47bf4a7d2fa070878cbf209a6c9f9a3b678a3356
[open-ath9k-htc-firmware.git] / target_firmware / wlan / include / wmi.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 /*
37  * This file contains the definitions of the WMI protocol specified in the
38  * Wireless Module Interface (WMI).  It includes definitions of all the
39  * commands and events. Commands are messages from the host to the WM.
40  * Events and Replies are messages from the WM to the host.
41  *
42  * Ownership of correctness in regards to WMI commands
43  * belongs to the host driver and the WM is not required to validate
44  * parameters for value, proper range, or any other checking.
45  *
46  * $Id: //depot/sw/branches/fusion_usb/target_firmware/wlan/include/wmi.h#6 $
47  */
48
49 #ifndef _WMI_H_
50 #define _WMI_H_
51
52 #include "athdefs.h"
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 #define HTC_PROTOCOL_VERSION    0x0002
59 #define HTC_PROTOCOL_REVISION   0x0000
60
61 #define WMI_PROTOCOL_VERSION    0x0002
62 #define WMI_PROTOCOL_REVISION   0x0000
63
64 #define ATH_MAC_LEN             6               /* length of mac in bytes */
65 #define WMI_CMD_MAX_LEN         100
66 #define WMI_CONTROL_MSG_MAX_LEN     256
67 #define WMI_OPT_CONTROL_MSG_MAX_LEN 1536
68 #define IS_ETHERTYPE(_typeOrLen)        ((_typeOrLen) >= 0x0600)
69 #define RFC1042OUI      {0x00, 0x00, 0x00}
70
71 #define IP_ETHERTYPE 0x0800
72
73 #define WMI_IMPLICIT_PSTREAM 0xFF
74 #define WMI_MAX_THINSTREAM 15
75
76 struct host_app_area_s {
77     a_uint32_t wmi_protocol_ver;
78 };
79
80 /*
81  * Data Path
82  */
83 typedef PREPACK struct {
84     a_uint8_t     dstMac[ATH_MAC_LEN];
85     a_uint8_t     srcMac[ATH_MAC_LEN];
86     a_uint16_t    typeOrLen;
87 } POSTPACK ATH_MAC_HDR;
88
89 typedef PREPACK struct {
90     a_uint8_t     dsap;
91     a_uint8_t     ssap;
92     a_uint8_t     cntl;
93     a_uint8_t     orgCode[3];
94     a_uint16_t    etherType;
95 } POSTPACK ATH_LLC_SNAP_HDR;
96
97 typedef enum {
98     DATA_MSGTYPE = 0x0,
99     CNTL_MSGTYPE,
100     SYNC_MSGTYPE,
101     OPT_MSGTYPE,
102 } WMI_MSG_TYPE;
103
104
105 typedef PREPACK struct {
106     a_int8_t      rssi;            
107     a_uint8_t     info;            /* WMI_MSG_TYPE in lower 2 bits - b1b0 */
108                                  /* UP in next 3 bits - b4b3b2 */
109 #define WMI_DATA_HDR_MSG_TYPE_MASK  0x03
110 #define WMI_DATA_HDR_MSG_TYPE_SHIFT 0
111 #define WMI_DATA_HDR_UP_MASK        0x07
112 #define WMI_DATA_HDR_UP_SHIFT       2   
113 #define WMI_DATA_HDR_IS_MSG_TYPE(h, t)  (((h)->info & (WMI_DATA_HDR_MSG_TYPE_MASK)) == (t))
114 } POSTPACK WMI_DATA_HDR;
115
116
117 #define WMI_DATA_HDR_SET_MSG_TYPE(h, t) (h)->info = (((h)->info & ~(WMI_DATA_HDR_MSG_TYPE_MASK << WMI_DATA_HDR_MSG_TYPE_SHIFT)) | (t << WMI_DATA_HDR_MSG_TYPE_SHIFT))
118 #define WMI_DATA_HDR_SET_UP(h, p) (h)->info = (((h)->info & ~(WMI_DATA_HDR_UP_MASK << WMI_DATA_HDR_UP_SHIFT)) | (p << WMI_DATA_HDR_UP_SHIFT))
119
120 /*
121  * Control Path
122  */
123 typedef PREPACK struct {
124     a_uint16_t    commandId;
125     a_uint16_t    seqNo;
126 } POSTPACK WMI_CMD_HDR;        /* used for commands and events */
127
128 /*
129  * List of Commnands
130  */
131 typedef enum {
132     WMI_ECHO_CMDID           = 0x0001,
133     WMI_ACCESS_MEMORY_CMDID,
134
135     /* Commands to Target */
136     WMI_GET_FW_VERSION,
137     WMI_DISABLE_INTR_CMDID,
138     WMI_ENABLE_INTR_CMDID,
139     WMI_ATH_INIT_CMDID,
140     WMI_ABORT_TXQ_CMDID,
141     WMI_STOP_TX_DMA_CMDID,
142     WMI_ABORT_TX_DMA_CMDID,
143     WMI_DRAIN_TXQ_CMDID,
144     WMI_DRAIN_TXQ_ALL_CMDID,
145     WMI_START_RECV_CMDID,
146     WMI_STOP_RECV_CMDID,
147     WMI_FLUSH_RECV_CMDID,
148     WMI_SET_MODE_CMDID,
149     WMI_NODE_CREATE_CMDID,
150     WMI_NODE_REMOVE_CMDID,
151     WMI_VAP_REMOVE_CMDID,
152     WMI_VAP_CREATE_CMDID,
153     WMI_REG_READ_CMDID,
154     WMI_REG_WRITE_CMDID,
155     WMI_RC_STATE_CHANGE_CMDID,
156     WMI_RC_RATE_UPDATE_CMDID,
157     WMI_TARGET_IC_UPDATE_CMDID,
158     WMI_TX_AGGR_ENABLE_CMDID,
159     WMI_TGT_DETACH_CMDID,
160     WMI_NODE_UPDATE_CMDID,
161     WMI_INT_STATS_CMDID,
162     WMI_TX_STATS_CMDID,
163     WMI_RX_STATS_CMDID,
164     WMI_BITRATE_MASK_CMDID,
165 } WMI_COMMAND_ID;
166
167 /*
168  * Frame Types
169  */
170 typedef enum {
171     WMI_FRAME_BEACON        =   0,
172     WMI_FRAME_PROBE_REQ,
173     WMI_FRAME_PROBE_RESP,
174     WMI_FRAME_ASSOC_REQ,
175     WMI_FRAME_ASSOC_RESP,
176     WMI_NUM_MGMT_FRAME 
177 } WMI_MGMT_FRAME_TYPE;
178
179 /*
180  * Connect Command
181  */
182 typedef enum {
183     INFRA_NETWORK       = 0x01,
184     ADHOC_NETWORK       = 0x02,
185     ADHOC_CREATOR       = 0x04,
186     OPT_NETWORK         = 0x08,
187 } NETWORK_TYPE;
188
189 typedef enum {
190     OPEN_AUTH           = 0x01,
191     SHARED_AUTH         = 0x02,
192     LEAP_AUTH           = 0x04,  /* different from IEEE_AUTH_MODE definitions */
193 } DOT11_AUTH_MODE;
194
195 typedef enum {
196     NONE_AUTH           = 0x01, 
197     WPA_AUTH            = 0x02,
198     WPA_PSK_AUTH        = 0x03,
199     WPA2_AUTH           = 0x04,
200     WPA2_PSK_AUTH       = 0x05,
201     WPA_AUTH_CCKM       = 0x06,
202     WPA2_AUTH_CCKM      = 0x07,
203 } AUTH_MODE;
204
205 typedef enum {
206     NONE_CRYPT          = 0x01,
207     WEP_CRYPT           = 0x02,
208     TKIP_CRYPT          = 0x03,
209     AES_CRYPT           = 0x04,
210 } CRYPTO_TYPE;
211
212 #define WMI_MIN_CRYPTO_TYPE NONE_CRYPT
213 #define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1)
214
215 #define WMI_MIN_KEY_INDEX   0
216 #define WMI_MAX_KEY_INDEX   3
217
218 #define WMI_MAX_KEY_LEN     32
219
220 #define WMI_MAX_SSID_LEN    32
221
222 typedef enum {
223     CONNECT_ASSOC_POLICY_USER = 0x0001,
224     CONNECT_SEND_REASSOC = 0x0002,
225     CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004,
226     CONNECT_PROFILE_MATCH_DONE = 0x0008,
227     CONNECT_IGNORE_AAC_BEACON = 0x0010,
228     CONNECT_CSA_FOLLOW_BSS = 0x0020,
229 } WMI_CONNECT_CTRL_FLAGS_BITS;
230
231 #define DEFAULT_CONNECT_CTRL_FLAGS    (CONNECT_CSA_FOLLOW_BSS)
232
233 /*
234  * WMI_ECHO_CMDID
235  */
236 #define WMI_ECHOCMD_MSG_MAX_LEN         53//64 - HTC_HDR_LENGTH + sizeof(WMI_CMD_HDR) - 1
237
238 typedef PREPACK struct {
239     a_uint8_t     msgSize;
240     a_uint8_t     msgData[1];
241 } POSTPACK WMI_ECHO_CMD;
242
243 /*
244  * WMI_ACCESS_MEMORY_CMDID
245  */
246 #define WMI_ACCESS_MEMORY_MAX_TUPLES    8
247
248 typedef PREPACK struct {
249     a_uint16_t    addressL;
250     a_uint16_t    addressH;
251     a_uint16_t    valueL;
252     a_uint16_t    valueH;
253 } POSTPACK WMI_AVT;
254
255 typedef PREPACK struct {
256     a_uint16_t     tupleNumL;
257     a_uint16_t     tupleNumH;
258     WMI_AVT      avt[1];
259 } POSTPACK WMI_ACCESS_MEMORY_CMD;
260
261 /*
262  * List of Events (target to host)
263  */
264 typedef enum {
265     WMI_TGT_RDY_EVENTID           = 0x1001,
266     WMI_SWBA_EVENTID,
267     WMI_FATAL_EVENTID,
268     WMI_TXTO_EVENTID,
269     WMI_BMISS_EVENTID,
270     WMI_DELBA_EVENTID,
271     WMI_TXSTATUS_EVENTID
272 } WMI_EVENT_ID;
273
274 typedef PREPACK struct {
275         a_uint64_t tsf;
276         a_uint8_t beaconPendingCount;
277 } POSTPACK WMI_SWBA_EVENT;
278
279 typedef PREPACK struct {
280         a_uint8_t    cookie;
281         a_uint8_t    ts_rate;
282         a_uint8_t    ts_flags;
283 } POSTPACK __WMI_TXSTATUS_EVENT;
284
285 #define HTC_MAX_TX_STATUS 12
286
287 typedef PREPACK struct {
288         a_uint8_t cnt;
289         __WMI_TXSTATUS_EVENT txstatus[HTC_MAX_TX_STATUS];
290 } POSTPACK WMI_TXSTATUS_EVENT;
291
292 #ifndef ATH_TARGET
293 //#include "athendpack.h"
294 #endif
295
296 #ifdef __cplusplus
297 }
298 #endif
299
300 #endif /* _WMI_H_ */