1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 23 Jan 2020 14:10:20 +0100
3 Subject: [PATCH] driver_nl80211: fix regulatory limits for wmm cwmin/cwmax
6 The internal WMM AC parameters use just the exponent of the CW value, while
7 nl80211 reports the full CW value.
8 This led to completely bogus CWmin/CWmax values in the WMM IE when a regulatory
9 limit was present. Fix this by converting the value to the exponent before
12 Signed-off-by: Felix Fietkau <nbd@nbd.name>
15 --- a/src/drivers/driver_nl80211_capa.c
16 +++ b/src/drivers/driver_nl80211_capa.c
17 @@ -1336,6 +1336,18 @@ static void phy_info_vht_capa(struct hos
21 +static inline int cw2ecw(unsigned int cw)
28 + for (bit = 1; cw != 1; bit++)
34 static void phy_info_freq(struct hostapd_hw_modes *mode,
35 struct hostapd_channel_data *chan,
36 @@ -1438,9 +1450,9 @@ static void phy_info_freq(struct hostapd
39 chan->wmm_rules[ac].min_cwmin =
40 - nla_get_u16(tb_wmm[NL80211_WMMR_CW_MIN]);
41 + cw2ecw(nla_get_u16(tb_wmm[NL80211_WMMR_CW_MIN]));
42 chan->wmm_rules[ac].min_cwmax =
43 - nla_get_u16(tb_wmm[NL80211_WMMR_CW_MAX]);
44 + cw2ecw(nla_get_u16(tb_wmm[NL80211_WMMR_CW_MAX]));
45 chan->wmm_rules[ac].min_aifs =
46 nla_get_u8(tb_wmm[NL80211_WMMR_AIFSN]);
47 chan->wmm_rules[ac].max_txop =