aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mac80211_hwsim.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2010-02-03 04:47:55 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-02-08 16:50:52 -0500
commit690680360cd22b55235481ca3421a3450a96138a (patch)
tree67b730c71d23c24a68ffc0fc85847aa17069fa64 /drivers/net/wireless/mac80211_hwsim.c
parent6e7e6213e4956828927c30e3ef5a42812d00c650 (diff)
mac80211_hwsim: add fake hw scan handler
For debugging hardware scan trigger/complete functionality, it was useful to have code in hwsim that pretends to do a hardware scan. This code could be extended to actually do the scan, but for now it was sufficient for me to only pretend. Since hwsim was written to ease debugging, it only makes sense to add it to it permanently. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mac80211_hwsim.c')
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c44
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;
32module_param(radios, int, 0444); 32module_param(radios, int, 0444);
33MODULE_PARM_DESC(radios, "Number of simulated radios"); 33MODULE_PARM_DESC(radios, "Number of simulated radios");
34 34
35static bool fake_hw_scan;
36module_param(fake_hw_scan, bool, 0444);
37MODULE_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
915struct hw_scan_done {
916 struct delayed_work w;
917 struct ieee80211_hw *hw;
918};
911 919
912static const struct ieee80211_ops mac80211_hwsim_ops = 920static 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
929static 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
951static 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