From 7e6487b6fac5d5846b1d3176aa1a75ee1c0f9d13 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 14 Sep 2020 14:54:33 +0200 Subject: [PATCH] perform PUCCH+PRACH PRB reservation right at the start of a new TTI in the scheduler --- srsenb/hdr/stack/mac/scheduler_carrier.h | 4 ---- srsenb/hdr/stack/mac/scheduler_grid.h | 1 + srsenb/src/stack/mac/scheduler_carrier.cc | 20 -------------------- srsenb/src/stack/mac/scheduler_grid.cc | 19 ++++++++++++++++++- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/srsenb/hdr/stack/mac/scheduler_carrier.h b/srsenb/hdr/stack/mac/scheduler_carrier.h index dd88e67ba..319e919b1 100644 --- a/srsenb/hdr/stack/mac/scheduler_carrier.h +++ b/srsenb/hdr/stack/mac/scheduler_carrier.h @@ -65,10 +65,6 @@ private: std::unique_ptr ul_metric; const uint32_t enb_cc_idx; - // derived from args - prbmask_t prach_mask; - prbmask_t pucch_mask; - // Subframe scheduling logic std::array sf_scheds; diff --git a/srsenb/hdr/stack/mac/scheduler_grid.h b/srsenb/hdr/stack/mac/scheduler_grid.h index fb2878871..bf302959b 100644 --- a/srsenb/hdr/stack/mac/scheduler_grid.h +++ b/srsenb/hdr/stack/mac/scheduler_grid.h @@ -326,6 +326,7 @@ private: const sched_cell_params_t* cc_cfg = nullptr; srslte::log_ref log_h; sf_sched_result* cc_results; ///< Results of other CCs for the same Subframe + prbmask_t pucch_mask; // internal state sf_grid_t tti_alloc; diff --git a/srsenb/src/stack/mac/scheduler_carrier.cc b/srsenb/src/stack/mac/scheduler_carrier.cc index e60ae75de..90e1ebea4 100644 --- a/srsenb/src/stack/mac/scheduler_carrier.cc +++ b/srsenb/src/stack/mac/scheduler_carrier.cc @@ -297,15 +297,6 @@ void sched::carrier_sched::carrier_cfg(const sched_cell_params_t& cell_params_) ul_metric.reset(new srsenb::ul_metric_rr{}); ul_metric->set_params(*cc_cfg); - // Setup constant PUCCH/PRACH mask - pucch_mask.resize(cc_cfg->nof_prb()); - if (cc_cfg->cfg.nrb_pucch > 0) { - pucch_mask.fill(0, (uint32_t)cc_cfg->cfg.nrb_pucch); - pucch_mask.fill(cc_cfg->nof_prb() - cc_cfg->cfg.nrb_pucch, cc_cfg->nof_prb()); - } - prach_mask.resize(cc_cfg->nof_prb()); - prach_mask.fill(cc_cfg->cfg.prach_freq_offset, cc_cfg->cfg.prach_freq_offset + 6); - // Initiate the tti_scheduler for each TTI for (sf_sched& tti_sched : sf_scheds) { tti_sched.init(*cc_cfg); @@ -391,17 +382,6 @@ void sched::carrier_sched::alloc_dl_users(sf_sched* tti_result) int sched::carrier_sched::alloc_ul_users(sf_sched* tti_sched) { - uint32_t tti_tx_ul = tti_sched->get_tti_tx_ul(); - - /* reserve PRBs for PRACH */ - if (srslte_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, tti_tx_ul, -1)) { - tti_sched->reserve_ul_prbs(prach_mask, false); - log_h->debug("SCHED: Allocated PRACH RBs. Mask: 0x%s\n", prach_mask.to_hex().c_str()); - } - - /* reserve PRBs for PUCCH */ - tti_sched->reserve_ul_prbs(pucch_mask, cc_cfg->nof_prb() != 6); - /* Call scheduler for UL data */ ul_metric->sched_users(*ue_db, tti_sched); diff --git a/srsenb/src/stack/mac/scheduler_grid.cc b/srsenb/src/stack/mac/scheduler_grid.cc index 87ba51990..63c506275 100644 --- a/srsenb/src/stack/mac/scheduler_grid.cc +++ b/srsenb/src/stack/mac/scheduler_grid.cc @@ -570,6 +570,12 @@ void sf_sched::init(const sched_cell_params_t& cell_params_) cc_cfg = &cell_params_; tti_alloc.init(*cc_cfg); max_msg3_prb = std::max(6u, cc_cfg->cfg.cell.nof_prb - (uint32_t)cc_cfg->cfg.nrb_pucch); + + pucch_mask.resize(cc_cfg->nof_prb()); + if (cc_cfg->cfg.nrb_pucch > 0) { + pucch_mask.fill(0, (uint32_t)cc_cfg->cfg.nrb_pucch); + pucch_mask.fill(cc_cfg->nof_prb() - cc_cfg->cfg.nrb_pucch, cc_cfg->nof_prb()); + } } void sf_sched::new_tti(uint32_t tti_rx_, sf_sched_result* cc_results_) @@ -584,6 +590,17 @@ void sf_sched::new_tti(uint32_t tti_rx_, sf_sched_result* cc_results_) tti_alloc.new_tti(tti_params); cc_results = cc_results_; + // Reserve PRBs for PUCCH + reserve_ul_prbs(pucch_mask, true); + + // Reserve PRBs for PRACH + if (srslte_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, tti_params.tti_tx_ul, -1)) { + prbmask_t prach_mask{cc_cfg->nof_prb()}; + prach_mask.fill(cc_cfg->cfg.prach_freq_offset, cc_cfg->cfg.prach_freq_offset + 6); + reserve_ul_prbs(prach_mask, cc_cfg->nof_prb() != 6); + log_h->debug("SCHED: Allocated PRACH RBs. Mask: 0x%s\n", prach_mask.to_hex().c_str()); + } + // setup first prb to be used for msg3 alloc. Account for potential PRACH alloc last_msg3_prb = cc_cfg->cfg.nrb_pucch; uint32_t tti_msg3_alloc = TTI_ADD(tti_params.tti_tx_ul, MSG3_DELAY_MS); @@ -1043,7 +1060,7 @@ uci_pusch_t is_uci_included(const sf_sched* sf_sched, } // Check if UCI needs to be allocated - const sched_interface::ue_cfg_t& ue_cfg = user->get_ue_cfg(); + const sched_interface::ue_cfg_t& ue_cfg = user->get_ue_cfg(); for (uint32_t enbccidx = 0; enbccidx < other_cc_results.enb_cc_list.size() and uci_alloc != UCI_PUSCH_ACK_CQI; ++enbccidx) { auto p = user->get_cell_index(enbccidx);