aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--src/tbf.cpp2
-rw-r--r--src/tbf.h2
-rw-r--r--src/tbf_dl.cpp21
3 files changed, 25 insertions, 0 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 388f82d..56804c3 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -470,6 +470,8 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
llist_add(&tbf->list.list, &bts->dl_tbfs);
tbf->bts->tbf_dl_created();
+ tbf->m_last_dl_poll_fn = -1;
+
gettimeofday(&tbf->m_bw.dl_bw_tv, NULL);
gettimeofday(&tbf->m_bw.dl_loss_tv, NULL);
diff --git a/src/tbf.h b/src/tbf.h
index ba7af36..ca5fedf 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -325,6 +325,7 @@ struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf {
void request_dl_ack();
bool need_control_ts() const;
bool have_data() const;
+ int frames_since_last_poll(unsigned fn) const;
bool is_control_ts(uint8_t ts) const {
return ts == control_ts;
@@ -342,6 +343,7 @@ struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf {
int32_t m_tx_counter; /* count all transmitted blocks */
uint8_t m_wait_confirm; /* wait for CCCH IMM.ASS cnf */
bool m_dl_ack_requested;
+ int32_t m_last_dl_poll_fn;
struct {
struct timeval dl_bw_tv; /* timestamp for dl bw calculation */
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index c9ad058..0630ba1 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;
+}
+