aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-09-20 17:55:28 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:27:51 +0100
commit95babb352d91a5627b897246bb07bf63617c2956 (patch)
treeac79860542f76c1e5709c4830b388142ebded647
parent78bc0c3e8fee66fbb188eedba266661974bf989b (diff)
Simplify TS alloc: use defines for constants
* define and use constant for occupied TFI instead copying the same magic number all over the place * use libosmocore's define for bit pretty-printer Change-Id: I2699ceebf0cbec01652a02fa68ccc9e9419d0293 Related: OS#2282
-rw-r--r--src/bts.cpp2
-rw-r--r--src/bts.h1
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp8
-rw-r--r--tests/alloc/AllocTest.cpp6
4 files changed, 9 insertions, 8 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index d652c59..e236f93 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -475,7 +475,7 @@ int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir,
for (trx = trx_from; trx <= trx_to; trx++) {
bool trx_has_pdch = false;
- free_tfis = 0xffffffff;
+ free_tfis = NO_FREE_TFI;
for (ts = 0; ts < 8; ts++) {
pdch = &m_bts.trx[trx].pdch[ts];
diff --git a/src/bts.h b/src/bts.h
index 8d3a3cc..34326b8 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -44,6 +44,7 @@ extern "C" {
#define LLC_CODEL_DISABLE 0
#define LLC_CODEL_USE_DEFAULT (-1)
#define MAX_GPRS_CS 9
+#define NO_FREE_TFI 0xffffffff
/* see bts->gsmtap_categ_mask */
enum pcu_gsmtap_category {
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index c246676..0e8b785 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -83,7 +83,7 @@ static inline int8_t find_free_tfi(struct gprs_rlcmac_pdch *pdch,
int8_t tfi;
tfi_map = pdch->assigned_tfi(dir);
- if (tfi_map == 0xffffffffUL)
+ if (tfi_map == NO_FREE_TFI)
return -1;
/* look for USF, don't use USF=7 */
@@ -164,7 +164,7 @@ static int compute_usage_for_algo_a(struct gprs_rlcmac_pdch *pdch,
pdch->num_tbfs(GPRS_RLCMAC_UL_TBF) +
compute_usage_by_reservation(pdch, dir);
- if (pdch->assigned_tfi(reverse(dir)) == 0xffffffff)
+ if (pdch->assigned_tfi(reverse(dir)) == NO_FREE_TFI)
/* No TFI in the opposite direction, avoid it */
usage += 32;
@@ -295,10 +295,10 @@ static int find_trx(BTS *bts, const GprsMs *ms, int use_trx)
if (!pdch->is_enabled())
continue;
- if (pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) == 0xffffffff)
+ if (pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) == NO_FREE_TFI)
continue;
- if (pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) == 0xffffffff)
+ if (pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) == NO_FREE_TFI)
continue;
return trx_no;
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 6e344dc..1c98e46 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -585,17 +585,17 @@ static unsigned alloc_many_tbfs(BTS *the_bts, unsigned min_class,
continue;
if (ul_tbf &&
- pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) != 0xffffffff)
+ pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) != NO_FREE_TFI)
continue;
if (dl_tbf &&
- pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) != 0xffffffff)
+ pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) != NO_FREE_TFI)
continue;
busy_slots |= 1 << i;
}
- printf(" TBF[%d] class %d reserves %c%c%c%c%c%c%c%c\n",
+ printf(" TBF[%d] class %d reserves " OSMO_BIT_SPEC "\n",
tfi, ms_class,
get_dir_char(0x01, ul_slots, dl_slots, busy_slots),
get_dir_char(0x02, ul_slots, dl_slots, busy_slots),