blob: 92747cece15e8ec3edd9bf48408bf915839f486f [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 Oikarinend8c42c02010-02-18 13:25:36 +020041int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030042int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
Juuso Oikarinen606c1482010-04-01 11:38:21 +030043 void *buf, size_t buf_len, int index, u32 rates);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030044int wl1271_cmd_build_null_data(struct wl1271 *wl);
45int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
Kalle Valo818e3062010-03-18 12:26:35 +020046int wl1271_cmd_build_probe_req(struct wl1271 *wl,
47 const u8 *ssid, size_t ssid_len,
48 const u8 *ie, size_t ie_len, u8 band);
Kalle Valo023e0822010-03-18 12:26:36 +020049int wl1271_build_qos_null_data(struct wl1271 *wl);
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020050int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030051int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
52int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
Juuso Oikarinenac4e4ce2009-10-08 21:56:19 +030053 u8 key_size, const u8 *key, const u8 *addr,
54 u32 tx_seq_32, u16 tx_seq_16);
Luciano Coelho25a7dc62009-10-12 15:08:42 +030055int wl1271_cmd_disconnect(struct wl1271 *wl);
Juuso Oikarinenbe86cbe2010-05-27 12:53:01 +030056int wl1271_cmd_set_sta_state(struct wl1271 *wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030057
58enum wl1271_commands {
59 CMD_INTERROGATE = 1, /*use this to read information elements*/
60 CMD_CONFIGURE = 2, /*use this to write information elements*/
61 CMD_ENABLE_RX = 3,
62 CMD_ENABLE_TX = 4,
63 CMD_DISABLE_RX = 5,
64 CMD_DISABLE_TX = 6,
65 CMD_SCAN = 8,
66 CMD_STOP_SCAN = 9,
67 CMD_START_JOIN = 11,
68 CMD_SET_KEYS = 12,
69 CMD_READ_MEMORY = 13,
70 CMD_WRITE_MEMORY = 14,
71 CMD_SET_TEMPLATE = 19,
72 CMD_TEST = 23,
73 CMD_NOISE_HIST = 28,
74 CMD_LNA_CONTROL = 32,
75 CMD_SET_BCN_MODE = 33,
76 CMD_MEASUREMENT = 34,
77 CMD_STOP_MEASUREMENT = 35,
78 CMD_DISCONNECT = 36,
79 CMD_SET_PS_MODE = 37,
80 CMD_CHANNEL_SWITCH = 38,
81 CMD_STOP_CHANNEL_SWICTH = 39,
82 CMD_AP_DISCOVERY = 40,
83 CMD_STOP_AP_DISCOVERY = 41,
84 CMD_SPS_SCAN = 42,
85 CMD_STOP_SPS_SCAN = 43,
86 CMD_HEALTH_CHECK = 45,
87 CMD_DEBUG = 46,
88 CMD_TRIGGER_SCAN_TO = 47,
89 CMD_CONNECTION_SCAN_CFG = 48,
90 CMD_CONNECTION_SCAN_SSID_CFG = 49,
91 CMD_START_PERIODIC_SCAN = 50,
92 CMD_STOP_PERIODIC_SCAN = 51,
93 CMD_SET_STA_STATE = 52,
94
95 NUM_COMMANDS,
96 MAX_COMMAND_ID = 0xFFFF,
97};
98
99#define MAX_CMD_PARAMS 572
100
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +0200101enum {
102 CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
103 CMD_TEMPL_KLV_IDX_MAX = 4
104};
105
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300106enum cmd_templ {
107 CMD_TEMPL_NULL_DATA = 0,
108 CMD_TEMPL_BEACON,
109 CMD_TEMPL_CFG_PROBE_REQ_2_4,
110 CMD_TEMPL_CFG_PROBE_REQ_5,
111 CMD_TEMPL_PROBE_RESPONSE,
112 CMD_TEMPL_QOS_NULL_DATA,
113 CMD_TEMPL_PS_POLL,
114 CMD_TEMPL_KLV,
115 CMD_TEMPL_DISCONNECT,
116 CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
117 CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
118 CMD_TEMPL_BAR, /* for firmware internal use only */
119 CMD_TEMPL_CTS, /*
120 * For CTS-to-self (FastCTS) mechanism
121 * for BT/WLAN coexistence (SoftGemini). */
122 CMD_TEMPL_MAX = 0xff
123};
124
125/* unit ms */
126#define WL1271_COMMAND_TIMEOUT 2000
127#define WL1271_CMD_TEMPL_MAX_SIZE 252
Teemu Paasikivi0cbb1032010-05-07 11:39:01 +0300128#define WL1271_EVENT_TIMEOUT 750
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300129
130struct wl1271_cmd_header {
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300131 __le16 id;
132 __le16 status;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300133 /* payload */
134 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000135} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300136
137#define WL1271_CMD_MAX_PARAMS 572
138
139struct wl1271_command {
140 struct wl1271_cmd_header header;
141 u8 parameters[WL1271_CMD_MAX_PARAMS];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000142} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300143
144enum {
145 CMD_MAILBOX_IDLE = 0,
146 CMD_STATUS_SUCCESS = 1,
147 CMD_STATUS_UNKNOWN_CMD = 2,
148 CMD_STATUS_UNKNOWN_IE = 3,
149 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
150 CMD_STATUS_RX_BUSY = 13,
151 CMD_STATUS_INVALID_PARAM = 14,
152 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
153 CMD_STATUS_OUT_OF_MEMORY = 16,
154 CMD_STATUS_STA_TABLE_FULL = 17,
155 CMD_STATUS_RADIO_ERROR = 18,
156 CMD_STATUS_WRONG_NESTING = 19,
157 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
158 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
159 MAX_COMMAND_STATUS = 0xff
160};
161
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300162#define CMDMBOX_HEADER_LEN 4
163#define CMDMBOX_INFO_ELEM_HEADER_LEN 4
164
165enum {
166 BSS_TYPE_IBSS = 0,
167 BSS_TYPE_STA_BSS = 2,
168 BSS_TYPE_AP_BSS = 3,
169 MAX_BSS_TYPE = 0xFF
170};
171
172#define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
173#define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
Teemu Paasikivia4102642009-10-13 12:47:51 +0300174#define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300175
176struct wl1271_cmd_join {
177 struct wl1271_cmd_header header;
178
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300179 __le32 bssid_lsb;
180 __le16 bssid_msb;
181 __le16 beacon_interval; /* in TBTTs */
182 __le32 rx_config_options;
183 __le32 rx_filter_options;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300184
185 /*
186 * The target uses this field to determine the rate at
187 * which to transmit control frame responses (such as
188 * ACK or CTS frames).
189 */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300190 __le32 basic_rate_set;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300191 u8 dtim_interval;
192 /*
193 * bits 0-2: This bitwise field specifies the type
194 * of BSS to start or join (BSS_TYPE_*).
195 * bit 4: Band - The radio band in which to join
196 * or start.
197 * 0 - 2.4GHz band
198 * 1 - 5GHz band
199 * bits 3, 5-7: Reserved
200 */
201 u8 bss_type;
202 u8 channel;
203 u8 ssid_len;
204 u8 ssid[IW_ESSID_MAX_SIZE];
205 u8 ctrl; /* JOIN_CMD_CTRL_* */
206 u8 reserved[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000207} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300208
209struct cmd_enabledisable_path {
210 struct wl1271_cmd_header header;
211
212 u8 channel;
213 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000214} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300215
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300216#define WL1271_RATE_AUTOMATIC 0
217
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300218struct wl1271_cmd_template_set {
219 struct wl1271_cmd_header header;
220
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300221 __le16 len;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300222 u8 template_type;
223 u8 index; /* relevant only for KLV_TEMPLATE type */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300224 __le32 enabled_rates;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300225 u8 short_retry_limit;
226 u8 long_retry_limit;
227 u8 aflags;
228 u8 reserved;
229 u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000230} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300231
232#define TIM_ELE_ID 5
233#define PARTIAL_VBM_MAX 251
234
235struct wl1271_tim {
236 u8 identity;
237 u8 length;
238 u8 dtim_count;
239 u8 dtim_period;
240 u8 bitmap_ctrl;
241 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000242} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300243
244enum wl1271_cmd_ps_mode {
245 STATION_ACTIVE_MODE,
246 STATION_POWER_SAVE_MODE
247};
248
249struct wl1271_cmd_ps_params {
250 struct wl1271_cmd_header header;
251
252 u8 ps_mode; /* STATION_* */
253 u8 send_null_data; /* Do we have to send NULL data packet ? */
254 u8 retries; /* Number of retires for the initial NULL data packet */
255
256 /*
257 * TUs during which the target stays awake after switching
258 * to power save mode.
259 */
260 u8 hang_over_period;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300261 __le32 null_data_rate;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000262} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300263
264/* HW encryption keys */
265#define NUM_ACCESS_CATEGORIES_COPY 4
266#define MAX_KEY_SIZE 32
267
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300268enum wl1271_cmd_key_action {
269 KEY_ADD_OR_REPLACE = 1,
270 KEY_REMOVE = 2,
271 KEY_SET_ID = 3,
272 MAX_KEY_ACTION = 0xffff,
273};
274
275enum wl1271_cmd_key_type {
276 KEY_NONE = 0,
277 KEY_WEP = 1,
278 KEY_TKIP = 2,
279 KEY_AES = 3,
280 KEY_GEM = 4
281};
282
283/* FIXME: Add description for key-types */
284
285struct wl1271_cmd_set_keys {
286 struct wl1271_cmd_header header;
287
288 /* Ignored for default WEP key */
289 u8 addr[ETH_ALEN];
290
291 /* key_action_e */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300292 __le16 key_action;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300293
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300294 __le16 reserved_1;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300295
296 /* key size in bytes */
297 u8 key_size;
298
299 /* key_type_e */
300 u8 key_type;
301 u8 ssid_profile;
302
303 /*
304 * TKIP, AES: frame's key id field.
305 * For WEP default key: key id;
306 */
307 u8 id;
308 u8 reserved_2[6];
309 u8 key[MAX_KEY_SIZE];
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300310 __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
311 __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000312} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300313
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300314struct wl1271_cmd_test_header {
315 u8 id;
316 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000317} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300318
319enum wl1271_channel_tune_bands {
320 WL1271_CHANNEL_TUNE_BAND_2_4,
321 WL1271_CHANNEL_TUNE_BAND_5,
322 WL1271_CHANNEL_TUNE_BAND_4_9
323};
324
325#define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
326
327#define TEST_CMD_P2G_CAL 0x02
328#define TEST_CMD_CHANNEL_TUNE 0x0d
329#define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200330#define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
331#define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
332
333struct wl1271_general_parms_cmd {
334 struct wl1271_cmd_header header;
335
336 struct wl1271_cmd_test_header test;
337
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300338 struct wl1271_ini_general_params general_params;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200339
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300340 u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
341 u8 sr_sen_n_p;
342 u8 sr_sen_n_p_gain;
343 u8 sr_sen_nrn;
344 u8 sr_sen_prn;
345 u8 padding[3];
David S. Miller14599f12010-06-11 11:34:06 -0700346} __packed;
Juuso Oikarinen152ee6e2010-02-18 13:25:42 +0200347
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200348struct wl1271_radio_parms_cmd {
349 struct wl1271_cmd_header header;
350
351 struct wl1271_cmd_test_header test;
352
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300353 /* Static radio parameters */
354 struct wl1271_ini_band_params_2 static_params_2;
355 struct wl1271_ini_band_params_5 static_params_5;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200356
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300357 /* Dynamic radio parameters */
358 struct wl1271_ini_fem_params_2 dyn_params_2;
359 u8 padding2;
360 struct wl1271_ini_fem_params_5 dyn_params_5;
361 u8 padding3[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000362} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300363
364struct wl1271_cmd_cal_channel_tune {
365 struct wl1271_cmd_header header;
366
367 struct wl1271_cmd_test_header test;
368
369 u8 band;
370 u8 channel;
371
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300372 __le16 radio_status;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000373} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300374
375struct wl1271_cmd_cal_update_ref_point {
376 struct wl1271_cmd_header header;
377
378 struct wl1271_cmd_test_header test;
379
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300380 __le32 ref_power;
381 __le32 ref_detector;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300382 u8 sub_band;
383 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000384} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300385
386#define MAX_TLV_LENGTH 400
387#define MAX_NVS_VERSION_LENGTH 12
388
389#define WL1271_CAL_P2G_BAND_B_G BIT(0)
390
391struct wl1271_cmd_cal_p2g {
392 struct wl1271_cmd_header header;
393
394 struct wl1271_cmd_test_header test;
395
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300396 __le16 len;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300397 u8 buf[MAX_TLV_LENGTH];
398 u8 type;
399 u8 padding;
400
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300401 __le16 radio_status;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300402 u8 nvs_version[MAX_NVS_VERSION_LENGTH];
403
404 u8 sub_band_mask;
405 u8 padding2;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000406} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300407
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300408
409/*
410 * There are three types of disconnections:
411 *
412 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
413 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
414 * we have passed
415 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
416 * we have passed
417 */
418enum wl1271_disconnect_type {
419 DISCONNECT_IMMEDIATE,
420 DISCONNECT_DEAUTH,
421 DISCONNECT_DISASSOC
422};
423
424struct wl1271_cmd_disconnect {
Luciano Coelho1ed95382010-04-01 11:38:18 +0300425 struct wl1271_cmd_header header;
426
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300427 __le32 rx_config_options;
428 __le32 rx_filter_options;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300429
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300430 __le16 reason;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300431 u8 type;
432
433 u8 padding;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000434} __packed;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300435
Juuso Oikarinenbe86cbe2010-05-27 12:53:01 +0300436#define WL1271_CMD_STA_STATE_CONNECTED 1
437
438struct wl1271_cmd_set_sta_state {
439 struct wl1271_cmd_header header;
440
441 u8 state;
442 u8 padding[3];
443} __attribute__ ((packed));
444
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300445#endif /* __WL1271_CMD_H__ */