Commit 4828a1e7 authored by Sakthivel Velumani's avatar Sakthivel Velumani

Add check function to NR_list

Add macro to iterate NR_list
use NR_list for group LCID for each slice in sched_ctrl of UE
update nssai setting function in mac_rlc_dl_handler.c to update LCID groups when adding DRBs. Also remove LCID from group when needed.
parent 7e034415
......@@ -1241,8 +1241,9 @@ void nr_schedule_ue_spec(module_id_t module_id,
if (sched_ctrl->sliceInfo[sched_ctrl->curSchedSliceIdx].num_total_bytes > 0) {
/* loop over all activated logical channels in current slice */
for (int i = 0; i < sched_ctrl->sliceInfo[sched_ctrl->curSchedSliceIdx].numLcids; ++i) {
const int lcid = sched_ctrl->sliceInfo[sched_ctrl->curSchedSliceIdx].lcid[i];
NR_List_Iterator(&sched_ctrl->sliceInfo[sched_ctrl->curSchedSliceIdx].lcid, cur_lcidP)
{
const int lcid = *cur_lcidP;
if (sched_ctrl->rlc_status[lcid].bytes_in_buffer == 0)
continue; // no data for this LC tbs_size_t len = 0;
......
......@@ -1868,7 +1868,7 @@ void add_nr_list(NR_list_t *listP, int id)
{
int *cur = &listP->head;
while (*cur >= 0) {
AssertFatal(*cur != id, "id %d already in NR_UE_list!\n", id);
AssertFatal(*cur != id, "id %d already in NR_list!\n", id);
cur = &listP->next[*cur];
}
*cur = id;
......@@ -1932,6 +1932,20 @@ void remove_front_nr_list(NR_list_t *listP)
listP->tail = -1;
}
/*
* Check if the id is in the list
*/
bool check_nr_list(const NR_list_t *listP, int id)
{
const int *cur = &listP->head;
while (*cur >= 0) {
if (*cur == id)
return true;
cur = &listP->next[*cur];
}
return false;
}
NR_UE_info_t *find_nr_UE(NR_UEs_t *UEs, rnti_t rntiP)
{
......@@ -1982,7 +1996,7 @@ int get_nrofHARQ_ProcessesForPDSCH(e_NR_PDSCH_ServingCellConfig__nrofHARQ_Proces
}
}
void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr, uid_allocator_t *uia)
void delete_nr_ue_data(gNB_MAC_INST *nr_mac, NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr, uid_allocator_t *uia)
{
ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, UE->CellGroup);
ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, UE->reconfigCellGroup);
......@@ -1996,6 +2010,9 @@ void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr, uid_alloca
destroy_nr_list(&sched_ctrl->retrans_ul_harq);
free_sched_pucch_list(sched_ctrl);
uid_linear_allocator_free(uia, UE->uid);
for (int slice = 0; slice < nr_mac->numSlices; slice++) {
destroy_nr_list(&sched_ctrl->sliceInfo[slice].lcid);
}
LOG_I(NR_MAC, "Remove NR rnti 0x%04x\n", UE->rnti);
free(UE);
}
......@@ -2358,6 +2375,11 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf
reset_srs_stats(UE);
/* prepare LC list for all slices in this UE */
for (int slice = 0; slice < nr_mac->numSlices; slice++) {
create_nr_list(&sched_ctrl->sliceInfo[slice].lcid, NR_MAX_NUM_LCID);
}
NR_SCHED_LOCK(&UE_info->mutex);
int i;
for(i=0; i<MAX_MOBILES_PER_GNB; i++) {
......@@ -2368,7 +2390,7 @@ NR_UE_info_t *add_new_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rntiP, NR_CellGroupConf
}
if (i == MAX_MOBILES_PER_GNB) {
LOG_E(NR_MAC,"Try to add UE %04x but the list is full\n", rntiP);
delete_nr_ue_data(UE, nr_mac->common_channels, &UE_info->uid_allocator);
delete_nr_ue_data(nr_mac, UE, nr_mac->common_channels, &UE_info->uid_allocator);
NR_SCHED_UNLOCK(&UE_info->mutex);
return NULL;
}
......@@ -2505,7 +2527,7 @@ void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti)
memcpy(UE_info->list, newUEs, sizeof(UE_info->list));
NR_SCHED_UNLOCK(&UE_info->mutex);
delete_nr_ue_data(UE, nr_mac->common_channels, &UE_info->uid_allocator);
delete_nr_ue_data(nr_mac, UE, nr_mac->common_channels, &UE_info->uid_allocator);
}
uint8_t nr_get_tpc(int target, uint8_t cqi, int incr) {
......
......@@ -298,6 +298,7 @@ void remove_nr_list(NR_list_t *listP, int id);
void add_tail_nr_list(NR_list_t *listP, int id);
void add_front_nr_list(NR_list_t *listP, int id);
void remove_front_nr_list(NR_list_t *listP);
bool check_nr_list(const NR_list_t *listP, int id);
NR_UE_info_t * find_nr_UE(NR_UEs_t* UEs, rnti_t rntiP);
......
......@@ -241,8 +241,53 @@ static int get_idx_from_lcid(const NR_UE_sched_ctrl_t *sched_ctrl, int lcid)
return -1;
}
static void set_nssaiConfig(const int drb_len, const f1ap_drb_to_be_setup_t *req_drbs, NR_UE_sched_ctrl_t *sched_ctrl)
static int get_slice_index(nssai_t nssai)
{
gNB_MAC_INST *mac = RC.nrmac[0];
for (int i = 0; i < mac->numSlices; i++) {
if (mac->sliceConfig[i].nssai.sd == nssai.sd && mac->sliceConfig[i].nssai.sst == nssai.sst) {
return i;
}
}
return -1;
}
static void set_nssaiConfig(const int srb_len,
const f1ap_srb_to_be_setup_t *req_srbs,
const int drb_len,
const f1ap_drb_to_be_setup_t *req_drbs,
const int drb_rel_len,
const f1ap_drb_to_be_released_t *req_drbs_rel,
NR_UE_sched_ctrl_t *sched_ctrl)
{
gNB_MAC_INST *mac = RC.nrmac[0];
for (int i = 0; i < drb_rel_len; i++) {
const f1ap_drb_to_be_released_t *drb = req_drbs_rel;
long lcid = get_lcid_from_drbid(drb->rb_id);
for (int s = 0; s < sched_ctrl->numSlices; s++) {
if (check_nr_list(&sched_ctrl->sliceInfo[s].lcid, lcid)) {
remove_nr_list(&sched_ctrl->sliceInfo[s].lcid, lcid);
break;
}
}
}
for (int i = 0; i < srb_len; i++) {
const f1ap_srb_to_be_setup_t *srb = &req_srbs[i];
long lcid = get_lcid_from_srbid(srb->srb_id);
int lcid_idx = get_idx_from_lcid(sched_ctrl, lcid);
DevAssert(lcid_idx > -1);
// set default slice for SRB
nssai_t *default_nssai = &mac->sliceConfig[0].nssai;
sched_ctrl->dl_lc[lcid_idx].nssai = *default_nssai;
add_nr_list(&sched_ctrl->sliceInfo[0].lcid, lcid);
LOG_I(NR_MAC, "Setting default NSSAI sst: %d, sd: %d for SRB: %ld\n", default_nssai->sst, default_nssai->sd, srb->srb_id);
}
for (int i = 0; i < drb_len; i++) {
const f1ap_drb_to_be_setup_t *drb = &req_drbs[i];
......@@ -250,6 +295,8 @@ static void set_nssaiConfig(const int drb_len, const f1ap_drb_to_be_setup_t *req
int lcid_idx = get_idx_from_lcid(sched_ctrl, lcid);
DevAssert(lcid_idx > -1);
sched_ctrl->dl_lc[lcid_idx].nssai = drb->nssai;
int sliceIdx = get_slice_index(drb->nssai);
add_nr_list(&sched_ctrl->sliceInfo[sliceIdx].lcid, lcid);
LOG_I(NR_MAC, "Setting NSSAI sst: %d, sd: %d for DRB: %ld\n", drb->nssai.sst, drb->nssai.sd, drb->drb_id);
}
}
......@@ -320,8 +367,14 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req)
/* TODO: need to apply after UE context reconfiguration confirmed? */
nr_mac_prepare_cellgroup_update(mac, UE, new_CellGroup);
/* Set NSSAI config in MAC for each active DRB */
set_nssaiConfig(req->drbs_to_be_setup_length, req->drbs_to_be_setup, &UE->UE_sched_ctrl);
/* Set NSSAI config in MAC for each active SRB & DRB */
set_nssaiConfig(req->srbs_to_be_setup_length,
req->srbs_to_be_setup,
req->drbs_to_be_setup_length,
req->drbs_to_be_setup,
req->drbs_to_be_released_length,
req->drbs_to_be_released,
&UE->UE_sched_ctrl);
NR_SCHED_UNLOCK(&mac->sched_lock);
......@@ -420,8 +473,14 @@ void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req)
nr_mac_prepare_cellgroup_update(mac, UE, new_CellGroup);
/* Set NSSAI config in MAC for each active DRB */
set_nssaiConfig(req->drbs_to_be_setup_length, req->drbs_to_be_setup, &UE->UE_sched_ctrl);
/* Set NSSAI config in MAC for each active SRB & DRB */
set_nssaiConfig(req->srbs_to_be_setup_length,
req->srbs_to_be_setup,
req->drbs_to_be_setup_length,
req->drbs_to_be_setup,
req->drbs_to_be_released_length,
req->drbs_to_be_released,
&UE->UE_sched_ctrl);
} else {
ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, new_CellGroup); // we actually don't need it
}
......
......@@ -111,6 +111,8 @@ typedef struct {
int len;
} NR_list_t;
#define NR_List_Iterator(BaSe, CuR) for (int *CuR = &(BaSe)->head, *nxt = (BaSe)->next; *CuR >= 0; CuR = &nxt[*CuR])
typedef enum {
RA_IDLE = 0,
Msg2 = 1,
......@@ -542,11 +544,8 @@ typedef struct {
} NR_LC_info_t;
typedef struct {
/// the index of slice from slice config stored in gNB_MAC_INST
int sliceIdx;
/// LCs in this slice
uint8_t numLcids;
uint8_t lcid[NR_MAX_NUM_LCID];
NR_list_t lcid;
/// total amount of data awaiting for this UE for each slice
uint32_t num_total_bytes;
uint16_t dl_pdus_total;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment