diff --git a/CMakeLists.txt b/CMakeLists.txt index 290754ee3..df9cf4f32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,7 +226,7 @@ macro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have) endmacro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -Wall -Wno-comment -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wformat -std=c++03") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -Wall -Wno-comment -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wformat -Wmissing-field-initializers -Wtype-limits -std=c++03") find_package(SSE) if (HAVE_AVX2) @@ -243,7 +243,7 @@ endif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clan ADD_CXX_COMPILER_FLAG_IF_AVAILABLE("-Werror=incompatible-pointer-types" HAVE_ERROR_INCOMPATIBLE) if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -Wall -Wno-comment -Wno-write-strings -Wno-format-extra-args -Winline -Wno-unused-result -Wno-format -std=c99 -D_GNU_SOURCE") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -Wall -Wno-comment -Wno-write-strings -Winline -Wno-unused-result -Wformat -Wmissing-field-initializers -Wtype-limits -std=c99 -D_GNU_SOURCE") if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -O0 -DDEBUG_MODE -DBUILD_TYPE_DEBUG") diff --git a/lib/examples/synch_file.c b/lib/examples/synch_file.c index 4d553bd38..c73e8d9dc 100644 --- a/lib/examples/synch_file.c +++ b/lib/examples/synch_file.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) { uint32_t m0, m1; float m0_value, m1_value; uint32_t N_id_2; - uint32_t sss_idx; + int sss_idx; struct timeval tdata[3]; int *exec_time; diff --git a/lib/include/srslte/common/buffer_pool.h b/lib/include/srslte/common/buffer_pool.h index 1895c8330..eee04caa8 100644 --- a/lib/include/srslte/common/buffer_pool.h +++ b/lib/include/srslte/common/buffer_pool.h @@ -93,6 +93,10 @@ public: #endif } + uint32_t nof_available_pdus() { + return available.size(); + } + bool is_almost_empty() { return available.size() < capacity/20; } diff --git a/lib/include/srslte/common/common.h b/lib/include/srslte/common/common.h index b7130f6d5..5668454e0 100644 --- a/lib/include/srslte/common/common.h +++ b/lib/include/srslte/common/common.h @@ -72,6 +72,8 @@ #define pool_allocate (pool->allocate()) #endif +#define ZERO_OBJECT(x) memset(&(x), 0x0, sizeof((x))) + #include "srslte/srslte.h" /******************************************************************************* diff --git a/lib/include/srslte/common/log.h b/lib/include/srslte/common/log.h index b47f79d90..79dbdc088 100644 --- a/lib/include/srslte/common/log.h +++ b/lib/include/srslte/common/log.h @@ -129,13 +129,13 @@ public: virtual void debug(const char * message, ...) __attribute__ ((format (printf, 2, 3))) = 0; // Same with hex dump - virtual void error_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void error_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5))) {error("error_hex not implemented.\n");} - virtual void warning_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void warning_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5))) {error("warning_hex not implemented.\n");} - virtual void info_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void info_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5))) {error("info_hex not implemented.\n");} - virtual void debug_hex(const uint8_t *hex, int size, const char *, ...) __attribute__((format (printf, 4, 5))) + virtual void debug_hex(const uint8_t *, int, const char *, ...) __attribute__((format (printf, 4, 5))) {error("debug_hex not implemented.\n");} protected: diff --git a/lib/include/srslte/common/pdu.h b/lib/include/srslte/common/pdu.h index cc2bb64f5..e9ee1f0e9 100644 --- a/lib/include/srslte/common/pdu.h +++ b/lib/include/srslte/common/pdu.h @@ -258,7 +258,7 @@ public: private: static const int MAX_CE_PAYLOAD_LEN = 8; uint32_t lcid; - int nof_bytes; + uint32_t nof_bytes; uint8_t* payload; uint8_t w_payload_ce[8]; bool F_bit; diff --git a/lib/src/common/pdu.cc b/lib/src/common/pdu.cc index 95d9dde9b..09fae2774 100644 --- a/lib/src/common/pdu.cc +++ b/lib/src/common/pdu.cc @@ -103,8 +103,10 @@ void sch_pdu::parse_packet(uint8_t *ptr) read_len += subheaders[i].size_plus_header(); } - if (pdu_len-read_len-1 >= 0) { - subheaders[nof_subheaders-1].set_payload_size(pdu_len-read_len-1); + int n_sub = pdu_len-read_len-1; + + if (n_sub >= 0) { + subheaders[nof_subheaders-1].set_payload_size(n_sub); } else { fprintf(stderr,"Reading MAC PDU: negative payload for last subheader\n"); } @@ -584,17 +586,22 @@ 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 - uint32_t sdu_sz = sdu_itf->read_pdu(lcid, payload, requested_bytes); + int sdu_sz = sdu_itf->read_pdu(lcid, payload, requested_bytes); - if (sdu_sz < 0 || sdu_sz > requested_bytes) { + if (sdu_sz < 0) { return -1; } if (sdu_sz == 0) { return 0; } + else { + // Save final number of written bytes + nof_bytes = sdu_sz; - // Save final number of written bytes - nof_bytes = sdu_sz; + if(nof_bytes > requested_bytes) { + return -1; + } + } ((sch_pdu*)parent)->add_sdu(nof_bytes); ((sch_pdu*)parent)->update_space_sdu(nof_bytes); diff --git a/lib/src/common/pdu_queue.cc b/lib/src/common/pdu_queue.cc index 9b5e83c7b..8e9656116 100644 --- a/lib/src/common/pdu_queue.cc +++ b/lib/src/common/pdu_queue.cc @@ -96,11 +96,6 @@ bool pdu_queue::process_pdus() if (callback) { callback->process_pdu(pdu->ptr, pdu->len, pdu->channel, pdu->tstamp); } - if (pdu->channel == DCH) { - if (!pool.deallocate(pdu)) { - log_h->warning("Error deallocating from buffer pool in process_pdus(): buffer not created in this pool.\n"); - } - } cnt++; have_data = true; } diff --git a/lib/src/phy/ch_estimation/chest_ul.c b/lib/src/phy/ch_estimation/chest_ul.c index ac4831cc9..d7e6f3be0 100644 --- a/lib/src/phy/ch_estimation/chest_ul.c +++ b/lib/src/phy/ch_estimation/chest_ul.c @@ -286,8 +286,8 @@ int srslte_chest_ul_estimate(srslte_chest_ul_t *q, cf_t *input, cf_t *ce, if (ce != NULL) { if (q->smooth_filter_len > 0) { average_pilots(q, q->pilot_estimates, ce, nrefs_sym, n_prb); - interpolate_pilots(q, ce, nrefs_sym, n_prb); - + interpolate_pilots(q, ce, nrefs_sym, n_prb); + /* If averaging, compute noise from difference between received and averaged estimates */ q->noise_estimate = estimate_noise_pilots(q, ce, nrefs_sym, n_prb); } else { @@ -301,8 +301,7 @@ int srslte_chest_ul_estimate(srslte_chest_ul_t *q, cf_t *input, cf_t *ce, q->noise_estimate = 0; } } - - // Estimate received pilot power + // Estimate received pilot power q->pilot_power = srslte_vec_avg_power_cf(q->pilot_recv_signal, nrefs_sf); return 0; } diff --git a/lib/src/phy/ch_estimation/test/chest_test_dl.c b/lib/src/phy/ch_estimation/test/chest_test_dl.c index 222263c7e..65cc8ced5 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_dl.c +++ b/lib/src/phy/ch_estimation/test/chest_test_dl.c @@ -37,7 +37,9 @@ srslte_cell_t cell = { 6, // nof_prb 1, // nof_ports 1000, // cell_id - SRSLTE_CP_NORM // cyclic prefix + SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_NORM, + SRSLTE_PHICH_R_1_6 }; char *output_matlab = NULL; diff --git a/lib/src/phy/ch_estimation/test/chest_test_ul.c b/lib/src/phy/ch_estimation/test/chest_test_ul.c index 7b9fbacc9..9d5a7f4f4 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_ul.c +++ b/lib/src/phy/ch_estimation/test/chest_test_ul.c @@ -37,7 +37,8 @@ srslte_cell_t cell = { 1, // nof_ports 0, 1000, // cell_id - SRSLTE_CP_NORM // cyclic prefix + SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_NORM }; char *output_matlab = NULL; @@ -116,6 +117,7 @@ int main(int argc, char **argv) { perror("srslte_vec_malloc"); goto do_exit; } + bzero(ce, num_re*sizeof(cf_t)); if (cell.id == 1000) { cid = 0; diff --git a/lib/src/phy/ch_estimation/test/refsignal_ul_test.c b/lib/src/phy/ch_estimation/test/refsignal_ul_test.c index c1323bf0d..5ca18cdda 100644 --- a/lib/src/phy/ch_estimation/test/refsignal_ul_test.c +++ b/lib/src/phy/ch_estimation/test/refsignal_ul_test.c @@ -36,7 +36,9 @@ srslte_cell_t cell = { 100, // nof_prb SRSLTE_MAX_PORTS, // nof_ports 1, // cell_id - SRSLTE_CP_NORM // cyclic prefix + SRSLTE_CP_NORM, // cyclic prefix + SRSLTE_PHICH_NORM, + SRSLTE_PHICH_R_1_6 }; void usage(char *prog) { diff --git a/lib/src/phy/fec/test/turbocoder_test.c b/lib/src/phy/fec/test/turbocoder_test.c index 8daeebdb8..f8219a4e2 100644 --- a/lib/src/phy/fec/test/turbocoder_test.c +++ b/lib/src/phy/fec/test/turbocoder_test.c @@ -40,7 +40,7 @@ uint32_t long_cb = 0; void usage(char *prog) { printf("Usage: %s\n", prog); - printf("\t-l long_cb [Default check all]\n", long_cb); + printf("\t-l long_cb [Default %u]\n", long_cb); } void parse_args(int argc, char **argv) { diff --git a/lib/src/phy/fec/test/turbodecoder_test.c b/lib/src/phy/fec/test/turbodecoder_test.c index aeac21433..014184ff5 100644 --- a/lib/src/phy/fec/test/turbodecoder_test.c +++ b/lib/src/phy/fec/test/turbodecoder_test.c @@ -244,6 +244,7 @@ int main(int argc, char **argv) { for (j=0;jmax_par_cb;i++) { - srslte_tdec_simd_decision_byte_cb(h, output[i], i, long_cb); + if (output[i]) { + srslte_tdec_simd_decision_byte_cb(h, output[i], i, long_cb); + } } } diff --git a/lib/src/phy/mimo/test/precoder_test.c b/lib/src/phy/mimo/test/precoder_test.c index a6925f318..7b5dd08a9 100644 --- a/lib/src/phy/mimo/test/precoder_test.c +++ b/lib/src/phy/mimo/test/precoder_test.c @@ -333,5 +333,11 @@ int main(int argc, char **argv) { } } + for (i = 0; i < nof_tx_ports; i++) { + if (y[i]) { + free(y[i]); + } + } + exit(ret); } diff --git a/lib/src/phy/phch/test/pbch_file_test.c b/lib/src/phy/phch/test/pbch_file_test.c index 6b79db422..2f750f1cc 100644 --- a/lib/src/phy/phch/test/pbch_file_test.c +++ b/lib/src/phy/phch/test/pbch_file_test.c @@ -208,7 +208,7 @@ int main(int argc, char **argv) { /* Get channel estimates for each port */ srslte_chest_dl_estimate(&chest, fft_buffer, ce, 0); - INFO("Decoding PBCH\n", 0); + INFO("Decoding PBCH\n"); for (int i=0;i 0 && frame_cnt < nof_frames); base_free(); + srslte_dft_exit(); + if (frame_cnt == 1) { if (n == 0) { printf("Could not decode PBCH\n"); diff --git a/lib/src/phy/phch/test/pbch_test.c b/lib/src/phy/phch/test/pbch_test.c index a8c673714..dd2e4106e 100644 --- a/lib/src/phy/phch/test/pbch_test.c +++ b/lib/src/phy/phch/test/pbch_test.c @@ -144,6 +144,7 @@ int main(int argc, char **argv) { srslte_vec_fprint_hex(stdout, bch_payload_tx, SRSLTE_BCH_PAYLOAD_LEN); printf("Rx payload: "); srslte_vec_fprint_hex(stdout, bch_payload_rx, SRSLTE_BCH_PAYLOAD_LEN); + srslte_dft_exit(); if (nof_rx_ports == cell.nof_ports && !memcmp(bch_payload_rx, bch_payload_tx, sizeof(uint8_t) * SRSLTE_BCH_PAYLOAD_LEN)) { printf("OK\n"); diff --git a/lib/src/phy/phch/test/pcfich_file_test.c b/lib/src/phy/phch/test/pcfich_file_test.c index 98ff829be..c84510fbb 100644 --- a/lib/src/phy/phch/test/pcfich_file_test.c +++ b/lib/src/phy/phch/test/pcfich_file_test.c @@ -239,6 +239,7 @@ int main(int argc, char **argv) { printf("cfi: %d, distance: %f\n", cfi, cfi_corr); base_free(); + srslte_dft_exit(); if (n < 0) { fprintf(stderr, "Error decoding PCFICH\n"); diff --git a/lib/src/phy/phch/test/pcfich_test.c b/lib/src/phy/phch/test/pcfich_test.c index 32e9925b2..ea821a8d0 100644 --- a/lib/src/phy/phch/test/pcfich_test.c +++ b/lib/src/phy/phch/test/pcfich_test.c @@ -154,6 +154,7 @@ int main(int argc, char **argv) { srslte_regs_free(®s); cid++; } + srslte_dft_exit(); for (i=0;i 0) { diff --git a/lib/src/phy/phch/test/pdsch_test.c b/lib/src/phy/phch/test/pdsch_test.c index eeaaa85c5..cdf608a2e 100644 --- a/lib/src/phy/phch/test/pdsch_test.c +++ b/lib/src/phy/phch/test/pdsch_test.c @@ -546,5 +546,6 @@ quit: } else { printf("Ok\n"); } + srslte_dft_exit(); exit(ret); } diff --git a/lib/src/phy/phch/test/phich_file_test.c b/lib/src/phy/phch/test/phich_file_test.c index 45eec4921..d1a5f7e30 100644 --- a/lib/src/phy/phch/test/phich_file_test.c +++ b/lib/src/phy/phch/test/phich_file_test.c @@ -278,6 +278,7 @@ int main(int argc, char **argv) { } base_free(); + srslte_dft_exit(); if (n < 0) { fprintf(stderr, "Error decoding phich\n"); diff --git a/lib/src/phy/phch/test/phich_test.c b/lib/src/phy/phch/test/phich_test.c index cffb85663..36b2d64e6 100644 --- a/lib/src/phy/phch/test/phich_test.c +++ b/lib/src/phy/phch/test/phich_test.c @@ -215,6 +215,7 @@ int main(int argc, char **argv) { } free(slot_symbols[i]); } + srslte_dft_exit(); printf("OK\n"); exit(0); } diff --git a/lib/src/phy/phch/test/pmch_file_test.c b/lib/src/phy/phch/test/pmch_file_test.c index fa6d04092..8b1595869 100644 --- a/lib/src/phy/phch/test/pmch_file_test.c +++ b/lib/src/phy/phch/test/pmch_file_test.c @@ -202,6 +202,7 @@ int main(int argc, char **argv) { if (data != NULL) { free(data); } + srslte_dft_exit(); if (ret > 0) { exit(0); } else { diff --git a/lib/src/phy/phch/test/pmch_test.c b/lib/src/phy/phch/test/pmch_test.c index 15634fe9b..448a40c2e 100644 --- a/lib/src/phy/phch/test/pmch_test.c +++ b/lib/src/phy/phch/test/pmch_test.c @@ -430,6 +430,15 @@ int main(int argc, char **argv) { ret = SRSLTE_SUCCESS; quit: + + for (i = 0; i < nof_rx_antennas; i++) { + srslte_ofdm_tx_free(&ifft_mbsfn[i]); + srslte_ofdm_rx_free(&fft_mbsfn[i]); + if (rx_sf_symbols[i]) { + free(rx_sf_symbols[i]); + } + } + srslte_pmch_free(&pmch_tx); srslte_pmch_free(&pmch_rx); for (i = 0; i < SRSLTE_MAX_CODEWORDS; i++) { @@ -453,6 +462,9 @@ quit: } for (i=0;i rf->new_rx_gain + 2 || gain < rf->new_rx_gain - 2) { + if (gain > rf->cur_rx_gain + 2 || gain < rf->cur_rx_gain - 2){ pthread_mutex_lock(&rf->mutex); rf->new_rx_gain = gain; pthread_cond_signal(&rf->cond); pthread_mutex_unlock(&rf->mutex); } - return gain; + return rf->cur_rx_gain; } void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t *rf, double offset) { @@ -65,8 +65,9 @@ static void* thread_gain_fcn(void *h) { pthread_cond_wait(&rf->cond, &rf->mutex); } if (rf->new_rx_gain != rf->cur_rx_gain) { - rf->cur_rx_gain = rf->new_rx_gain; - srslte_rf_set_rx_gain(h, rf->cur_rx_gain); + srslte_rf_set_rx_gain(h, rf->new_rx_gain); + rf->cur_rx_gain = srslte_rf_get_rx_gain(h); + rf->new_rx_gain = rf->cur_rx_gain; } if (rf->tx_gain_same_rx) { printf("setting also tx\n"); @@ -80,17 +81,17 @@ static void* thread_gain_fcn(void *h) { /* Create auxiliary thread and mutexes for AGC */ int srslte_rf_start_gain_thread(srslte_rf_t *rf, bool tx_gain_same_rx) { - rf->tx_gain_same_rx = tx_gain_same_rx; - rf->tx_rx_gain_offset = 0.0; + rf->tx_gain_same_rx = tx_gain_same_rx; + rf->tx_rx_gain_offset = 0.0; if (pthread_mutex_init(&rf->mutex, NULL)) { - return -1; + return -1; } if (pthread_cond_init(&rf->cond, NULL)) { - return -1; + return -1; } if (pthread_create(&rf->thread_gain, NULL, thread_gain_fcn, rf)) { perror("pthread_create"); - return -1; + return -1; } return 0; } diff --git a/lib/src/phy/sync/test/cfo_test.c b/lib/src/phy/sync/test/cfo_test.c index 901e1b0e0..3764d7401 100644 --- a/lib/src/phy/sync/test/cfo_test.c +++ b/lib/src/phy/sync/test/cfo_test.c @@ -106,6 +106,7 @@ int main(int argc, char **argv) { srslte_cfo_free(&cfocorr); free(input); free(output); + srslte_dft_exit(); printf("MSE: %f\n", mse); if (mse > MAX_MSE) { diff --git a/lib/src/phy/sync/test/sync_test.c b/lib/src/phy/sync/test/sync_test.c index 9016c1baa..7c6d02e01 100644 --- a/lib/src/phy/sync/test/sync_test.c +++ b/lib/src/phy/sync/test/sync_test.c @@ -185,6 +185,7 @@ int main(int argc, char **argv) { srslte_sync_free(&syncobj); srslte_ofdm_tx_free(&ifft); + srslte_dft_exit(); printf("Ok\n"); exit(0); diff --git a/lib/src/radio/radio.cc b/lib/src/radio/radio.cc index 7b53f7405..622e32589 100644 --- a/lib/src/radio/radio.cc +++ b/lib/src/radio/radio.cc @@ -51,13 +51,11 @@ bool radio::init(char *args, char *devname, uint32_t nof_channels) // Suppress radio stdout srslte_rf_suppress_stdout(&rf_device); - continuous_tx = false; + continuous_tx = true; tx_adv_auto = true; // Set default preamble length each known device // We distinguish by device family, maybe we should calibrate per device if (strstr(srslte_rf_name(&rf_device), "uhd")) { - burst_preamble_sec = uhd_default_burst_preamble_sec; - continuous_tx = true; } else if (strstr(srslte_rf_name(&rf_device), "bladerf")) { burst_preamble_sec = blade_default_burst_preamble_sec; } else { diff --git a/lib/src/radio/radio_multi.cc b/lib/src/radio/radio_multi.cc index ff0a036a2..43160c499 100644 --- a/lib/src/radio/radio_multi.cc +++ b/lib/src/radio/radio_multi.cc @@ -19,7 +19,8 @@ bool radio_multi::init_multi(uint32_t nof_rx_antennas, char* args, char* devname // Suppress radio stdout srslte_rf_suppress_stdout(&rf_device); - tx_adv_auto = true; + continuous_tx = true; + tx_adv_auto = true; // Set default preamble length each known device // We distinguish by device family, maybe we should calibrate per device if (strstr(srslte_rf_name(&rf_device), "uhd")) { diff --git a/lib/src/upper/pdcp_entity.cc b/lib/src/upper/pdcp_entity.cc index c7970ddd6..d8bb0556f 100644 --- a/lib/src/upper/pdcp_entity.cc +++ b/lib/src/upper/pdcp_entity.cc @@ -168,6 +168,12 @@ void pdcp_entity::write_pdu(byte_buffer_t *pdu) log->info_hex(pdu->msg, pdu->N_bytes, "RX %s PDU, do_integrity = %s, do_encryption = %s", rrc->get_rb_name(lcid).c_str(), (do_integrity) ? "true" : "false", (do_encryption) ? "true" : "false"); + // Sanity check + if(pdu->N_bytes <= sn_len_bytes) { + pool->deallocate(pdu); + return; + } + // Handle DRB messages if (cfg.is_data) { uint32_t sn; diff --git a/lib/test/common/msg_queue_test.cc b/lib/test/common/msg_queue_test.cc index 153f14dbc..393931ab5 100644 --- a/lib/test/common/msg_queue_test.cc +++ b/lib/test/common/msg_queue_test.cc @@ -49,26 +49,27 @@ void* write_thread(void *a) { int main(int argc, char **argv) { bool result; - msg_queue q; + msg_queue *q = new msg_queue; byte_buffer_t *b; pthread_t thread; args_t args; u_int32_t r; result = true; - args.q = &q; + args.q = q; pthread_create(&thread, NULL, &write_thread, &args); for(uint32_t i=0;iread(&b); memcpy(&r, b->msg, 4); delete b; if(r != i) result = false; } + delete q; pthread_join(thread, NULL); if(result) { diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index 8b6a731e2..9982841f0 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -242,13 +242,17 @@ void phch_worker::set_config_dedicated(uint16_t rnti, pthread_mutex_lock(&mutex); if (ue_db.count(rnti)) { /* PUSCH UCI and scheduling configuration */ - srslte_uci_cfg_t uci_cfg = {0}; + srslte_uci_cfg_t uci_cfg; + ZERO_OBJECT(uci_cfg); + if (dedicated->pusch_cnfg_ded_present && dedicated->sched_request_cnfg_present) { uci_cfg.I_offset_ack = dedicated->pusch_cnfg_ded.beta_offset_ack_idx; uci_cfg.I_offset_cqi = dedicated->pusch_cnfg_ded.beta_offset_cqi_idx; uci_cfg.I_offset_ri = dedicated->pusch_cnfg_ded.beta_offset_ri_idx; - srslte_pucch_sched_t pucch_sched = {false}; + srslte_pucch_sched_t pucch_sched; + ZERO_OBJECT(pucch_sched); + pucch_sched.N_pucch_1 = phy->pucch_cfg.n1_pucch_an; pucch_sched.n_pucch_2 = dedicated->cqi_report_cnfg.report_periodic.pucch_resource_idx; pucch_sched.n_pucch_sr = dedicated->sched_request_cnfg.sr_pucch_resource_idx; @@ -452,7 +456,9 @@ unlock: int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) { - srslte_uci_data_t uci_data = {0}; + srslte_uci_data_t uci_data; + ZERO_OBJECT(uci_data); + uint32_t wideband_cqi_value = 0, wideband_pmi = 0; bool wideband_pmi_present = false; @@ -478,7 +484,9 @@ int phch_worker::decode_pusch(srslte_enb_ul_pusch_t *grants, uint32_t nof_pusch) } // Configure PUSCH CQI channel - srslte_cqi_value_t cqi_value = {0}; + srslte_cqi_value_t cqi_value; + ZERO_OBJECT(cqi_value); + bool cqi_enabled = false; if (ue_db[rnti].cqi_en && ue_db[rnti].ri_en && srslte_ri_send(ue_db[rnti].pmi_idx, ue_db[rnti].ri_idx, tti_rx) ) { @@ -688,7 +696,9 @@ int phch_worker::decode_pucch() uci_data.uci_ack_len++; } } - srslte_cqi_value_t cqi_value = {0}; + srslte_cqi_value_t cqi_value; + ZERO_OBJECT(cqi_value); + LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT *dedicated = &ue_db[rnti].dedicated; LIBLTE_RRC_TRANSMISSION_MODE_ENUM tx_mode = dedicated->antenna_info_explicit_value.tx_mode; diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index a18df9a59..031322c5d 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -958,7 +958,7 @@ void rrc::ue::set_security_capabilities(LIBLTE_S1AP_UESECURITYCAPABILITIES_STRUC void rrc::ue::set_security_key(uint8_t* key, uint32_t length) { memcpy(k_enb, key, length); - + parent->rrc_log->info_hex(k_enb, 32, "Key eNodeB (k_enb)"); // Select algos (TODO: use security capabilities and config preferences) cipher_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0; integ_algo = srslte::INTEGRITY_ALGORITHM_ID_128_EIA1; diff --git a/srsepc/hdr/mme/s1ap_nas_transport.h b/srsepc/hdr/mme/s1ap_nas_transport.h index 9df615914..e0b7d93fa 100644 --- a/srsepc/hdr/mme/s1ap_nas_transport.h +++ b/srsepc/hdr/mme/s1ap_nas_transport.h @@ -47,7 +47,20 @@ public: bool handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *init_ue, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRANSPORT_STRUCT *ul_xport, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); - //Initial UE messages + bool pack_attach_accept(ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *ue_ecm_ctx, LIBLTE_S1AP_E_RABTOBESETUPITEMCTXTSUREQ_STRUCT *erab_ctxt, struct srslte::gtpc_pdn_address_allocation_ie *paa, srslte::byte_buffer_t *nas_buffer); + +private: + s1ap_nas_transport(); + virtual ~s1ap_nas_transport(); + + srslte::log *m_s1ap_log; + srslte::byte_buffer_pool *m_pool; + + s1ap* m_s1ap; + hss_interface_s1ap* m_hss; + mme_gtpc* m_mme_gtpc; + + //Initial UE messages bool handle_nas_attach_request( uint32_t enb_ue_s1ap_id, srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_buffer, @@ -107,7 +120,6 @@ public: bool pack_security_mode_command(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *ue_ecm_ctx); bool pack_esm_information_request(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *ue_ecm_ctx); - bool pack_attach_accept(ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *ue_ecm_ctx, LIBLTE_S1AP_E_RABTOBESETUPITEMCTXTSUREQ_STRUCT *erab_ctxt, struct srslte::gtpc_pdn_address_allocation_ie *paa, srslte::byte_buffer_t *nas_buffer); bool pack_identity_request(srslte::byte_buffer_t *reply_msg, uint32_t enb_ue_s1ap_id, uint32_t mme_ue_s1ap_id); bool pack_emm_information(ue_ctx_t* ue_ctx, srslte::byte_buffer_t *reply_msg); @@ -116,18 +128,6 @@ public: void log_unhandled_attach_request_ies(const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT *attach_req); void log_unhandled_pdn_con_request_ies(const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT *pdn_con_req); void log_unhandled_initial_ue_message_ies(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *init_ue); - - -private: - s1ap_nas_transport(); - virtual ~s1ap_nas_transport(); - - srslte::log *m_s1ap_log; - srslte::byte_buffer_pool *m_pool; - - s1ap* m_s1ap; - hss_interface_s1ap* m_hss; - mme_gtpc* m_mme_gtpc; }; } //namespace srsepc #endif // SRSEPC_S1AP_NAS_TRANSPORT_H diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index 5500fa561..a509b8a70 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -159,7 +159,7 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx, } //Get K eNB liblte_unpack(emm_ctx->security_ctxt.k_enb, 32, in_ctxt_req->SecurityKey.buffer); - m_s1ap_log->info_hex(emm_ctx->security_ctxt.k_enb, 32, "Initial Context Setup Request -- Key eNB\n"); + m_s1ap_log->info_hex(emm_ctx->security_ctxt.k_enb, 32, "Initial Context Setup Request -- Key eNB (k_enb)\n"); srslte::byte_buffer_t *nas_buffer = m_pool->allocate(); if(emm_ctx->state == EMM_STATE_DEREGISTERED) diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 32964daff..b6220f33a 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -241,6 +241,18 @@ s1ap_nas_transport::handle_uplink_nas_transport(LIBLTE_S1AP_MESSAGE_UPLINKNASTRA m_s1ap_log->console("Uplink NAS: Received Authentication Response\n"); handle_nas_authentication_response(nas_msg, ue_ctx, reply_buffer, reply_flag); break; + // Authentication failure with the option sync failure can be sent not integrity protected + case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_FAILURE: + m_s1ap_log->info("Plain UL NAS: Authentication Failure\n"); + m_s1ap_log->console("Plain UL NAS: Authentication Failure\n"); + handle_authentication_failure(nas_msg, ue_ctx, reply_buffer, reply_flag); + break; + // Detach request can be sent not integrity protected when "power off" option is used + case LIBLTE_MME_MSG_TYPE_DETACH_REQUEST: + m_s1ap_log->info("Plain Protected UL NAS: Detach Request\n"); + m_s1ap_log->console("Plain Protected UL NAS: Detach Request\n"); + handle_nas_detach_request(nas_msg, ue_ctx, reply_buffer, reply_flag); + break; default: m_s1ap_log->warning("Unhandled Plain NAS message 0x%x\n", msg_type ); m_s1ap_log->console("Unhandled Plain NAS message 0x%x\n", msg_type ); @@ -662,10 +674,11 @@ s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, m_s1ap->add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx); //Re-generate K_eNB - liblte_security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb); + srslte::security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb); m_s1ap_log->info("Generating KeNB with UL NAS COUNT: %d\n",emm_ctx->security_ctxt.ul_nas_count); m_s1ap_log->console("Generating KeNB with UL NAS COUNT: %d\n",emm_ctx->security_ctxt.ul_nas_count); - + m_s1ap_log->info_hex(emm_ctx->security_ctxt.k_enb, 32, "Key eNodeB (k_enb)\n"); + m_s1ap_log->console("Attach request -- IMSI: %015lu\n", ecm_ctx->imsi); m_s1ap_log->info("Attach request -- IMSI: %015lu\n", ecm_ctx->imsi); m_s1ap_log->console("Attach request -- eNB-UE S1AP Id: %d, MME-UE S1AP Id: %d\n", ecm_ctx->enb_ue_s1ap_id, ecm_ctx->mme_ue_s1ap_id); @@ -861,8 +874,10 @@ s1ap_nas_transport::handle_nas_service_request(uint32_t m_tmsi, m_s1ap_log->console("UE previously assigned IP: %s",inet_ntoa(emm_ctx->ue_ip)); //Re-generate K_eNB - liblte_security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb); + srslte::security_generate_k_enb(emm_ctx->security_ctxt.k_asme, emm_ctx->security_ctxt.ul_nas_count, emm_ctx->security_ctxt.k_enb); m_s1ap_log->info("Generating KeNB with UL NAS COUNT: %d\n",emm_ctx->security_ctxt.ul_nas_count); + m_s1ap_log->console("Generating KeNB with UL NAS COUNT: %d\n",emm_ctx->security_ctxt.ul_nas_count); + m_s1ap_log->info_hex(emm_ctx->security_ctxt.k_enb, 32, "Key eNodeB (k_enb)\n"); m_s1ap_log->console("UE Ctr TEID %d\n", emm_ctx->sgw_ctrl_fteid.teid); //Save UE ctx to MME UE S1AP id @@ -924,8 +939,8 @@ bool s1ap_nas_transport::handle_nas_detach_request(srslte::byte_buffer_t *nas_msg, ue_ctx_t* ue_ctx, srslte::byte_buffer_t *reply_msg, bool *reply_flag) { - m_s1ap_log->console("Detach request -- IMSI %015lu", ue_ctx->emm_ctx.imsi); - m_s1ap_log->info("Detach request -- IMSI %015lu", ue_ctx->emm_ctx.imsi); + m_s1ap_log->console("Detach request -- IMSI %015lu\n", ue_ctx->emm_ctx.imsi); + m_s1ap_log->info("Detach request -- IMSI %015lu\n", ue_ctx->emm_ctx.imsi); LIBLTE_MME_DETACH_REQUEST_MSG_STRUCT detach_req; LIBLTE_ERROR_ENUM err = liblte_mme_unpack_detach_request_msg((LIBLTE_BYTE_MSG_STRUCT*) nas_msg, &detach_req); @@ -1017,6 +1032,7 @@ s1ap_nas_transport::handle_nas_authentication_response(srslte::byte_buffer_t *na m_s1ap_log->console("UE Authentication Accepted.\n"); m_s1ap_log->info("UE Authentication Accepted.\n"); //Send Security Mode Command + emm_ctx->security_ctxt.ul_nas_count = 0; // Reset the NAS uplink counter for the right key k_enb derivation pack_security_mode_command(reply_buffer, emm_ctx, ecm_ctx); *reply_flag = true; m_s1ap_log->console("Downlink NAS: Sending NAS Security Mode Command.\n"); @@ -1106,10 +1122,10 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u //Attach requested from attach request m_mme_gtpc->send_modify_bearer_request(emm_ctx->imsi, &ecm_ctx->erabs_ctx[act_bearer.eps_bearer_id]); //Send reply to eNB - m_s1ap_log->console("Packing EMM infromationi\n"); + m_s1ap_log->console("Packing EMM Information\n"); *reply_flag = pack_emm_information(ue_ctx, reply_msg); - m_s1ap_log->console("Sending EMM infromation, bytes %d\n",reply_msg->N_bytes); - m_s1ap_log->info("Sending EMM infromation\n"); + m_s1ap_log->console("Sending EMM Information, bytes %d\n",reply_msg->N_bytes); + m_s1ap_log->info("Sending EMM Information\n"); } emm_ctx->state = EMM_STATE_REGISTERED; return true; @@ -1166,8 +1182,8 @@ s1ap_nas_transport::handle_identity_response(srslte::byte_buffer_t *nas_msg, ue_ ue_emm_ctx_t *emm_ctx = &ue_ctx->emm_ctx; ue_ecm_ctx_t *ecm_ctx = &ue_ctx->ecm_ctx; - m_s1ap_log->info("Id Response -- IMSI: %015lu\n", imsi); - m_s1ap_log->console("Id Response -- IMSI: %015lu\n", imsi); + m_s1ap_log->info("ID response -- IMSI: %015lu\n", imsi); + m_s1ap_log->console("ID Response -- IMSI: %015lu\n", imsi); //Set UE's context IMSI emm_ctx->imsi=imsi; @@ -1605,15 +1621,15 @@ s1ap_nas_transport::pack_security_mode_command(srslte::byte_buffer_t *reply_msg, ue_emm_ctx->security_ctxt.k_nas_enc, ue_emm_ctx->security_ctxt.k_nas_int ); - srslte::security_generate_k_nas( ue_emm_ctx->security_ctxt.k_asme, - srslte::CIPHERING_ALGORITHM_ID_EEA0, - srslte::INTEGRITY_ALGORITHM_ID_128_EIA1, - ue_emm_ctx->security_ctxt.k_nas_enc, - ue_emm_ctx->security_ctxt.k_nas_int - ); + + m_s1ap_log->info_hex(ue_emm_ctx->security_ctxt.k_nas_enc, 32, "Key NAS Encryption (k_nas_enc)\n"); + m_s1ap_log->info_hex(ue_emm_ctx->security_ctxt.k_nas_int, 32, "Key NAS Integrity (k_nas_int)\n"); + uint8_t key_enb[32]; - liblte_security_generate_k_enb(ue_emm_ctx->security_ctxt.k_asme, ue_emm_ctx->security_ctxt.ul_nas_count, ue_emm_ctx->security_ctxt.k_enb); - m_s1ap_log->info("Generating KeNB with UL NAS COUNT: %d\n",ue_emm_ctx->security_ctxt.ul_nas_count); + srslte::security_generate_k_enb(ue_emm_ctx->security_ctxt.k_asme, ue_emm_ctx->security_ctxt.ul_nas_count, ue_emm_ctx->security_ctxt.k_enb); + m_s1ap_log->info("Generating KeNB with UL NAS COUNT: %d\n", ue_emm_ctx->security_ctxt.ul_nas_count); + m_s1ap_log->console("Generating KeNB with UL NAS COUNT: %d\n", ue_emm_ctx->security_ctxt.ul_nas_count); + m_s1ap_log->info_hex(ue_emm_ctx->security_ctxt.k_enb, 32, "Key eNodeB (k_enb)\n"); //Generate MAC for integrity protection //FIXME Write wrapper to support EIA1, EIA2, etc. srslte::security_128_eia1 (&ue_emm_ctx->security_ctxt.k_nas_int[16], diff --git a/srsue/hdr/mac/dl_harq.h b/srsue/hdr/mac/dl_harq.h index 37eadad91..c56031ef3 100644 --- a/srsue/hdr/mac/dl_harq.h +++ b/srsue/hdr/mac/dl_harq.h @@ -224,10 +224,13 @@ private: } } - void reset(void) { - pthread_mutex_lock(&mutex); + void reset(bool lock = true) { + if (lock) { + pthread_mutex_lock(&mutex); + } is_first_tb = true; ack = false; + n_retx = 0; if (payload_buffer_ptr) { if (pid != HARQ_BCCH_PID) { harq_entity->demux_unit->deallocate(payload_buffer_ptr); @@ -238,7 +241,9 @@ private: if (is_initiated) { srslte_softbuffer_rx_reset(&softbuffer); } - pthread_mutex_unlock(&mutex); + if (lock) { + pthread_mutex_unlock(&mutex); + } } void new_grant_dl(Tgrant grant, Taction *action) { @@ -263,9 +268,7 @@ private: Warning("DL PID %d: Size of grant changed during a retransmission %d!=%d\n", pid, cur_grant.n_bytes[tid], grant.n_bytes[tid]); } - ack = false; - srslte_softbuffer_rx_reset_tbs(&softbuffer, cur_grant.n_bytes[tid] * 8); - n_retx = 0; + reset(false); } // If data has not yet been successfully decoded @@ -305,9 +308,7 @@ private: Warning("DL PID %d: Received duplicate TB. Discarting and retransmitting ACK (grant_tti=%d, ndi=%d, sz=%d, reset=%s)\n", pid, cur_grant.tti, cur_grant.ndi[tid], cur_grant.n_bytes[tid], interval>RESET_DUPLICATE_TIMEOUT?"yes":"no"); if (interval > RESET_DUPLICATE_TIMEOUT) { - pthread_mutex_unlock(&mutex); - reset(); - pthread_mutex_lock(&mutex); + reset(false); } } diff --git a/srsue/src/mac/demux.cc b/srsue/src/mac/demux.cc index 640b78bd5..dd481c76c 100644 --- a/srsue/src/mac/demux.cc +++ b/srsue/src/mac/demux.cc @@ -148,6 +148,8 @@ void demux::process_pdu(uint8_t *mac_pdu, uint32_t nof_bytes, srslte::pdu_queue: process_sch_pdu(&mac_msg); //srslte_vec_fprint_byte(stdout, mac_pdu, nof_bytes); + + pdus.deallocate(mac_pdu); break; case srslte::pdu_queue::BCH: rlc->write_pdu_bcch_dlsch(mac_pdu, nof_bytes); diff --git a/srsue/src/main.cc b/srsue/src/main.cc index d8469f3ae..e0487f60d 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -283,8 +283,8 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { "Selects the SSS estimation algorithm.") ("expert.pdsch_csi_enabled", - bpo::value(&args->expert.phy.pdsch_csi_enabled)->default_value(false), - "Stores the Channel State Information and uses it for weightening the softbits. It is only compatible with TM1.") + bpo::value(&args->expert.phy.pdsch_csi_enabled)->default_value(true), + "Stores the Channel State Information and uses it for weightening the softbits. It is only used in TM1.") ("rf_calibration.tx_corr_dc_gain", bpo::value(&args->rf_cal.tx_corr_dc_gain)->default_value(0.0), "TX DC offset gain correction") diff --git a/srsue/src/phy/phch_recv.cc b/srsue/src/phy/phch_recv.cc index 3bb6f4a40..b74139bf7 100644 --- a/srsue/src/phy/phch_recv.cc +++ b/srsue/src/phy/phch_recv.cc @@ -540,6 +540,7 @@ void phch_recv::run_thread() if (phy_state.is_camping()) { log_h->warning("Detected radio overflow while camping. Resynchronizing cell\n"); sfn_p.reset(); + srslte_ue_sync_reset(&ue_sync); phy_state.force_sfn_sync(); radio_overflow_return = true; } else { @@ -628,9 +629,7 @@ void phch_recv::set_agc_enable(bool enable) void phch_recv::set_time_adv_sec(float time_adv_sec) { // If transmitting earlier, transmit less samples to align time advance. If transmit later just delay next TX - if (time_adv_sec > this->time_adv_sec) { - next_offset = floor((this->time_adv_sec-time_adv_sec)*srslte_sampling_freq_hz(cell.nof_prb)+1); - } + next_offset = floor((this->time_adv_sec-time_adv_sec)*srslte_sampling_freq_hz(cell.nof_prb)); this->next_time_adv_sec = time_adv_sec; Info("Applying time_adv_sec=%.1f us, next_offset=%d\n", time_adv_sec*1e6, next_offset); } @@ -1047,29 +1046,33 @@ phch_recv::sfn_sync::ret_code phch_recv::sfn_sync::run_subframe(srslte_cell_t *c } int sfn_offset = 0; - Info("SYNC: Trying to decode MIB... SNR=%.1f dB\n", 10*log10(srslte_chest_dl_get_snr(&ue_mib.chest))); - int n = srslte_ue_mib_decode(&ue_mib, bch_payload, NULL, &sfn_offset); - if (n < 0) { - Error("SYNC: Error decoding MIB while synchronising SFN"); - return ERROR; - } else if (n == SRSLTE_UE_MIB_FOUND) { - uint32_t sfn; - srslte_pbch_mib_unpack(bch_payload, cell, &sfn); - - sfn = (sfn+sfn_offset)%1024; - if (tti_cnt) { - *tti_cnt = 10*sfn; - Info("SYNC: DONE, TTI=%d, sfn_offset=%d\n", *tti_cnt, sfn_offset); - } + switch(n) { + default: + Error("SYNC: Error decoding MIB while synchronising SFN"); + return ERROR; + case SRSLTE_UE_MIB_FOUND: + uint32_t sfn; + srslte_pbch_mib_unpack(bch_payload, cell, &sfn); + + sfn = (sfn+sfn_offset)%1024; + if (tti_cnt) { + *tti_cnt = 10*sfn; + Info("SYNC: DONE, SNR=%.1f dB, TTI=%d, sfn_offset=%d\n", + 10*log10(srslte_chest_dl_get_snr(&ue_mib.chest)), *tti_cnt, sfn_offset); + } - srslte_ue_sync_decode_sss_on_track(ue_sync, true); - reset(); - return SFN_FOUND; + srslte_ue_sync_decode_sss_on_track(ue_sync, true); + reset(); + return SFN_FOUND; + case SRSLTE_UE_MIB_NOTFOUND: + Info("SYNC: Found PSS but could not decode MIB. SNR=%.1f dB (%d/%d)\n", + 10*log10(srslte_chest_dl_get_snr(&ue_mib.chest)), cnt, timeout); + break; } } } else { - Info("SYNC: PSS/SSS not found...\n"); + Info("SYNC: Waiting for PSS while trying to decode MIB (%d/%d)\n", cnt, timeout); } cnt++; @@ -1174,27 +1177,27 @@ phch_recv::measure::ret_code phch_recv::measure::run_multiple_subframes(cf_t *in ret_code ret = IDLE; - offset = offset-sf_len/2; - while (offset < 0 && sf_idx < max_sf) { - Info("INTRA: offset=%d, sf_idx=%d\n", offset, sf_idx); - offset += sf_len; + int sf_start = offset-sf_len/2; + while (sf_start < 0 && sf_idx < max_sf) { + Info("INTRA: sf_start=%d, sf_idx=%d\n", sf_start, sf_idx); + sf_start += sf_len; sf_idx ++; } #ifdef FINE_TUNE_OFFSET_WITH_RS float max_rsrp = -200; - int best_test_offset = 0; - int test_offset = 0; + int best_test_sf_start = 0; + int test_sf_start = 0; bool found_best = false; - // Fine-tune offset using RS + // Fine-tune sf_start using RS for (uint32_t n=0;n<5;n++) { - test_offset = offset-2+n; - if (test_offset >= 0) { + test_sf_start = sf_start-2+n; + if (test_sf_start >= 0) { cf_t *buf_m[SRSLTE_MAX_PORTS]; - buf_m[0] = &input_buffer[test_offset]; + buf_m[0] = &input_buffer[test_sf_start]; uint32_t cfi; if (srslte_ue_dl_decode_fft_estimate_noguru(&ue_dl, buf_m, sf_idx, &cfi)) { @@ -1205,25 +1208,25 @@ phch_recv::measure::ret_code phch_recv::measure::run_multiple_subframes(cf_t *in float rsrp = srslte_chest_dl_get_rsrp(&ue_dl.chest); if (rsrp > max_rsrp) { max_rsrp = rsrp; - best_test_offset = test_offset; + best_test_sf_start = test_sf_start; found_best = true; } } } - Debug("INTRA: fine-tuning offset: %d, found_best=%d, rem_sf=%d\n", offset, found_best, nof_sf); + Debug("INTRA: fine-tuning sf_start: %d, found_best=%d, rem_sf=%d\n", sf_start, found_best, nof_sf); - offset = found_best?best_test_offset:offset; + sf_start = found_best?best_test_sf_start:sf_start; #endif - if (offset >= 0 && offset < (sf_len*max_sf)) { + if (sf_start >= 0 && sf_start < (int) (sf_len*max_sf)) { - uint32_t nof_sf = (sf_len*max_sf - offset)/sf_len; + uint32_t nof_sf = (sf_len*max_sf - sf_start)/sf_len; - final_offset = offset; + final_offset = sf_start; for (uint32_t i=0;iget_level() >= srslte::LOG_LEVEL_INFO) { srslte_vec_sprint_hex(hexstr, sizeof(hexstr), dci_msg.data, dci_msg.nof_bits); } - Info("PDCCH: DL DCI %s cce_index=%2d, L=%d, n_data_bits=%d, hex=%s\n", srslte_dci_format_string(dci_msg.format), - last_dl_pdcch_ncce, (1<phy_grant.ul.mcs.tbs==0) { Info("Received PUSCH grant with empty data\n"); @@ -924,7 +924,9 @@ void phch_worker::set_uci_periodic_cqi() compute_ri(NULL, NULL, NULL); phy->last_pmi = (uint8_t) ue_dl.pmi[phy->last_ri % SRSLTE_MAX_LAYERS]; - srslte_cqi_value_t cqi_report = {0}; + srslte_cqi_value_t cqi_report; + ZERO_OBJECT(cqi_report); + if (period_cqi.format_is_subband) { // TODO: Implement subband periodic reports cqi_report.type = SRSLTE_CQI_TYPE_SUBBAND; @@ -975,7 +977,9 @@ void phch_worker::set_uci_aperiodic_cqi() reported RI. For other transmission modes they are reported conditioned on rank 1. */ if (rnti_is_set) { - srslte_cqi_value_t cqi_report = {0}; + srslte_cqi_value_t cqi_report; + ZERO_OBJECT(cqi_report); + cqi_report.type = SRSLTE_CQI_TYPE_SUBBAND_HL; cqi_report.subband_hl.wideband_cqi_cw0 = srslte_cqi_from_snr(phy->avg_snr_db_cqi); @@ -1020,7 +1024,9 @@ void phch_worker::set_uci_aperiodic_cqi() */ if (rnti_is_set) { /* Fill CQI Report */ - srslte_cqi_value_t cqi_report = {0}; + srslte_cqi_value_t cqi_report; + ZERO_OBJECT(cqi_report); + cqi_report.type = SRSLTE_CQI_TYPE_SUBBAND_HL; cqi_report.subband_hl.wideband_cqi_cw0 = srslte_cqi_from_snr(sinr_db); diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index b8db55e5e..f98912680 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -161,6 +161,7 @@ bool ue::init(all_args_t *args_) radio.set_burst_preamble(atof(args->rf.burst_preamble.c_str())); } if (args->rf.continuous_tx.compare("auto")) { + printf("set continuous %s\n", args->rf.continuous_tx.c_str()); radio.set_continuous_tx(args->rf.continuous_tx.compare("yes")?false:true); } diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index 0488f4b45..067e6bfab 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -549,10 +549,14 @@ void nas::parse_attach_accept(uint32_t lcid, byte_buffer_t *pdu) { return; } - LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept = {0}; - LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_complete = {0}; - LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req = {0}; - LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT act_def_eps_bearer_context_accept = {0}; + LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept; + ZERO_OBJECT(attach_accept); + LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_complete; + ZERO_OBJECT(attach_complete); + LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req; + ZERO_OBJECT(act_def_eps_bearer_context_req); + LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT act_def_eps_bearer_context_accept; + ZERO_OBJECT(act_def_eps_bearer_context_accept); nas_log->info("Received Attach Accept\n"); @@ -677,7 +681,8 @@ void nas::parse_attach_accept(uint32_t lcid, byte_buffer_t *pdu) { } void nas::parse_attach_reject(uint32_t lcid, byte_buffer_t *pdu) { - LIBLTE_MME_ATTACH_REJECT_MSG_STRUCT attach_rej = {0}; + LIBLTE_MME_ATTACH_REJECT_MSG_STRUCT attach_rej; + ZERO_OBJECT(attach_rej); liblte_mme_unpack_attach_reject_msg((LIBLTE_BYTE_MSG_STRUCT *) pdu, &attach_rej); nas_log->warning("Received Attach Reject. Cause= %02X\n", attach_rej.emm_cause); @@ -746,8 +751,10 @@ void nas::parse_authentication_reject(uint32_t lcid, byte_buffer_t *pdu) { } void nas::parse_identity_request(uint32_t lcid, byte_buffer_t *pdu) { - LIBLTE_MME_ID_REQUEST_MSG_STRUCT id_req = {0}; - LIBLTE_MME_ID_RESPONSE_MSG_STRUCT id_resp = {0}; + LIBLTE_MME_ID_REQUEST_MSG_STRUCT id_req; + ZERO_OBJECT(id_req); + LIBLTE_MME_ID_RESPONSE_MSG_STRUCT id_resp; + ZERO_OBJECT(id_resp); liblte_mme_unpack_identity_request_msg((LIBLTE_BYTE_MSG_STRUCT *) pdu, &id_req); nas_log->info("Received Identity Request. ID type: %d\n", id_req.id_type); @@ -1037,7 +1044,8 @@ void nas::gen_service_request(byte_buffer_t *msg) { } void nas::gen_pdn_connectivity_request(LIBLTE_BYTE_MSG_STRUCT *msg) { - LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req = {0}; + LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req; + ZERO_OBJECT(pdn_con_req); nas_log->info("Generating PDN Connectivity Request\n"); diff --git a/srsue/src/upper/rrc.cc b/srsue/src/upper/rrc.cc index 0f5975705..4e09ba3f9 100644 --- a/srsue/src/upper/rrc.cc +++ b/srsue/src/upper/rrc.cc @@ -1582,7 +1582,9 @@ void rrc::write_pdu_bcch_dlsch(byte_buffer_t *pdu) { rrc_log->info_hex(pdu->msg, pdu->N_bytes, "BCCH DLSCH message received."); rrc_log->info("BCCH DLSCH message Stack latency: %ld us\n", pdu->get_latency_us()); - LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT dlsch_msg = {0}; + LIBLTE_RRC_BCCH_DLSCH_MSG_STRUCT dlsch_msg; + ZERO_OBJECT(dlsch_msg); + srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8); bit_buf.N_bits = pdu->N_bytes * 8; pool->deallocate(pdu); @@ -1697,7 +1699,8 @@ void rrc::process_pcch(byte_buffer_t *pdu) { rrc_log->info("PCCH message Stack latency: %ld us\n", pdu->get_latency_us()); rrc_log->console("PCCH message received %d bytes\n", pdu->N_bytes); - LIBLTE_RRC_PCCH_MSG_STRUCT pcch_msg = {0}; + LIBLTE_RRC_PCCH_MSG_STRUCT pcch_msg; + ZERO_OBJECT(pcch_msg); srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8); bit_buf.N_bits = pdu->N_bytes * 8; pool->deallocate(pdu); diff --git a/srsue/test/upper/rrc_reconfig_test.cc b/srsue/test/upper/rrc_reconfig_test.cc index c9df04e32..5280c338d 100644 --- a/srsue/test/upper/rrc_reconfig_test.cc +++ b/srsue/test/upper/rrc_reconfig_test.cc @@ -51,8 +51,11 @@ void nas_test() { uint8 msg_type; LIBLTE_BYTE_MSG_STRUCT buf; LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept; + bzero(&attach_accept, sizeof(LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT)); LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req; + bzero(&act_def_eps_bearer_context_req, sizeof(LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT)); + bzero(&buf, sizeof(LIBLTE_BYTE_MSG_STRUCT)); memcpy(buf.msg, nas_message, nas_message_len); buf.N_bytes = nas_message_len; liblte_mme_parse_msg_header(&buf, &pd, &msg_type); diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 7224cf8e3..b2cd36ffe 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -28,7 +28,7 @@ dl_earfcn = 3400 freq_offset = 0 tx_gain = 80 -rx_gain = 40 +#rx_gain = 40 #nof_rx_ant = 1 #device_name = auto @@ -190,7 +190,7 @@ enable = false # RS adjustments are allowed. # # pdsch_csi_enabled: Stores the Channel State Information and uses it for weightening the softbits. It is only -# compatible with TM1. It is False by default. +# used in TM1. It is True by default. # ##################################################################### [expert] @@ -217,7 +217,7 @@ enable = false #pregenerate_signals = false #metrics_csv_enable = false #metrics_csv_filename = /tmp/ue_metrics.csv -#pdsch_csi_enabled = true # Caution! Only TM1 supported! +#pdsch_csi_enabled = true # CFO related values #cfo_is_doppler = false