[PATCH] osmo-pcu[master]: Simplify TS alloc: use defines for constants

Max gerrit-no-reply at lists.osmocom.org
Tue Oct 10 16:58:11 UTC 2017


Hello Harald Welte, Jenkins Builder, Holger Freyther,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/3920

to look at the new patch set (#6).

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
---
M configure.ac
M src/bts.cpp
M src/bts.h
M src/gprs_rlcmac_ts_alloc.cpp
M tests/alloc/AllocTest.cpp
5 files changed, 10 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/20/3920/6

diff --git a/configure.ac b/configure.ac
index 0a3557d..91e245f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,7 +36,7 @@
 dnl Checks for typedefs, structures and compiler characteristics
 
 dnl checks for libraries
-PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore  >= 0.3.9)
+PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore  >= 0.9.4)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty)
 PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.3.3)
 PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.5.1.4)
diff --git a/src/bts.cpp b/src/bts.cpp
index b768569..6debb68 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -458,7 +458,7 @@
 	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 d65cd2f..26aaa21 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -44,6 +44,7 @@
 #define LLC_CODEL_DISABLE 0
 #define LLC_CODEL_USE_DEFAULT (-1)
 #define MAX_GPRS_CS 9
+#define NO_FREE_TFI 0xffffffffUL
 
 /* 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 57197b2..3b596f4 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -128,7 +128,7 @@
 	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 */
@@ -209,7 +209,7 @@
 		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;
 
@@ -340,10 +340,10 @@
 			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 a88f477..9bff38a 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -613,17 +613,17 @@
 				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),

-- 
To view, visit https://gerrit.osmocom.org/3920
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2699ceebf0cbec01652a02fa68ccc9e9419d0293
Gerrit-PatchSet: 6
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list