diff --git a/lib/include/srsran/rlc/rlc_am_nr.h b/lib/include/srsran/rlc/rlc_am_nr.h index a0d72a84f..bc566b18a 100644 --- a/lib/include/srsran/rlc/rlc_am_nr.h +++ b/lib/include/srsran/rlc/rlc_am_nr.h @@ -25,6 +25,8 @@ #include #include +const uint32_t mod_nr = 4096; + namespace srsran { /****************************** @@ -104,6 +106,8 @@ private: rlc_am* parent = nullptr; rlc_am_nr_rx* rx = nullptr; + inline int32_t tx_mod_base_nr(uint32_t sn) { return ((int32_t)sn - (int32_t)st.tx_next_ack) % mod_nr; } + /**************************************************************************** * Configurable parameters * Ref: 3GPP TS 38.322 v16.2.0 Section 7.4 @@ -166,6 +170,8 @@ private: rlc_am_nr_tx* tx = nullptr; byte_buffer_pool* pool = nullptr; + inline int32_t rx_mod_base_nr(uint32_t sn) { return ((int32_t)sn - (int32_t)rx_next) % mod_nr; } + // RX Window rlc_ringbuffer_t rx_window; diff --git a/lib/src/rlc/rlc_am_nr.cc b/lib/src/rlc/rlc_am_nr.cc index ae6741af2..ef3967d7b 100644 --- a/lib/src/rlc/rlc_am_nr.cc +++ b/lib/src/rlc/rlc_am_nr.cc @@ -20,9 +20,6 @@ #include #define RLC_AM_NR_WINDOW_SIZE 2048 -#define MOD_NR 4096 -#define RX_MOD_BASE_NR(x) ((((int32_t)x) - (int32_t)rx_next) % MOD_NR) -//#define TX_MOD_BASE_NR(x) (((x)-vt_a) % MOD_NR) namespace srsran { @@ -509,7 +506,7 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes) // 5.2.3.2.3 Actions when an AMD PDU is placed in the reception buffer // Update Rx_Next_Highest - if (RX_MOD_BASE_NR(header.sn) >= RX_MOD_BASE_NR(rx_next_highest)) { + if (rx_mod_base_nr(header.sn) >= rx_mod_base_nr(rx_next_highest)) { rx_next_highest = (header.sn + 1) % MOD; } @@ -519,7 +516,7 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes) * - update RX_Highest_Status to the SN of the first RLC SDU with SN > current RX_Highest_Status for which not * all bytes have been received. */ - if (RX_MOD_BASE_NR(header.sn) == RX_MOD_BASE_NR(rx_highest_status)) { + if (rx_mod_base_nr(header.sn) == rx_mod_base_nr(rx_highest_status)) { uint32_t sn_upd = 0; uint32_t window_top = rx_next + RLC_AM_WINDOW_SIZE; for (sn_upd = rx_highest_status; sn_upd < window_top; ++sn_upd) { @@ -541,7 +538,7 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes) * - update RX_Next to the SN of the first RLC SDU with SN > current RX_Next for which not all bytes * have been received. */ - if (RX_MOD_BASE_NR(header.sn) == RX_MOD_BASE_NR(rx_next)) { + if (rx_mod_base_nr(header.sn) == rx_mod_base_nr(rx_next)) { uint32_t sn_upd = 0; uint32_t window_top = rx_next + RLC_AM_WINDOW_SIZE; for (sn_upd = rx_next; sn_upd < window_top; ++sn_upd) { @@ -596,8 +593,8 @@ void rlc_am_nr_rx::handle_data_pdu(uint8_t* payload, uint32_t nof_bytes) bool rlc_am_nr_rx::inside_rx_window(uint32_t sn) { - return (RX_MOD_BASE_NR(sn) >= RX_MOD_BASE_NR(rx_next)) && - (RX_MOD_BASE_NR(sn) < RX_MOD_BASE_NR(rx_next + RLC_AM_NR_WINDOW_SIZE)); + return (rx_mod_base_nr(sn) >= rx_mod_base_nr(rx_next)) && + (rx_mod_base_nr(sn) < rx_mod_base_nr(rx_next + RLC_AM_NR_WINDOW_SIZE)); } /* @@ -615,7 +612,7 @@ uint32_t rlc_am_nr_rx::get_status_pdu(rlc_am_nr_status_pdu_t* status, uint32_t m byte_buffer_t tmp_buf; uint32_t i = status->ack_sn; - while (RX_MOD_BASE_NR(i) <= RX_MOD_BASE_NR(rx_highest_status)) { + while (rx_mod_base_nr(i) <= rx_mod_base_nr(rx_highest_status)) { if (rx_window.has_sn(i) || i == rx_highest_status) { // only update ACK_SN if this SN has been received, or if we reached the maximum possible SN status->ack_sn = i;