2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* Copyright 2013-2020 Software Radio Systems Limited
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08: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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-07-01 10:49:19 -07:00
|
|
|
#ifndef SRSLTE_PDCP_ENTITY_NR_H
|
|
|
|
#define SRSLTE_PDCP_ENTITY_NR_H
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2019-07-23 07:49:34 -07:00
|
|
|
#include "pdcp_entity_base.h"
|
2017-05-31 14:39:17 -07:00
|
|
|
#include "srslte/common/buffer_pool.h"
|
|
|
|
#include "srslte/common/common.h"
|
2019-07-01 10:49:19 -07:00
|
|
|
#include "srslte/common/interfaces_common.h"
|
2019-07-23 07:49:34 -07:00
|
|
|
#include "srslte/common/log.h"
|
2017-05-31 14:39:17 -07:00
|
|
|
#include "srslte/common/security.h"
|
2020-07-08 14:06:15 -07:00
|
|
|
#include "srslte/common/task_scheduler.h"
|
2017-11-30 09:09:12 -08:00
|
|
|
#include "srslte/common/threads.h"
|
2020-03-01 05:51:51 -08:00
|
|
|
#include "srslte/interfaces/ue_interfaces.h"
|
2019-10-01 10:40:23 -07:00
|
|
|
#include <map>
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2017-06-01 03:25:42 -07:00
|
|
|
namespace srslte {
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
/****************************************************************************
|
2019-07-04 08:02:47 -07:00
|
|
|
* NR PDCP Entity
|
|
|
|
* PDCP entity for 5G NR
|
2017-05-18 03:52:29 -07:00
|
|
|
***************************************************************************/
|
2020-06-16 04:08:34 -07:00
|
|
|
class pdcp_entity_nr final : public pdcp_entity_base
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
|
|
|
public:
|
2020-07-08 14:06:15 -07:00
|
|
|
pdcp_entity_nr(srsue::rlc_interface_pdcp* rlc_,
|
|
|
|
srsue::rrc_interface_pdcp* rrc_,
|
|
|
|
srsue::gw_interface_pdcp* gw_,
|
|
|
|
srslte::task_sched_handle task_sched_,
|
2021-02-10 02:47:56 -08:00
|
|
|
srslog::basic_logger& logger,
|
2020-07-08 14:06:15 -07:00
|
|
|
uint32_t lcid,
|
|
|
|
pdcp_config_t cfg_);
|
2020-06-16 04:08:34 -07:00
|
|
|
~pdcp_entity_nr() final;
|
|
|
|
void reset() final;
|
|
|
|
void reestablish() final;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
// RRC interface
|
2021-02-11 10:01:14 -08:00
|
|
|
void write_sdu(unique_byte_buffer_t sdu, int sn = -1) final;
|
2019-07-01 10:49:19 -07:00
|
|
|
|
2017-05-18 03:52:29 -07:00
|
|
|
// RLC interface
|
2020-06-16 04:08:34 -07:00
|
|
|
void write_pdu(unique_byte_buffer_t pdu) final;
|
2020-09-15 04:21:39 -07:00
|
|
|
void notify_delivery(const std::vector<uint32_t>& tx_count) final;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2019-10-17 03:06:34 -07:00
|
|
|
// State variable setters (should be used only for testing)
|
2019-10-07 08:44:49 -07:00
|
|
|
void set_tx_next(uint32_t tx_next_) { tx_next = tx_next_; }
|
|
|
|
void set_rx_next(uint32_t rx_next_) { rx_next = rx_next_; }
|
|
|
|
void set_rx_deliv(uint32_t rx_deliv_) { rx_deliv = rx_deliv_; }
|
|
|
|
void set_rx_reord(uint32_t rx_reord_) { rx_reord = rx_reord_; }
|
|
|
|
|
2020-06-16 04:08:34 -07:00
|
|
|
void get_bearer_state(pdcp_lte_state_t* state) override;
|
|
|
|
void set_bearer_state(const pdcp_lte_state_t& state) override;
|
|
|
|
|
2021-02-12 10:05:48 -08:00
|
|
|
void send_status_report() override {}
|
|
|
|
|
2021-01-28 09:22:19 -08:00
|
|
|
std::map<uint32_t, srslte::unique_byte_buffer_t> get_buffered_pdus() override { return {}; }
|
|
|
|
|
2019-11-28 07:03:36 -08:00
|
|
|
// State variable getters (useful for testing)
|
|
|
|
uint32_t nof_discard_timers() { return discard_timers_map.size(); }
|
|
|
|
|
2017-05-18 03:52:29 -07:00
|
|
|
private:
|
2019-06-21 06:09:00 -07:00
|
|
|
srsue::rlc_interface_pdcp* rlc = nullptr;
|
|
|
|
srsue::rrc_interface_pdcp* rrc = nullptr;
|
|
|
|
srsue::gw_interface_pdcp* gw = nullptr;
|
|
|
|
|
2019-07-02 10:53:41 -07:00
|
|
|
// State variables: 3GPP TS 38.323 v15.2.0, section 7.1
|
2019-07-03 10:51:44 -07:00
|
|
|
uint32_t tx_next = 0; // COUNT value of next SDU to be transmitted.
|
|
|
|
uint32_t rx_next = 0; // COUNT value of next SDU expected to be received.
|
|
|
|
uint32_t rx_deliv = 0; // COUNT value of first SDU not delivered to upper layers, but still waited for.
|
|
|
|
uint32_t rx_reord = 0; // COUNT value following the COUNT value of PDCP Data PDU which triggered t-Reordering.
|
|
|
|
|
2019-07-02 10:53:41 -07:00
|
|
|
// Constants: 3GPP TS 38.323 v15.2.0, section 7.2
|
|
|
|
uint32_t window_size = 0;
|
2019-07-04 06:44:02 -07:00
|
|
|
|
2019-10-02 08:55:40 -07:00
|
|
|
// Reordering Queue / Timers
|
|
|
|
std::map<uint32_t, unique_byte_buffer_t> reorder_queue;
|
2019-10-29 08:31:27 -07:00
|
|
|
timer_handler::unique_timer reordering_timer;
|
2019-10-02 08:55:40 -07:00
|
|
|
|
2019-10-03 08:58:15 -07:00
|
|
|
// Pass to Upper Layers Helper function
|
|
|
|
void deliver_all_consecutive_counts();
|
|
|
|
void pass_to_upper_layers(unique_byte_buffer_t pdu);
|
|
|
|
|
2019-10-07 08:44:49 -07:00
|
|
|
// Reodering callback (t-Reordering)
|
|
|
|
class reordering_callback;
|
|
|
|
std::unique_ptr<reordering_callback> reordering_fnc;
|
2019-10-10 06:41:20 -07:00
|
|
|
|
2019-11-25 04:04:31 -08:00
|
|
|
// Discard callback (discardTimer)
|
|
|
|
class discard_callback;
|
2019-11-26 10:07:38 -08:00
|
|
|
std::map<uint32_t, timer_handler::unique_timer> discard_timers_map;
|
2019-11-25 04:04:31 -08:00
|
|
|
|
2019-10-10 06:41:20 -07:00
|
|
|
// COUNT overflow protection
|
|
|
|
bool tx_overflow = false;
|
2019-10-11 10:33:16 -07:00
|
|
|
bool rx_overflow = false;
|
2019-10-07 08:44:49 -07:00
|
|
|
};
|
2019-10-03 08:58:15 -07:00
|
|
|
|
2019-10-07 08:44:49 -07:00
|
|
|
/*
|
|
|
|
* Timer callbacks
|
|
|
|
*/
|
2019-10-14 09:39:02 -07:00
|
|
|
// Reordering callback (t-Reordering)
|
2019-11-19 06:20:29 -08:00
|
|
|
class pdcp_entity_nr::reordering_callback
|
2019-10-07 08:44:49 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
reordering_callback(pdcp_entity_nr* parent_) { parent = parent_; };
|
2019-11-19 06:20:29 -08:00
|
|
|
void operator()(uint32_t timer_id);
|
2019-10-14 09:39:02 -07:00
|
|
|
|
2019-10-07 08:44:49 -07:00
|
|
|
private:
|
|
|
|
pdcp_entity_nr* parent;
|
2017-05-18 03:52:29 -07:00
|
|
|
};
|
|
|
|
|
2019-11-25 04:04:31 -08:00
|
|
|
// Discard callback (discardTimer)
|
|
|
|
class pdcp_entity_nr::discard_callback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
discard_callback(pdcp_entity_nr* parent_, uint32_t sn_)
|
|
|
|
{
|
|
|
|
parent = parent_;
|
|
|
|
discard_sn = sn_;
|
|
|
|
};
|
|
|
|
void operator()(uint32_t timer_id);
|
|
|
|
|
|
|
|
private:
|
|
|
|
pdcp_entity_nr* parent;
|
2019-11-25 07:16:37 -08:00
|
|
|
uint32_t discard_sn;
|
2019-11-25 04:04:31 -08:00
|
|
|
};
|
|
|
|
|
2019-10-09 07:24:19 -07:00
|
|
|
/*
|
|
|
|
* Helpers
|
|
|
|
*/
|
2019-10-03 08:58:15 -07:00
|
|
|
inline void pdcp_entity_nr::pass_to_upper_layers(unique_byte_buffer_t sdu)
|
|
|
|
{
|
|
|
|
if (is_srb()) {
|
|
|
|
rrc->write_pdu(lcid, std::move(sdu));
|
|
|
|
} else {
|
|
|
|
gw->write_pdu(lcid, std::move(sdu));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
} // namespace srslte
|
2019-07-01 10:49:19 -07:00
|
|
|
#endif // SRSLTE_PDCP_ENTITY_NR_H
|