Merge commit 'origin/master' into next
[pandora-kernel.git] / drivers / net / wireless / iwmc3200wifi / commands.h
1 /*
2  * Intel Wireless Multicomm 3200 WiFi driver
3  *
4  * Copyright (C) 2009 Intel Corporation. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  *   * Redistributions of source code must retain the above copyright
11  *     notice, this list of conditions and the following disclaimer.
12  *   * Redistributions in binary form must reproduce the above copyright
13  *     notice, this list of conditions and the following disclaimer in
14  *     the documentation and/or other materials provided with the
15  *     distribution.
16  *   * Neither the name of Intel Corporation nor the names of its
17  *     contributors may be used to endorse or promote products derived
18  *     from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  *
33  * Intel Corporation <ilw@linux.intel.com>
34  * Samuel Ortiz <samuel.ortiz@intel.com>
35  * Zhu Yi <yi.zhu@intel.com>
36  *
37  */
38
39 #ifndef __IWM_COMMANDS_H__
40 #define __IWM_COMMANDS_H__
41
42 #include <linux/ieee80211.h>
43
44 #define IWM_BARKER_REBOOT_NOTIFICATION  0xF
45 #define IWM_ACK_BARKER_NOTIFICATION     0x10
46
47 /* UMAC commands */
48 #define UMAC_RST_CTRL_FLG_LARC_CLK_EN   0x0001
49 #define UMAC_RST_CTRL_FLG_LARC_RESET    0x0002
50 #define UMAC_RST_CTRL_FLG_FUNC_RESET    0x0004
51 #define UMAC_RST_CTRL_FLG_DEV_RESET     0x0008
52 #define UMAC_RST_CTRL_FLG_WIFI_CORE_EN  0x0010
53 #define UMAC_RST_CTRL_FLG_WIFI_LINK_EN  0x0040
54 #define UMAC_RST_CTRL_FLG_WIFI_MLME_EN  0x0080
55 #define UMAC_RST_CTRL_FLG_NVM_RELOAD    0x0100
56
57 struct iwm_umac_cmd_reset {
58         __le32 flags;
59 } __attribute__ ((packed));
60
61 #define UMAC_PARAM_TBL_ORD_FIX    0x0
62 #define UMAC_PARAM_TBL_ORD_VAR    0x1
63 #define UMAC_PARAM_TBL_CFG_FIX    0x2
64 #define UMAC_PARAM_TBL_CFG_VAR    0x3
65 #define UMAC_PARAM_TBL_BSS_TRK    0x4
66 #define UMAC_PARAM_TBL_FA_CFG_FIX 0x5
67 #define UMAC_PARAM_TBL_STA        0x6
68 #define UMAC_PARAM_TBL_CHN        0x7
69 #define UMAC_PARAM_TBL_STATISTICS 0x8
70
71 /* fast access table */
72 enum {
73         CFG_FRAG_THRESHOLD = 0,
74         CFG_FRAME_RETRY_LIMIT,
75         CFG_OS_QUEUE_UTIL_TH,
76         CFG_RX_FILTER,
77         /* <-- LAST --> */
78         FAST_ACCESS_CFG_TBL_FIX_LAST
79 };
80
81 /* fixed size table */
82 enum {
83         CFG_POWER_INDEX = 0,
84         CFG_PM_LEGACY_RX_TIMEOUT,
85         CFG_PM_LEGACY_TX_TIMEOUT,
86         CFG_PM_CTRL_FLAGS,
87         CFG_PM_KEEP_ALIVE_IN_BEACONS,
88         CFG_BT_ON_THRESHOLD,
89         CFG_RTS_THRESHOLD,
90         CFG_CTS_TO_SELF,
91         CFG_COEX_MODE,
92         CFG_WIRELESS_MODE,
93         CFG_ASSOCIATION_TIMEOUT,
94         CFG_ROAM_TIMEOUT,
95         CFG_CAPABILITY_SUPPORTED_RATES,
96         CFG_SCAN_ALLOWED_UNASSOC_FLAGS,
97         CFG_SCAN_ALLOWED_MAIN_ASSOC_FLAGS,
98         CFG_SCAN_ALLOWED_PAN_ASSOC_FLAGS,
99         CFG_SCAN_INTERNAL_PERIODIC_ENABLED,
100         CFG_SCAN_IMM_INTERNAL_PERIODIC_SCAN_ON_INIT,
101         CFG_SCAN_DEFAULT_PERIODIC_FREQ_SEC,
102         CFG_SCAN_NUM_PASSIVE_CHAN_PER_PARTIAL_SCAN,
103         CFG_TLC_SUPPORTED_TX_HT_RATES,
104         CFG_TLC_SUPPORTED_TX_RATES,
105         CFG_TLC_VALID_ANTENNA,
106         CFG_TLC_SPATIAL_STREAM_SUPPORTED,
107         CFG_TLC_RETRY_PER_RATE,
108         CFG_TLC_RETRY_PER_HT_RATE,
109         CFG_TLC_FIXED_RATE,
110         CFG_TLC_FIXED_RATE_FLAGS,
111         CFG_TLC_CONTROL_FLAGS,
112         CFG_TLC_SR_MIN_FAIL,
113         CFG_TLC_SR_MIN_PASS,
114         CFG_TLC_HT_STAY_IN_COL_PASS_THRESH,
115         CFG_TLC_HT_STAY_IN_COL_FAIL_THRESH,
116         CFG_TLC_LEGACY_STAY_IN_COL_PASS_THRESH,
117         CFG_TLC_LEGACY_STAY_IN_COL_FAIL_THRESH,
118         CFG_TLC_HT_FLUSH_STATS_PACKETS,
119         CFG_TLC_LEGACY_FLUSH_STATS_PACKETS,
120         CFG_TLC_LEGACY_FLUSH_STATS_MS,
121         CFG_TLC_HT_FLUSH_STATS_MS,
122         CFG_TLC_STAY_IN_COL_TIME_OUT,
123         CFG_TLC_AGG_SHORT_LIM,
124         CFG_TLC_AGG_LONG_LIM,
125         CFG_TLC_HT_SR_NO_DECREASE,
126         CFG_TLC_LEGACY_SR_NO_DECREASE,
127         CFG_TLC_SR_FORCE_DECREASE,
128         CFG_TLC_SR_ALLOW_INCREASE,
129         CFG_TLC_AGG_SET_LONG,
130         CFG_TLC_AUTO_AGGREGATION,
131         CFG_TLC_AGG_THRESHOLD,
132         CFG_TLC_TID_LOAD_THRESHOLD,
133         CFG_TLC_BLOCK_ACK_TIMEOUT,
134         CFG_TLC_NO_BA_COUNTED_AS_ONE,
135         CFG_TLC_NUM_BA_STREAMS_ALLOWED,
136         CFG_TLC_NUM_BA_STREAMS_PRESENT,
137         CFG_TLC_RENEW_ADDBA_DELAY,
138         CFG_TLC_NUM_OF_MULTISEC_TO_COUN_LOAD,
139         CFG_TLC_IS_STABLE_IN_HT,
140         CFG_RLC_CHAIN_CTRL,
141         CFG_TRK_TABLE_OP_MODE,
142         CFG_TRK_TABLE_RSSI_THRESHOLD,
143         CFG_TX_PWR_TARGET, /* Used By xVT */
144         CFG_TX_PWR_LIMIT_USR,
145         CFG_TX_PWR_LIMIT_BSS, /* 11d limit */
146         CFG_TX_PWR_LIMIT_BSS_CONSTRAINT, /* 11h constraint */
147         CFG_TX_PWR_MODE,
148         CFG_MLME_DBG_NOTIF_BLOCK,
149         CFG_BT_OFF_BECONS_INTERVALS,
150         CFG_BT_FRAG_DURATION,
151
152         /* <-- LAST --> */
153         CFG_TBL_FIX_LAST
154 };
155
156 /* variable size table */
157 enum {
158         CFG_NET_ADDR = 0,
159         CFG_PROFILE,
160         /* <-- LAST --> */
161         CFG_TBL_VAR_LAST
162 };
163
164 struct iwm_umac_cmd_set_param_fix {
165         __le16 tbl;
166         __le16 key;
167         __le32 value;
168 } __attribute__ ((packed));
169
170 struct iwm_umac_cmd_set_param_var {
171         __le16 tbl;
172         __le16 key;
173         __le16 len;
174         __le16 reserved;
175 } __attribute__ ((packed));
176
177 struct iwm_umac_cmd_get_param {
178         __le16 tbl;
179         __le16 key;
180 } __attribute__ ((packed));
181
182 struct iwm_umac_cmd_get_param_resp {
183         __le16 tbl;
184         __le16 key;
185         __le16 len;
186         __le16 reserved;
187 } __attribute__ ((packed));
188
189 struct iwm_umac_cmd_eeprom_proxy_hdr {
190         __le32 type;
191         __le32 offset;
192         __le32 len;
193 } __attribute__ ((packed));
194
195 struct iwm_umac_cmd_eeprom_proxy {
196         struct iwm_umac_cmd_eeprom_proxy_hdr hdr;
197         u8 buf[0];
198 } __attribute__ ((packed));
199
200 #define IWM_UMAC_CMD_EEPROM_TYPE_READ       0x1
201 #define IWM_UMAC_CMD_EEPROM_TYPE_WRITE      0x2
202
203 #define UMAC_CHANNEL_FLAG_VALID         BIT(0)
204 #define UMAC_CHANNEL_FLAG_IBSS          BIT(1)
205 #define UMAC_CHANNEL_FLAG_ACTIVE        BIT(3)
206 #define UMAC_CHANNEL_FLAG_RADAR         BIT(4)
207 #define UMAC_CHANNEL_FLAG_DFS           BIT(7)
208
209 struct iwm_umac_channel_info {
210         u8 band;
211         u8 type;
212         u8 reserved;
213         u8 flags;
214         __le32 channels_mask;
215 } __attribute__ ((packed));
216
217 struct iwm_umac_cmd_get_channel_list {
218         __le16 count;
219         __le16 reserved;
220         struct iwm_umac_channel_info ch[0];
221 } __attribute__ ((packed));
222
223
224 /* UMAC WiFi interface commands */
225
226 /* Coexistence mode */
227 #define COEX_MODE_SA  0x1
228 #define COEX_MODE_XOR 0x2
229 #define COEX_MODE_CM  0x3
230 #define COEX_MODE_MAX 0x4
231
232 /* Wireless mode */
233 #define WIRELESS_MODE_11A  0x1
234 #define WIRELESS_MODE_11G  0x2
235
236 #define UMAC_PROFILE_EX_IE_REQUIRED     0x1
237 #define UMAC_PROFILE_QOS_ALLOWED        0x2
238
239 /* Scanning */
240 #define UMAC_WIFI_IF_PROBE_OPTION_MAX        10
241
242 #define UMAC_WIFI_IF_SCAN_TYPE_USER          0x0
243 #define UMAC_WIFI_IF_SCAN_TYPE_UMAC_RESERVED 0x1
244 #define UMAC_WIFI_IF_SCAN_TYPE_HOST_PERIODIC 0x2
245 #define UMAC_WIFI_IF_SCAN_TYPE_MAX           0x3
246
247 struct iwm_umac_ssid {
248         u8 ssid_len;
249         u8 ssid[IEEE80211_MAX_SSID_LEN];
250         u8 reserved[3];
251 } __attribute__ ((packed));
252
253 struct iwm_umac_cmd_scan_request {
254         struct iwm_umac_wifi_if hdr;
255         __le32 type; /* UMAC_WIFI_IF_SCAN_TYPE_* */
256         u8 ssid_num;
257         u8 seq_num;
258         u8 timeout; /* In seconds */
259         u8 reserved;
260         struct iwm_umac_ssid ssids[UMAC_WIFI_IF_PROBE_OPTION_MAX];
261 } __attribute__ ((packed));
262
263 #define UMAC_CIPHER_TYPE_NONE           0xFF
264 #define UMAC_CIPHER_TYPE_USE_GROUPCAST  0x00
265 #define UMAC_CIPHER_TYPE_WEP_40         0x01
266 #define UMAC_CIPHER_TYPE_WEP_104        0x02
267 #define UMAC_CIPHER_TYPE_TKIP           0x04
268 #define UMAC_CIPHER_TYPE_CCMP           0x08
269
270 /* Supported authentication types - bitmap */
271 #define UMAC_AUTH_TYPE_OPEN             0x00
272 #define UMAC_AUTH_TYPE_LEGACY_PSK       0x01
273 #define UMAC_AUTH_TYPE_8021X            0x02
274 #define UMAC_AUTH_TYPE_RSNA_PSK         0x04
275
276 /* iwm_umac_security.flag is WPA supported -- bits[0:0] */
277 #define UMAC_SEC_FLG_WPA_ON_POS         0
278 #define UMAC_SEC_FLG_WPA_ON_SEED        1
279 #define UMAC_SEC_FLG_WPA_ON_MSK (UMAC_SEC_FLG_WPA_ON_SEED << \
280                                  UMAC_SEC_FLG_WPA_ON_POS)
281
282 /* iwm_umac_security.flag is WPA2 supported -- bits [1:1] */
283 #define UMAC_SEC_FLG_RSNA_ON_POS        1
284 #define UMAC_SEC_FLG_RSNA_ON_SEED       1
285 #define UMAC_SEC_FLG_RSNA_ON_MSK        (UMAC_SEC_FLG_RSNA_ON_SEED << \
286                                          UMAC_SEC_FLG_RSNA_ON_POS)
287
288 /* iwm_umac_security.flag is WSC mode on -- bits [2:2] */
289 #define UMAC_SEC_FLG_WSC_ON_POS         2
290 #define UMAC_SEC_FLG_WSC_ON_SEED        1
291
292 /* Legacy profile can use only WEP40 and WEP104 for encryption and
293  * OPEN or PSK for authentication */
294 #define UMAC_SEC_FLG_LEGACY_PROFILE     0
295
296 struct iwm_umac_security {
297         u8 auth_type;
298         u8 ucast_cipher;
299         u8 mcast_cipher;
300         u8 flags;
301 } __attribute__ ((packed));
302
303 struct iwm_umac_ibss {
304         u8 beacon_interval;     /* in millisecond */
305         u8 atim;                /* in millisecond */
306         s8 join_only;
307         u8 band;
308         u8 channel;
309         u8 reserved[3];
310 } __attribute__ ((packed));
311
312 #define UMAC_MODE_BSS   0
313 #define UMAC_MODE_IBSS  1
314
315 #define UMAC_BSSID_MAX  4
316
317 struct iwm_umac_profile {
318         struct iwm_umac_wifi_if hdr;
319         __le32 mode;
320         struct iwm_umac_ssid ssid;
321         u8 bssid[UMAC_BSSID_MAX][ETH_ALEN];
322         struct iwm_umac_security sec;
323         struct iwm_umac_ibss ibss;
324         __le32 channel_2ghz;
325         __le32 channel_5ghz;
326         __le16 flags;
327         u8 wireless_mode;
328         u8 bss_num;
329 } __attribute__ ((packed));
330
331 struct iwm_umac_invalidate_profile {
332         struct iwm_umac_wifi_if hdr;
333         u8 reason;
334         u8 reserved[3];
335 } __attribute__ ((packed));
336
337 /* Encryption key commands */
338 struct iwm_umac_key_wep40 {
339         struct iwm_umac_wifi_if hdr;
340         struct iwm_umac_key_hdr key_hdr;
341         u8 key[WLAN_KEY_LEN_WEP40];
342         u8 static_key;
343         u8 reserved[2];
344 } __attribute__ ((packed));
345
346 struct iwm_umac_key_wep104 {
347         struct iwm_umac_wifi_if hdr;
348         struct iwm_umac_key_hdr key_hdr;
349         u8 key[WLAN_KEY_LEN_WEP104];
350         u8 static_key;
351         u8 reserved[2];
352 } __attribute__ ((packed));
353
354 #define IWM_TKIP_KEY_SIZE 16
355 #define IWM_TKIP_MIC_SIZE 8
356 struct iwm_umac_key_tkip {
357         struct iwm_umac_wifi_if hdr;
358         struct iwm_umac_key_hdr key_hdr;
359         u8 iv_count[6];
360         u8 reserved[2];
361         u8 tkip_key[IWM_TKIP_KEY_SIZE];
362         u8 mic_rx_key[IWM_TKIP_MIC_SIZE];
363         u8 mic_tx_key[IWM_TKIP_MIC_SIZE];
364 } __attribute__ ((packed));
365
366 struct iwm_umac_key_ccmp {
367         struct iwm_umac_wifi_if hdr;
368         struct iwm_umac_key_hdr key_hdr;
369         u8 iv_count[6];
370         u8 reserved[2];
371         u8 key[WLAN_KEY_LEN_CCMP];
372 } __attribute__ ((packed));
373
374 struct iwm_umac_key_remove {
375         struct iwm_umac_wifi_if hdr;
376         struct iwm_umac_key_hdr key_hdr;
377 } __attribute__ ((packed));
378
379 struct iwm_umac_tx_key_id {
380         struct iwm_umac_wifi_if hdr;
381         u8 key_idx;
382         u8 reserved[3];
383 } __attribute__ ((packed));
384
385 struct iwm_umac_cmd_stats_req {
386         __le32 flags;
387 } __attribute__ ((packed));
388
389 /* LMAC commands */
390 int iwm_read_mac(struct iwm_priv *iwm, u8 *mac);
391 int iwm_send_prio_table(struct iwm_priv *iwm);
392 int iwm_send_init_calib_cfg(struct iwm_priv *iwm, u8 calib_requested);
393 int iwm_send_periodic_calib_cfg(struct iwm_priv *iwm, u8 calib_requested);
394 int iwm_send_calib_results(struct iwm_priv *iwm);
395 int iwm_store_rxiq_calib_result(struct iwm_priv *iwm);
396
397 /* UMAC commands */
398 int iwm_send_wifi_if_cmd(struct iwm_priv *iwm, void *payload, u16 payload_size,
399                          bool resp);
400 int iwm_send_umac_reset(struct iwm_priv *iwm, __le32 reset_flags, bool resp);
401 int iwm_umac_set_config_fix(struct iwm_priv *iwm, u16 tbl, u16 key, u32 value);
402 int iwm_umac_set_config_var(struct iwm_priv *iwm, u16 key,
403                             void *payload, u16 payload_size);
404 int iwm_send_umac_config(struct iwm_priv *iwm, __le32 reset_flags);
405 int iwm_send_mlme_profile(struct iwm_priv *iwm);
406 int iwm_invalidate_mlme_profile(struct iwm_priv *iwm);
407 int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id);
408 int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx);
409 int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key,
410                 struct iwm_key *key);
411 int iwm_send_umac_stats_req(struct iwm_priv *iwm, u32 flags);
412 int iwm_send_umac_channel_list(struct iwm_priv *iwm);
413 int iwm_scan_ssids(struct iwm_priv *iwm, struct cfg80211_ssid *ssids,
414                    int ssid_num);
415 int iwm_scan_one_ssid(struct iwm_priv *iwm, u8 *ssid, int ssid_len);
416
417 /* UDMA commands */
418 int iwm_target_reset(struct iwm_priv *iwm);
419 #endif