Skip to content

Commit

Permalink
mac80211_hwsim: add sw_scan sw_scan_complete
Browse files Browse the repository at this point in the history
Simple pre-scan and scan complete callbacks, this at least shows
to me that mac80211 will issue two scans at the same time on the
same wiphy.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Luis R. Rodriguez authored and John W. Linville committed Apr 8, 2010
1 parent 4f59fce commit f74cb0f
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ struct mac80211_hwsim_data {
struct ieee80211_channel *channel;
unsigned long beacon_int; /* in jiffies unit */
unsigned int rx_filter;
bool started, idle;
bool started, idle, scanning;
struct mutex mutex;
struct timer_list beacon_timer;
enum ps_mode {
PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL
Expand Down Expand Up @@ -956,16 +957,46 @@ static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw,
hsd->hw = hw;
INIT_DELAYED_WORK(&hsd->w, hw_scan_done);

printk(KERN_DEBUG "hwsim scan request\n");
printk(KERN_DEBUG "hwsim hw_scan request\n");
for (i = 0; i < req->n_channels; i++)
printk(KERN_DEBUG "hwsim scan freq %d\n",
printk(KERN_DEBUG "hwsim hw_scan freq %d\n",
req->channels[i]->center_freq);

ieee80211_queue_delayed_work(hw, &hsd->w, 2 * HZ);

return 0;
}

static void mac80211_hwsim_sw_scan(struct ieee80211_hw *hw)
{
struct mac80211_hwsim_data *hwsim = hw->priv;

mutex_lock(&hwsim->mutex);

if (hwsim->scanning) {
printk(KERN_DEBUG "two hwsim sw_scans detected!\n");
goto out;
}

printk(KERN_DEBUG "hwsim sw_scan request, prepping stuff\n");
hwsim->scanning = true;

out:
mutex_unlock(&hwsim->mutex);
}

static void mac80211_hwsim_sw_scan_complete(struct ieee80211_hw *hw)
{
struct mac80211_hwsim_data *hwsim = hw->priv;

mutex_lock(&hwsim->mutex);

printk(KERN_DEBUG "hwsim sw_scan_complete\n");
hwsim->scanning = true;

mutex_unlock(&hwsim->mutex);
}

static struct ieee80211_ops mac80211_hwsim_ops =
{
.tx = mac80211_hwsim_tx,
Expand All @@ -983,6 +1014,8 @@ static struct ieee80211_ops mac80211_hwsim_ops =
.conf_tx = mac80211_hwsim_conf_tx,
CFG80211_TESTMODE_CMD(mac80211_hwsim_testmode_cmd)
.ampdu_action = mac80211_hwsim_ampdu_action,
.sw_scan_start = mac80211_hwsim_sw_scan,
.sw_scan_complete = mac80211_hwsim_sw_scan_complete,
.flush = mac80211_hwsim_flush,
};

Expand Down Expand Up @@ -1178,8 +1211,11 @@ static int __init init_mac80211_hwsim(void)
if (radios < 1 || radios > 100)
return -EINVAL;

if (fake_hw_scan)
if (fake_hw_scan) {
mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
mac80211_hwsim_ops.sw_scan_start = NULL;
mac80211_hwsim_ops.sw_scan_complete = NULL;
}

spin_lock_init(&hwsim_radio_lock);
INIT_LIST_HEAD(&hwsim_radios);
Expand Down Expand Up @@ -1284,6 +1320,7 @@ static int __init init_mac80211_hwsim(void)
}
/* By default all radios are belonging to the first group */
data->group = 1;
mutex_init(&data->mutex);

/* Work to be done prior to ieee80211_register_hw() */
switch (regtest) {
Expand Down

0 comments on commit f74cb0f

Please sign in to comment.