Change in libosmocore[master]: ns2: Introduce a per-bind stat_item group with backlog length

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Jan 31 11:35:10 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22569 )


Change subject: ns2: Introduce a per-bind stat_item group with backlog length
......................................................................

ns2: Introduce a per-bind stat_item group with backlog length

The backlog length indicates the instantaneous length of the backlog.

Change-Id: I1c55b4619b1221d7e607ace58649323407faf86b
---
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_fr.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_vty.c
4 files changed, 37 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/69/22569/1

diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 95fec19..abd445b 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -196,6 +196,18 @@
 	.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" },
@@ -1243,6 +1255,7 @@
 		bind->driver->free_bind(bind);
 
 	llist_del(&bind->list);
+	osmo_stat_item_group_free(bind->statg);
 	talloc_free((char *)bind->name);
 	talloc_free(bind);
 }
@@ -1373,10 +1386,18 @@
 		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 c32bce8..49e92ae 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 @@
 {
 	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 @@
 {
 	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 @@
 			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 8689f47..5fea6ef 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -72,10 +72,14 @@
 	_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 */
@@ -127,6 +131,7 @@
 
 	/*! 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;
@@ -249,6 +254,8 @@
 	/*! 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 c2b9bd9..5d0f5c0 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1374,6 +1374,10 @@
 {
 	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)

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22569
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I1c55b4619b1221d7e607ace58649323407faf86b
Gerrit-Change-Number: 22569
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210131/a5c90c4d/attachment.htm>


More information about the gerrit-log mailing list