blob: c02a9e45ec5eaec78ce9ef49c47957c6fcd2c7da [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02008 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8ca151b2013-01-24 14:25:36 +01009 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020025 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010026 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +020033 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
Johannes Berg8ca151b2013-01-24 14:25:36 +010034 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63
64#ifndef __fw_api_scan_h__
65#define __fw_api_scan_h__
66
67#include "fw-api.h"
68
69/* Scan Commands, Responses, Notifications */
70
71/* Masks for iwl_scan_channel.type flags */
Johannes Berg8ca151b2013-01-24 14:25:36 +010072#define SCAN_CHANNEL_TYPE_ACTIVE BIT(0)
73#define SCAN_CHANNEL_NARROW_BAND BIT(22)
74
75/* Max number of IEs for direct SSID scans in a command */
76#define PROBE_OPTION_MAX 20
77
78/**
79 * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table
80 * @channel: band is selected by iwl_scan_cmd "flags" field
81 * @tx_gain: gain for analog radio
82 * @dsp_atten: gain for DSP
83 * @active_dwell: dwell time for active scan in TU, typically 5-50
84 * @passive_dwell: dwell time for passive scan in TU, typically 20-500
85 * @type: type is broken down to these bits:
86 * bit 0: 0 = passive, 1 = active
87 * bits 1-20: SSID direct bit map. If any of these bits is set then
88 * the corresponding SSID IE is transmitted in probe request
89 * (bit i adds IE in position i to the probe request)
90 * bit 22: channel width, 0 = regular, 1 = TGj narrow channel
91 *
92 * @iteration_count:
93 * @iteration_interval:
94 * This struct is used once for each channel in the scan list.
95 * Each channel can independently select:
96 * 1) SSID for directed active scans
97 * 2) Txpower setting (for rate specified within Tx command)
98 * 3) How long to stay on-channel (behavior may be modified by quiet_time,
99 * quiet_plcp_th, good_CRC_th)
100 *
101 * To avoid uCode errors, make sure the following are true (see comments
102 * under struct iwl_scan_cmd about max_out_time and quiet_time):
103 * 1) If using passive_dwell (i.e. passive_dwell != 0):
104 * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0)
105 * 2) quiet_time <= active_dwell
106 * 3) If restricting off-channel time (i.e. max_out_time !=0):
107 * passive_dwell < max_out_time
108 * active_dwell < max_out_time
109 */
110struct iwl_scan_channel {
111 __le32 type;
112 __le16 channel;
113 __le16 iteration_count;
114 __le32 iteration_interval;
115 __le16 active_dwell;
116 __le16 passive_dwell;
117} __packed; /* SCAN_CHANNEL_CONTROL_API_S_VER_1 */
118
119/**
120 * struct iwl_ssid_ie - directed scan network information element
121 *
122 * Up to 20 of these may appear in REPLY_SCAN_CMD,
123 * selected by "type" bit field in struct iwl_scan_channel;
124 * each channel may select different ssids from among the 20 entries.
125 * SSID IEs get transmitted in reverse order of entry.
126 */
127struct iwl_ssid_ie {
128 u8 id;
129 u8 len;
130 u8 ssid[IEEE80211_MAX_SSID_LEN];
131} __packed; /* SCAN_DIRECT_SSID_IE_API_S_VER_1 */
132
133/**
134 * iwl_scan_flags - masks for scan command flags
135 *@SCAN_FLAGS_PERIODIC_SCAN:
136 *@SCAN_FLAGS_P2P_PUBLIC_ACTION_FRAME_TX:
137 *@SCAN_FLAGS_DELAYED_SCAN_LOWBAND:
138 *@SCAN_FLAGS_DELAYED_SCAN_HIGHBAND:
139 *@SCAN_FLAGS_FRAGMENTED_SCAN:
David Spinadel26e05cc2013-07-08 13:12:29 +0300140 *@SCAN_FLAGS_PASSIVE2ACTIVE: use active scan on channels that was active
141 * in the past hour, even if they are marked as passive.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100142 */
143enum iwl_scan_flags {
144 SCAN_FLAGS_PERIODIC_SCAN = BIT(0),
145 SCAN_FLAGS_P2P_PUBLIC_ACTION_FRAME_TX = BIT(1),
146 SCAN_FLAGS_DELAYED_SCAN_LOWBAND = BIT(2),
147 SCAN_FLAGS_DELAYED_SCAN_HIGHBAND = BIT(3),
148 SCAN_FLAGS_FRAGMENTED_SCAN = BIT(4),
David Spinadel26e05cc2013-07-08 13:12:29 +0300149 SCAN_FLAGS_PASSIVE2ACTIVE = BIT(5),
Johannes Berg8ca151b2013-01-24 14:25:36 +0100150};
151
152/**
153 * enum iwl_scan_type - Scan types for scan command
154 * @SCAN_TYPE_FORCED:
155 * @SCAN_TYPE_BACKGROUND:
156 * @SCAN_TYPE_OS:
157 * @SCAN_TYPE_ROAMING:
158 * @SCAN_TYPE_ACTION:
159 * @SCAN_TYPE_DISCOVERY:
160 * @SCAN_TYPE_DISCOVERY_FORCED:
161 */
162enum iwl_scan_type {
163 SCAN_TYPE_FORCED = 0,
164 SCAN_TYPE_BACKGROUND = 1,
165 SCAN_TYPE_OS = 2,
166 SCAN_TYPE_ROAMING = 3,
167 SCAN_TYPE_ACTION = 4,
168 SCAN_TYPE_DISCOVERY = 5,
169 SCAN_TYPE_DISCOVERY_FORCED = 6,
170}; /* SCAN_ACTIVITY_TYPE_E_VER_1 */
171
Eran Harary749f1fe2014-03-06 09:25:30 +0200172/**
Johannes Berg8ca151b2013-01-24 14:25:36 +0100173 * struct iwl_scan_cmd - scan request command
174 * ( SCAN_REQUEST_CMD = 0x80 )
175 * @len: command length in bytes
176 * @scan_flags: scan flags from SCAN_FLAGS_*
David Spinadel762533b2014-06-05 11:20:43 +0300177 * @channel_count: num of channels in channel list
178 * (1 - ucode_capa.n_scan_channels)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100179 * @quiet_time: in msecs, dwell this time for active scan on quiet channels
180 * @quiet_plcp_th: quiet PLCP threshold (channel is quiet if less than
181 * this number of packets were received (typically 1)
David Spinadel26e05cc2013-07-08 13:12:29 +0300182 * @passive2active: is auto switching from passive to active during scan allowed
Johannes Berg8ca151b2013-01-24 14:25:36 +0100183 * @rxchain_sel_flags: RXON_RX_CHAIN_*
Alexander Bondaref67f18d2014-03-30 10:47:08 +0300184 * @max_out_time: in TUs, max out of serving channel time
Johannes Berg8ca151b2013-01-24 14:25:36 +0100185 * @suspend_time: how long to pause scan when returning to service channel:
Alexander Bondaref67f18d2014-03-30 10:47:08 +0300186 * bits 0-19: beacon interal in TUs (suspend before executing)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100187 * bits 20-23: reserved
188 * bits 24-31: number of beacons (suspend between channels)
189 * @rxon_flags: RXON_FLG_*
190 * @filter_flags: RXON_FILTER_*
191 * @tx_cmd: for active scans (zero for passive), w/o payload,
192 * no RS so specify TX rate
193 * @direct_scan: direct scan SSIDs
194 * @type: one of SCAN_TYPE_*
195 * @repeats: how many time to repeat the scan
196 */
197struct iwl_scan_cmd {
198 __le16 len;
199 u8 scan_flags;
200 u8 channel_count;
201 __le16 quiet_time;
202 __le16 quiet_plcp_th;
203 __le16 passive2active;
204 __le16 rxchain_sel_flags;
205 __le32 max_out_time;
206 __le32 suspend_time;
207 /* RX_ON_FLAGS_API_S_VER_1 */
208 __le32 rxon_flags;
209 __le32 filter_flags;
210 struct iwl_tx_cmd tx_cmd;
211 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
212 __le32 type;
213 __le32 repeats;
214
215 /*
216 * Probe request frame, followed by channel list.
217 *
218 * Size of probe request frame is specified by byte count in tx_cmd.
219 * Channel list follows immediately after probe request frame.
220 * Number of channels in list is specified by channel_count.
221 * Each channel in list is of type:
222 *
223 * struct iwl_scan_channel channels[0];
224 *
225 * NOTE: Only one band of channels can be scanned per pass. You
226 * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait
227 * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION)
228 * before requesting another scan.
229 */
230 u8 data[0];
231} __packed; /* SCAN_REQUEST_FIXED_PART_API_S_VER_5 */
232
233/* Response to scan request contains only status with one of these values */
234#define SCAN_RESPONSE_OK 0x1
235#define SCAN_RESPONSE_ERROR 0x2
236
237/*
238 * SCAN_ABORT_CMD = 0x81
239 * When scan abort is requested, the command has no fields except the common
240 * header. The response contains only a status with one of these values.
241 */
242#define SCAN_ABORT_POSSIBLE 0x1
243#define SCAN_ABORT_IGNORED 0x2 /* no pending scans */
244
245/* TODO: complete documentation */
246#define SCAN_OWNER_STATUS 0x1
247#define MEASURE_OWNER_STATUS 0x2
248
249/**
250 * struct iwl_scan_start_notif - notifies start of scan in the device
251 * ( SCAN_START_NOTIFICATION = 0x82 )
252 * @tsf_low: TSF timer (lower half) in usecs
253 * @tsf_high: TSF timer (higher half) in usecs
254 * @beacon_timer: structured as follows:
255 * bits 0:19 - beacon interval in usecs
256 * bits 20:23 - reserved (0)
257 * bits 24:31 - number of beacons
258 * @channel: which channel is scanned
259 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
260 * @status: one of *_OWNER_STATUS
261 */
262struct iwl_scan_start_notif {
263 __le32 tsf_low;
264 __le32 tsf_high;
265 __le32 beacon_timer;
266 u8 channel;
267 u8 band;
268 u8 reserved[2];
269 __le32 status;
270} __packed; /* SCAN_START_NTF_API_S_VER_1 */
271
272/* scan results probe_status first bit indicates success */
273#define SCAN_PROBE_STATUS_OK 0
274#define SCAN_PROBE_STATUS_TX_FAILED BIT(0)
275/* error statuses combined with TX_FAILED */
276#define SCAN_PROBE_STATUS_FAIL_TTL BIT(1)
277#define SCAN_PROBE_STATUS_FAIL_BT BIT(2)
278
279/* How many statistics are gathered for each channel */
280#define SCAN_RESULTS_STATISTICS 1
281
282/**
283 * enum iwl_scan_complete_status - status codes for scan complete notifications
284 * @SCAN_COMP_STATUS_OK: scan completed successfully
285 * @SCAN_COMP_STATUS_ABORT: scan was aborted by user
286 * @SCAN_COMP_STATUS_ERR_SLEEP: sending null sleep packet failed
287 * @SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT: timeout before channel is ready
288 * @SCAN_COMP_STATUS_ERR_PROBE: sending probe request failed
289 * @SCAN_COMP_STATUS_ERR_WAKEUP: sending null wakeup packet failed
290 * @SCAN_COMP_STATUS_ERR_ANTENNAS: invalid antennas chosen at scan command
291 * @SCAN_COMP_STATUS_ERR_INTERNAL: internal error caused scan abort
292 * @SCAN_COMP_STATUS_ERR_COEX: medium was lost ot WiMax
293 * @SCAN_COMP_STATUS_P2P_ACTION_OK: P2P public action frame TX was successful
294 * (not an error!)
295 * @SCAN_COMP_STATUS_ITERATION_END: indicates end of one repeatition the driver
296 * asked for
297 * @SCAN_COMP_STATUS_ERR_ALLOC_TE: scan could not allocate time events
298*/
299enum iwl_scan_complete_status {
300 SCAN_COMP_STATUS_OK = 0x1,
301 SCAN_COMP_STATUS_ABORT = 0x2,
302 SCAN_COMP_STATUS_ERR_SLEEP = 0x3,
303 SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT = 0x4,
304 SCAN_COMP_STATUS_ERR_PROBE = 0x5,
305 SCAN_COMP_STATUS_ERR_WAKEUP = 0x6,
306 SCAN_COMP_STATUS_ERR_ANTENNAS = 0x7,
307 SCAN_COMP_STATUS_ERR_INTERNAL = 0x8,
308 SCAN_COMP_STATUS_ERR_COEX = 0x9,
309 SCAN_COMP_STATUS_P2P_ACTION_OK = 0xA,
310 SCAN_COMP_STATUS_ITERATION_END = 0x0B,
311 SCAN_COMP_STATUS_ERR_ALLOC_TE = 0x0C,
312};
313
314/**
315 * struct iwl_scan_results_notif - scan results for one channel
316 * ( SCAN_RESULTS_NOTIFICATION = 0x83 )
317 * @channel: which channel the results are from
318 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
319 * @probe_status: SCAN_PROBE_STATUS_*, indicates success of probe request
320 * @num_probe_not_sent: # of request that weren't sent due to not enough time
321 * @duration: duration spent in channel, in usecs
322 * @statistics: statistics gathered for this channel
323 */
324struct iwl_scan_results_notif {
325 u8 channel;
326 u8 band;
327 u8 probe_status;
328 u8 num_probe_not_sent;
329 __le32 duration;
330 __le32 statistics[SCAN_RESULTS_STATISTICS];
331} __packed; /* SCAN_RESULT_NTF_API_S_VER_2 */
332
333/**
334 * struct iwl_scan_complete_notif - notifies end of scanning (all channels)
335 * ( SCAN_COMPLETE_NOTIFICATION = 0x84 )
336 * @scanned_channels: number of channels scanned (and number of valid results)
337 * @status: one of SCAN_COMP_STATUS_*
338 * @bt_status: BT on/off status
339 * @last_channel: last channel that was scanned
340 * @tsf_low: TSF timer (lower half) in usecs
341 * @tsf_high: TSF timer (higher half) in usecs
David Spinadel762533b2014-06-05 11:20:43 +0300342 * @results: array of scan results, only "scanned_channels" of them are valid
Johannes Berg8ca151b2013-01-24 14:25:36 +0100343 */
344struct iwl_scan_complete_notif {
345 u8 scanned_channels;
346 u8 status;
347 u8 bt_status;
348 u8 last_channel;
349 __le32 tsf_low;
350 __le32 tsf_high;
David Spinadel762533b2014-06-05 11:20:43 +0300351 struct iwl_scan_results_notif results[];
Johannes Berg8ca151b2013-01-24 14:25:36 +0100352} __packed; /* SCAN_COMPLETE_NTF_API_S_VER_2 */
353
354/* scan offload */
Johannes Berg8ca151b2013-01-24 14:25:36 +0100355#define IWL_SCAN_MAX_BLACKLIST_LEN 64
David Spinadel35a000b2013-08-28 09:29:43 +0300356#define IWL_SCAN_SHORT_BLACKLIST_LEN 16
Johannes Berg8ca151b2013-01-24 14:25:36 +0100357#define IWL_SCAN_MAX_PROFILES 11
358#define SCAN_OFFLOAD_PROBE_REQ_SIZE 512
359
360/* Default watchdog (in MS) for scheduled scan iteration */
361#define IWL_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)
362
363#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
364#define CAN_ABORT_STATUS 1
365
366#define IWL_FULL_SCAN_MULTIPLIER 5
367#define IWL_FAST_SCHED_SCAN_ITERATIONS 3
368
David Spinadel35a000b2013-08-28 09:29:43 +0300369enum scan_framework_client {
370 SCAN_CLIENT_SCHED_SCAN = BIT(0),
371 SCAN_CLIENT_NETDETECT = BIT(1),
372 SCAN_CLIENT_ASSET_TRACKING = BIT(2),
373};
374
Johannes Berg8ca151b2013-01-24 14:25:36 +0100375/**
376 * struct iwl_scan_offload_cmd - SCAN_REQUEST_FIXED_PART_API_S_VER_6
377 * @scan_flags: see enum iwl_scan_flags
378 * @channel_count: channels in channel list
379 * @quiet_time: dwell time, in milisiconds, on quiet channel
380 * @quiet_plcp_th: quiet channel num of packets threshold
381 * @good_CRC_th: passive to active promotion threshold
382 * @rx_chain: RXON rx chain.
Alexander Bondaref67f18d2014-03-30 10:47:08 +0300383 * @max_out_time: max TUs to be out of assoceated channel
384 * @suspend_time: pause scan this TUs when returning to service channel
Johannes Berg8ca151b2013-01-24 14:25:36 +0100385 * @flags: RXON flags
386 * @filter_flags: RXONfilter
387 * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz.
388 * @direct_scan: list of SSIDs for directed active scan
389 * @scan_type: see enum iwl_scan_type.
390 * @rep_count: repetition count for each scheduled scan iteration.
391 */
392struct iwl_scan_offload_cmd {
393 __le16 len;
394 u8 scan_flags;
395 u8 channel_count;
396 __le16 quiet_time;
397 __le16 quiet_plcp_th;
398 __le16 good_CRC_th;
399 __le16 rx_chain;
400 __le32 max_out_time;
401 __le32 suspend_time;
402 /* RX_ON_FLAGS_API_S_VER_1 */
403 __le32 flags;
404 __le32 filter_flags;
405 struct iwl_tx_cmd tx_cmd[2];
406 /* SCAN_DIRECT_SSID_IE_API_S_VER_1 */
407 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
408 __le32 scan_type;
409 __le32 rep_count;
410} __packed;
411
412enum iwl_scan_offload_channel_flags {
413 IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE = BIT(0),
414 IWL_SCAN_OFFLOAD_CHANNEL_NARROW = BIT(22),
415 IWL_SCAN_OFFLOAD_CHANNEL_FULL = BIT(24),
416 IWL_SCAN_OFFLOAD_CHANNEL_PARTIAL = BIT(25),
417};
418
David Spinadel762533b2014-06-05 11:20:43 +0300419/* channel configuration for struct iwl_scan_offload_cfg. Each channels needs:
420 * __le32 type: bitmap; bits 1-20 are for directed scan to i'th ssid and
421 * see enum iwl_scan_offload_channel_flags.
422 * __le16 channel_number: channel number 1-13 etc.
423 * __le16 iter_count: repetition count for the channel.
424 * __le32 iter_interval: interval between two innteration on one channel.
425 * u8 active_dwell.
426 * u8 passive_dwell.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100427 */
David Spinadel762533b2014-06-05 11:20:43 +0300428#define IWL_SCAN_CHAN_SIZE 14
Johannes Berg8ca151b2013-01-24 14:25:36 +0100429
430/**
431 * iwl_scan_offload_cfg - SCAN_OFFLOAD_CONFIG_API_S
432 * @scan_cmd: scan command fixed part
David Spinadel762533b2014-06-05 11:20:43 +0300433 * @data: scan channel configuration and probe request frames
Johannes Berg8ca151b2013-01-24 14:25:36 +0100434 */
435struct iwl_scan_offload_cfg {
436 struct iwl_scan_offload_cmd scan_cmd;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100437 u8 data[0];
438} __packed;
439
440/**
441 * iwl_scan_offload_blacklist - SCAN_OFFLOAD_BLACKLIST_S
442 * @ssid: MAC address to filter out
443 * @reported_rssi: AP rssi reported to the host
David Spinadel35a000b2013-08-28 09:29:43 +0300444 * @client_bitmap: clients ignore this entry - enum scan_framework_client
Johannes Berg8ca151b2013-01-24 14:25:36 +0100445 */
446struct iwl_scan_offload_blacklist {
447 u8 ssid[ETH_ALEN];
448 u8 reported_rssi;
David Spinadel35a000b2013-08-28 09:29:43 +0300449 u8 client_bitmap;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100450} __packed;
451
452enum iwl_scan_offload_network_type {
453 IWL_NETWORK_TYPE_BSS = 1,
454 IWL_NETWORK_TYPE_IBSS = 2,
455 IWL_NETWORK_TYPE_ANY = 3,
456};
457
458enum iwl_scan_offload_band_selection {
459 IWL_SCAN_OFFLOAD_SELECT_2_4 = 0x4,
460 IWL_SCAN_OFFLOAD_SELECT_5_2 = 0x8,
461 IWL_SCAN_OFFLOAD_SELECT_ANY = 0xc,
462};
463
464/**
465 * iwl_scan_offload_profile - SCAN_OFFLOAD_PROFILE_S
466 * @ssid_index: index to ssid list in fixed part
467 * @unicast_cipher: encryption olgorithm to match - bitmap
468 * @aut_alg: authentication olgorithm to match - bitmap
469 * @network_type: enum iwl_scan_offload_network_type
470 * @band_selection: enum iwl_scan_offload_band_selection
David Spinadel35a000b2013-08-28 09:29:43 +0300471 * @client_bitmap: clients waiting for match - enum scan_framework_client
Johannes Berg8ca151b2013-01-24 14:25:36 +0100472 */
473struct iwl_scan_offload_profile {
474 u8 ssid_index;
475 u8 unicast_cipher;
476 u8 auth_alg;
477 u8 network_type;
478 u8 band_selection;
David Spinadel35a000b2013-08-28 09:29:43 +0300479 u8 client_bitmap;
480 u8 reserved[2];
Johannes Berg8ca151b2013-01-24 14:25:36 +0100481} __packed;
482
483/**
484 * iwl_scan_offload_profile_cfg - SCAN_OFFLOAD_PROFILES_CFG_API_S_VER_1
485 * @blaclist: AP list to filter off from scan results
486 * @profiles: profiles to search for match
487 * @blacklist_len: length of blacklist
488 * @num_profiles: num of profiles in the list
David Spinadel35a000b2013-08-28 09:29:43 +0300489 * @match_notify: clients waiting for match found notification
490 * @pass_match: clients waiting for the results
491 * @active_clients: active clients bitmap - enum scan_framework_client
David Spinadel6e0bbe52013-12-30 09:59:45 +0200492 * @any_beacon_notify: clients waiting for match notification without match
Johannes Berg8ca151b2013-01-24 14:25:36 +0100493 */
494struct iwl_scan_offload_profile_cfg {
Johannes Berg8ca151b2013-01-24 14:25:36 +0100495 struct iwl_scan_offload_profile profiles[IWL_SCAN_MAX_PROFILES];
496 u8 blacklist_len;
497 u8 num_profiles;
David Spinadel35a000b2013-08-28 09:29:43 +0300498 u8 match_notify;
499 u8 pass_match;
500 u8 active_clients;
David Spinadel6e0bbe52013-12-30 09:59:45 +0200501 u8 any_beacon_notify;
502 u8 reserved[2];
Johannes Berg8ca151b2013-01-24 14:25:36 +0100503} __packed;
504
505/**
506 * iwl_scan_offload_schedule - schedule of scan offload
507 * @delay: delay between iterations, in seconds.
508 * @iterations: num of scan iterations
509 * @full_scan_mul: number of partial scans before each full scan
510 */
511struct iwl_scan_offload_schedule {
David Spinadelb14fc2b2014-06-25 13:17:53 +0300512 __le16 delay;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100513 u8 iterations;
514 u8 full_scan_mul;
515} __packed;
516
517/*
518 * iwl_scan_offload_flags
519 *
Eliad Pellerde33fb52013-11-10 12:59:46 +0200520 * IWL_SCAN_OFFLOAD_FLAG_PASS_ALL: pass all results - no filtering.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100521 * IWL_SCAN_OFFLOAD_FLAG_CACHED_CHANNEL: add cached channels to partial scan.
Haim Dreyfusse820c2d2014-04-06 11:19:09 +0300522 * IWL_SCAN_OFFLOAD_FLAG_EBS_QUICK_MODE: EBS duration is 100mSec - typical
523 * beacon period. Finding channel activity in this mode is not guaranteed.
524 * IWL_SCAN_OFFLOAD_FLAG_EBS_ACCURATE_MODE: EBS duration is 200mSec.
525 * Assuming beacon period is 100ms finding channel activity is guaranteed.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100526 */
527enum iwl_scan_offload_flags {
Eliad Pellerde33fb52013-11-10 12:59:46 +0200528 IWL_SCAN_OFFLOAD_FLAG_PASS_ALL = BIT(0),
Johannes Berg8ca151b2013-01-24 14:25:36 +0100529 IWL_SCAN_OFFLOAD_FLAG_CACHED_CHANNEL = BIT(2),
Haim Dreyfusse820c2d2014-04-06 11:19:09 +0300530 IWL_SCAN_OFFLOAD_FLAG_EBS_QUICK_MODE = BIT(5),
531 IWL_SCAN_OFFLOAD_FLAG_EBS_ACCURATE_MODE = BIT(6),
Johannes Berg8ca151b2013-01-24 14:25:36 +0100532};
533
534/**
535 * iwl_scan_offload_req - scan offload request command
536 * @flags: bitmap - enum iwl_scan_offload_flags.
537 * @watchdog: maximum scan duration in TU.
538 * @delay: delay in seconds before first iteration.
539 * @schedule_line: scan offload schedule, for fast and regular scan.
540 */
541struct iwl_scan_offload_req {
542 __le16 flags;
543 __le16 watchdog;
544 __le16 delay;
545 __le16 reserved;
546 struct iwl_scan_offload_schedule schedule_line[2];
547} __packed;
548
549enum iwl_scan_offload_compleate_status {
550 IWL_SCAN_OFFLOAD_COMPLETED = 1,
551 IWL_SCAN_OFFLOAD_ABORTED = 2,
552};
553
Haim Dreyfusse820c2d2014-04-06 11:19:09 +0300554enum iwl_scan_ebs_status {
555 IWL_SCAN_EBS_SUCCESS,
556 IWL_SCAN_EBS_FAILED,
557 IWL_SCAN_EBS_CHAN_NOT_FOUND,
558};
559
Johannes Berg8ca151b2013-01-24 14:25:36 +0100560/**
561 * iwl_scan_offload_complete - SCAN_OFFLOAD_COMPLETE_NTF_API_S_VER_1
562 * @last_schedule_line: last schedule line executed (fast or regular)
563 * @last_schedule_iteration: last scan iteration executed before scan abort
564 * @status: enum iwl_scan_offload_compleate_status
Haim Dreyfusse820c2d2014-04-06 11:19:09 +0300565 * @ebs_status: last EBS status, see IWL_SCAN_EBS_*
Johannes Berg8ca151b2013-01-24 14:25:36 +0100566 */
567struct iwl_scan_offload_complete {
568 u8 last_schedule_line;
569 u8 last_schedule_iteration;
570 u8 status;
Haim Dreyfusse820c2d2014-04-06 11:19:09 +0300571 u8 ebs_status;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100572} __packed;
573
David Spinadel35a000b2013-08-28 09:29:43 +0300574/**
575 * iwl_sched_scan_results - SCAN_OFFLOAD_MATCH_FOUND_NTF_API_S_VER_1
576 * @ssid_bitmap: SSIDs indexes found in this iteration
577 * @client_bitmap: clients that are active and wait for this notification
578 */
579struct iwl_sched_scan_results {
580 __le16 ssid_bitmap;
581 u8 client_bitmap;
582 u8 reserved;
583};
584
David Spinadelfb98be52014-05-04 12:51:10 +0300585/* Unified LMAC scan API */
586
587#define IWL_MVM_BASIC_PASSIVE_DWELL 110
588
589/**
590 * iwl_scan_req_tx_cmd - SCAN_REQ_TX_CMD_API_S
591 * @tx_flags: combination of TX_CMD_FLG_*
592 * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
593 * cleared. Combination of RATE_MCS_*
594 * @sta_id: index of destination station in FW station table
595 * @reserved: for alignment and future use
596 */
597struct iwl_scan_req_tx_cmd {
598 __le32 tx_flags;
599 __le32 rate_n_flags;
600 u8 sta_id;
601 u8 reserved[3];
602} __packed;
603
604enum iwl_scan_channel_flags_lmac {
605 IWL_UNIFIED_SCAN_CHANNEL_FULL = BIT(27),
606 IWL_UNIFIED_SCAN_CHANNEL_PARTIAL = BIT(28),
607};
608
609/**
610 * iwl_scan_channel_cfg_lmac - SCAN_CHANNEL_CFG_S_VER2
611 * @flags: bits 1-20: directed scan to i'th ssid
612 * other bits &enum iwl_scan_channel_flags_lmac
613 * @channel_number: channel number 1-13 etc
614 * @iter_count: scan iteration on this channel
615 * @iter_interval: interval in seconds between iterations on one channel
616 */
617struct iwl_scan_channel_cfg_lmac {
618 __le32 flags;
619 __le16 channel_num;
620 __le16 iter_count;
621 __le32 iter_interval;
622} __packed;
623
624/*
625 * iwl_scan_probe_segment - PROBE_SEGMENT_API_S_VER_1
626 * @offset: offset in the data block
627 * @len: length of the segment
628 */
629struct iwl_scan_probe_segment {
630 __le16 offset;
631 __le16 len;
632} __packed;
633
634/* iwl_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_2
635 * @mac_header: first (and common) part of the probe
636 * @band_data: band specific data
637 * @common_data: last (and common) part of the probe
638 * @buf: raw data block
639 */
640struct iwl_scan_probe_req {
641 struct iwl_scan_probe_segment mac_header;
642 struct iwl_scan_probe_segment band_data[2];
643 struct iwl_scan_probe_segment common_data;
644 u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
645} __packed;
646
647enum iwl_scan_channel_flags {
648 IWL_SCAN_CHANNEL_FLAG_EBS = BIT(0),
649 IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE = BIT(1),
650 IWL_SCAN_CHANNEL_FLAG_CACHE_ADD = BIT(2),
651};
652
653/* iwl_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
654 * @flags: enum iwl_scan_channel_flgs
655 * @non_ebs_ratio: how many regular scan iteration before EBS
656 */
657struct iwl_scan_channel_opt {
658 __le16 flags;
659 __le16 non_ebs_ratio;
660} __packed;
661
662/**
663 * iwl_mvm_lmac_scan_flags
664 * @IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL: pass all beacons and probe responses
665 * without filtering.
666 * @IWL_MVM_LMAC_SCAN_FLAG_PASSIVE: force passive scan on all channels
667 * @IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION: single channel scan
668 * @IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE: send iteration complete notification
669 * @IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS multiple SSID matching
670 * @IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented
671 */
672enum iwl_mvm_lmac_scan_flags {
673 IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL = BIT(0),
674 IWL_MVM_LMAC_SCAN_FLAG_PASSIVE = BIT(1),
675 IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION = BIT(2),
676 IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE = BIT(3),
677 IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS = BIT(4),
678 IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED = BIT(5),
679};
680
681enum iwl_scan_priority {
682 IWL_SCAN_PRIORITY_LOW,
683 IWL_SCAN_PRIORITY_MEDIUM,
684 IWL_SCAN_PRIORITY_HIGH,
685};
686
687/**
688 * iwl_scan_req_unified_lmac - SCAN_REQUEST_CMD_API_S_VER_1
689 * @reserved1: for alignment and future use
690 * @channel_num: num of channels to scan
691 * @active-dwell: dwell time for active channels
692 * @passive-dwell: dwell time for passive channels
693 * @fragmented-dwell: dwell time for fragmented passive scan
694 * @reserved2: for alignment and future use
695 * @rx_chain_selct: PHY_RX_CHAIN_* flags
696 * @scan_flags: &enum iwl_mvm_lmac_scan_flags
697 * @max_out_time: max time (in TU) to be out of associated channel
698 * @suspend_time: pause scan this long (TUs) when returning to service channel
699 * @flags: RXON flags
700 * @filter_flags: RXON filter
701 * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz
702 * @direct_scan: list of SSIDs for directed active scan
703 * @scan_prio: enum iwl_scan_priority
704 * @iter_num: number of scan iterations
705 * @delay: delay in seconds before first iteration
706 * @schedule: two scheduling plans. The first one is finite, the second one can
707 * be infinite.
708 * @channel_opt: channel optimization options, for full and partial scan
709 * @data: channel configuration and probe request packet.
710 */
711struct iwl_scan_req_unified_lmac {
712 /* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
713 __le32 reserved1;
714 u8 n_channels;
715 u8 active_dwell;
716 u8 passive_dwell;
717 u8 fragmented_dwell;
718 __le16 reserved2;
719 __le16 rx_chain_select;
720 __le32 scan_flags;
721 __le32 max_out_time;
722 __le32 suspend_time;
723 /* RX_ON_FLAGS_API_S_VER_1 */
724 __le32 flags;
725 __le32 filter_flags;
726 struct iwl_scan_req_tx_cmd tx_cmd[2];
727 struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
728 __le32 scan_prio;
729 /* SCAN_REQ_PERIODIC_PARAMS_API_S */
730 __le32 iter_num;
731 __le32 delay;
732 struct iwl_scan_offload_schedule schedule[2];
733 struct iwl_scan_channel_opt channel_opt[2];
734 u8 data[];
735} __packed;
736
737/**
738 * struct iwl_lmac_scan_results_notif - scan results for one channel -
739 * SCAN_RESULT_NTF_API_S_VER_3
740 * @channel: which channel the results are from
741 * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
742 * @probe_status: SCAN_PROBE_STATUS_*, indicates success of probe request
743 * @num_probe_not_sent: # of request that weren't sent due to not enough time
744 * @duration: duration spent in channel, in usecs
745 */
746struct iwl_lmac_scan_results_notif {
747 u8 channel;
748 u8 band;
749 u8 probe_status;
750 u8 num_probe_not_sent;
751 __le32 duration;
752} __packed;
753
754/**
755 * struct iwl_lmac_scan_complete_notif - notifies end of scanning (all channels)
756 * SCAN_COMPLETE_NTF_API_S_VER_3
757 * @scanned_channels: number of channels scanned (and number of valid results)
758 * @status: one of SCAN_COMP_STATUS_*
759 * @bt_status: BT on/off status
760 * @last_channel: last channel that was scanned
761 * @tsf_low: TSF timer (lower half) in usecs
762 * @tsf_high: TSF timer (higher half) in usecs
763 * @results: an array of scan results, only "scanned_channels" of them are valid
764 */
765struct iwl_lmac_scan_complete_notif {
766 u8 scanned_channels;
767 u8 status;
768 u8 bt_status;
769 u8 last_channel;
770 __le32 tsf_low;
771 __le32 tsf_high;
772 struct iwl_scan_results_notif results[];
773} __packed;
774
775/**
776 * iwl_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2
777 * @last_schedule_line: last schedule line executed (fast or regular)
778 * @last_schedule_iteration: last scan iteration executed before scan abort
779 * @status: enum iwl_scan_offload_complete_status
780 * @ebs_status: EBS success status &enum iwl_scan_ebs_status
781 * @time_after_last_iter; time in seconds elapsed after last iteration
782 */
783struct iwl_periodic_scan_complete {
784 u8 last_schedule_line;
785 u8 last_schedule_iteration;
786 u8 status;
787 u8 ebs_status;
788 __le32 time_after_last_iter;
789 __le32 reserved;
790} __packed;
791
Johannes Berg8ca151b2013-01-24 14:25:36 +0100792#endif