Module Name:    src
Committed By:   thorpej
Date:           Wed Jan 29 14:09:58 UTC 2020

Modified Files:
        src/sys/dev/ic: aic6915.c an.c arn5008.c arn9003.c ath.c athn.c atw.c
            awi.c

Log Message:
Adopt <net/if_stats.h>.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/ic/aic6915.c
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/ic/an.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/arn5008.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/arn9003.c
cvs rdiff -u -r1.129 -r1.130 src/sys/dev/ic/ath.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/athn.c
cvs rdiff -u -r1.169 -r1.170 src/sys/dev/ic/atw.c
cvs rdiff -u -r1.99 -r1.100 src/sys/dev/ic/awi.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/ic/aic6915.c
diff -u src/sys/dev/ic/aic6915.c:1.40 src/sys/dev/ic/aic6915.c:1.41
--- src/sys/dev/ic/aic6915.c:1.40	Wed Oct 30 07:26:28 2019
+++ src/sys/dev/ic/aic6915.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aic6915.c,v 1.40 2019/10/30 07:26:28 msaitoh Exp $	*/
+/*	$NetBSD: aic6915.c,v 1.41 2020/01/29 14:09:58 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aic6915.c,v 1.40 2019/10/30 07:26:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aic6915.c,v 1.41 2020/01/29 14:09:58 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -502,7 +502,7 @@ sf_watchdog(struct ifnet *ifp)
 	struct sf_softc *sc = ifp->if_softc;
 
 	printf("%s: device timeout\n", device_xname(sc->sc_dev));
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 
 	(void) sf_init(ifp);
 
@@ -746,7 +746,7 @@ sf_rxintr(struct sf_softc *sc)
 		 */
 		m = ds->ds_mbuf;
 		if (sf_add_rxbuf(sc, rxidx) != 0) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			SF_INIT_RXDESC(sc, rxidx);
 			bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0,
 			    ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -762,7 +762,7 @@ sf_rxintr(struct sf_softc *sc)
 		MGETHDR(m, M_DONTWAIT, MT_DATA);
 		if (m == NULL) {
  dropit:
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			SF_INIT_RXDESC(sc, rxidx);
 			bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0,
 			    ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -846,19 +846,26 @@ sf_stats_update(struct sf_softc *sc)
 		sf_genreg_write(sc, SF_STATS_BASE + (i * sizeof(uint32_t)), 0);
 	}
 
-	ifp->if_opackets += stats.TransmitOKFrames;
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 
-	ifp->if_collisions += stats.SingleCollisionFrames +
-	    stats.MultipleCollisionFrames;
+	if_statadd_ref(nsr, if_opackets, stats.TransmitOKFrames);
 
-	ifp->if_oerrors += stats.TransmitAbortDueToExcessiveCollisions +
+	if_statadd_ref(nsr, if_collisions,
+	    stats.SingleCollisionFrames +
+	    stats.MultipleCollisionFrames);
+
+	if_statadd_ref(nsr, if_oerrors,
+	    stats.TransmitAbortDueToExcessiveCollisions +
 	    stats.TransmitAbortDueToExcessingDeferral +
-	    stats.FramesLostDueToInternalTransmitErrors;
+	    stats.FramesLostDueToInternalTransmitErrors);
 
-	ifp->if_ierrors += stats.ReceiveCRCErrors + stats.AlignmentErrors +
+	if_statadd_ref(nsr, if_ierrors,
+	    stats.ReceiveCRCErrors + stats.AlignmentErrors +
 	    stats.ReceiveFramesTooLong + stats.ReceiveFramesTooShort +
 	    stats.ReceiveFramesJabbersError +
-	    stats.FramesLostDueToInternalReceiveErrors;
+	    stats.FramesLostDueToInternalReceiveErrors);
+
+	IF_STAT_PUTREF(ifp);
 }
 
 /*

Index: src/sys/dev/ic/an.c
diff -u src/sys/dev/ic/an.c:1.72 src/sys/dev/ic/an.c:1.73
--- src/sys/dev/ic/an.c:1.72	Mon Sep 23 17:37:04 2019
+++ src/sys/dev/ic/an.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $	*/
+/*	$NetBSD: an.c,v 1.73 2020/01/29 14:09:58 thorpej Exp $	*/
 /*
  * Copyright (c) 1997, 1998, 1999
  *	Bill Paul <[email protected]>.  All rights reserved.
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.73 2020/01/29 14:09:58 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -755,7 +755,7 @@ an_start(struct ifnet *ifp)
 			break;
 		}
 		IFQ_DEQUEUE(&ifp->if_snd, m);
-		ifp->if_opackets++;
+		if_statinc(ifp, if_opackets);
 		bpf_mtap(ifp, m, BPF_D_OUT);
 		eh = mtod(m, struct ether_header *);
 		ni = ieee80211_find_txnode(ic, eh->ether_dhost);
@@ -853,7 +853,7 @@ an_start(struct ifnet *ifp)
 		sc->sc_txnext = cur;
 		continue;
 bad:
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		m_freem(m);
 	}
 }
@@ -891,7 +891,7 @@ an_watchdog(struct ifnet *ifp)
 	if (sc->sc_tx_timer) {
 		if (--sc->sc_tx_timer == 0) {
 			printf("%s: device timeout\n", ifp->if_xname);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			an_init(ifp);
 			return;
 		}
@@ -1390,7 +1390,7 @@ an_rx_intr(struct an_softc *sc)
 	/* First read in the frame header */
 	if (an_read_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr)) != 0) {
 		CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		DPRINTF(("an_rx_intr: read fid %x failed\n", fid));
 		return;
 	}
@@ -1414,7 +1414,7 @@ an_rx_intr(struct an_softc *sc)
 	if ((status & AN_STAT_ERRSTAT) != 0 &&
 	    ic->ic_opmode != IEEE80211_M_MONITOR) {
 		CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		DPRINTF(("an_rx_intr: fid %x status %x\n", fid, status));
 		return;
 	}
@@ -1426,7 +1426,7 @@ an_rx_intr(struct an_softc *sc)
 	if (off + len > MCLBYTES) {
 		if (ic->ic_opmode != IEEE80211_M_MONITOR) {
 			CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			DPRINTF(("an_rx_intr: oversized packet %d\n", len));
 			return;
 		}
@@ -1436,7 +1436,7 @@ an_rx_intr(struct an_softc *sc)
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == NULL) {
 		CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		DPRINTF(("an_rx_intr: MGET failed\n"));
 		return;
 	}
@@ -1445,7 +1445,7 @@ an_rx_intr(struct an_softc *sc)
 		if ((m->m_flags & M_EXT) == 0) {
 			CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX);
 			m_freem(m);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			DPRINTF(("an_rx_intr: MCLGET failed\n"));
 			return;
 		}
@@ -1457,7 +1457,7 @@ an_rx_intr(struct an_softc *sc)
 		if (gaplen > AN_GAPLEN_MAX) {
 			CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX);
 			m_freem(m);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			DPRINTF(("%s: gap too long\n", __func__));
 			return;
 		}
@@ -1549,9 +1549,9 @@ an_tx_intr(struct an_softc *sc, int stat
 	CSR_WRITE_2(sc, AN_EVENT_ACK, status & (AN_EV_TX | AN_EV_TX_EXC));
 
 	if (status & AN_EV_TX_EXC)
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 	else
-		ifp->if_opackets++;
+		if_statinc(ifp, if_opackets);
 
 	cur = sc->sc_txcur;
 	if (sc->sc_txd[cur].d_fid == fid) {

Index: src/sys/dev/ic/arn5008.c
diff -u src/sys/dev/ic/arn5008.c:1.16 src/sys/dev/ic/arn5008.c:1.17
--- src/sys/dev/ic/arn5008.c:1.16	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/arn5008.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arn5008.c,v 1.16 2019/11/10 21:16:35 chs Exp $	*/
+/*	$NetBSD: arn5008.c,v 1.17 2020/01/29 14:09:58 thorpej Exp $	*/
 /*	$OpenBSD: ar5008.c,v 1.21 2012/08/25 12:14:31 kettenis Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.16 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.17 2020/01/29 14:09:58 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -822,7 +822,7 @@ ar5008_rx_process(struct athn_softc *sc)
 			/* HW will not "move" RXDP in this case, so do it. */
 			AR_WRITE(sc, AR_RXDP, nbf->bf_daddr);
 			AR_WRITE_BARRIER(sc);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 		return EBUSY;
@@ -831,7 +831,7 @@ ar5008_rx_process(struct athn_softc *sc)
 	if (__predict_false(ds->ds_status1 & AR_RXS1_MORE)) {
 		/* Drop frames that span multiple Rx descriptors. */
 		DPRINTFN(DBG_RX, sc, "dropping split frame\n");
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 	if (!(ds->ds_status8 & AR_RXS8_FRAME_OK)) {
@@ -854,14 +854,14 @@ ar5008_rx_process(struct athn_softc *sc)
 			/* Report Michael MIC failures to net80211. */
 			ieee80211_notify_michael_failure(ic, wh, 0 /* XXX: keyix */);
 		}
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
 	len = MS(ds->ds_status1, AR_RXS1_DATA_LEN);
 	if (__predict_false(len < (int)IEEE80211_MIN_LEN || len > ATHN_RXBUFSZ)) {
 		DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%d\n", len);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -869,7 +869,7 @@ ar5008_rx_process(struct athn_softc *sc)
 	m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ);
 	if (__predict_false(m1 == NULL)) {
 		ic->ic_stats.is_rx_nobuf++;
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -889,7 +889,7 @@ ar5008_rx_process(struct athn_softc *sc)
 		    mtod(bf->bf_m, void *), ATHN_RXBUFSZ, NULL,
 		    BUS_DMA_NOWAIT | BUS_DMA_READ);
 		KASSERT(error != 0);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -985,12 +985,12 @@ ar5008_tx_process(struct athn_softc *sc,
 		return EBUSY;
 
 	SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list);
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 
 	sc->sc_tx_timer = 0;
 
 	if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES)
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 
 	if (ds->ds_status1 & AR_TXS1_UNDERRUN)
 		athn_inc_tx_trigger_level(sc);
@@ -1171,7 +1171,7 @@ ar5008_swba_intr(struct athn_softc *sc)
 
 		if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) {
 			ieee80211_free_node(ni);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 	}

Index: src/sys/dev/ic/arn9003.c
diff -u src/sys/dev/ic/arn9003.c:1.14 src/sys/dev/ic/arn9003.c:1.15
--- src/sys/dev/ic/arn9003.c:1.14	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/arn9003.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arn9003.c,v 1.14 2019/11/10 21:16:35 chs Exp $	*/
+/*	$NetBSD: arn9003.c,v 1.15 2020/01/29 14:09:58 thorpej Exp $	*/
 /*	$OpenBSD: ar9003.c,v 1.25 2012/10/20 09:53:32 stsp Exp $	*/
 
 /*-
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arn9003.c,v 1.14 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arn9003.c,v 1.15 2020/01/29 14:09:58 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -985,7 +985,7 @@ ar9003_rx_process(struct athn_softc *sc,
 			ieee80211_notify_michael_failure(ic, wh,
 			    0 /* XXX: keyix */);
 		}
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -994,7 +994,7 @@ ar9003_rx_process(struct athn_softc *sc,
 	    len > ATHN_RXBUFSZ - sizeof(*ds))) {
 		DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%zd\n",
 		    len);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -1002,7 +1002,7 @@ ar9003_rx_process(struct athn_softc *sc,
 	m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ);
 	if (__predict_false(m1 == NULL)) {
 		ic->ic_stats.is_rx_nobuf++;
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -1021,7 +1021,7 @@ ar9003_rx_process(struct athn_softc *sc,
 		    BUS_DMA_NOWAIT | BUS_DMA_READ);
 		KASSERT(error != 0);
 		bf->bf_daddr = bf->bf_map->dm_segs[0].ds_addr;
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 	bf->bf_desc = mtod(m1, struct ar_rx_status *);
@@ -1127,12 +1127,12 @@ ar9003_tx_process(struct athn_softc *sc)
 		return 0;
 	}
 	SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list);
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 
 	sc->sc_tx_timer = 0;
 
 	if (ds->ds_status3 & AR_TXS3_EXCESSIVE_RETRIES)
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 
 	if (ds->ds_status3 & AR_TXS3_UNDERRUN)
 		athn_inc_tx_trigger_level(sc);
@@ -1329,7 +1329,7 @@ ar9003_swba_intr(struct athn_softc *sc)
 
 		if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) {
 			ieee80211_free_node(ni);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 	}

Index: src/sys/dev/ic/ath.c
diff -u src/sys/dev/ic/ath.c:1.129 src/sys/dev/ic/ath.c:1.130
--- src/sys/dev/ic/ath.c:1.129	Tue Dec 17 04:54:36 2019
+++ src/sys/dev/ic/ath.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ath.c,v 1.129 2019/12/17 04:54:36 christos Exp $	*/
+/*	$NetBSD: ath.c,v 1.130 2020/01/29 14:09:58 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -41,7 +41,7 @@
 __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.129 2019/12/17 04:54:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.130 2020/01/29 14:09:58 thorpej Exp $");
 #endif
 
 /*
@@ -1400,7 +1400,7 @@ ath_start(struct ifnet *ifp)
 				m_freem(m);
 				goto bad;
 			}
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 
 			bpf_mtap(ifp, m, BPF_D_OUT);
 			/*
@@ -1462,7 +1462,7 @@ ath_start(struct ifnet *ifp)
 		next = m->m_nextpkt;
 		if (ath_tx_start(sc, ni, bf, m)) {
 	bad:
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 	reclaim:
 			ATH_TXBUF_LOCK(sc);
 			STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
@@ -3166,7 +3166,7 @@ ath_rx_proc(void *arg, int npending)
 						ds->ds_rxstat.rs_keyix-32 : ds->ds_rxstat.rs_keyix);
 				}
 			}
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			/*
 			 * Reject error frames, we normally don't want
 			 * to see them in monitor mode (in monitor mode
@@ -5294,7 +5294,7 @@ ath_watchdog(struct ifnet *ifp)
 			if (sc->sc_txintrperiod > 1)
 				sc->sc_txintrperiod--;
 			ath_reset(ifp);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			sc->sc_stats.ast_watchdog++;
 			break;
 		} else
@@ -5408,20 +5408,24 @@ ath_ioctl(struct ifnet *ifp, u_long cmd,
 			error = 0;
 		}
 		break;
-	case SIOCGATHSTATS:
+	case SIOCGATHSTATS: {
+		struct ath_stats stats_out;
+		struct if_data ifi;
+
 		/* NB: embed these numbers to get a consistent view */
-		sc->sc_stats.ast_tx_packets = ifp->if_opackets;
-		sc->sc_stats.ast_rx_packets = ifp->if_ipackets;
-		sc->sc_stats.ast_rx_rssi = ieee80211_getrssi(ic);
+
+		stats_out = sc->sc_stats;
+		stats_out.ast_rx_rssi = ieee80211_getrssi(ic);
 		splx(s);
-		/*
-		 * NB: Drop the softc lock in case of a page fault;
-		 * we'll accept any potential inconsisentcy in the
-		 * statistics.  The alternative is to copy the data
-		 * to a local structure.
-		 */
-		return copyout(&sc->sc_stats,
-				ifr->ifr_data, sizeof (sc->sc_stats));
+
+		if_export_if_data(ifp, &ifi, false);
+		stats_out.ast_tx_packets = ifi.ifi_opackets;
+		stats_out.ast_rx_packets = ifi.ifi_ipackets;
+
+		return copyout(&stats_out,
+				ifr->ifr_data, sizeof (stats_out));
+	    }
+
 	case SIOCGATHDIAG:
 		error = kauth_authorize_network(curlwp->l_cred,
 		    KAUTH_NETWORK_INTERFACE,

Index: src/sys/dev/ic/athn.c
diff -u src/sys/dev/ic/athn.c:1.22 src/sys/dev/ic/athn.c:1.23
--- src/sys/dev/ic/athn.c:1.22	Thu Jul 25 11:56:09 2019
+++ src/sys/dev/ic/athn.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: athn.c,v 1.22 2019/07/25 11:56:09 msaitoh Exp $	*/
+/*	$NetBSD: athn.c,v 1.23 2020/01/29 14:09:58 thorpej Exp $	*/
 /*	$OpenBSD: athn.c,v 1.83 2014/07/22 13:12:11 mpi Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.22 2019/07/25 11:56:09 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.23 2020/01/29 14:09:58 thorpej Exp $");
 
 #ifndef _MODULE
 #include "athn_usb.h"		/* for NATHN_USB */
@@ -2671,14 +2671,14 @@ athn_start(struct ifnet *ifp)
 
 		if (m->m_len < (int)sizeof(*eh) &&
 		    (m = m_pullup(m, sizeof(*eh))) == NULL) {
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 		eh = mtod(m, struct ether_header *);
 		ni = ieee80211_find_txnode(ic, eh->ether_dhost);
 		if (ni == NULL) {
 			m_freem(m);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -2691,7 +2691,7 @@ athn_start(struct ifnet *ifp)
 
 		if (sc->sc_ops.tx(sc, m, ni, 0) != 0) {
 			ieee80211_free_node(ni);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -2713,7 +2713,7 @@ athn_watchdog(struct ifnet *ifp)
 			/* see athn_init, no need to call athn_stop here */
 			/* athn_stop(ifp, 0); */
 			(void)athn_init(ifp);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;

Index: src/sys/dev/ic/atw.c
diff -u src/sys/dev/ic/atw.c:1.169 src/sys/dev/ic/atw.c:1.170
--- src/sys/dev/ic/atw.c:1.169	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/atw.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: atw.c,v 1.169 2019/11/10 21:16:35 chs Exp $  */
+/*	$NetBSD: atw.c,v 1.170 2020/01/29 14:09:58 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.169 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.170 2020/01/29 14:09:58 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -3153,7 +3153,7 @@ atw_rxintr(struct atw_softc *sc)
 			if (rxstat & (bit))				\
 				aprint_error_dev(sc->sc_dev, "receive error: %s\n",	\
 				    str)
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			PRINTERR(ATW_RXSTAT_DE, "descriptor error");
 			PRINTERR(ATW_RXSTAT_RXTOE, "time-out");
 #if 0
@@ -3183,14 +3183,14 @@ atw_rxintr(struct atw_softc *sc)
 		 */
 		m = rxs->rxs_mbuf;
 		if (atw_add_rxbuf(sc, i) != 0) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
 			    rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
 			atw_init_rxdesc(sc, i);
 			continue;
 		}
 
-		ifp->if_ipackets++;
+		if_statinc(ifp, if_ipackets);
 		m_set_rcvif(m, ifp);
 		m->m_pkthdr.len = m->m_len = MIN(m->m_ext.ext_size, len);
 
@@ -3246,7 +3246,7 @@ atw_rxintr(struct atw_softc *sc)
 				sc->sc_sfde_ev.ev_count++;
 			if (rxstat & ATW_RXSTAT_SIGE)
 				sc->sc_sige_ev.ev_count++;
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			m_freem(m);
 			splx(s);
 			continue;
@@ -3370,12 +3370,12 @@ atw_txintr(struct atw_softc *sc, uint32_
 			sc->sc_sofbr_ev.ev_count++;
 
 		if ((txstat & ATW_TXSTAT_ES) == 0)
-			ifp->if_collisions +=
-			    __SHIFTOUT(txstat, ATW_TXSTAT_ARC_MASK);
+			if_statadd(ifp, if_collisions,
+			    __SHIFTOUT(txstat, ATW_TXSTAT_ARC_MASK));
 		else
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 
-		ifp->if_opackets++;
+		if_statinc(ifp, if_opackets);
 	}
 
 	KASSERT(txs != NULL || (ifp->if_flags & IFF_OACTIVE) == 0);
@@ -3403,7 +3403,7 @@ atw_watchdog(struct ifnet *ifp)
 	if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0 &&
 	    !SIMPLEQ_EMPTY(&sc->sc_txdirtyq)) {
 		printf("%s: transmit timeout\n", ifp->if_xname);
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		(void)atw_init(ifp);
 		atw_start(ifp);
 	}
@@ -3566,12 +3566,12 @@ atw_start(struct ifnet *ifp)
 			ni = ieee80211_find_txnode(ic,
 			    mtod(m0, struct ether_header *)->ether_dhost);
 			if (ni == NULL) {
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				break;
 			}
 			if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) {
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				break;
 			}
 		}
@@ -3585,7 +3585,7 @@ atw_start(struct ifnet *ifp)
 		else if ((k = ieee80211_crypto_encap(ic, ni, m0)) == NULL) {
 			m_freem(m0);
 			ieee80211_free_node(ni);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 #if 0
@@ -3630,7 +3630,7 @@ atw_start(struct ifnet *ifp)
 			ieee80211_free_node(ni);
 
 		if (m0 == NULL) {
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 
@@ -3638,7 +3638,7 @@ atw_start(struct ifnet *ifp)
 		m0 = m_pullup(m0, sizeof(struct atw_frame));
 
 		if (m0 == NULL) {
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 

Index: src/sys/dev/ic/awi.c
diff -u src/sys/dev/ic/awi.c:1.99 src/sys/dev/ic/awi.c:1.100
--- src/sys/dev/ic/awi.c:1.99	Thu Dec  5 03:11:40 2019
+++ src/sys/dev/ic/awi.c	Wed Jan 29 14:09:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: awi.c,v 1.99 2019/12/05 03:11:40 msaitoh Exp $	*/
+/*	$NetBSD: awi.c,v 1.100 2020/01/29 14:09:58 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.99 2019/12/05 03:11:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.100 2020/01/29 14:09:58 thorpej Exp $");
 
 #include "opt_inet.h"
 
@@ -706,12 +706,12 @@ awi_start(struct ifnet *ifp)
 				break;
 			}
 			IFQ_DEQUEUE(&ifp->if_snd, m0);
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 			bpf_mtap(ifp, m0, BPF_D_OUT);
 			eh = mtod(m0, struct ether_header *);
 			ni = ieee80211_find_txnode(ic, eh->ether_dhost);
 			if (ni == NULL) {
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				continue;
 			}
 			if ((ifp->if_flags & IFF_LINK0) || sc->sc_adhoc_ap)
@@ -721,7 +721,7 @@ awi_start(struct ifnet *ifp)
 			}
 			if (m0 == NULL) {
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				continue;
 			}
 			wh = mtod(m0, struct ieee80211_frame *);
@@ -734,7 +734,7 @@ awi_start(struct ifnet *ifp)
 			    IEEE80211_FC0_TYPE_DATA) {
 				m_freem(m0);
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				continue;
 			}
 		}
@@ -743,7 +743,7 @@ awi_start(struct ifnet *ifp)
 			if ((ieee80211_crypto_encap(ic, ni, m0)) == NULL) {
 				m_freem(m0);
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				continue;
 			}
 		}
@@ -753,7 +753,7 @@ awi_start(struct ifnet *ifp)
 			printf("%s: length %d should be %d\n",
 			    sc->sc_if.if_xname, m0->m_pkthdr.len, len);
 			m_freem(m0);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 #endif
@@ -806,7 +806,7 @@ awi_watchdog(struct ifnet *ifp)
 			prevdone = sc->sc_txdone;
 			awi_tx_int(sc);
 			if (sc->sc_txdone == prevdone) {
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				awi_init(ifp);
 				goto out;
 			}
@@ -1084,7 +1084,7 @@ awi_rx_int(struct awi_softc *sc)
 			if (sc->sc_substate != AWI_ST_NONE)
 				goto rx_next;
 			if (state & AWI_RXD_ST_RXERROR) {
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				goto rx_next;
 			}
 			len    = awi_read_2(sc, rxoff + AWI_RXD_LEN);
@@ -1095,7 +1095,7 @@ awi_rx_int(struct awi_softc *sc)
 			rstamp = awi_read_4(sc, rxoff + AWI_RXD_LOCALTIME);
 			m = awi_devget(sc, frame, len);
 			if (m == NULL) {
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				goto rx_next;
 			}
 			if (state & AWI_RXD_ST_LF) {
@@ -1115,7 +1115,7 @@ awi_rx_int(struct awi_softc *sc)
 				else
 					m = m_pullup(m, sizeof(*wh));
 				if (m == NULL) {
-					ifp->if_ierrors++;
+					if_statinc(ifp, if_ierrors);
 					goto rx_next;
 				}
 				wh = mtod(m, struct ieee80211_frame_min *);
@@ -1159,7 +1159,7 @@ awi_tx_int(struct awi_softc *sc)
 		if ((flags & AWI_TXD_ST_OWN) || !(flags & AWI_TXD_ST_DONE))
 			break;
 		if (flags & AWI_TXD_ST_ERROR)
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 		sc->sc_txdone = awi_read_4(sc, sc->sc_txdone + AWI_TXD_NEXT) &
 		    0x7fff;
 	}

Reply via email to