From 02ccb8b32b9e5bd04db95bc1c2c1e23cdeedf1b3 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Thu, 5 Mar 2020 18:02:22 +0000 Subject: [PATCH] fix wrong calculation of sched tx and rx delays --- srsenb/hdr/stack/mac/scheduler_grid.h | 1 + srsenb/hdr/stack/mac/scheduler_ue.h | 2 +- srsenb/src/stack/mac/scheduler.cc | 2 +- srsenb/src/stack/mac/scheduler_carrier.cc | 2 +- srsenb/src/stack/mac/scheduler_grid.cc | 8 ++++---- srsenb/src/stack/mac/scheduler_harq.cc | 8 ++++---- srsenb/test/mac/scheduler_test_common.cc | 2 +- srsenb/test/mac/scheduler_test_rand.cc | 6 +++--- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/srsenb/hdr/stack/mac/scheduler_grid.h b/srsenb/hdr/stack/mac/scheduler_grid.h index 1cf9cd255..05ef26b99 100644 --- a/srsenb/hdr/stack/mac/scheduler_grid.h +++ b/srsenb/hdr/stack/mac/scheduler_grid.h @@ -53,6 +53,7 @@ struct tti_params_t { uint32_t sf_idx; uint32_t sfn; explicit tti_params_t(uint32_t tti_rx_); + uint32_t tti_rx_ack_dl() const { return tti_tx_ul; } }; //! Result of a Subframe sched computation diff --git a/srsenb/hdr/stack/mac/scheduler_ue.h b/srsenb/hdr/stack/mac/scheduler_ue.h index b7b06be48..59733196b 100644 --- a/srsenb/hdr/stack/mac/scheduler_ue.h +++ b/srsenb/hdr/stack/mac/scheduler_ue.h @@ -41,7 +41,7 @@ struct sched_dci_cce_t { }; struct sched_ue_carrier { - const static int SCHED_MAX_HARQ_PROC = SRSLTE_FDD_NOF_HARQ; + const static int SCHED_MAX_HARQ_PROC = TX_DELAY + FDD_HARQ_DELAY_MS; sched_ue_carrier(const sched_interface::ue_cfg_t& cfg_, const sched_cell_params_t& cell_cfg_, diff --git a/srsenb/src/stack/mac/scheduler.cc b/srsenb/src/stack/mac/scheduler.cc index 6cac81548..f8e2f3041 100644 --- a/srsenb/src/stack/mac/scheduler.cc +++ b/srsenb/src/stack/mac/scheduler.cc @@ -401,7 +401,7 @@ int sched::ul_sched(uint32_t tti, uint32_t cc_idx, srsenb::sched_interface::ul_s std::lock_guard lock(sched_mutex); // Compute scheduling Result for tti_rx - uint32_t tti_rx = sched_utils::tti_subtract(tti, 2 * FDD_HARQ_DELAY_MS); + uint32_t tti_rx = sched_utils::tti_subtract(tti, TX_DELAY + FDD_HARQ_DELAY_MS); if (cc_idx < carrier_schedulers.size()) { const sf_sched_result& tti_sched = carrier_schedulers[cc_idx]->generate_tti_result(tti_rx); diff --git a/srsenb/src/stack/mac/scheduler_carrier.cc b/srsenb/src/stack/mac/scheduler_carrier.cc index 252d6e5ff..b841466a1 100644 --- a/srsenb/src/stack/mac/scheduler_carrier.cc +++ b/srsenb/src/stack/mac/scheduler_carrier.cc @@ -378,7 +378,7 @@ void sched::carrier_sched::alloc_dl_users(sf_sched* tti_result) // NOTE: In case of 6 PRBs, do not transmit if there is going to be a PRACH in the UL to avoid collisions if (cc_cfg->nof_prb() == 6) { - uint32_t tti_rx_ack = TTI_RX_ACK(tti_result->get_tti_rx()); + uint32_t tti_rx_ack = tti_result->get_tti_params().tti_rx_ack_dl(); if (srslte_prach_tti_opportunity_config_fdd(cc_cfg->cfg.prach_config, tti_rx_ack, -1)) { tti_result->reserve_dl_rbgs(0, cc_cfg->nof_rbgs); } diff --git a/srsenb/src/stack/mac/scheduler_grid.cc b/srsenb/src/stack/mac/scheduler_grid.cc index cb7414313..e2915210e 100644 --- a/srsenb/src/stack/mac/scheduler_grid.cc +++ b/srsenb/src/stack/mac/scheduler_grid.cc @@ -48,10 +48,10 @@ const char* alloc_outcome_t::to_string() const tti_params_t::tti_params_t(uint32_t tti_rx_) : tti_rx(tti_rx_), - sf_idx(TTI_TX(tti_rx) % 10), - tti_tx_dl(TTI_TX(tti_rx)), - tti_tx_ul(TTI_RX_ACK(tti_rx)), - sfn(TTI_TX(tti_rx) / 10) + sf_idx(TTI_ADD(tti_rx, TX_DELAY) % 10), + tti_tx_dl(TTI_ADD(tti_rx, TX_DELAY)), + tti_tx_ul(TTI_ADD(tti_rx, (TX_DELAY + FDD_HARQ_DELAY_MS))), + sfn(TTI_ADD(tti_rx, TX_DELAY) / 10) { } diff --git a/srsenb/src/stack/mac/scheduler_harq.cc b/srsenb/src/stack/mac/scheduler_harq.cc index 4b10387d2..be62f37e3 100644 --- a/srsenb/src/stack/mac/scheduler_harq.cc +++ b/srsenb/src/stack/mac/scheduler_harq.cc @@ -223,7 +223,7 @@ rbgmask_t dl_harq_proc::get_rbgmask() const bool dl_harq_proc::has_pending_retx(uint32_t tb_idx, uint32_t tti_tx_dl) const { uint32_t tti_diff = srslte_tti_interval(tti_tx_dl, tti); - return (tti_diff < (10240 / 2)) and (tti_diff >= SRSLTE_FDD_NOF_HARQ) and has_pending_retx_common(tb_idx); + return (tti_diff < (10240 / 2)) and (tti_diff >= TX_DELAY + FDD_HARQ_DELAY_MS) and has_pending_retx_common(tb_idx); } int dl_harq_proc::get_tbs(uint32_t tb_idx) const @@ -366,7 +366,7 @@ dl_harq_proc* harq_entity::get_pending_dl_harq(uint32_t tti_tx_dl) std::pair harq_entity::set_ack_info(uint32_t tti_rx, uint32_t tb_idx, bool ack) { for (auto& h : dl_harqs) { - if (TTI_TX(h.get_tti()) == tti_rx) { + if (TTI_ADD(h.get_tti(), FDD_HARQ_DELAY_MS) == tti_rx) { h.set_ack(tb_idx, ack); return {h.get_id(), h.get_tbs(tb_idx)}; } @@ -381,8 +381,8 @@ ul_harq_proc* harq_entity::get_ul_harq(uint32_t tti_tx_ul) void harq_entity::reset_pending_data(uint32_t tti_rx) { - uint32_t tti_tx_ul = TTI_RX_ACK(tti_rx); - uint32_t tti_tx_dl = TTI_TX(tti_rx); + uint32_t tti_tx_ul = TTI_ADD(tti_rx, (TX_DELAY + FDD_HARQ_DELAY_MS)); + uint32_t tti_tx_dl = TTI_ADD(tti_rx, TX_DELAY); // Reset ACK state of UL Harq get_ul_harq(tti_tx_ul)->reset_pending_data(); diff --git a/srsenb/test/mac/scheduler_test_common.cc b/srsenb/test/mac/scheduler_test_common.cc index 46ade7f50..642f8c0b7 100644 --- a/srsenb/test/mac/scheduler_test_common.cc +++ b/srsenb/test/mac/scheduler_test_common.cc @@ -137,7 +137,7 @@ int output_sched_tester::test_pdsch_collisions(const tti_params_t& // forbid Data in DL if it conflicts with PRACH for PRB==6 if (cell_params.cfg.cell.nof_prb == 6) { - uint32_t tti_rx_ack = TTI_RX_ACK(tti_params.tti_rx); + uint32_t tti_rx_ack = tti_params.tti_rx_ack_dl(); if (srslte_prach_tti_opportunity_config_fdd(cell_params.cfg.prach_config, tti_rx_ack, -1)) { dl_allocs.fill(0, dl_allocs.size()); } diff --git a/srsenb/test/mac/scheduler_test_rand.cc b/srsenb/test/mac/scheduler_test_rand.cc index 41bfbbb8d..4bc1a4df6 100644 --- a/srsenb/test/mac/scheduler_test_rand.cc +++ b/srsenb/test/mac/scheduler_test_rand.cc @@ -111,7 +111,7 @@ struct sched_tester : public srsenb::common_sched_tester { bool has_ul_retx = false; bool has_ul_newtx = false; ///< *no* retx, but has tx bool ul_retx_got_delayed = false; - srsenb::dl_harq_proc dl_harqs[2 * FDD_HARQ_DELAY_MS]; + srsenb::dl_harq_proc dl_harqs[srsenb::sched_ue_carrier::SCHED_MAX_HARQ_PROC]; srsenb::ul_harq_proc ul_harq; }; struct sched_tti_data { @@ -174,7 +174,7 @@ void sched_tester::before_sched() tti_data.total_ues.has_dl_tx |= d.has_dl_tx; tti_data.total_ues.has_ul_newtx |= d.has_ul_newtx; - for (uint32_t i = 0; i < 2 * FDD_HARQ_DELAY_MS; ++i) { + for (uint32_t i = 0; i < srsenb::sched_ue_carrier::SCHED_MAX_HARQ_PROC; ++i) { const srsenb::dl_harq_proc& h = user->get_dl_harq(i, CARRIER_IDX); tti_data.ue_data[rnti].dl_harqs[i] = h; } @@ -359,7 +359,7 @@ int sched_tester::test_harqs() // Check whether some pids got old if (check_old_pids) { for (auto& user : ue_db) { - for (int i = 0; i < 2 * FDD_HARQ_DELAY_MS; i++) { + for (int i = 0; i < srsenb::sched_ue_carrier::SCHED_MAX_HARQ_PROC; i++) { if (not user.second.get_dl_harq(i, CARRIER_IDX).is_empty(0)) { if (srslte_tti_interval(tti_info.tti_params.tti_tx_dl, user.second.get_dl_harq(i, CARRIER_IDX).get_tti()) > 49) {