llc: Separate LLC queue handling from gprs_llc
Currently the gprs_llc class handles both LLC queueing and the
partition into smaller pieces for RLC/MAC encapsulation. This hinders
the separation of TBF and MS related data, since LLC queueing belongs
to the MS related code while the RLC/MAC encoding/decoding belongs to
the TBF layer.
This commits takes the LLC queueing related methods and members and
puts them into a new class gprs_llc_queue. It puts the queueing
object into gprs_rlcmac_tbf and adds accessor functions. The
implementation in tbf.cpp and tbf_dl.cpp is adapted accordingly.
Ticket: #1674
Sponsored-by: On-Waves ehf
diff --git a/src/llc.cpp b/src/llc.cpp
index 9c5581f..09242a5 100644
--- a/src/llc.cpp
+++ b/src/llc.cpp
@@ -42,12 +42,6 @@
m_index = 0;
}
-void gprs_llc::enqueue(struct msgb *llc_msg)
-{
- m_queue_size += 1;
- msgb_enqueue(&queue, llc_msg);
-}
-
/* Put an Unconfirmed Information (UI) Dummy command, see GSM 44.064, 6.4.2.2 */
void gprs_llc::put_dummy_frame(size_t req_len)
{
@@ -82,36 +76,62 @@
m_length += len;
}
-void gprs_llc::clear(BTS *bts)
+void gprs_llc::init()
+{
+ reset();
+}
+
+bool gprs_llc::is_user_data_frame(uint8_t *data, size_t len)
+{
+ if (len < 2)
+ return false;
+
+ if ((data[0] & 0x0f) == 1 /* GPRS_SAPI_GMM */)
+ return false;
+
+ if ((data[0] & 0x0e) != 0xc0 /* LLC UI */)
+ /* It is not an LLC UI frame */
+ return false;
+
+ return true;
+}
+
+void gprs_llc_queue::init()
+{
+ INIT_LLIST_HEAD(&m_queue);
+ m_queue_size = 0;
+ m_avg_queue_delay = 0;
+}
+
+void gprs_llc_queue::enqueue(struct msgb *llc_msg)
+{
+ m_queue_size += 1;
+ msgb_enqueue(&m_queue, llc_msg);
+}
+
+void gprs_llc_queue::clear(BTS *bts)
{
struct msgb *msg;
- while ((msg = msgb_dequeue(&queue))) {
- bts->llc_dropped_frame();
+ while ((msg = msgb_dequeue(&m_queue))) {
+ if (bts)
+ bts->llc_dropped_frame();
msgb_free(msg);
}
m_queue_size = 0;
}
-void gprs_llc::init()
-{
- INIT_LLIST_HEAD(&queue);
- m_queue_size = 0;
- m_avg_queue_delay = 0;
- reset();
-}
-
#define ALPHA 0.5f
-struct msgb *gprs_llc::dequeue()
+struct msgb *gprs_llc_queue::dequeue()
{
struct msgb *msg;
struct timeval *tv, tv_now, tv_result;
uint32_t lifetime;
- msg = msgb_dequeue(&queue);
+ msg = msgb_dequeue(&m_queue);
if (!msg)
return NULL;
@@ -128,8 +148,7 @@
return msg;
}
-
-void gprs_llc::calc_pdu_lifetime(BTS *bts, const uint16_t pdu_delay_csec, struct timeval *tv)
+void gprs_llc_queue::calc_pdu_lifetime(BTS *bts, const uint16_t pdu_delay_csec, struct timeval *tv)
{
uint16_t delay_csec;
if (bts->bts_data()->force_llc_lifetime)
@@ -152,7 +171,7 @@
timeradd(&now, &csec, tv);
}
-bool gprs_llc::is_frame_expired(struct timeval *tv_now, struct timeval *tv)
+bool gprs_llc_queue::is_frame_expired(struct timeval *tv_now, struct timeval *tv)
{
/* Timeout is infinite */
if (tv->tv_sec == 0 && tv->tv_usec == 0)
@@ -160,18 +179,3 @@
return timercmp(tv_now, tv, >);
}
-
-bool gprs_llc::is_user_data_frame(uint8_t *data, size_t len)
-{
- if (len < 2)
- return false;
-
- if ((data[0] & 0x0f) == 1 /* GPRS_SAPI_GMM */)
- return false;
-
- if ((data[0] & 0x0e) != 0xc0 /* LLC UI */)
- /* It is not an LLC UI frame */
- return false;
-
- return true;
-}