aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/chan_alloc.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@netfilter.org>2009-12-24 10:10:16 +0100
committerHarald Welte <laforge@netfilter.org>2009-12-24 10:10:16 +0100
commit4c70454bae4122b0c72c37fdaad0caa117c93888 (patch)
treeb290429e75f699eda7989afca28a82a942832b47 /openbsc/src/chan_alloc.c
parent02cbff09df44715abf671d10a351092b9c8cf61b (diff)
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.
Diffstat (limited to 'openbsc/src/chan_alloc.c')
-rw-r--r--openbsc/src/chan_alloc.c38
1 files changed, 38 insertions, 0 deletions
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 */