upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / net / wireless / wl12xx / wl1271_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 __WL1271_CMD_H__
26 #define __WL1271_CMD_H__
27
28 #include "wl1271.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_join(struct wl1271 *wl, u8 bss_type);
37 int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
38 int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
39 int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
40 int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
41 int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send);
42 int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
43                            size_t len);
44 int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
45                             void *buf, size_t buf_len, int index, u32 rates);
46 int wl1271_cmd_build_null_data(struct wl1271 *wl);
47 int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
48 int wl1271_cmd_build_probe_req(struct wl1271 *wl,
49                                const u8 *ssid, size_t ssid_len,
50                                const u8 *ie, size_t ie_len, u8 band);
51 int wl1271_build_qos_null_data(struct wl1271 *wl);
52 int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
53 int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
54 int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
55                        u8 key_size, const u8 *key, const u8 *addr,
56                        u32 tx_seq_32, u16 tx_seq_16);
57 int wl1271_cmd_disconnect(struct wl1271 *wl);
58
59 enum wl1271_commands {
60         CMD_INTERROGATE     = 1,    /*use this to read information elements*/
61         CMD_CONFIGURE       = 2,    /*use this to write information elements*/
62         CMD_ENABLE_RX       = 3,
63         CMD_ENABLE_TX       = 4,
64         CMD_DISABLE_RX      = 5,
65         CMD_DISABLE_TX      = 6,
66         CMD_SCAN            = 8,
67         CMD_STOP_SCAN       = 9,
68         CMD_START_JOIN      = 11,
69         CMD_SET_KEYS        = 12,
70         CMD_READ_MEMORY     = 13,
71         CMD_WRITE_MEMORY    = 14,
72         CMD_SET_TEMPLATE    = 19,
73         CMD_TEST            = 23,
74         CMD_NOISE_HIST      = 28,
75         CMD_LNA_CONTROL     = 32,
76         CMD_SET_BCN_MODE    = 33,
77         CMD_MEASUREMENT      = 34,
78         CMD_STOP_MEASUREMENT = 35,
79         CMD_DISCONNECT       = 36,
80         CMD_SET_PS_MODE      = 37,
81         CMD_CHANNEL_SWITCH   = 38,
82         CMD_STOP_CHANNEL_SWICTH = 39,
83         CMD_AP_DISCOVERY     = 40,
84         CMD_STOP_AP_DISCOVERY = 41,
85         CMD_SPS_SCAN = 42,
86         CMD_STOP_SPS_SCAN = 43,
87         CMD_HEALTH_CHECK     = 45,
88         CMD_DEBUG            = 46,
89         CMD_TRIGGER_SCAN_TO  = 47,
90         CMD_CONNECTION_SCAN_CFG      = 48,
91         CMD_CONNECTION_SCAN_SSID_CFG = 49,
92         CMD_START_PERIODIC_SCAN      = 50,
93         CMD_STOP_PERIODIC_SCAN       = 51,
94         CMD_SET_STA_STATE            = 52,
95
96         NUM_COMMANDS,
97         MAX_COMMAND_ID = 0xFFFF,
98 };
99
100 #define MAX_CMD_PARAMS 572
101
102 enum {
103         CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
104         CMD_TEMPL_KLV_IDX_MAX = 4
105 };
106
107 enum cmd_templ {
108         CMD_TEMPL_NULL_DATA = 0,
109         CMD_TEMPL_BEACON,
110         CMD_TEMPL_CFG_PROBE_REQ_2_4,
111         CMD_TEMPL_CFG_PROBE_REQ_5,
112         CMD_TEMPL_PROBE_RESPONSE,
113         CMD_TEMPL_QOS_NULL_DATA,
114         CMD_TEMPL_PS_POLL,
115         CMD_TEMPL_KLV,
116         CMD_TEMPL_DISCONNECT,
117         CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
118         CMD_TEMPL_PROBE_REQ_5,   /* for firmware internal use only */
119         CMD_TEMPL_BAR,           /* for firmware internal use only */
120         CMD_TEMPL_CTS,           /*
121                                   * For CTS-to-self (FastCTS) mechanism
122                                   * for BT/WLAN coexistence (SoftGemini). */
123         CMD_TEMPL_MAX = 0xff
124 };
125
126 /* unit ms */
127 #define WL1271_COMMAND_TIMEOUT     2000
128 #define WL1271_CMD_TEMPL_MAX_SIZE  252
129 #define WL1271_EVENT_TIMEOUT       750
130
131 struct wl1271_cmd_header {
132         __le16 id;
133         __le16 status;
134         /* payload */
135         u8 data[0];
136 } __packed;
137
138 #define WL1271_CMD_MAX_PARAMS 572
139
140 struct wl1271_command {
141         struct wl1271_cmd_header header;
142         u8  parameters[WL1271_CMD_MAX_PARAMS];
143 } __packed;
144
145 enum {
146         CMD_MAILBOX_IDLE                =  0,
147         CMD_STATUS_SUCCESS              =  1,
148         CMD_STATUS_UNKNOWN_CMD          =  2,
149         CMD_STATUS_UNKNOWN_IE           =  3,
150         CMD_STATUS_REJECT_MEAS_SG_ACTIVE        = 11,
151         CMD_STATUS_RX_BUSY              = 13,
152         CMD_STATUS_INVALID_PARAM                = 14,
153         CMD_STATUS_TEMPLATE_TOO_LARGE           = 15,
154         CMD_STATUS_OUT_OF_MEMORY                = 16,
155         CMD_STATUS_STA_TABLE_FULL               = 17,
156         CMD_STATUS_RADIO_ERROR          = 18,
157         CMD_STATUS_WRONG_NESTING                = 19,
158         CMD_STATUS_TIMEOUT              = 21, /* Driver internal use.*/
159         CMD_STATUS_FW_RESET             = 22, /* Driver internal use.*/
160         MAX_COMMAND_STATUS              = 0xff
161 };
162
163
164 /*
165  * CMD_READ_MEMORY
166  *
167  * The host issues this command to read the WiLink device memory/registers.
168  *
169  * Note: The Base Band address has special handling (16 bits registers and
170  * addresses). For more information, see the hardware specification.
171  */
172 /*
173  * CMD_WRITE_MEMORY
174  *
175  * The host issues this command to write the WiLink device memory/registers.
176  *
177  * The Base Band address has special handling (16 bits registers and
178  * addresses). For more information, see the hardware specification.
179  */
180 #define MAX_READ_SIZE 256
181
182 struct cmd_read_write_memory {
183         struct wl1271_cmd_header header;
184
185         /* The address of the memory to read from or write to.*/
186         __le32 addr;
187
188         /* The amount of data in bytes to read from or write to the WiLink
189          * device.*/
190         __le32 size;
191
192         /* The actual value read from or written to the Wilink. The source
193            of this field is the Host in WRITE command or the Wilink in READ
194            command. */
195         u8 value[MAX_READ_SIZE];
196 } __packed;
197
198 #define CMDMBOX_HEADER_LEN 4
199 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
200
201 enum {
202         BSS_TYPE_IBSS = 0,
203         BSS_TYPE_STA_BSS = 2,
204         BSS_TYPE_AP_BSS = 3,
205         MAX_BSS_TYPE = 0xFF
206 };
207
208 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH     0x80 /* Firmware flushes all Tx */
209 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
210 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
211
212 struct wl1271_cmd_join {
213         struct wl1271_cmd_header header;
214
215         __le32 bssid_lsb;
216         __le16 bssid_msb;
217         __le16 beacon_interval; /* in TBTTs */
218         __le32 rx_config_options;
219         __le32 rx_filter_options;
220
221         /*
222          * The target uses this field to determine the rate at
223          * which to transmit control frame responses (such as
224          * ACK or CTS frames).
225          */
226         __le32 basic_rate_set;
227         u8 dtim_interval;
228         /*
229          * bits 0-2: This bitwise field specifies the type
230          * of BSS to start or join (BSS_TYPE_*).
231          * bit 4: Band - The radio band in which to join
232          * or start.
233          *  0 - 2.4GHz band
234          *  1 - 5GHz band
235          * bits 3, 5-7: Reserved
236          */
237         u8 bss_type;
238         u8 channel;
239         u8 ssid_len;
240         u8 ssid[IW_ESSID_MAX_SIZE];
241         u8 ctrl; /* JOIN_CMD_CTRL_* */
242         u8 reserved[3];
243 } __packed;
244
245 struct cmd_enabledisable_path {
246         struct wl1271_cmd_header header;
247
248         u8 channel;
249         u8 padding[3];
250 } __packed;
251
252 #define WL1271_RATE_AUTOMATIC  0
253
254 struct wl1271_cmd_template_set {
255         struct wl1271_cmd_header header;
256
257         __le16 len;
258         u8 template_type;
259         u8 index;  /* relevant only for KLV_TEMPLATE type */
260         __le32 enabled_rates;
261         u8 short_retry_limit;
262         u8 long_retry_limit;
263         u8 aflags;
264         u8 reserved;
265         u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
266 } __packed;
267
268 #define TIM_ELE_ID    5
269 #define PARTIAL_VBM_MAX    251
270
271 struct wl1271_tim {
272         u8 identity;
273         u8 length;
274         u8 dtim_count;
275         u8 dtim_period;
276         u8 bitmap_ctrl;
277         u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
278 } __packed;
279
280 enum wl1271_cmd_ps_mode {
281         STATION_ACTIVE_MODE,
282         STATION_POWER_SAVE_MODE
283 };
284
285 struct wl1271_cmd_ps_params {
286         struct wl1271_cmd_header header;
287
288         u8 ps_mode; /* STATION_* */
289         u8 send_null_data; /* Do we have to send NULL data packet ? */
290         u8 retries; /* Number of retires for the initial NULL data packet */
291
292          /*
293           * TUs during which the target stays awake after switching
294           * to power save mode.
295           */
296         u8 hang_over_period;
297         __le32 null_data_rate;
298 } __packed;
299
300 /* HW encryption keys */
301 #define NUM_ACCESS_CATEGORIES_COPY 4
302 #define MAX_KEY_SIZE 32
303
304 enum wl1271_cmd_key_action {
305         KEY_ADD_OR_REPLACE = 1,
306         KEY_REMOVE         = 2,
307         KEY_SET_ID         = 3,
308         MAX_KEY_ACTION     = 0xffff,
309 };
310
311 enum wl1271_cmd_key_type {
312         KEY_NONE = 0,
313         KEY_WEP  = 1,
314         KEY_TKIP = 2,
315         KEY_AES  = 3,
316         KEY_GEM  = 4
317 };
318
319 /* FIXME: Add description for key-types */
320
321 struct wl1271_cmd_set_keys {
322         struct wl1271_cmd_header header;
323
324         /* Ignored for default WEP key */
325         u8 addr[ETH_ALEN];
326
327         /* key_action_e */
328         __le16 key_action;
329
330         __le16 reserved_1;
331
332         /* key size in bytes */
333         u8 key_size;
334
335         /* key_type_e */
336         u8 key_type;
337         u8 ssid_profile;
338
339         /*
340          * TKIP, AES: frame's key id field.
341          * For WEP default key: key id;
342          */
343         u8 id;
344         u8 reserved_2[6];
345         u8 key[MAX_KEY_SIZE];
346         __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
347         __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
348 } __packed;
349
350 struct wl1271_cmd_test_header {
351         u8 id;
352         u8 padding[3];
353 } __packed;
354
355 enum wl1271_channel_tune_bands {
356         WL1271_CHANNEL_TUNE_BAND_2_4,
357         WL1271_CHANNEL_TUNE_BAND_5,
358         WL1271_CHANNEL_TUNE_BAND_4_9
359 };
360
361 #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
362
363 #define TEST_CMD_P2G_CAL                   0x02
364 #define TEST_CMD_CHANNEL_TUNE              0x0d
365 #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
366 #define TEST_CMD_INI_FILE_RADIO_PARAM      0x19
367 #define TEST_CMD_INI_FILE_GENERAL_PARAM    0x1E
368
369 struct wl1271_general_parms_cmd {
370         struct wl1271_cmd_header header;
371
372         struct wl1271_cmd_test_header test;
373
374         struct wl1271_ini_general_params general_params;
375
376         u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
377         u8 sr_sen_n_p;
378         u8 sr_sen_n_p_gain;
379         u8 sr_sen_nrn;
380         u8 sr_sen_prn;
381         u8 padding[3];
382 } __packed;
383
384 struct wl1271_radio_parms_cmd {
385         struct wl1271_cmd_header header;
386
387         struct wl1271_cmd_test_header test;
388
389         /* Static radio parameters */
390         struct wl1271_ini_band_params_2 static_params_2;
391         struct wl1271_ini_band_params_5 static_params_5;
392
393         /* Dynamic radio parameters */
394         struct wl1271_ini_fem_params_2 dyn_params_2;
395         u8 padding2;
396         struct wl1271_ini_fem_params_5 dyn_params_5;
397         u8 padding3[2];
398 } __packed;
399
400 struct wl1271_cmd_cal_channel_tune {
401         struct wl1271_cmd_header header;
402
403         struct wl1271_cmd_test_header test;
404
405         u8 band;
406         u8 channel;
407
408         __le16 radio_status;
409 } __packed;
410
411 struct wl1271_cmd_cal_update_ref_point {
412         struct wl1271_cmd_header header;
413
414         struct wl1271_cmd_test_header test;
415
416         __le32 ref_power;
417         __le32 ref_detector;
418         u8  sub_band;
419         u8  padding[3];
420 } __packed;
421
422 #define MAX_TLV_LENGTH         400
423 #define MAX_NVS_VERSION_LENGTH 12
424
425 #define WL1271_CAL_P2G_BAND_B_G BIT(0)
426
427 struct wl1271_cmd_cal_p2g {
428         struct wl1271_cmd_header header;
429
430         struct wl1271_cmd_test_header test;
431
432         __le16 len;
433         u8  buf[MAX_TLV_LENGTH];
434         u8  type;
435         u8  padding;
436
437         __le16 radio_status;
438         u8  nvs_version[MAX_NVS_VERSION_LENGTH];
439
440         u8  sub_band_mask;
441         u8  padding2;
442 } __packed;
443
444
445 /*
446  * There are three types of disconnections:
447  *
448  * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
449  * DISCONNECT_DEAUTH:    the fw generates a DEAUTH request with the reason
450  *                       we have passed
451  * DISCONNECT_DISASSOC:  the fw generates a DESASSOC request with the reason
452  *                       we have passed
453  */
454 enum wl1271_disconnect_type {
455         DISCONNECT_IMMEDIATE,
456         DISCONNECT_DEAUTH,
457         DISCONNECT_DISASSOC
458 };
459
460 struct wl1271_cmd_disconnect {
461         struct wl1271_cmd_header header;
462
463         __le32 rx_config_options;
464         __le32 rx_filter_options;
465
466         __le16 reason;
467         u8  type;
468
469         u8  padding;
470 } __packed;
471
472 #endif /* __WL1271_CMD_H__ */