Setting up repository
[linux-libre-firmware.git] / ath9k_htc / 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_REG_RMW_CMDID,
166 } WMI_COMMAND_ID;
167
168 /*
169  * Frame Types
170  */
171 typedef enum {
172     WMI_FRAME_BEACON        =   0,
173     WMI_FRAME_PROBE_REQ,
174     WMI_FRAME_PROBE_RESP,
175     WMI_FRAME_ASSOC_REQ,
176     WMI_FRAME_ASSOC_RESP,
177     WMI_NUM_MGMT_FRAME 
178 } WMI_MGMT_FRAME_TYPE;
179
180 /*
181  * Connect Command
182  */
183 typedef enum {
184     INFRA_NETWORK       = 0x01,
185     ADHOC_NETWORK       = 0x02,
186     ADHOC_CREATOR       = 0x04,
187     OPT_NETWORK         = 0x08,
188 } NETWORK_TYPE;
189
190 typedef enum {
191     OPEN_AUTH           = 0x01,
192     SHARED_AUTH         = 0x02,
193     LEAP_AUTH           = 0x04,  /* different from IEEE_AUTH_MODE definitions */
194 } DOT11_AUTH_MODE;
195
196 typedef enum {
197     NONE_AUTH           = 0x01, 
198     WPA_AUTH            = 0x02,
199     WPA_PSK_AUTH        = 0x03,
200     WPA2_AUTH           = 0x04,
201     WPA2_PSK_AUTH       = 0x05,
202     WPA_AUTH_CCKM       = 0x06,
203     WPA2_AUTH_CCKM      = 0x07,
204 } AUTH_MODE;
205
206 typedef enum {
207     NONE_CRYPT          = 0x01,
208     WEP_CRYPT           = 0x02,
209     TKIP_CRYPT          = 0x03,
210     AES_CRYPT           = 0x04,
211 } CRYPTO_TYPE;
212
213 #define WMI_MIN_CRYPTO_TYPE NONE_CRYPT
214 #define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1)
215
216 #define WMI_MIN_KEY_INDEX   0
217 #define WMI_MAX_KEY_INDEX   3
218
219 #define WMI_MAX_KEY_LEN     32
220
221 #define WMI_MAX_SSID_LEN    32
222
223 typedef enum {
224     CONNECT_ASSOC_POLICY_USER = 0x0001,
225     CONNECT_SEND_REASSOC = 0x0002,
226     CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004,
227     CONNECT_PROFILE_MATCH_DONE = 0x0008,
228     CONNECT_IGNORE_AAC_BEACON = 0x0010,
229     CONNECT_CSA_FOLLOW_BSS = 0x0020,
230 } WMI_CONNECT_CTRL_FLAGS_BITS;
231
232 #define DEFAULT_CONNECT_CTRL_FLAGS    (CONNECT_CSA_FOLLOW_BSS)
233
234 /*
235  * WMI_ECHO_CMDID
236  */
237 #define WMI_ECHOCMD_MSG_MAX_LEN         53//64 - HTC_HDR_LENGTH + sizeof(WMI_CMD_HDR) - 1
238
239 typedef PREPACK struct {
240     a_uint8_t     msgSize;
241     a_uint8_t     msgData[1];
242 } POSTPACK WMI_ECHO_CMD;
243
244 /*
245  * WMI_ACCESS_MEMORY_CMDID
246  */
247 #define WMI_ACCESS_MEMORY_MAX_TUPLES    8
248
249 typedef PREPACK struct {
250     a_uint16_t    addressL;
251     a_uint16_t    addressH;
252     a_uint16_t    valueL;
253     a_uint16_t    valueH;
254 } POSTPACK WMI_AVT;
255
256 typedef PREPACK struct {
257     a_uint16_t     tupleNumL;
258     a_uint16_t     tupleNumH;
259     WMI_AVT      avt[1];
260 } POSTPACK WMI_ACCESS_MEMORY_CMD;
261
262 /*
263  * List of Events (target to host)
264  */
265 typedef enum {
266     WMI_TGT_RDY_EVENTID           = 0x1001,
267     WMI_SWBA_EVENTID,
268     WMI_FATAL_EVENTID,
269     WMI_TXTO_EVENTID,
270     WMI_BMISS_EVENTID,
271     WMI_DELBA_EVENTID,
272     WMI_TXSTATUS_EVENTID
273 } WMI_EVENT_ID;
274
275 typedef PREPACK struct {
276         a_uint64_t tsf;
277         a_uint8_t beaconPendingCount;
278 } POSTPACK WMI_SWBA_EVENT;
279
280 typedef PREPACK struct {
281         a_uint8_t    cookie;
282         a_uint8_t    ts_rate;
283         a_uint8_t    ts_flags;
284 } POSTPACK __WMI_TXSTATUS_EVENT;
285
286 #define HTC_MAX_TX_STATUS 12
287
288 typedef PREPACK struct {
289         a_uint8_t cnt;
290         __WMI_TXSTATUS_EVENT txstatus[HTC_MAX_TX_STATUS];
291 } POSTPACK WMI_TXSTATUS_EVENT;
292
293 struct register_rmw {
294         a_uint32_t reg;
295         a_uint32_t set;
296         a_uint32_t clr;
297 };
298
299 #ifndef ATH_TARGET
300 //#include "athendpack.h"
301 #endif
302
303 #ifdef __cplusplus
304 }
305 #endif
306
307 #endif /* _WMI_H_ */