Module Name:    src
Committed By:   thorpej
Date:           Thu Jan 30 05:42:00 UTC 2020

Modified Files:
        src/sys/dev/pci: if_et.c if_jme.c if_msk.c if_nfe.c if_sip.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_et.c
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pci/if_jme.c
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/pci/if_msk.c
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pci/if_nfe.c
cvs rdiff -u -r1.175 -r1.176 src/sys/dev/pci/if_sip.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/pci/if_et.c
diff -u src/sys/dev/pci/if_et.c:1.28 src/sys/dev/pci/if_et.c:1.29
--- src/sys/dev/pci/if_et.c:1.28	Thu Nov 28 17:09:10 2019
+++ src/sys/dev/pci/if_et.c	Thu Jan 30 05:42:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_et.c,v 1.28 2019/11/28 17:09:10 maxv Exp $	*/
+/*	$NetBSD: if_et.c,v 1.29 2020/01/30 05:42:00 thorpej Exp $	*/
 /*	$OpenBSD: if_et.c,v 1.12 2008/07/11 09:29:02 kevlo $	*/
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.28 2019/11/28 17:09:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.29 2020/01/30 05:42:00 thorpej Exp $");
 
 #include "opt_inet.h"
 #include "vlan.h"
@@ -1197,7 +1197,7 @@ et_start(struct ifnet *ifp)
 		}
 
 		if (et_encap(sc, &m)) {
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 			ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
@@ -1796,13 +1796,13 @@ et_rxeof(struct et_softc *sc)
 		CSR_WRITE_4(sc, ET_RXSTAT_POS, rxstat_pos);
 
 		if (ring_idx >= ET_RX_NRING) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			aprint_error_dev(sc->sc_dev, "invalid ring index %d\n",
 			    ring_idx);
 			continue;
 		}
 		if (buf_idx >= ET_RX_NDESC) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			aprint_error_dev(sc->sc_dev, "invalid buf index %d\n",
 			    buf_idx);
 			continue;
@@ -1817,7 +1817,7 @@ et_rxeof(struct et_softc *sc)
 		if (rbd->rbd_newbuf(rbd, buf_idx, 0) == 0) {
 			if (buflen < ETHER_CRC_LEN) {
 				m_freem(m);
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 			} else {
 				m->m_pkthdr.len = m->m_len = buflen -
 				    ETHER_CRC_LEN;
@@ -1826,7 +1826,7 @@ et_rxeof(struct et_softc *sc)
 				if_percpuq_enqueue(ifp->if_percpuq, m);
 			}
 		} else {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 		}
 
 		rx_ring = &sc->sc_rx_ring[ring_idx];
@@ -2018,7 +2018,7 @@ et_txeof(struct et_softc *sc)
 			bus_dmamap_unload(sc->sc_dmat, tb->tb_dmap);
 			m_freem(tb->tb_mbuf);
 			tb->tb_mbuf = NULL;
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 		}
 
 		if (++tbd->tbd_start_index == ET_TX_NDESC) {

Index: src/sys/dev/pci/if_jme.c
diff -u src/sys/dev/pci/if_jme.c:1.46 src/sys/dev/pci/if_jme.c:1.47
--- src/sys/dev/pci/if_jme.c:1.46	Mon Sep 23 06:50:04 2019
+++ src/sys/dev/pci/if_jme.c	Thu Jan 30 05:42:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_jme.c,v 1.46 2019/09/23 06:50:04 maxv Exp $	*/
+/*	$NetBSD: if_jme.c,v 1.47 2020/01/30 05:42:00 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2008 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.46 2019/09/23 06:50:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.47 2020/01/30 05:42:00 thorpej Exp $");
 
 
 #include <sys/param.h>
@@ -1095,7 +1095,7 @@ jme_intr_rx(jme_softc_t *sc) {
 			printf("rx error flags 0x%x buflen 0x%x\n",
 			    flags, buflen);
 #endif
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			/* reuse the mbufs */
 			for (seg = 0; seg < nsegs; seg++) {
 				m = sc->jme_rxmbuf[i];
@@ -1139,7 +1139,7 @@ jme_intr_rx(jme_softc_t *sc) {
 				JME_DESC_INC(sc->jme_rx_cons, JME_NBUFS);
 				i = sc->jme_rx_cons;
 			}
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			continue;
 		}
 
@@ -1595,13 +1595,14 @@ jme_txeof(struct jme_softc *sc)
 			break;
 
 		if ((status & (JME_TD_TMOUT | JME_TD_RETRY_EXP)) != 0)
-			ifp->if_oerrors++;
+			if_statinc(ifp, if_oerrors);
 		else {
-			ifp->if_opackets++;
-			if ((status & JME_TD_COLLISION) != 0)
-				ifp->if_collisions +=
+			if_statinc(ifp, if_opackets);
+			if ((status & JME_TD_COLLISION) != 0) {
+				if_statadd(ifp, if_collisions,
 				    le32toh(desc->buflen) &
-				    JME_TD_BUF_LEN_MASK;
+				    JME_TD_BUF_LEN_MASK);
+			}
 		}
 		/*
 		 * Only the first descriptor of multi-descriptor
@@ -1673,7 +1674,7 @@ nexttx:
 		/* try to add this mbuf to the TX ring */
 		if (jme_encap(sc, &mb_head)) {
 			if (mb_head == NULL) {
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 				/* packet dropped, try next one */
 				goto nexttx;
 			}
@@ -1726,7 +1727,7 @@ jme_ifwatchdog(struct ifnet *ifp)
 	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
 	printf("%s: device timeout\n", device_xname(sc->jme_dev));
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 	jme_init(ifp, 0);
 }
 

Index: src/sys/dev/pci/if_msk.c
diff -u src/sys/dev/pci/if_msk.c:1.96 src/sys/dev/pci/if_msk.c:1.97
--- src/sys/dev/pci/if_msk.c:1.96	Sun Dec  1 12:47:10 2019
+++ src/sys/dev/pci/if_msk.c	Thu Jan 30 05:42:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.96 2019/12/01 12:47:10 maxv Exp $ */
+/* $NetBSD: if_msk.c,v 1.97 2020/01/30 05:42:00 thorpej Exp $ */
 /*	$OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $	*/
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.96 2019/12/01 12:47:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.97 2020/01/30 05:42:00 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1986,7 +1986,7 @@ msk_watchdog(struct ifnet *ifp)
 	if (sc_if->sk_cdata.sk_tx_cnt != 0) {
 		aprint_error_dev(sc_if->sk_dev, "watchdog timeout\n");
 
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 
 		/* XXX Resets both ports; we shouldn't do that. */
 		mskc_reset(sc_if->sk_softc);
@@ -2077,7 +2077,7 @@ msk_rxeof(struct sk_if_softc *sc_if, uin
 	if (total_len < SK_MIN_FRAMELEN ||
 	    total_len > ETHER_MAX_LEN_JUMBO ||
 	    msk_rxvalid(sc, rxstat, total_len) == 0) {
-		ifp->if_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		m_freem(m);
 		return;
 	}
@@ -2121,7 +2121,7 @@ msk_txeof(struct sk_if_softc *sc_if)
 			msk_dump_txdesc(cur_tx, idx);
 #endif
 		if (sk_ctl & SK_Y2_TXCTL_LASTFRAG)
-			ifp->if_opackets++;
+			if_statinc(ifp, if_opackets);
 		if (sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf != NULL) {
 			entry = sc_if->sk_cdata.sk_tx_map[idx];
 

Index: src/sys/dev/pci/if_nfe.c
diff -u src/sys/dev/pci/if_nfe.c:1.72 src/sys/dev/pci/if_nfe.c:1.73
--- src/sys/dev/pci/if_nfe.c:1.72	Fri Sep 13 07:55:07 2019
+++ src/sys/dev/pci/if_nfe.c	Thu Jan 30 05:42:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_nfe.c,v 1.72 2019/09/13 07:55:07 msaitoh Exp $	*/
+/*	$NetBSD: if_nfe.c,v 1.73 2020/01/30 05:42:00 thorpej Exp $	*/
 /*	$OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $	*/
 
 /*-
@@ -21,7 +21,7 @@
 /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.72 2019/09/13 07:55:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.73 2020/01/30 05:42:00 thorpej Exp $");
 
 #include "opt_inet.h"
 #include "vlan.h"
@@ -837,7 +837,7 @@ nfe_rxeof(struct nfe_softc *sc)
 		}
 
 		if (flags & NFE_RX_ERROR) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -850,7 +850,7 @@ nfe_rxeof(struct nfe_softc *sc)
 		 */
 		MGETHDR(mnew, M_DONTWAIT, MT_DATA);
 		if (mnew == NULL) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			goto skip;
 		}
 
@@ -860,13 +860,13 @@ nfe_rxeof(struct nfe_softc *sc)
 			if ((jbuf = nfe_jalloc(sc, i)) == NULL) {
 				if (len > MCLBYTES) {
 					m_freem(mnew);
-					ifp->if_ierrors++;
+					if_statinc(ifp, if_ierrors);
 					goto skip1;
 				}
 				MCLGET(mnew, M_DONTWAIT);
 				if ((mnew->m_flags & M_EXT) == 0) {
 					m_freem(mnew);
-					ifp->if_ierrors++;
+					if_statinc(ifp, if_ierrors);
 					goto skip1;
 				}
 
@@ -886,7 +886,7 @@ nfe_rxeof(struct nfe_softc *sc)
 			MCLGET(mnew, M_DONTWAIT);
 			if ((mnew->m_flags & M_EXT) == 0) {
 				m_freem(mnew);
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				goto skip;
 			}
 
@@ -909,7 +909,7 @@ nfe_rxeof(struct nfe_softc *sc)
 					panic("%s: could not load old rx mbuf",
 					    device_xname(sc->sc_dev));
 				}
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				goto skip;
 			}
 			physaddr = data->map->dm_segs[0].ds_addr;
@@ -1026,9 +1026,9 @@ nfe_txeof(struct nfe_softc *sc)
 				snprintb(buf, sizeof(buf), NFE_V1_TXERR, flags);
 				aprint_error_dev(sc->sc_dev, "tx v1 error %s\n",
 				    buf);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 			} else
-				ifp->if_opackets++;
+				if_statinc(ifp, if_opackets);
 		} else {
 			if ((flags & NFE_TX_LASTFRAG_V2) == 0 &&
 			    data->m == NULL)
@@ -1038,9 +1038,9 @@ nfe_txeof(struct nfe_softc *sc)
 				snprintb(buf, sizeof(buf), NFE_V2_TXERR, flags);
 				aprint_error_dev(sc->sc_dev, "tx v2 error %s\n",
 				    buf);
-				ifp->if_oerrors++;
+				if_statinc(ifp, if_oerrors);
 			} else
-				ifp->if_opackets++;
+				if_statinc(ifp, if_opackets);
 		}
 
 		if (data->m == NULL) {	/* should not get there */
@@ -1241,7 +1241,7 @@ nfe_watchdog(struct ifnet *ifp)
 	ifp->if_flags &= ~IFF_RUNNING;
 	nfe_init(ifp);
 
-	ifp->if_oerrors++;
+	if_statinc(ifp, if_oerrors);
 }
 
 int

Index: src/sys/dev/pci/if_sip.c
diff -u src/sys/dev/pci/if_sip.c:1.175 src/sys/dev/pci/if_sip.c:1.176
--- src/sys/dev/pci/if_sip.c:1.175	Fri Sep 13 07:55:07 2019
+++ src/sys/dev/pci/if_sip.c	Thu Jan 30 05:42:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sip.c,v 1.175 2019/09/13 07:55:07 msaitoh Exp $	*/
+/*	$NetBSD: if_sip.c,v 1.176 2020/01/30 05:42:00 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.175 2019/09/13 07:55:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.176 2020/01/30 05:42:00 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1702,7 +1702,7 @@ sipcom_watchdog(struct ifnet *ifp)
 
 	if (sc->sc_txfree != sc->sc_ntxdesc) {
 		printf("%s: device timeout\n", device_xname(sc->sc_dev));
-		ifp->if_oerrors++;
+		if_statinc(ifp, if_oerrors);
 
 		/* Reset the interface. */
 		(void) sipcom_init(ifp);
@@ -1995,11 +1995,12 @@ sipcom_txintr(struct sip_softc *sc)
 		SIMPLEQ_INSERT_TAIL(&sc->sc_txfreeq, txs, txs_q);
 
 		/* Check for errors and collisions. */
+		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 		if (cmdsts & (CMDSTS_Tx_TXA | CMDSTS_Tx_TFU | CMDSTS_Tx_ED |
 		    CMDSTS_Tx_EC)) {
-			ifp->if_oerrors++;
+			if_statinc_ref(nsr, if_oerrors);
 			if (cmdsts & CMDSTS_Tx_EC)
-				ifp->if_collisions += 16;
+				if_statadd_ref(nsr, if_collisions, 16);
 			if (ifp->if_flags & IFF_DEBUG) {
 				if (cmdsts & CMDSTS_Tx_ED)
 					printf("%s: excessive deferral\n",
@@ -2010,9 +2011,12 @@ sipcom_txintr(struct sip_softc *sc)
 			}
 		} else {
 			/* Packet was transmitted successfully. */
-			ifp->if_opackets++;
-			ifp->if_collisions += CMDSTS_COLLISIONS(cmdsts);
+			if_statinc_ref(nsr, if_opackets);
+			if (CMDSTS_COLLISIONS(cmdsts))
+				if_statadd_ref(nsr, if_collisions,
+				    CMDSTS_COLLISIONS(cmdsts));
 		}
+		IF_STAT_PUTREF(ifp);
 	}
 
 	/*
@@ -2083,7 +2087,7 @@ gsip_rxintr(struct sip_softc *sc)
 			 * 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);
 			sip_init_rxdesc(sc, i);
@@ -2123,7 +2127,7 @@ gsip_rxintr(struct sip_softc *sc)
 		/* If an error occurred, update stats and drop the packet. */
 		if (cmdsts & (CMDSTS_Rx_RXA | CMDSTS_Rx_RUNT |
 		    CMDSTS_Rx_ISE | CMDSTS_Rx_CRCE | CMDSTS_Rx_FAE)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			if ((cmdsts & CMDSTS_Rx_RXA) != 0 &&
 			    (cmdsts & CMDSTS_Rx_RXO) == 0) {
 				/* Receive overrun handled elsewhere. */
@@ -2154,7 +2158,7 @@ gsip_rxintr(struct sip_softc *sc)
 			struct mbuf *nm;
 			MGETHDR(nm, M_DONTWAIT, MT_DATA);
 			if (nm == NULL) {
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				m_freem(m);
 				continue;
 			}
@@ -2272,7 +2276,7 @@ sip_rxintr(struct sip_softc *sc)
 
 		/* If any collisions were seen on the wire, count one. */
 		if (cmdsts & CMDSTS_Rx_COL)
-			ifp->if_collisions++;
+			if_statinc(ifp, if_collisions);
 
 		/*
 		 * If an error occurred, update stats, clear the status
@@ -2281,7 +2285,7 @@ sip_rxintr(struct sip_softc *sc)
 		 */
 		if (cmdsts & (CMDSTS_Rx_RXA | CMDSTS_Rx_RUNT |
 		    CMDSTS_Rx_ISE | CMDSTS_Rx_CRCE | CMDSTS_Rx_FAE)) {
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			if ((cmdsts & CMDSTS_Rx_RXA) != 0 &&
 			    (cmdsts & CMDSTS_Rx_RXO) == 0) {
 				/* Receive overrun handled elsewhere. */
@@ -2337,7 +2341,7 @@ sip_rxintr(struct sip_softc *sc)
 			m = rxs->rxs_mbuf;
 			if (sipcom_add_rxbuf(sc, i) != 0) {
  dropit:
-				ifp->if_ierrors++;
+				if_statinc(ifp, if_ierrors);
 				sip_init_rxdesc(sc, i);
 				bus_dmamap_sync(sc->sc_dmat,
 				    rxs->rxs_dmamap, 0,
@@ -2356,7 +2360,7 @@ sip_rxintr(struct sip_softc *sc)
 		MGETHDR(m, M_DONTWAIT, MT_DATA);
 		if (m == NULL) {
  dropit:
-			ifp->if_ierrors++;
+			if_statinc(ifp, if_ierrors);
 			sip_init_rxdesc(sc, i);
 			bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
 			    rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);

Reply via email to