7 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/module.h>
12 #include <linux/list.h>
13 #include <linux/slab.h>
17 #include <linux/device.h>
19 #include <linux/rtnetlink.h>
20 #include <linux/sched.h>
31 #define PHY_NAME "phy"
44 static struct dentry *ieee80211_debugfs_dir;
49 static bool cfg80211_disable_40mhz_24ghz;
52 "Disable 40MHz support in the 2.4GHz band");
59 if (!wiphy_idx_valid(wiphy_idx))
62 assert_cfg80211_lock();
65 if (rdev->wiphy_idx == wiphy_idx) {
79 rdev = wiphy_to_dev(wiphy);
88 if (!wiphy_idx_valid(wiphy_idx))
91 assert_cfg80211_lock();
127 assert_cfg80211_lock();
134 while (wiphy_idx /= 10)
146 if (
strcmp(newname, dev_name(&rdev->wiphy.dev)) == 0)
151 if (
strcmp(newname, dev_name(&rdev2->wiphy.dev)) == 0)
158 if (rdev->wiphy.debugfsdir &&
160 rdev->wiphy.debugfsdir,
161 rdev->wiphy.debugfsdir->d_parent,
163 pr_err(
"failed to rename debugfs dir to %s!\n", newname);
191 net = wiphy_net(&rdev->wiphy);
207 wiphy_net_set(&rdev->wiphy, net);
209 err =
device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev));
219 rdev->
ops->rfkill_poll(&rdev->wiphy);
222 static int cfg80211_rfkill_set_block(
void *data,
bool blocked)
243 rdev->
ops->stop_p2p_device(&rdev->wiphy, wdev);
266 static void cfg80211_event_work(
struct work_struct *work)
274 cfg80211_lock_rdev(rdev);
277 cfg80211_unlock_rdev(rdev);
285 static int wiphy_counter;
299 alloc_size =
sizeof(*rdev) + sizeof_priv;
332 #ifdef CONFIG_CFG80211_WEXT
338 rdev->wiphy.dev.platform_data =
rdev;
340 #ifdef CONFIG_CFG80211_DEFAULT_PS
344 wiphy_net_set(&rdev->wiphy, &
init_net);
346 rdev->
rfkill_ops.set_block = cfg80211_rfkill_set_block;
367 rdev->wiphy.retry_short = 7;
368 rdev->wiphy.retry_long = 4;
369 rdev->wiphy.frag_threshold = (
u32) -1;
370 rdev->wiphy.rts_threshold = (
u32) -1;
371 rdev->wiphy.coverage_class = 0;
377 static int wiphy_verify_combinations(
struct wiphy *
wiphy)
414 if (
WARN_ON(types & all_iftypes))
416 all_iftypes |= types;
453 bool have_band =
false;
485 res = wiphy_verify_combinations(wiphy);
511 if (cfg80211_disable_40mhz_24ghz &&
513 sband->
ht_cap.ht_supported) {
544 if (rdev->wiphy.
wowlan.n_patterns) {
546 rdev->wiphy.
wowlan.pattern_min_len >
547 rdev->wiphy.
wowlan.pattern_max_len))
570 rdev->wiphy.debugfsdir =
572 ieee80211_debugfs_dir);
573 if (IS_ERR(rdev->wiphy.debugfsdir))
574 rdev->wiphy.debugfsdir =
NULL;
599 rdev->wiphy.registered =
true;
613 if (!rdev->
ops->rfkill_poll)
633 rdev->wiphy.registered =
false;
657 list_del_rcu(&rdev->
list);
670 cfg80211_lock_rdev(rdev);
672 cfg80211_unlock_rdev(rdev);
689 if (rdev->
wowlan && rdev->
ops->set_wakeup)
690 rdev->
ops->set_wakeup(&rdev->wiphy,
false);
691 cfg80211_rdev_free_wowlan(rdev);
722 static void wdev_cleanup_work(
struct work_struct *work)
728 rdev = wiphy_to_dev(wdev->
wiphy);
730 cfg80211_lock_rdev(rdev);
737 cfg80211_unlock_rdev(rdev);
766 list_del_rcu(&wdev->
list);
773 rdev->
ops->stop_p2p_device(&rdev->wiphy, wdev);
799 static int cfg80211_netdev_notifier_call(
struct notifier_block *nb,
811 rdev = wiphy_to_dev(wdev->
wiphy);
841 pr_err(
"failed to add phy80211 symlink to netdev!\n");
846 #ifdef CONFIG_CFG80211_WEXT
847 wdev->wext.default_key = -1;
848 wdev->wext.default_mgmt_key = -1;
879 #ifdef CONFIG_CFG80211_WEXT
880 kfree(wdev->wext.ie);
881 wdev->wext.ie =
NULL;
882 wdev->wext.ie_len = 0;
920 cfg80211_lock_rdev(rdev);
924 #ifdef CONFIG_CFG80211_WEXT
932 #ifdef CONFIG_MAC80211_MESH
955 cfg80211_unlock_rdev(rdev);
963 rdev->
ops->set_power_mgmt)
964 if (rdev->
ops->set_power_mgmt(wdev->
wiphy, dev,
985 if (!list_empty(&wdev->
list)) {
987 list_del_rcu(&wdev->
list);
990 #ifdef CONFIG_CFG80211_WEXT
991 kfree(wdev->wext.keys);
1002 INIT_LIST_HEAD(&wdev->
list);
1013 return notifier_from_errno(-
ERFKILL);
1015 ret = cfg80211_can_add_interface(rdev, wdev->
iftype);
1018 return notifier_from_errno(ret);
1026 .notifier_call = cfg80211_netdev_notifier_call,
1036 if (net_eq(wiphy_net(&rdev->wiphy), net))
1044 .exit = cfg80211_pernet_exit,
1047 static int __init cfg80211_init(
void)
1053 goto out_fail_pernet;
1057 goto out_fail_sysfs;
1061 goto out_fail_notifier;
1065 goto out_fail_nl80211;
1094 static void __exit cfg80211_exit(
void)