Change in osmo-e1d[master]: Add per-line rate counter group to count various errors

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
Thu Dec 17 20:56:49 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/21783 )


Change subject: Add per-line rate counter group to count various errors
......................................................................

Add per-line rate counter group to count various errors

Change-Id: I766b717843d7cd8ac00d4ce18c38773ac50ec3e6
---
M src/e1d.h
M src/intf_line.c
M src/usb.c
M src/vty.c
4 files changed, 46 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/83/21783/1

diff --git a/src/e1d.h b/src/e1d.h
index a7ba005..16d0fad 100644
--- a/src/e1d.h
+++ b/src/e1d.h
@@ -26,7 +26,15 @@
 
 #include <osmocom/core/isdnhdlc.h>
 #include <osmocom/core/linuxlist.h>
+#include <osmocom/core/rate_ctr.h>
 
+enum e1d_line_ctr {
+	LINE_CTR_LOS,
+	LINE_CTR_LOA,
+	LINE_CTR_CRC_ERR,
+	LINE_CTR_RX_OVFL,
+	LINE_CTR_TX_UNFL,
+};
 
 enum e1_ts_mode {
 	E1_TS_MODE_OFF = 0,
@@ -81,6 +89,7 @@
 	enum e1_line_mode mode;
 
 	void *drv_data;
+	struct rate_ctr_group *ctrs;
 
 	/* timeslots for channelized mode */
 	struct e1_ts ts[32];
diff --git a/src/intf_line.c b/src/intf_line.c
index 5fd82b7..2ed9e66 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -33,6 +33,8 @@
 
 #include <osmocom/core/isdnhdlc.h>
 #include <osmocom/core/utils.h>
+#include <osmocom/core/stats.h>
+#include <osmocom/core/rate_ctr.h>
 #include <osmocom/e1d/proto.h>
 
 #include "e1d.h"
@@ -44,6 +46,22 @@
 	{ 0, NULL }
 };
 
+static const struct rate_ctr_desc line_ctr_description[] = {
+	[LINE_CTR_LOS] =	{ "rx:signal_lost",		"Rx Signal Lost" },
+	[LINE_CTR_LOA] =	{ "rx:alignment_lost",		"Rx Alignment Lost" },
+	[LINE_CTR_CRC_ERR] =	{ "rx:crc_errors",		"E1 Rx CRC Errors" },
+	[LINE_CTR_RX_OVFL] =	{ "rx:overflow",		"E1 Rx Overflow" },
+	[LINE_CTR_TX_UNFL] =	{ "tx:underflow",		"E1 Tx Underflow" },
+};
+
+static const struct rate_ctr_group_desc line_ctrg_desc = {
+	.group_name_prefix = "e1d_line",
+	.group_description = "Counters for each line in e1d",
+	.class_id = OSMO_STATS_CLASS_GLOBAL,
+	.num_ctr = ARRAY_SIZE(line_ctr_description),
+	.ctr_desc = line_ctr_description,
+};
+
 // ---------------------------------------------------------------------------
 // e1d structures
 // ---------------------------------------------------------------------------
@@ -122,6 +140,9 @@
 		line->id = l->id + 1;
 	}
 
+	line->ctrs = rate_ctr_group_alloc(line, &line_ctrg_desc, line->id);
+	OSMO_ASSERT(line->ctrs);
+
 	llist_add_tail(&line->list, &intf->lines);
 
 	LOGPLI(line, DE1D, LOGL_NOTICE, "Created\n");
diff --git a/src/usb.c b/src/usb.c
index 3a35a20..783f624 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -283,6 +283,14 @@
 
 static int resubmit_irq(struct e1_line *line);
 
+#define line_ctr_add(line, idx, add) rate_ctr_add(&(line)->ctrs->ctr[idx], add)
+
+/* compute how much advanced 'cur' is copared to 'prev', in modulo-0xffff for wraps */
+static uint32_t delta_mod_u16(uint32_t cur, uint32_t prev)
+{
+	return ((cur + 0xffff) - prev) % 0xffff;
+}
+
 static void rx_interrupt_errcnt(struct e1_line *line, const struct ice1usb_irq_err *errcnt)
 {
 	struct e1_usb_line_data *ld = (struct e1_usb_line_data *) line->drv_data;
@@ -291,21 +299,25 @@
 	if (errcnt->crc != last->crc) {
 		LOGPLI(line, DE1D, LOGL_ERROR, "CRC error count %d (was %d)\n",
 			errcnt->crc, last->crc);
+		line_ctr_add(line, LINE_CTR_CRC_ERR, delta_mod_u16(errcnt->crc, last->crc));
 	}
 
 	if (errcnt->align != last->align) {
 		LOGPLI(line, DE1D, LOGL_ERROR, "ALIGNMENT error count %d (was %d)\n",
 			errcnt->align, last->align);
+		line_ctr_add(line, LINE_CTR_LOA, delta_mod_u16(errcnt->align, last->align));
 	}
 
 	if (errcnt->ovfl != last->ovfl) {
 		LOGPLI(line, DE1D, LOGL_ERROR, "OVERFLOW error count %d (was %d)\n",
 			errcnt->ovfl, last->ovfl);
+		line_ctr_add(line, LINE_CTR_RX_OVFL, delta_mod_u16(errcnt->ovfl, last->ovfl));
 	}
 
 	if (errcnt->unfl != last->unfl) {
 		LOGPLI(line, DE1D, LOGL_ERROR, "UNDERFLOW error count %d (was %d)\n",
 			errcnt->unfl, last->unfl);
+		line_ctr_add(line, LINE_CTR_TX_UNFL, delta_mod_u16(errcnt->unfl, last->unfl));
 	}
 
 	if ((errcnt->flags & ICE1USB_ERR_F_ALIGN_ERR) != (last->flags & ICE1USB_ERR_F_ALIGN_ERR)) {
@@ -316,6 +328,8 @@
 	if ((errcnt->flags & ICE1USB_ERR_F_TICK_ERR) != (last->flags & ICE1USB_ERR_F_TICK_ERR)) {
 		LOGPLI(line, DE1D, LOGL_ERROR, "Rx Clock %s\n",
 			errcnt->flags & ICE1USB_ERR_F_TICK_ERR ? "LOST" : "REGAINED");
+		if (errcnt->flags & ICE1USB_ERR_F_TICK_ERR)
+			line_ctr_add(line, LINE_CTR_LOS, 1);
 	}
 
 	ld->irq.last_errcnt = *errcnt;
diff --git a/src/vty.c b/src/vty.c
index 1caa54f..c145a9d 100644
--- a/src/vty.c
+++ b/src/vty.c
@@ -125,6 +125,8 @@
 	vty_out(vty, " SC: Mode %s, FD %d, Peer PID %d%s",
 		get_value_string(e1_ts_mode_names, line->superchan.mode),
 		line->superchan.fd, get_remote_pid(line->superchan.fd), VTY_NEWLINE);
+
+	vty_out_rate_ctr_group(vty, " ", line->ctrs);
 }
 
 DEFUN(show_line, show_line_cmd, "show line [<0-255>]",

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

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I766b717843d7cd8ac00d4ce18c38773ac50ec3e6
Gerrit-Change-Number: 21783
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/20201217/c746ae64/attachment.htm>


More information about the gerrit-log mailing list