Wed Jan 29 05:30:14 2020 UTC ()
Adopt <net/if_stats.h>.
(thorpej)
diff -r1.27 -r1.28 src/sys/arch/mips/adm5120/dev/if_admsw.c
diff -r1.47 -r1.48 src/sys/arch/mips/alchemy/dev/if_aumac.c
diff -r1.37 -r1.38 src/sys/arch/mips/atheros/dev/if_ae.c
diff -r1.15 -r1.16 src/sys/arch/mips/cavium/dev/if_cnmac.c
diff -r1.7 -r1.8 src/sys/arch/mips/cavium/dev/octeon_gmx.c
diff -r1.2 -r1.3 src/sys/arch/mips/cavium/dev/octeon_pip.c
diff -r1.19 -r1.20 src/sys/arch/mips/ralink/ralink_eth.c
diff -r1.61 -r1.62 src/sys/arch/mips/sibyte/dev/sbmac.c
--- src/sys/arch/mips/adm5120/dev/if_admsw.c 2019/12/05 06:25:33 1.27
+++ src/sys/arch/mips/adm5120/dev/if_admsw.c 2020/01/29 05:30:14 1.28
@@ -1,4 +1,4 @@
-/* $NetBSD: if_admsw.c,v 1.27 2019/12/05 06:25:33 msaitoh Exp $ */
+/* $NetBSD: if_admsw.c,v 1.28 2020/01/29 05:30:14 thorpej Exp $ */
/*-
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_admsw.c,v 1.27 2019/12/05 06:25:33 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_admsw.c,v 1.28 2020/01/29 05:30:14 thorpej Exp $");
#include <sys/param.h>
@@ -871,7 +871,7 @@
gotone = 1;
/* printf("clear tx slot %d\n", i); */
- ifp->if_opackets++;
+ if_statinc(ifp, if_opackets);
sc->sc_txfree++;
}
@@ -995,7 +995,7 @@
m = ds->ds_mbuf;
if (admsw_add_rxlbuf(sc, i) != 0) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
ADMSW_INIT_RXLDESC(sc, i);
bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0,
ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
--- src/sys/arch/mips/alchemy/dev/if_aumac.c 2019/05/28 07:41:47 1.47
+++ src/sys/arch/mips/alchemy/dev/if_aumac.c 2020/01/29 05:30:14 1.48
@@ -1,4 +1,4 @@
-/* $NetBSD: if_aumac.c,v 1.47 2019/05/28 07:41:47 msaitoh Exp $ */
+/* $NetBSD: if_aumac.c,v 1.48 2020/01/29 05:30:14 thorpej Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.47 2019/05/28 07:41:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aumac.c,v 1.48 2020/01/29 05:30:14 thorpej Exp $");
@@ -565,16 +565,18 @@
stat = bus_space_read_4(sc->sc_st, sc->sc_dma_sh,
MACDMA_TX_STAT(i));
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
if (stat & TX_STAT_FA) {
/* XXX STATS */
- ifp->if_oerrors++;
+ if_statinc_ref(nsr, if_oerrors);
} else
- ifp->if_opackets++;
+ if_statinc_ref(nsr, if_opackets);
if (stat & TX_STAT_EC)
- ifp->if_collisions += 16;
- else
- ifp->if_collisions += TX_STAT_CC(stat);
+ if_statadd_ref(nsr, if_collisions, 16);
+ else if (TX_STAT_CC(stat))
+ if_statadd_ref(nsr, if_collisions, TX_STAT_CC(stat));
+ IF_STAT_PUTREF(ifp);
sc->sc_txfree++;
ifp->if_flags &= ~IFF_OACTIVE;
@@ -670,7 +672,7 @@
PRINTERR("dribbling bit");
}
#undef PRINTERR
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
dropit:
/* reuse the current descriptor */
--- src/sys/arch/mips/atheros/dev/if_ae.c 2019/09/13 07:55:06 1.37
+++ src/sys/arch/mips/atheros/dev/if_ae.c 2020/01/29 05:30:14 1.38
@@ -1,4 +1,4 @@
-/* $Id: if_ae.c,v 1.37 2019/09/13 07:55:06 msaitoh Exp $ */
+/* $Id: if_ae.c,v 1.38 2020/01/29 05:30:14 thorpej Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
* Copyright (c) 2006 Garrett D'Amore.
@@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ae.c,v 1.37 2019/09/13 07:55:06 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ae.c,v 1.38 2020/01/29 05:30:14 thorpej Exp $");
#include <sys/param.h>
@@ -784,7 +784,7 @@
if (doing_transmit) {
printf("%s: transmit timeout\n", device_xname(sc->sc_dev));
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
}
else
printf("%s: spurious watchdog timeout\n", device_xname(sc->sc_dev));
@@ -1033,7 +1033,7 @@
* If any collisions were seen on the wire, count one.
*/
if (rxstat & ADSTAT_Rx_CS)
- ifp->if_collisions++;
+ if_statinc(ifp, if_collisions);
/*
* If an error occurred, update stats, clear the status
@@ -1050,7 +1050,7 @@
if (rxstat & (bit)) \
printf("%s: receive error: %s\n", \
device_xname(sc->sc_dev), str)
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
PRINTERR(ADSTAT_Rx_DE, "descriptor error");
PRINTERR(ADSTAT_Rx_RF, "runt frame");
PRINTERR(ADSTAT_Rx_TL, "frame too long");
@@ -1084,7 +1084,7 @@
*/
m = rxs->rxs_mbuf;
if (ae_add_rxbuf(sc, i) != 0) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
AE_INIT_RXDESC(sc, i);
bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -1100,7 +1100,7 @@
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
dropit:
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
AE_INIT_RXDESC(sc, i);
bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD);
@@ -1216,17 +1216,20 @@
sc->sc_stats.ts_tx_lc++;
#endif
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
if (txstat & (ADSTAT_Tx_UF | ADSTAT_Tx_TO))
- ifp->if_oerrors++;
+ if_statinc_ref(nsr, if_oerrors);
if (txstat & ADSTAT_Tx_EC)
- ifp->if_collisions += 16;
- else
- ifp->if_collisions += ADSTAT_Tx_COLLISIONS(txstat);
+ if_statadd_ref(nsr, if_collisions, 16);
+ else if (ADSTAT_Tx_COLLISIONS(txstat))
+ if_statadd_ref(nsr, if_collisions,
+ ADSTAT_Tx_COLLISIONS(txstat));
if (txstat & ADSTAT_Tx_LC)
- ifp->if_collisions++;
+ if_statinc_ref(nsr, if_collisions);
- ifp->if_opackets++;
+ if_statinc_ref(nsr, if_opackets);
+ IF_STAT_PUTREF(ifp);
}
/*
--- src/sys/arch/mips/cavium/dev/if_cnmac.c 2019/12/28 02:58:59 1.15
+++ src/sys/arch/mips/cavium/dev/if_cnmac.c 2020/01/29 05:30:14 1.16
@@ -1,8 +1,8 @@
-/* $NetBSD: if_cnmac.c,v 1.15 2019/12/28 02:58:59 gutteridge Exp $ */
+/* $NetBSD: if_cnmac.c,v 1.16 2020/01/29 05:30:14 thorpej Exp $ */
#include <sys/cdefs.h>
#if 0
-__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.15 2019/12/28 02:58:59 gutteridge Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cnmac.c,v 1.16 2020/01/29 05:30:14 thorpej Exp $");
#endif
#include "opt_octeon.h"
@@ -1487,14 +1487,14 @@
OCTEON_ETH_KASSERT(ifp != NULL);
if (__predict_false(octeon_eth_recv_check(sc, word2) != 0)) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
result = 1;
octeon_eth_buf_free_work(sc, work, word2);
goto drop;
}
if (__predict_false(octeon_eth_recv_mbuf(sc, work, &m) != 0)) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
result = 1;
octeon_eth_buf_free_work(sc, work, word2);
goto drop;
--- src/sys/arch/mips/cavium/dev/octeon_gmx.c 2020/01/25 19:20:24 1.7
+++ src/sys/arch/mips/cavium/dev/octeon_gmx.c 2020/01/29 05:30:14 1.8
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_gmx.c,v 1.7 2020/01/25 19:20:24 thorpej Exp $ */
+/* $NetBSD: octeon_gmx.c,v 1.8 2020/01/29 05:30:14 thorpej Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.7 2020/01/25 19:20:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_gmx.c,v 1.8 2020/01/29 05:30:14 thorpej Exp $");
#include "opt_octeon.h"
@@ -1071,22 +1071,24 @@
* receive error of work queue entry.
* this is not add to input packet errors of interface.
*/
- ifp->if_iqdrops +=
- (uint32_t)_GMX_PORT_RD8(sc, GMX0_RX0_STATS_PKTS_DRP);
- ifp->if_opackets +=
- (uint32_t)_GMX_PORT_RD8(sc, GMX0_TX0_STAT3);
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+ if_statadd_ref(nsr, if_iqdrops,
+ (uint32_t)_GMX_PORT_RD8(sc, GMX0_RX0_STATS_PKTS_DRP));
+ if_statadd_ref(nsr, if_opackets,
+ (uint32_t)_GMX_PORT_RD8(sc, GMX0_TX0_STAT3));
tmp = _GMX_PORT_RD8(sc, GMX0_TX0_STAT0);
- ifp->if_oerrors +=
- (uint32_t)tmp + ((uint32_t)(tmp >> 32) * 16);
- ifp->if_collisions += (uint32_t)tmp;
+ if_statadd_ref(nsr, if_oerrors,
+ (uint32_t)tmp + ((uint32_t)(tmp >> 32) * 16));
+ if_statadd_ref(nsr, if_collisions, (uint32_t)tmp);
tmp = _GMX_PORT_RD8(sc, GMX0_TX0_STAT1);
- ifp->if_collisions +=
- (uint32_t)tmp + (uint32_t)(tmp >> 32);
+ if_statadd_ref(nsr, if_collisions,
+ (uint32_t)tmp + (uint32_t)(tmp >> 32));
tmp = _GMX_PORT_RD8(sc, GMX0_TX0_STAT9);
- ifp->if_oerrors += (uint32_t)(tmp >> 32);
+ if_statadd_ref(nsr, if_oerrors, (uint32_t)(tmp >> 32));
+ IF_STAT_PUTREF(ifp);
}
/* ---- DMAC filter */
--- src/sys/arch/mips/cavium/dev/octeon_pip.c 2018/02/06 09:33:45 1.2
+++ src/sys/arch/mips/cavium/dev/octeon_pip.c 2020/01/29 05:30:14 1.3
@@ -1,4 +1,4 @@
-/* $NetBSD: octeon_pip.c,v 1.2 2018/02/06 09:33:45 mrg Exp $ */
+/* $NetBSD: octeon_pip.c,v 1.3 2020/01/29 05:30:14 thorpej Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: octeon_pip.c,v 1.2 2018/02/06 09:33:45 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_pip.c,v 1.3 2020/01/29 05:30:14 thorpej Exp $");
#include "opt_octeon.h"
@@ -245,7 +245,7 @@
reg = &octeon_pip_dump_stats_[gmx_port];
tmp = _PIP_RD8(sc, reg->offset);
pkts = (tmp & 0xffffffff00000000ULL) >> 32;
- ifp->if_iqdrops += pkts;
+ if_statadd(ifp, if_iqdrops, pkts);
_PIP_WR8(sc, PIP_STAT_CTL_OFFSET, pip_stat_ctl);
}
--- src/sys/arch/mips/ralink/ralink_eth.c 2019/06/03 06:04:20 1.19
+++ src/sys/arch/mips/ralink/ralink_eth.c 2020/01/29 05:30:14 1.20
@@ -1,4 +1,4 @@
-/* $NetBSD: ralink_eth.c,v 1.19 2019/06/03 06:04:20 msaitoh Exp $ */
+/* $NetBSD: ralink_eth.c,v 1.20 2020/01/29 05:30:14 thorpej Exp $ */
/*-
* Copyright (c) 2011 CradlePoint Technology, Inc.
* All rights reserved.
@@ -29,7 +29,7 @@
/* ralink_eth.c -- Ralink Ethernet Driver */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ralink_eth.c,v 1.19 2019/06/03 06:04:20 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ralink_eth.c,v 1.20 2020/01/29 05:30:14 thorpej Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -1321,7 +1321,7 @@
if (doing_transmit) {
RALINK_DEBUG(RALINK_DEBUG_ERROR, "%s: transmit timeout\n",
ifp->if_xname);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
sc->sc_evcnt_wd_tx.ev_count++;
} else {
RALINK_DEBUG(RALINK_DEBUG_ERROR,
@@ -1626,7 +1626,7 @@
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
ifp->if_flags &= ~IFF_OACTIVE;
- ifp->if_opackets++;
+ if_statinc(ifp, if_opackets);
sc->sc_evcnt_output.ev_count++;
if (--sc->sc_pending_tx == 0)
--- src/sys/arch/mips/sibyte/dev/sbmac.c 2019/09/13 07:55:06 1.61
+++ src/sys/arch/mips/sibyte/dev/sbmac.c 2020/01/29 05:30:14 1.62
@@ -1,4 +1,4 @@
-/* $NetBSD: sbmac.c,v 1.61 2019/09/13 07:55:06 msaitoh Exp $ */
+/* $NetBSD: sbmac.c,v 1.62 2020/01/29 05:30:14 thorpej Exp $ */
/*
* Copyright 2000, 2001, 2004
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.61 2019/09/13 07:55:06 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.62 2020/01/29 05:30:14 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ns.h"
@@ -1016,7 +1016,7 @@
/*
* for transmits we just free buffers and count packets.
*/
- ifp->if_opackets++;
+ if_statinc(ifp, if_opackets);
m_freem(m);
/*