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>
|
2018-06-19 09:43:37 +00:00
|
|
|
#include <linux/pm_runtime.h>
|
2010-07-08 14:50:06 +00:00
|
|
|
|
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-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:45 +00:00
|
|
|
struct wl12xx_vif *wlvif;
|
2016-07-05 12:23:12 +00:00
|
|
|
struct cfg80211_scan_info info = {
|
|
|
|
.aborted = false,
|
|
|
|
};
|
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
|
|
|
|
2016-03-18 02:21:28 +00:00
|
|
|
dwork = to_delayed_work(work);
|
2010-09-21 04:23:32 +00:00
|
|
|
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
|
|
|
|
2012-07-24 16:18:49 +00:00
|
|
|
if (unlikely(wl->state != WLCORE_STATE_ON))
|
2011-03-01 10:27:26 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (wl->scan.state == WL1271_SCAN_STATE_IDLE)
|
|
|
|
goto out;
|
2010-09-21 04:23:30 +00:00
|
|
|
|
2012-11-22 16:06:19 +00:00
|
|
|
wlvif = wl->scan_wlvif;
|
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;
|
2012-11-22 16:06:19 +00:00
|
|
|
wl->scan_wlvif = NULL;
|
2010-09-21 04:23:32 +00:00
|
|
|
|
2018-06-19 09:43:37 +00:00
|
|
|
ret = pm_runtime_get_sync(wl->dev);
|
|
|
|
if (ret < 0) {
|
|
|
|
pm_runtime_put_noidle(wl->dev);
|
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
|
|
|
goto out;
|
2018-06-19 09:43:37 +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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-11-25 16:26:59 +00:00
|
|
|
wlcore_cmd_regdomain_config_locked(wl);
|
|
|
|
|
2018-06-19 09:43:42 +00:00
|
|
|
pm_runtime_mark_last_busy(wl->dev);
|
|
|
|
pm_runtime_put_autosuspend(wl->dev);
|
2018-06-19 09:43:38 +00:00
|
|
|
|
2016-07-05 12:23:12 +00:00
|
|
|
ieee80211_scan_completed(wl->hw, &info);
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-12-08 00:58:23 +00:00
|
|
|
static void wlcore_started_vifs_iter(void *data, u8 *mac,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
2013-09-09 09:24:43 +00:00
|
|
|
struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
|
|
|
|
bool active = false;
|
2012-12-08 00:58:23 +00:00
|
|
|
int *count = (int *)data;
|
|
|
|
|
2013-09-09 09:24:43 +00: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 00:58:23 +00: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 11:38:59 +00:00
|
|
|
static int
|
2012-11-22 16:06:12 +00: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-26 16:05:40 +00:00
|
|
|
u8 *n_pactive_ch,
|
|
|
|
int scan_type)
|
2011-05-10 11:38:59 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
u32 flags;
|
2012-11-22 16:06:12 +00:00
|
|
|
bool force_passive = !n_ssids;
|
2012-11-26 16:05:40 +00:00
|
|
|
u32 min_dwell_time_active, max_dwell_time_active;
|
2012-03-19 10:06:28 +00:00
|
|
|
u32 dwell_time_passive, dwell_time_dfs;
|
|
|
|
|
2012-11-26 16:05:40 +00: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 00:58:23 +00: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-26 16:05:40 +00: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;
|
|
|
|
|
2016-04-12 13:56:15 +00:00
|
|
|
if (band == NL80211_BAND_5GHZ)
|
2012-11-26 16:05:40 +00:00
|
|
|
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 10:06:28 +00: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-26 16:05:40 +00:00
|
|
|
dwell_time_passive = DIV_ROUND_UP(dwell_time_passive, 1000);
|
|
|
|
dwell_time_dfs = DIV_ROUND_UP(dwell_time_dfs, 1000);
|
2011-05-10 11:38:59 +00:00
|
|
|
|
|
|
|
for (i = 0, j = start;
|
2012-11-22 16:06:12 +00:00
|
|
|
i < n_channels && j < max_channels;
|
2011-05-10 11:38:59 +00:00
|
|
|
i++) {
|
2012-11-22 16:06:12 +00:00
|
|
|
flags = req_channels[i]->flags;
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2011-05-27 12:34:48 +00:00
|
|
|
if (force_passive)
|
2013-10-21 17:22:25 +00:00
|
|
|
flags |= IEEE80211_CHAN_NO_IR;
|
2011-05-27 12:34:48 +00:00
|
|
|
|
2012-11-22 16:06:12 +00:00
|
|
|
if ((req_channels[i]->band == band) &&
|
2011-05-27 12:34:46 +00:00
|
|
|
!(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 ||
|
2013-10-21 17:22:25 +00:00
|
|
|
!!(flags & IEEE80211_CHAN_NO_IR) == passive)) {
|
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
|
|
|
|
2012-11-22 16:06:12 +00:00
|
|
|
channels[j].tx_power_att = req_channels[i]->max_power;
|
|
|
|
channels[j].channel = req_channels[i]->hw_value;
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2012-11-22 16:06:12 +00:00
|
|
|
if (n_pactive_ch &&
|
2016-04-12 13:56:15 +00:00
|
|
|
(band == NL80211_BAND_2GHZ) &&
|
2012-05-15 14:04:40 +00:00
|
|
|
(channels[j].channel >= 12) &&
|
|
|
|
(channels[j].channel <= 14) &&
|
2013-10-21 17:22:25 +00:00
|
|
|
(flags & IEEE80211_CHAN_NO_IR) &&
|
2012-05-15 14:04:40 +00:00
|
|
|
!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 15:41:24 +00: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" : "",
|
2013-10-21 17:22:25 +00:00
|
|
|
flags & IEEE80211_CHAN_NO_IR ?
|
|
|
|
", NO-IR" : "");
|
2011-05-10 11:38:59 +00:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return j - start;
|
|
|
|
}
|
|
|
|
|
2012-11-22 16:06:15 +00:00
|
|
|
bool
|
2012-11-22 16:06:12 +00:00
|
|
|
wlcore_set_scan_chan_params(struct wl1271 *wl,
|
2012-11-22 16:06:15 +00:00
|
|
|
struct wlcore_scan_channels *cfg,
|
2012-11-22 16:06:12 +00:00
|
|
|
struct ieee80211_channel *channels[],
|
|
|
|
u32 n_channels,
|
2012-11-26 16:05:40 +00:00
|
|
|
u32 n_ssids,
|
|
|
|
int scan_type)
|
2011-05-10 11:38:59 +00:00
|
|
|
{
|
2012-05-15 14:04:40 +00:00
|
|
|
u8 n_pactive_ch = 0;
|
|
|
|
|
2011-05-10 11:38:59 +00:00
|
|
|
cfg->passive[0] =
|
2012-11-22 16:06:12 +00:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_2,
|
2016-04-12 13:56:15 +00:00
|
|
|
NL80211_BAND_2GHZ,
|
2012-11-22 16:06:12 +00:00
|
|
|
false, true, 0,
|
|
|
|
MAX_CHANNELS_2GHZ,
|
2012-11-26 16:05:40 +00:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-10 11:38:59 +00:00
|
|
|
cfg->active[0] =
|
2012-11-22 16:06:12 +00:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_2,
|
2016-04-12 13:56:15 +00:00
|
|
|
NL80211_BAND_2GHZ,
|
2012-11-22 16:06:12 +00:00
|
|
|
false, false,
|
|
|
|
cfg->passive[0],
|
|
|
|
MAX_CHANNELS_2GHZ,
|
2012-11-26 16:05:40 +00:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-10 11:38:59 +00:00
|
|
|
cfg->passive[1] =
|
2012-11-22 16:06:12 +00:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_5,
|
2016-04-12 13:56:15 +00:00
|
|
|
NL80211_BAND_5GHZ,
|
2012-11-22 16:06:12 +00:00
|
|
|
false, true, 0,
|
2012-11-22 16:06:16 +00:00
|
|
|
wl->max_channels_5,
|
2012-11-26 16:05:40 +00:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-27 12:34:46 +00:00
|
|
|
cfg->dfs =
|
2012-11-22 16:06:12 +00:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_5,
|
2016-04-12 13:56:15 +00:00
|
|
|
NL80211_BAND_5GHZ,
|
2012-11-22 16:06:12 +00:00
|
|
|
true, true,
|
|
|
|
cfg->passive[1],
|
2012-11-22 16:06:16 +00:00
|
|
|
wl->max_channels_5,
|
2012-11-26 16:05:40 +00:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2011-05-27 12:34:46 +00:00
|
|
|
cfg->active[1] =
|
2012-11-22 16:06:12 +00:00
|
|
|
wlcore_scan_get_channels(wl,
|
|
|
|
channels,
|
|
|
|
n_channels,
|
|
|
|
n_ssids,
|
|
|
|
cfg->channels_5,
|
2016-04-12 13:56:15 +00:00
|
|
|
NL80211_BAND_5GHZ,
|
2012-11-22 16:06:12 +00:00
|
|
|
false, false,
|
|
|
|
cfg->passive[1] + cfg->dfs,
|
2012-11-22 16:06:16 +00:00
|
|
|
wl->max_channels_5,
|
2012-11-26 16:05:40 +00:00
|
|
|
&n_pactive_ch,
|
|
|
|
scan_type);
|
2012-11-22 16:06:12 +00:00
|
|
|
|
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-11-22 16:06:15 +00:00
|
|
|
cfg->passive_active = n_pactive_ch;
|
2012-05-15 14:04:40 +00:00
|
|
|
|
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
|
|
|
}
|
2012-11-22 16:06:15 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_set_scan_chan_params);
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2012-11-22 16:06:15 +00: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-22 16:06:19 +00:00
|
|
|
wl->scan_wlvif = wlvif;
|
2012-11-22 16:06:15 +00: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 11:28:21 +00:00
|
|
|
/* Returns the scan type to be used or a negative value on error */
|
2012-11-22 16:06:15 +00:00
|
|
|
int
|
|
|
|
wlcore_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
|
|
|
|
2013-09-17 15:41:24 +00:00
|
|
|
wl1271_debug((DEBUG_CMD | DEBUG_SCAN), "cmd sched scan ssid list");
|
2011-08-23 15:34:44 +00:00
|
|
|
|
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-07-26 14:17:05 +00:00
|
|
|
cmd->role_id = wlvif->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 ==
|
2012-07-03 12:51:20 +00:00
|
|
|
cmd->ssids[j].len) &&
|
2012-05-15 15:31:58 +00:00
|
|
|
!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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2012-11-22 16:06:15 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_scan_sched_scan_ssid_list);
|
2011-05-10 11:38:59 +00:00
|
|
|
|
2012-11-28 09:42:47 +00:00
|
|
|
void wlcore_scan_sched_scan_results(struct wl1271 *wl)
|
2011-05-10 11:38:59 +00:00
|
|
|
{
|
|
|
|
wl1271_debug(DEBUG_SCAN, "got periodic scan results");
|
|
|
|
|
|
|
|
ieee80211_sched_scan_results(wl->hw);
|
|
|
|
}
|
2012-11-28 09:42:47 +00:00
|
|
|
EXPORT_SYMBOL_GPL(wlcore_scan_sched_scan_results);
|