diff --git a/lib/include/srsran/rlc/rlc_am_nr.h b/lib/include/srsran/rlc/rlc_am_nr.h index c35cb4690..c69a921f6 100644 --- a/lib/include/srsran/rlc/rlc_am_nr.h +++ b/lib/include/srsran/rlc/rlc_am_nr.h @@ -100,12 +100,14 @@ public: void stop() final; + bool inside_tx_window(uint32_t sn); + private: rlc_am* parent = nullptr; rlc_am_nr_rx* rx = nullptr; - uint32_t mod_nr = 4096; - inline int32_t tx_mod_base_nr(uint32_t sn) { return ((int32_t)sn - (int32_t)st.tx_next_ack) % mod_nr; } + uint32_t mod_nr = 4096; + inline uint32_t tx_mod_base_nr(uint32_t sn) const; /**************************************************************************** * Configurable parameters diff --git a/lib/src/rlc/rlc_am_nr.cc b/lib/src/rlc/rlc_am_nr.cc index e7a879a34..7245de22e 100644 --- a/lib/src/rlc/rlc_am_nr.cc +++ b/lib/src/rlc/rlc_am_nr.cc @@ -381,6 +381,11 @@ uint8_t rlc_am_nr_tx::get_pdu_poll() return poll; } +bool rlc_am_nr_tx::do_status() +{ + return rx->get_do_status(); +} + void rlc_am_nr_tx::reestablish() { stop(); @@ -395,12 +400,20 @@ bool rlc_am_nr_tx::sdu_queue_is_full() void rlc_am_nr_tx::empty_queue() {} -bool rlc_am_nr_tx::do_status() +void rlc_am_nr_tx::stop() {} +/* + * Window helpers + */ +uint32_t rlc_am_nr_tx::tx_mod_base_nr(uint32_t sn) const { - return rx->get_do_status(); + return (sn - st.tx_next_ack) % mod_nr; } -void rlc_am_nr_tx::stop() {} +bool rlc_am_nr_tx::inside_tx_window(uint32_t sn) +{ + // TX_Next_Ack <= SN < TX_Next_Ack + AM_Window_Size + return tx_mod_base_nr(sn) < RLC_AM_NR_WINDOW_SIZE; +} /**************************************************************************** * Rx subclass implementation diff --git a/lib/test/rlc/rlc_am_nr_test.cc b/lib/test/rlc/rlc_am_nr_test.cc index ce2e51788..c9ebc469b 100644 --- a/lib/test/rlc/rlc_am_nr_test.cc +++ b/lib/test/rlc/rlc_am_nr_test.cc @@ -82,6 +82,10 @@ int window_checker_test() TESTASSERT_EQ(true, rx->inside_rx_window(sn_inside_above)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_below)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_above)); + TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_below)); + TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_above)); + TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_below)); + TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_above)); } rlc_am_nr_rx_state_t rx_st = {}; @@ -102,6 +106,10 @@ int window_checker_test() TESTASSERT_EQ(true, rx->inside_rx_window(sn_inside_above)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_below)); TESTASSERT_EQ(false, rx->inside_rx_window(sn_outside_above)); + TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_below)); + TESTASSERT_EQ(true, tx->inside_tx_window(sn_inside_above)); + TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_below)); + TESTASSERT_EQ(false, tx->inside_tx_window(sn_outside_above)); } return SRSRAN_SUCCESS; }