enb: remove redundant RLC/PDPC classes for NR

the RLC/PDCP entities for NR are included in the RLC/PDCP wrapper classes
and don't require their own
master
Andre Puschmann 3 years ago
parent 651a76000e
commit b134781d36

@ -20,8 +20,6 @@
#include "srsenb/hdr/stack/mac/nr/mac_nr.h"
#include "srsenb/hdr/stack/rrc/rrc_nr.h"
#include "srsenb/hdr/stack/upper/pdcp_nr.h"
#include "srsenb/hdr/stack/upper/rlc_nr.h"
#include "upper/pdcp.h"
#include "upper/rlc.h"
#include "upper/sdap.h"
@ -29,10 +27,6 @@
#include "enb_stack_base.h"
#include "srsran/interfaces/gnb_interfaces.h"
// This is needed for GW
#include "srsran/interfaces/ue_interfaces.h"
#include "srsue/hdr/stack/upper/gw.h"
namespace srsenb {
class gnb_stack_nr final : public srsenb::enb_stack_base,

@ -1,117 +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.
*
*/
#include "srsran/interfaces/gnb_interfaces.h"
#include "srsran/interfaces/ue_gw_interfaces.h"
#include "srsran/interfaces/ue_rlc_interfaces.h"
#include "srsran/upper/pdcp.h"
#include <map>
#ifndef SRSENB_PDCP_NR_H
#define SRSENB_PDCP_NR_H
namespace srsenb {
struct pdcp_nr_args_t {
std::string log_level;
uint32_t log_hex_limit;
};
class pdcp_nr : public pdcp_interface_rlc_nr, public pdcp_interface_sdap_nr, public pdcp_interface_rrc_nr
{
public:
explicit pdcp_nr(srsran::task_sched_handle task_sched_, const char* logname);
virtual ~pdcp_nr() = default;
void init(const pdcp_nr_args_t& args_,
rlc_interface_pdcp_nr* rlc_,
rrc_interface_pdcp_nr* rrc_,
sdap_interface_pdcp_nr* gtpu_);
void stop();
// pdcp_interface_rlc_nr
void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu);
void notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn);
void notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sn);
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {}
// pdcp_interface_rrc_nr
void reset(uint16_t rnti) final;
void add_user(uint16_t rnti) final;
void rem_user(uint16_t rnti) final;
void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu) final;
void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) final;
void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) final;
void enable_integrity(uint16_t rnti, uint32_t lcid) final;
void enable_encryption(uint16_t rnti, uint32_t lcid) final;
private:
class user_interface_rlc final : public srsue::rlc_interface_pdcp
{
public:
uint16_t rnti;
srsenb::rlc_interface_pdcp_nr* rlc;
// rlc_interface_pdcp_nr
void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu) final;
void discard_sdu(uint32_t lcid, uint32_t discard_sn) final;
bool rb_is_um(uint32_t lcid) final;
bool sdu_queue_is_full(uint32_t lcid) final;
};
class user_interface_sdap : public srsue::gw_interface_pdcp
{
public:
uint16_t rnti;
srsenb::sdap_interface_pdcp_nr* sdap;
// gw_interface_pdcp
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) final {}
};
class user_interface_rrc : public srsue::rrc_interface_pdcp
{
public:
uint16_t rnti;
srsenb::rrc_interface_pdcp_nr* rrc;
// rrc_interface_pdcp_nr
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;
void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu) final;
void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu) final;
void write_pdu_pcch(srsran::unique_byte_buffer_t pdu) final;
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final {}
void notify_pdcp_integrity_error(uint32_t lcid) final {}
const char* get_rb_name(uint32_t lcid) final;
};
class user_interface
{
public:
user_interface_rlc rlc_itf;
user_interface_sdap sdap_itf;
user_interface_rrc rrc_itf;
std::unique_ptr<srsran::pdcp> pdcp;
};
// args
pdcp_nr_args_t m_args = {};
rlc_interface_pdcp_nr* m_rlc = nullptr;
rrc_interface_pdcp_nr* m_rrc = nullptr;
sdap_interface_pdcp_nr* m_sdap = nullptr;
std::map<uint32_t, user_interface> users;
srsran::task_sched_handle task_sched;
srslog::basic_logger& logger;
};
} // namespace srsenb
#endif // SRSENB_PDCP_NR_H

@ -1,95 +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 SRSENB_RLC_NR_H
#define SRSENB_RLC_NR_H
#include "srsran/interfaces/gnb_interfaces.h"
#include "srsran/interfaces/gnb_mac_interfaces.h"
#include "srsran/rlc/rlc.h"
#include <map>
namespace srsenb {
typedef struct {
uint32_t lcid;
uint32_t plmn;
uint16_t mtch_stop;
uint8_t* payload;
} mch_service_t;
class rlc_nr final : public rlc_interface_mac_nr, public rlc_interface_rrc_nr, public rlc_interface_pdcp_nr
{
public:
explicit rlc_nr(const char* logname);
void init(pdcp_interface_rlc_nr* pdcp_,
rrc_interface_rlc_nr* rrc_,
mac_interface_rlc_nr* mac_,
srsran::timer_handler* timers_);
void stop();
// rlc_interface_rrc_nr
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, srsran::rlc_config_t cnfg);
void add_bearer_mrb(uint16_t rnti, uint32_t lcid);
// rlc_interface_pdcp_nr
void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu);
bool rb_is_um(uint16_t rnti, uint32_t lcid);
bool sdu_queue_is_full(uint16_t rnti, uint32_t lcid);
const char* get_rb_name(uint32_t lcid);
// rlc_interface_mac_nr
int read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
// void read_pdu_bcch_dlsch(uint32_t sib_index, uint8_t* payload);
void write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
void read_pdu_pcch(uint8_t* payload, uint32_t buffer_size);
private:
class user_interface : public srsue::pdcp_interface_rlc, public srsue::rrc_interface_rlc
{
public:
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu);
void notify_delivery(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns);
void notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns);
void write_pdu_bcch_bch(srsran::unique_byte_buffer_t sdu);
void write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t sdu);
void write_pdu_pcch(srsran::unique_byte_buffer_t sdu);
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t sdu) {}
void max_retx_attempted() final;
void protocol_failure() final;
const char* get_rb_name(uint32_t lcid) final;
uint16_t rnti;
srsenb::pdcp_interface_rlc_nr* m_pdcp = nullptr;
srsenb::rrc_interface_rlc_nr* m_rrc = nullptr;
std::unique_ptr<srsran::rlc> m_rlc;
rlc_nr* parent = nullptr;
};
// args
srsran::timer_handler* timers = nullptr;
mac_interface_rlc_nr* m_mac = nullptr;
pdcp_interface_rlc_nr* m_pdcp = nullptr;
rrc_interface_rlc_nr* m_rrc = nullptr;
srslog::basic_logger& logger;
// state
std::map<uint32_t, user_interface> users;
std::vector<mch_service_t> mch_services;
};
} // namespace srsenb
#endif // SRSENB_RLC_NR_H

@ -10,5 +10,5 @@ set(SOURCES gtpu.cc pdcp.cc rlc.cc)
add_library(srsenb_upper STATIC ${SOURCES})
target_link_libraries(srsenb_upper srsran_asn1 srsran_gtpu)
set(SOURCES pdcp_nr.cc rlc_nr.cc sdap.cc)
add_library(srsgnb_upper STATIC ${SOURCES})
set(SOURCES sdap.cc)
add_library(srsgnb_upper STATIC ${SOURCES})

@ -1,180 +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.
*
*/
#include "srsenb/hdr/stack/upper/pdcp_nr.h"
#include "srsenb/hdr/common/common_enb.h"
namespace srsenb {
pdcp_nr::pdcp_nr(srsran::task_sched_handle task_sched_, const char* logname) :
task_sched(task_sched_), logger(srslog::fetch_basic_logger(logname))
{}
void pdcp_nr::init(const pdcp_nr_args_t& args_,
rlc_interface_pdcp_nr* rlc_,
rrc_interface_pdcp_nr* rrc_,
sdap_interface_pdcp_nr* sdap_)
{
m_args = args_;
m_rlc = rlc_;
m_rrc = rrc_;
m_sdap = sdap_;
logger.set_level(srslog::str_to_basic_level(m_args.log_level));
logger.set_hex_dump_max_size(m_args.log_hex_limit);
}
void pdcp_nr::stop()
{
for (auto& user : users) {
user.second.pdcp->stop();
}
users.clear();
}
void pdcp_nr::add_user(uint16_t rnti)
{
if (users.count(rnti) == 0) {
users[rnti].pdcp.reset(new srsran::pdcp(task_sched, "PDCP"));
users[rnti].rlc_itf.rnti = rnti;
users[rnti].sdap_itf.rnti = rnti;
users[rnti].rrc_itf.rnti = rnti;
users[rnti].rlc_itf.rlc = m_rlc;
users[rnti].rrc_itf.rrc = m_rrc;
users[rnti].sdap_itf.sdap = m_sdap;
users[rnti].pdcp->init(&users[rnti].rlc_itf, &users[rnti].rrc_itf, &users[rnti].sdap_itf);
}
}
void pdcp_nr::rem_user(uint16_t rnti)
{
users.erase(rnti);
}
void pdcp_nr::add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cfg)
{
if (users.count(rnti)) {
users[rnti].pdcp->add_bearer(lcid, cfg);
}
}
void pdcp_nr::reset(uint16_t rnti)
{
if (users.count(rnti)) {
users[rnti].pdcp->reset();
}
}
void pdcp_nr::config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg)
{
if (users.count(rnti)) {
users[rnti].pdcp->config_security(lcid, sec_cfg);
}
}
void pdcp_nr::enable_integrity(uint16_t rnti, uint32_t lcid)
{
users[rnti].pdcp->enable_integrity(lcid, srsran::DIRECTION_TXRX);
}
void pdcp_nr::enable_encryption(uint16_t rnti, uint32_t lcid)
{
users[rnti].pdcp->enable_encryption(lcid, srsran::DIRECTION_TXRX);
}
void pdcp_nr::write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu)
{
if (users.count(rnti)) {
users[rnti].pdcp->write_pdu(lcid, std::move(sdu));
} else {
logger.error("Can't write PDU. RNTI=0x%X doesn't exist.", rnti);
}
}
void pdcp_nr::notify_delivery(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns)
{
if (users.count(rnti)) {
users[rnti].pdcp->notify_delivery(lcid, pdcp_sns);
} else {
logger.error("Can't notify Ack of PDU. RNTI=0x%X doesn't exist.", rnti);
}
}
void pdcp_nr::notify_failure(uint16_t rnti, uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns)
{
if (users.count(rnti)) {
users[rnti].pdcp->notify_failure(lcid, pdcp_sns);
} else {
logger.error("Can't notify Ack of PDU. RNTI=0x%X doesn't exist.", rnti);
}
}
void pdcp_nr::write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu)
{
if (users.count(rnti)) {
users[rnti].pdcp->write_sdu(lcid, std::move(sdu));
} else {
logger.error("Can't write SDU. RNTI=0x%X doesn't exist.", rnti);
}
}
void pdcp_nr::user_interface_sdap::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
{
sdap->write_pdu(rnti, lcid, std::move(pdu));
}
void pdcp_nr::user_interface_rlc::write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu)
{
rlc->write_sdu(rnti, lcid, std::move(sdu));
}
void pdcp_nr::user_interface_rlc::discard_sdu(uint32_t lcid, uint32_t discard_sn)
{
fprintf(stderr, "discard_sdu method not implemented.\n");
}
bool pdcp_nr::user_interface_rlc::rb_is_um(uint32_t lcid)
{
return rlc->rb_is_um(rnti, lcid);
}
bool pdcp_nr::user_interface_rlc::sdu_queue_is_full(uint32_t lcid)
{
return rlc->sdu_queue_is_full(rnti, lcid);
}
void pdcp_nr::user_interface_rrc::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
{
rrc->write_pdu(rnti, lcid, std::move(pdu));
}
void pdcp_nr::user_interface_rrc::write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu)
{
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void pdcp_nr::user_interface_rrc::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t pdu)
{
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void pdcp_nr::user_interface_rrc::write_pdu_pcch(srsran::unique_byte_buffer_t pdu)
{
ERROR("Error: Received PCCH from ue=%d", rnti);
}
const char* pdcp_nr::user_interface_rrc::get_rb_name(uint32_t lcid)
{
return srsenb::get_rb_name(lcid);
}
} // namespace srsenb

@ -1,224 +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.
*
*/
#include "srsenb/hdr/stack/upper/rlc_nr.h"
#include "srsran/common/common_nr.h"
namespace srsenb {
rlc_nr::rlc_nr(const char* logname) : logger(srslog::fetch_basic_logger(logname)) {}
void rlc_nr::init(pdcp_interface_rlc_nr* pdcp_,
rrc_interface_rlc_nr* rrc_,
mac_interface_rlc_nr* mac_,
srsran::timer_handler* timers_)
{
m_pdcp = pdcp_;
m_rrc = rrc_;
m_mac = mac_;
timers = timers_;
}
void rlc_nr::stop()
{
for (auto& user : users) {
user.second.m_rlc->stop();
}
users.clear();
}
void rlc_nr::add_user(uint16_t rnti)
{
if (users.count(rnti) == 0) {
user_interface user_itf;
user_itf.rnti = rnti;
user_itf.m_pdcp = m_pdcp;
user_itf.m_rrc = m_rrc;
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::nr_srb::srb0);
}
}
void rlc_nr::rem_user(uint16_t rnti)
{
if (users.count(rnti)) {
users[rnti].m_rlc->stop();
users.erase(rnti);
} else {
logger.error("Removing rnti=0x%x. Already removed", rnti);
}
}
void rlc_nr::clear_buffer(uint16_t rnti)
{
if (users.count(rnti)) {
users[rnti].m_rlc->empty_queue();
for (int i = 0; i < SRSRAN_N_RADIO_BEARERS; i++) {
m_mac->rlc_buffer_state(rnti, i, 0, 0);
}
logger.info("Cleared buffer rnti=0x%x", rnti);
}
}
void rlc_nr::add_bearer(uint16_t rnti, uint32_t lcid, srsran::rlc_config_t cnfg)
{
if (users.count(rnti)) {
users[rnti].m_rlc->add_bearer(lcid, cnfg);
}
}
void rlc_nr::add_bearer_mrb(uint16_t rnti, uint32_t lcid)
{
if (users.count(rnti)) {
users[rnti].m_rlc->add_bearer_mrb(lcid);
}
}
void rlc_nr::read_pdu_pcch(uint8_t* payload, uint32_t buffer_size)
{
m_rrc->read_pdu_pcch(payload, buffer_size);
}
int rlc_nr::read_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
{
int ret;
uint32_t tx_queue;
if (users.count(rnti)) {
if (rnti != SRSRAN_MRNTI) {
ret = users[rnti].m_rlc->read_pdu(lcid, payload, nof_bytes);
tx_queue = users[rnti].m_rlc->get_buffer_state(lcid);
} else {
ret = users[rnti].m_rlc->read_pdu_mch(lcid, payload, nof_bytes);
tx_queue = users[rnti].m_rlc->get_total_mch_buffer_state(lcid);
}
// In the eNodeB, there is no polling for buffer state from the scheduler, thus
// communicate buffer state every time a PDU is read
uint32_t retx_queue = 0;
logger.debug("Buffer state PDCP: rnti=0x%x, lcid=%d, tx_queue=%d", rnti, lcid, tx_queue);
m_mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
} else {
ret = SRSRAN_ERROR;
}
return ret;
}
void rlc_nr::write_pdu(uint16_t rnti, uint32_t lcid, uint8_t* payload, uint32_t nof_bytes)
{
if (users.count(rnti)) {
users[rnti].m_rlc->write_pdu(lcid, payload, nof_bytes);
// In the eNodeB, there is no polling for buffer state from the scheduler, thus
// communicate buffer state every time a new PDU is written
uint32_t tx_queue = users[rnti].m_rlc->get_buffer_state(lcid);
uint32_t retx_queue = 0;
logger.debug("Buffer state PDCP: rnti=0x%x, lcid=%d, tx_queue=%d", rnti, lcid, tx_queue);
m_mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
}
}
// void rlc::read_pdu_bcch_dlsch(uint32_t sib_index, uint8_t* payload)
//{
// // RLC is transparent for BCCH
// m_rrc->read_pdu_bcch_dlsch(sib_index, payload);
//}
void rlc_nr::write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu)
{
uint32_t tx_queue;
if (users.count(rnti)) {
if (rnti != SRSRAN_MRNTI) {
users[rnti].m_rlc->write_sdu(lcid, std::move(sdu));
tx_queue = users[rnti].m_rlc->get_buffer_state(lcid);
} else {
users[rnti].m_rlc->write_sdu_mch(lcid, std::move(sdu));
tx_queue = users[rnti].m_rlc->get_total_mch_buffer_state(lcid);
}
// In the eNodeB, there is no polling for buffer state from the scheduler, thus
// communicate buffer state every time a new SDU is written
uint32_t retx_queue = 0;
m_mac->rlc_buffer_state(rnti, lcid, tx_queue, retx_queue);
logger.info("Buffer state: rnti=0x%x, lcid=%d, tx_queue=%d", rnti, lcid, tx_queue);
}
}
bool rlc_nr::rb_is_um(uint16_t rnti, uint32_t lcid)
{
bool ret = false;
if (users.count(rnti)) {
ret = users[rnti].m_rlc->rb_is_um(lcid);
}
return ret;
}
bool rlc_nr::sdu_queue_is_full(uint16_t rnti, uint32_t lcid)
{
bool ret = false;
if (users.count(rnti)) {
ret = users[rnti].m_rlc->sdu_queue_is_full(lcid);
}
return ret;
}
void rlc_nr::user_interface::max_retx_attempted()
{
m_rrc->max_retx_attempted(rnti);
}
void rlc_nr::user_interface::protocol_failure()
{
m_rrc->protocol_failure(rnti);
}
void rlc_nr::user_interface::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu)
{
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));
}
}
void rlc_nr::user_interface::write_pdu_bcch_bch(srsran::unique_byte_buffer_t sdu)
{
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void rlc_nr::user_interface::write_pdu_bcch_dlsch(srsran::unique_byte_buffer_t sdu)
{
ERROR("Error: Received BCCH from ue=%d", rnti);
}
void rlc_nr::user_interface::write_pdu_pcch(srsran::unique_byte_buffer_t sdu)
{
ERROR("Error: Received PCCH from ue=%d", rnti);
}
const char* rlc_nr::user_interface::get_rb_name(uint32_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)
{
m_pdcp->notify_delivery(rnti, lcid, pdcp_sns);
}
void rlc_nr::user_interface::notify_failure(uint32_t lcid, const srsran::pdcp_sn_vector_t& pdcp_sns)
{
m_pdcp->notify_failure(rnti, lcid, pdcp_sns);
}
} // namespace srsenb
Loading…
Cancel
Save