nm_*_fsm: Move to state Disabled NotInstalled Locked when shtudown proc ends

Change-Id: I5c070adbba6b4abb19467a02d6449a443657ae2b
This commit is contained in:
Pau Espin 2021-09-16 18:07:55 +02:00
parent c56d120b29
commit 92186c672d
8 changed files with 85 additions and 20 deletions

View File

@ -32,6 +32,7 @@ enum nm_fsm_events {
NM_EV_OPSTART_ACK,
NM_EV_OPSTART_NACK,
NM_EV_SHUTDOWN_START,
NM_EV_SHUTDOWN_FINISH,
NM_EV_RSL_UP, /* RadioCarrier and BaseBand Transceiver only */
NM_EV_RSL_DOWN, /* RadioCarrier and BaseBand Transceiver only */
NM_EV_PHYLINK_UP, /* RadioCarrier and BaseBand Transceiver only */

View File

@ -152,6 +152,10 @@ static void st_wait_trx_closed(struct osmo_fsm_inst *fi, uint32_t event, void *d
static void st_exit_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct gsm_bts *bts = (struct gsm_bts *)fi->priv;
osmo_fsm_inst_dispatch(bts->site_mgr.mo.fi, NM_EV_SHUTDOWN_FINISH, NULL);
LOGPFSML(fi, LOGL_NOTICE, "Shutdown process completed successfuly, exiting process\n");
exit(0);
}

View File

@ -41,6 +41,17 @@
#define nm_bb_transc_fsm_state_chg(fi, NEXT_STATE) \
osmo_fsm_inst_state_chg(fi, NEXT_STATE, 0, 0)
static void ev_dispatch_children(struct gsm_bts_bb_trx *bb_transc, uint32_t event)
{
struct gsm_bts_trx *trx = gsm_bts_bb_trx_get_trx(bb_transc);
uint8_t tn;
for (tn = 0; tn < TRX_NR_TS; tn++) {
struct gsm_bts_trx_ts *ts = &trx->ts[tn];
osmo_fsm_inst_dispatch(ts->mo.fi, event, NULL);
}
}
//////////////////////////
// FSM STATE ACTIONS
//////////////////////////
@ -184,8 +195,6 @@ static void st_op_enabled(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void nm_bb_transc_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct gsm_bts_bb_trx *bb_transc = (struct gsm_bts_bb_trx *)fi->priv;
struct gsm_bts_trx *trx = gsm_bts_bb_trx_get_trx(bb_transc);
uint8_t tn;
switch (event) {
case NM_EV_SHUTDOWN_START:
@ -193,10 +202,12 @@ static void nm_bb_transc_allstate(struct osmo_fsm_inst *fi, uint32_t event, void
oml_mo_state_chg(&bb_transc->mo, -1, -1, NM_STATE_SHUTDOWN);
/* Propagate event to children: */
for (tn = 0; tn < TRX_NR_TS; tn++) {
struct gsm_bts_trx_ts *ts = &trx->ts[tn];
osmo_fsm_inst_dispatch(ts->mo.fi, NM_EV_SHUTDOWN_START, NULL);
}
ev_dispatch_children(bb_transc, event);
break;
case NM_EV_SHUTDOWN_FINISH:
/* Propagate event to children: */
ev_dispatch_children(bb_transc, event);
nm_bb_transc_fsm_state_chg(fi, NM_BBTRANSC_ST_OP_DISABLED_NOTINSTALLED);
break;
default:
OSMO_ASSERT(false);
@ -213,6 +224,7 @@ static struct osmo_fsm_state nm_bb_transc_fsm_states[] = {
X(NM_EV_PHYLINK_DOWN) |
X(NM_EV_DISABLE),
.out_state_mask =
X(NM_BBTRANSC_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_BBTRANSC_ST_OP_DISABLED_OFFLINE),
.name = "DISABLED_NOTINSTALLED",
.onenter = st_op_disabled_notinstalled_on_enter,
@ -228,6 +240,7 @@ static struct osmo_fsm_state nm_bb_transc_fsm_states[] = {
X(NM_EV_PHYLINK_DOWN) |
X(NM_EV_DISABLE),
.out_state_mask =
X(NM_BBTRANSC_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_BBTRANSC_ST_OP_ENABLED),
.name = "DISABLED_OFFLINE",
.onenter = st_op_disabled_offline_on_enter,
@ -239,6 +252,7 @@ static struct osmo_fsm_state nm_bb_transc_fsm_states[] = {
X(NM_EV_PHYLINK_DOWN) |
X(NM_EV_DISABLE),
.out_state_mask =
X(NM_BBTRANSC_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_BBTRANSC_ST_OP_DISABLED_OFFLINE),
.name = "ENABLED",
.onenter = st_op_enabled_on_enter,
@ -252,7 +266,8 @@ struct osmo_fsm nm_bb_transc_fsm = {
.num_states = ARRAY_SIZE(nm_bb_transc_fsm_states),
.event_names = nm_fsm_event_names,
.allstate_action = nm_bb_transc_allstate,
.allstate_event_mask = X(NM_EV_SHUTDOWN_START),
.allstate_event_mask = X(NM_EV_SHUTDOWN_START) |
X(NM_EV_SHUTDOWN_FINISH),
.log_subsys = DOML,
};

View File

@ -41,6 +41,15 @@
#define nm_bts_fsm_state_chg(fi, NEXT_STATE) \
osmo_fsm_inst_state_chg(fi, NEXT_STATE, 0, 0)
static void ev_dispatch_children(struct gsm_bts *bts, uint32_t event)
{
struct gsm_bts_trx *trx;
llist_for_each_entry(trx, &bts->trx_list, list) {
osmo_fsm_inst_dispatch(trx->mo.fi, event, NULL);
osmo_fsm_inst_dispatch(trx->bb_transc.mo.fi, event, NULL);
}
}
//////////////////////////
// FSM STATE ACTIONS
//////////////////////////
@ -105,7 +114,6 @@ static void st_op_enabled(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void nm_bts_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct gsm_bts *bts = (struct gsm_bts *)fi->priv;
struct gsm_bts_trx *trx;
switch (event) {
case NM_EV_SHUTDOWN_START:
@ -113,10 +121,12 @@ static void nm_bts_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *data
oml_mo_state_chg(&bts->mo, -1, -1, NM_STATE_SHUTDOWN);
/* Propagate event to children: */
llist_for_each_entry(trx, &bts->trx_list, list) {
osmo_fsm_inst_dispatch(trx->mo.fi, NM_EV_SHUTDOWN_START, NULL);
osmo_fsm_inst_dispatch(trx->bb_transc.mo.fi, NM_EV_SHUTDOWN_START, NULL);
}
ev_dispatch_children(bts, event);
break;
case NM_EV_SHUTDOWN_FINISH:
/* Propagate event to children: */
ev_dispatch_children(bts, event);
nm_bts_fsm_state_chg(fi, NM_BTS_ST_OP_DISABLED_NOTINSTALLED);
break;
default:
OSMO_ASSERT(false);
@ -128,6 +138,7 @@ static struct osmo_fsm_state nm_bts_fsm_states[] = {
.in_event_mask =
X(NM_EV_SW_ACT),
.out_state_mask =
X(NM_BTS_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_BTS_ST_OP_DISABLED_OFFLINE),
.name = "DISABLED_NOTINSTALLED",
.onenter = st_op_disabled_notinstalled_on_enter,
@ -138,6 +149,7 @@ static struct osmo_fsm_state nm_bts_fsm_states[] = {
X(NM_EV_OPSTART_ACK) |
X(NM_EV_OPSTART_NACK),
.out_state_mask =
X(NM_BTS_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_BTS_ST_OP_ENABLED),
.name = "DISABLED_OFFLINE",
.onenter = st_op_disabled_offline_on_enter,
@ -145,7 +157,8 @@ static struct osmo_fsm_state nm_bts_fsm_states[] = {
},
[NM_BTS_ST_OP_ENABLED] = {
.in_event_mask = 0,
.out_state_mask = 0,
.out_state_mask =
X(NM_BTS_ST_OP_DISABLED_NOTINSTALLED),
.name = "ENABLED",
.onenter = st_op_enabled_on_enter,
.action = st_op_enabled,
@ -158,7 +171,8 @@ struct osmo_fsm nm_bts_fsm = {
.num_states = ARRAY_SIZE(nm_bts_fsm_states),
.event_names = nm_fsm_event_names,
.allstate_action = nm_bts_allstate,
.allstate_event_mask = X(NM_EV_SHUTDOWN_START),
.allstate_event_mask = X(NM_EV_SHUTDOWN_START) |
X(NM_EV_SHUTDOWN_FINISH),
.log_subsys = DOML,
};

View File

@ -41,6 +41,13 @@
#define nm_bts_sm_fsm_state_chg(fi, NEXT_STATE) \
osmo_fsm_inst_state_chg(fi, NEXT_STATE, 0, 0)
static void ev_dispatch_children(struct gsm_bts_sm *site_mgr, uint32_t event)
{
struct gsm_bts *bts = gsm_bts_sm_get_bts(site_mgr);
osmo_fsm_inst_dispatch(bts->mo.fi, event, NULL);
}
//////////////////////////
// FSM STATE ACTIONS
//////////////////////////
@ -105,7 +112,6 @@ static void st_op_enabled(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void nm_bts_sm_allstate(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);
switch (event) {
case NM_EV_SHUTDOWN_START:
@ -113,7 +119,12 @@ static void nm_bts_sm_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *d
oml_mo_state_chg(&site_mgr->mo, -1, -1, NM_STATE_SHUTDOWN);
/* Propagate event to children: */
osmo_fsm_inst_dispatch(bts->mo.fi, NM_EV_SHUTDOWN_START, NULL);
ev_dispatch_children(site_mgr, event);
break;
case NM_EV_SHUTDOWN_FINISH:
/* Propagate event to children: */
ev_dispatch_children(site_mgr, event);
nm_bts_sm_fsm_state_chg(fi, NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED);
break;
default:
OSMO_ASSERT(false);
@ -125,6 +136,7 @@ static struct osmo_fsm_state nm_bts_sm_fsm_states[] = {
.in_event_mask =
X(NM_EV_SW_ACT),
.out_state_mask =
X(NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_BTS_SM_ST_OP_DISABLED_OFFLINE),
.name = "DISABLED_NOTINSTALLED",
.onenter = st_op_disabled_notinstalled_on_enter,
@ -135,6 +147,7 @@ static struct osmo_fsm_state nm_bts_sm_fsm_states[] = {
X(NM_EV_OPSTART_ACK) |
X(NM_EV_OPSTART_NACK),
.out_state_mask =
X(NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_BTS_SM_ST_OP_ENABLED),
.name = "DISABLED_OFFLINE",
.onenter = st_op_disabled_offline_on_enter,
@ -142,7 +155,8 @@ static struct osmo_fsm_state nm_bts_sm_fsm_states[] = {
},
[NM_BTS_SM_ST_OP_ENABLED] = {
.in_event_mask = 0,
.out_state_mask = 0,
.out_state_mask =
X(NM_BTS_SM_ST_OP_DISABLED_NOTINSTALLED),
.name = "ENABLED",
.onenter = st_op_enabled_on_enter,
.action = st_op_enabled,
@ -155,7 +169,8 @@ struct osmo_fsm nm_bts_sm_fsm = {
.num_states = ARRAY_SIZE(nm_bts_sm_fsm_states),
.event_names = nm_fsm_event_names,
.allstate_action = nm_bts_sm_allstate,
.allstate_event_mask = X(NM_EV_SHUTDOWN_START),
.allstate_event_mask = X(NM_EV_SHUTDOWN_START) |
X(NM_EV_SHUTDOWN_FINISH),
.log_subsys = DOML,
};

View File

@ -177,6 +177,9 @@ static void nm_chan_allstate(struct osmo_fsm_inst *fi, uint32_t event, void *dat
/* Announce we start shutting down */
oml_mo_state_chg(&ts->mo, -1, -1, NM_STATE_SHUTDOWN);
break;
case NM_EV_SHUTDOWN_FINISH:
nm_chan_fsm_state_chg(fi, NM_CHAN_ST_OP_DISABLED_NOTINSTALLED);
break;
default:
OSMO_ASSERT(false);
}
@ -187,6 +190,7 @@ static struct osmo_fsm_state nm_chan_fsm_states[] = {
.in_event_mask =
X(NM_EV_BBTRANSC_INSTALLED),
.out_state_mask =
X(NM_CHAN_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_CHAN_ST_OP_DISABLED_OFFLINE) |
X(NM_CHAN_ST_OP_DISABLED_DEPENDENCY),
.name = "DISABLED_NOTINSTALLED",
@ -202,6 +206,7 @@ static struct osmo_fsm_state nm_chan_fsm_states[] = {
X(NM_EV_BBTRANSC_DISABLED) |
X(NM_EV_RCARRIER_DISABLED),
.out_state_mask =
X(NM_CHAN_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_CHAN_ST_OP_DISABLED_OFFLINE) |
X(NM_CHAN_ST_OP_ENABLED), /* backward compatibility, buggy BSC */
.name = "DISABLED_DEPENDENCY",
@ -215,6 +220,7 @@ static struct osmo_fsm_state nm_chan_fsm_states[] = {
X(NM_EV_BBTRANSC_DISABLED) |
X(NM_EV_RCARRIER_DISABLED),
.out_state_mask =
X(NM_CHAN_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_CHAN_ST_OP_ENABLED) |
X(NM_CHAN_ST_OP_DISABLED_DEPENDENCY),
.name = "DISABLED_OFFLINE",
@ -227,6 +233,7 @@ static struct osmo_fsm_state nm_chan_fsm_states[] = {
X(NM_EV_RCARRIER_DISABLED) |
X(NM_EV_DISABLE),
.out_state_mask =
X(NM_CHAN_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_CHAN_ST_OP_DISABLED_OFFLINE) |
X(NM_CHAN_ST_OP_DISABLED_DEPENDENCY),
.name = "ENABLED",
@ -241,7 +248,8 @@ struct osmo_fsm nm_chan_fsm = {
.num_states = ARRAY_SIZE(nm_chan_fsm_states),
.event_names = nm_fsm_event_names,
.allstate_action = nm_chan_allstate,
.allstate_event_mask = X(NM_EV_SHUTDOWN_START),
.allstate_event_mask = X(NM_EV_SHUTDOWN_START) |
X(NM_EV_SHUTDOWN_FINISH),
.log_subsys = DOML,
};

View File

@ -28,6 +28,7 @@ const struct value_string nm_fsm_event_names[] = {
{ NM_EV_OPSTART_ACK, "OPSTART_ACK" },
{ NM_EV_OPSTART_NACK, "OPSTART_NACK" },
{ NM_EV_SHUTDOWN_START, "SHUTDOWN_START" },
{ NM_EV_SHUTDOWN_FINISH, "SHUTDOWN_FINISH" },
{ NM_EV_RSL_UP, "RSL_UP" },
{ NM_EV_RSL_DOWN, "RSL_DOWN" },
{ NM_EV_PHYLINK_UP, "PHYLINK_UP" },

View File

@ -180,6 +180,9 @@ static void nm_rcarrier_allstate(struct osmo_fsm_inst *fi, uint32_t event, void
/* Announce we start shutting down */
oml_mo_state_chg(&trx->mo, -1, -1, NM_STATE_SHUTDOWN);
break;
case NM_EV_SHUTDOWN_FINISH:
nm_rcarrier_fsm_state_chg(fi, NM_RCARRIER_ST_OP_DISABLED_NOTINSTALLED);
break;
default:
OSMO_ASSERT(false);
}
@ -195,6 +198,7 @@ static struct osmo_fsm_state nm_rcarrier_fsm_states[] = {
X(NM_EV_PHYLINK_DOWN) |
X(NM_EV_DISABLE),
.out_state_mask =
X(NM_RCARRIER_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_RCARRIER_ST_OP_DISABLED_OFFLINE),
.name = "DISABLED_NOTINSTALLED",
.onenter = st_op_disabled_notinstalled_on_enter,
@ -210,6 +214,7 @@ static struct osmo_fsm_state nm_rcarrier_fsm_states[] = {
X(NM_EV_PHYLINK_DOWN) |
X(NM_EV_DISABLE),
.out_state_mask =
X(NM_RCARRIER_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_RCARRIER_ST_OP_ENABLED),
.name = "DISABLED_OFFLINE",
.onenter = st_op_disabled_offline_on_enter,
@ -221,6 +226,7 @@ static struct osmo_fsm_state nm_rcarrier_fsm_states[] = {
X(NM_EV_PHYLINK_DOWN) |
X(NM_EV_DISABLE),
.out_state_mask =
X(NM_RCARRIER_ST_OP_DISABLED_NOTINSTALLED) |
X(NM_RCARRIER_ST_OP_DISABLED_OFFLINE),
.name = "ENABLED",
.onenter = st_op_enabled_on_enter,
@ -234,7 +240,8 @@ struct osmo_fsm nm_rcarrier_fsm = {
.num_states = ARRAY_SIZE(nm_rcarrier_fsm_states),
.event_names = nm_fsm_event_names,
.allstate_action = nm_rcarrier_allstate,
.allstate_event_mask = X(NM_EV_SHUTDOWN_START),
.allstate_event_mask = X(NM_EV_SHUTDOWN_START) |
X(NM_EV_SHUTDOWN_FINISH),
.log_subsys = DOML,
};