aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-01-31 17:21:21 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:27:53 +0100
commit1fe35ec3d83fbc62d1a9fa2c5867444649794b60 (patch)
treeb6946bc4634e2d599a22eda2d62d27114aeddf5c
parent2d759e90f6593fb21671a17c187bc1dcd8100210 (diff)
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
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp61
1 files changed, 42 insertions, 19 deletions
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 @@ static int tbf_select_slot_set(const gprs_rlcmac_tbf *tbf, const gprs_rlcmac_trx
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 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcm
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);