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