From bb96625129d4f7a34bee6b64a744674b86eeb564 Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 20 Nov 2020 16:45:41 +0000 Subject: [PATCH] renaming lch_manager -> lch_ue_manager --- srsenb/hdr/stack/mac/sched_lch.h | 30 ++++++++------- srsenb/hdr/stack/mac/sched_ue.h | 4 +- srsenb/src/stack/mac/sched_lch.cc | 60 +++++++++++++++-------------- srsenb/src/stack/mac/sched_ue.cc | 8 ++-- srsenb/test/mac/sched_lc_ch_test.cc | 10 ++--- 5 files changed, 58 insertions(+), 54 deletions(-) diff --git a/srsenb/hdr/stack/mac/sched_lch.h b/srsenb/hdr/stack/mac/sched_lch.h index 62ea66a5b..47d42a1af 100644 --- a/srsenb/hdr/stack/mac/sched_lch.h +++ b/srsenb/hdr/stack/mac/sched_lch.h @@ -28,7 +28,7 @@ namespace srsenb { -class lch_manager +class lch_ue_manager { constexpr static uint32_t pbr_infinity = -1; constexpr static uint32_t MAX_LC = sched_interface::MAX_LC; @@ -49,16 +49,16 @@ public: bool is_bearer_dl(uint32_t lcid) const; bool has_pending_dl_txs() const; - int get_dl_tx_total() const; - int get_dl_tx_total(uint32_t lcid) const { return get_dl_tx(lcid) + get_dl_retx(lcid); } - int get_dl_tx_total_with_overhead(uint32_t lcid) const; - int get_dl_tx(uint32_t lcid) const; - int get_dl_tx_with_overhead(uint32_t lcid) const; - int get_dl_retx(uint32_t lcid) const; - int get_dl_retx_with_overhead(uint32_t lcid) const; - int get_bsr(uint32_t lcid) const; - int get_bsr_with_overhead(uint32_t lcid) const; - int get_max_prio_lcid() const; + int get_dl_tx_total() const; + int get_dl_tx_total(uint32_t lcid) const { return get_dl_tx(lcid) + get_dl_retx(lcid); } + int get_dl_tx_total_with_overhead(uint32_t lcid) const; + int get_dl_tx(uint32_t lcid) const; + int get_dl_tx_with_overhead(uint32_t lcid) const; + int get_dl_retx(uint32_t lcid) const; + int get_dl_retx_with_overhead(uint32_t lcid) const; + int get_bsr(uint32_t lcid) const; + int get_bsr_with_overhead(uint32_t lcid) const; + int get_max_prio_lcid() const; std::string get_bsr_text() const; @@ -91,8 +91,10 @@ private: * @param tbidx index of TB * @return allocated bytes, which is always equal or lower than total_tbs */ -uint32_t -allocate_mac_sdus(sched_interface::dl_sched_data_t* data, lch_manager& lch_handler, uint32_t total_tbs, uint32_t tbidx); +uint32_t allocate_mac_sdus(sched_interface::dl_sched_data_t* data, + lch_ue_manager& lch_handler, + uint32_t total_tbs, + uint32_t tbidx); /** * Allocate space for pending MAC CEs @@ -101,7 +103,7 @@ allocate_mac_sdus(sched_interface::dl_sched_data_t* data, lch_manager& lch_handl * @return number of bytes allocated */ uint32_t allocate_mac_ces(sched_interface::dl_sched_data_t* data, - lch_manager& lch_handler, + lch_ue_manager& lch_handler, uint32_t total_tbs, uint32_t ue_cc_idx); diff --git a/srsenb/hdr/stack/mac/sched_ue.h b/srsenb/hdr/stack/mac/sched_ue.h index 315ae7fed..f75290c1b 100644 --- a/srsenb/hdr/stack/mac/sched_ue.h +++ b/srsenb/hdr/stack/mac/sched_ue.h @@ -253,8 +253,8 @@ private: const sched_cell_params_t* main_cc_params = nullptr; /* Buffer states */ - bool sr = false; - lch_manager lch_handler; + bool sr = false; + lch_ue_manager lch_handler; int power_headroom = 0; uint32_t cqi_request_tti = 0; diff --git a/srsenb/src/stack/mac/sched_lch.cc b/srsenb/src/stack/mac/sched_lch.cc index 7a15bf2c9..6751fef6e 100644 --- a/srsenb/src/stack/mac/sched_lch.cc +++ b/srsenb/src/stack/mac/sched_lch.cc @@ -79,14 +79,14 @@ const char* to_string(sched_interface::ue_bearer_cfg_t::direction_t dir) } } -void lch_manager::set_cfg(const sched_interface::ue_cfg_t& cfg) +void lch_ue_manager::set_cfg(const sched_interface::ue_cfg_t& cfg) { for (uint32_t lcid = 0; lcid < sched_interface::MAX_LC; lcid++) { config_lcid(lcid, cfg.ue_bearers[lcid]); } } -void lch_manager::new_tti() +void lch_ue_manager::new_tti() { prio_idx++; for (uint32_t lcid = 0; lcid < sched_interface::MAX_LC; ++lcid) { @@ -98,7 +98,7 @@ void lch_manager::new_tti() } } -void lch_manager::config_lcid(uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& bearer_cfg) +void lch_ue_manager::config_lcid(uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& bearer_cfg) { if (lc_id >= sched_interface::MAX_LC) { Warning("Adding bearer with invalid logical channel id=%d\n", lc_id); @@ -128,7 +128,7 @@ void lch_manager::config_lcid(uint32_t lc_id, const sched_interface::ue_bearer_c } } -void lch_manager::ul_bsr(uint8_t lcg_id, uint32_t bsr) +void lch_ue_manager::ul_bsr(uint8_t lcg_id, uint32_t bsr) { if (lcg_id >= sched_interface::MAX_LC_GROUP) { Warning("The provided logical channel group id=%d is not valid\n", lcg_id); @@ -138,7 +138,7 @@ void lch_manager::ul_bsr(uint8_t lcg_id, uint32_t bsr) Debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s\n", bsr, lcg_id, get_bsr_text().c_str()); } -void lch_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes) +void lch_ue_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes) { if (lcid >= sched_interface::MAX_LC) { Warning("The provided lcid=%d is not valid\n", lcid); @@ -148,7 +148,7 @@ void lch_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes) Debug("SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s\n", bytes, lch[lcid].cfg.group, get_bsr_text().c_str()); } -void lch_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue) +void lch_ue_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue) { if (lcid >= sched_interface::MAX_LC) { Warning("The provided lcid=%d is not valid\n", lcid); @@ -159,7 +159,7 @@ void lch_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx Debug("SCHED: DL lcid=%d buffer_state=%d,%d\n", lcid, tx_queue, retx_queue); } -int lch_manager::get_max_prio_lcid() const +int lch_ue_manager::get_max_prio_lcid() const { int min_prio_val = std::numeric_limits::max(), prio_lcid = -1; @@ -208,7 +208,7 @@ int lch_manager::get_max_prio_lcid() const } /// Allocates first available RLC PDU -int lch_manager::alloc_rlc_pdu(sched_interface::dl_sched_pdu_t* rlc_pdu, int rem_bytes) +int lch_ue_manager::alloc_rlc_pdu(sched_interface::dl_sched_pdu_t* rlc_pdu, int rem_bytes) { int alloc_bytes = 0; int lcid = get_max_prio_lcid(); @@ -237,7 +237,7 @@ int lch_manager::alloc_rlc_pdu(sched_interface::dl_sched_pdu_t* rlc_pdu, int rem return alloc_bytes; } -int lch_manager::alloc_retx_bytes(uint8_t lcid, int rem_bytes) +int lch_ue_manager::alloc_retx_bytes(uint8_t lcid, int rem_bytes) { const int rlc_overhead = (lcid == 0) ? 0 : RLC_MAX_HEADER_SIZE_NO_LI; if (rem_bytes <= rlc_overhead) { @@ -249,7 +249,7 @@ int lch_manager::alloc_retx_bytes(uint8_t lcid, int rem_bytes) return alloc + (alloc > 0 ? rlc_overhead : 0); } -int lch_manager::alloc_tx_bytes(uint8_t lcid, int rem_bytes) +int lch_ue_manager::alloc_tx_bytes(uint8_t lcid, int rem_bytes) { const int rlc_overhead = (lcid == 0) ? 0 : RLC_MAX_HEADER_SIZE_NO_LI; if (rem_bytes <= rlc_overhead) { @@ -265,35 +265,35 @@ int lch_manager::alloc_tx_bytes(uint8_t lcid, int rem_bytes) return alloc + (alloc > 0 ? rlc_overhead : 0); } -bool lch_manager::is_bearer_active(uint32_t lcid) const +bool lch_ue_manager::is_bearer_active(uint32_t lcid) const { return lch[lcid].cfg.direction != sched_interface::ue_bearer_cfg_t::IDLE; } -bool lch_manager::is_bearer_ul(uint32_t lcid) const +bool lch_ue_manager::is_bearer_ul(uint32_t lcid) const { return is_bearer_active(lcid) and lch[lcid].cfg.direction != sched_interface::ue_bearer_cfg_t::DL; } -bool lch_manager::is_bearer_dl(uint32_t lcid) const +bool lch_ue_manager::is_bearer_dl(uint32_t lcid) const { return is_bearer_active(lcid) and lch[lcid].cfg.direction != sched_interface::ue_bearer_cfg_t::UL; } -bool lch_manager::has_pending_dl_txs() const +bool lch_ue_manager::has_pending_dl_txs() const { - if(not pending_ces.empty()) { + if (not pending_ces.empty()) { return true; } - for(uint32_t lcid = 0; lcid < lch.size(); ++lcid) { - if(get_dl_tx_total(lcid) > 0) { + for (uint32_t lcid = 0; lcid < lch.size(); ++lcid) { + if (get_dl_tx_total(lcid) > 0) { return true; } } return false; } -int lch_manager::get_dl_tx_total() const +int lch_ue_manager::get_dl_tx_total() const { int sum = 0; for (size_t lcid = 0; lcid < lch.size(); ++lcid) { @@ -302,48 +302,50 @@ int lch_manager::get_dl_tx_total() const return sum; } -int lch_manager::get_dl_tx_total_with_overhead(uint32_t lcid) const +int lch_ue_manager::get_dl_tx_total_with_overhead(uint32_t lcid) const { return get_dl_retx_with_overhead(lcid) + get_dl_tx_with_overhead(lcid); } -int lch_manager::get_dl_tx(uint32_t lcid) const +int lch_ue_manager::get_dl_tx(uint32_t lcid) const { return is_bearer_dl(lcid) ? lch[lcid].buf_tx : 0; } -int lch_manager::get_dl_tx_with_overhead(uint32_t lcid) const +int lch_ue_manager::get_dl_tx_with_overhead(uint32_t lcid) const { return get_mac_sdu_size_with_overhead(lcid, get_dl_tx(lcid)); } -int lch_manager::get_dl_retx(uint32_t lcid) const +int lch_ue_manager::get_dl_retx(uint32_t lcid) const { return is_bearer_dl(lcid) ? lch[lcid].buf_retx : 0; } -int lch_manager::get_dl_retx_with_overhead(uint32_t lcid) const +int lch_ue_manager::get_dl_retx_with_overhead(uint32_t lcid) const { return get_mac_sdu_size_with_overhead(lcid, get_dl_retx(lcid)); } -int lch_manager::get_bsr(uint32_t lcid) const +int lch_ue_manager::get_bsr(uint32_t lcid) const { return is_bearer_ul(lcid) ? lcg_bsr[lch[lcid].cfg.group] : 0; } -int lch_manager::get_bsr_with_overhead(uint32_t lcid) const +int lch_ue_manager::get_bsr_with_overhead(uint32_t lcid) const { int bsr = get_bsr(lcid); return bsr + (bsr == 0 ? 0 : ((lcid == 0) ? 0 : RLC_MAX_HEADER_SIZE_NO_LI)); } -std::string lch_manager::get_bsr_text() const +std::string lch_ue_manager::get_bsr_text() const { std::stringstream ss; ss << "{" << lcg_bsr[0] << ", " << lcg_bsr[1] << ", " << lcg_bsr[2] << ", " << lcg_bsr[3] << "}"; return ss.str(); } -uint32_t -allocate_mac_sdus(sched_interface::dl_sched_data_t* data, lch_manager& lch_handler, uint32_t total_tbs, uint32_t tbidx) +uint32_t allocate_mac_sdus(sched_interface::dl_sched_data_t* data, + lch_ue_manager& lch_handler, + uint32_t total_tbs, + uint32_t tbidx) { uint32_t rem_tbs = total_tbs; @@ -363,7 +365,7 @@ allocate_mac_sdus(sched_interface::dl_sched_data_t* data, lch_manager& lch_handl } uint32_t allocate_mac_ces(sched_interface::dl_sched_data_t* data, - lch_manager& lch_handler, + lch_ue_manager& lch_handler, uint32_t total_tbs, uint32_t ue_cc_idx) { diff --git a/srsenb/src/stack/mac/sched_ue.cc b/srsenb/src/stack/mac/sched_ue.cc index 3f7dcb2ba..8c8c77f19 100644 --- a/srsenb/src/stack/mac/sched_ue.cc +++ b/srsenb/src/stack/mac/sched_ue.cc @@ -264,9 +264,9 @@ void sched_ue::dl_buffer_state(uint8_t lc_id, uint32_t tx_queue, uint32_t retx_q void sched_ue::mac_buffer_state(uint32_t ce_code, uint32_t nof_cmds) { - auto cmd = (lch_manager::ce_cmd)ce_code; + auto cmd = (lch_ue_manager::ce_cmd)ce_code; for (uint32_t i = 0; i < nof_cmds; ++i) { - if (cmd == lch_manager::ce_cmd::CON_RES_ID) { + if (cmd == lch_ue_manager::ce_cmd::CON_RES_ID) { lch_handler.pending_ces.push_front(cmd); } else { lch_handler.pending_ces.push_back(cmd); @@ -946,7 +946,7 @@ srslte::interval sched_ue::get_requested_dl_bytes(uint32_t ue_cc_idx) // Wait for SRB0 data to be available for Msg4 before scheduling the ConRes CE return {}; } - for (const lch_manager::ce_cmd& ce : lch_handler.pending_ces) { + for (const lch_ue_manager::ce_cmd& ce : lch_handler.pending_ces) { sum_ce_data += srslte::ce_total_size(ce); } } @@ -958,7 +958,7 @@ srslte::interval sched_ue::get_requested_dl_bytes(uint32_t ue_cc_idx) /* Set Minimum boundary */ min_data = srb0_data; - if (not lch_handler.pending_ces.empty() and lch_handler.pending_ces.front() == lch_manager::ce_cmd::CON_RES_ID) { + if (not lch_handler.pending_ces.empty() and lch_handler.pending_ces.front() == lch_ue_manager::ce_cmd::CON_RES_ID) { min_data += srslte::ce_total_size(lch_handler.pending_ces.front()); } if (min_data == 0) { diff --git a/srsenb/test/mac/sched_lc_ch_test.cc b/srsenb/test/mac/sched_lc_ch_test.cc index d4ae8b124..ce5d44f08 100644 --- a/srsenb/test/mac/sched_lc_ch_test.cc +++ b/srsenb/test/mac/sched_lc_ch_test.cc @@ -28,7 +28,7 @@ using namespace srsenb; const uint32_t seed = std::chrono::system_clock::now().time_since_epoch().count(); /// Tests if a PDU was allocated with lcid and pdu_size bytes -int test_pdu_alloc_successful(srsenb::lch_manager& lch_handler, +int test_pdu_alloc_successful(srsenb::lch_ue_manager& lch_handler, sched_interface::dl_sched_pdu_t& pdu, int lcid, uint32_t pdu_size) @@ -40,7 +40,7 @@ int test_pdu_alloc_successful(srsenb::lch_manager& lch_handler, return SRSLTE_SUCCESS; } -int test_retx_until_empty(srsenb::lch_manager& lch_handler, int lcid, uint32_t pdu_size) +int test_retx_until_empty(srsenb::lch_ue_manager& lch_handler, int lcid, uint32_t pdu_size) { uint32_t nof_pdus = lch_handler.get_dl_retx(lcid) / pdu_size; sched_interface::dl_sched_pdu_t pdu; @@ -52,7 +52,7 @@ int test_retx_until_empty(srsenb::lch_manager& lch_handler, int lcid, uint32_t p return nof_pdus * pdu_size; } -int test_newtx_until_empty(srsenb::lch_manager& lch_handler, int lcid, uint32_t pdu_size) +int test_newtx_until_empty(srsenb::lch_ue_manager& lch_handler, int lcid, uint32_t pdu_size) { uint32_t nof_pdus = lch_handler.get_dl_tx(lcid) / pdu_size; sched_interface::dl_sched_pdu_t pdu; @@ -66,7 +66,7 @@ int test_newtx_until_empty(srsenb::lch_manager& lch_handler, int lcid, uint32_t int test_lc_ch_pbr_infinity() { - srsenb::lch_manager lch_handler; + srsenb::lch_ue_manager lch_handler; srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); ue_cfg = generate_setup_ue_cfg(ue_cfg); @@ -115,7 +115,7 @@ int test_lc_ch_pbr_infinity() int test_lc_ch_pbr_finite() { - srsenb::lch_manager lch_handler; + srsenb::lch_ue_manager lch_handler; sched_interface::dl_sched_pdu_t pdu; srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg();