Refactor srb and drb handling

master
David Rupprecht 4 years ago committed by Andre Puschmann
parent 91ff8a2e6d
commit 81ad72b0ff

@ -0,0 +1,99 @@
/**
*
* \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_COMMON_NR_H
#define SRSRAN_COMMON_NR_H
#include <array>
#include <cstdint>
namespace srsran {
// Radio Bearers
enum class nr_srb { srb0, srb1, srb2, srb3, count };
const uint32_t MAX_NR_SRB_ID = 3;
enum class nr_drb {
drb1 = 1,
drb2,
drb3,
drb4,
drb5,
drb6,
drb7,
drb8,
drb9,
drb10,
drb11,
drb12,
drb13,
drb14,
drb15,
drb16,
drb17,
drb18,
drb19,
drb20,
drb21,
drb22,
drb23,
drb24,
drb25,
drb26,
drb27,
drb28,
drb29,
invalid
};
const uint32_t MAX_NR_DRB_ID = 29;
const uint32_t MAX_NR_NOF_BEARERS = MAX_NR_DRB_ID + MAX_NR_SRB_ID;
constexpr bool is_nr_lcid(uint32_t lcid)
{
return lcid < MAX_NR_NOF_BEARERS;
}
constexpr bool is_nr_srb(uint32_t srib)
{
return srib <= MAX_NR_SRB_ID;
}
inline const char* get_srb_name(nr_srb srb_id)
{
static const char* names[] = {"SRB0", "SRB1", "SRB2", "SRB3", "invalid SRB id"};
return names[(uint32_t)(srb_id < nr_srb::count ? srb_id : nr_srb::count)];
}
constexpr uint32_t srb_to_lcid(nr_srb srb_id)
{
return static_cast<uint32_t>(srb_id);
}
constexpr nr_srb nr_lcid_to_srb(uint32_t lcid)
{
return static_cast<nr_srb>(lcid);
}
constexpr nr_drb nr_drb_id_to_drb(uint32_t drb_id)
{
return static_cast<nr_drb>(drb_id);
}
constexpr bool is_nr_drb(uint32_t drib)
{
return drib > MAX_NR_SRB_ID and is_nr_lcid(drib);
}
inline const char* get_drb_name(nr_drb drb_id)
{
static const char* names[] = {"DRB1", "DRB2", "DRB3", "DRB4", "DRB5", "DRB6", "DRB7", "DRB8",
"DRB9", "DRB10", "DRB11", "DRB12", "DRB13", "DRB14", "DRB15", "DRB16",
"DRB17", "DRB18", "DRB19", "DRB20", "DRB21", "DRB22", "DRB23", "DRB24",
"DRB25", "DRB26", "DRB27", "DRB28", "DRB29", "invalid DRB id"};
return names[(uint32_t)(drb_id < nr_drb::invalid ? drb_id : nr_drb::invalid) - 1];
}
} // namespace srsran
#endif // SRSRAN_COMMON_NR_H

@ -149,9 +149,10 @@ public:
class rrc_interface_rlc_nr
{
public:
virtual void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) = 0;
virtual void max_retx_attempted(uint16_t rnti) = 0;
virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0;
virtual void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) = 0;
virtual void max_retx_attempted(uint16_t rnti) = 0;
virtual void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) = 0;
virtual const char* get_rb_name(uint32_t lcid) = 0;
};
class rrc_interface_pdcp_nr
{

@ -1,110 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#ifndef SRSRAN_COMMON_NR_H
#define SRSRAN_COMMON_NR_H
namespace srsran {
// NR Radio Bearer Id
// maxDRB = 29
enum rb_id_nr_t {
NR_SRB0,
NR_SRB1,
NR_SRB2,
NR_SRB3,
NR_DRB1,
NR_DRB2,
NR_DRB3,
NR_DRB4,
NR_DRB5,
NR_DRB6,
NR_DRB7,
NR_DRB8,
NR_DRB9,
NR_DRB10,
NR_DRB11,
NR_DRB12,
NR_DRB13,
NR_DRB14,
NR_DRB15,
NR_DRB16,
NR_DRB17,
NR_DRB18,
NR_DRB19,
NR_DRB20,
NR_DRB21,
NR_DRB22,
NR_DRB23,
NR_DRB24,
NR_DRB25,
NR_DRB26,
NR_DRB27,
NR_DRB28,
NR_DRB29,
RB_ID_NR_N_ITEMS
};
inline const char* to_string(rb_id_nr_t rb_id)
{
const static char* names[] = {
"SRB0",
"SRB1",
"SRB2",
"SRB3",
"DRB1",
"DRB2",
"DRB3",
"DRB4",
"DRB5",
"DRB6",
"DRB7",
"DRB8",
"DRB9",
"DRB10",
"DRB11",
"DRB13",
"DRB14",
"DRB15",
"DRB16",
"DRB17",
"DRB18",
"DRB19",
"DRB20",
"DRB21",
"DRB22",
"DRB23",
"DRB24",
"DRB25",
"DRB26",
"DRB27",
"DRB28",
"DRB29",
};
return (rb_id < rb_id_nr_t::RB_ID_NR_N_ITEMS) ? names[rb_id] : "invalid bearer id";
}
inline bool is_srb(rb_id_nr_t lcid)
{
return lcid <= rb_id_nr_t::NR_SRB3;
}
inline bool is_drb(rb_id_nr_t lcid)
{
return not is_srb(lcid) and lcid <= rb_id_nr_t::RB_ID_NR_N_ITEMS;
}
inline int get_drb_id(rb_id_nr_t rb_id)
{
return is_drb(rb_id) ? (rb_id - 3) : -1;
}
} // namespace srsran
#endif // SRSRAN_NR_COMMON_INTERFACE_TYPES_H

@ -84,9 +84,9 @@ public:
// RLC interface
// TODO
void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) {}
void max_retx_attempted(uint16_t rnti) {}
void read_pdu_pcch(uint8_t* payload, uint32_t payload_size) {}
void max_retx_attempted(uint16_t rnti) {}
const char* get_rb_name(uint32_t lcid) { return "invalid"; }
// PDCP interface
void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;

@ -10,10 +10,10 @@
*
*/
#include "srsran/common/common_nr.h"
#include "srsran/asn1/rrc_nr_utils.h"
#include "srsenb/hdr/stack/rrc/rrc_nr.h"
#include "srsenb/hdr/common/common_enb.h"
#include "srsran/asn1/rrc_nr_utils.h"
#include "srsran/interfaces/nr_common_interface_types.h"
using namespace asn1::rrc_nr;
@ -312,16 +312,16 @@ void rrc_nr::get_metrics(srsenb::rrc_metrics_t& m)
void rrc_nr::handle_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu)
{
if (pdu) {
logger.info(pdu->msg, pdu->N_bytes, "Rx %s PDU", srsran::to_string(static_cast<srsran::rb_id_nr_t>(lcid)));
logger.info(pdu->msg, pdu->N_bytes, "Rx %s PDU", get_rb_name(lcid));
}
if (users.count(rnti) == 1) {
switch (static_cast<srsran::rb_id_nr_t>(lcid)) {
case srsran::rb_id_nr_t::NR_SRB0:
switch (static_cast<srsran::nr_srb>(lcid)) {
case srsran::nr_srb::srb0:
// parse_ul_ccch(rnti, std::move(pdu));
break;
case srsran::rb_id_nr_t::NR_SRB1:
case srsran::rb_id_nr_t::NR_SRB2:
case srsran::nr_srb::srb1:
case srsran::nr_srb::srb2:
// parse_ul_dcch(p.rnti, p.lcid, std::move(p.pdu));
break;
default:
@ -397,7 +397,7 @@ void rrc_nr::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg)
char buf[32] = {};
sprintf(buf, "SRB0 - rnti=0x%x", rnti);
parent->log_rrc_message(buf, Tx, pdu.get(), *dl_ccch_msg);
parent->rlc->write_sdu(rnti, srsran::NR_SRB0, std::move(pdu));
parent->rlc->write_sdu(rnti, (uint32_t)srsran::nr_srb::srb0, std::move(pdu));
}
} // namespace srsenb

@ -11,7 +11,6 @@
*/
#include "srsenb/hdr/stack/upper/pdcp_nr.h"
#include "lib/include/srsran/interfaces/nr_common_interface_types.h"
#include "srsenb/hdr/common/common_enb.h"
namespace srsenb {

@ -11,8 +11,7 @@
*/
#include "srsenb/hdr/stack/upper/rlc_nr.h"
#include "srsran/interfaces/nr_common_interface_types.h"
#include "srsran/common/common_nr.h"
namespace srsenb {
rlc_nr::rlc_nr(const char* logname) : logger(srslog::fetch_basic_logger(logname)) {}
@ -46,7 +45,7 @@ void rlc_nr::add_user(uint16_t rnti)
user_itf.parent = this;
user_itf.m_rlc.reset(new srsran::rlc(logger.id().c_str()));
users[rnti] = std::move(user_itf);
users[rnti].m_rlc->init(&users[rnti], &users[rnti], timers, (int)srsran::rb_id_nr_t::NR_SRB0);
users[rnti].m_rlc->init(&users[rnti], &users[rnti], timers, (int)srsran::nr_srb::srb0);
}
}
@ -180,7 +179,7 @@ void rlc_nr::user_interface::max_retx_attempted()
void rlc_nr::user_interface::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu)
{
if (lcid == (int)srsran::rb_id_nr_t::NR_SRB0) {
if (lcid == (int)srsran::nr_srb::srb0) {
m_rrc->write_pdu(rnti, lcid, std::move(sdu));
} else {
m_pdcp->write_pdu(rnti, lcid, std::move(sdu));
@ -204,7 +203,7 @@ void rlc_nr::user_interface::write_pdu_pcch(srsran::unique_byte_buffer_t sdu)
const char* rlc_nr::user_interface::get_rb_name(uint32_t lcid)
{
return srsran::to_string(static_cast<srsran::rb_id_nr_t>(lcid));
return m_rrc->get_rb_name(lcid);
}
void rlc_nr::user_interface::notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns)

@ -16,12 +16,12 @@
#include "srsran/asn1/rrc_nr.h"
#include "srsran/asn1/rrc_nr_utils.h"
#include "srsran/common/block_queue.h"
#include "srsran/common/common_nr.h"
#include "srsran/common/buffer_pool.h"
#include "srsran/common/stack_procedure.h"
#include "srsran/common/task_scheduler.h"
#include "srsran/interfaces/nr_common_interface_types.h"
#include "srsran/interfaces/ue_nr_interfaces.h"
#include "srsran/interfaces/ue_rrc_interfaces.h"
#include "srsran/interfaces/ue_nr_interfaces.h"
#include "srsue/hdr/stack/upper/gw.h"
namespace srsue {
@ -175,16 +175,10 @@ private:
const char* get_rb_name(uint32_t lcid) final;
typedef enum { Srb = 0, Drb } rb_type_t;
typedef struct {
uint32_t rb_id;
rb_type_t rb_type;
} rb_t;
bool add_lcid_rb(uint32_t lcid, rb_type_t rb_type, uint32_t rbid);
uint32_t get_lcid_for_rbid(uint32_t rdid);
bool add_lcid_drb(uint32_t lcid, uint32_t drb_id);
uint32_t get_lcid_for_drbid(uint32_t rdid);
std::map<uint32_t, rb_t> lcid_rb; // Map of lcid to radio bearer (type and rb id)
std::map<uint32_t, srsran::nr_drb> lcid_drb; // Map of lcid to drb
std::map<uint32_t, uint32_t> drb_eps_bearer_id; // Map of drb id to eps_bearer_id

@ -89,21 +89,14 @@ void rrc_nr::get_metrics(rrc_nr_metrics_t& m) {}
const char* rrc_nr::get_rb_name(uint32_t lcid)
{
uint32_t offset;
if (lcid_rb.find(lcid) != lcid_rb.end()) {
// Calulate offset for rb_id table
if (lcid_rb[lcid].rb_type == Srb) {
// SRB start at 0
offset = NR_SRB0 + lcid_rb[lcid].rb_id;
} else {
// DRB start at 1
offset = NR_SRB3 + lcid_rb[lcid].rb_id;
}
} else {
logger.warning("Unable to find lcid: %d. Return guessed rb name.");
offset = lcid;
if (is_nr_srb(lcid)) {
return get_srb_name(nr_lcid_to_srb(lcid));
}
return srsran::to_string((srsran::rb_id_nr_t)offset);
if (lcid_drb.find(lcid) != lcid_drb.end()) {
return get_drb_name(lcid_drb[lcid]);
}
logger.warning("Unable to find lcid: %d. Return invalid LCID");
return "invalid LCID";
}
// Timeout callback interface
@ -177,27 +170,26 @@ void rrc_nr::log_rrc_message(const std::string& source,
}
}
bool rrc_nr::add_lcid_rb(uint32_t lcid, rb_type_t rb_type, uint32_t rbid)
bool rrc_nr::add_lcid_drb(uint32_t lcid, uint32_t drb_id)
{
if (lcid_rb.find(lcid) != lcid_rb.end()) {
logger.error("Couldn't add RB to LCID (%d). RB %d already does exist.", lcid, rbid);
if (lcid_drb.find(lcid) != lcid_drb.end()) {
logger.error("Couldn't add DRB to LCID (%d). DRB %d already exists.", lcid, drb_id);
return false;
} else {
logger.info("Adding lcid %d and radio bearer ID %d with type %s ", lcid, rbid, (rb_type == Srb) ? "SRB" : "DRB");
lcid_rb[lcid].rb_id = rbid;
lcid_rb[lcid].rb_type = rb_type;
logger.info("Adding lcid %d and radio bearer ID %d", lcid, drb_id);
lcid_drb[lcid] = nr_drb_id_to_drb(drb_id);
}
return true;
}
uint32_t rrc_nr::get_lcid_for_rbid(uint32_t rb_id)
uint32_t rrc_nr::get_lcid_for_drbid(uint32_t drb_id)
{
for (auto& rb : lcid_rb) {
if (rb.second.rb_id == rb_id) {
for (auto& rb : lcid_drb) {
if (rb.second == nr_drb_id_to_drb(drb_id)) {
return rb.first;
}
}
logger.error("Couldn't find LCID for rb LCID. RB %d does exist.", rb_id);
logger.error("Couldn't find LCID for DRB. DRB %d does exist.", drb_id);
return 0;
}
@ -457,10 +449,7 @@ bool rrc_nr::apply_rlc_add_mod(const rlc_bearer_cfg_s& rlc_bearer_cfg)
if (rlc_bearer_cfg.served_radio_bearer_present == true) {
if (rlc_bearer_cfg.served_radio_bearer.type() == rlc_bearer_cfg_s::served_radio_bearer_c_::types::drb_id) {
drb_id = rlc_bearer_cfg.served_radio_bearer.drb_id();
add_lcid_rb(lc_ch_id, Drb, drb_id);
} else {
srb_id = rlc_bearer_cfg.served_radio_bearer.srb_id();
add_lcid_rb(lc_ch_id, Srb, srb_id);
add_lcid_drb(lc_ch_id, drb_id);
}
} else {
logger.warning("In RLC bearer cfg does not contain served radio bearer");
@ -1255,7 +1244,7 @@ bool rrc_nr::apply_cell_group_cfg(const cell_group_cfg_s& cell_group_cfg)
bool rrc_nr::apply_drb_release(const uint8_t drb)
{
uint32_t lcid = get_lcid_for_rbid(drb);
uint32_t lcid = get_lcid_for_drbid(drb);
if(lcid == 0){
logger.warning("Can not release bearer with lcid %d and drb %d", lcid, drb);
return false;
@ -1276,7 +1265,7 @@ bool rrc_nr::apply_drb_add_mod(const drb_to_add_mod_s& drb_cfg)
return false;
}
uint32_t lcid = get_lcid_for_rbid(drb_cfg.drb_id);
uint32_t lcid = get_lcid_for_drbid(drb_cfg.drb_id);
// Setup PDCP
if (!(drb_cfg.pdcp_cfg.drb_present == true)) {
@ -1363,7 +1352,7 @@ bool rrc_nr::apply_security_cfg(const security_cfg_s& security_cfg)
}
// Apply security config for all known NR lcids
for (auto& lcid : lcid_rb) {
for (auto& lcid : lcid_drb) {
pdcp->config_security(lcid.first, sec_cfg);
pdcp->enable_encryption(lcid.first);
}

Loading…
Cancel
Save