diff options
author | Max <msuraev@sysmocom.de> | 2017-05-16 16:10:45 +0200 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2017-05-26 07:55:52 +0000 |
commit | 9dabfa2c2b882bf4ce72c941f021f7a439de041a (patch) | |
tree | 6f060cdd5d071f9b156b5cbaafd1e167a4b3b71f /src/tbf_dl.cpp | |
parent | 356ac618f1f4b455e411507c4be4c9909fe927bb (diff) |
Cleanup FN scheduling
* replace magic number with defined constant
* move copy-pasted code to inline functions
* remove unused code
Change-Id: I6fee0714453d0c3c3f3f875f88daea2d9c477331
Related: OS#1524
Diffstat (limited to 'src/tbf_dl.cpp')
-rw-r--r-- | src/tbf_dl.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index d871c4d7..24c6385c 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -1170,30 +1170,27 @@ bool gprs_rlcmac_dl_tbf::have_data() const (llc_queue_size() > 0); } -int gprs_rlcmac_dl_tbf::frames_since_last_poll(unsigned fn) const +static inline int frames_since_last(int32_t last, unsigned fn) { - unsigned wrapped; - if (m_last_dl_poll_fn < 0) + unsigned wrapped = (fn + GSM_MAX_FN - last) % GSM_MAX_FN; + + if (last < 0) return -1; - wrapped = (fn + 2715648 - m_last_dl_poll_fn) % 2715648; - if (wrapped < 2715648/2) + if (wrapped < GSM_MAX_FN/2) return wrapped; - else - return wrapped - 2715648; + + return wrapped - GSM_MAX_FN; } -int gprs_rlcmac_dl_tbf::frames_since_last_drain(unsigned fn) const +int gprs_rlcmac_dl_tbf::frames_since_last_poll(unsigned fn) const { - unsigned wrapped; - if (m_last_dl_drained_fn < 0) - return -1; + return frames_since_last(m_last_dl_poll_fn, fn); +} - wrapped = (fn + 2715648 - m_last_dl_drained_fn) % 2715648; - if (wrapped < 2715648/2) - return wrapped; - else - return wrapped - 2715648; +int gprs_rlcmac_dl_tbf::frames_since_last_drain(unsigned fn) const +{ + return frames_since_last(m_last_dl_drained_fn, fn); } bool gprs_rlcmac_dl_tbf::keep_open(unsigned fn) const |