aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf.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/tbf.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/tbf.cpp')
-rw-r--r--src/tbf.cpp48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 4a8fd337..70483e35 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -174,20 +174,12 @@ gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
int8_t use_trx, uint8_t ms_class,
uint32_t tlli, uint8_t ta, GprsMs *ms)
{
- uint8_t trx;
struct gprs_rlcmac_ul_tbf *tbf;
- int8_t tfi; /* must be signed */
#warning "Copy and paste with tbf_new_dl_assignment"
/* create new TBF, use same TRX as DL TBF */
- tfi = bts->bts->tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx, use_trx);
- if (tfi < 0) {
- LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
- /* FIXME: send reject */
- return NULL;
- }
/* use multislot class of downlink TBF */
- tbf = tbf_alloc_ul_tbf(bts, ms, tfi, trx, ms_class, 0);
+ tbf = tbf_alloc_ul_tbf(bts, ms, use_trx, ms_class, 0);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
/* FIXME: send reject */
@@ -274,7 +266,8 @@ int gprs_rlcmac_tbf::update()
return -EINVAL;
tbf_unlink_pdch(this);
- rc = bts_data->alloc_algorithm(bts_data, ms(), this, bts_data->alloc_algorithm_curst, 0);
+ rc = bts_data->alloc_algorithm(bts_data, ms(), this,
+ bts_data->alloc_algorithm_curst, 0, -1);
/* if no resource */
if (rc < 0) {
LOGP(DRLCMAC, LOGL_ERROR, "No resource after update???\n");
@@ -445,14 +438,11 @@ void gprs_rlcmac_tbf::poll_timeout()
}
static int setup_tbf(struct gprs_rlcmac_tbf *tbf, struct gprs_rlcmac_bts *bts,
- GprsMs *ms, uint8_t tfi, uint8_t trx,
+ GprsMs *ms, int8_t use_trx,
uint8_t ms_class, uint8_t single_slot)
{
int rc;
- if (trx >= 8 || tfi >= 32)
- return -1;
-
if (!tbf)
return -1;
@@ -461,12 +451,10 @@ static int setup_tbf(struct gprs_rlcmac_tbf *tbf, struct gprs_rlcmac_bts *bts,
tbf->m_created_ts = time(NULL);
tbf->bts = bts->bts;
- tbf->m_tfi = tfi;
- tbf->trx = &bts->trx[trx];
tbf->set_ms_class(ms_class);
/* select algorithm */
rc = bts->alloc_algorithm(bts, ms, tbf, bts->alloc_algorithm_curst,
- single_slot);
+ single_slot, use_trx);
/* if no resource */
if (rc < 0) {
return -1;
@@ -485,23 +473,24 @@ static int setup_tbf(struct gprs_rlcmac_tbf *tbf, struct gprs_rlcmac_bts *bts,
tbf->m_llc.init();
tbf->set_ms(ms);
+ LOGP(DRLCMAC, LOGL_INFO,
+ "Allocated %s: trx = %d, ul_slots = %02x, dl_slots = %02x\n",
+ tbf->name(), tbf->trx->trx_no, tbf->ul_slots(), tbf->dl_slots());
+
return 0;
}
struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
- GprsMs *ms, uint8_t tfi, uint8_t trx,
+ GprsMs *ms, int8_t use_trx,
uint8_t ms_class, uint8_t single_slot)
{
struct gprs_rlcmac_ul_tbf *tbf;
int rc;
LOGP(DRLCMAC, LOGL_DEBUG, "********** TBF starts here **********\n");
- LOGP(DRLCMAC, LOGL_INFO, "Allocating %s TBF: TFI=%d TRX=%d "
- "MS_CLASS=%d\n", "UL", tfi, trx, ms_class);
-
- if (trx >= 8 || tfi >= 32)
- return NULL;
+ LOGP(DRLCMAC, LOGL_INFO, "Allocating %s TBF: MS_CLASS=%d\n",
+ "UL", ms_class);
tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
@@ -513,7 +502,7 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
if (!ms)
ms = bts->bts->ms_alloc(ms_class);
- rc = setup_tbf(tbf, bts, ms, tfi, trx, ms_class, single_slot);
+ rc = setup_tbf(tbf, bts, ms, use_trx, ms_class, single_slot);
/* if no resource */
if (rc < 0) {
talloc_free(tbf);
@@ -527,18 +516,15 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
}
struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
- GprsMs *ms, uint8_t tfi, uint8_t trx,
+ GprsMs *ms, int8_t use_trx,
uint8_t ms_class, uint8_t single_slot)
{
struct gprs_rlcmac_dl_tbf *tbf;
int rc;
LOGP(DRLCMAC, LOGL_DEBUG, "********** TBF starts here **********\n");
- LOGP(DRLCMAC, LOGL_INFO, "Allocating %s TBF: TFI=%d TRX=%d "
- "MS_CLASS=%d\n", "DL", tfi, trx, ms_class);
-
- if (trx >= 8 || tfi >= 32)
- return NULL;
+ LOGP(DRLCMAC, LOGL_INFO, "Allocating %s TBF: MS_CLASS=%d\n",
+ "DL", ms_class);
tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf);
@@ -550,7 +536,7 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
if (!ms)
ms = bts->bts->ms_alloc(ms_class);
- rc = setup_tbf(tbf, bts, ms, tfi, trx, ms_class, single_slot);
+ rc = setup_tbf(tbf, bts, ms, use_trx, ms_class, single_slot);
/* if no resource */
if (rc < 0) {
talloc_free(tbf);