From d66c76b37453a6ee4be90cc13fa42ddffbde30e7 Mon Sep 17 00:00:00 2001 From: Robert Falkenberg Date: Fri, 22 Apr 2022 10:29:57 +0200 Subject: [PATCH] lib,rlc_am_nr: consider size of all pending retx in buffer state --- lib/include/srsran/rlc/rlc_am_data_structs.h | 15 +++++++++++++++ lib/src/rlc/rlc_am_nr.cc | 8 ++++---- lib/test/rlc/rlc_am_nr_test.cc | 6 ++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/include/srsran/rlc/rlc_am_data_structs.h b/lib/include/srsran/rlc/rlc_am_data_structs.h index 5c4ce5012..98ac017a7 100644 --- a/lib/include/srsran/rlc/rlc_am_data_structs.h +++ b/lib/include/srsran/rlc/rlc_am_data_structs.h @@ -370,6 +370,9 @@ public: virtual bool empty() const = 0; virtual bool full() const = 0; + virtual T& operator[](size_t idx) = 0; + virtual const T& operator[](size_t idx) const = 0; + virtual bool has_sn(uint32_t sn) const = 0; virtual bool has_sn(uint32_t sn, uint32_t so) const = 0; }; @@ -396,6 +399,18 @@ public: return buffer[rpos]; } + T& operator[](size_t idx) override + { + srsran_assert(idx < size(), "Out-of-bounds access to element idx=%zd", idx); + return buffer[(rpos + idx) % WINDOW_SIZE]; + } + + const T& operator[](size_t idx) const override + { + srsran_assert(idx < size(), "Out-of-bounds access to element idx=%zd", idx); + return buffer[(rpos + idx) % WINDOW_SIZE]; + } + void clear() override { wpos = 0; diff --git a/lib/src/rlc/rlc_am_nr.cc b/lib/src/rlc/rlc_am_nr.cc index b1fcdc51d..6091694e0 100644 --- a/lib/src/rlc/rlc_am_nr.cc +++ b/lib/src/rlc/rlc_am_nr.cc @@ -968,8 +968,9 @@ void rlc_am_nr_tx::get_buffer_state(uint32_t& n_bytes_new, uint32_t& n_bytes_pri } // Bytes needed for retx - if (not retx_queue->empty()) { - rlc_amd_retx_nr_t& retx = retx_queue->front(); + size_t n_retx = retx_queue->size(); + for (size_t i = 0; i < n_retx; i++) { + rlc_amd_retx_nr_t& retx = (*retx_queue)[i]; RlcDebug("buffer state - retx - SN=%d, Segment: %s, %d:%d", retx.sn, retx.is_segment ? "true" : "false", @@ -979,8 +980,7 @@ void rlc_am_nr_tx::get_buffer_state(uint32_t& n_bytes_new, uint32_t& n_bytes_pri int req_bytes = retx.segment_length; int hdr_req_bytes = (retx.is_segment && retx.current_so != 0) ? max_hdr_size : min_hdr_size; if (req_bytes <= 0) { - RlcError("in get_buffer_state(): Removing retx with SN=%d from queue", retx.sn); - retx_queue->pop(); + RlcError("buffer state - retx - invalid length=%d for SN=%d", req_bytes, retx.sn); } else { n_bytes_prio += (req_bytes + hdr_req_bytes); RlcDebug("buffer state - retx: %d bytes", n_bytes_prio); diff --git a/lib/test/rlc/rlc_am_nr_test.cc b/lib/test/rlc/rlc_am_nr_test.cc index a452f78b2..1488bece1 100644 --- a/lib/test/rlc/rlc_am_nr_test.cc +++ b/lib/test/rlc/rlc_am_nr_test.cc @@ -1367,8 +1367,7 @@ int segment_retx_and_loose_segments_test(rlc_am_nr_sn_size_t sn_size) rlc1.write_pdu(status_buf.msg, status_buf.N_bytes); // Check there are two Retx segments (a first one and a continued one) - TESTASSERT_EQ(pdu_size_first, rlc1.get_buffer_state()); // Fixme: get_buffer_state() - // TESTASSERT_EQ(pdu_size_first + pdu_size_continued, rlc1.get_buffer_state()); // Should be this + TESTASSERT_EQ(pdu_size_first + pdu_size_continued, rlc1.get_buffer_state()); } { @@ -1656,8 +1655,7 @@ int retx_segment_test(rlc_am_nr_sn_size_t sn_size) rlc1.write_pdu(status_buf.msg, status_buf.N_bytes); // Check there are 3 Retx segments (a first one and two continued ones) - TESTASSERT_EQ(pdu_size_first, rlc1.get_buffer_state()); // Fixme: get_buffer_state() - // TESTASSERT_EQ(pdu_size_first + 2 * pdu_size_continued, rlc1.get_buffer_state()); // Should be this + TESTASSERT_EQ(pdu_size_first + 2 * pdu_size_continued, rlc1.get_buffer_state()); } {