iwlwifi: mvm: d3: parse wowlan status version 11
[linux-2.6-microblaze.git] / drivers / net / wireless / intel / iwlwifi / fw / api / d3.h
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  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
11  * Copyright(c) 2018 - 2020 Intel Corporation
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of version 2 of the GNU General Public License as
15  * published by the Free Software Foundation.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * The full GNU General Public License is included in this distribution
23  * in the file called COPYING.
24  *
25  * Contact Information:
26  *  Intel Linux Wireless <linuxwifi@intel.com>
27  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28  *
29  * BSD LICENSE
30  *
31  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
32  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
33  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
34  * Copyright(c) 2018 - 2020 Intel Corporation
35  * All rights reserved.
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  *
41  *  * Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  *  * Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in
45  *    the documentation and/or other materials provided with the
46  *    distribution.
47  *  * Neither the name Intel Corporation nor the names of its
48  *    contributors may be used to endorse or promote products derived
49  *    from this software without specific prior written permission.
50  *
51  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62  *****************************************************************************/
63
64 #ifndef __iwl_fw_api_d3_h__
65 #define __iwl_fw_api_d3_h__
66
67 /**
68  * enum iwl_d0i3_flags - d0i3 flags
69  * @IWL_D0I3_RESET_REQUIRE: FW require reset upon resume
70  */
71 enum iwl_d0i3_flags {
72         IWL_D0I3_RESET_REQUIRE = BIT(0),
73 };
74
75 /**
76  * enum iwl_d3_wakeup_flags - D3 manager wakeup flags
77  * @IWL_WAKEUP_D3_CONFIG_FW_ERROR: wake up on firmware sysassert
78  */
79 enum iwl_d3_wakeup_flags {
80         IWL_WAKEUP_D3_CONFIG_FW_ERROR = BIT(0),
81 }; /* D3_MANAGER_WAKEUP_CONFIG_API_E_VER_3 */
82
83 /**
84  * struct iwl_d3_manager_config - D3 manager configuration command
85  * @min_sleep_time: minimum sleep time (in usec)
86  * @wakeup_flags: wakeup flags, see &enum iwl_d3_wakeup_flags
87  * @wakeup_host_timer: force wakeup after this many seconds
88  *
89  * The structure is used for the D3_CONFIG_CMD command.
90  */
91 struct iwl_d3_manager_config {
92         __le32 min_sleep_time;
93         __le32 wakeup_flags;
94         __le32 wakeup_host_timer;
95 } __packed; /* D3_MANAGER_CONFIG_CMD_S_VER_4 */
96
97
98 /* TODO: OFFLOADS_QUERY_API_S_VER_1 */
99
100 /**
101  * enum iwl_d3_proto_offloads - enabled protocol offloads
102  * @IWL_D3_PROTO_OFFLOAD_ARP: ARP data is enabled
103  * @IWL_D3_PROTO_OFFLOAD_NS: NS (Neighbor Solicitation) is enabled
104  * @IWL_D3_PROTO_IPV4_VALID: IPv4 data is valid
105  * @IWL_D3_PROTO_IPV6_VALID: IPv6 data is valid
106  */
107 enum iwl_proto_offloads {
108         IWL_D3_PROTO_OFFLOAD_ARP = BIT(0),
109         IWL_D3_PROTO_OFFLOAD_NS = BIT(1),
110         IWL_D3_PROTO_IPV4_VALID = BIT(2),
111         IWL_D3_PROTO_IPV6_VALID = BIT(3),
112 };
113
114 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1     2
115 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2     6
116 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L    12
117 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S    4
118 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX    12
119
120 #define IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L     4
121 #define IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S     2
122
123 /**
124  * struct iwl_proto_offload_cmd_common - ARP/NS offload common part
125  * @enabled: enable flags
126  * @remote_ipv4_addr: remote address to answer to (or zero if all)
127  * @host_ipv4_addr: our IPv4 address to respond to queries for
128  * @arp_mac_addr: our MAC address for ARP responses
129  * @reserved: unused
130  */
131 struct iwl_proto_offload_cmd_common {
132         __le32 enabled;
133         __be32 remote_ipv4_addr;
134         __be32 host_ipv4_addr;
135         u8 arp_mac_addr[ETH_ALEN];
136         __le16 reserved;
137 } __packed;
138
139 /**
140  * struct iwl_proto_offload_cmd_v1 - ARP/NS offload configuration
141  * @common: common/IPv4 configuration
142  * @remote_ipv6_addr: remote address to answer to (or zero if all)
143  * @solicited_node_ipv6_addr: broken -- solicited node address exists
144  *      for each target address
145  * @target_ipv6_addr: our target addresses
146  * @ndp_mac_addr: neighbor solicitation response MAC address
147  * @reserved2: reserved
148  */
149 struct iwl_proto_offload_cmd_v1 {
150         struct iwl_proto_offload_cmd_common common;
151         u8 remote_ipv6_addr[16];
152         u8 solicited_node_ipv6_addr[16];
153         u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1][16];
154         u8 ndp_mac_addr[ETH_ALEN];
155         __le16 reserved2;
156 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_1 */
157
158 /**
159  * struct iwl_proto_offload_cmd_v2 - ARP/NS offload configuration
160  * @common: common/IPv4 configuration
161  * @remote_ipv6_addr: remote address to answer to (or zero if all)
162  * @solicited_node_ipv6_addr: broken -- solicited node address exists
163  *      for each target address
164  * @target_ipv6_addr: our target addresses
165  * @ndp_mac_addr: neighbor solicitation response MAC address
166  * @num_valid_ipv6_addrs: number of valid IPv6 addresses
167  * @reserved2: reserved
168  */
169 struct iwl_proto_offload_cmd_v2 {
170         struct iwl_proto_offload_cmd_common common;
171         u8 remote_ipv6_addr[16];
172         u8 solicited_node_ipv6_addr[16];
173         u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2][16];
174         u8 ndp_mac_addr[ETH_ALEN];
175         u8 num_valid_ipv6_addrs;
176         u8 reserved2[3];
177 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_2 */
178
179 struct iwl_ns_config {
180         struct in6_addr source_ipv6_addr;
181         struct in6_addr dest_ipv6_addr;
182         u8 target_mac_addr[ETH_ALEN];
183         __le16 reserved;
184 } __packed; /* NS_OFFLOAD_CONFIG */
185
186 struct iwl_targ_addr {
187         struct in6_addr addr;
188         __le32 config_num;
189 } __packed; /* TARGET_IPV6_ADDRESS */
190
191 /**
192  * struct iwl_proto_offload_cmd_v3_small - ARP/NS offload configuration
193  * @common: common/IPv4 configuration
194  * @num_valid_ipv6_addrs: number of valid IPv6 addresses
195  * @targ_addrs: target IPv6 addresses
196  * @ns_config: NS offload configurations
197  */
198 struct iwl_proto_offload_cmd_v3_small {
199         struct iwl_proto_offload_cmd_common common;
200         __le32 num_valid_ipv6_addrs;
201         struct iwl_targ_addr targ_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S];
202         struct iwl_ns_config ns_config[IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S];
203 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_3 */
204
205 /**
206  * struct iwl_proto_offload_cmd_v3_large - ARP/NS offload configuration
207  * @common: common/IPv4 configuration
208  * @num_valid_ipv6_addrs: number of valid IPv6 addresses
209  * @targ_addrs: target IPv6 addresses
210  * @ns_config: NS offload configurations
211  */
212 struct iwl_proto_offload_cmd_v3_large {
213         struct iwl_proto_offload_cmd_common common;
214         __le32 num_valid_ipv6_addrs;
215         struct iwl_targ_addr targ_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L];
216         struct iwl_ns_config ns_config[IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L];
217 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_3 */
218
219 /*
220  * WOWLAN_PATTERNS
221  */
222 #define IWL_WOWLAN_MIN_PATTERN_LEN      16
223 #define IWL_WOWLAN_MAX_PATTERN_LEN      128
224
225 struct iwl_wowlan_pattern_v1 {
226         u8 mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
227         u8 pattern[IWL_WOWLAN_MAX_PATTERN_LEN];
228         u8 mask_size;
229         u8 pattern_size;
230         __le16 reserved;
231 } __packed; /* WOWLAN_PATTERN_API_S_VER_1 */
232
233 #define IWL_WOWLAN_MAX_PATTERNS 20
234
235 /**
236  * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns
237  */
238 struct iwl_wowlan_patterns_cmd_v1 {
239         /**
240          * @n_patterns: number of patterns
241          */
242         __le32 n_patterns;
243
244         /**
245          * @patterns: the patterns, array length in @n_patterns
246          */
247         struct iwl_wowlan_pattern_v1 patterns[];
248 } __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_1 */
249
250 #define IPV4_ADDR_SIZE  4
251 #define IPV6_ADDR_SIZE  16
252
253 enum iwl_wowlan_pattern_type {
254         WOWLAN_PATTERN_TYPE_BITMASK,
255         WOWLAN_PATTERN_TYPE_IPV4_TCP_SYN,
256         WOWLAN_PATTERN_TYPE_IPV6_TCP_SYN,
257         WOWLAN_PATTERN_TYPE_IPV4_TCP_SYN_WILDCARD,
258         WOWLAN_PATTERN_TYPE_IPV6_TCP_SYN_WILDCARD,
259 }; /* WOWLAN_PATTERN_TYPE_API_E_VER_1 */
260
261 /**
262  * struct iwl_wowlan_ipv4_tcp_syn - WoWLAN IPv4 TCP SYN pattern data
263  */
264 struct iwl_wowlan_ipv4_tcp_syn {
265         /**
266          * @src_addr: source IP address to match
267          */
268         u8 src_addr[IPV4_ADDR_SIZE];
269
270         /**
271          * @dst_addr: destination IP address to match
272          */
273         u8 dst_addr[IPV4_ADDR_SIZE];
274
275         /**
276          * @src_port: source TCP port to match
277          */
278         __le16 src_port;
279
280         /**
281          * @dst_port: destination TCP port to match
282          */
283         __le16 dst_port;
284 } __packed; /* WOWLAN_IPV4_TCP_SYN_API_S_VER_1 */
285
286 /**
287  * struct iwl_wowlan_ipv6_tcp_syn - WoWLAN Ipv6 TCP SYN pattern data
288  */
289 struct iwl_wowlan_ipv6_tcp_syn {
290         /**
291          * @src_addr: source IP address to match
292          */
293         u8 src_addr[IPV6_ADDR_SIZE];
294
295         /**
296          * @dst_addr: destination IP address to match
297          */
298         u8 dst_addr[IPV6_ADDR_SIZE];
299
300         /**
301          * @src_port: source TCP port to match
302          */
303         __le16 src_port;
304
305         /**
306          * @dst_port: destination TCP port to match
307          */
308         __le16 dst_port;
309 } __packed; /* WOWLAN_IPV6_TCP_SYN_API_S_VER_1 */
310
311 /**
312  * union iwl_wowlan_pattern_data - Data for the different pattern types
313  *
314  * If wildcard addresses/ports are to be used, the union can be left
315  * undefined.
316  */
317 union iwl_wowlan_pattern_data {
318         /**
319          * @bitmask: bitmask pattern data
320          */
321         struct iwl_wowlan_pattern_v1 bitmask;
322
323         /**
324          * @ipv4_tcp_syn: IPv4 TCP SYN pattern data
325          */
326         struct iwl_wowlan_ipv4_tcp_syn ipv4_tcp_syn;
327
328         /**
329          * @ipv6_tcp_syn: IPv6 TCP SYN pattern data
330          */
331         struct iwl_wowlan_ipv6_tcp_syn ipv6_tcp_syn;
332 }; /* WOWLAN_PATTERN_API_U_VER_1 */
333
334 /**
335  * struct iwl_wowlan_pattern_v2 - Pattern entry for the WoWLAN wakeup patterns
336  */
337 struct iwl_wowlan_pattern_v2 {
338         /**
339          * @pattern_type: defines the struct type to be used in the union
340          */
341         u8 pattern_type;
342
343         /**
344          * @reserved: reserved for alignment
345          */
346         u8 reserved[3];
347
348         /**
349          * @u: the union containing the match data, or undefined for
350          *     wildcard matches
351          */
352         union iwl_wowlan_pattern_data u;
353 } __packed; /* WOWLAN_PATTERN_API_S_VER_2 */
354
355 /**
356  * struct iwl_wowlan_patterns_cmd - WoWLAN wakeup patterns command
357  */
358 struct iwl_wowlan_patterns_cmd {
359         /**
360          * @n_patterns: number of patterns
361          */
362         __le32 n_patterns;
363
364         /**
365          * @patterns: the patterns, array length in @n_patterns
366          */
367         struct iwl_wowlan_pattern_v2 patterns[];
368 } __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_2 */
369
370 enum iwl_wowlan_wakeup_filters {
371         IWL_WOWLAN_WAKEUP_MAGIC_PACKET                  = BIT(0),
372         IWL_WOWLAN_WAKEUP_PATTERN_MATCH                 = BIT(1),
373         IWL_WOWLAN_WAKEUP_BEACON_MISS                   = BIT(2),
374         IWL_WOWLAN_WAKEUP_LINK_CHANGE                   = BIT(3),
375         IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL                = BIT(4),
376         IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ                 = BIT(5),
377         IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE                = BIT(6),
378         IWL_WOWLAN_WAKEUP_ENABLE_NET_DETECT             = BIT(7),
379         IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT              = BIT(8),
380         IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS              = BIT(9),
381         IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE        = BIT(10),
382         IWL_WOWLAN_WAKEUP_REMOTE_TCP_EXTERNAL           = BIT(11),
383         IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET          = BIT(12),
384         IWL_WOWLAN_WAKEUP_IOAC_MAGIC_PACKET             = BIT(13),
385         IWL_WOWLAN_WAKEUP_HOST_TIMER                    = BIT(14),
386         IWL_WOWLAN_WAKEUP_RX_FRAME                      = BIT(15),
387         IWL_WOWLAN_WAKEUP_BCN_FILTERING                 = BIT(16),
388 }; /* WOWLAN_WAKEUP_FILTER_API_E_VER_4 */
389
390 enum iwl_wowlan_flags {
391         IS_11W_ASSOC            = BIT(0),
392         ENABLE_L3_FILTERING     = BIT(1),
393         ENABLE_NBNS_FILTERING   = BIT(2),
394         ENABLE_DHCP_FILTERING   = BIT(3),
395         ENABLE_STORE_BEACON     = BIT(4),
396 };
397
398 /**
399  * struct iwl_wowlan_config_cmd - WoWLAN configuration
400  * @wakeup_filter: filter from &enum iwl_wowlan_wakeup_filters
401  * @non_qos_seq: non-QoS sequence counter to use next
402  * @qos_seq: QoS sequence counters to use next
403  * @wowlan_ba_teardown_tids: bitmap of BA sessions to tear down
404  * @is_11n_connection: indicates HT connection
405  * @offloading_tid: TID reserved for firmware use
406  * @flags: extra flags, see &enum iwl_wowlan_flags
407  * @sta_id: station ID for wowlan.
408  * @reserved: reserved
409  */
410 struct iwl_wowlan_config_cmd {
411         __le32 wakeup_filter;
412         __le16 non_qos_seq;
413         __le16 qos_seq[8];
414         u8 wowlan_ba_teardown_tids;
415         u8 is_11n_connection;
416         u8 offloading_tid;
417         u8 flags;
418         u8 sta_id;
419         u8 reserved;
420 } __packed; /* WOWLAN_CONFIG_API_S_VER_5 */
421
422 /*
423  * WOWLAN_TSC_RSC_PARAMS
424  */
425 #define IWL_NUM_RSC     16
426
427 struct tkip_sc {
428         __le16 iv16;
429         __le16 pad;
430         __le32 iv32;
431 } __packed; /* TKIP_SC_API_U_VER_1 */
432
433 struct iwl_tkip_rsc_tsc {
434         struct tkip_sc unicast_rsc[IWL_NUM_RSC];
435         struct tkip_sc multicast_rsc[IWL_NUM_RSC];
436         struct tkip_sc tsc;
437 } __packed; /* TKIP_TSC_RSC_API_S_VER_1 */
438
439 struct aes_sc {
440         __le64 pn;
441 } __packed; /* TKIP_AES_SC_API_U_VER_1 */
442
443 struct iwl_aes_rsc_tsc {
444         struct aes_sc unicast_rsc[IWL_NUM_RSC];
445         struct aes_sc multicast_rsc[IWL_NUM_RSC];
446         struct aes_sc tsc;
447 } __packed; /* AES_TSC_RSC_API_S_VER_1 */
448
449 union iwl_all_tsc_rsc {
450         struct iwl_tkip_rsc_tsc tkip;
451         struct iwl_aes_rsc_tsc aes;
452 }; /* ALL_TSC_RSC_API_S_VER_2 */
453
454 struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 {
455         union iwl_all_tsc_rsc all_tsc_rsc;
456 } __packed; /* ALL_TSC_RSC_API_S_VER_2 */
457
458 struct iwl_wowlan_rsc_tsc_params_cmd {
459         struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 params;
460         __le32 sta_id;
461 } __packed; /* ALL_TSC_RSC_API_S_VER_4 */
462
463 #define IWL_MIC_KEY_SIZE        8
464 struct iwl_mic_keys {
465         u8 tx[IWL_MIC_KEY_SIZE];
466         u8 rx_unicast[IWL_MIC_KEY_SIZE];
467         u8 rx_mcast[IWL_MIC_KEY_SIZE];
468 } __packed; /* MIC_KEYS_API_S_VER_1 */
469
470 #define IWL_P1K_SIZE            5
471 struct iwl_p1k_cache {
472         __le16 p1k[IWL_P1K_SIZE];
473 } __packed;
474
475 #define IWL_NUM_RX_P1K_CACHE    2
476
477 struct iwl_wowlan_tkip_params_cmd_ver_1 {
478         struct iwl_mic_keys mic_keys;
479         struct iwl_p1k_cache tx;
480         struct iwl_p1k_cache rx_uni[IWL_NUM_RX_P1K_CACHE];
481         struct iwl_p1k_cache rx_multi[IWL_NUM_RX_P1K_CACHE];
482 } __packed; /* WOWLAN_TKIP_SETTING_API_S_VER_1 */
483
484 struct iwl_wowlan_tkip_params_cmd {
485         struct iwl_mic_keys mic_keys;
486         struct iwl_p1k_cache tx;
487         struct iwl_p1k_cache rx_uni[IWL_NUM_RX_P1K_CACHE];
488         struct iwl_p1k_cache rx_multi[IWL_NUM_RX_P1K_CACHE];
489         u8     reversed[2];
490         __le32 sta_id;
491 } __packed; /* WOWLAN_TKIP_SETTING_API_S_VER_2 */
492
493 #define IWL_KCK_MAX_SIZE        32
494 #define IWL_KEK_MAX_SIZE        32
495
496 struct iwl_wowlan_kek_kck_material_cmd_v2 {
497         u8      kck[IWL_KCK_MAX_SIZE];
498         u8      kek[IWL_KEK_MAX_SIZE];
499         __le16  kck_len;
500         __le16  kek_len;
501         __le64  replay_ctr;
502 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_2 */
503
504 struct iwl_wowlan_kek_kck_material_cmd_v3 {
505         u8      kck[IWL_KCK_MAX_SIZE];
506         u8      kek[IWL_KEK_MAX_SIZE];
507         __le16  kck_len;
508         __le16  kek_len;
509         __le64  replay_ctr;
510         __le32  akm;
511         __le32  gtk_cipher;
512         __le32  igtk_cipher;
513         __le32  bigtk_cipher;
514 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_3 */
515
516 #define RF_KILL_INDICATOR_FOR_WOWLAN    0x87
517
518 enum iwl_wowlan_rekey_status {
519         IWL_WOWLAN_REKEY_POST_REKEY = 0,
520         IWL_WOWLAN_REKEY_WHILE_REKEY = 1,
521 }; /* WOWLAN_REKEY_STATUS_API_E_VER_1 */
522
523 enum iwl_wowlan_wakeup_reason {
524         IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS                       = 0,
525         IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET                       = BIT(0),
526         IWL_WOWLAN_WAKEUP_BY_PATTERN                            = BIT(1),
527         IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON     = BIT(2),
528         IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH            = BIT(3),
529         IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE                  = BIT(4),
530         IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED                  = BIT(5),
531         IWL_WOWLAN_WAKEUP_BY_UCODE_ERROR                        = BIT(6),
532         IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST                      = BIT(7),
533         IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE                 = BIT(8),
534         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS                 = BIT(9),
535         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE           = BIT(10),
536         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_TCP_EXTERNAL              = BIT(11),
537         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET             = BIT(12),
538         IWL_WOWLAN_WAKEUP_BY_IOAC_MAGIC_PACKET                  = BIT(13),
539         IWL_WOWLAN_WAKEUP_BY_D3_WAKEUP_HOST_TIMER               = BIT(14),
540         IWL_WOWLAN_WAKEUP_BY_RXFRAME_FILTERED_IN                = BIT(15),
541         IWL_WOWLAN_WAKEUP_BY_BEACON_FILTERED_IN                 = BIT(16),
542         IWL_WAKEUP_BY_11W_UNPROTECTED_DEAUTH_OR_DISASSOC        = BIT(17),
543         IWL_WAKEUP_BY_PATTERN_IPV4_TCP_SYN                      = BIT(18),
544         IWL_WAKEUP_BY_PATTERN_IPV4_TCP_SYN_WILDCARD             = BIT(19),
545         IWL_WAKEUP_BY_PATTERN_IPV6_TCP_SYN                      = BIT(20),
546         IWL_WAKEUP_BY_PATTERN_IPV6_TCP_SYN_WILDCARD             = BIT(21),
547 }; /* WOWLAN_WAKE_UP_REASON_API_E_VER_2 */
548
549 struct iwl_wowlan_gtk_status_v1 {
550         u8 key_index;
551         u8 reserved[3];
552         u8 decrypt_key[16];
553         u8 tkip_mic_key[8];
554         struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 rsc;
555 } __packed; /* WOWLAN_GTK_MATERIAL_VER_1 */
556
557 #define WOWLAN_KEY_MAX_SIZE     32
558 #define WOWLAN_GTK_KEYS_NUM     2
559 #define WOWLAN_IGTK_KEYS_NUM    2
560
561 /**
562  * struct iwl_wowlan_gtk_status - GTK status
563  * @key: GTK material
564  * @key_len: GTK legth, if set to 0, the key is not available
565  * @key_flags: information about the key:
566  *      bits[0:1]:  key index assigned by the AP
567  *      bits[2:6]:  GTK index of the key in the internal DB
568  *      bit[7]:     Set iff this is the currently used GTK
569  * @reserved: padding
570  * @tkip_mic_key: TKIP RX MIC key
571  * @rsc: TSC RSC counters
572  */
573 struct iwl_wowlan_gtk_status {
574         u8 key[WOWLAN_KEY_MAX_SIZE];
575         u8 key_len;
576         u8 key_flags;
577         u8 reserved[2];
578         u8 tkip_mic_key[8];
579         struct iwl_wowlan_rsc_tsc_params_cmd_ver_2 rsc;
580 } __packed; /* WOWLAN_GTK_MATERIAL_VER_2 */
581
582 #define IWL_WOWLAN_GTK_IDX_MASK         (BIT(0) | BIT(1))
583
584 /**
585  * struct iwl_wowlan_igtk_status - IGTK status
586  * @key: IGTK material
587  * @ipn: the IGTK packet number (replay counter)
588  * @key_len: IGTK length, if set to 0, the key is not available
589  * @key_flags: information about the key:
590  *      bits[0]:    key index assigned by the AP (0: index 4, 1: index 5)
591  *      bits[1:5]:  IGTK index of the key in the internal DB
592  *      bit[6]:     Set iff this is the currently used IGTK
593  */
594 struct iwl_wowlan_igtk_status {
595         u8 key[WOWLAN_KEY_MAX_SIZE];
596         u8 ipn[6];
597         u8 key_len;
598         u8 key_flags;
599 } __packed; /* WOWLAN_IGTK_MATERIAL_VER_1 */
600
601 /**
602  * struct iwl_wowlan_status_v6 - WoWLAN status
603  * @gtk: GTK data
604  * @replay_ctr: GTK rekey replay counter
605  * @pattern_number: number of the matched pattern
606  * @non_qos_seq_ctr: non-QoS sequence counter to use next
607  * @qos_seq_ctr: QoS sequence counters to use next
608  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
609  * @num_of_gtk_rekeys: number of GTK rekeys
610  * @transmitted_ndps: number of transmitted neighbor discovery packets
611  * @received_beacons: number of received beacons
612  * @wake_packet_length: wakeup packet length
613  * @wake_packet_bufsize: wakeup packet buffer size
614  * @wake_packet: wakeup packet
615  */
616 struct iwl_wowlan_status_v6 {
617         struct iwl_wowlan_gtk_status_v1 gtk;
618         __le64 replay_ctr;
619         __le16 pattern_number;
620         __le16 non_qos_seq_ctr;
621         __le16 qos_seq_ctr[8];
622         __le32 wakeup_reasons;
623         __le32 num_of_gtk_rekeys;
624         __le32 transmitted_ndps;
625         __le32 received_beacons;
626         __le32 wake_packet_length;
627         __le32 wake_packet_bufsize;
628         u8 wake_packet[]; /* can be truncated from _length to _bufsize */
629 } __packed; /* WOWLAN_STATUSES_API_S_VER_6 */
630
631 /**
632  * struct iwl_wowlan_status - WoWLAN status
633  * @gtk: GTK data
634  * @igtk: IGTK data
635  * @replay_ctr: GTK rekey replay counter
636  * @pattern_number: number of the matched pattern
637  * @non_qos_seq_ctr: non-QoS sequence counter to use next
638  * @qos_seq_ctr: QoS sequence counters to use next
639  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
640  * @num_of_gtk_rekeys: number of GTK rekeys
641  * @transmitted_ndps: number of transmitted neighbor discovery packets
642  * @received_beacons: number of received beacons
643  * @wake_packet_length: wakeup packet length
644  * @wake_packet_bufsize: wakeup packet buffer size
645  * @wake_packet: wakeup packet
646  */
647 struct iwl_wowlan_status_v7 {
648         struct iwl_wowlan_gtk_status gtk[WOWLAN_GTK_KEYS_NUM];
649         struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
650         __le64 replay_ctr;
651         __le16 pattern_number;
652         __le16 non_qos_seq_ctr;
653         __le16 qos_seq_ctr[8];
654         __le32 wakeup_reasons;
655         __le32 num_of_gtk_rekeys;
656         __le32 transmitted_ndps;
657         __le32 received_beacons;
658         __le32 wake_packet_length;
659         __le32 wake_packet_bufsize;
660         u8 wake_packet[]; /* can be truncated from _length to _bufsize */
661 } __packed; /* WOWLAN_STATUSES_API_S_VER_7 */
662
663 /**
664  * struct iwl_wowlan_status_v9 - WoWLAN status (version 9)
665  * @gtk: GTK data
666  * @igtk: IGTK data
667  * @replay_ctr: GTK rekey replay counter
668  * @pattern_number: number of the matched pattern
669  * @non_qos_seq_ctr: non-QoS sequence counter to use next
670  * @qos_seq_ctr: QoS sequence counters to use next
671  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
672  * @num_of_gtk_rekeys: number of GTK rekeys
673  * @transmitted_ndps: number of transmitted neighbor discovery packets
674  * @received_beacons: number of received beacons
675  * @wake_packet_length: wakeup packet length
676  * @wake_packet_bufsize: wakeup packet buffer size
677  * @tid_tear_down: bit mask of tids whose BA sessions were closed
678  *                 in suspend state
679  * @reserved: unused
680  * @wake_packet: wakeup packet
681  */
682 struct iwl_wowlan_status_v9 {
683         struct iwl_wowlan_gtk_status gtk[WOWLAN_GTK_KEYS_NUM];
684         struct iwl_wowlan_igtk_status igtk[WOWLAN_IGTK_KEYS_NUM];
685         __le64 replay_ctr;
686         __le16 pattern_number;
687         __le16 non_qos_seq_ctr;
688         __le16 qos_seq_ctr[8];
689         __le32 wakeup_reasons;
690         __le32 num_of_gtk_rekeys;
691         __le32 transmitted_ndps;
692         __le32 received_beacons;
693         __le32 wake_packet_length;
694         __le32 wake_packet_bufsize;
695         u8 tid_tear_down;
696         u8 reserved[3];
697         u8 wake_packet[]; /* can be truncated from _length to _bufsize */
698 } __packed; /* WOWLAN_STATUSES_API_S_VER_9 */
699
700 /**
701  * struct iwl_wowlan_status - WoWLAN status
702  * @gtk: GTK data
703  * @igtk: IGTK data
704  * @bigtk: BIGTK data
705  * @replay_ctr: GTK rekey replay counter
706  * @pattern_number: number of the matched pattern
707  * @non_qos_seq_ctr: non-QoS sequence counter to use next
708  * @qos_seq_ctr: QoS sequence counters to use next
709  * @wakeup_reasons: wakeup reasons, see &enum iwl_wowlan_wakeup_reason
710  * @num_of_gtk_rekeys: number of GTK rekeys
711  * @tid_tear_down: bitmap of TIDs torn down
712  * @reserved: reserved
713  * @received_beacons: number of received beacons
714  * @wake_packet_length: wakeup packet length
715  * @wake_packet_bufsize: wakeup packet buffer size
716  * @tid_tear_down: bit mask of tids whose BA sessions were closed
717  *                 in suspend state
718  * @wake_packet: wakeup packet
719  */
720 struct iwl_wowlan_status {
721         struct iwl_wowlan_gtk_status gtk[1];
722         struct iwl_wowlan_igtk_status igtk[1];
723         struct iwl_wowlan_igtk_status bigtk[WOWLAN_IGTK_KEYS_NUM];
724         __le64 replay_ctr;
725         __le16 pattern_number;
726         __le16 non_qos_seq_ctr;
727         __le16 qos_seq_ctr[8];
728         __le32 wakeup_reasons;
729         __le32 num_of_gtk_rekeys;
730         u8 tid_tear_down;
731         u8 reserved[3];
732         __le32 received_beacons;
733         __le32 wake_packet_length;
734         __le32 wake_packet_bufsize;
735         u8 wake_packet[]; /* can be truncated from _length to _bufsize */
736 } __packed; /* WOWLAN_STATUSES_API_S_VER_11 */
737
738 static inline u8 iwlmvm_wowlan_gtk_idx(struct iwl_wowlan_gtk_status *gtk)
739 {
740         return gtk->key_flags & IWL_WOWLAN_GTK_IDX_MASK;
741 }
742
743 #define IWL_WOWLAN_TCP_MAX_PACKET_LEN           64
744 #define IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN   128
745 #define IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS       2048
746
747 struct iwl_tcp_packet_info {
748         __le16 tcp_pseudo_header_checksum;
749         __le16 tcp_payload_length;
750 } __packed; /* TCP_PACKET_INFO_API_S_VER_2 */
751
752 struct iwl_tcp_packet {
753         struct iwl_tcp_packet_info info;
754         u8 rx_mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
755         u8 data[IWL_WOWLAN_TCP_MAX_PACKET_LEN];
756 } __packed; /* TCP_PROTOCOL_PACKET_API_S_VER_1 */
757
758 struct iwl_remote_wake_packet {
759         struct iwl_tcp_packet_info info;
760         u8 rx_mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
761         u8 data[IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN];
762 } __packed; /* TCP_PROTOCOL_PACKET_API_S_VER_1 */
763
764 struct iwl_wowlan_remote_wake_config {
765         __le32 connection_max_time; /* unused */
766         /* TCP_PROTOCOL_CONFIG_API_S_VER_1 */
767         u8 max_syn_retries;
768         u8 max_data_retries;
769         u8 tcp_syn_ack_timeout;
770         u8 tcp_ack_timeout;
771
772         struct iwl_tcp_packet syn_tx;
773         struct iwl_tcp_packet synack_rx;
774         struct iwl_tcp_packet keepalive_ack_rx;
775         struct iwl_tcp_packet fin_tx;
776
777         struct iwl_remote_wake_packet keepalive_tx;
778         struct iwl_remote_wake_packet wake_rx;
779
780         /* REMOTE_WAKE_OFFSET_INFO_API_S_VER_1 */
781         u8 sequence_number_offset;
782         u8 sequence_number_length;
783         u8 token_offset;
784         u8 token_length;
785         /* REMOTE_WAKE_PROTOCOL_PARAMS_API_S_VER_1 */
786         __le32 initial_sequence_number;
787         __le16 keepalive_interval;
788         __le16 num_tokens;
789         u8 tokens[IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS];
790 } __packed; /* REMOTE_WAKE_CONFIG_API_S_VER_2 */
791
792 /* TODO: NetDetect API */
793
794 #endif /* __iwl_fw_api_d3_h__ */