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