Thu Jan 30 05:24:53 2020 UTC ()
Adopt <net/if_stats.h>.


(thorpej)
diff -r1.37 -r1.38 src/sys/dev/pci/if_cas.c
diff -r1.56 -r1.57 src/sys/dev/pci/if_dge.c
diff -r1.58 -r1.59 src/sys/dev/pci/if_ste.c
diff -r1.77 -r1.78 src/sys/dev/pci/if_stge.c
diff -r1.118 -r1.119 src/sys/dev/pci/if_tl.c
diff -r1.78 -r1.79 src/sys/dev/pci/if_vge.c
diff -r1.131 -r1.132 src/sys/dev/pci/if_vr.c

cvs diff -r1.37 -r1.38 src/sys/dev/pci/if_cas.c (expand / switch to context diff)
--- src/sys/dev/pci/if_cas.c 2019/12/26 17:51:08 1.37
+++ src/sys/dev/pci/if_cas.c 2020/01/30 05:24:53 1.38
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cas.c,v 1.37 2019/12/26 17:51:08 msaitoh Exp $	*/
+/*	$NetBSD: if_cas.c,v 1.38 2020/01/30 05:24:53 thorpej Exp $	*/
 /*	$OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $	*/
 
 /*
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.37 2019/12/26 17:51:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.38 2020/01/30 05:24:53 thorpej Exp $");
 
 #ifndef _MODULE
 #include "opt_inet.h"
@@ -842,21 +842,25 @@
 	int s;
 	uint32_t v;
 
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
 	/* unload collisions counters */
 	v = bus_space_read_4(t, mac, CAS_MAC_EXCESS_COLL_CNT) +
 	    bus_space_read_4(t, mac, CAS_MAC_LATE_COLL_CNT);
-	ifp->if_collisions += v +
+	if_statadd_ref(nsr, if_collisions, v +
 	    bus_space_read_4(t, mac, CAS_MAC_NORM_COLL_CNT) +
-	    bus_space_read_4(t, mac, CAS_MAC_FIRST_COLL_CNT);
-	ifp->if_oerrors += v;
+	    bus_space_read_4(t, mac, CAS_MAC_FIRST_COLL_CNT));
+	if_statadd_ref(nsr, if_oerrors, v);
 
 	/* read error counters */
-	ifp->if_ierrors +=
+	if_statadd_ref(nsr, if_ierrors,
 	    bus_space_read_4(t, mac, CAS_MAC_RX_LEN_ERR_CNT) +
 	    bus_space_read_4(t, mac, CAS_MAC_RX_ALIGN_ERR) +
 	    bus_space_read_4(t, mac, CAS_MAC_RX_CRC_ERR_CNT) +
-	    bus_space_read_4(t, mac, CAS_MAC_RX_CODE_VIOL);
+	    bus_space_read_4(t, mac, CAS_MAC_RX_CODE_VIOL));
 
+	IF_STAT_PUTREF(ifp);
+
 	/* clear the hardware counters */
 	bus_space_write_4(t, mac, CAS_MAC_NORM_COLL_CNT, 0);
 	bus_space_write_4(t, mac, CAS_MAC_FIRST_COLL_CNT, 0);
@@ -1416,7 +1420,7 @@
 				m->m_pkthdr.csum_flags = 0;
 				if_percpuq_enqueue(ifp->if_percpuq, m);
 			} else
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 		}
 
 		len = CAS_RC0_DATA_LEN(word[0]);
@@ -1446,7 +1450,7 @@
 				m->m_pkthdr.csum_flags = 0;
 				if_percpuq_enqueue(ifp->if_percpuq, m);
 			} else
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 		}
 
 		if (word[0] & CAS_RC0_SPLIT)
@@ -1586,7 +1590,7 @@
 		 * due to a silicon bug so handle them silently.
 		 */
 		if (rxstat & CAS_MAC_RX_OVERFLOW) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			cas_init(ifp);
 		}
 #ifdef CAS_DEBUG
@@ -1612,7 +1616,7 @@
 		bus_space_read_4(sc->sc_memt, sc->sc_memh, CAS_MAC_RX_CONFIG)));
 
 	log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
-	++ifp->if_oerrors;
+	if_statinc(ifp, if_oerrors);
 
 	/* Try to get more packets going. */
 	cas_init(ifp);
@@ -2131,7 +2135,7 @@
 			bus_dmamap_unload(sc->sc_dmatag, sd->sd_map);
 			m_freem(sd->sd_mbuf);
 			sd->sd_mbuf = NULL;
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 		}
 		sc->sc_tx_cnt--;
 		if (++cons == CAS_NTXDESC)

cvs diff -r1.56 -r1.57 src/sys/dev/pci/if_dge.c (expand / switch to context diff)
--- src/sys/dev/pci/if_dge.c 2019/11/10 21:16:36 1.56
+++ src/sys/dev/pci/if_dge.c 2020/01/30 05:24:53 1.57
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_dge.c,v 1.56 2019/11/10 21:16:36 chs Exp $ */
+/*	$NetBSD: if_dge.c,v 1.57 2020/01/30 05:24:53 thorpej Exp $ */
 
 /*
  * Copyright (c) 2004, SUNET, Swedish University Computer Network.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.56 2019/11/10 21:16:36 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.57 2020/01/30 05:24:53 thorpej Exp $");
 
 
 
@@ -1425,7 +1425,7 @@
 		printf("%s: device timeout (txfree %d txsfree %d txnext %d)\n",
 		    device_xname(sc->sc_dev), sc->sc_txfree, sc->sc_txsfree,
 		    sc->sc_txnext);
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 
 		/* Reset the interface. */
 		(void) dge_init(ifp);
@@ -1622,7 +1622,7 @@
 		    device_xname(sc->sc_dev), i, txs->txs_firstdesc,
 		    txs->txs_lastdesc));
 
-		ifp->if_opackets++;
+		if_statinc(ifp, if_opackets);
 		sc->sc_txfree += txs->txs_ndesc;
 		bus_dmamap_sync(sc->sc_dmat, txs->txs_dmamap,
 		    0, txs->txs_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE);
@@ -1706,7 +1706,7 @@
 			 * Failed, throw away what we've done so
 			 * far, and discard the rest of the packet.
 			 */
-			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);
 			DGE_INIT_RXDESC(sc, i);
@@ -1761,7 +1761,7 @@
 		 */
 		if (errors & (RDESC_ERR_CE | RDESC_ERR_SE | RDESC_ERR_P |
 		    RDESC_ERR_RXE)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			if (errors & RDESC_ERR_SE)
 				printf("%s: symbol error\n",
 				    device_xname(sc->sc_dev));

cvs diff -r1.58 -r1.59 src/sys/dev/pci/if_ste.c (expand / switch to context diff)
--- src/sys/dev/pci/if_ste.c 2019/11/02 21:11:55 1.58
+++ src/sys/dev/pci/if_ste.c 2020/01/30 05:24:53 1.59
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ste.c,v 1.58 2019/11/02 21:11:55 tnn Exp $	*/
+/*	$NetBSD: if_ste.c,v 1.59 2020/01/30 05:24:53 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.58 2019/11/02 21:11:55 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.59 2020/01/30 05:24:53 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -780,7 +780,7 @@
 	struct ste_softc *sc = ifp->if_softc;
 
 	printf("%s: device timeout\n", device_xname(sc->sc_dev));
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 
 	ste_txintr(sc);
 	ste_rxintr(sc);
@@ -1039,7 +1039,7 @@
 			m = ds->ds_mbuf;
 			if (ste_add_rxbuf(sc, i) != 0) {
  dropit:
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				STE_INIT_RXDESC(sc, i);
 				bus_dmamap_sync(sc->sc_dmat,
 				    ds->ds_dmamap, 0,
@@ -1097,25 +1097,29 @@
 	(void) bus_space_read_2(st, sh, STE_OctetsTransmittedOk0);
 	(void) bus_space_read_2(st, sh, STE_OctetsTransmittedOk1);
 
-	ifp->if_opackets +=
-	    (u_int) bus_space_read_2(st, sh, STE_FramesTransmittedOK);
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 
+	if_statadd_ref(nsr, if_opackets,
+	    (u_int) bus_space_read_2(st, sh, STE_FramesTransmittedOK));
+
 	(void) bus_space_read_2(st, sh, STE_FramesReceivedOK);
 
-	ifp->if_collisions +=
+	if_statadd_ref(nsr, if_collisions,
 	    (u_int) bus_space_read_1(st, sh, STE_LateCollisions) +
 	    (u_int) bus_space_read_1(st, sh, STE_MultipleColFrames) +
-	    (u_int) bus_space_read_1(st, sh, STE_SingleColFrames);
+	    (u_int) bus_space_read_1(st, sh, STE_SingleColFrames));
 
 	(void) bus_space_read_1(st, sh, STE_FramesWDeferredXmt);
 
-	ifp->if_ierrors +=
-	    (u_int) bus_space_read_1(st, sh, STE_FramesLostRxErrors);
+	if_statadd_ref(nsr, if_ierrors,
+	    (u_int) bus_space_read_1(st, sh, STE_FramesLostRxErrors));
 
-	ifp->if_oerrors +=
+	if_statadd_ref(nsr, if_oerrors,
 	    (u_int) bus_space_read_1(st, sh, STE_FramesWExDeferral) +
 	    (u_int) bus_space_read_1(st, sh, STE_FramesXbortXSColls) +
-	    bus_space_read_1(st, sh, STE_CarrierSenseErrors);
+	    bus_space_read_1(st, sh, STE_CarrierSenseErrors));
+
+	IF_STAT_PUTREF(ifp);
 
 	(void) bus_space_read_1(st, sh, STE_BcstFramesXmtdOk);
 	(void) bus_space_read_1(st, sh, STE_BcstFramesRcvdOk);

cvs diff -r1.77 -r1.78 src/sys/dev/pci/if_stge.c (expand / switch to context diff)
--- src/sys/dev/pci/if_stge.c 2020/01/14 09:49:26 1.77
+++ src/sys/dev/pci/if_stge.c 2020/01/30 05:24:53 1.78
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_stge.c,v 1.77 2020/01/14 09:49:26 msaitoh Exp $	*/
+/*	$NetBSD: if_stge.c,v 1.78 2020/01/30 05:24:53 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.77 2020/01/14 09:49:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.78 2020/01/30 05:24:53 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -1028,7 +1028,7 @@
 	stge_txintr(sc);
 	if (sc->sc_txpending != 0) {
 		printf("%s: device timeout\n", device_xname(sc->sc_dev));
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 
 		(void) stge_init(ifp);
 
@@ -1261,7 +1261,7 @@
 			 * Failed, throw away what we've done so
 			 * far, and discard the rest of the packet.
 			 */
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0,
 			    ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD);
 			STGE_INIT_RXDESC(sc, i);
@@ -1331,7 +1331,7 @@
 			struct mbuf *nm;
 			MGETHDR(nm, M_DONTWAIT, MT_DATA);
 			if (nm == NULL) {
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				m_freem(m);
 				continue;
 			}
@@ -1433,22 +1433,26 @@
 
 	(void) CSR_READ_4(sc, STGE_FramesRcvdOk);
 
-	ifp->if_ierrors +=
-	    (u_int) CSR_READ_2(sc, STGE_FramesLostRxErrors);
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 
+	if_statadd_ref(nsr, if_ierrors,
+	    (u_int) CSR_READ_2(sc, STGE_FramesLostRxErrors));
+
 	(void) CSR_READ_4(sc, STGE_OctetXmtdOk);
 
-	ifp->if_opackets +=
-	    CSR_READ_4(sc, STGE_FramesXmtdOk);
+	if_statadd_ref(nsr, if_opackets,
+	    CSR_READ_4(sc, STGE_FramesXmtdOk));
 
-	ifp->if_collisions +=
+	if_statadd_ref(nsr, if_collisions,
 	    CSR_READ_4(sc, STGE_LateCollisions) +
 	    CSR_READ_4(sc, STGE_MultiColFrames) +
-	    CSR_READ_4(sc, STGE_SingleColFrames);
+	    CSR_READ_4(sc, STGE_SingleColFrames));
 
-	ifp->if_oerrors +=
+	if_statadd_ref(nsr, if_oerrors,
 	    (u_int) CSR_READ_2(sc, STGE_FramesAbortXSColls) +
-	    (u_int) CSR_READ_2(sc, STGE_FramesWEXDeferal);
+	    (u_int) CSR_READ_2(sc, STGE_FramesWEXDeferal));
+
+	IF_STAT_PUTREF(ifp);
 }
 
 /*

cvs diff -r1.118 -r1.119 src/sys/dev/pci/if_tl.c (expand / switch to context diff)
--- src/sys/dev/pci/if_tl.c 2019/12/22 23:23:32 1.118
+++ src/sys/dev/pci/if_tl.c 2020/01/30 05:24:53 1.119
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_tl.c,v 1.118 2019/12/22 23:23:32 thorpej Exp $	*/
+/*	$NetBSD: if_tl.c,v 1.119 2020/01/30 05:24:53 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1997 Manuel Bouyer.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tl.c,v 1.118 2019/12/22 23:23:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tl.c,v 1.119 2020/01/30 05:24:53 thorpej Exp $");
 
 #undef TLDEBUG
 #define TL_PRIV_STATS
@@ -1409,7 +1409,7 @@
 	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 	printf("%s: device timeout\n", device_xname(sc->sc_dev));
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 	tl_init(ifp);
 }
 
@@ -1504,8 +1504,10 @@
 	int oerr_carrloss;
 	struct ifnet *ifp = &sc->tl_if;
 
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
 	reg =  tl_intreg_read(sc, TL_INT_STATS_TX);
-	ifp->if_opackets += reg & 0x00ffffff;
+	if_statadd_ref(nsr, if_opackets, reg & 0x00ffffff);
 	oerr_underr = reg >> 24;
 
 	reg =  tl_intreg_read(sc, TL_INT_STATS_RX);
@@ -1525,11 +1527,11 @@
 	oerr_latecoll = (reg & TL_LERR_LCOLL) >> 8;
 	oerr_carrloss = (reg & TL_LERR_CL) >> 16;
 
-
-	ifp->if_oerrors += oerr_underr + oerr_exesscoll + oerr_latecoll +
-	   oerr_carrloss;
-	ifp->if_collisions += oerr_coll + oerr_multicoll;
-	ifp->if_ierrors += ierr_overr + ierr_code + ierr_crc;
+	if_statadd_ref(nsr, if_oerrors,
+	   oerr_underr + oerr_exesscoll + oerr_latecoll + oerr_carrloss);
+	if_statadd_ref(nsr, if_collisions, oerr_coll + oerr_multicoll);
+	if_statadd_ref(nsr, if_ierrors, ierr_overr + ierr_code + ierr_crc);
+	IF_STAT_PUTREF(ifp);
 
 	if (ierr_overr)
 		printf("%s: receiver ring buffer overrun\n",

cvs diff -r1.78 -r1.79 src/sys/dev/pci/if_vge.c (expand / switch to context diff)
--- src/sys/dev/pci/if_vge.c 2019/12/27 07:41:23 1.78
+++ src/sys/dev/pci/if_vge.c 2020/01/30 05:24:53 1.79
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vge.c,v 1.78 2019/12/27 07:41:23 msaitoh Exp $ */
+/* $NetBSD: if_vge.c,v 1.79 2020/01/30 05:24:53 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2004
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.78 2019/12/27 07:41:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.79 2020/01/30 05:24:53 thorpej Exp $");
 
 /*
  * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver.
@@ -1231,7 +1231,7 @@
 		if ((rxstat & VGE_RDSTS_RXOK) == 0 &&
 		    (rxstat & VGE_RDSTS_VIDM) == 0 &&
 		    (rxstat & VGE_RDSTS_CSUMERR) == 0) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			/*
 			 * If this is part of a multi-fragment packet,
 			 * discard all the pieces.
@@ -1250,7 +1250,7 @@
 		 */
 
 		if (vge_newbuf(sc, idx, NULL)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			if (sc->sc_rx_mhead != NULL) {
 				m_freem(sc->sc_rx_mhead);
 				sc->sc_rx_mhead = sc->sc_rx_mtail = NULL;
@@ -1363,12 +1363,14 @@
 		bus_dmamap_sync(sc->sc_dmat, txs->txs_dmamap, 0,
 		    txs->txs_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE);
 		bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap);
+		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 		if (txstat & (VGE_TDSTS_EXCESSCOLL | VGE_TDSTS_COLL))
-			ifp->if_collisions++;
+			if_statinc_ref(nsr, if_collisions);
 		if (txstat & VGE_TDSTS_TXERR)
-			ifp->if_oerrors++;
+			if_statinc_ref(nsr, if_oerrors);
 		else
-			ifp->if_opackets++;
+			if_statinc_ref(nsr, if_opackets);
+		IF_STAT_PUTREF(ifp);
 	}
 
 	sc->sc_tx_considx = idx;
@@ -2019,7 +2021,7 @@
 	sc = ifp->if_softc;
 	s = splnet();
 	printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 
 	vge_txeof(sc);
 	vge_rxeof(sc);

cvs diff -r1.131 -r1.132 src/sys/dev/pci/if_vr.c (expand / switch to context diff)
--- src/sys/dev/pci/if_vr.c 2019/09/13 07:55:07 1.131
+++ src/sys/dev/pci/if_vr.c 2020/01/30 05:24:53 1.132
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vr.c,v 1.131 2019/09/13 07:55:07 msaitoh Exp $	*/
+/*	$NetBSD: if_vr.c,v 1.132 2020/01/30 05:24:53 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.131 2019/09/13 07:55:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.132 2020/01/30 05:24:53 thorpej Exp $");
 
 
 
@@ -625,7 +625,7 @@
 		if (rxstat & VR_RXSTAT_RXERR) {
 			const char *errstr;
 
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			switch (rxstat & 0x000000FF) {
 			case VR_RXSTAT_CRCERR:
 				errstr = "crc error";
@@ -665,7 +665,7 @@
 			 * time.  In case we receive a fragment that is not
 			 * a complete packet, we discard it.
 			 */
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 
 			aprint_error_dev(sc->vr_dev,
 			    "receive error: incomplete frame; "
@@ -689,7 +689,7 @@
 			 * missed to handle an error condition above.
 			 * Discard it to avoid a later crash.
 			 */
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 
 			aprint_error_dev(sc->vr_dev,
 			    "receive error: zero-length packet; "
@@ -733,7 +733,7 @@
 			m = ds->ds_mbuf;
 			if (vr_add_rxbuf(sc, i) == ENOBUFS) {
  dropit:
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				VR_INIT_RXDESC(sc, i);
 				bus_dmamap_sync(sc->vr_dmat,
 				    ds->ds_dmamap, 0,
@@ -752,7 +752,7 @@
 		MGETHDR(m, M_DONTWAIT, MT_DATA);
 		if (m == NULL) {
  dropit:
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			VR_INIT_RXDESC(sc, i);
 			bus_dmamap_sync(sc->vr_dmat, ds->ds_dmamap, 0,
 			    ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -798,7 +798,7 @@
 
 	ifp = &sc->vr_ec.ec_if;
 
-	ifp->if_ierrors++;
+	if_statinc(ifp, if_ierrors);
 
 	VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_RX_ON);
 	for (i = 0; i < VR_TIMEOUT; i++) {
@@ -874,16 +874,19 @@
 		m_freem(ds->ds_mbuf);
 		ds->ds_mbuf = NULL;
 
+		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 		if (txstat & VR_TXSTAT_ERRSUM) {
-			ifp->if_oerrors++;
+			if_statinc_ref(nsr, if_oerrors);
 			if (txstat & VR_TXSTAT_DEFER)
-				ifp->if_collisions++;
+				if_statinc_ref(nsr, if_collisions);
 			if (txstat & VR_TXSTAT_LATECOLL)
-				ifp->if_collisions++;
+				if_statinc_ref(nsr, if_collisions);
 		}
 
-		ifp->if_collisions += (txstat & VR_TXSTAT_COLLCNT) >> 3;
-		ifp->if_opackets++;
+		if_statadd_ref(nsr, if_collisions,
+		    (txstat & VR_TXSTAT_COLLCNT) >> 3);
+		if_statinc_ref(nsr, if_opackets);
+		IF_STAT_PUTREF(ifp);
 	}
 
 	/* Update the dirty transmit buffer pointer. */
@@ -934,7 +937,7 @@
 
 		if (status & VR_ISR_RX_DROPPED) {
 			aprint_error_dev(sc->vr_dev, "rx packet lost\n");
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 		}
 
 		if (status &
@@ -967,7 +970,7 @@
 			if (status & VR_ISR_TX_UDFI)
 				aprint_error_dev(sc->vr_dev,
 				    "transmit underflow\n");
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			dotx = 1;
 			vr_txeof(sc);
 			if (sc->vr_txpending) {
@@ -1330,7 +1333,7 @@
 	struct vr_softc *sc = ifp->if_softc;
 
 	aprint_error_dev(sc->vr_dev, "device timeout\n");
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 
 	(void) vr_init(ifp);
 }