nr,gnb,stack: use common gtpu_pdcp_adapter class for both NSA and SA cases

master
Francisco 3 years ago committed by Francisco Paisana
parent 123d79724d
commit 74fda904ac

@ -0,0 +1,78 @@
/**
*
* \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_GTPU_PDCP_ADAPTER_H
#define SRSRAN_GTPU_PDCP_ADAPTER_H
#include "srsran/common/bearer_manager.h"
#include "srsran/interfaces/enb_gtpu_interfaces.h"
#include "srsran/srslog/logger.h"
namespace srsenb {
class gtpu_pdcp_adapter final : public gtpu_interface_pdcp, public pdcp_interface_gtpu
{
public:
gtpu_pdcp_adapter(srslog::basic_logger& logger_,
pdcp_interface_gtpu* pdcp_lte,
pdcp_interface_gtpu* pdcp_nr,
gtpu* gtpu_,
enb_bearer_manager& bearers_) :
logger(logger_), pdcp_lte_obj(pdcp_lte), pdcp_nr_obj(pdcp_nr), gtpu_obj(gtpu_), bearers(&bearers_)
{}
/// Converts LCID to EPS-BearerID and sends corresponding PDU to GTPU
void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) override
{
auto bearer = bearers->get_lcid_bearer(rnti, lcid);
if (not bearer.is_valid()) {
logger.error("Bearer rnti=0x%x, lcid=%d not found", rnti, lcid);
return;
}
gtpu_obj->write_pdu(rnti, bearer.eps_bearer_id, std::move(pdu));
}
void write_sdu(uint16_t rnti, uint32_t eps_bearer_id, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) override
{
auto bearer = bearers->get_radio_bearer(rnti, eps_bearer_id);
// route SDU to PDCP entity
if (bearer.rat == srsran::srsran_rat_t::lte) {
pdcp_lte_obj->write_sdu(rnti, bearer.lcid, std::move(sdu), pdcp_sn);
} else if (bearer.rat == srsran::srsran_rat_t::nr) {
pdcp_nr_obj->write_sdu(rnti, bearer.lcid, std::move(sdu), pdcp_sn);
} else {
logger.warning("Can't deliver SDU for EPS bearer %d. Dropping it.", eps_bearer_id);
}
}
std::map<uint32_t, srsran::unique_byte_buffer_t> get_buffered_pdus(uint16_t rnti, uint32_t eps_bearer_id) override
{
auto bearer = bearers->get_radio_bearer(rnti, eps_bearer_id);
// route SDU to PDCP entity
if (bearer.rat == srsran::srsran_rat_t::lte) {
return pdcp_lte_obj->get_buffered_pdus(rnti, bearer.lcid);
} else if (bearer.rat == srsran::srsran_rat_t::nr) {
return pdcp_nr_obj->get_buffered_pdus(rnti, bearer.lcid);
}
logger.error("Bearer rnti=0x%x, eps-BearerID=%d not found", rnti, eps_bearer_id);
return {};
}
private:
srslog::basic_logger& logger;
gtpu* gtpu_obj = nullptr;
pdcp_interface_gtpu* pdcp_lte_obj = nullptr;
pdcp_interface_gtpu* pdcp_nr_obj = nullptr;
enb_bearer_manager* bearers = nullptr;
};
} // namespace srsenb
#endif // SRSRAN_GTPU_PDCP_ADAPTER_H

@ -13,6 +13,7 @@
#include "srsenb/hdr/stack/enb_stack_lte.h"
#include "srsenb/hdr/common/rnti_pool.h"
#include "srsenb/hdr/enb.h"
#include "srsenb/hdr/stack/upper/gtpu_pdcp_adapter.h"
#include "srsran/interfaces/enb_metrics_interface.h"
#include "srsran/interfaces/enb_x2_interfaces.h"
#include "srsran/rlc/bearer_mem_pool.h"
@ -22,60 +23,6 @@ using namespace srsran;
namespace srsenb {
class gtpu_pdcp_adapter final : public gtpu_interface_pdcp, public pdcp_interface_gtpu
{
public:
gtpu_pdcp_adapter(srslog::basic_logger& logger_,
pdcp* pdcp_lte,
pdcp_interface_gtpu* pdcp_x2,
gtpu* gtpu_,
enb_bearer_manager& bearers_) :
logger(logger_), pdcp_obj(pdcp_lte), pdcp_x2_obj(pdcp_x2), gtpu_obj(gtpu_), bearers(&bearers_)
{}
/// Converts LCID to EPS-BearerID and sends corresponding PDU to GTPU
void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) override
{
auto bearer = bearers->get_lcid_bearer(rnti, lcid);
if (not bearer.is_valid()) {
logger.error("Bearer rnti=0x%x, lcid=%d not found", rnti, lcid);
return;
}
gtpu_obj->write_pdu(rnti, bearer.eps_bearer_id, std::move(pdu));
}
void write_sdu(uint16_t rnti, uint32_t eps_bearer_id, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) override
{
auto bearer = bearers->get_radio_bearer(rnti, eps_bearer_id);
// route SDU to PDCP entity
if (bearer.rat == srsran_rat_t::lte) {
pdcp_obj->write_sdu(rnti, bearer.lcid, std::move(sdu), pdcp_sn);
} else if (bearer.rat == srsran_rat_t::nr) {
pdcp_x2_obj->write_sdu(rnti, bearer.lcid, std::move(sdu), pdcp_sn);
} else {
logger.warning("Can't deliver SDU for EPS bearer %d. Dropping it.", eps_bearer_id);
}
}
std::map<uint32_t, srsran::unique_byte_buffer_t> get_buffered_pdus(uint16_t rnti, uint32_t eps_bearer_id) override
{
auto bearer = bearers->get_radio_bearer(rnti, eps_bearer_id);
// route SDU to PDCP entity
if (bearer.rat == srsran_rat_t::lte) {
return pdcp_obj->get_buffered_pdus(rnti, bearer.lcid);
} else if (bearer.rat == srsran_rat_t::nr) {
return pdcp_x2_obj->get_buffered_pdus(rnti, bearer.lcid);
}
logger.error("Bearer rnti=0x%x, eps-BearerID=%d not found", rnti, eps_bearer_id);
return {};
}
private:
srslog::basic_logger& logger;
gtpu* gtpu_obj = nullptr;
pdcp* pdcp_obj = nullptr;
pdcp_interface_gtpu* pdcp_x2_obj = nullptr;
enb_bearer_manager* bearers = nullptr;
};
enb_stack_lte::enb_stack_lte(srslog::sink& log_sink) :
thread("STACK"),
mac_logger(srslog::fetch_basic_logger("MAC", log_sink)),

@ -34,7 +34,7 @@ namespace srsenb {
class ngap;
class gtpu;
class enb_bearer_manager;
class gtpu_pdcp_adapter_nr;
class gtpu_pdcp_adapter;
struct gnb_stack_args_t {
stack_log_args_t log;
@ -155,8 +155,8 @@ private:
std::unique_ptr<srsenb::gtpu> gtpu;
// std::unique_ptr<sdap> m_sdap;
std::unique_ptr<enb_bearer_manager> bearer_manager;
std::unique_ptr<gtpu_pdcp_adapter_nr> gtpu_adapter;
std::unique_ptr<enb_bearer_manager> bearer_manager;
std::unique_ptr<gtpu_pdcp_adapter> gtpu_adapter;
// state
std::atomic<bool> running = {false};

@ -12,55 +12,14 @@
#include "srsgnb/hdr/stack/gnb_stack_nr.h"
#include "srsenb/hdr/stack/upper/gtpu.h"
#include "srsenb/hdr/stack/upper/gtpu_pdcp_adapter.h"
#include "srsgnb/hdr/stack/ngap/ngap.h"
#include "srsran/common/bearer_manager.h"
#include "srsran/common/network_utils.h"
#include "srsran/common/standard_streams.h"
#include "srsran/srsran.h"
#include <srsran/interfaces/enb_metrics_interface.h>
namespace srsenb {
class gtpu_pdcp_adapter_nr final : public gtpu_interface_pdcp, public pdcp_interface_gtpu
{
public:
gtpu_pdcp_adapter_nr(srslog::basic_logger& logger_,
pdcp_interface_gtpu* pdcp_,
gtpu* gtpu_,
enb_bearer_manager& bearers_) :
logger(logger_), pdcp_obj(pdcp_), gtpu_obj(gtpu_), bearers(&bearers_)
{}
/// Converts LCID to EPS-BearerID and sends corresponding PDU to GTPU
void write_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu) override
{
auto bearer = bearers->get_lcid_bearer(rnti, lcid);
if (not bearer.is_valid()) {
logger.error("Bearer rnti=0x%x, lcid=%d not found", rnti, lcid);
return;
}
gtpu_obj->write_pdu(rnti, bearer.eps_bearer_id, std::move(pdu));
}
void write_sdu(uint16_t rnti, uint32_t eps_bearer_id, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) override
{
auto bearer = bearers->get_radio_bearer(rnti, eps_bearer_id);
// route SDU to PDCP entity
pdcp_obj->write_sdu(rnti, bearer.lcid, std::move(sdu), pdcp_sn);
}
std::map<uint32_t, srsran::unique_byte_buffer_t> get_buffered_pdus(uint16_t rnti, uint32_t eps_bearer_id) override
{
auto bearer = bearers->get_radio_bearer(rnti, eps_bearer_id);
// route SDU to PDCP entity
return pdcp_obj->get_buffered_pdus(rnti, bearer.lcid);
}
private:
srslog::basic_logger& logger;
gtpu* gtpu_obj = nullptr;
pdcp_interface_gtpu* pdcp_obj = nullptr;
enb_bearer_manager* bearers = nullptr;
};
gnb_stack_nr::gnb_stack_nr(srslog::sink& log_sink) :
task_sched{512, 128},
thread("gNB"),
@ -123,7 +82,7 @@ int gnb_stack_nr::init(const gnb_stack_args_t& args_,
// SA mode
ngap.reset(new srsenb::ngap(&task_sched, ngap_logger, &srsran::get_rx_io_manager()));
gtpu.reset(new srsenb::gtpu(&task_sched, gtpu_logger, &srsran::get_rx_io_manager()));
gtpu_adapter.reset(new gtpu_pdcp_adapter_nr(gtpu_logger, &pdcp, gtpu.get(), *bearer_manager));
gtpu_adapter.reset(new gtpu_pdcp_adapter(gtpu_logger, nullptr, &pdcp, gtpu.get(), *bearer_manager));
}
// Init all layers

Loading…
Cancel
Save