From 8e174c96eddb044db0a098b0c3dfe8f2706a695c Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 26 Jul 2021 15:51:50 +0100 Subject: [PATCH] sched,nr: provide allocated byte_buffer in DL sched output + changes in RA procedure + added sched nr in default nr_phy_tests --- srsenb/hdr/stack/mac/nr/sched_nr_harq.h | 11 +++++---- srsenb/hdr/stack/mac/nr/sched_nr_interface.h | 12 ++++++---- srsenb/src/stack/mac/nr/sched_nr_cell.cc | 24 ++++++++++++-------- srsenb/src/stack/mac/nr/sched_nr_harq.cc | 5 ++++ srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc | 1 + test/phy/CMakeLists.txt | 15 ++++++++++++ 6 files changed, 48 insertions(+), 20 deletions(-) diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_harq.h b/srsenb/hdr/stack/mac/nr/sched_nr_harq.h index a077f849f..22c21f1f8 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_harq.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_harq.h @@ -56,11 +56,12 @@ public: bool new_retx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant); bool new_retx(slot_point slot_tx, slot_point slot_ack); + const uint32_t pid; + +protected: // NOTE: Has to be used before first tx is dispatched bool set_tbs(uint32_t tbs); - const uint32_t pid; - private: struct tb_t { bool active = false; @@ -81,11 +82,10 @@ private: class dl_harq_proc : public harq_proc { public: - dl_harq_proc(uint32_t id_, uint32_t nprb) : - harq_proc(id_), softbuffer(harq_softbuffer_pool::get_instance().get_tx(nprb)) - {} + dl_harq_proc(uint32_t id_, uint32_t nprb); tx_harq_softbuffer& get_softbuffer() { return *softbuffer; } + uint8_t* get_tx_pdu() { return pdu->msg; } bool set_tbs(uint32_t tbs) { @@ -95,6 +95,7 @@ public: private: srsran::unique_pool_ptr softbuffer; + srsran::unique_byte_buffer_t pdu; }; class ul_harq_proc : public harq_proc diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_interface.h b/srsenb/hdr/stack/mac/nr/sched_nr_interface.h index 91b4e0d02..b7237f2a0 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_interface.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_interface.h @@ -81,11 +81,13 @@ public: ////// RACH ////// struct dl_sched_rar_info_t { - uint32_t preamble_idx; - uint32_t ta_cmd; - uint16_t temp_crnti; - uint32_t msg3_size; - uint32_t prach_slot; + uint32_t preamble_idx; + uint32_t ofdm_symbol_idx; + uint32_t freq_idx; + uint32_t ta_cmd; + uint16_t temp_crnti; + uint32_t msg3_size; + slot_point prach_slot; }; ///// Sched Result ///// diff --git a/srsenb/src/stack/mac/nr/sched_nr_cell.cc b/srsenb/src/stack/mac/nr/sched_nr_cell.cc index 9c30de42c..a1782b261 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_cell.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_cell.cc @@ -57,7 +57,8 @@ void ra_sched::run_slot(bwp_slot_allocator& slot_grid, slot_ue_map_t& slot_ues) static const uint32_t PRACH_RAR_OFFSET = 3; slot_point pdcch_slot = slot_grid.get_pdcch_tti(); slot_point msg3_slot = pdcch_slot + bwp_cfg->pusch_ra_list[0].msg3_delay; - if (not slot_grid.res_grid()[msg3_slot].is_ul) { + if (not slot_grid.res_grid()[pdcch_slot].is_dl or not slot_grid.res_grid()[msg3_slot].is_ul) { + // RAR only allowed if respective Msg3 slot is available for UL return; } @@ -113,24 +114,27 @@ void ra_sched::run_slot(bwp_slot_allocator& slot_grid, slot_ue_map_t& slot_ues) } } +/// See TS 38.321, 5.1.3 - RAP transmission int ra_sched::dl_rach_info(const dl_sched_rar_info_t& rar_info) { - logger.info("SCHED: New PRACH tti=%d, preamble=%d, temp_crnti=0x%x, ta_cmd=%d, msg3_size=%d", - rar_info.prach_slot, + logger.info("SCHED: New PRACH slot=%d, preamble=%d, temp_crnti=0x%x, ta_cmd=%d, msg3_size=%d", + rar_info.prach_slot.to_uint(), rar_info.preamble_idx, rar_info.temp_crnti, rar_info.ta_cmd, rar_info.msg3_size); - // RA-RNTI = 1 + t_id + f_id - // t_id = index of first subframe specified by PRACH (0<=t_id<10) - // f_id = index of the PRACH within subframe, in ascending order of freq domain (0<=f_id<6) (for FDD, f_id=0) - uint16_t ra_rnti = 1 + (uint16_t)(rar_info.prach_slot % 10u); + // RA-RNTI = 1 + s_id + 14 × t_id + 14 × 80 × f_id + 14 × 80 × 8 × ul_carrier_id + // s_id = index of the first OFDM symbol (0 <= s_id < 14) + // t_id = index of first slot of the PRACH (0 <= t_id < 80) + // f_id = index of the PRACH in the freq domain (0 <= f_id < 8) (for FDD, f_id=0) + // ul_carrier_id = 0 for NUL and 1 for SUL carrier + uint16_t ra_rnti = 1 + rar_info.ofdm_symbol_idx + 14 * rar_info.prach_slot.slot_idx() + 14 * 80 * rar_info.freq_idx; // find pending rar with same RA-RNTI for (pending_rar_t& r : pending_rars) { - if (r.prach_slot.to_uint() == rar_info.prach_slot and ra_rnti == r.ra_rnti) { - if (r.msg3_grant.size() >= sched_interface::MAX_RAR_LIST) { + if (r.prach_slot == rar_info.prach_slot and ra_rnti == r.ra_rnti) { + if (r.msg3_grant.full()) { logger.warning("PRACH ignored, as the the maximum number of RAR grants per tti has been reached"); return SRSRAN_ERROR; } @@ -142,7 +146,7 @@ int ra_sched::dl_rach_info(const dl_sched_rar_info_t& rar_info) // create new RAR pending_rar_t p; p.ra_rnti = ra_rnti; - p.prach_slot = slot_point{0, rar_info.prach_slot}; + p.prach_slot = rar_info.prach_slot; p.msg3_grant.push_back(rar_info); pending_rars.push_back(p); diff --git a/srsenb/src/stack/mac/nr/sched_nr_harq.cc b/srsenb/src/stack/mac/nr/sched_nr_harq.cc index 513b5da31..b3b77d304 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_harq.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_harq.cc @@ -11,6 +11,7 @@ */ #include "srsenb/hdr/stack/mac/nr/sched_nr_harq.h" +#include "srsran/common/buffer_pool.h" namespace srsenb { namespace sched_nr_impl { @@ -100,6 +101,10 @@ bool harq_proc::new_retx(slot_point slot_tx_, slot_point slot_ack_) return true; } +dl_harq_proc::dl_harq_proc(uint32_t id_, uint32_t nprb) : + harq_proc(id_), softbuffer(harq_softbuffer_pool::get_instance().get_tx(nprb)), pdu(srsran::make_byte_buffer()) +{} + harq_entity::harq_entity(uint32_t nprb, uint32_t nof_harq_procs) { // Create HARQs diff --git a/srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc b/srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc index e10cd61f0..ec9b6f7e5 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_rb_grid.cc @@ -234,6 +234,7 @@ alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_gr bool ret = ue.cfg->phy().get_pdsch_cfg(slot_cfg, pdcch.dci, pdsch.sch); srsran_assert(ret, "Error converting DCI to grant"); pdsch.sch.grant.tb[0].softbuffer.tx = ue.h_dl->get_softbuffer().get(); + pdsch.data[0] = ue.h_dl->get_tx_pdu(); if (ue.h_dl->nof_retx() == 0) { ue.h_dl->set_tbs(pdsch.sch.grant.tb[0].tbs); // update HARQ with correct TBS } else { diff --git a/test/phy/CMakeLists.txt b/test/phy/CMakeLists.txt index a89a27329..60814ee3c 100644 --- a/test/phy/CMakeLists.txt +++ b/test/phy/CMakeLists.txt @@ -60,6 +60,21 @@ if (RF_FOUND AND ENABLE_SRSUE AND ENABLE_SRSENB) --ue.phy.nof_threads=${NR_PHY_TEST_UE_NOF_THREADS} ) + add_nr_test(nr_phy_test_10MHz_bidir_sched nr_phy_test + --duration=100 # 100 slots + --gnb.stack.pdsch.slots=0,1,2,3,4,5 # All possible DL slots + --gnb.stack.pdsch.start=0 # Start at RB 0 + --gnb.stack.pdsch.length=52 # Full 10 MHz BW + --gnb.stack.pdsch.mcs=28 # Maximum MCS + --gnb.stack.pusch.slots=6,7,8,9 # All possible UL slots + --gnb.stack.pusch.start=0 # Start at RB 0 + --gnb.stack.pusch.length=52 # Full 10 MHz BW + --gnb.stack.pusch.mcs=28 # Maximum MCS + --gnb.stack.use_dummy_sched=false # Use real NR scheduler + --gnb.phy.nof_threads=${NR_PHY_TEST_GNB_NOF_THREADS} + --ue.phy.nof_threads=${NR_PHY_TEST_UE_NOF_THREADS} + ) + add_nr_test(nr_phy_test_10MHz_prach nr_phy_test --duration=1000 # 100 slots --gnb.stack.pdsch.slots=none # No PDSCH