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
This commit is contained in:
Neels Hofmeyr 2023-05-05 01:10:44 +02:00
parent 56323378db
commit e513ffb983
5 changed files with 137 additions and 0 deletions

View File

@ -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 @@ struct hnbgw_cnpool {
/* 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 @@ struct hnbgw_cnlink {
bool allow_attach;
bool allow_emerg;
struct rate_ctr_group *ctrs;
};
#define LOG_CNLINK(CNLINK, SUBSYS, LEVEL, FMT, ARGS...) \

View File

@ -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 @@ int hnbgw_cnlink_start_or_restart(struct hnbgw_cnlink *cnlink);
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;

View File

@ -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;
@ -71,6 +72,9 @@ void g_hnbgw_alloc(void *ctx)
.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);
@ -83,6 +87,9 @@ void g_hnbgw_alloc(void *ctx)
.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);
}

View File

@ -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 @@ static struct hnbgw_cnlink *cnlink_alloc(struct hnbgw_cnpool *cnpool, int nr)
.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 @@ char *cnlink_sccp_addr_to_str(struct hnbgw_cnlink *cnlink, const struct osmo_scc
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,
};

View File

@ -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 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
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);