diff options
Diffstat (limited to 'drivers/net/wireless/mac80211_hwsim.c')
-rw-r--r-- | drivers/net/wireless/mac80211_hwsim.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 0dbda8dfbd99..00ffe6dd435e 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -32,6 +32,10 @@ static int radios = 2; | |||
32 | module_param(radios, int, 0444); | 32 | module_param(radios, int, 0444); |
33 | MODULE_PARM_DESC(radios, "Number of simulated radios"); | 33 | MODULE_PARM_DESC(radios, "Number of simulated radios"); |
34 | 34 | ||
35 | static bool fake_hw_scan; | ||
36 | module_param(fake_hw_scan, bool, 0444); | ||
37 | MODULE_PARM_DESC(fake_hw_scan, "Install fake (no-op) hw-scan handler"); | ||
38 | |||
35 | /** | 39 | /** |
36 | * enum hwsim_regtest - the type of regulatory tests we offer | 40 | * enum hwsim_regtest - the type of regulatory tests we offer |
37 | * | 41 | * |
@@ -908,8 +912,43 @@ static void mac80211_hwsim_flush(struct ieee80211_hw *hw, bool drop) | |||
908 | */ | 912 | */ |
909 | } | 913 | } |
910 | 914 | ||
915 | struct hw_scan_done { | ||
916 | struct delayed_work w; | ||
917 | struct ieee80211_hw *hw; | ||
918 | }; | ||
911 | 919 | ||
912 | static const struct ieee80211_ops mac80211_hwsim_ops = | 920 | static void hw_scan_done(struct work_struct *work) |
921 | { | ||
922 | struct hw_scan_done *hsd = | ||
923 | container_of(work, struct hw_scan_done, w.work); | ||
924 | |||
925 | ieee80211_scan_completed(hsd->hw, false); | ||
926 | kfree(hsd); | ||
927 | } | ||
928 | |||
929 | static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw, | ||
930 | struct cfg80211_scan_request *req) | ||
931 | { | ||
932 | struct hw_scan_done *hsd = kzalloc(sizeof(*hsd), GFP_KERNEL); | ||
933 | int i; | ||
934 | |||
935 | if (!hsd) | ||
936 | return -ENOMEM; | ||
937 | |||
938 | hsd->hw = hw; | ||
939 | INIT_DELAYED_WORK(&hsd->w, hw_scan_done); | ||
940 | |||
941 | printk(KERN_DEBUG "hwsim scan request\n"); | ||
942 | for (i = 0; i < req->n_channels; i++) | ||
943 | printk(KERN_DEBUG "hwsim scan freq %d\n", | ||
944 | req->channels[i]->center_freq); | ||
945 | |||
946 | ieee80211_queue_delayed_work(hw, &hsd->w, 2 * HZ); | ||
947 | |||
948 | return 0; | ||
949 | } | ||
950 | |||
951 | static struct ieee80211_ops mac80211_hwsim_ops = | ||
913 | { | 952 | { |
914 | .tx = mac80211_hwsim_tx, | 953 | .tx = mac80211_hwsim_tx, |
915 | .start = mac80211_hwsim_start, | 954 | .start = mac80211_hwsim_start, |
@@ -1119,6 +1158,9 @@ static int __init init_mac80211_hwsim(void) | |||
1119 | if (radios < 1 || radios > 100) | 1158 | if (radios < 1 || radios > 100) |
1120 | return -EINVAL; | 1159 | return -EINVAL; |
1121 | 1160 | ||
1161 | if (fake_hw_scan) | ||
1162 | mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan; | ||
1163 | |||
1122 | spin_lock_init(&hwsim_radio_lock); | 1164 | spin_lock_init(&hwsim_radio_lock); |
1123 | INIT_LIST_HEAD(&hwsim_radios); | 1165 | INIT_LIST_HEAD(&hwsim_radios); |
1124 | 1166 | ||