aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs_rlcmac_ts_alloc.cpp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-09-29 08:18:17 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-30 14:45:57 +0100
commitb0a0075845b1a3b47ad5398a5219257567aad964 (patch)
tree6666034c17b0fba27954f9dd8b8dac80fa5a579e /src/gprs_rlcmac_ts_alloc.cpp
parent11a748935eb793f94e30c2d04932251c93560dc0 (diff)
alloc: Factor out the routine to find an enabled PDCH
Diffstat (limited to 'src/gprs_rlcmac_ts_alloc.cpp')
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index ee3ec799..29078d0e 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -97,6 +97,23 @@ static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch, uint8_t ts)
return -1;
}
+static int find_enabled_pdch(struct gprs_rlcmac_trx *trx, const uint8_t start_ts)
+{
+ int ts;
+ for (ts = start_ts; ts < 8; ts++) {
+ struct gprs_rlcmac_pdch *pdch;
+
+ pdch = &trx->pdch[ts];
+ if (!pdch->enable) {
+ LOGP(DRLCMAC, LOGL_DEBUG, "- Skipping TS %d, because "
+ "not enabled\n", ts);
+ continue;
+ }
+ return ts;
+ }
+
+ return 8;
+}
static void assign_uplink_tbf_usf(
struct gprs_rlcmac_pdch *pdch,
@@ -135,18 +152,11 @@ int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
LOGP(DRLCMAC, LOGL_DEBUG, "Slot Allocation (Algorithm A) for class "
"%d\n", tbf->ms_class);
- for (ts = 0; ts < 8; ts++) {
- pdch = &tbf->trx->pdch[ts];
- if (!pdch->enable) {
- LOGP(DRLCMAC, LOGL_DEBUG, "- Skipping TS %d, because "
- "not enabled\n", ts);
- continue;
- }
- break;
- }
+ ts = find_enabled_pdch(tbf->trx, 0);
if (ts == 8)
return -EINVAL;
+ pdch = &tbf->trx->pdch[ts];
tbf->tsc = pdch->tsc;
if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
/* if USF available */