|
|
|
@ -16,60 +16,138 @@
|
|
|
|
|
#include "srsran/adt/circular_buffer.h"
|
|
|
|
|
#include "srsran/adt/circular_map.h"
|
|
|
|
|
#include "srsran/adt/intrusive_list.h"
|
|
|
|
|
#include "srsran/common/buffer_pool.h"
|
|
|
|
|
#include <array>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace srsran {
|
|
|
|
|
|
|
|
|
|
template <typename header_t>
|
|
|
|
|
class rlc_amd_tx_pdu;
|
|
|
|
|
template <typename header_t>
|
|
|
|
|
class pdcp_pdu_info;
|
|
|
|
|
|
|
|
|
|
/// Pool that manages the allocation of RLC AM PDU Segments to RLC PDUs and tracking of segments ACK state
|
|
|
|
|
template <typename header_t>
|
|
|
|
|
struct rlc_am_pdu_segment_pool {
|
|
|
|
|
const static size_t MAX_POOL_SIZE = 16384;
|
|
|
|
|
using rlc_list_tag = default_intrusive_tag;
|
|
|
|
|
struct free_list_tag {};
|
|
|
|
|
|
|
|
|
|
/// RLC AM PDU Segment, containing the PDCP SN and RLC SN it has been assigned to, and its current ACK state
|
|
|
|
|
using rlc_list_tag = default_intrusive_tag;
|
|
|
|
|
struct free_list_tag {};
|
|
|
|
|
struct segment_resource : public intrusive_forward_list_element<rlc_list_tag>,
|
|
|
|
|
public intrusive_forward_list_element<free_list_tag>,
|
|
|
|
|
public intrusive_double_linked_list_element<> {
|
|
|
|
|
const static uint32_t invalid_rlc_sn = std::numeric_limits<uint32_t>::max();
|
|
|
|
|
const static uint32_t invalid_pdcp_sn = std::numeric_limits<uint32_t>::max() - 1; // -1 for Status Report
|
|
|
|
|
|
|
|
|
|
int id() const;
|
|
|
|
|
void release_pdcp_sn();
|
|
|
|
|
void release_rlc_sn();
|
|
|
|
|
int id() const { return std::distance(parent_pool->segments.cbegin(), this); }
|
|
|
|
|
|
|
|
|
|
void release_pdcp_sn()
|
|
|
|
|
{
|
|
|
|
|
pdcp_sn_ = invalid_pdcp_sn;
|
|
|
|
|
if (empty()) {
|
|
|
|
|
parent_pool->free_list.push_front(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void release_rlc_sn()
|
|
|
|
|
{
|
|
|
|
|
rlc_sn_ = invalid_rlc_sn;
|
|
|
|
|
if (empty()) {
|
|
|
|
|
parent_pool->free_list.push_front(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t rlc_sn() const { return rlc_sn_; }
|
|
|
|
|
uint32_t pdcp_sn() const { return pdcp_sn_; }
|
|
|
|
|
bool empty() const { return rlc_sn_ == invalid_rlc_sn and pdcp_sn_ == invalid_pdcp_sn; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend struct rlc_am_pdu_segment_pool;
|
|
|
|
|
friend struct rlc_am_pdu_segment_pool<header_t>;
|
|
|
|
|
uint32_t rlc_sn_ = invalid_rlc_sn;
|
|
|
|
|
uint32_t pdcp_sn_ = invalid_pdcp_sn;
|
|
|
|
|
rlc_am_pdu_segment_pool* parent_pool = nullptr;
|
|
|
|
|
rlc_am_pdu_segment_pool<header_t>* parent_pool = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rlc_am_pdu_segment_pool();
|
|
|
|
|
rlc_am_pdu_segment_pool()
|
|
|
|
|
{
|
|
|
|
|
for (segment_resource& s : segments) {
|
|
|
|
|
s.parent_pool = this;
|
|
|
|
|
free_list.push_front(&s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rlc_am_pdu_segment_pool(const rlc_am_pdu_segment_pool&) = delete;
|
|
|
|
|
rlc_am_pdu_segment_pool(rlc_am_pdu_segment_pool&&) = delete;
|
|
|
|
|
rlc_am_pdu_segment_pool& operator=(const rlc_am_pdu_segment_pool&) = delete;
|
|
|
|
|
rlc_am_pdu_segment_pool& operator=(rlc_am_pdu_segment_pool&&) = delete;
|
|
|
|
|
|
|
|
|
|
bool has_segments() const { return not free_list.empty(); }
|
|
|
|
|
bool make_segment(rlc_amd_tx_pdu& rlc_list, pdcp_pdu_info& pdcp_info);
|
|
|
|
|
bool make_segment(rlc_amd_tx_pdu<header_t>& rlc_list, pdcp_pdu_info<header_t>& pdcp_list)
|
|
|
|
|
{
|
|
|
|
|
if (not has_segments()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
segment_resource* segment = free_list.pop_front();
|
|
|
|
|
segment->rlc_sn_ = rlc_list.rlc_sn;
|
|
|
|
|
segment->pdcp_sn_ = pdcp_list.sn;
|
|
|
|
|
rlc_list.add_segment(*segment);
|
|
|
|
|
pdcp_list.add_segment(*segment);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
intrusive_forward_list<segment_resource, free_list_tag> free_list;
|
|
|
|
|
std::array<segment_resource, MAX_POOL_SIZE> segments;
|
|
|
|
|
intrusive_forward_list<rlc_am_pdu_segment_pool<header_t>::segment_resource, free_list_tag> free_list;
|
|
|
|
|
std::array<rlc_am_pdu_segment_pool<header_t>::segment_resource, MAX_POOL_SIZE> segments;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// RLC AM PDU Segment, containing the PDCP SN and RLC SN it has been assigned to, and its current ACK state
|
|
|
|
|
using rlc_am_pdu_segment = rlc_am_pdu_segment_pool::segment_resource;
|
|
|
|
|
/// Class that contains the parameters and state (e.g. segments) of a RLC PDU
|
|
|
|
|
template <typename header_t>
|
|
|
|
|
class rlc_amd_tx_pdu
|
|
|
|
|
{
|
|
|
|
|
using rlc_am_pdu_segment = typename rlc_am_pdu_segment_pool<header_t>::segment_resource;
|
|
|
|
|
using list_type = intrusive_forward_list<rlc_am_pdu_segment>;
|
|
|
|
|
const static uint32_t invalid_rlc_sn = std::numeric_limits<uint32_t>::max();
|
|
|
|
|
|
|
|
|
|
list_type list;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
using iterator = typename list_type::iterator;
|
|
|
|
|
using const_iterator = typename list_type::const_iterator;
|
|
|
|
|
|
|
|
|
|
const uint32_t rlc_sn = invalid_rlc_sn;
|
|
|
|
|
uint32_t retx_count = 0;
|
|
|
|
|
header_t header;
|
|
|
|
|
unique_byte_buffer_t buf;
|
|
|
|
|
|
|
|
|
|
explicit rlc_amd_tx_pdu(uint32_t rlc_sn_) : rlc_sn(rlc_sn_) {}
|
|
|
|
|
rlc_amd_tx_pdu(const rlc_amd_tx_pdu&) = delete;
|
|
|
|
|
rlc_amd_tx_pdu(rlc_amd_tx_pdu&& other) noexcept = default;
|
|
|
|
|
rlc_amd_tx_pdu& operator=(const rlc_amd_tx_pdu& other) = delete;
|
|
|
|
|
rlc_amd_tx_pdu& operator=(rlc_amd_tx_pdu&& other) = delete;
|
|
|
|
|
~rlc_amd_tx_pdu()
|
|
|
|
|
{
|
|
|
|
|
while (not list.empty()) {
|
|
|
|
|
// remove from list
|
|
|
|
|
rlc_am_pdu_segment* segment = list.pop_front();
|
|
|
|
|
// deallocate if also removed from PDCP
|
|
|
|
|
segment->release_rlc_sn();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Segment List Interface
|
|
|
|
|
void add_segment(rlc_am_pdu_segment& segment) { list.push_front(&segment); }
|
|
|
|
|
const_iterator begin() const { return list.begin(); }
|
|
|
|
|
const_iterator end() const { return list.end(); }
|
|
|
|
|
iterator begin() { return list.begin(); }
|
|
|
|
|
iterator end() { return list.end(); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Class that contains the parameters and state (e.g. unACKed segments) of a PDCP PDU
|
|
|
|
|
template <typename header_t>
|
|
|
|
|
class pdcp_pdu_info
|
|
|
|
|
{
|
|
|
|
|
using rlc_am_pdu_segment = typename rlc_am_pdu_segment_pool<header_t>::segment_resource;
|
|
|
|
|
using list_type = intrusive_double_linked_list<rlc_am_pdu_segment>;
|
|
|
|
|
|
|
|
|
|
list_type list; // List of unACKed RLC PDUs that contain segments that belong to the PDCP PDU.
|
|
|
|
@ -97,7 +175,13 @@ public:
|
|
|
|
|
|
|
|
|
|
// Interface for list of unACKed RLC segments of the PDCP PDU
|
|
|
|
|
void add_segment(rlc_am_pdu_segment& segment) { list.push_front(&segment); }
|
|
|
|
|
void ack_segment(rlc_am_pdu_segment& segment);
|
|
|
|
|
void ack_segment(rlc_am_pdu_segment& segment)
|
|
|
|
|
{
|
|
|
|
|
// remove from list
|
|
|
|
|
list.pop(&segment);
|
|
|
|
|
// signal pool that the pdcp handle is released
|
|
|
|
|
segment.release_pdcp_sn();
|
|
|
|
|
}
|
|
|
|
|
void clear()
|
|
|
|
|
{
|
|
|
|
|
sn = invalid_pdcp_sn;
|
|
|
|
@ -106,6 +190,7 @@ public:
|
|
|
|
|
ack_segment(list.front());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const_iterator begin() const { return list.begin(); }
|
|
|
|
|
const_iterator end() const { return list.end(); }
|
|
|
|
|
};
|
|
|
|
@ -146,6 +231,7 @@ private:
|
|
|
|
|
srsran::static_circular_map<uint32_t, T, WINDOW_SIZE> window;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename header_t>
|
|
|
|
|
struct buffered_pdcp_pdu_list {
|
|
|
|
|
public:
|
|
|
|
|
explicit buffered_pdcp_pdu_list() : buffered_pdus(buffered_pdcp_pdu_list::buffer_size) { clear(); }
|
|
|
|
@ -153,7 +239,7 @@ public:
|
|
|
|
|
void clear()
|
|
|
|
|
{
|
|
|
|
|
count = 0;
|
|
|
|
|
for (pdcp_pdu_info& b : buffered_pdus) {
|
|
|
|
|
for (pdcp_pdu_info<header_t>& b : buffered_pdus) {
|
|
|
|
|
b.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -162,7 +248,7 @@ public:
|
|
|
|
|
{
|
|
|
|
|
srsran_expect(sn <= max_pdcp_sn or sn == status_report_sn, "Invalid PDCP SN=%d", sn);
|
|
|
|
|
srsran_assert(not has_pdcp_sn(sn), "Cannot re-add same PDCP SN twice");
|
|
|
|
|
pdcp_pdu_info& pdu = get_pdu_(sn);
|
|
|
|
|
pdcp_pdu_info<header_t>& pdu = get_pdu_(sn);
|
|
|
|
|
if (pdu.valid()) {
|
|
|
|
|
pdu.clear();
|
|
|
|
|
count--;
|
|
|
|
@ -170,21 +256,25 @@ public:
|
|
|
|
|
pdu.sn = sn;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clear_pdcp_sdu(uint32_t sn)
|
|
|
|
|
{
|
|
|
|
|
pdcp_pdu_info& pdu = get_pdu_(sn);
|
|
|
|
|
pdcp_pdu_info<header_t>& pdu = get_pdu_(sn);
|
|
|
|
|
if (not pdu.valid()) {
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pdu.clear();
|
|
|
|
|
count--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pdcp_pdu_info& operator[](uint32_t sn)
|
|
|
|
|
pdcp_pdu_info<header_t>& operator[](uint32_t sn)
|
|
|
|
|
{
|
|
|
|
|
srsran_expect(has_pdcp_sn(sn), "Invalid access to non-existent PDCP SN=%d", sn);
|
|
|
|
|
return get_pdu_(sn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool has_pdcp_sn(uint32_t pdcp_sn) const
|
|
|
|
|
{
|
|
|
|
|
srsran_expect(pdcp_sn <= max_pdcp_sn or pdcp_sn == status_report_sn, "Invalid PDCP SN=%d", pdcp_sn);
|
|
|
|
@ -195,20 +285,20 @@ public:
|
|
|
|
|
private:
|
|
|
|
|
const static size_t max_pdcp_sn = 262143u;
|
|
|
|
|
const static size_t buffer_size = 4096u;
|
|
|
|
|
const static uint32_t status_report_sn = pdcp_pdu_info::status_report_sn;
|
|
|
|
|
const static uint32_t status_report_sn = pdcp_pdu_info<header_t>::status_report_sn;
|
|
|
|
|
|
|
|
|
|
pdcp_pdu_info& get_pdu_(uint32_t sn)
|
|
|
|
|
pdcp_pdu_info<header_t>& get_pdu_(uint32_t sn)
|
|
|
|
|
{
|
|
|
|
|
return (sn == status_report_sn) ? status_report_pdu : buffered_pdus[static_cast<size_t>(sn % buffer_size)];
|
|
|
|
|
}
|
|
|
|
|
const pdcp_pdu_info& get_pdu_(uint32_t sn) const
|
|
|
|
|
const pdcp_pdu_info<header_t>& get_pdu_(uint32_t sn) const
|
|
|
|
|
{
|
|
|
|
|
return (sn == status_report_sn) ? status_report_pdu : buffered_pdus[static_cast<size_t>(sn % buffer_size)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// size equal to buffer_size
|
|
|
|
|
std::vector<pdcp_pdu_info> buffered_pdus;
|
|
|
|
|
pdcp_pdu_info status_report_pdu;
|
|
|
|
|
std::vector<pdcp_pdu_info<header_t> > buffered_pdus;
|
|
|
|
|
pdcp_pdu_info<header_t> status_report_pdu;
|
|
|
|
|
uint32_t count = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|