From fef61554b2b5e64e225e481a2a212db1ceb3dd06 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Wed, 6 Jul 2022 10:34:05 +0200 Subject: [PATCH] srsgnb,sched: mark as occupied the resources used by SSB before scheduling other PDSCH (eg SIB1). Prevents overlapping SIB1 PDSCH with SSB --- .../hdr/stack/mac/sched_nr_grant_allocator.h | 2 ++ srsgnb/hdr/stack/mac/sched_nr_sch.h | 3 +++ srsgnb/src/stack/mac/sched_nr_signalling.cc | 21 +++++++++++++------ srsgnb/src/stack/mac/sched_nr_worker.cc | 6 ++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/srsgnb/hdr/stack/mac/sched_nr_grant_allocator.h b/srsgnb/hdr/stack/mac/sched_nr_grant_allocator.h index 44850847a..00ea1422b 100644 --- a/srsgnb/hdr/stack/mac/sched_nr_grant_allocator.h +++ b/srsgnb/hdr/stack/mac/sched_nr_grant_allocator.h @@ -57,6 +57,8 @@ struct bwp_slot_grid { explicit bwp_slot_grid(const bwp_params_t& bwp_params, uint32_t slot_idx_); void reset(); + void reserve_pdsch(const prb_grant& grant) { pdschs.reserve_prbs(grant); } + bool is_dl() const { return cfg->slots[slot_idx].is_dl; } bool is_ul() const { return cfg->slots[slot_idx].is_ul; } }; diff --git a/srsgnb/hdr/stack/mac/sched_nr_sch.h b/srsgnb/hdr/stack/mac/sched_nr_sch.h index d478a1864..c1f88061c 100644 --- a/srsgnb/hdr/stack/mac/sched_nr_sch.h +++ b/srsgnb/hdr/stack/mac/sched_nr_sch.h @@ -46,6 +46,9 @@ public: return dl_prbs.prbs(); } + /// Marks a range of PRBS as occupied, preventing further allocations + void reserve_prbs(const prb_grant& grant) { dl_prbs |= grant; } + /// Verifies if the input arguments are valid for an SI allocation and grant doesnt collide with other grants alloc_result is_si_grant_valid(uint32_t ss_id, const prb_grant& grant) const; diff --git a/srsgnb/src/stack/mac/sched_nr_signalling.cc b/srsgnb/src/stack/mac/sched_nr_signalling.cc index f237c2df1..b400a473f 100644 --- a/srsgnb/src/stack/mac/sched_nr_signalling.cc +++ b/srsgnb/src/stack/mac/sched_nr_signalling.cc @@ -96,6 +96,17 @@ void sched_dl_signalling(bwp_slot_allocator& bwp_alloc) // Schedule SSB sched_ssb_basic(sl_pdcch, bwp_params.cell_cfg.ssb.periodicity_ms, bwp_params.cell_cfg.mib, sl_grid.dl.phy.ssb); + // Mark SSB region as occupied + if (!sl_grid.dl.phy.ssb.empty()) { + float ssb_offset_hz = + bwp_params.cell_cfg.carrier.ssb_center_freq_hz - bwp_params.cell_cfg.carrier.dl_center_frequency_hz; + int ssb_offset_rb = ceil(ssb_offset_hz / (15000.0f * 12)); + int ssb_start_rb = bwp_params.cell_cfg.carrier.nof_prb / 2 + ssb_offset_rb - 10; + uint32_t ssb_len_rb = 20; + assert(ssb_start_rb >= 0 && ssb_start_rb + ssb_len_rb < bwp_params.cell_cfg.carrier.nof_prb); + sl_grid.reserve_pdsch(prb_grant({(uint32_t)ssb_start_rb, ssb_start_rb + ssb_len_rb})); + } + // Schedule NZP-CSI-RS sched_nzp_csi_rs(bwp_params.cfg.pdsch.nzp_csi_rs_sets, cfg, sl_grid.dl.phy.nzp_csi_rs); } @@ -150,12 +161,10 @@ void si_sched::run_slot(bwp_slot_allocator& bwp_alloc) } } 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_bytes, to_string(si.result)); - } else { - logger.warning( - "SCHED: Could not allocate SI message idx=%d, len=%d. Cause: %s", si.n, si.len_bytes, to_string(si.result)); - } + srsran_always_assert( + si.n == 0, "SCHED: Could not allocate SIB1, len=%d. Cause: %s", si.len_bytes, to_string(si.result)); + logger.warning( + "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(); } } diff --git a/srsgnb/src/stack/mac/sched_nr_worker.cc b/srsgnb/src/stack/mac/sched_nr_worker.cc index 861047a60..8dd159ea0 100644 --- a/srsgnb/src/stack/mac/sched_nr_worker.cc +++ b/srsgnb/src/stack/mac/sched_nr_worker.cc @@ -74,9 +74,15 @@ dl_sched_res_t* cc_worker::run_slot(slot_point tx_sl, ue_map_t& ue_db) // Log UEs state for slot log_sched_slot_ues(logger, tx_sl, cfg.cc, slot_ues); + const uint32_t ss_id = 0; + slot_point sl_pdcch = bwp_alloc.get_pdcch_tti(); + + prb_bitmap prbs_before = bwp_alloc.res_grid()[sl_pdcch].pdschs.occupied_prbs(ss_id, srsran_dci_format_nr_1_0); // Allocate cell DL signalling sched_dl_signalling(bwp_alloc); + prb_bitmap prbs_after = bwp_alloc.res_grid()[sl_pdcch].pdschs.occupied_prbs(ss_id, srsran_dci_format_nr_1_0); + // Allocate pending SIBs bwps[0].si.run_slot(bwp_alloc);