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>
|
|
|
|
|
2010-11-08 19:20:10 +08:00
|
|
|
#include "wl12xx.h"
|
|
|
|
#include "cmd.h"
|
|
|
|
#include "scan.h"
|
|
|
|
#include "acx.h"
|
2011-03-01 18:27:26 +08:00
|
|
|
#include "ps.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;
|
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;
|
2011-08-14 18:17:26 +08:00
|
|
|
bool is_sta, is_ibss;
|
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
|
|
|
|
2011-03-01 18:27:26 +08:00
|
|
|
if (wl->state == WL1271_STATE_OFF)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (wl->scan.state == WL1271_SCAN_STATE_IDLE)
|
|
|
|
goto out;
|
2010-09-21 12:23:30 +08:00
|
|
|
|
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;
|
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-03-01 18:27:26 +08:00
|
|
|
if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->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 */
|
|
|
|
wl1271_cmd_build_ap_probe_req(wl, wl->probereq);
|
2011-08-14 18:17:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return to ROC if needed */
|
|
|
|
is_sta = (wl->bss_type == BSS_TYPE_STA_BSS);
|
|
|
|
is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
|
|
|
|
if ((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) ||
|
|
|
|
(is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->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 remain on channel */
|
|
|
|
wl12xx_cmd_role_start_dev(wl);
|
|
|
|
wl12xx_roc(wl, wl->dev_role_id);
|
2011-03-01 18:27: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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-08 22:50:07 +08: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 22:50:06 +08:00
|
|
|
{
|
2010-09-21 14:14:31 +08:00
|
|
|
struct conf_scan_settings *c = &wl->conf.scan;
|
2010-07-08 22:50:07 +08:00
|
|
|
int i, j;
|
|
|
|
u32 flags;
|
2010-07-08 22:50:06 +08:00
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
for (i = 0, j = 0;
|
|
|
|
i < req->n_channels && j < WL1271_SCAN_MAX_CHANNELS;
|
|
|
|
i++) {
|
2010-07-08 22:50:06 +08:00
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
flags = req->channels[i]->flags;
|
2010-07-08 22:50:06 +08:00
|
|
|
|
2011-03-22 05:16:14 +08:00
|
|
|
if (!test_bit(i, wl->scan.scanned_ch) &&
|
2010-07-08 22:50:07 +08:00
|
|
|
!(flags & IEEE80211_CHAN_DISABLED) &&
|
|
|
|
((!!(flags & IEEE80211_CHAN_PASSIVE_SCAN)) == passive) &&
|
|
|
|
(req->channels[i]->band == band)) {
|
2010-07-08 22:50:06 +08:00
|
|
|
|
2010-07-08 22:50:07 +08: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 22:50:06 +08:00
|
|
|
|
2010-09-21 14:14:31 +08: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 22:50:07 +08:00
|
|
|
channels[j].early_termination = 0;
|
2010-07-08 22:50:08 +08:00
|
|
|
channels[j].tx_power_att = req->channels[i]->max_power;
|
2010-07-08 22:50:07 +08: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-22 05:16:14 +08:00
|
|
|
set_bit(i, wl->scan.scanned_ch);
|
2010-07-08 22:50:07 +08:00
|
|
|
|
2010-07-08 22:50:06 +08:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
return j;
|
|
|
|
}
|
2010-07-08 22:50:06 +08:00
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
#define WL1271_NOTHING_TO_SCAN 1
|
|
|
|
|
|
|
|
static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band,
|
|
|
|
bool passive, u32 basic_rate)
|
|
|
|
{
|
|
|
|
struct wl1271_cmd_scan *cmd;
|
|
|
|
struct wl1271_cmd_trigger_scan_to *trigger;
|
|
|
|
int ret;
|
|
|
|
u16 scan_options = 0;
|
|
|
|
|
|
|
|
cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
|
|
|
|
trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
|
|
|
|
if (!cmd || !trigger) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
2010-07-08 22:50:06 +08:00
|
|
|
}
|
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
/* We always use high priority scans */
|
|
|
|
scan_options = WL1271_SCAN_OPT_PRIORITY_HIGH;
|
2010-08-04 09:36:32 +08:00
|
|
|
|
|
|
|
/* No SSIDs means that we have a forced passive scan */
|
|
|
|
if (passive || wl->scan.req->n_ssids == 0)
|
2010-07-08 22:50:07 +08:00
|
|
|
scan_options |= WL1271_SCAN_OPT_PASSIVE;
|
2010-08-04 09:36:32 +08:00
|
|
|
|
2011-08-14 18:17:10 +08:00
|
|
|
if (WARN_ON(wl->role_id == WL12XX_INVALID_ROLE_ID)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
cmd->params.role_id = wl->role_id;
|
2010-07-08 22:50:07 +08: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 22:50:06 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
cmd->params.tx_rate = cpu_to_le32(basic_rate);
|
2010-09-21 14:14:31 +08:00
|
|
|
cmd->params.n_probe_reqs = wl->conf.scan.num_probe_reqs;
|
2010-07-08 22:50:07 +08:00
|
|
|
cmd->params.tx_rate = cpu_to_le32(basic_rate);
|
|
|
|
cmd->params.tid_trigger = 0;
|
|
|
|
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-08-14 18:17:10 +08:00
|
|
|
memcpy(cmd->addr, wl->mac_addr, ETH_ALEN);
|
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
ret = wl1271_cmd_build_probe_req(wl, wl->scan.ssid, wl->scan.ssid_len,
|
|
|
|
wl->scan.req->ie, wl->scan.req->ie_len,
|
|
|
|
band);
|
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("PROBE request template failed");
|
2010-07-08 22:50:06 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable the timeout */
|
|
|
|
trigger->timeout = 0;
|
|
|
|
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 22:50:07 +08:00
|
|
|
wl1271_dump(DEBUG_SCAN, "SCAN: ", cmd, sizeof(*cmd));
|
2010-07-08 22:50:06 +08:00
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
ret = wl1271_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd), 0);
|
2010-07-08 22:50:06 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("SCAN failed");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2010-07-08 22:50:07 +08:00
|
|
|
kfree(cmd);
|
2010-07-08 22:50:06 +08:00
|
|
|
kfree(trigger);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
void wl1271_scan_stm(struct wl1271 *wl)
|
2010-07-08 22:50:06 +08:00
|
|
|
{
|
2010-09-21 12:23:32 +08:00
|
|
|
int ret = 0;
|
2010-07-08 22:50:07 +08:00
|
|
|
|
|
|
|
switch (wl->scan.state) {
|
|
|
|
case WL1271_SCAN_STATE_IDLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_2GHZ_ACTIVE:
|
|
|
|
ret = wl1271_scan_send(wl, IEEE80211_BAND_2GHZ, false,
|
|
|
|
wl->conf.tx.basic_rate);
|
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE;
|
|
|
|
wl1271_scan_stm(wl);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_2GHZ_PASSIVE:
|
|
|
|
ret = wl1271_scan_send(wl, IEEE80211_BAND_2GHZ, true,
|
|
|
|
wl->conf.tx.basic_rate);
|
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
2010-08-19 10:41:15 +08:00
|
|
|
if (wl->enable_11a)
|
2010-07-08 22:50:07 +08:00
|
|
|
wl->scan.state = WL1271_SCAN_STATE_5GHZ_ACTIVE;
|
|
|
|
else
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_DONE;
|
|
|
|
wl1271_scan_stm(wl);
|
2010-07-08 22:50:06 +08:00
|
|
|
}
|
2010-07-08 22:50:07 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_5GHZ_ACTIVE:
|
|
|
|
ret = wl1271_scan_send(wl, IEEE80211_BAND_5GHZ, false,
|
|
|
|
wl->conf.tx.basic_rate_5);
|
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE;
|
|
|
|
wl1271_scan_stm(wl);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_5GHZ_PASSIVE:
|
|
|
|
ret = wl1271_scan_send(wl, IEEE80211_BAND_5GHZ, true,
|
|
|
|
wl->conf.tx.basic_rate_5);
|
|
|
|
if (ret == WL1271_NOTHING_TO_SCAN) {
|
|
|
|
wl->scan.state = WL1271_SCAN_STATE_DONE;
|
|
|
|
wl1271_scan_stm(wl);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WL1271_SCAN_STATE_DONE:
|
2010-09-21 12:23:32 +08: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 22:50:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wl1271_error("invalid scan state");
|
|
|
|
break;
|
2010-07-08 22:50:06 +08:00
|
|
|
}
|
2010-09-21 12:23:32 +08: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 22:50:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
|
|
|
|
struct cfg80211_scan_request *req)
|
|
|
|
{
|
2011-03-22 05:16:14 +08: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 22:50:07 +08: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl->scan.req = req;
|
2011-03-22 05:16:14 +08:00
|
|
|
memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
|
2010-07-08 22:50:07 +08:00
|
|
|
|
2010-09-21 12:23:32 +08: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));
|
|
|
|
|
2010-07-08 22:50:07 +08:00
|
|
|
wl1271_scan_stm(wl);
|
|
|
|
|
2010-07-08 22:50:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2011-06-27 18:06:44 +08: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 19:38:59 +08: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,
|
2011-05-31 21:38:56 +08:00
|
|
|
int start, int max_channels)
|
2011-05-10 19:38:59 +08:00
|
|
|
{
|
|
|
|
struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
|
|
|
|
int i, j;
|
|
|
|
u32 flags;
|
2011-05-27 20:34:48 +08:00
|
|
|
bool force_passive = !req->n_ssids;
|
2011-05-10 19:38:59 +08:00
|
|
|
|
|
|
|
for (i = 0, j = start;
|
2011-05-31 21:38:56 +08:00
|
|
|
i < req->n_channels && j < max_channels;
|
2011-05-10 19:38:59 +08:00
|
|
|
i++) {
|
|
|
|
flags = req->channels[i]->flags;
|
|
|
|
|
2011-05-27 20:34:48 +08:00
|
|
|
if (force_passive)
|
|
|
|
flags |= IEEE80211_CHAN_PASSIVE_SCAN;
|
|
|
|
|
2011-05-27 20:34:46 +08:00
|
|
|
if ((req->channels[i]->band == band) &&
|
|
|
|
!(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)) {
|
2011-05-10 19:38:59 +08: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);
|
|
|
|
|
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-05-27 20:34:47 +08:00
|
|
|
channels[j].passive_duration =
|
|
|
|
cpu_to_le16(c->dwell_time_dfs);
|
|
|
|
}
|
|
|
|
else if (flags & IEEE80211_CHAN_PASSIVE_SCAN) {
|
2011-05-10 19:38:59 +08:00
|
|
|
channels[j].passive_duration =
|
|
|
|
cpu_to_le16(c->dwell_time_passive);
|
|
|
|
} else {
|
|
|
|
channels[j].min_duration =
|
|
|
|
cpu_to_le16(c->min_dwell_time_active);
|
|
|
|
channels[j].max_duration =
|
|
|
|
cpu_to_le16(c->max_dwell_time_active);
|
|
|
|
}
|
2011-05-27 20:34:46 +08:00
|
|
|
channels[j].tx_power_att = req->channels[i]->max_power;
|
2011-05-10 19:38:59 +08:00
|
|
|
channels[j].channel = req->channels[i]->hw_value;
|
|
|
|
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return j - start;
|
|
|
|
}
|
|
|
|
|
2011-05-31 21:38:56 +08:00
|
|
|
static bool
|
2011-05-10 19:38:59 +08:00
|
|
|
wl1271_scan_sched_scan_channels(struct wl1271 *wl,
|
|
|
|
struct cfg80211_sched_scan_request *req,
|
|
|
|
struct wl1271_cmd_sched_scan_config *cfg)
|
|
|
|
{
|
|
|
|
cfg->passive[0] =
|
2011-05-31 21:38:56 +08:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
|
2011-05-10 19:38:59 +08:00
|
|
|
IEEE80211_BAND_2GHZ,
|
2011-05-31 21:38:56 +08:00
|
|
|
false, true, 0,
|
|
|
|
MAX_CHANNELS_2GHZ);
|
2011-05-10 19:38:59 +08:00
|
|
|
cfg->active[0] =
|
2011-05-31 21:38:56 +08:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
|
2011-05-10 19:38:59 +08:00
|
|
|
IEEE80211_BAND_2GHZ,
|
2011-05-31 21:38:56 +08:00
|
|
|
false, false,
|
|
|
|
cfg->passive[0],
|
|
|
|
MAX_CHANNELS_2GHZ);
|
2011-05-10 19:38:59 +08:00
|
|
|
cfg->passive[1] =
|
2011-05-31 21:38:56 +08:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
|
2011-05-10 19:38:59 +08:00
|
|
|
IEEE80211_BAND_5GHZ,
|
2011-05-31 21:38:56 +08:00
|
|
|
false, true, 0,
|
|
|
|
MAX_CHANNELS_5GHZ);
|
2011-05-27 20:34:46 +08:00
|
|
|
cfg->dfs =
|
2011-05-31 21:38:56 +08:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
|
2011-05-10 19:38:59 +08:00
|
|
|
IEEE80211_BAND_5GHZ,
|
2011-05-31 21:38:56 +08:00
|
|
|
true, true,
|
|
|
|
cfg->passive[1],
|
|
|
|
MAX_CHANNELS_5GHZ);
|
2011-05-27 20:34:46 +08:00
|
|
|
cfg->active[1] =
|
2011-05-31 21:38:56 +08:00
|
|
|
wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
|
2011-05-10 19:38:59 +08:00
|
|
|
IEEE80211_BAND_5GHZ,
|
2011-05-31 21:38:56 +08:00
|
|
|
false, false,
|
|
|
|
cfg->passive[1] + cfg->dfs,
|
|
|
|
MAX_CHANNELS_5GHZ);
|
|
|
|
/* 802.11j channels are not supported yet */
|
|
|
|
cfg->passive[2] = 0;
|
|
|
|
cfg->active[2] = 0;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
int wl1271_scan_sched_scan_config(struct wl1271 *wl,
|
|
|
|
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 21:38:56 +08:00
|
|
|
int i, ret;
|
2011-05-27 20:34:48 +08:00
|
|
|
bool force_passive = !req->n_ssids;
|
2011-05-10 19:38:59 +08:00
|
|
|
|
|
|
|
wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config");
|
|
|
|
|
|
|
|
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
|
|
|
|
if (!cfg)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
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-05-27 20:34:48 +08:00
|
|
|
if (!force_passive && req->ssids[0].ssid_len && req->ssids[0].ssid) {
|
2011-05-10 19:38:59 +08:00
|
|
|
cfg->filter_type = SCAN_SSID_FILTER_SPECIFIC;
|
|
|
|
cfg->ssid_len = req->ssids[0].ssid_len;
|
|
|
|
memcpy(cfg->ssid, req->ssids[0].ssid,
|
|
|
|
req->ssids[0].ssid_len);
|
|
|
|
} else {
|
|
|
|
cfg->filter_type = SCAN_SSID_FILTER_ANY;
|
|
|
|
cfg->ssid_len = 0;
|
|
|
|
}
|
|
|
|
|
2011-05-31 21:38:56 +08:00
|
|
|
if (!wl1271_scan_sched_scan_channels(wl, req, cfg)) {
|
2011-05-10 19:38:59 +08:00
|
|
|
wl1271_error("scan channel list is empty");
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-05-27 20:34:48 +08:00
|
|
|
if (!force_passive && cfg->active[0]) {
|
2011-05-10 19:38:59 +08:00
|
|
|
ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
|
|
|
|
req->ssids[0].ssid_len,
|
|
|
|
ies->ie[IEEE80211_BAND_2GHZ],
|
|
|
|
ies->len[IEEE80211_BAND_2GHZ],
|
|
|
|
IEEE80211_BAND_2GHZ);
|
|
|
|
if (ret < 0) {
|
|
|
|
wl1271_error("2.4GHz PROBE request template failed");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 20:34:48 +08:00
|
|
|
if (!force_passive && cfg->active[1]) {
|
2011-05-10 19:38:59 +08:00
|
|
|
ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
|
|
|
|
req->ssids[0].ssid_len,
|
|
|
|
ies->ie[IEEE80211_BAND_5GHZ],
|
|
|
|
ies->len[IEEE80211_BAND_5GHZ],
|
|
|
|
IEEE80211_BAND_5GHZ);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int wl1271_scan_sched_scan_start(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
struct wl1271_cmd_sched_scan_start *start;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
wl1271_debug(DEBUG_CMD, "cmd periodic scan start");
|
|
|
|
|
2011-05-12 22:07:55 +08:00
|
|
|
if (wl->bss_type != BSS_TYPE_STA_BSS)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!test_bit(WL1271_FLAG_IDLE, &wl->flags))
|
|
|
|
return -EBUSY;
|
|
|
|
|
2011-05-10 19:38:59 +08:00
|
|
|
start = kzalloc(sizeof(*start), GFP_KERNEL);
|
|
|
|
if (!start)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wl1271_scan_sched_scan_stop(struct wl1271 *wl)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
stop->tag = WL1271_SCAN_DEFAULT_TAG;
|
|
|
|
|
|
|
|
ret = wl1271_cmd_send(wl, CMD_STOP_PERIODIC_SCAN, stop,
|
|
|
|
sizeof(*stop), 0);
|
2011-05-10 19:46:02 +08:00
|
|
|
if (ret < 0) {
|
2011-05-10 19:38:59 +08:00
|
|
|
wl1271_error("failed to send sched scan stop command");
|
2011-05-10 19:46:02 +08:00
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
wl->sched_scanning = false;
|
2011-05-10 19:38:59 +08:00
|
|
|
|
2011-05-10 19:46:02 +08:00
|
|
|
out_free:
|
2011-05-10 19:38:59 +08:00
|
|
|
kfree(stop);
|
|
|
|
}
|