Commit 335842c1 authored by Raymond Knopp's avatar Raymond Knopp

removed race condition in ru_thread_tx when signaled from L1_thread_tx

parent 069ce10a
......@@ -124,6 +124,8 @@ typedef struct RU_proc_t_s {
int tti_rx;
/// subframe (LTE) / slot (NR) to act upon for transmission
int tti_tx;
/// slot to pass to feptx worker thread
int slot_feptx;
/// subframe to act upon for reception of prach
int subframe_prach;
#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
......@@ -385,7 +387,7 @@ typedef struct RU_t_s{
/// function pointer to synchronous RX fronthaul function (RRU,3GPP_eNB/3GPP_gNB)
void (*fh_south_in)(struct RU_t_s *ru,int *frame, int *subframe);
/// function pointer to synchronous TX fronthaul function
void (*fh_south_out)(struct RU_t_s *ru);
void (*fh_south_out)(struct RU_t_s *ru,int frame_tx,int tti_tx, uint64_t timestamp_tx);
/// function pointer to synchronous RX fronthaul function (RRU)
void (*fh_north_in)(struct RU_t_s *ru,int *frame, int *subframe);
/// function pointer to synchronous RX fronthaul function (RRU)
......@@ -403,9 +405,9 @@ typedef struct RU_t_s{
/// function pointer to RX front-end processing routine (DFTs/prefix removal or NULL)
void (*feprx)(struct RU_t_s *ru);
/// function pointer to TX front-end processing routine (IDFTs and prefix removal or NULL)
void (*feptx_ofdm)(struct RU_t_s *ru);
void (*feptx_ofdm)(struct RU_t_s *ru,int frame_tx,int tti_tx);
/// function pointer to TX front-end processing routine (PRECODING)
void (*feptx_prec)(struct RU_t_s *ru);
void (*feptx_prec)(struct RU_t_s *ru,int frame_tx,int tti_tx);
/// function pointer to wakeup routine in lte-enb/nr-gnb.
int (*wakeup_rxtx)(struct PHY_VARS_eNB_s *eNB, struct RU_t_s *ru);
int (*nr_wakeup_rxtx)(struct PHY_VARS_gNB_s *gNB, struct RU_t_s *ru);
......
......@@ -58,12 +58,12 @@ extern openair0_config_t openair0_cfg[MAX_CARDS];
extern int oai_exit;
void nr_feptx0(RU_t *ru,int first_symbol, int num_symbols) {
void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols) {
NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
unsigned int aa,slot_offset,slot_offsetF;
int slot = ru->proc.tti_tx;
int slot = tti_tx;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM+(first_symbol!=0?1:0) , 1 );
......@@ -112,13 +112,13 @@ void nr_feptx0(RU_t *ru,int first_symbol, int num_symbols) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM+(first_symbol!=0?1:0), 0);
}
void nr_feptx_ofdm_2thread(RU_t *ru) {
void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx) {
NR_DL_FRAME_PARMS *fp=ru->nr_frame_parms;
nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config;
RU_proc_t *proc = &ru->proc;
struct timespec wait;
int slot = ru->proc.tti_tx;
int slot = tti_tx;
wait.tv_sec=0;
wait.tv_nsec=5000000L;
......@@ -151,7 +151,10 @@ void nr_feptx_ofdm_2thread(RU_t *ru) {
}
++proc->instance_cnt_feptx;
// slot to pass to worker thread
proc->slot_feptx = slot;
pthread_mutex_unlock( &proc->mutex_feptx );
if (pthread_cond_signal(&proc->cond_feptx) != 0) {
printf("[RU] ERROR pthread_cond_signal for feptx thread\n");
......@@ -159,11 +162,10 @@ void nr_feptx_ofdm_2thread(RU_t *ru) {
return;
}
pthread_mutex_unlock( &proc->mutex_feptx );
}
// call first half-slot in this thread
nr_feptx0(ru,0,fp->symbols_per_slot>>1);
nr_feptx0(ru,slot,0,fp->symbols_per_slot>>1);
wait_on_busy_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"NR feptx thread");
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 );
......@@ -184,11 +186,13 @@ static void *nr_feptx_thread(void *param) {
while (!oai_exit) {
if (wait_on_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"NR feptx thread")<0) break;
nr_feptx0(ru,ru->nr_frame_parms->symbols_per_slot>>1,ru->nr_frame_parms->symbols_per_slot>>1);
int slot=proc->slot_feptx;
if (release_thread(&proc->mutex_feptx,&proc->instance_cnt_feptx,"NR feptx thread")<0) break;
nr_feptx0(ru,slot,ru->nr_frame_parms->symbols_per_slot>>1,ru->nr_frame_parms->symbols_per_slot>>1);
if (pthread_cond_signal(&proc->cond_feptx) != 0) {
printf("[gNB] ERROR pthread_cond_signal for NR feptx thread exit\n");
LOG_E(PHY,"[gNB] ERROR pthread_cond_signal for NR feptx thread exit\n");
exit_fun( "ERROR pthread_cond_signal" );
return NULL;
}
......@@ -212,7 +216,7 @@ void nr_init_feptx_thread(RU_t *ru,pthread_attr_t *attr_feptx) {
// is this supposed to generate a slot or a subframe???
// seems to be hardcoded to numerology 1 (2 slots=1 subframe)
void nr_feptx_ofdm(RU_t *ru) {
void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx) {
NR_DL_FRAME_PARMS *fp=ru->nr_frame_parms;
nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config;
......@@ -220,7 +224,7 @@ void nr_feptx_ofdm(RU_t *ru) {
unsigned int aa=0;
int slot_sizeF = (fp->ofdm_symbol_size)*
((cfg->subframe_config.dl_cyclic_prefix_type.value == 1) ? 12 : 14);
int slot = ru->proc.tti_tx;
int slot = tti_tx;
int *txdata = &ru->common.txdata[aa][slot*fp->samples_per_slot];
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 1 );
......@@ -235,7 +239,7 @@ void nr_feptx_ofdm(RU_t *ru) {
((nr_slot_select(cfg,slot)==SF_S))) {
// LOG_D(HW,"Frame %d: Generating slot %d\n",frame,next_slot);
nr_feptx0(ru,0,fp->symbols_per_slot);
nr_feptx0(ru,slot,0,fp->symbols_per_slot);
}
......@@ -243,7 +247,7 @@ void nr_feptx_ofdm(RU_t *ru) {
stop_meas(&ru->ofdm_mod_stats);
LOG_D(PHY,"feptx_ofdm (TXPATH): frame %d, slot %d: txp (time %p) %d dB, txp (freq) %d dB\n",
ru->proc.frame_tx,slot,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_slot)),
frame_tx,slot,txdata,dB_fixed(signal_energy((int32_t*)txdata,fp->samples_per_slot)),
dB_fixed(signal_energy_nodc(ru->common.txdataF_BF[aa],2*slot_sizeF)));
}
......@@ -39,9 +39,9 @@ void nr_set_ssb_first_subcarrier(nfapi_nr_config_request_t *cfg, NR_DL_FRAME_PAR
void phy_procedures_gNB_TX(PHY_VARS_gNB *gNB, int frame_tx,int slot_tx, int do_meas);
void nr_common_signal_procedures (PHY_VARS_gNB *gNB,int frame, int slot);
void nr_init_feptx_thread(RU_t *ru,pthread_attr_t *attr_feptx);
void nr_feptx_ofdm(RU_t *ru);
void nr_feptx_ofdm_2thread(RU_t *ru);
void nr_feptx0(RU_t *ru,int first_symbol, int num_symbols);
void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx);
void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx);
void nr_feptx0(RU_t *ru,int tti_tx,int first_symbol, int num_symbols);
void nr_configure_css_dci_initial(nfapi_nr_dl_config_pdcch_parameters_rel15_t* pdcch_params,
nr_scs_e scs_common,
......
/*
/*/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
......@@ -424,7 +424,7 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
int waitret;
struct timespec wait;
wait.tv_sec=0;
wait.tv_nsec=5000000L;
wait.tv_nsec=10000000L;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,proc->instance_cnt_RUs);
......@@ -433,7 +433,7 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
waitret=timedwait_on_condition(&proc->mutex_RUs_tx,&proc->cond_RUs,&proc->instance_cnt_RUs,"wakeup_txfh",500000);
if (waitret == ETIMEDOUT) {
LOG_W(PHY,"Dropping TX slot because FH is blocked more than 1 slot times (500us)\n");
LOG_W(PHY,"Dropping TX slot (%d.%d) because FH is blocked more than 2 slot times (1000us)\n",frame_tx,slot_tx);
pthread_mutex_lock(&gNB->proc.mutex_RU_tx);
gNB->proc.RU_mask_tx = 0;
......@@ -456,11 +456,11 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
pthread_mutex_unlock(&gNB->proc.mutex_RU_tx);
return(-1);
}
if (pthread_mutex_timedlock(&ru_proc->mutex_gNBs,&wait) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", ru_proc->tti_rx&1,ru_proc->instance_cnt_gNBs );
exit_fun( "error locking mutex_gNB" );
if ((waitret = pthread_mutex_timedlock(&ru_proc->mutex_gNBs,&wait)) == ETIMEDOUT) {
LOG_W( PHY, "[eNB] ERROR pthread_mutex_lock timed out on mutex_gNBs L1_thread_tx (timeout)\n");
return(-1);
}
else AssertFatal(waitret==0,"pthread_mutex_timedlock returned %d\n",waitret);
ru_proc->instance_cnt_gNBs = 0;
ru_proc->timestamp_tx = timestamp_tx;
......@@ -468,16 +468,15 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
ru_proc->frame_tx = frame_tx;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_UE, ru_proc->instance_cnt_gNBs);
pthread_mutex_unlock( &ru_proc->mutex_gNBs );
LOG_D(PHY,"Signaling tx_thread_fh for %d.%d\n",ru_proc->frame_tx,ru_proc->tti_tx);
LOG_D(PHY,"Signaling tx_thread_fh for %d.%d\n",frame_tx,slot_tx);
// the thread can now be woken up
if (pthread_cond_signal(&ru_proc->cond_gNBs) != 0) {
LOG_E( PHY, "[gNB] ERROR pthread_cond_signal for gNB TXnp4 thread\n");
exit_fun( "ERROR pthread_cond_signal" );
return(-1);
}
pthread_mutex_unlock( &ru_proc->mutex_gNBs );
}
return(0);
......
......@@ -580,8 +580,8 @@ void fh_if4p5_north_asynch_in(RU_t *ru,int *frame,int *slot) {
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, slot_tx );
}
if (ru->feptx_ofdm) ru->feptx_ofdm(ru);
if (ru->fh_south_out) ru->fh_south_out(ru);
if (ru->feptx_ofdm) ru->feptx_ofdm(ru,frame_tx,slot_tx);
if (ru->fh_south_out) ru->fh_south_out(ru,frame_tx,slot_tx,proc->timestamp_tx);
}
void fh_if5_north_out(RU_t *ru) {
......@@ -736,7 +736,7 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
}
void tx_rf(RU_t *ru) {
void tx_rf(RU_t *ru,int frame_tx,int tti_tx,uint64_t timestamp_tx) {
RU_proc_t *proc = &ru->proc;
NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
......@@ -745,10 +745,10 @@ void tx_rf(RU_t *ru) {
unsigned int txs;
int i;
T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(proc->frame_tx), T_INT(proc->tti_tx),
T_INT(0), T_BUFFER(&ru->common.txdata[0][proc->tti_tx * fp->samples_per_slot], fp->samples_per_slot * 4));
T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame_tx), T_INT(tti_tx),
T_INT(0), T_BUFFER(&ru->common.txdata[0][tti_tx * fp->samples_per_slot], fp->samples_per_slot * 4));
nr_subframe_t SF_type = nr_slot_select(cfg,proc->tti_tx%fp->slots_per_frame);
nr_subframe_t SF_type = nr_slot_select(cfg,tti_tx%fp->slots_per_frame);
int sf_extension = 0;
if ((SF_type == SF_DL) ||
......@@ -776,25 +776,24 @@ void tx_rf(RU_t *ru) {
flags = 4; // start of burst and end of burst (only one DL SF between two UL)
sf_extension = ru->N_TA_offset<<1;
} */
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_TTI_NUMBER_TX0_RU, proc->tti_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU,tti_tx );
for (i=0; i<ru->nb_tx; i++)
txp[i] = (void*)&ru->common.txdata[i][(proc->tti_tx*fp->samples_per_slot)-sf_extension];
txp[i] = (void*)&ru->common.txdata[i][(tti_tx*fp->samples_per_slot)-sf_extension];
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-ru->openair0_cfg.tx_sample_advance)&0xffffffff );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp_tx-ru->openair0_cfg.tx_sample_advance)&0xffffffff );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
// prepare tx buffer pointers
txs = ru->rfdevice.trx_write_func(&ru->rfdevice,
proc->timestamp_tx+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
timestamp_tx+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
txp,
siglen+sf_extension,
ru->nb_tx,
4);//flags);
LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n",ru->idx,
(long long unsigned int)proc->timestamp_tx,proc->frame_tx,proc->frame_tx_unwrap,proc->tti_tx);
(long long unsigned int)timestamp_tx,frame_tx,proc->frame_tx_unwrap,tti_tx);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
......@@ -1297,24 +1296,32 @@ static void* ru_thread_tx( void* param ) {
wait_on_condition(&proc->mutex_gNBs,&proc->cond_gNBs,&proc->instance_cnt_gNBs,"ru_thread_tx");
pthread_mutex_lock(&proc->mutex_gNBs);
int frame_tx=proc->frame_tx;
int tti_tx =proc->tti_tx;
uint64_t timestamp_tx = proc->timestamp_tx;
pthread_mutex_unlock(&proc->mutex_gNBs);
if (oai_exit) break;
//printf("~~~~~~~~~~~~~~~~start process for ru_thread_tx %d.%d\n", proc->frame_tx, proc->tti_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_TTI_NUMBER_TX0_RU, proc->tti_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, frame_tx );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TTI_NUMBER_TX0_RU, tti_tx );
// do TX front-end processing if needed (precoding and/or IDFTs)
if (ru->feptx_prec) ru->feptx_prec(ru);
if (ru->feptx_prec) ru->feptx_prec(ru,frame_tx,tti_tx);
// 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,frame_tx,tti_tx);
if(!emulate_rf){
// 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_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,frame_tx,tti_tx,timestamp_tx);
if (ru->fh_north_out) ru->fh_north_out(ru);
}
else
{
if(proc->frame_tx == print_frame)
if(frame_tx == print_frame)
{
for (i=0; i<ru->nb_tx; i++)
{
......@@ -1367,13 +1374,13 @@ static void* ru_thread_tx( void* param ) {
pthread_mutex_lock(&L1_proc->mutex_RUs_tx);
L1_proc->instance_cnt_RUs = 0;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,L1_proc->instance_cnt_RUs);
pthread_mutex_unlock( &L1_proc->mutex_RUs_tx );
// the thread can now be woken up
if (pthread_cond_signal(&L1_proc->cond_RUs) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB L1 TX thread\n");
exit_fun( "ERROR pthread_cond_signal" );
}
pthread_mutex_unlock( &L1_proc->mutex_RUs_tx );
}
}
}
......@@ -1526,14 +1533,14 @@ static void* ru_thread( void* param ) {
if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD && ru->num_gNB==0)
{
// do TX front-end processing if needed (precoding and/or IDFTs)
if (ru->feptx_prec) ru->feptx_prec(ru);
if (ru->feptx_prec) ru->feptx_prec(ru,proc->frame_tx,proc->tti_tx);
// 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,proc->frame_tx,proc->tti_tx);
if(!emulate_rf)
{
// 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_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru,proc->frame_tx,proc->tti_tx,proc->timestamp_tx);
if (ru->fh_north_out) ru->fh_north_out(ru);
}
......@@ -1676,9 +1683,9 @@ int stop_rf(RU_t *ru)
extern void fep_full(RU_t *ru);
extern void ru_fep_full_2thread(RU_t *ru);
extern void nr_feptx_ofdm(RU_t *ru);
extern void nr_feptx_ofdm_2thread(RU_t *ru);
extern void feptx_prec(RU_t *ru);
extern void nr_feptx_ofdm(RU_t *ru,int frame_tx,int tti_tx);
extern void nr_feptx_ofdm_2thread(RU_t *ru,int frame_tx,int tti_tx);
extern void feptx_prec(RU_t *ru, int frame_tx,int tti_tx);
extern void init_fep_thread(RU_t *ru,pthread_attr_t *attr);
extern void init_nr_feptx_thread(RU_t *ru,pthread_attr_t *attr);
......
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