Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/38b6c4239e90
branches:  trunk
changeset: 968803:38b6c4239e90
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jan 29 05:20:26 2020 +0000

description:
Adopt <net/if_stats.h>.

diffstat:

 sys/arch/amiga/dev/if_es.c               |  21 ++++++++-------
 sys/arch/amiga/dev/if_qn.c               |  24 +++++++++---------
 sys/arch/mac68k/dev/if_mc.c              |  42 +++++++++++++++++--------------
 sys/arch/mac68k/nubus/if_netdock_nubus.c |  10 +++---
 sys/net80211/ieee80211_input.c           |  18 ++++++------
 sys/netcan/can.c                         |   9 +++---
 sys/netcan/if_canloop.c                  |   7 ++---
 7 files changed, 67 insertions(+), 64 deletions(-)

diffs (truncated from 500 to 300 lines):

diff -r 595fc320fa96 -r 38b6c4239e90 sys/arch/amiga/dev/if_es.c
--- a/sys/arch/amiga/dev/if_es.c        Wed Jan 29 04:37:24 2020 +0000
+++ b/sys/arch/amiga/dev/if_es.c        Wed Jan 29 05:20:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_es.c,v 1.64 2019/05/29 10:07:28 msaitoh Exp $ */
+/*     $NetBSD: if_es.c,v 1.65 2020/01/29 05:23:16 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995 Michael L. Hitch
@@ -33,7 +33,7 @@
 #include "opt_ns.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.64 2019/05/29 10:07:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.65 2020/01/29 05:23:16 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -389,7 +389,7 @@
                    intsts);
                smc->b2.ist = ACK_RX_OVRN;
                printf ("->%02x\n", smc->b2.ist);
-               ifp->if_ierrors++;
+               if_statinc(ifp, if_ierrors);
        }
        if (intact & IST_TX_EMPTY) {
                u_short ecr;
@@ -417,8 +417,8 @@
                        smc->b0.bsr = BSR_BANK0;
                        ecr = smc->b0.ecr;      /* Get error counters */
                        if (ecr & 0xff00)
-                               ifp->if_collisions += ((ecr >> 8) & 15) +
-                                   ((ecr >> 11) & 0x1e);
+                               if_statadd(ifp, if_collisions,
+                                   ((ecr >> 8) & 15) + ((ecr >> 11) & 0x1e));
                        smc->b2.bsr = BSR_BANK2;
 #if 0
                        smc->b2.mmucr = MMUCR_RESET_TX; /* XXX reset TX FIFO */
@@ -468,7 +468,7 @@
                        smc->b0.bsr = BSR_BANK0;
                        smc->b0.tcr |= TCR_TXENA;
                        smc->b2.bsr = BSR_BANK2;
-                       ifp->if_oerrors++;
+                       if_statinc(ifp, if_oerrors);
                        sc->sc_intctl |= MSK_TX_EMPTY | MSK_TX;
                } else {
                        /*
@@ -509,7 +509,7 @@
                }
        }
        if (intact & IST_EPHINT) {
-               ifp->if_oerrors++;
+               if_statinc(ifp, if_oerrors);
                esreset(sc);
        }
        /* output packets */
@@ -601,7 +601,7 @@
                smc->b2.mmucr = MMUCR_REMRLS_RX;
                while (smc->b2.mmucr & MMUCR_BUSY)
                        ;
-               ++ifp->if_ierrors;
+               if_statinc(ifp, if_ierrors);
 #ifdef ESDEBUG
                if (--sc->sc_smcbusy) {
                        printf("%s: esrintr busy on bad packet exit\n",
@@ -922,7 +922,8 @@
                            device_xname(sc->sc_dev), active_pnr, smc->b2.pnr);
                bpf_mtap(&sc->sc_ethercom.ec_if, m0, BPF_D_OUT);
                m_freem(m0);
-               sc->sc_ethercom.ec_if.if_opackets++;    /* move to interrupt? */
+                               /* move to interrupt? */
+               if_statinc(&sc->sc_ethercom.ec_if, if_opackets);
                sc->sc_intctl |= MSK_TX_EMPTY | MSK_TX;
                sc->sc_ethercom.ec_if.if_timer = 5;
        }
@@ -1048,7 +1049,7 @@
        struct es_softc *sc = ifp->if_softc;
 
        log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
-       ++ifp->if_oerrors;
+       if_statinc(ifp, if_oerrors);
 
        esreset(sc);
 }
diff -r 595fc320fa96 -r 38b6c4239e90 sys/arch/amiga/dev/if_qn.c
--- a/sys/arch/amiga/dev/if_qn.c        Wed Jan 29 04:37:24 2020 +0000
+++ b/sys/arch/amiga/dev/if_qn.c        Wed Jan 29 05:20:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_qn.c,v 1.48 2019/11/12 13:17:43 msaitoh Exp $ */
+/*     $NetBSD: if_qn.c,v 1.49 2020/01/29 05:23:16 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995 Mika Kortelainen
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.48 2019/11/12 13:17:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.49 2020/01/29 05:23:16 thorpej Exp $");
 
 #include "qn.h"
 #if NQN > 0
@@ -305,7 +305,7 @@
        struct qn_softc *sc = ifp->if_softc;
 
        log(LOG_INFO, "qn: device timeout (watchdog)\n");
-       ++sc->sc_ethercom.ec_if.if_oerrors;
+       if_statinc(ifp, if_oerrors);
 
        qnreset(sc);
 }
@@ -613,19 +613,19 @@
 #ifdef QN_DEBUG
                log(LOG_INFO, "Overflow\n");
 #endif
-               ++sc->sc_ethercom.ec_if.if_ierrors;
+               if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
        }
        if (rstat & R_INT_CRC_ERR) {
 #ifdef QN_DEBUG
                log(LOG_INFO, "CRC Error\n");
 #endif
-               ++sc->sc_ethercom.ec_if.if_ierrors;
+               if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
        }
        if (rstat & R_INT_ALG_ERR) {
 #ifdef QN_DEBUG
                log(LOG_INFO, "Alignment error\n");
 #endif
-               ++sc->sc_ethercom.ec_if.if_ierrors;
+               if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
        }
        if (rstat & R_INT_SRT_PKT) {
                /* Short packet (these may occur and are
@@ -635,13 +635,13 @@
 #ifdef QN_DEBUG
                log(LOG_INFO, "Short packet\n");
 #endif
-               ++sc->sc_ethercom.ec_if.if_ierrors;
+               if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
        }
        if (rstat & 0x4040) {
 #ifdef QN_DEBUG
                log(LOG_INFO, "Bus read error\n");
 #endif
-               ++sc->sc_ethercom.ec_if.if_ierrors;
+               if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
                qnreset(sc);
        }
 
@@ -677,7 +677,7 @@
                            "%s: received a %s packet? (%u bytes)\n",
                            device_xname(sc->sc_dev),
                            len < ETHER_HDR_LEN ? "partial" : "big", len);
-                       ++sc->sc_ethercom.ec_if.if_ierrors;
+                       if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
                        continue;
                }
 #endif
@@ -742,7 +742,7 @@
                         * Update total number of successfully
                         * transmitted packets.
                         */
-                       sc->sc_ethercom.ec_if.if_opackets++;
+                       if_statinc(&sc->sc_ethercom.ec_if, if_opackets);
                }
 
                if (tint & T_SIXTEEN_COL) {
@@ -753,8 +753,8 @@
 #ifdef QN_DEBUG1
                        qn_dump(sc);
 #endif
-                       sc->sc_ethercom.ec_if.if_oerrors++;
-                       sc->sc_ethercom.ec_if.if_collisions += 16;
+                       if_statadd2(&sc->sc_ethercom.ec_if,
+                           if_oerrors, 1, if_collisions, 16);
                        sc->transmit_pending = 0;
                }
 
diff -r 595fc320fa96 -r 38b6c4239e90 sys/arch/mac68k/dev/if_mc.c
--- a/sys/arch/mac68k/dev/if_mc.c       Wed Jan 29 04:37:24 2020 +0000
+++ b/sys/arch/mac68k/dev/if_mc.c       Wed Jan 29 05:20:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mc.c,v 1.52 2019/12/27 09:32:09 msaitoh Exp $       */
+/*     $NetBSD: if_mc.c,v 1.53 2020/01/29 05:25:41 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1997 David Huang <khym%azeotrope.org@localhost>
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.52 2019/12/27 09:32:09 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.53 2020/01/29 05:25:41 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -266,7 +266,7 @@
                ifp->if_flags |= IFF_OACTIVE;
                maceput(sc, m);
 
-               ifp->if_opackets++;             /* # of pkts */
+               if_statinc(ifp, if_opackets);   /* # of pkts */
        }
 }
 
@@ -434,21 +434,21 @@
 #ifdef MCDEBUG
                printf("%s: jabber error\n", device_xname(sc->sc_dev));
 #endif
-               sc->sc_if.if_oerrors++;
+               if_statinc(&sc->sc_if, if_oerrors);
        }
 
        if (ir & BABL) {
 #ifdef MCDEBUG
                printf("%s: babble\n", device_xname(sc->sc_dev));
 #endif
-               sc->sc_if.if_oerrors++;
+               if_statinc(&sc->sc_if, if_oerrors);
        }
 
        if (ir & CERR) {
 #ifdef MCDEBUG
                printf("%s: collision error\n", device_xname(sc->sc_dev));
 #endif
-               sc->sc_if.if_collisions++;
+               if_statinc(&sc->sc_if, if_collisions);
        }
 
        /*
@@ -481,29 +481,33 @@
                return;
        }
 
+       net_stat_ref_t nsr = IF_STAT_GETREF(&sc->sc_if);
+
        if (xmtfs & LCOL) {
                printf("%s: late collision\n", device_xname(sc->sc_dev));
-               sc->sc_if.if_oerrors++;
-               sc->sc_if.if_collisions++;
+               if_statinc_ref(nsr, if_oerrors);
+               if_statinc_ref(nsr, if_collisions);
        }
 
        if (xmtfs & MORE)
                /* Real number is unknown. */
-               sc->sc_if.if_collisions += 2;
+               if_statadd_ref(nsr, if_collsions, 2);
        else if (xmtfs & ONE)
-               sc->sc_if.if_collisions++;
+               if_statinc_ref(nsr, if_collisions);
        else if (xmtfs & RTRY) {
                printf("%s: excessive collisions\n", device_xname(sc->sc_dev));
-               sc->sc_if.if_collisions += 16;
-               sc->sc_if.if_oerrors++;
+               if_statadd_ref(nsr, if_collsions, 16);
+               if_statinc_ref(nsr, if_oerrors);
        }
 
        if (xmtfs & LCAR) {
                sc->sc_havecarrier = 0;
                printf("%s: lost carrier\n", device_xname(sc->sc_dev));
-               sc->sc_if.if_oerrors++;
+               if_statinc_ref(nsr, if_oerrors);
        }
 
+       IF_STAT_PUTREF(&sc->sc_if);
+
        sc->sc_if.if_flags &= ~IFF_OACTIVE;
        sc->sc_if.if_timer = 0;
        if_schedule_deferred_start(&sc->sc_if);
@@ -526,18 +530,18 @@
 
        if (rxf.rx_rcvsts & OFLO) {
                printf("%s: receive FIFO overflow\n", device_xname(sc->sc_dev));
-               sc->sc_if.if_ierrors++;
+               if_statinc(&sc->sc_if, if_ierrors);
                return;
        }
 
        if (rxf.rx_rcvsts & CLSN)
-               sc->sc_if.if_collisions++;
+               if_statinc(&sc->sc_if, if_collisions);
 
        if (rxf.rx_rcvsts & FRAM) {
 #ifdef MCDEBUG
                printf("%s: framing error\n", device_xname(sc->sc_dev));
 #endif
-               sc->sc_if.if_ierrors++;
+               if_statinc(&sc->sc_if, if_ierrors);
                return;
        }
 
@@ -545,7 +549,7 @@
 #ifdef MCDEBUG
                printf("%s: frame control checksum error\n", device_xname(sc->sc_dev));
 #endif
-               sc->sc_if.if_ierrors++;
+               if_statinc(&sc->sc_if, if_ierrors);



Home | Main Index | Thread Index | Old Index