Add MAX_NUM_NR_UE_INST to NR UE MAC
- Use MAX_NUM_NR_UE_INST in NR UE MAC to control number of MAC instances. - Modify the MAC interface slightly so that nr_l2_init_ue only initializes one instance
This commit is contained in:
@@ -62,7 +62,7 @@ add_dependencies(telnetsrv telnetsrv_ci)
|
||||
|
||||
message(STATUS "Add CI specific telnet functions for nrUE in telnetsrv_ciUE.so")
|
||||
add_library(telnetsrv_ciUE MODULE telnetsrv_ciUE.c)
|
||||
target_link_libraries(telnetsrv_ciUE PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs)
|
||||
target_link_libraries(telnetsrv_ciUE PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs UTIL)
|
||||
add_dependencies(telnetsrv telnetsrv_ciUE)
|
||||
|
||||
message(STATUS "Add bearer specific telnet functions in libtelnetsrv_bearer.so")
|
||||
|
||||
+3
-6
@@ -1284,17 +1284,14 @@ 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_l2_init_ue(nb_inst);
|
||||
AssertFatal(mac_inst, "Couldn't allocate MAC module\n");
|
||||
|
||||
for (int instance_id = 0; instance_id < nb_inst; instance_id++) {
|
||||
NR_UE_MAC_INST_t *mac = get_mac_inst(instance_id);
|
||||
NR_UE_RRC_INST_t *rrc = nr_rrc_init_ue(uecap_file, instance_id, get_nrUE_params()->nb_antennas_tx);
|
||||
NR_UE_RRC_INST_t* rrc = nr_rrc_init_ue(uecap_file, instance_id, get_nrUE_params()->nb_antennas_tx);
|
||||
NR_UE_MAC_INST_t *mac = nr_l2_init_ue(instance_id);
|
||||
mac->if_module = nr_ue_if_module_init(instance_id);
|
||||
AssertFatal(mac->if_module, "can not initialize IF module\n");
|
||||
if (!IS_SA_MODE(get_softmodem_params()) && !get_softmodem_params()->sl_mode) {
|
||||
init_nsa_message(rrc, reconfig_file, rbconfig_file);
|
||||
nr_rlc_activate_srb0(mac_inst[instance_id].crnti, NULL, send_srb0_rrc);
|
||||
nr_rlc_activate_srb0(mac->crnti, NULL, send_srb0_rrc);
|
||||
}
|
||||
//TODO: Move this call to RRC
|
||||
start_sidelink(instance_id);
|
||||
|
||||
@@ -924,8 +924,7 @@ printf("%d\n", slot);
|
||||
|
||||
init_nr_ue_transport(UE);
|
||||
|
||||
nr_l2_init_ue(1);
|
||||
UE_mac = get_mac_inst(0);
|
||||
UE_mac = nr_l2_init_ue(0);
|
||||
ue_init_config_request(UE_mac, get_slots_per_frame_from_scs(mu));
|
||||
|
||||
UE->if_inst = nr_ue_if_module_init(0);
|
||||
|
||||
@@ -780,8 +780,7 @@ int main(int argc, char *argv[])
|
||||
init_nr_ue_transport(UE);
|
||||
|
||||
//Configure UE
|
||||
nr_l2_init_ue(1);
|
||||
NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0);
|
||||
NR_UE_MAC_INST_t* UE_mac = nr_l2_init_ue(0);
|
||||
|
||||
ue_init_config_request(UE_mac, get_slots_per_frame_from_scs(mu));
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "nr_rlc/nr_rlc_oai_api.h"
|
||||
#include "RRC/NR_UE/rrc_proto.h"
|
||||
#include <pthread.h>
|
||||
static NR_UE_MAC_INST_t *nr_ue_mac_inst;
|
||||
static NR_UE_MAC_INST_t *nr_ue_mac_inst[MAX_NUM_NR_UE_INST] = {0};
|
||||
|
||||
void send_srb0_rrc(int ue_id, const uint8_t *sdu, sdu_size_t sdu_len, void *data)
|
||||
{
|
||||
@@ -124,37 +124,38 @@ NR_UE_L2_STATE_t nr_ue_get_sync_state(module_id_t mod_id)
|
||||
return mac->state;
|
||||
}
|
||||
|
||||
NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst)
|
||||
NR_UE_MAC_INST_t *nr_l2_init_ue(int instance_id)
|
||||
{
|
||||
//init mac here
|
||||
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);
|
||||
AssertFatal(instance_id < MAX_NUM_NR_UE_INST, "instance_id %d is out of range\n", instance_id);
|
||||
AssertFatal(nr_ue_mac_inst[instance_id] == NULL, "MAC instance %d already initialized\n", instance_id);
|
||||
nr_ue_mac_inst[instance_id] = calloc_or_fail(1, sizeof(NR_UE_MAC_INST_t));
|
||||
|
||||
for (int j = 0; j < nb_inst; j++) {
|
||||
NR_UE_MAC_INST_t *mac = &nr_ue_mac_inst[j];
|
||||
mac->ue_id = j;
|
||||
nr_ue_init_mac(mac);
|
||||
int ret = pthread_mutex_init(&mac->if_mutex, NULL);
|
||||
AssertFatal(ret == 0, "Mutex init failed\n");
|
||||
nr_ue_mac_default_configs(mac);
|
||||
if (IS_SA_MODE(get_softmodem_params()))
|
||||
ue_init_config_request(mac, get_slots_per_frame_from_scs(get_softmodem_params()->numerology));
|
||||
NR_UE_MAC_INST_t *mac = nr_ue_mac_inst[instance_id];
|
||||
mac->ue_id = instance_id;
|
||||
nr_ue_init_mac(mac);
|
||||
int ret = pthread_mutex_init(&mac->if_mutex, NULL);
|
||||
AssertFatal(ret == 0, "Mutex init failed\n");
|
||||
nr_ue_mac_default_configs(mac);
|
||||
if (IS_SA_MODE(get_softmodem_params()))
|
||||
ue_init_config_request(mac, get_slots_per_frame_from_scs(get_softmodem_params()->numerology));
|
||||
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
int rc = nr_rlc_module_init(NR_RLC_OP_MODE_UE);
|
||||
AssertFatal(rc == 0, "Could not initialize RLC layer\n");
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
int rc = nr_rlc_module_init(NR_RLC_OP_MODE_UE);
|
||||
AssertFatal(rc == 0, "Could not initialize RLC layer\n");
|
||||
nr_rlc_activate_srb0(instance_id, NULL, send_srb0_rrc);
|
||||
|
||||
for (int j = 0; j < nb_inst; j++) {
|
||||
nr_rlc_activate_srb0(j, NULL, send_srb0_rrc);
|
||||
}
|
||||
|
||||
return (nr_ue_mac_inst);
|
||||
return nr_ue_mac_inst[instance_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);
|
||||
AssertFatal(module_id < MAX_NUM_NR_UE_INST, "module_id %d is out of range\n", module_id);
|
||||
NR_UE_MAC_INST_t *mac = nr_ue_mac_inst[module_id];
|
||||
if (mac == NULL) return NULL;
|
||||
AssertFatal(mac->ue_id == module_id, "MAC ID %d doesn't match with input %d\n", mac->ue_id, module_id);
|
||||
return mac;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user