rlc: Make the update loop more understandable
Add bitnum_to_bsn() as a convenience function to get the BSN, use it in the update handling and ignore rbb for values outside of our tx window.
This commit is contained in:
parent
48df40d2a4
commit
cc5a4cbe9b
18
src/rlc.cpp
18
src/rlc.cpp
|
@ -84,19 +84,23 @@ int gprs_rlc_v_b::count_unacked(const gprs_rlc_dl_window &w)
|
||||||
return unacked;
|
return unacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t bitnum_to_bsn(int bitnum, uint16_t ssn, uint16_t mod_sns)
|
||||||
|
{
|
||||||
|
return (ssn - 1 - bitnum) & mod_sns;
|
||||||
|
}
|
||||||
|
|
||||||
void gprs_rlc_v_b::update(BTS *bts, char *show_rbb, uint8_t ssn,
|
void gprs_rlc_v_b::update(BTS *bts, char *show_rbb, uint8_t ssn,
|
||||||
const gprs_rlc_dl_window &w,
|
const gprs_rlc_dl_window &w,
|
||||||
uint16_t *lost, uint16_t *received)
|
uint16_t *lost, uint16_t *received)
|
||||||
{
|
{
|
||||||
uint16_t bsn;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* SSN - 1 is in range V(A)..V(S)-1 */
|
/* SSN - 1 is in range V(A)..V(S)-1 */
|
||||||
for (i = 63, bsn = (ssn - 1) & w.mod_sns();
|
for (int bitpos = 0; bitpos < w.ws(); bitpos++) {
|
||||||
i >= 0 && bsn != ((w.v_a() - 1) & w.mod_sns());
|
uint16_t bsn = bitnum_to_bsn(bitpos, ssn, w.mod_sns());
|
||||||
i--, bsn = (bsn - 1) & w.mod_sns()) {
|
|
||||||
|
|
||||||
if (show_rbb[i] == 'R') {
|
if (bsn == ((w.v_a() - 1) & w.mod_sns()))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (show_rbb[w.ws() - 1 - bitpos] == 'R') {
|
||||||
LOGP(DRLCMACDL, LOGL_DEBUG, "- got ack for BSN=%d\n", bsn);
|
LOGP(DRLCMACDL, LOGL_DEBUG, "- got ack for BSN=%d\n", bsn);
|
||||||
if (!is_acked(bsn))
|
if (!is_acked(bsn))
|
||||||
*received += 1;
|
*received += 1;
|
||||||
|
|
Loading…
Reference in New Issue