Commit | Line | Data |
---|---|---|
28c61a66 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
f0706e82 JB |
2 | /* |
3 | * mac80211 configuration hooks for cfg80211 | |
4 | * | |
026331c4 | 5 | * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> |
b2eb0ee6 | 6 | * Copyright 2013-2015 Intel Mobile Communications GmbH |
e8e4f528 | 7 | * Copyright (C) 2015-2017 Intel Deutschland GmbH |
a096a860 | 8 | * Copyright (C) 2018-2025 Intel Corporation |
f0706e82 JB |
9 | */ |
10 | ||
e8cbb4cb | 11 | #include <linux/ieee80211.h> |
f0706e82 JB |
12 | #include <linux/nl80211.h> |
13 | #include <linux/rtnetlink.h> | |
5a0e3ad6 | 14 | #include <linux/slab.h> |
881d966b | 15 | #include <net/net_namespace.h> |
5dfdaf58 | 16 | #include <linux/rcupdate.h> |
5fdb3735 | 17 | #include <linux/fips.h> |
dfe018bf | 18 | #include <linux/if_ether.h> |
f0706e82 JB |
19 | #include <net/cfg80211.h> |
20 | #include "ieee80211_i.h" | |
24487981 | 21 | #include "driver-ops.h" |
2c8dccc7 | 22 | #include "rate.h" |
c5dd9c2b | 23 | #include "mesh.h" |
02219b3a | 24 | #include "wme.h" |
c5dd9c2b | 25 | |
c88f1542 | 26 | static struct ieee80211_link_data * |
ccdde7c7 JB |
27 | ieee80211_link_or_deflink(struct ieee80211_sub_if_data *sdata, int link_id, |
28 | bool require_valid) | |
c88f1542 ST |
29 | { |
30 | struct ieee80211_link_data *link; | |
31 | ||
32 | if (link_id < 0) { | |
ccdde7c7 JB |
33 | /* |
34 | * For keys, if sdata is not an MLD, we might not use | |
35 | * the return value at all (if it's not a pairwise key), | |
36 | * so in that case (require_valid==false) don't error. | |
37 | */ | |
f1871abd | 38 | if (require_valid && ieee80211_vif_is_mld(&sdata->vif)) |
c88f1542 ST |
39 | return ERR_PTR(-EINVAL); |
40 | ||
41 | return &sdata->deflink; | |
42 | } | |
43 | ||
44 | link = sdata_dereference(sdata->link[link_id], sdata); | |
45 | if (!link) | |
46 | return ERR_PTR(-ENOLINK); | |
47 | return link; | |
48 | } | |
49 | ||
65f1d600 JB |
50 | static void ieee80211_set_mu_mimo_follow(struct ieee80211_sub_if_data *sdata, |
51 | struct vif_params *params) | |
8c5e6889 | 52 | { |
8c5e6889 JB |
53 | bool mu_mimo_groups = false; |
54 | bool mu_mimo_follow = false; | |
55 | ||
8c5e6889 JB |
56 | if (params->vht_mumimo_groups) { |
57 | u64 membership; | |
58 | ||
59 | BUILD_BUG_ON(sizeof(membership) != WLAN_MEMBERSHIP_LEN); | |
60 | ||
65f1d600 | 61 | memcpy(sdata->vif.bss_conf.mu_group.membership, |
8c5e6889 | 62 | params->vht_mumimo_groups, WLAN_MEMBERSHIP_LEN); |
65f1d600 | 63 | memcpy(sdata->vif.bss_conf.mu_group.position, |
8c5e6889 JB |
64 | params->vht_mumimo_groups + WLAN_MEMBERSHIP_LEN, |
65 | WLAN_USER_POSITION_LEN); | |
d8675a63 | 66 | ieee80211_link_info_change_notify(sdata, &sdata->deflink, |
7b7090b4 | 67 | BSS_CHANGED_MU_GROUPS); |
8c5e6889 JB |
68 | /* don't care about endianness - just check for 0 */ |
69 | memcpy(&membership, params->vht_mumimo_groups, | |
70 | WLAN_MEMBERSHIP_LEN); | |
71 | mu_mimo_groups = membership != 0; | |
72 | } | |
73 | ||
74 | if (params->vht_mumimo_follow_addr) { | |
75 | mu_mimo_follow = | |
76 | is_valid_ether_addr(params->vht_mumimo_follow_addr); | |
65f1d600 | 77 | ether_addr_copy(sdata->u.mntr.mu_follow_addr, |
8c5e6889 JB |
78 | params->vht_mumimo_follow_addr); |
79 | } | |
80 | ||
d0a9123e | 81 | sdata->vif.bss_conf.mu_mimo_owner = mu_mimo_groups || mu_mimo_follow; |
65f1d600 JB |
82 | } |
83 | ||
84 | static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata, | |
85 | struct vif_params *params) | |
86 | { | |
87 | struct ieee80211_local *local = sdata->local; | |
88 | struct ieee80211_sub_if_data *monitor_sdata; | |
89 | ||
90 | /* check flags first */ | |
91 | if (params->flags && ieee80211_sdata_running(sdata)) { | |
286e6967 | 92 | u32 mask = MONITOR_FLAG_ACTIVE; |
65f1d600 JB |
93 | |
94 | /* | |
286e6967 AW |
95 | * Prohibit MONITOR_FLAG_ACTIVE to be changed |
96 | * while the interface is up. | |
65f1d600 JB |
97 | * Else we would need to add a lot of cruft |
98 | * to update everything: | |
286e6967 | 99 | * monitor and all fif_* counters |
65f1d600 JB |
100 | * reconfigure hardware |
101 | */ | |
102 | if ((params->flags & mask) != (sdata->u.mntr.flags & mask)) | |
103 | return -EBUSY; | |
104 | } | |
105 | ||
106 | /* also validate MU-MIMO change */ | |
9d40f7e3 FF |
107 | if (ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) |
108 | monitor_sdata = sdata; | |
109 | else | |
110 | monitor_sdata = wiphy_dereference(local->hw.wiphy, | |
111 | local->monitor_sdata); | |
65f1d600 JB |
112 | |
113 | if (!monitor_sdata && | |
114 | (params->vht_mumimo_groups || params->vht_mumimo_follow_addr)) | |
115 | return -EOPNOTSUPP; | |
116 | ||
117 | /* apply all changes now - no failures allowed */ | |
118 | ||
9d40f7e3 FF |
119 | if (monitor_sdata && |
120 | (ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) || | |
121 | ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR))) | |
65f1d600 JB |
122 | ieee80211_set_mu_mimo_follow(monitor_sdata, params); |
123 | ||
124 | if (params->flags) { | |
125 | if (ieee80211_sdata_running(sdata)) { | |
126 | ieee80211_adjust_monitor_flags(sdata, -1); | |
127 | sdata->u.mntr.flags = params->flags; | |
128 | ieee80211_adjust_monitor_flags(sdata, 1); | |
129 | ||
130 | ieee80211_configure_filter(local); | |
131 | } else { | |
132 | /* | |
133 | * Because the interface is down, ieee80211_do_stop | |
134 | * and ieee80211_do_open take care of "everything" | |
135 | * mentioned in the comment above. | |
136 | */ | |
137 | sdata->u.mntr.flags = params->flags; | |
138 | } | |
139 | } | |
8c5e6889 JB |
140 | |
141 | return 0; | |
142 | } | |
143 | ||
17196425 | 144 | static int ieee80211_set_ap_mbssid_options(struct ieee80211_sub_if_data *sdata, |
f2aadc72 | 145 | struct cfg80211_mbssid_config *params, |
d9f83f22 | 146 | struct ieee80211_bss_conf *link_conf) |
17196425 JC |
147 | { |
148 | struct ieee80211_sub_if_data *tx_sdata; | |
f6008327 | 149 | struct ieee80211_bss_conf *old; |
17196425 | 150 | |
d9f83f22 ST |
151 | link_conf->bssid_index = 0; |
152 | link_conf->nontransmitted = false; | |
153 | link_conf->ema_ap = false; | |
0eb38842 | 154 | link_conf->bssid_indicator = 0; |
17196425 | 155 | |
f2aadc72 | 156 | if (sdata->vif.type != NL80211_IFTYPE_AP || !params->tx_wdev) |
17196425 JC |
157 | return -EINVAL; |
158 | ||
f6008327 RS |
159 | old = sdata_dereference(link_conf->tx_bss_conf, sdata); |
160 | if (old) | |
161 | return -EALREADY; | |
162 | ||
f2aadc72 | 163 | tx_sdata = IEEE80211_WDEV_TO_SUB_IF(params->tx_wdev); |
17196425 JC |
164 | if (!tx_sdata) |
165 | return -EINVAL; | |
166 | ||
167 | if (tx_sdata == sdata) { | |
f6008327 | 168 | rcu_assign_pointer(link_conf->tx_bss_conf, link_conf); |
17196425 | 169 | } else { |
f6008327 RS |
170 | struct ieee80211_bss_conf *tx_bss_conf; |
171 | ||
172 | tx_bss_conf = sdata_dereference(tx_sdata->vif.link_conf[params->tx_link_id], | |
173 | sdata); | |
174 | if (rcu_access_pointer(tx_bss_conf->tx_bss_conf) != tx_bss_conf) | |
175 | return -EINVAL; | |
176 | ||
177 | rcu_assign_pointer(link_conf->tx_bss_conf, tx_bss_conf); | |
178 | ||
d9f83f22 | 179 | link_conf->nontransmitted = true; |
f2aadc72 | 180 | link_conf->bssid_index = params->index; |
17196425 | 181 | } |
f2aadc72 | 182 | if (params->ema) |
d9f83f22 | 183 | link_conf->ema_ap = true; |
17196425 JC |
184 | |
185 | return 0; | |
186 | } | |
187 | ||
552bff0c JB |
188 | static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, |
189 | const char *name, | |
6bab2e19 | 190 | unsigned char name_assign_type, |
84efbb84 | 191 | enum nl80211_iftype type, |
84efbb84 | 192 | struct vif_params *params) |
f0706e82 JB |
193 | { |
194 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
84efbb84 | 195 | struct wireless_dev *wdev; |
8cc9a739 MW |
196 | struct ieee80211_sub_if_data *sdata; |
197 | int err; | |
f0706e82 | 198 | |
6bab2e19 | 199 | err = ieee80211_if_add(local, name, name_assign_type, &wdev, type, params); |
f9e10ce4 JB |
200 | if (err) |
201 | return ERR_PTR(err); | |
8cc9a739 | 202 | |
8c5e6889 JB |
203 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
204 | ||
205 | if (type == NL80211_IFTYPE_MONITOR) { | |
65f1d600 | 206 | err = ieee80211_set_mon_options(sdata, params); |
8c5e6889 JB |
207 | if (err) { |
208 | ieee80211_if_remove(sdata); | |
209 | return NULL; | |
210 | } | |
f9e10ce4 JB |
211 | } |
212 | ||
074a8b54 IP |
213 | /* Let the driver know that an interface is going to be added. |
214 | * Indicate so only for interface types that will be added to the | |
215 | * driver. | |
216 | */ | |
217 | switch (type) { | |
218 | case NL80211_IFTYPE_AP_VLAN: | |
219 | break; | |
220 | case NL80211_IFTYPE_MONITOR: | |
221 | if (!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF) || | |
222 | !(params->flags & MONITOR_FLAG_ACTIVE)) | |
223 | break; | |
224 | fallthrough; | |
225 | default: | |
226 | drv_prep_add_interface(local, | |
227 | ieee80211_vif_type_p2p(&sdata->vif)); | |
228 | break; | |
229 | } | |
230 | ||
84efbb84 | 231 | return wdev; |
f0706e82 JB |
232 | } |
233 | ||
84efbb84 | 234 | static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev) |
f0706e82 | 235 | { |
84efbb84 | 236 | ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev)); |
f0706e82 | 237 | |
75636525 | 238 | return 0; |
f0706e82 JB |
239 | } |
240 | ||
e36d56b6 JB |
241 | static int ieee80211_change_iface(struct wiphy *wiphy, |
242 | struct net_device *dev, | |
818a986e | 243 | enum nl80211_iftype type, |
2ec600d6 | 244 | struct vif_params *params) |
42613db7 | 245 | { |
9607e6b6 | 246 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
a5d3cbdb FF |
247 | struct ieee80211_local *local = sdata->local; |
248 | struct sta_info *sta; | |
f3947e2d | 249 | int ret; |
42613db7 | 250 | |
4d3acf43 JB |
251 | lockdep_assert_wiphy(local->hw.wiphy); |
252 | ||
05c914fe | 253 | ret = ieee80211_if_change_type(sdata, type); |
f3947e2d JB |
254 | if (ret) |
255 | return ret; | |
42613db7 | 256 | |
6f527287 | 257 | if (type == NL80211_IFTYPE_AP_VLAN && params->use_4addr == 0) { |
a9b3cd7f | 258 | RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); |
49ddf8e6 | 259 | ieee80211_check_fast_rx_iface(sdata); |
6f527287 | 260 | } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) { |
a5d3cbdb FF |
261 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
262 | ||
263 | if (params->use_4addr == ifmgd->use_4addr) | |
264 | return 0; | |
265 | ||
90703ba9 | 266 | /* FIXME: no support for 4-addr MLO yet */ |
f1871abd | 267 | if (ieee80211_vif_is_mld(&sdata->vif)) |
90703ba9 JB |
268 | return -EOPNOTSUPP; |
269 | ||
9bc383de | 270 | sdata->u.mgd.use_4addr = params->use_4addr; |
a5d3cbdb FF |
271 | if (!ifmgd->associated) |
272 | return 0; | |
273 | ||
bfd8403a | 274 | sta = sta_info_get(sdata, sdata->deflink.u.mgd.bssid); |
a5d3cbdb FF |
275 | if (sta) |
276 | drv_sta_set_4addr(local, sdata, &sta->sta, | |
277 | params->use_4addr); | |
a5d3cbdb FF |
278 | |
279 | if (params->use_4addr) | |
280 | ieee80211_send_4addr_nullfunc(local, sdata); | |
49ddf8e6 | 281 | } |
9bc383de | 282 | |
42bd20d9 | 283 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR) { |
65f1d600 JB |
284 | ret = ieee80211_set_mon_options(sdata, params); |
285 | if (ret) | |
286 | return ret; | |
85416a4f | 287 | } |
f7917af9 | 288 | |
42613db7 JB |
289 | return 0; |
290 | } | |
291 | ||
f142c6b9 JB |
292 | static int ieee80211_start_p2p_device(struct wiphy *wiphy, |
293 | struct wireless_dev *wdev) | |
294 | { | |
b6a55015 LC |
295 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
296 | int ret; | |
297 | ||
5435af6e JB |
298 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
299 | ||
0874bcd0 | 300 | ret = ieee80211_check_combinations(sdata, NULL, 0, 0, -1); |
b6a55015 LC |
301 | if (ret < 0) |
302 | return ret; | |
303 | ||
f142c6b9 JB |
304 | return ieee80211_do_open(wdev, true); |
305 | } | |
306 | ||
307 | static void ieee80211_stop_p2p_device(struct wiphy *wiphy, | |
308 | struct wireless_dev *wdev) | |
309 | { | |
310 | ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev)); | |
311 | } | |
312 | ||
708d50ed AB |
313 | static int ieee80211_start_nan(struct wiphy *wiphy, |
314 | struct wireless_dev *wdev, | |
315 | struct cfg80211_nan_conf *conf) | |
316 | { | |
317 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
318 | int ret; | |
319 | ||
5435af6e JB |
320 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
321 | ||
0874bcd0 | 322 | ret = ieee80211_check_combinations(sdata, NULL, 0, 0, -1); |
708d50ed AB |
323 | if (ret < 0) |
324 | return ret; | |
325 | ||
326 | ret = ieee80211_do_open(wdev, true); | |
327 | if (ret) | |
328 | return ret; | |
329 | ||
330 | ret = drv_start_nan(sdata->local, sdata, conf); | |
331 | if (ret) | |
332 | ieee80211_sdata_stop(sdata); | |
333 | ||
167e33f4 AB |
334 | sdata->u.nan.conf = *conf; |
335 | ||
708d50ed AB |
336 | return ret; |
337 | } | |
338 | ||
339 | static void ieee80211_stop_nan(struct wiphy *wiphy, | |
340 | struct wireless_dev *wdev) | |
341 | { | |
342 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
343 | ||
344 | drv_stop_nan(sdata->local, sdata); | |
345 | ieee80211_sdata_stop(sdata); | |
346 | } | |
347 | ||
5953ff6d AB |
348 | static int ieee80211_nan_change_conf(struct wiphy *wiphy, |
349 | struct wireless_dev *wdev, | |
350 | struct cfg80211_nan_conf *conf, | |
351 | u32 changes) | |
352 | { | |
353 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
354 | struct cfg80211_nan_conf new_conf; | |
355 | int ret = 0; | |
356 | ||
357 | if (sdata->vif.type != NL80211_IFTYPE_NAN) | |
358 | return -EOPNOTSUPP; | |
359 | ||
360 | if (!ieee80211_sdata_running(sdata)) | |
361 | return -ENETDOWN; | |
362 | ||
363 | new_conf = sdata->u.nan.conf; | |
364 | ||
365 | if (changes & CFG80211_NAN_CONF_CHANGED_PREF) | |
366 | new_conf.master_pref = conf->master_pref; | |
367 | ||
8585989d LC |
368 | if (changes & CFG80211_NAN_CONF_CHANGED_BANDS) |
369 | new_conf.bands = conf->bands; | |
5953ff6d AB |
370 | |
371 | ret = drv_nan_change_conf(sdata->local, sdata, &new_conf, changes); | |
372 | if (!ret) | |
373 | sdata->u.nan.conf = new_conf; | |
374 | ||
375 | return ret; | |
376 | } | |
377 | ||
167e33f4 AB |
378 | static int ieee80211_add_nan_func(struct wiphy *wiphy, |
379 | struct wireless_dev *wdev, | |
380 | struct cfg80211_nan_func *nan_func) | |
381 | { | |
382 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
383 | int ret; | |
384 | ||
385 | if (sdata->vif.type != NL80211_IFTYPE_NAN) | |
386 | return -EOPNOTSUPP; | |
387 | ||
388 | if (!ieee80211_sdata_running(sdata)) | |
389 | return -ENETDOWN; | |
390 | ||
391 | spin_lock_bh(&sdata->u.nan.func_lock); | |
392 | ||
393 | ret = idr_alloc(&sdata->u.nan.function_inst_ids, | |
394 | nan_func, 1, sdata->local->hw.max_nan_de_entries + 1, | |
395 | GFP_ATOMIC); | |
396 | spin_unlock_bh(&sdata->u.nan.func_lock); | |
397 | ||
398 | if (ret < 0) | |
399 | return ret; | |
400 | ||
401 | nan_func->instance_id = ret; | |
402 | ||
403 | WARN_ON(nan_func->instance_id == 0); | |
404 | ||
405 | ret = drv_add_nan_func(sdata->local, sdata, nan_func); | |
406 | if (ret) { | |
407 | spin_lock_bh(&sdata->u.nan.func_lock); | |
408 | idr_remove(&sdata->u.nan.function_inst_ids, | |
409 | nan_func->instance_id); | |
410 | spin_unlock_bh(&sdata->u.nan.func_lock); | |
411 | } | |
412 | ||
413 | return ret; | |
414 | } | |
415 | ||
416 | static struct cfg80211_nan_func * | |
417 | ieee80211_find_nan_func_by_cookie(struct ieee80211_sub_if_data *sdata, | |
418 | u64 cookie) | |
419 | { | |
420 | struct cfg80211_nan_func *func; | |
421 | int id; | |
422 | ||
423 | lockdep_assert_held(&sdata->u.nan.func_lock); | |
424 | ||
425 | idr_for_each_entry(&sdata->u.nan.function_inst_ids, func, id) { | |
426 | if (func->cookie == cookie) | |
427 | return func; | |
428 | } | |
429 | ||
430 | return NULL; | |
431 | } | |
432 | ||
433 | static void ieee80211_del_nan_func(struct wiphy *wiphy, | |
434 | struct wireless_dev *wdev, u64 cookie) | |
435 | { | |
436 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
437 | struct cfg80211_nan_func *func; | |
438 | u8 instance_id = 0; | |
439 | ||
440 | if (sdata->vif.type != NL80211_IFTYPE_NAN || | |
441 | !ieee80211_sdata_running(sdata)) | |
442 | return; | |
443 | ||
444 | spin_lock_bh(&sdata->u.nan.func_lock); | |
445 | ||
446 | func = ieee80211_find_nan_func_by_cookie(sdata, cookie); | |
447 | if (func) | |
448 | instance_id = func->instance_id; | |
449 | ||
450 | spin_unlock_bh(&sdata->u.nan.func_lock); | |
451 | ||
452 | if (instance_id) | |
453 | drv_del_nan_func(sdata->local, sdata, instance_id); | |
454 | } | |
455 | ||
b53be792 SW |
456 | static int ieee80211_set_noack_map(struct wiphy *wiphy, |
457 | struct net_device *dev, | |
458 | u16 noack_map) | |
459 | { | |
460 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
461 | ||
462 | sdata->noack_map = noack_map; | |
17c18bf8 JB |
463 | |
464 | ieee80211_check_fast_xmit_iface(sdata); | |
465 | ||
b53be792 SW |
466 | return 0; |
467 | } | |
468 | ||
96fc6efb AW |
469 | static int ieee80211_set_tx(struct ieee80211_sub_if_data *sdata, |
470 | const u8 *mac_addr, u8 key_idx) | |
471 | { | |
472 | struct ieee80211_local *local = sdata->local; | |
473 | struct ieee80211_key *key; | |
474 | struct sta_info *sta; | |
475 | int ret = -EINVAL; | |
476 | ||
477 | if (!wiphy_ext_feature_isset(local->hw.wiphy, | |
478 | NL80211_EXT_FEATURE_EXT_KEY_ID)) | |
479 | return -EINVAL; | |
480 | ||
481 | sta = sta_info_get_bss(sdata, mac_addr); | |
482 | ||
483 | if (!sta) | |
484 | return -EINVAL; | |
485 | ||
486 | if (sta->ptk_idx == key_idx) | |
487 | return 0; | |
488 | ||
2a8b665e | 489 | key = wiphy_dereference(local->hw.wiphy, sta->ptk[key_idx]); |
96fc6efb AW |
490 | |
491 | if (key && key->conf.flags & IEEE80211_KEY_FLAG_NO_AUTO_TX) | |
492 | ret = ieee80211_set_tx_key(key); | |
493 | ||
96fc6efb AW |
494 | return ret; |
495 | } | |
496 | ||
e8cbb4cb | 497 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
e7a7b84e VJ |
498 | int link_id, u8 key_idx, bool pairwise, |
499 | const u8 *mac_addr, struct key_params *params) | |
e8cbb4cb | 500 | { |
26a58456 | 501 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
ccdde7c7 JB |
502 | struct ieee80211_link_data *link = |
503 | ieee80211_link_or_deflink(sdata, link_id, false); | |
2475b1cc | 504 | struct ieee80211_local *local = sdata->local; |
e8cbb4cb | 505 | struct sta_info *sta = NULL; |
db4d1169 | 506 | struct ieee80211_key *key; |
3b96766f | 507 | int err; |
4d3acf43 JB |
508 | |
509 | lockdep_assert_wiphy(local->hw.wiphy); | |
e8cbb4cb | 510 | |
26a58456 | 511 | if (!ieee80211_sdata_running(sdata)) |
ad0e2b5a JB |
512 | return -ENETDOWN; |
513 | ||
ccdde7c7 JB |
514 | if (IS_ERR(link)) |
515 | return PTR_ERR(link); | |
516 | ||
6bd9a087 BB |
517 | if (WARN_ON(pairwise && link_id >= 0)) |
518 | return -EINVAL; | |
519 | ||
96fc6efb AW |
520 | if (pairwise && params->mode == NL80211_KEY_SET_TX) |
521 | return ieee80211_set_tx(sdata, mac_addr, key_idx); | |
522 | ||
97359d12 | 523 | /* reject WEP and TKIP keys if WEP failed to initialize */ |
e8cbb4cb JB |
524 | switch (params->cipher) { |
525 | case WLAN_CIPHER_SUITE_WEP40: | |
e8cbb4cb | 526 | case WLAN_CIPHER_SUITE_TKIP: |
97359d12 | 527 | case WLAN_CIPHER_SUITE_WEP104: |
ccdde7c7 JB |
528 | if (link_id >= 0) |
529 | return -EINVAL; | |
5fdb3735 | 530 | if (WARN_ON_ONCE(fips_enabled)) |
97359d12 | 531 | return -EINVAL; |
aaaee2d6 | 532 | break; |
e8cbb4cb | 533 | default: |
97359d12 | 534 | break; |
e8cbb4cb JB |
535 | } |
536 | ||
97359d12 | 537 | key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, |
23a5f0af | 538 | params->key, params->seq_len, params->seq); |
1ac62ba7 BH |
539 | if (IS_ERR(key)) |
540 | return PTR_ERR(key); | |
db4d1169 | 541 | |
6bd9a087 | 542 | if (pairwise) { |
e31b8213 | 543 | key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE; |
6bd9a087 BB |
544 | key->conf.link_id = -1; |
545 | } else { | |
546 | key->conf.link_id = link->link_id; | |
547 | } | |
e31b8213 | 548 | |
96fc6efb AW |
549 | if (params->mode == NL80211_KEY_NO_TX) |
550 | key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX; | |
551 | ||
e8cbb4cb | 552 | if (mac_addr) { |
850092db | 553 | sta = sta_info_get_bss(sdata, mac_addr); |
1626e0fa JB |
554 | /* |
555 | * The ASSOC test makes sure the driver is ready to | |
556 | * receive the key. When wpa_supplicant has roamed | |
557 | * using FT, it attempts to set the key before | |
558 | * association has completed, this rejects that attempt | |
d070f913 | 559 | * so it will set the key again after association. |
1626e0fa JB |
560 | * |
561 | * TODO: accept the key if we have a station entry and | |
562 | * add it to the device after the station. | |
563 | */ | |
564 | if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) { | |
79cf2dfa | 565 | ieee80211_key_free_unused(key); |
4d3acf43 | 566 | return -ENOENT; |
db4d1169 | 567 | } |
e8cbb4cb JB |
568 | } |
569 | ||
e548c49e JB |
570 | switch (sdata->vif.type) { |
571 | case NL80211_IFTYPE_STATION: | |
572 | if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) | |
573 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; | |
574 | break; | |
575 | case NL80211_IFTYPE_AP: | |
576 | case NL80211_IFTYPE_AP_VLAN: | |
577 | /* Keys without a station are used for TX only */ | |
211710ca | 578 | if (sta && test_sta_flag(sta, WLAN_STA_MFP)) |
e548c49e JB |
579 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; |
580 | break; | |
581 | case NL80211_IFTYPE_ADHOC: | |
582 | /* no MFP (yet) */ | |
583 | break; | |
584 | case NL80211_IFTYPE_MESH_POINT: | |
585 | #ifdef CONFIG_MAC80211_MESH | |
586 | if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE) | |
587 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; | |
588 | break; | |
589 | #endif | |
590 | case NL80211_IFTYPE_WDS: | |
591 | case NL80211_IFTYPE_MONITOR: | |
592 | case NL80211_IFTYPE_P2P_DEVICE: | |
cb3b7d87 | 593 | case NL80211_IFTYPE_NAN: |
e548c49e JB |
594 | case NL80211_IFTYPE_UNSPECIFIED: |
595 | case NUM_NL80211_IFTYPES: | |
596 | case NL80211_IFTYPE_P2P_CLIENT: | |
597 | case NL80211_IFTYPE_P2P_GO: | |
6e0bd6c3 | 598 | case NL80211_IFTYPE_OCB: |
e548c49e JB |
599 | /* shouldn't happen */ |
600 | WARN_ON_ONCE(1); | |
601 | break; | |
602 | } | |
603 | ||
ccdde7c7 | 604 | err = ieee80211_key_link(key, link, sta); |
31db78a4 JB |
605 | /* KRACK protection, shouldn't happen but just silently accept key */ |
606 | if (err == -EALREADY) | |
607 | err = 0; | |
db4d1169 | 608 | |
3b96766f | 609 | return err; |
e8cbb4cb JB |
610 | } |
611 | ||
8cbf0c2a | 612 | static struct ieee80211_key * |
ccdde7c7 | 613 | ieee80211_lookup_key(struct ieee80211_sub_if_data *sdata, int link_id, |
8cbf0c2a JB |
614 | u8 key_idx, bool pairwise, const u8 *mac_addr) |
615 | { | |
09d838a4 | 616 | struct ieee80211_local *local __maybe_unused = sdata->local; |
ccdde7c7 | 617 | struct ieee80211_link_data *link = &sdata->deflink; |
bfd8403a | 618 | struct ieee80211_key *key; |
ccdde7c7 JB |
619 | |
620 | if (link_id >= 0) { | |
076fc877 | 621 | link = sdata_dereference(sdata->link[link_id], sdata); |
ccdde7c7 JB |
622 | if (!link) |
623 | return NULL; | |
624 | } | |
8cbf0c2a JB |
625 | |
626 | if (mac_addr) { | |
ccdde7c7 JB |
627 | struct sta_info *sta; |
628 | struct link_sta_info *link_sta; | |
629 | ||
8cbf0c2a JB |
630 | sta = sta_info_get_bss(sdata, mac_addr); |
631 | if (!sta) | |
632 | return NULL; | |
633 | ||
ccdde7c7 JB |
634 | if (link_id >= 0) { |
635 | link_sta = rcu_dereference_check(sta->link[link_id], | |
4d3acf43 | 636 | lockdep_is_held(&local->hw.wiphy->mtx)); |
ccdde7c7 JB |
637 | if (!link_sta) |
638 | return NULL; | |
639 | } else { | |
640 | link_sta = &sta->deflink; | |
641 | } | |
642 | ||
8cbf0c2a | 643 | if (pairwise && key_idx < NUM_DEFAULT_KEYS) |
2a8b665e JB |
644 | return wiphy_dereference(local->hw.wiphy, |
645 | sta->ptk[key_idx]); | |
8cbf0c2a JB |
646 | |
647 | if (!pairwise && | |
648 | key_idx < NUM_DEFAULT_KEYS + | |
649 | NUM_DEFAULT_MGMT_KEYS + | |
650 | NUM_DEFAULT_BEACON_KEYS) | |
2a8b665e JB |
651 | return wiphy_dereference(local->hw.wiphy, |
652 | link_sta->gtk[key_idx]); | |
8cbf0c2a JB |
653 | |
654 | return NULL; | |
655 | } | |
656 | ||
bfd8403a | 657 | if (pairwise && key_idx < NUM_DEFAULT_KEYS) |
2a8b665e | 658 | return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]); |
8cbf0c2a | 659 | |
2a8b665e | 660 | key = wiphy_dereference(local->hw.wiphy, link->gtk[key_idx]); |
bfd8403a JB |
661 | if (key) |
662 | return key; | |
663 | ||
e2722d27 JB |
664 | /* or maybe it was a WEP key */ |
665 | if (key_idx < NUM_DEFAULT_KEYS) | |
2a8b665e | 666 | return wiphy_dereference(local->hw.wiphy, sdata->keys[key_idx]); |
e2722d27 | 667 | |
8cbf0c2a JB |
668 | return NULL; |
669 | } | |
670 | ||
e8cbb4cb | 671 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
e7a7b84e VJ |
672 | int link_id, u8 key_idx, bool pairwise, |
673 | const u8 *mac_addr) | |
e8cbb4cb | 674 | { |
5c0c3641 JB |
675 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
676 | struct ieee80211_local *local = sdata->local; | |
8cbf0c2a | 677 | struct ieee80211_key *key; |
e8cbb4cb | 678 | |
4d3acf43 JB |
679 | lockdep_assert_wiphy(local->hw.wiphy); |
680 | ||
ccdde7c7 | 681 | key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr); |
2a8b665e JB |
682 | if (!key) |
683 | return -ENOENT; | |
e8cbb4cb | 684 | |
133bf90d | 685 | ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION); |
e8cbb4cb | 686 | |
2a8b665e | 687 | return 0; |
e8cbb4cb JB |
688 | } |
689 | ||
62da92fb | 690 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
e7a7b84e VJ |
691 | int link_id, u8 key_idx, bool pairwise, |
692 | const u8 *mac_addr, void *cookie, | |
62da92fb JB |
693 | void (*callback)(void *cookie, |
694 | struct key_params *params)) | |
695 | { | |
14db74bc | 696 | struct ieee80211_sub_if_data *sdata; |
62da92fb JB |
697 | u8 seq[6] = {0}; |
698 | struct key_params params; | |
8cbf0c2a | 699 | struct ieee80211_key *key; |
aba83a0b | 700 | u64 pn64; |
62da92fb JB |
701 | u32 iv32; |
702 | u16 iv16; | |
703 | int err = -ENOENT; | |
9352c19f | 704 | struct ieee80211_key_seq kseq = {}; |
62da92fb | 705 | |
14db74bc JB |
706 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
707 | ||
3b96766f JB |
708 | rcu_read_lock(); |
709 | ||
ccdde7c7 | 710 | key = ieee80211_lookup_key(sdata, link_id, key_idx, pairwise, mac_addr); |
62da92fb JB |
711 | if (!key) |
712 | goto out; | |
713 | ||
714 | memset(¶ms, 0, sizeof(params)); | |
715 | ||
97359d12 | 716 | params.cipher = key->conf.cipher; |
62da92fb | 717 | |
97359d12 JB |
718 | switch (key->conf.cipher) { |
719 | case WLAN_CIPHER_SUITE_TKIP: | |
f8079d43 EP |
720 | pn64 = atomic64_read(&key->conf.tx_pn); |
721 | iv32 = TKIP_PN_TO_IV32(pn64); | |
722 | iv16 = TKIP_PN_TO_IV16(pn64); | |
62da92fb | 723 | |
9352c19f JB |
724 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && |
725 | !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { | |
726 | drv_get_key_seq(sdata->local, key, &kseq); | |
727 | iv32 = kseq.tkip.iv32; | |
728 | iv16 = kseq.tkip.iv16; | |
729 | } | |
62da92fb JB |
730 | |
731 | seq[0] = iv16 & 0xff; | |
732 | seq[1] = (iv16 >> 8) & 0xff; | |
733 | seq[2] = iv32 & 0xff; | |
734 | seq[3] = (iv32 >> 8) & 0xff; | |
735 | seq[4] = (iv32 >> 16) & 0xff; | |
736 | seq[5] = (iv32 >> 24) & 0xff; | |
737 | params.seq = seq; | |
738 | params.seq_len = 6; | |
739 | break; | |
97359d12 | 740 | case WLAN_CIPHER_SUITE_CCMP: |
2b2ba0db | 741 | case WLAN_CIPHER_SUITE_CCMP_256: |
97359d12 | 742 | case WLAN_CIPHER_SUITE_AES_CMAC: |
56c52da2 | 743 | case WLAN_CIPHER_SUITE_BIP_CMAC_256: |
db388a56 JB |
744 | BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) != |
745 | offsetof(typeof(kseq), aes_cmac)); | |
fc0561dc | 746 | fallthrough; |
8ade538b JM |
747 | case WLAN_CIPHER_SUITE_BIP_GMAC_128: |
748 | case WLAN_CIPHER_SUITE_BIP_GMAC_256: | |
db388a56 JB |
749 | BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) != |
750 | offsetof(typeof(kseq), aes_gmac)); | |
fc0561dc | 751 | fallthrough; |
00b9cfa3 JM |
752 | case WLAN_CIPHER_SUITE_GCMP: |
753 | case WLAN_CIPHER_SUITE_GCMP_256: | |
db388a56 JB |
754 | BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) != |
755 | offsetof(typeof(kseq), gcmp)); | |
756 | ||
9352c19f JB |
757 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE && |
758 | !(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { | |
759 | drv_get_key_seq(sdata->local, key, &kseq); | |
db388a56 | 760 | memcpy(seq, kseq.ccmp.pn, 6); |
9352c19f | 761 | } else { |
db388a56 | 762 | pn64 = atomic64_read(&key->conf.tx_pn); |
9352c19f JB |
763 | seq[0] = pn64; |
764 | seq[1] = pn64 >> 8; | |
765 | seq[2] = pn64 >> 16; | |
766 | seq[3] = pn64 >> 24; | |
767 | seq[4] = pn64 >> 32; | |
768 | seq[5] = pn64 >> 40; | |
769 | } | |
00b9cfa3 JM |
770 | params.seq = seq; |
771 | params.seq_len = 6; | |
772 | break; | |
a31cf1c6 JB |
773 | default: |
774 | if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) | |
775 | break; | |
776 | if (WARN_ON(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) | |
777 | break; | |
778 | drv_get_key_seq(sdata->local, key, &kseq); | |
779 | params.seq = kseq.hw.seq; | |
780 | params.seq_len = kseq.hw.seq_len; | |
781 | break; | |
62da92fb JB |
782 | } |
783 | ||
62da92fb JB |
784 | callback(cookie, ¶ms); |
785 | err = 0; | |
786 | ||
787 | out: | |
3b96766f | 788 | rcu_read_unlock(); |
62da92fb JB |
789 | return err; |
790 | } | |
791 | ||
e8cbb4cb JB |
792 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
793 | struct net_device *dev, | |
e7a7b84e | 794 | int link_id, u8 key_idx, bool uni, |
dbd2fd65 | 795 | bool multi) |
e8cbb4cb | 796 | { |
ad0e2b5a | 797 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
ccdde7c7 JB |
798 | struct ieee80211_link_data *link = |
799 | ieee80211_link_or_deflink(sdata, link_id, false); | |
3b96766f | 800 | |
ccdde7c7 JB |
801 | if (IS_ERR(link)) |
802 | return PTR_ERR(link); | |
803 | ||
804 | ieee80211_set_default_key(link, key_idx, uni, multi); | |
e8cbb4cb JB |
805 | |
806 | return 0; | |
807 | } | |
808 | ||
3cfcf6ac JM |
809 | static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, |
810 | struct net_device *dev, | |
e7a7b84e | 811 | int link_id, u8 key_idx) |
3cfcf6ac | 812 | { |
66c52421 | 813 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
ccdde7c7 JB |
814 | struct ieee80211_link_data *link = |
815 | ieee80211_link_or_deflink(sdata, link_id, true); | |
3cfcf6ac | 816 | |
ccdde7c7 JB |
817 | if (IS_ERR(link)) |
818 | return PTR_ERR(link); | |
819 | ||
820 | ieee80211_set_default_mgmt_key(link, key_idx); | |
3cfcf6ac | 821 | |
3cfcf6ac JM |
822 | return 0; |
823 | } | |
824 | ||
e5473e80 JM |
825 | static int ieee80211_config_default_beacon_key(struct wiphy *wiphy, |
826 | struct net_device *dev, | |
e7a7b84e | 827 | int link_id, u8 key_idx) |
e5473e80 JM |
828 | { |
829 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
ccdde7c7 JB |
830 | struct ieee80211_link_data *link = |
831 | ieee80211_link_or_deflink(sdata, link_id, true); | |
832 | ||
833 | if (IS_ERR(link)) | |
834 | return PTR_ERR(link); | |
e5473e80 | 835 | |
ccdde7c7 | 836 | ieee80211_set_default_beacon_key(link, key_idx); |
e5473e80 JM |
837 | |
838 | return 0; | |
839 | } | |
840 | ||
6b62bf32 TP |
841 | void sta_set_rate_info_tx(struct sta_info *sta, |
842 | const struct ieee80211_tx_rate *rate, | |
843 | struct rate_info *rinfo) | |
844 | { | |
845 | rinfo->flags = 0; | |
8bc83c24 | 846 | if (rate->flags & IEEE80211_TX_RC_MCS) { |
6b62bf32 | 847 | rinfo->flags |= RATE_INFO_FLAGS_MCS; |
8bc83c24 JB |
848 | rinfo->mcs = rate->idx; |
849 | } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { | |
850 | rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; | |
851 | rinfo->mcs = ieee80211_rate_get_vht_mcs(rate); | |
852 | rinfo->nss = ieee80211_rate_get_vht_nss(rate); | |
853 | } else { | |
854 | struct ieee80211_supported_band *sband; | |
2103dec1 | 855 | |
21a8e9dd | 856 | sband = ieee80211_get_sband(sta->sdata); |
8b783d10 | 857 | WARN_ON_ONCE(sband && !sband->bitrates); |
2400dfe2 JB |
858 | if (sband && sband->bitrates) |
859 | rinfo->legacy = sband->bitrates[rate->idx].bitrate; | |
8bc83c24 | 860 | } |
6b62bf32 | 861 | if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
b51f3bee JB |
862 | rinfo->bw = RATE_INFO_BW_40; |
863 | else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) | |
864 | rinfo->bw = RATE_INFO_BW_80; | |
865 | else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) | |
866 | rinfo->bw = RATE_INFO_BW_160; | |
867 | else | |
868 | rinfo->bw = RATE_INFO_BW_20; | |
6b62bf32 TP |
869 | if (rate->flags & IEEE80211_TX_RC_SHORT_GI) |
870 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; | |
6b62bf32 TP |
871 | } |
872 | ||
c5dd9c2b | 873 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
3b3a0162 | 874 | int idx, u8 *mac, struct station_info *sinfo) |
c5dd9c2b | 875 | { |
3b53fde8 | 876 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
66572cfc | 877 | struct ieee80211_local *local = sdata->local; |
c5dd9c2b | 878 | struct sta_info *sta; |
d0709a65 JB |
879 | int ret = -ENOENT; |
880 | ||
4d3acf43 | 881 | lockdep_assert_wiphy(local->hw.wiphy); |
c5dd9c2b | 882 | |
3b53fde8 | 883 | sta = sta_info_get_by_idx(sdata, idx); |
d0709a65 JB |
884 | if (sta) { |
885 | ret = 0; | |
17741cdc | 886 | memcpy(mac, sta->sta.addr, ETH_ALEN); |
0fdf1493 | 887 | sta_set_sinfo(sta, sinfo, true); |
d0709a65 | 888 | } |
c5dd9c2b | 889 | |
d0709a65 | 890 | return ret; |
c5dd9c2b LCC |
891 | } |
892 | ||
1289723e HS |
893 | static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, |
894 | int idx, struct survey_info *survey) | |
895 | { | |
896 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
897 | ||
1289723e HS |
898 | return drv_get_survey(local, idx, survey); |
899 | } | |
900 | ||
7bbdd2d9 | 901 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
3b3a0162 | 902 | const u8 *mac, struct station_info *sinfo) |
7bbdd2d9 | 903 | { |
abe60632 | 904 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
66572cfc | 905 | struct ieee80211_local *local = sdata->local; |
7bbdd2d9 | 906 | struct sta_info *sta; |
d0709a65 | 907 | int ret = -ENOENT; |
7bbdd2d9 | 908 | |
4d3acf43 | 909 | lockdep_assert_wiphy(local->hw.wiphy); |
7bbdd2d9 | 910 | |
0e5ded5a | 911 | sta = sta_info_get_bss(sdata, mac); |
d0709a65 JB |
912 | if (sta) { |
913 | ret = 0; | |
0fdf1493 | 914 | sta_set_sinfo(sta, sinfo, true); |
d0709a65 JB |
915 | } |
916 | ||
d0709a65 | 917 | return ret; |
7bbdd2d9 JB |
918 | } |
919 | ||
55de908a | 920 | static int ieee80211_set_monitor_channel(struct wiphy *wiphy, |
9c4f8309 | 921 | struct net_device *dev, |
683b6d3b | 922 | struct cfg80211_chan_def *chandef) |
3d9e6e12 JB |
923 | { |
924 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
55de908a | 925 | struct ieee80211_sub_if_data *sdata; |
6092077a | 926 | struct ieee80211_chan_req chanreq = { .oper = *chandef }; |
0a44dfc0 | 927 | int ret; |
3d9e6e12 | 928 | |
0cd8080e JB |
929 | lockdep_assert_wiphy(local->hw.wiphy); |
930 | ||
9d40f7e3 FF |
931 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
932 | if (!ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) { | |
933 | if (cfg80211_chandef_identical(&local->monitor_chanreq.oper, | |
892726f0 | 934 | &chanreq.oper)) |
9d40f7e3 | 935 | return 0; |
3d9e6e12 | 936 | |
9d40f7e3 FF |
937 | sdata = wiphy_dereference(wiphy, local->monitor_sdata); |
938 | if (!sdata) | |
939 | goto done; | |
940 | } | |
3d9e6e12 | 941 | |
9d40f7e3 | 942 | if (rcu_access_pointer(sdata->deflink.conf->chanctx_conf) && |
892726f0 | 943 | cfg80211_chandef_identical(&sdata->vif.bss_conf.chanreq.oper, |
6092077a | 944 | &chanreq.oper)) |
0a44dfc0 | 945 | return 0; |
3d9e6e12 | 946 | |
0a44dfc0 | 947 | ieee80211_link_release_channel(&sdata->deflink); |
6092077a | 948 | ret = ieee80211_link_use_channel(&sdata->deflink, &chanreq, |
9d40f7e3 | 949 | IEEE80211_CHANCTX_SHARED); |
0a44dfc0 JB |
950 | if (ret) |
951 | return ret; | |
952 | done: | |
6092077a | 953 | local->monitor_chanreq = chanreq; |
0a44dfc0 | 954 | return 0; |
e8c9bd5b JB |
955 | } |
956 | ||
5f9404ab JC |
957 | static int |
958 | ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, | |
959 | const u8 *resp, size_t resp_len, | |
960 | const struct ieee80211_csa_settings *csa, | |
d9f83f22 ST |
961 | const struct ieee80211_color_change_settings *cca, |
962 | struct ieee80211_link_data *link) | |
02945821 | 963 | { |
aa7a0080 | 964 | struct probe_resp *new, *old; |
02945821 AN |
965 | |
966 | if (!resp || !resp_len) | |
aba4e6ff | 967 | return 1; |
02945821 | 968 | |
d9f83f22 | 969 | old = sdata_dereference(link->u.ap.probe_resp, sdata); |
02945821 | 970 | |
aa7a0080 | 971 | new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL); |
02945821 AN |
972 | if (!new) |
973 | return -ENOMEM; | |
974 | ||
aa7a0080 ES |
975 | new->len = resp_len; |
976 | memcpy(new->data, resp, resp_len); | |
02945821 | 977 | |
af296bdb | 978 | if (csa) |
8552a434 | 979 | memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_presp, |
af296bdb | 980 | csa->n_counter_offsets_presp * |
8552a434 | 981 | sizeof(new->cntdwn_counter_offsets[0])); |
5f9404ab JC |
982 | else if (cca) |
983 | new->cntdwn_counter_offsets[0] = cca->counter_offset_presp; | |
af296bdb | 984 | |
d9f83f22 | 985 | rcu_assign_pointer(link->u.ap.probe_resp, new); |
aa7a0080 ES |
986 | if (old) |
987 | kfree_rcu(old, rcu_head); | |
02945821 AN |
988 | |
989 | return 0; | |
990 | } | |
991 | ||
295b02c4 | 992 | static int ieee80211_set_fils_discovery(struct ieee80211_sub_if_data *sdata, |
d9f83f22 ST |
993 | struct cfg80211_fils_discovery *params, |
994 | struct ieee80211_link_data *link, | |
392d3dfd JB |
995 | struct ieee80211_bss_conf *link_conf, |
996 | u64 *changed) | |
295b02c4 AD |
997 | { |
998 | struct fils_discovery_data *new, *old = NULL; | |
999 | struct ieee80211_fils_discovery *fd; | |
1000 | ||
3b1c256e AD |
1001 | if (!params->update) |
1002 | return 0; | |
295b02c4 | 1003 | |
d9f83f22 | 1004 | fd = &link_conf->fils_discovery; |
295b02c4 AD |
1005 | fd->min_interval = params->min_interval; |
1006 | fd->max_interval = params->max_interval; | |
1007 | ||
d9f83f22 | 1008 | old = sdata_dereference(link->u.ap.fils_discovery, sdata); |
295b02c4 AD |
1009 | if (old) |
1010 | kfree_rcu(old, rcu_head); | |
1011 | ||
3b1c256e AD |
1012 | if (params->tmpl && params->tmpl_len) { |
1013 | new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL); | |
1014 | if (!new) | |
1015 | return -ENOMEM; | |
1016 | new->len = params->tmpl_len; | |
1017 | memcpy(new->data, params->tmpl, params->tmpl_len); | |
1018 | rcu_assign_pointer(link->u.ap.fils_discovery, new); | |
1019 | } else { | |
1020 | RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL); | |
1021 | } | |
1022 | ||
392d3dfd JB |
1023 | *changed |= BSS_CHANGED_FILS_DISCOVERY; |
1024 | return 0; | |
295b02c4 AD |
1025 | } |
1026 | ||
632189a0 AD |
1027 | static int |
1028 | ieee80211_set_unsol_bcast_probe_resp(struct ieee80211_sub_if_data *sdata, | |
d9f83f22 ST |
1029 | struct cfg80211_unsol_bcast_probe_resp *params, |
1030 | struct ieee80211_link_data *link, | |
178e9d6a JB |
1031 | struct ieee80211_bss_conf *link_conf, |
1032 | u64 *changed) | |
632189a0 AD |
1033 | { |
1034 | struct unsol_bcast_probe_resp_data *new, *old = NULL; | |
1035 | ||
3b1c256e AD |
1036 | if (!params->update) |
1037 | return 0; | |
632189a0 | 1038 | |
3b1c256e | 1039 | link_conf->unsol_bcast_probe_resp_interval = params->interval; |
632189a0 | 1040 | |
3b1c256e | 1041 | old = sdata_dereference(link->u.ap.unsol_bcast_probe_resp, sdata); |
632189a0 AD |
1042 | if (old) |
1043 | kfree_rcu(old, rcu_head); | |
1044 | ||
3b1c256e AD |
1045 | if (params->tmpl && params->tmpl_len) { |
1046 | new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL); | |
1047 | if (!new) | |
1048 | return -ENOMEM; | |
1049 | new->len = params->tmpl_len; | |
1050 | memcpy(new->data, params->tmpl, params->tmpl_len); | |
1051 | rcu_assign_pointer(link->u.ap.unsol_bcast_probe_resp, new); | |
1052 | } else { | |
1053 | RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL); | |
1054 | } | |
632189a0 | 1055 | |
178e9d6a JB |
1056 | *changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP; |
1057 | return 0; | |
632189a0 AD |
1058 | } |
1059 | ||
bc847970 PKC |
1060 | static int ieee80211_set_ftm_responder_params( |
1061 | struct ieee80211_sub_if_data *sdata, | |
1062 | const u8 *lci, size_t lci_len, | |
d9f83f22 ST |
1063 | const u8 *civicloc, size_t civicloc_len, |
1064 | struct ieee80211_bss_conf *link_conf) | |
bc847970 PKC |
1065 | { |
1066 | struct ieee80211_ftm_responder_params *new, *old; | |
bc847970 PKC |
1067 | u8 *pos; |
1068 | int len; | |
1069 | ||
554be833 JB |
1070 | if (!lci_len && !civicloc_len) |
1071 | return 0; | |
bc847970 | 1072 | |
d9f83f22 | 1073 | old = link_conf->ftmr_params; |
bc847970 PKC |
1074 | len = lci_len + civicloc_len; |
1075 | ||
1076 | new = kzalloc(sizeof(*new) + len, GFP_KERNEL); | |
1077 | if (!new) | |
1078 | return -ENOMEM; | |
1079 | ||
1080 | pos = (u8 *)(new + 1); | |
1081 | if (lci_len) { | |
1082 | new->lci_len = lci_len; | |
1083 | new->lci = pos; | |
1084 | memcpy(pos, lci, lci_len); | |
1085 | pos += lci_len; | |
1086 | } | |
1087 | ||
1088 | if (civicloc_len) { | |
1089 | new->civicloc_len = civicloc_len; | |
1090 | new->civicloc = pos; | |
1091 | memcpy(pos, civicloc, civicloc_len); | |
1092 | pos += civicloc_len; | |
1093 | } | |
1094 | ||
d9f83f22 | 1095 | link_conf->ftmr_params = new; |
bc847970 PKC |
1096 | kfree(old); |
1097 | ||
1098 | return 0; | |
1099 | } | |
1100 | ||
2b3171c6 LB |
1101 | static int |
1102 | ieee80211_copy_mbssid_beacon(u8 *pos, struct cfg80211_mbssid_elems *dst, | |
1103 | struct cfg80211_mbssid_elems *src) | |
1104 | { | |
1105 | int i, offset = 0; | |
1106 | ||
496db69f | 1107 | dst->cnt = src->cnt; |
2b3171c6 LB |
1108 | for (i = 0; i < src->cnt; i++) { |
1109 | memcpy(pos + offset, src->elem[i].data, src->elem[i].len); | |
1110 | dst->elem[i].len = src->elem[i].len; | |
1111 | dst->elem[i].data = pos + offset; | |
1112 | offset += dst->elem[i].len; | |
1113 | } | |
2b3171c6 LB |
1114 | |
1115 | return offset; | |
1116 | } | |
1117 | ||
68b9bea2 AD |
1118 | static int |
1119 | ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst, | |
1120 | struct cfg80211_rnr_elems *src) | |
1121 | { | |
1122 | int i, offset = 0; | |
1123 | ||
1124 | for (i = 0; i < src->cnt; i++) { | |
1125 | memcpy(pos + offset, src->elem[i].data, src->elem[i].len); | |
1126 | dst->elem[i].len = src->elem[i].len; | |
1127 | dst->elem[i].data = pos + offset; | |
1128 | offset += dst->elem[i].len; | |
1129 | } | |
1130 | dst->cnt = src->cnt; | |
1131 | ||
1132 | return offset; | |
1133 | } | |
1134 | ||
15ddba5f A |
1135 | static int |
1136 | ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, | |
1137 | struct ieee80211_link_data *link, | |
1138 | struct cfg80211_beacon_data *params, | |
1139 | const struct ieee80211_csa_settings *csa, | |
1140 | const struct ieee80211_color_change_settings *cca, | |
1141 | u64 *changed) | |
5dfdaf58 | 1142 | { |
2b3171c6 | 1143 | struct cfg80211_mbssid_elems *mbssid = NULL; |
68b9bea2 | 1144 | struct cfg80211_rnr_elems *rnr = NULL; |
5dfdaf58 JB |
1145 | struct beacon_data *new, *old; |
1146 | int new_head_len, new_tail_len; | |
8860020e | 1147 | int size, err; |
15ddba5f | 1148 | u64 _changed = BSS_CHANGED_BEACON; |
d8675a63 | 1149 | struct ieee80211_bss_conf *link_conf = link->conf; |
5dfdaf58 | 1150 | |
d9f83f22 | 1151 | old = sdata_dereference(link->u.ap.beacon, sdata); |
5dfdaf58 | 1152 | |
5dfdaf58 JB |
1153 | /* Need to have a beacon head if we don't have one yet */ |
1154 | if (!params->head && !old) | |
8860020e | 1155 | return -EINVAL; |
5dfdaf58 JB |
1156 | |
1157 | /* new or old head? */ | |
1158 | if (params->head) | |
1159 | new_head_len = params->head_len; | |
1160 | else | |
1161 | new_head_len = old->head_len; | |
1162 | ||
1163 | /* new or old tail? */ | |
1164 | if (params->tail || !old) | |
1165 | /* params->tail_len will be zero for !params->tail */ | |
1166 | new_tail_len = params->tail_len; | |
1167 | else | |
1168 | new_tail_len = old->tail_len; | |
1169 | ||
1170 | size = sizeof(*new) + new_head_len + new_tail_len; | |
1171 | ||
2b3171c6 LB |
1172 | /* new or old multiple BSSID elements? */ |
1173 | if (params->mbssid_ies) { | |
1174 | mbssid = params->mbssid_ies; | |
1175 | size += struct_size(new->mbssid_ies, elem, mbssid->cnt); | |
68b9bea2 AD |
1176 | if (params->rnr_ies) { |
1177 | rnr = params->rnr_ies; | |
1178 | size += struct_size(new->rnr_ies, elem, rnr->cnt); | |
1179 | } | |
1180 | size += ieee80211_get_mbssid_beacon_len(mbssid, rnr, | |
1181 | mbssid->cnt); | |
2b3171c6 LB |
1182 | } else if (old && old->mbssid_ies) { |
1183 | mbssid = old->mbssid_ies; | |
1184 | size += struct_size(new->mbssid_ies, elem, mbssid->cnt); | |
68b9bea2 AD |
1185 | if (old && old->rnr_ies) { |
1186 | rnr = old->rnr_ies; | |
1187 | size += struct_size(new->rnr_ies, elem, rnr->cnt); | |
1188 | } | |
1189 | size += ieee80211_get_mbssid_beacon_len(mbssid, rnr, | |
1190 | mbssid->cnt); | |
2b3171c6 LB |
1191 | } |
1192 | ||
5dfdaf58 JB |
1193 | new = kzalloc(size, GFP_KERNEL); |
1194 | if (!new) | |
1195 | return -ENOMEM; | |
1196 | ||
1197 | /* start filling the new info now */ | |
1198 | ||
5dfdaf58 JB |
1199 | /* |
1200 | * pointers go into the block we allocated, | |
68b9bea2 | 1201 | * memory is | beacon_data | head | tail | mbssid_ies | rnr_ies |
5dfdaf58 JB |
1202 | */ |
1203 | new->head = ((u8 *) new) + sizeof(*new); | |
1204 | new->tail = new->head + new_head_len; | |
1205 | new->head_len = new_head_len; | |
1206 | new->tail_len = new_tail_len; | |
2b3171c6 LB |
1207 | /* copy in optional mbssid_ies */ |
1208 | if (mbssid) { | |
1209 | u8 *pos = new->tail + new->tail_len; | |
1210 | ||
1211 | new->mbssid_ies = (void *)pos; | |
1212 | pos += struct_size(new->mbssid_ies, elem, mbssid->cnt); | |
68b9bea2 AD |
1213 | pos += ieee80211_copy_mbssid_beacon(pos, new->mbssid_ies, |
1214 | mbssid); | |
1215 | if (rnr) { | |
1216 | new->rnr_ies = (void *)pos; | |
1217 | pos += struct_size(new->rnr_ies, elem, rnr->cnt); | |
1218 | ieee80211_copy_rnr_beacon(pos, new->rnr_ies, rnr); | |
1219 | } | |
dde78aa5 | 1220 | /* update bssid_indicator */ |
d9f83f22 | 1221 | link_conf->bssid_indicator = |
dde78aa5 | 1222 | ilog2(__roundup_pow_of_two(mbssid->cnt + 1)); |
2b3171c6 | 1223 | } |
5dfdaf58 | 1224 | |
af296bdb | 1225 | if (csa) { |
8552a434 JC |
1226 | new->cntdwn_current_counter = csa->count; |
1227 | memcpy(new->cntdwn_counter_offsets, csa->counter_offsets_beacon, | |
af296bdb | 1228 | csa->n_counter_offsets_beacon * |
8552a434 | 1229 | sizeof(new->cntdwn_counter_offsets[0])); |
5f9404ab JC |
1230 | } else if (cca) { |
1231 | new->cntdwn_current_counter = cca->count; | |
1232 | new->cntdwn_counter_offsets[0] = cca->counter_offset_beacon; | |
af296bdb MK |
1233 | } |
1234 | ||
5dfdaf58 JB |
1235 | /* copy in head */ |
1236 | if (params->head) | |
1237 | memcpy(new->head, params->head, new_head_len); | |
1238 | else | |
1239 | memcpy(new->head, old->head, new_head_len); | |
1240 | ||
1241 | /* copy in optional tail */ | |
1242 | if (params->tail) | |
1243 | memcpy(new->tail, params->tail, new_tail_len); | |
1244 | else | |
1245 | if (old) | |
1246 | memcpy(new->tail, old->tail, new_tail_len); | |
1247 | ||
02945821 | 1248 | err = ieee80211_set_probe_resp(sdata, params->probe_resp, |
d9f83f22 | 1249 | params->probe_resp_len, csa, cca, link); |
bcc27fab LB |
1250 | if (err < 0) { |
1251 | kfree(new); | |
8860020e | 1252 | return err; |
bcc27fab | 1253 | } |
8860020e | 1254 | if (err == 0) |
15ddba5f | 1255 | _changed |= BSS_CHANGED_AP_PROBE_RESP; |
02945821 | 1256 | |
bc847970 | 1257 | if (params->ftm_responder != -1) { |
d9f83f22 | 1258 | link_conf->ftm_responder = params->ftm_responder; |
bc847970 PKC |
1259 | err = ieee80211_set_ftm_responder_params(sdata, |
1260 | params->lci, | |
1261 | params->lci_len, | |
1262 | params->civicloc, | |
d9f83f22 ST |
1263 | params->civicloc_len, |
1264 | link_conf); | |
bc847970 | 1265 | |
bcc27fab LB |
1266 | if (err < 0) { |
1267 | kfree(new); | |
bc847970 | 1268 | return err; |
bcc27fab | 1269 | } |
bc847970 | 1270 | |
15ddba5f | 1271 | _changed |= BSS_CHANGED_FTM_RESPONDER; |
bc847970 PKC |
1272 | } |
1273 | ||
d9f83f22 | 1274 | rcu_assign_pointer(link->u.ap.beacon, new); |
bfd8403a | 1275 | sdata->u.ap.active = true; |
8860020e JB |
1276 | |
1277 | if (old) | |
1278 | kfree_rcu(old, rcu_head); | |
7827493b | 1279 | |
15ddba5f A |
1280 | *changed |= _changed; |
1281 | return 0; | |
5dfdaf58 JB |
1282 | } |
1283 | ||
5fcc7c51 AKS |
1284 | static u8 ieee80211_num_beaconing_links(struct ieee80211_sub_if_data *sdata) |
1285 | { | |
1286 | struct ieee80211_link_data *link; | |
1287 | u8 link_id, num = 0; | |
1288 | ||
1289 | if (sdata->vif.type != NL80211_IFTYPE_AP && | |
1290 | sdata->vif.type != NL80211_IFTYPE_P2P_GO) | |
1291 | return num; | |
1292 | ||
68b44b05 AKS |
1293 | /* non-MLO mode of operation also uses link_id 0 in sdata so it is |
1294 | * safe to directly proceed with the below loop | |
1295 | */ | |
5fcc7c51 AKS |
1296 | for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { |
1297 | link = sdata_dereference(sdata->link[link_id], sdata); | |
1298 | if (!link) | |
1299 | continue; | |
1300 | ||
1301 | if (sdata_dereference(link->u.ap.beacon, sdata)) | |
1302 | num++; | |
1303 | } | |
1304 | ||
1305 | return num; | |
1306 | } | |
1307 | ||
8860020e JB |
1308 | static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, |
1309 | struct cfg80211_ap_settings *params) | |
5dfdaf58 | 1310 | { |
8860020e | 1311 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
34a3740d | 1312 | struct ieee80211_local *local = sdata->local; |
5dfdaf58 | 1313 | struct beacon_data *old; |
665c93a9 | 1314 | struct ieee80211_sub_if_data *vlan; |
2cc25e4b | 1315 | u64 changed = BSS_CHANGED_BEACON_INT | |
8860020e JB |
1316 | BSS_CHANGED_BEACON_ENABLED | |
1317 | BSS_CHANGED_BEACON | | |
4bcc56bb | 1318 | BSS_CHANGED_P2P_PS | |
a0de1ca3 | 1319 | BSS_CHANGED_TXPOWER | |
322cd27c | 1320 | BSS_CHANGED_TWT; |
08fad438 | 1321 | int i, err; |
83e37e0b | 1322 | int prev_beacon_int; |
d9f83f22 | 1323 | unsigned int link_id = params->beacon.link_id; |
d8675a63 JB |
1324 | struct ieee80211_link_data *link; |
1325 | struct ieee80211_bss_conf *link_conf; | |
6092077a | 1326 | struct ieee80211_chan_req chanreq = { .oper = params->chandef }; |
d8675a63 | 1327 | |
0cd8080e JB |
1328 | lockdep_assert_wiphy(local->hw.wiphy); |
1329 | ||
d8675a63 JB |
1330 | link = sdata_dereference(sdata->link[link_id], sdata); |
1331 | if (!link) | |
1332 | return -ENOLINK; | |
1333 | ||
1334 | link_conf = link->conf; | |
14db74bc | 1335 | |
d9f83f22 | 1336 | old = sdata_dereference(link->u.ap.beacon, sdata); |
5dfdaf58 JB |
1337 | if (old) |
1338 | return -EALREADY; | |
1339 | ||
d9f83f22 | 1340 | link->smps_mode = IEEE80211_SMPS_OFF; |
b3dd8279 | 1341 | |
d9f83f22 | 1342 | link->needed_rx_chains = sdata->local->rx_chains; |
04ecd257 | 1343 | |
d9f83f22 ST |
1344 | prev_beacon_int = link_conf->beacon_int; |
1345 | link_conf->beacon_int = params->beacon_interval; | |
ac668afe | 1346 | |
2ad7dd94 RL |
1347 | if (params->ht_cap) |
1348 | link_conf->ht_ldpc = | |
1349 | params->ht_cap->cap_info & | |
1350 | cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING); | |
1351 | ||
42470fa0 | 1352 | if (params->vht_cap) { |
2ad7dd94 RL |
1353 | link_conf->vht_ldpc = |
1354 | params->vht_cap->vht_cap_info & | |
1355 | cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC); | |
42470fa0 MS |
1356 | link_conf->vht_su_beamformer = |
1357 | params->vht_cap->vht_cap_info & | |
1358 | cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE); | |
1359 | link_conf->vht_su_beamformee = | |
1360 | params->vht_cap->vht_cap_info & | |
1361 | cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE); | |
1362 | link_conf->vht_mu_beamformer = | |
1363 | params->vht_cap->vht_cap_info & | |
1364 | cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE); | |
1365 | link_conf->vht_mu_beamformee = | |
1366 | params->vht_cap->vht_cap_info & | |
1367 | cpu_to_le32(IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE); | |
1368 | } | |
1369 | ||
03efb863 | 1370 | if (params->he_cap && params->he_oper) { |
d9f83f22 ST |
1371 | link_conf->he_support = true; |
1372 | link_conf->htc_trig_based_pkt_ext = | |
03efb863 ST |
1373 | le32_get_bits(params->he_oper->he_oper_params, |
1374 | IEEE80211_HE_OPERATION_DFLT_PE_DURATION_MASK); | |
d9f83f22 | 1375 | link_conf->frame_time_rts_th = |
03efb863 ST |
1376 | le32_get_bits(params->he_oper->he_oper_params, |
1377 | IEEE80211_HE_OPERATION_RTS_THRESHOLD_MASK); | |
322cd27c P |
1378 | changed |= BSS_CHANGED_HE_OBSS_PD; |
1379 | ||
3d48cb74 | 1380 | if (params->beacon.he_bss_color.enabled) |
322cd27c | 1381 | changed |= BSS_CHANGED_HE_BSS_COLOR; |
03efb863 | 1382 | } |
34fb190e | 1383 | |
b1b3297d | 1384 | if (params->he_cap) { |
2ad7dd94 RL |
1385 | link_conf->he_ldpc = |
1386 | params->he_cap->phy_cap_info[1] & | |
1387 | IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD; | |
b1b3297d MS |
1388 | link_conf->he_su_beamformer = |
1389 | params->he_cap->phy_cap_info[3] & | |
1390 | IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER; | |
1391 | link_conf->he_su_beamformee = | |
1392 | params->he_cap->phy_cap_info[4] & | |
1393 | IEEE80211_HE_PHY_CAP4_SU_BEAMFORMEE; | |
1394 | link_conf->he_mu_beamformer = | |
1395 | params->he_cap->phy_cap_info[4] & | |
1396 | IEEE80211_HE_PHY_CAP4_MU_BEAMFORMER; | |
1397 | link_conf->he_full_ul_mumimo = | |
1398 | params->he_cap->phy_cap_info[2] & | |
1399 | IEEE80211_HE_PHY_CAP2_UL_MU_FULL_MU_MIMO; | |
1400 | } | |
1401 | ||
2cc25e4b | 1402 | if (params->eht_cap) { |
e3e0ca32 AD |
1403 | if (!link_conf->he_support) |
1404 | return -EOPNOTSUPP; | |
1405 | ||
1406 | link_conf->eht_support = true; | |
f4d1181e RL |
1407 | |
1408 | link_conf->eht_su_beamformer = | |
1409 | params->eht_cap->fixed.phy_cap_info[0] & | |
1410 | IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER; | |
1411 | link_conf->eht_su_beamformee = | |
1412 | params->eht_cap->fixed.phy_cap_info[0] & | |
1413 | IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE; | |
1414 | link_conf->eht_mu_beamformer = | |
1415 | params->eht_cap->fixed.phy_cap_info[7] & | |
1416 | (IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ | | |
1417 | IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ | | |
1418 | IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ); | |
f9a0757a PKC |
1419 | link_conf->eht_80mhz_full_bw_ul_mumimo = |
1420 | params->eht_cap->fixed.phy_cap_info[7] & | |
1421 | (IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ | | |
1422 | IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ | | |
1423 | IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_320MHZ); | |
22c64f37 MK |
1424 | link_conf->eht_disable_mcs15 = |
1425 | u8_get_bits(params->eht_oper->params, | |
1426 | IEEE80211_EHT_OPER_MCS15_DISABLE); | |
f4d1181e RL |
1427 | } else { |
1428 | link_conf->eht_su_beamformer = false; | |
1429 | link_conf->eht_su_beamformee = false; | |
1430 | link_conf->eht_mu_beamformer = false; | |
2cc25e4b AD |
1431 | } |
1432 | ||
17196425 JC |
1433 | if (sdata->vif.type == NL80211_IFTYPE_AP && |
1434 | params->mbssid_config.tx_wdev) { | |
1435 | err = ieee80211_set_ap_mbssid_options(sdata, | |
f2aadc72 | 1436 | ¶ms->mbssid_config, |
d9f83f22 | 1437 | link_conf); |
17196425 JC |
1438 | if (err) |
1439 | return err; | |
1440 | } | |
1441 | ||
6092077a | 1442 | err = ieee80211_link_use_channel(link, &chanreq, |
b4f85443 | 1443 | IEEE80211_CHANCTX_SHARED); |
4e141dad | 1444 | if (!err) |
d9f83f22 | 1445 | ieee80211_link_copy_chanctx_to_vlans(link, false); |
83e37e0b | 1446 | if (err) { |
d9f83f22 | 1447 | link_conf->beacon_int = prev_beacon_int; |
aa430da4 | 1448 | return err; |
83e37e0b | 1449 | } |
aa430da4 | 1450 | |
665c93a9 JB |
1451 | /* |
1452 | * Apply control port protocol, this allows us to | |
1453 | * not encrypt dynamic WEP control frames. | |
1454 | */ | |
1455 | sdata->control_port_protocol = params->crypto.control_port_ethertype; | |
1456 | sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt; | |
018f6fbf DK |
1457 | sdata->control_port_over_nl80211 = |
1458 | params->crypto.control_port_over_nl80211; | |
7f3f96ce MT |
1459 | sdata->control_port_no_preauth = |
1460 | params->crypto.control_port_no_preauth; | |
2475b1cc | 1461 | |
665c93a9 JB |
1462 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { |
1463 | vlan->control_port_protocol = | |
1464 | params->crypto.control_port_ethertype; | |
1465 | vlan->control_port_no_encrypt = | |
1466 | params->crypto.control_port_no_encrypt; | |
018f6fbf DK |
1467 | vlan->control_port_over_nl80211 = |
1468 | params->crypto.control_port_over_nl80211; | |
7f3f96ce MT |
1469 | vlan->control_port_no_preauth = |
1470 | params->crypto.control_port_no_preauth; | |
665c93a9 JB |
1471 | } |
1472 | ||
d9f83f22 ST |
1473 | link_conf->dtim_period = params->dtim_period; |
1474 | link_conf->enable_beacon = true; | |
1475 | link_conf->allow_p2p_go_ps = sdata->vif.p2p; | |
1476 | link_conf->twt_responder = params->twt_responder; | |
1477 | link_conf->he_obss_pd = params->he_obss_pd; | |
1478 | link_conf->he_bss_color = params->beacon.he_bss_color; | |
f276e20b | 1479 | sdata->vif.cfg.s1g = params->chandef.chan->band == |
1d00ce80 | 1480 | NL80211_BAND_S1GHZ; |
8860020e | 1481 | |
f276e20b | 1482 | sdata->vif.cfg.ssid_len = params->ssid_len; |
8860020e | 1483 | if (params->ssid_len) |
f276e20b | 1484 | memcpy(sdata->vif.cfg.ssid, params->ssid, |
8860020e | 1485 | params->ssid_len); |
d9f83f22 | 1486 | link_conf->hidden_ssid = |
8860020e JB |
1487 | (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); |
1488 | ||
d9f83f22 ST |
1489 | memset(&link_conf->p2p_noa_attr, 0, |
1490 | sizeof(link_conf->p2p_noa_attr)); | |
1491 | link_conf->p2p_noa_attr.oppps_ctwindow = | |
67baf663 JD |
1492 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; |
1493 | if (params->p2p_opp_ps) | |
d9f83f22 | 1494 | link_conf->p2p_noa_attr.oppps_ctwindow |= |
67baf663 | 1495 | IEEE80211_P2P_OPPPS_ENABLE_BIT; |
339afbf4 | 1496 | |
08fad438 JM |
1497 | sdata->beacon_rate_set = false; |
1498 | if (wiphy_ext_feature_isset(local->hw.wiphy, | |
1499 | NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) { | |
1500 | for (i = 0; i < NUM_NL80211_BANDS; i++) { | |
1501 | sdata->beacon_rateidx_mask[i] = | |
1502 | params->beacon_rate.control[i].legacy; | |
1503 | if (sdata->beacon_rateidx_mask[i]) | |
1504 | sdata->beacon_rate_set = true; | |
1505 | } | |
1506 | } | |
1507 | ||
ba6ff70a | 1508 | if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) |
d9f83f22 | 1509 | link_conf->beacon_tx_rate = params->beacon_rate; |
ba6ff70a | 1510 | |
15ddba5f A |
1511 | err = ieee80211_assign_beacon(sdata, link, ¶ms->beacon, NULL, NULL, |
1512 | &changed); | |
295b02c4 AD |
1513 | if (err < 0) |
1514 | goto error; | |
8860020e | 1515 | |
3b1c256e | 1516 | err = ieee80211_set_fils_discovery(sdata, ¶ms->fils_discovery, |
392d3dfd | 1517 | link, link_conf, &changed); |
3b1c256e AD |
1518 | if (err < 0) |
1519 | goto error; | |
295b02c4 | 1520 | |
3b1c256e AD |
1521 | err = ieee80211_set_unsol_bcast_probe_resp(sdata, |
1522 | ¶ms->unsol_bcast_probe_resp, | |
178e9d6a | 1523 | link, link_conf, &changed); |
3b1c256e AD |
1524 | if (err < 0) |
1525 | goto error; | |
632189a0 | 1526 | |
b327c84c | 1527 | err = drv_start_ap(sdata->local, sdata, link_conf); |
1041638f | 1528 | if (err) { |
d9f83f22 | 1529 | old = sdata_dereference(link->u.ap.beacon, sdata); |
7ca133bc | 1530 | |
1041638f JB |
1531 | if (old) |
1532 | kfree_rcu(old, rcu_head); | |
d9f83f22 | 1533 | RCU_INIT_POINTER(link->u.ap.beacon, NULL); |
6d4ed5b3 AKS |
1534 | |
1535 | if (ieee80211_num_beaconing_links(sdata) == 0) | |
1536 | sdata->u.ap.active = false; | |
1537 | ||
295b02c4 | 1538 | goto error; |
1041638f JB |
1539 | } |
1540 | ||
057d5f4b | 1541 | ieee80211_recalc_dtim(local, sdata); |
d9f83f22 | 1542 | ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_SSID); |
d8675a63 | 1543 | ieee80211_link_info_change_notify(sdata, link, changed); |
8860020e | 1544 | |
5fcc7c51 AKS |
1545 | if (ieee80211_num_beaconing_links(sdata) <= 1) |
1546 | netif_carrier_on(dev); | |
1547 | ||
3edaf3e6 JB |
1548 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
1549 | netif_carrier_on(vlan->dev); | |
1550 | ||
665c93a9 | 1551 | return 0; |
295b02c4 AD |
1552 | |
1553 | error: | |
d9f83f22 | 1554 | ieee80211_link_release_channel(link); |
87a27062 | 1555 | |
295b02c4 | 1556 | return err; |
5dfdaf58 JB |
1557 | } |
1558 | ||
8860020e | 1559 | static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
bb55441c | 1560 | struct cfg80211_ap_update *params) |
66f85d57 | 1561 | |
5dfdaf58 | 1562 | { |
d9f83f22 | 1563 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
d8675a63 | 1564 | struct ieee80211_link_data *link; |
66f85d57 | 1565 | struct cfg80211_beacon_data *beacon = ¶ms->beacon; |
5dfdaf58 | 1566 | struct beacon_data *old; |
8860020e | 1567 | int err; |
d8675a63 | 1568 | struct ieee80211_bss_conf *link_conf; |
15ddba5f | 1569 | u64 changed = 0; |
5dfdaf58 | 1570 | |
076fc877 | 1571 | lockdep_assert_wiphy(wiphy); |
14db74bc | 1572 | |
66f85d57 | 1573 | link = sdata_dereference(sdata->link[beacon->link_id], sdata); |
d8675a63 JB |
1574 | if (!link) |
1575 | return -ENOLINK; | |
1576 | ||
1577 | link_conf = link->conf; | |
1578 | ||
5f9404ab | 1579 | /* don't allow changing the beacon while a countdown is in place - offset |
73da7d5b SW |
1580 | * of channel switch counter may change |
1581 | */ | |
d9f83f22 | 1582 | if (link_conf->csa_active || link_conf->color_change_active) |
73da7d5b SW |
1583 | return -EBUSY; |
1584 | ||
d8675a63 | 1585 | old = sdata_dereference(link->u.ap.beacon, sdata); |
5dfdaf58 JB |
1586 | if (!old) |
1587 | return -ENOENT; | |
1588 | ||
66f85d57 | 1589 | err = ieee80211_assign_beacon(sdata, link, beacon, NULL, NULL, |
15ddba5f | 1590 | &changed); |
8860020e JB |
1591 | if (err < 0) |
1592 | return err; | |
195b9a0f | 1593 | |
6bc5ddb2 | 1594 | err = ieee80211_set_fils_discovery(sdata, ¶ms->fils_discovery, |
392d3dfd | 1595 | link, link_conf, &changed); |
6bc5ddb2 AD |
1596 | if (err < 0) |
1597 | return err; | |
6bc5ddb2 AD |
1598 | |
1599 | err = ieee80211_set_unsol_bcast_probe_resp(sdata, | |
1600 | ¶ms->unsol_bcast_probe_resp, | |
178e9d6a | 1601 | link, link_conf, &changed); |
6bc5ddb2 AD |
1602 | if (err < 0) |
1603 | return err; | |
6bc5ddb2 | 1604 | |
66f85d57 AD |
1605 | if (beacon->he_bss_color_valid && |
1606 | beacon->he_bss_color.enabled != link_conf->he_bss_color.enabled) { | |
1607 | link_conf->he_bss_color.enabled = beacon->he_bss_color.enabled; | |
15ddba5f | 1608 | changed |= BSS_CHANGED_HE_BSS_COLOR; |
195b9a0f LS |
1609 | } |
1610 | ||
15ddba5f | 1611 | ieee80211_link_info_change_notify(sdata, link, changed); |
8860020e | 1612 | return 0; |
5dfdaf58 JB |
1613 | } |
1614 | ||
d9f83f22 | 1615 | static void ieee80211_free_next_beacon(struct ieee80211_link_data *link) |
0baef284 | 1616 | { |
d9f83f22 | 1617 | if (!link->u.ap.next_beacon) |
0baef284 JB |
1618 | return; |
1619 | ||
d9f83f22 | 1620 | kfree(link->u.ap.next_beacon->mbssid_ies); |
68b9bea2 | 1621 | kfree(link->u.ap.next_beacon->rnr_ies); |
d9f83f22 ST |
1622 | kfree(link->u.ap.next_beacon); |
1623 | link->u.ap.next_beacon = NULL; | |
0baef284 JB |
1624 | } |
1625 | ||
7b0a0e3c JB |
1626 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev, |
1627 | unsigned int link_id) | |
5dfdaf58 | 1628 | { |
7b20b8e8 JB |
1629 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1630 | struct ieee80211_sub_if_data *vlan; | |
1631 | struct ieee80211_local *local = sdata->local; | |
1632 | struct beacon_data *old_beacon; | |
1633 | struct probe_resp *old_probe_resp; | |
295b02c4 | 1634 | struct fils_discovery_data *old_fils_discovery; |
632189a0 | 1635 | struct unsol_bcast_probe_resp_data *old_unsol_bcast_probe_resp; |
d2859df5 | 1636 | struct cfg80211_chan_def chandef; |
d8675a63 JB |
1637 | struct ieee80211_link_data *link = |
1638 | sdata_dereference(sdata->link[link_id], sdata); | |
1639 | struct ieee80211_bss_conf *link_conf = link->conf; | |
1c0d21c4 | 1640 | LIST_HEAD(keys); |
14db74bc | 1641 | |
0cd8080e | 1642 | lockdep_assert_wiphy(local->hw.wiphy); |
dbd72850 | 1643 | |
d9f83f22 | 1644 | old_beacon = sdata_dereference(link->u.ap.beacon, sdata); |
7b20b8e8 | 1645 | if (!old_beacon) |
5dfdaf58 | 1646 | return -ENOENT; |
d9f83f22 | 1647 | old_probe_resp = sdata_dereference(link->u.ap.probe_resp, |
bfd8403a | 1648 | sdata); |
d9f83f22 | 1649 | old_fils_discovery = sdata_dereference(link->u.ap.fils_discovery, |
295b02c4 | 1650 | sdata); |
632189a0 | 1651 | old_unsol_bcast_probe_resp = |
d9f83f22 | 1652 | sdata_dereference(link->u.ap.unsol_bcast_probe_resp, |
632189a0 | 1653 | sdata); |
5dfdaf58 | 1654 | |
a23d7f5b | 1655 | /* abort any running channel switch or color change */ |
d9f83f22 | 1656 | link_conf->csa_active = false; |
a23d7f5b | 1657 | link_conf->color_change_active = false; |
dc494fdc | 1658 | ieee80211_vif_unblock_queues_csa(sdata); |
a46992b4 | 1659 | |
d9f83f22 | 1660 | ieee80211_free_next_beacon(link); |
1f3b8a2b | 1661 | |
7b20b8e8 | 1662 | /* turn off carrier for this interface and dependent VLANs */ |
3edaf3e6 JB |
1663 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
1664 | netif_carrier_off(vlan->dev); | |
5fcc7c51 | 1665 | |
6d4ed5b3 | 1666 | if (ieee80211_num_beaconing_links(sdata) <= 1) { |
5fcc7c51 | 1667 | netif_carrier_off(dev); |
6d4ed5b3 AKS |
1668 | sdata->u.ap.active = false; |
1669 | } | |
3edaf3e6 | 1670 | |
7b20b8e8 | 1671 | /* remove beacon and probe response */ |
d9f83f22 ST |
1672 | RCU_INIT_POINTER(link->u.ap.beacon, NULL); |
1673 | RCU_INIT_POINTER(link->u.ap.probe_resp, NULL); | |
1674 | RCU_INIT_POINTER(link->u.ap.fils_discovery, NULL); | |
1675 | RCU_INIT_POINTER(link->u.ap.unsol_bcast_probe_resp, NULL); | |
7b20b8e8 JB |
1676 | kfree_rcu(old_beacon, rcu_head); |
1677 | if (old_probe_resp) | |
1678 | kfree_rcu(old_probe_resp, rcu_head); | |
295b02c4 AD |
1679 | if (old_fils_discovery) |
1680 | kfree_rcu(old_fils_discovery, rcu_head); | |
632189a0 AD |
1681 | if (old_unsol_bcast_probe_resp) |
1682 | kfree_rcu(old_unsol_bcast_probe_resp, rcu_head); | |
8860020e | 1683 | |
d9f83f22 ST |
1684 | kfree(link_conf->ftmr_params); |
1685 | link_conf->ftmr_params = NULL; | |
bc847970 | 1686 | |
0eb38842 AD |
1687 | link_conf->bssid_index = 0; |
1688 | link_conf->nontransmitted = false; | |
1689 | link_conf->ema_ap = false; | |
1690 | link_conf->bssid_indicator = 0; | |
1691 | ||
a10723ce | 1692 | __sta_info_flush(sdata, true, link_id, NULL); |
1c0d21c4 RS |
1693 | |
1694 | ieee80211_remove_link_keys(link, &keys); | |
1695 | if (!list_empty(&keys)) { | |
1696 | synchronize_net(); | |
1697 | ieee80211_free_key_list(local, &keys); | |
1698 | } | |
75de9113 | 1699 | |
f6008327 RS |
1700 | ieee80211_stop_mbssid(sdata); |
1701 | RCU_INIT_POINTER(link_conf->tx_bss_conf, NULL); | |
1702 | ||
d9f83f22 | 1703 | link_conf->enable_beacon = false; |
08fad438 | 1704 | sdata->beacon_rate_set = false; |
f276e20b | 1705 | sdata->vif.cfg.ssid_len = 0; |
d6a83228 | 1706 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); |
d8675a63 | 1707 | ieee80211_link_info_change_notify(sdata, link, |
7fc83a2b | 1708 | BSS_CHANGED_BEACON_ENABLED); |
8860020e | 1709 | |
0b779823 | 1710 | if (sdata->wdev.links[link_id].cac_started) { |
6092077a | 1711 | chandef = link_conf->chanreq.oper; |
6241d79f | 1712 | wiphy_delayed_work_cancel(wiphy, &link->dfs_cac_timer_work); |
d2859df5 JD |
1713 | cfg80211_cac_event(sdata->dev, &chandef, |
1714 | NL80211_RADAR_CAC_ABORTED, | |
0b779823 | 1715 | GFP_KERNEL, link_id); |
a6b368f6 SW |
1716 | } |
1717 | ||
b327c84c | 1718 | drv_stop_ap(sdata->local, sdata, link_conf); |
1041638f | 1719 | |
7b20b8e8 JB |
1720 | /* free all potentially still buffered bcast frames */ |
1721 | local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf); | |
6b07d9ca | 1722 | ieee80211_purge_tx_queue(&local->hw, &sdata->u.ap.ps.bc_buf); |
7b20b8e8 | 1723 | |
d9f83f22 ST |
1724 | ieee80211_link_copy_chanctx_to_vlans(link, true); |
1725 | ieee80211_link_release_channel(link); | |
55de908a | 1726 | |
2d0ddec5 | 1727 | return 0; |
5dfdaf58 JB |
1728 | } |
1729 | ||
d582cffb JB |
1730 | static int sta_apply_auth_flags(struct ieee80211_local *local, |
1731 | struct sta_info *sta, | |
1732 | u32 mask, u32 set) | |
1733 | { | |
1734 | int ret; | |
1735 | ||
1736 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && | |
1737 | set & BIT(NL80211_STA_FLAG_AUTHENTICATED) && | |
1738 | !test_sta_flag(sta, WLAN_STA_AUTH)) { | |
1739 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); | |
1740 | if (ret) | |
1741 | return ret; | |
1742 | } | |
1743 | ||
1744 | if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && | |
1745 | set & BIT(NL80211_STA_FLAG_ASSOCIATED) && | |
1746 | !test_sta_flag(sta, WLAN_STA_ASSOC)) { | |
c23e31cf MP |
1747 | /* |
1748 | * When peer becomes associated, init rate control as | |
1749 | * well. Some drivers require rate control initialized | |
1750 | * before drv_sta_state() is called. | |
1751 | */ | |
44674d9c | 1752 | if (!test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) |
f828deb7 | 1753 | rate_control_rate_init_all_links(sta); |
c23e31cf | 1754 | |
d582cffb JB |
1755 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); |
1756 | if (ret) | |
1757 | return ret; | |
1758 | } | |
1759 | ||
1760 | if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { | |
1761 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) | |
1762 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); | |
1763 | else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
1764 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); | |
1765 | else | |
1766 | ret = 0; | |
1767 | if (ret) | |
1768 | return ret; | |
1769 | } | |
1770 | ||
1771 | if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && | |
1772 | !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) && | |
1773 | test_sta_flag(sta, WLAN_STA_ASSOC)) { | |
1774 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); | |
1775 | if (ret) | |
1776 | return ret; | |
1777 | } | |
1778 | ||
1779 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && | |
1780 | !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) && | |
1781 | test_sta_flag(sta, WLAN_STA_AUTH)) { | |
1782 | ret = sta_info_move_state(sta, IEEE80211_STA_NONE); | |
1783 | if (ret) | |
1784 | return ret; | |
1785 | } | |
1786 | ||
1787 | return 0; | |
1788 | } | |
1789 | ||
13657702 JB |
1790 | static void sta_apply_mesh_params(struct ieee80211_local *local, |
1791 | struct sta_info *sta, | |
1792 | struct station_parameters *params) | |
1793 | { | |
1794 | #ifdef CONFIG_MAC80211_MESH | |
1795 | struct ieee80211_sub_if_data *sdata = sta->sdata; | |
15ddba5f | 1796 | u64 changed = 0; |
13657702 JB |
1797 | |
1798 | if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) { | |
1799 | switch (params->plink_state) { | |
1800 | case NL80211_PLINK_ESTAB: | |
1801 | if (sta->mesh->plink_state != NL80211_PLINK_ESTAB) | |
1802 | changed = mesh_plink_inc_estab_count(sdata); | |
1803 | sta->mesh->plink_state = params->plink_state; | |
7d27a0ba | 1804 | sta->mesh->aid = params->peer_aid; |
13657702 JB |
1805 | |
1806 | ieee80211_mps_sta_status_update(sta); | |
1807 | changed |= ieee80211_mps_set_sta_local_pm(sta, | |
1808 | sdata->u.mesh.mshcfg.power_mode); | |
67fc0554 JH |
1809 | |
1810 | ewma_mesh_tx_rate_avg_init(&sta->mesh->tx_rate_avg); | |
1811 | /* init at low value */ | |
1812 | ewma_mesh_tx_rate_avg_add(&sta->mesh->tx_rate_avg, 10); | |
1813 | ||
13657702 JB |
1814 | break; |
1815 | case NL80211_PLINK_LISTEN: | |
1816 | case NL80211_PLINK_BLOCKED: | |
1817 | case NL80211_PLINK_OPN_SNT: | |
1818 | case NL80211_PLINK_OPN_RCVD: | |
1819 | case NL80211_PLINK_CNF_RCVD: | |
1820 | case NL80211_PLINK_HOLDING: | |
1821 | if (sta->mesh->plink_state == NL80211_PLINK_ESTAB) | |
1822 | changed = mesh_plink_dec_estab_count(sdata); | |
1823 | sta->mesh->plink_state = params->plink_state; | |
1824 | ||
1825 | ieee80211_mps_sta_status_update(sta); | |
1826 | changed |= ieee80211_mps_set_sta_local_pm(sta, | |
1827 | NL80211_MESH_POWER_UNKNOWN); | |
1828 | break; | |
1829 | default: | |
1830 | /* nothing */ | |
1831 | break; | |
1832 | } | |
1833 | } | |
1834 | ||
1835 | switch (params->plink_action) { | |
1836 | case NL80211_PLINK_ACTION_NO_ACTION: | |
1837 | /* nothing */ | |
1838 | break; | |
1839 | case NL80211_PLINK_ACTION_OPEN: | |
1840 | changed |= mesh_plink_open(sta); | |
1841 | break; | |
1842 | case NL80211_PLINK_ACTION_BLOCK: | |
1843 | changed |= mesh_plink_block(sta); | |
1844 | break; | |
1845 | } | |
1846 | ||
1847 | if (params->local_pm) | |
1848 | changed |= ieee80211_mps_set_sta_local_pm(sta, | |
1849 | params->local_pm); | |
1850 | ||
1851 | ieee80211_mbss_info_change_notify(sdata, changed); | |
1852 | #endif | |
1853 | } | |
1854 | ||
03ecd745 JB |
1855 | enum sta_link_apply_mode { |
1856 | STA_LINK_MODE_NEW, | |
1857 | STA_LINK_MODE_STA_MODIFY, | |
1858 | STA_LINK_MODE_LINK_MODIFY, | |
1859 | }; | |
1860 | ||
b95eb7f0 | 1861 | static int sta_link_apply_parameters(struct ieee80211_local *local, |
03ecd745 JB |
1862 | struct sta_info *sta, |
1863 | enum sta_link_apply_mode mode, | |
b95eb7f0 ST |
1864 | struct link_station_parameters *params) |
1865 | { | |
b95eb7f0 ST |
1866 | struct ieee80211_supported_band *sband; |
1867 | struct ieee80211_sub_if_data *sdata = sta->sdata; | |
1868 | u32 link_id = params->link_id < 0 ? 0 : params->link_id; | |
d8675a63 JB |
1869 | struct ieee80211_link_data *link = |
1870 | sdata_dereference(sdata->link[link_id], sdata); | |
b95eb7f0 ST |
1871 | struct link_sta_info *link_sta = |
1872 | rcu_dereference_protected(sta->link[link_id], | |
4d3acf43 | 1873 | lockdep_is_held(&local->hw.wiphy->mtx)); |
03ecd745 JB |
1874 | bool changes = params->link_mac || |
1875 | params->txpwr_set || | |
1876 | params->supported_rates_len || | |
1877 | params->ht_capa || | |
1878 | params->vht_capa || | |
1879 | params->he_capa || | |
1880 | params->eht_capa || | |
1881 | params->opmode_notif_used; | |
1882 | ||
1883 | switch (mode) { | |
1884 | case STA_LINK_MODE_NEW: | |
1885 | if (!params->link_mac) | |
1886 | return -EINVAL; | |
1887 | break; | |
1888 | case STA_LINK_MODE_LINK_MODIFY: | |
1889 | break; | |
1890 | case STA_LINK_MODE_STA_MODIFY: | |
1891 | if (params->link_id >= 0) | |
1892 | break; | |
1893 | if (!changes) | |
1894 | return 0; | |
1895 | break; | |
1896 | } | |
b303835d | 1897 | |
d8675a63 | 1898 | if (!link || !link_sta) |
b95eb7f0 ST |
1899 | return -EINVAL; |
1900 | ||
d8675a63 | 1901 | sband = ieee80211_get_link_sband(link); |
b95eb7f0 ST |
1902 | if (!sband) |
1903 | return -EINVAL; | |
1904 | ||
1905 | if (params->link_mac) { | |
03ecd745 | 1906 | if (mode == STA_LINK_MODE_NEW) { |
9aebce6c JB |
1907 | memcpy(link_sta->addr, params->link_mac, ETH_ALEN); |
1908 | memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN); | |
1909 | } else if (!ether_addr_equal(link_sta->addr, | |
1910 | params->link_mac)) { | |
1911 | return -EINVAL; | |
1912 | } | |
b95eb7f0 ST |
1913 | } |
1914 | ||
1915 | if (params->txpwr_set) { | |
642508a4 JB |
1916 | int ret; |
1917 | ||
b95eb7f0 ST |
1918 | link_sta->pub->txpwr.type = params->txpwr.type; |
1919 | if (params->txpwr.type == NL80211_TX_POWER_LIMITED) | |
1920 | link_sta->pub->txpwr.power = params->txpwr.power; | |
1921 | ret = drv_sta_set_txpwr(local, sdata, sta); | |
1922 | if (ret) | |
1923 | return ret; | |
1924 | } | |
1925 | ||
1926 | if (params->supported_rates && | |
16ee3ea8 ML |
1927 | params->supported_rates_len && |
1928 | !ieee80211_parse_bitrates(link->conf->chanreq.oper.width, | |
1929 | sband, params->supported_rates, | |
1930 | params->supported_rates_len, | |
1931 | &link_sta->pub->supp_rates[sband->band])) | |
1932 | return -EINVAL; | |
b95eb7f0 ST |
1933 | |
1934 | if (params->ht_capa) | |
1935 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, | |
1936 | params->ht_capa, link_sta); | |
1937 | ||
1938 | /* VHT can override some HT caps such as the A-MSDU max length */ | |
1939 | if (params->vht_capa) | |
1940 | ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband, | |
084cf2ae JB |
1941 | params->vht_capa, NULL, |
1942 | link_sta); | |
b95eb7f0 ST |
1943 | |
1944 | if (params->he_capa) | |
1945 | ieee80211_he_cap_ie_to_sta_he_cap(sdata, sband, | |
1946 | (void *)params->he_capa, | |
1947 | params->he_capa_len, | |
1948 | (void *)params->he_6ghz_capa, | |
1949 | link_sta); | |
1950 | ||
e8edb346 | 1951 | if (params->he_capa && params->eht_capa) |
b95eb7f0 ST |
1952 | ieee80211_eht_cap_ie_to_sta_eht_cap(sdata, sband, |
1953 | (u8 *)params->he_capa, | |
1954 | params->he_capa_len, | |
1955 | params->eht_capa, | |
1956 | params->eht_capa_len, | |
1957 | link_sta); | |
1958 | ||
819e0f1e BL |
1959 | ieee80211_sta_init_nss(link_sta); |
1960 | ||
b95eb7f0 | 1961 | if (params->opmode_notif_used) { |
58fcb1b4 MHL |
1962 | enum nl80211_chan_width width = link->conf->chanreq.oper.width; |
1963 | ||
1964 | switch (width) { | |
1965 | case NL80211_CHAN_WIDTH_20: | |
1966 | case NL80211_CHAN_WIDTH_40: | |
1967 | case NL80211_CHAN_WIDTH_80: | |
1968 | case NL80211_CHAN_WIDTH_160: | |
1969 | case NL80211_CHAN_WIDTH_80P80: | |
1970 | case NL80211_CHAN_WIDTH_320: /* not VHT, allowed for HE/EHT */ | |
1971 | break; | |
1972 | default: | |
1973 | return -EINVAL; | |
1974 | } | |
1975 | ||
b95eb7f0 ST |
1976 | /* returned value is only needed for rc update, but the |
1977 | * rc isn't initialized here yet, so ignore it | |
1978 | */ | |
1979 | __ieee80211_vht_handle_opmode(sdata, link_sta, | |
1980 | params->opmode_notif, | |
1981 | sband->band); | |
1982 | } | |
1983 | ||
642508a4 | 1984 | return 0; |
b95eb7f0 ST |
1985 | } |
1986 | ||
d9a7ddb0 JB |
1987 | static int sta_apply_parameters(struct ieee80211_local *local, |
1988 | struct sta_info *sta, | |
1989 | struct station_parameters *params) | |
4fd6931e | 1990 | { |
d0709a65 | 1991 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
eccb8e8f | 1992 | u32 mask, set; |
45b12570 | 1993 | int ret = 0; |
ae5eb026 | 1994 | |
eccb8e8f JB |
1995 | mask = params->sta_flags_mask; |
1996 | set = params->sta_flags_set; | |
73651ee6 | 1997 | |
d582cffb JB |
1998 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
1999 | /* | |
2000 | * In mesh mode, ASSOCIATED isn't part of the nl80211 | |
2001 | * API but must follow AUTHENTICATED for driver state. | |
2002 | */ | |
2003 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) | |
2004 | mask |= BIT(NL80211_STA_FLAG_ASSOCIATED); | |
2005 | if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) | |
2006 | set |= BIT(NL80211_STA_FLAG_ASSOCIATED); | |
77ee7c89 JB |
2007 | } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { |
2008 | /* | |
2009 | * TDLS -- everything follows authorized, but | |
2010 | * only becoming authorized is possible, not | |
2011 | * going back | |
2012 | */ | |
2013 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { | |
2014 | set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | | |
2015 | BIT(NL80211_STA_FLAG_ASSOCIATED); | |
2016 | mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | | |
2017 | BIT(NL80211_STA_FLAG_ASSOCIATED); | |
2018 | } | |
eccb8e8f | 2019 | } |
4fd6931e | 2020 | |
2c44be81 JB |
2021 | if (mask & BIT(NL80211_STA_FLAG_WME) && |
2022 | local->hw.queues >= IEEE80211_NUM_ACS) | |
2023 | sta->sta.wme = set & BIT(NL80211_STA_FLAG_WME); | |
2024 | ||
44674d9c | 2025 | /* auth flags will be set later for TDLS, |
b18dacab | 2026 | * and for unassociated stations that move to associated */ |
44674d9c AB |
2027 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) && |
2028 | !((mask & BIT(NL80211_STA_FLAG_ASSOCIATED)) && | |
2029 | (set & BIT(NL80211_STA_FLAG_ASSOCIATED)))) { | |
68885a54 AN |
2030 | ret = sta_apply_auth_flags(local, sta, mask, set); |
2031 | if (ret) | |
2032 | return ret; | |
2033 | } | |
d9a7ddb0 | 2034 | |
eccb8e8f | 2035 | if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { |
eccb8e8f | 2036 | if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) |
c2c98fde JB |
2037 | set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); |
2038 | else | |
2039 | clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); | |
eccb8e8f | 2040 | } |
4fd6931e | 2041 | |
eccb8e8f | 2042 | if (mask & BIT(NL80211_STA_FLAG_MFP)) { |
93f0490e | 2043 | sta->sta.mfp = !!(set & BIT(NL80211_STA_FLAG_MFP)); |
eccb8e8f | 2044 | if (set & BIT(NL80211_STA_FLAG_MFP)) |
c2c98fde JB |
2045 | set_sta_flag(sta, WLAN_STA_MFP); |
2046 | else | |
2047 | clear_sta_flag(sta, WLAN_STA_MFP); | |
4fd6931e | 2048 | } |
b39c48fa | 2049 | |
07ba55d7 | 2050 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
07ba55d7 | 2051 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) |
c2c98fde JB |
2052 | set_sta_flag(sta, WLAN_STA_TDLS_PEER); |
2053 | else | |
2054 | clear_sta_flag(sta, WLAN_STA_TDLS_PEER); | |
07ba55d7 | 2055 | } |
4fd6931e | 2056 | |
3b220ed8 JB |
2057 | if (mask & BIT(NL80211_STA_FLAG_SPP_AMSDU)) |
2058 | sta->sta.spp_amsdu = set & BIT(NL80211_STA_FLAG_SPP_AMSDU); | |
2059 | ||
9041c1fa AN |
2060 | /* mark TDLS channel switch support, if the AP allows it */ |
2061 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && | |
ab3a830d | 2062 | !sdata->deflink.u.mgd.tdls_chan_switch_prohibited && |
9041c1fa AN |
2063 | params->ext_capab_len >= 4 && |
2064 | params->ext_capab[3] & WLAN_EXT_CAPA4_TDLS_CHAN_SWITCH) | |
2065 | set_sta_flag(sta, WLAN_STA_TDLS_CHAN_SWITCH); | |
2066 | ||
b98fb44f | 2067 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && |
82c0cc90 | 2068 | !sdata->u.mgd.tdls_wider_bw_prohibited && |
b98fb44f AN |
2069 | ieee80211_hw_check(&local->hw, TDLS_WIDER_BW) && |
2070 | params->ext_capab_len >= 8 && | |
2071 | params->ext_capab[7] & WLAN_EXT_CAPA8_TDLS_WIDE_BW_ENABLED) | |
2072 | set_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW); | |
2073 | ||
3b9ce80c JB |
2074 | if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) { |
2075 | sta->sta.uapsd_queues = params->uapsd_queues; | |
2076 | sta->sta.max_sp = params->max_sp; | |
2077 | } | |
9533b4ac | 2078 | |
175ad2ec JB |
2079 | ieee80211_sta_set_max_amsdu_subframes(sta, params->ext_capab, |
2080 | params->ext_capab_len); | |
506bcfa8 | 2081 | |
51b50fbe JB |
2082 | /* |
2083 | * cfg80211 validates this (1-2007) and allows setting the AID | |
2084 | * only when creating a new station entry | |
2085 | */ | |
2086 | if (params->aid) | |
2087 | sta->sta.aid = params->aid; | |
2088 | ||
73651ee6 | 2089 | /* |
ba23d206 JB |
2090 | * Some of the following updates would be racy if called on an |
2091 | * existing station, via ieee80211_change_station(). However, | |
2092 | * all such changes are rejected by cfg80211 except for updates | |
2093 | * changing the supported rates on an existing but not yet used | |
2094 | * TDLS peer. | |
73651ee6 JB |
2095 | */ |
2096 | ||
4fd6931e JB |
2097 | if (params->listen_interval >= 0) |
2098 | sta->listen_interval = params->listen_interval; | |
2099 | ||
14e0f59a RK |
2100 | if (params->eml_cap_present) |
2101 | sta->sta.eml_cap = params->eml_cap; | |
2102 | ||
03ecd745 | 2103 | ret = sta_link_apply_parameters(local, sta, STA_LINK_MODE_STA_MODIFY, |
9aebce6c | 2104 | ¶ms->link_sta_params); |
b95eb7f0 ST |
2105 | if (ret) |
2106 | return ret; | |
b1bce14a | 2107 | |
52cfa1d6 AB |
2108 | if (params->support_p2p_ps >= 0) |
2109 | sta->sta.support_p2p_ps = params->support_p2p_ps; | |
2110 | ||
13657702 JB |
2111 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
2112 | sta_apply_mesh_params(local, sta, params); | |
d9a7ddb0 | 2113 | |
b4809e94 | 2114 | if (params->airtime_weight) |
942741da | 2115 | sta->airtime_weight = params->airtime_weight; |
b4809e94 | 2116 | |
68885a54 | 2117 | /* set the STA state after all sta info from usermode has been set */ |
44674d9c AB |
2118 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) || |
2119 | set & BIT(NL80211_STA_FLAG_ASSOCIATED)) { | |
68885a54 AN |
2120 | ret = sta_apply_auth_flags(local, sta, mask, set); |
2121 | if (ret) | |
2122 | return ret; | |
2123 | } | |
2124 | ||
3e0278b7 AO |
2125 | /* Mark the STA as MLO if MLD MAC address is available */ |
2126 | if (params->link_sta_params.mld_mac) | |
2127 | sta->sta.mlo = true; | |
2128 | ||
d9a7ddb0 | 2129 | return 0; |
4fd6931e JB |
2130 | } |
2131 | ||
2132 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |
3b3a0162 JB |
2133 | const u8 *mac, |
2134 | struct station_parameters *params) | |
4fd6931e | 2135 | { |
14db74bc | 2136 | struct ieee80211_local *local = wiphy_priv(wiphy); |
4fd6931e JB |
2137 | struct sta_info *sta; |
2138 | struct ieee80211_sub_if_data *sdata; | |
73651ee6 | 2139 | int err; |
4fd6931e | 2140 | |
4d3acf43 JB |
2141 | lockdep_assert_wiphy(local->hw.wiphy); |
2142 | ||
4fd6931e JB |
2143 | if (params->vlan) { |
2144 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); | |
2145 | ||
05c914fe JB |
2146 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
2147 | sdata->vif.type != NL80211_IFTYPE_AP) | |
4fd6931e JB |
2148 | return -EINVAL; |
2149 | } else | |
2150 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2151 | ||
b203ca39 | 2152 | if (ether_addr_equal(mac, sdata->vif.addr)) |
03e4497e JB |
2153 | return -EINVAL; |
2154 | ||
52dba8d7 | 2155 | if (!is_valid_ether_addr(mac)) |
03e4497e JB |
2156 | return -EINVAL; |
2157 | ||
5fd2f91a JB |
2158 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER) && |
2159 | sdata->vif.type == NL80211_IFTYPE_STATION && | |
2160 | !sdata->u.mgd.associated) | |
2161 | return -EINVAL; | |
2162 | ||
206c8c06 JB |
2163 | /* |
2164 | * If we have a link ID, it can be a non-MLO station on an AP MLD, | |
2165 | * but we need to have a link_mac in that case as well, so use the | |
2166 | * STA's MAC address in that case. | |
2167 | */ | |
f36fe0a2 JB |
2168 | if (params->link_sta_params.link_id >= 0) |
2169 | sta = sta_info_alloc_with_link(sdata, mac, | |
2170 | params->link_sta_params.link_id, | |
206c8c06 | 2171 | params->link_sta_params.link_mac ?: mac, |
f36fe0a2 JB |
2172 | GFP_KERNEL); |
2173 | else | |
2174 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); | |
2175 | ||
73651ee6 JB |
2176 | if (!sta) |
2177 | return -ENOMEM; | |
4fd6931e | 2178 | |
44674d9c AB |
2179 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) |
2180 | sta->sta.tdls = true; | |
4fd6931e | 2181 | |
b95eb7f0 ST |
2182 | /* Though the mutex is not needed here (since the station is not |
2183 | * visible yet), sta_apply_parameters (and inner functions) require | |
2184 | * the mutex due to other paths. | |
2185 | */ | |
d9a7ddb0 JB |
2186 | err = sta_apply_parameters(local, sta, params); |
2187 | if (err) { | |
2188 | sta_info_free(local, sta); | |
2189 | return err; | |
2190 | } | |
4fd6931e | 2191 | |
d64cf63e | 2192 | /* |
44674d9c AB |
2193 | * for TDLS and for unassociated station, rate control should be |
2194 | * initialized only when rates are known and station is marked | |
2195 | * authorized/associated | |
d64cf63e | 2196 | */ |
44674d9c AB |
2197 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER) && |
2198 | test_sta_flag(sta, WLAN_STA_ASSOC)) | |
f828deb7 | 2199 | rate_control_rate_init_all_links(sta); |
4fd6931e | 2200 | |
4ebdce1d | 2201 | return sta_info_insert(sta); |
4fd6931e JB |
2202 | } |
2203 | ||
2204 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, | |
89c771e5 | 2205 | struct station_del_parameters *params) |
4fd6931e | 2206 | { |
14db74bc | 2207 | struct ieee80211_sub_if_data *sdata; |
4fd6931e | 2208 | |
14db74bc JB |
2209 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2210 | ||
89c771e5 JM |
2211 | if (params->mac) |
2212 | return sta_info_destroy_addr_bss(sdata, params->mac); | |
4fd6931e | 2213 | |
ec67d6e0 | 2214 | sta_info_flush(sdata, params->link_id); |
4fd6931e JB |
2215 | return 0; |
2216 | } | |
2217 | ||
2218 | static int ieee80211_change_station(struct wiphy *wiphy, | |
3b3a0162 | 2219 | struct net_device *dev, const u8 *mac, |
4fd6931e JB |
2220 | struct station_parameters *params) |
2221 | { | |
abe60632 | 2222 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
14db74bc | 2223 | struct ieee80211_local *local = wiphy_priv(wiphy); |
4fd6931e JB |
2224 | struct sta_info *sta; |
2225 | struct ieee80211_sub_if_data *vlansdata; | |
77ee7c89 | 2226 | enum cfg80211_station_type statype; |
35b88623 | 2227 | int err; |
4fd6931e | 2228 | |
4d3acf43 | 2229 | lockdep_assert_wiphy(local->hw.wiphy); |
98dd6a57 | 2230 | |
0e5ded5a | 2231 | sta = sta_info_get_bss(sdata, mac); |
4d3acf43 JB |
2232 | if (!sta) |
2233 | return -ENOENT; | |
4fd6931e | 2234 | |
77ee7c89 JB |
2235 | switch (sdata->vif.type) { |
2236 | case NL80211_IFTYPE_MESH_POINT: | |
a6dad6a2 | 2237 | if (sdata->u.mesh.user_mpm) |
eef941e6 | 2238 | statype = CFG80211_STA_MESH_PEER_USER; |
77ee7c89 | 2239 | else |
eef941e6 | 2240 | statype = CFG80211_STA_MESH_PEER_KERNEL; |
77ee7c89 JB |
2241 | break; |
2242 | case NL80211_IFTYPE_ADHOC: | |
2243 | statype = CFG80211_STA_IBSS; | |
2244 | break; | |
2245 | case NL80211_IFTYPE_STATION: | |
2246 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { | |
2247 | statype = CFG80211_STA_AP_STA; | |
2248 | break; | |
2249 | } | |
2250 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
2251 | statype = CFG80211_STA_TDLS_PEER_ACTIVE; | |
2252 | else | |
2253 | statype = CFG80211_STA_TDLS_PEER_SETUP; | |
2254 | break; | |
2255 | case NL80211_IFTYPE_AP: | |
2256 | case NL80211_IFTYPE_AP_VLAN: | |
44674d9c AB |
2257 | if (test_sta_flag(sta, WLAN_STA_ASSOC)) |
2258 | statype = CFG80211_STA_AP_CLIENT; | |
2259 | else | |
2260 | statype = CFG80211_STA_AP_CLIENT_UNASSOC; | |
77ee7c89 JB |
2261 | break; |
2262 | default: | |
4d3acf43 | 2263 | return -EOPNOTSUPP; |
bdd90d5e JB |
2264 | } |
2265 | ||
77ee7c89 JB |
2266 | err = cfg80211_check_station_change(wiphy, params, statype); |
2267 | if (err) | |
4d3acf43 | 2268 | return err; |
77ee7c89 | 2269 | |
d0709a65 | 2270 | if (params->vlan && params->vlan != sta->sdata->dev) { |
4fd6931e JB |
2271 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
2272 | ||
9bc383de | 2273 | if (params->vlan->ieee80211_ptr->use_4addr) { |
4d3acf43 JB |
2274 | if (vlansdata->u.vlan.sta) |
2275 | return -EBUSY; | |
f14543ee | 2276 | |
cf778b00 | 2277 | rcu_assign_pointer(vlansdata->u.vlan.sta, sta); |
49ddf8e6 | 2278 | __ieee80211_check_fast_rx_iface(vlansdata); |
1ff4e8f2 | 2279 | drv_sta_set_4addr(local, sta->sdata, &sta->sta, true); |
7e3ed02c FF |
2280 | } |
2281 | ||
2282 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | |
4f2bdb3c | 2283 | sta->sdata->u.vlan.sta) |
0c2bef46 | 2284 | RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL); |
72f15d53 MB |
2285 | |
2286 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
2287 | ieee80211_vif_dec_num_mcast(sta->sdata); | |
f14543ee | 2288 | |
14db74bc | 2289 | sta->sdata = vlansdata; |
4f2bdb3c | 2290 | ieee80211_check_fast_rx(sta); |
464daaf0 | 2291 | ieee80211_check_fast_xmit(sta); |
7e3ed02c | 2292 | |
3e493173 | 2293 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) { |
72f15d53 | 2294 | ieee80211_vif_inc_num_mcast(sta->sdata); |
3e493173 JM |
2295 | cfg80211_send_layer2_update(sta->sdata->dev, |
2296 | sta->sta.addr); | |
2297 | } | |
4fd6931e JB |
2298 | } |
2299 | ||
076fc877 | 2300 | err = sta_apply_parameters(local, sta, params); |
77ee7c89 | 2301 | if (err) |
4d3acf43 | 2302 | return err; |
98dd6a57 | 2303 | |
808118cb | 2304 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
ab095877 | 2305 | params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
4a733ef1 | 2306 | ieee80211_recalc_ps(local); |
ab095877 EP |
2307 | ieee80211_recalc_ps_vif(sdata); |
2308 | } | |
77ee7c89 | 2309 | |
4fd6931e JB |
2310 | return 0; |
2311 | } | |
2312 | ||
c5dd9c2b LCC |
2313 | #ifdef CONFIG_MAC80211_MESH |
2314 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |
3b3a0162 | 2315 | const u8 *dst, const u8 *next_hop) |
c5dd9c2b | 2316 | { |
14db74bc | 2317 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
2318 | struct mesh_path *mpath; |
2319 | struct sta_info *sta; | |
c5dd9c2b | 2320 | |
14db74bc JB |
2321 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2322 | ||
d0709a65 | 2323 | rcu_read_lock(); |
abe60632 | 2324 | sta = sta_info_get(sdata, next_hop); |
d0709a65 JB |
2325 | if (!sta) { |
2326 | rcu_read_unlock(); | |
c5dd9c2b | 2327 | return -ENOENT; |
d0709a65 | 2328 | } |
c5dd9c2b | 2329 | |
ae76eef0 BC |
2330 | mpath = mesh_path_add(sdata, dst); |
2331 | if (IS_ERR(mpath)) { | |
d0709a65 | 2332 | rcu_read_unlock(); |
ae76eef0 | 2333 | return PTR_ERR(mpath); |
d0709a65 | 2334 | } |
c5dd9c2b | 2335 | |
c5dd9c2b | 2336 | mesh_path_fix_nexthop(mpath, sta); |
d0709a65 | 2337 | |
c5dd9c2b LCC |
2338 | rcu_read_unlock(); |
2339 | return 0; | |
2340 | } | |
2341 | ||
2342 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, | |
3b3a0162 | 2343 | const u8 *dst) |
c5dd9c2b | 2344 | { |
f698d856 JBG |
2345 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2346 | ||
c5dd9c2b | 2347 | if (dst) |
bf7cd94d | 2348 | return mesh_path_del(sdata, dst); |
c5dd9c2b | 2349 | |
ece1a2e7 | 2350 | mesh_path_flush_by_iface(sdata); |
c5dd9c2b LCC |
2351 | return 0; |
2352 | } | |
2353 | ||
3b3a0162 JB |
2354 | static int ieee80211_change_mpath(struct wiphy *wiphy, struct net_device *dev, |
2355 | const u8 *dst, const u8 *next_hop) | |
c5dd9c2b | 2356 | { |
14db74bc | 2357 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
2358 | struct mesh_path *mpath; |
2359 | struct sta_info *sta; | |
2360 | ||
14db74bc JB |
2361 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2362 | ||
d0709a65 JB |
2363 | rcu_read_lock(); |
2364 | ||
abe60632 | 2365 | sta = sta_info_get(sdata, next_hop); |
d0709a65 JB |
2366 | if (!sta) { |
2367 | rcu_read_unlock(); | |
c5dd9c2b | 2368 | return -ENOENT; |
d0709a65 | 2369 | } |
c5dd9c2b | 2370 | |
bf7cd94d | 2371 | mpath = mesh_path_lookup(sdata, dst); |
c5dd9c2b LCC |
2372 | if (!mpath) { |
2373 | rcu_read_unlock(); | |
c5dd9c2b LCC |
2374 | return -ENOENT; |
2375 | } | |
2376 | ||
2377 | mesh_path_fix_nexthop(mpath, sta); | |
d0709a65 | 2378 | |
c5dd9c2b LCC |
2379 | rcu_read_unlock(); |
2380 | return 0; | |
2381 | } | |
2382 | ||
2383 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, | |
2384 | struct mpath_info *pinfo) | |
2385 | { | |
a3836e02 JB |
2386 | struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop); |
2387 | ||
2388 | if (next_hop_sta) | |
2389 | memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN); | |
c5dd9c2b | 2390 | else |
c84a67a2 | 2391 | eth_zero_addr(next_hop); |
c5dd9c2b | 2392 | |
7ce8c7a3 LAYS |
2393 | memset(pinfo, 0, sizeof(*pinfo)); |
2394 | ||
2bdaf386 | 2395 | pinfo->generation = mpath->sdata->u.mesh.mesh_paths_generation; |
f5ea9120 | 2396 | |
c5dd9c2b | 2397 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
d19b3bf6 | 2398 | MPATH_INFO_SN | |
c5dd9c2b LCC |
2399 | MPATH_INFO_METRIC | |
2400 | MPATH_INFO_EXPTIME | | |
2401 | MPATH_INFO_DISCOVERY_TIMEOUT | | |
2402 | MPATH_INFO_DISCOVERY_RETRIES | | |
cc241636 | 2403 | MPATH_INFO_FLAGS | |
540bbcb9 JH |
2404 | MPATH_INFO_HOP_COUNT | |
2405 | MPATH_INFO_PATH_CHANGE; | |
c5dd9c2b LCC |
2406 | |
2407 | pinfo->frame_qlen = mpath->frame_queue.qlen; | |
d19b3bf6 | 2408 | pinfo->sn = mpath->sn; |
c5dd9c2b LCC |
2409 | pinfo->metric = mpath->metric; |
2410 | if (time_before(jiffies, mpath->exp_time)) | |
2411 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); | |
2412 | pinfo->discovery_timeout = | |
2413 | jiffies_to_msecs(mpath->discovery_timeout); | |
2414 | pinfo->discovery_retries = mpath->discovery_retries; | |
c5dd9c2b LCC |
2415 | if (mpath->flags & MESH_PATH_ACTIVE) |
2416 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; | |
2417 | if (mpath->flags & MESH_PATH_RESOLVING) | |
2418 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; | |
d19b3bf6 RP |
2419 | if (mpath->flags & MESH_PATH_SN_VALID) |
2420 | pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID; | |
c5dd9c2b LCC |
2421 | if (mpath->flags & MESH_PATH_FIXED) |
2422 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; | |
7ce8c7a3 LAYS |
2423 | if (mpath->flags & MESH_PATH_RESOLVED) |
2424 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED; | |
cc241636 | 2425 | pinfo->hop_count = mpath->hop_count; |
540bbcb9 | 2426 | pinfo->path_change_count = mpath->path_change_count; |
c5dd9c2b LCC |
2427 | } |
2428 | ||
2429 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, | |
2430 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) | |
2431 | ||
2432 | { | |
14db74bc | 2433 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
2434 | struct mesh_path *mpath; |
2435 | ||
14db74bc JB |
2436 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2437 | ||
c5dd9c2b | 2438 | rcu_read_lock(); |
bf7cd94d | 2439 | mpath = mesh_path_lookup(sdata, dst); |
c5dd9c2b LCC |
2440 | if (!mpath) { |
2441 | rcu_read_unlock(); | |
2442 | return -ENOENT; | |
2443 | } | |
2444 | memcpy(dst, mpath->dst, ETH_ALEN); | |
2445 | mpath_set_pinfo(mpath, next_hop, pinfo); | |
2446 | rcu_read_unlock(); | |
2447 | return 0; | |
2448 | } | |
2449 | ||
2450 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, | |
3b3a0162 JB |
2451 | int idx, u8 *dst, u8 *next_hop, |
2452 | struct mpath_info *pinfo) | |
c5dd9c2b | 2453 | { |
14db74bc | 2454 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
2455 | struct mesh_path *mpath; |
2456 | ||
14db74bc JB |
2457 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2458 | ||
c5dd9c2b | 2459 | rcu_read_lock(); |
bf7cd94d | 2460 | mpath = mesh_path_lookup_by_idx(sdata, idx); |
c5dd9c2b LCC |
2461 | if (!mpath) { |
2462 | rcu_read_unlock(); | |
2463 | return -ENOENT; | |
2464 | } | |
2465 | memcpy(dst, mpath->dst, ETH_ALEN); | |
2466 | mpath_set_pinfo(mpath, next_hop, pinfo); | |
2467 | rcu_read_unlock(); | |
2468 | return 0; | |
2469 | } | |
93da9cc1 | 2470 | |
a2db2ed3 HR |
2471 | static void mpp_set_pinfo(struct mesh_path *mpath, u8 *mpp, |
2472 | struct mpath_info *pinfo) | |
2473 | { | |
2474 | memset(pinfo, 0, sizeof(*pinfo)); | |
2475 | memcpy(mpp, mpath->mpp, ETH_ALEN); | |
2476 | ||
2bdaf386 | 2477 | pinfo->generation = mpath->sdata->u.mesh.mpp_paths_generation; |
a2db2ed3 HR |
2478 | } |
2479 | ||
2480 | static int ieee80211_get_mpp(struct wiphy *wiphy, struct net_device *dev, | |
2481 | u8 *dst, u8 *mpp, struct mpath_info *pinfo) | |
2482 | ||
2483 | { | |
2484 | struct ieee80211_sub_if_data *sdata; | |
2485 | struct mesh_path *mpath; | |
2486 | ||
2487 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2488 | ||
2489 | rcu_read_lock(); | |
2490 | mpath = mpp_path_lookup(sdata, dst); | |
2491 | if (!mpath) { | |
2492 | rcu_read_unlock(); | |
2493 | return -ENOENT; | |
2494 | } | |
2495 | memcpy(dst, mpath->dst, ETH_ALEN); | |
2496 | mpp_set_pinfo(mpath, mpp, pinfo); | |
2497 | rcu_read_unlock(); | |
2498 | return 0; | |
2499 | } | |
2500 | ||
2501 | static int ieee80211_dump_mpp(struct wiphy *wiphy, struct net_device *dev, | |
2502 | int idx, u8 *dst, u8 *mpp, | |
2503 | struct mpath_info *pinfo) | |
2504 | { | |
2505 | struct ieee80211_sub_if_data *sdata; | |
2506 | struct mesh_path *mpath; | |
2507 | ||
2508 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2509 | ||
2510 | rcu_read_lock(); | |
2511 | mpath = mpp_path_lookup_by_idx(sdata, idx); | |
2512 | if (!mpath) { | |
2513 | rcu_read_unlock(); | |
2514 | return -ENOENT; | |
2515 | } | |
2516 | memcpy(dst, mpath->dst, ETH_ALEN); | |
2517 | mpp_set_pinfo(mpath, mpp, pinfo); | |
2518 | rcu_read_unlock(); | |
2519 | return 0; | |
2520 | } | |
2521 | ||
24bdd9f4 | 2522 | static int ieee80211_get_mesh_config(struct wiphy *wiphy, |
93da9cc1 | 2523 | struct net_device *dev, |
2524 | struct mesh_config *conf) | |
2525 | { | |
2526 | struct ieee80211_sub_if_data *sdata; | |
2527 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2528 | ||
93da9cc1 | 2529 | memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); |
2530 | return 0; | |
2531 | } | |
2532 | ||
2533 | static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask) | |
2534 | { | |
2535 | return (mask >> (parm-1)) & 0x1; | |
2536 | } | |
2537 | ||
c80d545d JC |
2538 | static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh, |
2539 | const struct mesh_setup *setup) | |
2540 | { | |
2541 | u8 *new_ie; | |
4bb62344 CYY |
2542 | struct ieee80211_sub_if_data *sdata = container_of(ifmsh, |
2543 | struct ieee80211_sub_if_data, u.mesh); | |
08fad438 | 2544 | int i; |
c80d545d | 2545 | |
581a8b0f | 2546 | /* allocate information elements */ |
c80d545d | 2547 | new_ie = NULL; |
c80d545d | 2548 | |
581a8b0f JC |
2549 | if (setup->ie_len) { |
2550 | new_ie = kmemdup(setup->ie, setup->ie_len, | |
c80d545d JC |
2551 | GFP_KERNEL); |
2552 | if (!new_ie) | |
2553 | return -ENOMEM; | |
2554 | } | |
581a8b0f JC |
2555 | ifmsh->ie_len = setup->ie_len; |
2556 | ifmsh->ie = new_ie; | |
c80d545d JC |
2557 | |
2558 | /* now copy the rest of the setup parameters */ | |
2559 | ifmsh->mesh_id_len = setup->mesh_id_len; | |
2560 | memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); | |
d299a1f2 | 2561 | ifmsh->mesh_sp_id = setup->sync_method; |
c80d545d JC |
2562 | ifmsh->mesh_pp_id = setup->path_sel_proto; |
2563 | ifmsh->mesh_pm_id = setup->path_metric; | |
a6dad6a2 | 2564 | ifmsh->user_mpm = setup->user_mpm; |
0d4261ad | 2565 | ifmsh->mesh_auth_id = setup->auth_id; |
b130e5ce | 2566 | ifmsh->security = IEEE80211_MESH_SEC_NONE; |
0ab2e55d | 2567 | ifmsh->userspace_handles_dfs = setup->userspace_handles_dfs; |
b130e5ce JC |
2568 | if (setup->is_authenticated) |
2569 | ifmsh->security |= IEEE80211_MESH_SEC_AUTHED; | |
2570 | if (setup->is_secure) | |
2571 | ifmsh->security |= IEEE80211_MESH_SEC_SECURED; | |
c80d545d | 2572 | |
4bb62344 CYY |
2573 | /* mcast rate setting in Mesh Node */ |
2574 | memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate, | |
2575 | sizeof(setup->mcast_rate)); | |
ffb3cf30 | 2576 | sdata->vif.bss_conf.basic_rates = setup->basic_rates; |
4bb62344 | 2577 | |
9bdbf04d MP |
2578 | sdata->vif.bss_conf.beacon_int = setup->beacon_interval; |
2579 | sdata->vif.bss_conf.dtim_period = setup->dtim_period; | |
2580 | ||
08fad438 JM |
2581 | sdata->beacon_rate_set = false; |
2582 | if (wiphy_ext_feature_isset(sdata->local->hw.wiphy, | |
2583 | NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) { | |
2584 | for (i = 0; i < NUM_NL80211_BANDS; i++) { | |
2585 | sdata->beacon_rateidx_mask[i] = | |
2586 | setup->beacon_rate.control[i].legacy; | |
2587 | if (sdata->beacon_rateidx_mask[i]) | |
2588 | sdata->beacon_rate_set = true; | |
2589 | } | |
2590 | } | |
2591 | ||
c80d545d JC |
2592 | return 0; |
2593 | } | |
2594 | ||
24bdd9f4 | 2595 | static int ieee80211_update_mesh_config(struct wiphy *wiphy, |
29cbe68c JB |
2596 | struct net_device *dev, u32 mask, |
2597 | const struct mesh_config *nconf) | |
93da9cc1 | 2598 | { |
2599 | struct mesh_config *conf; | |
2600 | struct ieee80211_sub_if_data *sdata; | |
63c5723b RP |
2601 | struct ieee80211_if_mesh *ifmsh; |
2602 | ||
93da9cc1 | 2603 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
63c5723b | 2604 | ifmsh = &sdata->u.mesh; |
93da9cc1 | 2605 | |
93da9cc1 | 2606 | /* Set the config options which we are interested in setting */ |
2607 | conf = &(sdata->u.mesh.mshcfg); | |
2608 | if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) | |
2609 | conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; | |
2610 | if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) | |
2611 | conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; | |
2612 | if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) | |
2613 | conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; | |
2614 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) | |
2615 | conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; | |
2616 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) | |
2617 | conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; | |
2618 | if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) | |
2619 | conf->dot11MeshTTL = nconf->dot11MeshTTL; | |
45904f21 | 2620 | if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask)) |
58886a90 | 2621 | conf->element_ttl = nconf->element_ttl; |
146bb483 TP |
2622 | if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) { |
2623 | if (ifmsh->user_mpm) | |
2624 | return -EBUSY; | |
93da9cc1 | 2625 | conf->auto_open_plinks = nconf->auto_open_plinks; |
146bb483 | 2626 | } |
d299a1f2 JC |
2627 | if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask)) |
2628 | conf->dot11MeshNbrOffsetMaxNeighbor = | |
2629 | nconf->dot11MeshNbrOffsetMaxNeighbor; | |
93da9cc1 | 2630 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) |
2631 | conf->dot11MeshHWMPmaxPREQretries = | |
2632 | nconf->dot11MeshHWMPmaxPREQretries; | |
2633 | if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) | |
2634 | conf->path_refresh_time = nconf->path_refresh_time; | |
2635 | if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) | |
2636 | conf->min_discovery_timeout = nconf->min_discovery_timeout; | |
2637 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) | |
2638 | conf->dot11MeshHWMPactivePathTimeout = | |
2639 | nconf->dot11MeshHWMPactivePathTimeout; | |
2640 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) | |
2641 | conf->dot11MeshHWMPpreqMinInterval = | |
2642 | nconf->dot11MeshHWMPpreqMinInterval; | |
dca7e943 TP |
2643 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask)) |
2644 | conf->dot11MeshHWMPperrMinInterval = | |
2645 | nconf->dot11MeshHWMPperrMinInterval; | |
93da9cc1 | 2646 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
2647 | mask)) | |
2648 | conf->dot11MeshHWMPnetDiameterTraversalTime = | |
2649 | nconf->dot11MeshHWMPnetDiameterTraversalTime; | |
63c5723b RP |
2650 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) { |
2651 | conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode; | |
2652 | ieee80211_mesh_root_setup(ifmsh); | |
2653 | } | |
16dd7267 | 2654 | if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) { |
c6133661 TP |
2655 | /* our current gate announcement implementation rides on root |
2656 | * announcements, so require this ifmsh to also be a root node | |
2657 | * */ | |
2658 | if (nconf->dot11MeshGateAnnouncementProtocol && | |
dbb912cd CYY |
2659 | !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) { |
2660 | conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN; | |
c6133661 TP |
2661 | ieee80211_mesh_root_setup(ifmsh); |
2662 | } | |
16dd7267 JC |
2663 | conf->dot11MeshGateAnnouncementProtocol = |
2664 | nconf->dot11MeshGateAnnouncementProtocol; | |
2665 | } | |
a4f606ea | 2666 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) |
0507e159 JC |
2667 | conf->dot11MeshHWMPRannInterval = |
2668 | nconf->dot11MeshHWMPRannInterval; | |
94f90656 CYY |
2669 | if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask)) |
2670 | conf->dot11MeshForwarding = nconf->dot11MeshForwarding; | |
55335137 AN |
2671 | if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) { |
2672 | /* our RSSI threshold implementation is supported only for | |
2673 | * devices that report signal in dBm. | |
2674 | */ | |
30686bf7 | 2675 | if (!ieee80211_hw_check(&sdata->local->hw, SIGNAL_DBM)) |
0528e0fd | 2676 | return -EOPNOTSUPP; |
55335137 AN |
2677 | conf->rssi_threshold = nconf->rssi_threshold; |
2678 | } | |
70c33eaa AN |
2679 | if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) { |
2680 | conf->ht_opmode = nconf->ht_opmode; | |
2681 | sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode; | |
d8675a63 JB |
2682 | ieee80211_link_info_change_notify(sdata, &sdata->deflink, |
2683 | BSS_CHANGED_HT); | |
70c33eaa | 2684 | } |
ac1073a6 CYY |
2685 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask)) |
2686 | conf->dot11MeshHWMPactivePathToRootTimeout = | |
2687 | nconf->dot11MeshHWMPactivePathToRootTimeout; | |
2688 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask)) | |
2689 | conf->dot11MeshHWMProotInterval = | |
2690 | nconf->dot11MeshHWMProotInterval; | |
728b19e5 CYY |
2691 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask)) |
2692 | conf->dot11MeshHWMPconfirmationInterval = | |
2693 | nconf->dot11MeshHWMPconfirmationInterval; | |
3f52b7e3 MP |
2694 | if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) { |
2695 | conf->power_mode = nconf->power_mode; | |
2696 | ieee80211_mps_local_status_update(sdata); | |
2697 | } | |
2b5e1967 | 2698 | if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask)) |
3f52b7e3 MP |
2699 | conf->dot11MeshAwakeWindowDuration = |
2700 | nconf->dot11MeshAwakeWindowDuration; | |
66de6713 CT |
2701 | if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask)) |
2702 | conf->plink_timeout = nconf->plink_timeout; | |
01d66fbd BC |
2703 | if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask)) |
2704 | conf->dot11MeshConnectedToMeshGate = | |
2705 | nconf->dot11MeshConnectedToMeshGate; | |
e3718a61 LL |
2706 | if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask)) |
2707 | conf->dot11MeshNolearn = nconf->dot11MeshNolearn; | |
184eebe6 MT |
2708 | if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_AS, mask)) |
2709 | conf->dot11MeshConnectedToAuthServer = | |
2710 | nconf->dot11MeshConnectedToAuthServer; | |
2b5e1967 | 2711 | ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON); |
93da9cc1 | 2712 | return 0; |
2713 | } | |
2714 | ||
29cbe68c JB |
2715 | static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev, |
2716 | const struct mesh_config *conf, | |
2717 | const struct mesh_setup *setup) | |
2718 | { | |
2719 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
6092077a | 2720 | struct ieee80211_chan_req chanreq = { .oper = setup->chandef }; |
29cbe68c | 2721 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
c80d545d | 2722 | int err; |
29cbe68c | 2723 | |
0cd8080e JB |
2724 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
2725 | ||
c80d545d JC |
2726 | memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config)); |
2727 | err = copy_mesh_setup(ifmsh, setup); | |
2728 | if (err) | |
2729 | return err; | |
cc1d2806 | 2730 | |
018f6fbf DK |
2731 | sdata->control_port_over_nl80211 = setup->control_port_over_nl80211; |
2732 | ||
04ecd257 | 2733 | /* can mesh use other SMPS modes? */ |
bfd8403a JB |
2734 | sdata->deflink.smps_mode = IEEE80211_SMPS_OFF; |
2735 | sdata->deflink.needed_rx_chains = sdata->local->rx_chains; | |
04ecd257 | 2736 | |
6092077a | 2737 | err = ieee80211_link_use_channel(&sdata->deflink, &chanreq, |
b4f85443 | 2738 | IEEE80211_CHANCTX_SHARED); |
cc1d2806 JB |
2739 | if (err) |
2740 | return err; | |
2741 | ||
2b5e1967 | 2742 | return ieee80211_start_mesh(sdata); |
29cbe68c JB |
2743 | } |
2744 | ||
2745 | static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) | |
2746 | { | |
2747 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2748 | ||
0cd8080e JB |
2749 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
2750 | ||
29cbe68c | 2751 | ieee80211_stop_mesh(sdata); |
d8675a63 | 2752 | ieee80211_link_release_channel(&sdata->deflink); |
6a01afcf | 2753 | kfree(sdata->u.mesh.ie); |
29cbe68c JB |
2754 | |
2755 | return 0; | |
2756 | } | |
c5dd9c2b LCC |
2757 | #endif |
2758 | ||
9f1ba906 JM |
2759 | static int ieee80211_change_bss(struct wiphy *wiphy, |
2760 | struct net_device *dev, | |
2761 | struct bss_parameters *params) | |
2762 | { | |
55de908a | 2763 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
9a886df0 | 2764 | struct ieee80211_link_data *link; |
21a8e9dd | 2765 | struct ieee80211_supported_band *sband; |
15ddba5f | 2766 | u64 changed = 0; |
9f1ba906 | 2767 | |
9a886df0 JB |
2768 | link = ieee80211_link_or_deflink(sdata, params->link_id, true); |
2769 | if (IS_ERR(link)) | |
2770 | return PTR_ERR(link); | |
2771 | ||
2772 | if (!sdata_dereference(link->u.ap.beacon, sdata)) | |
55de908a JB |
2773 | return -ENOENT; |
2774 | ||
9a886df0 | 2775 | sband = ieee80211_get_link_sband(link); |
21a8e9dd MSS |
2776 | if (!sband) |
2777 | return -EINVAL; | |
9f1ba906 | 2778 | |
ce04abc3 | 2779 | if (params->basic_rates) { |
6092077a | 2780 | if (!ieee80211_parse_bitrates(link->conf->chanreq.oper.width, |
ce04abc3 JB |
2781 | wiphy->bands[sband->band], |
2782 | params->basic_rates, | |
2783 | params->basic_rates_len, | |
2784 | &link->conf->basic_rates)) | |
2785 | return -EINVAL; | |
2786 | changed |= BSS_CHANGED_BASIC_RATES; | |
2787 | ieee80211_check_rate_mask(link); | |
2788 | } | |
2789 | ||
9f1ba906 | 2790 | if (params->use_cts_prot >= 0) { |
9a886df0 | 2791 | link->conf->use_cts_prot = params->use_cts_prot; |
9f1ba906 JM |
2792 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
2793 | } | |
2794 | if (params->use_short_preamble >= 0) { | |
9a886df0 | 2795 | link->conf->use_short_preamble = params->use_short_preamble; |
9f1ba906 JM |
2796 | changed |= BSS_CHANGED_ERP_PREAMBLE; |
2797 | } | |
43d35343 | 2798 | |
9a886df0 | 2799 | if (!link->conf->use_short_slot && |
07c12d61 TM |
2800 | (sband->band == NL80211_BAND_5GHZ || |
2801 | sband->band == NL80211_BAND_6GHZ)) { | |
9a886df0 | 2802 | link->conf->use_short_slot = true; |
43d35343 FF |
2803 | changed |= BSS_CHANGED_ERP_SLOT; |
2804 | } | |
2805 | ||
9f1ba906 | 2806 | if (params->use_short_slot_time >= 0) { |
9a886df0 | 2807 | link->conf->use_short_slot = params->use_short_slot_time; |
9f1ba906 JM |
2808 | changed |= BSS_CHANGED_ERP_SLOT; |
2809 | } | |
2810 | ||
7b7b5e56 FF |
2811 | if (params->ap_isolate >= 0) { |
2812 | if (params->ap_isolate) | |
2813 | sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS; | |
2814 | else | |
2815 | sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS; | |
49ddf8e6 | 2816 | ieee80211_check_fast_rx_iface(sdata); |
7b7b5e56 FF |
2817 | } |
2818 | ||
80d7e403 | 2819 | if (params->ht_opmode >= 0) { |
9a886df0 | 2820 | link->conf->ht_operation_mode = (u16)params->ht_opmode; |
80d7e403 HS |
2821 | changed |= BSS_CHANGED_HT; |
2822 | } | |
2823 | ||
339afbf4 | 2824 | if (params->p2p_ctwindow >= 0) { |
9a886df0 | 2825 | link->conf->p2p_noa_attr.oppps_ctwindow &= |
67baf663 | 2826 | ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK; |
9a886df0 | 2827 | link->conf->p2p_noa_attr.oppps_ctwindow |= |
67baf663 | 2828 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; |
339afbf4 JB |
2829 | changed |= BSS_CHANGED_P2P_PS; |
2830 | } | |
2831 | ||
67baf663 | 2832 | if (params->p2p_opp_ps > 0) { |
9a886df0 | 2833 | link->conf->p2p_noa_attr.oppps_ctwindow |= |
67baf663 JD |
2834 | IEEE80211_P2P_OPPPS_ENABLE_BIT; |
2835 | changed |= BSS_CHANGED_P2P_PS; | |
2836 | } else if (params->p2p_opp_ps == 0) { | |
9a886df0 | 2837 | link->conf->p2p_noa_attr.oppps_ctwindow &= |
67baf663 | 2838 | ~IEEE80211_P2P_OPPPS_ENABLE_BIT; |
339afbf4 JB |
2839 | changed |= BSS_CHANGED_P2P_PS; |
2840 | } | |
2841 | ||
9a886df0 | 2842 | ieee80211_link_info_change_notify(sdata, link, changed); |
9f1ba906 JM |
2843 | |
2844 | return 0; | |
2845 | } | |
2846 | ||
31888487 | 2847 | static int ieee80211_set_txq_params(struct wiphy *wiphy, |
f70f01c2 | 2848 | struct net_device *dev, |
31888487 JM |
2849 | struct ieee80211_txq_params *params) |
2850 | { | |
2851 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
f6f3def3 | 2852 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
c88f1542 | 2853 | struct ieee80211_link_data *link = |
ccdde7c7 | 2854 | ieee80211_link_or_deflink(sdata, params->link_id, true); |
31888487 JM |
2855 | struct ieee80211_tx_queue_params p; |
2856 | ||
2857 | if (!local->ops->conf_tx) | |
2858 | return -EOPNOTSUPP; | |
2859 | ||
54bcbc69 JB |
2860 | if (local->hw.queues < IEEE80211_NUM_ACS) |
2861 | return -EOPNOTSUPP; | |
2862 | ||
c88f1542 ST |
2863 | if (IS_ERR(link)) |
2864 | return PTR_ERR(link); | |
2865 | ||
31888487 JM |
2866 | memset(&p, 0, sizeof(p)); |
2867 | p.aifs = params->aifs; | |
2868 | p.cw_max = params->cwmax; | |
2869 | p.cw_min = params->cwmin; | |
2870 | p.txop = params->txop; | |
ab13315a KV |
2871 | |
2872 | /* | |
2873 | * Setting tx queue params disables u-apsd because it's only | |
2874 | * called in master mode. | |
2875 | */ | |
2876 | p.uapsd = false; | |
2877 | ||
e552af05 HD |
2878 | ieee80211_regulatory_limit_wmm_params(sdata, &p, params->ac); |
2879 | ||
b3e2130b JB |
2880 | link->tx_conf[params->ac] = p; |
2881 | if (drv_conf_tx(local, link, params->ac, &p)) { | |
0fb9a9ec | 2882 | wiphy_debug(local->hw.wiphy, |
a3304b0a JB |
2883 | "failed to set TX queue parameters for AC %d\n", |
2884 | params->ac); | |
31888487 JM |
2885 | return -EINVAL; |
2886 | } | |
2887 | ||
b3e2130b | 2888 | ieee80211_link_info_change_notify(sdata, link, |
d8675a63 | 2889 | BSS_CHANGED_QOS); |
7d25745d | 2890 | |
31888487 JM |
2891 | return 0; |
2892 | } | |
2893 | ||
665af4fc | 2894 | #ifdef CONFIG_PM |
ff1b6e69 JB |
2895 | static int ieee80211_suspend(struct wiphy *wiphy, |
2896 | struct cfg80211_wowlan *wowlan) | |
665af4fc | 2897 | { |
eecc4800 | 2898 | return __ieee80211_suspend(wiphy_priv(wiphy), wowlan); |
665af4fc BC |
2899 | } |
2900 | ||
2901 | static int ieee80211_resume(struct wiphy *wiphy) | |
2902 | { | |
2903 | return __ieee80211_resume(wiphy_priv(wiphy)); | |
2904 | } | |
2905 | #else | |
2906 | #define ieee80211_suspend NULL | |
2907 | #define ieee80211_resume NULL | |
2908 | #endif | |
2909 | ||
2a519311 | 2910 | static int ieee80211_scan(struct wiphy *wiphy, |
2a519311 JB |
2911 | struct cfg80211_scan_request *req) |
2912 | { | |
fd014284 JB |
2913 | struct ieee80211_sub_if_data *sdata; |
2914 | ||
2915 | sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev); | |
2a519311 | 2916 | |
2ca27bcf JB |
2917 | switch (ieee80211_vif_type_p2p(&sdata->vif)) { |
2918 | case NL80211_IFTYPE_STATION: | |
2919 | case NL80211_IFTYPE_ADHOC: | |
2920 | case NL80211_IFTYPE_MESH_POINT: | |
2921 | case NL80211_IFTYPE_P2P_CLIENT: | |
f142c6b9 | 2922 | case NL80211_IFTYPE_P2P_DEVICE: |
2ca27bcf JB |
2923 | break; |
2924 | case NL80211_IFTYPE_P2P_GO: | |
2925 | if (sdata->local->ops->hw_scan) | |
2926 | break; | |
e9d7732e JB |
2927 | /* |
2928 | * FIXME: implement NoA while scanning in software, | |
2929 | * for now fall through to allow scanning only when | |
2930 | * beaconing hasn't been configured yet | |
2931 | */ | |
fc0561dc | 2932 | fallthrough; |
2ca27bcf | 2933 | case NL80211_IFTYPE_AP: |
5c95b940 AQ |
2934 | /* |
2935 | * If the scan has been forced (and the driver supports | |
2936 | * forcing), don't care about being beaconing already. | |
2937 | * This will create problems to the attached stations (e.g. all | |
71a659bf | 2938 | * the frames sent while scanning on other channel will be |
5c95b940 AQ |
2939 | * lost) |
2940 | */ | |
78a7a126 | 2941 | if (ieee80211_num_beaconing_links(sdata) && |
5c95b940 AQ |
2942 | (!(wiphy->features & NL80211_FEATURE_AP_SCAN) || |
2943 | !(req->flags & NL80211_SCAN_FLAG_AP))) | |
2ca27bcf JB |
2944 | return -EOPNOTSUPP; |
2945 | break; | |
cb3b7d87 | 2946 | case NL80211_IFTYPE_NAN: |
2ca27bcf JB |
2947 | default: |
2948 | return -EOPNOTSUPP; | |
2949 | } | |
2a519311 JB |
2950 | |
2951 | return ieee80211_request_scan(sdata, req); | |
2952 | } | |
2953 | ||
91f123f2 VK |
2954 | static void ieee80211_abort_scan(struct wiphy *wiphy, struct wireless_dev *wdev) |
2955 | { | |
2956 | ieee80211_scan_cancel(wiphy_priv(wiphy)); | |
2957 | } | |
2958 | ||
79f460ca LC |
2959 | static int |
2960 | ieee80211_sched_scan_start(struct wiphy *wiphy, | |
2961 | struct net_device *dev, | |
2962 | struct cfg80211_sched_scan_request *req) | |
2963 | { | |
2964 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2965 | ||
2966 | if (!sdata->local->ops->sched_scan_start) | |
2967 | return -EOPNOTSUPP; | |
2968 | ||
2969 | return ieee80211_request_sched_scan_start(sdata, req); | |
2970 | } | |
2971 | ||
2972 | static int | |
3a3ecf1d AVS |
2973 | ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev, |
2974 | u64 reqid) | |
79f460ca | 2975 | { |
0d440ea2 | 2976 | struct ieee80211_local *local = wiphy_priv(wiphy); |
79f460ca | 2977 | |
0d440ea2 | 2978 | if (!local->ops->sched_scan_stop) |
79f460ca LC |
2979 | return -EOPNOTSUPP; |
2980 | ||
0d440ea2 | 2981 | return ieee80211_request_sched_scan_stop(local); |
79f460ca LC |
2982 | } |
2983 | ||
636a5d36 JM |
2984 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
2985 | struct cfg80211_auth_request *req) | |
2986 | { | |
77fdaa12 | 2987 | return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
2988 | } |
2989 | ||
2990 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, | |
2991 | struct cfg80211_assoc_request *req) | |
2992 | { | |
77fdaa12 | 2993 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
2994 | } |
2995 | ||
2996 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, | |
63c9c5e7 | 2997 | struct cfg80211_deauth_request *req) |
636a5d36 | 2998 | { |
63c9c5e7 | 2999 | return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
3000 | } |
3001 | ||
3002 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, | |
63c9c5e7 | 3003 | struct cfg80211_disassoc_request *req) |
636a5d36 | 3004 | { |
63c9c5e7 | 3005 | return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
3006 | } |
3007 | ||
af8cdcd8 JB |
3008 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
3009 | struct cfg80211_ibss_params *params) | |
3010 | { | |
55de908a | 3011 | return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params); |
af8cdcd8 JB |
3012 | } |
3013 | ||
3014 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) | |
3015 | { | |
55de908a | 3016 | return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev)); |
af8cdcd8 JB |
3017 | } |
3018 | ||
239281f8 RL |
3019 | static int ieee80211_join_ocb(struct wiphy *wiphy, struct net_device *dev, |
3020 | struct ocb_setup *setup) | |
3021 | { | |
3022 | return ieee80211_ocb_join(IEEE80211_DEV_TO_SUB_IF(dev), setup); | |
3023 | } | |
3024 | ||
3025 | static int ieee80211_leave_ocb(struct wiphy *wiphy, struct net_device *dev) | |
3026 | { | |
3027 | return ieee80211_ocb_leave(IEEE80211_DEV_TO_SUB_IF(dev)); | |
3028 | } | |
3029 | ||
391e53e3 | 3030 | static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, |
57fbcce3 | 3031 | int rate[NUM_NL80211_BANDS]) |
391e53e3 AQ |
3032 | { |
3033 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3034 | ||
9887dbf5 | 3035 | memcpy(sdata->vif.bss_conf.mcast_rate, rate, |
57fbcce3 | 3036 | sizeof(int) * NUM_NL80211_BANDS); |
391e53e3 | 3037 | |
02c665f0 JB |
3038 | if (ieee80211_sdata_running(sdata)) |
3039 | ieee80211_link_info_change_notify(sdata, &sdata->deflink, | |
3040 | BSS_CHANGED_MCAST_RATE); | |
dcbe73ca | 3041 | |
391e53e3 AQ |
3042 | return 0; |
3043 | } | |
3044 | ||
b9a5f8ca JM |
3045 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
3046 | { | |
3047 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
24487981 | 3048 | int err; |
b9a5f8ca | 3049 | |
f23a4780 | 3050 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
17c18bf8 JB |
3051 | ieee80211_check_fast_xmit_all(local); |
3052 | ||
f23a4780 AN |
3053 | err = drv_set_frag_threshold(local, wiphy->frag_threshold); |
3054 | ||
17c18bf8 JB |
3055 | if (err) { |
3056 | ieee80211_check_fast_xmit_all(local); | |
f23a4780 | 3057 | return err; |
17c18bf8 | 3058 | } |
f23a4780 AN |
3059 | } |
3060 | ||
a4bcaf55 LB |
3061 | if ((changed & WIPHY_PARAM_COVERAGE_CLASS) || |
3062 | (changed & WIPHY_PARAM_DYN_ACK)) { | |
3063 | s16 coverage_class; | |
3064 | ||
3065 | coverage_class = changed & WIPHY_PARAM_COVERAGE_CLASS ? | |
3066 | wiphy->coverage_class : -1; | |
3067 | err = drv_set_coverage_class(local, coverage_class); | |
310bc676 LT |
3068 | |
3069 | if (err) | |
3070 | return err; | |
3071 | } | |
3072 | ||
b9a5f8ca | 3073 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
24487981 | 3074 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
b9a5f8ca | 3075 | |
24487981 JB |
3076 | if (err) |
3077 | return err; | |
b9a5f8ca JM |
3078 | } |
3079 | ||
8bc83c24 JB |
3080 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
3081 | if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY) | |
3082 | return -EINVAL; | |
b9a5f8ca | 3083 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
8bc83c24 JB |
3084 | } |
3085 | if (changed & WIPHY_PARAM_RETRY_LONG) { | |
3086 | if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY) | |
3087 | return -EINVAL; | |
b9a5f8ca | 3088 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
8bc83c24 | 3089 | } |
b9a5f8ca JM |
3090 | if (changed & |
3091 | (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) | |
3092 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); | |
3093 | ||
2fe4a29a THJ |
3094 | if (changed & (WIPHY_PARAM_TXQ_LIMIT | |
3095 | WIPHY_PARAM_TXQ_MEMORY_LIMIT | | |
3096 | WIPHY_PARAM_TXQ_QUANTUM)) | |
3097 | ieee80211_txq_set_params(local); | |
3098 | ||
b9a5f8ca JM |
3099 | return 0; |
3100 | } | |
3101 | ||
7643a2c3 | 3102 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
c8442118 | 3103 | struct wireless_dev *wdev, |
fa61cf70 | 3104 | enum nl80211_tx_power_setting type, int mbm) |
7643a2c3 JB |
3105 | { |
3106 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
1ea6f9c0 | 3107 | struct ieee80211_sub_if_data *sdata; |
db82d8a9 LB |
3108 | enum nl80211_tx_power_setting txp_type = type; |
3109 | bool update_txp_type = false; | |
3a3713ec | 3110 | bool has_monitor = false; |
c4382d5c | 3111 | int user_power_level; |
8dd04989 | 3112 | int old_power = local->user_power_level; |
7643a2c3 | 3113 | |
be0df01d JB |
3114 | lockdep_assert_wiphy(local->hw.wiphy); |
3115 | ||
c4382d5c EG |
3116 | switch (type) { |
3117 | case NL80211_TX_POWER_AUTOMATIC: | |
3118 | user_power_level = IEEE80211_UNSET_POWER_LEVEL; | |
3119 | txp_type = NL80211_TX_POWER_LIMITED; | |
3120 | break; | |
3121 | case NL80211_TX_POWER_LIMITED: | |
3122 | case NL80211_TX_POWER_FIXED: | |
3123 | if (mbm < 0 || (mbm % 100)) | |
3124 | return -EOPNOTSUPP; | |
3125 | user_power_level = MBM_TO_DBM(mbm); | |
3126 | break; | |
3127 | default: | |
3128 | return -EINVAL; | |
3129 | } | |
3130 | ||
1ea6f9c0 JB |
3131 | if (wdev) { |
3132 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
3133 | ||
9d40f7e3 FF |
3134 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
3135 | !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) { | |
8f4fa087 JB |
3136 | if (!ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) |
3137 | return -EOPNOTSUPP; | |
3138 | ||
6dd23603 JB |
3139 | sdata = wiphy_dereference(local->hw.wiphy, |
3140 | local->monitor_sdata); | |
3a3713ec PG |
3141 | if (!sdata) |
3142 | return -EOPNOTSUPP; | |
3143 | } | |
3144 | ||
c4382d5c EG |
3145 | for (int link_id = 0; |
3146 | link_id < ARRAY_SIZE(sdata->link); | |
3147 | link_id++) { | |
3148 | struct ieee80211_link_data *link = | |
3149 | wiphy_dereference(wiphy, sdata->link[link_id]); | |
1ea6f9c0 | 3150 | |
c4382d5c EG |
3151 | if (!link) |
3152 | continue; | |
3153 | ||
3154 | link->user_power_level = user_power_level; | |
db82d8a9 | 3155 | |
c4382d5c EG |
3156 | if (txp_type != link->conf->txpower_type) { |
3157 | update_txp_type = true; | |
3158 | link->conf->txpower_type = txp_type; | |
3159 | } | |
1ea6f9c0 | 3160 | |
c4382d5c EG |
3161 | ieee80211_recalc_txpower(link, update_txp_type); |
3162 | } | |
1ea6f9c0 JB |
3163 | return 0; |
3164 | } | |
55de908a | 3165 | |
c4382d5c | 3166 | local->user_power_level = user_power_level; |
7643a2c3 | 3167 | |
db82d8a9 | 3168 | list_for_each_entry(sdata, &local->interfaces, list) { |
9d40f7e3 FF |
3169 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
3170 | !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) { | |
3a3713ec PG |
3171 | has_monitor = true; |
3172 | continue; | |
3173 | } | |
c4382d5c EG |
3174 | |
3175 | for (int link_id = 0; | |
3176 | link_id < ARRAY_SIZE(sdata->link); | |
3177 | link_id++) { | |
3178 | struct ieee80211_link_data *link = | |
3179 | wiphy_dereference(wiphy, sdata->link[link_id]); | |
3180 | ||
3181 | if (!link) | |
3182 | continue; | |
3183 | ||
3184 | link->user_power_level = local->user_power_level; | |
3185 | if (txp_type != link->conf->txpower_type) | |
3186 | update_txp_type = true; | |
3187 | link->conf->txpower_type = txp_type; | |
3188 | } | |
db82d8a9 | 3189 | } |
3a3713ec | 3190 | list_for_each_entry(sdata, &local->interfaces, list) { |
9d40f7e3 FF |
3191 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR && |
3192 | !ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) | |
3a3713ec | 3193 | continue; |
c4382d5c EG |
3194 | |
3195 | for (int link_id = 0; | |
3196 | link_id < ARRAY_SIZE(sdata->link); | |
3197 | link_id++) { | |
3198 | struct ieee80211_link_data *link = | |
3199 | wiphy_dereference(wiphy, sdata->link[link_id]); | |
3200 | ||
3201 | if (!link) | |
3202 | continue; | |
3203 | ||
3204 | ieee80211_recalc_txpower(link, update_txp_type); | |
3205 | } | |
3a3713ec | 3206 | } |
7643a2c3 | 3207 | |
3a3713ec | 3208 | if (has_monitor) { |
6dd23603 JB |
3209 | sdata = wiphy_dereference(local->hw.wiphy, |
3210 | local->monitor_sdata); | |
8f4fa087 | 3211 | if (sdata && ieee80211_hw_check(&local->hw, WANT_MONITOR_VIF)) { |
bfd8403a | 3212 | sdata->deflink.user_power_level = local->user_power_level; |
3a3713ec PG |
3213 | if (txp_type != sdata->vif.bss_conf.txpower_type) |
3214 | update_txp_type = true; | |
3215 | sdata->vif.bss_conf.txpower_type = txp_type; | |
3216 | ||
9925aa85 EG |
3217 | ieee80211_recalc_txpower(&sdata->deflink, |
3218 | update_txp_type); | |
3a3713ec PG |
3219 | } |
3220 | } | |
3221 | ||
8dd04989 BG |
3222 | if (local->emulate_chanctx && |
3223 | (old_power != local->user_power_level)) | |
3224 | ieee80211_hw_conf_chan(local); | |
3225 | ||
7643a2c3 JB |
3226 | return 0; |
3227 | } | |
3228 | ||
c8442118 JB |
3229 | static int ieee80211_get_tx_power(struct wiphy *wiphy, |
3230 | struct wireless_dev *wdev, | |
7a53af85 | 3231 | unsigned int link_id, |
c8442118 | 3232 | int *dbm) |
7643a2c3 JB |
3233 | { |
3234 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
1ea6f9c0 | 3235 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
24dab555 | 3236 | struct ieee80211_link_data *link_data; |
7643a2c3 | 3237 | |
393b6bc1 FF |
3238 | if (local->ops->get_txpower && |
3239 | (sdata->flags & IEEE80211_SDATA_IN_DRIVER)) | |
24dab555 | 3240 | return drv_get_txpower(local, sdata, link_id, dbm); |
5b3dc42b | 3241 | |
24dab555 | 3242 | if (local->emulate_chanctx) { |
1ea6f9c0 | 3243 | *dbm = local->hw.conf.power_level; |
24dab555 RS |
3244 | } else { |
3245 | link_data = wiphy_dereference(wiphy, sdata->link[link_id]); | |
3246 | ||
3247 | if (link_data) | |
3248 | *dbm = link_data->conf->txpower; | |
3249 | else | |
3250 | return -ENOLINK; | |
3251 | } | |
7643a2c3 | 3252 | |
e160ab85 PKS |
3253 | /* INT_MIN indicates no power level was set yet */ |
3254 | if (*dbm == INT_MIN) | |
3255 | return -EINVAL; | |
3256 | ||
7643a2c3 JB |
3257 | return 0; |
3258 | } | |
3259 | ||
1f87f7d3 JB |
3260 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) |
3261 | { | |
3262 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3263 | ||
3264 | drv_rfkill_poll(local); | |
3265 | } | |
3266 | ||
aff89a9b | 3267 | #ifdef CONFIG_NL80211_TESTMODE |
fc73f11f DS |
3268 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, |
3269 | struct wireless_dev *wdev, | |
3270 | void *data, int len) | |
aff89a9b JB |
3271 | { |
3272 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
52981cd7 | 3273 | struct ieee80211_vif *vif = NULL; |
aff89a9b JB |
3274 | |
3275 | if (!local->ops->testmode_cmd) | |
3276 | return -EOPNOTSUPP; | |
3277 | ||
52981cd7 DS |
3278 | if (wdev) { |
3279 | struct ieee80211_sub_if_data *sdata; | |
3280 | ||
3281 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
3282 | if (sdata->flags & IEEE80211_SDATA_IN_DRIVER) | |
3283 | vif = &sdata->vif; | |
3284 | } | |
3285 | ||
3286 | return local->ops->testmode_cmd(&local->hw, vif, data, len); | |
aff89a9b | 3287 | } |
71063f0e WYG |
3288 | |
3289 | static int ieee80211_testmode_dump(struct wiphy *wiphy, | |
3290 | struct sk_buff *skb, | |
3291 | struct netlink_callback *cb, | |
3292 | void *data, int len) | |
3293 | { | |
3294 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3295 | ||
3296 | if (!local->ops->testmode_dump) | |
3297 | return -EOPNOTSUPP; | |
3298 | ||
3299 | return local->ops->testmode_dump(&local->hw, skb, cb, data, len); | |
3300 | } | |
aff89a9b JB |
3301 | #endif |
3302 | ||
687da132 | 3303 | int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata, |
d8675a63 | 3304 | struct ieee80211_link_data *link, |
687da132 | 3305 | enum ieee80211_smps_mode smps_mode) |
0f78231b JB |
3306 | { |
3307 | const u8 *ap; | |
3308 | enum ieee80211_smps_mode old_req; | |
3309 | int err; | |
d51c2ea3 AN |
3310 | struct sta_info *sta; |
3311 | bool tdls_peer_found = false; | |
0f78231b | 3312 | |
076fc877 | 3313 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
243e6df4 | 3314 | |
687da132 EG |
3315 | if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) |
3316 | return -EINVAL; | |
3317 | ||
68f6c6af | 3318 | if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) |
e665ab9c IP |
3319 | return 0; |
3320 | ||
d8675a63 JB |
3321 | old_req = link->u.mgd.req_smps; |
3322 | link->u.mgd.req_smps = smps_mode; | |
0f78231b | 3323 | |
00f823b6 IP |
3324 | /* The driver indicated that EML is enabled for the interface, which |
3325 | * implies that SMPS flows towards the AP should be stopped. | |
3326 | */ | |
3327 | if (sdata->vif.driver_flags & IEEE80211_VIF_EML_ACTIVE) | |
3328 | return 0; | |
3329 | ||
0f78231b JB |
3330 | if (old_req == smps_mode && |
3331 | smps_mode != IEEE80211_SMPS_AUTOMATIC) | |
3332 | return 0; | |
3333 | ||
3334 | /* | |
3335 | * If not associated, or current association is not an HT | |
04ecd257 JB |
3336 | * association, there's no need to do anything, just store |
3337 | * the new value until we associate. | |
0f78231b JB |
3338 | */ |
3339 | if (!sdata->u.mgd.associated || | |
6092077a | 3340 | link->conf->chanreq.oper.width == NL80211_CHAN_WIDTH_20_NOHT) |
0f78231b | 3341 | return 0; |
0f78231b | 3342 | |
e665ab9c | 3343 | ap = sdata->vif.cfg.ap_addr; |
0f78231b | 3344 | |
d51c2ea3 AN |
3345 | rcu_read_lock(); |
3346 | list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) { | |
3347 | if (!sta->sta.tdls || sta->sdata != sdata || !sta->uploaded || | |
3348 | !test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
3349 | continue; | |
3350 | ||
3351 | tdls_peer_found = true; | |
3352 | break; | |
3353 | } | |
3354 | rcu_read_unlock(); | |
3355 | ||
0f78231b | 3356 | if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { |
d51c2ea3 | 3357 | if (tdls_peer_found || !sdata->u.mgd.powersave) |
0f78231b | 3358 | smps_mode = IEEE80211_SMPS_OFF; |
d51c2ea3 AN |
3359 | else |
3360 | smps_mode = IEEE80211_SMPS_DYNAMIC; | |
0f78231b JB |
3361 | } |
3362 | ||
3363 | /* send SM PS frame to AP */ | |
3364 | err = ieee80211_send_smps_action(sdata, smps_mode, | |
e665ab9c IP |
3365 | ap, ap, |
3366 | ieee80211_vif_is_mld(&sdata->vif) ? | |
3367 | link->link_id : -1); | |
0f78231b | 3368 | if (err) |
d8675a63 | 3369 | link->u.mgd.req_smps = old_req; |
d51c2ea3 | 3370 | else if (smps_mode != IEEE80211_SMPS_OFF && tdls_peer_found) |
85977fc0 | 3371 | ieee80211_teardown_tdls_peers(link); |
0f78231b JB |
3372 | |
3373 | return err; | |
3374 | } | |
3375 | ||
bc92afd9 JB |
3376 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
3377 | bool enabled, int timeout) | |
3378 | { | |
3379 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3380 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
e9aac179 | 3381 | unsigned int link_id; |
bc92afd9 | 3382 | |
2d3db210 | 3383 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
e5de30c9 BP |
3384 | return -EOPNOTSUPP; |
3385 | ||
30686bf7 | 3386 | if (!ieee80211_hw_check(&local->hw, SUPPORTS_PS)) |
bc92afd9 JB |
3387 | return -EOPNOTSUPP; |
3388 | ||
3389 | if (enabled == sdata->u.mgd.powersave && | |
ff616381 | 3390 | timeout == local->dynamic_ps_forced_timeout) |
bc92afd9 JB |
3391 | return 0; |
3392 | ||
3393 | sdata->u.mgd.powersave = enabled; | |
ff616381 | 3394 | local->dynamic_ps_forced_timeout = timeout; |
bc92afd9 | 3395 | |
0f78231b | 3396 | /* no change, but if automatic follow powersave */ |
e9aac179 | 3397 | for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) { |
d8675a63 JB |
3398 | struct ieee80211_link_data *link; |
3399 | ||
3400 | link = sdata_dereference(sdata->link[link_id], sdata); | |
3401 | ||
3402 | if (!link) | |
e9aac179 | 3403 | continue; |
d8675a63 JB |
3404 | __ieee80211_request_smps_mgd(sdata, link, |
3405 | link->u.mgd.req_smps); | |
e9aac179 | 3406 | } |
0f78231b | 3407 | |
30686bf7 | 3408 | if (ieee80211_hw_check(&local->hw, SUPPORTS_DYNAMIC_PS)) |
bc92afd9 JB |
3409 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); |
3410 | ||
4a733ef1 | 3411 | ieee80211_recalc_ps(local); |
ab095877 | 3412 | ieee80211_recalc_ps_vif(sdata); |
1d870162 | 3413 | ieee80211_check_fast_rx_iface(sdata); |
bc92afd9 JB |
3414 | |
3415 | return 0; | |
3416 | } | |
3417 | ||
0e3a2238 IP |
3418 | static void ieee80211_set_cqm_rssi_link(struct ieee80211_sub_if_data *sdata, |
3419 | struct ieee80211_link_data *link, | |
3420 | s32 rssi_thold, u32 rssi_hyst, | |
3421 | s32 rssi_low, s32 rssi_high) | |
3422 | { | |
3423 | struct ieee80211_bss_conf *conf; | |
3424 | ||
3425 | if (!link || !link->conf) | |
3426 | return; | |
3427 | ||
3428 | conf = link->conf; | |
3429 | ||
3430 | if (rssi_thold && rssi_hyst && | |
3431 | rssi_thold == conf->cqm_rssi_thold && | |
3432 | rssi_hyst == conf->cqm_rssi_hyst) | |
3433 | return; | |
3434 | ||
3435 | conf->cqm_rssi_thold = rssi_thold; | |
3436 | conf->cqm_rssi_hyst = rssi_hyst; | |
3437 | conf->cqm_rssi_low = rssi_low; | |
3438 | conf->cqm_rssi_high = rssi_high; | |
3439 | link->u.mgd.last_cqm_event_signal = 0; | |
3440 | ||
3441 | if (!ieee80211_vif_link_active(&sdata->vif, link->link_id)) | |
3442 | return; | |
3443 | ||
3444 | if (sdata->u.mgd.associated && | |
3445 | (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) | |
3446 | ieee80211_link_info_change_notify(sdata, link, BSS_CHANGED_CQM); | |
3447 | } | |
3448 | ||
a97c13c3 JO |
3449 | static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, |
3450 | struct net_device *dev, | |
3451 | s32 rssi_thold, u32 rssi_hyst) | |
3452 | { | |
3453 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
a97c13c3 | 3454 | struct ieee80211_vif *vif = &sdata->vif; |
0e3a2238 | 3455 | int link_id; |
a97c13c3 | 3456 | |
0e3a2238 IP |
3457 | if (vif->driver_flags & IEEE80211_VIF_BEACON_FILTER && |
3458 | !(vif->driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)) | |
ef9be10c JB |
3459 | return -EOPNOTSUPP; |
3460 | ||
0e3a2238 IP |
3461 | /* For MLD, handle CQM change on all the active links */ |
3462 | for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { | |
3463 | struct ieee80211_link_data *link = | |
3464 | sdata_dereference(sdata->link[link_id], sdata); | |
2c3c5f8c | 3465 | |
0e3a2238 IP |
3466 | ieee80211_set_cqm_rssi_link(sdata, link, rssi_thold, rssi_hyst, |
3467 | 0, 0); | |
3468 | } | |
2c3c5f8c AZ |
3469 | |
3470 | return 0; | |
3471 | } | |
3472 | ||
3473 | static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy, | |
3474 | struct net_device *dev, | |
3475 | s32 rssi_low, s32 rssi_high) | |
3476 | { | |
3477 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3478 | struct ieee80211_vif *vif = &sdata->vif; | |
0e3a2238 | 3479 | int link_id; |
2c3c5f8c | 3480 | |
0e3a2238 | 3481 | if (vif->driver_flags & IEEE80211_VIF_BEACON_FILTER) |
2c3c5f8c AZ |
3482 | return -EOPNOTSUPP; |
3483 | ||
0e3a2238 IP |
3484 | /* For MLD, handle CQM change on all the active links */ |
3485 | for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { | |
3486 | struct ieee80211_link_data *link = | |
3487 | sdata_dereference(sdata->link[link_id], sdata); | |
a97c13c3 | 3488 | |
0e3a2238 IP |
3489 | ieee80211_set_cqm_rssi_link(sdata, link, 0, 0, |
3490 | rssi_low, rssi_high); | |
3491 | } | |
a97c13c3 JO |
3492 | |
3493 | return 0; | |
3494 | } | |
3495 | ||
9930380f JB |
3496 | static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, |
3497 | struct net_device *dev, | |
7b0a0e3c | 3498 | unsigned int link_id, |
9930380f JB |
3499 | const u8 *addr, |
3500 | const struct cfg80211_bitrate_mask *mask) | |
3501 | { | |
3502 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3503 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
bdbfd6b5 | 3504 | int i, ret; |
2c7e6bc9 | 3505 | |
554a43d5 EP |
3506 | if (!ieee80211_sdata_running(sdata)) |
3507 | return -ENETDOWN; | |
3508 | ||
e8e4f528 JB |
3509 | /* |
3510 | * If active validate the setting and reject it if it doesn't leave | |
3511 | * at least one basic rate usable, since we really have to be able | |
3512 | * to send something, and if we're an AP we have to be able to do | |
3513 | * so at a basic rate so that all clients can receive it. | |
3514 | */ | |
d0a9123e | 3515 | if (rcu_access_pointer(sdata->vif.bss_conf.chanctx_conf) && |
6092077a | 3516 | sdata->vif.bss_conf.chanreq.oper.chan) { |
e8e4f528 | 3517 | u32 basic_rates = sdata->vif.bss_conf.basic_rates; |
6092077a JB |
3518 | enum nl80211_band band; |
3519 | ||
3520 | band = sdata->vif.bss_conf.chanreq.oper.chan->band; | |
e8e4f528 JB |
3521 | |
3522 | if (!(mask->control[band].legacy & basic_rates)) | |
3523 | return -EINVAL; | |
3524 | } | |
3525 | ||
e5f5ce37 JB |
3526 | if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { |
3527 | ret = drv_set_bitrate_mask(local, sdata, mask); | |
3528 | if (ret) | |
3529 | return ret; | |
3530 | } | |
3531 | ||
57fbcce3 | 3532 | for (i = 0; i < NUM_NL80211_BANDS; i++) { |
2ffbe6d3 FF |
3533 | struct ieee80211_supported_band *sband = wiphy->bands[i]; |
3534 | int j; | |
3535 | ||
37eb0b16 | 3536 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
d1e33e65 JD |
3537 | memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs, |
3538 | sizeof(mask->control[i].ht_mcs)); | |
b119ad6e LB |
3539 | memcpy(sdata->rc_rateidx_vht_mcs_mask[i], |
3540 | mask->control[i].vht_mcs, | |
3541 | sizeof(mask->control[i].vht_mcs)); | |
2ffbe6d3 FF |
3542 | |
3543 | sdata->rc_has_mcs_mask[i] = false; | |
b119ad6e | 3544 | sdata->rc_has_vht_mcs_mask[i] = false; |
2ffbe6d3 FF |
3545 | if (!sband) |
3546 | continue; | |
3547 | ||
b119ad6e | 3548 | for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) { |
1944015f | 3549 | if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) { |
2ffbe6d3 | 3550 | sdata->rc_has_mcs_mask[i] = true; |
2df1b131 JB |
3551 | break; |
3552 | } | |
3553 | } | |
b119ad6e | 3554 | |
2df1b131 | 3555 | for (j = 0; j < NL80211_VHT_NSS_MAX; j++) { |
1944015f | 3556 | if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) { |
b119ad6e | 3557 | sdata->rc_has_vht_mcs_mask[i] = true; |
2ffbe6d3 | 3558 | break; |
2df1b131 | 3559 | } |
b119ad6e | 3560 | } |
19468413 | 3561 | } |
9930380f | 3562 | |
37eb0b16 | 3563 | return 0; |
9930380f JB |
3564 | } |
3565 | ||
164eb02d SW |
3566 | static int ieee80211_start_radar_detection(struct wiphy *wiphy, |
3567 | struct net_device *dev, | |
31559f35 | 3568 | struct cfg80211_chan_def *chandef, |
81f67d60 | 3569 | u32 cac_time_ms, int link_id) |
164eb02d SW |
3570 | { |
3571 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
6092077a | 3572 | struct ieee80211_chan_req chanreq = { .oper = *chandef }; |
164eb02d | 3573 | struct ieee80211_local *local = sdata->local; |
d74380ee | 3574 | struct ieee80211_link_data *link_data; |
164eb02d SW |
3575 | int err; |
3576 | ||
0cd8080e JB |
3577 | lockdep_assert_wiphy(local->hw.wiphy); |
3578 | ||
f403fed7 AKS |
3579 | if (!list_empty(&local->roc_list) || local->scanning) |
3580 | return -EBUSY; | |
164eb02d | 3581 | |
d74380ee AKS |
3582 | link_data = sdata_dereference(sdata->link[link_id], sdata); |
3583 | if (!link_data) | |
3584 | return -ENOLINK; | |
3585 | ||
164eb02d | 3586 | /* whatever, but channel contexts should not complain about that one */ |
d74380ee AKS |
3587 | link_data->smps_mode = IEEE80211_SMPS_OFF; |
3588 | link_data->needed_rx_chains = local->rx_chains; | |
164eb02d | 3589 | |
d74380ee | 3590 | err = ieee80211_link_use_channel(link_data, &chanreq, |
b4f85443 | 3591 | IEEE80211_CHANCTX_SHARED); |
164eb02d | 3592 | if (err) |
f403fed7 | 3593 | return err; |
164eb02d | 3594 | |
d74380ee | 3595 | wiphy_delayed_work_queue(wiphy, &link_data->dfs_cac_timer_work, |
766d2601 | 3596 | msecs_to_jiffies(cac_time_ms)); |
164eb02d | 3597 | |
f403fed7 | 3598 | return 0; |
164eb02d SW |
3599 | } |
3600 | ||
26ec17a1 | 3601 | static void ieee80211_end_cac(struct wiphy *wiphy, |
81f67d60 | 3602 | struct net_device *dev, unsigned int link_id) |
26ec17a1 OM |
3603 | { |
3604 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3605 | struct ieee80211_local *local = sdata->local; | |
d74380ee | 3606 | struct ieee80211_link_data *link_data; |
26ec17a1 | 3607 | |
0cd8080e JB |
3608 | lockdep_assert_wiphy(local->hw.wiphy); |
3609 | ||
26ec17a1 | 3610 | list_for_each_entry(sdata, &local->interfaces, list) { |
d74380ee AKS |
3611 | link_data = sdata_dereference(sdata->link[link_id], sdata); |
3612 | if (!link_data) | |
3613 | continue; | |
3614 | ||
766d2601 | 3615 | wiphy_delayed_work_cancel(wiphy, |
d74380ee | 3616 | &link_data->dfs_cac_timer_work); |
26ec17a1 | 3617 | |
d74380ee AKS |
3618 | if (sdata->wdev.links[link_id].cac_started) { |
3619 | ieee80211_link_release_channel(link_data); | |
3620 | sdata->wdev.links[link_id].cac_started = false; | |
26ec17a1 OM |
3621 | } |
3622 | } | |
26ec17a1 OM |
3623 | } |
3624 | ||
73da7d5b SW |
3625 | static struct cfg80211_beacon_data * |
3626 | cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) | |
3627 | { | |
3628 | struct cfg80211_beacon_data *new_beacon; | |
3629 | u8 *pos; | |
3630 | int len; | |
3631 | ||
3632 | len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len + | |
3633 | beacon->proberesp_ies_len + beacon->assocresp_ies_len + | |
bd54f3c2 AD |
3634 | beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len; |
3635 | ||
3636 | if (beacon->mbssid_ies) | |
3637 | len += ieee80211_get_mbssid_beacon_len(beacon->mbssid_ies, | |
68b9bea2 | 3638 | beacon->rnr_ies, |
bd54f3c2 | 3639 | beacon->mbssid_ies->cnt); |
73da7d5b SW |
3640 | |
3641 | new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL); | |
3642 | if (!new_beacon) | |
3643 | return NULL; | |
3644 | ||
2b3171c6 LB |
3645 | if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { |
3646 | new_beacon->mbssid_ies = | |
3647 | kzalloc(struct_size(new_beacon->mbssid_ies, | |
3648 | elem, beacon->mbssid_ies->cnt), | |
3649 | GFP_KERNEL); | |
3650 | if (!new_beacon->mbssid_ies) { | |
3651 | kfree(new_beacon); | |
3652 | return NULL; | |
3653 | } | |
68b9bea2 AD |
3654 | |
3655 | if (beacon->rnr_ies && beacon->rnr_ies->cnt) { | |
3656 | new_beacon->rnr_ies = | |
3657 | kzalloc(struct_size(new_beacon->rnr_ies, | |
3658 | elem, beacon->rnr_ies->cnt), | |
3659 | GFP_KERNEL); | |
3660 | if (!new_beacon->rnr_ies) { | |
3661 | kfree(new_beacon->mbssid_ies); | |
3662 | kfree(new_beacon); | |
3663 | return NULL; | |
3664 | } | |
3665 | } | |
2b3171c6 LB |
3666 | } |
3667 | ||
73da7d5b SW |
3668 | pos = (u8 *)(new_beacon + 1); |
3669 | if (beacon->head_len) { | |
3670 | new_beacon->head_len = beacon->head_len; | |
3671 | new_beacon->head = pos; | |
3672 | memcpy(pos, beacon->head, beacon->head_len); | |
3673 | pos += beacon->head_len; | |
3674 | } | |
3675 | if (beacon->tail_len) { | |
3676 | new_beacon->tail_len = beacon->tail_len; | |
3677 | new_beacon->tail = pos; | |
3678 | memcpy(pos, beacon->tail, beacon->tail_len); | |
3679 | pos += beacon->tail_len; | |
3680 | } | |
3681 | if (beacon->beacon_ies_len) { | |
3682 | new_beacon->beacon_ies_len = beacon->beacon_ies_len; | |
3683 | new_beacon->beacon_ies = pos; | |
3684 | memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len); | |
3685 | pos += beacon->beacon_ies_len; | |
3686 | } | |
3687 | if (beacon->proberesp_ies_len) { | |
3688 | new_beacon->proberesp_ies_len = beacon->proberesp_ies_len; | |
3689 | new_beacon->proberesp_ies = pos; | |
3690 | memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len); | |
3691 | pos += beacon->proberesp_ies_len; | |
3692 | } | |
3693 | if (beacon->assocresp_ies_len) { | |
3694 | new_beacon->assocresp_ies_len = beacon->assocresp_ies_len; | |
3695 | new_beacon->assocresp_ies = pos; | |
3696 | memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len); | |
3697 | pos += beacon->assocresp_ies_len; | |
3698 | } | |
3699 | if (beacon->probe_resp_len) { | |
3700 | new_beacon->probe_resp_len = beacon->probe_resp_len; | |
bee92d06 | 3701 | new_beacon->probe_resp = pos; |
73da7d5b SW |
3702 | memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); |
3703 | pos += beacon->probe_resp_len; | |
3704 | } | |
68b9bea2 | 3705 | if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) { |
2b3171c6 LB |
3706 | pos += ieee80211_copy_mbssid_beacon(pos, |
3707 | new_beacon->mbssid_ies, | |
3708 | beacon->mbssid_ies); | |
68b9bea2 AD |
3709 | if (beacon->rnr_ies && beacon->rnr_ies->cnt) |
3710 | pos += ieee80211_copy_rnr_beacon(pos, | |
3711 | new_beacon->rnr_ies, | |
3712 | beacon->rnr_ies); | |
3713 | } | |
03b73862 JB |
3714 | |
3715 | /* might copy -1, meaning no changes requested */ | |
3716 | new_beacon->ftm_responder = beacon->ftm_responder; | |
bc847970 PKC |
3717 | if (beacon->lci) { |
3718 | new_beacon->lci_len = beacon->lci_len; | |
3719 | new_beacon->lci = pos; | |
3720 | memcpy(pos, beacon->lci, beacon->lci_len); | |
3721 | pos += beacon->lci_len; | |
3722 | } | |
3723 | if (beacon->civicloc) { | |
3724 | new_beacon->civicloc_len = beacon->civicloc_len; | |
3725 | new_beacon->civicloc = pos; | |
3726 | memcpy(pos, beacon->civicloc, beacon->civicloc_len); | |
3727 | pos += beacon->civicloc_len; | |
3728 | } | |
73da7d5b SW |
3729 | |
3730 | return new_beacon; | |
3731 | } | |
3732 | ||
04ada859 | 3733 | void ieee80211_csa_finish(struct ieee80211_vif *vif, unsigned int link_id) |
73da7d5b | 3734 | { |
66e01cf9 | 3735 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
c9eb90a5 | 3736 | struct ieee80211_local *local = sdata->local; |
f6008327 | 3737 | struct ieee80211_bss_conf *tx_bss_conf; |
04ada859 AKS |
3738 | struct ieee80211_link_data *link_data; |
3739 | ||
3740 | if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS)) | |
3741 | return; | |
c9eb90a5 JC |
3742 | |
3743 | rcu_read_lock(); | |
3744 | ||
04ada859 AKS |
3745 | link_data = rcu_dereference(sdata->link[link_id]); |
3746 | if (WARN_ON(!link_data)) { | |
3747 | rcu_read_unlock(); | |
3748 | return; | |
3749 | } | |
3750 | ||
f6008327 RS |
3751 | tx_bss_conf = rcu_dereference(link_data->conf->tx_bss_conf); |
3752 | if (tx_bss_conf == link_data->conf) { | |
c9eb90a5 JC |
3753 | /* Trigger ieee80211_csa_finish() on the non-transmitting |
3754 | * interfaces when channel switch is received on | |
3755 | * transmitting interface | |
3756 | */ | |
f6008327 | 3757 | struct ieee80211_link_data *iter; |
73da7d5b | 3758 | |
f6008327 RS |
3759 | for_each_sdata_link(local, iter) { |
3760 | if (iter->sdata == sdata || | |
3761 | rcu_access_pointer(iter->conf->tx_bss_conf) != tx_bss_conf) | |
c9eb90a5 JC |
3762 | continue; |
3763 | ||
f6008327 RS |
3764 | wiphy_work_queue(iter->sdata->local->hw.wiphy, |
3765 | &iter->csa.finalize_work); | |
c9eb90a5 JC |
3766 | } |
3767 | } | |
f6008327 | 3768 | |
344d18ce | 3769 | wiphy_work_queue(local->hw.wiphy, &link_data->csa.finalize_work); |
c9eb90a5 JC |
3770 | |
3771 | rcu_read_unlock(); | |
66e01cf9 LC |
3772 | } |
3773 | EXPORT_SYMBOL(ieee80211_csa_finish); | |
e487eaeb | 3774 | |
11ac0d7c | 3775 | void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif) |
6d501764 NE |
3776 | { |
3777 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | |
3778 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | |
3779 | struct ieee80211_local *local = sdata->local; | |
3780 | ||
6d501764 | 3781 | sdata_info(sdata, "channel switch failed, disconnecting\n"); |
4b8d43f1 | 3782 | wiphy_work_queue(local->hw.wiphy, &ifmgd->csa_connection_drop_work); |
6d501764 NE |
3783 | } |
3784 | EXPORT_SYMBOL(ieee80211_channel_switch_disconnect); | |
3785 | ||
a3a637a6 | 3786 | static int ieee80211_set_after_csa_beacon(struct ieee80211_link_data *link_data, |
15ddba5f | 3787 | u64 *changed) |
66e01cf9 | 3788 | { |
a3a637a6 | 3789 | struct ieee80211_sub_if_data *sdata = link_data->sdata; |
66199506 | 3790 | int err; |
7578d575 | 3791 | |
cd7760e6 SW |
3792 | switch (sdata->vif.type) { |
3793 | case NL80211_IFTYPE_AP: | |
a3a637a6 | 3794 | if (!link_data->u.ap.next_beacon) |
450c271d LB |
3795 | return -EINVAL; |
3796 | ||
a3a637a6 AKS |
3797 | err = ieee80211_assign_beacon(sdata, link_data, |
3798 | link_data->u.ap.next_beacon, | |
15ddba5f | 3799 | NULL, NULL, changed); |
a3a637a6 | 3800 | ieee80211_free_next_beacon(link_data); |
97518af1 | 3801 | |
cd7760e6 | 3802 | if (err < 0) |
66199506 | 3803 | return err; |
cd7760e6 SW |
3804 | break; |
3805 | case NL80211_IFTYPE_ADHOC: | |
15ddba5f | 3806 | err = ieee80211_ibss_finish_csa(sdata, changed); |
faf046e7 | 3807 | if (err < 0) |
66199506 | 3808 | return err; |
cd7760e6 | 3809 | break; |
b8456a14 CYY |
3810 | #ifdef CONFIG_MAC80211_MESH |
3811 | case NL80211_IFTYPE_MESH_POINT: | |
15ddba5f | 3812 | err = ieee80211_mesh_finish_csa(sdata, changed); |
b8456a14 | 3813 | if (err < 0) |
66199506 | 3814 | return err; |
b8456a14 CYY |
3815 | break; |
3816 | #endif | |
cd7760e6 SW |
3817 | default: |
3818 | WARN_ON(1); | |
66199506 MK |
3819 | return -EINVAL; |
3820 | } | |
3821 | ||
3822 | return 0; | |
3823 | } | |
3824 | ||
a469a593 | 3825 | static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data) |
66199506 | 3826 | { |
a469a593 | 3827 | struct ieee80211_sub_if_data *sdata = link_data->sdata; |
66199506 | 3828 | struct ieee80211_local *local = sdata->local; |
1a96bb4e | 3829 | struct ieee80211_bss_conf *link_conf = link_data->conf; |
15ddba5f | 3830 | u64 changed = 0; |
66199506 MK |
3831 | int err; |
3832 | ||
5435af6e | 3833 | lockdep_assert_wiphy(local->hw.wiphy); |
66199506 | 3834 | |
03078de4 MK |
3835 | /* |
3836 | * using reservation isn't immediate as it may be deferred until later | |
3837 | * with multi-vif. once reservation is complete it will re-schedule the | |
3838 | * work with no reserved_chanctx so verify chandef to check if it | |
3839 | * completed successfully | |
3840 | */ | |
66199506 | 3841 | |
a469a593 | 3842 | if (link_data->reserved_chanctx) { |
03078de4 MK |
3843 | /* |
3844 | * with multi-vif csa driver may call ieee80211_csa_finish() | |
3845 | * many times while waiting for other interfaces to use their | |
3846 | * reservations | |
3847 | */ | |
a469a593 | 3848 | if (link_data->reserved_ready) |
03078de4 MK |
3849 | return 0; |
3850 | ||
1a96bb4e | 3851 | return ieee80211_link_use_reserved_context(link_data); |
cd7760e6 | 3852 | } |
73da7d5b | 3853 | |
1a96bb4e | 3854 | if (!cfg80211_chandef_identical(&link_conf->chanreq.oper, |
344d18ce | 3855 | &link_data->csa.chanreq.oper)) |
03078de4 MK |
3856 | return -EINVAL; |
3857 | ||
1a96bb4e | 3858 | link_conf->csa_active = false; |
66199506 | 3859 | |
1a96bb4e | 3860 | err = ieee80211_set_after_csa_beacon(link_data, &changed); |
66199506 | 3861 | if (err) |
cf8767dd | 3862 | return err; |
faf046e7 | 3863 | |
86a8db67 | 3864 | ieee80211_link_info_change_notify(sdata, link_data, changed); |
59af6928 | 3865 | |
dc494fdc | 3866 | ieee80211_vif_unblock_queues_csa(sdata); |
cf8767dd | 3867 | |
a469a593 | 3868 | err = drv_post_channel_switch(link_data); |
f1d65583 LC |
3869 | if (err) |
3870 | return err; | |
3871 | ||
344d18ce | 3872 | cfg80211_ch_switch_notify(sdata->dev, &link_data->csa.chanreq.oper, |
b82730bf | 3873 | link_data->link_id); |
f1d65583 | 3874 | |
cf8767dd MK |
3875 | return 0; |
3876 | } | |
3877 | ||
a469a593 | 3878 | static void ieee80211_csa_finalize(struct ieee80211_link_data *link_data) |
cf8767dd | 3879 | { |
a469a593 EG |
3880 | struct ieee80211_sub_if_data *sdata = link_data->sdata; |
3881 | ||
3882 | if (__ieee80211_csa_finalize(link_data)) { | |
1a96bb4e AKS |
3883 | sdata_info(sdata, "failed to finalize CSA on link %d, disconnecting\n", |
3884 | link_data->link_id); | |
cf8767dd MK |
3885 | cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev, |
3886 | GFP_KERNEL); | |
3887 | } | |
66e01cf9 LC |
3888 | } |
3889 | ||
d7074be6 | 3890 | void ieee80211_csa_finalize_work(struct wiphy *wiphy, struct wiphy_work *work) |
66e01cf9 | 3891 | { |
a469a593 | 3892 | struct ieee80211_link_data *link = |
344d18ce | 3893 | container_of(work, struct ieee80211_link_data, csa.finalize_work); |
a469a593 | 3894 | struct ieee80211_sub_if_data *sdata = link->sdata; |
59af6928 | 3895 | struct ieee80211_local *local = sdata->local; |
66e01cf9 | 3896 | |
5435af6e | 3897 | lockdep_assert_wiphy(local->hw.wiphy); |
59af6928 | 3898 | |
66e01cf9 | 3899 | /* AP might have been stopped while waiting for the lock. */ |
a469a593 | 3900 | if (!link->conf->csa_active) |
076fc877 | 3901 | return; |
66e01cf9 LC |
3902 | |
3903 | if (!ieee80211_sdata_running(sdata)) | |
076fc877 | 3904 | return; |
66e01cf9 | 3905 | |
a469a593 | 3906 | ieee80211_csa_finalize(link); |
73da7d5b SW |
3907 | } |
3908 | ||
a3a637a6 | 3909 | static int ieee80211_set_csa_beacon(struct ieee80211_link_data *link_data, |
37fa2bdd | 3910 | struct cfg80211_csa_settings *params, |
15ddba5f | 3911 | u64 *changed) |
73da7d5b | 3912 | { |
a3a637a6 | 3913 | struct ieee80211_sub_if_data *sdata = link_data->sdata; |
af296bdb | 3914 | struct ieee80211_csa_settings csa = {}; |
37fa2bdd | 3915 | int err; |
73da7d5b | 3916 | |
73da7d5b SW |
3917 | switch (sdata->vif.type) { |
3918 | case NL80211_IFTYPE_AP: | |
a3a637a6 | 3919 | link_data->u.ap.next_beacon = |
cd7760e6 | 3920 | cfg80211_beacon_dup(¶ms->beacon_after); |
a3a637a6 | 3921 | if (!link_data->u.ap.next_beacon) |
cd7760e6 SW |
3922 | return -ENOMEM; |
3923 | ||
66e01cf9 LC |
3924 | /* |
3925 | * With a count of 0, we don't have to wait for any | |
3926 | * TBTT before switching, so complete the CSA | |
3927 | * immediately. In theory, with a count == 1 we | |
3928 | * should delay the switch until just before the next | |
3929 | * TBTT, but that would complicate things so we switch | |
3930 | * immediately too. If we would delay the switch | |
3931 | * until the next TBTT, we would have to set the probe | |
3932 | * response here. | |
3933 | * | |
3934 | * TODO: A channel switch with count <= 1 without | |
3935 | * sending a CSA action frame is kind of useless, | |
3936 | * because the clients won't know we're changing | |
3937 | * channels. The action frame must be implemented | |
3938 | * either here or in the userspace. | |
3939 | */ | |
3940 | if (params->count <= 1) | |
3941 | break; | |
3942 | ||
0d06d9ba | 3943 | if ((params->n_counter_offsets_beacon > |
8552a434 | 3944 | IEEE80211_MAX_CNTDWN_COUNTERS_NUM) || |
0d06d9ba | 3945 | (params->n_counter_offsets_presp > |
2b3171c6 | 3946 | IEEE80211_MAX_CNTDWN_COUNTERS_NUM)) { |
a3a637a6 | 3947 | ieee80211_free_next_beacon(link_data); |
0d06d9ba | 3948 | return -EINVAL; |
2b3171c6 | 3949 | } |
9a774c78 | 3950 | |
af296bdb MK |
3951 | csa.counter_offsets_beacon = params->counter_offsets_beacon; |
3952 | csa.counter_offsets_presp = params->counter_offsets_presp; | |
3953 | csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon; | |
3954 | csa.n_counter_offsets_presp = params->n_counter_offsets_presp; | |
3955 | csa.count = params->count; | |
9a774c78 | 3956 | |
a3a637a6 | 3957 | err = ieee80211_assign_beacon(sdata, link_data, |
d8675a63 | 3958 | ¶ms->beacon_csa, &csa, |
15ddba5f | 3959 | NULL, changed); |
cd7760e6 | 3960 | if (err < 0) { |
a3a637a6 | 3961 | ieee80211_free_next_beacon(link_data); |
cd7760e6 SW |
3962 | return err; |
3963 | } | |
66e01cf9 | 3964 | |
cd7760e6 SW |
3965 | break; |
3966 | case NL80211_IFTYPE_ADHOC: | |
f276e20b | 3967 | if (!sdata->vif.cfg.ibss_joined) |
cd7760e6 SW |
3968 | return -EINVAL; |
3969 | ||
3970 | if (params->chandef.width != sdata->u.ibss.chandef.width) | |
3971 | return -EINVAL; | |
3972 | ||
3973 | switch (params->chandef.width) { | |
3974 | case NL80211_CHAN_WIDTH_40: | |
3975 | if (cfg80211_get_chandef_type(¶ms->chandef) != | |
3976 | cfg80211_get_chandef_type(&sdata->u.ibss.chandef)) | |
3977 | return -EINVAL; | |
aaaee2d6 | 3978 | break; |
cd7760e6 SW |
3979 | case NL80211_CHAN_WIDTH_5: |
3980 | case NL80211_CHAN_WIDTH_10: | |
3981 | case NL80211_CHAN_WIDTH_20_NOHT: | |
3982 | case NL80211_CHAN_WIDTH_20: | |
3983 | break; | |
3984 | default: | |
3985 | return -EINVAL; | |
3986 | } | |
3987 | ||
3988 | /* changes into another band are not supported */ | |
3989 | if (sdata->u.ibss.chandef.chan->band != | |
3990 | params->chandef.chan->band) | |
3991 | return -EINVAL; | |
3992 | ||
66e01cf9 LC |
3993 | /* see comments in the NL80211_IFTYPE_AP block */ |
3994 | if (params->count > 1) { | |
15ddba5f | 3995 | err = ieee80211_ibss_csa_beacon(sdata, params, changed); |
66e01cf9 LC |
3996 | if (err < 0) |
3997 | return err; | |
66e01cf9 LC |
3998 | } |
3999 | ||
4000 | ieee80211_send_action_csa(sdata, params); | |
4001 | ||
73da7d5b | 4002 | break; |
c6da674a | 4003 | #ifdef CONFIG_MAC80211_MESH |
37fa2bdd MK |
4004 | case NL80211_IFTYPE_MESH_POINT: { |
4005 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | |
c6da674a | 4006 | |
c6da674a | 4007 | /* changes into another band are not supported */ |
6092077a | 4008 | if (sdata->vif.bss_conf.chanreq.oper.chan->band != |
c6da674a CYY |
4009 | params->chandef.chan->band) |
4010 | return -EINVAL; | |
4011 | ||
c782bf8c | 4012 | if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) { |
0cb4d4dc | 4013 | ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT; |
c782bf8c CYY |
4014 | if (!ifmsh->pre_value) |
4015 | ifmsh->pre_value = 1; | |
4016 | else | |
4017 | ifmsh->pre_value++; | |
4018 | } | |
0cb4d4dc | 4019 | |
66e01cf9 LC |
4020 | /* see comments in the NL80211_IFTYPE_AP block */ |
4021 | if (params->count > 1) { | |
15ddba5f | 4022 | err = ieee80211_mesh_csa_beacon(sdata, params, changed); |
66e01cf9 LC |
4023 | if (err < 0) { |
4024 | ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE; | |
4025 | return err; | |
4026 | } | |
3f718fd8 | 4027 | } |
66e01cf9 LC |
4028 | |
4029 | if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT) | |
4030 | ieee80211_send_action_csa(sdata, params); | |
4031 | ||
c6da674a | 4032 | break; |
37fa2bdd | 4033 | } |
c6da674a | 4034 | #endif |
73da7d5b SW |
4035 | default: |
4036 | return -EOPNOTSUPP; | |
4037 | } | |
4038 | ||
37fa2bdd MK |
4039 | return 0; |
4040 | } | |
4041 | ||
414e736c | 4042 | static void ieee80211_color_change_abort(struct ieee80211_link_data *link) |
5f9404ab | 4043 | { |
414e736c | 4044 | link->conf->color_change_active = false; |
0baef284 | 4045 | |
414e736c | 4046 | ieee80211_free_next_beacon(link); |
5f9404ab | 4047 | |
414e736c | 4048 | cfg80211_color_change_aborted_notify(link->sdata->dev, link->link_id); |
5f9404ab JC |
4049 | } |
4050 | ||
f29f58a9 LC |
4051 | static int |
4052 | __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | |
4053 | struct cfg80211_csa_settings *params) | |
37fa2bdd MK |
4054 | { |
4055 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
6092077a | 4056 | struct ieee80211_chan_req chanreq = { .oper = params->chandef }; |
37fa2bdd | 4057 | struct ieee80211_local *local = sdata->local; |
e6ee3a37 JB |
4058 | struct ieee80211_channel_switch ch_switch = { |
4059 | .link_id = params->link_id, | |
4060 | }; | |
2b32713d | 4061 | struct ieee80211_chanctx_conf *conf; |
37fa2bdd | 4062 | struct ieee80211_chanctx *chanctx; |
1a96bb4e AKS |
4063 | struct ieee80211_bss_conf *link_conf; |
4064 | struct ieee80211_link_data *link_data; | |
15ddba5f | 4065 | u64 changed = 0; |
1a96bb4e | 4066 | u8 link_id = params->link_id; |
b08cc24e | 4067 | int err; |
37fa2bdd | 4068 | |
5435af6e | 4069 | lockdep_assert_wiphy(local->hw.wiphy); |
37fa2bdd MK |
4070 | |
4071 | if (!list_empty(&local->roc_list) || local->scanning) | |
4072 | return -EBUSY; | |
4073 | ||
0b779823 | 4074 | if (sdata->wdev.links[link_id].cac_started) |
37fa2bdd MK |
4075 | return -EBUSY; |
4076 | ||
1a96bb4e AKS |
4077 | if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS)) |
4078 | return -EINVAL; | |
4079 | ||
4080 | link_data = wiphy_dereference(wiphy, sdata->link[link_id]); | |
4081 | if (!link_data) | |
4082 | return -ENOLINK; | |
4083 | ||
4084 | link_conf = link_data->conf; | |
4085 | ||
4086 | if (chanreq.oper.punctured && !link_conf->eht_support) | |
b82730bf JB |
4087 | return -EINVAL; |
4088 | ||
03078de4 | 4089 | /* don't allow another channel switch if one is already active. */ |
1a96bb4e | 4090 | if (link_conf->csa_active) |
03078de4 MK |
4091 | return -EBUSY; |
4092 | ||
1a96bb4e | 4093 | conf = wiphy_dereference(wiphy, link_conf->chanctx_conf); |
2b32713d | 4094 | if (!conf) { |
03078de4 MK |
4095 | err = -EBUSY; |
4096 | goto out; | |
37fa2bdd MK |
4097 | } |
4098 | ||
b6011960 TP |
4099 | if (params->chandef.chan->freq_offset) { |
4100 | /* this may work, but is untested */ | |
4101 | err = -EOPNOTSUPP; | |
4102 | goto out; | |
4103 | } | |
4104 | ||
2b32713d | 4105 | chanctx = container_of(conf, struct ieee80211_chanctx, conf); |
37fa2bdd | 4106 | |
000baa5d LC |
4107 | ch_switch.timestamp = 0; |
4108 | ch_switch.device_timestamp = 0; | |
4109 | ch_switch.block_tx = params->block_tx; | |
6092077a | 4110 | ch_switch.chandef = chanreq.oper; |
000baa5d LC |
4111 | ch_switch.count = params->count; |
4112 | ||
6d027bcc LC |
4113 | err = drv_pre_channel_switch(sdata, &ch_switch); |
4114 | if (err) | |
4115 | goto out; | |
4116 | ||
1a96bb4e | 4117 | err = ieee80211_link_reserve_chanctx(link_data, &chanreq, |
b4f85443 JB |
4118 | chanctx->mode, |
4119 | params->radar_required); | |
03078de4 MK |
4120 | if (err) |
4121 | goto out; | |
37fa2bdd | 4122 | |
03078de4 | 4123 | /* if reservation is invalid then this will fail */ |
0874bcd0 | 4124 | err = ieee80211_check_combinations(sdata, NULL, chanctx->mode, 0, -1); |
03078de4 | 4125 | if (err) { |
1a96bb4e | 4126 | ieee80211_link_unreserve_chanctx(link_data); |
03078de4 MK |
4127 | goto out; |
4128 | } | |
37fa2bdd | 4129 | |
5f9404ab | 4130 | /* if there is a color change in progress, abort it */ |
1a96bb4e | 4131 | if (link_conf->color_change_active) |
414e736c | 4132 | ieee80211_color_change_abort(link_data); |
5f9404ab | 4133 | |
1a96bb4e | 4134 | err = ieee80211_set_csa_beacon(link_data, params, &changed); |
03078de4 | 4135 | if (err) { |
1a96bb4e | 4136 | ieee80211_link_unreserve_chanctx(link_data); |
03078de4 MK |
4137 | goto out; |
4138 | } | |
37fa2bdd | 4139 | |
344d18ce | 4140 | link_data->csa.chanreq = chanreq; |
1a96bb4e | 4141 | link_conf->csa_active = true; |
73da7d5b | 4142 | |
dc494fdc JB |
4143 | if (params->block_tx) |
4144 | ieee80211_vif_block_queues_csa(sdata); | |
59af6928 | 4145 | |
bfd8403a | 4146 | cfg80211_ch_switch_started_notify(sdata->dev, |
93d4e8bb | 4147 | &link_data->csa.chanreq.oper, link_id, |
b82730bf | 4148 | params->count, params->block_tx); |
2f457293 | 4149 | |
66e01cf9 | 4150 | if (changed) { |
1a96bb4e | 4151 | ieee80211_link_info_change_notify(sdata, link_data, changed); |
344d18ce | 4152 | drv_channel_switch_beacon(sdata, &link_data->csa.chanreq.oper); |
66e01cf9 LC |
4153 | } else { |
4154 | /* if the beacon didn't change, we can finalize immediately */ | |
1a96bb4e | 4155 | ieee80211_csa_finalize(link_data); |
66e01cf9 | 4156 | } |
73da7d5b | 4157 | |
03078de4 | 4158 | out: |
03078de4 | 4159 | return err; |
73da7d5b SW |
4160 | } |
4161 | ||
59af6928 MK |
4162 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, |
4163 | struct cfg80211_csa_settings *params) | |
4164 | { | |
4165 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4166 | struct ieee80211_local *local = sdata->local; | |
59af6928 | 4167 | |
0cd8080e | 4168 | lockdep_assert_wiphy(local->hw.wiphy); |
59af6928 | 4169 | |
0cd8080e | 4170 | return __ieee80211_channel_switch(wiphy, dev, params); |
59af6928 MK |
4171 | } |
4172 | ||
a2fcfccb JB |
4173 | u64 ieee80211_mgmt_tx_cookie(struct ieee80211_local *local) |
4174 | { | |
0cd8080e | 4175 | lockdep_assert_wiphy(local->hw.wiphy); |
a2fcfccb JB |
4176 | |
4177 | local->roc_cookie_counter++; | |
4178 | ||
4179 | /* wow, you wrapped 64 bits ... more likely a bug */ | |
4180 | if (WARN_ON(local->roc_cookie_counter == 0)) | |
4181 | local->roc_cookie_counter++; | |
4182 | ||
4183 | return local->roc_cookie_counter; | |
4184 | } | |
4185 | ||
5ee00dbd JB |
4186 | int ieee80211_attach_ack_skb(struct ieee80211_local *local, struct sk_buff *skb, |
4187 | u64 *cookie, gfp_t gfp) | |
3b79af97 JB |
4188 | { |
4189 | unsigned long spin_flags; | |
4190 | struct sk_buff *ack_skb; | |
4191 | int id; | |
4192 | ||
4193 | ack_skb = skb_copy(skb, gfp); | |
4194 | if (!ack_skb) | |
5ee00dbd | 4195 | return -ENOMEM; |
3b79af97 JB |
4196 | |
4197 | spin_lock_irqsave(&local->ack_status_lock, spin_flags); | |
4198 | id = idr_alloc(&local->ack_status_frames, ack_skb, | |
f2b18bac | 4199 | 1, 0x2000, GFP_ATOMIC); |
3b79af97 JB |
4200 | spin_unlock_irqrestore(&local->ack_status_lock, spin_flags); |
4201 | ||
4202 | if (id < 0) { | |
4203 | kfree_skb(ack_skb); | |
5ee00dbd | 4204 | return -ENOMEM; |
3b79af97 JB |
4205 | } |
4206 | ||
f498f6ab JB |
4207 | IEEE80211_SKB_CB(skb)->status_data_idr = 1; |
4208 | IEEE80211_SKB_CB(skb)->status_data = id; | |
3b79af97 JB |
4209 | |
4210 | *cookie = ieee80211_mgmt_tx_cookie(local); | |
4211 | IEEE80211_SKB_CB(ack_skb)->ack.cookie = *cookie; | |
4212 | ||
5ee00dbd | 4213 | return 0; |
3b79af97 JB |
4214 | } |
4215 | ||
6cd536fe JB |
4216 | static void |
4217 | ieee80211_update_mgmt_frame_registrations(struct wiphy *wiphy, | |
71bbc994 | 4218 | struct wireless_dev *wdev, |
6cd536fe | 4219 | struct mgmt_frame_regs *upd) |
7be5086d JB |
4220 | { |
4221 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
1b09b556 | 4222 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
6cd536fe | 4223 | u32 preq_mask = BIT(IEEE80211_STYPE_PROBE_REQ >> 4); |
873b1cf6 | 4224 | u32 action_mask = BIT(IEEE80211_STYPE_ACTION >> 4); |
6cd536fe | 4225 | bool global_change, intf_change; |
7be5086d | 4226 | |
6cd536fe | 4227 | global_change = |
873b1cf6 JM |
4228 | (local->probe_req_reg != !!(upd->global_stypes & preq_mask)) || |
4229 | (local->rx_mcast_action_reg != | |
4230 | !!(upd->global_mcast_stypes & action_mask)); | |
6cd536fe | 4231 | local->probe_req_reg = upd->global_stypes & preq_mask; |
873b1cf6 | 4232 | local->rx_mcast_action_reg = upd->global_mcast_stypes & action_mask; |
1b09b556 | 4233 | |
873b1cf6 JM |
4234 | intf_change = (sdata->vif.probe_req_reg != |
4235 | !!(upd->interface_stypes & preq_mask)) || | |
4236 | (sdata->vif.rx_mcast_action_reg != | |
4237 | !!(upd->interface_mcast_stypes & action_mask)); | |
6cd536fe | 4238 | sdata->vif.probe_req_reg = upd->interface_stypes & preq_mask; |
873b1cf6 JM |
4239 | sdata->vif.rx_mcast_action_reg = |
4240 | upd->interface_mcast_stypes & action_mask; | |
7be5086d | 4241 | |
6cd536fe JB |
4242 | if (!local->open_count) |
4243 | return; | |
35f5149e | 4244 | |
6cd536fe JB |
4245 | if (intf_change && ieee80211_sdata_running(sdata)) |
4246 | drv_config_iface_filter(local, sdata, | |
4247 | sdata->vif.probe_req_reg ? | |
4248 | FIF_PROBE_REQ : 0, | |
4249 | FIF_PROBE_REQ); | |
1b09b556 | 4250 | |
6cd536fe | 4251 | if (global_change) |
1b09b556 | 4252 | ieee80211_configure_filter(local); |
7be5086d JB |
4253 | } |
4254 | ||
15d96753 BR |
4255 | static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant) |
4256 | { | |
4257 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
2bf57b00 | 4258 | int ret; |
15d96753 BR |
4259 | |
4260 | if (local->started) | |
4261 | return -EOPNOTSUPP; | |
4262 | ||
2bf57b00 EG |
4263 | ret = drv_set_antenna(local, tx_ant, rx_ant); |
4264 | if (ret) | |
4265 | return ret; | |
4266 | ||
4267 | local->rx_chains = hweight8(rx_ant); | |
4268 | return 0; | |
15d96753 BR |
4269 | } |
4270 | ||
4271 | static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant) | |
4272 | { | |
4273 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4274 | ||
4275 | return drv_get_antenna(local, tx_ant, rx_ant); | |
4276 | } | |
4277 | ||
c68f4b89 JB |
4278 | static int ieee80211_set_rekey_data(struct wiphy *wiphy, |
4279 | struct net_device *dev, | |
4280 | struct cfg80211_gtk_rekey_data *data) | |
4281 | { | |
4282 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4283 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4284 | ||
4285 | if (!local->ops->set_rekey_data) | |
4286 | return -EOPNOTSUPP; | |
4287 | ||
4288 | drv_set_rekey_data(local, sdata, data); | |
4289 | ||
4290 | return 0; | |
4291 | } | |
4292 | ||
06500736 JB |
4293 | static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, |
4294 | const u8 *peer, u64 *cookie) | |
4295 | { | |
4296 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4297 | struct ieee80211_local *local = sdata->local; | |
4298 | struct ieee80211_qos_hdr *nullfunc; | |
5ee00dbd | 4299 | struct sk_buff *skb; |
06500736 JB |
4300 | int size = sizeof(*nullfunc); |
4301 | __le16 fc; | |
4302 | bool qos; | |
4303 | struct ieee80211_tx_info *info; | |
4304 | struct sta_info *sta; | |
55de908a | 4305 | struct ieee80211_chanctx_conf *chanctx_conf; |
57fbcce3 | 4306 | enum nl80211_band band; |
3b79af97 JB |
4307 | int ret; |
4308 | ||
4309 | /* the lock is needed to assign the cookie later */ | |
0cd8080e | 4310 | lockdep_assert_wiphy(local->hw.wiphy); |
06500736 JB |
4311 | |
4312 | rcu_read_lock(); | |
67dfa589 JB |
4313 | sta = sta_info_get_bss(sdata, peer); |
4314 | if (!sta) { | |
4315 | ret = -ENOLINK; | |
4316 | goto unlock; | |
4317 | } | |
4318 | ||
4319 | qos = sta->sta.wme; | |
4320 | ||
d0a9123e | 4321 | chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf); |
55de908a | 4322 | if (WARN_ON(!chanctx_conf)) { |
3b79af97 JB |
4323 | ret = -EINVAL; |
4324 | goto unlock; | |
55de908a | 4325 | } |
4bf88530 | 4326 | band = chanctx_conf->def.chan->band; |
06500736 JB |
4327 | |
4328 | if (qos) { | |
4329 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | | |
4330 | IEEE80211_STYPE_QOS_NULLFUNC | | |
4331 | IEEE80211_FCTL_FROMDS); | |
4332 | } else { | |
4333 | size -= 2; | |
4334 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | | |
4335 | IEEE80211_STYPE_NULLFUNC | | |
4336 | IEEE80211_FCTL_FROMDS); | |
4337 | } | |
4338 | ||
4339 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); | |
55de908a | 4340 | if (!skb) { |
3b79af97 JB |
4341 | ret = -ENOMEM; |
4342 | goto unlock; | |
55de908a | 4343 | } |
06500736 JB |
4344 | |
4345 | skb->dev = dev; | |
4346 | ||
4347 | skb_reserve(skb, local->hw.extra_tx_headroom); | |
4348 | ||
4df864c1 | 4349 | nullfunc = skb_put(skb, size); |
06500736 JB |
4350 | nullfunc->frame_control = fc; |
4351 | nullfunc->duration_id = 0; | |
4352 | memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); | |
4353 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); | |
4354 | memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); | |
4355 | nullfunc->seq_ctrl = 0; | |
4356 | ||
4357 | info = IEEE80211_SKB_CB(skb); | |
4358 | ||
4359 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | | |
4360 | IEEE80211_TX_INTFL_NL80211_FRAME_TX; | |
73c4e195 | 4361 | info->band = band; |
06500736 JB |
4362 | |
4363 | skb_set_queue_mapping(skb, IEEE80211_AC_VO); | |
4364 | skb->priority = 7; | |
4365 | if (qos) | |
4366 | nullfunc->qos_ctrl = cpu_to_le16(7); | |
4367 | ||
5ee00dbd JB |
4368 | ret = ieee80211_attach_ack_skb(local, skb, cookie, GFP_ATOMIC); |
4369 | if (ret) { | |
3b79af97 | 4370 | kfree_skb(skb); |
3b79af97 JB |
4371 | goto unlock; |
4372 | } | |
4373 | ||
06500736 | 4374 | local_bh_disable(); |
08aca29a | 4375 | ieee80211_xmit(sdata, sta, skb); |
06500736 | 4376 | local_bh_enable(); |
3b79af97 JB |
4377 | |
4378 | ret = 0; | |
4379 | unlock: | |
55de908a | 4380 | rcu_read_unlock(); |
06500736 | 4381 | |
3b79af97 | 4382 | return ret; |
06500736 JB |
4383 | } |
4384 | ||
683b6d3b JB |
4385 | static int ieee80211_cfg_get_channel(struct wiphy *wiphy, |
4386 | struct wireless_dev *wdev, | |
7b0a0e3c | 4387 | unsigned int link_id, |
683b6d3b | 4388 | struct cfg80211_chan_def *chandef) |
5b7ccaf3 | 4389 | { |
55de908a | 4390 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
cb601ffa | 4391 | struct ieee80211_local *local = wiphy_priv(wiphy); |
55de908a | 4392 | struct ieee80211_chanctx_conf *chanctx_conf; |
d8675a63 | 4393 | struct ieee80211_link_data *link; |
683b6d3b | 4394 | int ret = -ENODATA; |
55de908a JB |
4395 | |
4396 | rcu_read_lock(); | |
d8675a63 JB |
4397 | link = rcu_dereference(sdata->link[link_id]); |
4398 | if (!link) { | |
4399 | ret = -ENOLINK; | |
4400 | goto out; | |
4401 | } | |
4402 | ||
4403 | chanctx_conf = rcu_dereference(link->conf->chanctx_conf); | |
feda3027 | 4404 | if (chanctx_conf) { |
6092077a | 4405 | *chandef = link->conf->chanreq.oper; |
feda3027 | 4406 | ret = 0; |
12986004 AW |
4407 | } else if (local->open_count > 0 && |
4408 | local->open_count == local->virt_monitors && | |
feda3027 | 4409 | sdata->vif.type == NL80211_IFTYPE_MONITOR) { |
6092077a | 4410 | *chandef = local->monitor_chanreq.oper; |
683b6d3b | 4411 | ret = 0; |
55de908a | 4412 | } |
d8675a63 | 4413 | out: |
55de908a | 4414 | rcu_read_unlock(); |
5b7ccaf3 | 4415 | |
683b6d3b | 4416 | return ret; |
5b7ccaf3 JB |
4417 | } |
4418 | ||
6d52563f JB |
4419 | #ifdef CONFIG_PM |
4420 | static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled) | |
4421 | { | |
4422 | drv_set_wakeup(wiphy_priv(wiphy), enabled); | |
4423 | } | |
4424 | #endif | |
4425 | ||
32db6b54 KP |
4426 | static int ieee80211_set_qos_map(struct wiphy *wiphy, |
4427 | struct net_device *dev, | |
4428 | struct cfg80211_qos_map *qos_map) | |
4429 | { | |
4430 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4431 | struct mac80211_qos_map *new_qos_map, *old_qos_map; | |
4432 | ||
4433 | if (qos_map) { | |
4434 | new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL); | |
4435 | if (!new_qos_map) | |
4436 | return -ENOMEM; | |
4437 | memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map)); | |
4438 | } else { | |
4439 | /* A NULL qos_map was passed to disable QoS mapping */ | |
4440 | new_qos_map = NULL; | |
4441 | } | |
4442 | ||
194ff52d | 4443 | old_qos_map = sdata_dereference(sdata->qos_map, sdata); |
32db6b54 KP |
4444 | rcu_assign_pointer(sdata->qos_map, new_qos_map); |
4445 | if (old_qos_map) | |
4446 | kfree_rcu(old_qos_map, rcu_head); | |
4447 | ||
4448 | return 0; | |
4449 | } | |
4450 | ||
3b1700bd JM |
4451 | static int ieee80211_set_ap_chanwidth(struct wiphy *wiphy, |
4452 | struct net_device *dev, | |
7b0a0e3c | 4453 | unsigned int link_id, |
3b1700bd JM |
4454 | struct cfg80211_chan_def *chandef) |
4455 | { | |
4456 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
d8675a63 | 4457 | struct ieee80211_link_data *link; |
6092077a | 4458 | struct ieee80211_chan_req chanreq = { .oper = *chandef }; |
3b1700bd | 4459 | int ret; |
aa87cd8b | 4460 | u64 changed = 0; |
3b1700bd | 4461 | |
d8675a63 JB |
4462 | link = sdata_dereference(sdata->link[link_id], sdata); |
4463 | ||
6092077a | 4464 | ret = ieee80211_link_change_chanreq(link, &chanreq, &changed); |
3b1700bd | 4465 | if (ret == 0) |
d8675a63 | 4466 | ieee80211_link_info_change_notify(sdata, link, changed); |
3b1700bd JM |
4467 | |
4468 | return ret; | |
4469 | } | |
4470 | ||
02219b3a JB |
4471 | static int ieee80211_add_tx_ts(struct wiphy *wiphy, struct net_device *dev, |
4472 | u8 tsid, const u8 *peer, u8 up, | |
4473 | u16 admitted_time) | |
4474 | { | |
4475 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4476 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | |
4477 | int ac = ieee802_1d_to_ac[up]; | |
4478 | ||
4479 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | |
4480 | return -EOPNOTSUPP; | |
4481 | ||
4482 | if (!(sdata->wmm_acm & BIT(up))) | |
4483 | return -EINVAL; | |
4484 | ||
4485 | if (ifmgd->tx_tspec[ac].admitted_time) | |
4486 | return -EBUSY; | |
4487 | ||
4488 | if (admitted_time) { | |
4489 | ifmgd->tx_tspec[ac].admitted_time = 32 * admitted_time; | |
4490 | ifmgd->tx_tspec[ac].tsid = tsid; | |
4491 | ifmgd->tx_tspec[ac].up = up; | |
4492 | } | |
4493 | ||
4494 | return 0; | |
4495 | } | |
4496 | ||
4497 | static int ieee80211_del_tx_ts(struct wiphy *wiphy, struct net_device *dev, | |
4498 | u8 tsid, const u8 *peer) | |
4499 | { | |
4500 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4501 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | |
4502 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4503 | int ac; | |
4504 | ||
4505 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { | |
4506 | struct ieee80211_sta_tx_tspec *tx_tspec = &ifmgd->tx_tspec[ac]; | |
4507 | ||
4508 | /* skip unused entries */ | |
4509 | if (!tx_tspec->admitted_time) | |
4510 | continue; | |
4511 | ||
4512 | if (tx_tspec->tsid != tsid) | |
4513 | continue; | |
4514 | ||
4515 | /* due to this new packets will be reassigned to non-ACM ACs */ | |
4516 | tx_tspec->up = -1; | |
4517 | ||
4518 | /* Make sure that all packets have been sent to avoid to | |
4519 | * restore the QoS params on packets that are still on the | |
4520 | * queues. | |
4521 | */ | |
4522 | synchronize_net(); | |
3b24f4c6 | 4523 | ieee80211_flush_queues(local, sdata, false); |
02219b3a JB |
4524 | |
4525 | /* restore the normal QoS parameters | |
4526 | * (unconditionally to avoid races) | |
4527 | */ | |
4528 | tx_tspec->action = TX_TSPEC_ACTION_STOP_DOWNGRADE; | |
4529 | tx_tspec->downgraded = false; | |
4530 | ieee80211_sta_handle_tspec_ac_params(sdata); | |
4531 | ||
4532 | /* finally clear all the data */ | |
4533 | memset(tx_tspec, 0, sizeof(*tx_tspec)); | |
4534 | ||
4535 | return 0; | |
4536 | } | |
4537 | ||
4538 | return -ENOENT; | |
4539 | } | |
4540 | ||
167e33f4 AB |
4541 | void ieee80211_nan_func_terminated(struct ieee80211_vif *vif, |
4542 | u8 inst_id, | |
4543 | enum nl80211_nan_func_term_reason reason, | |
4544 | gfp_t gfp) | |
4545 | { | |
4546 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | |
4547 | struct cfg80211_nan_func *func; | |
4548 | u64 cookie; | |
4549 | ||
4550 | if (WARN_ON(vif->type != NL80211_IFTYPE_NAN)) | |
4551 | return; | |
4552 | ||
4553 | spin_lock_bh(&sdata->u.nan.func_lock); | |
4554 | ||
4555 | func = idr_find(&sdata->u.nan.function_inst_ids, inst_id); | |
4556 | if (WARN_ON(!func)) { | |
4557 | spin_unlock_bh(&sdata->u.nan.func_lock); | |
4558 | return; | |
4559 | } | |
4560 | ||
4561 | cookie = func->cookie; | |
4562 | idr_remove(&sdata->u.nan.function_inst_ids, inst_id); | |
4563 | ||
4564 | spin_unlock_bh(&sdata->u.nan.func_lock); | |
4565 | ||
4566 | cfg80211_free_nan_func(func); | |
4567 | ||
4568 | cfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id, | |
4569 | reason, cookie, gfp); | |
4570 | } | |
4571 | EXPORT_SYMBOL(ieee80211_nan_func_terminated); | |
4572 | ||
92bc43bc AB |
4573 | void ieee80211_nan_func_match(struct ieee80211_vif *vif, |
4574 | struct cfg80211_nan_match_params *match, | |
4575 | gfp_t gfp) | |
4576 | { | |
4577 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | |
4578 | struct cfg80211_nan_func *func; | |
4579 | ||
4580 | if (WARN_ON(vif->type != NL80211_IFTYPE_NAN)) | |
4581 | return; | |
4582 | ||
4583 | spin_lock_bh(&sdata->u.nan.func_lock); | |
4584 | ||
4585 | func = idr_find(&sdata->u.nan.function_inst_ids, match->inst_id); | |
4586 | if (WARN_ON(!func)) { | |
4587 | spin_unlock_bh(&sdata->u.nan.func_lock); | |
4588 | return; | |
4589 | } | |
4590 | match->cookie = func->cookie; | |
4591 | ||
4592 | spin_unlock_bh(&sdata->u.nan.func_lock); | |
4593 | ||
4594 | cfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp); | |
4595 | } | |
4596 | EXPORT_SYMBOL(ieee80211_nan_func_match); | |
4597 | ||
ebceec86 MB |
4598 | static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy, |
4599 | struct net_device *dev, | |
4600 | const bool enabled) | |
4601 | { | |
4602 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4603 | ||
4604 | sdata->u.ap.multicast_to_unicast = enabled; | |
4605 | ||
4606 | return 0; | |
4607 | } | |
4608 | ||
2fe4a29a THJ |
4609 | void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats, |
4610 | struct txq_info *txqi) | |
4611 | { | |
4612 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_BYTES))) { | |
4613 | txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_BYTES); | |
4614 | txqstats->backlog_bytes = txqi->tin.backlog_bytes; | |
4615 | } | |
4616 | ||
4617 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS))) { | |
4618 | txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS); | |
4619 | txqstats->backlog_packets = txqi->tin.backlog_packets; | |
4620 | } | |
4621 | ||
4622 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_FLOWS))) { | |
4623 | txqstats->filled |= BIT(NL80211_TXQ_STATS_FLOWS); | |
4624 | txqstats->flows = txqi->tin.flows; | |
4625 | } | |
4626 | ||
4627 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_DROPS))) { | |
4628 | txqstats->filled |= BIT(NL80211_TXQ_STATS_DROPS); | |
4629 | txqstats->drops = txqi->cstats.drop_count; | |
4630 | } | |
4631 | ||
4632 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_ECN_MARKS))) { | |
4633 | txqstats->filled |= BIT(NL80211_TXQ_STATS_ECN_MARKS); | |
4634 | txqstats->ecn_marks = txqi->cstats.ecn_mark; | |
4635 | } | |
4636 | ||
4637 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_OVERLIMIT))) { | |
4638 | txqstats->filled |= BIT(NL80211_TXQ_STATS_OVERLIMIT); | |
4639 | txqstats->overlimit = txqi->tin.overlimit; | |
4640 | } | |
4641 | ||
4642 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_COLLISIONS))) { | |
4643 | txqstats->filled |= BIT(NL80211_TXQ_STATS_COLLISIONS); | |
4644 | txqstats->collisions = txqi->tin.collisions; | |
4645 | } | |
4646 | ||
4647 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_BYTES))) { | |
4648 | txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_BYTES); | |
4649 | txqstats->tx_bytes = txqi->tin.tx_bytes; | |
4650 | } | |
4651 | ||
4652 | if (!(txqstats->filled & BIT(NL80211_TXQ_STATS_TX_PACKETS))) { | |
4653 | txqstats->filled |= BIT(NL80211_TXQ_STATS_TX_PACKETS); | |
4654 | txqstats->tx_packets = txqi->tin.tx_packets; | |
4655 | } | |
4656 | } | |
4657 | ||
4658 | static int ieee80211_get_txq_stats(struct wiphy *wiphy, | |
4659 | struct wireless_dev *wdev, | |
4660 | struct cfg80211_txq_stats *txqstats) | |
4661 | { | |
4662 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4663 | struct ieee80211_sub_if_data *sdata; | |
4664 | int ret = 0; | |
4665 | ||
2fe4a29a THJ |
4666 | spin_lock_bh(&local->fq.lock); |
4667 | rcu_read_lock(); | |
4668 | ||
4669 | if (wdev) { | |
4670 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
4671 | if (!sdata->vif.txq) { | |
4672 | ret = 1; | |
4673 | goto out; | |
4674 | } | |
4675 | ieee80211_fill_txq_stats(txqstats, to_txq_info(sdata->vif.txq)); | |
4676 | } else { | |
4677 | /* phy stats */ | |
4678 | txqstats->filled |= BIT(NL80211_TXQ_STATS_BACKLOG_PACKETS) | | |
4679 | BIT(NL80211_TXQ_STATS_BACKLOG_BYTES) | | |
4680 | BIT(NL80211_TXQ_STATS_OVERLIMIT) | | |
4681 | BIT(NL80211_TXQ_STATS_OVERMEMORY) | | |
4682 | BIT(NL80211_TXQ_STATS_COLLISIONS) | | |
4683 | BIT(NL80211_TXQ_STATS_MAX_FLOWS); | |
4684 | txqstats->backlog_packets = local->fq.backlog; | |
4685 | txqstats->backlog_bytes = local->fq.memory_usage; | |
4686 | txqstats->overlimit = local->fq.overlimit; | |
4687 | txqstats->overmemory = local->fq.overmemory; | |
4688 | txqstats->collisions = local->fq.collisions; | |
4689 | txqstats->max_flows = local->fq.flows_cnt; | |
4690 | } | |
4691 | ||
4692 | out: | |
4693 | rcu_read_unlock(); | |
4694 | spin_unlock_bh(&local->fq.lock); | |
4695 | ||
4696 | return ret; | |
4697 | } | |
4698 | ||
bc847970 PKC |
4699 | static int |
4700 | ieee80211_get_ftm_responder_stats(struct wiphy *wiphy, | |
4701 | struct net_device *dev, | |
4702 | struct cfg80211_ftm_responder_stats *ftm_stats) | |
4703 | { | |
4704 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4705 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4706 | ||
4707 | return drv_get_ftm_responder_stats(local, sdata, ftm_stats); | |
4708 | } | |
4709 | ||
cee7013b JB |
4710 | static int |
4711 | ieee80211_start_pmsr(struct wiphy *wiphy, struct wireless_dev *dev, | |
4712 | struct cfg80211_pmsr_request *request) | |
4713 | { | |
4714 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4715 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev); | |
4716 | ||
4717 | return drv_start_pmsr(local, sdata, request); | |
4718 | } | |
4719 | ||
4720 | static void | |
4721 | ieee80211_abort_pmsr(struct wiphy *wiphy, struct wireless_dev *dev, | |
4722 | struct cfg80211_pmsr_request *request) | |
4723 | { | |
4724 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4725 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(dev); | |
4726 | ||
4727 | return drv_abort_pmsr(local, sdata, request); | |
4728 | } | |
4729 | ||
370f51d5 T |
4730 | static int ieee80211_set_tid_config(struct wiphy *wiphy, |
4731 | struct net_device *dev, | |
4732 | struct cfg80211_tid_config *tid_conf) | |
4733 | { | |
4734 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4735 | struct sta_info *sta; | |
4d3acf43 JB |
4736 | |
4737 | lockdep_assert_wiphy(sdata->local->hw.wiphy); | |
370f51d5 T |
4738 | |
4739 | if (!sdata->local->ops->set_tid_config) | |
4740 | return -EOPNOTSUPP; | |
4741 | ||
4742 | if (!tid_conf->peer) | |
4743 | return drv_set_tid_config(sdata->local, sdata, NULL, tid_conf); | |
4744 | ||
370f51d5 | 4745 | sta = sta_info_get_bss(sdata, tid_conf->peer); |
4d3acf43 | 4746 | if (!sta) |
370f51d5 | 4747 | return -ENOENT; |
370f51d5 | 4748 | |
4d3acf43 | 4749 | return drv_set_tid_config(sdata->local, sdata, &sta->sta, tid_conf); |
370f51d5 T |
4750 | } |
4751 | ||
4752 | static int ieee80211_reset_tid_config(struct wiphy *wiphy, | |
4753 | struct net_device *dev, | |
60c2ef0e | 4754 | const u8 *peer, u8 tids) |
370f51d5 T |
4755 | { |
4756 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
4757 | struct sta_info *sta; | |
4d3acf43 JB |
4758 | |
4759 | lockdep_assert_wiphy(sdata->local->hw.wiphy); | |
370f51d5 T |
4760 | |
4761 | if (!sdata->local->ops->reset_tid_config) | |
4762 | return -EOPNOTSUPP; | |
4763 | ||
4764 | if (!peer) | |
60c2ef0e | 4765 | return drv_reset_tid_config(sdata->local, sdata, NULL, tids); |
370f51d5 | 4766 | |
370f51d5 | 4767 | sta = sta_info_get_bss(sdata, peer); |
4d3acf43 | 4768 | if (!sta) |
370f51d5 | 4769 | return -ENOENT; |
370f51d5 | 4770 | |
4d3acf43 | 4771 | return drv_reset_tid_config(sdata->local, sdata, &sta->sta, tids); |
370f51d5 T |
4772 | } |
4773 | ||
c534e093 CH |
4774 | static int ieee80211_set_sar_specs(struct wiphy *wiphy, |
4775 | struct cfg80211_sar_specs *sar) | |
4776 | { | |
4777 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
4778 | ||
4779 | if (!local->ops->set_sar_specs) | |
4780 | return -EOPNOTSUPP; | |
4781 | ||
4782 | return local->ops->set_sar_specs(&local->hw, sar); | |
4783 | } | |
4784 | ||
5f9404ab | 4785 | static int |
414e736c | 4786 | ieee80211_set_after_color_change_beacon(struct ieee80211_link_data *link, |
15ddba5f | 4787 | u64 *changed) |
5f9404ab | 4788 | { |
414e736c AKS |
4789 | struct ieee80211_sub_if_data *sdata = link->sdata; |
4790 | ||
5f9404ab JC |
4791 | switch (sdata->vif.type) { |
4792 | case NL80211_IFTYPE_AP: { | |
4793 | int ret; | |
4794 | ||
414e736c | 4795 | if (!link->u.ap.next_beacon) |
450c271d LB |
4796 | return -EINVAL; |
4797 | ||
414e736c AKS |
4798 | ret = ieee80211_assign_beacon(sdata, link, |
4799 | link->u.ap.next_beacon, | |
15ddba5f | 4800 | NULL, NULL, changed); |
414e736c | 4801 | ieee80211_free_next_beacon(link); |
5f9404ab JC |
4802 | |
4803 | if (ret < 0) | |
4804 | return ret; | |
4805 | ||
5f9404ab JC |
4806 | break; |
4807 | } | |
4808 | default: | |
4809 | WARN_ON_ONCE(1); | |
4810 | return -EINVAL; | |
4811 | } | |
4812 | ||
4813 | return 0; | |
4814 | } | |
4815 | ||
4816 | static int | |
414e736c | 4817 | ieee80211_set_color_change_beacon(struct ieee80211_link_data *link, |
5f9404ab | 4818 | struct cfg80211_color_change_settings *params, |
15ddba5f | 4819 | u64 *changed) |
5f9404ab | 4820 | { |
414e736c | 4821 | struct ieee80211_sub_if_data *sdata = link->sdata; |
5f9404ab JC |
4822 | struct ieee80211_color_change_settings color_change = {}; |
4823 | int err; | |
4824 | ||
4825 | switch (sdata->vif.type) { | |
4826 | case NL80211_IFTYPE_AP: | |
414e736c | 4827 | link->u.ap.next_beacon = |
5f9404ab | 4828 | cfg80211_beacon_dup(¶ms->beacon_next); |
414e736c | 4829 | if (!link->u.ap.next_beacon) |
5f9404ab JC |
4830 | return -ENOMEM; |
4831 | ||
4832 | if (params->count <= 1) | |
4833 | break; | |
4834 | ||
4835 | color_change.counter_offset_beacon = | |
4836 | params->counter_offset_beacon; | |
4837 | color_change.counter_offset_presp = | |
4838 | params->counter_offset_presp; | |
4839 | color_change.count = params->count; | |
4840 | ||
414e736c | 4841 | err = ieee80211_assign_beacon(sdata, link, |
d8675a63 | 4842 | ¶ms->beacon_color_change, |
15ddba5f | 4843 | NULL, &color_change, changed); |
5f9404ab | 4844 | if (err < 0) { |
414e736c | 4845 | ieee80211_free_next_beacon(link); |
5f9404ab JC |
4846 | return err; |
4847 | } | |
5f9404ab JC |
4848 | break; |
4849 | default: | |
4850 | return -EOPNOTSUPP; | |
4851 | } | |
4852 | ||
4853 | return 0; | |
4854 | } | |
4855 | ||
4856 | static void | |
414e736c | 4857 | ieee80211_color_change_bss_config_notify(struct ieee80211_link_data *link, |
15ddba5f | 4858 | u8 color, int enable, u64 changed) |
5f9404ab | 4859 | { |
414e736c AKS |
4860 | struct ieee80211_sub_if_data *sdata = link->sdata; |
4861 | ||
be0df01d JB |
4862 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
4863 | ||
414e736c AKS |
4864 | link->conf->he_bss_color.color = color; |
4865 | link->conf->he_bss_color.enabled = enable; | |
5f9404ab JC |
4866 | changed |= BSS_CHANGED_HE_BSS_COLOR; |
4867 | ||
414e736c | 4868 | ieee80211_link_info_change_notify(sdata, link, changed); |
eb87d3e0 | 4869 | |
f6008327 RS |
4870 | if (!link->conf->nontransmitted && |
4871 | rcu_access_pointer(link->conf->tx_bss_conf)) { | |
4872 | struct ieee80211_link_data *tmp; | |
eb87d3e0 | 4873 | |
f6008327 RS |
4874 | for_each_sdata_link(sdata->local, tmp) { |
4875 | if (tmp->sdata == sdata || | |
4876 | rcu_access_pointer(tmp->conf->tx_bss_conf) != link->conf) | |
4877 | continue; | |
4878 | ||
4879 | tmp->conf->he_bss_color.color = color; | |
4880 | tmp->conf->he_bss_color.enabled = enable; | |
4881 | ieee80211_link_info_change_notify(tmp->sdata, tmp, | |
4882 | BSS_CHANGED_HE_BSS_COLOR); | |
eb87d3e0 | 4883 | } |
eb87d3e0 | 4884 | } |
5f9404ab JC |
4885 | } |
4886 | ||
414e736c | 4887 | static int ieee80211_color_change_finalize(struct ieee80211_link_data *link) |
5f9404ab | 4888 | { |
414e736c | 4889 | struct ieee80211_sub_if_data *sdata = link->sdata; |
5f9404ab | 4890 | struct ieee80211_local *local = sdata->local; |
15ddba5f | 4891 | u64 changed = 0; |
5f9404ab JC |
4892 | int err; |
4893 | ||
0cd8080e | 4894 | lockdep_assert_wiphy(local->hw.wiphy); |
5f9404ab | 4895 | |
414e736c | 4896 | link->conf->color_change_active = false; |
5f9404ab | 4897 | |
414e736c | 4898 | err = ieee80211_set_after_color_change_beacon(link, &changed); |
5f9404ab | 4899 | if (err) { |
414e736c | 4900 | cfg80211_color_change_aborted_notify(sdata->dev, link->link_id); |
5f9404ab JC |
4901 | return err; |
4902 | } | |
4903 | ||
414e736c AKS |
4904 | ieee80211_color_change_bss_config_notify(link, |
4905 | link->conf->color_change_color, | |
5f9404ab | 4906 | 1, changed); |
414e736c | 4907 | cfg80211_color_change_notify(sdata->dev, link->link_id); |
5f9404ab JC |
4908 | |
4909 | return 0; | |
4910 | } | |
4911 | ||
b38579ae JB |
4912 | void ieee80211_color_change_finalize_work(struct wiphy *wiphy, |
4913 | struct wiphy_work *work) | |
5f9404ab | 4914 | { |
414e736c AKS |
4915 | struct ieee80211_link_data *link = |
4916 | container_of(work, struct ieee80211_link_data, | |
4917 | color_change_finalize_work); | |
4918 | struct ieee80211_sub_if_data *sdata = link->sdata; | |
4919 | struct ieee80211_bss_conf *link_conf = link->conf; | |
5f9404ab JC |
4920 | struct ieee80211_local *local = sdata->local; |
4921 | ||
0cd8080e | 4922 | lockdep_assert_wiphy(local->hw.wiphy); |
5f9404ab JC |
4923 | |
4924 | /* AP might have been stopped while waiting for the lock. */ | |
414e736c | 4925 | if (!link_conf->color_change_active) |
076fc877 | 4926 | return; |
5f9404ab JC |
4927 | |
4928 | if (!ieee80211_sdata_running(sdata)) | |
076fc877 | 4929 | return; |
5f9404ab | 4930 | |
414e736c | 4931 | ieee80211_color_change_finalize(link); |
5f9404ab JC |
4932 | } |
4933 | ||
4cc6f3e5 RP |
4934 | void ieee80211_color_collision_detection_work(struct wiphy *wiphy, |
4935 | struct wiphy_work *work) | |
92881884 | 4936 | { |
92881884 | 4937 | struct ieee80211_link_data *link = |
4cc6f3e5 RP |
4938 | container_of(work, struct ieee80211_link_data, |
4939 | color_collision_detect_work.work); | |
92881884 LB |
4940 | struct ieee80211_sub_if_data *sdata = link->sdata; |
4941 | ||
414e736c AKS |
4942 | cfg80211_obss_color_collision_notify(sdata->dev, link->color_bitmap, |
4943 | link->link_id); | |
92881884 LB |
4944 | } |
4945 | ||
414e736c | 4946 | void ieee80211_color_change_finish(struct ieee80211_vif *vif, u8 link_id) |
5f9404ab JC |
4947 | { |
4948 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | |
414e736c AKS |
4949 | struct ieee80211_link_data *link; |
4950 | ||
4951 | if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS)) | |
4952 | return; | |
4953 | ||
4954 | rcu_read_lock(); | |
4955 | ||
4956 | link = rcu_dereference(sdata->link[link_id]); | |
4957 | if (WARN_ON(!link)) { | |
4958 | rcu_read_unlock(); | |
4959 | return; | |
4960 | } | |
5f9404ab | 4961 | |
b38579ae | 4962 | wiphy_work_queue(sdata->local->hw.wiphy, |
414e736c AKS |
4963 | &link->color_change_finalize_work); |
4964 | ||
4965 | rcu_read_unlock(); | |
5f9404ab JC |
4966 | } |
4967 | EXPORT_SYMBOL_GPL(ieee80211_color_change_finish); | |
4968 | ||
4969 | void | |
82253dda | 4970 | ieee80211_obss_color_collision_notify(struct ieee80211_vif *vif, |
414e736c | 4971 | u64 color_bitmap, u8 link_id) |
5f9404ab JC |
4972 | { |
4973 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); | |
414e736c | 4974 | struct ieee80211_link_data *link; |
5f9404ab | 4975 | |
414e736c | 4976 | if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS)) |
5f9404ab JC |
4977 | return; |
4978 | ||
414e736c AKS |
4979 | rcu_read_lock(); |
4980 | ||
4981 | link = rcu_dereference(sdata->link[link_id]); | |
4982 | if (WARN_ON(!link)) { | |
4983 | rcu_read_unlock(); | |
92881884 | 4984 | return; |
414e736c AKS |
4985 | } |
4986 | ||
4987 | if (link->conf->color_change_active || link->conf->csa_active) { | |
4988 | rcu_read_unlock(); | |
4989 | return; | |
4990 | } | |
4991 | ||
4cc6f3e5 RP |
4992 | if (wiphy_delayed_work_pending(sdata->local->hw.wiphy, |
4993 | &link->color_collision_detect_work)) { | |
414e736c AKS |
4994 | rcu_read_unlock(); |
4995 | return; | |
4996 | } | |
92881884 LB |
4997 | |
4998 | link->color_bitmap = color_bitmap; | |
4999 | /* queue the color collision detection event every 500 ms in order to | |
5000 | * avoid sending too much netlink messages to userspace. | |
5001 | */ | |
4cc6f3e5 RP |
5002 | wiphy_delayed_work_queue(sdata->local->hw.wiphy, |
5003 | &link->color_collision_detect_work, | |
5004 | msecs_to_jiffies(500)); | |
414e736c AKS |
5005 | |
5006 | rcu_read_unlock(); | |
5f9404ab | 5007 | } |
82253dda | 5008 | EXPORT_SYMBOL_GPL(ieee80211_obss_color_collision_notify); |
5f9404ab JC |
5009 | |
5010 | static int | |
5011 | ieee80211_color_change(struct wiphy *wiphy, struct net_device *dev, | |
5012 | struct cfg80211_color_change_settings *params) | |
5013 | { | |
5014 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
5015 | struct ieee80211_local *local = sdata->local; | |
414e736c AKS |
5016 | struct ieee80211_bss_conf *link_conf; |
5017 | struct ieee80211_link_data *link; | |
5018 | u8 link_id = params->link_id; | |
15ddba5f | 5019 | u64 changed = 0; |
5f9404ab JC |
5020 | int err; |
5021 | ||
0cd8080e | 5022 | lockdep_assert_wiphy(local->hw.wiphy); |
5f9404ab | 5023 | |
414e736c AKS |
5024 | if (WARN_ON(link_id >= IEEE80211_MLD_MAX_NUM_LINKS)) |
5025 | return -EINVAL; | |
5026 | ||
5027 | link = wiphy_dereference(wiphy, sdata->link[link_id]); | |
5028 | if (!link) | |
5029 | return -ENOLINK; | |
5030 | ||
5031 | link_conf = link->conf; | |
5032 | ||
5033 | if (link_conf->nontransmitted) | |
eb87d3e0 JC |
5034 | return -EINVAL; |
5035 | ||
5f9404ab JC |
5036 | /* don't allow another color change if one is already active or if csa |
5037 | * is active | |
5038 | */ | |
414e736c | 5039 | if (link_conf->color_change_active || link_conf->csa_active) { |
5f9404ab JC |
5040 | err = -EBUSY; |
5041 | goto out; | |
5042 | } | |
5043 | ||
414e736c | 5044 | err = ieee80211_set_color_change_beacon(link, params, &changed); |
5f9404ab JC |
5045 | if (err) |
5046 | goto out; | |
5047 | ||
414e736c AKS |
5048 | link_conf->color_change_active = true; |
5049 | link_conf->color_change_color = params->color; | |
5f9404ab | 5050 | |
414e736c | 5051 | cfg80211_color_change_started_notify(sdata->dev, params->count, link_id); |
5f9404ab JC |
5052 | |
5053 | if (changed) | |
414e736c | 5054 | ieee80211_color_change_bss_config_notify(link, 0, 0, changed); |
5f9404ab JC |
5055 | else |
5056 | /* if the beacon didn't change, we can finalize immediately */ | |
414e736c | 5057 | ieee80211_color_change_finalize(link); |
5f9404ab JC |
5058 | |
5059 | out: | |
5f9404ab JC |
5060 | |
5061 | return err; | |
5062 | } | |
5063 | ||
237337c2 | 5064 | static int |
a95bfb87 LB |
5065 | ieee80211_set_radar_background(struct wiphy *wiphy, |
5066 | struct cfg80211_chan_def *chandef) | |
237337c2 LB |
5067 | { |
5068 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
5069 | ||
a95bfb87 | 5070 | if (!local->ops->set_radar_background) |
237337c2 LB |
5071 | return -EOPNOTSUPP; |
5072 | ||
a95bfb87 | 5073 | return local->ops->set_radar_background(&local->hw, chandef); |
237337c2 LB |
5074 | } |
5075 | ||
0d8c4a3c JB |
5076 | static int ieee80211_add_intf_link(struct wiphy *wiphy, |
5077 | struct wireless_dev *wdev, | |
5078 | unsigned int link_id) | |
5079 | { | |
5080 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
0cd8080e JB |
5081 | |
5082 | lockdep_assert_wiphy(sdata->local->hw.wiphy); | |
0d8c4a3c | 5083 | |
90703ba9 JB |
5084 | if (wdev->use_4addr) |
5085 | return -EOPNOTSUPP; | |
5086 | ||
0cd8080e | 5087 | return ieee80211_vif_set_links(sdata, wdev->valid_links, 0); |
0d8c4a3c JB |
5088 | } |
5089 | ||
5090 | static void ieee80211_del_intf_link(struct wiphy *wiphy, | |
5091 | struct wireless_dev *wdev, | |
5092 | unsigned int link_id) | |
5093 | { | |
5094 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
b5c32ff6 | 5095 | u16 new_links = wdev->valid_links & ~BIT(link_id); |
0d8c4a3c | 5096 | |
0cd8080e JB |
5097 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
5098 | ||
b5c32ff6 AKS |
5099 | /* During the link teardown process, certain functions require the |
5100 | * link_id to remain in the valid_links bitmap. Therefore, instead | |
5101 | * of removing the link_id from the bitmap, pass a masked value to | |
5102 | * simulate as if link_id does not exist anymore. | |
5103 | */ | |
5104 | ieee80211_vif_set_links(sdata, new_links, 0); | |
0d8c4a3c JB |
5105 | } |
5106 | ||
5c24e83f JB |
5107 | static int |
5108 | ieee80211_add_link_station(struct wiphy *wiphy, struct net_device *dev, | |
5109 | struct link_station_parameters *params) | |
21476ad1 | 5110 | { |
5c24e83f JB |
5111 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
5112 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
21476ad1 ST |
5113 | struct sta_info *sta; |
5114 | int ret; | |
5115 | ||
5c24e83f JB |
5116 | lockdep_assert_wiphy(local->hw.wiphy); |
5117 | ||
21476ad1 ST |
5118 | sta = sta_info_get_bss(sdata, params->mld_mac); |
5119 | if (!sta) | |
5120 | return -ENOENT; | |
5121 | ||
956b9613 JB |
5122 | if (!sta->sta.valid_links) |
5123 | return -EINVAL; | |
5124 | ||
21476ad1 ST |
5125 | if (sta->sta.valid_links & BIT(params->link_id)) |
5126 | return -EALREADY; | |
5127 | ||
5128 | ret = ieee80211_sta_allocate_link(sta, params->link_id); | |
5129 | if (ret) | |
5130 | return ret; | |
5131 | ||
03ecd745 | 5132 | ret = sta_link_apply_parameters(local, sta, STA_LINK_MODE_NEW, params); |
21476ad1 ST |
5133 | if (ret) { |
5134 | ieee80211_sta_free_link(sta, params->link_id); | |
5135 | return ret; | |
5136 | } | |
5137 | ||
f828deb7 JB |
5138 | if (test_sta_flag(sta, WLAN_STA_ASSOC)) { |
5139 | struct link_sta_info *link_sta; | |
5140 | ||
5141 | link_sta = sdata_dereference(sta->link[params->link_id], sdata); | |
5142 | rate_control_rate_init(link_sta); | |
5143 | } | |
5144 | ||
21476ad1 ST |
5145 | /* ieee80211_sta_activate_link frees the link upon failure */ |
5146 | return ieee80211_sta_activate_link(sta, params->link_id); | |
5147 | } | |
5148 | ||
5149 | static int | |
5c24e83f | 5150 | ieee80211_mod_link_station(struct wiphy *wiphy, struct net_device *dev, |
21476ad1 ST |
5151 | struct link_station_parameters *params) |
5152 | { | |
5153 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
5154 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
21476ad1 ST |
5155 | struct sta_info *sta; |
5156 | ||
5c24e83f JB |
5157 | lockdep_assert_wiphy(local->hw.wiphy); |
5158 | ||
21476ad1 ST |
5159 | sta = sta_info_get_bss(sdata, params->mld_mac); |
5160 | if (!sta) | |
5161 | return -ENOENT; | |
5162 | ||
5163 | if (!(sta->sta.valid_links & BIT(params->link_id))) | |
5164 | return -EINVAL; | |
5165 | ||
03ecd745 JB |
5166 | return sta_link_apply_parameters(local, sta, STA_LINK_MODE_LINK_MODIFY, |
5167 | params); | |
21476ad1 ST |
5168 | } |
5169 | ||
5170 | static int | |
5c24e83f JB |
5171 | ieee80211_del_link_station(struct wiphy *wiphy, struct net_device *dev, |
5172 | struct link_station_del_parameters *params) | |
21476ad1 ST |
5173 | { |
5174 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
5c24e83f | 5175 | struct sta_info *sta; |
21476ad1 | 5176 | |
4d3acf43 | 5177 | lockdep_assert_wiphy(sdata->local->hw.wiphy); |
21476ad1 | 5178 | |
21476ad1 ST |
5179 | sta = sta_info_get_bss(sdata, params->mld_mac); |
5180 | if (!sta) | |
5181 | return -ENOENT; | |
5182 | ||
5183 | if (!(sta->sta.valid_links & BIT(params->link_id))) | |
5184 | return -EINVAL; | |
5185 | ||
956b9613 JB |
5186 | /* must not create a STA without links */ |
5187 | if (sta->sta.valid_links == BIT(params->link_id)) | |
5188 | return -EINVAL; | |
5189 | ||
21476ad1 ST |
5190 | ieee80211_sta_remove_link(sta, params->link_id); |
5191 | ||
5192 | return 0; | |
5193 | } | |
5194 | ||
81202305 AS |
5195 | static int ieee80211_set_hw_timestamp(struct wiphy *wiphy, |
5196 | struct net_device *dev, | |
5197 | struct cfg80211_set_hw_timestamp *hwts) | |
5198 | { | |
5199 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
5200 | struct ieee80211_local *local = sdata->local; | |
5201 | ||
5202 | if (!local->ops->set_hw_timestamp) | |
5203 | return -EOPNOTSUPP; | |
5204 | ||
5205 | if (!check_sdata_in_driver(sdata)) | |
5206 | return -EIO; | |
5207 | ||
5208 | return local->ops->set_hw_timestamp(&local->hw, &sdata->vif, hwts); | |
5209 | } | |
5210 | ||
f7660b3f AB |
5211 | static int |
5212 | ieee80211_set_ttlm(struct wiphy *wiphy, struct net_device *dev, | |
5213 | struct cfg80211_ttlm_params *params) | |
5214 | { | |
5215 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
5216 | ||
5217 | lockdep_assert_wiphy(sdata->local->hw.wiphy); | |
5218 | ||
5219 | return ieee80211_req_neg_ttlm(sdata, params); | |
5220 | } | |
5221 | ||
36e05b0b IP |
5222 | static int |
5223 | ieee80211_assoc_ml_reconf(struct wiphy *wiphy, struct net_device *dev, | |
a096a860 | 5224 | struct cfg80211_ml_reconf_req *req) |
36e05b0b IP |
5225 | { |
5226 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
5227 | ||
5228 | lockdep_assert_wiphy(sdata->local->hw.wiphy); | |
5229 | ||
a096a860 | 5230 | return ieee80211_mgd_assoc_ml_reconf(sdata, req); |
36e05b0b IP |
5231 | } |
5232 | ||
de86c5f6 IP |
5233 | static int |
5234 | ieee80211_set_epcs(struct wiphy *wiphy, struct net_device *dev, bool enable) | |
5235 | { | |
5236 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
5237 | ||
5238 | return ieee80211_mgd_set_epcs(sdata, enable); | |
5239 | } | |
5240 | ||
8a47cea7 | 5241 | const struct cfg80211_ops mac80211_config_ops = { |
f0706e82 JB |
5242 | .add_virtual_intf = ieee80211_add_iface, |
5243 | .del_virtual_intf = ieee80211_del_iface, | |
42613db7 | 5244 | .change_virtual_intf = ieee80211_change_iface, |
f142c6b9 JB |
5245 | .start_p2p_device = ieee80211_start_p2p_device, |
5246 | .stop_p2p_device = ieee80211_stop_p2p_device, | |
e8cbb4cb JB |
5247 | .add_key = ieee80211_add_key, |
5248 | .del_key = ieee80211_del_key, | |
62da92fb | 5249 | .get_key = ieee80211_get_key, |
e8cbb4cb | 5250 | .set_default_key = ieee80211_config_default_key, |
3cfcf6ac | 5251 | .set_default_mgmt_key = ieee80211_config_default_mgmt_key, |
e5473e80 | 5252 | .set_default_beacon_key = ieee80211_config_default_beacon_key, |
8860020e JB |
5253 | .start_ap = ieee80211_start_ap, |
5254 | .change_beacon = ieee80211_change_beacon, | |
5255 | .stop_ap = ieee80211_stop_ap, | |
4fd6931e JB |
5256 | .add_station = ieee80211_add_station, |
5257 | .del_station = ieee80211_del_station, | |
5258 | .change_station = ieee80211_change_station, | |
7bbdd2d9 | 5259 | .get_station = ieee80211_get_station, |
c5dd9c2b | 5260 | .dump_station = ieee80211_dump_station, |
1289723e | 5261 | .dump_survey = ieee80211_dump_survey, |
c5dd9c2b LCC |
5262 | #ifdef CONFIG_MAC80211_MESH |
5263 | .add_mpath = ieee80211_add_mpath, | |
5264 | .del_mpath = ieee80211_del_mpath, | |
5265 | .change_mpath = ieee80211_change_mpath, | |
5266 | .get_mpath = ieee80211_get_mpath, | |
5267 | .dump_mpath = ieee80211_dump_mpath, | |
a2db2ed3 HR |
5268 | .get_mpp = ieee80211_get_mpp, |
5269 | .dump_mpp = ieee80211_dump_mpp, | |
24bdd9f4 JC |
5270 | .update_mesh_config = ieee80211_update_mesh_config, |
5271 | .get_mesh_config = ieee80211_get_mesh_config, | |
29cbe68c JB |
5272 | .join_mesh = ieee80211_join_mesh, |
5273 | .leave_mesh = ieee80211_leave_mesh, | |
c5dd9c2b | 5274 | #endif |
239281f8 RL |
5275 | .join_ocb = ieee80211_join_ocb, |
5276 | .leave_ocb = ieee80211_leave_ocb, | |
9f1ba906 | 5277 | .change_bss = ieee80211_change_bss, |
108d2022 | 5278 | .inform_bss = ieee80211_inform_bss, |
31888487 | 5279 | .set_txq_params = ieee80211_set_txq_params, |
e8c9bd5b | 5280 | .set_monitor_channel = ieee80211_set_monitor_channel, |
665af4fc BC |
5281 | .suspend = ieee80211_suspend, |
5282 | .resume = ieee80211_resume, | |
2a519311 | 5283 | .scan = ieee80211_scan, |
91f123f2 | 5284 | .abort_scan = ieee80211_abort_scan, |
79f460ca LC |
5285 | .sched_scan_start = ieee80211_sched_scan_start, |
5286 | .sched_scan_stop = ieee80211_sched_scan_stop, | |
636a5d36 JM |
5287 | .auth = ieee80211_auth, |
5288 | .assoc = ieee80211_assoc, | |
5289 | .deauth = ieee80211_deauth, | |
5290 | .disassoc = ieee80211_disassoc, | |
af8cdcd8 JB |
5291 | .join_ibss = ieee80211_join_ibss, |
5292 | .leave_ibss = ieee80211_leave_ibss, | |
391e53e3 | 5293 | .set_mcast_rate = ieee80211_set_mcast_rate, |
b9a5f8ca | 5294 | .set_wiphy_params = ieee80211_set_wiphy_params, |
7643a2c3 JB |
5295 | .set_tx_power = ieee80211_set_tx_power, |
5296 | .get_tx_power = ieee80211_get_tx_power, | |
1f87f7d3 | 5297 | .rfkill_poll = ieee80211_rfkill_poll, |
aff89a9b | 5298 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) |
71063f0e | 5299 | CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump) |
bc92afd9 | 5300 | .set_power_mgmt = ieee80211_set_power_mgmt, |
9930380f | 5301 | .set_bitrate_mask = ieee80211_set_bitrate_mask, |
b8bc4b0a JB |
5302 | .remain_on_channel = ieee80211_remain_on_channel, |
5303 | .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, | |
2e161f78 | 5304 | .mgmt_tx = ieee80211_mgmt_tx, |
f30221e4 | 5305 | .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait, |
a97c13c3 | 5306 | .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config, |
2c3c5f8c | 5307 | .set_cqm_rssi_range_config = ieee80211_set_cqm_rssi_range_config, |
6cd536fe JB |
5308 | .update_mgmt_frame_registrations = |
5309 | ieee80211_update_mgmt_frame_registrations, | |
15d96753 BR |
5310 | .set_antenna = ieee80211_set_antenna, |
5311 | .get_antenna = ieee80211_get_antenna, | |
c68f4b89 | 5312 | .set_rekey_data = ieee80211_set_rekey_data, |
dfe018bf AN |
5313 | .tdls_oper = ieee80211_tdls_oper, |
5314 | .tdls_mgmt = ieee80211_tdls_mgmt, | |
a7a6bdd0 AN |
5315 | .tdls_channel_switch = ieee80211_tdls_channel_switch, |
5316 | .tdls_cancel_channel_switch = ieee80211_tdls_cancel_channel_switch, | |
06500736 | 5317 | .probe_client = ieee80211_probe_client, |
b53be792 | 5318 | .set_noack_map = ieee80211_set_noack_map, |
6d52563f JB |
5319 | #ifdef CONFIG_PM |
5320 | .set_wakeup = ieee80211_set_wakeup, | |
5321 | #endif | |
5b7ccaf3 | 5322 | .get_channel = ieee80211_cfg_get_channel, |
164eb02d | 5323 | .start_radar_detection = ieee80211_start_radar_detection, |
26ec17a1 | 5324 | .end_cac = ieee80211_end_cac, |
73da7d5b | 5325 | .channel_switch = ieee80211_channel_switch, |
32db6b54 | 5326 | .set_qos_map = ieee80211_set_qos_map, |
3b1700bd | 5327 | .set_ap_chanwidth = ieee80211_set_ap_chanwidth, |
02219b3a JB |
5328 | .add_tx_ts = ieee80211_add_tx_ts, |
5329 | .del_tx_ts = ieee80211_del_tx_ts, | |
708d50ed AB |
5330 | .start_nan = ieee80211_start_nan, |
5331 | .stop_nan = ieee80211_stop_nan, | |
5953ff6d | 5332 | .nan_change_conf = ieee80211_nan_change_conf, |
167e33f4 AB |
5333 | .add_nan_func = ieee80211_add_nan_func, |
5334 | .del_nan_func = ieee80211_del_nan_func, | |
ebceec86 | 5335 | .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast, |
91180649 | 5336 | .tx_control_port = ieee80211_tx_control_port, |
2fe4a29a | 5337 | .get_txq_stats = ieee80211_get_txq_stats, |
bc847970 | 5338 | .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats, |
cee7013b JB |
5339 | .start_pmsr = ieee80211_start_pmsr, |
5340 | .abort_pmsr = ieee80211_abort_pmsr, | |
8828f81a | 5341 | .probe_mesh_link = ieee80211_probe_mesh_link, |
370f51d5 T |
5342 | .set_tid_config = ieee80211_set_tid_config, |
5343 | .reset_tid_config = ieee80211_reset_tid_config, | |
c534e093 | 5344 | .set_sar_specs = ieee80211_set_sar_specs, |
5f9404ab | 5345 | .color_change = ieee80211_color_change, |
a95bfb87 | 5346 | .set_radar_background = ieee80211_set_radar_background, |
0d8c4a3c JB |
5347 | .add_intf_link = ieee80211_add_intf_link, |
5348 | .del_intf_link = ieee80211_del_intf_link, | |
21476ad1 ST |
5349 | .add_link_station = ieee80211_add_link_station, |
5350 | .mod_link_station = ieee80211_mod_link_station, | |
5351 | .del_link_station = ieee80211_del_link_station, | |
81202305 | 5352 | .set_hw_timestamp = ieee80211_set_hw_timestamp, |
f7660b3f | 5353 | .set_ttlm = ieee80211_set_ttlm, |
0874bcd0 | 5354 | .get_radio_mask = ieee80211_get_radio_mask, |
36e05b0b | 5355 | .assoc_ml_reconf = ieee80211_assoc_ml_reconf, |
de86c5f6 | 5356 | .set_epcs = ieee80211_set_epcs, |
f0706e82 | 5357 | }; |