diff --git a/executables/nr-softmodem-common.h b/executables/nr-softmodem-common.h index c968fee7b6..500819e684 100644 --- a/executables/nr-softmodem-common.h +++ b/executables/nr-softmodem-common.h @@ -77,6 +77,7 @@ #define CONFIG_HLP_UE "Set the lte softmodem as a UE\n" #define CONFIG_HLP_L2MONW "Enable L2 wireshark messages on localhost \n" #define CONFIG_HLP_L2MONP "Enable L2 pcap messages on localhost \n" +#define CONFIG_HLP_MAC "Disable the MAC procedures at UE side (default is enabled)\n" #define CONFIG_HLP_VCD "Enable VCD (generated file will is named openair_dump_eNB.vcd, read it with target/RT/USER/eNB.gtkw\n" #define CONFIG_HLP_TQFS "Apply three-quarter of sampling frequency, 23.04 Msps to reduce the data rate on USB/PCIe transfers (only valid for 20 MHz)\n" #define CONFIG_HLP_TPORT "tracer port\n" diff --git a/executables/nr-ue.c b/executables/nr-ue.c index dc96afbf16..ad5478e62e 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -93,7 +93,6 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue, int nb_connected_gNB = 1, gNB_id; ue->Mod_id = UE_id; - ue->mac_enabled = 1; ue->if_inst = nr_ue_if_module_init(0); // Setting UE mode to NOT_SYNCHED by default diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index 1d3288862d..90a451c12b 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -111,6 +111,7 @@ volatile int oai_exit = 0; extern int16_t nr_dlsch_demod_shift; static int tx_max_power[MAX_NUM_CCs] = {0}; +int mac_enabled = 1; int single_thread_flag = 1; int threequarter_fs = 0; int UE_scan_carrier = 0; @@ -299,6 +300,7 @@ void set_options(int CC_id, PHY_VARS_NR_UE *UE){ tx_gain[0][CC_id] = tx_gain[0][0]; // Set UE variables + UE->mac_enabled = mac_enabled; UE->UE_scan = UE_scan; UE->UE_scan_carrier = UE_scan_carrier; UE->UE_fo_compensation = UE_fo_compensation; diff --git a/executables/nr-uesoftmodem.h b/executables/nr-uesoftmodem.h index b2d321ae29..f11335e59e 100644 --- a/executables/nr-uesoftmodem.h +++ b/executables/nr-uesoftmodem.h @@ -63,6 +63,7 @@ {"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, iptr:&threequarter_fs, defintval:0, TYPE_INT, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ {"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \ + {"mac-enabled" , CONFIG_HLP_MAC, PARAMFLAG_BOOL, iptr:&mac_enabled, defintval:1, TYPE_INT, 0}, \ {"ue-timing-correction-disable", CONFIG_HLP_DISABLETIMECORR, PARAMFLAG_BOOL, iptr:&UE_no_timing_correction, defintval:0, TYPE_INT, 0}, \ {"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0} \ } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 9ce071068d..689b0b1471 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -241,7 +241,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, } if (get_softmodem_params()->do_ra==1) { - if ((ue->UE_mode[gNB_id] > NOT_SYNCHED && ue->UE_mode[gNB_id] < PUSCH) && (ue->prach_vars[gNB_id]->prach_Config_enabled == 1)) { + if ((ue->UE_mode[gNB_id] > NOT_SYNCHED && ue->UE_mode[gNB_id] < PUSCH) && (ue->prach_vars[gNB_id]->prach_Config_enabled == 1) && ue->mac_enabled) { nr_ue_prach_procedures(ue, proc, gNB_id); } } @@ -846,9 +846,10 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { UE_MODE_t UE_mode = ue->UE_mode[gNB_index]; NR_PRACH_RESOURCES_t *prach_resources = ue->prach_resources[gNB_index]; - LOG_D(PHY,"[UE %d][RAPROC] Frame %d slot %d Received RAR mode %d\n", module_id, frame_rx, nr_slot_rx, UE_mode); - if (ue->mac_enabled == 1) { + + LOG_D(PHY,"[UE %d][RAPROC] Frame %d slot %d Received RAR mode %d\n", module_id, frame_rx, nr_slot_rx, UE_mode); + if ((UE_mode != PUSCH) && (prach_resources->Msg3 != NULL)) { LOG_D(PHY,"[UE %d][RAPROC] Frame %d slot %d Invoking MAC for RAR (current preamble %d)\n", module_id, frame_rx, nr_slot_rx, prach_resources->ra_PreambleIndex); @@ -878,10 +879,6 @@ void nr_process_rar(nr_downlink_indication_t *dl_info) { LOG_W(PHY,"[UE %d][RAPROC] Received RAR preamble (%d) doesn't match !!!\n", ue->Mod_id, prach_resources->ra_PreambleIndex); } } - } else { - // rar = dlsch0->harq_processes[0]->b+1; - // ta_command = ((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); - // nr_process_timing_advance_rar(ue, frame_rx, nr_slot_rx, ta_command); } } @@ -2141,30 +2138,22 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t prach_resources->init_msg1 = 1; } - if (ue->mac_enabled == 0){ - // prach_resources->ra_PreambleIndex = preamble_tx; - prach_resources->ra_TDD_map_index = 0; - prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = 10; - prach_resources->ra_RNTI = 0x1234; - nr_prach = 1; - } else { - // ask L2 for RACH transport - LOG_D(PHY, "Getting PRACH resources. Frame %d Slot %d \n", frame_tx, nr_slot_tx); - // flush Msg3 Buffer - if (prach_resources->Msg3 == NULL){ - for(int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) { - ue->ulsch_Msg3_active[i] = 0; - } + // ask L2 for RACH transport + LOG_D(PHY, "Getting PRACH resources. Frame %d Slot %d \n", frame_tx, nr_slot_tx); + // flush Msg3 Buffer + if (prach_resources->Msg3 == NULL){ + for(int i = 0; i < NUMBER_OF_CONNECTED_gNB_MAX; i++) { + ue->ulsch_Msg3_active[i] = 0; } - nr_prach = nr_ue_get_rach(ue->prach_resources[gNB_id], &ue->prach_vars[0]->prach_pdu, mod_id, ue->CC_id, UE_mode, frame_tx, gNB_id, nr_slot_tx); } + nr_prach = nr_ue_get_rach(ue->prach_resources[gNB_id], &ue->prach_vars[0]->prach_pdu, mod_id, ue->CC_id, UE_mode, frame_tx, gNB_id, nr_slot_tx); + if (ue->prach_resources[gNB_id] != NULL && nr_prach == 1 && prach_resources->init_msg1) { pathloss = get_nr_PL(mod_id, ue->CC_id, gNB_id); - if (ue->mac_enabled) - ue->tx_power_dBm[nr_slot_tx] = prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER + pathloss; + ue->tx_power_dBm[nr_slot_tx] = prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER + pathloss; LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_slot_tx %d : Generating PRACH, preamble %d, PL %d, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, RA-RNTI %x\n", ue->Mod_id, @@ -2202,8 +2191,7 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t dB_fixed(prach_power), ue->prach_vars[gNB_id]->amp); - if (ue->mac_enabled == 1) - nr_Msg1_transmitted(ue->Mod_id, ue->CC_id, frame_tx, gNB_id); + nr_Msg1_transmitted(ue->Mod_id, ue->CC_id, frame_tx, gNB_id); LOG_I(PHY,"[UE %d][RAPROC] Frame %d, nr_slot_tx %d: Generated PRACH Msg1 (gNB %d) preamble index %d for UL, TX power %d dBm (PL %d dB) \n", ue->Mod_id,