aboutsummaryrefslogtreecommitdiffstats
path: root/src/rlc.h
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-12-23 16:29:07 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-01 13:58:12 +0100
commit93c55d04e5917aa54ce37a9e997d0af87cc8be85 (patch)
tree25d4261bbed94b8fce8b5d826287955ef44011e9 /src/rlc.h
parent2b3121eebf1ec6cbcb25422d6a254d2b4fc15d18 (diff)
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
Diffstat (limited to 'src/rlc.h')
-rw-r--r--src/rlc.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/rlc.h b/src/rlc.h
index f2acb98a..4905aa1f 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -140,6 +140,7 @@ private:
struct gprs_rlc_dl_window {
void reset();
const uint16_t mod_sns() const;
+ const uint16_t mod_sns(uint16_t bsn) const;
const uint16_t sns() const;
const uint16_t ws() const;
@@ -186,6 +187,7 @@ private:
struct gprs_rlc_ul_window {
const uint16_t mod_sns() const;
+ const uint16_t mod_sns(uint16_t bsn) const;
const uint16_t sns() const;
const uint16_t ws() const;
@@ -353,6 +355,11 @@ inline const uint16_t gprs_rlc_dl_window::mod_sns() const
return sns() - 1;
}
+inline const uint16_t gprs_rlc_dl_window::mod_sns(uint16_t bsn) const
+{
+ return bsn & mod_sns();
+}
+
inline const uint16_t gprs_rlc_dl_window::v_s() const
{
return m_v_s;
@@ -360,7 +367,7 @@ inline const uint16_t gprs_rlc_dl_window::v_s() const
inline const uint16_t gprs_rlc_dl_window::v_s_mod(int offset) const
{
- return (m_v_s + offset) & mod_sns();
+ return mod_sns(m_v_s + offset);
}
inline const uint16_t gprs_rlc_dl_window::v_a() const
@@ -370,7 +377,7 @@ inline const uint16_t gprs_rlc_dl_window::v_a() const
inline bool gprs_rlc_dl_window::window_stalled() const
{
- return ((m_v_s - m_v_a) & mod_sns()) == ws();
+ return (mod_sns(m_v_s - m_v_a)) == ws();
}
inline bool gprs_rlc_dl_window::window_empty() const
@@ -428,6 +435,11 @@ inline const uint16_t gprs_rlc_ul_window::mod_sns() const
return sns() - 1;
}
+inline const uint16_t gprs_rlc_ul_window::mod_sns(uint16_t bsn) const
+{
+ return bsn & mod_sns();
+}
+
inline const uint16_t gprs_rlc_ul_window::v_r() const
{
return m_v_r;
@@ -445,12 +457,12 @@ inline const uint16_t gprs_rlc_ul_window::ssn() const
inline void gprs_rlc_ul_window::raise_v_r_to(int moves)
{
- m_v_r = (m_v_r + moves) & mod_sns();
+ m_v_r = mod_sns(m_v_r + moves);
}
inline void gprs_rlc_ul_window::raise_v_q(int incr)
{
- m_v_q = (m_v_q + incr) & mod_sns();
+ m_v_q = mod_sns(m_v_q + incr);
}
inline void gprs_rlc_v_n::mark_received(int bsn)