Commit d8c7ff4c authored by Guido Casati's avatar Guido Casati

Refactor init_gNB()

* code cleanup
* clang-formatted
* adopted calloc_or_fail
* allocate nb_nr_L1_inst of RC.gNB instead of (RC.nb_nr_L1_inst + 1)
parent 220d851d
...@@ -439,39 +439,41 @@ void init_eNB_afterRU(void) { ...@@ -439,39 +439,41 @@ void init_eNB_afterRU(void) {
} }
void init_gNB(int wait_for_sync) { /**
* @brief Initialize gNB struct in RAN context
int inst; */
PHY_VARS_gNB *gNB; 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) { if (RC.gNB == NULL) {
RC.gNB = (PHY_VARS_gNB **) calloc(1+RC.nb_nr_L1_inst, sizeof(PHY_VARS_gNB *)); RC.gNB = (PHY_VARS_gNB **)calloc_or_fail(RC.nb_nr_L1_inst, sizeof(PHY_VARS_gNB *));
LOG_D(PHY, "gNB L1 structure RC.gNB allocated @ %p\n", RC.gNB); LOG_D(NR_PHY, "gNB L1 structure RC.gNB allocated @ %p\n", RC.gNB);
} }
for (inst=0; inst<RC.nb_nr_L1_inst; inst++) { for (int inst = 0; inst < RC.nb_nr_L1_inst; inst++) {
// Allocate L1 instance
if (RC.gNB[inst] == NULL) { if (RC.gNB[inst] == NULL) {
RC.gNB[inst] = (PHY_VARS_gNB *) calloc(1, sizeof(PHY_VARS_gNB)); RC.gNB[inst] = (PHY_VARS_gNB *)calloc_or_fail(1, sizeof(PHY_VARS_gNB));
LOG_D(PHY, "[nr-gnb.c] gNB structure RC.gNB[%d] allocated @ %p\n", inst, RC.gNB[inst]); LOG_D(NR_PHY, "[nr-gnb.c] gNB structure RC.gNB[%d] allocated @ %p\n", inst, RC.gNB[inst]);
} }
gNB = RC.gNB[inst]; PHY_VARS_gNB *gNB = RC.gNB[inst];
/*nr_polar_init(&gNB->nrPolar_params, LOG_D(NR_PHY, "Initializing gNB %d\n", inst);
NR_POLAR_PBCH_MESSAGE_TYPE,
NR_POLAR_PBCH_PAYLOAD_BITS, // Init module ID
NR_POLAR_PBCH_AGGREGATION_LEVEL);*/ gNB->Mod_id = inst;
// Register MAC interface module
AssertFatal((gNB->if_inst = NR_IF_Module_init(inst)) != NULL, "Cannot register interface"); AssertFatal((gNB->if_inst = NR_IF_Module_init(inst)) != NULL, "Cannot register interface");
gNB->if_inst->NR_Schedule_response = nr_schedule_response; LOG_I(NR_PHY, "Registered with MAC interface module (%p)\n", gNB->if_inst);
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
memset(&gNB->UL_INFO, 0, sizeof(gNB->UL_INFO));
// 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.rx_ind.pdu_list = gNB->rx_pdu_list;
gNB->UL_INFO.crc_ind.crc_list = gNB->crc_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->prach_energy_counter = 0;
gNB->chest_time = get_softmodem_params()->chest_time; gNB->chest_time = get_softmodem_params()->chest_time;
...@@ -479,7 +481,6 @@ void init_gNB(int wait_for_sync) { ...@@ -479,7 +481,6 @@ void init_gNB(int wait_for_sync) {
} }
} }
void stop_gNB(int nb_inst) { void stop_gNB(int nb_inst) {
for (int inst=0; inst<nb_inst; inst++) { for (int inst=0; inst<nb_inst; inst++) {
LOG_I(PHY,"Killing gNB %d processing threads\n",inst); LOG_I(PHY,"Killing gNB %d processing threads\n",inst);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment