blob: ff8e35e87d987d04b84d31deea5c80c8551919ab [file] [log] [blame]
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001/*
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
Juuso Oikarinenfa867e72009-11-02 20:22:13 +020032int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
33 size_t res_len);
Luciano Coelho98b5dd52009-11-23 23:22:17 +020034int wl1271_cmd_general_parms(struct wl1271 *wl);
35int wl1271_cmd_radio_parms(struct wl1271 *wl);
Juuso Oikarinen15305492010-02-22 08:38:32 +020036int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030037int 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);
Luciano Coelho94210892009-12-11 15:40:55 +020040int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
Juuso Oikarinen65cddbf2010-08-24 06:28:03 +030041int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, u32 rates, bool send);
42int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
43 size_t len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030044int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
Juuso Oikarinen606c1482010-04-01 11:38:21 +030045 void *buf, size_t buf_len, int index, u32 rates);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030046int wl1271_cmd_build_null_data(struct wl1271 *wl);
47int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
Kalle Valo818e3062010-03-18 12:26:35 +020048int wl1271_cmd_build_probe_req(struct wl1271 *wl,
49 const u8 *ssid, size_t ssid_len,
50 const u8 *ie, size_t ie_len, u8 band);
Kalle Valo023e0822010-03-18 12:26:36 +020051int wl1271_build_qos_null_data(struct wl1271 *wl);
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020052int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030053int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
54int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
Juuso Oikarinenac4e4ce2009-10-08 21:56:19 +030055 u8 key_size, const u8 *key, const u8 *addr,
56 u32 tx_seq_32, u16 tx_seq_16);
Luciano Coelho25a7dc62009-10-12 15:08:42 +030057int wl1271_cmd_disconnect(struct wl1271 *wl);
Juuso Oikarinenbe86cbe2010-05-27 12:53:01 +030058int wl1271_cmd_set_sta_state(struct wl1271 *wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030059
60enum wl1271_commands {
61 CMD_INTERROGATE = 1, /*use this to read information elements*/
62 CMD_CONFIGURE = 2, /*use this to write information elements*/
63 CMD_ENABLE_RX = 3,
64 CMD_ENABLE_TX = 4,
65 CMD_DISABLE_RX = 5,
66 CMD_DISABLE_TX = 6,
67 CMD_SCAN = 8,
68 CMD_STOP_SCAN = 9,
69 CMD_START_JOIN = 11,
70 CMD_SET_KEYS = 12,
71 CMD_READ_MEMORY = 13,
72 CMD_WRITE_MEMORY = 14,
73 CMD_SET_TEMPLATE = 19,
74 CMD_TEST = 23,
75 CMD_NOISE_HIST = 28,
76 CMD_LNA_CONTROL = 32,
77 CMD_SET_BCN_MODE = 33,
78 CMD_MEASUREMENT = 34,
79 CMD_STOP_MEASUREMENT = 35,
80 CMD_DISCONNECT = 36,
81 CMD_SET_PS_MODE = 37,
82 CMD_CHANNEL_SWITCH = 38,
83 CMD_STOP_CHANNEL_SWICTH = 39,
84 CMD_AP_DISCOVERY = 40,
85 CMD_STOP_AP_DISCOVERY = 41,
86 CMD_SPS_SCAN = 42,
87 CMD_STOP_SPS_SCAN = 43,
88 CMD_HEALTH_CHECK = 45,
89 CMD_DEBUG = 46,
90 CMD_TRIGGER_SCAN_TO = 47,
91 CMD_CONNECTION_SCAN_CFG = 48,
92 CMD_CONNECTION_SCAN_SSID_CFG = 49,
93 CMD_START_PERIODIC_SCAN = 50,
94 CMD_STOP_PERIODIC_SCAN = 51,
95 CMD_SET_STA_STATE = 52,
96
97 NUM_COMMANDS,
98 MAX_COMMAND_ID = 0xFFFF,
99};
100
101#define MAX_CMD_PARAMS 572
102
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +0200103enum {
104 CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
105 CMD_TEMPL_KLV_IDX_MAX = 4
106};
107
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300108enum cmd_templ {
109 CMD_TEMPL_NULL_DATA = 0,
110 CMD_TEMPL_BEACON,
111 CMD_TEMPL_CFG_PROBE_REQ_2_4,
112 CMD_TEMPL_CFG_PROBE_REQ_5,
113 CMD_TEMPL_PROBE_RESPONSE,
114 CMD_TEMPL_QOS_NULL_DATA,
115 CMD_TEMPL_PS_POLL,
116 CMD_TEMPL_KLV,
117 CMD_TEMPL_DISCONNECT,
118 CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
119 CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
120 CMD_TEMPL_BAR, /* for firmware internal use only */
121 CMD_TEMPL_CTS, /*
122 * For CTS-to-self (FastCTS) mechanism
123 * for BT/WLAN coexistence (SoftGemini). */
124 CMD_TEMPL_MAX = 0xff
125};
126
127/* unit ms */
128#define WL1271_COMMAND_TIMEOUT 2000
129#define WL1271_CMD_TEMPL_MAX_SIZE 252
Teemu Paasikivi0cbb1032010-05-07 11:39:01 +0300130#define WL1271_EVENT_TIMEOUT 750
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300131
132struct wl1271_cmd_header {
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300133 __le16 id;
134 __le16 status;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300135 /* payload */
136 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000137} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300138
139#define WL1271_CMD_MAX_PARAMS 572
140
141struct wl1271_command {
142 struct wl1271_cmd_header header;
143 u8 parameters[WL1271_CMD_MAX_PARAMS];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000144} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300145
146enum {
147 CMD_MAILBOX_IDLE = 0,
148 CMD_STATUS_SUCCESS = 1,
149 CMD_STATUS_UNKNOWN_CMD = 2,
150 CMD_STATUS_UNKNOWN_IE = 3,
151 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
152 CMD_STATUS_RX_BUSY = 13,
153 CMD_STATUS_INVALID_PARAM = 14,
154 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
155 CMD_STATUS_OUT_OF_MEMORY = 16,
156 CMD_STATUS_STA_TABLE_FULL = 17,
157 CMD_STATUS_RADIO_ERROR = 18,
158 CMD_STATUS_WRONG_NESTING = 19,
159 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
160 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
161 MAX_COMMAND_STATUS = 0xff
162};
163
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300164#define CMDMBOX_HEADER_LEN 4
165#define CMDMBOX_INFO_ELEM_HEADER_LEN 4
166
167enum {
168 BSS_TYPE_IBSS = 0,
169 BSS_TYPE_STA_BSS = 2,
170 BSS_TYPE_AP_BSS = 3,
171 MAX_BSS_TYPE = 0xFF
172};
173
174#define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
175#define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
Teemu Paasikivia4102642009-10-13 12:47:51 +0300176#define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300177
178struct wl1271_cmd_join {
179 struct wl1271_cmd_header header;
180
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300181 __le32 bssid_lsb;
182 __le16 bssid_msb;
183 __le16 beacon_interval; /* in TBTTs */
184 __le32 rx_config_options;
185 __le32 rx_filter_options;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300186
187 /*
188 * The target uses this field to determine the rate at
189 * which to transmit control frame responses (such as
190 * ACK or CTS frames).
191 */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300192 __le32 basic_rate_set;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300193 u8 dtim_interval;
194 /*
195 * bits 0-2: This bitwise field specifies the type
196 * of BSS to start or join (BSS_TYPE_*).
197 * bit 4: Band - The radio band in which to join
198 * or start.
199 * 0 - 2.4GHz band
200 * 1 - 5GHz band
201 * bits 3, 5-7: Reserved
202 */
203 u8 bss_type;
204 u8 channel;
205 u8 ssid_len;
206 u8 ssid[IW_ESSID_MAX_SIZE];
207 u8 ctrl; /* JOIN_CMD_CTRL_* */
208 u8 reserved[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000209} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300210
211struct cmd_enabledisable_path {
212 struct wl1271_cmd_header header;
213
214 u8 channel;
215 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000216} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300217
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300218#define WL1271_RATE_AUTOMATIC 0
219
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300220struct wl1271_cmd_template_set {
221 struct wl1271_cmd_header header;
222
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300223 __le16 len;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300224 u8 template_type;
225 u8 index; /* relevant only for KLV_TEMPLATE type */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300226 __le32 enabled_rates;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300227 u8 short_retry_limit;
228 u8 long_retry_limit;
229 u8 aflags;
230 u8 reserved;
231 u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000232} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300233
234#define TIM_ELE_ID 5
235#define PARTIAL_VBM_MAX 251
236
237struct wl1271_tim {
238 u8 identity;
239 u8 length;
240 u8 dtim_count;
241 u8 dtim_period;
242 u8 bitmap_ctrl;
243 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000244} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300245
246enum wl1271_cmd_ps_mode {
247 STATION_ACTIVE_MODE,
248 STATION_POWER_SAVE_MODE
249};
250
251struct wl1271_cmd_ps_params {
252 struct wl1271_cmd_header header;
253
254 u8 ps_mode; /* STATION_* */
255 u8 send_null_data; /* Do we have to send NULL data packet ? */
256 u8 retries; /* Number of retires for the initial NULL data packet */
257
258 /*
259 * TUs during which the target stays awake after switching
260 * to power save mode.
261 */
262 u8 hang_over_period;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300263 __le32 null_data_rate;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000264} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300265
266/* HW encryption keys */
267#define NUM_ACCESS_CATEGORIES_COPY 4
268#define MAX_KEY_SIZE 32
269
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300270enum wl1271_cmd_key_action {
271 KEY_ADD_OR_REPLACE = 1,
272 KEY_REMOVE = 2,
273 KEY_SET_ID = 3,
274 MAX_KEY_ACTION = 0xffff,
275};
276
277enum wl1271_cmd_key_type {
278 KEY_NONE = 0,
279 KEY_WEP = 1,
280 KEY_TKIP = 2,
281 KEY_AES = 3,
282 KEY_GEM = 4
283};
284
285/* FIXME: Add description for key-types */
286
287struct wl1271_cmd_set_keys {
288 struct wl1271_cmd_header header;
289
290 /* Ignored for default WEP key */
291 u8 addr[ETH_ALEN];
292
293 /* key_action_e */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300294 __le16 key_action;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300295
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300296 __le16 reserved_1;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300297
298 /* key size in bytes */
299 u8 key_size;
300
301 /* key_type_e */
302 u8 key_type;
303 u8 ssid_profile;
304
305 /*
306 * TKIP, AES: frame's key id field.
307 * For WEP default key: key id;
308 */
309 u8 id;
310 u8 reserved_2[6];
311 u8 key[MAX_KEY_SIZE];
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300312 __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
313 __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000314} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300315
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300316struct wl1271_cmd_test_header {
317 u8 id;
318 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000319} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300320
321enum wl1271_channel_tune_bands {
322 WL1271_CHANNEL_TUNE_BAND_2_4,
323 WL1271_CHANNEL_TUNE_BAND_5,
324 WL1271_CHANNEL_TUNE_BAND_4_9
325};
326
327#define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
328
329#define TEST_CMD_P2G_CAL 0x02
330#define TEST_CMD_CHANNEL_TUNE 0x0d
331#define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200332#define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
333#define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
334
335struct wl1271_general_parms_cmd {
336 struct wl1271_cmd_header header;
337
338 struct wl1271_cmd_test_header test;
339
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300340 struct wl1271_ini_general_params general_params;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200341
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300342 u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
343 u8 sr_sen_n_p;
344 u8 sr_sen_n_p_gain;
345 u8 sr_sen_nrn;
346 u8 sr_sen_prn;
347 u8 padding[3];
David S. Miller14599f12010-06-11 11:34:06 -0700348} __packed;
Juuso Oikarinen152ee6e2010-02-18 13:25:42 +0200349
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200350struct wl1271_radio_parms_cmd {
351 struct wl1271_cmd_header header;
352
353 struct wl1271_cmd_test_header test;
354
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300355 /* Static radio parameters */
356 struct wl1271_ini_band_params_2 static_params_2;
357 struct wl1271_ini_band_params_5 static_params_5;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200358
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300359 /* Dynamic radio parameters */
360 struct wl1271_ini_fem_params_2 dyn_params_2;
361 u8 padding2;
362 struct wl1271_ini_fem_params_5 dyn_params_5;
363 u8 padding3[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000364} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300365
366struct wl1271_cmd_cal_channel_tune {
367 struct wl1271_cmd_header header;
368
369 struct wl1271_cmd_test_header test;
370
371 u8 band;
372 u8 channel;
373
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300374 __le16 radio_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000375} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300376
377struct wl1271_cmd_cal_update_ref_point {
378 struct wl1271_cmd_header header;
379
380 struct wl1271_cmd_test_header test;
381
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300382 __le32 ref_power;
383 __le32 ref_detector;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300384 u8 sub_band;
385 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000386} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300387
388#define MAX_TLV_LENGTH 400
389#define MAX_NVS_VERSION_LENGTH 12
390
391#define WL1271_CAL_P2G_BAND_B_G BIT(0)
392
393struct wl1271_cmd_cal_p2g {
394 struct wl1271_cmd_header header;
395
396 struct wl1271_cmd_test_header test;
397
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300398 __le16 len;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300399 u8 buf[MAX_TLV_LENGTH];
400 u8 type;
401 u8 padding;
402
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300403 __le16 radio_status;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300404 u8 nvs_version[MAX_NVS_VERSION_LENGTH];
405
406 u8 sub_band_mask;
407 u8 padding2;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000408} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300409
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300410
411/*
412 * There are three types of disconnections:
413 *
414 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
415 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
416 * we have passed
417 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
418 * we have passed
419 */
420enum wl1271_disconnect_type {
421 DISCONNECT_IMMEDIATE,
422 DISCONNECT_DEAUTH,
423 DISCONNECT_DISASSOC
424};
425
426struct wl1271_cmd_disconnect {
Luciano Coelho1ed95382010-04-01 11:38:18 +0300427 struct wl1271_cmd_header header;
428
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300429 __le32 rx_config_options;
430 __le32 rx_filter_options;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300431
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300432 __le16 reason;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300433 u8 type;
434
435 u8 padding;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000436} __packed;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300437
Juuso Oikarinenbe86cbe2010-05-27 12:53:01 +0300438#define WL1271_CMD_STA_STATE_CONNECTED 1
439
440struct wl1271_cmd_set_sta_state {
441 struct wl1271_cmd_header header;
442
443 u8 state;
444 u8 padding[3];
445} __attribute__ ((packed));
446
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300447#endif /* __WL1271_CMD_H__ */