]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/wireless/mac80211_hwsim.c
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[mv-sheeva.git] / drivers / net / wireless / mac80211_hwsim.c
index 0dbda8dfbd9941bcbcaaa36e3d58e3065283b55f..7cd5f56662fcfe1176deeeffc2a010b7ed843a3e 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <linux/list.h>
+#include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <net/dst.h>
 #include <net/xfrm.h>
@@ -32,6 +33,10 @@ static int radios = 2;
 module_param(radios, int, 0444);
 MODULE_PARM_DESC(radios, "Number of simulated radios");
 
+static bool fake_hw_scan;
+module_param(fake_hw_scan, bool, 0444);
+MODULE_PARM_DESC(fake_hw_scan, "Install fake (no-op) hw-scan handler");
+
 /**
  * enum hwsim_regtest - the type of regulatory tests we offer
  *
@@ -767,23 +772,41 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
        }
 }
 
+static int mac80211_hwsim_sta_add(struct ieee80211_hw *hw,
+                                 struct ieee80211_vif *vif,
+                                 struct ieee80211_sta *sta)
+{
+       hwsim_check_magic(vif);
+       hwsim_set_sta_magic(sta);
+
+       return 0;
+}
+
+static int mac80211_hwsim_sta_remove(struct ieee80211_hw *hw,
+                                    struct ieee80211_vif *vif,
+                                    struct ieee80211_sta *sta)
+{
+       hwsim_check_magic(vif);
+       hwsim_clear_sta_magic(sta);
+
+       return 0;
+}
+
 static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw,
                                      struct ieee80211_vif *vif,
                                      enum sta_notify_cmd cmd,
                                      struct ieee80211_sta *sta)
 {
        hwsim_check_magic(vif);
+
        switch (cmd) {
-       case STA_NOTIFY_ADD:
-               hwsim_set_sta_magic(sta);
-               break;
-       case STA_NOTIFY_REMOVE:
-               hwsim_clear_sta_magic(sta);
-               break;
        case STA_NOTIFY_SLEEP:
        case STA_NOTIFY_AWAKE:
                /* TODO: make good use of these flags */
                break;
+       default:
+               WARN(1, "Invalid sta notify: %d\n", cmd);
+               break;
        }
 }
 
@@ -908,8 +931,43 @@ static void mac80211_hwsim_flush(struct ieee80211_hw *hw, bool drop)
         */
 }
 
+struct hw_scan_done {
+       struct delayed_work w;
+       struct ieee80211_hw *hw;
+};
 
-static const struct ieee80211_ops mac80211_hwsim_ops =
+static void hw_scan_done(struct work_struct *work)
+{
+       struct hw_scan_done *hsd =
+               container_of(work, struct hw_scan_done, w.work);
+
+       ieee80211_scan_completed(hsd->hw, false);
+       kfree(hsd);
+}
+
+static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw,
+                                 struct cfg80211_scan_request *req)
+{
+       struct hw_scan_done *hsd = kzalloc(sizeof(*hsd), GFP_KERNEL);
+       int i;
+
+       if (!hsd)
+               return -ENOMEM;
+
+       hsd->hw = hw;
+       INIT_DELAYED_WORK(&hsd->w, hw_scan_done);
+
+       printk(KERN_DEBUG "hwsim scan request\n");
+       for (i = 0; i < req->n_channels; i++)
+               printk(KERN_DEBUG "hwsim scan freq %d\n",
+                       req->channels[i]->center_freq);
+
+       ieee80211_queue_delayed_work(hw, &hsd->w, 2 * HZ);
+
+       return 0;
+}
+
+static struct ieee80211_ops mac80211_hwsim_ops =
 {
        .tx = mac80211_hwsim_tx,
        .start = mac80211_hwsim_start,
@@ -919,6 +977,8 @@ static const struct ieee80211_ops mac80211_hwsim_ops =
        .config = mac80211_hwsim_config,
        .configure_filter = mac80211_hwsim_configure_filter,
        .bss_info_changed = mac80211_hwsim_bss_info_changed,
+       .sta_add = mac80211_hwsim_sta_add,
+       .sta_remove = mac80211_hwsim_sta_remove,
        .sta_notify = mac80211_hwsim_sta_notify,
        .set_tim = mac80211_hwsim_set_tim,
        .conf_tx = mac80211_hwsim_conf_tx,
@@ -1119,6 +1179,9 @@ static int __init init_mac80211_hwsim(void)
        if (radios < 1 || radios > 100)
                return -EINVAL;
 
+       if (fake_hw_scan)
+               mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
+
        spin_lock_init(&hwsim_radio_lock);
        INIT_LIST_HEAD(&hwsim_radios);