From eecfee365b3ab3f73121571f53504e804fce9a00 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 30 Jul 2021 15:08:53 +0100 Subject: [PATCH] sched,nr: fix softbuffer dimensioning for NR scheduler. Renamed sched_nr_rb_grid file --- srsenb/hdr/stack/mac/nr/harq_softbuffer.h | 14 ++++++++++++-- srsenb/hdr/stack/mac/nr/sched_nr_cell.h | 2 +- ...hed_nr_rb_grid.h => sched_nr_grant_allocator.h} | 6 +++--- srsenb/hdr/stack/mac/nr/sched_nr_time_rr.h | 8 ++++++++ srsenb/hdr/stack/mac/nr/sched_nr_worker.h | 4 ++-- srsenb/src/stack/mac/nr/CMakeLists.txt | 2 +- ...d_nr_rb_grid.cc => sched_nr_grant_allocator.cc} | 7 ++++++- srsenb/src/stack/mac/nr/sched_nr_time_rr.cc | 4 ++++ srsenb/src/stack/mac/nr/sched_nr_worker.cc | 10 ++++++---- srsenb/test/mac/nr/sched_nr_ue_ded_test_suite.cc | 2 +- 10 files changed, 44 insertions(+), 15 deletions(-) rename srsenb/hdr/stack/mac/nr/{sched_nr_rb_grid.h => sched_nr_grant_allocator.h} (96%) create mode 100644 srsenb/hdr/stack/mac/nr/sched_nr_time_rr.h rename srsenb/src/stack/mac/nr/{sched_nr_rb_grid.cc => sched_nr_grant_allocator.cc} (97%) create mode 100644 srsenb/src/stack/mac/nr/sched_nr_time_rr.cc diff --git a/srsenb/hdr/stack/mac/nr/harq_softbuffer.h b/srsenb/hdr/stack/mac/nr/harq_softbuffer.h index ec33718b6..5ca8ae96e 100644 --- a/srsenb/hdr/stack/mac/nr/harq_softbuffer.h +++ b/srsenb/hdr/stack/mac/nr/harq_softbuffer.h @@ -18,6 +18,8 @@ extern "C" { #include "srsran/phy/common/phy_common_nr.h" #include "srsran/phy/fec/softbuffer.h" +#include "srsran/phy/phch/sch_nr.h" +#include "srsran/phy/utils/vector.h" } namespace srsenb { @@ -26,7 +28,11 @@ class tx_harq_softbuffer { public: tx_harq_softbuffer() { bzero(&buffer, sizeof(buffer)); } - explicit tx_harq_softbuffer(uint32_t nof_prb_) { srsran_softbuffer_tx_init(&buffer, nof_prb_); } + explicit tx_harq_softbuffer(uint32_t nof_prb_) + { + // Note: for now we use same size regardless of nof_prb_ + srsran_softbuffer_tx_init_guru(&buffer, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB); + } tx_harq_softbuffer(const tx_harq_softbuffer&) = delete; tx_harq_softbuffer(tx_harq_softbuffer&& other) noexcept { @@ -64,7 +70,11 @@ class rx_harq_softbuffer { public: rx_harq_softbuffer() { bzero(&buffer, sizeof(buffer)); } - explicit rx_harq_softbuffer(uint32_t nof_prb_) { srsran_softbuffer_rx_init(&buffer, nof_prb_); } + explicit rx_harq_softbuffer(uint32_t nof_prb_) + { + // Note: for now we use same size regardless of nof_prb_ + srsran_softbuffer_rx_init_guru(&buffer, SRSRAN_SCH_NR_MAX_NOF_CB_LDPC, SRSRAN_LDPC_MAX_LEN_ENCODED_CB); + } rx_harq_softbuffer(const rx_harq_softbuffer&) = delete; rx_harq_softbuffer(rx_harq_softbuffer&& other) noexcept { diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_cell.h b/srsenb/hdr/stack/mac/nr/sched_nr_cell.h index 3efcf5649..794f5993d 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_cell.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_cell.h @@ -14,7 +14,7 @@ #define SRSRAN_SCHED_NR_CELL_H #include "sched_nr_cfg.h" -#include "sched_nr_rb_grid.h" +#include "sched_nr_grant_allocator.h" #include "srsran/adt/pool/cached_alloc.h" namespace srsenb { diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_rb_grid.h b/srsenb/hdr/stack/mac/nr/sched_nr_grant_allocator.h similarity index 96% rename from srsenb/hdr/stack/mac/nr/sched_nr_rb_grid.h rename to srsenb/hdr/stack/mac/nr/sched_nr_grant_allocator.h index 9c4c4998b..7129e8f57 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_rb_grid.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_grant_allocator.h @@ -10,8 +10,8 @@ * */ -#ifndef SRSRAN_SCHED_NR_RB_GRID_H -#define SRSRAN_SCHED_NR_RB_GRID_H +#ifndef SRSRAN_SCHED_NR_GRANT_ALLOCATOR_H +#define SRSRAN_SCHED_NR_GRANT_ALLOCATOR_H #include "../sched_common.h" #include "lib/include/srsran/adt/circular_array.h" @@ -108,4 +108,4 @@ private: } // namespace sched_nr_impl } // namespace srsenb -#endif // SRSRAN_SCHED_NR_RB_GRID_H +#endif // SRSRAN_SCHED_NR_GRANT_ALLOCATOR_H diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_time_rr.h b/srsenb/hdr/stack/mac/nr/sched_nr_time_rr.h new file mode 100644 index 000000000..ced0856f2 --- /dev/null +++ b/srsenb/hdr/stack/mac/nr/sched_nr_time_rr.h @@ -0,0 +1,8 @@ +// +// Created by xico on 30/07/21. +// + +#ifndef SRSRAN_SCHED_NR_TIME_RR_H +#define SRSRAN_SCHED_NR_TIME_RR_H + +#endif //SRSRAN_SCHED_NR_TIME_RR_H diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_worker.h b/srsenb/hdr/stack/mac/nr/sched_nr_worker.h index c9b14a35e..532812946 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_worker.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_worker.h @@ -15,7 +15,7 @@ #include "sched_nr_cell.h" #include "sched_nr_cfg.h" -#include "sched_nr_rb_grid.h" +#include "sched_nr_grant_allocator.h" #include "sched_nr_ue.h" #include "srsran/adt/circular_array.h" #include "srsran/adt/optional.h" @@ -71,7 +71,7 @@ private: srsran::deque pending_feedback, tmp_feedback_to_run; srsran::deque > pending_events, tmp_events_to_run; - srsran::static_circular_map slot_ues; + slot_ue_map_t slot_ues; }; class sched_worker_manager diff --git a/srsenb/src/stack/mac/nr/CMakeLists.txt b/srsenb/src/stack/mac/nr/CMakeLists.txt index 4602c4f73..5173e0384 100644 --- a/srsenb/src/stack/mac/nr/CMakeLists.txt +++ b/srsenb/src/stack/mac/nr/CMakeLists.txt @@ -11,7 +11,7 @@ set(SOURCES mac_nr.cc sched_nr.cc sched_nr_ue.cc sched_nr_worker.cc - sched_nr_rb_grid.cc + sched_nr_grant_allocator.cc sched_nr_harq.cc sched_nr_pdcch.cc sched_nr_cfg.cc diff --git a/srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc b/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc similarity index 97% rename from srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc rename to srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc index 1eb31ae58..2f3743516 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc @@ -10,7 +10,7 @@ * */ -#include "srsenb/hdr/stack/mac/nr/sched_nr_rb_grid.h" +#include "srsenb/hdr/stack/mac/nr/sched_nr_grant_allocator.h" #include "srsenb/hdr/stack/mac/nr/sched_nr_cell.h" #include "srsenb/hdr/stack/mac/nr/sched_nr_helpers.h" @@ -289,6 +289,11 @@ alloc_result bwp_slot_allocator::alloc_pusch(slot_ue& ue, const prb_grant& ul_pr bool success = ue.cfg->phy().get_pusch_cfg(slot_cfg, pdcch.dci, pusch.sch); srsran_assert(success, "Error converting DCI to PUSCH grant"); pusch.sch.grant.tb[0].softbuffer.rx = ue.h_ul->get_softbuffer().get(); + if (ue.h_ul->nof_retx() == 0) { + ue.h_ul->set_tbs(pusch.sch.grant.tb[0].tbs); // update HARQ with correct TBS + } else { + srsran_assert(pusch.sch.grant.tb[0].tbs == (int)ue.h_ul->tbs(), "The TBS did not remain constant in retx"); + } return alloc_result::success; } diff --git a/srsenb/src/stack/mac/nr/sched_nr_time_rr.cc b/srsenb/src/stack/mac/nr/sched_nr_time_rr.cc new file mode 100644 index 000000000..7f3826248 --- /dev/null +++ b/srsenb/src/stack/mac/nr/sched_nr_time_rr.cc @@ -0,0 +1,4 @@ +// +// Created by xico on 30/07/21. +// + diff --git a/srsenb/src/stack/mac/nr/sched_nr_worker.cc b/srsenb/src/stack/mac/nr/sched_nr_worker.cc index 0b783d2b6..e981d8612 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_worker.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_worker.cc @@ -155,14 +155,15 @@ void slot_cc_worker::log_result() const if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_c) { const slot_ue& ue = slot_ues[pdcch.dci.ctx.rnti]; fmt::format_to(fmtbuf, - "SCHED: DL {}, cc={}, rnti=0x{:x}, pid={}, nrtx={}, f={}, dai={}, tti_pdsch={}, tti_ack={}", + "SCHED: DL {}, cc={}, rnti=0x{:x}, pid={}, f={}, nrtx={}, dai={}, tbs={}, tti_pdsch={}, tti_ack={}", ue.h_dl->nof_retx() == 0 ? "tx" : "retx", cell.cfg.cc, ue.rnti, pdcch.dci.pid, - ue.h_dl->nof_retx(), srsran_dci_format_nr_string(pdcch.dci.ctx.format), + ue.h_dl->nof_retx(), pdcch.dci.dai, + ue.h_dl->tbs(), ue.pdsch_slot, ue.uci_slot); } else if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_ra) { @@ -178,13 +179,14 @@ void slot_cc_worker::log_result() const if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_c) { const slot_ue& ue = slot_ues[pdcch.dci.ctx.rnti]; fmt::format_to(fmtbuf, - "SCHED: UL {}, cc={}, rnti=0x{:x}, pid={}, nrtx={}, f={}, tti_pusch={}", + "SCHED: UL {}, cc={}, rnti=0x{:x}, pid={}, f={}, nrtx={}, tbs={}, tti_pusch={}", ue.h_dl->nof_retx() == 0 ? "tx" : "retx", cell.cfg.cc, ue.rnti, pdcch.dci.pid, - ue.h_dl->nof_retx(), srsran_dci_format_nr_string(pdcch.dci.ctx.format), + ue.h_dl->nof_retx(), + ue.h_ul->tbs(), ue.pusch_slot); } else if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_tc) { const slot_ue& ue = slot_ues[pdcch.dci.ctx.rnti]; diff --git a/srsenb/test/mac/nr/sched_nr_ue_ded_test_suite.cc b/srsenb/test/mac/nr/sched_nr_ue_ded_test_suite.cc index d5f115a56..ecf656dfa 100644 --- a/srsenb/test/mac/nr/sched_nr_ue_ded_test_suite.cc +++ b/srsenb/test/mac/nr/sched_nr_ue_ded_test_suite.cc @@ -11,7 +11,7 @@ */ #include "sched_nr_ue_ded_test_suite.h" -#include "srsenb/hdr/stack/mac/nr/sched_nr_rb_grid.h" +#include "srsenb/hdr/stack/mac/nr/sched_nr_grant_allocator.h" #include "srsran/common/test_common.h" namespace srsenb {