summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2006-01-25 21:01:25 +0000
committerBrad Smith <brad@cvs.openbsd.org>2006-01-25 21:01:25 +0000
commita9baf2a1140435e534c53cb428653db6bc3741c8 (patch)
treea91882c4b6d53f57d979e461b3d1244d4272c65a /sys/dev
parent405e6e935990c546fcd0580700b6329072ef7645 (diff)
- Count packets discarded by RX/TX MAC (cause of FIFO overflow, etc)
as input/output interface errors. - Keep values of rx/tx discards & tx collisions inside struct bge_softc. So we can keep statistic across ifconfig down/up runs (cause bringing bge up will reset chip). From oleg FreeBSD
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_bge.c57
-rw-r--r--sys/dev/pci/if_bgereg.h5
2 files changed, 35 insertions, 27 deletions
diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c
index 1ca60a2ee7e..9c3e5bf2fde 100644
--- a/sys/dev/pci/if_bge.c
+++ b/sys/dev/pci/if_bge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bge.c,v 1.120 2005/12/28 22:02:44 brad Exp $ */
+/* $OpenBSD: if_bge.c,v 1.121 2006/01/25 21:01:24 brad Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -2504,6 +2504,7 @@ bge_stats_update_regs(struct bge_softc *sc)
struct ifnet *ifp;
struct bge_mac_stats_regs stats;
u_int32_t *s;
+ u_long cnt;
int i;
ifp = &sc->arpcom.ac_if;
@@ -2514,12 +2515,13 @@ bge_stats_update_regs(struct bge_softc *sc)
s++;
}
- ifp->if_collisions +=
- (stats.dot3StatsSingleCollisionFrames +
- stats.dot3StatsMultipleCollisionFrames +
- stats.dot3StatsExcessiveCollisions +
- stats.dot3StatsLateCollisions) -
- ifp->if_collisions;
+ cnt = stats.dot3StatsSingleCollisionFrames +
+ stats.dot3StatsMultipleCollisionFrames +
+ stats.dot3StatsExcessiveCollisions +
+ stats.dot3StatsLateCollisions;
+ ifp->if_collisions += cnt >= sc->bge_tx_collisions ?
+ cnt - sc->bge_tx_collisions : cnt;
+ sc->bge_tx_collisions = cnt;
}
void
@@ -2527,31 +2529,34 @@ bge_stats_update(struct bge_softc *sc)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
bus_size_t stats = BGE_MEMWIN_START + BGE_STATS_BLOCK;
+ u_long cnt;
#define READ_STAT(sc, stats, stat) \
CSR_READ_4(sc, stats + offsetof(struct bge_stats, stat))
- ifp->if_collisions +=
- (READ_STAT(sc, stats,
- txstats.dot3StatsSingleCollisionFrames.bge_addr_lo) +
- READ_STAT(sc, stats,
- txstats.dot3StatsMultipleCollisionFrames.bge_addr_lo) +
- READ_STAT(sc, stats,
- txstats.dot3StatsExcessiveCollisions.bge_addr_lo) +
- READ_STAT(sc, stats,
- txstats.dot3StatsLateCollisions.bge_addr_lo)) -
- ifp->if_collisions;
+ cnt = READ_STAT(sc, stats,
+ txstats.dot3StatsSingleCollisionFrames.bge_addr_lo);
+ cnt += READ_STAT(sc, stats,
+ txstats.dot3StatsMultipleCollisionFrames.bge_addr_lo);
+ cnt += READ_STAT(sc, stats,
+ txstats.dot3StatsExcessiveCollisions.bge_addr_lo);
+ cnt += READ_STAT(sc, stats,
+ txstats.dot3StatsLateCollisions.bge_addr_lo);
+ ifp->if_collisions += cnt >= sc->bge_tx_collisions ?
+ cnt - sc->bge_tx_collisions : cnt;
+ sc->bge_tx_collisions = cnt;
+
+ cnt = READ_STAT(sc, stats, ifInDiscards.bge_addr_lo);
+ ifp->if_ierrors += cnt >= sc->bge_rx_discards ?
+ cnt - sc->bge_rx_discards : cnt;
+ sc->bge_rx_discards = cnt;
+
+ cnt = READ_STAT(sc, stats, txstats.ifOutDiscards.bge_addr_lo);
+ ifp->if_oerrors += cnt >= sc->bge_tx_discards ?
+ cnt - sc->bge_tx_discards : cnt;
+ sc->bge_tx_discards = cnt;
#undef READ_STAT
-
-#ifdef notdef
- ifp->if_collisions +=
- (sc->bge_rdata->bge_info.bge_stats.dot3StatsSingleCollisionFrames +
- sc->bge_rdata->bge_info.bge_stats.dot3StatsMultipleCollisionFrames +
- sc->bge_rdata->bge_info.bge_stats.dot3StatsExcessiveCollisions +
- sc->bge_rdata->bge_info.bge_stats.dot3StatsLateCollisions) -
- ifp->if_collisions;
-#endif
}
/*
diff --git a/sys/dev/pci/if_bgereg.h b/sys/dev/pci/if_bgereg.h
index 3b778ee7a7c..fc78ab59358 100644
--- a/sys/dev/pci/if_bgereg.h
+++ b/sys/dev/pci/if_bgereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bgereg.h,v 1.38 2006/01/21 16:35:39 brad Exp $ */
+/* $OpenBSD: if_bgereg.h,v 1.39 2006/01/25 21:01:24 brad Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -2344,6 +2344,9 @@ struct bge_softc {
int bge_txcnt;
int bge_link;
struct timeout bge_timeout;
+ u_long bge_rx_discards;
+ u_long bge_tx_discards;
+ u_long bge_tx_collisions;
SLIST_HEAD(, txdmamap_pool_entry) txdma_list;
struct txdmamap_pool_entry *txdma[BGE_TX_RING_CNT];
};