aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf_dl.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-03-20 14:53:54 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-03-25 12:12:27 +0100
commit005ee7f8626d4733e8fa01f3589154287ed163ed (patch)
tree2750793d56cf9eac54f5e66933f7a716162e7086 /src/tbf_dl.cpp
parent2493c660e9cbede4ac43f2584c0a8e6d8625e1dd (diff)
tbf: Add frames_since_last_poll method
This functions calculates the number of frames that have passed since the last DL poll (RRBP flag set) has been sent. It returns a value less than zero (fn_now - fn_sched) if the block has been scheduled but not yet sent. If the function is called before the first data block has been sent it will return -1. If the function is called before the first DL poll is sent, it returns the number of frames since the first data block has been sent. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/tbf_dl.cpp')
-rw-r--r--src/tbf_dl.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index c9ad058c..0630ba17 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -484,6 +484,11 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
len = m_rlc.block(index)->len;
rh = (struct rlc_dl_header *)data;
+ /* If the TBF has just started, relate frames_since_last_poll to the
+ * current fn */
+ if (m_last_dl_poll_fn < 0)
+ m_last_dl_poll_fn = fn;
+
need_poll = state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK);
/* Clear Polling, if still set in history buffer */
rh->s_p = 0;
@@ -538,6 +543,8 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
/* set polling in header */
rh->rrbp = 0; /* N+13 */
rh->s_p = 1; /* Polling */
+
+ m_last_dl_poll_fn = poll_fn;
}
}
@@ -730,3 +737,17 @@ bool gprs_rlcmac_dl_tbf::have_data() const
{
return m_llc.chunk_size() > 0 || !llist_empty(&m_llc.queue);
}
+
+int gprs_rlcmac_dl_tbf::frames_since_last_poll(unsigned fn) const
+{
+ unsigned wrapped;
+ if (m_last_dl_poll_fn < 0)
+ return -1;
+
+ wrapped = (fn + 2715648 - m_last_dl_poll_fn) % 2715648;
+ if (wrapped < 2715648/2)
+ return wrapped;
+ else
+ return wrapped - 2715648;
+}
+