Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Adopt <net/if_stats.h>.
details: https://anonhg.NetBSD.org/src/rev/ee65a8f96f27
branches: trunk
changeset: 1006847:ee65a8f96f27
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Jan 29 06:35:28 2020 +0000
description:
Adopt <net/if_stats.h>.
diffstat:
sys/dev/pci/if_wm.c | 48 ++++++++++++++++++++++++++----------------------
sys/dev/usb/if_otus.c | 28 ++++++++++++++--------------
sys/dev/usb/if_rum.c | 22 +++++++++++-----------
sys/dev/usb/if_run.c | 28 ++++++++++++++--------------
sys/dev/usb/if_smsc.c | 16 ++++++++--------
sys/dev/usb/if_udav.c | 8 ++++----
sys/dev/usb/if_umb.c | 21 ++++++++++-----------
sys/dev/usb/if_upgt.c | 16 ++++++++--------
sys/dev/usb/if_upl.c | 9 ++++-----
sys/dev/usb/if_ural.c | 22 +++++++++++-----------
sys/dev/usb/if_ure.c | 8 ++++----
sys/dev/usb/if_url.c | 8 ++++----
sys/dev/usb/if_urndis.c | 6 +++---
sys/dev/usb/if_urtw.c | 26 +++++++++++++-------------
sys/dev/usb/if_urtwn.c | 28 ++++++++++++++--------------
sys/dev/usb/if_zyd.c | 30 +++++++++++++++---------------
sys/dev/usb/uhso.c | 21 ++++++++++-----------
sys/dev/usb/usbnet.c | 20 ++++++++++----------
18 files changed, 183 insertions(+), 182 deletions(-)
diffs (truncated from 1522 to 300 lines):
diff -r 92ae4972179a -r ee65a8f96f27 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c Wed Jan 29 06:17:07 2020 +0000
+++ b/sys/dev/pci/if_wm.c Wed Jan 29 06:35:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wm.c,v 1.662 2020/01/24 02:50:41 knakahara Exp $ */
+/* $NetBSD: if_wm.c,v 1.663 2020/01/29 06:44:27 thorpej Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.662 2020/01/24 02:50:41 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.663 2020/01/29 06:44:27 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -3266,7 +3266,7 @@
"%s: device timeout (txfree %d txsfree %d txnext %d)\n",
device_xname(sc->sc_dev), txq->txq_free, txq->txq_sfree,
txq->txq_next);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
#ifdef WM_DEBUG
for (i = txq->txq_sdirty; i != txq->txq_snext;
i = WM_NEXTTXS(txq, i)) {
@@ -3331,15 +3331,16 @@
WM_EVCNT_ADD(&sc->sc_ev_rx_macctl, CSR_READ(sc, WMREG_FCRUC));
}
- ifp->if_collisions += CSR_READ(sc, WMREG_COLC);
- ifp->if_ierrors += 0ULL /* ensure quad_t */
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+ if_statadd_ref(nsr, if_collisions, CSR_READ(sc, WMREG_COLC));
+ if_statadd_ref(nsr, if_ierrors, 0ULL /* ensure quad_t */
+ CSR_READ(sc, WMREG_CRCERRS)
+ CSR_READ(sc, WMREG_ALGNERRC)
+ CSR_READ(sc, WMREG_SYMERRC)
+ CSR_READ(sc, WMREG_RXERRC)
+ CSR_READ(sc, WMREG_SEC)
+ CSR_READ(sc, WMREG_CEXTERR)
- + CSR_READ(sc, WMREG_RLEC);
+ + CSR_READ(sc, WMREG_RLEC));
/*
* WMREG_RNBC is incremented when there is no available buffers in host
* memory. It does not mean the number of dropped packet. Because
@@ -3349,7 +3350,8 @@
* If you want to know the nubmer of WMREG_RMBC, you should use such as
* own EVCNT instead of if_iqdrops.
*/
- ifp->if_iqdrops += CSR_READ(sc, WMREG_MPC);
+ if_statadd_ref(nsr, if_iqdrops, CSR_READ(sc, WMREG_MPC));
+ IF_STAT_PUTREF(ifp);
if (sc->sc_flags & WM_F_HAS_MII)
mii_tick(&sc->sc_mii);
@@ -5847,8 +5849,8 @@
wm_stop_locked(ifp, 0);
/* Update statistics before reset */
- ifp->if_collisions += CSR_READ(sc, WMREG_COLC);
- ifp->if_ierrors += CSR_READ(sc, WMREG_RXERRC);
+ if_statadd2(ifp, if_collisions, CSR_READ(sc, WMREG_COLC),
+ if_ierrors, CSR_READ(sc, WMREG_RXERRC));
/* PCH_SPT hardware workaround */
if (sc->sc_type == WM_T_PCH_SPT)
@@ -7562,7 +7564,7 @@
KASSERT(if_is_mpsafe(ifp));
#endif
/*
- * ifp->if_obytes and ifp->if_omcasts are added in if_transmit()@if.c.
+ * if_obytes and if_omcasts are added in if_transmit()@if.c.
*/
mutex_enter(txq->txq_lock);
@@ -7596,10 +7598,11 @@
return ENOBUFS;
}
- /* XXX NOMPSAFE: ifp->if_data should be percpu. */
- ifp->if_obytes += m->m_pkthdr.len;
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+ if_statadd_ref(nsr, if_obytes, m->m_pkthdr.len);
if (m->m_flags & M_MCAST)
- ifp->if_omcasts++;
+ if_statinc_ref(nsr, if_omcasts);
+ IF_STAT_PUTREF(ifp);
if (mutex_tryenter(txq->txq_lock)) {
if (!txq->txq_stopping)
@@ -8167,7 +8170,7 @@
KASSERT(if_is_mpsafe(ifp));
#endif
/*
- * ifp->if_obytes and ifp->if_omcasts are added in if_transmit()@if.c.
+ * if_obytes and if_omcasts are added in if_transmit()@if.c.
*/
mutex_enter(txq->txq_lock);
@@ -8201,10 +8204,11 @@
return ENOBUFS;
}
- /* XXX NOMPSAFE: ifp->if_data should be percpu. */
- ifp->if_obytes += m->m_pkthdr.len;
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+ if_statadd_ref(nsr, if_obytes, m->m_pkthdr.len);
if (m->m_flags & M_MCAST)
- ifp->if_omcasts++;
+ if_statinc_ref(nsr, if_omcasts);
+ IF_STAT_PUTREF(ifp);
/*
* The situations which this mutex_tryenter() fails at running time
@@ -8649,18 +8653,18 @@
if (((status & (WTX_ST_EC | WTX_ST_LC)) != 0)
&& ((sc->sc_type < WM_T_82574)
|| (sc->sc_type == WM_T_80003))) {
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
if (status & WTX_ST_LC)
log(LOG_WARNING, "%s: late collision\n",
device_xname(sc->sc_dev));
else if (status & WTX_ST_EC) {
- ifp->if_collisions +=
- TX_COLLISION_THRESHOLD + 1;
+ if_statadd(ifp, if_collisions,
+ TX_COLLISION_THRESHOLD + 1);
log(LOG_WARNING, "%s: excessive collisions\n",
device_xname(sc->sc_dev));
}
} else
- ifp->if_opackets++;
+ if_statinc(ifp, if_opackets);
txq->txq_packets++;
txq->txq_bytes += txs->txs_mbuf->m_pkthdr.len;
@@ -8982,7 +8986,7 @@
* 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);
wm_init_rxdesc(rxq, i);
diff -r 92ae4972179a -r ee65a8f96f27 sys/dev/usb/if_otus.c
--- a/sys/dev/usb/if_otus.c Wed Jan 29 06:17:07 2020 +0000
+++ b/sys/dev/usb/if_otus.c Wed Jan 29 06:35:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_otus.c,v 1.40 2020/01/15 08:20:13 skrll Exp $ */
+/* $NetBSD: if_otus.c,v 1.41 2020/01/29 06:35:28 thorpej Exp $ */
/* $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $ */
/*-
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.40 2020/01/15 08:20:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.41 2020/01/29 06:35:28 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -1734,7 +1734,7 @@
/* Received MPDU. */
if (__predict_false(len < AR_PLCP_HDR_LEN + sizeof(*tail))) {
DPRINTFN(DBG_RX, sc, "MPDU too short %d\n", len);
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
return;
}
tail = (void *)(plcp + len - sizeof(*tail));
@@ -1749,7 +1749,7 @@
/* Report Michael MIC failures to net80211. */
ieee80211_notify_michael_failure(ic, wh, 0 /* XXX: keyix */);
}
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
return;
}
/* Compute MPDU's length. */
@@ -1761,7 +1761,7 @@
* want this in IEEE80211_M_MONITOR mode?
*/
if (__predict_false(mlen < sizeof(*wh))) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
return;
}
@@ -1770,13 +1770,13 @@
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (__predict_false(m == NULL)) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
return;
}
if (align + mlen > MHLEN) {
MCLGET(m, M_DONTWAIT);
if (__predict_false(!(m->m_flags & M_EXT))) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
m_freem(m);
return;
}
@@ -1917,10 +1917,10 @@
DPRINTFN(DBG_TX, sc, "TX status=%d\n", status);
if (status == USBD_STALLED)
usbd_clear_endpoint_stall_async(sc->sc_data_tx_pipe);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
return;
}
- ifp->if_opackets++;
+ if_statinc(ifp, if_opackets);
s = splnet();
sc->sc_tx_timer = 0;
@@ -2114,7 +2114,7 @@
if (m->m_len < (int)sizeof(*eh) &&
(m = m_pullup(m, sizeof(*eh))) == NULL) {
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
continue;
}
@@ -2122,7 +2122,7 @@
ni = ieee80211_find_txnode(ic, eh->ether_dhost);
if (ni == NULL) {
m_freem(m);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
continue;
}
@@ -2131,7 +2131,7 @@
if ((m = ieee80211_encap(ic, m, ni)) == NULL) {
/* original m was freed by ieee80211_encap() */
ieee80211_free_node(ni);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
continue;
}
sendit:
@@ -2140,7 +2140,7 @@
if (otus_tx(sc, m, ni, data) != 0) {
m_freem(m);
ieee80211_free_node(ni);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
continue;
}
@@ -2175,7 +2175,7 @@
if (--sc->sc_tx_timer == 0) {
aprint_error_dev(sc->sc_dev, "device timeout\n");
/* otus_init(ifp); XXX needs a process context! */
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
return;
}
ifp->if_timer = 1;
diff -r 92ae4972179a -r ee65a8f96f27 sys/dev/usb/if_rum.c
--- a/sys/dev/usb/if_rum.c Wed Jan 29 06:17:07 2020 +0000
+++ b/sys/dev/usb/if_rum.c Wed Jan 29 06:35:28 2020 +0000
@@ -1,5 +1,5 @@
/* $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $ */
-/* $NetBSD: if_rum.c,v 1.65 2019/05/05 03:17:54 mrg Exp $ */
+/* $NetBSD: if_rum.c,v 1.66 2020/01/29 06:35:28 thorpej Exp $ */
/*-
* Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini%free.fr@localhost>
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.65 2019/05/05 03:17:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.66 2020/01/29 06:35:28 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -776,7 +776,7 @@
if (status == USBD_STALLED)
usbd_clear_endpoint_stall_async(sc->sc_tx_pipeh);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
return;
}
@@ -786,7 +786,7 @@
data->ni = NULL;
sc->tx_queued--;
- ifp->if_opackets++;
Home |
Main Index |
Thread Index |
Old Index