blob: 1ecf08b22fcb0a980ee99f7c2e7243504e8a981c [file] [log] [blame]
developer8eb72a32023-03-30 08:32:07 +08001From f910e307237f20440fd1664918fe3b8399267b45 Mon Sep 17 00:00:00 2001
developer24a77e32023-03-22 18:02:16 +08002From: Amit Khatri <amit.khatri@mediatek.com>
3Date: Thu, 23 Mar 2023 14:26:46 +0800
developer8eb72a32023-03-30 08:32:07 +08004Subject: [PATCH 24/25] hostapd: mtk: Add support for masking EHT capabilities.
developer24a77e32023-03-22 18:02:16 +08005
6If STA want to disable EHT mode connection.
7STA can set
8disable_eht=1 in netowrk bloack of AP configuration.
9e.g.
10wpa_cli -iapcli0 set_network 0 disable_eht=1
11
12It will make EHT capability on driver level.
13
14Signed-off-by: Amit Khatri <amit.khatri@mediatek.com>
15---
16 src/drivers/driver.h | 8 ++++++++
17 src/drivers/driver_nl80211.c | 9 +++++++++
18 src/drivers/nl80211_copy.h | 2 ++
19 wpa_supplicant/Makefile | 4 ++++
20 wpa_supplicant/config.c | 3 +++
21 wpa_supplicant/config_file.c | 3 +++
22 wpa_supplicant/config_ssid.h | 11 +++++++++++
23 wpa_supplicant/sme.c | 4 ++++
24 wpa_supplicant/wpa_cli.c | 3 +++
25 wpa_supplicant/wpa_supplicant.c | 15 +++++++++++++++
26 wpa_supplicant/wpa_supplicant_i.h | 6 ++++++
27 11 files changed, 68 insertions(+)
28
29diff --git a/src/drivers/driver.h b/src/drivers/driver.h
30index 7f6392f..1bf0cd6 100644
31--- a/src/drivers/driver.h
32+++ b/src/drivers/driver.h
33@@ -1151,6 +1151,14 @@ struct wpa_driver_associate_params {
34 int disable_he;
35 #endif /* CONFIG_HE_OVERRIDES */
36
37+#ifdef CONFIG_EHT_OVERRIDES
38+ /**
39+ * disable_eht - Disable EHT for this connection
40+ */
41+ int disable_eht;
42+#endif /* CONFIG_EHT_OVERRIDES */
43+
44+
45 /**
46 * req_key_mgmt_offload - Request key management offload for connection
47 *
48diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
49index f9a8763..945ce3e 100644
50--- a/src/drivers/driver_nl80211.c
51+++ b/src/drivers/driver_nl80211.c
52@@ -6058,6 +6058,15 @@ static int nl80211_ht_vht_overrides(struct nl_msg *msg,
53 }
54 #endif /* CONFIG_HE_OVERRIDES */
55
56+#ifdef CONFIG_EHT_OVERRIDES
57+ if (params->disable_eht) {
58+ wpa_printf(MSG_DEBUG, " * EHT disabled");
59+ if (nla_put_flag(msg, NL80211_ATTR_DISABLE_EHT))
60+ return -1;
61+ }
62+#endif /* CONFIG_EHT_OVERRIDES */
63+
64+
65 return 0;
66 }
67
68diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h
69index 0937752..ce8ee58 100644
70--- a/src/drivers/nl80211_copy.h
71+++ b/src/drivers/nl80211_copy.h
72@@ -3175,6 +3175,8 @@ enum nl80211_attrs {
73
74 NL80211_ATTR_EHT_CAPABILITY,
75
76+ NL80211_ATTR_DISABLE_EHT,
77+
78 /* add attributes here, update the policy in nl80211.c */
79
80 __NL80211_ATTR_AFTER_LAST,
81diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
82index ef36b56..40cdb59 100644
83--- a/wpa_supplicant/Makefile
84+++ b/wpa_supplicant/Makefile
85@@ -208,6 +208,10 @@ ifdef CONFIG_HE_OVERRIDES
86 CFLAGS += -DCONFIG_HE_OVERRIDES
87 endif
88
89+ifdef CONFIG_EHT_OVERRIDES
90+CFLAGS += -DCONFIG_EHT_OVERRIDES
91+endif
92+
93 ifndef CONFIG_BACKEND
94 CONFIG_BACKEND=file
95 endif
96diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
97index f9880ed..994ee5e 100644
98--- a/wpa_supplicant/config.c
99+++ b/wpa_supplicant/config.c
100@@ -2718,6 +2718,9 @@ static const struct parse_data ssid_fields[] = {
101 #ifdef CONFIG_HE_OVERRIDES
102 { INT_RANGE(disable_he, 0, 1)},
103 #endif /* CONFIG_HE_OVERRIDES */
104+#ifdef CONFIG_EHT_OVERRIDES
105+ { INT_RANGE(disable_eht, 0, 1)},
106+#endif /* CONFIG_EHT_OVERRIDES */
107 { INT(ap_max_inactivity) },
108 { INT(dtim_period) },
109 { INT(beacon_int) },
110diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
111index 24c2998..056b265 100644
112--- a/wpa_supplicant/config_file.c
113+++ b/wpa_supplicant/config_file.c
114@@ -881,6 +881,9 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
115 #ifdef CONFIG_HE_OVERRIDES
116 INT(disable_he);
117 #endif /* CONFIG_HE_OVERRIDES */
118+#ifdef CONFIG_EHT_OVERRIDES
119+ INT(disable_eht);
120+#endif /* CONFIG_EHT_OVERRIDES */
121
122 #undef STR
123 #undef INT
124diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
125index 9a389cc..cc9aa8e 100644
126--- a/wpa_supplicant/config_ssid.h
127+++ b/wpa_supplicant/config_ssid.h
128@@ -810,6 +810,17 @@ struct wpa_ssid {
129 int disable_he;
130 #endif /* CONFIG_HE_OVERRIDES */
131
132+#ifdef CONFIG_EHT_OVERRIDES
133+ /**
134+ * disable_eht - Disable EHT (IEEE 802.11be) for this network
135+ *
136+ * By default, use it if it is available, but this can be configured
137+ * to 1 to have it disabled.
138+ */
139+ int disable_eht;
140+#endif /* CONFIG_EHT_OVERRIDES */
141+
142+
143 /**
144 * ap_max_inactivity - Timeout in seconds to detect STA's inactivity
145 *
146diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
147index 2dad36d..e7aadf6 100644
148--- a/wpa_supplicant/sme.c
149+++ b/wpa_supplicant/sme.c
150@@ -2001,6 +2001,10 @@ mscs_fail:
151 #ifdef CONFIG_HE_OVERRIDES
152 wpa_supplicant_apply_he_overrides(wpa_s, ssid, &params);
153 #endif /* CONFIG_HE_OVERRIDES */
154+#ifdef CONFIG_EHT_OVERRIDES
155+ wpa_supplicant_apply_eht_overrides(wpa_s, ssid, &params);
156+#endif /* CONFIG_EHT_OVERRIDES */
157+
158 #ifdef CONFIG_IEEE80211R
159 if (auth_type == WLAN_AUTH_FT && wpa_s->sme.ft_ies &&
160 get_ie(wpa_s->sme.ft_ies, wpa_s->sme.ft_ies_len,
161diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
162index 8443f54..ea251db 100644
163--- a/wpa_supplicant/wpa_cli.c
164+++ b/wpa_supplicant/wpa_cli.c
165@@ -1476,6 +1476,9 @@ static const char *network_fields[] = {
166 #ifdef CONFIG_HE_OVERRIDES
167 "disable_he",
168 #endif /* CONFIG_HE_OVERRIDES */
169+#ifdef CONFIG_EHT_OVERRIDES
170+ "disable_eht",
171+#endif /* CONFIG_EHT_OVERRIDES */
172 "ap_max_inactivity", "dtim_period", "beacon_int",
173 #ifdef CONFIG_MACSEC
174 "macsec_policy",
175diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
developer8eb72a32023-03-30 08:32:07 +0800176index 04c37b1..67c801d 100644
developer24a77e32023-03-22 18:02:16 +0800177--- a/wpa_supplicant/wpa_supplicant.c
178+++ b/wpa_supplicant/wpa_supplicant.c
developer8eb72a32023-03-30 08:32:07 +0800179@@ -4084,6 +4084,10 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
developer24a77e32023-03-22 18:02:16 +0800180 #ifdef CONFIG_HE_OVERRIDES
181 wpa_supplicant_apply_he_overrides(wpa_s, ssid, &params);
182 #endif /* CONFIG_HE_OVERRIDES */
183+#ifdef CONFIG_EHT_OVERRIDES
184+ wpa_supplicant_apply_eht_overrides(wpa_s, ssid, &params);
185+#endif /* CONFIG_EHT_OVERRIDES */
186+
187
188 #ifdef CONFIG_P2P
189 /*
developer8eb72a32023-03-30 08:32:07 +0800190@@ -5879,6 +5883,17 @@ void wpa_supplicant_apply_he_overrides(
developer24a77e32023-03-22 18:02:16 +0800191 }
192 #endif /* CONFIG_HE_OVERRIDES */
193
194+#ifdef CONFIG_EHT_OVERRIDES
195+void wpa_supplicant_apply_eht_overrides(
196+ struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
197+ struct wpa_driver_associate_params *params)
198+{
199+ if (!ssid)
200+ return;
201+
202+ params->disable_eht = ssid->disable_eht;
203+}
204+#endif /* CONFIG_EHT_OVERRIDES */
205
206 static int pcsc_reader_init(struct wpa_supplicant *wpa_s)
207 {
208diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
209index 3285af3..76607c5 100644
210--- a/wpa_supplicant/wpa_supplicant_i.h
211+++ b/wpa_supplicant/wpa_supplicant_i.h
212@@ -1576,6 +1576,12 @@ void wpa_supplicant_apply_vht_overrides(
213 void wpa_supplicant_apply_he_overrides(
214 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
215 struct wpa_driver_associate_params *params);
216+#ifdef CONFIG_EHT_OVERRIDES
217+void wpa_supplicant_apply_eht_overrides(
218+ struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
219+ struct wpa_driver_associate_params *params);
220+#endif CONFIG_EHT_OVERRIDES
221+
222
223 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
224 int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
225--
2262.18.0
227