From c57333e1581131a794a5dd1c1d30f97e73120dfe Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 21 Dec 2020 13:14:54 +0100 Subject: Add a bts_model->bts_init() and trx_init() call-back function This allows a given BTS model driver to initialize data structures specific cor this BTS instance (or a TRX for this BTS instance). Change-Id: Icbad9cdc12221c9ad997267d77e5414edcbac538 --- include/osmocom/bsc/bts.h | 8 ++++++++ src/osmo-bsc/bts.c | 13 +++++++++++++ src/osmo-bsc/bts_trx.c | 7 +++++++ 3 files changed, 28 insertions(+) diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h index 7d070af2e..aef0e0384 100644 --- a/include/osmocom/bsc/bts.h +++ b/include/osmocom/bsc/bts.h @@ -178,7 +178,15 @@ struct gsm_bts_model { const char *name; bool started; + /* start the model itself */ int (*start)(struct gsm_network *net); + + /* initialize a single BTS for this model */ + int (*bts_init)(struct gsm_bts *bts); + + /* initialize a single TRX for this model */ + int (*trx_init)(struct gsm_bts_trx *trx); + int (*oml_rcvmsg)(struct msgb *msg); char * (*oml_status)(const struct gsm_bts *bts); diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c index 747e8b7cc..39122ae03 100644 --- a/src/osmo-bsc/bts.c +++ b/src/osmo-bsc/bts.c @@ -503,6 +503,19 @@ int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type) model->started = true; } + if (model->bts_init) { + int rc = model->bts_init(bts); + if (rc < 0) + return rc; + } + + /* handle those TRX which are already allocated at the time we set the type */ + if (model->trx_init) { + struct gsm_bts_trx *trx; + llist_for_each_entry(trx, &bts->trx_list, list) + model->trx_init(trx); + } + switch (bts->type) { case GSM_BTS_TYPE_OSMOBTS: /* Enable dynamic Uplink power control by default */ diff --git a/src/osmo-bsc/bts_trx.c b/src/osmo-bsc/bts_trx.c index 0e5223874..6d98929b5 100644 --- a/src/osmo-bsc/bts_trx.c +++ b/src/osmo-bsc/bts_trx.c @@ -120,6 +120,13 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts) if (trx->nr != 0) trx->nominal_power = bts->c0->nominal_power; + if (bts->model && bts->model->trx_init) { + if (bts->model->trx_init(trx) < 0) { + talloc_free(trx); + return NULL; + } + } + llist_add_tail(&trx->list, &bts->trx_list); return trx; -- cgit v1.2.3