Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Adopt <net/if_stats.h>.
details: https://anonhg.NetBSD.org/src/rev/e31312df2cac
branches: trunk
changeset: 744420:e31312df2cac
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Feb 01 06:17:23 2020 +0000
description:
Adopt <net/if_stats.h>.
diffstat:
sys/dev/pci/if_bge.c | 47 +++++++++++++++++++++++++++++------------------
sys/dev/pci/if_bgevar.h | 3 ++-
2 files changed, 31 insertions(+), 19 deletions(-)
diffs (147 lines):
diff -r 4f563bd4a132 -r e31312df2cac sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c Sat Feb 01 06:17:11 2020 +0000
+++ b/sys/dev/pci/if_bge.c Sat Feb 01 06:17:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bge.c,v 1.342 2019/11/25 05:35:26 msaitoh Exp $ */
+/* $NetBSD: if_bge.c,v 1.343 2020/02/01 06:17:23 thorpej Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.342 2019/11/25 05:35:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.343 2020/02/01 06:17:23 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -4453,13 +4453,13 @@
mtod(m, char *) - (char *)sc->bge_cdata.bge_jumbo_buf,
BGE_JLEN, BUS_DMASYNC_POSTREAD);
if (cur_rx->bge_flags & BGE_RXBDFLAG_ERROR) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
bge_newbuf_jumbo(sc, sc->bge_jumbo, m);
continue;
}
if (bge_newbuf_jumbo(sc, sc->bge_jumbo,
NULL)== ENOBUFS) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
bge_newbuf_jumbo(sc, sc->bge_jumbo, m);
continue;
}
@@ -4472,7 +4472,7 @@
dmamap = sc->bge_cdata.bge_rx_std_map[rxidx];
sc->bge_cdata.bge_rx_std_map[rxidx] = NULL;
if (dmamap == NULL) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
bge_newbuf_std(sc, sc->bge_std, m, dmamap);
continue;
}
@@ -4480,13 +4480,13 @@
dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD);
bus_dmamap_unload(sc->bge_dmatag, dmamap);
if (cur_rx->bge_flags & BGE_RXBDFLAG_ERROR) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
bge_newbuf_std(sc, sc->bge_std, m, dmamap);
continue;
}
if (bge_newbuf_std(sc, sc->bge_std,
NULL, dmamap) == ENOBUFS) {
- ifp->if_ierrors++;
+ if_statinc(ifp, if_ierrors);
bge_newbuf_std(sc, sc->bge_std, m, dmamap);
continue;
}
@@ -4617,7 +4617,7 @@
idx = sc->bge_tx_saved_considx;
cur_tx = &sc->bge_rdata->bge_tx_ring[idx];
if (cur_tx->bge_flags & BGE_TXBDFLAG_END)
- ifp->if_opackets++;
+ if_statinc(ifp, if_opackets);
m = sc->bge_cdata.bge_tx_chain[idx];
if (m != NULL) {
sc->bge_cdata.bge_tx_chain[idx] = NULL;
@@ -4812,8 +4812,11 @@
{
struct ifnet *ifp = &sc->ethercom.ec_if;
- ifp->if_collisions += CSR_READ_4(sc, BGE_MAC_STATS +
- offsetof(struct bge_mac_stats_regs, etherStatsCollisions));
+ net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+
+ if_statadd_ref(nsr, if_collisions,
+ CSR_READ_4(sc, BGE_MAC_STATS +
+ offsetof(struct bge_mac_stats_regs, etherStatsCollisions)));
/*
* On BCM5717, BCM5718, BCM5719 A0 and BCM5720 A0,
@@ -4824,10 +4827,15 @@
if (BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5717 &&
sc->bge_chipid != BGE_CHIPID_BCM5719_A0 &&
sc->bge_chipid != BGE_CHIPID_BCM5720_A0) {
- ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS);
- }
- ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_ERRORS);
- ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_OUT_OF_BDS);
+ if_statadd_ref(nsr, if_ierrors,
+ CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS));
+ }
+ if_statadd_ref(nsr, if_ierrors,
+ CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_ERRORS));
+ if_statadd_ref(nsr, if_ierrors,
+ CSR_READ_4(sc, BGE_RXLP_LOCSTAT_OUT_OF_BDS));
+
+ IF_STAT_PUTREF(ifp);
if (sc->bge_flags & BGEF_RDMA_BUG) {
uint32_t val, ucast, mcast, bcast;
@@ -4865,12 +4873,15 @@
#define READ_STAT(sc, stats, stat) \
CSR_READ_4(sc, stats + offsetof(struct bge_stats, stat))
- ifp->if_collisions +=
+ uint64_t collisions =
(READ_STAT(sc, stats, dot3StatsSingleCollisionFrames.bge_addr_lo) +
READ_STAT(sc, stats, dot3StatsMultipleCollisionFrames.bge_addr_lo) +
READ_STAT(sc, stats, dot3StatsExcessiveCollisions.bge_addr_lo) +
- READ_STAT(sc, stats, dot3StatsLateCollisions.bge_addr_lo)) -
- ifp->if_collisions;
+ READ_STAT(sc, stats, dot3StatsLateCollisions.bge_addr_lo));
+
+ if_statadd(ifp, if_collisions, collisions - sc->bge_if_collisions);
+ sc->bge_if_collisions = collisions;
+
BGE_EVCNT_UPD(sc->bge_ev_tx_xoff,
READ_STAT(sc, stats, outXoffSent.bge_addr_lo));
@@ -5942,7 +5953,7 @@
ifp->if_flags &= ~IFF_RUNNING;
bge_init(ifp);
- ifp->if_oerrors++;
+ if_statinc(ifp, if_oerrors);
}
static void
diff -r 4f563bd4a132 -r e31312df2cac sys/dev/pci/if_bgevar.h
--- a/sys/dev/pci/if_bgevar.h Sat Feb 01 06:17:11 2020 +0000
+++ b/sys/dev/pci/if_bgevar.h Sat Feb 01 06:17:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bgevar.h,v 1.25 2019/09/13 07:55:07 msaitoh Exp $ */
+/* $NetBSD: if_bgevar.h,v 1.26 2020/02/01 06:17:23 thorpej Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
* Copyright (c) 1997, 1998, 1999, 2001
@@ -339,6 +339,7 @@
struct evcnt bge_ev_rx_macctl; /* receive MAC control packets */
struct evcnt bge_ev_xoffentered;/* XOFF state entered */
#endif /* BGE_EVENT_COUNTERS */
+ uint64_t bge_if_collisions;
int bge_txcnt;
struct callout bge_timeout;
int bge_pending_rxintr_change;
Home |
Main Index |
Thread Index |
Old Index