From 3ea47b645a144e7ad628e7b3be080ef993b5ed03 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 6 Nov 2020 17:01:04 +0000 Subject: [PATCH] changed the way the number of UL pending bytes is calculated in the scheduler --- srsenb/hdr/stack/mac/scheduler_ue.h | 9 ++-- srsenb/src/stack/mac/scheduler_grid.cc | 16 +++---- srsenb/src/stack/mac/scheduler_ue.cc | 58 ++++++++++++++++---------- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/srsenb/hdr/stack/mac/scheduler_ue.h b/srsenb/hdr/stack/mac/scheduler_ue.h index 2cbed4815..ab9d48dcb 100644 --- a/srsenb/hdr/stack/mac/scheduler_ue.h +++ b/srsenb/hdr/stack/mac/scheduler_ue.h @@ -203,10 +203,13 @@ public: rbg_interval get_required_dl_rbgs(uint32_t ue_cc_idx); srslte::interval get_requested_dl_bytes(uint32_t ue_cc_idx); uint32_t get_pending_dl_new_data(); - uint32_t get_pending_ul_new_data(uint32_t tti, int this_ue_cc_idx); - uint32_t get_pending_ul_old_data(uint32_t cc_idx); uint32_t get_pending_dl_new_data_total(); + uint32_t get_pending_ul_data_total(uint32_t tti, int this_ue_cc_idx); + uint32_t get_pending_ul_new_data(uint32_t tti, int this_ue_cc_idx); + uint32_t get_pending_ul_old_data(); + uint32_t get_pending_ul_old_data(uint32_t cc_idx); + dl_harq_proc* get_pending_dl_harq(uint32_t tti_tx_dl, uint32_t cc_idx); dl_harq_proc* get_empty_dl_harq(uint32_t tti_tx_dl, uint32_t cc_idx); ul_harq_proc* get_ul_harq(uint32_t tti, uint32_t ue_cc_idx); @@ -273,8 +276,6 @@ private: uint32_t cfi, const srslte_dci_dl_t& dci); - uint32_t get_pending_ul_old_data_unlocked(uint32_t cc_idx); - bool needs_cqi_unlocked(uint32_t tti, uint32_t cc_idx, bool will_send = false); int generate_format1(uint32_t pid, diff --git a/srsenb/src/stack/mac/scheduler_grid.cc b/srsenb/src/stack/mac/scheduler_grid.cc index dce1a9c77..3ba050bc5 100644 --- a/srsenb/src/stack/mac/scheduler_grid.cc +++ b/srsenb/src/stack/mac/scheduler_grid.cc @@ -1167,8 +1167,8 @@ void sf_sched::set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul uci_pusch_t uci_type = is_uci_included(this, *cc_results, user, cc_cfg->enb_cc_idx); /* Generate DCI Format1A */ - uint32_t pending_data_before = user->get_pending_ul_new_data(get_tti_tx_ul(), cell_index); - int tbs = user->generate_format0(pusch, + uint32_t total_data_before = user->get_pending_ul_data_total(get_tti_tx_ul(), cell_index); + int tbs = user->generate_format0(pusch, get_tti_tx_ul(), cell_index, ul_alloc.alloc, @@ -1177,7 +1177,8 @@ void sf_sched::set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul ul_alloc.msg3_mcs, uci_type); - ul_harq_proc* h = user->get_ul_harq(get_tti_tx_ul(), cell_index); + ul_harq_proc* h = user->get_ul_harq(get_tti_tx_ul(), cell_index); + uint32_t new_pending_bytes = user->get_pending_ul_new_data(get_tti_tx_ul(), cell_index); // Allow TBS=0 in case of UCI-only PUSCH if (tbs < 0 || (tbs == 0 && pusch->dci.tb.mcs_idx != 29)) { log_h->warning("SCHED: Error %s %s rnti=0x%x, pid=%d, dci=(%d,%d), prb=%s, bsr=%d\n", @@ -1188,11 +1189,12 @@ void sf_sched::set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul pusch->dci.location.L, pusch->dci.location.ncce, ul_alloc.alloc.to_string().c_str(), - user->get_pending_ul_new_data(get_tti_tx_ul(), cell_index)); + new_pending_bytes); continue; } // Print Resulting UL Allocation + uint32_t old_pending_bytes = user->get_pending_ul_old_data(); log_h->info("SCHED: %s %s rnti=0x%x, cc=%d, pid=%d, dci=(%d,%d), prb=%s, n_rtx=%d, tbs=%d, bsr=%d (%d-%d)\n", ul_alloc.is_msg3() ? "Msg3" : "UL", ul_alloc.is_retx() ? "retx" : "tx", @@ -1204,9 +1206,9 @@ void sf_sched::set_ul_sched_result(const pdcch_grid_t::alloc_result_t& dci_resul ul_alloc.alloc.to_string().c_str(), h->nof_retx(0), tbs, - user->get_pending_ul_new_data(get_tti_tx_ul(), cell_index), - pending_data_before, - user->get_pending_ul_old_data(cell_index)); + new_pending_bytes, + total_data_before, + old_pending_bytes); ul_result->nof_dci_elems++; } diff --git a/srsenb/src/stack/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc index dbd169957..ed34e8a5f 100644 --- a/srsenb/src/stack/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -1018,12 +1018,28 @@ uint32_t sched_ue::get_pending_dl_new_data() return pending_data; } -uint32_t sched_ue::get_pending_ul_old_data(uint32_t cc_idx) +/// Returns nof bytes allocated to active UL HARQs in the carrier cc_idx. +/// NOTE: The returned value accounts for the MAC header and payload (RLC headers and actual data) +uint32_t sched_ue::get_pending_ul_old_data(uint32_t ue_cc_idx) { - return get_pending_ul_old_data_unlocked(cc_idx); + uint32_t pending_data = 0; + for (auto& h : carriers[ue_cc_idx].harq_ent.ul_harq_procs()) { + pending_data += h.get_pending_data(); + } + return pending_data; } -uint32_t sched_ue::get_pending_ul_new_data(uint32_t tti, int this_ue_cc_idx) +/// Returns the total of all TB bytes allocated to UL HARQs +uint32_t sched_ue::get_pending_ul_old_data() +{ + uint32_t pending_ul_data = 0; + for (uint32_t cc_idx = 0; cc_idx < carriers.size(); ++cc_idx) { + pending_ul_data += get_pending_ul_old_data(cc_idx); + } + return pending_ul_data; +} + +uint32_t sched_ue::get_pending_ul_data_total(uint32_t tti, int this_ue_cc_idx) { static constexpr uint32_t lbsr_size = 4, sbsr_size = 2; @@ -1033,9 +1049,11 @@ uint32_t sched_ue::get_pending_ul_new_data(uint32_t tti, int this_ue_cc_idx) for (int i = 0; i < sched_interface::MAX_LC_GROUP; i++) { if (lch_handler.is_bearer_ul(i)) { int bsr = lch_handler.get_bsr(i); - pending_data += bsr; + if (bsr > 0) { + pending_data += sched_utils::get_mac_sdu_and_subheader_size(bsr + RLC_MAX_HEADER_SIZE_NO_LI); + pending_data++; + } active_lcgs++; - pending_lcgs += (bsr > 0) ? 1 : 0; } } if (pending_data > 0) { @@ -1065,28 +1083,22 @@ uint32_t sched_ue::get_pending_ul_new_data(uint32_t tti, int this_ue_cc_idx) } } - // Subtract all the UL data already allocated in the UL harqs - uint32_t pending_ul_data = 0; - for (uint32_t cc_idx = 0; cc_idx < carriers.size(); ++cc_idx) { - pending_ul_data += get_pending_ul_old_data_unlocked(cc_idx); - } - pending_data = (pending_data > pending_ul_data) ? pending_data - pending_ul_data : 0; - - if (pending_data > 0) { - Debug("SCHED: pending_data=%d, pending_ul_data=%d, bsr=%s\n", - pending_data, - pending_ul_data, - lch_handler.get_bsr_text().c_str()); - } return pending_data; } -// Private lock-free implementation -uint32_t sched_ue::get_pending_ul_old_data_unlocked(uint32_t cc_idx) +uint32_t sched_ue::get_pending_ul_new_data(uint32_t tti, int this_ue_cc_idx) { - uint32_t pending_data = 0; - for (auto& h : carriers[cc_idx].harq_ent.ul_harq_procs()) { - pending_data += h.get_pending_data(); + uint32_t pending_data = get_pending_ul_data_total(tti, this_ue_cc_idx); + + // Subtract all the UL data already allocated in the UL harqs + uint32_t pending_ul_data = get_pending_ul_old_data(); + pending_data = (pending_data > pending_ul_data) ? pending_data - pending_ul_data : 0; + + if (pending_data > 0) { + Debug("SCHED: pending_data=%d, in_harq_data=%d, bsr=%s\n", + pending_data, + pending_ul_data, + lch_handler.get_bsr_text().c_str()); } return pending_data; }