From 8ee0b8efdfbdda30047f0fdc059ca96dca68b2c3 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 14 Apr 2025 09:27:02 +0200 Subject: [PATCH] Introduce mac_top_destroy_gNB(): free MAC memory --- executables/nr-softmodem.c | 5 +++++ openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 3 +++ openair2/LAYER2/NR_MAC_gNB/main.c | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 24df549243..5a8464b60c 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -758,6 +758,11 @@ int main( int argc, char **argv ) { if (RC.nb_nr_L1_inst > 0 || RC.nb_RU > 0) stop_L1(0); + if (RC.nb_nr_macrlc_inst > 0) { + DevAssert(RC.nb_nr_macrlc_inst == 1); + mac_top_destroy_gNB(RC.nrmac[0]); + } + pthread_cond_destroy(&sync_cond); pthread_mutex_destroy(&sync_mutex); pthread_cond_destroy(&nfapi_sync_cond); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index dad0eb570c..8b403f9e86 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -47,10 +47,13 @@ int get_full_ul_slots_per_period(const frame_structure_t *fs); int get_full_dl_slots_per_period(const frame_structure_t *fs); int get_ul_slot_offset(const frame_structure_t *fs, int idx, bool count_mixed); +void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr, uid_allocator_t *uia); + void mac_top_init_gNB(ngran_node_t node_type, NR_ServingCellConfigCommon_t *scc, NR_ServingCellConfig_t *scd, const nr_mac_config_t *conf); +void mac_top_destroy_gNB(gNB_MAC_INST *mac); void nr_mac_send_f1_setup_req(void); void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, const nr_mac_config_t *mac_config); diff --git a/openair2/LAYER2/NR_MAC_gNB/main.c b/openair2/LAYER2/NR_MAC_gNB/main.c index acf0658e4c..099cb725e1 100644 --- a/openair2/LAYER2/NR_MAC_gNB/main.c +++ b/openair2/LAYER2/NR_MAC_gNB/main.c @@ -346,6 +346,19 @@ void mac_top_init_gNB(ngran_node_t node_type, srand48(0); } +void mac_top_destroy_gNB(gNB_MAC_INST *mac) +{ + NR_COMMON_channels_t *cc = &mac->common_channels[0]; + ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, cc->mib); + ASN_STRUCT_FREE(asn_DEF_NR_BCCH_DL_SCH_Message, cc->sib1); + ASN_STRUCT_FREE(asn_DEF_NR_ServingCellConfig, cc->pre_ServingCellConfig); + ASN_STRUCT_FREE(asn_DEF_NR_ServingCellConfigCommon, cc->ServingCellConfigCommon); + NR_UEs_t *UE_info = &mac->UE_info; + for (int i = 0; i < sizeofArray(UE_info->list); ++i) + if (UE_info->list[i]) + delete_nr_ue_data(UE_info->list[i], cc, &UE_info->uid_allocator); +} + void nr_mac_send_f1_setup_req(void) { gNB_MAC_INST *mac = RC.nrmac[0];