From owner-svn-src-all@FreeBSD.ORG Fri Jul 20 02:17:49 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A3AE106564A; Fri, 20 Jul 2012 02:17:49 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 748058FC16; Fri, 20 Jul 2012 02:17:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6K2HnmP045907; Fri, 20 Jul 2012 02:17:49 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6K2HnaF045904; Fri, 20 Jul 2012 02:17:49 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201207200217.q6K2HnaF045904@svn.freebsd.org> From: Adrian Chadd Date: Fri, 20 Jul 2012 02:17:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238638 - in head/sys/dev/ath: . ath_rate/sample X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 02:17:49 -0000 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. */