blob: ca81de20ebef838018511195624b0b61eb23912c [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
29int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
Luciano Coelho08688d62010-07-08 17:50:07 +030030 struct cfg80211_scan_request *req);
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030031int wl1271_scan_build_probe_req(struct wl1271 *wl,
32 const u8 *ssid, size_t ssid_len,
33 const u8 *ie, size_t ie_len, u8 band);
Luciano Coelho08688d62010-07-08 17:50:07 +030034void wl1271_scan_stm(struct wl1271 *wl);
Juuso Oikarinenc454f1d2010-08-24 06:28:03 +030035void wl1271_scan_complete_work(struct work_struct *work);
Luciano Coelho95feadc2011-05-10 14:38:59 +030036int wl1271_scan_sched_scan_config(struct wl1271 *wl,
37 struct cfg80211_sched_scan_request *req,
38 struct ieee80211_sched_scan_ies *ies);
39int wl1271_scan_sched_scan_start(struct wl1271 *wl);
40void wl1271_scan_sched_scan_stop(struct wl1271 *wl);
41void wl1271_scan_sched_scan_results(struct wl1271 *wl);
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030042
43#define WL1271_SCAN_MAX_CHANNELS 24
44#define WL1271_SCAN_DEFAULT_TAG 1
45#define WL1271_SCAN_CURRENT_TX_PWR 0
46#define WL1271_SCAN_OPT_ACTIVE 0
47#define WL1271_SCAN_OPT_PASSIVE 1
48#define WL1271_SCAN_OPT_PRIORITY_HIGH 4
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030049#define WL1271_SCAN_BAND_2_4_GHZ 0
50#define WL1271_SCAN_BAND_5_GHZ 1
Luciano Coelho08688d62010-07-08 17:50:07 +030051
Juuso Oikarinen78abd322010-09-21 06:23:32 +020052#define WL1271_SCAN_TIMEOUT 10000 /* msec */
53
Luciano Coelho08688d62010-07-08 17:50:07 +030054enum {
55 WL1271_SCAN_STATE_IDLE,
56 WL1271_SCAN_STATE_2GHZ_ACTIVE,
57 WL1271_SCAN_STATE_2GHZ_PASSIVE,
58 WL1271_SCAN_STATE_5GHZ_ACTIVE,
59 WL1271_SCAN_STATE_5GHZ_PASSIVE,
60 WL1271_SCAN_STATE_DONE
61};
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030062
63struct basic_scan_params {
64 __le32 rx_config_options;
65 __le32 rx_filter_options;
66 /* Scan option flags (WL1271_SCAN_OPT_*) */
67 __le16 scan_options;
68 /* Number of scan channels in the list (maximum 30) */
Luciano Coelho08688d62010-07-08 17:50:07 +030069 u8 n_ch;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030070 /* This field indicates the number of probe requests to send
71 per channel for an active scan */
Luciano Coelho08688d62010-07-08 17:50:07 +030072 u8 n_probe_reqs;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030073 /* Rate bit field for sending the probes */
74 __le32 tx_rate;
75 u8 tid_trigger;
76 u8 ssid_len;
77 /* in order to align */
78 u8 padding1[2];
79 u8 ssid[IW_ESSID_MAX_SIZE];
80 /* Band to scan */
81 u8 band;
82 u8 use_ssid_list;
83 u8 scan_tag;
84 u8 padding2;
Luciano Coelho72e93e92010-07-09 14:10:58 +030085} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +030086
87struct basic_scan_channel_params {
88 /* Duration in TU to wait for frames on a channel for active scan */
89 __le32 min_duration;
90 __le32 max_duration;
91 __le32 bssid_lsb;
92 __le16 bssid_msb;
93 u8 early_termination;
94 u8 tx_power_att;
95 u8 channel;
96 /* FW internal use only! */
97 u8 dfs_candidate;
98 u8 activity_detected;
99 u8 pad;
Luciano Coelho72e93e92010-07-09 14:10:58 +0300100} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300101
102struct wl1271_cmd_scan {
103 struct wl1271_cmd_header header;
104
105 struct basic_scan_params params;
106 struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
Luciano Coelho72e93e92010-07-09 14:10:58 +0300107} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300108
109struct wl1271_cmd_trigger_scan_to {
110 struct wl1271_cmd_header header;
111
112 __le32 timeout;
Luciano Coelho72e93e92010-07-09 14:10:58 +0300113} __packed;
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300114
Luciano Coelhod2c2bb92011-05-31 16:38:56 +0300115#define MAX_CHANNELS_2GHZ 14
116#define MAX_CHANNELS_5GHZ 23
117#define MAX_CHANNELS_4GHZ 4
118
Luciano Coelho95feadc2011-05-10 14:38:59 +0300119#define SCAN_MAX_CYCLE_INTERVALS 16
120#define SCAN_MAX_BANDS 3
121
122enum {
Luciano Coelho95feadc2011-05-10 14:38:59 +0300123 SCAN_SSID_FILTER_ANY = 0,
124 SCAN_SSID_FILTER_SPECIFIC = 1,
125 SCAN_SSID_FILTER_LIST = 2,
126 SCAN_SSID_FILTER_DISABLED = 3
127};
128
129enum {
130 SCAN_BSS_TYPE_INDEPENDENT,
131 SCAN_BSS_TYPE_INFRASTRUCTURE,
132 SCAN_BSS_TYPE_ANY,
133};
134
Luciano Coelho2497a242011-05-27 15:34:46 +0300135#define SCAN_CHANNEL_FLAGS_DFS BIT(0)
136#define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
137
Luciano Coelho95feadc2011-05-10 14:38:59 +0300138struct conn_scan_ch_params {
139 __le16 min_duration;
140 __le16 max_duration;
141 __le16 passive_duration;
142
143 u8 channel;
144 u8 tx_power_att;
145
146 /* bit 0: DFS channel; bit 1: DFS enabled */
147 u8 flags;
148
149 u8 padding[3];
150} __packed;
151
152struct wl1271_cmd_sched_scan_config {
153 struct wl1271_cmd_header header;
154
155 __le32 intervals[SCAN_MAX_CYCLE_INTERVALS];
156
157 s8 rssi_threshold; /* for filtering (in dBm) */
158 s8 snr_threshold; /* for filtering (in dB) */
159
160 u8 cycles; /* maximum number of scan cycles */
161 u8 report_after; /* report when this number of results are received */
162 u8 terminate; /* stop scanning after reporting */
163
164 u8 tag;
165 u8 bss_type; /* for filtering */
166 u8 filter_type;
167
168 u8 ssid_len; /* For SCAN_SSID_FILTER_SPECIFIC */
169 u8 ssid[IW_ESSID_MAX_SIZE];
170
171 u8 n_probe_reqs; /* Number of probes requests per channel */
172
173 u8 passive[SCAN_MAX_BANDS];
174 u8 active[SCAN_MAX_BANDS];
175
176 u8 dfs;
177
178 u8 padding[3];
179
Luciano Coelhod2c2bb92011-05-31 16:38:56 +0300180 struct conn_scan_ch_params channels_2[MAX_CHANNELS_2GHZ];
181 struct conn_scan_ch_params channels_5[MAX_CHANNELS_5GHZ];
182 struct conn_scan_ch_params channels_4[MAX_CHANNELS_4GHZ];
Luciano Coelho95feadc2011-05-10 14:38:59 +0300183} __packed;
184
185
186#define SCHED_SCAN_MAX_SSIDS 8
187
188enum {
189 SCAN_SSID_TYPE_PUBLIC = 0,
190 SCAN_SSID_TYPE_HIDDEN = 1,
191};
192
193struct wl1271_ssid {
194 u8 type;
195 u8 len;
196 u8 ssid[IW_ESSID_MAX_SIZE];
197 /* u8 padding[2]; */
198} __packed;
199
200struct wl1271_cmd_sched_scan_ssid_list {
201 struct wl1271_cmd_header header;
202
203 u8 n_ssids;
204 struct wl1271_ssid ssids[SCHED_SCAN_MAX_SSIDS];
205 u8 padding[3];
206} __packed;
207
208struct wl1271_cmd_sched_scan_start {
209 struct wl1271_cmd_header header;
210
211 u8 tag;
212 u8 padding[3];
213} __packed;
214
215struct wl1271_cmd_sched_scan_stop {
216 struct wl1271_cmd_header header;
217
218 u8 tag;
219 u8 padding[3];
220} __packed;
221
222
Luciano Coelho34dd2aa2010-07-08 17:50:06 +0300223#endif /* __WL1271_SCAN_H__ */