Module Name: src Committed By: thorpej Date: Thu Jan 30 04:56:11 UTC 2020
Modified Files: src/sys/dev/ic: seeq8005.c sgec.c smc83c170.c smc90cx6.c smc91cxx.c wi.c Log Message: Adopt <net/if_stats.h>. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/dev/ic/seeq8005.c cvs rdiff -u -r1.51 -r1.52 src/sys/dev/ic/sgec.c cvs rdiff -u -r1.91 -r1.92 src/sys/dev/ic/smc83c170.c cvs rdiff -u -r1.74 -r1.75 src/sys/dev/ic/smc90cx6.c cvs rdiff -u -r1.103 -r1.104 src/sys/dev/ic/smc91cxx.c cvs rdiff -u -r1.254 -r1.255 src/sys/dev/ic/wi.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/seeq8005.c diff -u src/sys/dev/ic/seeq8005.c:1.65 src/sys/dev/ic/seeq8005.c:1.66 --- src/sys/dev/ic/seeq8005.c:1.65 Sun Nov 10 21:16:35 2019 +++ src/sys/dev/ic/seeq8005.c Thu Jan 30 04:56:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: seeq8005.c,v 1.65 2019/11/10 21:16:35 chs Exp $ */ +/* $NetBSD: seeq8005.c,v 1.66 2020/01/30 04:56:11 thorpej Exp $ */ /* * Copyright (c) 2000, 2001 Ben Harris @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.65 2019/11/10 21:16:35 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.66 2020/01/30 04:56:11 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1077,27 +1077,27 @@ ea_txint(struct seeq8005_softc *sc) * The 8004 contains a 4 bit collision count * in the status register. */ - +#if 0 /* This appears to be broken on 80C04.AE */ -/* ifp->if_collisions += + if_statadd(ifp, if_collisions, (txstatus >> SEEQ_TXSTAT_COLLISIONS_SHIFT) - & SEEQ_TXSTAT_COLLISION_MASK;*/ + & SEEQ_TXSTAT_COLLISION_MASK; +#endif /* Use the TX Collision register */ ea_select_buffer(sc, SEEQ_BUFCODE_TX_COLLS); colls = bus_space_read_1(iot, ioh, SEEQ_BUFWIN); - ifp->if_collisions += colls; + if_statadd(ifp, if_collisions, colls); break; } case SEEQ_8005: /* We known there was at least 1 collision */ - ifp->if_collisions++; + if_statinc(ifp, if_collisions); break; } } else if (txstatus & SEEQ_TXSTAT_COLLISION16) { printf("seeq_intr: col16 %x\n", txstatus); - ifp->if_collisions += 16; - ifp->if_oerrors++; + if_statadd2(ifp, if_collisions, 16, if_oerrors, 1); } /* Have we completed transmission on the packet ? */ @@ -1107,7 +1107,7 @@ ea_txint(struct seeq8005_softc *sc) ifp->if_flags &= ~IFF_OACTIVE; /* Update stats */ - ifp->if_opackets++; + if_statinc(ifp, if_opackets); /* Tx next packet */ @@ -1155,7 +1155,7 @@ ea_rxint(struct seeq8005_softc *sc) /* Sanity-check the next-packet pointer and flags. */ if (__predict_false(ptr < sc->sc_tx_bufsize || (ctrl & SEEQ_PKTCMD_TX))) { - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); log(LOG_ERR, "%s: Rx chain corrupt at %04x (ptr = %04x)\n", device_xname(sc->sc_dev), addr, ptr); @@ -1181,7 +1181,7 @@ ea_rxint(struct seeq8005_softc *sc) if (__predict_false(status & (SEEQ_RXSTAT_CRC_ERROR | SEEQ_RXSTAT_DRIBBLE_ERROR | SEEQ_RXSTAT_SHORT_FRAME))) { - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); log(LOG_WARNING, "%s: rx packet error at %04x (err=%02x)\n", device_xname(sc->sc_dev), addr, status & 0x0f); @@ -1195,7 +1195,7 @@ ea_rxint(struct seeq8005_softc *sc) * wants incoming packets in a single mbuf cluster. */ if (__predict_false(len > MCLBYTES)) { - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); log(LOG_ERR, "%s: rx packet size error at %04x (len=%d)\n", device_xname(sc->sc_dev), addr, len); @@ -1478,7 +1478,7 @@ ea_watchdog(struct ifnet *ifp) log(LOG_ERR, "%s: lost Tx interrupt (status = 0x%04x)\n", device_xname(sc->sc_dev), SEEQ_READ16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_STATUS)); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); /* Kick the interface */ Index: src/sys/dev/ic/sgec.c diff -u src/sys/dev/ic/sgec.c:1.51 src/sys/dev/ic/sgec.c:1.52 --- src/sys/dev/ic/sgec.c:1.51 Tue May 28 07:41:48 2019 +++ src/sys/dev/ic/sgec.c Thu Jan 30 04:56:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sgec.c,v 1.51 2019/05/28 07:41:48 msaitoh Exp $ */ +/* $NetBSD: sgec.c,v 1.52 2020/01/30 04:56:11 thorpej Exp $ */ /* * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.51 2019/05/28 07:41:48 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.52 2020/01/30 04:56:11 thorpej Exp $"); #include "opt_inet.h" @@ -452,7 +452,7 @@ sgec_intr(struct ze_softc *sc) if (++sc->sc_nextrx == RXDESCS) sc->sc_nextrx = 0; if (len < ETHER_MIN_LEN) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); m_freem(m); } else { m_set_rcvif(m, ifp); @@ -495,7 +495,7 @@ sgec_intr(struct ze_softc *sc) sc->sc_txcnt = 0; sc->sc_inq -= map->dm_nsegs; KASSERT(zc->zc_xmit[lastack].ze_tdes1 & ZE_TDES1_LS); - ifp->if_opackets++; + if_statinc(ifp, if_opackets); bus_dmamap_unload(sc->sc_dmat, map); KASSERT(sc->sc_txmbuf[lastack]); m_freem(sc->sc_txmbuf[lastack]); Index: src/sys/dev/ic/smc83c170.c diff -u src/sys/dev/ic/smc83c170.c:1.91 src/sys/dev/ic/smc83c170.c:1.92 --- src/sys/dev/ic/smc83c170.c:1.91 Wed Jan 22 03:48:10 2020 +++ src/sys/dev/ic/smc83c170.c Thu Jan 30 04:56:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: smc83c170.c,v 1.91 2020/01/22 03:48:10 thorpej Exp $ */ +/* $NetBSD: smc83c170.c,v 1.92 2020/01/30 04:56:11 thorpej Exp $ */ /*- * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: smc83c170.c,v 1.91 2020/01/22 03:48:10 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smc83c170.c,v 1.92 2020/01/30 04:56:11 thorpej Exp $"); #include <sys/param.h> @@ -545,7 +545,7 @@ epic_watchdog(struct ifnet *ifp) struct epic_softc *sc = ifp->if_softc; printf("%s: device timeout\n", device_xname(sc->sc_dev)); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); (void)epic_init(ifp); } @@ -645,7 +645,7 @@ epic_intr(void *arg) if (rxstatus & ER_RXSTAT_ALIGNERROR) printf("%s: alignment error\n", device_xname(sc->sc_dev)); - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); EPIC_INIT_RXDESC(sc, i); continue; } @@ -663,7 +663,7 @@ epic_intr(void *arg) /* * Runt packet; drop it now. */ - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); EPIC_INIT_RXDESC(sc, i); bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, ds->ds_dmamap->dm_mapsize, @@ -696,7 +696,7 @@ epic_intr(void *arg) m = ds->ds_mbuf; if (epic_add_rxbuf(sc, i) != 0) { dropit: - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); EPIC_INIT_RXDESC(sc, i); bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, @@ -762,15 +762,18 @@ epic_intr(void *arg) /* * Check for errors and collisions. */ + net_stat_ref_t nsr = IF_STAT_GETREF(ifp); if ((txstatus & ET_TXSTAT_PACKETTX) == 0) - ifp->if_oerrors++; + if_statinc_ref(nsr, if_oerrors); else - ifp->if_opackets++; - ifp->if_collisions += - TXSTAT_COLLISIONS(txstatus); + if_statinc_ref(nsr, if_opackets); + if (TXSTAT_COLLISIONS(txstatus)) + if_statadd_ref(nsr, if_collisions, + TXSTAT_COLLISIONS(txstatus)); if (txstatus & ET_TXSTAT_CARSENSELOST) printf("%s: lost carrier\n", device_xname(sc->sc_dev)); + IF_STAT_PUTREF(ifp); } /* Update the dirty transmit buffer pointer. */ Index: src/sys/dev/ic/smc90cx6.c diff -u src/sys/dev/ic/smc90cx6.c:1.74 src/sys/dev/ic/smc90cx6.c:1.75 --- src/sys/dev/ic/smc90cx6.c:1.74 Tue Feb 5 06:17:02 2019 +++ src/sys/dev/ic/smc90cx6.c Thu Jan 30 04:56:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: smc90cx6.c,v 1.74 2019/02/05 06:17:02 msaitoh Exp $ */ +/* $NetBSD: smc90cx6.c,v 1.75 2020/01/30 04:56:11 thorpej Exp $ */ /*- * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.74 2019/02/05 06:17:02 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.75 2020/01/30 04:56:11 thorpej Exp $"); /* #define BAHSOFTCOPY */ #define BAHRETRANSMIT /**/ @@ -523,7 +523,7 @@ bah_srint(void *vsc) * count it as input error (we dont have any other * detectable) */ - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); goto cleanup; } @@ -548,7 +548,7 @@ bah_srint(void *vsc) MCLGET(m, M_DONTWAIT); if (m == 0) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); goto cleanup; } @@ -575,7 +575,7 @@ bah_srint(void *vsc) MGET(m, M_DONTWAIT, MT_DATA); if (m == 0) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); goto cleanup; } @@ -654,7 +654,7 @@ bah_tint(struct bah_softc *sc, int isr) */ if (isr & BAH_TMA || sc->sc_broadcast[buffer]) - sc->sc_arccom.ac_if.if_opackets++; + if_statinc(ifp, if_opackets); #ifdef BAHRETRANSMIT else if (ifp->if_flags & IFF_LINK2 && ifp->if_timer > 0 && --sc->sc_retransmits[buffer] > 0) { @@ -664,7 +664,7 @@ bah_tint(struct bah_softc *sc, int isr) } #endif else - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); /* We know we can accept another buffer at this point. */ @@ -760,7 +760,7 @@ bahintr(void *arg) * PUTREG(BAHCMD, BAH_CONF(CONF_LONG)); */ PUTREG(BAHCMD, BAH_CLR(CLR_RECONFIG)); - sc->sc_arccom.ac_if.if_collisions++; + if_statinc(&sc->sc_arccom.ac_if, if_collisions); /* * If less than 2 seconds per reconfig: Index: src/sys/dev/ic/smc91cxx.c diff -u src/sys/dev/ic/smc91cxx.c:1.103 src/sys/dev/ic/smc91cxx.c:1.104 --- src/sys/dev/ic/smc91cxx.c:1.103 Fri Dec 6 07:12:38 2019 +++ src/sys/dev/ic/smc91cxx.c Thu Jan 30 04:56:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: smc91cxx.c,v 1.103 2019/12/06 07:12:38 maxv Exp $ */ +/* $NetBSD: smc91cxx.c,v 1.104 2020/01/30 04:56:11 thorpej Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.103 2019/12/06 07:12:38 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.104 2020/01/30 04:56:11 thorpej Exp $"); #include "opt_inet.h" @@ -643,7 +643,7 @@ smc91cxx_start(struct ifnet *ifp) if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN)) { printf("%s: large packet discarded\n", device_xname(sc->sc_dev)); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); IFQ_DEQUEUE(&ifp->if_snd, m); m_freem(m); goto readcheck; @@ -762,7 +762,7 @@ smc91cxx_start(struct ifnet *ifp) /* Hand off a copy to the bpf. */ bpf_mtap(ifp, m, BPF_D_OUT); - ifp->if_opackets++; + if_statinc(ifp, if_opackets); m_freem(m); readcheck: @@ -891,7 +891,7 @@ smc91cxx_intr(void *arg) /* Receive overrun interrupts. */ if (status & IM_RX_OVRN_INT) { smc91cxx_intr_ack_write(bst, bsh, IM_RX_OVRN_INT, 0); - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); } /* Receive interrupts. */ @@ -951,10 +951,10 @@ smc91cxx_intr(void *arg) printf("%s: successful packet caused TX" " interrupt?!\n", device_xname(sc->sc_dev)); } else - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); if (tx_status & EPHSR_LATCOL) - ifp->if_collisions++; + if_statinc(ifp, if_collisions); /* Disable this interrupt (start will reenable if needed). */ mask &= ~IM_TX_INT; @@ -995,10 +995,14 @@ smc91cxx_intr(void *arg) card_stats = bus_space_read_2(bst, bsh, COUNTER_REG_W); /* Single collisions. */ - ifp->if_collisions += card_stats & ECR_COLN_MASK; + if (card_stats & ECR_COLN_MASK) + if_statadd(ifp, if_collisions, + card_stats & ECR_COLN_MASK); /* Multiple collisions. */ - ifp->if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4; + if ((card_stats & ECR_MCOLN_MASK) >> 4) + if_statadd(ifp, if_collisions, + (card_stats & ECR_MCOLN_MASK) >> 4); SMC_SELECT_BANK(sc, 2); @@ -1080,7 +1084,7 @@ smc91cxx_read(struct smc91cxx_softc *sc) packetlen &= RLEN_MASK; if (packetlen < ETHER_MIN_LEN - ETHER_CRC_LEN + 6 || packetlen > 1534) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); goto out; } @@ -1092,7 +1096,7 @@ smc91cxx_read(struct smc91cxx_softc *sc) /* Account for receive errors and discard. */ if (status & RS_ERRORS) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); goto out; } @@ -1114,7 +1118,7 @@ smc91cxx_read(struct smc91cxx_softc *sc) MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_freem(m); - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); aprint_error_dev(sc->sc_dev, "can't allocate cluster for incoming packet\n"); goto out; @@ -1296,7 +1300,7 @@ smc91cxx_watchdog(struct ifnet *ifp) struct smc91cxx_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); smc91cxx_reset(sc); } Index: src/sys/dev/ic/wi.c diff -u src/sys/dev/ic/wi.c:1.254 src/sys/dev/ic/wi.c:1.255 --- src/sys/dev/ic/wi.c:1.254 Thu Dec 5 03:11:40 2019 +++ src/sys/dev/ic/wi.c Thu Jan 30 04:56:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wi.c,v 1.254 2019/12/05 03:11:40 msaitoh Exp $ */ +/* $NetBSD: wi.c,v 1.255 2020/01/30 04:56:11 thorpej Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.254 2019/12/05 03:11:40 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.255 2020/01/30 04:56:11 thorpej Exp $"); #define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */ #define WI_HERMES_STATS_WAR /* Work around stats counter bug. */ @@ -1173,7 +1173,7 @@ wi_start(struct ifnet *ifp) if (m0 == NULL) break; IFQ_DEQUEUE(&ifp->if_snd, m0); - ifp->if_opackets++; + if_statinc(ifp, if_opackets); m_copydata(m0, 0, ETHER_HDR_LEN, (void *)&frmhdr.wi_ehdr); bpf_mtap(ifp, m0, BPF_D_OUT); @@ -1181,7 +1181,7 @@ wi_start(struct ifnet *ifp) eh = mtod(m0, struct ether_header *); ni = ieee80211_find_txnode(ic, eh->ether_dhost); if (ni == NULL) { - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); continue; } if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && @@ -1191,7 +1191,7 @@ wi_start(struct ifnet *ifp) } if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); continue; } wh = mtod(m0, struct ieee80211_frame *); @@ -1207,7 +1207,7 @@ wi_start(struct ifnet *ifp) (wh->i_fc[1] & IEEE80211_FC1_WEP)) { if (ieee80211_crypto_encap(ic, ni, m0) == NULL) { m_freem(m0); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); goto next; } frmhdr.wi_tx_ctl |= htole16(WI_TXCNTL_NOCRYPT); @@ -1257,7 +1257,7 @@ wi_start(struct ifnet *ifp) wi_mwrite_bap(sc, fid, off, m0, m0->m_pkthdr.len) != 0) { aprint_error_dev(sc->sc_dev, "%s write fid %x failed\n", __func__, fid); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); m_freem(m0); goto next; } @@ -1332,7 +1332,7 @@ wi_watchdog(struct ifnet *ifp) if (sc->sc_tx_timer) { if (--sc->sc_tx_timer == 0) { printf("%s: device timeout\n", ifp->if_xname); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); wi_init(ifp); return; } @@ -1669,7 +1669,7 @@ wi_rx_intr(struct wi_softc *sc) if (wi_read_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr))) { aprint_error_dev(sc->sc_dev, "%s read fid %x failed\n", __func__, fid); - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); return; } @@ -1682,7 +1682,7 @@ wi_rx_intr(struct wi_softc *sc) status = le16toh(frmhdr.wi_status); if ((status & WI_STAT_ERRSTAT) != 0 && ic->ic_opmode != IEEE80211_M_MONITOR) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); DPRINTF(("wi_rx_intr: fid %x error status %x\n", fid, status)); return; } @@ -1698,7 +1698,7 @@ wi_rx_intr(struct wi_softc *sc) */ if (off + len > MCLBYTES) { if (ic->ic_opmode != IEEE80211_M_MONITOR) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); DPRINTF(("wi_rx_intr: oversized packet\n")); return; } else @@ -1707,7 +1707,7 @@ wi_rx_intr(struct wi_softc *sc) MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); DPRINTF(("wi_rx_intr: MGET failed\n")); return; } @@ -1715,7 +1715,7 @@ wi_rx_intr(struct wi_softc *sc) MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_freem(m); - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); DPRINTF(("wi_rx_intr: MCLGET failed\n")); return; } @@ -1831,7 +1831,7 @@ wi_tx_ex_intr(struct wi_softc *sc) printf(", status=0x%x", status); printf("\n"); } - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); rssd = &sc->sc_rssd[frmhdr.wi_tx_idx]; id = &rssd->rd_desc; if ((status & WI_TXSTAT_RET_ERR) != 0) @@ -2084,9 +2084,10 @@ wi_info_intr(struct wi_softc *sc) #endif *ptr += stat; } - ifp->if_collisions = sc->sc_stats.wi_tx_single_retries + + if_statadd(ifp, if_collisions, + sc->sc_stats.wi_tx_single_retries + sc->sc_stats.wi_tx_multi_retries + - sc->sc_stats.wi_tx_retry_limit; + sc->sc_stats.wi_tx_retry_limit); break; case WI_INFO_SCAN_RESULTS: