diff options
| author | Andrew Thompson <thompsa@FreeBSD.org> | 2010-04-07 00:27:59 +0000 |
|---|---|---|
| committer | Andrew Thompson <thompsa@FreeBSD.org> | 2010-04-07 00:27:59 +0000 |
| commit | 3769678a8262f91d4826e7518560acc8dd3f280c (patch) | |
| tree | 255a98c0d88eccd722af58c66d00975a9a92af6f /sys | |
| parent | 1e6c93d364d9ece6bb1b71c400338d6f043bd04c (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/dev/usb/wlan/if_urtw.c | 53 | ||||
| -rw-r--r-- | sys/dev/usb/wlan/if_urtwvar.h | 6 |
2 files changed, 59 insertions, 0 deletions
diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index 00789b89acc2..6604268e009b 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -762,6 +762,7 @@ static int urtw_compute_txtime(uint16_t, uint16_t, uint8_t, uint8_t); static void urtw_updateslot(struct ifnet *); static void urtw_updateslottask(void *, int); +static void urtw_sysctl_node(struct urtw_softc *); static int urtw_match(device_t dev) @@ -906,6 +907,8 @@ urtw_attach(device_t dev) &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), URTW_RX_RADIOTAP_PRESENT); + urtw_sysctl_node(sc); + if (bootverbose) ieee80211_announce(ic); return (0); @@ -1703,6 +1706,8 @@ urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, rate = urtw_rtl2rate(sc->sc_currate); } + sc->sc_stats.txrates[sc->sc_currate]++; + if (IEEE80211_IS_MULTICAST(wh->i_addr1)) txdur = pkttime = urtw_compute_txtime(m0->m_pkthdr.len + IEEE80211_CRC_LEN, rate, 0, 0); @@ -4372,6 +4377,54 @@ fail: URTW_UNLOCK(sc); } +static void +urtw_sysctl_node(struct urtw_softc *sc) +{ +#define URTW_SYSCTL_STAT_ADD32(c, h, n, p, d) \ + SYSCTL_ADD_UINT(c, h, OID_AUTO, n, CTLFLAG_RD, p, 0, d) + struct sysctl_ctx_list *ctx; + struct sysctl_oid_list *child, *parent; + struct sysctl_oid *tree; + struct urtw_stats *stats = &sc->sc_stats; + + ctx = device_get_sysctl_ctx(sc->sc_dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sc_dev)); + + tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD, + NULL, "URTW statistics"); + parent = SYSCTL_CHILDREN(tree); + + /* Tx statistics. */ + tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "tx", CTLFLAG_RD, + NULL, "Tx MAC statistics"); + child = SYSCTL_CHILDREN(tree); + URTW_SYSCTL_STAT_ADD32(ctx, child, "1m", &stats->txrates[0], + "1 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "2m", &stats->txrates[1], + "2 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "5.5m", &stats->txrates[2], + "5.5 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "6m", &stats->txrates[4], + "6 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "9m", &stats->txrates[5], + "9 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "11m", &stats->txrates[3], + "11 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "12m", &stats->txrates[6], + "12 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "18m", &stats->txrates[7], + "18 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "24m", &stats->txrates[8], + "24 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "36m", &stats->txrates[9], + "36 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "48m", &stats->txrates[10], + "48 Mbit/s"); + URTW_SYSCTL_STAT_ADD32(ctx, child, "54m", &stats->txrates[11], + "54 Mbit/s"); +#undef URTW_SYSCTL_STAT_ADD32 +} + static device_method_t urtw_methods[] = { DEVMETHOD(device_probe, urtw_match), DEVMETHOD(device_attach, urtw_attach), diff --git a/sys/dev/usb/wlan/if_urtwvar.h b/sys/dev/usb/wlan/if_urtwvar.h index 6941abbb8b81..e4a872147fe0 100644 --- a/sys/dev/usb/wlan/if_urtwvar.h +++ b/sys/dev/usb/wlan/if_urtwvar.h @@ -81,6 +81,10 @@ struct urtw_tx_radiotap_header { ((1 << IEEE80211_RADIOTAP_FLAGS) | \ (1 << IEEE80211_RADIOTAP_CHANNEL)) +struct urtw_stats { + unsigned int txrates[12]; +}; + struct urtw_vap { struct ieee80211vap vap; int (*newstate)(struct ieee80211vap *, @@ -169,6 +173,8 @@ struct urtw_softc { uint64_t sc_txstatus; /* only for 8187B */ struct task sc_updateslot_task; + struct urtw_stats sc_stats; + struct urtw_rx_radiotap_header sc_rxtap; int sc_rxtap_len; struct urtw_tx_radiotap_header sc_txtap; |
