From 1924b3c79392eb6f61fbe654025b1e5c6972bc3a Mon Sep 17 00:00:00 2001 From: vijay chadachan Date: Tue, 23 Apr 2024 10:44:00 +0200 Subject: [PATCH] Fix for the overflow issue while processing GPS based timestamp from RU The absslot_tx overflow issue observed during integration testing of AW2S RU with GPS as the source for the clock synchronization. Causes the gNB not to start the TX thread and stops the processing. --- executables/nr-gnb.c | 10 +++++----- executables/nr-ru.c | 6 +++--- executables/rt_profiling.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index 1fa3478d75..9df218fe1b 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -115,10 +115,10 @@ static void tx_func(void *param) int slot_tx = info->slot; int frame_rx = info->frame_rx; int slot_rx = info->slot_rx; - int absslot_tx = info->timestamp_tx / info->gNB->frame_parms.get_samples_per_slot(slot_tx, &info->gNB->frame_parms); - int absslot_rx = absslot_tx - info->gNB->RU_list[0]->sl_ahead; + int64_t absslot_tx = info->timestamp_tx / info->gNB->frame_parms.get_samples_per_slot(slot_tx, &info->gNB->frame_parms); + int64_t absslot_rx = absslot_tx - info->gNB->RU_list[0]->sl_ahead; if (absslot_rx < 0) { - LOG_W(NR_PHY, "Slot ahead %d is larger than absslot_tx %d. Cannot start TX yet.\n", info->gNB->RU_list[0]->sl_ahead, absslot_tx); + LOG_W(NR_PHY, "Slot ahead %d is larger than absslot_tx %ld. Cannot start TX yet.\n", info->gNB->RU_list[0]->sl_ahead, absslot_tx); return; } LOG_D(NR_PHY, "%d.%d running tx_func\n", frame_tx, slot_tx); @@ -218,8 +218,8 @@ void rx_func(void *param) for (; i < gNB->frame_parms.slots_per_subframe / 2; i++) cumul_samples += gNB->frame_parms.get_samples_per_slot(i, &gNB->frame_parms); int samples = cumul_samples / i; - int absslot_tx = info->timestamp_tx / samples; - int absslot_rx = absslot_tx - gNB->RU_list[0]->sl_ahead; + int64_t absslot_tx = info->timestamp_tx / samples; + int64_t absslot_rx = absslot_tx - gNB->RU_list[0]->sl_ahead; int rt_prof_idx = absslot_rx % RT_PROF_DEPTH; clock_gettime(CLOCK_MONOTONIC,&info->gNB->rt_L1_profiling.start_L1_RX[rt_prof_idx]); start_meas(&softmodem_stats_rxtx_sf); diff --git a/executables/nr-ru.c b/executables/nr-ru.c index 96c9e55e75..aa6e658bac 100644 --- a/executables/nr-ru.c +++ b/executables/nr-ru.c @@ -1108,8 +1108,8 @@ void ru_tx_func(void *param) { for (; i < fp->slots_per_subframe / 2; i++) cumul_samples += fp->get_samples_per_slot(i, fp); int samples = cumul_samples / i; - int absslot_tx = info->timestamp_tx / samples; - int absslot_rx = absslot_tx - ru->sl_ahead; + int64_t absslot_tx = info->timestamp_tx / samples; + int64_t absslot_rx = absslot_tx - ru->sl_ahead; int rt_prof_idx = absslot_rx % RT_PROF_DEPTH; clock_gettime(CLOCK_MONOTONIC,&ru->rt_ru_profiling.start_RU_TX[rt_prof_idx]); // do TX front-end processing if needed (precoding and/or IDFTs) @@ -1335,7 +1335,7 @@ void *ru_thread( void *param ) { proc->timestamp_tx += fp->get_samples_per_slot(i % fp->slots_per_frame, fp); proc->tti_tx = (proc->tti_rx + ru->sl_ahead) % fp->slots_per_frame; proc->frame_tx = proc->tti_rx > proc->tti_tx ? (proc->frame_rx + 1) & 1023 : proc->frame_rx; - int absslot_rx = proc->timestamp_rx/fp->get_samples_per_slot(proc->tti_rx,fp); + int64_t absslot_rx = proc->timestamp_rx/fp->get_samples_per_slot(proc->tti_rx,fp); int rt_prof_idx = absslot_rx % RT_PROF_DEPTH; clock_gettime(CLOCK_MONOTONIC,&ru->rt_ru_profiling.return_RU_south_in[rt_prof_idx]); LOG_D(PHY,"AFTER fh_south_in - SFN/SL:%d%d RU->proc[RX:%d.%d TX:%d.%d] RC.gNB[0]:[RX:%d%d TX(SFN):%d]\n", diff --git a/executables/rt_profiling.h b/executables/rt_profiling.h index 03dcf94517..9b72a7091f 100644 --- a/executables/rt_profiling.h +++ b/executables/rt_profiling.h @@ -40,7 +40,7 @@ extern "C" // depth of trace in slots #define RT_PROF_DEPTH 100 typedef struct { - int absslot_rx[RT_PROF_DEPTH]; + int64_t absslot_rx[RT_PROF_DEPTH]; struct timespec return_RU_south_in[RT_PROF_DEPTH]; struct timespec return_RU_feprx[RT_PROF_DEPTH]; struct timespec return_RU_prachrx[RT_PROF_DEPTH]; @@ -50,7 +50,7 @@ typedef struct { } rt_ru_profiling_t; typedef struct { - int absslot_ux[RT_PROF_DEPTH]; + int64_t absslot_ux[RT_PROF_DEPTH]; struct timespec start_L1_RX[RT_PROF_DEPTH]; struct timespec return_L1_RX[RT_PROF_DEPTH]; struct timespec start_L1_TX[RT_PROF_DEPTH];