Correct nr_clear_ra_proc() for SA+NSA case, fix memory leak
In NSA, the RA process contains the RNTI of the UE to add. The previous implementation would not remove the RNTI in NSA/for CFRA, which is unclear (why should it stay? RA is over). Also, we did not clear all contents, which masked a bug, as we were reusing an RA process for a subsequent attach, leading to a segfault on reattach. That is fixed in this commit. Also, we were using the RA structure after having cleared it in _nr_rx_sdu(), which semantically makes no sense. To harmonize handling of the preambles: completely reset the RA processes inside nr_clear_ra_proc(). For SA, also add the initialization of allowed preambles. Finally, this commit fixes a memory leak: we always (also in SA) fill a list of preambles in a dynamically allocated preamble list. Since the total list is only up to 64 preambles of 1B each, put it directly into the struct instead of dynamically allocating it.
This commit is contained in:
@@ -603,7 +603,6 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, c
|
||||
DevAssert(nrmac != NULL);
|
||||
DevAssert(scc != NULL);
|
||||
DevAssert(config != NULL);
|
||||
//NR_SCHED_LOCK(&nrmac->sched_lock);
|
||||
|
||||
AssertFatal(scc->ssb_PositionsInBurst->present > 0 && scc->ssb_PositionsInBurst->present < 4,
|
||||
"SSB Bitmap type %d is not valid\n",
|
||||
@@ -668,19 +667,13 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, c
|
||||
nrmac->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(0);
|
||||
}
|
||||
|
||||
if (get_softmodem_params()->sa > 0) {
|
||||
NR_COMMON_channels_t *cc = &nrmac->common_channels[0];
|
||||
for (int n = 0; n < NR_NB_RA_PROC_MAX; n++) {
|
||||
NR_RA_t *ra = &cc->ra[n];
|
||||
ra->cfra = false;
|
||||
ra->rnti = 0;
|
||||
ra->preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
|
||||
ra->preambles.preamble_list = malloc(MAX_NUM_NR_PRACH_PREAMBLES * sizeof(*ra->preambles.preamble_list));
|
||||
for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
|
||||
ra->preambles.preamble_list[i] = i;
|
||||
}
|
||||
NR_COMMON_channels_t *cc = &nrmac->common_channels[0];
|
||||
NR_SCHED_LOCK(&nrmac->sched_lock);
|
||||
for (int n = 0; n < NR_NB_RA_PROC_MAX; n++) {
|
||||
NR_RA_t *ra = &cc->ra[n];
|
||||
nr_clear_ra_proc(ra);
|
||||
}
|
||||
//NR_SCHED_UNLOCK(&nrmac->sched_lock);
|
||||
NR_SCHED_UNLOCK(&nrmac->sched_lock);
|
||||
}
|
||||
|
||||
void nr_mac_configure_sib1(gNB_MAC_INST *nrmac, const f1ap_plmn_t *plmn, uint64_t cellID, int tac)
|
||||
@@ -749,7 +742,6 @@ bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig
|
||||
struct NR_CFRA *cfra = CellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra;
|
||||
uint8_t num_preamble = cfra->resources.choice.ssb->ssb_ResourceList.list.count;
|
||||
ra->preambles.num_preambles = num_preamble;
|
||||
ra->preambles.preamble_list = calloc(ra->preambles.num_preambles, sizeof(*ra->preambles.preamble_list));
|
||||
for (int i = 0; i < cc->num_active_ssb; i++) {
|
||||
for (int j = 0; j < num_preamble; j++) {
|
||||
if (cc->ssb_index[i] == cfra->resources.choice.ssb->ssb_ResourceList.list.array[j]->ssb) {
|
||||
|
||||
@@ -2017,11 +2017,12 @@ void nr_clear_ra_proc(NR_RA_t *ra)
|
||||
{
|
||||
/* we assume that this function is mutex-protected from outside */
|
||||
NR_SCHED_ENSURE_LOCKED(&RC.nrmac[0]->sched_lock);
|
||||
memset(ra, 0, sizeof(*ra));
|
||||
ra->ra_state = nrRA_gNB_IDLE;
|
||||
ra->timing_offset = 0;
|
||||
ra->msg3_round = 0;
|
||||
if(ra->cfra == false) {
|
||||
ra->rnti = 0;
|
||||
if (get_softmodem_params()->sa) { // in SA, prefill with allowed preambles
|
||||
ra->preambles.num_preambles = MAX_NUM_NR_PRACH_PREAMBLES;
|
||||
for (int i = 0; i < MAX_NUM_NR_PRACH_PREAMBLES; i++)
|
||||
ra->preambles.preamble_list[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -851,8 +851,8 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP,
|
||||
nr_mac_reset_ul_failure(UE_scheduling_control);
|
||||
reset_dl_harq_list(UE_scheduling_control);
|
||||
reset_ul_harq_list(UE_scheduling_control);
|
||||
nr_clear_ra_proc(ra);
|
||||
process_addmod_bearers_cellGroupConfig(&UE->UE_sched_ctrl, ra->CellGroup->rlc_BearerToAddModList);
|
||||
nr_clear_ra_proc(ra);
|
||||
} else {
|
||||
LOG_A(NR_MAC, "[RAPROC] RA-Msg3 received (sdu_lenP %d)\n", sdu_lenP);
|
||||
LOG_D(NR_MAC, "[RAPROC] Received Msg3:\n");
|
||||
|
||||
@@ -159,7 +159,7 @@ typedef struct nr_mac_config_t {
|
||||
|
||||
typedef struct NR_preamble_ue {
|
||||
uint8_t num_preambles;
|
||||
uint8_t *preamble_list;
|
||||
uint8_t preamble_list[MAX_NUM_NR_PRACH_PREAMBLES];
|
||||
} NR_preamble_ue_t;
|
||||
|
||||
typedef struct NR_sched_pdcch {
|
||||
|
||||
Reference in New Issue
Block a user