2 * This file is part of wl1271
4 * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
5 * Copyright (C) 2009 Nokia Corporation
7 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
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.
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.
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
25 #ifndef __WL1271_CMD_H__
26 #define __WL1271_CMD_H__
32 int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
34 int wl1271_cmd_general_parms(struct wl1271 *wl);
35 int wl1271_cmd_radio_parms(struct wl1271 *wl);
36 int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type);
37 int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
38 int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
39 int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
40 int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
41 int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send);
42 int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
44 int 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);
47 int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
48 void *buf, size_t buf_len, int index, u32 rates);
49 int wl1271_cmd_build_null_data(struct wl1271 *wl);
50 int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
51 int 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);
54 int wl1271_build_qos_null_data(struct wl1271 *wl);
55 int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
56 int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
57 int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
58 u8 key_size, const u8 *key, const u8 *addr,
59 u32 tx_seq_32, u16 tx_seq_16);
60 int wl1271_cmd_disconnect(struct wl1271 *wl);
62 enum wl1271_commands {
63 CMD_INTERROGATE = 1, /*use this to read information elements*/
64 CMD_CONFIGURE = 2, /*use this to write information elements*/
74 CMD_WRITE_MEMORY = 14,
75 CMD_SET_TEMPLATE = 19,
79 CMD_SET_BCN_MODE = 33,
81 CMD_STOP_MEASUREMENT = 35,
84 CMD_CHANNEL_SWITCH = 38,
85 CMD_STOP_CHANNEL_SWICTH = 39,
86 CMD_AP_DISCOVERY = 40,
87 CMD_STOP_AP_DISCOVERY = 41,
89 CMD_STOP_SPS_SCAN = 43,
90 CMD_HEALTH_CHECK = 45,
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,
100 MAX_COMMAND_ID = 0xFFFF,
103 #define MAX_CMD_PARAMS 572
106 CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
107 CMD_TEMPL_KLV_IDX_MAX = 4
111 CMD_TEMPL_NULL_DATA = 0,
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,
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 */
124 * For CTS-to-self (FastCTS) mechanism
125 * for BT/WLAN coexistence (SoftGemini). */
130 #define WL1271_COMMAND_TIMEOUT 2000
131 #define WL1271_CMD_TEMPL_MAX_SIZE 252
132 #define WL1271_EVENT_TIMEOUT 750
134 struct wl1271_cmd_header {
139 } __attribute__ ((packed));
141 #define WL1271_CMD_MAX_PARAMS 572
143 struct wl1271_command {
144 struct wl1271_cmd_header header;
145 u8 parameters[WL1271_CMD_MAX_PARAMS];
146 } __attribute__ ((packed));
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
170 * The host issues this command to read the WiLink device memory/registers.
172 * Note: The Base Band address has special handling (16 bits registers and
173 * addresses). For more information, see the hardware specification.
178 * The host issues this command to write the WiLink device memory/registers.
180 * The Base Band address has special handling (16 bits registers and
181 * addresses). For more information, see the hardware specification.
183 #define MAX_READ_SIZE 256
185 struct cmd_read_write_memory {
186 struct wl1271_cmd_header header;
188 /* The address of the memory to read from or write to.*/
191 /* The amount of data in bytes to read from or write to the WiLink
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
198 u8 value[MAX_READ_SIZE];
199 } __attribute__ ((packed));
201 #define CMDMBOX_HEADER_LEN 4
202 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
206 BSS_TYPE_STA_BSS = 2,
211 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
212 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
213 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
215 struct wl1271_cmd_join {
216 struct wl1271_cmd_header header;
220 __le16 beacon_interval; /* in TBTTs */
221 __le32 rx_config_options;
222 __le32 rx_filter_options;
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).
229 __le32 basic_rate_set;
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
238 * bits 3, 5-7: Reserved
243 u8 ssid[IW_ESSID_MAX_SIZE];
244 u8 ctrl; /* JOIN_CMD_CTRL_* */
246 } __attribute__ ((packed));
248 struct cmd_enabledisable_path {
249 struct wl1271_cmd_header header;
253 } __attribute__ ((packed));
255 #define WL1271_RATE_AUTOMATIC 0
257 struct wl1271_cmd_template_set {
258 struct wl1271_cmd_header header;
262 u8 index; /* relevant only for KLV_TEMPLATE type */
263 __le32 enabled_rates;
264 u8 short_retry_limit;
268 u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
269 } __attribute__ ((packed));
272 #define PARTIAL_VBM_MAX 251
280 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
281 } __attribute__ ((packed));
283 enum wl1271_cmd_ps_mode {
285 STATION_POWER_SAVE_MODE
288 struct wl1271_cmd_ps_params {
289 struct wl1271_cmd_header header;
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 */
296 * TUs during which the target stays awake after switching
297 * to power save mode.
300 __le32 null_data_rate;
301 } __attribute__ ((packed));
303 /* HW encryption keys */
304 #define NUM_ACCESS_CATEGORIES_COPY 4
305 #define MAX_KEY_SIZE 32
307 enum wl1271_cmd_key_action {
308 KEY_ADD_OR_REPLACE = 1,
311 MAX_KEY_ACTION = 0xffff,
314 enum wl1271_cmd_key_type {
322 /* FIXME: Add description for key-types */
324 struct wl1271_cmd_set_keys {
325 struct wl1271_cmd_header header;
327 /* Ignored for default WEP key */
335 /* key size in bytes */
343 * TKIP, AES: frame's key id field.
344 * For WEP default key: key id;
348 u8 key[MAX_KEY_SIZE];
349 __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
350 __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
351 } __attribute__ ((packed));
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 */
362 #define WL1271_SCAN_BAND_2_4_GHZ 0
363 #define WL1271_SCAN_BAND_5_GHZ 1
364 #define WL1271_SCAN_BAND_DUAL 2
366 struct basic_scan_params {
367 __le32 rx_config_options;
368 __le32 rx_filter_options;
369 /* Scan option flags (WL1271_SCAN_OPT_*) */
371 /* Number of scan channels in the list (maximum 30) */
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 */
380 /* in order to align */
382 u8 ssid[IW_ESSID_MAX_SIZE];
388 } __attribute__ ((packed));
390 struct basic_scan_channel_params {
391 /* Duration in TU to wait for frames on a channel for active scan */
396 u8 early_termination;
399 /* FW internal use only! */
401 u8 activity_detected;
403 } __attribute__ ((packed));
405 struct wl1271_cmd_scan {
406 struct wl1271_cmd_header header;
408 struct basic_scan_params params;
409 struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
410 } __attribute__ ((packed));
412 struct wl1271_cmd_trigger_scan_to {
413 struct wl1271_cmd_header header;
416 } __attribute__ ((packed));
418 struct wl1271_cmd_test_header {
421 } __attribute__ ((packed));
423 enum wl1271_channel_tune_bands {
424 WL1271_CHANNEL_TUNE_BAND_2_4,
425 WL1271_CHANNEL_TUNE_BAND_5,
426 WL1271_CHANNEL_TUNE_BAND_4_9
429 #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
431 #define TEST_CMD_P2G_CAL 0x02
432 #define TEST_CMD_CHANNEL_TUNE 0x0d
433 #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
434 #define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
435 #define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
437 struct wl1271_general_parms_cmd {
438 struct wl1271_cmd_header header;
440 struct wl1271_cmd_test_header test;
442 struct wl1271_ini_general_params general_params;
444 u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
450 } __attribute__ ((packed));
452 struct wl1271_radio_parms_cmd {
453 struct wl1271_cmd_header header;
455 struct wl1271_cmd_test_header test;
457 /* Static radio parameters */
458 struct wl1271_ini_band_params_2 static_params_2;
459 struct wl1271_ini_band_params_5 static_params_5;
461 /* Dynamic radio parameters */
462 struct wl1271_ini_fem_params_2 dyn_params_2;
464 struct wl1271_ini_fem_params_5 dyn_params_5;
466 } __attribute__ ((packed));
468 struct wl1271_cmd_cal_channel_tune {
469 struct wl1271_cmd_header header;
471 struct wl1271_cmd_test_header test;
477 } __attribute__ ((packed));
479 struct wl1271_cmd_cal_update_ref_point {
480 struct wl1271_cmd_header header;
482 struct wl1271_cmd_test_header test;
488 } __attribute__ ((packed));
490 #define MAX_TLV_LENGTH 400
491 #define MAX_NVS_VERSION_LENGTH 12
493 #define WL1271_CAL_P2G_BAND_B_G BIT(0)
495 struct wl1271_cmd_cal_p2g {
496 struct wl1271_cmd_header header;
498 struct wl1271_cmd_test_header test;
501 u8 buf[MAX_TLV_LENGTH];
506 u8 nvs_version[MAX_NVS_VERSION_LENGTH];
510 } __attribute__ ((packed));
514 * There are three types of disconnections:
516 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
517 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
519 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
522 enum wl1271_disconnect_type {
523 DISCONNECT_IMMEDIATE,
528 struct wl1271_cmd_disconnect {
529 struct wl1271_cmd_header header;
531 __le32 rx_config_options;
532 __le32 rx_filter_options;
538 } __attribute__ ((packed));
540 #endif /* __WL1271_CMD_H__ */