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