From 020bec025e1053f837eef80c5b2cb5ef840ce1c0 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Wed, 1 Sep 2021 11:02:36 +0200 Subject: [PATCH] sched: created class common to LTE and NR for ue buffer status management --- lib/include/srsran/asn1/rrc_nr_utils.h | 2 +- lib/include/srsran/asn1/rrc_utils.h | 2 +- lib/include/srsran/common/common_nr.h | 2 +- .../srsran/interfaces/enb_mac_interfaces.h | 10 +- .../srsran/interfaces/enb_rrc_interfaces.h | 2 +- .../srsran/interfaces/gnb_interfaces.h | 2 +- srsenb/hdr/enb.h | 2 +- srsenb/hdr/stack/mac/common/sched_config.h | 24 ++- .../hdr/stack/mac/common/ue_buffer_manager.h | 95 +++++++++++ srsenb/hdr/stack/mac/mac.h | 4 +- srsenb/hdr/stack/mac/nr/sched_nr_ue.h | 6 +- .../stack/mac/nr/sched_nr_ue_buffer_manager.h | 66 -------- srsenb/hdr/stack/mac/nr/ue_nr.h | 2 +- srsenb/hdr/stack/mac/sched.h | 4 +- srsenb/hdr/stack/mac/sched_grid.h | 2 +- srsenb/hdr/stack/mac/sched_helpers.h | 4 +- .../hdr/stack/mac}/sched_interface.h | 13 +- srsenb/hdr/stack/mac/sched_lte_common.h | 2 +- srsenb/hdr/stack/mac/sched_ue.h | 5 +- .../hdr/stack/mac/sched_ue_ctrl/sched_harq.h | 2 +- .../hdr/stack/mac/sched_ue_ctrl/sched_lch.h | 56 +++---- srsenb/hdr/stack/mac/ue.h | 2 +- srsenb/hdr/stack/rrc/mac_controller.h | 4 +- srsenb/hdr/stack/rrc/rrc_ue.h | 2 +- srsenb/src/stack/mac/CMakeLists.txt | 3 + srsenb/src/stack/mac/common/CMakeLists.txt | 10 ++ .../src/stack/mac/common/ue_buffer_manager.cc | 116 +++++++++++++ srsenb/src/stack/mac/mac.cc | 4 +- srsenb/src/stack/mac/nr/CMakeLists.txt | 4 +- .../mac/nr/sched_nr_ue_buffer_manager.cc | 70 -------- srsenb/src/stack/mac/sched.cc | 2 +- srsenb/src/stack/mac/sched_helpers.cc | 16 -- srsenb/src/stack/mac/sched_ue.cc | 6 +- .../src/stack/mac/sched_ue_ctrl/sched_lch.cc | 157 +++--------------- .../stack/mac/sched_ue_ctrl/sched_ue_cell.cc | 2 +- srsenb/src/stack/rrc/mac_controller.cc | 32 ++-- srsenb/src/stack/rrc/rrc.cc | 2 +- srsenb/src/stack/rrc/rrc_mobility.cc | 2 +- srsenb/src/stack/rrc/rrc_ue.cc | 10 +- srsenb/test/common/dummy_classes.h | 2 +- srsenb/test/mac/sched_common_test_suite.h | 2 +- srsenb/test/mac/sched_lc_ch_test.cc | 12 +- srsenb/test/mac/sched_sim_ue.cc | 4 +- srsenb/test/mac/sched_sim_ue.h | 6 +- srsenb/test/mac/sched_test_rand.cc | 2 +- srsenb/test/mac/sched_test_utils.h | 38 ++--- srsenb/test/rrc/rrc_mobility_test.cc | 21 +-- 47 files changed, 397 insertions(+), 441 deletions(-) create mode 100644 srsenb/hdr/stack/mac/common/ue_buffer_manager.h delete mode 100644 srsenb/hdr/stack/mac/nr/sched_nr_ue_buffer_manager.h rename {lib/include/srsran/interfaces => srsenb/hdr/stack/mac}/sched_interface.h (96%) create mode 100644 srsenb/src/stack/mac/common/CMakeLists.txt create mode 100644 srsenb/src/stack/mac/common/ue_buffer_manager.cc delete mode 100644 srsenb/src/stack/mac/nr/sched_nr_ue_buffer_manager.cc diff --git a/lib/include/srsran/asn1/rrc_nr_utils.h b/lib/include/srsran/asn1/rrc_nr_utils.h index 9d88feb82..bb5ad0326 100644 --- a/lib/include/srsran/asn1/rrc_nr_utils.h +++ b/lib/include/srsran/asn1/rrc_nr_utils.h @@ -13,11 +13,11 @@ #ifndef SRSRAN_RRC_NR_UTILS_H #define SRSRAN_RRC_NR_UTILS_H +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/common/phy_cfg_nr.h" #include "srsran/interfaces/mac_interface_types.h" #include "srsran/interfaces/pdcp_interface_types.h" #include "srsran/interfaces/rlc_interface_types.h" -#include "srsran/interfaces/sched_interface.h" /************************ * Forward declarations diff --git a/lib/include/srsran/asn1/rrc_utils.h b/lib/include/srsran/asn1/rrc_utils.h index 18d4a4b4a..58f3d58a5 100644 --- a/lib/include/srsran/asn1/rrc_utils.h +++ b/lib/include/srsran/asn1/rrc_utils.h @@ -13,11 +13,11 @@ #ifndef SRSRAN_RRC_UTILS_H #define SRSRAN_RRC_UTILS_H +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/interfaces/mac_interface_types.h" #include "srsran/interfaces/pdcp_interface_types.h" #include "srsran/interfaces/rlc_interface_types.h" #include "srsran/interfaces/rrc_interface_types.h" -#include "srsran/interfaces/sched_interface.h" /************************ * Forward declarations diff --git a/lib/include/srsran/common/common_nr.h b/lib/include/srsran/common/common_nr.h index 0257938e3..17e9e2521 100644 --- a/lib/include/srsran/common/common_nr.h +++ b/lib/include/srsran/common/common_nr.h @@ -55,7 +55,7 @@ enum class nr_drb { invalid }; const uint32_t MAX_NR_DRB_ID = 29; -const uint32_t MAX_NR_NOF_BEARERS = MAX_NR_DRB_ID + MAX_NR_SRB_ID; +const uint32_t MAX_NR_NOF_BEARERS = MAX_NR_DRB_ID + MAX_NR_SRB_ID; // 32 constexpr bool is_nr_lcid(uint32_t lcid) { diff --git a/lib/include/srsran/interfaces/enb_mac_interfaces.h b/lib/include/srsran/interfaces/enb_mac_interfaces.h index 9e2ea5673..ba13e75dc 100644 --- a/lib/include/srsran/interfaces/enb_mac_interfaces.h +++ b/lib/include/srsran/interfaces/enb_mac_interfaces.h @@ -10,8 +10,8 @@ * */ +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/interfaces/rrc_interface_types.h" -#include "srsran/interfaces/sched_interface.h" #ifndef SRSRAN_ENB_MAC_INTERFACES_H #define SRSRAN_ENB_MAC_INTERFACES_H @@ -239,14 +239,14 @@ public: virtual int ue_set_crnti(uint16_t temp_crnti, uint16_t crnti, const sched_interface::ue_cfg_t& cfg) = 0; /* Manages UE bearers and associated configuration */ - virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) = 0; - virtual int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) = 0; - virtual void phy_config_enabled(uint16_t rnti, bool enabled) = 0; + virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, mac_lc_ch_cfg_t* cfg) = 0; + virtual int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) = 0; + virtual void phy_config_enabled(uint16_t rnti, bool enabled) = 0; virtual void write_mcch(const srsran::sib2_mbms_t* sib2_, const srsran::sib13_t* sib13_, const srsran::mcch_msg_t* mcch_, const uint8_t* mcch_payload, - const uint8_t mcch_payload_length) = 0; + const uint8_t mcch_payload_length) = 0; /** * Allocate a C-RNTI for a new user, without adding it to the phy layer and scheduler yet diff --git a/lib/include/srsran/interfaces/enb_rrc_interfaces.h b/lib/include/srsran/interfaces/enb_rrc_interfaces.h index 4948b1a47..85f961080 100644 --- a/lib/include/srsran/interfaces/enb_rrc_interfaces.h +++ b/lib/include/srsran/interfaces/enb_rrc_interfaces.h @@ -10,9 +10,9 @@ * */ +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/asn1/s1ap_utils.h" #include "srsran/interfaces/enb_rrc_interface_types.h" -#include "srsran/interfaces/sched_interface.h" #ifndef SRSRAN_ENB_RRC_INTERFACES_H #define SRSRAN_ENB_RRC_INTERFACES_H diff --git a/lib/include/srsran/interfaces/gnb_interfaces.h b/lib/include/srsran/interfaces/gnb_interfaces.h index 5faf4945b..d7116276c 100644 --- a/lib/include/srsran/interfaces/gnb_interfaces.h +++ b/lib/include/srsran/interfaces/gnb_interfaces.h @@ -15,12 +15,12 @@ #include "srsran/srsran.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/common/interfaces_common.h" #include "srsran/common/security.h" #include "srsran/interfaces/pdcp_interface_types.h" #include "srsran/interfaces/rlc_interface_types.h" #include "srsran/interfaces/rrc_interface_types.h" -#include "srsran/interfaces/sched_interface.h" // EUTRA interfaces that are used unmodified #include "srsran/interfaces/enb_mac_interfaces.h" #include "srsran/interfaces/enb_rrc_interfaces.h" diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 1974b3901..a04a72c43 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -31,6 +31,7 @@ #include "srsenb/hdr/stack/enb_stack_base.h" #include "srsenb/hdr/stack/rrc/rrc_config.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/common/bcd_helpers.h" #include "srsran/common/buffer_pool.h" #include "srsran/common/interfaces_common.h" @@ -38,7 +39,6 @@ #include "srsran/common/security.h" #include "srsran/interfaces/enb_command_interface.h" #include "srsran/interfaces/enb_metrics_interface.h" -#include "srsran/interfaces/sched_interface.h" #include "srsran/interfaces/ue_interfaces.h" #include "srsran/srslog/srslog.h" #include "srsran/system/sys_metrics_processor.h" diff --git a/srsenb/hdr/stack/mac/common/sched_config.h b/srsenb/hdr/stack/mac/common/sched_config.h index 94bdf663c..3a16ee158 100644 --- a/srsenb/hdr/stack/mac/common/sched_config.h +++ b/srsenb/hdr/stack/mac/common/sched_config.h @@ -20,7 +20,7 @@ namespace srsenb { /** * Structure used in UE logical channel configuration */ -struct logical_channel_cfg_t { +struct mac_lc_ch_cfg_t { enum direction_t { IDLE = 0, UL, DL, BOTH } direction = IDLE; int priority = 1; // channel priority (1 is highest) uint32_t bsd = 1000; // msec @@ -30,8 +30,30 @@ struct logical_channel_cfg_t { bool is_active() const { return direction != IDLE; } bool is_dl() const { return direction == DL or direction == BOTH; } bool is_ul() const { return direction == UL or direction == BOTH; } + bool operator==(const mac_lc_ch_cfg_t& other) const + { + return direction == other.direction and priority == other.priority and bsd == other.bsd and pbr == other.pbr and + group == other.group; + } + bool operator!=(const mac_lc_ch_cfg_t& other) const { return not(*this == other); } }; +inline const char* to_string(mac_lc_ch_cfg_t::direction_t dir) +{ + switch (dir) { + case mac_lc_ch_cfg_t::direction_t::IDLE: + return "idle"; + case mac_lc_ch_cfg_t::direction_t::BOTH: + return "bi-dir"; + case mac_lc_ch_cfg_t::direction_t::DL: + return "DL"; + case mac_lc_ch_cfg_t::direction_t::UL: + return "UL"; + default: + return "unrecognized direction"; + } +} + } // namespace srsenb #endif // SRSRAN_SCHED_CONFIG_H diff --git a/srsenb/hdr/stack/mac/common/ue_buffer_manager.h b/srsenb/hdr/stack/mac/common/ue_buffer_manager.h new file mode 100644 index 000000000..ea722b8be --- /dev/null +++ b/srsenb/hdr/stack/mac/common/ue_buffer_manager.h @@ -0,0 +1,95 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_UE_BUFFER_MANAGER_H +#define SRSRAN_UE_BUFFER_MANAGER_H + +#include "sched_config.h" +#include "srsran/common/common_lte.h" +#include "srsran/common/common_nr.h" +#include "srsran/srslog/srslog.h" +#include "srsran/support/srsran_assert.h" + +namespace srsenb { + +/** + * Class to handle UE DL+UL RLC and MAC buffers state + */ +template +class ue_buffer_manager +{ +protected: + const static uint32_t MAX_LC_ID = isNR ? srsran::MAX_NR_NOF_BEARERS : srsran::MAX_LTE_LCID; + const static uint32_t MAX_LCG_ID = isNR ? 7 : 3; + const static uint32_t MAX_SRB_LC_ID = isNR ? srsran::MAX_NR_SRB_ID : srsran::MAX_LTE_SRB_ID; + const static uint32_t MAX_NOF_LCIDS = MAX_LC_ID + 1; + const static uint32_t MAX_NOF_LCGS = MAX_LCG_ID + 1; + constexpr static uint32_t pbr_infinity = -1; + +public: + explicit ue_buffer_manager(srslog::basic_logger& logger_) : logger(logger_) {} + + // Bearer configuration + void config_lcid(uint32_t lcid, const mac_lc_ch_cfg_t& bearer_cfg); + + // Buffer Status update + void ul_bsr(uint32_t lcg_id, uint32_t val); + void dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue); + + // Configuration getters + bool is_bearer_active(uint32_t lcid) const { return get_cfg(lcid).is_active(); } + bool is_bearer_ul(uint32_t lcid) const { return get_cfg(lcid).is_ul(); } + bool is_bearer_dl(uint32_t lcid) const { return get_cfg(lcid).is_dl(); } + const mac_lc_ch_cfg_t& get_cfg(uint32_t lcid) const + { + srsran_assert(is_lcid_valid(lcid), "Provided LCID=%d is above limit=%d", lcid, MAX_LC_ID); + return channels[lcid].cfg; + } + + /// DL newtx buffer status for given LCID (no RLC overhead included) + int get_dl_tx(uint32_t lcid) const { return is_bearer_dl(lcid) ? channels[lcid].buf_tx : 0; } + + /// DL retx buffer status for given LCID (no RLC overhead included) + int get_dl_retx(uint32_t lcid) const { return is_bearer_dl(lcid) ? channels[lcid].buf_retx : 0; } + + /// Sum of DL RLC newtx and retx buffer status for given LCID (no RLC overhead included) + int get_dl_tx_total(uint32_t lcid) const { return get_dl_tx(lcid) + get_dl_retx(lcid); } + + /// Sum of DL RLC newtx and retx buffer status for all LCIDS + int get_dl_tx_total() const; + + // UL BSR methods + bool is_lcg_active(uint32_t lcg) const; + int get_bsr(uint32_t lcg) const; + const std::array& get_bsr_state() const { return lcg_bsr; } + + static bool is_lcid_valid(uint32_t lcid) { return lcid <= MAX_LC_ID; } + static bool is_lcg_valid(uint32_t lcg) { return lcg <= MAX_LCG_ID; } + +protected: + srslog::basic_logger& logger; + + struct logical_channel { + mac_lc_ch_cfg_t cfg; + int buf_tx = 0; + int buf_retx = 0; + int Bj = 0; + int bucket_size = 0; + }; + std::array channels; + + std::array lcg_bsr{0}; +}; + +} // namespace srsenb + +#endif // SRSRAN_UE_BUFFER_MANAGER_H diff --git a/srsenb/hdr/stack/mac/mac.h b/srsenb/hdr/stack/mac/mac.h index 63e5527dd..cbb7e4af3 100644 --- a/srsenb/hdr/stack/mac/mac.h +++ b/srsenb/hdr/stack/mac/mac.h @@ -14,6 +14,7 @@ #define SRSENB_MAC_H #include "sched.h" +#include "sched_interface.h" #include "srsenb/hdr/common/rnti_pool.h" #include "srsenb/hdr/stack/mac/schedulers/sched_time_rr.h" #include "srsran/adt/circular_map.h" @@ -26,7 +27,6 @@ #include "srsran/interfaces/enb_mac_interfaces.h" #include "srsran/interfaces/enb_metrics_interface.h" #include "srsran/interfaces/enb_rrc_interface_types.h" -#include "srsran/interfaces/sched_interface.h" #include "srsran/srslog/srslog.h" #include "ta.h" #include "ue.h" @@ -86,7 +86,7 @@ public: void phy_config_enabled(uint16_t rnti, bool enabled) override; /* Manages UE bearers and associated configuration */ - int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) override; + int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, mac_lc_ch_cfg_t* cfg) override; int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) override; int rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint32_t retx_queue) override; diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_ue.h b/srsenb/hdr/stack/mac/nr/sched_nr_ue.h index 79f0d503e..24b563745 100644 --- a/srsenb/hdr/stack/mac/nr/sched_nr_ue.h +++ b/srsenb/hdr/stack/mac/nr/sched_nr_ue.h @@ -16,7 +16,7 @@ #include "sched_nr_cfg.h" #include "sched_nr_harq.h" #include "sched_nr_interface.h" -#include "sched_nr_ue_buffer_manager.h" +#include "srsenb/hdr/stack/mac/common/ue_buffer_manager.h" #include "srsran/adt/circular_map.h" #include "srsran/adt/move_callback.h" #include "srsran/adt/pool/cached_alloc.h" @@ -100,8 +100,8 @@ private: const uint16_t rnti; const sched_params& sched_cfg; - bool pending_sr = false; - ue_buffer_manager buffers; + bool pending_sr = false; + ue_buffer_manager buffers; ue_cfg_t ue_cfg; }; diff --git a/srsenb/hdr/stack/mac/nr/sched_nr_ue_buffer_manager.h b/srsenb/hdr/stack/mac/nr/sched_nr_ue_buffer_manager.h deleted file mode 100644 index ec88132c0..000000000 --- a/srsenb/hdr/stack/mac/nr/sched_nr_ue_buffer_manager.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2021 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#ifndef SRSRAN_SCHED_NR_UE_BUFFER_MANAGER_H -#define SRSRAN_SCHED_NR_UE_BUFFER_MANAGER_H - -#include "srsenb/hdr/stack/mac/common/sched_config.h" -#include "srsran/srslog/srslog.h" -#include "srsran/support/srsran_assert.h" - -namespace srsenb { -namespace sched_nr_impl { - -class ue_buffer_manager -{ - const static uint32_t MAX_LCG_ID = 7; - const static uint32_t MAX_LC_ID = 32; - const static uint32_t MAX_SRB_LC_ID = 3; - -public: - explicit ue_buffer_manager(srslog::basic_logger& logger_); - - // Configuration getters - bool is_channel_active(uint32_t lcid) const { return get_cfg(lcid).is_active(); } - bool is_bearer_ul(uint32_t lcid) const { return get_cfg(lcid).is_ul(); } - bool is_bearer_dl(uint32_t lcid) const { return get_cfg(lcid).is_dl(); } - const logical_channel_cfg_t& get_cfg(uint32_t lcid) const - { - srsran_assert(lcid < MAX_LC_ID, "Provided LCID=%d is above limit=%d", lcid, MAX_LC_ID); - return channels[lcid].cfg; - } - - // Buffer Status update - void ul_bsr(uint32_t lcg_id, uint32_t val); - void dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue); - - // UL BSR methods - bool is_lcg_active(uint32_t lcg) const; - int get_bsr(uint32_t lcg) const; - -private: - srslog::basic_logger& logger; - - struct logical_channel { - logical_channel_cfg_t cfg; - int buf_tx = 0; - int buf_retx = 0; - }; - std::array channels; - - std::array lcg_bsr{0}; -}; - -} // namespace sched_nr_impl -} // namespace srsenb - -#endif // SRSRAN_SCHED_NR_UE_BUFFER_MANAGER_H diff --git a/srsenb/hdr/stack/mac/nr/ue_nr.h b/srsenb/hdr/stack/mac/nr/ue_nr.h index 0e644cb9e..5d33623b1 100644 --- a/srsenb/hdr/stack/mac/nr/ue_nr.h +++ b/srsenb/hdr/stack/mac/nr/ue_nr.h @@ -14,10 +14,10 @@ #define SRSENB_UE_NR_H #include "srsenb/hdr/stack/mac/common/mac_metrics.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/common/block_queue.h" #include "srsran/common/interfaces_common.h" #include "srsran/interfaces/enb_rlc_interfaces.h" -#include "srsran/interfaces/sched_interface.h" #include "srsran/mac/mac_sch_pdu_nr.h" #include #include diff --git a/srsenb/hdr/stack/mac/sched.h b/srsenb/hdr/stack/mac/sched.h index 8aaf1195a..36fa3f8a6 100644 --- a/srsenb/hdr/stack/mac/sched.h +++ b/srsenb/hdr/stack/mac/sched.h @@ -14,9 +14,9 @@ #define SRSENB_SCHEDULER_H #include "sched_grid.h" +#include "sched_interface.h" #include "sched_ue.h" #include "srsenb/hdr/common/common_enb.h" -#include "srsran/interfaces/sched_interface.h" #include #include #include @@ -47,7 +47,7 @@ public: void phy_config_enabled(uint16_t rnti, bool enabled); - int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, const ue_bearer_cfg_t& cfg) final; + int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, const mac_lc_ch_cfg_t& cfg) final; int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) final; uint32_t get_ul_buffer(uint16_t rnti) final; diff --git a/srsenb/hdr/stack/mac/sched_grid.h b/srsenb/hdr/stack/mac/sched_grid.h index f7d7ce183..7341cdaba 100644 --- a/srsenb/hdr/stack/mac/sched_grid.h +++ b/srsenb/hdr/stack/mac/sched_grid.h @@ -13,8 +13,8 @@ #ifndef SRSRAN_SCHED_GRID_H #define SRSRAN_SCHED_GRID_H -#include "lib/include/srsran/interfaces/sched_interface.h" #include "sched_common.h" +#include "sched_interface.h" #include "sched_phy_ch/sched_result.h" #include "sched_phy_ch/sf_cch_allocator.h" #include "sched_ue.h" diff --git a/srsenb/hdr/stack/mac/sched_helpers.h b/srsenb/hdr/stack/mac/sched_helpers.h index 651dae6b8..bea8e667f 100644 --- a/srsenb/hdr/stack/mac/sched_helpers.h +++ b/srsenb/hdr/stack/mac/sched_helpers.h @@ -13,8 +13,8 @@ #ifndef SRSRAN_SCHED_HELPERS_H #define SRSRAN_SCHED_HELPERS_H +#include "sched_interface.h" #include "srsenb/hdr/stack/mac/sched_lte_common.h" -#include "srsran/interfaces/sched_interface.h" #include "srsran/srslog/srslog.h" namespace srsenb { @@ -96,8 +96,6 @@ void log_phich_cc_results(srslog::basic_logger& logger, uint32_t enb_cc_idx, const sched_interface::ul_sched_res_t& result); -const char* to_string(sched_interface::ue_bearer_cfg_t::direction_t dir); - } // namespace srsenb #endif // SRSRAN_SCHED_HELPERS_H diff --git a/lib/include/srsran/interfaces/sched_interface.h b/srsenb/hdr/stack/mac/sched_interface.h similarity index 96% rename from lib/include/srsran/interfaces/sched_interface.h rename to srsenb/hdr/stack/mac/sched_interface.h index aae980273..d6eafc012 100644 --- a/lib/include/srsran/interfaces/sched_interface.h +++ b/srsenb/hdr/stack/mac/sched_interface.h @@ -10,6 +10,7 @@ * */ +#include "common/sched_config.h" #include "srsran/adt/bounded_vector.h" #include "srsran/common/common.h" #include "srsran/srsran.h" @@ -116,14 +117,6 @@ public: std::vector scell_list; }; - struct ue_bearer_cfg_t { - int priority = 1; - uint32_t bsd = 1000; // msec - uint32_t pbr = -1; - int group = 0; - enum direction_t { IDLE = 0, UL, DL, BOTH } direction = IDLE; - }; - struct ant_info_ded_t { enum class tx_mode_t { tm1, tm2, tm3, tm4, tm5, tm6, tm7, tm8_v920, nulltype } tx_mode = tx_mode_t::tm1; enum class codebook_t { @@ -153,7 +146,7 @@ public: bool continuous_pusch = false; srsran_uci_offset_cfg_t uci_offset = {15, 12, 10}; srsran_pucch_cfg_t pucch_cfg = {}; - std::array ue_bearers = {}; + std::array ue_bearers = {}; std::vector supported_cc_list; ///< list of UE supported CCs. First index for PCell ant_info_ded_t dl_ant_info; bool use_tbs_index_alt = false; @@ -258,7 +251,7 @@ public: virtual bool ue_exists(uint16_t rnti) = 0; /* Manages UE bearers and associated configuration */ - virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, const ue_bearer_cfg_t& cfg) = 0; + virtual int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, const mac_lc_ch_cfg_t& cfg) = 0; virtual int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) = 0; virtual uint32_t get_ul_buffer(uint16_t rnti) = 0; diff --git a/srsenb/hdr/stack/mac/sched_lte_common.h b/srsenb/hdr/stack/mac/sched_lte_common.h index 39bd4bf9e..e76d8f676 100644 --- a/srsenb/hdr/stack/mac/sched_lte_common.h +++ b/srsenb/hdr/stack/mac/sched_lte_common.h @@ -13,9 +13,9 @@ #ifndef SRSRAN_SCHED_LTE_COMMON_H #define SRSRAN_SCHED_LTE_COMMON_H +#include "sched_interface.h" #include "srsran/adt/bounded_bitset.h" #include "srsran/common/tti_point.h" -#include "srsran/interfaces/sched_interface.h" namespace srsenb { diff --git a/srsenb/hdr/stack/mac/sched_ue.h b/srsenb/hdr/stack/mac/sched_ue.h index da03a9fc2..fc68c70c8 100644 --- a/srsenb/hdr/stack/mac/sched_ue.h +++ b/srsenb/hdr/stack/mac/sched_ue.h @@ -32,8 +32,7 @@ typedef enum { UCI_PUSCH_NONE = 0, UCI_PUSCH_CQI, UCI_PUSCH_ACK, UCI_PUSCH_ACK_C */ class sched_ue { - using ue_cfg_t = sched_interface::ue_cfg_t; - using bearer_cfg_t = sched_interface::ue_bearer_cfg_t; + using ue_cfg_t = sched_interface::ue_cfg_t; public: sched_ue(uint16_t rnti, const std::vector& cell_list_params_, const ue_cfg_t& cfg); @@ -48,7 +47,7 @@ public: void phy_config_enabled(tti_point tti_rx, bool enabled); void set_cfg(const ue_cfg_t& cfg); - void set_bearer_cfg(uint32_t lc_id, const bearer_cfg_t& cfg); + void set_bearer_cfg(uint32_t lc_id, const mac_lc_ch_cfg_t& cfg); void rem_bearer(uint32_t lc_id); void dl_buffer_state(uint8_t lc_id, uint32_t tx_queue, uint32_t retx_queue); diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h index 50577374f..6bdfa3290 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_harq.h @@ -13,9 +13,9 @@ #ifndef SRSENB_SCHEDULER_HARQ_H #define SRSENB_SCHEDULER_HARQ_H +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/adt/bounded_bitset.h" #include "srsran/common/tti_point.h" -#include "srsran/interfaces/sched_interface.h" #include "srsran/srslog/srslog.h" namespace srsenb { diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h index 90b79fd93..c4ce54b77 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_lch.h @@ -13,70 +13,58 @@ #ifndef SRSRAN_SCHED_LCH_H #define SRSRAN_SCHED_LCH_H +#include "srsenb/hdr/stack/mac/common/ue_buffer_manager.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/adt/pool/cached_alloc.h" -#include "srsran/interfaces/sched_interface.h" #include "srsran/mac/pdu.h" #include "srsran/srslog/srslog.h" namespace srsenb { -class lch_ue_manager +class lch_ue_manager : private ue_buffer_manager { - constexpr static uint32_t pbr_infinity = -1; - constexpr static uint32_t MAX_LC = sched_interface::MAX_LC; + using base_type = ue_buffer_manager; public: - lch_ue_manager() : logger(srslog::fetch_basic_logger("MAC")) {} + lch_ue_manager() : ue_buffer_manager(srslog::fetch_basic_logger("MAC")) {} void set_cfg(const sched_interface::ue_cfg_t& cfg_); void new_tti(); - void config_lcid(uint32_t lcg_id, const sched_interface::ue_bearer_cfg_t& bearer_cfg); - void ul_bsr(uint8_t lcg_id, uint32_t bsr); + // Inherited methods from ue_buffer_manager base class + using base_type::config_lcid; + using base_type::dl_buffer_state; + using base_type::get_bsr; + using base_type::get_bsr_state; + using base_type::get_dl_retx; + using base_type::get_dl_tx; + using base_type::get_dl_tx_total; + using base_type::is_bearer_active; + using base_type::is_bearer_dl; + using base_type::is_bearer_ul; + using base_type::is_lcg_active; + using base_type::ul_bsr; + void ul_buffer_add(uint8_t lcid, uint32_t bytes); - void dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue); int alloc_rlc_pdu(sched_interface::dl_sched_pdu_t* lcid, int rem_bytes); - bool is_bearer_active(uint32_t lcid) const; - bool is_bearer_ul(uint32_t lcid) const; - 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; - bool is_lcg_active(uint32_t lcg) const; - int get_bsr(uint32_t lcid) const; - int get_bsr_with_overhead(uint32_t lcid) const; - int get_max_prio_lcid() const; - - const std::array& get_bsr_state() const; + int get_bsr_with_overhead(uint32_t lcid) const; + int get_max_prio_lcid() const; // Control Element Command queue using ce_cmd = srsran::dl_sch_lcid; srsran::deque pending_ces; private: - struct ue_bearer_t { - sched_interface::ue_bearer_cfg_t cfg = {}; - int bucket_size = 0; - int buf_tx = 0; - int buf_retx = 0; - int Bj = 0; - }; - int alloc_retx_bytes(uint8_t lcid, int rem_bytes); int alloc_tx_bytes(uint8_t lcid, int rem_bytes); - size_t prio_idx = 0; - srslog::basic_logger& logger; - std::array lch = {}; - std::array lcg_bsr = {}; + size_t prio_idx = 0; }; /** diff --git a/srsenb/hdr/stack/mac/ue.h b/srsenb/hdr/stack/mac/ue.h index 4fb3a6d58..f9040ef5c 100644 --- a/srsenb/hdr/stack/mac/ue.h +++ b/srsenb/hdr/stack/mac/ue.h @@ -14,6 +14,7 @@ #define SRSENB_UE_H #include "common/mac_metrics.h" +#include "sched_interface.h" #include "srsran/adt/circular_array.h" #include "srsran/adt/circular_map.h" #include "srsran/adt/pool/pool_interface.h" @@ -21,7 +22,6 @@ #include "srsran/common/mac_pcap.h" #include "srsran/common/mac_pcap_net.h" #include "srsran/common/tti_point.h" -#include "srsran/interfaces/sched_interface.h" #include "srsran/mac/pdu.h" #include "srsran/mac/pdu_queue.h" #include "srsran/srslog/srslog.h" diff --git a/srsenb/hdr/stack/rrc/mac_controller.h b/srsenb/hdr/stack/rrc/mac_controller.h index ff9a62b60..2056881eb 100644 --- a/srsenb/hdr/stack/rrc/mac_controller.h +++ b/srsenb/hdr/stack/rrc/mac_controller.h @@ -15,8 +15,8 @@ #include "rrc_bearer_cfg.h" #include "rrc_cell_cfg.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/interfaces/rrc_interface_types.h" -#include "srsran/interfaces/sched_interface.h" #include namespace srsenb { @@ -55,7 +55,7 @@ public: const srsran::rrc_ue_capabilities_t& uecaps); void handle_ho_prep(const asn1::rrc::ho_prep_info_r8_ies_s& ho_prep); - void set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::direction_t dir); + void set_radio_bearer_state(mac_lc_ch_cfg_t::direction_t dir); const ue_cfg_t& get_ue_sched_cfg() const { return current_sched_ue_cfg; } bool is_crnti_set() const { return crnti_set; } diff --git a/srsenb/hdr/stack/rrc/rrc_ue.h b/srsenb/hdr/stack/rrc/rrc_ue.h index 2a9d19b8d..3f66332cb 100644 --- a/srsenb/hdr/stack/rrc/rrc_ue.h +++ b/srsenb/hdr/stack/rrc/rrc_ue.h @@ -49,7 +49,7 @@ public: void rlf_timer_expired(uint32_t timeout_id); void max_rlc_retx_reached(); void protocol_failure(); - void deactivate_bearers() { mac_ctrl.set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::IDLE); } + void deactivate_bearers() { mac_ctrl.set_radio_bearer_state(mac_lc_ch_cfg_t::IDLE); } rrc_state_t get_state(); void get_metrics(rrc_ue_metrics_t& ue_metrics) const; diff --git a/srsenb/src/stack/mac/CMakeLists.txt b/srsenb/src/stack/mac/CMakeLists.txt index 0ee0ac9bf..44bea9de7 100644 --- a/srsenb/src/stack/mac/CMakeLists.txt +++ b/srsenb/src/stack/mac/CMakeLists.txt @@ -6,6 +6,8 @@ # the distribution. # +add_subdirectory(common) + add_subdirectory(schedulers) set(SOURCES mac.cc ue.cc sched.cc sched_carrier.cc sched_grid.cc sched_ue_ctrl/sched_harq.cc sched_ue.cc @@ -13,5 +15,6 @@ set(SOURCES mac.cc ue.cc sched.cc sched_carrier.cc sched_grid.cc sched_ue_ctrl/s sched_phy_ch/sf_cch_allocator.cc sched_phy_ch/sched_dci.cc sched_phy_ch/sched_phy_resource.cc sched_helpers.cc) add_library(srsenb_mac STATIC ${SOURCES} $) +target_link_libraries(srsenb_mac srsenb_mac_common) add_subdirectory(nr) \ No newline at end of file diff --git a/srsenb/src/stack/mac/common/CMakeLists.txt b/srsenb/src/stack/mac/common/CMakeLists.txt new file mode 100644 index 000000000..328c5c30f --- /dev/null +++ b/srsenb/src/stack/mac/common/CMakeLists.txt @@ -0,0 +1,10 @@ +# +# Copyright 2013-2021 Software Radio Systems Limited +# +# By using this file, you agree to the terms and conditions set +# forth in the LICENSE file which can be found at the top level of +# the distribution. +# + +set(SOURCES ue_buffer_manager.cc) +add_library(srsenb_mac_common STATIC ${SOURCES}) diff --git a/srsenb/src/stack/mac/common/ue_buffer_manager.cc b/srsenb/src/stack/mac/common/ue_buffer_manager.cc new file mode 100644 index 000000000..775d20fb1 --- /dev/null +++ b/srsenb/src/stack/mac/common/ue_buffer_manager.cc @@ -0,0 +1,116 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#include "srsenb/hdr/stack/mac/common/ue_buffer_manager.h" +#include "srsran/common/string_helpers.h" +#include "srsran/srslog/bundled/fmt/format.h" +#include "srsran/srslog/bundled/fmt/ranges.h" + +namespace srsenb { + +template +void ue_buffer_manager::config_lcid(uint32_t lcid, const mac_lc_ch_cfg_t& bearer_cfg) +{ + if (not is_lcid_valid(lcid)) { + logger.warning("Configuring bearer with invalid logical channel id=%d", lcid); + return; + } + if (not is_lcg_valid(bearer_cfg.group)) { + logger.warning("Configuring bearer with invalid logical channel group id=%d", bearer_cfg.group); + return; + } + + // update bearer config + if (bearer_cfg != channels[lcid].cfg) { + channels[lcid].cfg = bearer_cfg; + if (channels[lcid].cfg.pbr == pbr_infinity) { + channels[lcid].bucket_size = std::numeric_limits::max(); + channels[lcid].Bj = std::numeric_limits::max(); + } else { + channels[lcid].bucket_size = channels[lcid].cfg.bsd * channels[lcid].cfg.pbr; + channels[lcid].Bj = 0; + } + logger.info("SCHED: bearer configured: lcid=%d, mode=%s, prio=%d", + lcid, + to_string(channels[lcid].cfg.direction), + channels[lcid].cfg.priority); + } +} + +template +int ue_buffer_manager::get_dl_tx_total() const +{ + int sum = 0; + for (size_t lcid = 0; is_lcid_valid(lcid); ++lcid) { + sum += get_dl_tx_total(lcid); + } + return sum; +} + +template +bool ue_buffer_manager::is_lcg_active(uint32_t lcg) const +{ + if (lcg == 0) { + return true; + } + for (uint32_t lcid = 0; is_lcid_valid(lcid); ++lcid) { + if (is_bearer_ul(lcid) and channels[lcid].cfg.group == (int)lcg) { + return true; + } + } + return false; +} + +template +int ue_buffer_manager::get_bsr(uint32_t lcg) const +{ + return is_lcg_active(lcg) ? lcg_bsr[lcg] : 0; +} + +template +void ue_buffer_manager::ul_bsr(uint32_t lcg_id, uint32_t val) +{ + if (not is_lcg_valid(lcg_id)) { + logger.warning("The provided logical channel group id=%d is not valid", lcg_id); + return; + } + lcg_bsr[lcg_id] = val; + + if (logger.debug.enabled()) { + fmt::memory_buffer str_buffer; + fmt::format_to(str_buffer, "{}", lcg_bsr); + logger.debug("SCHED: lcg_id=%d, bsr=%d. Current state=%s", lcg_id, val, srsran::to_c_str(str_buffer)); + } +} + +template +void ue_buffer_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue) +{ + if (not is_lcid_valid(lcid)) { + logger.warning("The provided lcid=%d is not valid", lcid); + return; + } + if (lcid <= MAX_SRB_LC_ID and + (channels[lcid].buf_tx != (int)tx_queue or channels[lcid].buf_retx != (int)retx_queue)) { + logger.info("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); + } else { + logger.debug("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); + } + channels[lcid].buf_retx = retx_queue; + channels[lcid].buf_tx = tx_queue; +} + +// Explicit instantiation +template class ue_buffer_manager; +template class ue_buffer_manager; + +} // namespace srsenb diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index f9fcd278a..aee82af20 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -147,7 +147,7 @@ int mac::rlc_buffer_state(uint16_t rnti, uint32_t lc_id, uint32_t tx_queue, uint return ret; } -int mac::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) +int mac::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, mac_lc_ch_cfg_t* cfg) { srsran::rwlock_read_guard lock(rwlock); return check_ue_active(rnti) ? scheduler.bearer_ue_cfg(rnti, lc_id, *cfg) : -1; @@ -552,7 +552,7 @@ void mac::rach_detected(uint32_t tti, uint32_t enb_cc_idx, uint32_t preamble_idx uecfg.supported_cc_list.emplace_back(); uecfg.supported_cc_list.back().active = true; uecfg.supported_cc_list.back().enb_cc_idx = enb_cc_idx; - uecfg.ue_bearers[0].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + uecfg.ue_bearers[0].direction = mac_lc_ch_cfg_t::BOTH; uecfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; if (ue_cfg(rnti, &uecfg) != SRSRAN_SUCCESS) { return; diff --git a/srsenb/src/stack/mac/nr/CMakeLists.txt b/srsenb/src/stack/mac/nr/CMakeLists.txt index 5ca49c739..51e8d57eb 100644 --- a/srsenb/src/stack/mac/nr/CMakeLists.txt +++ b/srsenb/src/stack/mac/nr/CMakeLists.txt @@ -19,7 +19,7 @@ set(SOURCES mac_nr.cc sched_nr_cell.cc sched_nr_rb.cc sched_nr_time_rr.cc - harq_softbuffer.cc - sched_nr_ue_buffer_manager.cc) + harq_softbuffer.cc) add_library(srsgnb_mac STATIC ${SOURCES}) +target_link_libraries(srsgnb_mac srsenb_mac_common) diff --git a/srsenb/src/stack/mac/nr/sched_nr_ue_buffer_manager.cc b/srsenb/src/stack/mac/nr/sched_nr_ue_buffer_manager.cc deleted file mode 100644 index ac0a27b55..000000000 --- a/srsenb/src/stack/mac/nr/sched_nr_ue_buffer_manager.cc +++ /dev/null @@ -1,70 +0,0 @@ -/** - * - * \section COPYRIGHT - * - * Copyright 2013-2021 Software Radio Systems Limited - * - * By using this file, you agree to the terms and conditions set - * forth in the LICENSE file which can be found at the top level of - * the distribution. - * - */ - -#include "srsenb/hdr/stack/mac/nr/sched_nr_ue_buffer_manager.h" -#include "srsran/common/string_helpers.h" -#include "srsran/srslog/bundled/fmt/format.h" -#include "srsran/srslog/bundled/fmt/ranges.h" - -namespace srsenb { -namespace sched_nr_impl { - -ue_buffer_manager::ue_buffer_manager(srslog::basic_logger& logger_) : logger(logger_) {} - -bool ue_buffer_manager::is_lcg_active(uint32_t lcg) const -{ - if (lcg == 0) { - return true; - } - for (uint32_t lcid = 0; lcid < MAX_LC_ID; ++lcid) { - if (is_bearer_ul(lcid) and channels[lcid].cfg.group == (int)lcg) { - return true; - } - } - return false; -} - -int ue_buffer_manager::get_bsr(uint32_t lcg) const -{ - return is_lcg_active(lcg) ? lcg_bsr[lcg] : 0; -} - -void ue_buffer_manager::ul_bsr(uint32_t lcg_id, uint32_t val) -{ - srsran_assert(lcg_id < MAX_LCG_ID, "Provided LCG_ID=%d is above its limit=%d", lcg_id, MAX_LCG_ID); - lcg_bsr[lcg_id] = val; - - if (logger.debug.enabled()) { - fmt::memory_buffer str_buffer; - fmt::format_to(str_buffer, "{}", lcg_bsr); - logger.debug("SCHED: lcg_id=%d, bsr=%s. Current state=%s", lcg_id, val, srsran::to_c_str(str_buffer)); - } -} - -void ue_buffer_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue) -{ - if (lcid >= MAX_LC_ID) { - logger.warning("The provided lcid=%d is not valid", lcid); - return; - } - if (lcid <= MAX_SRB_LC_ID and - (channels[lcid].buf_tx != (int)tx_queue or channels[lcid].buf_retx != (int)retx_queue)) { - logger.info("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); - } else { - logger.debug("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); - } - channels[lcid].buf_retx = retx_queue; - channels[lcid].buf_tx = tx_queue; -} - -} // namespace sched_nr_impl -} // namespace srsenb diff --git a/srsenb/src/stack/mac/sched.cc b/srsenb/src/stack/mac/sched.cc index f55023c23..f01a209fe 100644 --- a/srsenb/src/stack/mac/sched.cc +++ b/srsenb/src/stack/mac/sched.cc @@ -136,7 +136,7 @@ void sched::phy_config_enabled(uint16_t rnti, bool enabled) rnti, [this, enabled](sched_ue& ue) { ue.phy_config_enabled(last_tti, enabled); }, __PRETTY_FUNCTION__); } -int sched::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg_) +int sched::bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, const mac_lc_ch_cfg_t& cfg_) { return ue_db_access_locked(rnti, [lc_id, cfg_](sched_ue& ue) { ue.set_bearer_cfg(lc_id, cfg_); }); } diff --git a/srsenb/src/stack/mac/sched_helpers.cc b/srsenb/src/stack/mac/sched_helpers.cc index 0dd785551..5b7d78f20 100644 --- a/srsenb/src/stack/mac/sched_helpers.cc +++ b/srsenb/src/stack/mac/sched_helpers.cc @@ -450,20 +450,4 @@ int check_ue_cfg_correctness(const sched_interface::ue_cfg_t& ue_cfg) return ret; } -const char* to_string(sched_interface::ue_bearer_cfg_t::direction_t dir) -{ - switch (dir) { - case sched_interface::ue_bearer_cfg_t::IDLE: - return "idle"; - case sched_interface::ue_bearer_cfg_t::BOTH: - return "bi-dir"; - case sched_interface::ue_bearer_cfg_t::DL: - return "DL"; - case sched_interface::ue_bearer_cfg_t::UL: - return "UL"; - default: - return "unrecognized direction"; - } -} - } // namespace srsenb diff --git a/srsenb/src/stack/mac/sched_ue.cc b/srsenb/src/stack/mac/sched_ue.cc index 0b8f07107..fd9031323 100644 --- a/srsenb/src/stack/mac/sched_ue.cc +++ b/srsenb/src/stack/mac/sched_ue.cc @@ -104,7 +104,7 @@ void sched_ue::new_subframe(tti_point tti_rx, uint32_t enb_cc_idx) * *******************************************************/ -void sched_ue::set_bearer_cfg(uint32_t lc_id, const bearer_cfg_t& cfg_) +void sched_ue::set_bearer_cfg(uint32_t lc_id, const mac_lc_ch_cfg_t& cfg_) { cfg.ue_bearers[lc_id] = cfg_; lch_handler.config_lcid(lc_id, cfg_); @@ -112,8 +112,8 @@ void sched_ue::set_bearer_cfg(uint32_t lc_id, const bearer_cfg_t& cfg_) void sched_ue::rem_bearer(uint32_t lc_id) { - cfg.ue_bearers[lc_id] = sched_interface::ue_bearer_cfg_t{}; - lch_handler.config_lcid(lc_id, sched_interface::ue_bearer_cfg_t{}); + cfg.ue_bearers[lc_id] = mac_lc_ch_cfg_t{}; + lch_handler.config_lcid(lc_id, mac_lc_ch_cfg_t{}); } void sched_ue::phy_config_enabled(tti_point tti_rx, bool enabled) diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc index 10869e80b..3bd85f603 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_lch.cc @@ -57,7 +57,7 @@ uint32_t get_ul_mac_sdu_size_with_overhead(uint32_t rlc_pdu_bytes) void lch_ue_manager::set_cfg(const sched_interface::ue_cfg_t& cfg) { - for (uint32_t lcid = 0; lcid < sched_interface::MAX_LC; lcid++) { + for (uint32_t lcid = 0; is_lcid_valid(lcid); lcid++) { config_lcid(lcid, cfg.ue_bearers[lcid]); } } @@ -67,85 +67,27 @@ void lch_ue_manager::new_tti() prio_idx++; for (uint32_t lcid = 0; lcid < sched_interface::MAX_LC; ++lcid) { if (is_bearer_active(lcid)) { - if (lch[lcid].cfg.pbr != pbr_infinity) { - lch[lcid].Bj = std::min(lch[lcid].Bj + (int)(lch[lcid].cfg.pbr * tti_duration_ms), lch[lcid].bucket_size); + if (channels[lcid].cfg.pbr != pbr_infinity) { + channels[lcid].Bj = + std::min(channels[lcid].Bj + (int)(channels[lcid].cfg.pbr * tti_duration_ms), channels[lcid].bucket_size); } } } } -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) { - logger.warning("Adding bearer with invalid logical channel id=%d", lc_id); - return; - } - if (bearer_cfg.group >= sched_interface::MAX_LC_GROUP) { - logger.warning("Adding bearer with invalid logical channel group id=%d", bearer_cfg.group); - return; - } - - // update bearer config - bool is_equal = memcmp(&bearer_cfg, &lch[lc_id].cfg, sizeof(bearer_cfg)) == 0; - - if (not is_equal) { - lch[lc_id].cfg = bearer_cfg; - if (lch[lc_id].cfg.pbr == pbr_infinity) { - lch[lc_id].bucket_size = std::numeric_limits::max(); - lch[lc_id].Bj = std::numeric_limits::max(); - } else { - lch[lc_id].bucket_size = lch[lc_id].cfg.bsd * lch[lc_id].cfg.pbr; - lch[lc_id].Bj = 0; - } - logger.info("SCHED: bearer configured: lc_id=%d, mode=%s, prio=%d", - lc_id, - to_string(lch[lc_id].cfg.direction), - lch[lc_id].cfg.priority); - } -} - -void lch_ue_manager::ul_bsr(uint8_t lcg_id, uint32_t bsr) -{ - if (lcg_id >= sched_interface::MAX_LC_GROUP) { - logger.warning("The provided logical channel group id=%d is not valid", lcg_id); - return; - } - lcg_bsr[lcg_id] = bsr; - if (logger.debug.enabled()) { - fmt::memory_buffer str_buffer; - fmt::format_to(str_buffer, "{}", get_bsr_state()); - logger.debug("SCHED: bsr=%d, lcg_id=%d, bsr=%s", bsr, lcg_id, srsran::to_c_str(str_buffer)); - } -} - void lch_ue_manager::ul_buffer_add(uint8_t lcid, uint32_t bytes) { if (lcid >= sched_interface::MAX_LC) { logger.warning("The provided lcid=%d is not valid", lcid); return; } - lcg_bsr[lch[lcid].cfg.group] += bytes; + lcg_bsr[channels[lcid].cfg.group] += bytes; if (logger.debug.enabled()) { fmt::memory_buffer str_buffer; fmt::format_to(str_buffer, "{}", get_bsr_state()); logger.debug( - "SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s", bytes, lch[lcid].cfg.group, srsran::to_c_str(str_buffer)); - } -} - -void lch_ue_manager::dl_buffer_state(uint8_t lcid, uint32_t tx_queue, uint32_t retx_queue) -{ - if (lcid >= sched_interface::MAX_LC) { - logger.warning("The provided lcid=%d is not valid", lcid); - return; - } - if (lcid < 3 and (lch[lcid].buf_tx != (int)tx_queue or lch[lcid].buf_retx != (int)retx_queue)) { - logger.info("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); - } else { - logger.debug("SCHED: DL lcid=%d buffer_state=%d,%d", lcid, tx_queue, retx_queue); + "SCHED: UL buffer update=%d, lcg_id=%d, bsr=%s", bytes, channels[lcid].cfg.group, srsran::to_c_str(str_buffer)); } - lch[lcid].buf_retx = retx_queue; - lch[lcid].buf_tx = tx_queue; } int lch_ue_manager::get_max_prio_lcid() const @@ -153,9 +95,9 @@ int lch_ue_manager::get_max_prio_lcid() const int min_prio_val = std::numeric_limits::max(), prio_lcid = -1; // Prioritize retxs - for (uint32_t lcid = 0; lcid < MAX_LC; ++lcid) { - if (get_dl_retx(lcid) > 0 and lch[lcid].cfg.priority < min_prio_val) { - min_prio_val = lch[lcid].cfg.priority; + for (uint32_t lcid = 0; is_lcid_valid(lcid); ++lcid) { + if (get_dl_retx(lcid) > 0 and channels[lcid].cfg.priority < min_prio_val) { + min_prio_val = channels[lcid].cfg.priority; prio_lcid = lcid; } } @@ -164,9 +106,9 @@ int lch_ue_manager::get_max_prio_lcid() const } // Select lcid with new txs using Bj - for (uint32_t lcid = 0; lcid < MAX_LC; ++lcid) { - if (get_dl_tx(lcid) > 0 and lch[lcid].Bj > 0 and lch[lcid].cfg.priority < min_prio_val) { - min_prio_val = lch[lcid].cfg.priority; + for (uint32_t lcid = 0; is_lcid_valid(lcid); ++lcid) { + if (get_dl_tx(lcid) > 0 and channels[lcid].Bj > 0 and channels[lcid].cfg.priority < min_prio_val) { + min_prio_val = channels[lcid].cfg.priority; prio_lcid = lcid; } } @@ -175,15 +117,15 @@ int lch_ue_manager::get_max_prio_lcid() const } // Disregard Bj - size_t nof_lcids = 0; - std::array chosen_lcids = {}; - for (uint32_t lcid = 0; lcid < MAX_LC; ++lcid) { + size_t nof_lcids = 0; + std::array chosen_lcids = {}; + for (uint32_t lcid = 0; is_lcid_valid(lcid); ++lcid) { if (get_dl_tx_total(lcid) > 0) { - if (lch[lcid].cfg.priority < min_prio_val) { - min_prio_val = lch[lcid].cfg.priority; + if (channels[lcid].cfg.priority < min_prio_val) { + min_prio_val = channels[lcid].cfg.priority; chosen_lcids[0] = lcid; nof_lcids = 1; - } else if (lch[lcid].cfg.priority == min_prio_val) { + } else if (channels[lcid].cfg.priority == min_prio_val) { chosen_lcids[nof_lcids++] = lcid; } } @@ -234,7 +176,7 @@ int lch_ue_manager::alloc_retx_bytes(uint8_t lcid, int rem_bytes) } int rem_bytes_no_header = rem_bytes - rlc_overhead; int alloc = std::min(rem_bytes_no_header, get_dl_retx(lcid)); - lch[lcid].buf_retx -= alloc; + channels[lcid].buf_retx -= alloc; return alloc + (alloc > 0 ? rlc_overhead : 0); } @@ -246,35 +188,20 @@ int lch_ue_manager::alloc_tx_bytes(uint8_t lcid, int rem_bytes) } int rem_bytes_no_header = rem_bytes - rlc_overhead; int alloc = std::min(rem_bytes_no_header, get_dl_tx(lcid)); - lch[lcid].buf_tx -= alloc; - if (alloc > 0 and lch[lcid].cfg.pbr != pbr_infinity) { + channels[lcid].buf_tx -= alloc; + if (alloc > 0 and channels[lcid].cfg.pbr != pbr_infinity) { // Update Bj - lch[lcid].Bj -= alloc; + channels[lcid].Bj -= alloc; } return alloc + (alloc > 0 ? rlc_overhead : 0); } -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_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_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_ue_manager::has_pending_dl_txs() const { if (not pending_ces.empty()) { return true; } - for (uint32_t lcid = 0; lcid < lch.size(); ++lcid) { + for (uint32_t lcid = 0; is_lcid_valid(lcid); ++lcid) { if (get_dl_tx_total(lcid) > 0) { return true; } @@ -282,64 +209,26 @@ bool lch_ue_manager::has_pending_dl_txs() const return false; } -int lch_ue_manager::get_dl_tx_total() const -{ - int sum = 0; - for (size_t lcid = 0; lcid < lch.size(); ++lcid) { - sum += get_dl_tx_total(lcid); - } - return sum; -} - 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_ue_manager::get_dl_tx(uint32_t lcid) const -{ - return is_bearer_dl(lcid) ? lch[lcid].buf_tx : 0; -} int lch_ue_manager::get_dl_tx_with_overhead(uint32_t lcid) const { return get_dl_mac_sdu_size_with_overhead(lcid, get_dl_tx(lcid)); } -int lch_ue_manager::get_dl_retx(uint32_t lcid) const -{ - return is_bearer_dl(lcid) ? lch[lcid].buf_retx : 0; -} int lch_ue_manager::get_dl_retx_with_overhead(uint32_t lcid) const { return get_dl_mac_sdu_size_with_overhead(lcid, get_dl_retx(lcid)); } -bool lch_ue_manager::is_lcg_active(uint32_t lcg) const -{ - if (lcg == 0) { - return true; - } - for (uint32_t lcid = 0; lcid < MAX_LC; ++lcid) { - if (is_bearer_ul(lcid) and lch[lcid].cfg.group == (int)lcg) { - return true; - } - } - return false; -} -int lch_ue_manager::get_bsr(uint32_t lcg) const -{ - return is_lcg_active(lcg) ? lcg_bsr[lcg] : 0; -} int lch_ue_manager::get_bsr_with_overhead(uint32_t lcg) const { return get_ul_mac_sdu_size_with_overhead(get_bsr(lcg)); } -const std::array& lch_ue_manager::get_bsr_state() const -{ - return lcg_bsr; -} - uint32_t allocate_mac_sdus(sched_interface::dl_sched_data_t* data, lch_ue_manager& lch_handler, uint32_t total_tbs, diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc index a4c28cdaa..24dd95133 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc @@ -255,7 +255,7 @@ int sched_ue_cell::set_ack_info(tti_point tti_rx, uint32_t tb_idx, bool ack) int sched_ue_cell::set_ul_snr(tti_point tti_rx, float ul_snr, uint32_t ul_ch_code) { CHECK_VALID_CC("UL SNR estimate"); - if (ue_cfg->ue_bearers[1].direction == sched_interface::ue_bearer_cfg_t::IDLE) { + if (ue_cfg->ue_bearers[1].direction == mac_lc_ch_cfg_t::IDLE) { // Ignore Msg3 SNR samples as Msg3 uses a separate power control loop return SRSRAN_SUCCESS; } diff --git a/srsenb/src/stack/rrc/mac_controller.cc b/srsenb/src/stack/rrc/mac_controller.cc index 1f36d2ef8..1b4925508 100644 --- a/srsenb/src/stack/rrc/mac_controller.cc +++ b/srsenb/src/stack/rrc/mac_controller.cc @@ -23,28 +23,28 @@ using ue_cfg_t = sched_interface::ue_cfg_t; /********* Helper Methods ********/ // TS 36.331 9.1.1.2 - CCCH configuration -sched_interface::ue_bearer_cfg_t get_bearer_default_ccch_config() +mac_lc_ch_cfg_t get_bearer_default_ccch_config() { - sched_interface::ue_bearer_cfg_t bearer = {}; - bearer.direction = sched_interface::ue_bearer_cfg_t::BOTH; - bearer.priority = 1; - bearer.pbr = -1; - bearer.bsd = -1; - bearer.group = 0; + mac_lc_ch_cfg_t bearer = {}; + bearer.direction = mac_lc_ch_cfg_t::BOTH; + bearer.priority = 1; + bearer.pbr = -1; + bearer.bsd = -1; + bearer.group = 0; return bearer; } // TS 36.331 9.2.1.1 - SRB1 -sched_interface::ue_bearer_cfg_t get_bearer_default_srb1_config() +mac_lc_ch_cfg_t get_bearer_default_srb1_config() { return get_bearer_default_ccch_config(); } // TS 36.331 9.2.1.2 - SRB2 -sched_interface::ue_bearer_cfg_t get_bearer_default_srb2_config() +mac_lc_ch_cfg_t get_bearer_default_srb2_config() { - sched_interface::ue_bearer_cfg_t bearer = get_bearer_default_srb1_config(); - bearer.priority = 3; + mac_lc_ch_cfg_t bearer = get_bearer_default_srb1_config(); + bearer.priority = 3; return bearer; } @@ -233,7 +233,7 @@ void mac_controller::apply_current_bearers_cfg() for (const drb_to_add_mod_s& drb : drbs) { auto& bcfg = current_sched_ue_cfg.ue_bearers[drb.lc_ch_id]; bcfg = {}; - bcfg.direction = sched_interface::ue_bearer_cfg_t::BOTH; + bcfg.direction = mac_lc_ch_cfg_t::BOTH; bcfg.group = 1; bcfg.priority = 4; if (drb.lc_ch_cfg_present and drb.lc_ch_cfg.ul_specific_params_present) { @@ -283,7 +283,7 @@ void mac_controller::handle_intraenb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_i // Stop any SRB UL (including SRs) for (uint32_t i = srb_to_lcid(lte_srb::srb1); i <= srb_to_lcid(lte_srb::srb2); ++i) { - current_sched_ue_cfg.ue_bearers[i].direction = sched_interface::ue_bearer_cfg_t::DL; + current_sched_ue_cfg.ue_bearers[i].direction = mac_lc_ch_cfg_t::DL; } update_mac(mac_controller::config_tx); @@ -297,7 +297,7 @@ void mac_controller::handle_ho_prep(const asn1::rrc::ho_prep_info_r8_ies_s& ho_p } } -void mac_controller::set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::direction_t dir) +void mac_controller::set_radio_bearer_state(mac_lc_ch_cfg_t::direction_t dir) { for (uint32_t i = srb_to_lcid(lte_srb::srb0); i <= srb_to_lcid(lte_srb::srb2); ++i) { current_sched_ue_cfg.ue_bearers[i].direction = dir; @@ -319,7 +319,7 @@ void mac_controller::set_drb_activation(bool active) { for (const drb_to_add_mod_s& drb : bearer_list.get_established_drbs()) { current_sched_ue_cfg.ue_bearers[drb_to_lcid((lte_drb)drb.drb_id)].direction = - active ? sched_interface::ue_bearer_cfg_t::BOTH : sched_interface::ue_bearer_cfg_t::IDLE; + active ? mac_lc_ch_cfg_t::BOTH : mac_lc_ch_cfg_t::IDLE; } } @@ -388,7 +388,7 @@ void ue_cfg_apply_srb_updates(ue_cfg_t& ue_cfg, const srb_to_add_mod_list_l& srb srslog::fetch_basic_logger("RRC").warning("Invalid SRB ID %d", (int)srb.srb_id); bcfg = {}; } - bcfg.direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + bcfg.direction = srsenb::mac_lc_ch_cfg_t::BOTH; if (srb.lc_ch_cfg_present and srb.lc_ch_cfg.type().value == srb_to_add_mod_s::lc_ch_cfg_c_::types_opts::explicit_value and srb.lc_ch_cfg.explicit_value().ul_specific_params_present) { diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 078a51dbd..c74506a07 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -11,6 +11,7 @@ */ #include "srsenb/hdr/stack/rrc/rrc.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_endc.h" #include "srsenb/hdr/stack/rrc/rrc_mobility.h" @@ -24,7 +25,6 @@ #include "srsran/interfaces/enb_mac_interfaces.h" #include "srsran/interfaces/enb_pdcp_interfaces.h" #include "srsran/interfaces/enb_rlc_interfaces.h" -#include "srsran/interfaces/sched_interface.h" using srsran::byte_buffer_t; diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 7888799d2..946f977de 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -161,7 +161,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& ue_cfg.supported_cc_list.resize(1); ue_cfg.supported_cc_list[0].active = true; ue_cfg.supported_cc_list[0].enb_cc_idx = target_cell->enb_cc_idx; - ue_cfg.ue_bearers[0].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[0].direction = mac_lc_ch_cfg_t::BOTH; ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; uint16_t rnti = mac->reserve_new_crnti(ue_cfg); if (rnti == SRSRAN_INVALID_RNTI) { diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index ddaab20cc..81fad3b40 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -136,7 +136,7 @@ void rrc::ue::set_radiolink_dl_state(bool crc_res) parent->logger.info( "DL RLF timer stopped for rnti=0x%x (time elapsed=%dms)", rnti, phy_dl_rlf_timer.time_elapsed()); phy_dl_rlf_timer.stop(); - mac_ctrl.set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::BOTH); + mac_ctrl.set_radio_bearer_state(mac_lc_ch_cfg_t::BOTH); } return; } @@ -151,7 +151,7 @@ void rrc::ue::set_radiolink_dl_state(bool crc_res) consecutive_kos_dl++; if (consecutive_kos_dl > parent->cfg.max_mac_dl_kos) { parent->logger.info("Max KOs in DL reached, starting RLF timer rnti=0x%x", rnti); - mac_ctrl.set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::IDLE); + mac_ctrl.set_radio_bearer_state(mac_lc_ch_cfg_t::IDLE); phy_dl_rlf_timer.run(); } } @@ -168,7 +168,7 @@ void rrc::ue::set_radiolink_ul_state(bool crc_res) parent->logger.info( "UL RLF timer stopped for rnti=0x%x (time elapsed=%dms)", rnti, phy_ul_rlf_timer.time_elapsed()); phy_ul_rlf_timer.stop(); - mac_ctrl.set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::BOTH); + mac_ctrl.set_radio_bearer_state(mac_lc_ch_cfg_t::BOTH); } return; } @@ -190,7 +190,7 @@ void rrc::ue::set_radiolink_ul_state(bool crc_res) consecutive_kos_ul++; if (consecutive_kos_ul > parent->cfg.max_mac_ul_kos) { parent->logger.info("Max KOs in UL reached, starting RLF timer rnti=0x%x", rnti); - mac_ctrl.set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::IDLE); + mac_ctrl.set_radio_bearer_state(mac_lc_ch_cfg_t::IDLE); phy_ul_rlf_timer.run(); } } @@ -250,7 +250,7 @@ void rrc::ue::max_rlc_retx_reached() parent->logger.info("Max RLC retx reached for rnti=0x%x", rnti); // Turn off scheduling but give UE chance to start re-establishment - mac_ctrl.set_radio_bearer_state(sched_interface::ue_bearer_cfg_t::IDLE); + mac_ctrl.set_radio_bearer_state(mac_lc_ch_cfg_t::IDLE); rlc_rlf_timer.run(); } diff --git a/srsenb/test/common/dummy_classes.h b/srsenb/test/common/dummy_classes.h index d439a44d1..e27f57dad 100644 --- a/srsenb/test/common/dummy_classes.h +++ b/srsenb/test/common/dummy_classes.h @@ -30,7 +30,7 @@ public: int ue_cfg(uint16_t rnti, const sched_interface::ue_cfg_t* cfg) override { return 0; } int ue_rem(uint16_t rnti) override { return 0; } int ue_set_crnti(uint16_t temp_crnti, uint16_t crnti, const sched_interface::ue_cfg_t& cfg) override { return 0; } - int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, sched_interface::ue_bearer_cfg_t* cfg) override { return 0; } + int bearer_ue_cfg(uint16_t rnti, uint32_t lc_id, mac_lc_ch_cfg_t* cfg) override { return 0; } int bearer_ue_rem(uint16_t rnti, uint32_t lc_id) override { return 0; } void phy_config_enabled(uint16_t rnti, bool enabled) override {} void write_mcch(const srsran::sib2_mbms_t* sib2_, diff --git a/srsenb/test/mac/sched_common_test_suite.h b/srsenb/test/mac/sched_common_test_suite.h index 7ff5c9f93..bc4d35dfb 100644 --- a/srsenb/test/mac/sched_common_test_suite.h +++ b/srsenb/test/mac/sched_common_test_suite.h @@ -13,11 +13,11 @@ #ifndef SRSRAN_SCHED_COMMON_TEST_SUITE_H #define SRSRAN_SCHED_COMMON_TEST_SUITE_H +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsenb/hdr/stack/mac/sched_lte_common.h" #include "srsenb/hdr/stack/mac/sched_phy_ch/sched_phy_resource.h" #include "srsran/adt/span.h" #include "srsran/common/tti_point.h" -#include "srsran/interfaces/sched_interface.h" namespace srsenb { diff --git a/srsenb/test/mac/sched_lc_ch_test.cc b/srsenb/test/mac/sched_lc_ch_test.cc index 530050e92..d321bb144 100644 --- a/srsenb/test/mac/sched_lc_ch_test.cc +++ b/srsenb/test/mac/sched_lc_ch_test.cc @@ -81,12 +81,12 @@ int test_lc_ch_pbr_infinity() srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); ue_cfg = generate_setup_ue_cfg(ue_cfg); ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))] = {}; - ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))].direction = mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))] = {}; - ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].direction = mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].priority = 5; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))] = {}; - ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].direction = mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].priority = 3; lch_handler.set_cfg(ue_cfg); @@ -131,14 +131,14 @@ int test_lc_ch_pbr_finite() srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); ue_cfg = generate_setup_ue_cfg(ue_cfg); ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))] = {}; - ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid((lte_srb::srb1))].direction = mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))] = {}; - ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].direction = mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].pbr = 256; // kBps ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].bsd = 50; // msec ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb1))].priority = 5; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))] = {}; - ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].direction = sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].direction = mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].pbr = 8; // kBps ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].bsd = 50; // msec ue_cfg.ue_bearers[drb_to_lcid((lte_drb::drb2))].priority = 3; diff --git a/srsenb/test/mac/sched_sim_ue.cc b/srsenb/test/mac/sched_sim_ue.cc index 4606ba400..fbbb22f44 100644 --- a/srsenb/test/mac/sched_sim_ue.cc +++ b/srsenb/test/mac/sched_sim_ue.cc @@ -61,7 +61,7 @@ void ue_sim::set_cfg(const sched_interface::ue_cfg_t& ue_cfg_) } } -void ue_sim::bearer_cfg(uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg) +void ue_sim::bearer_cfg(uint32_t lc_id, const mac_lc_ch_cfg_t& cfg) { ctxt.ue_cfg.ue_bearers.at(lc_id) = cfg; } @@ -269,7 +269,7 @@ int sched_sim_base::ue_recfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_ return SRSRAN_SUCCESS; } -int sched_sim_base::bearer_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg) +int sched_sim_base::bearer_cfg(uint16_t rnti, uint32_t lc_id, const mac_lc_ch_cfg_t& cfg) { ue_db.at(rnti).bearer_cfg(lc_id, cfg); return sched_ptr->bearer_ue_cfg(rnti, lc_id, cfg); diff --git a/srsenb/test/mac/sched_sim_ue.h b/srsenb/test/mac/sched_sim_ue.h index 8a39426f5..11fcea029 100644 --- a/srsenb/test/mac/sched_sim_ue.h +++ b/srsenb/test/mac/sched_sim_ue.h @@ -14,7 +14,7 @@ #define SRSRAN_SCHED_SIM_UE_H #include "sched_common_test_suite.h" -#include "srsran/interfaces/sched_interface.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/srslog/srslog.h" #include #include @@ -80,7 +80,7 @@ public: uint32_t preamble_idx); void set_cfg(const sched_interface::ue_cfg_t& ue_cfg_); - void bearer_cfg(uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg); + void bearer_cfg(uint32_t lc_id, const mac_lc_ch_cfg_t& cfg); int update(const sf_output_res_t& sf_out); @@ -106,7 +106,7 @@ public: int add_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_, uint32_t preamble_idx); int ue_recfg(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_); - int bearer_cfg(uint16_t rnti, uint32_t lc_id, const sched_interface::ue_bearer_cfg_t& cfg); + int bearer_cfg(uint16_t rnti, uint32_t lc_id, const mac_lc_ch_cfg_t& cfg); int rem_user(uint16_t rnti); void new_tti(srsran::tti_point tti_rx); diff --git a/srsenb/test/mac/sched_test_rand.cc b/srsenb/test/mac/sched_test_rand.cc index 766230bea..c55145715 100644 --- a/srsenb/test/mac/sched_test_rand.cc +++ b/srsenb/test/mac/sched_test_rand.cc @@ -19,7 +19,7 @@ #include #include -#include "srsran/interfaces/sched_interface.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/phy/utils/debug.h" #include "sched_common_test_suite.h" diff --git a/srsenb/test/mac/sched_test_utils.h b/srsenb/test/mac/sched_test_utils.h index ed1745ef2..15d96511e 100644 --- a/srsenb/test/mac/sched_test_utils.h +++ b/srsenb/test/mac/sched_test_utils.h @@ -15,8 +15,8 @@ #include "srsenb/hdr/common/common_enb.h" #include "srsenb/hdr/stack/mac/sched.h" +#include "srsenb/hdr/stack/mac/sched_interface.h" #include "srsran/common/test_common.h" -#include "srsran/interfaces/sched_interface.h" #include #include #include @@ -71,10 +71,10 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg() ue_cfg.supported_cc_list[0].enb_cc_idx = 0; ue_cfg.supported_cc_list[0].active = true; ue_cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; - ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].group = 1; ue_cfg.pucch_cfg.sr_configured = true; @@ -88,9 +88,9 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg2() { srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); - ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; + ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; + ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].group = 1; return ue_cfg; @@ -99,7 +99,7 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg2() inline srsenb::sched_interface::ue_cfg_t generate_rach_ue_cfg(const srsenb::sched_interface::ue_cfg_t& final_cfg) { srsenb::sched_interface::ue_cfg_t cfg = {}; - cfg.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + cfg.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; cfg.supported_cc_list.resize(1); cfg.supported_cc_list[0].enb_cc_idx = final_cfg.supported_cc_list[0].enb_cc_idx; cfg.supported_cc_list[0].active = true; @@ -111,7 +111,7 @@ inline srsenb::sched_interface::ue_cfg_t generate_setup_ue_cfg(const srsenb::sch srsenb::sched_interface::ue_cfg_t cfg = generate_rach_ue_cfg(final_cfg); cfg.maxharq_tx = final_cfg.maxharq_tx; - cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + cfg.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; cfg.supported_cc_list[0].dl_cfg.tm = SRSRAN_TM1; cfg.continuous_pusch = final_cfg.continuous_pusch; @@ -150,11 +150,11 @@ struct tti_ev { uint32_t dl_nof_retxs = 0; ///< update DL buffer retx }; struct user_cfg_ev { - uint16_t rnti; - std::unique_ptr ue_sim_cfg; ///< optional ue_cfg call - std::unique_ptr bearer_cfg; ///< optional bearer_cfg call - std::unique_ptr buffer_ev; ///< update of a user dl/ul buffer - bool rem_user = false; ///< whether to remove a ue + uint16_t rnti; + std::unique_ptr ue_sim_cfg; ///< optional ue_cfg call + std::unique_ptr bearer_cfg; ///< optional bearer_cfg call + std::unique_ptr buffer_ev; ///< update of a user dl/ul buffer + bool rem_user = false; ///< whether to remove a ue }; std::vector user_updates; }; @@ -259,11 +259,9 @@ struct sched_sim_event_generator { ue_sim_cfg.ue_cfg = generate_default_ue_cfg(); user->ue_sim_cfg.reset(new ue_ctxt_test_cfg{ue_sim_cfg}); // it should by now have a DRB1. Add other DRBs manually - user->ue_sim_cfg->ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = - srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - user->ue_sim_cfg->ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = - srsenb::sched_interface::ue_bearer_cfg_t::BOTH; - user->ue_sim_cfg->ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].group = 1; + user->ue_sim_cfg->ue_cfg.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; + user->ue_sim_cfg->ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction = srsenb::mac_lc_ch_cfg_t::BOTH; + user->ue_sim_cfg->ue_cfg.ue_bearers[drb_to_lcid(lte_drb::drb1)].group = 1; return user; } diff --git a/srsenb/test/rrc/rrc_mobility_test.cc b/srsenb/test/rrc/rrc_mobility_test.cc index 0c7ac9838..15739a1f7 100644 --- a/srsenb/test/rrc/rrc_mobility_test.cc +++ b/srsenb/test/rrc/rrc_mobility_test.cc @@ -323,7 +323,7 @@ int test_s1ap_tenb_mobility(test_event test_params) auto& mac_ue = tester.mac.ue_db[0x46]; TESTASSERT(mac_ue.supported_cc_list[0].active); TESTASSERT(mac_ue.supported_cc_list[0].enb_cc_idx == 0); - TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction == sched_interface::ue_bearer_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb0)].direction == mac_lc_ch_cfg_t::BOTH); // Check Security Configuration TESTASSERT(tester.pdcp.bearers.count(0x46)); TESTASSERT(tester.pdcp.bearers[0x46].count(srb_to_lcid(lte_srb::srb1)) and @@ -384,9 +384,9 @@ int test_s1ap_tenb_mobility(test_event test_params) copy_msg_to_buffer(pdu, recfg_complete); tester.rrc.write_pdu(0x46, srb_to_lcid(lte_srb::srb1), std::move(pdu)); tester.tic(); - TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH); - TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == sched_interface::ue_bearer_cfg_t::BOTH); - TESTASSERT(mac_ue.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction == sched_interface::ue_bearer_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == mac_lc_ch_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == mac_lc_ch_cfg_t::BOTH); + TESTASSERT(mac_ue.ue_bearers[drb_to_lcid(lte_drb::drb1)].direction == mac_lc_ch_cfg_t::BOTH); TESTASSERT(mac_ue.pucch_cfg.I_sr == recfg_r8.rr_cfg_ded.phys_cfg_ded.sched_request_cfg.setup().sr_cfg_idx); TESTASSERT(mac_ue.pucch_cfg.n_pucch_sr == recfg_r8.rr_cfg_ded.phys_cfg_ded.sched_request_cfg.setup().sr_pucch_res_idx); @@ -474,8 +474,8 @@ int test_intraenb_mobility(srsran::log_sink_spy& spy, test_event test_params) TESTASSERT((1 + recfg_r8.meas_cfg.meas_gap_cfg.setup().gap_offset.type().value) * 40u == tester.cfg.cell_list[1].meas_cfg.meas_gap_period); auto* ue_cfg = &tester.mac.ue_db[tester.rnti]; - TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == srsenb::sched_interface::ue_bearer_cfg_t::DL); - TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == srsenb::sched_interface::ue_bearer_cfg_t::DL); + TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == srsenb::mac_lc_ch_cfg_t::DL); + TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == srsenb::mac_lc_ch_cfg_t::DL); /* Test Case: The UE sends a C-RNTI CE. Bearers are reestablished, PHY is configured */ tester.pdcp.last_sdu.sdu = nullptr; @@ -485,12 +485,9 @@ int test_intraenb_mobility(srsran::log_sink_spy& spy, test_event test_params) TESTASSERT(tester.phy.phy_cfg_set); TESTASSERT(tester.phy.last_cfg.size() == 1 and ue_cfg->supported_cc_list.size() == 1); TESTASSERT(tester.phy.last_cfg[0].enb_cc_idx == ue_cfg->supported_cc_list[0].enb_cc_idx); - TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb0)].direction == - srsenb::sched_interface::ue_bearer_cfg_t::BOTH); - TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == - srsenb::sched_interface::ue_bearer_cfg_t::BOTH); - TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == - srsenb::sched_interface::ue_bearer_cfg_t::BOTH); + TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb0)].direction == srsenb::mac_lc_ch_cfg_t::BOTH); + TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb1)].direction == srsenb::mac_lc_ch_cfg_t::BOTH); + TESTASSERT(ue_cfg->ue_bearers[srb_to_lcid(lte_srb::srb2)].direction == srsenb::mac_lc_ch_cfg_t::BOTH); /* Test Case: The UE receives a duplicate C-RNTI CE. Nothing should happen */ if (test_params == test_event::duplicate_crnti_ce) {