From a60e70136689af431a2c2b362fa185e277d1f501 Mon Sep 17 00:00:00 2001 From: Raymond Knopp <raymond.knopp@eurecom.fr> Date: Mon, 30 May 2016 00:36:07 +0200 Subject: [PATCH] bug fixing for new L1 scheduling, updates to vcd tracing --- openair1/PHY/defs.h | 2 + openair1/SCHED/phy_procedures_lte_eNb.c | 80 ++++++++++++++----------- openair2/UTIL/LOG/vcd_signal_dumper.c | 1 + openair2/UTIL/LOG/vcd_signal_dumper.h | 1 + targets/RT/USER/eNB_usrp.gtkw | 20 +++---- targets/RT/USER/lte-enb.c | 7 ++- 6 files changed, 64 insertions(+), 47 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index c483035abc..e18c0b1d91 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -210,6 +210,8 @@ typedef struct { pthread_t pthread_tx; /// pthread structure for rx processing thread pthread_t pthread_rx; + /// flag to indicate first RX acquisition + int first_rx; /// pthread attributes for tx processing thread pthread_attr_t attr_tx; /// pthread attributes for rx processing thread diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index c2dc89c2c5..a444686758 100755 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -2487,6 +2487,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl int subframe = proc->subframe_rx; int frame = proc->frame_rx; + if (subframe==9) { subframe=0; frame++; @@ -2515,7 +2516,10 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl fp->nb_antennas_rx); proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023; proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; - AssertFatal(proc->subframe_rx == subframe, "Received Timestamp doesn't correspond to the time we think it is"); + if (proc->first_rx == 0) + AssertFatal(proc->subframe_rx == subframe, "Received Timestamp doesn't correspond to the time we think it is"); + else + proc->first_rx = 0; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX_ENB, frame ); @@ -2526,7 +2530,42 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl exit_fun( "problem receiving samples" ); } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - + + // wake up TX thread + // lock the TX mutex and make sure the thread is ready + if (pthread_mutex_lock(&proc->mutex_tx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX thread %d (IC %d)\n", proc->instance_cnt_tx ); + exit_fun( "error locking mutex_tx" ); + return; + } + + int cnt_tx = ++proc->instance_cnt_tx; + // We have just received and processed the common part of the first slot of a subframe, say n. + // TX_rx is the last received timestamp (start of 1st slot), TX_tx is the desired + // transmitted timestamp of the next TX slot (first). + // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, + // we want to generate subframe (n+3), so TS_tx = TX_rx+3*samples_per_tti, + // and proc->subframe_tx = proc->subframe_rx+3 + proc->timestamp_tx = proc->timestamp_rx + (3*fp->samples_per_tti); + proc->frame_tx = (subframe > 6) ? (frame+1) : frame; + proc->subframe_tx = (subframe + 3)%10; + + pthread_mutex_unlock( &proc->mutex_tx ); + + if (cnt_tx == 0){ + // the thread was presumably waiting where it should and can now be woken up + if (pthread_cond_signal(&proc->cond_tx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TX thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return; + } + } else { + LOG_W( PHY,"[eNB] Frame %d, eNB TX thread busy!! (cnt_tx %i)\n", frame, cnt_tx ); + exit_fun( "TX thread busy" ); + return; + } + // now do common RX processing for first slot in subframe + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1); remove_7_5_kHz(eNB,subframe<<1); for (l=0; l<fp->symbols_per_tti/2; l++) slot_fep_ul(fp, @@ -2540,6 +2579,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl if (eNB->node_function == NGFI_RRU_IF4) { //send_IF4(eNB,subframe<<1); } + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,0); for (i=0; i<fp->nb_antennas_rx; i++) rxp[i] = (void*)&eNB->common_vars.rxdata[0][i][(fp->samples_per_tti>>1)+(subframe*fp->samples_per_tti)]; @@ -2552,6 +2592,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl fp->nb_antennas_rx); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,1); remove_7_5_kHz(eNB,(subframe<<1)+1); for (l=0; l<fp->symbols_per_tti/2; l++) slot_fep_ul(fp, @@ -2561,6 +2602,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl 0, 0 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP,0); if (eNB->node_function == NGFI_RRU_IF4) { //send_IF4(eNB,(subframe<<1)+1); } @@ -2610,39 +2652,7 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl } - // wake up TX thread - // lock the TX mutex and make sure the thread is ready - if (pthread_mutex_lock(&proc->mutex_tx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX thread %d (IC %d)\n", proc->instance_cnt_tx ); - exit_fun( "error locking mutex_tx" ); - return; - } - - int cnt_tx = ++proc->instance_cnt_tx; - // We have just received and processed the common part of an entire subframe, say n. - // TX_rx is the last received timestamp (start of 2nd slot), TX_tx is the desired - // transmitted timestamp of the next TX slot (first). - // The last (TS_rx mod samples_per_frame) was (n+.5)*samples_per_tti, - // we want to generate subframe (n+3), so TS_tx = TX_rx+2.5*samples_per_tti, - // and proc->subframe_tx = proc->subframe_rx+3 - proc->timestamp_tx = proc->timestamp_rx + (fp->samples_per_tti<<1) + (fp->samples_per_tti>>1); - proc->frame_tx = (subframe > 6) ? (frame+1) : frame; - proc->subframe_tx = (subframe + 3)%10; - - pthread_mutex_unlock( &proc->mutex_tx ); - - if (cnt_tx == 0){ - // the thread was presumably waiting where it should and can now be woken up - if (pthread_cond_signal(&proc->cond_tx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TX thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return; - } - } else { - LOG_W( PHY,"[eNB] Frame %d, eNB TX thread busy!! (cnt_tx %i)\n", frame, cnt_tx ); - exit_fun( "TX thread busy" ); - return; - } + } diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.c b/openair2/UTIL/LOG/vcd_signal_dumper.c index 1972993a94..9e855696c4 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.c +++ b/openair2/UTIL/LOG/vcd_signal_dumper.c @@ -230,6 +230,7 @@ const char* eurecomFunctionsNames[] = { "phy_procedures_eNb_rx", "phy_procedures_eNb_rx_common", "phy_procedures_eNb_rx_uespec", + "phy_eNB_slot_fep", "phy_procedures_ue_tx", "phy_procedures_ue_rx", "phy_procedures_eNB_lte", diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.h b/openair2/UTIL/LOG/vcd_signal_dumper.h index f0a3e70274..192bebd976 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.h +++ b/openair2/UTIL/LOG/vcd_signal_dumper.h @@ -204,6 +204,7 @@ typedef enum { VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_COMMON, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, + VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_SLOT_FEP, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_RX, VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_LTE, diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index 677e214f31..474d2d1cf3 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,15 +1,15 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Fri May 27 01:34:58 2016 +[*] Sun May 29 20:10:01 2016 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Fri May 27 01:33:50 2016" -[dumpfile_size] 12743642 +[dumpfile_mtime] "Sun May 29 20:07:25 2016" +[dumpfile_size] 16398004 [savefile] "/home/papillon/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" -[timestart] 10801070000 -[size] 1535 845 -[pos] -1 -1 -*-21.793451 10817350000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +[timestart] 10806270000 +[size] 1535 724 +[pos] 309 0 +*-18.793451 10806918339 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 284 [signals_width] 254 [sst_expanded] 1 @@ -28,10 +28,12 @@ variables.subframe_number_RX_eNB[63:0] functions.eNB_thread_rx0 functions.eNB_thread_tx0 functions.phy_procedures_eNb_tx -@29 functions.phy_enb_sfgen +@29 +functions.phy_eNB_slot_fep @28 functions.phy_procedures_eNb_rx +functions.phy_enb_prach_rx @24 variables.dci_info[63:0] variables.ue0_BO[63:0] @@ -46,8 +48,6 @@ functions.macxface_SR_indication @420 variables.ue0_SR_ENERGY[63:0] variables.ue0_SR_THRES[63:0] -@24 -variables.dci_info[63:0] @28 functions.phy_enb_ulsch_decoding0 @24 diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index a8444edfc9..dcf970e44e 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -372,7 +372,7 @@ static void* eNB_thread_tx( void* param ) } - LOG_I( HW, "[SCHED][eNB] TX thread %d started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",sched_getcpu(),gettid(), + LOG_I( HW, "[SCHED][eNB] TX thread started on CPU %d TID %ld, sched_policy = %s , priority = %d, CPU Affinity=%s \n",sched_getcpu(),gettid(), (policy == SCHED_FIFO) ? "SCHED_FIFO" : (policy == SCHED_RR) ? "SCHED_RR" : (policy == SCHED_OTHER) ? "SCHED_OTHER" : @@ -868,7 +868,7 @@ static void* eNB_thread_prach( void* param ) } - LOG_I( HW, "[SCHED][eNB] RX thread %d started on CPU %d TID %ld, sched_policy = %s, priority = %d, CPU Affinity = %s\n", sched_getcpu(),gettid(), + LOG_I( HW, "[SCHED][eNB] RX thread started on CPU %d TID %ld, sched_policy = %s, priority = %d, CPU Affinity = %s\n", sched_getcpu(),gettid(), (policy == SCHED_FIFO) ? "SCHED_FIFO" : (policy == SCHED_RR) ? "SCHED_RR" : (policy == SCHED_OTHER) ? "SCHED_OTHER" : @@ -975,6 +975,9 @@ void init_eNB_proc(void) proc->instance_cnt_tx = -1; proc->instance_cnt_prach = -1; proc->CC_id = CC_id; + + proc->first_rx=1; + pthread_mutex_init( &proc->mutex_tx, NULL); pthread_cond_init( &proc->cond_tx, NULL); pthread_cond_init( &proc->cond_prach, NULL); -- GitLab