blob: 111d112544fc3358a80a60c07539e9f831313ce5 [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
Shahar Levi00d20102010-11-08 11:20:10 +000025#ifndef __CMD_H__
26#define __CMD_H__
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030027
Shahar Levi00d20102010-11-08 11:20:10 +000028#include "wl12xx.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030029
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 Oikarinen644a4862010-10-05 13:11:56 +020036int wl1271_cmd_ext_radio_parms(struct wl1271 *wl);
Juuso Oikarinen15305492010-02-22 08:38:32 +020037int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030038int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
39int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
40int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
Luciano Coelho94210892009-12-11 15:40:55 +020041int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
Juuso Oikarinen65cddbf2010-08-24 06:28:03 +030042int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, u32 rates, bool send);
43int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
44 size_t len);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030045int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
Juuso Oikarinen606c1482010-04-01 11:38:21 +030046 void *buf, size_t buf_len, int index, u32 rates);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030047int wl1271_cmd_build_null_data(struct wl1271 *wl);
48int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
Kalle Valo818e3062010-03-18 12:26:35 +020049int wl1271_cmd_build_probe_req(struct wl1271 *wl,
50 const u8 *ssid, size_t ssid_len,
51 const u8 *ie, size_t ie_len, u8 band);
Juuso Oikarinen2f6724b2010-11-24 08:16:57 +020052struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl,
53 struct sk_buff *skb);
Kalle Valo023e0822010-03-18 12:26:36 +020054int wl1271_build_qos_null_data(struct wl1271 *wl);
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020055int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030056int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
57int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
Juuso Oikarinenac4e4ce2009-10-08 21:56:19 +030058 u8 key_size, const u8 *key, const u8 *addr,
59 u32 tx_seq_32, u16 tx_seq_16);
Luciano Coelho25a7dc62009-10-12 15:08:42 +030060int wl1271_cmd_disconnect(struct wl1271 *wl);
Juuso Oikarinenbe86cbe2010-05-27 12:53:01 +030061int wl1271_cmd_set_sta_state(struct wl1271 *wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030062
63enum wl1271_commands {
64 CMD_INTERROGATE = 1, /*use this to read information elements*/
65 CMD_CONFIGURE = 2, /*use this to write information elements*/
66 CMD_ENABLE_RX = 3,
67 CMD_ENABLE_TX = 4,
68 CMD_DISABLE_RX = 5,
69 CMD_DISABLE_TX = 6,
70 CMD_SCAN = 8,
71 CMD_STOP_SCAN = 9,
72 CMD_START_JOIN = 11,
73 CMD_SET_KEYS = 12,
74 CMD_READ_MEMORY = 13,
75 CMD_WRITE_MEMORY = 14,
76 CMD_SET_TEMPLATE = 19,
77 CMD_TEST = 23,
78 CMD_NOISE_HIST = 28,
79 CMD_LNA_CONTROL = 32,
80 CMD_SET_BCN_MODE = 33,
81 CMD_MEASUREMENT = 34,
82 CMD_STOP_MEASUREMENT = 35,
83 CMD_DISCONNECT = 36,
84 CMD_SET_PS_MODE = 37,
85 CMD_CHANNEL_SWITCH = 38,
86 CMD_STOP_CHANNEL_SWICTH = 39,
87 CMD_AP_DISCOVERY = 40,
88 CMD_STOP_AP_DISCOVERY = 41,
89 CMD_SPS_SCAN = 42,
90 CMD_STOP_SPS_SCAN = 43,
91 CMD_HEALTH_CHECK = 45,
92 CMD_DEBUG = 46,
93 CMD_TRIGGER_SCAN_TO = 47,
94 CMD_CONNECTION_SCAN_CFG = 48,
95 CMD_CONNECTION_SCAN_SSID_CFG = 49,
96 CMD_START_PERIODIC_SCAN = 50,
97 CMD_STOP_PERIODIC_SCAN = 51,
98 CMD_SET_STA_STATE = 52,
99
100 NUM_COMMANDS,
101 MAX_COMMAND_ID = 0xFFFF,
102};
103
104#define MAX_CMD_PARAMS 572
105
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +0200106enum {
107 CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
108 CMD_TEMPL_KLV_IDX_MAX = 4
109};
110
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300111enum cmd_templ {
112 CMD_TEMPL_NULL_DATA = 0,
113 CMD_TEMPL_BEACON,
114 CMD_TEMPL_CFG_PROBE_REQ_2_4,
115 CMD_TEMPL_CFG_PROBE_REQ_5,
116 CMD_TEMPL_PROBE_RESPONSE,
117 CMD_TEMPL_QOS_NULL_DATA,
118 CMD_TEMPL_PS_POLL,
119 CMD_TEMPL_KLV,
120 CMD_TEMPL_DISCONNECT,
121 CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
122 CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
123 CMD_TEMPL_BAR, /* for firmware internal use only */
124 CMD_TEMPL_CTS, /*
125 * For CTS-to-self (FastCTS) mechanism
126 * for BT/WLAN coexistence (SoftGemini). */
127 CMD_TEMPL_MAX = 0xff
128};
129
130/* unit ms */
131#define WL1271_COMMAND_TIMEOUT 2000
132#define WL1271_CMD_TEMPL_MAX_SIZE 252
Teemu Paasikivi0cbb1032010-05-07 11:39:01 +0300133#define WL1271_EVENT_TIMEOUT 750
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300134
135struct wl1271_cmd_header {
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300136 __le16 id;
137 __le16 status;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300138 /* payload */
139 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000140} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300141
142#define WL1271_CMD_MAX_PARAMS 572
143
144struct wl1271_command {
145 struct wl1271_cmd_header header;
146 u8 parameters[WL1271_CMD_MAX_PARAMS];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000147} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300148
149enum {
150 CMD_MAILBOX_IDLE = 0,
151 CMD_STATUS_SUCCESS = 1,
152 CMD_STATUS_UNKNOWN_CMD = 2,
153 CMD_STATUS_UNKNOWN_IE = 3,
154 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
155 CMD_STATUS_RX_BUSY = 13,
156 CMD_STATUS_INVALID_PARAM = 14,
157 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
158 CMD_STATUS_OUT_OF_MEMORY = 16,
159 CMD_STATUS_STA_TABLE_FULL = 17,
160 CMD_STATUS_RADIO_ERROR = 18,
161 CMD_STATUS_WRONG_NESTING = 19,
162 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
163 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
164 MAX_COMMAND_STATUS = 0xff
165};
166
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300167#define CMDMBOX_HEADER_LEN 4
168#define CMDMBOX_INFO_ELEM_HEADER_LEN 4
169
170enum {
171 BSS_TYPE_IBSS = 0,
172 BSS_TYPE_STA_BSS = 2,
173 BSS_TYPE_AP_BSS = 3,
174 MAX_BSS_TYPE = 0xFF
175};
176
177#define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
178#define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
Teemu Paasikivia4102642009-10-13 12:47:51 +0300179#define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300180
181struct wl1271_cmd_join {
182 struct wl1271_cmd_header header;
183
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300184 __le32 bssid_lsb;
185 __le16 bssid_msb;
186 __le16 beacon_interval; /* in TBTTs */
187 __le32 rx_config_options;
188 __le32 rx_filter_options;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300189
190 /*
191 * The target uses this field to determine the rate at
192 * which to transmit control frame responses (such as
193 * ACK or CTS frames).
194 */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300195 __le32 basic_rate_set;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300196 u8 dtim_interval;
197 /*
198 * bits 0-2: This bitwise field specifies the type
199 * of BSS to start or join (BSS_TYPE_*).
200 * bit 4: Band - The radio band in which to join
201 * or start.
202 * 0 - 2.4GHz band
203 * 1 - 5GHz band
204 * bits 3, 5-7: Reserved
205 */
206 u8 bss_type;
207 u8 channel;
208 u8 ssid_len;
209 u8 ssid[IW_ESSID_MAX_SIZE];
210 u8 ctrl; /* JOIN_CMD_CTRL_* */
211 u8 reserved[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000212} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300213
214struct cmd_enabledisable_path {
215 struct wl1271_cmd_header header;
216
217 u8 channel;
218 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000219} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300220
Juuso Oikarinen606c1482010-04-01 11:38:21 +0300221#define WL1271_RATE_AUTOMATIC 0
222
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300223struct wl1271_cmd_template_set {
224 struct wl1271_cmd_header header;
225
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300226 __le16 len;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300227 u8 template_type;
228 u8 index; /* relevant only for KLV_TEMPLATE type */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300229 __le32 enabled_rates;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300230 u8 short_retry_limit;
231 u8 long_retry_limit;
232 u8 aflags;
233 u8 reserved;
234 u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000235} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300236
237#define TIM_ELE_ID 5
238#define PARTIAL_VBM_MAX 251
239
240struct wl1271_tim {
241 u8 identity;
242 u8 length;
243 u8 dtim_count;
244 u8 dtim_period;
245 u8 bitmap_ctrl;
246 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000247} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300248
249enum wl1271_cmd_ps_mode {
250 STATION_ACTIVE_MODE,
251 STATION_POWER_SAVE_MODE
252};
253
254struct wl1271_cmd_ps_params {
255 struct wl1271_cmd_header header;
256
257 u8 ps_mode; /* STATION_* */
258 u8 send_null_data; /* Do we have to send NULL data packet ? */
259 u8 retries; /* Number of retires for the initial NULL data packet */
260
261 /*
262 * TUs during which the target stays awake after switching
263 * to power save mode.
264 */
265 u8 hang_over_period;
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300266 __le32 null_data_rate;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000267} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300268
269/* HW encryption keys */
270#define NUM_ACCESS_CATEGORIES_COPY 4
271#define MAX_KEY_SIZE 32
272
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300273enum wl1271_cmd_key_action {
274 KEY_ADD_OR_REPLACE = 1,
275 KEY_REMOVE = 2,
276 KEY_SET_ID = 3,
277 MAX_KEY_ACTION = 0xffff,
278};
279
280enum wl1271_cmd_key_type {
281 KEY_NONE = 0,
282 KEY_WEP = 1,
283 KEY_TKIP = 2,
284 KEY_AES = 3,
Juuso Oikarinen7a557242010-09-27 12:42:07 +0200285 KEY_GEM = 4,
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300286};
287
288/* FIXME: Add description for key-types */
289
290struct wl1271_cmd_set_keys {
291 struct wl1271_cmd_header header;
292
293 /* Ignored for default WEP key */
294 u8 addr[ETH_ALEN];
295
296 /* key_action_e */
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300297 __le16 key_action;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300298
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300299 __le16 reserved_1;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300300
301 /* key size in bytes */
302 u8 key_size;
303
304 /* key_type_e */
305 u8 key_type;
306 u8 ssid_profile;
307
308 /*
309 * TKIP, AES: frame's key id field.
310 * For WEP default key: key id;
311 */
312 u8 id;
313 u8 reserved_2[6];
314 u8 key[MAX_KEY_SIZE];
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300315 __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
316 __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000317} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300318
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300319struct wl1271_cmd_test_header {
320 u8 id;
321 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000322} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300323
324enum wl1271_channel_tune_bands {
325 WL1271_CHANNEL_TUNE_BAND_2_4,
326 WL1271_CHANNEL_TUNE_BAND_5,
327 WL1271_CHANNEL_TUNE_BAND_4_9
328};
329
Juuso Oikarinen644a4862010-10-05 13:11:56 +0200330#define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300331
Juuso Oikarinen644a4862010-10-05 13:11:56 +0200332#define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
333#define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
334#define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200335
336struct wl1271_general_parms_cmd {
337 struct wl1271_cmd_header header;
338
339 struct wl1271_cmd_test_header test;
340
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300341 struct wl1271_ini_general_params general_params;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200342
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300343 u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
344 u8 sr_sen_n_p;
345 u8 sr_sen_n_p_gain;
346 u8 sr_sen_nrn;
347 u8 sr_sen_prn;
348 u8 padding[3];
David S. Miller14599f12010-06-11 11:34:06 -0700349} __packed;
Juuso Oikarinen152ee6e2010-02-18 13:25:42 +0200350
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200351struct wl1271_radio_parms_cmd {
352 struct wl1271_cmd_header header;
353
354 struct wl1271_cmd_test_header test;
355
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300356 /* Static radio parameters */
357 struct wl1271_ini_band_params_2 static_params_2;
358 struct wl1271_ini_band_params_5 static_params_5;
Luciano Coelho98b5dd52009-11-23 23:22:17 +0200359
Juuso Oikarineneb70eb72010-05-14 10:46:22 +0300360 /* Dynamic radio parameters */
361 struct wl1271_ini_fem_params_2 dyn_params_2;
362 u8 padding2;
363 struct wl1271_ini_fem_params_5 dyn_params_5;
364 u8 padding3[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000365} __packed;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300366
Juuso Oikarinen644a4862010-10-05 13:11:56 +0200367struct wl1271_ext_radio_parms_cmd {
368 struct wl1271_cmd_header header;
369
370 struct wl1271_cmd_test_header test;
371
372 u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
373 u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
374 u8 padding[3];
375} __packed;
376
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300377/*
378 * There are three types of disconnections:
379 *
380 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
381 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
382 * we have passed
383 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
384 * we have passed
385 */
386enum wl1271_disconnect_type {
387 DISCONNECT_IMMEDIATE,
388 DISCONNECT_DEAUTH,
389 DISCONNECT_DISASSOC
390};
391
392struct wl1271_cmd_disconnect {
Luciano Coelho1ed95382010-04-01 11:38:18 +0300393 struct wl1271_cmd_header header;
394
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300395 __le32 rx_config_options;
396 __le32 rx_filter_options;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300397
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300398 __le16 reason;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300399 u8 type;
400
401 u8 padding;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000402} __packed;
Luciano Coelho25a7dc62009-10-12 15:08:42 +0300403
Juuso Oikarinenbe86cbe2010-05-27 12:53:01 +0300404#define WL1271_CMD_STA_STATE_CONNECTED 1
405
406struct wl1271_cmd_set_sta_state {
407 struct wl1271_cmd_header header;
408
409 u8 state;
410 u8 padding[3];
Luciano Coelho5082b822010-10-05 14:58:49 +0300411} __packed;
Juuso Oikarinenbe86cbe2010-05-27 12:53:01 +0300412
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300413#endif /* __WL1271_CMD_H__ */