aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-09-30 12:52:04 +0200
committerlaforge <laforge@osmocom.org>2020-10-15 05:55:36 +0000
commit4338de5f51068dbd4ea1b8e3a61bdfdf5ede1833 (patch)
tree0a803d32c1551af16e833d1702026b869f685e10 /src
parent12e15479d69b226ea1fb6a2f2a478b6df3dd6682 (diff)
Introduce NM BTS Site Manager FSM
Diffstat (limited to 'src')
-rw-r--r--src/ipaccess/Makefile.am4
-rw-r--r--src/osmo-bsc/Makefile.am2
-rw-r--r--src/osmo-bsc/abis_nm.c13
-rw-r--r--src/osmo-bsc/bts.c22
-rw-r--r--src/osmo-bsc/bts_ipaccess_nanobts.c47
-rw-r--r--src/osmo-bsc/nm_bts_sm_fsm.c279
-rw-r--r--src/osmo-bsc/nm_common_fsm.c32
-rw-r--r--src/utils/Makefile.am4
8 files changed, 387 insertions, 16 deletions
diff --git a/src/ipaccess/Makefile.am b/src/ipaccess/Makefile.am
index 717a6a187..0e06caabf 100644
--- a/src/ipaccess/Makefile.am
+++ b/src/ipaccess/Makefile.am
@@ -54,6 +54,8 @@ ipaccess_config_LDADD = \
$(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \
$(top_builddir)/src/osmo-bsc/gsm_data.o \
$(top_builddir)/src/osmo-bsc/net_init.o \
+ $(top_builddir)/src/osmo-bsc/nm_common_fsm.o \
+ $(top_builddir)/src/osmo-bsc/nm_bts_sm_fsm.o \
$(OSMO_LIBS) \
$(NULL)
@@ -68,5 +70,7 @@ ipaccess_proxy_LDADD = \
$(top_builddir)/src/osmo-bsc/bts.o \
$(top_builddir)/src/osmo-bsc/bts_trx.o \
$(top_builddir)/src/osmo-bsc/gsm_data.o \
+ $(top_builddir)/src/osmo-bsc/nm_common_fsm.o \
+ $(top_builddir)/src/osmo-bsc/nm_bts_sm_fsm.o \
$(OSMO_LIBS) \
$(NULL)
diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am
index 4473fc14c..ffa39a03e 100644
--- a/src/osmo-bsc/Makefile.am
+++ b/src/osmo-bsc/Makefile.am
@@ -76,6 +76,8 @@ osmo_bsc_SOURCES = \
neighbor_ident.c \
neighbor_ident_vty.c \
net_init.c \
+ nm_common_fsm.c \
+ nm_bts_sm_fsm.c \
gsm_08_08.c \
osmo_bsc_bssap.c \
osmo_bsc_ctrl.c \
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index 0bcb81c98..511c4b3e2 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -826,6 +826,14 @@ static int abis_nm_rx_opstart_ack(struct msgb *mb)
return 0;
}
+static int abis_nm_rx_opstart_nack(struct msgb *mb)
+{
+ struct abis_om_fom_hdr *foh = msgb_l3(mb);
+ DEBUGPFOH(DNM, foh, "Opstart NACK\n");
+ osmo_signal_dispatch(SS_NM, S_NM_OPSTART_NACK, mb);
+ return 0;
+}
+
static int abis_nm_rx_set_radio_attr_ack(struct msgb *mb)
{
struct abis_om_fom_hdr *foh = msgb_l3(mb);
@@ -947,7 +955,10 @@ static int abis_nm_rcvmsg_fom(struct msgb *mb)
ret = abis_nm_rx_lmt_event(mb);
break;
case NM_MT_OPSTART_ACK:
- abis_nm_rx_opstart_ack(mb);
+ ret = abis_nm_rx_opstart_ack(mb);
+ break;
+ case NM_MT_OPSTART_NACK:
+ ret = abis_nm_rx_opstart_nack(mb);
break;
case NM_MT_SET_CHAN_ATTR_ACK:
DEBUGPFOH(DNM, foh, "Set Channel Attributes ACK\n");
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index ce1b20068..fe1641230 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -23,6 +23,7 @@
#include <osmocom/bsc/gsm_data.h>
#include <osmocom/bsc/bts.h>
#include <osmocom/bsc/debug.h>
+#include <osmocom/bsc/nm_common_fsm.h>
const struct value_string bts_attribute_names[] = {
OSMO_VALUE_STRING(BTS_TYPE_VARIANT),
@@ -146,6 +147,15 @@ static const struct gprs_rlc_cfg rlc_cfg_default = {
.initial_mcs = 6,
};
+static int gsm_bts_talloc_destructor(struct gsm_bts *bts)
+{
+ if (bts->site_mgr.mo.fi) {
+ osmo_fsm_inst_free(bts->site_mgr.mo.fi);
+ bts->site_mgr.mo.fi = NULL;
+ }
+ return 0;
+}
+
/* Initialize those parts that don't require osmo-bsc specific dependencies.
* This part is shared among the thin programs in osmo-bsc/src/utils/.
* osmo-bsc requires further initialization that pulls in more dependencies (see
@@ -159,6 +169,8 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num)
if (!bts)
return NULL;
+ talloc_set_destructor(bts, gsm_bts_talloc_destructor);
+
bts->nr = bts_num;
bts->num_trx = 0;
INIT_LLIST_HEAD(&bts->trx_list);
@@ -166,10 +178,12 @@ struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num)
bts->ms_max_power = 15; /* dBm */
- gsm_mo_init(&bts->mo, bts, NM_OC_BTS,
- bts->nr, 0xff, 0xff);
- gsm_mo_init(&bts->site_mgr.mo, bts, NM_OC_SITE_MANAGER,
- 0xff, 0xff, 0xff);
+ bts->site_mgr.mo.fi = osmo_fsm_inst_alloc(&nm_bts_sm_fsm, bts, &bts->site_mgr,
+ LOGL_INFO, NULL);
+ osmo_fsm_inst_update_id_f(bts->site_mgr.mo.fi, "bts_sm");
+ gsm_mo_init(&bts->site_mgr.mo, bts, NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff);
+
+ gsm_mo_init(&bts->mo, bts, NM_OC_BTS, bts->nr, 0xff, 0xff);
for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
bts->gprs.nsvc[i].bts = bts;
diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c b/src/osmo-bsc/bts_ipaccess_nanobts.c
index 4c95196f8..457448cdd 100644
--- a/src/osmo-bsc/bts_ipaccess_nanobts.c
+++ b/src/osmo-bsc/bts_ipaccess_nanobts.c
@@ -46,6 +46,7 @@
#include <osmocom/bsc/paging.h>
#include <osmocom/bsc/timeslot_fsm.h>
#include <osmocom/bsc/bts.h>
+#include <osmocom/bsc/nm_common_fsm.h>
static int bts_model_nanobts_start(struct gsm_network *net);
static void bts_model_nanobts_e1line_bind_ops(struct e1inp_line *line);
@@ -127,6 +128,7 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd)
void *obj = nsd->obj;
struct gsm_nm_state *new_state = nsd->new_state;
+ struct gsm_bts_sm *bts_sm;
struct gsm_bts *bts;
struct gsm_bts_trx *trx;
struct gsm_bts_trx_ts *ts;
@@ -146,12 +148,8 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd)
switch (obj_class) {
case NM_OC_SITE_MANAGER:
- bts = container_of(obj, struct gsm_bts, site_mgr);
- if ((new_state->operational == NM_OPSTATE_ENABLED &&
- new_state->availability == NM_AVSTATE_OK) ||
- (new_state->operational == NM_OPSTATE_DISABLED &&
- new_state->availability == NM_AVSTATE_OFF_LINE))
- abis_nm_opstart(bts, obj_class, 0xff, 0xff, 0xff);
+ bts_sm = obj;
+ osmo_fsm_inst_dispatch(bts_sm->mo.fi, NM_EV_STATE_CHG_REP, nsd);
break;
case NM_OC_BTS:
bts = obj;
@@ -258,16 +256,18 @@ static int sw_activ_rep(struct msgb *mb)
struct abis_om_fom_hdr *foh = msgb_l3(mb);
struct e1inp_sign_link *sign_link = mb->dst;
struct gsm_bts *bts = sign_link->trx->bts;
- struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr);
-
- if (!trx)
- return -EINVAL;
+ struct gsm_bts_trx *trx;
- if (!is_ipaccess_bts(trx->bts))
+ if (!is_ipaccess_bts(bts))
return 0;
switch (foh->obj_class) {
+ case NM_OC_SITE_MANAGER:
+ osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_SW_ACT_REP, NULL);
+ break;
case NM_OC_BASEB_TRANSC:
+ if (!(trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr)))
+ return -EINVAL;
abis_nm_chg_adm_state(trx->bts, foh->obj_class,
trx->bts->bts_nr, trx->nr, 0xff,
NM_STATE_UNLOCKED);
@@ -278,6 +278,8 @@ static int sw_activ_rep(struct msgb *mb)
3003, trx->rsl_tei);
break;
case NM_OC_RADIO_CARRIER: {
+ if (!(trx = gsm_bts_trx_num(bts, foh->obj_inst.trx_nr)))
+ return -EINVAL;
/*
* Locking the radio carrier will make it go
* offline again and we would come here. The
@@ -318,7 +320,12 @@ static void nm_rx_opstart_ack_chan(struct msgb *oml_msg)
static void nm_rx_opstart_ack(struct msgb *oml_msg)
{
struct abis_om_fom_hdr *foh = msgb_l3(oml_msg);
+ struct e1inp_sign_link *sign_link = oml_msg->dst;
+ struct gsm_bts *bts = sign_link->trx->bts;
switch (foh->obj_class) {
+ case NM_OC_SITE_MANAGER:
+ osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_OPSTART_ACK, NULL);
+ break;
case NM_OC_CHANNEL:
nm_rx_opstart_ack_chan(oml_msg);
break;
@@ -327,6 +334,20 @@ static void nm_rx_opstart_ack(struct msgb *oml_msg)
}
}
+static void nm_rx_opstart_nack(struct msgb *oml_msg)
+{
+ struct abis_om_fom_hdr *foh = msgb_l3(oml_msg);
+ struct e1inp_sign_link *sign_link = oml_msg->dst;
+ struct gsm_bts *bts = sign_link->trx->bts;
+ switch (foh->obj_class) {
+ case NM_OC_SITE_MANAGER:
+ osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_OPSTART_NACK, NULL);
+ break;
+ default:
+ break;
+ }
+}
+
static void nm_rx_set_radio_attr_ack(struct msgb *oml_msg)
{
struct abis_om_fom_hdr *foh = msgb_l3(oml_msg);
@@ -358,6 +379,9 @@ static int bts_ipa_nm_sig_cb(unsigned int subsys, unsigned int signal,
case S_NM_OPSTART_ACK:
nm_rx_opstart_ack(signal_data);
return 0;
+ case S_NM_OPSTART_NACK:
+ nm_rx_opstart_nack(signal_data);
+ return 0;
case S_NM_SET_RADIO_ATTR_ACK:
nm_rx_set_radio_attr_ack(signal_data);
return 0;
@@ -442,6 +466,7 @@ void ipaccess_drop_oml(struct gsm_bts *bts, const char *reason)
llist_for_each_entry(trx, &bts->trx_list, list)
ipaccess_drop_rsl(trx, "OML link drop");
+ osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_OML_DOWN, NULL);
gsm_bts_all_ts_dispatch(bts, TS_EV_OML_DOWN, NULL);
bts->ip_access.flags = 0;
diff --git a/src/osmo-bsc/nm_bts_sm_fsm.c b/src/osmo-bsc/nm_bts_sm_fsm.c
new file mode 100644
index 000000000..94ca9d3d4
--- /dev/null
+++ b/src/osmo-bsc/nm_bts_sm_fsm.c
@@ -0,0 +1,279 @@
+/* NM BTS Site Manager FSM */
+
+/* (C) 2020 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>
+ * Author: Pau Espin Pedrol <pespin@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <inttypes.h>
+
+#include <osmocom/core/fsm.h>
+#include <osmocom/core/tdef.h>
+#include <osmocom/gsm/protocol/gsm_12_21.h>
+
+#include <osmocom/bsc/bts.h>
+#include <osmocom/bsc/signal.h>
+#include <osmocom/bsc/abis_nm.h>
+#include <osmocom/bsc/nm_common_fsm.h>
+#include <osmocom/bsc/debug.h>
+
+#define X(s) (1 << (s))
+
+#define nm_bts_sm_fsm_state_chg(fi, NEXT_STATE) \
+ osmo_fsm_inst_state_chg(fi, NEXT_STATE, 0, 0)
+
+//////////////////////////
+// FSM STATE ACTIONS
+//////////////////////////
+
+static void st_op_disabled_notinstalled_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ struct gsm_bts_sm *site_mgr = (struct gsm_bts_sm *)fi->priv;
+
+ site_mgr->mo.opstart_sent = false;
+}
+
+static void st_op_disabled_notinstalled(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+ struct gsm_bts_sm *site_mgr = (struct gsm_bts_sm *)fi->priv;
+ struct gsm_bts *bts = gsm_bts_sm_get_bts(site_mgr);
+ struct nm_statechg_signal_data *nsd;
+ struct gsm_nm_state *new_state;
+
+ switch (event) {
+ case NM_EV_SW_ACT_REP:
+ break;
+ case NM_EV_STATE_CHG_REP:
+ nsd = (struct nm_statechg_signal_data *)data;
+ new_state = nsd->new_state;
+ if (new_state->operational == NM_OPSTATE_ENABLED) {
+ /* nanobts always go directly into Reported ENABLED state during
+ startup, but we still need to OPSTART it, otherwise it won't
+ connect on RSL later on */
+ if (bts->type == GSM_BTS_TYPE_NANOBTS) {
+ site_mgr->mo.opstart_sent = true;
+ abis_nm_opstart(bts, NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff);
+ } else {
+ LOGPFSML(fi, LOGL_NOTICE, "Received BTS Site Mgr State Report Enabled "
+ "without Opstart. You are probably using a nanoBTS but don't "
+ "have your .cfg with 'type nanobts'\n");
+ }
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_ENABLED);
+ return;
+ }
+ switch (new_state->availability) { /* operational = DISABLED */
+ case NM_AVSTATE_DEPENDENCY:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_DEPENDENCY);
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_OFFLINE);
+ return;
+ default:
+ return;
+ }
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+static void st_op_disabled_dependency(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+ struct nm_statechg_signal_data *nsd;
+ struct gsm_nm_state *new_state;
+
+ switch (event) {
+ case NM_EV_STATE_CHG_REP:
+ nsd = (struct nm_statechg_signal_data *)data;
+ new_state = nsd->new_state;
+ if (new_state->operational == NM_OPSTATE_ENABLED) {
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_ENABLED);
+ return;
+ }
+ switch (new_state->availability) { /* operational = DISABLED */
+ case NM_AVSTATE_NOT_INSTALLED:
+ case NM_AVSTATE_POWER_OFF:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED);
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_OFFLINE);
+ return;
+ default:
+ return;
+ }
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+static void st_op_disabled_offline_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ struct gsm_bts_sm *site_mgr = (struct gsm_bts_sm *)fi->priv;
+ struct gsm_bts *bts = gsm_bts_sm_get_bts(site_mgr);
+ if (!site_mgr->mo.opstart_sent) {
+ site_mgr->mo.opstart_sent = true;
+ abis_nm_opstart(bts, NM_OC_SITE_MANAGER, 0xff, 0xff, 0xff);
+ }
+}
+
+static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+ struct nm_statechg_signal_data *nsd;
+ struct gsm_nm_state *new_state;
+
+ switch (event) {
+ case NM_EV_STATE_CHG_REP:
+ nsd = (struct nm_statechg_signal_data *)data;
+ new_state = nsd->new_state;
+ if (new_state->operational == NM_OPSTATE_ENABLED) {
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_ENABLED);
+ return;
+ }
+ switch (new_state->availability) { /* operational = DISABLED */
+ case NM_AVSTATE_NOT_INSTALLED:
+ case NM_AVSTATE_POWER_OFF:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED);
+ return;
+ case NM_AVSTATE_DEPENDENCY:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_DEPENDENCY);
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ return;
+ default:
+ return;
+ }
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+static void st_op_enabled(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+ struct nm_statechg_signal_data *nsd;
+ struct gsm_nm_state *new_state;
+
+ switch (event) {
+ case NM_EV_STATE_CHG_REP:
+ nsd = (struct nm_statechg_signal_data *)data;
+ new_state = nsd->new_state;
+ if (new_state->operational == NM_OPSTATE_ENABLED)
+ return;
+ switch (new_state->availability) { /* operational = DISABLED */
+ case NM_AVSTATE_NOT_INSTALLED:
+ case NM_AVSTATE_POWER_OFF:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED);
+ return;
+ case NM_AVSTATE_DEPENDENCY:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_DEPENDENCY);
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_OFFLINE);
+ return;
+ default:
+ return;
+ }
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+static void st_op_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+ struct gsm_bts_sm *site_mgr = (struct gsm_bts_sm *)fi->priv;
+
+ switch (event) {
+ case NM_EV_OPSTART_ACK:
+ case NM_EV_OPSTART_NACK:
+ /* TODO: if on state OFFLINE and rx NACK, try again? */
+ site_mgr->mo.opstart_sent = false;
+ break;
+ case NM_EV_OML_DOWN:
+ nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED);
+ break;
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+static struct osmo_fsm_state nm_bts_sm_fsm_states[] = {
+ [NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED] = {
+ .in_event_mask =
+ X(NM_EV_SW_ACT_REP) |
+ X(NM_EV_STATE_CHG_REP),
+ .out_state_mask =
+ X(NM_BTS_SM_ST_OP_DISABLED_DEPENDENCY) |
+ X(NM_BTS_SM_ST_OP_DISABLED_OFFLINE) |
+ X(NM_BTS_SM_ST_OP_ENABLED),
+ .name = "DISABLED_NOTINSTALLED",
+ .onenter = st_op_disabled_notinstalled_on_enter,
+ .action = st_op_disabled_notinstalled,
+ },
+ [NM_BTS_SM_ST_OP_DISABLED_DEPENDENCY] = {
+ .in_event_mask =
+ X(NM_EV_STATE_CHG_REP),
+ .out_state_mask =
+ X(NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED) |
+ X(NM_BTS_SM_ST_OP_DISABLED_OFFLINE) |
+ X(NM_BTS_SM_ST_OP_ENABLED),
+ .name = "DISABLED_DEPENDENCY",
+ .action = st_op_disabled_dependency,
+ },
+ [NM_BTS_SM_ST_OP_DISABLED_OFFLINE] = {
+ .in_event_mask =
+ X(NM_EV_STATE_CHG_REP),
+ .out_state_mask =
+ X(NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED) |
+ X(NM_BTS_SM_ST_OP_DISABLED_DEPENDENCY) |
+ X(NM_BTS_SM_ST_OP_ENABLED),
+ .name = "DISABLED_OFFLINE",
+ .onenter = st_op_disabled_offline_on_enter,
+ .action = st_op_disabled_offline,
+ },
+ [NM_BTS_SM_ST_OP_ENABLED] = {
+ .in_event_mask =
+ X(NM_EV_STATE_CHG_REP),
+ .out_state_mask =
+ X(NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED) |
+ X(NM_BTS_SM_ST_OP_DISABLED_DEPENDENCY) |
+ X(NM_BTS_SM_ST_OP_DISABLED_OFFLINE),
+ .name = "ENABLED",
+ .action = st_op_enabled,
+ },
+};
+
+struct osmo_fsm nm_bts_sm_fsm = {
+ .name = "NM_BTS_SM_OP",
+ .states = nm_bts_sm_fsm_states,
+ .num_states = ARRAY_SIZE(nm_bts_sm_fsm_states),
+ .allstate_event_mask =
+ X(NM_EV_OPSTART_ACK) |
+ X(NM_EV_OPSTART_NACK) |
+ X(NM_EV_OML_DOWN),
+ .allstate_action = st_op_allstate,
+ .event_names = nm_fsm_event_names,
+ .log_subsys = DNM,
+};
+
+static __attribute__((constructor)) void nm_bts_sm_fsm_init(void)
+{
+ OSMO_ASSERT(osmo_fsm_register(&nm_bts_sm_fsm) == 0);
+}
diff --git a/src/osmo-bsc/nm_common_fsm.c b/src/osmo-bsc/nm_common_fsm.c
new file mode 100644
index 000000000..9851f5d95
--- /dev/null
+++ b/src/osmo-bsc/nm_common_fsm.c
@@ -0,0 +1,32 @@
+/* NM FSM, common bits */
+
+/* (C) 2020 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>
+ * Author: Pau Espin Pedrol <pespin@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/bsc/nm_common_fsm.h>
+
+const struct value_string nm_fsm_event_names[] = {
+ { NM_EV_SW_ACT_REP, "SW_ACT_REP" },
+ { NM_EV_STATE_CHG_REP, "STATE_CHG_REP" },
+ { NM_EV_OPSTART_ACK, "OPSTART_ACK" },
+ { NM_EV_OPSTART_NACK, "OPSTART_NACK" },
+ { NM_EV_OML_DOWN, "OML_DOWN" },
+ { 0, NULL }
+};
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
index fd03cb384..30de5b4e6 100644
--- a/src/utils/Makefile.am
+++ b/src/utils/Makefile.am
@@ -55,6 +55,8 @@ bs11_config_LDADD = \
$(top_builddir)/src/osmo-bsc/e1_config.o \
$(top_builddir)/src/osmo-bsc/gsm_data.o \
$(top_builddir)/src/osmo-bsc/net_init.o \
+ $(top_builddir)/src/osmo-bsc/nm_common_fsm.o \
+ $(top_builddir)/src/osmo-bsc/nm_bts_sm_fsm.o \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOABIS_LIBS) \
@@ -125,6 +127,8 @@ meas_json_LDADD = \
$(top_builddir)/src/osmo-bsc/bts.o \
$(top_builddir)/src/osmo-bsc/bts_trx.o \
$(top_builddir)/src/osmo-bsc/gsm_data.o \
+ $(top_builddir)/src/osmo-bsc/nm_common_fsm.o \
+ $(top_builddir)/src/osmo-bsc/nm_bts_sm_fsm.o \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOABIS_LIBS) \