2010-07-08 22:50:06 +08: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-22 01:25:24 +08:00
|
|
|
#include "wlcore.h"
|
2011-10-07 16:02:42 +08:00
|
|
|
#include "debug.h"
|
2010-11-08 19:20:10 +08:00
|
|
|
#include "cmd.h"
|
|
|
|
#include "scan.h"
|
|
|
|
#include "acx.h"
|
2011-03-01 18:27:26 +08:00
|
|
|
#include "ps.h"
|
2011-09-19 18:51:42 +08:00
|
|
|
#include "tx.h"
|
2010-07-08 22:50:06 +08:00
|
|
|
|
2010-08-24 11:28:03 +08:00
|
|
|
void wl1271_scan_complete_work(struct work_struct *work)
|
|
|
|
{
|
2010-09-21 12:23:32 +08:00
|
|
|
struct delayed_work *dwork;
|
|
|
|
struct wl1271 *wl;
|
2011-10-05 17:55:45 +08: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 18:17:17 +08:00
|
|
|
int ret;
|
2010-09-21 12:23:32 +08:00
|
|
|
|
|
|
|
dwork = container_of(work, struct delayed_work, work);
|
|
|
|
wl = container_of(dwork, struct wl1271, scan_complete_work);
|
2010-08-24 11:28:03 +08:00
|
|
|
|
|
|
|
wl1271_debug(DEBUG_SCAN, "Scanning complete");
|
|
|
|
|
|
|
|
mutex_lock(&wl->mutex);
|
2010-09-21 12:23:30 +08:00
|
|
|
|
2012-07-25 00:18:49 +08:00
|
|
|
if (unlikely(wl->state != WLCORE_STATE_ON))
|
2011-03-01 18:27:26 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (wl->scan.state == WL1271_SCAN_STATE_IDLE)
|
|
|
|
goto out;
|
2010-09-21 12:23:30 +08:00
|
|
|
|
2012-11-23 00:06:19 +08:00
|
|
|
wlvif = wl->scan_wlvif;
|
2011-10-05 17:55:45 +08:00
|
|
|
|
2012-03-04 04:18:00 +08: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 11:28:03 +08:00
|
|
|
wl->scan.state = WL1271_SCAN_STATE_IDLE;
|
2011-03-22 05:16:14 +08:00
|
|
|
memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
|
2010-10-26 19:24:38 +08:00
|
|
|
wl->scan.req = NULL;
|
2012-11-23 00:06:19 +08:00
|
|
|
wl->scan_wlvif = NULL;
|
2010-09-21 12:23:32 +08: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 18:17:17 +08:00
|
|
|
ret = wl1271_ps_elp_wakeup(wl);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
2011-10-10 16:13:00 +08: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 18:17:17 +08:00
|
|
|
/* restore hardware connection monitoring template */
|
2011-10-10 16:12:53 +08:00
|
|
|
wl1271_cmd_build_ap_probe_req(wl, wlvif, wlvif->probereq);
|
2011-08-14 18:17:26 +08: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 18:17:17 +08:00
|
|
|
wl1271_ps_elp_sleep(wl);
|
2010-11-24 14:16:57 +08:00
|
|
|
|
2010-09-21 12:23:32 +08:00
|
|
|
if (wl->scan.failed) {
|
|
|
|
wl1271_info("Scan completed due to error.");
|
2011-06-06 19:57:05 +08:00
|
|
|
wl12xx_queue_recovery_work(wl);
|
2010-09-21 12:23:32 +08:00
|
|
|
}
|
2011-03-01 18:27:26 +08:00
|
|
|
|
2012-11-26 00:26:59 +08:00
|
|
|
wlcore_cmd_regdomain_config_locked(wl);
|
|
|
|
|
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 18:17:17 +08:00
|
|
|
ieee80211_scan_completed(wl->hw, false);
|
|
|
|
|
2011-03-01 18:27:26 +08:00
|
|
|
out:
|
2010-10-26 19:24:38 +08:00
|
|
|
mutex_unlock(&wl->mutex);
|
|
|
|
|
2010-08-24 11:28:03 +08:00
|
|
|
}
|
|
|
|
|
2012-12-08 08:58:23 +08:00
|
|
|
static void wlcore_started_vifs_iter(void *data, u8 *mac,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
2013-09-09 17:24:43 +08:00
|
|
|
struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
|
|
|
|
bool active = false;
|
2012-12-08 08:58:23 +08:00
|
|
|
int *count = (int *)data;
|
|
|
|
|
2013-09-09 17:24:43 +08:00
|
|
|
/*
|
|
|
|
* count active interfaces according to interface type.
|
|
|
|
* checking only bss_conf.idle is bad for some cases, e.g.
|
|
|
|
* we don't want to count sta in p2p_find as active interface.
|
|
|
|
*/
|
|
|
|
switch (wlvif->bss_type) {
|
|
|
|
case BSS_TYPE_STA_BSS:
|
|
|
|
if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
|
|
|
|
active = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BSS_TYPE_AP_BSS:
|
|
|
|
if (wlvif->wl->active_sta_count > 0)
|
|
|
|
active = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active)
|
2012-12-08 08:58:23 +08:00
|
|
|
(*count)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wlcore_count_started_vifs(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
ieee80211_iterate_active_interfaces_atomic(wl->hw,
|
|
|
|
IEEE80211_IFACE_ITER_RESUME_ALL,
|
|
|
|
wlcore_started_vifs_iter, &count);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2011-05-10 19:38:59 +08:00
|
|
|
static int
|
2012-11-23 00:06:12 +08:00
|
|
|
wlcore_scan_get_channels(struct wl1271 *wl,
|
|
|
|
struct ieee80211_channel *req_channels[],
|
|
|
|
u32 n_channels,
|
|
|
|
u32 n_ssids,
|
|
|
|
struct conn_scan_ch_params *channels,
|
|
|
|
u32 band, bool radar, bool passive,
|
|
|
|
int start, int max_channels,
|
2012-11-27 00:05:40 +08:00
|
|
|
u8 *n_pactive_ch,
|
|
|
|
int scan_type)
|
2011-05-10 19:38:59 +08:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
u32 flags;
|
2012-11-23 00:06:12 +08:00
|
|
|
bool force_passive = !n_ssids;
|
2012-11-27 00:05:40 +08:00
|
|
|
u32 min_dwell_time_active, max_dwell_time_active;
|
2012-03-19 18:06:28 +08:00
|
|
|
u32 dwell_time_passive, dwell_time_dfs;
|
|
|
|
|
2012-11-27 00:05:40 +08:00
|
|
|
/* configure dwell times according to scan type */
|
|
|
|
if (scan_type == SCAN_TYPE_SEARCH) {
|
|
|
|
struct conf_scan_settings *c = &wl->conf.scan;
|
2012-12-08 08:58:23 +08:00
|
|
|
bool active_vif_exists = !!wlcore_count_started_vifs(wl);
|
|
|
|
|
|
|
|
min_dwell_time_active = active_vif_exists ?
|
|
|
|
c->min_dwell_time_active :
|
|
|
|
c->min_dwell_time_active_long;
|
|
|
|
max_dwell_time_active = active_vif_exists ?
|
|
|
|
c->max_dwell_time_active :
|
|
|
|
c->max_dwell_time_active_long;
|
2012-11-27 00:05:40 +08:00
|
|
|
dwell_time_passive = c->dwell_time_passive;
|
|
|
|
dwell_time_dfs = c->dwell_time_dfs;
|
|
|
|
} else {
|
|
|
|
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
|
|
|
|
u32 delta_per_probe;
|
|
|
|
|
|
|
|
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 +
|
|
|
|
n_ssids * c->num_probe_reqs * delta_per_probe;
|
|
|
|
|
|
|
|
max_dwell_time_active = min_dwell_time_active +
|
|
|
|
c->max_dwell_time_delta;
|
|
|
|
dwell_time_passive = c->dwell_time_passive;
|
|
|
|
dwell_time_dfs = c->dwell_time_dfs;
|
|
|
|
}
|
2012-03-19 18:06:28 +08:00
|
|
|
min_dwell_time_active = DIV_ROUND_UP(min_dwell_time_active, 1000);
|
|
|
|
max_dwell_time_active = DIV_ROUND_UP(max_dwell_time_active, 1000);
|
2012-11-27 00:05:40 +08:00
|
|
|
dwell_time_passive = DIV_ROUND_UP(dwell_time_passive, 1000);
|
|
|
|
dwell_time_dfs = DIV_ROUND_UP(dwell_time_dfs, 1000);
|
2011-05-10 19:38:59 +08:00
|
|
|
|
|
|
|
for (i = 0, j = start;
|
2012-11-23 00:06:12 +08:00
|
|
|
i < n_channels && j < max_channels;
|
2011-05-10 19:38:59 +08:00
|
|
|
i++) {
|
2012-11-23 00:06:12 +08:00
|
|
|
flags = req_channels[i]->flags;
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2011-05-27 20:34:48 +08:00
|
|
|
if (force_passive)
|
|
|
|
flags |= IEEE80211_CHAN_PASSIVE_SCAN;
|
|
|
|
|
2012-11-23 00:06:12 +08:00
|
|
|
if ((req_channels[i]->band == band) &&
|
2011-05-27 20:34:46 +08:00
|
|
|
!(flags & IEEE80211_CHAN_DISABLED) &&
|
2011-05-27 20:34:45 +08:00
|
|
|
(!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
|
2011-05-27 20:34:46 +08:00
|
|
|
/* if radar is set, we ignore the passive flag */
|
|
|
|
(radar ||
|
|
|
|
!!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
|
2013-09-17 23:41:24 +08:00
|
|
|
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2011-05-27 20:34:47 +08:00
|
|
|
if (flags & IEEE80211_CHAN_RADAR) {
|
2011-05-27 20:34:46 +08:00
|
|
|
channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS;
|
2011-12-20 18:04:01 +08:00
|
|
|
|
2011-05-27 20:34:47 +08:00
|
|
|
channels[j].passive_duration =
|
2012-03-19 18:06:28 +08:00
|
|
|
cpu_to_le16(dwell_time_dfs);
|
2011-12-20 18:04:01 +08:00
|
|
|
} else {
|
2011-05-10 19:38:59 +08:00
|
|
|
channels[j].passive_duration =
|
2012-03-19 18:06:28 +08:00
|
|
|
cpu_to_le16(dwell_time_passive);
|
2011-05-10 19:38:59 +08:00
|
|
|
}
|
2011-12-20 18:04:01 +08:00
|
|
|
|
|
|
|
channels[j].min_duration =
|
2012-03-19 18:06:28 +08:00
|
|
|
cpu_to_le16(min_dwell_time_active);
|
2011-12-20 18:04:01 +08:00
|
|
|
channels[j].max_duration =
|
2012-03-19 18:06:28 +08:00
|
|
|
cpu_to_le16(max_dwell_time_active);
|
2011-12-20 18:04:01 +08:00
|
|
|
|
2012-11-23 00:06:12 +08:00
|
|
|
channels[j].tx_power_att = req_channels[i]->max_power;
|
|
|
|
channels[j].channel = req_channels[i]->hw_value;
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2012-11-23 00:06:12 +08:00
|
|
|
if (n_pactive_ch &&
|
|
|
|
(band == IEEE80211_BAND_2GHZ) &&
|
2012-05-15 22:04:40 +08:00
|
|
|
(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);
|
|
|
|
}
|
|
|
|
|
2013-09-17 23:41:24 +08:00
|
|
|
wl1271_debug(DEBUG_SCAN, "freq %d, ch. %d, flags 0x%x, power %d, min/max_dwell %d/%d%s%s",
|
|
|
|
req_channels[i]->center_freq,
|
|
|
|
req_channels[i]->hw_value,
|
|
|
|
req_channels[i]->flags,
|
|
|
|
req_channels[i]->max_power,
|
|
|
|
min_dwell_time_active,
|
|
|
|
max_dwell_time_active,
|
|
|
|
flags & IEEE80211_CHAN_RADAR ?
|
|
|
|
", DFS" : "",
|
|
|
|
flags & IEEE80211_CHAN_PASSIVE_SCAN ?
|
|
|
|
", PASSIVE" : "");
|
2011-05-10 19:38:59 +08:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return j - start;
|
|
|
|
}
|
|
|
|
|
2012-11-23 00:06:15 +08:00
|
|
|
bool
|
2012-11-23 00:06:12 +08:00
|
|
|
wlcore_set_scan_chan_params(struct wl1271 *wl,
|
2012-11-23 00:06:15 +08:00
|
|
|
struct wlcore_scan_channels *cfg,
|
2012-11-23 00:06:12 +08:00
|
|
|
struct ieee80211_channel *channels[],
|
|
|
|
u32 n_channels,
|
2012-11-27 00:05:40 +08:00
|
|
|
u32 n_ssids,
|
|
|
|
int scan_type)
|
2011-05-10 19:38:59 +08:00
|
|
|
{
|
2012-05-15 22:04:40 +08:00
|
|
|
u8 n_pactive_ch = 0;
|
|
|
|
|
2011-05-10 19:38:59 +08:00
|
|
|
cfg->passive[0] =
|
2012-11-23 00:06:12 +08:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_2,
|
|
|
|
IEEE80211_BAND_2GHZ,
|
|
|
|
false, true, 0,
|
|
|
|
MAX_CHANNELS_2GHZ,
|
2012-11-27 00:05:40 +08:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-10 19:38:59 +08:00
|
|
|
cfg->active[0] =
|
2012-11-23 00:06:12 +08:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_2,
|
|
|
|
IEEE80211_BAND_2GHZ,
|
|
|
|
false, false,
|
|
|
|
cfg->passive[0],
|
|
|
|
MAX_CHANNELS_2GHZ,
|
2012-11-27 00:05:40 +08:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-10 19:38:59 +08:00
|
|
|
cfg->passive[1] =
|
2012-11-23 00:06:12 +08:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_5,
|
|
|
|
IEEE80211_BAND_5GHZ,
|
|
|
|
false, true, 0,
|
2012-11-23 00:06:16 +08:00
|
|
|
wl->max_channels_5,
|
2012-11-27 00:05:40 +08:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-27 20:34:46 +08:00
|
|
|
cfg->dfs =
|
2012-11-23 00:06:12 +08:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_5,
|
|
|
|
IEEE80211_BAND_5GHZ,
|
|
|
|
true, true,
|
|
|
|
cfg->passive[1],
|
2012-11-23 00:06:16 +08:00
|
|
|
wl->max_channels_5,
|
2012-11-27 00:05:40 +08:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-27 20:34:46 +08:00
|
|
|
cfg->active[1] =
|
2012-11-23 00:06:12 +08:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_5,
|
|
|
|
IEEE80211_BAND_5GHZ,
|
|
|
|
false, false,
|
|
|
|
cfg->passive[1] + cfg->dfs,
|
2012-11-23 00:06:16 +08:00
|
|
|
wl->max_channels_5,
|
2012-11-27 00:05:40 +08:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2012-11-23 00:06:12 +08:00
|
|
|
|
2011-05-31 21:38:56 +08:00
|
|
|
/* 802.11j channels are not supported yet */
|
|
|
|
cfg->passive[2] = 0;
|
|
|
|
cfg->active[2] = 0;
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2012-11-23 00:06:15 +08:00
|
|
|
cfg->passive_active = n_pactive_ch;
|
2012-05-15 22:04:40 +08:00
|
|
|
|
2011-05-10 19:38:59 +08: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 20:34:46 +08:00
|
|
|
wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs);
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2011-05-31 21:38:56 +08: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 19:38:59 +08:00
|
|
|
}
|
2012-11-23 00:06:15 +08:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_set_scan_chan_params);
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2012-11-23 00:06:15 +08:00
|
|
|
int wlcore_scan(struct wl1271 *wl, struct ieee80211_vif *vif,
|
|
|
|
const u8 *ssid, size_t ssid_len,
|
|
|
|
struct cfg80211_scan_request *req)
|
|
|
|
{
|
|
|
|
struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* cfg80211 should guarantee that we don't get more channels
|
|
|
|
* than what we have registered.
|
|
|
|
*/
|
|
|
|
BUG_ON(req->n_channels > WL1271_MAX_CHANNELS);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-11-23 00:06:19 +08:00
|
|
|
wl->scan_wlvif = wlvif;
|
2012-11-23 00:06:15 +08:00
|
|
|
wl->scan.req = req;
|
|
|
|
memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
|
|
|
|
|
|
|
|
/* 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));
|
|
|
|
|
|
|
|
wl->ops->scan_start(wl, wlvif, req);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-09-02 19:28:21 +08:00
|
|
|
/* Returns the scan type to be used or a negative value on error */
|
2012-11-23 00:06:15 +08:00
|
|
|
int
|
|
|
|
wlcore_scan_sched_scan_ssid_list(struct wl1271 *wl,
|
2012-05-16 16:34:17 +08:00
|
|
|
struct wl12xx_vif *wlvif,
|
2011-08-23 23:34:44 +08:00
|
|
|
struct cfg80211_sched_scan_request *req)
|
|
|
|
{
|
|
|
|
struct wl1271_cmd_sched_scan_ssid_list *cmd = NULL;
|
2011-09-02 19:28:21 +08:00
|
|
|
struct cfg80211_match_set *sets = req->match_sets;
|
|
|
|
struct cfg80211_ssid *ssids = req->ssids;
|
2011-09-02 19:28:23 +08:00
|
|
|
int ret = 0, type, i, j, n_match_ssids = 0;
|
2011-08-23 23:34:44 +08:00
|
|
|
|
2013-09-17 23:41:24 +08:00
|
|
|
wl1271_debug((DEBUG_CMD | DEBUG_SCAN), "cmd sched scan ssid list");
|
2011-08-23 23:34:44 +08:00
|
|
|
|
2011-09-02 19:28:23 +08: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 19:28:21 +08:00
|
|
|
/* No filter, no ssids or only bcast ssid */
|
2011-09-02 19:28:23 +08:00
|
|
|
if (!n_match_ssids &&
|
2011-09-02 19:28:21 +08:00
|
|
|
(!req->n_ssids ||
|
|
|
|
(req->n_ssids == 1 && req->ssids[0].ssid_len == 0))) {
|
|
|
|
type = SCAN_SSID_FILTER_ANY;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-08-23 23:34:44 +08:00
|
|
|
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
|
2011-09-02 19:28:21 +08:00
|
|
|
if (!cmd) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-07-26 22:17:05 +08:00
|
|
|
cmd->role_id = wlvif->role_id;
|
2011-09-02 19:28:23 +08:00
|
|
|
if (!n_match_ssids) {
|
2011-09-02 19:28:21 +08: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 23:34:44 +08:00
|
|
|
|
2011-09-02 19:28:21 +08:00
|
|
|
/* Add all SSIDs from the filters */
|
|
|
|
for (i = 0; i < req->n_match_sets; i++) {
|
2011-09-02 19:28:23 +08:00
|
|
|
/* ignore sets without SSIDs */
|
|
|
|
if (!sets[i].ssid.ssid_len)
|
|
|
|
continue;
|
|
|
|
|
2011-08-23 23:34:45 +08:00
|
|
|
cmd->ssids[cmd->n_ssids].type = SCAN_SSID_TYPE_PUBLIC;
|
2011-09-02 19:28:21 +08: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 18:37:04 +08:00
|
|
|
if (!req->ssids[i].ssid_len)
|
|
|
|
continue;
|
|
|
|
|
2011-09-02 19:28:21 +08:00
|
|
|
for (j = 0; j < cmd->n_ssids; j++)
|
2012-05-15 23:31:58 +08:00
|
|
|
if ((req->ssids[i].ssid_len ==
|
2012-07-03 20:51:20 +08:00
|
|
|
cmd->ssids[j].len) &&
|
2012-05-15 23:31:58 +08:00
|
|
|
!memcmp(req->ssids[i].ssid,
|
2011-09-02 19:28:21 +08: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 21:54:46 +08:00
|
|
|
if (j == cmd->n_ssids) {
|
2011-09-02 19:28:21 +08:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
}
|
2011-08-23 23:34:45 +08:00
|
|
|
}
|
2011-08-23 23:34:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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 19:28:21 +08:00
|
|
|
goto out_free;
|
2011-08-23 23:34:44 +08:00
|
|
|
}
|
|
|
|
|
2011-09-02 19:28:21 +08:00
|
|
|
out_free:
|
2011-08-23 23:34:44 +08:00
|
|
|
kfree(cmd);
|
2011-09-02 19:28:21 +08:00
|
|
|
out:
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
return type;
|
2011-08-23 23:34:44 +08:00
|
|
|
}
|
2012-11-23 00:06:15 +08:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_scan_sched_scan_ssid_list);
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2012-11-28 17:42:47 +08:00
|
|
|
void wlcore_scan_sched_scan_results(struct wl1271 *wl)
|
2011-05-10 19:38:59 +08:00
|
|
|
{
|
|
|
|
wl1271_debug(DEBUG_SCAN, "got periodic scan results");
|
|
|
|
|
|
|
|
ieee80211_sched_scan_results(wl->hw);
|
|
|
|
}
|
2012-11-28 17:42:47 +08:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_scan_sched_scan_results);
|