diff --git a/lib/include/srslte/common/common.h b/lib/include/srslte/common/common.h index af7d66ccf..fe7fd3a6a 100644 --- a/lib/include/srslte/common/common.h +++ b/lib/include/srslte/common/common.h @@ -59,6 +59,7 @@ #define TTIMOD(tti) (tti % TTIMOD_SZ) #define INVALID_TTI 10241 +#define TX_ENB_DELAY FDD_HARQ_DELAY_UL_MS #define PHICH_MAX_SF 6 // Maximum PHICH in a subframe (1 in FDD, > 1 in TDD, see table 9.1.2-1 36.213) diff --git a/lib/include/srslte/common/tti_point.h b/lib/include/srslte/common/tti_point.h index 55e23b3bf..a5d3d405f 100644 --- a/lib/include/srslte/common/tti_point.h +++ b/lib/include/srslte/common/tti_point.h @@ -31,7 +31,7 @@ namespace srslte { struct tti_point { constexpr tti_point() = default; - explicit tti_point(uint32_t tti_val_) : tti_val(tti_val_ % 10240) + explicit tti_point(uint32_t tti_val_) : tti_val(tti_val_ % 10240u) { if (tti_val_ > std::numeric_limits::max() / 2) { // there was a overflow at tti initialization @@ -118,21 +118,29 @@ inline tti_point min(tti_point tti1, tti_point tti2) return tti1 < tti2 ? tti1 : tti2; } -inline tti_point to_tx_dl(const srslte::tti_point& t) +using tti_interval = srslte::interval; + +} // namespace srslte + +namespace srsenb { + +inline srslte::tti_point to_tx_dl(srslte::tti_point t) { - return t + FDD_HARQ_DELAY_UL_MS; + return t + TX_ENB_DELAY; } -inline tti_point to_tx_ul(const srslte::tti_point& t) +inline srslte::tti_point to_tx_ul(srslte::tti_point t) { - return t + (FDD_HARQ_DELAY_UL_MS + FDD_HARQ_DELAY_DL_MS); + return t + (TX_ENB_DELAY + FDD_HARQ_DELAY_DL_MS); } -inline tti_point to_tx_dl_ack(const srslte::tti_point& t) +inline srslte::tti_point to_tx_dl_ack(srslte::tti_point t) { return to_tx_ul(t); } +inline srslte::tti_point to_tx_ul_ack(srslte::tti_point t) +{ + return to_tx_ul(t) + TX_ENB_DELAY; +} -using tti_interval = srslte::interval; - -} // namespace srslte +} // namespace srsenb #endif // SRSLTE_TTI_POINT_H diff --git a/srsenb/hdr/stack/mac/scheduler_common.h b/srsenb/hdr/stack/mac/scheduler_common.h index a4fbe0f68..7c539c3c6 100644 --- a/srsenb/hdr/stack/mac/scheduler_common.h +++ b/srsenb/hdr/stack/mac/scheduler_common.h @@ -23,7 +23,7 @@ #define SRSLTE_SCHEDULER_COMMON_H #include "srslte/adt/bounded_bitset.h" -#include "srslte/adt/interval.h" +#include "srslte/common/tti_point.h" #include "srslte/interfaces/sched_interface.h" namespace srsenb { diff --git a/srsenb/src/stack/mac/scheduler_harq.cc b/srsenb/src/stack/mac/scheduler_harq.cc index 9157296c5..8af67655a 100644 --- a/srsenb/src/stack/mac/scheduler_harq.cc +++ b/srsenb/src/stack/mac/scheduler_harq.cc @@ -383,8 +383,8 @@ std::pair harq_entity::set_ul_crc(srslte::tti_point tti_rx, uint void harq_entity::reset_pending_data(srslte::tti_point tti_rx) { - tti_point tti_tx_ul = srslte::to_tx_ul(tti_rx); - tti_point tti_tx_dl = srslte::to_tx_dl(tti_rx); + tti_point tti_tx_ul = to_tx_ul(tti_rx); + tti_point tti_tx_dl = to_tx_dl(tti_rx); // Reset ACK state of UL Harq get_ul_harq(tti_tx_ul.to_uint())->reset_pending_data(); diff --git a/srsenb/src/stack/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc index ed34e8a5f..49c7d7abf 100644 --- a/srsenb/src/stack/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -28,6 +28,7 @@ #include "srslte/mac/pdu.h" #include "srslte/srslte.h" +using srslte::tti_interval; using srslte::tti_point; namespace srsenb { @@ -1366,7 +1367,7 @@ void cc_sched_ue::finish_tti(srslte::tti_point tti_rx) // Check if cell state needs to be updated if (ue_cc_idx > 0 and cc_state_ == cc_st::deactivating) { // wait for all ACKs to be received before completely deactivating SCell - if (last_tti > srslte::to_tx_dl_ack(cfg_tti)) { + if (last_tti > to_tx_dl_ack(cfg_tti)) { cc_state_ = cc_st::idle; reset(); } diff --git a/srsenb/test/mac/sched_common_test_suite.cc b/srsenb/test/mac/sched_common_test_suite.cc index 523f13a04..1fe5c6a76 100644 --- a/srsenb/test/mac/sched_common_test_suite.cc +++ b/srsenb/test/mac/sched_common_test_suite.cc @@ -49,7 +49,7 @@ int test_pusch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co /* TEST: Check if there is space for PRACH */ bool is_prach_tti_tx_ul = - srslte_prach_tti_opportunity_config_fdd(cell_params.cfg.prach_config, sf_out.tti_tx_ul().to_uint(), -1); + srslte_prach_tti_opportunity_config_fdd(cell_params.cfg.prach_config, to_tx_ul(sf_out.tti_rx).to_uint(), -1); if (is_prach_tti_tx_ul) { try_ul_fill({cell_params.cfg.prach_freq_offset, cell_params.cfg.prach_freq_offset + 6}, "PRACH"); } @@ -131,7 +131,8 @@ int test_pdsch_collisions(const sf_output_res_t& sf_out, uint32_t enb_cc_idx, co // forbid Data in DL if its ACKs conflict with PRACH for PRB==6 if (cell_params.nof_prb() == 6) { - if (srslte_prach_tti_opportunity_config_fdd(cell_params.cfg.prach_config, sf_out.tti_rx_ack_dl().to_uint(), -1)) { + if (srslte_prach_tti_opportunity_config_fdd( + cell_params.cfg.prach_config, to_tx_dl_ack(sf_out.tti_rx).to_uint(), -1)) { dl_allocs.fill(0, dl_allocs.size()); } } @@ -171,8 +172,8 @@ int test_sib_scheduling(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) { const auto& cell_params = sf_out.cc_params[enb_cc_idx]; const auto& dl_result = sf_out.dl_cc_result[enb_cc_idx]; - uint32_t sfn = sf_out.tti_tx_dl().to_uint() / 10; - uint32_t sf_idx = sf_out.tti_tx_dl().to_uint() % 10; + uint32_t sfn = to_tx_dl(sf_out.tti_rx).to_uint() / 10; + uint32_t sf_idx = to_tx_dl(sf_out.tti_rx).to_uint() % 10; bool sib1_expected = ((sfn % 2) == 0) and sf_idx == 5; using bc_elem = const sched_interface::dl_sched_bc_t; @@ -202,7 +203,7 @@ int test_sib_scheduling(const sf_output_res_t& sf_out, uint32_t enb_cc_idx) } srslte::tti_point win_start{sfn_start * 10 + sf}; srslte::tti_interval window{win_start, win_start + cell_params.cfg.si_window_ms}; - CONDERROR(not window.contains(sf_out.tti_tx_dl()), "Scheduled SIB is outside of its SIB window\n"); + CONDERROR(not window.contains(to_tx_dl(sf_out.tti_rx)), "Scheduled SIB is outside of its SIB window\n"); } return SRSLTE_SUCCESS; } diff --git a/srsenb/test/mac/sched_common_test_suite.h b/srsenb/test/mac/sched_common_test_suite.h index 4b9d71092..b0ba75520 100644 --- a/srsenb/test/mac/sched_common_test_suite.h +++ b/srsenb/test/mac/sched_common_test_suite.h @@ -34,9 +34,6 @@ struct sf_output_res_t { srslte::tti_point tti_rx; srslte::span ul_cc_result; srslte::span dl_cc_result; - srslte::tti_point tti_tx_ul() const { return srslte::to_tx_ul(tti_rx); } - srslte::tti_point tti_rx_ack_dl() const { return tti_tx_ul(); } - srslte::tti_point tti_tx_dl() const { return srslte::to_tx_dl(tti_rx); } }; /** diff --git a/srsenb/test/mac/scheduler_test_common.cc b/srsenb/test/mac/scheduler_test_common.cc index 70640ffc9..70e508a33 100644 --- a/srsenb/test/mac/scheduler_test_common.cc +++ b/srsenb/test/mac/scheduler_test_common.cc @@ -199,8 +199,8 @@ int ue_ctxt_test::test_ra(cc_result result) /* TEST: RAR allocation */ uint32_t rar_win_size = cell_params[result.enb_cc_idx].prach_rar_window; std::array rar_window = {prach_tti + 3, prach_tti + 3 + rar_win_size}; - srslte::tti_point tti_tx_dl = srslte::to_tx_dl(current_tti_rx); - srslte::tti_point tti_tx_ul = srslte::to_tx_ul(current_tti_rx); + srslte::tti_point tti_tx_dl = to_tx_dl(current_tti_rx); + srslte::tti_point tti_tx_ul = to_tx_ul(current_tti_rx); bool is_in_rar_window = tti_tx_dl >= rar_window[0] and tti_tx_dl <= rar_window[1]; if (not is_in_rar_window) { @@ -357,7 +357,7 @@ int ue_ctxt_test::test_harqs(cc_result result) h.active = true; h.nof_retxs = 0; h.ndi = data.dci.tb[0].ndi; - h.tti_tx = srslte::to_tx_dl(current_tti_rx); + h.tti_tx = to_tx_dl(current_tti_rx); } else { // it is retx CONDERROR(sched_utils::get_rvidx(h.nof_retxs + 1) != (uint32_t)data.dci.tb[0].rv, "Invalid rv index for retx\n"); @@ -370,7 +370,7 @@ int ue_ctxt_test::test_harqs(cc_result result) sim_cfg.ue_cfg.maxharq_tx); h.nof_retxs++; - h.tti_tx = srslte::to_tx_dl(current_tti_rx); + h.tti_tx = to_tx_dl(current_tti_rx); } h.nof_txs++; } @@ -383,7 +383,7 @@ int ue_ctxt_test::test_harqs(cc_result result) } CONDERROR(pusch.dci.ue_cc_idx != cc->ue_cc_idx, "invalid ue_cc_idx=%d in sched result\n", pusch.dci.ue_cc_idx); - auto& h = cc->ul_harqs[srslte::to_tx_ul(current_tti_rx).to_uint() % cc->ul_harqs.size()]; + auto& h = cc->ul_harqs[to_tx_ul(current_tti_rx).to_uint() % cc->ul_harqs.size()]; uint32_t nof_retx = sched_utils::get_nof_retx(pusch.dci.tb.rv); // 0..3 if (h.nof_txs == 0 or h.ndi != pusch.dci.tb.ndi) { @@ -409,7 +409,7 @@ int ue_ctxt_test::test_harqs(cc_result result) h.nof_retxs++; } - h.tti_tx = srslte::to_tx_ul(current_tti_rx); + h.tti_tx = to_tx_ul(current_tti_rx); h.riv = pusch.dci.type2_alloc.riv; h.nof_txs++; } @@ -430,7 +430,7 @@ int ue_ctxt_test::schedule_acks(cc_result result) continue; } pending_ack_t ack_data; - ack_data.tti_ack = srslte::to_tx_dl_ack(current_tti_rx); + ack_data.tti_ack = to_tx_dl_ack(current_tti_rx); ack_data.cc_idx = result.enb_cc_idx; ack_data.tb = 0; ack_data.pid = data.dci.pid; @@ -449,11 +449,11 @@ int ue_ctxt_test::schedule_acks(cc_result result) } pending_ack_t ack_data; - ack_data.tti_ack = srslte::to_tx_ul(current_tti_rx); + ack_data.tti_ack = to_tx_ul(current_tti_rx); ack_data.cc_idx = result.enb_cc_idx; ack_data.ue_cc_idx = pusch.dci.ue_cc_idx; ack_data.tb = 0; - ack_data.pid = srslte::to_tx_ul(current_tti_rx).to_uint() % cc->ul_harqs.size(); + ack_data.pid = to_tx_ul(current_tti_rx).to_uint() % cc->ul_harqs.size(); uint32_t nof_retx = sched_utils::get_nof_retx(pusch.dci.tb.rv); // 0..3 ack_data.ack = randf() < sim_cfg.prob_ul_ack_mask[nof_retx % sim_cfg.prob_ul_ack_mask.size()];