From e74792586f61e3f6a08f82d8395e0eb37b80f0b8 Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Wed, 17 Dec 2025 18:05:32 +0100 Subject: [PATCH] fix BWP switching Co-authored-by: Luis Pereira --- .../NR_MAC_gNB/gNB_scheduler_primitives.c | 5 ++--- openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c | 17 +++++------------ openair2/LAYER2/NR_MAC_gNB/nr_radio_config.h | 1 - 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 5e611e4150..0f614e53f8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -3933,7 +3933,8 @@ void nr_mac_trigger_reconfiguration(const gNB_MAC_INST *nrmac, NR_UE_info_t *UE, buf, sizeof(buf)); AssertFatal(enc_rval.encoded > 0, "ASN1 encoding of CellGroupConfig failed, failed type %s\n", enc_rval.failed_type->name); - UE->reestablish_rlc = true; + ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, UE->reconfigCellGroup); + UE->reconfigCellGroup = cellGroup_for_UE; du_to_cu_rrc_information_t du2cu = { .cellGroupConfig = buf, .cellGroupConfig_length = (enc_rval.encoded + 7) >> 3, @@ -3947,8 +3948,6 @@ void nr_mac_trigger_reconfiguration(const gNB_MAC_INST *nrmac, NR_UE_info_t *UE, .cause_value = F1AP_CauseRadioNetwork_action_desirable_for_radio_reasons, }; nrmac->mac_rrc.ue_context_modification_required(&required); - if (cellGroup_for_UE) - free_cellGroupConfig(cellGroup_for_UE); } long get_lcid_from_drbid(int drb_id) diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c b/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c index a56d6e5ef8..efe6fe1391 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c +++ b/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.c @@ -3813,14 +3813,12 @@ NR_CellGroupConfig_t *update_cellGroupConfig_for_BWP_switch(NR_CellGroupConfig_t // we temporarily need to keep both the old and the new BWP in the CG used by the gNB // while removing the old from the CG sent to the UE - if (old_bwp > 0) { - NR_CellGroupConfig_t *clone_cg = NULL; - const int copy_result = asn_copy(&asn_DEF_NR_CellGroupConfig, (void **)&clone_cg, cellGroupConfig); - AssertFatal(copy_result == 0, "unable to copy NR_CellGroupConfig for cloning\n"); + NR_CellGroupConfig_t *clone_cg = NULL; + const int copy_result = asn_copy(&asn_DEF_NR_CellGroupConfig, (void **)&clone_cg, cellGroupConfig); + AssertFatal(copy_result == 0, "unable to copy NR_CellGroupConfig for cloning\n"); + if (old_bwp > 0) clean_bwp_structures(clone_cg->spCellConfig); - return clone_cg; - } - return NULL; + return clone_cg; } void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, @@ -3933,11 +3931,6 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, } } -void free_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig) -{ - ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, cellGroupConfig); -} - int encode_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, uint8_t *buffer, int max_buffer_size) { asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, cellGroupConfig, buffer, max_buffer_size); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.h b/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.h index b776d667d6..27cca60b26 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_radio_config.h @@ -96,7 +96,6 @@ void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, const NR_UE_NR_Capability_t *uecap, const nr_mac_config_t *configuration, const NR_ServingCellConfigCommon_t *scc); -void free_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig); int encode_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, uint8_t *buffer, int max_buffer_size); NR_CellGroupConfig_t *decode_cellGroupConfig(const uint8_t *buffer, int max_buffer_size);