]>
Commit | Line | Data |
---|---|---|
f0706e82 JB |
1 | /* |
2 | * mac80211 configuration hooks for cfg80211 | |
3 | * | |
026331c4 | 4 | * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> |
f0706e82 JB |
5 | * |
6 | * This file is GPLv2 as found in COPYING. | |
7 | */ | |
8 | ||
e8cbb4cb | 9 | #include <linux/ieee80211.h> |
f0706e82 JB |
10 | #include <linux/nl80211.h> |
11 | #include <linux/rtnetlink.h> | |
5a0e3ad6 | 12 | #include <linux/slab.h> |
881d966b | 13 | #include <net/net_namespace.h> |
5dfdaf58 | 14 | #include <linux/rcupdate.h> |
dfe018bf | 15 | #include <linux/if_ether.h> |
f0706e82 JB |
16 | #include <net/cfg80211.h> |
17 | #include "ieee80211_i.h" | |
24487981 | 18 | #include "driver-ops.h" |
e0eb6859 | 19 | #include "cfg.h" |
2c8dccc7 | 20 | #include "rate.h" |
c5dd9c2b | 21 | #include "mesh.h" |
c5dd9c2b | 22 | |
552bff0c JB |
23 | static struct wireless_dev *ieee80211_add_iface(struct wiphy *wiphy, |
24 | const char *name, | |
84efbb84 JB |
25 | enum nl80211_iftype type, |
26 | u32 *flags, | |
27 | struct vif_params *params) | |
f0706e82 JB |
28 | { |
29 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
84efbb84 | 30 | struct wireless_dev *wdev; |
8cc9a739 MW |
31 | struct ieee80211_sub_if_data *sdata; |
32 | int err; | |
f0706e82 | 33 | |
84efbb84 | 34 | err = ieee80211_if_add(local, name, &wdev, type, params); |
f9e10ce4 JB |
35 | if (err) |
36 | return ERR_PTR(err); | |
8cc9a739 | 37 | |
f9e10ce4 | 38 | if (type == NL80211_IFTYPE_MONITOR && flags) { |
84efbb84 | 39 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
f9e10ce4 JB |
40 | sdata->u.mntr_flags = *flags; |
41 | } | |
42 | ||
84efbb84 | 43 | return wdev; |
f0706e82 JB |
44 | } |
45 | ||
84efbb84 | 46 | static int ieee80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev) |
f0706e82 | 47 | { |
84efbb84 | 48 | ieee80211_if_remove(IEEE80211_WDEV_TO_SUB_IF(wdev)); |
f0706e82 | 49 | |
75636525 | 50 | return 0; |
f0706e82 JB |
51 | } |
52 | ||
e36d56b6 JB |
53 | static int ieee80211_change_iface(struct wiphy *wiphy, |
54 | struct net_device *dev, | |
2ec600d6 LCC |
55 | enum nl80211_iftype type, u32 *flags, |
56 | struct vif_params *params) | |
42613db7 | 57 | { |
9607e6b6 | 58 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
f3947e2d | 59 | int ret; |
42613db7 | 60 | |
05c914fe | 61 | ret = ieee80211_if_change_type(sdata, type); |
f3947e2d JB |
62 | if (ret) |
63 | return ret; | |
42613db7 | 64 | |
9bc383de JB |
65 | if (type == NL80211_IFTYPE_AP_VLAN && |
66 | params && params->use_4addr == 0) | |
a9b3cd7f | 67 | RCU_INIT_POINTER(sdata->u.vlan.sta, NULL); |
9bc383de JB |
68 | else if (type == NL80211_IFTYPE_STATION && |
69 | params && params->use_4addr >= 0) | |
70 | sdata->u.mgd.use_4addr = params->use_4addr; | |
71 | ||
85416a4f CL |
72 | if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) { |
73 | struct ieee80211_local *local = sdata->local; | |
74 | ||
75 | if (ieee80211_sdata_running(sdata)) { | |
31eba5bc FF |
76 | u32 mask = MONITOR_FLAG_COOK_FRAMES | |
77 | MONITOR_FLAG_ACTIVE; | |
78 | ||
85416a4f | 79 | /* |
31eba5bc FF |
80 | * Prohibit MONITOR_FLAG_COOK_FRAMES and |
81 | * MONITOR_FLAG_ACTIVE to be changed while the | |
82 | * interface is up. | |
85416a4f CL |
83 | * Else we would need to add a lot of cruft |
84 | * to update everything: | |
85 | * cooked_mntrs, monitor and all fif_* counters | |
86 | * reconfigure hardware | |
87 | */ | |
31eba5bc | 88 | if ((*flags & mask) != (sdata->u.mntr_flags & mask)) |
85416a4f CL |
89 | return -EBUSY; |
90 | ||
91 | ieee80211_adjust_monitor_flags(sdata, -1); | |
92 | sdata->u.mntr_flags = *flags; | |
93 | ieee80211_adjust_monitor_flags(sdata, 1); | |
94 | ||
95 | ieee80211_configure_filter(local); | |
96 | } else { | |
97 | /* | |
98 | * Because the interface is down, ieee80211_do_stop | |
99 | * and ieee80211_do_open take care of "everything" | |
100 | * mentioned in the comment above. | |
101 | */ | |
102 | sdata->u.mntr_flags = *flags; | |
103 | } | |
104 | } | |
f7917af9 | 105 | |
42613db7 JB |
106 | return 0; |
107 | } | |
108 | ||
f142c6b9 JB |
109 | static int ieee80211_start_p2p_device(struct wiphy *wiphy, |
110 | struct wireless_dev *wdev) | |
111 | { | |
b6a55015 LC |
112 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
113 | int ret; | |
114 | ||
115 | mutex_lock(&sdata->local->chanctx_mtx); | |
116 | ret = ieee80211_check_combinations(sdata, NULL, 0, 0); | |
117 | mutex_unlock(&sdata->local->chanctx_mtx); | |
118 | if (ret < 0) | |
119 | return ret; | |
120 | ||
f142c6b9 JB |
121 | return ieee80211_do_open(wdev, true); |
122 | } | |
123 | ||
124 | static void ieee80211_stop_p2p_device(struct wiphy *wiphy, | |
125 | struct wireless_dev *wdev) | |
126 | { | |
127 | ieee80211_sdata_stop(IEEE80211_WDEV_TO_SUB_IF(wdev)); | |
128 | } | |
129 | ||
b53be792 SW |
130 | static int ieee80211_set_noack_map(struct wiphy *wiphy, |
131 | struct net_device *dev, | |
132 | u16 noack_map) | |
133 | { | |
134 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
135 | ||
136 | sdata->noack_map = noack_map; | |
137 | return 0; | |
138 | } | |
139 | ||
e8cbb4cb | 140 | static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, |
e31b8213 | 141 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
e8cbb4cb JB |
142 | struct key_params *params) |
143 | { | |
26a58456 | 144 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2475b1cc | 145 | struct ieee80211_local *local = sdata->local; |
e8cbb4cb | 146 | struct sta_info *sta = NULL; |
2475b1cc | 147 | const struct ieee80211_cipher_scheme *cs = NULL; |
db4d1169 | 148 | struct ieee80211_key *key; |
3b96766f | 149 | int err; |
e8cbb4cb | 150 | |
26a58456 | 151 | if (!ieee80211_sdata_running(sdata)) |
ad0e2b5a JB |
152 | return -ENETDOWN; |
153 | ||
97359d12 | 154 | /* reject WEP and TKIP keys if WEP failed to initialize */ |
e8cbb4cb JB |
155 | switch (params->cipher) { |
156 | case WLAN_CIPHER_SUITE_WEP40: | |
e8cbb4cb | 157 | case WLAN_CIPHER_SUITE_TKIP: |
97359d12 | 158 | case WLAN_CIPHER_SUITE_WEP104: |
2475b1cc | 159 | if (IS_ERR(local->wep_tx_tfm)) |
97359d12 | 160 | return -EINVAL; |
3cfcf6ac | 161 | break; |
2475b1cc MS |
162 | case WLAN_CIPHER_SUITE_CCMP: |
163 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
164 | case WLAN_CIPHER_SUITE_GCMP: | |
165 | break; | |
e8cbb4cb | 166 | default: |
2475b1cc | 167 | cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type); |
97359d12 | 168 | break; |
e8cbb4cb JB |
169 | } |
170 | ||
97359d12 | 171 | key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len, |
2475b1cc MS |
172 | params->key, params->seq_len, params->seq, |
173 | cs); | |
1ac62ba7 BH |
174 | if (IS_ERR(key)) |
175 | return PTR_ERR(key); | |
db4d1169 | 176 | |
e31b8213 JB |
177 | if (pairwise) |
178 | key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE; | |
179 | ||
2475b1cc | 180 | mutex_lock(&local->sta_mtx); |
3b96766f | 181 | |
e8cbb4cb | 182 | if (mac_addr) { |
ff973af7 TP |
183 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
184 | sta = sta_info_get(sdata, mac_addr); | |
185 | else | |
186 | sta = sta_info_get_bss(sdata, mac_addr); | |
1626e0fa JB |
187 | /* |
188 | * The ASSOC test makes sure the driver is ready to | |
189 | * receive the key. When wpa_supplicant has roamed | |
190 | * using FT, it attempts to set the key before | |
191 | * association has completed, this rejects that attempt | |
192 | * so it will set the key again after assocation. | |
193 | * | |
194 | * TODO: accept the key if we have a station entry and | |
195 | * add it to the device after the station. | |
196 | */ | |
197 | if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) { | |
79cf2dfa | 198 | ieee80211_key_free_unused(key); |
3b96766f JB |
199 | err = -ENOENT; |
200 | goto out_unlock; | |
db4d1169 | 201 | } |
e8cbb4cb JB |
202 | } |
203 | ||
e548c49e JB |
204 | switch (sdata->vif.type) { |
205 | case NL80211_IFTYPE_STATION: | |
206 | if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) | |
207 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; | |
208 | break; | |
209 | case NL80211_IFTYPE_AP: | |
210 | case NL80211_IFTYPE_AP_VLAN: | |
211 | /* Keys without a station are used for TX only */ | |
212 | if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP)) | |
213 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; | |
214 | break; | |
215 | case NL80211_IFTYPE_ADHOC: | |
216 | /* no MFP (yet) */ | |
217 | break; | |
218 | case NL80211_IFTYPE_MESH_POINT: | |
219 | #ifdef CONFIG_MAC80211_MESH | |
220 | if (sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE) | |
221 | key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; | |
222 | break; | |
223 | #endif | |
224 | case NL80211_IFTYPE_WDS: | |
225 | case NL80211_IFTYPE_MONITOR: | |
226 | case NL80211_IFTYPE_P2P_DEVICE: | |
227 | case NL80211_IFTYPE_UNSPECIFIED: | |
228 | case NUM_NL80211_IFTYPES: | |
229 | case NL80211_IFTYPE_P2P_CLIENT: | |
230 | case NL80211_IFTYPE_P2P_GO: | |
231 | /* shouldn't happen */ | |
232 | WARN_ON_ONCE(1); | |
233 | break; | |
234 | } | |
235 | ||
2475b1cc MS |
236 | if (sta) |
237 | sta->cipher_scheme = cs; | |
238 | ||
3ffc2a90 | 239 | err = ieee80211_key_link(key, sdata, sta); |
db4d1169 | 240 | |
3b96766f | 241 | out_unlock: |
2475b1cc | 242 | mutex_unlock(&local->sta_mtx); |
3b96766f JB |
243 | |
244 | return err; | |
e8cbb4cb JB |
245 | } |
246 | ||
247 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | |
e31b8213 | 248 | u8 key_idx, bool pairwise, const u8 *mac_addr) |
e8cbb4cb | 249 | { |
5c0c3641 JB |
250 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
251 | struct ieee80211_local *local = sdata->local; | |
e8cbb4cb | 252 | struct sta_info *sta; |
5c0c3641 | 253 | struct ieee80211_key *key = NULL; |
e8cbb4cb JB |
254 | int ret; |
255 | ||
5c0c3641 JB |
256 | mutex_lock(&local->sta_mtx); |
257 | mutex_lock(&local->key_mtx); | |
3b96766f | 258 | |
e8cbb4cb | 259 | if (mac_addr) { |
3b96766f JB |
260 | ret = -ENOENT; |
261 | ||
0e5ded5a | 262 | sta = sta_info_get_bss(sdata, mac_addr); |
e8cbb4cb | 263 | if (!sta) |
3b96766f | 264 | goto out_unlock; |
e8cbb4cb | 265 | |
5c0c3641 | 266 | if (pairwise) |
2475b1cc | 267 | key = key_mtx_dereference(local, sta->ptk[key_idx]); |
5c0c3641 | 268 | else |
40b275b6 | 269 | key = key_mtx_dereference(local, sta->gtk[key_idx]); |
5c0c3641 | 270 | } else |
40b275b6 | 271 | key = key_mtx_dereference(local, sdata->keys[key_idx]); |
e8cbb4cb | 272 | |
5c0c3641 | 273 | if (!key) { |
3b96766f JB |
274 | ret = -ENOENT; |
275 | goto out_unlock; | |
276 | } | |
e8cbb4cb | 277 | |
3b8d9c29 | 278 | ieee80211_key_free(key, true); |
e8cbb4cb | 279 | |
3b96766f JB |
280 | ret = 0; |
281 | out_unlock: | |
5c0c3641 JB |
282 | mutex_unlock(&local->key_mtx); |
283 | mutex_unlock(&local->sta_mtx); | |
3b96766f JB |
284 | |
285 | return ret; | |
e8cbb4cb JB |
286 | } |
287 | ||
62da92fb | 288 | static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, |
e31b8213 JB |
289 | u8 key_idx, bool pairwise, const u8 *mac_addr, |
290 | void *cookie, | |
62da92fb JB |
291 | void (*callback)(void *cookie, |
292 | struct key_params *params)) | |
293 | { | |
14db74bc | 294 | struct ieee80211_sub_if_data *sdata; |
62da92fb JB |
295 | struct sta_info *sta = NULL; |
296 | u8 seq[6] = {0}; | |
297 | struct key_params params; | |
e31b8213 | 298 | struct ieee80211_key *key = NULL; |
aba83a0b | 299 | u64 pn64; |
62da92fb JB |
300 | u32 iv32; |
301 | u16 iv16; | |
302 | int err = -ENOENT; | |
303 | ||
14db74bc JB |
304 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
305 | ||
3b96766f JB |
306 | rcu_read_lock(); |
307 | ||
62da92fb | 308 | if (mac_addr) { |
0e5ded5a | 309 | sta = sta_info_get_bss(sdata, mac_addr); |
62da92fb JB |
310 | if (!sta) |
311 | goto out; | |
312 | ||
354e159d | 313 | if (pairwise && key_idx < NUM_DEFAULT_KEYS) |
2475b1cc | 314 | key = rcu_dereference(sta->ptk[key_idx]); |
31f1f4ec MS |
315 | else if (!pairwise && |
316 | key_idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS) | |
a3836e02 | 317 | key = rcu_dereference(sta->gtk[key_idx]); |
62da92fb | 318 | } else |
a3836e02 | 319 | key = rcu_dereference(sdata->keys[key_idx]); |
62da92fb JB |
320 | |
321 | if (!key) | |
322 | goto out; | |
323 | ||
324 | memset(¶ms, 0, sizeof(params)); | |
325 | ||
97359d12 | 326 | params.cipher = key->conf.cipher; |
62da92fb | 327 | |
97359d12 JB |
328 | switch (key->conf.cipher) { |
329 | case WLAN_CIPHER_SUITE_TKIP: | |
b0f76b33 HH |
330 | iv32 = key->u.tkip.tx.iv32; |
331 | iv16 = key->u.tkip.tx.iv16; | |
62da92fb | 332 | |
24487981 JB |
333 | if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) |
334 | drv_get_tkip_seq(sdata->local, | |
335 | key->conf.hw_key_idx, | |
336 | &iv32, &iv16); | |
62da92fb JB |
337 | |
338 | seq[0] = iv16 & 0xff; | |
339 | seq[1] = (iv16 >> 8) & 0xff; | |
340 | seq[2] = iv32 & 0xff; | |
341 | seq[3] = (iv32 >> 8) & 0xff; | |
342 | seq[4] = (iv32 >> 16) & 0xff; | |
343 | seq[5] = (iv32 >> 24) & 0xff; | |
344 | params.seq = seq; | |
345 | params.seq_len = 6; | |
346 | break; | |
97359d12 | 347 | case WLAN_CIPHER_SUITE_CCMP: |
aba83a0b JB |
348 | pn64 = atomic64_read(&key->u.ccmp.tx_pn); |
349 | seq[0] = pn64; | |
350 | seq[1] = pn64 >> 8; | |
351 | seq[2] = pn64 >> 16; | |
352 | seq[3] = pn64 >> 24; | |
353 | seq[4] = pn64 >> 32; | |
354 | seq[5] = pn64 >> 40; | |
62da92fb JB |
355 | params.seq = seq; |
356 | params.seq_len = 6; | |
357 | break; | |
97359d12 | 358 | case WLAN_CIPHER_SUITE_AES_CMAC: |
75396ae6 JB |
359 | pn64 = atomic64_read(&key->u.aes_cmac.tx_pn); |
360 | seq[0] = pn64; | |
361 | seq[1] = pn64 >> 8; | |
362 | seq[2] = pn64 >> 16; | |
363 | seq[3] = pn64 >> 24; | |
364 | seq[4] = pn64 >> 32; | |
365 | seq[5] = pn64 >> 40; | |
3cfcf6ac JM |
366 | params.seq = seq; |
367 | params.seq_len = 6; | |
368 | break; | |
62da92fb JB |
369 | } |
370 | ||
371 | params.key = key->conf.key; | |
372 | params.key_len = key->conf.keylen; | |
373 | ||
374 | callback(cookie, ¶ms); | |
375 | err = 0; | |
376 | ||
377 | out: | |
3b96766f | 378 | rcu_read_unlock(); |
62da92fb JB |
379 | return err; |
380 | } | |
381 | ||
e8cbb4cb JB |
382 | static int ieee80211_config_default_key(struct wiphy *wiphy, |
383 | struct net_device *dev, | |
dbd2fd65 JB |
384 | u8 key_idx, bool uni, |
385 | bool multi) | |
e8cbb4cb | 386 | { |
ad0e2b5a | 387 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
3b96766f | 388 | |
f7e0104c | 389 | ieee80211_set_default_key(sdata, key_idx, uni, multi); |
e8cbb4cb JB |
390 | |
391 | return 0; | |
392 | } | |
393 | ||
3cfcf6ac JM |
394 | static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, |
395 | struct net_device *dev, | |
396 | u8 key_idx) | |
397 | { | |
66c52421 | 398 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
3cfcf6ac | 399 | |
3cfcf6ac JM |
400 | ieee80211_set_default_mgmt_key(sdata, key_idx); |
401 | ||
3cfcf6ac JM |
402 | return 0; |
403 | } | |
404 | ||
6b62bf32 TP |
405 | void sta_set_rate_info_tx(struct sta_info *sta, |
406 | const struct ieee80211_tx_rate *rate, | |
407 | struct rate_info *rinfo) | |
408 | { | |
409 | rinfo->flags = 0; | |
8bc83c24 | 410 | if (rate->flags & IEEE80211_TX_RC_MCS) { |
6b62bf32 | 411 | rinfo->flags |= RATE_INFO_FLAGS_MCS; |
8bc83c24 JB |
412 | rinfo->mcs = rate->idx; |
413 | } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { | |
414 | rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; | |
415 | rinfo->mcs = ieee80211_rate_get_vht_mcs(rate); | |
416 | rinfo->nss = ieee80211_rate_get_vht_nss(rate); | |
417 | } else { | |
418 | struct ieee80211_supported_band *sband; | |
2103dec1 SW |
419 | int shift = ieee80211_vif_get_shift(&sta->sdata->vif); |
420 | u16 brate; | |
421 | ||
8bc83c24 JB |
422 | sband = sta->local->hw.wiphy->bands[ |
423 | ieee80211_get_sdata_band(sta->sdata)]; | |
2103dec1 SW |
424 | brate = sband->bitrates[rate->idx].bitrate; |
425 | rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); | |
8bc83c24 | 426 | } |
6b62bf32 TP |
427 | if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) |
428 | rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; | |
8bc83c24 JB |
429 | if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH) |
430 | rinfo->flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; | |
431 | if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH) | |
432 | rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; | |
6b62bf32 TP |
433 | if (rate->flags & IEEE80211_TX_RC_SHORT_GI) |
434 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; | |
6b62bf32 TP |
435 | } |
436 | ||
003e676a S |
437 | void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo) |
438 | { | |
439 | rinfo->flags = 0; | |
440 | ||
441 | if (sta->last_rx_rate_flag & RX_FLAG_HT) { | |
442 | rinfo->flags |= RATE_INFO_FLAGS_MCS; | |
443 | rinfo->mcs = sta->last_rx_rate_idx; | |
444 | } else if (sta->last_rx_rate_flag & RX_FLAG_VHT) { | |
445 | rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS; | |
446 | rinfo->nss = sta->last_rx_rate_vht_nss; | |
447 | rinfo->mcs = sta->last_rx_rate_idx; | |
448 | } else { | |
449 | struct ieee80211_supported_band *sband; | |
2103dec1 SW |
450 | int shift = ieee80211_vif_get_shift(&sta->sdata->vif); |
451 | u16 brate; | |
003e676a S |
452 | |
453 | sband = sta->local->hw.wiphy->bands[ | |
454 | ieee80211_get_sdata_band(sta->sdata)]; | |
2103dec1 SW |
455 | brate = sband->bitrates[sta->last_rx_rate_idx].bitrate; |
456 | rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); | |
003e676a S |
457 | } |
458 | ||
459 | if (sta->last_rx_rate_flag & RX_FLAG_40MHZ) | |
460 | rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; | |
461 | if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI) | |
462 | rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI; | |
1b8d242a | 463 | if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_80MHZ) |
003e676a | 464 | rinfo->flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
1b8d242a | 465 | if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_80P80MHZ) |
003e676a | 466 | rinfo->flags |= RATE_INFO_FLAGS_80P80_MHZ_WIDTH; |
1b8d242a | 467 | if (sta->last_rx_rate_vht_flag & RX_VHT_FLAG_160MHZ) |
003e676a S |
468 | rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; |
469 | } | |
470 | ||
c5dd9c2b LCC |
471 | static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) |
472 | { | |
d0709a65 | 473 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
66572cfc | 474 | struct ieee80211_local *local = sdata->local; |
ebe27c91 | 475 | struct timespec uptime; |
560d2682 | 476 | u64 packets = 0; |
ef0621e8 | 477 | int i, ac; |
c5dd9c2b | 478 | |
f5ea9120 JB |
479 | sinfo->generation = sdata->local->sta_generation; |
480 | ||
c5dd9c2b | 481 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
560d2682 JB |
482 | STATION_INFO_RX_BYTES64 | |
483 | STATION_INFO_TX_BYTES64 | | |
98c8a60a JM |
484 | STATION_INFO_RX_PACKETS | |
485 | STATION_INFO_TX_PACKETS | | |
b206b4ef BR |
486 | STATION_INFO_TX_RETRIES | |
487 | STATION_INFO_TX_FAILED | | |
5a5c731a | 488 | STATION_INFO_TX_BITRATE | |
3af6334c | 489 | STATION_INFO_RX_BITRATE | |
f4263c98 | 490 | STATION_INFO_RX_DROP_MISC | |
ebe27c91 | 491 | STATION_INFO_BSS_PARAM | |
7a724767 | 492 | STATION_INFO_CONNECTED_TIME | |
a85e1d55 PS |
493 | STATION_INFO_STA_FLAGS | |
494 | STATION_INFO_BEACON_LOSS_COUNT; | |
ebe27c91 MSS |
495 | |
496 | do_posix_clock_monotonic_gettime(&uptime); | |
497 | sinfo->connected_time = uptime.tv_sec - sta->last_connected; | |
c5dd9c2b LCC |
498 | |
499 | sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); | |
560d2682 JB |
500 | sinfo->tx_bytes = 0; |
501 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { | |
502 | sinfo->tx_bytes += sta->tx_bytes[ac]; | |
503 | packets += sta->tx_packets[ac]; | |
504 | } | |
505 | sinfo->tx_packets = packets; | |
c5dd9c2b | 506 | sinfo->rx_bytes = sta->rx_bytes; |
98c8a60a | 507 | sinfo->rx_packets = sta->rx_packets; |
b206b4ef BR |
508 | sinfo->tx_retries = sta->tx_retry_count; |
509 | sinfo->tx_failed = sta->tx_retry_failed; | |
5a5c731a | 510 | sinfo->rx_dropped_misc = sta->rx_dropped; |
a85e1d55 | 511 | sinfo->beacon_loss_count = sta->beacon_loss_count; |
c5dd9c2b | 512 | |
19deffbe JL |
513 | if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) || |
514 | (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) { | |
541a45a1 | 515 | sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG; |
66572cfc VG |
516 | if (!local->ops->get_rssi || |
517 | drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal)) | |
518 | sinfo->signal = (s8)sta->last_signal; | |
541a45a1 | 519 | sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal); |
420e7fab | 520 | } |
ef0621e8 FF |
521 | if (sta->chains) { |
522 | sinfo->filled |= STATION_INFO_CHAIN_SIGNAL | | |
523 | STATION_INFO_CHAIN_SIGNAL_AVG; | |
524 | ||
525 | sinfo->chains = sta->chains; | |
526 | for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { | |
527 | sinfo->chain_signal[i] = sta->chain_signal_last[i]; | |
528 | sinfo->chain_signal_avg[i] = | |
529 | (s8) -ewma_read(&sta->chain_signal_avg[i]); | |
530 | } | |
531 | } | |
420e7fab | 532 | |
6b62bf32 | 533 | sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate); |
003e676a | 534 | sta_set_rate_info_rx(sta, &sinfo->rxrate); |
420e7fab | 535 | |
902acc78 | 536 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
c5dd9c2b | 537 | #ifdef CONFIG_MAC80211_MESH |
c5dd9c2b LCC |
538 | sinfo->filled |= STATION_INFO_LLID | |
539 | STATION_INFO_PLID | | |
3f52b7e3 MP |
540 | STATION_INFO_PLINK_STATE | |
541 | STATION_INFO_LOCAL_PM | | |
542 | STATION_INFO_PEER_PM | | |
543 | STATION_INFO_NONPEER_PM; | |
c5dd9c2b | 544 | |
6f101ef0 CYY |
545 | sinfo->llid = sta->llid; |
546 | sinfo->plid = sta->plid; | |
c5dd9c2b | 547 | sinfo->plink_state = sta->plink_state; |
d299a1f2 JC |
548 | if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { |
549 | sinfo->filled |= STATION_INFO_T_OFFSET; | |
550 | sinfo->t_offset = sta->t_offset; | |
551 | } | |
3f52b7e3 MP |
552 | sinfo->local_pm = sta->local_pm; |
553 | sinfo->peer_pm = sta->peer_pm; | |
554 | sinfo->nonpeer_pm = sta->nonpeer_pm; | |
c5dd9c2b | 555 | #endif |
902acc78 | 556 | } |
f4263c98 PS |
557 | |
558 | sinfo->bss_param.flags = 0; | |
559 | if (sdata->vif.bss_conf.use_cts_prot) | |
560 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT; | |
561 | if (sdata->vif.bss_conf.use_short_preamble) | |
562 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE; | |
563 | if (sdata->vif.bss_conf.use_short_slot) | |
564 | sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME; | |
565 | sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period; | |
566 | sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int; | |
7a724767 HS |
567 | |
568 | sinfo->sta_flags.set = 0; | |
569 | sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) | | |
570 | BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | | |
571 | BIT(NL80211_STA_FLAG_WME) | | |
572 | BIT(NL80211_STA_FLAG_MFP) | | |
e4121562 | 573 | BIT(NL80211_STA_FLAG_AUTHENTICATED) | |
d582cffb | 574 | BIT(NL80211_STA_FLAG_ASSOCIATED) | |
e4121562 | 575 | BIT(NL80211_STA_FLAG_TDLS_PEER); |
7a724767 HS |
576 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) |
577 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); | |
578 | if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) | |
579 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); | |
580 | if (test_sta_flag(sta, WLAN_STA_WME)) | |
581 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME); | |
582 | if (test_sta_flag(sta, WLAN_STA_MFP)) | |
583 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); | |
584 | if (test_sta_flag(sta, WLAN_STA_AUTH)) | |
585 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); | |
d582cffb JB |
586 | if (test_sta_flag(sta, WLAN_STA_ASSOC)) |
587 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED); | |
e4121562 HS |
588 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) |
589 | sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); | |
c5dd9c2b LCC |
590 | } |
591 | ||
b1ab7925 BG |
592 | static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = { |
593 | "rx_packets", "rx_bytes", "wep_weak_iv_count", | |
594 | "rx_duplicates", "rx_fragments", "rx_dropped", | |
595 | "tx_packets", "tx_bytes", "tx_fragments", | |
596 | "tx_filtered", "tx_retry_failed", "tx_retries", | |
3073a7c2 BG |
597 | "beacon_loss", "sta_state", "txrate", "rxrate", "signal", |
598 | "channel", "noise", "ch_time", "ch_time_busy", | |
599 | "ch_time_ext_busy", "ch_time_rx", "ch_time_tx" | |
b1ab7925 BG |
600 | }; |
601 | #define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats) | |
602 | ||
603 | static int ieee80211_get_et_sset_count(struct wiphy *wiphy, | |
604 | struct net_device *dev, | |
605 | int sset) | |
606 | { | |
e352114f BG |
607 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
608 | int rv = 0; | |
609 | ||
b1ab7925 | 610 | if (sset == ETH_SS_STATS) |
e352114f BG |
611 | rv += STA_STATS_LEN; |
612 | ||
613 | rv += drv_get_et_sset_count(sdata, sset); | |
b1ab7925 | 614 | |
e352114f BG |
615 | if (rv == 0) |
616 | return -EOPNOTSUPP; | |
617 | return rv; | |
b1ab7925 BG |
618 | } |
619 | ||
620 | static void ieee80211_get_et_stats(struct wiphy *wiphy, | |
621 | struct net_device *dev, | |
622 | struct ethtool_stats *stats, | |
623 | u64 *data) | |
624 | { | |
625 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
55de908a JB |
626 | struct ieee80211_chanctx_conf *chanctx_conf; |
627 | struct ieee80211_channel *channel; | |
b1ab7925 BG |
628 | struct sta_info *sta; |
629 | struct ieee80211_local *local = sdata->local; | |
3073a7c2 BG |
630 | struct station_info sinfo; |
631 | struct survey_info survey; | |
632 | int i, q; | |
633 | #define STA_STATS_SURVEY_LEN 7 | |
b1ab7925 BG |
634 | |
635 | memset(data, 0, sizeof(u64) * STA_STATS_LEN); | |
636 | ||
637 | #define ADD_STA_STATS(sta) \ | |
638 | do { \ | |
639 | data[i++] += sta->rx_packets; \ | |
640 | data[i++] += sta->rx_bytes; \ | |
641 | data[i++] += sta->wep_weak_iv_count; \ | |
642 | data[i++] += sta->num_duplicates; \ | |
643 | data[i++] += sta->rx_fragments; \ | |
644 | data[i++] += sta->rx_dropped; \ | |
645 | \ | |
560d2682 JB |
646 | data[i++] += sinfo.tx_packets; \ |
647 | data[i++] += sinfo.tx_bytes; \ | |
b1ab7925 BG |
648 | data[i++] += sta->tx_fragments; \ |
649 | data[i++] += sta->tx_filtered_count; \ | |
650 | data[i++] += sta->tx_retry_failed; \ | |
651 | data[i++] += sta->tx_retry_count; \ | |
652 | data[i++] += sta->beacon_loss_count; \ | |
653 | } while (0) | |
654 | ||
655 | /* For Managed stations, find the single station based on BSSID | |
656 | * and use that. For interface types, iterate through all available | |
657 | * stations and add stats for any station that is assigned to this | |
658 | * network device. | |
659 | */ | |
660 | ||
66572cfc | 661 | mutex_lock(&local->sta_mtx); |
b1ab7925 BG |
662 | |
663 | if (sdata->vif.type == NL80211_IFTYPE_STATION) { | |
664 | sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid); | |
3073a7c2 BG |
665 | |
666 | if (!(sta && !WARN_ON(sta->sdata->dev != dev))) | |
667 | goto do_survey; | |
668 | ||
560d2682 JB |
669 | sinfo.filled = 0; |
670 | sta_set_sinfo(sta, &sinfo); | |
671 | ||
3073a7c2 BG |
672 | i = 0; |
673 | ADD_STA_STATS(sta); | |
674 | ||
675 | data[i++] = sta->sta_state; | |
676 | ||
3073a7c2 | 677 | |
5204267d | 678 | if (sinfo.filled & STATION_INFO_TX_BITRATE) |
3073a7c2 BG |
679 | data[i] = 100000 * |
680 | cfg80211_calculate_bitrate(&sinfo.txrate); | |
681 | i++; | |
5204267d | 682 | if (sinfo.filled & STATION_INFO_RX_BITRATE) |
3073a7c2 BG |
683 | data[i] = 100000 * |
684 | cfg80211_calculate_bitrate(&sinfo.rxrate); | |
685 | i++; | |
686 | ||
5204267d | 687 | if (sinfo.filled & STATION_INFO_SIGNAL_AVG) |
3073a7c2 BG |
688 | data[i] = (u8)sinfo.signal_avg; |
689 | i++; | |
b1ab7925 | 690 | } else { |
66572cfc | 691 | list_for_each_entry(sta, &local->sta_list, list) { |
b1ab7925 BG |
692 | /* Make sure this station belongs to the proper dev */ |
693 | if (sta->sdata->dev != dev) | |
694 | continue; | |
695 | ||
e13bae4f JB |
696 | sinfo.filled = 0; |
697 | sta_set_sinfo(sta, &sinfo); | |
b1ab7925 BG |
698 | i = 0; |
699 | ADD_STA_STATS(sta); | |
b1ab7925 BG |
700 | } |
701 | } | |
702 | ||
3073a7c2 BG |
703 | do_survey: |
704 | i = STA_STATS_LEN - STA_STATS_SURVEY_LEN; | |
705 | /* Get survey stats for current channel */ | |
55de908a | 706 | survey.filled = 0; |
3073a7c2 | 707 | |
55de908a JB |
708 | rcu_read_lock(); |
709 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | |
710 | if (chanctx_conf) | |
4bf88530 | 711 | channel = chanctx_conf->def.chan; |
55de908a JB |
712 | else |
713 | channel = NULL; | |
714 | rcu_read_unlock(); | |
715 | ||
716 | if (channel) { | |
717 | q = 0; | |
718 | do { | |
719 | survey.filled = 0; | |
720 | if (drv_get_survey(local, q, &survey) != 0) { | |
721 | survey.filled = 0; | |
722 | break; | |
723 | } | |
724 | q++; | |
725 | } while (channel != survey.channel); | |
3073a7c2 BG |
726 | } |
727 | ||
728 | if (survey.filled) | |
729 | data[i++] = survey.channel->center_freq; | |
730 | else | |
731 | data[i++] = 0; | |
732 | if (survey.filled & SURVEY_INFO_NOISE_DBM) | |
733 | data[i++] = (u8)survey.noise; | |
734 | else | |
735 | data[i++] = -1LL; | |
736 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME) | |
737 | data[i++] = survey.channel_time; | |
738 | else | |
739 | data[i++] = -1LL; | |
740 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY) | |
741 | data[i++] = survey.channel_time_busy; | |
742 | else | |
743 | data[i++] = -1LL; | |
744 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY) | |
745 | data[i++] = survey.channel_time_ext_busy; | |
746 | else | |
747 | data[i++] = -1LL; | |
748 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX) | |
749 | data[i++] = survey.channel_time_rx; | |
750 | else | |
751 | data[i++] = -1LL; | |
752 | if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX) | |
753 | data[i++] = survey.channel_time_tx; | |
754 | else | |
755 | data[i++] = -1LL; | |
756 | ||
66572cfc | 757 | mutex_unlock(&local->sta_mtx); |
e352114f | 758 | |
3073a7c2 BG |
759 | if (WARN_ON(i != STA_STATS_LEN)) |
760 | return; | |
761 | ||
e352114f | 762 | drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN])); |
b1ab7925 BG |
763 | } |
764 | ||
765 | static void ieee80211_get_et_strings(struct wiphy *wiphy, | |
766 | struct net_device *dev, | |
767 | u32 sset, u8 *data) | |
768 | { | |
e352114f BG |
769 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
770 | int sz_sta_stats = 0; | |
771 | ||
b1ab7925 | 772 | if (sset == ETH_SS_STATS) { |
e352114f | 773 | sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats); |
bd500af2 | 774 | memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats); |
b1ab7925 | 775 | } |
e352114f | 776 | drv_get_et_strings(sdata, sset, &(data[sz_sta_stats])); |
b1ab7925 | 777 | } |
c5dd9c2b LCC |
778 | |
779 | static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev, | |
780 | int idx, u8 *mac, struct station_info *sinfo) | |
781 | { | |
3b53fde8 | 782 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
66572cfc | 783 | struct ieee80211_local *local = sdata->local; |
c5dd9c2b | 784 | struct sta_info *sta; |
d0709a65 JB |
785 | int ret = -ENOENT; |
786 | ||
66572cfc | 787 | mutex_lock(&local->sta_mtx); |
c5dd9c2b | 788 | |
3b53fde8 | 789 | sta = sta_info_get_by_idx(sdata, idx); |
d0709a65 JB |
790 | if (sta) { |
791 | ret = 0; | |
17741cdc | 792 | memcpy(mac, sta->sta.addr, ETH_ALEN); |
d0709a65 JB |
793 | sta_set_sinfo(sta, sinfo); |
794 | } | |
c5dd9c2b | 795 | |
66572cfc | 796 | mutex_unlock(&local->sta_mtx); |
c5dd9c2b | 797 | |
d0709a65 | 798 | return ret; |
c5dd9c2b LCC |
799 | } |
800 | ||
1289723e HS |
801 | static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev, |
802 | int idx, struct survey_info *survey) | |
803 | { | |
804 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
805 | ||
1289723e HS |
806 | return drv_get_survey(local, idx, survey); |
807 | } | |
808 | ||
7bbdd2d9 | 809 | static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
2ec600d6 | 810 | u8 *mac, struct station_info *sinfo) |
7bbdd2d9 | 811 | { |
abe60632 | 812 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
66572cfc | 813 | struct ieee80211_local *local = sdata->local; |
7bbdd2d9 | 814 | struct sta_info *sta; |
d0709a65 | 815 | int ret = -ENOENT; |
7bbdd2d9 | 816 | |
66572cfc | 817 | mutex_lock(&local->sta_mtx); |
7bbdd2d9 | 818 | |
0e5ded5a | 819 | sta = sta_info_get_bss(sdata, mac); |
d0709a65 JB |
820 | if (sta) { |
821 | ret = 0; | |
822 | sta_set_sinfo(sta, sinfo); | |
823 | } | |
824 | ||
66572cfc | 825 | mutex_unlock(&local->sta_mtx); |
d0709a65 JB |
826 | |
827 | return ret; | |
7bbdd2d9 JB |
828 | } |
829 | ||
55de908a | 830 | static int ieee80211_set_monitor_channel(struct wiphy *wiphy, |
683b6d3b | 831 | struct cfg80211_chan_def *chandef) |
3d9e6e12 JB |
832 | { |
833 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
55de908a JB |
834 | struct ieee80211_sub_if_data *sdata; |
835 | int ret = 0; | |
3d9e6e12 | 836 | |
4bf88530 | 837 | if (cfg80211_chandef_identical(&local->monitor_chandef, chandef)) |
55de908a | 838 | return 0; |
3d9e6e12 | 839 | |
34a3740d | 840 | mutex_lock(&local->mtx); |
55de908a JB |
841 | mutex_lock(&local->iflist_mtx); |
842 | if (local->use_chanctx) { | |
843 | sdata = rcu_dereference_protected( | |
844 | local->monitor_sdata, | |
845 | lockdep_is_held(&local->iflist_mtx)); | |
846 | if (sdata) { | |
847 | ieee80211_vif_release_channel(sdata); | |
4bf88530 | 848 | ret = ieee80211_vif_use_channel(sdata, chandef, |
55de908a JB |
849 | IEEE80211_CHANCTX_EXCLUSIVE); |
850 | } | |
851 | } else if (local->open_count == local->monitors) { | |
675a0b04 | 852 | local->_oper_chandef = *chandef; |
55de908a JB |
853 | ieee80211_hw_config(local, 0); |
854 | } | |
3d9e6e12 | 855 | |
4bf88530 JB |
856 | if (ret == 0) |
857 | local->monitor_chandef = *chandef; | |
55de908a | 858 | mutex_unlock(&local->iflist_mtx); |
34a3740d | 859 | mutex_unlock(&local->mtx); |
3d9e6e12 | 860 | |
55de908a | 861 | return ret; |
e8c9bd5b JB |
862 | } |
863 | ||
02945821 | 864 | static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, |
8860020e | 865 | const u8 *resp, size_t resp_len) |
02945821 | 866 | { |
aa7a0080 | 867 | struct probe_resp *new, *old; |
02945821 AN |
868 | |
869 | if (!resp || !resp_len) | |
aba4e6ff | 870 | return 1; |
02945821 | 871 | |
7ca133bc | 872 | old = sdata_dereference(sdata->u.ap.probe_resp, sdata); |
02945821 | 873 | |
aa7a0080 | 874 | new = kzalloc(sizeof(struct probe_resp) + resp_len, GFP_KERNEL); |
02945821 AN |
875 | if (!new) |
876 | return -ENOMEM; | |
877 | ||
aa7a0080 ES |
878 | new->len = resp_len; |
879 | memcpy(new->data, resp, resp_len); | |
02945821 AN |
880 | |
881 | rcu_assign_pointer(sdata->u.ap.probe_resp, new); | |
aa7a0080 ES |
882 | if (old) |
883 | kfree_rcu(old, rcu_head); | |
02945821 AN |
884 | |
885 | return 0; | |
886 | } | |
887 | ||
0ae07968 LC |
888 | static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, |
889 | struct cfg80211_beacon_data *params) | |
5dfdaf58 JB |
890 | { |
891 | struct beacon_data *new, *old; | |
892 | int new_head_len, new_tail_len; | |
8860020e JB |
893 | int size, err; |
894 | u32 changed = BSS_CHANGED_BEACON; | |
5dfdaf58 | 895 | |
7ca133bc SW |
896 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
897 | ||
5dfdaf58 | 898 | |
5dfdaf58 JB |
899 | /* Need to have a beacon head if we don't have one yet */ |
900 | if (!params->head && !old) | |
8860020e | 901 | return -EINVAL; |
5dfdaf58 JB |
902 | |
903 | /* new or old head? */ | |
904 | if (params->head) | |
905 | new_head_len = params->head_len; | |
906 | else | |
907 | new_head_len = old->head_len; | |
908 | ||
909 | /* new or old tail? */ | |
910 | if (params->tail || !old) | |
911 | /* params->tail_len will be zero for !params->tail */ | |
912 | new_tail_len = params->tail_len; | |
913 | else | |
914 | new_tail_len = old->tail_len; | |
915 | ||
916 | size = sizeof(*new) + new_head_len + new_tail_len; | |
917 | ||
918 | new = kzalloc(size, GFP_KERNEL); | |
919 | if (!new) | |
920 | return -ENOMEM; | |
921 | ||
922 | /* start filling the new info now */ | |
923 | ||
5dfdaf58 JB |
924 | /* |
925 | * pointers go into the block we allocated, | |
926 | * memory is | beacon_data | head | tail | | |
927 | */ | |
928 | new->head = ((u8 *) new) + sizeof(*new); | |
929 | new->tail = new->head + new_head_len; | |
930 | new->head_len = new_head_len; | |
931 | new->tail_len = new_tail_len; | |
932 | ||
933 | /* copy in head */ | |
934 | if (params->head) | |
935 | memcpy(new->head, params->head, new_head_len); | |
936 | else | |
937 | memcpy(new->head, old->head, new_head_len); | |
938 | ||
939 | /* copy in optional tail */ | |
940 | if (params->tail) | |
941 | memcpy(new->tail, params->tail, new_tail_len); | |
942 | else | |
943 | if (old) | |
944 | memcpy(new->tail, old->tail, new_tail_len); | |
945 | ||
02945821 AN |
946 | err = ieee80211_set_probe_resp(sdata, params->probe_resp, |
947 | params->probe_resp_len); | |
8860020e JB |
948 | if (err < 0) |
949 | return err; | |
950 | if (err == 0) | |
02945821 AN |
951 | changed |= BSS_CHANGED_AP_PROBE_RESP; |
952 | ||
8860020e JB |
953 | rcu_assign_pointer(sdata->u.ap.beacon, new); |
954 | ||
955 | if (old) | |
956 | kfree_rcu(old, rcu_head); | |
7827493b | 957 | |
8860020e | 958 | return changed; |
5dfdaf58 JB |
959 | } |
960 | ||
8860020e JB |
961 | static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, |
962 | struct cfg80211_ap_settings *params) | |
5dfdaf58 | 963 | { |
8860020e | 964 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
34a3740d | 965 | struct ieee80211_local *local = sdata->local; |
5dfdaf58 | 966 | struct beacon_data *old; |
665c93a9 | 967 | struct ieee80211_sub_if_data *vlan; |
8860020e JB |
968 | u32 changed = BSS_CHANGED_BEACON_INT | |
969 | BSS_CHANGED_BEACON_ENABLED | | |
970 | BSS_CHANGED_BEACON | | |
339afbf4 JB |
971 | BSS_CHANGED_SSID | |
972 | BSS_CHANGED_P2P_PS; | |
8860020e | 973 | int err; |
14db74bc | 974 | |
7ca133bc | 975 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
5dfdaf58 JB |
976 | if (old) |
977 | return -EALREADY; | |
978 | ||
04ecd257 JB |
979 | /* TODO: make hostapd tell us what it wants */ |
980 | sdata->smps_mode = IEEE80211_SMPS_OFF; | |
981 | sdata->needed_rx_chains = sdata->local->rx_chains; | |
982 | ||
34a3740d | 983 | mutex_lock(&local->mtx); |
4bf88530 | 984 | err = ieee80211_vif_use_channel(sdata, ¶ms->chandef, |
55de908a | 985 | IEEE80211_CHANCTX_SHARED); |
4e141dad MK |
986 | if (!err) |
987 | ieee80211_vif_copy_chanctx_to_vlans(sdata, false); | |
34a3740d | 988 | mutex_unlock(&local->mtx); |
aa430da4 JB |
989 | if (err) |
990 | return err; | |
991 | ||
665c93a9 JB |
992 | /* |
993 | * Apply control port protocol, this allows us to | |
994 | * not encrypt dynamic WEP control frames. | |
995 | */ | |
996 | sdata->control_port_protocol = params->crypto.control_port_ethertype; | |
997 | sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt; | |
2475b1cc MS |
998 | sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local, |
999 | ¶ms->crypto, | |
1000 | sdata->vif.type); | |
1001 | ||
665c93a9 JB |
1002 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { |
1003 | vlan->control_port_protocol = | |
1004 | params->crypto.control_port_ethertype; | |
1005 | vlan->control_port_no_encrypt = | |
1006 | params->crypto.control_port_no_encrypt; | |
2475b1cc MS |
1007 | vlan->encrypt_headroom = |
1008 | ieee80211_cs_headroom(sdata->local, | |
1009 | ¶ms->crypto, | |
1010 | vlan->vif.type); | |
665c93a9 JB |
1011 | } |
1012 | ||
8860020e JB |
1013 | sdata->vif.bss_conf.beacon_int = params->beacon_interval; |
1014 | sdata->vif.bss_conf.dtim_period = params->dtim_period; | |
d6a83228 | 1015 | sdata->vif.bss_conf.enable_beacon = true; |
8860020e JB |
1016 | |
1017 | sdata->vif.bss_conf.ssid_len = params->ssid_len; | |
1018 | if (params->ssid_len) | |
1019 | memcpy(sdata->vif.bss_conf.ssid, params->ssid, | |
1020 | params->ssid_len); | |
1021 | sdata->vif.bss_conf.hidden_ssid = | |
1022 | (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); | |
1023 | ||
67baf663 JD |
1024 | memset(&sdata->vif.bss_conf.p2p_noa_attr, 0, |
1025 | sizeof(sdata->vif.bss_conf.p2p_noa_attr)); | |
1026 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow = | |
1027 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; | |
1028 | if (params->p2p_opp_ps) | |
1029 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= | |
1030 | IEEE80211_P2P_OPPPS_ENABLE_BIT; | |
339afbf4 | 1031 | |
8860020e | 1032 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon); |
0297ea17 EG |
1033 | if (err < 0) { |
1034 | ieee80211_vif_release_channel(sdata); | |
8860020e | 1035 | return err; |
0297ea17 | 1036 | } |
8860020e JB |
1037 | changed |= err; |
1038 | ||
1041638f JB |
1039 | err = drv_start_ap(sdata->local, sdata); |
1040 | if (err) { | |
7ca133bc SW |
1041 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
1042 | ||
1041638f JB |
1043 | if (old) |
1044 | kfree_rcu(old, rcu_head); | |
1045 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); | |
0297ea17 | 1046 | ieee80211_vif_release_channel(sdata); |
1041638f JB |
1047 | return err; |
1048 | } | |
1049 | ||
057d5f4b | 1050 | ieee80211_recalc_dtim(local, sdata); |
8860020e JB |
1051 | ieee80211_bss_info_change_notify(sdata, changed); |
1052 | ||
3edaf3e6 JB |
1053 | netif_carrier_on(dev); |
1054 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) | |
1055 | netif_carrier_on(vlan->dev); | |
1056 | ||
665c93a9 | 1057 | return 0; |
5dfdaf58 JB |
1058 | } |
1059 | ||
8860020e JB |
1060 | static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, |
1061 | struct cfg80211_beacon_data *params) | |
5dfdaf58 | 1062 | { |
14db74bc | 1063 | struct ieee80211_sub_if_data *sdata; |
5dfdaf58 | 1064 | struct beacon_data *old; |
8860020e | 1065 | int err; |
5dfdaf58 | 1066 | |
14db74bc | 1067 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
dbd72850 | 1068 | sdata_assert_lock(sdata); |
14db74bc | 1069 | |
73da7d5b SW |
1070 | /* don't allow changing the beacon while CSA is in place - offset |
1071 | * of channel switch counter may change | |
1072 | */ | |
1073 | if (sdata->vif.csa_active) | |
1074 | return -EBUSY; | |
1075 | ||
7ca133bc | 1076 | old = sdata_dereference(sdata->u.ap.beacon, sdata); |
5dfdaf58 JB |
1077 | if (!old) |
1078 | return -ENOENT; | |
1079 | ||
8860020e JB |
1080 | err = ieee80211_assign_beacon(sdata, params); |
1081 | if (err < 0) | |
1082 | return err; | |
1083 | ieee80211_bss_info_change_notify(sdata, err); | |
1084 | return 0; | |
5dfdaf58 JB |
1085 | } |
1086 | ||
8860020e | 1087 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) |
5dfdaf58 | 1088 | { |
7b20b8e8 JB |
1089 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1090 | struct ieee80211_sub_if_data *vlan; | |
1091 | struct ieee80211_local *local = sdata->local; | |
1092 | struct beacon_data *old_beacon; | |
1093 | struct probe_resp *old_probe_resp; | |
d2859df5 | 1094 | struct cfg80211_chan_def chandef; |
14db74bc | 1095 | |
dbd72850 MK |
1096 | sdata_assert_lock(sdata); |
1097 | ||
7ca133bc | 1098 | old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata); |
7b20b8e8 | 1099 | if (!old_beacon) |
5dfdaf58 | 1100 | return -ENOENT; |
7ca133bc | 1101 | old_probe_resp = sdata_dereference(sdata->u.ap.probe_resp, sdata); |
5dfdaf58 | 1102 | |
73da7d5b SW |
1103 | /* abort any running channel switch */ |
1104 | sdata->vif.csa_active = false; | |
1f3b8a2b SW |
1105 | kfree(sdata->u.ap.next_beacon); |
1106 | sdata->u.ap.next_beacon = NULL; | |
1107 | ||
7b20b8e8 | 1108 | /* turn off carrier for this interface and dependent VLANs */ |
3edaf3e6 JB |
1109 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
1110 | netif_carrier_off(vlan->dev); | |
1111 | netif_carrier_off(dev); | |
1112 | ||
7b20b8e8 | 1113 | /* remove beacon and probe response */ |
a9b3cd7f | 1114 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); |
7b20b8e8 JB |
1115 | RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL); |
1116 | kfree_rcu(old_beacon, rcu_head); | |
1117 | if (old_probe_resp) | |
1118 | kfree_rcu(old_probe_resp, rcu_head); | |
8ffcc704 | 1119 | sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF; |
8860020e | 1120 | |
e716251d | 1121 | __sta_info_flush(sdata, true); |
7907c7d3 | 1122 | ieee80211_free_keys(sdata, true); |
75de9113 | 1123 | |
d6a83228 | 1124 | sdata->vif.bss_conf.enable_beacon = false; |
0eabccd9 | 1125 | sdata->vif.bss_conf.ssid_len = 0; |
d6a83228 | 1126 | clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED, &sdata->state); |
2d0ddec5 | 1127 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
8860020e | 1128 | |
a6b368f6 | 1129 | if (sdata->wdev.cac_started) { |
d2859df5 | 1130 | chandef = sdata->vif.bss_conf.chandef; |
a6b368f6 | 1131 | cancel_delayed_work_sync(&sdata->dfs_cac_timer_work); |
d2859df5 JD |
1132 | cfg80211_cac_event(sdata->dev, &chandef, |
1133 | NL80211_RADAR_CAC_ABORTED, | |
a6b368f6 SW |
1134 | GFP_KERNEL); |
1135 | } | |
1136 | ||
1041638f JB |
1137 | drv_stop_ap(sdata->local, sdata); |
1138 | ||
7b20b8e8 JB |
1139 | /* free all potentially still buffered bcast frames */ |
1140 | local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf); | |
1141 | skb_queue_purge(&sdata->u.ap.ps.bc_buf); | |
1142 | ||
34a3740d | 1143 | mutex_lock(&local->mtx); |
4e141dad | 1144 | ieee80211_vif_copy_chanctx_to_vlans(sdata, true); |
55de908a | 1145 | ieee80211_vif_release_channel(sdata); |
34a3740d | 1146 | mutex_unlock(&local->mtx); |
55de908a | 1147 | |
2d0ddec5 | 1148 | return 0; |
5dfdaf58 JB |
1149 | } |
1150 | ||
4fd6931e JB |
1151 | /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */ |
1152 | struct iapp_layer2_update { | |
1153 | u8 da[ETH_ALEN]; /* broadcast */ | |
1154 | u8 sa[ETH_ALEN]; /* STA addr */ | |
1155 | __be16 len; /* 6 */ | |
1156 | u8 dsap; /* 0 */ | |
1157 | u8 ssap; /* 0 */ | |
1158 | u8 control; | |
1159 | u8 xid_info[3]; | |
bc10502d | 1160 | } __packed; |
4fd6931e JB |
1161 | |
1162 | static void ieee80211_send_layer2_update(struct sta_info *sta) | |
1163 | { | |
1164 | struct iapp_layer2_update *msg; | |
1165 | struct sk_buff *skb; | |
1166 | ||
1167 | /* Send Level 2 Update Frame to update forwarding tables in layer 2 | |
1168 | * bridge devices */ | |
1169 | ||
1170 | skb = dev_alloc_skb(sizeof(*msg)); | |
1171 | if (!skb) | |
1172 | return; | |
1173 | msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg)); | |
1174 | ||
1175 | /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID) | |
1176 | * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */ | |
1177 | ||
e83e6541 | 1178 | eth_broadcast_addr(msg->da); |
17741cdc | 1179 | memcpy(msg->sa, sta->sta.addr, ETH_ALEN); |
4fd6931e JB |
1180 | msg->len = htons(6); |
1181 | msg->dsap = 0; | |
1182 | msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */ | |
1183 | msg->control = 0xaf; /* XID response lsb.1111F101. | |
1184 | * F=0 (no poll command; unsolicited frame) */ | |
1185 | msg->xid_info[0] = 0x81; /* XID format identifier */ | |
1186 | msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */ | |
1187 | msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */ | |
1188 | ||
d0709a65 JB |
1189 | skb->dev = sta->sdata->dev; |
1190 | skb->protocol = eth_type_trans(skb, sta->sdata->dev); | |
4fd6931e | 1191 | memset(skb->cb, 0, sizeof(skb->cb)); |
06ee1c26 | 1192 | netif_rx_ni(skb); |
4fd6931e JB |
1193 | } |
1194 | ||
d582cffb JB |
1195 | static int sta_apply_auth_flags(struct ieee80211_local *local, |
1196 | struct sta_info *sta, | |
1197 | u32 mask, u32 set) | |
1198 | { | |
1199 | int ret; | |
1200 | ||
1201 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && | |
1202 | set & BIT(NL80211_STA_FLAG_AUTHENTICATED) && | |
1203 | !test_sta_flag(sta, WLAN_STA_AUTH)) { | |
1204 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); | |
1205 | if (ret) | |
1206 | return ret; | |
1207 | } | |
1208 | ||
1209 | if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && | |
1210 | set & BIT(NL80211_STA_FLAG_ASSOCIATED) && | |
1211 | !test_sta_flag(sta, WLAN_STA_ASSOC)) { | |
1212 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); | |
1213 | if (ret) | |
1214 | return ret; | |
1215 | } | |
1216 | ||
1217 | if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { | |
1218 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) | |
1219 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED); | |
1220 | else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
1221 | ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC); | |
1222 | else | |
1223 | ret = 0; | |
1224 | if (ret) | |
1225 | return ret; | |
1226 | } | |
1227 | ||
1228 | if (mask & BIT(NL80211_STA_FLAG_ASSOCIATED) && | |
1229 | !(set & BIT(NL80211_STA_FLAG_ASSOCIATED)) && | |
1230 | test_sta_flag(sta, WLAN_STA_ASSOC)) { | |
1231 | ret = sta_info_move_state(sta, IEEE80211_STA_AUTH); | |
1232 | if (ret) | |
1233 | return ret; | |
1234 | } | |
1235 | ||
1236 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED) && | |
1237 | !(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) && | |
1238 | test_sta_flag(sta, WLAN_STA_AUTH)) { | |
1239 | ret = sta_info_move_state(sta, IEEE80211_STA_NONE); | |
1240 | if (ret) | |
1241 | return ret; | |
1242 | } | |
1243 | ||
1244 | return 0; | |
1245 | } | |
1246 | ||
d9a7ddb0 JB |
1247 | static int sta_apply_parameters(struct ieee80211_local *local, |
1248 | struct sta_info *sta, | |
1249 | struct station_parameters *params) | |
4fd6931e | 1250 | { |
d9a7ddb0 | 1251 | int ret = 0; |
8318d78a | 1252 | struct ieee80211_supported_band *sband; |
d0709a65 | 1253 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
55de908a | 1254 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
eccb8e8f | 1255 | u32 mask, set; |
4fd6931e | 1256 | |
55de908a | 1257 | sband = local->hw.wiphy->bands[band]; |
ae5eb026 | 1258 | |
eccb8e8f JB |
1259 | mask = params->sta_flags_mask; |
1260 | set = params->sta_flags_set; | |
73651ee6 | 1261 | |
d582cffb JB |
1262 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
1263 | /* | |
1264 | * In mesh mode, ASSOCIATED isn't part of the nl80211 | |
1265 | * API but must follow AUTHENTICATED for driver state. | |
1266 | */ | |
1267 | if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) | |
1268 | mask |= BIT(NL80211_STA_FLAG_ASSOCIATED); | |
1269 | if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) | |
1270 | set |= BIT(NL80211_STA_FLAG_ASSOCIATED); | |
77ee7c89 JB |
1271 | } else if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { |
1272 | /* | |
1273 | * TDLS -- everything follows authorized, but | |
1274 | * only becoming authorized is possible, not | |
1275 | * going back | |
1276 | */ | |
1277 | if (set & BIT(NL80211_STA_FLAG_AUTHORIZED)) { | |
1278 | set |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | | |
1279 | BIT(NL80211_STA_FLAG_ASSOCIATED); | |
1280 | mask |= BIT(NL80211_STA_FLAG_AUTHENTICATED) | | |
1281 | BIT(NL80211_STA_FLAG_ASSOCIATED); | |
1282 | } | |
eccb8e8f | 1283 | } |
4fd6931e | 1284 | |
d582cffb JB |
1285 | ret = sta_apply_auth_flags(local, sta, mask, set); |
1286 | if (ret) | |
1287 | return ret; | |
d9a7ddb0 | 1288 | |
eccb8e8f | 1289 | if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) { |
eccb8e8f | 1290 | if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) |
c2c98fde JB |
1291 | set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); |
1292 | else | |
1293 | clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE); | |
eccb8e8f | 1294 | } |
4fd6931e | 1295 | |
eccb8e8f | 1296 | if (mask & BIT(NL80211_STA_FLAG_WME)) { |
39df600a | 1297 | if (set & BIT(NL80211_STA_FLAG_WME)) { |
c2c98fde | 1298 | set_sta_flag(sta, WLAN_STA_WME); |
39df600a | 1299 | sta->sta.wme = true; |
c2c98fde JB |
1300 | } else { |
1301 | clear_sta_flag(sta, WLAN_STA_WME); | |
1302 | sta->sta.wme = false; | |
39df600a | 1303 | } |
eccb8e8f | 1304 | } |
5394af4d | 1305 | |
eccb8e8f | 1306 | if (mask & BIT(NL80211_STA_FLAG_MFP)) { |
eccb8e8f | 1307 | if (set & BIT(NL80211_STA_FLAG_MFP)) |
c2c98fde JB |
1308 | set_sta_flag(sta, WLAN_STA_MFP); |
1309 | else | |
1310 | clear_sta_flag(sta, WLAN_STA_MFP); | |
4fd6931e | 1311 | } |
b39c48fa | 1312 | |
07ba55d7 | 1313 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
07ba55d7 | 1314 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) |
c2c98fde JB |
1315 | set_sta_flag(sta, WLAN_STA_TDLS_PEER); |
1316 | else | |
1317 | clear_sta_flag(sta, WLAN_STA_TDLS_PEER); | |
07ba55d7 | 1318 | } |
4fd6931e | 1319 | |
3b9ce80c JB |
1320 | if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) { |
1321 | sta->sta.uapsd_queues = params->uapsd_queues; | |
1322 | sta->sta.max_sp = params->max_sp; | |
1323 | } | |
9533b4ac | 1324 | |
51b50fbe JB |
1325 | /* |
1326 | * cfg80211 validates this (1-2007) and allows setting the AID | |
1327 | * only when creating a new station entry | |
1328 | */ | |
1329 | if (params->aid) | |
1330 | sta->sta.aid = params->aid; | |
1331 | ||
73651ee6 | 1332 | /* |
ba23d206 JB |
1333 | * Some of the following updates would be racy if called on an |
1334 | * existing station, via ieee80211_change_station(). However, | |
1335 | * all such changes are rejected by cfg80211 except for updates | |
1336 | * changing the supported rates on an existing but not yet used | |
1337 | * TDLS peer. | |
73651ee6 JB |
1338 | */ |
1339 | ||
4fd6931e JB |
1340 | if (params->listen_interval >= 0) |
1341 | sta->listen_interval = params->listen_interval; | |
1342 | ||
1343 | if (params->supported_rates) { | |
2103dec1 SW |
1344 | ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef, |
1345 | sband, params->supported_rates, | |
1346 | params->supported_rates_len, | |
1347 | &sta->sta.supp_rates[band]); | |
4fd6931e | 1348 | } |
c5dd9c2b | 1349 | |
d9fe60de | 1350 | if (params->ht_capa) |
ef96a842 | 1351 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, |
e1a0c6b3 | 1352 | params->ht_capa, sta); |
36aedc90 | 1353 | |
f461be3e MP |
1354 | if (params->vht_capa) |
1355 | ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband, | |
4a34215e | 1356 | params->vht_capa, sta); |
f461be3e | 1357 | |
b1bce14a | 1358 | if (params->opmode_notif_used) { |
b1bce14a MK |
1359 | /* returned value is only needed for rc update, but the |
1360 | * rc isn't initialized here yet, so ignore it | |
1361 | */ | |
1362 | __ieee80211_vht_handle_opmode(sdata, sta, | |
1363 | params->opmode_notif, | |
1364 | band, false); | |
1365 | } | |
1366 | ||
9c3990aa | 1367 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
4daf50f2 | 1368 | #ifdef CONFIG_MAC80211_MESH |
39886b61 | 1369 | u32 changed = 0; |
77ee7c89 JB |
1370 | |
1371 | if (params->sta_modify_mask & STATION_PARAM_APPLY_PLINK_STATE) { | |
9c3990aa | 1372 | switch (params->plink_state) { |
57cf8043 | 1373 | case NL80211_PLINK_ESTAB: |
1617bab8 MP |
1374 | if (sta->plink_state != NL80211_PLINK_ESTAB) |
1375 | changed = mesh_plink_inc_estab_count( | |
1376 | sdata); | |
1377 | sta->plink_state = params->plink_state; | |
3f52b7e3 MP |
1378 | |
1379 | ieee80211_mps_sta_status_update(sta); | |
39886b61 TP |
1380 | changed |= ieee80211_mps_set_sta_local_pm(sta, |
1381 | sdata->u.mesh.mshcfg.power_mode); | |
1617bab8 MP |
1382 | break; |
1383 | case NL80211_PLINK_LISTEN: | |
57cf8043 | 1384 | case NL80211_PLINK_BLOCKED: |
1617bab8 MP |
1385 | case NL80211_PLINK_OPN_SNT: |
1386 | case NL80211_PLINK_OPN_RCVD: | |
1387 | case NL80211_PLINK_CNF_RCVD: | |
1388 | case NL80211_PLINK_HOLDING: | |
1389 | if (sta->plink_state == NL80211_PLINK_ESTAB) | |
1390 | changed = mesh_plink_dec_estab_count( | |
1391 | sdata); | |
9c3990aa | 1392 | sta->plink_state = params->plink_state; |
3f52b7e3 MP |
1393 | |
1394 | ieee80211_mps_sta_status_update(sta); | |
446075d7 MP |
1395 | changed |= ieee80211_mps_set_sta_local_pm(sta, |
1396 | NL80211_MESH_POWER_UNKNOWN); | |
9c3990aa JC |
1397 | break; |
1398 | default: | |
1399 | /* nothing */ | |
1400 | break; | |
1401 | } | |
77ee7c89 JB |
1402 | } |
1403 | ||
1404 | switch (params->plink_action) { | |
1405 | case NL80211_PLINK_ACTION_NO_ACTION: | |
1406 | /* nothing */ | |
1407 | break; | |
1408 | case NL80211_PLINK_ACTION_OPEN: | |
1409 | changed |= mesh_plink_open(sta); | |
1410 | break; | |
1411 | case NL80211_PLINK_ACTION_BLOCK: | |
1412 | changed |= mesh_plink_block(sta); | |
1413 | break; | |
1617bab8 | 1414 | } |
3f52b7e3 MP |
1415 | |
1416 | if (params->local_pm) | |
39886b61 TP |
1417 | changed |= |
1418 | ieee80211_mps_set_sta_local_pm(sta, | |
1419 | params->local_pm); | |
6c751ef8 | 1420 | ieee80211_mbss_info_change_notify(sdata, changed); |
4daf50f2 | 1421 | #endif |
902acc78 | 1422 | } |
d9a7ddb0 JB |
1423 | |
1424 | return 0; | |
4fd6931e JB |
1425 | } |
1426 | ||
1427 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |
1428 | u8 *mac, struct station_parameters *params) | |
1429 | { | |
14db74bc | 1430 | struct ieee80211_local *local = wiphy_priv(wiphy); |
4fd6931e JB |
1431 | struct sta_info *sta; |
1432 | struct ieee80211_sub_if_data *sdata; | |
73651ee6 | 1433 | int err; |
b8d476c8 | 1434 | int layer2_update; |
4fd6931e | 1435 | |
4fd6931e JB |
1436 | if (params->vlan) { |
1437 | sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); | |
1438 | ||
05c914fe JB |
1439 | if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && |
1440 | sdata->vif.type != NL80211_IFTYPE_AP) | |
4fd6931e JB |
1441 | return -EINVAL; |
1442 | } else | |
1443 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1444 | ||
b203ca39 | 1445 | if (ether_addr_equal(mac, sdata->vif.addr)) |
03e4497e JB |
1446 | return -EINVAL; |
1447 | ||
1448 | if (is_multicast_ether_addr(mac)) | |
1449 | return -EINVAL; | |
1450 | ||
1451 | sta = sta_info_alloc(sdata, mac, GFP_KERNEL); | |
73651ee6 JB |
1452 | if (!sta) |
1453 | return -ENOMEM; | |
4fd6931e | 1454 | |
d582cffb JB |
1455 | /* |
1456 | * defaults -- if userspace wants something else we'll | |
1457 | * change it accordingly in sta_apply_parameters() | |
1458 | */ | |
77ee7c89 JB |
1459 | if (!(params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))) { |
1460 | sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); | |
1461 | sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC); | |
1462 | } | |
4fd6931e | 1463 | |
d9a7ddb0 JB |
1464 | err = sta_apply_parameters(local, sta, params); |
1465 | if (err) { | |
1466 | sta_info_free(local, sta); | |
1467 | return err; | |
1468 | } | |
4fd6931e | 1469 | |
d64cf63e | 1470 | /* |
77ee7c89 JB |
1471 | * for TDLS, rate control should be initialized only when |
1472 | * rates are known and station is marked authorized | |
d64cf63e AN |
1473 | */ |
1474 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) | |
1475 | rate_control_rate_init(sta); | |
4fd6931e | 1476 | |
b8d476c8 JM |
1477 | layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || |
1478 | sdata->vif.type == NL80211_IFTYPE_AP; | |
1479 | ||
34e89507 | 1480 | err = sta_info_insert_rcu(sta); |
73651ee6 | 1481 | if (err) { |
73651ee6 JB |
1482 | rcu_read_unlock(); |
1483 | return err; | |
1484 | } | |
1485 | ||
b8d476c8 | 1486 | if (layer2_update) |
73651ee6 JB |
1487 | ieee80211_send_layer2_update(sta); |
1488 | ||
1489 | rcu_read_unlock(); | |
1490 | ||
4fd6931e JB |
1491 | return 0; |
1492 | } | |
1493 | ||
1494 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, | |
1495 | u8 *mac) | |
1496 | { | |
14db74bc | 1497 | struct ieee80211_sub_if_data *sdata; |
4fd6931e | 1498 | |
14db74bc JB |
1499 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1500 | ||
34e89507 JB |
1501 | if (mac) |
1502 | return sta_info_destroy_addr_bss(sdata, mac); | |
4fd6931e | 1503 | |
b998e8bb | 1504 | sta_info_flush(sdata); |
4fd6931e JB |
1505 | return 0; |
1506 | } | |
1507 | ||
1508 | static int ieee80211_change_station(struct wiphy *wiphy, | |
77ee7c89 | 1509 | struct net_device *dev, u8 *mac, |
4fd6931e JB |
1510 | struct station_parameters *params) |
1511 | { | |
abe60632 | 1512 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
14db74bc | 1513 | struct ieee80211_local *local = wiphy_priv(wiphy); |
4fd6931e JB |
1514 | struct sta_info *sta; |
1515 | struct ieee80211_sub_if_data *vlansdata; | |
77ee7c89 | 1516 | enum cfg80211_station_type statype; |
35b88623 | 1517 | int err; |
4fd6931e | 1518 | |
87be1e1e | 1519 | mutex_lock(&local->sta_mtx); |
98dd6a57 | 1520 | |
0e5ded5a | 1521 | sta = sta_info_get_bss(sdata, mac); |
98dd6a57 | 1522 | if (!sta) { |
77ee7c89 JB |
1523 | err = -ENOENT; |
1524 | goto out_err; | |
98dd6a57 | 1525 | } |
4fd6931e | 1526 | |
77ee7c89 JB |
1527 | switch (sdata->vif.type) { |
1528 | case NL80211_IFTYPE_MESH_POINT: | |
a6dad6a2 | 1529 | if (sdata->u.mesh.user_mpm) |
eef941e6 | 1530 | statype = CFG80211_STA_MESH_PEER_USER; |
77ee7c89 | 1531 | else |
eef941e6 | 1532 | statype = CFG80211_STA_MESH_PEER_KERNEL; |
77ee7c89 JB |
1533 | break; |
1534 | case NL80211_IFTYPE_ADHOC: | |
1535 | statype = CFG80211_STA_IBSS; | |
1536 | break; | |
1537 | case NL80211_IFTYPE_STATION: | |
1538 | if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) { | |
1539 | statype = CFG80211_STA_AP_STA; | |
1540 | break; | |
1541 | } | |
1542 | if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
1543 | statype = CFG80211_STA_TDLS_PEER_ACTIVE; | |
1544 | else | |
1545 | statype = CFG80211_STA_TDLS_PEER_SETUP; | |
1546 | break; | |
1547 | case NL80211_IFTYPE_AP: | |
1548 | case NL80211_IFTYPE_AP_VLAN: | |
1549 | statype = CFG80211_STA_AP_CLIENT; | |
1550 | break; | |
1551 | default: | |
1552 | err = -EOPNOTSUPP; | |
1553 | goto out_err; | |
bdd90d5e JB |
1554 | } |
1555 | ||
77ee7c89 JB |
1556 | err = cfg80211_check_station_change(wiphy, params, statype); |
1557 | if (err) | |
1558 | goto out_err; | |
1559 | ||
d0709a65 | 1560 | if (params->vlan && params->vlan != sta->sdata->dev) { |
7e3ed02c FF |
1561 | bool prev_4addr = false; |
1562 | bool new_4addr = false; | |
1563 | ||
4fd6931e JB |
1564 | vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); |
1565 | ||
9bc383de | 1566 | if (params->vlan->ieee80211_ptr->use_4addr) { |
3305443c | 1567 | if (vlansdata->u.vlan.sta) { |
77ee7c89 JB |
1568 | err = -EBUSY; |
1569 | goto out_err; | |
3305443c | 1570 | } |
f14543ee | 1571 | |
cf778b00 | 1572 | rcu_assign_pointer(vlansdata->u.vlan.sta, sta); |
7e3ed02c FF |
1573 | new_4addr = true; |
1574 | } | |
1575 | ||
1576 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | |
1577 | sta->sdata->u.vlan.sta) { | |
0c2bef46 | 1578 | RCU_INIT_POINTER(sta->sdata->u.vlan.sta, NULL); |
7e3ed02c | 1579 | prev_4addr = true; |
f14543ee FF |
1580 | } |
1581 | ||
14db74bc | 1582 | sta->sdata = vlansdata; |
7e3ed02c FF |
1583 | |
1584 | if (sta->sta_state == IEEE80211_STA_AUTHORIZED && | |
1585 | prev_4addr != new_4addr) { | |
1586 | if (new_4addr) | |
1587 | atomic_dec(&sta->sdata->bss->num_mcast_sta); | |
1588 | else | |
1589 | atomic_inc(&sta->sdata->bss->num_mcast_sta); | |
1590 | } | |
1591 | ||
4fd6931e JB |
1592 | ieee80211_send_layer2_update(sta); |
1593 | } | |
1594 | ||
35b88623 | 1595 | err = sta_apply_parameters(local, sta, params); |
77ee7c89 JB |
1596 | if (err) |
1597 | goto out_err; | |
4fd6931e | 1598 | |
77ee7c89 JB |
1599 | /* When peer becomes authorized, init rate control as well */ |
1600 | if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && | |
1601 | test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
d64cf63e AN |
1602 | rate_control_rate_init(sta); |
1603 | ||
87be1e1e | 1604 | mutex_unlock(&local->sta_mtx); |
98dd6a57 | 1605 | |
687da132 EG |
1606 | if ((sdata->vif.type == NL80211_IFTYPE_AP || |
1607 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) && | |
1608 | sta->known_smps_mode != sta->sdata->bss->req_smps && | |
1609 | test_sta_flag(sta, WLAN_STA_AUTHORIZED) && | |
1610 | sta_info_tx_streams(sta) != 1) { | |
1611 | ht_dbg(sta->sdata, | |
1612 | "%pM just authorized and MIMO capable - update SMPS\n", | |
1613 | sta->sta.addr); | |
1614 | ieee80211_send_smps_action(sta->sdata, | |
1615 | sta->sdata->bss->req_smps, | |
1616 | sta->sta.addr, | |
1617 | sta->sdata->vif.bss_conf.bssid); | |
1618 | } | |
1619 | ||
808118cb | 1620 | if (sdata->vif.type == NL80211_IFTYPE_STATION && |
ab095877 | 1621 | params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) { |
808118cb | 1622 | ieee80211_recalc_ps(local, -1); |
ab095877 EP |
1623 | ieee80211_recalc_ps_vif(sdata); |
1624 | } | |
77ee7c89 | 1625 | |
4fd6931e | 1626 | return 0; |
77ee7c89 JB |
1627 | out_err: |
1628 | mutex_unlock(&local->sta_mtx); | |
1629 | return err; | |
4fd6931e JB |
1630 | } |
1631 | ||
c5dd9c2b LCC |
1632 | #ifdef CONFIG_MAC80211_MESH |
1633 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | |
1634 | u8 *dst, u8 *next_hop) | |
1635 | { | |
14db74bc | 1636 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
1637 | struct mesh_path *mpath; |
1638 | struct sta_info *sta; | |
c5dd9c2b | 1639 | |
14db74bc JB |
1640 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1641 | ||
d0709a65 | 1642 | rcu_read_lock(); |
abe60632 | 1643 | sta = sta_info_get(sdata, next_hop); |
d0709a65 JB |
1644 | if (!sta) { |
1645 | rcu_read_unlock(); | |
c5dd9c2b | 1646 | return -ENOENT; |
d0709a65 | 1647 | } |
c5dd9c2b | 1648 | |
ae76eef0 BC |
1649 | mpath = mesh_path_add(sdata, dst); |
1650 | if (IS_ERR(mpath)) { | |
d0709a65 | 1651 | rcu_read_unlock(); |
ae76eef0 | 1652 | return PTR_ERR(mpath); |
d0709a65 | 1653 | } |
c5dd9c2b | 1654 | |
c5dd9c2b | 1655 | mesh_path_fix_nexthop(mpath, sta); |
d0709a65 | 1656 | |
c5dd9c2b LCC |
1657 | rcu_read_unlock(); |
1658 | return 0; | |
1659 | } | |
1660 | ||
1661 | static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, | |
bf7cd94d | 1662 | u8 *dst) |
c5dd9c2b | 1663 | { |
f698d856 JBG |
1664 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1665 | ||
c5dd9c2b | 1666 | if (dst) |
bf7cd94d | 1667 | return mesh_path_del(sdata, dst); |
c5dd9c2b | 1668 | |
ece1a2e7 | 1669 | mesh_path_flush_by_iface(sdata); |
c5dd9c2b LCC |
1670 | return 0; |
1671 | } | |
1672 | ||
1673 | static int ieee80211_change_mpath(struct wiphy *wiphy, | |
1674 | struct net_device *dev, | |
1675 | u8 *dst, u8 *next_hop) | |
1676 | { | |
14db74bc | 1677 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
1678 | struct mesh_path *mpath; |
1679 | struct sta_info *sta; | |
1680 | ||
14db74bc JB |
1681 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1682 | ||
d0709a65 JB |
1683 | rcu_read_lock(); |
1684 | ||
abe60632 | 1685 | sta = sta_info_get(sdata, next_hop); |
d0709a65 JB |
1686 | if (!sta) { |
1687 | rcu_read_unlock(); | |
c5dd9c2b | 1688 | return -ENOENT; |
d0709a65 | 1689 | } |
c5dd9c2b | 1690 | |
bf7cd94d | 1691 | mpath = mesh_path_lookup(sdata, dst); |
c5dd9c2b LCC |
1692 | if (!mpath) { |
1693 | rcu_read_unlock(); | |
c5dd9c2b LCC |
1694 | return -ENOENT; |
1695 | } | |
1696 | ||
1697 | mesh_path_fix_nexthop(mpath, sta); | |
d0709a65 | 1698 | |
c5dd9c2b LCC |
1699 | rcu_read_unlock(); |
1700 | return 0; | |
1701 | } | |
1702 | ||
1703 | static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop, | |
1704 | struct mpath_info *pinfo) | |
1705 | { | |
a3836e02 JB |
1706 | struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop); |
1707 | ||
1708 | if (next_hop_sta) | |
1709 | memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN); | |
c5dd9c2b LCC |
1710 | else |
1711 | memset(next_hop, 0, ETH_ALEN); | |
1712 | ||
7ce8c7a3 LAYS |
1713 | memset(pinfo, 0, sizeof(*pinfo)); |
1714 | ||
f5ea9120 JB |
1715 | pinfo->generation = mesh_paths_generation; |
1716 | ||
c5dd9c2b | 1717 | pinfo->filled = MPATH_INFO_FRAME_QLEN | |
d19b3bf6 | 1718 | MPATH_INFO_SN | |
c5dd9c2b LCC |
1719 | MPATH_INFO_METRIC | |
1720 | MPATH_INFO_EXPTIME | | |
1721 | MPATH_INFO_DISCOVERY_TIMEOUT | | |
1722 | MPATH_INFO_DISCOVERY_RETRIES | | |
1723 | MPATH_INFO_FLAGS; | |
1724 | ||
1725 | pinfo->frame_qlen = mpath->frame_queue.qlen; | |
d19b3bf6 | 1726 | pinfo->sn = mpath->sn; |
c5dd9c2b LCC |
1727 | pinfo->metric = mpath->metric; |
1728 | if (time_before(jiffies, mpath->exp_time)) | |
1729 | pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies); | |
1730 | pinfo->discovery_timeout = | |
1731 | jiffies_to_msecs(mpath->discovery_timeout); | |
1732 | pinfo->discovery_retries = mpath->discovery_retries; | |
c5dd9c2b LCC |
1733 | if (mpath->flags & MESH_PATH_ACTIVE) |
1734 | pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE; | |
1735 | if (mpath->flags & MESH_PATH_RESOLVING) | |
1736 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING; | |
d19b3bf6 RP |
1737 | if (mpath->flags & MESH_PATH_SN_VALID) |
1738 | pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID; | |
c5dd9c2b LCC |
1739 | if (mpath->flags & MESH_PATH_FIXED) |
1740 | pinfo->flags |= NL80211_MPATH_FLAG_FIXED; | |
7ce8c7a3 LAYS |
1741 | if (mpath->flags & MESH_PATH_RESOLVED) |
1742 | pinfo->flags |= NL80211_MPATH_FLAG_RESOLVED; | |
c5dd9c2b LCC |
1743 | } |
1744 | ||
1745 | static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, | |
1746 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) | |
1747 | ||
1748 | { | |
14db74bc | 1749 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
1750 | struct mesh_path *mpath; |
1751 | ||
14db74bc JB |
1752 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1753 | ||
c5dd9c2b | 1754 | rcu_read_lock(); |
bf7cd94d | 1755 | mpath = mesh_path_lookup(sdata, dst); |
c5dd9c2b LCC |
1756 | if (!mpath) { |
1757 | rcu_read_unlock(); | |
1758 | return -ENOENT; | |
1759 | } | |
1760 | memcpy(dst, mpath->dst, ETH_ALEN); | |
1761 | mpath_set_pinfo(mpath, next_hop, pinfo); | |
1762 | rcu_read_unlock(); | |
1763 | return 0; | |
1764 | } | |
1765 | ||
1766 | static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, | |
1767 | int idx, u8 *dst, u8 *next_hop, | |
1768 | struct mpath_info *pinfo) | |
1769 | { | |
14db74bc | 1770 | struct ieee80211_sub_if_data *sdata; |
c5dd9c2b LCC |
1771 | struct mesh_path *mpath; |
1772 | ||
14db74bc JB |
1773 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1774 | ||
c5dd9c2b | 1775 | rcu_read_lock(); |
bf7cd94d | 1776 | mpath = mesh_path_lookup_by_idx(sdata, idx); |
c5dd9c2b LCC |
1777 | if (!mpath) { |
1778 | rcu_read_unlock(); | |
1779 | return -ENOENT; | |
1780 | } | |
1781 | memcpy(dst, mpath->dst, ETH_ALEN); | |
1782 | mpath_set_pinfo(mpath, next_hop, pinfo); | |
1783 | rcu_read_unlock(); | |
1784 | return 0; | |
1785 | } | |
93da9cc1 | 1786 | |
24bdd9f4 | 1787 | static int ieee80211_get_mesh_config(struct wiphy *wiphy, |
93da9cc1 | 1788 | struct net_device *dev, |
1789 | struct mesh_config *conf) | |
1790 | { | |
1791 | struct ieee80211_sub_if_data *sdata; | |
1792 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1793 | ||
93da9cc1 | 1794 | memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config)); |
1795 | return 0; | |
1796 | } | |
1797 | ||
1798 | static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask) | |
1799 | { | |
1800 | return (mask >> (parm-1)) & 0x1; | |
1801 | } | |
1802 | ||
c80d545d JC |
1803 | static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh, |
1804 | const struct mesh_setup *setup) | |
1805 | { | |
1806 | u8 *new_ie; | |
1807 | const u8 *old_ie; | |
4bb62344 CYY |
1808 | struct ieee80211_sub_if_data *sdata = container_of(ifmsh, |
1809 | struct ieee80211_sub_if_data, u.mesh); | |
c80d545d | 1810 | |
581a8b0f | 1811 | /* allocate information elements */ |
c80d545d | 1812 | new_ie = NULL; |
581a8b0f | 1813 | old_ie = ifmsh->ie; |
c80d545d | 1814 | |
581a8b0f JC |
1815 | if (setup->ie_len) { |
1816 | new_ie = kmemdup(setup->ie, setup->ie_len, | |
c80d545d JC |
1817 | GFP_KERNEL); |
1818 | if (!new_ie) | |
1819 | return -ENOMEM; | |
1820 | } | |
581a8b0f JC |
1821 | ifmsh->ie_len = setup->ie_len; |
1822 | ifmsh->ie = new_ie; | |
1823 | kfree(old_ie); | |
c80d545d JC |
1824 | |
1825 | /* now copy the rest of the setup parameters */ | |
1826 | ifmsh->mesh_id_len = setup->mesh_id_len; | |
1827 | memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len); | |
d299a1f2 | 1828 | ifmsh->mesh_sp_id = setup->sync_method; |
c80d545d JC |
1829 | ifmsh->mesh_pp_id = setup->path_sel_proto; |
1830 | ifmsh->mesh_pm_id = setup->path_metric; | |
a6dad6a2 | 1831 | ifmsh->user_mpm = setup->user_mpm; |
0d4261ad | 1832 | ifmsh->mesh_auth_id = setup->auth_id; |
b130e5ce JC |
1833 | ifmsh->security = IEEE80211_MESH_SEC_NONE; |
1834 | if (setup->is_authenticated) | |
1835 | ifmsh->security |= IEEE80211_MESH_SEC_AUTHED; | |
1836 | if (setup->is_secure) | |
1837 | ifmsh->security |= IEEE80211_MESH_SEC_SECURED; | |
c80d545d | 1838 | |
4bb62344 CYY |
1839 | /* mcast rate setting in Mesh Node */ |
1840 | memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate, | |
1841 | sizeof(setup->mcast_rate)); | |
ffb3cf30 | 1842 | sdata->vif.bss_conf.basic_rates = setup->basic_rates; |
4bb62344 | 1843 | |
9bdbf04d MP |
1844 | sdata->vif.bss_conf.beacon_int = setup->beacon_interval; |
1845 | sdata->vif.bss_conf.dtim_period = setup->dtim_period; | |
1846 | ||
c80d545d JC |
1847 | return 0; |
1848 | } | |
1849 | ||
24bdd9f4 | 1850 | static int ieee80211_update_mesh_config(struct wiphy *wiphy, |
29cbe68c JB |
1851 | struct net_device *dev, u32 mask, |
1852 | const struct mesh_config *nconf) | |
93da9cc1 | 1853 | { |
1854 | struct mesh_config *conf; | |
1855 | struct ieee80211_sub_if_data *sdata; | |
63c5723b RP |
1856 | struct ieee80211_if_mesh *ifmsh; |
1857 | ||
93da9cc1 | 1858 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
63c5723b | 1859 | ifmsh = &sdata->u.mesh; |
93da9cc1 | 1860 | |
93da9cc1 | 1861 | /* Set the config options which we are interested in setting */ |
1862 | conf = &(sdata->u.mesh.mshcfg); | |
1863 | if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask)) | |
1864 | conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout; | |
1865 | if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask)) | |
1866 | conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout; | |
1867 | if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask)) | |
1868 | conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout; | |
1869 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask)) | |
1870 | conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks; | |
1871 | if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask)) | |
1872 | conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries; | |
1873 | if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask)) | |
1874 | conf->dot11MeshTTL = nconf->dot11MeshTTL; | |
45904f21 | 1875 | if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask)) |
58886a90 | 1876 | conf->element_ttl = nconf->element_ttl; |
146bb483 TP |
1877 | if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask)) { |
1878 | if (ifmsh->user_mpm) | |
1879 | return -EBUSY; | |
93da9cc1 | 1880 | conf->auto_open_plinks = nconf->auto_open_plinks; |
146bb483 | 1881 | } |
d299a1f2 JC |
1882 | if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask)) |
1883 | conf->dot11MeshNbrOffsetMaxNeighbor = | |
1884 | nconf->dot11MeshNbrOffsetMaxNeighbor; | |
93da9cc1 | 1885 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask)) |
1886 | conf->dot11MeshHWMPmaxPREQretries = | |
1887 | nconf->dot11MeshHWMPmaxPREQretries; | |
1888 | if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask)) | |
1889 | conf->path_refresh_time = nconf->path_refresh_time; | |
1890 | if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask)) | |
1891 | conf->min_discovery_timeout = nconf->min_discovery_timeout; | |
1892 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask)) | |
1893 | conf->dot11MeshHWMPactivePathTimeout = | |
1894 | nconf->dot11MeshHWMPactivePathTimeout; | |
1895 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask)) | |
1896 | conf->dot11MeshHWMPpreqMinInterval = | |
1897 | nconf->dot11MeshHWMPpreqMinInterval; | |
dca7e943 TP |
1898 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask)) |
1899 | conf->dot11MeshHWMPperrMinInterval = | |
1900 | nconf->dot11MeshHWMPperrMinInterval; | |
93da9cc1 | 1901 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME, |
1902 | mask)) | |
1903 | conf->dot11MeshHWMPnetDiameterTraversalTime = | |
1904 | nconf->dot11MeshHWMPnetDiameterTraversalTime; | |
63c5723b RP |
1905 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) { |
1906 | conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode; | |
1907 | ieee80211_mesh_root_setup(ifmsh); | |
1908 | } | |
16dd7267 | 1909 | if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) { |
c6133661 TP |
1910 | /* our current gate announcement implementation rides on root |
1911 | * announcements, so require this ifmsh to also be a root node | |
1912 | * */ | |
1913 | if (nconf->dot11MeshGateAnnouncementProtocol && | |
dbb912cd CYY |
1914 | !(conf->dot11MeshHWMPRootMode > IEEE80211_ROOTMODE_ROOT)) { |
1915 | conf->dot11MeshHWMPRootMode = IEEE80211_PROACTIVE_RANN; | |
c6133661 TP |
1916 | ieee80211_mesh_root_setup(ifmsh); |
1917 | } | |
16dd7267 JC |
1918 | conf->dot11MeshGateAnnouncementProtocol = |
1919 | nconf->dot11MeshGateAnnouncementProtocol; | |
1920 | } | |
a4f606ea | 1921 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) |
0507e159 JC |
1922 | conf->dot11MeshHWMPRannInterval = |
1923 | nconf->dot11MeshHWMPRannInterval; | |
94f90656 CYY |
1924 | if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask)) |
1925 | conf->dot11MeshForwarding = nconf->dot11MeshForwarding; | |
55335137 AN |
1926 | if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) { |
1927 | /* our RSSI threshold implementation is supported only for | |
1928 | * devices that report signal in dBm. | |
1929 | */ | |
1930 | if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM)) | |
1931 | return -ENOTSUPP; | |
1932 | conf->rssi_threshold = nconf->rssi_threshold; | |
1933 | } | |
70c33eaa AN |
1934 | if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) { |
1935 | conf->ht_opmode = nconf->ht_opmode; | |
1936 | sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode; | |
1937 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); | |
1938 | } | |
ac1073a6 CYY |
1939 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT, mask)) |
1940 | conf->dot11MeshHWMPactivePathToRootTimeout = | |
1941 | nconf->dot11MeshHWMPactivePathToRootTimeout; | |
1942 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOT_INTERVAL, mask)) | |
1943 | conf->dot11MeshHWMProotInterval = | |
1944 | nconf->dot11MeshHWMProotInterval; | |
728b19e5 CYY |
1945 | if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL, mask)) |
1946 | conf->dot11MeshHWMPconfirmationInterval = | |
1947 | nconf->dot11MeshHWMPconfirmationInterval; | |
3f52b7e3 MP |
1948 | if (_chg_mesh_attr(NL80211_MESHCONF_POWER_MODE, mask)) { |
1949 | conf->power_mode = nconf->power_mode; | |
1950 | ieee80211_mps_local_status_update(sdata); | |
1951 | } | |
2b5e1967 | 1952 | if (_chg_mesh_attr(NL80211_MESHCONF_AWAKE_WINDOW, mask)) |
3f52b7e3 MP |
1953 | conf->dot11MeshAwakeWindowDuration = |
1954 | nconf->dot11MeshAwakeWindowDuration; | |
66de6713 CT |
1955 | if (_chg_mesh_attr(NL80211_MESHCONF_PLINK_TIMEOUT, mask)) |
1956 | conf->plink_timeout = nconf->plink_timeout; | |
2b5e1967 | 1957 | ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON); |
93da9cc1 | 1958 | return 0; |
1959 | } | |
1960 | ||
29cbe68c JB |
1961 | static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev, |
1962 | const struct mesh_config *conf, | |
1963 | const struct mesh_setup *setup) | |
1964 | { | |
1965 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1966 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | |
c80d545d | 1967 | int err; |
29cbe68c | 1968 | |
c80d545d JC |
1969 | memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config)); |
1970 | err = copy_mesh_setup(ifmsh, setup); | |
1971 | if (err) | |
1972 | return err; | |
cc1d2806 | 1973 | |
04ecd257 JB |
1974 | /* can mesh use other SMPS modes? */ |
1975 | sdata->smps_mode = IEEE80211_SMPS_OFF; | |
1976 | sdata->needed_rx_chains = sdata->local->rx_chains; | |
1977 | ||
34a3740d | 1978 | mutex_lock(&sdata->local->mtx); |
4bf88530 | 1979 | err = ieee80211_vif_use_channel(sdata, &setup->chandef, |
55de908a | 1980 | IEEE80211_CHANCTX_SHARED); |
34a3740d | 1981 | mutex_unlock(&sdata->local->mtx); |
cc1d2806 JB |
1982 | if (err) |
1983 | return err; | |
1984 | ||
2b5e1967 | 1985 | return ieee80211_start_mesh(sdata); |
29cbe68c JB |
1986 | } |
1987 | ||
1988 | static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) | |
1989 | { | |
1990 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1991 | ||
1992 | ieee80211_stop_mesh(sdata); | |
34a3740d | 1993 | mutex_lock(&sdata->local->mtx); |
55de908a | 1994 | ieee80211_vif_release_channel(sdata); |
34a3740d | 1995 | mutex_unlock(&sdata->local->mtx); |
29cbe68c JB |
1996 | |
1997 | return 0; | |
1998 | } | |
c5dd9c2b LCC |
1999 | #endif |
2000 | ||
9f1ba906 JM |
2001 | static int ieee80211_change_bss(struct wiphy *wiphy, |
2002 | struct net_device *dev, | |
2003 | struct bss_parameters *params) | |
2004 | { | |
55de908a JB |
2005 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2006 | enum ieee80211_band band; | |
9f1ba906 JM |
2007 | u32 changed = 0; |
2008 | ||
7ca133bc | 2009 | if (!sdata_dereference(sdata->u.ap.beacon, sdata)) |
55de908a JB |
2010 | return -ENOENT; |
2011 | ||
2012 | band = ieee80211_get_sdata_band(sdata); | |
9f1ba906 | 2013 | |
9f1ba906 | 2014 | if (params->use_cts_prot >= 0) { |
bda3933a | 2015 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; |
9f1ba906 JM |
2016 | changed |= BSS_CHANGED_ERP_CTS_PROT; |
2017 | } | |
2018 | if (params->use_short_preamble >= 0) { | |
bda3933a | 2019 | sdata->vif.bss_conf.use_short_preamble = |
9f1ba906 JM |
2020 | params->use_short_preamble; |
2021 | changed |= BSS_CHANGED_ERP_PREAMBLE; | |
2022 | } | |
43d35343 FF |
2023 | |
2024 | if (!sdata->vif.bss_conf.use_short_slot && | |
55de908a | 2025 | band == IEEE80211_BAND_5GHZ) { |
43d35343 FF |
2026 | sdata->vif.bss_conf.use_short_slot = true; |
2027 | changed |= BSS_CHANGED_ERP_SLOT; | |
2028 | } | |
2029 | ||
9f1ba906 | 2030 | if (params->use_short_slot_time >= 0) { |
bda3933a | 2031 | sdata->vif.bss_conf.use_short_slot = |
9f1ba906 JM |
2032 | params->use_short_slot_time; |
2033 | changed |= BSS_CHANGED_ERP_SLOT; | |
2034 | } | |
2035 | ||
90c97a04 | 2036 | if (params->basic_rates) { |
2103dec1 SW |
2037 | ieee80211_parse_bitrates(&sdata->vif.bss_conf.chandef, |
2038 | wiphy->bands[band], | |
2039 | params->basic_rates, | |
2040 | params->basic_rates_len, | |
2041 | &sdata->vif.bss_conf.basic_rates); | |
90c97a04 JM |
2042 | changed |= BSS_CHANGED_BASIC_RATES; |
2043 | } | |
2044 | ||
7b7b5e56 FF |
2045 | if (params->ap_isolate >= 0) { |
2046 | if (params->ap_isolate) | |
2047 | sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS; | |
2048 | else | |
2049 | sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS; | |
2050 | } | |
2051 | ||
80d7e403 HS |
2052 | if (params->ht_opmode >= 0) { |
2053 | sdata->vif.bss_conf.ht_operation_mode = | |
2054 | (u16) params->ht_opmode; | |
2055 | changed |= BSS_CHANGED_HT; | |
2056 | } | |
2057 | ||
339afbf4 | 2058 | if (params->p2p_ctwindow >= 0) { |
67baf663 JD |
2059 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= |
2060 | ~IEEE80211_P2P_OPPPS_CTWINDOW_MASK; | |
2061 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= | |
2062 | params->p2p_ctwindow & IEEE80211_P2P_OPPPS_CTWINDOW_MASK; | |
339afbf4 JB |
2063 | changed |= BSS_CHANGED_P2P_PS; |
2064 | } | |
2065 | ||
67baf663 JD |
2066 | if (params->p2p_opp_ps > 0) { |
2067 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |= | |
2068 | IEEE80211_P2P_OPPPS_ENABLE_BIT; | |
2069 | changed |= BSS_CHANGED_P2P_PS; | |
2070 | } else if (params->p2p_opp_ps == 0) { | |
2071 | sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow &= | |
2072 | ~IEEE80211_P2P_OPPPS_ENABLE_BIT; | |
339afbf4 JB |
2073 | changed |= BSS_CHANGED_P2P_PS; |
2074 | } | |
2075 | ||
9f1ba906 JM |
2076 | ieee80211_bss_info_change_notify(sdata, changed); |
2077 | ||
2078 | return 0; | |
2079 | } | |
2080 | ||
31888487 | 2081 | static int ieee80211_set_txq_params(struct wiphy *wiphy, |
f70f01c2 | 2082 | struct net_device *dev, |
31888487 JM |
2083 | struct ieee80211_txq_params *params) |
2084 | { | |
2085 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
f6f3def3 | 2086 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
31888487 JM |
2087 | struct ieee80211_tx_queue_params p; |
2088 | ||
2089 | if (!local->ops->conf_tx) | |
2090 | return -EOPNOTSUPP; | |
2091 | ||
54bcbc69 JB |
2092 | if (local->hw.queues < IEEE80211_NUM_ACS) |
2093 | return -EOPNOTSUPP; | |
2094 | ||
31888487 JM |
2095 | memset(&p, 0, sizeof(p)); |
2096 | p.aifs = params->aifs; | |
2097 | p.cw_max = params->cwmax; | |
2098 | p.cw_min = params->cwmin; | |
2099 | p.txop = params->txop; | |
ab13315a KV |
2100 | |
2101 | /* | |
2102 | * Setting tx queue params disables u-apsd because it's only | |
2103 | * called in master mode. | |
2104 | */ | |
2105 | p.uapsd = false; | |
2106 | ||
a3304b0a JB |
2107 | sdata->tx_conf[params->ac] = p; |
2108 | if (drv_conf_tx(local, sdata, params->ac, &p)) { | |
0fb9a9ec | 2109 | wiphy_debug(local->hw.wiphy, |
a3304b0a JB |
2110 | "failed to set TX queue parameters for AC %d\n", |
2111 | params->ac); | |
31888487 JM |
2112 | return -EINVAL; |
2113 | } | |
2114 | ||
7d25745d JB |
2115 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS); |
2116 | ||
31888487 JM |
2117 | return 0; |
2118 | } | |
2119 | ||
665af4fc | 2120 | #ifdef CONFIG_PM |
ff1b6e69 JB |
2121 | static int ieee80211_suspend(struct wiphy *wiphy, |
2122 | struct cfg80211_wowlan *wowlan) | |
665af4fc | 2123 | { |
eecc4800 | 2124 | return __ieee80211_suspend(wiphy_priv(wiphy), wowlan); |
665af4fc BC |
2125 | } |
2126 | ||
2127 | static int ieee80211_resume(struct wiphy *wiphy) | |
2128 | { | |
2129 | return __ieee80211_resume(wiphy_priv(wiphy)); | |
2130 | } | |
2131 | #else | |
2132 | #define ieee80211_suspend NULL | |
2133 | #define ieee80211_resume NULL | |
2134 | #endif | |
2135 | ||
2a519311 | 2136 | static int ieee80211_scan(struct wiphy *wiphy, |
2a519311 JB |
2137 | struct cfg80211_scan_request *req) |
2138 | { | |
fd014284 JB |
2139 | struct ieee80211_sub_if_data *sdata; |
2140 | ||
2141 | sdata = IEEE80211_WDEV_TO_SUB_IF(req->wdev); | |
2a519311 | 2142 | |
2ca27bcf JB |
2143 | switch (ieee80211_vif_type_p2p(&sdata->vif)) { |
2144 | case NL80211_IFTYPE_STATION: | |
2145 | case NL80211_IFTYPE_ADHOC: | |
2146 | case NL80211_IFTYPE_MESH_POINT: | |
2147 | case NL80211_IFTYPE_P2P_CLIENT: | |
f142c6b9 | 2148 | case NL80211_IFTYPE_P2P_DEVICE: |
2ca27bcf JB |
2149 | break; |
2150 | case NL80211_IFTYPE_P2P_GO: | |
2151 | if (sdata->local->ops->hw_scan) | |
2152 | break; | |
e9d7732e JB |
2153 | /* |
2154 | * FIXME: implement NoA while scanning in software, | |
2155 | * for now fall through to allow scanning only when | |
2156 | * beaconing hasn't been configured yet | |
2157 | */ | |
2ca27bcf | 2158 | case NL80211_IFTYPE_AP: |
5c95b940 AQ |
2159 | /* |
2160 | * If the scan has been forced (and the driver supports | |
2161 | * forcing), don't care about being beaconing already. | |
2162 | * This will create problems to the attached stations (e.g. all | |
2163 | * the frames sent while scanning on other channel will be | |
2164 | * lost) | |
2165 | */ | |
2166 | if (sdata->u.ap.beacon && | |
2167 | (!(wiphy->features & NL80211_FEATURE_AP_SCAN) || | |
2168 | !(req->flags & NL80211_SCAN_FLAG_AP))) | |
2ca27bcf JB |
2169 | return -EOPNOTSUPP; |
2170 | break; | |
2171 | default: | |
2172 | return -EOPNOTSUPP; | |
2173 | } | |
2a519311 JB |
2174 | |
2175 | return ieee80211_request_scan(sdata, req); | |
2176 | } | |
2177 | ||
79f460ca LC |
2178 | static int |
2179 | ieee80211_sched_scan_start(struct wiphy *wiphy, | |
2180 | struct net_device *dev, | |
2181 | struct cfg80211_sched_scan_request *req) | |
2182 | { | |
2183 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2184 | ||
2185 | if (!sdata->local->ops->sched_scan_start) | |
2186 | return -EOPNOTSUPP; | |
2187 | ||
2188 | return ieee80211_request_sched_scan_start(sdata, req); | |
2189 | } | |
2190 | ||
2191 | static int | |
85a9994a | 2192 | ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev) |
79f460ca LC |
2193 | { |
2194 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2195 | ||
2196 | if (!sdata->local->ops->sched_scan_stop) | |
2197 | return -EOPNOTSUPP; | |
2198 | ||
85a9994a | 2199 | return ieee80211_request_sched_scan_stop(sdata); |
79f460ca LC |
2200 | } |
2201 | ||
636a5d36 JM |
2202 | static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, |
2203 | struct cfg80211_auth_request *req) | |
2204 | { | |
77fdaa12 | 2205 | return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
2206 | } |
2207 | ||
2208 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, | |
2209 | struct cfg80211_assoc_request *req) | |
2210 | { | |
77fdaa12 | 2211 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
2212 | } |
2213 | ||
2214 | static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev, | |
63c9c5e7 | 2215 | struct cfg80211_deauth_request *req) |
636a5d36 | 2216 | { |
63c9c5e7 | 2217 | return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
2218 | } |
2219 | ||
2220 | static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, | |
63c9c5e7 | 2221 | struct cfg80211_disassoc_request *req) |
636a5d36 | 2222 | { |
63c9c5e7 | 2223 | return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
636a5d36 JM |
2224 | } |
2225 | ||
af8cdcd8 JB |
2226 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
2227 | struct cfg80211_ibss_params *params) | |
2228 | { | |
55de908a | 2229 | return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params); |
af8cdcd8 JB |
2230 | } |
2231 | ||
2232 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) | |
2233 | { | |
55de908a | 2234 | return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev)); |
af8cdcd8 JB |
2235 | } |
2236 | ||
391e53e3 AQ |
2237 | static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, |
2238 | int rate[IEEE80211_NUM_BANDS]) | |
2239 | { | |
2240 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2241 | ||
9887dbf5 CD |
2242 | memcpy(sdata->vif.bss_conf.mcast_rate, rate, |
2243 | sizeof(int) * IEEE80211_NUM_BANDS); | |
391e53e3 AQ |
2244 | |
2245 | return 0; | |
2246 | } | |
2247 | ||
b9a5f8ca JM |
2248 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
2249 | { | |
2250 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
24487981 | 2251 | int err; |
b9a5f8ca | 2252 | |
f23a4780 AN |
2253 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
2254 | err = drv_set_frag_threshold(local, wiphy->frag_threshold); | |
2255 | ||
2256 | if (err) | |
2257 | return err; | |
2258 | } | |
2259 | ||
310bc676 LT |
2260 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) { |
2261 | err = drv_set_coverage_class(local, wiphy->coverage_class); | |
2262 | ||
2263 | if (err) | |
2264 | return err; | |
2265 | } | |
2266 | ||
b9a5f8ca | 2267 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
24487981 | 2268 | err = drv_set_rts_threshold(local, wiphy->rts_threshold); |
b9a5f8ca | 2269 | |
24487981 JB |
2270 | if (err) |
2271 | return err; | |
b9a5f8ca JM |
2272 | } |
2273 | ||
8bc83c24 JB |
2274 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
2275 | if (wiphy->retry_short > IEEE80211_MAX_TX_RETRY) | |
2276 | return -EINVAL; | |
b9a5f8ca | 2277 | local->hw.conf.short_frame_max_tx_count = wiphy->retry_short; |
8bc83c24 JB |
2278 | } |
2279 | if (changed & WIPHY_PARAM_RETRY_LONG) { | |
2280 | if (wiphy->retry_long > IEEE80211_MAX_TX_RETRY) | |
2281 | return -EINVAL; | |
b9a5f8ca | 2282 | local->hw.conf.long_frame_max_tx_count = wiphy->retry_long; |
8bc83c24 | 2283 | } |
b9a5f8ca JM |
2284 | if (changed & |
2285 | (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG)) | |
2286 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS); | |
2287 | ||
2288 | return 0; | |
2289 | } | |
2290 | ||
7643a2c3 | 2291 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
c8442118 | 2292 | struct wireless_dev *wdev, |
fa61cf70 | 2293 | enum nl80211_tx_power_setting type, int mbm) |
7643a2c3 JB |
2294 | { |
2295 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
1ea6f9c0 | 2296 | struct ieee80211_sub_if_data *sdata; |
7643a2c3 | 2297 | |
1ea6f9c0 JB |
2298 | if (wdev) { |
2299 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
2300 | ||
2301 | switch (type) { | |
2302 | case NL80211_TX_POWER_AUTOMATIC: | |
2303 | sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL; | |
2304 | break; | |
2305 | case NL80211_TX_POWER_LIMITED: | |
2306 | case NL80211_TX_POWER_FIXED: | |
2307 | if (mbm < 0 || (mbm % 100)) | |
2308 | return -EOPNOTSUPP; | |
2309 | sdata->user_power_level = MBM_TO_DBM(mbm); | |
2310 | break; | |
2311 | } | |
2312 | ||
2313 | ieee80211_recalc_txpower(sdata); | |
2314 | ||
2315 | return 0; | |
2316 | } | |
55de908a | 2317 | |
7643a2c3 | 2318 | switch (type) { |
fa61cf70 | 2319 | case NL80211_TX_POWER_AUTOMATIC: |
1ea6f9c0 | 2320 | local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; |
7643a2c3 | 2321 | break; |
fa61cf70 | 2322 | case NL80211_TX_POWER_LIMITED: |
fa61cf70 JO |
2323 | case NL80211_TX_POWER_FIXED: |
2324 | if (mbm < 0 || (mbm % 100)) | |
2325 | return -EOPNOTSUPP; | |
fa61cf70 | 2326 | local->user_power_level = MBM_TO_DBM(mbm); |
7643a2c3 | 2327 | break; |
7643a2c3 JB |
2328 | } |
2329 | ||
1ea6f9c0 JB |
2330 | mutex_lock(&local->iflist_mtx); |
2331 | list_for_each_entry(sdata, &local->interfaces, list) | |
2332 | sdata->user_power_level = local->user_power_level; | |
2333 | list_for_each_entry(sdata, &local->interfaces, list) | |
2334 | ieee80211_recalc_txpower(sdata); | |
2335 | mutex_unlock(&local->iflist_mtx); | |
7643a2c3 JB |
2336 | |
2337 | return 0; | |
2338 | } | |
2339 | ||
c8442118 JB |
2340 | static int ieee80211_get_tx_power(struct wiphy *wiphy, |
2341 | struct wireless_dev *wdev, | |
2342 | int *dbm) | |
7643a2c3 JB |
2343 | { |
2344 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
1ea6f9c0 | 2345 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
7643a2c3 | 2346 | |
1ea6f9c0 JB |
2347 | if (!local->use_chanctx) |
2348 | *dbm = local->hw.conf.power_level; | |
2349 | else | |
2350 | *dbm = sdata->vif.bss_conf.txpower; | |
7643a2c3 | 2351 | |
7643a2c3 JB |
2352 | return 0; |
2353 | } | |
2354 | ||
ab737a4f | 2355 | static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev, |
388ac775 | 2356 | const u8 *addr) |
ab737a4f JB |
2357 | { |
2358 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2359 | ||
2360 | memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN); | |
2361 | ||
2362 | return 0; | |
2363 | } | |
2364 | ||
1f87f7d3 JB |
2365 | static void ieee80211_rfkill_poll(struct wiphy *wiphy) |
2366 | { | |
2367 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
2368 | ||
2369 | drv_rfkill_poll(local); | |
2370 | } | |
2371 | ||
aff89a9b | 2372 | #ifdef CONFIG_NL80211_TESTMODE |
fc73f11f DS |
2373 | static int ieee80211_testmode_cmd(struct wiphy *wiphy, |
2374 | struct wireless_dev *wdev, | |
2375 | void *data, int len) | |
aff89a9b JB |
2376 | { |
2377 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
52981cd7 | 2378 | struct ieee80211_vif *vif = NULL; |
aff89a9b JB |
2379 | |
2380 | if (!local->ops->testmode_cmd) | |
2381 | return -EOPNOTSUPP; | |
2382 | ||
52981cd7 DS |
2383 | if (wdev) { |
2384 | struct ieee80211_sub_if_data *sdata; | |
2385 | ||
2386 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | |
2387 | if (sdata->flags & IEEE80211_SDATA_IN_DRIVER) | |
2388 | vif = &sdata->vif; | |
2389 | } | |
2390 | ||
2391 | return local->ops->testmode_cmd(&local->hw, vif, data, len); | |
aff89a9b | 2392 | } |
71063f0e WYG |
2393 | |
2394 | static int ieee80211_testmode_dump(struct wiphy *wiphy, | |
2395 | struct sk_buff *skb, | |
2396 | struct netlink_callback *cb, | |
2397 | void *data, int len) | |
2398 | { | |
2399 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
2400 | ||
2401 | if (!local->ops->testmode_dump) | |
2402 | return -EOPNOTSUPP; | |
2403 | ||
2404 | return local->ops->testmode_dump(&local->hw, skb, cb, data, len); | |
2405 | } | |
aff89a9b JB |
2406 | #endif |
2407 | ||
687da132 EG |
2408 | int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata, |
2409 | enum ieee80211_smps_mode smps_mode) | |
2410 | { | |
2411 | struct sta_info *sta; | |
2412 | enum ieee80211_smps_mode old_req; | |
2413 | int i; | |
2414 | ||
2415 | if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_AP)) | |
2416 | return -EINVAL; | |
2417 | ||
2418 | if (sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) | |
2419 | return 0; | |
2420 | ||
2421 | old_req = sdata->u.ap.req_smps; | |
2422 | sdata->u.ap.req_smps = smps_mode; | |
2423 | ||
2424 | /* AUTOMATIC doesn't mean much for AP - don't allow it */ | |
2425 | if (old_req == smps_mode || | |
2426 | smps_mode == IEEE80211_SMPS_AUTOMATIC) | |
2427 | return 0; | |
2428 | ||
2429 | /* If no associated stations, there's no need to do anything */ | |
2430 | if (!atomic_read(&sdata->u.ap.num_mcast_sta)) { | |
2431 | sdata->smps_mode = smps_mode; | |
2432 | ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps); | |
2433 | return 0; | |
2434 | } | |
2435 | ||
2436 | ht_dbg(sdata, | |
2437 | "SMSP %d requested in AP mode, sending Action frame to %d stations\n", | |
2438 | smps_mode, atomic_read(&sdata->u.ap.num_mcast_sta)); | |
2439 | ||
2440 | mutex_lock(&sdata->local->sta_mtx); | |
2441 | for (i = 0; i < STA_HASH_SIZE; i++) { | |
2442 | for (sta = rcu_dereference_protected(sdata->local->sta_hash[i], | |
2443 | lockdep_is_held(&sdata->local->sta_mtx)); | |
2444 | sta; | |
2445 | sta = rcu_dereference_protected(sta->hnext, | |
2446 | lockdep_is_held(&sdata->local->sta_mtx))) { | |
2447 | /* | |
2448 | * Only stations associated to our AP and | |
2449 | * associated VLANs | |
2450 | */ | |
2451 | if (sta->sdata->bss != &sdata->u.ap) | |
2452 | continue; | |
2453 | ||
2454 | /* This station doesn't support MIMO - skip it */ | |
2455 | if (sta_info_tx_streams(sta) == 1) | |
2456 | continue; | |
2457 | ||
2458 | /* | |
2459 | * Don't wake up a STA just to send the action frame | |
2460 | * unless we are getting more restrictive. | |
2461 | */ | |
2462 | if (test_sta_flag(sta, WLAN_STA_PS_STA) && | |
2463 | !ieee80211_smps_is_restrictive(sta->known_smps_mode, | |
2464 | smps_mode)) { | |
2465 | ht_dbg(sdata, | |
2466 | "Won't send SMPS to sleeping STA %pM\n", | |
2467 | sta->sta.addr); | |
2468 | continue; | |
2469 | } | |
2470 | ||
2471 | /* | |
2472 | * If the STA is not authorized, wait until it gets | |
2473 | * authorized and the action frame will be sent then. | |
2474 | */ | |
2475 | if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED)) | |
2476 | continue; | |
2477 | ||
2478 | ht_dbg(sdata, "Sending SMPS to %pM\n", sta->sta.addr); | |
2479 | ieee80211_send_smps_action(sdata, smps_mode, | |
2480 | sta->sta.addr, | |
2481 | sdata->vif.bss_conf.bssid); | |
2482 | } | |
2483 | } | |
2484 | mutex_unlock(&sdata->local->sta_mtx); | |
2485 | ||
2486 | sdata->smps_mode = smps_mode; | |
2487 | ieee80211_queue_work(&sdata->local->hw, &sdata->recalc_smps); | |
2488 | ||
2489 | return 0; | |
2490 | } | |
2491 | ||
2492 | int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata, | |
2493 | enum ieee80211_smps_mode smps_mode) | |
0f78231b JB |
2494 | { |
2495 | const u8 *ap; | |
2496 | enum ieee80211_smps_mode old_req; | |
2497 | int err; | |
2498 | ||
8d61ffa5 | 2499 | lockdep_assert_held(&sdata->wdev.mtx); |
243e6df4 | 2500 | |
687da132 EG |
2501 | if (WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION)) |
2502 | return -EINVAL; | |
2503 | ||
0f78231b JB |
2504 | old_req = sdata->u.mgd.req_smps; |
2505 | sdata->u.mgd.req_smps = smps_mode; | |
2506 | ||
2507 | if (old_req == smps_mode && | |
2508 | smps_mode != IEEE80211_SMPS_AUTOMATIC) | |
2509 | return 0; | |
2510 | ||
2511 | /* | |
2512 | * If not associated, or current association is not an HT | |
04ecd257 JB |
2513 | * association, there's no need to do anything, just store |
2514 | * the new value until we associate. | |
0f78231b JB |
2515 | */ |
2516 | if (!sdata->u.mgd.associated || | |
4bf88530 | 2517 | sdata->vif.bss_conf.chandef.width == NL80211_CHAN_WIDTH_20_NOHT) |
0f78231b | 2518 | return 0; |
0f78231b | 2519 | |
0c1ad2ca | 2520 | ap = sdata->u.mgd.associated->bssid; |
0f78231b JB |
2521 | |
2522 | if (smps_mode == IEEE80211_SMPS_AUTOMATIC) { | |
2523 | if (sdata->u.mgd.powersave) | |
2524 | smps_mode = IEEE80211_SMPS_DYNAMIC; | |
2525 | else | |
2526 | smps_mode = IEEE80211_SMPS_OFF; | |
2527 | } | |
2528 | ||
2529 | /* send SM PS frame to AP */ | |
2530 | err = ieee80211_send_smps_action(sdata, smps_mode, | |
2531 | ap, ap); | |
2532 | if (err) | |
2533 | sdata->u.mgd.req_smps = old_req; | |
2534 | ||
2535 | return err; | |
2536 | } | |
2537 | ||
bc92afd9 JB |
2538 | static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
2539 | bool enabled, int timeout) | |
2540 | { | |
2541 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2542 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
bc92afd9 | 2543 | |
2d3db210 | 2544 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
e5de30c9 BP |
2545 | return -EOPNOTSUPP; |
2546 | ||
bc92afd9 JB |
2547 | if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) |
2548 | return -EOPNOTSUPP; | |
2549 | ||
2550 | if (enabled == sdata->u.mgd.powersave && | |
ff616381 | 2551 | timeout == local->dynamic_ps_forced_timeout) |
bc92afd9 JB |
2552 | return 0; |
2553 | ||
2554 | sdata->u.mgd.powersave = enabled; | |
ff616381 | 2555 | local->dynamic_ps_forced_timeout = timeout; |
bc92afd9 | 2556 | |
0f78231b | 2557 | /* no change, but if automatic follow powersave */ |
ed405be5 | 2558 | sdata_lock(sdata); |
687da132 | 2559 | __ieee80211_request_smps_mgd(sdata, sdata->u.mgd.req_smps); |
ed405be5 | 2560 | sdata_unlock(sdata); |
0f78231b | 2561 | |
bc92afd9 JB |
2562 | if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) |
2563 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS); | |
2564 | ||
2565 | ieee80211_recalc_ps(local, -1); | |
ab095877 | 2566 | ieee80211_recalc_ps_vif(sdata); |
bc92afd9 JB |
2567 | |
2568 | return 0; | |
2569 | } | |
2570 | ||
a97c13c3 JO |
2571 | static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy, |
2572 | struct net_device *dev, | |
2573 | s32 rssi_thold, u32 rssi_hyst) | |
2574 | { | |
2575 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
a97c13c3 JO |
2576 | struct ieee80211_vif *vif = &sdata->vif; |
2577 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; | |
2578 | ||
a97c13c3 JO |
2579 | if (rssi_thold == bss_conf->cqm_rssi_thold && |
2580 | rssi_hyst == bss_conf->cqm_rssi_hyst) | |
2581 | return 0; | |
2582 | ||
2583 | bss_conf->cqm_rssi_thold = rssi_thold; | |
2584 | bss_conf->cqm_rssi_hyst = rssi_hyst; | |
2585 | ||
2586 | /* tell the driver upon association, unless already associated */ | |
ea086359 JB |
2587 | if (sdata->u.mgd.associated && |
2588 | sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI) | |
a97c13c3 JO |
2589 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM); |
2590 | ||
2591 | return 0; | |
2592 | } | |
2593 | ||
9930380f JB |
2594 | static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, |
2595 | struct net_device *dev, | |
2596 | const u8 *addr, | |
2597 | const struct cfg80211_bitrate_mask *mask) | |
2598 | { | |
2599 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2600 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
bdbfd6b5 | 2601 | int i, ret; |
2c7e6bc9 | 2602 | |
554a43d5 EP |
2603 | if (!ieee80211_sdata_running(sdata)) |
2604 | return -ENETDOWN; | |
2605 | ||
bdbfd6b5 SM |
2606 | if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) { |
2607 | ret = drv_set_bitrate_mask(local, sdata, mask); | |
2608 | if (ret) | |
2609 | return ret; | |
2610 | } | |
9930380f | 2611 | |
19468413 | 2612 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) { |
2ffbe6d3 FF |
2613 | struct ieee80211_supported_band *sband = wiphy->bands[i]; |
2614 | int j; | |
2615 | ||
37eb0b16 | 2616 | sdata->rc_rateidx_mask[i] = mask->control[i].legacy; |
d1e33e65 JD |
2617 | memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].ht_mcs, |
2618 | sizeof(mask->control[i].ht_mcs)); | |
2ffbe6d3 FF |
2619 | |
2620 | sdata->rc_has_mcs_mask[i] = false; | |
2621 | if (!sband) | |
2622 | continue; | |
2623 | ||
2624 | for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) | |
2625 | if (~sdata->rc_rateidx_mcs_mask[i][j]) { | |
2626 | sdata->rc_has_mcs_mask[i] = true; | |
2627 | break; | |
2628 | } | |
19468413 | 2629 | } |
9930380f | 2630 | |
37eb0b16 | 2631 | return 0; |
9930380f JB |
2632 | } |
2633 | ||
2eb278e0 JB |
2634 | static int ieee80211_start_roc_work(struct ieee80211_local *local, |
2635 | struct ieee80211_sub_if_data *sdata, | |
2636 | struct ieee80211_channel *channel, | |
2eb278e0 | 2637 | unsigned int duration, u64 *cookie, |
d339d5ca IP |
2638 | struct sk_buff *txskb, |
2639 | enum ieee80211_roc_type type) | |
2eb278e0 JB |
2640 | { |
2641 | struct ieee80211_roc_work *roc, *tmp; | |
2642 | bool queued = false; | |
21f83589 | 2643 | int ret; |
21f83589 JB |
2644 | |
2645 | lockdep_assert_held(&local->mtx); | |
2646 | ||
fe57d9f5 JB |
2647 | if (local->use_chanctx && !local->ops->remain_on_channel) |
2648 | return -EOPNOTSUPP; | |
2649 | ||
2eb278e0 JB |
2650 | roc = kzalloc(sizeof(*roc), GFP_KERNEL); |
2651 | if (!roc) | |
2652 | return -ENOMEM; | |
2653 | ||
2fae062e IP |
2654 | /* |
2655 | * If the duration is zero, then the driver | |
2656 | * wouldn't actually do anything. Set it to | |
2657 | * 10 for now. | |
2658 | * | |
2659 | * TODO: cancel the off-channel operation | |
2660 | * when we get the SKB's TX status and | |
2661 | * the wait time was zero before. | |
2662 | */ | |
2663 | if (!duration) | |
2664 | duration = 10; | |
2665 | ||
2eb278e0 | 2666 | roc->chan = channel; |
2eb278e0 JB |
2667 | roc->duration = duration; |
2668 | roc->req_duration = duration; | |
2669 | roc->frame = txskb; | |
d339d5ca | 2670 | roc->type = type; |
2eb278e0 JB |
2671 | roc->mgmt_tx_cookie = (unsigned long)txskb; |
2672 | roc->sdata = sdata; | |
2673 | INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work); | |
2674 | INIT_LIST_HEAD(&roc->dependents); | |
2675 | ||
2f617435 EP |
2676 | /* |
2677 | * cookie is either the roc cookie (for normal roc) | |
2678 | * or the SKB (for mgmt TX) | |
2679 | */ | |
2680 | if (!txskb) { | |
2681 | /* local->mtx protects this */ | |
2682 | local->roc_cookie_counter++; | |
2683 | roc->cookie = local->roc_cookie_counter; | |
2684 | /* wow, you wrapped 64 bits ... more likely a bug */ | |
2685 | if (WARN_ON(roc->cookie == 0)) { | |
2686 | roc->cookie = 1; | |
2687 | local->roc_cookie_counter++; | |
2688 | } | |
2689 | *cookie = roc->cookie; | |
2690 | } else { | |
2691 | *cookie = (unsigned long)txskb; | |
2692 | } | |
2693 | ||
2eb278e0 | 2694 | /* if there's one pending or we're scanning, queue this one */ |
164eb02d SW |
2695 | if (!list_empty(&local->roc_list) || |
2696 | local->scanning || local->radar_detect_enabled) | |
2eb278e0 JB |
2697 | goto out_check_combine; |
2698 | ||
2699 | /* if not HW assist, just queue & schedule work */ | |
2700 | if (!local->ops->remain_on_channel) { | |
2701 | ieee80211_queue_delayed_work(&local->hw, &roc->work, 0); | |
2702 | goto out_queue; | |
2703 | } | |
2704 | ||
2705 | /* otherwise actually kick it off here (for error handling) */ | |
2706 | ||
d339d5ca | 2707 | ret = drv_remain_on_channel(local, sdata, channel, duration, type); |
21f83589 | 2708 | if (ret) { |
2eb278e0 JB |
2709 | kfree(roc); |
2710 | return ret; | |
21f83589 JB |
2711 | } |
2712 | ||
2eb278e0 JB |
2713 | roc->started = true; |
2714 | goto out_queue; | |
2715 | ||
2716 | out_check_combine: | |
2717 | list_for_each_entry(tmp, &local->roc_list, list) { | |
42d97a59 | 2718 | if (tmp->chan != channel || tmp->sdata != sdata) |
2eb278e0 JB |
2719 | continue; |
2720 | ||
2721 | /* | |
2722 | * Extend this ROC if possible: | |
2723 | * | |
2724 | * If it hasn't started yet, just increase the duration | |
2725 | * and add the new one to the list of dependents. | |
d339d5ca IP |
2726 | * If the type of the new ROC has higher priority, modify the |
2727 | * type of the previous one to match that of the new one. | |
2eb278e0 JB |
2728 | */ |
2729 | if (!tmp->started) { | |
2730 | list_add_tail(&roc->list, &tmp->dependents); | |
2731 | tmp->duration = max(tmp->duration, roc->duration); | |
d339d5ca | 2732 | tmp->type = max(tmp->type, roc->type); |
2eb278e0 JB |
2733 | queued = true; |
2734 | break; | |
2735 | } | |
2736 | ||
2737 | /* If it has already started, it's more difficult ... */ | |
2738 | if (local->ops->remain_on_channel) { | |
2739 | unsigned long j = jiffies; | |
2740 | ||
2741 | /* | |
2742 | * In the offloaded ROC case, if it hasn't begun, add | |
2743 | * this new one to the dependent list to be handled | |
d339d5ca | 2744 | * when the master one begins. If it has begun, |
2eb278e0 JB |
2745 | * check that there's still a minimum time left and |
2746 | * if so, start this one, transmitting the frame, but | |
d339d5ca | 2747 | * add it to the list directly after this one with |
2eb278e0 JB |
2748 | * a reduced time so we'll ask the driver to execute |
2749 | * it right after finishing the previous one, in the | |
2750 | * hope that it'll also be executed right afterwards, | |
2751 | * effectively extending the old one. | |
2752 | * If there's no minimum time left, just add it to the | |
2753 | * normal list. | |
d339d5ca IP |
2754 | * TODO: the ROC type is ignored here, assuming that it |
2755 | * is better to immediately use the current ROC. | |
2eb278e0 JB |
2756 | */ |
2757 | if (!tmp->hw_begun) { | |
2758 | list_add_tail(&roc->list, &tmp->dependents); | |
2759 | queued = true; | |
2760 | break; | |
2761 | } | |
2762 | ||
2763 | if (time_before(j + IEEE80211_ROC_MIN_LEFT, | |
2764 | tmp->hw_start_time + | |
2765 | msecs_to_jiffies(tmp->duration))) { | |
2766 | int new_dur; | |
2767 | ||
2768 | ieee80211_handle_roc_started(roc); | |
2769 | ||
2770 | new_dur = roc->duration - | |
2771 | jiffies_to_msecs(tmp->hw_start_time + | |
2772 | msecs_to_jiffies( | |
2773 | tmp->duration) - | |
2774 | j); | |
2775 | ||
2776 | if (new_dur > 0) { | |
2777 | /* add right after tmp */ | |
2778 | list_add(&roc->list, &tmp->list); | |
2779 | } else { | |
2780 | list_add_tail(&roc->list, | |
2781 | &tmp->dependents); | |
2782 | } | |
2783 | queued = true; | |
2784 | } | |
2785 | } else if (del_timer_sync(&tmp->work.timer)) { | |
2786 | unsigned long new_end; | |
2787 | ||
2788 | /* | |
2789 | * In the software ROC case, cancel the timer, if | |
2790 | * that fails then the finish work is already | |
2791 | * queued/pending and thus we queue the new ROC | |
2792 | * normally, if that succeeds then we can extend | |
2793 | * the timer duration and TX the frame (if any.) | |
2794 | */ | |
2795 | ||
2796 | list_add_tail(&roc->list, &tmp->dependents); | |
2797 | queued = true; | |
2798 | ||
2799 | new_end = jiffies + msecs_to_jiffies(roc->duration); | |
2800 | ||
2801 | /* ok, it was started & we canceled timer */ | |
2802 | if (time_after(new_end, tmp->work.timer.expires)) | |
2803 | mod_timer(&tmp->work.timer, new_end); | |
2804 | else | |
2805 | add_timer(&tmp->work.timer); | |
2806 | ||
2807 | ieee80211_handle_roc_started(roc); | |
2808 | } | |
2809 | break; | |
2810 | } | |
2811 | ||
2812 | out_queue: | |
2813 | if (!queued) | |
2814 | list_add_tail(&roc->list, &local->roc_list); | |
2815 | ||
2eb278e0 | 2816 | return 0; |
21f83589 JB |
2817 | } |
2818 | ||
b8bc4b0a | 2819 | static int ieee80211_remain_on_channel(struct wiphy *wiphy, |
71bbc994 | 2820 | struct wireless_dev *wdev, |
b8bc4b0a | 2821 | struct ieee80211_channel *chan, |
b8bc4b0a JB |
2822 | unsigned int duration, |
2823 | u64 *cookie) | |
2824 | { | |
71bbc994 | 2825 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
21f83589 | 2826 | struct ieee80211_local *local = sdata->local; |
2eb278e0 | 2827 | int ret; |
21f83589 | 2828 | |
2eb278e0 | 2829 | mutex_lock(&local->mtx); |
42d97a59 | 2830 | ret = ieee80211_start_roc_work(local, sdata, chan, |
d339d5ca IP |
2831 | duration, cookie, NULL, |
2832 | IEEE80211_ROC_TYPE_NORMAL); | |
2eb278e0 | 2833 | mutex_unlock(&local->mtx); |
b8bc4b0a | 2834 | |
2eb278e0 | 2835 | return ret; |
b8bc4b0a JB |
2836 | } |
2837 | ||
2eb278e0 JB |
2838 | static int ieee80211_cancel_roc(struct ieee80211_local *local, |
2839 | u64 cookie, bool mgmt_tx) | |
21f83589 | 2840 | { |
2eb278e0 | 2841 | struct ieee80211_roc_work *roc, *tmp, *found = NULL; |
21f83589 JB |
2842 | int ret; |
2843 | ||
2eb278e0 JB |
2844 | mutex_lock(&local->mtx); |
2845 | list_for_each_entry_safe(roc, tmp, &local->roc_list, list) { | |
e979e33c JB |
2846 | struct ieee80211_roc_work *dep, *tmp2; |
2847 | ||
2848 | list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) { | |
50febf6a | 2849 | if (!mgmt_tx && dep->cookie != cookie) |
e979e33c JB |
2850 | continue; |
2851 | else if (mgmt_tx && dep->mgmt_tx_cookie != cookie) | |
2852 | continue; | |
2853 | /* found dependent item -- just remove it */ | |
2854 | list_del(&dep->list); | |
2855 | mutex_unlock(&local->mtx); | |
2856 | ||
3fbd45ca | 2857 | ieee80211_roc_notify_destroy(dep, true); |
e979e33c JB |
2858 | return 0; |
2859 | } | |
2860 | ||
50febf6a | 2861 | if (!mgmt_tx && roc->cookie != cookie) |
2eb278e0 JB |
2862 | continue; |
2863 | else if (mgmt_tx && roc->mgmt_tx_cookie != cookie) | |
2864 | continue; | |
21f83589 | 2865 | |
2eb278e0 JB |
2866 | found = roc; |
2867 | break; | |
2868 | } | |
21f83589 | 2869 | |
2eb278e0 JB |
2870 | if (!found) { |
2871 | mutex_unlock(&local->mtx); | |
2872 | return -ENOENT; | |
2873 | } | |
21f83589 | 2874 | |
e979e33c JB |
2875 | /* |
2876 | * We found the item to cancel, so do that. Note that it | |
2877 | * may have dependents, which we also cancel (and send | |
2878 | * the expired signal for.) Not doing so would be quite | |
2879 | * tricky here, but we may need to fix it later. | |
2880 | */ | |
2881 | ||
2eb278e0 JB |
2882 | if (local->ops->remain_on_channel) { |
2883 | if (found->started) { | |
2884 | ret = drv_cancel_remain_on_channel(local); | |
2885 | if (WARN_ON_ONCE(ret)) { | |
2886 | mutex_unlock(&local->mtx); | |
2887 | return ret; | |
2888 | } | |
2889 | } | |
21f83589 | 2890 | |
2eb278e0 | 2891 | list_del(&found->list); |
21f83589 | 2892 | |
0f6b3f59 JB |
2893 | if (found->started) |
2894 | ieee80211_start_next_roc(local); | |
2eb278e0 | 2895 | mutex_unlock(&local->mtx); |
21f83589 | 2896 | |
3fbd45ca | 2897 | ieee80211_roc_notify_destroy(found, true); |
2eb278e0 JB |
2898 | } else { |
2899 | /* work may be pending so use it all the time */ | |
2900 | found->abort = true; | |
2901 | ieee80211_queue_delayed_work(&local->hw, &found->work, 0); | |
21f83589 | 2902 | |
21f83589 JB |
2903 | mutex_unlock(&local->mtx); |
2904 | ||
2eb278e0 JB |
2905 | /* work will clean up etc */ |
2906 | flush_delayed_work(&found->work); | |
3fbd45ca JB |
2907 | WARN_ON(!found->to_be_freed); |
2908 | kfree(found); | |
21f83589 | 2909 | } |
b8bc4b0a | 2910 | |
2eb278e0 | 2911 | return 0; |
b8bc4b0a JB |
2912 | } |
2913 | ||
2eb278e0 | 2914 | static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy, |
71bbc994 | 2915 | struct wireless_dev *wdev, |
2eb278e0 | 2916 | u64 cookie) |
f30221e4 | 2917 | { |
71bbc994 | 2918 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
2eb278e0 | 2919 | struct ieee80211_local *local = sdata->local; |
f30221e4 | 2920 | |
2eb278e0 | 2921 | return ieee80211_cancel_roc(local, cookie, false); |
f30221e4 JB |
2922 | } |
2923 | ||
164eb02d SW |
2924 | static int ieee80211_start_radar_detection(struct wiphy *wiphy, |
2925 | struct net_device *dev, | |
31559f35 JD |
2926 | struct cfg80211_chan_def *chandef, |
2927 | u32 cac_time_ms) | |
164eb02d SW |
2928 | { |
2929 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
2930 | struct ieee80211_local *local = sdata->local; | |
164eb02d SW |
2931 | int err; |
2932 | ||
34a3740d JB |
2933 | mutex_lock(&local->mtx); |
2934 | if (!list_empty(&local->roc_list) || local->scanning) { | |
2935 | err = -EBUSY; | |
2936 | goto out_unlock; | |
2937 | } | |
164eb02d SW |
2938 | |
2939 | /* whatever, but channel contexts should not complain about that one */ | |
2940 | sdata->smps_mode = IEEE80211_SMPS_OFF; | |
2941 | sdata->needed_rx_chains = local->rx_chains; | |
164eb02d | 2942 | |
164eb02d SW |
2943 | err = ieee80211_vif_use_channel(sdata, chandef, |
2944 | IEEE80211_CHANCTX_SHARED); | |
164eb02d | 2945 | if (err) |
34a3740d | 2946 | goto out_unlock; |
164eb02d | 2947 | |
164eb02d | 2948 | ieee80211_queue_delayed_work(&sdata->local->hw, |
31559f35 JD |
2949 | &sdata->dfs_cac_timer_work, |
2950 | msecs_to_jiffies(cac_time_ms)); | |
164eb02d | 2951 | |
34a3740d JB |
2952 | out_unlock: |
2953 | mutex_unlock(&local->mtx); | |
2954 | return err; | |
164eb02d SW |
2955 | } |
2956 | ||
73da7d5b SW |
2957 | static struct cfg80211_beacon_data * |
2958 | cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) | |
2959 | { | |
2960 | struct cfg80211_beacon_data *new_beacon; | |
2961 | u8 *pos; | |
2962 | int len; | |
2963 | ||
2964 | len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len + | |
2965 | beacon->proberesp_ies_len + beacon->assocresp_ies_len + | |
2966 | beacon->probe_resp_len; | |
2967 | ||
2968 | new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL); | |
2969 | if (!new_beacon) | |
2970 | return NULL; | |
2971 | ||
2972 | pos = (u8 *)(new_beacon + 1); | |
2973 | if (beacon->head_len) { | |
2974 | new_beacon->head_len = beacon->head_len; | |
2975 | new_beacon->head = pos; | |
2976 | memcpy(pos, beacon->head, beacon->head_len); | |
2977 | pos += beacon->head_len; | |
2978 | } | |
2979 | if (beacon->tail_len) { | |
2980 | new_beacon->tail_len = beacon->tail_len; | |
2981 | new_beacon->tail = pos; | |
2982 | memcpy(pos, beacon->tail, beacon->tail_len); | |
2983 | pos += beacon->tail_len; | |
2984 | } | |
2985 | if (beacon->beacon_ies_len) { | |
2986 | new_beacon->beacon_ies_len = beacon->beacon_ies_len; | |
2987 | new_beacon->beacon_ies = pos; | |
2988 | memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len); | |
2989 | pos += beacon->beacon_ies_len; | |
2990 | } | |
2991 | if (beacon->proberesp_ies_len) { | |
2992 | new_beacon->proberesp_ies_len = beacon->proberesp_ies_len; | |
2993 | new_beacon->proberesp_ies = pos; | |
2994 | memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len); | |
2995 | pos += beacon->proberesp_ies_len; | |
2996 | } | |
2997 | if (beacon->assocresp_ies_len) { | |
2998 | new_beacon->assocresp_ies_len = beacon->assocresp_ies_len; | |
2999 | new_beacon->assocresp_ies = pos; | |
3000 | memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len); | |
3001 | pos += beacon->assocresp_ies_len; | |
3002 | } | |
3003 | if (beacon->probe_resp_len) { | |
3004 | new_beacon->probe_resp_len = beacon->probe_resp_len; | |
3005 | beacon->probe_resp = pos; | |
3006 | memcpy(pos, beacon->probe_resp, beacon->probe_resp_len); | |
3007 | pos += beacon->probe_resp_len; | |
3008 | } | |
3009 | ||
3010 | return new_beacon; | |
3011 | } | |
3012 | ||
66e01cf9 | 3013 | void ieee80211_csa_finish(struct ieee80211_vif *vif) |
73da7d5b | 3014 | { |
66e01cf9 | 3015 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
73da7d5b | 3016 | |
66e01cf9 LC |
3017 | ieee80211_queue_work(&sdata->local->hw, |
3018 | &sdata->csa_finalize_work); | |
3019 | } | |
3020 | EXPORT_SYMBOL(ieee80211_csa_finish); | |
e487eaeb | 3021 | |
66e01cf9 LC |
3022 | static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata) |
3023 | { | |
3024 | struct ieee80211_local *local = sdata->local; | |
3025 | int err, changed = 0; | |
73da7d5b | 3026 | |
dbd72850 MK |
3027 | sdata_assert_lock(sdata); |
3028 | ||
34a3740d | 3029 | mutex_lock(&local->mtx); |
cc901de1 | 3030 | sdata->radar_required = sdata->csa_radar_required; |
33787fc4 | 3031 | err = ieee80211_vif_change_channel(sdata, &changed); |
34a3740d | 3032 | mutex_unlock(&local->mtx); |
73da7d5b | 3033 | if (WARN_ON(err < 0)) |
66e01cf9 | 3034 | return; |
73da7d5b | 3035 | |
7578d575 | 3036 | if (!local->use_chanctx) { |
33787fc4 | 3037 | local->_oper_chandef = sdata->csa_chandef; |
7578d575 AN |
3038 | ieee80211_hw_config(local, 0); |
3039 | } | |
3040 | ||
e487eaeb | 3041 | sdata->vif.csa_active = false; |
cd7760e6 SW |
3042 | switch (sdata->vif.type) { |
3043 | case NL80211_IFTYPE_AP: | |
3044 | err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon); | |
97518af1 MK |
3045 | kfree(sdata->u.ap.next_beacon); |
3046 | sdata->u.ap.next_beacon = NULL; | |
3047 | ||
cd7760e6 | 3048 | if (err < 0) |
66e01cf9 | 3049 | return; |
cd7760e6 | 3050 | changed |= err; |
cd7760e6 SW |
3051 | break; |
3052 | case NL80211_IFTYPE_ADHOC: | |
faf046e7 MK |
3053 | err = ieee80211_ibss_finish_csa(sdata); |
3054 | if (err < 0) | |
3055 | return; | |
3056 | changed |= err; | |
cd7760e6 | 3057 | break; |
b8456a14 CYY |
3058 | #ifdef CONFIG_MAC80211_MESH |
3059 | case NL80211_IFTYPE_MESH_POINT: | |
3060 | err = ieee80211_mesh_finish_csa(sdata); | |
3061 | if (err < 0) | |
66e01cf9 | 3062 | return; |
faf046e7 | 3063 | changed |= err; |
b8456a14 CYY |
3064 | break; |
3065 | #endif | |
cd7760e6 SW |
3066 | default: |
3067 | WARN_ON(1); | |
66e01cf9 | 3068 | return; |
cd7760e6 | 3069 | } |
73da7d5b | 3070 | |
faf046e7 MK |
3071 | ieee80211_bss_info_change_notify(sdata, changed); |
3072 | ||
73da7d5b SW |
3073 | ieee80211_wake_queues_by_reason(&sdata->local->hw, |
3074 | IEEE80211_MAX_QUEUE_MAP, | |
3075 | IEEE80211_QUEUE_STOP_REASON_CSA); | |
3076 | ||
33787fc4 | 3077 | cfg80211_ch_switch_notify(sdata->dev, &sdata->csa_chandef); |
66e01cf9 LC |
3078 | } |
3079 | ||
3080 | void ieee80211_csa_finalize_work(struct work_struct *work) | |
3081 | { | |
3082 | struct ieee80211_sub_if_data *sdata = | |
3083 | container_of(work, struct ieee80211_sub_if_data, | |
3084 | csa_finalize_work); | |
3085 | ||
3086 | sdata_lock(sdata); | |
3087 | /* AP might have been stopped while waiting for the lock. */ | |
3088 | if (!sdata->vif.csa_active) | |
3089 | goto unlock; | |
3090 | ||
3091 | if (!ieee80211_sdata_running(sdata)) | |
3092 | goto unlock; | |
3093 | ||
3094 | ieee80211_csa_finalize(sdata); | |
e487eaeb SW |
3095 | |
3096 | unlock: | |
3097 | sdata_unlock(sdata); | |
73da7d5b SW |
3098 | } |
3099 | ||
37fa2bdd MK |
3100 | static int ieee80211_set_csa_beacon(struct ieee80211_sub_if_data *sdata, |
3101 | struct cfg80211_csa_settings *params, | |
3102 | u32 *changed) | |
73da7d5b | 3103 | { |
37fa2bdd | 3104 | int err; |
73da7d5b | 3105 | |
73da7d5b SW |
3106 | switch (sdata->vif.type) { |
3107 | case NL80211_IFTYPE_AP: | |
cd7760e6 SW |
3108 | sdata->u.ap.next_beacon = |
3109 | cfg80211_beacon_dup(¶ms->beacon_after); | |
3110 | if (!sdata->u.ap.next_beacon) | |
3111 | return -ENOMEM; | |
3112 | ||
66e01cf9 LC |
3113 | /* |
3114 | * With a count of 0, we don't have to wait for any | |
3115 | * TBTT before switching, so complete the CSA | |
3116 | * immediately. In theory, with a count == 1 we | |
3117 | * should delay the switch until just before the next | |
3118 | * TBTT, but that would complicate things so we switch | |
3119 | * immediately too. If we would delay the switch | |
3120 | * until the next TBTT, we would have to set the probe | |
3121 | * response here. | |
3122 | * | |
3123 | * TODO: A channel switch with count <= 1 without | |
3124 | * sending a CSA action frame is kind of useless, | |
3125 | * because the clients won't know we're changing | |
3126 | * channels. The action frame must be implemented | |
3127 | * either here or in the userspace. | |
3128 | */ | |
3129 | if (params->count <= 1) | |
3130 | break; | |
3131 | ||
3132 | sdata->csa_counter_offset_beacon = | |
3133 | params->counter_offset_beacon; | |
3134 | sdata->csa_counter_offset_presp = params->counter_offset_presp; | |
cd7760e6 SW |
3135 | err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa); |
3136 | if (err < 0) { | |
3137 | kfree(sdata->u.ap.next_beacon); | |
3138 | return err; | |
3139 | } | |
37fa2bdd | 3140 | *changed |= err; |
66e01cf9 | 3141 | |
cd7760e6 SW |
3142 | break; |
3143 | case NL80211_IFTYPE_ADHOC: | |
3144 | if (!sdata->vif.bss_conf.ibss_joined) | |
3145 | return -EINVAL; | |
3146 | ||
3147 | if (params->chandef.width != sdata->u.ibss.chandef.width) | |
3148 | return -EINVAL; | |
3149 | ||
3150 | switch (params->chandef.width) { | |
3151 | case NL80211_CHAN_WIDTH_40: | |
3152 | if (cfg80211_get_chandef_type(¶ms->chandef) != | |
3153 | cfg80211_get_chandef_type(&sdata->u.ibss.chandef)) | |
3154 | return -EINVAL; | |
3155 | case NL80211_CHAN_WIDTH_5: | |
3156 | case NL80211_CHAN_WIDTH_10: | |
3157 | case NL80211_CHAN_WIDTH_20_NOHT: | |
3158 | case NL80211_CHAN_WIDTH_20: | |
3159 | break; | |
3160 | default: | |
3161 | return -EINVAL; | |
3162 | } | |
3163 | ||
3164 | /* changes into another band are not supported */ | |
3165 | if (sdata->u.ibss.chandef.chan->band != | |
3166 | params->chandef.chan->band) | |
3167 | return -EINVAL; | |
3168 | ||
66e01cf9 LC |
3169 | /* see comments in the NL80211_IFTYPE_AP block */ |
3170 | if (params->count > 1) { | |
3171 | err = ieee80211_ibss_csa_beacon(sdata, params); | |
3172 | if (err < 0) | |
3173 | return err; | |
37fa2bdd | 3174 | *changed |= err; |
66e01cf9 LC |
3175 | } |
3176 | ||
3177 | ieee80211_send_action_csa(sdata, params); | |
3178 | ||
73da7d5b | 3179 | break; |
c6da674a | 3180 | #ifdef CONFIG_MAC80211_MESH |
37fa2bdd MK |
3181 | case NL80211_IFTYPE_MESH_POINT: { |
3182 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | |
c6da674a | 3183 | |
c6da674a CYY |
3184 | if (params->chandef.width != sdata->vif.bss_conf.chandef.width) |
3185 | return -EINVAL; | |
3186 | ||
3187 | /* changes into another band are not supported */ | |
3188 | if (sdata->vif.bss_conf.chandef.chan->band != | |
3189 | params->chandef.chan->band) | |
3190 | return -EINVAL; | |
3191 | ||
c782bf8c | 3192 | if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_NONE) { |
0cb4d4dc | 3193 | ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_INIT; |
c782bf8c CYY |
3194 | if (!ifmsh->pre_value) |
3195 | ifmsh->pre_value = 1; | |
3196 | else | |
3197 | ifmsh->pre_value++; | |
3198 | } | |
0cb4d4dc | 3199 | |
66e01cf9 LC |
3200 | /* see comments in the NL80211_IFTYPE_AP block */ |
3201 | if (params->count > 1) { | |
3202 | err = ieee80211_mesh_csa_beacon(sdata, params); | |
3203 | if (err < 0) { | |
3204 | ifmsh->csa_role = IEEE80211_MESH_CSA_ROLE_NONE; | |
3205 | return err; | |
3206 | } | |
37fa2bdd | 3207 | *changed |= err; |
3f718fd8 | 3208 | } |
66e01cf9 LC |
3209 | |
3210 | if (ifmsh->csa_role == IEEE80211_MESH_CSA_ROLE_INIT) | |
3211 | ieee80211_send_action_csa(sdata, params); | |
3212 | ||
c6da674a | 3213 | break; |
37fa2bdd | 3214 | } |
c6da674a | 3215 | #endif |
73da7d5b SW |
3216 | default: |
3217 | return -EOPNOTSUPP; | |
3218 | } | |
3219 | ||
37fa2bdd MK |
3220 | return 0; |
3221 | } | |
3222 | ||
3223 | int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, | |
3224 | struct cfg80211_csa_settings *params) | |
3225 | { | |
3226 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3227 | struct ieee80211_local *local = sdata->local; | |
3228 | struct ieee80211_chanctx_conf *chanctx_conf; | |
3229 | struct ieee80211_chanctx *chanctx; | |
3230 | int err, num_chanctx, changed = 0; | |
3231 | ||
3232 | sdata_assert_lock(sdata); | |
3233 | ||
3234 | if (!list_empty(&local->roc_list) || local->scanning) | |
3235 | return -EBUSY; | |
3236 | ||
3237 | if (sdata->wdev.cac_started) | |
3238 | return -EBUSY; | |
3239 | ||
3240 | if (cfg80211_chandef_identical(¶ms->chandef, | |
3241 | &sdata->vif.bss_conf.chandef)) | |
3242 | return -EINVAL; | |
3243 | ||
3244 | rcu_read_lock(); | |
3245 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | |
3246 | if (!chanctx_conf) { | |
3247 | rcu_read_unlock(); | |
3248 | return -EBUSY; | |
3249 | } | |
3250 | ||
3251 | /* don't handle for multi-VIF cases */ | |
3252 | chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf); | |
3253 | if (chanctx->refcount > 1) { | |
3254 | rcu_read_unlock(); | |
3255 | return -EBUSY; | |
3256 | } | |
3257 | num_chanctx = 0; | |
3258 | list_for_each_entry_rcu(chanctx, &local->chanctx_list, list) | |
3259 | num_chanctx++; | |
3260 | rcu_read_unlock(); | |
3261 | ||
3262 | if (num_chanctx > 1) | |
3263 | return -EBUSY; | |
3264 | ||
3265 | /* don't allow another channel switch if one is already active. */ | |
3266 | if (sdata->vif.csa_active) | |
3267 | return -EBUSY; | |
3268 | ||
3269 | err = ieee80211_set_csa_beacon(sdata, params, &changed); | |
3270 | if (err) | |
3271 | return err; | |
3272 | ||
73da7d5b SW |
3273 | sdata->csa_radar_required = params->radar_required; |
3274 | ||
3275 | if (params->block_tx) | |
3276 | ieee80211_stop_queues_by_reason(&local->hw, | |
3277 | IEEE80211_MAX_QUEUE_MAP, | |
3278 | IEEE80211_QUEUE_STOP_REASON_CSA); | |
3279 | ||
33787fc4 | 3280 | sdata->csa_chandef = params->chandef; |
73da7d5b SW |
3281 | sdata->vif.csa_active = true; |
3282 | ||
66e01cf9 LC |
3283 | if (changed) { |
3284 | ieee80211_bss_info_change_notify(sdata, changed); | |
3285 | drv_channel_switch_beacon(sdata, ¶ms->chandef); | |
3286 | } else { | |
3287 | /* if the beacon didn't change, we can finalize immediately */ | |
3288 | ieee80211_csa_finalize(sdata); | |
3289 | } | |
73da7d5b SW |
3290 | |
3291 | return 0; | |
3292 | } | |
3293 | ||
71bbc994 | 3294 | static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
b176e629 AO |
3295 | struct cfg80211_mgmt_tx_params *params, |
3296 | u64 *cookie) | |
026331c4 | 3297 | { |
71bbc994 | 3298 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
9d38d85d JB |
3299 | struct ieee80211_local *local = sdata->local; |
3300 | struct sk_buff *skb; | |
3301 | struct sta_info *sta; | |
b176e629 | 3302 | const struct ieee80211_mgmt *mgmt = (void *)params->buf; |
2eb278e0 | 3303 | bool need_offchan = false; |
e247bd90 | 3304 | u32 flags; |
2eb278e0 | 3305 | int ret; |
f7ca38df | 3306 | |
b176e629 | 3307 | if (params->dont_wait_for_ack) |
e247bd90 JB |
3308 | flags = IEEE80211_TX_CTL_NO_ACK; |
3309 | else | |
3310 | flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | | |
3311 | IEEE80211_TX_CTL_REQ_TX_STATUS; | |
3312 | ||
b176e629 | 3313 | if (params->no_cck) |
aad14ceb RM |
3314 | flags |= IEEE80211_TX_CTL_NO_CCK_RATE; |
3315 | ||
9d38d85d JB |
3316 | switch (sdata->vif.type) { |
3317 | case NL80211_IFTYPE_ADHOC: | |
2eb278e0 JB |
3318 | if (!sdata->vif.bss_conf.ibss_joined) |
3319 | need_offchan = true; | |
3320 | /* fall through */ | |
3321 | #ifdef CONFIG_MAC80211_MESH | |
3322 | case NL80211_IFTYPE_MESH_POINT: | |
3323 | if (ieee80211_vif_is_mesh(&sdata->vif) && | |
3324 | !sdata->u.mesh.mesh_id_len) | |
3325 | need_offchan = true; | |
3326 | /* fall through */ | |
3327 | #endif | |
663fcafd JB |
3328 | case NL80211_IFTYPE_AP: |
3329 | case NL80211_IFTYPE_AP_VLAN: | |
3330 | case NL80211_IFTYPE_P2P_GO: | |
2eb278e0 JB |
3331 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC && |
3332 | !ieee80211_vif_is_mesh(&sdata->vif) && | |
3333 | !rcu_access_pointer(sdata->bss->beacon)) | |
3334 | need_offchan = true; | |
663fcafd | 3335 | if (!ieee80211_is_action(mgmt->frame_control) || |
ac49e1a8 | 3336 | mgmt->u.action.category == WLAN_CATEGORY_PUBLIC || |
cd7760e6 SW |
3337 | mgmt->u.action.category == WLAN_CATEGORY_SELF_PROTECTED || |
3338 | mgmt->u.action.category == WLAN_CATEGORY_SPECTRUM_MGMT) | |
9d38d85d JB |
3339 | break; |
3340 | rcu_read_lock(); | |
3341 | sta = sta_info_get(sdata, mgmt->da); | |
3342 | rcu_read_unlock(); | |
3343 | if (!sta) | |
3344 | return -ENOLINK; | |
3345 | break; | |
3346 | case NL80211_IFTYPE_STATION: | |
663fcafd | 3347 | case NL80211_IFTYPE_P2P_CLIENT: |
2eb278e0 JB |
3348 | if (!sdata->u.mgd.associated) |
3349 | need_offchan = true; | |
9d38d85d | 3350 | break; |
f142c6b9 JB |
3351 | case NL80211_IFTYPE_P2P_DEVICE: |
3352 | need_offchan = true; | |
3353 | break; | |
9d38d85d JB |
3354 | default: |
3355 | return -EOPNOTSUPP; | |
3356 | } | |
3357 | ||
f7aeb6fb AQ |
3358 | /* configurations requiring offchan cannot work if no channel has been |
3359 | * specified | |
3360 | */ | |
b176e629 | 3361 | if (need_offchan && !params->chan) |
f7aeb6fb AQ |
3362 | return -EINVAL; |
3363 | ||
2eb278e0 JB |
3364 | mutex_lock(&local->mtx); |
3365 | ||
3366 | /* Check if the operating channel is the requested channel */ | |
3367 | if (!need_offchan) { | |
55de908a JB |
3368 | struct ieee80211_chanctx_conf *chanctx_conf; |
3369 | ||
3370 | rcu_read_lock(); | |
3371 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | |
3372 | ||
f7aeb6fb | 3373 | if (chanctx_conf) { |
b176e629 AO |
3374 | need_offchan = params->chan && |
3375 | (params->chan != | |
3376 | chanctx_conf->def.chan); | |
3377 | } else if (!params->chan) { | |
f7aeb6fb AQ |
3378 | ret = -EINVAL; |
3379 | rcu_read_unlock(); | |
3380 | goto out_unlock; | |
3381 | } else { | |
2eb278e0 | 3382 | need_offchan = true; |
f7aeb6fb | 3383 | } |
55de908a | 3384 | rcu_read_unlock(); |
2eb278e0 JB |
3385 | } |
3386 | ||
b176e629 | 3387 | if (need_offchan && !params->offchan) { |
2eb278e0 JB |
3388 | ret = -EBUSY; |
3389 | goto out_unlock; | |
3390 | } | |
3391 | ||
b176e629 | 3392 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + params->len); |
2eb278e0 JB |
3393 | if (!skb) { |
3394 | ret = -ENOMEM; | |
3395 | goto out_unlock; | |
3396 | } | |
9d38d85d JB |
3397 | skb_reserve(skb, local->hw.extra_tx_headroom); |
3398 | ||
b176e629 | 3399 | memcpy(skb_put(skb, params->len), params->buf, params->len); |
9d38d85d JB |
3400 | |
3401 | IEEE80211_SKB_CB(skb)->flags = flags; | |
3402 | ||
3403 | skb->dev = sdata->dev; | |
9d38d85d | 3404 | |
2eb278e0 | 3405 | if (!need_offchan) { |
7f9f78ab | 3406 | *cookie = (unsigned long) skb; |
f30221e4 | 3407 | ieee80211_tx_skb(sdata, skb); |
2eb278e0 JB |
3408 | ret = 0; |
3409 | goto out_unlock; | |
f30221e4 JB |
3410 | } |
3411 | ||
6c17b77b SF |
3412 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN | |
3413 | IEEE80211_TX_INTFL_OFFCHAN_TX_OK; | |
2eb278e0 JB |
3414 | if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL) |
3415 | IEEE80211_SKB_CB(skb)->hw_queue = | |
3416 | local->hw.offchannel_tx_hw_queue; | |
f30221e4 | 3417 | |
2eb278e0 | 3418 | /* This will handle all kinds of coalescing and immediate TX */ |
b176e629 AO |
3419 | ret = ieee80211_start_roc_work(local, sdata, params->chan, |
3420 | params->wait, cookie, skb, | |
d339d5ca | 3421 | IEEE80211_ROC_TYPE_MGMT_TX); |
2eb278e0 JB |
3422 | if (ret) |
3423 | kfree_skb(skb); | |
3424 | out_unlock: | |
3425 | mutex_unlock(&local->mtx); | |
3426 | return ret; | |
026331c4 JM |
3427 | } |
3428 | ||
f30221e4 | 3429 | static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy, |
71bbc994 | 3430 | struct wireless_dev *wdev, |
f30221e4 JB |
3431 | u64 cookie) |
3432 | { | |
71bbc994 | 3433 | struct ieee80211_local *local = wiphy_priv(wiphy); |
f30221e4 | 3434 | |
2eb278e0 | 3435 | return ieee80211_cancel_roc(local, cookie, true); |
f30221e4 JB |
3436 | } |
3437 | ||
7be5086d | 3438 | static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, |
71bbc994 | 3439 | struct wireless_dev *wdev, |
7be5086d JB |
3440 | u16 frame_type, bool reg) |
3441 | { | |
3442 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3443 | ||
6abe0563 | 3444 | switch (frame_type) { |
6abe0563 WH |
3445 | case IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ: |
3446 | if (reg) | |
3447 | local->probe_req_reg++; | |
3448 | else | |
3449 | local->probe_req_reg--; | |
7be5086d | 3450 | |
35f5149e FF |
3451 | if (!local->open_count) |
3452 | break; | |
3453 | ||
6abe0563 WH |
3454 | ieee80211_queue_work(&local->hw, &local->reconfig_filter); |
3455 | break; | |
3456 | default: | |
3457 | break; | |
3458 | } | |
7be5086d JB |
3459 | } |
3460 | ||
15d96753 BR |
3461 | static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant) |
3462 | { | |
3463 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3464 | ||
3465 | if (local->started) | |
3466 | return -EOPNOTSUPP; | |
3467 | ||
3468 | return drv_set_antenna(local, tx_ant, rx_ant); | |
3469 | } | |
3470 | ||
3471 | static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant) | |
3472 | { | |
3473 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3474 | ||
3475 | return drv_get_antenna(local, tx_ant, rx_ant); | |
3476 | } | |
3477 | ||
38c09159 JL |
3478 | static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx) |
3479 | { | |
3480 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3481 | ||
3482 | return drv_set_ringparam(local, tx, rx); | |
3483 | } | |
3484 | ||
3485 | static void ieee80211_get_ringparam(struct wiphy *wiphy, | |
3486 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max) | |
3487 | { | |
3488 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3489 | ||
3490 | drv_get_ringparam(local, tx, tx_max, rx, rx_max); | |
3491 | } | |
3492 | ||
c68f4b89 JB |
3493 | static int ieee80211_set_rekey_data(struct wiphy *wiphy, |
3494 | struct net_device *dev, | |
3495 | struct cfg80211_gtk_rekey_data *data) | |
3496 | { | |
3497 | struct ieee80211_local *local = wiphy_priv(wiphy); | |
3498 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3499 | ||
3500 | if (!local->ops->set_rekey_data) | |
3501 | return -EOPNOTSUPP; | |
3502 | ||
3503 | drv_set_rekey_data(local, sdata, data); | |
3504 | ||
3505 | return 0; | |
3506 | } | |
3507 | ||
dfe018bf AN |
3508 | static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb) |
3509 | { | |
3510 | u8 *pos = (void *)skb_put(skb, 7); | |
3511 | ||
3512 | *pos++ = WLAN_EID_EXT_CAPABILITY; | |
3513 | *pos++ = 5; /* len */ | |
3514 | *pos++ = 0x0; | |
3515 | *pos++ = 0x0; | |
3516 | *pos++ = 0x0; | |
3517 | *pos++ = 0x0; | |
3518 | *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED; | |
3519 | } | |
3520 | ||
3521 | static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata) | |
3522 | { | |
3523 | struct ieee80211_local *local = sdata->local; | |
3524 | u16 capab; | |
3525 | ||
3526 | capab = 0; | |
55de908a | 3527 | if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ) |
dfe018bf AN |
3528 | return capab; |
3529 | ||
3530 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) | |
3531 | capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME; | |
3532 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE)) | |
3533 | capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; | |
3534 | ||
3535 | return capab; | |
3536 | } | |
3537 | ||
3538 | static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr, | |
3539 | u8 *peer, u8 *bssid) | |
3540 | { | |
3541 | struct ieee80211_tdls_lnkie *lnkid; | |
3542 | ||
3543 | lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie)); | |
3544 | ||
3545 | lnkid->ie_type = WLAN_EID_LINK_ID; | |
3546 | lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2; | |
3547 | ||
3548 | memcpy(lnkid->bssid, bssid, ETH_ALEN); | |
3549 | memcpy(lnkid->init_sta, src_addr, ETH_ALEN); | |
3550 | memcpy(lnkid->resp_sta, peer, ETH_ALEN); | |
3551 | } | |
3552 | ||
3553 | static int | |
3554 | ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, | |
3555 | u8 *peer, u8 action_code, u8 dialog_token, | |
3556 | u16 status_code, struct sk_buff *skb) | |
3557 | { | |
3558 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
55de908a | 3559 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
dfe018bf AN |
3560 | struct ieee80211_tdls_data *tf; |
3561 | ||
3562 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); | |
3563 | ||
3564 | memcpy(tf->da, peer, ETH_ALEN); | |
3565 | memcpy(tf->sa, sdata->vif.addr, ETH_ALEN); | |
3566 | tf->ether_type = cpu_to_be16(ETH_P_TDLS); | |
3567 | tf->payload_type = WLAN_TDLS_SNAP_RFTYPE; | |
3568 | ||
3569 | switch (action_code) { | |
3570 | case WLAN_TDLS_SETUP_REQUEST: | |
3571 | tf->category = WLAN_CATEGORY_TDLS; | |
3572 | tf->action_code = WLAN_TDLS_SETUP_REQUEST; | |
3573 | ||
3574 | skb_put(skb, sizeof(tf->u.setup_req)); | |
3575 | tf->u.setup_req.dialog_token = dialog_token; | |
3576 | tf->u.setup_req.capability = | |
3577 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | |
3578 | ||
55de908a JB |
3579 | ieee80211_add_srates_ie(sdata, skb, false, band); |
3580 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | |
dfe018bf AN |
3581 | ieee80211_tdls_add_ext_capab(skb); |
3582 | break; | |
3583 | case WLAN_TDLS_SETUP_RESPONSE: | |
3584 | tf->category = WLAN_CATEGORY_TDLS; | |
3585 | tf->action_code = WLAN_TDLS_SETUP_RESPONSE; | |
3586 | ||
3587 | skb_put(skb, sizeof(tf->u.setup_resp)); | |
3588 | tf->u.setup_resp.status_code = cpu_to_le16(status_code); | |
3589 | tf->u.setup_resp.dialog_token = dialog_token; | |
3590 | tf->u.setup_resp.capability = | |
3591 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | |
3592 | ||
55de908a JB |
3593 | ieee80211_add_srates_ie(sdata, skb, false, band); |
3594 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | |
dfe018bf AN |
3595 | ieee80211_tdls_add_ext_capab(skb); |
3596 | break; | |
3597 | case WLAN_TDLS_SETUP_CONFIRM: | |
3598 | tf->category = WLAN_CATEGORY_TDLS; | |
3599 | tf->action_code = WLAN_TDLS_SETUP_CONFIRM; | |
3600 | ||
3601 | skb_put(skb, sizeof(tf->u.setup_cfm)); | |
3602 | tf->u.setup_cfm.status_code = cpu_to_le16(status_code); | |
3603 | tf->u.setup_cfm.dialog_token = dialog_token; | |
3604 | break; | |
3605 | case WLAN_TDLS_TEARDOWN: | |
3606 | tf->category = WLAN_CATEGORY_TDLS; | |
3607 | tf->action_code = WLAN_TDLS_TEARDOWN; | |
3608 | ||
3609 | skb_put(skb, sizeof(tf->u.teardown)); | |
3610 | tf->u.teardown.reason_code = cpu_to_le16(status_code); | |
3611 | break; | |
3612 | case WLAN_TDLS_DISCOVERY_REQUEST: | |
3613 | tf->category = WLAN_CATEGORY_TDLS; | |
3614 | tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST; | |
3615 | ||
3616 | skb_put(skb, sizeof(tf->u.discover_req)); | |
3617 | tf->u.discover_req.dialog_token = dialog_token; | |
3618 | break; | |
3619 | default: | |
3620 | return -EINVAL; | |
3621 | } | |
3622 | ||
3623 | return 0; | |
3624 | } | |
3625 | ||
3626 | static int | |
3627 | ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, | |
3628 | u8 *peer, u8 action_code, u8 dialog_token, | |
3629 | u16 status_code, struct sk_buff *skb) | |
3630 | { | |
3631 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
55de908a | 3632 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
dfe018bf AN |
3633 | struct ieee80211_mgmt *mgmt; |
3634 | ||
3635 | mgmt = (void *)skb_put(skb, 24); | |
3636 | memset(mgmt, 0, 24); | |
3637 | memcpy(mgmt->da, peer, ETH_ALEN); | |
3638 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); | |
3639 | memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); | |
3640 | ||
3641 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | | |
3642 | IEEE80211_STYPE_ACTION); | |
3643 | ||
3644 | switch (action_code) { | |
3645 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | |
3646 | skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp)); | |
3647 | mgmt->u.action.category = WLAN_CATEGORY_PUBLIC; | |
3648 | mgmt->u.action.u.tdls_discover_resp.action_code = | |
3649 | WLAN_PUB_ACTION_TDLS_DISCOVER_RES; | |
3650 | mgmt->u.action.u.tdls_discover_resp.dialog_token = | |
3651 | dialog_token; | |
3652 | mgmt->u.action.u.tdls_discover_resp.capability = | |
3653 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | |
3654 | ||
55de908a JB |
3655 | ieee80211_add_srates_ie(sdata, skb, false, band); |
3656 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); | |
dfe018bf AN |
3657 | ieee80211_tdls_add_ext_capab(skb); |
3658 | break; | |
3659 | default: | |
3660 | return -EINVAL; | |
3661 | } | |
3662 | ||
3663 | return 0; | |
3664 | } | |
3665 | ||
3666 | static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, | |
3667 | u8 *peer, u8 action_code, u8 dialog_token, | |
df942e7b SDU |
3668 | u16 status_code, u32 peer_capability, |
3669 | const u8 *extra_ies, size_t extra_ies_len) | |
dfe018bf AN |
3670 | { |
3671 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3672 | struct ieee80211_local *local = sdata->local; | |
dfe018bf AN |
3673 | struct sk_buff *skb = NULL; |
3674 | bool send_direct; | |
3675 | int ret; | |
3676 | ||
3677 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) | |
3678 | return -ENOTSUPP; | |
3679 | ||
3680 | /* make sure we are in managed mode, and associated */ | |
3681 | if (sdata->vif.type != NL80211_IFTYPE_STATION || | |
3682 | !sdata->u.mgd.associated) | |
3683 | return -EINVAL; | |
3684 | ||
bdcbd8e0 JB |
3685 | tdls_dbg(sdata, "TDLS mgmt action %d peer %pM\n", |
3686 | action_code, peer); | |
dfe018bf AN |
3687 | |
3688 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + | |
3689 | max(sizeof(struct ieee80211_mgmt), | |
3690 | sizeof(struct ieee80211_tdls_data)) + | |
3691 | 50 + /* supported rates */ | |
3692 | 7 + /* ext capab */ | |
3693 | extra_ies_len + | |
3694 | sizeof(struct ieee80211_tdls_lnkie)); | |
3695 | if (!skb) | |
3696 | return -ENOMEM; | |
3697 | ||
dfe018bf AN |
3698 | skb_reserve(skb, local->hw.extra_tx_headroom); |
3699 | ||
3700 | switch (action_code) { | |
3701 | case WLAN_TDLS_SETUP_REQUEST: | |
3702 | case WLAN_TDLS_SETUP_RESPONSE: | |
3703 | case WLAN_TDLS_SETUP_CONFIRM: | |
3704 | case WLAN_TDLS_TEARDOWN: | |
3705 | case WLAN_TDLS_DISCOVERY_REQUEST: | |
3706 | ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer, | |
3707 | action_code, dialog_token, | |
3708 | status_code, skb); | |
3709 | send_direct = false; | |
3710 | break; | |
3711 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | |
3712 | ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code, | |
3713 | dialog_token, status_code, | |
3714 | skb); | |
3715 | send_direct = true; | |
3716 | break; | |
3717 | default: | |
3718 | ret = -ENOTSUPP; | |
3719 | break; | |
3720 | } | |
3721 | ||
3722 | if (ret < 0) | |
3723 | goto fail; | |
3724 | ||
3725 | if (extra_ies_len) | |
3726 | memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len); | |
3727 | ||
3728 | /* the TDLS link IE is always added last */ | |
3729 | switch (action_code) { | |
3730 | case WLAN_TDLS_SETUP_REQUEST: | |
3731 | case WLAN_TDLS_SETUP_CONFIRM: | |
3732 | case WLAN_TDLS_TEARDOWN: | |
3733 | case WLAN_TDLS_DISCOVERY_REQUEST: | |
3734 | /* we are the initiator */ | |
3735 | ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer, | |
3736 | sdata->u.mgd.bssid); | |
3737 | break; | |
3738 | case WLAN_TDLS_SETUP_RESPONSE: | |
3739 | case WLAN_PUB_ACTION_TDLS_DISCOVER_RES: | |
3740 | /* we are the responder */ | |
3741 | ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr, | |
3742 | sdata->u.mgd.bssid); | |
3743 | break; | |
3744 | default: | |
3745 | ret = -ENOTSUPP; | |
3746 | goto fail; | |
3747 | } | |
3748 | ||
3749 | if (send_direct) { | |
3750 | ieee80211_tx_skb(sdata, skb); | |
3751 | return 0; | |
3752 | } | |
3753 | ||
3754 | /* | |
3755 | * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise | |
3756 | * we should default to AC_VI. | |
3757 | */ | |
3758 | switch (action_code) { | |
3759 | case WLAN_TDLS_SETUP_REQUEST: | |
3760 | case WLAN_TDLS_SETUP_RESPONSE: | |
3761 | skb_set_queue_mapping(skb, IEEE80211_AC_BK); | |
3762 | skb->priority = 2; | |
3763 | break; | |
3764 | default: | |
3765 | skb_set_queue_mapping(skb, IEEE80211_AC_VI); | |
3766 | skb->priority = 5; | |
3767 | break; | |
3768 | } | |
3769 | ||
3770 | /* disable bottom halves when entering the Tx path */ | |
3771 | local_bh_disable(); | |
3772 | ret = ieee80211_subif_start_xmit(skb, dev); | |
3773 | local_bh_enable(); | |
3774 | ||
3775 | return ret; | |
3776 | ||
3777 | fail: | |
3778 | dev_kfree_skb(skb); | |
3779 | return ret; | |
3780 | } | |
3781 | ||
3782 | static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, | |
3783 | u8 *peer, enum nl80211_tdls_operation oper) | |
3784 | { | |
941c93cd | 3785 | struct sta_info *sta; |
dfe018bf AN |
3786 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
3787 | ||
3788 | if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS)) | |
3789 | return -ENOTSUPP; | |
3790 | ||
3791 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | |
3792 | return -EINVAL; | |
3793 | ||
bdcbd8e0 | 3794 | tdls_dbg(sdata, "TDLS oper %d peer %pM\n", oper, peer); |
dfe018bf AN |
3795 | |
3796 | switch (oper) { | |
3797 | case NL80211_TDLS_ENABLE_LINK: | |
941c93cd AN |
3798 | rcu_read_lock(); |
3799 | sta = sta_info_get(sdata, peer); | |
3800 | if (!sta) { | |
3801 | rcu_read_unlock(); | |
3802 | return -ENOLINK; | |
3803 | } | |
3804 | ||
c2c98fde | 3805 | set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH); |
941c93cd | 3806 | rcu_read_unlock(); |
dfe018bf AN |
3807 | break; |
3808 | case NL80211_TDLS_DISABLE_LINK: | |
3809 | return sta_info_destroy_addr(sdata, peer); | |
3810 | case NL80211_TDLS_TEARDOWN: | |
3811 | case NL80211_TDLS_SETUP: | |
3812 | case NL80211_TDLS_DISCOVERY_REQ: | |
3813 | /* We don't support in-driver setup/teardown/discovery */ | |
3814 | return -ENOTSUPP; | |
3815 | default: | |
3816 | return -ENOTSUPP; | |
3817 | } | |
3818 | ||
3819 | return 0; | |
3820 | } | |
3821 | ||
06500736 JB |
3822 | static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, |
3823 | const u8 *peer, u64 *cookie) | |
3824 | { | |
3825 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3826 | struct ieee80211_local *local = sdata->local; | |
3827 | struct ieee80211_qos_hdr *nullfunc; | |
3828 | struct sk_buff *skb; | |
3829 | int size = sizeof(*nullfunc); | |
3830 | __le16 fc; | |
3831 | bool qos; | |
3832 | struct ieee80211_tx_info *info; | |
3833 | struct sta_info *sta; | |
55de908a JB |
3834 | struct ieee80211_chanctx_conf *chanctx_conf; |
3835 | enum ieee80211_band band; | |
06500736 JB |
3836 | |
3837 | rcu_read_lock(); | |
55de908a JB |
3838 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
3839 | if (WARN_ON(!chanctx_conf)) { | |
3840 | rcu_read_unlock(); | |
3841 | return -EINVAL; | |
3842 | } | |
4bf88530 | 3843 | band = chanctx_conf->def.chan->band; |
03bb7f42 | 3844 | sta = sta_info_get_bss(sdata, peer); |
b4487c2d | 3845 | if (sta) { |
06500736 | 3846 | qos = test_sta_flag(sta, WLAN_STA_WME); |
b4487c2d JB |
3847 | } else { |
3848 | rcu_read_unlock(); | |
06500736 | 3849 | return -ENOLINK; |
b4487c2d | 3850 | } |
06500736 JB |
3851 | |
3852 | if (qos) { | |
3853 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | | |
3854 | IEEE80211_STYPE_QOS_NULLFUNC | | |
3855 | IEEE80211_FCTL_FROMDS); | |
3856 | } else { | |
3857 | size -= 2; | |
3858 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | | |
3859 | IEEE80211_STYPE_NULLFUNC | | |
3860 | IEEE80211_FCTL_FROMDS); | |
3861 | } | |
3862 | ||
3863 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); | |
55de908a JB |
3864 | if (!skb) { |
3865 | rcu_read_unlock(); | |
06500736 | 3866 | return -ENOMEM; |
55de908a | 3867 | } |
06500736 JB |
3868 | |
3869 | skb->dev = dev; | |
3870 | ||
3871 | skb_reserve(skb, local->hw.extra_tx_headroom); | |
3872 | ||
3873 | nullfunc = (void *) skb_put(skb, size); | |
3874 | nullfunc->frame_control = fc; | |
3875 | nullfunc->duration_id = 0; | |
3876 | memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); | |
3877 | memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); | |
3878 | memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); | |
3879 | nullfunc->seq_ctrl = 0; | |
3880 | ||
3881 | info = IEEE80211_SKB_CB(skb); | |
3882 | ||
3883 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | | |
3884 | IEEE80211_TX_INTFL_NL80211_FRAME_TX; | |
3885 | ||
3886 | skb_set_queue_mapping(skb, IEEE80211_AC_VO); | |
3887 | skb->priority = 7; | |
3888 | if (qos) | |
3889 | nullfunc->qos_ctrl = cpu_to_le16(7); | |
3890 | ||
3891 | local_bh_disable(); | |
55de908a | 3892 | ieee80211_xmit(sdata, skb, band); |
06500736 | 3893 | local_bh_enable(); |
55de908a | 3894 | rcu_read_unlock(); |
06500736 JB |
3895 | |
3896 | *cookie = (unsigned long) skb; | |
3897 | return 0; | |
3898 | } | |
3899 | ||
683b6d3b JB |
3900 | static int ieee80211_cfg_get_channel(struct wiphy *wiphy, |
3901 | struct wireless_dev *wdev, | |
3902 | struct cfg80211_chan_def *chandef) | |
5b7ccaf3 | 3903 | { |
55de908a | 3904 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
cb601ffa | 3905 | struct ieee80211_local *local = wiphy_priv(wiphy); |
55de908a | 3906 | struct ieee80211_chanctx_conf *chanctx_conf; |
683b6d3b | 3907 | int ret = -ENODATA; |
55de908a JB |
3908 | |
3909 | rcu_read_lock(); | |
feda3027 JB |
3910 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
3911 | if (chanctx_conf) { | |
3912 | *chandef = chanctx_conf->def; | |
3913 | ret = 0; | |
3914 | } else if (local->open_count > 0 && | |
3915 | local->open_count == local->monitors && | |
3916 | sdata->vif.type == NL80211_IFTYPE_MONITOR) { | |
3917 | if (local->use_chanctx) | |
3918 | *chandef = local->monitor_chandef; | |
3919 | else | |
675a0b04 | 3920 | *chandef = local->_oper_chandef; |
683b6d3b | 3921 | ret = 0; |
55de908a JB |
3922 | } |
3923 | rcu_read_unlock(); | |
5b7ccaf3 | 3924 | |
683b6d3b | 3925 | return ret; |
5b7ccaf3 JB |
3926 | } |
3927 | ||
6d52563f JB |
3928 | #ifdef CONFIG_PM |
3929 | static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled) | |
3930 | { | |
3931 | drv_set_wakeup(wiphy_priv(wiphy), enabled); | |
3932 | } | |
3933 | #endif | |
3934 | ||
32db6b54 KP |
3935 | static int ieee80211_set_qos_map(struct wiphy *wiphy, |
3936 | struct net_device *dev, | |
3937 | struct cfg80211_qos_map *qos_map) | |
3938 | { | |
3939 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
3940 | struct mac80211_qos_map *new_qos_map, *old_qos_map; | |
3941 | ||
3942 | if (qos_map) { | |
3943 | new_qos_map = kzalloc(sizeof(*new_qos_map), GFP_KERNEL); | |
3944 | if (!new_qos_map) | |
3945 | return -ENOMEM; | |
3946 | memcpy(&new_qos_map->qos_map, qos_map, sizeof(*qos_map)); | |
3947 | } else { | |
3948 | /* A NULL qos_map was passed to disable QoS mapping */ | |
3949 | new_qos_map = NULL; | |
3950 | } | |
3951 | ||
194ff52d | 3952 | old_qos_map = sdata_dereference(sdata->qos_map, sdata); |
32db6b54 KP |
3953 | rcu_assign_pointer(sdata->qos_map, new_qos_map); |
3954 | if (old_qos_map) | |
3955 | kfree_rcu(old_qos_map, rcu_head); | |
3956 | ||
3957 | return 0; | |
3958 | } | |
3959 | ||
8a47cea7 | 3960 | const struct cfg80211_ops mac80211_config_ops = { |
f0706e82 JB |
3961 | .add_virtual_intf = ieee80211_add_iface, |
3962 | .del_virtual_intf = ieee80211_del_iface, | |
42613db7 | 3963 | .change_virtual_intf = ieee80211_change_iface, |
f142c6b9 JB |
3964 | .start_p2p_device = ieee80211_start_p2p_device, |
3965 | .stop_p2p_device = ieee80211_stop_p2p_device, | |
e8cbb4cb JB |
3966 | .add_key = ieee80211_add_key, |
3967 | .del_key = ieee80211_del_key, | |
62da92fb | 3968 | .get_key = ieee80211_get_key, |
e8cbb4cb | 3969 | .set_default_key = ieee80211_config_default_key, |
3cfcf6ac | 3970 | .set_default_mgmt_key = ieee80211_config_default_mgmt_key, |
8860020e JB |
3971 | .start_ap = ieee80211_start_ap, |
3972 | .change_beacon = ieee80211_change_beacon, | |
3973 | .stop_ap = ieee80211_stop_ap, | |
4fd6931e JB |
3974 | .add_station = ieee80211_add_station, |
3975 | .del_station = ieee80211_del_station, | |
3976 | .change_station = ieee80211_change_station, | |
7bbdd2d9 | 3977 | .get_station = ieee80211_get_station, |
c5dd9c2b | 3978 | .dump_station = ieee80211_dump_station, |
1289723e | 3979 | .dump_survey = ieee80211_dump_survey, |
c5dd9c2b LCC |
3980 | #ifdef CONFIG_MAC80211_MESH |
3981 | .add_mpath = ieee80211_add_mpath, | |
3982 | .del_mpath = ieee80211_del_mpath, | |
3983 | .change_mpath = ieee80211_change_mpath, | |
3984 | .get_mpath = ieee80211_get_mpath, | |
3985 | .dump_mpath = ieee80211_dump_mpath, | |
24bdd9f4 JC |
3986 | .update_mesh_config = ieee80211_update_mesh_config, |
3987 | .get_mesh_config = ieee80211_get_mesh_config, | |
29cbe68c JB |
3988 | .join_mesh = ieee80211_join_mesh, |
3989 | .leave_mesh = ieee80211_leave_mesh, | |
c5dd9c2b | 3990 | #endif |
9f1ba906 | 3991 | .change_bss = ieee80211_change_bss, |
31888487 | 3992 | .set_txq_params = ieee80211_set_txq_params, |
e8c9bd5b | 3993 | .set_monitor_channel = ieee80211_set_monitor_channel, |
665af4fc BC |
3994 | .suspend = ieee80211_suspend, |
3995 | .resume = ieee80211_resume, | |
2a519311 | 3996 | .scan = ieee80211_scan, |
79f460ca LC |
3997 | .sched_scan_start = ieee80211_sched_scan_start, |
3998 | .sched_scan_stop = ieee80211_sched_scan_stop, | |
636a5d36 JM |
3999 | .auth = ieee80211_auth, |
4000 | .assoc = ieee80211_assoc, | |
4001 | .deauth = ieee80211_deauth, | |
4002 | .disassoc = ieee80211_disassoc, | |
af8cdcd8 JB |
4003 | .join_ibss = ieee80211_join_ibss, |
4004 | .leave_ibss = ieee80211_leave_ibss, | |
391e53e3 | 4005 | .set_mcast_rate = ieee80211_set_mcast_rate, |
b9a5f8ca | 4006 | .set_wiphy_params = ieee80211_set_wiphy_params, |
7643a2c3 JB |
4007 | .set_tx_power = ieee80211_set_tx_power, |
4008 | .get_tx_power = ieee80211_get_tx_power, | |
ab737a4f | 4009 | .set_wds_peer = ieee80211_set_wds_peer, |
1f87f7d3 | 4010 | .rfkill_poll = ieee80211_rfkill_poll, |
aff89a9b | 4011 | CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd) |
71063f0e | 4012 | CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump) |
bc92afd9 | 4013 | .set_power_mgmt = ieee80211_set_power_mgmt, |
9930380f | 4014 | .set_bitrate_mask = ieee80211_set_bitrate_mask, |
b8bc4b0a JB |
4015 | .remain_on_channel = ieee80211_remain_on_channel, |
4016 | .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel, | |
2e161f78 | 4017 | .mgmt_tx = ieee80211_mgmt_tx, |
f30221e4 | 4018 | .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait, |
a97c13c3 | 4019 | .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config, |
7be5086d | 4020 | .mgmt_frame_register = ieee80211_mgmt_frame_register, |
15d96753 BR |
4021 | .set_antenna = ieee80211_set_antenna, |
4022 | .get_antenna = ieee80211_get_antenna, | |
38c09159 JL |
4023 | .set_ringparam = ieee80211_set_ringparam, |
4024 | .get_ringparam = ieee80211_get_ringparam, | |
c68f4b89 | 4025 | .set_rekey_data = ieee80211_set_rekey_data, |
dfe018bf AN |
4026 | .tdls_oper = ieee80211_tdls_oper, |
4027 | .tdls_mgmt = ieee80211_tdls_mgmt, | |
06500736 | 4028 | .probe_client = ieee80211_probe_client, |
b53be792 | 4029 | .set_noack_map = ieee80211_set_noack_map, |
6d52563f JB |
4030 | #ifdef CONFIG_PM |
4031 | .set_wakeup = ieee80211_set_wakeup, | |
4032 | #endif | |
b1ab7925 BG |
4033 | .get_et_sset_count = ieee80211_get_et_sset_count, |
4034 | .get_et_stats = ieee80211_get_et_stats, | |
4035 | .get_et_strings = ieee80211_get_et_strings, | |
5b7ccaf3 | 4036 | .get_channel = ieee80211_cfg_get_channel, |
164eb02d | 4037 | .start_radar_detection = ieee80211_start_radar_detection, |
73da7d5b | 4038 | .channel_switch = ieee80211_channel_switch, |
32db6b54 | 4039 | .set_qos_map = ieee80211_set_qos_map, |
f0706e82 | 4040 | }; |