mac80211: add support for HW scheduled scan

Implement support for HW scheduled scan.  The mac80211 code doesn't perform
scheduled scans itself, but calls the driver to start and stop scheduled
scans.

This patch also creates a trace event class to be used by drv_hw_scan
and the new drv_sched_scan_start and drv_sched_stop functions, in
order to avoid duplicate code.

Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Luciano Coelho
2011-05-11 17:09:36 +03:00
committed by John W. Linville
parent 807f8a8c30
commit 79f460ca49
8 changed files with 292 additions and 22 deletions

View File

@@ -15,6 +15,7 @@
#include <linux/if_arp.h>
#include <linux/rtnetlink.h>
#include <linux/pm_qos_params.h>
#include <linux/slab.h>
#include <net/sch_generic.h>
#include <linux/slab.h>
#include <net/mac80211.h>
@@ -850,3 +851,101 @@ void ieee80211_scan_cancel(struct ieee80211_local *local)
}
mutex_unlock(&local->mtx);
}
int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
struct cfg80211_sched_scan_request *req)
{
struct ieee80211_local *local = sdata->local;
int ret, i;
mutex_lock(&sdata->local->mtx);
if (local->sched_scanning) {
ret = -EBUSY;
goto out;
}
if (!local->ops->sched_scan_start) {
ret = -ENOTSUPP;
goto out;
}
for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
local->sched_scan_ies.ie[i] = kzalloc(2 +
IEEE80211_MAX_SSID_LEN +
local->scan_ies_len,
GFP_KERNEL);
if (!local->sched_scan_ies.ie[i]) {
ret = -ENOMEM;
goto out_free;
}
local->sched_scan_ies.len[i] =
ieee80211_build_preq_ies(local,
local->sched_scan_ies.ie[i],
req->ie, req->ie_len, i,
(u32) -1, 0);
}
ret = drv_sched_scan_start(local, sdata, req,
&local->sched_scan_ies);
if (ret == 0) {
local->sched_scanning = true;
goto out;
}
out_free:
while (i > 0)
kfree(local->sched_scan_ies.ie[--i]);
out:
mutex_unlock(&sdata->local->mtx);
return ret;
}
int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata,
bool driver_initiated)
{
struct ieee80211_local *local = sdata->local;
int ret = 0, i;
mutex_lock(&sdata->local->mtx);
if (!local->ops->sched_scan_stop) {
ret = -ENOTSUPP;
goto out;
}
if (local->sched_scanning) {
for (i = 0; i < IEEE80211_NUM_BANDS; i++)
kfree(local->sched_scan_ies.ie[i]);
if (!driver_initiated)
drv_sched_scan_stop(local, sdata);
local->sched_scanning = false;
}
out:
mutex_unlock(&sdata->local->mtx);
return ret;
}
void ieee80211_sched_scan_results(struct ieee80211_hw *hw)
{
struct ieee80211_local *local = hw_to_local(hw);
trace_api_sched_scan_results(local);
cfg80211_sched_scan_results(hw->wiphy);
}
EXPORT_SYMBOL(ieee80211_sched_scan_results);
void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
{
struct ieee80211_local *local = hw_to_local(hw);
trace_api_sched_scan_stopped(local);
cfg80211_sched_scan_stopped(hw->wiphy);
}
EXPORT_SYMBOL(ieee80211_sched_scan_stopped);