diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2012-08-07 17:06:08 +0200 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2012-08-07 17:06:08 +0200 |
commit | adb2f185387fd2d6a40a8bdceb336132f8dd19ca (patch) | |
tree | 007be7211778e011d22f0c65519466c95ea12d20 /src/gprs_rlcmac.cpp | |
parent | 07e97cf8a551b05d7f5f3f9583b68b2eff0f1c23 (diff) |
Assign TFI to complete TRX, not just one TS
This is required, since we may change slot allocation. In case of a
change, we do not want to be unable to change, if the same TFI on one of
the other slots is already in use by a different TBF (having same TFI, but
on different slot).
Diffstat (limited to 'src/gprs_rlcmac.cpp')
-rw-r--r-- | src/gprs_rlcmac.cpp | 81 |
1 files changed, 25 insertions, 56 deletions
diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp index 1aeb9b18..cfd3ad9f 100644 --- a/src/gprs_rlcmac.cpp +++ b/src/gprs_rlcmac.cpp @@ -120,9 +120,9 @@ int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, uint8_t *_ts, LOGP(DRLCMAC, LOGL_DEBUG, "Searching for first unallocated TFI: " "TRX=%d first TS=%d\n", trx, ts); if (dir == GPRS_RLCMAC_UL_TBF) - tbfp = pdch->ul_tbf; + tbfp = bts->trx[trx].ul_tbf; else - tbfp = pdch->dl_tbf; + tbfp = bts->trx[trx].dl_tbf; for (tfi = 0; tfi < 32; tfi++) { if (!tbfp[tfi]) break; @@ -163,19 +163,19 @@ static inline int8_t find_free_usf(struct gprs_rlcmac_pdch *pdch, uint8_t ts) } /* lookup TBF Entity (by TFI) */ -struct gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, uint8_t trx, uint8_t ts, +struct gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, uint8_t trx, enum gprs_rlcmac_tbf_direction dir) { struct gprs_rlcmac_tbf *tbf; struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts; - if (tfi >= 32 || trx >= 8 || ts >= 8) + if (tfi >= 32 || trx >= 8) return NULL; if (dir == GPRS_RLCMAC_UL_TBF) - tbf = bts->trx[trx].pdch[ts].ul_tbf[tfi]; + tbf = bts->trx[trx].ul_tbf[tfi]; else - tbf = bts->trx[trx].pdch[ts].dl_tbf[tfi]; + tbf = bts->trx[trx].dl_tbf[tfi]; if (!tbf) return NULL; @@ -312,38 +312,24 @@ int alloc_algorithm_a(struct gprs_rlcmac_tbf *old_tbf, } tbf->tsc = pdch->tsc; if (tbf->direction == GPRS_RLCMAC_UL_TBF) { - /* if TFI is free on TS */ - if (!pdch->ul_tbf[tbf->tfi]) { - /* if USF available */ - usf = find_free_usf(pdch, ts); - if (usf >= 0) { - LOGP(DRLCMAC, LOGL_DEBUG, "- Assign uplink " - "TS=%d USF=%d\n", ts, usf); - pdch->ul_tbf[tbf->tfi] = tbf; - tbf->pdch[ts] = pdch; - } else { - LOGP(DRLCMAC, LOGL_NOTICE, "- Failed " - "allocating TS=%d, no USF available\n", - ts); - return -EBUSY; - } - } else { - LOGP(DRLCMAC, LOGL_NOTICE, "- Failed allocating " - "TS=%d, TFI is not available\n", ts); - return -EBUSY; - } - } else { - /* if TFI is free on TS */ - if (!pdch->dl_tbf[tbf->tfi]) { - LOGP(DRLCMAC, LOGL_DEBUG, "- Assign downlink TS=%d\n", - ts); - pdch->dl_tbf[tbf->tfi] = tbf; + /* if USF available */ + usf = find_free_usf(pdch, ts); + if (usf >= 0) { + LOGP(DRLCMAC, LOGL_DEBUG, "- Assign uplink " + "TS=%d USF=%d\n", ts, usf); + bts->trx[tbf->trx].ul_tbf[tbf->tfi] = tbf; + pdch->ul_tbf[tbf->tfi] = tbf; tbf->pdch[ts] = pdch; } else { - LOGP(DRLCMAC, LOGL_NOTICE, "- Failed allocating " - "TS=%d, TFI is not available\n", ts); + LOGP(DRLCMAC, LOGL_NOTICE, "- Failed " + "allocating TS=%d, no USF available\n", ts); return -EBUSY; } + } else { + LOGP(DRLCMAC, LOGL_DEBUG, "- Assign downlink TS=%d\n", ts); + bts->trx[tbf->trx].dl_tbf[tbf->tfi] = tbf; + pdch->dl_tbf[tbf->tfi] = tbf; + tbf->pdch[ts] = pdch; } /* the only one TS is the common TS */ tbf->first_common_ts = ts; @@ -474,18 +460,6 @@ int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf, i++; continue; } - /* check if TFI for slot is available - * This is only possible for downlink TFI. */ - if (tbf->direction == GPRS_RLCMAC_DL_TBF - && pdch->dl_tbf[tbf->tfi]) { - LOGP(DRLCMAC, LOGL_DEBUG, "- Skipping TS %d, because " - "already assigned to other DL TBF with " - "TFI=%d\n", ts, tbf->tfi); - /* increase window for Type 1 */ - if (Type == 1) - i++; - continue; - } rx_window |= (1 << ts); LOGP(DRLCMAC, LOGL_DEBUG, "- Selected DL TS %d\n", ts); @@ -634,16 +608,6 @@ int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf, i++; continue; } - /* check if TFI for slot is available */ - if (pdch->ul_tbf[tbf->tfi]) { - LOGP(DRLCMAC, LOGL_DEBUG, "- Skipping TS %d, " - "because already assigned to other " - "UL TBF with TFI=%d\n", ts, tbf->tfi); - /* increase window for Type 1 */ - if (Type == 1) - i++; - continue; - } /* check for free usf */ usf[ts] = find_free_usf(pdch, ts); if (usf[ts] < 0) { @@ -703,6 +667,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf, LOGP(DRLCMAC, LOGL_DEBUG, "- Assigning DL TS " "%d\n", ts); pdch = &bts->trx[tbf->trx].pdch[ts]; + bts->trx[tbf->trx].dl_tbf[tbf->tfi] = tbf; pdch->dl_tbf[tbf->tfi] = tbf; tbf->pdch[ts] = pdch; slotcount++; @@ -723,6 +688,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf, LOGP(DRLCMAC, LOGL_DEBUG, "- Assigning UL TS " "%d\n", ts); pdch = &bts->trx[tbf->trx].pdch[ts]; + bts->trx[tbf->trx].ul_tbf[tbf->tfi] = tbf; pdch->ul_tbf[tbf->tfi] = tbf; tbf->pdch[ts] = pdch; tbf->dir.ul.usf[ts] = usf[ts]; @@ -739,10 +705,12 @@ int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf, static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf) { + struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts; struct gprs_rlcmac_pdch *pdch; int ts; if (tbf->direction == GPRS_RLCMAC_UL_TBF) { + bts->trx[tbf->trx].ul_tbf[tbf->tfi] = NULL; for (ts = 0; ts < 8; ts++) { pdch = tbf->pdch[ts]; if (pdch) @@ -750,6 +718,7 @@ static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf) tbf->pdch[ts] = NULL; } } else { + bts->trx[tbf->trx].dl_tbf[tbf->tfi] = NULL; for (ts = 0; ts < 8; ts++) { pdch = tbf->pdch[ts]; if (pdch) |