diff options
-rw-r--r-- | sys/dev/ath/ath_rate/amrr/amrr.c | 8 | ||||
-rw-r--r-- | sys/dev/ath/ath_rate/onoe/onoe.c | 8 | ||||
-rw-r--r-- | sys/dev/ath/ath_rate/sample/sample.c | 81 | ||||
-rw-r--r-- | sys/dev/ath/ath_rate/sample/sample.h | 8 |
4 files changed, 97 insertions, 8 deletions
diff --git a/sys/dev/ath/ath_rate/amrr/amrr.c b/sys/dev/ath/ath_rate/amrr/amrr.c index efba5dd..c252009 100644 --- a/sys/dev/ath/ath_rate/amrr/amrr.c +++ b/sys/dev/ath/ath_rate/amrr/amrr.c @@ -421,6 +421,14 @@ ath_rate_ctl(void *arg, struct ieee80211_node *ni) } } +static int +ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, + struct ath_rateioctl *re) +{ + + return (EINVAL); +} + static void ath_rate_sysctlattach(struct ath_softc *sc) { diff --git a/sys/dev/ath/ath_rate/onoe/onoe.c b/sys/dev/ath/ath_rate/onoe/onoe.c index 7160346..7c73926 100644 --- a/sys/dev/ath/ath_rate/onoe/onoe.c +++ b/sys/dev/ath/ath_rate/onoe/onoe.c @@ -407,6 +407,14 @@ ath_rate_sysctlattach(struct ath_softc *sc) "rate control: # good periods before raising rate"); } +static int +ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, + struct ath_rateioctl *re) +{ + + return (EINVAL); +} + struct ath_ratectrl * ath_rate_attach(struct ath_softc *sc) { diff --git a/sys/dev/ath/ath_rate/sample/sample.c b/sys/dev/ath/ath_rate/sample/sample.c index ae77e5e..b1003be 100644 --- a/sys/dev/ath/ath_rate/sample/sample.c +++ b/sys/dev/ath/ath_rate/sample/sample.c @@ -105,8 +105,6 @@ __FBSDID("$FreeBSD$"); static void ath_rate_ctl_reset(struct ath_softc *, struct ieee80211_node *); -static const int packet_size_bins[NUM_PACKET_SIZE_BINS] = { 250, 1600 }; - static __inline int size_to_bin(int size) { @@ -128,12 +126,6 @@ size_to_bin(int size) return NUM_PACKET_SIZE_BINS-1; } -static __inline int -bin_to_size(int index) -{ - return packet_size_bins[index]; -} - void ath_rate_node_init(struct ath_softc *sc, struct ath_node *an) { @@ -1198,6 +1190,79 @@ ath_rate_ctl_reset(struct ath_softc *sc, struct ieee80211_node *ni) #undef DOT11RATE } +/* + * Fetch the statistics for the given node. + * + * The ieee80211 node must be referenced and unlocked, however the ath_node + * must be locked. + * + * The main difference here is that we convert the rate indexes + * to 802.11 rates, or the userland output won't make much sense + * as it has no access to the rix table. + */ +int +ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, + struct ath_rateioctl *rs) +{ + struct sample_node *sn = ATH_NODE_SAMPLE(an); + const HAL_RATE_TABLE *rt = sc->sc_currates; + struct ath_rateioctl_tlv av; + struct sample_node *ts; + int y; + + ATH_NODE_LOCK_ASSERT(an); + + /* + * Ensure there's enough space for the statistics. + */ + if (rs->len < + sizeof(struct ath_rateioctl_tlv) + + sizeof(struct sample_node)) + return (EINVAL); + + /* + * Take a temporary copy of the sample node state so we can + * modify it before we copy it. + */ + ts = malloc(sizeof(struct sample_node), M_TEMP, M_WAITOK | M_ZERO); + if (ts == NULL) + return (ENOMEM); + memcpy(ts, sn, sizeof(struct sample_node)); + + /* Convert rix -> 802.11 rate codes */ + ts->static_rix = dot11rate(rt, sn->static_rix); + for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { + /* + * For non-11n rates, clear the high bit - that + * means "basic rate" and will confuse things. + * + * For 11n rates, set the high bit. + */ + ts->current_rix[y] = dot11rate(rt, sn->current_rix[y]); + ts->current_sample_rix[y] = + dot11rate(rt, sn->current_sample_rix[y]); + ts->last_sample_rix[y] = + dot11rate(rt, sn->last_sample_rix[y]); + } + + /* + * Assemble the TLV. + */ + av.tlv_id = ATH_RATE_TLV_SAMPLENODE; + av.tlv_len = sizeof(struct sample_node); + copyout(&av, rs->buf, sizeof(struct ath_rateioctl_tlv)); + + /* + * Copy the statistics over to the provided buffer. + */ + copyout(ts, rs->buf + sizeof(struct ath_rateioctl_tlv), + sizeof(struct sample_node)); + + free(ts, M_TEMP); + + return (0); +} + static void sample_stats(void *arg, struct ieee80211_node *ni) { diff --git a/sys/dev/ath/ath_rate/sample/sample.h b/sys/dev/ath/ath_rate/sample/sample.h index 2d586b7..fcac316 100644 --- a/sys/dev/ath/ath_rate/sample/sample.h +++ b/sys/dev/ath/ath_rate/sample/sample.h @@ -79,6 +79,14 @@ struct txschedule { */ #define NUM_PACKET_SIZE_BINS 2 +static const int packet_size_bins[NUM_PACKET_SIZE_BINS] = { 250, 1600 }; + +static inline int +bin_to_size(int index) +{ + return packet_size_bins[index]; +} + /* per-node state */ struct sample_node { int static_rix; /* rate index of fixed tx rate */ |