Module Name: src Committed By: martin Date: Sun Oct 8 15:31:18 UTC 2023
Modified Files: src/sys/dev/pci [netbsd-8]: if_wm.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #1910): sys/dev/pci/if_wm.c: revision 1.785 sys/dev/pci/if_wm.c: revision 1.786 sys/dev/pci/if_wm.c: revision 1.787 sys/dev/pci/if_wm.c: revision 1.788 sys/dev/pci/if_wm.c: revision 1.789 wm(4): Use SCVPC and HRMPC for 82575 and newer. The SCVPC(SerDes/SGMII Code Violation Packet Count) register and the HRMPC (Header Redirection Missed Packet Count) register were added in if_wm.c rev. 1.776 but the location in the code were incorrect. Fix them. wm(4): Add some info to some event counters. - The difference between the RUC(Rx Undersize) and RFC(Rx Fragment) is whether the CRC is valid or not. - The difference between the ROC(Rx Oversize) and RJC(Rx Jabber) is whether the CRC is valid or not. - LENERRS(Length Errors) is for the length/type field <= 1500. wm(4): the IAC(Interrupt Assertion Count) register is for 82571 and newer. wm(4): Modify descriptions of flow control related event counters. wm(4): Replace /* nothing */ to __nothing for evcnt macros Prevent empty if bodies for !WM_EVENT_COUNTERS. To generate a diff of this commit: cvs rdiff -u -r1.508.4.51 -r1.508.4.52 src/sys/dev/pci/if_wm.c 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.508.4.51 src/sys/dev/pci/if_wm.c:1.508.4.52 --- src/sys/dev/pci/if_wm.c:1.508.4.51 Mon Sep 4 17:57:49 2023 +++ src/sys/dev/pci/if_wm.c Sun Oct 8 15:31:17 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.508.4.51 2023/09/04 17:57:49 martin Exp $ */ +/* $NetBSD: if_wm.c,v 1.508.4.52 2023/10/08 15:31:17 martin 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.508.4.51 2023/09/04 17:57:49 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.52 2023/10/08 15:31:17 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -770,13 +770,13 @@ do { \ #define WM_Q_EVCNT_ADD(qname, evname, val) \ WM_EVCNT_ADD(&(qname)->qname##_ev_##evname, (val)) #else /* !WM_EVENT_COUNTERS */ -#define WM_EVCNT_INCR(ev) /* nothing */ -#define WM_EVCNT_STORE(ev, val) /* nothing */ -#define WM_EVCNT_ADD(ev, val) /* nothing */ - -#define WM_Q_EVCNT_INCR(qname, evname) /* nothing */ -#define WM_Q_EVCNT_STORE(qname, evname, val) /* nothing */ -#define WM_Q_EVCNT_ADD(qname, evname, val) /* nothing */ +#define WM_EVCNT_INCR(ev) __nothing +#define WM_EVCNT_STORE(ev, val) __nothing +#define WM_EVCNT_ADD(ev, val) __nothing + +#define WM_Q_EVCNT_INCR(qname, evname) __nothing +#define WM_Q_EVCNT_STORE(qname, evname, val) __nothing +#define WM_Q_EVCNT_ADD(qname, evname, val) __nothing #endif /* !WM_EVENT_COUNTERS */ #define CSR_READ(sc, reg) \ @@ -3274,15 +3274,15 @@ alloc_retry: if (sc->sc_type >= WM_T_82542_2_1) { evcnt_attach_dynamic(&sc->sc_ev_tx_xoff, EVCNT_TYPE_MISC, - NULL, xname, "tx_xoff"); + NULL, xname, "XOFF Transmitted"); evcnt_attach_dynamic(&sc->sc_ev_tx_xon, EVCNT_TYPE_MISC, - NULL, xname, "tx_xon"); + NULL, xname, "XON Transmitted"); evcnt_attach_dynamic(&sc->sc_ev_rx_xoff, EVCNT_TYPE_MISC, - NULL, xname, "rx_xoff"); + NULL, xname, "XOFF Received"); evcnt_attach_dynamic(&sc->sc_ev_rx_xon, EVCNT_TYPE_MISC, - NULL, xname, "rx_xon"); + NULL, xname, "XON Received"); evcnt_attach_dynamic(&sc->sc_ev_rx_macctl, EVCNT_TYPE_MISC, - NULL, xname, "rx_macctl"); + NULL, xname, "FC Received Unsupported"); } evcnt_attach_dynamic(&sc->sc_ev_scc, EVCNT_TYPE_MISC, @@ -3327,13 +3327,13 @@ alloc_retry: 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"); + NULL, xname, "Rx Undersize (valid CRC)"); evcnt_attach_dynamic(&sc->sc_ev_rfc, EVCNT_TYPE_MISC, - NULL, xname, "Rx Fragment"); + NULL, xname, "Rx Fragment (bad CRC)"); evcnt_attach_dynamic(&sc->sc_ev_roc, EVCNT_TYPE_MISC, - NULL, xname, "Rx Oversize"); + NULL, xname, "Rx Oversize (valid CRC)"); evcnt_attach_dynamic(&sc->sc_ev_rjc, EVCNT_TYPE_MISC, - NULL, xname, "Rx Jabber"); + NULL, xname, "Rx Jabber (bad CRC)"); if (sc->sc_type >= WM_T_82540) { evcnt_attach_dynamic(&sc->sc_ev_mgtprc, EVCNT_TYPE_MISC, NULL, xname, "Management Packets RX"); @@ -3366,8 +3366,9 @@ alloc_retry: NULL, xname, "Multicast Packets Tx"); evcnt_attach_dynamic(&sc->sc_ev_bptc, EVCNT_TYPE_MISC, NULL, xname, "Broadcast Packets Tx"); - evcnt_attach_dynamic(&sc->sc_ev_iac, EVCNT_TYPE_MISC, - NULL, xname, "Interrupt Assertion"); + if (sc->sc_type >= WM_T_82571) /* PCIe, 80003 and ICH/PCHs */ + evcnt_attach_dynamic(&sc->sc_ev_iac, EVCNT_TYPE_MISC, + NULL, xname, "Interrupt Assertion"); if (sc->sc_type < WM_T_82575) { evcnt_attach_dynamic(&sc->sc_ev_icrxptc, EVCNT_TYPE_MISC, NULL, xname, "Intr. Cause Rx Pkt Timer Expire"); @@ -3426,7 +3427,11 @@ alloc_retry: evcnt_attach_dynamic(&sc->sc_ev_hgotc, EVCNT_TYPE_MISC, NULL, xname, "Host Good Octets Tx"); evcnt_attach_dynamic(&sc->sc_ev_lenerrs, EVCNT_TYPE_MISC, - NULL, xname, "Length Errors"); + NULL, xname, "Length Errors (length/type <= 1500)"); + evcnt_attach_dynamic(&sc->sc_ev_scvpc, EVCNT_TYPE_MISC, + NULL, xname, "SerDes/SGMII Code Violation Packet"); + evcnt_attach_dynamic(&sc->sc_ev_hrmpc, EVCNT_TYPE_MISC, + NULL, xname, "Header Redirection Missed Packet"); } if ((sc->sc_type >= WM_T_I350) && !WM_IS_ICHPCH(sc)) { evcnt_attach_dynamic(&sc->sc_ev_tlpic, EVCNT_TYPE_MISC, @@ -3441,10 +3446,6 @@ alloc_retry: NULL, xname, "BMC2OS Packets sent by BMC"); evcnt_attach_dynamic(&sc->sc_ev_o2bgptc, EVCNT_TYPE_MISC, NULL, xname, "OS2BMC Packets received by BMC"); - evcnt_attach_dynamic(&sc->sc_ev_scvpc, EVCNT_TYPE_MISC, - NULL, xname, "SerDes/SGMII Code Violation Packet"); - evcnt_attach_dynamic(&sc->sc_ev_hrmpc, EVCNT_TYPE_MISC, - NULL, xname, "Header Redirection Missed Packet"); } #endif /* WM_EVENT_COUNTERS */ @@ -3566,7 +3567,8 @@ wm_detach(device_t self, int flags __unu evcnt_detach(&sc->sc_ev_ptc1522); evcnt_detach(&sc->sc_ev_mptc); evcnt_detach(&sc->sc_ev_bptc); - evcnt_detach(&sc->sc_ev_iac); + if (sc->sc_type >= WM_T_82571) + evcnt_detach(&sc->sc_ev_iac); if (sc->sc_type < WM_T_82575) { evcnt_detach(&sc->sc_ev_icrxptc); evcnt_detach(&sc->sc_ev_icrxatc); @@ -3589,6 +3591,8 @@ wm_detach(device_t self, int flags __unu evcnt_detach(&sc->sc_ev_hgorc); evcnt_detach(&sc->sc_ev_hgotc); evcnt_detach(&sc->sc_ev_lenerrs); + evcnt_detach(&sc->sc_ev_scvpc); + evcnt_detach(&sc->sc_ev_hrmpc); } if ((sc->sc_type >= WM_T_I350) && !WM_IS_ICHPCH(sc)) { evcnt_detach(&sc->sc_ev_tlpic); @@ -3597,8 +3601,6 @@ wm_detach(device_t self, int flags __unu evcnt_detach(&sc->sc_ev_o2bspc); evcnt_detach(&sc->sc_ev_b2ospc); evcnt_detach(&sc->sc_ev_o2bgptc); - evcnt_detach(&sc->sc_ev_scvpc); - evcnt_detach(&sc->sc_ev_hrmpc); } #endif /* WM_EVENT_COUNTERS */ @@ -6596,7 +6598,8 @@ wm_update_stats(struct wm_softc *sc) WM_EVCNT_ADD(&sc->sc_ev_ptc1522, CSR_READ(sc, WMREG_PTC1522)); 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_iac, CSR_READ(sc, WMREG_IAC)); + if (sc->sc_type >= WM_T_82571) + WM_EVCNT_ADD(&sc->sc_ev_iac, CSR_READ(sc, WMREG_IAC)); if (sc->sc_type < WM_T_82575) { WM_EVCNT_ADD(&sc->sc_ev_icrxptc, CSR_READ(sc, WMREG_ICRXPTC)); WM_EVCNT_ADD(&sc->sc_ev_icrxatc, CSR_READ(sc, WMREG_ICRXATC)); @@ -6625,6 +6628,8 @@ wm_update_stats(struct wm_softc *sc) CSR_READ(sc, WMREG_HGOTCL) + ((uint64_t)CSR_READ(sc, WMREG_HGOTCH) << 32)); WM_EVCNT_ADD(&sc->sc_ev_lenerrs, CSR_READ(sc, WMREG_LENERRS)); + WM_EVCNT_ADD(&sc->sc_ev_scvpc, CSR_READ(sc, WMREG_SCVPC)); + WM_EVCNT_ADD(&sc->sc_ev_hrmpc, CSR_READ(sc, WMREG_HRMPC)); } if ((sc->sc_type >= WM_T_I350) && !WM_IS_ICHPCH(sc)) { WM_EVCNT_ADD(&sc->sc_ev_tlpic, CSR_READ(sc, WMREG_TLPIC)); @@ -6639,8 +6644,6 @@ wm_update_stats(struct wm_softc *sc) WM_EVCNT_ADD(&sc->sc_ev_o2bgptc, CSR_READ(sc, WMREG_O2BGPTC)); } - WM_EVCNT_ADD(&sc->sc_ev_scvpc, CSR_READ(sc, WMREG_SCVPC)); - WM_EVCNT_ADD(&sc->sc_ev_hrmpc, CSR_READ(sc, WMREG_HRMPC)); } ifp->if_collisions += colc; ifp->if_ierrors += @@ -6782,7 +6785,8 @@ wm_clear_evcnt(struct wm_softc *sc) WM_EVCNT_STORE(&sc->sc_ev_ptc1522, 0); WM_EVCNT_STORE(&sc->sc_ev_mptc, 0); WM_EVCNT_STORE(&sc->sc_ev_bptc, 0); - WM_EVCNT_STORE(&sc->sc_ev_iac, 0); + if (sc->sc_type >= WM_T_82571) + WM_EVCNT_STORE(&sc->sc_ev_iac, 0); if (sc->sc_type < WM_T_82575) { WM_EVCNT_STORE(&sc->sc_ev_icrxptc, 0); WM_EVCNT_STORE(&sc->sc_ev_icrxatc, 0); @@ -6805,6 +6809,8 @@ wm_clear_evcnt(struct wm_softc *sc) WM_EVCNT_STORE(&sc->sc_ev_hgorc, 0); WM_EVCNT_STORE(&sc->sc_ev_hgotc, 0); WM_EVCNT_STORE(&sc->sc_ev_lenerrs, 0); + WM_EVCNT_STORE(&sc->sc_ev_scvpc, 0); + WM_EVCNT_STORE(&sc->sc_ev_hrmpc, 0); } if ((sc->sc_type >= WM_T_I350) && !WM_IS_ICHPCH(sc)) { WM_EVCNT_STORE(&sc->sc_ev_tlpic, 0); @@ -6813,8 +6819,6 @@ wm_clear_evcnt(struct wm_softc *sc) WM_EVCNT_STORE(&sc->sc_ev_o2bspc, 0); WM_EVCNT_STORE(&sc->sc_ev_b2ospc, 0); WM_EVCNT_STORE(&sc->sc_ev_o2bgptc, 0); - WM_EVCNT_STORE(&sc->sc_ev_scvpc, 0); - WM_EVCNT_STORE(&sc->sc_ev_hrmpc, 0); } #endif }