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