Module Name:    src
Committed By:   thorpej
Date:           Wed Jan 29 06:39:07 UTC 2020

Modified Files:
        src/sys/dev/usb: if_ure.c if_url.c if_urndis.c if_urtw.c if_urtwn.c
            if_zyd.c uhso.c usbnet.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/usb/if_ure.c
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/usb/if_url.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/usb/if_urndis.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/usb/if_urtw.c
cvs rdiff -u -r1.80 -r1.81 src/sys/dev/usb/if_urtwn.c
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/usb/if_zyd.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/usb/uhso.c
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/usb/usbnet.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/usb/if_ure.c
diff -u src/sys/dev/usb/if_ure.c:1.34 src/sys/dev/usb/if_ure.c:1.35
--- src/sys/dev/usb/if_ure.c:1.34	Tue Jan  7 06:42:26 2020
+++ src/sys/dev/usb/if_ure.c	Wed Jan 29 06:39:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ure.c,v 1.34 2020/01/07 06:42:26 maxv Exp $	*/
+/*	$NetBSD: if_ure.c,v 1.35 2020/01/29 06:39:07 thorpej Exp $	*/
 /*	$OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $	*/
 
 /*-
@@ -30,7 +30,7 @@
 /* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.34 2020/01/07 06:42:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.35 2020/01/29 06:39:07 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1007,7 +1007,7 @@ ure_rx_loop(struct usbnet *un, struct us
 	do {
 		if (total_len < sizeof(rxhdr)) {
 			DPRINTF(("too few bytes left for a packet header\n"));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			return;
 		}
 
@@ -1020,7 +1020,7 @@ ure_rx_loop(struct usbnet *un, struct us
 		DPRINTFN(4, ("next packet is %d bytes\n", pkt_len));
 		if (pkt_len > total_len) {
 			DPRINTF(("not enough bytes left for next packet\n"));
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			return;
 		}
 

Index: src/sys/dev/usb/if_url.c
diff -u src/sys/dev/usb/if_url.c:1.72 src/sys/dev/usb/if_url.c:1.73
--- src/sys/dev/usb/if_url.c:1.72	Tue Jan  7 06:42:26 2020
+++ src/sys/dev/usb/if_url.c	Wed Jan 29 06:39:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_url.c,v 1.72 2020/01/07 06:42:26 maxv Exp $	*/
+/*	$NetBSD: if_url.c,v 1.73 2020/01/29 06:39:07 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.72 2020/01/07 06:42:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.73 2020/01/29 06:39:07 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -576,7 +576,7 @@ url_rx_loop(struct usbnet *un, struct us
 	DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev),__func__));
 
 	if (total_len <= ETHER_CRC_LEN || total_len <= sizeof(rxhdr)) {
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -591,7 +591,7 @@ url_rx_loop(struct usbnet *un, struct us
 		 UGETW(rxhdr) & URL_RXHDR_MCASTPKT_MASK ? ", Multicast" : ""));
 
 	if ((UGETW(rxhdr) & URL_RXHDR_VALID_MASK) == 0) {
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 

Index: src/sys/dev/usb/if_urndis.c
diff -u src/sys/dev/usb/if_urndis.c:1.35 src/sys/dev/usb/if_urndis.c:1.36
--- src/sys/dev/usb/if_urndis.c:1.35	Tue Jan  7 06:42:26 2020
+++ src/sys/dev/usb/if_urndis.c	Wed Jan 29 06:39:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urndis.c,v 1.35 2020/01/07 06:42:26 maxv Exp $ */
+/*	$NetBSD: if_urndis.c,v 1.36 2020/01/29 06:39:07 thorpej Exp $ */
 /*	$OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
 
 /*
@@ -21,7 +21,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.35 2020/01/07 06:42:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.36 2020/01/29 06:39:07 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -820,7 +820,7 @@ urndis_rx_loop(struct usbnet * un, struc
 		}
 
 		if (le32toh(msg->rm_datalen) < sizeof(struct ether_header)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			printf("%s: urndis_decap invalid ethernet size "
 			    "%d < %zu\n",
 			    DEVNAME(un),

Index: src/sys/dev/usb/if_urtw.c
diff -u src/sys/dev/usb/if_urtw.c:1.20 src/sys/dev/usb/if_urtw.c:1.21
--- src/sys/dev/usb/if_urtw.c:1.20	Thu Nov 28 17:09:10 2019
+++ src/sys/dev/usb/if_urtw.c	Wed Jan 29 06:39:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtw.c,v 1.20 2019/11/28 17:09:10 maxv Exp $	*/
+/*	$NetBSD: if_urtw.c,v 1.21 2020/01/29 06:39:07 thorpej Exp $	*/
 /*	$OpenBSD: if_urtw.c,v 1.39 2011/07/03 15:47:17 matthew Exp $	*/
 
 /*-
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.20 2019/11/28 17:09:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.21 2020/01/29 06:39:07 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2489,7 +2489,7 @@ urtw_start(struct ifnet *ifp)
 			if (urtw_tx_start(sc, ni, m0, URTW_PRIORITY_NORMAL)
 			    != 0) {
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				break;
 			}
 		}
@@ -2508,7 +2508,7 @@ urtw_watchdog(struct ifnet *ifp)
 	if (sc->sc_txtimer > 0) {
 		if (--sc->sc_txtimer == 0) {
 			printf("%s: device timeout\n", device_xname(sc->sc_dev));
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;
@@ -2537,7 +2537,7 @@ urtw_txeof_low(struct usbd_xfer *xfer, v
 		if (status == USBD_STALLED)
 			usbd_clear_endpoint_stall_async(sc->sc_txpipe_low);
 
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		return;
 	}
 
@@ -2547,7 +2547,7 @@ urtw_txeof_low(struct usbd_xfer *xfer, v
 	data->ni = NULL;
 
 	sc->sc_txtimer = 0;
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 
 	sc->sc_tx_queued[URTW_PRIORITY_LOW]--;
 	ifp->if_flags &= ~IFF_OACTIVE;
@@ -2576,7 +2576,7 @@ urtw_txeof_normal(struct usbd_xfer *xfer
 		if (status == USBD_STALLED)
 			usbd_clear_endpoint_stall_async(sc->sc_txpipe_normal);
 
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		return;
 	}
 
@@ -2586,7 +2586,7 @@ urtw_txeof_normal(struct usbd_xfer *xfer
 	data->ni = NULL;
 
 	sc->sc_txtimer = 0;
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 
 	sc->sc_tx_queued[URTW_PRIORITY_NORMAL]--;
 	ifp->if_flags &= ~IFF_OACTIVE;
@@ -3073,13 +3073,13 @@ urtw_rxeof(struct usbd_xfer *xfer, void 
 
 		if (status == USBD_STALLED)
 			usbd_clear_endpoint_stall_async(sc->sc_rxpipe);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
 	usbd_get_xfer_status(xfer, NULL, NULL, &actlen, NULL);
 	if (actlen < URTW_MIN_RXBUFSZ) {
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -3093,7 +3093,7 @@ urtw_rxeof(struct usbd_xfer *xfer, void 
 	desc = data->buf + len;
 	flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff);
 	if (flen > actlen) {
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -3119,7 +3119,7 @@ urtw_rxeof(struct usbd_xfer *xfer, void 
 	if (mnew == NULL) {
 		printf("%s: could not allocate rx mbuf\n",
 		    device_xname(sc->sc_dev));
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 	MCLGET(mnew, M_DONTWAIT);
@@ -3127,7 +3127,7 @@ urtw_rxeof(struct usbd_xfer *xfer, void 
 		printf("%s: could not allocate rx mbuf cluster\n",
 		    device_xname(sc->sc_dev));
 		m_freem(mnew);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 

Index: src/sys/dev/usb/if_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.80 src/sys/dev/usb/if_urtwn.c:1.81
--- src/sys/dev/usb/if_urtwn.c:1.80	Wed Jan 15 08:20:13 2020
+++ src/sys/dev/usb/if_urtwn.c	Wed Jan 29 06:39:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.80 2020/01/15 08:20:13 skrll Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.81 2020/01/29 06:39:07 thorpej Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.80 2020/01/15 08:20:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.81 2020/01/29 06:39:07 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2380,7 +2380,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 		 * to not receive these frames.
 		 */
 		DPRINTFN(DBG_RX, "CRC error", 0, 0, 0, 0);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 	/*
@@ -2391,12 +2391,12 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 	if (__predict_false(pktlen < (int)sizeof(struct ieee80211_frame_ack))) {
 		DPRINTFN(DBG_RX, "packet too short %jd", pktlen, 0, 0, 0);
 		ic->ic_stats.is_rx_tooshort++;
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 	if (__predict_false(pktlen > MCLBYTES)) {
 		DPRINTFN(DBG_RX, "packet too big %jd", pktlen, 0, 0, 0);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -2420,7 +2420,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 	if (__predict_false(m == NULL)) {
 		aprint_error_dev(sc->sc_dev, "couldn't allocate rx mbuf\n");
 		ic->ic_stats.is_rx_nobuf++;
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 	if (pktlen > (int)MHLEN) {
@@ -2430,7 +2430,7 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
 			    "couldn't allocate rx mbuf cluster\n");
 			m_freem(m);
 			ic->ic_stats.is_rx_nobuf++;
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			return;
 		}
 	}
@@ -2598,13 +2598,13 @@ urtwn_txeof(struct usbd_xfer *xfer, void
 				usbd_clear_endpoint_stall_async(pipe);
 			}
 			printf("ERROR1\n");
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 		}
 		splx(s);
 		return;
 	}
 
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 	urtwn_start(ifp);
 	splx(s);
 
@@ -2891,7 +2891,7 @@ urtwn_start(struct ifnet *ifp)
 		if (m->m_len < (int)sizeof(*eh) &&
 		    (m = m_pullup(m, sizeof(*eh))) == NULL) {
 			printf("ERROR6\n");
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 		eh = mtod(m, struct ether_header *);
@@ -2899,7 +2899,7 @@ urtwn_start(struct ifnet *ifp)
 		if (ni == NULL) {
 			m_freem(m);
 			printf("ERROR5\n");
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 
@@ -2908,7 +2908,7 @@ urtwn_start(struct ifnet *ifp)
 		if ((m = ieee80211_encap(ic, m, ni)) == NULL) {
 			ieee80211_free_node(ni);
 			printf("ERROR4\n");
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
  sendit:
@@ -2918,7 +2918,7 @@ urtwn_start(struct ifnet *ifp)
 			m_freem(m);
 			ieee80211_free_node(ni);
 			printf("ERROR3\n");
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			continue;
 		}
 		m_freem(m);
@@ -2942,7 +2942,7 @@ urtwn_watchdog(struct ifnet *ifp)
 			aprint_error_dev(sc->sc_dev, "device timeout\n");
 			/* urtwn_init(ifp); XXX needs a process context! */
 			printf("ERROR2\n");
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;

Index: src/sys/dev/usb/if_zyd.c
diff -u src/sys/dev/usb/if_zyd.c:1.55 src/sys/dev/usb/if_zyd.c:1.56
--- src/sys/dev/usb/if_zyd.c:1.55	Wed Jan 15 08:21:00 2020
+++ src/sys/dev/usb/if_zyd.c	Wed Jan 29 06:39:07 2020
@@ -1,5 +1,5 @@
 /*	$OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $	*/
-/*	$NetBSD: if_zyd.c,v 1.55 2020/01/15 08:21:00 skrll Exp $	*/
+/*	$NetBSD: if_zyd.c,v 1.56 2020/01/29 06:39:07 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2006 by Damien Bergamini <[email protected]>
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.55 2020/01/15 08:21:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.56 2020/01/29 06:39:07 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1857,7 +1857,7 @@ zyd_intr(struct usbd_xfer *xfer, void * 
 		((struct zyd_node *)ni)->amn.amn_retrycnt++;
 
 		if (le16toh(retry->count) & 0x100)
-			ifp->if_oerrors++;	/* too many retries */
+			if_statinc(ifp, if_oerrors);
 
 	} else if (le16toh(cmd->code) == ZYD_NOTIF_IORD) {
 		struct rq *rqp;
@@ -1913,7 +1913,7 @@ zyd_rx_data(struct zyd_softc *sc, const 
 	if (len < ZYD_MIN_FRAGSZ) {
 		printf("%s: frame too short (length=%d)\n",
 		    device_xname(sc->sc_dev), len);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -1924,7 +1924,7 @@ zyd_rx_data(struct zyd_softc *sc, const 
 	if (stat->flags & ZYD_RX_ERROR) {
 		DPRINTF(("%s: RX status indicated error (%x)\n",
 		    device_xname(sc->sc_dev), stat->flags));
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -1937,7 +1937,7 @@ zyd_rx_data(struct zyd_softc *sc, const 
 	if (m == NULL) {
 		printf("%s: could not allocate rx mbuf\n",
 		    device_xname(sc->sc_dev));
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 	if (rlen > MHLEN) {
@@ -1946,7 +1946,7 @@ zyd_rx_data(struct zyd_softc *sc, const 
 			printf("%s: could not allocate rx mbuf cluster\n",
 			    device_xname(sc->sc_dev));
 			m_freem(m);
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			return;
 		}
 	}
@@ -2006,7 +2006,7 @@ zyd_rxeof(struct usbd_xfer *xfer, void *
 	if (len < ZYD_MIN_RXBUFSZ) {
 		printf("%s: xfer too short (length=%d)\n",
 		    device_xname(sc->sc_dev), len);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		goto skip;
 	}
 
@@ -2145,7 +2145,7 @@ zyd_tx_mgt(struct zyd_softc *sc, struct 
 	    USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof);
 	error = usbd_transfer(data->xfer);
 	if (error != USBD_IN_PROGRESS && error != 0) {
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		return EIO;
 	}
 	sc->tx_queued++;
@@ -2172,7 +2172,7 @@ zyd_txeof(struct usbd_xfer *xfer, void *
 			usbd_clear_endpoint_stall_async(
 			    sc->zyd_ep[ZYD_ENDPT_BOUT]);
 		}
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		return;
 	}
 
@@ -2185,7 +2185,7 @@ zyd_txeof(struct usbd_xfer *xfer, void *
 	data->ni = NULL;
 
 	sc->tx_queued--;
-	ifp->if_opackets++;
+	if_statinc(ifp, if_opackets);
 
 	sc->tx_timer = 0;
 	ifp->if_flags &= ~IFF_OACTIVE;
@@ -2302,7 +2302,7 @@ zyd_tx_data(struct zyd_softc *sc, struct
 	    USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof);
 	error = usbd_transfer(data->xfer);
 	if (error != USBD_IN_PROGRESS && error != 0) {
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		return EIO;
 	}
 	sc->tx_queued++;
@@ -2358,13 +2358,13 @@ zyd_start(struct ifnet *ifp)
 			bpf_mtap(ifp, m0, BPF_D_OUT);
 			if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) {
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				continue;
 			}
 			bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
 			if (zyd_tx_data(sc, m0, ni) != 0) {
 				ieee80211_free_node(ni);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				break;
 			}
 		}
@@ -2386,7 +2386,7 @@ zyd_watchdog(struct ifnet *ifp)
 		if (--sc->tx_timer == 0) {
 			printf("%s: device timeout\n", device_xname(sc->sc_dev));
 			/* zyd_init(ifp); XXX needs a process context ? */
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			return;
 		}
 		ifp->if_timer = 1;

Index: src/sys/dev/usb/uhso.c
diff -u src/sys/dev/usb/uhso.c:1.31 src/sys/dev/usb/uhso.c:1.32
--- src/sys/dev/usb/uhso.c:1.31	Sun Dec  1 08:27:54 2019
+++ src/sys/dev/usb/uhso.c	Wed Jan 29 06:39:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhso.c,v 1.31 2019/12/01 08:27:54 maxv Exp $	*/
+/*	$NetBSD: uhso.c,v 1.32 2020/01/29 06:39:07 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2009 Iain Hibbert
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhso.c,v 1.31 2019/12/01 08:27:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhso.c,v 1.32 2020/01/29 06:39:07 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2024,7 +2024,7 @@ uhso_ifnet_write_cb(struct usbd_xfer *xf
 		else
 			return;
 
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 	} else {
 		usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL);
 		DPRINTF(5, "wrote %d bytes (of %zd)\n", cc, hp->hp_wlen);
@@ -2032,7 +2032,7 @@ uhso_ifnet_write_cb(struct usbd_xfer *xf
 		if (cc != hp->hp_wlen)
 			DPRINTF(0, "cc=%u, wlen=%zd\n", cc, hp->hp_wlen);
 
-		ifp->if_opackets++;
+		if_statinc(ifp, if_opackets);
 	}
 
 	s = splnet();
@@ -2065,7 +2065,7 @@ uhso_ifnet_read_cb(struct usbd_xfer *xfe
 		else
 			return;
 
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		hp->hp_rlen = 0;
 	} else {
 		usbd_get_xfer_status(xfer, NULL, (void **)&cp, &cc, NULL);
@@ -2097,14 +2097,14 @@ uhso_ifnet_input(struct ifnet *ifp, stru
 			MGETHDR(m, M_DONTWAIT, MT_DATA);
 			if (m == NULL) {
 				aprint_error_ifnet(ifp, "no mbufs\n");
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				break;
 			}
 
 			MCLGET(m, M_DONTWAIT);
 			if (!ISSET(m->m_flags, M_EXT)) {
 				aprint_error_ifnet(ifp, "no mbuf clusters\n");
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				m_freem(m);
 				break;
 			}
@@ -2127,7 +2127,7 @@ uhso_ifnet_input(struct ifnet *ifp, stru
 			    "bad IP header (v=%d, hl=%zd)\n",
 			    mtod(m, struct ip *)->ip_v, want);
 
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			m_freem(m);
 			break;
 		}
@@ -2179,8 +2179,7 @@ uhso_ifnet_input(struct ifnet *ifp, stru
 		if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) {
 			m_freem(m);
 		} else {
-			ifp->if_ipackets++;
-			ifp->if_ibytes += got;
+			if_statadd2(ifp, if_ipackets, 1, if_ibytes, got);
 		}
 		splx(s);
 	}
@@ -2339,7 +2338,7 @@ uhso_ifnet_start(struct ifnet *ifp)
 	m_freem(m);
 
 	if ((*hp->hp_write)(hp) != 0) {
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		CLR(ifp->if_flags, IFF_OACTIVE);
 	}
 }

Index: src/sys/dev/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.33 src/sys/dev/usb/usbnet.c:1.34
--- src/sys/dev/usb/usbnet.c:1.33	Sat Dec 14 15:40:43 2019
+++ src/sys/dev/usb/usbnet.c	Wed Jan 29 06:39:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.33 2019/12/14 15:40:43 maya Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.34 2020/01/29 06:39:07 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.33 2019/12/14 15:40:43 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.34 2020/01/29 06:39:07 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -271,7 +271,7 @@ usbnet_enqueue(struct usbnet * const un,
 	m = usbnet_newbuf(buflen);
 	if (m == NULL) {
 		DPRINTF("%d: no memory", unp->unp_number, 0, 0, 0);
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -300,7 +300,7 @@ usbnet_input(struct usbnet * const un, u
 
 	m = usbnet_newbuf(buflen);
 	if (m == NULL) {
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		return;
 	}
 
@@ -402,12 +402,12 @@ usbnet_txeof(struct usbd_xfer *xfer, voi
 		break;
 
 	case USBD_NORMAL_COMPLETION:
-		ifp->if_opackets++;
+		if_statinc(ifp, if_opackets);
 		break;
 
 	default:
 
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		if (usbd_ratecheck(&unp->unp_tx_notice))
 			aprint_error_dev(un->un_dev, "usb error on tx: %s\n",
 			    usbd_errstr(status));
@@ -500,13 +500,13 @@ usbnet_start_locked(struct ifnet *ifp)
 		length = uno_tx_prepare(un, m, c);
 		if (length == 0) {
 			DPRINTF("uno_tx_prepare gave zero length", 0, 0, 0, 0);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 
 		if (__predict_false(c->unc_xfer == NULL)) {
 			DPRINTF("unc_xfer is NULL", 0, 0, 0, 0);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 
@@ -518,7 +518,7 @@ usbnet_start_locked(struct ifnet *ifp)
 		if (err != USBD_IN_PROGRESS) {
 			DPRINTF("usbd_transfer on %jx for %ju bytes: %d",
 			    (uintptr_t)c->unc_buf, length, err, 0);
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			break;
 		}
 		done_transmit = true;
@@ -1149,7 +1149,7 @@ usbnet_watchdog(struct ifnet *ifp)
 	struct usbnet_cdata * const cd = un_cdata(un);
 	usbd_status err;
 
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 	aprint_error_dev(un->un_dev, "watchdog timeout\n");
 
 	if (cd->uncd_tx_cnt > 0) {

Reply via email to