aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-09-28 16:41:24 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:27:52 +0100
commitb28518bee85656c6e363197b72370c1e6cd9eb47 (patch)
tree60ec7c47f81c9233d7c8662ecf535be192efa8d5
parent3d60f305a1b74f9b6e6c0006ca9ef8e0bf2f4e8c (diff)
Simplify TS alloc: internalize TRX check
Move TRX check inside local tfi_find_free() wrapper to make main algorithm easier to follow. Change-Id: I02da2b8ba8c9c8815dae0e39e1fed277ca0df171 Related: OS#2282
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index e394a6e..c45aa39 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -329,7 +329,7 @@ static bool idle_pdch_avail(const struct gprs_rlcmac_bts *bts_data)
/*! Return free TFI
*
* \param[in] bts Pointer to BTS struct
- * \param[in] trx Pointer to TRX struct
+ * \param[in] trx Optional pointer to TRX struct
* \param[in] ms Pointer to MS object
* \param[in] dir DL or UL direction
* \param[in] use_trx which TRX to use or -1 if it should be selected based on what MS uses
@@ -342,6 +342,15 @@ static int tfi_find_free(const BTS *bts, const gprs_rlcmac_trx *trx, const GprsM
int tfi;
uint8_t trx_no;
+ if (trx) {
+ if (use_trx >= 0 && use_trx != trx->trx_no) {
+ LOGP(DRLCMAC, LOGL_ERROR, "- Requested incompatible TRX %d (current is %d)\n",
+ use_trx, trx->trx_no);
+ return -EINVAL;
+ }
+ use_trx = trx->trx_no;
+ }
+
if (use_trx == -1 && ms->current_trx())
use_trx = ms->current_trx()->trx_no;
@@ -786,16 +795,6 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts, GprsMs *ms_, struct gprs_rlcm
first_common_ts = ms->first_common_ts();
trx = ms->current_trx();
- if (trx) {
- if (use_trx >= 0 && use_trx != trx->trx_no) {
- LOGP(DRLCMAC, LOGL_ERROR,
- "- Requested incompatible TRX %d (current is %d)\n",
- use_trx, trx->trx_no);
- return -EINVAL;
- }
- use_trx = trx->trx_no;
- }
-
/* Step 2a: Find usable TRX and TFI */
tfi = tfi_find_free(bts->bts, trx, ms, tbf->direction, use_trx, &trx_no);
if (tfi < 0) {