2010-07-08 14:50:06 +00:00
|
|
|
/*
|
|
|
|
* This file is part of wl1271
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009-2010 Nokia Corporation
|
|
|
|
*
|
|
|
|
* Contact: Luciano Coelho <luciano.coelho@nokia.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/ieee80211.h>
|
|
|
|
|
2011-11-21 17:25:24 +00:00
|
|
|
#include "wlcore.h"
|
2011-10-07 08:02:42 +00:00
|
|
|
#include "debug.h"
|
2010-11-08 11:20:10 +00:00
|
|
|
#include "cmd.h"
|
|
|
|
#include "scan.h"
|
|
|
|
#include "acx.h"
|
2011-03-01 10:27:26 +00:00
|
|
|
#include "ps.h"
|
2011-09-19 10:51:42 +00:00
|
|
|
#include "tx.h"
|
2010-07-08 14:50:06 +00:00
|
|
|
|
2010-08-24 03:28:03 +00:00
|
|
|
void wl1271_scan_complete_work(struct work_struct *work)
|
|
|
|
{
|
2010-09-21 04:23:32 +00:00
|
|
|
struct delayed_work *dwork;
|
|
|
|
struct wl1271 *wl;
|
2011-10-05 09:55:52 +00:00
|
|
|
struct ieee80211_vif *vif;
|
2011-10-05 09:55:45 +00:00
|
|
|
struct wl12xx_vif *wlvif;
|
wl12xx: replace dummy_join with ROC/CROC commands
The ROC command asks the fw stay on the channel of the given
hlid. it currently has 2 primary functions:
1. Allow tx/rx from the device role.
In order to tx/rx packets while the stations is not associated
(e.g. auth req/resp), the device role has to be used, along
with ROC on its link.
Keep the logic similiar to the one used in dummy_join. However,
since we can't scan while we ROC, we add CROC before starting
a scan, and ROC again (if needed) on scan complete.
2. Keeping the antenna for a specific link.
We ROC until the connection was completed (after EAPOLs exchange)
in order to prevent BT coex operations from taking the antenna
and failing the connection (after this stage, psm can be used).
During association, we ROC on the station role, and then CROC
the device role, thus assuring being ROC during all the connection
process.
Delete the WL1271_FLAG_JOINED flag, and use a roc bitmap
to indicate what roles are currently ROCed.
Add wl12xx_roc/croc functions in order to wrap the roc/croc
commands while taking care of the roc bitmap.
The current ROC/CROC state-machine is a bit complicated. In
the future we'll probably want to use wpa_supplicant to control
the ROC during connection.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
2011-08-14 10:17:17 +00:00
|
|
|
int ret;
|
2010-09-21 04:23:32 +00:00
|
|
|
|
|
|
|
dwork = container_of(work, struct delayed_work, work);
|
|
|
|
wl = container_of(dwork, struct wl1271, scan_complete_work);
|
2010-08-24 03:28:03 +00:00
|
|
|
|
|
|
|
wl1271_debug(DEBUG_SCAN, "Scanning complete");
|
|
|
|
|
|
|
|
mutex_lock(&wl->mutex);
|
2010-09-21 04:23:30 +00:00
|
|
|
|
2011-03-01 10:27:26 +00:00
|
|
|
if (wl->state == WL1271_STATE_OFF)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (wl->scan.state == WL1271_SCAN_STATE_IDLE)
|
|
|
|
goto out;
|
2010-09-21 04:23:30 +00:00
|
|
|
|
2011-10-05 09:55:52 +00:00
|
|
|
vif = wl->scan_vif;
|
|
|
|
wlvif = wl12xx_vif_to_data(vif);
|
2011-10-05 09:55:45 +00:00
|
|
|
|
2012-03-03 20:18:00 +00:00
|
|
|
/*
|
|
|
|
* Rearm the tx watchdog just before idling scan. This
|
|
|
|
* prevents just-finished scans from triggering the watchdog
|
|
|
|
*/
|
|
|
|
wl12xx_rearm_tx_watchdog_locked(wl);
|
|
|
|
|
2010-08-24 03:28:03 +00:00
|
|
|
wl->scan.state = WL1271_SCAN_STATE_IDLE;
|
2011-03-21 21:16:14 +00:00
|
|
|
memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
|
2010-10-26 11:24:38 +00:00
|
|
|
wl->scan.req = NULL;
|
2011-10-05 09:55:39 +00:00
|
|
|
wl->scan_vif = NULL;
|
2010-09-21 04:23:32 +00:00
|
|
|
|
wl12xx: replace dummy_join with ROC/CROC commands
The ROC command asks the fw stay on the channel of the given
hlid. it currently has 2 primary functions:
1. Allow tx/rx from the device role.
In order to tx/rx packets while the stations is not associated
(e.g. auth req/resp), the device role has to be used, along
with ROC on its link.
Keep the logic similiar to the one used in dummy_join. However,
since we can't scan while we ROC, we add CROC before starting
a scan, and ROC again (if needed) on scan complete.
2. Keeping the antenna for a specific link.
We ROC until the connection was completed (after EAPOLs exchange)
in order to prevent BT coex operations from taking the antenna
and failing the connection (after this stage, psm can be used).
During association, we ROC on the station role, and then CROC
the device role, thus assuring being ROC during all the connection
process.
Delete the WL1271_FLAG_JOINED flag, and use a roc bitmap
to indicate what roles are currently ROCed.
Add wl12xx_roc/croc functions in order to wrap the roc/croc
commands while taking care of the roc bitmap.
The current ROC/CROC state-machine is a bit complicated. In
the future we'll probably want to use wpa_supplicant to control
the ROC during connection.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
2011-08-14 10:17:17 +00:00
|
|
|
ret = wl1271_ps_elp_wakeup(wl);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
2011-10-10 08:13:00 +00:00
|
|
|
if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) {
|
wl12xx: replace dummy_join with ROC/CROC commands
The ROC command asks the fw stay on the channel of the given
hlid. it currently has 2 primary functions:
1. Allow tx/rx from the device role.
In order to tx/rx packets while the stations is not associated
(e.g. auth req/resp), the device role has to be used, along
with ROC on its link.
Keep the logic similiar to the one used in dummy_join. However,
since we can't scan while we ROC, we add CROC before starting
a scan, and ROC again (if needed) on scan complete.
2. Keeping the antenna for a specific link.
We ROC until the connection was completed (after EAPOLs exchange)
in order to prevent BT coex operations from taking the antenna
and failing the connection (after this stage, psm can be used).
During association, we ROC on the station role, and then CROC
the device role, thus assuring being ROC during all the connection
process.
Delete the WL1271_FLAG_JOINED flag, and use a roc bitmap
to indicate what roles are currently ROCed.
Add wl12xx_roc/croc functions in order to wrap the roc/croc
commands while taking care of the roc bitmap.
The current ROC/CROC state-machine is a bit complicated. In
the future we'll probably want to use wpa_supplicant to control
the ROC during connection.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
2011-08-14 10:17:17 +00:00
|
|
|
/* restore hardware connection monitoring template */
|
2011-10-10 08:12:53 +00:00
|
|
|
wl1271_cmd_build_ap_probe_req(wl, wlvif, wlvif->probereq);
|
2011-08-14 10:17:26 +00:00
|
|
|
}
|
|
|
|
|
wl12xx: replace dummy_join with ROC/CROC commands
The ROC command asks the fw stay on the channel of the given
hlid. it currently has 2 primary functions:
1. Allow tx/rx from the device role.
In order to tx/rx packets while the stations is not associated
(e.g. auth req/resp), the device role has to be used, along
with ROC on its link.
Keep the logic similiar to the one used in dummy_join. However,
since we can't scan while we ROC, we add CROC before starting
a scan, and ROC again (if needed) on scan complete.
2. Keeping the antenna for a specific link.
We ROC until the connection was completed (after EAPOLs exchange)
in order to prevent BT coex operations from taking the antenna
and failing the connection (after this stage, psm can be used).
During association, we ROC on the station role, and then CROC
the device role, thus assuring being ROC during all the connection
process.
Delete the WL1271_FLAG_JOINED flag, and use a roc bitmap
to indicate what roles are currently ROCed.
Add wl12xx_roc/croc functions in order to wrap the roc/croc
commands while taking care of the roc bitmap.
The current ROC/CROC state-machine is a bit complicated. In
the future we'll probably want to use wpa_supplicant to control
the ROC during connection.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
2011-08-14 10:17:17 +00:00
|
|
|
wl1271_ps_elp_sleep(wl);
|
2010-11-24 06:16:57 +00:00
|
|
|
|
2010-09-21 04:23:32 +00:00
|
|
|
if (wl->scan.failed) {
|
|
|
|
wl1271_info("Scan completed due to error.");
|
2011-06-06 11:57:05 +00:00
|
|
|
wl12xx_queue_recovery_work(wl);
|
2010-09-21 04:23:32 +00:00
|
|
|
}
|
2011-03-01 10:27:26 +00:00
|
|
|
|
wl12xx: replace dummy_join with ROC/CROC commands
The ROC command asks the fw stay on the channel of the given
hlid. it currently has 2 primary functions:
1. Allow tx/rx from the device role.
In order to tx/rx packets while the stations is not associated
(e.g. auth req/resp), the device role has to be used, along
with ROC on its link.
Keep the logic similiar to the one used in dummy_join. However,
since we can't scan while we ROC, we add CROC before starting
a scan, and ROC again (if needed) on scan complete.
2. Keeping the antenna for a specific link.
We ROC until the connection was completed (after EAPOLs exchange)
in order to prevent BT coex operations from taking the antenna
and failing the connection (after this stage, psm can be used).
During association, we ROC on the station role, and then CROC
the device role, thus assuring being ROC during all the connection
process.
Delete the WL1271_FLAG_JOINED flag, and use a roc bitmap
to indicate what roles are currently ROCed.
Add wl12xx_roc/croc functions in order to wrap the roc/croc
commands while taking care of the roc bitmap.
The current ROC/CROC state-machine is a bit complicated. In
the future we'll probably want to use wpa_supplicant to control
the ROC during connection.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
2011-08-14 10:17:17 +00:00
|
|
|
ieee80211_scan_completed(wl->hw, false);
|
|
|
|
|
2011-03-01 10:27:26 +00:00
|
|
|
out:
|
2010-10-26 11:24:38 +00:00
|
|
|
mutex_unlock(&wl->mutex);
|
|
|
|
|
2010-08-24 03:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
static int wl1271_get_scan_channels(struct wl1271 *wl,
|
|
|
|
struct cfg80211_scan_request *req,
|
|
|
|
struct basic_scan_channel_params *channels,
|
|
|
|
enum ieee80211_band band, bool passive)
|
2010-07-08 14:50:06 +00:00
|
|
|
{
|
2010-09-21 06:14:31 +00:00
|
|
|
struct conf_scan_settings *c = &wl->conf.scan;
|
2010-07-08 14:50:07 +00:00
|
|
|
int i, j;
|
|
|
|
u32 flags;
|
2010-07-08 14:50:06 +00:00
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
for (i = 0, j = 0;
|
|
|
|
i < req->n_channels && j < WL1271_SCAN_MAX_CHANNELS;
|
|
|
|
i++) {
|
|
|
|
flags = req->channels[i]->flags;
|
2010-07-08 14:50:06 +00:00
|
|
|
|
2011-03-21 21:16:14 +00:00
|
|
|
if (!test_bit(i, wl->scan.scanned_ch) &&
|
2010-07-08 14:50:07 +00:00
|
|
|
!(flags & IEEE80211_CHAN_DISABLED) &&
|
2011-09-22 07:06:10 +00:00
|
|
|
(req->channels[i]->band == band) &&
|
|
|
|
/*
|
|
|
|
* In passive scans, we scan all remaining
|
|
|
|
* channels, even if not marked as such.
|
|
|
|
* In active scans, we only scan channels not
|
|
|
|
* marked as passive.
|
|
|
|
*/
|
|
|
|
(passive || !(flags & IEEE80211_CHAN_PASSIVE_SCAN))) {
|
2010-07-08 14:50:07 +00:00
|
|
|
wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
|
|
|
|
req->channels[i]->band,
|
|
|
|
req->channels[i]->center_freq);
|
|
|
|
wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
|
|
|
|
req->channels[i]->hw_value,
|
|
|
|
req->channels[i]->flags);
|
|
|
|
wl1271_debug(DEBUG_SCAN,
|
|
|
|
"max_antenna_gain %d, max_power %d",
|
|
|
|
req->channels[i]->max_antenna_gain,
|
|
|
|
req->channels[i]->max_power);
|
|
|
|
wl1271_debug(DEBUG_SCAN, "beacon_found %d",
|
|
|
|
req->channels[i]->beacon_found);
|
2010-07-08 14:50:06 +00:00
|
|
|
|
2010-09-21 06:14:31 +00:00
|
|
|
if (!passive) {
|
|
|
|
channels[j].min_duration =
|
|
|
|
cpu_to_le32(c->min_dwell_time_active);
|
|
|
|
channels[j].max_duration =
|
|
|
|
cpu_to_le32(c->max_dwell_time_active);
|
|
|
|
} else {
|
|
|
|
channels[j].min_duration =
|
|
|
|
cpu_to_le32(c->min_dwell_time_passive);
|
|
|
|
channels[j].max_duration =
|
|
|
|
cpu_to_le32(c->max_dwell_time_passive);
|
|
|
|
}
|
2010-07-08 14:50:07 +00:00
|
|
|
channels[j].early_termination = 0;
|
2010-07-08 14:50:08 +00:00
|
|
|
channels[j].tx_power_att = req->channels[i]->max_power;
|
2010-07-08 14:50:07 +00:00
|
|
|
channels[j].channel = req->channels[i]->hw_value;
|
|
|
|
|
|
|
|
memset(&channels[j].bssid_lsb, 0xff, 4);
|
|
|
|
memset(&channels[j].bssid_msb, 0xff, 2);
|
|
|
|
|
|
|
|
/* Mark the channels we already used */
|
2011-03-21 21:16:14 +00:00
|
|
|
set_bit(i, wl->scan.scanned_ch);
|
2010-07-08 14:50:07 +00:00
|
|
|
|
2010-07-08 14:50:06 +00:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
return j;
|
|
|
|
}
|
2010-07-08 14:50:06 +00:00
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
#define WL1271_NOTHING_TO_SCAN 1
|
|
|
|
|
2011-10-05 09:55:39 +00:00
|
|
|
static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif,
|
|
|
|
enum ieee80211_band band,
|
|
|
|
bool passive, u32 basic_rate)
|
2010-07-08 14:50:07 +00:00
|
|
|
{
|
2011-10-05 09:55:51 +00:00
|
|
|
struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
|
2010-07-08 14:50:07 +00:00
|
|
|
struct wl1271_cmd_scan *cmd;
|
|
|
|
struct wl1271_cmd_trigger_scan_to *trigger;
|
|
|
|
int ret;
|
|
|
|
u16 scan_options = 0;
|
|
|
|
|
2011-09-22 07:06:10 +00:00
|
|
|
/* skip active scans if we don't have SSIDs */
|
|
|
|
if (!passive && wl->scan.req->n_ssids == 0)
|
|
|
|
return WL1271_NOTHING_TO_SCAN;
|
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
|
|
|
|
trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
|
|
|
|
if (!cmd || !trigger) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
2010-07-08 14:50:06 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 11:54:28 +00:00
|
|
|
if (wl->conf.scan.split_scan_timeout)
|
|
|
|
scan_options |= WL1271_SCAN_OPT_SPLIT_SCAN;
|
|
|
|
|
2011-09-22 07:06:10 +00:00
|
|
|
if (passive)
|
2010-07-08 14:50:07 +00:00
|
|
|
scan_options |= WL1271_SCAN_OPT_PASSIVE;
|
2010-08-04 01:36:32 +00:00
|
|
|
|
2012-02-02 11:54:26 +00:00
|
|
|
if (wlvif->bss_type == BSS_TYPE_AP_BSS ||
|
|
|
|
test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
|
2012-01-31 09:57:17 +00:00
|
|
|
cmd->params.role_id = wlvif->role_id;
|
|
|
|
else
|
|
|
|
cmd->params.role_id = wlvif->dev_role_id;
|
|
|
|
|
2012-02-02 11:54:26 +00:00
|
|
|
if (WARN_ON(cmd->params.role_id == WL12XX_INVALID_ROLE_ID)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
cmd->params.scan_options = cpu_to_le16(scan_options);
|
|
|
|
|
|
|
|
cmd->params.n_ch = wl1271_get_scan_channels(wl, wl->scan.req,
|
|
|
|
cmd->channels,
|
|
|
|
band, passive);
|
|
|
|
if (cmd->params.n_ch == 0) {
|
|
|
|
ret = WL1271_NOTHING_TO_SCAN;
|
2010-07-08 14:50:06 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
cmd->params.tx_rate = cpu_to_le32(basic_rate);
|
2010-09-21 06:14:31 +00:00
|
|
|
cmd->params.n_probe_reqs = wl->conf.scan.num_probe_reqs;
|
2012-02-02 11:54:28 +00:00
|
|
|
cmd->params.tid_trigger = CONF_TX_AC_ANY_TID;
|
2010-07-08 14:50:07 +00:00
|
|
|
cmd->params.scan_tag = WL1271_SCAN_DEFAULT_TAG;
|
|
|
|
|
|
|
|
if (band == IEEE80211_BAND_2GHZ)
|
|
|
|
cmd->params.band = WL1271_SCAN_BAND_2_4_GHZ;
|
|
|
|
else
|
|
|
|
cmd->params.band = WL1271_SCAN_BAND_5_GHZ;
|
|
|
|
|
|
|
|
if (wl->scan.ssid_len && wl->scan.ssid) {
|
|
|
|
cmd->params.ssid_len = wl->scan.ssid_len;
|
|
|
|
memcpy(cmd->params.ssid, wl->scan.ssid, wl->scan.ssid_len);
|
|
|
|
}
|
|
|
|
|
2011-10-05 09:55:39 +00:00
|
|
|
memcpy(cmd->addr, vif->addr, ETH_ALEN);
|
2011-08-14 10:17:10 +00:00
|
|
|
|
2012-01-31 09:57:16 +00:00
|
|
|
ret = wl12xx_cmd_build_probe_req(wl, wlvif,
|
2012-01-31 09:57:17 +00:00
|
|
|
cmd->params.role_id, band,
|
2012-01-31 09:57:16 +00:00
|
|
|
wl->scan.ssid, wl->scan.ssid_len,
|
|
|
|
wl->scan.req->ie,
|
2012-06-27 10:01:44 +00:00
|
|
|
wl->scan.req->ie_len, false);
|
2010-07-08 14:50:07 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("PROBE request template failed");
|
2010-07-08 14:50:06 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-02-02 11:54:28 +00:00
|
|
|
trigger->timeout = cpu_to_le32(wl->conf.scan.split_scan_timeout);
|
2010-07-08 14:50:06 +00:00
|
|
|
ret = wl1271_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
|
|
|
|
sizeof(*trigger), 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("trigger scan to failed for hw scan");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
wl1271_dump(DEBUG_SCAN, "SCAN: ", cmd, sizeof(*cmd));
|
2010-07-08 14:50:06 +00:00
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
ret = wl1271_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd), 0);
|
2010-07-08 14:50:06 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("SCAN failed");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2010-07-08 14:50:07 +00:00
|
|
|
kfree(cmd);
|
2010-07-08 14:50:06 +00:00
|
|
|
kfree(trigger);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-05 09:55:39 +00:00
|
|
|
void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif)
|
2010-07-08 14:50:06 +00:00
|
|
|
{
|
2011-10-10 08:12:53 +00:00
|
|
|
struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
|
2010-09-21 04:23:32 +00:00
|
|
|
int ret = 0;
|
2011-09-19 10:51:42 +00:00
|
|
|
enum ieee80211_band band;
|
2011-11-01 07:23:51 +00:00
|
|
|
u32 rate, mask;
|
2010-07-08 14:50:07 +00:00
|
|
|
|
|
|
|
switch (wl->scan.state) {
|
|
|
|
case WL1271_SCAN_STATE_IDLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_2GHZ_ACTIVE:
|
2011-09-19 10:51:42 +00:00
|
|
|
band = IEEE80211_BAND_2GHZ;
|
2011-11-01 07:23:51 +00:00
|
|
|
mask = wlvif->bitrate_masks[band];
|
|
|
|
if (wl->scan.req->no_cck) {
|
|
|
|
mask &= ~CONF_TX_CCK_RATES;
|
|
|
|
if (!mask)
|
|
|
|
mask = CONF_TX_RATE_MASK_BASIC_P2P;
|
|
|
|
}
|
|
|
|
rate = wl1271_tx_min_rate_get(wl, mask);
|
2011-10-05 09:55:39 +00:00
|
|
|
ret = wl1271_scan_send(wl, vif, band, false, rate);
|
2010-07-08 14:50:07 +00:00
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE;
|
2011-10-05 09:55:39 +00:00
|
|
|
wl1271_scan_stm(wl, vif);
|
2010-07-08 14:50:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_2GHZ_PASSIVE:
|
2011-09-19 10:51:42 +00:00
|
|
|
band = IEEE80211_BAND_2GHZ;
|
2011-11-01 07:23:51 +00:00
|
|
|
mask = wlvif->bitrate_masks[band];
|
|
|
|
if (wl->scan.req->no_cck) {
|
|
|
|
mask &= ~CONF_TX_CCK_RATES;
|
|
|
|
if (!mask)
|
|
|
|
mask = CONF_TX_RATE_MASK_BASIC_P2P;
|
|
|
|
}
|
|
|
|
rate = wl1271_tx_min_rate_get(wl, mask);
|
2011-10-05 09:55:39 +00:00
|
|
|
ret = wl1271_scan_send(wl, vif, band, true, rate);
|
2010-07-08 14:50:07 +00:00
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
2010-08-19 02:41:15 +00:00
|
|
|
if (wl->enable_11a)
|
2010-07-08 14:50:07 +00:00
|
|
|
wl->scan.state = WL1271_SCAN_STATE_5GHZ_ACTIVE;
|
|
|
|
else
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_DONE;
|
2011-10-05 09:55:39 +00:00
|
|
|
wl1271_scan_stm(wl, vif);
|
2010-07-08 14:50:06 +00:00
|
|
|
}
|
2010-07-08 14:50:07 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_5GHZ_ACTIVE:
|
2011-09-19 10:51:42 +00:00
|
|
|
band = IEEE80211_BAND_5GHZ;
|
2011-10-10 08:12:53 +00:00
|
|
|
rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]);
|
2011-10-05 09:55:39 +00:00
|
|
|
ret = wl1271_scan_send(wl, vif, band, false, rate);
|
2010-07-08 14:50:07 +00:00
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE;
|
2011-10-05 09:55:39 +00:00
|
|
|
wl1271_scan_stm(wl, vif);
|
2010-07-08 14:50:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_5GHZ_PASSIVE:
|
2011-09-19 10:51:42 +00:00
|
|
|
band = IEEE80211_BAND_5GHZ;
|
2011-10-10 08:12:53 +00:00
|
|
|
rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]);
|
2011-10-05 09:55:39 +00:00
|
|
|
ret = wl1271_scan_send(wl, vif, band, true, rate);
|
2010-07-08 14:50:07 +00:00
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_DONE;
|
2011-10-05 09:55:39 +00:00
|
|
|
wl1271_scan_stm(wl, vif);
|
2010-07-08 14:50:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_DONE:
|
2010-09-21 04:23:32 +00:00
|
|
|
wl->scan.failed = false;
|
|
|
|
cancel_delayed_work(&wl->scan_complete_work);
|
|
|
|
ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
|
|
|
|
msecs_to_jiffies(0));
|
2010-07-08 14:50:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wl1271_error("invalid scan state");
|
|
|
|
break;
|
2010-07-08 14:50:06 +00:00
|
|
|
}
|
2010-09-21 04:23:32 +00:00
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
cancel_delayed_work(&wl->scan_complete_work);
|
|
|
|
ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
|
|
|
|
msecs_to_jiffies(0));
|
|
|
|
}
|
2010-07-08 14:50:07 +00:00
|
|
|
}
|
|
|
|
|
2011-10-05 09:55:39 +00:00
|
|
|
int wl1271_scan(struct wl1271 *wl, struct ieee80211_vif *vif,
|
|
|
|
const u8 *ssid, size_t ssid_len,
|
2010-07-08 14:50:07 +00:00
|
|
|
struct cfg80211_scan_request *req)
|
|
|
|
{
|
2011-03-21 21:16:14 +00:00
|
|
|
/*
|
|
|
|
* cfg80211 should guarantee that we don't get more channels
|
|
|
|
* than what we have registered.
|
|
|
|
*/
|
|
|
|
BUG_ON(req->n_channels > WL1271_MAX_CHANNELS);
|
|
|
|
|
2010-07-08 14:50:07 +00:00
|
|
|
if (wl->scan.state != WL1271_SCAN_STATE_IDLE)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_2GHZ_ACTIVE;
|
|
|
|
|
|
|
|
if (ssid_len && ssid) {
|
|
|
|
wl->scan.ssid_len = ssid_len;
|
|
|
|
memcpy(wl->scan.ssid, ssid, ssid_len);
|
|
|
|
} else {
|
|
|
|
wl->scan.ssid_len = 0;
|
|
|
|
}
|
|
|
|
|
2011-10-05 09:55:39 +00:00
|
|
|
wl->scan_vif = vif;
|
2010-07-08 14:50:07 +00:00
|
|
|
wl->scan.req = req;
|
2011-03-21 21:16:14 +00:00
|
|
|
memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
|
2010-07-08 14:50:07 +00:00
|
|
|
|
2010-09-21 04:23:32 +00:00
|
|
|
/* we assume failure so that timeout scenarios are handled correctly */
|
|
|
|
wl->scan.failed = true;
|
|
|
|
ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
|
|
|
|
msecs_to_jiffies(WL1271_SCAN_TIMEOUT));
|
|
|
|
|
2011-10-05 09:55:39 +00:00
|
|
|
wl1271_scan_stm(wl, vif);
|
2010-07-08 14:50:07 +00:00
|
|
|
|
2010-07-08 14:50:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2011-06-27 10:06:44 +00:00
|
|
|
int wl1271_scan_stop(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
struct wl1271_cmd_header *cmd = NULL;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (WARN_ON(wl->scan.state == WL1271_SCAN_STATE_IDLE))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
wl1271_debug(DEBUG_CMD, "cmd scan stop");
|
|
|
|
|
|
|
|
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
|
|
|
|
if (!cmd) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = wl1271_cmd_send(wl, CMD_STOP_SCAN, cmd,
|
|
|
|
sizeof(*cmd), 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("cmd stop_scan failed");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
kfree(cmd);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-05-10 11:38:59 +00:00
|
|
|
static int
|
|
|
|
wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
|
|
|
|
struct cfg80211_sched_scan_request *req,
|
|
|
|
struct conn_scan_ch_params *channels,
|
|
|
|
u32 band, bool radar, bool passive,
|
2012-05-15 14:04:40 +00:00
|
|
|
int start, int max_channels,
|
|
|
|
u8 *n_pactive_ch)
|
2011-05-10 11:38:59 +00:00
|
|
|
{
|
|
|
|
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
|
|
|
|
int i, j;
|
|
|
|
u32 flags;
|
2011-05-27 12:34:48 +00:00
|
|
|
bool force_passive = !req->n_ssids;
|
2012-03-19 10:06:28 +00:00
|
|
|
u32 min_dwell_time_active, max_dwell_time_active, delta_per_probe;
|
|
|
|
u32 dwell_time_passive, dwell_time_dfs;
|
|
|
|
|
|
|
|
if (band == IEEE80211_BAND_5GHZ)
|
|
|
|
delta_per_probe = c->dwell_time_delta_per_probe_5;
|
|
|
|
else
|
|
|
|
delta_per_probe = c->dwell_time_delta_per_probe;
|
|
|
|
|
|
|
|
min_dwell_time_active = c->base_dwell_time +
|
|
|
|
req->n_ssids * c->num_probe_reqs * delta_per_probe;
|
|
|
|
|
|
|
|
max_dwell_time_active = min_dwell_time_active + c->max_dwell_time_delta;
|
|
|
|
|
|
|
|
min_dwell_time_active = DIV_ROUND_UP(min_dwell_time_active, 1000);
|
|
|
|
max_dwell_time_active = DIV_ROUND_UP(max_dwell_time_active, 1000);
|
|
|
|
dwell_time_passive = DIV_ROUND_UP(c->dwell_time_passive, 1000);
|
|
|
|
dwell_time_dfs = DIV_ROUND_UP(c->dwell_time_dfs, 1000);
|
2011-05-10 11:38:59 +00:00
|
|
|
|
|
|
|
for (i = 0, j = start;
|
2011-05-31 13:38:56 +00:00
|
|
|
i < req->n_channels && j < max_channels;
|
2011-05-10 11:38:59 +00:00
|
|
|
i++) {
|
|
|
|
flags = req->channels[i]->flags;
|
|
|
|
|
2011-05-27 12:34:48 +00:00
|
|
|
if (force_passive)
|
|
|
|
flags |= IEEE80211_CHAN_PASSIVE_SCAN;
|
|
|
|
|
2011-05-27 12:34:46 +00:00
|
|
|
if ((req->channels[i]->band == band) &&
|
|
|
|
!(flags & IEEE80211_CHAN_DISABLED) &&
|
2011-05-27 12:34:45 +00:00
|
|
|
(!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
|
2011-05-27 12:34:46 +00:00
|
|
|
/* if radar is set, we ignore the passive flag */
|
|
|
|
(radar ||
|
|
|
|
!!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
|
2011-05-10 11:38:59 +00:00
|
|
|
wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
|
|
|
|
req->channels[i]->band,
|
|
|
|
req->channels[i]->center_freq);
|
|
|
|
wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
|
|
|
|
req->channels[i]->hw_value,
|
|
|
|
req->channels[i]->flags);
|
|
|
|
wl1271_debug(DEBUG_SCAN, "max_power %d",
|
|
|
|
req->channels[i]->max_power);
|
2012-03-19 10:06:28 +00:00
|
|
|
wl1271_debug(DEBUG_SCAN, "min_dwell_time %d max dwell time %d",
|
|
|
|
min_dwell_time_active,
|
|
|
|
max_dwell_time_active);
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2011-05-27 12:34:47 +00:00
|
|
|
if (flags & IEEE80211_CHAN_RADAR) {
|
2011-05-27 12:34:46 +00:00
|
|
|
channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS;
|
2011-12-20 10:04:01 +00:00
|
|
|
|
2011-05-27 12:34:47 +00:00
|
|
|
channels[j].passive_duration =
|
2012-03-19 10:06:28 +00:00
|
|
|
cpu_to_le16(dwell_time_dfs);
|
2011-12-20 10:04:01 +00:00
|
|
|
} else {
|
2011-05-10 11:38:59 +00:00
|
|
|
channels[j].passive_duration =
|
2012-03-19 10:06:28 +00:00
|
|
|
cpu_to_le16(dwell_time_passive);
|
2011-05-10 11:38:59 +00:00
|
|
|
}
|
2011-12-20 10:04:01 +00:00
|
|
|
|
|
|
|
channels[j].min_duration =
|
2012-03-19 10:06:28 +00:00
|
|
|
cpu_to_le16(min_dwell_time_active);
|
2011-12-20 10:04:01 +00:00
|
|
|
channels[j].max_duration =
|
2012-03-19 10:06:28 +00:00
|
|
|
cpu_to_le16(max_dwell_time_active);
|
2011-12-20 10:04:01 +00:00
|
|
|
|
2011-05-27 12:34:46 +00:00
|
|
|
channels[j].tx_power_att = req->channels[i]->max_power;
|
2011-05-10 11:38:59 +00:00
|
|
|
channels[j].channel = req->channels[i]->hw_value;
|
|
|
|
|
2012-05-15 14:04:40 +00:00
|
|
|
if ((band == IEEE80211_BAND_2GHZ) &&
|
|
|
|
(channels[j].channel >= 12) &&
|
|
|
|
(channels[j].channel <= 14) &&
|
|
|
|
(flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
|
|
|
|
!force_passive) {
|
|
|
|
/* pactive channels treated as DFS */
|
|
|
|
channels[j].flags = SCAN_CHANNEL_FLAGS_DFS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* n_pactive_ch is counted down from the end of
|
|
|
|
* the passive channel list
|
|
|
|
*/
|
|
|
|
(*n_pactive_ch)++;
|
|
|
|
wl1271_debug(DEBUG_SCAN, "n_pactive_ch = %d",
|
|
|
|
*n_pactive_ch);
|
|
|
|
}
|
|
|
|
|
2011-05-10 11:38:59 +00:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return j - start;
|
|
|
|
}
|
|
|
|
|
2011-05-31 13:38:56 +00:00
|
|
|
static bool
|
2011-05-10 11:38:59 +00:00
|
|
|
wl1271_scan_sched_scan_channels(struct wl1271 *wl,
|
|
|
|
struct cfg80211_sched_scan_request *req,
|
|
|
|
struct wl1271_cmd_sched_scan_config *cfg)
|
|
|
|
{
|
2012-05-15 14:04:40 +00:00
|
|
|
u8 n_pactive_ch = 0;
|
|
|
|
|
2011-05-10 11:38:59 +00:00
|
|
|
cfg->passive[0] =
|
2011-05-31 13:38:56 +00:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
|
2011-05-10 11:38:59 +00:00
|
|
|
IEEE80211_BAND_2GHZ,
|
2011-05-31 13:38:56 +00:00
|
|
|
false, true, 0,
|
2012-05-15 14:04:40 +00:00
|
|
|
MAX_CHANNELS_2GHZ,
|
|
|
|
&n_pactive_ch);
|
2011-05-10 11:38:59 +00:00
|
|
|
cfg->active[0] =
|
2011-05-31 13:38:56 +00:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
|
2011-05-10 11:38:59 +00:00
|
|
|
IEEE80211_BAND_2GHZ,
|
2011-05-31 13:38:56 +00:00
|
|
|
false, false,
|
|
|
|
cfg->passive[0],
|
2012-05-15 14:04:40 +00:00
|
|
|
MAX_CHANNELS_2GHZ,
|
|
|
|
&n_pactive_ch);
|
2011-05-10 11:38:59 +00:00
|
|
|
cfg->passive[1] =
|
2011-05-31 13:38:56 +00:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
|
2011-05-10 11:38:59 +00:00
|
|
|
IEEE80211_BAND_5GHZ,
|
2011-05-31 13:38:56 +00:00
|
|
|
false, true, 0,
|
2012-05-15 14:04:40 +00:00
|
|
|
MAX_CHANNELS_5GHZ,
|
|
|
|
&n_pactive_ch);
|
2011-05-27 12:34:46 +00:00
|
|
|
cfg->dfs =
|
2011-05-31 13:38:56 +00:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
|
2011-05-10 11:38:59 +00:00
|
|
|
IEEE80211_BAND_5GHZ,
|
2011-05-31 13:38:56 +00:00
|
|
|
true, true,
|
|
|
|
cfg->passive[1],
|
2012-05-15 14:04:40 +00:00
|
|
|
MAX_CHANNELS_5GHZ,
|
|
|
|
&n_pactive_ch);
|
2011-05-27 12:34:46 +00:00
|
|
|
cfg->active[1] =
|
2011-05-31 13:38:56 +00:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
|
2011-05-10 11:38:59 +00:00
|
|
|
IEEE80211_BAND_5GHZ,
|
2011-05-31 13:38:56 +00:00
|
|
|
false, false,
|
|
|
|
cfg->passive[1] + cfg->dfs,
|
2012-05-15 14:04:40 +00:00
|
|
|
MAX_CHANNELS_5GHZ,
|
|
|
|
&n_pactive_ch);
|
2011-05-31 13:38:56 +00:00
|
|
|
/* 802.11j channels are not supported yet */
|
|
|
|
cfg->passive[2] = 0;
|
|
|
|
cfg->active[2] = 0;
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2012-05-15 14:04:40 +00:00
|
|
|
cfg->n_pactive_ch = n_pactive_ch;
|
|
|
|
|
2011-05-10 11:38:59 +00:00
|
|
|
wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d",
|
|
|
|
cfg->active[0], cfg->passive[0]);
|
|
|
|
wl1271_debug(DEBUG_SCAN, " 5GHz: active %d passive %d",
|
|
|
|
cfg->active[1], cfg->passive[1]);
|
2011-05-27 12:34:46 +00:00
|
|
|
wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs);
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2011-05-31 13:38:56 +00:00
|
|
|
return cfg->passive[0] || cfg->active[0] ||
|
|
|
|
cfg->passive[1] || cfg->active[1] || cfg->dfs ||
|
|
|
|
cfg->passive[2] || cfg->active[2];
|
2011-05-10 11:38:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-02 11:28:21 +00:00
|
|
|
/* Returns the scan type to be used or a negative value on error */
|
2011-08-23 15:34:44 +00:00
|
|
|
static int
|
|
|
|
wl12xx_scan_sched_scan_ssid_list(struct wl1271 *wl,
|
2012-05-16 08:34:17 +00:00
|
|
|
struct wl12xx_vif *wlvif,
|
2011-08-23 15:34:44 +00:00
|
|
|
struct cfg80211_sched_scan_request *req)
|
|
|
|
{
|
|
|
|
struct wl1271_cmd_sched_scan_ssid_list *cmd = NULL;
|
2011-09-02 11:28:21 +00:00
|
|
|
struct cfg80211_match_set *sets = req->match_sets;
|
|
|
|
struct cfg80211_ssid *ssids = req->ssids;
|
2011-09-02 11:28:23 +00:00
|
|
|
int ret = 0, type, i, j, n_match_ssids = 0;
|
2011-08-23 15:34:44 +00:00
|
|
|
|
|
|
|
wl1271_debug(DEBUG_CMD, "cmd sched scan ssid list");
|
|
|
|
|
2011-09-02 11:28:23 +00:00
|
|
|
/* count the match sets that contain SSIDs */
|
|
|
|
for (i = 0; i < req->n_match_sets; i++)
|
|
|
|
if (sets[i].ssid.ssid_len > 0)
|
|
|
|
n_match_ssids++;
|
|
|
|
|
2011-09-02 11:28:21 +00:00
|
|
|
/* No filter, no ssids or only bcast ssid */
|
2011-09-02 11:28:23 +00:00
|
|
|
if (!n_match_ssids &&
|
2011-09-02 11:28:21 +00:00
|
|
|
(!req->n_ssids ||
|
|
|
|
(req->n_ssids == 1 && req->ssids[0].ssid_len == 0))) {
|
|
|
|
type = SCAN_SSID_FILTER_ANY;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-08-23 15:34:44 +00:00
|
|
|
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
|
2011-09-02 11:28:21 +00:00
|
|
|
if (!cmd) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-05-16 08:34:17 +00:00
|
|
|
cmd->role_id = wlvif->dev_role_id;
|
2011-09-02 11:28:23 +00:00
|
|
|
if (!n_match_ssids) {
|
2011-09-02 11:28:21 +00:00
|
|
|
/* No filter, with ssids */
|
|
|
|
type = SCAN_SSID_FILTER_DISABLED;
|
|
|
|
|
|
|
|
for (i = 0; i < req->n_ssids; i++) {
|
|
|
|
cmd->ssids[cmd->n_ssids].type = (ssids[i].ssid_len) ?
|
|
|
|
SCAN_SSID_TYPE_HIDDEN : SCAN_SSID_TYPE_PUBLIC;
|
|
|
|
cmd->ssids[cmd->n_ssids].len = ssids[i].ssid_len;
|
|
|
|
memcpy(cmd->ssids[cmd->n_ssids].ssid, ssids[i].ssid,
|
|
|
|
ssids[i].ssid_len);
|
|
|
|
cmd->n_ssids++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
type = SCAN_SSID_FILTER_LIST;
|
2011-08-23 15:34:44 +00:00
|
|
|
|
2011-09-02 11:28:21 +00:00
|
|
|
/* Add all SSIDs from the filters */
|
|
|
|
for (i = 0; i < req->n_match_sets; i++) {
|
2011-09-02 11:28:23 +00:00
|
|
|
/* ignore sets without SSIDs */
|
|
|
|
if (!sets[i].ssid.ssid_len)
|
|
|
|
continue;
|
|
|
|
|
2011-08-23 15:34:45 +00:00
|
|
|
cmd->ssids[cmd->n_ssids].type = SCAN_SSID_TYPE_PUBLIC;
|
2011-09-02 11:28:21 +00:00
|
|
|
cmd->ssids[cmd->n_ssids].len = sets[i].ssid.ssid_len;
|
|
|
|
memcpy(cmd->ssids[cmd->n_ssids].ssid,
|
|
|
|
sets[i].ssid.ssid, sets[i].ssid.ssid_len);
|
|
|
|
cmd->n_ssids++;
|
|
|
|
}
|
|
|
|
if ((req->n_ssids > 1) ||
|
|
|
|
(req->n_ssids == 1 && req->ssids[0].ssid_len > 0)) {
|
|
|
|
/*
|
|
|
|
* Mark all the SSIDs passed in the SSID list as HIDDEN,
|
|
|
|
* so they're used in probe requests.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < req->n_ssids; i++) {
|
2011-12-07 10:37:04 +00:00
|
|
|
if (!req->ssids[i].ssid_len)
|
|
|
|
continue;
|
|
|
|
|
2011-09-02 11:28:21 +00:00
|
|
|
for (j = 0; j < cmd->n_ssids; j++)
|
2012-05-15 15:31:58 +00:00
|
|
|
if ((req->ssids[i].ssid_len ==
|
|
|
|
req->ssids[j].ssid_len) &&
|
|
|
|
!memcmp(req->ssids[i].ssid,
|
2011-09-02 11:28:21 +00:00
|
|
|
cmd->ssids[j].ssid,
|
|
|
|
req->ssids[i].ssid_len)) {
|
|
|
|
cmd->ssids[j].type =
|
|
|
|
SCAN_SSID_TYPE_HIDDEN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Fail if SSID isn't present in the filters */
|
2011-11-08 13:54:46 +00:00
|
|
|
if (j == cmd->n_ssids) {
|
2011-09-02 11:28:21 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
}
|
2011-08-23 15:34:45 +00:00
|
|
|
}
|
2011-08-23 15:34:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wl1271_dump(DEBUG_SCAN, "SSID_LIST: ", cmd, sizeof(*cmd));
|
|
|
|
|
|
|
|
ret = wl1271_cmd_send(wl, CMD_CONNECTION_SCAN_SSID_CFG, cmd,
|
|
|
|
sizeof(*cmd), 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("cmd sched scan ssid list failed");
|
2011-09-02 11:28:21 +00:00
|
|
|
goto out_free;
|
2011-08-23 15:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-02 11:28:21 +00:00
|
|
|
out_free:
|
2011-08-23 15:34:44 +00:00
|
|
|
kfree(cmd);
|
2011-09-02 11:28:21 +00:00
|
|
|
out:
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
return type;
|
2011-08-23 15:34:44 +00:00
|
|
|
}
|
|
|
|
|
2011-05-10 11:38:59 +00:00
|
|
|
int wl1271_scan_sched_scan_config(struct wl1271 *wl,
|
2011-10-05 09:55:45 +00:00
|
|
|
struct wl12xx_vif *wlvif,
|
2011-05-10 11:38:59 +00:00
|
|
|
struct cfg80211_sched_scan_request *req,
|
|
|
|
struct ieee80211_sched_scan_ies *ies)
|
|
|
|
{
|
|
|
|
struct wl1271_cmd_sched_scan_config *cfg = NULL;
|
|
|
|
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
|
2011-05-31 13:38:56 +00:00
|
|
|
int i, ret;
|
2011-05-27 12:34:48 +00:00
|
|
|
bool force_passive = !req->n_ssids;
|
2011-05-10 11:38:59 +00:00
|
|
|
|
|
|
|
wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config");
|
|
|
|
|
|
|
|
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
|
|
|
|
if (!cfg)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-05-16 08:34:17 +00:00
|
|
|
cfg->role_id = wlvif->dev_role_id;
|
2011-05-10 11:38:59 +00:00
|
|
|
cfg->rssi_threshold = c->rssi_threshold;
|
|
|
|
cfg->snr_threshold = c->snr_threshold;
|
|
|
|
cfg->n_probe_reqs = c->num_probe_reqs;
|
|
|
|
/* cycles set to 0 it means infinite (until manually stopped) */
|
|
|
|
cfg->cycles = 0;
|
|
|
|
/* report APs when at least 1 is found */
|
|
|
|
cfg->report_after = 1;
|
|
|
|
/* don't stop scanning automatically when something is found */
|
|
|
|
cfg->terminate = 0;
|
|
|
|
cfg->tag = WL1271_SCAN_DEFAULT_TAG;
|
|
|
|
/* don't filter on BSS type */
|
|
|
|
cfg->bss_type = SCAN_BSS_TYPE_ANY;
|
|
|
|
/* currently NL80211 supports only a single interval */
|
|
|
|
for (i = 0; i < SCAN_MAX_CYCLE_INTERVALS; i++)
|
|
|
|
cfg->intervals[i] = cpu_to_le32(req->interval);
|
|
|
|
|
2011-08-23 15:34:44 +00:00
|
|
|
cfg->ssid_len = 0;
|
2012-05-16 08:34:17 +00:00
|
|
|
ret = wl12xx_scan_sched_scan_ssid_list(wl, wlvif, req);
|
2011-09-02 11:28:21 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
cfg->filter_type = ret;
|
|
|
|
|
|
|
|
wl1271_debug(DEBUG_SCAN, "filter_type = %d", cfg->filter_type);
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2011-05-31 13:38:56 +00:00
|
|
|
if (!wl1271_scan_sched_scan_channels(wl, req, cfg)) {
|
2011-05-10 11:38:59 +00:00
|
|
|
wl1271_error("scan channel list is empty");
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-05-27 12:34:48 +00:00
|
|
|
if (!force_passive && cfg->active[0]) {
|
2012-01-31 09:57:16 +00:00
|
|
|
u8 band = IEEE80211_BAND_2GHZ;
|
|
|
|
ret = wl12xx_cmd_build_probe_req(wl, wlvif,
|
2012-01-31 09:57:17 +00:00
|
|
|
wlvif->dev_role_id, band,
|
2012-01-31 09:57:16 +00:00
|
|
|
req->ssids[0].ssid,
|
2011-05-10 11:38:59 +00:00
|
|
|
req->ssids[0].ssid_len,
|
2012-01-31 09:57:16 +00:00
|
|
|
ies->ie[band],
|
2012-06-27 10:01:44 +00:00
|
|
|
ies->len[band], true);
|
2011-05-10 11:38:59 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("2.4GHz PROBE request template failed");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 12:34:48 +00:00
|
|
|
if (!force_passive && cfg->active[1]) {
|
2012-01-31 09:57:16 +00:00
|
|
|
u8 band = IEEE80211_BAND_5GHZ;
|
|
|
|
ret = wl12xx_cmd_build_probe_req(wl, wlvif,
|
2012-01-31 09:57:17 +00:00
|
|
|
wlvif->dev_role_id, band,
|
2012-01-31 09:57:16 +00:00
|
|
|
req->ssids[0].ssid,
|
2011-05-10 11:38:59 +00:00
|
|
|
req->ssids[0].ssid_len,
|
2012-01-31 09:57:16 +00:00
|
|
|
ies->ie[band],
|
2012-06-27 10:01:44 +00:00
|
|
|
ies->len[band], true);
|
2011-05-10 11:38:59 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("5GHz PROBE request template failed");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wl1271_dump(DEBUG_SCAN, "SCAN_CFG: ", cfg, sizeof(*cfg));
|
|
|
|
|
|
|
|
ret = wl1271_cmd_send(wl, CMD_CONNECTION_SCAN_CFG, cfg,
|
|
|
|
sizeof(*cfg), 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("SCAN configuration failed");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
kfree(cfg);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-10-05 09:55:45 +00:00
|
|
|
int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif)
|
2011-05-10 11:38:59 +00:00
|
|
|
{
|
|
|
|
struct wl1271_cmd_sched_scan_start *start;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
wl1271_debug(DEBUG_CMD, "cmd periodic scan start");
|
|
|
|
|
2011-10-05 09:55:45 +00:00
|
|
|
if (wlvif->bss_type != BSS_TYPE_STA_BSS)
|
2011-05-12 14:07:55 +00:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-06-14 06:47:40 +00:00
|
|
|
if ((wl->quirks & WLCORE_QUIRK_NO_SCHED_SCAN_WHILE_CONN) &&
|
|
|
|
test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags))
|
2011-05-12 14:07:55 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
2011-05-10 11:38:59 +00:00
|
|
|
start = kzalloc(sizeof(*start), GFP_KERNEL);
|
|
|
|
if (!start)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-05-16 08:34:17 +00:00
|
|
|
start->role_id = wlvif->dev_role_id;
|
2011-05-10 11:38:59 +00:00
|
|
|
start->tag = WL1271_SCAN_DEFAULT_TAG;
|
|
|
|
|
|
|
|
ret = wl1271_cmd_send(wl, CMD_START_PERIODIC_SCAN, start,
|
|
|
|
sizeof(*start), 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("failed to send scan start command");
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
out_free:
|
|
|
|
kfree(start);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wl1271_scan_sched_scan_results(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
wl1271_debug(DEBUG_SCAN, "got periodic scan results");
|
|
|
|
|
|
|
|
ieee80211_sched_scan_results(wl->hw);
|
|
|
|
}
|
|
|
|
|
2012-05-16 08:34:17 +00:00
|
|
|
void wl1271_scan_sched_scan_stop(struct wl1271 *wl, struct wl12xx_vif *wlvif)
|
2011-05-10 11:38:59 +00:00
|
|
|
{
|
|
|
|
struct wl1271_cmd_sched_scan_stop *stop;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
wl1271_debug(DEBUG_CMD, "cmd periodic scan stop");
|
|
|
|
|
|
|
|
/* FIXME: what to do if alloc'ing to stop fails? */
|
|
|
|
stop = kzalloc(sizeof(*stop), GFP_KERNEL);
|
|
|
|
if (!stop) {
|
|
|
|
wl1271_error("failed to alloc memory to send sched scan stop");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-16 08:34:17 +00:00
|
|
|
stop->role_id = wlvif->dev_role_id;
|
2011-05-10 11:38:59 +00:00
|
|
|
stop->tag = WL1271_SCAN_DEFAULT_TAG;
|
|
|
|
|
|
|
|
ret = wl1271_cmd_send(wl, CMD_STOP_PERIODIC_SCAN, stop,
|
|
|
|
sizeof(*stop), 0);
|
2011-05-10 11:46:02 +00:00
|
|
|
if (ret < 0) {
|
2011-05-10 11:38:59 +00:00
|
|
|
wl1271_error("failed to send sched scan stop command");
|
2011-05-10 11:46:02 +00:00
|
|
|
goto out_free;
|
|
|
|
}
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2011-05-10 11:46:02 +00:00
|
|
|
out_free:
|
2011-05-10 11:38:59 +00:00
|
|
|
kfree(stop);
|
|
|
|
}
|