aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs_rlcmac_ts_alloc.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-07-10 10:41:36 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-07-16 10:25:14 +0200
commit5879c6493f74aecddc81abbd785065325bf2e117 (patch)
treeb5b600e88447ee2e9caefecd4d5583f14cfbe2c4 /src/gprs_rlcmac_ts_alloc.cpp
parent47a57f6f869f19704bbb993fc157a86fd0c85e58 (diff)
tbf: Move TFI selection into alloc_algorithm
Currently the TFI and the TRX have to be determined before the actual TBF allocation function is called, passing TFI and TRX number as parameters. This does fit to TFI reuse for different slots, since this were tightly coupled with the slot selection. This commit just moves the TFI selection into the alloc_algorithm functions. The tfi parameter is removed from the the TFI alloc functions. The trx parameter is changed into use_trx to optionally limit the trx selection (same semantics like in tfi_find_free). Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/gprs_rlcmac_ts_alloc.cpp')
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index ec228d1a..33814365 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -277,6 +277,24 @@ static void assign_dlink_tbf(
attach_tbf_to_pdch(pdch, tbf);
}
+static int tfi_find_free(BTS *bts, GprsMs *ms, enum gprs_rlcmac_tbf_direction dir,
+ int use_trx, int *trx_no_)
+{
+ int tfi;
+ uint8_t trx_no;
+
+ if (use_trx == -1 && ms->current_trx())
+ use_trx = ms->current_trx()->trx_no;
+
+ tfi = bts->tfi_find_free(dir, &trx_no, use_trx);
+ if (tfi < 0)
+ return -EBUSY;
+
+ if (trx_no_)
+ *trx_no_ = trx_no;
+
+ return tfi;
+}
/* Slot Allocation: Algorithm A
*
@@ -284,11 +302,14 @@ static void assign_dlink_tbf(
*/
int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
GprsMs *ms,
- struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single)
+ struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single,
+ int use_trx)
{
struct gprs_rlcmac_pdch *pdch;
int ts = -1;
uint8_t ul_slots, dl_slots;
+ int trx_no;
+ int rc;
int usf = -1;
int mask = 0xff;
const char *mask_reason = NULL;
@@ -296,6 +317,14 @@ int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
LOGP(DRLCMAC, LOGL_DEBUG, "Slot Allocation (Algorithm A) for class "
"%d\n", tbf->ms_class());
+ rc = tfi_find_free(bts->bts, ms, tbf->direction, use_trx, &trx_no);
+ if (rc < 0) {
+ LOGP(DRLCMAC, LOGL_NOTICE, "- Failed to allocate a TFI\n");
+ return rc;
+ }
+ tbf->m_tfi = rc;
+ tbf->trx = &bts->trx[trx_no];
+
dl_slots = ms->reserved_dl_slots();
ul_slots = ms->reserved_ul_slots();
@@ -348,7 +377,6 @@ int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
ms->set_reserved_slots(tbf->trx, 1 << ts, 1 << ts);
tbf->upgrade_to_multislot = 0;
-
return 0;
}
@@ -669,7 +697,7 @@ static int find_multi_slots(struct gprs_rlcmac_bts *bts,
*/
int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
GprsMs *ms,
- struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single)
+ struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, int use_trx)
{
uint8_t dl_slots = 0;
uint8_t ul_slots = 0;
@@ -679,6 +707,15 @@ int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
char slot_info[9] = {0};
int ts;
int rc;
+ int trx_no;
+
+ rc = tfi_find_free(bts->bts, ms, tbf->direction, use_trx, &trx_no);
+ if (rc < 0) {
+ LOGP(DRLCMAC, LOGL_NOTICE, "- Failed to allocate a TFI\n");
+ return rc;
+ }
+ tbf->m_tfi = rc;
+ tbf->trx = &bts->trx[trx_no];
if (!ms) {
LOGP(DRLCMAC, LOGL_ERROR, "MS not set\n");