From f4e4ef74ff315a6bd7b8c5187c67ad905db99818 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 2 Oct 2025 15:11:12 +0200 Subject: [PATCH 1/2] remove emulate_l1 code --- doc/L2NFAPI.md | 43 +- executables/create_tasks.c | 2 +- executables/nr-ue.c | 188 ---- executables/nr-uesoftmodem.c | 213 ++-- executables/nr-uesoftmodem.h | 2 - executables/softmodem-common.h | 5 - openair1/SCHED_NR_UE/fapi_nr_ue_l1.c | 237 ---- openair2/LAYER2/NR_MAC_COMMON/nr_mac.h | 29 - openair2/LAYER2/NR_MAC_UE/config_ue.c | 15 +- openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 - openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 1 - openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 32 - openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 10 - openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 6 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.h | 2 - openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 1018 +----------------- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h | 42 - openair2/RRC/LTE/rrc_eNB.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 2 +- openair2/RRC/NR_UE/rrc_proto.h | 2 - 20 files changed, 90 insertions(+), 1763 deletions(-) diff --git a/doc/L2NFAPI.md b/doc/L2NFAPI.md index d9f0ad0435..282e6eeedf 100644 --- a/doc/L2NFAPI.md +++ b/doc/L2NFAPI.md @@ -40,48 +40,7 @@ Normally it should be fine to run both executables on the same host using the `l **2022/03/08: Starting the `2022.w01` tag on the `develop` branch, the L2 nFAPI simulation is using a proxy.** -## 5G L2 nFAPI simulator - -**Note: L2 simulator does not work anymore.** - -### Download and Build the Proxy Server (from EpiSci) - -```bash -$ cd ~ -$ git clone https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy.git -$ cd oai-lte-multi-ue-proxy -$ make -``` - -### Start Proxy Server -Set the number of UEs to connect to server as 1 and the mode is SA. -```bash -$ number_of_ues=1 -$ sudo -E ./build/proxy $number_of_ues --nr -``` - -### Start gNB -```bash -$ sudo -E ./nr-softmodem -O ../ci-scripts/conf_files/episci/proxy_rcc.band78.tm1.106PRB.nfapi.conf --nfapi VNF --noS1 --emulate-l1 -``` -### Start UE -```bash -$ sudo -E ./nr-uesoftmodem -O ../ci-scripts/conf_files/nrue.uicc.conf --nfapi STANDALONE_PNF --node-number 2 --emulate-l1 -``` ### EpiSci's Documentation A more detailed tutorial is available on the [EpiSci GitHub Repository](https://github.com/EpiSci/oai-lte-5g-multi-ue-proxy#readme). -This proxy allows to perform L2 nFAPI simulator for: - -* LTE -* 5G-NSA -* 5G-SA - -### L2 Simulator as Docker Containers - -There used to be docker deployment with L2sim that was run in the CI. Since L2 -simulator does not work anymore, it has been removed. However, you can see the -old `README.md` from tag `2024.w44` -[here](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/2024.w44/ci-scripts/yaml_files/5g_l2sim_tdd/README.md). -In the same directory is a `docker-compose.yaml` file that can be used to run -L2sim. +Since 5G code has been removed, this proxy allows to perform L2 nFAPI simulator for LTE only. diff --git a/executables/create_tasks.c b/executables/create_tasks.c index ad81beca09..a36cf410e5 100644 --- a/executables/create_tasks.c +++ b/executables/create_tasks.c @@ -52,7 +52,7 @@ int create_tasks(uint32_t enb_nb) { rrc_enb_init(); itti_mark_task_ready(TASK_RRC_ENB); - if (get_softmodem_params()->emulate_l1 || !IS_SOFTMODEM_NOS1) { + if (!IS_SOFTMODEM_NOS1) { rc = itti_create_task(TASK_SCTP, sctp_eNB_task, NULL); AssertFatal(rc >= 0, "Create task for SCTP failed\n"); } diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 588465133b..f789484465 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -31,13 +31,10 @@ #include "SCHED_NR_UE/defs.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "executables/softmodem-common.h" -#include "PHY/NR_REFSIG/refsig_defs_ue.h" #include "radio/COMMON/common_lib.h" #include "LAYER2/nr_pdcp/nr_pdcp_oai_api.h" #include "LAYER2/nr_rlc/nr_rlc_oai_api.h" -#include "RRC/NR/MESSAGES/asn1_msg.h" #include "openair1/PHY/TOOLS/phy_scope_interface.h" -#include "PHY/MODULATION/nr_modulation.h" #include "instrumentation.h" #include "common/utils/threadPool/notified_fifo.h" #include "position_interface.h" @@ -102,8 +99,6 @@ * */ -static void *NRUE_phy_stub_standalone_pnf_task(void *arg); - static void start_process_slot_tx(void* arg) { notifiedFIFO_elt_t *newTx = arg; nr_rxtx_thread_data_t *curMsgTx = NotifiedFifoData(newTx); @@ -194,189 +189,6 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, uint8_t UE_id) ue->ta_slot = -1; } -void init_nrUE_standalone_thread(int ue_idx) -{ - int standalone_tx_port = 3611 + ue_idx * 2; - int standalone_rx_port = 3612 + ue_idx * 2; - nrue_init_standalone_socket(standalone_tx_port, standalone_rx_port); - - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - pthread_mutex_init(&mac->mutex_dl_info, NULL); - - pthread_t thread; - if (pthread_create(&thread, NULL, nrue_standalone_pnf_task, NULL) != 0) { - LOG_E(NR_MAC, "pthread_create failed for calling nrue_standalone_pnf_task"); - } - pthread_setname_np(thread, "oai:nrue-stand"); - pthread_t phy_thread; - if (pthread_create(&phy_thread, NULL, NRUE_phy_stub_standalone_pnf_task, NULL) != 0) { - LOG_E(NR_MAC, "pthread_create failed for calling NRUE_phy_stub_standalone_pnf_task"); - } - pthread_setname_np(phy_thread, "oai:nrue-stand-phy"); -} - -static void process_queued_nr_nfapi_msgs(NR_UE_MAC_INST_t *mac, int sfn, int slot) -{ - struct sfn_slot_s sfn_slot = {.sfn = sfn, .slot = slot}; - nfapi_nr_rach_indication_t *rach_ind = unqueue_matching(&nr_rach_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - nfapi_nr_dl_tti_request_t *dl_tti_request = get_queue(&nr_dl_tti_req_queue); - nfapi_nr_ul_dci_request_t *ul_dci_request = get_queue(&nr_ul_dci_req_queue); - - for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) { - LOG_D(NR_MAC, - "Try to get a ul_tti_req by matching CRC active sfn/slot %d.%d from queue with %lu items\n", - sfn, - slot, - nr_ul_tti_req_queue.num_items); - struct sfn_slot_s sfn_sf = {.sfn = mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn, .slot = mac->nr_ue_emul_l1.harq[i].active_ul_harq_slot }; - nfapi_nr_ul_tti_request_t *ul_tti_request_crc = unqueue_matching(&nr_ul_tti_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_sf); - if (ul_tti_request_crc && ul_tti_request_crc->n_pdus > 0) { - check_and_process_dci(NULL, NULL, NULL, ul_tti_request_crc); - free_and_zero(ul_tti_request_crc); - } - } - - if (rach_ind && rach_ind->number_of_pdus > 0) { - NR_UL_IND_t UL_INFO = { - .rach_ind = *rach_ind, - }; - send_nsa_standalone_msg(&UL_INFO, rach_ind->header.message_id); - free_and_zero(rach_ind->pdu_list); - free_and_zero(rach_ind); - } - if (dl_tti_request) { - struct sfn_slot_s sfn_slot = {.sfn = dl_tti_request->SFN, .slot = dl_tti_request->Slot}; - nfapi_nr_tx_data_request_t *tx_data_request = unqueue_matching(&nr_tx_req_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - if (!tx_data_request) { - LOG_E(NR_MAC, "[%d.%d] No corresponding tx_data_request for given dl_tti_request sfn/slot\n", - dl_tti_request->SFN, dl_tti_request->Slot); - if (get_softmodem_params()->nsa) - save_nr_measurement_info(dl_tti_request); - free_and_zero(dl_tti_request); - } - else if (dl_tti_request->dl_tti_request_body.nPDUs > 0 && tx_data_request->Number_of_PDUs > 0) { - if (get_softmodem_params()->nsa) - save_nr_measurement_info(dl_tti_request); - check_and_process_dci(dl_tti_request, tx_data_request, NULL, NULL); - free_and_zero(dl_tti_request); - free_and_zero(tx_data_request); - } - else { - AssertFatal(false, "We dont have PDUs in either dl_tti %d or tx_req %d\n", - dl_tti_request->dl_tti_request_body.nPDUs, tx_data_request->Number_of_PDUs); - } - } - if (ul_dci_request && ul_dci_request->numPdus > 0) { - check_and_process_dci(NULL, NULL, ul_dci_request, NULL); - free_and_zero(ul_dci_request); - } -} - -static void *NRUE_phy_stub_standalone_pnf_task(void *arg) -{ - LOG_I(MAC, "Clearing Queues\n"); - reset_queue(&nr_rach_ind_queue); - reset_queue(&nr_rx_ind_queue); - reset_queue(&nr_crc_ind_queue); - reset_queue(&nr_uci_ind_queue); - reset_queue(&nr_dl_tti_req_queue); - reset_queue(&nr_tx_req_queue); - reset_queue(&nr_ul_dci_req_queue); - reset_queue(&nr_ul_tti_req_queue); - - int last_sfn_slot = -1; - uint16_t sfn_slot = 0; - - module_id_t mod_id = 0; - NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); - for (int i = 0; i < NR_MAX_HARQ_PROCESSES; i++) { - mac->nr_ue_emul_l1.harq[i].active = false; - mac->nr_ue_emul_l1.harq[i].active_ul_harq_sfn = -1; - mac->nr_ue_emul_l1.harq[i].active_ul_harq_slot = -1; - } - - while (!oai_exit) { - if (sem_wait(&sfn_slot_semaphore) != 0) { - LOG_E(NR_MAC, "sem_wait() error\n"); - abort(); - } - uint16_t *slot_ind = get_queue(&nr_sfn_slot_queue); - nr_phy_channel_params_t *ch_info = get_queue(&nr_chan_param_queue); - if (!slot_ind && !ch_info) { - LOG_D(MAC, "get nr_sfn_slot_queue and nr_chan_param_queue == NULL!\n"); - continue; - } - if (slot_ind) { - sfn_slot = *slot_ind; - free_and_zero(slot_ind); - } - else if (ch_info) { - sfn_slot = ch_info->sfn_slot; - free_and_zero(ch_info); - } - - int mu = 1; // NR-UE emul-L1 is hardcoded to 30kHZ, see check_and_process_dci() - frame_t frame = NFAPI_SFNSLOTDEC2SFN(mu, sfn_slot); - int slot = NFAPI_SFNSLOTDEC2SLOT(mu, sfn_slot); - if (sfn_slot == last_sfn_slot) { - LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n", - frame, slot); - continue; - } - last_sfn_slot = sfn_slot; - - LOG_D(NR_MAC, "The received sfn/slot [%d %d] from proxy\n", - frame, slot); - - if (IS_SA_MODE(get_softmodem_params()) && mac->mib == NULL) { - LOG_D(NR_MAC, "We haven't gotten MIB. Lets see if we received it\n"); - nr_ue_dl_indication(&mac->dl_info); - process_queued_nr_nfapi_msgs(mac, frame, slot); - } - - int CC_id = 0; - uint8_t gNB_id = 0; - int slots_per_frame = 20; //30 kHZ subcarrier spacing - int slot_ahead = 2; // TODO: Make this dynamic - nr_uplink_indication_t ul_info = {.cc_id = CC_id, - .gNB_index = gNB_id, - .module_id = mod_id, - .slot = (slot + slot_ahead) % slots_per_frame, - .frame = (slot + slot_ahead >= slots_per_frame) ? (frame + 1) % 1024 : frame}; - - if (pthread_mutex_lock(&mac->mutex_dl_info)) abort(); - - if (ch_info) { - mac->nr_ue_emul_l1.pmi = ch_info->csi[0].pmi; - mac->nr_ue_emul_l1.ri = ch_info->csi[0].ri; - mac->nr_ue_emul_l1.cqi = ch_info->csi[0].cqi; - free_and_zero(ch_info); - } - - if (is_dl_slot(slot, &mac->frame_structure)) { - memset(&mac->dl_info, 0, sizeof(mac->dl_info)); - mac->dl_info.cc_id = CC_id; - mac->dl_info.gNB_index = gNB_id; - mac->dl_info.module_id = mod_id; - mac->dl_info.frame = frame; - mac->dl_info.slot = slot; - mac->dl_info.dci_ind = NULL; - mac->dl_info.rx_ind = NULL; - nr_ue_dl_indication(&mac->dl_info); - } - - if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); - - if (is_ul_slot(ul_info.slot, &mac->frame_structure)) { - LOG_D(NR_MAC, "Slot %d. calling nr_ue_ul_ind()\n", ul_info.slot); - nr_ue_ul_scheduler(mac, &ul_info); - } - process_queued_nr_nfapi_msgs(mac, frame, slot); - } - return NULL; -} - - /*! * It performs band scanning and synchonization. * \param arg is a pointer to a \ref PHY_VARS_NR_UE structure. diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index ac7b23382f..fb740781cd 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -93,15 +93,6 @@ unsigned short config_frames[4] = {2,9,11,13}; THREAD_STRUCT thread_struct; nrUE_params_t nrUE_params = {0}; -// Thread variables -pthread_cond_t nfapi_sync_cond; -pthread_mutex_t nfapi_sync_mutex; -int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex -pthread_cond_t sync_cond; -pthread_mutex_t sync_mutex; -int sync_var=-1; //!< protected by mutex \ref sync_mutex. -int config_sync_var=-1; - // not used in UE instance_t CUuniqInstance=0; instance_t DUuniqInstance=0; @@ -111,7 +102,6 @@ int get_node_type() {return -1;} RAN_CONTEXT_t RC; int oai_exit = 0; - static int tx_max_power[MAX_NUM_CCs] = {0}; double rx_gain_off = 0.0; @@ -121,10 +111,7 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; uint64_t sidelink_frequency[MAX_NUM_CCs][4]; // UE and OAI config variables -int16_t node_synch_ref[MAX_NUM_CCs]; -int otg_enabled; double cpuf; -uint32_t N_RB_DL = 106; int create_tasks_nrue(uint32_t ue_nb) { LOG_D(NR_RRC, "%s(ue_nb:%d)\n", __FUNCTION__, ue_nb); @@ -342,40 +329,6 @@ static void trigger_deregistration(int sig) } } -static void get_channel_model_mode(configmodule_interface_t *cfg) -{ - paramdef_t GNBParams[] = GNBPARAMS_DESC; - config_get(cfg, GNBParams, sizeofArray(GNBParams), NULL); - int num_xp_antennas = *GNBParams[GNB_PDSCH_ANTENNAPORTS_XP_IDX].iptr; - - if (num_xp_antennas == 2) - init_nr_bler_table("NR_MIMO2x2_AWGN_RESULTS_DIR"); - else - init_nr_bler_table("NR_AWGN_RESULTS_DIR"); -} - -void start_oai_nrue_threads() -{ - init_queue(&nr_rach_ind_queue); - init_queue(&nr_rx_ind_queue); - init_queue(&nr_crc_ind_queue); - init_queue(&nr_uci_ind_queue); - init_queue(&nr_sfn_slot_queue); - init_queue(&nr_chan_param_queue); - init_queue(&nr_dl_tti_req_queue); - init_queue(&nr_tx_req_queue); - init_queue(&nr_ul_dci_req_queue); - init_queue(&nr_ul_tti_req_queue); - - if (sem_init(&sfn_slot_semaphore, 0, 0) != 0) - { - LOG_E(MAC, "sem_init() error\n"); - abort(); - } - - init_nrUE_standalone_thread(ue_id_g); -} - int NB_UE_INST = 1; configmodule_interface_t *uniqCfg = NULL; nrLDPC_coding_interface_t nrLDPC_coding_interface = {0}; @@ -455,11 +408,6 @@ int main(int argc, char **argv) init_NR_UE(NB_UE_INST, get_nrUE_params()->uecap_file, get_nrUE_params()->reconfig_file, get_nrUE_params()->rbconfig_file); - if (get_softmodem_params()->emulate_l1) { - RCconfig_nr_ue_macrlc(); - get_channel_model_mode(uniqCfg); - } - // start time manager with some reasonable default for the running mode // (may be overwritten in configuration file or command line) void nr_pdcp_ms_tick(void); @@ -475,97 +423,90 @@ int main(int argc, char **argv) IS_SOFTMODEM_RFSIM ? TIME_SOURCE_IQ_SAMPLES : TIME_SOURCE_REALTIME); - if (!get_softmodem_params()->nsa && get_softmodem_params()->emulate_l1) - start_oai_nrue_threads(); - - if (!get_softmodem_params()->emulate_l1) { - 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(inst); - init_nr_ue_phy_cpu_stats(&UE[CC_id]->phy_cpu_stats); - - if (IS_SA_MODE(get_softmodem_params()) || 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 { - do { - notifiedFIFO_elt_t *elt = pollNotifiedFIFO(&mac->input_nf); - if (!elt) { - break; - } - process_msg_rcc_to_mac(NotifiedFifoData(elt), inst); - delNotifiedFIFO_elt(elt); - } while (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); - } - - UE[CC_id]->sl_mode = get_softmodem_params()->sl_mode; - init_actor(&UE[CC_id]->sync_actor, "SYNC_", -1); - if (get_nrUE_params()->num_dl_actors > 0) { - UE[CC_id]->dl_actors = calloc_or_fail(get_nrUE_params()->num_dl_actors, sizeof(*UE[CC_id]->dl_actors)); - for (int i = 0; i < get_nrUE_params()->num_dl_actors; i++) { - init_actor(&UE[CC_id]->dl_actors[i], "DL_", -1); + 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(inst); + init_nr_ue_phy_cpu_stats(&UE[CC_id]->phy_cpu_stats); + // set frame config to initial values from command line and assume that the SSB is centered on the grid + if (IS_SA_MODE(get_softmodem_params()) || get_softmodem_params()->sl_mode) { + 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 { + do { + notifiedFIFO_elt_t *elt = pollNotifiedFIFO(&mac->input_nf); + if (!elt) { + break; } - } - if (get_nrUE_params()->num_ul_actors > 0) { - UE[CC_id]->ul_actors = calloc_or_fail(get_nrUE_params()->num_ul_actors, sizeof(*UE[CC_id]->ul_actors)); - for (int i = 0; i < get_nrUE_params()->num_ul_actors; i++) { - init_actor(&UE[CC_id]->ul_actors[i], "UL_", -1); - } - } - init_nr_ue_vars(UE[CC_id], inst); - - 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); - 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]); - } - init_openair0(UE[CC_id]); + process_msg_rcc_to_mac(NotifiedFifoData(elt), inst); + delNotifiedFIFO_elt(elt); + } while (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); } - } - lock_memory_to_ram(); + UE[CC_id]->sl_mode = get_softmodem_params()->sl_mode; + init_actor(&UE[CC_id]->sync_actor, "SYNC_", -1); + if (get_nrUE_params()->num_dl_actors > 0) { + UE[CC_id]->dl_actors = calloc_or_fail(get_nrUE_params()->num_dl_actors, sizeof(*UE[CC_id]->dl_actors)); + for (int i = 0; i < get_nrUE_params()->num_dl_actors; i++) { + init_actor(&UE[CC_id]->dl_actors[i], "DL_", -1); + } + } + if (get_nrUE_params()->num_ul_actors > 0) { + UE[CC_id]->ul_actors = calloc_or_fail(get_nrUE_params()->num_ul_actors, sizeof(*UE[CC_id]->ul_actors)); + for (int i = 0; i < get_nrUE_params()->num_ul_actors; i++) { + init_actor(&UE[CC_id]->ul_actors[i], "UL_", -1); + } + } + init_nr_ue_vars(UE[CC_id], inst); - if (IS_SOFTMODEM_DOSCOPE) { - load_softscope("nr", PHY_vars_UE_g[0][0]); + 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); + 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]); + } + init_openair0(UE[CC_id]); } - if (IS_SOFTMODEM_IMSCOPE_ENABLED) { - load_softscope("im", PHY_vars_UE_g[0][0]); - } - AssertFatal(!(IS_SOFTMODEM_IMSCOPE_ENABLED && IS_SOFTMODEM_IMSCOPE_RECORD_ENABLED), - "Data recoding and ImScope cannot be enabled at the same time\n"); - if (IS_SOFTMODEM_IMSCOPE_RECORD_ENABLED) { - load_module_shlib("imscope_record", NULL, 0, PHY_vars_UE_g[0][0]); - } - - 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()); } + lock_memory_to_ram(); + + if (IS_SOFTMODEM_DOSCOPE) { + load_softscope("nr", PHY_vars_UE_g[0][0]); + } + if (IS_SOFTMODEM_IMSCOPE_ENABLED) { + load_softscope("im", PHY_vars_UE_g[0][0]); + } + AssertFatal(!(IS_SOFTMODEM_IMSCOPE_ENABLED && IS_SOFTMODEM_IMSCOPE_RECORD_ENABLED), + "Data recoding and ImScope cannot be enabled at the same time\n"); + if (IS_SOFTMODEM_IMSCOPE_RECORD_ENABLED) { + load_module_shlib("imscope_record", NULL, 0, PHY_vars_UE_g[0][0]); + } + + 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()); + // wait for end of program printf("TYPE TO TERMINATE\n"); diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index 3ceb3e479e..df13e2e02e 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -137,8 +137,6 @@ extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t * extern void fill_ue_band_info(void); extern void init_NR_UE(int, char *, char *, char *); extern void init_NR_UE_threads(PHY_VARS_NR_UE *ue); -void start_oai_nrue_threads(void); void *UE_thread(void *arg); void init_nr_ue_vars(PHY_VARS_NR_UE *ue, uint8_t UE_id); -void init_nrUE_standalone_thread(int ue_idx); #endif diff --git a/executables/softmodem-common.h b/executables/softmodem-common.h index d122b1a1d5..4dfa5eb680 100644 --- a/executables/softmodem-common.h +++ b/executables/softmodem-common.h @@ -105,7 +105,6 @@ extern "C" #define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n" #define CONFIG_HLP_USRP_THREAD "having extra thead for usrp tx\n" #define CONFIG_HLP_NFAPI "Change the nFAPI mode for NR 'MONOLITHIC', 'PNF', 'VNF', 'AERIAL','UE_STUB_PNF','UE_STUB_OFFNET','STANDALONE_PNF'\n" -#define CONFIG_L1_EMULATOR "Run in L1 emulated mode (disable PHY layer)\n" #define CONFIG_HLP_CONTINUOUS_TX "perform continuous transmission, even in TDD mode (to work around USRP issues)\n" #define CONFIG_HLP_STATS_DISABLE "disable globally the stats generation and persistence" #define CONFIG_HLP_NOITTI "Do not start itti threads, call queue processing in place, inside the caller thread" @@ -137,7 +136,6 @@ extern "C" #define NSA softmodem_params.nsa #define NODE_NUMBER softmodem_params.node_number #define NON_STOP softmodem_params.non_stop -#define EMULATE_L1 softmodem_params.emulate_l1 #define CONTINUOUS_TX softmodem_params.continuous_tx #define SYNC_REF softmodem_params.sync_ref #define DEFAULT_PDU_ID softmodem_params.default_pdu_session_id @@ -174,7 +172,6 @@ extern int usrp_tx_thread; {"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, .iptr=&usrp_tx_thread, .defstrval=0, TYPE_INT, 0}, \ {"nfapi", CONFIG_HLP_NFAPI, 0, .strptr=NULL, .defstrval="MONOLITHIC", TYPE_STRING, 0}, \ {"non-stop", CONFIG_HLP_NONSTOP, PARAMFLAG_BOOL, .iptr=&NON_STOP, .defintval=0, TYPE_INT, 0}, \ - {"emulate-l1", CONFIG_L1_EMULATOR, PARAMFLAG_BOOL, .iptr=&EMULATE_L1, .defintval=0, TYPE_INT, 0}, \ {"continuous-tx", CONFIG_HLP_CONTINUOUS_TX, PARAMFLAG_BOOL, .iptr=&CONTINUOUS_TX, .defintval=0, TYPE_INT, 0}, \ {"disable-stats", CONFIG_HLP_STATS_DISABLE, PARAMFLAG_BOOL, .iptr=&stats_disabled, .defintval=0, TYPE_INT, 0}, \ {"no-itti-threads", CONFIG_HLP_NOITTI, PARAMFLAG_BOOL, .iptr=&softmodem_params.no_itti, .defintval=0, TYPE_INT, 0}, \ @@ -228,7 +225,6 @@ extern int usrp_tx_thread; { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ { .s5 = { NULL } }, \ - { .s5 = { NULL } }, \ } // clang-format on @@ -331,7 +327,6 @@ typedef struct { int nsa; uint16_t node_number; int non_stop; - int emulate_l1; int continuous_tx; uint32_t sync_ref; int no_itti; diff --git a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c index 52d5033457..92da66fdd6 100644 --- a/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c +++ b/openair1/SCHED_NR_UE/fapi_nr_ue_l1.c @@ -31,7 +31,6 @@ */ #include - #include "fapi_nr_ue_interface.h" #include "fapi_nr_ue_l1.h" #include "harq_nr.h" @@ -39,247 +38,11 @@ #include "PHY/defs_nr_UE.h" #include "PHY/impl_defs_nr.h" #include "utils.h" -#include "openair2/PHY_INTERFACE/queue_t.h" #include "SCHED_NR_UE/phy_sch_processing_time.h" #include "openair1/PHY/phy_extern_nr_ue.h" const char *const dl_pdu_type[] = {"DCI", "DLSCH", "RA_DLSCH", "SI_DLSCH", "P_DLSCH", "CSI_RS", "CSI_IM", "TA"}; const char *const ul_pdu_type[] = {"PRACH", "PUCCH", "PUSCH", "SRS"}; -queue_t nr_rx_ind_queue; -queue_t nr_crc_ind_queue; -queue_t nr_uci_ind_queue; -queue_t nr_rach_ind_queue; - -static void fill_uci_2_3_4(nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4, - fapi_nr_ul_config_pucch_pdu *pucch_pdu) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - memset(pdu_2_3_4, 0, sizeof(*pdu_2_3_4)); - pdu_2_3_4->handle = 0; - pdu_2_3_4->rnti = pucch_pdu->rnti; - pdu_2_3_4->pucch_format = 2; - pdu_2_3_4->ul_cqi = 255; - pdu_2_3_4->timing_advance = 0; - pdu_2_3_4->rssi = 0; - // TODO: Eventually check 38.212:Sect.631 to know when to use csi_part2, for now only using csi_part1 - pdu_2_3_4->pduBitmap = 4; - pdu_2_3_4->csi_part1.csi_part1_bit_len = mac->nr_ue_emul_l1.num_csi_reports; - int csi_part1_byte_len = (int)((pdu_2_3_4->csi_part1.csi_part1_bit_len / 8) + 1); - AssertFatal(!pdu_2_3_4->csi_part1.csi_part1_payload, "pdu_2_3_4->csi_part1.csi_part1_payload != NULL\n"); - pdu_2_3_4->csi_part1.csi_part1_payload = CALLOC(csi_part1_byte_len, - sizeof(pdu_2_3_4->csi_part1.csi_part1_payload)); - for (int k = 0; k < csi_part1_byte_len; k++) - { - pdu_2_3_4->csi_part1.csi_part1_payload[k] = (pucch_pdu->payload >> (k * 8)) & 0xff; - } - pdu_2_3_4->csi_part1.csi_part1_crc = 0; -} - -static void free_uci_inds(nfapi_nr_uci_indication_t *uci_ind) -{ - for (int k = 0; k < uci_ind->num_ucis; k++) - { - if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE) - { - //nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[k].pucch_pdu_format_0_1; - // Warning: pdu_0_1 is unused - } - if (uci_ind->uci_list[k].pdu_type == NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE) - { - nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[k].pucch_pdu_format_2_3_4; - free(pdu_2_3_4->sr.sr_payload); - pdu_2_3_4->sr.sr_payload = NULL; - free(pdu_2_3_4->harq.harq_payload); - pdu_2_3_4->harq.harq_payload = NULL; - } - } - free(uci_ind->uci_list); - uci_ind->uci_list = NULL; - free(uci_ind); -} - -int8_t nr_ue_scheduled_response_stub(nr_scheduled_response_t *scheduled_response) { - - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - - if (scheduled_response && scheduled_response->ul_config) { - int frame = scheduled_response->ul_config->frame; - int slot = scheduled_response->ul_config->slot; - fapi_nr_ul_config_request_pdu_t *it = fapiLockIterator(scheduled_response->ul_config, frame, slot); - while (it->pdu_type != FAPI_NR_END) { - switch (it->pdu_type) { - case FAPI_NR_UL_CONFIG_TYPE_PRACH: { - fapi_nr_ul_config_prach_pdu *prach_pdu = &it->prach_config_pdu; - nfapi_nr_rach_indication_t *rach_ind = CALLOC(1, sizeof(*rach_ind)); - rach_ind->sfn = frame; - rach_ind->slot = slot; - rach_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION; - uint8_t pdu_index = 0; - rach_ind->pdu_list = CALLOC(1, sizeof(*rach_ind->pdu_list)); - rach_ind->number_of_pdus = 1; - rach_ind->pdu_list[pdu_index].phy_cell_id = prach_pdu->phys_cell_id; - rach_ind->pdu_list[pdu_index].symbol_index = prach_pdu->prach_start_symbol; - rach_ind->pdu_list[pdu_index].slot_index = prach_pdu->prach_slot; - rach_ind->pdu_list[pdu_index].freq_index = prach_pdu->num_ra; - rach_ind->pdu_list[pdu_index].avg_rssi = 128; - rach_ind->pdu_list[pdu_index].avg_snr = 0xff; // invalid for now - const int num_p = rach_ind->pdu_list[pdu_index].num_preamble; - AssertFatal(num_p == 1, "can handle only one preamble in preamble_list\n"); - rach_ind->pdu_list[pdu_index].num_preamble = 1; - rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_index = prach_pdu->ra_PreambleIndex; - rach_ind->pdu_list[pdu_index].preamble_list[0].timing_advance = 0; - rach_ind->pdu_list[pdu_index].preamble_list[0].preamble_pwr = 0xffffffff; - - if (!put_queue(&nr_rach_ind_queue, rach_ind)) { - free(rach_ind->pdu_list); - free(rach_ind); - } - LOG_D(NR_MAC, "We have successfully filled the rach_ind queue with the recently filled rach ind\n"); - break; - } - case (FAPI_NR_UL_CONFIG_TYPE_PUSCH): { - nfapi_nr_rx_data_indication_t *rx_ind = CALLOC(1, sizeof(*rx_ind)); - nfapi_nr_crc_indication_t *crc_ind = CALLOC(1, sizeof(*crc_ind)); - nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu = &it->pusch_config_pdu; - if (pusch_config_pdu->tx_request_body.fapiTxPdu) { - rx_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION; - rx_ind->sfn = frame; - rx_ind->slot = slot; - rx_ind->number_of_pdus = 1; - rx_ind->pdu_list = CALLOC(rx_ind->number_of_pdus, sizeof(*rx_ind->pdu_list)); - for (int j = 0; j < rx_ind->number_of_pdus; j++) { - fapi_nr_tx_request_body_t *tx_req_body = &pusch_config_pdu->tx_request_body; - rx_ind->pdu_list[j].handle = pusch_config_pdu->handle; - rx_ind->pdu_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id; - rx_ind->pdu_list[j].pdu_length = tx_req_body->pdu_length; - rx_ind->pdu_list[j].pdu = CALLOC(tx_req_body->pdu_length, sizeof(*rx_ind->pdu_list[j].pdu)); - memcpy(rx_ind->pdu_list[j].pdu, tx_req_body->fapiTxPdu, tx_req_body->pdu_length * sizeof(*rx_ind->pdu_list[j].pdu)); - rx_ind->pdu_list[j].rnti = pusch_config_pdu->rnti; - /* TODO: Implement channel modeling to abstract TA and CQI. For now, - we hard code the values below since they are set in L1 and we are - abstracting L1. */ - rx_ind->pdu_list[j].timing_advance = 31; - rx_ind->pdu_list[j].ul_cqi = 255; - } - - crc_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION; - crc_ind->number_crcs = rx_ind->number_of_pdus; - crc_ind->sfn = frame; - crc_ind->slot = slot; - crc_ind->crc_list = CALLOC(crc_ind->number_crcs, sizeof(*crc_ind->crc_list)); - for (int j = 0; j < crc_ind->number_crcs; j++) { - crc_ind->crc_list[j].handle = pusch_config_pdu->handle; - crc_ind->crc_list[j].harq_id = pusch_config_pdu->pusch_data.harq_process_id; - LOG_D(NR_MAC, "This is the harq pid %d for crc_list[%d]\n", crc_ind->crc_list[j].harq_id, j); - LOG_D(NR_MAC, "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d]\n", frame, slot, crc_ind->sfn, crc_ind->slot); - crc_ind->crc_list[j].num_cb = pusch_config_pdu->pusch_data.num_cb; - crc_ind->crc_list[j].rnti = pusch_config_pdu->rnti; - crc_ind->crc_list[j].tb_crc_status = 0; - crc_ind->crc_list[j].timing_advance = 31; - crc_ind->crc_list[j].ul_cqi = 255; - emul_l1_harq_t *harq = &mac->nr_ue_emul_l1.harq[crc_ind->crc_list[j].harq_id]; - AssertFatal(harq->active_ul_harq_sfn == -1 && harq->active_ul_harq_slot == -1, - "We did not send an active CRC when we should have!\n"); - harq->active_ul_harq_sfn = crc_ind->sfn; - harq->active_ul_harq_slot = crc_ind->slot; - LOG_D(NR_MAC, - "This is sched sfn/sl [%d %d] and crc sfn/sl [%d %d] with mcs_index in ul_cqi -> %d\n", - frame, - slot, - crc_ind->sfn, - crc_ind->slot, - pusch_config_pdu->mcs_index); - } - - if (!put_queue(&nr_rx_ind_queue, rx_ind)) { - LOG_E(NR_MAC, "Put_queue failed for rx_ind\n"); - for (int i = 0; i < rx_ind->number_of_pdus; i++) { - free(rx_ind->pdu_list[i].pdu); - rx_ind->pdu_list[i].pdu = NULL; - } - - free(rx_ind->pdu_list); - rx_ind->pdu_list = NULL; - free(rx_ind); - rx_ind = NULL; - } - if (!put_queue(&nr_crc_ind_queue, crc_ind)) { - LOG_E(NR_MAC, "Put_queue failed for crc_ind\n"); - free(crc_ind->crc_list); - crc_ind->crc_list = NULL; - free(crc_ind); - crc_ind = NULL; - } - - LOG_D(PHY, "In %s: Filled queue rx/crc_ind which was filled by ulconfig. \n", __FUNCTION__); - } - break; - } - case FAPI_NR_UL_CONFIG_TYPE_PUCCH: { - nfapi_nr_uci_indication_t *uci_ind = CALLOC(1, sizeof(*uci_ind)); - uci_ind->header.message_id = NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION; - uci_ind->sfn = frame; - uci_ind->slot = slot; - uci_ind->num_ucis = 1; - uci_ind->uci_list = CALLOC(uci_ind->num_ucis, sizeof(*uci_ind->uci_list)); - for (int j = 0; j < uci_ind->num_ucis; j++) { - LOG_D(NR_MAC, "pucch_config_pdu.n_bit = %d\n", it->pucch_config_pdu.n_bit); - if (it->pucch_config_pdu.n_bit > 3 && mac->nr_ue_emul_l1.num_csi_reports > 0) { - uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_2_3_4_PDU_TYPE; - uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_2_3_4_t); - nfapi_nr_uci_pucch_pdu_format_2_3_4_t *pdu_2_3_4 = &uci_ind->uci_list[j].pucch_pdu_format_2_3_4; - fill_uci_2_3_4(pdu_2_3_4, &it->pucch_config_pdu); - } else { - nfapi_nr_uci_pucch_pdu_format_0_1_t *pdu_0_1 = &uci_ind->uci_list[j].pucch_pdu_format_0_1; - uci_ind->uci_list[j].pdu_type = NFAPI_NR_UCI_FORMAT_0_1_PDU_TYPE; - uci_ind->uci_list[j].pdu_size = sizeof(nfapi_nr_uci_pucch_pdu_format_0_1_t); - memset(pdu_0_1, 0, sizeof(*pdu_0_1)); - pdu_0_1->handle = 0; - pdu_0_1->rnti = it->pucch_config_pdu.rnti; - pdu_0_1->pucch_format = 1; - pdu_0_1->ul_cqi = 255; - pdu_0_1->timing_advance = 0; - pdu_0_1->rssi = 0; - if (mac->nr_ue_emul_l1.num_harqs > 0) { - int harq_index = 0; - pdu_0_1->pduBitmap = 2; // (value->pduBitmap >> 1) & 0x01) == HARQ and (value->pduBitmap) & 0x01) == SR - pdu_0_1->harq.num_harq = mac->nr_ue_emul_l1.num_harqs; - pdu_0_1->harq.harq_confidence_level = 0; - int harq_pid = -1; - for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) { - if (mac->nr_ue_emul_l1.harq[k].active && mac->nr_ue_emul_l1.harq[k].active_dl_harq_sfn == uci_ind->sfn - && mac->nr_ue_emul_l1.harq[k].active_dl_harq_slot == uci_ind->slot) { - mac->nr_ue_emul_l1.harq[k].active = false; - harq_pid = k; - AssertFatal(harq_index < pdu_0_1->harq.num_harq, "Invalid harq_index %d\n", harq_index); - pdu_0_1->harq.harq_list[harq_index].harq_value = !mac->dl_harq_info[k].ack; - harq_index++; - } - } - AssertFatal(harq_pid != -1, "No active harq_pid, sfn_slot = %u.%u", uci_ind->sfn, uci_ind->slot); - } - } - } - - LOG_D(NR_PHY, "Sending UCI with %d PDUs in sfn.slot %d/%d\n", uci_ind->num_ucis, uci_ind->sfn, uci_ind->slot); - NR_UL_IND_t ul_info = { - .uci_ind = *uci_ind, - }; - send_nsa_standalone_msg(&ul_info, uci_ind->header.message_id); - free_uci_inds(uci_ind); - break; - } - - default: - LOG_W(NR_MAC, "Unknown ul_config->pdu_type %d\n", it->pdu_type); - break; - } - it++; - } - release_ul_config(it, true); - } - return 0; -} static void configure_dlsch(NR_UE_DLSCH_t *dlsch0, NR_DL_UE_HARQ_t *harq_list, diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h index 68182ab9ec..6e73a0f855 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_mac.h @@ -320,35 +320,6 @@ typedef struct { uint8_t nbits; } dci_field_t; -typedef struct { - /* The active harq sfn/slot field was created to save the - scheduled SFN/Slot transmission for the ACK/NAK. If we - do not save it, then we have to calculate it again as the - NRUE MAC layer already does in get_downlink_ack(). */ - int active_dl_harq_sfn; - int active_dl_harq_slot; - int active_ul_harq_sfn; - int active_ul_harq_slot; - bool active; -} emul_l1_harq_t; - -typedef struct { - bool expected_sib; - bool index_has_sib[NR_MAX_HARQ_PROCESSES]; - bool expected_rar; - bool index_has_rar[NR_MAX_HARQ_PROCESSES]; - bool expected_dci; - bool index_has_dci[NR_MAX_HARQ_PROCESSES]; - emul_l1_harq_t harq[NR_MAX_HARQ_PROCESSES]; - int active_uci_sfn_slot; - int num_srs; - int num_harqs; - int num_csi_reports; - uint8_t pmi; - uint8_t ri; - uint8_t cqi; -} nr_emulated_l1_t; - typedef struct { uint8_t format_indicator; //1 bit diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index bb37c3d582..f592423c5a 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1942,8 +1942,7 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *si if (mac->state == UE_RECEIVING_SIB && can_start_ra) mac->state = UE_PERFORMING_RA; - if (!get_softmodem_params()->emulate_l1) - mac->if_module->phy_config_request(&mac->phy_config); + mac->if_module->phy_config_request(&mac->phy_config); ret = pthread_mutex_unlock(&mac->if_mutex); AssertFatal(!ret, "mutex failed %d\n", ret); } @@ -2002,13 +2001,11 @@ static void handle_reconfiguration_with_sync(NR_UE_MAC_INST_t *mac, ra->ra_state = nrRA_UE_IDLE; nr_ue_mac_default_configs(mac); - if (!get_softmodem_params()->emulate_l1) { - mac->synch_request.Mod_id = mac->ue_id; - mac->synch_request.CC_id = cc_idP; - mac->synch_request.synch_req.target_Nid_cell = mac->physCellId; - mac->if_module->synch_request(&mac->synch_request); - mac->if_module->phy_config_request(&mac->phy_config); - } + mac->synch_request.Mod_id = mac->ue_id; + mac->synch_request.CC_id = cc_idP; + mac->synch_request.synch_req.target_Nid_cell = mac->physCellId; + mac->if_module->synch_request(&mac->synch_request); + mac->if_module->phy_config_request(&mac->phy_config); } static void configure_physicalcellgroup(NR_UE_MAC_INST_t *mac, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index 3e41ec0980..b7ebd5a651 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -646,8 +646,6 @@ typedef struct NR_UE_MAC_INST_s { NR_TimeAlignmentTimer_t timeAlignmentTimerCommon; NR_timer_t time_alignment_timer; - nr_emulated_l1_t nr_ue_emul_l1; - pthread_mutex_t mutex_dl_info; //SIDELINK MAC PARAMETERS diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 3f3df90cde..c6385e765c 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -1253,7 +1253,6 @@ void prepare_msg4_msgb_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack) NR_UE_DL_HARQ_STATUS_t *current_harq = &mac->dl_harq_info[pid]; int sched_slot = current_harq->ul_slot; int sched_frame = current_harq->ul_frame; - mac->nr_ue_emul_l1.num_harqs = 1; PUCCH_sched_t pucch = {.n_CCE = current_harq->n_CCE, .N_CCE = current_harq->N_CCE, .ack_payload = ack_nack, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index f2f783869c..0b1d7dfaa9 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2420,11 +2420,6 @@ bool get_downlink_ack(NR_UE_MAC_INST_t *mac, frame_t frame, int slot, PUCCH_sche dl_harq_pid, current_harq->ul_frame, current_harq->ul_slot); /* check if current tx slot should transmit downlink acknowlegment */ if (current_harq->ul_frame == frame && current_harq->ul_slot == slot) { - if (get_softmodem_params()->emulate_l1) { - mac->nr_ue_emul_l1.harq[dl_harq_pid].active = true; - mac->nr_ue_emul_l1.harq[dl_harq_pid].active_dl_harq_sfn = frame; - mac->nr_ue_emul_l1.harq[dl_harq_pid].active_dl_harq_slot = slot; - } if (res_ind != -1 && res_ind != current_harq->pucch_resource_indicator) LOG_E(NR_MAC, "Value of pucch_resource_indicator %d not matching with what set before %d (Possibly due to a false DCI) \n", @@ -3037,18 +3032,6 @@ static csi_payload_t get_csirs_RI_PMI_CQI_payload(NR_UE_MAC_INST_t *mac, int pmi_x1_bitlen = csi_report->csi_meas_bitlen.pmi_x1_bitlen[mac->l1_measurements.rank_indicator]; int pmi_x2_bitlen = csi_report->csi_meas_bitlen.pmi_x2_bitlen[mac->l1_measurements.rank_indicator]; int cqi_bitlen = csi_report->csi_meas_bitlen.cqi_bitlen[mac->l1_measurements.rank_indicator]; - - if (get_softmodem_params()->emulate_l1) { - static const uint8_t mcs_to_cqi[] = {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, - 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15}; - CHECK_INDEX(nr_bler_data, NR_NUM_MCS - 1); - int mcs = get_mcs_from_sinr(nr_bler_data, (mac->nr_ue_emul_l1.cqi - 640) * 0.1); - CHECK_INDEX(mcs_to_cqi, mcs); - mac->l1_measurements.rank_indicator = mac->nr_ue_emul_l1.ri; - mac->l1_measurements.i1 = mac->nr_ue_emul_l1.pmi; - mac->l1_measurements.cqi = mcs_to_cqi[mcs]; - } - int padding_bitlen = 0; // TODO: Improvements will be needed to cri_bitlen>0 and pmi_x1_bitlen>0 if (mapping_type == ON_PUSCH) { @@ -4291,21 +4274,6 @@ static void nr_ue_process_rar(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *d handle_rar_reception(mac, rar, frame, slot); if (ra->cfra) nr_ra_succeeded(mac, dl_info->gNB_index, frame, slot); - if (get_softmodem_params()->emulate_l1) { - /* When we are emulating L1 with multiple UEs, the rx_indication will have - multiple RAR PDUs. The code would previously handle each of these PDUs, - but it should only be handling the single RAR that matches the current - UE. */ - LOG_I(NR_MAC, "RAR PDU found for our UE with PDU index %d\n", pdu_id); - dl_info->rx_ind->number_pdus = 1; - if (pdu_id != 0) { - memcpy(&dl_info->rx_ind->rx_indication_body[0], - &dl_info->rx_ind->rx_indication_body[pdu_id], - sizeof(fapi_nr_rx_indication_body_t)); - } - mac->nr_ue_emul_l1.expected_rar = false; - memset(mac->nr_ue_emul_l1.index_has_rar, 0, sizeof(mac->nr_ue_emul_l1.index_has_rar)); - } break; } if (rarh->E == 0) { diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 16af9b4883..03bd8b6fd4 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1718,10 +1718,6 @@ static bool schedule_uci_on_pusch(NR_UE_MAC_INST_t *mac, static void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frame, int slot) { PUCCH_sched_t pucch[3] = {0}; // TODO the size might change in the future in case of multiple SR or multiple CSI in a slot - - mac->nr_ue_emul_l1.num_srs = 0; - mac->nr_ue_emul_l1.num_harqs = 0; - mac->nr_ue_emul_l1.num_csi_reports = 0; int num_res = 0; if (mac->ra.ra_pucch) { @@ -1771,9 +1767,6 @@ static void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frame, int slot pucch[j].n_harq, pucch[j].n_sr, pucch[j].n_csi); - mac->nr_ue_emul_l1.num_srs = pucch[j].n_sr; - mac->nr_ue_emul_l1.num_harqs = pucch[j].n_harq; - mac->nr_ue_emul_l1.num_csi_reports = pucch[j].n_csi; // checking if we need to schedule pucch[j] on PUSCH if (schedule_uci_on_pusch(mac, frame, slot, &pucch[j], mac->current_UL_BWP)) @@ -1784,9 +1777,6 @@ static void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frame, int slot LOG_E(NR_MAC, "Error in pucch allocation\n"); return; } - DevAssert(mac->current_DL_BWP != NULL); - int mu = mac->current_DL_BWP->scs; - mac->nr_ue_emul_l1.active_uci_sfn_slot = NFAPI_SFNSLOT2DEC(mu, frame, slot); int ret = nr_ue_configure_pucch(mac, slot, frame, diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index f93044f9cd..e0afa1ee35 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -1262,7 +1262,7 @@ pdcp_run ( // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer // if (LINK_ENB_PDCP_TO_GTPV1U && ctxt_pP->enb_flag == ENB_FLAG_NO) { - if (!get_softmodem_params()->emulate_l1 && (IS_SOFTMODEM_NOS1 || ctxt_pP->enb_flag == ENB_FLAG_NO)) { + if (IS_SOFTMODEM_NOS1 || ctxt_pP->enb_flag == ENB_FLAG_NO) { pdcp_fifo_read_input_sdus(ctxt_pP); } @@ -1272,9 +1272,7 @@ pdcp_run ( } else { start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip); } - if (!get_softmodem_params()->emulate_l1) { - pdcp_fifo_flush_sdus(ctxt_pP); - } + pdcp_fifo_flush_sdus(ctxt_pP); if (ctxt_pP->enb_flag) { stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_ip); diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h index ce6acffc2c..52a0f28871 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h @@ -138,8 +138,6 @@ void NR_IF_Module_kill(int Mod_id); void NR_UL_indication(NR_UL_IND_t *UL_INFO); -void RCconfig_nr_ue_macrlc(void); - /*Interface for Downlink, transmitting the DLSCH SDU, DCI SDU*/ void NR_Schedule_Response(NR_Sched_Rsp_t *Sched_INFO); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 1f86c61be5..23cd60b25f 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -30,41 +30,16 @@ * \warning */ -#include -#include -#include - #include "PHY/defs_nr_UE.h" #include "NR_IF_Module.h" #include "NR_MAC_UE/mac_proto.h" #include "assertions.h" #include "SCHED_NR_UE/fapi_nr_ue_l1.h" -#include "executables/softmodem-common.h" #include "openair2/RRC/NR_UE/L2_interface_ue.h" -#include "openair2/GNB_APP/L1_nr_paramdef.h" -#include "openair2/GNB_APP/gnb_paramdef.h" -#include "radio/ETHERNET/if_defs.h" -#include -#include "openair2/GNB_APP/MACRLC_nr_paramdef.h" #define MAX_IF_MODULES 100 -UL_IND_t *UL_INFO = NULL; - -static eth_params_t stub_eth_params; static nr_ue_if_module_t *nr_ue_if_module_inst[MAX_IF_MODULES]; -static int ue_tx_sock_descriptor = -1; -static int ue_rx_sock_descriptor = -1; -static int g_harq_pid; -sem_t sfn_slot_semaphore; - -queue_t nr_sfn_slot_queue; -queue_t nr_chan_param_queue; -queue_t nr_dl_tti_req_queue; -queue_t nr_tx_req_queue; -queue_t nr_ul_dci_req_queue; -queue_t nr_ul_tti_req_queue; -static void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request); void print_ue_mac_stats(const module_id_t mod, const int frame_rx, const int slot_rx) { @@ -126,956 +101,6 @@ void print_ue_mac_stats(const module_id_t mod, const int frame_rx, const int slo AssertFatal(!ret, "mutex failed %d\n", ret); } -void nrue_init_standalone_socket(int tx_port, int rx_port) -{ - { - struct sockaddr_in server_address; - int addr_len = sizeof(server_address); - memset(&server_address, 0, addr_len); - server_address.sin_family = AF_INET; - server_address.sin_port = htons(tx_port); - - int sd = socket(server_address.sin_family, SOCK_DGRAM, 0); - if (sd < 0) - { - LOG_E(NR_MAC, "Socket creation error standalone PNF\n"); - return; - } - - if (inet_pton(server_address.sin_family, stub_eth_params.remote_addr, &server_address.sin_addr) <= 0) - { - LOG_E(NR_MAC, "Invalid standalone PNF Address\n"); - close(sd); - return; - } - - // Using connect to use send() instead of sendto() - if (connect(sd, (struct sockaddr *)&server_address, addr_len) < 0) - { - LOG_E(NR_MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); - close(sd); - return; - } - assert(ue_tx_sock_descriptor == -1); - ue_tx_sock_descriptor = sd; - LOG_T(NR_RRC, "Successfully set up tx_socket in %s.\n", __FUNCTION__); - } - - { - struct sockaddr_in server_address; - int addr_len = sizeof(server_address); - memset(&server_address, 0, addr_len); - server_address.sin_family = AF_INET; - server_address.sin_addr.s_addr = INADDR_ANY; - server_address.sin_port = htons(rx_port); - - int sd = socket(server_address.sin_family, SOCK_DGRAM, 0); - if (sd < 0) - { - LOG_E(MAC, "Socket creation error standalone PNF\n"); - return; - } - - if (bind(sd, (struct sockaddr *)&server_address, addr_len) < 0) - { - LOG_E(NR_MAC, "Connection to standalone PNF failed: %s\n", strerror(errno)); - close(sd); - return; - } - assert(ue_rx_sock_descriptor == -1); - ue_rx_sock_descriptor = sd; - LOG_T(NR_RRC, "Successfully set up rx_socket in %s.\n", __FUNCTION__); - } - LOG_D(NR_RRC, "NRUE standalone socket info: tx_port %d rx_port %d on %s.\n", - tx_port, rx_port, stub_eth_params.remote_addr); -} - -void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id) -{ - switch(msg_id) - { - case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: - { - char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_T(NR_MAC, "RACH header id :%d\n", UL_INFO->rach_ind.header.message_id); - int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->rach_ind, buffer, sizeof(buffer), NULL); - if (encoded_size <= 0) - { - LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); - return; - } - - LOG_D(NR_MAC, "NR_RACH_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, - UL_INFO->rach_ind.sfn, UL_INFO->rach_ind.slot, UL_INFO->rach_ind.number_of_pdus); - if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) - { - LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); - return; - } - break; - } - case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: - { - char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_T(NR_MAC, "RX header id :%d\n", UL_INFO->rx_ind.header.message_id); - int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->rx_ind, buffer, sizeof(buffer), NULL); - if (encoded_size <= 0) - { - LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); - return; - } - - LOG_D(NR_MAC, "NR_RX_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, - UL_INFO->rx_ind.sfn, UL_INFO->rx_ind.slot, UL_INFO->rx_ind.number_of_pdus); - if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) - { - LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); - return; - } - break; - } - case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: - { - char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_T(NR_MAC, "CRC header id :%d\n", UL_INFO->crc_ind.header.message_id); - int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->crc_ind, buffer, sizeof(buffer), NULL); - if (encoded_size <= 0) - { - LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); - return; - } - - LOG_D(NR_MAC, "NR_CRC_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, - UL_INFO->crc_ind.sfn, UL_INFO->crc_ind.slot, UL_INFO->crc_ind.number_crcs); - if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) - { - LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); - return; - } - break; - } - case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: - { - char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - LOG_D(NR_MAC, "UCI header id :%d\n", UL_INFO->uci_ind.header.message_id); - int encoded_size = nfapi_nr_p7_message_pack(&UL_INFO->uci_ind, buffer, sizeof(buffer), NULL); - if (encoded_size <= 0) - { - LOG_E(NR_MAC, "nfapi_nr_p7_message_pack has failed. Encoded size = %d\n", encoded_size); - return; - } - - LOG_D(NR_MAC, "NR_UCI_IND sent to Proxy, Size: %d Frame %d Slot %d Num PDUS %d\n", encoded_size, - UL_INFO->uci_ind.sfn, UL_INFO->uci_ind.slot, UL_INFO->uci_ind.num_ucis); - if (send(ue_tx_sock_descriptor, buffer, encoded_size, 0) < 0) - { - LOG_E(NR_MAC, "Send Proxy NR_UE failed\n"); - return; - } - break; - } - case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION: - break; - default: - break; - } -} - -bool sfn_slot_matcher(void *sfn_slot_s, void *candidate) -{ - nfapi_p7_message_header_t *msg = candidate; - const struct sfn_slot_s *sfn_sf = (const struct sfn_slot_s *)sfn_slot_s; - - switch (msg->message_id) - { - case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION: - { - nfapi_nr_rach_indication_t *ind = candidate; - return sfn_sf->sfn == ind->sfn && sfn_sf->slot == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION: - { - nfapi_nr_rx_data_indication_t *ind = candidate; - return sfn_sf->sfn == ind->sfn && sfn_sf->slot == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION: - { - nfapi_nr_crc_indication_t *ind = candidate; - return sfn_sf->sfn == ind->sfn && sfn_sf->slot == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION: - { - nfapi_nr_uci_indication_t *ind = candidate; - return sfn_sf->sfn == ind->sfn && sfn_sf->slot == ind->slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: - { - nfapi_nr_dl_tti_request_t *ind = candidate; - return sfn_sf->sfn == ind->SFN && sfn_sf->slot == ind->Slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: - { - nfapi_nr_tx_data_request_t *ind = candidate; - return sfn_sf->sfn == ind->SFN && sfn_sf->slot == ind->Slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: - { - nfapi_nr_ul_dci_request_t *ind = candidate; - return sfn_sf->sfn == ind->SFN && sfn_sf->slot == ind->Slot; - } - - case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: - { - nfapi_nr_ul_tti_request_t *ind = candidate; - return sfn_sf->sfn == ind->SFN && sfn_sf->slot == ind->Slot; - } - - default: - LOG_E(NR_MAC, "sfn_slot_match bad ID: %d\n", msg->message_id); - - } - - return false; -} - -static void fill_dl_info_with_pdcch(fapi_nr_dci_indication_t *dci, nfapi_nr_dl_dci_pdu_t *rx_dci, int idx) -{ - int num_bytes = (rx_dci->PayloadSizeBits + 7) / 8; - LOG_D(NR_PHY, "[%d, %d] PDCCH DCI (Payload) for rnti %x with PayloadSizeBits %d, num_bytes %d\n", - dci->SFN, dci->slot, rx_dci->RNTI, rx_dci->PayloadSizeBits, num_bytes); - for (int k = 0; k < num_bytes; k++) - { - LOG_D(NR_MAC, "PDCCH DCI PDU payload[%d] = %d\n", k, rx_dci->Payload[k]); - dci->dci_list[idx].payloadBits[k] = rx_dci->Payload[k]; - } - dci->dci_list[idx].payloadSize = rx_dci->PayloadSizeBits; - dci->dci_list[idx].rnti = rx_dci->RNTI; - dci->dci_list[idx].n_CCE = rx_dci->CceIndex; - dci->dci_list[idx].N_CCE = rx_dci->AggregationLevel; - dci->number_of_dcis = idx + 1; -} - -static void fill_mib_in_rx_ind(nfapi_nr_dl_tti_request_pdu_t *pdu_list, fapi_nr_rx_indication_t *rx_ind, int pdu_idx, int pdu_type) -{ - AssertFatal(pdu_idx < sizeof(rx_ind->rx_indication_body) / sizeof(rx_ind->rx_indication_body[0]), - "pdu_index (%d) is greater than rx_indication_body size!\n", pdu_idx); - AssertFatal(pdu_idx == rx_ind->number_pdus, "Invalid pdu_idx %d!\n", pdu_idx); - - LOG_T(NR_MAC, "Recevied an SSB and are filling rx_ind with the MIB!\n"); - - nfapi_nr_dl_tti_ssb_pdu_rel15_t *ssb_pdu = &pdu_list->ssb_pdu.ssb_pdu_rel15; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.cell_id = ssb_pdu->PhysCellId; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[0] = (ssb_pdu->bchPayload) & 0xff; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[1] = (ssb_pdu->bchPayload >> 8) & 0xff; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.pdu[2] = (ssb_pdu->bchPayload >> 16) & 0xff; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_index = ssb_pdu->SsbBlockIndex; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_length = pdu_list->PDUSize; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.ssb_start_subcarrier = ssb_pdu->SsbSubcarrierOffset; - rx_ind->rx_indication_body[pdu_idx].ssb_pdu.decoded_pdu = true; - rx_ind->rx_indication_body[pdu_idx].pdu_type = pdu_type; - rx_ind->number_pdus = pdu_idx + 1; -} - -static bool is_my_dci(NR_UE_MAC_INST_t *mac, nfapi_nr_dl_dci_pdu_t *received_pdu) -{ - /* For multiple UEs, we need to be able to filter the rx'd messages by - the RNTI. The filtering is different between NSA mode and SA mode. - NSA mode has a two step CFRA procedure and SA has a 4 step procedure. - We only need to check if the rx'd RNTI doesnt match the CRNTI if the RAR - has been processed already, in NSA mode. - In SA, depending on the RA state, we can have a SIB (0xffff), RAR (0x10b), - Msg3 (TC_RNTI) or an actual DCI message (CRNTI). When we get Msg3, the - MAC instance of the UE still has a CRNTI = 0. We should only check if the - CRNTI doesnt match the received RNTI in SA mode if Msg3 has been processed - already. Only once the RA procedure succeeds is the CRNTI value updated - to the TC_RNTI. */ - if (get_softmodem_params()->nsa) { - if (received_pdu->RNTI != mac->crnti && (received_pdu->RNTI != mac->ra.ra_rnti)) - return false; - } - if (IS_SA_MODE(get_softmodem_params())) { - if (mac->state == UE_NOT_SYNC) - return false; - if (received_pdu->RNTI == 0xFFFF) - return false; - if (received_pdu->RNTI != mac->crnti && mac->ra.ra_state == nrRA_SUCCEEDED) - return false; - if (received_pdu->RNTI != mac->ra.t_crnti && mac->ra.ra_state == nrRA_WAIT_CONTENTION_RESOLUTION) - return false; - if (received_pdu->RNTI != 0x10b && mac->ra.ra_state == nrRA_WAIT_RAR) - return false; - if (received_pdu->RNTI != 0xFFFF && mac->ra.ra_state <= nrRA_GENERATE_PREAMBLE) - return false; - } - return true; -} - -static void copy_dl_tti_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_dl_tti_request_t *dl_tti_request) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); - mac->nr_ue_emul_l1.expected_sib = false; - memset(mac->nr_ue_emul_l1.index_has_sib, 0, sizeof(mac->nr_ue_emul_l1.index_has_sib)); - mac->nr_ue_emul_l1.expected_rar = false; - memset(mac->nr_ue_emul_l1.index_has_rar, 0, sizeof(mac->nr_ue_emul_l1.index_has_rar)); - mac->nr_ue_emul_l1.expected_dci = false; - memset(mac->nr_ue_emul_l1.index_has_dci, 0, sizeof(mac->nr_ue_emul_l1.index_has_dci)); - int pdu_idx = 0; - - int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs; - AssertFatal(num_pdus >= 0, "Invalid dl_tti_request number of PDUS\n"); - - for (int i = 0; i < num_pdus; i++) - { - nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; - if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) - { - LOG_D(NR_PHY, "[%d, %d] PDSCH PDU for rnti %x\n", - dl_tti_request->SFN, dl_tti_request->Slot, pdu_list->pdsch_pdu.pdsch_pdu_rel15.rnti); - } - - if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDCCH_PDU_TYPE) - { - LOG_D(NR_PHY, "[%d, %d] PDCCH DCI PDU (Format for incoming PDSCH PDU)\n", - dl_tti_request->SFN, dl_tti_request->Slot); - uint16_t num_dcis = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci; - if (num_dcis > 0) - { - if (!dl_info->dci_ind) - { - dl_info->dci_ind = CALLOC(1, sizeof(fapi_nr_dci_indication_t)); - } - dl_info->dci_ind->SFN = dl_tti_request->SFN; - dl_info->dci_ind->slot = dl_tti_request->Slot; - AssertFatal(num_dcis <= sizeof(dl_info->dci_ind->dci_list) / sizeof(dl_info->dci_ind->dci_list[0]), - "The number of DCIs is greater than dci_list"); - for (int j = 0; j < num_dcis; j++) - { - nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; - if (!is_my_dci(mac, dci_pdu_list)) - { - continue; - } - fill_dl_info_with_pdcch(dl_info->dci_ind, dci_pdu_list, pdu_idx); - if (dci_pdu_list->RNTI == 0xffff) - { - mac->nr_ue_emul_l1.expected_sib = true; - mac->nr_ue_emul_l1.index_has_sib[j] = true; - LOG_T(NR_MAC, "Setting index_has_sib[%d] = true\n", j); - } - else if (dci_pdu_list->RNTI == mac->ra.ra_rnti) - { - mac->nr_ue_emul_l1.expected_rar = true; - mac->nr_ue_emul_l1.index_has_rar[j] = true; - LOG_T(NR_MAC, "Setting index_has_rar[%d] = true\n", j); - } - else - { - mac->nr_ue_emul_l1.expected_dci = true; - mac->nr_ue_emul_l1.index_has_dci[j] = true; - LOG_T(NR_MAC, "Setting index_has_dci[%d] = true\n", j); - } - pdu_idx++; - } - } - } - if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) - { - /* If we get a MIB, we want to handle it right away and then come back. - The MIB and SIB come in the same dl_tti_req but the MIB should be - processed first and then the DCI and payload of the SIB1 can be - processed. The MIB should be handled first and then the rx_ind - will be freed after handling. This is why the PDU index will - always be zero for the RX_IND becasue we should not have more than - one MIB. */ - if (!dl_info->rx_ind) - { - dl_info->rx_ind = CALLOC(1, sizeof(*dl_info->rx_ind)); - } - fapi_nr_rx_indication_t *rx_ind = dl_info->rx_ind; - rx_ind->sfn = dl_tti_request->SFN; - rx_ind->slot = dl_tti_request->Slot; - fill_mib_in_rx_ind(pdu_list, rx_ind, 0, FAPI_NR_RX_PDU_TYPE_SSB); - nr_ue_dl_indication(&mac->dl_info); - } - } - dl_info->slot = dl_tti_request->Slot; - dl_info->frame = dl_tti_request->SFN; -} - -static void fill_rx_ind(nfapi_nr_pdu_t *pdu_list, fapi_nr_rx_indication_t *rx_ind, int pdu_idx, int pdu_type) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - AssertFatal(pdu_list->num_TLV < sizeof(pdu_list->TLVs) / sizeof(pdu_list->TLVs[0]), "Num TLVs exceeds TLV array size"); - int length = 0; - for (int j = 0; j < pdu_list->num_TLV; j++) - { - length += pdu_list->TLVs[j].length; - } - LOG_D(NR_PHY, "%s: num_tlv %d and length %d, pdu index %d\n", - __FUNCTION__, pdu_list->num_TLV, length, pdu_idx); - uint8_t *pdu = malloc(length); - AssertFatal(pdu != NULL, "%s: Out of memory in malloc", __FUNCTION__); - rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.pdu = pdu; - for (int j = 0; j < pdu_list->num_TLV; j++) - { - const uint32_t *ptr; - if (pdu_list->TLVs[j].tag) - ptr = pdu_list->TLVs[j].value.ptr; - else - ptr = pdu_list->TLVs[j].value.direct; - memcpy(pdu, ptr, pdu_list->TLVs[j].length); - pdu += pdu_list->TLVs[j].length; - } - bool ack_nack = true; - if (mac->ra.ra_state >= nrRA_SUCCEEDED && should_drop_transport_block(rx_ind->slot, mac->crnti)) { - ack_nack = false; - } - rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.ack_nack = ack_nack; - rx_ind->rx_indication_body[pdu_idx].pdsch_pdu.pdu_length = length; - rx_ind->rx_indication_body[pdu_idx].pdu_type = pdu_type; - -} - - -static void copy_tx_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_tx_data_request_t *tx_data_request) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); - int num_pdus = tx_data_request->Number_of_PDUs; - AssertFatal(num_pdus >= 0, "Invalid tx_data_request number of PDUS\n"); - - if (!dl_info->rx_ind) - { - dl_info->rx_ind = CALLOC(num_pdus, sizeof(fapi_nr_rx_indication_t)); - } - AssertFatal(dl_info->rx_ind != NULL, "%s: Out of memory in calloc", __FUNCTION__); - fapi_nr_rx_indication_t *rx_ind = dl_info->rx_ind; - rx_ind->sfn = tx_data_request->SFN; - rx_ind->slot = tx_data_request->Slot; - - int pdu_idx = 0; - - for (int i = 0; i < num_pdus; i++) - { - nfapi_nr_pdu_t *pdu_list = &tx_data_request->pdu_list[i]; - if (mac->nr_ue_emul_l1.index_has_sib[i]) - { - AssertFatal(!get_softmodem_params()->nsa, - "Should not be processing SIB in NSA mode, something bad happened\n"); - fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_SIB); - pdu_idx++; - } - else if (mac->nr_ue_emul_l1.index_has_rar[i]) - { - fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_RAR); - pdu_idx++; - } - else if (mac->nr_ue_emul_l1.index_has_dci[i]) - { - fill_rx_ind(pdu_list, rx_ind, pdu_idx, FAPI_NR_RX_PDU_TYPE_DLSCH); - pdu_idx++; - } - else - { - LOG_T(NR_MAC, "mac->nr_ue_emul_l1.index_has_dci[%d] = 0, so this index contained a DCI for a different UE\n", i); - } - - } - dl_info->slot = tx_data_request->Slot; - dl_info->frame = tx_data_request->SFN; - dl_info->rx_ind->number_pdus = pdu_idx; -} - -static void copy_ul_dci_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_dci_request_t *ul_dci_req) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(dl_info->module_id); - int pdu_idx = 0; - - int num_pdus = ul_dci_req->numPdus; - AssertFatal(num_pdus >= 0, "Invalid ul_dci_request number of PDUS\n"); - - for (int i = 0; i < num_pdus; i++) - { - nfapi_nr_ul_dci_request_pdus_t *pdu_list = &ul_dci_req->ul_dci_pdu_list[i]; - AssertFatal(pdu_list->PDUType == 0, "ul_dci_req pdu type != PUCCH"); - LOG_D(NR_PHY, "[%d %d] PUCCH PDU in ul_dci for rnti %x and numDLDCI = %d\n", - ul_dci_req->SFN, ul_dci_req->Slot, pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu->RNTI, - pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci); - uint16_t num_dci = pdu_list->pdcch_pdu.pdcch_pdu_rel15.numDlDci; - if (num_dci > 0) - { - if (!dl_info->dci_ind) - { - dl_info->dci_ind = CALLOC(1, sizeof(fapi_nr_dci_indication_t)); - } - AssertFatal(dl_info->dci_ind != NULL, "%s: Out of memory in calloc", __FUNCTION__); - dl_info->dci_ind->SFN = ul_dci_req->SFN; - dl_info->dci_ind->slot = ul_dci_req->Slot; - AssertFatal(num_dci < sizeof(dl_info->dci_ind->dci_list) / sizeof(dl_info->dci_ind->dci_list[0]), "The number of DCIs is greater than dci_list"); - for (int j = 0; j < num_dci; j++) - { - nfapi_nr_dl_dci_pdu_t *dci_pdu_list = &pdu_list->pdcch_pdu.pdcch_pdu_rel15.dci_pdu[j]; - if (dci_pdu_list->RNTI != mac->crnti) - { - LOG_T(NR_MAC, "dci_pdu_list->RNTI (%x) != mac->crnti (%x)\n", dci_pdu_list->RNTI, mac->crnti); - continue; - } - fill_dl_info_with_pdcch(dl_info->dci_ind, dci_pdu_list, pdu_idx); - pdu_idx++; - } - } - } - dl_info->frame = ul_dci_req->SFN; - dl_info->slot = ul_dci_req->Slot; -} - -static bool send_crc_ind_and_rx_ind(int sfn, int slot) -{ - bool sent_crc_rx = true; - - struct sfn_slot_s sfn_slot = {.sfn = sfn, .slot = slot}; - nfapi_nr_rx_data_indication_t *rx_ind = unqueue_matching(&nr_rx_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - nfapi_nr_crc_indication_t *crc_ind = unqueue_matching(&nr_crc_ind_queue, MAX_QUEUE_SIZE, sfn_slot_matcher, &sfn_slot); - - if (crc_ind && crc_ind->number_crcs > 0) - { - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - for (int i = 0; i < crc_ind->number_crcs; i++) { - int harq_pid = crc_ind->crc_list[i].harq_id; - LOG_T(NR_MAC, "Resetting harq_pid %d active_ul_harq_sfn/slot\n", harq_pid); - mac->nr_ue_emul_l1.harq[harq_pid].active_ul_harq_sfn = -1; - mac->nr_ue_emul_l1.harq[harq_pid].active_ul_harq_slot = -1; - } - NR_UL_IND_t UL_INFO = { - .crc_ind = *crc_ind, - }; - send_nsa_standalone_msg(&UL_INFO, crc_ind->header.message_id); - free(crc_ind->crc_list); - free(crc_ind); - } - if (rx_ind && rx_ind->number_of_pdus > 0) - { - NR_UL_IND_t UL_INFO = { - .rx_ind = *rx_ind, - }; - send_nsa_standalone_msg(&UL_INFO, rx_ind->header.message_id); - free(rx_ind->pdu_list); - free(rx_ind); - } - else - { - sent_crc_rx = false; - } - return sent_crc_rx; -} - -static void copy_ul_tti_data_req_to_dl_info(nr_downlink_indication_t *dl_info, nfapi_nr_ul_tti_request_t *ul_tti_req) -{ - int num_pdus = ul_tti_req->n_pdus; - AssertFatal(num_pdus >= 0, "Invalid ul_tti_request number of PDUS\n"); - AssertFatal(num_pdus <= sizeof(ul_tti_req->pdus_list) / sizeof(ul_tti_req->pdus_list[0]), - "Too many pdus %d in ul_tti_req\n", num_pdus); - - if (!send_crc_ind_and_rx_ind(ul_tti_req->SFN, ul_tti_req->Slot)) - { - LOG_T(NR_MAC, "CRC_RX ind not sent\n"); - if (!put_queue(&nr_ul_tti_req_queue, ul_tti_req)) - { - LOG_E(NR_PHY, "put_queue failed for ul_tti_req.\n"); - } - return; - } -} - -static void fill_dci_from_dl_config(nr_downlink_indication_t*dl_ind, fapi_nr_dl_config_request_t *dl_config) -{ - - if (!dl_ind->dci_ind) - return; - - AssertFatal(dl_config->number_pdus < sizeof(dl_config->dl_config_list) / sizeof(dl_config->dl_config_list[0]), - "Too many dl_config pdus %d", dl_config->number_pdus); - for (int i = 0; i < dl_config->number_pdus; i++) { - LOG_D(PHY, "Filling DCI with a total of %d total DL PDUs (dl_config %p) \n", - dl_config->number_pdus, dl_config); - fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15_dci = &dl_config->dl_config_list[i].dci_config_pdu.dci_config_rel15; - int num_dci_options = rel15_dci->num_dci_options; - if (num_dci_options <= 0) - LOG_D(NR_MAC, "num_dci_opts = %d for pdu[%d] in dl_config_list\n", rel15_dci->num_dci_options, i); - AssertFatal(num_dci_options <= sizeof(rel15_dci->dci_length_options) / sizeof(rel15_dci->dci_length_options[0]), - "num_dci_options %d > dci_length_options array\n", num_dci_options); - AssertFatal(num_dci_options <= sizeof(rel15_dci->dci_format_options) / sizeof(rel15_dci->dci_format_options[0]), - "num_dci_options %d > dci_format_options array\n", num_dci_options); - - for (int j = 0; j < num_dci_options; j++) { - int num_dcis = dl_ind->dci_ind->number_of_dcis; - AssertFatal(num_dcis <= sizeof(dl_ind->dci_ind->dci_list) / sizeof(dl_ind->dci_ind->dci_list[0]), - "dl_config->number_pdus %d > dci_ind->dci_list array\n", num_dcis); - for (int k = 0; k < num_dcis; k++) { - LOG_T(NR_PHY, "Received len %d, length options[%d] %d, format assigned %d, format options[%d] %d\n", - dl_ind->dci_ind->dci_list[k].payloadSize, j, rel15_dci->dci_length_options[j], - dl_ind->dci_ind->dci_list[k].dci_format, j, rel15_dci->dci_format_options[j]); - if (rel15_dci->dci_length_options[j] == dl_ind->dci_ind->dci_list[k].payloadSize) { - dl_ind->dci_ind->dci_list[k].dci_format = rel15_dci->dci_format_options[j]; - dl_ind->dci_ind->dci_list[k].ss_type = rel15_dci->ss_type_options[j]; - dl_ind->dci_ind->dci_list[k].coreset_type = rel15_dci->coreset.CoreSetType; - LOG_D(NR_PHY, "format assigned dl_ind->dci_ind->dci_list[k].dci_format %d\n", - dl_ind->dci_ind->dci_list[k].dci_format); - } - } - } - } -} - -// This piece of code is not used in "normal" ue, but in "fapi mode" -void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, - nfapi_nr_tx_data_request_t *tx_data_request, - nfapi_nr_ul_dci_request_t *ul_dci_request, - nfapi_nr_ul_tti_request_t *ul_tti_request) -{ - frame_t frame = 0; - int slot = 0; - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - - if (pthread_mutex_lock(&mac->mutex_dl_info)) abort(); - - if (dl_tti_request) { - frame = dl_tti_request->SFN; - slot = dl_tti_request->Slot; - LOG_D(NR_PHY, "[%d, %d] dl_tti_request\n", frame, slot); - copy_dl_tti_req_to_dl_info(&mac->dl_info, dl_tti_request); - } - /* This checks if the previously recevied DCI matches our current RNTI - value. The assumption is that if the DCI matches our RNTI, then the - incoming tx_data_request is also destined for the current UE. If the - RAR hasn't been processed yet, we do not want to be filtering the - tx_data_requests. */ - if (tx_data_request) { - if (mac->nr_ue_emul_l1.expected_sib || - mac->nr_ue_emul_l1.expected_rar || - mac->nr_ue_emul_l1.expected_dci) { - frame = tx_data_request->SFN; - slot = tx_data_request->Slot; - LOG_D(NR_PHY, "[%d, %d] PDSCH in tx_request\n", frame, slot); - copy_tx_data_req_to_dl_info(&mac->dl_info, tx_data_request); - } - else { - LOG_D(NR_MAC, "Unexpected tx_data_req\n"); - } - } - else if (ul_dci_request) { - frame = ul_dci_request->SFN; - slot = ul_dci_request->Slot; - LOG_D(NR_PHY, "[%d, %d] ul_dci_request\n", frame, slot); - copy_ul_dci_data_req_to_dl_info(&mac->dl_info, ul_dci_request); - } - else if (ul_tti_request) { - frame = ul_tti_request->SFN; - slot = ul_tti_request->Slot; - LOG_T(NR_PHY, "[%d, %d] ul_tti_request\n", frame, slot); - copy_ul_tti_data_req_to_dl_info(&mac->dl_info, ul_tti_request); - } - else { - if (pthread_mutex_unlock(&mac->mutex_dl_info)) abort(); - LOG_T(NR_MAC, "All indications were NULL in %s\n", __FUNCTION__); - return; - } - - if (dl_tti_request || tx_data_request || ul_dci_request) { - fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, slot); - fill_dci_from_dl_config(&mac->dl_info, dl_config); - } - nr_ue_dl_scheduler(mac, &mac->dl_info); - nr_ue_dl_indication(&mac->dl_info); - - if (pthread_mutex_unlock(&mac->mutex_dl_info)) - abort(); - int slots_per_frame = 20; //30 kHZ subcarrier spacing - int slot_ahead = 2; // TODO: Make this dynamic - - if (is_ul_slot((slot + slot_ahead) % slots_per_frame, &mac->frame_structure) - && mac->ra.ra_state != nrRA_SUCCEEDED) { - // If we filled dl_info AFTER we got the slot indication, we want to check if we should fill tx_req: - nr_uplink_indication_t ul_info = {.slot = (slot + slot_ahead) % slots_per_frame, - .frame = slot + slot_ahead >= slots_per_frame ? (frame + 1) % 1024 : frame}; - nr_ue_ul_scheduler(mac, &ul_info); - } -} - -void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request) -{ - int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs; - char buffer[MAX_MESSAGE_SIZE]; - if (num_pdus <= 0) - { - LOG_E(NR_PHY, "%s: dl_tti_request number of PDUS <= 0\n", __FUNCTION__); - abort(); - } - LOG_T(NR_PHY, "%s: dl_tti_request number of PDUS: %d\n", __FUNCTION__, num_pdus); - for (int i = 0; i < num_pdus; i++) - { - nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; - if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) - { - LOG_T(NR_PHY, "Cell_id: %d, the ssb_block_idx %d, sc_offset: %d and payload %d\n", - pdu_list->ssb_pdu.ssb_pdu_rel15.PhysCellId, - pdu_list->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex, - pdu_list->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset, - pdu_list->ssb_pdu.ssb_pdu_rel15.bchPayload); - pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp = 60; - LOG_T(NR_RRC, "Setting pdulist[%d].ssbRsrp to %d\n", i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp); - } - } - - size_t pack_len = nfapi_nr_p7_message_pack((void *)dl_tti_request, - buffer, - sizeof(buffer), - NULL); - if (pack_len < 0) - { - LOG_E(NR_PHY, "%s: Error packing nr p7 message.\n", __FUNCTION__); - } - nsa_sendmsg_to_lte_ue(buffer, pack_len, NR_UE_RRC_MEASUREMENT); - LOG_A(NR_RRC, "Populated NR_UE_RRC_MEASUREMENT information and sent to LTE UE\n"); -} - -static void enqueue_nr_nfapi_msg(void *buffer, ssize_t len, nfapi_p7_message_header_t header) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - switch (header.message_id) - { - case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST: - { - nfapi_nr_dl_tti_request_t *dl_tti_request = malloc16(sizeof(*dl_tti_request)); - const bool result = nfapi_nr_p7_message_unpack(buffer, len, dl_tti_request, sizeof(*dl_tti_request), NULL); - if (!result) { - LOG_E(NR_PHY, "Message dl_tti_request failed to unpack\n"); - break; - } - LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message in sfn/slot %d %d. \n", - dl_tti_request->SFN, dl_tti_request->Slot); - - if (is_channel_modeling()) - save_pdsch_pdu_for_crnti(dl_tti_request); - - if (!put_queue(&nr_dl_tti_req_queue, dl_tti_request)) - { - LOG_E(NR_PHY, "put_queue failed for dl_tti_request.\n"); - free(dl_tti_request); - dl_tti_request = NULL; - } - break; - } - - case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST: - { - nfapi_nr_tx_data_request_t *tx_data_request = malloc16(sizeof(*tx_data_request)); - const bool result = nfapi_nr_p7_message_unpack(buffer, len, tx_data_request, sizeof(*tx_data_request), NULL); - if (!result) { - LOG_E(NR_PHY, "Message tx_data_request failed to unpack\n"); - break; - } - LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message in SFN/slot %d %d. \n", - tx_data_request->SFN, tx_data_request->Slot); - if (!put_queue(&nr_tx_req_queue, tx_data_request)) - { - LOG_E(NR_PHY, "put_queue failed for tx_request.\n"); - free(tx_data_request); - tx_data_request = NULL; - } - break; - } - - case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST: - { - nfapi_nr_ul_dci_request_t *ul_dci_request = malloc16(sizeof(*ul_dci_request)); - const bool result = nfapi_nr_p7_message_unpack(buffer, len, ul_dci_request, sizeof(*ul_dci_request), NULL); - if (!result) { - LOG_E(NR_PHY, "Message ul_dci_request failed to unpack\n"); - break; - } - LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message in SFN/slot %d %d. \n", - ul_dci_request->SFN, ul_dci_request->Slot); - if (!put_queue(&nr_ul_dci_req_queue, ul_dci_request)) - { - LOG_E(NR_PHY, "put_queue failed for ul_dci_request.\n"); - free(ul_dci_request); - ul_dci_request = NULL; - } - break; - } - - case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST: - { - nfapi_nr_ul_tti_request_t *ul_tti_request = malloc16(sizeof(*ul_tti_request)); - const bool result = nfapi_nr_p7_message_unpack(buffer, len, ul_tti_request, sizeof(*ul_tti_request), NULL); - if (!result) { - LOG_E(NR_PHY, "Message ul_tti_request failed to unpack\n"); - break; - } - /* We are filtering UL_TTI_REQs below. We only care about UL_TTI_REQs that - will trigger sending a ul_harq (CRC/RX pair). This UL_TTI_REQ will have - NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE. If we have not yet completed the CBRA/ - CFRA procedure, we need to queue all UL_TTI_REQs. */ - for (int i = 0; i < ul_tti_request->n_pdus; i++) { - if (ul_tti_request->pdus_list[i].pdu_type == NFAPI_NR_UL_CONFIG_PUSCH_PDU_TYPE - && mac->ra.ra_state >= nrRA_SUCCEEDED) { - if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) { - LOG_D(NR_PHY, "put_queue failed for ul_tti_request, calling put_queue_replace.\n"); - nfapi_nr_ul_tti_request_t *evicted_ul_tti_req = put_queue_replace(&nr_ul_tti_req_queue, ul_tti_request); - free(evicted_ul_tti_req); - } - break; - } else if (mac->ra.ra_state < nrRA_SUCCEEDED) { - if (!put_queue(&nr_ul_tti_req_queue, ul_tti_request)) { - LOG_D(NR_PHY, "put_queue failed for ul_tti_request, calling put_queue_replace.\n"); - nfapi_nr_ul_tti_request_t *evicted_ul_tti_req = put_queue_replace(&nr_ul_tti_req_queue, ul_tti_request); - free(evicted_ul_tti_req); - } - break; - } - } - break; - } - - default: - LOG_E(NR_PHY, "Invalid nFAPI message. Header ID %d\n", - header.message_id); - break; - } - return; -} - -static void save_pdsch_pdu_for_crnti(nfapi_nr_dl_tti_request_t *dl_tti_request) -{ - int count_sent = 0; - NR_UE_MAC_INST_t *mac = get_mac_inst(0); - int number_of_pdu = dl_tti_request->dl_tti_request_body.nPDUs; - if (number_of_pdu <= 0) - { - LOG_E(NR_MAC, "%s: dl_tti_request pdu size <= 0\n", __FUNCTION__); - abort(); - } - - for (int i = 0; i < number_of_pdu; i++) - { - const nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i]; - - if (pdu_list->PDUType == NFAPI_NR_DL_TTI_PDSCH_PDU_TYPE) - { - const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *pdsch_pdu = &pdu_list->pdsch_pdu.pdsch_pdu_rel15; - if (pdsch_pdu->rnti == mac->crnti && mac->ra.ra_state == nrRA_SUCCEEDED) { - read_channel_param(pdsch_pdu, dl_tti_request->Slot, count_sent); - count_sent++; - LOG_T(NR_MAC, "pdsch_pdu->rnti %x mac->crnti %x mac->ra.ra_state %d count_sent %d\n", - pdsch_pdu->rnti, mac->crnti, mac->ra.ra_state, count_sent); - } - } - } -} - -static uint16_t get_message_id(const uint8_t *buffer, ssize_t len) -{ - if (len < 4) - return 0; - - // Unpack 2 bytes message_id from buffer. - uint16_t v; - memcpy(&v, buffer + 2, sizeof(v)); - return ntohs(v); -} - -void *nrue_standalone_pnf_task(void *context) -{ - struct sockaddr_in server_address; - socklen_t addr_len = sizeof(server_address); - int sd = ue_rx_sock_descriptor; - assert(sd > 0); - - char buffer[NFAPI_MAX_PACKED_MESSAGE_SIZE]; - - LOG_I(NR_RRC, "Successfully started %s.\n", __FUNCTION__); - - while (true) - { - ssize_t len = recvfrom(sd, buffer, sizeof(buffer), MSG_TRUNC, (struct sockaddr *)&server_address, &addr_len); - if (len == -1) - { - LOG_E(NR_PHY, "reading from standalone pnf sctp socket failed \n"); - continue; - } - if (len > sizeof(buffer)) - { - LOG_E(NR_PHY, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len); - continue; - } - if (len == sizeof(uint16_t)) - { - uint16_t *sfn_slot = CALLOC(1, sizeof(*sfn_slot)); - memcpy(sfn_slot, buffer, sizeof(*sfn_slot)); - - LOG_D(NR_PHY, "Received from proxy sfn_slot %x\n", *sfn_slot); - - if (!put_queue(&nr_sfn_slot_queue, sfn_slot)) - { - LOG_E(NR_PHY, "put_queue failed for sfn slot.\n"); - } - - if (sem_post(&sfn_slot_semaphore) != 0) - { - LOG_E(NR_PHY, "sem_post() error\n"); - abort(); - } - } - else if (get_message_id((const uint8_t *)buffer, len) == 0x0FFF) // 0x0FFF : channel info identifier. - { - nr_phy_channel_params_t *ch_info = CALLOC(1, sizeof(*ch_info)); - memcpy(ch_info, buffer, sizeof(*ch_info)); - - if (ch_info->nb_of_csi > 1) - LOG_W(NR_PHY, "Expecting only one CSI report.\n"); - - // TODO: Update sinr field of slot_rnti_mcs to be array. - for (int i = 0; i < ch_info->nb_of_csi; ++i) - { - int mu = 1; // NR-UE emul-L1 is hardcoded to 30kHZ, see check_and_process_dci() - int frame = NFAPI_SFNSLOTDEC2SFN(mu, ch_info->sfn_slot); - int slot = NFAPI_SFNSLOTDEC2SLOT(mu, ch_info->sfn_slot); - slot_rnti_mcs[slot].sinr = ch_info->csi[i].sinr; - slot_rnti_mcs[slot].area_code = ch_info->csi[i].area_code; - - LOG_D(NR_PHY, "Received_SINR[%d] = %f, sfn:slot %d:%d\n", i, ch_info->csi[i].sinr, frame, slot); - } - - if (!put_queue(&nr_chan_param_queue, ch_info)) - { - LOG_E(NR_PHY, "put_queue failed for sfn slot.\n"); - } - - if (sem_post(&sfn_slot_semaphore) != 0) - { - LOG_E(NR_MAC, "sem_post() error\n"); - abort(); - } - } - else - { - nfapi_p7_message_header_t header; - if (nfapi_p7_message_header_unpack(buffer, len, &header, sizeof(header), NULL) < 0) - { - LOG_E(NR_PHY, "Header unpack failed for nrue_standalone pnf\n"); - continue; - } - enqueue_nr_nfapi_msg(buffer, len, header); - } - } //while(true) -} - // L2 Abstraction Layer static int handle_bcch_bch(NR_UE_MAC_INST_t *mac, int cc_id, @@ -1141,13 +166,6 @@ static nr_dci_format_t handle_dci(NR_UE_MAC_INST_t *mac, // Note: sdu should always be processed because data and timing advance updates are transmitted by the UE static int8_t handle_dlsch(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, int pdu_id) { - /* L1 assigns harq_pid, but in emulated L1 mode we need to assign - the harq_pid based on the saved global g_harq_pid. Because we are - emulating L1, no antenna measurements are conducted to calculate - a harq_pid, therefore we must set it here. */ - if (get_softmodem_params()->emulate_l1) - dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid = g_harq_pid; - if (mac->ra.ra_state != nrRA_WAIT_RAR) // no HARQ for MSG2 update_harq_status(mac, dl_info->rx_ind->rx_indication_body[pdu_id].pdsch_pdu.harq_pid, @@ -1232,9 +250,6 @@ static uint32_t nr_ue_dl_processing(NR_UE_MAC_INST_t *mac, nr_downlink_indicatio continue; } dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dl_info->slot][dci_format]; - g_harq_pid = def_dci_pdu_rel15->harq_pid.val; - LOG_T(NR_MAC, "Setting harq_pid = %d and dci_index = %d (based on format)\n", g_harq_pid, dci_format); - ret_mask |= (1 << FAPI_NR_DCI_IND); AssertFatal(nr_ue_if_module_inst[dl_info->module_id] != NULL, "IF module is NULL!\n"); fapi_nr_dl_config_request_t *dl_config = get_dl_config_request(mac, dl_info->slot); @@ -1362,45 +377,14 @@ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id) nr_ue_if_module_inst[module_id]->sl_phy_config_request = nr_ue_sl_phy_config_request; nr_ue_if_module_inst[module_id]->sl_indication = nr_ue_sl_indication; } - if (get_softmodem_params()->emulate_l1) - nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response_stub; - else - nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response; + nr_ue_if_module_inst[module_id]->scheduled_response = nr_ue_scheduled_response; nr_ue_if_module_inst[module_id]->dl_indication = nr_ue_dl_indication; nr_ue_if_module_inst[module_id]->ul_indication = nr_ue_ul_indication; nr_ue_if_module_inst[module_id]->slot_indication = nr_ue_slot_indication; } - return nr_ue_if_module_inst[module_id]; } -void RCconfig_nr_ue_macrlc(void) { - int j; - paramdef_t MACRLC_Params[] = MACRLCPARAMS_DESC; - paramlist_def_t MACRLC_ParamList = {CONFIG_STRING_MACRLC_LIST, NULL, 0}; - - config_getlist(config_get_if(), &MACRLC_ParamList, MACRLC_Params, sizeofArray(MACRLC_Params), NULL); - if (MACRLC_ParamList.numelt > 0) { - for (j = 0; j < MACRLC_ParamList.numelt; j++) { - if (strcmp(*(MACRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { - stub_eth_params.my_addr = strdup( - *(MACRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_ADDRESS_IDX].strptr)); - stub_eth_params.remote_addr = strdup( - *(MACRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_ADDRESS_IDX].strptr)); - stub_eth_params.my_portc = - *(MACRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTC_IDX].iptr); - stub_eth_params.remote_portc = - *(MACRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTC_IDX].iptr); - stub_eth_params.my_portd = - *(MACRLC_ParamList.paramarray[j][MACRLC_LOCAL_N_PORTD_IDX].iptr); - stub_eth_params.remote_portd = - *(MACRLC_ParamList.paramarray[j][MACRLC_REMOTE_N_PORTD_IDX].iptr); - stub_eth_params.transp_preference = ETH_UDP_MODE; - } - } - } -} - static void handle_sl_bch(int ue_id, sl_nr_ue_mac_params_t *sl_mac, uint8_t *const sl_mib, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h index 2bbd97db84..a1175282f0 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h @@ -34,11 +34,8 @@ #define __NR_IF_MODULE_H__ #include "common/platform_types.h" -#include #include "fapi_nr_ue_interface.h" -#include "openair2/PHY_INTERFACE/queue_t.h" #include "openair2/NR_PHY_INTERFACE/NR_IF_Module.h" -#include "NR_Packet_Drop.h" #include "nfapi/open-nFAPI/nfapi/public_inc/sidelink_nr_ue_interface.h" typedef enum sl_sidelink_slot_type { @@ -50,19 +47,6 @@ typedef enum sl_sidelink_slot_type { } sl_sidelink_slot_type_t; -extern queue_t nr_rach_ind_queue; -extern queue_t nr_rx_ind_queue; -extern queue_t nr_crc_ind_queue; -extern queue_t nr_uci_ind_queue; -extern queue_t nr_sfn_slot_queue; -extern queue_t nr_chan_param_queue; -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; - -extern slot_rnti_mcs_s slot_rnti_mcs[NUM_NFAPI_SLOT]; - typedef struct NR_UL_TIME_ALIGNMENT NR_UL_TIME_ALIGNMENT_t; typedef struct { @@ -292,32 +276,6 @@ typedef struct nr_ue_if_module_s { \param module_id module id*/ nr_ue_if_module_t *nr_ue_if_module_init(uint32_t module_id); -void nrue_init_standalone_socket(int tx_port, int rx_port); - -void *nrue_standalone_pnf_task(void *context); -extern sem_t sfn_slot_semaphore; - -typedef struct nfapi_dl_tti_config_req_tx_data_req_t -{ - nfapi_nr_dl_tti_request_pdu_t *dl_itti_config_req; - nfapi_nr_tx_data_request_t *tx_data_req_pdu_list; -} nfapi_dl_tti_config_req_tx_data_req_t; - -void send_nsa_standalone_msg(NR_UL_IND_t *UL_INFO, uint16_t msg_id); - -void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request); - -void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, - nfapi_nr_tx_data_request_t *tx_data_request, - nfapi_nr_ul_dci_request_t *ul_dci_request, - nfapi_nr_ul_tti_request_t *ul_tti_request); - -struct sfn_slot_s { - int sfn; - int slot; -}; -bool sfn_slot_matcher(void *sfn_slot_s, void *candidate); - /**\brief interface between L1/L2, indicating the downlink related information, like dci_ind and rx_req \param dl_info including dci_ind and rx_request messages*/ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info); diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c index 90b2d3b86f..4ddd7fc625 100644 --- a/openair2/RRC/LTE/rrc_eNB.c +++ b/openair2/RRC/LTE/rrc_eNB.c @@ -6354,7 +6354,7 @@ rrc_eNB_decode_dcch( /*NN: revise the condition */ /*FK: left the condition as is for the case MME is used (S1 mode) but setting dedicated_DRB = 1 otherwise (noS1 mode) so that no second RRCReconfiguration message activationg more DRB is sent as this causes problems with the nasmesh driver.*/ - if (!IS_SOFTMODEM_NOS1 || get_softmodem_params()->emulate_l1) { + if (!IS_SOFTMODEM_NOS1) { if (ue_context_p->ue_context.StatusRrc == RRC_RECONFIGURED) { dedicated_DRB = 1; LOG_I(RRC, diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index c167982859..0544637975 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -2921,7 +2921,7 @@ static void process_lte_nsa_msg(NR_UE_RRC_INST_t *rrc, nsa_msg_t *msg, int msg_l LOG_D(NR_RRC, "NR carrierFreq_r15 (ssb): %ld and sub carrier spacing:%ld\n", nr_meas_obj->measObject.choice.measObjectNR_r15.carrierFreq_r15, nr_meas_obj->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15); - start_oai_nrue_threads(); + //start_oai_nrue_threads(); break; } diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index d332ca5175..cdcf1966b4 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -74,8 +74,6 @@ void *recv_msgs_from_lte_ue(void *args_p); void init_connections_with_lte_ue(void); -extern void start_oai_nrue_threads(void); - int get_from_lte_ue_fd(); void nr_rrc_SI_timers(NR_UE_RRC_SI_INFO *SInfo); From 6289409f15c82d6e5426ebc473fc00f2d537f2a1 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 2 Oct 2025 17:21:27 +0200 Subject: [PATCH 2/2] remove nsa UE option code --- CMakeLists.txt | 4 - common/utils/ocp_itti/intertask_interface.h | 2 - doc/Doxyfile | 1 - executables/create_tasks_ue.c | 9 - executables/nr-uesoftmodem.c | 25 +- openair2/COMMON/as_message.h | 4 - openair2/COMMON/pdcp_messages_def.h | 1 - openair2/COMMON/pdcp_messages_types.h | 1 - openair2/COMMON/rrc_messages_def.h | 2 - openair2/COMMON/rrc_messages_types.h | 1 - openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 29 +- openair2/RRC/LTE/MESSAGES/asn1_msg.c | 119 +--- openair2/RRC/LTE/MESSAGES/asn1_msg.h | 4 +- openair2/RRC/LTE/rrc_UE.c | 642 +------------------ openair2/RRC/LTE/rrc_proto.h | 6 - openair2/RRC/NR_UE/L2_interface_ue.h | 1 - openair2/RRC/NR_UE/rrc_UE.c | 182 ------ openair2/RRC/NR_UE/rrc_nsa.c | 85 --- openair2/RRC/NR_UE/rrc_proto.h | 6 - openair3/NAS/NR_UE/nr_nas_msg.c | 2 +- 20 files changed, 7 insertions(+), 1119 deletions(-) delete mode 100644 openair2/RRC/NR_UE/rrc_nsa.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dc7ba40d5..57d165ea05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1184,7 +1184,6 @@ set(NR_L2_SRC_UE ${NR_UE_RRC_DIR}/L2_interface_ue.c ${NR_UE_RRC_DIR}/main_ue.c ${NR_UE_RRC_DIR}/rrc_UE.c - ${NR_UE_RRC_DIR}/rrc_nsa.c ${NR_UE_RRC_DIR}/rrc_timers_and_constants.c ${NR_UE_RRC_DIR}/rrc_sl_preconfig.c ) @@ -1977,7 +1976,6 @@ target_link_libraries(nr_pbchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_psbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/psbchsim.c ${OPENAIR_DIR}/executables/softmodem-common.c - ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${NFAPI_USER_DIR}/gnb_ind_vars.c ${PHY_INTERFACE_DIR}/queue_t.c @@ -1998,7 +1996,6 @@ target_link_libraries(nr_pucchsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_dlsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlsim.c ${OPENAIR_DIR}/executables/softmodem-common.c - ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${NFAPI_USER_DIR}/gnb_ind_vars.c ${PHY_INTERFACE_DIR}/queue_t.c @@ -2028,7 +2025,6 @@ target_link_libraries(nr_ulschsim PRIVATE asn1_nr_rrc_hdrs asn1_lte_rrc_hdrs) add_executable(nr_ulsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/ulsim.c ${OPENAIR_DIR}/executables/softmodem-common.c - ${NR_UE_RRC_DIR}/rrc_nsa.c ${NFAPI_USER_DIR}/nfapi.c ${NFAPI_USER_DIR}/gnb_ind_vars.c ${PHY_INTERFACE_DIR}/queue_t.c diff --git a/common/utils/ocp_itti/intertask_interface.h b/common/utils/ocp_itti/intertask_interface.h index 84dbd15365..8f4e25d8b1 100644 --- a/common/utils/ocp_itti/intertask_interface.h +++ b/common/utils/ocp_itti/intertask_interface.h @@ -321,8 +321,6 @@ typedef struct { TASK_DEF(TASK_DU_F1, 200) \ TASK_DEF(TASK_CUCP_E1, 200) \ TASK_DEF(TASK_CUUP_E1, 200) \ - TASK_DEF(TASK_RRC_NSA_UE, 200) \ - TASK_DEF(TASK_RRC_NSA_NRUE, 200) \ TASK_DEF(TASK_NAS_NRUE, 200) \ TASK_DEF(TASK_MAX, 200) diff --git a/doc/Doxyfile b/doc/Doxyfile index e91e63386f..5f96bc2e4a 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1836,7 +1836,6 @@ INPUT = \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/common.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_UE.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_sl_preconfig.c \ -@CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_nsa.c \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_proto.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/rrc_vars.h \ @CMAKE_CURRENT_SOURCE_DIR@/../openair2/RRC/NR_UE/sl_preconfig_paramvalues.h \ diff --git a/executables/create_tasks_ue.c b/executables/create_tasks_ue.c index 50b9221f3f..46b80a0496 100644 --- a/executables/create_tasks_ue.c +++ b/executables/create_tasks_ue.c @@ -64,15 +64,6 @@ int create_tasks_ue(uint32_t ue_nb) LOG_E(RRC, "Create task for RRC UE failed\n"); return -1; } - - if (get_softmodem_params()->nsa) { - init_connections_with_nr_ue(); - LOG_I(RRC, "Started LTE-NR link in the LTE UE\n"); - if (itti_create_task (TASK_RRC_NSA_UE, recv_msgs_from_nr_ue, NULL) < 0) { - LOG_E(RRC, "Create task for RRC NSA UE failed\n"); - return -1; - } - } } itti_wait_ready(0); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index fb740781cd..fbac6402f5 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -124,13 +124,6 @@ int create_tasks_nrue(uint32_t ue_nb) { LOG_E(NR_RRC, "Create task for RRC UE failed\n"); return -1; } - if (get_softmodem_params()->nsa) { - init_connections_with_lte_ue(); - if (itti_create_task (TASK_RRC_NSA_NRUE, recv_msgs_from_lte_ue, NULL) < 0) { - LOG_E(NR_RRC, "Create task for RRC NSA nr-UE failed\n"); - return -1; - } - } const ittiTask_parms_t parmsNAS = {NULL, nas_nrue}; if (itti_create_task(TASK_NAS_NRUE, nas_nrue_task, &parmsNAS) < 0) { LOG_E(NR_RRC, "Create task for NAS UE failed\n"); @@ -292,14 +285,6 @@ void init_openair0(PHY_VARS_NR_UE *ue) } } -static void init_pdcp(int ue_id) -{ - if (get_softmodem_params()->nsa && nr_rlc_module_init(NR_RLC_OP_MODE_UE) != 0) { - LOG_I(RLC, "Problem at RLC initiation \n"); - } - nr_pdcp_layer_init(); -} - // Stupid function addition because UE itti messages queues definition is common with eNB void *rrc_enb_process_msg(void *notUsed) { return NULL; @@ -395,15 +380,7 @@ int main(int argc, char **argv) exit(-1); // need a softer mode } - int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1; - uint16_t node_number = get_softmodem_params()->node_number; - ue_id_g = (node_number == 0) ? 0 : node_number - 2; - AssertFatal(ue_id_g >= 0, "UE id is expected to be nonnegative.\n"); - - if (node_number == 0) - init_pdcp(0); - else - init_pdcp(mode_offset + ue_id_g); + nr_pdcp_layer_init(); nas_init_nrue(NB_UE_INST); init_NR_UE(NB_UE_INST, get_nrUE_params()->uecap_file, get_nrUE_params()->reconfig_file, get_nrUE_params()->rbconfig_file); diff --git a/openair2/COMMON/as_message.h b/openair2/COMMON/as_message.h index 1fb59c6aa9..a134c1b47c 100644 --- a/openair2/COMMON/as_message.h +++ b/openair2/COMMON/as_message.h @@ -218,10 +218,6 @@ typedef struct kenb_refresh_req_s { uint8_t kenb[32]; } kenb_refresh_req_t; -typedef struct nsa_oai_tun_nsa_s { - uint8_t buffer[500]; -} nas_oai_tun_nsa_t; - /* * NAS->AS - Cell Information request * NAS request AS to search for a suitable cell belonging to the selected diff --git a/openair2/COMMON/pdcp_messages_def.h b/openair2/COMMON/pdcp_messages_def.h index 5392c9e04d..da7d87f142 100644 --- a/openair2/COMMON/pdcp_messages_def.h +++ b/openair2/COMMON/pdcp_messages_def.h @@ -31,7 +31,6 @@ MESSAGE_DEF(RRC_DCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataReq, rrc_dcch_data_req) MESSAGE_DEF(RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_dcch_data_ind) MESSAGE_DEF(RRC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcPcchDataReq, rrc_pcch_data_req) -MESSAGE_DEF(RRC_NRUE_CAP_INFO_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_nrue_cap_info_ind) MESSAGE_DEF(RRC_DCCH_DATA_COPY_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_dcch_data_copy_ind) // gNB diff --git a/openair2/COMMON/pdcp_messages_types.h b/openair2/COMMON/pdcp_messages_types.h index b97fdef986..cf7a1f8f0c 100644 --- a/openair2/COMMON/pdcp_messages_types.h +++ b/openair2/COMMON/pdcp_messages_types.h @@ -34,7 +34,6 @@ #define RRC_DCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_req #define RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_ind #define RRC_PCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_pcch_data_req -#define RRC_NRUE_CAP_INFO_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_nrue_cap_info_ind #define RRC_DCCH_DATA_COPY_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_copy_ind // gNB diff --git a/openair2/COMMON/rrc_messages_def.h b/openair2/COMMON/rrc_messages_def.h index 33d6b7b59e..7dda028565 100644 --- a/openair2/COMMON/rrc_messages_def.h +++ b/openair2/COMMON/rrc_messages_def.h @@ -67,8 +67,6 @@ MESSAGE_DEF(NAS_5GMM_IND, MESSAGE_PRIORITY_MED, nas_5gmm_ind_t, nas_5gmm_ind) MESSAGE_DEF(NAS_RAB_ESTABLI_RSP, MESSAGE_PRIORITY_MED, rab_establish_rsp_t, nas_rab_est_rsp) -MESSAGE_DEF(NAS_OAI_TUN_NSA, MESSAGE_PRIORITY_MED, nas_oai_tun_nsa_t, nas_oai_tun_nsa) - // UE: RRC -> NAS messages MESSAGE_DEF(NAS_CELL_SELECTION_CNF, MESSAGE_PRIORITY_MED, cell_info_cnf_t, nas_cell_selection_cnf) MESSAGE_DEF(NAS_CELL_SELECTION_IND, MESSAGE_PRIORITY_MED, cell_info_ind_t, nas_cell_selection_ind) diff --git a/openair2/COMMON/rrc_messages_types.h b/openair2/COMMON/rrc_messages_types.h index e1656a3d7f..255da9f189 100644 --- a/openair2/COMMON/rrc_messages_types.h +++ b/openair2/COMMON/rrc_messages_types.h @@ -103,7 +103,6 @@ #define RLC_SDU_INDICATION(mSGpTR) (mSGpTR)->ittiMsg.rlc_sdu_indication #define NRDuDlReq(mSGpTR) (mSGpTR)->ittiMsg.nr_du_dl_req -#define NAS_OAI_TUN_NSA(mSGpTR) (mSGpTR)->ittiMsg.nas_oai_tun_nsa #define NAS_PDU_SESSION_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_pdu_session_req #define NR_RRC_RLC_MAXRTX(mSGpTR) (mSGpTR)->ittiMsg.nr_rlc_maxrtx_indication diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index c6385e765c..0dae34eda7 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -835,34 +835,7 @@ bool init_RA(NR_UE_MAC_INST_t *mac, int frame) // TODO this piece of code is required to compute MSG3_size that is used by ra_preambles_config function // Not a good implementation, it needs improvements - int size_sdu = 0; - - // Concerning the C-RNTI MAC CE, - // it has to be included if the UL transmission (Msg3) is not being made for the CCCH logical channel. - // Therefore it has been assumed that this event only occurs only when RA is done and it is not SA mode. - if (get_softmodem_params()->nsa) { - - uint8_t mac_sdus[34 * 1056]; - uint16_t sdu_lengths[NB_RB_MAX] = {0}; - int TBS_bytes = 848; - int mac_ce_len = 0; - unsigned short post_padding = 1; - - // fill ulsch_buffer with random data - for (int i = 0; i < TBS_bytes; i++) { - mac_sdus[i] = (unsigned char)(rand()&0xff); - } - // Sending SDUs with size 1 - // Initialize elements of sdu_lengths - sdu_lengths[0] = TBS_bytes - 3 - post_padding - mac_ce_len; - size_sdu += sdu_lengths[0]; - - if (size_sdu > 0) { - memcpy(ra->cont_res_id, mac_sdus, sizeof(uint8_t) * 6); - ra->Msg3_size = size_sdu + sizeof(NR_MAC_SUBHEADER_SHORT) + sizeof(NR_MAC_SUBHEADER_SHORT); - } - - } else if (!IS_SA_MODE(get_softmodem_params())) + if (!IS_SA_MODE(get_softmodem_params())) ra->Msg3_size = sizeof(uint16_t) + sizeof(NR_MAC_SUBHEADER_FIXED); // Random acces procedure initialization diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.c b/openair2/RRC/LTE/MESSAGES/asn1_msg.c index 9511a7494b..61a0456511 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.c +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.c @@ -4521,117 +4521,8 @@ is_en_dc_supported( #undef NCE } -void allocate_en_DC_r15(LTE_UE_EUTRA_Capability_t *cap) +OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname) { - LOG_D(RRC, "Entered %s\n", __FUNCTION__); - if (!cap->nonCriticalExtension) - cap->nonCriticalExtension = CALLOC(1, sizeof(*cap->nonCriticalExtension)); - - typeof(cap->nonCriticalExtension) nce1 = cap->nonCriticalExtension; - if (!nce1->nonCriticalExtension) - nce1->nonCriticalExtension = CALLOC(1, sizeof(*nce1->nonCriticalExtension)); - - typeof(nce1->nonCriticalExtension) nce2 = nce1->nonCriticalExtension; - if (!nce2->nonCriticalExtension) - nce2->nonCriticalExtension = CALLOC(1, sizeof(*nce2->nonCriticalExtension)); - - typeof(nce2->nonCriticalExtension) nce3 = nce2->nonCriticalExtension; - if (!nce3->nonCriticalExtension) - nce3->nonCriticalExtension = CALLOC(1, sizeof(*nce3->nonCriticalExtension)); - - typeof(nce3->nonCriticalExtension) nce4 = nce3->nonCriticalExtension; - if (!nce4->nonCriticalExtension) - nce4->nonCriticalExtension = CALLOC(1, sizeof(*nce4->nonCriticalExtension)); - - typeof(nce4->nonCriticalExtension) nce5 = nce4->nonCriticalExtension; - if (!nce5->nonCriticalExtension) - nce5->nonCriticalExtension = CALLOC(1, sizeof(*nce5->nonCriticalExtension)); - - typeof(nce5->nonCriticalExtension) nce6 = nce5->nonCriticalExtension; - if (!nce6->nonCriticalExtension) - nce6->nonCriticalExtension = CALLOC(1, sizeof(*nce6->nonCriticalExtension)); - - typeof(nce6->nonCriticalExtension) nce7 = nce6->nonCriticalExtension; - if (!nce7->nonCriticalExtension) - nce7->nonCriticalExtension = CALLOC(1, sizeof(*nce7->nonCriticalExtension)); - - typeof(nce7->nonCriticalExtension) nce8 = nce7->nonCriticalExtension; - if (!nce8->nonCriticalExtension) - nce8->nonCriticalExtension = CALLOC(1, sizeof(*nce8->nonCriticalExtension)); - - typeof(nce8->nonCriticalExtension) nce9 = nce8->nonCriticalExtension; - if (!nce9->nonCriticalExtension) - nce9->nonCriticalExtension = CALLOC(1, sizeof(*nce9->nonCriticalExtension)); - - typeof(nce9->nonCriticalExtension) nce10 = nce9->nonCriticalExtension; - if (!nce10->nonCriticalExtension) - nce10->nonCriticalExtension = CALLOC(1, sizeof(*nce10->nonCriticalExtension)); - - typeof(nce10->nonCriticalExtension) nce11 = nce10->nonCriticalExtension; - if (!nce11->nonCriticalExtension) - nce11->nonCriticalExtension = CALLOC(1, sizeof(*nce11->nonCriticalExtension)); - - typeof(nce11->nonCriticalExtension) nce12 = nce11->nonCriticalExtension; - if (!nce12->nonCriticalExtension) - nce12->nonCriticalExtension = CALLOC(1, sizeof(*nce12->nonCriticalExtension)); - - typeof(nce12->nonCriticalExtension) nce13 = nce12->nonCriticalExtension; - if (!nce13->nonCriticalExtension) - nce13->nonCriticalExtension = CALLOC(1, sizeof(*nce13->nonCriticalExtension)); - - typeof(nce13->nonCriticalExtension) nce14 = nce13->nonCriticalExtension; - if (!nce14->nonCriticalExtension) - nce14->nonCriticalExtension = CALLOC(1, sizeof(*nce14->nonCriticalExtension)); - - typeof(nce14->nonCriticalExtension) nce15 = nce14->nonCriticalExtension; - if (!nce15->nonCriticalExtension) - nce15->nonCriticalExtension = CALLOC(1, sizeof(*nce15->nonCriticalExtension)); - - typeof(nce15->nonCriticalExtension) nce16 = nce15->nonCriticalExtension; - if (!nce16->nonCriticalExtension) - nce16->nonCriticalExtension = CALLOC(1, sizeof(*nce16->nonCriticalExtension)); - - typeof(nce16->nonCriticalExtension) nce17 = nce16->nonCriticalExtension; - if (!nce17->nonCriticalExtension) - nce17->nonCriticalExtension = CALLOC(1, sizeof(*nce17->nonCriticalExtension)); - - typeof(nce17->nonCriticalExtension) nce18 = nce17->nonCriticalExtension; - if (!nce18->nonCriticalExtension) - nce18->nonCriticalExtension = CALLOC(1, sizeof(*nce18->nonCriticalExtension)); - - typeof(nce18->nonCriticalExtension) nce19 = nce18->nonCriticalExtension; - if (!nce19->nonCriticalExtension) - nce19->nonCriticalExtension = CALLOC(1, sizeof(*nce19->nonCriticalExtension)); - - typeof(nce19->nonCriticalExtension) nce20 = nce19->nonCriticalExtension; - if (!nce20->nonCriticalExtension) - nce20->nonCriticalExtension = CALLOC(1, sizeof(*nce20->nonCriticalExtension)); - - typeof(nce20->nonCriticalExtension) nce21 = nce20->nonCriticalExtension; - if (!nce21->nonCriticalExtension) - nce21->nonCriticalExtension = CALLOC(1, sizeof(*nce21->nonCriticalExtension)); - - typeof(nce21->nonCriticalExtension) nce22 = nce21->nonCriticalExtension; - if (!nce22->nonCriticalExtension) - nce22->nonCriticalExtension = CALLOC(1, sizeof(*nce22->nonCriticalExtension)); - - typeof(nce22->nonCriticalExtension) nce23 = nce22->nonCriticalExtension; - if (!nce23->nonCriticalExtension) - nce23->nonCriticalExtension = CALLOC(1, sizeof(*nce23->nonCriticalExtension)); - - typeof(nce23->nonCriticalExtension) nce24 = nce23->nonCriticalExtension; - if (!nce24->irat_ParametersNR_r15) - nce24->irat_ParametersNR_r15 = CALLOC(1, sizeof(*nce24->irat_ParametersNR_r15)); - - typeof(nce24->irat_ParametersNR_r15) irat = nce24->irat_ParametersNR_r15; - if (!irat->en_DC_r15) - irat->en_DC_r15 = CALLOC(1, sizeof(*irat->en_DC_r15)); - - *irat->en_DC_r15 = LTE_IRAT_ParametersNR_r15__en_DC_r15_supported; - -} - -OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname, bool received_nr_msg) { static OAI_UECapability_t UECapability; /* TODO declared static to allow returning this has an address should be allocated in a cleaner way. */ static LTE_SupportedBandEUTRA_t Bandlist[4]; // the macro asn1cSeqAdd() does not copy the source, but only stores a reference to it static LTE_InterFreqBandInfo_t InterFreqBandInfo[4][4]; // the macro asn1cSeqAdd() does not copy the source, but only stores a reference to it @@ -4716,14 +4607,6 @@ OAI_UECapability_t *fill_ue_capability(char *UE_EUTRA_Capability_xer_fname, bool // UE_EUTRA_Capability->measParameters.bandListEUTRA.list.count = 0; // no measurements on other bands // UE_EUTRA_Capability->featureGroupIndicators // null - - if (get_softmodem_params()->nsa && received_nr_msg) - { - allocate_en_DC_r15(UE_EUTRA_Capability); - if (!is_en_dc_supported(UE_EUTRA_Capability)){ - LOG_E(RRC, "We did not properly allocate en_DC_r15 for UE_EUTRA_Capability\n"); - } - } } else { FILE *f = fopen(UE_EUTRA_Capability_xer_fname, "r"); assert(f); diff --git a/openair2/RRC/LTE/MESSAGES/asn1_msg.h b/openair2/RRC/LTE/MESSAGES/asn1_msg.h index 3d5a8bb68c..b7d9dc4856 100644 --- a/openair2/RRC/LTE/MESSAGES/asn1_msg.h +++ b/openair2/RRC/LTE/MESSAGES/asn1_msg.h @@ -368,12 +368,10 @@ int do_HandoverPreparation(char *ho_buf, int ho_size, LTE_UE_EUTRA_Capability_t int do_HandoverCommand(char *ho_buf, int ho_size, char *rrc_buf, int rrc_size); -OAI_UECapability_t *fill_ue_capability(char *LTE_UE_EUTRA_Capability_xer, bool received_nr_msg); +OAI_UECapability_t *fill_ue_capability(char *LTE_UE_EUTRA_Capability_xer); int is_en_dc_supported(LTE_UE_EUTRA_Capability_t *c); -void allocate_en_DC_r15(LTE_UE_EUTRA_Capability_t *cap); - uint8_t do_UECapabilityEnquiry( const protocol_ctxt_t *const ctxt_pP, diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c index b9d2551fcb..70692bfaa9 100644 --- a/openair2/RRC/LTE/rrc_UE.c +++ b/openair2/RRC/LTE/rrc_UE.c @@ -64,9 +64,6 @@ #include "LTE_UECapabilityEnquiry.h" #include "LTE_UE-CapabilityRequest.h" -#include "NR_RAT-Type.h" -#include "NR_UE-CapabilityRAT-Container.h" - #include "common/utils/tun_if.h" #if ENABLE_RAL #include "rrc_UE_ral.h" @@ -97,9 +94,6 @@ //for D2D int ctrl_sock_fd; struct sockaddr_in prose_app_addr; -static const char nsa_ipaddr[] = "127.0.0.1"; -static int from_nr_ue_fd = -1; -static int to_nr_ue_fd = -1; int slrb_id; int send_ue_information = 0; // TimeToTrigger enum mapping table (36.331 TimeToTrigger IE) @@ -144,22 +138,10 @@ typedef struct rrc_dcch_data_copy_t LTE_DL_DCCH_Message_t *dl_dcch_msg; } rrc_dcch_data_copy_t; -typedef struct rrc_nrue_cap_info_t -{ - uint8_t mesg[RRC_BUF_SIZE]; - size_t mesg_len; - LTE_DL_DCCH_Message_t *dl_dcch_msg; -} rrc_nrue_cap_info_t; - static void rrc_ue_process_ueCapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, LTE_UECapabilityEnquiry_t *UECapabilityEnquiry, uint8_t eNB_index); -static void rrc_ue_process_nrueCapabilityEnquiry(const protocol_ctxt_t *const ctxt_pP, - LTE_UECapabilityEnquiry_t *UECapabilityEnquiry, - rrc_nrue_cap_info_t *nrue_cap_info, - uint8_t eNB_index); - /** \brief Generates/Encodes RRCConnnectionSetupComplete message at UE * \param ctxt_pP Running context * \param eNB_index Index of corresponding eNB/CH @@ -184,8 +166,6 @@ static void rrc_ue_generate_RRCConnectionReconfigurationComplete(const protocol_ static void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index ); -static void rrc_ue_generate_nrMeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index ); - static uint8_t check_trigger_meas_event( module_id_t module_idP, frame_t frameP, @@ -208,8 +188,6 @@ rrc_ue_process_MBMSCountingRequest( uint8_t eNB_index ); -static void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len); -static void nsa_sendmsg_to_nrue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); protocol_ctxt_t ctxt_pP_local; @@ -838,25 +816,6 @@ rrc_ue_process_measConfig( measObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth, measObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1, measObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0]); - } else if (measObj->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectNR_r15) { - ue->subframeCount = 0; - LOG_I(RRC, "NR_r15 Measurement: carrierFreq: %ld\n", - measObj->measObject.choice.measObjectNR_r15.carrierFreq_r15); - if (!get_softmodem_params()->nsa) { - LOG_E(RRC, "Not in NSA mode but attempting to send measurement request to NR-UE\n"); - return; - } - uint8_t buffer[RRC_BUF_SIZE]; - asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_MeasObjectToAddMod, - NULL, - measObj, - buffer, - sizeof(buffer)); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %zu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - nsa_sendmsg_to_nrue(buffer, (enc_rval.encoded + 7)/8, RRC_MEASUREMENT_PROCEDURE); - LOG_A(RRC, "Encoded measurement object %zu bits (%zu bytes) and sent to NR UE\n", - enc_rval.encoded, (enc_rval.encoded + 7)/8); } LOG_D(RRC, "Adding measurement object [%d][%ld]\n", eNB_index, ind); ue->MeasObj[eNB_index][ind-1]=measObj; @@ -1697,102 +1656,6 @@ rrc_ue_process_MBMSCountingRequest( } - -//----------------------------------------------------------------------------- -void -rrc_ue_process_nrueCapabilityEnquiry( - const protocol_ctxt_t *const ctxt_pP, - LTE_UECapabilityEnquiry_t *UECapabilityEnquiry, - rrc_nrue_cap_info_t *nrue_cap_info, - uint8_t eNB_index -) -//----------------------------------------------------------------------------- -{ - asn_enc_rval_t enc_rval; - uint8_t buffer[RRC_BUF_SIZE]; - LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing NRUECapabilityEnquiry (eNB %d)\n", - ctxt_pP->module_id, - ctxt_pP->frame, - eNB_index); - LTE_UL_DCCH_Message_t ul_dcch_msg; - memset(&ul_dcch_msg, 0, sizeof(ul_dcch_msg)); - LTE_UECapabilityInformation_t *ue_cap = &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation; - ul_dcch_msg.message.present = LTE_UL_DCCH_MessageType_PR_c1; - ul_dcch_msg.message.choice.c1.present = LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation; - ue_cap->rrc_TransactionIdentifier = UECapabilityEnquiry->rrc_TransactionIdentifier; - - NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container; - memset(&ue_CapabilityRAT_Container, 0, sizeof(ue_CapabilityRAT_Container)); - ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_nr; - OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ue_CapabilityRAT_Container, - (const char *)nrue_cap_info->mesg, - nrue_cap_info->mesg_len); - # if(1) // TODO: The MRDC capabilites should be filled in the NR UE - NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container_mrdc; - memset(&ue_CapabilityRAT_Container_mrdc, 0, sizeof(ue_CapabilityRAT_Container_mrdc)); - uint8_t buffer_mrdc[RRC_BUF_SIZE]; - NR_UE_MRDC_Capability_t *UE_Capability_MRDC = CALLOC(1, sizeof(NR_UE_MRDC_Capability_t)); - asn_enc_rval_t enc_rval_mrdc = uper_encode_to_buffer(&asn_DEF_NR_UE_MRDC_Capability, - NULL, - (void *)UE_Capability_MRDC, - &buffer_mrdc, - sizeof(buffer_mrdc)); - AssertFatal (enc_rval_mrdc.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval_mrdc.failed_type->name, enc_rval_mrdc.encoded); - LOG_I(RRC, "[NR_RRC] NRUE MRDC Capability encoded, %ld bytes (%ld bits)\n", - (enc_rval_mrdc.encoded + 7) / 8, enc_rval_mrdc.encoded + 7); - - ue_CapabilityRAT_Container_mrdc.rat_Type = NR_RAT_Type_eutra_nr; - OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container_mrdc.ue_CapabilityRAT_Container, - (const char *)buffer_mrdc, - (enc_rval_mrdc.encoded + 7) / 8); - #endif - - ue_cap->criticalExtensions.present = LTE_UECapabilityInformation__criticalExtensions_PR_c1; - ue_cap->criticalExtensions.choice.c1.present = LTE_UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; - ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count = 0; - int count = UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count; - xer_fprint(stdout, &asn_DEF_NR_UE_CapabilityRAT_Container, (void *)&ue_CapabilityRAT_Container); - LTE_UE_CapabilityRequest_t *cap_req = &UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest; - for (int i = 0; i < count; i++) { - enc_rval.encoded = 0; - if (*cap_req->list.array[i] == LTE_RAT_Type_nr) { - asn1cSeqAdd(&ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, - &ue_CapabilityRAT_Container); - ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[i]->rat_Type = LTE_RAT_Type_nr; - asn_enc_rval_t enc_rval_nr = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, sizeof(buffer)); - AssertFatal (enc_rval_nr.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", - enc_rval_nr.failed_type->name, enc_rval_nr.encoded); - enc_rval.encoded = enc_rval.encoded + enc_rval_nr.encoded; - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); - LOG_A(RRC, "%s: NR_UECapInfo LTE_RAT_Type_nr Encoded %zd bits (%zd bytes)\n", - __FUNCTION__, enc_rval.encoded, (enc_rval.encoded+7)/8); - } - else if (*cap_req->list.array[i] == LTE_RAT_Type_eutra_nr) { - asn1cSeqAdd(&ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, - &ue_CapabilityRAT_Container_mrdc); - ue_cap->criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.array[i]->rat_Type = LTE_RAT_Type_eutra_nr; - asn_enc_rval_t enc_rval_eutra_nr = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, sizeof(buffer)); - AssertFatal (enc_rval_eutra_nr.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", - enc_rval_eutra_nr.failed_type->name, enc_rval_eutra_nr.encoded); - enc_rval.encoded = enc_rval.encoded + enc_rval_eutra_nr.encoded; - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); - LOG_A(RRC, "%s: NR_UECapInfo LTE_RAT_Type_eutra_nr Encoded %zd bits (%zd bytes)\n", - __FUNCTION__, enc_rval.encoded, (enc_rval.encoded+7)/8); - } - rrc_data_req_ue ( - ctxt_pP, - DCCH, - rrc_mui++, - SDU_CONFIRM_NO, - (enc_rval.encoded + 7) / 8, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - } -} - - - //----------------------------------------------------------------------------- void rrc_ue_process_ueCapabilityEnquiry( @@ -1861,57 +1724,9 @@ rrc_ue_process_ueCapabilityEnquiry( buffer, PDCP_TRANSMISSION_MODE_CONTROL); } - else if (*UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.array[i] - == LTE_RAT_Type_nr) { - asn1cSeqAdd( - &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, - &ue_CapabilityRAT_Container); - enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UL_DCCH_Message, NULL, (void *) &ul_dcch_msg, buffer, 100); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - - if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) { - xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg); - } - - LOG_A(RRC, "%s: NR_UECapabilityInformation Encoded %zd bits (%zd bytes)\n", - __FUNCTION__, enc_rval.encoded,(enc_rval.encoded+7)/8); - rrc_data_req_ue ( - ctxt_pP, - DCCH, - rrc_mui++, - SDU_CONFIRM_NO, - (enc_rval.encoded + 7) / 8, - buffer, - PDCP_TRANSMISSION_MODE_CONTROL); - } } } -static bool is_nr_r15_config_present(LTE_RRCConnectionReconfiguration_r8_IEs_t *c) -{ -#define NCE nonCriticalExtension -#define chk(x) do { \ - if ((x) == NULL) { \ - LOG_I(RRC, "NULL at %d\n", __LINE__); \ - return false; \ - } \ -} while(0) - chk(c); - chk(c->NCE); - chk(c->NCE->NCE); - chk(c->NCE->NCE->NCE); - chk(c->NCE->NCE->NCE->NCE); - chk(c->NCE->NCE->NCE->NCE->NCE); - chk(c->NCE->NCE->NCE->NCE->NCE->NCE); - chk(c->NCE->NCE->NCE->NCE->NCE->NCE->NCE); - chk(c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE); - return c->NCE->NCE->NCE->NCE->NCE->NCE->NCE->NCE->nr_Config_r15->present == - LTE_RRCConnectionReconfiguration_v1510_IEs__nr_Config_r15_PR_setup; - -#undef NCE -#undef chk -} /** \brief process the received rrcConnectionReconfiguration message at UE \param ctxt_pP Running context \param *rrcConnectionReconfiguration pointer to the sturcture @@ -1932,42 +1747,6 @@ static void rrc_ue_process_rrcConnectionReconfiguration(const protocol_ctxt_t *c criticalExtensions.choice.c1. choice.rrcConnectionReconfiguration_r8; - if (is_nr_r15_config_present(r_r8)) { - OCTET_STRING_t *nr_RadioBearer = r_r8->nonCriticalExtension->nonCriticalExtension-> - nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> - nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> - nr_RadioBearerConfig1_r15; - OCTET_STRING_t *nr_SecondaryCellGroup = r_r8->nonCriticalExtension->nonCriticalExtension-> - nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> - nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> - nr_Config_r15->choice.setup.nr_SecondaryCellGroupConfig_r15; - uint32_t total_size = nr_RadioBearer->size + nr_SecondaryCellGroup->size; - struct msg { - uint32_t RadioBearer_size; - uint32_t SecondaryCellGroup_size; - uint8_t trans_id; - uint8_t padding[3]; - uint8_t *buffer; - } msg; - - msg.buffer = calloc(total_size, sizeof(*msg.buffer)); - AssertFatal(msg.buffer != NULL, "Error in memory allocation\n"); - msg.RadioBearer_size = nr_RadioBearer->size; - msg.SecondaryCellGroup_size = nr_SecondaryCellGroup->size; - msg.trans_id = rrcConnectionReconfiguration->rrc_TransactionIdentifier; - memcpy(msg.buffer, nr_RadioBearer->buf, nr_RadioBearer->size); - memcpy(msg.buffer + nr_RadioBearer->size, nr_SecondaryCellGroup->buf, nr_SecondaryCellGroup->size); - - LOG_D(RRC, "nr_RadioBearerConfig1_r15 size %ld nr_SecondaryCellGroupConfig_r15 size %ld, sizeof(msg) = %zu\n", - nr_RadioBearer->size, - nr_SecondaryCellGroup->size, - sizeof(msg)); - - nsa_sendmsg_to_nrue(&msg, sizeof(msg), RRC_CONFIG_COMPLETE_REQ); - free(msg.buffer); - LOG_A(RRC, "Sent RRC_CONFIG_COMPLETE_REQ to the NR UE\n"); - } - if (r_r8->mobilityControlInfo) { LOG_I(RRC,"Mobility Control Information is present\n"); rrc_ue_process_mobilityControlInfo( @@ -2483,52 +2262,7 @@ static void rrc_ue_decode_dcch(const protocol_ctxt_t *const ctxt_pP, ctxt_pP->module_id, eNB_indexP); - LTE_UE_CapabilityRequest_t *ue_cap = &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry.criticalExtensions. - choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest; - bool have_received_nrue_cap = false; - for (int i = 0; i < ue_cap->list.count; i++) { - if (*ue_cap->list.array[i] == LTE_RAT_Type_nr || *ue_cap->list.array[i] == LTE_RAT_Type_eutra_nr) { - have_received_nrue_cap = true; - break; - } - } - if (have_received_nrue_cap) { - LTE_UECapabilityEnquiry_t *ueCapabilityEnquiry_nsa = &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry; - OCTET_STRING_t * requestedFreqBandsNR = ueCapabilityEnquiry_nsa-> - criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.nonCriticalExtension-> - nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> - nonCriticalExtension->requestedFreqBandsNR_MRDC_r15; - nsa_sendmsg_to_nrue(requestedFreqBandsNR->buf, requestedFreqBandsNR->size, NRUE_CAPABILITY_ENQUIRY); - LOG_A(RRC, "Second ueCapabilityEnquiry (request for NR capabilities) sent to NR UE with size %zu\n", - requestedFreqBandsNR->size); - // Save ueCapabilityEnquiry so we can use in nsa mode after nrUE response is received - UE_RRC_INFO *info = &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP]; - if (info->dl_dcch_msg != NULL) { - info->dl_dcch_msg = NULL; - } - info->dl_dcch_msg = dl_dcch_msg; - dl_dcch_msg = NULL; - } else if (get_softmodem_params()->nsa && !have_received_nrue_cap) { - LTE_UECapabilityEnquiry_t *ueCapabilityEnquiry_nsa = &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry; - OCTET_STRING_t * requestedFreqBandsNR = ueCapabilityEnquiry_nsa-> - criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.nonCriticalExtension-> - nonCriticalExtension->nonCriticalExtension->nonCriticalExtension-> - nonCriticalExtension->requestedFreqBandsNR_MRDC_r15; - nsa_sendmsg_to_nrue(requestedFreqBandsNR->buf, requestedFreqBandsNR->size, UE_CAPABILITY_ENQUIRY); - LOG_A(RRC, "Initial ueCapabilityEnquiry sent to NR UE with size %zu\n", requestedFreqBandsNR->size); - // Save ueCapabilityEnquiry so we can use in nsa mode after nrUE response is received - UE_RRC_INFO *info = &UE_rrc_inst[ctxt_pP->module_id].Info[eNB_indexP]; - if (info->dl_dcch_msg != NULL) { - info->dl_dcch_msg = NULL; - } - info->dl_dcch_msg = dl_dcch_msg; - dl_dcch_msg = NULL; - } else { - rrc_ue_process_ueCapabilityEnquiry( - ctxt_pP, - &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, - eNB_indexP); - } + rrc_ue_process_ueCapabilityEnquiry(ctxt_pP, &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, eNB_indexP); break; case LTE_DL_DCCH_MessageType__c1_PR_counterCheck: @@ -4285,43 +4019,6 @@ void ue_meas_filtering( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_ } } } -//Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 -//----------------------------------------------------------------------------- -void rrc_ue_generate_nrMeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t eNB_index ) { - uint8_t buffer[RRC_BUF_SIZE]; - UE_RRC_INST *ue = &UE_rrc_inst[ctxt_pP->module_id]; - uint8_t target_eNB_offset = ue->Info[0].handoverTarget; - LTE_PhysCellId_t targetCellId = ue->HandoverInfoUe.targetCellId; - - for (int i = 0; i < MAX_MEAS_ID; i++) { - if (ue->measReportList[eNB_index][i] != NULL) { - LTE_MeasId_t measId = ue->measReportList[eNB_index][i]->measId; - long rsrp_s = binary_search_float(RSRP_meas_mapping, 98, ue->rsrp_db_filtered[eNB_index]); - long rsrq_s = binary_search_float(RSRQ_meas_mapping, 35, ue->rsrq_db_filtered[eNB_index]); - long rsrp_tar = binary_search_float(RSRP_meas_mapping, 98, ue->rsrp_db_filtered[target_eNB_offset]); - long rsrq_tar = binary_search_float(RSRQ_meas_mapping, 35, ue->rsrq_db_filtered[target_eNB_offset]); - - LOG_I(RRC,"[UE %d] Frame %d: source eNB: %d target eNB: %d servingCell(%d) targetCell(%ld)\n", - ctxt_pP->module_id, - ctxt_pP->frame, - eNB_index, - target_eNB_offset, - get_adjacent_cell_id(ctxt_pP->module_id, eNB_index), - targetCellId); - - if (ctxt_pP->frame != 0) { - LOG_I(RRC, "measId %ld, targetCellId %ld, rsrp_s %ld, rsrq_s %ld, rsrp_t %ld, rsrq_t %ld\n", - measId, targetCellId, rsrp_s, rsrq_s, rsrp_tar, rsrq_tar); - ssize_t size = do_nrMeasurementReport(buffer, sizeof(buffer), measId, targetCellId, rsrp_s, rsrq_s, rsrp_tar, rsrq_tar); - AssertFatal(size >= 0, "do_nrMeasurementReport failed \n"); - LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", - ctxt_pP->module_id, ctxt_pP->frame, eNB_index); - const bool result = pdcp_data_req(ctxt_pP, SRB_FLAG_YES, DCCH, rrc_mui++, 0, size, buffer, PDCP_TRANSMISSION_MODE_DATA,NULL, NULL); - AssertFatal (result == true, "PDCP data request failed!\n"); - } - } - } -} //Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 //----------------------------------------------------------------------------- @@ -4395,39 +4092,6 @@ void rrc_ue_generate_MeasurementReport(protocol_ctxt_t *const ctxt_pP, uint8_t e } } -static bool does_rrcConnReconfig_have_nr(const UE_RRC_INST *ue) { - for (int i = 0; i < NB_CNX_UE; i++) { - for (int j = 0; j < MAX_MEAS_ID; j++) { - LTE_ReportConfigId_t reportConfigId = ue->MeasId[i][j]->reportConfigId; - AssertFatal(reportConfigId >= 1 && reportConfigId <= MAX_MEAS_CONFIG, "Bad index\n"); - const LTE_ReportConfigToAddMod_t *rc = ue->ReportConfig[i][reportConfigId-1]; - if (rc == NULL) { - LOG_D(RRC, "UE_rrc_inst[ctxt_pP->module_id]->ReportConfig[%d][%ld] = NULL\n", i, reportConfigId-1); - continue; - } - if (rc->reportConfig.present != LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigInterRAT) { - LOG_D(RRC, "reportConfig.present = %d, not LTE_ReportConfigToAddMod__reportConfig_PR_reportConfigInterRAT\n", - rc->reportConfig.present); - continue; - } - LTE_ReportConfigInterRAT_t irat = rc->reportConfig.choice.reportConfigInterRAT; - if (irat.triggerType.present != LTE_ReportConfigInterRAT__triggerType_PR_event) { - LOG_D(RRC, "irat.triggerType.present = %d, not LTE_ReportConfigInterRAT__triggerType_PR_event\n", - irat.triggerType.present); - continue; - } - if (irat.triggerType.choice.event.eventId.present != LTE_ReportConfigInterRAT__triggerType__event__eventId_PR_eventB1_NR_r15) { - LOG_D(RRC, "irat.triggerType.choice.event.eventId.present = %d\n", - irat.triggerType.choice.event.eventId.present); - continue; - } - return true; - } - } - return false; -} - - // Measurement report triggering, described in 36.331 Section 5.5.4.1: called periodically //----------------------------------------------------------------------------- void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) { @@ -4528,49 +4192,6 @@ void ue_measurement_report_triggering(protocol_ctxt_t *const ctxt_pP, const uint } } } - - if (ue->MeasObj[i][measObjId-1]->measObject.present == LTE_MeasObjectToAddMod__measObject_PR_measObjectNR_r15) { - if (!does_rrcConnReconfig_have_nr(ue)) - break; - LTE_ReportConfigInterRAT_t *rc = &ue->ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigInterRAT; - LTE_TimeToTrigger_t trig_per = rc->triggerType.choice.event.timeToTrigger; - ttt_ms = timeToTrigger_ms[trig_per]; - LOG_D(RRC, "[UE %d] Frame %d: B1_NR_r15 event. count %d, ttt %ld\n", - ctxt_pP->module_id, ctxt_pP->frame, ue->subframeCount, ttt_ms); - if (ue->subframeCount < ttt_ms) { - ++ue->subframeCount; - break; - } - ue->subframeCount = 0; - bool is_state_connected = false; - bool is_t304_inactive = false; - bool have_meas_flag = false; - if (ue->Info[0].State >= RRC_CONNECTED) - is_state_connected = true; - if (ue->Info[0].T304_active == 0) - is_t304_inactive = true; - if (ue->HandoverInfoUe.measFlag == 1) - have_meas_flag = true; - - if (is_state_connected && is_t304_inactive && have_meas_flag) { - LOG_I(RRC,"[UE %d] Frame %d: Triggering generation of Meas Report for NR_r15. count = %d\n", - ctxt_pP->module_id, ctxt_pP->frame, ue->subframeCount); - if (ue->measReportList[i][j] == NULL) { - ue->measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); - } - ue->measReportList[i][j]->measId = ue->MeasId[i][j]->measId; - ue->measReportList[i][j]->numberOfReportsSent = 0; - rrc_ue_generate_nrMeasurementReport(ctxt_pP, eNB_index); - ue->HandoverInfoUe.measFlag = 1; - LOG_I(RRC,"[UE %d] Frame %d: RSRB detected, state: %d \n", - ctxt_pP->module_id, ctxt_pP->frame, ue->Info[0].State); - } else { - if(ue->measReportList[i][j] != NULL) { - free(ue->measReportList[i][j]); - } - ue->measReportList[i][j] = NULL; - } - } } } } @@ -4970,38 +4591,6 @@ void *rrc_ue_task( void *args_p ) { break; } - case RRC_NRUE_CAP_INFO_IND: - { - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, RRC_NRUE_CAP_INFO_IND (msg_p).module_id, - ENB_FLAG_NO, RRC_NRUE_CAP_INFO_IND (msg_p).rnti, - RRC_NRUE_CAP_INFO_IND (msg_p).frame, - 0, - RRC_NRUE_CAP_INFO_IND (msg_p).eNB_index); - LOG_I(RRC, "[UE %d] Received %s. Now calling rrc_ue_process_nrueCapabilityEnquiry\n", - ue_mod_id, ITTI_MSG_NAME (msg_p)); - rrc_nrue_cap_info_t *nrue_cap_info = (void *)RRC_NRUE_CAP_INFO_IND (msg_p).sdu_p; - AssertFatal(RRC_NRUE_CAP_INFO_IND (msg_p).sdu_size == sizeof(*nrue_cap_info), "Size of nrue_cap_info incorrect\n"); - rrc_ue_process_nrueCapabilityEnquiry( - &ctxt, - &nrue_cap_info->dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, - nrue_cap_info, - RRC_NRUE_CAP_INFO_IND (msg_p).eNB_index); - SEQUENCE_free(&asn_DEF_LTE_DL_DCCH_Message, nrue_cap_info->dl_dcch_msg, ASFM_FREE_EVERYTHING); - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_NRUE_CAP_INFO_IND (msg_p).sdu_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - break; - } - case NAS_OAI_TUN_NSA: - { - LOG_D(NAS, "Received %s: length %lu. About to send this to the NR UE\n", ITTI_MSG_NAME (msg_p), - sizeof(NAS_OAI_TUN_NSA (msg_p).buffer)); - char buffer[RRC_BUF_SIZE]; - memcpy(buffer, NAS_OAI_TUN_NSA(msg_p).buffer, sizeof(buffer)); - nsa_sendmsg_to_nrue(buffer, sizeof(buffer), OAI_TUN_IFACE_NSA); - break; - } - - case NAS_KENB_REFRESH_REQ: memcpy((void *)UE_rrc_inst[ue_mod_id].kenb, (void *)NAS_KENB_REFRESH_REQ(msg_p).kenb, sizeof(UE_rrc_inst[ue_mod_id].kenb)); LOG_D(RRC, "[UE %d] Received %s: refreshed RRC::KeNB = " @@ -5331,8 +4920,7 @@ openair_rrc_top_init_ue( memset (UE_rrc_inst, 0, NB_UE_INST * sizeof(UE_RRC_INST)); LOG_D(RRC, "ALLOCATE %d Bytes for UE_RRC_INST @ %p\n", (unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)), UE_rrc_inst); // fill UE capability - bool received_nr_msg = false; - UECap = fill_ue_capability (uecap_xer, received_nr_msg); + UECap = fill_ue_capability (uecap_xer); for (module_id = 0; module_id < NB_UE_INST; module_id++) { UE_rrc_inst[module_id].UECap = UECap; @@ -6405,229 +5993,3 @@ rrc_rx_tx_ue( VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_RX_TX,VCD_FUNCTION_OUT); return (RRC_OK); } - -void *recv_msgs_from_nr_ue(void *args_p) -{ - itti_mark_task_ready (TASK_RRC_NSA_UE); - for (;;) - { - nsa_msg_t msg; - int recvLen = recvfrom(from_nr_ue_fd, &msg, sizeof(msg), - MSG_WAITALL | MSG_TRUNC, NULL, NULL); - if (recvLen == -1) - { - LOG_E(RRC, "%s: recvfrom: %s\n", __func__, strerror(errno)); - continue; - } - if (recvLen > sizeof(msg)) - { - LOG_E(NR_RRC, "%s: Received a truncated message %d\n", __func__, recvLen); - continue; - } - LOG_D(RRC, "We have received a %d msg (%d bytes). Calling process_nr_nsa_msg\n", msg.msg_type, recvLen); - process_nr_nsa_msg(&msg, recvLen); - } - -} - -void nsa_sendmsg_to_nrue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type) -{ - LOG_I(RRC, "Entered %s \n", __FUNCTION__); - nsa_msg_t n_msg; - if (msg_len > sizeof(n_msg.msg_buffer)) - { - LOG_E(RRC, "%s: message too big: %zu\n", __func__, msg_len); - abort(); - } - n_msg.msg_type = msg_type; - memcpy(n_msg.msg_buffer, message, msg_len); - size_t to_send = sizeof(n_msg.msg_type) + msg_len; - - struct sockaddr_in sa = - { - .sin_family = AF_INET, - .sin_port = htons(6008 + ue_id_g * 2), - }; - int sent = sendto(to_nr_ue_fd, &n_msg, to_send, 0, - (struct sockaddr *)&sa, sizeof(sa)); - if (sent == -1) - { - LOG_E(RRC, "%s: sendto: %s\n", __func__, strerror(errno)); - return; - } - if (sent != to_send) - { - LOG_E(RRC, "%s: Short send %d != %zu\n", __func__, sent, to_send); - return; - } - LOG_I(RRC, "Sent a %d message to the nrUE (%d bytes) \n", msg_type, sent); -} - -void init_connections_with_nr_ue() -{ - struct sockaddr_in sa = - { - .sin_family = AF_INET, - .sin_port = htons(6007 + ue_id_g * 2), - }; - AssertFatal(from_nr_ue_fd == -1, "from_nr_ue_fd was assigned already"); - from_nr_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); - if (from_nr_ue_fd == -1) - { - LOG_E(RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, from_nr_ue_fd, errno, strerror(errno)); - abort(); - } - - if (inet_aton(nsa_ipaddr, &sa.sin_addr) == 0) - { - LOG_E(RRC, "Bad nsa_ipaddr '%s'\n", nsa_ipaddr); - abort(); - } - - if (bind(from_nr_ue_fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) - { - LOG_E(RRC,"%s: Failed to bind the socket\n", __FUNCTION__); - abort(); - } - - AssertFatal(to_nr_ue_fd == -1, "to_nr_ue_fd was assigned already"); - to_nr_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); - if (to_nr_ue_fd == -1) - { - LOG_E(RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, to_nr_ue_fd, errno, strerror(errno)); - abort(); - } - -} - -void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len) -{ - if (msg_len < sizeof(msg->msg_type)) - { - LOG_E(RRC, "Msg_len = %d\n", msg_len); - return; - } - LOG_D(RRC, "We are processing an NSA message %d \n", msg->msg_type); - Rrc_Msg_Type_t msg_type = msg->msg_type; - uint8_t *const msg_buffer = msg->msg_buffer; - msg_len -= sizeof(msg->msg_type); - bool received_nr_msg = true; - protocol_ctxt_t ctxt; - module_id_t module_id = 0; - eNB_index_t eNB_index = 0; - - switch (msg_type) - { - case NRUE_CAPABILITY_INFO: - { - LOG_I(RRC, "Create itti msg to send received NRUE_CAPABILITY_INFO to eNB\n"); - - MessageDef *message_p; - rrc_nrue_cap_info_t *nrue_cap_buf = itti_malloc (TASK_RRC_NSA_UE, - TASK_RRC_UE, - sizeof(rrc_nrue_cap_info_t)); - AssertFatal(msg_len <= sizeof(nrue_cap_buf->mesg), "msg_len = %d\n", msg_len); - memcpy(nrue_cap_buf->mesg, msg_buffer, msg_len); - nrue_cap_buf->mesg_len = msg_len; - UE_RRC_INFO *info = &UE_rrc_inst[module_id].Info[eNB_index]; - nrue_cap_buf->dl_dcch_msg = info->dl_dcch_msg; - info->dl_dcch_msg = NULL; - message_p = itti_alloc_new_message (TASK_RRC_UE, 0, RRC_NRUE_CAP_INFO_IND); - RRC_NRUE_CAP_INFO_IND (message_p).sdu_p = (void *)nrue_cap_buf; - RRC_NRUE_CAP_INFO_IND (message_p).sdu_size = sizeof(*nrue_cap_buf); - RRC_NRUE_CAP_INFO_IND (message_p).module_id = module_id; - RRC_NRUE_CAP_INFO_IND (message_p).rnti = info->rnti; - RRC_NRUE_CAP_INFO_IND (message_p).eNB_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, 0, message_p); - LOG_I(RRC, "Sent itti RRC_NRUE_CAP_INFO_IND\n"); - break; - } - case UE_CAPABILITY_DUMMY: - { - fill_ue_capability(NULL, received_nr_msg); - UE_rrc_inst[module_id].UECap = UE_rrc_inst->UECap; - if (!is_en_dc_supported(UE_rrc_inst->UECap->UE_EUTRA_Capability)) - { - LOG_E(RRC, "en_dc is NOT supported! Not sending RRC_DCCH_DATA_COPY_IND to update UE_Capability_INFO\n"); - break; - } - - LOG_I(RRC, "Send itti msg to trigger processing of capabilites b/c we have a UE_CAPABILITY_DUMMY\n"); - MessageDef *message_p; - rrc_dcch_data_copy_t *dl_dcch_buffer = itti_malloc (TASK_RRC_NSA_UE, - TASK_RRC_UE, - sizeof(rrc_dcch_data_copy_t)); - UE_RRC_INFO *info = &UE_rrc_inst[module_id].Info[eNB_index]; - dl_dcch_buffer->dl_dcch_msg = info->dl_dcch_msg; - info->dl_dcch_msg = NULL; - message_p = itti_alloc_new_message (TASK_RRC_UE, 0, RRC_DCCH_DATA_COPY_IND); - RRC_DCCH_DATA_COPY_IND (message_p).sdu_p = (void *)dl_dcch_buffer; - RRC_DCCH_DATA_COPY_IND (message_p).sdu_size = sizeof(rrc_dcch_data_copy_t); - RRC_DCCH_DATA_COPY_IND (message_p).module_id = module_id; - RRC_DCCH_DATA_COPY_IND (message_p).rnti = info->rnti; - RRC_DCCH_DATA_COPY_IND (message_p).eNB_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, 0, message_p); - LOG_I(RRC, "Sent itti RRC_DCCH_DATA_COPY_IND\n"); - break; - } - - case NR_UE_RRC_MEASUREMENT: - { - nfapi_p7_message_header_t header; - if (nfapi_p7_message_header_unpack((void *)msg_buffer, msg_len, &header, sizeof(header), NULL) < 0) - { - LOG_E(MAC, "Header unpack failed in %s \n", __FUNCTION__); - break; - } - if (header.message_id != NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST) - { - LOG_E(MAC, "%s: Unexpected nfapi message type: %d\n", __FUNCTION__, header.message_id); - break; - } - - nfapi_nr_dl_tti_request_t dl_tti_request; - const bool result = - nfapi_nr_p7_message_unpack((void *)msg_buffer, msg_len, &dl_tti_request, sizeof(nfapi_nr_dl_tti_request_t), NULL); - if (!result) { - LOG_E(RRC, "%s: SSB PDU unpack failed \n", __FUNCTION__); - break; - } - int num_pdus = dl_tti_request.dl_tti_request_body.nPDUs; - if (num_pdus <= 0) - { - LOG_E(RRC, "%s: dl_tti_request number of PDUS <= 0\n", __FUNCTION__); - abort(); - } - for (int i = 0; i < num_pdus; i++) - { - nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request.dl_tti_request_body.dl_tti_pdu_list[i]; - if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE) - { - LOG_I(RRC, "Got an NR_UE_RRC_MEASUREMENT. pdulist[%d].ssbRsrp = %d\n", - i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssbRsrp); - } - } - break; - } - - case NR_RRC_CONFIG_COMPLETE_REQ: - { - LOG_I(RRC, "Got an NR_RRC_CONFIG_COMPLETE_REQ. Now make octet string and call below!\n"); - OCTET_STRING_t rrcConfigurationComplete; - memset(&rrcConfigurationComplete, 0, sizeof(rrcConfigurationComplete)); - OCTET_STRING_fromBuf(&rrcConfigurationComplete, - (const char *)msg_buffer, - msg_len); - UE_RRC_INFO *info = &UE_rrc_inst[module_id].Info[eNB_index]; - uint8_t t_id = info->dl_dcch_msg->message.choice.c1.choice. - rrcConnectionReconfiguration.rrc_TransactionIdentifier; - PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_id, - ENB_FLAG_NO, info->rnti, - 0, 0, eNB_index); - rrc_ue_generate_RRCConnectionReconfigurationComplete(&ctxt, ctxt.eNB_index, t_id, &rrcConfigurationComplete); - break; - } - default: - LOG_E(RRC, "No NSA Message Found\n"); - } -} diff --git a/openair2/RRC/LTE/rrc_proto.h b/openair2/RRC/LTE/rrc_proto.h index 38ba42b251..261e6a9960 100644 --- a/openair2/RRC/LTE/rrc_proto.h +++ b/openair2/RRC/LTE/rrc_proto.h @@ -331,12 +331,6 @@ void *rrc_enb_task(void *args_p); \param args_p Pointer on arguments to start the task. */ void *rrc_ue_task(void *args_p); -/**\brief RRC NSA UE task. - \param args_p Pointer on arguments to start the task. */ -void *recv_msgs_from_nr_ue(void *args_p); - -void init_connections_with_nr_ue(void); - void rrc_eNB_process_x2_setup_request(int mod_id, x2ap_setup_req_t *m); void rrc_eNB_process_x2_setup_response(int mod_id, x2ap_setup_resp_t *m); diff --git a/openair2/RRC/NR_UE/L2_interface_ue.h b/openair2/RRC/NR_UE/L2_interface_ue.h index 857c110d9e..7ab320f709 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.h +++ b/openair2/RRC/NR_UE/L2_interface_ue.h @@ -47,7 +47,6 @@ void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id); void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, bool prepare_payload); void nr_ue_rrc_timer_trigger(int instance, int frame, int gnb_id); void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success); -void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); void process_msg_rcc_to_mac(nr_mac_rrc_message_t *msg, int instance_id); #endif diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 0544637975..d502ec45d0 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -140,7 +140,6 @@ static void nr_rrc_manage_rlc_bearers(NR_UE_RRC_INST_t *rrc, static void nr_rrc_ue_process_RadioBearerConfig(NR_UE_RRC_INST_t *ue_rrc, NR_RadioBearerConfig_t *const radioBearerConfig); static void nr_rrc_ue_generate_rrcReestablishmentComplete(const NR_UE_RRC_INST_t *rrc, const NR_RRCReestablishment_t *rrcReestablishment); -static void process_lte_nsa_msg(NR_UE_RRC_INST_t *rrc, nsa_msg_t *msg, int msg_len); static void nr_rrc_ue_process_ueCapabilityEnquiry(NR_UE_RRC_INST_t *rrc, NR_UECapabilityEnquiry_t *UECapabilityEnquiry); static void nr_rrc_ue_process_masterCellGroup(NR_UE_RRC_INST_t *rrc, OCTET_STRING_t *masterCellGroup, @@ -2713,10 +2712,6 @@ static void nr_rrc_ue_process_ueCapabilityEnquiry(NR_UE_RRC_INST_t *rrc, NR_UECa ue_CapabilityRAT_Container->rat_Type = NR_RAT_Type_nr; OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container->ue_CapabilityRAT_Container, (const char *)rrc->UECap.sdu, rrc->UECap.sdu_size); NR_UECapabilityEnquiry_IEs_t *ueCapabilityEnquiry_ie = UECapabilityEnquiry->criticalExtensions.choice.ueCapabilityEnquiry; - if (get_softmodem_params()->nsa == 1) { - OCTET_STRING_t *requestedFreqBandsNR = ueCapabilityEnquiry_ie->ue_CapabilityEnquiryExt; - nsa_sendmsg_to_lte_ue(requestedFreqBandsNR->buf, requestedFreqBandsNR->size, UE_CAPABILITY_INFO); - } // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.buf = UE_rrc_inst[ue_mod_idP].UECapability; // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.size = UE_rrc_inst[ue_mod_idP].UECapability_size; AssertFatal(UECapabilityEnquiry->criticalExtensions.present == NR_UECapabilityEnquiry__criticalExtensions_PR_ueCapabilityEnquiry, @@ -2799,183 +2794,6 @@ static void nr_rrc_ue_generate_rrcReestablishmentComplete(const NR_UE_RRC_INST_t nr_pdcp_data_req_srb(rrc->ue_id, srb_id, 0, size, buffer, deliver_pdu_srb_rlc, NULL); } -void *recv_msgs_from_lte_ue(void *args_p) -{ - itti_mark_task_ready (TASK_RRC_NSA_NRUE); - int from_lte_ue_fd = get_from_lte_ue_fd(); - for (;;) { - nsa_msg_t msg; - int recvLen = recvfrom(from_lte_ue_fd, &msg, sizeof(msg), MSG_WAITALL | MSG_TRUNC, NULL, NULL); - if (recvLen == -1) { - LOG_E(NR_RRC, "%s: recvfrom: %s\n", __func__, strerror(errno)); - continue; - } - if (recvLen > sizeof(msg)) { - LOG_E(NR_RRC, "%s: Received truncated message %d\n", __func__, recvLen); - continue; - } - process_lte_nsa_msg(get_NR_UE_rrc_inst(0), &msg, recvLen); - } - return NULL; -} - -static void nsa_rrc_ue_process_ueCapabilityEnquiry(NR_UE_RRC_INST_t *rrc) -{ - NR_UE_NR_Capability_t *UE_Capability_nr = rrc->UECap.UE_NR_Capability = CALLOC(1, sizeof(NR_UE_NR_Capability_t)); - NR_BandNR_t *nr_bandnr = CALLOC(1, sizeof(NR_BandNR_t)); - nr_bandnr->bandNR = 78; - asn1cSeqAdd(&UE_Capability_nr->rf_Parameters.supportedBandListNR.list, nr_bandnr); - OAI_NR_UECapability_t *UECap = CALLOC(1, sizeof(OAI_NR_UECapability_t)); - UECap->UE_NR_Capability = UE_Capability_nr; - - asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_NR_Capability, - NULL, - (void *)UE_Capability_nr, - &UECap->sdu[0], - MAX_UE_NR_CAPABILITY_SIZE); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", - enc_rval.failed_type->name, enc_rval.encoded); - UECap->sdu_size = (enc_rval.encoded + 7) / 8; - LOG_A(NR_RRC, "[NR_RRC] NRUE Capability encoded, %d bytes (%zd bits)\n", - UECap->sdu_size, enc_rval.encoded + 7); - - NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container; - memset(&ue_CapabilityRAT_Container, 0, sizeof(NR_UE_CapabilityRAT_Container_t)); - ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_nr; - OCTET_STRING_fromBuf(&ue_CapabilityRAT_Container.ue_CapabilityRAT_Container, - (const char *)rrc->UECap.sdu, - rrc->UECap.sdu_size); - - nsa_sendmsg_to_lte_ue(ue_CapabilityRAT_Container.ue_CapabilityRAT_Container.buf, - ue_CapabilityRAT_Container.ue_CapabilityRAT_Container.size, - NRUE_CAPABILITY_INFO); -} - -static void process_lte_nsa_msg(NR_UE_RRC_INST_t *rrc, nsa_msg_t *msg, int msg_len) -{ - if (msg_len < sizeof(msg->msg_type)) { - LOG_E(RRC, "Msg_len = %d\n", msg_len); - return; - } - LOG_D(NR_RRC, "Processing an NSA message\n"); - Rrc_Msg_Type_t msg_type = msg->msg_type; - uint8_t *const msg_buffer = msg->msg_buffer; - msg_len -= sizeof(msg->msg_type); - switch (msg_type) { - case UE_CAPABILITY_ENQUIRY: { - LOG_D(NR_RRC, "We are processing a %d message \n", msg_type); - NR_FreqBandList_t *nr_freq_band_list = NULL; - asn_dec_rval_t dec_rval = uper_decode_complete(NULL, - &asn_DEF_NR_FreqBandList, - (void **)&nr_freq_band_list, - msg_buffer, - msg_len); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - SEQUENCE_free(&asn_DEF_NR_FreqBandList, nr_freq_band_list, ASFM_FREE_EVERYTHING); - LOG_E(RRC, "Failed to decode UECapabilityInfo (%zu bits)\n", dec_rval.consumed); - break; - } - for (int i = 0; i < nr_freq_band_list->list.count; i++) { - LOG_D(NR_RRC, "Received NR band information: %ld.\n", - nr_freq_band_list->list.array[i]->choice.bandInformationNR->bandNR); - } - int dummy_msg = 0;// whatever piece of data, it will never be used by sendee - LOG_D(NR_RRC, "We are calling nsa_sendmsg_to_lte_ue to send a UE_CAPABILITY_DUMMY\n"); - nsa_sendmsg_to_lte_ue(&dummy_msg, sizeof(dummy_msg), UE_CAPABILITY_DUMMY); - LOG_A(NR_RRC, "Sent initial NRUE Capability response to LTE UE\n"); - break; - } - - case NRUE_CAPABILITY_ENQUIRY: { - LOG_I(NR_RRC, "We are processing a %d message \n", msg_type); - NR_FreqBandList_t *nr_freq_band_list = NULL; - asn_dec_rval_t dec_rval = uper_decode_complete(NULL, - &asn_DEF_NR_FreqBandList, - (void **)&nr_freq_band_list, - msg_buffer, - msg_len); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - SEQUENCE_free(&asn_DEF_NR_FreqBandList, nr_freq_band_list, ASFM_FREE_EVERYTHING); - LOG_E(NR_RRC, "Failed to decode UECapabilityInfo (%zu bits)\n", dec_rval.consumed); - break; - } - LOG_I(NR_RRC, "Calling nsa_rrc_ue_process_ueCapabilityEnquiry\n"); - nsa_rrc_ue_process_ueCapabilityEnquiry(rrc); - break; - } - - case RRC_MEASUREMENT_PROCEDURE: { - LOG_I(NR_RRC, "We are processing a %d message \n", msg_type); - - LTE_MeasObjectToAddMod_t *nr_meas_obj = NULL; - asn_dec_rval_t dec_rval = uper_decode_complete(NULL, - &asn_DEF_NR_MeasObjectToAddMod, - (void **)&nr_meas_obj, - msg_buffer, - msg_len); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { - SEQUENCE_free(&asn_DEF_NR_MeasObjectToAddMod, nr_meas_obj, ASFM_FREE_EVERYTHING); - LOG_E(RRC, "Failed to decode measurement object (%zu bits) %d\n", dec_rval.consumed, dec_rval.code); - break; - } - LOG_D(NR_RRC, "NR carrierFreq_r15 (ssb): %ld and sub carrier spacing:%ld\n", - nr_meas_obj->measObject.choice.measObjectNR_r15.carrierFreq_r15, - nr_meas_obj->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15); - //start_oai_nrue_threads(); - break; - } - - case RRC_CONFIG_COMPLETE_REQ: { - struct msg { - uint32_t RadioBearer_size; - uint32_t SecondaryCellGroup_size; - uint8_t trans_id; - uint8_t padding[3]; - uint8_t buffer[]; - } hdr; - AssertFatal(msg_len >= sizeof(hdr), "Bad received msg\n"); - memcpy(&hdr, msg_buffer, sizeof(hdr)); - LOG_I(NR_RRC, "We got an RRC_CONFIG_COMPLETE_REQ\n"); - uint32_t nr_RadioBearer_size = hdr.RadioBearer_size; - uint32_t nr_SecondaryCellGroup_size = hdr.SecondaryCellGroup_size; - AssertFatal(sizeof(hdr) + nr_RadioBearer_size + nr_SecondaryCellGroup_size <= msg_len, - "nr_RadioBearerConfig1_r15 size %u nr_SecondaryCellGroupConfig_r15 size %u sizeof(hdr) %zu, msg_len = %d\n", - nr_RadioBearer_size, - nr_SecondaryCellGroup_size, - sizeof(hdr), - msg_len); - NR_RRC_TransactionIdentifier_t t_id = hdr.trans_id; - LOG_I(NR_RRC, "nr_RadioBearerConfig1_r15 size %d nr_SecondaryCellGroupConfig_r15 size %d t_id %ld\n", - nr_RadioBearer_size, - nr_SecondaryCellGroup_size, - t_id); - - uint8_t *nr_RadioBearer_buffer = msg_buffer + offsetof(struct msg, buffer); - uint8_t *nr_SecondaryCellGroup_buffer = nr_RadioBearer_buffer + nr_RadioBearer_size; - process_nsa_message(get_NR_UE_rrc_inst(0), nr_SecondaryCellGroupConfig_r15, nr_SecondaryCellGroup_buffer, nr_SecondaryCellGroup_size); - process_nsa_message(get_NR_UE_rrc_inst(0), nr_RadioBearerConfigX_r15, nr_RadioBearer_buffer, nr_RadioBearer_size); - LOG_I(NR_RRC, "Calling do_NR_RRCReconfigurationComplete. t_id %ld \n", t_id); - uint8_t buffer[NR_RRC_BUF_SIZE]; - size_t size = do_NR_RRCReconfigurationComplete_for_nsa(buffer, sizeof(buffer), t_id); - nsa_sendmsg_to_lte_ue(buffer, size, NR_RRC_CONFIG_COMPLETE_REQ); - break; - } - - case OAI_TUN_IFACE_NSA: { - LOG_I(NR_RRC, "We got an OAI_TUN_IFACE_NSA!!\n"); - char cmd_line[NR_RRC_BUF_SIZE]; - memcpy(cmd_line, msg_buffer, sizeof(cmd_line)); - LOG_D(NR_RRC, "Command line: %s\n", cmd_line); - if (background_system(cmd_line) != 0) - LOG_E(NR_RRC, "ESM-PROC - failed command '%s'", cmd_line); - break; - } - - default: - LOG_E(NR_RRC, "No NSA Message Found\n"); - } -} - void handle_RRCRelease(NR_UE_RRC_INST_t *rrc) { NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; diff --git a/openair2/RRC/NR_UE/rrc_nsa.c b/openair2/RRC/NR_UE/rrc_nsa.c deleted file mode 100644 index 279e920779..0000000000 --- a/openair2/RRC/NR_UE/rrc_nsa.c +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include -#include -#include "common/utils/LOG/log.h" -#include "openair2/RRC/NR_UE/rrc_proto.h" - -static const char nsa_ipaddr[] = "127.0.0.1"; -static int from_lte_ue_fd = -1; -static int to_lte_ue_fd = -1; -uint16_t ue_id_g; - -int get_from_lte_ue_fd() -{ - return from_lte_ue_fd; -} - -void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type) -{ - LOG_I(NR_RRC, "Entered %s \n", __FUNCTION__); - nsa_msg_t n_msg; - if (msg_len > sizeof(n_msg.msg_buffer)) - { - LOG_E(NR_RRC, "%s: message too big: %zu\n", __func__, msg_len); - abort(); - } - n_msg.msg_type = msg_type; - memcpy(n_msg.msg_buffer, message, msg_len); - size_t to_send = sizeof(n_msg.msg_type) + msg_len; - - struct sockaddr_in sa = - { - .sin_family = AF_INET, - .sin_port = htons(6007 + ue_id_g * 2), - }; - int sent = sendto(from_lte_ue_fd, &n_msg, to_send, 0, - (struct sockaddr *)&sa, sizeof(sa)); - if (sent == -1) - { - LOG_E(NR_RRC, "%s: sendto: %s\n", __func__, strerror(errno)); - return; - } - if (sent != to_send) - { - LOG_E(NR_RRC, "%s: Short send %d != %zu\n", __func__, sent, to_send); - return; - } - LOG_D(NR_RRC, "Sent a %d message to the LTE UE (%d bytes) \n", msg_type, sent); -} - -void init_connections_with_lte_ue(void) -{ - struct sockaddr_in sa = - { - .sin_family = AF_INET, - .sin_port = htons(6008 + ue_id_g * 2), - }; - AssertFatal(from_lte_ue_fd == -1, "from_lte_ue_fd %d was assigned already", from_lte_ue_fd); - from_lte_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); - if (from_lte_ue_fd == -1) - { - LOG_E(NR_RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, from_lte_ue_fd, errno, strerror(errno)); - abort(); - } - - if (inet_aton(nsa_ipaddr, &sa.sin_addr) == 0) - { - LOG_E(NR_RRC, "Bad nsa_ipaddr '%s'\n", nsa_ipaddr); - abort(); - } - - if (bind(from_lte_ue_fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) - { - LOG_E(NR_RRC,"%s: Failed to bind the socket\n", __FUNCTION__); - abort(); - } - - AssertFatal(to_lte_ue_fd == -1, "to_lte_ue_fd was assigned already"); - to_lte_ue_fd = socket(AF_INET, SOCK_DGRAM, 0); - if (to_lte_ue_fd == -1) - { - LOG_E(NR_RRC, "%s: Error opening socket %d (%d:%s)\n", __FUNCTION__, to_lte_ue_fd, errno, strerror(errno)); - abort(); - } - LOG_I(NR_RRC, "Started LTE-NR link in the nr-UE\n"); -} diff --git a/openair2/RRC/NR_UE/rrc_proto.h b/openair2/RRC/NR_UE/rrc_proto.h index cdcf1966b4..1ebb728884 100644 --- a/openair2/RRC/NR_UE/rrc_proto.h +++ b/openair2/RRC/NR_UE/rrc_proto.h @@ -68,12 +68,6 @@ void nr_rrc_handle_timers(NR_UE_RRC_INST_t *rrc); void handle_rlf_detection(NR_UE_RRC_INST_t *rrc); void handle_302_expired_stopped(NR_UE_RRC_INST_t *rrc); -/**\brief RRC NSA UE task. - \param void *args_p Pointer on arguments to start the task. */ -void *recv_msgs_from_lte_ue(void *args_p); - -void init_connections_with_lte_ue(void); - int get_from_lte_ue_fd(); void nr_rrc_SI_timers(NR_UE_RRC_SI_INFO *SInfo); diff --git a/openair3/NAS/NR_UE/nr_nas_msg.c b/openair3/NAS/NR_UE/nr_nas_msg.c index cf8b5dd0d6..d0230e0a03 100644 --- a/openair3/NAS/NR_UE/nr_nas_msg.c +++ b/openair3/NAS/NR_UE/nr_nas_msg.c @@ -2160,7 +2160,7 @@ void *nas_nrue(void *args_p) case NAS_INIT_NOS1_IF: { const int pdu_session_id = get_softmodem_params()->default_pdu_session_id; - const char *ip = !get_softmodem_params()->nsa ? "10.0.1.2" : "10.0.1.3"; + const char *ip = "10.0.1.2"; const int qfi = 7; create_ue_ip_if(ip, NULL, nas->UE_id, pdu_session_id); set_qfi(qfi, pdu_session_id, nas->UE_id);