neels has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmo-hnbgw/+/33134 )
Change subject: add rate_ctr infra; add rate_ctrs for cnpool
......................................................................
add rate_ctr infra; add rate_ctrs for cnpool
Introduce rate counter stats to osmo-hnbgw.
Add the first rate counters -- they will be fed in upcoming commit
"cnpool: select CN link from pool by NRI or round robin"
I66fba27cfbe6e2b27ee3443718846ecfbbd8a974
Related: SYS#6412
Change-Id: I0132d053223a38e5756cede74106019c47ddcd94
---
M include/osmocom/hnbgw/hnbgw.h
M include/osmocom/hnbgw/hnbgw_cn.h
M src/osmo-hnbgw/hnbgw.c
M src/osmo-hnbgw/hnbgw_cn.c
M src/osmo-hnbgw/osmo_hnbgw_main.c
5 files changed, 153 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/34/33134/1
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index 8183cbc..62e5392 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -5,6 +5,7 @@
#include <osmocom/core/hashtable.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/timer.h>
+#include <osmocom/core/rate_ctr.h>
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/osmo_ss7.h>
#include <osmocom/ctrl/control_if.h>
@@ -135,6 +136,12 @@
/* Emergency calls potentially select a different set of MSCs, so to not mess up the
normal round-robin
* behavior, emergency calls need a separate round-robin counter. */
unsigned int round_robin_next_emerg_nr;
+
+ /* rate counter group that child hnbgw_cnlinks should use (points to msc_ctrg_desc or
sgsn_ctrg_desc) */
+ const struct rate_ctr_group_desc *cnlink_ctrg_desc;
+
+ /* Running counters for this pool */
+ struct rate_ctr_group *ctrs;
};
/* A CN peer, like 'msc 0' or 'sgsn 23' */
@@ -164,6 +171,8 @@
bool allow_attach;
bool allow_emerg;
+
+ struct rate_ctr_group *ctrs;
};
#define LOG_CNLINK(CNLINK, SUBSYS, LEVEL, FMT, ARGS...) \
diff --git a/include/osmocom/hnbgw/hnbgw_cn.h b/include/osmocom/hnbgw/hnbgw_cn.h
index 79d3c27..bd54a1f 100644
--- a/include/osmocom/hnbgw/hnbgw_cn.h
+++ b/include/osmocom/hnbgw/hnbgw_cn.h
@@ -1,5 +1,6 @@
#pragma once
+#include <osmocom/core/rate_ctr.h>
#include <osmocom/hnbgw/hnbgw.h>
struct hnbgw_cnlink *hnbgw_cnlink_find_by_addr(const struct hnbgw_sccp_user *hsu,
@@ -13,3 +14,33 @@
char *cnlink_sccp_addr_to_str(struct hnbgw_cnlink *cnlink, const struct osmo_sccp_addr
*addr);
+enum hnbgw_cnpool_ctr {
+ /* TODO: basic counters completely missing
+ * ...
+ */
+
+ /* Counters related to link selection from a CN pool. */
+ CNPOOL_CTR_SUBSCR_NO_CNLINK,
+ CNPOOL_CTR_EMERG_FORWARDED,
+ CNPOOL_CTR_EMERG_LOST,
+};
+
+extern const struct rate_ctr_group_desc iucs_ctrg_desc;
+extern const struct rate_ctr_group_desc iups_ctrg_desc;
+
+enum hnbgw_cnlink_ctr {
+ /* TODO: basic counters completely missing
+ * ...
+ */
+
+ /* Counters related to link selection from a CN pool. */
+ CNLINK_CTR_CNPOOL_SUBSCR_NEW,
+ CNLINK_CTR_CNPOOL_SUBSCR_REATTACH,
+ CNLINK_CTR_CNPOOL_SUBSCR_KNOWN,
+ CNLINK_CTR_CNPOOL_SUBSCR_PAGED,
+ CNLINK_CTR_CNPOOL_SUBSCR_ATTACH_LOST,
+ CNLINK_CTR_CNPOOL_EMERG_FORWARDED,
+};
+
+extern const struct rate_ctr_group_desc msc_ctrg_desc;
+extern const struct rate_ctr_group_desc sgsn_ctrg_desc;
diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c
index 0d64adf..1fd04e1 100644
--- a/src/osmo-hnbgw/hnbgw.c
+++ b/src/osmo-hnbgw/hnbgw.c
@@ -36,6 +36,7 @@
#include <osmocom/hnbgw/hnbgw.h>
#include <osmocom/hnbgw/hnbgw_hnbap.h>
#include <osmocom/hnbgw/hnbgw_rua.h>
+#include <osmocom/hnbgw/hnbgw_cn.h>
#include <osmocom/hnbgw/context_map.h>
struct hnbgw *g_hnbgw = NULL;
@@ -72,6 +73,9 @@
.nri_bitlen = OSMO_NRI_BITLEN_DEFAULT,
.null_nri_ranges = osmo_nri_ranges_alloc(g_hnbgw),
},
+ .cnlink_ctrg_desc = &msc_ctrg_desc,
+
+ .ctrs = rate_ctr_group_alloc(g_hnbgw, &iucs_ctrg_desc, 0),
};
INIT_LLIST_HEAD(&g_hnbgw->sccp.cnpool_iucs.cnlinks);
@@ -84,6 +88,9 @@
.nri_bitlen = OSMO_NRI_BITLEN_DEFAULT,
.null_nri_ranges = osmo_nri_ranges_alloc(g_hnbgw),
},
+ .cnlink_ctrg_desc = &sgsn_ctrg_desc,
+
+ .ctrs = rate_ctr_group_alloc(g_hnbgw, &iups_ctrg_desc, 0),
};
INIT_LLIST_HEAD(&g_hnbgw->sccp.cnpool_iups.cnlinks);
}
diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c
index 9dc2016..486d30a 100644
--- a/src/osmo-hnbgw/hnbgw_cn.c
+++ b/src/osmo-hnbgw/hnbgw_cn.c
@@ -26,6 +26,7 @@
#include <osmocom/core/msgb.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/timer.h>
+#include <osmocom/core/stats.h>
#include <osmocom/gsm/gsm23236.h>
@@ -655,6 +656,7 @@
.nri_ranges = osmo_nri_ranges_alloc(cnlink),
},
.allow_attach = true,
+ .ctrs = rate_ctr_group_alloc(g_hnbgw, cnpool->cnlink_ctrg_desc, nr),
};
INIT_LLIST_HEAD(&cnlink->map_list);
@@ -724,3 +726,81 @@
return osmo_sccp_addr_dump(addr);
return osmo_sccp_inst_addr_to_str_c(OTC_SELECT, sccp, addr);
}
+
+static const struct rate_ctr_desc cnlink_ctr_description[] = {
+
+ /* Indicators for CN pool usage */
+ [CNLINK_CTR_CNPOOL_SUBSCR_NEW] = {
+ "cnpool:subscr:new",
+ "Complete Layer 3 requests assigned to this CN link by round-robin (no NRI was
assigned yet).",
+ },
+ [CNLINK_CTR_CNPOOL_SUBSCR_REATTACH] = {
+ "cnpool:subscr:reattach",
+ "Complete Layer 3 requests assigned to this CN link by round-robin because the
subscriber indicates a"
+ " NULL-NRI (previously assigned by another CN link).",
+ },
+ [CNLINK_CTR_CNPOOL_SUBSCR_KNOWN] = {
+ "cnpool:subscr:known",
+ "Complete Layer 3 requests directed to this CN link because the subscriber
indicates an NRI of this CN link.",
+ },
+ [CNLINK_CTR_CNPOOL_SUBSCR_PAGED] = {
+ "cnpool:subscr:paged",
+ "Paging Response directed to this CN link because the subscriber was recently
paged by this CN link.",
+ },
+ [CNLINK_CTR_CNPOOL_SUBSCR_ATTACH_LOST] = {
+ "cnpool:subscr:attach_lost",
+ "A subscriber indicates an NRI value matching this CN link, but the CN link is not
connected:"
+ " a re-attach to another CN link (if available) was forced, with possible service
failure.",
+ },
+ [CNLINK_CTR_CNPOOL_EMERG_FORWARDED] = {
+ "cnpool:emerg:forwarded",
+ "Emergency call requests forwarded to this CN link.",
+ },
+};
+
+const struct rate_ctr_group_desc msc_ctrg_desc = {
+ "msc",
+ "MSC",
+ OSMO_STATS_CLASS_GLOBAL,
+ ARRAY_SIZE(cnlink_ctr_description),
+ cnlink_ctr_description,
+};
+
+const struct rate_ctr_group_desc sgsn_ctrg_desc = {
+ "sgsn",
+ "SGSN",
+ OSMO_STATS_CLASS_GLOBAL,
+ ARRAY_SIZE(cnlink_ctr_description),
+ cnlink_ctr_description,
+};
+
+static const struct rate_ctr_desc cnpool_ctr_description[] = {
+ [CNPOOL_CTR_SUBSCR_NO_CNLINK] = {
+ "cnpool:subscr:no_cnlink",
+ "Complete Layer 3 requests lost because no connected CN link is found
available",
+ },
+ [CNPOOL_CTR_EMERG_FORWARDED] = {
+ "cnpool:emerg:forwarded",
+ "Emergency call requests forwarded to a CN link (see also per-CN-link
counters)",
+ },
+ [CNPOOL_CTR_EMERG_LOST] = {
+ "cnpool:emerg:lost",
+ "Emergency call requests lost because no CN link was found available",
+ },
+};
+
+const struct rate_ctr_group_desc iucs_ctrg_desc = {
+ "iucs",
+ "IuCS",
+ OSMO_STATS_CLASS_GLOBAL,
+ ARRAY_SIZE(cnpool_ctr_description),
+ cnpool_ctr_description,
+};
+
+const struct rate_ctr_group_desc iups_ctrg_desc = {
+ "iups",
+ "IuPS",
+ OSMO_STATS_CLASS_GLOBAL,
+ ARRAY_SIZE(cnpool_ctr_description),
+ cnpool_ctr_description,
+};
diff --git a/src/osmo-hnbgw/osmo_hnbgw_main.c b/src/osmo-hnbgw/osmo_hnbgw_main.c
index 30f3de9..d371914 100644
--- a/src/osmo-hnbgw/osmo_hnbgw_main.c
+++ b/src/osmo-hnbgw/osmo_hnbgw_main.c
@@ -25,6 +25,7 @@
#include <osmocom/core/application.h>
#include <osmocom/core/logging.h>
+#include <osmocom/core/stats.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
@@ -32,6 +33,7 @@
#include <osmocom/vty/misc.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/ports.h>
+#include <osmocom/vty/stats.h>
#include <osmocom/ctrl/control_vty.h>
#include <osmocom/ctrl/ports.h>
@@ -194,6 +196,13 @@
if (rc < 0)
exit(1);
+ osmo_stats_init(g_hnbgw);
+ rc = rate_ctr_init(g_hnbgw);
+ if (rc) {
+ LOGP(DMAIN, LOGL_FATAL, "rate_ctr_init() failed with rc=%d\n", rc);
+ exit(1);
+ }
+
osmo_fsm_log_timeouts(true);
rc = osmo_ss7_init();
@@ -211,6 +220,7 @@
ctrl_vty_init(g_hnbgw);
logging_vty_add_cmds();
osmo_talloc_vty_add_cmds();
+ osmo_stats_vty_add_cmds();
/* Handle options after vty_init(), for --version */
handle_options(argc, argv);
--
To view, visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/33134
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I0132d053223a38e5756cede74106019c47ddcd94
Gerrit-Change-Number: 33134
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange