Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2013 16:47:21 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 222006 for review
Message-ID:  <201302131647.r1DGlLO3064517@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@222006?ac=10

Change 222006 by bz@bz_zenith on 2013/02/13 16:47:07

	Track rx_err[] signalling as much as we found the information
	in the data sheets and export them via sysctl.
	Rename MAC stats to make it more clear and names less conflicting.

Affected files ...

.. //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atse.c#12 edit
.. //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atsereg.h#3 edit

Differences ...

==== //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atse.c#12 (text+ko) ====

@@ -1195,6 +1195,17 @@
 	return (error);
 }
 
+static void
+atse_update_rx_err(struct atse_softc *sc, uint32_t mask)
+{
+	int i;
+
+	/* RX error are 6 bits, we only know 4 of them. */
+	for (i = 0; i < ATSE_RX_ERR_MAX; i++)
+		if ((mask & (1 << i)) != 0)
+			sc->atse_rx_err[i]++;
+}
+
 static int
 atse_rx_locked(struct atse_softc *sc)
 {
@@ -1235,6 +1246,9 @@
 			meta = ATSE_RX_META_READ(sc);
 			if (meta & A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) {
 				/* XXX-BZ evaluate error. */
+				atse_update_rx_err(sc, ((meta &
+				    A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) >>
+				    A_ONCHIP_FIFO_MEM_CORE_ERROR_SHIFT) & 0xff);
 				ifp->if_ierrors++;
 				sc->atse_rx_buf_len = 0;
 				/*
@@ -1382,6 +1396,9 @@
 		if (rx & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW|
 		    A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW)) {
 			/* XXX-BZ ERROR HANDLING. */
+			atse_update_rx_err(sc, ((rx &
+			    A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) >>
+			    A_ONCHIP_FIFO_MEM_CORE_ERROR_SHIFT) & 0xff);
 			ifp->if_ierrors++;
 		}
 		if ((rx & A_ONCHIP_FIFO_MEM_CORE_EVENT_EMPTY) != 0) {
@@ -1448,6 +1465,9 @@
 		if (rx & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW|
 		    A_ONCHIP_FIFO_MEM_CORE_EVENT_UNDERFLOW)) {
 			/* XXX-BZ ERROR HANDLING. */
+			atse_update_rx_err(sc, ((rx &
+			    A_ONCHIP_FIFO_MEM_CORE_ERROR_MASK) >>
+			    A_ONCHIP_FIFO_MEM_CORE_ERROR_SHIFT) & 0xff);
 			ifp->if_ierrors++;
 		}
 		if (tx & (A_ONCHIP_FIFO_MEM_CORE_EVENT_OVERFLOW|
@@ -1471,10 +1491,10 @@
 }
 #endif /* DEVICE_POLLING */
 
-static struct atse_stats_regs {
+static struct atse_mac_stats_regs {
 	const char *name;
 	const char *descr;	/* Mostly copied from Altera datasheet. */
-} atse_stats_regs[] = {
+} atse_mac_stats_regs[] = {
 	[0x1a] =
 	{ "aFramesTransmittedOK",
 	    "The number of frames that are successfully transmitted including "
@@ -1576,7 +1596,7 @@
 };
 
 static int
-sysctl_atse_stats_proc(SYSCTL_HANDLER_ARGS)
+sysctl_atse_mac_stats_proc(SYSCTL_HANDLER_ARGS)
 {
 	struct atse_softc *sc;
         int error, offset, s;
@@ -1592,6 +1612,49 @@
         return (0);
 }
 
+static struct atse_rx_err_stats_regs {
+	const char *name;
+	const char *descr;
+} atse_rx_err_stats_regs[] = {
+
+#define ATSE_RX_ERR_FIFO_THRES_EOP      0 /* FIFO threshold reached, on EOP. */
+#define ATSE_RX_ERR_ELEN                1 /* Frame/payload length not valid. */
+#define ATSE_RX_ERR_CRC32               2 /* CRC-32 error. */
+#define ATSE_RX_ERR_FIFO_THRES_TRUNC    3 /* FIFO thresh., truncated frame. */
+#define ATSE_RX_ERR_4                   4 /* ? */
+#define ATSE_RX_ERR_5                   5 /* / */
+
+	{ "rx_err_fifo_thres_eop",
+	    "FIFO threshold reached, reported on EOP." },
+	{ "rx_err_fifo_elen",
+	    "Frame or payload length not valid." },
+	{ "rx_err_fifo_crc32",
+	    "CRC-32 error." },
+	{ "rx_err_fifo_thres_trunc",
+	    "FIFO threshold reached, truncated frame" },
+	{ "rx_err_4",
+	    "?" },
+	{ "rx_err_5",
+	    "?" },
+};
+
+static int
+sysctl_atse_rx_err_stats_proc(SYSCTL_HANDLER_ARGS)
+{
+	struct atse_softc *sc;
+        int error, offset, s;
+
+        sc = arg1;
+	offset = arg2;
+
+	s = sc->atse_rx_err[offset];
+	error = sysctl_handle_int(oidp, &s, 0, req);
+	if (error || !req->newptr)
+		return (error);
+
+        return (0);
+}
+
 static void
 atse_sysctl_stats_attach(device_t dev)
 {
@@ -1604,14 +1667,29 @@
         sctx = device_get_sysctl_ctx(dev);
         soid = device_get_sysctl_tree(dev);
 
-	for (i = 0; i < sizeof(atse_stats_regs)/sizeof(*atse_stats_regs); i++) {
-		if (atse_stats_regs[i].name == NULL ||
-		    atse_stats_regs[i].descr == NULL)
+	/* MAC statistics. */
+	for (i = 0; i < sizeof(atse_mac_stats_regs) /
+	    sizeof(*atse_mac_stats_regs); i++) {
+		if (atse_mac_stats_regs[i].name == NULL ||
+		    atse_mac_stats_regs[i].descr == NULL)
+			continue;
+
+		SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
+		    atse_mac_stats_regs[i].name, CTLTYPE_UINT|CTLFLAG_RD,
+		    sc, i, sysctl_atse_mac_stats_proc, "IU",
+		    atse_mac_stats_regs[i].descr);
+	}
+
+	/* rx_err[]. */
+	for (i = 0; i < ATSE_RX_ERR_MAX; i++) {
+		if (atse_rx_err_stats_regs[i].name == NULL ||
+		    atse_rx_err_stats_regs[i].descr == NULL)
 			continue;
 
 		SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
-		    atse_stats_regs[i].name, CTLTYPE_UINT|CTLFLAG_RD, sc, i,
-		    sysctl_atse_stats_proc, "IU", atse_stats_regs[i].descr);
+		    atse_rx_err_stats_regs[i].name, CTLTYPE_UINT|CTLFLAG_RD,
+		    sc, i, sysctl_atse_rx_err_stats_proc, "IU",
+		    atse_rx_err_stats_regs[i].descr);
 	}
 }
 

==== //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atsereg.h#3 (text+ko) ====

@@ -395,7 +395,7 @@
 /* -------------------------------------------------------------------------- */
 
 /* DE4 Intel Strata Flash Ethernet Option Bits area. */
-/* XXX-BZ this is something a loader will ahve to handle for us. */
+/* XXX-BZ this is something a loader will have to handle for us. */
 #define	ALTERA_ETHERNET_OPTION_BITS_OFF	0x00008000
 #define	ALTERA_ETHERNET_OPTION_BITS_LEN	0x00007fff
 
@@ -456,6 +456,14 @@
 	uint16_t		atse_rx_buf_len;
 	int16_t			atse_rx_cycles;		/* POLLING */
 #define	RX_CYCLES_IN_INTR	5
+	uint32_t		atse_rx_err[6];
+#define	ATSE_RX_ERR_FIFO_THRES_EOP	0 /* FIFO threshold reached, on EOP. */
+#define	ATSE_RX_ERR_ELEN		1 /* Frame/payload length not valid. */
+#define	ATSE_RX_ERR_CRC32		2 /* CRC-32 error. */
+#define	ATSE_RX_ERR_FIFO_THRES_TRUNC	3 /* FIFO thresh., truncated frame. */
+#define	ATSE_RX_ERR_4			4 /* ? */
+#define	ATSE_RX_ERR_5			5 /* / */
+#define	ATSE_RX_ERR_MAX			6
 	struct callout		atse_tick;
 	struct mtx		atse_mtx;
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302131647.r1DGlLO3064517>