mac80211: handle TDLS high-level commands and frames
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / mac80211 / cfg.c
1 /*
2 * mac80211 configuration hooks for cfg80211
3 *
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * This file is GPLv2 as found in COPYING.
7 */
8
9 #include <linux/ieee80211.h>
10 #include <linux/nl80211.h>
11 #include <linux/rtnetlink.h>
12 #include <linux/slab.h>
13 #include <net/net_namespace.h>
14 #include <linux/rcupdate.h>
15 #include <linux/if_ether.h>
16 #include <net/cfg80211.h>
17 #include "ieee80211_i.h"
18 #include "driver-ops.h"
19 #include "cfg.h"
20 #include "rate.h"
21 #include "mesh.h"
22
23 static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name,
24 enum nl80211_iftype type,
25 u32 *flags,
26 struct vif_params *params)
27 {
28 struct ieee80211_local *local = wiphy_priv(wiphy);
29 struct net_device *dev;
30 struct ieee80211_sub_if_data *sdata;
31 int err;
32
33 err = ieee80211_if_add(local, name, &dev, type, params);
34 if (err)
35 return ERR_PTR(err);
36
37 if (type == NL80211_IFTYPE_MONITOR && flags) {
38 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
39 sdata->u.mntr_flags = *flags;
40 }
41
42 return dev;
43 }
44
45 static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev)
46 {
47 ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev));
48
49 return 0;
50 }
51
52 static int ieee80211_change_iface(struct wiphy *wiphy,
53 struct net_device *dev,
54 enum nl80211_iftype type, u32 *flags,
55 struct vif_params *params)
56 {
57 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
58 int ret;
59
60 ret = ieee80211_if_change_type(sdata, type);
61 if (ret)
62 return ret;
63
64 if (type == NL80211_IFTYPE_AP_VLAN &&
65 params && params->use_4addr == 0)
66 rcu_assign_pointer(sdata->u.vlan.sta, NULL);
67 else if (type == NL80211_IFTYPE_STATION &&
68 params && params->use_4addr >= 0)
69 sdata->u.mgd.use_4addr = params->use_4addr;
70
71 if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
72 struct ieee80211_local *local = sdata->local;
73
74 if (ieee80211_sdata_running(sdata)) {
75 /*
76 * Prohibit MONITOR_FLAG_COOK_FRAMES to be
77 * changed while the interface is up.
78 * Else we would need to add a lot of cruft
79 * to update everything:
80 * cooked_mntrs, monitor and all fif_* counters
81 * reconfigure hardware
82 */
83 if ((*flags & MONITOR_FLAG_COOK_FRAMES) !=
84 (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
85 return -EBUSY;
86
87 ieee80211_adjust_monitor_flags(sdata, -1);
88 sdata->u.mntr_flags = *flags;
89 ieee80211_adjust_monitor_flags(sdata, 1);
90
91 ieee80211_configure_filter(local);
92 } else {
93 /*
94 * Because the interface is down, ieee80211_do_stop
95 * and ieee80211_do_open take care of "everything"
96 * mentioned in the comment above.
97 */
98 sdata->u.mntr_flags = *flags;
99 }
100 }
101
102 return 0;
103 }
104
105 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
106 u8 key_idx, bool pairwise, const u8 *mac_addr,
107 struct key_params *params)
108 {
109 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
110 struct sta_info *sta = NULL;
111 struct ieee80211_key *key;
112 int err;
113
114 if (!ieee80211_sdata_running(sdata))
115 return -ENETDOWN;
116
117 /* reject WEP and TKIP keys if WEP failed to initialize */
118 switch (params->cipher) {
119 case WLAN_CIPHER_SUITE_WEP40:
120 case WLAN_CIPHER_SUITE_TKIP:
121 case WLAN_CIPHER_SUITE_WEP104:
122 if (IS_ERR(sdata->local->wep_tx_tfm))
123 return -EINVAL;
124 break;
125 default:
126 break;
127 }
128
129 key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
130 params->key, params->seq_len, params->seq);
131 if (IS_ERR(key))
132 return PTR_ERR(key);
133
134 if (pairwise)
135 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
136
137 mutex_lock(&sdata->local->sta_mtx);
138
139 if (mac_addr) {
140 if (ieee80211_vif_is_mesh(&sdata->vif))
141 sta = sta_info_get(sdata, mac_addr);
142 else
143 sta = sta_info_get_bss(sdata, mac_addr);
144 if (!sta) {
145 ieee80211_key_free(sdata->local, key);
146 err = -ENOENT;
147 goto out_unlock;
148 }
149 }
150
151 err = ieee80211_key_link(key, sdata, sta);
152 if (err)
153 ieee80211_key_free(sdata->local, key);
154
155 out_unlock:
156 mutex_unlock(&sdata->local->sta_mtx);
157
158 return err;
159 }
160
161 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
162 u8 key_idx, bool pairwise, const u8 *mac_addr)
163 {
164 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
165 struct ieee80211_local *local = sdata->local;
166 struct sta_info *sta;
167 struct ieee80211_key *key = NULL;
168 int ret;
169
170 mutex_lock(&local->sta_mtx);
171 mutex_lock(&local->key_mtx);
172
173 if (mac_addr) {
174 ret = -ENOENT;
175
176 sta = sta_info_get_bss(sdata, mac_addr);
177 if (!sta)
178 goto out_unlock;
179
180 if (pairwise)
181 key = key_mtx_dereference(local, sta->ptk);
182 else
183 key = key_mtx_dereference(local, sta->gtk[key_idx]);
184 } else
185 key = key_mtx_dereference(local, sdata->keys[key_idx]);
186
187 if (!key) {
188 ret = -ENOENT;
189 goto out_unlock;
190 }
191
192 __ieee80211_key_free(key);
193
194 ret = 0;
195 out_unlock:
196 mutex_unlock(&local->key_mtx);
197 mutex_unlock(&local->sta_mtx);
198
199 return ret;
200 }
201
202 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
203 u8 key_idx, bool pairwise, const u8 *mac_addr,
204 void *cookie,
205 void (*callback)(void *cookie,
206 struct key_params *params))
207 {
208 struct ieee80211_sub_if_data *sdata;
209 struct sta_info *sta = NULL;
210 u8 seq[6] = {0};
211 struct key_params params;
212 struct ieee80211_key *key = NULL;
213 u64 pn64;
214 u32 iv32;
215 u16 iv16;
216 int err = -ENOENT;
217
218 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
219
220 rcu_read_lock();
221
222 if (mac_addr) {
223 sta = sta_info_get_bss(sdata, mac_addr);
224 if (!sta)
225 goto out;
226
227 if (pairwise)
228 key = rcu_dereference(sta->ptk);
229 else if (key_idx < NUM_DEFAULT_KEYS)
230 key = rcu_dereference(sta->gtk[key_idx]);
231 } else
232 key = rcu_dereference(sdata->keys[key_idx]);
233
234 if (!key)
235 goto out;
236
237 memset(&params, 0, sizeof(params));
238
239 params.cipher = key->conf.cipher;
240
241 switch (key->conf.cipher) {
242 case WLAN_CIPHER_SUITE_TKIP:
243 iv32 = key->u.tkip.tx.iv32;
244 iv16 = key->u.tkip.tx.iv16;
245
246 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
247 drv_get_tkip_seq(sdata->local,
248 key->conf.hw_key_idx,
249 &iv32, &iv16);
250
251 seq[0] = iv16 & 0xff;
252 seq[1] = (iv16 >> 8) & 0xff;
253 seq[2] = iv32 & 0xff;
254 seq[3] = (iv32 >> 8) & 0xff;
255 seq[4] = (iv32 >> 16) & 0xff;
256 seq[5] = (iv32 >> 24) & 0xff;
257 params.seq = seq;
258 params.seq_len = 6;
259 break;
260 case WLAN_CIPHER_SUITE_CCMP:
261 pn64 = atomic64_read(&key->u.ccmp.tx_pn);
262 seq[0] = pn64;
263 seq[1] = pn64 >> 8;
264 seq[2] = pn64 >> 16;
265 seq[3] = pn64 >> 24;
266 seq[4] = pn64 >> 32;
267 seq[5] = pn64 >> 40;
268 params.seq = seq;
269 params.seq_len = 6;
270 break;
271 case WLAN_CIPHER_SUITE_AES_CMAC:
272 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
273 seq[0] = pn64;
274 seq[1] = pn64 >> 8;
275 seq[2] = pn64 >> 16;
276 seq[3] = pn64 >> 24;
277 seq[4] = pn64 >> 32;
278 seq[5] = pn64 >> 40;
279 params.seq = seq;
280 params.seq_len = 6;
281 break;
282 }
283
284 params.key = key->conf.key;
285 params.key_len = key->conf.keylen;
286
287 callback(cookie, &params);
288 err = 0;
289
290 out:
291 rcu_read_unlock();
292 return err;
293 }
294
295 static int ieee80211_config_default_key(struct wiphy *wiphy,
296 struct net_device *dev,
297 u8 key_idx, bool uni,
298 bool multi)
299 {
300 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
301
302 ieee80211_set_default_key(sdata, key_idx, uni, multi);
303
304 return 0;
305 }
306
307 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
308 struct net_device *dev,
309 u8 key_idx)
310 {
311 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
312
313 ieee80211_set_default_mgmt_key(sdata, key_idx);
314
315 return 0;
316 }
317
318 static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
319 {
320 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
321 struct ieee80211_supported_band *sband;
322 sband = sta->local->hw.wiphy->bands[
323 sta->local->hw.conf.channel->band];
324 rate->legacy = sband->bitrates[idx].bitrate;
325 } else
326 rate->mcs = idx;
327 }
328
329 static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
330 {
331 struct ieee80211_sub_if_data *sdata = sta->sdata;
332 struct timespec uptime;
333
334 sinfo->generation = sdata->local->sta_generation;
335
336 sinfo->filled = STATION_INFO_INACTIVE_TIME |
337 STATION_INFO_RX_BYTES |
338 STATION_INFO_TX_BYTES |
339 STATION_INFO_RX_PACKETS |
340 STATION_INFO_TX_PACKETS |
341 STATION_INFO_TX_RETRIES |
342 STATION_INFO_TX_FAILED |
343 STATION_INFO_TX_BITRATE |
344 STATION_INFO_RX_BITRATE |
345 STATION_INFO_RX_DROP_MISC |
346 STATION_INFO_BSS_PARAM |
347 STATION_INFO_CONNECTED_TIME;
348
349 do_posix_clock_monotonic_gettime(&uptime);
350 sinfo->connected_time = uptime.tv_sec - sta->last_connected;
351
352 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
353 sinfo->rx_bytes = sta->rx_bytes;
354 sinfo->tx_bytes = sta->tx_bytes;
355 sinfo->rx_packets = sta->rx_packets;
356 sinfo->tx_packets = sta->tx_packets;
357 sinfo->tx_retries = sta->tx_retry_count;
358 sinfo->tx_failed = sta->tx_retry_failed;
359 sinfo->rx_dropped_misc = sta->rx_dropped;
360
361 if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
362 (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
363 sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
364 sinfo->signal = (s8)sta->last_signal;
365 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
366 }
367
368 sinfo->txrate.flags = 0;
369 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)
370 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
371 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
372 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
373 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
374 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
375 rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx);
376
377 sinfo->rxrate.flags = 0;
378 if (sta->last_rx_rate_flag & RX_FLAG_HT)
379 sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
380 if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
381 sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
382 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
383 sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
384 rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
385
386 if (ieee80211_vif_is_mesh(&sdata->vif)) {
387 #ifdef CONFIG_MAC80211_MESH
388 sinfo->filled |= STATION_INFO_LLID |
389 STATION_INFO_PLID |
390 STATION_INFO_PLINK_STATE;
391
392 sinfo->llid = le16_to_cpu(sta->llid);
393 sinfo->plid = le16_to_cpu(sta->plid);
394 sinfo->plink_state = sta->plink_state;
395 #endif
396 }
397
398 sinfo->bss_param.flags = 0;
399 if (sdata->vif.bss_conf.use_cts_prot)
400 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
401 if (sdata->vif.bss_conf.use_short_preamble)
402 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
403 if (sdata->vif.bss_conf.use_short_slot)
404 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
405 sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
406 sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
407 }
408
409
410 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
411 int idx, u8 *mac, struct station_info *sinfo)
412 {
413 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
414 struct sta_info *sta;
415 int ret = -ENOENT;
416
417 rcu_read_lock();
418
419 sta = sta_info_get_by_idx(sdata, idx);
420 if (sta) {
421 ret = 0;
422 memcpy(mac, sta->sta.addr, ETH_ALEN);
423 sta_set_sinfo(sta, sinfo);
424 }
425
426 rcu_read_unlock();
427
428 return ret;
429 }
430
431 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
432 int idx, struct survey_info *survey)
433 {
434 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
435
436 return drv_get_survey(local, idx, survey);
437 }
438
439 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
440 u8 *mac, struct station_info *sinfo)
441 {
442 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
443 struct sta_info *sta;
444 int ret = -ENOENT;
445
446 rcu_read_lock();
447
448 sta = sta_info_get_bss(sdata, mac);
449 if (sta) {
450 ret = 0;
451 sta_set_sinfo(sta, sinfo);
452 }
453
454 rcu_read_unlock();
455
456 return ret;
457 }
458
459 static void ieee80211_config_ap_ssid(struct ieee80211_sub_if_data *sdata,
460 struct beacon_parameters *params)
461 {
462 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
463
464 bss_conf->ssid_len = params->ssid_len;
465
466 if (params->ssid_len)
467 memcpy(bss_conf->ssid, params->ssid, params->ssid_len);
468
469 bss_conf->hidden_ssid =
470 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
471 }
472
473 /*
474 * This handles both adding a beacon and setting new beacon info
475 */
476 static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
477 struct beacon_parameters *params)
478 {
479 struct beacon_data *new, *old;
480 int new_head_len, new_tail_len;
481 int size;
482 int err = -EINVAL;
483
484 old = rtnl_dereference(sdata->u.ap.beacon);
485
486 /* head must not be zero-length */
487 if (params->head && !params->head_len)
488 return -EINVAL;
489
490 /*
491 * This is a kludge. beacon interval should really be part
492 * of the beacon information.
493 */
494 if (params->interval &&
495 (sdata->vif.bss_conf.beacon_int != params->interval)) {
496 sdata->vif.bss_conf.beacon_int = params->interval;
497 ieee80211_bss_info_change_notify(sdata,
498 BSS_CHANGED_BEACON_INT);
499 }
500
501 /* Need to have a beacon head if we don't have one yet */
502 if (!params->head && !old)
503 return err;
504
505 /* sorry, no way to start beaconing without dtim period */
506 if (!params->dtim_period && !old)
507 return err;
508
509 /* new or old head? */
510 if (params->head)
511 new_head_len = params->head_len;
512 else
513 new_head_len = old->head_len;
514
515 /* new or old tail? */
516 if (params->tail || !old)
517 /* params->tail_len will be zero for !params->tail */
518 new_tail_len = params->tail_len;
519 else
520 new_tail_len = old->tail_len;
521
522 size = sizeof(*new) + new_head_len + new_tail_len;
523
524 new = kzalloc(size, GFP_KERNEL);
525 if (!new)
526 return -ENOMEM;
527
528 /* start filling the new info now */
529
530 /* new or old dtim period? */
531 if (params->dtim_period)
532 new->dtim_period = params->dtim_period;
533 else
534 new->dtim_period = old->dtim_period;
535
536 /*
537 * pointers go into the block we allocated,
538 * memory is | beacon_data | head | tail |
539 */
540 new->head = ((u8 *) new) + sizeof(*new);
541 new->tail = new->head + new_head_len;
542 new->head_len = new_head_len;
543 new->tail_len = new_tail_len;
544
545 /* copy in head */
546 if (params->head)
547 memcpy(new->head, params->head, new_head_len);
548 else
549 memcpy(new->head, old->head, new_head_len);
550
551 /* copy in optional tail */
552 if (params->tail)
553 memcpy(new->tail, params->tail, new_tail_len);
554 else
555 if (old)
556 memcpy(new->tail, old->tail, new_tail_len);
557
558 sdata->vif.bss_conf.dtim_period = new->dtim_period;
559
560 rcu_assign_pointer(sdata->u.ap.beacon, new);
561
562 synchronize_rcu();
563
564 kfree(old);
565
566 ieee80211_config_ap_ssid(sdata, params);
567
568 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
569 BSS_CHANGED_BEACON |
570 BSS_CHANGED_SSID);
571 return 0;
572 }
573
574 static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
575 struct beacon_parameters *params)
576 {
577 struct ieee80211_sub_if_data *sdata;
578 struct beacon_data *old;
579
580 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
581
582 old = rtnl_dereference(sdata->u.ap.beacon);
583 if (old)
584 return -EALREADY;
585
586 return ieee80211_config_beacon(sdata, params);
587 }
588
589 static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
590 struct beacon_parameters *params)
591 {
592 struct ieee80211_sub_if_data *sdata;
593 struct beacon_data *old;
594
595 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
596
597 old = rtnl_dereference(sdata->u.ap.beacon);
598 if (!old)
599 return -ENOENT;
600
601 return ieee80211_config_beacon(sdata, params);
602 }
603
604 static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
605 {
606 struct ieee80211_sub_if_data *sdata;
607 struct beacon_data *old;
608
609 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
610
611 old = rtnl_dereference(sdata->u.ap.beacon);
612 if (!old)
613 return -ENOENT;
614
615 rcu_assign_pointer(sdata->u.ap.beacon, NULL);
616 synchronize_rcu();
617 kfree(old);
618
619 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
620 return 0;
621 }
622
623 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
624 struct iapp_layer2_update {
625 u8 da[ETH_ALEN]; /* broadcast */
626 u8 sa[ETH_ALEN]; /* STA addr */
627 __be16 len; /* 6 */
628 u8 dsap; /* 0 */
629 u8 ssap; /* 0 */
630 u8 control;
631 u8 xid_info[3];
632 } __packed;
633
634 static void ieee80211_send_layer2_update(struct sta_info *sta)
635 {
636 struct iapp_layer2_update *msg;
637 struct sk_buff *skb;
638
639 /* Send Level 2 Update Frame to update forwarding tables in layer 2
640 * bridge devices */
641
642 skb = dev_alloc_skb(sizeof(*msg));
643 if (!skb)
644 return;
645 msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
646
647 /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
648 * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
649
650 memset(msg->da, 0xff, ETH_ALEN);
651 memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
652 msg->len = htons(6);
653 msg->dsap = 0;
654 msg->ssap = 0x01; /* NULL LSAP, CR Bit: Response */
655 msg->control = 0xaf; /* XID response lsb.1111F101.
656 * F=0 (no poll command; unsolicited frame) */
657 msg->xid_info[0] = 0x81; /* XID format identifier */
658 msg->xid_info[1] = 1; /* LLC types/classes: Type 1 LLC */
659 msg->xid_info[2] = 0; /* XID sender's receive window size (RW) */
660
661 skb->dev = sta->sdata->dev;
662 skb->protocol = eth_type_trans(skb, sta->sdata->dev);
663 memset(skb->cb, 0, sizeof(skb->cb));
664 netif_rx_ni(skb);
665 }
666
667 static void sta_apply_parameters(struct ieee80211_local *local,
668 struct sta_info *sta,
669 struct station_parameters *params)
670 {
671 unsigned long flags;
672 u32 rates;
673 int i, j;
674 struct ieee80211_supported_band *sband;
675 struct ieee80211_sub_if_data *sdata = sta->sdata;
676 u32 mask, set;
677
678 sband = local->hw.wiphy->bands[local->oper_channel->band];
679
680 spin_lock_irqsave(&sta->flaglock, flags);
681 mask = params->sta_flags_mask;
682 set = params->sta_flags_set;
683
684 if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
685 sta->flags &= ~WLAN_STA_AUTHORIZED;
686 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
687 sta->flags |= WLAN_STA_AUTHORIZED;
688 }
689
690 if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
691 sta->flags &= ~WLAN_STA_SHORT_PREAMBLE;
692 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
693 sta->flags |= WLAN_STA_SHORT_PREAMBLE;
694 }
695
696 if (mask & BIT(NL80211_STA_FLAG_WME)) {
697 sta->flags &= ~WLAN_STA_WME;
698 sta->sta.wme = false;
699 if (set & BIT(NL80211_STA_FLAG_WME)) {
700 sta->flags |= WLAN_STA_WME;
701 sta->sta.wme = true;
702 }
703 }
704
705 if (mask & BIT(NL80211_STA_FLAG_MFP)) {
706 sta->flags &= ~WLAN_STA_MFP;
707 if (set & BIT(NL80211_STA_FLAG_MFP))
708 sta->flags |= WLAN_STA_MFP;
709 }
710
711 if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
712 sta->flags &= ~WLAN_STA_AUTH;
713 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED))
714 sta->flags |= WLAN_STA_AUTH;
715 }
716 spin_unlock_irqrestore(&sta->flaglock, flags);
717
718 if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
719 sta->sta.uapsd_queues = params->uapsd_queues;
720 sta->sta.max_sp = params->max_sp;
721 }
722
723 /*
724 * cfg80211 validates this (1-2007) and allows setting the AID
725 * only when creating a new station entry
726 */
727 if (params->aid)
728 sta->sta.aid = params->aid;
729
730 /*
731 * FIXME: updating the following information is racy when this
732 * function is called from ieee80211_change_station().
733 * However, all this information should be static so
734 * maybe we should just reject attemps to change it.
735 */
736
737 if (params->listen_interval >= 0)
738 sta->listen_interval = params->listen_interval;
739
740 if (params->supported_rates) {
741 rates = 0;
742
743 for (i = 0; i < params->supported_rates_len; i++) {
744 int rate = (params->supported_rates[i] & 0x7f) * 5;
745 for (j = 0; j < sband->n_bitrates; j++) {
746 if (sband->bitrates[j].bitrate == rate)
747 rates |= BIT(j);
748 }
749 }
750 sta->sta.supp_rates[local->oper_channel->band] = rates;
751 }
752
753 if (params->ht_capa)
754 ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
755 params->ht_capa,
756 &sta->sta.ht_cap);
757
758 if (ieee80211_vif_is_mesh(&sdata->vif)) {
759 #ifdef CONFIG_MAC80211_MESH
760 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
761 switch (params->plink_state) {
762 case NL80211_PLINK_LISTEN:
763 case NL80211_PLINK_ESTAB:
764 case NL80211_PLINK_BLOCKED:
765 sta->plink_state = params->plink_state;
766 break;
767 default:
768 /* nothing */
769 break;
770 }
771 else
772 switch (params->plink_action) {
773 case PLINK_ACTION_OPEN:
774 mesh_plink_open(sta);
775 break;
776 case PLINK_ACTION_BLOCK:
777 mesh_plink_block(sta);
778 break;
779 }
780 #endif
781 }
782 }
783
784 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
785 u8 *mac, struct station_parameters *params)
786 {
787 struct ieee80211_local *local = wiphy_priv(wiphy);
788 struct sta_info *sta;
789 struct ieee80211_sub_if_data *sdata;
790 int err;
791 int layer2_update;
792
793 if (params->vlan) {
794 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
795
796 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
797 sdata->vif.type != NL80211_IFTYPE_AP)
798 return -EINVAL;
799 } else
800 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
801
802 if (compare_ether_addr(mac, sdata->vif.addr) == 0)
803 return -EINVAL;
804
805 if (is_multicast_ether_addr(mac))
806 return -EINVAL;
807
808 sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
809 if (!sta)
810 return -ENOMEM;
811
812 sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC;
813
814 sta_apply_parameters(local, sta, params);
815
816 rate_control_rate_init(sta);
817
818 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
819 sdata->vif.type == NL80211_IFTYPE_AP;
820
821 err = sta_info_insert_rcu(sta);
822 if (err) {
823 rcu_read_unlock();
824 return err;
825 }
826
827 if (layer2_update)
828 ieee80211_send_layer2_update(sta);
829
830 rcu_read_unlock();
831
832 return 0;
833 }
834
835 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
836 u8 *mac)
837 {
838 struct ieee80211_local *local = wiphy_priv(wiphy);
839 struct ieee80211_sub_if_data *sdata;
840
841 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
842
843 if (mac)
844 return sta_info_destroy_addr_bss(sdata, mac);
845
846 sta_info_flush(local, sdata);
847 return 0;
848 }
849
850 static int ieee80211_change_station(struct wiphy *wiphy,
851 struct net_device *dev,
852 u8 *mac,
853 struct station_parameters *params)
854 {
855 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
856 struct ieee80211_local *local = wiphy_priv(wiphy);
857 struct sta_info *sta;
858 struct ieee80211_sub_if_data *vlansdata;
859
860 rcu_read_lock();
861
862 sta = sta_info_get_bss(sdata, mac);
863 if (!sta) {
864 rcu_read_unlock();
865 return -ENOENT;
866 }
867
868 if (params->vlan && params->vlan != sta->sdata->dev) {
869 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
870
871 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
872 vlansdata->vif.type != NL80211_IFTYPE_AP) {
873 rcu_read_unlock();
874 return -EINVAL;
875 }
876
877 if (params->vlan->ieee80211_ptr->use_4addr) {
878 if (vlansdata->u.vlan.sta) {
879 rcu_read_unlock();
880 return -EBUSY;
881 }
882
883 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
884 }
885
886 sta->sdata = vlansdata;
887 ieee80211_send_layer2_update(sta);
888 }
889
890 sta_apply_parameters(local, sta, params);
891
892 rcu_read_unlock();
893
894 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
895 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))
896 ieee80211_recalc_ps(local, -1);
897
898 return 0;
899 }
900
901 #ifdef CONFIG_MAC80211_MESH
902 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
903 u8 *dst, u8 *next_hop)
904 {
905 struct ieee80211_sub_if_data *sdata;
906 struct mesh_path *mpath;
907 struct sta_info *sta;
908 int err;
909
910 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
911
912 rcu_read_lock();
913 sta = sta_info_get(sdata, next_hop);
914 if (!sta) {
915 rcu_read_unlock();
916 return -ENOENT;
917 }
918
919 err = mesh_path_add(dst, sdata);
920 if (err) {
921 rcu_read_unlock();
922 return err;
923 }
924
925 mpath = mesh_path_lookup(dst, sdata);
926 if (!mpath) {
927 rcu_read_unlock();
928 return -ENXIO;
929 }
930 mesh_path_fix_nexthop(mpath, sta);
931
932 rcu_read_unlock();
933 return 0;
934 }
935
936 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
937 u8 *dst)
938 {
939 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
940
941 if (dst)
942 return mesh_path_del(dst, sdata);
943
944 mesh_path_flush_by_iface(sdata);
945 return 0;
946 }
947
948 static int ieee80211_change_mpath(struct wiphy *wiphy,
949 struct net_device *dev,
950 u8 *dst, u8 *next_hop)
951 {
952 struct ieee80211_sub_if_data *sdata;
953 struct mesh_path *mpath;
954 struct sta_info *sta;
955
956 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
957
958 rcu_read_lock();
959
960 sta = sta_info_get(sdata, next_hop);
961 if (!sta) {
962 rcu_read_unlock();
963 return -ENOENT;
964 }
965
966 mpath = mesh_path_lookup(dst, sdata);
967 if (!mpath) {
968 rcu_read_unlock();
969 return -ENOENT;
970 }
971
972 mesh_path_fix_nexthop(mpath, sta);
973
974 rcu_read_unlock();
975 return 0;
976 }
977
978 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
979 struct mpath_info *pinfo)
980 {
981 struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
982
983 if (next_hop_sta)
984 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
985 else
986 memset(next_hop, 0, ETH_ALEN);
987
988 pinfo->generation = mesh_paths_generation;
989
990 pinfo->filled = MPATH_INFO_FRAME_QLEN |
991 MPATH_INFO_SN |
992 MPATH_INFO_METRIC |
993 MPATH_INFO_EXPTIME |
994 MPATH_INFO_DISCOVERY_TIMEOUT |
995 MPATH_INFO_DISCOVERY_RETRIES |
996 MPATH_INFO_FLAGS;
997
998 pinfo->frame_qlen = mpath->frame_queue.qlen;
999 pinfo->sn = mpath->sn;
1000 pinfo->metric = mpath->metric;
1001 if (time_before(jiffies, mpath->exp_time))
1002 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
1003 pinfo->discovery_timeout =
1004 jiffies_to_msecs(mpath->discovery_timeout);
1005 pinfo->discovery_retries = mpath->discovery_retries;
1006 pinfo->flags = 0;
1007 if (mpath->flags & MESH_PATH_ACTIVE)
1008 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
1009 if (mpath->flags & MESH_PATH_RESOLVING)
1010 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1011 if (mpath->flags & MESH_PATH_SN_VALID)
1012 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
1013 if (mpath->flags & MESH_PATH_FIXED)
1014 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
1015 if (mpath->flags & MESH_PATH_RESOLVING)
1016 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
1017
1018 pinfo->flags = mpath->flags;
1019 }
1020
1021 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
1022 u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
1023
1024 {
1025 struct ieee80211_sub_if_data *sdata;
1026 struct mesh_path *mpath;
1027
1028 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1029
1030 rcu_read_lock();
1031 mpath = mesh_path_lookup(dst, sdata);
1032 if (!mpath) {
1033 rcu_read_unlock();
1034 return -ENOENT;
1035 }
1036 memcpy(dst, mpath->dst, ETH_ALEN);
1037 mpath_set_pinfo(mpath, next_hop, pinfo);
1038 rcu_read_unlock();
1039 return 0;
1040 }
1041
1042 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
1043 int idx, u8 *dst, u8 *next_hop,
1044 struct mpath_info *pinfo)
1045 {
1046 struct ieee80211_sub_if_data *sdata;
1047 struct mesh_path *mpath;
1048
1049 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1050
1051 rcu_read_lock();
1052 mpath = mesh_path_lookup_by_idx(idx, sdata);
1053 if (!mpath) {
1054 rcu_read_unlock();
1055 return -ENOENT;
1056 }
1057 memcpy(dst, mpath->dst, ETH_ALEN);
1058 mpath_set_pinfo(mpath, next_hop, pinfo);
1059 rcu_read_unlock();
1060 return 0;
1061 }
1062
1063 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
1064 struct net_device *dev,
1065 struct mesh_config *conf)
1066 {
1067 struct ieee80211_sub_if_data *sdata;
1068 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1069
1070 memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
1071 return 0;
1072 }
1073
1074 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
1075 {
1076 return (mask >> (parm-1)) & 0x1;
1077 }
1078
1079 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
1080 const struct mesh_setup *setup)
1081 {
1082 u8 *new_ie;
1083 const u8 *old_ie;
1084
1085 /* allocate information elements */
1086 new_ie = NULL;
1087 old_ie = ifmsh->ie;
1088
1089 if (setup->ie_len) {
1090 new_ie = kmemdup(setup->ie, setup->ie_len,
1091 GFP_KERNEL);
1092 if (!new_ie)
1093 return -ENOMEM;
1094 }
1095 ifmsh->ie_len = setup->ie_len;
1096 ifmsh->ie = new_ie;
1097 kfree(old_ie);
1098
1099 /* now copy the rest of the setup parameters */
1100 ifmsh->mesh_id_len = setup->mesh_id_len;
1101 memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
1102 ifmsh->mesh_pp_id = setup->path_sel_proto;
1103 ifmsh->mesh_pm_id = setup->path_metric;
1104 ifmsh->security = IEEE80211_MESH_SEC_NONE;
1105 if (setup->is_authenticated)
1106 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
1107 if (setup->is_secure)
1108 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
1109
1110 return 0;
1111 }
1112
1113 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
1114 struct net_device *dev, u32 mask,
1115 const struct mesh_config *nconf)
1116 {
1117 struct mesh_config *conf;
1118 struct ieee80211_sub_if_data *sdata;
1119 struct ieee80211_if_mesh *ifmsh;
1120
1121 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1122 ifmsh = &sdata->u.mesh;
1123
1124 /* Set the config options which we are interested in setting */
1125 conf = &(sdata->u.mesh.mshcfg);
1126 if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
1127 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
1128 if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
1129 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
1130 if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
1131 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
1132 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
1133 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
1134 if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
1135 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
1136 if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
1137 conf->dot11MeshTTL = nconf->dot11MeshTTL;
1138 if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
1139 conf->dot11MeshTTL = nconf->element_ttl;
1140 if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
1141 conf->auto_open_plinks = nconf->auto_open_plinks;
1142 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
1143 conf->dot11MeshHWMPmaxPREQretries =
1144 nconf->dot11MeshHWMPmaxPREQretries;
1145 if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
1146 conf->path_refresh_time = nconf->path_refresh_time;
1147 if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
1148 conf->min_discovery_timeout = nconf->min_discovery_timeout;
1149 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
1150 conf->dot11MeshHWMPactivePathTimeout =
1151 nconf->dot11MeshHWMPactivePathTimeout;
1152 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
1153 conf->dot11MeshHWMPpreqMinInterval =
1154 nconf->dot11MeshHWMPpreqMinInterval;
1155 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
1156 mask))
1157 conf->dot11MeshHWMPnetDiameterTraversalTime =
1158 nconf->dot11MeshHWMPnetDiameterTraversalTime;
1159 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
1160 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
1161 ieee80211_mesh_root_setup(ifmsh);
1162 }
1163 if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
1164 /* our current gate announcement implementation rides on root
1165 * announcements, so require this ifmsh to also be a root node
1166 * */
1167 if (nconf->dot11MeshGateAnnouncementProtocol &&
1168 !conf->dot11MeshHWMPRootMode) {
1169 conf->dot11MeshHWMPRootMode = 1;
1170 ieee80211_mesh_root_setup(ifmsh);
1171 }
1172 conf->dot11MeshGateAnnouncementProtocol =
1173 nconf->dot11MeshGateAnnouncementProtocol;
1174 }
1175 if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) {
1176 conf->dot11MeshHWMPRannInterval =
1177 nconf->dot11MeshHWMPRannInterval;
1178 }
1179 return 0;
1180 }
1181
1182 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
1183 const struct mesh_config *conf,
1184 const struct mesh_setup *setup)
1185 {
1186 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1187 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1188 int err;
1189
1190 memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
1191 err = copy_mesh_setup(ifmsh, setup);
1192 if (err)
1193 return err;
1194 ieee80211_start_mesh(sdata);
1195
1196 return 0;
1197 }
1198
1199 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
1200 {
1201 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1202
1203 ieee80211_stop_mesh(sdata);
1204
1205 return 0;
1206 }
1207 #endif
1208
1209 static int ieee80211_change_bss(struct wiphy *wiphy,
1210 struct net_device *dev,
1211 struct bss_parameters *params)
1212 {
1213 struct ieee80211_sub_if_data *sdata;
1214 u32 changed = 0;
1215
1216 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1217
1218 if (params->use_cts_prot >= 0) {
1219 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1220 changed |= BSS_CHANGED_ERP_CTS_PROT;
1221 }
1222 if (params->use_short_preamble >= 0) {
1223 sdata->vif.bss_conf.use_short_preamble =
1224 params->use_short_preamble;
1225 changed |= BSS_CHANGED_ERP_PREAMBLE;
1226 }
1227
1228 if (!sdata->vif.bss_conf.use_short_slot &&
1229 sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) {
1230 sdata->vif.bss_conf.use_short_slot = true;
1231 changed |= BSS_CHANGED_ERP_SLOT;
1232 }
1233
1234 if (params->use_short_slot_time >= 0) {
1235 sdata->vif.bss_conf.use_short_slot =
1236 params->use_short_slot_time;
1237 changed |= BSS_CHANGED_ERP_SLOT;
1238 }
1239
1240 if (params->basic_rates) {
1241 int i, j;
1242 u32 rates = 0;
1243 struct ieee80211_local *local = wiphy_priv(wiphy);
1244 struct ieee80211_supported_band *sband =
1245 wiphy->bands[local->oper_channel->band];
1246
1247 for (i = 0; i < params->basic_rates_len; i++) {
1248 int rate = (params->basic_rates[i] & 0x7f) * 5;
1249 for (j = 0; j < sband->n_bitrates; j++) {
1250 if (sband->bitrates[j].bitrate == rate)
1251 rates |= BIT(j);
1252 }
1253 }
1254 sdata->vif.bss_conf.basic_rates = rates;
1255 changed |= BSS_CHANGED_BASIC_RATES;
1256 }
1257
1258 if (params->ap_isolate >= 0) {
1259 if (params->ap_isolate)
1260 sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1261 else
1262 sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
1263 }
1264
1265 if (params->ht_opmode >= 0) {
1266 sdata->vif.bss_conf.ht_operation_mode =
1267 (u16) params->ht_opmode;
1268 changed |= BSS_CHANGED_HT;
1269 }
1270
1271 ieee80211_bss_info_change_notify(sdata, changed);
1272
1273 return 0;
1274 }
1275
1276 static int ieee80211_set_txq_params(struct wiphy *wiphy,
1277 struct net_device *dev,
1278 struct ieee80211_txq_params *params)
1279 {
1280 struct ieee80211_local *local = wiphy_priv(wiphy);
1281 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1282 struct ieee80211_tx_queue_params p;
1283
1284 if (!local->ops->conf_tx)
1285 return -EOPNOTSUPP;
1286
1287 memset(&p, 0, sizeof(p));
1288 p.aifs = params->aifs;
1289 p.cw_max = params->cwmax;
1290 p.cw_min = params->cwmin;
1291 p.txop = params->txop;
1292
1293 /*
1294 * Setting tx queue params disables u-apsd because it's only
1295 * called in master mode.
1296 */
1297 p.uapsd = false;
1298
1299 if (params->queue >= local->hw.queues)
1300 return -EINVAL;
1301
1302 sdata->tx_conf[params->queue] = p;
1303 if (drv_conf_tx(local, sdata, params->queue, &p)) {
1304 wiphy_debug(local->hw.wiphy,
1305 "failed to set TX queue parameters for queue %d\n",
1306 params->queue);
1307 return -EINVAL;
1308 }
1309
1310 return 0;
1311 }
1312
1313 static int ieee80211_set_channel(struct wiphy *wiphy,
1314 struct net_device *netdev,
1315 struct ieee80211_channel *chan,
1316 enum nl80211_channel_type channel_type)
1317 {
1318 struct ieee80211_local *local = wiphy_priv(wiphy);
1319 struct ieee80211_sub_if_data *sdata = NULL;
1320 struct ieee80211_channel *old_oper;
1321 enum nl80211_channel_type old_oper_type;
1322 enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
1323
1324 if (netdev)
1325 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
1326
1327 switch (ieee80211_get_channel_mode(local, NULL)) {
1328 case CHAN_MODE_HOPPING:
1329 return -EBUSY;
1330 case CHAN_MODE_FIXED:
1331 if (local->oper_channel != chan)
1332 return -EBUSY;
1333 if (!sdata && local->_oper_channel_type == channel_type)
1334 return 0;
1335 break;
1336 case CHAN_MODE_UNDEFINED:
1337 break;
1338 }
1339
1340 if (sdata)
1341 old_vif_oper_type = sdata->vif.bss_conf.channel_type;
1342 old_oper_type = local->_oper_channel_type;
1343
1344 if (!ieee80211_set_channel_type(local, sdata, channel_type))
1345 return -EBUSY;
1346
1347 old_oper = local->oper_channel;
1348 local->oper_channel = chan;
1349
1350 /* Update driver if changes were actually made. */
1351 if ((old_oper != local->oper_channel) ||
1352 (old_oper_type != local->_oper_channel_type))
1353 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1354
1355 if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) &&
1356 old_vif_oper_type != sdata->vif.bss_conf.channel_type)
1357 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1358
1359 return 0;
1360 }
1361
1362 #ifdef CONFIG_PM
1363 static int ieee80211_suspend(struct wiphy *wiphy,
1364 struct cfg80211_wowlan *wowlan)
1365 {
1366 return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
1367 }
1368
1369 static int ieee80211_resume(struct wiphy *wiphy)
1370 {
1371 return __ieee80211_resume(wiphy_priv(wiphy));
1372 }
1373 #else
1374 #define ieee80211_suspend NULL
1375 #define ieee80211_resume NULL
1376 #endif
1377
1378 static int ieee80211_scan(struct wiphy *wiphy,
1379 struct net_device *dev,
1380 struct cfg80211_scan_request *req)
1381 {
1382 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1383
1384 switch (ieee80211_vif_type_p2p(&sdata->vif)) {
1385 case NL80211_IFTYPE_STATION:
1386 case NL80211_IFTYPE_ADHOC:
1387 case NL80211_IFTYPE_MESH_POINT:
1388 case NL80211_IFTYPE_P2P_CLIENT:
1389 break;
1390 case NL80211_IFTYPE_P2P_GO:
1391 if (sdata->local->ops->hw_scan)
1392 break;
1393 /*
1394 * FIXME: implement NoA while scanning in software,
1395 * for now fall through to allow scanning only when
1396 * beaconing hasn't been configured yet
1397 */
1398 case NL80211_IFTYPE_AP:
1399 if (sdata->u.ap.beacon)
1400 return -EOPNOTSUPP;
1401 break;
1402 default:
1403 return -EOPNOTSUPP;
1404 }
1405
1406 return ieee80211_request_scan(sdata, req);
1407 }
1408
1409 static int
1410 ieee80211_sched_scan_start(struct wiphy *wiphy,
1411 struct net_device *dev,
1412 struct cfg80211_sched_scan_request *req)
1413 {
1414 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1415
1416 if (!sdata->local->ops->sched_scan_start)
1417 return -EOPNOTSUPP;
1418
1419 return ieee80211_request_sched_scan_start(sdata, req);
1420 }
1421
1422 static int
1423 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
1424 {
1425 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1426
1427 if (!sdata->local->ops->sched_scan_stop)
1428 return -EOPNOTSUPP;
1429
1430 return ieee80211_request_sched_scan_stop(sdata);
1431 }
1432
1433 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
1434 struct cfg80211_auth_request *req)
1435 {
1436 return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
1437 }
1438
1439 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
1440 struct cfg80211_assoc_request *req)
1441 {
1442 struct ieee80211_local *local = wiphy_priv(wiphy);
1443 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1444
1445 switch (ieee80211_get_channel_mode(local, sdata)) {
1446 case CHAN_MODE_HOPPING:
1447 return -EBUSY;
1448 case CHAN_MODE_FIXED:
1449 if (local->oper_channel == req->bss->channel)
1450 break;
1451 return -EBUSY;
1452 case CHAN_MODE_UNDEFINED:
1453 break;
1454 }
1455
1456 return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
1457 }
1458
1459 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
1460 struct cfg80211_deauth_request *req,
1461 void *cookie)
1462 {
1463 return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev),
1464 req, cookie);
1465 }
1466
1467 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
1468 struct cfg80211_disassoc_request *req,
1469 void *cookie)
1470 {
1471 return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev),
1472 req, cookie);
1473 }
1474
1475 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
1476 struct cfg80211_ibss_params *params)
1477 {
1478 struct ieee80211_local *local = wiphy_priv(wiphy);
1479 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1480
1481 switch (ieee80211_get_channel_mode(local, sdata)) {
1482 case CHAN_MODE_HOPPING:
1483 return -EBUSY;
1484 case CHAN_MODE_FIXED:
1485 if (!params->channel_fixed)
1486 return -EBUSY;
1487 if (local->oper_channel == params->channel)
1488 break;
1489 return -EBUSY;
1490 case CHAN_MODE_UNDEFINED:
1491 break;
1492 }
1493
1494 return ieee80211_ibss_join(sdata, params);
1495 }
1496
1497 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1498 {
1499 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1500
1501 return ieee80211_ibss_leave(sdata);
1502 }
1503
1504 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
1505 {
1506 struct ieee80211_local *local = wiphy_priv(wiphy);
1507 int err;
1508
1509 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
1510 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
1511
1512 if (err)
1513 return err;
1514 }
1515
1516 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
1517 err = drv_set_coverage_class(local, wiphy->coverage_class);
1518
1519 if (err)
1520 return err;
1521 }
1522
1523 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
1524 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
1525
1526 if (err)
1527 return err;
1528 }
1529
1530 if (changed & WIPHY_PARAM_RETRY_SHORT)
1531 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
1532 if (changed & WIPHY_PARAM_RETRY_LONG)
1533 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
1534 if (changed &
1535 (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
1536 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
1537
1538 return 0;
1539 }
1540
1541 static int ieee80211_set_tx_power(struct wiphy *wiphy,
1542 enum nl80211_tx_power_setting type, int mbm)
1543 {
1544 struct ieee80211_local *local = wiphy_priv(wiphy);
1545 struct ieee80211_channel *chan = local->hw.conf.channel;
1546 u32 changes = 0;
1547
1548 switch (type) {
1549 case NL80211_TX_POWER_AUTOMATIC:
1550 local->user_power_level = -1;
1551 break;
1552 case NL80211_TX_POWER_LIMITED:
1553 if (mbm < 0 || (mbm % 100))
1554 return -EOPNOTSUPP;
1555 local->user_power_level = MBM_TO_DBM(mbm);
1556 break;
1557 case NL80211_TX_POWER_FIXED:
1558 if (mbm < 0 || (mbm % 100))
1559 return -EOPNOTSUPP;
1560 /* TODO: move to cfg80211 when it knows the channel */
1561 if (MBM_TO_DBM(mbm) > chan->max_power)
1562 return -EINVAL;
1563 local->user_power_level = MBM_TO_DBM(mbm);
1564 break;
1565 }
1566
1567 ieee80211_hw_config(local, changes);
1568
1569 return 0;
1570 }
1571
1572 static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
1573 {
1574 struct ieee80211_local *local = wiphy_priv(wiphy);
1575
1576 *dbm = local->hw.conf.power_level;
1577
1578 return 0;
1579 }
1580
1581 static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
1582 const u8 *addr)
1583 {
1584 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1585
1586 memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
1587
1588 return 0;
1589 }
1590
1591 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
1592 {
1593 struct ieee80211_local *local = wiphy_priv(wiphy);
1594
1595 drv_rfkill_poll(local);
1596 }
1597
1598 #ifdef CONFIG_NL80211_TESTMODE
1599 static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
1600 {
1601 struct ieee80211_local *local = wiphy_priv(wiphy);
1602
1603 if (!local->ops->testmode_cmd)
1604 return -EOPNOTSUPP;
1605
1606 return local->ops->testmode_cmd(&local->hw, data, len);
1607 }
1608
1609 static int ieee80211_testmode_dump(struct wiphy *wiphy,
1610 struct sk_buff *skb,
1611 struct netlink_callback *cb,
1612 void *data, int len)
1613 {
1614 struct ieee80211_local *local = wiphy_priv(wiphy);
1615
1616 if (!local->ops->testmode_dump)
1617 return -EOPNOTSUPP;
1618
1619 return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
1620 }
1621 #endif
1622
1623 int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1624 enum ieee80211_smps_mode smps_mode)
1625 {
1626 const u8 *ap;
1627 enum ieee80211_smps_mode old_req;
1628 int err;
1629
1630 lockdep_assert_held(&sdata->u.mgd.mtx);
1631
1632 old_req = sdata->u.mgd.req_smps;
1633 sdata->u.mgd.req_smps = smps_mode;
1634
1635 if (old_req == smps_mode &&
1636 smps_mode != IEEE80211_SMPS_AUTOMATIC)
1637 return 0;
1638
1639 /*
1640 * If not associated, or current association is not an HT
1641 * association, there's no need to send an action frame.
1642 */
1643 if (!sdata->u.mgd.associated ||
1644 sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
1645 mutex_lock(&sdata->local->iflist_mtx);
1646 ieee80211_recalc_smps(sdata->local);
1647 mutex_unlock(&sdata->local->iflist_mtx);
1648 return 0;
1649 }
1650
1651 ap = sdata->u.mgd.associated->bssid;
1652
1653 if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
1654 if (sdata->u.mgd.powersave)
1655 smps_mode = IEEE80211_SMPS_DYNAMIC;
1656 else
1657 smps_mode = IEEE80211_SMPS_OFF;
1658 }
1659
1660 /* send SM PS frame to AP */
1661 err = ieee80211_send_smps_action(sdata, smps_mode,
1662 ap, ap);
1663 if (err)
1664 sdata->u.mgd.req_smps = old_req;
1665
1666 return err;
1667 }
1668
1669 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
1670 bool enabled, int timeout)
1671 {
1672 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1673 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1674
1675 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1676 return -EOPNOTSUPP;
1677
1678 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
1679 return -EOPNOTSUPP;
1680
1681 if (enabled == sdata->u.mgd.powersave &&
1682 timeout == local->dynamic_ps_forced_timeout)
1683 return 0;
1684
1685 sdata->u.mgd.powersave = enabled;
1686 local->dynamic_ps_forced_timeout = timeout;
1687
1688 /* no change, but if automatic follow powersave */
1689 mutex_lock(&sdata->u.mgd.mtx);
1690 __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
1691 mutex_unlock(&sdata->u.mgd.mtx);
1692
1693 if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
1694 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
1695
1696 ieee80211_recalc_ps(local, -1);
1697
1698 return 0;
1699 }
1700
1701 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
1702 struct net_device *dev,
1703 s32 rssi_thold, u32 rssi_hyst)
1704 {
1705 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1706 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1707 struct ieee80211_vif *vif = &sdata->vif;
1708 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1709
1710 if (rssi_thold == bss_conf->cqm_rssi_thold &&
1711 rssi_hyst == bss_conf->cqm_rssi_hyst)
1712 return 0;
1713
1714 bss_conf->cqm_rssi_thold = rssi_thold;
1715 bss_conf->cqm_rssi_hyst = rssi_hyst;
1716
1717 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_CQM_RSSI)) {
1718 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1719 return -EOPNOTSUPP;
1720 return 0;
1721 }
1722
1723 /* tell the driver upon association, unless already associated */
1724 if (sdata->u.mgd.associated)
1725 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
1726
1727 return 0;
1728 }
1729
1730 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
1731 struct net_device *dev,
1732 const u8 *addr,
1733 const struct cfg80211_bitrate_mask *mask)
1734 {
1735 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1736 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1737 int i, ret;
1738
1739 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
1740 ret = drv_set_bitrate_mask(local, sdata, mask);
1741 if (ret)
1742 return ret;
1743 }
1744
1745 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
1746 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
1747
1748 return 0;
1749 }
1750
1751 static int ieee80211_remain_on_channel_hw(struct ieee80211_local *local,
1752 struct net_device *dev,
1753 struct ieee80211_channel *chan,
1754 enum nl80211_channel_type chantype,
1755 unsigned int duration, u64 *cookie)
1756 {
1757 int ret;
1758 u32 random_cookie;
1759
1760 lockdep_assert_held(&local->mtx);
1761
1762 if (local->hw_roc_cookie)
1763 return -EBUSY;
1764 /* must be nonzero */
1765 random_cookie = random32() | 1;
1766
1767 *cookie = random_cookie;
1768 local->hw_roc_dev = dev;
1769 local->hw_roc_cookie = random_cookie;
1770 local->hw_roc_channel = chan;
1771 local->hw_roc_channel_type = chantype;
1772 local->hw_roc_duration = duration;
1773 ret = drv_remain_on_channel(local, chan, chantype, duration);
1774 if (ret) {
1775 local->hw_roc_channel = NULL;
1776 local->hw_roc_cookie = 0;
1777 }
1778
1779 return ret;
1780 }
1781
1782 static int ieee80211_remain_on_channel(struct wiphy *wiphy,
1783 struct net_device *dev,
1784 struct ieee80211_channel *chan,
1785 enum nl80211_channel_type channel_type,
1786 unsigned int duration,
1787 u64 *cookie)
1788 {
1789 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1790 struct ieee80211_local *local = sdata->local;
1791
1792 if (local->ops->remain_on_channel) {
1793 int ret;
1794
1795 mutex_lock(&local->mtx);
1796 ret = ieee80211_remain_on_channel_hw(local, dev,
1797 chan, channel_type,
1798 duration, cookie);
1799 local->hw_roc_for_tx = false;
1800 mutex_unlock(&local->mtx);
1801
1802 return ret;
1803 }
1804
1805 return ieee80211_wk_remain_on_channel(sdata, chan, channel_type,
1806 duration, cookie);
1807 }
1808
1809 static int ieee80211_cancel_remain_on_channel_hw(struct ieee80211_local *local,
1810 u64 cookie)
1811 {
1812 int ret;
1813
1814 lockdep_assert_held(&local->mtx);
1815
1816 if (local->hw_roc_cookie != cookie)
1817 return -ENOENT;
1818
1819 ret = drv_cancel_remain_on_channel(local);
1820 if (ret)
1821 return ret;
1822
1823 local->hw_roc_cookie = 0;
1824 local->hw_roc_channel = NULL;
1825
1826 ieee80211_recalc_idle(local);
1827
1828 return 0;
1829 }
1830
1831 static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
1832 struct net_device *dev,
1833 u64 cookie)
1834 {
1835 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1836 struct ieee80211_local *local = sdata->local;
1837
1838 if (local->ops->cancel_remain_on_channel) {
1839 int ret;
1840
1841 mutex_lock(&local->mtx);
1842 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
1843 mutex_unlock(&local->mtx);
1844
1845 return ret;
1846 }
1847
1848 return ieee80211_wk_cancel_remain_on_channel(sdata, cookie);
1849 }
1850
1851 static enum work_done_result
1852 ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb)
1853 {
1854 /*
1855 * Use the data embedded in the work struct for reporting
1856 * here so if the driver mangled the SKB before dropping
1857 * it (which is the only way we really should get here)
1858 * then we don't report mangled data.
1859 *
1860 * If there was no wait time, then by the time we get here
1861 * the driver will likely not have reported the status yet,
1862 * so in that case userspace will have to deal with it.
1863 */
1864
1865 if (wk->offchan_tx.wait && wk->offchan_tx.frame)
1866 cfg80211_mgmt_tx_status(wk->sdata->dev,
1867 (unsigned long) wk->offchan_tx.frame,
1868 wk->ie, wk->ie_len, false, GFP_KERNEL);
1869
1870 return WORK_DONE_DESTROY;
1871 }
1872
1873 static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
1874 struct ieee80211_channel *chan, bool offchan,
1875 enum nl80211_channel_type channel_type,
1876 bool channel_type_valid, unsigned int wait,
1877 const u8 *buf, size_t len, bool no_cck,
1878 u64 *cookie)
1879 {
1880 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1881 struct ieee80211_local *local = sdata->local;
1882 struct sk_buff *skb;
1883 struct sta_info *sta;
1884 struct ieee80211_work *wk;
1885 const struct ieee80211_mgmt *mgmt = (void *)buf;
1886 u32 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
1887 IEEE80211_TX_CTL_REQ_TX_STATUS;
1888 bool is_offchan = false;
1889
1890 /* Check that we are on the requested channel for transmission */
1891 if (chan != local->tmp_channel &&
1892 chan != local->oper_channel)
1893 is_offchan = true;
1894 if (channel_type_valid &&
1895 (channel_type != local->tmp_channel_type &&
1896 channel_type != local->_oper_channel_type))
1897 is_offchan = true;
1898
1899 if (chan == local->hw_roc_channel) {
1900 /* TODO: check channel type? */
1901 is_offchan = false;
1902 flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
1903 }
1904
1905 if (no_cck)
1906 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
1907
1908 if (is_offchan && !offchan)
1909 return -EBUSY;
1910
1911 switch (sdata->vif.type) {
1912 case NL80211_IFTYPE_ADHOC:
1913 case NL80211_IFTYPE_AP:
1914 case NL80211_IFTYPE_AP_VLAN:
1915 case NL80211_IFTYPE_P2P_GO:
1916 case NL80211_IFTYPE_MESH_POINT:
1917 if (!ieee80211_is_action(mgmt->frame_control) ||
1918 mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
1919 break;
1920 rcu_read_lock();
1921 sta = sta_info_get(sdata, mgmt->da);
1922 rcu_read_unlock();
1923 if (!sta)
1924 return -ENOLINK;
1925 break;
1926 case NL80211_IFTYPE_STATION:
1927 case NL80211_IFTYPE_P2P_CLIENT:
1928 break;
1929 default:
1930 return -EOPNOTSUPP;
1931 }
1932
1933 skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
1934 if (!skb)
1935 return -ENOMEM;
1936 skb_reserve(skb, local->hw.extra_tx_headroom);
1937
1938 memcpy(skb_put(skb, len), buf, len);
1939
1940 IEEE80211_SKB_CB(skb)->flags = flags;
1941
1942 skb->dev = sdata->dev;
1943
1944 *cookie = (unsigned long) skb;
1945
1946 if (is_offchan && local->ops->remain_on_channel) {
1947 unsigned int duration;
1948 int ret;
1949
1950 mutex_lock(&local->mtx);
1951 /*
1952 * If the duration is zero, then the driver
1953 * wouldn't actually do anything. Set it to
1954 * 100 for now.
1955 *
1956 * TODO: cancel the off-channel operation
1957 * when we get the SKB's TX status and
1958 * the wait time was zero before.
1959 */
1960 duration = 100;
1961 if (wait)
1962 duration = wait;
1963 ret = ieee80211_remain_on_channel_hw(local, dev, chan,
1964 channel_type,
1965 duration, cookie);
1966 if (ret) {
1967 kfree_skb(skb);
1968 mutex_unlock(&local->mtx);
1969 return ret;
1970 }
1971
1972 local->hw_roc_for_tx = true;
1973 local->hw_roc_duration = wait;
1974
1975 /*
1976 * queue up frame for transmission after
1977 * ieee80211_ready_on_channel call
1978 */
1979
1980 /* modify cookie to prevent API mismatches */
1981 *cookie ^= 2;
1982 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
1983 local->hw_roc_skb = skb;
1984 local->hw_roc_skb_for_status = skb;
1985 mutex_unlock(&local->mtx);
1986
1987 return 0;
1988 }
1989
1990 /*
1991 * Can transmit right away if the channel was the
1992 * right one and there's no wait involved... If a
1993 * wait is involved, we might otherwise not be on
1994 * the right channel for long enough!
1995 */
1996 if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) {
1997 ieee80211_tx_skb(sdata, skb);
1998 return 0;
1999 }
2000
2001 wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL);
2002 if (!wk) {
2003 kfree_skb(skb);
2004 return -ENOMEM;
2005 }
2006
2007 wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
2008 wk->chan = chan;
2009 wk->chan_type = channel_type;
2010 wk->sdata = sdata;
2011 wk->done = ieee80211_offchan_tx_done;
2012 wk->offchan_tx.frame = skb;
2013 wk->offchan_tx.wait = wait;
2014 wk->ie_len = len;
2015 memcpy(wk->ie, buf, len);
2016
2017 ieee80211_add_work(wk);
2018 return 0;
2019 }
2020
2021 static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
2022 struct net_device *dev,
2023 u64 cookie)
2024 {
2025 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2026 struct ieee80211_local *local = sdata->local;
2027 struct ieee80211_work *wk;
2028 int ret = -ENOENT;
2029
2030 mutex_lock(&local->mtx);
2031
2032 if (local->ops->cancel_remain_on_channel) {
2033 cookie ^= 2;
2034 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
2035
2036 if (ret == 0) {
2037 kfree_skb(local->hw_roc_skb);
2038 local->hw_roc_skb = NULL;
2039 local->hw_roc_skb_for_status = NULL;
2040 }
2041
2042 mutex_unlock(&local->mtx);
2043
2044 return ret;
2045 }
2046
2047 list_for_each_entry(wk, &local->work_list, list) {
2048 if (wk->sdata != sdata)
2049 continue;
2050
2051 if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
2052 continue;
2053
2054 if (cookie != (unsigned long) wk->offchan_tx.frame)
2055 continue;
2056
2057 wk->timeout = jiffies;
2058
2059 ieee80211_queue_work(&local->hw, &local->work_work);
2060 ret = 0;
2061 break;
2062 }
2063 mutex_unlock(&local->mtx);
2064
2065 return ret;
2066 }
2067
2068 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2069 struct net_device *dev,
2070 u16 frame_type, bool reg)
2071 {
2072 struct ieee80211_local *local = wiphy_priv(wiphy);
2073
2074 if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
2075 return;
2076
2077 if (reg)
2078 local->probe_req_reg++;
2079 else
2080 local->probe_req_reg--;
2081
2082 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2083 }
2084
2085 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
2086 {
2087 struct ieee80211_local *local = wiphy_priv(wiphy);
2088
2089 if (local->started)
2090 return -EOPNOTSUPP;
2091
2092 return drv_set_antenna(local, tx_ant, rx_ant);
2093 }
2094
2095 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
2096 {
2097 struct ieee80211_local *local = wiphy_priv(wiphy);
2098
2099 return drv_get_antenna(local, tx_ant, rx_ant);
2100 }
2101
2102 static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2103 {
2104 struct ieee80211_local *local = wiphy_priv(wiphy);
2105
2106 return drv_set_ringparam(local, tx, rx);
2107 }
2108
2109 static void ieee80211_get_ringparam(struct wiphy *wiphy,
2110 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2111 {
2112 struct ieee80211_local *local = wiphy_priv(wiphy);
2113
2114 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2115 }
2116
2117 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2118 struct net_device *dev,
2119 struct cfg80211_gtk_rekey_data *data)
2120 {
2121 struct ieee80211_local *local = wiphy_priv(wiphy);
2122 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2123
2124 if (!local->ops->set_rekey_data)
2125 return -EOPNOTSUPP;
2126
2127 drv_set_rekey_data(local, sdata, data);
2128
2129 return 0;
2130 }
2131
2132 static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
2133 {
2134 u8 *pos = (void *)skb_put(skb, 7);
2135
2136 *pos++ = WLAN_EID_EXT_CAPABILITY;
2137 *pos++ = 5; /* len */
2138 *pos++ = 0x0;
2139 *pos++ = 0x0;
2140 *pos++ = 0x0;
2141 *pos++ = 0x0;
2142 *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
2143 }
2144
2145 static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
2146 {
2147 struct ieee80211_local *local = sdata->local;
2148 u16 capab;
2149
2150 capab = 0;
2151 if (local->oper_channel->band != IEEE80211_BAND_2GHZ)
2152 return capab;
2153
2154 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
2155 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
2156 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
2157 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
2158
2159 return capab;
2160 }
2161
2162 static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
2163 u8 *peer, u8 *bssid)
2164 {
2165 struct ieee80211_tdls_lnkie *lnkid;
2166
2167 lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
2168
2169 lnkid->ie_type = WLAN_EID_LINK_ID;
2170 lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
2171
2172 memcpy(lnkid->bssid, bssid, ETH_ALEN);
2173 memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
2174 memcpy(lnkid->resp_sta, peer, ETH_ALEN);
2175 }
2176
2177 static int
2178 ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
2179 u8 *peer, u8 action_code, u8 dialog_token,
2180 u16 status_code, struct sk_buff *skb)
2181 {
2182 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2183 struct ieee80211_tdls_data *tf;
2184
2185 tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
2186
2187 memcpy(tf->da, peer, ETH_ALEN);
2188 memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
2189 tf->ether_type = cpu_to_be16(ETH_P_TDLS);
2190 tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
2191
2192 switch (action_code) {
2193 case WLAN_TDLS_SETUP_REQUEST:
2194 tf->category = WLAN_CATEGORY_TDLS;
2195 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
2196
2197 skb_put(skb, sizeof(tf->u.setup_req));
2198 tf->u.setup_req.dialog_token = dialog_token;
2199 tf->u.setup_req.capability =
2200 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2201
2202 ieee80211_add_srates_ie(&sdata->vif, skb);
2203 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2204 ieee80211_tdls_add_ext_capab(skb);
2205 break;
2206 case WLAN_TDLS_SETUP_RESPONSE:
2207 tf->category = WLAN_CATEGORY_TDLS;
2208 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
2209
2210 skb_put(skb, sizeof(tf->u.setup_resp));
2211 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
2212 tf->u.setup_resp.dialog_token = dialog_token;
2213 tf->u.setup_resp.capability =
2214 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2215
2216 ieee80211_add_srates_ie(&sdata->vif, skb);
2217 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2218 ieee80211_tdls_add_ext_capab(skb);
2219 break;
2220 case WLAN_TDLS_SETUP_CONFIRM:
2221 tf->category = WLAN_CATEGORY_TDLS;
2222 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
2223
2224 skb_put(skb, sizeof(tf->u.setup_cfm));
2225 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
2226 tf->u.setup_cfm.dialog_token = dialog_token;
2227 break;
2228 case WLAN_TDLS_TEARDOWN:
2229 tf->category = WLAN_CATEGORY_TDLS;
2230 tf->action_code = WLAN_TDLS_TEARDOWN;
2231
2232 skb_put(skb, sizeof(tf->u.teardown));
2233 tf->u.teardown.reason_code = cpu_to_le16(status_code);
2234 break;
2235 case WLAN_TDLS_DISCOVERY_REQUEST:
2236 tf->category = WLAN_CATEGORY_TDLS;
2237 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
2238
2239 skb_put(skb, sizeof(tf->u.discover_req));
2240 tf->u.discover_req.dialog_token = dialog_token;
2241 break;
2242 default:
2243 return -EINVAL;
2244 }
2245
2246 return 0;
2247 }
2248
2249 static int
2250 ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
2251 u8 *peer, u8 action_code, u8 dialog_token,
2252 u16 status_code, struct sk_buff *skb)
2253 {
2254 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2255 struct ieee80211_mgmt *mgmt;
2256
2257 mgmt = (void *)skb_put(skb, 24);
2258 memset(mgmt, 0, 24);
2259 memcpy(mgmt->da, peer, ETH_ALEN);
2260 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
2261 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
2262
2263 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2264 IEEE80211_STYPE_ACTION);
2265
2266 switch (action_code) {
2267 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2268 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
2269 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
2270 mgmt->u.action.u.tdls_discover_resp.action_code =
2271 WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
2272 mgmt->u.action.u.tdls_discover_resp.dialog_token =
2273 dialog_token;
2274 mgmt->u.action.u.tdls_discover_resp.capability =
2275 cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
2276
2277 ieee80211_add_srates_ie(&sdata->vif, skb);
2278 ieee80211_add_ext_srates_ie(&sdata->vif, skb);
2279 ieee80211_tdls_add_ext_capab(skb);
2280 break;
2281 default:
2282 return -EINVAL;
2283 }
2284
2285 return 0;
2286 }
2287
2288 static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
2289 u8 *peer, u8 action_code, u8 dialog_token,
2290 u16 status_code, const u8 *extra_ies,
2291 size_t extra_ies_len)
2292 {
2293 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2294 struct ieee80211_local *local = sdata->local;
2295 struct ieee80211_tx_info *info;
2296 struct sk_buff *skb = NULL;
2297 bool send_direct;
2298 int ret;
2299
2300 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2301 return -ENOTSUPP;
2302
2303 /* make sure we are in managed mode, and associated */
2304 if (sdata->vif.type != NL80211_IFTYPE_STATION ||
2305 !sdata->u.mgd.associated)
2306 return -EINVAL;
2307
2308 #ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2309 printk(KERN_DEBUG "TDLS mgmt action %d peer %pM\n", action_code, peer);
2310 #endif
2311
2312 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
2313 max(sizeof(struct ieee80211_mgmt),
2314 sizeof(struct ieee80211_tdls_data)) +
2315 50 + /* supported rates */
2316 7 + /* ext capab */
2317 extra_ies_len +
2318 sizeof(struct ieee80211_tdls_lnkie));
2319 if (!skb)
2320 return -ENOMEM;
2321
2322 info = IEEE80211_SKB_CB(skb);
2323 skb_reserve(skb, local->hw.extra_tx_headroom);
2324
2325 switch (action_code) {
2326 case WLAN_TDLS_SETUP_REQUEST:
2327 case WLAN_TDLS_SETUP_RESPONSE:
2328 case WLAN_TDLS_SETUP_CONFIRM:
2329 case WLAN_TDLS_TEARDOWN:
2330 case WLAN_TDLS_DISCOVERY_REQUEST:
2331 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
2332 action_code, dialog_token,
2333 status_code, skb);
2334 send_direct = false;
2335 break;
2336 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2337 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
2338 dialog_token, status_code,
2339 skb);
2340 send_direct = true;
2341 break;
2342 default:
2343 ret = -ENOTSUPP;
2344 break;
2345 }
2346
2347 if (ret < 0)
2348 goto fail;
2349
2350 if (extra_ies_len)
2351 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
2352
2353 /* the TDLS link IE is always added last */
2354 switch (action_code) {
2355 case WLAN_TDLS_SETUP_REQUEST:
2356 case WLAN_TDLS_SETUP_CONFIRM:
2357 case WLAN_TDLS_TEARDOWN:
2358 case WLAN_TDLS_DISCOVERY_REQUEST:
2359 /* we are the initiator */
2360 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
2361 sdata->u.mgd.bssid);
2362 break;
2363 case WLAN_TDLS_SETUP_RESPONSE:
2364 case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
2365 /* we are the responder */
2366 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
2367 sdata->u.mgd.bssid);
2368 break;
2369 default:
2370 ret = -ENOTSUPP;
2371 goto fail;
2372 }
2373
2374 if (send_direct) {
2375 ieee80211_tx_skb(sdata, skb);
2376 return 0;
2377 }
2378
2379 /*
2380 * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
2381 * we should default to AC_VI.
2382 */
2383 switch (action_code) {
2384 case WLAN_TDLS_SETUP_REQUEST:
2385 case WLAN_TDLS_SETUP_RESPONSE:
2386 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
2387 skb->priority = 2;
2388 break;
2389 default:
2390 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
2391 skb->priority = 5;
2392 break;
2393 }
2394
2395 /* disable bottom halves when entering the Tx path */
2396 local_bh_disable();
2397 ret = ieee80211_subif_start_xmit(skb, dev);
2398 local_bh_enable();
2399
2400 return ret;
2401
2402 fail:
2403 dev_kfree_skb(skb);
2404 return ret;
2405 }
2406
2407 static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
2408 u8 *peer, enum nl80211_tdls_operation oper)
2409 {
2410 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2411
2412 if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
2413 return -ENOTSUPP;
2414
2415 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2416 return -EINVAL;
2417
2418 #ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
2419 printk(KERN_DEBUG "TDLS oper %d peer %pM\n", oper, peer);
2420 #endif
2421
2422 switch (oper) {
2423 case NL80211_TDLS_ENABLE_LINK:
2424 break;
2425 case NL80211_TDLS_DISABLE_LINK:
2426 return sta_info_destroy_addr(sdata, peer);
2427 case NL80211_TDLS_TEARDOWN:
2428 case NL80211_TDLS_SETUP:
2429 case NL80211_TDLS_DISCOVERY_REQ:
2430 /* We don't support in-driver setup/teardown/discovery */
2431 return -ENOTSUPP;
2432 default:
2433 return -ENOTSUPP;
2434 }
2435
2436 return 0;
2437 }
2438
2439 struct cfg80211_ops mac80211_config_ops = {
2440 .add_virtual_intf = ieee80211_add_iface,
2441 .del_virtual_intf = ieee80211_del_iface,
2442 .change_virtual_intf = ieee80211_change_iface,
2443 .add_key = ieee80211_add_key,
2444 .del_key = ieee80211_del_key,
2445 .get_key = ieee80211_get_key,
2446 .set_default_key = ieee80211_config_default_key,
2447 .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
2448 .add_beacon = ieee80211_add_beacon,
2449 .set_beacon = ieee80211_set_beacon,
2450 .del_beacon = ieee80211_del_beacon,
2451 .add_station = ieee80211_add_station,
2452 .del_station = ieee80211_del_station,
2453 .change_station = ieee80211_change_station,
2454 .get_station = ieee80211_get_station,
2455 .dump_station = ieee80211_dump_station,
2456 .dump_survey = ieee80211_dump_survey,
2457 #ifdef CONFIG_MAC80211_MESH
2458 .add_mpath = ieee80211_add_mpath,
2459 .del_mpath = ieee80211_del_mpath,
2460 .change_mpath = ieee80211_change_mpath,
2461 .get_mpath = ieee80211_get_mpath,
2462 .dump_mpath = ieee80211_dump_mpath,
2463 .update_mesh_config = ieee80211_update_mesh_config,
2464 .get_mesh_config = ieee80211_get_mesh_config,
2465 .join_mesh = ieee80211_join_mesh,
2466 .leave_mesh = ieee80211_leave_mesh,
2467 #endif
2468 .change_bss = ieee80211_change_bss,
2469 .set_txq_params = ieee80211_set_txq_params,
2470 .set_channel = ieee80211_set_channel,
2471 .suspend = ieee80211_suspend,
2472 .resume = ieee80211_resume,
2473 .scan = ieee80211_scan,
2474 .sched_scan_start = ieee80211_sched_scan_start,
2475 .sched_scan_stop = ieee80211_sched_scan_stop,
2476 .auth = ieee80211_auth,
2477 .assoc = ieee80211_assoc,
2478 .deauth = ieee80211_deauth,
2479 .disassoc = ieee80211_disassoc,
2480 .join_ibss = ieee80211_join_ibss,
2481 .leave_ibss = ieee80211_leave_ibss,
2482 .set_wiphy_params = ieee80211_set_wiphy_params,
2483 .set_tx_power = ieee80211_set_tx_power,
2484 .get_tx_power = ieee80211_get_tx_power,
2485 .set_wds_peer = ieee80211_set_wds_peer,
2486 .rfkill_poll = ieee80211_rfkill_poll,
2487 CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
2488 CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
2489 .set_power_mgmt = ieee80211_set_power_mgmt,
2490 .set_bitrate_mask = ieee80211_set_bitrate_mask,
2491 .remain_on_channel = ieee80211_remain_on_channel,
2492 .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
2493 .mgmt_tx = ieee80211_mgmt_tx,
2494 .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
2495 .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
2496 .mgmt_frame_register = ieee80211_mgmt_frame_register,
2497 .set_antenna = ieee80211_set_antenna,
2498 .get_antenna = ieee80211_get_antenna,
2499 .set_ringparam = ieee80211_set_ringparam,
2500 .get_ringparam = ieee80211_get_ringparam,
2501 .set_rekey_data = ieee80211_set_rekey_data,
2502 .tdls_oper = ieee80211_tdls_oper,
2503 .tdls_mgmt = ieee80211_tdls_mgmt,
2504 };