From ae4071a3df717a1ed2820602ceb349e8cd88cdbf Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 8 Nov 2021 13:38:18 +0000 Subject: [PATCH] nr,gnb,rrc: propagate RRC SIB configurations to mac and scheduler --- srsgnb/hdr/stack/mac/sched_nr_interface.h | 1 + srsgnb/hdr/stack/mac/sched_nr_signalling.h | 8 +++--- srsgnb/src/stack/mac/mac_nr.cc | 31 ++++++++++----------- srsgnb/src/stack/mac/sched_nr_signalling.cc | 31 +++++++++++---------- srsgnb/src/stack/rrc/rrc_nr.cc | 8 ++++-- 5 files changed, 41 insertions(+), 38 deletions(-) diff --git a/srsgnb/hdr/stack/mac/sched_nr_interface.h b/srsgnb/hdr/stack/mac/sched_nr_interface.h index 8ff4ca3fa..fc4a10766 100644 --- a/srsgnb/hdr/stack/mac/sched_nr_interface.h +++ b/srsgnb/hdr/stack/mac/sched_nr_interface.h @@ -67,6 +67,7 @@ public: struct cell_cfg_sib_t { uint32_t len; uint32_t period_rf; + uint32_t si_window_slots; }; struct cell_cfg_t { diff --git a/srsgnb/hdr/stack/mac/sched_nr_signalling.h b/srsgnb/hdr/stack/mac/sched_nr_signalling.h index 68fef4640..2ddf60eb1 100644 --- a/srsgnb/hdr/stack/mac/sched_nr_signalling.h +++ b/srsgnb/hdr/stack/mac/sched_nr_signalling.h @@ -65,10 +65,10 @@ private: struct si_msg_ctxt_t { // args - uint32_t n = 0; /// 0 for SIB1, n/index in schedulingInfoList in si-SchedulingInfo in SIB1 - uint32_t len = 0; /// length in bytes of SIB1 / SI message - uint32_t win_len = 0; /// window length in slots - uint32_t period = 0; /// periodicity of SIB1/SI window + uint32_t n = 0; /// 0 for SIB1, n/index in schedulingInfoList in si-SchedulingInfo in SIB1 + uint32_t len_bytes = 0; /// length in bytes of SIB1 / SI message + uint32_t win_len_slots = 0; /// window length in slots + uint32_t period_frames = 0; /// periodicity of SIB1/SI window in frames // state uint32_t n_tx = 0; /// nof transmissions of the same SIB1 / SI message diff --git a/srsgnb/src/stack/mac/mac_nr.cc b/srsgnb/src/stack/mac/mac_nr.cc index 220e16942..fe59ff938 100644 --- a/srsgnb/src/stack/mac/mac_nr.cc +++ b/srsgnb/src/stack/mac/mac_nr.cc @@ -255,24 +255,21 @@ int mac_nr::cell_cfg(const std::vector& detected_rachs.resize(nr_cells.size()); // read SIBs from RRC (SIB1 for now only) - for (int i = 0; i < 1 /* srsenb::sched_interface::MAX_SIBS */; i++) { - // TODO: add flag for SIBs into cell config - if (true) { - sib_info_t sib = {}; - sib.index = i; - sib.periodicity = 160; // TODO: read period_rf from config - sib.payload = srsran::make_byte_buffer(); - if (sib.payload == nullptr) { - logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); - return SRSRAN_ERROR; - } - if (rrc->read_pdu_bcch_dlsch(sib.index, *sib.payload) != SRSRAN_SUCCESS) { - logger.error("Couldn't read SIB %d from RRC", sib.index); - } - - logger.info("Including SIB %d into SI scheduling", sib.index + 1); - bcch_dlsch_payload.push_back(std::move(sib)); + for (uint32_t i = 0; i < nr_cells[0].sibs.size(); i++) { + sib_info_t sib = {}; + sib.index = i; + sib.periodicity = 160; // TODO: read period_rf from config + sib.payload = srsran::make_byte_buffer(); + if (sib.payload == nullptr) { + logger.error("Couldn't allocate PDU in %s().", __FUNCTION__); + return SRSRAN_ERROR; + } + if (rrc->read_pdu_bcch_dlsch(sib.index, *sib.payload) != SRSRAN_SUCCESS) { + logger.error("Couldn't read SIB %d from RRC", sib.index); } + + logger.info("Including SIB %d into SI scheduling", sib.index + 1); + bcch_dlsch_payload.push_back(std::move(sib)); } rx.reset(new mac_nr_rx{rlc, rrc, stack_task_queue, sched.get(), logger}); diff --git a/srsgnb/src/stack/mac/sched_nr_signalling.cc b/srsgnb/src/stack/mac/sched_nr_signalling.cc index c4d8f68f2..5ca008215 100644 --- a/srsgnb/src/stack/mac/sched_nr_signalling.cc +++ b/srsgnb/src/stack/mac/sched_nr_signalling.cc @@ -129,13 +129,15 @@ bool fill_dci_sib(prb_interval interv, si_sched::si_sched(const bwp_params_t& bwp_cfg_) : bwp_cfg(&bwp_cfg_), logger(srslog::fetch_basic_logger(bwp_cfg_.sched_cfg.logger_name)) { - // TODO: Get SIB1 other SI msgs config from RRC - pending_sis.emplace_back(); - pending_sis[0].n = 0; - pending_sis[0].len = 77; - pending_sis[0].period = 160; - pending_sis[0].win_len = 160; - pending_sis[0].si_softbuffer = harq_softbuffer_pool::get_instance().get_tx(bwp_cfg->nof_prb()); + for (uint32_t i = 0; i < bwp_cfg->cell_cfg.sibs.size(); ++i) { + pending_sis.emplace_back(); + si_msg_ctxt_t& si = pending_sis.back(); + si.n = i; + si.len_bytes = bwp_cfg->cell_cfg.sibs[i].len; + si.period_frames = bwp_cfg->cell_cfg.sibs[i].period_rf; + si.win_len_slots = bwp_cfg->cell_cfg.sibs[i].si_window_slots; + si.si_softbuffer = harq_softbuffer_pool::get_instance().get_tx(bwp_cfg->nof_prb()); + } } void si_sched::run_slot(bwp_slot_allocator& bwp_alloc) @@ -152,7 +154,7 @@ void si_sched::run_slot(bwp_slot_allocator& bwp_alloc) // Update SI windows uint32_t N = bwp_cfg->slots.size(); for (si_msg_ctxt_t& si : pending_sis) { - uint32_t x = (si.n - 1) * si.win_len; + uint32_t x = (si.n - 1) * si.win_len_slots; if (not si.win_start.valid()) { bool start_window; @@ -161,20 +163,21 @@ void si_sched::run_slot(bwp_slot_allocator& bwp_alloc) start_window = sl_pdcch.slot_idx() == 0 and sl_pdcch.sfn() % 2 == 0; } else { // 5.2.2.3.2 - Acquisition of SI message - start_window = (sl_pdcch.sfn() % si.period == x / N) and sl_pdcch.slot_idx() == x % bwp_cfg->slots.size(); + start_window = + (sl_pdcch.sfn() % si.period_frames == x / N) and sl_pdcch.slot_idx() == x % bwp_cfg->slots.size(); } if (start_window) { // If start of SI message window si.win_start = sl_pdcch; si.n_tx = 0; } - } else if (si.win_start + si.win_len >= sl_pdcch) { + } else if (si.win_start + si.win_len_slots >= sl_pdcch) { // If end of SI message window if (si.n == 0) { - logger.error("SCHED: Could not allocate SIB1, len=%d. Cause: %s", si.len, to_string(si.result)); + logger.error("SCHED: Could not allocate SIB1, len=%d. Cause: %s", si.len_bytes, to_string(si.result)); } else { logger.warning( - "SCHED: Could not allocate SI message idx=%d, len=%d. Cause: %s", si.n, si.len, to_string(si.result)); + "SCHED: Could not allocate SI message idx=%d, len=%d. Cause: %s", si.n, si.len_bytes, to_string(si.result)); } si.win_start.clear(); } @@ -205,9 +208,9 @@ void si_sched::run_slot(bwp_slot_allocator& bwp_alloc) si.win_start.clear(); si.n_tx++; if (si.n == 0) { - logger.debug("SCHED: Allocated SIB1, len=%d.", si.n, si.len); + logger.debug("SCHED: Allocated SIB1, len=%d.", si.n, si.len_bytes); } else { - logger.debug("SCHED: Allocated SI message idx=%d, len=%d.", si.n, si.len); + logger.debug("SCHED: Allocated SI message idx=%d, len=%d.", si.n, si.len_bytes); } } } diff --git a/srsgnb/src/stack/rrc/rrc_nr.cc b/srsgnb/src/stack/rrc/rrc_nr.cc index 0d0cda0a9..6f3758f29 100644 --- a/srsgnb/src/stack/rrc/rrc_nr.cc +++ b/srsgnb/src/stack/rrc/rrc_nr.cc @@ -300,9 +300,11 @@ void rrc_nr::config_mac() for (uint32_t i = 0; i < cell_ctxt->sib_buffer.size(); i++) { cell.sibs[i].len = cell_ctxt->sib_buffer[i]->N_bytes; if (i == 0) { - cell.sibs[i].period_rf = 16; // SIB1 is always 16 rf + cell.sibs[i].period_rf = 16; // SIB1 is always 16 rf + cell.sibs[i].si_window_slots = 160; } else { - cell.sibs[i].period_rf = cell_ctxt->sib1.si_sched_info.sched_info_list[i - 1].si_periodicity.to_number(); + cell.sibs[i].period_rf = cell_ctxt->sib1.si_sched_info.sched_info_list[i - 1].si_periodicity.to_number(); + cell.sibs[i].si_window_slots = cell_ctxt->sib1.si_sched_info.si_win_len.to_number(); } } @@ -406,7 +408,7 @@ int rrc_nr::read_pdu_bcch_bch(const uint32_t tti, srsran::byte_buffer_t& buffer) int rrc_nr::read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer) { if (sib_index >= cell_ctxt->sib_buffer.size()) { - logger.error("SIB %d is not a configured SIB.", sib_index); + logger.error("SI%s%d is not a configured SIB.", sib_index == 0 ? "B" : "", sib_index + 1); return SRSRAN_ERROR; }