Module Name: src
Committed By: msaitoh
Date: Fri Jul 22 05:23:50 UTC 2022
Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h
Log Message:
Add more statistics countes.
- Add many statics counters that the chip has.
- Attach event counters only if available.
To generate a diff of this commit:
cvs rdiff -u -r1.745 -r1.746 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/pci/if_wmreg.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.745 src/sys/dev/pci/if_wm.c:1.746
--- src/sys/dev/pci/if_wm.c:1.745 Tue Jul 19 08:22:34 2022
+++ src/sys/dev/pci/if_wm.c Fri Jul 22 05:23:50 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.745 2022/07/19 08:22:34 riastradh Exp $ */
+/* $NetBSD: if_wm.c,v 1.746 2022/07/22 05:23:50 msaitoh Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.745 2022/07/19 08:22:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.746 2022/07/22 05:23:50 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -595,12 +595,76 @@ struct wm_softc {
/* Event counters. */
struct evcnt sc_ev_linkintr; /* Link interrupts */
- /* WM_T_82542_2_1 only */
+ /* >= WM_T_82542_2_1 */
struct evcnt sc_ev_tx_xoff; /* Tx PAUSE(!0) frames */
struct evcnt sc_ev_tx_xon; /* Tx PAUSE(0) frames */
struct evcnt sc_ev_rx_xoff; /* Rx PAUSE(!0) frames */
struct evcnt sc_ev_rx_xon; /* Rx PAUSE(0) frames */
struct evcnt sc_ev_rx_macctl; /* Rx Unsupported */
+
+ struct evcnt sc_ev_crcerrs; /* CRC Error */
+ struct evcnt sc_ev_algnerrc; /* Alignment Error */
+ struct evcnt sc_ev_symerrc; /* Symbol Error */
+ struct evcnt sc_ev_rxerrc; /* Receive Error */
+ struct evcnt sc_ev_mpc; /* Missed Packets */
+ struct evcnt sc_ev_colc; /* Collision */
+ struct evcnt sc_ev_sec; /* Sequence Error */
+ struct evcnt sc_ev_cexterr; /* Carrier Extension Error */
+ struct evcnt sc_ev_rlec; /* Receive Length Error */
+ struct evcnt sc_ev_scc; /* Single Collision */
+ struct evcnt sc_ev_ecol; /* Excessive Collision */
+ struct evcnt sc_ev_mcc; /* Multiple Collision */
+ struct evcnt sc_ev_latecol; /* Late Collision */
+ struct evcnt sc_ev_dc; /* Defer */
+ struct evcnt sc_ev_gprc; /* Good Packets Rx */
+ struct evcnt sc_ev_bprc; /* Broadcast Packets Rx */
+ struct evcnt sc_ev_mprc; /* Multicast Packets Rx */
+ struct evcnt sc_ev_gptc; /* Good Packets Tx */
+ struct evcnt sc_ev_gorc; /* Good Octets Rx */
+ struct evcnt sc_ev_gotc; /* Good Octets Tx */
+ struct evcnt sc_ev_rnbc; /* Rx No Buffers */
+ struct evcnt sc_ev_ruc; /* Rx Undersize */
+ struct evcnt sc_ev_rfc; /* Rx Fragment */
+ struct evcnt sc_ev_roc; /* Rx Oversize */
+ struct evcnt sc_ev_rjc; /* Rx Jabber */
+ struct evcnt sc_ev_tor; /* Total Octets Rx */
+ struct evcnt sc_ev_tot; /* Total Octets Tx */
+ struct evcnt sc_ev_tpr; /* Total Packets Rx */
+ struct evcnt sc_ev_tpt; /* Total Packets Tx */
+ struct evcnt sc_ev_mptc; /* Multicast Packets Tx */
+ struct evcnt sc_ev_bptc; /* Broadcast Packets Tx Count */
+ struct evcnt sc_ev_prc64; /* Packets Rx (64 bytes) */
+ struct evcnt sc_ev_prc127; /* Packets Rx (65-127 bytes) */
+ struct evcnt sc_ev_prc255; /* Packets Rx (128-255 bytes) */
+ struct evcnt sc_ev_prc511; /* Packets Rx (255-511 bytes) */
+ struct evcnt sc_ev_prc1023; /* Packets Rx (512-1023 bytes) */
+ struct evcnt sc_ev_prc1522; /* Packets Rx (1024-1522 bytes) */
+ struct evcnt sc_ev_ptc64; /* Packets Tx (64 bytes) */
+ struct evcnt sc_ev_ptc127; /* Packets Tx (65-127 bytes) */
+ struct evcnt sc_ev_ptc255; /* Packets Tx (128-255 bytes) */
+ struct evcnt sc_ev_ptc511; /* Packets Tx (256-511 bytes) */
+ struct evcnt sc_ev_ptc1023; /* Packets Tx (512-1023 bytes) */
+ struct evcnt sc_ev_ptc1522; /* Packets Tx (1024-1522 Bytes) */
+ struct evcnt sc_ev_iac; /* Interrupt Assertion */
+ struct evcnt sc_ev_icrxptc; /* Intr. Cause Rx Pkt Timer Expire */
+ struct evcnt sc_ev_icrxatc; /* Intr. Cause Rx Abs Timer Expire */
+ struct evcnt sc_ev_ictxptc; /* Intr. Cause Tx Pkt Timer Expire */
+ struct evcnt sc_ev_ictxact; /* Intr. Cause Tx Abs Timer Expire */
+ struct evcnt sc_ev_ictxqec; /* Intr. Cause Tx Queue Empty */
+ struct evcnt sc_ev_ictxqmtc; /* Intr. Cause Tx Queue Min Thresh */
+ struct evcnt sc_ev_icrxdmtc; /* Intr. Cause Rx Desc Min Thresh */
+ struct evcnt sc_ev_icrxoc; /* Intr. Cause Receiver Overrun */
+ struct evcnt sc_ev_tncrs; /* Tx-No CRS */
+ struct evcnt sc_ev_tsctc; /* TCP Segmentation Context Tx */
+ struct evcnt sc_ev_tsctfc; /* TCP Segmentation Context Tx Fail */
+ struct evcnt sc_ev_mgtprc; /* Management Packets RX */
+ struct evcnt sc_ev_mgtpdc; /* Management Packets Dropped */
+ struct evcnt sc_ev_mgtptc; /* Management Packets TX */
+ struct evcnt sc_ev_b2ogprc; /* BMC2OS pkts received by host */
+ struct evcnt sc_ev_o2bspc; /* OS2BMC pkts transmitted by host */
+ struct evcnt sc_ev_b2ospc; /* BMC2OS pkts sent by BMC */
+ struct evcnt sc_ev_o2bgptc; /* OS2BMC pkts received by BMC */
+
#endif /* WM_EVENT_COUNTERS */
struct sysctllog *sc_sysctllog;
@@ -3138,16 +3202,153 @@ alloc_retry:
evcnt_attach_dynamic(&sc->sc_ev_linkintr, EVCNT_TYPE_INTR,
NULL, xname, "linkintr");
- evcnt_attach_dynamic(&sc->sc_ev_tx_xoff, EVCNT_TYPE_MISC,
- NULL, xname, "tx_xoff");
- evcnt_attach_dynamic(&sc->sc_ev_tx_xon, EVCNT_TYPE_MISC,
- NULL, xname, "tx_xon");
- evcnt_attach_dynamic(&sc->sc_ev_rx_xoff, EVCNT_TYPE_MISC,
- NULL, xname, "rx_xoff");
- evcnt_attach_dynamic(&sc->sc_ev_rx_xon, EVCNT_TYPE_MISC,
- NULL, xname, "rx_xon");
- evcnt_attach_dynamic(&sc->sc_ev_rx_macctl, EVCNT_TYPE_MISC,
- NULL, xname, "rx_macctl");
+ if (sc->sc_type >= WM_T_82542_2_1) {
+ evcnt_attach_dynamic(&sc->sc_ev_tx_xoff, EVCNT_TYPE_MISC,
+ NULL, xname, "tx_xoff");
+ evcnt_attach_dynamic(&sc->sc_ev_tx_xon, EVCNT_TYPE_MISC,
+ NULL, xname, "tx_xon");
+ evcnt_attach_dynamic(&sc->sc_ev_rx_xoff, EVCNT_TYPE_MISC,
+ NULL, xname, "rx_xoff");
+ evcnt_attach_dynamic(&sc->sc_ev_rx_xon, EVCNT_TYPE_MISC,
+ NULL, xname, "rx_xon");
+ evcnt_attach_dynamic(&sc->sc_ev_rx_macctl, EVCNT_TYPE_MISC,
+ NULL, xname, "rx_macctl");
+ }
+
+ evcnt_attach_dynamic(&sc->sc_ev_crcerrs, EVCNT_TYPE_MISC,
+ NULL, xname, "CRC Error");
+ evcnt_attach_dynamic(&sc->sc_ev_symerrc, EVCNT_TYPE_MISC,
+ NULL, xname, "Symbol Error");
+
+ if (sc->sc_type >= WM_T_82543) {
+ evcnt_attach_dynamic(&sc->sc_ev_algnerrc, EVCNT_TYPE_MISC,
+ NULL, xname, "Alignment Error");
+ evcnt_attach_dynamic(&sc->sc_ev_rxerrc, EVCNT_TYPE_MISC,
+ NULL, xname, "Receive Error");
+ evcnt_attach_dynamic(&sc->sc_ev_cexterr, EVCNT_TYPE_MISC,
+ NULL, xname, "Carrier Extension Error");
+ }
+
+ evcnt_attach_dynamic(&sc->sc_ev_mpc, EVCNT_TYPE_MISC,
+ NULL, xname, "Missed Packets");
+ evcnt_attach_dynamic(&sc->sc_ev_colc, EVCNT_TYPE_MISC,
+ NULL, xname, "Collision");
+ evcnt_attach_dynamic(&sc->sc_ev_sec, EVCNT_TYPE_MISC,
+ NULL, xname, "Sequence Error");
+ evcnt_attach_dynamic(&sc->sc_ev_rlec, EVCNT_TYPE_MISC,
+ NULL, xname, "Receive Length Error");
+ evcnt_attach_dynamic(&sc->sc_ev_scc, EVCNT_TYPE_MISC,
+ NULL, xname, "Single Collision");
+ evcnt_attach_dynamic(&sc->sc_ev_ecol, EVCNT_TYPE_MISC,
+ NULL, xname, "Excessive Collisions");
+ evcnt_attach_dynamic(&sc->sc_ev_mcc, EVCNT_TYPE_MISC,
+ NULL, xname, "Multiple Collision");
+ evcnt_attach_dynamic(&sc->sc_ev_latecol, EVCNT_TYPE_MISC,
+ NULL, xname, "Late Collisions");
+ evcnt_attach_dynamic(&sc->sc_ev_dc, EVCNT_TYPE_MISC,
+ NULL, xname, "Defer");
+ evcnt_attach_dynamic(&sc->sc_ev_gprc, EVCNT_TYPE_MISC,
+ NULL, xname, "Good Packets Rx");
+ evcnt_attach_dynamic(&sc->sc_ev_bprc, EVCNT_TYPE_MISC,
+ NULL, xname, "Broadcast Packets Rx");
+ evcnt_attach_dynamic(&sc->sc_ev_mprc, EVCNT_TYPE_MISC,
+ NULL, xname, "Multicast Packets Rx");
+ evcnt_attach_dynamic(&sc->sc_ev_gptc, EVCNT_TYPE_MISC,
+ NULL, xname, "Good Packets Tx");
+ evcnt_attach_dynamic(&sc->sc_ev_gorc, EVCNT_TYPE_MISC,
+ NULL, xname, "Good Octets Rx");
+ evcnt_attach_dynamic(&sc->sc_ev_gotc, EVCNT_TYPE_MISC,
+ NULL, xname, "Good Octets Tx");
+ evcnt_attach_dynamic(&sc->sc_ev_rnbc, EVCNT_TYPE_MISC,
+ NULL, xname, "Rx No Buffers");
+ evcnt_attach_dynamic(&sc->sc_ev_ruc, EVCNT_TYPE_MISC,
+ NULL, xname, "Rx Undersize");
+ evcnt_attach_dynamic(&sc->sc_ev_rfc, EVCNT_TYPE_MISC,
+ NULL, xname, "Rx Fragment");
+ evcnt_attach_dynamic(&sc->sc_ev_roc, EVCNT_TYPE_MISC,
+ NULL, xname, "Rx Oversize");
+ evcnt_attach_dynamic(&sc->sc_ev_rjc, EVCNT_TYPE_MISC,
+ NULL, xname, "Rx Jabber");
+ evcnt_attach_dynamic(&sc->sc_ev_tor, EVCNT_TYPE_MISC,
+ NULL, xname, "Total Octets Rx");
+ evcnt_attach_dynamic(&sc->sc_ev_tot, EVCNT_TYPE_MISC,
+ NULL, xname, "Total Octets Tx");
+ evcnt_attach_dynamic(&sc->sc_ev_tpr, EVCNT_TYPE_MISC,
+ NULL, xname, "Total Packets Rx");
+ evcnt_attach_dynamic(&sc->sc_ev_tpt, EVCNT_TYPE_MISC,
+ NULL, xname, "Total Packets Tx");
+ evcnt_attach_dynamic(&sc->sc_ev_mptc, EVCNT_TYPE_MISC,
+ NULL, xname, "Multicast Packets Tx");
+ evcnt_attach_dynamic(&sc->sc_ev_bptc, EVCNT_TYPE_MISC,
+ NULL, xname, "Broadcast Packets Tx Count");
+ evcnt_attach_dynamic(&sc->sc_ev_prc64, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Rx (64 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_prc127, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Rx (65-127 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_prc255, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Rx (128-255 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_prc511, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Rx (255-511 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_prc1023, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Rx (512-1023 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_prc1522, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Rx (1024-1522 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_ptc64, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Tx (64 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_ptc127, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Tx (65-127 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_ptc255, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Tx (128-255 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_ptc511, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Tx (256-511 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_ptc1023, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Tx (512-1023 bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_ptc1522, EVCNT_TYPE_MISC,
+ NULL, xname, "Packets Tx (1024-1522 Bytes)");
+ evcnt_attach_dynamic(&sc->sc_ev_iac, EVCNT_TYPE_MISC,
+ NULL, xname, "Interrupt Assertion");
+ evcnt_attach_dynamic(&sc->sc_ev_icrxptc, EVCNT_TYPE_MISC,
+ NULL, xname, "Intr. Cause Rx Pkt Timer Expire");
+ evcnt_attach_dynamic(&sc->sc_ev_icrxatc, EVCNT_TYPE_MISC,
+ NULL, xname, "Intr. Cause Rx Abs Timer Expire");
+ evcnt_attach_dynamic(&sc->sc_ev_ictxptc, EVCNT_TYPE_MISC,
+ NULL, xname, "Intr. Cause Tx Pkt Timer Expire");
+ evcnt_attach_dynamic(&sc->sc_ev_ictxact, EVCNT_TYPE_MISC,
+ NULL, xname, "Intr. Cause Tx Abs Timer Expire");
+ evcnt_attach_dynamic(&sc->sc_ev_ictxqec, EVCNT_TYPE_MISC,
+ NULL, xname, "Intr. Cause Tx Queue Empty");
+ evcnt_attach_dynamic(&sc->sc_ev_ictxqmtc, EVCNT_TYPE_MISC,
+ NULL, xname, "Intr. Cause Tx Queue Min Thresh");
+ evcnt_attach_dynamic(&sc->sc_ev_icrxdmtc, EVCNT_TYPE_MISC,
+ NULL, xname, "Intr. Cause Rx Desc Min Thresh");
+ evcnt_attach_dynamic(&sc->sc_ev_icrxoc, EVCNT_TYPE_MISC,
+ NULL, xname, "Interrupt Cause Receiver Overrun");
+ if (sc->sc_type >= WM_T_82543) {
+ evcnt_attach_dynamic(&sc->sc_ev_tncrs, EVCNT_TYPE_MISC,
+ NULL, xname, "Tx with No CRS");
+ evcnt_attach_dynamic(&sc->sc_ev_tsctc, EVCNT_TYPE_MISC,
+ NULL, xname, "TCP Segmentation Context Tx");
+ evcnt_attach_dynamic(&sc->sc_ev_tsctfc, EVCNT_TYPE_MISC,
+ NULL, xname, "TCP Segmentation Context Tx Fail");
+ }
+ if (sc->sc_type >= WM_T_82540) {
+ evcnt_attach_dynamic(&sc->sc_ev_mgtprc, EVCNT_TYPE_MISC,
+ NULL, xname, "Management Packets RX");
+ evcnt_attach_dynamic(&sc->sc_ev_mgtpdc, EVCNT_TYPE_MISC,
+ NULL, xname, "Management Packets Dropped");
+ evcnt_attach_dynamic(&sc->sc_ev_mgtptc, EVCNT_TYPE_MISC,
+ NULL, xname, "Management Packets TX");
+ }
+ if ((sc->sc_type >= WM_T_I350) && (sc->sc_type < WM_T_80003)) {
+ evcnt_attach_dynamic(&sc->sc_ev_b2ogprc, EVCNT_TYPE_MISC,
+ NULL, xname, "BMC2OS Packets received by host");
+ evcnt_attach_dynamic(&sc->sc_ev_o2bspc, EVCNT_TYPE_MISC,
+ NULL, xname, "OS2BMC Packets transmitted by host");
+ evcnt_attach_dynamic(&sc->sc_ev_b2ospc, EVCNT_TYPE_MISC,
+ NULL, xname, "BMC2OS Packets sent by BMC");
+ evcnt_attach_dynamic(&sc->sc_ev_o2bgptc, EVCNT_TYPE_MISC,
+ NULL, xname, "OS2BMC Packets received by BMC");
+ }
#endif /* WM_EVENT_COUNTERS */
sc->sc_txrx_use_workqueue = false;
@@ -3192,11 +3393,85 @@ wm_detach(device_t self, int flags __unu
#ifdef WM_EVENT_COUNTERS
evcnt_detach(&sc->sc_ev_linkintr);
- evcnt_detach(&sc->sc_ev_tx_xoff);
- evcnt_detach(&sc->sc_ev_tx_xon);
- evcnt_detach(&sc->sc_ev_rx_xoff);
- evcnt_detach(&sc->sc_ev_rx_xon);
- evcnt_detach(&sc->sc_ev_rx_macctl);
+ if (sc->sc_type >= WM_T_82542_2_1) {
+ evcnt_detach(&sc->sc_ev_tx_xoff);
+ evcnt_detach(&sc->sc_ev_tx_xon);
+ evcnt_detach(&sc->sc_ev_rx_xoff);
+ evcnt_detach(&sc->sc_ev_rx_xon);
+ evcnt_detach(&sc->sc_ev_rx_macctl);
+ }
+
+ evcnt_detach(&sc->sc_ev_crcerrs);
+ evcnt_detach(&sc->sc_ev_symerrc);
+
+ if (sc->sc_type >= WM_T_82543) {
+ evcnt_detach(&sc->sc_ev_algnerrc);
+ evcnt_detach(&sc->sc_ev_rxerrc);
+ evcnt_detach(&sc->sc_ev_cexterr);
+ }
+ evcnt_detach(&sc->sc_ev_mpc);
+ evcnt_detach(&sc->sc_ev_colc);
+ evcnt_detach(&sc->sc_ev_sec);
+ evcnt_detach(&sc->sc_ev_rlec);
+ evcnt_detach(&sc->sc_ev_scc);
+ evcnt_detach(&sc->sc_ev_ecol);
+ evcnt_detach(&sc->sc_ev_mcc);
+ evcnt_detach(&sc->sc_ev_latecol);
+ evcnt_detach(&sc->sc_ev_dc);
+ evcnt_detach(&sc->sc_ev_gprc);
+ evcnt_detach(&sc->sc_ev_bprc);
+ evcnt_detach(&sc->sc_ev_mprc);
+ evcnt_detach(&sc->sc_ev_gptc);
+ evcnt_detach(&sc->sc_ev_gorc);
+ evcnt_detach(&sc->sc_ev_gotc);
+ evcnt_detach(&sc->sc_ev_rnbc);
+ evcnt_detach(&sc->sc_ev_ruc);
+ evcnt_detach(&sc->sc_ev_rfc);
+ evcnt_detach(&sc->sc_ev_roc);
+ evcnt_detach(&sc->sc_ev_rjc);
+ evcnt_detach(&sc->sc_ev_tor);
+ evcnt_detach(&sc->sc_ev_tot);
+ evcnt_detach(&sc->sc_ev_tpr);
+ evcnt_detach(&sc->sc_ev_tpt);
+ evcnt_detach(&sc->sc_ev_mptc);
+ evcnt_detach(&sc->sc_ev_bptc);
+ evcnt_detach(&sc->sc_ev_prc64);
+ evcnt_detach(&sc->sc_ev_prc127);
+ evcnt_detach(&sc->sc_ev_prc255);
+ evcnt_detach(&sc->sc_ev_prc511);
+ evcnt_detach(&sc->sc_ev_prc1023);
+ evcnt_detach(&sc->sc_ev_prc1522);
+ evcnt_detach(&sc->sc_ev_ptc64);
+ evcnt_detach(&sc->sc_ev_ptc127);
+ evcnt_detach(&sc->sc_ev_ptc255);
+ evcnt_detach(&sc->sc_ev_ptc511);
+ evcnt_detach(&sc->sc_ev_ptc1023);
+ evcnt_detach(&sc->sc_ev_ptc1522);
+ evcnt_detach(&sc->sc_ev_iac);
+ evcnt_detach(&sc->sc_ev_icrxptc);
+ evcnt_detach(&sc->sc_ev_icrxatc);
+ evcnt_detach(&sc->sc_ev_ictxptc);
+ evcnt_detach(&sc->sc_ev_ictxact);
+ evcnt_detach(&sc->sc_ev_ictxqec);
+ evcnt_detach(&sc->sc_ev_ictxqmtc);
+ evcnt_detach(&sc->sc_ev_icrxdmtc);
+ evcnt_detach(&sc->sc_ev_icrxoc);
+ if (sc->sc_type >= WM_T_82543) {
+ evcnt_detach(&sc->sc_ev_tncrs);
+ evcnt_detach(&sc->sc_ev_tsctc);
+ evcnt_detach(&sc->sc_ev_tsctfc);
+ }
+ if (sc->sc_type >= WM_T_82540) {
+ evcnt_detach(&sc->sc_ev_mgtprc);
+ evcnt_detach(&sc->sc_ev_mgtpdc);
+ evcnt_detach(&sc->sc_ev_mgtptc);
+ }
+ if ((sc->sc_type >= WM_T_I350) && (sc->sc_type < WM_T_80003)) {
+ evcnt_detach(&sc->sc_ev_b2ogprc);
+ evcnt_detach(&sc->sc_ev_o2bspc);
+ evcnt_detach(&sc->sc_ev_b2ospc);
+ evcnt_detach(&sc->sc_ev_o2bgptc);
+ }
#endif /* WM_EVENT_COUNTERS */
rnd_detach_source(&sc->rnd_source);
@@ -3435,6 +3710,8 @@ wm_tick(void *arg)
{
struct wm_softc *sc = arg;
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+ uint64_t crcerrs, algnerrc, symerrc, mpc, colc, sec, rlec, rxerrc,
+ cexterr;
#ifndef WM_MPSAFE
int s = splnet();
#endif
@@ -3449,6 +3726,20 @@ wm_tick(void *arg)
return;
}
+ crcerrs = CSR_READ(sc, WMREG_CRCERRS);
+ symerrc = CSR_READ(sc, WMREG_SYMERRC);
+ mpc = CSR_READ(sc, WMREG_MPC);
+ colc = CSR_READ(sc, WMREG_COLC);
+ sec = CSR_READ(sc, WMREG_SEC);
+ rlec = CSR_READ(sc, WMREG_RLEC);
+
+ WM_EVCNT_ADD(&sc->sc_ev_crcerrs, crcerrs);
+ WM_EVCNT_ADD(&sc->sc_ev_symerrc, symerrc);
+ WM_EVCNT_ADD(&sc->sc_ev_mpc, mpc);
+ WM_EVCNT_ADD(&sc->sc_ev_colc, colc);
+ WM_EVCNT_ADD(&sc->sc_ev_sec, sec);
+ WM_EVCNT_ADD(&sc->sc_ev_rlec, rlec);
+
if (sc->sc_type >= WM_T_82542_2_1) {
WM_EVCNT_ADD(&sc->sc_ev_rx_xon, CSR_READ(sc, WMREG_XONRXC));
WM_EVCNT_ADD(&sc->sc_ev_tx_xon, CSR_READ(sc, WMREG_XONTXC));
@@ -3456,17 +3747,88 @@ wm_tick(void *arg)
WM_EVCNT_ADD(&sc->sc_ev_tx_xoff, CSR_READ(sc, WMREG_XOFFTXC));
WM_EVCNT_ADD(&sc->sc_ev_rx_macctl, CSR_READ(sc, WMREG_FCRUC));
}
+ WM_EVCNT_ADD(&sc->sc_ev_scc, CSR_READ(sc, WMREG_SCC));
+ WM_EVCNT_ADD(&sc->sc_ev_ecol, CSR_READ(sc, WMREG_ECOL));
+ WM_EVCNT_ADD(&sc->sc_ev_mcc, CSR_READ(sc, WMREG_MCC));
+ WM_EVCNT_ADD(&sc->sc_ev_latecol, CSR_READ(sc, WMREG_LATECOL));
+ WM_EVCNT_ADD(&sc->sc_ev_dc, CSR_READ(sc, WMREG_DC));
+ WM_EVCNT_ADD(&sc->sc_ev_gprc, CSR_READ(sc, WMREG_GPRC));
+ WM_EVCNT_ADD(&sc->sc_ev_bprc, CSR_READ(sc, WMREG_BPRC));
+ WM_EVCNT_ADD(&sc->sc_ev_mprc, CSR_READ(sc, WMREG_MPRC));
+ WM_EVCNT_ADD(&sc->sc_ev_gptc, CSR_READ(sc, WMREG_GPTC));
+
+ WM_EVCNT_ADD(&sc->sc_ev_gorc,
+ CSR_READ(sc, WMREG_GORCL) + CSR_READ(sc, WMREG_GORCH));
+ WM_EVCNT_ADD(&sc->sc_ev_gotc,
+ CSR_READ(sc, WMREG_GOTCL) + CSR_READ(sc, WMREG_GOTCH));
+
+ WM_EVCNT_ADD(&sc->sc_ev_rnbc, CSR_READ(sc, WMREG_RNBC));
+ WM_EVCNT_ADD(&sc->sc_ev_ruc, CSR_READ(sc, WMREG_RUC));
+ WM_EVCNT_ADD(&sc->sc_ev_rfc, CSR_READ(sc, WMREG_RFC));
+ WM_EVCNT_ADD(&sc->sc_ev_roc, CSR_READ(sc, WMREG_ROC));
+ WM_EVCNT_ADD(&sc->sc_ev_rjc, CSR_READ(sc, WMREG_RJC));
+
+ WM_EVCNT_ADD(&sc->sc_ev_tor,
+ CSR_READ(sc, WMREG_TORL) + CSR_READ(sc, WMREG_TORH));
+ WM_EVCNT_ADD(&sc->sc_ev_tot,
+ CSR_READ(sc, WMREG_TOTL) + CSR_READ(sc, WMREG_TOTH));
+
+ WM_EVCNT_ADD(&sc->sc_ev_tpr, CSR_READ(sc, WMREG_TPR));
+ WM_EVCNT_ADD(&sc->sc_ev_tpt, CSR_READ(sc, WMREG_TPT));
+ WM_EVCNT_ADD(&sc->sc_ev_mptc, CSR_READ(sc, WMREG_MPTC));
+ WM_EVCNT_ADD(&sc->sc_ev_bptc, CSR_READ(sc, WMREG_BPTC));
+ WM_EVCNT_ADD(&sc->sc_ev_prc64, CSR_READ(sc, WMREG_PRC64));
+ WM_EVCNT_ADD(&sc->sc_ev_prc127, CSR_READ(sc, WMREG_PRC127));
+ WM_EVCNT_ADD(&sc->sc_ev_prc255, CSR_READ(sc, WMREG_PRC255));
+ WM_EVCNT_ADD(&sc->sc_ev_prc511, CSR_READ(sc, WMREG_PRC511));
+ WM_EVCNT_ADD(&sc->sc_ev_prc1023, CSR_READ(sc, WMREG_PRC1023));
+ WM_EVCNT_ADD(&sc->sc_ev_prc1522, CSR_READ(sc, WMREG_PRC1522));
+ WM_EVCNT_ADD(&sc->sc_ev_ptc64, CSR_READ(sc, WMREG_PTC64));
+ WM_EVCNT_ADD(&sc->sc_ev_ptc127, CSR_READ(sc, WMREG_PTC127));
+ WM_EVCNT_ADD(&sc->sc_ev_ptc255, CSR_READ(sc, WMREG_PTC255));
+ WM_EVCNT_ADD(&sc->sc_ev_ptc511, CSR_READ(sc, WMREG_PTC511));
+ WM_EVCNT_ADD(&sc->sc_ev_ptc1023, CSR_READ(sc, WMREG_PTC1023));
+ WM_EVCNT_ADD(&sc->sc_ev_ptc1522, CSR_READ(sc, WMREG_PTC1522));
+ WM_EVCNT_ADD(&sc->sc_ev_iac, CSR_READ(sc, WMREG_IAC));
+ WM_EVCNT_ADD(&sc->sc_ev_icrxptc, CSR_READ(sc, WMREG_ICRXPTC));
+ WM_EVCNT_ADD(&sc->sc_ev_icrxatc, CSR_READ(sc, WMREG_ICRXATC));
+ WM_EVCNT_ADD(&sc->sc_ev_ictxptc, CSR_READ(sc, WMREG_ICTXPTC));
+ WM_EVCNT_ADD(&sc->sc_ev_ictxact, CSR_READ(sc, WMREG_ICTXATC));
+ WM_EVCNT_ADD(&sc->sc_ev_ictxqec, CSR_READ(sc, WMREG_ICTXQEC));
+ WM_EVCNT_ADD(&sc->sc_ev_ictxqmtc, CSR_READ(sc, WMREG_ICTXQMTC));
+ WM_EVCNT_ADD(&sc->sc_ev_icrxdmtc, CSR_READ(sc, WMREG_ICRXDMTC));
+ WM_EVCNT_ADD(&sc->sc_ev_icrxoc, CSR_READ(sc, WMREG_ICRXOC));
+ if (sc->sc_type >= WM_T_82543) {
+ algnerrc = CSR_READ(sc, WMREG_ALGNERRC);
+ rxerrc = CSR_READ(sc, WMREG_RXERRC);
+ cexterr = CSR_READ(sc, WMREG_CEXTERR);
+ WM_EVCNT_ADD(&sc->sc_ev_algnerrc, algnerrc);
+ WM_EVCNT_ADD(&sc->sc_ev_rxerrc, rxerrc);
+ WM_EVCNT_ADD(&sc->sc_ev_cexterr, cexterr);
+
+ WM_EVCNT_ADD(&sc->sc_ev_tncrs, CSR_READ(sc, WMREG_TNCRS));
+ WM_EVCNT_ADD(&sc->sc_ev_tsctc, CSR_READ(sc, WMREG_TSCTC));
+ WM_EVCNT_ADD(&sc->sc_ev_tsctfc, CSR_READ(sc, WMREG_TSCTFC));
+ } else
+ algnerrc = rxerrc = cexterr = 0;
+
+ if (sc->sc_type >= WM_T_82540) {
+ WM_EVCNT_ADD(&sc->sc_ev_mgtprc, CSR_READ(sc, WMREG_MGTPRC));
+ WM_EVCNT_ADD(&sc->sc_ev_mgtpdc, CSR_READ(sc, WMREG_MGTPDC));
+ WM_EVCNT_ADD(&sc->sc_ev_mgtptc, CSR_READ(sc, WMREG_MGTPTC));
+ }
+ if (((sc->sc_type >= WM_T_I350) && (sc->sc_type < WM_T_80003))
+ && ((CSR_READ(sc, WMREG_MANC) & MANC_EN_BMC2OS) != 0)) {
+ WM_EVCNT_ADD(&sc->sc_ev_b2ogprc, CSR_READ(sc, WMREG_B2OGPRC));
+ WM_EVCNT_ADD(&sc->sc_ev_o2bspc, CSR_READ(sc, WMREG_O2BSPC));
+ WM_EVCNT_ADD(&sc->sc_ev_b2ospc, CSR_READ(sc, WMREG_B2OSPC));
+ WM_EVCNT_ADD(&sc->sc_ev_o2bgptc, CSR_READ(sc, WMREG_O2BGPTC));
+ }
net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
- if_statadd_ref(nsr, if_collisions, CSR_READ(sc, WMREG_COLC));
- if_statadd_ref(nsr, if_ierrors, 0ULL /* ensure quad_t */
- + CSR_READ(sc, WMREG_CRCERRS)
- + CSR_READ(sc, WMREG_ALGNERRC)
- + CSR_READ(sc, WMREG_SYMERRC)
- + CSR_READ(sc, WMREG_RXERRC)
- + CSR_READ(sc, WMREG_SEC)
- + CSR_READ(sc, WMREG_CEXTERR)
- + CSR_READ(sc, WMREG_RLEC));
+ if_statadd_ref(nsr, if_collisions, colc);
+ if_statadd_ref(nsr, if_ierrors,
+ crcerrs + algnerrc + symerrc + rxerrc + sec + cexterr + rlec);
/*
* WMREG_RNBC is incremented when there are no available buffers in host
* memory. It does not mean the number of dropped packets, because an
@@ -3476,7 +3838,7 @@ wm_tick(void *arg)
* If you want to know the nubmer of WMREG_RMBC, you should use such as
* own EVCNT instead of if_iqdrops.
*/
- if_statadd_ref(nsr, if_iqdrops, CSR_READ(sc, WMREG_MPC));
+ if_statadd_ref(nsr, if_iqdrops, mpc);
IF_STAT_PUTREF(ifp);
if (sc->sc_flags & WM_F_HAS_MII)
Index: src/sys/dev/pci/if_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.126 src/sys/dev/pci/if_wmreg.h:1.127
--- src/sys/dev/pci/if_wmreg.h:1.126 Wed Jul 20 06:43:37 2022
+++ src/sys/dev/pci/if_wmreg.h Fri Jul 22 05:23:50 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wmreg.h,v 1.126 2022/07/20 06:43:37 msaitoh Exp $ */
+/* $NetBSD: if_wmreg.h,v 1.127 2022/07/22 05:23:50 msaitoh Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -1147,7 +1147,13 @@ struct livengood_tcpip_ctxdesc {
#define WMREG_SYMERRC 0x4008 /* Symbol Error Count */
#define WMREG_RXERRC 0x400c /* Receive error Count - R/clr */
#define WMREG_MPC 0x4010 /* Missed Packets Count - R/clr */
+#define WMREG_SCC 0x4014 /* Single Collision Count - R/clr */
+#define WMREG_ECOL 0x4018 /* Excessive Collisions Count - R/clr */
+#define WMREG_MCC 0x401c /* Multiple Collision Count - R/clr */
+#define WMREG_LATECOL 0x4020 /* Late Collisions Count - R/clr */
#define WMREG_COLC 0x4028 /* Collision Count - R/clr */
+#define WMREG_DC 0x4030 /* Defer Count - R/clr */
+#define WMREG_TNCRS 0x4034 /* Tx with No CRS - R/clr */
#define WMREG_SEC 0x4038 /* Sequence Error Count */
#define WMREG_CEXTERR 0x403c /* Carrier Extension Error Count */
#define WMREG_RLEC 0x4040 /* Receive Length Error Count */
@@ -1156,9 +1162,57 @@ struct livengood_tcpip_ctxdesc {
#define WMREG_XOFFRXC 0x4050 /* XOFF Rx Count - R/clr */
#define WMREG_XOFFTXC 0x4054 /* XOFF Tx Count - R/clr */
#define WMREG_FCRUC 0x4058 /* Flow Control Rx Unsupported Count - R/clr */
+#define WMREG_PRC64 0x405c /* Packets Rx (64 bytes) - R/clr */
+#define WMREG_PRC127 0x4060 /* Packets Rx (65-127 bytes) - R/clr */
+#define WMREG_PRC255 0x4064 /* Packets Rx (128-255 bytes) - R/clr */
+#define WMREG_PRC511 0x4068 /* Packets Rx (255-511 bytes) - R/clr */
+#define WMREG_PRC1023 0x406c /* Packets Rx (512-1023 bytes) - R/clr */
+#define WMREG_PRC1522 0x4070 /* Packets Rx (1024-1522 bytes) - R/clr */
+#define WMREG_GPRC 0x4074 /* Good Packets Rx Count - R/clr */
+#define WMREG_BPRC 0x4078 /* Broadcast Packets Rx Count - R/clr */
+#define WMREG_MPRC 0x407c /* Multicast Packets Rx Count - R/clr */
+#define WMREG_GPTC 0x4080 /* Good Packets Tx Count - R/clr */
+#define WMREG_GORCL 0x4088 /* Good Octets Rx Count Low - R/clr */
+#define WMREG_GORCH 0x408c /* Good Octets Rx Count High - R/clr */
+#define WMREG_GOTCL 0x4090 /* Good Octets Tx Count Low - R/clr */
+#define WMREG_GOTCH 0x4094 /* Good Octets Tx Count High - R/clr */
#define WMREG_RNBC 0x40a0 /* Receive No Buffers Count */
+#define WMREG_RUC 0x40a4 /* Rx Undersize Count - R/clr */
+#define WMREG_RFC 0x40a8 /* Rx Fragment Count - R/clr */
+#define WMREG_ROC 0x40ac /* Rx Oversize Count - R/clr */
+#define WMREG_RJC 0x40b0 /* Rx Jabber Count - R/clr */
+#define WMREG_MGTPRC 0x40b4 /* Management Packets RX Count - R/clr */
+#define WMREG_MGTPDC 0x40b8 /* Management Packets Dropped Count - R/clr */
+#define WMREG_MGTPTC 0x40bc /* Management Packets TX Count - R/clr */
+#define WMREG_TORL 0x40c0 /* Total Octets Rx Low - R/clr */
+#define WMREG_TORH 0x40c4 /* Total Octets Rx High - R/clr */
+#define WMREG_TOTL 0x40c8 /* Total Octets Tx Low - R/clr */
+#define WMREG_TOTH 0x40cc /* Total Octets Tx High - R/clr */
+#define WMREG_TPR 0x40d0 /* Total Packets Rx - R/clr */
+#define WMREG_TPT 0x40d4 /* Total Packets Tx - R/clr */
+#define WMREG_PTC64 0x40d8 /* Packets Tx (64 bytes) - R/clr */
+#define WMREG_PTC127 0x40dc /* Packets Tx (65-127 bytes) - R/clr */
+#define WMREG_PTC255 0x40e0 /* Packets Tx (128-255 bytes) - R/clr */
+#define WMREG_PTC511 0x40e4 /* Packets Tx (256-511 bytes) - R/clr */
+#define WMREG_PTC1023 0x40e8 /* Packets Tx (512-1023 bytes) - R/clr */
+#define WMREG_PTC1522 0x40ec /* Packets Tx (1024-1522 Bytes) - R/clr */
+#define WMREG_MPTC 0x40f0 /* Multicast Packets Tx Count - R/clr */
+#define WMREG_BPTC 0x40f4 /* Broadcast Packets Tx Count */
+#define WMREG_TSCTC 0x40f8 /* TCP Segmentation Context Tx */
+#define WMREG_TSCTFC 0x40fc /* TCP Segmentation Context Tx Fail */
+#define WMREG_IAC 0x4100 /* Interrupt Assertion Count */
+#define WMREG_ICRXPTC 0x4104 /* Interrupt Cause Rx Pkt Timer Expire Count */
+#define WMREG_ICRXATC 0x4108 /* Interrupt Cause Rx Abs Timer Expire Count */
+#define WMREG_ICTXPTC 0x410c /* Interrupt Cause Tx Pkt Timer Expire Count */
+#define WMREG_ICTXATC 0x4110 /* Interrupt Cause Tx Abs Timer Expire Count */
+#define WMREG_ICTXQEC 0x4118 /* Interrupt Cause Tx Queue Empty Count */
+#define WMREG_ICTXQMTC 0x411c /* Interrupt Cause Tx Queue Min Thresh Count */
+#define WMREG_ICRXDMTC 0x4120 /* Interrupt Cause Rx Desc Min Thresh Count */
+#define WMREG_ICRXOC 0x4124 /* Interrupt Cause Receiver Overrun Count */
#define WMREG_TLPIC 0x4148 /* EEE Tx LPI Count */
#define WMREG_RLPIC 0x414c /* EEE Rx LPI Count */
+#define WMREG_B2OGPRC 0x4158 /* BMC2OS packets received by host */
+#define WMREG_O2BSPC 0x415c /* OS2BMC packets transmitted by host */
#define WMREG_PCS_CFG 0x4200 /* PCS Configuration */
#define PCS_CFG_PCS_EN __BIT(3)
@@ -1311,6 +1365,7 @@ struct livengood_tcpip_ctxdesc {
#define MANC_RECV_ALL __BIT(19)
#define MANC_EN_MAC_ADDR_FILTER __BIT(20)
#define MANC_EN_MNG2HOST __BIT(21)
+#define MANC_EN_BMC2OS __BIT(28)
#define WMREG_MANC2H 0x5860 /* Management Control To Host - RW */
#define MANC2H_PORT_623 (1 << 5)
@@ -1387,6 +1442,9 @@ struct livengood_tcpip_ctxdesc {
#define WMREG_CRC_OFFSET 0x5f50
#define WMREG_PCH_RAICC(x) (WMREG_CRC_OFFSET + (x) * 4)
+#define WMREG_B2OSPC 0x8fe0 /* BMC2OS packets sent by BMC */
+#define WMREG_O2BGPTC 0x8fe4 /* OS2BMC packets received by BMC */
+
#define WMREG_EEC 0x12010
#define EEC_FLASH_DETECTED __BIT(19) /* FLASH */
#define EEC_FLUPD __BIT(23) /* Update FLASH */