xref: /linux/drivers/net/wireless/intel/iwlwifi/fw/api/d3.h (revision 4fd18fc38757217c746aa063ba9e4729814dc737)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2012-2014, 2018-2020 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  * WOWLAN_PATTERNS
164  */
165 #define IWL_WOWLAN_MIN_PATTERN_LEN	16
166 #define IWL_WOWLAN_MAX_PATTERN_LEN	128
167 
168 struct iwl_wowlan_pattern_v1 {
169 	u8 mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
170 	u8 pattern[IWL_WOWLAN_MAX_PATTERN_LEN];
171 	u8 mask_size;
172 	u8 pattern_size;
173 	__le16 reserved;
174 } __packed; /* WOWLAN_PATTERN_API_S_VER_1 */
175 
176 #define IWL_WOWLAN_MAX_PATTERNS	20
177 
178 /**
179  * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns
180  */
181 struct iwl_wowlan_patterns_cmd_v1 {
182 	/**
183 	 * @n_patterns: number of patterns
184 	 */
185 	__le32 n_patterns;
186 
187 	/**
188 	 * @patterns: the patterns, array length in @n_patterns
189 	 */
190 	struct iwl_wowlan_pattern_v1 patterns[];
191 } __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_1 */
192 
193 #define IPV4_ADDR_SIZE	4
194 #define IPV6_ADDR_SIZE	16
195 
196 enum iwl_wowlan_pattern_type {
197 	WOWLAN_PATTERN_TYPE_BITMASK,
198 	WOWLAN_PATTERN_TYPE_IPV4_TCP_SYN,
199 	WOWLAN_PATTERN_TYPE_IPV6_TCP_SYN,
200 	WOWLAN_PATTERN_TYPE_IPV4_TCP_SYN_WILDCARD,
201 	WOWLAN_PATTERN_TYPE_IPV6_TCP_SYN_WILDCARD,
202 }; /* WOWLAN_PATTERN_TYPE_API_E_VER_1 */
203 
204 /**
205  * struct iwl_wowlan_ipv4_tcp_syn - WoWLAN IPv4 TCP SYN pattern data
206  */
207 struct iwl_wowlan_ipv4_tcp_syn {
208 	/**
209 	 * @src_addr: source IP address to match
210 	 */
211 	u8 src_addr[IPV4_ADDR_SIZE];
212 
213 	/**
214 	 * @dst_addr: destination IP address to match
215 	 */
216 	u8 dst_addr[IPV4_ADDR_SIZE];
217 
218 	/**
219 	 * @src_port: source TCP port to match
220 	 */
221 	__le16 src_port;
222 
223 	/**
224 	 * @dst_port: destination TCP port to match
225 	 */
226 	__le16 dst_port;
227 } __packed; /* WOWLAN_IPV4_TCP_SYN_API_S_VER_1 */
228 
229 /**
230  * struct iwl_wowlan_ipv6_tcp_syn - WoWLAN Ipv6 TCP SYN pattern data
231  */
232 struct iwl_wowlan_ipv6_tcp_syn {
233 	/**
234 	 * @src_addr: source IP address to match
235 	 */
236 	u8 src_addr[IPV6_ADDR_SIZE];
237 
238 	/**
239 	 * @dst_addr: destination IP address to match
240 	 */
241 	u8 dst_addr[IPV6_ADDR_SIZE];
242 
243 	/**
244 	 * @src_port: source TCP port to match
245 	 */
246 	__le16 src_port;
247 
248 	/**
249 	 * @dst_port: destination TCP port to match
250 	 */
251 	__le16 dst_port;
252 } __packed; /* WOWLAN_IPV6_TCP_SYN_API_S_VER_1 */
253 
254 /**
255  * union iwl_wowlan_pattern_data - Data for the different pattern types
256  *
257  * If wildcard addresses/ports are to be used, the union can be left
258  * undefined.
259  */
260 union iwl_wowlan_pattern_data {
261 	/**
262 	 * @bitmask: bitmask pattern data
263 	 */
264 	struct iwl_wowlan_pattern_v1 bitmask;
265 
266 	/**
267 	 * @ipv4_tcp_syn: IPv4 TCP SYN pattern data
268 	 */
269 	struct iwl_wowlan_ipv4_tcp_syn ipv4_tcp_syn;
270 
271 	/**
272 	 * @ipv6_tcp_syn: IPv6 TCP SYN pattern data
273 	 */
274 	struct iwl_wowlan_ipv6_tcp_syn ipv6_tcp_syn;
275 }; /* WOWLAN_PATTERN_API_U_VER_1 */
276 
277 /**
278  * struct iwl_wowlan_pattern_v2 - Pattern entry for the WoWLAN wakeup patterns
279  */
280 struct iwl_wowlan_pattern_v2 {
281 	/**
282 	 * @pattern_type: defines the struct type to be used in the union
283 	 */
284 	u8 pattern_type;
285 
286 	/**
287 	 * @reserved: reserved for alignment
288 	 */
289 	u8 reserved[3];
290 
291 	/**
292 	 * @u: the union containing the match data, or undefined for
293 	 *     wildcard matches
294 	 */
295 	union iwl_wowlan_pattern_data u;
296 } __packed; /* WOWLAN_PATTERN_API_S_VER_2 */
297 
298 /**
299  * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns command
300  */
301 struct iwl_wowlan_patterns_cmd {
302 	/**
303 	 * @n_patterns: number of patterns
304 	 */
305 	__le32 n_patterns;
306 
307 	/**
308 	 * @patterns: the patterns, array length in @n_patterns
309 	 */
310 	struct iwl_wowlan_pattern_v2 patterns[];
311 } __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_2 */
312 
313 enum iwl_wowlan_wakeup_filters {
314 	IWL_WOWLAN_WAKEUP_MAGIC_PACKET			= BIT(0),
315 	IWL_WOWLAN_WAKEUP_PATTERN_MATCH			= BIT(1),
316 	IWL_WOWLAN_WAKEUP_BEACON_MISS			= BIT(2),
317 	IWL_WOWLAN_WAKEUP_LINK_CHANGE			= BIT(3),
318 	IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL		= BIT(4),
319 	IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ			= BIT(5),
320 	IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE		= BIT(6),
321 	IWL_WOWLAN_WAKEUP_ENABLE_NET_DETECT		= BIT(7),
322 	IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT		= BIT(8),
323 	IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS		= BIT(9),
324 	IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE	= BIT(10),
325 	IWL_WOWLAN_WAKEUP_REMOTE_TCP_EXTERNAL		= BIT(11),
326 	IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET		= BIT(12),
327 	IWL_WOWLAN_WAKEUP_IOAC_MAGIC_PACKET		= BIT(13),
328 	IWL_WOWLAN_WAKEUP_HOST_TIMER			= BIT(14),
329 	IWL_WOWLAN_WAKEUP_RX_FRAME			= BIT(15),
330 	IWL_WOWLAN_WAKEUP_BCN_FILTERING			= BIT(16),
331 }; /* WOWLAN_WAKEUP_FILTER_API_E_VER_4 */
332 
333 enum iwl_wowlan_flags {
334 	IS_11W_ASSOC		= BIT(0),
335 	ENABLE_L3_FILTERING	= BIT(1),
336 	ENABLE_NBNS_FILTERING	= BIT(2),
337 	ENABLE_DHCP_FILTERING	= BIT(3),
338 	ENABLE_STORE_BEACON	= BIT(4),
339 };
340 
341 /**
342  * struct iwl_wowlan_config_cmd - WoWLAN configuration
343  * @wakeup_filter: filter from &enum iwl_wowlan_wakeup_filters
344  * @non_qos_seq: non-QoS sequence counter to use next
345  * @qos_seq: QoS sequence counters to use next
346  * @wowlan_ba_teardown_tids: bitmap of BA sessions to tear down
347  * @is_11n_connection: indicates HT connection
348  * @offloading_tid: TID reserved for firmware use
349  * @flags: extra flags, see &enum iwl_wowlan_flags
350  * @sta_id: station ID for wowlan.
351  * @reserved: reserved
352  */
353 struct iwl_wowlan_config_cmd {
354 	__le32 wakeup_filter;
355 	__le16 non_qos_seq;
356 	__le16 qos_seq[8];
357 	u8 wowlan_ba_teardown_tids;
358 	u8 is_11n_connection;
359 	u8 offloading_tid;
360 	u8 flags;
361 	u8 sta_id;
362 	u8 reserved;
363 } __packed; /* WOWLAN_CONFIG_API_S_VER_5 */
364 
365 /*
366  * WOWLAN_TSC_RSC_PARAMS
367  */
368 #define IWL_NUM_RSC	16
369 
370 struct tkip_sc {
371 	__le16 iv16;
372 	__le16 pad;
373 	__le32 iv32;
374 } __packed; /* TKIP_SC_API_U_VER_1 */
375 
376 struct iwl_tkip_rsc_tsc {
377 	struct tkip_sc unicast_rsc[IWL_NUM_RSC];
378 	struct tkip_sc multicast_rsc[IWL_NUM_RSC];
379 	struct tkip_sc tsc;
380 } __packed; /* TKIP_TSC_RSC_API_S_VER_1 */
381 
382 struct aes_sc {
383 	__le64 pn;
384 } __packed; /* TKIP_AES_SC_API_U_VER_1 */
385 
386 struct iwl_aes_rsc_tsc {
387 	struct aes_sc unicast_rsc[IWL_NUM_RSC];
388 	struct aes_sc multicast_rsc[IWL_NUM_RSC];
389 	struct aes_sc tsc;
390 } __packed; /* AES_TSC_RSC_API_S_VER_1 */
391 
392 union iwl_all_tsc_rsc {
393 	struct iwl_tkip_rsc_tsc tkip;
394 	struct iwl_aes_rsc_tsc aes;
395 }; /* ALL_TSC_RSC_API_S_VER_2 */
396 
397 struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 {
398 	union iwl_all_tsc_rsc all_tsc_rsc;
399 } __packed; /* ALL_TSC_RSC_API_S_VER_2 */
400 
401 struct iwl_wowlan_rsc_tsc_params_cmd {
402 	struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 params;
403 	__le32 sta_id;
404 } __packed; /* ALL_TSC_RSC_API_S_VER_4 */
405 
406 #define IWL_MIC_KEY_SIZE	8
407 struct iwl_mic_keys {
408 	u8 tx[IWL_MIC_KEY_SIZE];
409 	u8 rx_unicast[IWL_MIC_KEY_SIZE];
410 	u8 rx_mcast[IWL_MIC_KEY_SIZE];
411 } __packed; /* MIC_KEYS_API_S_VER_1 */
412 
413 #define IWL_P1K_SIZE		5
414 struct iwl_p1k_cache {
415 	__le16 p1k[IWL_P1K_SIZE];
416 } __packed;
417 
418 #define IWL_NUM_RX_P1K_CACHE	2
419 
420 struct iwl_wowlan_tkip_params_cmd_ver_1 {
421 	struct iwl_mic_keys mic_keys;
422 	struct iwl_p1k_cache tx;
423 	struct iwl_p1k_cache rx_uni[IWL_NUM_RX_P1K_CACHE];
424 	struct iwl_p1k_cache rx_multi[IWL_NUM_RX_P1K_CACHE];
425 } __packed; /* WOWLAN_TKIP_SETTING_API_S_VER_1 */
426 
427 struct iwl_wowlan_tkip_params_cmd {
428 	struct iwl_mic_keys mic_keys;
429 	struct iwl_p1k_cache tx;
430 	struct iwl_p1k_cache rx_uni[IWL_NUM_RX_P1K_CACHE];
431 	struct iwl_p1k_cache rx_multi[IWL_NUM_RX_P1K_CACHE];
432 	u8     reversed[2];
433 	__le32 sta_id;
434 } __packed; /* WOWLAN_TKIP_SETTING_API_S_VER_2 */
435 
436 #define IWL_KCK_MAX_SIZE	32
437 #define IWL_KEK_MAX_SIZE	32
438 
439 struct iwl_wowlan_kek_kck_material_cmd_v2 {
440 	u8	kck[IWL_KCK_MAX_SIZE];
441 	u8	kek[IWL_KEK_MAX_SIZE];
442 	__le16	kck_len;
443 	__le16	kek_len;
444 	__le64	replay_ctr;
445 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_2 */
446 
447 struct iwl_wowlan_kek_kck_material_cmd_v3 {
448 	u8	kck[IWL_KCK_MAX_SIZE];
449 	u8	kek[IWL_KEK_MAX_SIZE];
450 	__le16	kck_len;
451 	__le16	kek_len;
452 	__le64	replay_ctr;
453 	__le32  akm;
454 	__le32  gtk_cipher;
455 	__le32  igtk_cipher;
456 	__le32  bigtk_cipher;
457 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_3 */
458 
459 #define RF_KILL_INDICATOR_FOR_WOWLAN	0x87
460 
461 enum iwl_wowlan_rekey_status {
462 	IWL_WOWLAN_REKEY_POST_REKEY = 0,
463 	IWL_WOWLAN_REKEY_WHILE_REKEY = 1,
464 }; /* WOWLAN_REKEY_STATUS_API_E_VER_1 */
465 
466 enum iwl_wowlan_wakeup_reason {
467 	IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS			= 0,
468 	IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET			= BIT(0),
469 	IWL_WOWLAN_WAKEUP_BY_PATTERN				= BIT(1),
470 	IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON	= BIT(2),
471 	IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH		= BIT(3),
472 	IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE			= BIT(4),
473 	IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED			= BIT(5),
474 	IWL_WOWLAN_WAKEUP_BY_UCODE_ERROR			= BIT(6),
475 	IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST			= BIT(7),
476 	IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE			= BIT(8),
477 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS			= BIT(9),
478 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE		= BIT(10),
479 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_TCP_EXTERNAL		= BIT(11),
480 	IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET		= BIT(12),
481 	IWL_WOWLAN_WAKEUP_BY_IOAC_MAGIC_PACKET			= BIT(13),
482 	IWL_WOWLAN_WAKEUP_BY_D3_WAKEUP_HOST_TIMER		= BIT(14),
483 	IWL_WOWLAN_WAKEUP_BY_RXFRAME_FILTERED_IN		= BIT(15),
484 	IWL_WOWLAN_WAKEUP_BY_BEACON_FILTERED_IN			= BIT(16),
485 	IWL_WAKEUP_BY_11W_UNPROTECTED_DEAUTH_OR_DISASSOC	= BIT(17),
486 	IWL_WAKEUP_BY_PATTERN_IPV4_TCP_SYN			= BIT(18),
487 	IWL_WAKEUP_BY_PATTERN_IPV4_TCP_SYN_WILDCARD		= BIT(19),
488 	IWL_WAKEUP_BY_PATTERN_IPV6_TCP_SYN			= BIT(20),
489 	IWL_WAKEUP_BY_PATTERN_IPV6_TCP_SYN_WILDCARD		= BIT(21),
490 }; /* WOWLAN_WAKE_UP_REASON_API_E_VER_2 */
491 
492 struct iwl_wowlan_gtk_status_v1 {
493 	u8 key_index;
494 	u8 reserved[3];
495 	u8 decrypt_key[16];
496 	u8 tkip_mic_key[8];
497 	struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 rsc;
498 } __packed; /* WOWLAN_GTK_MATERIAL_VER_1 */
499 
500 #define WOWLAN_KEY_MAX_SIZE	32
501 #define WOWLAN_GTK_KEYS_NUM     2
502 #define WOWLAN_IGTK_KEYS_NUM	2
503 
504 /**
505  * struct iwl_wowlan_gtk_status - GTK status
506  * @key: GTK material
507  * @key_len: GTK legth, if set to 0, the key is not available
508  * @key_flags: information about the key:
509  *	bits[0:1]:  key index assigned by the AP
510  *	bits[2:6]:  GTK index of the key in the internal DB
511  *	bit[7]:     Set iff this is the currently used GTK
512  * @reserved: padding
513  * @tkip_mic_key: TKIP RX MIC key
514  * @rsc: TSC RSC counters
515  */
516 struct iwl_wowlan_gtk_status {
517 	u8 key[WOWLAN_KEY_MAX_SIZE];
518 	u8 key_len;
519 	u8 key_flags;
520 	u8 reserved[2];
521 	u8 tkip_mic_key[8];
522 	struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 rsc;
523 } __packed; /* WOWLAN_GTK_MATERIAL_VER_2 */
524 
525 #define IWL_WOWLAN_GTK_IDX_MASK		(BIT(0) | BIT(1))
526 
527 /**
528  * struct iwl_wowlan_igtk_status - IGTK status
529  * @key: IGTK material
530  * @ipn: the IGTK packet number (replay counter)
531  * @key_len: IGTK length, if set to 0, the key is not available
532  * @key_flags: information about the key:
533  *	bits[0]:    key index assigned by the AP (0: index 4, 1: index 5)
534  *	bits[1:5]:  IGTK index of the key in the internal DB
535  *	bit[6]:     Set iff this is the currently used IGTK
536  */
537 struct iwl_wowlan_igtk_status {
538 	u8 key[WOWLAN_KEY_MAX_SIZE];
539 	u8 ipn[6];
540 	u8 key_len;
541 	u8 key_flags;
542 } __packed; /* WOWLAN_IGTK_MATERIAL_VER_1 */
543 
544 /**
545  * struct iwl_wowlan_status_v6 - WoWLAN status
546  * @gtk: GTK data
547  * @replay_ctr: GTK rekey replay counter
548  * @pattern_number: number of the matched pattern
549  * @non_qos_seq_ctr: non-QoS sequence counter to use next
550  * @qos_seq_ctr: QoS sequence counters to use next
551  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
552  * @num_of_gtk_rekeys: number of GTK rekeys
553  * @transmitted_ndps: number of transmitted neighbor discovery packets
554  * @received_beacons: number of received beacons
555  * @wake_packet_length: wakeup packet length
556  * @wake_packet_bufsize: wakeup packet buffer size
557  * @wake_packet: wakeup packet
558  */
559 struct iwl_wowlan_status_v6 {
560 	struct iwl_wowlan_gtk_status_v1 gtk;
561 	__le64 replay_ctr;
562 	__le16 pattern_number;
563 	__le16 non_qos_seq_ctr;
564 	__le16 qos_seq_ctr[8];
565 	__le32 wakeup_reasons;
566 	__le32 num_of_gtk_rekeys;
567 	__le32 transmitted_ndps;
568 	__le32 received_beacons;
569 	__le32 wake_packet_length;
570 	__le32 wake_packet_bufsize;
571 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
572 } __packed; /* WOWLAN_STATUSES_API_S_VER_6 */
573 
574 /**
575  * struct iwl_wowlan_status - WoWLAN status
576  * @gtk: GTK data
577  * @igtk: IGTK data
578  * @replay_ctr: GTK rekey replay counter
579  * @pattern_number: number of the matched pattern
580  * @non_qos_seq_ctr: non-QoS sequence counter to use next
581  * @qos_seq_ctr: QoS sequence counters to use next
582  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
583  * @num_of_gtk_rekeys: number of GTK rekeys
584  * @transmitted_ndps: number of transmitted neighbor discovery packets
585  * @received_beacons: number of received beacons
586  * @wake_packet_length: wakeup packet length
587  * @wake_packet_bufsize: wakeup packet buffer size
588  * @wake_packet: wakeup packet
589  */
590 struct iwl_wowlan_status_v7 {
591 	struct iwl_wowlan_gtk_status gtk[WOWLAN_GTK_KEYS_NUM];
592 	struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
593 	__le64 replay_ctr;
594 	__le16 pattern_number;
595 	__le16 non_qos_seq_ctr;
596 	__le16 qos_seq_ctr[8];
597 	__le32 wakeup_reasons;
598 	__le32 num_of_gtk_rekeys;
599 	__le32 transmitted_ndps;
600 	__le32 received_beacons;
601 	__le32 wake_packet_length;
602 	__le32 wake_packet_bufsize;
603 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
604 } __packed; /* WOWLAN_STATUSES_API_S_VER_7 */
605 
606 /**
607  * struct iwl_wowlan_status_v9 - WoWLAN status (version 9)
608  * @gtk: GTK data
609  * @igtk: IGTK data
610  * @replay_ctr: GTK rekey replay counter
611  * @pattern_number: number of the matched pattern
612  * @non_qos_seq_ctr: non-QoS sequence counter to use next
613  * @qos_seq_ctr: QoS sequence counters to use next
614  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
615  * @num_of_gtk_rekeys: number of GTK rekeys
616  * @transmitted_ndps: number of transmitted neighbor discovery packets
617  * @received_beacons: number of received beacons
618  * @wake_packet_length: wakeup packet length
619  * @wake_packet_bufsize: wakeup packet buffer size
620  * @tid_tear_down: bit mask of tids whose BA sessions were closed
621  *		   in suspend state
622  * @reserved: unused
623  * @wake_packet: wakeup packet
624  */
625 struct iwl_wowlan_status_v9 {
626 	struct iwl_wowlan_gtk_status gtk[WOWLAN_GTK_KEYS_NUM];
627 	struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
628 	__le64 replay_ctr;
629 	__le16 pattern_number;
630 	__le16 non_qos_seq_ctr;
631 	__le16 qos_seq_ctr[8];
632 	__le32 wakeup_reasons;
633 	__le32 num_of_gtk_rekeys;
634 	__le32 transmitted_ndps;
635 	__le32 received_beacons;
636 	__le32 wake_packet_length;
637 	__le32 wake_packet_bufsize;
638 	u8 tid_tear_down;
639 	u8 reserved[3];
640 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
641 } __packed; /* WOWLAN_STATUSES_API_S_VER_9 */
642 
643 /**
644  * struct iwl_wowlan_status - WoWLAN status
645  * @gtk: GTK data
646  * @igtk: IGTK data
647  * @bigtk: BIGTK data
648  * @replay_ctr: GTK rekey replay counter
649  * @pattern_number: number of the matched pattern
650  * @non_qos_seq_ctr: non-QoS sequence counter to use next
651  * @qos_seq_ctr: QoS sequence counters to use next
652  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
653  * @num_of_gtk_rekeys: number of GTK rekeys
654  * @tid_tear_down: bitmap of TIDs torn down
655  * @reserved: reserved
656  * @received_beacons: number of received beacons
657  * @wake_packet_length: wakeup packet length
658  * @wake_packet_bufsize: wakeup packet buffer size
659  * @tid_tear_down: bit mask of tids whose BA sessions were closed
660  *		   in suspend state
661  * @wake_packet: wakeup packet
662  */
663 struct iwl_wowlan_status {
664 	struct iwl_wowlan_gtk_status gtk[1];
665 	struct iwl_wowlan_igtk_status igtk[1];
666 	struct iwl_wowlan_igtk_status bigtk[WOWLAN_IGTK_KEYS_NUM];
667 	__le64 replay_ctr;
668 	__le16 pattern_number;
669 	__le16 non_qos_seq_ctr;
670 	__le16 qos_seq_ctr[8];
671 	__le32 wakeup_reasons;
672 	__le32 num_of_gtk_rekeys;
673 	u8 tid_tear_down;
674 	u8 reserved[3];
675 	__le32 received_beacons;
676 	__le32 wake_packet_length;
677 	__le32 wake_packet_bufsize;
678 	u8 wake_packet[]; /* can be truncated from _length to _bufsize */
679 } __packed; /* WOWLAN_STATUSES_API_S_VER_11 */
680 
681 static inline u8 iwlmvm_wowlan_gtk_idx(struct iwl_wowlan_gtk_status *gtk)
682 {
683 	return gtk->key_flags & IWL_WOWLAN_GTK_IDX_MASK;
684 }
685 
686 #define IWL_WOWLAN_TCP_MAX_PACKET_LEN		64
687 #define IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN	128
688 #define IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS	2048
689 
690 struct iwl_tcp_packet_info {
691 	__le16 tcp_pseudo_header_checksum;
692 	__le16 tcp_payload_length;
693 } __packed; /* TCP_PACKET_INFO_API_S_VER_2 */
694 
695 struct iwl_tcp_packet {
696 	struct iwl_tcp_packet_info info;
697 	u8 rx_mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
698 	u8 data[IWL_WOWLAN_TCP_MAX_PACKET_LEN];
699 } __packed; /* TCP_PROTOCOL_PACKET_API_S_VER_1 */
700 
701 struct iwl_remote_wake_packet {
702 	struct iwl_tcp_packet_info info;
703 	u8 rx_mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
704 	u8 data[IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN];
705 } __packed; /* TCP_PROTOCOL_PACKET_API_S_VER_1 */
706 
707 struct iwl_wowlan_remote_wake_config {
708 	__le32 connection_max_time; /* unused */
709 	/* TCP_PROTOCOL_CONFIG_API_S_VER_1 */
710 	u8 max_syn_retries;
711 	u8 max_data_retries;
712 	u8 tcp_syn_ack_timeout;
713 	u8 tcp_ack_timeout;
714 
715 	struct iwl_tcp_packet syn_tx;
716 	struct iwl_tcp_packet synack_rx;
717 	struct iwl_tcp_packet keepalive_ack_rx;
718 	struct iwl_tcp_packet fin_tx;
719 
720 	struct iwl_remote_wake_packet keepalive_tx;
721 	struct iwl_remote_wake_packet wake_rx;
722 
723 	/* REMOTE_WAKE_OFFSET_INFO_API_S_VER_1 */
724 	u8 sequence_number_offset;
725 	u8 sequence_number_length;
726 	u8 token_offset;
727 	u8 token_length;
728 	/* REMOTE_WAKE_PROTOCOL_PARAMS_API_S_VER_1 */
729 	__le32 initial_sequence_number;
730 	__le16 keepalive_interval;
731 	__le16 num_tokens;
732 	u8 tokens[IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS];
733 } __packed; /* REMOTE_WAKE_CONFIG_API_S_VER_2 */
734 
735 /* TODO: NetDetect API */
736 
737 #endif /* __iwl_fw_api_d3_h__ */
738