aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-09-28 15:56:05 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:27:51 +0100
commit399804b941414e2eaa9763e21abde73166cc469b (patch)
tree7afe62f7b5692364e4788a3b8672826b1ce36c90
parentf7607d63290583f978e6c6677694047d823b8f05 (diff)
Simplify TS alloc: adjust allocator signatures
* drop unused parameters (from both functions and structs) * document used parameters and return values * tighten types used for parameters * use consistent formatting Tests are adjusted accordingly but test results are left untouched to avoid regressions. Change-Id: I39d81ab64ff790b9c4c2d0312a574485cd83e755 Related: OS#2282
-rw-r--r--src/bts.h8
-rw-r--r--src/gprs_rlcmac.h24
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp46
-rw-r--r--src/tbf.cpp21
-rw-r--r--src/tbf.h10
-rw-r--r--src/tbf_dl.cpp6
-rw-r--r--tests/alloc/AllocTest.cpp8
7 files changed, 61 insertions, 62 deletions
diff --git a/src/bts.h b/src/bts.h
index b1724c9b..8d3a3cc4 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -203,11 +203,9 @@ struct gprs_rlcmac_bts {
struct gsmtap_inst *gsmtap;
uint32_t gsmtap_categ_mask;
struct gprs_rlcmac_trx trx[8];
- int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts,
- struct GprsMs *ms,
- struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single,
- int use_tbf);
- uint32_t alloc_algorithm_curst; /* options to customize algorithm */
+ int (*alloc_algorithm)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf,
+ bool single, int8_t use_tbf);
+
uint8_t force_two_phase;
uint8_t alpha, gamma;
uint8_t egprs_enabled;
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 64b6d6c8..33dd9fd5 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -21,6 +21,8 @@
#ifndef GPRS_RLCMAC_H
#define GPRS_RLCMAC_H
+#include <stdbool.h>
+
#ifdef __cplusplus
#include <gsm_rlcmac.h>
#include <gsm_timer.h>
@@ -100,20 +102,14 @@ int gprs_alloc_max_dl_slots_per_ms(struct gprs_rlcmac_bts *bts,
extern "C" {
#endif
-int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
- struct GprsMs *ms,
- struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single,
- int use_trx);
-
-int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
- struct GprsMs *ms,
- struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single,
- int use_trx);
-
-int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts,
- struct GprsMs *ms,
- struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single,
- int use_trx);
+int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
+ int8_t use_trx);
+
+int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
+ int8_t use_trx);
+
+int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
+ int8_t use_trx);
#ifdef __cplusplus
}
#endif
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index b5edf051..cd82ca73 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -351,14 +351,19 @@ static int tfi_find_free(BTS *bts, const GprsMs *ms,
return tfi;
}
-/* Slot Allocation: Algorithm A
+/*! Slot Allocation: Algorithm A
*
* Assign single slot for uplink and downlink
+ *
+ * \param[in,out] bts Pointer to BTS struct
+ * \param[in,out] ms_ Pointer to MS object
+ * \param[in,out] tbf_ Pointer to TBF struct
+ * \param[in] single flag indicating if we should force single-slot allocation
+ * \param[in] use_trx which TRX to use or -1 if it should be selected during allocation
+ * \returns negative error code or 0 on success
*/
-int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
- GprsMs *ms_,
- struct gprs_rlcmac_tbf *tbf_, uint32_t cust, uint8_t single,
- int use_trx)
+int alloc_algorithm_a(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_, bool single,
+ int8_t use_trx)
{
struct gprs_rlcmac_pdch *pdch;
int ts = -1;
@@ -725,15 +730,20 @@ int find_multi_slots(struct gprs_rlcmac_trx *trx, uint8_t mslot_class, uint8_t *
return 0;
}
-/* Slot Allocation: Algorithm B
+/*! Slot Allocation: Algorithm B
*
* Assign as many downlink slots as possible.
* Assign one uplink slot. (With free USF)
*
+ * \param[in,out] bts Pointer to BTS struct
+ * \param[in,out] ms_ Pointer to MS object
+ * \param[in,out] tbf_ Pointer to TBF struct
+ * \param[in] single flag indicating if we should force single-slot allocation
+ * \param[in] use_trx which TRX to use or -1 if it should be selected during allocation
+ * \returns negative error code or 0 on success
*/
-int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
- GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_,
- uint32_t cust, uint8_t single, int use_trx)
+int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_, bool single,
+ int8_t use_trx)
{
uint8_t dl_slots;
uint8_t ul_slots;
@@ -954,7 +964,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
return 0;
}
-/* Slot Allocation: Algorithm dynamic
+/*! Slot Allocation: Algorithm dynamic
*
* This meta algorithm automatically selects on of the other algorithms based
* on the current system state.
@@ -962,10 +972,15 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
* The goal is to support as many MS and TBF as possible. On low usage, the
* goal is to provide the highest possible bandwidth per MS.
*
+ * \param[in,out] bts Pointer to BTS struct
+ * \param[in,out] ms_ Pointer to MS object
+ * \param[in,out] tbf_ Pointer to TBF struct
+ * \param[in] single flag indicating if we should force single-slot allocation
+ * \param[in] use_trx which TRX to use or -1 if it should be selected during allocation
+ * \returns negative error code or 0 on success
*/
-int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts,
- GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_,
- uint32_t cust, uint8_t single, int use_trx)
+int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcmac_tbf *tbf_, bool single,
+ int8_t use_trx)
{
int rc;
@@ -977,7 +992,7 @@ int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts,
}
if (!bts->multislot_disabled) {
- rc = alloc_algorithm_b(bts, ms_, tbf_, cust, single, use_trx);
+ rc = alloc_algorithm_b(bts, ms_, tbf_, single, use_trx);
if (rc >= 0)
return rc;
@@ -986,8 +1001,7 @@ int alloc_algorithm_dynamic(struct gprs_rlcmac_bts *bts,
bts->multislot_disabled = 1;
}
- rc = alloc_algorithm_a(bts, ms_, tbf_, cust, single, use_trx);
- return rc;
+ return alloc_algorithm_a(bts, ms_, tbf_, single, use_trx);
}
int gprs_alloc_max_dl_slots_per_ms(struct gprs_rlcmac_bts *bts, uint8_t ms_class)
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 672c2964..ea3ffe34 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -500,8 +500,7 @@ int gprs_rlcmac_tbf::update()
LOGP(DTBF, LOGL_DEBUG, "********** DL-TBF update **********\n");
tbf_unlink_pdch(this);
- rc = bts_data->alloc_algorithm(bts_data, ms(), this,
- bts_data->alloc_algorithm_curst, 0, -1);
+ rc = bts_data->alloc_algorithm(bts_data, ms(), this, false, -1);
/* if no resource */
if (rc < 0) {
LOGPTBF(this, LOGL_ERROR, "No resource after update???\n");
@@ -828,9 +827,8 @@ void gprs_rlcmac_tbf::poll_timeout()
LOGPTBF(this, LOGL_ERROR, "Poll Timeout, but no event!\n");
}
-static int setup_tbf(struct gprs_rlcmac_tbf *tbf,
- GprsMs *ms, int8_t use_trx,
- uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot)
+static int setup_tbf(struct gprs_rlcmac_tbf *tbf, GprsMs *ms, int8_t use_trx, uint8_t ms_class, uint8_t egprs_ms_class,
+ bool single_slot)
{
int rc;
struct gprs_rlcmac_bts *bts;
@@ -845,8 +843,7 @@ static int setup_tbf(struct gprs_rlcmac_tbf *tbf,
tbf->m_created_ts = time(NULL);
tbf->set_ms_class(ms_class);
/* select algorithm */
- rc = bts->alloc_algorithm(bts, ms, tbf, bts->alloc_algorithm_curst,
- single_slot, use_trx);
+ rc = bts->alloc_algorithm(bts, ms, tbf, single_slot, use_trx);
/* if no resource */
if (rc < 0) {
return -1;
@@ -906,9 +903,8 @@ static void setup_egprs_mode(gprs_rlcmac_bts *bts, GprsMs *ms)
}
}
-struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
- GprsMs *ms, int8_t use_trx,
- uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot)
+struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, uint8_t ms_class,
+ uint8_t egprs_ms_class, bool single_slot)
{
struct gprs_rlcmac_ul_tbf *tbf;
int rc;
@@ -995,9 +991,8 @@ static int dl_tbf_dtor(struct gprs_rlcmac_dl_tbf *tbf)
return 0;
}
-struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
- GprsMs *ms, int8_t use_trx,
- uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot)
+struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, uint8_t ms_class,
+ uint8_t egprs_ms_class, bool single_slot)
{
struct gprs_rlcmac_dl_tbf *tbf;
int rc;
diff --git a/src/tbf.h b/src/tbf.h
index bb5fd0ab..803ea330 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -366,13 +366,11 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
int8_t use_trx, uint8_t ms_class, uint8_t egprs_ms_class,
uint32_t tlli, uint8_t ta, GprsMs *ms);
-struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
- GprsMs *ms, int8_t use_trx,
- uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot);
+struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, uint8_t ms_class,
+ uint8_t egprs_ms_class, bool single_slot);
-struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
- GprsMs *ms, int8_t use_trx,
- uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot);
+struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, uint8_t ms_class,
+ uint8_t egprs_ms_class, bool single_slot);
void tbf_free(struct gprs_rlcmac_tbf *tbf);
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 80e38318..e8aec237 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -115,7 +115,7 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts,
const uint8_t egprs_ms_class,
struct gprs_rlcmac_dl_tbf **tbf)
{
- uint8_t ss;
+ bool ss;
int8_t use_trx;
uint16_t ta = GSM48_TA_INVALID;
struct gprs_rlcmac_ul_tbf *ul_tbf = NULL, *old_ul_tbf;
@@ -133,11 +133,11 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts,
if (ul_tbf && ul_tbf->m_contention_resolution_done
&& !ul_tbf->m_final_ack_sent) {
use_trx = ul_tbf->trx->trx_no;
- ss = 0;
+ ss = false;
old_ul_tbf = ul_tbf;
} else {
use_trx = -1;
- ss = 1; /* PCH assignment only allows one timeslot */
+ ss = true; /* PCH assignment only allows one timeslot */
old_ul_tbf = NULL;
}
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 885e2a1f..1aa3f636 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -40,7 +40,7 @@ int16_t spoof_mnc = 0, spoof_mcc = 0;
static gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_bts *bts,
GprsMs *ms, gprs_rlcmac_tbf_direction dir,
uint8_t use_trx,
- uint8_t ms_class, uint8_t egprs_ms_class, uint8_t single_slot)
+ uint8_t ms_class, uint8_t egprs_ms_class, bool single_slot)
{
if (dir == GPRS_RLCMAC_UL_TBF)
return tbf_alloc_ul_tbf(bts, ms, use_trx,
@@ -410,10 +410,8 @@ static void test_alloc_b()
test_all_alloc_b();
}
-typedef int (*algo_t)(struct gprs_rlcmac_bts *bts,
- struct GprsMs *ms,
- struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single,
- int use_trx);
+typedef int (*algo_t)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
+ int8_t use_trx);
static char get_dir_char(uint8_t mask, uint8_t tx, uint8_t rx, uint8_t busy)
{