diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index 8b30bf78f0..35b6fa509a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -1065,6 +1065,24 @@ bool nr_update_sib19(const gnb_sat_position_update_t *sat_position) return true; } +bool nr_trigger_bwp_switch(uint16_t rnti, int bwp_id) +{ + gNB_MAC_INST *nrmac = RC.nrmac[0]; + NR_SCHED_LOCK(&nrmac->sched_lock); + NR_UE_info_t *UE = find_nr_UE(&nrmac->UE_info, rnti); + bool success = false; + if (!UE) { + LOG_W(NR_MAC, "could not find UE for RNTI %04x\n", rnti); + } else if (UE->current_DL_BWP.bwp_id == bwp_id) { + LOG_W(NR_MAC, "UE %04x is already on BWP ID %d, not triggering reconfiguration\n", rnti, bwp_id); + } else { // UE != NULL && current_DL_BWP.bwp_id != bwp_id + nr_mac_trigger_reconfiguration(nrmac, UE, bwp_id); + success = true; + } + NR_SCHED_UNLOCK(&nrmac->sched_lock); + return success; +} + void prepare_du_configuration_update(gNB_MAC_INST *mac, f1ap_served_cell_info_t *info, NR_BCCH_BCH_Message_t *mib, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_config.h b/openair2/LAYER2/NR_MAC_gNB/mac_config.h index 1fdbe62115..6089d39975 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_config.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_config.h @@ -43,4 +43,6 @@ typedef struct gnb_sat_position_update_s { bool nr_update_sib19(const gnb_sat_position_update_t *sat_position); +bool nr_trigger_bwp_switch(uint16_t rnti, int bwp_id); + #endif /*__LAYER2_NR_MAC_CONFIG_H__*/