1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
4  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5  * Copyright (C) 2015-2017 Intel Deutschland GmbH
6  */
7 #ifndef __iwl_fw_api_d3_h__
8 #define __iwl_fw_api_d3_h__
9 #include <iwl-trans.h>
10 
11 /**
12  * enum iwl_d0i3_flags - d0i3 flags
13  * @IWL_D0I3_RESET_REQUIRE: FW require reset upon resume
14  */
15 enum iwl_d0i3_flags {
16 	IWL_D0I3_RESET_REQUIRE = BIT(0),
17 };
18 
19 /**
20  * enum iwl_d3_wakeup_flags - D3 manager wakeup flags
21  * @IWL_WAKEUP_D3_CONFIG_FW_ERROR: wake up on firmware sysassert
22  */
23 enum iwl_d3_wakeup_flags {
24 	IWL_WAKEUP_D3_CONFIG_FW_ERROR = BIT(0),
25 }; /* D3_MANAGER_WAKEUP_CONFIG_API_E_VER_3 */
26 
27 /**
28  * struct iwl_d3_manager_config - D3 manager configuration command
29  * @min_sleep_time: minimum sleep time (in usec)
30  * @wakeup_flags: wakeup flags, see &enum iwl_d3_wakeup_flags
31  * @wakeup_host_timer: force wakeup after this many seconds
32  *
33  * The structure is used for the D3_CONFIG_CMD command.
34  */
35 struct iwl_d3_manager_config {
36 	__le32 min_sleep_time;
37 	__le32 wakeup_flags;
38 	__le32 wakeup_host_timer;
39 } __packed; /* D3_MANAGER_CONFIG_CMD_S_VER_4 */
40 
41 
42 /* TODO: OFFLOADS_QUERY_API_S_VER_1 */
43 
44 /**
45  * enum iwl_d3_proto_offloads - enabled protocol offloads
46  * @IWL_D3_PROTO_OFFLOAD_ARP: ARP data is enabled
47  * @IWL_D3_PROTO_OFFLOAD_NS: NS (Neighbor Solicitation) is enabled
48  * @IWL_D3_PROTO_IPV4_VALID: IPv4 data is valid
49  * @IWL_D3_PROTO_IPV6_VALID: IPv6 data is valid
50  */
51 enum iwl_proto_offloads {
52 	IWL_D3_PROTO_OFFLOAD_ARP = BIT(0),
53 	IWL_D3_PROTO_OFFLOAD_NS = BIT(1),
54 	IWL_D3_PROTO_IPV4_VALID = BIT(2),
55 	IWL_D3_PROTO_IPV6_VALID = BIT(3),
56 };
57 
58 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1	2
59 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2	6
60 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L	12
61 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S	4
62 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX	12
63 
64 #define IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L	4
65 #define IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S	2
66 
67 /**
68  * struct iwl_proto_offload_cmd_common - ARP/NS offload common part
69  * @enabled: enable flags
70  * @remote_ipv4_addr: remote address to answer to (or zero if all)
71  * @host_ipv4_addr: our IPv4 address to respond to queries for
72  * @arp_mac_addr: our MAC address for ARP responses
73  * @reserved: unused
74  */
75 struct iwl_proto_offload_cmd_common {
76 	__le32 enabled;
77 	__be32 remote_ipv4_addr;
78 	__be32 host_ipv4_addr;
79 	u8 arp_mac_addr[ETH_ALEN];
80 	__le16 reserved;
81 } __packed;
82 
83 /**
84  * struct iwl_proto_offload_cmd_v1 - ARP/NS offload configuration
85  * @common: common/IPv4 configuration
86  * @remote_ipv6_addr: remote address to answer to (or zero if all)
87  * @solicited_node_ipv6_addr: broken -- solicited node address exists
88  *	for each target address
89  * @target_ipv6_addr: our target addresses
90  * @ndp_mac_addr: neighbor solicitation response MAC address
91  * @reserved2: reserved
92  */
93 struct iwl_proto_offload_cmd_v1 {
94 	struct iwl_proto_offload_cmd_common common;
95 	u8 remote_ipv6_addr[16];
96 	u8 solicited_node_ipv6_addr[16];
97 	u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1][16];
98 	u8 ndp_mac_addr[ETH_ALEN];
99 	__le16 reserved2;
100 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_1 */
101 
102 /**
103  * struct iwl_proto_offload_cmd_v2 - ARP/NS offload configuration
104  * @common: common/IPv4 configuration
105  * @remote_ipv6_addr: remote address to answer to (or zero if all)
106  * @solicited_node_ipv6_addr: broken -- solicited node address exists
107  *	for each target address
108  * @target_ipv6_addr: our target addresses
109  * @ndp_mac_addr: neighbor solicitation response MAC address
110  * @num_valid_ipv6_addrs: number of valid IPv6 addresses
111  * @reserved2: reserved
112  */
113 struct iwl_proto_offload_cmd_v2 {
114 	struct iwl_proto_offload_cmd_common common;
115 	u8 remote_ipv6_addr[16];
116 	u8 solicited_node_ipv6_addr[16];
117 	u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2][16];
118 	u8 ndp_mac_addr[ETH_ALEN];
119 	u8 num_valid_ipv6_addrs;
120 	u8 reserved2[3];
121 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_2 */
122 
123 struct iwl_ns_config {
124 	struct in6_addr source_ipv6_addr;
125 	struct in6_addr dest_ipv6_addr;
126 	u8 target_mac_addr[ETH_ALEN];
127 	__le16 reserved;
128 } __packed; /* NS_OFFLOAD_CONFIG */
129 
130 struct iwl_targ_addr {
131 	struct in6_addr addr;
132 	__le32 config_num;
133 } __packed; /* TARGET_IPV6_ADDRESS */
134 
135 /**
136  * struct iwl_proto_offload_cmd_v3_small - ARP/NS offload configuration
137  * @common: common/IPv4 configuration
138  * @num_valid_ipv6_addrs: number of valid IPv6 addresses
139  * @targ_addrs: target IPv6 addresses
140  * @ns_config: NS offload configurations
141  */
142 struct iwl_proto_offload_cmd_v3_small {
143 	struct iwl_proto_offload_cmd_common common;
144 	__le32 num_valid_ipv6_addrs;
145 	struct iwl_targ_addr targ_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S];
146 	struct iwl_ns_config ns_config[IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S];
147 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_3 */
148 
149 /**
150  * struct iwl_proto_offload_cmd_v3_large - ARP/NS offload configuration
151  * @common: common/IPv4 configuration
152  * @num_valid_ipv6_addrs: number of valid IPv6 addresses
153  * @targ_addrs: target IPv6 addresses
154  * @ns_config: NS offload configurations
155  */
156 struct iwl_proto_offload_cmd_v3_large {
157 	struct iwl_proto_offload_cmd_common common;
158 	__le32 num_valid_ipv6_addrs;
159 	struct iwl_targ_addr targ_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L];
160 	struct iwl_ns_config ns_config[IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L];
161 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_3 */
162 
163 /**
164  * struct iwl_proto_offload_cmd_v4 - ARP/NS offload configuration
165  * @sta_id: station id
166  * @common: common/IPv4 configuration
167  * @num_valid_ipv6_addrs: number of valid IPv6 addresses
168  * @targ_addrs: target IPv6 addresses
169  * @ns_config: NS offload configurations
170  */
171 struct iwl_proto_offload_cmd_v4 {
172 	__le32 sta_id;
173 	struct iwl_proto_offload_cmd_common common;
174 	__le32 num_valid_ipv6_addrs;
175 	struct iwl_targ_addr targ_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L];
176 	struct iwl_ns_config ns_config[IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L];
177 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_4 */
178 
179 /*
180  * WOWLAN_PATTERNS
181  */
182 #define IWL_WOWLAN_MIN_PATTERN_LEN	16
183 #define IWL_WOWLAN_MAX_PATTERN_LEN	128
184 
185 struct iwl_wowlan_pattern_v1 {
186 	u8 mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
187 	u8 pattern[IWL_WOWLAN_MAX_PATTERN_LEN];
188 	u8 mask_size;
189 	u8 pattern_size;
190 	__le16 reserved;
191 } __packed; /* WOWLAN_PATTERN_API_S_VER_1 */
192 
193 #define IWL_WOWLAN_MAX_PATTERNS	20
194 
195 /**
196  * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns
197  */
198 struct iwl_wowlan_patterns_cmd_v1 {
199 	/**
200 	 * @n_patterns: number of patterns
201 	 */
202 	__le32 n_patterns;
203 
204 	/**
205 	 * @patterns: the patterns, array length in @n_patterns
206 	 */
207 	struct iwl_wowlan_pattern_v1 patterns[];
208 } __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_1 */
209 
210 #define IPV4_ADDR_SIZE	4
211 #define IPV6_ADDR_SIZE	16
212 
213 enum iwl_wowlan_pattern_type {
214 	WOWLAN_PATTERN_TYPE_BITMASK,
215 	WOWLAN_PATTERN_TYPE_IPV4_TCP_SYN,
216 	WOWLAN_PATTERN_TYPE_IPV6_TCP_SYN,
217 	WOWLAN_PATTERN_TYPE_IPV4_TCP_SYN_WILDCARD,
218 	WOWLAN_PATTERN_TYPE_IPV6_TCP_SYN_WILDCARD,
219 }; /* WOWLAN_PATTERN_TYPE_API_E_VER_1 */
220 
221 /**
222  * struct iwl_wowlan_ipv4_tcp_syn - WoWLAN IPv4 TCP SYN pattern data
223  */
224 struct iwl_wowlan_ipv4_tcp_syn {
225 	/**
226 	 * @src_addr: source IP address to match
227 	 */
228 	u8 src_addr[IPV4_ADDR_SIZE];
229 
230 	/**
231 	 * @dst_addr: destination IP address to match
232 	 */
233 	u8 dst_addr[IPV4_ADDR_SIZE];
234 
235 	/**
236 	 * @src_port: source TCP port to match
237 	 */
238 	__le16 src_port;
239 
240 	/**
241 	 * @dst_port: destination TCP port to match
242 	 */
243 	__le16 dst_port;
244 } __packed; /* WOWLAN_IPV4_TCP_SYN_API_S_VER_1 */
245 
246 /**
247  * struct iwl_wowlan_ipv6_tcp_syn - WoWLAN Ipv6 TCP SYN pattern data
248  */
249 struct iwl_wowlan_ipv6_tcp_syn {
250 	/**
251 	 * @src_addr: source IP address to match
252 	 */
253 	u8 src_addr[IPV6_ADDR_SIZE];
254 
255 	/**
256 	 * @dst_addr: destination IP address to match
257 	 */
258 	u8 dst_addr[IPV6_ADDR_SIZE];
259 
260 	/**
261 	 * @src_port: source TCP port to match
262 	 */
263 	__le16 src_port;
264 
265 	/**
266 	 * @dst_port: destination TCP port to match
267 	 */
268 	__le16 dst_port;
269 } __packed; /* WOWLAN_IPV6_TCP_SYN_API_S_VER_1 */
270 
271 /**
272  * union iwl_wowlan_pattern_data - Data for the different pattern types
273  *
274  * If wildcard addresses/ports are to be used, the union can be left
275  * undefined.
276  */
277 union iwl_wowlan_pattern_data {
278 	/**
279 	 * @bitmask: bitmask pattern data
280 	 */
281 	struct iwl_wowlan_pattern_v1 bitmask;
282 
283 	/**
284 	 * @ipv4_tcp_syn: IPv4 TCP SYN pattern data
285 	 */
286 	struct iwl_wowlan_ipv4_tcp_syn ipv4_tcp_syn;
287 
288 	/**
289 	 * @ipv6_tcp_syn: IPv6 TCP SYN pattern data
290 	 */
291 	struct iwl_wowlan_ipv6_tcp_syn ipv6_tcp_syn;
292 }; /* WOWLAN_PATTERN_API_U_VER_1 */
293 
294 /**
295  * struct iwl_wowlan_pattern_v2 - Pattern entry for the WoWLAN wakeup patterns
296  */
297 struct iwl_wowlan_pattern_v2 {
298 	/**
299 	 * @pattern_type: defines the struct type to be used in the union
300 	 */
301 	u8 pattern_type;
302 
303 	/**
304 	 * @reserved: reserved for alignment
305 	 */
306 	u8 reserved[3];
307 
308 	/**
309 	 * @u: the union containing the match data, or undefined for
310 	 *     wildcard matches
311 	 */
312 	union iwl_wowlan_pattern_data u;
313 } __packed; /* WOWLAN_PATTERN_API_S_VER_2 */
314 
315 /**
316  * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns command
317  */
318 struct iwl_wowlan_patterns_cmd {
319 	/**
320 	 * @n_patterns: number of patterns
321 	 */
322 	u8 n_patterns;
323 
324 	/**
325 	 * @n_patterns: sta_id
326 	 */
327 	u8 sta_id;
328 
329 	/**
330 	 * @reserved: reserved for alignment
331 	 */
332 	__le16 reserved;
333 
334 	/**
335 	 * @patterns: the patterns, array length in @n_patterns
336 	 */
337 	struct iwl_wowlan_pattern_v2 patterns[];
338 } __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_3 */
339 
340 enum iwl_wowlan_wakeup_filters {
341 	IWL_WOWLAN_WAKEUP_MAGIC_PACKET			= BIT(0),
342 	IWL_WOWLAN_WAKEUP_PATTERN_MATCH			= BIT(1),
343 	IWL_WOWLAN_WAKEUP_BEACON_MISS			= BIT(2),
344 	IWL_WOWLAN_WAKEUP_LINK_CHANGE			= BIT(3),
345 	IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL		= BIT(4),
346 	IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ			= BIT(5),
347 	IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE		= BIT(6),
348 	IWL_WOWLAN_WAKEUP_ENABLE_NET_DETECT		= BIT(7),
349 	IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT		= BIT(8),
350 	IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS		= BIT(9),
351 	IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE	= BIT(10),
352 	IWL_WOWLAN_WAKEUP_REMOTE_TCP_EXTERNAL		= BIT(11),
353 	IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET		= BIT(12),
354 	IWL_WOWLAN_WAKEUP_IOAC_MAGIC_PACKET		= BIT(13),
355 	IWL_WOWLAN_WAKEUP_HOST_TIMER			= BIT(14),
356 	IWL_WOWLAN_WAKEUP_RX_FRAME			= BIT(15),
357 	IWL_WOWLAN_WAKEUP_BCN_FILTERING			= BIT(16),
358 }; /* WOWLAN_WAKEUP_FILTER_API_E_VER_4 */
359 
360 enum iwl_wowlan_flags {
361 	IS_11W_ASSOC		= BIT(0),
362 	ENABLE_L3_FILTERING	= BIT(1),
363 	ENABLE_NBNS_FILTERING	= BIT(2),
364 	ENABLE_DHCP_FILTERING	= BIT(3),
365 	ENABLE_STORE_BEACON	= BIT(4),
366 };
367 
368 /**
369  * struct iwl_wowlan_config_cmd - WoWLAN configuration (versions 5 and 6)
370  * @wakeup_filter: filter from &enum iwl_wowlan_wakeup_filters
371  * @non_qos_seq: non-QoS sequence counter to use next.
372  *               Reserved if the struct has version >= 6.
373  * @qos_seq: QoS sequence counters to use next
374  * @wowlan_ba_teardown_tids: bitmap of BA sessions to tear down
375  * @is_11n_connection: indicates HT connection
376  * @offloading_tid: TID reserved for firmware use
377  * @flags: extra flags, see &enum iwl_wowlan_flags
378  * @sta_id: station ID for wowlan.
379  * @reserved: reserved
380  */
381 struct iwl_wowlan_config_cmd {
382 	__le32 wakeup_filter;
383 	__le16 non_qos_seq;
384 	__le16 qos_seq[8];
385 	u8 wowlan_ba_teardown_tids;
386 	u8 is_11n_connection;
387 	u8 offloading_tid;
388 	u8 flags;
389 	u8 sta_id;
390 	u8 reserved;
391 } __packed; /* WOWLAN_CONFIG_API_S_VER_5 */
392 
393 #define IWL_NUM_RSC	16
394 #define WOWLAN_KEY_MAX_SIZE	32
395 #define WOWLAN_GTK_KEYS_NUM     2
396 #define WOWLAN_IGTK_KEYS_NUM	2
397 
398 /*
399  * WOWLAN_TSC_RSC_PARAMS
400  */
401 struct tkip_sc {
402 	__le16 iv16;
403 	__le16 pad;
404 	__le32 iv32;
405 } __packed; /* TKIP_SC_API_U_VER_1 */
406 
407 struct iwl_tkip_rsc_tsc {
408 	struct tkip_sc unicast_rsc[IWL_NUM_RSC];
409 	struct tkip_sc multicast_rsc[IWL_NUM_RSC];
410 	struct tkip_sc tsc;
411 } __packed; /* TKIP_TSC_RSC_API_S_VER_1 */
412 
413 struct aes_sc {
414 	__le64 pn;
415 } __packed; /* TKIP_AES_SC_API_U_VER_1 */
416 
417 struct iwl_aes_rsc_tsc {
418 	struct aes_sc unicast_rsc[IWL_NUM_RSC];
419 	struct aes_sc multicast_rsc[IWL_NUM_RSC];
420 	struct aes_sc tsc;
421 } __packed; /* AES_TSC_RSC_API_S_VER_1 */
422 
423 union iwl_all_tsc_rsc {
424 	struct iwl_tkip_rsc_tsc tkip;
425 	struct iwl_aes_rsc_tsc aes;
426 }; /* ALL_TSC_RSC_API_S_VER_2 */
427 
428 struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 {
429 	union iwl_all_tsc_rsc all_tsc_rsc;
430 } __packed; /* ALL_TSC_RSC_API_S_VER_2 */
431 
432 struct iwl_wowlan_rsc_tsc_params_cmd_v4 {
433 	struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 params;
434 	__le32 sta_id;
435 } __packed; /* ALL_TSC_RSC_API_S_VER_4 */
436 
437 struct iwl_wowlan_rsc_tsc_params_cmd {
438 	__le64 ucast_rsc[IWL_MAX_TID_COUNT];
439 	__le64 mcast_rsc[WOWLAN_GTK_KEYS_NUM][IWL_MAX_TID_COUNT];
440 	__le32 sta_id;
441 #define IWL_MCAST_KEY_MAP_INVALID	0xff
442 	u8 mcast_key_id_map[4];
443 } __packed; /* ALL_TSC_RSC_API_S_VER_5 */
444 
445 #define IWL_MIC_KEY_SIZE	8
446 struct iwl_mic_keys {
447 	u8 tx[IWL_MIC_KEY_SIZE];
448 	u8 rx_unicast[IWL_MIC_KEY_SIZE];
449 	u8 rx_mcast[IWL_MIC_KEY_SIZE];
450 } __packed; /* MIC_KEYS_API_S_VER_1 */
451 
452 #define IWL_P1K_SIZE		5
453 struct iwl_p1k_cache {
454 	__le16 p1k[IWL_P1K_SIZE];
455 } __packed;
456 
457 #define IWL_NUM_RX_P1K_CACHE	2
458 
459 struct iwl_wowlan_tkip_params_cmd_ver_1 {
460 	struct iwl_mic_keys mic_keys;
461 	struct iwl_p1k_cache tx;
462 	struct iwl_p1k_cache rx_uni[IWL_NUM_RX_P1K_CACHE];
463 	struct iwl_p1k_cache rx_multi[IWL_NUM_RX_P1K_CACHE];
464 } __packed; /* WOWLAN_TKIP_SETTING_API_S_VER_1 */
465 
466 struct iwl_wowlan_tkip_params_cmd {
467 	struct iwl_mic_keys mic_keys;
468 	struct iwl_p1k_cache tx;
469 	struct iwl_p1k_cache rx_uni[IWL_NUM_RX_P1K_CACHE];
470 	struct iwl_p1k_cache rx_multi[IWL_NUM_RX_P1K_CACHE];
471 	u8     reversed[2];
472 	__le32 sta_id;
473 } __packed; /* WOWLAN_TKIP_SETTING_API_S_VER_2 */
474 
475 #define IWL_KCK_MAX_SIZE	32
476 #define IWL_KEK_MAX_SIZE	32
477 
478 struct iwl_wowlan_kek_kck_material_cmd_v2 {
479 	u8	kck[IWL_KCK_MAX_SIZE];
480 	u8	kek[IWL_KEK_MAX_SIZE];
481 	__le16	kck_len;
482 	__le16	kek_len;
483 	__le64	replay_ctr;
484 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_2 */
485 
486 struct iwl_wowlan_kek_kck_material_cmd_v3 {
487 	u8	kck[IWL_KCK_MAX_SIZE];
488 	u8	kek[IWL_KEK_MAX_SIZE];
489 	__le16	kck_len;
490 	__le16	kek_len;
491 	__le64	replay_ctr;
492 	__le32  akm;
493 	__le32  gtk_cipher;
494 	__le32  igtk_cipher;
495 	__le32  bigtk_cipher;
496 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_3 */
497 
498 struct iwl_wowlan_kek_kck_material_cmd_v4 {
499 	__le32  sta_id;
500 	u8	kck[IWL_KCK_MAX_SIZE];
501 	u8	kek[IWL_KEK_MAX_SIZE];
502 	__le16	kck_len;
503 	__le16	kek_len;
504 	__le64	replay_ctr;
505 	__le32  akm;
506 	__le32  gtk_cipher;
507 	__le32  igtk_cipher;
508 	__le32  bigtk_cipher;
509 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_4 */
510 
511 struct iwl_wowlan_get_status_cmd {
512 	__le32  sta_id;
513 } __packed; /* WOWLAN_GET_STATUSES_CMD_API_S_VER_1 */
514 
515 #define RF_KILL_INDICATOR_FOR_WOWLAN	0x87
516 
517 enum iwl_wowlan_rekey_status {
518 	IWL_WOWLAN_REKEY_POST_REKEY = 0,
519 	IWL_WOWLAN_REKEY_WHILE_REKEY = 1,
520 }; /* WOWLAN_REKEY_STATUS_API_E_VER_1 */
521 
522 enum iwl_wowlan_wakeup_reason {
523 	IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS			= 0,
524 	IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET			= BIT(0),
525 	IWL_WOWLAN_WAKEUP_BY_PATTERN				= BIT(1),
526 	IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON	= BIT(2),
527 	IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH		= BIT(3),
528 	IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE			= BIT(4),
529 	IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED			= BIT(5),
530 	IWL_WOWLAN_WAKEUP_BY_UCODE_ERROR			= BIT(6),
531 	IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST			= BIT(7),
532 	IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE			= BIT(8),
533 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS			= BIT(9),
534 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE		= BIT(10),
535 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_TCP_EXTERNAL		= BIT(11),
536 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET		= BIT(12),
537 	IWL_WOWLAN_WAKEUP_BY_IOAC_MAGIC_PACKET			= BIT(13),
538 	IWL_WOWLAN_WAKEUP_BY_D3_WAKEUP_HOST_TIMER		= BIT(14),
539 	IWL_WOWLAN_WAKEUP_BY_RXFRAME_FILTERED_IN		= BIT(15),
540 	IWL_WOWLAN_WAKEUP_BY_BEACON_FILTERED_IN			= BIT(16),
541 	IWL_WAKEUP_BY_11W_UNPROTECTED_DEAUTH_OR_DISASSOC	= BIT(17),
542 	IWL_WAKEUP_BY_PATTERN_IPV4_TCP_SYN			= BIT(18),
543 	IWL_WAKEUP_BY_PATTERN_IPV4_TCP_SYN_WILDCARD		= BIT(19),
544 	IWL_WAKEUP_BY_PATTERN_IPV6_TCP_SYN			= BIT(20),
545 	IWL_WAKEUP_BY_PATTERN_IPV6_TCP_SYN_WILDCARD		= BIT(21),
546 }; /* WOWLAN_WAKE_UP_REASON_API_E_VER_2 */
547 
548 struct iwl_wowlan_gtk_status_v1 {
549 	u8 key_index;
550 	u8 reserved[3];
551 	u8 decrypt_key[16];
552 	u8 tkip_mic_key[8];
553 	struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 rsc;
554 } __packed; /* WOWLAN_GTK_MATERIAL_VER_1 */
555 
556 /**
557  * struct iwl_wowlan_gtk_status_v2 - GTK status
558  * @key: GTK material
559  * @key_len: GTK legth, if set to 0, the key is not available
560  * @key_flags: information about the key:
561  *	bits[0:1]:  key index assigned by the AP
562  *	bits[2:6]:  GTK index of the key in the internal DB
563  *	bit[7]:     Set iff this is the currently used GTK
564  * @reserved: padding
565  * @tkip_mic_key: TKIP RX MIC key
566  * @rsc: TSC RSC counters
567  */
568 struct iwl_wowlan_gtk_status_v2 {
569 	u8 key[WOWLAN_KEY_MAX_SIZE];
570 	u8 key_len;
571 	u8 key_flags;
572 	u8 reserved[2];
573 	u8 tkip_mic_key[8];
574 	struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 rsc;
575 } __packed; /* WOWLAN_GTK_MATERIAL_VER_2 */
576 
577 /**
578  * struct iwl_wowlan_all_rsc_tsc_v5 - key counters
579  * @ucast_rsc: unicast RSC values
580  * @mcast_rsc: multicast RSC values (per key map value)
581  * @sta_id: station ID
582  * @mcast_key_id_map: map of key id to @mcast_rsc entry
583  */
584 struct iwl_wowlan_all_rsc_tsc_v5 {
585 	__le64 ucast_rsc[IWL_MAX_TID_COUNT];
586 	__le64 mcast_rsc[2][IWL_MAX_TID_COUNT];
587 	__le32 sta_id;
588 	u8 mcast_key_id_map[4];
589 } __packed; /* ALL_TSC_RSC_API_S_VER_5 */
590 
591 /**
592  * struct iwl_wowlan_gtk_status_v3 - GTK status
593  * @key: GTK material
594  * @key_len: GTK length, if set to 0, the key is not available
595  * @key_flags: information about the key:
596  *	bits[0:1]:  key index assigned by the AP
597  *	bits[2:6]:  GTK index of the key in the internal DB
598  *	bit[7]:     Set iff this is the currently used GTK
599  * @reserved: padding
600  * @tkip_mic_key: TKIP RX MIC key
601  * @sc: RSC/TSC counters
602  */
603 struct iwl_wowlan_gtk_status_v3 {
604 	u8 key[WOWLAN_KEY_MAX_SIZE];
605 	u8 key_len;
606 	u8 key_flags;
607 	u8 reserved[2];
608 	u8 tkip_mic_key[IWL_MIC_KEY_SIZE];
609 	struct iwl_wowlan_all_rsc_tsc_v5 sc;
610 } __packed; /* WOWLAN_GTK_MATERIAL_VER_3 */
611 
612 #define IWL_WOWLAN_GTK_IDX_MASK		(BIT(0) | BIT(1))
613 
614 /**
615  * struct iwl_wowlan_igtk_status - IGTK status
616  * @key: IGTK material
617  * @ipn: the IGTK packet number (replay counter)
618  * @key_len: IGTK length, if set to 0, the key is not available
619  * @key_flags: information about the key:
620  *	bits[0]:    key index assigned by the AP (0: index 4, 1: index 5)
621  *	bits[1:5]:  IGTK index of the key in the internal DB
622  *	bit[6]:     Set iff this is the currently used IGTK
623  */
624 struct iwl_wowlan_igtk_status {
625 	u8 key[WOWLAN_KEY_MAX_SIZE];
626 	u8 ipn[6];
627 	u8 key_len;
628 	u8 key_flags;
629 } __packed; /* WOWLAN_IGTK_MATERIAL_VER_1 */
630 
631 /**
632  * struct iwl_wowlan_status_v6 - WoWLAN status
633  * @gtk: GTK data
634  * @replay_ctr: GTK rekey replay counter
635  * @pattern_number: number of the matched pattern
636  * @non_qos_seq_ctr: non-QoS sequence counter to use next
637  * @qos_seq_ctr: QoS sequence counters to use next
638  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
639  * @num_of_gtk_rekeys: number of GTK rekeys
640  * @transmitted_ndps: number of transmitted neighbor discovery packets
641  * @received_beacons: number of received beacons
642  * @wake_packet_length: wakeup packet length
643  * @wake_packet_bufsize: wakeup packet buffer size
644  * @wake_packet: wakeup packet
645  */
646 struct iwl_wowlan_status_v6 {
647 	struct iwl_wowlan_gtk_status_v1 gtk;
648 	__le64 replay_ctr;
649 	__le16 pattern_number;
650 	__le16 non_qos_seq_ctr;
651 	__le16 qos_seq_ctr[8];
652 	__le32 wakeup_reasons;
653 	__le32 num_of_gtk_rekeys;
654 	__le32 transmitted_ndps;
655 	__le32 received_beacons;
656 	__le32 wake_packet_length;
657 	__le32 wake_packet_bufsize;
658 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
659 } __packed; /* WOWLAN_STATUSES_API_S_VER_6 */
660 
661 /**
662  * struct iwl_wowlan_status_v7 - WoWLAN status
663  * @gtk: GTK data
664  * @igtk: IGTK data
665  * @replay_ctr: GTK rekey replay counter
666  * @pattern_number: number of the matched pattern
667  * @non_qos_seq_ctr: non-QoS sequence counter to use next
668  * @qos_seq_ctr: QoS sequence counters to use next
669  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
670  * @num_of_gtk_rekeys: number of GTK rekeys
671  * @transmitted_ndps: number of transmitted neighbor discovery packets
672  * @received_beacons: number of received beacons
673  * @wake_packet_length: wakeup packet length
674  * @wake_packet_bufsize: wakeup packet buffer size
675  * @wake_packet: wakeup packet
676  */
677 struct iwl_wowlan_status_v7 {
678 	struct iwl_wowlan_gtk_status_v2 gtk[WOWLAN_GTK_KEYS_NUM];
679 	struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
680 	__le64 replay_ctr;
681 	__le16 pattern_number;
682 	__le16 non_qos_seq_ctr;
683 	__le16 qos_seq_ctr[8];
684 	__le32 wakeup_reasons;
685 	__le32 num_of_gtk_rekeys;
686 	__le32 transmitted_ndps;
687 	__le32 received_beacons;
688 	__le32 wake_packet_length;
689 	__le32 wake_packet_bufsize;
690 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
691 } __packed; /* WOWLAN_STATUSES_API_S_VER_7 */
692 
693 /**
694  * struct iwl_wowlan_status_v9 - WoWLAN status (versions 9 and 10)
695  * @gtk: GTK data
696  * @igtk: IGTK data
697  * @replay_ctr: GTK rekey replay counter
698  * @pattern_number: number of the matched pattern
699  * @non_qos_seq_ctr: non-QoS sequence counter to use next.
700  *                   Reserved if the struct has version >= 10.
701  * @qos_seq_ctr: QoS sequence counters to use next
702  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
703  * @num_of_gtk_rekeys: number of GTK rekeys
704  * @transmitted_ndps: number of transmitted neighbor discovery packets
705  * @received_beacons: number of received beacons
706  * @wake_packet_length: wakeup packet length
707  * @wake_packet_bufsize: wakeup packet buffer size
708  * @tid_tear_down: bit mask of tids whose BA sessions were closed
709  *		   in suspend state
710  * @reserved: unused
711  * @wake_packet: wakeup packet
712  */
713 struct iwl_wowlan_status_v9 {
714 	struct iwl_wowlan_gtk_status_v2 gtk[WOWLAN_GTK_KEYS_NUM];
715 	struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
716 	__le64 replay_ctr;
717 	__le16 pattern_number;
718 	__le16 non_qos_seq_ctr;
719 	__le16 qos_seq_ctr[8];
720 	__le32 wakeup_reasons;
721 	__le32 num_of_gtk_rekeys;
722 	__le32 transmitted_ndps;
723 	__le32 received_beacons;
724 	__le32 wake_packet_length;
725 	__le32 wake_packet_bufsize;
726 	u8 tid_tear_down;
727 	u8 reserved[3];
728 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
729 } __packed; /* WOWLAN_STATUSES_RSP_API_S_VER_9 */
730 
731 /**
732  * struct iwl_wowlan_status_v12 - WoWLAN status
733  * @gtk: GTK data
734  * @igtk: IGTK data
735  * @replay_ctr: GTK rekey replay counter
736  * @pattern_number: number of the matched pattern
737  * @non_qos_seq_ctr: non-QoS sequence counter to use next.
738  *                   Reserved if the struct has version >= 10.
739  * @qos_seq_ctr: QoS sequence counters to use next
740  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
741  * @num_of_gtk_rekeys: number of GTK rekeys
742  * @transmitted_ndps: number of transmitted neighbor discovery packets
743  * @received_beacons: number of received beacons
744  * @wake_packet_length: wakeup packet length
745  * @wake_packet_bufsize: wakeup packet buffer size
746  * @tid_tear_down: bit mask of tids whose BA sessions were closed
747  *		   in suspend state
748  * @reserved: unused
749  * @wake_packet: wakeup packet
750  */
751 struct iwl_wowlan_status_v12 {
752 	struct iwl_wowlan_gtk_status_v3 gtk[WOWLAN_GTK_KEYS_NUM];
753 	struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
754 	__le64 replay_ctr;
755 	__le16 pattern_number;
756 	__le16 non_qos_seq_ctr;
757 	__le16 qos_seq_ctr[8];
758 	__le32 wakeup_reasons;
759 	__le32 num_of_gtk_rekeys;
760 	__le32 transmitted_ndps;
761 	__le32 received_beacons;
762 	__le32 wake_packet_length;
763 	__le32 wake_packet_bufsize;
764 	u8 tid_tear_down;
765 	u8 reserved[3];
766 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
767 } __packed; /* WOWLAN_STATUSES_RSP_API_S_VER_12 */
768 
769 /**
770  * struct iwl_wowlan_info_notif - WoWLAN information notification
771  * @gtk: GTK data
772  * @igtk: IGTK data
773  * @replay_ctr: GTK rekey replay counter
774  * @pattern_number: number of the matched patterns
775  * @reserved1: reserved
776  * @qos_seq_ctr: QoS sequence counters to use next
777  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
778  * @num_of_gtk_rekeys: number of GTK rekeys
779  * @transmitted_ndps: number of transmitted neighbor discovery packets
780  * @received_beacons: number of received beacons
781  * @wake_packet_length: wakeup packet length
782  * @wake_packet_bufsize: wakeup packet buffer size
783  * @tid_tear_down: bit mask of tids whose BA sessions were closed
784  *	in suspend state
785  * @station_id: station id
786  * @reserved2: reserved
787  */
788 struct iwl_wowlan_info_notif {
789 	struct iwl_wowlan_gtk_status_v3 gtk[WOWLAN_GTK_KEYS_NUM];
790 	struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
791 	__le64 replay_ctr;
792 	__le16 pattern_number;
793 	__le16 reserved1;
794 	__le16 qos_seq_ctr[8];
795 	__le32 wakeup_reasons;
796 	__le32 num_of_gtk_rekeys;
797 	__le32 transmitted_ndps;
798 	__le32 received_beacons;
799 	__le32 wake_packet_length;
800 	__le32 wake_packet_bufsize;
801 	u8 tid_tear_down;
802 	u8 station_id;
803 	u8 reserved2[2];
804 } __packed; /* WOWLAN_INFO_NTFY_API_S_VER_1 */
805 
806 /**
807  * struct iwl_wowlan_wake_pkt_notif - WoWLAN wake packet notification
808  * @wake_packet_length: wakeup packet length
809  * @station_id: station id
810  * @reserved: unused
811  * @wake_packet: wakeup packet
812  */
813 struct iwl_wowlan_wake_pkt_notif {
814 	__le32 wake_packet_length;
815 	u8 station_id;
816 	u8 reserved[3];
817 	u8 wake_packet[1];
818 } __packed; /* WOWLAN_WAKE_PKT_NTFY_API_S_VER_1 */
819 
820 /**
821  * struct iwl_mvm_d3_end_notif -  d3 end notification
822  * @flags: See &enum iwl_d0i3_flags
823  */
824 struct iwl_mvm_d3_end_notif {
825 	__le32 flags;
826 } __packed;
827 
828 /* TODO: NetDetect API */
829 
830 #endif /* __iwl_fw_api_d3_h__ */
831