[PATCH] osmo-pcu[master]: Simplify TS alloc: split USF/UL allocation

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 16:15:27 UTC 2017


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

Simplify TS alloc: split USF/UL allocation

* move USF allocation into separate function
* document USF allocation

This allows to clearly see where selected UL TS is forced into single TS
in algorithm B allocator.

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


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

diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index cfef05a..6dfb13b 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -950,6 +950,44 @@
 	return sl;
 }
 
+/*! Allocate USF according to a given UL TS mapping
+ *
+ * N. B: this is legacy implementation which ignores given selected_ul_slots
+ *  \param[in] trx Pointer to TRX object
+ *  \param[in] tbf Pointer to TBF object
+ *  \param[in] first_common_ts First TS which is common to both UL and DL
+ *  \param[in] selected_ul_slots set of UL timeslots selected for allocation
+ *  \param[in] dl_slots set of DL timeslots
+ *  \param[out] usf array for allocated USF
+ *  \returns updated UL TS or negative on error
+ */
+static int allocate_usf(const gprs_rlcmac_trx *trx, int8_t first_common_ts, uint8_t selected_ul_slots, uint8_t dl_slots,
+			int *usf)
+{
+	int free_usf = -1, ts;
+	uint8_t ul_slots = selected_ul_slots;
+
+	if (first_common_ts >= 0)
+		ul_slots = 1 << first_common_ts;
+	else
+		ul_slots = ul_slots & dl_slots;
+
+	ts = find_least_busy_pdch(trx, GPRS_RLCMAC_UL_TBF, ul_slots, compute_usage_by_num_tbfs, NULL, &free_usf);
+
+	if (free_usf < 0 || ts < 0) {
+		LOGP(DRLCMAC, LOGL_NOTICE, "No USF available\n");
+		return -EBUSY;
+	}
+
+	OSMO_ASSERT(ts >= 0 && ts <= 8);
+
+	/* We will stick to that single UL slot, unreserve the others */
+	ul_slots = 1 << ts;
+	usf[ts] = free_usf;
+
+	return ul_slots;
+}
+
 /*! Slot Allocation: Algorithm B
  *
  * Assign as many downlink slots as possible.
@@ -973,7 +1011,6 @@
 	int8_t first_common_ts;
 	uint8_t slotcount = 0;
 	uint8_t avail_count = 0, trx_no;
-	int ts;
 	int first_ts = -1;
 	int usf[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
 	int rc;
@@ -1027,27 +1064,12 @@
 		dl_slots = rc;
 		update_slot_counters(dl_slots, reserved_dl_slots, &slotcount, &avail_count);
 	} else {
-		int free_usf = -1;
-
-		ul_slots = rc;
-
-		if (first_common_ts >= 0)
-			ul_slots = 1 << first_common_ts;
-		else
-			ul_slots = ul_slots & dl_slots;
-
-		ts = find_least_busy_pdch(trx, GPRS_RLCMAC_UL_TBF, ul_slots, compute_usage_by_num_tbfs, NULL, &free_usf);
-
-		if (free_usf < 0) {
-			LOGP(DRLCMAC, LOGL_NOTICE, "No USF available\n");
-			return -EBUSY;
-		}
-
-		OSMO_ASSERT(ts >= 0 && ts <= 8);
+		rc = allocate_usf(trx, first_common_ts, rc, dl_slots, usf);
+		if (rc < 0)
+			return rc;
 
 		/* We will stick to that single UL slot, unreserve the others */
-		ul_slots = 1 << ts;
-		usf[ts] = free_usf;
+		ul_slots = rc;
 		reserved_ul_slots = ul_slots;
 
 		update_slot_counters(ul_slots, reserved_ul_slots, &slotcount, &avail_count);

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

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