aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/bsc/bsc_msc_data.h10
-rw-r--r--src/osmo-bsc/a_reset.c37
-rw-r--r--src/osmo-bsc/osmo_bsc_msc.c37
3 files changed, 78 insertions, 6 deletions
diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h
index b9df4ba8f..7d797eb9e 100644
--- a/include/osmocom/bsc/bsc_msc_data.h
+++ b/include/osmocom/bsc/bsc_msc_data.h
@@ -56,6 +56,12 @@ enum {
MSC_CON_TYPE_LOCAL,
};
+/* Constants for the MSC stats */
+enum {
+ MSC_STAT_MSC_LINKS_ACTIVE,
+ MSC_STAT_MSC_LINKS_TOTAL,
+};
+
/*! /brief Information on a remote MSC for libbsc.
*/
struct bsc_msc_data {
@@ -99,6 +105,10 @@ struct bsc_msc_data {
char *acc_lst_name;
+ /* structures for keeping rate counters and gauge stats */
+ struct rate_ctr_group *msc_ctrs;
+ struct osmo_stat_item_group *msc_statg;
+
/* Sigtran connection data */
struct {
uint32_t cs7_instance;
diff --git a/src/osmo-bsc/a_reset.c b/src/osmo-bsc/a_reset.c
index 3f512781b..63273e9f2 100644
--- a/src/osmo-bsc/a_reset.c
+++ b/src/osmo-bsc/a_reset.c
@@ -66,18 +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);
- LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection succeeded.\n");
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;
@@ -85,10 +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) {
- LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection down, reconnecting...\n");
+ 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:
@@ -97,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)
{
@@ -117,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,
},
};
@@ -161,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 */
diff --git a/src/osmo-bsc/osmo_bsc_msc.c b/src/osmo-bsc/osmo_bsc_msc.c
index 24c8c6d99..1704a73a8 100644
--- a/src/osmo-bsc/osmo_bsc_msc.c
+++ b/src/osmo-bsc/osmo_bsc_msc.c
@@ -43,6 +43,30 @@
#include <netinet/tcp.h>
#include <unistd.h>
+static const struct rate_ctr_desc msc_ctr_description[] = {
+};
+
+static const struct rate_ctr_group_desc msc_ctrg_desc = {
+ "msc",
+ "mobile switching center",
+ OSMO_STATS_CLASS_GLOBAL,
+ ARRAY_SIZE(msc_ctr_description),
+ msc_ctr_description,
+};
+
+static const struct osmo_stat_item_desc msc_stat_desc[] = {
+ { "msc_links:active", "Number of active MSC links", "", 16, 0 },
+ { "msc_links:total", "Number of configured MSC links", "", 16, 0 },
+};
+
+static const struct osmo_stat_item_group_desc msc_statg_desc = {
+ .group_name_prefix = "msc",
+ .group_description = "mobile switching center",
+ .class_id = OSMO_STATS_CLASS_GLOBAL,
+ .num_items = ARRAY_SIZE(msc_stat_desc),
+ .item_desc = msc_stat_desc,
+};
+
int osmo_bsc_msc_init(struct bsc_msc_data *msc)
{
struct gsm_network *net = msc->network;
@@ -91,6 +115,19 @@ struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr)
if (!msc_data)
return NULL;
+ /* init statistics */
+ msc_data->msc_ctrs = rate_ctr_group_alloc(net, &msc_ctrg_desc, nr);
+ if (!msc_data->msc_ctrs) {
+ talloc_free(msc_data);
+ return NULL;
+ }
+ msc_data->msc_statg = osmo_stat_item_group_alloc(net, &msc_statg_desc, nr);
+ if (!msc_data->msc_statg) {
+ rate_ctr_group_free(msc_data->msc_ctrs);
+ talloc_free(msc_data);
+ return NULL;
+ }
+
llist_add_tail(&msc_data->entry, &net->bsc_data->mscs);
/* Init back pointer */