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);
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, u8 *ssid, size_t len,
45 u8 active_scan, u8 high_prio, u8 band,
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, u8 *ssid, size_t ssid_len,
53 int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
54 int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
55 u8 key_size, const u8 *key, const u8 *addr,
56 u32 tx_seq_32, u16 tx_seq_16);
57 int wl1271_cmd_disconnect(struct wl1271 *wl);
59 enum wl1271_commands {
60 CMD_INTERROGATE = 1, /*use this to read information elements*/
61 CMD_CONFIGURE = 2, /*use this to write information elements*/
71 CMD_WRITE_MEMORY = 14,
72 CMD_SET_TEMPLATE = 19,
76 CMD_SET_BCN_MODE = 33,
78 CMD_STOP_MEASUREMENT = 35,
81 CMD_CHANNEL_SWITCH = 38,
82 CMD_STOP_CHANNEL_SWICTH = 39,
83 CMD_AP_DISCOVERY = 40,
84 CMD_STOP_AP_DISCOVERY = 41,
86 CMD_STOP_SPS_SCAN = 43,
87 CMD_HEALTH_CHECK = 45,
89 CMD_TRIGGER_SCAN_TO = 47,
90 CMD_CONNECTION_SCAN_CFG = 48,
91 CMD_CONNECTION_SCAN_SSID_CFG = 49,
92 CMD_START_PERIODIC_SCAN = 50,
93 CMD_STOP_PERIODIC_SCAN = 51,
94 CMD_SET_STA_STATE = 52,
97 MAX_COMMAND_ID = 0xFFFF,
100 #define MAX_CMD_PARAMS 572
103 CMD_TEMPL_NULL_DATA = 0,
105 CMD_TEMPL_CFG_PROBE_REQ_2_4,
106 CMD_TEMPL_CFG_PROBE_REQ_5,
107 CMD_TEMPL_PROBE_RESPONSE,
108 CMD_TEMPL_QOS_NULL_DATA,
111 CMD_TEMPL_DISCONNECT,
112 CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
113 CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
114 CMD_TEMPL_BAR, /* for firmware internal use only */
116 * For CTS-to-self (FastCTS) mechanism
117 * for BT/WLAN coexistence (SoftGemini). */
122 #define WL1271_COMMAND_TIMEOUT 2000
123 #define WL1271_CMD_TEMPL_MAX_SIZE 252
125 struct wl1271_cmd_header {
130 } __attribute__ ((packed));
132 #define WL1271_CMD_MAX_PARAMS 572
134 struct wl1271_command {
135 struct wl1271_cmd_header header;
136 u8 parameters[WL1271_CMD_MAX_PARAMS];
137 } __attribute__ ((packed));
140 CMD_MAILBOX_IDLE = 0,
141 CMD_STATUS_SUCCESS = 1,
142 CMD_STATUS_UNKNOWN_CMD = 2,
143 CMD_STATUS_UNKNOWN_IE = 3,
144 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
145 CMD_STATUS_RX_BUSY = 13,
146 CMD_STATUS_INVALID_PARAM = 14,
147 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
148 CMD_STATUS_OUT_OF_MEMORY = 16,
149 CMD_STATUS_STA_TABLE_FULL = 17,
150 CMD_STATUS_RADIO_ERROR = 18,
151 CMD_STATUS_WRONG_NESTING = 19,
152 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
153 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
154 MAX_COMMAND_STATUS = 0xff
161 * The host issues this command to read the WiLink device memory/registers.
163 * Note: The Base Band address has special handling (16 bits registers and
164 * addresses). For more information, see the hardware specification.
169 * The host issues this command to write the WiLink device memory/registers.
171 * The Base Band address has special handling (16 bits registers and
172 * addresses). For more information, see the hardware specification.
174 #define MAX_READ_SIZE 256
176 struct cmd_read_write_memory {
177 struct wl1271_cmd_header header;
179 /* The address of the memory to read from or write to.*/
182 /* The amount of data in bytes to read from or write to the WiLink
186 /* The actual value read from or written to the Wilink. The source
187 of this field is the Host in WRITE command or the Wilink in READ
189 u8 value[MAX_READ_SIZE];
190 } __attribute__ ((packed));
192 #define CMDMBOX_HEADER_LEN 4
193 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
197 BSS_TYPE_STA_BSS = 2,
202 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
203 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
204 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
206 struct wl1271_cmd_join {
207 struct wl1271_cmd_header header;
211 __le16 beacon_interval; /* in TBTTs */
212 __le32 rx_config_options;
213 __le32 rx_filter_options;
216 * The target uses this field to determine the rate at
217 * which to transmit control frame responses (such as
218 * ACK or CTS frames).
220 __le32 basic_rate_set;
223 * bits 0-2: This bitwise field specifies the type
224 * of BSS to start or join (BSS_TYPE_*).
225 * bit 4: Band - The radio band in which to join
229 * bits 3, 5-7: Reserved
234 u8 ssid[IW_ESSID_MAX_SIZE];
235 u8 ctrl; /* JOIN_CMD_CTRL_* */
237 } __attribute__ ((packed));
239 struct cmd_enabledisable_path {
240 struct wl1271_cmd_header header;
244 } __attribute__ ((packed));
246 struct wl1271_cmd_template_set {
247 struct wl1271_cmd_header header;
251 u8 index; /* relevant only for KLV_TEMPLATE type */
252 __le32 enabled_rates;
253 u8 short_retry_limit;
257 u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
258 } __attribute__ ((packed));
261 #define PARTIAL_VBM_MAX 251
269 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
270 } __attribute__ ((packed));
272 enum wl1271_cmd_ps_mode {
274 STATION_POWER_SAVE_MODE
277 struct wl1271_cmd_ps_params {
278 struct wl1271_cmd_header header;
280 u8 ps_mode; /* STATION_* */
281 u8 send_null_data; /* Do we have to send NULL data packet ? */
282 u8 retries; /* Number of retires for the initial NULL data packet */
285 * TUs during which the target stays awake after switching
286 * to power save mode.
289 __le32 null_data_rate;
290 } __attribute__ ((packed));
292 /* HW encryption keys */
293 #define NUM_ACCESS_CATEGORIES_COPY 4
294 #define MAX_KEY_SIZE 32
296 enum wl1271_cmd_key_action {
297 KEY_ADD_OR_REPLACE = 1,
300 MAX_KEY_ACTION = 0xffff,
303 enum wl1271_cmd_key_type {
311 /* FIXME: Add description for key-types */
313 struct wl1271_cmd_set_keys {
314 struct wl1271_cmd_header header;
316 /* Ignored for default WEP key */
324 /* key size in bytes */
332 * TKIP, AES: frame's key id field.
333 * For WEP default key: key id;
337 u8 key[MAX_KEY_SIZE];
338 __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
339 __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
340 } __attribute__ ((packed));
343 #define WL1271_SCAN_MAX_CHANNELS 24
344 #define WL1271_SCAN_DEFAULT_TAG 1
345 #define WL1271_SCAN_CURRENT_TX_PWR 0
346 #define WL1271_SCAN_OPT_ACTIVE 0
347 #define WL1271_SCAN_OPT_PASSIVE 1
348 #define WL1271_SCAN_OPT_PRIORITY_HIGH 4
349 #define WL1271_SCAN_CHAN_MIN_DURATION 30000 /* TU */
350 #define WL1271_SCAN_CHAN_MAX_DURATION 60000 /* TU */
351 #define WL1271_SCAN_BAND_2_4_GHZ 0
352 #define WL1271_SCAN_BAND_5_GHZ 1
353 #define WL1271_SCAN_BAND_DUAL 2
355 struct basic_scan_params {
356 __le32 rx_config_options;
357 __le32 rx_filter_options;
358 /* Scan option flags (WL1271_SCAN_OPT_*) */
360 /* Number of scan channels in the list (maximum 30) */
362 /* This field indicates the number of probe requests to send
363 per channel for an active scan */
364 u8 num_probe_requests;
365 /* Rate bit field for sending the probes */
369 /* in order to align */
371 u8 ssid[IW_ESSID_MAX_SIZE];
377 } __attribute__ ((packed));
379 struct basic_scan_channel_params {
380 /* Duration in TU to wait for frames on a channel for active scan */
385 u8 early_termination;
388 /* FW internal use only! */
390 u8 activity_detected;
392 } __attribute__ ((packed));
394 struct wl1271_cmd_scan {
395 struct wl1271_cmd_header header;
397 struct basic_scan_params params;
398 struct basic_scan_channel_params channels[WL1271_SCAN_MAX_CHANNELS];
399 } __attribute__ ((packed));
401 struct wl1271_cmd_trigger_scan_to {
402 struct wl1271_cmd_header header;
405 } __attribute__ ((packed));
407 struct wl1271_cmd_test_header {
410 } __attribute__ ((packed));
412 enum wl1271_channel_tune_bands {
413 WL1271_CHANNEL_TUNE_BAND_2_4,
414 WL1271_CHANNEL_TUNE_BAND_5,
415 WL1271_CHANNEL_TUNE_BAND_4_9
418 #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
420 #define TEST_CMD_P2G_CAL 0x02
421 #define TEST_CMD_CHANNEL_TUNE 0x0d
422 #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
423 #define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
424 #define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
426 struct wl1271_general_parms_cmd {
427 struct wl1271_cmd_header header;
429 struct wl1271_cmd_test_header test;
431 u8 params[WL1271_NVS_GENERAL_PARAMS_SIZE];
433 } __attribute__ ((packed));
435 #define WL1271_STAT_RADIO_PARAMS_5_SIZE 29
436 #define WL1271_DYN_RADIO_PARAMS_5_SIZE 104
438 struct wl1271_radio_parms_cmd {
439 struct wl1271_cmd_header header;
441 struct wl1271_cmd_test_header test;
443 u8 stat_radio_params[WL1271_NVS_STAT_RADIO_PARAMS_SIZE];
444 u8 stat_radio_params_5[WL1271_STAT_RADIO_PARAMS_5_SIZE];
446 u8 dyn_radio_params[WL1271_NVS_DYN_RADIO_PARAMS_SIZE];
448 u8 dyn_radio_params_5[WL1271_DYN_RADIO_PARAMS_5_SIZE];
449 } __attribute__ ((packed));
451 struct wl1271_cmd_cal_channel_tune {
452 struct wl1271_cmd_header header;
454 struct wl1271_cmd_test_header test;
460 } __attribute__ ((packed));
462 struct wl1271_cmd_cal_update_ref_point {
463 struct wl1271_cmd_header header;
465 struct wl1271_cmd_test_header test;
471 } __attribute__ ((packed));
473 #define MAX_TLV_LENGTH 400
474 #define MAX_NVS_VERSION_LENGTH 12
476 #define WL1271_CAL_P2G_BAND_B_G BIT(0)
478 struct wl1271_cmd_cal_p2g {
479 struct wl1271_cmd_header header;
481 struct wl1271_cmd_test_header test;
484 u8 buf[MAX_TLV_LENGTH];
489 u8 nvs_version[MAX_NVS_VERSION_LENGTH];
493 } __attribute__ ((packed));
497 * There are three types of disconnections:
499 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
500 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
502 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
505 enum wl1271_disconnect_type {
506 DISCONNECT_IMMEDIATE,
511 struct wl1271_cmd_disconnect {
512 __le32 rx_config_options;
513 __le32 rx_filter_options;
519 } __attribute__ ((packed));
521 #endif /* __WL1271_CMD_H__ */