Commit 4afeaaf2 authored by Raymond Knopp's avatar Raymond Knopp

Merge branch 'ru_rau_enhancement' of...

Merge branch 'ru_rau_enhancement' of https://gitlab.eurecom.fr/oai/openairinterface5g into ru_rau_enhancement
parents 570ac353 e57ecfb7
...@@ -327,8 +327,7 @@ static int trx_usrp_start(openair0_device *device) { ...@@ -327,8 +327,7 @@ static int trx_usrp_start(openair0_device *device) {
s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0x7f); s->usrp->set_gpio_attr("FP0", "CTRL", 0x7f,0x7f);
//set ATR register //set ATR register
s->usrp->set_gpio_attr("FP0", "ATR_RX", 1<<4, 0x7f); s->usrp->set_gpio_attr("FP0", "ATR_RX", (1<<4)|(1<<6), 0x7f);
s->usrp->set_gpio_attr("FP0", "ATR_RX", 1<<6, 0x7f);
// init recv and send streaming // init recv and send streaming
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
...@@ -341,7 +340,7 @@ static int trx_usrp_start(openair0_device *device) { ...@@ -341,7 +340,7 @@ static int trx_usrp_start(openair0_device *device) {
} }
else { else {
s->wait_for_first_pps = 0; s->wait_for_first_pps = 0;
cmd.time_spec = s->usrp->get_time_now() + uhd::time_spec_t(0.05); cmd.time_spec = s->usrp->get_time_now() + uhd::time_spec_t(0.005);
} }
cmd.stream_now = false; // start at constant delay cmd.stream_now = false; // start at constant delay
......
...@@ -662,6 +662,9 @@ void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { ...@@ -662,6 +662,9 @@ void fh_if5_north_asynch_in(RU_t *ru,int *frame,int *subframe) {
subframe_tx = (timestamp_tx/fp->samples_per_tti)%10; subframe_tx = (timestamp_tx/fp->samples_per_tti)%10;
frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023; frame_tx = (timestamp_tx/(fp->samples_per_tti*10))&1023;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx );
if (proc->first_tx != 0) { if (proc->first_tx != 0) {
*subframe = subframe_tx; *subframe = subframe_tx;
*frame = frame_tx; *frame = frame_tx;
...@@ -734,7 +737,9 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) { ...@@ -734,7 +737,9 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *subframe) {
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, subframe_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, subframe_tx );
} }
if (ru->feptx_ofdm) ru->feptx_ofdm(ru); if (ru->feptx_ofdm) ru->feptx_ofdm(ru);
if (ru->fh_south_out) ru->fh_south_out(ru); if (ru->fh_south_out) ru->fh_south_out(ru);
} }
...@@ -823,10 +828,11 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { ...@@ -823,10 +828,11 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
// synchronize first reception to frame 0 subframe 0 // synchronize first reception to frame 0 subframe 0
if (ru->fh_north_asynch_in == NULL) {
proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti); proc->timestamp_tx = proc->timestamp_rx+(sf_ahead*fp->samples_per_tti);
proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10; proc->subframe_tx = (proc->subframe_rx+sf_ahead)%10;
proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx; proc->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (proc->frame_rx+1)&1023 : proc->frame_rx;
}
LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, subframe %d\n", LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, subframe %d\n",
ru->idx, ru->idx,
0, 0,
...@@ -837,9 +843,11 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { ...@@ -837,9 +843,11 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
if (ru == RC.ru[0]) { if (ru == RC.ru[0]) {
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, proc->frame_rx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, proc->frame_rx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_RU, proc->subframe_rx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_RU, proc->subframe_rx );
if (ru->fh_north_asynch_in == NULL) {
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx );
} }
}
if (proc->first_rx == 0) { if (proc->first_rx == 0) {
if (proc->subframe_rx != *subframe){ if (proc->subframe_rx != *subframe){
...@@ -961,11 +969,11 @@ static void* ru_thread_asynch_rxtx( void* param ) { ...@@ -961,11 +969,11 @@ static void* ru_thread_asynch_rxtx( void* param ) {
wait_sync("ru_thread_asynch_rxtx"); wait_sync("ru_thread_asynch_rxtx");
// wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe
printf( "waiting for devices (ru_thread_asynch_rx)\n"); LOG_I(PHY, "waiting for devices (ru_thread_asynch_rxtx)\n");
wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch"); wait_on_condition(&proc->mutex_asynch_rxtx,&proc->cond_asynch_rxtx,&proc->instance_cnt_asynch_rxtx,"thread_asynch");
printf( "devices ok (ru_thread_asynch_rx)\n"); LOG_I(PHY, "devices ok (ru_thread_asynch_rxtx)\n");
while (!oai_exit) { while (!oai_exit) {
...@@ -1176,6 +1184,7 @@ void do_ru_synch(RU_t *ru) { ...@@ -1176,6 +1184,7 @@ void do_ru_synch(RU_t *ru) {
int32_t dummy_rx[ru->nb_rx][fp->samples_per_tti] __attribute__((aligned(32))); int32_t dummy_rx[ru->nb_rx][fp->samples_per_tti] __attribute__((aligned(32)));
int rxs; int rxs;
int ic; int ic;
RRU_CONFIG_msg_t rru_config_msg;
// initialize the synchronization buffer to the common_vars.rxdata // initialize the synchronization buffer to the common_vars.rxdata
for (int i=0;i<ru->nb_rx;i++) for (int i=0;i<ru->nb_rx;i++)
...@@ -1236,6 +1245,14 @@ void do_ru_synch(RU_t *ru) { ...@@ -1236,6 +1245,14 @@ void do_ru_synch(RU_t *ru) {
ru->rfdevice.trx_set_freq_func(&ru->rfdevice,ru->rfdevice.openair0_cfg,0); ru->rfdevice.trx_set_freq_func(&ru->rfdevice,ru->rfdevice.openair0_cfg,0);
*/ */
ru->state = RU_RUN;
// Send RRU_sync_ok
rru_config_msg.type = RRU_sync_ok;
rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len
LOG_I(PHY,"Sending RRU_sync_ok to RAU\n", ru->idx);
AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU %d\n",ru->idx);
LOG_I(PHY,"Exiting synch routine\n"); LOG_I(PHY,"Exiting synch routine\n");
} }
...@@ -1779,6 +1796,8 @@ static void* ru_thread( void* param ) { ...@@ -1779,6 +1796,8 @@ static void* ru_thread( void* param ) {
int ret; int ret;
int subframe =9; int subframe =9;
int frame =1023; int frame =1023;
struct timespec time_rf;
long old_time;
// set default return value // set default return value
ru_thread_status = 0; ru_thread_status = 0;
...@@ -1801,6 +1820,7 @@ static void* ru_thread( void* param ) { ...@@ -1801,6 +1820,7 @@ static void* ru_thread( void* param ) {
if (ru->is_slave == 0) AssertFatal(ru->state == RU_RUN,"ru-%d state = %s != RU_RUN\n",ru->idx,ru_states[ru->state]); if (ru->is_slave == 0) AssertFatal(ru->state == RU_RUN,"ru-%d state = %s != RU_RUN\n",ru->idx,ru_states[ru->state]);
else if (ru->is_slave == 1) AssertFatal(ru->state == RU_SYNC || ru->state == RU_RUN,"ru %d state = %s != RU_SYNC or RU_RUN\n",ru->idx,ru_states[ru->state]); else if (ru->is_slave == 1) AssertFatal(ru->state == RU_SYNC || ru->state == RU_RUN,"ru %d state = %s != RU_SYNC or RU_RUN\n",ru->idx,ru_states[ru->state]);
// Start RF device if any // Start RF device if any
clock_gettime(CLOCK_MONOTONIC,&time_rf);
if (ru->start_rf) { if (ru->start_rf) {
if (ru->start_rf(ru) != 0) if (ru->start_rf(ru) != 0)
LOG_E(HW,"Could not start the RF device\n"); LOG_E(HW,"Could not start the RF device\n");
...@@ -1853,6 +1873,11 @@ static void* ru_thread( void* param ) { ...@@ -1853,6 +1873,11 @@ static void* ru_thread( void* param ) {
LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); LOG_I(PHY,"RU %d rf device stopped\n",ru->idx);
break; break;
} }
old_time = time_rf.tv_nsec;
clock_gettime(CLOCK_MONOTONIC,&time_rf);
//if ((time_rf.tv_nsec > old_time + 1200000) || (time_rf.tv_nsec < old_time + 500000))
// LOG_I(PHY,"RU thread %d, frame %d (%p), subframe %d : RF time difference : %lu\n",
// ru->idx, frame,&frame,subframe,time_rf.tv_nsec - old_time);
if (ru->fh_south_in && ru->state == RU_RUN ) ru->fh_south_in(ru,&frame,&subframe); if (ru->fh_south_in && ru->state == RU_RUN ) ru->fh_south_in(ru,&frame,&subframe);
else AssertFatal(1==0, "No fronthaul interface at south port"); else AssertFatal(1==0, "No fronthaul interface at south port");
...@@ -1935,7 +1960,6 @@ void *ru_thread_synch(void *arg) { ...@@ -1935,7 +1960,6 @@ void *ru_thread_synch(void *arg) {
uint32_t sync_corr[307200] __attribute__((aligned(32))); uint32_t sync_corr[307200] __attribute__((aligned(32)));
static int ru_thread_synch_status=0; static int ru_thread_synch_status=0;
int cnt=0; int cnt=0;
RRU_CONFIG_msg_t rru_config_msg;
thread_top_init("ru_thread_synch",0,5000000,10000000,10000000); thread_top_init("ru_thread_synch",0,5000000,10000000,10000000);
...@@ -1996,13 +2020,6 @@ void *ru_thread_synch(void *arg) { ...@@ -1996,13 +2020,6 @@ void *ru_thread_synch(void *arg) {
} }
*/ */
ru->in_synch = 1; ru->in_synch = 1;
ru->state = RU_RUN;
// Send RRU_sync_ok
rru_config_msg.type = RRU_sync_ok;
rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len
LOG_I(PHY,"Sending RRU_sync_ok to RAU\n", ru->idx);
AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU %d\n",ru->idx);
} // symc_pos > 0 } // symc_pos > 0
else { else {
......
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