Module Name: src Committed By: thorpej Date: Wed Jan 29 15:00:39 UTC 2020
Modified Files: src/sys/dev/ic: malo.c mb86950.c mb86960.c mtd803.c Log Message: Adopt <net/if_stats.h>. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/malo.c cvs rdiff -u -r1.32 -r1.33 src/sys/dev/ic/mb86950.c cvs rdiff -u -r1.93 -r1.94 src/sys/dev/ic/mb86960.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/ic/mtd803.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/malo.c diff -u src/sys/dev/ic/malo.c:1.17 src/sys/dev/ic/malo.c:1.18 --- src/sys/dev/ic/malo.c:1.17 Sun Nov 10 21:16:35 2019 +++ src/sys/dev/ic/malo.c Wed Jan 29 15:00:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: malo.c,v 1.17 2019/11/10 21:16:35 chs Exp $ */ +/* $NetBSD: malo.c,v 1.18 2020/01/29 15:00:39 thorpej Exp $ */ /* $OpenBSD: malo.c,v 1.92 2010/08/27 17:08:00 jsg Exp $ */ /* @@ -19,7 +19,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.17 2019/11/10 21:16:35 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.18 2020/01/29 15:00:39 thorpej Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -1043,14 +1043,14 @@ malo_start(struct ifnet *ifp) if (m0->m_len < sizeof (*eh) && (m0 = m_pullup(m0, sizeof (*eh))) == NULL) { - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); continue; } eh = mtod(m0, struct ether_header *); ni = ieee80211_find_txnode(ic, eh->ether_dhost); if (ni == NULL) { m_freem(m0); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); continue; } @@ -1066,7 +1066,7 @@ malo_start(struct ifnet *ifp) if (malo_tx_data(sc, m0, ni) != 0) { ieee80211_free_node(ni); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); break; } } @@ -1352,12 +1352,12 @@ malo_tx_intr(struct malo_softc *sc) case MALO_TXD_STATUS_OK: DPRINTF(2, "%s: data frame was sent successfully\n", device_xname(sc->sc_dev)); - ifp->if_opackets++; + if_statinc(ifp, if_opackets); break; default: DPRINTF(1, "%s: data frame sending error\n", device_xname(sc->sc_dev)); - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); break; } @@ -1415,7 +1415,7 @@ malo_tx_data(struct malo_softc *sc, stru if (m0->m_len < sizeof(struct ieee80211_frame)) { m0 = m_pullup(m0, sizeof(struct ieee80211_frame)); if (m0 == NULL) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); return (ENOBUFS); } } @@ -1555,14 +1555,14 @@ malo_rx_intr(struct malo_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; } @@ -1582,7 +1582,7 @@ malo_rx_intr(struct malo_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; } Index: src/sys/dev/ic/mb86950.c diff -u src/sys/dev/ic/mb86950.c:1.32 src/sys/dev/ic/mb86950.c:1.33 --- src/sys/dev/ic/mb86950.c:1.32 Wed May 29 10:07:29 2019 +++ src/sys/dev/ic/mb86950.c Wed Jan 29 15:00:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mb86950.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $ */ +/* $NetBSD: mb86950.c,v 1.33 2020/01/29 15:00:39 thorpej Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.33 2020/01/29 15:00:39 thorpej Exp $"); /* * Device driver for Fujitsu mb86950 based Ethernet cards. @@ -415,7 +415,7 @@ mb86950_watchdog(struct ifnet *ifp) * Don't know how many packets are lost by this accident. * ... So just errors = errors + 1 */ - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); mb86950_reset(sc); } @@ -735,12 +735,12 @@ mb86950_tint(struct mb86950_softc *sc, u if (tstat & (TX_UNDERFLO | TX_BUS_WR_ERR)) { /* XXX What do we need to do here? reset ? */ - ifp->if_oerrors++; + if_statinc(ifp, if_oerrors); } /* Excessive collision */ if (tstat & TX_16COL) { - ifp->if_collisions += 16; + if_statadd(ifp, if_collisions, 16); /* 16 collisions means that the packet has been thrown away. */ if (sc->txb_sched > 0) sc->txb_sched--; @@ -749,7 +749,7 @@ mb86950_tint(struct mb86950_softc *sc, u /* Transmission complete. */ if (tstat & TX_DONE) { /* Successfully transmitted packets ++. */ - ifp->if_opackets++; + if_statinc(ifp, if_opackets); if (sc->txb_sched > 0) sc->txb_sched--; @@ -757,7 +757,7 @@ mb86950_tint(struct mb86950_softc *sc, u if (tstat & TX_COL) { col = (bus_space_read_1(bst, bsh, DLCR_TX_MODE) & COL_MASK) >> 4; - ifp->if_collisions = ifp->if_collisions + col; + if_statadd(ifp, if_collisions, col); } } @@ -786,7 +786,7 @@ mb86950_rint(struct mb86950_softc *sc, u * count everything else */ if ((rstat & RX_BUS_RD_ERR) == 0) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); } } @@ -810,7 +810,7 @@ mb86950_rint(struct mb86950_softc *sc, u /* Bad packet? */ if ((status & GOOD_PKT) == 0) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); mb86950_drain_fifo(sc); continue; } @@ -820,14 +820,14 @@ mb86950_rint(struct mb86950_softc *sc, u if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN) || len < ETHER_HDR_LEN) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); mb86950_drain_fifo(sc); continue; } if (mb86950_get_fifo(sc, len) != 0) { /* No mbufs? Drop packet. */ - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); mb86950_drain_fifo(sc); return; } Index: src/sys/dev/ic/mb86960.c diff -u src/sys/dev/ic/mb86960.c:1.93 src/sys/dev/ic/mb86960.c:1.94 --- src/sys/dev/ic/mb86960.c:1.93 Wed May 29 10:07:29 2019 +++ src/sys/dev/ic/mb86960.c Wed Jan 29 15:00:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mb86960.c,v 1.93 2019/05/29 10:07:29 msaitoh Exp $ */ +/* $NetBSD: mb86960.c,v 1.94 2020/01/29 15:00:39 thorpej Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.93 2019/05/29 10:07:29 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.94 2020/01/29 15:00:39 thorpej Exp $"); /* * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. @@ -427,7 +427,7 @@ mb86960_watchdog(struct ifnet *ifp) #endif /* Record how many packets are lost by this accident. */ - sc->sc_ec.ec_if.if_oerrors += sc->txb_sched + sc->txb_count; + if_statadd(ifp, if_oerrors, sc->txb_sched + sc->txb_count); mb86960_reset(sc); } @@ -818,9 +818,11 @@ mb86960_tint(struct mb86960_softc *sc, u /* * Update statistics. */ - ifp->if_collisions += 16; - ifp->if_oerrors++; - ifp->if_opackets += sc->txb_sched - left; + net_stat_ref_t nsr = IF_STAT_GETREF(ifp); + if_statadd_ref(nsr, if_collisions, 16); + if_statinc_ref(nsr, if_oerrors); + if_statadd_ref(nsr, if_opackets, sc->txb_sched - left); + IF_STAT_PUTREF(ifp); /* * Collision statistics has been updated. @@ -889,7 +891,7 @@ mb86960_tint(struct mb86960_softc *sc, u col = 1; } else col >>= FE_D4_COL_SHIFT; - ifp->if_collisions += col; + if_statadd(ifp, if_collisions, col); #if FE_DEBUG >= 4 log(LOG_WARNING, "%s: %d collision%s (%d)\n", device_xname(sc->sc_dev), col, col == 1 ? "" : "s", @@ -901,7 +903,7 @@ mb86960_tint(struct mb86960_softc *sc, u * Update total number of successfully * transmitted packets. */ - ifp->if_opackets += sc->txb_sched; + if_statadd(ifp, if_opackets, sc->txb_sched); sc->txb_sched = 0; } @@ -948,7 +950,7 @@ mb86960_rint(struct mb86960_softc *sc, u log(LOG_WARNING, "%s: receive error: %s\n", device_xname(sc->sc_dev), sbuf); #endif - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); } /* @@ -988,7 +990,7 @@ mb86960_rint(struct mb86960_softc *sc, u */ if ((status & FE_RXSTAT_GOODPKT) == 0) { if ((ifp->if_flags & IFF_PROMISC) == 0) { - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); mb86960_droppacket(sc); continue; } @@ -1022,7 +1024,7 @@ mb86960_rint(struct mb86960_softc *sc, u device_xname(sc->sc_dev), len < ETHER_HDR_LEN ? "partial" : "big", len); #endif - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); mb86960_droppacket(sc); continue; } @@ -1051,7 +1053,7 @@ mb86960_rint(struct mb86960_softc *sc, u "%s: out of mbufs; dropping packet (%u bytes)\n", device_xname(sc->sc_dev), len); #endif - ifp->if_ierrors++; + if_statinc(ifp, if_ierrors); mb86960_droppacket(sc); /* @@ -1391,7 +1393,7 @@ mb86960_write_mbufs(struct mb86960_softc log(LOG_ERR, "%s: got a %s packet (%u bytes) to send\n", device_xname(sc->sc_dev), totlen < ETHER_HDR_LEN ? "partial" : "big", totlen); - sc->sc_ec.ec_if.if_oerrors++; + if_statinc(&sc->sc_ec.ec_if, if_oerrors); return; } #endif Index: src/sys/dev/ic/mtd803.c diff -u src/sys/dev/ic/mtd803.c:1.40 src/sys/dev/ic/mtd803.c:1.41 --- src/sys/dev/ic/mtd803.c:1.40 Thu May 30 02:32:18 2019 +++ src/sys/dev/ic/mtd803.c Wed Jan 29 15:00:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mtd803.c,v 1.40 2019/05/30 02:32:18 msaitoh Exp $ */ +/* $NetBSD: mtd803.c,v 1.41 2020/01/29 15:00:39 thorpej Exp $ */ /*- * @@ -44,7 +44,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mtd803.c,v 1.40 2019/05/30 02:32:18 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mtd803.c,v 1.41 2020/01/29 15:00:39 thorpej Exp $"); #include <sys/param.h> @@ -539,7 +539,7 @@ mtd_watchdog(struct ifnet *ifp) int s; log(LOG_ERR, "%s: device timeout\n", device_xname(sc->dev)); - ++sc->ethercom.ec_if.if_oerrors; + if_statinc(ifp, if_oerrors); mtd_stop(ifp, 0); @@ -645,7 +645,7 @@ mtd_rxirq(struct mtd_softc *sc) sc->desc[sc->cur_rx].stat = MTD_RXD_OWNER; sc->desc[sc->cur_rx].conf = MTD_RXBUF_SIZE & MTD_RXD_CONF_BUFS; - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); if (++sc->cur_rx >= MTD_NUM_RXD) sc->cur_rx = 0; continue; @@ -662,7 +662,7 @@ mtd_rxirq(struct mtd_softc *sc) sc->desc[sc->cur_rx].stat = MTD_RXD_OWNER; sc->desc[sc->cur_rx].conf = MTD_RXBUF_SIZE & MTD_RXD_CONF_BUFS; - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); if (++sc->cur_rx >= MTD_NUM_RXD) sc->cur_rx = 0; continue; @@ -680,7 +680,7 @@ mtd_rxirq(struct mtd_softc *sc) if (m == NULL) { aprint_error_dev(sc->dev, "error pulling packet off interface\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); continue; } @@ -701,7 +701,7 @@ mtd_txirq(struct mtd_softc *sc) ifp->if_timer = 0; ifp->if_flags &= ~IFF_OACTIVE; - ++ifp->if_opackets; + if_statinc(ifp, if_opackets); /* XXX FIXME If there is some queued, do an mtd_start? */ @@ -755,44 +755,44 @@ mtd_irq_h(void *args) if (status & MTD_ISR_RXBUN) { aprint_error_dev(sc->dev, "receive buffer unavailable\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if (status & MTD_ISR_RXERR) { aprint_error_dev(sc->dev, "receive error\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if (status & MTD_ISR_TXBUN) { aprint_error_dev(sc->dev, "transmit buffer unavailable\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if ((status & MTD_ISR_PDF)) { aprint_error_dev(sc->dev, "parallel detection fault\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if (status & MTD_ISR_FBUSERR) { aprint_error_dev(sc->dev, "fatal bus error\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if (status & MTD_ISR_TARERR) { aprint_error_dev(sc->dev, "target error\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if (status & MTD_ISR_MASTERR) { aprint_error_dev(sc->dev, "master error\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if (status & MTD_ISR_PARERR) { aprint_error_dev(sc->dev, "parity error\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); } if (status & MTD_ISR_RXIRQ) /* Receive interrupt */