From 16b5e1fd4de8104c66a0415c37a1a937e36937b3 Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 12 Mar 2021 16:21:39 +0000 Subject: [PATCH] fix collision detection of n1pucch for the ACK and SR in the scheduler --- .../stack/mac/sched_phy_ch/sf_cch_allocator.h | 7 +++++-- .../stack/mac/sched_phy_ch/sf_cch_allocator.cc | 17 +++++++++-------- srsenb/test/mac/sched_test_rand.cc | 3 +++ srsenb/test/mac/sched_test_utils.h | 10 +++++----- srsenb/test/mac/sched_ue_ded_test_suite.cc | 8 ++++++++ 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h b/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h index ca5ba2674..aa86fc6f0 100644 --- a/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h +++ b/srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h @@ -74,8 +74,8 @@ private: // args size_t nof_cces; - const sched_cell_params_t* cc_cfg = nullptr; - srslte_pucch_cfg_t* pucch_cfg = nullptr; + const sched_cell_params_t* cc_cfg = nullptr; + srslte_pucch_cfg_t* pucch_cfg_temp = nullptr; uint32_t cfi; // state std::vector dci_alloc_tree; @@ -111,6 +111,9 @@ private: std::vector dci_record_list; ///< Keeps a record of all the PDCCH allocations done so far }; +// Helper methods +bool is_pucch_sr_collision(const srslte_pucch_cfg_t& ue_pucch_cfg, tti_point tti_tx_dl_ack, uint32_t n1_pucch); + } // namespace srsenb #endif // SRSLTE_PDCCH_SCHED_H diff --git a/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc b/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc index 5934f3c31..304978dac 100644 --- a/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc +++ b/srsenb/src/stack/mac/sched_phy_ch/sf_cch_allocator.cc @@ -159,8 +159,8 @@ std::string sf_cch_allocator::result_to_string(bool verbose) const sf_cch_allocator::alloc_tree_t::alloc_tree_t(uint32_t this_cfi, const sched_cell_params_t& cc_params, - srslte_pucch_cfg_t& pucch_cfg) : - cfi(this_cfi), cc_cfg(&cc_params), pucch_cfg(&pucch_cfg), nof_cces(cc_params.nof_cce_table[this_cfi - 1]) + srslte_pucch_cfg_t& pucch_cfg_common) : + cfi(this_cfi), cc_cfg(&cc_params), pucch_cfg_temp(&pucch_cfg_common), nof_cces(cc_params.nof_cce_table[this_cfi - 1]) { dci_alloc_tree.reserve(8); } @@ -172,10 +172,10 @@ void sf_cch_allocator::alloc_tree_t::reset() dci_alloc_tree.clear(); } -bool is_pucch_sr_collision(const srslte_pucch_cfg_t& pucch_cfg, tti_point tti_tx_dl, uint32_t n1_pucch) +bool is_pucch_sr_collision(const srslte_pucch_cfg_t& ue_pucch_cfg, tti_point tti_tx_dl_ack, uint32_t n1_pucch) { - if (pucch_cfg.sr_configured && srslte_ue_ul_sr_send_tti(&pucch_cfg, tti_tx_dl.to_uint())) { - return n1_pucch == pucch_cfg.n_pucch_sr; + if (ue_pucch_cfg.sr_configured && srslte_ue_ul_sr_send_tti(&ue_pucch_cfg, tti_tx_dl_ack.to_uint())) { + return n1_pucch == ue_pucch_cfg.n_pucch_sr; } return false; } @@ -209,14 +209,15 @@ bool sf_cch_allocator::alloc_tree_t::add_tree_node_leaves(int if (dci_record.alloc_type == alloc_type_t::DL_DATA and not dci_record.pusch_uci) { // The UE needs to allocate space in PUCCH for HARQ-ACK - pucch_cfg->n_pucch = ncce_pos + pucch_cfg->N_pucch_1; + pucch_cfg_temp->n_pucch = ncce_pos + pucch_cfg_temp->N_pucch_1; - if (is_pucch_sr_collision(*pucch_cfg, to_tx_dl_ack(tti_rx_), pucch_cfg->n_pucch)) { + if (is_pucch_sr_collision( + dci_record.user->get_ue_cfg().pucch_cfg, to_tx_dl_ack(tti_rx_), pucch_cfg_temp->n_pucch)) { // avoid collision of HARQ-ACK with own SR n(1)_pucch continue; } - pucch_prbidx = srslte_pucch_n_prb(&cc_cfg->cfg.cell, pucch_cfg, 0); + pucch_prbidx = srslte_pucch_n_prb(&cc_cfg->cfg.cell, pucch_cfg_temp, 0); if (not cc_cfg->sched_cfg->pucch_mux_enabled and parent_pucch_mask.test(pucch_prbidx)) { // PUCCH allocation would collide with other PUCCH/PUSCH grants. Try another CCE position continue; diff --git a/srsenb/test/mac/sched_test_rand.cc b/srsenb/test/mac/sched_test_rand.cc index 631626cba..20ee20174 100644 --- a/srsenb/test/mac/sched_test_rand.cc +++ b/srsenb/test/mac/sched_test_rand.cc @@ -285,6 +285,9 @@ sched_sim_events rand_sim_params(uint32_t nof_ttis) sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_period = pick_random_uniform({0, 40, 80}); sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_offset = std::uniform_int_distribution{ 0, sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_period}(srsenb::get_rand_gen()); + sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.pucch_cfg.n_pucch_sr = + std::uniform_int_distribution{0, 2047}(srsenb::get_rand_gen()); + sim_gen.sim_args.start_tti = 0; sim_gen.sim_args.sched_args.pdsch_mcs = boolean_dist() ? -1 : std::uniform_int_distribution<>{0, 24}(srsenb::get_rand_gen()); diff --git a/srsenb/test/mac/sched_test_utils.h b/srsenb/test/mac/sched_test_utils.h index 7a3a83645..4adc9e091 100644 --- a/srsenb/test/mac/sched_test_utils.h +++ b/srsenb/test/mac/sched_test_utils.h @@ -73,6 +73,10 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg() ue_cfg.ue_bearers[srsenb::RB_ID_DRB1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; ue_cfg.ue_bearers[srsenb::RB_ID_DRB1].group = 1; + ue_cfg.pucch_cfg.sr_configured = true; + ue_cfg.pucch_cfg.I_sr = 15; // periodicity of 20 msec + ue_cfg.pucch_cfg.n_pucch_sr = 0; + return ue_cfg; } @@ -117,11 +121,7 @@ inline srsenb::sched_interface::ue_cfg_t generate_setup_ue_cfg(const srsenb::sch inline srsenb::sched_interface::ue_cfg_t generate_reconf_ue_cfg(const srsenb::sched_interface::ue_cfg_t& final_cfg) { srsenb::sched_interface::ue_cfg_t cfg = generate_setup_ue_cfg(final_cfg); - - cfg.supported_cc_list.resize(1); - cfg.ue_bearers = {}; - cfg.ue_bearers[srsenb::RB_ID_SRB0] = final_cfg.ue_bearers[srsenb::RB_ID_SRB0]; - cfg.ue_bearers[srsenb::RB_ID_SRB1] = final_cfg.ue_bearers[srsenb::RB_ID_SRB1]; + cfg.ue_bearers[srsenb::RB_ID_SRB2] = final_cfg.ue_bearers[srsenb::RB_ID_SRB1]; return cfg; } diff --git a/srsenb/test/mac/sched_ue_ded_test_suite.cc b/srsenb/test/mac/sched_ue_ded_test_suite.cc index e8c223f52..637cededd 100644 --- a/srsenb/test/mac/sched_ue_ded_test_suite.cc +++ b/srsenb/test/mac/sched_ue_ded_test_suite.cc @@ -13,6 +13,7 @@ #include "sched_ue_ded_test_suite.h" #include "lib/include/srslte/mac/pdu.h" #include "srsenb/hdr/stack/mac/sched_helpers.h" +#include "srsenb/hdr/stack/mac/sched_phy_ch/sf_cch_allocator.h" #include "srslte/common/test_common.h" namespace srsenb { @@ -65,6 +66,7 @@ int test_pdsch_grant(const sim_enb_ctxt_t& enb_ctxt, const sim_ue_ctxt_t& ue_ctxt = *enb_ctxt.ue_db.at(pdsch.dci.rnti); const sched_interface::ue_cfg_t::cc_cfg_t* cc_cfg = ue_ctxt.get_cc_cfg(enb_cc_idx); const sched_interface::cell_cfg_t& cell_params = (*enb_ctxt.cell_params)[enb_cc_idx]; + bool has_pusch_grant = find_pusch_grant(pdsch.dci.rnti, sf_out.ul_cc_result[enb_cc_idx]) != nullptr; // TEST: Check if CC is configured and active CONDERROR(cc_cfg == nullptr or not cc_cfg->active, "PDSCH allocation for disabled or unavailable cc"); @@ -107,6 +109,12 @@ int test_pdsch_grant(const sim_enb_ctxt_t& enb_ctxt, CONDERROR(coderate > 0.930f * Qm, "Max coderate was exceeded"); } + // TEST: PUCCH-ACK will not collide with SR + CONDERROR(not has_pusch_grant and is_pucch_sr_collision(ue_ctxt.ue_cfg.pucch_cfg, + to_tx_dl_ack(sf_out.tti_rx), + pdsch.dci.location.ncce + cell_params.n1pucch_an), + "Collision detected between UE PUCCH-ACK and SR"); + return SRSLTE_SUCCESS; }