aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bsc
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-09-30 16:36:30 +0200
committerlaforge <laforge@osmocom.org>2020-10-15 05:55:36 +0000
commit09544ab43657d16f0ff58f7aa1ee113c9cb4bb05 (patch)
treeabac5aaf37bce7c265502720538c01e6eb4a2a93 /src/osmo-bsc
parentd9d105c1f73713b1363849554d5d87d36d4ae7b6 (diff)
Introduce Radio Channel FSM
Diffstat (limited to 'src/osmo-bsc')
-rw-r--r--src/osmo-bsc/Makefile.am1
-rw-r--r--src/osmo-bsc/abis_nm.c10
-rw-r--r--src/osmo-bsc/bts_ipaccess_nanobts.c51
-rw-r--r--src/osmo-bsc/bts_trx.c13
-rw-r--r--src/osmo-bsc/nm_channel_fsm.c362
5 files changed, 421 insertions, 16 deletions
diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am
index af9c53e4a..573988549 100644
--- a/src/osmo-bsc/Makefile.am
+++ b/src/osmo-bsc/Makefile.am
@@ -80,6 +80,7 @@ osmo_bsc_SOURCES = \
nm_bb_transc_fsm.c \
nm_bts_sm_fsm.c \
nm_bts_fsm.c \
+ nm_channel_fsm.c \
nm_rcarrier_fsm.c \
gsm_08_08.c \
osmo_bsc_bssap.c \
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index 54dfccbbf..6e31a8523 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -842,6 +842,14 @@ static int abis_nm_rx_set_radio_attr_ack(struct msgb *mb)
return 0;
}
+static int abis_nm_rx_set_channel_attr_ack(struct msgb *mb)
+{
+ struct abis_om_fom_hdr *foh = msgb_l3(mb);
+ DEBUGPFOH(DNM, foh, "Set Channel Attributes ACK\n");
+ osmo_signal_dispatch(SS_NM, S_NM_SET_CHAN_ATTR_ACK, mb);
+ return 0;
+}
+
static int abis_nm_rx_set_bts_attr_ack(struct msgb *mb)
{
struct abis_om_fom_hdr *foh = msgb_l3(mb);
@@ -969,7 +977,7 @@ static int abis_nm_rcvmsg_fom(struct msgb *mb)
ret = abis_nm_rx_opstart_nack(mb);
break;
case NM_MT_SET_CHAN_ATTR_ACK:
- DEBUGPFOH(DNM, foh, "Set Channel Attributes ACK\n");
+ abis_nm_rx_set_channel_attr_ack(mb);
break;
case NM_MT_SET_RADIO_ATTR_ACK:
abis_nm_rx_set_radio_attr_ack(mb);
diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c b/src/osmo-bsc/bts_ipaccess_nanobts.c
index 850e4772e..134d50a79 100644
--- a/src/osmo-bsc/bts_ipaccess_nanobts.c
+++ b/src/osmo-bsc/bts_ipaccess_nanobts.c
@@ -147,6 +147,7 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd)
if (obj_class != NM_OC_BTS &&
obj_class != NM_OC_BASEB_TRANSC &&
obj_class != NM_OC_RADIO_CARRIER &&
+ obj_class != NM_OC_CHANNEL &&
evt != S_NM_STATECHG_OPER)
return 0;
@@ -166,20 +167,7 @@ static int nm_statechg_event(int evt, struct nm_statechg_signal_data *nsd)
case NM_OC_CHANNEL:
ts = obj;
trx = ts->trx;
- if (new_state->operational == NM_OPSTATE_DISABLED &&
- new_state->availability == NM_AVSTATE_DEPENDENCY) {
- enum abis_nm_chan_comb ccomb =
- abis_nm_chcomb4pchan(ts->pchan_from_config);
- if (abis_nm_set_channel_attr(ts, ccomb) == -EINVAL) {
- ipaccess_drop_oml_deferred(trx->bts);
- return -1;
- }
- abis_nm_chg_adm_state(trx->bts, obj_class,
- trx->bts->bts_nr, trx->nr, ts->nr,
- NM_STATE_UNLOCKED);
- abis_nm_opstart(trx->bts, obj_class,
- trx->bts->bts_nr, trx->nr, ts->nr);
- }
+ osmo_fsm_inst_dispatch(ts->mo.fi, NM_EV_STATE_CHG_REP, nsd);
break;
case NM_OC_RADIO_CARRIER:
trx = obj;
@@ -257,6 +245,7 @@ static int sw_activ_rep(struct msgb *mb)
struct e1inp_sign_link *sign_link = mb->dst;
struct gsm_bts *bts = sign_link->trx->bts;
struct gsm_bts_trx *trx;
+ struct gsm_bts_trx_ts *ts;
if (!is_ipaccess_bts(bts))
return 0;
@@ -278,6 +267,11 @@ static int sw_activ_rep(struct msgb *mb)
return -EINVAL;
osmo_fsm_inst_dispatch(trx->mo.fi, NM_EV_SW_ACT_REP, NULL);
break;
+ case NM_OC_CHANNEL:
+ if (!(ts = abis_nm_get_ts(mb)))
+ return -EINVAL;
+ osmo_fsm_inst_dispatch(ts->mo.fi, NM_EV_SW_ACT_REP, NULL);
+ break;
}
return 0;
}
@@ -293,7 +287,7 @@ static void nm_rx_opstart_ack_chan(struct msgb *oml_msg)
LOG_TS(ts, LOGL_ERROR, "Channel OPSTART ACK for uninitialized TS\n");
return;
}
-
+ osmo_fsm_inst_dispatch(ts->mo.fi, NM_EV_OPSTART_ACK, NULL);
osmo_fsm_inst_dispatch(ts->fi, TS_EV_OML_READY, NULL);
}
@@ -335,6 +329,7 @@ static void nm_rx_opstart_nack(struct msgb *oml_msg)
struct e1inp_sign_link *sign_link = oml_msg->dst;
struct gsm_bts *bts = sign_link->trx->bts;
struct gsm_bts_trx *trx;
+ struct gsm_bts_trx_ts *ts;
switch (foh->obj_class) {
case NM_OC_SITE_MANAGER:
@@ -353,6 +348,11 @@ static void nm_rx_opstart_nack(struct msgb *oml_msg)
return;
osmo_fsm_inst_dispatch(trx->bb_transc.mo.fi, NM_EV_OPSTART_NACK, NULL);
break;
+ case NM_OC_CHANNEL:
+ if (!(ts = abis_nm_get_ts(oml_msg)))
+ return;
+ osmo_fsm_inst_dispatch(ts->mo.fi, NM_EV_OPSTART_NACK, NULL);
+ break;
default:
break;
}
@@ -386,6 +386,18 @@ static void nm_rx_set_radio_attr_ack(struct msgb *oml_msg)
osmo_fsm_inst_dispatch(trx->mo.fi, NM_EV_SET_ATTR_ACK, NULL);
}
+static void nm_rx_set_chan_attr_ack(struct msgb *oml_msg)
+{
+ struct abis_om_fom_hdr *foh = msgb_l3(oml_msg);
+ struct gsm_bts_trx_ts *ts = abis_nm_get_ts(oml_msg);
+
+ if (!ts || foh->obj_class != NM_OC_CHANNEL) {
+ LOG_TS(ts, LOGL_ERROR, "Set Channel Attr Ack received on non Radio Channel object!\n");
+ return;
+ }
+ osmo_fsm_inst_dispatch(ts->mo.fi, NM_EV_SET_ATTR_ACK, NULL);
+}
+
/* Callback function to be called every time we receive a signal from NM */
static int bts_ipa_nm_sig_cb(unsigned int subsys, unsigned int signal,
void *handler_data, void *signal_data)
@@ -411,6 +423,9 @@ static int bts_ipa_nm_sig_cb(unsigned int subsys, unsigned int signal,
case S_NM_SET_RADIO_ATTR_ACK:
nm_rx_set_radio_attr_ack(signal_data);
return 0;
+ case S_NM_SET_CHAN_ATTR_ACK:
+ nm_rx_set_chan_attr_ack(signal_data);
+ return 0;
default:
break;
}
@@ -475,6 +490,8 @@ void ipaccess_drop_oml(struct gsm_bts *bts, const char *reason)
{
struct gsm_bts *rdep_bts;
struct gsm_bts_trx *trx;
+ struct gsm_bts_trx_ts *ts ;
+ uint8_t tn;
/* First of all, remove deferred drop if enabled */
osmo_timer_del(&bts->oml_drop_link_timer);
@@ -493,6 +510,10 @@ void ipaccess_drop_oml(struct gsm_bts *bts, const char *reason)
ipaccess_drop_rsl(trx, "OML link drop");
osmo_fsm_inst_dispatch(trx->bb_transc.mo.fi, NM_EV_OML_DOWN, NULL);
osmo_fsm_inst_dispatch(trx->mo.fi, NM_EV_OML_DOWN, NULL);
+ for (tn = 0; tn < TRX_NR_TS; tn++) {
+ ts = &trx->ts[tn];
+ osmo_fsm_inst_dispatch(ts->mo.fi, NM_EV_OML_DOWN, NULL);
+ }
}
osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_OML_DOWN, NULL);
diff --git a/src/osmo-bsc/bts_trx.c b/src/osmo-bsc/bts_trx.c
index 5f21b497c..0e5223874 100644
--- a/src/osmo-bsc/bts_trx.c
+++ b/src/osmo-bsc/bts_trx.c
@@ -34,6 +34,8 @@
static int gsm_bts_trx_talloc_destructor(struct gsm_bts_trx *trx)
{
+ unsigned int i;
+
if (trx->bb_transc.mo.fi) {
osmo_fsm_inst_free(trx->bb_transc.mo.fi);
trx->bb_transc.mo.fi = NULL;
@@ -42,6 +44,13 @@ static int gsm_bts_trx_talloc_destructor(struct gsm_bts_trx *trx)
osmo_fsm_inst_free(trx->mo.fi);
trx->mo.fi = NULL;
}
+ for (i = 0; i < TRX_NR_TS; i++) {
+ struct gsm_bts_trx_ts *ts = &trx->ts[i];
+ if (ts->mo.fi) {
+ osmo_fsm_inst_free(ts->mo.fi);
+ ts->mo.fi = NULL;
+ }
+ }
return 0;
}
@@ -82,6 +91,10 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
ts_fsm_alloc(ts);
+ ts->mo.fi = osmo_fsm_inst_alloc(&nm_chan_fsm, trx, ts,
+ LOGL_INFO, NULL);
+ osmo_fsm_inst_update_id_f(ts->mo.fi, "bts%d-trx%d-ts%d",
+ bts->nr, trx->nr, ts->nr);
gsm_mo_init(&ts->mo, bts, NM_OC_CHANNEL,
bts->nr, trx->nr, ts->nr);
diff --git a/src/osmo-bsc/nm_channel_fsm.c b/src/osmo-bsc/nm_channel_fsm.c
new file mode 100644
index 000000000..aeaf1fe50
--- /dev/null
+++ b/src/osmo-bsc/nm_channel_fsm.c
@@ -0,0 +1,362 @@
+/* NM Radio Channel 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/bts_ipaccess_nanobts_omlattr.h>
+#include <osmocom/bsc/ipaccess.h>
+#include <osmocom/bsc/nm_common_fsm.h>
+#include <osmocom/bsc/debug.h>
+
+#define X(s) (1 << (s))
+
+#define nm_chan_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_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+
+ ts->mo.set_attr_sent = false;
+ ts->mo.set_attr_ack_received = false;
+ ts->mo.adm_unlock_sent = false;
+ ts->mo.opstart_sent = false;
+}
+
+static void st_op_disabled_notinstalled(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_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) {
+ /*should not happen... */
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_ENABLED);
+ return;
+ }
+ switch (new_state->availability) { /* operational = DISABLED */
+ case NM_AVSTATE_DEPENDENCY:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_DEPENDENCY);
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_OFFLINE);
+ return;
+ default:
+ return;
+ }
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+static void configure_loop(struct gsm_bts_trx_ts *ts, struct gsm_nm_state *state, bool allow_opstart)
+{
+ enum abis_nm_chan_comb ccomb;
+ struct gsm_bts_trx *trx = ts->trx;
+
+ if (!ts->mo.set_attr_sent && !ts->mo.set_attr_ack_received) {
+ ts->mo.set_attr_sent = true;
+ ccomb = abis_nm_chcomb4pchan(ts->pchan_from_config);
+ if (abis_nm_set_channel_attr(ts, ccomb) == -EINVAL) {
+ /* FIXME: using this here makes crazy lots of .o
+ dependencies be fulled in, ending up in
+ osmo_bsc_main.o which conficts due to containing its
+ own main() */
+ LOGPFSML(ts->mo.fi, LOGL_ERROR,
+ "FIXME: Here OML link should br dropped, "
+ "something is wrong in your setup!\n");
+ //ipaccess_drop_oml_deferred(trx->bts);
+ }
+ }
+
+ if (state->administrative != NM_STATE_UNLOCKED && !ts->mo.adm_unlock_sent) {
+ ts->mo.adm_unlock_sent = true;
+ abis_nm_chg_adm_state(trx->bts, NM_OC_CHANNEL,
+ trx->bts->bts_nr, trx->nr, ts->nr,
+ NM_STATE_UNLOCKED);
+ }
+
+ if (allow_opstart && state->administrative == NM_STATE_UNLOCKED &&
+ ts->mo.set_attr_ack_received && !ts->mo.opstart_sent) {
+ ts->mo.opstart_sent = true;
+ abis_nm_opstart(trx->bts, NM_OC_CHANNEL, trx->bts->bts_nr, trx->nr, ts->nr);
+ }
+}
+
+static void st_op_disabled_dependency_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+
+ /* nanoBTS is broken, doesn't follow TS 12.21. Opstart MUST be sent
+ during Dependency, so we simply move to OFFLINE state here to avoid
+ duplicating code */
+ if (ts->trx->bts->type == GSM_BTS_TYPE_NANOBTS) {
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_OFFLINE);
+ return;
+ }
+ configure_loop(ts, &ts->mo.nm_state, false);
+}
+
+static void st_op_disabled_dependency(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+ struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+ struct nm_statechg_signal_data *nsd;
+ struct gsm_nm_state *new_state;
+
+ switch (event) {
+ case NM_EV_SET_ATTR_ACK:
+ ts->mo.set_attr_ack_received = true;
+ ts->mo.set_attr_sent = false;
+ configure_loop(ts, &ts->mo.nm_state, false);
+ return;
+ 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) {
+ /* should not happen... */
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_ENABLED);
+ return;
+ }
+ switch (new_state->availability) { /* operational = DISABLED */
+ case NM_AVSTATE_NOT_INSTALLED:
+ case NM_AVSTATE_POWER_OFF:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_NOTINSTALLED);
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_OFFLINE);
+ return;
+ case NM_AVSTATE_DEPENDENCY:
+ configure_loop(ts, new_state, false);
+ 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_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+
+ /* Warning: In here we may be acessing an state older than new_state
+ from prev (syncrhonous) FSM state */
+ configure_loop(ts, &ts->mo.nm_state, true);
+}
+
+static void st_op_disabled_offline(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+ struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+ struct nm_statechg_signal_data *nsd;
+ struct gsm_nm_state *new_state;
+
+ switch (event) {
+ case NM_EV_SET_ATTR_ACK:
+ ts->mo.set_attr_ack_received = true;
+ ts->mo.set_attr_sent = false;
+ configure_loop(ts, &ts->mo.nm_state, true);
+ return;
+ 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_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_ENABLED);
+ return;
+ }
+ switch (new_state->availability) { /* operational = DISABLED */
+ case NM_AVSTATE_NOT_INSTALLED:
+ case NM_AVSTATE_POWER_OFF:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_NOTINSTALLED);
+ return;
+ case NM_AVSTATE_DEPENDENCY:
+ /* There's no point in moving back to Dependency in nanoBTS, since it's broken
+ and it acts actually as if it was in Offline state */
+ if (ts->trx->bts->type != GSM_BTS_TYPE_NANOBTS) {
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_DEPENDENCY);
+ } else {
+ /* Moreover, in nanoBTS we need to check here for tx
+ Opstart since we may have gone Unlocked state
+ in this event, which means Opstart may be txed here. */
+ configure_loop(ts, new_state, true);
+ }
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ configure_loop(ts, new_state, true);
+ return;
+ default:
+ return;
+ }
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+static void st_op_enabled_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+ struct gsm_bts_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+
+ /* Reset state, we don't need it in this state and it will need to be
+ reused as soon as we move back to Disabled */
+ ts->mo.opstart_sent = false;
+ ts->mo.adm_unlock_sent = false;
+ ts->mo.set_attr_ack_received = false;
+ ts->mo.set_attr_sent = false;
+}
+
+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_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_NOTINSTALLED);
+ return;
+ case NM_AVSTATE_DEPENDENCY:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_DEPENDENCY);
+ return;
+ case NM_AVSTATE_OFF_LINE:
+ case NM_AVSTATE_OK:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_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_trx_ts *ts = (struct gsm_bts_trx_ts *)fi->priv;
+
+ switch (event) {
+ case NM_EV_OPSTART_ACK:
+ case NM_EV_OPSTART_NACK:
+ /* TODO: if on state OFFLINE and rx NACK, try again? */
+ ts->mo.opstart_sent = false;
+ break;
+ case NM_EV_OML_DOWN:
+ nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_NOTINSTALLED);
+ break;
+ default:
+ OSMO_ASSERT(0);
+ }
+}
+
+static struct osmo_fsm_state nm_chan_fsm_states[] = {
+ [NM_CHAN_ST_OP_DISABLED_NOTINSTALLED] = {
+ .in_event_mask =
+ X(NM_EV_SW_ACT_REP) |
+ X(NM_EV_STATE_CHG_REP),
+ .out_state_mask =
+ X(NM_CHAN_ST_OP_DISABLED_DEPENDENCY) |
+ X(NM_CHAN_ST_OP_DISABLED_OFFLINE) |
+ X(NM_CHAN_ST_OP_ENABLED),
+ .name = "DISABLED_NOTINSTALLED",
+ .onenter = st_op_disabled_notinstalled_on_enter,
+ .action = st_op_disabled_notinstalled,
+ },
+ [NM_CHAN_ST_OP_DISABLED_DEPENDENCY] = {
+ .in_event_mask =
+ X(NM_EV_STATE_CHG_REP) |
+ X(NM_EV_SET_ATTR_ACK),
+ .out_state_mask =
+ X(NM_CHAN_ST_OP_DISABLED_NOTINSTALLED) |
+ X(NM_CHAN_ST_OP_DISABLED_OFFLINE) |
+ X(NM_CHAN_ST_OP_ENABLED),
+ .name = "DISABLED_DEPENDENCY",
+ .onenter = st_op_disabled_dependency_on_enter,
+ .action = st_op_disabled_dependency,
+ },
+ [NM_CHAN_ST_OP_DISABLED_OFFLINE] = {
+ .in_event_mask =
+ X(NM_EV_STATE_CHG_REP) |
+ X(NM_EV_SET_ATTR_ACK),
+ .out_state_mask =
+ X(NM_CHAN_ST_OP_DISABLED_NOTINSTALLED) |
+ X(NM_CHAN_ST_OP_DISABLED_DEPENDENCY) |
+ X(NM_CHAN_ST_OP_ENABLED),
+ .name = "DISABLED_OFFLINE",
+ .onenter = st_op_disabled_offline_on_enter,
+ .action = st_op_disabled_offline,
+ },
+ [NM_CHAN_ST_OP_ENABLED] = {
+ .in_event_mask =
+ X(NM_EV_STATE_CHG_REP),
+ .out_state_mask =
+ X(NM_CHAN_ST_OP_DISABLED_NOTINSTALLED) |
+ X(NM_CHAN_ST_OP_DISABLED_DEPENDENCY) |
+ X(NM_CHAN_ST_OP_DISABLED_OFFLINE),
+ .name = "ENABLED",
+ .onenter = st_op_enabled_on_enter,
+ .action = st_op_enabled,
+ },
+};
+
+struct osmo_fsm nm_chan_fsm = {
+ .name = "NM_CHAN_OP",
+ .states = nm_chan_fsm_states,
+ .num_states = ARRAY_SIZE(nm_chan_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_chan_fsm_init(void)
+{
+ OSMO_ASSERT(osmo_fsm_register(&nm_chan_fsm) == 0);
+}