From 4b525127c90e7f6f9c5c21b12aa2e2414368db71 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Thu, 30 Apr 2020 12:51:50 +0100 Subject: [PATCH] created separate cell ctxt common list --- srsenb/hdr/stack/rrc/rrc.h | 84 +++---------------------- srsenb/hdr/stack/rrc/rrc_cell_cfg.h | 57 +++++++++++++++++ srsenb/hdr/stack/rrc/rrc_config.h | 86 ++++++++++++++++++++++++++ srsenb/src/stack/rrc/CMakeLists.txt | 2 +- srsenb/src/stack/rrc/rrc.cc | 92 +++++++--------------------- srsenb/src/stack/rrc/rrc_cell_cfg.cc | 77 +++++++++++++++++++++++ srsenb/src/stack/rrc/rrc_mobility.cc | 3 +- 7 files changed, 256 insertions(+), 145 deletions(-) create mode 100644 srsenb/hdr/stack/rrc/rrc_cell_cfg.h create mode 100644 srsenb/hdr/stack/rrc/rrc_config.h create mode 100644 srsenb/src/stack/rrc/rrc_cell_cfg.cc diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index 1ff5a0ac7..be6922bc8 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -22,9 +22,9 @@ #ifndef SRSENB_RRC_H #define SRSENB_RRC_H +#include "rrc_config.h" #include "rrc_metrics.h" #include "srsenb/hdr/stack/upper/common_enb.h" -#include "srslte/asn1/rrc_asn1.h" #include "srslte/common/block_queue.h" #include "srslte/common/buffer_pool.h" #include "srslte/common/common.h" @@ -32,64 +32,13 @@ #include "srslte/common/stack_procedure.h" #include "srslte/common/timeout.h" #include "srslte/interfaces/enb_interfaces.h" -#include "srslte/interfaces/enb_rrc_interface_types.h" #include #include namespace srsenb { -struct rrc_cfg_sr_t { - uint32_t period; - asn1::rrc::sched_request_cfg_c::setup_s_::dsr_trans_max_e_ dsr_max; - uint32_t nof_prb; - uint32_t sf_mapping[80]; - uint32_t nof_subframes; -}; - -enum rrc_cfg_cqi_mode_t { RRC_CFG_CQI_MODE_PERIODIC = 0, RRC_CFG_CQI_MODE_APERIODIC, RRC_CFG_CQI_MODE_N_ITEMS }; - -static const char rrc_cfg_cqi_mode_text[RRC_CFG_CQI_MODE_N_ITEMS][20] = {"periodic", "aperiodic"}; - -typedef struct { - uint32_t sf_mapping[80]; - uint32_t nof_subframes; - uint32_t nof_prb; - uint32_t period; - uint32_t m_ri; - bool simultaneousAckCQI; - rrc_cfg_cqi_mode_t mode; -} rrc_cfg_cqi_t; - -typedef struct { - bool configured; - asn1::rrc::lc_ch_cfg_s::ul_specific_params_s_ lc_cfg; - asn1::rrc::pdcp_cfg_s pdcp_cfg; - asn1::rrc::rlc_cfg_c rlc_cfg; -} rrc_cfg_qci_t; - -#define MAX_NOF_QCI 10 - -struct rrc_cfg_t { - uint32_t enb_id; ///< Required to pack SIB1 - // Per eNB SIBs - asn1::rrc::sib_type1_s sib1; - asn1::rrc::sib_info_item_c sibs[ASN1_RRC_MAX_SIB]; - asn1::rrc::mac_main_cfg_s mac_cnfg; - - asn1::rrc::pusch_cfg_ded_s pusch_cfg; - asn1::rrc::ant_info_ded_s antenna_info; - asn1::rrc::pdsch_cfg_ded_s::p_a_e_ pdsch_cfg; - rrc_cfg_sr_t sr_cfg; - rrc_cfg_cqi_t cqi_cfg; - rrc_cfg_qci_t qci_cfg[MAX_NOF_QCI]; - bool enable_mbsfn; - uint32_t inactivity_timeout_ms; - srslte::CIPHERING_ALGORITHM_ID_ENUM eea_preference_list[srslte::CIPHERING_ALGORITHM_ID_N_ITEMS]; - srslte::INTEGRITY_ALGORITHM_ID_ENUM eia_preference_list[srslte::INTEGRITY_ALGORITHM_ID_N_ITEMS]; - bool meas_cfg_present = false; - srslte_cell_t cell; - cell_list_t cell_list; -}; +class cell_ctxt_common; +class cell_ctxt_common_list; static const char rrc_state_text[RRC_STATE_N_ITEMS][100] = {"IDLE", "WAIT FOR CON SETUP COMPLETE", @@ -158,17 +107,6 @@ public: const std::string& msg_type); private: - struct cell_ctxt_t { - uint32_t enb_cc_idx = 0; - asn1::rrc::mib_s mib; - asn1::rrc::sib_type1_s sib1; - asn1::rrc::sib_type2_s sib2; - const cell_cfg_t& cell_cfg; - std::vector sib_buffer; ///< Packed SIBs for given CC - - cell_ctxt_t(uint32_t idx, const cell_cfg_t& cell_cfg); - }; - class ue { public: @@ -313,18 +251,18 @@ private: // Struct to store the cell resources allocated to a user struct cell_res_ded_t { - const cell_ctxt_t* cell_common = nullptr; - uint32_t pmi_idx = 0; - uint32_t pucch_res = 0; - uint32_t prb_idx = 0; - uint32_t sf_idx = 0; + const cell_ctxt_common* cell_common = nullptr; + uint32_t pmi_idx = 0; + uint32_t pucch_res = 0; + uint32_t prb_idx = 0; + uint32_t sf_idx = 0; }; std::map cell_res_list = {}; int get_drbid_config(asn1::rrc::drb_to_add_mod_s* drb, int drbid); ///< Helper to access a cell cfg based on ue_cc_idx - cell_ctxt_t* get_ue_cc_cfg(uint32_t ue_cc_idx); + cell_ctxt_common* get_ue_cc_cfg(uint32_t ue_cc_idx); ///< Helper to fill SCell struct for RRR Connection Reconfig int fill_scell_to_addmod_list(asn1::rrc::rrc_conn_recfg_r8_ies_s* conn_reconf); @@ -378,14 +316,12 @@ private: srslte::log_ref rrc_log; // derived params - std::vector > cell_ctxt_list; + std::unique_ptr cell_ctxt_list; // state std::map > users; // NOTE: has to have fixed addr std::map pending_paging; - cell_ctxt_t* find_cell_ctxt(uint32_t cell_id); - void process_release_complete(uint16_t rnti); void process_rl_failure(uint16_t rnti); void rem_user(uint16_t rnti); diff --git a/srsenb/hdr/stack/rrc/rrc_cell_cfg.h b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h new file mode 100644 index 000000000..124849b02 --- /dev/null +++ b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h @@ -0,0 +1,57 @@ +/* + * Copyright 2013-2020 Software Radio Systems Limited + * + * This file is part of srsLTE. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#ifndef SRSLTE_RRC_CELL_CFG_H +#define SRSLTE_RRC_CELL_CFG_H + +#include "rrc_config.h" + +namespace srsenb { + +struct cell_ctxt_common { + uint32_t enb_cc_idx = 0; + asn1::rrc::mib_s mib; + asn1::rrc::sib_type1_s sib1; + asn1::rrc::sib_type2_s sib2; + const cell_cfg_t& cell_cfg; + std::vector > sib_buffer; ///< Packed SIBs for given CC + + cell_ctxt_common(uint32_t idx_, const cell_cfg_t& cfg) : enb_cc_idx(idx_), cell_cfg(cfg) {} +}; + +class cell_ctxt_common_list +{ +public: + explicit cell_ctxt_common_list(const rrc_cfg_t& cfg_); + + cell_ctxt_common* get_cc_idx(uint32_t enb_cc_idx) { return &cell_list[enb_cc_idx]; } + cell_ctxt_common* get_cell_id(uint32_t cell_id); + cell_ctxt_common* get_pci(uint32_t pci); + size_t nof_cells() const { return cell_list.size(); } + +private: + const rrc_cfg_t& cfg; + std::vector cell_list; +}; + +} // namespace srsenb + +#endif // SRSLTE_RRC_CELL_CFG_H diff --git a/srsenb/hdr/stack/rrc/rrc_config.h b/srsenb/hdr/stack/rrc/rrc_config.h new file mode 100644 index 000000000..23afae9ef --- /dev/null +++ b/srsenb/hdr/stack/rrc/rrc_config.h @@ -0,0 +1,86 @@ +/* + * Copyright 2013-2020 Software Radio Systems Limited + * + * This file is part of srsLTE. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#ifndef SRSLTE_RRC_CONFIG_H +#define SRSLTE_RRC_CONFIG_H + +#include "srslte/asn1/rrc_asn1.h" +#include "srslte/common/security.h" +#include "srslte/interfaces/enb_rrc_interface_types.h" + +namespace srsenb { + +struct rrc_cfg_sr_t { + uint32_t period; + asn1::rrc::sched_request_cfg_c::setup_s_::dsr_trans_max_e_ dsr_max; + uint32_t nof_prb; + uint32_t sf_mapping[80]; + uint32_t nof_subframes; +}; + +enum rrc_cfg_cqi_mode_t { RRC_CFG_CQI_MODE_PERIODIC = 0, RRC_CFG_CQI_MODE_APERIODIC, RRC_CFG_CQI_MODE_N_ITEMS }; + +static const char rrc_cfg_cqi_mode_text[RRC_CFG_CQI_MODE_N_ITEMS][20] = {"periodic", "aperiodic"}; + +typedef struct { + uint32_t sf_mapping[80]; + uint32_t nof_subframes; + uint32_t nof_prb; + uint32_t period; + uint32_t m_ri; + bool simultaneousAckCQI; + rrc_cfg_cqi_mode_t mode; +} rrc_cfg_cqi_t; + +typedef struct { + bool configured; + asn1::rrc::lc_ch_cfg_s::ul_specific_params_s_ lc_cfg; + asn1::rrc::pdcp_cfg_s pdcp_cfg; + asn1::rrc::rlc_cfg_c rlc_cfg; +} rrc_cfg_qci_t; + +#define MAX_NOF_QCI 10 + +struct rrc_cfg_t { + uint32_t enb_id; ///< Required to pack SIB1 + // Per eNB SIBs + asn1::rrc::sib_type1_s sib1; + asn1::rrc::sib_info_item_c sibs[ASN1_RRC_MAX_SIB]; + asn1::rrc::mac_main_cfg_s mac_cnfg; + + asn1::rrc::pusch_cfg_ded_s pusch_cfg; + asn1::rrc::ant_info_ded_s antenna_info; + asn1::rrc::pdsch_cfg_ded_s::p_a_e_ pdsch_cfg; + rrc_cfg_sr_t sr_cfg; + rrc_cfg_cqi_t cqi_cfg; + rrc_cfg_qci_t qci_cfg[MAX_NOF_QCI]; + bool enable_mbsfn; + uint32_t inactivity_timeout_ms; + srslte::CIPHERING_ALGORITHM_ID_ENUM eea_preference_list[srslte::CIPHERING_ALGORITHM_ID_N_ITEMS]; + srslte::INTEGRITY_ALGORITHM_ID_ENUM eia_preference_list[srslte::INTEGRITY_ALGORITHM_ID_N_ITEMS]; + bool meas_cfg_present = false; + srslte_cell_t cell; + cell_list_t cell_list; +}; + +} // namespace srsenb + +#endif // SRSLTE_RRC_CONFIG_H diff --git a/srsenb/src/stack/rrc/CMakeLists.txt b/srsenb/src/stack/rrc/CMakeLists.txt index c0652c43e..c5542753b 100644 --- a/srsenb/src/stack/rrc/CMakeLists.txt +++ b/srsenb/src/stack/rrc/CMakeLists.txt @@ -18,5 +18,5 @@ # and at http://www.gnu.org/licenses/. # -set(SOURCES rrc.cc rrc_mobility.cc) +set(SOURCES rrc.cc rrc_mobility.cc rrc_cell_cfg.cc) add_library(srsenb_rrc STATIC ${SOURCES}) \ No newline at end of file diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 9dfd46be5..e4018c659 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -20,6 +20,7 @@ */ #include "srsenb/hdr/stack/rrc/rrc.h" +#include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_mobility.h" #include "srslte/asn1/asn1_utils.h" #include "srslte/asn1/rrc_asn1_utils.h" @@ -114,8 +115,8 @@ void rrc::get_metrics(rrc_metrics_t& m) uint8_t* rrc::read_pdu_bcch_dlsch(const uint8_t cc_idx, const uint32_t sib_index) { - if (sib_index < ASN1_RRC_MAX_SIB && cc_idx < cell_ctxt_list.size()) { - return cell_ctxt_list.at(cc_idx)->sib_buffer.at(sib_index)->msg; + if (sib_index < ASN1_RRC_MAX_SIB && cc_idx < cell_ctxt_list->nof_cells()) { + return &cell_ctxt_list->get_cc_idx(cc_idx)->sib_buffer.at(sib_index)[0]; } return nullptr; } @@ -687,15 +688,6 @@ void rrc::process_rl_failure(uint16_t rnti) } } -///< Helper method to get cell ctxt based on id -rrc::cell_ctxt_t* rrc::find_cell_ctxt(uint32_t cell_id) -{ - auto it = std::find_if(cell_ctxt_list.begin(), - cell_ctxt_list.end(), - [cell_id](const std::unique_ptr& c) { return cell_id == c->cell_cfg.cell_id; }); - return (it == cell_ctxt_list.end()) ? nullptr : it->get(); -} - ///< User mutex must be hold by caller void rrc::process_release_complete(uint16_t rnti) { @@ -750,7 +742,7 @@ void rrc::config_mac() // set sib/prach cfg for (uint32_t i = 0; i < nof_si_messages; i++) { - item.sibs[i].len = cell_ctxt_list.at(ccidx)->sib_buffer.at(i)->N_bytes; + item.sibs[i].len = cell_ctxt_list->get_cc_idx(ccidx)->sib_buffer.at(i).size(); if (i == 0) { item.sibs[i].period_rf = 8; // SIB1 is always 8 rf } else { @@ -810,44 +802,18 @@ uint32_t rrc::generate_sibs() uint32_t nof_messages = 1 + cfg.sib1.sched_info_list.size(); sched_info_list_l& sched_info = cfg.sib1.sched_info_list; - // Store in cell_ctxt_list, the SIB cfg of each carrier - for (uint32_t cc_idx = 0; cc_idx < cfg.cell_list.size(); cc_idx++) { - cell_ctxt_list.push_back(std::unique_ptr(new cell_ctxt_t{cc_idx, cfg.cell_list[cc_idx]})); - cell_ctxt_t& cell_ctxt = *cell_ctxt_list.back(); - - // Set Cell MIB - asn1::number_to_enum(cell_ctxt.mib.dl_bw, cfg.cell.nof_prb); - cell_ctxt.mib.phich_cfg.phich_res.value = (phich_cfg_s::phich_res_opts::options)cfg.cell.phich_resources; - cell_ctxt.mib.phich_cfg.phich_dur.value = (phich_cfg_s::phich_dur_opts::options)cfg.cell.phich_length; - - // Set Cell SIB1 - cell_ctxt.sib1 = cfg.sib1; - // Update cellId - sib_type1_s::cell_access_related_info_s_* cell_access = &cell_ctxt.sib1.cell_access_related_info; - cell_access->cell_id.from_number((cfg.enb_id << 8u) + cell_ctxt.cell_cfg.cell_id); - cell_access->tac.from_number(cell_ctxt.cell_cfg.tac); - // Update DL EARFCN - cell_ctxt.sib1.freq_band_ind = (uint8_t)srslte_band_get_band(cell_ctxt.cell_cfg.dl_earfcn); - - // Set Cell SIB2 - // update PRACH root seq index for this cell - cell_ctxt.sib2 = cfg.sibs[1].sib2(); - cell_ctxt.sib2.rr_cfg_common.prach_cfg.root_seq_idx = cell_ctxt.cell_cfg.root_seq_idx; - // update carrier freq - if (cell_ctxt.sib2.freq_info.ul_carrier_freq_present) { - cell_ctxt.sib2.freq_info.ul_carrier_freq = cell_ctxt.cell_cfg.ul_earfcn; - } - } + // Store configs,SIBs in common cell ctxt list + cell_ctxt_list.reset(new cell_ctxt_common_list{cfg}); // generate and pack into SIB buffers for (uint32_t cc_idx = 0; cc_idx < cfg.cell_list.size(); cc_idx++) { - cell_ctxt_t& cell_ctxt = *cell_ctxt_list[cc_idx]; + cell_ctxt_common* cell_ctxt = cell_ctxt_list->get_cc_idx(cc_idx); // msg is array of SI messages, each SI message msg[i] may contain multiple SIBs // all SIBs in a SI message msg[i] share the same periodicity asn1::dyn_array msg(nof_messages + 1); // Copy SIB1 to first SI message - msg[0].msg.set_c1().set_sib_type1() = cell_ctxt.sib1; + msg[0].msg.set_c1().set_sib_type1() = cell_ctxt->sib1; // Copy rest of SIBs for (uint32_t sched_info_elem = 0; sched_info_elem < nof_messages - 1; sched_info_elem++) { @@ -860,7 +826,7 @@ uint32_t rrc::generate_sibs() // SIB2 always in second SI message if (msg_index == 1) { sib_info_item_c sibitem; - sibitem.set_sib2() = cell_ctxt.sib2; + sibitem.set_sib2() = cell_ctxt->sib2; sib_list.push_back(sibitem); } @@ -872,22 +838,17 @@ uint32_t rrc::generate_sibs() // Pack payload for all messages for (uint32_t msg_index = 0; msg_index < nof_messages; msg_index++) { - srslte::unique_byte_buffer_t sib = srslte::allocate_unique_buffer(*pool); - asn1::bit_ref bref(sib->msg, sib->get_tailroom()); + srslte::unique_byte_buffer_t sib_buffer = srslte::allocate_unique_buffer(*pool); + asn1::bit_ref bref(sib_buffer->msg, sib_buffer->get_tailroom()); if (msg[msg_index].pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) { rrc_log->error("Failed to pack SIB message %d\n", msg_index); } - sib->N_bytes = bref.distance_bytes(); - - cell_ctxt.sib_buffer.push_back(std::move(sib)); + sib_buffer->N_bytes = bref.distance_bytes(); + cell_ctxt->sib_buffer.emplace_back(sib_buffer->msg, sib_buffer->msg + sib_buffer->N_bytes); // Log SIBs in JSON format std::string log_msg("CC" + std::to_string(cc_idx) + " SIB payload"); - log_rrc_message(log_msg, - Tx, - cell_ctxt.sib_buffer.at(msg_index).get(), - msg[msg_index], - msg[msg_index].msg.c1().type().to_string()); + log_rrc_message(log_msg, Tx, sib_buffer.get(), msg[msg_index], msg[msg_index].msg.c1().type().to_string()); } if (cfg.sibs[6].type() == asn1::rrc::sys_info_r8_ies_s::sib_type_and_info_item_c_::types::sib7) { @@ -1958,19 +1919,19 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) } //! Helper method to access Cell configuration based on UE Carrier Index -rrc::cell_ctxt_t* rrc::ue::get_ue_cc_cfg(uint32_t ue_cc_idx) +cell_ctxt_common* rrc::ue::get_ue_cc_cfg(uint32_t ue_cc_idx) { if (ue_cc_idx >= current_sched_ue_cfg.supported_cc_list.size()) { return nullptr; } uint32_t enb_cc_idx = current_sched_ue_cfg.supported_cc_list[ue_cc_idx].enb_cc_idx; - return parent->cell_ctxt_list[enb_cc_idx].get(); + return parent->cell_ctxt_list->get_cc_idx(enb_cc_idx); } //! Method to fill SCellToAddModList for SCell info int rrc::ue::fill_scell_to_addmod_list(asn1::rrc::rrc_conn_recfg_r8_ies_s* conn_reconf) { - const cell_ctxt_t* pcell_cfg = get_ue_cc_cfg(UE_PCELL_CC_IDX); + const cell_ctxt_common* pcell_cfg = get_ue_cc_cfg(UE_PCELL_CC_IDX); if (pcell_cfg->cell_cfg.scell_list.empty()) { return SRSLTE_SUCCESS; } @@ -1995,10 +1956,10 @@ int rrc::ue::fill_scell_to_addmod_list(asn1::rrc::rrc_conn_recfg_r8_ies_s* conn_ if (p.first == UE_PCELL_CC_IDX) { continue; } - uint32_t scell_idx = p.first; - const cell_ctxt_t* cc_cfg = p.second.cell_common; - const sib_type1_s& cell_sib1 = cc_cfg->sib1; - const sib_type2_s& cell_sib2 = cc_cfg->sib2; + uint32_t scell_idx = p.first; + const cell_ctxt_common* cc_cfg = p.second.cell_common; + const sib_type1_s& cell_sib1 = cc_cfg->sib1; + const sib_type2_s& cell_sib2 = cc_cfg->sib2; scell_to_add_mod_r10_s cell; cell.scell_idx_r10 = scell_idx; @@ -2718,13 +2679,8 @@ int rrc::ue::cqi_allocate(uint32_t period, uint32_t ue_cc_idx) if (ue_cc_idx == UE_PCELL_CC_IDX) { cell_res_list[ue_cc_idx].cell_common = get_ue_cc_cfg(UE_PCELL_CC_IDX); } else { - const auto& l = parent->cell_ctxt_list; - uint32_t cell_id = get_ue_cc_cfg(UE_PCELL_CC_IDX)->cell_cfg.scell_list[ue_cc_idx - 1].cell_id; - // search for cell based on cell_id - auto it = std::find_if(l.begin(), l.end(), [cell_id](const std::unique_ptr& c) { - return c->cell_cfg.cell_id == cell_id; - }); - cell_res_list[ue_cc_idx].cell_common = it->get(); + uint32_t cell_id = get_ue_cc_cfg(UE_PCELL_CC_IDX)->cell_cfg.scell_list[ue_cc_idx - 1].cell_id; + cell_res_list[ue_cc_idx].cell_common = parent->cell_ctxt_list->get_cell_id(cell_id); } parent->rrc_log->info( @@ -2788,6 +2744,4 @@ int rrc::ue::get_ri(uint32_t m_ri, uint16_t* ri_idx) return ret; } -rrc::cell_ctxt_t::cell_ctxt_t(uint32_t idx, const cell_cfg_t& cell_cfg_) : enb_cc_idx(idx), cell_cfg(cell_cfg_) {} - } // namespace srsenb diff --git a/srsenb/src/stack/rrc/rrc_cell_cfg.cc b/srsenb/src/stack/rrc/rrc_cell_cfg.cc new file mode 100644 index 000000000..2bbc0c06d --- /dev/null +++ b/srsenb/src/stack/rrc/rrc_cell_cfg.cc @@ -0,0 +1,77 @@ +/* + * Copyright 2013-2020 Software Radio Systems Limited + * + * This file is part of srsLTE. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" + +using namespace asn1::rrc; + +namespace srsenb { + +cell_ctxt_common_list::cell_ctxt_common_list(const rrc_cfg_t& cfg_) : cfg(cfg_) +{ + cell_list.reserve(cfg.cell_list.size()); + + // Store the SIB cfg of each carrier + for (size_t ccidx = 0; ccidx < cfg.cell_list.size(); ++ccidx) { + cell_list.emplace_back(ccidx, cfg.cell_list[ccidx]); + auto& cell_ctxt = cell_list.back(); + + // Set Cell MIB + asn1::number_to_enum(cell_ctxt.mib.dl_bw, cfg.cell.nof_prb); + cell_ctxt.mib.phich_cfg.phich_res.value = (phich_cfg_s::phich_res_opts::options)cfg.cell.phich_resources; + cell_ctxt.mib.phich_cfg.phich_dur.value = (phich_cfg_s::phich_dur_opts::options)cfg.cell.phich_length; + + // Set Cell SIB1 + cell_ctxt.sib1 = cfg.sib1; + // Update cellId + sib_type1_s::cell_access_related_info_s_* cell_access = &cell_ctxt.sib1.cell_access_related_info; + cell_access->cell_id.from_number((cfg.enb_id << 8u) + cell_ctxt.cell_cfg.cell_id); + cell_access->tac.from_number(cell_ctxt.cell_cfg.tac); + // Update DL EARFCN + cell_ctxt.sib1.freq_band_ind = (uint8_t)srslte_band_get_band(cell_ctxt.cell_cfg.dl_earfcn); + + // Set Cell SIB2 + // update PRACH root seq index for this cell + cell_ctxt.sib2 = cfg.sibs[1].sib2(); + cell_ctxt.sib2.rr_cfg_common.prach_cfg.root_seq_idx = cell_ctxt.cell_cfg.root_seq_idx; + // update carrier freq + if (cell_ctxt.sib2.freq_info.ul_carrier_freq_present) { + cell_ctxt.sib2.freq_info.ul_carrier_freq = cell_ctxt.cell_cfg.ul_earfcn; + } + } +} + +cell_ctxt_common* cell_ctxt_common_list::get_cell_id(uint32_t cell_id) +{ + auto it = std::find_if(cell_list.begin(), cell_list.end(), [cell_id](const cell_ctxt_common& c) { + return c.cell_cfg.cell_id == cell_id; + }); + return it == cell_list.end() ? nullptr : &(*it); +} + +cell_ctxt_common* cell_ctxt_common_list::get_pci(uint32_t pci) +{ + auto it = std::find_if( + cell_list.begin(), cell_list.end(), [pci](const cell_ctxt_common& c) { return c.cell_cfg.pci == pci; }); + return it == cell_list.end() ? nullptr : &(*it); +} + +} // namespace srsenb diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 45795d90f..fb9fbf477 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -20,6 +20,7 @@ */ #include "srsenb/hdr/stack/rrc/rrc_mobility.h" +#include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/common.h" @@ -710,7 +711,7 @@ bool rrc::ue::rrc_mobility::fill_conn_recfg_msg(asn1::rrc::rrc_conn_recfg_r8_ies } // Check if there has been any update in ue_var_meas - cell_ctxt_t* pcell = rrc_ue->get_ue_cc_cfg(UE_PCELL_CC_IDX); + cell_ctxt_common* pcell = rrc_ue->get_ue_cc_cfg(UE_PCELL_CC_IDX); asn1::rrc::meas_cfg_s& meas_cfg = conn_recfg->meas_cfg; conn_recfg->meas_cfg_present = update_ue_var_meas_cfg(*ue_var_meas, pcell->enb_cc_idx, &meas_cfg); return conn_recfg->meas_cfg_present;