From 6b037352d05a6d46319eced39989aebbbfe3e89a Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Mon, 11 Dec 2006 18:00:34 +0000 Subject: - Correct collision counter for BCM5705+. This register is read/clear. - Correct RX packet drop counter for BCM5705+. This register is read/clear and it wraps very quickly under heavy packet drops because only the lower ten bits are valid according to the documentation. However, it seems few more bits are actually valid and the rest bits are always zeros[1]. Therefore, we don't mask them off here. To get accurate packet drop count, we need to check the register from bge_rxeof(). It is commented out for now, not to penalize normal operation. Actual performance impact should be measured later. - Correct integer casting from u_long to uint32_t. Casting is not really needed for all supported platforms but we better do this correctly[2]. Tested by: bde[1] Suggested by: bde[2] --- sys/dev/bge/if_bge.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'sys/dev/bge/if_bge.c') diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 095d72ef0ab6..a861b3babc72 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -2755,6 +2755,14 @@ bge_rxeof(struct bge_softc *sc) CSR_WRITE_4(sc, BGE_MBX_RX_STD_PROD_LO, sc->bge_std); if (jumbocnt) CSR_WRITE_4(sc, BGE_MBX_RX_JUMBO_PROD_LO, sc->bge_jumbo); +#ifdef notyet + /* + * This register wraps very quickly under heavy packet drops. + * If you need correct statistics, you can enable this check. + */ + if (BGE_IS_5705_PLUS(sc)) + ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS); +#endif } static void @@ -2967,18 +2975,13 @@ static void bge_stats_update_regs(struct bge_softc *sc) { struct ifnet *ifp; - uint32_t cnt; /* current register value */ ifp = sc->bge_ifp; - cnt = CSR_READ_4(sc, BGE_MAC_STATS + + ifp->if_collisions += CSR_READ_4(sc, BGE_MAC_STATS + offsetof(struct bge_mac_stats_regs, etherStatsCollisions)); - ifp->if_collisions += (u_long)(cnt - sc->bge_tx_collisions); - sc->bge_tx_collisions = cnt; - cnt = CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS); - ifp->if_ierrors += (u_long)(cnt - sc->bge_rx_discards); - sc->bge_rx_discards = cnt; + ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS); } static void @@ -3003,15 +3006,15 @@ bge_stats_update(struct bge_softc *sc) txstats.dot3StatsExcessiveCollisions.bge_addr_lo); cnt += READ_STAT(sc, stats, txstats.dot3StatsLateCollisions.bge_addr_lo); - ifp->if_collisions += (u_long)(cnt - sc->bge_tx_collisions); + ifp->if_collisions += (uint32_t)(cnt - sc->bge_tx_collisions); sc->bge_tx_collisions = cnt; cnt = READ_STAT(sc, stats, ifInDiscards.bge_addr_lo); - ifp->if_ierrors += (u_long)(cnt - sc->bge_rx_discards); + ifp->if_ierrors += (uint32_t)(cnt - sc->bge_rx_discards); sc->bge_rx_discards = cnt; cnt = READ_STAT(sc, stats, txstats.ifOutDiscards.bge_addr_lo); - ifp->if_oerrors += (u_long)(cnt - sc->bge_tx_discards); + ifp->if_oerrors += (uint32_t)(cnt - sc->bge_tx_discards); sc->bge_tx_discards = cnt; #undef READ_STAT -- cgit v1.2.3