aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2016-01-19 14:07:33 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-08 00:45:35 +0100
commitdb88380b76e70db4ab3d895102b3e164bf8efe3d (patch)
tree2ba78359ce45849e3377d96382860cf99db0b0ac
parent3b1c5537731cc63125f1b82c0e6149372a7fe0da (diff)
rlc: Add unified gprs_rlc_window parent class
Currently gprs_rlc_ul_window and gprs_rlc_dl_window are completely separate classes, containing several identical members and methods. This commit add a shared parent class containing WS and SNS handling. Sponsored-by: On-Waves ehf
-rw-r--r--src/bts.h2
-rw-r--r--src/rlc.cpp20
-rw-r--r--src/rlc.h78
3 files changed, 32 insertions, 68 deletions
diff --git a/src/bts.h b/src/bts.h
index e467c1e..c6247be 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -188,6 +188,8 @@ struct gprs_rlcmac_bts {
uint8_t cs_adj_lower_limit;
struct {int16_t low; int16_t high;} cs_lqual_ranges[4];
uint16_t cs_downgrade_threshold; /* downgrade if less packets left (DL) */
+ uint16_t egprs_ws_base;
+ uint16_t egprs_ws_lin;
/* State for dynamic algorithm selection */
int multislot_disabled;
diff --git a/src/rlc.cpp b/src/rlc.cpp
index 6d3cfd5..e4a9563 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -55,22 +55,6 @@ void gprs_rlc_dl_window::reset()
m_v_b.reset();
}
-void gprs_rlc_dl_window::set_sns(uint16_t sns)
-{
- OSMO_ASSERT(sns >= RLC_GPRS_SNS);
- OSMO_ASSERT(sns <= RLC_MAX_SNS);
- /* check for 2^n */
- OSMO_ASSERT((sns & (-sns)) == sns);
- m_sns = sns;
-}
-
-void gprs_rlc_dl_window::set_ws(uint16_t ws)
-{
- OSMO_ASSERT(ws >= RLC_GPRS_SNS/2);
- OSMO_ASSERT(ws <= RLC_MAX_SNS/2);
- m_ws = ws;
-}
-
int gprs_rlc_dl_window::resend_needed()
{
for (uint16_t bsn = v_a(); bsn != v_s(); bsn = mod_sns(bsn + 1)) {
@@ -219,7 +203,7 @@ void gprs_rlc_v_n::reset()
m_v_n[i] = GPRS_RLC_UL_BSN_INVALID;
}
-void gprs_rlc_ul_window::set_sns(uint16_t sns)
+void gprs_rlc_window::set_sns(uint16_t sns)
{
OSMO_ASSERT(sns >= RLC_GPRS_SNS);
OSMO_ASSERT(sns <= RLC_MAX_SNS);
@@ -228,7 +212,7 @@ void gprs_rlc_ul_window::set_sns(uint16_t sns)
m_sns = sns;
}
-void gprs_rlc_ul_window::set_ws(uint16_t ws)
+void gprs_rlc_window::set_ws(uint16_t ws)
{
OSMO_ASSERT(ws >= RLC_GPRS_SNS/2);
OSMO_ASSERT(ws <= RLC_MAX_SNS/2);
diff --git a/src/rlc.h b/src/rlc.h
index 3f599d4..3a7f1a1 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -151,13 +151,26 @@ private:
/**
* TODO: The UL/DL code could/should share a base class.
*/
-struct gprs_rlc_dl_window {
- void reset();
+class gprs_rlc_window {
+public:
+ gprs_rlc_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;
+ void set_sns(uint16_t sns);
+ void set_ws(uint16_t ws);
+
+protected:
+ uint16_t m_sns;
+ uint16_t m_ws;
+};
+
+struct gprs_rlc_dl_window: public gprs_rlc_window {
+ void reset();
+
bool window_stalled() const;
bool window_empty() const;
@@ -186,13 +199,7 @@ struct gprs_rlc_dl_window {
gprs_rlc_v_b m_v_b;
- void set_sns(uint16_t sns);
- void set_ws(uint16_t ws);
-
gprs_rlc_dl_window();
-private:
- uint16_t m_sns;
- uint16_t m_ws;
};
struct gprs_rlc_v_n {
@@ -210,12 +217,7 @@ private:
gprs_rlc_ul_bsn_state m_v_n[RLC_MAX_SNS/2]; /* receive state array */
};
-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;
-
+struct gprs_rlc_ul_window: public gprs_rlc_window {
const uint16_t v_r() const;
const uint16_t v_q() const;
@@ -239,13 +241,7 @@ struct gprs_rlc_ul_window {
gprs_rlc_v_n m_v_n;
- void set_sns(uint16_t sns);
- void set_ws(uint16_t ws);
-
gprs_rlc_ul_window();
-private:
- uint16_t m_sns;
- uint16_t m_ws;
};
extern "C" {
@@ -388,34 +384,38 @@ inline void gprs_rlc_v_b::mark_invalid(int bsn)
return mark(bsn, GPRS_RLC_DL_BSN_INVALID);
}
-inline gprs_rlc_dl_window::gprs_rlc_dl_window()
- : m_v_s(0)
- , m_v_a(0)
- , m_sns(RLC_GPRS_SNS)
+inline gprs_rlc_window::gprs_rlc_window()
+ : m_sns(RLC_GPRS_SNS)
, m_ws(RLC_GPRS_WS)
{
}
-inline const uint16_t gprs_rlc_dl_window::sns() const
+inline const uint16_t gprs_rlc_window::sns() const
{
return m_sns;
}
-inline const uint16_t gprs_rlc_dl_window::ws() const
+inline const uint16_t gprs_rlc_window::ws() const
{
return m_ws;
}
-inline const uint16_t gprs_rlc_dl_window::mod_sns() const
+inline const uint16_t gprs_rlc_window::mod_sns() const
{
return sns() - 1;
}
-inline const uint16_t gprs_rlc_dl_window::mod_sns(uint16_t bsn) const
+inline const uint16_t gprs_rlc_window::mod_sns(uint16_t bsn) const
{
return bsn & mod_sns();
}
+inline gprs_rlc_dl_window::gprs_rlc_dl_window()
+ : m_v_s(0)
+ , m_v_a(0)
+{
+}
+
inline const uint16_t gprs_rlc_dl_window::v_s() const
{
return m_v_s;
@@ -459,8 +459,6 @@ inline const int16_t gprs_rlc_dl_window::distance() const
inline gprs_rlc_ul_window::gprs_rlc_ul_window()
: m_v_r(0)
, m_v_q(0)
- , m_sns(RLC_GPRS_SNS)
- , m_ws(RLC_GPRS_WS)
{
}
@@ -484,26 +482,6 @@ inline bool gprs_rlc_ul_window::is_received(uint16_t bsn) const
return is_in_window(bsn) && m_v_n.is_received(bsn) && offset_v_r < ws();
}
-inline const uint16_t gprs_rlc_ul_window::sns() const
-{
- return m_sns;
-}
-
-inline const uint16_t gprs_rlc_ul_window::ws() const
-{
- return m_ws;
-}
-
-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;