mirror of https://github.com/pvnis/srsRAN_4G.git
Merge branch 'next' into agpl_next
commit
34dbee4c7d
@ -0,0 +1,246 @@
|
||||
/**
|
||||
*
|
||||
* \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_INTRUSIVE_LIST_H
|
||||
#define SRSRAN_INTRUSIVE_LIST_H
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
namespace srsran {
|
||||
|
||||
struct default_intrusive_tag;
|
||||
|
||||
/// Base class of T, where T is a node of intrusive_forward_list<T>
|
||||
template <typename Tag = default_intrusive_tag>
|
||||
struct intrusive_forward_list_element {
|
||||
intrusive_forward_list_element<Tag>* next_node = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Forward linked list of pointers of type "T" that doesn't rely on allocations.
|
||||
* It leverages each node's internal pointer (thus intrusive) to store the next node of the list.
|
||||
* It supports push_front/pop_front, iteration, clear, etc.
|
||||
* @tparam T node type. It must be a subclass of intrusive_forward_list_element<Tag>
|
||||
* @tparam Tag useful to differentiate multiple intrusive lists in the same node
|
||||
*/
|
||||
template <typename T, typename Tag = default_intrusive_tag>
|
||||
class intrusive_forward_list
|
||||
{
|
||||
using node_t = intrusive_forward_list_element<Tag>;
|
||||
|
||||
template <typename U>
|
||||
class iterator_impl
|
||||
{
|
||||
using elem_t = typename std::conditional<std::is_const<U>::value, const node_t, node_t>::type;
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = U;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = U*;
|
||||
using reference = U&;
|
||||
|
||||
explicit iterator_impl(elem_t* node_ = nullptr) : node(node_) {}
|
||||
iterator_impl<U>& operator++()
|
||||
{
|
||||
node = node->next_node;
|
||||
return *this;
|
||||
}
|
||||
pointer operator->() { return static_cast<pointer>(node); }
|
||||
reference operator*() { return static_cast<reference>(*node); }
|
||||
|
||||
bool operator==(const iterator_impl<U>& other) const { return node == other.node; }
|
||||
bool operator!=(const iterator_impl<U>& other) const { return node != other.node; }
|
||||
|
||||
private:
|
||||
elem_t* node;
|
||||
};
|
||||
|
||||
public:
|
||||
using iterator = iterator_impl<T>;
|
||||
using const_iterator = iterator_impl<const T>;
|
||||
|
||||
intrusive_forward_list()
|
||||
{
|
||||
static_assert(std::is_base_of<node_t, T>::value,
|
||||
"Provided template argument T must have intrusive_forward_list_element<Tag> as base class");
|
||||
}
|
||||
intrusive_forward_list(const intrusive_forward_list&) = default;
|
||||
intrusive_forward_list(intrusive_forward_list&& other) noexcept : node(other.node) { other.node = nullptr; }
|
||||
intrusive_forward_list& operator=(const intrusive_forward_list&) = default;
|
||||
intrusive_forward_list& operator =(intrusive_forward_list&& other) noexcept
|
||||
{
|
||||
node = other.node;
|
||||
other.node = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
T& front() const { return *static_cast<T*>(node); }
|
||||
|
||||
void push_front(T* t)
|
||||
{
|
||||
node_t* new_head = static_cast<node_t*>(t);
|
||||
new_head->next_node = node;
|
||||
node = new_head;
|
||||
}
|
||||
T* pop_front()
|
||||
{
|
||||
node_t* ret = node;
|
||||
node = node->next_node;
|
||||
return static_cast<T*>(ret);
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
while (node != nullptr) {
|
||||
node_t* torem = node;
|
||||
node = node->next_node;
|
||||
torem->next_node = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const { return node == nullptr; }
|
||||
|
||||
iterator begin() { return iterator(node); }
|
||||
iterator end() { return iterator(nullptr); }
|
||||
const_iterator begin() const { return const_iterator(node); }
|
||||
const_iterator end() const { return const_iterator(nullptr); }
|
||||
|
||||
private:
|
||||
node_t* node = nullptr;
|
||||
};
|
||||
|
||||
template <typename Tag = default_intrusive_tag>
|
||||
struct intrusive_double_linked_list_element {
|
||||
intrusive_double_linked_list_element<Tag>* next_node = nullptr;
|
||||
intrusive_double_linked_list_element<Tag>* prev_node = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Double Linked List of pointers of type "T" that doesn't rely on allocations.
|
||||
* Instead, it leverages T's internal pointers to store the next and previous nodes
|
||||
* @tparam T node type. Must be a subclass of intrusive_double_linked_list_element<Tag>
|
||||
* @tparam Tag tag of nodes. Useful to differentiate separate intrusive lists inside the same T node
|
||||
*/
|
||||
template <typename T, typename Tag = default_intrusive_tag>
|
||||
class intrusive_double_linked_list
|
||||
{
|
||||
using node_t = intrusive_double_linked_list_element<Tag>;
|
||||
|
||||
template <typename U>
|
||||
class iterator_impl
|
||||
{
|
||||
using elem_t = typename std::conditional<std::is_const<U>::value, const node_t, node_t>::type;
|
||||
|
||||
public:
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
using value_type = U;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = U*;
|
||||
using reference = U&;
|
||||
|
||||
explicit iterator_impl(elem_t* node_ = nullptr) : node(node_) {}
|
||||
iterator_impl<U>& operator++()
|
||||
{
|
||||
node = node->next_node;
|
||||
return *this;
|
||||
}
|
||||
iterator_impl<U>& operator--()
|
||||
{
|
||||
node = node->prev_node;
|
||||
return *this;
|
||||
}
|
||||
pointer operator->() { return static_cast<pointer>(node); }
|
||||
reference operator*() { return static_cast<reference>(*node); }
|
||||
|
||||
bool operator==(const iterator_impl<U>& other) const { return node == other.node; }
|
||||
bool operator!=(const iterator_impl<U>& other) const { return node != other.node; }
|
||||
|
||||
private:
|
||||
elem_t* node;
|
||||
};
|
||||
|
||||
public:
|
||||
using iterator = iterator_impl<T>;
|
||||
using const_iterator = iterator_impl<const T>;
|
||||
|
||||
intrusive_double_linked_list()
|
||||
{
|
||||
static_assert(std::is_base_of<node_t, T>::value,
|
||||
"Provided template argument T must have intrusive_forward_list_element<Tag> as base class");
|
||||
}
|
||||
intrusive_double_linked_list(const intrusive_double_linked_list&) = default;
|
||||
intrusive_double_linked_list(intrusive_double_linked_list&& other) noexcept : node(other.node)
|
||||
{
|
||||
other.node = nullptr;
|
||||
}
|
||||
intrusive_double_linked_list& operator=(const intrusive_double_linked_list&) = default;
|
||||
intrusive_double_linked_list& operator=(intrusive_double_linked_list&& other) noexcept
|
||||
{
|
||||
node = other.node;
|
||||
other.node = nullptr;
|
||||
return *this;
|
||||
}
|
||||
~intrusive_double_linked_list() { clear(); }
|
||||
|
||||
T& front() const { return *static_cast<T*>(node); }
|
||||
|
||||
void push_front(T* t)
|
||||
{
|
||||
node_t* new_head = static_cast<node_t*>(t);
|
||||
new_head->prev_node = nullptr;
|
||||
new_head->next_node = node;
|
||||
if (node != nullptr) {
|
||||
node->prev_node = new_head;
|
||||
}
|
||||
node = new_head;
|
||||
}
|
||||
void pop(T* t)
|
||||
{
|
||||
node_t* to_rem = static_cast<node_t*>(t);
|
||||
if (to_rem == node) {
|
||||
node = to_rem->next_node;
|
||||
}
|
||||
if (to_rem->prev_node != nullptr) {
|
||||
to_rem->prev_node->next_node = to_rem->next_node;
|
||||
}
|
||||
if (to_rem->next_node != nullptr) {
|
||||
to_rem->next_node->prev_node = to_rem->prev_node;
|
||||
}
|
||||
to_rem->next_node = nullptr;
|
||||
to_rem->prev_node = nullptr;
|
||||
}
|
||||
void pop_front() { pop(static_cast<T*>(node)); }
|
||||
void clear()
|
||||
{
|
||||
while (node != nullptr) {
|
||||
node_t* torem = node;
|
||||
node = node->next_node;
|
||||
torem->next_node = nullptr;
|
||||
torem->prev_node = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const { return node == nullptr; }
|
||||
|
||||
iterator begin() { return iterator(node); }
|
||||
iterator end() { return iterator(nullptr); }
|
||||
const_iterator begin() const { return const_iterator(node); }
|
||||
const_iterator end() const { return const_iterator(nullptr); }
|
||||
|
||||
private:
|
||||
node_t* node = nullptr;
|
||||
};
|
||||
|
||||
} // namespace srsran
|
||||
|
||||
#endif // SRSRAN_INTRUSIVE_LIST_H
|
@ -0,0 +1,91 @@
|
||||
/**
|
||||
*
|
||||
* \section COPYRIGHT
|
||||
*
|
||||
* Copyright 2012-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_LTE_COMMON_H
|
||||
#define SRSRAN_LTE_COMMON_H
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
namespace srsran {
|
||||
|
||||
// Cell nof PRBs
|
||||
const std::array<uint32_t, 6> lte_cell_nof_prbs = {6, 15, 25, 50, 75, 100};
|
||||
inline uint32_t lte_cell_nof_prb_to_index(uint32_t nof_prb)
|
||||
{
|
||||
switch (nof_prb) {
|
||||
case 6:
|
||||
return 0;
|
||||
case 15:
|
||||
return 1;
|
||||
case 25:
|
||||
return 2;
|
||||
case 50:
|
||||
return 3;
|
||||
case 75:
|
||||
return 4;
|
||||
case 100:
|
||||
return 5;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
inline bool is_lte_cell_nof_prb(uint32_t nof_prb)
|
||||
{
|
||||
return lte_cell_nof_prb_to_index(nof_prb) < lte_cell_nof_prbs.size();
|
||||
}
|
||||
|
||||
// Radio Bearers
|
||||
enum class lte_srb { srb0, srb1, srb2, count };
|
||||
const uint32_t MAX_LTE_SRB_ID = 2;
|
||||
enum class lte_drb { drb1 = 1, drb2, drb3, drb4, drb5, drb6, drb7, drb8, drb9, drb10, drb11, invalid };
|
||||
const uint32_t MAX_LTE_DRB_ID = 11;
|
||||
const uint32_t MAX_NOF_BEARERS = 14;
|
||||
|
||||
constexpr bool is_lte_rb(uint32_t lcid)
|
||||
{
|
||||
return lcid < MAX_NOF_BEARERS;
|
||||
}
|
||||
|
||||
constexpr bool is_lte_srb(uint32_t lcid)
|
||||
{
|
||||
return lcid <= MAX_LTE_SRB_ID;
|
||||
}
|
||||
inline const char* get_srb_name(lte_srb srb_id)
|
||||
{
|
||||
static const char* names[] = {"SRB0", "SRB1", "SRB2", "invalid SRB id"};
|
||||
return names[(uint32_t)(srb_id < lte_srb::count ? srb_id : lte_srb::count)];
|
||||
}
|
||||
constexpr uint32_t srb_to_lcid(lte_srb srb_id)
|
||||
{
|
||||
return static_cast<uint32_t>(srb_id);
|
||||
}
|
||||
constexpr lte_srb lte_lcid_to_srb(uint32_t lcid)
|
||||
{
|
||||
return static_cast<lte_srb>(lcid);
|
||||
}
|
||||
|
||||
constexpr bool is_lte_drb(uint32_t lcid)
|
||||
{
|
||||
return lcid > MAX_LTE_SRB_ID and is_lte_rb(lcid);
|
||||
}
|
||||
inline const char* get_drb_name(lte_drb drb_id)
|
||||
{
|
||||
static const char* names[] = {
|
||||
"DRB1", "DRB2", "DRB3", "DRB4", "DRB5", "DRB6", "DRB7", "DRB8", "DRB9", "DRB10", "DRB11", "invalid DRB id"};
|
||||
return names[(uint32_t)(drb_id < lte_drb::invalid ? drb_id : lte_drb::invalid) - 1];
|
||||
}
|
||||
|
||||
} // namespace srsran
|
||||
|
||||
#endif // SRSRAN_LTE_COMMON_H
|
@ -0,0 +1,47 @@
|
||||
/**
|
||||
*
|
||||
* \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 "srsran/asn1/s1ap_utils.h"
|
||||
#include "srsran/asn1/s1ap.h"
|
||||
|
||||
namespace asn1 {
|
||||
namespace s1ap {
|
||||
|
||||
template <>
|
||||
uint32_t get_obj_id<erab_item_s>(const erab_item_s& obj)
|
||||
{
|
||||
return obj.erab_id;
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t get_obj_id<protocol_ie_single_container_s<erab_to_be_setup_item_ctxt_su_req_ies_o> >(
|
||||
const protocol_ie_single_container_s<erab_to_be_setup_item_ctxt_su_req_ies_o>& obj)
|
||||
{
|
||||
return obj.value.erab_to_be_setup_item_ctxt_su_req().erab_id;
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t get_obj_id<protocol_ie_single_container_s<erab_to_be_setup_item_bearer_su_req_ies_o> >(
|
||||
const protocol_ie_single_container_s<erab_to_be_setup_item_bearer_su_req_ies_o>& obj)
|
||||
{
|
||||
return obj.value.erab_to_be_setup_item_bearer_su_req().erab_id;
|
||||
}
|
||||
|
||||
template <>
|
||||
uint32_t get_obj_id<protocol_ie_single_container_s<erab_to_be_modified_item_bearer_mod_req_ies_o> >(
|
||||
const protocol_ie_single_container_s<erab_to_be_modified_item_bearer_mod_req_ies_o>& obj)
|
||||
{
|
||||
return obj.value.erab_to_be_modified_item_bearer_mod_req().erab_id;
|
||||
}
|
||||
|
||||
} // namespace s1ap
|
||||
} // namespace asn1
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue