diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bts.cpp | 16 | ||||
-rw-r--r-- | src/bts.h | 12 | ||||
-rw-r--r-- | src/gprs_rlcmac_ts_alloc.cpp | 14 | ||||
-rw-r--r-- | src/tbf.cpp | 15 |
4 files changed, 49 insertions, 8 deletions
diff --git a/src/bts.cpp b/src/bts.cpp index bc5ac945..6da8cdd8 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -1131,3 +1131,19 @@ gprs_rlcmac_dl_tbf *gprs_rlcmac_pdch::dl_tbf_by_tfi(uint8_t tfi) { return static_cast<gprs_rlcmac_dl_tbf *>(tbf_from_list_by_tfi(&bts_data()->dl_tbfs, tfi, GPRS_RLCMAC_DL_TBF)); } + +void gprs_rlcmac_pdch::attach_tbf(gprs_rlcmac_tbf *tbf) +{ + m_num_tbfs[tbf->direction] += 1; + LOGP(DRLCMAC, LOGL_INFO, "PDCH(TS %d, TRX %d): Attaching %s, %d TBFs.\n", + ts_no, trx_no(), tbf->name(), m_num_tbfs[tbf->direction]); +} + +void gprs_rlcmac_pdch::detach_tbf(gprs_rlcmac_tbf *tbf) +{ + OSMO_ASSERT(m_num_tbfs[tbf->direction] > 0); + + m_num_tbfs[tbf->direction] -= 1; + LOGP(DRLCMAC, LOGL_INFO, "PDCH(TS %d, TRX %d): Detaching %s, %d TBFs.\n", + ts_no, trx_no(), tbf->name(), m_num_tbfs[tbf->direction]); +} @@ -66,6 +66,11 @@ struct gprs_rlcmac_pdch { struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi); struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi); + + void attach_tbf(gprs_rlcmac_tbf *tbf); + void detach_tbf(gprs_rlcmac_tbf *tbf); + + unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const; #endif uint8_t m_is_enabled; /* TS is enabled */ @@ -93,6 +98,8 @@ private: gprs_rlcmac_tbf *tbf_from_list_by_tfi(struct llist_head *tbf_list, uint8_t tfi, enum gprs_rlcmac_tbf_direction dir); #endif + + uint8_t m_num_tbfs[2]; }; struct gprs_rlcmac_trx { @@ -299,6 +306,11 @@ inline BTS *gprs_rlcmac_pdch::bts() const return trx->bts; } +inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const +{ + return m_num_tbfs[dir]; +} + inline struct rate_ctr_group *BTS::rate_counters() const { return m_ratectrs; diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp index bae1ea5f..29749b8e 100644 --- a/src/gprs_rlcmac_ts_alloc.cpp +++ b/src/gprs_rlcmac_ts_alloc.cpp @@ -117,13 +117,23 @@ static int find_enabled_pdch(struct gprs_rlcmac_trx *trx, const uint8_t start_ts return 8; } +static void attach_tbf_to_pdch(struct gprs_rlcmac_pdch *pdch, + struct gprs_rlcmac_tbf *tbf) +{ + if (tbf->pdch[pdch->ts_no]) + tbf->pdch[pdch->ts_no]->detach_tbf(tbf); + + tbf->pdch[pdch->ts_no] = pdch; + pdch->attach_tbf(tbf); +} + static void assign_uplink_tbf_usf( struct gprs_rlcmac_pdch *pdch, struct gprs_rlcmac_ul_tbf *tbf, int8_t usf) { tbf->trx->ul_tbf[tbf->tfi()] = tbf; - tbf->pdch[pdch->ts_no] = pdch; tbf->m_usf[pdch->ts_no] = usf; + attach_tbf_to_pdch(pdch, tbf); } static void assign_dlink_tbf( @@ -131,7 +141,7 @@ static void assign_dlink_tbf( struct gprs_rlcmac_dl_tbf *tbf) { tbf->trx->dl_tbf[tbf->tfi()] = tbf; - tbf->pdch[pdch->ts_no] = pdch; + attach_tbf_to_pdch(pdch, tbf); } diff --git a/src/tbf.cpp b/src/tbf.cpp index 9bdc1f78..ddc3b91f 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -209,14 +209,17 @@ static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf) { int ts; - if (tbf->direction == GPRS_RLCMAC_UL_TBF) { + if (tbf->direction == GPRS_RLCMAC_UL_TBF) tbf->trx->ul_tbf[tbf->tfi()] = NULL; - for (ts = 0; ts < 8; ts++) - tbf->pdch[ts] = NULL; - } else { + else tbf->trx->dl_tbf[tbf->tfi()] = NULL; - for (ts = 0; ts < 8; ts++) - tbf->pdch[ts] = NULL; + + for (ts = 0; ts < 8; ts++) { + if (!tbf->pdch[ts]) + continue; + + tbf->pdch[ts]->detach_tbf(tbf); + tbf->pdch[ts] = NULL; } } |