aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-24 00:38:54 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-11-26 20:57:24 +0100
commit8b16ae30fe0d6353ac7d39a2884f6716ff3efc5f (patch)
tree9c1b93a595f19b28e1a7111d7a4e9b82239ee56d
parentc03e38291aa0fe9bf8168776c08f915bf9e66efe (diff)
tbf/rlc: Move the marking of frames for resend into the v_b
-rw-r--r--src/rlc.cpp18
-rw-r--r--src/rlc.h2
-rw-r--r--src/tbf.cpp16
3 files changed, 24 insertions, 12 deletions
diff --git a/src/rlc.cpp b/src/rlc.cpp
index 1a055468..f6b13623 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -50,3 +50,21 @@ int gprs_rlc_v_b::resend_needed(const uint16_t v_a, const uint16_t v_s,
return -1;
}
+
+int gprs_rlc_v_b::mark_for_resend(const uint16_t v_a, const uint16_t v_s,
+ const uint16_t mod_sns,
+ const uint16_t mod_sns_half)
+{
+ int resend = 0;
+
+ for (uint8_t bsn = v_a; bsn != v_s; bsn = (bsn + 1) & mod_sns) {
+ uint16_t index = (bsn & mod_sns_half);
+ if (is_unacked(index)) {
+ /* mark to be re-send */
+ mark_resend(index);
+ resend += 1;
+ }
+ }
+
+ return resend;
+}
diff --git a/src/rlc.h b/src/rlc.h
index 3f65a2c2..6edfb921 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -46,6 +46,8 @@ struct gprs_rlc {
struct gprs_rlc_v_b {
int resend_needed(const uint16_t acked, const uint16_t sent,
const uint16_t mod_sns, const uint16_t mod_sns_half);
+ int mark_for_resend(const uint16_t acked, const uint16_t sent,
+ const uint16_t mod_sns, const uint16_t mod_sns_half);
/* Check for an individual frame */
bool is_unacked(int index) const;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index a279fcc2..3dc4146f 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -907,8 +907,6 @@ do_resend:
/* if the window has stalled, or transfer is complete,
* send an unacknowledged block */
if (state_is(GPRS_RLCMAC_FINISHED) || dl_window_stalled()) {
- int resend = 0;
-
if (state_is(GPRS_RLCMAC_FINISHED)) {
LOGP(DRLCMACDL, LOGL_DEBUG, "- Restarting at BSN %d, "
"because all blocks have been transmitted.\n",
@@ -936,16 +934,10 @@ do_resend:
}
/* cycle through all unacked blocks */
- for (bsn = dir.dl.v_a; bsn != dir.dl.v_s;
- bsn = (bsn + 1) & mod_sns) {
- index = (bsn & mod_sns_half);
- if (dir.dl.v_b.is_unacked(index)) {
- /* mark to be re-send */
- dir.dl.v_b.mark_resend(index);
- resend++;
- }
- }
- /* At this point there should be at leasst one unacked block
+ int resend = dir.dl.v_b.mark_for_resend(dir.dl.v_a, dir.dl.v_s,
+ mod_sns, mod_sns_half);
+
+ /* At this point there should be at least one unacked block
* to be resent. If not, this is an software error. */
if (resend == 0) {
LOGP(DRLCMACDL, LOGL_ERROR, "Software error: "