Compare commits

...

1 Commits

Author SHA1 Message Date
Xin Zhe Khooi
3d2b69ec7a fhi72: introduce xran faststart 2025-08-12 18:21:50 +08:00
3 changed files with 87 additions and 2 deletions

View File

@@ -0,0 +1,82 @@
diff --git a/fhi_lib/lib/src/xran_common.c b/fhi_lib/lib/src/xran_common.c
index 5968d01..3eaab2b 100644
--- a/fhi_lib/lib/src/xran_common.c
+++ b/fhi_lib/lib/src/xran_common.c
@@ -52,7 +52,7 @@
#include "xran_printf.h"
#include "xran_mlog_lnx.h"
-static struct timespec sleeptime = {.tv_nsec = 1E3 }; /* 1 us */
+static struct timespec sleeptime = {.tv_nsec = 2E3 };
extern int32_t first_call;
diff --git a/fhi_lib/lib/src/xran_main.c b/fhi_lib/lib/src/xran_main.c
index 216c7f5..8fb32c0 100644
--- a/fhi_lib/lib/src/xran_main.c
+++ b/fhi_lib/lib/src/xran_main.c
@@ -490,6 +490,17 @@ tti_ota_cb(struct rte_timer *tim, void *arg)
MLogTask(PID_TTI_TIMER, t1, MLogTick());
+ static int s_first_call = 0;
+ if (s_first_call == 0) {
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ const uint32_t usecs = ts.tv_nsec / 1000;
+ for(int i=0; i<XRAN_PORTS_NUM; i++) {
+ xran_lib_ota_tti[i] = ((usecs / 500) + 1) - 1; // set good initial values by pretending to be the previous TTI
+ }
+ }
+ s_first_call = 1;
+
if(p_xran_dev_ctx->xran_port_id == 0){
/* To match TTbox */
if(xran_lib_ota_tti[0] == 0)
@@ -1425,7 +1436,7 @@ tti_to_phy_cb(struct rte_timer *tim, void *arg)
uint32_t slot_id = XranGetSlotNum(tti, SLOTNUM_PER_SUBFRAME(interval));
uint32_t subframe_id = XranGetSubFrameNum(tti,SLOTNUM_PER_SUBFRAME(interval), SUBFRAMES_PER_SYSTEMFRAME);
uint32_t frame_id = XranGetFrameNum(tti,xran_getSfnSecStart(),SUBFRAMES_PER_SYSTEMFRAME, SLOTNUM_PER_SUBFRAME(interval));
- if((frame_id == xran_max_frame)&&(subframe_id==9)&&(slot_id == SLOTNUM_PER_SUBFRAME(interval)-1)) { //(tti == xran_fs_get_max_slot()-1)
+ if((subframe_id==9)&&(slot_id == SLOTNUM_PER_SUBFRAME(interval)-1)) {
first_call = 1;
}
}
diff --git a/fhi_lib/lib/src/xran_timer.c b/fhi_lib/lib/src/xran_timer.c
index 55182d8..429b224 100644
--- a/fhi_lib/lib/src/xran_timer.c
+++ b/fhi_lib/lib/src/xran_timer.c
@@ -62,7 +62,7 @@ static struct timespec* p_last_time = &last_time;
static struct timespec* p_temp_time;
-static struct timespec sleeptime = {.tv_nsec = 1E3 }; /* 1 us */
+static struct timespec sleeptime = {.tv_nsec = 2E3 }; /* 1 us */
volatile static unsigned long current_second = 0;
static unsigned long started_second = 0;
@@ -194,11 +194,24 @@ long poll_next_tick(long interval_ns, unsigned long *used_tick)
int i;
if(counter == 0) {
+ while(true) {
+ struct timespec ts;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ const uint32_t usecs = ts.tv_nsec / 1000;
+ if(usecs % 1000 == 0) {
+ sym_cnt = 0;
+ sym_acc = (usecs / 500) * 14 * (fine_tuning[1][0] + fine_tuning[1][1]) / 2;
+ xran_lib_ota_sym[0] = 0;
+ xran_lib_ota_sym_idx[0] = (usecs / 500) * 14;
+ break;
+ }
+ }
clock_gettime(CLOCK_REALTIME, p_last_time);
last_tick = MLogTick();
if(unlikely(p_xran_dev_ctx->offset_sec || p_xran_dev_ctx->offset_nsec))
timing_adjust_gps_second(p_last_time);
current_second = p_last_time->tv_sec;
+ xran_updateSfnSecStart();
counter = 1;
}

View File

@@ -98,6 +98,7 @@ pthread_mutex_t sync_mutex;
int sync_var=-1; //!< protected by mutex \ref sync_mutex.
int config_sync_var=-1;
int oai_exit = 0;
int is_l1_ready = 0;
unsigned int mmapped_dma=0;
@@ -750,7 +751,7 @@ int main( int argc, char **argv ) {
if (NFAPI_MODE != NFAPI_MODE_PNF && NFAPI_MODE != NFAPI_MODE_VNF && NFAPI_MODE != NFAPI_MODE_AERIAL) {
init_eNB_afterRU();
}
}
// connect the TX/RX buffers
pthread_mutex_lock(&sync_mutex);
@@ -758,6 +759,7 @@ int main( int argc, char **argv ) {
pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex);
}
is_l1_ready = 1;
// wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n");

View File

@@ -50,6 +50,7 @@
// Declare variable useful for the send buffer function
volatile bool first_call_set = false;
extern int is_l1_ready;
int xran_is_prach_slot(uint8_t PortId, uint32_t subframe_id, uint32_t slot_id);
#include "common/utils/LOG/log.h"
@@ -114,7 +115,7 @@ void oai_xran_fh_rx_callback(void *pCallbackTag, xran_status_t status)
// if xran did not call xran_physide_dl_tti callback, it's not ready yet.
// wait till first callback to advance counters, because otherwise users
// would see periodic output with only "0" in stats counters
if (!first_call_set)
if (!first_call_set || !is_l1_ready)
return;
uint32_t slot2 = slot + (subframe * slots_in_sf);
rx_RU[ru_id][slot2] = 1;