From 58e2e5104400502f1f9d362793c4df8dc1aba470 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Thu, 4 Jul 2019 17:15:40 +0100 Subject: [PATCH] removed rlc_interfaces. The rlc_cnfg types are now part of the rrc_interface_types. Removed implicit RB initialization in the RLC. --- lib/include/srslte/asn1/rrc_asn1_utils.h | 58 +--- .../srslte/interfaces/enb_interfaces.h | 7 +- .../srslte/interfaces/rrc_interface_types.h | 262 ++++++++++++++++++ lib/include/srslte/interfaces/ue_interfaces.h | 6 +- lib/include/srslte/upper/rlc.h | 3 +- lib/include/srslte/upper/rlc_am.h | 12 +- lib/include/srslte/upper/rlc_common.h | 4 +- lib/include/srslte/upper/rlc_interface.h | 110 -------- lib/include/srslte/upper/rlc_tm.h | 2 +- lib/include/srslte/upper/rlc_um.h | 12 +- lib/src/asn1/rrc_asn1_utils.cc | 211 ++++++-------- lib/src/upper/rlc.cc | 49 +--- lib/src/upper/rlc_am.cc | 8 +- lib/src/upper/rlc_tm.cc | 13 +- lib/src/upper/rlc_um.cc | 26 +- lib/test/asn1/srslte_asn1_rrc_mcch_test.cc | 6 +- lib/test/asn1/srslte_asn1_rrc_meas_test.cc | 3 +- lib/test/upper/rlc_am_test.cc | 6 +- lib/test/upper/rlc_stress_test.cc | 11 +- lib/test/upper/rlc_um_data_test.cc | 4 +- lib/test/upper/rlc_um_test.cc | 36 +-- srsenb/hdr/stack/upper/rlc.h | 3 +- srsenb/src/CMakeLists.txt | 2 +- srsenb/src/enb_cfg_parser.cc | 3 +- srsenb/src/stack/rrc/rrc.cc | 14 +- srsenb/src/stack/upper/rlc.cc | 11 +- srsenb/test/upper/plmn_test.cc | 3 +- srsue/hdr/stack/rrc/rrc.h | 4 +- srsue/src/stack/CMakeLists.txt | 1 - srsue/src/stack/rrc/CMakeLists.txt | 3 +- srsue/src/stack/rrc/rrc.cc | 16 +- 31 files changed, 476 insertions(+), 433 deletions(-) create mode 100644 lib/include/srslte/interfaces/rrc_interface_types.h delete mode 100644 lib/include/srslte/upper/rlc_interface.h diff --git a/lib/include/srslte/asn1/rrc_asn1_utils.h b/lib/include/srslte/asn1/rrc_asn1_utils.h index f440b3f2d..566e65b8d 100644 --- a/lib/include/srslte/asn1/rrc_asn1_utils.h +++ b/lib/include/srslte/asn1/rrc_asn1_utils.h @@ -22,64 +22,36 @@ #ifndef SRSLTE_RRC_ASN1_UTILS_H #define SRSLTE_RRC_ASN1_UTILS_H -#include +#include "srslte/interfaces/rrc_interface_types.h" -// fwd decls +/************************ + * Forward declarations + ***********************/ namespace asn1 { namespace rrc { struct plmn_id_s; struct s_tmsi_s; struct rlc_cfg_c; +struct srb_to_add_mod_s; } // namespace rrc } // namespace asn1 +/************************ + * Conversion Helpers + ***********************/ namespace srslte { -bool plmn_is_valid(const asn1::rrc::plmn_id_s& asn1_type); +plmn_id_t make_plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type); +void to_asn1(asn1::rrc::plmn_id_s* asn1_type, const plmn_id_t& cfg); -struct plmn_id_t { - uint8_t mcc[3]; - uint8_t mnc[3]; - uint8_t nof_mnc_digits; +s_tmsi_t make_s_tmsi_t(const asn1::rrc::s_tmsi_s& asn1_type); +void to_asn1(asn1::rrc::s_tmsi_s* asn1_type, const s_tmsi_t& cfg); - plmn_id_t() : mcc(), mnc(), nof_mnc_digits(2) {} - explicit plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type); - void reset(); - int from_asn1(const asn1::rrc::plmn_id_s& asn1_type); - int to_asn1(asn1::rrc::plmn_id_s* asn1_type) const; - int from_number(uint16_t mcc_num, uint16_t mnc_num); - int from_string(const std::string& plmn_str); - std::string to_string() const; - bool operator==(const plmn_id_t& other); -}; - -struct s_tmsi_t { - uint8_t mmec = 0; - uint32_t m_tmsi = 0; - - s_tmsi_t() = default; - explicit s_tmsi_t(const asn1::rrc::s_tmsi_s& asn1_type); - void from_asn1(const asn1::rrc::s_tmsi_s& asn1_type); - void to_asn1(asn1::rrc::s_tmsi_s* asn1_type) const; -}; - -enum class establishment_cause_t { - emergency, - high_prio_access, - mt_access, - mo_sig, - mo_data, - delay_tolerant_access_v1020, - mo_voice_call_v1280, - spare1, - nulltype -}; -std::string to_string(const establishment_cause_t& cause); - -class srslte_rlc_config_t; -void convert_from_asn1(srslte_rlc_config_t* out, const asn1::rrc::rlc_cfg_c& asn1_type); +rlc_config_t make_rlc_config_t(const asn1::rrc::rlc_cfg_c& asn1_type); +rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_type); +void to_asn1(asn1::rrc::rlc_cfg_c* asn1_type, const rlc_config_t& cfg); } #endif // SRSLTE_RRC_ASN1_UTILS_H diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 20787c8bd..c524d5c0d 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -26,8 +26,8 @@ #include "srslte/common/common.h" #include "srslte/common/interfaces_common.h" #include "srslte/common/security.h" +#include "srslte/interfaces/rrc_interface_types.h" #include "srslte/interfaces/sched_interface.h" -#include "srslte/upper/rlc_interface.h" #include @@ -189,9 +189,8 @@ class rlc_interface_rrc public: virtual void clear_buffer(uint16_t rnti) = 0; virtual void add_user(uint16_t rnti) = 0; - virtual void rem_user(uint16_t rnti) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid) = 0; - virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_rlc_config_t cnfg) = 0; + virtual void rem_user(uint16_t rnti) = 0; + virtual void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) = 0; virtual void add_bearer_mrb(uint16_t rnti, uint32_t lcid) = 0; virtual void write_sdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t sdu) = 0; }; diff --git a/lib/include/srslte/interfaces/rrc_interface_types.h b/lib/include/srslte/interfaces/rrc_interface_types.h new file mode 100644 index 000000000..d4412bbd0 --- /dev/null +++ b/lib/include/srslte/interfaces/rrc_interface_types.h @@ -0,0 +1,262 @@ +/* + * Copyright 2013-2019 Software Radio Systems Limited + * + * This file is part of srsLTE. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#ifndef SRSLTE_RRC_INTERFACE_TYPES_H +#define SRSLTE_RRC_INTERFACE_TYPES_H + +#include "srslte/common/bcd_helpers.h" +#include "srslte/config.h" +#include + +/************************ + * Forward declarations + ***********************/ +namespace asn1 { +namespace rrc { + +struct plmn_id_s; +struct s_tmsi_s; +struct rlc_cfg_c; +struct srb_to_add_mod_s; + +} // namespace rrc +} // namespace asn1 + +/************************ + * Interface types + ***********************/ +namespace srslte { + +// helper functions +inline const char* enum_to_text(const char* const array[], uint32_t nof_types, uint32_t enum_val) +{ + return enum_val >= nof_types ? "" : array[enum_val]; +} + +template +ItemType enum_to_number(ItemType* array, uint32_t nof_types, uint32_t enum_val) +{ + return enum_val >= nof_types ? -1 : array[enum_val]; +} + +/*************************** + * PLMN ID + **************************/ + +struct plmn_id_t { + uint8_t mcc[3]; + uint8_t mnc[3]; + uint8_t nof_mnc_digits; + + plmn_id_t() : mcc(), mnc(), nof_mnc_digits(0) {} + void reset() + { + nof_mnc_digits = 0; + std::fill(&mnc[0], &mnc[3], 0); + std::fill(&mcc[0], &mcc[3], 0); + } + int from_number(uint16_t mcc_num, uint16_t mnc_num) + { + srslte::mcc_to_bytes(mcc_num, &mcc[0]); + if (not srslte::mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits)) { + reset(); + return SRSLTE_ERROR; + } + return SRSLTE_SUCCESS; + } + int from_string(const std::string& plmn_str) + { + if (plmn_str.size() < 5 or plmn_str.size() > 6) { + reset(); + return SRSLTE_ERROR; + } + uint16_t mnc_num, mcc_num; + if (not string_to_mcc(std::string(plmn_str.begin(), plmn_str.begin() + 3), &mcc_num)) { + reset(); + return SRSLTE_ERROR; + } + if (not string_to_mnc(std::string(plmn_str.begin() + 3, plmn_str.end()), &mnc_num)) { + reset(); + return SRSLTE_ERROR; + } + return from_number(mcc_num, mnc_num); + } + std::string to_string() const + { + std::string mcc_str, mnc_str; + uint16_t mnc_num, mcc_num; + bytes_to_mnc(&mnc[0], &mnc_num, nof_mnc_digits); + bytes_to_mcc(&mcc[0], &mcc_num); + mnc_to_string(mnc_num, &mnc_str); + mcc_to_string(mcc_num, &mcc_str); + return mcc_str + mnc_str; + } + bool operator==(const plmn_id_t& other) const + { + return std::equal(&mcc[0], &mcc[3], &other.mcc[0]) and nof_mnc_digits == other.nof_mnc_digits and + std::equal(&mnc[0], &mnc[nof_mnc_digits], &other.mnc[0]); + } + bool is_valid() const { return nof_mnc_digits == 2 or nof_mnc_digits == 3; } +}; + +/*************************** + * s-TMSI + **************************/ + +struct s_tmsi_t { + uint8_t mmec = 0; + uint32_t m_tmsi = 0; +}; + +/*************************** + * Establishment Cause + **************************/ + +enum class establishment_cause_t { + emergency, + high_prio_access, + mt_access, + mo_sig, + mo_data, + delay_tolerant_access_v1020, + mo_voice_call_v1280, + spare1, + nulltype +}; +inline std::string to_string(const establishment_cause_t& cause) +{ + constexpr static const char* options[] = {"emergency", + "highPriorityAccess", + "mt-Access", + "mo-Signalling", + "mo-Data", + "delayTolerantAccess-v1020", + "mo-VoiceCall-v1280", + "spare1"}; + return enum_to_text(options, (uint32_t)establishment_cause_t::nulltype, (uint32_t)cause); +} + +/*************************** + * RLC Config + **************************/ +enum class rlc_mode_t { tm, um, am, nulltype }; +inline std::string to_string(const rlc_mode_t& mode, bool long_txt = true) +{ + constexpr static const char* long_options[] = {"Transparent Mode", "Unacknowledged Mode", "Acknowledged Mode"}; + constexpr static const char* short_options[] = {"TM", "UM", "AM"}; + if (long_txt) { + return enum_to_text(long_options, (uint32_t)rlc_mode_t::nulltype, (uint32_t)mode); + } + return enum_to_text(short_options, (uint32_t)rlc_mode_t::nulltype, (uint32_t)mode); +} + +enum class rlc_umd_sn_size_t { size5bits, size10bits, nulltype }; +inline std::string to_string(const rlc_umd_sn_size_t& sn_size) +{ + constexpr static const char* options[] = {"5 bits", "10 bits"}; + return enum_to_text(options, (uint32_t)rlc_mode_t::nulltype, (uint32_t)sn_size); +} +inline uint16_t to_number(const rlc_umd_sn_size_t& sn_size) +{ + constexpr static uint16_t options[] = {5, 10}; + return enum_to_number(options, (uint32_t)rlc_mode_t::nulltype, (uint32_t)sn_size); +} + +struct rlc_am_config_t { + /**************************************************************************** + * Configurable parameters + * Ref: 3GPP TS 36.322 v10.0.0 Section 7 + ***************************************************************************/ + + // TX configs + int32_t t_poll_retx; // Poll retx timeout (ms) + int32_t poll_pdu; // Insert poll bit after this many PDUs + int32_t poll_byte; // Insert poll bit after this much data (KB) + uint32_t max_retx_thresh; // Max number of retx + + // RX configs + int32_t t_reordering; // Timer used by rx to detect PDU loss (ms) + int32_t t_status_prohibit; // Timer used by rx to prohibit tx of status PDU (ms) +}; + +struct rlc_um_config_t { + /**************************************************************************** + * Configurable parameters + * Ref: 3GPP TS 36.322 v10.0.0 Section 7 + ***************************************************************************/ + + int32_t t_reordering; // Timer used by rx to detect PDU loss (ms) + rlc_umd_sn_size_t tx_sn_field_length; // Number of bits used for tx (UL) sequence number + rlc_umd_sn_size_t rx_sn_field_length; // Number of bits used for rx (DL) sequence number + + uint32_t rx_window_size; + uint32_t rx_mod; // Rx counter modulus + uint32_t tx_mod; // Tx counter modulus + bool is_mrb; // Whether this is a multicast bearer +}; + +#define RLC_TX_QUEUE_LEN (128) + +class rlc_config_t +{ +public: + rlc_mode_t rlc_mode; + rlc_am_config_t am; + rlc_um_config_t um; + uint32_t tx_queue_length; + + rlc_config_t() : rlc_mode(rlc_mode_t::tm), am(), um(), tx_queue_length(RLC_TX_QUEUE_LEN){}; + + // Factory for MCH + static rlc_config_t mch_config() + { + rlc_config_t cfg; + cfg.rlc_mode = rlc_mode_t::um; + cfg.um.t_reordering = 45; + cfg.um.rx_sn_field_length = rlc_umd_sn_size_t::size5bits; + cfg.um.rx_window_size = 16; + cfg.um.rx_mod = 32; + cfg.um.tx_sn_field_length = rlc_umd_sn_size_t::size5bits; + cfg.um.tx_mod = 32; + cfg.um.is_mrb = true; + cfg.tx_queue_length = 1024; + return cfg; + } + static rlc_config_t srb_config(uint32_t idx) + { + if (idx == 0 or idx > 2) { + return {}; + } + // SRB1 and SRB2 are AM + rlc_config_t rlc_cfg; + rlc_cfg.rlc_mode = rlc_mode_t::am; + rlc_cfg.am.t_poll_retx = 45; + rlc_cfg.am.poll_pdu = -1; + rlc_cfg.am.poll_byte = -1; + rlc_cfg.am.max_retx_thresh = 4; + rlc_cfg.am.t_reordering = 35; + rlc_cfg.am.t_status_prohibit = 0; + return rlc_cfg; + } +}; +} // namespace srslte + +#endif // SRSLTE_RRC_INTERFACE_TYPES_H diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index d39468c09..a7ff06136 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -30,15 +30,14 @@ #include +#include "rrc_interface_types.h" #include "srslte/asn1/liblte_mme.h" #include "srslte/asn1/rrc_asn1.h" -#include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/common.h" #include "srslte/common/interfaces_common.h" #include "srslte/common/security.h" #include "srslte/phy/channel/channel.h" #include "srslte/phy/rf/rf.h" -#include "srslte/upper/rlc_interface.h" namespace srsue { @@ -279,8 +278,7 @@ public: virtual void reset() = 0; virtual void reestablish() = 0; virtual void reestablish(uint32_t lcid) = 0; - virtual void add_bearer(uint32_t lcid) = 0; - virtual void add_bearer(uint32_t lcid, srslte::srslte_rlc_config_t cnfg) = 0; + virtual void add_bearer(uint32_t lcid, srslte::rlc_config_t cnfg) = 0; virtual void add_bearer_mrb(uint32_t lcid) = 0; virtual void del_bearer(uint32_t lcid) = 0; virtual void resume_bearer(uint32_t lcid) = 0; diff --git a/lib/include/srslte/upper/rlc.h b/lib/include/srslte/upper/rlc.h index 9847a0d02..d4f1f99e3 100644 --- a/lib/include/srslte/upper/rlc.h +++ b/lib/include/srslte/upper/rlc.h @@ -76,8 +76,7 @@ public: void reestablish(uint32_t lcid); void reset(); void empty_queue(); - void add_bearer(uint32_t lcid); - void add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg); + void add_bearer(uint32_t lcid, rlc_config_t cnfg); void add_bearer_mrb(uint32_t lcid); void del_bearer(uint32_t lcid); void del_bearer_mrb(uint32_t lcid); diff --git a/lib/include/srslte/upper/rlc_am.h b/lib/include/srslte/upper/rlc_am.h index c2260ace0..1ce60d21e 100644 --- a/lib/include/srslte/upper/rlc_am.h +++ b/lib/include/srslte/upper/rlc_am.h @@ -71,7 +71,7 @@ public: srslte::mac_interface_timers* mac_timers_); ~rlc_am(); bool resume(); - bool configure(srslte_rlc_config_t cfg_); + bool configure(rlc_config_t cfg_); void reestablish(); void stop(); @@ -102,7 +102,7 @@ private: rlc_am_tx(rlc_am* parent_); ~rlc_am_tx(); - bool configure(srslte_rlc_config_t cfg_); + bool configure(rlc_config_t cfg_); void empty_queue(); void reestablish(); @@ -148,7 +148,7 @@ private: * Ref: 3GPP TS 36.322 v10.0.0 Section 7 ***************************************************************************/ - srslte_rlc_am_config_t cfg = {}; + rlc_am_config_t cfg = {}; // TX SDU buffers rlc_tx_queue tx_sdu_queue; @@ -202,7 +202,7 @@ private: rlc_am_rx(rlc_am* parent_); ~rlc_am_rx(); - bool configure(srslte_rlc_am_config_t cfg_); + bool configure(rlc_am_config_t cfg_); void reestablish(); void stop(); @@ -237,7 +237,7 @@ private: * Configurable parameters * Ref: 3GPP TS 36.322 v10.0.0 Section 7 ***************************************************************************/ - srslte_rlc_am_config_t cfg = {}; + rlc_am_config_t cfg = {}; // RX SDU buffers unique_byte_buffer_t rx_sdu; @@ -282,7 +282,7 @@ private: srsue::pdcp_interface_rlc* pdcp = nullptr; mac_interface_timers* mac_timers = nullptr; uint32_t lcid = 0; - srslte_rlc_config_t cfg = {}; + rlc_config_t cfg = {}; bool has_configuration = false; std::string rb_name; diff --git a/lib/include/srslte/upper/rlc_common.h b/lib/include/srslte/upper/rlc_common.h index 4b9dbcdb4..f3edc25d5 100644 --- a/lib/include/srslte/upper/rlc_common.h +++ b/lib/include/srslte/upper/rlc_common.h @@ -22,8 +22,6 @@ #ifndef SRSLTE_RLC_COMMON_H #define SRSLTE_RLC_COMMON_H -#include "srslte/upper/rlc_interface.h" - namespace srslte { /**************************************************************************** @@ -143,7 +141,7 @@ public: const static int RLC_BUFFER_NOF_PDU = 128; virtual ~rlc_common() {} - virtual bool configure(srslte_rlc_config_t cnfg) = 0; + virtual bool configure(rlc_config_t cnfg) = 0; virtual bool resume() = 0; virtual void stop() = 0; virtual void reestablish() = 0; diff --git a/lib/include/srslte/upper/rlc_interface.h b/lib/include/srslte/upper/rlc_interface.h deleted file mode 100644 index d8f084cf1..000000000 --- a/lib/include/srslte/upper/rlc_interface.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2013-2019 Software Radio Systems Limited - * - * This file is part of srsLTE. - * - * srsLTE is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. - * - * srsLTE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * A copy of the GNU Affero General Public License can be found in - * the LICENSE file in the top-level directory of this distribution - * and at http://www.gnu.org/licenses/. - * - */ - -#ifndef SRSLTE_RLC_INTERFACE_H -#define SRSLTE_RLC_INTERFACE_H - -#define RLC_TX_QUEUE_LEN (128) - -namespace srslte { - -typedef enum{ - RLC_MODE_TM = 0, - RLC_MODE_UM, - RLC_MODE_AM, - RLC_MODE_N_ITEMS, -}rlc_mode_t; -static const char rlc_mode_text[RLC_MODE_N_ITEMS][20] = {"Transparent Mode", - "Unacknowledged Mode", - "Acknowledged Mode"}; - -typedef enum { - RLC_UMD_SN_SIZE_5_BITS = 0, - RLC_UMD_SN_SIZE_10_BITS, - RLC_UMD_SN_SIZE_N_ITEMS, -} rlc_umd_sn_size_t; -static const char rlc_umd_sn_size_text[RLC_UMD_SN_SIZE_N_ITEMS][20] = {"5 bits", "10 bits"}; -static const uint16_t rlc_umd_sn_size_num[RLC_UMD_SN_SIZE_N_ITEMS] = {5, 10}; - -typedef struct { - /**************************************************************************** - * Configurable parameters - * Ref: 3GPP TS 36.322 v10.0.0 Section 7 - ***************************************************************************/ - - // TX configs - int32_t t_poll_retx; // Poll retx timeout (ms) - int32_t poll_pdu; // Insert poll bit after this many PDUs - int32_t poll_byte; // Insert poll bit after this much data (KB) - uint32_t max_retx_thresh; // Max number of retx - - // RX configs - int32_t t_reordering; // Timer used by rx to detect PDU loss (ms) - int32_t t_status_prohibit; // Timer used by rx to prohibit tx of status PDU (ms) -} srslte_rlc_am_config_t; - -typedef struct { - /**************************************************************************** - * Configurable parameters - * Ref: 3GPP TS 36.322 v10.0.0 Section 7 - ***************************************************************************/ - - int32_t t_reordering; // Timer used by rx to detect PDU loss (ms) - rlc_umd_sn_size_t tx_sn_field_length; // Number of bits used for tx (UL) sequence number - rlc_umd_sn_size_t rx_sn_field_length; // Number of bits used for rx (DL) sequence number - - uint32_t rx_window_size; - uint32_t rx_mod; // Rx counter modulus - uint32_t tx_mod; // Tx counter modulus - bool is_mrb; // Whether this is a multicast bearer -} srslte_rlc_um_config_t; - -class srslte_rlc_config_t -{ -public: - rlc_mode_t rlc_mode; - srslte_rlc_am_config_t am; - srslte_rlc_um_config_t um; - uint32_t tx_queue_length; - - // Default ctor - srslte_rlc_config_t() : rlc_mode(RLC_MODE_TM), am(), um(), tx_queue_length(RLC_TX_QUEUE_LEN){}; - - // Factory for MCH - static srslte_rlc_config_t mch_config() - { - srslte_rlc_config_t cfg; - cfg.rlc_mode = RLC_MODE_UM; - cfg.um.t_reordering = 45; - cfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; - cfg.um.rx_window_size = 16; - cfg.um.rx_mod = 32; - cfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; - cfg.um.tx_mod = 32; - cfg.um.is_mrb = true; - cfg.tx_queue_length = 1024; - return cfg; - } -}; - -} // namespace srslte - -#endif // SRSLTE_RLC_INTERFACE_H diff --git a/lib/include/srslte/upper/rlc_tm.h b/lib/include/srslte/upper/rlc_tm.h index c4258235e..60f2b2dcf 100644 --- a/lib/include/srslte/upper/rlc_tm.h +++ b/lib/include/srslte/upper/rlc_tm.h @@ -41,7 +41,7 @@ public: srslte::mac_interface_timers* mac_timers_, uint32_t queue_len = 16); ~rlc_tm(); - bool configure(srslte_rlc_config_t cnfg); + bool configure(rlc_config_t cnfg); bool resume(); void stop(); void reestablish(); diff --git a/lib/include/srslte/upper/rlc_um.h b/lib/include/srslte/upper/rlc_um.h index 171a404ac..eeb56782e 100644 --- a/lib/include/srslte/upper/rlc_um.h +++ b/lib/include/srslte/upper/rlc_um.h @@ -49,7 +49,7 @@ public: srsue::rrc_interface_rlc* rrc_, mac_interface_timers* mac_timers_); ~rlc_um(); - bool configure(srslte_rlc_config_t cnfg); + bool configure(rlc_config_t cnfg); bool resume(); void reestablish(); void stop(); @@ -81,7 +81,7 @@ private: public: rlc_um_tx(srslte::log* log_); ~rlc_um_tx(); - bool configure(srslte_rlc_config_t cfg, std::string rb_name); + bool configure(rlc_config_t cfg, std::string rb_name); int build_data_pdu(uint8_t *payload, uint32_t nof_bytes); void stop(); void reestablish(); @@ -102,7 +102,7 @@ private: * Configurable parameters * Ref: 3GPP TS 36.322 v10.0.0 Section 7 ***************************************************************************/ - srslte_rlc_um_config_t cfg = {}; + rlc_um_config_t cfg = {}; // TX SDU buffers rlc_tx_queue tx_sdu_queue; @@ -137,7 +137,7 @@ private: ~rlc_um_rx(); void stop(); void reestablish(); - bool configure(srslte_rlc_config_t cfg, std::string rb_name); + bool configure(rlc_config_t cfg, std::string rb_name); void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes); void reassemble_rx_sdus(); bool pdu_belongs_to_rx_sdu(); @@ -160,7 +160,7 @@ private: * Configurable parameters * Ref: 3GPP TS 36.322 v10.0.0 Section 7 ***************************************************************************/ - srslte_rlc_um_config_t cfg = {}; + rlc_um_config_t cfg = {}; // Rx window std::map rx_window; @@ -203,7 +203,7 @@ private: srsue::rrc_interface_rlc* rrc = nullptr; srslte::log* log = nullptr; uint32_t lcid = 0; - srslte_rlc_config_t cfg = {}; + rlc_config_t cfg = {}; bool has_configuration = false; std::string rb_name; byte_buffer_pool* pool = nullptr; diff --git a/lib/src/asn1/rrc_asn1_utils.cc b/lib/src/asn1/rrc_asn1_utils.cc index cde508d9d..55666717d 100644 --- a/lib/src/asn1/rrc_asn1_utils.cc +++ b/lib/src/asn1/rrc_asn1_utils.cc @@ -21,167 +21,138 @@ #include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/asn1/rrc_asn1.h" -#include "srslte/common/bcd_helpers.h" #include "srslte/config.h" -#include "srslte/upper/rlc_interface.h" #include namespace srslte { +/*************************** + * PLMN ID + **************************/ + bool plmn_is_valid(const asn1::rrc::plmn_id_s& asn1_type) { return asn1_type.mcc_present and (asn1_type.mnc.size() == 3 or asn1_type.mnc.size() == 2); } -plmn_id_t::plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type) -{ - from_asn1(asn1_type); -} - -void plmn_id_t::reset() -{ - nof_mnc_digits = 2; - std::fill(&mnc[0], &mnc[3], 3); - std::fill(&mcc[0], &mcc[3], 3); -} - -int plmn_id_t::from_asn1(const asn1::rrc::plmn_id_s& asn1_type) +plmn_id_t make_plmn_id_t(const asn1::rrc::plmn_id_s& asn1_type) { if (not plmn_is_valid(asn1_type)) { - reset(); - return SRSLTE_ERROR; + return {}; } - std::copy(&asn1_type.mcc[0], &asn1_type.mcc[3], &mcc[0]); - nof_mnc_digits = asn1_type.mnc.size(); - std::copy(&asn1_type.mnc[0], &asn1_type.mnc[nof_mnc_digits], &mnc[0]); + plmn_id_t plmn; + std::copy(&asn1_type.mcc[0], &asn1_type.mcc[3], &plmn.mcc[0]); + plmn.nof_mnc_digits = asn1_type.mnc.size(); + std::copy(&asn1_type.mnc[0], &asn1_type.mnc[plmn.nof_mnc_digits], &plmn.mnc[0]); - return SRSLTE_SUCCESS; + return plmn; } -int plmn_id_t::to_asn1(asn1::rrc::plmn_id_s* asn1_type) const +void to_asn1(asn1::rrc::plmn_id_s* asn1_type, const plmn_id_t& cfg) { asn1_type->mcc_present = true; - std::copy(&mcc[0], &mcc[3], &asn1_type->mcc[0]); - asn1_type->mnc.resize(nof_mnc_digits); - std::copy(&mnc[0], &mnc[nof_mnc_digits], &asn1_type->mnc[0]); - return SRSLTE_SUCCESS; + std::copy(&cfg.mcc[0], &cfg.mcc[3], &asn1_type->mcc[0]); + asn1_type->mnc.resize(cfg.nof_mnc_digits); + std::copy(&cfg.mnc[0], &cfg.mnc[cfg.nof_mnc_digits], &asn1_type->mnc[0]); } -int plmn_id_t::from_number(uint16_t mcc_num, uint16_t mnc_num) -{ - srslte::mcc_to_bytes(mcc_num, &mcc[0]); - if (not srslte::mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits)) { - reset(); - return SRSLTE_ERROR; - } - return SRSLTE_SUCCESS; -} +/*************************** + * s-TMSI + **************************/ -int plmn_id_t::from_string(const std::string& plmn_str) +s_tmsi_t make_s_tmsi_t(const asn1::rrc::s_tmsi_s& asn1_type) { - if (plmn_str.size() < 5 or plmn_str.size() > 6) { - reset(); - return SRSLTE_ERROR; - } - uint16_t mnc_num, mcc_num; - if (not string_to_mcc(std::string(plmn_str.begin(), plmn_str.begin() + 3), &mcc_num)) { - reset(); - return SRSLTE_ERROR; - } - if (not string_to_mnc(std::string(plmn_str.begin() + 3, plmn_str.end()), &mnc_num)) { - reset(); - return SRSLTE_ERROR; - } - if (not mcc_to_bytes(mcc_num, &mcc[0])) { - reset(); - return SRSLTE_ERROR; - } - return mnc_to_bytes(mnc_num, &mnc[0], &nof_mnc_digits) ? SRSLTE_SUCCESS : SRSLTE_ERROR; + s_tmsi_t tmsi; + tmsi.mmec = asn1_type.mmec.to_number(); + tmsi.m_tmsi = asn1_type.m_tmsi.to_number(); + return tmsi; } -std::string plmn_id_t::to_string() const +void to_asn1(asn1::rrc::s_tmsi_s* asn1_type, const s_tmsi_t& cfg) { - std::string mcc_str, mnc_str; - uint16_t mnc_num, mcc_num; - bytes_to_mnc(&mnc[0], &mnc_num, nof_mnc_digits); - bytes_to_mcc(&mcc[0], &mcc_num); - mnc_to_string(mnc_num, &mnc_str); - mcc_to_string(mcc_num, &mcc_str); - return mcc_str + mnc_str; + asn1_type->mmec.from_number(cfg.mmec); + asn1_type->m_tmsi.from_number(cfg.m_tmsi); } -bool plmn_id_t::operator==(const plmn_id_t& other) -{ - return std::equal(&mcc[0], &mcc[3], &other.mcc[0]) and nof_mnc_digits == other.nof_mnc_digits and - std::equal(&mnc[0], &mnc[nof_mnc_digits], &other.mnc[0]); -} +/*************************** + * Establishment Cause + **************************/ -s_tmsi_t::s_tmsi_t(const asn1::rrc::s_tmsi_s& asn1_type) -{ - from_asn1(asn1_type); -} +static_assert((int)establishment_cause_t::nulltype == (int)asn1::rrc::establishment_cause_opts::nulltype, + "Failed conversion of ASN1 type"); -void s_tmsi_t::from_asn1(const asn1::rrc::s_tmsi_s& asn1_type) -{ - mmec = asn1_type.mmec.to_number(); - m_tmsi = asn1_type.m_tmsi.to_number(); -} +/*************************** + * RLC Config + **************************/ -void s_tmsi_t::to_asn1(asn1::rrc::s_tmsi_s* asn1_type) const +srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::rlc_cfg_c& asn1_type) { - asn1_type->mmec.from_number(mmec); - asn1_type->m_tmsi.from_number(m_tmsi); + srslte::rlc_config_t rlc_cfg; + switch (asn1_type.type().value) { + case asn1::rrc::rlc_cfg_c::types_opts::am: + rlc_cfg.rlc_mode = rlc_mode_t::am; + rlc_cfg.am.t_poll_retx = asn1_type.am().ul_am_rlc.t_poll_retx.to_number(); + rlc_cfg.am.poll_pdu = asn1_type.am().ul_am_rlc.poll_pdu.to_number(); + rlc_cfg.am.poll_byte = asn1_type.am().ul_am_rlc.poll_byte.to_number() * 1000; // KB + rlc_cfg.am.max_retx_thresh = asn1_type.am().ul_am_rlc.max_retx_thres.to_number(); + rlc_cfg.am.t_reordering = asn1_type.am().dl_am_rlc.t_reordering.to_number(); + rlc_cfg.am.t_status_prohibit = asn1_type.am().dl_am_rlc.t_status_prohibit.to_number(); + break; + case asn1::rrc::rlc_cfg_c::types_opts::um_bi_dir: + case asn1::rrc::rlc_cfg_c::types_opts::um_uni_dir_dl: + case asn1::rrc::rlc_cfg_c::types_opts::um_uni_dir_ul: + rlc_cfg.rlc_mode = rlc_mode_t::um; + rlc_cfg.um.t_reordering = asn1_type.um_bi_dir().dl_um_rlc.t_reordering.to_number(); + rlc_cfg.um.rx_sn_field_length = (rlc_umd_sn_size_t)asn1_type.um_bi_dir().dl_um_rlc.sn_field_len.value; + rlc_cfg.um.rx_window_size = (rlc_cfg.um.rx_sn_field_length == rlc_umd_sn_size_t::size5bits) ? 16 : 512; + rlc_cfg.um.rx_mod = (rlc_cfg.um.rx_sn_field_length == rlc_umd_sn_size_t::size5bits) ? 32 : 1024; + rlc_cfg.um.tx_sn_field_length = (rlc_umd_sn_size_t)asn1_type.um_bi_dir().ul_um_rlc.sn_field_len.value; + rlc_cfg.um.tx_mod = (rlc_cfg.um.tx_sn_field_length == rlc_umd_sn_size_t::size5bits) ? 32 : 1024; + break; + default: + break; + } + return rlc_cfg; } -static_assert((int)establishment_cause_t::nulltype == (int)asn1::rrc::establishment_cause_opts::nulltype, - "Failed conversion of ASN1 type"); -std::string to_string(const establishment_cause_t& cause) +srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_type) { - asn1::rrc::establishment_cause_e asn1_cause((asn1::rrc::establishment_cause_opts::options)cause); - return asn1_cause.to_string(); + if (asn1_type.rlc_cfg.type().value == asn1::rrc::srb_to_add_mod_s::rlc_cfg_c_::types_opts::explicit_value) { + return make_rlc_config_t(asn1_type.rlc_cfg.explicit_value()); + } + if (asn1_type.srb_id <= 2) { + return rlc_config_t::srb_config(asn1_type.srb_id); + } else { + asn1::rrc::rrc_log_print( + asn1::LOG_LEVEL_ERROR, "SRB %d does not support default initialization type\n", asn1_type.srb_id); + } } -void convert_from_asn1(srslte_rlc_config_t* out, const asn1::rrc::rlc_cfg_c& asn1_type) +void to_asn1(asn1::rrc::rlc_cfg_c* asn1_type, const srslte::rlc_config_t& cfg) { - out->am = srslte_rlc_am_config_t(); - out->um = srslte_rlc_um_config_t(); - - // update RLC mode to internal mode struct - out->rlc_mode = (asn1_type.type() == asn1::rrc::rlc_cfg_c::types::am) ? RLC_MODE_AM : RLC_MODE_UM; - - switch (out->rlc_mode) { - case RLC_MODE_AM: - out->am.t_poll_retx = asn1_type.am().ul_am_rlc.t_poll_retx.to_number(); - out->am.poll_pdu = asn1_type.am().ul_am_rlc.poll_pdu.to_number(); - out->am.poll_byte = asn1_type.am().ul_am_rlc.poll_byte.to_number() * 1000; // KB - out->am.max_retx_thresh = asn1_type.am().ul_am_rlc.max_retx_thres.to_number(); - out->am.t_reordering = asn1_type.am().dl_am_rlc.t_reordering.to_number(); - out->am.t_status_prohibit = asn1_type.am().dl_am_rlc.t_status_prohibit.to_number(); - break; - case RLC_MODE_UM: - out->um.t_reordering = asn1_type.um_bi_dir().dl_um_rlc.t_reordering.to_number(); - out->um.rx_sn_field_length = (rlc_umd_sn_size_t)asn1_type.um_bi_dir().dl_um_rlc.sn_field_len.value; - out->um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == out->um.rx_sn_field_length) ? 16 : 512; - out->um.rx_mod = (RLC_UMD_SN_SIZE_5_BITS == out->um.rx_sn_field_length) ? 32 : 1024; - out->um.tx_sn_field_length = (rlc_umd_sn_size_t)asn1_type.um_bi_dir().ul_um_rlc.sn_field_len.value; - out->um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == out->um.tx_sn_field_length) ? 32 : 1024; + *asn1_type = asn1::rrc::rlc_cfg_c(); + switch (cfg.rlc_mode) { + case rlc_mode_t::um: + asn1_type->set_um_bi_dir(); + asn1::number_to_enum(asn1_type->um_bi_dir().dl_um_rlc.t_reordering, cfg.um.t_reordering); + asn1_type->um_bi_dir().dl_um_rlc.sn_field_len.value = + (asn1::rrc::sn_field_len_opts::options)cfg.um.rx_sn_field_length; + asn1_type->um_bi_dir().ul_um_rlc.sn_field_len.value = + (asn1::rrc::sn_field_len_opts::options)cfg.um.tx_sn_field_length; + case rlc_mode_t::am: + asn1_type->set_am(); + asn1::number_to_enum(asn1_type->am().ul_am_rlc.t_poll_retx, cfg.am.t_poll_retx); + asn1::number_to_enum(asn1_type->am().ul_am_rlc.poll_pdu, cfg.am.poll_pdu); + asn1::number_to_enum(asn1_type->am().ul_am_rlc.poll_byte, cfg.am.poll_byte / 1000); + asn1::number_to_enum(asn1_type->am().ul_am_rlc.max_retx_thres, cfg.am.max_retx_thresh); + asn1::number_to_enum(asn1_type->am().dl_am_rlc.t_reordering, cfg.am.t_reordering); + asn1::number_to_enum(asn1_type->am().dl_am_rlc.t_status_prohibit, cfg.am.t_status_prohibit); break; - // case asn1::rrc::rlc_cfg_c::types::um_uni_dir_ul: - // um.tx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_uni_dir_ul().ul_um_rlc.sn_field_len.value; - // um.tx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.tx_sn_field_length) ? 32 : 1024; - // break; - // case asn1::rrc::rlc_cfg_c::types::um_uni_dir_dl: - // um.t_reordering = cnfg->um_uni_dir_dl().dl_um_rlc.t_reordering.to_number(); - // um.rx_sn_field_length = (rlc_umd_sn_size_t)cnfg->um_uni_dir_dl().dl_um_rlc.sn_field_len.value; - // um.rx_window_size = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 16 : 512; - // um.rx_mod = (RLC_UMD_SN_SIZE_5_BITS == um.rx_sn_field_length) ? 32 : 1024; - // break; default: - // Handle default case + // stays TM break; } - out->tx_queue_length = RLC_TX_QUEUE_LEN; } -} // namespace \ No newline at end of file +} // namespace srslte diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 5625679cf..4b87f7eff 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -65,7 +65,7 @@ void rlc::init(srsue::pdcp_interface_rlc* pdcp_, reset_metrics(); // create default RLC_TM bearer for SRB0 - add_bearer(default_lcid, srslte_rlc_config_t()); + add_bearer(default_lcid, rlc_config_t()); } void rlc::reset_metrics() @@ -171,7 +171,7 @@ void rlc::reset() pthread_rwlock_unlock(&rwlock); // Add SRB0 again - add_bearer(default_lcid, srslte_rlc_config_t()); + add_bearer(default_lcid, rlc_config_t()); } void rlc::empty_queue() @@ -223,7 +223,7 @@ bool rlc::rb_is_um(uint32_t lcid) pthread_rwlock_rdlock(&rwlock); if (valid_lcid(lcid)) { - ret = rlc_array.at(lcid)->get_mode() == RLC_MODE_UM; + ret = rlc_array.at(lcid)->get_mode() == rlc_mode_t::um; } else { rlc_log->warning("LCID %d doesn't exist.\n", lcid); } @@ -374,34 +374,7 @@ void rlc::write_pdu_mch(uint32_t lcid, uint8_t *payload, uint32_t nof_bytes) RRC interface *******************************************************************************/ -// FIXME: Remove function to forbid implicit configuration -void rlc::add_bearer(uint32_t lcid) -{ - if (lcid > 2) { - rlc_log->error("Radio bearer %s does not support default RLC configuration.\n", rrc->get_rb_name(lcid).c_str()); - return; - } - - // No config provided - use defaults for SRB0, SRB1, and SRB2 - if (lcid == 0) { - // SRB0 is TM - add_bearer(lcid, srslte_rlc_config_t()); - } else { - // SRB1 and SRB2 are AM - srslte_rlc_config_t rlc_cfg; - rlc_cfg.rlc_mode = RLC_MODE_AM; - rlc_cfg.am.t_poll_retx = 45; - rlc_cfg.am.poll_pdu = -1; - rlc_cfg.am.poll_byte = -1; - rlc_cfg.am.max_retx_thresh = 4; - rlc_cfg.am.t_reordering = 35; - rlc_cfg.am.t_status_prohibit = 0; - add_bearer(lcid, rlc_cfg); - } -} - - -void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) +void rlc::add_bearer(uint32_t lcid, rlc_config_t cnfg) { pthread_rwlock_wrlock(&rwlock); @@ -410,13 +383,13 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) if (not valid_lcid(lcid)) { switch(cnfg.rlc_mode) { - case RLC_MODE_TM: + case rlc_mode_t::tm: rlc_entity = new rlc_tm(rlc_log, lcid, pdcp, rrc, mac_timers); break; - case RLC_MODE_AM: + case rlc_mode_t::am: rlc_entity = new rlc_am(rlc_log, lcid, pdcp, rrc, mac_timers); break; - case RLC_MODE_UM: + case rlc_mode_t::um: rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, mac_timers); break; default: @@ -425,8 +398,8 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) } // configure and add to array - if (cnfg.rlc_mode != RLC_MODE_TM) { - if (rlc_entity->configure(cnfg) == false) { + if (cnfg.rlc_mode != rlc_mode_t::tm) { + if (not rlc_entity->configure(cnfg)) { rlc_log->error("Error configuring RLC entity\n."); goto delete_and_exit; } @@ -436,7 +409,7 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg) rlc_log->error("Error inserting RLC entity in to array\n."); goto delete_and_exit; } - rlc_log->info("Added radio bearer %s in %s\n", rrc->get_rb_name(lcid).c_str(), rlc_mode_text[cnfg.rlc_mode]); + rlc_log->info("Added radio bearer %s in %s\n", rrc->get_rb_name(lcid).c_str(), to_string(cnfg.rlc_mode).c_str()); goto unlock_and_exit; } else { rlc_log->warning("Bearer %s already created.\n", rrc->get_rb_name(lcid).c_str()); @@ -460,7 +433,7 @@ void rlc::add_bearer_mrb(uint32_t lcid) if (not valid_lcid_mrb(lcid)) { rlc_entity = new rlc_um(rlc_log, lcid, pdcp, rrc, mac_timers); // configure and add to array - if (not rlc_entity->configure(srslte_rlc_config_t::mch_config())) { + if (not rlc_entity->configure(rlc_config_t::mch_config())) { rlc_log->error("Error configuring RLC entity\n."); goto delete_and_exit; } diff --git a/lib/src/upper/rlc_am.cc b/lib/src/upper/rlc_am.cc index fa1f9f024..e31a33753 100644 --- a/lib/src/upper/rlc_am.cc +++ b/lib/src/upper/rlc_am.cc @@ -71,7 +71,7 @@ bool rlc_am::resume() return true; } -bool rlc_am::configure(srslte_rlc_config_t cfg_) +bool rlc_am::configure(rlc_config_t cfg_) { // determine bearer name and configure Rx/Tx objects rb_name = rrc->get_rb_name(lcid); @@ -118,7 +118,7 @@ void rlc_am::stop() rlc_mode_t rlc_am::get_mode() { - return RLC_MODE_AM; + return rlc_mode_t::am; } uint32_t rlc_am::get_bearer() @@ -204,7 +204,7 @@ rlc_am::rlc_am_tx::~rlc_am_tx() pthread_mutex_destroy(&mutex); } -bool rlc_am::rlc_am_tx::configure(srslte_rlc_config_t cfg_) +bool rlc_am::rlc_am_tx::configure(rlc_config_t cfg_) { // TODO: add config checks cfg = cfg_.am; @@ -1152,7 +1152,7 @@ rlc_am::rlc_am_rx::~rlc_am_rx() pthread_mutex_destroy(&mutex); } -bool rlc_am::rlc_am_rx::configure(srslte_rlc_am_config_t cfg_) +bool rlc_am::rlc_am_rx::configure(rlc_am_config_t cfg_) { // TODO: add config checks cfg = cfg_; diff --git a/lib/src/upper/rlc_tm.cc b/lib/src/upper/rlc_tm.cc index c2eaad7b0..3ace9063b 100644 --- a/lib/src/upper/rlc_tm.cc +++ b/lib/src/upper/rlc_tm.cc @@ -43,7 +43,7 @@ rlc_tm::~rlc_tm() { pool = NULL; } -bool rlc_tm::configure(srslte_rlc_config_t cnfg) +bool rlc_tm::configure(rlc_config_t cnfg) { log->error("Attempted to configure TM RLC entity\n"); return true; @@ -76,7 +76,7 @@ void rlc_tm::stop() rlc_mode_t rlc_tm::get_mode() { - return RLC_MODE_TM; + return rlc_mode_t::tm; } uint32_t rlc_tm::get_bearer() @@ -160,8 +160,13 @@ int rlc_tm::read_pdu(uint8_t *payload, uint32_t nof_bytes) memcpy(payload, buf->msg, buf->N_bytes); log->debug("%s Complete SDU scheduled for tx. Stack latency: %ld us\n", rrc->get_rb_name(lcid).c_str(), buf->get_latency_us()); - log->info_hex(payload, pdu_size, "TX %s, %s PDU, queue size=%d, bytes=%d", - rrc->get_rb_name(lcid).c_str(), rlc_mode_text[RLC_MODE_TM], ul_queue.size(), ul_queue.size_bytes()); + log->info_hex(payload, + pdu_size, + "TX %s, %s PDU, queue size=%d, bytes=%d", + rrc->get_rb_name(lcid).c_str(), + srslte::to_string(rlc_mode_t::tm).c_str(), + ul_queue.size(), + ul_queue.size_bytes()); num_tx_bytes += pdu_size; return pdu_size; diff --git a/lib/src/upper/rlc_um.cc b/lib/src/upper/rlc_um.cc index cd201a7b6..a5ca951da 100644 --- a/lib/src/upper/rlc_um.cc +++ b/lib/src/upper/rlc_um.cc @@ -21,7 +21,6 @@ #include "srslte/upper/rlc_um.h" #include -#include #define RX_MOD_BASE(x) (((x)-vr_uh-cfg.rx_window_size)%cfg.rx_mod) @@ -67,7 +66,7 @@ bool rlc_um::resume() return true; } -bool rlc_um::configure(srslte_rlc_config_t cnfg_) +bool rlc_um::configure(rlc_config_t cnfg_) { // determine bearer name and configure Rx/Tx objects rb_name = get_rb_name(rrc, lcid, cnfg_.um.is_mrb); @@ -79,18 +78,17 @@ bool rlc_um::configure(srslte_rlc_config_t cnfg_) if (resume()) { log->info("%s configured in %s: t_reordering=%d ms, rx_sn_field_length=%u bits, tx_sn_field_length=%u bits\n", rb_name.c_str(), - rlc_mode_text[cnfg_.rlc_mode], + srslte::to_string(cnfg_.rlc_mode).c_str(), cfg.um.t_reordering, - rlc_umd_sn_size_num[cfg.um.rx_sn_field_length], - rlc_umd_sn_size_num[cfg.um.rx_sn_field_length]); + srslte::to_number(cfg.um.rx_sn_field_length), + srslte::to_number(cfg.um.tx_sn_field_length)); return true; } else { return false; } } - -bool rlc_um::rlc_um_rx::configure(srslte_rlc_config_t cnfg_, std::string rb_name_) +bool rlc_um::rlc_um_rx::configure(rlc_config_t cnfg_, std::string rb_name_) { cfg = cnfg_.um; @@ -140,7 +138,7 @@ void rlc_um::stop() rlc_mode_t rlc_um::get_mode() { - return RLC_MODE_UM; + return rlc_mode_t::um; } uint32_t rlc_um::get_bearer() @@ -232,8 +230,7 @@ rlc_um::rlc_um_tx::~rlc_um_tx() pthread_mutex_destroy(&mutex); } - -bool rlc_um::rlc_um_tx::configure(srslte_rlc_config_t cnfg_, std::string rb_name_) +bool rlc_um::rlc_um_tx::configure(rlc_config_t cnfg_, std::string rb_name_) { cfg = cnfg_.um; @@ -981,8 +978,7 @@ void rlc_um_read_data_pdu_header(uint8_t *payload, uint32_t nof_bytes, rlc_umd_s uint8_t ext; uint8_t *ptr = payload; // Fixed part - if(RLC_UMD_SN_SIZE_5_BITS == sn_size) - { + if (sn_size == rlc_umd_sn_size_t::size5bits) { header->fi = (rlc_fi_field_t)((*ptr >> 6) & 0x03); // 2 bits FI ext = ((*ptr >> 5) & 0x01); // 1 bit EXT header->sn = *ptr & 0x1F; // 5 bits SN @@ -1032,8 +1028,7 @@ void rlc_um_write_data_pdu_header(rlc_umd_pdu_header_t* header, byte_buffer_t* p uint8_t *ptr = pdu->msg; // Fixed part - if(RLC_UMD_SN_SIZE_5_BITS == header->sn_size) - { + if (header->sn_size == rlc_umd_sn_size_t::size5bits) { *ptr = (header->fi & 0x03) << 6; // 2 bits FI *ptr |= (ext & 0x01) << 5; // 1 bit EXT *ptr |= header->sn & 0x1F; // 5 bits SN @@ -1078,8 +1073,7 @@ void rlc_um_write_data_pdu_header(rlc_umd_pdu_header_t* header, byte_buffer_t* p uint32_t rlc_um_packed_length(rlc_umd_pdu_header_t *header) { uint32_t len = 0; - if(RLC_UMD_SN_SIZE_5_BITS == header->sn_size) - { + if (header->sn_size == rlc_umd_sn_size_t::size5bits) { len += 1; // Fixed part is 1 byte }else{ len += 2; // Fixed part is 2 bytes diff --git a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc b/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc index 175e2e216..2d3e979a0 100644 --- a/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_mcch_test.cc @@ -23,6 +23,7 @@ #include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/log_filter.h" +#include "srslte/interfaces/rrc_interface_types.h" #include using namespace asn1::rrc; @@ -85,7 +86,7 @@ int basic_test() .mbms_session_info_list_r9[0] .tmgi_r9.plmn_id_r9.explicit_value_r9() .mcc_present); - srslte::plmn_id_t plmn( + srslte::plmn_id_t plmn = srslte::make_plmn_id_t( area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); TESTASSERT(plmn.to_string() == "987654"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.service_id_r9.to_string() == @@ -108,7 +109,8 @@ int basic_test() .mbms_session_info_list_r9[0] .tmgi_r9.plmn_id_r9.explicit_value_r9() .mcc_present); - plmn.from_asn1(area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); + plmn = srslte::make_plmn_id_t( + area_cfg_r9->pmch_info_list_r9[0].mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); TESTASSERT(plmn.to_string() == "987654"); TESTASSERT(area_cfg_r9->pmch_info_list_r9[1].mbms_session_info_list_r9[0].tmgi_r9.service_id_r9.to_string() == "000002"); diff --git a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc b/lib/test/asn1/srslte_asn1_rrc_meas_test.cc index aea41f4c0..384772755 100644 --- a/lib/test/asn1/srslte_asn1_rrc_meas_test.cc +++ b/lib/test/asn1/srslte_asn1_rrc_meas_test.cc @@ -23,6 +23,7 @@ #include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/log_filter.h" +#include "srslte/interfaces/rrc_interface_types.h" #include #include @@ -76,7 +77,7 @@ int basic_test() TESTASSERT(meas_list[0].cgi_info_present); TESTASSERT(meas_list[0].cgi_info.plmn_id_list_present); TESTASSERT(meas_list[0].cgi_info.cell_global_id.plmn_id.mcc_present); - srslte::plmn_id_t plmn(meas_list[0].cgi_info.cell_global_id.plmn_id); + srslte::plmn_id_t plmn = srslte::make_plmn_id_t(meas_list[0].cgi_info.cell_global_id.plmn_id); TESTASSERT(plmn.to_string() == "89878"); TESTASSERT(meas_list[0].cgi_info.cell_global_id.cell_id.to_number() == 0x1084104); TESTASSERT(meas_list[0].cgi_info.tac.to_number() == 0x1042); diff --git a/lib/test/upper/rlc_am_test.cc b/lib/test/upper/rlc_am_test.cc index cb6eceeb6..99fa0b2f8 100644 --- a/lib/test/upper/rlc_am_test.cc +++ b/lib/test/upper/rlc_am_test.cc @@ -129,10 +129,10 @@ private: bool running; }; -srslte_rlc_config_t default_rlc_cnfg() +rlc_config_t default_rlc_cnfg() { - srslte_rlc_config_t rlc_cnfg; - rlc_cnfg.rlc_mode = RLC_MODE_AM; + rlc_config_t rlc_cnfg; + rlc_cnfg.rlc_mode = rlc_mode_t::am; rlc_cnfg.am.t_reordering = 5; rlc_cnfg.am.t_status_prohibit = 5; rlc_cnfg.am.max_retx_thresh = 4; diff --git a/lib/test/upper/rlc_stress_test.cc b/lib/test/upper/rlc_stress_test.cc index 9309bbf9a..0a2526408 100644 --- a/lib/test/upper/rlc_stress_test.cc +++ b/lib/test/upper/rlc_stress_test.cc @@ -32,7 +32,6 @@ #include #include #include -#include #define LOG_HEX_LIMIT (-1) @@ -328,10 +327,10 @@ void stress_test(stress_test_args_t args) pcap.open("rlc_stress_test.pcap", 0); } - srslte_rlc_config_t cnfg_; + rlc_config_t cnfg_; if (args.mode == "AM") { // config RLC AM bearer - cnfg_.rlc_mode = RLC_MODE_AM; + cnfg_.rlc_mode = rlc_mode_t::am; cnfg_.am.max_retx_thresh = 4; cnfg_.am.poll_byte = 25*1000; cnfg_.am.poll_pdu = 4; @@ -340,12 +339,12 @@ void stress_test(stress_test_args_t args) cnfg_.am.t_status_prohibit = 5; } else if (args.mode == "UM") { // config UM bearer - cnfg_.rlc_mode = RLC_MODE_UM; + cnfg_.rlc_mode = rlc_mode_t::um; cnfg_.um.t_reordering = 5; cnfg_.um.rx_mod = 32; - cnfg_.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg_.um.rx_sn_field_length = rlc_umd_sn_size_t::size5bits; cnfg_.um.rx_window_size = 16; - cnfg_.um.tx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg_.um.tx_sn_field_length = rlc_umd_sn_size_t::size5bits; cnfg_.um.tx_mod = 32; } else if (args.mode == "TM") { // use default LCID in TM diff --git a/lib/test/upper/rlc_um_data_test.cc b/lib/test/upper/rlc_um_data_test.cc index 710f005ca..8ee7f7604 100644 --- a/lib/test/upper/rlc_um_data_test.cc +++ b/lib/test/upper/rlc_um_data_test.cc @@ -39,7 +39,7 @@ int main(int argc, char **argv) { memcpy(b1.msg, &pdu1[0], PDU1_LEN); b1.N_bytes = PDU1_LEN; - rlc_um_read_data_pdu_header(&b1, srslte::RLC_UMD_SN_SIZE_10_BITS, &h); + rlc_um_read_data_pdu_header(&b1, srslte::rlc_umd_sn_size_t::size10bits, &h); assert(0x03 == h.fi); assert(0 == h.N_li); assert(226 == h.sn); @@ -54,7 +54,7 @@ int main(int argc, char **argv) { memcpy(b1.msg, &pdu2[0], PDU2_LEN); b1.N_bytes = PDU2_LEN; - rlc_um_read_data_pdu_header(&b1, srslte::RLC_UMD_SN_SIZE_10_BITS, &h); + rlc_um_read_data_pdu_header(&b1, srslte::rlc_umd_sn_size_t::size10bits, &h); assert(0x03 == h.fi); assert(225 == h.sn); assert(1 == h.N_li); diff --git a/lib/test/upper/rlc_um_test.cc b/lib/test/upper/rlc_um_test.cc index 7eca32096..f572128eb 100644 --- a/lib/test/upper/rlc_um_test.cc +++ b/lib/test/upper/rlc_um_test.cc @@ -109,13 +109,13 @@ int basic_test() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - srslte_rlc_config_t cnfg; - cnfg.rlc_mode = RLC_MODE_UM; + rlc_config_t cnfg; + cnfg.rlc_mode = rlc_mode_t::um; cnfg.um.t_reordering = 5; - cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.rx_sn_field_length = rlc_umd_sn_size_t::size10bits; cnfg.um.rx_window_size = 512; cnfg.um.rx_mod = 1024; - cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.tx_sn_field_length = rlc_umd_sn_size_t::size10bits; cnfg.um.tx_mod = 1024; TESTASSERT(rlc1.configure(cnfg) == true); @@ -179,13 +179,13 @@ int loss_test() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - srslte_rlc_config_t cnfg; - cnfg.rlc_mode = RLC_MODE_UM; + rlc_config_t cnfg; + cnfg.rlc_mode = rlc_mode_t::um; cnfg.um.t_reordering = 5; - cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.rx_sn_field_length = rlc_umd_sn_size_t::size10bits; cnfg.um.rx_window_size = 512; cnfg.um.rx_mod = 1024; - cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_10_BITS; + cnfg.um.tx_sn_field_length = rlc_umd_sn_size_t::size10bits; cnfg.um.tx_mod = 1024; rlc1.configure(cnfg); @@ -247,8 +247,8 @@ int basic_mbsfn_test() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - rlc1.configure(srslte_rlc_config_t::mch_config()); - rlc2.configure(srslte_rlc_config_t::mch_config()); + rlc1.configure(rlc_config_t::mch_config()); + rlc2.configure(rlc_config_t::mch_config()); tester.set_expected_sdu_len(1); @@ -319,13 +319,13 @@ int reassmble_test() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - srslte_rlc_config_t cnfg; - cnfg.rlc_mode = RLC_MODE_UM; + rlc_config_t cnfg; + cnfg.rlc_mode = rlc_mode_t::um; cnfg.um.t_reordering = 5; - cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.rx_sn_field_length = rlc_umd_sn_size_t::size5bits; cnfg.um.rx_window_size = 16; cnfg.um.rx_mod = 32; - cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.tx_sn_field_length = rlc_umd_sn_size_t::size5bits; cnfg.um.tx_mod = 32; rlc1.configure(cnfg); @@ -435,13 +435,13 @@ int reassmble_test2() rlc_um rlc1(&log1, 3, &tester, &tester, &timers); rlc_um rlc2(&log2, 3, &tester, &tester, &timers); - srslte_rlc_config_t cnfg; - cnfg.rlc_mode = RLC_MODE_UM; + rlc_config_t cnfg; + cnfg.rlc_mode = rlc_mode_t::um; cnfg.um.t_reordering = 5; - cnfg.um.rx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.rx_sn_field_length = rlc_umd_sn_size_t::size5bits; cnfg.um.rx_window_size = 16; cnfg.um.rx_mod = 32; - cnfg.um.tx_sn_field_length = RLC_UMD_SN_SIZE_5_BITS; + cnfg.um.tx_sn_field_length = rlc_umd_sn_size_t::size5bits; cnfg.um.tx_mod = 32; rlc1.configure(cnfg); diff --git a/srsenb/hdr/stack/upper/rlc.h b/srsenb/hdr/stack/upper/rlc.h index cbbe9b2a4..2a93e05e4 100644 --- a/srsenb/hdr/stack/upper/rlc.h +++ b/srsenb/hdr/stack/upper/rlc.h @@ -50,8 +50,7 @@ public: void clear_buffer(uint16_t rnti); void add_user(uint16_t rnti); void rem_user(uint16_t rnti); - void add_bearer(uint16_t rnti, uint32_t lcid); - void add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_rlc_config_t cnfg); + void add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg); void add_bearer_mrb(uint16_t rnti, uint32_t lcid); // rlc_interface_pdcp diff --git a/srsenb/src/CMakeLists.txt b/srsenb/src/CMakeLists.txt index fde7a33a2..194fe0cc8 100644 --- a/srsenb/src/CMakeLists.txt +++ b/srsenb/src/CMakeLists.txt @@ -44,7 +44,7 @@ target_link_libraries(srsenb srsenb_phy srslte_upper srslte_radio rrc_asn1 - ${CMAKE_THREAD_LIBS_INIT} + ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${SEC_LIBRARIES} ${LIBCONFIGPP_LIBRARIES} diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 22581146f..b41556f00 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -23,6 +23,7 @@ #include "srslte/srslte.h" #include "enb_cfg_parser.h" +#include "srslte/asn1/rrc_asn1_utils.h" using namespace asn1::rrc; @@ -640,7 +641,7 @@ int enb::parse_sibs(all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_config_ ERROR("Could not convert %s to a plmn_id\n", (mcc_str + mnc_str).c_str()); return -1; } - plmn.to_asn1(&cell_access->plmn_id_list[0].plmn_id); + srslte::to_asn1(&cell_access->plmn_id_list[0].plmn_id, plmn); cell_access->plmn_id_list[0].cell_reserved_for_oper = plmn_id_info_s::cell_reserved_for_oper_e_::not_reserved; sib1->cell_sel_info.q_rx_lev_min_offset = 0; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 0792d3db8..d3f13aab6 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -764,7 +764,7 @@ void rrc::configure_mbsfn_sibs(sib_type2_s* sib2, sib_type13_r9_s* sib13) pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.set_explicit_value_r9(); srslte::plmn_id_t plmn_obj; plmn_obj.from_string("00003"); - plmn_obj.to_asn1(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9()); + srslte::to_asn1(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.plmn_id_r9.explicit_value_r9(), plmn_obj); uint8_t byte[] = {0x0, 0x0, 0x0}; memcpy(&pmch_item->mbms_session_info_list_r9[0].tmgi_r9.service_id_r9[0], &byte[0], 3); @@ -1526,7 +1526,7 @@ void rrc::ue::send_connection_setup(bool is_setup) parent->mac->ue_cfg(rnti, &sched_cfg); // Configure SRB1 in RLC - parent->rlc->add_bearer(rnti, 1); + parent->rlc->add_bearer(rnti, 1, srslte::rlc_config_t::srb_config(1)); // Configure SRB1 in PDCP srslte::srslte_pdcp_config_t pdcp_cnfg; @@ -1736,7 +1736,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) parent->mac->bearer_ue_cfg(rnti, 3, &bearer_cfg); // Configure SRB2 in RLC and PDCP - parent->rlc->add_bearer(rnti, 2); + parent->rlc->add_bearer(rnti, 2, srslte::rlc_config_t::srb_config(2)); // Configure SRB2 in PDCP srslte::srslte_pdcp_config_t pdcp_cnfg; @@ -1751,9 +1751,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) parent->pdcp->enable_encryption(rnti, 2); // Configure DRB1 in RLC - srslte::srslte_rlc_config_t rlc_cfg; - srslte::convert_from_asn1(&rlc_cfg, conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].rlc_cfg); - parent->rlc->add_bearer(rnti, 3, rlc_cfg); + parent->rlc->add_bearer(rnti, 3, srslte::make_rlc_config_t(conn_reconf->rr_cfg_ded.drb_to_add_mod_list[0].rlc_cfg)); // Configure DRB1 in PDCP pdcp_cnfg.is_control = false; @@ -1820,9 +1818,7 @@ void rrc::ue::send_connection_reconf_new_bearer(LIBLTE_S1AP_E_RABTOBESETUPLISTBE parent->mac->bearer_ue_cfg(rnti, lcid, &bearer_cfg); // Configure DRB in RLC - srslte::srslte_rlc_config_t rlc_cfg; - srslte::convert_from_asn1(&rlc_cfg, drb_item.rlc_cfg); - parent->rlc->add_bearer(rnti, lcid, rlc_cfg); + parent->rlc->add_bearer(rnti, lcid, srslte::make_rlc_config_t(drb_item.rlc_cfg)); // Configure DRB in PDCP srslte::srslte_pdcp_config_t pdcp_config; diff --git a/srsenb/src/stack/upper/rlc.cc b/srsenb/src/stack/upper/rlc.cc index 252979d29..4b63db6b7 100644 --- a/srsenb/src/stack/upper/rlc.cc +++ b/srsenb/src/stack/upper/rlc.cc @@ -89,16 +89,7 @@ void rlc::clear_buffer(uint16_t rnti) pthread_rwlock_unlock(&rwlock); } -void rlc::add_bearer(uint16_t rnti, uint32_t lcid) -{ - pthread_rwlock_rdlock(&rwlock); - if (users.count(rnti)) { - users[rnti].rlc->add_bearer(lcid); - } - pthread_rwlock_unlock(&rwlock); -} - -void rlc::add_bearer(uint16_t rnti, uint32_t lcid, srslte::srslte_rlc_config_t cnfg) +void rlc::add_bearer(uint16_t rnti, uint32_t lcid, srslte::rlc_config_t cnfg) { pthread_rwlock_rdlock(&rwlock); if (users.count(rnti)) { diff --git a/srsenb/test/upper/plmn_test.cc b/srsenb/test/upper/plmn_test.cc index 2d30e4a33..82ac5ef85 100644 --- a/srsenb/test/upper/plmn_test.cc +++ b/srsenb/test/upper/plmn_test.cc @@ -23,6 +23,7 @@ #include "srslte/asn1/rrc_asn1.h" #include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" +#include "srslte/interfaces/rrc_interface_types.h" #include using namespace asn1::rrc; @@ -63,7 +64,7 @@ int rrc_plmn_test() TESTASSERT(plmn_in.mnc == plmn_out.mnc); // Test plmn --> string - srslte::plmn_id_t srsplmn_out(plmn_out); + srslte::plmn_id_t srsplmn_out = srslte::make_plmn_id_t(plmn_out); TESTASSERT(srsplmn_out.to_string() == "12345"); asn1::bit_ref bref_in(&byte_buf[0], sizeof(byte_buf)); diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 9be2a3c23..c0322287f 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -25,6 +25,7 @@ #include "pthread.h" #include "rrc_common.h" +#include "srslte/asn1/rrc_asn1_utils.h" #include "srslte/common/bcd_helpers.h" #include "srslte/common/block_queue.h" #include "srslte/common/buffer_pool.h" @@ -104,8 +105,7 @@ class cell_t srslte::plmn_id_t get_plmn(uint32_t idx) { if (idx < sib1.cell_access_related_info.plmn_id_list.size() && has_valid_sib1) { - srslte::plmn_id_t ret(sib1.cell_access_related_info.plmn_id_list[idx].plmn_id); - return ret; + return srslte::make_plmn_id_t(sib1.cell_access_related_info.plmn_id_list[idx].plmn_id); } else { return {}; } diff --git a/srsue/src/stack/CMakeLists.txt b/srsue/src/stack/CMakeLists.txt index 371ec4fe5..47a9b10b3 100644 --- a/srsue/src/stack/CMakeLists.txt +++ b/srsue/src/stack/CMakeLists.txt @@ -25,7 +25,6 @@ add_subdirectory(upper) set(SOURCES ue_stack_lte.cc) add_library(srsue_stack STATIC ${SOURCES}) -target_link_libraries(srsue_stack) install(TARGETS srsue_stack DESTINATION ${LIBRARY_DIR}) diff --git a/srsue/src/stack/rrc/CMakeLists.txt b/srsue/src/stack/rrc/CMakeLists.txt index 94e98a4a8..91fc5224f 100644 --- a/srsue/src/stack/rrc/CMakeLists.txt +++ b/srsue/src/stack/rrc/CMakeLists.txt @@ -22,4 +22,5 @@ set(SOURCES rrc.cc) add_library(srsue_rrc STATIC ${SOURCES}) -install(TARGETS srsue_rrc DESTINATION ${LIBRARY_DIR}) \ No newline at end of file +install(TARGETS srsue_rrc DESTINATION ${LIBRARY_DIR}) + diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 59ed9de7f..b3e8c6976 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -1288,7 +1288,7 @@ void rrc::send_con_request(asn1::rrc::establishment_cause_e cause) if (ue_identity_configured) { rrc_conn_req->ue_id.set_s_tmsi(); - ue_identity.to_asn1(&rrc_conn_req->ue_id.s_tmsi()); + srslte::to_asn1(&rrc_conn_req->ue_id.s_tmsi(), ue_identity); } else { rrc_conn_req->ue_id.set_random_value(); // TODO use proper RNG @@ -2087,7 +2087,7 @@ void rrc::process_pcch(unique_byte_buffer_t pdu) } for (uint32_t i = 0; i < paging->paging_record_list.size(); i++) { - s_tmsi_t s_tmsi_paged(paging->paging_record_list[i].ue_id.s_tmsi()); + s_tmsi_t s_tmsi_paged = make_s_tmsi_t(paging->paging_record_list[i].ue_id.s_tmsi()); rrc_log->info("Received paging (%d/%d) for UE %" PRIu64 ":%" PRIu64 "\n", i + 1, paging->paging_record_list.size(), @@ -3094,13 +3094,7 @@ void rrc::add_srb(srb_to_add_mod_s* srb_cnfg) // Setup RLC if (srb_cnfg->rlc_cfg_present) { - if (srb_cnfg->rlc_cfg.type() == srb_to_add_mod_s::rlc_cfg_c_::types::default_value) { - rlc->add_bearer(srb_cnfg->srb_id); - }else{ - srslte_rlc_config_t rlc_cfg; - srslte::convert_from_asn1(&rlc_cfg, srb_cnfg->rlc_cfg.explicit_value()); - rlc->add_bearer(srb_cnfg->srb_id, rlc_cfg); - } + rlc->add_bearer(srb_cnfg->srb_id, make_rlc_config_t(*srb_cnfg)); } // Setup MAC @@ -3176,9 +3170,7 @@ void rrc::add_drb(drb_to_add_mod_s* drb_cnfg) pdcp->enable_encryption(lcid); // Setup RLC - srslte_rlc_config_t rlc_cfg; - srslte::convert_from_asn1(&rlc_cfg, drb_cnfg->rlc_cfg); - rlc->add_bearer(lcid, rlc_cfg); + rlc->add_bearer(lcid, make_rlc_config_t(drb_cnfg->rlc_cfg)); // Setup MAC uint8_t log_chan_group = 0;