llc_queue: Refactor to handle codel_state per prio queue internally

A CoDel state per prio queue is needed, otherwise the sojourn time state
is not properly reset when a high prio packet is dequeued.

If we have a global codel state shared for all prio queues of an MS, then
basically high prio (GMM) packets will "never" be dropped because they are
handled/dequeued way quicker, so it's sojourn time will be below the
threshold most probably, stopping the "dropping" state for the rest of
lower prio packets.

The handling of different codel states is moved from MS object to the
llc_queue, also offloading already loaded dl_tbf.cpp in the process.
This will also allow in the future setting different CoDel parameters
for different priority queues if needed.

Tests need to be adapted since now the CoDel and PDU lifetime are
incorporated into the llc_queue_dequeue(). Also because dequeue now also
accesses related MS fields.

Related: OS#5508
Change-Id: I2bce2e82ab6389d8a70130a5c26a966a316b0fa4
diff --git a/src/llc.h b/src/llc.h
index adfab65..fe14c6a 100644
--- a/src/llc.h
+++ b/src/llc.h
@@ -28,9 +28,12 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/endian.h>
 
+#include "gprs_codel.h"
+
 #define LLC_MAX_LEN 1543
 
 struct gprs_rlcmac_bts;
+struct GprsMs;
 
 struct gprs_llc_hdr {
 #if OSMO_IS_LITTLE_ENDIAN
@@ -110,22 +113,29 @@
 	LLC_QUEUE_PRIO_OTHER, /* Other SAPIs */
 	_LLC_QUEUE_PRIO_SIZE /* used to calculate size of enum */
 };
+struct gprs_llc_prio_queue {
+	struct gprs_codel codel_state;
+	struct llist_head queue; /* queued LLC DL data. See enum gprs_llc_queue_prio. */
+};
 struct gprs_llc_queue {
+	struct GprsMs *ms; /* backpointer */
 	uint32_t avg_queue_delay; /* Average delay of data going through the queue */
 	size_t queue_size;
 	size_t queue_octets;
-	struct llist_head queue[_LLC_QUEUE_PRIO_SIZE]; /* queued LLC DL data. See enum gprs_llc_queue_prio. */
+	bool use_codel;
+	struct gprs_llc_prio_queue pq[_LLC_QUEUE_PRIO_SIZE]; /* queued LLC DL data. See enum gprs_llc_queue_prio. */
 };
 
 void llc_queue_calc_pdu_lifetime(struct gprs_rlcmac_bts *bts, const uint16_t pdu_delay_csec,
 		struct timespec *tv);
 bool llc_queue_is_frame_expired(const struct timespec *tv_now, const struct timespec *tv);
 
-void llc_queue_init(struct gprs_llc_queue *q);
+void llc_queue_init(struct gprs_llc_queue *q, struct GprsMs *ms);
 void llc_queue_clear(struct gprs_llc_queue *q, struct gprs_rlcmac_bts *bts);
+void llc_queue_set_codel_interval(struct gprs_llc_queue *q, unsigned int interval);
 void llc_queue_move_and_merge(struct gprs_llc_queue *q, struct gprs_llc_queue *o);
 void llc_queue_enqueue(struct gprs_llc_queue *q, struct msgb *llc_msg, const struct timespec *expire_time);
-struct msgb *llc_queue_dequeue(struct gprs_llc_queue *q, const struct MetaInfo **info);
+struct msgb *llc_queue_dequeue(struct gprs_llc_queue *q);
 
 static inline size_t llc_queue_size(const struct gprs_llc_queue *q)
 {