Module Name:    src
Committed By:   thorpej
Date:           Wed Jan 29 15:06:12 UTC 2020

Modified Files:
        src/sys/dev/ic: rt2560.c rt2661.c rt2860.c rtl8169.c rtl81x9.c rtw.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ic/rt2560.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/ic/rt2661.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ic/rt2860.c
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/ic/rtl81x9.c
cvs rdiff -u -r1.134 -r1.135 src/sys/dev/ic/rtw.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/rt2560.c
diff -u src/sys/dev/ic/rt2560.c:1.37 src/sys/dev/ic/rt2560.c:1.38
--- src/sys/dev/ic/rt2560.c:1.37	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/rt2560.c	Wed Jan 29 15:06:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rt2560.c,v 1.37 2019/11/10 21:16:35 chs Exp $	*/
+/*	$NetBSD: rt2560.c,v 1.38 2020/01/29 15:06:12 thorpej Exp $	*/
 /*	$OpenBSD: rt2560.c,v 1.15 2006/04/20 20:31:12 miod Exp $  */
 /*	$FreeBSD: rt2560.c,v 1.3 2006/03/21 21:15:43 damien Exp $*/
 
@@ -24,7 +24,7 @@
  * http://www.ralinktech.com/
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.37 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.38 2020/01/29 15:06:12 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -1098,13 +1098,13 @@ rt2560_tx_intr(struct rt2560_softc *sc)
 				ieee80211_rssadapt_raise_rate(ic,
 				    &rn->rssadapt, &data->id);
 			}
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 			break;
 
 		case RT2560_TX_SUCCESS_RETRY:
 			DPRINTFN(9, ("data frame sent after %u retries\n",
 			    (le32toh(desc->flags) >> 5) & 0x7));
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 			break;
 
 		case RT2560_TX_FAIL_RETRY:
@@ -1114,7 +1114,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
 				ieee80211_rssadapt_lower_rate(ic, data->ni,
 				    &rn->rssadapt, &data->id);
 			}
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 
 		case RT2560_TX_FAIL_INVALID:
@@ -1123,7 +1123,7 @@ rt2560_tx_intr(struct rt2560_softc *sc)
 			aprint_error_dev(sc->sc_dev,
 			    "sending data frame failed 0x%08x\n",
 			    le32toh(desc->flags));
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 		}
 
 		bus_dmamap_sync(sc->sc_dmat, data->map, 0,
@@ -1261,13 +1261,13 @@ rt2560_decryption_intr(struct rt2560_sof
 			break;
 
 		if (data->drop) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
 		if ((le32toh(desc->flags) & RT2560_RX_CIPHER_MASK) != 0 &&
 		    (le32toh(desc->flags) & RT2560_RX_ICV_ERROR)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -1280,14 +1280,14 @@ rt2560_decryption_intr(struct rt2560_sof
 		 */
 		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;
 		}
 
@@ -1311,7 +1311,7 @@ rt2560_decryption_intr(struct rt2560_sof
 			}
 			/* physical address may have changed */
 			desc->physaddr = htole32(data->map->dm_segs->ds_addr);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -2150,7 +2150,7 @@ rt2560_start(struct ifnet *ifp)
 
 			if (rt2560_tx_data(sc, m0, ni) != 0) {
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				break;
 			}
 		}
@@ -2171,7 +2171,7 @@ rt2560_watchdog(struct ifnet *ifp)
 		if (--sc->sc_tx_timer == 0) {
 			aprint_error_dev(sc->sc_dev, "device timeout\n");
 			rt2560_init(ifp);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;

Index: src/sys/dev/ic/rt2661.c
diff -u src/sys/dev/ic/rt2661.c:1.42 src/sys/dev/ic/rt2661.c:1.43
--- src/sys/dev/ic/rt2661.c:1.42	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/rt2661.c	Wed Jan 29 15:06:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rt2661.c,v 1.42 2019/11/10 21:16:35 chs Exp $	*/
+/*	$NetBSD: rt2661.c,v 1.43 2020/01/29 15:06:12 thorpej Exp $	*/
 /*	$OpenBSD: rt2661.c,v 1.17 2006/05/01 08:41:11 damien Exp $	*/
 /*	$FreeBSD: rt2560.c,v 1.5 2006/06/02 19:59:31 csjp Exp $	*/
 
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.42 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.43 2020/01/29 15:06:12 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -946,7 +946,7 @@ rt2661_tx_intr(struct rt2661_softc *sc)
 			rn->amn.amn_txcnt++;
 			if (retrycnt > 0)
 				rn->amn.amn_retrycnt++;
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 			break;
 
 		case RT2661_TX_RETRY_FAIL:
@@ -954,13 +954,13 @@ rt2661_tx_intr(struct rt2661_softc *sc)
 			    "retries)\n"));
 			rn->amn.amn_txcnt++;
 			rn->amn.amn_retrycnt++;
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 
 		default:
 			/* other failure */
 			aprint_error_dev(sc->sc_dev, "sending data frame failed 0x%08x\n", val);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 		}
 
 		ieee80211_free_node(data->ni);
@@ -1050,12 +1050,12 @@ rt2661_rx_intr(struct rt2661_softc *sc)
 			 */
 			DPRINTFN(5, ("PHY or CRC error flags 0x%08x\n",
 			    le32toh(desc->flags)));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
 		if ((le32toh(desc->flags) & RT2661_RX_CIPHER_MASK) != 0) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -1068,14 +1068,14 @@ rt2661_rx_intr(struct rt2661_softc *sc)
 		 */
 		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;
 		}
 
@@ -1099,7 +1099,7 @@ rt2661_rx_intr(struct rt2661_softc *sc)
 			}
 			/* physical address may have changed */
 			desc->physaddr = htole32(data->map->dm_segs->ds_addr);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -1863,7 +1863,7 @@ rt2661_start(struct ifnet *ifp)
 			ni = ieee80211_find_txnode(ic, eh->ether_dhost);
 			if (ni == NULL) {
 				m_freem(m0);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				continue;
 			}
 
@@ -1871,14 +1871,14 @@ rt2661_start(struct ifnet *ifp)
 			m0 = ieee80211_encap(ic, m0, ni);
 			if (m0 == NULL) {
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				continue;
 			}
 			bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
 			if (rt2661_tx_data(sc, m0, ni, 0) != 0) {
 				if (ni != NULL)
 					ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				break;
 			}
 		}
@@ -1899,7 +1899,7 @@ rt2661_watchdog(struct ifnet *ifp)
 		if (--sc->sc_tx_timer == 0) {
 			aprint_error_dev(sc->sc_dev, "device timeout\n");
 			rt2661_init(ifp);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;

Index: src/sys/dev/ic/rt2860.c
diff -u src/sys/dev/ic/rt2860.c:1.34 src/sys/dev/ic/rt2860.c:1.35
--- src/sys/dev/ic/rt2860.c:1.34	Tue Sep  3 14:26:55 2019
+++ src/sys/dev/ic/rt2860.c	Wed Jan 29 15:06:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rt2860.c,v 1.34 2019/09/03 14:26:55 msaitoh Exp $	*/
+/*	$NetBSD: rt2860.c,v 1.35 2020/01/29 15:06:12 thorpej Exp $	*/
 /*	$OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $	*/
 /*	$FreeBSD: head/sys/dev/ral/rt2860.c 306591 2016-10-02 20:35:55Z avos $ */
 
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.34 2019/09/03 14:26:55 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.35 2020/01/29 15:06:12 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -1266,7 +1266,7 @@ rt2860_drain_stats_fifo(struct rt2860_so
 				amn->amn_retrycnt++;
 		} else {
 			amn->amn_retrycnt++;
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 		}
 	}
 }
@@ -1300,7 +1300,7 @@ rt2860_tx_intr(struct rt2860_softc *sc, 
 			SLIST_INSERT_HEAD(&sc->data_pool, data, next);
 			ring->data[ring->next] = NULL;
 
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 		}
 		ring->queued--;
 		ring->next = (ring->next + 1) % RT2860_TX_RING_COUNT;
@@ -1366,7 +1366,7 @@ rt2860_rx_intr(struct rt2860_softc *sc)
 		if (__predict_false(rxd->flags &
 		    htole32(RT2860_RX_CRCERR | RT2860_RX_ICVERR))) {
 			DPRINTF(("error %#x\n", rxd->flags));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -1374,14 +1374,14 @@ rt2860_rx_intr(struct rt2860_softc *sc)
 		MGETHDR(m1, M_DONTWAIT, MT_DATA);
 		if (__predict_false(m1 == NULL)) {
 			DPRINTF(("error2 %#x\n", rxd->flags));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 		MCLGET(m1, M_DONTWAIT);
 		if (__predict_false((m1->m_flags & M_EXT) == 0)) {
 			DPRINTF(("no mbuf\n"));
 			m_freem(m1);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -1406,7 +1406,7 @@ rt2860_rx_intr(struct rt2860_softc *sc)
 			}
 			/* physical address may have changed */
 			rxd->sdp0 = htole32(data->map->dm_segs[0].ds_addr);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -1446,7 +1446,7 @@ rt2860_rx_intr(struct rt2860_softc *sc)
 			/* report MIC failures to net80211 for TKIP */
 			ieee80211_notify_michael_failure(ic, wh, 0/* XXX */);
 			DPRINTF(("error2 %#x\n", rxd->flags));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 #endif
@@ -1906,7 +1906,7 @@ rt2860_start(struct ifnet *ifp)
 		if (m->m_len < (int)sizeof(*eh) &&
 		    (m = m_pullup(m, sizeof(*eh))) == NULL) {
 			DPRINTF(("%s: nothing to send\n", __func__));
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -1916,7 +1916,7 @@ rt2860_start(struct ifnet *ifp)
 		if (ni == NULL) {
 			DPRINTF(("%s: can't find tx node\n", __func__));
 			m_freem(m);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -1925,7 +1925,7 @@ rt2860_start(struct ifnet *ifp)
 		if ((m = ieee80211_encap(ic, m, ni)) == NULL) {
 			DPRINTF(("%s: can't encap\n", __func__));
 			ieee80211_free_node(ni);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 sendit:
@@ -1935,7 +1935,7 @@ sendit:
 			DPRINTF(("%s: can't tx\n", __func__));
 			m_freem(m);
 			ieee80211_free_node(ni);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -1957,7 +1957,7 @@ rt2860_watchdog(struct ifnet *ifp)
 			aprint_error_dev(sc->sc_dev, "device timeout\n");
 			rt2860_stop(ifp, 0);
 			rt2860_init(ifp);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;

Index: src/sys/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.161 src/sys/dev/ic/rtl8169.c:1.162
--- src/sys/dev/ic/rtl8169.c:1.161	Tue Dec 17 10:42:06 2019
+++ src/sys/dev/ic/rtl8169.c	Wed Jan 29 15:06:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.161 2019/12/17 10:42:06 msaitoh Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.162 2020/01/29 15:06:12 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.161 2019/12/17 10:42:06 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.162 2020/01/29 15:06:12 thorpej Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -1263,7 +1263,7 @@ re_rxeof(struct rtk_softc *sc)
 				printf(", CRC error");
 			printf("\n");
 #endif
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			/*
 			 * If this is part of a multi-fragment packet,
 			 * discard all the pieces.
@@ -1282,7 +1282,7 @@ re_rxeof(struct rtk_softc *sc)
 		 */
 
 		if (__predict_false(re_newbuf(sc, i, NULL) != 0)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			if (sc->re_head != NULL) {
 				m_freem(sc->re_head);
 				sc->re_head = sc->re_tail = NULL;
@@ -1418,12 +1418,14 @@ re_txeof(struct rtk_softc *sc)
 		m_freem(txq->txq_mbuf);
 		txq->txq_mbuf = NULL;
 
+		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 		if (txstat & (RE_TDESC_STAT_EXCESSCOL | RE_TDESC_STAT_COLCNT))
-			ifp->if_collisions++;
+			if_statinc_ref(nsr, if_collisions);
 		if (txstat & RE_TDESC_STAT_TXERRSUM)
-			ifp->if_oerrors++;
+			if_statinc_ref(nsr, if_oerrors);
 		else
-			ifp->if_opackets++;
+			if_statinc_ref(nsr, if_opackets);
+		IF_STAT_PUTREF(ifp);
 	}
 
 	sc->re_ldata.re_txq_considx = idx;
@@ -1631,7 +1633,7 @@ re_start(struct ifnet *ifp)
 
 			IFQ_DEQUEUE(&ifp->if_snd, m);
 			m_freem(m);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -2097,7 +2099,7 @@ re_watchdog(struct ifnet *ifp)
 	sc = ifp->if_softc;
 	s = splnet();
 	printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 
 	re_txeof(sc);
 	re_rxeof(sc);

Index: src/sys/dev/ic/rtl81x9.c
diff -u src/sys/dev/ic/rtl81x9.c:1.107 src/sys/dev/ic/rtl81x9.c:1.108
--- src/sys/dev/ic/rtl81x9.c:1.107	Thu Aug  1 15:21:50 2019
+++ src/sys/dev/ic/rtl81x9.c	Wed Jan 29 15:06:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9.c,v 1.107 2019/08/01 15:21:50 msaitoh Exp $	*/
+/*	$NetBSD: rtl81x9.c,v 1.108 2020/01/29 15:06:12 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -86,7 +86,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.107 2019/08/01 15:21:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl81x9.c,v 1.108 2020/01/29 15:06:12 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -954,7 +954,7 @@ rtk_rxeof(struct rtk_softc *sc)
 		if ((rxstat & RTK_RXSTAT_RXOK) == 0 ||
 		    total_len < ETHER_MIN_LEN ||
 		    total_len > (MCLBYTES - RTK_ETHER_ALIGN)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 
 			/*
 			 * submitted by:[netbsd-pcmcia:00484]
@@ -1030,7 +1030,7 @@ rtk_rxeof(struct rtk_softc *sc)
 		if (m == NULL) {
 			printf("%s: unable to allocate Rx mbuf\n",
 			    device_xname(sc->sc_dev));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto next_packet;
 		}
 		if (total_len > (MHLEN - RTK_ETHER_ALIGN)) {
@@ -1038,7 +1038,7 @@ rtk_rxeof(struct rtk_softc *sc)
 			if ((m->m_flags & M_EXT) == 0) {
 				printf("%s: unable to allocate Rx cluster\n",
 				    device_xname(sc->sc_dev));
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				m_freem(m);
 				m = NULL;
 				goto next_packet;
@@ -1116,12 +1116,14 @@ rtk_txeof(struct rtk_softc *sc)
 		m_freem(txd->txd_mbuf);
 		txd->txd_mbuf = NULL;
 
-		ifp->if_collisions += (txstat & RTK_TXSTAT_COLLCNT) >> 24;
+		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+		if_statadd_ref(nsr, if_collisions,
+		    (txstat & RTK_TXSTAT_COLLCNT) >> 24);
 
 		if (txstat & RTK_TXSTAT_TX_OK)
-			ifp->if_opackets++;
+			if_statinc_ref(nsr, if_opackets);
 		else {
-			ifp->if_oerrors++;
+			if_statinc_ref(nsr, if_oerrors);
 
 			/*
 			 * Increase Early TX threshold if underrun occurred.
@@ -1146,6 +1148,7 @@ rtk_txeof(struct rtk_softc *sc)
 			if (txstat & (RTK_TXSTAT_TXABRT | RTK_TXSTAT_OUTOFWIN))
 				CSR_WRITE_4(sc, RTK_TXCFG, RTK_TXCFG_CONFIG);
 		}
+		IF_STAT_PUTREF(ifp);
 		SIMPLEQ_INSERT_TAIL(&sc->rtk_tx_free, txd, txd_q);
 		ifp->if_flags &= ~IFF_OACTIVE;
 	}
@@ -1460,7 +1463,7 @@ rtk_watchdog(struct ifnet *ifp)
 	sc = ifp->if_softc;
 
 	printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 	rtk_txeof(sc);
 	rtk_rxeof(sc);
 	rtk_init(ifp);

Index: src/sys/dev/ic/rtw.c
diff -u src/sys/dev/ic/rtw.c:1.134 src/sys/dev/ic/rtw.c:1.135
--- src/sys/dev/ic/rtw.c:1.134	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/rtw.c	Wed Jan 29 15:06:12 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: rtw.c,v 1.134 2019/11/10 21:16:35 chs Exp $ */
+/* $NetBSD: rtw.c,v 1.135 2020/01/29 15:06:12 thorpej Exp $ */
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 David Young.  All rights
  * reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.134 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.135 2020/01/29 15:06:12 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -1523,7 +1523,7 @@ rtw_intr_rx(struct rtw_softc *sc, uint16
 			aprint_error_dev(sc->sc_dev,
 			    "DMA error/FIFO overflow %08" PRIx32 ", "
 			    "rx descriptor %d\n", hstat, next);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto next;
 		}
 
@@ -1537,7 +1537,7 @@ rtw_intr_rx(struct rtw_softc *sc, uint16
 			    "rx frame too long, %d > %d, %08" PRIx32
 			    ", desc %d\n",
 			    len, rs->rs_mbuf->m_len, hstat, next);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto next;
 		}
 
@@ -1546,7 +1546,7 @@ rtw_intr_rx(struct rtw_softc *sc, uint16
 			aprint_error_dev(sc->sc_dev,
 			    "unknown rate #%" __PRIuBITS "\n",
 			    __SHIFTOUT(hstat, RTW_RXSTAT_RATE_MASK));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto next;
 		}
 		rate = ratetbl[hwrate];
@@ -1722,12 +1722,13 @@ rtw_collect_txpkt(struct rtw_softc *sc, 
 	rts_retry = __SHIFTOUT(hstat, RTW_TXSTAT_RTSRETRY_MASK);
 	data_retry = __SHIFTOUT(hstat, RTW_TXSTAT_DRC_MASK);
 
-	ifp->if_collisions += rts_retry + data_retry;
+	if (rts_retry + data_retry)
+		if_statadd(ifp, if_collisions, rts_retry + data_retry);
 
 	if ((hstat & RTW_TXSTAT_TOK) != 0)
 		condstring = "ok";
 	else {
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		condstring = "error";
 	}
 
@@ -3184,7 +3185,7 @@ rtw_dequeue(struct ifnet *ifp, struct rt
 		return 0;
 	}
 	DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: dequeue data frame\n", __func__));
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 	bpf_mtap(ifp, m0, BPF_D_OUT);
 	eh = mtod(m0, struct ether_header *);
 	*nip = ieee80211_find_txnode(&sc->sc_ic, eh->ether_dhost);
@@ -3195,7 +3196,7 @@ rtw_dequeue(struct ifnet *ifp, struct rt
 	}
 	if ((m0 = ieee80211_encap(&sc->sc_ic, m0, *nip)) == NULL) {
 		DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: encap error\n", __func__));
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		return -1;
 	}
 	DPRINTF(sc, RTW_DEBUG_XMIT, ("%s: leave\n", __func__));
@@ -3580,7 +3581,7 @@ rtw_watchdog(struct ifnet *ifp)
 				continue;
 			printf("%s: transmit timeout, priority %d\n",
 			    ifp->if_xname, pri);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			if (pri != RTW_TXPRIBCN)
 				tx_timeouts++;
 		} else

Reply via email to