Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/ae4212cb3fc5
branches:  trunk
changeset: 744345:ae4212cb3fc5
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jan 30 04:56:11 2020 +0000

description:
Adopt <net/if_stats.h>.

diffstat:

 sys/dev/ic/seeq8005.c  |  28 ++++++++++++++--------------
 sys/dev/ic/sgec.c      |   8 ++++----
 sys/dev/ic/smc83c170.c |  23 +++++++++++++----------
 sys/dev/ic/smc90cx6.c  |  16 ++++++++--------
 sys/dev/ic/smc91cxx.c  |  30 +++++++++++++++++-------------
 sys/dev/ic/wi.c        |  33 +++++++++++++++++----------------
 sys/dev/pci/if_cas.c   |  28 ++++++++++++++++------------
 sys/dev/pci/if_dge.c   |  12 ++++++------
 sys/dev/pci/if_et.c    |  16 ++++++++--------
 sys/dev/pci/if_jme.c   |  23 ++++++++++++-----------
 sys/dev/pci/if_msk.c   |  10 +++++-----
 sys/dev/pci/if_nfe.c   |  26 +++++++++++++-------------
 sys/dev/pci/if_sip.c   |  32 ++++++++++++++++++--------------
 sys/dev/pci/if_ste.c   |  28 ++++++++++++++++------------
 sys/dev/pci/if_stge.c  |  30 +++++++++++++++++-------------
 sys/dev/pci/if_tl.c    |  20 +++++++++++---------
 sys/dev/pci/if_vge.c   |  18 ++++++++++--------
 sys/dev/pci/if_vr.c    |  35 +++++++++++++++++++----------------
 18 files changed, 224 insertions(+), 192 deletions(-)

diffs (truncated from 1489 to 300 lines):

diff -r a57830832783 -r ae4212cb3fc5 sys/dev/ic/seeq8005.c
--- a/sys/dev/ic/seeq8005.c     Thu Jan 30 01:49:44 2020 +0000
+++ b/sys/dev/ic/seeq8005.c     Thu Jan 30 04:56:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: seeq8005.c,v 1.65 2019/11/10 21:16:35 chs Exp $ */
+/* $NetBSD: seeq8005.c,v 1.66 2020/01/30 04:56:11 thorpej Exp $ */
 
 /*
  * Copyright (c) 2000, 2001 Ben Harris
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.65 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.66 2020/01/30 04:56:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1077,27 +1077,27 @@
                         * The 8004 contains a 4 bit collision count
                         * in the status register.
                         */
-
+#if 0
                        /* This appears to be broken on 80C04.AE */
-/*                     ifp->if_collisions +=
+                       if_statadd(ifp, if_collisions,
                            (txstatus >> SEEQ_TXSTAT_COLLISIONS_SHIFT)
-                           & SEEQ_TXSTAT_COLLISION_MASK;*/
+                           & SEEQ_TXSTAT_COLLISION_MASK;
+#endif
 
                        /* Use the TX Collision register */
                        ea_select_buffer(sc, SEEQ_BUFCODE_TX_COLLS);
                        colls = bus_space_read_1(iot, ioh, SEEQ_BUFWIN);
-                       ifp->if_collisions += colls;
+                       if_statadd(ifp, if_collisions, colls);
                        break;
                }
                case SEEQ_8005:
                        /* We known there was at least 1 collision */
-                       ifp->if_collisions++;
+                       if_statinc(ifp, if_collisions);
                        break;
                }
        } else if (txstatus & SEEQ_TXSTAT_COLLISION16) {
                printf("seeq_intr: col16 %x\n", txstatus);
-               ifp->if_collisions += 16;
-               ifp->if_oerrors++;
+               if_statadd2(ifp, if_collisions, 16, if_oerrors, 1);
        }
 
        /* Have we completed transmission on the packet ? */
@@ -1107,7 +1107,7 @@
                ifp->if_flags &= ~IFF_OACTIVE;
 
                /* Update stats */
-               ifp->if_opackets++;
+               if_statinc(ifp, if_opackets);
 
                /* Tx next packet */
 
@@ -1155,7 +1155,7 @@
                /* Sanity-check the next-packet pointer and flags. */
                if (__predict_false(ptr < sc->sc_tx_bufsize ||
                    (ctrl & SEEQ_PKTCMD_TX))) {
-                       ++ifp->if_ierrors;
+                       if_statinc(ifp, if_ierrors);
                        log(LOG_ERR,
                            "%s: Rx chain corrupt at %04x (ptr = %04x)\n",
                            device_xname(sc->sc_dev), addr, ptr);
@@ -1181,7 +1181,7 @@
                if (__predict_false(status &
                        (SEEQ_RXSTAT_CRC_ERROR | SEEQ_RXSTAT_DRIBBLE_ERROR |
                         SEEQ_RXSTAT_SHORT_FRAME))) {
-                       ++ifp->if_ierrors;
+                       if_statinc(ifp, if_ierrors);
                        log(LOG_WARNING,
                            "%s: rx packet error at %04x (err=%02x)\n",
                            device_xname(sc->sc_dev), addr, status & 0x0f);
@@ -1195,7 +1195,7 @@
                 * wants incoming packets in a single mbuf cluster.
                 */
                if (__predict_false(len > MCLBYTES)) {
-                       ++ifp->if_ierrors;
+                       if_statinc(ifp, if_ierrors);
                        log(LOG_ERR,
                            "%s: rx packet size error at %04x (len=%d)\n",
                            device_xname(sc->sc_dev), addr, len);
@@ -1478,7 +1478,7 @@
        log(LOG_ERR, "%s: lost Tx interrupt (status = 0x%04x)\n",
            device_xname(sc->sc_dev),
            SEEQ_READ16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_STATUS));
-       ifp->if_oerrors++;
+       if_statinc(ifp, if_oerrors);
 
        /* Kick the interface */
 
diff -r a57830832783 -r ae4212cb3fc5 sys/dev/ic/sgec.c
--- a/sys/dev/ic/sgec.c Thu Jan 30 01:49:44 2020 +0000
+++ b/sys/dev/ic/sgec.c Thu Jan 30 04:56:11 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: sgec.c,v 1.51 2019/05/28 07:41:48 msaitoh Exp $ */
+/*      $NetBSD: sgec.c,v 1.52 2020/01/30 04:56:11 thorpej Exp $ */
 /*
  * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
  *
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.51 2019/05/28 07:41:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.52 2020/01/30 04:56:11 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -452,7 +452,7 @@
                        if (++sc->sc_nextrx == RXDESCS)
                                sc->sc_nextrx = 0;
                        if (len < ETHER_MIN_LEN) {
-                               ifp->if_ierrors++;
+                               if_statinc(ifp, if_ierrors);
                                m_freem(m);
                        } else {
                                m_set_rcvif(m, ifp);
@@ -495,7 +495,7 @@
                            sc->sc_txcnt = 0;
                        sc->sc_inq -= map->dm_nsegs;
                        KASSERT(zc->zc_xmit[lastack].ze_tdes1 & ZE_TDES1_LS);
-                       ifp->if_opackets++;
+                       if_statinc(ifp, if_opackets);
                        bus_dmamap_unload(sc->sc_dmat, map);
                        KASSERT(sc->sc_txmbuf[lastack]);
                        m_freem(sc->sc_txmbuf[lastack]);
diff -r a57830832783 -r ae4212cb3fc5 sys/dev/ic/smc83c170.c
--- a/sys/dev/ic/smc83c170.c    Thu Jan 30 01:49:44 2020 +0000
+++ b/sys/dev/ic/smc83c170.c    Thu Jan 30 04:56:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smc83c170.c,v 1.91 2020/01/22 03:48:10 thorpej Exp $   */
+/*     $NetBSD: smc83c170.c,v 1.92 2020/01/30 04:56:11 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smc83c170.c,v 1.91 2020/01/22 03:48:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smc83c170.c,v 1.92 2020/01/30 04:56:11 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -545,7 +545,7 @@
        struct epic_softc *sc = ifp->if_softc;
 
        printf("%s: device timeout\n", device_xname(sc->sc_dev));
-       ifp->if_oerrors++;
+       if_statinc(ifp, if_oerrors);
 
        (void)epic_init(ifp);
 }
@@ -645,7 +645,7 @@
                                if (rxstatus & ER_RXSTAT_ALIGNERROR)
                                        printf("%s: alignment error\n",
                                            device_xname(sc->sc_dev));
-                               ifp->if_ierrors++;
+                               if_statinc(ifp, if_ierrors);
                                EPIC_INIT_RXDESC(sc, i);
                                continue;
                        }
@@ -663,7 +663,7 @@
                                /*
                                 * Runt packet; drop it now.
                                 */
-                               ifp->if_ierrors++;
+                               if_statinc(ifp, if_ierrors);
                                EPIC_INIT_RXDESC(sc, i);
                                bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0,
                                    ds->ds_dmamap->dm_mapsize,
@@ -696,7 +696,7 @@
                                m = ds->ds_mbuf;
                                if (epic_add_rxbuf(sc, i) != 0) {
  dropit:
-                                       ifp->if_ierrors++;
+                                       if_statinc(ifp, if_ierrors);
                                        EPIC_INIT_RXDESC(sc, i);
                                        bus_dmamap_sync(sc->sc_dmat,
                                            ds->ds_dmamap, 0,
@@ -762,15 +762,18 @@
                        /*
                         * Check for errors and collisions.
                         */
+                       net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
                        if ((txstatus & ET_TXSTAT_PACKETTX) == 0)
-                               ifp->if_oerrors++;
+                               if_statinc_ref(nsr, if_oerrors);
                        else
-                               ifp->if_opackets++;
-                       ifp->if_collisions +=
-                           TXSTAT_COLLISIONS(txstatus);
+                               if_statinc_ref(nsr, if_opackets);
+                       if (TXSTAT_COLLISIONS(txstatus))
+                               if_statadd_ref(nsr, if_collisions,
+                                   TXSTAT_COLLISIONS(txstatus));
                        if (txstatus & ET_TXSTAT_CARSENSELOST)
                                printf("%s: lost carrier\n",
                                    device_xname(sc->sc_dev));
+                       IF_STAT_PUTREF(ifp);
                }
 
                /* Update the dirty transmit buffer pointer. */
diff -r a57830832783 -r ae4212cb3fc5 sys/dev/ic/smc90cx6.c
--- a/sys/dev/ic/smc90cx6.c     Thu Jan 30 01:49:44 2020 +0000
+++ b/sys/dev/ic/smc90cx6.c     Thu Jan 30 04:56:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smc90cx6.c,v 1.74 2019/02/05 06:17:02 msaitoh Exp $ */
+/*     $NetBSD: smc90cx6.c,v 1.75 2020/01/30 04:56:11 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.74 2019/02/05 06:17:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.75 2020/01/30 04:56:11 thorpej Exp $");
 
 /* #define BAHSOFTCOPY */
 #define BAHRETRANSMIT /**/
@@ -523,7 +523,7 @@
                 * count it as input error (we dont have any other
                 * detectable)
                 */
-               ifp->if_ierrors++;
+               if_statinc(ifp, if_ierrors);
                goto cleanup;
        }
 
@@ -548,7 +548,7 @@
                MCLGET(m, M_DONTWAIT);
 
        if (m == 0) {
-               ifp->if_ierrors++;
+               if_statinc(ifp, if_ierrors);
                goto cleanup;
        }
 
@@ -575,7 +575,7 @@
                        MGET(m, M_DONTWAIT, MT_DATA);
 
                        if (m == 0) {
-                               ifp->if_ierrors++;
+                               if_statinc(ifp, if_ierrors);
                                goto cleanup;
                        }
 
@@ -654,7 +654,7 @@
         */
 
        if (isr & BAH_TMA || sc->sc_broadcast[buffer])
-               sc->sc_arccom.ac_if.if_opackets++;
+               if_statinc(ifp, if_opackets);
 #ifdef BAHRETRANSMIT
        else if (ifp->if_flags & IFF_LINK2 && ifp->if_timer > 0
            && --sc->sc_retransmits[buffer] > 0) {
@@ -664,7 +664,7 @@
        }
 #endif
        else
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
 
 
        /* We know we can accept another buffer at this point. */
@@ -760,7 +760,7 @@
                         * PUTREG(BAHCMD, BAH_CONF(CONF_LONG));
                         */
                        PUTREG(BAHCMD, BAH_CLR(CLR_RECONFIG));
-                       sc->sc_arccom.ac_if.if_collisions++;
+                       if_statinc(&sc->sc_arccom.ac_if, if_collisions);
 
                        /*
                         * If less than 2 seconds per reconfig:
diff -r a57830832783 -r ae4212cb3fc5 sys/dev/ic/smc91cxx.c
--- a/sys/dev/ic/smc91cxx.c     Thu Jan 30 01:49:44 2020 +0000
+++ b/sys/dev/ic/smc91cxx.c     Thu Jan 30 04:56:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smc91cxx.c,v 1.103 2019/12/06 07:12:38 maxv Exp $      */
+/*     $NetBSD: smc91cxx.c,v 1.104 2020/01/30 04:56:11 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.103 2019/12/06 07:12:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.104 2020/01/30 04:56:11 thorpej Exp $");
 
 #include "opt_inet.h"



Home | Main Index | Thread Index | Old Index