scan.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  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. IWL_SCAN_CHANNEL_FLAG_EBS_FRAG = BIT(3),
  243. };
  244. /* struct iwl_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
  245. * @flags: enum iwl_scan_channel_flags
  246. * @non_ebs_ratio: defines the ratio of number of scan iterations where EBS is
  247. * involved.
  248. * 1 - EBS is disabled.
  249. * 2 - every second scan will be full scan(and so on).
  250. */
  251. struct iwl_scan_channel_opt {
  252. __le16 flags;
  253. __le16 non_ebs_ratio;
  254. } __packed;
  255. /**
  256. * enum iwl_mvm_lmac_scan_flags - LMAC scan flags
  257. * @IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL: pass all beacons and probe responses
  258. * without filtering.
  259. * @IWL_MVM_LMAC_SCAN_FLAG_PASSIVE: force passive scan on all channels
  260. * @IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION: single channel scan
  261. * @IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE: send iteration complete notification
  262. * @IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS: multiple SSID matching
  263. * @IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED: all passive scans will be fragmented
  264. * @IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED: insert WFA vendor-specific TPC report
  265. * and DS parameter set IEs into probe requests.
  266. * @IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL: use extended dwell time on channels
  267. * 1, 6 and 11.
  268. * @IWL_MVM_LMAC_SCAN_FLAG_MATCH: Send match found notification on matches
  269. */
  270. enum iwl_mvm_lmac_scan_flags {
  271. IWL_MVM_LMAC_SCAN_FLAG_PASS_ALL = BIT(0),
  272. IWL_MVM_LMAC_SCAN_FLAG_PASSIVE = BIT(1),
  273. IWL_MVM_LMAC_SCAN_FLAG_PRE_CONNECTION = BIT(2),
  274. IWL_MVM_LMAC_SCAN_FLAG_ITER_COMPLETE = BIT(3),
  275. IWL_MVM_LMAC_SCAN_FLAG_MULTIPLE_SSIDS = BIT(4),
  276. IWL_MVM_LMAC_SCAN_FLAG_FRAGMENTED = BIT(5),
  277. IWL_MVM_LMAC_SCAN_FLAGS_RRM_ENABLED = BIT(6),
  278. IWL_MVM_LMAC_SCAN_FLAG_EXTENDED_DWELL = BIT(7),
  279. IWL_MVM_LMAC_SCAN_FLAG_MATCH = BIT(9),
  280. };
  281. enum iwl_scan_priority {
  282. IWL_SCAN_PRIORITY_LOW,
  283. IWL_SCAN_PRIORITY_MEDIUM,
  284. IWL_SCAN_PRIORITY_HIGH,
  285. };
  286. enum iwl_scan_priority_ext {
  287. IWL_SCAN_PRIORITY_EXT_0_LOWEST,
  288. IWL_SCAN_PRIORITY_EXT_1,
  289. IWL_SCAN_PRIORITY_EXT_2,
  290. IWL_SCAN_PRIORITY_EXT_3,
  291. IWL_SCAN_PRIORITY_EXT_4,
  292. IWL_SCAN_PRIORITY_EXT_5,
  293. IWL_SCAN_PRIORITY_EXT_6,
  294. IWL_SCAN_PRIORITY_EXT_7_HIGHEST,
  295. };
  296. /**
  297. * struct iwl_scan_req_lmac - SCAN_REQUEST_CMD_API_S_VER_1
  298. * @reserved1: for alignment and future use
  299. * @n_channels: num of channels to scan
  300. * @active_dwell: dwell time for active channels
  301. * @passive_dwell: dwell time for passive channels
  302. * @fragmented_dwell: dwell time for fragmented passive scan
  303. * @extended_dwell: dwell time for channels 1, 6 and 11 (in certain cases)
  304. * @reserved2: for alignment and future use
  305. * @rx_chain_select: PHY_RX_CHAIN_* flags
  306. * @scan_flags: &enum iwl_mvm_lmac_scan_flags
  307. * @max_out_time: max time (in TU) to be out of associated channel
  308. * @suspend_time: pause scan this long (TUs) when returning to service channel
  309. * @flags: RXON flags
  310. * @filter_flags: RXON filter
  311. * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz
  312. * @direct_scan: list of SSIDs for directed active scan
  313. * @scan_prio: enum iwl_scan_priority
  314. * @iter_num: number of scan iterations
  315. * @delay: delay in seconds before first iteration
  316. * @schedule: two scheduling plans. The first one is finite, the second one can
  317. * be infinite.
  318. * @channel_opt: channel optimization options, for full and partial scan
  319. * @data: channel configuration and probe request packet.
  320. */
  321. struct iwl_scan_req_lmac {
  322. /* SCAN_REQUEST_FIXED_PART_API_S_VER_7 */
  323. __le32 reserved1;
  324. u8 n_channels;
  325. u8 active_dwell;
  326. u8 passive_dwell;
  327. u8 fragmented_dwell;
  328. u8 extended_dwell;
  329. u8 reserved2;
  330. __le16 rx_chain_select;
  331. __le32 scan_flags;
  332. __le32 max_out_time;
  333. __le32 suspend_time;
  334. /* RX_ON_FLAGS_API_S_VER_1 */
  335. __le32 flags;
  336. __le32 filter_flags;
  337. struct iwl_scan_req_tx_cmd tx_cmd[2];
  338. struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
  339. __le32 scan_prio;
  340. /* SCAN_REQ_PERIODIC_PARAMS_API_S */
  341. __le32 iter_num;
  342. __le32 delay;
  343. struct iwl_scan_schedule_lmac schedule[IWL_MAX_SCHED_SCAN_PLANS];
  344. struct iwl_scan_channel_opt channel_opt[2];
  345. u8 data[];
  346. } __packed;
  347. /**
  348. * struct iwl_scan_results_notif - scan results for one channel -
  349. * SCAN_RESULT_NTF_API_S_VER_3
  350. * @channel: which channel the results are from
  351. * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
  352. * @probe_status: SCAN_PROBE_STATUS_*, indicates success of probe request
  353. * @num_probe_not_sent: # of request that weren't sent due to not enough time
  354. * @duration: duration spent in channel, in usecs
  355. */
  356. struct iwl_scan_results_notif {
  357. u8 channel;
  358. u8 band;
  359. u8 probe_status;
  360. u8 num_probe_not_sent;
  361. __le32 duration;
  362. } __packed;
  363. /**
  364. * struct iwl_lmac_scan_complete_notif - notifies end of scanning (all channels)
  365. * SCAN_COMPLETE_NTF_API_S_VER_3
  366. * @scanned_channels: number of channels scanned (and number of valid results)
  367. * @status: one of SCAN_COMP_STATUS_*
  368. * @bt_status: BT on/off status
  369. * @last_channel: last channel that was scanned
  370. * @tsf_low: TSF timer (lower half) in usecs
  371. * @tsf_high: TSF timer (higher half) in usecs
  372. * @results: an array of scan results, only "scanned_channels" of them are valid
  373. */
  374. struct iwl_lmac_scan_complete_notif {
  375. u8 scanned_channels;
  376. u8 status;
  377. u8 bt_status;
  378. u8 last_channel;
  379. __le32 tsf_low;
  380. __le32 tsf_high;
  381. struct iwl_scan_results_notif results[];
  382. } __packed;
  383. /**
  384. * struct iwl_scan_offload_complete - PERIODIC_SCAN_COMPLETE_NTF_API_S_VER_2
  385. * @last_schedule_line: last schedule line executed (fast or regular)
  386. * @last_schedule_iteration: last scan iteration executed before scan abort
  387. * @status: &enum iwl_scan_offload_complete_status
  388. * @ebs_status: EBS success status &enum iwl_scan_ebs_status
  389. * @time_after_last_iter: time in seconds elapsed after last iteration
  390. * @reserved: reserved
  391. */
  392. struct iwl_periodic_scan_complete {
  393. u8 last_schedule_line;
  394. u8 last_schedule_iteration;
  395. u8 status;
  396. u8 ebs_status;
  397. __le32 time_after_last_iter;
  398. __le32 reserved;
  399. } __packed;
  400. /* UMAC Scan API */
  401. /* The maximum of either of these cannot exceed 8, because we use an
  402. * 8-bit mask (see IWL_MVM_SCAN_MASK in mvm.h).
  403. */
  404. #define IWL_MVM_MAX_UMAC_SCANS 8
  405. #define IWL_MVM_MAX_LMAC_SCANS 1
  406. enum scan_config_flags {
  407. SCAN_CONFIG_FLAG_ACTIVATE = BIT(0),
  408. SCAN_CONFIG_FLAG_DEACTIVATE = BIT(1),
  409. SCAN_CONFIG_FLAG_FORBID_CHUB_REQS = BIT(2),
  410. SCAN_CONFIG_FLAG_ALLOW_CHUB_REQS = BIT(3),
  411. SCAN_CONFIG_FLAG_SET_TX_CHAINS = BIT(8),
  412. SCAN_CONFIG_FLAG_SET_RX_CHAINS = BIT(9),
  413. SCAN_CONFIG_FLAG_SET_AUX_STA_ID = BIT(10),
  414. SCAN_CONFIG_FLAG_SET_ALL_TIMES = BIT(11),
  415. SCAN_CONFIG_FLAG_SET_EFFECTIVE_TIMES = BIT(12),
  416. SCAN_CONFIG_FLAG_SET_CHANNEL_FLAGS = BIT(13),
  417. SCAN_CONFIG_FLAG_SET_LEGACY_RATES = BIT(14),
  418. SCAN_CONFIG_FLAG_SET_MAC_ADDR = BIT(15),
  419. SCAN_CONFIG_FLAG_SET_FRAGMENTED = BIT(16),
  420. SCAN_CONFIG_FLAG_CLEAR_FRAGMENTED = BIT(17),
  421. SCAN_CONFIG_FLAG_SET_CAM_MODE = BIT(18),
  422. SCAN_CONFIG_FLAG_CLEAR_CAM_MODE = BIT(19),
  423. SCAN_CONFIG_FLAG_SET_PROMISC_MODE = BIT(20),
  424. SCAN_CONFIG_FLAG_CLEAR_PROMISC_MODE = BIT(21),
  425. SCAN_CONFIG_FLAG_SET_LMAC2_FRAGMENTED = BIT(22),
  426. SCAN_CONFIG_FLAG_CLEAR_LMAC2_FRAGMENTED = BIT(23),
  427. /* Bits 26-31 are for num of channels in channel_array */
  428. #define SCAN_CONFIG_N_CHANNELS(n) ((n) << 26)
  429. };
  430. enum scan_config_rates {
  431. /* OFDM basic rates */
  432. SCAN_CONFIG_RATE_6M = BIT(0),
  433. SCAN_CONFIG_RATE_9M = BIT(1),
  434. SCAN_CONFIG_RATE_12M = BIT(2),
  435. SCAN_CONFIG_RATE_18M = BIT(3),
  436. SCAN_CONFIG_RATE_24M = BIT(4),
  437. SCAN_CONFIG_RATE_36M = BIT(5),
  438. SCAN_CONFIG_RATE_48M = BIT(6),
  439. SCAN_CONFIG_RATE_54M = BIT(7),
  440. /* CCK basic rates */
  441. SCAN_CONFIG_RATE_1M = BIT(8),
  442. SCAN_CONFIG_RATE_2M = BIT(9),
  443. SCAN_CONFIG_RATE_5M = BIT(10),
  444. SCAN_CONFIG_RATE_11M = BIT(11),
  445. /* Bits 16-27 are for supported rates */
  446. #define SCAN_CONFIG_SUPPORTED_RATE(rate) ((rate) << 16)
  447. };
  448. enum iwl_channel_flags {
  449. IWL_CHANNEL_FLAG_EBS = BIT(0),
  450. IWL_CHANNEL_FLAG_ACCURATE_EBS = BIT(1),
  451. IWL_CHANNEL_FLAG_EBS_ADD = BIT(2),
  452. IWL_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE = BIT(3),
  453. };
  454. /**
  455. * struct iwl_scan_dwell
  456. * @active: default dwell time for active scan
  457. * @passive: default dwell time for passive scan
  458. * @fragmented: default dwell time for fragmented scan
  459. * @extended: default dwell time for channels 1, 6 and 11
  460. */
  461. struct iwl_scan_dwell {
  462. u8 active;
  463. u8 passive;
  464. u8 fragmented;
  465. u8 extended;
  466. } __packed;
  467. /**
  468. * struct iwl_scan_config
  469. * @flags: enum scan_config_flags
  470. * @tx_chains: valid_tx antenna - ANT_* definitions
  471. * @rx_chains: valid_rx antenna - ANT_* definitions
  472. * @legacy_rates: default legacy rates - enum scan_config_rates
  473. * @out_of_channel_time: default max out of serving channel time
  474. * @suspend_time: default max suspend time
  475. * @dwell: dwells for the scan
  476. * @mac_addr: default mac address to be used in probes
  477. * @bcast_sta_id: the index of the station in the fw
  478. * @channel_flags: default channel flags - enum iwl_channel_flags
  479. * scan_config_channel_flag
  480. * @channel_array: default supported channels
  481. */
  482. struct iwl_scan_config_v1 {
  483. __le32 flags;
  484. __le32 tx_chains;
  485. __le32 rx_chains;
  486. __le32 legacy_rates;
  487. __le32 out_of_channel_time;
  488. __le32 suspend_time;
  489. struct iwl_scan_dwell dwell;
  490. u8 mac_addr[ETH_ALEN];
  491. u8 bcast_sta_id;
  492. u8 channel_flags;
  493. u8 channel_array[];
  494. } __packed; /* SCAN_CONFIG_DB_CMD_API_S */
  495. #define SCAN_TWO_LMACS 2
  496. #define SCAN_LB_LMAC_IDX 0
  497. #define SCAN_HB_LMAC_IDX 1
  498. struct iwl_scan_config {
  499. __le32 flags;
  500. __le32 tx_chains;
  501. __le32 rx_chains;
  502. __le32 legacy_rates;
  503. __le32 out_of_channel_time[SCAN_TWO_LMACS];
  504. __le32 suspend_time[SCAN_TWO_LMACS];
  505. struct iwl_scan_dwell dwell;
  506. u8 mac_addr[ETH_ALEN];
  507. u8 bcast_sta_id;
  508. u8 channel_flags;
  509. u8 channel_array[];
  510. } __packed; /* SCAN_CONFIG_DB_CMD_API_S_3 */
  511. /**
  512. * enum iwl_umac_scan_flags - UMAC scan flags
  513. * @IWL_UMAC_SCAN_FLAG_PREEMPTIVE: scan process triggered by this scan request
  514. * can be preempted by other scan requests with higher priority.
  515. * The low priority scan will be resumed when the higher proirity scan is
  516. * completed.
  517. * @IWL_UMAC_SCAN_FLAG_START_NOTIF: notification will be sent to the driver
  518. * when scan starts.
  519. */
  520. enum iwl_umac_scan_flags {
  521. IWL_UMAC_SCAN_FLAG_PREEMPTIVE = BIT(0),
  522. IWL_UMAC_SCAN_FLAG_START_NOTIF = BIT(1),
  523. };
  524. enum iwl_umac_scan_uid_offsets {
  525. IWL_UMAC_SCAN_UID_TYPE_OFFSET = 0,
  526. IWL_UMAC_SCAN_UID_SEQ_OFFSET = 8,
  527. };
  528. enum iwl_umac_scan_general_flags {
  529. IWL_UMAC_SCAN_GEN_FLAGS_PERIODIC = BIT(0),
  530. IWL_UMAC_SCAN_GEN_FLAGS_OVER_BT = BIT(1),
  531. IWL_UMAC_SCAN_GEN_FLAGS_PASS_ALL = BIT(2),
  532. IWL_UMAC_SCAN_GEN_FLAGS_PASSIVE = BIT(3),
  533. IWL_UMAC_SCAN_GEN_FLAGS_PRE_CONNECT = BIT(4),
  534. IWL_UMAC_SCAN_GEN_FLAGS_ITER_COMPLETE = BIT(5),
  535. IWL_UMAC_SCAN_GEN_FLAGS_MULTIPLE_SSID = BIT(6),
  536. IWL_UMAC_SCAN_GEN_FLAGS_FRAGMENTED = BIT(7),
  537. IWL_UMAC_SCAN_GEN_FLAGS_RRM_ENABLED = BIT(8),
  538. IWL_UMAC_SCAN_GEN_FLAGS_MATCH = BIT(9),
  539. IWL_UMAC_SCAN_GEN_FLAGS_EXTENDED_DWELL = BIT(10),
  540. /* Extended dwell is obselete when adaptive dwell is used, making this
  541. * bit reusable. Hence, probe request defer is used only when adaptive
  542. * dwell is supported. */
  543. IWL_UMAC_SCAN_GEN_FLAGS_PROB_REQ_DEFER_SUPP = BIT(10),
  544. IWL_UMAC_SCAN_GEN_FLAGS_LMAC2_FRAGMENTED = BIT(11),
  545. IWL_UMAC_SCAN_GEN_FLAGS_ADAPTIVE_DWELL = BIT(13),
  546. IWL_UMAC_SCAN_GEN_FLAGS_MAX_CHNL_TIME = BIT(14),
  547. IWL_UMAC_SCAN_GEN_FLAGS_PROB_REQ_HIGH_TX_RATE = BIT(15),
  548. };
  549. /**
  550. * enum iwl_umac_scan_general_flags2 - UMAC scan general flags #2
  551. * @IWL_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL: Whether to send a complete
  552. * notification per channel or not.
  553. */
  554. enum iwl_umac_scan_general_flags2 {
  555. IWL_UMAC_SCAN_GEN_FLAGS2_NOTIF_PER_CHNL = BIT(0),
  556. };
  557. /**
  558. * struct iwl_scan_channel_cfg_umac
  559. * @flags: bitmap - 0-19: directed scan to i'th ssid.
  560. * @channel_num: channel number 1-13 etc.
  561. * @iter_count: repetition count for the channel.
  562. * @iter_interval: interval between two scan iterations on one channel.
  563. */
  564. struct iwl_scan_channel_cfg_umac {
  565. __le32 flags;
  566. u8 channel_num;
  567. u8 iter_count;
  568. __le16 iter_interval;
  569. } __packed; /* SCAN_CHANNEL_CFG_S_VER2 */
  570. /**
  571. * struct iwl_scan_umac_schedule
  572. * @interval: interval in seconds between scan iterations
  573. * @iter_count: num of scan iterations for schedule plan, 0xff for infinite loop
  574. * @reserved: for alignment and future use
  575. */
  576. struct iwl_scan_umac_schedule {
  577. __le16 interval;
  578. u8 iter_count;
  579. u8 reserved;
  580. } __packed; /* SCAN_SCHED_PARAM_API_S_VER_1 */
  581. /**
  582. * struct iwl_scan_req_umac_tail - the rest of the UMAC scan request command
  583. * parameters following channels configuration array.
  584. * @schedule: two scheduling plans.
  585. * @delay: delay in TUs before starting the first scan iteration
  586. * @reserved: for future use and alignment
  587. * @preq: probe request with IEs blocks
  588. * @direct_scan: list of SSIDs for directed active scan
  589. */
  590. struct iwl_scan_req_umac_tail {
  591. /* SCAN_PERIODIC_PARAMS_API_S_VER_1 */
  592. struct iwl_scan_umac_schedule schedule[IWL_MAX_SCHED_SCAN_PLANS];
  593. __le16 delay;
  594. __le16 reserved;
  595. /* SCAN_PROBE_PARAMS_API_S_VER_1 */
  596. struct iwl_scan_probe_req preq;
  597. struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX];
  598. } __packed;
  599. /**
  600. * struct iwl_scan_umac_chan_param
  601. * @flags: channel flags &enum iwl_scan_channel_flags
  602. * @count: num of channels in scan request
  603. * @reserved: for future use and alignment
  604. */
  605. struct iwl_scan_umac_chan_param {
  606. u8 flags;
  607. u8 count;
  608. __le16 reserved;
  609. } __packed; /*SCAN_CHANNEL_PARAMS_API_S_VER_1 */
  610. /**
  611. * struct iwl_scan_req_umac
  612. * @flags: &enum iwl_umac_scan_flags
  613. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  614. * @ooc_priority: out of channel priority - &enum iwl_scan_priority
  615. * @general_flags: &enum iwl_umac_scan_general_flags
  616. * @scan_start_mac_id: report the scan start TSF time according to this mac TSF
  617. * @extended_dwell: dwell time for channels 1, 6 and 11
  618. * @active_dwell: dwell time for active scan per LMAC
  619. * @passive_dwell: dwell time for passive scan per LMAC
  620. * @fragmented_dwell: dwell time for fragmented passive scan
  621. * @adwell_default_n_aps: for adaptive dwell the default number of APs
  622. * per channel
  623. * @adwell_default_n_aps_social: for adaptive dwell the default
  624. * number of APs per social (1,6,11) channel
  625. * @general_flags2: &enum iwl_umac_scan_general_flags2
  626. * @adwell_max_budget: for adaptive dwell the maximal budget of TU to be added
  627. * to total scan time
  628. * @max_out_time: max out of serving channel time, per LMAC - for CDB there
  629. * are 2 LMACs
  630. * @suspend_time: max suspend time, per LMAC - for CDB there are 2 LMACs
  631. * @scan_priority: scan internal prioritization &enum iwl_scan_priority
  632. * @num_of_fragments: Number of fragments needed for full coverage per band.
  633. * Relevant only for fragmented scan.
  634. * @channel: &struct iwl_scan_umac_chan_param
  635. * @reserved: for future use and alignment
  636. * @reserved3: for future use and alignment
  637. * @data: &struct iwl_scan_channel_cfg_umac and
  638. * &struct iwl_scan_req_umac_tail
  639. */
  640. struct iwl_scan_req_umac {
  641. __le32 flags;
  642. __le32 uid;
  643. __le32 ooc_priority;
  644. __le16 general_flags;
  645. u8 reserved;
  646. u8 scan_start_mac_id;
  647. union {
  648. struct {
  649. u8 extended_dwell;
  650. u8 active_dwell;
  651. u8 passive_dwell;
  652. u8 fragmented_dwell;
  653. __le32 max_out_time;
  654. __le32 suspend_time;
  655. __le32 scan_priority;
  656. struct iwl_scan_umac_chan_param channel;
  657. u8 data[];
  658. } v1; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_1 */
  659. struct {
  660. u8 extended_dwell;
  661. u8 active_dwell;
  662. u8 passive_dwell;
  663. u8 fragmented_dwell;
  664. __le32 max_out_time[SCAN_TWO_LMACS];
  665. __le32 suspend_time[SCAN_TWO_LMACS];
  666. __le32 scan_priority;
  667. struct iwl_scan_umac_chan_param channel;
  668. u8 data[];
  669. } v6; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_6 */
  670. struct {
  671. u8 active_dwell;
  672. u8 passive_dwell;
  673. u8 fragmented_dwell;
  674. u8 adwell_default_n_aps;
  675. u8 adwell_default_n_aps_social;
  676. u8 reserved3;
  677. __le16 adwell_max_budget;
  678. __le32 max_out_time[SCAN_TWO_LMACS];
  679. __le32 suspend_time[SCAN_TWO_LMACS];
  680. __le32 scan_priority;
  681. struct iwl_scan_umac_chan_param channel;
  682. u8 data[];
  683. } v7; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_7 */
  684. struct {
  685. u8 active_dwell[SCAN_TWO_LMACS];
  686. u8 reserved2;
  687. u8 adwell_default_n_aps;
  688. u8 adwell_default_n_aps_social;
  689. u8 general_flags2;
  690. __le16 adwell_max_budget;
  691. __le32 max_out_time[SCAN_TWO_LMACS];
  692. __le32 suspend_time[SCAN_TWO_LMACS];
  693. __le32 scan_priority;
  694. u8 passive_dwell[SCAN_TWO_LMACS];
  695. u8 num_of_fragments[SCAN_TWO_LMACS];
  696. struct iwl_scan_umac_chan_param channel;
  697. u8 data[];
  698. } v8; /* SCAN_REQUEST_CMD_UMAC_API_S_VER_8 */
  699. };
  700. } __packed;
  701. #define IWL_SCAN_REQ_UMAC_SIZE_V8 sizeof(struct iwl_scan_req_umac)
  702. #define IWL_SCAN_REQ_UMAC_SIZE_V7 48
  703. #define IWL_SCAN_REQ_UMAC_SIZE_V6 44
  704. #define IWL_SCAN_REQ_UMAC_SIZE_V1 36
  705. /**
  706. * struct iwl_umac_scan_abort
  707. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  708. * @flags: reserved
  709. */
  710. struct iwl_umac_scan_abort {
  711. __le32 uid;
  712. __le32 flags;
  713. } __packed; /* SCAN_ABORT_CMD_UMAC_API_S_VER_1 */
  714. /**
  715. * struct iwl_umac_scan_complete
  716. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  717. * @last_schedule: last scheduling line
  718. * @last_iter: last scan iteration number
  719. * @status: &enum iwl_scan_offload_complete_status
  720. * @ebs_status: &enum iwl_scan_ebs_status
  721. * @time_from_last_iter: time elapsed from last iteration
  722. * @reserved: for future use
  723. */
  724. struct iwl_umac_scan_complete {
  725. __le32 uid;
  726. u8 last_schedule;
  727. u8 last_iter;
  728. u8 status;
  729. u8 ebs_status;
  730. __le32 time_from_last_iter;
  731. __le32 reserved;
  732. } __packed; /* SCAN_COMPLETE_NTF_UMAC_API_S_VER_1 */
  733. #define SCAN_OFFLOAD_MATCHING_CHANNELS_LEN 5
  734. /**
  735. * struct iwl_scan_offload_profile_match - match information
  736. * @bssid: matched bssid
  737. * @reserved: reserved
  738. * @channel: channel where the match occurred
  739. * @energy: energy
  740. * @matching_feature: feature matches
  741. * @matching_channels: bitmap of channels that matched, referencing
  742. * the channels passed in tue scan offload request
  743. */
  744. struct iwl_scan_offload_profile_match {
  745. u8 bssid[ETH_ALEN];
  746. __le16 reserved;
  747. u8 channel;
  748. u8 energy;
  749. u8 matching_feature;
  750. u8 matching_channels[SCAN_OFFLOAD_MATCHING_CHANNELS_LEN];
  751. } __packed; /* SCAN_OFFLOAD_PROFILE_MATCH_RESULTS_S_VER_1 */
  752. /**
  753. * struct iwl_scan_offload_profiles_query - match results query response
  754. * @matched_profiles: bitmap of matched profiles, referencing the
  755. * matches passed in the scan offload request
  756. * @last_scan_age: age of the last offloaded scan
  757. * @n_scans_done: number of offloaded scans done
  758. * @gp2_d0u: GP2 when D0U occurred
  759. * @gp2_invoked: GP2 when scan offload was invoked
  760. * @resume_while_scanning: not used
  761. * @self_recovery: obsolete
  762. * @reserved: reserved
  763. * @matches: array of match information, one for each match
  764. */
  765. struct iwl_scan_offload_profiles_query {
  766. __le32 matched_profiles;
  767. __le32 last_scan_age;
  768. __le32 n_scans_done;
  769. __le32 gp2_d0u;
  770. __le32 gp2_invoked;
  771. u8 resume_while_scanning;
  772. u8 self_recovery;
  773. __le16 reserved;
  774. struct iwl_scan_offload_profile_match matches[IWL_SCAN_MAX_PROFILES];
  775. } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_2 */
  776. /**
  777. * struct iwl_umac_scan_iter_complete_notif - notifies end of scanning iteration
  778. * @uid: scan id, &enum iwl_umac_scan_uid_offsets
  779. * @scanned_channels: number of channels scanned and number of valid elements in
  780. * results array
  781. * @status: one of SCAN_COMP_STATUS_*
  782. * @bt_status: BT on/off status
  783. * @last_channel: last channel that was scanned
  784. * @start_tsf: TSF timer in usecs of the scan start time for the mac specified
  785. * in &struct iwl_scan_req_umac.
  786. * @results: array of scan results, length in @scanned_channels
  787. */
  788. struct iwl_umac_scan_iter_complete_notif {
  789. __le32 uid;
  790. u8 scanned_channels;
  791. u8 status;
  792. u8 bt_status;
  793. u8 last_channel;
  794. __le64 start_tsf;
  795. struct iwl_scan_results_notif results[];
  796. } __packed; /* SCAN_ITER_COMPLETE_NTF_UMAC_API_S_VER_2 */
  797. #endif /* __iwl_fw_api_scan_h__ */