svn commit: r238638 - in head/sys/dev/ath: . ath_rate/sample
Adrian Chadd
adrian at FreeBSD.org
Fri Jul 20 02:17:49 UTC 2012
Author: adrian
Date: Fri Jul 20 02:17:48 2012
New Revision: 238638
URL: http://svn.freebsd.org/changeset/base/238638
Log:
Introduce a rate table TLV so rate table statistics consumers
know how to map rix -> rate code.
Modified:
head/sys/dev/ath/ath_rate/sample/sample.c
head/sys/dev/ath/if_athioctl.h
Modified: head/sys/dev/ath/ath_rate/sample/sample.c
==============================================================================
--- head/sys/dev/ath/ath_rate/sample/sample.c Fri Jul 20 01:56:14 2012 (r238637)
+++ head/sys/dev/ath/ath_rate/sample/sample.c Fri Jul 20 02:17:48 2012 (r238638)
@@ -1207,8 +1207,9 @@ ath_rate_fetch_node_stats(struct ath_sof
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;
+ struct ath_rateioctl_rt *tv;
int y;
+ int o = 0;
ATH_NODE_LOCK_ASSERT(an);
@@ -1217,48 +1218,61 @@ ath_rate_fetch_node_stats(struct ath_sof
*/
if (rs->len <
sizeof(struct ath_rateioctl_tlv) +
- sizeof(struct sample_node))
+ sizeof(struct ath_rateioctl_rt) +
+ sizeof(struct ath_rateioctl_tlv) +
+ sizeof(struct sample_node)) {
+ device_printf(sc->sc_dev, "%s: len=%d, too short\n",
+ __func__,
+ rs->len);
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)
+ tv = malloc(sizeof(struct ath_rateioctl_rt), M_TEMP,
+ M_NOWAIT | M_ZERO);
+ if (tv == 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]);
+ /*
+ * Populate the rate table mapping TLV.
+ */
+ tv->nentries = rt->rateCount;
+ for (y = 0; y < rt->rateCount; y++) {
+ tv->ratecode[y] = rt->info[y].dot11Rate & IEEE80211_RATE_VAL;
+ if (rt->info[y].phy == IEEE80211_T_HT)
+ tv->ratecode[y] |= IEEE80211_RATE_MCS;
}
+ o = 0;
+ /*
+ * First TLV - rate code mapping
+ */
+ av.tlv_id = ATH_RATE_TLV_RATETABLE;
+ av.tlv_len = sizeof(struct ath_rateioctl_rt);
+ copyout(&av, rs->buf + o, sizeof(struct ath_rateioctl_tlv));
+ o += sizeof(struct ath_rateioctl_tlv);
+ copyout(tv, rs->buf + o, sizeof(struct ath_rateioctl_rt));
+ o += sizeof(struct ath_rateioctl_rt);
+
/*
- * Assemble the TLV.
+ * Second TLV - sample node statistics
*/
av.tlv_id = ATH_RATE_TLV_SAMPLENODE;
av.tlv_len = sizeof(struct sample_node);
- copyout(&av, rs->buf, sizeof(struct ath_rateioctl_tlv));
+ copyout(&av, rs->buf + o, sizeof(struct ath_rateioctl_tlv));
+ o += 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));
+ copyout(sn, rs->buf + o, sizeof(struct sample_node));
+ o += sizeof(struct sample_node);
- free(ts, M_TEMP);
+ free(tv, M_TEMP);
return (0);
}
Modified: head/sys/dev/ath/if_athioctl.h
==============================================================================
--- head/sys/dev/ath/if_athioctl.h Fri Jul 20 01:56:14 2012 (r238637)
+++ head/sys/dev/ath/if_athioctl.h Fri Jul 20 02:17:48 2012 (r238638)
@@ -204,6 +204,18 @@ struct ath_rateioctl_tlv {
#define ATH_RATE_TLV_MACADDR 0xaab0
/*
+ * The rate control modules may decide to push a mapping table
+ * of rix -> net80211 ratecode as part of the update.
+ */
+#define ATH_RATE_TLV_RATETABLE_NENTRIES 64
+struct ath_rateioctl_rt {
+ uint16_t nentries;
+ uint16_t pad[1];
+ uint8_t ratecode[ATH_RATE_TLV_RATETABLE_NENTRIES];
+};
+#define ATH_RATE_TLV_RATETABLE 0xaab1
+
+/*
* This is the sample node statistics structure.
* More in ath_rate/sample/sample.h.
*/
More information about the svn-src-all
mailing list