From 55cf994c29754fb18852fffee96f00c436d70ee3 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 13 Nov 2013 18:15:45 +0100 Subject: [PATCH] tbf: Re-use the code that is re-using the tbf Address the fixme and re-use the code. Fix the counting in the final ack case and provide a log message in the other case. Prefix it with the tbf name --- src/tbf.cpp | 49 +++++++++++++++++++++++++------------------------ src/tbf.h | 1 + 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/tbf.cpp b/src/tbf.cpp index 63c8070d..76a9c412 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -98,17 +98,8 @@ int gprs_rlcmac_tbf::append_data(const uint8_t ms_class, LOGP(DRLCMAC, LOGL_DEBUG, "%s in WAIT RELEASE state " "(T3193), so reuse TBF\n", tbf_name(this)); - bts->tbf_reused(); - m_llc.put_frame(data, len); - bts->llc_frame_sched(); - /* reset rlc states */ - memset(&dir.dl, 0, sizeof(dir.dl)); - /* keep to flags */ - state_flags &= GPRS_RLCMAC_FLAG_TO_MASK; - state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH); tbf_update_ms_class(this, ms_class); - update(); - bts->trigger_dl_ass(this, this, NULL); + reuse_tbf(data, len); } else { /* the TBF exists, so we must write it in the queue * we prepend lifetime in front of PDU */ @@ -1536,21 +1527,10 @@ int gprs_rlcmac_tbf::snd_dl_ack(uint8_t final, uint8_t ssn, uint8_t *rbb) return 0; } - #warning "Copy and paste on the sender path" - m_llc.put_frame(msg->data, msg->len); - bts->llc_frame_sched(); - msgb_free(msg); - /* we have a message, so we trigger downlink assignment, and there - * set the state to ASSIGN. also we set old_downlink, because we - * re-use this tbf. */ - LOGP(DRLCMAC, LOGL_DEBUG, "Trigger dowlink assignment on PACCH, " - "because another LLC PDU has arrived in between\n"); - memset(&dir.dl, 0, sizeof(dir.dl)); /* reset RLC states */ - state_flags &= GPRS_RLCMAC_FLAG_TO_MASK; /* keep TO flags */ - state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH); - update(); - bts->trigger_dl_ass(this, this, NULL); + /* we have more data so we will re-use this tbf */ + reuse_tbf(msg->data, msg->len); + msgb_free(msg); return 0; } @@ -1851,3 +1831,24 @@ const char *tbf_name(gprs_rlcmac_tbf *tbf) return buf; } + +void gprs_rlcmac_tbf::reuse_tbf(const uint8_t *data, const uint16_t len) +{ + bts->tbf_reused(); + m_llc.put_frame(data, len); + bts->llc_frame_sched(); + + /* reset rlc states */ + memset(&dir.dl, 0, sizeof(dir.dl)); + + /* keep to flags */ + state_flags &= GPRS_RLCMAC_FLAG_TO_MASK; + state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH); + + update(); + + LOGP(DRLCMAC, LOGL_DEBUG, "%s Trigger dowlink assignment on PACCH, " + "because another LLC PDU has arrived in between\n", + tbf_name(this)); + bts->trigger_dl_ass(this, this, NULL); +} diff --git a/src/tbf.h b/src/tbf.h index 9bb40a33..95186709 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -240,6 +240,7 @@ struct gprs_rlcmac_tbf { char m_imsi[16]; protected: + void reuse_tbf(const uint8_t *data, const uint16_t len); gprs_rlcmac_bts *bts_data() const; int append_data(const uint8_t ms_class,