From e8beb2ef81fa6b72b0bb09c859facd362acd7e32 Mon Sep 17 00:00:00 2001 From: Francisco Date: Tue, 16 Nov 2021 18:09:33 +0000 Subject: [PATCH] nr,rrc: redesign fetching of asn1 obj ids for comparison and addmod/rem to asn1 lists --- .../obj_id_cmp_utils.h} | 67 +++++++---- lib/include/srsran/asn1/rrc_utils.h | 33 ------ lib/src/asn1/rrc_nr_utils.cc | 11 ++ lib/src/asn1/rrc_utils.cc | 105 +++--------------- srsenb/src/stack/rrc/rrc_bearer_cfg.cc | 2 +- srsenb/src/stack/rrc/rrc_mobility.cc | 2 +- srsenb/src/stack/rrc/ue_meas_cfg.cc | 3 +- srsenb/src/stack/rrc/ue_rr_cfg.cc | 2 +- srsenb/test/rrc/rrc_meascfg_test.cc | 2 +- srsue/src/stack/rrc/rrc_meas.cc | 4 +- 10 files changed, 80 insertions(+), 151 deletions(-) rename lib/include/srsran/{rrc/rrc_cfg_utils.h => asn1/obj_id_cmp_utils.h} (76%) diff --git a/lib/include/srsran/rrc/rrc_cfg_utils.h b/lib/include/srsran/asn1/obj_id_cmp_utils.h similarity index 76% rename from lib/include/srsran/rrc/rrc_cfg_utils.h rename to lib/include/srsran/asn1/obj_id_cmp_utils.h index 695750a2b..ccc6835cd 100644 --- a/lib/include/srsran/rrc/rrc_cfg_utils.h +++ b/lib/include/srsran/asn1/obj_id_cmp_utils.h @@ -10,18 +10,37 @@ * */ -#ifndef SRSRAN_RRC_CFG_UTILS_H -#define SRSRAN_RRC_CFG_UTILS_H +#ifndef SRSRAN_OBJ_ID_CMP_UTILS_H +#define SRSRAN_OBJ_ID_CMP_UTILS_H -#include "srsran/asn1/rrc_utils.h" #include "srsran/common/common.h" #include #include namespace srsran { -template -using rrc_obj_id_t = decltype(asn1::rrc::get_rrc_obj_id(std::declval())); +using asn1_obj_id_t = uint8_t; + +/// Template function to generically obtain id of asn1 object (e.g. srb_id of srbs, drb_id of drbs, etc.) +template +uint8_t get_asn1_obj_id(const Asn1Obj& obj); + +/// Template function to generically set id of asn1 object (e.g. srb_id of srbs, drb_id of drbs, etc.) +template +void set_asn1_obj_id(Asn1Obj& obj, uint8_t id); + +/// helper macro to help define get_asn1_obj_id and set_asn1_obj_id for specific asn1 objects +#define ASN1_OBJ_ID_DEFINE(Asn1ObjType, member) \ + template <> \ + uint8_t get_asn1_obj_id(const Asn1ObjType& obj) \ + { \ + return obj.member; \ + } \ + template <> \ + void set_asn1_obj_id(Asn1ObjType & obj, uint8_t id) \ + { \ + obj.member = id; \ + } //! Functor to compare RRC config elements (e.g. SRB/measObj/Rep) based on ID struct rrc_obj_id_cmp { @@ -29,27 +48,27 @@ struct rrc_obj_id_cmp { typename std::enable_if::value and not std::is_integral::value, bool>::type operator()(const T& lhs, const U& rhs) const { - return asn1::rrc::get_rrc_obj_id(lhs) < asn1::rrc::get_rrc_obj_id(rhs); + return get_asn1_obj_id(lhs) < get_asn1_obj_id(rhs); } template - bool operator()(const T& lhs, rrc_obj_id_t id) const + bool operator()(const T& lhs, asn1_obj_id_t id) const { - return asn1::rrc::get_rrc_obj_id(lhs) < id; + return get_asn1_obj_id(lhs) < id; } template - bool operator()(rrc_obj_id_t id, const T& rhs) const + bool operator()(asn1_obj_id_t id, const T& rhs) const { - return id < asn1::rrc::get_rrc_obj_id(rhs); + return id < get_asn1_obj_id(rhs); } }; template struct unary_rrc_obj_id { - rrc_obj_id_t id; + asn1_obj_id_t id; template explicit unary_rrc_obj_id(T id_) : id(id_) {} - bool operator()(const typename Container::value_type& e) const { return asn1::rrc::get_rrc_obj_id(e) == id; } + bool operator()(const typename Container::value_type& e) const { return get_asn1_obj_id(e) == id; } }; /// Find rrc object in list based on ID @@ -69,13 +88,13 @@ template typename Container::iterator sorted_find_rrc_obj_id(Container& c, IdType id) { auto it = std::lower_bound(c.begin(), c.end(), id, rrc_obj_id_cmp{}); - return (it == c.end() or asn1::rrc::get_rrc_obj_id(*it) != id) ? c.end() : it; + return (it == c.end() or get_asn1_obj_id(*it) != id) ? c.end() : it; } template typename Container::const_iterator sorted_find_rrc_obj_id(const Container& c, IdType id) { auto it = std::lower_bound(c.begin(), c.end(), id, rrc_obj_id_cmp{}); - return (it == c.end() or asn1::rrc::get_rrc_obj_id(*it) != id) ? c.end() : it; + return (it == c.end() or get_asn1_obj_id(*it) != id) ? c.end() : it; } template @@ -86,7 +105,7 @@ bool equal_rrc_obj_ids(const Container& c, const Container2& c2) c2.begin(), c2.end(), [](const typename Container::value_type& e, const typename Container2::value_type& e2) { - return asn1::rrc::get_rrc_obj_id(e) == asn1::rrc::get_rrc_obj_id(e2); + return get_asn1_obj_id(e) == get_asn1_obj_id(e2); }); } @@ -98,7 +117,7 @@ typename Container::iterator add_rrc_obj_id(Container& c, IdType id) if (it == c.end()) { c.push_back({}); it = c.end() - 1; - asn1::rrc::set_rrc_obj_id(*it, id); + set_asn1_obj_id(*it, id); std::sort(c.begin(), c.end(), rrc_obj_id_cmp{}); it = sorted_find_rrc_obj_id(c, id); } @@ -108,11 +127,11 @@ typename Container::iterator add_rrc_obj_id(Container& c, IdType id) template typename Container::iterator add_rrc_obj(Container& c, const typename Container::value_type& v) { - auto it = sorted_find_rrc_obj_id(c, asn1::rrc::get_rrc_obj_id(v)); + auto it = sorted_find_rrc_obj_id(c, get_asn1_obj_id(v)); if (it == c.end()) { c.push_back(v); std::sort(c.begin(), c.end(), rrc_obj_id_cmp{}); - it = sorted_find_rrc_obj_id(c, asn1::rrc::get_rrc_obj_id(v)); + it = sorted_find_rrc_obj_id(c, get_asn1_obj_id(v)); } else { *it = v; } @@ -136,21 +155,21 @@ bool rem_rrc_obj_id(Container& c, IdType id) * @return id value */ template -auto find_rrc_obj_id_gap(const Container& c) -> decltype(asn1::rrc::get_rrc_obj_id(c[0])) +auto find_rrc_obj_id_gap(const Container& c) -> decltype(get_asn1_obj_id(c[0])) { auto id_cmp_op = rrc_obj_id_cmp{}; assert(std::is_sorted(c.begin(), c.end(), id_cmp_op)); auto prev_it = c.begin(); - if (prev_it != c.end() and asn1::rrc::get_rrc_obj_id(*prev_it) == 1) { + if (prev_it != c.end() and get_asn1_obj_id(*prev_it) == 1) { auto it = prev_it; for (++it; it != c.end(); prev_it = it, ++it) { - if (asn1::rrc::get_rrc_obj_id(*it) > asn1::rrc::get_rrc_obj_id(*prev_it) + 1) { + if (get_asn1_obj_id(*it) > get_asn1_obj_id(*prev_it) + 1) { break; } } } - return (prev_it == c.end()) ? 1 : asn1::rrc::get_rrc_obj_id(*prev_it) + 1; // starts at 1. + return (prev_it == c.end()) ? 1 : get_asn1_obj_id(*prev_it) + 1; // starts at 1. } /** @@ -307,7 +326,7 @@ void compute_cfg_diff(const toAddModList& src_list, } using it_t = typename toAddModList::const_iterator; - auto rem_func = [&rem_diff_list](it_t rem_it) { rem_diff_list.push_back(asn1::rrc::get_rrc_obj_id(*rem_it)); }; + auto rem_func = [&rem_diff_list](it_t rem_it) { rem_diff_list.push_back(get_asn1_obj_id(*rem_it)); }; auto add_func = [&add_diff_list](it_t add_it) { add_diff_list.push_back(*add_it); }; auto mod_func = [&add_diff_list](it_t src_it, it_t target_it) { if (not(*src_it == *target_it)) { @@ -319,4 +338,4 @@ void compute_cfg_diff(const toAddModList& src_list, } // namespace srsran -#endif // SRSRAN_RRC_CFG_UTILS_H +#endif // SRSRAN_OBJ_ID_CMP_UTILS_H diff --git a/lib/include/srsran/asn1/rrc_utils.h b/lib/include/srsran/asn1/rrc_utils.h index 58f3d58a5..de7832f5d 100644 --- a/lib/include/srsran/asn1/rrc_utils.h +++ b/lib/include/srsran/asn1/rrc_utils.h @@ -141,37 +141,4 @@ sib13_t make_sib13(const asn1::rrc::sib_type13_r9_s& asn1_type); } // namespace srsran -/************************ - * ASN1 RRC extensions - ***********************/ -namespace asn1 { -namespace rrc { - -/************************** - * RRC Obj Id - *************************/ - -uint8_t get_rrc_obj_id(const srb_to_add_mod_s& srb); -uint8_t get_rrc_obj_id(const drb_to_add_mod_s& drb); -uint8_t get_rrc_obj_id(const cells_to_add_mod_s& obj); -uint8_t get_rrc_obj_id(const cells_to_add_mod_nr_r15_s& obj); -uint8_t get_rrc_obj_id(const black_cells_to_add_mod_s& obj); -uint8_t get_rrc_obj_id(const meas_obj_to_add_mod_s& obj); -uint8_t get_rrc_obj_id(const report_cfg_to_add_mod_s& obj); -uint8_t get_rrc_obj_id(const meas_id_to_add_mod_s& obj); -uint8_t get_rrc_obj_id(const scell_to_add_mod_r10_s& obj); - -void set_rrc_obj_id(srb_to_add_mod_s& srb, uint8_t id); -void set_rrc_obj_id(drb_to_add_mod_s& drb, uint8_t id); -void set_rrc_obj_id(cells_to_add_mod_s& obj, uint8_t id); -void set_rrc_obj_id(cells_to_add_mod_nr_r15_s& obj, uint8_t id); -void set_rrc_obj_id(black_cells_to_add_mod_s& obj, uint8_t id); -void set_rrc_obj_id(meas_obj_to_add_mod_s& obj, uint8_t id); -void set_rrc_obj_id(report_cfg_to_add_mod_s& obj, uint8_t id); -void set_rrc_obj_id(meas_id_to_add_mod_s& obj, uint8_t id); -void set_rrc_obj_id(scell_to_add_mod_r10_s& obj, uint8_t id); - -} // namespace rrc -} // namespace asn1 - #endif // SRSRAN_RRC_UTILS_H diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 9d6c02744..b44ecfc4e 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -11,6 +11,7 @@ */ #include "srsran/asn1/rrc_nr_utils.h" +#include "srsran/asn1/obj_id_cmp_utils.h" #include "srsran/asn1/rrc_nr.h" #include "srsran/common/band_helper.h" #include "srsran/config.h" @@ -1612,4 +1613,14 @@ bool fill_phy_pdcch_cfg_common(const asn1::rrc_nr::pdcch_cfg_common_s& pdcch_cfg return true; } +/************************** + * Asn1 Obj Id + *************************/ + +ASN1_OBJ_ID_DEFINE(asn1::rrc_nr::srb_to_add_mod_s, srb_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc_nr::drb_to_add_mod_s, drb_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc_nr::meas_obj_to_add_mod_s, meas_obj_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc_nr::report_cfg_to_add_mod_s, report_cfg_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc_nr::meas_id_to_add_mod_s, meas_id); + } // namespace srsran diff --git a/lib/src/asn1/rrc_utils.cc b/lib/src/asn1/rrc_utils.cc index 3296ea37b..cafe89082 100644 --- a/lib/src/asn1/rrc_utils.cc +++ b/lib/src/asn1/rrc_utils.cc @@ -11,6 +11,7 @@ */ #include "srsran/asn1/rrc_utils.h" +#include "srsran/asn1/obj_id_cmp_utils.h" #include "srsran/asn1/rrc.h" #include "srsran/config.h" #include @@ -129,12 +130,12 @@ srsran::rlc_config_t make_rlc_config_t(const asn1::rrc::rlc_cfg_c& asn1_type) srsran::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() < 0 - ? -1 - : asn1_type.am().ul_am_rlc.poll_byte.to_number() * 1000; // KB + 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() < 0 + ? -1 + : 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(); @@ -1087,88 +1088,18 @@ sib13_t make_sib13(const asn1::rrc::sib_type13_r9_s& asn1_type) return sib13; } -} // namespace srsran - -namespace asn1 { -namespace rrc { - /************************** - * RRC Obj Id + * Asn1 Obj Id *************************/ -uint8_t get_rrc_obj_id(const srb_to_add_mod_s& srb) -{ - return srb.srb_id; -} -uint8_t get_rrc_obj_id(const drb_to_add_mod_s& drb) -{ - return drb.drb_id; -} -uint8_t get_rrc_obj_id(const black_cells_to_add_mod_s& obj) -{ - return obj.cell_idx; -} -uint8_t get_rrc_obj_id(const cells_to_add_mod_s& obj) -{ - return obj.cell_idx; -} -uint8_t get_rrc_obj_id(const cells_to_add_mod_nr_r15_s& obj) -{ - return obj.cell_idx_r15; -} -uint8_t get_rrc_obj_id(const meas_obj_to_add_mod_s& obj) -{ - return obj.meas_obj_id; -} -uint8_t get_rrc_obj_id(const report_cfg_to_add_mod_s& obj) -{ - return obj.report_cfg_id; -} -uint8_t get_rrc_obj_id(const meas_id_to_add_mod_s& obj) -{ - return obj.meas_id; -} -uint8_t get_rrc_obj_id(const scell_to_add_mod_r10_s& obj) -{ - return obj.scell_idx_r10; -} +ASN1_OBJ_ID_DEFINE(asn1::rrc::srb_to_add_mod_s, srb_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc::drb_to_add_mod_s, drb_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc::black_cells_to_add_mod_s, cell_idx); +ASN1_OBJ_ID_DEFINE(asn1::rrc::cells_to_add_mod_s, cell_idx); +ASN1_OBJ_ID_DEFINE(asn1::rrc::cells_to_add_mod_nr_r15_s, cell_idx_r15); +ASN1_OBJ_ID_DEFINE(asn1::rrc::meas_obj_to_add_mod_s, meas_obj_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc::report_cfg_to_add_mod_s, report_cfg_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc::meas_id_to_add_mod_s, meas_id); +ASN1_OBJ_ID_DEFINE(asn1::rrc::scell_to_add_mod_r10_s, scell_idx_r10); -void set_rrc_obj_id(srb_to_add_mod_s& srb, uint8_t id) -{ - srb.srb_id = id; -} -void set_rrc_obj_id(drb_to_add_mod_s& drb, uint8_t id) -{ - drb.drb_id = id; -} -void set_rrc_obj_id(black_cells_to_add_mod_s& obj, uint8_t id) -{ - obj.cell_idx = id; -} -void set_rrc_obj_id(cells_to_add_mod_s& obj, uint8_t id) -{ - obj.cell_idx = id; -} -void set_rrc_obj_id(cells_to_add_mod_nr_r15_s& obj, uint8_t id) -{ - obj.cell_idx_r15 = id; -} -void set_rrc_obj_id(meas_obj_to_add_mod_s& obj, uint8_t id) -{ - obj.meas_obj_id = id; -} -void set_rrc_obj_id(report_cfg_to_add_mod_s& obj, uint8_t id) -{ - obj.report_cfg_id = id; -} -void set_rrc_obj_id(meas_id_to_add_mod_s& obj, uint8_t id) -{ - obj.meas_id = id; -} -void set_rrc_obj_id(scell_to_add_mod_r10_s& obj, uint8_t id) -{ - obj.scell_idx_r10 = id; -} - -} // namespace rrc -} // namespace asn1 +} // namespace srsran diff --git a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc index 57c7a3c70..7fd091b6c 100644 --- a/srsenb/src/stack/rrc/rrc_bearer_cfg.cc +++ b/srsenb/src/stack/rrc/rrc_bearer_cfg.cc @@ -12,8 +12,8 @@ #include "srsenb/hdr/stack/rrc/rrc_bearer_cfg.h" #include "srsenb/hdr/common/common_enb.h" +#include "srsran/asn1/obj_id_cmp_utils.h" #include "srsran/asn1/rrc_utils.h" -#include "srsran/rrc/rrc_cfg_utils.h" namespace srsenb { diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index b7db4f775..cff4df91f 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -15,6 +15,7 @@ #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srsenb/hdr/stack/rrc/ue_meas_cfg.h" #include "srsenb/hdr/stack/rrc/ue_rr_cfg.h" +#include "srsran/asn1/obj_id_cmp_utils.h" #include "srsran/asn1/rrc_utils.h" #include "srsran/common/bcd_helpers.h" #include "srsran/common/common.h" @@ -25,7 +26,6 @@ #include "srsran/interfaces/enb_pdcp_interfaces.h" #include "srsran/interfaces/enb_rlc_interfaces.h" #include "srsran/interfaces/enb_s1ap_interfaces.h" -#include "srsran/rrc/rrc_cfg_utils.h" #include #include diff --git a/srsenb/src/stack/rrc/ue_meas_cfg.cc b/srsenb/src/stack/rrc/ue_meas_cfg.cc index f5fc06d4a..dc4b54d0f 100644 --- a/srsenb/src/stack/rrc/ue_meas_cfg.cc +++ b/srsenb/src/stack/rrc/ue_meas_cfg.cc @@ -12,7 +12,8 @@ #include "srsenb/hdr/stack/rrc/ue_meas_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" -#include "srsran/rrc/rrc_cfg_utils.h" +#include "srsran/asn1/obj_id_cmp_utils.h" +#include "srsran/asn1/rrc_utils.h" using namespace asn1::rrc; diff --git a/srsenb/src/stack/rrc/ue_rr_cfg.cc b/srsenb/src/stack/rrc/ue_rr_cfg.cc index c46f3e9f4..0b9b1b616 100644 --- a/srsenb/src/stack/rrc/ue_rr_cfg.cc +++ b/srsenb/src/stack/rrc/ue_rr_cfg.cc @@ -14,8 +14,8 @@ #include "srsenb/hdr/stack/rrc/rrc_bearer_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_cell_cfg.h" #include "srsenb/hdr/stack/rrc/rrc_config.h" +#include "srsran/asn1/obj_id_cmp_utils.h" #include "srsran/asn1/rrc_utils.h" -#include "srsran/rrc/rrc_cfg_utils.h" #define SET_OPT_FIELD(fieldname, out, in) \ if (in.fieldname##_present) { \ diff --git a/srsenb/test/rrc/rrc_meascfg_test.cc b/srsenb/test/rrc/rrc_meascfg_test.cc index 4f39d1980..c5673955a 100644 --- a/srsenb/test/rrc/rrc_meascfg_test.cc +++ b/srsenb/test/rrc/rrc_meascfg_test.cc @@ -12,10 +12,10 @@ #include "srsenb/hdr/enb.h" #include "srsenb/hdr/stack/rrc/ue_meas_cfg.h" +#include "srsran/asn1/obj_id_cmp_utils.h" #include "srsran/asn1/rrc_utils.h" #include "srsran/common/test_common.h" #include "srsran/interfaces/enb_rrc_interface_types.h" -#include "srsran/rrc/rrc_cfg_utils.h" #include "test_helpers.h" using namespace asn1::rrc; diff --git a/srsue/src/stack/rrc/rrc_meas.cc b/srsue/src/stack/rrc/rrc_meas.cc index 0914a06ea..f9926e89d 100644 --- a/srsue/src/stack/rrc/rrc_meas.cc +++ b/srsue/src/stack/rrc/rrc_meas.cc @@ -11,9 +11,9 @@ */ #include "srsue/hdr/stack/rrc/rrc_meas.h" +#include "srsran/asn1/obj_id_cmp_utils.h" #include "srsran/asn1/rrc/dl_dcch_msg.h" #include "srsran/interfaces/ue_phy_interfaces.h" -#include "srsran/rrc/rrc_cfg_utils.h" #include "srsue/hdr/stack/rrc/rrc.h" /************************************************************************ @@ -403,7 +403,7 @@ void rrc::rrc_meas::var_meas_report_list::generate_report(const uint32_t measId) meas_results_s* report = &ul_dcch_msg.msg.c1().meas_report().crit_exts.c1().meas_report_r8().meas_results; - report->meas_id = (uint8_t)measId; + report->meas_id = (uint8_t)measId; report->meas_result_pcell.rsrp_result = rrc_value_to_range(quant_rsrp, serv_cell->get_rsrp()); report->meas_result_pcell.rsrq_result = rrc_value_to_range(quant_rsrq, serv_cell->get_rsrq());