diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index ae5305d77c..e718210e8b 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -2718,8 +2718,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, AssertFatal(dl_bwp_switch == ul_bwp_switch, "Different UL and DL BWP not supported\n"); DL_BWP->bwp_id = dl_bwp_switch; UL_BWP->bwp_id = ul_bwp_switch; - } - else { + } else { // (re)configuring BWP // TODO BWP switching not via RRC reconfiguration // via RRC if firstActiveXlinkBWP_Id is NULL, MAC stays on the same BWP as before @@ -2768,8 +2767,7 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, UL_BWP->pusch_Config = ubwpd->pusch_Config->choice.setup; UL_BWP->pucch_Config = ubwpd->pucch_Config->choice.setup; UL_BWP->srs_Config = ubwpd->srs_Config->choice.setup; - } - else { + } else { DL_BWP->bwp_id = 0; UL_BWP->bwp_id = 0; DL_BWP->pdsch_Config = NULL; @@ -2778,11 +2776,6 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, UL_BWP->configuredGrantConfig = NULL; } - if (old_dl_bwp_id != DL_BWP->bwp_id) - LOG_I(NR_MAC, "Switching to DL-BWP %li\n", DL_BWP->bwp_id); - if (old_ul_bwp_id != UL_BWP->bwp_id) - LOG_I(NR_MAC, "Switching to UL-BWP %li\n", UL_BWP->bwp_id); - // TDA lists if (DL_BWP->bwp_id>0) DL_BWP->tdaList_Common = dl_bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList; @@ -2832,6 +2825,19 @@ void configure_UE_BWP(gNB_MAC_INST *nr_mac, UL_BWP->rach_ConfigCommon = scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; } + // if PRACH occasions are not configured for the active UL BWP + // switch the active UL BWP to BWP indicated by initialUplinkBWP + // as described in 5.15 of 38.321 + if (is_RA && !UL_BWP->rach_ConfigCommon) { + LOG_I(NR_MAC, "Cannot perform RA in current BWP, switching to initial BWP\n"); + configure_UE_BWP(nr_mac, scc, UE, is_RA, target_ss, 0, 0); + return; + } + if (old_dl_bwp_id != DL_BWP->bwp_id) + LOG_I(NR_MAC, "Switching to DL-BWP %li\n", DL_BWP->bwp_id); + if (old_ul_bwp_id != UL_BWP->bwp_id) + LOG_I(NR_MAC, "Switching to UL-BWP %li\n", UL_BWP->bwp_id); + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; // Reset required fields in sched_ctrl (e.g. ul_ri and tpmi) reset_sched_ctrl(sched_ctrl);