From d5acf73c46df03dbfe8149bc7370d06e9a8748a9 Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 18 Oct 2021 13:26:14 +0100 Subject: [PATCH] nr,gnb,sched: fix logging of tbs. check if sched args are supported at sched startup. change the tti logging to be equal to tti_rx --- srsenb/hdr/stack/mac/nr/sched_nr_harq.h | 19 ++++---------- srsenb/src/stack/mac/nr/mac_nr.cc | 2 +- srsenb/src/stack/mac/nr/sched_nr_cfg.cc | 6 ++++- .../stack/mac/nr/sched_nr_grant_allocator.cc | 25 ++++++++----------- srsenb/src/stack/mac/nr/sched_nr_harq.cc | 18 +++++++------ srsenb/src/stack/mac/nr/sched_nr_helpers.cc | 4 +-- 6 files changed, 35 insertions(+), 39 deletions(-) diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_harq.h b/srsenb/hdr/stack/mac/nr/sched_nr_harq.h index dcf2c587e..8af07e9b7 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_harq.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_harq.h @@ -48,17 +48,13 @@ public: void new_slot(slot_point slot_rx); void reset(); - bool new_tx(slot_point slot_tx, - slot_point slot_ack, - const prb_grant& grant, - uint32_t mcs, - uint32_t tbs, - uint32_t max_retx); + bool new_tx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant, uint32_t mcs, uint32_t max_retx); 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); // NOTE: Has to be used before first tx is dispatched - bool set_tbs(uint32_t tbs, int mcs = -1); + bool set_tbs(uint32_t tbs); + bool set_mcs(uint32_t mcs); const uint32_t pid; @@ -87,12 +83,7 @@ public: tx_harq_softbuffer& get_softbuffer() { return *softbuffer; } srsran::unique_byte_buffer_t* get_tx_pdu() { return &pdu; } - bool new_tx(slot_point slot_tx, - slot_point slot_ack, - const prb_grant& grant, - uint32_t mcs, - uint32_t tbs, - uint32_t max_retx); + bool new_tx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant, uint32_t mcs, uint32_t max_retx); private: srsran::unique_pool_ptr softbuffer; @@ -110,7 +101,7 @@ public: bool set_tbs(uint32_t tbs) { - softbuffer->reset(tbs * 8u); + softbuffer->reset(tbs); return harq_proc::set_tbs(tbs); } diff --git a/srsenb/src/stack/mac/nr/mac_nr.cc b/srsenb/src/stack/mac/nr/mac_nr.cc index 23c59c594..bd418cf53 100644 --- a/srsenb/src/stack/mac/nr/mac_nr.cc +++ b/srsenb/src/stack/mac/nr/mac_nr.cc @@ -291,7 +291,7 @@ int mac_nr::slot_indication(const srsran_slot_cfg_t& slot_cfg) int mac_nr::get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched) { - logger.set_context(slot_cfg.idx); + logger.set_context(slot_cfg.idx - TX_ENB_DELAY); slot_point pdsch_slot = srsran::slot_point{NUMEROLOGY_IDX, slot_cfg.idx}; sched_nr_interface::dl_sched_res_t dl_res; diff --git a/srsenb/src/stack/mac/nr/sched_nr_cfg.cc b/srsenb/src/stack/mac/nr/sched_nr_cfg.cc index 0a924b099..ecbb30e4c 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_cfg.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_cfg.cc @@ -101,7 +101,11 @@ cell_params_t::cell_params_t(uint32_t cc_, const cell_cfg_t& cell, const sched_a srsran_assert(not bwps.empty(), "No BWPs were configured"); } -sched_params::sched_params(const sched_args_t& sched_cfg_) : sched_cfg(sched_cfg_) {} +sched_params::sched_params(const sched_args_t& sched_cfg_) : sched_cfg(sched_cfg_) +{ + srsran_assert(sched_cfg.fixed_dl_mcs >= 0, "Dynamic DL MCS not supported"); + srsran_assert(sched_cfg.fixed_ul_mcs >= 0, "Dynamic DL MCS not supported"); +} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc b/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc index f2b544761..6982a5726 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_grant_allocator.cc @@ -172,7 +172,7 @@ alloc_result bwp_slot_allocator::alloc_rar_and_msg3(uint16_t prb_interval msg3_interv{last_msg3, last_msg3 + msg3_nof_prbs}; last_msg3 += msg3_nof_prbs; ue.h_ul = ue.harq_ent->find_empty_ul_harq(); - success = ue.h_ul->new_tx(msg3_slot, msg3_slot, msg3_interv, mcs, 100, max_harq_msg3_retx); + success = ue.h_ul->new_tx(msg3_slot, msg3_slot, msg3_interv, mcs, max_harq_msg3_retx); srsran_assert(success, "Failed to allocate Msg3"); fill_dci_msg3(ue, *bwp_grid.cfg, rar_grant.msg3_dci); @@ -240,22 +240,20 @@ alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_gr } // Allocate HARQ + int mcs = ue.cfg->fixed_pdsch_mcs(); if (ue.h_dl->empty()) { - int mcs = ue.cfg->fixed_pdsch_mcs(); - srsran_assert(mcs >= 0, "Dynamic MCS not yet supported"); - int tbs = 100; - bool ret = ue.h_dl->new_tx(ue.pdsch_slot, ue.uci_slot, dl_grant, mcs, tbs, 4); + bool ret = ue.h_dl->new_tx(ue.pdsch_slot, ue.uci_slot, dl_grant, mcs, 4); srsran_assert(ret, "Failed to allocate DL HARQ"); } else { bool ret = ue.h_dl->new_retx(ue.pdsch_slot, ue.uci_slot, dl_grant); + mcs = ue.h_dl->mcs(); srsran_assert(ret, "Failed to allocate DL HARQ retx"); } // Allocation Successful - int mcs = ue.h_dl->mcs(); const static float max_R = 0.93; - do { + while (true) { // Generate PDCCH pdcch_dl_t& pdcch = bwp_pdcch_slot.dl_pdcchs.back(); fill_dl_dci_ue_fields(ue, *bwp_grid.cfg, ss_id, pdcch.dci.ctx.location, pdcch.dci); @@ -288,15 +286,15 @@ alloc_result bwp_slot_allocator::alloc_pdsch(slot_ue& ue, const prb_grant& dl_gr } else { srsran_assert(pdsch.sch.grant.tb[0].tbs == (int)ue.h_dl->tbs(), "The TBS did not remain constant in retx"); } - if (bwp_pdsch_slot.pdschs.back().sch.grant.tb[0].R_prime < max_R or mcs == 0) { + if (ue.h_dl->nof_retx() > 0 or bwp_pdsch_slot.pdschs.back().sch.grant.tb[0].R_prime < max_R or mcs <= 0) { break; } - // Decrease MCS if rate is too high + // Decrease MCS if first tx and rate is too high mcs--; - ue.h_dl->set_tbs(100, mcs); + ue.h_dl->set_mcs(mcs); bwp_pdsch_slot.pdschs.pop_back(); bwp_uci_slot.pending_acks.pop_back(); - } while (true); + } if (mcs == 0) { logger.warning("Couldn't find mcs that leads to R<0.9"); } @@ -338,10 +336,9 @@ alloc_result bwp_slot_allocator::alloc_pusch(slot_ue& ue, const prb_grant& ul_pr } if (ue.h_ul->empty()) { - int mcs = ue.cfg->fixed_pusch_mcs(); - srsran_assert(mcs >= 0, "Dynamic MCS not yet supported"); + int mcs = ue.cfg->fixed_pusch_mcs(); int tbs = 100; - bool success = ue.h_ul->new_tx(ue.pusch_slot, ue.pusch_slot, ul_prbs, mcs, tbs, ue.cfg->ue_cfg()->maxharq_tx); + bool success = ue.h_ul->new_tx(ue.pusch_slot, ue.pusch_slot, ul_prbs, mcs, ue.cfg->ue_cfg()->maxharq_tx); srsran_assert(success, "Failed to allocate UL HARQ"); } else { bool success = ue.h_ul->new_retx(ue.pusch_slot, ue.pusch_slot, ul_prbs); diff --git a/srsenb/src/stack/mac/nr/sched_nr_harq.cc b/srsenb/src/stack/mac/nr/sched_nr_harq.cc index 003925a3a..6019190fa 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_harq.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_harq.cc @@ -48,7 +48,6 @@ bool harq_proc::new_tx(slot_point slot_tx_, slot_point slot_ack_, const prb_grant& grant, uint32_t mcs, - uint32_t tbs, uint32_t max_retx_) { if (not empty()) { @@ -61,20 +60,26 @@ bool harq_proc::new_tx(slot_point slot_tx_, prbs_ = grant; tb[0].ndi = !tb[0].ndi; tb[0].mcs = mcs; - tb[0].tbs = tbs; + tb[0].tbs = 0; tb[0].active = true; return true; } -bool harq_proc::set_tbs(uint32_t tbs, int mcs) +bool harq_proc::set_tbs(uint32_t tbs) { if (empty() or nof_retx() > 0) { return false; } tb[0].tbs = tbs; - if (mcs >= 0) { - tb[0].mcs = mcs; + return true; +} + +bool harq_proc::set_mcs(uint32_t mcs) +{ + if (empty() or nof_retx() > 0) { + return false; } + tb[0].mcs = mcs; return true; } @@ -112,10 +117,9 @@ bool dl_harq_proc::new_tx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant, uint32_t mcs, - uint32_t tbs, uint32_t max_retx) { - if (harq_proc::new_tx(slot_tx, slot_ack, grant, mcs, tbs, max_retx)) { + if (harq_proc::new_tx(slot_tx, slot_ack, grant, mcs, max_retx)) { softbuffer->reset(); pdu->clear(); return true; diff --git a/srsenb/src/stack/mac/nr/sched_nr_helpers.cc b/srsenb/src/stack/mac/nr/sched_nr_helpers.cc index 015059778..e1ed7032b 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_helpers.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_helpers.cc @@ -156,7 +156,7 @@ void log_sched_bwp_result(srslog::basic_logger& logger, ue.h_dl->prbs(), ue.h_dl->nof_retx(), pdcch.dci.dai, - ue.h_dl->tbs(), + ue.h_dl->tbs() / 8u, ue.dl_pending_bytes, ue.pdsch_slot, ue.uci_slot); @@ -193,7 +193,7 @@ void log_sched_bwp_result(srslog::basic_logger& logger, pdcch.dci.ctx.coreset_id, srsran_dci_format_nr_string(pdcch.dci.ctx.format), ue.h_ul->nof_retx(), - ue.h_ul->tbs(), + ue.h_ul->tbs() / 8u, ue.ul_pending_bytes, ue.pusch_slot); } else if (pdcch.dci.ctx.rnti_type == srsran_rnti_type_tc) {