aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-24 22:43:03 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-26 21:00:51 +0100
commit6ab5b24be4fe42ae8843b4843f4bfcf550484e12 (patch)
tree45a8cb5a22d7e0195883a19d57d5e15bb8d88a09
parent7decedcbf895e70517ca4a9abc9b7e583e1d328e (diff)
tbf/rlc: Move the check if something is in the window out.
-rw-r--r--src/rlc.h13
-rw-r--r--src/tbf.cpp9
2 files changed, 16 insertions, 6 deletions
diff --git a/src/rlc.h b/src/rlc.h
index e46c5f0..09712fe 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -83,6 +83,8 @@ struct gprs_rlc_ul_window {
const uint16_t v_r() const;
const uint16_t v_q() const;
+ bool is_in_window(uint8_t bsn) const;
+
void raise(int moves);
void increment_q(int);
@@ -300,6 +302,17 @@ inline const int16_t gprs_rlc_dl_window::distance() const
return (m_v_s - m_v_a) & mod_sns();
}
+inline bool gprs_rlc_ul_window::is_in_window(uint8_t bsn) const
+{
+ uint16_t offset_v_q;
+
+ /* current block relative to lowest unreceived block */
+ offset_v_q = (bsn - m_v_q) & mod_sns();
+ /* If out of window (may happen if blocks below V(Q) are received
+ * again. */
+ return offset_v_q < ws();
+}
+
inline const uint16_t gprs_rlc_ul_window::sns() const
{
return 128;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 694a41c..21b8e65 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -1520,7 +1520,7 @@ void gprs_rlcmac_tbf::update_tlli(uint32_t tlli)
int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len, int8_t rssi)
{
- uint16_t offset_v_q, offset_v_r, index;
+ uint16_t offset_v_r, index;
struct rlc_ul_header *rh = (struct rlc_ul_header *)data;
int rc;
@@ -1601,17 +1601,14 @@ int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len
/* Increment RX-counter */
this->dir.ul.rx_counter++;
- /* current block relative to lowest unreceived block */
- offset_v_q = (rh->bsn - this->dir.ul.window.v_q()) & mod_sns;
- /* If out of window (may happen if blocks below V(Q) are received
- * again. */
- if (offset_v_q >= dir.ul.window.ws()) {
+ if (!dir.ul.window.is_in_window(rh->bsn)) {
LOGP(DRLCMACUL, LOGL_DEBUG, "- BSN %d out of window "
"%d..%d (it's normal)\n", rh->bsn,
dir.ul.window.v_q(),
(dir.ul.window.v_q() + ws - 1) & mod_sns);
return 0;
}
+
/* Write block to buffer and set receive state array. */
index = rh->bsn & mod_sns_half; /* memory index of block */
memcpy(m_rlc.blocks[index].block, data, len); /* Copy block. */