fw-api-scan.h 28 KB

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