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