Merge branch 'integrity-check-patch-v2' of git://btrfs.giantdisaster.de/git/btrfs...
[cascardo/linux.git] / drivers / net / wireless / ath / ath6kl / wmi.h
1 /*
2  * Copyright (c) 2010-2011 Atheros Communications Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 /*
18  * This file contains the definitions of the WMI protocol specified in the
19  * Wireless Module Interface (WMI).  It includes definitions of all the
20  * commands and events. Commands are messages from the host to the WM.
21  * Events and Replies are messages from the WM to the host.
22  */
23
24 #ifndef WMI_H
25 #define WMI_H
26
27 #include <linux/ieee80211.h>
28
29 #include "htc.h"
30
31 #define HTC_PROTOCOL_VERSION            0x0002
32 #define WMI_PROTOCOL_VERSION            0x0002
33 #define WMI_CONTROL_MSG_MAX_LEN         256
34 #define is_ethertype(type_or_len)       ((type_or_len) >= 0x0600)
35
36 #define IP_ETHERTYPE            0x0800
37
38 #define WMI_IMPLICIT_PSTREAM    0xFF
39 #define WMI_MAX_THINSTREAM      15
40
41 #define SSID_IE_LEN_INDEX       13
42
43 /* Host side link management data structures */
44 #define SIG_QUALITY_THRESH_LVLS         6
45 #define SIG_QUALITY_UPPER_THRESH_LVLS   SIG_QUALITY_THRESH_LVLS
46 #define SIG_QUALITY_LOWER_THRESH_LVLS   SIG_QUALITY_THRESH_LVLS
47
48 #define A_BAND_24GHZ           0
49 #define A_BAND_5GHZ            1
50 #define A_NUM_BANDS            2
51
52 /* in ms */
53 #define WMI_IMPLICIT_PSTREAM_INACTIVITY_INT 5000
54
55 /*
56  * There are no signed versions of __le16 and __le32, so for a temporary
57  * solution come up with our own version. The idea is from fs/ntfs/types.h.
58  *
59  * Use a_ prefix so that it doesn't conflict if we get proper support to
60  * linux/types.h.
61  */
62 typedef __s16 __bitwise a_sle16;
63 typedef __s32 __bitwise a_sle32;
64
65 static inline a_sle32 a_cpu_to_sle32(s32 val)
66 {
67         return (__force a_sle32) cpu_to_le32(val);
68 }
69
70 static inline s32 a_sle32_to_cpu(a_sle32 val)
71 {
72         return le32_to_cpu((__force __le32) val);
73 }
74
75 static inline a_sle16 a_cpu_to_sle16(s16 val)
76 {
77         return (__force a_sle16) cpu_to_le16(val);
78 }
79
80 static inline s16 a_sle16_to_cpu(a_sle16 val)
81 {
82         return le16_to_cpu((__force __le16) val);
83 }
84
85 struct sq_threshold_params {
86         s16 upper_threshold[SIG_QUALITY_UPPER_THRESH_LVLS];
87         s16 lower_threshold[SIG_QUALITY_LOWER_THRESH_LVLS];
88         u32 upper_threshold_valid_count;
89         u32 lower_threshold_valid_count;
90         u32 polling_interval;
91         u8 weight;
92         u8 last_rssi;
93         u8 last_rssi_poll_event;
94 };
95
96 struct wmi_stats {
97         u32 cmd_len_err;
98         u32 cmd_id_err;
99 };
100
101 struct wmi_data_sync_bufs {
102         u8 traffic_class;
103         struct sk_buff *skb;
104 };
105
106 /* WMM stream classes */
107 #define WMM_NUM_AC  4
108 #define WMM_AC_BE   0           /* best effort */
109 #define WMM_AC_BK   1           /* background */
110 #define WMM_AC_VI   2           /* video */
111 #define WMM_AC_VO   3           /* voice */
112
113 struct wmi {
114         bool ready;
115         u16 stream_exist_for_ac[WMM_NUM_AC];
116         u8 fat_pipe_exist;
117         struct ath6kl *parent_dev;
118         struct wmi_stats stat;
119         u8 pwr_mode;
120         u8 phy_mode;
121         u8 keep_alive_intvl;
122         spinlock_t lock;
123         enum htc_endpoint_id ep_id;
124         struct sq_threshold_params
125             sq_threshld[SIGNAL_QUALITY_METRICS_NUM_MAX];
126         enum crypto_type pair_crypto_type;
127         enum crypto_type grp_crypto_type;
128         bool is_wmm_enabled;
129         u8 ht_allowed[A_NUM_BANDS];
130         u8 traffic_class;
131         bool is_probe_ssid;
132
133         u8 *last_mgmt_tx_frame;
134         size_t last_mgmt_tx_frame_len;
135 };
136
137 struct host_app_area {
138         u32 wmi_protocol_ver;
139 };
140
141 enum wmi_msg_type {
142         DATA_MSGTYPE = 0x0,
143         CNTL_MSGTYPE,
144         SYNC_MSGTYPE,
145         OPT_MSGTYPE,
146 };
147
148 /*
149  * Macros for operating on WMI_DATA_HDR (info) field
150  */
151
152 #define WMI_DATA_HDR_MSG_TYPE_MASK  0x03
153 #define WMI_DATA_HDR_MSG_TYPE_SHIFT 0
154 #define WMI_DATA_HDR_UP_MASK        0x07
155 #define WMI_DATA_HDR_UP_SHIFT       2
156
157 /* In AP mode, the same bit (b5) is used to indicate Power save state in
158  * the Rx dir and More data bit state in the tx direction.
159  */
160 #define WMI_DATA_HDR_PS_MASK        0x1
161 #define WMI_DATA_HDR_PS_SHIFT       5
162
163 #define WMI_DATA_HDR_MORE_MASK      0x1
164 #define WMI_DATA_HDR_MORE_SHIFT     5
165
166 enum wmi_data_hdr_data_type {
167         WMI_DATA_HDR_DATA_TYPE_802_3 = 0,
168         WMI_DATA_HDR_DATA_TYPE_802_11,
169
170         /* used to be used for the PAL */
171         WMI_DATA_HDR_DATA_TYPE_ACL,
172 };
173
174 #define WMI_DATA_HDR_DATA_TYPE_MASK     0x3
175 #define WMI_DATA_HDR_DATA_TYPE_SHIFT    6
176
177 /* Macros for operating on WMI_DATA_HDR (info2) field */
178 #define WMI_DATA_HDR_SEQNO_MASK     0xFFF
179 #define WMI_DATA_HDR_SEQNO_SHIFT    0
180
181 #define WMI_DATA_HDR_AMSDU_MASK     0x1
182 #define WMI_DATA_HDR_AMSDU_SHIFT    12
183
184 #define WMI_DATA_HDR_META_MASK      0x7
185 #define WMI_DATA_HDR_META_SHIFT     13
186
187 struct wmi_data_hdr {
188         s8 rssi;
189
190         /*
191          * usage of 'info' field(8-bit):
192          *
193          *  b1:b0       - WMI_MSG_TYPE
194          *  b4:b3:b2    - UP(tid)
195          *  b5          - Used in AP mode.
196          *  More-data in tx dir, PS in rx.
197          *  b7:b6       - Dot3 header(0),
198          *                Dot11 Header(1),
199          *                ACL data(2)
200          */
201         u8 info;
202
203         /*
204          * usage of 'info2' field(16-bit):
205          *
206          * b11:b0       - seq_no
207          * b12          - A-MSDU?
208          * b15:b13      - META_DATA_VERSION 0 - 7
209          */
210         __le16 info2;
211         __le16 info3;
212 } __packed;
213
214 static inline u8 wmi_data_hdr_get_up(struct wmi_data_hdr *dhdr)
215 {
216         return (dhdr->info >> WMI_DATA_HDR_UP_SHIFT) & WMI_DATA_HDR_UP_MASK;
217 }
218
219 static inline void wmi_data_hdr_set_up(struct wmi_data_hdr *dhdr,
220                                        u8 usr_pri)
221 {
222         dhdr->info &= ~(WMI_DATA_HDR_UP_MASK << WMI_DATA_HDR_UP_SHIFT);
223         dhdr->info |= usr_pri << WMI_DATA_HDR_UP_SHIFT;
224 }
225
226 static inline u8 wmi_data_hdr_get_dot11(struct wmi_data_hdr *dhdr)
227 {
228         u8 data_type;
229
230         data_type = (dhdr->info >> WMI_DATA_HDR_DATA_TYPE_SHIFT) &
231                                    WMI_DATA_HDR_DATA_TYPE_MASK;
232         return (data_type == WMI_DATA_HDR_DATA_TYPE_802_11);
233 }
234
235 static inline u16 wmi_data_hdr_get_seqno(struct wmi_data_hdr *dhdr)
236 {
237         return (le16_to_cpu(dhdr->info2) >> WMI_DATA_HDR_SEQNO_SHIFT) &
238                                 WMI_DATA_HDR_SEQNO_MASK;
239 }
240
241 static inline u8 wmi_data_hdr_is_amsdu(struct wmi_data_hdr *dhdr)
242 {
243         return (le16_to_cpu(dhdr->info2) >> WMI_DATA_HDR_AMSDU_SHIFT) &
244                                WMI_DATA_HDR_AMSDU_MASK;
245 }
246
247 static inline u8 wmi_data_hdr_get_meta(struct wmi_data_hdr *dhdr)
248 {
249         return (le16_to_cpu(dhdr->info2) >> WMI_DATA_HDR_META_SHIFT) &
250                                WMI_DATA_HDR_META_MASK;
251 }
252
253 /* Tx meta version definitions */
254 #define WMI_MAX_TX_META_SZ      12
255 #define WMI_META_VERSION_1      0x01
256 #define WMI_META_VERSION_2      0x02
257
258 struct wmi_tx_meta_v1 {
259         /* packet ID to identify the tx request */
260         u8 pkt_id;
261
262         /* rate policy to be used for the tx of this frame */
263         u8 rate_plcy_id;
264 } __packed;
265
266 struct wmi_tx_meta_v2 {
267         /*
268          * Offset from start of the WMI header for csum calculation to
269          * begin.
270          */
271         u8 csum_start;
272
273         /* offset from start of WMI header where final csum goes */
274         u8 csum_dest;
275
276         /* no of bytes over which csum is calculated */
277         u8 csum_flags;
278 } __packed;
279
280 struct wmi_rx_meta_v1 {
281         u8 status;
282
283         /* rate index mapped to rate at which this packet was received. */
284         u8 rix;
285
286         /* rssi of packet */
287         u8 rssi;
288
289         /* rf channel during packet reception */
290         u8 channel;
291
292         __le16 flags;
293 } __packed;
294
295 struct wmi_rx_meta_v2 {
296         __le16 csum;
297
298         /* bit 0 set -partial csum valid bit 1 set -test mode */
299         u8 csum_flags;
300 } __packed;
301
302 /* Control Path */
303 struct wmi_cmd_hdr {
304         __le16 cmd_id;
305
306         /* info1 - 16 bits
307          * b03:b00 - id
308          * b15:b04 - unused */
309         __le16 info1;
310
311         /* for alignment */
312         __le16 reserved;
313 } __packed;
314
315 /* List of WMI commands */
316 enum wmi_cmd_id {
317         WMI_CONNECT_CMDID = 0x0001,
318         WMI_RECONNECT_CMDID,
319         WMI_DISCONNECT_CMDID,
320         WMI_SYNCHRONIZE_CMDID,
321         WMI_CREATE_PSTREAM_CMDID,
322         WMI_DELETE_PSTREAM_CMDID,
323         WMI_START_SCAN_CMDID,
324         WMI_SET_SCAN_PARAMS_CMDID,
325         WMI_SET_BSS_FILTER_CMDID,
326         WMI_SET_PROBED_SSID_CMDID,      /* 10 */
327         WMI_SET_LISTEN_INT_CMDID,
328         WMI_SET_BMISS_TIME_CMDID,
329         WMI_SET_DISC_TIMEOUT_CMDID,
330         WMI_GET_CHANNEL_LIST_CMDID,
331         WMI_SET_BEACON_INT_CMDID,
332         WMI_GET_STATISTICS_CMDID,
333         WMI_SET_CHANNEL_PARAMS_CMDID,
334         WMI_SET_POWER_MODE_CMDID,
335         WMI_SET_IBSS_PM_CAPS_CMDID,
336         WMI_SET_POWER_PARAMS_CMDID,     /* 20 */
337         WMI_SET_POWERSAVE_TIMERS_POLICY_CMDID,
338         WMI_ADD_CIPHER_KEY_CMDID,
339         WMI_DELETE_CIPHER_KEY_CMDID,
340         WMI_ADD_KRK_CMDID,
341         WMI_DELETE_KRK_CMDID,
342         WMI_SET_PMKID_CMDID,
343         WMI_SET_TX_PWR_CMDID,
344         WMI_GET_TX_PWR_CMDID,
345         WMI_SET_ASSOC_INFO_CMDID,
346         WMI_ADD_BAD_AP_CMDID,           /* 30 */
347         WMI_DELETE_BAD_AP_CMDID,
348         WMI_SET_TKIP_COUNTERMEASURES_CMDID,
349         WMI_RSSI_THRESHOLD_PARAMS_CMDID,
350         WMI_TARGET_ERROR_REPORT_BITMASK_CMDID,
351         WMI_SET_ACCESS_PARAMS_CMDID,
352         WMI_SET_RETRY_LIMITS_CMDID,
353         WMI_SET_OPT_MODE_CMDID,
354         WMI_OPT_TX_FRAME_CMDID,
355         WMI_SET_VOICE_PKT_SIZE_CMDID,
356         WMI_SET_MAX_SP_LEN_CMDID,       /* 40 */
357         WMI_SET_ROAM_CTRL_CMDID,
358         WMI_GET_ROAM_TBL_CMDID,
359         WMI_GET_ROAM_DATA_CMDID,
360         WMI_ENABLE_RM_CMDID,
361         WMI_SET_MAX_OFFHOME_DURATION_CMDID,
362         WMI_EXTENSION_CMDID,    /* Non-wireless extensions */
363         WMI_SNR_THRESHOLD_PARAMS_CMDID,
364         WMI_LQ_THRESHOLD_PARAMS_CMDID,
365         WMI_SET_LPREAMBLE_CMDID,
366         WMI_SET_RTS_CMDID,              /* 50 */
367         WMI_CLR_RSSI_SNR_CMDID,
368         WMI_SET_FIXRATES_CMDID,
369         WMI_GET_FIXRATES_CMDID,
370         WMI_SET_AUTH_MODE_CMDID,
371         WMI_SET_REASSOC_MODE_CMDID,
372         WMI_SET_WMM_CMDID,
373         WMI_SET_WMM_TXOP_CMDID,
374         WMI_TEST_CMDID,
375
376         /* COEX AR6002 only */
377         WMI_SET_BT_STATUS_CMDID,
378         WMI_SET_BT_PARAMS_CMDID,        /* 60 */
379
380         WMI_SET_KEEPALIVE_CMDID,
381         WMI_GET_KEEPALIVE_CMDID,
382         WMI_SET_APPIE_CMDID,
383         WMI_GET_APPIE_CMDID,
384         WMI_SET_WSC_STATUS_CMDID,
385
386         /* Wake on Wireless */
387         WMI_SET_HOST_SLEEP_MODE_CMDID,
388         WMI_SET_WOW_MODE_CMDID,
389         WMI_GET_WOW_LIST_CMDID,
390         WMI_ADD_WOW_PATTERN_CMDID,
391         WMI_DEL_WOW_PATTERN_CMDID,      /* 70 */
392
393         WMI_SET_FRAMERATES_CMDID,
394         WMI_SET_AP_PS_CMDID,
395         WMI_SET_QOS_SUPP_CMDID,
396
397         /* WMI_THIN_RESERVED_... mark the start and end
398          * values for WMI_THIN_RESERVED command IDs. These
399          * command IDs can be found in wmi_thin.h */
400         WMI_THIN_RESERVED_START = 0x8000,
401         WMI_THIN_RESERVED_END = 0x8fff,
402
403         /* Developer commands starts at 0xF000 */
404         WMI_SET_BITRATE_CMDID = 0xF000,
405         WMI_GET_BITRATE_CMDID,
406         WMI_SET_WHALPARAM_CMDID,
407         WMI_SET_MAC_ADDRESS_CMDID,
408         WMI_SET_AKMP_PARAMS_CMDID,
409         WMI_SET_PMKID_LIST_CMDID,
410         WMI_GET_PMKID_LIST_CMDID,
411         WMI_ABORT_SCAN_CMDID,
412         WMI_SET_TARGET_EVENT_REPORT_CMDID,
413
414         /* Unused */
415         WMI_UNUSED1,
416         WMI_UNUSED2,
417
418         /* AP mode commands */
419         WMI_AP_HIDDEN_SSID_CMDID,
420         WMI_AP_SET_NUM_STA_CMDID,
421         WMI_AP_ACL_POLICY_CMDID,
422         WMI_AP_ACL_MAC_LIST_CMDID,
423         WMI_AP_CONFIG_COMMIT_CMDID,
424         WMI_AP_SET_MLME_CMDID,
425         WMI_AP_SET_PVB_CMDID,
426         WMI_AP_CONN_INACT_CMDID,
427         WMI_AP_PROT_SCAN_TIME_CMDID,
428         WMI_AP_SET_COUNTRY_CMDID,
429         WMI_AP_SET_DTIM_CMDID,
430         WMI_AP_MODE_STAT_CMDID,
431
432         WMI_SET_IP_CMDID,
433         WMI_SET_PARAMS_CMDID,
434         WMI_SET_MCAST_FILTER_CMDID,
435         WMI_DEL_MCAST_FILTER_CMDID,
436
437         WMI_ALLOW_AGGR_CMDID,
438         WMI_ADDBA_REQ_CMDID,
439         WMI_DELBA_REQ_CMDID,
440         WMI_SET_HT_CAP_CMDID,
441         WMI_SET_HT_OP_CMDID,
442         WMI_SET_TX_SELECT_RATES_CMDID,
443         WMI_SET_TX_SGI_PARAM_CMDID,
444         WMI_SET_RATE_POLICY_CMDID,
445
446         WMI_HCI_CMD_CMDID,
447         WMI_RX_FRAME_FORMAT_CMDID,
448         WMI_SET_THIN_MODE_CMDID,
449         WMI_SET_BT_WLAN_CONN_PRECEDENCE_CMDID,
450
451         WMI_AP_SET_11BG_RATESET_CMDID,
452         WMI_SET_PMK_CMDID,
453         WMI_MCAST_FILTER_CMDID,
454
455         /* COEX CMDID AR6003 */
456         WMI_SET_BTCOEX_FE_ANT_CMDID,
457         WMI_SET_BTCOEX_COLOCATED_BT_DEV_CMDID,
458         WMI_SET_BTCOEX_SCO_CONFIG_CMDID,
459         WMI_SET_BTCOEX_A2DP_CONFIG_CMDID,
460         WMI_SET_BTCOEX_ACLCOEX_CONFIG_CMDID,
461         WMI_SET_BTCOEX_BTINQUIRY_PAGE_CONFIG_CMDID,
462         WMI_SET_BTCOEX_DEBUG_CMDID,
463         WMI_SET_BTCOEX_BT_OPERATING_STATUS_CMDID,
464         WMI_GET_BTCOEX_STATS_CMDID,
465         WMI_GET_BTCOEX_CONFIG_CMDID,
466
467         WMI_SET_DFS_ENABLE_CMDID,       /* F034 */
468         WMI_SET_DFS_MINRSSITHRESH_CMDID,
469         WMI_SET_DFS_MAXPULSEDUR_CMDID,
470         WMI_DFS_RADAR_DETECTED_CMDID,
471
472         /* P2P commands */
473         WMI_P2P_SET_CONFIG_CMDID,       /* F038 */
474         WMI_WPS_SET_CONFIG_CMDID,
475         WMI_SET_REQ_DEV_ATTR_CMDID,
476         WMI_P2P_FIND_CMDID,
477         WMI_P2P_STOP_FIND_CMDID,
478         WMI_P2P_GO_NEG_START_CMDID,
479         WMI_P2P_LISTEN_CMDID,
480
481         WMI_CONFIG_TX_MAC_RULES_CMDID,  /* F040 */
482         WMI_SET_PROMISCUOUS_MODE_CMDID,
483         WMI_RX_FRAME_FILTER_CMDID,
484         WMI_SET_CHANNEL_CMDID,
485
486         /* WAC commands */
487         WMI_ENABLE_WAC_CMDID,
488         WMI_WAC_SCAN_REPLY_CMDID,
489         WMI_WAC_CTRL_REQ_CMDID,
490         WMI_SET_DIV_PARAMS_CMDID,
491
492         WMI_GET_PMK_CMDID,
493         WMI_SET_PASSPHRASE_CMDID,
494         WMI_SEND_ASSOC_RES_CMDID,
495         WMI_SET_ASSOC_REQ_RELAY_CMDID,
496
497         /* ACS command, consists of sub-commands */
498         WMI_ACS_CTRL_CMDID,
499         WMI_SET_EXCESS_TX_RETRY_THRES_CMDID,
500         WMI_SET_TBD_TIME_CMDID, /*added for wmiconfig command for TBD */
501
502         /* Pktlog cmds */
503         WMI_PKTLOG_ENABLE_CMDID,
504         WMI_PKTLOG_DISABLE_CMDID,
505
506         /* More P2P Cmds */
507         WMI_P2P_GO_NEG_REQ_RSP_CMDID,
508         WMI_P2P_GRP_INIT_CMDID,
509         WMI_P2P_GRP_FORMATION_DONE_CMDID,
510         WMI_P2P_INVITE_CMDID,
511         WMI_P2P_INVITE_REQ_RSP_CMDID,
512         WMI_P2P_PROV_DISC_REQ_CMDID,
513         WMI_P2P_SET_CMDID,
514
515         WMI_GET_RFKILL_MODE_CMDID,
516         WMI_SET_RFKILL_MODE_CMDID,
517         WMI_AP_SET_APSD_CMDID,
518         WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID,
519
520         WMI_P2P_SDPD_TX_CMDID, /* F05C */
521         WMI_P2P_STOP_SDPD_CMDID,
522         WMI_P2P_CANCEL_CMDID,
523         /* Ultra low power store / recall commands */
524         WMI_STORERECALL_CONFIGURE_CMDID,
525         WMI_STORERECALL_RECALL_CMDID,
526         WMI_STORERECALL_HOST_READY_CMDID,
527         WMI_FORCE_TARGET_ASSERT_CMDID,
528
529         WMI_SET_PROBED_SSID_EX_CMDID,
530         WMI_SET_NETWORK_LIST_OFFLOAD_CMDID,
531         WMI_SET_ARP_NS_OFFLOAD_CMDID,
532         WMI_ADD_WOW_EXT_PATTERN_CMDID,
533         WMI_GTK_OFFLOAD_OP_CMDID,
534         WMI_REMAIN_ON_CHNL_CMDID,
535         WMI_CANCEL_REMAIN_ON_CHNL_CMDID,
536         WMI_SEND_ACTION_CMDID,
537         WMI_PROBE_REQ_REPORT_CMDID,
538         WMI_DISABLE_11B_RATES_CMDID,
539         WMI_SEND_PROBE_RESPONSE_CMDID,
540         WMI_GET_P2P_INFO_CMDID,
541         WMI_AP_JOIN_BSS_CMDID,
542 };
543
544 enum wmi_mgmt_frame_type {
545         WMI_FRAME_BEACON = 0,
546         WMI_FRAME_PROBE_REQ,
547         WMI_FRAME_PROBE_RESP,
548         WMI_FRAME_ASSOC_REQ,
549         WMI_FRAME_ASSOC_RESP,
550         WMI_NUM_MGMT_FRAME
551 };
552
553 /* WMI_CONNECT_CMDID  */
554 enum network_type {
555         INFRA_NETWORK = 0x01,
556         ADHOC_NETWORK = 0x02,
557         ADHOC_CREATOR = 0x04,
558         AP_NETWORK = 0x10,
559 };
560
561 enum dot11_auth_mode {
562         OPEN_AUTH = 0x01,
563         SHARED_AUTH = 0x02,
564
565         /* different from IEEE_AUTH_MODE definitions */
566         LEAP_AUTH = 0x04,
567 };
568
569 enum auth_mode {
570         NONE_AUTH = 0x01,
571         WPA_AUTH = 0x02,
572         WPA2_AUTH = 0x04,
573         WPA_PSK_AUTH = 0x08,
574         WPA2_PSK_AUTH = 0x10,
575         WPA_AUTH_CCKM = 0x20,
576         WPA2_AUTH_CCKM = 0x40,
577 };
578
579 #define WMI_MIN_CRYPTO_TYPE NONE_CRYPT
580 #define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1)
581
582 #define WMI_MIN_KEY_INDEX   0
583 #define WMI_MAX_KEY_INDEX   3
584
585 #define WMI_MAX_KEY_LEN     32
586
587 /*
588  * NB: these values are ordered carefully; there are lots of
589  * of implications in any reordering.  In particular beware
590  * that 4 is not used to avoid conflicting with IEEE80211_F_PRIVACY.
591  */
592 #define ATH6KL_CIPHER_WEP            0
593 #define ATH6KL_CIPHER_TKIP           1
594 #define ATH6KL_CIPHER_AES_OCB        2
595 #define ATH6KL_CIPHER_AES_CCM        3
596 #define ATH6KL_CIPHER_CKIP           5
597 #define ATH6KL_CIPHER_CCKM_KRK       6
598 #define ATH6KL_CIPHER_NONE           7 /* pseudo value */
599
600 /*
601  * 802.11 rate set.
602  */
603 #define ATH6KL_RATE_MAXSIZE  15 /* max rates we'll handle */
604
605 #define ATH_OUI_TYPE            0x01
606 #define WPA_OUI_TYPE            0x01
607 #define WMM_PARAM_OUI_SUBTYPE   0x01
608 #define WMM_OUI_TYPE            0x02
609 #define WSC_OUT_TYPE            0x04
610
611 enum wmi_connect_ctrl_flags_bits {
612         CONNECT_ASSOC_POLICY_USER = 0x0001,
613         CONNECT_SEND_REASSOC = 0x0002,
614         CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004,
615         CONNECT_PROFILE_MATCH_DONE = 0x0008,
616         CONNECT_IGNORE_AAC_BEACON = 0x0010,
617         CONNECT_CSA_FOLLOW_BSS = 0x0020,
618         CONNECT_DO_WPA_OFFLOAD = 0x0040,
619         CONNECT_DO_NOT_DEAUTH = 0x0080,
620 };
621
622 struct wmi_connect_cmd {
623         u8 nw_type;
624         u8 dot11_auth_mode;
625         u8 auth_mode;
626         u8 prwise_crypto_type;
627         u8 prwise_crypto_len;
628         u8 grp_crypto_type;
629         u8 grp_crypto_len;
630         u8 ssid_len;
631         u8 ssid[IEEE80211_MAX_SSID_LEN];
632         __le16 ch;
633         u8 bssid[ETH_ALEN];
634         __le32 ctrl_flags;
635 } __packed;
636
637 /* WMI_RECONNECT_CMDID */
638 struct wmi_reconnect_cmd {
639         /* channel hint */
640         __le16 channel;
641
642         /* mandatory if set */
643         u8 bssid[ETH_ALEN];
644 } __packed;
645
646 /* WMI_ADD_CIPHER_KEY_CMDID */
647 enum key_usage {
648         PAIRWISE_USAGE = 0x00,
649         GROUP_USAGE = 0x01,
650
651         /* default Tx Key - static WEP only */
652         TX_USAGE = 0x02,
653 };
654
655 /*
656  * Bit Flag
657  * Bit 0 - Initialise TSC - default is Initialize
658  */
659 #define KEY_OP_INIT_TSC     0x01
660 #define KEY_OP_INIT_RSC     0x02
661
662 /* default initialise the TSC & RSC */
663 #define KEY_OP_INIT_VAL     0x03
664 #define KEY_OP_VALID_MASK   0x03
665
666 struct wmi_add_cipher_key_cmd {
667         u8 key_index;
668         u8 key_type;
669
670         /* enum key_usage */
671         u8 key_usage;
672
673         u8 key_len;
674
675         /* key replay sequence counter */
676         u8 key_rsc[8];
677
678         u8 key[WLAN_MAX_KEY_LEN];
679
680         /* additional key control info */
681         u8 key_op_ctrl;
682
683         u8 key_mac_addr[ETH_ALEN];
684 } __packed;
685
686 /* WMI_DELETE_CIPHER_KEY_CMDID */
687 struct wmi_delete_cipher_key_cmd {
688         u8 key_index;
689 } __packed;
690
691 #define WMI_KRK_LEN     16
692
693 /* WMI_ADD_KRK_CMDID */
694 struct wmi_add_krk_cmd {
695         u8 krk[WMI_KRK_LEN];
696 } __packed;
697
698 /* WMI_SETPMKID_CMDID */
699
700 #define WMI_PMKID_LEN 16
701
702 enum pmkid_enable_flg {
703         PMKID_DISABLE = 0,
704         PMKID_ENABLE = 1,
705 };
706
707 struct wmi_setpmkid_cmd {
708         u8 bssid[ETH_ALEN];
709
710         /* enum pmkid_enable_flg */
711         u8 enable;
712
713         u8 pmkid[WMI_PMKID_LEN];
714 } __packed;
715
716 /* WMI_START_SCAN_CMD */
717 enum wmi_scan_type {
718         WMI_LONG_SCAN = 0,
719         WMI_SHORT_SCAN = 1,
720 };
721
722 struct wmi_start_scan_cmd {
723         __le32 force_fg_scan;
724
725         /* for legacy cisco AP compatibility */
726         __le32 is_legacy;
727
728         /* max duration in the home channel(msec) */
729         __le32 home_dwell_time;
730
731         /* time interval between scans (msec) */
732         __le32 force_scan_intvl;
733
734         /* enum wmi_scan_type */
735         u8 scan_type;
736
737         /* how many channels follow */
738         u8 num_ch;
739
740         /* channels in Mhz */
741         __le16 ch_list[1];
742 } __packed;
743
744 /* WMI_SET_SCAN_PARAMS_CMDID */
745 #define WMI_SHORTSCANRATIO_DEFAULT      3
746
747 /*
748  *  Warning: scan control flag value of 0xFF is used to disable
749  *  all flags in WMI_SCAN_PARAMS_CMD. Do not add any more
750  *  flags here
751  */
752 enum wmi_scan_ctrl_flags_bits {
753
754         /* set if can scan in the connect cmd */
755         CONNECT_SCAN_CTRL_FLAGS = 0x01,
756
757         /* set if scan for the SSID it is already connected to */
758         SCAN_CONNECTED_CTRL_FLAGS = 0x02,
759
760         /* set if enable active scan */
761         ACTIVE_SCAN_CTRL_FLAGS = 0x04,
762
763         /* set if enable roam scan when bmiss and lowrssi */
764         ROAM_SCAN_CTRL_FLAGS = 0x08,
765
766         /* set if follows customer BSSINFO reporting rule */
767         REPORT_BSSINFO_CTRL_FLAGS = 0x10,
768
769         /* if disabled, target doesn't scan after a disconnect event  */
770         ENABLE_AUTO_CTRL_FLAGS = 0x20,
771
772         /*
773          * Scan complete event with canceled status will be generated when
774          * a scan is prempted before it gets completed.
775          */
776         ENABLE_SCAN_ABORT_EVENT = 0x40
777 };
778
779 #define DEFAULT_SCAN_CTRL_FLAGS                 \
780         (CONNECT_SCAN_CTRL_FLAGS |              \
781          SCAN_CONNECTED_CTRL_FLAGS |            \
782          ACTIVE_SCAN_CTRL_FLAGS |               \
783          ROAM_SCAN_CTRL_FLAGS |                 \
784          ENABLE_AUTO_CTRL_FLAGS)
785
786 struct wmi_scan_params_cmd {
787           /* sec */
788         __le16 fg_start_period;
789
790         /* sec */
791         __le16 fg_end_period;
792
793         /* sec */
794         __le16 bg_period;
795
796         /* msec */
797         __le16 maxact_chdwell_time;
798
799         /* msec */
800         __le16 pas_chdwell_time;
801
802           /* how many shorts scan for one long */
803         u8 short_scan_ratio;
804
805         u8 scan_ctrl_flags;
806
807         /* msec */
808         __le16 minact_chdwell_time;
809
810         /* max active scans per ssid */
811         __le16 maxact_scan_per_ssid;
812
813         /* msecs */
814         __le32 max_dfsch_act_time;
815 } __packed;
816
817 /* WMI_SET_BSS_FILTER_CMDID */
818 enum wmi_bss_filter {
819         /* no beacons forwarded */
820         NONE_BSS_FILTER = 0x0,
821
822         /* all beacons forwarded */
823         ALL_BSS_FILTER,
824
825         /* only beacons matching profile */
826         PROFILE_FILTER,
827
828         /* all but beacons matching profile */
829         ALL_BUT_PROFILE_FILTER,
830
831         /* only beacons matching current BSS */
832         CURRENT_BSS_FILTER,
833
834         /* all but beacons matching BSS */
835         ALL_BUT_BSS_FILTER,
836
837         /* beacons matching probed ssid */
838         PROBED_SSID_FILTER,
839
840         /* marker only */
841         LAST_BSS_FILTER,
842 };
843
844 struct wmi_bss_filter_cmd {
845         /* see, enum wmi_bss_filter */
846         u8 bss_filter;
847
848         /* for alignment */
849         u8 reserved1;
850
851         /* for alignment */
852         __le16 reserved2;
853
854         __le32 ie_mask;
855 } __packed;
856
857 /* WMI_SET_PROBED_SSID_CMDID */
858 #define MAX_PROBED_SSID_INDEX   9
859
860 enum wmi_ssid_flag {
861         /* disables entry */
862         DISABLE_SSID_FLAG = 0,
863
864         /* probes specified ssid */
865         SPECIFIC_SSID_FLAG = 0x01,
866
867         /* probes for any ssid */
868         ANY_SSID_FLAG = 0x02,
869 };
870
871 struct wmi_probed_ssid_cmd {
872         /* 0 to MAX_PROBED_SSID_INDEX */
873         u8 entry_index;
874
875         /* see, enum wmi_ssid_flg */
876         u8 flag;
877
878         u8 ssid_len;
879         u8 ssid[IEEE80211_MAX_SSID_LEN];
880 } __packed;
881
882 /*
883  * WMI_SET_LISTEN_INT_CMDID
884  * The Listen interval is between 15 and 3000 TUs
885  */
886 struct wmi_listen_int_cmd {
887         __le16 listen_intvl;
888         __le16 num_beacons;
889 } __packed;
890
891 /* WMI_SET_POWER_MODE_CMDID */
892 enum wmi_power_mode {
893         REC_POWER = 0x01,
894         MAX_PERF_POWER,
895 };
896
897 struct wmi_power_mode_cmd {
898         /* see, enum wmi_power_mode */
899         u8 pwr_mode;
900 } __packed;
901
902 /*
903  * Policy to determnine whether power save failure event should be sent to
904  * host during scanning
905  */
906 enum power_save_fail_event_policy {
907         SEND_POWER_SAVE_FAIL_EVENT_ALWAYS = 1,
908         IGNORE_POWER_SAVE_FAIL_EVENT_DURING_SCAN = 2,
909 };
910
911 struct wmi_power_params_cmd {
912         /* msec */
913         __le16 idle_period;
914
915         __le16 pspoll_number;
916         __le16 dtim_policy;
917         __le16 tx_wakeup_policy;
918         __le16 num_tx_to_wakeup;
919         __le16 ps_fail_event_policy;
920 } __packed;
921
922 /* WMI_SET_DISC_TIMEOUT_CMDID */
923 struct wmi_disc_timeout_cmd {
924         /* seconds */
925         u8 discon_timeout;
926 } __packed;
927
928 enum dir_type {
929         UPLINK_TRAFFIC = 0,
930         DNLINK_TRAFFIC = 1,
931         BIDIR_TRAFFIC = 2,
932 };
933
934 enum voiceps_cap_type {
935         DISABLE_FOR_THIS_AC = 0,
936         ENABLE_FOR_THIS_AC = 1,
937         ENABLE_FOR_ALL_AC = 2,
938 };
939
940 enum traffic_type {
941         TRAFFIC_TYPE_APERIODIC = 0,
942         TRAFFIC_TYPE_PERIODIC = 1,
943 };
944
945 /* WMI_SYNCHRONIZE_CMDID */
946 struct wmi_sync_cmd {
947         u8 data_sync_map;
948 } __packed;
949
950 /* WMI_CREATE_PSTREAM_CMDID */
951 struct wmi_create_pstream_cmd {
952         /* msec */
953         __le32 min_service_int;
954
955         /* msec */
956         __le32 max_service_int;
957
958         /* msec */
959         __le32 inactivity_int;
960
961         /* msec */
962         __le32 suspension_int;
963
964         __le32 service_start_time;
965
966         /* in bps */
967         __le32 min_data_rate;
968
969         /* in bps */
970         __le32 mean_data_rate;
971
972         /* in bps */
973         __le32 peak_data_rate;
974
975         __le32 max_burst_size;
976         __le32 delay_bound;
977
978         /* in bps */
979         __le32 min_phy_rate;
980
981         __le32 sba;
982         __le32 medium_time;
983
984         /* in octects */
985         __le16 nominal_msdu;
986
987         /* in octects */
988         __le16 max_msdu;
989
990         u8 traffic_class;
991
992         /* see, enum dir_type */
993         u8 traffic_direc;
994
995         u8 rx_queue_num;
996
997         /* see, enum traffic_type */
998         u8 traffic_type;
999
1000         /* see, enum voiceps_cap_type */
1001         u8 voice_psc_cap;
1002         u8 tsid;
1003
1004         /* 802.1D user priority */
1005         u8 user_pri;
1006
1007         /* nominal phy rate */
1008         u8 nominal_phy;
1009 } __packed;
1010
1011 /* WMI_DELETE_PSTREAM_CMDID */
1012 struct wmi_delete_pstream_cmd {
1013         u8 tx_queue_num;
1014         u8 rx_queue_num;
1015         u8 traffic_direc;
1016         u8 traffic_class;
1017         u8 tsid;
1018 } __packed;
1019
1020 /* WMI_SET_CHANNEL_PARAMS_CMDID */
1021 enum wmi_phy_mode {
1022         WMI_11A_MODE = 0x1,
1023         WMI_11G_MODE = 0x2,
1024         WMI_11AG_MODE = 0x3,
1025         WMI_11B_MODE = 0x4,
1026         WMI_11GONLY_MODE = 0x5,
1027 };
1028
1029 #define WMI_MAX_CHANNELS        32
1030
1031 /*
1032  *  WMI_RSSI_THRESHOLD_PARAMS_CMDID
1033  *  Setting the polltime to 0 would disable polling. Threshold values are
1034  *  in the ascending order, and should agree to:
1035  *  (lowThreshold_lowerVal < lowThreshold_upperVal < highThreshold_lowerVal
1036  *   < highThreshold_upperVal)
1037  */
1038
1039 struct wmi_rssi_threshold_params_cmd {
1040         /* polling time as a factor of LI */
1041         __le32 poll_time;
1042
1043         /* lowest of upper */
1044         a_sle16 thresh_above1_val;
1045
1046         a_sle16 thresh_above2_val;
1047         a_sle16 thresh_above3_val;
1048         a_sle16 thresh_above4_val;
1049         a_sle16 thresh_above5_val;
1050
1051         /* highest of upper */
1052         a_sle16 thresh_above6_val;
1053
1054         /* lowest of bellow */
1055         a_sle16 thresh_below1_val;
1056
1057         a_sle16 thresh_below2_val;
1058         a_sle16 thresh_below3_val;
1059         a_sle16 thresh_below4_val;
1060         a_sle16 thresh_below5_val;
1061
1062         /* highest of bellow */
1063         a_sle16 thresh_below6_val;
1064
1065         /* "alpha" */
1066         u8 weight;
1067
1068         u8 reserved[3];
1069 } __packed;
1070
1071 /*
1072  *  WMI_SNR_THRESHOLD_PARAMS_CMDID
1073  *  Setting the polltime to 0 would disable polling.
1074  */
1075
1076 struct wmi_snr_threshold_params_cmd {
1077         /* polling time as a factor of LI */
1078         __le32 poll_time;
1079
1080         /* "alpha" */
1081         u8 weight;
1082
1083         /* lowest of uppper */
1084         u8 thresh_above1_val;
1085
1086         u8 thresh_above2_val;
1087         u8 thresh_above3_val;
1088
1089         /* highest of upper */
1090         u8 thresh_above4_val;
1091
1092         /* lowest of bellow */
1093         u8 thresh_below1_val;
1094
1095         u8 thresh_below2_val;
1096         u8 thresh_below3_val;
1097
1098         /* highest of bellow */
1099         u8 thresh_below4_val;
1100
1101         u8 reserved[3];
1102 } __packed;
1103
1104 enum wmi_preamble_policy {
1105         WMI_IGNORE_BARKER_IN_ERP = 0,
1106         WMI_DONOT_IGNORE_BARKER_IN_ERP
1107 };
1108
1109 struct wmi_set_lpreamble_cmd {
1110         u8 status;
1111         u8 preamble_policy;
1112 } __packed;
1113
1114 struct wmi_set_rts_cmd {
1115         __le16 threshold;
1116 } __packed;
1117
1118 /* WMI_SET_TX_PWR_CMDID */
1119 struct wmi_set_tx_pwr_cmd {
1120         /* in dbM units */
1121         u8 dbM;
1122 } __packed;
1123
1124 struct wmi_tx_pwr_reply {
1125         /* in dbM units */
1126         u8 dbM;
1127 } __packed;
1128
1129 struct wmi_report_sleep_state_event {
1130         __le32 sleep_state;
1131 };
1132
1133 enum wmi_report_sleep_status {
1134         WMI_REPORT_SLEEP_STATUS_IS_DEEP_SLEEP = 0,
1135         WMI_REPORT_SLEEP_STATUS_IS_AWAKE
1136 };
1137 enum target_event_report_config {
1138         /* default */
1139         DISCONN_EVT_IN_RECONN = 0,
1140
1141         NO_DISCONN_EVT_IN_RECONN
1142 };
1143
1144 /* Command Replies */
1145
1146 /* WMI_GET_CHANNEL_LIST_CMDID reply */
1147 struct wmi_channel_list_reply {
1148         u8 reserved;
1149
1150         /* number of channels in reply */
1151         u8 num_ch;
1152
1153         /* channel in Mhz */
1154         __le16 ch_list[1];
1155 } __packed;
1156
1157 /* List of Events (target to host) */
1158 enum wmi_event_id {
1159         WMI_READY_EVENTID = 0x1001,
1160         WMI_CONNECT_EVENTID,
1161         WMI_DISCONNECT_EVENTID,
1162         WMI_BSSINFO_EVENTID,
1163         WMI_CMDERROR_EVENTID,
1164         WMI_REGDOMAIN_EVENTID,
1165         WMI_PSTREAM_TIMEOUT_EVENTID,
1166         WMI_NEIGHBOR_REPORT_EVENTID,
1167         WMI_TKIP_MICERR_EVENTID,
1168         WMI_SCAN_COMPLETE_EVENTID,      /* 0x100a */
1169         WMI_REPORT_STATISTICS_EVENTID,
1170         WMI_RSSI_THRESHOLD_EVENTID,
1171         WMI_ERROR_REPORT_EVENTID,
1172         WMI_OPT_RX_FRAME_EVENTID,
1173         WMI_REPORT_ROAM_TBL_EVENTID,
1174         WMI_EXTENSION_EVENTID,
1175         WMI_CAC_EVENTID,
1176         WMI_SNR_THRESHOLD_EVENTID,
1177         WMI_LQ_THRESHOLD_EVENTID,
1178         WMI_TX_RETRY_ERR_EVENTID,       /* 0x1014 */
1179         WMI_REPORT_ROAM_DATA_EVENTID,
1180         WMI_TEST_EVENTID,
1181         WMI_APLIST_EVENTID,
1182         WMI_GET_WOW_LIST_EVENTID,
1183         WMI_GET_PMKID_LIST_EVENTID,
1184         WMI_CHANNEL_CHANGE_EVENTID,
1185         WMI_PEER_NODE_EVENTID,
1186         WMI_PSPOLL_EVENTID,
1187         WMI_DTIMEXPIRY_EVENTID,
1188         WMI_WLAN_VERSION_EVENTID,
1189         WMI_SET_PARAMS_REPLY_EVENTID,
1190         WMI_ADDBA_REQ_EVENTID,          /*0x1020 */
1191         WMI_ADDBA_RESP_EVENTID,
1192         WMI_DELBA_REQ_EVENTID,
1193         WMI_TX_COMPLETE_EVENTID,
1194         WMI_HCI_EVENT_EVENTID,
1195         WMI_ACL_DATA_EVENTID,
1196         WMI_REPORT_SLEEP_STATE_EVENTID,
1197         WMI_REPORT_BTCOEX_STATS_EVENTID,
1198         WMI_REPORT_BTCOEX_CONFIG_EVENTID,
1199         WMI_GET_PMK_EVENTID,
1200
1201         /* DFS Events */
1202         WMI_DFS_HOST_ATTACH_EVENTID,
1203         WMI_DFS_HOST_INIT_EVENTID,
1204         WMI_DFS_RESET_DELAYLINES_EVENTID,
1205         WMI_DFS_RESET_RADARQ_EVENTID,
1206         WMI_DFS_RESET_AR_EVENTID,
1207         WMI_DFS_RESET_ARQ_EVENTID,
1208         WMI_DFS_SET_DUR_MULTIPLIER_EVENTID,
1209         WMI_DFS_SET_BANGRADAR_EVENTID,
1210         WMI_DFS_SET_DEBUGLEVEL_EVENTID,
1211         WMI_DFS_PHYERR_EVENTID,
1212
1213         /* CCX Evants */
1214         WMI_CCX_RM_STATUS_EVENTID,
1215
1216         /* P2P Events */
1217         WMI_P2P_GO_NEG_RESULT_EVENTID,
1218
1219         WMI_WAC_SCAN_DONE_EVENTID,
1220         WMI_WAC_REPORT_BSS_EVENTID,
1221         WMI_WAC_START_WPS_EVENTID,
1222         WMI_WAC_CTRL_REQ_REPLY_EVENTID,
1223
1224         WMI_REPORT_WMM_PARAMS_EVENTID,
1225         WMI_WAC_REJECT_WPS_EVENTID,
1226
1227         /* More P2P Events */
1228         WMI_P2P_GO_NEG_REQ_EVENTID,
1229         WMI_P2P_INVITE_REQ_EVENTID,
1230         WMI_P2P_INVITE_RCVD_RESULT_EVENTID,
1231         WMI_P2P_INVITE_SENT_RESULT_EVENTID,
1232         WMI_P2P_PROV_DISC_RESP_EVENTID,
1233         WMI_P2P_PROV_DISC_REQ_EVENTID,
1234
1235         /* RFKILL Events */
1236         WMI_RFKILL_STATE_CHANGE_EVENTID,
1237         WMI_RFKILL_GET_MODE_CMD_EVENTID,
1238
1239         WMI_P2P_START_SDPD_EVENTID,
1240         WMI_P2P_SDPD_RX_EVENTID,
1241
1242         WMI_THIN_RESERVED_START_EVENTID = 0x8000,
1243         /* Events in this range are reserved for thinmode */
1244         WMI_THIN_RESERVED_END_EVENTID = 0x8fff,
1245
1246         WMI_SET_CHANNEL_EVENTID,
1247         WMI_ASSOC_REQ_EVENTID,
1248
1249         /* Generic ACS event */
1250         WMI_ACS_EVENTID,
1251         WMI_STORERECALL_STORE_EVENTID,
1252         WMI_WOW_EXT_WAKE_EVENTID,
1253         WMI_GTK_OFFLOAD_STATUS_EVENTID,
1254         WMI_NETWORK_LIST_OFFLOAD_EVENTID,
1255         WMI_REMAIN_ON_CHNL_EVENTID,
1256         WMI_CANCEL_REMAIN_ON_CHNL_EVENTID,
1257         WMI_TX_STATUS_EVENTID,
1258         WMI_RX_PROBE_REQ_EVENTID,
1259         WMI_P2P_CAPABILITIES_EVENTID,
1260         WMI_RX_ACTION_EVENTID,
1261         WMI_P2P_INFO_EVENTID,
1262 };
1263
1264 struct wmi_ready_event_2 {
1265         __le32 sw_version;
1266         __le32 abi_version;
1267         u8 mac_addr[ETH_ALEN];
1268         u8 phy_cap;
1269 } __packed;
1270
1271 /* Connect Event */
1272 struct wmi_connect_event {
1273         union {
1274                 struct {
1275                         __le16 ch;
1276                         u8 bssid[ETH_ALEN];
1277                         __le16 listen_intvl;
1278                         __le16 beacon_intvl;
1279                         __le32 nw_type;
1280                 } sta;
1281                 struct {
1282                         u8 phymode;
1283                         u8 aid;
1284                         u8 mac_addr[ETH_ALEN];
1285                         u8 auth;
1286                         u8 keymgmt;
1287                         __le16 cipher;
1288                         u8 apsd_info;
1289                         u8 unused[3];
1290                 } ap_sta;
1291                 struct {
1292                         __le16 ch;
1293                         u8 bssid[ETH_ALEN];
1294                         u8 unused[8];
1295                 } ap_bss;
1296         } u;
1297         u8 beacon_ie_len;
1298         u8 assoc_req_len;
1299         u8 assoc_resp_len;
1300         u8 assoc_info[1];
1301 } __packed;
1302
1303 /* Disconnect Event */
1304 enum wmi_disconnect_reason {
1305         NO_NETWORK_AVAIL = 0x01,
1306
1307         /* bmiss */
1308         LOST_LINK = 0x02,
1309
1310         DISCONNECT_CMD = 0x03,
1311         BSS_DISCONNECTED = 0x04,
1312         AUTH_FAILED = 0x05,
1313         ASSOC_FAILED = 0x06,
1314         NO_RESOURCES_AVAIL = 0x07,
1315         CSERV_DISCONNECT = 0x08,
1316         INVALID_PROFILE = 0x0a,
1317         DOT11H_CHANNEL_SWITCH = 0x0b,
1318         PROFILE_MISMATCH = 0x0c,
1319         CONNECTION_EVICTED = 0x0d,
1320         IBSS_MERGE = 0xe,
1321 };
1322
1323 #define ATH6KL_COUNTRY_RD_SHIFT        16
1324
1325 struct ath6kl_wmi_regdomain {
1326         __le32 reg_code;
1327 };
1328
1329 struct wmi_disconnect_event {
1330         /* reason code, see 802.11 spec. */
1331         __le16 proto_reason_status;
1332
1333         /* set if known */
1334         u8 bssid[ETH_ALEN];
1335
1336         /* see WMI_DISCONNECT_REASON */
1337         u8 disconn_reason;
1338
1339         u8 assoc_resp_len;
1340         u8 assoc_info[1];
1341 } __packed;
1342
1343 /*
1344  * BSS Info Event.
1345  * Mechanism used to inform host of the presence and characteristic of
1346  * wireless networks present.  Consists of bss info header followed by
1347  * the beacon or probe-response frame body.  The 802.11 header is no included.
1348  */
1349 enum wmi_bi_ftype {
1350         BEACON_FTYPE = 0x1,
1351         PROBERESP_FTYPE,
1352         ACTION_MGMT_FTYPE,
1353         PROBEREQ_FTYPE,
1354 };
1355
1356 #define DEF_LRSSI_SCAN_PERIOD            5
1357 #define DEF_LRSSI_ROAM_THRESHOLD        20
1358 #define DEF_LRSSI_ROAM_FLOOR            60
1359 #define DEF_SCAN_FOR_ROAM_INTVL          2
1360
1361 enum wmi_roam_ctrl {
1362         WMI_FORCE_ROAM = 1,
1363         WMI_SET_ROAM_MODE,
1364         WMI_SET_HOST_BIAS,
1365         WMI_SET_LRSSI_SCAN_PARAMS,
1366 };
1367
1368 struct bss_bias {
1369         u8 bssid[ETH_ALEN];
1370         u8  bias;
1371 } __packed;
1372
1373 struct bss_bias_info {
1374         u8 num_bss;
1375         struct bss_bias bss_bias[1];
1376 } __packed;
1377
1378 struct low_rssi_scan_params {
1379         __le16 lrssi_scan_period;
1380         a_sle16 lrssi_scan_threshold;
1381         a_sle16 lrssi_roam_threshold;
1382         u8 roam_rssi_floor;
1383         u8 reserved[1];
1384 } __packed;
1385
1386 struct roam_ctrl_cmd {
1387         union {
1388                 u8 bssid[ETH_ALEN];
1389                 u8 roam_mode;
1390                 struct bss_bias_info bss;
1391                 struct low_rssi_scan_params params;
1392         } __packed info;
1393         u8 roam_ctrl;
1394 } __packed;
1395
1396 /* BSS INFO HDR version 2.0 */
1397 struct wmi_bss_info_hdr2 {
1398         __le16 ch; /* frequency in MHz */
1399
1400         /* see, enum wmi_bi_ftype */
1401         u8 frame_type;
1402
1403         u8 snr; /* note: rssi = snr - 95 dBm */
1404         u8 bssid[ETH_ALEN];
1405         __le16 ie_mask;
1406 } __packed;
1407
1408 /* Command Error Event */
1409 enum wmi_error_code {
1410         INVALID_PARAM = 0x01,
1411         ILLEGAL_STATE = 0x02,
1412         INTERNAL_ERROR = 0x03,
1413 };
1414
1415 struct wmi_cmd_error_event {
1416         __le16 cmd_id;
1417         u8 err_code;
1418 } __packed;
1419
1420 struct wmi_pstream_timeout_event {
1421         u8 tx_queue_num;
1422         u8 rx_queue_num;
1423         u8 traffic_direc;
1424         u8 traffic_class;
1425 } __packed;
1426
1427 /*
1428  * The WMI_NEIGHBOR_REPORT Event is generated by the target to inform
1429  * the host of BSS's it has found that matches the current profile.
1430  * It can be used by the host to cache PMKs and/to initiate pre-authentication
1431  * if the BSS supports it.  The first bssid is always the current associated
1432  * BSS.
1433  * The bssid and bssFlags information repeats according to the number
1434  * or APs reported.
1435  */
1436 enum wmi_bss_flags {
1437         WMI_DEFAULT_BSS_FLAGS = 0x00,
1438         WMI_PREAUTH_CAPABLE_BSS = 0x01,
1439         WMI_PMKID_VALID_BSS = 0x02,
1440 };
1441
1442 struct wmi_neighbor_info {
1443         u8 bssid[ETH_ALEN];
1444         u8 bss_flags; /* enum wmi_bss_flags */
1445 } __packed;
1446
1447 struct wmi_neighbor_report_event {
1448         u8 num_neighbors;
1449         struct wmi_neighbor_info neighbor[0];
1450 } __packed;
1451
1452 /* TKIP MIC Error Event */
1453 struct wmi_tkip_micerr_event {
1454         u8 key_id;
1455         u8 is_mcast;
1456 } __packed;
1457
1458 /* WMI_SCAN_COMPLETE_EVENTID */
1459 struct wmi_scan_complete_event {
1460         a_sle32 status;
1461 } __packed;
1462
1463 #define MAX_OPT_DATA_LEN 1400
1464
1465 /*
1466  * Special frame receive Event.
1467  * Mechanism used to inform host of the receiption of the special frames.
1468  * Consists of special frame info header followed by special frame body.
1469  * The 802.11 header is not included.
1470  */
1471 struct wmi_opt_rx_info_hdr {
1472         __le16 ch;
1473         u8 frame_type;
1474         s8 snr;
1475         u8 src_addr[ETH_ALEN];
1476         u8 bssid[ETH_ALEN];
1477 } __packed;
1478
1479 /* Reporting statistic */
1480 struct tx_stats {
1481         __le32 pkt;
1482         __le32 byte;
1483         __le32 ucast_pkt;
1484         __le32 ucast_byte;
1485         __le32 mcast_pkt;
1486         __le32 mcast_byte;
1487         __le32 bcast_pkt;
1488         __le32 bcast_byte;
1489         __le32 rts_success_cnt;
1490         __le32 pkt_per_ac[4];
1491         __le32 err_per_ac[4];
1492
1493         __le32 err;
1494         __le32 fail_cnt;
1495         __le32 retry_cnt;
1496         __le32 mult_retry_cnt;
1497         __le32 rts_fail_cnt;
1498         a_sle32 ucast_rate;
1499 } __packed;
1500
1501 struct rx_stats {
1502         __le32 pkt;
1503         __le32 byte;
1504         __le32 ucast_pkt;
1505         __le32 ucast_byte;
1506         __le32 mcast_pkt;
1507         __le32 mcast_byte;
1508         __le32 bcast_pkt;
1509         __le32 bcast_byte;
1510         __le32 frgment_pkt;
1511
1512         __le32 err;
1513         __le32 crc_err;
1514         __le32 key_cache_miss;
1515         __le32 decrypt_err;
1516         __le32 dupl_frame;
1517         a_sle32 ucast_rate;
1518 } __packed;
1519
1520 struct tkip_ccmp_stats {
1521         __le32 tkip_local_mic_fail;
1522         __le32 tkip_cnter_measures_invoked;
1523         __le32 tkip_replays;
1524         __le32 tkip_fmt_err;
1525         __le32 ccmp_fmt_err;
1526         __le32 ccmp_replays;
1527 } __packed;
1528
1529 struct pm_stats {
1530         __le32 pwr_save_failure_cnt;
1531         __le16 stop_tx_failure_cnt;
1532         __le16 atim_tx_failure_cnt;
1533         __le16 atim_rx_failure_cnt;
1534         __le16 bcn_rx_failure_cnt;
1535 } __packed;
1536
1537 struct cserv_stats {
1538         __le32 cs_bmiss_cnt;
1539         __le32 cs_low_rssi_cnt;
1540         __le16 cs_connect_cnt;
1541         __le16 cs_discon_cnt;
1542         a_sle16 cs_ave_beacon_rssi;
1543         __le16 cs_roam_count;
1544         a_sle16 cs_rssi;
1545         u8 cs_snr;
1546         u8 cs_ave_beacon_snr;
1547         u8 cs_last_roam_msec;
1548 } __packed;
1549
1550 struct wlan_net_stats {
1551         struct tx_stats tx;
1552         struct rx_stats rx;
1553         struct tkip_ccmp_stats tkip_ccmp_stats;
1554 } __packed;
1555
1556 struct arp_stats {
1557         __le32 arp_received;
1558         __le32 arp_matched;
1559         __le32 arp_replied;
1560 } __packed;
1561
1562 struct wlan_wow_stats {
1563         __le32 wow_pkt_dropped;
1564         __le16 wow_evt_discarded;
1565         u8 wow_host_pkt_wakeups;
1566         u8 wow_host_evt_wakeups;
1567 } __packed;
1568
1569 struct wmi_target_stats {
1570         __le32 lq_val;
1571         a_sle32 noise_floor_calib;
1572         struct pm_stats pm_stats;
1573         struct wlan_net_stats stats;
1574         struct wlan_wow_stats wow_stats;
1575         struct arp_stats arp_stats;
1576         struct cserv_stats cserv_stats;
1577 } __packed;
1578
1579 /*
1580  * WMI_RSSI_THRESHOLD_EVENTID.
1581  * Indicate the RSSI events to host. Events are indicated when we breach a
1582  * thresold value.
1583  */
1584 enum wmi_rssi_threshold_val {
1585         WMI_RSSI_THRESHOLD1_ABOVE = 0,
1586         WMI_RSSI_THRESHOLD2_ABOVE,
1587         WMI_RSSI_THRESHOLD3_ABOVE,
1588         WMI_RSSI_THRESHOLD4_ABOVE,
1589         WMI_RSSI_THRESHOLD5_ABOVE,
1590         WMI_RSSI_THRESHOLD6_ABOVE,
1591         WMI_RSSI_THRESHOLD1_BELOW,
1592         WMI_RSSI_THRESHOLD2_BELOW,
1593         WMI_RSSI_THRESHOLD3_BELOW,
1594         WMI_RSSI_THRESHOLD4_BELOW,
1595         WMI_RSSI_THRESHOLD5_BELOW,
1596         WMI_RSSI_THRESHOLD6_BELOW
1597 };
1598
1599 struct wmi_rssi_threshold_event {
1600         a_sle16 rssi;
1601         u8 range;
1602 } __packed;
1603
1604 enum wmi_snr_threshold_val {
1605         WMI_SNR_THRESHOLD1_ABOVE = 1,
1606         WMI_SNR_THRESHOLD1_BELOW,
1607         WMI_SNR_THRESHOLD2_ABOVE,
1608         WMI_SNR_THRESHOLD2_BELOW,
1609         WMI_SNR_THRESHOLD3_ABOVE,
1610         WMI_SNR_THRESHOLD3_BELOW,
1611         WMI_SNR_THRESHOLD4_ABOVE,
1612         WMI_SNR_THRESHOLD4_BELOW
1613 };
1614
1615 struct wmi_snr_threshold_event {
1616         /* see, enum wmi_snr_threshold_val */
1617         u8 range;
1618
1619         u8 snr;
1620 } __packed;
1621
1622 /* WMI_REPORT_ROAM_TBL_EVENTID */
1623 #define MAX_ROAM_TBL_CAND   5
1624
1625 struct wmi_bss_roam_info {
1626         a_sle32 roam_util;
1627         u8 bssid[ETH_ALEN];
1628         s8 rssi;
1629         s8 rssidt;
1630         s8 last_rssi;
1631         s8 util;
1632         s8 bias;
1633
1634         /* for alignment */
1635         u8 reserved;
1636 } __packed;
1637
1638 /* WMI_CAC_EVENTID */
1639 enum cac_indication {
1640         CAC_INDICATION_ADMISSION = 0x00,
1641         CAC_INDICATION_ADMISSION_RESP = 0x01,
1642         CAC_INDICATION_DELETE = 0x02,
1643         CAC_INDICATION_NO_RESP = 0x03,
1644 };
1645
1646 #define WMM_TSPEC_IE_LEN   63
1647
1648 struct wmi_cac_event {
1649         u8 ac;
1650         u8 cac_indication;
1651         u8 status_code;
1652         u8 tspec_suggestion[WMM_TSPEC_IE_LEN];
1653 } __packed;
1654
1655 /* WMI_APLIST_EVENTID */
1656
1657 enum aplist_ver {
1658         APLIST_VER1 = 1,
1659 };
1660
1661 struct wmi_ap_info_v1 {
1662         u8 bssid[ETH_ALEN];
1663         __le16 channel;
1664 } __packed;
1665
1666 union wmi_ap_info {
1667         struct wmi_ap_info_v1 ap_info_v1;
1668 } __packed;
1669
1670 struct wmi_aplist_event {
1671         u8 ap_list_ver;
1672         u8 num_ap;
1673         union wmi_ap_info ap_list[1];
1674 } __packed;
1675
1676 /* Developer Commands */
1677
1678 /*
1679  * WMI_SET_BITRATE_CMDID
1680  *
1681  * Get bit rate cmd uses same definition as set bit rate cmd
1682  */
1683 enum wmi_bit_rate {
1684         RATE_AUTO = -1,
1685         RATE_1Mb = 0,
1686         RATE_2Mb = 1,
1687         RATE_5_5Mb = 2,
1688         RATE_11Mb = 3,
1689         RATE_6Mb = 4,
1690         RATE_9Mb = 5,
1691         RATE_12Mb = 6,
1692         RATE_18Mb = 7,
1693         RATE_24Mb = 8,
1694         RATE_36Mb = 9,
1695         RATE_48Mb = 10,
1696         RATE_54Mb = 11,
1697         RATE_MCS_0_20 = 12,
1698         RATE_MCS_1_20 = 13,
1699         RATE_MCS_2_20 = 14,
1700         RATE_MCS_3_20 = 15,
1701         RATE_MCS_4_20 = 16,
1702         RATE_MCS_5_20 = 17,
1703         RATE_MCS_6_20 = 18,
1704         RATE_MCS_7_20 = 19,
1705         RATE_MCS_0_40 = 20,
1706         RATE_MCS_1_40 = 21,
1707         RATE_MCS_2_40 = 22,
1708         RATE_MCS_3_40 = 23,
1709         RATE_MCS_4_40 = 24,
1710         RATE_MCS_5_40 = 25,
1711         RATE_MCS_6_40 = 26,
1712         RATE_MCS_7_40 = 27,
1713 };
1714
1715 struct wmi_bit_rate_reply {
1716         /* see, enum wmi_bit_rate */
1717         s8 rate_index;
1718 } __packed;
1719
1720 /*
1721  * WMI_SET_FIXRATES_CMDID
1722  *
1723  * Get fix rates cmd uses same definition as set fix rates cmd
1724  */
1725 struct wmi_fix_rates_reply {
1726         /* see wmi_bit_rate */
1727         __le32 fix_rate_mask;
1728 } __packed;
1729
1730 enum roam_data_type {
1731         /* get the roam time data */
1732         ROAM_DATA_TIME = 1,
1733 };
1734
1735 struct wmi_target_roam_time {
1736         __le32 disassoc_time;
1737         __le32 no_txrx_time;
1738         __le32 assoc_time;
1739         __le32 allow_txrx_time;
1740         u8 disassoc_bssid[ETH_ALEN];
1741         s8 disassoc_bss_rssi;
1742         u8 assoc_bssid[ETH_ALEN];
1743         s8 assoc_bss_rssi;
1744 } __packed;
1745
1746 enum wmi_txop_cfg {
1747         WMI_TXOP_DISABLED = 0,
1748         WMI_TXOP_ENABLED
1749 };
1750
1751 struct wmi_set_wmm_txop_cmd {
1752         u8 txop_enable;
1753 } __packed;
1754
1755 struct wmi_set_keepalive_cmd {
1756         u8 keep_alive_intvl;
1757 } __packed;
1758
1759 struct wmi_get_keepalive_cmd {
1760         __le32 configured;
1761         u8 keep_alive_intvl;
1762 } __packed;
1763
1764 struct wmi_set_appie_cmd {
1765         u8 mgmt_frm_type; /* enum wmi_mgmt_frame_type */
1766         u8 ie_len;
1767         u8 ie_info[0];
1768 } __packed;
1769
1770 /* Notify the WSC registration status to the target */
1771 #define WSC_REG_ACTIVE     1
1772 #define WSC_REG_INACTIVE   0
1773
1774 #define WOW_MAX_FILTER_LISTS     1
1775 #define WOW_MAX_FILTERS_PER_LIST 4
1776 #define WOW_PATTERN_SIZE         64
1777 #define WOW_MASK_SIZE            64
1778
1779 #define MAC_MAX_FILTERS_PER_LIST 4
1780
1781 struct wow_filter {
1782         u8 wow_valid_filter;
1783         u8 wow_filter_id;
1784         u8 wow_filter_size;
1785         u8 wow_filter_offset;
1786         u8 wow_filter_mask[WOW_MASK_SIZE];
1787         u8 wow_filter_pattern[WOW_PATTERN_SIZE];
1788 } __packed;
1789
1790 #define MAX_IP_ADDRS  2
1791
1792 struct wmi_set_ip_cmd {
1793         /* IP in network byte order */
1794         __le32 ips[MAX_IP_ADDRS];
1795 } __packed;
1796
1797 /* WMI_GET_WOW_LIST_CMD reply  */
1798 struct wmi_get_wow_list_reply {
1799         /* number of patterns in reply */
1800         u8 num_filters;
1801
1802         /* this is filter # x of total num_filters */
1803         u8 this_filter_num;
1804
1805         u8 wow_mode;
1806         u8 host_mode;
1807         struct wow_filter wow_filters[1];
1808 } __packed;
1809
1810 /* WMI_SET_AKMP_PARAMS_CMD */
1811
1812 struct wmi_pmkid {
1813         u8 pmkid[WMI_PMKID_LEN];
1814 } __packed;
1815
1816 /* WMI_GET_PMKID_LIST_CMD  Reply */
1817 struct wmi_pmkid_list_reply {
1818         __le32 num_pmkid;
1819         u8 bssid_list[ETH_ALEN][1];
1820         struct wmi_pmkid pmkid_list[1];
1821 } __packed;
1822
1823 /* WMI_ADDBA_REQ_EVENTID */
1824 struct wmi_addba_req_event {
1825         u8 tid;
1826         u8 win_sz;
1827         __le16 st_seq_no;
1828
1829         /* f/w response for ADDBA Req; OK (0) or failure (!=0) */
1830         u8 status;
1831 } __packed;
1832
1833 /* WMI_ADDBA_RESP_EVENTID */
1834 struct wmi_addba_resp_event {
1835         u8 tid;
1836
1837         /* OK (0), failure (!=0) */
1838         u8 status;
1839
1840         /* three values: not supported(0), 3839, 8k */
1841         __le16 amsdu_sz;
1842 } __packed;
1843
1844 /* WMI_DELBA_EVENTID
1845  * f/w received a DELBA for peer and processed it.
1846  * Host is notified of this
1847  */
1848 struct wmi_delba_event {
1849         u8 tid;
1850         u8 is_peer_initiator;
1851         __le16 reason_code;
1852 } __packed;
1853
1854 #define PEER_NODE_JOIN_EVENT            0x00
1855 #define PEER_NODE_LEAVE_EVENT           0x01
1856 #define PEER_FIRST_NODE_JOIN_EVENT      0x10
1857 #define PEER_LAST_NODE_LEAVE_EVENT      0x11
1858
1859 struct wmi_peer_node_event {
1860         u8 event_code;
1861         u8 peer_mac_addr[ETH_ALEN];
1862 } __packed;
1863
1864 /* Transmit complete event data structure(s) */
1865
1866 /* version 1 of tx complete msg */
1867 struct tx_complete_msg_v1 {
1868 #define TX_COMPLETE_STATUS_SUCCESS 0
1869 #define TX_COMPLETE_STATUS_RETRIES 1
1870 #define TX_COMPLETE_STATUS_NOLINK  2
1871 #define TX_COMPLETE_STATUS_TIMEOUT 3
1872 #define TX_COMPLETE_STATUS_OTHER   4
1873
1874         u8 status;
1875
1876         /* packet ID to identify parent packet */
1877         u8 pkt_id;
1878
1879         /* rate index on successful transmission */
1880         u8 rate_idx;
1881
1882         /* number of ACK failures in tx attempt */
1883         u8 ack_failures;
1884 } __packed;
1885
1886 struct wmi_tx_complete_event {
1887         /* no of tx comp msgs following this struct */
1888         u8 num_msg;
1889
1890         /* length in bytes for each individual msg following this struct */
1891         u8 msg_len;
1892
1893         /* version of tx complete msg data following this struct */
1894         u8 msg_type;
1895
1896         /* individual messages follow this header */
1897         u8 reserved;
1898 } __packed;
1899
1900 /*
1901  * ------- AP Mode definitions --------------
1902  */
1903
1904 /*
1905  * !!! Warning !!!
1906  * -Changing the following values needs compilation of both driver and firmware
1907  */
1908 #define AP_MAX_NUM_STA          8
1909
1910 /* Spl. AID used to set DTIM flag in the beacons */
1911 #define MCAST_AID               0xFF
1912
1913 #define DEF_AP_COUNTRY_CODE     "US "
1914
1915 /* Used with WMI_AP_SET_NUM_STA_CMDID */
1916
1917 /*
1918  * Used with WMI_AP_SET_MLME_CMDID
1919  */
1920
1921 /* MLME Commands */
1922 #define WMI_AP_MLME_ASSOC       1   /* associate station */
1923 #define WMI_AP_DISASSOC         2   /* disassociate station */
1924 #define WMI_AP_DEAUTH           3   /* deauthenticate station */
1925 #define WMI_AP_MLME_AUTHORIZE   4   /* authorize station */
1926 #define WMI_AP_MLME_UNAUTHORIZE 5   /* unauthorize station */
1927
1928 struct wmi_ap_set_mlme_cmd {
1929         u8 mac[ETH_ALEN];
1930         __le16 reason;          /* 802.11 reason code */
1931         u8 cmd;                 /* operation to perform (WMI_AP_*) */
1932 } __packed;
1933
1934 struct wmi_ap_set_pvb_cmd {
1935         __le32 flag;
1936         __le16 rsvd;
1937         __le16 aid;
1938 } __packed;
1939
1940 struct wmi_rx_frame_format_cmd {
1941         /* version of meta data for rx packets <0 = default> (0-7 = valid) */
1942         u8 meta_ver;
1943
1944         /*
1945          * 1 == leave .11 header intact,
1946          * 0 == replace .11 header with .3 <default>
1947          */
1948         u8 dot11_hdr;
1949
1950         /*
1951          * 1 == defragmentation is performed by host,
1952          * 0 == performed by target <default>
1953          */
1954         u8 defrag_on_host;
1955
1956         /* for alignment */
1957         u8 reserved[1];
1958 } __packed;
1959
1960 /* AP mode events */
1961
1962 /* WMI_PS_POLL_EVENT */
1963 struct wmi_pspoll_event {
1964         __le16 aid;
1965 } __packed;
1966
1967 struct wmi_per_sta_stat {
1968         __le32 tx_bytes;
1969         __le32 tx_pkts;
1970         __le32 tx_error;
1971         __le32 tx_discard;
1972         __le32 rx_bytes;
1973         __le32 rx_pkts;
1974         __le32 rx_error;
1975         __le32 rx_discard;
1976         __le32 aid;
1977 } __packed;
1978
1979 struct wmi_ap_mode_stat {
1980         __le32 action;
1981         struct wmi_per_sta_stat sta[AP_MAX_NUM_STA + 1];
1982 } __packed;
1983
1984 /* End of AP mode definitions */
1985
1986 struct wmi_remain_on_chnl_cmd {
1987         __le32 freq;
1988         __le32 duration;
1989 } __packed;
1990
1991 struct wmi_send_action_cmd {
1992         __le32 id;
1993         __le32 freq;
1994         __le32 wait;
1995         __le16 len;
1996         u8 data[0];
1997 } __packed;
1998
1999 struct wmi_tx_status_event {
2000         __le32 id;
2001         u8 ack_status;
2002 } __packed;
2003
2004 struct wmi_probe_req_report_cmd {
2005         u8 enable;
2006 } __packed;
2007
2008 struct wmi_disable_11b_rates_cmd {
2009         u8 disable;
2010 } __packed;
2011
2012 struct wmi_set_appie_extended_cmd {
2013         u8 role_id;
2014         u8 mgmt_frm_type;
2015         u8 ie_len;
2016         u8 ie_info[0];
2017 } __packed;
2018
2019 struct wmi_remain_on_chnl_event {
2020         __le32 freq;
2021         __le32 duration;
2022 } __packed;
2023
2024 struct wmi_cancel_remain_on_chnl_event {
2025         __le32 freq;
2026         __le32 duration;
2027         u8 status;
2028 } __packed;
2029
2030 struct wmi_rx_action_event {
2031         __le32 freq;
2032         __le16 len;
2033         u8 data[0];
2034 } __packed;
2035
2036 struct wmi_p2p_capabilities_event {
2037         __le16 len;
2038         u8 data[0];
2039 } __packed;
2040
2041 struct wmi_p2p_rx_probe_req_event {
2042         __le32 freq;
2043         __le16 len;
2044         u8 data[0];
2045 } __packed;
2046
2047 #define P2P_FLAG_CAPABILITIES_REQ   (0x00000001)
2048 #define P2P_FLAG_MACADDR_REQ        (0x00000002)
2049 #define P2P_FLAG_HMODEL_REQ         (0x00000002)
2050
2051 struct wmi_get_p2p_info {
2052         __le32 info_req_flags;
2053 } __packed;
2054
2055 struct wmi_p2p_info_event {
2056         __le32 info_req_flags;
2057         __le16 len;
2058         u8 data[0];
2059 } __packed;
2060
2061 struct wmi_p2p_capabilities {
2062         u8 go_power_save;
2063 } __packed;
2064
2065 struct wmi_p2p_macaddr {
2066         u8 mac_addr[ETH_ALEN];
2067 } __packed;
2068
2069 struct wmi_p2p_hmodel {
2070         u8 p2p_model;
2071 } __packed;
2072
2073 struct wmi_p2p_probe_response_cmd {
2074         __le32 freq;
2075         u8 destination_addr[ETH_ALEN];
2076         __le16 len;
2077         u8 data[0];
2078 } __packed;
2079
2080 /* Extended WMI (WMIX)
2081  *
2082  * Extended WMIX commands are encapsulated in a WMI message with
2083  * cmd=WMI_EXTENSION_CMD.
2084  *
2085  * Extended WMI commands are those that are needed during wireless
2086  * operation, but which are not really wireless commands.  This allows,
2087  * for instance, platform-specific commands.  Extended WMI commands are
2088  * embedded in a WMI command message with WMI_COMMAND_ID=WMI_EXTENSION_CMDID.
2089  * Extended WMI events are similarly embedded in a WMI event message with
2090  * WMI_EVENT_ID=WMI_EXTENSION_EVENTID.
2091  */
2092 struct wmix_cmd_hdr {
2093         __le32 cmd_id;
2094 } __packed;
2095
2096 enum wmix_command_id {
2097         WMIX_DSETOPEN_REPLY_CMDID = 0x2001,
2098         WMIX_DSETDATA_REPLY_CMDID,
2099         WMIX_GPIO_OUTPUT_SET_CMDID,
2100         WMIX_GPIO_INPUT_GET_CMDID,
2101         WMIX_GPIO_REGISTER_SET_CMDID,
2102         WMIX_GPIO_REGISTER_GET_CMDID,
2103         WMIX_GPIO_INTR_ACK_CMDID,
2104         WMIX_HB_CHALLENGE_RESP_CMDID,
2105         WMIX_DBGLOG_CFG_MODULE_CMDID,
2106         WMIX_PROF_CFG_CMDID,    /* 0x200a */
2107         WMIX_PROF_ADDR_SET_CMDID,
2108         WMIX_PROF_START_CMDID,
2109         WMIX_PROF_STOP_CMDID,
2110         WMIX_PROF_COUNT_GET_CMDID,
2111 };
2112
2113 enum wmix_event_id {
2114         WMIX_DSETOPENREQ_EVENTID = 0x3001,
2115         WMIX_DSETCLOSE_EVENTID,
2116         WMIX_DSETDATAREQ_EVENTID,
2117         WMIX_GPIO_INTR_EVENTID,
2118         WMIX_GPIO_DATA_EVENTID,
2119         WMIX_GPIO_ACK_EVENTID,
2120         WMIX_HB_CHALLENGE_RESP_EVENTID,
2121         WMIX_DBGLOG_EVENTID,
2122         WMIX_PROF_COUNT_EVENTID,
2123 };
2124
2125 /*
2126  * ------Error Detection support-------
2127  */
2128
2129 /*
2130  * WMIX_HB_CHALLENGE_RESP_CMDID
2131  * Heartbeat Challenge Response command
2132  */
2133 struct wmix_hb_challenge_resp_cmd {
2134         __le32 cookie;
2135         __le32 source;
2136 } __packed;
2137
2138 struct ath6kl_wmix_dbglog_cfg_module_cmd {
2139         __le32 valid;
2140         __le32 config;
2141 } __packed;
2142
2143 /* End of Extended WMI (WMIX) */
2144
2145 enum wmi_sync_flag {
2146         NO_SYNC_WMIFLAG = 0,
2147
2148         /* transmit all queued data before cmd */
2149         SYNC_BEFORE_WMIFLAG,
2150
2151         /* any new data waits until cmd execs */
2152         SYNC_AFTER_WMIFLAG,
2153
2154         SYNC_BOTH_WMIFLAG,
2155
2156         /* end marker */
2157         END_WMIFLAG
2158 };
2159
2160 enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi);
2161 void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id);
2162 int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb);
2163 int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb,
2164                             u8 msg_type, bool more_data,
2165                             enum wmi_data_hdr_data_type data_type,
2166                             u8 meta_ver, void *tx_meta_info);
2167
2168 int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb);
2169 int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb);
2170 int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb,
2171                                        u32 layer2_priority, bool wmm_enabled,
2172                                        u8 *ac);
2173
2174 int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb);
2175
2176 int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb,
2177                         enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag);
2178
2179 int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type,
2180                            enum dot11_auth_mode dot11_auth_mode,
2181                            enum auth_mode auth_mode,
2182                            enum crypto_type pairwise_crypto,
2183                            u8 pairwise_crypto_len,
2184                            enum crypto_type group_crypto,
2185                            u8 group_crypto_len, int ssid_len, u8 *ssid,
2186                            u8 *bssid, u16 channel, u32 ctrl_flags);
2187
2188 int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel);
2189 int ath6kl_wmi_disconnect_cmd(struct wmi *wmi);
2190 int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type,
2191                              u32 force_fgscan, u32 is_legacy,
2192                              u32 home_dwell_time, u32 force_scan_interval,
2193                              s8 num_chan, u16 *ch_list);
2194 int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec,
2195                               u16 fg_end_sec, u16 bg_sec,
2196                               u16 minact_chdw_msec, u16 maxact_chdw_msec,
2197                               u16 pas_chdw_msec, u8 short_scan_ratio,
2198                               u8 scan_ctrl_flag, u32 max_dfsch_act_time,
2199                               u16 maxact_scan_per_ssid);
2200 int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask);
2201 int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag,
2202                               u8 ssid_len, u8 *ssid);
2203 int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval,
2204                                   u16 listen_beacons);
2205 int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode);
2206 int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period,
2207                             u16 ps_poll_num, u16 dtim_policy,
2208                             u16 tx_wakup_policy, u16 num_tx_to_wakeup,
2209                             u16 ps_fail_event_policy);
2210 int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout);
2211 int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi,
2212                                   struct wmi_create_pstream_cmd *pstream);
2213 int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid);
2214
2215 int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold);
2216 int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status,
2217                                  u8 preamble_policy);
2218
2219 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source);
2220 int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config);
2221
2222 int ath6kl_wmi_get_stats_cmd(struct wmi *wmi);
2223 int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index,
2224                           enum crypto_type key_type,
2225                           u8 key_usage, u8 key_len,
2226                           u8 *key_rsc, u8 *key_material,
2227                           u8 key_op_ctrl, u8 *mac_addr,
2228                           enum wmi_sync_flag sync_flag);
2229 int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk);
2230 int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index);
2231 int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid,
2232                             const u8 *pmkid, bool set);
2233 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM);
2234 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi);
2235
2236 int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg);
2237 int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl);
2238 int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len);
2239
2240 s32 ath6kl_wmi_get_rate(s8 rate_index);
2241
2242 int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd);
2243 int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi);
2244
2245 /* AP mode */
2246 int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p);
2247
2248 int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason);
2249
2250 int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag);
2251
2252 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_version,
2253                                        bool rx_dot11_hdr, bool defrag_on_host);
2254
2255 int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie,
2256                              u8 ie_len);
2257
2258 /* P2P */
2259 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable);
2260
2261 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur);
2262
2263 int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait,
2264                                const u8 *data, u16 data_len);
2265
2266 int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq,
2267                                        const u8 *dst,
2268                                        const u8 *data, u16 data_len);
2269
2270 int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable);
2271
2272 int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags);
2273
2274 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi);
2275
2276 int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie,
2277                              u8 ie_len);
2278
2279 void *ath6kl_wmi_init(struct ath6kl *devt);
2280 void ath6kl_wmi_shutdown(struct wmi *wmi);
2281
2282 #endif /* WMI_H */