From 5bb6cdec1e8167b9c0ae823f55513f22573ad582 Mon Sep 17 00:00:00 2001 From: Robert Falkenberg Date: Sat, 12 Mar 2022 07:44:51 +0100 Subject: [PATCH] lib,rlc_am_nr: use std:vector for nacks in rlc_am_nr_status_pdu_t - Also create tx_status a member to avoid frequent allocations for each created PDU. - Remove unused member nack_range from rlc_am_nr_status_pdu_t. --- lib/include/srsran/rlc/rlc_am_nr.h | 3 ++- lib/include/srsran/rlc/rlc_am_nr_packing.h | 24 +++++++++++++++------- lib/include/srsran/rlc/rlc_common.h | 3 ++- lib/src/rlc/rlc_am_nr.cc | 6 ++++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/include/srsran/rlc/rlc_am_nr.h b/lib/include/srsran/rlc/rlc_am_nr.h index a5312a89d..de65f0f3e 100644 --- a/lib/include/srsran/rlc/rlc_am_nr.h +++ b/lib/include/srsran/rlc/rlc_am_nr.h @@ -149,10 +149,11 @@ private: struct rlc_am_nr_tx_state_t st = {}; std::unique_ptr > tx_window; - // Queues and buffers + // Queues, buffers and container std::unique_ptr > retx_queue; uint32_t sdu_under_segmentation_sn = INVALID_RLC_SN; // SN of the SDU currently being segmented. pdcp_sn_vector_t notify_info_vec; + rlc_am_nr_status_pdu_t tx_status; // Helper constants uint32_t min_hdr_size = 2; diff --git a/lib/include/srsran/rlc/rlc_am_nr_packing.h b/lib/include/srsran/rlc/rlc_am_nr_packing.h index 457b14e8a..574d89c17 100644 --- a/lib/include/srsran/rlc/rlc_am_nr_packing.h +++ b/lib/include/srsran/rlc/rlc_am_nr_packing.h @@ -78,13 +78,23 @@ struct rlc_amd_tx_sdu_nr_t { }; ///< AM NR Status PDU header (perhaps merge with LTE version) -typedef struct { - rlc_am_nr_control_pdu_type_t cpt; - uint32_t ack_sn; ///< SN of the next not received RLC Data PDU - uint16_t N_nack; ///< number of NACKs - uint8_t nack_range; ///< number of consecutively lost RLC SDUs starting from and including NACK_SN - rlc_status_nack_t nacks[RLC_AM_NR_MAX_NACKS]; -} rlc_am_nr_status_pdu_t; +struct rlc_am_nr_status_pdu_t { + rlc_am_nr_control_pdu_type_t cpt; + uint32_t ack_sn; ///< SN of the next not received RLC Data PDU + uint16_t N_nack; ///< number of NACKs + std::vector nacks; + + rlc_am_nr_status_pdu_t() : + cpt(rlc_am_nr_control_pdu_type_t::status_pdu), ack_sn(INVALID_RLC_SN), N_nack(0), nacks(RLC_AM_NR_TYP_NACKS) + {} + void reset() + { + cpt = rlc_am_nr_control_pdu_type_t::status_pdu; + ack_sn = INVALID_RLC_SN; + N_nack = 0; + nacks.clear(); + } +}; /**************************************************************************** * Header pack/unpack helper functions for NR diff --git a/lib/include/srsran/rlc/rlc_common.h b/lib/include/srsran/rlc/rlc_common.h index 0e1dacc94..796704823 100644 --- a/lib/include/srsran/rlc/rlc_common.h +++ b/lib/include/srsran/rlc/rlc_common.h @@ -34,7 +34,8 @@ namespace srsran { #define RLC_MAX_SDU_SIZE ((1 << 11) - 1) // Length of LI field is 11bits #define RLC_AM_MIN_DATA_PDU_SIZE (3) // AMD PDU with 10 bit SN (length of LI field is 11 bits) (No LI) -#define RLC_AM_NR_MAX_NACKS 2048 +#define RLC_AM_NR_TYP_NACKS 512 // Expected number of NACKs in status PDU before expanding space by alloc +#define RLC_AM_NR_MAX_NACKS 2048 // Maximum number of NACKs in status PDU #define RlcDebug(fmt, ...) logger.debug("%s: " fmt, rb_name, ##__VA_ARGS__) #define RlcInfo(fmt, ...) logger.info("%s: " fmt, rb_name, ##__VA_ARGS__) diff --git a/lib/src/rlc/rlc_am_nr.cc b/lib/src/rlc/rlc_am_nr.cc index 643af2d05..c2cf5fc52 100644 --- a/lib/src/rlc/rlc_am_nr.cc +++ b/lib/src/rlc/rlc_am_nr.cc @@ -676,8 +676,8 @@ uint32_t rlc_am_nr_tx::get_retx_expected_hdr_len(const rlc_amd_retx_nr_t& retx) uint32_t rlc_am_nr_tx::build_status_pdu(byte_buffer_t* payload, uint32_t nof_bytes) { RlcInfo("generating status PDU. Bytes available:%d", nof_bytes); - rlc_am_nr_status_pdu_t tx_status; - int pdu_len = rx->get_status_pdu(&tx_status, nof_bytes); + tx_status.reset(); + int pdu_len = rx->get_status_pdu(&tx_status, nof_bytes); if (pdu_len == SRSRAN_ERROR) { RlcDebug("deferred status PDU. Cause: Failed to acquire rx lock"); pdu_len = 0; @@ -1286,6 +1286,8 @@ uint32_t rlc_am_nr_rx::get_status_pdu(rlc_am_nr_status_pdu_t* status, uint32_t m } } + // TODO: add check to not exceed status->N_nack >= RLC_AM_NR_MAX_NACKS + // make sure we don't exceed grant size (FIXME) rlc_am_nr_write_status_pdu(*status, cfg.rx_sn_field_length, &tmp_buf); // TODO