blob: 63ae3193f7c6f77488b4c6aef281192839300432 [file] [log] [blame]
Kalle Valo2f01a1f2009-04-29 23:33:31 +03001/*
Kalle Valo80301cd2009-06-12 14:17:39 +03002 * This file is part of wl1251
Kalle Valo2f01a1f2009-04-29 23:33:31 +03003 *
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
Kalle Valo80301cd2009-06-12 14:17:39 +030025#ifndef __WL1251_CMD_H__
26#define __WL1251_CMD_H__
Kalle Valo2f01a1f2009-04-29 23:33:31 +030027
Kalle Valo13674112009-06-12 14:17:25 +030028#include "wl1251.h"
Kalle Valo2f01a1f2009-04-29 23:33:31 +030029
Kalle Valoff258392009-06-12 14:14:19 +030030struct acx_header;
31
Kalle Valo80301cd2009-06-12 14:17:39 +030032int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len);
33int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer);
34int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len);
35int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len);
36int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030037 void *bitmap, u16 bitmap_len, u8 bitmap_control);
Kalle Valo80301cd2009-06-12 14:17:39 +030038int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable);
Kalle Valoc88f8752009-08-07 13:34:34 +030039int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel,
40 u16 beacon_interval, u8 dtim_interval);
Kalle Valo80301cd2009-06-12 14:17:39 +030041int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
42int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
Kalle Valoff258392009-06-12 14:14:19 +030043 size_t len);
Kalle Valo80301cd2009-06-12 14:17:39 +030044int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030045 void *buf, size_t buf_len);
Kalle Valo3a98c302010-01-05 20:16:51 +020046int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len,
47 unsigned int n_channels, unsigned int n_probes);
48int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout);
Kalle Valo2f01a1f2009-04-29 23:33:31 +030049
50/* unit ms */
Kalle Valo80301cd2009-06-12 14:17:39 +030051#define WL1251_COMMAND_TIMEOUT 2000
Kalle Valo2f01a1f2009-04-29 23:33:31 +030052
Kalle Valo80301cd2009-06-12 14:17:39 +030053enum wl1251_commands {
Kalle Valo2f01a1f2009-04-29 23:33:31 +030054 CMD_RESET = 0,
55 CMD_INTERROGATE = 1, /*use this to read information elements*/
56 CMD_CONFIGURE = 2, /*use this to write information elements*/
57 CMD_ENABLE_RX = 3,
58 CMD_ENABLE_TX = 4,
59 CMD_DISABLE_RX = 5,
60 CMD_DISABLE_TX = 6,
61 CMD_SCAN = 8,
62 CMD_STOP_SCAN = 9,
63 CMD_VBM = 10,
64 CMD_START_JOIN = 11,
65 CMD_SET_KEYS = 12,
66 CMD_READ_MEMORY = 13,
67 CMD_WRITE_MEMORY = 14,
68 CMD_BEACON = 19,
69 CMD_PROBE_RESP = 20,
70 CMD_NULL_DATA = 21,
71 CMD_PROBE_REQ = 22,
72 CMD_TEST = 23,
73 CMD_RADIO_CALIBRATE = 25, /* OBSOLETE */
74 CMD_ENABLE_RX_PATH = 27, /* OBSOLETE */
75 CMD_NOISE_HIST = 28,
76 CMD_RX_RESET = 29,
77 CMD_PS_POLL = 30,
78 CMD_QOS_NULL_DATA = 31,
79 CMD_LNA_CONTROL = 32,
80 CMD_SET_BCN_MODE = 33,
81 CMD_MEASUREMENT = 34,
82 CMD_STOP_MEASUREMENT = 35,
83 CMD_DISCONNECT = 36,
84 CMD_SET_PS_MODE = 37,
85 CMD_CHANNEL_SWITCH = 38,
86 CMD_STOP_CHANNEL_SWICTH = 39,
87 CMD_AP_DISCOVERY = 40,
88 CMD_STOP_AP_DISCOVERY = 41,
89 CMD_SPS_SCAN = 42,
90 CMD_STOP_SPS_SCAN = 43,
91 CMD_HEALTH_CHECK = 45,
92 CMD_DEBUG = 46,
93 CMD_TRIGGER_SCAN_TO = 47,
94
95 NUM_COMMANDS,
96 MAX_COMMAND_ID = 0xFFFF,
97};
98
99#define MAX_CMD_PARAMS 572
100
Kalle Valo80301cd2009-06-12 14:17:39 +0300101struct wl1251_cmd_header {
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300102 u16 id;
103 u16 status;
Kalle Valoff258392009-06-12 14:14:19 +0300104 /* payload */
105 u8 data[0];
106} __attribute__ ((packed));
107
Kalle Valo80301cd2009-06-12 14:17:39 +0300108struct wl1251_command {
109 struct wl1251_cmd_header header;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300110 u8 parameters[MAX_CMD_PARAMS];
111};
112
113enum {
114 CMD_MAILBOX_IDLE = 0,
115 CMD_STATUS_SUCCESS = 1,
116 CMD_STATUS_UNKNOWN_CMD = 2,
117 CMD_STATUS_UNKNOWN_IE = 3,
118 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
119 CMD_STATUS_RX_BUSY = 13,
120 CMD_STATUS_INVALID_PARAM = 14,
121 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
122 CMD_STATUS_OUT_OF_MEMORY = 16,
123 CMD_STATUS_STA_TABLE_FULL = 17,
124 CMD_STATUS_RADIO_ERROR = 18,
125 CMD_STATUS_WRONG_NESTING = 19,
126 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
127 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
128 MAX_COMMAND_STATUS = 0xff
129};
130
131
132/*
133 * CMD_READ_MEMORY
134 *
135 * The host issues this command to read the WiLink device memory/registers.
136 *
137 * Note: The Base Band address has special handling (16 bits registers and
138 * addresses). For more information, see the hardware specification.
139 */
140/*
141 * CMD_WRITE_MEMORY
142 *
143 * The host issues this command to write the WiLink device memory/registers.
144 *
145 * The Base Band address has special handling (16 bits registers and
146 * addresses). For more information, see the hardware specification.
147 */
148#define MAX_READ_SIZE 256
149
150struct cmd_read_write_memory {
Kalle Valo80301cd2009-06-12 14:17:39 +0300151 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300152
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300153 /* The address of the memory to read from or write to.*/
154 u32 addr;
155
156 /* The amount of data in bytes to read from or write to the WiLink
157 * device.*/
158 u32 size;
159
160 /* The actual value read from or written to the Wilink. The source
161 of this field is the Host in WRITE command or the Wilink in READ
162 command. */
163 u8 value[MAX_READ_SIZE];
164};
165
166#define CMDMBOX_HEADER_LEN 4
167#define CMDMBOX_INFO_ELEM_HEADER_LEN 4
168
Kalle Valo3a98c302010-01-05 20:16:51 +0200169#define WL1251_SCAN_MIN_DURATION 30000
170#define WL1251_SCAN_MAX_DURATION 60000
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300171
Kalle Valo3a98c302010-01-05 20:16:51 +0200172struct wl1251_scan_parameters {
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300173 u32 rx_config_options;
174 u32 rx_filter_options;
175
176 /*
177 * Scan options:
178 * bit 0: When this bit is set, passive scan.
179 * bit 1: Band, when this bit is set we scan
180 * in the 5Ghz band.
181 * bit 2: voice mode, 0 for normal scan.
182 * bit 3: scan priority, 1 for high priority.
183 */
184 u16 scan_options;
185
186 /* Number of channels to scan */
187 u8 num_channels;
188
189 /* Number opf probe requests to send, per channel */
190 u8 num_probe_requests;
191
192 /* Rate and modulation for probe requests */
193 u16 tx_rate;
194
195 u8 tid_trigger;
196 u8 ssid_len;
Kalle Valo3a98c302010-01-05 20:16:51 +0200197 u8 ssid[32];
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300198
199} __attribute__ ((packed));
200
Kalle Valo3a98c302010-01-05 20:16:51 +0200201struct wl1251_scan_ch_parameters {
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300202 u32 min_duration; /* in TU */
203 u32 max_duration; /* in TU */
204 u32 bssid_lsb;
205 u16 bssid_msb;
206
207 /*
208 * bits 0-3: Early termination count.
209 * bits 4-5: Early termination condition.
210 */
211 u8 early_termination;
212
213 u8 tx_power_att;
214 u8 channel;
215 u8 pad[3];
216} __attribute__ ((packed));
217
218/* SCAN parameters */
219#define SCAN_MAX_NUM_OF_CHANNELS 16
220
Kalle Valo3a98c302010-01-05 20:16:51 +0200221struct wl1251_cmd_scan {
Kalle Valo80301cd2009-06-12 14:17:39 +0300222 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300223
Kalle Valo3a98c302010-01-05 20:16:51 +0200224 struct wl1251_scan_parameters params;
225 struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300226} __attribute__ ((packed));
227
228enum {
229 BSS_TYPE_IBSS = 0,
230 BSS_TYPE_STA_BSS = 2,
231 BSS_TYPE_AP_BSS = 3,
232 MAX_BSS_TYPE = 0xFF
233};
234
235#define JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
236#define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE 0x01 /* Early wakeup time */
237
238
239struct cmd_join {
Kalle Valo80301cd2009-06-12 14:17:39 +0300240 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300241
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300242 u32 bssid_lsb;
243 u16 bssid_msb;
244 u16 beacon_interval; /* in TBTTs */
245 u32 rx_config_options;
246 u32 rx_filter_options;
247
248 /*
249 * The target uses this field to determine the rate at
250 * which to transmit control frame responses (such as
251 * ACK or CTS frames).
252 */
253 u16 basic_rate_set;
254 u8 dtim_interval;
255 u8 tx_ctrl_frame_rate; /* OBSOLETE */
256 u8 tx_ctrl_frame_mod; /* OBSOLETE */
257 /*
258 * bits 0-2: This bitwise field specifies the type
259 * of BSS to start or join (BSS_TYPE_*).
260 * bit 4: Band - The radio band in which to join
261 * or start.
262 * 0 - 2.4GHz band
263 * 1 - 5GHz band
264 * bits 3, 5-7: Reserved
265 */
266 u8 bss_type;
267 u8 channel;
268 u8 ssid_len;
269 u8 ssid[IW_ESSID_MAX_SIZE];
270 u8 ctrl; /* JOIN_CMD_CTRL_* */
271 u8 tx_mgt_frame_rate; /* OBSOLETE */
272 u8 tx_mgt_frame_mod; /* OBSOLETE */
273 u8 reserved;
274} __attribute__ ((packed));
275
Kalle Valoff258392009-06-12 14:14:19 +0300276struct cmd_enabledisable_path {
Kalle Valo80301cd2009-06-12 14:17:39 +0300277 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300278
279 u8 channel;
280 u8 padding[3];
281} __attribute__ ((packed));
282
Kalle Valo80301cd2009-06-12 14:17:39 +0300283#define WL1251_MAX_TEMPLATE_SIZE 300
Kalle Valoff258392009-06-12 14:14:19 +0300284
Kalle Valo80301cd2009-06-12 14:17:39 +0300285struct wl1251_cmd_packet_template {
286 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300287
288 __le16 size;
289 u8 data[0];
290} __attribute__ ((packed));
291
292#define TIM_ELE_ID 5
293#define PARTIAL_VBM_MAX 251
294
Kalle Valo80301cd2009-06-12 14:17:39 +0300295struct wl1251_tim {
Kalle Valoff258392009-06-12 14:14:19 +0300296 u8 identity;
297 u8 length;
298 u8 dtim_count;
299 u8 dtim_period;
300 u8 bitmap_ctrl;
301 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
302} __attribute__ ((packed));
303
304/* Virtual Bit Map update */
Kalle Valo80301cd2009-06-12 14:17:39 +0300305struct wl1251_cmd_vbm_update {
306 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300307 __le16 len;
308 u8 padding[2];
Kalle Valo80301cd2009-06-12 14:17:39 +0300309 struct wl1251_tim tim;
Kalle Valoff258392009-06-12 14:14:19 +0300310} __attribute__ ((packed));
311
Kalle Valo80301cd2009-06-12 14:17:39 +0300312enum wl1251_cmd_ps_mode {
Kalle Valoff258392009-06-12 14:14:19 +0300313 STATION_ACTIVE_MODE,
314 STATION_POWER_SAVE_MODE
315};
316
Kalle Valo80301cd2009-06-12 14:17:39 +0300317struct wl1251_cmd_ps_params {
318 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300319
320 u8 ps_mode; /* STATION_* */
321 u8 send_null_data; /* Do we have to send NULL data packet ? */
322 u8 retries; /* Number of retires for the initial NULL data packet */
323
324 /*
325 * TUs during which the target stays awake after switching
326 * to power save mode.
327 */
328 u8 hang_over_period;
329 u16 null_data_rate;
330 u8 pad[2];
331} __attribute__ ((packed));
332
Kalle Valo80301cd2009-06-12 14:17:39 +0300333struct wl1251_cmd_trigger_scan_to {
334 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300335
336 u32 timeout;
337};
338
339/* HW encryption keys */
340#define NUM_ACCESS_CATEGORIES_COPY 4
341#define MAX_KEY_SIZE 32
342
343/* When set, disable HW encryption */
344#define DF_ENCRYPTION_DISABLE 0x01
345/* When set, disable HW decryption */
346#define DF_SNIFF_MODE_ENABLE 0x80
347
Kalle Valo80301cd2009-06-12 14:17:39 +0300348enum wl1251_cmd_key_action {
Kalle Valoff258392009-06-12 14:14:19 +0300349 KEY_ADD_OR_REPLACE = 1,
350 KEY_REMOVE = 2,
351 KEY_SET_ID = 3,
352 MAX_KEY_ACTION = 0xffff,
353};
354
Kalle Valo80301cd2009-06-12 14:17:39 +0300355enum wl1251_cmd_key_type {
Kalle Valoff258392009-06-12 14:14:19 +0300356 KEY_WEP_DEFAULT = 0,
357 KEY_WEP_ADDR = 1,
358 KEY_AES_GROUP = 4,
359 KEY_AES_PAIRWISE = 5,
360 KEY_WEP_GROUP = 6,
361 KEY_TKIP_MIC_GROUP = 10,
362 KEY_TKIP_MIC_PAIRWISE = 11,
363};
364
365/*
366 *
367 * key_type_e key size key format
368 * ---------- --------- ----------
369 * 0x00 5, 13, 29 Key data
370 * 0x01 5, 13, 29 Key data
371 * 0x04 16 16 bytes of key data
372 * 0x05 16 16 bytes of key data
373 * 0x0a 32 16 bytes of TKIP key data
374 * 8 bytes of RX MIC key data
375 * 8 bytes of TX MIC key data
376 * 0x0b 32 16 bytes of TKIP key data
377 * 8 bytes of RX MIC key data
378 * 8 bytes of TX MIC key data
379 *
380 */
381
Kalle Valo80301cd2009-06-12 14:17:39 +0300382struct wl1251_cmd_set_keys {
383 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300384
385 /* Ignored for default WEP key */
386 u8 addr[ETH_ALEN];
387
388 /* key_action_e */
389 u16 key_action;
390
391 u16 reserved_1;
392
393 /* key size in bytes */
394 u8 key_size;
395
396 /* key_type_e */
397 u8 key_type;
398 u8 ssid_profile;
399
400 /*
401 * TKIP, AES: frame's key id field.
402 * For WEP default key: key id;
403 */
404 u8 id;
405 u8 reserved_2[6];
406 u8 key[MAX_KEY_SIZE];
407 u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
408 u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
409} __attribute__ ((packed));
410
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300411
Kalle Valo80301cd2009-06-12 14:17:39 +0300412#endif /* __WL1251_CMD_H__ */