Commit d44479ff authored by matzakos's avatar matzakos

tuning on laptops and fix of race condition between L1_RX -> L1_TX

parent 8c1f9c9e
......@@ -1072,7 +1072,7 @@ static inline int release_thread(pthread_mutex_t *mutex,int *instance_cnt,char *
return(-1);
}
*instance_cnt=*instance_cnt-1;
*instance_cnt=-1;
if (pthread_mutex_unlock(mutex) != 0) {
LOG_E( PHY, "[SCHED][eNB] error unlocking mutex for %s\n",name);
......
......@@ -86,9 +86,14 @@ UE0:
};
SIM: {
MSIN="0100001111";
USIM_API_K="8baf473f2f8fd09487cccbd7097c6862";
OPC="e734f8734007d6c5ce7a0508809e7e9c";
MSIN="0000000001";
#USIM_API_K="e56e26f5608b8d268f2556e198a0e01b";
#USIM_API_K="8baf473f2f8fd09487cccbd7097c6862"; #initial
#USIM_API_K= "11111111111111111111111111111111"; #nano
USIM_API_K="fec86ba6eb707ed08905757b1bb44b8f";
#OPC="e734f8734007d6c5ce7a0508809e7e9c"; #initial
#OPC="f47f37e4719a9c379e3447f089b1f10a"; #nano
OPC="C42449363BBAD02B66D16BC975D77CC1";
MSISDN="33611123456";
};
......
......@@ -464,46 +464,105 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
}
}
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
s->tx_md.has_time_spec = flags;
int packet_size = s->tx_stream->get_max_num_samps();
int residual = nsamps % packet_size;
int num_packets = (nsamps/packet_size) + ((residual>0) ? 1 : 0);
int first_packet_length = (num_packets>1) ? packet_size : residual;
int packet_s;
/* s->tx_md.has_time_spec = flags;
if(flags>0)
s->tx_md.has_time_spec = true;
else
s->tx_md.has_time_spec = false;
s->tx_md.has_time_spec = false;*/
boolean_t first_packet_state=false,last_packet_state=false,first_packet_has_timespec=false;
if (flags == 2) { // start of burst
s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = false;
// s->tx_md.start_of_burst = true;
// s->tx_md.end_of_burst = false;
first_packet_state = true;
last_packet_state = false;
first_packet_has_timespec=true;
} else if (flags == 3) { // end of burst
s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = true;
//s->tx_md.start_of_burst = false;
//s->tx_md.end_of_burst = true;
first_packet_state = false;
last_packet_state - true;
} else if (flags == 4) { // start and end
s->tx_md.start_of_burst = true;
s->tx_md.end_of_burst = true;
// s->tx_md.start_of_burst = true;
// s->tx_md.end_of_burst = true;
first_packet_state = true;
last_packet_state = true;
first_packet_has_timespec=true;
} else if (flags==1) { // middle of burst
// s->tx_md.start_of_burst = false;
// s->tx_md.end_of_burst = false;
first_packet_state = false;
last_packet_state = false;
}
else if (flags==10) { // fail safe mode
// s->tx_md.has_time_spec = false;
// s->tx_md.start_of_burst = false;
// s->tx_md.end_of_burst = true;
first_packet_state=false;
last_packet_state=true;
}
/*
int offset=0;
for (int packet_ind=0;packet_ind<num_packets;packet_ind++) {
s->tx_md.has_time_spec = first_packet_has_timespec;
s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = false;
}
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp+offset, s->sample_rate);
if(flags==10) { // fail safe mode
s->tx_md.has_time_spec = false;
s->tx_md.start_of_burst = false;
s->tx_md.end_of_burst = true;
if (packet_ind == 0) {
packet_s = first_packet_length;
s->tx_md.start_of_burst = first_packet_state;
if (num_packets==1) s->tx_md.end_of_burst = last_packet_state;
else s->tx_md.end_of_burst = false;
}
else if (packet_ind==num_packets-1) {
packet_s = residual;
s->tx_md.end_of_burst = last_packet_state;
}
else packet_s = packet_size;
if (cc>1) {
std::vector<void *> buff_ptrs;
for (int i=0; i<cc; i++)
buff_ptrs.push_back(buff_tx[i]);
buff_ptrs.push_back(&(((int16_t*)buff_tx[i])[offset]));
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,250e-6);
ret = (int)s->tx_stream->send(buff_ptrs, packet_s, s->tx_md,1e-3);
} else
ret = (int)s->tx_stream->send(buff_tx[0], nsamps, s->tx_md,250e-6);
ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[offset]), packet_s, s->tx_md,1e-3);
if (ret != nsamps)
if (ret != packet_s) {
LOG_E(PHY,"[xmit] tx samples %d != %d\n",ret,nsamps);
break;
}
offset += packet_s;
}
ret=offset;
*/
s->tx_md.has_time_spec = first_packet_has_timespec;
s->tx_md.start_of_burst = first_packet_state;
s->tx_md.end_of_burst = last_packet_state;
s->tx_md.time_spec = uhd::time_spec_t::from_ticks(timestamp, s->sample_rate);
if (cc>1) {
std::vector<void *> buff_ptrs;
for (int i=0; i<cc; i++)
buff_ptrs.push_back(&(((int16_t*)buff_tx[i])[0]));
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md,1e-3);
} else
ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md,1e-3);
if (ret != nsamps) LOG_E(PHY,"[xmit] tx samples %d != %d\n",ret,nsamps);
#if defined(USRP_REC_PLAY)
} else {
......
[*]
[*] GTKWave Analyzer v3.3.61 (w)1999-2014 BSI
[*] Mon May 6 11:32:36 2019
[*] GTKWave Analyzer v3.3.86 (w)1999-2017 BSI
[*] Tue May 7 21:21:14 2019
[*]
[dumpfile] "/tmp/openair_dump_gNB40.vcd"
[dumpfile_mtime] "Mon May 6 11:32:05 2019"
[dumpfile_size] 803075
[savefile] "/home/caracal/raymond/openairinterface5g/targets/RT/USER/gNB_usrp.gtkw"
[timestart] 10835824000
[dumpfile_mtime] "Tue May 7 21:19:43 2019"
[dumpfile_size] 18197199
[savefile] "/home/belostome/raymond/openairinterface5g/targets/RT/USER/gNB_usrp.gtkw"
[timestart] 8147990000
[size] 1920 859
[pos] -1 -1
*-19.848083 10838512202 -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
*-21.848083 8158741030 -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] 386
[signals_width] 344
[sst_expanded] 1
......@@ -17,6 +17,10 @@
@28
functions.trx_read
functions.trx_write
@421
variables.frame_number_TX0_UE[63:0]
@420
variables.frame_number_RX1_UE[63:0]
@24
variables.trx_ts[63:0]
variables.trx_tst[63:0]
......@@ -48,7 +52,7 @@ functions.phy_enb_pdcch_tx
functions.phy_eNB_dlsch_encoding
functions.phy_eNB_dlsch_encoding_w
functions.generate_dlsch
@421
@420
variables.frame_number_RX0_UE[63:0]
@28
functions.phy_procedures_ru_feprx0
......
......@@ -248,7 +248,6 @@ static void* gNB_L1_thread_tx(void* param) {
while (!oai_exit) {
while (L1_proc_tx->instance_cnt==-1)
if (wait_on_condition(&L1_proc_tx->mutex,&L1_proc_tx->cond,&L1_proc_tx->instance_cnt,thread_name)<0) break;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PROC_RXTX1, 1 );
if (oai_exit) break;
......@@ -410,26 +409,28 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
// note this should depend on the numerology used by the TX L1 thread, set here for 500us slot time
waitret=timedwait_on_condition(&proc->mutex_RUs_tx,&proc->cond_RUs,&proc->instance_cnt_RUs,"wakeup_txfh",500000);
if (release_thread(&proc->mutex_RUs_tx,&proc->instance_cnt_RUs,"wakeup_txfh")<0) return(-1);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,proc->instance_cnt_RUs);
if (waitret == ETIMEDOUT) {
LOG_W(PHY,"Dropping TX slot because FH is blocked more than 2 slot times (1000us)\n");
LOG_W(PHY,"Dropping TX slot because FH is blocked more than 1 slot times (500us)\n");
pthread_mutex_lock(&gNB->proc.mutex_RU_tx);
gNB->proc.RU_mask_tx = 0;
pthread_mutex_unlock(&gNB->proc.mutex_RU_tx);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,1);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,0);
return(-1);
}
else if (release_thread(&proc->mutex_RUs_tx,&proc->instance_cnt_RUs,"wakeup_txfh")<0) return(-1);
for(int i=0; i<gNB->num_RU; i++)
{
ru = gNB->RU_list[i];
ru_proc = &ru->proc;
if (ru_proc->instance_cnt_gNBs == 0) {
LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->tti_tx, proc->frame_rx, proc->slot_rx);
pthread_mutex_lock(&gNB->proc.mutex_RU_tx);
gNB->proc.RU_mask_tx = 0;
pthread_mutex_unlock(&gNB->proc.mutex_RU_tx);
return(-1);
}
if (pthread_mutex_timedlock(&ru_proc->mutex_gNBs,&wait) != 0) {
......@@ -443,6 +444,8 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
ru_proc->tti_tx = slot_tx;
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);
LOG_D(PHY,"Signaling tx_thread_fh for %d.%d\n",ru_proc->frame_tx,ru_proc->tti_tx);
// the thread can now be woken up
if (pthread_cond_signal(&ru_proc->cond_gNBs) != 0) {
......@@ -486,6 +489,8 @@ int wakeup_tx(PHY_VARS_gNB *gNB,int frame_rx,int slot_rx,int frame_tx,int slot_t
L1_proc_tx->frame_tx = frame_tx;
L1_proc_tx->timestamp_tx = timestamp_tx;
pthread_mutex_unlock( &L1_proc_tx->mutex);
// the thread can now be woken up
if (pthread_cond_signal(&L1_proc_tx->cond) != 0) {
LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n");
......@@ -493,7 +498,6 @@ int wakeup_tx(PHY_VARS_gNB *gNB,int frame_rx,int slot_rx,int frame_tx,int slot_t
return(-1);
}
pthread_mutex_unlock( &L1_proc_tx->mutex);
return(0);
}
......
......@@ -754,7 +754,7 @@ void tx_rf(RU_t *ru) {
if ((SF_type == SF_DL) ||
(SF_type == SF_S)) {
int siglen=fp->samples_per_slot,flags=1;
int siglen=fp->samples_per_slot>>1,flags=1;
/*
if (SF_type == SF_S) {
......@@ -1280,20 +1280,13 @@ static void* ru_thread_tx( void* param ) {
int print_frame = 8;
int i = 0;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
thread_top_init("ru_thread_tx",1,400000,500000,500000);
//CPU_SET(5, &cpuset);
//pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
//wait_sync("ru_thread_tx");
thread_top_init("ru_thread_tx",0,400000,500000,500000);
wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx");
printf( "ru_thread_tx ready\n");
while (!oai_exit) {
if (oai_exit) break;
......@@ -1301,7 +1294,9 @@ static void* ru_thread_tx( void* param ) {
LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n");
// wait until eNBs are finished subframe RX n and TX n+4
wait_on_condition(&proc->mutex_gNBs,&proc->cond_gNBs,&proc->instance_cnt_gNBs,"ru_thread_tx");
if (oai_exit) break;
//printf("~~~~~~~~~~~~~~~~start process for ru_thread_tx %d.%d\n", proc->frame_tx, proc->tti_tx);
......@@ -1347,6 +1342,8 @@ static void* ru_thread_tx( void* param ) {
}//if(proc->frame_tx == print_frame)
}//else emulate_rf
release_thread(&proc->mutex_gNBs,&proc->instance_cnt_gNBs,"ru_thread_tx");
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_UE, proc->instance_cnt_gNBs);
for(i = 0; i<ru->num_gNB; i++)
{
gNB = ru->gNB_list[i];
......
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