[PATCH] osmo-pcu[master]: Simplify TS alloc: separate capacity computation

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
Wed Sep 13 17:49:53 UTC 2017


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

Simplify TS alloc: separate capacity computation

Move TRX capacity computation into separate function and document it.

Change-Id: Ifd88fc7ff818ea2a041eae61c5d457926a0df0f2
Related: OS#2282
---
M src/gprs_rlcmac_ts_alloc.cpp
1 file changed, 28 insertions(+), 20 deletions(-)


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

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index cfef05a..74e8519 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -500,6 +500,33 @@
 	return 0;
 }
 
+/*! Compute capacity of a given TRX
+ *
+ *  \param[in] trx Pointer to TRX object
+ *  \param[in] rx_window Receive window
+ *  \param[in] tx_window Transmit window
+ *  \returns non-negative capacity
+ */
+static inline unsigned compute_capacity(const struct gprs_rlcmac_trx *trx, int rx_window, int tx_window)
+{
+	const struct gprs_rlcmac_pdch *pdch;
+	unsigned ts, capacity = 0;
+
+	for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) {
+		pdch = &trx->pdch[ts];
+		if (rx_window & (1 << ts))
+			capacity += OSMO_MAX(32 - pdch->num_reserved(GPRS_RLCMAC_DL_TBF), 1);
+
+		/* Only consider common slots for UL */
+		if (tx_window & rx_window & (1 << ts)) {
+			if (find_free_usf(pdch) >= 0)
+				capacity += OSMO_MAX(32 - pdch->num_reserved(GPRS_RLCMAC_UL_TBF), 1);
+		}
+	}
+
+	return capacity;
+}
+
 /*! Find set of slots available for allocation while taking MS class into account
  *
  *  \param[in] trx Pointer to TRX object
@@ -654,7 +681,6 @@
 					unsigned rx_slot_count;
 					uint16_t rx_bad;
 					uint8_t rx_good;
-					unsigned ts;
 					int capacity;
 
 					/* Filter out bad slots */
@@ -746,25 +772,7 @@
 					}
 
 					/* Compute capacity */
-					capacity = 0;
-
-					for (ts = 0; ts < ARRAY_SIZE(trx->pdch); ts++) {
-						int c;
-						const struct gprs_rlcmac_pdch *pdch = &trx->pdch[ts];
-						if (rx_window & (1 << ts)) {
-							c = 32 - pdch->num_reserved(GPRS_RLCMAC_DL_TBF);
-							c = OSMO_MAX(c, 1);
-							capacity += c;
-						}
-						/* Only consider common slots for UL */
-						if (tx_window & rx_window & (1 << ts)) {
-							if (find_free_usf(pdch) >= 0) {
-								c = 32 - pdch->num_reserved(GPRS_RLCMAC_UL_TBF);
-								c = OSMO_MAX(c, 1);
-								capacity += c;
-							}
-						}
-					}
+					capacity = compute_capacity(trx, rx_window, tx_window);
 
 #ifdef ENABLE_TS_ALLOC_DEBUG
 					snprintf(slot_info, 9, OSMO_BIT_SPEC, OSMO_BIT_PRINT_EX(rx_bad, 'x'));

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd88fc7ff818ea2a041eae61c5d457926a0df0f2
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