From 5b14a7d58508d5613c78b17228c2c695573936c3 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 29 Jan 2020 13:16:09 +0100 Subject: [PATCH] Implementation Tx RLC suspend --- lib/include/srslte/upper/rlc_common.h | 33 +++++++++++++++++++++++---- lib/src/upper/rlc.cc | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/include/srslte/upper/rlc_common.h b/lib/include/srslte/upper/rlc_common.h index 065ec251c..29e3c355d 100644 --- a/lib/include/srslte/upper/rlc_common.h +++ b/lib/include/srslte/upper/rlc_common.h @@ -240,6 +240,11 @@ public: write_pdu(p.payload, p.nof_bytes); free(p.payload); } + + unique_byte_buffer_t s; + while (tx_sdu_resume_queue.try_pop(&s)) { + write_sdu(std::move(s), false); + } suspended = false; return true; } @@ -247,12 +252,21 @@ public: void write_pdu_s(uint8_t* payload, uint32_t nof_bytes) { if (suspended) { - queue_pdu(payload, nof_bytes); + queue_rx_pdu(payload, nof_bytes); } else { write_pdu(payload, nof_bytes); } } + void write_sdu_s(unique_byte_buffer_t sdu, bool blocking) + { + if (suspended) { + queue_tx_sdu(std::move(sdu)); + } else { + write_sdu(std::move(sdu), blocking); + } + } + virtual rlc_mode_t get_mode() = 0; virtual uint32_t get_bearer() = 0; @@ -273,8 +287,8 @@ public: private: bool suspended = false; - // Enqueues the PDU in the resume queue - void queue_pdu(uint8_t* payload, uint32_t nof_bytes) + // Enqueues the Rx PDU in the resume queue + void queue_rx_pdu(uint8_t* payload, uint32_t nof_bytes) { pdu_t p = {}; p.nof_bytes = nof_bytes; @@ -288,12 +302,23 @@ private: } } + // Enqueues the Tx SDU in the resume queue + void queue_tx_sdu(unique_byte_buffer_t sdu) + { + // Do not block ever + if (!tx_sdu_resume_queue.try_push(std::move(sdu)).first) { + fprintf(stderr, "Error dropping SDUs while bearer suspended. Queue should be unbounded\n"); + return; + } + } + typedef struct { uint8_t* payload; uint32_t nof_bytes; } pdu_t; - block_queue rx_pdu_resume_queue; + block_queue rx_pdu_resume_queue; + block_queue tx_sdu_resume_queue; }; } // namespace srslte diff --git a/lib/src/upper/rlc.cc b/lib/src/upper/rlc.cc index 336a74913..f6aaf436c 100644 --- a/lib/src/upper/rlc.cc +++ b/lib/src/upper/rlc.cc @@ -201,7 +201,7 @@ void rlc::write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, bool blocking) pthread_rwlock_rdlock(&rwlock); if (valid_lcid(lcid)) { - rlc_array.at(lcid)->write_sdu(std::move(sdu), blocking); + rlc_array.at(lcid)->write_sdu_s(std::move(sdu), blocking); } else { rlc_log->warning("RLC LCID %d doesn't exist. Deallocating SDU\n", lcid); }