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 type
, void *buf
, size_t buf_len
);
33 int wl1271_cmd_join(struct wl1271
*wl
);
34 int wl1271_cmd_test(struct wl1271
*wl
, void *buf
, size_t buf_len
, u8 answer
);
35 int wl1271_cmd_interrogate(struct wl1271
*wl
, u16 id
, void *buf
, size_t len
);
36 int wl1271_cmd_configure(struct wl1271
*wl
, u16 id
, void *buf
, size_t len
);
37 int wl1271_cmd_data_path(struct wl1271
*wl
, u8 channel
, bool enable
);
38 int wl1271_cmd_ps_mode(struct wl1271
*wl
, u8 ps_mode
);
39 int wl1271_cmd_read_memory(struct wl1271
*wl
, u32 addr
, void *answer
,
41 int wl1271_cmd_scan(struct wl1271
*wl
, u8
*ssid
, size_t len
,
42 u8 active_scan
, u8 high_prio
, u8 band
,
44 int wl1271_cmd_template_set(struct wl1271
*wl
, u16 template_id
,
45 void *buf
, size_t buf_len
);
46 int wl1271_cmd_build_null_data(struct wl1271
*wl
);
47 int wl1271_cmd_build_ps_poll(struct wl1271
*wl
, u16 aid
);
48 int wl1271_cmd_build_probe_req(struct wl1271
*wl
, u8
*ssid
, size_t ssid_len
,
50 int wl1271_cmd_set_default_wep_key(struct wl1271
*wl
, u8 id
);
51 int wl1271_cmd_set_key(struct wl1271
*wl
, u16 action
, u8 id
, u8 key_type
,
52 u8 key_size
, const u8
*key
, const u8
*addr
,
53 u32 tx_seq_32
, u16 tx_seq_16
);
54 int wl1271_cmd_disconnect(struct wl1271
*wl
);
56 enum wl1271_commands
{
57 CMD_INTERROGATE
= 1, /*use this to read information elements*/
58 CMD_CONFIGURE
= 2, /*use this to write information elements*/
68 CMD_WRITE_MEMORY
= 14,
69 CMD_SET_TEMPLATE
= 19,
73 CMD_SET_BCN_MODE
= 33,
75 CMD_STOP_MEASUREMENT
= 35,
78 CMD_CHANNEL_SWITCH
= 38,
79 CMD_STOP_CHANNEL_SWICTH
= 39,
80 CMD_AP_DISCOVERY
= 40,
81 CMD_STOP_AP_DISCOVERY
= 41,
83 CMD_STOP_SPS_SCAN
= 43,
84 CMD_HEALTH_CHECK
= 45,
86 CMD_TRIGGER_SCAN_TO
= 47,
87 CMD_CONNECTION_SCAN_CFG
= 48,
88 CMD_CONNECTION_SCAN_SSID_CFG
= 49,
89 CMD_START_PERIODIC_SCAN
= 50,
90 CMD_STOP_PERIODIC_SCAN
= 51,
91 CMD_SET_STA_STATE
= 52,
94 MAX_COMMAND_ID
= 0xFFFF,
97 #define MAX_CMD_PARAMS 572
100 CMD_TEMPL_NULL_DATA
= 0,
102 CMD_TEMPL_CFG_PROBE_REQ_2_4
,
103 CMD_TEMPL_CFG_PROBE_REQ_5
,
104 CMD_TEMPL_PROBE_RESPONSE
,
105 CMD_TEMPL_QOS_NULL_DATA
,
108 CMD_TEMPL_DISCONNECT
,
109 CMD_TEMPL_PROBE_REQ_2_4
, /* for firmware internal use only */
110 CMD_TEMPL_PROBE_REQ_5
, /* for firmware internal use only */
111 CMD_TEMPL_BAR
, /* for firmware internal use only */
113 * For CTS-to-self (FastCTS) mechanism
114 * for BT/WLAN coexistence (SoftGemini). */
119 #define WL1271_COMMAND_TIMEOUT 2000
120 #define WL1271_CMD_TEMPL_MAX_SIZE 252
122 struct wl1271_cmd_header
{
127 } __attribute__ ((packed
));
129 #define WL1271_CMD_MAX_PARAMS 572
131 struct wl1271_command
{
132 struct wl1271_cmd_header header
;
133 u8 parameters
[WL1271_CMD_MAX_PARAMS
];
134 } __attribute__ ((packed
));
137 CMD_MAILBOX_IDLE
= 0,
138 CMD_STATUS_SUCCESS
= 1,
139 CMD_STATUS_UNKNOWN_CMD
= 2,
140 CMD_STATUS_UNKNOWN_IE
= 3,
141 CMD_STATUS_REJECT_MEAS_SG_ACTIVE
= 11,
142 CMD_STATUS_RX_BUSY
= 13,
143 CMD_STATUS_INVALID_PARAM
= 14,
144 CMD_STATUS_TEMPLATE_TOO_LARGE
= 15,
145 CMD_STATUS_OUT_OF_MEMORY
= 16,
146 CMD_STATUS_STA_TABLE_FULL
= 17,
147 CMD_STATUS_RADIO_ERROR
= 18,
148 CMD_STATUS_WRONG_NESTING
= 19,
149 CMD_STATUS_TIMEOUT
= 21, /* Driver internal use.*/
150 CMD_STATUS_FW_RESET
= 22, /* Driver internal use.*/
151 MAX_COMMAND_STATUS
= 0xff
158 * The host issues this command to read the WiLink device memory/registers.
160 * Note: The Base Band address has special handling (16 bits registers and
161 * addresses). For more information, see the hardware specification.
166 * The host issues this command to write the WiLink device memory/registers.
168 * The Base Band address has special handling (16 bits registers and
169 * addresses). For more information, see the hardware specification.
171 #define MAX_READ_SIZE 256
173 struct cmd_read_write_memory
{
174 struct wl1271_cmd_header header
;
176 /* The address of the memory to read from or write to.*/
179 /* The amount of data in bytes to read from or write to the WiLink
183 /* The actual value read from or written to the Wilink. The source
184 of this field is the Host in WRITE command or the Wilink in READ
186 u8 value
[MAX_READ_SIZE
];
189 #define CMDMBOX_HEADER_LEN 4
190 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
194 BSS_TYPE_STA_BSS
= 2,
199 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
200 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
202 struct wl1271_cmd_join
{
203 struct wl1271_cmd_header header
;
207 u16 beacon_interval
; /* in TBTTs */
208 u32 rx_config_options
;
209 u32 rx_filter_options
;
212 * The target uses this field to determine the rate at
213 * which to transmit control frame responses (such as
214 * ACK or CTS frames).
219 * bits 0-2: This bitwise field specifies the type
220 * of BSS to start or join (BSS_TYPE_*).
221 * bit 4: Band - The radio band in which to join
225 * bits 3, 5-7: Reserved
230 u8 ssid
[IW_ESSID_MAX_SIZE
];
231 u8 ctrl
; /* JOIN_CMD_CTRL_* */
233 } __attribute__ ((packed
));
235 struct cmd_enabledisable_path
{
236 struct wl1271_cmd_header header
;
240 } __attribute__ ((packed
));
242 struct wl1271_cmd_template_set
{
243 struct wl1271_cmd_header header
;
247 u8 index
; /* relevant only for KLV_TEMPLATE type */
249 u8 short_retry_limit
;
253 u8 template_data
[WL1271_CMD_TEMPL_MAX_SIZE
];
254 } __attribute__ ((packed
));
257 #define PARTIAL_VBM_MAX 251
265 u8 pvb_field
[PARTIAL_VBM_MAX
]; /* Partial Virtual Bitmap */
266 } __attribute__ ((packed
));
268 enum wl1271_cmd_ps_mode
{
270 STATION_POWER_SAVE_MODE
273 struct wl1271_cmd_ps_params
{
274 struct wl1271_cmd_header header
;
276 u8 ps_mode
; /* STATION_* */
277 u8 send_null_data
; /* Do we have to send NULL data packet ? */
278 u8 retries
; /* Number of retires for the initial NULL data packet */
281 * TUs during which the target stays awake after switching
282 * to power save mode.
286 } __attribute__ ((packed
));
288 /* HW encryption keys */
289 #define NUM_ACCESS_CATEGORIES_COPY 4
290 #define MAX_KEY_SIZE 32
292 enum wl1271_cmd_key_action
{
293 KEY_ADD_OR_REPLACE
= 1,
296 MAX_KEY_ACTION
= 0xffff,
299 enum wl1271_cmd_key_type
{
307 /* FIXME: Add description for key-types */
309 struct wl1271_cmd_set_keys
{
310 struct wl1271_cmd_header header
;
312 /* Ignored for default WEP key */
320 /* key size in bytes */
328 * TKIP, AES: frame's key id field.
329 * For WEP default key: key id;
333 u8 key
[MAX_KEY_SIZE
];
334 u16 ac_seq_num16
[NUM_ACCESS_CATEGORIES_COPY
];
335 u32 ac_seq_num32
[NUM_ACCESS_CATEGORIES_COPY
];
336 } __attribute__ ((packed
));
339 #define WL1271_SCAN_MAX_CHANNELS 24
340 #define WL1271_SCAN_DEFAULT_TAG 1
341 #define WL1271_SCAN_CURRENT_TX_PWR 0
342 #define WL1271_SCAN_OPT_ACTIVE 0
343 #define WL1271_SCAN_OPT_PASSIVE 1
344 #define WL1271_SCAN_OPT_PRIORITY_HIGH 4
345 #define WL1271_SCAN_CHAN_MIN_DURATION 30000 /* TU */
346 #define WL1271_SCAN_CHAN_MAX_DURATION 60000 /* TU */
347 #define WL1271_SCAN_BAND_2_4_GHZ 0
348 #define WL1271_SCAN_BAND_5_GHZ 1
349 #define WL1271_SCAN_BAND_DUAL 2
351 struct basic_scan_params
{
352 u32 rx_config_options
;
353 u32 rx_filter_options
;
354 /* Scan option flags (WL1271_SCAN_OPT_*) */
356 /* Number of scan channels in the list (maximum 30) */
358 /* This field indicates the number of probe requests to send
359 per channel for an active scan */
360 u8 num_probe_requests
;
361 /* Rate bit field for sending the probes */
365 /* in order to align */
367 u8 ssid
[IW_ESSID_MAX_SIZE
];
373 } __attribute__ ((packed
));
375 struct basic_scan_channel_params
{
376 /* Duration in TU to wait for frames on a channel for active scan */
381 u8 early_termination
;
384 /* FW internal use only! */
386 u8 activity_detected
;
388 } __attribute__ ((packed
));
390 struct wl1271_cmd_scan
{
391 struct wl1271_cmd_header header
;
393 struct basic_scan_params params
;
394 struct basic_scan_channel_params channels
[WL1271_SCAN_MAX_CHANNELS
];
395 } __attribute__ ((packed
));
397 struct wl1271_cmd_trigger_scan_to
{
398 struct wl1271_cmd_header header
;
403 struct wl1271_cmd_test_header
{
408 enum wl1271_channel_tune_bands
{
409 WL1271_CHANNEL_TUNE_BAND_2_4
,
410 WL1271_CHANNEL_TUNE_BAND_5
,
411 WL1271_CHANNEL_TUNE_BAND_4_9
414 #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
416 #define TEST_CMD_P2G_CAL 0x02
417 #define TEST_CMD_CHANNEL_TUNE 0x0d
418 #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
420 struct wl1271_cmd_cal_channel_tune
{
421 struct wl1271_cmd_header header
;
423 struct wl1271_cmd_test_header test
;
429 } __attribute__ ((packed
));
431 struct wl1271_cmd_cal_update_ref_point
{
432 struct wl1271_cmd_header header
;
434 struct wl1271_cmd_test_header test
;
440 } __attribute__ ((packed
));
442 #define MAX_TLV_LENGTH 400
443 #define MAX_NVS_VERSION_LENGTH 12
445 #define WL1271_CAL_P2G_BAND_B_G BIT(0)
447 struct wl1271_cmd_cal_p2g
{
448 struct wl1271_cmd_header header
;
450 struct wl1271_cmd_test_header test
;
453 u8 buf
[MAX_TLV_LENGTH
];
458 u8 nvs_version
[MAX_NVS_VERSION_LENGTH
];
462 } __attribute__ ((packed
));
466 * There are three types of disconnections:
468 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
469 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
471 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
474 enum wl1271_disconnect_type
{
475 DISCONNECT_IMMEDIATE
,
480 struct wl1271_cmd_disconnect
{
481 u32 rx_config_options
;
482 u32 rx_filter_options
;
488 } __attribute__ ((packed
));
490 #endif /* __WL1271_CMD_H__ */