blob: 15177bdfb54283c938683452a50c64936889bcc8 [file] [log] [blame]
Luciano Coelho34dd2aa2010-07-08 17:50:06 +03001/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 2009-2010 Nokia Corporation
5 *
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
Shahar Levi00d20102010-11-08 11:20:10 +000024#ifndef __SCAN_H__
25#define __SCAN_H__
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030026
Shahar Levi00d20102010-11-08 11:20:10 +000027#include "wl12xx.h"
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030028
Eliad Peller784f6942011-10-05 11:55:39 +020029int wl1271_scan(struct wl1271 *wl, struct ieee80211_vif *vif,
30 const u8 *ssid, size_t ssid_len,
Luciano Coelho08688d62010-07-08 17:50:07 +030031 struct cfg80211_scan_request *req);
Eliad Peller2aa01592011-06-27 13:06:44 +030032int wl1271_scan_stop(struct wl1271 *wl);
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030033int wl1271_scan_build_probe_req(struct wl1271 *wl,
34 const u8 *ssid, size_t ssid_len,
35 const u8 *ie, size_t ie_len, u8 band);
Eliad Peller784f6942011-10-05 11:55:39 +020036void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif);
Juuso Oikarinenc454f1d2010-08-24 06:28:03 +030037void wl1271_scan_complete_work(struct work_struct *work);
Luciano Coelho95feadc2011-05-10 14:38:59 +030038int wl1271_scan_sched_scan_config(struct wl1271 *wl,
39 struct cfg80211_sched_scan_request *req,
40 struct ieee80211_sched_scan_ies *ies);
41int wl1271_scan_sched_scan_start(struct wl1271 *wl);
42void wl1271_scan_sched_scan_stop(struct wl1271 *wl);
43void wl1271_scan_sched_scan_results(struct wl1271 *wl);
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030044
45#define WL1271_SCAN_MAX_CHANNELS 24
46#define WL1271_SCAN_DEFAULT_TAG 1
47#define WL1271_SCAN_CURRENT_TX_PWR 0
48#define WL1271_SCAN_OPT_ACTIVE 0
49#define WL1271_SCAN_OPT_PASSIVE 1
Eliad Pellera4e02f32011-08-14 13:17:10 +030050#define WL1271_SCAN_OPT_TRIGGERED_SCAN 2
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030051#define WL1271_SCAN_OPT_PRIORITY_HIGH 4
Eliad Pellera4e02f32011-08-14 13:17:10 +030052/* scan even if we fail to enter psm */
53#define WL1271_SCAN_OPT_FORCE 8
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030054#define WL1271_SCAN_BAND_2_4_GHZ 0
55#define WL1271_SCAN_BAND_5_GHZ 1
Luciano Coelho08688d62010-07-08 17:50:07 +030056
Juuso Oikarinen78abd322010-09-21 06:23:32 +020057#define WL1271_SCAN_TIMEOUT 10000 /* msec */
58
Luciano Coelho08688d62010-07-08 17:50:07 +030059enum {
60 WL1271_SCAN_STATE_IDLE,
61 WL1271_SCAN_STATE_2GHZ_ACTIVE,
62 WL1271_SCAN_STATE_2GHZ_PASSIVE,
63 WL1271_SCAN_STATE_5GHZ_ACTIVE,
64 WL1271_SCAN_STATE_5GHZ_PASSIVE,
65 WL1271_SCAN_STATE_DONE
66};
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030067
68struct basic_scan_params {
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030069 /* Scan option flags (WL1271_SCAN_OPT_*) */
70 __le16 scan_options;
Eliad Pellera4e02f32011-08-14 13:17:10 +030071 u8 role_id;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030072 /* Number of scan channels in the list (maximum 30) */
Luciano Coelho08688d62010-07-08 17:50:07 +030073 u8 n_ch;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030074 /* This field indicates the number of probe requests to send
75 per channel for an active scan */
Luciano Coelho08688d62010-07-08 17:50:07 +030076 u8 n_probe_reqs;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030077 u8 tid_trigger;
78 u8 ssid_len;
Eliad Pellera4e02f32011-08-14 13:17:10 +030079 u8 use_ssid_list;
80
81 /* Rate bit field for sending the probes */
82 __le32 tx_rate;
83
Johannes Berg3b40c042011-07-13 10:39:16 +020084 u8 ssid[IEEE80211_MAX_SSID_LEN];
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030085 /* Band to scan */
86 u8 band;
Eliad Pellera4e02f32011-08-14 13:17:10 +030087
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030088 u8 scan_tag;
Eliad Pellera4e02f32011-08-14 13:17:10 +030089 u8 padding2[2];
Luciano Coelho72e93e92010-07-09 14:10:58 +030090} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030091
92struct basic_scan_channel_params {
93 /* Duration in TU to wait for frames on a channel for active scan */
94 __le32 min_duration;
95 __le32 max_duration;
96 __le32 bssid_lsb;
97 __le16 bssid_msb;
98 u8 early_termination;
99 u8 tx_power_att;
100 u8 channel;
101 /* FW internal use only! */
102 u8 dfs_candidate;
103 u8 activity_detected;
104 u8 pad;
Luciano Coelho72e93e92010-07-09 14:10:58 +0300105} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300106
107struct wl1271_cmd_scan {
108 struct wl1271_cmd_header header;
109
110 struct basic_scan_params params;
111 struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
Eliad Pellera4e02f32011-08-14 13:17:10 +0300112
113 /* src mac address */
114 u8 addr[ETH_ALEN];
115 u8 padding[2];
Luciano Coelho72e93e92010-07-09 14:10:58 +0300116} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300117
118struct wl1271_cmd_trigger_scan_to {
119 struct wl1271_cmd_header header;
120
121 __le32 timeout;
Luciano Coelho72e93e92010-07-09 14:10:58 +0300122} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300123
Luciano Coelhod2c2bb92011-05-31 16:38:56 +0300124#define MAX_CHANNELS_2GHZ 14
125#define MAX_CHANNELS_5GHZ 23
126#define MAX_CHANNELS_4GHZ 4
127
Luciano Coelho95feadc2011-05-10 14:38:59 +0300128#define SCAN_MAX_CYCLE_INTERVALS 16
129#define SCAN_MAX_BANDS 3
130
131enum {
Luciano Coelho95feadc2011-05-10 14:38:59 +0300132 SCAN_SSID_FILTER_ANY = 0,
133 SCAN_SSID_FILTER_SPECIFIC = 1,
134 SCAN_SSID_FILTER_LIST = 2,
135 SCAN_SSID_FILTER_DISABLED = 3
136};
137
138enum {
139 SCAN_BSS_TYPE_INDEPENDENT,
140 SCAN_BSS_TYPE_INFRASTRUCTURE,
141 SCAN_BSS_TYPE_ANY,
142};
143
Luciano Coelho2497a242011-05-27 15:34:46 +0300144#define SCAN_CHANNEL_FLAGS_DFS BIT(0)
145#define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
146
Luciano Coelho95feadc2011-05-10 14:38:59 +0300147struct conn_scan_ch_params {
148 __le16 min_duration;
149 __le16 max_duration;
150 __le16 passive_duration;
151
152 u8 channel;
153 u8 tx_power_att;
154
155 /* bit 0: DFS channel; bit 1: DFS enabled */
156 u8 flags;
157
158 u8 padding[3];
159} __packed;
160
161struct wl1271_cmd_sched_scan_config {
162 struct wl1271_cmd_header header;
163
164 __le32 intervals[SCAN_MAX_CYCLE_INTERVALS];
165
166 s8 rssi_threshold; /* for filtering (in dBm) */
167 s8 snr_threshold; /* for filtering (in dB) */
168
169 u8 cycles; /* maximum number of scan cycles */
170 u8 report_after; /* report when this number of results are received */
171 u8 terminate; /* stop scanning after reporting */
172
173 u8 tag;
174 u8 bss_type; /* for filtering */
175 u8 filter_type;
176
177 u8 ssid_len; /* For SCAN_SSID_FILTER_SPECIFIC */
Johannes Berg3b40c042011-07-13 10:39:16 +0200178 u8 ssid[IEEE80211_MAX_SSID_LEN];
Luciano Coelho95feadc2011-05-10 14:38:59 +0300179
180 u8 n_probe_reqs; /* Number of probes requests per channel */
181
182 u8 passive[SCAN_MAX_BANDS];
183 u8 active[SCAN_MAX_BANDS];
184
185 u8 dfs;
186
187 u8 padding[3];
188
Luciano Coelhod2c2bb92011-05-31 16:38:56 +0300189 struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
190 struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
191 struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
Luciano Coelho95feadc2011-05-10 14:38:59 +0300192} __packed;
193
194
Eliad Pellera4e02f32011-08-14 13:17:10 +0300195#define SCHED_SCAN_MAX_SSIDS 16
Luciano Coelho95feadc2011-05-10 14:38:59 +0300196
197enum {
198 SCAN_SSID_TYPE_PUBLIC = 0,
199 SCAN_SSID_TYPE_HIDDEN = 1,
200};
201
202struct wl1271_ssid {
203 u8 type;
204 u8 len;
Johannes Berg3b40c042011-07-13 10:39:16 +0200205 u8 ssid[IEEE80211_MAX_SSID_LEN];
Luciano Coelho95feadc2011-05-10 14:38:59 +0300206 /* u8 padding[2]; */
207} __packed;
208
209struct wl1271_cmd_sched_scan_ssid_list {
210 struct wl1271_cmd_header header;
211
212 u8 n_ssids;
213 struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS];
214 u8 padding[3];
215} __packed;
216
217struct wl1271_cmd_sched_scan_start {
218 struct wl1271_cmd_header header;
219
220 u8 tag;
221 u8 padding[3];
222} __packed;
223
224struct wl1271_cmd_sched_scan_stop {
225 struct wl1271_cmd_header header;
226
227 u8 tag;
228 u8 padding[3];
229} __packed;
230
231
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300232#endif /* __WL1271_SCAN_H__ */