From 5acb37c3e2e53ea6a45cf127bc6350558af4269f Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Thu, 20 Feb 2025 12:39:25 +0100 Subject: [PATCH] Handle changing N_TA_offset correctly Handle N_TA_offset update the same way timing advance changes are handled: modify writeBlockSize to ensure continuous transmission. Also address possible data races by making sure the new timing_advance/N_TA_offset is only read once from global memory. --- executables/nr-ue.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index a5c4f69ed5..e08569e999 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -867,6 +867,7 @@ void *UE_thread(void *arg) initNotifiedFIFO_nothreadSafe(&freeBlocks); int timing_advance = UE->timing_advance; + int N_TA_offset = UE->N_TA_offset; NR_UE_MAC_INST_t *mac = get_mac_inst(UE->Mod_id); bool syncRunning = false; @@ -1089,13 +1090,19 @@ void *UE_thread(void *arg) // use previous timing_advance value to compute writeTimestamp const openair0_timestamp writeTimestamp = rx_timestamp + fp->get_samples_slot_timestamp(slot_nr, fp, duration_rx_to_tx) - - firstSymSamp - UE->N_TA_offset - timing_advance; + - firstSymSamp - N_TA_offset - timing_advance; // but use current UE->timing_advance value to compute writeBlockSize int writeBlockSize = fp->get_samples_per_slot((slot_nr + duration_rx_to_tx) % nb_slot_frame, fp) - iq_shift_to_apply; - if (UE->timing_advance != timing_advance) { - writeBlockSize -= UE->timing_advance - timing_advance; - timing_advance = UE->timing_advance; + int new_timing_advance = UE->timing_advance; + if (new_timing_advance != timing_advance) { + writeBlockSize -= new_timing_advance- timing_advance; + timing_advance = new_timing_advance; + } + int new_N_TA_offset = UE->N_TA_offset; + if (new_N_TA_offset != N_TA_offset) { + writeBlockSize -= new_N_TA_offset - N_TA_offset; + N_TA_offset = new_N_TA_offset; } if (curMsg.proc.nr_slot_tx == 0)