wl1251: implement disconnect command properly
[pandora-kernel.git] / drivers / net / wireless / wl1251 / cmd.h
1 /*
2  * This file is part of wl1251
3  *
4  * Copyright (c) 1998-2007 Texas Instruments Incorporated
5  * Copyright (C) 2008 Nokia Corporation
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  *
21  */
22
23 #ifndef __WL1251_CMD_H__
24 #define __WL1251_CMD_H__
25
26 #include "wl1251.h"
27
28 #include <net/cfg80211.h>
29
30 struct acx_header;
31
32 int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len);
33 int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer);
34 int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len);
35 int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len);
36 int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity,
37                    void *bitmap, u16 bitmap_len, u8 bitmap_control);
38 int wl1251_cmd_data_path_rx(struct wl1251 *wl, u8 channel, bool enable);
39 int wl1251_cmd_data_path_tx(struct wl1251 *wl, u8 channel, bool enable);
40 int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel,
41                     u16 beacon_interval, u8 dtim_interval);
42 int wl1251_cmd_disconnect(struct wl1251 *wl);
43 int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
44 int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
45                            size_t len);
46 int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
47                             void *buf, size_t buf_len);
48 int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len,
49                     struct ieee80211_channel *channels[],
50                     unsigned int n_channels, unsigned int n_probes);
51 int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout);
52
53 /* unit ms */
54 #define WL1251_COMMAND_TIMEOUT 2000
55
56 enum wl1251_commands {
57         CMD_RESET           = 0,
58         CMD_INTERROGATE     = 1,    /*use this to read information elements*/
59         CMD_CONFIGURE       = 2,    /*use this to write information elements*/
60         CMD_ENABLE_RX       = 3,
61         CMD_ENABLE_TX       = 4,
62         CMD_DISABLE_RX      = 5,
63         CMD_DISABLE_TX      = 6,
64         CMD_SCAN            = 8,
65         CMD_STOP_SCAN       = 9,
66         CMD_VBM             = 10,
67         CMD_START_JOIN      = 11,
68         CMD_SET_KEYS        = 12,
69         CMD_READ_MEMORY     = 13,
70         CMD_WRITE_MEMORY    = 14,
71         CMD_BEACON          = 19,
72         CMD_PROBE_RESP      = 20,
73         CMD_NULL_DATA       = 21,
74         CMD_PROBE_REQ       = 22,
75         CMD_TEST            = 23,
76         CMD_RADIO_CALIBRATE     = 25,   /* OBSOLETE */
77         CMD_ENABLE_RX_PATH      = 27,   /* OBSOLETE */
78         CMD_NOISE_HIST      = 28,
79         CMD_RX_RESET        = 29,
80         CMD_PS_POLL         = 30,
81         CMD_QOS_NULL_DATA   = 31,
82         CMD_LNA_CONTROL     = 32,
83         CMD_SET_BCN_MODE    = 33,
84         CMD_MEASUREMENT      = 34,
85         CMD_STOP_MEASUREMENT = 35,
86         CMD_DISCONNECT       = 36,
87         CMD_SET_PS_MODE      = 37,
88         CMD_CHANNEL_SWITCH   = 38,
89         CMD_STOP_CHANNEL_SWICTH = 39,
90         CMD_AP_DISCOVERY     = 40,
91         CMD_STOP_AP_DISCOVERY = 41,
92         CMD_SPS_SCAN = 42,
93         CMD_STOP_SPS_SCAN = 43,
94         CMD_HEALTH_CHECK     = 45,
95         CMD_DEBUG            = 46,
96         CMD_TRIGGER_SCAN_TO  = 47,
97
98         NUM_COMMANDS,
99         MAX_COMMAND_ID = 0xFFFF,
100 };
101
102 #define MAX_CMD_PARAMS 572
103
104 struct wl1251_cmd_header {
105         u16 id;
106         u16 status;
107         /* payload */
108         u8 data[0];
109 } __packed;
110
111 struct  wl1251_command {
112         struct wl1251_cmd_header header;
113         u8  parameters[MAX_CMD_PARAMS];
114 } __packed;
115
116 enum {
117         CMD_MAILBOX_IDLE                        =  0,
118         CMD_STATUS_SUCCESS                      =  1,
119         CMD_STATUS_UNKNOWN_CMD                  =  2,
120         CMD_STATUS_UNKNOWN_IE                   =  3,
121         CMD_STATUS_REJECT_MEAS_SG_ACTIVE        = 11,
122         CMD_STATUS_RX_BUSY                      = 13,
123         CMD_STATUS_INVALID_PARAM                = 14,
124         CMD_STATUS_TEMPLATE_TOO_LARGE           = 15,
125         CMD_STATUS_OUT_OF_MEMORY                = 16,
126         CMD_STATUS_STA_TABLE_FULL               = 17,
127         CMD_STATUS_RADIO_ERROR                  = 18,
128         CMD_STATUS_WRONG_NESTING                = 19,
129         CMD_STATUS_TIMEOUT                      = 21, /* Driver internal use.*/
130         CMD_STATUS_FW_RESET                     = 22, /* Driver internal use.*/
131         MAX_COMMAND_STATUS                      = 0xff
132 };
133
134
135 /*
136  * CMD_READ_MEMORY
137  *
138  * The host issues this command to read the WiLink device memory/registers.
139  *
140  * Note: The Base Band address has special handling (16 bits registers and
141  * addresses). For more information, see the hardware specification.
142  */
143 /*
144  * CMD_WRITE_MEMORY
145  *
146  * The host issues this command to write the WiLink device memory/registers.
147  *
148  * The Base Band address has special handling (16 bits registers and
149  * addresses). For more information, see the hardware specification.
150  */
151 #define MAX_READ_SIZE 256
152
153 struct cmd_read_write_memory {
154         struct wl1251_cmd_header header;
155
156         /* The address of the memory to read from or write to.*/
157         u32 addr;
158
159         /* The amount of data in bytes to read from or write to the WiLink
160          * device.*/
161         u32 size;
162
163         /* The actual value read from or written to the Wilink. The source
164            of this field is the Host in WRITE command or the Wilink in READ
165            command. */
166         u8 value[MAX_READ_SIZE];
167 } __packed;
168
169 #define CMDMBOX_HEADER_LEN 4
170 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
171
172 #define WL1251_SCAN_OPT_PASSIVE         1
173 #define WL1251_SCAN_OPT_5GHZ_BAND       2
174 #define WL1251_SCAN_OPT_TRIGGERD_SCAN   4
175 #define WL1251_SCAN_OPT_PRIORITY_HIGH   8
176
177 #define WL1251_SCAN_MIN_DURATION 30000
178 #define WL1251_SCAN_MAX_DURATION 60000
179
180 #define WL1251_SCAN_NUM_PROBES 3
181
182 struct wl1251_scan_parameters {
183         __le32 rx_config_options;
184         __le32 rx_filter_options;
185
186         /*
187          * Scan options:
188          * bit 0: When this bit is set, passive scan.
189          * bit 1: Band, when this bit is set we scan
190          * in the 5Ghz band.
191          * bit 2: voice mode, 0 for normal scan.
192          * bit 3: scan priority, 1 for high priority.
193          */
194         __le16 scan_options;
195
196         /* Number of channels to scan */
197         u8 num_channels;
198
199         /* Number opf probe requests to send, per channel */
200         u8 num_probe_requests;
201
202         /* Rate and modulation for probe requests */
203         __le16 tx_rate;
204
205         u8 tid_trigger;
206         u8 ssid_len;
207         u8 ssid[32];
208
209 } __packed;
210
211 struct wl1251_scan_ch_parameters {
212         __le32 min_duration; /* in TU */
213         __le32 max_duration; /* in TU */
214         u32 bssid_lsb;
215         u16 bssid_msb;
216
217         /*
218          * bits 0-3: Early termination count.
219          * bits 4-5: Early termination condition.
220          */
221         u8 early_termination;
222
223         u8 tx_power_att;
224         u8 channel;
225         u8 pad[3];
226 } __packed;
227
228 /* SCAN parameters */
229 #define SCAN_MAX_NUM_OF_CHANNELS 16
230
231 struct wl1251_cmd_scan {
232         struct wl1251_cmd_header header;
233
234         struct wl1251_scan_parameters params;
235         struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
236 } __packed;
237
238 enum {
239         BSS_TYPE_IBSS = 0,
240         BSS_TYPE_STA_BSS = 2,
241         BSS_TYPE_AP_BSS = 3,
242         MAX_BSS_TYPE = 0xFF
243 };
244
245 #define JOIN_CMD_CTRL_TX_FLUSH             0x80 /* Firmware flushes all Tx */
246 #define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE  0x01 /* Early wakeup time */
247
248
249 struct cmd_join {
250         struct wl1251_cmd_header header;
251
252         u32 bssid_lsb;
253         u16 bssid_msb;
254         u16 beacon_interval; /* in TBTTs */
255         u32 rx_config_options;
256         u32 rx_filter_options;
257
258         /*
259          * The target uses this field to determine the rate at
260          * which to transmit control frame responses (such as
261          * ACK or CTS frames).
262          */
263         u16 basic_rate_set;
264         u8 dtim_interval;
265         u8 tx_ctrl_frame_rate; /* OBSOLETE */
266         u8 tx_ctrl_frame_mod;  /* OBSOLETE */
267         /*
268          * bits 0-2: This bitwise field specifies the type
269          * of BSS to start or join (BSS_TYPE_*).
270          * bit 4: Band - The radio band in which to join
271          * or start.
272          *  0 - 2.4GHz band
273          *  1 - 5GHz band
274          * bits 3, 5-7: Reserved
275          */
276         u8 bss_type;
277         u8 channel;
278         u8 ssid_len;
279         u8 ssid[IEEE80211_MAX_SSID_LEN];
280         u8 ctrl; /* JOIN_CMD_CTRL_* */
281         u8 tx_mgt_frame_rate; /* OBSOLETE */
282         u8 tx_mgt_frame_mod;  /* OBSOLETE */
283         u8 reserved;
284 } __packed;
285
286 struct wl1251_cmd_disconnect {
287         struct wl1251_cmd_header header;
288
289         u32 rx_config_options;
290         u32 rx_filter_options;
291 } __packed;
292
293 struct cmd_enabledisable_path {
294         struct wl1251_cmd_header header;
295
296         u8 channel;
297         u8 padding[3];
298 } __packed;
299
300 #define WL1251_MAX_TEMPLATE_SIZE 300
301
302 struct wl1251_cmd_packet_template {
303         struct wl1251_cmd_header header;
304
305         __le16 size;
306         u8 data[0];
307 } __packed;
308
309 #define TIM_ELE_ID    5
310 #define PARTIAL_VBM_MAX    251
311
312 struct wl1251_tim {
313         u8 identity;
314         u8 length;
315         u8 dtim_count;
316         u8 dtim_period;
317         u8 bitmap_ctrl;
318         u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
319 } __packed;
320
321 /* Virtual Bit Map update */
322 struct wl1251_cmd_vbm_update {
323         struct wl1251_cmd_header header;
324         __le16 len;
325         u8  padding[2];
326         struct wl1251_tim tim;
327 } __packed;
328
329 enum wl1251_cmd_ps_mode {
330         CHIP_ACTIVE_MODE,
331         CHIP_POWER_SAVE_MODE
332 };
333
334 struct wl1251_cmd_ps_params {
335         struct wl1251_cmd_header header;
336
337         u8 ps_mode; /* STATION_* */
338         u8 send_null_data; /* Do we have to send NULL data packet ? */
339         u8 retries; /* Number of retires for the initial NULL data packet */
340
341          /*
342           * TUs during which the target stays awake after switching
343           * to power save mode.
344           */
345         u8 hang_over_period;
346         u16 null_data_rate;
347         u8 pad[2];
348 } __packed;
349
350 struct wl1251_cmd_trigger_scan_to {
351         struct wl1251_cmd_header header;
352
353         u32 timeout;
354 } __packed;
355
356 /* HW encryption keys */
357 #define NUM_ACCESS_CATEGORIES_COPY 4
358 #define MAX_KEY_SIZE 32
359
360 /* When set, disable HW encryption */
361 #define DF_ENCRYPTION_DISABLE      0x01
362 /* When set, disable HW decryption */
363 #define DF_SNIFF_MODE_ENABLE       0x80
364
365 enum wl1251_cmd_key_action {
366         KEY_ADD_OR_REPLACE = 1,
367         KEY_REMOVE         = 2,
368         KEY_SET_ID         = 3,
369         MAX_KEY_ACTION     = 0xffff,
370 };
371
372 enum wl1251_cmd_key_type {
373         KEY_WEP_DEFAULT       = 0,
374         KEY_WEP_ADDR          = 1,
375         KEY_AES_GROUP         = 4,
376         KEY_AES_PAIRWISE      = 5,
377         KEY_WEP_GROUP         = 6,
378         KEY_TKIP_MIC_GROUP    = 10,
379         KEY_TKIP_MIC_PAIRWISE = 11,
380 };
381
382 /*
383  *
384  * key_type_e   key size    key format
385  * ----------   ---------   ----------
386  * 0x00         5, 13, 29   Key data
387  * 0x01         5, 13, 29   Key data
388  * 0x04         16          16 bytes of key data
389  * 0x05         16          16 bytes of key data
390  * 0x0a         32          16 bytes of TKIP key data
391  *                          8 bytes of RX MIC key data
392  *                          8 bytes of TX MIC key data
393  * 0x0b         32          16 bytes of TKIP key data
394  *                          8 bytes of RX MIC key data
395  *                          8 bytes of TX MIC key data
396  *
397  */
398
399 struct wl1251_cmd_set_keys {
400         struct wl1251_cmd_header header;
401
402         /* Ignored for default WEP key */
403         u8 addr[ETH_ALEN];
404
405         /* key_action_e */
406         u16 key_action;
407
408         u16 reserved_1;
409
410         /* key size in bytes */
411         u8 key_size;
412
413         /* key_type_e */
414         u8 key_type;
415         u8 ssid_profile;
416
417         /*
418          * TKIP, AES: frame's key id field.
419          * For WEP default key: key id;
420          */
421         u8 id;
422         u8 reserved_2[6];
423         u8 key[MAX_KEY_SIZE];
424         u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
425         u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
426 } __packed;
427
428
429 #endif /* __WL1251_CMD_H__ */