diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 2ee1d0760..2f5ea9b33 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -245,7 +245,7 @@ private: std::unique_ptr measurements; // List of strongest neighbour cell - using unique_cell_t = std::unique_ptr; + using unique_cell_t = std::unique_ptr; meas_cell_list meas_cells; bool initiated = false; @@ -260,7 +260,7 @@ private: std::set get_cells(const uint32_t earfcn); float get_cell_rsrp(const uint32_t earfcn, const uint32_t pci); float get_cell_rsrq(const uint32_t earfcn, const uint32_t pci); - cell_t* get_serving_cell(); + meas_cell* get_serving_cell(); void process_cell_meas(); void process_new_cell_meas(const std::vector& meas); diff --git a/srsue/hdr/stack/rrc/rrc_cell.h b/srsue/hdr/stack/rrc/rrc_cell.h index a104efd84..95ddd3b50 100644 --- a/srsue/hdr/stack/rrc/rrc_cell.h +++ b/srsue/hdr/stack/rrc/rrc_cell.h @@ -28,19 +28,19 @@ namespace srsue { -class cell_t +class meas_cell { public: - cell_t() { gettimeofday(&last_update, nullptr); } - explicit cell_t(phy_cell_t phy_cell_) : cell_t() { phy_cell = phy_cell_; } + meas_cell() { gettimeofday(&last_update, nullptr); } + explicit meas_cell(phy_cell_t phy_cell_) : meas_cell() { phy_cell = phy_cell_; } // comparison based on pci and earfcn bool is_valid() { return phy_cell.earfcn != 0 && srslte_cellid_isvalid(phy_cell.pci); } - bool equals(const cell_t& x) { return equals(x.phy_cell.earfcn, x.phy_cell.pci); } + bool equals(const meas_cell& x) { return equals(x.phy_cell.earfcn, x.phy_cell.pci); } bool equals(uint32_t earfcn, uint32_t pci) { return earfcn == phy_cell.earfcn && pci == phy_cell.pci; } // NaN means an RSRP value has not yet been obtained. Keep then in the list and clean them if never updated - bool greater(cell_t* x) { return rsrp > x->rsrp || std::isnan(rsrp); } + bool greater(meas_cell* x) { return rsrp > x->rsrp || std::isnan(rsrp); } bool has_plmn_id(asn1::rrc::plmn_id_s plmn_id) const; uint32_t nof_plmns() const { return has_sib1() ? sib1.cell_access_related_info.plmn_id_list.size() : 0; } @@ -111,13 +111,13 @@ public: bool is_sib_scheduled(uint32_t sib_index) const; - phy_cell_t phy_cell = {0, 0, 0}; - bool has_mcch = false; - asn1::rrc::sib_type1_s sib1 = {}; - asn1::rrc::sib_type2_s sib2 = {}; - asn1::rrc::sib_type3_s sib3 = {}; - asn1::rrc::sib_type13_r9_s sib13 = {}; - asn1::rrc::mcch_msg_s mcch = {}; + phy_cell_t phy_cell = {0, 0, 0}; + bool has_mcch = false; + asn1::rrc::sib_type1_s sib1 = {}; + asn1::rrc::sib_type2_s sib2 = {}; + asn1::rrc::sib_type3_s sib3 = {}; + asn1::rrc::sib_type13_r9_s sib13 = {}; + asn1::rrc::mcch_msg_s mcch = {}; private: float rsrp = NAN; @@ -139,7 +139,7 @@ uint32_t get_pci(const T& t) return t.pci; } template <> -inline uint32_t get_pci(const cell_t& t) +inline uint32_t get_pci(const meas_cell& t) { return t.get_pci(); } @@ -149,7 +149,7 @@ uint32_t get_earfcn(const T& t) return t.earfcn; } template <> -inline uint32_t get_earfcn(const cell_t& t) +inline uint32_t get_earfcn(const meas_cell& t) { return t.get_earfcn(); } @@ -164,51 +164,51 @@ class meas_cell_list using phy_meas_t = rrc_interface_phy_lte::phy_meas_t; public: - const static int NEIGHBOUR_TIMEOUT = 5; - const static int MAX_NEIGHBOUR_CELLS = 8; - typedef std::unique_ptr unique_cell_t; + const static int NEIGHBOUR_TIMEOUT = 5; + const static int MAX_NEIGHBOUR_CELLS = 8; + typedef std::unique_ptr unique_meas_cell; meas_cell_list(); - bool add_meas_cell(const phy_meas_t& meas); - bool add_meas_cell(unique_cell_t cell); - void rem_last_neighbour(); - unique_cell_t remove_neighbour_cell(uint32_t earfcn, uint32_t pci); - void clean_neighbours(); - void sort_neighbour_cells(); + bool add_meas_cell(const phy_meas_t& meas); + bool add_meas_cell(unique_meas_cell cell); + void rem_last_neighbour(); + unique_meas_cell remove_neighbour_cell(uint32_t earfcn, uint32_t pci); + void clean_neighbours(); + void sort_neighbour_cells(); - bool process_new_cell_meas(const std::vector& meas, - const std::function& filter_meas); + bool process_new_cell_meas(const std::vector& meas, + const std::function& filter_meas); - cell_t* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci); - const cell_t* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const; + meas_cell* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci); + const meas_cell* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const; void log_neighbour_cells() const; std::string print_neighbour_cells() const; std::set get_neighbour_pcis(uint32_t earfcn) const; bool has_neighbour_cell(uint32_t earfcn, uint32_t pci) const; size_t nof_neighbours() const { return neighbour_cells.size(); } - cell_t& operator[](size_t idx) { return *neighbour_cells[idx]; } - const cell_t& operator[](size_t idx) const { return *neighbour_cells[idx]; } - cell_t& at(size_t idx) { return *neighbour_cells.at(idx); } - cell_t* find_cell(uint32_t earfcn, uint32_t pci); + meas_cell& operator[](size_t idx) { return *neighbour_cells[idx]; } + const meas_cell& operator[](size_t idx) const { return *neighbour_cells[idx]; } + meas_cell& at(size_t idx) { return *neighbour_cells.at(idx); } + meas_cell* find_cell(uint32_t earfcn, uint32_t pci); // serving cell handling int set_serving_cell(phy_cell_t phy_cell, bool discard_serving); - cell_t& serving_cell() { return *serv_cell; } - const cell_t& serving_cell() const { return *serv_cell; } + meas_cell& serving_cell() { return *serv_cell; } + const meas_cell& serving_cell() const { return *serv_cell; } - using iterator = std::vector::iterator; + using iterator = std::vector::iterator; iterator begin() { return neighbour_cells.begin(); } iterator end() { return neighbour_cells.end(); } private: - bool add_neighbour_cell_unsorted(unique_cell_t cell); + bool add_neighbour_cell_unsorted(unique_meas_cell cell); srslte::log_ref log_h{"RRC"}; - unique_cell_t serv_cell; - std::vector neighbour_cells; + unique_meas_cell serv_cell; + std::vector neighbour_cells; }; } // namespace srsue diff --git a/srsue/hdr/stack/rrc/rrc_procedures.h b/srsue/hdr/stack/rrc/rrc_procedures.h index c9d206f7e..b32d2dea4 100644 --- a/srsue/hdr/stack/rrc/rrc_procedures.h +++ b/srsue/hdr/stack/rrc/rrc_procedures.h @@ -330,8 +330,8 @@ public: void then(const srslte::proc_state_t& result); static const char* name() { return "Handover"; } - cell_t ho_src_cell; - uint16_t ho_src_rnti = 0; + meas_cell ho_src_cell; + uint16_t ho_src_rnti = 0; private: rrc* rrc_ptr = nullptr; diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 41892aa61..f633fcd0d 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -119,7 +119,7 @@ void rrc::init(phy_interface_rrc_lte* phy_, auto on_every_cell_selection = [this](uint32_t earfcn, uint32_t pci, bool csel_result) { if (not csel_result) { - cell_t* c = meas_cells.find_cell(earfcn, pci); + meas_cell* c = meas_cells.find_cell(earfcn, pci); if (c != nullptr) { c->set_rsrp(-INFINITY); } @@ -395,7 +395,7 @@ void rrc::process_cell_meas() void rrc::process_new_cell_meas(const std::vector& meas) { - const std::function filter = [this](cell_t& c, const phy_meas_t& m) { + const std::function filter = [this](meas_cell& c, const phy_meas_t& m) { c.set_rsrp(measurements->rsrp_filter(m.rsrp, c.get_rsrp())); c.set_rsrq(measurements->rsrq_filter(m.rsrq, c.get_rsrq())); c.set_cfo(m.cfo_hz); @@ -1055,17 +1055,17 @@ std::set rrc::get_cells(const uint32_t earfcn) float rrc::get_cell_rsrp(const uint32_t earfcn, const uint32_t pci) { - cell_t* c = meas_cells.get_neighbour_cell_handle(earfcn, pci); + meas_cell* c = meas_cells.get_neighbour_cell_handle(earfcn, pci); return (c != nullptr) ? c->get_rsrp() : NAN; } float rrc::get_cell_rsrq(const uint32_t earfcn, const uint32_t pci) { - cell_t* c = meas_cells.get_neighbour_cell_handle(earfcn, pci); + meas_cell* c = meas_cells.get_neighbour_cell_handle(earfcn, pci); return (c != nullptr) ? c->get_rsrq() : NAN; } -cell_t* rrc::get_serving_cell() +meas_cell* rrc::get_serving_cell() { return &meas_cells.serving_cell(); } diff --git a/srsue/src/stack/rrc/rrc_cell.cc b/srsue/src/stack/rrc/rrc_cell.cc index 9bb852ab0..68838f641 100644 --- a/srsue/src/stack/rrc/rrc_cell.cc +++ b/srsue/src/stack/rrc/rrc_cell.cc @@ -23,7 +23,7 @@ namespace srsue { -srslte::plmn_id_t cell_t::get_plmn(uint32_t idx) const +srslte::plmn_id_t meas_cell::get_plmn(uint32_t idx) const { if (idx < sib1.cell_access_related_info.plmn_id_list.size() && has_valid_sib1) { return srslte::make_plmn_id_t(sib1.cell_access_related_info.plmn_id_list[idx].plmn_id); @@ -32,7 +32,7 @@ srslte::plmn_id_t cell_t::get_plmn(uint32_t idx) const } } -void cell_t::set_sib1(const asn1::rrc::sib_type1_s& sib1_) +void meas_cell::set_sib1(const asn1::rrc::sib_type1_s& sib1_) { sib1 = sib1_; has_valid_sib1 = true; @@ -45,28 +45,28 @@ void cell_t::set_sib1(const asn1::rrc::sib_type1_s& sib1_) } } -void cell_t::set_sib2(const asn1::rrc::sib_type2_s& sib2_) +void meas_cell::set_sib2(const asn1::rrc::sib_type2_s& sib2_) { sib2 = sib2_; has_valid_sib2 = true; } -void cell_t::set_sib3(const asn1::rrc::sib_type3_s& sib3_) +void meas_cell::set_sib3(const asn1::rrc::sib_type3_s& sib3_) { sib3 = sib3_; has_valid_sib3 = true; } -void cell_t::set_sib13(const asn1::rrc::sib_type13_r9_s& sib13_) +void meas_cell::set_sib13(const asn1::rrc::sib_type13_r9_s& sib13_) { sib13 = sib13_; has_valid_sib13 = true; } -bool cell_t::is_sib_scheduled(uint32_t sib_index) const +bool meas_cell::is_sib_scheduled(uint32_t sib_index) const { return sib_info_map.find(sib_index) != sib_info_map.end(); } -uint32_t cell_t::timeout_secs(struct timeval now) const +uint32_t meas_cell::timeout_secs(struct timeval now) const { struct timeval t[3]; memcpy(&t[2], &now, sizeof(struct timeval)); @@ -75,7 +75,7 @@ uint32_t cell_t::timeout_secs(struct timeval now) const return t[0].tv_sec; } -bool cell_t::has_sibs(srslte::span indexes) const +bool meas_cell::has_sibs(srslte::span indexes) const { for (uint32_t idx : indexes) { if (not has_sib(idx)) { @@ -85,7 +85,7 @@ bool cell_t::has_sibs(srslte::span indexes) const return true; } -bool cell_t::has_sib(uint32_t index) const +bool meas_cell::has_sib(uint32_t index) const { switch (index) { case 0: @@ -102,7 +102,7 @@ bool cell_t::has_sib(uint32_t index) const return false; } -std::string cell_t::to_string() const +std::string meas_cell::to_string() const { char buf[256]; snprintf(buf, @@ -116,7 +116,7 @@ std::string cell_t::to_string() const return std::string{buf}; } -bool cell_t::has_plmn_id(asn1::rrc::plmn_id_s plmn_id) const +bool meas_cell::has_plmn_id(asn1::rrc::plmn_id_s plmn_id) const { if (has_valid_sib1) { for (const auto& e : sib1.cell_access_related_info.plmn_id_list) { @@ -128,7 +128,7 @@ bool cell_t::has_plmn_id(asn1::rrc::plmn_id_s plmn_id) const return false; } -uint16_t cell_t::get_mcc() const +uint16_t meas_cell::get_mcc() const { uint16_t mcc; if (has_valid_sib1) { @@ -141,7 +141,7 @@ uint16_t cell_t::get_mcc() const return 0; } -uint16_t cell_t::get_mnc() const +uint16_t meas_cell::get_mnc() const { uint16_t mnc; if (has_valid_sib1) { @@ -160,19 +160,19 @@ uint16_t cell_t::get_mnc() const * Neighbour Cell List ********************************************/ -meas_cell_list::meas_cell_list() : serv_cell(new cell_t()) {} +meas_cell_list::meas_cell_list() : serv_cell(new meas_cell()) {} -cell_t* meas_cell_list::get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) +meas_cell* meas_cell_list::get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) { - auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_cell_t& cell) { + auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_meas_cell& cell) { return cell->equals(earfcn, pci); }); return it != neighbour_cells.end() ? it->get() : nullptr; } -const cell_t* meas_cell_list::get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const +const meas_cell* meas_cell_list::get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const { - auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_cell_t& cell) { + auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_meas_cell& cell) { return cell->equals(earfcn, pci); }); return it != neighbour_cells.end() ? it->get() : nullptr; @@ -184,14 +184,14 @@ bool meas_cell_list::add_meas_cell(const rrc_interface_phy_lte::phy_meas_t& meas phy_cell_t phy_cell = {}; phy_cell.earfcn = meas.earfcn; phy_cell.pci = meas.pci; - unique_cell_t c = unique_cell_t(new cell_t(phy_cell)); + unique_meas_cell c = unique_meas_cell(new meas_cell(phy_cell)); c.get()->set_rsrp(meas.rsrp); c.get()->set_rsrq(meas.rsrq); c.get()->set_cfo(meas.cfo_hz); return add_meas_cell(std::move(c)); } -bool meas_cell_list::add_meas_cell(unique_cell_t cell) +bool meas_cell_list::add_meas_cell(unique_meas_cell cell) { bool ret = add_neighbour_cell_unsorted(std::move(cell)); if (ret) { @@ -200,7 +200,7 @@ bool meas_cell_list::add_meas_cell(unique_cell_t cell) return ret; } -bool meas_cell_list::add_neighbour_cell_unsorted(unique_cell_t new_cell) +bool meas_cell_list::add_neighbour_cell_unsorted(unique_meas_cell new_cell) { // Make sure cell is valid if (!new_cell->is_valid()) { @@ -215,7 +215,7 @@ bool meas_cell_list::add_neighbour_cell_unsorted(unique_cell_t new_cell) } // If cell exists, update RSRP value - cell_t* existing_cell = get_neighbour_cell_handle(new_cell->get_earfcn(), new_cell->get_pci()); + meas_cell* existing_cell = get_neighbour_cell_handle(new_cell->get_earfcn(), new_cell->get_pci()); if (existing_cell != nullptr) { if (std::isnormal(new_cell.get()->get_rsrp())) { existing_cell->set_rsrp(new_cell.get()->get_rsrp()); @@ -243,15 +243,15 @@ bool meas_cell_list::add_neighbour_cell_unsorted(unique_cell_t new_cell) void meas_cell_list::rem_last_neighbour() { if (not neighbour_cells.empty()) { - unique_cell_t& c = neighbour_cells.back(); + unique_meas_cell& c = neighbour_cells.back(); log_h->debug("Delete cell %s from neighbor list.\n", c->to_string().c_str()); neighbour_cells.pop_back(); } } -meas_cell_list::unique_cell_t meas_cell_list::remove_neighbour_cell(uint32_t earfcn, uint32_t pci) +meas_cell_list::unique_meas_cell meas_cell_list::remove_neighbour_cell(uint32_t earfcn, uint32_t pci) { - auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_cell_t& cell) { + auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_meas_cell& cell) { return cell->equals(earfcn, pci); }); if (it != neighbour_cells.end()) { @@ -265,9 +265,9 @@ meas_cell_list::unique_cell_t meas_cell_list::remove_neighbour_cell(uint32_t ear // Sort neighbour cells by decreasing order of RSRP void meas_cell_list::sort_neighbour_cells() { - std::sort(std::begin(neighbour_cells), std::end(neighbour_cells), [](const unique_cell_t& a, const unique_cell_t& b) { - return a->greater(b.get()); - }); + std::sort(std::begin(neighbour_cells), + std::end(neighbour_cells), + [](const unique_meas_cell& a, const unique_meas_cell& b) { return a->greater(b.get()); }); log_neighbour_cells(); } @@ -326,7 +326,7 @@ std::string meas_cell_list::print_neighbour_cells() const std::set meas_cell_list::get_neighbour_pcis(uint32_t earfcn) const { std::set pcis = {}; - for (const unique_cell_t& cell : neighbour_cells) { + for (const unique_meas_cell& cell : neighbour_cells) { if (cell->get_earfcn() == earfcn) { pcis.insert(cell->get_pci()); } @@ -339,7 +339,7 @@ bool meas_cell_list::has_neighbour_cell(uint32_t earfcn, uint32_t pci) const return get_neighbour_cell_handle(earfcn, pci) != nullptr; } -cell_t* meas_cell_list::find_cell(uint32_t earfcn, uint32_t pci) +meas_cell* meas_cell_list::find_cell(uint32_t earfcn, uint32_t pci) { if (serving_cell().phy_cell.pci == pci and serving_cell().phy_cell.earfcn == earfcn) { return &serving_cell(); @@ -355,7 +355,7 @@ int meas_cell_list::set_serving_cell(phy_cell_t phy_cell, bool discard_serving) } // Remove future serving cell from neighbours to make space for current serving cell - unique_cell_t new_serving_cell = remove_neighbour_cell(phy_cell.earfcn, phy_cell.pci); + unique_meas_cell new_serving_cell = remove_neighbour_cell(phy_cell.earfcn, phy_cell.pci); if (new_serving_cell == nullptr) { log_h->error("Setting serving cell: Unknown cell with earfcn=%d, PCI=%d\n", phy_cell.earfcn, phy_cell.pci); return SRSLTE_ERROR; @@ -375,12 +375,12 @@ int meas_cell_list::set_serving_cell(phy_cell_t phy_cell, bool discard_serving) return SRSLTE_SUCCESS; } -bool meas_cell_list::process_new_cell_meas(const std::vector& meas, - const std::function& filter_meas) +bool meas_cell_list::process_new_cell_meas(const std::vector& meas, + const std::function& filter_meas) { bool neighbour_added = false; for (const auto& m : meas) { - cell_t* c = nullptr; + meas_cell* c = nullptr; // Get serving_cell handle if it's the serving cell bool is_serving_cell = m.earfcn == 0 or is_same_cell(m, serving_cell()); diff --git a/srsue/src/stack/rrc/rrc_meas.cc b/srsue/src/stack/rrc/rrc_meas.cc index de3fc9341..13e798b6a 100644 --- a/srsue/src/stack/rrc/rrc_meas.cc +++ b/srsue/src/stack/rrc/rrc_meas.cc @@ -182,7 +182,7 @@ void rrc::rrc_meas::var_meas_report_list::init(rrc* rrc_ptr_) /* Generate report procedure 5.5.5 */ void rrc::rrc_meas::var_meas_report_list::generate_report(const uint32_t measId) { - cell_t* serv_cell = rrc_ptr->get_serving_cell(); + meas_cell* serv_cell = rrc_ptr->get_serving_cell(); if (serv_cell == nullptr) { log_h->warning("MEAS: Serving cell not set when evaluating triggers\n"); return; @@ -445,7 +445,7 @@ bool rrc::rrc_meas::var_meas_cfg::is_rsrp(report_cfg_eutra_s::trigger_quant_opts /* Evaluate event trigger conditions for each cell 5.5.4 */ void rrc::rrc_meas::var_meas_cfg::eval_triggers() { - cell_t* serv_cell = rrc_ptr->get_serving_cell(); + meas_cell* serv_cell = rrc_ptr->get_serving_cell(); if (serv_cell == nullptr) { log_h->warning("MEAS: Serving cell not set when evaluating triggers\n"); @@ -1097,7 +1097,7 @@ bool rrc::rrc_meas::var_meas_cfg::parse_meas_config(const meas_cfg_s* cfg, bool // According to 5.5.6.1, if the new configuration after a HO/Reest does not configure the target frequency, we need to // swap frequencies with source if (is_ho_reest) { - cell_t* serv_cell = rrc_ptr->get_serving_cell(); + meas_cell* serv_cell = rrc_ptr->get_serving_cell(); if (serv_cell) { // Check if the target frequency is configured uint32_t target_earfcn = serv_cell->get_earfcn(); diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 6ef536f8b..fc169bbab 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -90,7 +90,7 @@ proc_outcome_t rrc::cell_search_proc::handle_cell_found(const phy_cell_t& new_ce Info("Cell found in this frequency. Setting new serving cell EARFCN=%d PCI=%d ...\n", new_cell.earfcn, new_cell.pci); // Create a cell with NaN RSRP. Will be updated by new_phy_meas() during SIB search. - if (not rrc_ptr->meas_cells.add_meas_cell(unique_cell_t(new cell_t(new_cell)))) { + if (not rrc_ptr->meas_cells.add_meas_cell(unique_cell_t(new meas_cell(new_cell)))) { Error("Could not add new found cell\n"); return proc_outcome_t::error; } @@ -1541,7 +1541,7 @@ srslte::proc_outcome_t rrc::ho_proc::init(const asn1::rrc::rrc_conn_recfg_s& rrc : rrc_ptr->meas_cells.serving_cell().get_earfcn(); // Target cell shall be either serving cell (intra-cell HO) or neighbour cell - cell_t* cell_to_ho = rrc_ptr->meas_cells.find_cell(target_earfcn, mob_ctrl_info->target_pci); + meas_cell* cell_to_ho = rrc_ptr->meas_cells.find_cell(target_earfcn, mob_ctrl_info->target_pci); if (cell_to_ho != nullptr) { target_cell = cell_to_ho->phy_cell; } else {