Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.git] / drivers / net / wireless / wl12xx / cmd.h
1 /*
2  * This file is part of wl1271
3  *
4  * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
5  * Copyright (C) 2009 Nokia Corporation
6  *
7  * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 #ifndef __CMD_H__
26 #define __CMD_H__
27
28 #include "wl12xx.h"
29
30 struct acx_header;
31
32 int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
33                     size_t res_len);
34 int wl1271_cmd_general_parms(struct wl1271 *wl);
35 int wl1271_cmd_radio_parms(struct wl1271 *wl);
36 int wl1271_cmd_ext_radio_parms(struct wl1271 *wl);
37 int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type);
38 int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
39 int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
40 int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
41 int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
42 int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, u32 rates, bool send);
43 int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
44                            size_t len);
45 int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
46                             void *buf, size_t buf_len, int index, u32 rates);
47 int wl1271_cmd_build_null_data(struct wl1271 *wl);
48 int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
49 int wl1271_cmd_build_probe_req(struct wl1271 *wl,
50                                const u8 *ssid, size_t ssid_len,
51                                const u8 *ie, size_t ie_len, u8 band);
52 struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl,
53                                               struct sk_buff *skb);
54 int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr);
55 int wl1271_build_qos_null_data(struct wl1271 *wl);
56 int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
57 int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
58 int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
59                        u8 key_size, const u8 *key, const u8 *addr,
60                        u32 tx_seq_32, u16 tx_seq_16);
61 int wl1271_cmd_disconnect(struct wl1271 *wl);
62 int wl1271_cmd_set_sta_state(struct wl1271 *wl);
63
64 enum wl1271_commands {
65         CMD_INTERROGATE     = 1,    /*use this to read information elements*/
66         CMD_CONFIGURE       = 2,    /*use this to write information elements*/
67         CMD_ENABLE_RX       = 3,
68         CMD_ENABLE_TX       = 4,
69         CMD_DISABLE_RX      = 5,
70         CMD_DISABLE_TX      = 6,
71         CMD_SCAN            = 8,
72         CMD_STOP_SCAN       = 9,
73         CMD_START_JOIN      = 11,
74         CMD_SET_KEYS        = 12,
75         CMD_READ_MEMORY     = 13,
76         CMD_WRITE_MEMORY    = 14,
77         CMD_SET_TEMPLATE    = 19,
78         CMD_TEST            = 23,
79         CMD_NOISE_HIST      = 28,
80         CMD_LNA_CONTROL     = 32,
81         CMD_SET_BCN_MODE    = 33,
82         CMD_MEASUREMENT      = 34,
83         CMD_STOP_MEASUREMENT = 35,
84         CMD_DISCONNECT       = 36,
85         CMD_SET_PS_MODE      = 37,
86         CMD_CHANNEL_SWITCH   = 38,
87         CMD_STOP_CHANNEL_SWICTH = 39,
88         CMD_AP_DISCOVERY     = 40,
89         CMD_STOP_AP_DISCOVERY = 41,
90         CMD_SPS_SCAN = 42,
91         CMD_STOP_SPS_SCAN = 43,
92         CMD_HEALTH_CHECK     = 45,
93         CMD_DEBUG            = 46,
94         CMD_TRIGGER_SCAN_TO  = 47,
95         CMD_CONNECTION_SCAN_CFG      = 48,
96         CMD_CONNECTION_SCAN_SSID_CFG = 49,
97         CMD_START_PERIODIC_SCAN      = 50,
98         CMD_STOP_PERIODIC_SCAN       = 51,
99         CMD_SET_STA_STATE            = 52,
100
101         NUM_COMMANDS,
102         MAX_COMMAND_ID = 0xFFFF,
103 };
104
105 #define MAX_CMD_PARAMS 572
106
107 enum {
108         CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
109         CMD_TEMPL_KLV_IDX_MAX = 4
110 };
111
112 enum cmd_templ {
113         CMD_TEMPL_NULL_DATA = 0,
114         CMD_TEMPL_BEACON,
115         CMD_TEMPL_CFG_PROBE_REQ_2_4,
116         CMD_TEMPL_CFG_PROBE_REQ_5,
117         CMD_TEMPL_PROBE_RESPONSE,
118         CMD_TEMPL_QOS_NULL_DATA,
119         CMD_TEMPL_PS_POLL,
120         CMD_TEMPL_KLV,
121         CMD_TEMPL_DISCONNECT,
122         CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
123         CMD_TEMPL_PROBE_REQ_5,   /* for firmware internal use only */
124         CMD_TEMPL_BAR,           /* for firmware internal use only */
125         CMD_TEMPL_CTS,           /*
126                                   * For CTS-to-self (FastCTS) mechanism
127                                   * for BT/WLAN coexistence (SoftGemini). */
128         CMD_TEMPL_ARP_RSP,
129         CMD_TEMPL_MAX = 0xff
130 };
131
132 /* unit ms */
133 #define WL1271_COMMAND_TIMEOUT     2000
134 #define WL1271_CMD_TEMPL_MAX_SIZE  252
135 #define WL1271_EVENT_TIMEOUT       750
136
137 struct wl1271_cmd_header {
138         __le16 id;
139         __le16 status;
140         /* payload */
141         u8 data[0];
142 } __packed;
143
144 #define WL1271_CMD_MAX_PARAMS 572
145
146 struct wl1271_command {
147         struct wl1271_cmd_header header;
148         u8  parameters[WL1271_CMD_MAX_PARAMS];
149 } __packed;
150
151 enum {
152         CMD_MAILBOX_IDLE                =  0,
153         CMD_STATUS_SUCCESS              =  1,
154         CMD_STATUS_UNKNOWN_CMD          =  2,
155         CMD_STATUS_UNKNOWN_IE           =  3,
156         CMD_STATUS_REJECT_MEAS_SG_ACTIVE        = 11,
157         CMD_STATUS_RX_BUSY              = 13,
158         CMD_STATUS_INVALID_PARAM                = 14,
159         CMD_STATUS_TEMPLATE_TOO_LARGE           = 15,
160         CMD_STATUS_OUT_OF_MEMORY                = 16,
161         CMD_STATUS_STA_TABLE_FULL               = 17,
162         CMD_STATUS_RADIO_ERROR          = 18,
163         CMD_STATUS_WRONG_NESTING                = 19,
164         CMD_STATUS_TIMEOUT              = 21, /* Driver internal use.*/
165         CMD_STATUS_FW_RESET             = 22, /* Driver internal use.*/
166         MAX_COMMAND_STATUS              = 0xff
167 };
168
169 #define CMDMBOX_HEADER_LEN 4
170 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
171
172 enum {
173         BSS_TYPE_IBSS = 0,
174         BSS_TYPE_STA_BSS = 2,
175         BSS_TYPE_AP_BSS = 3,
176         MAX_BSS_TYPE = 0xFF
177 };
178
179 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH     0x80 /* Firmware flushes all Tx */
180 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
181 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
182
183 struct wl1271_cmd_join {
184         struct wl1271_cmd_header header;
185
186         __le32 bssid_lsb;
187         __le16 bssid_msb;
188         __le16 beacon_interval; /* in TBTTs */
189         __le32 rx_config_options;
190         __le32 rx_filter_options;
191
192         /*
193          * The target uses this field to determine the rate at
194          * which to transmit control frame responses (such as
195          * ACK or CTS frames).
196          */
197         __le32 basic_rate_set;
198         u8 dtim_interval;
199         /*
200          * bits 0-2: This bitwise field specifies the type
201          * of BSS to start or join (BSS_TYPE_*).
202          * bit 4: Band - The radio band in which to join
203          * or start.
204          *  0 - 2.4GHz band
205          *  1 - 5GHz band
206          * bits 3, 5-7: Reserved
207          */
208         u8 bss_type;
209         u8 channel;
210         u8 ssid_len;
211         u8 ssid[IW_ESSID_MAX_SIZE];
212         u8 ctrl; /* JOIN_CMD_CTRL_* */
213         u8 reserved[3];
214 } __packed;
215
216 struct cmd_enabledisable_path {
217         struct wl1271_cmd_header header;
218
219         u8 channel;
220         u8 padding[3];
221 } __packed;
222
223 #define WL1271_RATE_AUTOMATIC  0
224
225 struct wl1271_cmd_template_set {
226         struct wl1271_cmd_header header;
227
228         __le16 len;
229         u8 template_type;
230         u8 index;  /* relevant only for KLV_TEMPLATE type */
231         __le32 enabled_rates;
232         u8 short_retry_limit;
233         u8 long_retry_limit;
234         u8 aflags;
235         u8 reserved;
236         u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
237 } __packed;
238
239 #define TIM_ELE_ID    5
240 #define PARTIAL_VBM_MAX    251
241
242 struct wl1271_tim {
243         u8 identity;
244         u8 length;
245         u8 dtim_count;
246         u8 dtim_period;
247         u8 bitmap_ctrl;
248         u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
249 } __packed;
250
251 enum wl1271_cmd_ps_mode {
252         STATION_ACTIVE_MODE,
253         STATION_POWER_SAVE_MODE
254 };
255
256 struct wl1271_cmd_ps_params {
257         struct wl1271_cmd_header header;
258
259         u8 ps_mode; /* STATION_* */
260         u8 send_null_data; /* Do we have to send NULL data packet ? */
261         u8 retries; /* Number of retires for the initial NULL data packet */
262
263          /*
264           * TUs during which the target stays awake after switching
265           * to power save mode.
266           */
267         u8 hang_over_period;
268         __le32 null_data_rate;
269 } __packed;
270
271 /* HW encryption keys */
272 #define NUM_ACCESS_CATEGORIES_COPY 4
273 #define MAX_KEY_SIZE 32
274
275 enum wl1271_cmd_key_action {
276         KEY_ADD_OR_REPLACE = 1,
277         KEY_REMOVE         = 2,
278         KEY_SET_ID         = 3,
279         MAX_KEY_ACTION     = 0xffff,
280 };
281
282 enum wl1271_cmd_key_type {
283         KEY_NONE = 0,
284         KEY_WEP  = 1,
285         KEY_TKIP = 2,
286         KEY_AES  = 3,
287         KEY_GEM  = 4,
288 };
289
290 /* FIXME: Add description for key-types */
291
292 struct wl1271_cmd_set_keys {
293         struct wl1271_cmd_header header;
294
295         /* Ignored for default WEP key */
296         u8 addr[ETH_ALEN];
297
298         /* key_action_e */
299         __le16 key_action;
300
301         __le16 reserved_1;
302
303         /* key size in bytes */
304         u8 key_size;
305
306         /* key_type_e */
307         u8 key_type;
308         u8 ssid_profile;
309
310         /*
311          * TKIP, AES: frame's key id field.
312          * For WEP default key: key id;
313          */
314         u8 id;
315         u8 reserved_2[6];
316         u8 key[MAX_KEY_SIZE];
317         __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
318         __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
319 } __packed;
320
321 struct wl1271_cmd_test_header {
322         u8 id;
323         u8 padding[3];
324 } __packed;
325
326 enum wl1271_channel_tune_bands {
327         WL1271_CHANNEL_TUNE_BAND_2_4,
328         WL1271_CHANNEL_TUNE_BAND_5,
329         WL1271_CHANNEL_TUNE_BAND_4_9
330 };
331
332 #define WL1271_PD_REFERENCE_POINT_BAND_B_G  0
333
334 #define TEST_CMD_INI_FILE_RADIO_PARAM       0x19
335 #define TEST_CMD_INI_FILE_GENERAL_PARAM     0x1E
336 #define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
337
338 struct wl1271_general_parms_cmd {
339         struct wl1271_cmd_header header;
340
341         struct wl1271_cmd_test_header test;
342
343         struct wl1271_ini_general_params general_params;
344
345         u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
346         u8 sr_sen_n_p;
347         u8 sr_sen_n_p_gain;
348         u8 sr_sen_nrn;
349         u8 sr_sen_prn;
350         u8 padding[3];
351 } __packed;
352
353 struct wl1271_radio_parms_cmd {
354         struct wl1271_cmd_header header;
355
356         struct wl1271_cmd_test_header test;
357
358         /* Static radio parameters */
359         struct wl1271_ini_band_params_2 static_params_2;
360         struct wl1271_ini_band_params_5 static_params_5;
361
362         /* Dynamic radio parameters */
363         struct wl1271_ini_fem_params_2 dyn_params_2;
364         u8 padding2;
365         struct wl1271_ini_fem_params_5 dyn_params_5;
366         u8 padding3[2];
367 } __packed;
368
369 struct wl1271_ext_radio_parms_cmd {
370         struct wl1271_cmd_header header;
371
372         struct wl1271_cmd_test_header test;
373
374         u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
375         u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
376         u8 padding[3];
377 } __packed;
378
379 /*
380  * There are three types of disconnections:
381  *
382  * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
383  * DISCONNECT_DEAUTH:    the fw generates a DEAUTH request with the reason
384  *                       we have passed
385  * DISCONNECT_DISASSOC:  the fw generates a DESASSOC request with the reason
386  *                       we have passed
387  */
388 enum wl1271_disconnect_type {
389         DISCONNECT_IMMEDIATE,
390         DISCONNECT_DEAUTH,
391         DISCONNECT_DISASSOC
392 };
393
394 struct wl1271_cmd_disconnect {
395         struct wl1271_cmd_header header;
396
397         __le32 rx_config_options;
398         __le32 rx_filter_options;
399
400         __le16 reason;
401         u8  type;
402
403         u8  padding;
404 } __packed;
405
406 #define WL1271_CMD_STA_STATE_CONNECTED  1
407
408 struct wl1271_cmd_set_sta_state {
409         struct wl1271_cmd_header header;
410
411         u8 state;
412         u8 padding[3];
413 } __packed;
414
415 #endif /* __WL1271_CMD_H__ */