Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Adopt <net/if_stats.h>.



details:   https://anonhg.NetBSD.org/src/rev/dc30942ea7db
branches:  trunk
changeset: 744355:dc30942ea7db
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jan 30 13:56:48 2020 +0000

description:
Adopt <net/if_stats.h>.

diffstat:

 sys/dev/pci/if_age.c        |  33 ++++++++++++++++++++-------------
 sys/dev/pci/if_alc.c        |  35 +++++++++++++++++++++--------------
 sys/dev/pci/if_ale.c        |  31 +++++++++++++++++++------------
 sys/dev/pci/if_bce.c        |  16 ++++++++--------
 sys/dev/pci/if_lii.c        |  16 ++++++++--------
 sys/dev/pci/if_mcx.c        |   4 ++--
 sys/dev/pci/if_vioif.c      |  12 +++++++-----
 sys/dev/pci/ixgbe/ix_txrx.c |  13 ++++++-------
 8 files changed, 91 insertions(+), 69 deletions(-)

diffs (truncated from 465 to 300 lines):

diff -r 0a30e9892c62 -r dc30942ea7db sys/dev/pci/if_age.c
--- a/sys/dev/pci/if_age.c      Thu Jan 30 13:54:05 2020 +0000
+++ b/sys/dev/pci/if_age.c      Thu Jan 30 13:56:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_age.c,v 1.65 2019/12/01 08:16:49 msaitoh Exp $ */
+/*     $NetBSD: if_age.c,v 1.66 2020/01/30 13:59:24 thorpej Exp $ */
 /*     $OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $        */
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.65 2019/12/01 08:16:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.66 2020/01/30 13:59:24 thorpej Exp $");
 
 #include "vlan.h"
 
@@ -1079,7 +1079,7 @@
        if ((sc->age_flags & AGE_FLAG_LINK) == 0) {
                printf("%s: watchdog timeout (missed link)\n",
                    device_xname(sc->sc_dev));
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
                age_init(ifp);
                return;
        }
@@ -1092,7 +1092,7 @@
        }
 
        printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
-       ifp->if_oerrors++;
+       if_statinc(ifp, if_oerrors);
        age_init(ifp);
        age_start(ifp);
 }
@@ -1411,7 +1411,7 @@
                desc = rxd->rx_desc;
                /* Add a new receive buffer to the ring. */
                if (age_newbuf(sc, rxd, 0) != 0) {
-                       ifp->if_iqdrops++;
+                       if_statinc(ifp, if_iqdrops);
                        /* Reuse Rx buffers. */
                        if (sc->age_cdata.age_rxhead != NULL) {
                                m_freem(sc->age_cdata.age_rxhead);
@@ -2033,20 +2033,27 @@
        stat->tx_mcast_bytes += smb->tx_mcast_bytes;
 
        /* Update counters in ifnet. */
-       ifp->if_opackets += smb->tx_frames;
+       net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 
-       ifp->if_collisions += smb->tx_single_colls +
-           smb->tx_multi_colls + smb->tx_late_colls +
-           smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT;
+       if_statadd_ref(nsr, if_opackets, smb->tx_frames);
 
-       ifp->if_oerrors += smb->tx_excess_colls +
+       if_statadd_ref(nsr, if_collisions,
+           smb->tx_single_colls +
+           smb->tx_multi_colls + smb->tx_late_colls +
+           smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT);
+
+       if_statadd_ref(nsr, if_oerrors,
+           smb->tx_excess_colls +
            smb->tx_late_colls + smb->tx_underrun +
-           smb->tx_pkts_truncated;
+           smb->tx_pkts_truncated);
 
-       ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+       if_statadd_ref(nsr, if_ierrors,
+           smb->rx_crcerrs + smb->rx_lenerrs +
            smb->rx_runts + smb->rx_pkts_truncated +
            smb->rx_fifo_oflows + smb->rx_desc_oflows +
-           smb->rx_alignerrs;
+           smb->rx_alignerrs);
+
+       IF_STAT_PUTREF(ifp);
 
        /* Update done, clear. */
        smb->updated = 0;
diff -r 0a30e9892c62 -r dc30942ea7db sys/dev/pci/if_alc.c
--- a/sys/dev/pci/if_alc.c      Thu Jan 30 13:54:05 2020 +0000
+++ b/sys/dev/pci/if_alc.c      Thu Jan 30 13:56:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_alc.c,v 1.46 2019/12/18 13:25:00 msaitoh Exp $      */
+/*     $NetBSD: if_alc.c,v 1.47 2020/01/30 13:59:24 thorpej Exp $      */
 /*     $OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $        */
 /*-
  * Copyright (c) 2009, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -2059,13 +2059,13 @@
        if ((sc->alc_flags & ALC_FLAG_LINK) == 0) {
                printf("%s: watchdog timeout (missed link)\n",
                    device_xname(sc->sc_dev));
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
                alc_init_backend(ifp, false);
                return;
        }
 
        printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
-       ifp->if_oerrors++;
+       if_statinc(ifp, if_oerrors);
        alc_init_backend(ifp, false);
        alc_start(ifp);
 }
@@ -2267,19 +2267,26 @@
        stat->tx_mcast_bytes += smb->tx_mcast_bytes;
 
        /* Update counters in ifnet. */
-       ifp->if_opackets += smb->tx_frames;
-
-       ifp->if_collisions += smb->tx_single_colls +
+       net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
+       if_statadd_ref(nsr, if_opackets, smb->tx_frames);
+
+       if_statadd_ref(nsr, if_collisions,
+           smb->tx_single_colls +
            smb->tx_multi_colls * 2 + smb->tx_late_colls +
-           smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT;
-
-       ifp->if_oerrors += smb->tx_late_colls + smb->tx_excess_colls +
-           smb->tx_underrun + smb->tx_pkts_truncated;
-
-       ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+           smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT);
+
+       if_statadd_ref(nsr, if_oerrors,
+           smb->tx_late_colls + smb->tx_excess_colls +
+           smb->tx_underrun + smb->tx_pkts_truncated);
+
+       if_statadd_ref(nsr, if_ierrors,
+           smb->rx_crcerrs + smb->rx_lenerrs +
            smb->rx_runts + smb->rx_pkts_truncated +
            smb->rx_fifo_oflows + smb->rx_rrs_errs +
-           smb->rx_alignerrs;
+           smb->rx_alignerrs);
+
+       IF_STAT_PUTREF(ifp);
 
        if ((sc->alc_flags & ALC_FLAG_SMB_BUG) == 0) {
                /* Update done, clear. */
@@ -2551,7 +2558,7 @@
                mp = rxd->rx_m;
                /* Add a new receive buffer to the ring. */
                if (alc_newbuf(sc, rxd, false) != 0) {
-                       ifp->if_iqdrops++;
+                       if_statinc(ifp, if_iqdrops);
                        /* Reuse Rx buffers. */
                        if (sc->alc_cdata.alc_rxhead != NULL)
                                m_freem(sc->alc_cdata.alc_rxhead);
diff -r 0a30e9892c62 -r dc30942ea7db sys/dev/pci/if_ale.c
--- a/sys/dev/pci/if_ale.c      Thu Jan 30 13:54:05 2020 +0000
+++ b/sys/dev/pci/if_ale.c      Thu Jan 30 13:56:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ale.c,v 1.37 2019/12/01 08:16:49 msaitoh Exp $      */
+/*     $NetBSD: if_ale.c,v 1.38 2020/01/30 13:59:24 thorpej Exp $      */
 
 /*-
  * Copyright (c) 2008, Pyun YongHyeon <yongari%FreeBSD.org@localhost>
@@ -32,7 +32,7 @@
 /* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.37 2019/12/01 08:16:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.38 2020/01/30 13:59:24 thorpej Exp $");
 
 #include "vlan.h"
 
@@ -1098,13 +1098,13 @@
        if ((sc->ale_flags & ALE_FLAG_LINK) == 0) {
                printf("%s: watchdog timeout (missed link)\n",
                    device_xname(sc->sc_dev));
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
                ale_init(ifp);
                return;
        }
 
        printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
-       ifp->if_oerrors++;
+       if_statinc(ifp, if_oerrors);
        ale_init(ifp);
 
        if (!IFQ_IS_EMPTY(&ifp->if_snd))
@@ -1257,11 +1257,14 @@
        stat->tx_mcast_bytes += smb->tx_mcast_bytes;
 
        /* Update counters in ifnet. */
-       ifp->if_opackets += smb->tx_frames;
+       net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
+       if_statadd_ref(nsr, if_opackets, smb->tx_frames);
 
-       ifp->if_collisions += smb->tx_single_colls +
+       if_statadd_ref(nsr, if_collisions,
+           smb->tx_single_colls +
            smb->tx_multi_colls * 2 + smb->tx_late_colls +
-           smb->tx_abort * HDPX_CFG_RETRY_DEFAULT;
+           smb->tx_abort * HDPX_CFG_RETRY_DEFAULT);
 
        /*
         * XXX
@@ -1270,13 +1273,17 @@
         * the counter name is not correct one so I've removed the
         * counter in output errors.
         */
-       ifp->if_oerrors += smb->tx_abort + smb->tx_late_colls +
-           smb->tx_underrun;
+       if_statadd_ref(nsr, if_oerrors,
+           smb->tx_abort + smb->tx_late_colls +
+           smb->tx_underrun);
 
-       ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs +
+       if_statadd_ref(nsr, if_ierrors,
+           smb->rx_crcerrs + smb->rx_lenerrs +
            smb->rx_runts + smb->rx_pkts_truncated +
            smb->rx_fifo_oflows + smb->rx_rrs_errs +
-           smb->rx_alignerrs;
+           smb->rx_alignerrs);
+
+       IF_STAT_PUTREF(ifp);
 }
 
 static int
@@ -1532,7 +1539,7 @@
                m = m_devget((char *)(rs + 1), length - ETHER_CRC_LEN,
                    0, ifp);
                if (m == NULL) {
-                       ifp->if_iqdrops++;
+                       if_statinc(ifp, if_iqdrops);
                        ale_rx_update_page(sc, &rx_page, length, &prod);
                        continue;
                }
diff -r 0a30e9892c62 -r dc30942ea7db sys/dev/pci/if_bce.c
--- a/sys/dev/pci/if_bce.c      Thu Jan 30 13:54:05 2020 +0000
+++ b/sys/dev/pci/if_bce.c      Thu Jan 30 13:56:48 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bce.c,v 1.56 2019/10/18 23:08:29 msaitoh Exp $   */
+/* $NetBSD: if_bce.c,v 1.57 2020/01/30 13:56:48 thorpej Exp $   */
 
 /*
  * Copyright (c) 2003 Clifford Wright. All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.56 2019/10/18 23:08:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.57 2020/01/30 13:56:48 thorpej Exp $");
 
 #include "vlan.h"
 
@@ -558,7 +558,7 @@
                            "dropping...\n");
                        IFQ_DEQUEUE(&ifp->if_snd, m0);
                        m_freem(m0);
-                       ifp->if_oerrors++;
+                       if_statinc(ifp, if_oerrors);
                        continue;
                } else if (error) {
                        /* short on resources, come back later */
@@ -654,7 +654,7 @@
        struct bce_softc *sc = ifp->if_softc;
 
        device_printf(sc->bce_dev, "device timeout\n");
-       ifp->if_oerrors++;
+       if_statinc(ifp, if_oerrors);
 
        (void) bce_init(ifp);
 
@@ -702,7 +702,7 @@
                                msg = "transmit fifo underflow";
                        if (intstatus & I_RO) {
                                msg = "receive fifo overflow";
-                               ifp->if_ierrors++;
+                               if_statinc(ifp, if_ierrors);
                        }
                        if (intstatus & I_RU)
                                msg = "receive descriptor underflow";
@@ -762,7 +762,7 @@
                 */
                pph = mtod(sc->bce_cdata.bce_rx_chain[i], struct rx_pph *);
                if (pph->flags & (RXF_NO | RXF_RXER | RXF_CRC | RXF_OV)) {
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        pph->len = 0;
                        pph->flags = 0;
                        continue;
@@ -805,7 +805,7 @@
                        m = sc->bce_cdata.bce_rx_chain[i];
                        if (bce_add_rxbuf(sc, i) != 0) {
                dropit:
-                               ifp->if_ierrors++;
+                               if_statinc(ifp, if_ierrors);
                                /* continue to use old buffer */
                                sc->bce_cdata.bce_rx_chain[i]->m_data -= 30;
                                bus_dmamap_sync(sc->bce_dmatag,
@@ -862,7 +862,7 @@
                bus_dmamap_unload(sc->bce_dmatag, sc->bce_cdata.bce_tx_map[i]);



Home | Main Index | Thread Index | Old Index