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