diff --git a/lib/include/srslte/common/block_queue.h b/lib/include/srslte/common/block_queue.h index 63b0e4177..2e476dd65 100644 --- a/lib/include/srslte/common/block_queue.h +++ b/lib/include/srslte/common/block_queue.h @@ -122,7 +122,7 @@ public: } void clear() { // remove all items - myobj item; + myobj *item = NULL; while (try_pop(item)); } diff --git a/lib/include/srslte/phy/utils/mat.h b/lib/include/srslte/phy/utils/mat.h index 8db0205f9..c8465b34e 100644 --- a/lib/include/srslte/phy/utils/mat.h +++ b/lib/include/srslte/phy/utils/mat.h @@ -166,8 +166,13 @@ static inline void srslte_mat_2x2_mmse_csi_simd(simd_cf_t y0, simd_cf_t _noise_estimate; simd_f_t _norm = srslte_simd_f_set1(norm); +#if HAVE_NEON + _noise_estimate.val[0] = srslte_simd_f_set1(noise_estimate); + _noise_estimate.val[1] = srslte_simd_f_zero(); +#else /* HAVE_NEON */ _noise_estimate.re = srslte_simd_f_set1(noise_estimate); _noise_estimate.im = srslte_simd_f_zero(); +#endif /* HAVE_NEON */ /* 1. A = H' x H + No*/ simd_cf_t a00 = diff --git a/lib/include/srslte/phy/utils/simd.h b/lib/include/srslte/phy/utils/simd.h index 6f2e18e46..491c1f661 100644 --- a/lib/include/srslte/phy/utils/simd.h +++ b/lib/include/srslte/phy/utils/simd.h @@ -139,7 +139,7 @@ #define SRSLTE_SIMD_S_SIZE 8 #define SRSLTE_SIMD_C16_SIZE 8 -#else /* LV_HAVE_NEON */ +#else /* HAVE_NEON */ #define SRSLTE_SIMD_F_SIZE 0 #define SRSLTE_SIMD_CF_SIZE 0 @@ -514,7 +514,7 @@ static inline simd_f_t srslte_simd_f_abs(simd_f_t a) { return _mm_andnot_ps(_mm_set1_ps(-0.0f), a); #else /* LV_HAVE_SSE */ #ifdef HAVE_NEON - return vqabsq_s32(a); + return vabsq_f32(a); #endif /* HAVE_NEON */ #endif /* LV_HAVE_SSE */ #endif /* LV_HAVE_AVX2 */ @@ -990,13 +990,13 @@ static inline simd_cf_t srslte_simd_cf_rcp (simd_cf_t a) { static inline simd_cf_t srslte_simd_cf_neg (simd_cf_t a) { simd_cf_t ret; -#if LV_HAVE_NEON +#if HAVE_NEON ret.val[0] = srslte_simd_f_neg(a.val[0]); ret.val[1] = srslte_simd_f_neg(a.val[1]); -#else /* LV_HAVE_NEON */ +#else /* HAVE_NEON */ ret.re = srslte_simd_f_neg(a.re); ret.im = srslte_simd_f_neg(a.im); -#endif /* LV_HAVE_NEON */ +#endif /* HAVE_NEON */ return ret; } @@ -1007,37 +1007,37 @@ static inline simd_cf_t srslte_simd_cf_neg_mask (simd_cf_t a, simd_f_t mask) { mask = _mm256_permutevar8x32_ps(mask, _mm256_setr_epi32(0,4,1,5,2,6,3,7)); #endif /* LV_HAVE_AVX2 */ #endif /* LV_HAVE_AVX512 */ -#if LV_HAVE_NEON +#if HAVE_NEON ret.val[0] = srslte_simd_f_neg_mask(a.val[0], mask); ret.val[1] = srslte_simd_f_neg_mask(a.val[1], mask); -#else /* LV_HAVE_NEON */ +#else /* HAVE_NEON */ ret.re = srslte_simd_f_neg_mask(a.re, mask); ret.im = srslte_simd_f_neg_mask(a.im, mask); -#endif /* LV_HAVE_NEON */ +#endif /* HAVE_NEON */ return ret; } static inline simd_cf_t srslte_simd_cf_conj (simd_cf_t a) { simd_cf_t ret; -#if LV_HAVE_NEON +#if HAVE_NEON ret.val[0] = a.val[0]; ret.val[1] = srslte_simd_f_neg(a.val[1]); -#else /* LV_HAVE_NEON */ +#else /* HAVE_NEON */ ret.re = a.re; ret.im = srslte_simd_f_neg(a.im); -#endif /* LV_HAVE_NEON */ +#endif /* HAVE_NEON */ return ret; } static inline simd_cf_t srslte_simd_cf_mulj (simd_cf_t a) { simd_cf_t ret; -#if LV_HAVE_NEON +#if HAVE_NEON ret.val[0] = srslte_simd_f_neg(a.val[1]); ret.val[1] = a.val[0]; -#else /* LV_HAVE_NEON */ +#else /* HAVE_NEON */ ret.re = srslte_simd_f_neg(a.im); ret.im = a.re; -#endif /* LV_HAVE_NEON */ +#endif /* HAVE_NEON */ return ret; } diff --git a/lib/include/srslte/upper/rlc_metrics.h b/lib/include/srslte/upper/rlc_metrics.h index ab6e83c02..153fba57b 100644 --- a/lib/include/srslte/upper/rlc_metrics.h +++ b/lib/include/srslte/upper/rlc_metrics.h @@ -27,13 +27,15 @@ #ifndef SRSLTE_RLC_METRICS_H #define SRSLTE_RLC_METRICS_H +#include "srslte/common/common.h" namespace srslte { struct rlc_metrics_t { - float dl_tput_mbps; - float ul_tput_mbps; + float dl_tput_mbps[SRSLTE_N_RADIO_BEARERS]; + float ul_tput_mbps[SRSLTE_N_RADIO_BEARERS]; + float dl_tput_mrb_mbps[SRSLTE_N_MCH_LCIDS]; }; } // namespace srslte diff --git a/lib/src/phy/rf/rf_blade_imp.c b/lib/src/phy/rf/rf_blade_imp.c index 41a047bdc..71e5025b5 100644 --- a/lib/src/phy/rf/rf_blade_imp.c +++ b/lib/src/phy/rf/rf_blade_imp.c @@ -404,16 +404,16 @@ double rf_blade_set_tx_freq(void *h, double freq) void rf_blade_set_tx_cal(void *h, srslte_rf_cal_t *cal) { rf_blade_handler_t *handler = (rf_blade_handler_t*) h; - bladerf_set_correction(handler->dev, BLADERF_MODULE_TX, BLADERF_CORR_FPGA_PHASE, cal->dc_gain); - bladerf_set_correction(handler->dev, BLADERF_MODULE_TX, BLADERF_CORR_FPGA_GAIN, cal->dc_phase); + bladerf_set_correction(handler->dev, BLADERF_MODULE_TX, BLADERF_CORR_FPGA_PHASE, cal->dc_phase); + bladerf_set_correction(handler->dev, BLADERF_MODULE_TX, BLADERF_CORR_FPGA_GAIN, cal->dc_gain); bladerf_set_correction(handler->dev, BLADERF_MODULE_TX, BLADERF_CORR_LMS_DCOFF_I, cal->iq_i); bladerf_set_correction(handler->dev, BLADERF_MODULE_TX, BLADERF_CORR_LMS_DCOFF_Q, cal->iq_q); } void rf_blade_set_rx_cal(void *h, srslte_rf_cal_t *cal) { rf_blade_handler_t *handler = (rf_blade_handler_t*) h; - bladerf_set_correction(handler->dev, BLADERF_MODULE_RX, BLADERF_CORR_FPGA_PHASE, cal->dc_gain); - bladerf_set_correction(handler->dev, BLADERF_MODULE_RX, BLADERF_CORR_FPGA_GAIN, cal->dc_phase); + bladerf_set_correction(handler->dev, BLADERF_MODULE_RX, BLADERF_CORR_FPGA_PHASE, cal->dc_phase); + bladerf_set_correction(handler->dev, BLADERF_MODULE_RX, BLADERF_CORR_FPGA_GAIN, cal->dc_gain); bladerf_set_correction(handler->dev, BLADERF_MODULE_RX, BLADERF_CORR_LMS_DCOFF_I, cal->iq_i); bladerf_set_correction(handler->dev, BLADERF_MODULE_RX, BLADERF_CORR_LMS_DCOFF_Q, cal->iq_q); } diff --git a/lib/src/phy/rf/rf_soapy_imp.c b/lib/src/phy/rf/rf_soapy_imp.c index a0dcc6542..26ad5bac0 100644 --- a/lib/src/phy/rf/rf_soapy_imp.c +++ b/lib/src/phy/rf/rf_soapy_imp.c @@ -228,7 +228,7 @@ int rf_soapy_start_rx_stream(void *h, bool now) { rf_soapy_handler_t *handler = (rf_soapy_handler_t*) h; if(handler->rx_stream_active == false){ - if(SoapySDRDevice_activateStream(handler->device, handler->rxStream, 0, 0, 0) != 0) + if(SoapySDRDevice_activateStream(handler->device, handler->rxStream, SOAPY_SDR_HAS_TIME | SOAPY_SDR_END_BURST, 0, 0) != 0) return SRSLTE_ERROR; handler->rx_stream_active = true; } @@ -339,9 +339,19 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) rf_soapy_set_rx_srate(handler, 1.92e6); rf_soapy_set_tx_srate(handler, 1.92e6); - if(SoapySDRDevice_getNumChannels(handler->device, SOAPY_SDR_RX) > 0){ + size_t channels = SoapySDRDevice_getNumChannels(handler->device, SOAPY_SDR_RX); + + if((channels > 0) && (nof_rx_antennas > 0)){ printf("Setting up RX stream\n"); - if(SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, NULL, 0, NULL) != 0) { + size_t numChannels = channels; + if (channels > nof_rx_antennas) { + numChannels = nof_rx_antennas; + } + size_t rx_channels[numChannels]; + for(int i = 0 ; i < numChannels ; i++) { + rx_channels[i] = i; + } + if(SoapySDRDevice_setupStream(handler->device, &(handler->rxStream), SOAPY_SDR_RX, SOAPY_SDR_CF32, rx_channels, numChannels, NULL) != 0) { printf("Rx setupStream fail: %s\n", SoapySDRDevice_lastError()); return SRSLTE_ERROR; } @@ -439,9 +449,11 @@ int rf_soapy_open_multi(char *args, void **h, uint32_t nof_rx_antennas) #if HAVE_ASYNC_THREAD bool start_async_thread = true; - if (strstr(args, "silent")) { - REMOVE_SUBSTRING_WITHCOMAS(args, "silent"); - start_async_thread = false; + if (args) { + if (strstr(args, "silent")) { + REMOVE_SUBSTRING_WITHCOMAS(args, "silent"); + start_async_thread = false; + } } #endif @@ -839,7 +851,7 @@ int rf_soapy_send_timed_multi(void *h, // Convert initial tx time if (has_time_spec) { - timeNs = secs * 1000000000; + timeNs = (long long)secs * 1000000000; timeNs = timeNs + (frac_secs * 1000000000); } diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index 202b47b8d..5439db828 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -788,17 +788,17 @@ int rf_uhd_recv_with_time_multi(void *h, rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h; uhd_rx_metadata_handle *md = &handler->rx_md_first; size_t rxd_samples = 0; + size_t rxd_samples_total = 0; int trials = 0; if (blocking) { - int n = 0; - while (n < nsamples && trials < 100) { + while (rxd_samples_total < nsamples && trials < 100) { void *buffs_ptr[4]; for (int i=0;inof_rx_channels;i++) { cf_t *data_c = (cf_t*) data[i]; - buffs_ptr[i] = &data_c[n]; + buffs_ptr[i] = &data_c[rxd_samples_total]; } - size_t num_samps_left = nsamples - n; + size_t num_samps_left = nsamples - rxd_samples_total; size_t num_rx_samples = (num_samps_left > handler->rx_nof_samples) ? handler->rx_nof_samples : num_samps_left; rxd_samples = 0; @@ -814,7 +814,7 @@ int rf_uhd_recv_with_time_multi(void *h, uhd_rx_metadata_error_code(*md, &error_code); md = &handler->rx_md; - n += rxd_samples; + rxd_samples_total += rxd_samples; trials++; if (error_code == UHD_RX_METADATA_ERROR_CODE_OVERFLOW) { @@ -830,6 +830,7 @@ int rf_uhd_recv_with_time_multi(void *h, } } else { uhd_error error = uhd_rx_streamer_recv(handler->rx_stream, data, nsamples, md, 0.0, false, &rxd_samples); + rxd_samples_total = rxd_samples; if (error) { fprintf(stderr, "Error receiving from UHD: %d\n", error); log_rx_error(handler); @@ -839,7 +840,7 @@ int rf_uhd_recv_with_time_multi(void *h, if (secs && frac_secs) { uhd_rx_metadata_time_spec(handler->rx_md_first, secs, frac_secs); } - return nsamples; + return rxd_samples_total; } int rf_uhd_send_timed(void *h, diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 413da1364..e32e64bc7 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -117,13 +117,10 @@ void rlc::get_metrics(rlc_metrics_t &m) gettimeofday(&metrics_time[2], NULL); get_time_interval(metrics_time); double secs = (double)metrics_time[0].tv_sec + metrics_time[0].tv_usec*1e-6; - - m.dl_tput_mbps = 0; - m.ul_tput_mbps = 0; for (rlc_map_t::iterator it = rlc_array.begin(); it != rlc_array.end(); ++it) { - m.dl_tput_mbps += (it->second->get_num_rx_bytes()*8/(double)1e6)/secs; - m.ul_tput_mbps += (it->second->get_num_tx_bytes()*8/(double)1e6)/secs; + m.dl_tput_mbps[it->first] = (it->second->get_num_rx_bytes()*8/static_cast(1e6))/secs; + m.ul_tput_mbps[it->first] = (it->second->get_num_tx_bytes()*8/static_cast(1e6))/secs; rlc_log->info("LCID=%d, RX throughput: %4.6f Mbps. TX throughput: %4.6f Mbps.\n", it->first, (it->second->get_num_rx_bytes()*8/(double)1e6)/secs, @@ -132,10 +129,10 @@ void rlc::get_metrics(rlc_metrics_t &m) // Add multicast metrics for (rlc_map_t::iterator it = rlc_array_mrb.begin(); it != rlc_array_mrb.end(); ++it) { - m.dl_tput_mbps += (it->second->get_num_rx_bytes()*8/(double)1e6)/secs; + m.dl_tput_mbps[it->first] = (it->second->get_num_rx_bytes()*8/static_cast(1e6))/secs; rlc_log->info("MCH_LCID=%d, RX throughput: %4.6f Mbps\n", it->first, - (it->second->get_num_rx_bytes()*8/(double)1e6)/secs); + (it->second->get_num_rx_bytes()*8/static_cast(1e6))/secs); } memcpy(&metrics_time[1], &metrics_time[2], sizeof(struct timeval)); diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index ec02a699a..9da13c12c 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -374,16 +374,16 @@ void stress_test(stress_test_args_t args) tester1.get_nof_rx_pdus(), args.test_duration_sec, (float)tester1.get_nof_rx_pdus()/args.test_duration_sec, - metrics.dl_tput_mbps, - metrics.ul_tput_mbps); + metrics.dl_tput_mbps[lcid], + metrics.ul_tput_mbps[lcid]); rlc2.get_metrics(metrics); printf("RLC2 received %d SDUs in %ds (%.2f PDU/s), Throughput: DL=%4.2f Mbps, UL=%4.2f Mbps\n", tester2.get_nof_rx_pdus(), args.test_duration_sec, (float)tester2.get_nof_rx_pdus()/args.test_duration_sec, - metrics.dl_tput_mbps, - metrics.ul_tput_mbps); + metrics.dl_tput_mbps[lcid], + metrics.ul_tput_mbps[lcid]); } diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index ef5a5cbad..3212da983 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -1073,7 +1073,7 @@ void phch_worker::ue::metrics_ul(uint32_t mcs, float rssi, float sinr, uint32_t { metrics.ul.mcs = SRSLTE_VEC_CMA((float) mcs, metrics.ul.mcs, metrics.ul.n_samples); metrics.ul.sinr = SRSLTE_VEC_CMA((float) sinr, metrics.ul.sinr, metrics.ul.n_samples); - metrics.ul.rssi = SRSLTE_VEC_CMA((float) sinr, metrics.ul.rssi, metrics.ul.n_samples); + metrics.ul.rssi = SRSLTE_VEC_CMA((float) rssi, metrics.ul.rssi, metrics.ul.n_samples); metrics.ul.turbo_iters = SRSLTE_VEC_CMA((float) turbo_iters, metrics.ul.turbo_iters, metrics.ul.n_samples); metrics.ul.n_samples++; } diff --git a/srsue/hdr/mac/mac_metrics.h b/srsue/hdr/mac/mac_metrics.h index a201d2a7f..56d20dcdc 100644 --- a/srsue/hdr/mac/mac_metrics.h +++ b/srsue/hdr/mac/mac_metrics.h @@ -39,6 +39,8 @@ struct mac_metrics_t int rx_errors; int rx_brate; int ul_buffer; + float dl_retx_avg; + float ul_retx_avg; }; } // namespace srsue diff --git a/srsue/src/mac/mac.cc b/srsue/src/mac/mac.cc index fc050bcc7..964e394e9 100644 --- a/srsue/src/mac/mac.cc +++ b/srsue/src/mac/mac.cc @@ -477,6 +477,8 @@ void mac::get_metrics(mac_metrics_t &m) ul_harq.get_average_retx()); metrics.ul_buffer = (int) bsr_procedure.get_buffer_state(); + metrics.dl_retx_avg = dl_harq.get_average_retx(); + metrics.ul_retx_avg = ul_harq.get_average_retx(); m = metrics; bzero(&metrics, sizeof(mac_metrics_t)); } diff --git a/srsue/src/mac/proc_ra.cc b/srsue/src/mac/proc_ra.cc index 5b5b56ee7..11e53195c 100644 --- a/srsue/src/mac/proc_ra.cc +++ b/srsue/src/mac/proc_ra.cc @@ -237,7 +237,8 @@ void ra_proc::step_resource_selection() { } if (sel_group == RA_GROUP_A) { if (nof_groupA_preambles) { - sel_preamble = preambleTransmissionCounter%nof_groupA_preambles; + // randomly choose preamble from [0 nof_groupA_preambles) + sel_preamble = rand() % nof_groupA_preambles; } else { rError("Selected group preamble A but nof_groupA_preambles=0\n"); state = RA_PROBLEM; @@ -245,7 +246,8 @@ void ra_proc::step_resource_selection() { } } else { if (nof_groupB_preambles) { - sel_preamble = nof_groupA_preambles + rand()%nof_groupB_preambles; + // randomly choose preamble from [nof_groupA_preambles nof_groupB_preambles) + sel_preamble = nof_groupA_preambles + rand() % nof_groupB_preambles; } else { rError("Selected group preamble B but nof_groupA_preambles=0\n"); state = RA_PROBLEM; @@ -254,7 +256,7 @@ void ra_proc::step_resource_selection() { } sel_maskIndex = 0; } - + rDebug("Selected preambleIndex=%d maskIndex=%d GroupA=%d, GroupB=%d\n", sel_preamble, sel_maskIndex,nof_groupA_preambles, nof_groupB_preambles); state = PREAMBLE_TRANSMISSION;