diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_pdcch.h b/srsenb/hdr/stack/mac/nr/sched_nr_pdcch.h index c151a8465..68dfec3d3 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_pdcch.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_pdcch.h @@ -72,9 +72,9 @@ private: pdcch_grant_type_t alloc_type; slot_ue* ue; }; - srsran::bounded_vector dci_list; - pdcch_dl_list_t& pdcch_dl_list; - pdcch_ul_list_t& pdcch_ul_list; + srsran::bounded_vector dci_list; + pdcch_dl_list_t& pdcch_dl_list; + pdcch_ul_list_t& pdcch_ul_list; // DFS decision tree of PDCCH grants struct tree_node { @@ -85,7 +85,7 @@ private: /// Accumulation of all PDCCH masks for the current solution (DFS path) coreset_bitmap total_mask, current_mask; }; - using alloc_tree_dfs_t = srsran::bounded_vector; + using alloc_tree_dfs_t = std::vector; alloc_tree_dfs_t dfs_tree, saved_dfs_tree; srsran::span get_cce_loc_table(const alloc_record& record) const; diff --git a/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc b/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc index 6982a5726..61ffe8df8 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc @@ -110,6 +110,13 @@ alloc_result bwp_slot_allocator::alloc_rar_and_msg3(uint16_t if (ret != alloc_result::success) { return ret; } + if (bwp_pdcch_slot.rar.full()) { + return alloc_result::no_grant_space; + } + if (pending_rars.size() > MAX_GRANTS) { + logger.error("SCHED: Trying to allocate too many Msg3 grants in a single slot (%zd)", pending_rars.size()); + return alloc_result::invalid_grant_params; + } // Check DL RB collision if (bwp_pdcch_slot.dl_prbs.collides(interv)) { @@ -209,6 +216,10 @@ alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_gr if (result != alloc_result::success) { return result; } + if (bwp_uci_slot.pending_acks.full()) { + logger.warning("SCHED: PDSCH allocation for rnti=0x%x failed due to lack of space for respective ACK", ue.rnti); + return alloc_result::no_grant_space; + } if (bwp_pdsch_slot.dl_prbs.collides(dl_grant)) { return alloc_result::sch_collision; } diff --git a/srsenb/src/stack/mac/nr/sched_nr_pdcch.cc b/srsenb/src/stack/mac/nr/sched_nr_pdcch.cc index 2d54546d0..c6098b80d 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_pdcch.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_pdcch.cc @@ -56,6 +56,7 @@ bool coreset_region::alloc_dci(pdcch_grant_type_t alloc_type, srsran_assert((user == nullptr) xor (alloc_type == pdcch_grant_type_t::dl_data or alloc_type == pdcch_grant_type_t::ul_data), "UE should be only provided for DL or UL data allocations"); + srsran_assert(not dci_list.full(), "SCHED: Unable to allocate DCI"); saved_dfs_tree.clear(); alloc_record record; @@ -80,13 +81,13 @@ bool coreset_region::alloc_dci(pdcch_grant_type_t alloc_type, dci_list.push_back(record); return true; } - if (dfs_tree.empty()) { + if (saved_dfs_tree.empty()) { saved_dfs_tree = dfs_tree; } } while (get_next_dfs()); // Revert steps to initial state, before dci record allocation was attempted - dfs_tree = saved_dfs_tree; + dfs_tree.swap(saved_dfs_tree); if (record.alloc_type == pdcch_grant_type_t::ul_data) { pdcch_ul_list.pop_back(); } else { diff --git a/srsenb/src/stack/mac/nr/sched_nr_signalling.cc b/srsenb/src/stack/mac/nr/sched_nr_signalling.cc index a3b310be7..5d125b5e8 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_signalling.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_signalling.cc @@ -34,6 +34,10 @@ void sched_nzp_csi_rs(srsran::const_span nzp_csi_rs_set // Check if the resource is scheduled for this slot if (srsran_csi_rs_send(&nzp_csi_resource.periodicity, &slot_cfg)) { + if (csi_rs_list.full()) { + srslog::fetch_basic_logger("MAC-NR").error("SCHED: Failed to allocate NZP-CSI RS"); + return; + } csi_rs_list.push_back(nzp_csi_resource); } } @@ -42,6 +46,10 @@ void sched_nzp_csi_rs(srsran::const_span nzp_csi_rs_set void sched_ssb_basic(const slot_point& sl_point, uint32_t ssb_periodicity, ssb_list& ssb_list) { + if (ssb_list.full()) { + srslog::fetch_basic_logger("MAC-NR").error("SCHED: Failed to allocate SSB"); + return; + } // If the periodicity is 0, it means that the parameter was not passed by the upper layers. // In that case, we use default value of 5ms (see Clause 4.1, TS 38.213) if (ssb_periodicity == 0) { diff --git a/srsenb/src/stack/mac/nr/sched_nr_worker.cc b/srsenb/src/stack/mac/nr/sched_nr_worker.cc index ecc0b6215..6bba51151 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_worker.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_worker.cc @@ -183,6 +183,10 @@ void slot_cc_worker::postprocess_decisions() } if (not has_pusch) { // If any UCI information is triggered, schedule PUCCH + if (bwp_slot.pucch.full()) { + logger.warning("SCHED: Cannot fit pending UCI into PUCCH"); + continue; + } bwp_slot.pucch.emplace_back(); mac_interface_phy_nr::pucch_t& pucch = bwp_slot.pucch.back();