Commit d95ac0a9 authored by thamizhselvan.k's avatar thamizhselvan.k Committed by Manish

Changes to sync oai tti with xran tti

parent 8f1db2ea
......@@ -29,6 +29,8 @@
// Declare variable useful for the send buffer function
struct xran_device_ctx *p_xran_dev_ctx_2;
volatile uint8_t first_call_set = 0;
volatile uint8_t first_rx_set = 0;
// Variable declaration useful for fill IQ samples from file
#define IQ_PLAYBACK_BUFFER_BYTES (XRAN_NUM_OF_SLOT_IN_TDD_LOOP*N_SYM_PER_SLOT*XRAN_MAX_PRBS*N_SC_PER_PRB*4L)
......@@ -36,7 +38,15 @@ int16_t *p_tx_play_buffer[MAX_ANT_CARRIER_SUPPORTED];
int iq_playback_buffer_size_dl = IQ_PLAYBACK_BUFFER_BYTES;
int32_t tx_play_buffer_size[MAX_ANT_CARRIER_SUPPORTED];
int32_t tx_play_buffer_position[MAX_ANT_CARRIER_SUPPORTED];
int rx_tti;
int rx_sym;
volatile uint32_t rx_cb_tti = 0;
volatile uint32_t rx_cb_frame = 0;
volatile uint32_t rx_cb_subframe = 0;
volatile uint32_t rx_cb_slot = 0;
#define GetFrameNum(tti,SFNatSecStart,numSubFramePerSystemFrame, numSlotPerSubFrame) ((((uint32_t)tti / ((uint32_t)numSubFramePerSystemFrame * (uint32_t)numSlotPerSubFrame)) + SFNatSecStart) & 0x3FF)
#define GetSlotNum(tti, numSlotPerSfn) ((uint32_t)tti % ((uint32_t)numSlotPerSfn))
// Declare the function useful to load IQs from file
int sys_load_file_to_buff(char *filename, char *bufname, unsigned char *pBuffer, unsigned int size, unsigned int buffers_num)
{
......@@ -91,19 +101,28 @@ int sys_load_file_to_buff(char *filename, char *bufname, unsigned char *pBuffer,
//------------------------------------------------------------------------
void xran_fh_rx_callback(void *pCallbackTag, xran_status_t status){
rte_pause();
#if 0
xran_cb_tag *callback_tag = (xran_cb_tag *)pCallbackTag;
printf(" xran_fh_RX_callback::: cellId=%d\tslotiId=%d\tsymbol=%d\n",callback_tag->cellId,callback_tag->slotiId,callback_tag->symbol);
uint32_t frame,subFrame,slot;
int32_t tti;
uint64_t second;
tti = xran_get_slot_idx(&frame,&subFrame,&slot,&second);
printf(" tti=%d\tframe=%d\tsubFrame=%d\tslot=%d\tsecond=%ld\n",tti,frame,subFrame,slot,second);
if(callback_tag->slotiId==10){
exit(0);
uint32_t tti;
uint32_t frame;
uint32_t subframe;
uint32_t slot;
tti = xran_get_slot_idx(&frame,&subframe,&slot,&second);
rx_tti = callback_tag->slotiId;
rx_sym = callback_tag->symbol;
if (rx_sym == 7) {
if (first_call_set) {
if (!first_rx_set) {
printf("first_rx is set\n");
}
first_rx_set = 1;
}
rx_cb_tti = tti;
rx_cb_frame = frame;
rx_cb_subframe = subframe;
rx_cb_slot = slot;
}
#endif
}
void xran_fh_srs_callback(void *pCallbackTag, xran_status_t status){
rte_pause();
......@@ -123,7 +142,9 @@ void xran_fh_rx_prach_callback(void *pCallbackTag, xran_status_t status){
int physide_dl_tti_call_back(void * param)
{
rte_pause();
if (!first_call_set)
printf("first_call set from phy cb first_call_set=%p\n",&first_call_set);
first_call_set = 1;
return 0;
}
......@@ -327,7 +348,7 @@ extern "C"
int register_physide_callbacks(void *xranlib_){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
xran_reg_physide_cb(xranlib->get_xranhandle(), physide_dl_tti_call_back, NULL, 10, XRAN_CB_TTI);
xran_reg_physide_cb(xranlib->get_xranhandle(), physide_dl_tti_call_back, xranlib, 1, XRAN_CB_TTI);
xran_reg_physide_cb(xranlib->get_xranhandle(), physide_ul_half_slot_call_back, NULL, 10, XRAN_CB_HALF_SLOT_RX);
xran_reg_physide_cb(xranlib->get_xranhandle(), physide_ul_full_slot_call_back, NULL, 10, XRAN_CB_FULL_SLOT_RX);
......@@ -535,7 +556,7 @@ extern "C"
struct rte_mbuf *mb;
/* calculate tti and subframe_id from frame, slot num */
int tti = 10 * (frame) + (slot);
int tti = 20 * (frame) + (slot);
uint32_t subframe = XranGetSubFrameNum(tti, 2, 10);
uint32_t is_prach_slot = xran_is_prach_slot(subframe, (slot % 2));
int sym_idx = 0;
......@@ -579,44 +600,53 @@ extern "C"
extern "C"
{
#endif
int xran_fh_rx_read_slot(void *xranlib_, ru_info_t *ru, int frame, int slot){
int xran_fh_rx_read_slot(void *xranlib_, ru_info_t *ru, int *frame, int *slot, int oframe, int oslot, uint8_t sync){
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
int tti = /*frame*SUBFRAMES_PER_SYSTEMFRAME*SLOTNUM_PER_SUBFRAME+*/10*frame+slot; //commented out temporarily to check that compilation of oran 5g is working.
//int32_t flowId;
void *ptr = NULL;
int32_t *pos = NULL;
int idx = 0;
static int print_tmp = 1;
static int print_tmp_1 = 1;
p_xran_dev_ctx_2 = xran_dev_get_ctx();
#if 0
if (p_xran_dev_ctx_2 != NULL){
printf("p_xran_dev_ctx_2=%d\n",p_xran_dev_ctx_2);
while (first_call_set != 1){
if (print_tmp) {
print_tmp = 0;
printf("wait in ru_thread() till first_call_set is set in xran\n");
}
}
#endif
int num_eaxc = xranlib->get_num_eaxc();
int num_eaxc_ul = xranlib->get_num_eaxc_ul();
uint32_t xran_max_antenna_nr = RTE_MAX(num_eaxc, num_eaxc_ul);
//uint32_t ant_el_trx = xranlib->get_num_antelmtrx();
//uint32_t xran_max_ant_array_elm_nr = RTE_MAX(ant_el_trx, xran_max_antenna_nr);
while (first_rx_set != 1){
if (print_tmp_1) {
print_tmp_1 = 0;
printf("wait in ru_thread for first_rx_set to set in xran\n");
}
}
//int32_t nSectorIndex[XRAN_MAX_SECTOR_NR];
//int32_t nSectorNum;
volatile uint32_t prev_rx_cb_tti;
int tti;
/*
for (nSectorNum = 0; nSectorNum < XRAN_MAX_SECTOR_NR; nSectorNum++)
{
nSectorIndex[nSectorNum] = nSectorNum;
prev_rx_cb_tti = rx_cb_tti;
*frame = rx_cb_frame;
*slot = (rx_cb_subframe*2)+rx_cb_slot;
tti = (*frame*20) + *slot;
while (rx_cb_tti == prev_rx_cb_tti) {
}
*/
//nSectorNum = xranlib->get_num_cc();
//int maxflowid = num_eaxc * (nSectorNum-1) + (xran_max_antenna_nr-1);
read_prach_data(ru, *frame, *slot);
p_xran_dev_ctx_2 = xran_dev_get_ctx();
int num_eaxc = xranlib->get_num_eaxc();
int num_eaxc_ul = xranlib->get_num_eaxc_ul();
uint32_t xran_max_antenna_nr = RTE_MAX(num_eaxc, num_eaxc_ul);
int slot_offset_rxdata = 3&(*slot);
uint32_t slot_size = 4*14*4096;
uint8_t *rx_data = (uint8_t *)ru->rxdataF[0];
uint8_t *start_ptr = NULL;
start_ptr = rx_data + (slot_size*slot_offset_rxdata);
for(uint16_t cc_id=0; cc_id<1/*nSectorNum*/; cc_id++){ // OAI does not support multiple CC yet.
for(uint8_t ant_id = 0; ant_id < xran_max_antenna_nr && ant_id<ru->nb_rx; ant_id++){
// This loop would better be more inner to avoid confusion and maybe also errors.
......@@ -627,7 +657,7 @@ int xran_fh_rx_read_slot(void *xranlib_, ru_info_t *ru, int frame, int slot){
uint8_t *pPrbMapData = p_xran_dev_ctx_2->sFrontHaulRxPrbMapBbuIoBufCtrl[tti % XRAN_N_FE_BUF_LEN][cc_id][ant_id].sBufferList.pBuffers->pData;
struct xran_prb_map *pPrbMap = (struct xran_prb_map *)pPrbMapData;
ptr = pData;
pos = &ru->rxdataF[ant_id][sym_idx * 4096 /*fp->ofdm_symbol_size*/]; // We had to use a different ru structure than benetel so the access to the buffer is not the same.
pos = (int32_t *)(start_ptr + (4*sym_idx*4096));
uint8_t *u8dptr;
struct xran_prb_map *pRbMap = pPrbMap;
......@@ -673,11 +703,9 @@ int xran_fh_rx_read_slot(void *xranlib_, ru_info_t *ru, int frame, int slot){
dst1 = (uint8_t *)(pos + p_prbMapElm->nRBStart*N_SC_PER_PRB);
// second half
dst2 = (uint8_t *)(pos + (p_prbMapElm->nRBStart*N_SC_PER_PRB + 3276/2) + 4096 - 3276);
//printf("RRR: idxElm=%d\tcompMethod=%d\tiqWidth=%d\n",idxElm,p_prbMapElm->compMethod,p_prbMapElm->iqWidth);
if(p_prbMapElm->compMethod == XRAN_COMPMETHOD_NONE) {
payload_len = p_prbMapElm->nRBSize*N_SC_PER_PRB*4L;
src1 = src2 + payload_len/2;
/*Convert Network Order to Host order*/
for (idx = 0; idx < payload_len/(2*sizeof(int16_t)); idx++) {
((uint16_t *)dst1)[idx] = ntohs(((uint16_t *)src1)[idx]);
((uint16_t *)dst2)[idx] = ntohs(((uint16_t *)src2)[idx]);
......@@ -735,6 +763,8 @@ int xran_fh_rx_read_slot(void *xranlib_, ru_info_t *ru, int frame, int slot){
}
}
}
return(0);
}
......@@ -750,7 +780,7 @@ int xran_fh_tx_send_slot(void *xranlib_, ru_info_t *ru, int frame, int slot, uin
xranLibWraper *xranlib = ((xranLibWraper *) xranlib_);
int tti = /*frame*SUBFRAMES_PER_SYSTEMFRAME*SLOTNUM_PER_SUBFRAME+*/10*frame+slot; //commented out temporarily to check that compilation of oran 5g is working.
int tti = /*frame*SUBFRAMES_PER_SYSTEMFRAME*SLOTNUM_PER_SUBFRAME+*/20*frame+slot; //commented out temporarily to check that compilation of oran 5g is working.
//int32_t flowId;
void *ptr = NULL;
......@@ -767,12 +797,6 @@ int xran_fh_tx_send_slot(void *xranlib_, ru_info_t *ru, int frame, int slot, uin
int num_eaxc = xranlib->get_num_eaxc();
int num_eaxc_ul = xranlib->get_num_eaxc_ul();
uint32_t xran_max_antenna_nr = RTE_MAX(num_eaxc, num_eaxc_ul);
//uint32_t ant_el_trx = xranlib->get_num_antelmtrx();
//uint32_t xran_max_ant_array_elm_nr = RTE_MAX(ant_el_trx, xran_max_antenna_nr);
//int32_t nSectorIndex[XRAN_MAX_SECTOR_NR];
//int32_t nSectorNum;
/*
for (nSectorNum = 0; nSectorNum < XRAN_MAX_SECTOR_NR; nSectorNum++)
{
......
......@@ -282,6 +282,7 @@ void oran_fh_if4p5_south_in(RU_t *ru,
int symbol;
int32_t *rxdata;
int antenna;
static uint8_t sync = 0;
//printf("XXX ORAN_fh_if4p5_south_in %d %d\n", *frame, *slot);
......@@ -290,9 +291,11 @@ void oran_fh_if4p5_south_in(RU_t *ru,
ru_info.rxdataF = ru->common.rxdataF;
ru_info.prach_buf = (int *)ru->prach_rxsigF[0][0];//index: [prach_oca][ant_id]
read_prach_data(&ru_info, *frame, *slot);
RU_proc_t *proc = &ru->proc;
extern uint16_t sl_ahead;
int f, sl;
int ret = xran_fh_rx_read_slot(s->oran_priv, &ru_info, *frame, *slot);
int ret = xran_fh_rx_read_slot(s->oran_priv, &ru_info, &f, &sl, *frame, *slot, sync);
if (ret != 0){
printf("ORAN: ORAN_fh_if4p5_south_in ERROR in RX function \n");
......@@ -344,25 +347,30 @@ next:
}
}
#endif
RU_proc_t *proc = &ru->proc;
extern uint16_t sl_ahead;
int f = *frame;
int sl = *slot;
//calculate timestamp_rx, timestamp_tx based on frame and slot
proc->tti_rx = sl;
proc->frame_rx = f;
/* TODO: be sure of samples_per_slot0
FK: should use get_samples_per_slot(slot)
but for mu=1 its ok
*/
proc->timestamp_rx = ((proc->frame_rx * 20) + proc->tti_rx ) * fp->samples_per_slot0;
if (get_nprocs()<=4) {
// why? what if there are more?
proc->tti_tx = (sl+sl_ahead)%20;
proc->frame_tx = (sl>(19-sl_ahead)) ? (f+1)&1023 : f;
if (proc->first_rx == 0) {
if (proc->tti_rx != *slot) {
LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->tti_rx %d, slot %d)\n",proc->tti_rx,*slot);
//exit_fun("Exiting");
}
if (proc->frame_rx != *frame) {
LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->frame_rx %d frame %d proc->tti_rx %d tti %d)\n",proc->frame_rx,*frame,proc->tti_rx,*slot);
//exit_fun("Exiting");
}
} else {
proc->first_rx = 0;
LOG_I(PHY, "before adjusting, OAI: frame=%d slot=%d, XRAN: frame=%d slot=%d\n",*frame,*slot,proc->frame_rx,proc->tti_rx);
*frame = proc->frame_rx;
*slot = proc->tti_rx;
LOG_I(PHY, "After adjusting, OAI: frame=%d slot=%d, XRAN: frame=%d slot=%d\n",*frame,*slot,proc->frame_rx,proc->tti_rx);
}
sync = 1;
#if 0
printf("south_in:\ttimestamp_rx=%d{frame_rx=%d,tti_rx=%d}\ttti_tx=%d\tframe_tx=%d\n\n",proc->timestamp_rx,proc->frame_rx,proc->tti_rx,proc->tti_tx,proc->frame_tx);
if(proc->frame_rx ==20){
......
......@@ -45,6 +45,9 @@ typedef struct ru_info_s{
// Needed for Prach
int *prach_buf;
// previous slot number
int slot_prev;
} ru_info_t;
#ifdef __cplusplus
......@@ -161,7 +164,7 @@ int load_iq_from_file(void *xranlib_);
extern "C"
{
#endif
int xran_fh_rx_read_slot(void *xranlib_, ru_info_t *ru, int frame, int slot);
int xran_fh_rx_read_slot(void *xranlib_, ru_info_t *ru, int *frame, int *slot, int oframe, int oslot, uint8_t sync);
#ifdef __cplusplus
}
#endif
......
......@@ -1155,6 +1155,38 @@ void * xranLibWraper::get_timer_ctx() { return((void *)&m_timer_ctx[0]); }
//------------------------------------------------------------------------------------------------------------------------------------------------
int xranLibWraper::get_symbol_index() { return (xran_lib_ota_sym); }
int xranLibWraper::get_ota_tti() { return (xran_lib_ota_tti); }
int xranLibWraper::get_symbol_offset(int32_t offSym, int32_t otaSym, int32_t numSymTotal, enum xran_in_period* pInPeriod)
{
int32_t sym;
// Suppose the offset is usually small
if (unlikely(offSym > otaSym))
{
sym = numSymTotal - offSym + otaSym;
*pInPeriod = XRAN_IN_PREV_PERIOD;
}
else
{
sym = otaSym - offSym;
if (unlikely(sym >= numSymTotal))
{
sym -= numSymTotal;
*pInPeriod = XRAN_IN_NEXT_PERIOD;
}
else
{
*pInPeriod = XRAN_IN_CURR_PERIOD;
}
}
return sym;
}
int xranLibWraper::get_SFN_at_sec_start() { return (xran_SFN_at_Sec_Start); }
//------------------------------------------------------------------------------------------------------------------------------------------------
bool xranLibWraper::is_running() { return((xran_get_if_state() == XRAN_RUNNING)?true:false); }
......
......@@ -40,11 +40,18 @@
#define MAX_ANT_CARRIER_SUPPORTED (XRAN_MAX_SECTOR_NR*XRAN_MAX_ANTENNA_NR)
enum xran_in_period
{
XRAN_IN_PREV_PERIOD = 0,
XRAN_IN_CURR_PERIOD,
XRAN_IN_NEXT_PERIOD
};
extern "C"
{
extern uint32_t xran_lib_ota_tti;
extern uint32_t xran_lib_ota_sym;
extern uint32_t xran_lib_ota_sym_idx;
extern uint32_t xran_SFN_at_Sec_Start;
void sym_ota_cb(struct rte_timer *tim, void *arg);
void tti_ota_cb(struct rte_timer *tim, void *arg);
......@@ -225,6 +232,12 @@ public:
int get_symbol_index();
int get_ota_tti();
int get_SFN_at_sec_start();
int get_symbol_offset(int32_t offSym, int32_t otaSym, int32_t numSymTotal, enum xran_in_period* pInPeriod);
bool is_running();
enum xran_category get_rucategory();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment