Commit d30a28c3 authored by WANG Tsu-Han's avatar WANG Tsu-Han

adding check for overflow, removing prints and parameter setting fix

parent c2b3867f
...@@ -717,7 +717,6 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { ...@@ -717,7 +717,6 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) {
NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms; NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
//nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config; //nfapi_nr_config_request_t *cfg = &ru->gNB_list[0]->gNB_config;
void *txp[ru->nb_tx]; void *txp[ru->nb_tx];
char *print_test[ru->nb_tx];
unsigned int txs; unsigned int txs;
int i; int i;
T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot), T(T_ENB_PHY_OUTPUT_SIGNAL, T_INT(0), T_INT(0), T_INT(frame), T_INT(slot),
...@@ -762,27 +761,23 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) { ...@@ -762,27 +761,23 @@ void tx_rf(RU_t *ru,int frame,int slot, uint64_t timestamp) {
for (i=0; i<ru->nb_tx; i++){ for (i=0; i<ru->nb_tx; i++){
txp[i] = (void *)&ru->common.txdata[i][(slot*fp->samples_per_slot)-sf_extension]; txp[i] = (void *)&ru->common.txdata[i][(slot*fp->samples_per_slot)-sf_extension];
} }
print_test[0] = (char *)&ru->common.txdata[0][(slot*fp->samples_per_slot)-sf_extension];
printf("txdata[0] = %p\n", print_test[0]);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp-ru->openair0_cfg.tx_sample_advance)&0xffffffff );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
// prepare tx buffer pointers // prepare tx buffer pointers
start_meas(&ru->tx_fhaul); start_meas(&ru->tx_fhaul);
printf("sending trx write from tx_rf\n");
txs = ru->rfdevice.trx_write_func(&ru->rfdevice, txs = ru->rfdevice.trx_write_func(&ru->rfdevice,
timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension, timestamp+ru->ts_offset-ru->openair0_cfg.tx_sample_advance-sf_extension,
txp, txp,
siglen+sf_extension, siglen+sf_extension,
ru->nb_tx, ru->nb_tx,
flags); flags);
//printf("txp = %s\n", (char*)txp[0]);
stop_meas(&ru->tx_fhaul); stop_meas(&ru->tx_fhaul);
LOG_D(PHY,"[TXPATH] RU %d tx_rf, writing to TS %llu, frame %d, unwrapped_frame %d, subframe %d\n",ru->idx, 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)timestamp,frame,proc->frame_tx_unwrap,slot); (long long unsigned int)timestamp,frame,proc->frame_tx_unwrap,slot);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 0 );
//AssertFatal(txs == siglen+sf_extension,"TX : Timeout (sent %u/%d)\n", txs, siglen); AssertFatal(txs == 0,"trx write function error %d\n", txs);
} }
} }
......
...@@ -48,6 +48,9 @@ ...@@ -48,6 +48,9 @@
#define RAU_LOCAL_RADIO_HEAD 0 #define RAU_LOCAL_RADIO_HEAD 0
#define RAU_REMOTE_RADIO_HEAD 1 #define RAU_REMOTE_RADIO_HEAD 1
#define WRITE_THREAD_PACKAGE 10
#define WRITE_THREAD_BUFFER_SIZE 8
#ifndef MAX_CARDS #ifndef MAX_CARDS
#define MAX_CARDS 8 #define MAX_CARDS 8
#endif #endif
...@@ -278,7 +281,7 @@ typedef struct { ...@@ -278,7 +281,7 @@ typedef struct {
typedef struct { typedef struct {
openair0_timestamp timestamp; openair0_timestamp timestamp;
void *buff[8];// buffer to be write; void *buff[WRITE_THREAD_BUFFER_SIZE];// buffer to be write;
int nsamps; int nsamps;
int cc; int cc;
signed char first_packet; signed char first_packet;
...@@ -286,9 +289,7 @@ typedef struct { ...@@ -286,9 +289,7 @@ typedef struct {
} openair0_write_package_t; } openair0_write_package_t;
typedef struct { typedef struct {
openair0_write_package_t write_package[10]; openair0_write_package_t write_package[WRITE_THREAD_PACKAGE];
/// write package number
int num_package;
int start; int start;
int end; int end;
/// \internal This variable is protected by \ref mutex_write /// \internal This variable is protected by \ref mutex_write
......
...@@ -405,11 +405,11 @@ static int trx_usrp_write_recplay(openair0_device *device, openair0_timestamp ti ...@@ -405,11 +405,11 @@ static int trx_usrp_write_recplay(openair0_device *device, openair0_timestamp ti
@param flags flags must be set to TRUE if timestamp parameter needs to be applied @param flags flags must be set to TRUE if timestamp parameter needs to be applied
*/ */
static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) { static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags) {
int ret=0;
int end; int end;
openair0_thread_t *write_thread = &device->write_thread; openair0_thread_t *write_thread = &device->write_thread;
openair0_write_package_t *write_package = write_thread->write_package; openair0_write_package_t *write_package = write_thread->write_package;
AssertFatal( WRITE_THREAD_BUFFER_SIZE >= cc,"Do not support more than %d cc number\n", WRITE_THREAD_BUFFER_SIZE);
boolean_t first_packet_state=false,last_packet_state=false; boolean_t first_packet_state=false,last_packet_state=false;
...@@ -440,10 +440,15 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, ...@@ -440,10 +440,15 @@ static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp,
first_packet_state = false; first_packet_state = false;
last_packet_state = true; last_packet_state = true;
} }
printf("~~~1 buff in usrp write = %p\n", buff[0]);
pthread_mutex_lock(&write_thread->mutex_write); pthread_mutex_lock(&write_thread->mutex_write);
if(write_thread->instance_cnt_write >= WRITE_THREAD_PACKAGE){
LOG_W(HW,"Buffer overflow, resetting write package\n");
write_thread->end = write_thread->start;
write_thread->instance_cnt_write = 0;
}
end = write_thread->end; end = write_thread->end;
printf("package being write is %d\n", end);
write_package[end].timestamp = timestamp; write_package[end].timestamp = timestamp;
write_package[end].nsamps = nsamps; write_package[end].nsamps = nsamps;
write_package[end].cc = cc; write_package[end].cc = cc;
...@@ -451,11 +456,9 @@ printf("package being write is %d\n", end); ...@@ -451,11 +456,9 @@ printf("package being write is %d\n", end);
write_package[end].last_packet = last_packet_state; write_package[end].last_packet = last_packet_state;
for (int i = 0; i < cc; i++) for (int i = 0; i < cc; i++)
write_package[end].buff[i] = buff[i]; write_package[end].buff[i] = buff[i];
printf("~~~2 write_package buff in usrp write = %p\n", write_package[end].buff[0]); ++write_thread->instance_cnt_write;
write_thread->instance_cnt_write = 0; write_thread->end = (write_thread->end + 1)% WRITE_THREAD_PACKAGE;
write_thread->end = (write_thread->end + 1)% write_thread->num_package;
pthread_cond_signal(&write_thread->cond_write); pthread_cond_signal(&write_thread->cond_write);
printf("trx_usrp_write signal end\n");
pthread_mutex_unlock(&write_thread->mutex_write); pthread_mutex_unlock(&write_thread->mutex_write);
...@@ -489,28 +492,20 @@ void *trx_usrp_write_thread(void * arg){ ...@@ -489,28 +492,20 @@ void *trx_usrp_write_thread(void * arg){
while(1){ while(1){
pthread_mutex_lock(&write_thread->mutex_write); pthread_mutex_lock(&write_thread->mutex_write);
printf("waiting for signal \n"); while (write_thread->instance_cnt_write == 0) {
while (write_thread->instance_cnt_write < 0) {
pthread_cond_wait(&write_thread->cond_write,&write_thread->mutex_write); // this unlocks mutex_rxtx while waiting and then locks it again pthread_cond_wait(&write_thread->cond_write,&write_thread->mutex_write); // this unlocks mutex_rxtx while waiting and then locks it again
} }
printf("signal unlock\n");
s = (usrp_state_t *)device->priv; s = (usrp_state_t *)device->priv;
start = write_thread->start; start = write_thread->start;
printf("package bing use is start = %d, end = %d\n", start, write_thread->end);
timestamp = write_package[start].timestamp; timestamp = write_package[start].timestamp;
buff = write_package[start].buff; buff = write_package[start].buff;
nsamps = write_package[start].nsamps; nsamps = write_package[start].nsamps;
cc = write_package[start].cc; cc = write_package[start].cc;
first_packet = write_package[start].first_packet; first_packet = write_package[start].first_packet;
last_packet = write_package[start].last_packet; last_packet = write_package[start].last_packet;
write_thread->start = (write_thread->start + 1)% write_thread->num_package; write_thread->start = (write_thread->start + 1)% WRITE_THREAD_PACKAGE;
if(write_thread->end == write_thread->start){ --write_thread->instance_cnt_write;
write_thread->instance_cnt_write = -1;
}
pthread_mutex_unlock(&write_thread->mutex_write); pthread_mutex_unlock(&write_thread->mutex_write);
printf("end of write thread signal getting \n");
printf("~~~2.5 write_package buff in thread = %p\n", write_package[start].buff[0]);
printf("~~~3 buff in tx write thread= %p\n", buff[0]);
#if defined(__x86_64) || defined(__i386__) #if defined(__x86_64) || defined(__i386__)
#ifdef __AVX2__ #ifdef __AVX2__
...@@ -557,7 +552,6 @@ printf("~~~3 buff in tx write thread= %p\n", buff[0]); ...@@ -557,7 +552,6 @@ printf("~~~3 buff in tx write thread= %p\n", buff[0]);
ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md); ret = (int)s->tx_stream->send(buff_ptrs, nsamps, s->tx_md);
} else ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md); } else ret = (int)s->tx_stream->send(&(((int16_t *)buff_tx[0])[0]), nsamps, s->tx_md);
if (ret != nsamps) LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps); if (ret != nsamps) LOG_E(HW,"[xmit] tx samples %d != %d\n",ret,nsamps);
printf("end of sending buffer in trx write thread\n");
if(0) break; if(0) break;
} }
...@@ -571,10 +565,9 @@ int trx_write_init(openair0_device *device){ ...@@ -571,10 +565,9 @@ int trx_write_init(openair0_device *device){
openair0_thread_t *write_thread = &device->write_thread; openair0_thread_t *write_thread = &device->write_thread;
printf("initializing tx write thread\n"); printf("initializing tx write thread\n");
write_thread->num_package = 10;
write_thread->start = 0; write_thread->start = 0;
write_thread->end = 0; write_thread->end = 0;
write_thread->instance_cnt_write = -1; write_thread->instance_cnt_write = 0;
printf("end of tx write thread\n"); printf("end of tx write thread\n");
pthread_create(&write_thread->pthread_write,NULL,trx_usrp_write_thread,(void *)device); pthread_create(&write_thread->pthread_write,NULL,trx_usrp_write_thread,(void *)device);
......
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