From 93c55d04e5917aa54ce37a9e997d0af87cc8be85 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Wed, 23 Dec 2015 16:29:07 +0100 Subject: rlc: Add and use mod_sns(bsn) method Currently there is only a mod_sns() method which is being used in expression like bsn_expr & win.mod_sns(). This only works, because it is known that mod_sns() is (sns() - 1) where sns() in turn is always 2^n. This is error prone, hard to read, and relies on window specifics that should be kept inside the respective module. This commit adds a mod_sns(uint bsn) method to gprs_rlc_ul_window and gprs_rlc_dl_window, that encapsulates and hides this optimized computation. Sponsored-by: On-Waves ehf --- src/tbf_ul.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/tbf_ul.cpp') diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index 271f87aa..cde361f9 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -145,7 +145,6 @@ int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( { int8_t rssi = meas->have_rssi ? meas->rssi : 0; - const uint16_t mod_sns = m_window.mod_sns(); const uint16_t ws = m_window.ws(); this->state_flags |= (1 << GPRS_RLCMAC_FLAG_UL_DATA); @@ -194,7 +193,7 @@ int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( LOGP(DRLCMACUL, LOGL_DEBUG, "- BSN %d out of window " "%d..%d (it's normal)\n", rdbi->bsn, m_window.v_q(), - (m_window.v_q() + ws - 1) & mod_sns); + m_window.mod_sns(m_window.v_q() + ws - 1)); } else if (m_window.is_received(rdbi->bsn)) { LOGP(DRLCMACUL, LOGL_DEBUG, "- BSN %d already received\n", rdbi->bsn); @@ -219,7 +218,7 @@ int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( LOGP(DRLCMACUL, LOGL_DEBUG, "- BSN %d storing in window (%d..%d)\n", rdbi->bsn, m_window.v_q(), - (m_window.v_q() + ws - 1) & mod_sns); + m_window.mod_sns(m_window.v_q() + ws - 1)); block = m_rlc.block(rdbi->bsn); block->block_info = *rdbi; block->cs = rlc->cs; @@ -296,7 +295,7 @@ int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( /* Retrieve LLC frames from blocks that are ready */ for (uint16_t i = 0; i < count; ++i) { - uint16_t index = (v_q_beg + i) & mod_sns; + uint16_t index = m_window.mod_sns(v_q_beg + i); assemble_forward_llc(m_rlc.block(index)); } @@ -304,7 +303,7 @@ int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged( if (this->state_is(GPRS_RLCMAC_FLOW) /* still in flow state */ && this->m_window.v_q() == this->m_window.v_r()) { /* if complete */ struct gprs_rlc_data *block = - m_rlc.block((m_window.v_r() - 1) & mod_sns); + m_rlc.block(m_window.mod_sns(m_window.v_r() - 1)); const struct gprs_rlc_ul_data_block_info *rdbi = &block->block_info; -- cgit v1.2.3