aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/hostapd/patches/071-driver_nl80211-fix-regulatory-limits-for-wmm-cwmin-c.patch
blob: fe41e2b7880d4319075edbad3d1e1594b8fce3cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From: Felix Fietkau <nbd@nbd.name>
Date: Thu, 23 Jan 2020 14:10:20 +0100
Subject: [PATCH] driver_nl80211: fix regulatory limits for wmm cwmin/cwmax
 values

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

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---

--- a/src/drivers/driver_nl80211_capa.c
+++ b/src/drivers/driver_nl80211_capa.c
@@ -1336,6 +1336,18 @@ static void phy_info_vht_capa(struct hos
 	}
 }
 
+static inline 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,
@@ -1438,9 +1450,9 @@ static void phy_info_freq(struct hostapd
 
 			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 =