From owner-svn-src-head@FreeBSD.ORG Sun Mar 13 11:58:41 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D2491065690; Sun, 13 Mar 2011 11:58:41 +0000 (UTC) (envelope-from bschmidt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1281D8FC12; Sun, 13 Mar 2011 11:58:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2DBwe1h053974; Sun, 13 Mar 2011 11:58:40 GMT (envelope-from bschmidt@svn.freebsd.org) Received: (from bschmidt@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2DBweGk053972; Sun, 13 Mar 2011 11:58:40 GMT (envelope-from bschmidt@svn.freebsd.org) Message-Id: <201103131158.p2DBweGk053972@svn.freebsd.org> From: Bernhard Schmidt Date: Sun, 13 Mar 2011 11:58:40 +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: r219601 - head/sys/net80211 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Mar 2011 11:58:41 -0000 Author: bschmidt Date: Sun Mar 13 11:58:40 2011 New Revision: 219601 URL: http://svn.freebsd.org/changeset/base/219601 Log: Fix rmax calculation during BSS selection. If multiple networks are available the max bandwidth is one condition used for selecting the "best" BSS. To achieve that we should consider all parameters which affect the max RX rate. This includes 20/40MHz, SGI and the of course the MCS set. If the TX MCS parameters are available we should use those, because an AP announcing support for receiving frames at 450Mbps might only be able to transmit at 150Mbps (1T3R). I haven't seen devices with support for transmitting at higher rates then receiving, so prefering TX over RX information should be safe. While here, remove the hardcoded assumption that MCS15 is the max possible MCS rate, use MCS31 instead which really is the highest rate (according to the 802.11n std). Also, fix a mismatch of an 40MHz/SGI check. Modified: head/sys/net80211/ieee80211_scan_sta.c Modified: head/sys/net80211/ieee80211_scan_sta.c ============================================================================== --- head/sys/net80211/ieee80211_scan_sta.c Sun Mar 13 11:56:33 2011 (r219600) +++ head/sys/net80211/ieee80211_scan_sta.c Sun Mar 13 11:58:40 2011 (r219601) @@ -756,26 +756,38 @@ maxrate(const struct ieee80211_scan_entr { const struct ieee80211_ie_htcap *htcap = (const struct ieee80211_ie_htcap *) se->se_ies.htcap_ie; - int rmax, r, i; + int rmax, r, i, txstream; uint16_t caps; + uint8_t txparams; rmax = 0; if (htcap != NULL) { /* * HT station; inspect supported MCS and then adjust - * rate by channel width. Could also include short GI - * in this if we want to be extra accurate. + * rate by channel width. */ - /* XXX assumes MCS15 is max */ - for (i = 15; i >= 0 && isclr(htcap->hc_mcsset, i); i--) - ; + txparams = htcap->hc_mcsset[12]; + if (txparams & 0x3) { + /* + * TX MCS parameters defined and not equal to RX, + * extract the number of spartial streams and + * map it to the highest MCS rate. + */ + txstream = ((txparams & 0xc) >> 2) + 1; + i = txstream * 8 - 1; + } else + for (i = 31; i >= 0 && isclr(htcap->hc_mcsset, i); i--); if (i >= 0) { caps = LE_READ_2(&htcap->hc_cap); - /* XXX short/long GI */ - if (caps & IEEE80211_HTCAP_CHWIDTH40) + if ((caps & IEEE80211_HTCAP_CHWIDTH40) && + (caps & IEEE80211_HTCAP_SHORTGI40)) rmax = ieee80211_htrates[i].ht40_rate_400ns; - else + else if (caps & IEEE80211_HTCAP_CHWIDTH40) rmax = ieee80211_htrates[i].ht40_rate_800ns; + else if (caps & IEEE80211_HTCAP_SHORTGI20) + rmax = ieee80211_htrates[i].ht20_rate_400ns; + else + rmax = ieee80211_htrates[i].ht20_rate_800ns; } } for (i = 0; i < se->se_rates[1]; i++) {