Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/fc43eba620e6
branches:  trunk
changeset: 744315:fc43eba620e6
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jan 29 15:00:39 2020 +0000

description:
Adopt <net/if_stats.h>.

diffstat:

 sys/dev/ic/malo.c    |  22 +++++++++++-----------
 sys/dev/ic/mb86950.c |  22 +++++++++++-----------
 sys/dev/ic/mb86960.c |  28 +++++++++++++++-------------
 sys/dev/ic/mtd803.c  |  30 +++++++++++++++---------------
 sys/dev/ic/rt2560.c  |  26 +++++++++++++-------------
 sys/dev/ic/rt2661.c  |  28 ++++++++++++++--------------
 sys/dev/ic/rt2860.c  |  28 ++++++++++++++--------------
 sys/dev/ic/rtl8169.c |  20 +++++++++++---------
 sys/dev/ic/rtl81x9.c |  21 ++++++++++++---------
 sys/dev/ic/rtw.c     |  21 +++++++++++----------
 10 files changed, 127 insertions(+), 119 deletions(-)

diffs (truncated from 1006 to 300 lines):

diff -r 38af3dfc2e58 -r fc43eba620e6 sys/dev/ic/malo.c
--- a/sys/dev/ic/malo.c Wed Jan 29 14:47:08 2020 +0000
+++ b/sys/dev/ic/malo.c Wed Jan 29 15:00:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: malo.c,v 1.17 2019/11/10 21:16:35 chs Exp $ */
+/*     $NetBSD: malo.c,v 1.18 2020/01/29 15:00:39 thorpej Exp $ */
 /*     $OpenBSD: malo.c,v 1.92 2010/08/27 17:08:00 jsg Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.17 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.18 2020/01/29 15:00:39 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1043,14 +1043,14 @@
 
                        if (m0->m_len < sizeof (*eh) &&
                            (m0 = m_pullup(m0, sizeof (*eh))) == NULL) {
-                               ifp->if_oerrors++;
+                               if_statinc(ifp, if_oerrors);
                                continue;
                        }
                        eh = mtod(m0, struct ether_header *);
                        ni = ieee80211_find_txnode(ic, eh->ether_dhost);
                        if (ni == NULL) {
                                m_freem(m0);
-                               ifp->if_oerrors++;
+                               if_statinc(ifp, if_oerrors);
                                continue;
                        }
 
@@ -1066,7 +1066,7 @@
 
                        if (malo_tx_data(sc, m0, ni) != 0) {
                                ieee80211_free_node(ni);
-                               ifp->if_oerrors++;
+                               if_statinc(ifp, if_oerrors);
                                break;
                        }
                }
@@ -1352,12 +1352,12 @@
                case MALO_TXD_STATUS_OK:
                        DPRINTF(2, "%s: data frame was sent successfully\n",
                            device_xname(sc->sc_dev));
-                       ifp->if_opackets++;
+                       if_statinc(ifp, if_opackets);
                        break;
                default:
                        DPRINTF(1, "%s: data frame sending error\n",
                            device_xname(sc->sc_dev));
-                       ifp->if_oerrors++;
+                       if_statinc(ifp, if_oerrors);
                        break;
                }
 
@@ -1415,7 +1415,7 @@
        if (m0->m_len < sizeof(struct ieee80211_frame)) {
                m0 = m_pullup(m0, sizeof(struct ieee80211_frame));
                if (m0 == NULL) {
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        return (ENOBUFS);
                }
        }
@@ -1555,14 +1555,14 @@
 
                MGETHDR(mnew, M_DONTWAIT, MT_DATA);
                if (mnew == NULL) {
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        goto skip;
                }
 
                MCLGET(mnew, M_DONTWAIT);
                if (!(mnew->m_flags & M_EXT)) {
                        m_freem(mnew);
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        goto skip;
                }
 
@@ -1582,7 +1582,7 @@
                                panic("%s: could not load old rx mbuf",
                                    device_xname(sc->sc_dev));
                        }
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        goto skip;
                }
 
diff -r 38af3dfc2e58 -r fc43eba620e6 sys/dev/ic/mb86950.c
--- a/sys/dev/ic/mb86950.c      Wed Jan 29 14:47:08 2020 +0000
+++ b/sys/dev/ic/mb86950.c      Wed Jan 29 15:00:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mb86950.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $     */
+/*     $NetBSD: mb86950.c,v 1.33 2020/01/29 15:00:39 thorpej Exp $     */
 
 /*
  * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@@ -67,7 +67,7 @@
   */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.33 2020/01/29 15:00:39 thorpej Exp $");
 
 /*
  * Device driver for Fujitsu mb86950 based Ethernet cards.
@@ -415,7 +415,7 @@
         * Don't know how many packets are lost by this accident.
         *  ... So just errors = errors + 1
         */
-       ifp->if_oerrors++;
+       if_statinc(ifp, if_oerrors);
 
        mb86950_reset(sc);
 }
@@ -735,12 +735,12 @@
 
        if (tstat & (TX_UNDERFLO | TX_BUS_WR_ERR)) {
                /* XXX What do we need to do here? reset ? */
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
        }
 
        /* Excessive collision */
        if (tstat & TX_16COL) {
-               ifp->if_collisions += 16;
+               if_statadd(ifp, if_collisions, 16);
                /* 16 collisions means that the packet has been thrown away. */
                if (sc->txb_sched > 0)
                        sc->txb_sched--;
@@ -749,7 +749,7 @@
        /* Transmission complete. */
        if (tstat & TX_DONE) {
                /* Successfully transmitted packets ++. */
-               ifp->if_opackets++;
+               if_statinc(ifp, if_opackets);
                if (sc->txb_sched > 0)
                        sc->txb_sched--;
 
@@ -757,7 +757,7 @@
                if (tstat & TX_COL) {
                        col = (bus_space_read_1(bst, bsh, DLCR_TX_MODE)
                            & COL_MASK) >> 4;
-                       ifp->if_collisions = ifp->if_collisions + col;
+                       if_statadd(ifp, if_collisions, col);
                }
        }
 
@@ -786,7 +786,7 @@
                 * count everything else
                 */
                if ((rstat & RX_BUS_RD_ERR) == 0) {
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                }
        }
 
@@ -810,7 +810,7 @@
 
                /* Bad packet? */
                if ((status & GOOD_PKT) == 0) {
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        mb86950_drain_fifo(sc);
                        continue;
                }
@@ -820,14 +820,14 @@
 
                if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN)
                    || len < ETHER_HDR_LEN) {
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        mb86950_drain_fifo(sc);
                        continue;
                }
 
                if (mb86950_get_fifo(sc, len) != 0) {
                        /* No mbufs? Drop packet. */
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        mb86950_drain_fifo(sc);
                        return;
                }
diff -r 38af3dfc2e58 -r fc43eba620e6 sys/dev/ic/mb86960.c
--- a/sys/dev/ic/mb86960.c      Wed Jan 29 14:47:08 2020 +0000
+++ b/sys/dev/ic/mb86960.c      Wed Jan 29 15:00:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mb86960.c,v 1.93 2019/05/29 10:07:29 msaitoh Exp $     */
+/*     $NetBSD: mb86960.c,v 1.94 2020/01/29 15:00:39 thorpej Exp $     */
 
 /*
  * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.93 2019/05/29 10:07:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.94 2020/01/29 15:00:39 thorpej Exp $");
 
 /*
  * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
@@ -427,7 +427,7 @@
 #endif
 
        /* Record how many packets are lost by this accident. */
-       sc->sc_ec.ec_if.if_oerrors += sc->txb_sched + sc->txb_count;
+       if_statadd(ifp, if_oerrors, sc->txb_sched + sc->txb_count);
 
        mb86960_reset(sc);
 }
@@ -818,9 +818,11 @@
                /*
                 * Update statistics.
                 */
-               ifp->if_collisions += 16;
-               ifp->if_oerrors++;
-               ifp->if_opackets += sc->txb_sched - left;
+               net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+               if_statadd_ref(nsr, if_collisions, 16);
+               if_statinc_ref(nsr, if_oerrors);
+               if_statadd_ref(nsr, if_opackets, sc->txb_sched - left);
+               IF_STAT_PUTREF(ifp);
 
                /*
                 * Collision statistics has been updated.
@@ -889,7 +891,7 @@
                                col = 1;
                        } else
                                col >>= FE_D4_COL_SHIFT;
-                       ifp->if_collisions += col;
+                       if_statadd(ifp, if_collisions, col);
 #if FE_DEBUG >= 4
                        log(LOG_WARNING, "%s: %d collision%s (%d)\n",
                            device_xname(sc->sc_dev), col, col == 1 ? "" : "s",
@@ -901,7 +903,7 @@
                 * Update total number of successfully
                 * transmitted packets.
                 */
-               ifp->if_opackets += sc->txb_sched;
+               if_statadd(ifp, if_opackets, sc->txb_sched);
                sc->txb_sched = 0;
        }
 
@@ -948,7 +950,7 @@
                log(LOG_WARNING, "%s: receive error: %s\n",
                    device_xname(sc->sc_dev), sbuf);
 #endif
-               ifp->if_ierrors++;
+               if_statinc(ifp, if_ierrors);
        }
 
        /*
@@ -988,7 +990,7 @@
                 */
                if ((status & FE_RXSTAT_GOODPKT) == 0) {
                        if ((ifp->if_flags & IFF_PROMISC) == 0) {
-                               ifp->if_ierrors++;
+                               if_statinc(ifp, if_ierrors);
                                mb86960_droppacket(sc);
                                continue;
                        }
@@ -1022,7 +1024,7 @@
                            device_xname(sc->sc_dev),
                            len < ETHER_HDR_LEN ? "partial" : "big", len);
 #endif
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        mb86960_droppacket(sc);
                        continue;
                }
@@ -1051,7 +1053,7 @@
                            "%s: out of mbufs; dropping packet (%u bytes)\n",
                            device_xname(sc->sc_dev), len);
 #endif
-                       ifp->if_ierrors++;
+                       if_statinc(ifp, if_ierrors);
                        mb86960_droppacket(sc);
 
                        /*
@@ -1391,7 +1393,7 @@
                log(LOG_ERR, "%s: got a %s packet (%u bytes) to send\n",
                    device_xname(sc->sc_dev),
                    totlen < ETHER_HDR_LEN ? "partial" : "big", totlen);
-               sc->sc_ec.ec_if.if_oerrors++;
+               if_statinc(&sc->sc_ec.ec_if, if_oerrors);
                return;
        }
 #endif
diff -r 38af3dfc2e58 -r fc43eba620e6 sys/dev/ic/mtd803.c
--- a/sys/dev/ic/mtd803.c       Wed Jan 29 14:47:08 2020 +0000
+++ b/sys/dev/ic/mtd803.c       Wed Jan 29 15:00:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mtd803.c,v 1.40 2019/05/30 02:32:18 msaitoh Exp $ */
+/* $NetBSD: mtd803.c,v 1.41 2020/01/29 15:00:39 thorpej Exp $ */



Home | Main Index | Thread Index | Old Index