From owner-svn-src-user@FreeBSD.ORG Fri May 31 22:23:18 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3F745FC; Fri, 31 May 2013 22:23:18 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 21ACEF54; Fri, 31 May 2013 22:23:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4VMNIlG092308; Fri, 31 May 2013 22:23:18 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4VMNHS7092307; Fri, 31 May 2013 22:23:17 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201305312223.r4VMNHS7092307@svn.freebsd.org> From: Adrian Chadd Date: Fri, 31 May 2013 22:23:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r251205 - user/adrian/net80211_tx/sys/net80211 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 May 2013 22:23:18 -0000 Author: adrian Date: Fri May 31 22:23:17 2013 New Revision: 251205 URL: http://svnweb.freebsd.org/changeset/base/251205 Log: Assert if the high bit in the passed in rate value is set for these routines. Since MCS rates will trip these routines up, let's just enforce for now that the caller strip out the high bit of any basic rate. Modified: user/adrian/net80211_tx/sys/net80211/ieee80211_phy.h Modified: user/adrian/net80211_tx/sys/net80211/ieee80211_phy.h ============================================================================== --- user/adrian/net80211_tx/sys/net80211/ieee80211_phy.h Fri May 31 22:21:37 2013 (r251204) +++ user/adrian/net80211_tx/sys/net80211/ieee80211_phy.h Fri May 31 22:23:17 2013 (r251205) @@ -85,7 +85,14 @@ const struct ieee80211_rate_table *ieee8 static __inline__ uint8_t ieee80211_ack_rate(const struct ieee80211_rate_table *rt, uint8_t rate) { - uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex; + /* + * XXX Assert this is for a legacy rate; not for an MCS rate. + * If the caller wishes to use it for a basic rate, they should + * clear the high bit first. + */ + KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); + + uint8_t cix = rt->info[rt->rateCodeToIndex[rate & IEEE80211_RATE_VAL]].ctlRateIndex; KASSERT(cix != (uint8_t)-1, ("rate %d has no info", rate)); return rt->info[cix].dot11Rate; } @@ -93,7 +100,14 @@ ieee80211_ack_rate(const struct ieee8021 static __inline__ uint8_t ieee80211_ctl_rate(const struct ieee80211_rate_table *rt, uint8_t rate) { - uint8_t cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex; + /* + * XXX Assert this is for a legacy rate; not for an MCS rate. + * If the caller wishes to use it for a basic rate, they should + * clear the high bit first. + */ + KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); + + uint8_t cix = rt->info[rt->rateCodeToIndex[rate & IEEE80211_RATE_VAL]].ctlRateIndex; KASSERT(cix != (uint8_t)-1, ("rate %d has no info", rate)); return rt->info[cix].dot11Rate; } @@ -101,7 +115,14 @@ ieee80211_ctl_rate(const struct ieee8021 static __inline__ enum ieee80211_phytype ieee80211_rate2phytype(const struct ieee80211_rate_table *rt, uint8_t rate) { - uint8_t rix = rt->rateCodeToIndex[rate]; + /* + * XXX Assert this is for a legacy rate; not for an MCS rate. + * If the caller wishes to use it for a basic rate, they should + * clear the high bit first. + */ + KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); + + uint8_t rix = rt->rateCodeToIndex[rate & IEEE80211_RATE_VAL]; KASSERT(rix != (uint8_t)-1, ("rate %d has no info", rate)); return rt->info[rix].phy; } @@ -109,6 +130,13 @@ ieee80211_rate2phytype(const struct ieee static __inline__ int ieee80211_isratevalid(const struct ieee80211_rate_table *rt, uint8_t rate) { + /* + * XXX Assert this is for a legacy rate; not for an MCS rate. + * If the caller wishes to use it for a basic rate, they should + * clear the high bit first. + */ + KASSERT(! (rate & 0x80), ("rate %d is basic/mcs?", rate)); + return rt->rateCodeToIndex[rate] != (uint8_t)-1; }