From owner-p4-projects@FreeBSD.ORG Wed Feb 13 15:45:17 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 87FE7632; Wed, 13 Feb 2013 15:45:17 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4B361630 for ; Wed, 13 Feb 2013 15:45:17 +0000 (UTC) (envelope-from bz@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:1900:2254:2068::682:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2EBBCA94 for ; Wed, 13 Feb 2013 15:45:17 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.6/8.14.6) with ESMTP id r1DFjHXC058586 for ; Wed, 13 Feb 2013 15:45:17 GMT (envelope-from bz@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.6/8.14.6/Submit) id r1DFjHEl058583 for perforce@freebsd.org; Wed, 13 Feb 2013 15:45:17 GMT (envelope-from bz@freebsd.org) Date: Wed, 13 Feb 2013 15:45:17 GMT Message-Id: <201302131545.r1DFjHEl058583@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to bz@freebsd.org using -f From: "Bjoern A. Zeeb" Subject: PERFORCE change 222004 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2013 15:45:17 -0000 http://p4web.freebsd.org/@@222004?ac=10 Change 222004 by bz@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); }