From a01ade336f7b05bae3eced05abda5e43be613c64 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Thu, 3 Nov 2022 21:19:16 -0400 Subject: [PATCH 1/4] Start TX slot after receiving slot samples from RU --- executables/nr-ue.c | 60 +++++++-------------- openair1/SCHED_NR_UE/defs.h | 3 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 27 ++++++---- openair1/SIMULATION/NR_PHY/dlsim.c | 3 +- openair1/SIMULATION/NR_PHY/ulsim.c | 4 -- openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c | 15 ++---- 6 files changed, 42 insertions(+), 70 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index b3de5d751a..19284a3d72 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -32,7 +32,6 @@ #include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h" #include "executables/softmodem-common.h" #include "LAYER2/nr_pdcp/nr_pdcp_entity.h" -#include "SCHED_NR_UE/pucch_uci_ue_nr.h" #include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" @@ -668,7 +667,7 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { phy_procedures_slot_parallelization_nrUE_RX( UE, proc, 0, 0, 1, no_relay, NULL ); #else uint64_t a=rdtsc_oai(); - phy_procedures_nrUE_RX(UE, proc, gNB_id, &phy_data, &rxtxD->txFifo); + phy_procedures_nrUE_RX(UE, proc, gNB_id, &phy_data); LOG_D(PHY, "In %s: slot %d, time %llu\n", __FUNCTION__, proc->nr_slot_rx, (rdtsc_oai()-a)/3500); #endif @@ -678,46 +677,6 @@ void UE_processing(nr_rxtx_thread_data_t *rxtxD) { PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, UE->Mod_id, ENB_FLAG_NO, mac->crnti, proc->frame_rx, proc->nr_slot_rx, 0); pdcp_run(&ctxt); } - - // Wait for PUSCH processing to finish - notifiedFIFO_elt_t *res; - res = pullTpool(&rxtxD->txFifo,&(get_nrUE_params()->Tpool)); - if (res == NULL) - return; // Tpool has been stopped - delNotifiedFIFO_elt(res); - } - - if (proc->tx_slot_type == NR_UPLINK_SLOT || proc->tx_slot_type == NR_MIXED_SLOT) { - nr_phy_data_tx_t phy_data = {0}; - if (UE->if_inst != NULL && UE->if_inst->ul_indication != NULL) { - nr_uplink_indication_t ul_indication; - memset((void*)&ul_indication, 0, sizeof(ul_indication)); - ul_indication.module_id = UE->Mod_id; - ul_indication.gNB_index = gNB_id; - ul_indication.cc_id = UE->CC_id; - ul_indication.frame_rx = proc->frame_rx; - ul_indication.slot_rx = proc->nr_slot_rx; - ul_indication.frame_tx = proc->frame_tx; - ul_indication.slot_tx = proc->nr_slot_tx; - ul_indication.ue_sched_mode = SCHED_PUCCH; - ul_indication.phy_data = &phy_data; - UE->if_inst->ul_indication(&ul_indication); - } - if (UE->UE_mode[gNB_id] <= PUSCH) { - pucch_procedures_ue_nr(UE, - gNB_id, - proc, - &phy_data); - } - - LOG_D(PHY, "Sending Uplink data \n"); - nr_ue_pusch_common_procedures(UE, - proc->nr_slot_tx, - &UE->frame_parms, - UE->frame_parms.nb_antennas_tx); - - if (UE->UE_mode[gNB_id] > NOT_SYNCHED && UE->UE_mode[gNB_id] < PUSCH) - nr_ue_prach_procedures(UE, proc, proc->gNB_id); } ue_ta_procedures(UE, proc->nr_slot_tx, proc->frame_tx); @@ -911,6 +870,7 @@ void *UE_thread(void *arg) { int slot_nr = absolute_slot % nb_slot_frame; nr_rxtx_thread_data_t curMsg = {0}; + initNotifiedFIFO(&curMsg.txFifo); curMsg.UE=UE; // update thread index for received subframe curMsg.proc.CC_id = UE->CC_id; @@ -980,8 +940,24 @@ void *UE_thread(void *arg) { UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX) - firstSymSamp; + // Start TX slot processing here. It runs in parallel with RX slot processing + notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_tx, &curMsg.txFifo, processSlotTX); + nr_rxtx_thread_data_t *curMsgTx = (nr_rxtx_thread_data_t *) NotifiedFifoData(newElt); + curMsgTx->proc = curMsg.proc; + curMsgTx->UE = UE; + pushTpool(&(get_nrUE_params()->Tpool), newElt); + + // RX slot processing UE_processing(&curMsg); + // Wait for PUSCH processing to finish + notifiedFIFO_elt_t *res; + res = pullTpool(&curMsg.txFifo, &(get_nrUE_params()->Tpool)); + if (res == NULL) + LOG_E(PHY, "Tpool has been aborted\n"); + else + delNotifiedFIFO_elt(res); + if (curMsg.proc.decoded_frame_rx != -1) decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | curMsg.proc.decoded_frame_rx); else diff --git a/openair1/SCHED_NR_UE/defs.h b/openair1/SCHED_NR_UE/defs.h index 4e65074c43..89e5d7501c 100644 --- a/openair1/SCHED_NR_UE/defs.h +++ b/openair1/SCHED_NR_UE/defs.h @@ -109,8 +109,7 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - nr_phy_data_t *phy_data, - notifiedFIFO_t *txFifo); + nr_phy_data_t *phy_data); int phy_procedures_slot_parallelization_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, uint8_t abstraction_flag, uint8_t do_pdcch_flag, relaying_type_t r_type); diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index af44860664..fd916797cc 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -297,6 +297,23 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, if (ue->UE_mode[gNB_id] == PUSCH) { ue_srs_procedures_nr(ue, proc, gNB_id); } + + if (ue->UE_mode[gNB_id] <= PUSCH) { + pucch_procedures_ue_nr(ue, + gNB_id, + proc, + phy_data); + } + + LOG_D(PHY, "Sending Uplink data \n"); + nr_ue_pusch_common_procedures(ue, + proc->nr_slot_tx, + &ue->frame_parms, + ue->frame_parms.nb_antennas_tx); + + if (ue->UE_mode[gNB_id] > NOT_SYNCHED && ue->UE_mode[gNB_id] < PUSCH) + nr_ue_prach_procedures(ue, proc, proc->gNB_id); + LOG_D(PHY,"****** end TX-Chain for AbsSubframe %d.%d ******\n", proc->frame_tx, proc->nr_slot_tx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); @@ -981,8 +998,7 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t gNB_id, - nr_phy_data_t *phy_data, - notifiedFIFO_t *txFifo) { + nr_phy_data_t *phy_data) { int frame_rx = proc->frame_rx; int nr_slot_rx = proc->nr_slot_rx; @@ -1176,13 +1192,6 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, #endif //NR_PDCCH_SCHED - // Start PUSCH processing here. It runs in parallel with PDSCH processing - notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), proc->nr_slot_tx,txFifo,processSlotTX); - nr_rxtx_thread_data_t *curMsg=(nr_rxtx_thread_data_t *)NotifiedFifoData(newElt); - curMsg->proc = *proc; - curMsg->UE = ue; - curMsg->ue_sched_mode = SCHED_PUSCH; - pushTpool(&(get_nrUE_params()->Tpool), newElt); start_meas(&ue->generic_stat); // do procedures for C-RNTI int ret_pdsch = 0; diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 68f63d9512..0d2f7667be 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -1267,8 +1267,7 @@ int main(int argc, char **argv) phy_procedures_nrUE_RX(UE, &UE_proc, 0, - &phy_data, - NULL); + &phy_data); //---------------------------------------------------------- //---------------------- count errors ---------------------- diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 5355f34d65..5a3be4306d 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -1243,10 +1243,6 @@ int main(int argc, char **argv) phy_procedures_nrUE_TX(UE, &UE_proc, gNB_id, &phy_data); - /* We need to call common sending function to send signal */ - LOG_D(PHY, "Sending Uplink data \n"); - nr_ue_pusch_common_procedures(UE, slot, &UE->frame_parms, UE->frame_parms.nb_antennas_tx); - if (n_trials == 1) { LOG_M("txsig0.m", "txs0", &UE->common_vars.txdata[0][slot_offset], slot_length, 1, 1); LOG_M("txsig0F.m", "txs0F", UE->common_vars.txdataF[0], frame_parms->ofdm_symbol_size * 14, 1, 1); diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index e606c409b4..d93a4ada98 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1140,17 +1140,10 @@ int nr_ue_ul_indication(nr_uplink_indication_t *ul_info){ LOG_T(NR_MAC, "In %s():%d not calling scheduler. sched mode = %d and mac->ra.ra_state = %d\n", __FUNCTION__, __LINE__, ul_info->ue_sched_mode, mac->ra.ra_state); - switch (ul_info->ue_sched_mode) { - case SCHED_PUSCH: - ret = nr_ue_scheduler(NULL, ul_info); - if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type) && !get_softmodem_params()->phy_test) - nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); - break; - - case SCHED_PUCCH: - if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type)) - nr_ue_pucch_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->phy_data); - break; + ret = nr_ue_scheduler(NULL, ul_info); + if (is_nr_UL_slot(tdd_UL_DL_ConfigurationCommon, ul_info->slot_tx, mac->frame_type) && !get_softmodem_params()->phy_test) { + nr_ue_pucch_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx, ul_info->phy_data); + nr_ue_prach_scheduler(module_id, ul_info->frame_tx, ul_info->slot_tx); } switch(ret){ From 6d7afb014f80d3ab0b46ba492c5e4e292a185e09 Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Mon, 7 Nov 2022 19:22:28 -0500 Subject: [PATCH 2/4] Moved writing samples to RU inside TX function --- executables/nr-ue.c | 160 +++++++++++++++++++---------------- openair1/PHY/defs_nr_UE.h | 4 +- openair1/PHY/impl_defs_top.h | 4 +- radio/COMMON/common_lib.h | 8 ++ 4 files changed, 97 insertions(+), 79 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 19284a3d72..2e0dde6c67 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -34,6 +34,7 @@ #include "LAYER2/nr_pdcp/nr_pdcp_entity.h" #include "openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.h" #include "PHY/NR_REFSIG/refsig_defs_ue.h" +#include "radio/COMMON/common_lib.h" /* * NR SLOT PROCESSING SEQUENCE @@ -602,6 +603,61 @@ static void UE_synch(void *arg) { } } +static void RU_write(nr_rxtx_thread_data_t *rxtxD) { + + PHY_VARS_NR_UE *UE = rxtxD->UE; + UE_nr_rxtx_proc_t *proc = &rxtxD->proc; + + void *txp[NB_ANTENNAS_TX]; + for (int i=0; iframe_parms.nb_antennas_tx; i++) + txp[i] = (void *)&UE->common_vars.txdata[i][UE->frame_parms.get_samples_slot_timestamp( + proc->nr_slot_tx, &UE->frame_parms, 0)]; + + radio_tx_flag_t flags = Invalid; + + NR_UE_MAC_INST_t *mac = get_mac_inst(0); + + if (openair0_cfg[0].duplex_mode == duplex_mode_TDD && !get_softmodem_params()->continuous_tx) { + + uint8_t tdd_period = mac->phy_config.config_req.tdd_table.tdd_period_in_slots; + int nrofUplinkSlots, nrofUplinkSymbols; + if (mac->scc) { + nrofUplinkSlots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + nrofUplinkSymbols = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; + } + else { + nrofUplinkSlots = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; + nrofUplinkSymbols = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; + } + + int slot_tx_usrp = proc->nr_slot_tx; + uint8_t num_UL_slots = nrofUplinkSlots + (nrofUplinkSymbols != 0); + uint8_t first_tx_slot = tdd_period - num_UL_slots; + + if (slot_tx_usrp % tdd_period == first_tx_slot) + flags = StartOfBurst; + else if (slot_tx_usrp % tdd_period == first_tx_slot + num_UL_slots - 1) + flags = EndOfBurst; + else if (slot_tx_usrp % tdd_period > first_tx_slot) + flags = MiddleOfBurst; + } else { + flags = MiddleOfBurst; + } + + if (flags || IS_SOFTMODEM_RFSIM) + AssertFatal(rxtxD->writeBlockSize == + UE->rfdevice.trx_write_func(&UE->rfdevice, + proc->timestamp_tx, + txp, + rxtxD->writeBlockSize, + UE->frame_parms.nb_antennas_tx, + flags),""); + + for (int i=0; iframe_parms.nb_antennas_tx; i++) + memset(txp[i], 0, rxtxD->writeBlockSize); + +} + void processSlotTX(void *arg) { nr_rxtx_thread_data_t *rxtxD = (nr_rxtx_thread_data_t *) arg; @@ -635,6 +691,8 @@ void processSlotTX(void *arg) { phy_procedures_nrUE_TX(UE, proc, proc->gNB_id, &phy_data); } + + RU_write(rxtxD); } void UE_processing(nr_rxtx_thread_data_t *rxtxD) { @@ -783,7 +841,7 @@ void *UE_thread(void *arg) { PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg; // int tx_enabled = 0; openair0_timestamp timestamp, writeTimestamp; - void *rxp[NB_ANTENNAS_RX], *txp[NB_ANTENNAS_TX]; + void *rxp[NB_ANTENNAS_RX]; int start_rx_stream = 0; fapi_nr_config_request_t *cfg = &UE->nrUE_config; AssertFatal(0== openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]), ""); @@ -795,11 +853,14 @@ void *UE_thread(void *arg) { notifiedFIFO_t nf; initNotifiedFIFO(&nf); + notifiedFIFO_t txFifo; + initNotifiedFIFO(&txFifo); + notifiedFIFO_t freeBlocks; initNotifiedFIFO_nothreadSafe(&freeBlocks); - NR_UE_MAC_INST_t *mac = get_mac_inst(0); int timing_advance = UE->timing_advance; + NR_UE_MAC_INST_t *mac = get_mac_inst(0); bool syncRunning=false; const int nb_slot_frame = UE->frame_parms.slots_per_frame; @@ -870,7 +931,6 @@ void *UE_thread(void *arg) { int slot_nr = absolute_slot % nb_slot_frame; nr_rxtx_thread_data_t curMsg = {0}; - initNotifiedFIFO(&curMsg.txFifo); curMsg.UE=UE; // update thread index for received subframe curMsg.proc.CC_id = UE->CC_id; @@ -897,20 +957,16 @@ void *UE_thread(void *arg) { rxp[i] = (void *)&UE->common_vars.rxdata[i][firstSymSamp+ UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,0)]; - for (int i=0; iframe_parms.nb_antennas_tx; i++) - txp[i] = (void *)&UE->common_vars.txdata[i][UE->frame_parms.get_samples_slot_timestamp( - ((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH)%nb_slot_frame),&UE->frame_parms,0)]; - int readBlockSize, writeBlockSize; if (slot_nr<(nb_slot_frame - 1)) { readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms); - writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms); + writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms); } else { UE->rx_offset_diff = computeSamplesShift(UE); readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) - UE->rx_offset_diff; - writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff; + writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff; } AssertFatal(readBlockSize == @@ -936,28 +992,30 @@ void *UE_thread(void *arg) { LOG_E(PHY,"can't compensate: diff =%d\n", first_symbols); } - curMsg.proc.timestamp_tx = timestamp+ - UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX) - - firstSymSamp; + // use previous timing_advance value to compute writeTimestamp + writeTimestamp = timestamp+ + UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX) + - firstSymSamp - openair0_cfg[0].tx_sample_advance - + UE->N_TA_offset - timing_advance; + + // but use current UE->timing_advance value to compute writeBlockSize + if (UE->timing_advance != timing_advance) { + writeBlockSize -= UE->timing_advance - timing_advance; + timing_advance = UE->timing_advance; + } // Start TX slot processing here. It runs in parallel with RX slot processing - notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_tx, &curMsg.txFifo, processSlotTX); + notifiedFIFO_elt_t *newElt = newNotifiedFIFO_elt(sizeof(nr_rxtx_thread_data_t), curMsg.proc.nr_slot_tx, &txFifo, processSlotTX); nr_rxtx_thread_data_t *curMsgTx = (nr_rxtx_thread_data_t *) NotifiedFifoData(newElt); curMsgTx->proc = curMsg.proc; + curMsgTx->writeBlockSize = writeBlockSize; + curMsgTx->proc.timestamp_tx = writeTimestamp; curMsgTx->UE = UE; pushTpool(&(get_nrUE_params()->Tpool), newElt); // RX slot processing UE_processing(&curMsg); - // Wait for PUSCH processing to finish - notifiedFIFO_elt_t *res; - res = pullTpool(&curMsg.txFifo, &(get_nrUE_params()->Tpool)); - if (res == NULL) - LOG_E(PHY, "Tpool has been aborted\n"); - else - delNotifiedFIFO_elt(res); - if (curMsg.proc.decoded_frame_rx != -1) decoded_frame_rx=(((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | curMsg.proc.decoded_frame_rx); else @@ -967,59 +1025,13 @@ void *UE_thread(void *arg) { LOG_E(PHY,"Decoded frame index (%d) is not compatible with current context (%d), UE should go back to synch mode\n", decoded_frame_rx, curMsg.proc.frame_rx); - // use previous timing_advance value to compute writeTimestamp - writeTimestamp = timestamp+ - UE->frame_parms.get_samples_slot_timestamp(slot_nr,&UE->frame_parms,DURATION_RX_TO_TX - - NR_RX_NB_TH) - firstSymSamp - openair0_cfg[0].tx_sample_advance - - UE->N_TA_offset - timing_advance; - - // but use current UE->timing_advance value to compute writeBlockSize - if (UE->timing_advance != timing_advance) { - writeBlockSize -= UE->timing_advance - timing_advance; - timing_advance = UE->timing_advance; - } - - int flags = 0; - - if (openair0_cfg[0].duplex_mode == duplex_mode_TDD && !get_softmodem_params()->continuous_tx) { - - uint8_t tdd_period = mac->phy_config.config_req.tdd_table.tdd_period_in_slots; - int nrofUplinkSlots, nrofUplinkSymbols; - if (mac->scc) { - nrofUplinkSlots = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - nrofUplinkSymbols = mac->scc->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; - } - else { - nrofUplinkSlots = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSlots; - nrofUplinkSymbols = mac->scc_SIB->tdd_UL_DL_ConfigurationCommon->pattern1.nrofUplinkSymbols; - } - - int slot_tx_usrp = slot_nr + DURATION_RX_TO_TX - NR_RX_NB_TH; - uint8_t num_UL_slots = nrofUplinkSlots + (nrofUplinkSymbols != 0); - uint8_t first_tx_slot = tdd_period - num_UL_slots; - - if (slot_tx_usrp % tdd_period == first_tx_slot) - flags = 2; - else if (slot_tx_usrp % tdd_period == first_tx_slot + num_UL_slots - 1) - flags = 3; - else if (slot_tx_usrp % tdd_period > first_tx_slot) - flags = 1; - } else { - flags = 1; - } - - if (flags || IS_SOFTMODEM_RFSIM) - AssertFatal(writeBlockSize == - UE->rfdevice.trx_write_func(&UE->rfdevice, - writeTimestamp, - txp, - writeBlockSize, - UE->frame_parms.nb_antennas_tx, - flags),""); - - for (int i=0; iframe_parms.nb_antennas_tx; i++) - memset(txp[i], 0, writeBlockSize); - + // Wait for TX slot processing to finish + notifiedFIFO_elt_t *res; + res = pullTpool(&txFifo, &(get_nrUE_params()->Tpool)); + if (res == NULL) + LOG_E(PHY, "Tpool has been aborted\n"); + else + delNotifiedFIFO_elt(res); } // while !oai_exit return NULL; diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 9c2e20a6e5..2b96f1582c 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -768,8 +768,8 @@ typedef struct nr_rxtx_thread_data_s { UE_nr_rxtx_proc_t proc; PHY_VARS_NR_UE *UE; NR_UE_SCHED_MODE_t ue_sched_mode; - notifiedFIFO_t txFifo; -} nr_rxtx_thread_data_t; + int writeBlockSize; +} nr_rxtx_thread_data_t; typedef struct LDPCDecode_ue_s { PHY_VARS_NR_UE *phy_vars_ue; diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 35a965567f..e082db54fb 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -269,9 +269,7 @@ /* FFS_NR_TODO it defines ue capability which is the number of slots */ /* - between reception of pdsch and tarnsmission of its acknowlegment */ /* - between reception of un uplink grant and its related transmission */ -/* - FIXME temprarily set to 5 to avoid timing issues at OAI UE in rfsimulator */ -/* - issues caused by no rendez-vous point between TX and RX in the OAI UE */ -#define NR_UE_CAPABILITY_SLOT_RX_TO_TX (5) +#define NR_UE_CAPABILITY_SLOT_RX_TO_TX (4) #ifndef NO_RAT_NR #define DURATION_RX_TO_TX (NR_UE_CAPABILITY_SLOT_RX_TO_TX) /* for NR this will certainly depends to such UE capability which is not yet defined */ diff --git a/radio/COMMON/common_lib.h b/radio/COMMON/common_lib.h index 368e8e9ac5..3733914ef4 100644 --- a/radio/COMMON/common_lib.h +++ b/radio/COMMON/common_lib.h @@ -150,6 +150,14 @@ typedef enum { gpsdo=2 } clock_source_t; +/*! \brief Radio Tx burst flags */ +typedef enum { + Invalid = 0, + MiddleOfBurst, + StartOfBurst, + EndOfBurst +} radio_tx_flag_t; + /*! \brief Structure used for initializing UDP read threads */ typedef struct { openair0_device *device; From b3092a45fdca9d900164e7404747c7e2b6a0440d Mon Sep 17 00:00:00 2001 From: Sakthivel Velumani Date: Wed, 16 Nov 2022 09:51:04 -0500 Subject: [PATCH 3/4] Added documentation for UE_thread design --- executables/docs/nr-ue-design.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 executables/docs/nr-ue-design.md diff --git a/executables/docs/nr-ue-design.md b/executables/docs/nr-ue-design.md new file mode 100644 index 0000000000..0b0b940d5f --- /dev/null +++ b/executables/docs/nr-ue-design.md @@ -0,0 +1,22 @@ +# Multi-threading Design +The `UE_thread` function in `nr-ue.c` is the main top level thread that interacts with the radio unit. Once the thread spawns, it starts the 'Initial Syncronization'. Once its complete, the regular processing of slots commences. + +## Initial Syncronization Block +```mermaid +graph TD + A(Start) -->|UE_thread| B["readFrame
--Reads samples worth 2 frames"] + B --> |Tpool thread| C["UE_synch
--PSS & SSS detection
--PBCH decode"] + B --> |UE_thread| D["readFrame
--trash samples to unblock radio"] + C --> |Tpool thread| E[syncInFrame
--shift first sample to start of frame] + D --> |UE_thread| E +``` +## Regular Slot Processing +```mermaid +graph TD + E[syncInFrame
--shift first sample to start of frame] -->|UE_thread| F["trx_read_func (slot n)"] + F --> |Tpool thread| G["processSlotTX (slot n+4)
--PUSCH encode
--PUCCH encode
--trx_write_func"] + F --> |UE_thread| H["UE_processing (slot n)
--PDCCH decode
--PDSCH decode"] + G --> |Tpool thread| I(Merge) + H --> |UE_thread| I(Merge) + I --> |Go to next slot
UE_thread| F +``` From f47acc4955cbc6e041e1d01d88b8f05b5b786808 Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 28 Nov 2022 11:46:23 +0100 Subject: [PATCH 4/4] fix warning --- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index fd916797cc..b69c413358 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -52,6 +52,7 @@ #include "executables/softmodem-common.h" #include "executables/nr-uesoftmodem.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" +#include "openair1/SCHED_NR_UE/pucch_uci_ue_nr.h" //#define DEBUG_PHY_PROC #define NR_PDCCH_SCHED