OSDN Git Service

Merge changes into msm-4.4
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / net / wireless / core.c
1 /*
2  * This is the linux wireless configuration interface.
3  *
4  * Copyright 2006-2010          Johannes Berg <johannes@sipsolutions.net>
5  * Copyright 2013-2014  Intel Mobile Communications GmbH
6  * Copyright 2015       Intel Deutschland GmbH
7  */
8
9 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10
11 #include <linux/if.h>
12 #include <linux/module.h>
13 #include <linux/err.h>
14 #include <linux/list.h>
15 #include <linux/slab.h>
16 #include <linux/nl80211.h>
17 #include <linux/debugfs.h>
18 #include <linux/notifier.h>
19 #include <linux/device.h>
20 #include <linux/etherdevice.h>
21 #include <linux/rtnetlink.h>
22 #include <linux/sched.h>
23 #include <net/genetlink.h>
24 #include <net/cfg80211.h>
25 #include "nl80211.h"
26 #include "core.h"
27 #include "sysfs.h"
28 #include "debugfs.h"
29 #include "wext-compat.h"
30 #include "rdev-ops.h"
31
32 /* name for sysfs, %d is appended */
33 #define PHY_NAME "phy"
34
35 MODULE_AUTHOR("Johannes Berg");
36 MODULE_LICENSE("GPL");
37 MODULE_DESCRIPTION("wireless configuration support");
38 MODULE_ALIAS_GENL_FAMILY(NL80211_GENL_NAME);
39
40 /* RCU-protected (and RTNL for writers) */
41 LIST_HEAD(cfg80211_rdev_list);
42 int cfg80211_rdev_list_generation;
43
44 /* for debugfs */
45 static struct dentry *ieee80211_debugfs_dir;
46
47 /* for the cleanup, scan and event works */
48 struct workqueue_struct *cfg80211_wq;
49
50 static bool cfg80211_disable_40mhz_24ghz;
51 module_param(cfg80211_disable_40mhz_24ghz, bool, 0644);
52 MODULE_PARM_DESC(cfg80211_disable_40mhz_24ghz,
53                  "Disable 40MHz support in the 2.4GHz band");
54
55 struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx)
56 {
57         struct cfg80211_registered_device *result = NULL, *rdev;
58
59         ASSERT_RTNL();
60
61         list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
62                 if (rdev->wiphy_idx == wiphy_idx) {
63                         result = rdev;
64                         break;
65                 }
66         }
67
68         return result;
69 }
70
71 int get_wiphy_idx(struct wiphy *wiphy)
72 {
73         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
74
75         return rdev->wiphy_idx;
76 }
77
78 struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx)
79 {
80         struct cfg80211_registered_device *rdev;
81
82         ASSERT_RTNL();
83
84         rdev = cfg80211_rdev_by_wiphy_idx(wiphy_idx);
85         if (!rdev)
86                 return NULL;
87         return &rdev->wiphy;
88 }
89
90 static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev,
91                                    const char *newname)
92 {
93         struct cfg80211_registered_device *rdev2;
94         int wiphy_idx, taken = -1, digits;
95
96         ASSERT_RTNL();
97
98         if (strlen(newname) > NL80211_WIPHY_NAME_MAXLEN)
99                 return -EINVAL;
100
101         /* prohibit calling the thing phy%d when %d is not its number */
102         sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
103         if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
104                 /* count number of places needed to print wiphy_idx */
105                 digits = 1;
106                 while (wiphy_idx /= 10)
107                         digits++;
108                 /*
109                  * deny the name if it is phy<idx> where <idx> is printed
110                  * without leading zeroes. taken == strlen(newname) here
111                  */
112                 if (taken == strlen(PHY_NAME) + digits)
113                         return -EINVAL;
114         }
115
116         /* Ensure another device does not already have this name. */
117         list_for_each_entry(rdev2, &cfg80211_rdev_list, list)
118                 if (strcmp(newname, wiphy_name(&rdev2->wiphy)) == 0)
119                         return -EINVAL;
120
121         return 0;
122 }
123
124 int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
125                         char *newname)
126 {
127         int result;
128
129         ASSERT_RTNL();
130
131         /* Ignore nop renames */
132         if (strcmp(newname, wiphy_name(&rdev->wiphy)) == 0)
133                 return 0;
134
135         result = cfg80211_dev_check_name(rdev, newname);
136         if (result < 0)
137                 return result;
138
139         result = device_rename(&rdev->wiphy.dev, newname);
140         if (result)
141                 return result;
142
143         if (rdev->wiphy.debugfsdir &&
144             !debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
145                             rdev->wiphy.debugfsdir,
146                             rdev->wiphy.debugfsdir->d_parent,
147                             newname))
148                 pr_err("failed to rename debugfs dir to %s!\n", newname);
149
150         nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
151
152         return 0;
153 }
154
155 int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
156                           struct net *net)
157 {
158         struct wireless_dev *wdev;
159         int err = 0;
160
161         if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK))
162                 return -EOPNOTSUPP;
163
164         list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
165                 if (!wdev->netdev)
166                         continue;
167                 wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
168                 err = dev_change_net_namespace(wdev->netdev, net, "wlan%d");
169                 if (err)
170                         break;
171                 wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
172         }
173
174         if (err) {
175                 /* failed -- clean up to old netns */
176                 net = wiphy_net(&rdev->wiphy);
177
178                 list_for_each_entry_continue_reverse(wdev,
179                                                      &rdev->wiphy.wdev_list,
180                                                      list) {
181                         if (!wdev->netdev)
182                                 continue;
183                         wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
184                         err = dev_change_net_namespace(wdev->netdev, net,
185                                                         "wlan%d");
186                         WARN_ON(err);
187                         wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
188                 }
189
190                 return err;
191         }
192
193         wiphy_net_set(&rdev->wiphy, net);
194
195         err = device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev));
196         WARN_ON(err);
197
198         return 0;
199 }
200
201 static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data)
202 {
203         struct cfg80211_registered_device *rdev = data;
204
205         rdev_rfkill_poll(rdev);
206 }
207
208 void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
209                               struct wireless_dev *wdev)
210 {
211         ASSERT_RTNL();
212
213         if (WARN_ON(wdev->iftype != NL80211_IFTYPE_P2P_DEVICE))
214                 return;
215
216         if (!wdev->p2p_started)
217                 return;
218
219         rdev_stop_p2p_device(rdev, wdev);
220         wdev->p2p_started = false;
221
222         rdev->opencount--;
223
224         if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
225                 if (WARN_ON(!rdev->scan_req->notified))
226                         rdev->scan_req->aborted = true;
227                 ___cfg80211_scan_done(rdev, false);
228         }
229 }
230
231 void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
232 {
233         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
234         struct wireless_dev *wdev;
235
236         ASSERT_RTNL();
237
238         list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
239                 if (wdev->netdev) {
240                         dev_close(wdev->netdev);
241                         continue;
242                 }
243                 /* otherwise, check iftype */
244                 switch (wdev->iftype) {
245                 case NL80211_IFTYPE_P2P_DEVICE:
246                         cfg80211_stop_p2p_device(rdev, wdev);
247                         break;
248                 default:
249                         break;
250                 }
251         }
252 }
253 EXPORT_SYMBOL_GPL(cfg80211_shutdown_all_interfaces);
254
255 static int cfg80211_rfkill_set_block(void *data, bool blocked)
256 {
257         struct cfg80211_registered_device *rdev = data;
258
259         if (!blocked)
260                 return 0;
261
262         rtnl_lock();
263         cfg80211_shutdown_all_interfaces(&rdev->wiphy);
264         rtnl_unlock();
265
266         return 0;
267 }
268
269 static void cfg80211_rfkill_sync_work(struct work_struct *work)
270 {
271         struct cfg80211_registered_device *rdev;
272
273         rdev = container_of(work, struct cfg80211_registered_device, rfkill_sync);
274         cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill));
275 }
276
277 static void cfg80211_event_work(struct work_struct *work)
278 {
279         struct cfg80211_registered_device *rdev;
280
281         rdev = container_of(work, struct cfg80211_registered_device,
282                             event_work);
283
284         rtnl_lock();
285         cfg80211_process_rdev_events(rdev);
286         rtnl_unlock();
287 }
288
289 void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev)
290 {
291         struct cfg80211_iface_destroy *item;
292
293         ASSERT_RTNL();
294
295         spin_lock_irq(&rdev->destroy_list_lock);
296         while ((item = list_first_entry_or_null(&rdev->destroy_list,
297                                                 struct cfg80211_iface_destroy,
298                                                 list))) {
299                 struct wireless_dev *wdev, *tmp;
300                 u32 nlportid = item->nlportid;
301
302                 list_del(&item->list);
303                 kfree(item);
304                 spin_unlock_irq(&rdev->destroy_list_lock);
305
306                 list_for_each_entry_safe(wdev, tmp,
307                                          &rdev->wiphy.wdev_list, list) {
308                         if (nlportid == wdev->owner_nlportid)
309                                 rdev_del_virtual_intf(rdev, wdev);
310                 }
311
312                 spin_lock_irq(&rdev->destroy_list_lock);
313         }
314         spin_unlock_irq(&rdev->destroy_list_lock);
315 }
316
317 static void cfg80211_destroy_iface_wk(struct work_struct *work)
318 {
319         struct cfg80211_registered_device *rdev;
320
321         rdev = container_of(work, struct cfg80211_registered_device,
322                             destroy_work);
323
324         rtnl_lock();
325         cfg80211_destroy_ifaces(rdev);
326         rtnl_unlock();
327 }
328
329 static void cfg80211_sched_scan_stop_wk(struct work_struct *work)
330 {
331         struct cfg80211_registered_device *rdev;
332
333         rdev = container_of(work, struct cfg80211_registered_device,
334                            sched_scan_stop_wk);
335
336         rtnl_lock();
337
338         __cfg80211_stop_sched_scan(rdev, false);
339
340         rtnl_unlock();
341 }
342
343 /* exported functions */
344
345 struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
346                            const char *requested_name)
347 {
348         static atomic_t wiphy_counter = ATOMIC_INIT(0);
349
350         struct cfg80211_registered_device *rdev;
351         int alloc_size;
352
353         WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
354         WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));
355         WARN_ON(ops->connect && !ops->disconnect);
356         WARN_ON(ops->join_ibss && !ops->leave_ibss);
357         WARN_ON(ops->add_virtual_intf && !ops->del_virtual_intf);
358         WARN_ON(ops->add_station && !ops->del_station);
359         WARN_ON(ops->add_mpath && !ops->del_mpath);
360         WARN_ON(ops->join_mesh && !ops->leave_mesh);
361
362         alloc_size = sizeof(*rdev) + sizeof_priv;
363
364         rdev = kzalloc(alloc_size, GFP_KERNEL);
365         if (!rdev)
366                 return NULL;
367
368         rdev->ops = ops;
369
370         rdev->wiphy_idx = atomic_inc_return(&wiphy_counter);
371
372         if (unlikely(rdev->wiphy_idx < 0)) {
373                 /* ugh, wrapped! */
374                 atomic_dec(&wiphy_counter);
375                 kfree(rdev);
376                 return NULL;
377         }
378
379         /* atomic_inc_return makes it start at 1, make it start at 0 */
380         rdev->wiphy_idx--;
381
382         /* give it a proper name */
383         if (requested_name && requested_name[0]) {
384                 int rv;
385
386                 rtnl_lock();
387                 rv = cfg80211_dev_check_name(rdev, requested_name);
388
389                 if (rv < 0) {
390                         rtnl_unlock();
391                         goto use_default_name;
392                 }
393
394                 rv = dev_set_name(&rdev->wiphy.dev, "%s", requested_name);
395                 rtnl_unlock();
396                 if (rv)
397                         goto use_default_name;
398         } else {
399                 int rv;
400
401 use_default_name:
402                 /* NOTE:  This is *probably* safe w/out holding rtnl because of
403                  * the restrictions on phy names.  Probably this call could
404                  * fail if some other part of the kernel (re)named a device
405                  * phyX.  But, might should add some locking and check return
406                  * value, and use a different name if this one exists?
407                  */
408                 rv = dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
409                 if (rv < 0) {
410                         kfree(rdev);
411                         return NULL;
412                 }
413         }
414
415         INIT_LIST_HEAD(&rdev->wiphy.wdev_list);
416         INIT_LIST_HEAD(&rdev->beacon_registrations);
417         spin_lock_init(&rdev->beacon_registrations_lock);
418         spin_lock_init(&rdev->bss_lock);
419         INIT_LIST_HEAD(&rdev->bss_list);
420         INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done);
421         INIT_WORK(&rdev->sched_scan_results_wk, __cfg80211_sched_scan_results);
422         INIT_LIST_HEAD(&rdev->mlme_unreg);
423         spin_lock_init(&rdev->mlme_unreg_lock);
424         INIT_WORK(&rdev->mlme_unreg_wk, cfg80211_mlme_unreg_wk);
425         INIT_DELAYED_WORK(&rdev->dfs_update_channels_wk,
426                           cfg80211_dfs_channels_update_work);
427 #ifdef CONFIG_CFG80211_WEXT
428         rdev->wiphy.wext = &cfg80211_wext_handler;
429 #endif
430
431         device_initialize(&rdev->wiphy.dev);
432         rdev->wiphy.dev.class = &ieee80211_class;
433         rdev->wiphy.dev.platform_data = rdev;
434         device_enable_async_suspend(&rdev->wiphy.dev);
435
436         INIT_LIST_HEAD(&rdev->destroy_list);
437         spin_lock_init(&rdev->destroy_list_lock);
438         INIT_WORK(&rdev->destroy_work, cfg80211_destroy_iface_wk);
439         INIT_WORK(&rdev->sched_scan_stop_wk, cfg80211_sched_scan_stop_wk);
440
441 #ifdef CONFIG_CFG80211_DEFAULT_PS
442         rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
443 #endif
444
445         wiphy_net_set(&rdev->wiphy, &init_net);
446
447         rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block;
448         rdev->rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev),
449                                    &rdev->wiphy.dev, RFKILL_TYPE_WLAN,
450                                    &rdev->rfkill_ops, rdev);
451
452         if (!rdev->rfkill) {
453                 kfree(rdev);
454                 return NULL;
455         }
456
457         INIT_WORK(&rdev->rfkill_sync, cfg80211_rfkill_sync_work);
458         INIT_WORK(&rdev->conn_work, cfg80211_conn_work);
459         INIT_WORK(&rdev->event_work, cfg80211_event_work);
460
461         init_waitqueue_head(&rdev->dev_wait);
462
463         /*
464          * Initialize wiphy parameters to IEEE 802.11 MIB default values.
465          * Fragmentation and RTS threshold are disabled by default with the
466          * special -1 value.
467          */
468         rdev->wiphy.retry_short = 7;
469         rdev->wiphy.retry_long = 4;
470         rdev->wiphy.frag_threshold = (u32) -1;
471         rdev->wiphy.rts_threshold = (u32) -1;
472         rdev->wiphy.coverage_class = 0;
473
474         rdev->wiphy.max_num_csa_counters = 1;
475
476         rdev->wiphy.max_sched_scan_plans = 1;
477         rdev->wiphy.max_sched_scan_plan_interval = U32_MAX;
478
479         return &rdev->wiphy;
480 }
481 EXPORT_SYMBOL(wiphy_new_nm);
482
483 static int wiphy_verify_combinations(struct wiphy *wiphy)
484 {
485         const struct ieee80211_iface_combination *c;
486         int i, j;
487
488         for (i = 0; i < wiphy->n_iface_combinations; i++) {
489                 u32 cnt = 0;
490                 u16 all_iftypes = 0;
491
492                 c = &wiphy->iface_combinations[i];
493
494                 /*
495                  * Combinations with just one interface aren't real,
496                  * however we make an exception for DFS.
497                  */
498                 if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths))
499                         return -EINVAL;
500
501                 /* Need at least one channel */
502                 if (WARN_ON(!c->num_different_channels))
503                         return -EINVAL;
504
505                 /*
506                  * Put a sane limit on maximum number of different
507                  * channels to simplify channel accounting code.
508                  */
509                 if (WARN_ON(c->num_different_channels >
510                                 CFG80211_MAX_NUM_DIFFERENT_CHANNELS))
511                         return -EINVAL;
512
513                 /* DFS only works on one channel. */
514                 if (WARN_ON(c->radar_detect_widths &&
515                             (c->num_different_channels > 1)))
516                         return -EINVAL;
517
518                 if (WARN_ON(!c->n_limits))
519                         return -EINVAL;
520
521                 for (j = 0; j < c->n_limits; j++) {
522                         u16 types = c->limits[j].types;
523
524                         /* interface types shouldn't overlap */
525                         if (WARN_ON(types & all_iftypes))
526                                 return -EINVAL;
527                         all_iftypes |= types;
528
529                         if (WARN_ON(!c->limits[j].max))
530                                 return -EINVAL;
531
532                         /* Shouldn't list software iftypes in combinations! */
533                         if (WARN_ON(wiphy->software_iftypes & types))
534                                 return -EINVAL;
535
536                         /* Only a single P2P_DEVICE can be allowed */
537                         if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) &&
538                                     c->limits[j].max > 1))
539                                 return -EINVAL;
540
541                         cnt += c->limits[j].max;
542                         /*
543                          * Don't advertise an unsupported type
544                          * in a combination.
545                          */
546                         if (WARN_ON((wiphy->interface_modes & types) != types))
547                                 return -EINVAL;
548                 }
549
550                 /* You can't even choose that many! */
551                 if (WARN_ON(cnt < c->max_interfaces))
552                         return -EINVAL;
553         }
554
555         return 0;
556 }
557
558 int wiphy_register(struct wiphy *wiphy)
559 {
560         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
561         int res;
562         enum ieee80211_band band;
563         struct ieee80211_supported_band *sband;
564         bool have_band = false;
565         int i;
566         u16 ifmodes = wiphy->interface_modes;
567
568 #ifdef CONFIG_PM
569         if (WARN_ON(wiphy->wowlan &&
570                     (wiphy->wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) &&
571                     !(wiphy->wowlan->flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY)))
572                 return -EINVAL;
573         if (WARN_ON(wiphy->wowlan &&
574                     !wiphy->wowlan->flags && !wiphy->wowlan->n_patterns &&
575                     !wiphy->wowlan->tcp))
576                 return -EINVAL;
577 #endif
578         if (WARN_ON((wiphy->features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) &&
579                     (!rdev->ops->tdls_channel_switch ||
580                      !rdev->ops->tdls_cancel_channel_switch)))
581                 return -EINVAL;
582
583         /*
584          * if a wiphy has unsupported modes for regulatory channel enforcement,
585          * opt-out of enforcement checking
586          */
587         if (wiphy->interface_modes & ~(BIT(NL80211_IFTYPE_STATION) |
588                                        BIT(NL80211_IFTYPE_P2P_CLIENT) |
589                                        BIT(NL80211_IFTYPE_AP) |
590                                        BIT(NL80211_IFTYPE_P2P_GO) |
591                                        BIT(NL80211_IFTYPE_ADHOC) |
592                                        BIT(NL80211_IFTYPE_P2P_DEVICE) |
593                                        BIT(NL80211_IFTYPE_AP_VLAN) |
594                                        BIT(NL80211_IFTYPE_MONITOR)))
595                 wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
596
597         if (WARN_ON((wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) &&
598                     (wiphy->regulatory_flags &
599                                         (REGULATORY_CUSTOM_REG |
600                                          REGULATORY_STRICT_REG |
601                                          REGULATORY_COUNTRY_IE_FOLLOW_POWER |
602                                          REGULATORY_COUNTRY_IE_IGNORE))))
603                 return -EINVAL;
604
605         if (WARN_ON(wiphy->coalesce &&
606                     (!wiphy->coalesce->n_rules ||
607                      !wiphy->coalesce->n_patterns) &&
608                     (!wiphy->coalesce->pattern_min_len ||
609                      wiphy->coalesce->pattern_min_len >
610                         wiphy->coalesce->pattern_max_len)))
611                 return -EINVAL;
612
613         if (WARN_ON(wiphy->ap_sme_capa &&
614                     !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME)))
615                 return -EINVAL;
616
617         if (WARN_ON(wiphy->addresses && !wiphy->n_addresses))
618                 return -EINVAL;
619
620         if (WARN_ON(wiphy->addresses &&
621                     !is_zero_ether_addr(wiphy->perm_addr) &&
622                     memcmp(wiphy->perm_addr, wiphy->addresses[0].addr,
623                            ETH_ALEN)))
624                 return -EINVAL;
625
626         if (WARN_ON(wiphy->max_acl_mac_addrs &&
627                     (!(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME) ||
628                      !rdev->ops->set_mac_acl)))
629                 return -EINVAL;
630
631         /* assure only valid behaviours are flagged by driver
632          * hence subtract 2 as bit 0 is invalid.
633          */
634         if (WARN_ON(wiphy->bss_select_support &&
635                     (wiphy->bss_select_support & ~(BIT(__NL80211_BSS_SELECT_ATTR_AFTER_LAST) - 2))))
636                 return -EINVAL;
637
638         if (wiphy->addresses)
639                 memcpy(wiphy->perm_addr, wiphy->addresses[0].addr, ETH_ALEN);
640
641         /* sanity check ifmodes */
642         WARN_ON(!ifmodes);
643         ifmodes &= ((1 << NUM_NL80211_IFTYPES) - 1) & ~1;
644         if (WARN_ON(ifmodes != wiphy->interface_modes))
645                 wiphy->interface_modes = ifmodes;
646
647         res = wiphy_verify_combinations(wiphy);
648         if (res)
649                 return res;
650
651         /* sanity check supported bands/channels */
652         for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
653                 sband = wiphy->bands[band];
654                 if (!sband)
655                         continue;
656
657                 sband->band = band;
658                 if (WARN_ON(!sband->n_channels))
659                         return -EINVAL;
660                 /*
661                  * on 60GHz band, there are no legacy rates, so
662                  * n_bitrates is 0
663                  */
664                 if (WARN_ON(band != IEEE80211_BAND_60GHZ &&
665                             !sband->n_bitrates))
666                         return -EINVAL;
667
668                 /*
669                  * Since cfg80211_disable_40mhz_24ghz is global, we can
670                  * modify the sband's ht data even if the driver uses a
671                  * global structure for that.
672                  */
673                 if (cfg80211_disable_40mhz_24ghz &&
674                     band == IEEE80211_BAND_2GHZ &&
675                     sband->ht_cap.ht_supported) {
676                         sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
677                         sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
678                 }
679
680                 /*
681                  * Since we use a u32 for rate bitmaps in
682                  * ieee80211_get_response_rate, we cannot
683                  * have more than 32 legacy rates.
684                  */
685                 if (WARN_ON(sband->n_bitrates > 32))
686                         return -EINVAL;
687
688                 for (i = 0; i < sband->n_channels; i++) {
689                         sband->channels[i].orig_flags =
690                                 sband->channels[i].flags;
691                         sband->channels[i].orig_mag = INT_MAX;
692                         sband->channels[i].orig_mpwr =
693                                 sband->channels[i].max_power;
694                         sband->channels[i].band = band;
695                 }
696
697                 have_band = true;
698         }
699
700         if (!have_band) {
701                 WARN_ON(1);
702                 return -EINVAL;
703         }
704
705 #ifdef CONFIG_PM
706         if (WARN_ON(rdev->wiphy.wowlan && rdev->wiphy.wowlan->n_patterns &&
707                     (!rdev->wiphy.wowlan->pattern_min_len ||
708                      rdev->wiphy.wowlan->pattern_min_len >
709                                 rdev->wiphy.wowlan->pattern_max_len)))
710                 return -EINVAL;
711 #endif
712
713         /* check and set up bitrates */
714         ieee80211_set_bitrate_flags(wiphy);
715
716         rdev->wiphy.features |= NL80211_FEATURE_SCAN_FLUSH;
717
718         rtnl_lock();
719         res = device_add(&rdev->wiphy.dev);
720         if (res) {
721                 rtnl_unlock();
722                 return res;
723         }
724
725         /* set up regulatory info */
726         wiphy_regulatory_register(wiphy);
727
728         list_add_rcu(&rdev->list, &cfg80211_rdev_list);
729         cfg80211_rdev_list_generation++;
730
731         /* add to debugfs */
732         rdev->wiphy.debugfsdir =
733                 debugfs_create_dir(wiphy_name(&rdev->wiphy),
734                                    ieee80211_debugfs_dir);
735         if (IS_ERR(rdev->wiphy.debugfsdir))
736                 rdev->wiphy.debugfsdir = NULL;
737
738         cfg80211_debugfs_rdev_add(rdev);
739         nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
740
741         if (wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) {
742                 struct regulatory_request request;
743
744                 request.wiphy_idx = get_wiphy_idx(wiphy);
745                 request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
746                 request.alpha2[0] = '9';
747                 request.alpha2[1] = '9';
748
749                 nl80211_send_reg_change_event(&request);
750         }
751
752         /* Check that nobody globally advertises any capabilities they do not
753          * advertise on all possible interface types.
754          */
755         if (wiphy->extended_capabilities_len &&
756             wiphy->num_iftype_ext_capab &&
757             wiphy->iftype_ext_capab) {
758                 u8 supported_on_all, j;
759                 const struct wiphy_iftype_ext_capab *capab;
760
761                 capab = wiphy->iftype_ext_capab;
762                 for (j = 0; j < wiphy->extended_capabilities_len; j++) {
763                         if (capab[0].extended_capabilities_len > j)
764                                 supported_on_all =
765                                         capab[0].extended_capabilities[j];
766                         else
767                                 supported_on_all = 0x00;
768                         for (i = 1; i < wiphy->num_iftype_ext_capab; i++) {
769                                 if (j >= capab[i].extended_capabilities_len) {
770                                         supported_on_all = 0x00;
771                                         break;
772                                 }
773                                 supported_on_all &=
774                                         capab[i].extended_capabilities[j];
775                         }
776                         if (WARN_ON(wiphy->extended_capabilities[j] &
777                                     ~supported_on_all))
778                                 break;
779                 }
780         }
781
782         rdev->wiphy.registered = true;
783         rtnl_unlock();
784
785         res = rfkill_register(rdev->rfkill);
786         if (res) {
787                 rfkill_destroy(rdev->rfkill);
788                 rdev->rfkill = NULL;
789                 wiphy_unregister(&rdev->wiphy);
790                 return res;
791         }
792
793         return 0;
794 }
795 EXPORT_SYMBOL(wiphy_register);
796
797 void wiphy_rfkill_start_polling(struct wiphy *wiphy)
798 {
799         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
800
801         if (!rdev->ops->rfkill_poll)
802                 return;
803         rdev->rfkill_ops.poll = cfg80211_rfkill_poll;
804         rfkill_resume_polling(rdev->rfkill);
805 }
806 EXPORT_SYMBOL(wiphy_rfkill_start_polling);
807
808 void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
809 {
810         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
811
812         rfkill_pause_polling(rdev->rfkill);
813 }
814 EXPORT_SYMBOL(wiphy_rfkill_stop_polling);
815
816 void wiphy_unregister(struct wiphy *wiphy)
817 {
818         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
819
820         wait_event(rdev->dev_wait, ({
821                 int __count;
822                 rtnl_lock();
823                 __count = rdev->opencount;
824                 rtnl_unlock();
825                 __count == 0; }));
826
827         if (rdev->rfkill)
828                 rfkill_unregister(rdev->rfkill);
829
830         rtnl_lock();
831         nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
832         rdev->wiphy.registered = false;
833
834         WARN_ON(!list_empty(&rdev->wiphy.wdev_list));
835
836         /*
837          * First remove the hardware from everywhere, this makes
838          * it impossible to find from userspace.
839          */
840         debugfs_remove_recursive(rdev->wiphy.debugfsdir);
841         list_del_rcu(&rdev->list);
842         synchronize_rcu();
843
844         /*
845          * If this device got a regulatory hint tell core its
846          * free to listen now to a new shiny device regulatory hint
847          */
848         wiphy_regulatory_deregister(wiphy);
849
850         cfg80211_rdev_list_generation++;
851         device_del(&rdev->wiphy.dev);
852
853         rtnl_unlock();
854
855         flush_work(&rdev->scan_done_wk);
856         cancel_work_sync(&rdev->conn_work);
857         flush_work(&rdev->event_work);
858         cancel_delayed_work_sync(&rdev->dfs_update_channels_wk);
859         flush_work(&rdev->destroy_work);
860         flush_work(&rdev->sched_scan_stop_wk);
861         flush_work(&rdev->mlme_unreg_wk);
862
863 #ifdef CONFIG_PM
864         if (rdev->wiphy.wowlan_config && rdev->ops->set_wakeup)
865                 rdev_set_wakeup(rdev, false);
866 #endif
867         cfg80211_rdev_free_wowlan(rdev);
868         cfg80211_rdev_free_coalesce(rdev);
869 }
870 EXPORT_SYMBOL(wiphy_unregister);
871
872 void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
873 {
874         struct cfg80211_internal_bss *scan, *tmp;
875         struct cfg80211_beacon_registration *reg, *treg;
876         rfkill_destroy(rdev->rfkill);
877         list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
878                 list_del(&reg->list);
879                 kfree(reg);
880         }
881         list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list)
882                 cfg80211_put_bss(&rdev->wiphy, &scan->pub);
883         kfree(rdev);
884 }
885
886 void wiphy_free(struct wiphy *wiphy)
887 {
888         put_device(&wiphy->dev);
889 }
890 EXPORT_SYMBOL(wiphy_free);
891
892 void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
893 {
894         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
895
896         if (rfkill_set_hw_state(rdev->rfkill, blocked))
897                 schedule_work(&rdev->rfkill_sync);
898 }
899 EXPORT_SYMBOL(wiphy_rfkill_set_hw_state);
900
901 void cfg80211_unregister_wdev(struct wireless_dev *wdev)
902 {
903         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
904
905         ASSERT_RTNL();
906
907         if (WARN_ON(wdev->netdev))
908                 return;
909
910         list_del_rcu(&wdev->list);
911         rdev->devlist_generation++;
912
913         switch (wdev->iftype) {
914         case NL80211_IFTYPE_P2P_DEVICE:
915                 cfg80211_mlme_purge_registrations(wdev);
916                 cfg80211_stop_p2p_device(rdev, wdev);
917                 break;
918         default:
919                 WARN_ON_ONCE(1);
920                 break;
921         }
922 }
923 EXPORT_SYMBOL(cfg80211_unregister_wdev);
924
925 static const struct device_type wiphy_type = {
926         .name   = "wlan",
927 };
928
929 void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
930                                enum nl80211_iftype iftype, int num)
931 {
932         ASSERT_RTNL();
933
934         rdev->num_running_ifaces += num;
935         if (iftype == NL80211_IFTYPE_MONITOR)
936                 rdev->num_running_monitor_ifaces += num;
937 }
938
939 void __cfg80211_leave(struct cfg80211_registered_device *rdev,
940                       struct wireless_dev *wdev)
941 {
942         struct net_device *dev = wdev->netdev;
943         struct cfg80211_sched_scan_request *sched_scan_req;
944
945         ASSERT_RTNL();
946         ASSERT_WDEV_LOCK(wdev);
947
948         switch (wdev->iftype) {
949         case NL80211_IFTYPE_ADHOC:
950                 __cfg80211_leave_ibss(rdev, dev, true);
951                 break;
952         case NL80211_IFTYPE_P2P_CLIENT:
953         case NL80211_IFTYPE_STATION:
954                 sched_scan_req = rtnl_dereference(rdev->sched_scan_req);
955                 if (sched_scan_req && dev == sched_scan_req->dev)
956                         __cfg80211_stop_sched_scan(rdev, false);
957 #ifdef CONFIG_CFG80211_WEXT
958                 kfree(wdev->wext.ie);
959                 wdev->wext.ie = NULL;
960                 wdev->wext.ie_len = 0;
961                 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
962 #endif
963                 cfg80211_disconnect(rdev, dev,
964                                     WLAN_REASON_DEAUTH_LEAVING, true);
965                 cfg80211_mlme_down(rdev, dev);
966                 break;
967         case NL80211_IFTYPE_MESH_POINT:
968                 __cfg80211_leave_mesh(rdev, dev);
969                 break;
970         case NL80211_IFTYPE_AP:
971         case NL80211_IFTYPE_P2P_GO:
972                 __cfg80211_stop_ap(rdev, dev, true);
973                 break;
974         case NL80211_IFTYPE_OCB:
975                 __cfg80211_leave_ocb(rdev, dev);
976                 break;
977         case NL80211_IFTYPE_WDS:
978                 /* must be handled by mac80211/driver, has no APIs */
979                 break;
980         case NL80211_IFTYPE_P2P_DEVICE:
981                 /* cannot happen, has no netdev */
982                 break;
983         case NL80211_IFTYPE_AP_VLAN:
984         case NL80211_IFTYPE_MONITOR:
985                 /* nothing to do */
986                 break;
987         case NL80211_IFTYPE_UNSPECIFIED:
988         case NUM_NL80211_IFTYPES:
989                 /* invalid */
990                 break;
991         }
992         wdev->beacon_interval = 0;
993 }
994
995 void cfg80211_leave(struct cfg80211_registered_device *rdev,
996                     struct wireless_dev *wdev)
997 {
998         wdev_lock(wdev);
999         __cfg80211_leave(rdev, wdev);
1000         wdev_unlock(wdev);
1001 }
1002
1003 void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
1004                          gfp_t gfp)
1005 {
1006         struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1007         struct cfg80211_event *ev;
1008         unsigned long flags;
1009
1010         trace_cfg80211_stop_iface(wiphy, wdev);
1011
1012         ev = kzalloc(sizeof(*ev), gfp);
1013         if (!ev)
1014                 return;
1015
1016         ev->type = EVENT_STOPPED;
1017
1018         spin_lock_irqsave(&wdev->event_lock, flags);
1019         list_add_tail(&ev->list, &wdev->event_list);
1020         spin_unlock_irqrestore(&wdev->event_lock, flags);
1021         queue_work(cfg80211_wq, &rdev->event_work);
1022 }
1023 EXPORT_SYMBOL(cfg80211_stop_iface);
1024
1025 static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
1026                                          unsigned long state, void *ptr)
1027 {
1028         struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1029         struct wireless_dev *wdev = dev->ieee80211_ptr;
1030         struct cfg80211_registered_device *rdev;
1031         struct cfg80211_sched_scan_request *sched_scan_req;
1032
1033         if (!wdev)
1034                 return NOTIFY_DONE;
1035
1036         rdev = wiphy_to_rdev(wdev->wiphy);
1037
1038         WARN_ON(wdev->iftype == NL80211_IFTYPE_UNSPECIFIED);
1039
1040         switch (state) {
1041         case NETDEV_POST_INIT:
1042                 SET_NETDEV_DEVTYPE(dev, &wiphy_type);
1043                 break;
1044         case NETDEV_REGISTER:
1045                 /*
1046                  * NB: cannot take rdev->mtx here because this may be
1047                  * called within code protected by it when interfaces
1048                  * are added with nl80211.
1049                  */
1050                 mutex_init(&wdev->mtx);
1051                 INIT_LIST_HEAD(&wdev->event_list);
1052                 spin_lock_init(&wdev->event_lock);
1053                 INIT_LIST_HEAD(&wdev->mgmt_registrations);
1054                 spin_lock_init(&wdev->mgmt_registrations_lock);
1055
1056                 wdev->identifier = ++rdev->wdev_id;
1057                 list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
1058                 rdev->devlist_generation++;
1059                 /* can only change netns with wiphy */
1060                 dev->features |= NETIF_F_NETNS_LOCAL;
1061
1062                 if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
1063                                       "phy80211")) {
1064                         pr_err("failed to add phy80211 symlink to netdev!\n");
1065                 }
1066                 wdev->netdev = dev;
1067 #ifdef CONFIG_CFG80211_WEXT
1068                 wdev->wext.default_key = -1;
1069                 wdev->wext.default_mgmt_key = -1;
1070                 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
1071 #endif
1072
1073                 if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT)
1074                         wdev->ps = true;
1075                 else
1076                         wdev->ps = false;
1077                 /* allow mac80211 to determine the timeout */
1078                 wdev->ps_timeout = -1;
1079
1080                 if ((wdev->iftype == NL80211_IFTYPE_STATION ||
1081                      wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
1082                      wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
1083                         dev->priv_flags |= IFF_DONT_BRIDGE;
1084                 break;
1085         case NETDEV_GOING_DOWN:
1086                 cfg80211_leave(rdev, wdev);
1087                 break;
1088         case NETDEV_DOWN:
1089                 cfg80211_update_iface_num(rdev, wdev->iftype, -1);
1090                 if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
1091                         if (WARN_ON(!rdev->scan_req->notified))
1092                                 rdev->scan_req->aborted = true;
1093                         ___cfg80211_scan_done(rdev, false);
1094                 }
1095
1096                 sched_scan_req = rtnl_dereference(rdev->sched_scan_req);
1097                 if (WARN_ON(sched_scan_req &&
1098                             sched_scan_req->dev == wdev->netdev)) {
1099                         __cfg80211_stop_sched_scan(rdev, false);
1100                 }
1101
1102                 rdev->opencount--;
1103                 wake_up(&rdev->dev_wait);
1104                 break;
1105         case NETDEV_UP:
1106                 cfg80211_update_iface_num(rdev, wdev->iftype, 1);
1107                 wdev_lock(wdev);
1108                 switch (wdev->iftype) {
1109 #ifdef CONFIG_CFG80211_WEXT
1110                 case NL80211_IFTYPE_ADHOC:
1111                         cfg80211_ibss_wext_join(rdev, wdev);
1112                         break;
1113                 case NL80211_IFTYPE_STATION:
1114                         cfg80211_mgd_wext_connect(rdev, wdev);
1115                         break;
1116 #endif
1117 #ifdef CONFIG_MAC80211_MESH
1118                 case NL80211_IFTYPE_MESH_POINT:
1119                         {
1120                                 /* backward compat code... */
1121                                 struct mesh_setup setup;
1122                                 memcpy(&setup, &default_mesh_setup,
1123                                                 sizeof(setup));
1124                                  /* back compat only needed for mesh_id */
1125                                 setup.mesh_id = wdev->ssid;
1126                                 setup.mesh_id_len = wdev->mesh_id_up_len;
1127                                 if (wdev->mesh_id_up_len)
1128                                         __cfg80211_join_mesh(rdev, dev,
1129                                                         &setup,
1130                                                         &default_mesh_config);
1131                                 break;
1132                         }
1133 #endif
1134                 default:
1135                         break;
1136                 }
1137                 wdev_unlock(wdev);
1138                 rdev->opencount++;
1139
1140                 /*
1141                  * Configure power management to the driver here so that its
1142                  * correctly set also after interface type changes etc.
1143                  */
1144                 if ((wdev->iftype == NL80211_IFTYPE_STATION ||
1145                      wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) &&
1146                     rdev->ops->set_power_mgmt)
1147                         if (rdev_set_power_mgmt(rdev, dev, wdev->ps,
1148                                                 wdev->ps_timeout)) {
1149                                 /* assume this means it's off */
1150                                 wdev->ps = false;
1151                         }
1152                 break;
1153         case NETDEV_UNREGISTER:
1154                 /*
1155                  * It is possible to get NETDEV_UNREGISTER
1156                  * multiple times. To detect that, check
1157                  * that the interface is still on the list
1158                  * of registered interfaces, and only then
1159                  * remove and clean it up.
1160                  */
1161                 if (!list_empty(&wdev->list)) {
1162                         sysfs_remove_link(&dev->dev.kobj, "phy80211");
1163                         list_del_rcu(&wdev->list);
1164                         rdev->devlist_generation++;
1165                         cfg80211_mlme_purge_registrations(wdev);
1166 #ifdef CONFIG_CFG80211_WEXT
1167                         kzfree(wdev->wext.keys);
1168 #endif
1169                 }
1170                 /*
1171                  * synchronise (so that we won't find this netdev
1172                  * from other code any more) and then clear the list
1173                  * head so that the above code can safely check for
1174                  * !list_empty() to avoid double-cleanup.
1175                  */
1176                 synchronize_rcu();
1177                 INIT_LIST_HEAD(&wdev->list);
1178                 /*
1179                  * Ensure that all events have been processed and
1180                  * freed.
1181                  */
1182                 cfg80211_process_wdev_events(wdev);
1183
1184                 if (WARN_ON(wdev->current_bss)) {
1185                         cfg80211_unhold_bss(wdev->current_bss);
1186                         cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
1187                         wdev->current_bss = NULL;
1188                 }
1189                 break;
1190         case NETDEV_PRE_UP:
1191                 if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)))
1192                         return notifier_from_errno(-EOPNOTSUPP);
1193                 if (rfkill_blocked(rdev->rfkill))
1194                         return notifier_from_errno(-ERFKILL);
1195                 break;
1196         default:
1197                 return NOTIFY_DONE;
1198         }
1199
1200         wireless_nlevent_flush();
1201
1202         return NOTIFY_OK;
1203 }
1204
1205 static struct notifier_block cfg80211_netdev_notifier = {
1206         .notifier_call = cfg80211_netdev_notifier_call,
1207 };
1208
1209 static void __net_exit cfg80211_pernet_exit(struct net *net)
1210 {
1211         struct cfg80211_registered_device *rdev;
1212
1213         rtnl_lock();
1214         list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
1215                 if (net_eq(wiphy_net(&rdev->wiphy), net))
1216                         WARN_ON(cfg80211_switch_netns(rdev, &init_net));
1217         }
1218         rtnl_unlock();
1219 }
1220
1221 static struct pernet_operations cfg80211_pernet_ops = {
1222         .exit = cfg80211_pernet_exit,
1223 };
1224
1225 static int __init cfg80211_init(void)
1226 {
1227         int err;
1228
1229         err = register_pernet_device(&cfg80211_pernet_ops);
1230         if (err)
1231                 goto out_fail_pernet;
1232
1233         err = wiphy_sysfs_init();
1234         if (err)
1235                 goto out_fail_sysfs;
1236
1237         err = register_netdevice_notifier(&cfg80211_netdev_notifier);
1238         if (err)
1239                 goto out_fail_notifier;
1240
1241         err = nl80211_init();
1242         if (err)
1243                 goto out_fail_nl80211;
1244
1245         ieee80211_debugfs_dir = debugfs_create_dir("ieee80211", NULL);
1246
1247         err = regulatory_init();
1248         if (err)
1249                 goto out_fail_reg;
1250
1251         cfg80211_wq = create_singlethread_workqueue("cfg80211");
1252         if (!cfg80211_wq) {
1253                 err = -ENOMEM;
1254                 goto out_fail_wq;
1255         }
1256
1257         return 0;
1258
1259 out_fail_wq:
1260         regulatory_exit();
1261 out_fail_reg:
1262         debugfs_remove(ieee80211_debugfs_dir);
1263         nl80211_exit();
1264 out_fail_nl80211:
1265         unregister_netdevice_notifier(&cfg80211_netdev_notifier);
1266 out_fail_notifier:
1267         wiphy_sysfs_exit();
1268 out_fail_sysfs:
1269         unregister_pernet_device(&cfg80211_pernet_ops);
1270 out_fail_pernet:
1271         return err;
1272 }
1273 subsys_initcall(cfg80211_init);
1274
1275 static void __exit cfg80211_exit(void)
1276 {
1277         debugfs_remove(ieee80211_debugfs_dir);
1278         nl80211_exit();
1279         unregister_netdevice_notifier(&cfg80211_netdev_notifier);
1280         wiphy_sysfs_exit();
1281         regulatory_exit();
1282         unregister_pernet_device(&cfg80211_pernet_ops);
1283         destroy_workqueue(cfg80211_wq);
1284 }
1285 module_exit(cfg80211_exit);