From 327687cbc2c4d3e970a9cb842fe701f7f3e1b7e9 Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 22 Oct 2021 13:59:34 +0100 Subject: [PATCH] nr,sched: auto clear HARQs that exceeded maxretx, after the feedback has been processed --- srsenb/hdr/stack/mac/nr/sched_nr_harq.h | 7 +++++-- srsenb/hdr/stack/mac/nr/sched_nr_ue.h | 6 +++++- srsenb/src/stack/mac/nr/sched_nr_harq.cc | 17 ++++++++++++----- srsenb/src/stack/mac/nr/sched_nr_ue.cc | 20 +++++++------------- srsenb/src/stack/mac/nr/sched_nr_worker.cc | 5 ++++- srsenb/test/mac/nr/sched_nr_rar_test.cc | 1 + 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_harq.h b/srsenb/hdr/stack/mac/nr/sched_nr_harq.h index 8af07e9b7..5ab33d932 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_harq.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_harq.h @@ -46,7 +46,7 @@ public: int ack_info(uint32_t tb_idx, bool ack); - void new_slot(slot_point slot_rx); + bool clear_if_maxretx(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 max_retx); bool new_retx(slot_point slot_tx, slot_point slot_ack, const prb_grant& grant); @@ -112,7 +112,7 @@ private: class harq_entity { public: - explicit harq_entity(uint32_t nprb, uint32_t nof_harq_procs = SCHED_NR_MAX_HARQ); + explicit harq_entity(uint16_t rnti, uint32_t nprb, uint32_t nof_harq_procs, srslog::basic_logger& logger); void new_slot(slot_point slot_rx_); int dl_ack_info(uint32_t pid, uint32_t tb_idx, bool ack) { return dl_harqs[pid].ack_info(tb_idx, ack); } @@ -154,6 +154,9 @@ private: return (it == ul_harqs.end()) ? nullptr : &(*it); } + uint16_t rnti; + srslog::basic_logger& logger; + slot_point slot_rx; std::vector dl_harqs; std::vector ul_harqs; diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_ue.h b/srsenb/hdr/stack/mac/nr/sched_nr_ue.h index 21076a204..2f056a985 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_ue.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_ue.h @@ -63,7 +63,11 @@ class ue_carrier { public: ue_carrier(uint16_t rnti, const ue_cfg_t& cfg, const cell_params_t& cell_params_); - void set_cfg(const ue_cfg_t& ue_cfg); + void set_cfg(const ue_cfg_t& ue_cfg); + + /// Called after CC Feedback has been processed + void new_slot(slot_point slot_tx); + slot_ue try_reserve(slot_point pdcch_slot, uint32_t dl_harq_bytes, uint32_t ul_harq_bytes); const uint16_t rnti; diff --git a/srsenb/src/stack/mac/nr/sched_nr_harq.cc b/srsenb/src/stack/mac/nr/sched_nr_harq.cc index 6019190fa..396f73031 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_harq.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_harq.cc @@ -28,11 +28,13 @@ int harq_proc::ack_info(uint32_t tb_idx, bool ack) return ack ? tb[tb_idx].tbs : 0; } -void harq_proc::new_slot(slot_point slot_rx) +bool harq_proc::clear_if_maxretx(slot_point slot_rx) { - if (has_pending_retx(slot_rx) and nof_retx() + 1 >= max_nof_retx()) { + if (has_pending_retx(slot_rx) and nof_retx() + 1 > max_nof_retx()) { tb[0].active = false; + return true; } + return false; } void harq_proc::reset() @@ -127,7 +129,8 @@ bool dl_harq_proc::new_tx(slot_point slot_tx, return false; } -harq_entity::harq_entity(uint32_t nprb, uint32_t nof_harq_procs) +harq_entity::harq_entity(uint16_t rnti_, uint32_t nprb, uint32_t nof_harq_procs, srslog::basic_logger& logger_) : + rnti(rnti_), logger(logger_) { // Create HARQs dl_harqs.reserve(nof_harq_procs); @@ -142,10 +145,14 @@ void harq_entity::new_slot(slot_point slot_rx_) { slot_rx = slot_rx_; for (harq_proc& dl_h : dl_harqs) { - dl_h.new_slot(slot_rx); + if (dl_h.clear_if_maxretx(slot_rx)) { + logger.info("SCHED: discarding rnti=0x%x, DL TB pid=%d. Cause: Maximum number of retx exceeded (%d)"); + } } for (harq_proc& ul_h : ul_harqs) { - ul_h.new_slot(slot_rx); + if (ul_h.clear_if_maxretx(slot_rx)) { + logger.info("SCHED: discarding rnti=0x%x, UL TB pid=%d. Cause: Maximum number of retx exceeded (%d)"); + } } } diff --git a/srsenb/src/stack/mac/nr/sched_nr_ue.cc b/srsenb/src/stack/mac/nr/sched_nr_ue.cc index f48a47ad2..0079c9eaf 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_ue.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_ue.cc @@ -26,7 +26,7 @@ ue_carrier::ue_carrier(uint16_t rnti_, const ue_cfg_t& uecfg_, const cell_params cc(cell_params_.cc), bwp_cfg(rnti_, cell_params_.bwps[0], uecfg_), cell_params(cell_params_), - harq_ent(cell_params_.nof_prb()) + harq_ent(rnti_, cell_params_.nof_prb(), SCHED_NR_MAX_HARQ, cell_params_.bwps[0].logger) {} void ue_carrier::set_cfg(const ue_cfg_t& ue_cfg) @@ -34,6 +34,11 @@ void ue_carrier::set_cfg(const ue_cfg_t& ue_cfg) bwp_cfg = bwp_ue_cfg(rnti, cell_params.bwps[0], ue_cfg); } +void ue_carrier::new_slot(slot_point slot_tx) +{ + harq_ent.new_slot(slot_tx - TX_ENB_DELAY); +} + slot_ue ue_carrier::try_reserve(slot_point pdcch_slot, uint32_t dl_pending_bytes, uint32_t ul_pending_bytes) { slot_point slot_rx = pdcch_slot - TX_ENB_DELAY; @@ -103,14 +108,6 @@ void ue::new_slot(slot_point pdcch_slot) { last_pdcch_slot = pdcch_slot; - for (auto& ue_cc_cfg : ue_cfg.carriers) { - auto& cc = carriers[ue_cc_cfg.cc]; - if (cc != nullptr) { - // Update CC HARQ state - cc->harq_ent.new_slot(pdcch_slot - TX_ENB_DELAY); - } - } - // Compute pending DL/UL bytes for {rnti, pdcch_slot} if (sched_cfg.sched_cfg.auto_refill_buffer) { dl_pending_bytes = 1000000; @@ -142,10 +139,7 @@ void ue::new_slot(slot_point pdcch_slot) slot_ue ue::try_reserve(slot_point pdcch_slot, uint32_t cc) { - if (carriers[cc] == nullptr) { - return slot_ue(); - } - + srsran_assert(carriers[cc] != nullptr, "try_reserve() called for inexistent rnti=0x%x,cc=%d", rnti, cc); return carriers[cc]->try_reserve(pdcch_slot, dl_pending_bytes, ul_pending_bytes); } diff --git a/srsenb/src/stack/mac/nr/sched_nr_worker.cc b/srsenb/src/stack/mac/nr/sched_nr_worker.cc index 871e31117..ecc0b6215 100644 --- a/srsenb/src/stack/mac/nr/sched_nr_worker.cc +++ b/srsenb/src/stack/mac/nr/sched_nr_worker.cc @@ -80,6 +80,9 @@ void slot_cc_worker::run(slot_point pdcch_slot, ue_map_t& ue_db) continue; } + // Update UE CC state + u.carriers[cfg.cc]->new_slot(pdcch_slot); + // info for a given UE on a slot to be process slot_ues.insert(rnti, u.try_reserve(pdcch_slot, cfg.cc)); if (slot_ues[rnti].empty()) { @@ -374,7 +377,7 @@ void sched_worker_manager::get_metrics_nolocking(mac_metrics_t& metrics) { for (mac_ue_metrics_t& ue_metric : metrics.ues) { if (ue_db.contains(ue_metric.rnti) and ue_db[ue_metric.rnti]->carriers[0] != nullptr) { - auto& ue_cc = *ue_db[ue_metric.rnti]->carriers[0]; + auto& ue_cc = *ue_db[ue_metric.rnti]->carriers[0]; std::lock_guard lock(ue_cc.metrics_mutex); ue_metric.tx_brate = ue_cc.metrics.tx_brate; ue_metric.tx_errors = ue_cc.metrics.tx_errors; diff --git a/srsenb/test/mac/nr/sched_nr_rar_test.cc b/srsenb/test/mac/nr/sched_nr_rar_test.cc index b9acd4a6c..27622c318 100644 --- a/srsenb/test/mac/nr/sched_nr_rar_test.cc +++ b/srsenb/test/mac/nr/sched_nr_rar_test.cc @@ -57,6 +57,7 @@ void test_single_prach() auto run_slot = [&alloc, &rasched, &pdcch_slot, &slot_ues, &u]() -> const bwp_slot_grid* { mac_logger.set_context(pdcch_slot.to_uint()); u.new_slot(pdcch_slot); + u.carriers[0]->new_slot(pdcch_slot); slot_ues.clear(); slot_ue sfu = u.try_reserve(pdcch_slot, 0); if (not sfu.empty()) {