[PATCH] osmo-pcu[master]: Simplify TS alloc: use define for constant

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Tue Sep 12 16:35:19 UTC 2017


Review at  https://gerrit.osmocom.org/3920

Simplify TS alloc: use define for constant

Define and use constant for occupied TFI instead copying the same
magic number all over the place.

Change-Id: I2699ceebf0cbec01652a02fa68ccc9e9419d0293
Related: OS#2282
---
M src/bts.cpp
M src/bts.h
M src/gprs_rlcmac_ts_alloc.cpp
M tests/alloc/AllocTest.cpp
4 files changed, 8 insertions(+), 7 deletions(-)


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

diff --git a/src/bts.cpp b/src/bts.cpp
index 68c23ff..f5f6f44 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -457,7 +457,7 @@
 	for (trx = trx_from; trx <= trx_to; trx++) {
 		bool trx_has_pdch = false;
 
-		free_tfis = 0xffffffff;
+		free_tfis = TFI_IS_BUSY;
 
 		for (ts = 0; ts < 8; ts++) {
 			pdch = &m_bts.trx[trx].pdch[ts];
diff --git a/src/bts.h b/src/bts.h
index 611a58b..555b393 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 TFI_IS_BUSY 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 1410e00..1141734 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -126,7 +126,7 @@
 	uint32_t tfi_map = pdch->assigned_tfi(dir);
 	int8_t tfi;
 
-	if (tfi_map == 0xffffffffUL)
+	if (tfi_map == TFI_IS_BUSY)
 		return -1;
 
 	/* look for USF, don't use USF=7 */
@@ -203,7 +203,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)) == TFI_IS_BUSY)
 		/* No TFI in the opposite direction, avoid it */
 		usage += 32;
 
@@ -327,10 +327,10 @@
 			if (!pdch->is_enabled())
 				continue;
 
-			if (pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) == 0xffffffff)
+			if (pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) == TFI_IS_BUSY)
 				continue;
 
-			if (pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) == 0xffffffff)
+			if (pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) == TFI_IS_BUSY)
 				continue;
 
 			return trx_no;
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index c614d48..dd5f242 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -609,11 +609,11 @@
 				continue;
 
 			if (ul_tbf &&
-				pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) != 0xffffffff)
+				pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) != TFI_IS_BUSY)
 				continue;
 
 			if (dl_tbf &&
-				pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) != 0xffffffff)
+				pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) != TFI_IS_BUSY)
 				continue;
 
 			busy_slots |= 1 << i;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2699ceebf0cbec01652a02fa68ccc9e9419d0293
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list