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