scan.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. /******************************************************************************
  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. *
  8. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  10. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  11. * Copyright(c) 2018 Intel Corporation
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of version 2 of the GNU General Public License as
  15. * published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful, but
  18. * WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * General Public License for more details.
  21. *
  22. * The full GNU General Public License is included in this distribution
  23. * in the file called COPYING.
  24. *
  25. * Contact Information:
  26. * Intel Linux Wireless <linuxwifi@intel.com>
  27. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  28. *
  29. * BSD LICENSE
  30. *
  31. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  32. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  33. * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  34. * Copyright(c) 2018 Intel Corporation
  35. * All rights reserved.
  36. *
  37. * Redistribution and use in source and binary forms, with or without
  38. * modification, are permitted provided that the following conditions
  39. * are met:
  40. *
  41. * * Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * * Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in
  45. * the documentation and/or other materials provided with the
  46. * distribution.
  47. * * Neither the name Intel Corporation nor the names of its
  48. * contributors may be used to endorse or promote products derived
  49. * from this software without specific prior written permission.
  50. *
  51. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  52. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  53. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  54. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  55. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  56. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  57. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  58. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  59. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  60. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  61. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  62. *
  63. *****************************************************************************/
  64. #ifndef __iwl_fw_api_scan_h__
  65. #define __iwl_fw_api_scan_h__
  66. /* Scan Commands, Responses, Notifications */
  67. /* Max number of IEs for direct SSID scans in a command */
  68. #define PROBE_OPTION_MAX 20
  69. /**
  70. * struct iwl_ssid_ie - directed scan network information element
  71. *
  72. * Up to 20 of these may appear in REPLY_SCAN_CMD,
  73. * selected by "type" bit field in struct iwl_scan_channel;
  74. * each channel may select different ssids from among the 20 entries.
  75. * SSID IEs get transmitted in reverse order of entry.
  76. *
  77. * @id: element ID
  78. * @len: element length
  79. * @ssid: element (SSID) data
  80. */
  81. struct iwl_ssid_ie {
  82. u8 id;
  83. u8 len;
  84. u8 ssid[IEEE80211_MAX_SSID_LEN];
  85. } __packed; /* SCAN_DIRECT_SSID_IE_API_S_VER_1 */
  86. /* scan offload */
  87. #define IWL_SCAN_MAX_BLACKLIST_LEN 64
  88. #define IWL_SCAN_SHORT_BLACKLIST_LEN 16
  89. #define IWL_SCAN_MAX_PROFILES 11
  90. #define SCAN_OFFLOAD_PROBE_REQ_SIZE 512
  91. /* Default watchdog (in MS) for scheduled scan iteration */
  92. #define IWL_SCHED_SCAN_WATCHDOG cpu_to_le16(15000)
  93. #define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
  94. #define CAN_ABORT_STATUS 1
  95. #define IWL_FULL_SCAN_MULTIPLIER 5
  96. #define IWL_FAST_SCHED_SCAN_ITERATIONS 3
  97. #define IWL_MAX_SCHED_SCAN_PLANS 2
  98. enum scan_framework_client {
  99. SCAN_CLIENT_SCHED_SCAN = BIT(0),
  100. SCAN_CLIENT_NETDETECT = BIT(1),
  101. SCAN_CLIENT_ASSET_TRACKING = BIT(2),
  102. };
  103. /**
  104. * struct iwl_scan_offload_blacklist - SCAN_OFFLOAD_BLACKLIST_S
  105. * @ssid: MAC address to filter out
  106. * @reported_rssi: AP rssi reported to the host
  107. * @client_bitmap: clients ignore this entry - enum scan_framework_client
  108. */
  109. struct iwl_scan_offload_blacklist {
  110. u8 ssid[ETH_ALEN];
  111. u8 reported_rssi;
  112. u8 client_bitmap;
  113. } __packed;
  114. enum iwl_scan_offload_network_type {
  115. IWL_NETWORK_TYPE_BSS = 1,
  116. IWL_NETWORK_TYPE_IBSS = 2,
  117. IWL_NETWORK_TYPE_ANY = 3,
  118. };
  119. enum iwl_scan_offload_band_selection {
  120. IWL_SCAN_OFFLOAD_SELECT_2_4 = 0x4,
  121. IWL_SCAN_OFFLOAD_SELECT_5_2 = 0x8,
  122. IWL_SCAN_OFFLOAD_SELECT_ANY = 0xc,
  123. };
  124. /**
  125. * struct iwl_scan_offload_profile - SCAN_OFFLOAD_PROFILE_S
  126. * @ssid_index: index to ssid list in fixed part
  127. * @unicast_cipher: encryption algorithm to match - bitmap
  128. * @auth_alg: authentication algorithm to match - bitmap
  129. * @network_type: enum iwl_scan_offload_network_type
  130. * @band_selection: enum iwl_scan_offload_band_selection
  131. * @client_bitmap: clients waiting for match - enum scan_framework_client
  132. * @reserved: reserved
  133. */
  134. struct iwl_scan_offload_profile {
  135. u8 ssid_index;
  136. u8 unicast_cipher;
  137. u8 auth_alg;
  138. u8 network_type;
  139. u8 band_selection;
  140. u8 client_bitmap;
  141. u8 reserved[2];
  142. } __packed;
  143. /**
  144. * struct iwl_scan_offload_profile_cfg - SCAN_OFFLOAD_PROFILES_CFG_API_S_VER_1
  145. * @profiles: profiles to search for match
  146. * @blacklist_len: length of blacklist
  147. * @num_profiles: num of profiles in the list
  148. * @match_notify: clients waiting for match found notification
  149. * @pass_match: clients waiting for the results
  150. * @active_clients: active clients bitmap - enum scan_framework_client
  151. * @any_beacon_notify: clients waiting for match notification without match
  152. * @reserved: reserved
  153. */
  154. struct iwl_scan_offload_profile_cfg {
  155. struct iwl_scan_offload_profile profiles[IWL_SCAN_MAX_PROFILES];
  156. u8 blacklist_len;
  157. u8 num_profiles;
  158. u8 match_notify;
  159. u8 pass_match;
  160. u8 active_clients;
  161. u8 any_beacon_notify;
  162. u8 reserved[2];
  163. } __packed;
  164. /**
  165. * struct iwl_scan_schedule_lmac - schedule of scan offload
  166. * @delay: delay between iterations, in seconds.
  167. * @iterations: num of scan iterations
  168. * @full_scan_mul: number of partial scans before each full scan
  169. */
  170. struct iwl_scan_schedule_lmac {
  171. __le16 delay;
  172. u8 iterations;
  173. u8 full_scan_mul;
  174. } __packed; /* SCAN_SCHEDULE_API_S */
  175. enum iwl_scan_offload_complete_status {
  176. IWL_SCAN_OFFLOAD_COMPLETED = 1,
  177. IWL_SCAN_OFFLOAD_ABORTED = 2,
  178. };
  179. enum iwl_scan_ebs_status {
  180. IWL_SCAN_EBS_SUCCESS,
  181. IWL_SCAN_EBS_FAILED,
  182. IWL_SCAN_EBS_CHAN_NOT_FOUND,
  183. IWL_SCAN_EBS_INACTIVE,
  184. };
  185. /**
  186. * struct iwl_scan_req_tx_cmd - SCAN_REQ_TX_CMD_API_S
  187. * @tx_flags: combination of TX_CMD_FLG_*
  188. * @rate_n_flags: rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is
  189. * cleared. Combination of RATE_MCS_*
  190. * @sta_id: index of destination station in FW station table
  191. * @reserved: for alignment and future use
  192. */
  193. struct iwl_scan_req_tx_cmd {
  194. __le32 tx_flags;
  195. __le32 rate_n_flags;
  196. u8 sta_id;
  197. u8 reserved[3];
  198. } __packed;
  199. enum iwl_scan_channel_flags_lmac {
  200. IWL_UNIFIED_SCAN_CHANNEL_FULL = BIT(27),
  201. IWL_UNIFIED_SCAN_CHANNEL_PARTIAL = BIT(28),
  202. };
  203. /**
  204. * struct iwl_scan_channel_cfg_lmac - SCAN_CHANNEL_CFG_S_VER2
  205. * @flags: bits 1-20: directed scan to i'th ssid
  206. * other bits &enum iwl_scan_channel_flags_lmac
  207. * @channel_num: channel number 1-13 etc
  208. * @iter_count: scan iteration on this channel
  209. * @iter_interval: interval in seconds between iterations on one channel
  210. */
  211. struct iwl_scan_channel_cfg_lmac {
  212. __le32 flags;
  213. __le16 channel_num;
  214. __le16 iter_count;
  215. __le32 iter_interval;
  216. } __packed;
  217. /*
  218. * struct iwl_scan_probe_segment - PROBE_SEGMENT_API_S_VER_1
  219. * @offset: offset in the data block
  220. * @len: length of the segment
  221. */
  222. struct iwl_scan_probe_segment {
  223. __le16 offset;
  224. __le16 len;
  225. } __packed;
  226. /* iwl_scan_probe_req - PROBE_REQUEST_FRAME_API_S_VER_2
  227. * @mac_header: first (and common) part of the probe
  228. * @band_data: band specific data
  229. * @common_data: last (and common) part of the probe
  230. * @buf: raw data block
  231. */
  232. struct iwl_scan_probe_req {
  233. struct iwl_scan_probe_segment mac_header;
  234. struct iwl_scan_probe_segment band_data[2];
  235. struct iwl_scan_probe_segment common_data;
  236. u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
  237. } __packed;
  238. enum iwl_scan_channel_flags {
  239. IWL_SCAN_CHANNEL_FLAG_EBS = BIT(0),
  240. IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE = BIT(1),
  241. IWL_SCAN_CHANNEL_FLAG_CACHE_ADD = BIT(2),
  242. };
  243. /* struct iwl_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
  244. * @flags: enum iwl_scan_channel_flags
  245. * @non_ebs_ratio: defines the ratio of number of scan iterations where EBS is
  246. * involved.
  247. * 1 - EBS is disabled.
  248. * 2 - every second scan will be full scan(and so on).
  249. */
  250. struct iwl_scan_channel_opt {
  251. __le16 flags;
  252. __le16 non_ebs_ratio;
  253. } __packed;
  254. /**
  255. * enum iwl_mvm_lmac_scan_flags - LMAC scan flags
  256. * @IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL: pass all beacons and probe responses
  257. * without filtering.
  258. * @IWL_MVM_LMAC_SCAN_FLAG_PASSIVE: force passive scan on all channels
  259. * @IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION: single channel scan
  260. * @IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE: send iteration complete notification
  261. * @IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS: multiple SSID matching
  262. * @IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented
  263. * @IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED: insert WFA vendor-specific TPC report
  264. * and DS parameter set IEs into probe requests.
  265. * @IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL: use extended dwell time on channels
  266. * 1, 6 and 11.
  267. * @IWL_MVM_LMAC_SCAN_FLAG_MATCH: Send match found notification on matches
  268. */
  269. enum iwl_mvm_lmac_scan_flags {
  270. IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL = BIT(0),
  271. IWL_MVM_LMAC_SCAN_FLAG_PASSIVE = BIT(1),
  272. IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION = BIT(2),
  273. IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE = BIT(3),
  274. IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS = BIT(4),
  275. IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED = BIT(5),
  276. IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED = BIT(6),
  277. IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL = BIT(7),
  278. IWL_MVM_LMAC_SCAN_FLAG_MATCH = BIT(9),
  279. };
  280. enum iwl_scan_priority {
  281. IWL_SCAN_PRIORITY_LOW,
  282. IWL_SCAN_PRIORITY_MEDIUM,
  283. IWL_SCAN_PRIORITY_HIGH,
  284. };
  285. enum iwl_scan_priority_ext {
  286. IWL_SCAN_PRIORITY_EXT_0_LOWEST,
  287. IWL_SCAN_PRIORITY_EXT_1,
  288. IWL_SCAN_PRIORITY_EXT_2,
  289. IWL_SCAN_PRIORITY_EXT_3,
  290. IWL_SCAN_PRIORITY_EXT_4,
  291. IWL_SCAN_PRIORITY_EXT_5,
  292. IWL_SCAN_PRIORITY_EXT_6,
  293. IWL_SCAN_PRIORITY_EXT_7_HIGHEST,
  294. };
  295. /**
  296. * struct iwl_scan_req_lmac - SCAN_REQUEST_CMD_API_S_VER_1
  297. * @reserved1: for alignment and future use
  298. * @n_channels: num of channels to scan
  299. * @active_dwell: dwell time for active channels
  300. * @passive_dwell: dwell time for passive channels
  301. * @fragmented_dwell: dwell time for fragmented passive scan
  302. * @extended_dwell: dwell time for channels 1, 6 and 11 (in certain cases)
  303. * @reserved2: for alignment and future use
  304. * @rx_chain_select: PHY_RX_CHAIN_* flags
  305. * @scan_flags: &enum iwl_mvm_lmac_scan_flags
  306. * @max_out_time: max time (in TU) to be out of associated channel
  307. * @suspend_time: pause scan this long (TUs) when returning to service channel
  308. * @flags: RXON flags
  309. * @filter_flags: RXON filter
  310. * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz
  311. * @direct_scan: list of SSIDs for directed active scan
  312. * @scan_prio: enum iwl_scan_priority
  313. * @iter_num: number of scan iterations
  314. * @delay: delay in seconds before first iteration
  315. * @schedule: two scheduling plans. The first one is finite, the second one can
  316. * be infinite.
  317. * @channel_opt: channel optimization options, for full and partial scan
  318. * @data: channel configuration and probe request packet.
  319. */
  320. struct iwl_scan_req_lmac {
  321. /* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
  322. __le32 reserved1;
  323. u8 n_channels;
  324. u8 active_dwell;
  325. u8 passive_dwell;
  326. u8 fragmented_dwell;
  327. u8 extended_dwell;
  328. u8 reserved2;
  329. __le16 rx_chain_select;
  330. __le32 scan_flags;
  331. __le32 max_out_time;
  332. __le32 suspend_time;
  333. /* RX_ON_FLAGS_API_S_VER_1 */
  334. __le32 flags;
  335. __le32 filter_flags;
  336. struct iwl_scan_req_tx_cmd tx_cmd[2];
  337. struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
  338. __le32 scan_prio;
  339. /* SCAN_REQ_PERIODIC_PARAMS_API_S */
  340. __le32 iter_num;
  341. __le32 delay;
  342. struct iwl_scan_schedule_lmac schedule[IWL_MAX_SCHED_SCAN_PLANS];
  343. struct iwl_scan_channel_opt channel_opt[2];
  344. u8 data[];
  345. } __packed;
  346. /**
  347. * struct iwl_scan_results_notif - scan results for one channel -
  348. * SCAN_RESULT_NTF_API_S_VER_3
  349. * @channel: which channel the results are from
  350. * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
  351. * @probe_status: SCAN_PROBE_STATUS_*, indicates success of probe request
  352. * @num_probe_not_sent: # of request that weren't sent due to not enough time
  353. * @duration: duration spent in channel, in usecs
  354. */
  355. struct iwl_scan_results_notif {
  356. u8 channel;
  357. u8 band;
  358. u8 probe_status;
  359. u8 num_probe_not_sent;
  360. __le32 duration;
  361. } __packed;
  362. /**
  363. * struct iwl_lmac_scan_complete_notif - notifies end of scanning (all channels)
  364. * SCAN_COMPLETE_NTF_API_S_VER_3
  365. * @scanned_channels: number of channels scanned (and number of valid results)
  366. * @status: one of SCAN_COMP_STATUS_*
  367. * @bt_status: BT on/off status
  368. * @last_channel: last channel that was scanned
  369. * @tsf_low: TSF timer (lower half) in usecs
  370. * @tsf_high: TSF timer (higher half) in usecs
  371. * @results: an array of scan results, only "scanned_channels" of them are valid
  372. */
  373. struct iwl_lmac_scan_complete_notif {
  374. u8 scanned_channels;
  375. u8 status;
  376. u8 bt_status;
  377. u8 last_channel;
  378. __le32 tsf_low;
  379. __le32 tsf_high;
  380. struct iwl_scan_results_notif results[];
  381. } __packed;
  382. /**
  383. * struct iwl_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2
  384. * @last_schedule_line: last schedule line executed (fast or regular)
  385. * @last_schedule_iteration: last scan iteration executed before scan abort
  386. * @status: &enum iwl_scan_offload_complete_status
  387. * @ebs_status: EBS success status &enum iwl_scan_ebs_status
  388. * @time_after_last_iter: time in seconds elapsed after last iteration
  389. * @reserved: reserved
  390. */
  391. struct iwl_periodic_scan_complete {
  392. u8 last_schedule_line;
  393. u8 last_schedule_iteration;
  394. u8 status;
  395. u8 ebs_status;
  396. __le32 time_after_last_iter;
  397. __le32 reserved;
  398. } __packed;
  399. /* UMAC Scan API */
  400. /* The maximum of either of these cannot exceed 8, because we use an
  401. * 8-bit mask (see IWL_MVM_SCAN_MASK in mvm.h).
  402. */
  403. #define IWL_MVM_MAX_UMAC_SCANS 8
  404. #define IWL_MVM_MAX_LMAC_SCANS 1
  405. enum scan_config_flags {
  406. SCAN_CONFIG_FLAG_ACTIVATE = BIT(0),
  407. SCAN_CONFIG_FLAG_DEACTIVATE = BIT(1),
  408. SCAN_CONFIG_FLAG_FORBID_CHUB_REQS = BIT(2),
  409. SCAN_CONFIG_FLAG_ALLOW_CHUB_REQS = BIT(3),
  410. SCAN_CONFIG_FLAG_SET_TX_CHAINS = BIT(8),
  411. SCAN_CONFIG_FLAG_SET_RX_CHAINS = BIT(9),
  412. SCAN_CONFIG_FLAG_SET_AUX_STA_ID = BIT(10),
  413. SCAN_CONFIG_FLAG_SET_ALL_TIMES = BIT(11),
  414. SCAN_CONFIG_FLAG_SET_EFFECTIVE_TIMES = BIT(12),
  415. SCAN_CONFIG_FLAG_SET_CHANNEL_FLAGS = BIT(13),
  416. SCAN_CONFIG_FLAG_SET_LEGACY_RATES = BIT(14),
  417. SCAN_CONFIG_FLAG_SET_MAC_ADDR = BIT(15),
  418. SCAN_CONFIG_FLAG_SET_FRAGMENTED = BIT(16),
  419. SCAN_CONFIG_FLAG_CLEAR_FRAGMENTED = BIT(17),
  420. SCAN_CONFIG_FLAG_SET_CAM_MODE = BIT(18),
  421. SCAN_CONFIG_FLAG_CLEAR_CAM_MODE = BIT(19),
  422. SCAN_CONFIG_FLAG_SET_PROMISC_MODE = BIT(20),
  423. SCAN_CONFIG_FLAG_CLEAR_PROMISC_MODE = BIT(21),
  424. SCAN_CONFIG_FLAG_SET_LMAC2_FRAGMENTED = BIT(22),
  425. SCAN_CONFIG_FLAG_CLEAR_LMAC2_FRAGMENTED = BIT(23),
  426. /* Bits 26-31 are for num of channels in channel_array */
  427. #define SCAN_CONFIG_N_CHANNELS(n) ((n) << 26)
  428. };
  429. enum scan_config_rates {
  430. /* OFDM basic rates */
  431. SCAN_CONFIG_RATE_6M = BIT(0),
  432. SCAN_CONFIG_RATE_9M = BIT(1),
  433. SCAN_CONFIG_RATE_12M = BIT(2),
  434. SCAN_CONFIG_RATE_18M = BIT(3),
  435. SCAN_CONFIG_RATE_24M = BIT(4),
  436. SCAN_CONFIG_RATE_36M = BIT(5),
  437. SCAN_CONFIG_RATE_48M = BIT(6),
  438. SCAN_CONFIG_RATE_54M = BIT(7),
  439. /* CCK basic rates */
  440. SCAN_CONFIG_RATE_1M = BIT(8),
  441. SCAN_CONFIG_RATE_2M = BIT(9),
  442. SCAN_CONFIG_RATE_5M = BIT(10),
  443. SCAN_CONFIG_RATE_11M = BIT(11),
  444. /* Bits 16-27 are for supported rates */
  445. #define SCAN_CONFIG_SUPPORTED_RATE(rate) ((rate) << 16)
  446. };
  447. enum iwl_channel_flags {
  448. IWL_CHANNEL_FLAG_EBS = BIT(0),
  449. IWL_CHANNEL_FLAG_ACCURATE_EBS = BIT(1),
  450. IWL_CHANNEL_FLAG_EBS_ADD = BIT(2),
  451. IWL_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE = BIT(3),
  452. };
  453. /**
  454. * struct iwl_scan_dwell
  455. * @active: default dwell time for active scan
  456. * @passive: default dwell time for passive scan
  457. * @fragmented: default dwell time for fragmented scan
  458. * @extended: default dwell time for channels 1, 6 and 11
  459. */
  460. struct iwl_scan_dwell {
  461. u8 active;
  462. u8 passive;
  463. u8 fragmented;
  464. u8 extended;
  465. } __packed;
  466. /**
  467. * struct iwl_scan_config
  468. * @flags: enum scan_config_flags
  469. * @tx_chains: valid_tx antenna - ANT_* definitions
  470. * @rx_chains: valid_rx antenna - ANT_* definitions
  471. * @legacy_rates: default legacy rates - enum scan_config_rates
  472. * @out_of_channel_time: default max out of serving channel time
  473. * @suspend_time: default max suspend time
  474. * @dwell: dwells for the scan
  475. * @mac_addr: default mac address to be used in probes
  476. * @bcast_sta_id: the index of the station in the fw
  477. * @channel_flags: default channel flags - enum iwl_channel_flags
  478. * scan_config_channel_flag
  479. * @channel_array: default supported channels
  480. */
  481. struct iwl_scan_config_v1 {
  482. __le32 flags;
  483. __le32 tx_chains;
  484. __le32 rx_chains;
  485. __le32 legacy_rates;
  486. __le32 out_of_channel_time;
  487. __le32 suspend_time;
  488. struct iwl_scan_dwell dwell;
  489. u8 mac_addr[ETH_ALEN];
  490. u8 bcast_sta_id;
  491. u8 channel_flags;
  492. u8 channel_array[];
  493. } __packed; /* SCAN_CONFIG_DB_CMD_API_S */
  494. #define SCAN_TWO_LMACS 2
  495. #define SCAN_LB_LMAC_IDX 0
  496. #define SCAN_HB_LMAC_IDX 1
  497. struct iwl_scan_config {
  498. __le32 flags;
  499. __le32 tx_chains;
  500. __le32 rx_chains;
  501. __le32 legacy_rates;
  502. __le32 out_of_channel_time[SCAN_TWO_LMACS];
  503. __le32 suspend_time[SCAN_TWO_LMACS];
  504. struct iwl_scan_dwell dwell;
  505. u8 mac_addr[ETH_ALEN];
  506. u8 bcast_sta_id;
  507. u8 channel_flags;
  508. u8 channel_array[];
  509. } __packed; /* SCAN_CONFIG_DB_CMD_API_S_3 */
  510. /**
  511. * enum iwl_umac_scan_flags - UMAC scan flags
  512. * @IWL_UMAC_SCAN_FLAG_PREEMPTIVE: scan process triggered by this scan request
  513. * can be preempted by other scan requests with higher priority.
  514. * The low priority scan will be resumed when the higher proirity scan is
  515. * completed.
  516. * @IWL_UMAC_SCAN_FLAG_START_NOTIF: notification will be sent to the driver
  517. * when scan starts.
  518. */
  519. enum iwl_umac_scan_flags {
  520. IWL_UMAC_SCAN_FLAG_PREEMPTIVE = BIT(0),
  521. IWL_UMAC_SCAN_FLAG_START_NOTIF = BIT(1),
  522. };
  523. enum iwl_umac_scan_uid_offsets {
  524. IWL_UMAC_SCAN_UID_TYPE_OFFSET = 0,
  525. IWL_UMAC_SCAN_UID_SEQ_OFFSET = 8,
  526. };
  527. enum iwl_umac_scan_general_flags {
  528. IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC = BIT(0),
  529. IWL_UMAC_SCAN_GEN_FLAGS_OVER_BT = BIT(1),
  530. IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL = BIT(2),
  531. IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE = BIT(3),
  532. IWL_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT = BIT(4),
  533. IWL_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE = BIT(5),
  534. IWL_UMAC_SCAN_GEN_FLAGS_MULTIPLE_SSID = BIT(6),
  535. IWL_UMAC_SCAN_GEN_FLAGS_FRAGMENTED = BIT(7),
  536. IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED = BIT(8),
  537. IWL_UMAC_SCAN_GEN_FLAGS_MATCH = BIT(9),
  538. IWL_UMAC_SCAN_GEN_FLAGS_EXTENDED_DWELL = BIT(10),
  539. /* Extended dwell is obselete when adaptive dwell is used, making this
  540. * bit reusable. Hence, probe request defer is used only when adaptive
  541. * dwell is supported. */
  542. IWL_UMAC_SCAN_GEN_FLAGS_PROB_REQ_DEFER_SUPP = BIT(10),
  543. IWL_UMAC_SCAN_GEN_FLAGS_LMAC2_FRAGMENTED = BIT(11),
  544. IWL_UMAC_SCAN_GEN_FLAGS_ADAPTIVE_DWELL = BIT(13),
  545. IWL_UMAC_SCAN_GEN_FLAGS_MAX_CHNL_TIME = BIT(14),
  546. IWL_UMAC_SCAN_GEN_FLAGS_PROB_REQ_HIGH_TX_RATE = BIT(15),
  547. };
  548. /**
  549. * enum iwl_umac_scan_general_flags2 - UMAC scan general flags #2
  550. * @IWL_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL: Whether to send a complete
  551. * notification per channel or not.
  552. */
  553. enum iwl_umac_scan_general_flags2 {
  554. IWL_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL = BIT(0),
  555. };
  556. /**
  557. * struct iwl_scan_channel_cfg_umac
  558. * @flags: bitmap - 0-19: directed scan to i'th ssid.
  559. * @channel_num: channel number 1-13 etc.
  560. * @iter_count: repetition count for the channel.
  561. * @iter_interval: interval between two scan iterations on one channel.
  562. */
  563. struct iwl_scan_channel_cfg_umac {
  564. __le32 flags;
  565. u8 channel_num;
  566. u8 iter_count;
  567. __le16 iter_interval;
  568. } __packed; /* SCAN_CHANNEL_CFG_S_VER2 */
  569. /**
  570. * struct iwl_scan_umac_schedule
  571. * @interval: interval in seconds between scan iterations
  572. * @iter_count: num of scan iterations for schedule plan, 0xff for infinite loop
  573. * @reserved: for alignment and future use
  574. */
  575. struct iwl_scan_umac_schedule {
  576. __le16 interval;
  577. u8 iter_count;
  578. u8 reserved;
  579. } __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */
  580. /**
  581. * struct iwl_scan_req_umac_tail - the rest of the UMAC scan request command
  582. * parameters following channels configuration array.
  583. * @schedule: two scheduling plans.
  584. * @delay: delay in TUs before starting the first scan iteration
  585. * @reserved: for future use and alignment
  586. * @preq: probe request with IEs blocks
  587. * @direct_scan: list of SSIDs for directed active scan
  588. */
  589. struct iwl_scan_req_umac_tail {
  590. /* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
  591. struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
  592. __le16 delay;
  593. __le16 reserved;
  594. /* SCAN_PROBE_PARAMS_API_S_VER_1 */
  595. struct iwl_scan_probe_req preq;
  596. struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
  597. } __packed;
  598. /**
  599. * struct iwl_scan_umac_chan_param
  600. * @flags: channel flags &enum iwl_scan_channel_flags
  601. * @count: num of channels in scan request
  602. * @reserved: for future use and alignment
  603. */
  604. struct iwl_scan_umac_chan_param {
  605. u8 flags;
  606. u8 count;
  607. __le16 reserved;
  608. } __packed; /*SCAN_CHANNEL_PARAMS_API_S_VER_1 */
  609. /**
  610. * struct iwl_scan_req_umac
  611. * @flags: &enum iwl_umac_scan_flags
  612. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  613. * @ooc_priority: out of channel priority - &enum iwl_scan_priority
  614. * @general_flags: &enum iwl_umac_scan_general_flags
  615. * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
  616. * @extended_dwell: dwell time for channels 1, 6 and 11
  617. * @active_dwell: dwell time for active scan per LMAC
  618. * @passive_dwell: dwell time for passive scan per LMAC
  619. * @fragmented_dwell: dwell time for fragmented passive scan
  620. * @adwell_default_n_aps: for adaptive dwell the default number of APs
  621. * per channel
  622. * @adwell_default_n_aps_social: for adaptive dwell the default
  623. * number of APs per social (1,6,11) channel
  624. * @general_flags2: &enum iwl_umac_scan_general_flags2
  625. * @adwell_max_budget: for adaptive dwell the maximal budget of TU to be added
  626. * to total scan time
  627. * @max_out_time: max out of serving channel time, per LMAC - for CDB there
  628. * are 2 LMACs
  629. * @suspend_time: max suspend time, per LMAC - for CDB there are 2 LMACs
  630. * @scan_priority: scan internal prioritization &enum iwl_scan_priority
  631. * @num_of_fragments: Number of fragments needed for full coverage per band.
  632. * Relevant only for fragmented scan.
  633. * @channel: &struct iwl_scan_umac_chan_param
  634. * @reserved: for future use and alignment
  635. * @reserved3: for future use and alignment
  636. * @data: &struct iwl_scan_channel_cfg_umac and
  637. * &struct iwl_scan_req_umac_tail
  638. */
  639. struct iwl_scan_req_umac {
  640. __le32 flags;
  641. __le32 uid;
  642. __le32 ooc_priority;
  643. __le16 general_flags;
  644. u8 reserved;
  645. u8 scan_start_mac_id;
  646. union {
  647. struct {
  648. u8 extended_dwell;
  649. u8 active_dwell;
  650. u8 passive_dwell;
  651. u8 fragmented_dwell;
  652. __le32 max_out_time;
  653. __le32 suspend_time;
  654. __le32 scan_priority;
  655. struct iwl_scan_umac_chan_param channel;
  656. u8 data[];
  657. } v1; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_1 */
  658. struct {
  659. u8 extended_dwell;
  660. u8 active_dwell;
  661. u8 passive_dwell;
  662. u8 fragmented_dwell;
  663. __le32 max_out_time[SCAN_TWO_LMACS];
  664. __le32 suspend_time[SCAN_TWO_LMACS];
  665. __le32 scan_priority;
  666. struct iwl_scan_umac_chan_param channel;
  667. u8 data[];
  668. } v6; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_6 */
  669. struct {
  670. u8 active_dwell;
  671. u8 passive_dwell;
  672. u8 fragmented_dwell;
  673. u8 adwell_default_n_aps;
  674. u8 adwell_default_n_aps_social;
  675. u8 reserved3;
  676. __le16 adwell_max_budget;
  677. __le32 max_out_time[SCAN_TWO_LMACS];
  678. __le32 suspend_time[SCAN_TWO_LMACS];
  679. __le32 scan_priority;
  680. struct iwl_scan_umac_chan_param channel;
  681. u8 data[];
  682. } v7; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_7 */
  683. struct {
  684. u8 active_dwell[SCAN_TWO_LMACS];
  685. u8 reserved2;
  686. u8 adwell_default_n_aps;
  687. u8 adwell_default_n_aps_social;
  688. u8 general_flags2;
  689. __le16 adwell_max_budget;
  690. __le32 max_out_time[SCAN_TWO_LMACS];
  691. __le32 suspend_time[SCAN_TWO_LMACS];
  692. __le32 scan_priority;
  693. u8 passive_dwell[SCAN_TWO_LMACS];
  694. u8 num_of_fragments[SCAN_TWO_LMACS];
  695. struct iwl_scan_umac_chan_param channel;
  696. u8 data[];
  697. } v8; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_8 */
  698. };
  699. } __packed;
  700. #define IWL_SCAN_REQ_UMAC_SIZE_V8 sizeof(struct iwl_scan_req_umac)
  701. #define IWL_SCAN_REQ_UMAC_SIZE_V7 48
  702. #define IWL_SCAN_REQ_UMAC_SIZE_V6 44
  703. #define IWL_SCAN_REQ_UMAC_SIZE_V1 36
  704. /**
  705. * struct iwl_umac_scan_abort
  706. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  707. * @flags: reserved
  708. */
  709. struct iwl_umac_scan_abort {
  710. __le32 uid;
  711. __le32 flags;
  712. } __packed; /* SCAN_ABORT_CMD_UMAC_API_S_VER_1 */
  713. /**
  714. * struct iwl_umac_scan_complete
  715. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  716. * @last_schedule: last scheduling line
  717. * @last_iter: last scan iteration number
  718. * @status: &enum iwl_scan_offload_complete_status
  719. * @ebs_status: &enum iwl_scan_ebs_status
  720. * @time_from_last_iter: time elapsed from last iteration
  721. * @reserved: for future use
  722. */
  723. struct iwl_umac_scan_complete {
  724. __le32 uid;
  725. u8 last_schedule;
  726. u8 last_iter;
  727. u8 status;
  728. u8 ebs_status;
  729. __le32 time_from_last_iter;
  730. __le32 reserved;
  731. } __packed; /* SCAN_COMPLETE_NTF_UMAC_API_S_VER_1 */
  732. #define SCAN_OFFLOAD_MATCHING_CHANNELS_LEN 5
  733. /**
  734. * struct iwl_scan_offload_profile_match - match information
  735. * @bssid: matched bssid
  736. * @reserved: reserved
  737. * @channel: channel where the match occurred
  738. * @energy: energy
  739. * @matching_feature: feature matches
  740. * @matching_channels: bitmap of channels that matched, referencing
  741. * the channels passed in tue scan offload request
  742. */
  743. struct iwl_scan_offload_profile_match {
  744. u8 bssid[ETH_ALEN];
  745. __le16 reserved;
  746. u8 channel;
  747. u8 energy;
  748. u8 matching_feature;
  749. u8 matching_channels[SCAN_OFFLOAD_MATCHING_CHANNELS_LEN];
  750. } __packed; /* SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S_VER_1 */
  751. /**
  752. * struct iwl_scan_offload_profiles_query - match results query response
  753. * @matched_profiles: bitmap of matched profiles, referencing the
  754. * matches passed in the scan offload request
  755. * @last_scan_age: age of the last offloaded scan
  756. * @n_scans_done: number of offloaded scans done
  757. * @gp2_d0u: GP2 when D0U occurred
  758. * @gp2_invoked: GP2 when scan offload was invoked
  759. * @resume_while_scanning: not used
  760. * @self_recovery: obsolete
  761. * @reserved: reserved
  762. * @matches: array of match information, one for each match
  763. */
  764. struct iwl_scan_offload_profiles_query {
  765. __le32 matched_profiles;
  766. __le32 last_scan_age;
  767. __le32 n_scans_done;
  768. __le32 gp2_d0u;
  769. __le32 gp2_invoked;
  770. u8 resume_while_scanning;
  771. u8 self_recovery;
  772. __le16 reserved;
  773. struct iwl_scan_offload_profile_match matches[IWL_SCAN_MAX_PROFILES];
  774. } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_2 */
  775. /**
  776. * struct iwl_umac_scan_iter_complete_notif - notifies end of scanning iteration
  777. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  778. * @scanned_channels: number of channels scanned and number of valid elements in
  779. * results array
  780. * @status: one of SCAN_COMP_STATUS_*
  781. * @bt_status: BT on/off status
  782. * @last_channel: last channel that was scanned
  783. * @start_tsf: TSF timer in usecs of the scan start time for the mac specified
  784. * in &struct iwl_scan_req_umac.
  785. * @results: array of scan results, length in @scanned_channels
  786. */
  787. struct iwl_umac_scan_iter_complete_notif {
  788. __le32 uid;
  789. u8 scanned_channels;
  790. u8 status;
  791. u8 bt_status;
  792. u8 last_channel;
  793. __le64 start_tsf;
  794. struct iwl_scan_results_notif results[];
  795. } __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_2 */
  796. #endif /* __iwl_fw_api_scan_h__ */