mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
4.5 KiB
C
174 lines
4.5 KiB
C
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* 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.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_RLC_UM_BASE_H
|
||
|
#define SRSRAN_RLC_UM_BASE_H
|
||
5 years ago
|
|
||
4 years ago
|
#include "srsran/adt/accumulators.h"
|
||
|
#include "srsran/common/buffer_pool.h"
|
||
|
#include "srsran/common/common.h"
|
||
|
#include "srsran/common/task_scheduler.h"
|
||
4 years ago
|
#include "srsran/rlc/rlc_common.h"
|
||
4 years ago
|
#include "srsran/upper/byte_buffer_queue.h"
|
||
5 years ago
|
#include <map>
|
||
|
#include <mutex>
|
||
|
#include <pthread.h>
|
||
|
#include <queue>
|
||
|
|
||
4 years ago
|
namespace srsue {
|
||
|
|
||
|
class pdcp_interface_rlc;
|
||
4 years ago
|
class rrc_interface_rlc;
|
||
4 years ago
|
|
||
4 years ago
|
} // namespace srsue
|
||
4 years ago
|
|
||
4 years ago
|
namespace srsran {
|
||
5 years ago
|
|
||
|
class rlc_um_base : public rlc_common
|
||
|
{
|
||
|
public:
|
||
4 years ago
|
rlc_um_base(srslog::basic_logger& logger,
|
||
5 years ago
|
uint32_t lcid_,
|
||
|
srsue::pdcp_interface_rlc* pdcp_,
|
||
|
srsue::rrc_interface_rlc* rrc_,
|
||
4 years ago
|
srsran::timer_handler* timers_);
|
||
5 years ago
|
virtual ~rlc_um_base();
|
||
|
void reestablish();
|
||
|
void stop();
|
||
|
void empty_queue();
|
||
|
bool is_mrb();
|
||
|
|
||
|
rlc_mode_t get_mode();
|
||
|
uint32_t get_bearer();
|
||
|
|
||
|
// PDCP interface
|
||
5 years ago
|
void write_sdu(unique_byte_buffer_t sdu);
|
||
5 years ago
|
void discard_sdu(uint32_t discard_sn);
|
||
5 years ago
|
bool sdu_queue_is_full();
|
||
5 years ago
|
|
||
|
// MAC interface
|
||
|
bool has_data();
|
||
|
uint32_t get_buffer_state();
|
||
4 years ago
|
uint32_t read_pdu(uint8_t* payload, uint32_t nof_bytes);
|
||
5 years ago
|
void write_pdu(uint8_t* payload, uint32_t nof_bytes);
|
||
|
int get_increment_sequence_num();
|
||
|
|
||
|
rlc_bearer_metrics_t get_metrics();
|
||
5 years ago
|
void reset_metrics();
|
||
5 years ago
|
|
||
5 years ago
|
void set_bsr_callback(bsr_callback_t callback) {}
|
||
|
|
||
5 years ago
|
protected:
|
||
|
// Transmitter sub-class base
|
||
|
class rlc_um_base_tx
|
||
|
{
|
||
|
public:
|
||
|
rlc_um_base_tx(rlc_um_base* parent_);
|
||
|
virtual ~rlc_um_base_tx();
|
||
5 years ago
|
virtual bool configure(const rlc_config_t& cfg, std::string rb_name) = 0;
|
||
4 years ago
|
uint32_t build_data_pdu(uint8_t* payload, uint32_t nof_bytes);
|
||
5 years ago
|
void stop();
|
||
|
void reestablish();
|
||
|
void empty_queue();
|
||
|
void write_sdu(unique_byte_buffer_t sdu);
|
||
5 years ago
|
void discard_sdu(uint32_t discard_sn);
|
||
5 years ago
|
bool sdu_queue_is_full();
|
||
5 years ago
|
int try_write_sdu(unique_byte_buffer_t sdu);
|
||
5 years ago
|
void reset_metrics();
|
||
|
bool has_data();
|
||
|
virtual uint32_t get_buffer_state() = 0;
|
||
|
|
||
|
protected:
|
||
4 years ago
|
byte_buffer_pool* pool = nullptr;
|
||
|
srslog::basic_logger& logger;
|
||
|
std::string rb_name;
|
||
|
rlc_um_base* parent = nullptr;
|
||
5 years ago
|
|
||
|
rlc_config_t cfg = {};
|
||
|
|
||
|
// TX SDU buffers
|
||
5 years ago
|
byte_buffer_queue tx_sdu_queue;
|
||
5 years ago
|
unique_byte_buffer_t tx_sdu;
|
||
|
|
||
|
// Mutexes
|
||
|
std::mutex mutex;
|
||
|
|
||
4 years ago
|
// Metrics
|
||
|
#ifdef ENABLE_TIMESTAMP
|
||
4 years ago
|
srsran::rolling_average<double> mean_pdu_latency_us;
|
||
4 years ago
|
#endif
|
||
|
|
||
4 years ago
|
virtual uint32_t build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) = 0;
|
||
5 years ago
|
|
||
|
// helper functions
|
||
|
virtual void debug_state() = 0;
|
||
5 years ago
|
virtual void reset() = 0;
|
||
5 years ago
|
};
|
||
|
|
||
|
// Receiver sub-class base
|
||
|
class rlc_um_base_rx : public timer_callback
|
||
|
{
|
||
|
public:
|
||
|
rlc_um_base_rx(rlc_um_base* parent_);
|
||
|
virtual ~rlc_um_base_rx();
|
||
4 years ago
|
virtual bool configure(const rlc_config_t& cnfg_, std::string rb_name_) = 0;
|
||
5 years ago
|
|
||
|
virtual void stop() = 0;
|
||
|
virtual void reestablish() = 0;
|
||
|
|
||
|
virtual void handle_data_pdu(uint8_t* payload, uint32_t nof_bytes) = 0;
|
||
|
|
||
|
protected:
|
||
5 years ago
|
byte_buffer_pool* pool = nullptr;
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
4 years ago
|
srsran::timer_handler* timers = nullptr;
|
||
5 years ago
|
srsue::pdcp_interface_rlc* pdcp = nullptr;
|
||
|
srsue::rrc_interface_rlc* rrc = nullptr;
|
||
|
|
||
|
rlc_bearer_metrics_t& metrics;
|
||
|
|
||
|
std::string rb_name;
|
||
|
rlc_config_t cfg = {};
|
||
|
|
||
|
unique_byte_buffer_t rx_sdu;
|
||
|
|
||
|
uint32_t& lcid;
|
||
|
|
||
|
// helper functions
|
||
|
virtual void debug_state() = 0;
|
||
|
};
|
||
|
|
||
|
// Common variables needed by parent class
|
||
5 years ago
|
srsue::rrc_interface_rlc* rrc = nullptr;
|
||
|
srsue::pdcp_interface_rlc* pdcp = nullptr;
|
||
4 years ago
|
srslog::basic_logger& logger;
|
||
4 years ago
|
srsran::timer_handler* timers = nullptr;
|
||
5 years ago
|
uint32_t lcid = 0;
|
||
|
rlc_config_t cfg = {};
|
||
|
std::string rb_name;
|
||
|
byte_buffer_pool* pool = nullptr;
|
||
|
std::string get_rb_name(srsue::rrc_interface_rlc* rrc, uint32_t lcid, bool is_mrb);
|
||
|
|
||
|
// Rx and Tx objects
|
||
|
std::unique_ptr<rlc_um_base_tx> tx;
|
||
|
std::unique_ptr<rlc_um_base_rx> rx;
|
||
|
|
||
5 years ago
|
bool tx_enabled = false;
|
||
|
bool rx_enabled = false;
|
||
5 years ago
|
|
||
|
rlc_bearer_metrics_t metrics = {};
|
||
|
};
|
||
|
|
||
4 years ago
|
} // namespace srsran
|
||
5 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_RLC_UM_BASE_H
|