Rename gprs_rlcmac_ts_alloc.cpp -> alloc_algo.cpp & create own .h file

First commit towards trying to have alloc algorithm as isolated as
possible from others parts of the code trying to avoid state changes on
data structures.
Change name also because the alloc_algo not only allocated TS, but TFIs
and USFs.

Change-Id: I33a6c178c64a769f05d3880a69c38acb154afa62
diff --git a/debian/copyright b/debian/copyright
index c714f1f..31b06fa 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -46,7 +46,7 @@
            src/encoding.cpp
            src/encoding.h
            src/gprs_rlcmac.cpp
-           src/gprs_rlcmac_ts_alloc.cpp
+           src/ts_alloc.cpp
 Copyright: 2012 Ivan Klyuchnikov
            2012 Andreas Eversberg <jolly@eversberg.eu>
            2013 by Holger Hans Peter Freyther
@@ -56,9 +56,11 @@
 Files:     src/gprs_rlcmac.h
            src/gprs_bssgp_pcu.cpp
            src/gprs_bssgp_pcu.h
+           src/ts_alloc.h
            src/bts.h
 Copyright: 2012 Ivan Klyuchnikov
            2013 by Holger Hans Peter Freyther
+           2022 by by Sysmocom s.f.m.c. GmbH
 License:   GPL-2.0+
 
 Files:     src/rlc.h
diff --git a/src/Makefile.am b/src/Makefile.am
index e7e94e0..e020ffa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,6 +39,7 @@
 noinst_LTLIBRARIES = libgprs.la
 
 libgprs_la_SOURCES = \
+	alloc_algo.cpp \
 	gprs_debug.c \
 	csn1.c \
 	csn1_dec.c \
@@ -49,7 +50,6 @@
 	gprs_rlcmac.cpp \
 	gprs_rlcmac_sched.cpp \
 	gprs_rlcmac_meas.cpp \
-	gprs_rlcmac_ts_alloc.cpp \
 	gprs_ms.c \
 	gprs_ms_storage.cpp \
 	gprs_pcu.c \
@@ -89,6 +89,7 @@
 noinst_PROGRAMS =
 
 noinst_HEADERS = \
+	alloc_algo.h \
 	gprs_debug.h \
 	csn1.h \
 	gsm_rlcmac.h \
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/alloc_algo.cpp
similarity index 99%
rename from src/gprs_rlcmac_ts_alloc.cpp
rename to src/alloc_algo.cpp
index 704b696..047bae2 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/alloc_algo.cpp
@@ -1,8 +1,9 @@
-/* gprs_rlcmac.cpp
+/* alloc_algo.cpp
  *
  * Copyright (C) 2012 Ivan Klyuchnikov
  * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
  * Copyright (C) 2013 by Holger Hans Peter Freyther
+ * Copyright (C) 2022 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -29,6 +30,7 @@
 
 extern "C" {
 #include "mslot_class.h"
+#include "alloc_algo.h"
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/logging.h>
 #include <osmocom/core/utils.h>
diff --git a/src/alloc_algo.h b/src/alloc_algo.h
new file mode 100644
index 0000000..a7c370e
--- /dev/null
+++ b/src/alloc_algo.h
@@ -0,0 +1,40 @@
+/* alloc_algo.h
+ *
+ * Copyright (C) 2022 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+struct gprs_rlcmac_bts;
+struct gprs_rlcmac_tbf;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
+		      int8_t use_trx);
+
+int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
+		      int8_t use_trx);
+
+int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
+			    int8_t use_trx);
+int gprs_alloc_max_dl_slots_per_ms(const struct gprs_rlcmac_bts *bts, uint8_t ms_class);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/gprs_bssgp_pcu.c b/src/gprs_bssgp_pcu.c
index 8fd6d85..f441437 100644
--- a/src/gprs_bssgp_pcu.c
+++ b/src/gprs_bssgp_pcu.c
@@ -36,6 +36,7 @@
 #include "llc.h"
 #include "gprs_rlcmac.h"
 #include "bts_pch_timer.h"
+#include "alloc_algo.h"
 
 /* Tuning parameters for BSSGP flow control */
 #define FC_DEFAULT_LIFE_TIME_SECS 10		/* experimental value, 10s */
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 468712e..22a33b4 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -100,17 +100,7 @@
 
 extern "C" {
 #endif
-int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
-		      int8_t use_trx);
-
-int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
-		      int8_t use_trx);
-
-int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *tbf, bool single,
-			    int8_t use_trx);
-
 int gprs_rlcmac_paging_request(struct gprs_rlcmac_bts *bts, const struct osmo_mobile_identity *mi, uint16_t pgroup);
-int gprs_alloc_max_dl_slots_per_ms(const struct gprs_rlcmac_bts *bts, uint8_t ms_class);
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 86b5398..60c8c79 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -28,6 +28,7 @@
 #include <bts.h>
 #include <osmocom/pcu/pcuif_proto.h>
 #include "gprs_bssgp_pcu.h"
+#include "alloc_algo.h"
 
 extern "C" {
 #include "pcu_vty.h"
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index 244a58a..54e0df6 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -23,6 +23,7 @@
 #include "bts.h"
 #include "tbf.h"
 #include "pcu_vty_functions.h"
+#include "alloc_algo.h"
 
 #define X(x) (1 << x)
 
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 4b4fbd5..75bf145 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -27,6 +27,7 @@
 
 extern "C" {
 #include "mslot_class.h"
+#include "alloc_algo.h"
 #include <osmocom/core/application.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/talloc.h>
diff --git a/tests/app_info/AppInfoTest.cpp b/tests/app_info/AppInfoTest.cpp
index 6806f20..668b081 100644
--- a/tests/app_info/AppInfoTest.cpp
+++ b/tests/app_info/AppInfoTest.cpp
@@ -24,6 +24,8 @@
 #include <osmocom/core/utils.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/application.h>
+
+#include "alloc_algo.h"
 }
 
 using namespace std;
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 02a3568..dd318c0 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -31,6 +31,7 @@
 extern "C" {
 #include "pcu_vty.h"
 #include "coding_scheme.h"
+#include "alloc_algo.h"
 
 #include <osmocom/core/application.h>
 #include <osmocom/core/msgb.h>
diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp
index 7c9baa9..b08c31d 100644
--- a/tests/emu/pcu_emu.cpp
+++ b/tests/emu/pcu_emu.cpp
@@ -22,6 +22,7 @@
 extern "C" {
 #include <osmocom/core/talloc.h>
 #include <pcu_vty.h>
+#include <alloc_algo.h>
 }
 
 #include "gprs_tests.h"
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 80dfc2f..47566f8 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -36,6 +36,7 @@
 extern "C" {
 #include "pcu_vty.h"
 #include "coding_scheme.h"
+#include "alloc_algo.h"
 
 #include <osmocom/core/application.h>
 #include <osmocom/core/msgb.h>
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index 1e714e1..c728af1 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -30,6 +30,7 @@
 #include "decoding.h"
 #include "gprs_rlcmac.h"
 #include "egprs_rlc_compression.h"
+#include "alloc_algo.h"
 
 extern "C" {
 #include <osmocom/core/application.h>