Module Name:    src
Committed By:   thorpej
Date:           Wed Jan 29 14:49:44 UTC 2020

Modified Files:
        src/sys/dev/ic: i82557.c i82586.c i82596.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/dev/ic/i82557.c
cvs rdiff -u -r1.87 -r1.88 src/sys/dev/ic/i82586.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/ic/i82596.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/i82557.c
diff -u src/sys/dev/ic/i82557.c:1.156 src/sys/dev/ic/i82557.c:1.157
--- src/sys/dev/ic/i82557.c:1.156	Wed Oct 30 07:26:28 2019
+++ src/sys/dev/ic/i82557.c	Wed Jan 29 14:49:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82557.c,v 1.156 2019/10/30 07:26:28 msaitoh Exp $	*/
+/*	$NetBSD: i82557.c,v 1.157 2020/01/29 14:49:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.156 2019/10/30 07:26:28 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.157 2020/01/29 14:49:44 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1436,7 +1436,7 @@ fxp_rxintr(struct fxp_softc *sc)
 		} else {
 			if (fxp_add_rfabuf(sc, rxmap, 1) != 0) {
  dropit:
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				FXP_INIT_RFABUF(sc, m);
 				continue;
 			}
@@ -1474,26 +1474,28 @@ fxp_tick(void *arg)
 
 	s = splnet();
 
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
 	FXP_CDSTATSSYNC(sc, BUS_DMASYNC_POSTREAD);
 
-	ifp->if_opackets += le32toh(sp->tx_good);
-	ifp->if_collisions += le32toh(sp->tx_total_collisions);
+	if_statadd_ref(nsr, if_opackets, le32toh(sp->tx_good));
+	if_statadd_ref(nsr, if_collisions, le32toh(sp->tx_total_collisions));
 	if (sp->rx_good) {
 		sc->sc_rxidle = 0;
 	} else if (sc->sc_flags & FXPF_RECV_WORKAROUND) {
 		sc->sc_rxidle++;
 	}
-	ifp->if_ierrors +=
+	if_statadd_ref(nsr, if_ierrors,
 	    le32toh(sp->rx_crc_errors) +
 	    le32toh(sp->rx_alignment_errors) +
 	    le32toh(sp->rx_rnr_errors) +
-	    le32toh(sp->rx_overrun_errors);
+	    le32toh(sp->rx_overrun_errors));
 	/*
 	 * If any transmit underruns occurred, bump up the transmit
 	 * threshold by another 512 bytes (64 * 8).
 	 */
 	if (sp->tx_underruns) {
-		ifp->if_oerrors += le32toh(sp->tx_underruns);
+		if_statadd_ref(nsr, if_oerrors, le32toh(sp->tx_underruns));
 		if (tx_threshold < 192)
 			tx_threshold += 64;
 	}
@@ -1504,6 +1506,8 @@ fxp_tick(void *arg)
 	}
 #endif
 
+	IF_STAT_PUTREF(ifp);
+
 	/*
 	 * If we haven't received any packets in FXP_MAX_RX_IDLE seconds,
 	 * then assume the receiver has locked up and attempt to clear
@@ -1652,7 +1656,7 @@ fxp_watchdog(struct ifnet *ifp)
 	struct fxp_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);
 
 	(void) fxp_init(ifp);
 }

Index: src/sys/dev/ic/i82586.c
diff -u src/sys/dev/ic/i82586.c:1.87 src/sys/dev/ic/i82586.c:1.88
--- src/sys/dev/ic/i82586.c:1.87	Sun Nov 10 21:16:35 2019
+++ src/sys/dev/ic/i82586.c	Wed Jan 29 14:49:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82586.c,v 1.87 2019/11/10 21:16:35 chs Exp $	*/
+/*	$NetBSD: i82586.c,v 1.88 2020/01/29 14:49:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -137,7 +137,7 @@ Mode of operation:
 */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.87 2019/11/10 21:16:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.88 2020/01/29 14:49:44 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -281,7 +281,7 @@ i82586_watchdog(struct ifnet *ifp)
 	struct ie_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);
 
 	i82586_reset(sc, 1);
 }
@@ -401,11 +401,11 @@ i82586_count_errors(struct ie_softc *sc)
 {
 	int scb = sc->scb;
 
-	sc->sc_ethercom.ec_if.if_ierrors +=
+	if_statadd(&sc->sc_ethercom.ec_if, if_ierrors,
 	    sc->ie_bus_read16(sc, IE_SCB_ERRCRC(scb)) +
 	    sc->ie_bus_read16(sc, IE_SCB_ERRALN(scb)) +
 	    sc->ie_bus_read16(sc, IE_SCB_ERRRES(scb)) +
-	    sc->ie_bus_read16(sc, IE_SCB_ERROVR(scb));
+	    sc->ie_bus_read16(sc, IE_SCB_ERROVR(scb)));
 
 	/* Clear error counters */
 	sc->ie_bus_write16(sc, IE_SCB_ERRCRC(scb), 0);
@@ -588,7 +588,7 @@ static	int timesthru = 1024;
 			i82586_drop_frames(sc);
 			if ((status & IE_FD_RNR) != 0)
 				sc->rnr_expect = 1;
-			sc->sc_ethercom.ec_if.if_ierrors++;
+			if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
 		} else if (ie_readframe(sc, i) != 0)
 			return (1);
 	}
@@ -638,13 +638,13 @@ static	int timesthru = 1024;
 				return (1);
 
 			i82586_start_transceiver(sc);
-			sc->sc_ethercom.ec_if.if_ierrors++;
+			if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
 			return (0);
 		} else
 			printf("%s: receiver not ready; scbstatus=0x%x\n",
 				device_xname(sc->sc_dev), scbstatus);
 
-		sc->sc_ethercom.ec_if.if_ierrors++;
+		if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
 		return (1);	/* Ask for a reset */
 	}
 
@@ -689,10 +689,10 @@ i82586_tint(struct ie_softc *sc, int scb
 	}
 
 	if (status & IE_STAT_OK) {
-		ifp->if_opackets++;
-		ifp->if_collisions += (status & IE_XS_MAXCOLL);
+		if_statadd2(ifp, if_opackets, 1,
+		    if_collisions, status & IE_XS_MAXCOLL);
 	} else {
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 		/*
 		 * Check SQE and DEFERRED?
 		 * What if more than one bit is set?
@@ -707,7 +707,7 @@ i82586_tint(struct ie_softc *sc, int scb
 			aprint_error_dev(sc->sc_dev, "DMA underrun\n");
 		else if (status & IE_XS_EXCMAX) {
 			aprint_error_dev(sc->sc_dev, "too many collisions\n");
-			sc->sc_ethercom.ec_if.if_collisions += 16;
+			if_statadd(&sc->sc_ethercom.ec_if, if_collisions, 16);
 		}
 	}
 
@@ -1008,7 +1008,7 @@ ie_readframe(
 	int pktlen;
 
 	if (i82586_get_rbd_list(sc, &bstart, &bend, &pktlen) == 0) {
-		sc->sc_ethercom.ec_if.if_ierrors++;
+		if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
 		return (1);
 	}
 
@@ -1016,7 +1016,7 @@ ie_readframe(
 	i82586_release_rbd_list(sc, bstart, bend);
 
 	if (m == 0) {
-		sc->sc_ethercom.ec_if.if_ierrors++;
+		if_statinc(&sc->sc_ethercom.ec_if, if_ierrors);
 		return (0);
 	}
 

Index: src/sys/dev/ic/i82596.c
diff -u src/sys/dev/ic/i82596.c:1.42 src/sys/dev/ic/i82596.c:1.43
--- src/sys/dev/ic/i82596.c:1.42	Wed May 29 10:07:29 2019
+++ src/sys/dev/ic/i82596.c	Wed Jan 29 14:49:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: i82596.c,v 1.42 2019/05/29 10:07:29 msaitoh Exp $ */
+/* $NetBSD: i82596.c,v 1.43 2020/01/29 14:49:44 thorpej Exp $ */
 
 /*
  * Copyright (c) 2003 Jochen Kunz.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i82596.c,v 1.42 2019/05/29 10:07:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82596.c,v 1.43 2020/01/29 14:49:44 thorpej Exp $");
 
 /* autoconfig and device stuff */
 #include <sys/param.h>
@@ -348,8 +348,9 @@ iee_intr(void *intarg)
 						    & IEE_CB_MAXCOL;
 					sc->sc_tx_col += col;
 					if ((status & IEE_CB_OK) != 0) {
-						ifp->if_opackets++;
-						ifp->if_collisions += col;
+						if_statadd2(ifp,
+						    if_opackets, 1,
+						    if_collisions, col);
 					}
 				}
 				sc->sc_next_tbd = 0;

Reply via email to