nr,rrc: redesign fetching of asn1 obj ids for comparison and addmod/rem to asn1 lists

master
Francisco 3 years ago committed by Francisco Paisana
parent 7f6abb8d6f
commit e8beb2ef81

@ -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 <algorithm>
#include <cassert>
namespace srsran {
template <typename rrcObj>
using rrc_obj_id_t = decltype(asn1::rrc::get_rrc_obj_id(std::declval<rrcObj>()));
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 <typename Asn1Obj>
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 <typename Asn1Obj>
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<Asn1ObjType>(const Asn1ObjType& obj) \
{ \
return obj.member; \
} \
template <> \
void set_asn1_obj_id<Asn1ObjType>(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<not std::is_integral<T>::value and not std::is_integral<U>::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 <typename T>
bool operator()(const T& lhs, rrc_obj_id_t<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 <typename T>
bool operator()(rrc_obj_id_t<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 <typename Container>
struct unary_rrc_obj_id {
rrc_obj_id_t<typename Container::value_type> id;
asn1_obj_id_t id;
template <typename T>
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, typename IdType>
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, typename IdType>
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 <typename Container, typename Container2>
@ -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>
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 <typename Container>
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

@ -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

@ -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

@ -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 <algorithm>
@ -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

@ -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 {

@ -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 <algorithm>
#include <cstdio>

@ -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;

@ -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) { \

@ -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;

@ -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"
/************************************************************************

Loading…
Cancel
Save