diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index 418714bafc..bdc1309743 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -880,13 +880,13 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, nr_mac_trigger_release_timer(&UE->UE_sched_ctrl, UE->current_UL_BWP.scs); // Replace the current UE by the UE identified by C-RNTI - UE = find_nr_UE(&RC.nrmac[gnb_mod_idP]->UE_info, crnti); + UE = find_nr_UE(&gNB_mac->UE_info, crnti); if (!UE) { // The UE identified by C-RNTI no longer exists at the gNB // Let's abort the current RA, so the UE will trigger a new RA later but using RRCSetupRequest instead. A better // solution may be implemented LOG_W(NR_MAC, "No UE found with C-RNTI %04x, ignoring Msg3 to have UE come back with new RA attempt\n", ra->rnti); - mac_remove_nr_ue(RC.nrmac[gnb_mod_idP], ra->rnti); + mac_remove_nr_ue(gNB_mac, ra->rnti); nr_clear_ra_proc(ra); return; } @@ -899,6 +899,14 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, reset_dl_harq_list(&UE->UE_sched_ctrl); reset_ul_harq_list(&UE->UE_sched_ctrl); + // Switch to BWP where RA is configured, typically in the InitialBWP + // At this point, UE already switched and triggered RA in that BWP, need to do BWP switching also at gNB for C-RNTI + if (ra->DL_BWP.bwp_id != UE->current_DL_BWP.bwp_id || ra->UL_BWP.bwp_id != UE->current_UL_BWP.bwp_id) { + LOG_D(NR_MAC, "UE %04x Switch BWP from %ld to BWP id %ld\n", UE->rnti, UE->current_DL_BWP.bwp_id, ra->DL_BWP.bwp_id); + NR_ServingCellConfigCommon_t *scc = gNB_mac->common_channels[CC_idP].ServingCellConfigCommon; + configure_UE_BWP(gNB_mac, scc, &UE->UE_sched_ctrl, NULL, UE, ra->DL_BWP.bwp_id, ra->UL_BWP.bwp_id); + } + if (UE->reconfigCellGroup) { // Nothing to do // A RRCReconfiguration message should be already pending (for example, an ongoing RRCReestablishment), and it will be @@ -906,7 +914,7 @@ static void _nr_rx_sdu(const module_id_t gnb_mod_idP, } else { // Trigger RRC Reconfiguration LOG_I(NR_MAC, "Received UL_SCH_LCID_C_RNTI with C-RNTI 0x%04x, triggering RRC Reconfiguration\n", UE->rnti); - nr_mac_trigger_reconfiguration(RC.nrmac[gnb_mod_idP], UE); + nr_mac_trigger_reconfiguration(gNB_mac, UE); } } else { // UE Contention Resolution Identity