aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf_dl.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-12-23 16:29:07 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-01 13:58:12 +0100
commit93c55d04e5917aa54ce37a9e997d0af87cc8be85 (patch)
tree25d4261bbed94b8fce8b5d826287955ef44011e9 /src/tbf_dl.cpp
parent2b3121eebf1ec6cbcb25422d6a254d2b4fc15d18 (diff)
rlc: Add and use mod_sns(bsn) method
Currently there is only a mod_sns() method which is being used in expression like bsn_expr & win.mod_sns(). This only works, because it is known that mod_sns() is (sns() - 1) where sns() in turn is always 2^n. This is error prone, hard to read, and relies on window specifics that should be kept inside the respective module. This commit adds a mod_sns(uint bsn) method to gprs_rlc_ul_window and gprs_rlc_dl_window, that encapsulates and hides this optimized computation. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/tbf_dl.cpp')
-rw-r--r--src/tbf_dl.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 70194f7c..8bac99f3 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -703,9 +703,9 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
return dl_msg;
}
-static uint16_t bitnum_to_bsn(int bitnum, uint16_t ssn, uint16_t mod_sns)
+static uint16_t bitnum_to_bsn(int bitnum, uint16_t ssn)
{
- return (ssn - 1 - bitnum) & mod_sns;
+ return ssn - 1 - bitnum;
}
int gprs_rlcmac_dl_tbf::analyse_errors(char *show_rbb, uint8_t ssn,
@@ -724,9 +724,9 @@ int gprs_rlcmac_dl_tbf::analyse_errors(char *show_rbb, uint8_t ssn,
for (int bitpos = 0; bitpos < m_window.ws(); bitpos++) {
bool is_received = show_rbb[m_window.ws() - 1 - bitpos] == 'R';
- bsn = bitnum_to_bsn(bitpos, ssn, m_window.mod_sns());
+ bsn = m_window.mod_sns(bitnum_to_bsn(bitpos, ssn));
- if (bsn == ((m_window.v_a() - 1) & m_window.mod_sns())) {
+ if (bsn == m_window.mod_sns(m_window.v_a() - 1)) {
info[bitpos] = '$';
break;
}
@@ -794,19 +794,18 @@ int gprs_rlcmac_dl_tbf::update_window(const uint8_t ssn, const uint8_t *rbb)
uint16_t lost = 0, received = 0;
char show_rbb[65];
char show_v_b[RLC_MAX_SNS + 1];
- const uint16_t mod_sns = m_window.mod_sns();
int error_rate;
struct ana_result ana_res;
Decoding::extract_rbb(rbb, show_rbb);
/* show received array in debug (bit 64..1) */
LOGP(DRLCMACDL, LOGL_DEBUG, "- ack: (BSN=%d)\"%s\""
- "(BSN=%d) R=ACK I=NACK\n", (ssn - 64) & mod_sns,
- show_rbb, (ssn - 1) & mod_sns);
+ "(BSN=%d) R=ACK I=NACK\n", m_window.mod_sns(ssn - 64),
+ show_rbb, m_window.mod_sns(ssn - 1));
/* apply received array to receive state (SSN-64..SSN-1) */
/* calculate distance of ssn from V(S) */
- dist = (m_window.v_s() - ssn) & mod_sns;
+ dist = m_window.mod_sns(m_window.v_s() - ssn);
/* check if distance is less than distance V(A)..V(S) */
if (dist >= m_window.distance()) {
/* this might happpen, if the downlink assignment