From 489a2b35d87610fb077a51de696555a54e5fb247 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 28 May 2015 19:07:01 +0200 Subject: tbf: Move the LLC queue to GprsMs Currently the enqueued DL LLC messages which have not yet passed to RLC/MAC encoding are eventually copied from one TBF to the next one (see gprs_rlcmac_dl_tbf::reuse_tbf). Since the enqueued LLC messages are related to a specific MS, they should be stored at that layer. This commit moves the gprs_llc_queue object to GprsMs and changes the TBF's accessor methods accordingly. The LLC copying code is removed from gprs_rlcmac_dl_tbf::reuse_tbf(). Sponsored-by: On-Waves ehf --- src/gprs_ms.cpp | 2 ++ src/gprs_ms.h | 16 ++++++++++++++++ src/tbf.cpp | 12 ++++++++++-- src/tbf.h | 11 ----------- src/tbf_dl.cpp | 9 +++------ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/gprs_ms.cpp b/src/gprs_ms.cpp index f5b92d2f..d047cf57 100644 --- a/src/gprs_ms.cpp +++ b/src/gprs_ms.cpp @@ -81,6 +81,7 @@ GprsMs::GprsMs(uint32_t tlli) : m_imsi[0] = 0; memset(&m_timer, 0, sizeof(m_timer)); m_timer.cb = GprsMs::timeout; + m_llc_queue.init(); } GprsMs::~GprsMs() @@ -99,6 +100,7 @@ GprsMs::~GprsMs() m_dl_tbf->set_ms(NULL); m_dl_tbf = NULL; } + m_llc_queue.clear(NULL); } void* GprsMs::operator new(size_t size) diff --git a/src/gprs_ms.h b/src/gprs_ms.h index db55badf..5c42c50a 100644 --- a/src/gprs_ms.h +++ b/src/gprs_ms.h @@ -25,6 +25,7 @@ struct gprs_rlcmac_dl_tbf; struct gprs_rlcmac_ul_tbf; #include "cxx_linuxlist.h" +#include "llc.h" extern "C" { #include @@ -67,6 +68,9 @@ public: uint8_t ta() const; void set_ta(uint8_t ta); + gprs_llc_queue *llc_queue(); + const gprs_llc_queue *llc_queue() const; + void set_timeout(unsigned secs); void attach_tbf(gprs_rlcmac_tbf *tbf); @@ -104,6 +108,7 @@ private: /* store IMSI for look-up and PCH retransmission */ char m_imsi[16]; uint8_t m_ta; + gprs_llc_queue m_llc_queue; bool m_is_idle; int m_ref; @@ -139,3 +144,14 @@ inline void GprsMs::set_timeout(unsigned secs) { m_delay = secs; } + +inline gprs_llc_queue *GprsMs::llc_queue() +{ + return &m_llc_queue; +} + +inline const gprs_llc_queue *GprsMs::llc_queue() const +{ + return &m_llc_queue; +} + diff --git a/src/tbf.cpp b/src/tbf.cpp index dc26cc70..136226cb 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -102,6 +102,16 @@ void gprs_rlcmac_tbf::set_ta(uint8_t ta) m_ta = ta; } +gprs_llc_queue *gprs_rlcmac_tbf::llc_queue() +{ + return m_ms ? m_ms->llc_queue() : NULL; +} + +const gprs_llc_queue *gprs_rlcmac_tbf::llc_queue() const +{ + return m_ms ? m_ms->llc_queue() : NULL; +} + void gprs_rlcmac_tbf::set_ms(GprsMs *ms) { if (m_ms == ms) @@ -219,7 +229,6 @@ void tbf_free(struct gprs_rlcmac_tbf *tbf) tbf_name(tbf)); tbf->stop_timer(); #warning "TODO: Could/Should generate bssgp_tx_llc_discarded" - tbf->llc_queue()->clear(tbf->bts); tbf_unlink_pdch(tbf); llist_del(&tbf->list.list); @@ -451,7 +460,6 @@ static int setup_tbf(struct gprs_rlcmac_tbf *tbf, struct gprs_rlcmac_bts *bts, gettimeofday(&tbf->meas.rssi_tv, NULL); tbf->m_llc.init(); - tbf->llc_queue()->init(); return 0; } diff --git a/src/tbf.h b/src/tbf.h index b665a88e..7f8d660d 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -232,7 +232,6 @@ protected: /* Field to take the TA value if no MS is associated */ uint8_t m_ta; - gprs_llc_queue m_llc_queue; private: mutable char m_name_buf[60]; }; @@ -289,16 +288,6 @@ inline GprsMs *gprs_rlcmac_tbf::ms() const return m_ms; } -inline gprs_llc_queue *gprs_rlcmac_tbf::llc_queue() -{ - return &m_llc_queue; -} - -inline const gprs_llc_queue *gprs_rlcmac_tbf::llc_queue() const -{ - return &m_llc_queue; -} - inline bool gprs_rlcmac_tbf::is_tlli_valid() const { return tlli() != 0; diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 5b9c06ca..85cd7513 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -771,7 +771,6 @@ void gprs_rlcmac_dl_tbf::reuse_tbf(const uint8_t *data, const uint16_t len) uint8_t trx; struct gprs_rlcmac_dl_tbf *new_tbf = NULL; int8_t tfi; /* must be signed */ - struct msgb *msg; bts->tbf_reused(); @@ -790,13 +789,10 @@ void gprs_rlcmac_dl_tbf::reuse_tbf(const uint8_t *data, const uint16_t len) new_tbf->set_ms(ms()); - /* Copy over all data to the new TBF */ + /* Start with the passed frame */ new_tbf->m_llc.put_frame(data, len); bts->llc_frame_sched(); - while ((msg = llc_queue()->dequeue())) - new_tbf->llc_queue()->enqueue(msg); - /* reset rlc states */ m_tx_counter = 0; m_wait_confirm = 0; @@ -836,7 +832,8 @@ bool gprs_rlcmac_dl_tbf::need_control_ts() const bool gprs_rlcmac_dl_tbf::have_data() const { - return m_llc.chunk_size() > 0 || llc_queue()->size() > 0; + return m_llc.chunk_size() > 0 || + (llc_queue() && llc_queue()->size() > 0); } int gprs_rlcmac_dl_tbf::frames_since_last_poll(unsigned fn) const -- cgit v1.2.3