From a351b2534e1c5edd923d3cb06512bc6d03f4313d Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 2 Nov 2020 19:43:20 +0000 Subject: [PATCH] allow PUSCH grants for CQI in PCell --- srsenb/hdr/stack/mac/scheduler_ue.h | 7 ++++++- srsenb/src/stack/mac/scheduler_grid.cc | 11 ++++++----- srsenb/src/stack/mac/scheduler_ue.cc | 19 ++++++++++++++++++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/srsenb/hdr/stack/mac/scheduler_ue.h b/srsenb/hdr/stack/mac/scheduler_ue.h index dd34eb4b3..045930b91 100644 --- a/srsenb/hdr/stack/mac/scheduler_ue.h +++ b/srsenb/hdr/stack/mac/scheduler_ue.h @@ -29,6 +29,7 @@ #include #include "scheduler_harq.h" +#include #include namespace srsenb { @@ -240,7 +241,11 @@ public: srslte_dci_format_t get_dci_format(); sched_dci_cce_t* get_locations(uint32_t enb_cc_idx, uint32_t current_cfi, uint32_t sf_idx); - cc_sched_ue* find_ue_carrier(uint32_t enb_cc_idx); + + cc_sched_ue* find_ue_carrier(uint32_t enb_cc_idx); + size_t nof_carriers() const { return carriers.size(); } + std::bitset scell_activation_mask() const; + int find_enb_cc_idx(uint32_t enb_cc_idx) const; bool needs_cqi(uint32_t tti, uint32_t cc_idx, bool will_send = false); uint32_t get_max_retx(); diff --git a/srsenb/src/stack/mac/scheduler_grid.cc b/srsenb/src/stack/mac/scheduler_grid.cc index 0f953aac4..0383d08cb 100644 --- a/srsenb/src/stack/mac/scheduler_grid.cc +++ b/srsenb/src/stack/mac/scheduler_grid.cc @@ -770,7 +770,7 @@ alloc_outcome_t sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_ma } // Check if allocation would cause segmentation - uint32_t ue_cc_idx = user->get_active_cell_index(cc_cfg->enb_cc_idx).second; + uint32_t ue_cc_idx = user->find_enb_cc_idx(cc_cfg->enb_cc_idx); const dl_harq_proc& h = user->get_dl_harq(pid, ue_cc_idx); if (h.is_empty()) { // It is newTx @@ -782,16 +782,17 @@ alloc_outcome_t sf_sched::alloc_dl_user(sched_ue* user, const rbgmask_t& user_ma } // Check if there is space in the PUCCH for HARQ ACKs - const sched_interface::ue_cfg_t& ue_cfg = user->get_ue_cfg(); - bool has_scells = ue_cfg.supported_cc_list.size() > 1; - if (has_scells and is_periodic_cqi_expected(ue_cfg, get_tti_tx_ul())) { + const sched_interface::ue_cfg_t& ue_cfg = user->get_ue_cfg(); + std::bitset scells = user->scell_activation_mask(); + if (scells.any() and (ue_cc_idx == 0 or scells[ue_cc_idx]) and is_periodic_cqi_expected(ue_cfg, get_tti_tx_ul())) { bool has_pusch_grant = is_ul_alloc(user->get_rnti()) or cc_results->is_ul_alloc(user->get_rnti()); if (not has_pusch_grant) { // Try to allocate small PUSCH grant, if there are no allocated PUSCH grants for this TTI yet prb_interval alloc = {}; uint32_t L = user->get_required_prb_ul(ue_cc_idx, srslte::ceil_div(SRSLTE_UCI_CQI_CODED_PUCCH_B + 2, 8)); tti_alloc.find_ul_alloc(L, &alloc); - if (ue_cc_idx != 0 and (alloc.length() == 0 or not alloc_ul_user(user, alloc))) { + bool ul_alloc_success = alloc.length() > 0 or alloc_ul_user(user, alloc); + if (ue_cc_idx != 0 and not ul_alloc_success) { // For SCells, if we can't allocate small PUSCH grant, abort DL allocation return alloc_outcome_t::PUCCH_COLLISION; } diff --git a/srsenb/src/stack/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc index 6295e2cf6..dc32a3a2c 100644 --- a/srsenb/src/stack/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -1199,11 +1199,28 @@ sched_dci_cce_t* sched_ue::get_locations(uint32_t enb_cc_idx, uint32_t cfi, uint } cc_sched_ue* sched_ue::find_ue_carrier(uint32_t enb_cc_idx) +{ + int ue_cc_idx = find_enb_cc_idx(enb_cc_idx); + return ue_cc_idx >= 0 ? &carriers[ue_cc_idx] : nullptr; +} + +std::bitset sched_ue::scell_activation_mask() const +{ + std::bitset ret{0}; + for (size_t i = 1; i < carriers.size(); ++i) { + if (carriers[i].cc_state() == cc_st::active) { + ret[i] = true; + } + } + return ret; +} + +int sched_ue::find_enb_cc_idx(uint32_t enb_cc_idx) const { auto it = std::find_if(carriers.begin(), carriers.end(), [enb_cc_idx](const cc_sched_ue& c) { return c.get_cell_cfg()->enb_cc_idx == enb_cc_idx; }); - return it != carriers.end() ? &(*it) : nullptr; + return it != carriers.end() ? std::distance(carriers.begin(), it) : -1; } int cc_sched_ue::cqi_to_tbs(uint32_t nof_prb, uint32_t nof_re, bool use_tbs_index_alt, bool is_ul, uint32_t* mcs)