diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 0954a13287..006f126bd0 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -439,39 +439,41 @@ void init_eNB_afterRU(void) { } -void init_gNB(int wait_for_sync) { - - int inst; - PHY_VARS_gNB *gNB; - +/** + * @brief Initialize gNB struct in RAN context + */ +void init_gNB(int wait_for_sync) +{ + LOG_I(NR_PHY, "Initializing gNB threads wait_for_sync:%d\n", wait_for_sync); if (RC.gNB == NULL) { - RC.gNB = (PHY_VARS_gNB **) calloc(1+RC.nb_nr_L1_inst, sizeof(PHY_VARS_gNB *)); - LOG_D(PHY, "gNB L1 structure RC.gNB allocated @ %p\n", RC.gNB); + RC.gNB = (PHY_VARS_gNB **)calloc_or_fail(RC.nb_nr_L1_inst, sizeof(PHY_VARS_gNB *)); + LOG_D(NR_PHY, "gNB L1 structure RC.gNB allocated @ %p\n", RC.gNB); } - for (inst=0; instnrPolar_params, - NR_POLAR_PBCH_MESSAGE_TYPE, - NR_POLAR_PBCH_PAYLOAD_BITS, - NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ + PHY_VARS_gNB *gNB = RC.gNB[inst]; + LOG_D(NR_PHY, "Initializing gNB %d\n", inst); + // Init module ID + gNB->Mod_id = inst; + + // Register MAC interface module AssertFatal((gNB->if_inst = NR_IF_Module_init(inst)) != NULL, "Cannot register interface"); - gNB->if_inst->NR_Schedule_response = nr_schedule_response; - gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; - memset(&gNB->UL_INFO, 0, sizeof(gNB->UL_INFO)); + LOG_I(NR_PHY, "Registered with MAC interface module (%p)\n", gNB->if_inst); + // Set function pointers in MAC IF module + gNB->if_inst->NR_Schedule_response = nr_schedule_response; + gNB->if_inst->NR_PHY_config_req = nr_phy_config_request; + + // Clear UL_INFO and set rx/crc indication lists + memset((void *)&gNB->UL_INFO, 0, sizeof(gNB->UL_INFO)); gNB->UL_INFO.rx_ind.pdu_list = gNB->rx_pdu_list; gNB->UL_INFO.crc_ind.crc_list = gNB->crc_pdu_list; - /*gNB->UL_INFO.sr_ind.sr_indication_body.sr_pdu_list = gNB->sr_pdu_list; - gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list; - gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list; - gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;*/ gNB->prach_energy_counter = 0; gNB->chest_time = get_softmodem_params()->chest_time; @@ -479,7 +481,6 @@ void init_gNB(int wait_for_sync) { } } - void stop_gNB(int nb_inst) { for (int inst=0; inst