diff options
Diffstat (limited to 'src/osmo-bsc/a_reset.c')
-rw-r--r-- | src/osmo-bsc/a_reset.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/osmo-bsc/a_reset.c b/src/osmo-bsc/a_reset.c index 9d7be8585..63273e9f2 100644 --- a/src/osmo-bsc/a_reset.c +++ b/src/osmo-bsc/a_reset.c @@ -66,20 +66,28 @@ static const struct value_string fsm_event_names[] = { {0, NULL} }; -/* Disconnected state */ +/* Disconnected state event handler */ static void fsm_disc_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct reset_ctx *reset_ctx = (struct reset_ctx *)fi->priv; OSMO_ASSERT(reset_ctx); - struct bsc_msc_data *msc = reset_ctx->priv; - LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection succeeded.\n"); - osmo_stat_item_set(msc->network->bsc_statg->items[BSC_STAT_MSC_LINK], 1); reset_ctx->conn_loss_counter = 0; osmo_fsm_inst_state_chg(fi, ST_CONN, 0, 0); } -/* Connected state */ +/* Called when entering Disconnected state */ +static void fsm_disc_onenter_cb(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct reset_ctx *reset_ctx = (struct reset_ctx *)fi->priv; + struct bsc_msc_data *msc = reset_ctx->priv; + + LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection down, reconnecting...\n"); + if (prev_state != ST_DISC) + osmo_stat_item_dec(msc->msc_statg->items[MSC_STAT_MSC_LINKS_ACTIVE], 1); +} + +/* Connected state event handler */ static void fsm_conn_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct reset_ctx *reset_ctx = (struct reset_ctx *)fi->priv; @@ -87,12 +95,9 @@ static void fsm_conn_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data) switch (event) { case EV_N_DISCONNECT: - if (reset_ctx->conn_loss_counter >= BAD_CONNECTION_THRESOLD) { - struct bsc_msc_data *msc = reset_ctx->priv; - LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection down, reconnecting...\n"); - osmo_stat_item_set(msc->network->bsc_statg->items[BSC_STAT_MSC_LINK], 0); + if (reset_ctx->conn_loss_counter >= BAD_CONNECTION_THRESOLD) osmo_fsm_inst_state_chg(fi, ST_DISC, RESET_RESEND_INTERVAL, RESET_RESEND_TIMER_NO); - } else + else reset_ctx->conn_loss_counter++; break; case EV_N_CONNECT: @@ -101,6 +106,17 @@ static void fsm_conn_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data) } } +/* Called when entering Connected state */ +static void fsm_conn_onenter_cb(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct reset_ctx *reset_ctx = (struct reset_ctx *)fi->priv; + struct bsc_msc_data *msc = reset_ctx->priv; + + LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection succeeded.\n"); + if (prev_state != ST_CONN) + osmo_stat_item_inc(msc->msc_statg->items[MSC_STAT_MSC_LINKS_ACTIVE], 1); +} + /* Timer callback to retransmit the reset signal */ static int fsm_reset_ack_timeout_cb(struct osmo_fsm_inst *fi) { @@ -121,12 +137,14 @@ static struct osmo_fsm_state reset_fsm_states[] = { .out_state_mask = (1 << ST_DISC) | (1 << ST_CONN), .name = "DISC", .action = fsm_disc_cb, + .onenter = fsm_disc_onenter_cb, }, [ST_CONN] = { .in_event_mask = (1 << EV_N_DISCONNECT) | (1 << EV_N_CONNECT), .out_state_mask = (1 << ST_DISC) | (1 << ST_CONN), .name = "CONN", .action = fsm_conn_cb, + .onenter = fsm_conn_onenter_cb, }, }; @@ -165,6 +183,9 @@ void a_reset_alloc(struct bsc_msc_data *msc, const char *name, void *cb) /* Immediately (1ms) kick off reset sending mechanism */ osmo_fsm_inst_state_chg_ms(reset_fsm, ST_DISC, 1, RESET_RESEND_TIMER_NO); + + /* Count the new MSC link */ + osmo_stat_item_inc(msc->msc_statg->items[MSC_STAT_MSC_LINKS_TOTAL], 1); } /* Confirm that we successfully received a reset acknowledge message */ |