rlc/tbf: Move the code to raise V(R) into the ul_window handling

This commit is contained in:
Holger Hans Peter Freyther 2013-11-25 23:26:06 +01:00
parent 423dd2286b
commit cbb00ebd04
3 changed files with 22 additions and 14 deletions

View File

@ -149,3 +149,19 @@ void gprs_rlc_v_n::reset()
{
memset(m_v_n, 0x0, sizeof(m_v_n));
}
/* Raise V(R) to highest received sequence number not received. */
void gprs_rlc_ul_window::raise(const uint16_t bsn, gprs_rlc_v_n *v_n)
{
uint16_t offset_v_r;
offset_v_r = (bsn + 1 - v_r()) & mod_sns();
/* Positive offset, so raise. */
if (offset_v_r < (sns() >> 1)) {
while (offset_v_r--) {
if (offset_v_r) /* all except the received block */
v_n->mark_missing(v_r() & mod_sns_half());
raise(1);
}
LOGP(DRLCMACUL, LOGL_DEBUG, "- Raising V(R) to %d\n", v_r());
}
}

View File

@ -26,6 +26,7 @@
#define RLC_MAX_LEN 54 /* CS-4 including spare bits */
class BTS;
struct gprs_rlc_v_n;
struct gprs_rlc_data {
uint8_t *prepare(size_t block_data_length);
@ -87,6 +88,8 @@ struct gprs_rlc_ul_window {
bool is_in_window(uint8_t bsn) const;
void raise(int moves);
void raise(const uint16_t bsn, gprs_rlc_v_n *v_n);
void increment_q(int);
uint16_t m_v_r; /* receive state */

View File

@ -1553,7 +1553,7 @@ int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len)
int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len, int8_t rssi)
{
uint16_t offset_v_r, index;
uint16_t index;
struct rlc_ul_header *rh = (struct rlc_ul_header *)data;
int rc;
@ -1608,23 +1608,12 @@ int gprs_rlcmac_tbf::rcv_data_block_acknowledged(const uint8_t *data, size_t len
/* Write block to buffer and set receive state array. */
index = rh->bsn & mod_sns_half; /* memory index of block */
m_rlc.blocks[index].put_data(data, len);
dir.ul.v_n.mark_received(index);
LOGP(DRLCMACUL, LOGL_DEBUG, "- BSN %d storing in window (%d..%d)\n",
rh->bsn, dir.ul.window.v_q(),
(dir.ul.window.v_q() + ws - 1) & mod_sns);
/* Raise V(R) to highest received sequence number not received. */
offset_v_r = (rh->bsn + 1 - dir.ul.window.v_r()) & mod_sns;
if (offset_v_r < (sns() >> 1)) { /* Positive offset, so raise. */
while (offset_v_r--) {
if (offset_v_r) /* all except the received block */
dir.ul.v_n.mark_missing(dir.ul.window.v_r() & mod_sns_half);
this->dir.ul.window.raise(1);
/* Inc V(R). */
}
LOGP(DRLCMACUL, LOGL_DEBUG, "- Raising V(R) to %d\n",
this->dir.ul.window.v_r());
}
dir.ul.v_n.mark_received(index);
dir.ul.window.raise(rh->bsn, &dir.ul.v_n);
/* Raise V(Q) if possible, and retrieve LLC frames from blocks.
* This is looped until there is a gap (non received block) or