PERFORCE change 222004 for review
Bjoern A. Zeeb
bz at FreeBSD.org
Wed Feb 13 15:45:17 UTC 2013
http://p4web.freebsd.org/@@222004?ac=10
Change 222004 by bz at bz_zenith on 2013/02/13 15:45:02
Export MAC statistics by sysctl.
Descriptions match the Altera data sheet (mostly).
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atse.c#11 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/sys/dev/altera/atse/if_atse.c#11 (text+ko) ====
@@ -1471,6 +1471,150 @@
}
#endif /* DEVICE_POLLING */
+static struct atse_stats_regs {
+ const char *name;
+ const char *descr; /* Mostly copied from Altera datasheet. */
+} atse_stats_regs[] = {
+ [0x1a] =
+ { "aFramesTransmittedOK",
+ "The number of frames that are successfully transmitted including "
+ "the pause frames." },
+ { "aFramesReceivedOK",
+ "The number of frames that are successfully received including the "
+ "pause frames." },
+ { "aFrameCheckSequenceErrors",
+ "The number of receive frames with CRC error." },
+ { "aAlignmentErrors",
+ "The number of receive frames with alignment error." },
+ { "aOctetsTransmittedOK",
+ "The lower 32 bits of the number of data and padding octets that "
+ "are successfully transmitted." },
+ { "aOctetsReceivedOK",
+ "The lower 32 bits of the number of data and padding octets that "
+ " are successfully received." },
+ { "aTxPAUSEMACCtrlFrames",
+ "The number of pause frames transmitted." },
+ { "aRxPAUSEMACCtrlFrames",
+ "The number received pause frames received." },
+ { "ifInErrors",
+ "The number of errored frames received." },
+ { "ifOutErrors",
+ "The number of transmit frames with either a FIFO overflow error, "
+ "a FIFO underflow error, or a error defined by the user "
+ "application." },
+ { "ifInUcastPkts",
+ "The number of valid unicast frames received." },
+ { "ifInMulticastPkts",
+ "The number of valid multicast frames received. The count does "
+ "not include pause frames." },
+ { "ifInBroadcastPkts",
+ "The number of valid broadcast frames received." },
+ { "ifOutDiscards",
+ "This statistics counter is not in use. The MAC function does not "
+ "discard frames that are written to the FIFO buffer by the user "
+ "application." },
+ { "ifOutUcastPkts",
+ "The number of valid unicast frames transmitted." },
+ { "ifOutMulticastPkts",
+ "The number of valid multicast frames transmitted, excluding pause "
+ "frames." },
+ { "ifOutBroadcastPkts",
+ "The number of valid broadcast frames transmitted." },
+ { "etherStatsDropEvents",
+ "The number of frames that are dropped due to MAC internal errors "
+ "when FIFO buffer overflow persists." },
+ { "etherStatsOctets",
+ "The lower 32 bits of the total number of octets received. This "
+ "count includes both good and errored frames." },
+ { "etherStatsPkts",
+ "The total number of good and errored frames received." },
+ { "etherStatsUndersizePkts",
+ "The number of frames received with length less than 64 bytes. "
+ "This count does not include errored frames." },
+ { "etherStatsOversizePkts",
+ "The number of frames received that are longer than the value "
+ "configured in the frm_length register. This count does not "
+ "include errored frames." },
+ { "etherStatsPkts64Octets",
+ "The number of 64-byte frames received. This count includes good "
+ "and errored frames." },
+ { "etherStatsPkts65to127Octets",
+ "The number of received good and errored frames between the length "
+ "of 65 and 127 bytes." },
+ { "etherStatsPkts128to255Octets",
+ "The number of received good and errored frames between the length "
+ "of 128 and 255 bytes." },
+ { "etherStatsPkts256to511Octets",
+ "The number of received good and errored frames between the length "
+ "of 256 and 511 bytes." },
+ { "etherStatsPkts512to1023Octets",
+ "The number of received good and errored frames between the length "
+ "of 512 and 1023 bytes." },
+ { "etherStatsPkts1024to1518Octets",
+ "The number of received good and errored frames between the length "
+ "of 1024 and 1518 bytes." },
+ { "etherStatsPkts1519toXOctets",
+ "The number of received good and errored frames between the length "
+ "of 1519 and the maximum frame length configured in the frm_length "
+ "register." },
+ { "etherStatsJabbers",
+ "Too long frames with CRC error." },
+ { "etherStatsFragments",
+ "Too short frames with CRC error." },
+ /* 0x39 unused, 0x3a/b non-stats. */
+ [0x3c] =
+ /* Extended Statistics Counters */
+ { "msb_aOctetsTransmittedOK",
+ "Upper 32 bits of the number of data and padding octets that are "
+ "successfully transmitted." },
+ { "msb_aOctetsReceivedOK",
+ "Upper 32 bits of the number of data and padding octets that are "
+ "successfully received." },
+ { "msb_etherStatsOctets",
+ "Upper 32 bits of the total number of octets received. This count "
+ "includes both good and errored frames." }
+};
+
+static int
+sysctl_atse_stats_proc(SYSCTL_HANDLER_ARGS)
+{
+ struct atse_softc *sc;
+ int error, offset, s;
+
+ sc = arg1;
+ offset = arg2;
+
+ s = CSR_READ_4(sc, 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)
+{
+ struct sysctl_ctx_list *sctx;
+ struct sysctl_oid *soid;
+ struct atse_softc *sc;
+ int i;
+
+ sc = device_get_softc(dev);
+ 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)
+ 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);
+ }
+}
+
/*
* Generic device handling routines.
*/
@@ -1595,6 +1739,9 @@
if (error != 0)
atse_detach(dev);
+ if (error == 0)
+ atse_sysctl_stats_attach(dev);
+
return (error);
}
More information about the p4-projects
mailing list