Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / wlan / include / wmi.h
1 /*
2  * Copyright (c) 2004-2006 Atheros Communications Inc.
3  * All rights reserved.
4  *
5  * This file contains the definitions of the WMI protocol specified in the
6  * Wireless Module Interface (WMI).  It includes definitions of all the
7  * commands and events. Commands are messages from the host to the WM.
8  * Events and Replies are messages from the WM to the host.
9  *
10  * Ownership of correctness in regards to WMI commands
11  * belongs to the host driver and the WM is not required to validate
12  * parameters for value, proper range, or any other checking.
13  *
14  * $Id: //depot/sw/branches/fusion_usb/target_firmware/wlan/include/wmi.h#6 $
15  *
16  */
17
18 #ifndef _WMI_H_
19 #define _WMI_H_
20
21 #include "athdefs.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #define HTC_PROTOCOL_VERSION    0x0002
28 #define HTC_PROTOCOL_REVISION   0x0000
29
30 #define WMI_PROTOCOL_VERSION    0x0002
31 #define WMI_PROTOCOL_REVISION   0x0000
32
33 #define ATH_MAC_LEN             6               /* length of mac in bytes */
34 #define WMI_CMD_MAX_LEN         100
35 #define WMI_CONTROL_MSG_MAX_LEN     256
36 #define WMI_OPT_CONTROL_MSG_MAX_LEN 1536
37 #define IS_ETHERTYPE(_typeOrLen)        ((_typeOrLen) >= 0x0600)
38 #define RFC1042OUI      {0x00, 0x00, 0x00}
39
40 #define IP_ETHERTYPE 0x0800
41
42 #define WMI_IMPLICIT_PSTREAM 0xFF
43 #define WMI_MAX_THINSTREAM 15
44
45 struct host_app_area_s {
46     a_uint32_t wmi_protocol_ver;
47 };
48
49 /*
50  * Data Path
51  */
52 typedef PREPACK struct {
53     a_uint8_t     dstMac[ATH_MAC_LEN];
54     a_uint8_t     srcMac[ATH_MAC_LEN];
55     a_uint16_t    typeOrLen;
56 } POSTPACK ATH_MAC_HDR;
57
58 typedef PREPACK struct {
59     a_uint8_t     dsap;
60     a_uint8_t     ssap;
61     a_uint8_t     cntl;
62     a_uint8_t     orgCode[3];
63     a_uint16_t    etherType;
64 } POSTPACK ATH_LLC_SNAP_HDR;
65
66 typedef enum {
67     DATA_MSGTYPE = 0x0,
68     CNTL_MSGTYPE,
69     SYNC_MSGTYPE,
70     OPT_MSGTYPE,
71 } WMI_MSG_TYPE;
72
73
74 typedef PREPACK struct {
75     a_int8_t      rssi;            
76     a_uint8_t     info;            /* WMI_MSG_TYPE in lower 2 bits - b1b0 */
77                                  /* UP in next 3 bits - b4b3b2 */
78 #define WMI_DATA_HDR_MSG_TYPE_MASK  0x03
79 #define WMI_DATA_HDR_MSG_TYPE_SHIFT 0
80 #define WMI_DATA_HDR_UP_MASK        0x07
81 #define WMI_DATA_HDR_UP_SHIFT       2   
82 #define WMI_DATA_HDR_IS_MSG_TYPE(h, t)  (((h)->info & (WMI_DATA_HDR_MSG_TYPE_MASK)) == (t))
83 } POSTPACK WMI_DATA_HDR;
84
85
86 #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))
87 #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))
88
89 /*
90  * Control Path
91  */
92 typedef PREPACK struct {
93     a_uint16_t    commandId;
94     a_uint16_t    seqNo;
95 } POSTPACK WMI_CMD_HDR;        /* used for commands and events */
96
97 /*
98  * List of Commnands
99  */
100 typedef enum {
101     WMI_ECHO_CMDID           = 0x0001,
102     WMI_ACCESS_MEMORY_CMDID,
103
104     /* Commands to Target */
105     WMI_GET_FW_VERSION,
106     WMI_DISABLE_INTR_CMDID,
107     WMI_ENABLE_INTR_CMDID,
108     WMI_ATH_INIT_CMDID,
109     WMI_ABORT_TXQ_CMDID,
110     WMI_STOP_TX_DMA_CMDID,
111     WMI_ABORT_TX_DMA_CMDID,
112     WMI_DRAIN_TXQ_CMDID,
113     WMI_DRAIN_TXQ_ALL_CMDID,
114     WMI_START_RECV_CMDID,
115     WMI_STOP_RECV_CMDID,
116     WMI_FLUSH_RECV_CMDID,
117     WMI_SET_MODE_CMDID,
118     WMI_NODE_CREATE_CMDID,
119     WMI_NODE_REMOVE_CMDID,
120     WMI_VAP_REMOVE_CMDID,
121     WMI_VAP_CREATE_CMDID,
122     WMI_REG_READ_CMDID,
123     WMI_REG_WRITE_CMDID,
124     WMI_RC_STATE_CHANGE_CMDID,
125     WMI_RC_RATE_UPDATE_CMDID,
126     WMI_TARGET_IC_UPDATE_CMDID,
127     WMI_TX_AGGR_ENABLE_CMDID,
128     WMI_TGT_DETACH_CMDID,
129     WMI_NODE_UPDATE_CMDID,
130     WMI_INT_STATS_CMDID,
131     WMI_TX_STATS_CMDID,
132     WMI_RX_STATS_CMDID,
133     WMI_BITRATE_MASK_CMDID,
134 } WMI_COMMAND_ID;
135
136 /*
137  * Frame Types
138  */
139 typedef enum {
140     WMI_FRAME_BEACON        =   0,
141     WMI_FRAME_PROBE_REQ,
142     WMI_FRAME_PROBE_RESP,
143     WMI_FRAME_ASSOC_REQ,
144     WMI_FRAME_ASSOC_RESP,
145     WMI_NUM_MGMT_FRAME 
146 } WMI_MGMT_FRAME_TYPE;
147
148 /*
149  * Connect Command
150  */
151 typedef enum {
152     INFRA_NETWORK       = 0x01,
153     ADHOC_NETWORK       = 0x02,
154     ADHOC_CREATOR       = 0x04,
155     OPT_NETWORK         = 0x08,
156 } NETWORK_TYPE;
157
158 typedef enum {
159     OPEN_AUTH           = 0x01,
160     SHARED_AUTH         = 0x02,
161     LEAP_AUTH           = 0x04,  /* different from IEEE_AUTH_MODE definitions */
162 } DOT11_AUTH_MODE;
163
164 typedef enum {
165     NONE_AUTH           = 0x01, 
166     WPA_AUTH            = 0x02,
167     WPA_PSK_AUTH        = 0x03,
168     WPA2_AUTH           = 0x04,
169     WPA2_PSK_AUTH       = 0x05,
170     WPA_AUTH_CCKM       = 0x06,
171     WPA2_AUTH_CCKM      = 0x07,
172 } AUTH_MODE;
173
174 typedef enum {
175     NONE_CRYPT          = 0x01,
176     WEP_CRYPT           = 0x02,
177     TKIP_CRYPT          = 0x03,
178     AES_CRYPT           = 0x04,
179 } CRYPTO_TYPE;
180
181 #define WMI_MIN_CRYPTO_TYPE NONE_CRYPT
182 #define WMI_MAX_CRYPTO_TYPE (AES_CRYPT + 1)
183
184 #define WMI_MIN_KEY_INDEX   0
185 #define WMI_MAX_KEY_INDEX   3
186
187 #define WMI_MAX_KEY_LEN     32
188
189 #define WMI_MAX_SSID_LEN    32
190
191 typedef enum {
192     CONNECT_ASSOC_POLICY_USER = 0x0001,
193     CONNECT_SEND_REASSOC = 0x0002,
194     CONNECT_IGNORE_WPAx_GROUP_CIPHER = 0x0004,
195     CONNECT_PROFILE_MATCH_DONE = 0x0008,
196     CONNECT_IGNORE_AAC_BEACON = 0x0010,
197     CONNECT_CSA_FOLLOW_BSS = 0x0020,
198 } WMI_CONNECT_CTRL_FLAGS_BITS;
199
200 #define DEFAULT_CONNECT_CTRL_FLAGS    (CONNECT_CSA_FOLLOW_BSS)
201
202 /*
203  * WMI_ECHO_CMDID
204  */
205 #define WMI_ECHOCMD_MSG_MAX_LEN         53//64 - HTC_HDR_LENGTH + sizeof(WMI_CMD_HDR) - 1
206
207 typedef PREPACK struct {
208     a_uint8_t     msgSize;
209     a_uint8_t     msgData[1];
210 } POSTPACK WMI_ECHO_CMD;
211
212 /*
213  * WMI_ACCESS_MEMORY_CMDID
214  */
215 #define WMI_ACCESS_MEMORY_MAX_TUPLES    8
216
217 typedef PREPACK struct {
218     a_uint16_t    addressL;
219     a_uint16_t    addressH;
220     a_uint16_t    valueL;
221     a_uint16_t    valueH;
222 } POSTPACK WMI_AVT;
223
224 typedef PREPACK struct {
225     a_uint16_t     tupleNumL;
226     a_uint16_t     tupleNumH;
227     WMI_AVT      avt[1];
228 } POSTPACK WMI_ACCESS_MEMORY_CMD;
229
230 /*
231  * List of Events (target to host)
232  */
233 typedef enum {
234     WMI_TGT_RDY_EVENTID           = 0x1001,
235     WMI_SWBA_EVENTID,
236     WMI_FATAL_EVENTID,
237     WMI_TXTO_EVENTID,
238     WMI_BMISS_EVENTID,
239     WMI_DELBA_EVENTID,
240     WMI_TXSTATUS_EVENTID
241 } WMI_EVENT_ID;
242
243 typedef PREPACK struct {
244         a_uint64_t tsf;
245         a_uint8_t beaconPendingCount;
246 } POSTPACK WMI_SWBA_EVENT;
247
248 typedef PREPACK struct {
249         a_uint8_t    cookie;
250         a_uint8_t    ts_rate;
251         a_uint8_t    ts_flags;
252 } POSTPACK __WMI_TXSTATUS_EVENT;
253
254 #define HTC_MAX_TX_STATUS 12
255
256 typedef PREPACK struct {
257         a_uint8_t cnt;
258         __WMI_TXSTATUS_EVENT txstatus[HTC_MAX_TX_STATUS];
259 } POSTPACK WMI_TXSTATUS_EVENT;
260
261 #ifndef ATH_TARGET
262 //#include "athendpack.h"
263 #endif
264
265 #ifdef __cplusplus
266 }
267 #endif
268
269 #endif /* _WMI_H_ */