diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-10-26 19:17:58 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-10-30 21:24:11 +0100 |
commit | 70ddde6929a0fe24b509da6a621ca138daefa9a3 (patch) | |
tree | 15e03cfa35fa3133f5b4c7d952da64beb0505955 /src | |
parent | f63cabd931cc0d03420b41d5990d04e48dbe74c4 (diff) |
tbf/bts: Move the tfi_find_free into the bts
Diffstat (limited to 'src')
-rw-r--r-- | src/bts.cpp | 55 | ||||
-rw-r--r-- | src/bts.h | 2 | ||||
-rw-r--r-- | src/gprs_rlcmac.cpp | 55 | ||||
-rw-r--r-- | src/gprs_rlcmac_data.cpp | 2 | ||||
-rw-r--r-- | src/tbf.cpp | 4 | ||||
-rw-r--r-- | src/tbf.h | 3 |
6 files changed, 60 insertions, 61 deletions
diff --git a/src/bts.cpp b/src/bts.cpp index cbe6303..cc53f25 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -236,6 +236,61 @@ gprs_rlcmac_tbf *BTS::tbf_by_tfi(uint8_t tfi, uint8_t trx, return NULL; } +/* FIXME: spread resources over multiple TRX. Also add option to use same + * TRX in case of existing TBF for TLLI in the other direction. */ +/* search for free TFI and return TFI, TRX */ +int BTS::tfi_find_free(enum gprs_rlcmac_tbf_direction dir, + uint8_t *_trx, int8_t use_trx) +{ + struct gprs_rlcmac_pdch *pdch; + struct gprs_rlcmac_tbf **tbfp; + uint8_t trx_from, trx_to, trx, ts, tfi; + + if (use_trx >= 0 && use_trx < 8) + trx_from = trx_to = use_trx; + else { + trx_from = 0; + trx_to = 7; + } + + /* on TRX find first enabled TS */ + for (trx = trx_from; trx <= trx_to; trx++) { + for (ts = 0; ts < 8; ts++) { + pdch = &m_bts.trx[trx].pdch[ts]; + if (!pdch->is_enabled()) + continue; + break; + } + if (ts < 8) + break; + } + if (trx > trx_to) { + LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH available.\n"); + return -EINVAL; + } + + + LOGP(DRLCMAC, LOGL_DEBUG, "Searching for first unallocated TFI: " + "TRX=%d first TS=%d\n", trx, ts); + if (dir == GPRS_RLCMAC_UL_TBF) + tbfp = m_bts.trx[trx].ul_tbf; + else + tbfp = m_bts.trx[trx].dl_tbf; + for (tfi = 0; tfi < 32; tfi++) { + if (!tbfp[tfi]) + break; + } + + if (tfi < 32) { + LOGP(DRLCMAC, LOGL_DEBUG, " Found TFI=%d.\n", tfi); + *_trx = trx; + return tfi; + } + LOGP(DRLCMAC, LOGL_NOTICE, "No TFI available.\n"); + + return -1; +} + /* * PDCH code below. TODO: move to a separate file @@ -166,6 +166,8 @@ public: gprs_rlcmac_tbf *tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts); gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, uint8_t trx, enum gprs_rlcmac_tbf_direction dir); + int tfi_find_free(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx); + private: int m_cur_fn; struct gprs_rlcmac_bts m_bts; diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp index 62e8ea7..8abe475 100644 --- a/src/gprs_rlcmac.cpp +++ b/src/gprs_rlcmac.cpp @@ -113,61 +113,6 @@ void debug_diagram(BTS *bts, int diag, const char *format, ...) } #endif -/* FIXME: spread resources over multiple TRX. Also add option to use same - * TRX in case of existing TBF for TLLI in the other direction. */ -/* search for free TFI and return TFI, TRX */ -int tfi_find_free(struct gprs_rlcmac_bts *bts, enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx) -{ - struct gprs_rlcmac_pdch *pdch; - struct gprs_rlcmac_tbf **tbfp; - uint8_t trx_from, trx_to, trx, ts, tfi; - - if (use_trx >= 0 && use_trx < 8) - trx_from = trx_to = use_trx; - else { - trx_from = 0; - trx_to = 7; - } - - /* on TRX find first enabled TS */ - for (trx = trx_from; trx <= trx_to; trx++) { - for (ts = 0; ts < 8; ts++) { - pdch = &bts->trx[trx].pdch[ts]; - if (!pdch->is_enabled()) - continue; - break; - } - if (ts < 8) - break; - } - if (trx > trx_to) { - LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH available.\n"); - return -EINVAL; - } - - - LOGP(DRLCMAC, LOGL_DEBUG, "Searching for first unallocated TFI: " - "TRX=%d first TS=%d\n", trx, ts); - if (dir == GPRS_RLCMAC_UL_TBF) - tbfp = bts->trx[trx].ul_tbf; - else - tbfp = bts->trx[trx].dl_tbf; - for (tfi = 0; tfi < 32; tfi++) { - if (!tbfp[tfi]) - break; - } - - if (tfi < 32) { - LOGP(DRLCMAC, LOGL_DEBUG, " Found TFI=%d.\n", tfi); - *_trx = trx; - return tfi; - } - LOGP(DRLCMAC, LOGL_NOTICE, "No TFI available.\n"); - - return -1; -} - /* Send Uplink unit-data to SGSN. */ int gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf) { diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp index d5bebff..a9720ca 100644 --- a/src/gprs_rlcmac_data.cpp +++ b/src/gprs_rlcmac_data.cpp @@ -334,7 +334,7 @@ int gprs_rlcmac_rcv_rach(struct gprs_rlcmac_bts *bts, } else { // Create new TBF #warning "Copy and pate with other routines.." - tfi = tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx, -1); + tfi = bts->bts->tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx, -1); if (tfi < 0) { LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n"); /* FIXME: send reject */ diff --git a/src/tbf.cpp b/src/tbf.cpp index 2282aea..4225b3b 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -158,7 +158,7 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts, // Create new TBF (any TRX) #warning "Copy and paste with alloc_ul_tbf" - tfi = tfi_find_free(bts, GPRS_RLCMAC_DL_TBF, &trx, use_trx); + tfi = bts->bts->tfi_find_free(GPRS_RLCMAC_DL_TBF, &trx, use_trx); if (tfi < 0) { LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n"); /* FIXME: send reject */ @@ -227,7 +227,7 @@ struct gprs_rlcmac_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts, #warning "Copy and paste with tbf_new_dl_assignment" /* create new TBF, use sme TRX as DL TBF */ - tfi = tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx, use_trx); + tfi = bts->bts->tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx, use_trx); if (tfi < 0) { LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n"); /* FIXME: send reject */ @@ -219,9 +219,6 @@ struct gprs_rlcmac_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts, int8_t use_trx, uint8_t ms_class, uint32_t tlli, uint8_t ta, struct gprs_rlcmac_tbf *dl_tbf); -int tfi_find_free(struct gprs_rlcmac_bts *bts, enum gprs_rlcmac_tbf_direction dir, - uint8_t *_trx, int8_t use_trx); - struct gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_tbf *old_tbf, enum gprs_rlcmac_tbf_direction dir, uint8_t tfi, uint8_t trx, |