ssb: drop BCM4328 hack for SPROM revision
[deliverable/linux.git] / drivers / net / wireless / wl12xx / wl1271_cmd.h
1 /*
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
30 struct acx_header;
31
32 int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
33 size_t res_len);
34 int wl1271_cmd_general_parms(struct wl1271 *wl);
35 int wl1271_cmd_radio_parms(struct wl1271 *wl);
36 int wl1271_cmd_ext_radio_parms(struct wl1271 *wl);
37 int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type);
38 int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
39 int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
40 int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
41 int wl1271_cmd_data_path(struct wl1271 *wl, bool enable);
42 int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, u32 rates, bool send);
43 int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
44 size_t len);
45 int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
46 void *buf, size_t buf_len, int index, u32 rates);
47 int wl1271_cmd_build_null_data(struct wl1271 *wl);
48 int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
49 int 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);
52 int wl1271_build_qos_null_data(struct wl1271 *wl);
53 int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
54 int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
55 int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
56 u8 key_size, const u8 *key, const u8 *addr,
57 u32 tx_seq_32, u16 tx_seq_16);
58 int wl1271_cmd_disconnect(struct wl1271 *wl);
59 int wl1271_cmd_set_sta_state(struct wl1271 *wl);
60
61 enum wl1271_commands {
62 CMD_INTERROGATE = 1, /*use this to read information elements*/
63 CMD_CONFIGURE = 2, /*use this to write information elements*/
64 CMD_ENABLE_RX = 3,
65 CMD_ENABLE_TX = 4,
66 CMD_DISABLE_RX = 5,
67 CMD_DISABLE_TX = 6,
68 CMD_SCAN = 8,
69 CMD_STOP_SCAN = 9,
70 CMD_START_JOIN = 11,
71 CMD_SET_KEYS = 12,
72 CMD_READ_MEMORY = 13,
73 CMD_WRITE_MEMORY = 14,
74 CMD_SET_TEMPLATE = 19,
75 CMD_TEST = 23,
76 CMD_NOISE_HIST = 28,
77 CMD_LNA_CONTROL = 32,
78 CMD_SET_BCN_MODE = 33,
79 CMD_MEASUREMENT = 34,
80 CMD_STOP_MEASUREMENT = 35,
81 CMD_DISCONNECT = 36,
82 CMD_SET_PS_MODE = 37,
83 CMD_CHANNEL_SWITCH = 38,
84 CMD_STOP_CHANNEL_SWICTH = 39,
85 CMD_AP_DISCOVERY = 40,
86 CMD_STOP_AP_DISCOVERY = 41,
87 CMD_SPS_SCAN = 42,
88 CMD_STOP_SPS_SCAN = 43,
89 CMD_HEALTH_CHECK = 45,
90 CMD_DEBUG = 46,
91 CMD_TRIGGER_SCAN_TO = 47,
92 CMD_CONNECTION_SCAN_CFG = 48,
93 CMD_CONNECTION_SCAN_SSID_CFG = 49,
94 CMD_START_PERIODIC_SCAN = 50,
95 CMD_STOP_PERIODIC_SCAN = 51,
96 CMD_SET_STA_STATE = 52,
97
98 NUM_COMMANDS,
99 MAX_COMMAND_ID = 0xFFFF,
100 };
101
102 #define MAX_CMD_PARAMS 572
103
104 enum {
105 CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
106 CMD_TEMPL_KLV_IDX_MAX = 4
107 };
108
109 enum cmd_templ {
110 CMD_TEMPL_NULL_DATA = 0,
111 CMD_TEMPL_BEACON,
112 CMD_TEMPL_CFG_PROBE_REQ_2_4,
113 CMD_TEMPL_CFG_PROBE_REQ_5,
114 CMD_TEMPL_PROBE_RESPONSE,
115 CMD_TEMPL_QOS_NULL_DATA,
116 CMD_TEMPL_PS_POLL,
117 CMD_TEMPL_KLV,
118 CMD_TEMPL_DISCONNECT,
119 CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
120 CMD_TEMPL_PROBE_REQ_5, /* for firmware internal use only */
121 CMD_TEMPL_BAR, /* for firmware internal use only */
122 CMD_TEMPL_CTS, /*
123 * For CTS-to-self (FastCTS) mechanism
124 * for BT/WLAN coexistence (SoftGemini). */
125 CMD_TEMPL_MAX = 0xff
126 };
127
128 /* unit ms */
129 #define WL1271_COMMAND_TIMEOUT 2000
130 #define WL1271_CMD_TEMPL_MAX_SIZE 252
131 #define WL1271_EVENT_TIMEOUT 750
132
133 struct wl1271_cmd_header {
134 __le16 id;
135 __le16 status;
136 /* payload */
137 u8 data[0];
138 } __packed;
139
140 #define WL1271_CMD_MAX_PARAMS 572
141
142 struct wl1271_command {
143 struct wl1271_cmd_header header;
144 u8 parameters[WL1271_CMD_MAX_PARAMS];
145 } __packed;
146
147 enum {
148 CMD_MAILBOX_IDLE = 0,
149 CMD_STATUS_SUCCESS = 1,
150 CMD_STATUS_UNKNOWN_CMD = 2,
151 CMD_STATUS_UNKNOWN_IE = 3,
152 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
153 CMD_STATUS_RX_BUSY = 13,
154 CMD_STATUS_INVALID_PARAM = 14,
155 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
156 CMD_STATUS_OUT_OF_MEMORY = 16,
157 CMD_STATUS_STA_TABLE_FULL = 17,
158 CMD_STATUS_RADIO_ERROR = 18,
159 CMD_STATUS_WRONG_NESTING = 19,
160 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
161 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
162 MAX_COMMAND_STATUS = 0xff
163 };
164
165 #define CMDMBOX_HEADER_LEN 4
166 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
167
168 enum {
169 BSS_TYPE_IBSS = 0,
170 BSS_TYPE_STA_BSS = 2,
171 BSS_TYPE_AP_BSS = 3,
172 MAX_BSS_TYPE = 0xFF
173 };
174
175 #define WL1271_JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
176 #define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
177 #define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
178
179 struct wl1271_cmd_join {
180 struct wl1271_cmd_header header;
181
182 __le32 bssid_lsb;
183 __le16 bssid_msb;
184 __le16 beacon_interval; /* in TBTTs */
185 __le32 rx_config_options;
186 __le32 rx_filter_options;
187
188 /*
189 * The target uses this field to determine the rate at
190 * which to transmit control frame responses (such as
191 * ACK or CTS frames).
192 */
193 __le32 basic_rate_set;
194 u8 dtim_interval;
195 /*
196 * bits 0-2: This bitwise field specifies the type
197 * of BSS to start or join (BSS_TYPE_*).
198 * bit 4: Band - The radio band in which to join
199 * or start.
200 * 0 - 2.4GHz band
201 * 1 - 5GHz band
202 * bits 3, 5-7: Reserved
203 */
204 u8 bss_type;
205 u8 channel;
206 u8 ssid_len;
207 u8 ssid[IW_ESSID_MAX_SIZE];
208 u8 ctrl; /* JOIN_CMD_CTRL_* */
209 u8 reserved[3];
210 } __packed;
211
212 struct cmd_enabledisable_path {
213 struct wl1271_cmd_header header;
214
215 u8 channel;
216 u8 padding[3];
217 } __packed;
218
219 #define WL1271_RATE_AUTOMATIC 0
220
221 struct wl1271_cmd_template_set {
222 struct wl1271_cmd_header header;
223
224 __le16 len;
225 u8 template_type;
226 u8 index; /* relevant only for KLV_TEMPLATE type */
227 __le32 enabled_rates;
228 u8 short_retry_limit;
229 u8 long_retry_limit;
230 u8 aflags;
231 u8 reserved;
232 u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
233 } __packed;
234
235 #define TIM_ELE_ID 5
236 #define PARTIAL_VBM_MAX 251
237
238 struct wl1271_tim {
239 u8 identity;
240 u8 length;
241 u8 dtim_count;
242 u8 dtim_period;
243 u8 bitmap_ctrl;
244 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
245 } __packed;
246
247 enum wl1271_cmd_ps_mode {
248 STATION_ACTIVE_MODE,
249 STATION_POWER_SAVE_MODE
250 };
251
252 struct wl1271_cmd_ps_params {
253 struct wl1271_cmd_header header;
254
255 u8 ps_mode; /* STATION_* */
256 u8 send_null_data; /* Do we have to send NULL data packet ? */
257 u8 retries; /* Number of retires for the initial NULL data packet */
258
259 /*
260 * TUs during which the target stays awake after switching
261 * to power save mode.
262 */
263 u8 hang_over_period;
264 __le32 null_data_rate;
265 } __packed;
266
267 /* HW encryption keys */
268 #define NUM_ACCESS_CATEGORIES_COPY 4
269 #define MAX_KEY_SIZE 32
270
271 enum wl1271_cmd_key_action {
272 KEY_ADD_OR_REPLACE = 1,
273 KEY_REMOVE = 2,
274 KEY_SET_ID = 3,
275 MAX_KEY_ACTION = 0xffff,
276 };
277
278 enum wl1271_cmd_key_type {
279 KEY_NONE = 0,
280 KEY_WEP = 1,
281 KEY_TKIP = 2,
282 KEY_AES = 3,
283 KEY_GEM = 4,
284 };
285
286 /* FIXME: Add description for key-types */
287
288 struct wl1271_cmd_set_keys {
289 struct wl1271_cmd_header header;
290
291 /* Ignored for default WEP key */
292 u8 addr[ETH_ALEN];
293
294 /* key_action_e */
295 __le16 key_action;
296
297 __le16 reserved_1;
298
299 /* key size in bytes */
300 u8 key_size;
301
302 /* key_type_e */
303 u8 key_type;
304 u8 ssid_profile;
305
306 /*
307 * TKIP, AES: frame's key id field.
308 * For WEP default key: key id;
309 */
310 u8 id;
311 u8 reserved_2[6];
312 u8 key[MAX_KEY_SIZE];
313 __le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
314 __le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
315 } __packed;
316
317 struct wl1271_cmd_test_header {
318 u8 id;
319 u8 padding[3];
320 } __packed;
321
322 enum wl1271_channel_tune_bands {
323 WL1271_CHANNEL_TUNE_BAND_2_4,
324 WL1271_CHANNEL_TUNE_BAND_5,
325 WL1271_CHANNEL_TUNE_BAND_4_9
326 };
327
328 #define WL1271_PD_REFERENCE_POINT_BAND_B_G 0
329
330 #define TEST_CMD_P2G_CAL 0x02
331 #define TEST_CMD_CHANNEL_TUNE 0x0d
332 #define TEST_CMD_UPDATE_PD_REFERENCE_POINT 0x1d
333 #define TEST_CMD_INI_FILE_RADIO_PARAM 0x19
334 #define TEST_CMD_INI_FILE_GENERAL_PARAM 0x1E
335 #define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
336
337 struct wl1271_general_parms_cmd {
338 struct wl1271_cmd_header header;
339
340 struct wl1271_cmd_test_header test;
341
342 struct wl1271_ini_general_params general_params;
343
344 u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
345 u8 sr_sen_n_p;
346 u8 sr_sen_n_p_gain;
347 u8 sr_sen_nrn;
348 u8 sr_sen_prn;
349 u8 padding[3];
350 } __packed;
351
352 struct wl1271_radio_parms_cmd {
353 struct wl1271_cmd_header header;
354
355 struct wl1271_cmd_test_header test;
356
357 /* Static radio parameters */
358 struct wl1271_ini_band_params_2 static_params_2;
359 struct wl1271_ini_band_params_5 static_params_5;
360
361 /* Dynamic radio parameters */
362 struct wl1271_ini_fem_params_2 dyn_params_2;
363 u8 padding2;
364 struct wl1271_ini_fem_params_5 dyn_params_5;
365 u8 padding3[2];
366 } __packed;
367
368 struct wl1271_ext_radio_parms_cmd {
369 struct wl1271_cmd_header header;
370
371 struct wl1271_cmd_test_header test;
372
373 u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
374 u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
375 u8 padding[3];
376 } __packed;
377
378 struct wl1271_cmd_cal_channel_tune {
379 struct wl1271_cmd_header header;
380
381 struct wl1271_cmd_test_header test;
382
383 u8 band;
384 u8 channel;
385
386 __le16 radio_status;
387 } __packed;
388
389 struct wl1271_cmd_cal_update_ref_point {
390 struct wl1271_cmd_header header;
391
392 struct wl1271_cmd_test_header test;
393
394 __le32 ref_power;
395 __le32 ref_detector;
396 u8 sub_band;
397 u8 padding[3];
398 } __packed;
399
400 #define MAX_TLV_LENGTH 400
401 #define MAX_NVS_VERSION_LENGTH 12
402
403 #define WL1271_CAL_P2G_BAND_B_G BIT(0)
404
405 struct wl1271_cmd_cal_p2g {
406 struct wl1271_cmd_header header;
407
408 struct wl1271_cmd_test_header test;
409
410 __le16 len;
411 u8 buf[MAX_TLV_LENGTH];
412 u8 type;
413 u8 padding;
414
415 __le16 radio_status;
416 u8 nvs_version[MAX_NVS_VERSION_LENGTH];
417
418 u8 sub_band_mask;
419 u8 padding2;
420 } __packed;
421
422
423 /*
424 * There are three types of disconnections:
425 *
426 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
427 * DISCONNECT_DEAUTH: the fw generates a DEAUTH request with the reason
428 * we have passed
429 * DISCONNECT_DISASSOC: the fw generates a DESASSOC request with the reason
430 * we have passed
431 */
432 enum wl1271_disconnect_type {
433 DISCONNECT_IMMEDIATE,
434 DISCONNECT_DEAUTH,
435 DISCONNECT_DISASSOC
436 };
437
438 struct wl1271_cmd_disconnect {
439 struct wl1271_cmd_header header;
440
441 __le32 rx_config_options;
442 __le32 rx_filter_options;
443
444 __le16 reason;
445 u8 type;
446
447 u8 padding;
448 } __packed;
449
450 #define WL1271_CMD_STA_STATE_CONNECTED 1
451
452 struct wl1271_cmd_set_sta_state {
453 struct wl1271_cmd_header header;
454
455 u8 state;
456 u8 padding[3];
457 } __packed;
458
459 #endif /* __WL1271_CMD_H__ */
This page took 0.047048 seconds and 5 git commands to generate.