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