srsLTE/lib/include/srsran/rlc/rlc.h

122 lines
4.0 KiB
C
Raw Normal View History

/**
2017-05-18 03:52:29 -07:00
*
* \section COPYRIGHT
2017-05-18 03:52:29 -07:00
*
2021-03-19 03:45:56 -07:00
* Copyright 2013-2021 Software Radio Systems Limited
2017-05-18 03:52:29 -07:00
*
* 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.
2017-05-18 03:52:29 -07:00
*
*/
2021-03-19 03:45:56 -07:00
#ifndef SRSRAN_RLC_H
#define SRSRAN_RLC_H
2017-05-18 03:52:29 -07:00
2021-03-19 03:45:56 -07:00
#include "srsran/common/buffer_pool.h"
#include "srsran/common/common.h"
#include "srsran/common/task_scheduler.h"
#include "srsran/interfaces/ue_pdcp_interfaces.h"
#include "srsran/interfaces/ue_rlc_interfaces.h"
#include "srsran/interfaces/ue_rrc_interfaces.h"
2021-06-25 06:24:56 -07:00
#include "srsran/rlc/rlc_common.h"
#include "srsran/rlc/rlc_metrics.h"
2017-05-18 03:52:29 -07:00
2021-03-19 03:45:56 -07:00
namespace srsran {
2017-05-18 03:52:29 -07:00
/****************************************************************************
* RLC Layer
* Ref: 3GPP TS 36.322 v10.0.0
* Single interface for RLC layer - contains separate RLC entities for
* each bearer.
***************************************************************************/
class rlc : public srsue::rlc_interface_mac, public srsue::rlc_interface_pdcp, public srsue::rlc_interface_rrc
2017-05-18 03:52:29 -07:00
{
public:
2020-03-25 07:57:29 -07:00
rlc(const char* logname);
virtual ~rlc();
void init(srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_,
2021-03-19 03:45:56 -07:00
srsran::timer_handler* timers_,
uint32_t lcid_);
2021-06-25 06:24:56 -07:00
void init(srsue::pdcp_interface_rlc* pdcp_,
srsue::rrc_interface_rlc* rrc_,
2021-03-19 03:45:56 -07:00
srsran::timer_handler* timers_,
uint32_t lcid_,
bsr_callback_t bsr_callback_);
2017-05-18 03:52:29 -07:00
void stop();
void get_metrics(rlc_metrics_t& m, const uint32_t nof_tti);
2017-05-18 03:52:29 -07:00
// PDCP interface
void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu);
2019-05-13 07:34:15 -07:00
void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu);
2017-11-23 10:46:34 -08:00
bool rb_is_um(uint32_t lcid);
void discard_sdu(uint32_t lcid, uint32_t discard_sn);
bool sdu_queue_is_full(uint32_t lcid);
2017-05-18 03:52:29 -07:00
// MAC interface
bool has_data_locked(const uint32_t lcid);
uint32_t get_buffer_state(const uint32_t lcid);
uint32_t get_total_mch_buffer_state(uint32_t lcid);
uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
uint32_t read_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
int get_increment_sequence_num();
void write_pdu(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
2021-03-19 03:45:56 -07:00
void write_pdu_bcch_bch(srsran::unique_byte_buffer_t pdu);
void write_pdu_bcch_dlsch(uint8_t* payload, uint32_t nof_bytes);
2021-03-19 03:45:56 -07:00
void write_pdu_pcch(srsran::unique_byte_buffer_t pdu);
void write_pdu_mch(uint32_t lcid, uint8_t* payload, uint32_t nof_bytes);
2017-05-18 03:52:29 -07:00
// RRC interface
bool is_suspended(const uint32_t lcid);
bool has_data(const uint32_t lcid);
2017-11-23 10:46:34 -08:00
void reestablish();
void reestablish(uint32_t lcid);
2017-05-18 03:52:29 -07:00
void reset();
2017-08-22 06:06:51 -07:00
void empty_queue();
int add_bearer(uint32_t lcid, const rlc_config_t& cnfg);
int add_bearer_mrb(uint32_t lcid);
2018-08-03 07:28:06 -07:00
void del_bearer(uint32_t lcid);
void del_bearer_mrb(uint32_t lcid);
2019-07-09 13:54:04 -07:00
void suspend_bearer(uint32_t lcid);
2019-06-04 08:29:02 -07:00
void resume_bearer(uint32_t lcid);
2018-09-17 04:11:03 -07:00
void change_lcid(uint32_t old_lcid, uint32_t new_lcid);
bool has_bearer(uint32_t lcid);
2017-05-18 03:52:29 -07:00
private:
void reset_metrics();
srslog::basic_logger& logger;
2021-04-13 05:23:00 -07:00
byte_buffer_pool* pool = nullptr;
2020-03-25 07:57:29 -07:00
srsue::pdcp_interface_rlc* pdcp = nullptr;
srsue::rrc_interface_rlc* rrc = nullptr;
2021-03-19 03:45:56 -07:00
srsran::timer_handler* timers = nullptr;
typedef std::map<uint16_t, std::unique_ptr<rlc_common> > rlc_map_t;
typedef std::pair<uint16_t, std::unique_ptr<rlc_common> > rlc_map_pair_t;
rlc_map_t rlc_array, rlc_array_mrb;
pthread_rwlock_t rwlock;
uint32_t default_lcid = 0;
2017-05-18 03:52:29 -07:00
bsr_callback_t bsr_callback = nullptr;
// Timer needed for metrics calculation
std::chrono::high_resolution_clock::time_point metrics_tp;
2017-05-18 03:52:29 -07:00
bool valid_lcid(uint32_t lcid);
bool valid_lcid_mrb(uint32_t lcid);
void update_bsr(uint32_t lcid);
void update_bsr_mch(uint32_t lcid);
2017-05-18 03:52:29 -07:00
};
void rlc_bearer_metrics_print(const rlc_bearer_metrics_t& metrics);
2021-03-19 03:45:56 -07:00
} // namespace srsran
2017-05-18 03:52:29 -07:00
2021-03-19 03:45:56 -07:00
#endif // SRSRAN_RLC_H