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);
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_set_default_wep_key(struct wl1271 *wl, u8 id);
56 int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
57 u8 key_size, const u8 *key, const u8 *addr,
58 u32 tx_seq_32, u16 tx_seq_16);
59 int wl1271_cmd_disconnect(struct wl1271 *wl);
61 enum wl1271_commands {
62 CMD_INTERROGATE = 1, /*use this to read information elements*/
63 CMD_CONFIGURE = 2, /*use this to write information elements*/
73 CMD_WRITE_MEMORY = 14,
74 CMD_SET_TEMPLATE = 19,
78 CMD_SET_BCN_MODE = 33,
80 CMD_STOP_MEASUREMENT = 35,
83 CMD_CHANNEL_SWITCH = 38,
84 CMD_STOP_CHANNEL_SWICTH = 39,
85 CMD_AP_DISCOVERY = 40,
86 CMD_STOP_AP_DISCOVERY = 41,
88 CMD_STOP_SPS_SCAN = 43,
89 CMD_HEALTH_CHECK = 45,
91 CMD_TRIGGER_SCAN_TO = 47,
92 CMD_CONNECTION_SCAN_CFG = 48,
93 CMD_CONNECTION_SCAN_SSID_CFG = 49,
94 CMD_START_PERIODIC_SCAN = 50,
95 CMD_STOP_PERIODIC_SCAN = 51,
96 CMD_SET_STA_STATE = 52,
99 MAX_COMMAND_ID = 0xFFFF,
102 #define MAX_CMD_PARAMS 572
105 CMD_TEMPL_NULL_DATA = 0,
107 CMD_TEMPL_CFG_PROBE_REQ_2_4,
108 CMD_TEMPL_CFG_PROBE_REQ_5,
109 CMD_TEMPL_PROBE_RESPONSE,
110 CMD_TEMPL_QOS_NULL_DATA,
113 CMD_TEMPL_DISCONNECT,
114 CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
115 CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
116 CMD_TEMPL_BAR, /* for firmware internal use only */
118 * For CTS-to-self (FastCTS) mechanism
119 * for BT/WLAN coexistence (SoftGemini). */
124 #define WL1271_COMMAND_TIMEOUT 2000
125 #define WL1271_CMD_TEMPL_MAX_SIZE 252
126 #define WL1271_EVENT_TIMEOUT 100
128 struct wl1271_cmd_header {
133 } __attribute__ ((packed));
135 #define WL1271_CMD_MAX_PARAMS 572
137 struct wl1271_command {
138 struct wl1271_cmd_header header;
139 u8 parameters[WL1271_CMD_MAX_PARAMS];
140 } __attribute__ ((packed));
143 CMD_MAILBOX_IDLE = 0,
144 CMD_STATUS_SUCCESS = 1,
145 CMD_STATUS_UNKNOWN_CMD = 2,
146 CMD_STATUS_UNKNOWN_IE = 3,
147 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
148 CMD_STATUS_RX_BUSY = 13,
149 CMD_STATUS_INVALID_PARAM = 14,
150 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
151 CMD_STATUS_OUT_OF_MEMORY = 16,
152 CMD_STATUS_STA_TABLE_FULL = 17,
153 CMD_STATUS_RADIO_ERROR = 18,
154 CMD_STATUS_WRONG_NESTING = 19,
155 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
156 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
157 MAX_COMMAND_STATUS = 0xff
164 * The host issues this command to read the WiLink device memory/registers.
166 * Note: The Base Band address has special handling (16 bits registers and
167 * addresses). For more information, see the hardware specification.
172 * The host issues this command to write the WiLink device memory/registers.
174 * The Base Band address has special handling (16 bits registers and
175 * addresses). For more information, see the hardware specification.
177 #define MAX_READ_SIZE 256
179 struct cmd_read_write_memory {
180 struct wl1271_cmd_header header;
182 /* The address of the memory to read from or write to.*/
185 /* The amount of data in bytes to read from or write to the WiLink
189 /* The actual value read from or written to the Wilink. The source
190 of this field is the Host in WRITE command or the Wilink in READ
192 u8 value[MAX_READ_SIZE];
193 } __attribute__ ((packed));
195 #define CMDMBOX_HEADER_LEN 4
196 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
200 BSS_TYPE_STA_BSS = 2,
205 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
206 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
207 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
209 struct wl1271_cmd_join {
210 struct wl1271_cmd_header header;
214 __le16 beacon_interval; /* in TBTTs */
215 __le32 rx_config_options;
216 __le32 rx_filter_options;
219 * The target uses this field to determine the rate at
220 * which to transmit control frame responses (such as
221 * ACK or CTS frames).
223 __le32 basic_rate_set;
226 * bits 0-2: This bitwise field specifies the type
227 * of BSS to start or join (BSS_TYPE_*).
228 * bit 4: Band - The radio band in which to join
232 * bits 3, 5-7: Reserved
237 u8 ssid[IW_ESSID_MAX_SIZE];
238 u8 ctrl; /* JOIN_CMD_CTRL_* */
240 } __attribute__ ((packed));
242 struct cmd_enabledisable_path {
243 struct wl1271_cmd_header header;
247 } __attribute__ ((packed));
249 struct wl1271_cmd_template_set {
250 struct wl1271_cmd_header header;
254 u8 index; /* relevant only for KLV_TEMPLATE type */
255 __le32 enabled_rates;
256 u8 short_retry_limit;
260 u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
261 } __attribute__ ((packed));
264 #define PARTIAL_VBM_MAX 251
272 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
273 } __attribute__ ((packed));
275 enum wl1271_cmd_ps_mode {
277 STATION_POWER_SAVE_MODE
280 struct wl1271_cmd_ps_params {
281 struct wl1271_cmd_header header;
283 u8 ps_mode; /* STATION_* */
284 u8 send_null_data; /* Do we have to send NULL data packet ? */
285 u8 retries; /* Number of retires for the initial NULL data packet */
288 * TUs during which the target stays awake after switching
289 * to power save mode.
292 __le32 null_data_rate;
293 } __attribute__ ((packed));
295 /* HW encryption keys */
296 #define NUM_ACCESS_CATEGORIES_COPY 4
297 #define MAX_KEY_SIZE 32
299 enum wl1271_cmd_key_action {
300 KEY_ADD_OR_REPLACE = 1,
303 MAX_KEY_ACTION = 0xffff,
306 enum wl1271_cmd_key_type {
314 /* FIXME: Add description for key-types */
316 struct wl1271_cmd_set_keys {
317 struct wl1271_cmd_header header;
319 /* Ignored for default WEP key */
327 /* key size in bytes */
335 * TKIP, AES: frame's key id field.
336 * For WEP default key: key id;
340 u8 key[MAX_KEY_SIZE];
341 __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
342 __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
343 } __attribute__ ((packed));
346 #define WL1271_SCAN_MAX_CHANNELS 24
347 #define WL1271_SCAN_DEFAULT_TAG 1
348 #define WL1271_SCAN_CURRENT_TX_PWR 0
349 #define WL1271_SCAN_OPT_ACTIVE 0
350 #define WL1271_SCAN_OPT_PASSIVE 1
351 #define WL1271_SCAN_OPT_PRIORITY_HIGH 4
352 #define WL1271_SCAN_CHAN_MIN_DURATION 30000 /* TU */
353 #define WL1271_SCAN_CHAN_MAX_DURATION 60000 /* TU */
354 #define WL1271_SCAN_BAND_2_4_GHZ 0
355 #define WL1271_SCAN_BAND_5_GHZ 1
356 #define WL1271_SCAN_BAND_DUAL 2
358 struct basic_scan_params {
359 __le32 rx_config_options;
360 __le32 rx_filter_options;
361 /* Scan option flags (WL1271_SCAN_OPT_*) */
363 /* Number of scan channels in the list (maximum 30) */
365 /* This field indicates the number of probe requests to send
366 per channel for an active scan */
367 u8 num_probe_requests;
368 /* Rate bit field for sending the probes */
372 /* in order to align */
374 u8 ssid[IW_ESSID_MAX_SIZE];
380 } __attribute__ ((packed));
382 struct basic_scan_channel_params {
383 /* Duration in TU to wait for frames on a channel for active scan */
388 u8 early_termination;
391 /* FW internal use only! */
393 u8 activity_detected;
395 } __attribute__ ((packed));
397 struct wl1271_cmd_scan {
398 struct wl1271_cmd_header header;
400 struct basic_scan_params params;
401 struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
402 } __attribute__ ((packed));
404 struct wl1271_cmd_trigger_scan_to {
405 struct wl1271_cmd_header header;
408 } __attribute__ ((packed));
410 struct wl1271_cmd_test_header {
413 } __attribute__ ((packed));
415 enum wl1271_channel_tune_bands {
416 WL1271_CHANNEL_TUNE_BAND_2_4,
417 WL1271_CHANNEL_TUNE_BAND_5,
418 WL1271_CHANNEL_TUNE_BAND_4_9
421 #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
423 #define TEST_CMD_P2G_CAL 0x02
424 #define TEST_CMD_CHANNEL_TUNE 0x0d
425 #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
426 #define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
427 #define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
429 struct wl1271_general_parms_cmd {
430 struct wl1271_cmd_header header;
432 struct wl1271_cmd_test_header test;
434 u8 params[WL1271_NVS_GENERAL_PARAMS_SIZE];
436 } __attribute__ ((packed));
438 #define WL1271_STAT_RADIO_PARAMS_5_SIZE 29
439 #define WL1271_DYN_RADIO_PARAMS_5_SIZE 104
441 struct wl1271_radio_parms_cmd {
442 struct wl1271_cmd_header header;
444 struct wl1271_cmd_test_header test;
446 u8 stat_radio_params[WL1271_NVS_STAT_RADIO_PARAMS_SIZE];
447 u8 stat_radio_params_5[WL1271_STAT_RADIO_PARAMS_5_SIZE];
449 u8 dyn_radio_params[WL1271_NVS_DYN_RADIO_PARAMS_SIZE];
451 u8 dyn_radio_params_5[WL1271_DYN_RADIO_PARAMS_5_SIZE];
452 } __attribute__ ((packed));
454 struct wl1271_cmd_cal_channel_tune {
455 struct wl1271_cmd_header header;
457 struct wl1271_cmd_test_header test;
463 } __attribute__ ((packed));
465 struct wl1271_cmd_cal_update_ref_point {
466 struct wl1271_cmd_header header;
468 struct wl1271_cmd_test_header test;
474 } __attribute__ ((packed));
476 #define MAX_TLV_LENGTH 400
477 #define MAX_NVS_VERSION_LENGTH 12
479 #define WL1271_CAL_P2G_BAND_B_G BIT(0)
481 struct wl1271_cmd_cal_p2g {
482 struct wl1271_cmd_header header;
484 struct wl1271_cmd_test_header test;
487 u8 buf[MAX_TLV_LENGTH];
492 u8 nvs_version[MAX_NVS_VERSION_LENGTH];
496 } __attribute__ ((packed));
500 * There are three types of disconnections:
502 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
503 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
505 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
508 enum wl1271_disconnect_type {
509 DISCONNECT_IMMEDIATE,
514 struct wl1271_cmd_disconnect {
515 __le32 rx_config_options;
516 __le32 rx_filter_options;
522 } __attribute__ ((packed));
524 #endif /* __WL1271_CMD_H__ */