From 83f66f2ade3081b74615cb0f504008ddf3e73e02 Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Fri, 14 Jun 2024 16:28:51 +0200 Subject: [PATCH 1/4] Replace 0 with module id for NR UE Add UE id to several LOG macros --- executables/nr-ue.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 2 +- openair2/LAYER2/NR_MAC_UE/config_ue.c | 4 ++-- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 3a11b4e4e3..e5e3ef3569 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -416,7 +416,7 @@ static void RU_write(nr_rxtx_thread_data_t *rxtxD, bool sl_tx_action) radio_tx_burst_flag_t flags = TX_BURST_INVALID; - NR_UE_MAC_INST_t *mac = get_mac_inst(0); + NR_UE_MAC_INST_t *mac = get_mac_inst(UE->Mod_id); if (mac->phy_config_request_sent && openair0_cfg[0].duplex_mode == duplex_mode_TDD && !get_softmodem_params()->continuous_tx) { @@ -769,7 +769,7 @@ void *UE_thread(void *arg) initNotifiedFIFO_nothreadSafe(&freeBlocks); int timing_advance = UE->timing_advance; - NR_UE_MAC_INST_t *mac = get_mac_inst(0); + NR_UE_MAC_INST_t *mac = get_mac_inst(UE->Mod_id); bool syncRunning = false; const int nb_slot_frame = fp->slots_per_frame; diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index fbb6113405..980c8e3813 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -1004,7 +1004,7 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, switch (csirs_config_pdu->measurement_bitmap) { case 1 : - LOG_I(NR_PHY, "RSRP = %i dBm\n", rsrp_dBm); + LOG_I(NR_PHY, "[UE %d] RSRP = %i dBm\n", ue->Mod_id, rsrp_dBm); break; case 26 : LOG_I(NR_PHY, "RI = %i i1 = %i.%i.%i, i2 = %i, SINR = %i dB, CQI = %i\n", diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index d3ce92da26..dcc5a058c8 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -944,7 +944,7 @@ int pbch_pdcch_processing(PHY_VARS_NR_UE *ue, const UE_nr_rxtx_proc_t *proc, nr_ char output[harq_output_len]; char *p = output; const char *end = output + harq_output_len; - p += snprintf(p, end - p, "Harq round stats for Downlink: %d", ue->dl_stats[0]); + p += snprintf(p, end - p, "[UE %d] Harq round stats for Downlink: %d", ue->Mod_id, ue->dl_stats[0]); for (int round = 1; round < 16 && (round < 3 || ue->dl_stats[round] != 0); ++round) p += snprintf(p, end - p,"/%d", ue->dl_stats[round]); LOG_I(NR_PHY,"%s\n", output); diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 52d45c938b..9fb3d1cfc9 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -250,7 +250,7 @@ static void config_common_ue(NR_UE_MAC_INST_t *mac, mac->phy_config.CC_id = cc_idP; // carrier config - LOG_D(MAC, "Entering UE Config Common\n"); + LOG_D(MAC, "[UE %d] Entering UE Config Common\n", mac->ue_id); AssertFatal(scc->downlinkConfigCommon, "Not expecting downlinkConfigCommon to be NULL here\n"); @@ -2219,7 +2219,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, NR_CellGroupConfig_t *cell_group_config, NR_UE_NR_Capability_t *ue_Capability) { - LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n"); + LOG_I(MAC,"[UE %d] Applying CellGroupConfig from gNodeB\n", module_id); AssertFatal(cell_group_config, "CellGroupConfig should not be NULL\n"); NR_UE_MAC_INST_t *mac = get_mac_inst(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 3941488682..4d8b79a2ab 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -130,7 +130,7 @@ NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst) AssertFatal(nr_ue_mac_inst, "Couldn't allocate %d instances of MAC module\n", nb_inst); for (int j = 0; j < nb_inst; j++) { - NR_UE_MAC_INST_t *mac = get_mac_inst(j); + NR_UE_MAC_INST_t *mac = &nr_ue_mac_inst[j]; mac->ue_id = j; nr_ue_init_mac(mac); nr_ue_mac_default_configs(mac); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 980f793c0a..7192b36af2 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -225,7 +225,7 @@ static void nr_rrc_ue_process_rrcReconfiguration(NR_UE_RRC_INST_t *rrc, nr_rrc_cellgroup_configuration(rrc, cellGroupConfig); AssertFatal(!get_softmodem_params()->sa, "secondaryCellGroup only used in NSA for now\n"); - nr_rrc_mac_config_req_cg(0, 0, cellGroupConfig, rrc->UECap.UE_NR_Capability); + nr_rrc_mac_config_req_cg(rrc->ue_id, 0, cellGroupConfig, rrc->UECap.UE_NR_Capability); asn1cFreeStruc(asn_DEF_NR_CellGroupConfig, cellGroupConfig); } if (ie->measConfig != NULL) { From d5a427217788fb605c2a6f93b4c077f9b07c74be Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Fri, 14 Jun 2024 16:31:57 +0200 Subject: [PATCH 2/4] Add parameter --num-ues to NR UE --- executables/nr-uesoftmodem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 4c3a35b048..9471988c02 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -62,6 +62,7 @@ {"chest-time", CONFIG_HLP_CHESTTIME, 0, .iptr=&(nrUE_params.chest_time), .defintval=0, TYPE_INT, 0}, \ {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, .iptr=&(nrUE_params.no_timing_correction), .defintval=0, TYPE_INT, 0}, \ {"SLC", CONFIG_HLP_SLF, 0, .u64ptr=&(sidelink_frequency[0][0]), .defuintval=2600000000,TYPE_UINT64,0}, \ + {"num-ues", NULL, 0, .iptr=&(NB_UE_INST), .defuintval=1, TYPE_INT,0}, \ } // clang-format on From bcfe3a6733452f5a2c739fa0e6ef17cbb96de864 Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Fri, 14 Jun 2024 16:34:27 +0200 Subject: [PATCH 3/4] Initialize number of NR UEs equal to --num-ues parameter --- executables/nr-ue.c | 29 +++++------ executables/nr-uesoftmodem.c | 95 +++++++++++++++++++----------------- executables/nr-uesoftmodem.h | 2 +- 3 files changed, 64 insertions(+), 62 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e5e3ef3569..8a73bdd311 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -146,7 +146,7 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, int nb_connected_gNB = 1; ue->Mod_id = UE_id; - ue->if_inst = nr_ue_if_module_init(0); + ue->if_inst = nr_ue_if_module_init(UE_id); ue->dci_thres = 0; ue->target_Nid_cell = -1; @@ -998,27 +998,22 @@ void init_NR_UE(int nb_inst, char *uecap_file, char *reconfig_file, char *rbconf mac->if_module = nr_ue_if_module_init(i); AssertFatal(mac->if_module, "can not initialize IF module\n"); if (!get_softmodem_params()->sa || !get_softmodem_params()->sl_mode) { - init_nsa_message(rrc_inst, reconfig_file, rbconfig_file); - nr_rlc_activate_srb0(mac_inst->crnti, NULL, send_srb0_rrc); + init_nsa_message(&rrc_inst[i], reconfig_file, rbconfig_file); + nr_rlc_activate_srb0(mac_inst[i].crnti, NULL, send_srb0_rrc); } //TODO: Move this call to RRC start_sidelink((&rrc_inst[i])->ue_id); } } -void init_NR_UE_threads(int nb_inst) { - int inst; - - pthread_t threads[nb_inst]; - - for (inst=0; inst < nb_inst; inst++) { - PHY_VARS_NR_UE *UE = PHY_vars_UE_g[inst][0]; - - LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]); - threadCreate(&threads[inst], UE_thread, (void *)UE, "UEthread", -1, OAI_PRIORITY_RT_MAX); - if (!IS_SOFTMODEM_NOSTATS_BIT) { - pthread_t stat_pthread; - threadCreate(&stat_pthread, nrL1_UE_stats_thread, UE, "L1_UE_stats", -1, OAI_PRIORITY_RT_LOW); - } +void init_NR_UE_threads(PHY_VARS_NR_UE *UE) { + pthread_t thread; + char thread_name[16]; + sprintf(thread_name, "UEthread_%d", UE->Mod_id); + threadCreate(&thread, UE_thread, (void *)UE, thread_name, -1, OAI_PRIORITY_RT_MAX); + if (!IS_SOFTMODEM_NOSTATS_BIT) { + pthread_t stat_pthread; + sprintf(thread_name, "L1_UE_stats_%d", UE->Mod_id); + threadCreate(&stat_pthread, nrL1_UE_stats_thread, UE, thread_name, -1, OAI_PRIORITY_RT_LOW); } } diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index befc03a2da..b3944548fd 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -502,11 +502,13 @@ int main(int argc, char **argv) // strdup to put the sring in the core file for post mortem identification LOG_I(HW, "Version: %s\n", strdup(PACKAGE_VERSION)); - PHY_vars_UE_g = malloc(sizeof(*PHY_vars_UE_g)); - PHY_vars_UE_g[0] = malloc(sizeof(*PHY_vars_UE_g[0]) * MAX_NUM_CCs); - for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - PHY_vars_UE_g[0][CC_id] = malloc(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])); + PHY_vars_UE_g = malloc(sizeof(*PHY_vars_UE_g) * NB_UE_INST); + for (int inst = 0; inst < NB_UE_INST; inst++) { + PHY_vars_UE_g[inst] = malloc(sizeof(*PHY_vars_UE_g[inst]) * MAX_NUM_CCs); + for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + PHY_vars_UE_g[inst][CC_id] = malloc(sizeof(*PHY_vars_UE_g[inst][CC_id])); + memset(PHY_vars_UE_g[inst][CC_id], 0, sizeof(*PHY_vars_UE_g[inst][CC_id])); + } } int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1; @@ -536,49 +538,51 @@ int main(int argc, char **argv) start_oai_nrue_threads(); if (!get_softmodem_params()->emulate_l1) { - PHY_VARS_NR_UE *UE[MAX_NUM_CCs]; - for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - UE[CC_id] = PHY_vars_UE_g[0][CC_id]; + for (int inst = 0; inst < NB_UE_INST; inst++) { + PHY_VARS_NR_UE *UE[MAX_NUM_CCs]; + for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { + UE[CC_id] = PHY_vars_UE_g[inst][CC_id]; - set_options(CC_id, UE[CC_id]); - NR_UE_MAC_INST_t *mac = get_mac_inst(0); + set_options(CC_id, UE[CC_id]); + NR_UE_MAC_INST_t *mac = get_mac_inst(inst); - if (get_softmodem_params()->sa || get_softmodem_params()->sl_mode) { // set frame config to initial values from command line - // and assume that the SSB is centered on the grid - uint16_t nr_band = get_softmodem_params()->band; - mac->nr_band = nr_band; - mac->ssb_start_subcarrier = UE[CC_id]->frame_parms.ssb_start_subcarrier; - nr_init_frame_parms_ue_sa(&UE[CC_id]->frame_parms, - downlink_frequency[CC_id][0], - uplink_frequency_offset[CC_id][0], - get_softmodem_params()->numerology, - nr_band); - } else { - DevAssert(mac->if_module != NULL && mac->if_module->phy_config_request != NULL); - mac->if_module->phy_config_request(&mac->phy_config); - mac->phy_config_request_sent = true; - fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; + if (get_softmodem_params()->sa || get_softmodem_params()->sl_mode) { // set frame config to initial values from command line + // and assume that the SSB is centered on the grid + uint16_t nr_band = get_softmodem_params()->band; + mac->nr_band = nr_band; + mac->ssb_start_subcarrier = UE[CC_id]->frame_parms.ssb_start_subcarrier; + nr_init_frame_parms_ue_sa(&UE[CC_id]->frame_parms, + downlink_frequency[CC_id][0], + uplink_frequency_offset[CC_id][0], + get_softmodem_params()->numerology, + nr_band); + } else { + DevAssert(mac->if_module != NULL && mac->if_module->phy_config_request != NULL); + mac->if_module->phy_config_request(&mac->phy_config); + mac->phy_config_request_sent = true; + fapi_nr_config_request_t *nrUE_config = &UE[CC_id]->nrUE_config; - nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, mac->nr_band); - } + nr_init_frame_parms_ue(&UE[CC_id]->frame_parms, nrUE_config, mac->nr_band); + } - UE[CC_id]->sl_mode = get_softmodem_params()->sl_mode; - init_nr_ue_vars(UE[CC_id], 0, abstraction_flag); + UE[CC_id]->sl_mode = get_softmodem_params()->sl_mode; + init_nr_ue_vars(UE[CC_id], inst, abstraction_flag); - if (UE[CC_id]->sl_mode) { - AssertFatal(UE[CC_id]->sl_mode == 2, "Only Sidelink mode 2 supported. Mode 1 not yet supported\n"); - DevAssert(mac->if_module != NULL && mac->if_module->sl_phy_config_request != NULL); - nr_sl_phy_config_t *phycfg = &mac->SL_MAC_PARAMS->sl_phy_config; - phycfg->sl_config_req.sl_carrier_config.sl_num_rx_ant = get_nrUE_params()->nb_antennas_rx; - phycfg->sl_config_req.sl_carrier_config.sl_num_tx_ant = get_nrUE_params()->nb_antennas_tx; - mac->if_module->sl_phy_config_request(phycfg); - mac->phy_config_request_sent = true; - sl_nr_ue_phy_params_t *sl_phy = &UE[CC_id]->SL_UE_PHY_PARAMS; - nr_init_frame_parms_ue_sl(&sl_phy->sl_frame_params, - &sl_phy->sl_config, - get_softmodem_params()->threequarter_fs, - get_nrUE_params()->ofdm_offset_divisor); - sl_ue_phy_init(UE[CC_id]); + if (UE[CC_id]->sl_mode) { + AssertFatal(UE[CC_id]->sl_mode == 2, "Only Sidelink mode 2 supported. Mode 1 not yet supported\n"); + DevAssert(mac->if_module != NULL && mac->if_module->sl_phy_config_request != NULL); + nr_sl_phy_config_t *phycfg = &mac->SL_MAC_PARAMS->sl_phy_config; + phycfg->sl_config_req.sl_carrier_config.sl_num_rx_ant = get_nrUE_params()->nb_antennas_rx; + phycfg->sl_config_req.sl_carrier_config.sl_num_tx_ant = get_nrUE_params()->nb_antennas_tx; + mac->if_module->sl_phy_config_request(phycfg); + mac->phy_config_request_sent = true; + sl_nr_ue_phy_params_t *sl_phy = &UE[CC_id]->SL_UE_PHY_PARAMS; + nr_init_frame_parms_ue_sl(&sl_phy->sl_frame_params, + &sl_phy->sl_config, + get_softmodem_params()->threequarter_fs, + get_nrUE_params()->ofdm_offset_divisor); + sl_ue_phy_init(UE[CC_id]); + } } } @@ -593,7 +597,10 @@ int main(int argc, char **argv) load_softscope("nr",PHY_vars_UE_g[0][0]); } - init_NR_UE_threads(1); + for (int inst = 0; inst < NB_UE_INST; inst++) { + LOG_I(PHY,"Intializing UE Threads for instance %d ...\n", inst); + init_NR_UE_threads(PHY_vars_UE_g[inst][0]); + } printf("UE threads created by %ld\n", gettid()); } diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 9471988c02..c61151e9ad 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -92,7 +92,7 @@ extern nrUE_params_t *get_nrUE_params(void); extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg); extern void fill_ue_band_info(void); extern void init_NR_UE(int, char *, char *, char *); -extern void init_NR_UE_threads(int); +extern void init_NR_UE_threads(PHY_VARS_NR_UE *ue); extern void reset_opp_meas(void); extern void print_opp_meas(void); void start_oai_nrue_threads(void); From 3c5ddf94696dc9457c10db06f8137c07083b1522 Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Fri, 14 Jun 2024 16:33:46 +0200 Subject: [PATCH 4/4] Lift RLC restriction to 1 UE / process --- openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 5178ebc1d9..4f34a64999 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -147,7 +147,7 @@ void mac_rlc_data_ind(const module_id_t module_idP, num_tb_t num_tbP, crc_t *crcs_pP) { - if (module_idP != 0 || eNB_index != 0 || /*enb_flagP != 1 ||*/ MBMS_flagP != 0) { + if (eNB_index != 0 || /*enb_flagP != 1 ||*/ MBMS_flagP != 0) { LOG_E(RLC, "%s:%d:%s: fatal\n", __FILE__, __LINE__, __FUNCTION__); exit(1); }