From cbb709d4e373d3ee675c87a3d8dda24c76516b3f Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 27 Sep 2021 12:29:01 +0200 Subject: [PATCH] sched,nr: function to log UEs buffer status before scheduling decision, fix const_iterator of circular_map --- lib/include/srsran/adt/circular_map.h | 7 ++++++- srsenb/hdr/stack/mac/nr/sched_nr_helpers.h | 6 ++++++ srsenb/src/stack/mac/nr/mac_nr.cc | 1 + srsenb/src/stack/mac/nr/sched_nr_helpers.cc | 21 +++++++++++++++++++++ srsenb/src/stack/mac/nr/sched_nr_worker.cc | 3 +++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/include/srsran/adt/circular_map.h b/lib/include/srsran/adt/circular_map.h index a7744f0fa..47b8ecd5f 100644 --- a/lib/include/srsran/adt/circular_map.h +++ b/lib/include/srsran/adt/circular_map.h @@ -90,7 +90,12 @@ public: { public: const_iterator() = default; - const_iterator(const static_circular_map* map, size_t idx_) : ptr(map), idx(idx_) {} + const_iterator(const static_circular_map* map, size_t idx_) : ptr(map), idx(idx_) + { + if (idx < ptr->capacity() and not ptr->present[idx]) { + ++(*this); + } + } const_iterator& operator++() { diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_helpers.h b/srsenb/hdr/stack/mac/nr/sched_nr_helpers.h index 4241fcf96..ab450d04a 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_helpers.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_helpers.h @@ -43,6 +43,12 @@ void fill_ul_dci_ue_fields(const slot_ue& ue, srsran_dci_location_t dci_pos, srsran_dci_ul_nr_t& dci); +/// Log UE state for slot being scheduled +void log_sched_slot_ues(srslog::basic_logger& logger, + slot_point pdcch_slot, + uint32_t cc, + const slot_ue_map_t& slot_ues); + /// Log Scheduling Result for a given BWP and slot void log_sched_bwp_result(srslog::basic_logger& logger, slot_point pdcch_slot, diff --git a/srsenb/src/stack/mac/nr/mac_nr.cc b/srsenb/src/stack/mac/nr/mac_nr.cc index 44017dd9e..0b45e3c65 100644 --- a/srsenb/src/stack/mac/nr/mac_nr.cc +++ b/srsenb/src/stack/mac/nr/mac_nr.cc @@ -139,6 +139,7 @@ uint16_t mac_nr::reserve_rnti(uint32_t enb_cc_idx) // Add new user to the scheduler so that it can RX/TX SRB0 srsenb::sched_nr_interface::ue_cfg_t ue_cfg = srsenb::get_default_ue_cfg(1); + ue_cfg.ue_bearers[0].direction = mac_lc_ch_cfg_t::IDLE; sched.ue_cfg(rnti, ue_cfg); return rnti; diff --git a/srsenb/src/stack/mac/nr/sched_nr_helpers.cc b/srsenb/src/stack/mac/nr/sched_nr_helpers.cc index b55b10c81..a73c0bfbb 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_helpers.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_helpers.cc @@ -112,6 +112,27 @@ void fill_ul_dci_ue_fields(const slot_ue& ue, fill_dci_common(ue, bwp_cfg, dci); } +void log_sched_slot_ues(srslog::basic_logger& logger, slot_point pdcch_slot, uint32_t cc, const slot_ue_map_t& slot_ues) +{ + if (not logger.info.enabled() or slot_ues.empty()) { + return; + } + + fmt::memory_buffer fmtbuf; + fmt::format_to(fmtbuf, "SCHED: UE candidates, pdcch_tti={}, cc={}: [", pdcch_slot, cc); + + const char* use_comma = ""; + for (const auto& ue_pair : slot_ues) { + auto& ue = ue_pair->second; + + fmt::format_to( + fmtbuf, "{}{{rnti=0x{:x}, dl_bs={}, ul_bs={}}}", use_comma, ue.rnti, ue.dl_pending_bytes, ue.ul_pending_bytes); + use_comma = ", "; + } + + logger.info("%s]", srsran::to_c_str(fmtbuf)); +} + void log_sched_bwp_result(srslog::basic_logger& logger, slot_point pdcch_slot, const bwp_res_grid& res_grid, diff --git a/srsenb/src/stack/mac/nr/sched_nr_worker.cc b/srsenb/src/stack/mac/nr/sched_nr_worker.cc index 6c843b245..57b1d40ad 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_worker.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_worker.cc @@ -90,6 +90,9 @@ void slot_cc_worker::run(slot_point pdcch_slot, ue_map_t& ue_db) // Create an BWP allocator object that will passed along to RA, SI, Data schedulers bwp_alloc.new_slot(slot_rx + TX_ENB_DELAY, slot_ues); + // Log UEs state for slot + log_sched_slot_ues(logger, bwp_alloc.get_pdcch_tti(), cfg.cc, slot_ues); + // Allocate pending RARs cell.bwps[0].ra.run_slot(bwp_alloc);