Merge remote-tracking branch 'origin/fix-nrsoftmodem-stop' into integration_2022_wk33

This commit is contained in:
Robert Schmidt
2022-08-19 18:22:23 +02:00
65 changed files with 737 additions and 693 deletions
+2
View File
@@ -310,6 +310,8 @@ typedef struct {
pthread_cond_t cond_write;
/// mutex for trx write thread
pthread_mutex_t mutex_write;
/// to inform the thread to exit
bool write_thread_exit;
} openair0_thread_t;
/*!\brief structure holds the parameters to configure USRP devices */
+52 -2
View File
@@ -309,6 +309,26 @@ static int trx_usrp_start(openair0_device *device) {
return 0;
}
static void trx_usrp_send_end_of_burst(usrp_state_t *s) {
// if last packet sent was end of burst no need to do anything. otherwise send end of burst packet
if (s->tx_md.end_of_burst)
return;
s->tx_md.end_of_burst = true;
s->tx_md.start_of_burst = false;
s->tx_md.has_time_spec = false;
int32_t dummy = 0;
std::vector<const void *> buffs;
for (size_t ch = 0; ch < s->tx_stream->get_num_channels(); ch++)
buffs.push_back(&dummy); // same buffer for each channel
s->tx_stream->send(buffs, 0, s->tx_md);
}
static void trx_usrp_write_reset(openair0_thread_t *wt);
/*! \brief Terminate operation of the USRP transceiver -- free all associated resources
* \param device the hardware to use
*/
@@ -318,11 +338,27 @@ static void trx_usrp_end(openair0_device *device) {
usrp_state_t *s = (usrp_state_t *)device->priv;
if (s == NULL)
return;
AssertFatal(s != NULL, "%s() called on uninitialized USRP\n", __func__);
iqrecorder_end(device);
LOG_I(HW, "releasing USRP\n");
if (usrp_tx_thread != 0)
trx_usrp_write_reset(&device->write_thread);
trx_usrp_send_end_of_burst(s);
s->tx_stream->~tx_streamer();
s->rx_stream->~rx_streamer();
s->usrp->~multi_usrp();
free(s);
device->priv = NULL;
device->trx_start_func = NULL;
device->trx_get_stats_func = NULL;
device->trx_reset_stats_func = NULL;
device->trx_end_func = NULL;
device->trx_stop_func = NULL;
device->trx_set_freq_func = NULL;
device->trx_set_gains_func = NULL;
device->trx_write_init = NULL;
}
/*! \brief Called to send samples to the USRP RF target
@@ -505,6 +541,8 @@ void *trx_usrp_write_thread(void * arg){
while (write_thread->count_write == 0) {
pthread_cond_wait(&write_thread->cond_write,&write_thread->mutex_write); // this unlocks mutex_rxtx while waiting and then locks it again
}
if (write_thread->write_thread_exit)
break;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE_THREAD, 1 );
s = (usrp_state_t *)device->priv;
start = write_thread->start;
@@ -599,6 +637,7 @@ int trx_usrp_write_init(openair0_device *device){
write_thread->start = 0;
write_thread->end = 0;
write_thread->count_write = 0;
write_thread->write_thread_exit = false;
printf("end of tx write thread\n");
pthread_mutex_init(&write_thread->mutex_write, NULL);
pthread_cond_init(&write_thread->cond_write, NULL);
@@ -607,6 +646,17 @@ int trx_usrp_write_init(openair0_device *device){
return(0);
}
static void trx_usrp_write_reset(openair0_thread_t *wt) {
pthread_mutex_lock(&wt->mutex_write);
wt->count_write = 1;
wt->write_thread_exit = true;
pthread_mutex_unlock(&wt->mutex_write);
pthread_cond_signal(&wt->cond_write);
void *retval = NULL;
pthread_join(wt->pthread_write, &retval);
LOG_I(HW, "stopped USRP write thread\n");
}
//---------------------end-------------------------
/*! \brief Receive samples from hardware.
+13 -5
View File
@@ -225,15 +225,16 @@ enum blocking_t {
};
static void setblocking(int sock, enum blocking_t active) {
int opts;
AssertFatal( (opts = fcntl(sock, F_GETFL)) >= 0,"");
int opts = fcntl(sock, F_GETFL);
AssertFatal(opts >= 0, "fcntl(): errno %d, %s\n", errno, strerror(errno));
if (active==blocking)
opts = opts & ~O_NONBLOCK;
else
opts = opts | O_NONBLOCK;
AssertFatal(fcntl(sock, F_SETFL, opts) >= 0, "");
opts = fcntl(sock, F_SETFL, opts);
AssertFatal(opts >= 0, "fcntl(): errno %d, %s\n", errno, strerror(errno));
}
static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps);
@@ -248,7 +249,6 @@ static void fullwrite(int fd, void *_buf, ssize_t count, rfsimulator_state_t *t)
"Bug: %d/%p/%zd/%p", fd, _buf, count, t);
char *buf = _buf;
ssize_t l;
setblocking(fd, notBlocking);
while (count) {
l = write(fd, buf, count);
@@ -740,7 +740,15 @@ static int rfsimulator_get_stats(openair0_device *device) {
static int rfsimulator_reset_stats(openair0_device *device) {
return 0;
}
static void rfsimulator_end(openair0_device *device) {}
static void rfsimulator_end(openair0_device *device) {
rfsimulator_state_t* s = device->priv;
for (int i = 0; i < FD_SETSIZE; i++) {
buffer_t *b = &s->buf[i];
if (b->conn_sock >= 0 )
close(b->conn_sock);
}
close(s->epollfd);
}
static int rfsimulator_stop(openair0_device *device) {
return 0;
}
+1 -1
View File
@@ -106,7 +106,7 @@ struct timing_info_t {
// Fix per CC openair rf/if device update
// extern openair0_device openair0;
extern volatile int oai_exit;
extern int oai_exit;
extern int transmission_mode;
+1 -1
View File
@@ -78,7 +78,7 @@ static int DEFBFW[] = {0x00007fff};
#define MBMS_EXPERIMENTAL
extern volatile int oai_exit;
extern int oai_exit;
extern clock_source_t clock_source;
#include "executables/thread-common.h"
//extern PARALLEL_CONF_t get_thread_parallel_conf(void);
+1 -1
View File
@@ -106,7 +106,7 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75,
uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
volatile int oai_exit = 0;
int oai_exit = 0;
uint64_t downlink_frequency[MAX_NUM_CCs][4];
int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
+1 -1
View File
@@ -146,7 +146,7 @@ extern int rx_input_level_dBm;
extern uint64_t num_missed_slots; // counter for the number of missed slots
extern int oaisim_flag;
extern volatile int oai_exit;
extern int oai_exit;
extern openair0_config_t openair0_cfg[MAX_CARDS];
extern pthread_cond_t sync_cond;
+1 -1
View File
@@ -99,7 +99,7 @@ int config_sync_var=-1;
uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
volatile int oai_exit = 0;
int oai_exit = 0;
unsigned int mmapped_dma=0;