pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-hnbgw/+/40269?usp=email )
Change subject: cnlink: Introduce stats group with connected state
......................................................................
cnlink: Introduce stats group with connected state
Change-Id: I9c78c6b78b4ee8d6836df8d90c5c57103aa4d762
---
M include/osmocom/hnbgw/cnlink.h
M src/osmo-hnbgw/cnlink.c
M src/osmo-hnbgw/cnlink_fsm.c
3 files changed, 37 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/69/40269/1
diff --git a/include/osmocom/hnbgw/cnlink.h b/include/osmocom/hnbgw/cnlink.h
index fd1b7de..ee1a8dd 100644
--- a/include/osmocom/hnbgw/cnlink.h
+++ b/include/osmocom/hnbgw/cnlink.h
@@ -3,6 +3,7 @@
#include <stdbool.h>
#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/stat_item.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/sigtran/sccp_sap.h>
@@ -48,6 +49,13 @@
CNLINK_CTR_CNPOOL_SUBSCR_ATTACH_LOST,
CNLINK_CTR_CNPOOL_EMERG_FORWARDED,
};
+#define CNLINK_CTR_INC(cnlink, x) rate_ctr_inc2((cnlink)->ctrs, x)
+
+enum cnlink_stat {
+ CNLINK_STAT_CONNECTED,
+};
+#define CNLINK_STAT(cnlink, x) osmo_stat_item_group_get_item((cnlink)->statg, x)
+#define CNLINK_STAT_SET(cnlink, x, val) osmo_stat_item_set(CNLINK_STAT(cnlink, x), val)
/* User provided configuration for struct hnbgw_cnlink. */
struct hnbgw_cnlink_cfg {
@@ -90,6 +98,7 @@
struct llist_head paging;
struct rate_ctr_group *ctrs;
+ struct osmo_stat_item_group *statg;
};
struct hnbgw_cnlink *hnbgw_cnlink_alloc(struct hnbgw_cnpool *cnpool, int nr);
@@ -125,5 +134,3 @@
#define LOG_CNLINK(CNLINK, SUBSYS, LEVEL, FMT, ARGS...) \
LOGP(SUBSYS, LEVEL, "(%s) " FMT, (CNLINK) ? (CNLINK)->name :
"null", ##ARGS)
-
-#define CNLINK_CTR_INC(cnlink, x) rate_ctr_inc2((cnlink)->ctrs, x)
diff --git a/src/osmo-hnbgw/cnlink.c b/src/osmo-hnbgw/cnlink.c
index 19f1d3d..8d312c6 100644
--- a/src/osmo-hnbgw/cnlink.c
+++ b/src/osmo-hnbgw/cnlink.c
@@ -21,6 +21,7 @@
#include <osmocom/core/fsm.h>
#include <osmocom/core/tdef.h>
#include <osmocom/core/stats.h>
+#include <osmocom/core/stat_item.h>
#include <osmocom/gsm/gsm23236.h>
@@ -161,19 +162,42 @@
cnlink_ctr_description,
};
+static const struct osmo_stat_item_desc cnlink_stat_desc[] = {
+ [CNLINK_STAT_CONNECTED] = { "connected", "Connected (1) or disconnected
(0)", NULL, 60, 0 },
+};
+
+const struct osmo_stat_item_group_desc msc_statg_desc = {
+ .group_name_prefix = "msc",
+ .group_description = "MSC",
+ .class_id = OSMO_STATS_CLASS_GLOBAL,
+ .num_items = ARRAY_SIZE(cnlink_stat_desc),
+ .item_desc = cnlink_stat_desc,
+};
+
+const struct osmo_stat_item_group_desc sgsn_statg_desc = {
+ .group_name_prefix = "sgsn",
+ .group_description = "SGSN",
+ .class_id = OSMO_STATS_CLASS_GLOBAL,
+ .num_items = ARRAY_SIZE(cnlink_stat_desc),
+ .item_desc = cnlink_stat_desc,
+};
+
struct hnbgw_cnlink *hnbgw_cnlink_alloc(struct hnbgw_cnpool *cnpool, int nr)
{
struct hnbgw_cnlink *cnlink;
const struct rate_ctr_group_desc *ctrg_desc;
+ const struct osmo_stat_item_group_desc *statg_desc;
OSMO_ASSERT(cnpool);
switch (cnpool->domain) {
case DOMAIN_CS:
ctrg_desc = &msc_ctrg_desc;
+ statg_desc = &msc_statg_desc;
break;
case DOMAIN_PS:
ctrg_desc = &sgsn_ctrg_desc;
+ statg_desc = &sgsn_statg_desc;
break;
default:
OSMO_ASSERT(0);
@@ -190,6 +214,7 @@
},
.allow_attach = true,
.ctrs = rate_ctr_group_alloc(cnlink, ctrg_desc, nr),
+ .statg = osmo_stat_item_group_alloc(cnlink, statg_desc, nr),
};
cnlink->name = talloc_asprintf(cnlink, "%s-%d", cnpool->peer_name, nr);
INIT_LLIST_HEAD(&cnlink->map_list);
@@ -230,6 +255,7 @@
osmo_fsm_inst_term(cnlink->fi, OSMO_FSM_TERM_REQUEST, NULL);
cnlink->fi = NULL;
+ osmo_stat_item_group_free(cnlink->statg);
rate_ctr_group_free(cnlink->ctrs);
llist_del(&cnlink->entry);
talloc_free(cnlink);
diff --git a/src/osmo-hnbgw/cnlink_fsm.c b/src/osmo-hnbgw/cnlink_fsm.c
index acfbae4..9402198 100644
--- a/src/osmo-hnbgw/cnlink_fsm.c
+++ b/src/osmo-hnbgw/cnlink_fsm.c
@@ -63,6 +63,7 @@
static void link_up(struct hnbgw_cnlink *cnlink)
{
LOGPFSML(cnlink->fi, LOGL_NOTICE, "link up\n");
+ CNLINK_STAT_SET(cnlink, CNLINK_STAT_CONNECTED, 1);
}
static void link_lost(struct hnbgw_cnlink *cnlink)
@@ -70,6 +71,7 @@
struct hnbgw_context_map *map, *map2;
LOGPFSML(cnlink->fi, LOGL_NOTICE, "link lost\n");
+ CNLINK_STAT_SET(cnlink, CNLINK_STAT_CONNECTED, 0);
llist_for_each_entry_safe(map, map2, &cnlink->map_list, hnbgw_cnlink_entry)
context_map_cnlink_lost(map);
--
To view, visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/40269?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I9c78c6b78b4ee8d6836df8d90c5c57103aa4d762
Gerrit-Change-Number: 40269
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>