iwlwifi: mvm: add firmware API name comment
[cascardo/linux.git] / drivers / net / wireless / intel / iwlwifi / mvm / 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 Intel Deutschland GmbH
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of version 2 of the GNU General Public License as
14  * published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24  * USA
25  *
26  * The full GNU General Public License is included in this distribution
27  * in the file called COPYING.
28  *
29  * Contact Information:
30  *  Intel Linux Wireless <linuxwifi@intel.com>
31  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
32  *
33  * BSD LICENSE
34  *
35  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
36  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
37  * All rights reserved.
38  *
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  *
43  *  * Redistributions of source code must retain the above copyright
44  *    notice, this list of conditions and the following disclaimer.
45  *  * Redistributions in binary form must reproduce the above copyright
46  *    notice, this list of conditions and the following disclaimer in
47  *    the documentation and/or other materials provided with the
48  *    distribution.
49  *  * Neither the name Intel Corporation nor the names of its
50  *    contributors may be used to endorse or promote products derived
51  *    from this software without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64  *****************************************************************************/
65
66 #ifndef __fw_api_d3_h__
67 #define __fw_api_d3_h__
68
69 /**
70  * enum iwl_d3_wakeup_flags - D3 manager wakeup flags
71  * @IWL_WAKEUP_D3_CONFIG_FW_ERROR: wake up on firmware sysassert
72  */
73 enum iwl_d3_wakeup_flags {
74         IWL_WAKEUP_D3_CONFIG_FW_ERROR = BIT(0),
75 }; /* D3_MANAGER_WAKEUP_CONFIG_API_E_VER_3 */
76
77 /**
78  * struct iwl_d3_manager_config - D3 manager configuration command
79  * @min_sleep_time: minimum sleep time (in usec)
80  * @wakeup_flags: wakeup flags, see &enum iwl_d3_wakeup_flags
81  * @wakeup_host_timer: force wakeup after this many seconds
82  *
83  * The structure is used for the D3_CONFIG_CMD command.
84  */
85 struct iwl_d3_manager_config {
86         __le32 min_sleep_time;
87         __le32 wakeup_flags;
88         __le32 wakeup_host_timer;
89 } __packed; /* D3_MANAGER_CONFIG_CMD_S_VER_4 */
90
91
92 /* TODO: OFFLOADS_QUERY_API_S_VER_1 */
93
94 /**
95  * enum iwl_d3_proto_offloads - enabled protocol offloads
96  * @IWL_D3_PROTO_OFFLOAD_ARP: ARP data is enabled
97  * @IWL_D3_PROTO_OFFLOAD_NS: NS (Neighbor Solicitation) is enabled
98  * @IWL_D3_PROTO_IPV4_VALID: IPv4 data is valid
99  * @IWL_D3_PROTO_IPV6_VALID: IPv6 data is valid
100  */
101 enum iwl_proto_offloads {
102         IWL_D3_PROTO_OFFLOAD_ARP = BIT(0),
103         IWL_D3_PROTO_OFFLOAD_NS = BIT(1),
104         IWL_D3_PROTO_IPV4_VALID = BIT(2),
105         IWL_D3_PROTO_IPV6_VALID = BIT(3),
106 };
107
108 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1     2
109 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2     6
110 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L    12
111 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S    4
112 #define IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX    12
113
114 #define IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L     4
115 #define IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S     2
116
117 /**
118  * struct iwl_proto_offload_cmd_common - ARP/NS offload common part
119  * @enabled: enable flags
120  * @remote_ipv4_addr: remote address to answer to (or zero if all)
121  * @host_ipv4_addr: our IPv4 address to respond to queries for
122  * @arp_mac_addr: our MAC address for ARP responses
123  * @reserved: unused
124  */
125 struct iwl_proto_offload_cmd_common {
126         __le32 enabled;
127         __be32 remote_ipv4_addr;
128         __be32 host_ipv4_addr;
129         u8 arp_mac_addr[ETH_ALEN];
130         __le16 reserved;
131 } __packed;
132
133 /**
134  * struct iwl_proto_offload_cmd_v1 - ARP/NS offload configuration
135  * @common: common/IPv4 configuration
136  * @remote_ipv6_addr: remote address to answer to (or zero if all)
137  * @solicited_node_ipv6_addr: broken -- solicited node address exists
138  *      for each target address
139  * @target_ipv6_addr: our target addresses
140  * @ndp_mac_addr: neighbor solicitation response MAC address
141  */
142 struct iwl_proto_offload_cmd_v1 {
143         struct iwl_proto_offload_cmd_common common;
144         u8 remote_ipv6_addr[16];
145         u8 solicited_node_ipv6_addr[16];
146         u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1][16];
147         u8 ndp_mac_addr[ETH_ALEN];
148         __le16 reserved2;
149 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_1 */
150
151 /**
152  * struct iwl_proto_offload_cmd_v2 - ARP/NS offload configuration
153  * @common: common/IPv4 configuration
154  * @remote_ipv6_addr: remote address to answer to (or zero if all)
155  * @solicited_node_ipv6_addr: broken -- solicited node address exists
156  *      for each target address
157  * @target_ipv6_addr: our target addresses
158  * @ndp_mac_addr: neighbor solicitation response MAC address
159  */
160 struct iwl_proto_offload_cmd_v2 {
161         struct iwl_proto_offload_cmd_common common;
162         u8 remote_ipv6_addr[16];
163         u8 solicited_node_ipv6_addr[16];
164         u8 target_ipv6_addr[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2][16];
165         u8 ndp_mac_addr[ETH_ALEN];
166         u8 numValidIPv6Addresses;
167         u8 reserved2[3];
168 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_2 */
169
170 struct iwl_ns_config {
171         struct in6_addr source_ipv6_addr;
172         struct in6_addr dest_ipv6_addr;
173         u8 target_mac_addr[ETH_ALEN];
174         __le16 reserved;
175 } __packed; /* NS_OFFLOAD_CONFIG */
176
177 struct iwl_targ_addr {
178         struct in6_addr addr;
179         __le32 config_num;
180 } __packed; /* TARGET_IPV6_ADDRESS */
181
182 /**
183  * struct iwl_proto_offload_cmd_v3_small - ARP/NS offload configuration
184  * @common: common/IPv4 configuration
185  * @target_ipv6_addr: target IPv6 addresses
186  * @ns_config: NS offload configurations
187  */
188 struct iwl_proto_offload_cmd_v3_small {
189         struct iwl_proto_offload_cmd_common common;
190         __le32 num_valid_ipv6_addrs;
191         struct iwl_targ_addr targ_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S];
192         struct iwl_ns_config ns_config[IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S];
193 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_3 */
194
195 /**
196  * struct iwl_proto_offload_cmd_v3_large - ARP/NS offload configuration
197  * @common: common/IPv4 configuration
198  * @target_ipv6_addr: target IPv6 addresses
199  * @ns_config: NS offload configurations
200  */
201 struct iwl_proto_offload_cmd_v3_large {
202         struct iwl_proto_offload_cmd_common common;
203         __le32 num_valid_ipv6_addrs;
204         struct iwl_targ_addr targ_addrs[IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L];
205         struct iwl_ns_config ns_config[IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L];
206 } __packed; /* PROT_OFFLOAD_CONFIG_CMD_DB_S_VER_3 */
207
208 /*
209  * WOWLAN_PATTERNS
210  */
211 #define IWL_WOWLAN_MIN_PATTERN_LEN      16
212 #define IWL_WOWLAN_MAX_PATTERN_LEN      128
213
214 struct iwl_wowlan_pattern {
215         u8 mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
216         u8 pattern[IWL_WOWLAN_MAX_PATTERN_LEN];
217         u8 mask_size;
218         u8 pattern_size;
219         __le16 reserved;
220 } __packed; /* WOWLAN_PATTERN_API_S_VER_1 */
221
222 #define IWL_WOWLAN_MAX_PATTERNS 20
223
224 struct iwl_wowlan_patterns_cmd {
225         __le32 n_patterns;
226         struct iwl_wowlan_pattern patterns[];
227 } __packed; /* WOWLAN_PATTERN_ARRAY_API_S_VER_1 */
228
229 enum iwl_wowlan_wakeup_filters {
230         IWL_WOWLAN_WAKEUP_MAGIC_PACKET                  = BIT(0),
231         IWL_WOWLAN_WAKEUP_PATTERN_MATCH                 = BIT(1),
232         IWL_WOWLAN_WAKEUP_BEACON_MISS                   = BIT(2),
233         IWL_WOWLAN_WAKEUP_LINK_CHANGE                   = BIT(3),
234         IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL                = BIT(4),
235         IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ                 = BIT(5),
236         IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE                = BIT(6),
237         IWL_WOWLAN_WAKEUP_ENABLE_NET_DETECT             = BIT(7),
238         IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT              = BIT(8),
239         IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS              = BIT(9),
240         IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE        = BIT(10),
241         IWL_WOWLAN_WAKEUP_REMOTE_TCP_EXTERNAL           = BIT(11),
242         IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET          = BIT(12),
243         IWL_WOWLAN_WAKEUP_IOAC_MAGIC_PACKET             = BIT(13),
244         IWL_WOWLAN_WAKEUP_HOST_TIMER                    = BIT(14),
245         IWL_WOWLAN_WAKEUP_RX_FRAME                      = BIT(15),
246         IWL_WOWLAN_WAKEUP_BCN_FILTERING                 = BIT(16),
247 }; /* WOWLAN_WAKEUP_FILTER_API_E_VER_4 */
248
249 enum iwl_wowlan_flags {
250         IS_11W_ASSOC            = BIT(0),
251         ENABLE_L3_FILTERING     = BIT(1),
252         ENABLE_NBNS_FILTERING   = BIT(2),
253         ENABLE_DHCP_FILTERING   = BIT(3),
254         ENABLE_STORE_BEACON     = BIT(4),
255 };
256
257 struct iwl_wowlan_config_cmd {
258         __le32 wakeup_filter;
259         __le16 non_qos_seq;
260         __le16 qos_seq[8];
261         u8 wowlan_ba_teardown_tids;
262         u8 is_11n_connection;
263         u8 offloading_tid;
264         u8 flags;
265         u8 reserved[2];
266 } __packed; /* WOWLAN_CONFIG_API_S_VER_4 */
267
268 /*
269  * WOWLAN_TSC_RSC_PARAMS
270  */
271 #define IWL_NUM_RSC     16
272
273 struct tkip_sc {
274         __le16 iv16;
275         __le16 pad;
276         __le32 iv32;
277 } __packed; /* TKIP_SC_API_U_VER_1 */
278
279 struct iwl_tkip_rsc_tsc {
280         struct tkip_sc unicast_rsc[IWL_NUM_RSC];
281         struct tkip_sc multicast_rsc[IWL_NUM_RSC];
282         struct tkip_sc tsc;
283 } __packed; /* TKIP_TSC_RSC_API_S_VER_1 */
284
285 struct aes_sc {
286         __le64 pn;
287 } __packed; /* TKIP_AES_SC_API_U_VER_1 */
288
289 struct iwl_aes_rsc_tsc {
290         struct aes_sc unicast_rsc[IWL_NUM_RSC];
291         struct aes_sc multicast_rsc[IWL_NUM_RSC];
292         struct aes_sc tsc;
293 } __packed; /* AES_TSC_RSC_API_S_VER_1 */
294
295 union iwl_all_tsc_rsc {
296         struct iwl_tkip_rsc_tsc tkip;
297         struct iwl_aes_rsc_tsc aes;
298 }; /* ALL_TSC_RSC_API_S_VER_2 */
299
300 struct iwl_wowlan_rsc_tsc_params_cmd {
301         union iwl_all_tsc_rsc all_tsc_rsc;
302 } __packed; /* ALL_TSC_RSC_API_S_VER_2 */
303
304 #define IWL_MIC_KEY_SIZE        8
305 struct iwl_mic_keys {
306         u8 tx[IWL_MIC_KEY_SIZE];
307         u8 rx_unicast[IWL_MIC_KEY_SIZE];
308         u8 rx_mcast[IWL_MIC_KEY_SIZE];
309 } __packed; /* MIC_KEYS_API_S_VER_1 */
310
311 #define IWL_P1K_SIZE            5
312 struct iwl_p1k_cache {
313         __le16 p1k[IWL_P1K_SIZE];
314 } __packed;
315
316 #define IWL_NUM_RX_P1K_CACHE    2
317
318 struct iwl_wowlan_tkip_params_cmd {
319         struct iwl_mic_keys mic_keys;
320         struct iwl_p1k_cache tx;
321         struct iwl_p1k_cache rx_uni[IWL_NUM_RX_P1K_CACHE];
322         struct iwl_p1k_cache rx_multi[IWL_NUM_RX_P1K_CACHE];
323 } __packed; /* WOWLAN_TKIP_SETTING_API_S_VER_1 */
324
325 #define IWL_KCK_MAX_SIZE        32
326 #define IWL_KEK_MAX_SIZE        32
327
328 struct iwl_wowlan_kek_kck_material_cmd {
329         u8      kck[IWL_KCK_MAX_SIZE];
330         u8      kek[IWL_KEK_MAX_SIZE];
331         __le16  kck_len;
332         __le16  kek_len;
333         __le64  replay_ctr;
334 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_2 */
335
336 #define RF_KILL_INDICATOR_FOR_WOWLAN    0x87
337
338 enum iwl_wowlan_rekey_status {
339         IWL_WOWLAN_REKEY_POST_REKEY = 0,
340         IWL_WOWLAN_REKEY_WHILE_REKEY = 1,
341 }; /* WOWLAN_REKEY_STATUS_API_E_VER_1 */
342
343 enum iwl_wowlan_wakeup_reason {
344         IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS                       = 0,
345         IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET                       = BIT(0),
346         IWL_WOWLAN_WAKEUP_BY_PATTERN                            = BIT(1),
347         IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON     = BIT(2),
348         IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH            = BIT(3),
349         IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE                  = BIT(4),
350         IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED                  = BIT(5),
351         IWL_WOWLAN_WAKEUP_BY_UCODE_ERROR                        = BIT(6),
352         IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST                      = BIT(7),
353         IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE                 = BIT(8),
354         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS                 = BIT(9),
355         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE           = BIT(10),
356         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_TCP_EXTERNAL              = BIT(11),
357         IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET             = BIT(12),
358         IWL_WOWLAN_WAKEUP_BY_IOAC_MAGIC_PACKET                  = BIT(13),
359         IWL_WOWLAN_WAKEUP_BY_D3_WAKEUP_HOST_TIMER               = BIT(14),
360         IWL_WOWLAN_WAKEUP_BY_RXFRAME_FILTERED_IN                = BIT(15),
361         IWL_WOWLAN_WAKEUP_BY_BEACON_FILTERED_IN                 = BIT(16),
362
363 }; /* WOWLAN_WAKE_UP_REASON_API_E_VER_2 */
364
365 struct iwl_wowlan_gtk_status {
366         u8 key_index;
367         u8 reserved[3];
368         u8 decrypt_key[16];
369         u8 tkip_mic_key[8];
370         struct iwl_wowlan_rsc_tsc_params_cmd rsc;
371 } __packed; /* WOWLAN_GTK_MATERIAL_VER_1 */
372
373 struct iwl_wowlan_status {
374         struct iwl_wowlan_gtk_status gtk;
375         __le64 replay_ctr;
376         __le16 pattern_number;
377         __le16 non_qos_seq_ctr;
378         __le16 qos_seq_ctr[8];
379         __le32 wakeup_reasons;
380         __le32 num_of_gtk_rekeys;
381         __le32 transmitted_ndps;
382         __le32 received_beacons;
383         __le32 wake_packet_length;
384         __le32 wake_packet_bufsize;
385         u8 wake_packet[]; /* can be truncated from _length to _bufsize */
386 } __packed; /* WOWLAN_STATUSES_API_S_VER_6 */
387
388 #define IWL_WOWLAN_TCP_MAX_PACKET_LEN           64
389 #define IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN   128
390 #define IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS       2048
391
392 struct iwl_tcp_packet_info {
393         __le16 tcp_pseudo_header_checksum;
394         __le16 tcp_payload_length;
395 } __packed; /* TCP_PACKET_INFO_API_S_VER_2 */
396
397 struct iwl_tcp_packet {
398         struct iwl_tcp_packet_info info;
399         u8 rx_mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
400         u8 data[IWL_WOWLAN_TCP_MAX_PACKET_LEN];
401 } __packed; /* TCP_PROTOCOL_PACKET_API_S_VER_1 */
402
403 struct iwl_remote_wake_packet {
404         struct iwl_tcp_packet_info info;
405         u8 rx_mask[IWL_WOWLAN_MAX_PATTERN_LEN / 8];
406         u8 data[IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN];
407 } __packed; /* TCP_PROTOCOL_PACKET_API_S_VER_1 */
408
409 struct iwl_wowlan_remote_wake_config {
410         __le32 connection_max_time; /* unused */
411         /* TCP_PROTOCOL_CONFIG_API_S_VER_1 */
412         u8 max_syn_retries;
413         u8 max_data_retries;
414         u8 tcp_syn_ack_timeout;
415         u8 tcp_ack_timeout;
416
417         struct iwl_tcp_packet syn_tx;
418         struct iwl_tcp_packet synack_rx;
419         struct iwl_tcp_packet keepalive_ack_rx;
420         struct iwl_tcp_packet fin_tx;
421
422         struct iwl_remote_wake_packet keepalive_tx;
423         struct iwl_remote_wake_packet wake_rx;
424
425         /* REMOTE_WAKE_OFFSET_INFO_API_S_VER_1 */
426         u8 sequence_number_offset;
427         u8 sequence_number_length;
428         u8 token_offset;
429         u8 token_length;
430         /* REMOTE_WAKE_PROTOCOL_PARAMS_API_S_VER_1 */
431         __le32 initial_sequence_number;
432         __le16 keepalive_interval;
433         __le16 num_tokens;
434         u8 tokens[IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS];
435 } __packed; /* REMOTE_WAKE_CONFIG_API_S_VER_2 */
436
437 /* TODO: NetDetect API */
438
439 #endif /* __fw_api_d3_h__ */