diff options
Diffstat (limited to 'src/sba.cpp')
-rw-r--r-- | src/sba.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/sba.cpp b/src/sba.cpp index 46c1431..117aa34 100644 --- a/src/sba.cpp +++ b/src/sba.cpp @@ -49,8 +49,27 @@ int SBAController::alloc( struct gprs_rlcmac_pdch *pdch; struct gprs_rlcmac_sba *sba; - int8_t trx, ts; + int8_t ts; uint32_t fn; + bool trxs[8]; + int selected_trx; + int ret; + + ret = m_bts.get_possible_trxs_sba(trxs); + + if (ret == -EINVAL) + return -EINVAL; + + selected_trx = m_bts.get_suitable_trx(trxs); + + for (ts = 7; ts >= 0; ts--) { + pdch = &m_bts.bts_data()->trx[selected_trx].pdch[ts]; + if (!pdch->is_enabled()) + continue; + break; + } + if (ts < 0) + return -EINVAL; sba = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_sba); if (!sba) @@ -59,25 +78,10 @@ int SBAController::alloc( if (!gsm48_ta_is_valid(ta)) return -EINVAL; - for (trx = 0; trx < 8; trx++) { - for (ts = 7; ts >= 0; ts--) { - pdch = &m_bts.bts_data()->trx[trx].pdch[ts]; - if (!pdch->is_enabled()) - continue; - break; - } - if (ts >= 0) - break; - } - if (trx == 8) { - LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH available.\n"); - talloc_free(sba); - return -EINVAL; - } fn = (pdch->last_rts_fn + AGCH_START_OFFSET) % 2715648; - sba->trx_no = trx; + sba->trx_no = selected_trx; sba->ts_no = ts; sba->fn = fn; sba->ta = ta; @@ -85,9 +89,11 @@ int SBAController::alloc( llist_add(&sba->list, &m_sbas); m_bts.sba_allocated(); - *_trx = trx; + *_trx = selected_trx; *_ts = ts; *_fn = fn; + LOGP(DRLCMAC, LOGL_DEBUG, " sba fn=%d ts = %d trx = %d\n", fn, ts, selected_trx); + return 0; } |