diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-04-05 09:13:38 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-04-10 13:37:24 +0200 |
commit | 21c22f2f96311fbd9d2d1e3951e52a96356757e8 (patch) | |
tree | 4c8a11ebd8d2e51ad8cdab1f1941aead6c50b24b | |
parent | cd91b7e1190177942252dd1a759be82037a7a2a7 (diff) | |
download | NetworkManager-21c22f2f96311fbd9d2d1e3951e52a96356757e8.tar.gz |
wifi: fix HT max rate calculation
The rates of MCSs are not monotonically increasing.
-rw-r--r-- | src/devices/wifi/nm-wifi-ap.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index e477c8e86d..c45eaafa93 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -628,36 +628,40 @@ get_max_rate_vht_160_ss3 (int mcs) static gboolean get_max_rate_ht (const guint8 *bytes, guint len, guint32 *out_maxrate) { - guint32 mcs, i, m; + guint32 mcs, i; guint8 ht_cap_info; const guint8 *supported_mcs_set; + guint32 rate; - /* https://mrncciew.com/2014/10/19/cwap-ht-capabilities-ie/ - http://luci.subsignal.org/~jow/802.11n-2009.pdf */ + /* http://standards.ieee.org/getieee802/download/802.11-2012.pdf + * https://mrncciew.com/2014/10/19/cwap-ht-capabilities-ie/ + */ if (len != 26) return FALSE; ht_cap_info = bytes[0]; supported_mcs_set = &bytes[3]; + *out_maxrate = 0; /* Find the maximum supported mcs rate */ mcs = -1; for (i = 0; i <= 76; i++) { - unsigned int mcs_octet = i/8; + unsigned int mcs_octet = i / 8; unsigned int MCS_RATE_BIT = 1 << i % 8; - if (supported_mcs_set[mcs_octet] & MCS_RATE_BIT) - mcs = i; - } + if (supported_mcs_set[mcs_octet] & MCS_RATE_BIT) { + /* Check for 40Mhz wide channel support */ + if (ht_cap_info & (1 << 1)) + rate = get_max_rate_ht_40 (i); + else + rate = get_max_rate_ht_20 (i); - /* Check for 40Mhz wide channel support */ - if (ht_cap_info & (1 << 1)) - m = get_max_rate_ht_40 (mcs); - else - m = get_max_rate_ht_20 (mcs); + if (rate > *out_maxrate) + *out_maxrate = rate; + } + } - *out_maxrate = m; return TRUE; } |