]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Fix regulatory limits for WMM cwmin/cwmax values
authorFelix Fietkau <nbd@nbd.name>
Thu, 23 Jan 2020 13:13:33 +0000 (14:13 +0100)
committerJouni Malinen <jouni@codeaurora.org>
Mon, 3 Feb 2020 00:03:32 +0000 (02:03 +0200)
The internal WMM AC parameters use just the exponent of the CW value,
while nl80211 reports the full CW value. This led to completely bogus
CWmin/CWmax values in the WMM IE when a regulatory limit was present.
Fix this by converting the value to the exponent before passing it on.

Fixes: 636c02c6e9 ("nl80211: Add regulatory wmm_limit to hostapd_channel_data")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
src/drivers/driver_nl80211_capa.c

index 59d06bcc9956194ff3927705a86e6d94abccc7e6..31e7cbfe522cd7bc6761a31598d257c76a6bd200 100644 (file)
@@ -1368,6 +1368,20 @@ static int phy_info_edmg_capa(struct hostapd_hw_modes *mode,
 }
 
 
+static int cw2ecw(unsigned int cw)
+{
+       int bit;
+
+       if (cw == 0)
+               return 0;
+
+       for (bit = 1; cw != 1; bit++)
+               cw >>= 1;
+
+       return bit;
+}
+
+
 static void phy_info_freq(struct hostapd_hw_modes *mode,
                          struct hostapd_channel_data *chan,
                          struct nlattr *tb_freq[])
@@ -1475,9 +1489,11 @@ static void phy_info_freq(struct hostapd_hw_modes *mode,
 
                        ac = wmm_map[ac];
                        chan->wmm_rules[ac].min_cwmin =
-                               nla_get_u16(tb_wmm[NL80211_WMMR_CW_MIN]);
+                               cw2ecw(nla_get_u16(
+                                              tb_wmm[NL80211_WMMR_CW_MIN]));
                        chan->wmm_rules[ac].min_cwmax =
-                               nla_get_u16(tb_wmm[NL80211_WMMR_CW_MAX]);
+                               cw2ecw(nla_get_u16(
+                                              tb_wmm[NL80211_WMMR_CW_MAX]));
                        chan->wmm_rules[ac].min_aifs =
                                nla_get_u8(tb_wmm[NL80211_WMMR_AIFSN]);
                        chan->wmm_rules[ac].max_txop =