mirror of https://github.com/pvnis/srsRAN_4G.git
srsue, nr: Add SDAP to the UE. Supports only UL header
parent
a4f26fa5d6
commit
bfe69deccc
@ -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.
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* File: ue_sdap_interfaces.h
|
||||
* Description: Abstract base class interfaces for SDAP layer
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef SRSRAN_UE_SDAP_INTERFACES_H
|
||||
#define SRSRAN_UE_SDAP_INTERFACES_H
|
||||
|
||||
/*****************************
|
||||
* SDAP INTERFACES
|
||||
****************************/
|
||||
class sdap_interface_pdcp_nr
|
||||
{
|
||||
public:
|
||||
virtual void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0;
|
||||
};
|
||||
class sdap_interface_gw_nr
|
||||
{
|
||||
public:
|
||||
virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) = 0;
|
||||
};
|
||||
|
||||
class sdap_interface_rrc
|
||||
{
|
||||
public:
|
||||
struct bearer_cfg_t {
|
||||
bool is_data;
|
||||
bool add_downlink_header;
|
||||
bool add_uplink_header;
|
||||
uint32_t qfi;
|
||||
};
|
||||
virtual bool set_bearer_cfg(uint32_t lcid, const bearer_cfg_t& cfg) = 0;
|
||||
};
|
||||
|
||||
#endif // SRSRAN_UE_SDAP_INTERFACES_H
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
*
|
||||
* \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 SRSUE_SDAP_H
|
||||
#define SRSUE_SDAP_H
|
||||
|
||||
#include "srsran/common/buffer_pool.h"
|
||||
#include "srsran/common/common.h"
|
||||
#include "srsran/common/common_nr.h"
|
||||
#include "srsran/interfaces/ue_gw_interfaces.h"
|
||||
#include "srsran/interfaces/ue_pdcp_interfaces.h"
|
||||
#include "srsran/interfaces/ue_sdap_interfaces.h"
|
||||
|
||||
namespace srsue {
|
||||
|
||||
class sdap final : public sdap_interface_pdcp_nr, public sdap_interface_gw_nr, public sdap_interface_rrc
|
||||
{
|
||||
public:
|
||||
explicit sdap(const char* logname);
|
||||
bool init(pdcp_interface_sdap_nr* pdcp_, srsue::gw_interface_pdcp* gw_);
|
||||
void stop();
|
||||
|
||||
// Interface for GW
|
||||
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;
|
||||
|
||||
// Interface for PDCP
|
||||
void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu) final;
|
||||
|
||||
// Interface for RRC
|
||||
bool set_bearer_cfg(uint32_t lcid, const sdap_interface_rrc::bearer_cfg_t& cfg) final;
|
||||
|
||||
private:
|
||||
pdcp_interface_sdap_nr* m_pdcp = nullptr;
|
||||
gw_interface_pdcp* m_gw = nullptr;
|
||||
|
||||
// state
|
||||
bool running = false;
|
||||
|
||||
// configuration
|
||||
std::array<sdap_interface_rrc::bearer_cfg_t, srsran::MAX_NR_NOF_BEARERS> bearers = {};
|
||||
|
||||
srslog::basic_logger& logger;
|
||||
};
|
||||
|
||||
} // namespace srsue
|
||||
|
||||
#endif // SRSUE_SDAP_H
|
@ -0,0 +1,76 @@
|
||||
/**
|
||||
*
|
||||
* \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 "srsue/hdr/stack/upper/sdap.h"
|
||||
|
||||
namespace srsue {
|
||||
|
||||
sdap::sdap(const char* logname) : logger(srslog::fetch_basic_logger(logname)) {}
|
||||
|
||||
bool sdap::init(pdcp_interface_sdap_nr* pdcp_, srsue::gw_interface_pdcp* gw_)
|
||||
{
|
||||
m_pdcp = pdcp_;
|
||||
m_gw = gw_;
|
||||
|
||||
running = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void sdap::stop()
|
||||
{
|
||||
if (running) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void sdap::write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
|
||||
{
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
m_gw->write_pdu(lcid, std::move(pdu));
|
||||
}
|
||||
|
||||
void sdap::write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
|
||||
{
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
if (lcid < bearers.size()) {
|
||||
if (bearers[lcid].add_uplink_header) {
|
||||
if (pdu->get_headroom() > 1) {
|
||||
pdu->msg -= 1;
|
||||
pdu->N_bytes += 1;
|
||||
pdu->msg[0] = ((bearers[lcid].is_data ? 1 : 0) << 7) | (bearers[lcid].qfi & 0x3f);
|
||||
} else {
|
||||
logger.error("Not enough headroom in PDU to add header\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pdcp->write_sdu(lcid, std::move(pdu));
|
||||
}
|
||||
|
||||
bool sdap::set_bearer_cfg(uint32_t lcid, const sdap_interface_rrc::bearer_cfg_t& cfg)
|
||||
{
|
||||
if (lcid >= bearers.size()) {
|
||||
logger.error("Error setting configuration: invalid lcid=%d\n", lcid);
|
||||
return false;
|
||||
}
|
||||
if (cfg.add_downlink_header) {
|
||||
logger.error("Error setting configuration: downlink header not supported\n");
|
||||
return false;
|
||||
}
|
||||
bearers[lcid] = cfg;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace srsue
|
Loading…
Reference in New Issue