From f22700e332f4830c82b4385bf979e9c3d00e1a1f Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 22 May 2017 22:20:51 +0200 Subject: [PATCH 1/7] clean up Soapy RF driver --- srslte/lib/rf/rf_soapy_imp.c | 513 +++++++++++++++++------------------ srslte/lib/rf/rf_soapy_imp.h | 18 +- 2 files changed, 260 insertions(+), 271 deletions(-) diff --git a/srslte/lib/rf/rf_soapy_imp.c b/srslte/lib/rf/rf_soapy_imp.c index 261c4ab54..609398da8 100644 --- a/srslte/lib/rf/rf_soapy_imp.c +++ b/srslte/lib/rf/rf_soapy_imp.c @@ -36,422 +36,411 @@ #include #include -//#include "lime/LimeSuite.h" typedef struct { - - SoapySDRKwargs args; - SoapySDRDevice *device; - SoapySDRRange *ranges; - - SoapySDRStream *rxStream; - SoapySDRStream *txStream; - - + SoapySDRKwargs args; + SoapySDRDevice *device; + SoapySDRRange *ranges; + SoapySDRStream *rxStream; + SoapySDRStream *txStream; } rf_soapy_handler_t; + int soapy_error(void *h) { } + void rf_soapy_get_freq_range(void *h) { - + } + void rf_soapy_suppress_handler(const char *x) { - // not supported + // not supported } + void rf_soapy_msg_handler(const char *msg) { - // not supported + // not supported } + void rf_soapy_suppress_stdout(void *h) { - // not supported + // not supported } + void rf_soapy_register_error_handler(void *notused, srslte_rf_error_handler_t new_handler) { - // not supported + // not supported } + static bool isLocked(rf_soapy_handler_t *handler, char *sensor_name, void *value_h) { - // not supported + printf("TODO: implement isLocked()\n"); return true; } + char* rf_soapy_devname(void* h) { - + printf("TODO: implement rf_soapy_devname()\n"); } bool rf_soapy_rx_wait_lo_locked(void *h) { - // not supported + printf("TODO: implement rf_soapy_rx_wait_lo_locked()\n"); return true; } + void rf_soapy_set_tx_cal(void *h, srslte_rf_cal_t *cal) { + printf("TODO: implement rf_soapy_rx_wait_lo_locked()\n"); // not supported } -void rf_soapy_set_rx_cal(void *h, srslte_rf_cal_t *cal) + +void rf_soapy_set_rx_cal(void *h, srslte_rf_cal_t *cal) { - // not supported + printf("TODO: implement rf_soapy_set_rx_cal()\n"); } + int rf_soapy_start_rx_stream(void *h) { - //printf("starting SOAPY rx stream \n"); - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - //SoapySDRStream *rxStream; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if(SoapySDRDevice_activateStream(handler->device, handler->rxStream, 0, 0, 0)!=0)//start streaming - return SRSLTE_ERROR; - - - return SRSLTE_SUCCESS; + if (SoapySDRDevice_activateStream(handler->device, handler->rxStream, 0, 0, 0) != 0) + return SRSLTE_ERROR; + + return SRSLTE_SUCCESS; } int rf_soapy_start_tx_stream(void *h) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - //SoapySDRStream *rxStream; - if (SoapySDRDevice_setupStream(handler->device, &(handler->txStream), SOAPY_SDR_TX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) - { - printf("setupStream fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; - } - if(SoapySDRDevice_activateStream(handler->device, handler->txStream, 0, 0, 0) != 0) - return SRSLTE_ERROR; - - - return SRSLTE_SUCCESS; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setupStream(handler->device, &(handler->txStream), SOAPY_SDR_TX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) { + printf("setupStream fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + + if(SoapySDRDevice_activateStream(handler->device, handler->txStream, 0, 0, 0) != 0) + return SRSLTE_ERROR; + + return SRSLTE_SUCCESS; } + int rf_soapy_stop_rx_stream(void *h) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if(SoapySDRDevice_deactivateStream(handler->device, handler->rxStream, 0, 0) != 0) - return SRSLTE_ERROR; - - - - return SRSLTE_SUCCESS; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_deactivateStream(handler->device, handler->rxStream, 0, 0) != 0) + return SRSLTE_ERROR; + + return SRSLTE_SUCCESS; } + + int rf_soapy_stop_tx_stream(void *h) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - - if(SoapySDRDevice_deactivateStream(handler->device, handler->txStream, 0, 0) != 0) - return SRSLTE_ERROR; - - - - return SRSLTE_SUCCESS; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if(SoapySDRDevice_deactivateStream(handler->device, handler->txStream, 0, 0) != 0) + return SRSLTE_ERROR; + + return SRSLTE_SUCCESS; } + void rf_soapy_flush_buffer(void *h) { - int n; + int n; cf_t tmp1[1024]; cf_t tmp2[1024]; void *data[2] = {tmp1, tmp2}; do { n = rf_soapy_recv_with_time_multi(h, data, 1024, 0, NULL, NULL); - } while (n > 0); + } while (n > 0); } + bool rf_soapy_has_rssi(void *h) { - + printf("TODO: implement rf_soapy_has_rssi()\n"); + return false; } + float rf_soapy_get_rssi(void *h) { - + printf("TODO: implement rf_soapy_get_rssi()\n"); + return 0.0; } + //TODO: add multi-channel support int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) -{//SoapySDRKwargs soapy_args = {}; - size_t length; - const SoapySDRKwargs *soapy_args = SoapySDRDevice_enumerate(NULL, &length); - - if(length == 0) - { - return SRSLTE_ERROR; - } - - for (size_t i = 0; i < length; i++) - { - printf("Soapy Has Found device #%d: ", (int)i); - for (size_t j = 0; j < soapy_args[i].size; j++) - { - printf("%s=%s, ", soapy_args[i].keys[j], soapy_args[i].vals[j]); - } - printf("\n"); - } - - // SoapySDRrgs_set(&soapy_args, "driver", "rtlsdr"); - SoapySDRDevice *sdr = SoapySDRDevice_make(&(soapy_args[0])); - - if(sdr == NULL) - { - printf("failed to create SOAPY object\n"); - return SRSLTE_ERROR; - - } - - //SoapySDRKwargs_clear(&soapy_args); - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) malloc(sizeof(rf_soapy_handler_t)); - *h = handler; - handler->device = sdr; - - - - //size_t channels[1]; - //channels[0] = 0; - - if (SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) +{ + size_t length; + const SoapySDRKwargs *soapy_args = SoapySDRDevice_enumerate(NULL, &length); + + if (length == 0) { + printf("No Soapy devices found.\n"); + return SRSLTE_ERROR; + } + + for (size_t i = 0; i < length; i++) { + printf("Soapy Has Found device #%d: ", (int)i); + for (size_t j = 0; j < soapy_args[i].size; j++) { - printf("setupStream fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; + printf("%s=%s, ", soapy_args[i].keys[j], soapy_args[i].vals[j]); } - - - - return SRSLTE_SUCCESS; - + printf("\n"); + } + + SoapySDRDevice *sdr = SoapySDRDevice_make(&(soapy_args[0])); + if (sdr == NULL) { + printf("failed to create SOAPY object\n"); + return SRSLTE_ERROR; + } + + // create handler + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) malloc(sizeof(rf_soapy_handler_t)); + bzero(handler, sizeof(rf_soapy_handler_t)); + *h = handler; + handler->device = sdr; + + if (SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) { + printf("setupStream fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + + return SRSLTE_SUCCESS; } + int rf_soapy_open(char *args, void **h) { - return rf_soapy_open_multi(args, h, 1); + return rf_soapy_open_multi(args, h, 1); } int rf_soapy_close(void *h) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - SoapySDRDevice_closeStream(handler->device, handler->txStream); - SoapySDRDevice_closeStream(handler->device, handler->rxStream); - SoapySDRDevice_unmake(handler->device); + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (handler->txStream) { + rf_soapy_stop_tx_stream(handler); + SoapySDRDevice_closeStream(handler->device, handler->txStream); + } + + if (handler->rxStream) { + rf_soapy_stop_rx_stream(handler); + SoapySDRDevice_closeStream(handler->device, handler->rxStream); + } + + SoapySDRDevice_unmake(handler->device); + free(handler); } void rf_soapy_set_master_clock_rate(void *h, double rate) { // Allow the soapy to automatically set the appropriate clock rate - - printf("SET MASTER CLOCK RATE\n"); + printf("SET MASTER CLOCK RATE\n"); } -bool rf_soapy_is_master_clock_dynamic(void *h) + +bool rf_soapy_is_master_clock_dynamic(void *h) { - + printf("TODO: implement rf_soapy_is_master_clock_dynamic()\n"); + return false; } + double rf_soapy_set_rx_srate(void *h, double rate) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_RX, 0, rate) != 0) - { - printf("setSampleRate fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; - } - - double ret = SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_RX,0); - printf("Sampling rate is set to %f.3 : \n",ret); - return ret; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_RX, 0, rate) != 0) { + printf("setSampleRate fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + + double ret = SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_RX,0); + printf("Sampling rate is set to %f.3 : \n",ret); + return ret; } double rf_soapy_set_tx_srate(void *h, double rate) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_TX, 0, rate) != 0) - { - printf("setSampleRate fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; - } - double ret = SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0); - printf("Sampling rate is set to %f.3 : \n",ret); - return ret; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setSampleRate(handler->device, SOAPY_SDR_TX, 0, rate) != 0) { + printf("setSampleRate fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + double ret = SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0); + printf("Sampling rate is set to %f.3 : \n",ret); + return ret; } + double rf_soapy_set_rx_gain(void *h, double gain) { - - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if (SoapySDRDevice_setGain(handler->device, SOAPY_SDR_RX, 0, gain) != 0) - { - printf("setGain fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; - } - double ret = rf_soapy_get_rx_gain(h); - printf("gain has been set to %f.2 \n",ret); - return ret; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setGain(handler->device, SOAPY_SDR_RX, 0, gain) != 0) + { + printf("setGain fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + double ret = rf_soapy_get_rx_gain(h); + printf("Rx gain has been set to %f.2 \n",ret); + return ret; } + double rf_soapy_set_tx_gain(void *h, double gain) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if (SoapySDRDevice_setGain(handler->device, SOAPY_SDR_TX, 0, gain) != 0) - { - printf("setGain fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; - } - double ret = rf_soapy_get_rx_gain(h); - printf("gain has been set to %f.2 \n",ret); - return ret; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setGain(handler->device, SOAPY_SDR_TX, 0, gain) != 0) + { + printf("setGain fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + double ret = rf_soapy_get_rx_gain(h); + printf("Tx gain has been set to %f.2 \n",ret); + return ret; } + double rf_soapy_get_rx_gain(void *h) { - - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_RX,0); - + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_RX,0); } + double rf_soapy_get_tx_gain(void *h) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_TX,0); + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + return SoapySDRDevice_getGain(handler->device,SOAPY_SDR_TX,0); } + double rf_soapy_set_rx_freq(void *h, double freq) { - - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if (SoapySDRDevice_setFrequency(handler->device, SOAPY_SDR_RX, 0, freq, NULL) != 0) - { - printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; - } - - double ret = SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); - printf("Frequency has been set to %f : \n",ret); - return ret; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setFrequency(handler->device, SOAPY_SDR_RX, 0, freq, NULL) != 0) + { + printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + double ret = SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); + printf("Rx frequency has been set to %f : \n",ret); + return ret; } double rf_soapy_set_tx_freq(void *h, double freq) { - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - if (SoapySDRDevice_setFrequency(handler->device, SOAPY_SDR_TX, 0, freq, NULL) != 0) - { - printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); - return SRSLTE_ERROR; - } - double ret = SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); - printf("Frequency has been set to %f : \n",ret); - return ret; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + if (SoapySDRDevice_setFrequency(handler->device, SOAPY_SDR_TX, 0, freq, NULL) != 0) + { + printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); + return SRSLTE_ERROR; + } + double ret = SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); + printf("Tx frequency has been set to %f : \n",ret); + return ret; } void rf_soapy_get_time(void *h, time_t *secs, double *frac_secs) { - + } //TODO: add multi-channel support int rf_soapy_recv_with_time_multi(void *h, - void **data, - uint32_t nsamples, - bool blocking, - time_t *secs, - double *frac_secs) -{ - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - //void *buffs[] = {buff}; //array of buffers - - int flags; //flags set by receive operation - - int num_channels = 1; // temp - - int trials = 0; - int ret = 0; - long long timeNs; //timestamp for receive buffer - int n = 0; - do{ - - size_t rx_samples = nsamples; - - if (rx_samples > nsamples - n) - { - rx_samples = nsamples - n; - } - void *buffs_ptr[4]; - for (int i=0;idevice, handler->rxStream,buffs_ptr , rx_samples, &flags, &timeNs, 1000000); - - if(ret < 0) - return SRSLTE_ERROR; - n += ret; - trials++; - }while (n < nsamples && trials < 100); - - - //*secs = timeNs / 1000000000; - //*frac_secs = (timeNs % 1000000000)/1000000000; - // printf("ret=%d, flags=%d, timeNs=%lld\n", ret, flags, timeNs); - return n; + void **data, + uint32_t nsamples, + bool blocking, + time_t *secs, + double *frac_secs) +{ + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + //void *buffs[] = {buff}; //array of buffers + + int flags; //flags set by receive operation + + int num_channels = 1; // temp + + int trials = 0; + int ret = 0; + long long timeNs; //timestamp for receive buffer + int n = 0; + do { + size_t rx_samples = nsamples; + + if (rx_samples > nsamples - n) + { + rx_samples = nsamples - n; + } + void *buffs_ptr[4]; + for (int i=0; idevice, handler->rxStream,buffs_ptr , rx_samples, &flags, &timeNs, 1000000); - + if(ret < 0) + return SRSLTE_ERROR; + n += ret; + trials++; + } while (n < nsamples && trials < 100); + + + //*secs = timeNs / 1000000000; + //*frac_secs = (timeNs % 1000000000)/1000000000; + // printf("ret=%d, flags=%d, timeNs=%lld\n", ret, flags, timeNs); + return n; } int rf_soapy_recv_with_time(void *h, - void *data, - uint32_t nsamples, - bool blocking, - time_t *secs, - double *frac_secs) + void *data, + uint32_t nsamples, + bool blocking, + time_t *secs, + double *frac_secs) { - return rf_soapy_recv_with_time_multi(h, &data, nsamples, blocking, secs, frac_secs); + return rf_soapy_recv_with_time_multi(h, &data, nsamples, blocking, secs, frac_secs); } - -int rf_soapy_send_timed(void *h, - void *data, - int nsamples, - time_t secs, - double frac_secs, - bool has_time_spec, - bool blocking, - bool is_start_of_burst, - bool is_end_of_burst) -{ - - int flags; - long long timeNs; - rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; - timeNs = secs * 1000000000; - timeNs = timeNs + (frac_secs * 1000000000); - int ret = SoapySDRDevice_writeStream(handler->device, handler->txStream, &data, nsamples, &flags, timeNs, 100000); - - - - if(ret != nsamples) - return SRSLTE_ERROR; - - - - return ret; +int rf_soapy_send_timed(void *h, + void *data, + int nsamples, + time_t secs, + double frac_secs, + bool has_time_spec, + bool blocking, + bool is_start_of_burst, + bool is_end_of_burst) +{ + int flags; + long long timeNs; + rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; + timeNs = secs * 1000000000; + timeNs = timeNs + (frac_secs * 1000000000); + int ret = SoapySDRDevice_writeStream(handler->device, handler->txStream, &data, nsamples, &flags, timeNs, 100000); + if(ret != nsamples) + return SRSLTE_ERROR; + + return ret; } - - - - diff --git a/srslte/lib/rf/rf_soapy_imp.h b/srslte/lib/rf/rf_soapy_imp.h index 145609267..04c6c79b3 100644 --- a/srslte/lib/rf/rf_soapy_imp.h +++ b/srslte/lib/rf/rf_soapy_imp.h @@ -30,12 +30,12 @@ #include "srslte/rf/rf.h" -SRSLTE_API int rf_soapy_open( char *args, - void **handler); +SRSLTE_API int rf_soapy_open(char *args, + void **handler); -SRSLTE_API int rf_soapy_open_multi( char *args, - void **handler, - uint32_t nof_rx_antennas); +SRSLTE_API int rf_soapy_open_multi(char *args, + void **handler, + uint32_t nof_rx_antennas); SRSLTE_API char* rf_soapy_devname(void *h); @@ -58,20 +58,20 @@ SRSLTE_API float rf_soapy_get_rssi(void *h); SRSLTE_API bool rf_soapy_rx_wait_lo_locked(void *h); SRSLTE_API void rf_soapy_set_master_clock_rate(void *h, - double rate); + double rate); SRSLTE_API bool rf_soapy_is_master_clock_dynamic(void *h); SRSLTE_API double rf_soapy_set_rx_srate(void *h, - double freq); + double freq); SRSLTE_API double rf_soapy_set_rx_gain(void *h, - double gain); + double gain); SRSLTE_API double rf_soapy_get_rx_gain(void *h); SRSLTE_API double rf_soapy_set_tx_gain(void *h, - double gain); + double gain); SRSLTE_API double rf_soapy_get_tx_gain(void *h); From 062bb2720e6c189dd1d14675dee69d752dbf0165 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Mon, 22 May 2017 22:31:50 +0200 Subject: [PATCH 2/7] fix bug in Soapy Tx call and some compile warnings --- srslte/lib/rf/rf_soapy_imp.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/srslte/lib/rf/rf_soapy_imp.c b/srslte/lib/rf/rf_soapy_imp.c index 609398da8..641542c08 100644 --- a/srslte/lib/rf/rf_soapy_imp.c +++ b/srslte/lib/rf/rf_soapy_imp.c @@ -48,7 +48,7 @@ typedef struct { int soapy_error(void *h) { - + return 0; } @@ -82,16 +82,9 @@ void rf_soapy_register_error_handler(void *notused, srslte_rf_error_handler_t ne } -static bool isLocked(rf_soapy_handler_t *handler, char *sensor_name, void *value_h) -{ - printf("TODO: implement isLocked()\n"); - return true; -} - - char* rf_soapy_devname(void* h) { - printf("TODO: implement rf_soapy_devname()\n"); + return "soapy"; } bool rf_soapy_rx_wait_lo_locked(void *h) @@ -248,6 +241,8 @@ int rf_soapy_close(void *h) SoapySDRDevice_unmake(handler->device); free(handler); + + return SRSLTE_SUCCESS; } void rf_soapy_set_master_clock_rate(void *h, double rate) @@ -438,7 +433,7 @@ int rf_soapy_send_timed(void *h, rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; timeNs = secs * 1000000000; timeNs = timeNs + (frac_secs * 1000000000); - int ret = SoapySDRDevice_writeStream(handler->device, handler->txStream, &data, nsamples, &flags, timeNs, 100000); + int ret = SoapySDRDevice_writeStream(handler->device, handler->txStream, data, nsamples, &flags, timeNs, 100000); if(ret != nsamples) return SRSLTE_ERROR; From 465398e8b9dfe0d2207f29d66d86bfaf20aea09e Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 23 May 2017 14:44:42 +0200 Subject: [PATCH 3/7] gracefully handle overflows in SoapySDR driver - continue rx'ing when getting overflows - remove printfs in setter functions --- srslte/lib/rf/rf_soapy_imp.c | 44 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/srslte/lib/rf/rf_soapy_imp.c b/srslte/lib/rf/rf_soapy_imp.c index 641542c08..3a94e06f6 100644 --- a/srslte/lib/rf/rf_soapy_imp.c +++ b/srslte/lib/rf/rf_soapy_imp.c @@ -248,7 +248,7 @@ int rf_soapy_close(void *h) void rf_soapy_set_master_clock_rate(void *h, double rate) { // Allow the soapy to automatically set the appropriate clock rate - printf("SET MASTER CLOCK RATE\n"); + // TODO: implement this function } @@ -266,10 +266,7 @@ double rf_soapy_set_rx_srate(void *h, double rate) printf("setSampleRate fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } - - double ret = SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_RX,0); - printf("Sampling rate is set to %f.3 : \n",ret); - return ret; + return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_RX,0); } double rf_soapy_set_tx_srate(void *h, double rate) @@ -279,9 +276,7 @@ double rf_soapy_set_tx_srate(void *h, double rate) printf("setSampleRate fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } - double ret = SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0); - printf("Sampling rate is set to %f.3 : \n",ret); - return ret; + return SoapySDRDevice_getSampleRate(handler->device, SOAPY_SDR_TX,0); } @@ -293,9 +288,7 @@ double rf_soapy_set_rx_gain(void *h, double gain) printf("setGain fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } - double ret = rf_soapy_get_rx_gain(h); - printf("Rx gain has been set to %f.2 \n",ret); - return ret; + return rf_soapy_get_rx_gain(h); } @@ -307,9 +300,7 @@ double rf_soapy_set_tx_gain(void *h, double gain) printf("setGain fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } - double ret = rf_soapy_get_rx_gain(h); - printf("Tx gain has been set to %f.2 \n",ret); - return ret; + return rf_soapy_get_rx_gain(h); } @@ -336,9 +327,7 @@ double rf_soapy_set_rx_freq(void *h, double freq) return SRSLTE_ERROR; } - double ret = SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); - printf("Rx frequency has been set to %f : \n",ret); - return ret; + return SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); } double rf_soapy_set_tx_freq(void *h, double freq) @@ -349,10 +338,7 @@ double rf_soapy_set_tx_freq(void *h, double freq) printf("setFrequency fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } - double ret = SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); - printf("Tx frequency has been set to %f : \n",ret); - return ret; - + return SoapySDRDevice_getFrequency(handler->device, SOAPY_SDR_RX, 0); } @@ -392,10 +378,18 @@ int rf_soapy_recv_with_time_multi(void *h, cf_t *data_c = (cf_t*) data[i]; buffs_ptr[i] = &data_c[n]; } //(void*)(&data) - ret = SoapySDRDevice_readStream(handler->device, handler->rxStream,buffs_ptr , rx_samples, &flags, &timeNs, 1000000); - - if(ret < 0) - return SRSLTE_ERROR; + ret = SoapySDRDevice_readStream(handler->device, handler->rxStream, buffs_ptr , rx_samples, &flags, &timeNs, 1000000); + if(ret < 0) { + // continue when getting overflows + if (ret == SOAPY_SDR_OVERFLOW) { + fprintf(stderr, "O"); + fflush(stderr); + continue; + } else { + return SRSLTE_ERROR; + } + } + n += ret; trials++; } while (n < nsamples && trials < 100); From 39517952d416742c5c502ce0f05aa9907a2d7034 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Fri, 26 May 2017 16:46:33 +0200 Subject: [PATCH 4/7] fixed temporal scrambling sequence in pdsch_decode --- srslte/lib/phch/pdsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srslte/lib/phch/pdsch.c b/srslte/lib/phch/pdsch.c index 9a2281753..87e54a6d5 100644 --- a/srslte/lib/phch/pdsch.c +++ b/srslte/lib/phch/pdsch.c @@ -542,7 +542,7 @@ int srslte_pdsch_encode(srslte_pdsch_t *q, if (srslte_sequence_pdsch(&seq, rnti, 0, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { return SRSLTE_ERROR; } - srslte_scrambling_bytes(&q->users[rnti]->seq[cfg->sf_idx], (uint8_t*) q->e, cfg->nbits.nof_bits); + srslte_scrambling_bytes(&seq, (uint8_t*) q->e, cfg->nbits.nof_bits); srslte_sequence_free(&seq); } else { srslte_scrambling_bytes(&q->users[rnti]->seq[cfg->sf_idx], (uint8_t*) q->e, cfg->nbits.nof_bits); From ff7400f140373475a6c1f8652b5368ee862f61f1 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 31 May 2017 13:32:58 +0200 Subject: [PATCH 5/7] remove unused header --- srsue/hdr/phy/nbiot_phy.h | 165 -------------------------------------- 1 file changed, 165 deletions(-) delete mode 100644 srsue/hdr/phy/nbiot_phy.h diff --git a/srsue/hdr/phy/nbiot_phy.h b/srsue/hdr/phy/nbiot_phy.h deleted file mode 100644 index 575c94431..000000000 --- a/srsue/hdr/phy/nbiot_phy.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2015 Software Radio Systems Limited - * - * \section LICENSE - * - * This file is part of the srsUE library. - * - * srsUE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsUE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#ifndef UEPHY_H -#define UEPHY_H - -#include "srslte/srslte.h" -#include "common/phy_interface.h" -#include "common/log.h" -#include "phy/phy_metrics.h" -#include "phy/phch_recv.h" -#include "phy/prach.h" -#include "phy/phch_worker.h" -#include "phy/phch_common.h" -#include "radio/radio.h" -#include "common/task_dispatcher.h" -#include "common/trace.h" -#include "common/mac_interface.h" -#include "common/interfaces.h" - -namespace srsue { - -typedef _Complex float cf_t; - -class phy - : public phy_interface_mac - , public phy_interface_rrc -{ -public: - phy(); - bool init(srslte::radio *radio_handler, - mac_interface_phy *mac, - rrc_interface_phy *rrc, - srslte::log *log_h, - phy_args_t *args = NULL); - - void stop(); - - void set_agc_enable(bool enabled); - - void get_metrics(phy_metrics_t &m); - - void set_crnti(uint16_t rnti); - - - static uint32_t tti_to_SFN(uint32_t tti); - static uint32_t tti_to_subf(uint32_t tti); - - void enable_pregen_signals(bool enable); - - void start_trace(); - void write_trace(std::string filename); - - /********** RRC INTERFACE ********************/ - void reset(); - bool status_is_sync(); - void configure_ul_params(bool pregen_disabled = false); - void resync_sfn(); - - /********** MAC INTERFACE ********************/ - /* Functions to synchronize with a cell */ - void sync_start(); - void sync_stop(); - - /* Instructs the PHY to configure using the parameters written by set_param() */ - void configure_prach_params(); - - /* Transmits PRACH in the next opportunity */ - void prach_send(uint32_t preamble_idx, int allowed_subframe = -1, float target_power_dbm = 0.0); - int prach_tx_tti(); - - /* Indicates the transmission of a SR signal in the next opportunity */ - void sr_send(); - int sr_last_tx_tti(); - - // Time advance commands - void set_timeadv_rar(uint32_t ta_cmd); - void set_timeadv(uint32_t ta_cmd); - - /* Sets RAR grant payload */ - void set_rar_grant(uint32_t tti, uint8_t grant_payload[SRSLTE_RAR_GRANT_LEN]); - - /* Instruct the PHY to decode PDCCH with the CRC scrambled with given RNTI */ - void pdcch_ul_search(srslte_rnti_type_t rnti_type, uint16_t rnti, int tti_start = -1, int tti_end = -1); - void pdcch_dl_search(srslte_rnti_type_t rnti_type, uint16_t rnti, int tti_start = -1, int tti_end = -1); - void pdcch_ul_search_reset(); - void pdcch_dl_search_reset(); - - /* Get/Set PHY parameters interface from RRC */ - void get_config(phy_cfg_t *phy_cfg); - void set_config(phy_cfg_t *phy_cfg); - void set_config_dedicated(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT *dedicated); - void set_config_common(phy_cfg_common_t *common); - void set_config_tdd(LIBLTE_RRC_TDD_CONFIG_STRUCT *tdd); - void set_config_64qam_en(bool enable); - - - float get_phr(); - float get_pathloss_db(); - - uint32_t get_current_tti(); - void get_current_cell(srslte_cell_t *cell); - - void start_plot(); - void start_channel_emulator(const char *filename, int *path_taps, int nof_paths, int nof_coeffs, int nof_samples, int nof_tti); - -private: - - uint32_t nof_workers; - - const static int MAX_WORKERS = 4; - const static int DEFAULT_WORKERS = 2; - - const static int SF_RECV_THREAD_PRIO = 1; - const static int WORKERS_THREAD_PRIO = 0; - - srslte::radio *radio_handler; - srslte::log *log_h; - - srslte::thread_pool workers_pool; - std::vector workers; - phch_common workers_common; - phch_recv sf_recv; - prach prach_buffer; - - srslte_cell_t cell; - - phy_cfg_t config; - phy_args_t *args; - - /* Current time advance */ - uint32_t n_ta; - - bool init_(srslte::radio *radio_handler, mac_interface_phy *mac, srslte::log *log_h, bool do_agc, uint32_t nof_workers); - void set_default_args(phy_args_t *args); - bool check_args(phy_args_t *args); - -}; - -} // namespace srsue - -#endif // UEPHY_H From bcecdf292baf36f332bf183b77a89b192f8f9038 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 31 May 2017 13:44:10 +0200 Subject: [PATCH 6/7] add C++ compile flags and enable useful warnings --- CMakeLists.txt | 19 +++++++++++++++++++ lib/CMakeLists.txt | 13 ------------- lib/src/asn1/CMakeLists.txt | 2 +- srsue/test/mac/CMakeLists.txt | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3eb7b76f..57bdb3f8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,10 +200,12 @@ endif(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-write-strings -Wno-format-extra-args -Winline -Wno-unused-result -Wno-format -std=c99 -D_GNU_SOURCE -g") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable") if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") find_package(SSE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -DDEBUG_MODE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -std=c++03") if(HAVE_AVX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") elseif(HAVE_SSE) @@ -211,14 +213,18 @@ if(CMAKE_COMPILER_IS_GNUCC) endif(HAVE_AVX) else(${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++03") find_package(SSE) if (HAVE_AVX2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx2 -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -mavx2 -DLV_HAVE_AVX -DLV_HAVE_SSE") else (HAVE_AVX2) if(HAVE_AVX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -mavx -Ofast -funroll-loops -DLV_HAVE_AVX -DLV_HAVE_SSE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -mavx -DLV_HAVE_AVX -DLV_HAVE_SSE") elseif(HAVE_SSE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -mfpmath=sse -msse4.1 -Ofast -funroll-loops -DLV_HAVE_SSE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mfpmath=sse -msse4.1 -DLV_HAVE_SSE") endif(HAVE_AVX) endif (HAVE_AVX2) @@ -288,6 +294,19 @@ include_directories(${PROJECT_SOURCE_DIR}/lib/include) # Includes needed by all code previously resided in srsUE include_directories(${PROJECT_SOURCE_DIR}/lib/include/srslte) +######################################################################## +# Add headers to cmake project (useful for IDEs) +######################################################################## +set(HEADERS_ALL "") +file(GLOB headers *) +foreach(_header ${headers}) + if(IS_DIRECTORY ${_header}) + file(GLOB_RECURSE tmp "${_header}/*.h") + list(APPEND HEADERS_ALL ${tmp}) + endif(IS_DIRECTORY ${_header}) +endforeach() +add_custom_target(add_srslte_headers SOURCES ${HEADERS_ALL}) + ######################################################################## # Add the subdirectories ######################################################################## diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 1f30ed290..15aa4d635 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -26,19 +26,6 @@ INSTALL(DIRECTORY include/ FILES_MATCHING PATTERN "*.h" ) -######################################################################## -# Add headers to cmake project (useful for IDEs) -######################################################################## -set(HEADERS_ALL "") -file(GLOB headers *) -FOREACH (_header ${headers}) - if(IS_DIRECTORY ${_header}) - file(GLOB_RECURSE tmp "${_header}/*.h") - list(APPEND HEADERS_ALL ${tmp}) - endif(IS_DIRECTORY ${_header}) -ENDFOREACH() -add_custom_target (add_srslte_headers SOURCES ${HEADERS_ALL}) - ######################################################################## # Find Dependencies ######################################################################## diff --git a/lib/src/asn1/CMakeLists.txt b/lib/src/asn1/CMakeLists.txt index 83fe5e315..b9671177d 100644 --- a/lib/src/asn1/CMakeLists.txt +++ b/lib/src/asn1/CMakeLists.txt @@ -1,4 +1,4 @@ -include_directories(hdr) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-but-set-variable -Wno-unused-variable -Wno-return-type -Wno-sign-compare -Wno-reorder -Wno-parantheses") add_library(srslte_asn1 SHARED liblte_common.cc liblte_rrc.cc diff --git a/srsue/test/mac/CMakeLists.txt b/srsue/test/mac/CMakeLists.txt index b1bf4e07f..e458b9362 100644 --- a/srsue/test/mac/CMakeLists.txt +++ b/srsue/test/mac/CMakeLists.txt @@ -16,7 +16,7 @@ # the LICENSE file in the top-level directory of this distribution # and at http://www.gnu.org/licenses/. # - +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch") add_executable(mac_test mac_test.cc) target_link_libraries(mac_test srsue_mac srsue_phy srslte_common srslte_phy srslte_radio srslte_asn1 ${SRSLTE_LIBRARIES} ${LIBLTE_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) From c51c4d2a38ce63541c99bd59e614079e0a18c355 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 31 May 2017 13:45:01 +0200 Subject: [PATCH 7/7] fix compile warnings --- lib/include/srslte/asn1/liblte_common.h | 8 +++++++ lib/include/srslte/asn1/liblte_rrc.h | 2 +- lib/include/srslte/common/buffer_pool.h | 2 +- lib/include/srslte/common/common.h | 8 +++++++ lib/include/srslte/common/pdu.h | 6 ++--- lib/include/srslte/common/timers.h | 8 +++---- lib/include/srslte/upper/rlc_am.h | 2 +- lib/include/srslte/upper/rlc_common.h | 2 +- lib/src/common/mac_pcap.cc | 8 +++---- lib/src/common/pdu.cc | 20 ++++++++++------ lib/src/common/thread_pool.cc | 4 ++-- lib/src/phy/utils/vector.c | 4 ++-- lib/src/upper/gw.cc | 2 +- lib/src/upper/rlc_am.cc | 26 ++++++++++---------- lib/src/upper/rlc_um.cc | 14 ++++++----- lib/src/upper/rrc.cc | 32 ++++++++++++------------- lib/test/common/log_filter_test.cc | 1 + lib/test/upper/rlc_am_control_test.cc | 4 ++-- lib/test/upper/rlc_am_data_test.cc | 6 ++--- lib/test/upper/rlc_um_data_test.cc | 4 ++-- srsue/hdr/mac/mux.h | 2 +- srsue/hdr/ue.h | 2 +- srsue/src/mac/demux.cc | 2 +- srsue/src/mac/dl_harq.cc | 2 +- srsue/src/mac/mux.cc | 25 +++++++++---------- srsue/src/mac/proc_bsr.cc | 13 ++++++---- srsue/src/mac/proc_ra.cc | 3 ++- srsue/src/mac/proc_sr.cc | 2 +- srsue/src/mac/ul_harq.cc | 6 ++--- srsue/src/phy/phch_common.cc | 12 +++++----- srsue/src/phy/phch_recv.cc | 10 ++++---- srsue/src/phy/phch_worker.cc | 6 ++--- srsue/src/phy/phy.cc | 8 +++---- srsue/test/mac/mac_test.cc | 6 +++-- srsue/test/upper/ip_test.cc | 8 +++---- 35 files changed, 151 insertions(+), 119 deletions(-) diff --git a/lib/include/srslte/asn1/liblte_common.h b/lib/include/srslte/asn1/liblte_common.h index 71e0bb76f..36fb32190 100644 --- a/lib/include/srslte/asn1/liblte_common.h +++ b/lib/include/srslte/asn1/liblte_common.h @@ -121,8 +121,12 @@ struct LIBLTE_BYTE_MSG_STRUCT{ } LIBLTE_BYTE_MSG_STRUCT & operator= (const LIBLTE_BYTE_MSG_STRUCT & buf) { + // avoid self assignment + if (&buf == this) + return *this; N_bytes = buf.N_bytes; memcpy(msg, buf.msg, N_bytes); + return *this; } uint32 get_headroom() { @@ -152,8 +156,12 @@ struct LIBLTE_BIT_MSG_STRUCT{ memcpy(msg, buf.msg, N_bits); } LIBLTE_BIT_MSG_STRUCT & operator= (const LIBLTE_BIT_MSG_STRUCT & buf){ + // avoid self assignment + if (&buf == this) + return *this; N_bits = buf.N_bits; memcpy(msg, buf.msg, N_bits); + return *this; } uint32 get_headroom() { diff --git a/lib/include/srslte/asn1/liblte_rrc.h b/lib/include/srslte/asn1/liblte_rrc.h index 71fe37f99..5a8515dbb 100644 --- a/lib/include/srslte/asn1/liblte_rrc.h +++ b/lib/include/srslte/asn1/liblte_rrc.h @@ -4494,7 +4494,7 @@ typedef enum{ }LIBLTE_RRC_MAX_RETX_THRESHOLD_ENUM; static const char liblte_rrc_max_retx_threshold_text[LIBLTE_RRC_MAX_RETX_THRESHOLD_N_ITEMS][20] = { "t1", "t2", "t3", "t4", "t6", "t8", "t16", "t32"}; -static const int32 liblte_rrc_max_retx_threshold_num[LIBLTE_RRC_MAX_RETX_THRESHOLD_N_ITEMS] = { 1, 2, 3, 4, +static const uint32_t liblte_rrc_max_retx_threshold_num[LIBLTE_RRC_MAX_RETX_THRESHOLD_N_ITEMS] = { 1, 2, 3, 4, 6, 8, 16, 32}; typedef enum{ LIBLTE_RRC_T_REORDERING_MS0 = 0, diff --git a/lib/include/srslte/common/buffer_pool.h b/lib/include/srslte/common/buffer_pool.h index 231afefe0..8058d1f51 100644 --- a/lib/include/srslte/common/buffer_pool.h +++ b/lib/include/srslte/common/buffer_pool.h @@ -57,7 +57,7 @@ public: buffer_pool(uint32_t nof_buffers = POOL_SIZE) { pthread_mutex_init(&mutex, NULL); - for(int i=0;i 0) { + if (nof_subheaders < (int)max_subheaders - 1 && rem_len > 0) { nof_subheaders++; next(); return true; @@ -148,7 +148,7 @@ protected: uint32_t pdu_len; uint32_t rem_len; int cur_idx; - int nof_subheaders; + int nof_subheaders; uint32_t max_subheaders; bool pdu_is_ul; uint8_t* buffer_tx; @@ -169,7 +169,7 @@ private: total_sdu_len = 0; last_sdu_idx = -1; reset(); - for (int i=0;istep(); } } void stop_all() { - for (int i=0;istop(); } } void run_all() { - for (int i=0;irun(); } } void reset_all() { - for (int i=0;ireset(); } } diff --git a/lib/include/srslte/upper/rlc_am.h b/lib/include/srslte/upper/rlc_am.h index dcb6e2734..2dba1da26 100644 --- a/lib/include/srslte/upper/rlc_am.h +++ b/lib/include/srslte/upper/rlc_am.h @@ -134,7 +134,7 @@ private: int32_t t_poll_retx; // Poll retx timeout (ms) int32_t poll_pdu; // Insert poll bit after this many PDUs int32_t poll_byte; // Insert poll bit after this much data (KB) - int32_t max_retx_thresh; // Max number of retx + uint32_t max_retx_thresh; // Max number of retx // RX configs int32_t t_reordering; // Timer used by rx to detect PDU loss (ms) diff --git a/lib/include/srslte/upper/rlc_common.h b/lib/include/srslte/upper/rlc_common.h index bb353a6ae..f43973d41 100644 --- a/lib/include/srslte/upper/rlc_common.h +++ b/lib/include/srslte/upper/rlc_common.h @@ -126,7 +126,7 @@ struct rlc_amd_pdu_header_t{ lsf = h.lsf; so = h.so; N_li = h.N_li; - for(int i=0;i= nbytes; + int s = get_sdu_space(); + + if (s < 0) { + return false; + } else { + return (uint32_t)s >= nbytes; + } } bool sch_pdu::update_space_sdu(uint32_t nbytes) @@ -495,7 +501,7 @@ bool sch_subh::set_bsr(uint32_t buff_size[4], sch_subh::cetype format) w_payload_ce[1] = (buff_size_table(buff_size[1])&0xf) << 4 | (buff_size_table(buff_size[2])&0xf0)>>4; w_payload_ce[2] = (buff_size_table(buff_size[2])&0x3) << 6 | (buff_size_table(buff_size[3])&0x3f); } else { - w_payload_ce[0] = (nonzero_lcg&0x3)<<6 | buff_size_table(buff_size[nonzero_lcg])&0x3f; + w_payload_ce[0] = (nonzero_lcg&0x3)<<6 | (buff_size_table(buff_size[nonzero_lcg])&0x3f); } lcid = format; ((sch_pdu*)parent)->update_space_ce(ce_size); @@ -569,7 +575,7 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, read_pdu_interfa payload = ((sch_pdu*)parent)->get_current_sdu_ptr(); // Copy data and get final number of bytes written to the MAC PDU - int sdu_sz = sdu_itf->read_pdu(lcid, payload, requested_bytes); + uint32_t sdu_sz = sdu_itf->read_pdu(lcid, payload, requested_bytes); if (sdu_sz < 0 || sdu_sz > requested_bytes) { return -1; @@ -652,7 +658,7 @@ bool sch_subh::read_subheader(uint8_t** ptr) nof_bytes = (uint32_t)*(*ptr) & 0x7f; *ptr += 1; if (F_bit) { - nof_bytes = nof_bytes<<8 | (uint32_t) *(*ptr) & 0xff; + nof_bytes = nof_bytes<<8 | ((uint32_t) *(*ptr) & 0xff); *ptr += 1; } } else { @@ -807,7 +813,7 @@ void rar_subh::set_temp_crnti(uint16_t temp_rnti_) // Section 6.2.2 void rar_subh::write_subheader(uint8_t** ptr, bool is_last) { - *(*ptr) = (uint8_t) (!is_last<<7 | 1<<6 | preamble & 0x3f); + *(*ptr) = (uint8_t) (!is_last<<7 | 1<<6 | (preamble & 0x3f)); *ptr += 1; } // Section 6.2.3 diff --git a/lib/src/common/thread_pool.cc b/lib/src/common/thread_pool.cc index 330a38043..aa9362227 100644 --- a/lib/src/common/thread_pool.cc +++ b/lib/src/common/thread_pool.cc @@ -84,7 +84,7 @@ thread_pool::thread_pool(uint32_t max_workers_) : { max_workers = max_workers_; - for (int i=0;iwarning("TUN/TAP not up - dropping gw RX message\n"); }else{ int n = write(tun_fd, pdu->msg, pdu->N_bytes); - if(pdu->N_bytes != n) + if(n > 0 && (pdu->N_bytes != (uint32_t)n)) { gw_log->warning("DL TUN/TAP write failure\n"); } diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index 5a2106271..a80376b9b 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -372,9 +372,9 @@ void rlc_am::check_reordering_timeout() bool rlc_am::poll_required() { - if(poll_pdu > 0 && pdu_without_poll > poll_pdu) + if(poll_pdu > 0 && pdu_without_poll > (uint32_t)poll_pdu) return true; - if(poll_byte > 0 && byte_without_poll > poll_byte) + if(poll_byte > 0 && byte_without_poll > (uint32_t)poll_byte) return true; if(poll_retx()) return true; @@ -402,7 +402,7 @@ int rlc_am::prepare_status() int rlc_am::build_status_pdu(uint8_t *payload, uint32_t nof_bytes) { int pdu_len = rlc_am_packed_length(&status); - if(nof_bytes >= pdu_len) + if(pdu_len > 0 && nof_bytes >= (uint32_t)pdu_len) { log->info("%s Tx status PDU - %s\n", rb_id_text[lcid], rlc_am_to_string(&status).c_str()); @@ -432,7 +432,7 @@ int rlc_am::build_retx_pdu(uint8_t *payload, uint32_t nof_bytes) } // Is resegmentation needed? - if(retx.is_segment || required_buffer_size(retx) > nof_bytes) { + if(retx.is_segment || required_buffer_size(retx) > (int)nof_bytes) { log->debug("%s build_retx_pdu - resegmentation required\n", rb_id_text[lcid]); return build_segment(payload, nof_bytes, retx); } @@ -506,7 +506,7 @@ int rlc_am::build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t r uint32_t upper = 0; uint32_t li = 0; - for(int i=0; i= retx.so_end) break; @@ -561,7 +561,7 @@ int rlc_am::build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t r debug_state(); int pdu_len = (ptr-payload) + len; - if(pdu_len > nof_bytes) { + if(pdu_len > (int)nof_bytes) { log->error("%s Retx PDU segment length error. Available: %d, Used: %d\n", rb_id_text[lcid], nof_bytes, pdu_len); log->debug("%s Retx PDU segment length error. Header len: %d, Payload len: %d, N_li: %d\n", @@ -784,8 +784,8 @@ void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_h if( vr_x == vr_r || (RX_MOD_BASE(vr_x) < RX_MOD_BASE(vr_r) || - RX_MOD_BASE(vr_x) > RX_MOD_BASE(vr_mr) && - vr_x != vr_mr) + (RX_MOD_BASE(vr_x) > RX_MOD_BASE(vr_mr) && + vr_x != vr_mr)) ) { reordering_timeout.reset(); @@ -902,7 +902,7 @@ void rlc_am::handle_control_pdu(uint8_t *payload, uint32_t nof_bytes) std::map::iterator it; bool nack = false; - for(int j=0;jmsg[rx_sdu->N_bytes], rx_window[vr_r].buf->msg, len); @@ -1076,7 +1076,7 @@ bool rlc_am::add_segment_and_check(rlc_amd_rx_pdu_segments_t *pdu, rlc_amd_rx_pd if(it->header.N_li > 0) { header.li[header.N_li++] = it->header.li[0] + carryover; count += it->header.li[0]; - for(int i=1; iheader.N_li; i++) { + for(uint32_t i=1; iheader.N_li; i++) { header.li[header.N_li++] = it->header.li[i]; count += it->header.li[i]; } @@ -1134,7 +1134,7 @@ int rlc_am::required_buffer_size(rlc_amd_retx_t retx) uint32_t upper = 0; uint32_t li = 0; - for(int i=0; i= retx.so_end) break; @@ -1448,7 +1448,7 @@ std::string rlc_am_to_string(rlc_status_pdu_t *status) if(status->N_nack > 0) { ss << ", NACK_SN = "; - for(int i=0; iN_nack; i++) + for(uint32_t i=0; iN_nack; i++) { if(status->nacks[i].has_so) { ss << "[" << status->nacks[i].nack_sn << " " << status->nacks[i].so_start \ diff --git a/lib/src/upper/rlc_um.cc b/lib/src/upper/rlc_um.cc index 08b8a492e..ea01a6f7f 100644 --- a/lib/src/upper/rlc_um.cc +++ b/lib/src/upper/rlc_um.cc @@ -295,7 +295,8 @@ int rlc_um::build_data_pdu(uint8_t *payload, uint32_t nof_bytes) // Check for SDU segment if(tx_sdu) { - to_move = ((pdu_space-head_len) >= tx_sdu->N_bytes) ? tx_sdu->N_bytes : pdu_space-head_len; + uint32_t space = pdu_space-head_len; + to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; log->debug("%s adding remainder of SDU segment - %d bytes of %d remaining\n", rb_id_text[lcid], to_move, tx_sdu->N_bytes); memcpy(pdu_ptr, tx_sdu->msg, to_move); @@ -323,7 +324,8 @@ int rlc_um::build_data_pdu(uint8_t *payload, uint32_t nof_bytes) header.li[header.N_li++] = last_li; head_len = rlc_um_packed_length(&header); tx_sdu_queue.read(&tx_sdu); - to_move = ((pdu_space-head_len) >= tx_sdu->N_bytes) ? tx_sdu->N_bytes : pdu_space-head_len; + uint32_t space = pdu_space-head_len; + to_move = space >= tx_sdu->N_bytes ? tx_sdu->N_bytes : space; log->debug("%s adding new SDU segment - %d bytes of %d remaining\n", rb_id_text[lcid], to_move, tx_sdu->N_bytes); memcpy(pdu_ptr, tx_sdu->msg, to_move); @@ -445,14 +447,14 @@ void rlc_um::reassemble_rx_sdus() rx_sdu->reset(); }else{ // Handle any SDU segments - for(int i=0; imsg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, len); rx_sdu->N_bytes += len; rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->N_bytes -= len; - if(pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi) || vr_ur != ((vr_ur_in_rx_sdu+1)%rx_mod)) { + if((pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) || (vr_ur != ((vr_ur_in_rx_sdu+1)%rx_mod))) { log->warning("Dropping remainder of lost PDU (lower edge middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)\n", vr_ur, vr_ur_in_rx_sdu); rx_sdu->reset(); } else { @@ -497,7 +499,7 @@ void rlc_um::reassemble_rx_sdus() while(rx_window.end() != rx_window.find(vr_ur)) { // Handle any SDU segments - for(int i=0; imsg[rx_sdu->N_bytes], rx_window[vr_ur].buf->msg, len); @@ -506,7 +508,7 @@ void rlc_um::reassemble_rx_sdus() rx_sdu->N_bytes += len; rx_window[vr_ur].buf->msg += len; rx_window[vr_ur].buf->N_bytes -= len; - if(pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi) || vr_ur != ((vr_ur_in_rx_sdu+1)%rx_mod)) { + if((pdu_lost && !rlc_um_start_aligned(rx_window[vr_ur].header.fi)) || (vr_ur != ((vr_ur_in_rx_sdu+1)%rx_mod))) { log->warning("Dropping remainder of lost PDU (update vr_ur middle segments, vr_ur=%d, vr_ur_in_rx_sdu=%d)\n", vr_ur, vr_ur_in_rx_sdu); rx_sdu->reset(); } else { diff --git a/lib/src/upper/rrc.cc b/lib/src/upper/rrc.cc index 141b54a4a..c33890d82 100644 --- a/lib/src/upper/rrc.cc +++ b/lib/src/upper/rrc.cc @@ -282,7 +282,7 @@ void rrc::write_pdu_bcch_dlsch(byte_buffer_t *pdu) liblte_rrc_si_window_length_num[sib1.si_window_length], liblte_rrc_si_periodicity_num[sib1.sched_info[0].si_periodicity]); std::stringstream ss; - for(int i=0;iinfo("Received paging (%d/%d) for UE 0x%x\n", i+1, pcch_msg.paging_record_list_size, pcch_msg.paging_record_list[i].ue_identity.s_tmsi); @@ -396,7 +396,7 @@ void rrc::send_con_request() // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -409,7 +409,7 @@ void rrc::send_con_request() uint64_t uecri=0; uint8_t *ue_cri_ptr = (uint8_t*) &uecri; uint32_t nbytes = 6; - for (int i=0;imsg[i]; } rrc_log->debug("Setting UE contention resolution ID: %d\n", uecri); @@ -490,7 +490,7 @@ void rrc::send_con_restablish_request() // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -502,7 +502,7 @@ void rrc::send_con_restablish_request() uint64_t uecri=0; uint8_t *ue_cri_ptr = (uint8_t*) &uecri; uint32_t nbytes = 6; - for (int i=0;imsg[i]; } rrc_log->debug("Setting UE contention resolution ID: %d\n", uecri); @@ -527,7 +527,7 @@ void rrc::send_con_restablish_complete() // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -558,7 +558,7 @@ void rrc::send_con_setup_complete(byte_buffer_t *nas_msg) // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -592,7 +592,7 @@ void rrc::send_ul_info_transfer(uint32_t lcid, byte_buffer_t *sdu) // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -616,7 +616,7 @@ void rrc::send_security_mode_complete(uint32_t lcid, byte_buffer_t *pdu) // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -640,7 +640,7 @@ void rrc::send_rrc_con_reconfig_complete(uint32_t lcid, byte_buffer_t *pdu) // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -727,7 +727,7 @@ void rrc::send_rrc_ue_cap_info(uint32_t lcid, byte_buffer_t *pdu) // Byte align and pack the message bits for PDCP if((bit_buf.N_bits % 8) != 0) { - for(int i=0; i<8-(bit_buf.N_bits % 8); i++) + for(uint32_t i=0; i<8-(bit_buf.N_bits % 8); i++) bit_buf.msg[bit_buf.N_bits + i] = 0; bit_buf.N_bits += 8 - (bit_buf.N_bits % 8); } @@ -823,7 +823,7 @@ void rrc::parse_dl_dcch(uint32_t lcid, byte_buffer_t *pdu) break; case LIBLTE_RRC_DL_DCCH_MSG_TYPE_UE_CAPABILITY_ENQUIRY: transaction_id = dl_dcch_msg.msg.ue_cap_enquiry.rrc_transaction_id; - for(int i=0; irlf_timers_and_constants_present) { //TODO } - for(int i=0; isrb_to_add_mod_list_size; i++) { + for(uint32_t i=0; isrb_to_add_mod_list_size; i++) { // TODO: handle SRB modification add_srb(&cnfg->srb_to_add_mod_list[i]); } - for(int i=0; idrb_to_release_list_size; i++) { + for(uint32_t i=0; idrb_to_release_list_size; i++) { release_drb(cnfg->drb_to_release_list[i]); } - for(int i=0; idrb_to_add_mod_list_size; i++) { + for(uint32_t i=0; idrb_to_add_mod_list_size; i++) { // TODO: handle DRB modification add_drb(&cnfg->drb_to_add_mod_list[i]); } diff --git a/lib/test/common/log_filter_test.cc b/lib/test/common/log_filter_test.cc index dd1f34fff..eac0f5f0e 100644 --- a/lib/test/common/log_filter_test.cc +++ b/lib/test/common/log_filter_test.cc @@ -52,6 +52,7 @@ void* thread_loop(void *a) { filter.info("Thread %d: %d", args->thread_id, i); filter.debug("Thread %d: %d", args->thread_id, i); } + return NULL; } void* thread_loop_hex(void *a) { diff --git a/lib/test/upper/rlc_am_control_test.cc b/lib/test/upper/rlc_am_control_test.cc index 7f400ef28..93c09828a 100644 --- a/lib/test/upper/rlc_am_control_test.cc +++ b/lib/test/upper/rlc_am_control_test.cc @@ -47,7 +47,7 @@ int main(int argc, char **argv) { assert(s.N_nack == 0); rlc_am_write_status_pdu(&s, &b2); assert(b2.N_bytes == PDU1_LEN); - for(int i=0;iget()->get_sdu_lcid() == 0) { uint8_t *x = pdu_msg->get()->get_sdu_ptr(); uint32_t sum = 0; - for (int i=0;iget()->get_payload_size();i++) { + for (uint32_t i=0;iget()->get_payload_size();i++) { sum += x[i]; } if (sum == 0) { diff --git a/srsue/src/mac/dl_harq.cc b/srsue/src/mac/dl_harq.cc index 27dc881e5..ffe1fb8eb 100644 --- a/srsue/src/mac/dl_harq.cc +++ b/srsue/src/mac/dl_harq.cc @@ -197,7 +197,7 @@ bool dl_harq_entity::dl_harq_process::is_sps() bool dl_harq_entity::dl_harq_process::calc_is_new_transmission(mac_interface_phy::mac_grant_t grant) { bool is_new_tb = true; - if (srslte_tti_interval(grant.tti, cur_grant.tti) <= 8 && grant.n_bytes == cur_grant.n_bytes || + if ((srslte_tti_interval(grant.tti, cur_grant.tti) <= 8 && (grant.n_bytes == cur_grant.n_bytes)) || pid == HARQ_BCCH_PID) { is_new_tb = false; diff --git a/srsue/src/mac/mux.cc b/srsue/src/mac/mux.cc index a927f9d72..58ba3d57f 100644 --- a/srsue/src/mac/mux.cc +++ b/srsue/src/mac/mux.cc @@ -68,7 +68,7 @@ void mux::reset() bool mux::is_pending_any_sdu() { - for (int i=0;iget_buffer_state(lch[i].id)) { return true; } @@ -82,7 +82,7 @@ bool mux::is_pending_sdu(uint32_t lch_id) { int mux::find_lchid(uint32_t lcid) { - for (int i=0;i= 0) { lch[i].Bj += lch[i].PBR; } - if (lch[i].Bj >= lch[i].BSD) { + if (lch[i].Bj >= (int)lch[i].BSD) { lch[i].Bj = lch[i].BSD*lch[i].PBR; } } @@ -197,14 +198,14 @@ uint8_t* mux::pdu_get(uint8_t *payload, uint32_t pdu_sz, uint32_t tx_tti, uint32 } // Update buffer states for all logical channels int sdu_space = pdu_msg.get_sdu_space(); - for (int i=0;iget_buffer_state(lch[i].id); lch[i].sched_len = 0; } // data from any Logical Channel, except data from UL-CCCH; // first only those with positive Bj - for (int i=0;i= 0) { lch[i].Bj -= lch[i].sched_len; @@ -213,7 +214,7 @@ uint8_t* mux::pdu_get(uint8_t *payload, uint32_t pdu_sz, uint32_t tx_tti, uint32 } // If resources remain, allocate regardless of their Bj value - for (int i=0;i 0) { - for (int i=lch.size()-1;i--;i>=0) { + for (int i=(int)lch.size()-1;i>=0;i--) { if (lch[i].sched_len > 0) { lch[i].sched_len = -1; break; @@ -229,7 +230,7 @@ uint8_t* mux::pdu_get(uint8_t *payload, uint32_t pdu_sz, uint32_t tx_tti, uint32 } } // Now allocate the SDUs from the RLC - for (int i=0;iinfo("Allocating scheduled lch=%d len=%d\n", lch[i].id, lch[i].sched_len); allocate_sdu(lch[i].id, &pdu_msg, lch[i].sched_len); diff --git a/srsue/src/mac/proc_bsr.cc b/srsue/src/mac/proc_bsr.cc index 1f4c40c31..db2e12c15 100644 --- a/srsue/src/mac/proc_bsr.cc +++ b/srsue/src/mac/proc_bsr.cc @@ -222,14 +222,14 @@ void bsr_proc::step(uint32_t tti) } int periodic = liblte_rrc_periodic_bsr_timer_num[mac_cfg->main.ulsch_cnfg.periodic_bsr_timer]; - if (periodic != timers_db->get(mac::BSR_TIMER_PERIODIC)->get_timeout() && periodic > 0) + if (periodic > 0 && (uint32_t)periodic != timers_db->get(mac::BSR_TIMER_PERIODIC)->get_timeout()) { timers_db->get(mac::BSR_TIMER_PERIODIC)->set(this, periodic); timers_db->get(mac::BSR_TIMER_PERIODIC)->run(); Info("BSR: Configured timer periodic %d ms\n", periodic); } int retx = liblte_rrc_retransmission_bsr_timer_num[mac_cfg->main.ulsch_cnfg.retx_bsr_timer]; - if (retx != timers_db->get(mac::BSR_TIMER_RETX)->get_timeout() && retx > 0) + if (retx > 0 && (uint32_t)retx != timers_db->get(mac::BSR_TIMER_RETX)->get_timeout()) { timers_db->get(mac::BSR_TIMER_RETX)->set(this, retx); timers_db->get(mac::BSR_TIMER_RETX)->run(); @@ -279,6 +279,8 @@ char* bsr_proc::bsr_format_tostring(bsr_format_t format) { return (char*) "Short"; case bsr_proc::TRUNC_BSR: return (char*) "Truncated"; + default: + return (char*) "Short"; } } @@ -290,7 +292,7 @@ bool bsr_proc::need_to_send_bsr_on_ul_grant(uint32_t grant_size, bsr_t *bsr) if (triggered_bsr_type == PERIODIC || triggered_bsr_type == REGULAR) { /* Check if grant + MAC SDU headers is enough to accomodate all pending data */ int total_data = 0; - for (int i=0;iget_buffer_state(i))+rlc->get_buffer_state(i); } total_data--; // Because last SDU has no size header @@ -300,7 +302,7 @@ bool bsr_proc::need_to_send_bsr_on_ul_grant(uint32_t grant_size, bsr_t *bsr) */ generate_bsr(bsr, 0); bsr_sz = bsr->format==LONG_BSR?3:1; - if (total_data <= grant_size && total_data + 1 + bsr_sz > grant_size) { + if (total_data <= (int)grant_size && total_data + 1 + bsr_sz > grant_size) { Debug("Grant is not enough to accomodate the BSR MAC CE\n"); } else { Debug("BSR: Including Regular BSR: grant_size=%d, total_data=%d, bsr_sz=%d\n", @@ -390,7 +392,8 @@ void bsr_proc::set_priority(uint32_t lcid, uint32_t priority) { } uint32_t bsr_proc::find_max_priority_lcid() { - uint32_t max_prio = 0, max_idx = 0; + int32_t max_prio = 0; + uint32_t max_idx = 0; for (int i=0;i max_prio) { max_prio = priorities[i]; diff --git a/srsue/src/mac/proc_ra.cc b/srsue/src/mac/proc_ra.cc index 88e1a74e5..495c9945f 100644 --- a/srsue/src/mac/proc_ra.cc +++ b/srsue/src/mac/proc_ra.cc @@ -450,7 +450,7 @@ void ra_proc::step_contention_resolution() { { // Random Access with transmission of MAC C-RNTI CE if ((!started_by_pdcch && pdcch_to_crnti_received == PDCCH_CRNTI_UL_GRANT) || - started_by_pdcch && pdcch_to_crnti_received != PDCCH_CRNTI_NOT_RECEIVED) + (started_by_pdcch && pdcch_to_crnti_received != PDCCH_CRNTI_NOT_RECEIVED)) { rDebug("PDCCH for C-RNTI received\n"); timers_db->get(mac::CONTENTION_TIMER)->stop(); @@ -515,6 +515,7 @@ void ra_proc::step(uint32_t tti_) case COMPLETION: step_completition(); case COMPLETION_DONE: + case RA_PROBLEM: break; } } diff --git a/srsue/src/mac/proc_sr.cc b/srsue/src/mac/proc_sr.cc index 0aa7fb77e..afd2b7b5a 100644 --- a/srsue/src/mac/proc_sr.cc +++ b/srsue/src/mac/proc_sr.cc @@ -57,7 +57,7 @@ bool sr_proc::need_tx(uint32_t tti) { int last_tx_tti = phy_h->sr_last_tx_tti(); if (last_tx_tti >= 0) { - if (tti > last_tx_tti) { + if (tti > (uint32_t)last_tx_tti) { if (tti - last_tx_tti > 8) { return true; } diff --git a/srsue/src/mac/ul_harq.cc b/srsue/src/mac/ul_harq.cc index 43cafef65..06bcbfd1b 100644 --- a/srsue/src/mac/ul_harq.cc +++ b/srsue/src/mac/ul_harq.cc @@ -95,7 +95,7 @@ void ul_harq_entity::set_ack(uint32_t tti, bool ack) { tti_harq += 10240; } uint32_t pid_harq = pidof(tti_harq); - if (proc[pid_harq].has_grant() && proc[pid_harq].last_tx_tti() <= tti_harq) { + if (proc[pid_harq].has_grant() && (proc[pid_harq].last_tx_tti() <= (uint32_t)tti_harq)) { proc[pid_harq].set_harq_feedback(ack); } } @@ -228,7 +228,7 @@ void ul_harq_entity::ul_harq_process::run_tti(uint32_t tti_tx, mac_interface_phy { - int max_retx; + uint32_t max_retx; if (is_msg3) { max_retx = harq_entity->mac_cfg->rach.max_harq_msg3_tx; } else { @@ -238,7 +238,7 @@ void ul_harq_entity::ul_harq_process::run_tti(uint32_t tti_tx, mac_interface_phy // Receive and route HARQ feedbacks if (grant) { - if ((!grant->rnti_type == SRSLTE_RNTI_TEMP && grant->ndi != get_ndi()) || + if ((!(grant->rnti_type == SRSLTE_RNTI_TEMP) && grant->ndi != get_ndi()) || (grant->rnti_type == SRSLTE_RNTI_USER && !has_grant()) || grant->is_from_rar) { diff --git a/srsue/src/phy/phch_common.cc b/srsue/src/phy/phch_common.cc index 0fe112ec4..3c3987863 100644 --- a/srsue/src/phy/phch_common.cc +++ b/srsue/src/phy/phch_common.cc @@ -84,7 +84,7 @@ void phch_common::init(phy_interface_rrc::phy_cfg_t *_config, phy_args_t *_args, is_first_tx = true; sr_last_tx_tti = -1; - for (int i=0;i= ul_rnti_start && ul_rnti_start >= 0 || ul_rnti_start < 0) && - (tti < ul_rnti_end && ul_rnti_end >= 0 || ul_rnti_end < 0)) + if ((((int)tti >= ul_rnti_start && ul_rnti_start >= 0) || ul_rnti_start < 0) && + (((int)tti < ul_rnti_end && ul_rnti_end >= 0) || ul_rnti_end < 0)) { return true; } else { @@ -106,8 +106,8 @@ bool phch_common::ul_rnti_active(uint32_t tti) { bool phch_common::dl_rnti_active(uint32_t tti) { Debug("tti=%d, dl_rnti_start=%d, dl_rnti_end=%d, dl_rnti=0x%x\n", tti, dl_rnti_start, dl_rnti_end, dl_rnti); - if (((tti >= dl_rnti_start && dl_rnti_start >= 0) || dl_rnti_start < 0) && - ((tti < dl_rnti_end && dl_rnti_end >= 0) || dl_rnti_end < 0)) + if ((((int)tti >= dl_rnti_start && dl_rnti_start >= 0) || dl_rnti_start < 0) && + (((int)tti < dl_rnti_end && dl_rnti_end >= 0) || dl_rnti_end < 0)) { bool ret = true; // FIXME: This scheduling decision belongs to RRC @@ -325,7 +325,7 @@ void phch_common::reset_ul() { is_first_tx = true; is_first_of_burst = true; - for (int i=0;iget_nof_workers();i++) { + for (uint32_t i=0;iget_nof_workers();i++) { if (!((phch_worker*) workers_pool->get_worker(i))->init_cell(cell)) { Error("Error setting cell: initiating PHCH worker\n"); return false; @@ -180,7 +180,7 @@ bool phch_recv::init_cell() { void phch_recv::free_cell() { if (cell_is_set) { - for (int i=0;iget_nof_workers();i++) { + for (uint32_t i=0;iget_nof_workers();i++) { ((phch_worker*) workers_pool->get_worker(i))->free_cell(); } prach_buffer->free_cell(); @@ -402,7 +402,7 @@ void phch_recv::run_thread() worker = (phch_worker*) workers_pool->wait_worker(tti); sync_res = 0; if (worker) { - for (int i=0;iget_buffer(i); } diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index e0ed424f0..5f842c0f9 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -93,7 +93,7 @@ bool phch_worker::init_cell(srslte_cell_t cell_) memcpy(&cell, &cell_, sizeof(srslte_cell_t)); // ue_sync in phy.cc requires a buffer for 3 subframes - for (int i=0;iargs->nof_rx_ant;i++) { + for (uint32_t i=0;iargs->nof_rx_ant;i++) { signal_buffer[i] = (cf_t*) srslte_vec_malloc(3 * sizeof(cf_t) * SRSLTE_SF_LEN_PRB(cell.nof_prb)); if (!signal_buffer[i]) { Error("Allocating memory\n"); @@ -121,7 +121,7 @@ bool phch_worker::init_cell(srslte_cell_t cell_) void phch_worker::free_cell() { if (cell_initiated) { - for (int i=0;iargs->nof_rx_ant;i++) { + for (uint32_t i=0;iargs->nof_rx_ant;i++) { if (signal_buffer[i]) { free(signal_buffer[i]); } @@ -950,7 +950,7 @@ void phch_worker::start_plot() { } int phch_worker::read_ce_abs(float *ce_abs) { - int i=0; + uint32_t i=0; int sz = srslte_symbol_sz(cell.nof_prb); bzero(ce_abs, sizeof(float)*sz); int g = (sz - 12*cell.nof_prb)/2; diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index bd11a5490..3b76cb983 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -118,7 +118,7 @@ bool phy::init(srslte::radio_multi* radio_handler_, mac_interface_phy *mac, rrc_ nof_workers = args->nof_phy_threads; // Add workers to workers pool and start threads - for (int i=0;iworker_cpu_mask); } @@ -141,14 +141,14 @@ void phy::set_agc_enable(bool enabled) void phy::start_trace() { - for (int i=0;i( &(ostringstream() << i) )->str(); workers[i].write_trace(filename + "_" + i_str); } @@ -200,7 +200,7 @@ void phy::configure_prach_params() void phy::configure_ul_params(bool pregen_disabled) { Info("PHY: Configuring UL parameters\n"); - for (int i=0;iconfigure_ul_params(); // Setup radio bearers - for (int i=0;irr_cnfg.srb_to_add_mod_list_size;i++) { + for (uint32_t i=0;irr_cnfg.srb_to_add_mod_list_size;i++) { if (msg->rr_cnfg.srb_to_add_mod_list[i].lc_default_cnfg_present) { printf("Setting up Default Configuration for SRB%d \n", msg->rr_cnfg.srb_to_add_mod_list[i].srb_id); switch(msg->rr_cnfg.srb_to_add_mod_list[i].srb_id) { @@ -315,7 +315,7 @@ public: uint8_t *ue_cri_ptr = (uint8_t*) &uecri; uint32_t nbytes = bit_msg.N_bits/8; uint8_t *ptr = bit_msg.msg; - for (int i=0;iconsole("SIB1 received, CellID=%d, %s\n", @@ -250,13 +250,13 @@ public: // Send Msg3 sdu->N_bytes = 10; - for (int i=0;iN_bytes;i++) { + for (uint32_t i=0;iN_bytes;i++) { sdu->msg[i] = i+1; } uint64_t uecri = 0; uint8_t *ue_cri_ptr = (uint8_t*) &uecri; uint32_t nbytes = 6; - for (int i=0;imsg[i]; } log_h->info("Setting UE contention resolution ID: %d\n", uecri); @@ -274,7 +274,7 @@ public: void write_pdu(uint32_t lcid, srslte::byte_buffer_t *sdu) { - int n=0; + uint32_t n=0; switch(lcid) { case LCID: n = write(tun_fd, sdu->msg, sdu->N_bytes);