Deleted Added
full compact
34c34
< __FBSDID("$FreeBSD: head/sys/dev/ste/if_ste.c 200908 2009-12-23 18:42:25Z yongari $");
---
> __FBSDID("$FreeBSD: head/sys/dev/ste/if_ste.c 200910 2009-12-23 19:18:07Z yongari $");
127a128
> static void ste_stats_clear(struct ste_softc *);
129a131
> static void ste_sysctl_node(struct ste_softc *);
925a928,955
> ste_stats_clear(struct ste_softc *sc)
> {
>
> STE_LOCK_ASSERT(sc);
>
> /* Rx stats. */
> CSR_READ_2(sc, STE_STAT_RX_OCTETS_LO);
> CSR_READ_2(sc, STE_STAT_RX_OCTETS_HI);
> CSR_READ_2(sc, STE_STAT_RX_FRAMES);
> CSR_READ_1(sc, STE_STAT_RX_BCAST);
> CSR_READ_1(sc, STE_STAT_RX_MCAST);
> CSR_READ_1(sc, STE_STAT_RX_LOST);
> /* Tx stats. */
> CSR_READ_2(sc, STE_STAT_TX_OCTETS_LO);
> CSR_READ_2(sc, STE_STAT_TX_OCTETS_HI);
> CSR_READ_2(sc, STE_STAT_TX_FRAMES);
> CSR_READ_1(sc, STE_STAT_TX_BCAST);
> CSR_READ_1(sc, STE_STAT_TX_MCAST);
> CSR_READ_1(sc, STE_STAT_CARRIER_ERR);
> CSR_READ_1(sc, STE_STAT_SINGLE_COLLS);
> CSR_READ_1(sc, STE_STAT_MULTI_COLLS);
> CSR_READ_1(sc, STE_STAT_LATE_COLLS);
> CSR_READ_1(sc, STE_STAT_TX_DEFER);
> CSR_READ_1(sc, STE_STAT_TX_EXDEFER);
> CSR_READ_1(sc, STE_STAT_TX_ABORT);
> }
>
> static void
928a959,960
> struct ste_hw_stats *stats;
> uint32_t val;
933,935c965,995
< ifp->if_collisions += CSR_READ_1(sc, STE_LATE_COLLS)
< + CSR_READ_1(sc, STE_MULTI_COLLS)
< + CSR_READ_1(sc, STE_SINGLE_COLLS);
---
> stats = &sc->ste_stats;
> /* Rx stats. */
> val = (uint32_t)CSR_READ_2(sc, STE_STAT_RX_OCTETS_LO) |
> ((uint32_t)CSR_READ_2(sc, STE_STAT_RX_OCTETS_HI)) << 16;
> val &= 0x000FFFFF;
> stats->rx_bytes += val;
> stats->rx_frames += CSR_READ_2(sc, STE_STAT_RX_FRAMES);
> stats->rx_bcast_frames += CSR_READ_1(sc, STE_STAT_RX_BCAST);
> stats->rx_mcast_frames += CSR_READ_1(sc, STE_STAT_RX_MCAST);
> stats->rx_lost_frames += CSR_READ_1(sc, STE_STAT_RX_LOST);
> /* Tx stats. */
> val = (uint32_t)CSR_READ_2(sc, STE_STAT_TX_OCTETS_LO) |
> ((uint32_t)CSR_READ_2(sc, STE_STAT_TX_OCTETS_HI)) << 16;
> val &= 0x000FFFFF;
> stats->tx_bytes += val;
> stats->tx_frames += CSR_READ_2(sc, STE_STAT_TX_FRAMES);
> stats->tx_bcast_frames += CSR_READ_1(sc, STE_STAT_TX_BCAST);
> stats->tx_mcast_frames += CSR_READ_1(sc, STE_STAT_TX_MCAST);
> stats->tx_carrsense_errs += CSR_READ_1(sc, STE_STAT_CARRIER_ERR);
> val = CSR_READ_1(sc, STE_STAT_SINGLE_COLLS);
> stats->tx_single_colls += val;
> ifp->if_collisions += val;
> val = CSR_READ_1(sc, STE_STAT_MULTI_COLLS);
> stats->tx_multi_colls += val;
> ifp->if_collisions += val;
> val += CSR_READ_1(sc, STE_STAT_LATE_COLLS);
> stats->tx_late_colls += val;
> ifp->if_collisions += val;
> stats->tx_frames_defered += CSR_READ_1(sc, STE_STAT_TX_DEFER);
> stats->tx_excess_defers += CSR_READ_1(sc, STE_STAT_TX_EXDEFER);
> stats->tx_abort += CSR_READ_1(sc, STE_STAT_TX_ABORT);
1034a1095
> ste_sysctl_node(sc);
1627a1689,1690
> /* Clear stats counters. */
> ste_stats_clear(sc);
2015a2079,2145
>
> #define STE_SYSCTL_STAT_ADD32(c, h, n, p, d) \
> SYSCTL_ADD_UINT(c, h, OID_AUTO, n, CTLFLAG_RD, p, 0, d)
> #define STE_SYSCTL_STAT_ADD64(c, h, n, p, d) \
> SYSCTL_ADD_QUAD(c, h, OID_AUTO, n, CTLFLAG_RD, p, d)
>
> static void
> ste_sysctl_node(struct ste_softc *sc)
> {
> struct sysctl_ctx_list *ctx;
> struct sysctl_oid_list *child, *parent;
> struct sysctl_oid *tree;
> struct ste_hw_stats *stats;
>
> stats = &sc->ste_stats;
> ctx = device_get_sysctl_ctx(sc->ste_dev);
> child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->ste_dev));
>
> tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD,
> NULL, "STE statistics");
> parent = SYSCTL_CHILDREN(tree);
>
> /* Rx statistics. */
> tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx", CTLFLAG_RD,
> NULL, "Rx MAC statistics");
> child = SYSCTL_CHILDREN(tree);
> STE_SYSCTL_STAT_ADD64(ctx, child, "good_octets",
> &stats->rx_bytes, "Good octets");
> STE_SYSCTL_STAT_ADD32(ctx, child, "good_frames",
> &stats->rx_frames, "Good frames");
> STE_SYSCTL_STAT_ADD32(ctx, child, "good_bcast_frames",
> &stats->rx_bcast_frames, "Good broadcast frames");
> STE_SYSCTL_STAT_ADD32(ctx, child, "good_mcast_frames",
> &stats->rx_mcast_frames, "Good multicast frames");
> STE_SYSCTL_STAT_ADD32(ctx, child, "lost_frames",
> &stats->rx_lost_frames, "Lost frames");
>
> /* Tx statistics. */
> tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "tx", CTLFLAG_RD,
> NULL, "Tx MAC statistics");
> child = SYSCTL_CHILDREN(tree);
> STE_SYSCTL_STAT_ADD64(ctx, child, "good_octets",
> &stats->tx_bytes, "Good octets");
> STE_SYSCTL_STAT_ADD32(ctx, child, "good_frames",
> &stats->tx_frames, "Good frames");
> STE_SYSCTL_STAT_ADD32(ctx, child, "good_bcast_frames",
> &stats->tx_bcast_frames, "Good broadcast frames");
> STE_SYSCTL_STAT_ADD32(ctx, child, "good_mcast_frames",
> &stats->tx_mcast_frames, "Good multicast frames");
> STE_SYSCTL_STAT_ADD32(ctx, child, "carrier_errs",
> &stats->tx_carrsense_errs, "Carrier sense errors");
> STE_SYSCTL_STAT_ADD32(ctx, child, "single_colls",
> &stats->tx_single_colls, "Single collisions");
> STE_SYSCTL_STAT_ADD32(ctx, child, "multi_colls",
> &stats->tx_multi_colls, "Multiple collisions");
> STE_SYSCTL_STAT_ADD32(ctx, child, "late_colls",
> &stats->tx_late_colls, "Late collisions");
> STE_SYSCTL_STAT_ADD32(ctx, child, "defers",
> &stats->tx_frames_defered, "Frames with deferrals");
> STE_SYSCTL_STAT_ADD32(ctx, child, "excess_defers",
> &stats->tx_excess_defers, "Frames with excessive derferrals");
> STE_SYSCTL_STAT_ADD32(ctx, child, "abort",
> &stats->tx_abort, "Aborted frames due to Excessive collisions");
> }
>
> #undef STE_SYSCTL_STAT_ADD32
> #undef STE_SYSCTL_STAT_ADD64