From 72bfd1b5c3280725b44203f697cf98ebc84cebac Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 25 Aug 2025 19:04:22 +0200 Subject: [PATCH 1/2] switch to initial BWP if current BWP has no PRACH in gNB --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) 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); From 47554f89ce19ac89ecba526b357b139d2fe9418f Mon Sep 17 00:00:00 2001 From: francescomani Date: Mon, 25 Aug 2025 16:14:56 +0200 Subject: [PATCH 2/2] fix switch to initial UL BWP if no PRACH common configuration in current BWP --- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 58269f769a..42712ebbb4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -879,23 +879,23 @@ bool init_RA(NR_UE_MAC_INST_t *mac, int frame) // set POWER_OFFSET_2STEP_RA to 0 dB prach_resources->power_offset_2step = 0; - const NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; // perform the BWP operation as specified in clause 5.15 // if PRACH occasions are not configured for the active UL BWP - if (!current_UL_BWP->rach_ConfigCommon) { + if (!mac->current_UL_BWP->rach_ConfigCommon) { // switch the active UL BWP to BWP indicated by initialUplinkBWP - current_UL_BWP = get_ul_bwp_structure(mac, 0, false); + mac->current_UL_BWP = get_ul_bwp_structure(mac, 0, false); // if the Serving Cell is an SpCell // switch the active DL BWP to BWP indicated by initialDownlinkBWP mac->current_DL_BWP = get_dl_bwp_structure(mac, 0, false); } else { // if the active DL BWP does not have the same bwp-Id as the active UL BWP - if (current_UL_BWP->bwp_id != mac->current_DL_BWP->bwp_id) { + if (mac->current_UL_BWP->bwp_id != mac->current_DL_BWP->bwp_id) { // switch the active DL BWP to the DL BWP with the same bwp-Id as the active UL BWP mac->current_DL_BWP = get_dl_bwp_structure(mac, 0, false); } } + const NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = current_UL_BWP->rach_ConfigCommon; AssertFatal(nr_rach_ConfigCommon, "rach-ConfigCommon should be configured here\n"); // stop the bwp-InactivityTimer associated with the active DL BWP of this Serving Cell, if running