Commit 08f0283c authored by francescomani's avatar francescomani Committed by Jaroslava Fiedlerova

improvements in initializing multiple instances of MAC and RRC

parent 82e323ee
...@@ -981,18 +981,18 @@ void *UE_thread(void *arg) ...@@ -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) 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 = nr_rrc_init_ue(uecap_file, nb_inst);
NR_UE_RRC_INST_t* rrc_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 inst = 0; inst < nb_inst; inst++) { for (int i = 0; i < nb_inst; i++) {
AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file)) != NULL, "can not initialize RRC module\n"); NR_UE_MAC_INST_t *mac = get_mac_inst(i);
AssertFatal((mac_inst = nr_l2_init_ue()) != NULL, "can not initialize L2 module\n"); AssertFatal((mac->if_module = nr_ue_if_module_init(i)) != NULL, "can not initialize IF module\n");
AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n");
if (!get_softmodem_params()->sa) { 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? // TODO why do we need noS1 configuration?
// temporarily moved here to understand why not using the one provided by gNB // 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) { if (IS_SOFTMODEM_NOS1) {
// get default noS1 configuration // get default noS1 configuration
NR_RadioBearerConfig_t *rbconfig = NULL; NR_RadioBearerConfig_t *rbconfig = NULL;
...@@ -1001,8 +1001,8 @@ void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconf ...@@ -1001,8 +1001,8 @@ void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconf
// set up PDCP, RLC, MAC // set up PDCP, RLC, MAC
nr_pdcp_layer_init(false); nr_pdcp_layer_init(false);
nr_pdcp_add_drbs(ENB_FLAG_NO, inst, rbconfig->drb_ToAddModList, 0, NULL, NULL); nr_pdcp_add_drbs(ENB_FLAG_NO, i, rbconfig->drb_ToAddModList, 0, NULL, NULL);
nr_rlc_add_drb(mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig); nr_rlc_add_drb(mac->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig);
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_toadd_list; struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_toadd_list;
rlc_toadd_list.list.count = 1; rlc_toadd_list.list.count = 1;
rlc_toadd_list.list.array = calloc(1, sizeof(NR_RLC_BearerConfig_t)); rlc_toadd_list.list.array = calloc(1, sizeof(NR_RLC_BearerConfig_t));
......
...@@ -454,7 +454,8 @@ configmodule_interface_t *uniqCfg = NULL; ...@@ -454,7 +454,8 @@ configmodule_interface_t *uniqCfg = NULL;
// A global var to reduce the changes size // A global var to reduce the changes size
ldpc_interface_t ldpc_interface = {0}, ldpc_interface_offload = {0}; 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; int set_exe_prio = 1;
if (checkIfFedoraDistribution()) if (checkIfFedoraDistribution())
if (checkIfGenericKernelOnFedora()) if (checkIfGenericKernelOnFedora())
...@@ -509,7 +510,7 @@ int main( int argc, char **argv ) { ...@@ -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])); 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; int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1;
uint16_t node_number = get_softmodem_params()->node_number; uint16_t node_number = get_softmodem_params()->node_number;
......
...@@ -849,7 +849,7 @@ int main(int argc, char **argv) ...@@ -849,7 +849,7 @@ int main(int argc, char **argv)
nr_gold_pdsch(UE, i, UE->scramblingID_dlsch[i]); 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_mac = get_mac_inst(0);
ue_init_config_request(UE_mac, mu); ue_init_config_request(UE_mac, mu);
......
...@@ -690,8 +690,7 @@ int main(int argc, char *argv[]) ...@@ -690,8 +690,7 @@ int main(int argc, char *argv[])
} }
//Configure UE //Configure UE
nr_l2_init_ue(); nr_l2_init_ue(1);
NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0); NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0);
ue_init_config_request(UE_mac, mu); ue_init_config_request(UE_mac, mu);
......
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
// NR UE defs // NR UE defs
// ========== // ==========
#define NB_NR_UE_MAC_INST 1
#define MAX_NUM_BWP_UE 5 #define MAX_NUM_BWP_UE 5
#define NUM_SLOT_FRAME 10 #define NUM_SLOT_FRAME 10
...@@ -452,6 +451,7 @@ typedef struct { ...@@ -452,6 +451,7 @@ typedef struct {
/*!\brief Top level UE MAC structure */ /*!\brief Top level UE MAC structure */
typedef struct { typedef struct {
module_id_t ue_id;
NR_UE_L2_STATE_t state; NR_UE_L2_STATE_t state;
int servCellIndex; int servCellIndex;
long physCellId; long physCellId;
......
...@@ -197,10 +197,10 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, ...@@ -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); 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*/ /**\brief initialization NR UE MAC instance(s)*/
NR_UE_MAC_INST_t * nr_l2_init_ue(); 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)*/ \param module_id index of MAC instance(s)*/
NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id); NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id);
......
...@@ -112,26 +112,32 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) ...@@ -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 //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_init_mac(j);
NR_UE_MAC_INST_t *mac = get_mac_inst(j); NR_UE_MAC_INST_t *mac = get_mac_inst(j);
mac->ue_id = j;
nr_ue_mac_default_configs(mac); nr_ue_mac_default_configs(mac);
if (get_softmodem_params()->sa) if (get_softmodem_params()->sa)
ue_init_config_request(mac, get_softmodem_params()->numerology); ue_init_config_request(mac, get_softmodem_params()->numerology);
} }
int rc = rlc_module_init(0); 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); return (nr_ue_mac_inst);
} }
NR_UE_MAC_INST_t *get_mac_inst(module_id_t module_id) { 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 *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) void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
......
...@@ -2409,7 +2409,6 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *p ...@@ -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) 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 // 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_MAC_INST_t *mac = get_mac_inst(module_idP);
NR_UE_SCHEDULING_INFO *si = &mac->scheduling_info; NR_UE_SCHEDULING_INFO *si = &mac->scheduling_info;
int max_sr_transmissions = (1 << (2 + si->sr_TransMax)); int max_sr_transmissions = (1 << (2 + si->sr_TransMax));
......
...@@ -308,9 +308,8 @@ rlc_op_status_t rlc_data_req(const protocol_ctxt_t *const ctxt_pP, ...@@ -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_ue_t *ue;
nr_rlc_entity_t *rb; 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", LOG_D(RLC, "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, rnti, srb_flagP, rb_idP, muiP, confirmP, sdu_sizeP, MBMS_flagP);
MBMS_flagP);
if (ctxt_pP->enb_flag) 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)); T(T_ENB_RLC_DL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rntiMaybeUEid), T_INT(rb_idP), T_INT(sdu_sizeP));
......
...@@ -35,11 +35,6 @@ ...@@ -35,11 +35,6 @@
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include "executables/softmodem-common.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) 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) { if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1) {
......
...@@ -299,11 +299,12 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, ...@@ -299,11 +299,12 @@ 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_inst, sizeof(NR_UE_RRC_INST_t));
NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(NB_NR_UE_INST , sizeof(NR_UE_RRC_INST_t)); AssertFatal(NR_UE_rrc_inst, "Couldn't allocate %d instances of RRC module\n", nb_inst);
for(int nr_ue = 0; nr_ue < NB_NR_UE_INST; nr_ue++) {
for(int nr_ue = 0; nr_ue < nb_inst; nr_ue++) {
NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[nr_ue]; NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[nr_ue];
rrc->ue_id = nr_ue; rrc->ue_id = nr_ue;
// fill UE-NR-Capability @ UE-CapabilityRAT-Container here. // fill UE-NR-Capability @ UE-CapabilityRAT-Container here.
...@@ -313,6 +314,8 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file) ...@@ -313,6 +314,8 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file)
rrc->ul_bwp_id = 0; rrc->ul_bwp_id = 0;
rrc->as_security_activated = false; rrc->as_security_activated = false;
rrc->uecap_file = uecap_file;
for (int i = 0; i < NB_CNX_UE; i++) { for (int i = 0; i < NB_CNX_UE; i++) {
rrcPerNB_t *ptr = &rrc->perNB[i]; rrcPerNB_t *ptr = &rrc->perNB[i];
ptr->SInfo = (NR_UE_RRC_SI_INFO){0}; ptr->SInfo = (NR_UE_RRC_SI_INFO){0};
...@@ -325,15 +328,9 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file) ...@@ -325,15 +328,9 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file)
} }
} }
NR_UE_rrc_inst->uecap_file = uecap_file;
if (get_softmodem_params()->sl_mode) { if (get_softmodem_params()->sl_mode) {
configure_NR_SL_Preconfig(get_softmodem_params()->sync_ref); configure_NR_SL_Preconfig(get_softmodem_params()->sync_ref);
} }
}
else{
NR_UE_rrc_inst = NULL;
}
return NR_UE_rrc_inst; return NR_UE_rrc_inst;
} }
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include "as_message.h" #include "as_message.h"
#include "common/utils/nr/nr_common.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 NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE
#define MAX_MEAS_OBJ 7 #define MAX_MEAS_OBJ 7
#define MAX_MEAS_CONFIG 7 #define MAX_MEAS_CONFIG 7
......
...@@ -52,18 +52,8 @@ extern queue_t nr_dl_tti_req_queue; ...@@ -52,18 +52,8 @@ extern queue_t nr_dl_tti_req_queue;
extern queue_t nr_tx_req_queue; extern queue_t nr_tx_req_queue;
extern queue_t nr_ul_dci_req_queue; extern queue_t nr_ul_dci_req_queue;
extern queue_t nr_ul_tti_req_queue; extern queue_t nr_ul_tti_req_queue;
//
// main_rrc.c NR_UE_RRC_INST_t *nr_rrc_init_ue(char* uecap_file, int nb_inst);
//
/**\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 *);
void init_nsa_message (NR_UE_RRC_INST_t *rrc, char* reconfig_file, char* rbconfig_file); 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); void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type, void *message, int msg_len);
......
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