avoid the use of two arrays for managing buffered pdcp sns in RLC AM

master
Francisco 4 years ago committed by Francisco Paisana
parent 299634b319
commit bad2302e31

@ -123,23 +123,21 @@ private:
struct buffered_pdcp_pdu_list { struct buffered_pdcp_pdu_list {
public: public:
void resize(size_t size) const static size_t max_pdcp_sn = 262144;
{
buffered_pdus.resize(size); void resize(size_t size);
active_flag.resize(size, false);
}
void clear(); void clear();
void add_pdcp_sdu(pdcp_sdu_info_t sdu) void add_pdcp_sdu(uint32_t sn)
{ {
assert(not has_pdcp_sn(sdu.sn)); assert(not has_pdcp_sn(sn));
buffered_pdus[sdu.sn] = sdu; buffered_pdus[sn].sn = sn;
active_flag[sdu.sn] = true;
count++; count++;
} }
void clear_pdcp_sdu(uint32_t sn) void clear_pdcp_sdu(uint32_t sn)
{ {
active_flag[sn] = false; buffered_pdus[sn].rlc_sn_info_list.clear();
buffered_pdus[sn].sn = -1;
count--; count--;
} }
@ -148,12 +146,11 @@ public:
assert(has_pdcp_sn(sn)); assert(has_pdcp_sn(sn));
return buffered_pdus[sn]; return buffered_pdus[sn];
} }
bool has_pdcp_sn(uint32_t pdcp_sn) const { return active_flag[pdcp_sn]; } bool has_pdcp_sn(uint32_t pdcp_sn) const { return buffered_pdus[pdcp_sn].sn < max_pdcp_sn; }
uint32_t nof_sdus() const { return count; } uint32_t nof_sdus() const { return count; }
private: private:
std::vector<pdcp_sdu_info_t> buffered_pdus; std::vector<pdcp_sdu_info_t> buffered_pdus;
std::vector<bool> active_flag;
uint32_t count = 0; uint32_t count = 0;
}; };

@ -190,7 +190,7 @@ bool rlc_am_lte::rlc_am_lte_tx::configure(const rlc_config_t& cfg_)
cfg = cfg_.am; cfg = cfg_.am;
// TODO: Set size based on PDCP config // TODO: Set size based on PDCP config
undelivered_sdu_info_queue.resize(262144); undelivered_sdu_info_queue.resize(buffered_pdcp_pdu_list::max_pdcp_sn);
// check timers // check timers
if (not poll_retx_timer.is_valid() or not status_prohibit_timer.is_valid()) { if (not poll_retx_timer.is_valid() or not status_prohibit_timer.is_valid()) {
@ -367,8 +367,7 @@ int rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu)
} }
// Get SDU info // Get SDU info
pdcp_sdu_info_t info = {}; uint32_t sdu_pdcp_sn = sdu->md.pdcp_sn;
info.sn = sdu->md.pdcp_sn;
// Store SDU // Store SDU
uint8_t* msg_ptr = sdu->msg; uint8_t* msg_ptr = sdu->msg;
@ -390,15 +389,15 @@ int rlc_am_lte::rlc_am_lte_tx::write_sdu(unique_byte_buffer_t sdu)
// Store SDU info // Store SDU info
logger.debug( logger.debug(
"Storing PDCP SDU info in queue. PDCP_SN=%d, Queue Size=%ld", info.sn, undelivered_sdu_info_queue.nof_sdus()); "Storing PDCP SDU info in queue. PDCP_SN=%d, Queue Size=%ld", sdu_pdcp_sn, undelivered_sdu_info_queue.nof_sdus());
if (undelivered_sdu_info_queue.has_pdcp_sn(info.sn)) { if (undelivered_sdu_info_queue.has_pdcp_sn(sdu_pdcp_sn)) {
logger.error("PDCP SDU info already exists. SN=%d", info.sn); logger.error("PDCP SDU info already exists. SN=%d", sdu_pdcp_sn);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
undelivered_sdu_info_queue.add_pdcp_sdu(info); undelivered_sdu_info_queue.add_pdcp_sdu(sdu_pdcp_sn);
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
@ -2018,10 +2017,21 @@ void rlc_am_lte::rlc_am_lte_rx::debug_state()
logger.debug("%s vr_r = %d, vr_mr = %d, vr_x = %d, vr_ms = %d, vr_h = %d", RB_NAME, vr_r, vr_mr, vr_x, vr_ms, vr_h); logger.debug("%s vr_r = %d, vr_mr = %d, vr_x = %d, vr_ms = %d, vr_h = %d", RB_NAME, vr_r, vr_mr, vr_x, vr_ms, vr_h);
} }
void buffered_pdcp_pdu_list::resize(size_t size)
{
size_t old_size = buffered_pdus.size();
buffered_pdus.resize(size);
for (size_t i = old_size; i < buffered_pdus.size(); ++i) {
buffered_pdus[i].sn = -1;
buffered_pdus[i].rlc_sn_info_list.reserve(5);
}
}
void buffered_pdcp_pdu_list::clear() void buffered_pdcp_pdu_list::clear()
{ {
for (auto& b : buffered_pdus) { for (auto& b : buffered_pdus) {
b = {}; b.sn = -1;
b.rlc_sn_info_list.clear();
} }
} }

Loading…
Cancel
Save