diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 36a798cfff..e889bd27ab 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -981,18 +981,18 @@ void *UE_thread(void *arg) void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconfig_file) { - NR_UE_MAC_INST_t *mac_inst; - NR_UE_RRC_INST_t* rrc_inst; - - for (int inst = 0; inst < nb_inst; inst++) { - AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file)) != NULL, "can not initialize RRC module\n"); - AssertFatal((mac_inst = nr_l2_init_ue()) != NULL, "can not initialize L2 module\n"); - AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n"); + NR_UE_RRC_INST_t *rrc_inst = nr_rrc_init_ue(uecap_file, nb_inst); + NR_UE_MAC_INST_t *mac_inst = nr_l2_init_ue(nb_inst); + AssertFatal(mac_inst, "Couldn't allocate MAC module\n"); + + for (int i = 0; i < nb_inst; i++) { + NR_UE_MAC_INST_t *mac = get_mac_inst(i); + AssertFatal((mac->if_module = nr_ue_if_module_init(i)) != NULL, "can not initialize IF module\n"); if (!get_softmodem_params()->sa) { - init_nsa_message(rrc_inst, reconfig_file, rbconfig_file); + init_nsa_message(&rrc_inst[i], reconfig_file, rbconfig_file); // TODO why do we need noS1 configuration? // temporarily moved here to understand why not using the one provided by gNB - nr_rlc_activate_srb0(mac_inst->crnti, NULL, send_srb0_rrc); + nr_rlc_activate_srb0(mac->crnti, NULL, send_srb0_rrc); if (IS_SOFTMODEM_NOS1) { // get default noS1 configuration NR_RadioBearerConfig_t *rbconfig = NULL; @@ -1001,8 +1001,8 @@ void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconf // set up PDCP, RLC, MAC nr_pdcp_layer_init(false); - nr_pdcp_add_drbs(ENB_FLAG_NO, inst, rbconfig->drb_ToAddModList, 0, NULL, NULL); - nr_rlc_add_drb(mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig); + nr_pdcp_add_drbs(ENB_FLAG_NO, i, rbconfig->drb_ToAddModList, 0, NULL, NULL); + nr_rlc_add_drb(mac->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig); struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_toadd_list; rlc_toadd_list.list.count = 1; rlc_toadd_list.list.array = calloc(1, sizeof(NR_RLC_BearerConfig_t)); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 62f5e4b772..6fe411c253 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -454,7 +454,8 @@ configmodule_interface_t *uniqCfg = NULL; // A global var to reduce the changes size ldpc_interface_t ldpc_interface = {0}, ldpc_interface_offload = {0}; -int main( int argc, char **argv ) { +int main(int argc, char **argv) +{ int set_exe_prio = 1; if (checkIfFedoraDistribution()) if (checkIfGenericKernelOnFedora()) @@ -509,7 +510,7 @@ int main( int argc, char **argv ) { memset(PHY_vars_UE_g[0][CC_id], 0, sizeof(*PHY_vars_UE_g[0][CC_id])); } - init_NR_UE(1, uecap_file, reconfig_file, rbconfig_file); + init_NR_UE(NB_UE_INST, uecap_file, reconfig_file, rbconfig_file); int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1; uint16_t node_number = get_softmodem_params()->node_number; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 30e84a8837..4572b5f75c 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -849,7 +849,7 @@ int main(int argc, char **argv) nr_gold_pdsch(UE, i, UE->scramblingID_dlsch[i]); } - nr_l2_init_ue(); + nr_l2_init_ue(1); UE_mac = get_mac_inst(0); ue_init_config_request(UE_mac, mu); diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 684a8385d1..9b227f3b7a 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -690,8 +690,7 @@ int main(int argc, char *argv[]) } //Configure UE - nr_l2_init_ue(); - + nr_l2_init_ue(1); NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); ue_init_config_request(UE_mac, mu); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 43125659a9..378411abca 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -68,7 +68,6 @@ // NR UE defs // ========== -#define NB_NR_UE_MAC_INST 1 #define MAX_NUM_BWP_UE 5 #define NUM_SLOT_FRAME 10 @@ -452,6 +451,7 @@ typedef struct { /*!\brief Top level UE MAC structure */ typedef struct { + module_id_t ue_id; NR_UE_L2_STATE_t state; int servCellIndex; long physCellId; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 9d955580b2..4145b49f49 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -197,10 +197,10 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t cause); -/**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/ -NR_UE_MAC_INST_t * nr_l2_init_ue(); +/**\brief initialization NR UE MAC instance(s)*/ +NR_UE_MAC_INST_t * nr_l2_init_ue(int nb_inst); -/**\brief fetch MAC instance by module_id, within 0 - (NB_NR_UE_MAC_INST-1) +/**\brief fetch MAC instance by module_id \param module_id index of MAC instance(s)*/ NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 83b5d7867b..31b395a439 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -112,26 +112,32 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) } } -NR_UE_MAC_INST_t *nr_l2_init_ue() +NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst) { //init mac here - nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(NB_NR_UE_MAC_INST, sizeof(NR_UE_MAC_INST_t)); + nr_ue_mac_inst = (NR_UE_MAC_INST_t *)calloc(nb_inst, sizeof(NR_UE_MAC_INST_t)); + AssertFatal(nr_ue_mac_inst, "Couldn't allocate %d instances of MAC module\n", nb_inst); - for (int j = 0; j < NB_NR_UE_MAC_INST; j++) { + for (int j = 0; j < nb_inst; j++) { nr_ue_init_mac(j); NR_UE_MAC_INST_t *mac = get_mac_inst(j); + mac->ue_id = j; nr_ue_mac_default_configs(mac); if (get_softmodem_params()->sa) ue_init_config_request(mac, get_softmodem_params()->numerology); } + int rc = rlc_module_init(0); - AssertFatal(rc == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__); + AssertFatal(rc == 0, "Could not initialize RLC layer\n"); return (nr_ue_mac_inst); } -NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id) { - return &nr_ue_mac_inst[(int)module_id]; +NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id) +{ + NR_UE_MAC_INST_t *mac = &nr_ue_mac_inst[(int)module_id]; + AssertFatal(mac, "Couldn't get MAC inst %d\n", module_id); + return mac; } void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index be2c785b7b..640caf5dad 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2409,7 +2409,6 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *p int8_t nr_ue_get_SR(module_id_t module_idP, frame_t frameP, slot_t slot) { // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti - DevCheck(module_idP < NB_NR_UE_MAC_INST, module_idP, NB_NR_UE_MAC_INST, 0); NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP); NR_UE_SCHEDULING_INFO *si = &mac->scheduling_info; int max_sr_transmissions = (1 << (2 + si->sr_TransMax)); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 7c7ee584a2..f678b2a0ca 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -308,9 +308,8 @@ rlc_op_status_t rlc_data_req(const protocol_ctxt_t *const ctxt_pP, nr_rlc_ue_t *ue; nr_rlc_entity_t *rb; - LOG_D(RLC, "%s rnti %d srb_flag %d rb_id %ld mui %d confirm %d sdu_size %d MBMS_flag %d\n", - __FUNCTION__, rnti, srb_flagP, rb_idP, muiP, confirmP, sdu_sizeP, - MBMS_flagP); + LOG_D(RLC, "rnti %d srb_flag %d rb_id %ld mui %d confirm %d sdu_size %d MBMS_flag %d\n", + rnti, srb_flagP, rb_idP, muiP, confirmP, sdu_sizeP, MBMS_flagP); if (ctxt_pP->enb_flag) T(T_ENB_RLC_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rntiMaybeUEid), T_INT(rb_idP), T_INT(sdu_sizeP)); diff --git a/openair2/RRC/NR_UE/main_ue.c b/openair2/RRC/NR_UE/main_ue.c index b558744e9e..0e51fe2779 100644 --- a/openair2/RRC/NR_UE/main_ue.c +++ b/openair2/RRC/NR_UE/main_ue.c @@ -35,11 +35,6 @@ #include "common/utils/LOG/log.h" #include "executables/softmodem-common.h" -NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap) -{ - return openair_rrc_top_init_ue_nr(uecap); -} - void init_nsa_message(NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig_file) { if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1) { diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 1b33e60fdf..da338ebd4c 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -299,40 +299,37 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, } } -NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file) +NR_UE_RRC_INST_t* nr_rrc_init_ue(char* uecap_file, int nb_inst) { - if(NB_NR_UE_INST > 0) { - NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(NB_NR_UE_INST , sizeof(NR_UE_RRC_INST_t)); - for(int nr_ue = 0; nr_ue < NB_NR_UE_INST; nr_ue++) { - NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[nr_ue]; - rrc->ue_id = nr_ue; - // fill UE-NR-Capability @ UE-CapabilityRAT-Container here. - rrc->selected_plmn_identity = 1; + NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(nb_inst, sizeof(NR_UE_RRC_INST_t)); + AssertFatal(NR_UE_rrc_inst, "Couldn't allocate %d instances of RRC module\n", nb_inst); - rrc->dl_bwp_id = 0; - rrc->ul_bwp_id = 0; - rrc->as_security_activated = false; + for(int nr_ue = 0; nr_ue < nb_inst; nr_ue++) { + NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[nr_ue]; + rrc->ue_id = nr_ue; + // fill UE-NR-Capability @ UE-CapabilityRAT-Container here. + rrc->selected_plmn_identity = 1; - for (int i = 0; i < NB_CNX_UE; i++) { - rrcPerNB_t *ptr = &rrc->perNB[i]; - ptr->SInfo = (NR_UE_RRC_SI_INFO){0}; - for (int j = 0; j < NR_NUM_SRB; j++) - ptr->Srb[j] = RB_NOT_PRESENT; - for (int j = 0; j < MAX_DRBS_PER_UE; j++) - ptr->status_DRBs[j] = RB_NOT_PRESENT; - // SRB0 activated by default - ptr->Srb[0] = RB_ESTABLISHED; - } - } + rrc->dl_bwp_id = 0; + rrc->ul_bwp_id = 0; + rrc->as_security_activated = false; - NR_UE_rrc_inst->uecap_file = uecap_file; + rrc->uecap_file = uecap_file; - if (get_softmodem_params()->sl_mode) { - configure_NR_SL_Preconfig(get_softmodem_params()->sync_ref); + for (int i = 0; i < NB_CNX_UE; i++) { + rrcPerNB_t *ptr = &rrc->perNB[i]; + ptr->SInfo = (NR_UE_RRC_SI_INFO){0}; + for (int j = 0; j < NR_NUM_SRB; j++) + ptr->Srb[j] = RB_NOT_PRESENT; + for (int j = 0; j < MAX_DRBS_PER_UE; j++) + ptr->status_DRBs[j] = RB_NOT_PRESENT; + // SRB0 activated by default + ptr->Srb[0] = RB_ESTABLISHED; } } - else{ - NR_UE_rrc_inst = NULL; + + if (get_softmodem_params()->sl_mode) { + configure_NR_SL_Preconfig(get_softmodem_params()->sync_ref); } return NR_UE_rrc_inst; diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index dacf5dd70d..9f9cb9a289 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -59,7 +59,6 @@ #include "as_message.h" #include "common/utils/nr/nr_common.h" -#define NB_NR_UE_INST 1 #define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE #define MAX_MEAS_OBJ 7 #define MAX_MEAS_CONFIG 7 diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index 08db8f6506..ba7c23cdb7 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -52,18 +52,8 @@ extern queue_t nr_dl_tti_req_queue; extern queue_t nr_tx_req_queue; extern queue_t nr_ul_dci_req_queue; extern queue_t nr_ul_tti_req_queue; -// -// main_rrc.c -// -/**\brief Layer 3 initialization*/ -NR_UE_RRC_INST_t *nr_l3_init_ue(char *); -// -// UE_rrc.c -// - -/**\brief Initial the top level RRC structure instance*/ -NR_UE_RRC_INST_t *openair_rrc_top_init_ue_nr(char *); +NR_UE_RRC_INST_t *nr_rrc_init_ue(char* uecap_file, int nb_inst); void init_nsa_message (NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig_file); void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len);