aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-01-31 11:54:02 +0100
committerHarald Welte <laforge@osmocom.org>2021-02-01 09:39:29 +0100
commit76346079e8e7ee86121bde83b2338f06cd4f7ead (patch)
tree0ff77cc8fdc19e76bb13f1fb1e49fb2e99fba68c
parent97ccbf71b311639f6668fcb952806a3c0931d114 (diff)
ns2: Introduce a per-bind stat_item group with backlog length
The backlog length indicates the instantaneous length of the backlog. Change-Id: I1c55b4619b1221d7e607ace58649323407faf86b
-rw-r--r--src/gb/gprs_ns2.c21
-rw-r--r--src/gb/gprs_ns2_fr.c4
-rw-r--r--src/gb/gprs_ns2_internal.h9
-rw-r--r--src/gb/gprs_ns2_vty.c4
4 files changed, 37 insertions, 1 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 9c9da79b..1f7525e0 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -198,6 +198,18 @@ static const struct osmo_stat_item_group_desc nsvc_statg_desc = {
.class_id = OSMO_STATS_CLASS_PEER,
};
+const struct osmo_stat_item_desc nsbind_stat_description[] = {
+ [NS2_BIND_STAT_BACKLOG_LEN] = { "tx_backlog_length", "Transmit backlog length", "packets", 16, 0 },
+};
+
+static const struct osmo_stat_item_group_desc nsbind_statg_desc = {
+ .group_name_prefix = "ns.bind",
+ .group_description = "NS Bind Statistics",
+ .num_items = ARRAY_SIZE(nsbind_stat_description),
+ .item_desc = nsbind_stat_description,
+ .class_id = OSMO_STATS_CLASS_PEER,
+};
+
const struct value_string gprs_ns2_aff_cause_prim_strs[] = {
{ GPRS_NS2_AFF_CAUSE_VC_FAILURE, "NSVC failure" },
{ GPRS_NS2_AFF_CAUSE_VC_RECOVERY, "NSVC recovery" },
@@ -1245,6 +1257,7 @@ void gprs_ns2_free_bind(struct gprs_ns2_vc_bind *bind)
bind->driver->free_bind(bind);
llist_del(&bind->list);
+ osmo_stat_item_group_free(bind->statg);
talloc_free((char *)bind->name);
talloc_free(bind);
}
@@ -1375,10 +1388,18 @@ int ns2_bind_alloc(struct gprs_ns2_inst *nsi, const char *name,
return -ENOMEM;
}
+ bind->statg = osmo_stat_item_group_alloc(bind, &nsbind_statg_desc, nsi->bind_rate_ctr_idx);
+ if (!bind->statg) {
+ talloc_free(bind);
+ return -ENOMEM;
+ }
+
bind->nsi = nsi;
INIT_LLIST_HEAD(&bind->nsvc);
llist_add(&bind->list, &nsi->binding);
+ nsi->bind_rate_ctr_idx++;
+
if (result)
*result = bind;
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index c32bce87..49e92ae2 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -47,6 +47,7 @@
#include <osmocom/gprs/frame_relay.h>
#include <osmocom/core/byteswap.h>
+#include <osmocom/core/stat_item.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
@@ -327,6 +328,7 @@ static void enqueue_at_head(struct gprs_ns2_vc_bind *bind, struct msgb *msg)
{
struct priv_bind *priv = bind->priv;
llist_add(&msg->list, &priv->backlog.list);
+ osmo_stat_item_inc(bind->statg->items[NS2_BIND_STAT_BACKLOG_LEN], 1);
osmo_timer_schedule(&priv->backlog.timer, 0, priv->backlog.retry_us);
}
@@ -334,6 +336,7 @@ static void enqueue_at_tail(struct gprs_ns2_vc_bind *bind, struct msgb *msg)
{
struct priv_bind *priv = bind->priv;
llist_add_tail(&msg->list, &priv->backlog.list);
+ osmo_stat_item_inc(bind->statg->items[NS2_BIND_STAT_BACKLOG_LEN], 1);
osmo_timer_schedule(&priv->backlog.timer, 0, priv->backlog.retry_us);
}
@@ -402,6 +405,7 @@ static void fr_backlog_timer_cb(void *data)
llist_add(&msg->list, &priv->backlog.list);
break;
}
+ osmo_stat_item_dec(bind->statg->items[NS2_BIND_STAT_BACKLOG_LEN], 1);
}
/* re-start timer if we still have data in the queue */
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index f3c68f50..64629071 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -72,10 +72,14 @@ enum nsvc_timer_mode {
_NSVC_TIMER_NR,
};
-enum ns_stat {
+enum ns2_vc_stat {
NS_STAT_ALIVE_DELAY,
};
+enum ns2_bind_stat {
+ NS2_BIND_STAT_BACKLOG_LEN,
+};
+
/*! Osmocom NS2 VC create status */
enum ns2_cs {
NS2_CS_CREATED, /*!< A NSVC object has been created */
@@ -129,6 +133,7 @@ struct gprs_ns2_inst {
/*! workaround for rate counter until rate counter accepts char str as index */
uint32_t nsvc_rate_ctr_idx;
+ uint32_t bind_rate_ctr_idx;
/*! libmnl netlink socket for link state monitoring */
struct osmo_mnl *linkmon_mnl;
@@ -251,6 +256,8 @@ struct gprs_ns2_vc_bind {
/*! allow to show information for the vty */
void (*dump_vty)(const struct gprs_ns2_vc_bind *bind,
struct vty *vty, bool stats);
+
+ struct osmo_stat_item_group *statg;
};
struct gprs_ns2_vc_driver {
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index c2b9bd9a..5d0f5c05 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1374,6 +1374,10 @@ static void dump_bind(struct vty *vty, const struct gprs_ns2_vc_bind *bind, bool
{
if (bind->dump_vty)
bind->dump_vty(bind, vty, stats);
+
+ if (stats) {
+ vty_out_stat_item_group(vty, " ", bind->statg);
+ }
}
static void dump_ns_bind(struct vty *vty, const struct gprs_ns2_inst *nsi, bool stats)