tbf: Pass the MS object around instead of old_tbf

Currently the old TBF (either uplink or downlink) is passed around at
TBF allocation mainly to get information about the MS. To implement
more complex allocation algorithms, the MS object itself will be
needed anyway.

This commit replaces the old_tbf arguments by MS object arguments.

Sponsored-by: On-Waves ehf
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index e8bedad..bae1ea5 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -23,6 +23,7 @@
 #include <gprs_debug.h>
 #include <bts.h>
 #include <tbf.h>
+#include <gprs_ms.h>
 
 #include <errno.h>
 
@@ -139,7 +140,7 @@
  * Assign single slot for uplink and downlink
  */
 int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
-	struct gprs_rlcmac_tbf *old_tbf,
+	GprsMs *ms,
 	struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single)
 {
 	struct gprs_rlcmac_pdch *pdch;
@@ -261,16 +262,21 @@
 	return rx_window;
 }
 
-static int reduce_rx_window(const int ms_type, const struct gprs_rlcmac_tbf *old_tbf,
+static int reduce_rx_window(const int ms_type, const GprsMs *ms,
 				const int Tt, const int Tr,
 				int *rx_window,
 				uint8_t *rx_win_min, uint8_t *rx_win_max)
 {
+	gprs_rlcmac_ul_tbf *ul_tbf;
+
 	if (ms_type != 1)
 		return 0;
-	if (!old_tbf)
+	if (!ms)
 		return 0;
-	if (old_tbf->direction != GPRS_RLCMAC_UL_TBF)
+
+	ul_tbf = ms->ul_tbf();
+
+	if (!ul_tbf)
 		return 0;
 
 	uint8_t collide = 0, ul_usage = 0;
@@ -278,7 +284,7 @@
 	/* calculate mask of colliding slots */
 	for (uint8_t ts_no = 0; ts_no < 8; ts_no++) {
 		int j;
-		if (!old_tbf->pdch[ts_no])
+		if (!ul_tbf->pdch[ts_no])
 			continue;
 
 		ul_usage |= (1 << ts_no);
@@ -525,7 +531,7 @@
  *
  */
 int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
-	struct gprs_rlcmac_tbf *old_tbf,
+	GprsMs *ms,
 	struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single)
 {
 	const struct gprs_ms_multislot_class *ms_class;
@@ -592,7 +598,7 @@
 
 
 	/* reduce window, if existing uplink slots collide RX window */
-	int rc = reduce_rx_window(ms_class->type, old_tbf, Tt, Tr,
+	int rc = reduce_rx_window(ms_class->type, ms, Tt, Tr,
 				&rx_window, &rx_win_min, &rx_win_max);
 	if (rc < 0)
 		return rc;