diff --git a/srsenb/hdr/stack/rrc/rrc_cell_cfg.h b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h index 80a51f05b..c21628fb9 100644 --- a/srsenb/hdr/stack/rrc/rrc_cell_cfg.h +++ b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h @@ -77,13 +77,16 @@ public: const cell_info_common* get_pci(uint32_t pci) const; size_t nof_cells() const { return cell_list.size(); } - std::vector get_potential_cells(uint32_t enb_cc_idx) const; - private: const rrc_cfg_t& cfg; std::vector > cell_list; }; +// Helper methods +std::vector get_available_intraenb_cells(const cell_info_common_list& list, + uint32_t pcell_enb_cc_idx); +std::vector get_available_intraenb_earfcns(const cell_info_common_list& list, uint32_t pcell_enb_cc_idx); + /** Class used to store all the resources specific to a UE's cell */ struct cell_ctxt_dedicated { uint32_t ue_cc_idx; diff --git a/srsenb/hdr/stack/rrc/rrc_mobility.h b/srsenb/hdr/stack/rrc/rrc_mobility.h index 4fcf63a15..833adbba9 100644 --- a/srsenb/hdr/stack/rrc/rrc_mobility.h +++ b/srsenb/hdr/stack/rrc/rrc_mobility.h @@ -68,7 +68,7 @@ public: std::string to_string() const; static var_meas_cfg_t make(const asn1::rrc::meas_cfg_s& meas_cfg); - static var_meas_cfg_t make(std::vector active_cells, const rrc_cfg_t& cfg); + static var_meas_cfg_t make(const std::vector& active_earfcns, const rrc_cfg_t& cfg); private: asn1::rrc::var_meas_cfg_s var_meas; @@ -104,9 +104,9 @@ public: private: // helper methods - bool update_ue_var_meas_cfg(uint32_t src_earfcn, - std::vector target_cells, - asn1::rrc::meas_cfg_s* diff_meas_cfg); + bool update_ue_var_meas_cfg(uint32_t src_earfcn, + std::vector target_earfcns, + asn1::rrc::meas_cfg_s* diff_meas_cfg); // Handover from source cell bool start_ho_preparation(uint32_t target_eci, uint8_t measobj_id, bool fwd_direct_path_available); diff --git a/srsenb/src/stack/rrc/rrc_cell_cfg.cc b/srsenb/src/stack/rrc/rrc_cell_cfg.cc index ed10fb09d..7fecb8d60 100644 --- a/srsenb/src/stack/rrc/rrc_cell_cfg.cc +++ b/srsenb/src/stack/rrc/rrc_cell_cfg.cc @@ -95,18 +95,33 @@ const cell_info_common* cell_info_common_list::get_pci(uint32_t pci) const return it == cell_list.end() ? nullptr : it->get(); } -std::vector cell_info_common_list::get_potential_cells(uint32_t enb_cc_idx) const +std::vector get_available_intraenb_cells(const cell_info_common_list& list, + uint32_t pcell_enb_cc_idx) { - const cell_info_common* pcell = get_cc_idx(enb_cc_idx); + const cell_info_common* pcell = list.get_cc_idx(pcell_enb_cc_idx); std::vector cells(pcell->cell_cfg.scell_list.size() + 1); cells[0] = pcell; for (uint32_t i = 0; i < pcell->cell_cfg.scell_list.size(); ++i) { uint32_t cell_id = pcell->cell_cfg.scell_list[i].cell_id; - cells[i + 1] = get_cell_id(cell_id); + cells[i + 1] = list.get_cell_id(cell_id); } return cells; } +std::vector get_available_intraenb_earfcns(const cell_info_common_list& list, uint32_t pcell_enb_cc_idx) +{ + std::vector cells = get_available_intraenb_cells(list, pcell_enb_cc_idx); + std::vector earfcns(cells.size()); + for (uint32_t i = 0; i < cells.size(); ++i) { + earfcns[i] = cells[i]->cell_cfg.dl_earfcn; + } + // sort by earfcn + std::sort(earfcns.begin(), earfcns.end()); + // remove duplicates + earfcns.erase(std::unique(earfcns.begin(), earfcns.end()), earfcns.end()); + return earfcns; +} + /************************* * cell ctxt dedicated ************************/ diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 1abe27a56..6f7ca80c6 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -453,26 +453,18 @@ var_meas_cfg_t var_meas_cfg_t::make(const asn1::rrc::meas_cfg_s& meas_cfg) return var; } -var_meas_cfg_t var_meas_cfg_t::make(std::vector active_cells, const rrc_cfg_t& cfg) +var_meas_cfg_t var_meas_cfg_t::make(const std::vector& active_earfcns, const rrc_cfg_t& cfg) { var_meas_cfg_t var_meas; - // sort by earfcn, and remove duplicates. This avoids unnecessary measObjects/measIds transmissions - auto cmp_freq = [](const cell_info_common* lhs, const cell_info_common* rhs) { - return lhs->cell_cfg.dl_earfcn < rhs->cell_cfg.dl_earfcn; - }; - auto equal_freq = [](const cell_info_common* lhs, const cell_info_common* rhs) { - return lhs->cell_cfg.dl_earfcn == rhs->cell_cfg.dl_earfcn; - }; - std::sort(active_cells.begin(), active_cells.end(), cmp_freq); - active_cells.erase(std::unique(active_cells.begin(), active_cells.end(), equal_freq), active_cells.end()); - // Add PCell+Scells as MeasObjs - for (const cell_info_common* c : active_cells) { - var_meas.add_meas_obj(c->cell_cfg.dl_earfcn); - } if (not cfg.meas_cfg_present) { return var_meas; } + // Add PCell+Scells as MeasObjs + for (uint32_t earfcn : active_earfcns) { + var_meas.add_meas_obj(earfcn); + } + for (const auto& cell_cfg : cfg.cell_list) { // inserts all neighbor cells for (const meas_cell_cfg_t& meascell : cell_cfg.meas_cfg.meas_cells) { @@ -583,10 +575,10 @@ bool rrc::ue::rrc_mobility::fill_conn_recfg_no_ho_cmd(asn1::rrc::rrc_conn_recfg_ } // Check if there has been any update in ue_var_meas based on UE current cell list - cell_ctxt_dedicated* pcell = rrc_ue->cell_ded_list.get_ue_cc_idx(UE_PCELL_CC_IDX); - uint32_t src_earfcn = pcell->get_dl_earfcn(); - auto target_cells = rrc_enb->cell_common_list->get_potential_cells(pcell->cell_common->enb_cc_idx); - conn_recfg->meas_cfg_present = update_ue_var_meas_cfg(src_earfcn, target_cells, &conn_recfg->meas_cfg); + cell_ctxt_dedicated* pcell = rrc_ue->cell_ded_list.get_ue_cc_idx(UE_PCELL_CC_IDX); + uint32_t src_earfcn = pcell->get_dl_earfcn(); + auto target_earfcns = get_available_intraenb_earfcns(*rrc_enb->cell_common_list, pcell->cell_common->enb_cc_idx); + conn_recfg->meas_cfg_present = update_ue_var_meas_cfg(src_earfcn, target_earfcns, &conn_recfg->meas_cfg); return conn_recfg->meas_cfg_present; } @@ -793,13 +785,13 @@ bool rrc::ue::rrc_mobility::start_s1_tenb_ho( return is_in_state(); } -bool rrc::ue::rrc_mobility::update_ue_var_meas_cfg(uint32_t src_earfcn, - std::vector target_cells, - asn1::rrc::meas_cfg_s* diff_meas_cfg) +bool rrc::ue::rrc_mobility::update_ue_var_meas_cfg(uint32_t src_earfcn, + std::vector target_earfcns, + asn1::rrc::meas_cfg_s* diff_meas_cfg) { // Make UE Target VarMeasCfg based on active cells and parsed Config files - var_meas_cfg_t target_var_meas = var_meas_cfg_t::make(target_cells, rrc_enb->cfg); - uint32_t target_earfcn = target_cells[0]->cell_cfg.dl_earfcn; + var_meas_cfg_t target_var_meas = var_meas_cfg_t::make(target_earfcns, rrc_enb->cfg); + uint32_t target_earfcn = target_earfcns[0]; // Apply TS 36.331 5.5.6.1 - If Source and Target eNB EARFCNs do no match, update SourceVarMeasCfg.MeasIdList if (target_earfcn != src_earfcn) { @@ -917,8 +909,8 @@ void rrc::ue::rrc_mobility::fill_mobility_reconf_common(asn1::rrc::dl_dcch_msg_s ant_info.ue_tx_ant_sel.set(setup_e::release); // Add MeasConfig of target cell - auto target_cells = rrc_enb->cell_common_list->get_potential_cells(target_cell.enb_cc_idx); - recfg_r8.meas_cfg_present = update_ue_var_meas_cfg(src_dl_earfcn, target_cells, &recfg_r8.meas_cfg); + auto target_earfcns = get_available_intraenb_earfcns(*rrc_enb->cell_common_list, target_cell.enb_cc_idx); + recfg_r8.meas_cfg_present = update_ue_var_meas_cfg(src_dl_earfcn, target_earfcns, &recfg_r8.meas_cfg); } /**