From 31cf9ab84760eea32a49f959420d46ef6645d286 Mon Sep 17 00:00:00 2001 From: rmagueta Date: Tue, 23 Feb 2021 02:22:27 +0000 Subject: [PATCH] Fix ra->rnti --- openair1/PHY/defs_gNB.h | 1 + openair2/LAYER2/NR_MAC_gNB/config.c | 7 +++++++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 20 ++++++++++--------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index b7923adb0b..f3f212effb 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -655,6 +655,7 @@ typedef struct { int prach_I0; } PHY_MEASUREMENTS_gNB; +#define TOTAL_NUM_NR_PRACH_PREAMBLES 64 #define MAX_NUM_NR_RX_RACH_PDUS 4 #define MAX_NUM_NR_RX_PRACH_PREAMBLES 4 #define MAX_UL_PDUS_PER_SLOT 8 diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 6aa906b82b..6f6ea8a327 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -416,6 +416,13 @@ int rrc_mac_config_req_gNB(module_id_t Mod_idP, for (int i = 0; i < num_preamble; i++) ra->preambles.preamble_list[i] = cfra.resources.choice.ssb->ssb_ResourceList.list.array[i]->ra_PreambleIndex; } + } else { + ra->cfra = false; + ra->rnti = rnti; + ra->preambles.num_preambles = TOTAL_NUM_NR_PRACH_PREAMBLES; + ra->preambles.preamble_list = (uint8_t *) malloc(TOTAL_NUM_NR_PRACH_PREAMBLES*sizeof(uint8_t)); + for (int i = 0; i < TOTAL_NUM_NR_PRACH_PREAMBLES; i++) + ra->preambles.preamble_list[i] = i; } LOG_I(PHY,"Added new RA process for UE RNTI %04x with initial secondaryCellGroup\n", rnti); } else { // secondaryCellGroup has been updated diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 037b0f16af..0b3492ccdc 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -454,15 +454,11 @@ void nr_initiate_ra_proc(module_id_t module_idP, // if the preamble received correspond to one of the listed // the UE sent a RACH either for starting RA procedure or RA procedure failed and UE retries int pr_found=0; - if(ra->preambles.num_preambles > 0) { - for (int i = 0; i < ra->preambles.num_preambles; i++) { - if (preamble_index == ra->preambles.preamble_list[i]) { - pr_found=1; - break; - } + for (int i = 0; i < ra->preambles.num_preambles; i++) { + if (preamble_index == ra->preambles.preamble_list[i]) { + pr_found=1; + break; } - } else { - pr_found=1; } if (!pr_found) { @@ -487,7 +483,7 @@ void nr_initiate_ra_proc(module_id_t module_idP, preamble_index, freq_index, symbol); - int loop = 0; + LOG_D(MAC, "Frame %d, Slot %d: Activating RA process \n", frameP, slotP); ra->state = Msg2; ra->timing_offset = timing_offset; @@ -514,6 +510,10 @@ void nr_initiate_ra_proc(module_id_t module_idP, ra->Msg2_slot = msg2_slot; LOG_I(MAC, "%s() Msg2[%04d%d] SFN/SF:%04d%d\n", __FUNCTION__, ra->Msg2_frame, ra->Msg2_slot, frameP, slotP); + + // TODO: Configure RRC with the new RNTI of the following commented lines + /* + int loop = 0; if (!ra->cfra) { do { ra->rnti = (taus() % 65518) + 1; @@ -525,6 +525,8 @@ void nr_initiate_ra_proc(module_id_t module_idP, abort(); } } + */ + ra->RA_rnti = ra_rnti; ra->preamble_index = preamble_index; ra->beam_id = beam_index;