adding emulate-rf feature in nr
This commit is contained in:
+99
-39
@@ -151,6 +151,9 @@ int connect_rau(RU_t *ru);
|
|||||||
|
|
||||||
extern uint16_t sf_ahead;
|
extern uint16_t sf_ahead;
|
||||||
|
|
||||||
|
extern int emulate_rf;
|
||||||
|
extern int numerology;
|
||||||
|
|
||||||
/*************************************************************/
|
/*************************************************************/
|
||||||
/* Functions to attach and configure RRU */
|
/* Functions to attach and configure RRU */
|
||||||
|
|
||||||
@@ -686,6 +689,34 @@ void fh_if4p5_north_out(RU_t *ru) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void* emulatedRF_thread(void* param) {
|
||||||
|
RU_proc_t *proc = (RU_proc_t *) param;
|
||||||
|
int microsec = 500; // length of time to sleep, in miliseconds
|
||||||
|
struct timespec req = {0};
|
||||||
|
req.tv_sec = 0;
|
||||||
|
req.tv_nsec = (numerology>0)? ((microsec * 1000L)/numerology):(microsec * 1000L)*2;
|
||||||
|
cpu_set_t cpuset;
|
||||||
|
CPU_SET(1,&cpuset);
|
||||||
|
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||||
|
|
||||||
|
int policy;
|
||||||
|
struct sched_param sparam;
|
||||||
|
memset(&sparam, 0, sizeof(sparam));
|
||||||
|
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||||
|
policy = SCHED_FIFO ;
|
||||||
|
pthread_setschedparam(pthread_self(), policy, &sparam);
|
||||||
|
|
||||||
|
wait_sync("emulatedRF_thread");
|
||||||
|
while(!oai_exit){
|
||||||
|
nanosleep(&req, (struct timespec *)NULL);
|
||||||
|
pthread_mutex_lock(&proc->mutex_emulateRF);
|
||||||
|
++proc->instance_cnt_emulateRF;
|
||||||
|
pthread_mutex_unlock(&proc->mutex_emulateRF);
|
||||||
|
pthread_cond_signal(&proc->cond_emulateRF);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void rx_rf(RU_t *ru,int *frame,int *subframe) {
|
void rx_rf(RU_t *ru,int *frame,int *subframe) {
|
||||||
|
|
||||||
RU_proc_t *proc = &ru->proc;
|
RU_proc_t *proc = &ru->proc;
|
||||||
@@ -702,11 +733,18 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
|
|||||||
|
|
||||||
old_ts = proc->timestamp_rx;
|
old_ts = proc->timestamp_rx;
|
||||||
|
|
||||||
rxs = ru->rfdevice.trx_read_func(&ru->rfdevice,
|
if(emulate_rf){
|
||||||
|
wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread");
|
||||||
|
release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread");
|
||||||
|
rxs = fp->samples_per_tti;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
rxs = ru->rfdevice.trx_read_func(&ru->rfdevice,
|
||||||
&ts,
|
&ts,
|
||||||
rxp,
|
rxp,
|
||||||
fp->samples_per_subframe,
|
fp->samples_per_subframe,
|
||||||
ru->nb_rx);
|
ru->nb_rx);
|
||||||
|
}
|
||||||
|
|
||||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 );
|
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 );
|
||||||
|
|
||||||
@@ -1377,26 +1415,37 @@ static void* ru_thread( void* param ) {
|
|||||||
|
|
||||||
LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]);
|
LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,NB_functions[ru->function],NB_timing[ru->if_timing]);
|
||||||
|
|
||||||
|
if(emulate_rf){
|
||||||
// Start IF device if any
|
|
||||||
if (ru->start_if) {
|
|
||||||
LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx);
|
|
||||||
AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n");
|
|
||||||
if (ru->if_south == LOCAL_RF) ret = connect_rau(ru);
|
|
||||||
else ret = attach_rru(ru);
|
|
||||||
AssertFatal(ret==0,"Cannot connect to radio\n");
|
|
||||||
}
|
|
||||||
if (ru->if_south == LOCAL_RF) { // configure RF parameters only
|
|
||||||
fill_rf_config(ru,ru->rf_config_file);
|
fill_rf_config(ru,ru->rf_config_file);
|
||||||
nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp);
|
nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp);
|
||||||
nr_dump_frame_parms(fp);
|
nr_dump_frame_parms(fp);
|
||||||
nr_phy_init_RU(ru);
|
nr_phy_init_RU(ru);
|
||||||
|
if (setup_RU_buffers(ru)!=0) {
|
||||||
ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg);
|
printf("Exiting, cannot initialize RU Buffers\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (setup_RU_buffers(ru)!=0) {
|
else{
|
||||||
printf("Exiting, cannot initialize RU Buffers\n");
|
// Start IF device if any
|
||||||
exit(-1);
|
if (ru->start_if) {
|
||||||
|
LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx);
|
||||||
|
AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n");
|
||||||
|
if (ru->if_south == LOCAL_RF) ret = connect_rau(ru);
|
||||||
|
else ret = attach_rru(ru);
|
||||||
|
AssertFatal(ret==0,"Cannot connect to radio\n");
|
||||||
|
}
|
||||||
|
if (ru->if_south == LOCAL_RF) { // configure RF parameters only
|
||||||
|
fill_rf_config(ru,ru->rf_config_file);
|
||||||
|
nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp);
|
||||||
|
nr_dump_frame_parms(fp);
|
||||||
|
nr_phy_init_RU(ru);
|
||||||
|
|
||||||
|
ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg);
|
||||||
|
}
|
||||||
|
if (setup_RU_buffers(ru)!=0) {
|
||||||
|
printf("Exiting, cannot initialize RU Buffers\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx);
|
LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx);
|
||||||
@@ -1407,28 +1456,30 @@ static void* ru_thread( void* param ) {
|
|||||||
|
|
||||||
wait_sync("ru_thread");
|
wait_sync("ru_thread");
|
||||||
|
|
||||||
// Start RF device if any
|
if(!emulate_rf){
|
||||||
if (ru->start_rf) {
|
// Start RF device if any
|
||||||
if (ru->start_rf(ru) != 0)
|
if (ru->start_rf) {
|
||||||
LOG_E(HW,"Could not start the RF device\n");
|
if (ru->start_rf(ru) != 0)
|
||||||
else LOG_I(PHY,"RU %d rf device ready\n",ru->idx);
|
LOG_E(HW,"Could not start the RF device\n");
|
||||||
}
|
else LOG_I(PHY,"RU %d rf device ready\n",ru->idx);
|
||||||
else LOG_I(PHY,"RU %d no rf device\n",ru->idx);
|
}
|
||||||
|
else LOG_I(PHY,"RU %d no rf device\n",ru->idx);
|
||||||
|
|
||||||
|
|
||||||
// if an asnych_rxtx thread exists
|
// if an asnych_rxtx thread exists
|
||||||
// wakeup the thread because the devices are ready at this point
|
// wakeup the thread because the devices are ready at this point
|
||||||
|
|
||||||
if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) {
|
if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) {
|
||||||
pthread_mutex_lock(&proc->mutex_asynch_rxtx);
|
pthread_mutex_lock(&proc->mutex_asynch_rxtx);
|
||||||
proc->instance_cnt_asynch_rxtx=0;
|
proc->instance_cnt_asynch_rxtx=0;
|
||||||
pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
|
pthread_mutex_unlock(&proc->mutex_asynch_rxtx);
|
||||||
pthread_cond_signal(&proc->cond_asynch_rxtx);
|
pthread_cond_signal(&proc->cond_asynch_rxtx);
|
||||||
}
|
}
|
||||||
else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx);
|
else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx);
|
||||||
|
|
||||||
// if this is a slave RRU, try to synchronize on the DL frequency
|
// if this is a slave RRU, try to synchronize on the DL frequency
|
||||||
if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru);
|
if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices
|
// This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices
|
||||||
@@ -1487,9 +1538,12 @@ static void* ru_thread( void* param ) {
|
|||||||
|
|
||||||
// do OFDM if needed
|
// do OFDM if needed
|
||||||
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
|
if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru);
|
||||||
// do outgoing fronthaul (south) if needed
|
if (!emulate_rf)
|
||||||
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
|
{
|
||||||
|
// do outgoing fronthaul (south) if needed
|
||||||
|
if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru);
|
||||||
|
}
|
||||||
|
|
||||||
if (ru->fh_north_out) ru->fh_north_out(ru);
|
if (ru->fh_north_out) ru->fh_north_out(ru);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1610,7 +1664,7 @@ void init_RU_proc(RU_t *ru) {
|
|||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
RU_proc_t *proc;
|
RU_proc_t *proc;
|
||||||
pthread_attr_t *attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL;// *attr_synch=NULL;
|
pthread_attr_t *attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL, *attr_emulateRF=NULL;// *attr_synch=NULL;
|
||||||
//pthread_attr_t *attr_fep=NULL;
|
//pthread_attr_t *attr_fep=NULL;
|
||||||
#ifdef Rel14
|
#ifdef Rel14
|
||||||
//pthread_attr_t *attr_prach_br=NULL;
|
//pthread_attr_t *attr_prach_br=NULL;
|
||||||
@@ -1628,6 +1682,7 @@ void init_RU_proc(RU_t *ru) {
|
|||||||
proc->instance_cnt_synch = -1; ;
|
proc->instance_cnt_synch = -1; ;
|
||||||
proc->instance_cnt_FH = -1;
|
proc->instance_cnt_FH = -1;
|
||||||
proc->instance_cnt_asynch_rxtx = -1;
|
proc->instance_cnt_asynch_rxtx = -1;
|
||||||
|
proc->instance_cnt_emulateRF = -1;
|
||||||
proc->first_rx = 1;
|
proc->first_rx = 1;
|
||||||
proc->first_tx = 1;
|
proc->first_tx = 1;
|
||||||
proc->frame_offset = 0;
|
proc->frame_offset = 0;
|
||||||
@@ -1640,15 +1695,18 @@ void init_RU_proc(RU_t *ru) {
|
|||||||
pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL);
|
pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL);
|
||||||
pthread_mutex_init( &proc->mutex_synch,NULL);
|
pthread_mutex_init( &proc->mutex_synch,NULL);
|
||||||
pthread_mutex_init( &proc->mutex_FH,NULL);
|
pthread_mutex_init( &proc->mutex_FH,NULL);
|
||||||
|
pthread_mutex_init( &proc->mutex_emulateRF,NULL);
|
||||||
pthread_mutex_init( &proc->mutex_gNBs, NULL);
|
pthread_mutex_init( &proc->mutex_gNBs, NULL);
|
||||||
|
|
||||||
pthread_cond_init( &proc->cond_prach, NULL);
|
pthread_cond_init( &proc->cond_prach, NULL);
|
||||||
pthread_cond_init( &proc->cond_FH, NULL);
|
pthread_cond_init( &proc->cond_FH, NULL);
|
||||||
|
pthread_cond_init( &proc->cond_emulateRF, NULL);
|
||||||
pthread_cond_init( &proc->cond_asynch_rxtx, NULL);
|
pthread_cond_init( &proc->cond_asynch_rxtx, NULL);
|
||||||
pthread_cond_init( &proc->cond_synch,NULL);
|
pthread_cond_init( &proc->cond_synch,NULL);
|
||||||
pthread_cond_init( &proc->cond_gNBs, NULL);
|
pthread_cond_init( &proc->cond_gNBs, NULL);
|
||||||
|
|
||||||
pthread_attr_init( &proc->attr_FH);
|
pthread_attr_init( &proc->attr_FH);
|
||||||
|
pthread_attr_init( &proc->attr_emulateRF);
|
||||||
pthread_attr_init( &proc->attr_prach);
|
pthread_attr_init( &proc->attr_prach);
|
||||||
pthread_attr_init( &proc->attr_synch);
|
pthread_attr_init( &proc->attr_synch);
|
||||||
pthread_attr_init( &proc->attr_asynch_rxtx);
|
pthread_attr_init( &proc->attr_asynch_rxtx);
|
||||||
@@ -1657,13 +1715,15 @@ void init_RU_proc(RU_t *ru) {
|
|||||||
|
|
||||||
#ifndef DEADLINE_SCHEDULER
|
#ifndef DEADLINE_SCHEDULER
|
||||||
attr_FH = &proc->attr_FH;
|
attr_FH = &proc->attr_FH;
|
||||||
|
attr_emulateRF = &proc->attr_emulateRF;
|
||||||
attr_prach = &proc->attr_prach;
|
attr_prach = &proc->attr_prach;
|
||||||
//attr_synch = &proc->attr_synch;
|
//attr_synch = &proc->attr_synch;
|
||||||
attr_asynch = &proc->attr_asynch_rxtx;
|
attr_asynch = &proc->attr_asynch_rxtx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru );
|
pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru );
|
||||||
|
if(emulate_rf)
|
||||||
|
pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc );
|
||||||
if (ru->function == NGFI_RRU_IF4p5) {
|
if (ru->function == NGFI_RRU_IF4p5) {
|
||||||
pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru );
|
pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru );
|
||||||
///tmp deactivation of synch thread
|
///tmp deactivation of synch thread
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ extern void init_eNB_afterRU(void);
|
|||||||
|
|
||||||
int transmission_mode=1;
|
int transmission_mode=1;
|
||||||
int emulate_rf = 0;
|
int emulate_rf = 0;
|
||||||
//int numerology = 0;
|
int numerology = 0;
|
||||||
int codingw = 0;
|
int codingw = 0;
|
||||||
//int fepw = 0;
|
//int fepw = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,8 @@
|
|||||||
#define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n"
|
#define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n"
|
||||||
#define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n"
|
#define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n"
|
||||||
|
|
||||||
|
#define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n"
|
||||||
|
|
||||||
/***************************************************************************************************************************************/
|
/***************************************************************************************************************************************/
|
||||||
/* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument
|
/* command line options definitions, CMDLINE_XXXX_DESC macros are used to initialize paramdef_t arrays which are then used as argument
|
||||||
when calling config_get or config_getlist functions */
|
when calling config_get or config_getlist functions */
|
||||||
@@ -167,6 +169,7 @@
|
|||||||
{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \
|
{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \
|
||||||
{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \
|
{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \
|
||||||
{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \
|
{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \
|
||||||
|
{"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \
|
||||||
{"nbiot-disable", CONFIG_HLP_DISABLNBIOT,PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \
|
{"nbiot-disable", CONFIG_HLP_DISABLNBIOT,PARAMFLAG_BOOL, iptr:&nonbiotflag, defintval:0, TYPE_INT, 0} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user