From 4c70454bae4122b0c72c37fdaad0caa117c93888 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 24 Dec 2009 10:10:16 +0100 Subject: channel allocator: don't allocate channels of unavalable TRXs In case we have multiple TRX configured, but not all of them are actually active/operational, we should not try to allocate channels from such transceivers. --- openbsc/src/chan_alloc.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'openbsc/src/chan_alloc.c') diff --git a/openbsc/src/chan_alloc.c b/openbsc/src/chan_alloc.c index 632860814..4bdf722b0 100644 --- a/openbsc/src/chan_alloc.c +++ b/openbsc/src/chan_alloc.c @@ -35,6 +35,32 @@ static void auto_release_channel(void *_lchan); +static int ts_is_usable(struct gsm_bts_trx_ts *ts) +{ + /* FIXME: How does this behave for BS-11 ? */ + if (is_ipaccess_bts(ts->trx->bts)) { + if (ts->nm_state.operational != NM_OPSTATE_ENABLED || + ts->nm_state.availability != NM_AVSTATE_OK) + return 0; + } + + return 1; +} + +static int trx_is_usable(struct gsm_bts_trx *trx) +{ + /* FIXME: How does this behave for BS-11 ? */ + if (is_ipaccess_bts(trx->bts)) { + if (trx->nm_state.operational != NM_OPSTATE_ENABLED || + trx->nm_state.availability != NM_AVSTATE_OK || + trx->bb_transc.nm_state.operational != NM_OPSTATE_ENABLED || + trx->bb_transc.nm_state.availability != NM_AVSTATE_OK) + return 0; + } + + return 1; +} + struct gsm_bts_trx_ts *ts_c0_alloc(struct gsm_bts *bts, enum gsm_phys_chan_config pchan) { @@ -63,6 +89,9 @@ struct gsm_bts_trx_ts *ts_alloc(struct gsm_bts *bts, llist_for_each_entry(trx, &bts->trx_list, list) { int from, to; + if (!trx_is_usable(trx)) + continue; + /* the following constraints are pure policy, * no requirement to put this restriction in place */ if (trx == bts->c0) { @@ -97,6 +126,10 @@ struct gsm_bts_trx_ts *ts_alloc(struct gsm_bts *bts, for (j = from; j <= to; j++) { struct gsm_bts_trx_ts *ts = &trx->ts[j]; + + if (!ts_is_usable(ts)) + continue; + if (ts->pchan == GSM_PCHAN_NONE) { ts->pchan = pchan; /* set channel attribute on OML */ @@ -130,8 +163,13 @@ _lc_find_trx(struct gsm_bts_trx *trx, enum gsm_phys_chan_config pchan) struct gsm_bts_trx_ts *ts; int j, ss; + if (!trx_is_usable(trx)) + return NULL; + for (j = 0; j < 8; j++) { ts = &trx->ts[j]; + if (!ts_is_usable(ts)) + continue; if (ts->pchan != pchan) continue; /* check if all sub-slots are allocated yet */ -- cgit v1.2.3