From f2af447b1acb552a6856cfc2f05f3132ea8d63cf Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Wed, 13 May 2020 12:36:00 +0100 Subject: [PATCH] use of unique_byte_buffer for sib scheduling to allow for padding --- srsenb/hdr/stack/rrc/rrc_cell_cfg.h | 20 ++++++------- srsenb/src/stack/rrc/rrc.cc | 9 +++--- srsenb/src/stack/rrc/rrc_cell_cfg.cc | 43 ++++++++++++++-------------- 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/srsenb/hdr/stack/rrc/rrc_cell_cfg.h b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h index 828bc7623..bb33b229d 100644 --- a/srsenb/hdr/stack/rrc/rrc_cell_cfg.h +++ b/srsenb/hdr/stack/rrc/rrc_cell_cfg.h @@ -56,12 +56,12 @@ private: /** Storage of cell-specific eNB config and derived params */ struct cell_info_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 + 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_info_common(uint32_t idx_, const cell_cfg_t& cfg) : enb_cc_idx(idx_), cell_cfg(cfg) {} }; @@ -71,15 +71,15 @@ class cell_info_common_list public: explicit cell_info_common_list(const rrc_cfg_t& cfg_); - cell_info_common* get_cc_idx(uint32_t enb_cc_idx) { return &cell_list[enb_cc_idx]; } - const cell_info_common* get_cc_idx(uint32_t enb_cc_idx) const { return &cell_list[enb_cc_idx]; } + cell_info_common* get_cc_idx(uint32_t enb_cc_idx) { return cell_list[enb_cc_idx].get(); } + const cell_info_common* get_cc_idx(uint32_t enb_cc_idx) const { return cell_list[enb_cc_idx].get(); } const cell_info_common* get_cell_id(uint32_t cell_id) const; const cell_info_common* get_pci(uint32_t pci) const; size_t nof_cells() const { return cell_list.size(); } private: - const rrc_cfg_t& cfg; - std::vector cell_list; + const rrc_cfg_t& cfg; + std::vector > cell_list; }; /** Class used to store all the resources specific to a UE's cell */ diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 59f24d197..0a77b01e8 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -117,7 +117,7 @@ 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_common_list->nof_cells()) { - return &cell_common_list->get_cc_idx(cc_idx)->sib_buffer.at(sib_index)[0]; + return cell_common_list->get_cc_idx(cc_idx)->sib_buffer.at(sib_index)->msg; } return nullptr; } @@ -635,7 +635,7 @@ void rrc::config_mac() // set sib/prach cfg for (uint32_t i = 0; i < nof_si_messages; i++) { - item.sibs[i].len = cell_common_list->get_cc_idx(ccidx)->sib_buffer.at(i).size(); + item.sibs[i].len = cell_common_list->get_cc_idx(ccidx)->sib_buffer.at(i)->N_bytes; if (i == 0) { item.sibs[i].period_rf = 8; // SIB1 is always 8 rf } else { @@ -737,11 +737,12 @@ uint32_t rrc::generate_sibs() rrc_log->error("Failed to pack SIB message %d\n", msg_index); } sib_buffer->N_bytes = bref.distance_bytes(); - cell_ctxt->sib_buffer.emplace_back(sib_buffer->msg, sib_buffer->msg + sib_buffer->N_bytes); + cell_ctxt->sib_buffer.push_back(std::move(sib_buffer)); // Log SIBs in JSON format std::string log_msg("CC" + std::to_string(cc_idx) + " SIB payload"); - log_rrc_message(log_msg, Tx, sib_buffer.get(), msg[msg_index], msg[msg_index].msg.c1().type().to_string()); + log_rrc_message( + log_msg, Tx, cell_ctxt->sib_buffer.back().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) { diff --git a/srsenb/src/stack/rrc/rrc_cell_cfg.cc b/srsenb/src/stack/rrc/rrc_cell_cfg.cc index 5faa3cc26..48f976bb7 100644 --- a/srsenb/src/stack/rrc/rrc_cell_cfg.cc +++ b/srsenb/src/stack/rrc/rrc_cell_cfg.cc @@ -50,48 +50,49 @@ cell_info_common_list::cell_info_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(); + for (uint32_t ccidx = 0; ccidx < cfg.cell_list.size(); ++ccidx) { + cell_list.emplace_back(std::unique_ptr{new cell_info_common{ccidx, cfg.cell_list[ccidx]}}); + cell_info_common* cell_ctxt = cell_list.back().get(); // 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; + 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; + 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); + 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); + 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; + 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; + if (cell_ctxt->sib2.freq_info.ul_carrier_freq_present) { + cell_ctxt->sib2.freq_info.ul_carrier_freq = cell_ctxt->cell_cfg.ul_earfcn; } } } const cell_info_common* cell_info_common_list::get_cell_id(uint32_t cell_id) const { - auto it = std::find_if(cell_list.begin(), cell_list.end(), [cell_id](const cell_info_common& c) { - return c.cell_cfg.cell_id == cell_id; + auto it = std::find_if(cell_list.begin(), cell_list.end(), [cell_id](const std::unique_ptr& c) { + return c->cell_cfg.cell_id == cell_id; }); - return it == cell_list.end() ? nullptr : &(*it); + return it == cell_list.end() ? nullptr : it->get(); } const cell_info_common* cell_info_common_list::get_pci(uint32_t pci) const { - auto it = std::find_if( - cell_list.begin(), cell_list.end(), [pci](const cell_info_common& c) { return c.cell_cfg.pci == pci; }); - return it == cell_list.end() ? nullptr : &(*it); + auto it = std::find_if(cell_list.begin(), cell_list.end(), [pci](const std::unique_ptr& c) { + return c->cell_cfg.pci == pci; + }); + return it == cell_list.end() ? nullptr : it->get(); } /*************************