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

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Feb 19 09:00:21 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: Simplify TS alloc: split USF/UL allocation
......................................................................


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(+), 19 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index 8ab3b93..0955411 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -790,6 +790,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.
@@ -867,27 +905,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: merged
Gerrit-Change-Id: I563dc10827ce68295553f88f3bf2e1fc0ba595c1
Gerrit-PatchSet: 13
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


More information about the gerrit-log mailing list