diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index c95fd50a9..87ecfe6f1 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -185,7 +185,8 @@ void parse_args(int argc, char **argv) { cell.id = atoi(argv[optind]); break; case 'x': - strncpy(mimo_type_str, argv[optind], 32); + strncpy(mimo_type_str, argv[optind], 31); + mimo_type_str[31] = 0; break; case 'b': multiplex_pmi = (uint32_t) atoi(argv[optind]); diff --git a/lib/include/srslte/common/buffer_pool.h b/lib/include/srslte/common/buffer_pool.h index 16d21dce8..81a6025a8 100644 --- a/lib/include/srslte/common/buffer_pool.h +++ b/lib/include/srslte/common/buffer_pool.h @@ -75,9 +75,11 @@ public: void print_all_buffers() { printf("%d buffers in queue\n", (int) used.size()); +#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED for (uint32_t i=0;idebug_name)?used[i]->debug_name:"Undefined"); } +#endif } bool is_almost_empty() { diff --git a/lib/include/srslte/common/common.h b/lib/include/srslte/common/common.h index ddd558016..41a89fb36 100644 --- a/lib/include/srslte/common/common.h +++ b/lib/include/srslte/common/common.h @@ -63,7 +63,7 @@ #define SRSLTE_MAX_BUFFER_SIZE_BYTES 12756 #define SRSLTE_BUFFER_HEADER_OFFSET 1024 -#define SRSLTE_BUFFER_POOL_LOG_ENABLED +//#define SRSLTE_BUFFER_POOL_LOG_ENABLED #ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED #define pool_allocate (pool->allocate(__FUNCTION__)) diff --git a/lib/include/srslte/phy/common/phy_common.h b/lib/include/srslte/phy/common/phy_common.h index 2800e7db6..c55713cfc 100644 --- a/lib/include/srslte/phy/common/phy_common.h +++ b/lib/include/srslte/phy/common/phy_common.h @@ -110,7 +110,7 @@ typedef enum {SRSLTE_SF_NORM, SRSLTE_SF_MBSFN} srslte_sf_t; #define SRSLTE_SF_LEN_MAX (SRSLTE_SF_LEN(SRSLTE_SYMBOL_SZ_MAX)) #define SRSLTE_SLOT_LEN_PRB(nof_prb) (SRSLTE_SLOT_LEN(srslte_symbol_sz(nof_prb))) -#define SRSLTE_SF_LEN_PRB(nof_prb) (nof_prb > 0 ? SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb)) : 0) +#define SRSLTE_SF_LEN_PRB(nof_prb) (SRSLTE_SF_LEN(srslte_symbol_sz(nof_prb))) #define SRSLTE_SLOT_LEN_RE(nof_prb, cp) (nof_prb*SRSLTE_NRE*SRSLTE_CP_NSYMB(cp)) #define SRSLTE_SF_LEN_RE(nof_prb, cp) (2*SRSLTE_SLOT_LEN_RE(nof_prb, cp)) diff --git a/lib/include/srslte/upper/rlc_am.h b/lib/include/srslte/upper/rlc_am.h index c0289956c..e28e11618 100644 --- a/lib/include/srslte/upper/rlc_am.h +++ b/lib/include/srslte/upper/rlc_am.h @@ -180,8 +180,8 @@ private: int build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t retx); int build_data_pdu(uint8_t *payload, uint32_t nof_bytes); - void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header); - void handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header); + void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header); + void handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header); void handle_control_pdu(uint8_t *payload, uint32_t nof_bytes); void reassemble_rx_sdus(); diff --git a/lib/src/asn1/liblte_s1ap.cc b/lib/src/asn1/liblte_s1ap.cc index 530767c2f..e6a8fe575 100644 --- a/lib/src/asn1/liblte_s1ap.cc +++ b/lib/src/asn1/liblte_s1ap.cc @@ -2243,9 +2243,9 @@ LIBLTE_ERROR_ENUM liblte_s1ap_pack_imsi( if(ie != NULL && ptr != NULL) { - // max length of IE buffer is 32, so limit - if (ie->n_octets > 31) { - printf("Length in struct exceeds buffer (%d > 31).\n", ie->n_octets); + // max length of IE buffer is 8, so limit + if (ie->n_octets > 7) { + printf("Length in struct exceeds buffer (%d > 7).\n", ie->n_octets); return LIBLTE_ERROR_ENCODE_FAIL; } diff --git a/lib/src/phy/phch/sch.c b/lib/src/phy/phch/sch.c index 3a8285f73..e6b7d49b9 100644 --- a/lib/src/phy/phch/sch.c +++ b/lib/src/phy/phch/sch.c @@ -89,7 +89,8 @@ uint32_t srslte_sch_find_Ioffset_cqi(float beta) { int srslte_sch_init(srslte_sch_t *q) { int ret = SRSLTE_ERROR_INVALID_INPUTS; - if (q) { + if (q) { + ret = SRSLTE_ERROR; bzero(q, sizeof(srslte_sch_t)); if (srslte_crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) { @@ -753,7 +754,11 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q, uint32_t nb_q = cfg->nbits.nof_bits; uint32_t Qm = cfg->grant.Qm; - + + if (Qm == 0) { + return SRSLTE_ERROR_INVALID_INPUTS; + } + if (uci_data.uci_ri_len > 0) { float beta = beta_ri_offset[cfg->uci_cfg.I_offset_ri]; if (cfg->cb_segm.tbs == 0) { diff --git a/lib/src/phy/phch/test/pdsch_test.c b/lib/src/phy/phch/test/pdsch_test.c index 4053176d9..eeaaa85c5 100644 --- a/lib/src/phy/phch/test/pdsch_test.c +++ b/lib/src/phy/phch/test/pdsch_test.c @@ -178,21 +178,10 @@ int main(int argc, char **argv) { goto quit; } - switch(mimo_type) { - - case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA: - cell.nof_ports = 1; - break; - case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX: - case SRSLTE_MIMO_TYPE_CDD: - if (nof_rx_antennas < 2) { - ERROR("At least two receiving antennas are required"); - goto quit; - } - case SRSLTE_MIMO_TYPE_TX_DIVERSITY: - default: - cell.nof_ports = 2; - break; + if (mimo_type == SRSLTE_MIMO_TYPE_SINGLE_ANTENNA) { + cell.nof_ports = 1; + } else { + cell.nof_ports = 2; } srslte_ra_dl_dci_t dci; @@ -250,7 +239,7 @@ int main(int argc, char **argv) { for (i=0;i 1e6) { - if (30720%((int) srate/1000) == 0) { + if (srate > 1e6 && (srate/1000) > 0) { + if (30720%(srate/1000) == 0) { srslte_rf_set_master_clock_rate(&rf, 30.72e6); } else { srslte_rf_set_master_clock_rate(&rf, 23.04e6); diff --git a/lib/src/phy/phch/uci.c b/lib/src/phy/phch/uci.c index 43de2937e..1b7b43ecb 100644 --- a/lib/src/phy/phch/uci.c +++ b/lib/src/phy/phch/uci.c @@ -655,11 +655,19 @@ int srslte_uci_encode_ack(srslte_pusch_cfg_t *cfg, uint8_t acks[2], uint32_t nof uint32_t nof_encoded_bits = encode_ri_ack(acks, nof_acks, q_encoded_bits, cfg->grant.Qm); - for (uint32_t i=0;igrant.Qm, H_prime_total, cfg->nbits.nof_symb, cfg->cp, &ack_bits[cfg->grant.Qm*i]); - uci_ulsch_interleave_put(&q_encoded_bits[(i*cfg->grant.Qm)%nof_encoded_bits], cfg->grant.Qm, &ack_bits[cfg->grant.Qm*i]); + if (nof_encoded_bits > 0) { + for (uint32_t i = 0; i < Qprime; i++) { + uci_ulsch_interleave_ack_gen(i, + cfg->grant.Qm, + H_prime_total, + cfg->nbits.nof_symb, + cfg->cp, + &ack_bits[cfg->grant.Qm * i]); + uci_ulsch_interleave_put(&q_encoded_bits[(i * cfg->grant.Qm) % nof_encoded_bits], + cfg->grant.Qm, + &ack_bits[cfg->grant.Qm * i]); + } } - return (int) Qprime; } @@ -706,25 +714,27 @@ int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t *cfg, uint32_t nof_encoded_bits = encode_ri_ack(data, data_len, q_encoded_bits, cfg->grant.Qm); - for (uint32_t i = 0; i < Qprime; i++) { - if (ack_ri) { - uci_ulsch_interleave_ri_gen(i, - cfg->grant.Qm, - H_prime_total, - cfg->nbits.nof_symb, - cfg->cp, - &bits[cfg->grant.Qm * i]); - } else { - uci_ulsch_interleave_ack_gen(i, - cfg->grant.Qm, - H_prime_total, - cfg->nbits.nof_symb, - cfg->cp, - &bits[cfg->grant.Qm * i]); + if (nof_encoded_bits > 0) { + for (uint32_t i = 0; i < Qprime; i++) { + if (ack_ri) { + uci_ulsch_interleave_ri_gen(i, + cfg->grant.Qm, + H_prime_total, + cfg->nbits.nof_symb, + cfg->cp, + &bits[cfg->grant.Qm * i]); + } else { + uci_ulsch_interleave_ack_gen(i, + cfg->grant.Qm, + H_prime_total, + cfg->nbits.nof_symb, + cfg->cp, + &bits[cfg->grant.Qm * i]); + } + uci_ulsch_interleave_put(&q_encoded_bits[(i * cfg->grant.Qm) % nof_encoded_bits], + cfg->grant.Qm, + &bits[cfg->grant.Qm * i]); } - uci_ulsch_interleave_put(&q_encoded_bits[(i * cfg->grant.Qm) % nof_encoded_bits], - cfg->grant.Qm, - &bits[cfg->grant.Qm * i]); } return (int) Qprime; diff --git a/lib/src/phy/sync/test/pss_file.c b/lib/src/phy/sync/test/pss_file.c index 4087366ec..d1ec2a130 100644 --- a/lib/src/phy/sync/test/pss_file.c +++ b/lib/src/phy/sync/test/pss_file.c @@ -59,7 +59,7 @@ void usage(char *prog) { printf("Usage: %s [nlestodv] -i cell_id -f input_file_name\n", prog); printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-l N_id_2 to sync [Default use cell_id]\n"); - printf("\t-e Extended CP [Default Normal]\n", fft_size); + printf("\t-e Extended CP [Default Normal]\n"); printf("\t-s symbol_sz [Default %d]\n", fft_size); printf("\t-t threshold [Default %.2f]\n", threshold); printf("\t-o file read offset [Default %d]\n", file_offset); @@ -266,7 +266,7 @@ int main(int argc, char **argv) { } } else { - INFO("No space for CFO computation. Frame starts at \n",peak_idx); + INFO("No space for CFO computation. Frame starts at \n"); } if(srslte_sss_subframe(m0,m1) == 0) diff --git a/lib/src/phy/sync/test/pss_usrp.c b/lib/src/phy/sync/test/pss_usrp.c index 70881f15b..d82555c95 100644 --- a/lib/src/phy/sync/test/pss_usrp.c +++ b/lib/src/phy/sync/test/pss_usrp.c @@ -61,7 +61,7 @@ void usage(char *prog) { printf("\t-g RF Gain [Default %.2f dB]\n", rf_gain); printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-l N_id_2 to sync [Default use cell_id]\n"); - printf("\t-e Extended CP [Default Normal]\n", fft_size); + printf("\t-e Extended CP [Default Normal]\n"); printf("\t-s symbol_sz [Default %d]\n", fft_size); printf("\t-t threshold [Default %.2f]\n", threshold); #ifndef DISABLE_GRAPHICS @@ -291,7 +291,7 @@ int main(int argc, char **argv) { } } else { - INFO("No space for CFO computation. Frame starts at \n",peak_idx); + INFO("No space for CFO computation. Frame starts at \n"); } if(srslte_sss_subframe(m0,m1) == 0) diff --git a/lib/src/phy/ue/ue_dl.c b/lib/src/phy/ue/ue_dl.c index 5c61b2c22..cbd84093a 100644 --- a/lib/src/phy/ue/ue_dl.c +++ b/lib/src/phy/ue/ue_dl.c @@ -896,7 +896,7 @@ static int find_dl_dci_type_crnti(srslte_ue_dl_t *q, uint32_t tm, uint32_t cfi, dci_blind_search_t *current_ss = &search_space; if (cfi < 1 || cfi > 3) { - ERROR("CFI must be 1 ≤ cfi ≤ 3", cfi); + ERROR("CFI must be 1 ≤ cfi ≤ 3 (cfi=%d)", cfi); return SRSLTE_ERROR; } diff --git a/lib/src/upper/pdcp.cc b/lib/src/upper/pdcp.cc index 320f02450..188c56c97 100644 --- a/lib/src/upper/pdcp.cc +++ b/lib/src/upper/pdcp.cc @@ -30,7 +30,14 @@ namespace srslte { pdcp::pdcp() -{} +{ + rlc = NULL; + rrc = NULL; + gw = NULL; + pdcp_log = NULL; + lcid = 0; + direction = 0; +} void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_, srsue::gw_interface_pdcp *gw_, log *pdcp_log_, uint32_t lcid_, uint8_t direction_) { diff --git a/lib/src/upper/pdcp_entity.cc b/lib/src/upper/pdcp_entity.cc index 84c90d931..c7970ddd6 100644 --- a/lib/src/upper/pdcp_entity.cc +++ b/lib/src/upper/pdcp_entity.cc @@ -35,6 +35,17 @@ pdcp_entity::pdcp_entity() ,tx_count(0) { pool = byte_buffer_pool::get_instance(); + log = NULL; + rlc = NULL; + rrc = NULL; + gw = NULL; + lcid = 0; + sn_len_bytes = 0; + do_integrity = false; + do_encryption = false; + rx_count = 0; + cipher_algo = CIPHERING_ALGORITHM_ID_EEA0; + integ_algo = INTEGRITY_ALGORITHM_ID_EIA0; } void pdcp_entity::init(srsue::rlc_interface_pdcp *rlc_, diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 7a7180e45..a626f3002 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -35,6 +35,15 @@ namespace srslte { rlc::rlc() { pool = byte_buffer_pool::get_instance(); + rlc_log = NULL; + pdcp = NULL; + rrc = NULL; + mac_timers = NULL; + ue = NULL; + default_lcid = 0; + bzero(metrics_time, sizeof(metrics_time)); + bzero(ul_tput_bytes, sizeof(ul_tput_bytes)); + bzero(dl_tput_bytes, sizeof(dl_tput_bytes)); } void rlc::init(srsue::pdcp_interface_rlc *pdcp_, @@ -233,13 +242,13 @@ void rlc::add_bearer(uint32_t lcid) void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) { - if(lcid < 0 || lcid >= SRSLTE_N_RADIO_BEARERS) { + if(lcid >= SRSLTE_N_RADIO_BEARERS) { rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid); return; } if (!rlc_array[lcid].active()) { - rlc_log->info("Adding radio bearer %s with mode %s\n", + rlc_log->warning("Adding radio bearer %s with mode %s\n", rrc->get_rb_name(lcid).c_str(), liblte_rrc_rlc_mode_text[cnfg.rlc_mode]); switch(cnfg.rlc_mode) { @@ -271,10 +280,9 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) *******************************************************************************/ bool rlc::valid_lcid(uint32_t lcid) { - if(lcid < 0 || lcid >= SRSLTE_N_RADIO_BEARERS) { + if(lcid >= SRSLTE_N_RADIO_BEARERS) { return false; - } - if(!rlc_array[lcid].active()) { + } else if(!rlc_array[lcid].active()) { return false; } return true; diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index f4e7839c4..6905151f0 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -38,6 +38,12 @@ namespace srslte { rlc_am::rlc_am() : tx_sdu_queue(16) { + log = NULL; + pdcp = NULL; + rrc = NULL; + lcid = 0; + bzero(&cfg, sizeof(srslte_rlc_am_config_t)); + tx_sdu = NULL; rx_sdu = NULL; pool = byte_buffer_pool::get_instance(); @@ -77,7 +83,7 @@ void rlc_am::init(srslte::log *log_, void rlc_am::configure(srslte_rlc_config_t cfg_) { cfg = cfg_.am; - log->info("%s configured: t_poll_retx=%d, poll_pdu=%d, poll_byte=%d, max_retx_thresh=%d, " + log->warning("%s configured: t_poll_retx=%d, poll_pdu=%d, poll_byte=%d, max_retx_thresh=%d, " "t_reordering=%d, t_status_prohibit=%d\n", rrc->get_rb_name(lcid).c_str(), cfg.t_poll_retx, cfg.poll_pdu, cfg.poll_byte, cfg.max_retx_thresh, cfg.t_reordering, cfg.t_status_prohibit); @@ -768,7 +774,7 @@ int rlc_am::build_data_pdu(uint8_t *payload, uint32_t nof_bytes) return (ptr-payload) + pdu->N_bytes; } -void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header) +void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header) { std::map::iterator it; @@ -806,7 +812,7 @@ void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_h memcpy(pdu.buf->msg, payload, nof_bytes); pdu.buf->N_bytes = nof_bytes; - pdu.header = header; + memcpy(&pdu.header, &header, sizeof(rlc_amd_pdu_header_t)); rx_window[header.sn] = pdu; @@ -865,7 +871,7 @@ void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_h debug_state(); } -void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header) +void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header) { std::map::iterator it; @@ -891,7 +897,7 @@ void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_a } memcpy(segment.buf->msg, payload, nof_bytes); segment.buf->N_bytes = nof_bytes; - segment.header = header; + memcpy(&segment.header, &header, sizeof(rlc_amd_pdu_header_t)); // Check if we already have a segment from the same PDU it = rx_segments.find(header.sn); diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index 843236ca8..bcf3cd20a 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -31,6 +31,10 @@ namespace srslte { rlc_tm::rlc_tm() : ul_queue(16) { + log = NULL; + pdcp = NULL; + rrc = NULL; + lcid = 0; pool = byte_buffer_pool::get_instance(); } diff --git a/lib/src/upper/rlc_um.cc b/lib/src/upper/rlc_um.cc index 85fc9f818..213e8c840 100644 --- a/lib/src/upper/rlc_um.cc +++ b/lib/src/upper/rlc_um.cc @@ -33,6 +33,14 @@ namespace srslte { rlc_um::rlc_um() : tx_sdu_queue(16) { + log = NULL; + pdcp = NULL; + rrc = NULL; + reordering_timer = NULL; + lcid = 0; + reordering_timer_id = 0; + bzero(&cfg, sizeof(srslte_rlc_um_config_t)); + tx_sdu = NULL; rx_sdu = NULL; pool = byte_buffer_pool::get_instance(); @@ -73,18 +81,18 @@ void rlc_um::configure(srslte_rlc_config_t cnfg_) switch(cnfg_.rlc_mode) { case LIBLTE_RRC_RLC_MODE_UM_BI: - log->info("%s configured in %s mode: " + log->warning("%s configured in %s mode: " "t_reordering=%d ms, rx_sn_field_length=%u bits, tx_sn_field_length=%u bits\n", rrc->get_rb_name(lcid).c_str(), liblte_rrc_rlc_mode_text[cnfg_.rlc_mode], cfg.t_reordering, rlc_umd_sn_size_num[cfg.rx_sn_field_length], rlc_umd_sn_size_num[cfg.rx_sn_field_length]); break; case LIBLTE_RRC_RLC_MODE_UM_UNI_UL: - log->info("%s configured in %s mode: tx_sn_field_length=%u bits\n", + log->warning("%s configured in %s mode: tx_sn_field_length=%u bits\n", rrc->get_rb_name(lcid).c_str(), liblte_rrc_rlc_mode_text[cnfg_.rlc_mode], rlc_umd_sn_size_num[cfg.rx_sn_field_length]); break; case LIBLTE_RRC_RLC_MODE_UM_UNI_DL: - log->info("%s configured in %s mode: " + log->warning("%s configured in %s mode: " "t_reordering=%d ms, rx_sn_field_length=%u bits\n", rrc->get_rb_name(lcid).c_str(), liblte_rrc_rlc_mode_text[cnfg_.rlc_mode], cfg.t_reordering, rlc_umd_sn_size_num[cfg.rx_sn_field_length]); diff --git a/lib/test/common/logger_test.cc b/lib/test/common/logger_test.cc index 845d4c104..1e0d86b50 100644 --- a/lib/test/common/logger_test.cc +++ b/lib/test/common/logger_test.cc @@ -67,7 +67,7 @@ void write(std::string filename) { bool read(std::string filename) { bool pass = true; bool written[NTHREADS][NMSGS]; - int thread, msg; + int thread = 0, msg = 0; int r; for(int i=0;ienb_files.rr_config, &phy_cnfg); - cell->phich_length = (srslte_phich_length_t) phichcfg.dur; - cell->phich_resources = (srslte_phich_resources_t) phichcfg.res; + cell->phich_length = (srslte_phich_length_t) (int) phichcfg.dur; + cell->phich_resources = (srslte_phich_resources_t) (int) phichcfg.res; if (!srslte_cell_isvalid(cell)) { fprintf(stderr, "Invalid cell parameters: nof_prb=%d, cell_id=%d\n", args->enb.n_prb, args->enb.s1ap.cell_id); @@ -845,7 +845,7 @@ int enb::parse_rr(all_args_t* args, rrc_cfg_t* rrc_cfg) { /* Transmission mode config section */ - if (args->enb.transmission_mode < 0 || args->enb.transmission_mode > 4) { + if (args->enb.transmission_mode < 1 || args->enb.transmission_mode > 4) { ERROR("Invalid transmission mode (%d). Only indexes 1-4 are implemented.\n", args->enb.transmission_mode); return SRSLTE_ERROR; } else if (args->enb.transmission_mode == 1 && args->enb.nof_ports > 1) { diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/mac/mac.cc index c710534ac..8b76cc4f3 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/mac/mac.cc @@ -42,13 +42,26 @@ namespace srsenb { -mac::mac() : timers_db(128), - timers_thread(&timers_db), - rar_pdu_msg(sched_interface::MAX_RAR_LIST), +mac::mac() : timers_db(128), timers_thread(&timers_db), tti(0), last_rnti(0), + rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload(), pdu_process_thread(this) { started = false; - pcap = NULL; + pcap = NULL; + phy_h = NULL; + rlc_h = NULL; + rrc_h = NULL; + log_h = NULL; + + bzero(&locations, sizeof(locations)); + bzero(&cell, sizeof(cell)); + bzero(&args, sizeof(args)); + bzero(&pending_rars, sizeof(pending_rars)); + bzero(&bcch_dlsch_payload, sizeof(bcch_dlsch_payload)); + bzero(&pcch_payload_buffer, sizeof(pcch_payload_buffer)); + bzero(&bcch_softbuffer_tx, sizeof(bcch_softbuffer_tx)); + bzero(&pcch_softbuffer_tx, sizeof(pcch_softbuffer_tx)); + bzero(&rar_softbuffer_tx, sizeof(rar_softbuffer_tx)); } bool mac::init(mac_args_t *args_, srslte_cell_t *cell_, phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h_) @@ -722,8 +735,7 @@ void mac::timer_thread::tti_clock() * DEMU unit * *******************************************************/ -mac::pdu_process::pdu_process(pdu_process_handler *h) -{ +mac::pdu_process::pdu_process(pdu_process_handler *h) : running(false) { handler = h; pthread_mutex_init(&mutex, NULL); pthread_cond_init(&cvar, NULL); diff --git a/srsenb/src/mac/scheduler.cc b/srsenb/src/mac/scheduler.cc index 9ba288e82..9e83e5499 100644 --- a/srsenb/src/mac/scheduler.cc +++ b/srsenb/src/mac/scheduler.cc @@ -18,10 +18,26 @@ namespace srsenb { * Initialization and sched configuration functions * *******************************************************/ -sched::sched() -{ +sched::sched() : bc_aggr_level(0), rar_aggr_level(0), avail_rbg(0), P(0), start_rbg(0), si_n_rbg(0), rar_n_rb(0), + nof_rbg(0), sf_idx(0), sfn(0), current_cfi(0) { current_tti = 0; - log_h = NULL; + log_h = NULL; + dl_metric = NULL; + ul_metric = NULL; + rrc = NULL; + + bzero(&cfg, sizeof(cfg)); + bzero(®s, sizeof(regs)); + bzero(&used_cce, sizeof(used_cce)); + bzero(&sched_cfg, sizeof(sched_cfg)); + bzero(&common_locations, sizeof(common_locations)); + bzero(&pdsch_re, sizeof(pdsch_re)); + bzero(&mutex, sizeof(mutex)); + + for (int i = 0; i < 3; i++) { + bzero(rar_locations[i], sizeof(sched_ue::sched_dci_cce_t) * 10); + } + pthread_mutex_init(&mutex, NULL); reset(); } @@ -80,7 +96,10 @@ int sched::cell_cfg(sched_interface::cell_cfg_t* cell_cfg) memcpy(&cfg, cell_cfg, sizeof(sched_interface::cell_cfg_t)); // Get DCI locations - srslte_regs_init(®s, cfg.cell); + if (srslte_regs_init(®s, cfg.cell)) { + Error("Getting DCI locations\n"); + return SRSLTE_ERROR; + } P = srslte_ra_type0_P(cfg.cell.nof_prb); si_n_rbg = 4/P; diff --git a/srsenb/src/mac/scheduler_ue.cc b/srsenb/src/mac/scheduler_ue.cc index 0c89f9728..6948f922a 100644 --- a/srsenb/src/mac/scheduler_ue.cc +++ b/srsenb/src/mac/scheduler_ue.cc @@ -49,9 +49,18 @@ namespace srsenb { * *******************************************************/ -sched_ue::sched_ue() +sched_ue::sched_ue() : ue_idx(0), has_pucch(false), power_headroom(0), rnti(0), max_mcs_dl(0), max_mcs_ul(0), + fixed_mcs_ul(0), fixed_mcs_dl(0), phy_config_dedicated_enabled(false) { - reset(); + log_h = NULL; + + bzero(&cell, sizeof(cell)); + bzero(&lch, sizeof(lch)); + bzero(&dci_locations, sizeof(dci_locations)); + bzero(&dl_harq, sizeof(dl_harq)); + bzero(&ul_harq, sizeof(ul_harq)); + bzero(&dl_ant_info, sizeof(dl_ant_info)); + reset(); } void sched_ue::set_cfg(uint16_t rnti_, sched_interface::ue_cfg_t *cfg_, sched_interface::cell_cfg_t *cell_cfg, @@ -92,17 +101,21 @@ void sched_ue::set_cfg(uint16_t rnti_, sched_interface::ue_cfg_t *cfg_, sched_in void sched_ue::reset() { bzero(&cfg, sizeof(sched_interface::ue_cfg_t)); - sr = false; + sr = false; next_tpc_pusch = 1; next_tpc_pucch = 1; buf_mac = 0; buf_ul = 0; - phy_config_dedicated_enabled = false; - dl_cqi = 1; - ul_cqi = 1; - dl_cqi_tti = 0; - ul_cqi_tti = 0; - cqi_request_tti = 0; + phy_config_dedicated_enabled = false; + dl_cqi = 1; + ul_cqi = 1; + dl_cqi_tti = 0; + ul_cqi_tti = 0; + dl_ri = 0; + dl_ri_tti = 0; + dl_pmi = 0; + dl_pmi_tti = 0; + cqi_request_tti = 0; for (int i=0;i #include +#include using namespace std; @@ -46,11 +47,11 @@ char const * const prefixes[2][9] = { "", "k", "M", "G", "T", "P", "E", "Z", "Y", }, }; -metrics_stdout::metrics_stdout() - :started(false) - ,do_print(false) - ,n_reports(10) +metrics_stdout::metrics_stdout() : started(false) ,do_print(false), metrics_report_period(0.0f),n_reports(10) { + enb_ = NULL; + bzero(&metrics_thread, sizeof(metrics_thread)); + bzero(&metrics, sizeof(metrics)); } bool metrics_stdout::init(enb_metrics_interface *u, float report_period_secs) @@ -101,6 +102,8 @@ void metrics_stdout::metrics_thread_run() void metrics_stdout::print_metrics() { + std::ios::fmtflags f(cout.flags()); // For avoiding Coverity defect: Not restoring ostream format + if(!do_print) return; @@ -157,7 +160,8 @@ void metrics_stdout::print_metrics() if(metrics.rf.rf_error) { printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l); } - + + cout.flags(f); // For avoiding Coverity defect: Not restoring ostream format } void metrics_stdout::print_disconnect() diff --git a/srsenb/src/phy/phch_worker.cc b/srsenb/src/phy/phch_worker.cc index 11c80ca8d..8013a7d5c 100644 --- a/srsenb/src/phy/phch_worker.cc +++ b/srsenb/src/phy/phch_worker.cc @@ -73,6 +73,11 @@ namespace srsenb { phch_worker::phch_worker() { phy = NULL; + + bzero(&enb_dl, sizeof(enb_dl)); + bzero(&enb_ul, sizeof(enb_ul)); + bzero(&tx_time, sizeof(tx_time)); + reset(); } diff --git a/srsenb/src/phy/phy.cc b/srsenb/src/phy/phy.cc index f171dee85..d47998fa9 100644 --- a/srsenb/src/phy/phy.cc +++ b/srsenb/src/phy/phy.cc @@ -48,8 +48,11 @@ namespace srsenb { phy::phy() : workers_pool(MAX_WORKERS), workers(MAX_WORKERS), - workers_common(txrx::MUTEX_X_WORKER*MAX_WORKERS) + workers_common(txrx::MUTEX_X_WORKER*MAX_WORKERS), + nof_workers(0) { + radio_handler = NULL; + bzero(&prach_cfg, sizeof(prach_cfg)); } void phy::parse_config(phy_cfg_t* cfg) diff --git a/srsenb/src/phy/txrx.cc b/srsenb/src/phy/txrx.cc index a247f3d63..7e97bd1af 100644 --- a/srsenb/src/phy/txrx.cc +++ b/srsenb/src/phy/txrx.cc @@ -42,13 +42,13 @@ using namespace std; namespace srsenb { -txrx::txrx() -{ +txrx::txrx() : tx_mutex_cnt(0), nof_tx_mutex(0), tti(0) { running = false; radio_h = NULL; log_h = NULL; workers_pool = NULL; - worker_com = NULL; + worker_com = NULL; + prach = NULL; } bool txrx::init(srslte::radio* radio_h_, srslte::thread_pool* workers_pool_, phch_common* worker_com_, prach_worker *prach_, srslte::log* log_h_, uint32_t prio_) diff --git a/srsenb/src/upper/rrc.cc b/srsenb/src/upper/rrc.cc index 69a03500e..f1ae51016 100644 --- a/srsenb/src/upper/rrc.cc +++ b/srsenb/src/upper/rrc.cc @@ -553,61 +553,67 @@ void rrc::read_pdu_pcch(uint8_t *payload, uint32_t buffer_size) void rrc::parse_ul_ccch(uint16_t rnti, byte_buffer_t *pdu) { uint16_t old_rnti = 0; - - LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg; - bzero(&ul_ccch_msg, sizeof(LIBLTE_RRC_UL_CCCH_MSG_STRUCT)); - - srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes*8); - bit_buf.N_bits = pdu->N_bytes*8; - liblte_rrc_unpack_ul_ccch_msg((LIBLTE_BIT_MSG_STRUCT*)&bit_buf, &ul_ccch_msg); - - rrc_log->info_hex(pdu->msg, pdu->N_bytes, - "SRB0 - Rx: %s", - liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]); - - switch(ul_ccch_msg.msg_type) { - case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REQ: - if (users.count(rnti)) { - users[rnti].handle_rrc_con_req(&ul_ccch_msg.msg.rrc_con_req); - } else { - rrc_log->error("Received ConnectionSetup for rnti=0x%x without context\n", rnti); - } - break; - case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REEST_REQ: - rrc_log->debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s\n", - ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti, ul_ccch_msg.msg.rrc_con_reest_req.ue_id.phys_cell_id, - ul_ccch_msg.msg.rrc_con_reest_req.ue_id.short_mac_i, liblte_rrc_con_reest_req_cause_text[ul_ccch_msg.msg.rrc_con_reest_req.cause] - ); - if (users[rnti].is_idle()) { - old_rnti = ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti; - if (users.count(old_rnti)) { - rrc_log->error("Not supported: ConnectionReestablishment. Sending Connection Reject\n", old_rnti); - users[rnti].send_connection_reest_rej(); - rem_user_thread(old_rnti); + + if (pdu) { + LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg; + bzero(&ul_ccch_msg, sizeof(LIBLTE_RRC_UL_CCCH_MSG_STRUCT)); + + srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8); + bit_buf.N_bits = pdu->N_bytes * 8; + liblte_rrc_unpack_ul_ccch_msg((LIBLTE_BIT_MSG_STRUCT *) &bit_buf, &ul_ccch_msg); + + rrc_log->info_hex(pdu->msg, pdu->N_bytes, + "SRB0 - Rx: %s", + liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]); + + switch (ul_ccch_msg.msg_type) { + case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REQ: + if (users.count(rnti)) { + users[rnti].handle_rrc_con_req(&ul_ccch_msg.msg.rrc_con_req); } else { - rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context\n", old_rnti); - users[rnti].send_connection_reest_rej(); + rrc_log->error("Received ConnectionSetup for rnti=0x%x without context\n", rnti); } - // remove temporal rnti - rem_user_thread(rnti); - } else { - rrc_log->error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE\n", rnti); - } - break; - default: - rrc_log->error("UL CCCH message not recognised\n"); - break; + break; + case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REEST_REQ: + rrc_log->debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s\n", + ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti, + ul_ccch_msg.msg.rrc_con_reest_req.ue_id.phys_cell_id, + ul_ccch_msg.msg.rrc_con_reest_req.ue_id.short_mac_i, + liblte_rrc_con_reest_req_cause_text[ul_ccch_msg.msg.rrc_con_reest_req.cause] + ); + if (users[rnti].is_idle()) { + old_rnti = ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti; + if (users.count(old_rnti)) { + rrc_log->error("Not supported: ConnectionReestablishment. Sending Connection Reject\n", old_rnti); + users[rnti].send_connection_reest_rej(); + rem_user_thread(old_rnti); + } else { + rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context\n", old_rnti); + users[rnti].send_connection_reest_rej(); + } + // remove temporal rnti + rem_user_thread(rnti); + } else { + rrc_log->error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE\n", rnti); + } + break; + default: + rrc_log->error("UL CCCH message not recognised\n"); + break; + } + + pool->deallocate(pdu); } - - pool->deallocate(pdu); } void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, byte_buffer_t *pdu) { - if (users.count(rnti)) { - users[rnti].parse_ul_dcch(lcid, pdu); - } else { - rrc_log->error("Processing %s: Unkown rnti=0x%x\n", rb_id_text[lcid], rnti); + if (pdu) { + if (users.count(rnti)) { + users[rnti].parse_ul_dcch(lcid, pdu); + } else { + rrc_log->error("Processing %s: Unkown rnti=0x%x\n", rb_id_text[lcid], rnti); + } } } @@ -1757,7 +1763,7 @@ int rrc::ue::cqi_allocate(uint32_t period, uint32_t *pmi_idx, uint32_t *n_pucch) *pmi_idx = 318 + parent->cfg.cqi_cfg.sf_mapping[j_min]; } else if (period == 64) { *pmi_idx = 350 + parent->cfg.cqi_cfg.sf_mapping[j_min]; - } else if (period == 64) { + } else if (period == 128) { *pmi_idx = 414 + parent->cfg.cqi_cfg.sf_mapping[j_min]; } } diff --git a/srsenb/test/upper/ip_test.cc b/srsenb/test/upper/ip_test.cc index 1d8423b9d..deceb486e 100644 --- a/srsenb/test/upper/ip_test.cc +++ b/srsenb/test/upper/ip_test.cc @@ -590,15 +590,15 @@ int main(int argc, char *argv[]) /******************* This is copied from srsue gw **********************/ int setup_if_addr(char *ip_addr) { - char *dev = (char*) "tun_srsenb"; + int sock = 0; // Construct the TUN device int tun_fd = open("/dev/net/tun", O_RDWR); if(0 > tun_fd) { perror("open"); - return(-1); + return SRSLTE_ERROR; } struct ifreq ifr; @@ -609,30 +609,23 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(tun_fd, TUNSETIFF, &ifr)) { perror("ioctl1"); - close(tun_fd); - return -1; + goto clean_exit; } // Bring up the interface - int sock = socket(AF_INET, SOCK_DGRAM, 0); + sock = socket(AF_INET, SOCK_DGRAM, 0); if(0 > ioctl(sock, SIOCGIFFLAGS, &ifr)) { perror("socket"); - close(sock); - close(tun_fd); - return -1; + goto clean_exit; } ifr.ifr_flags |= IFF_UP | IFF_RUNNING; if(0 > ioctl(sock, SIOCSIFFLAGS, &ifr)) { perror("ioctl2"); - close(sock); - close(tun_fd); - return -1; + goto clean_exit; } - close(sock); - // Setup the IP address sock = socket(AF_INET, SOCK_DGRAM, 0); ifr.ifr_addr.sa_family = AF_INET; @@ -640,21 +633,19 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCSIFADDR, &ifr)) { perror("ioctl"); - close(sock); - close(tun_fd); - return -1; + goto clean_exit; } ifr.ifr_netmask.sa_family = AF_INET; ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr = inet_addr("255.255.255.0"); if(0 > ioctl(sock, SIOCSIFNETMASK, &ifr)) { perror("ioctl"); - close(sock); - close(tun_fd); - return -1; + goto clean_exit; } - - close(sock); return(tun_fd); + +clean_exit: + close(tun_fd); + return SRSLTE_ERROR; } diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 07563e7ca..a3c68bc26 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -193,6 +193,7 @@ s1ap::enb_listen() evnts.sctp_data_io_event = 1; evnts.sctp_shutdown_event=1; if(setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof (evnts))){ + close(sock_fd); m_s1ap_log->console("Subscribing to sctp_data_io_events failed\n"); return -1; } @@ -204,6 +205,7 @@ s1ap::enb_listen() s1mme_addr.sin_port = htons(S1MME_PORT); err = bind(sock_fd, (struct sockaddr*) &s1mme_addr, sizeof (s1mme_addr)); if (err != 0){ + close(sock_fd); m_s1ap_log->error("Error binding SCTP socket\n"); m_s1ap_log->console("Error binding SCTP socket\n"); return -1; @@ -212,6 +214,7 @@ s1ap::enb_listen() //Listen for connections err = listen(sock_fd,SOMAXCONN); if (err != 0){ + close(sock_fd); m_s1ap_log->error("Error in SCTP socket listen\n"); m_s1ap_log->console("Error in SCTP socket listen\n"); return -1; diff --git a/srsepc/src/mme/s1ap_nas_transport.cc b/srsepc/src/mme/s1ap_nas_transport.cc index 092e92ae3..7ba6fbe25 100644 --- a/srsepc/src/mme/s1ap_nas_transport.cc +++ b/srsepc/src/mme/s1ap_nas_transport.cc @@ -428,22 +428,19 @@ s1ap_nas_transport::handle_nas_authentication_response(srslte::byte_buffer_t *na bool ue_valid=true; m_s1ap_log->console("Authentication Response -- IMSI %015lu\n", ue_ctx->imsi); - m_s1ap_log->console("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n", - auth_resp.res[0], - auth_resp.res[1], - auth_resp.res[2], - auth_resp.res[3], - auth_resp.res[4], - auth_resp.res[5], - auth_resp.res[6], - auth_resp.res[7] - ); + //Get NAS authentication response LIBLTE_ERROR_ENUM err = liblte_mme_unpack_authentication_response_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &auth_resp); if(err != LIBLTE_SUCCESS){ m_s1ap_log->error("Error unpacking NAS authentication response. Error: %s\n", liblte_error_text[err]); return false; } + m_s1ap_log->console("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n", + auth_resp.res[0], auth_resp.res[1], auth_resp.res[2], auth_resp.res[3], + auth_resp.res[4], auth_resp.res[5], auth_resp.res[6], auth_resp.res[7]); + m_s1ap_log->info("Authentication Response -- RES 0x%x%x%x%x%x%x%x%x\n", + auth_resp.res[0], auth_resp.res[1], auth_resp.res[2], auth_resp.res[3], + auth_resp.res[4], auth_resp.res[5], auth_resp.res[6], auth_resp.res[7]); for(int i=0; i<8;i++) { @@ -547,7 +544,7 @@ s1ap_nas_transport::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, u m_s1ap_log->console("Unpacked Attached Complete Message\n"); m_s1ap_log->console("Unpacked Activavate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id); //ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid; - if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 16) + if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 15) { m_s1ap_log->error("EPS Bearer ID out of range\n"); return false; @@ -1091,6 +1088,14 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[2] = 8; act_def_eps_bearer_context_req.protocol_cnfg_opts.opt[0].contents[3] = 8; + //Make sure all unused options are set to false + act_def_eps_bearer_context_req.negotiated_qos_present = false; + act_def_eps_bearer_context_req.llc_sapi_present = false; + act_def_eps_bearer_context_req.radio_prio_present = false; + act_def_eps_bearer_context_req.packet_flow_id_present = false; + act_def_eps_bearer_context_req.apn_ambr_present = false; + act_def_eps_bearer_context_req.esm_cause_present = false; + uint8_t sec_hdr_type =2; ue_ctx->security_ctxt.dl_nas_count++; liblte_mme_pack_activate_default_eps_bearer_context_request_msg(&act_def_eps_bearer_context_req, &attach_accept.esm_msg); diff --git a/srsepc/src/spgw/spgw.cc b/srsepc/src/spgw/spgw.cc index 2458a065b..add16b2c4 100644 --- a/srsepc/src/spgw/spgw.cc +++ b/srsepc/src/spgw/spgw.cc @@ -175,7 +175,9 @@ spgw::init_sgi_if(spgw_args_t *args) memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TUN | IFF_NO_PI; - strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ); + strncpy(ifr.ifr_ifrn.ifrn_name, dev, IFNAMSIZ-1); + ifr.ifr_ifrn.ifrn_name[IFNAMSIZ-1]='\0'; + if(ioctl(m_sgi_if, TUNSETIFF, &ifr) < 0) { m_spgw_log->error("Failed to set TUN device name: %s\n", strerror(errno)); diff --git a/srsue/hdr/metrics_stdout.h b/srsue/hdr/metrics_stdout.h index cd19e7f16..01f28f35e 100644 --- a/srsue/hdr/metrics_stdout.h +++ b/srsue/hdr/metrics_stdout.h @@ -57,7 +57,6 @@ private: std::string float_to_eng_string(float f, int digits); std::string int_to_eng_string(int f, int digits); - float metrics_report_period; bool do_print; uint8_t n_reports; ue_metrics_interface* ue; diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index 1569b0860..ebb8710d5 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -232,8 +232,8 @@ void phch_worker::work_imp() /** Calculate RSSI on the input signal before generating the output */ - // Average RSSI over all symbols - float rssi_dbm = 10*log10(srslte_vec_avg_power_cf(signal_buffer[0], SRSLTE_SF_LEN_PRB(cell.nof_prb))) + 30; + // Average RSSI over all symbols (make sure SF length is non-zero) + float rssi_dbm = SRSLTE_SF_LEN_PRB(cell.nof_prb) > 0 ? (10*log10(srslte_vec_avg_power_cf(signal_buffer[0], SRSLTE_SF_LEN_PRB(cell.nof_prb))) + 30) : 0; if (isnormal(rssi_dbm)) { phy->avg_rssi_dbm = SRSLTE_VEC_EMA(rssi_dbm, phy->avg_rssi_dbm, phy->args->snr_ema_coeff); } diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 78988ef9e..184cbcf56 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -81,6 +81,7 @@ bool ue::init(all_args_t *args_) // Init logs rf_log.set_level(srslte::LOG_LEVEL_INFO); + rf_log.info("Starting UE\n"); for (int i=0;iexpert.phy.nof_phy_threads;i++) { ((srslte::log_filter*) phy_log[i])->set_level(level(args->log.phy_level)); }