blob: e5c74c631374cd0c051574dff620b0a200f3d83a [file] [log] [blame]
Kalle Valo2f01a1f2009-04-29 23:33:31 +03001/*
Kalle Valo80301cd2009-06-12 14:17:39 +03002 * This file is part of wl1251
Kalle Valo2f01a1f2009-04-29 23:33:31 +03003 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation
6 *
Kalle Valo2f01a1f2009-04-29 23:33:31 +03007 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 */
22
Kalle Valo80301cd2009-06-12 14:17:39 +030023#ifndef __WL1251_CMD_H__
24#define __WL1251_CMD_H__
Kalle Valo2f01a1f2009-04-29 23:33:31 +030025
Kalle Valo13674112009-06-12 14:17:25 +030026#include "wl1251.h"
Kalle Valo2f01a1f2009-04-29 23:33:31 +030027
Kalle Valodc52f0a2010-01-05 20:17:03 +020028#include <net/cfg80211.h>
29
Kalle Valoff258392009-06-12 14:14:19 +030030struct acx_header;
31
Kalle Valo80301cd2009-06-12 14:17:39 +030032int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len);
33int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer);
34int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len);
35int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len);
36int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030037 void *bitmap, u16 bitmap_len, u8 bitmap_control);
Kalle Valo80301cd2009-06-12 14:17:39 +030038int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable);
Kalle Valoc88f8752009-08-07 13:34:34 +030039int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel,
40 u16 beacon_interval, u8 dtim_interval);
Kalle Valo80301cd2009-06-12 14:17:39 +030041int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
42int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
Kalle Valoff258392009-06-12 14:14:19 +030043 size_t len);
Kalle Valo80301cd2009-06-12 14:17:39 +030044int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
Kalle Valo2f01a1f2009-04-29 23:33:31 +030045 void *buf, size_t buf_len);
Kalle Valo3a98c302010-01-05 20:16:51 +020046int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len,
Kalle Valodc52f0a2010-01-05 20:17:03 +020047 struct ieee80211_channel *channels[],
Kalle Valo3a98c302010-01-05 20:16:51 +020048 unsigned int n_channels, unsigned int n_probes);
49int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout);
Kalle Valo2f01a1f2009-04-29 23:33:31 +030050
51/* unit ms */
Kalle Valo80301cd2009-06-12 14:17:39 +030052#define WL1251_COMMAND_TIMEOUT 2000
Kalle Valo2f01a1f2009-04-29 23:33:31 +030053
Kalle Valo80301cd2009-06-12 14:17:39 +030054enum wl1251_commands {
Kalle Valo2f01a1f2009-04-29 23:33:31 +030055 CMD_RESET = 0,
56 CMD_INTERROGATE = 1, /*use this to read information elements*/
57 CMD_CONFIGURE = 2, /*use this to write information elements*/
58 CMD_ENABLE_RX = 3,
59 CMD_ENABLE_TX = 4,
60 CMD_DISABLE_RX = 5,
61 CMD_DISABLE_TX = 6,
62 CMD_SCAN = 8,
63 CMD_STOP_SCAN = 9,
64 CMD_VBM = 10,
65 CMD_START_JOIN = 11,
66 CMD_SET_KEYS = 12,
67 CMD_READ_MEMORY = 13,
68 CMD_WRITE_MEMORY = 14,
69 CMD_BEACON = 19,
70 CMD_PROBE_RESP = 20,
71 CMD_NULL_DATA = 21,
72 CMD_PROBE_REQ = 22,
73 CMD_TEST = 23,
74 CMD_RADIO_CALIBRATE = 25, /* OBSOLETE */
75 CMD_ENABLE_RX_PATH = 27, /* OBSOLETE */
76 CMD_NOISE_HIST = 28,
77 CMD_RX_RESET = 29,
78 CMD_PS_POLL = 30,
79 CMD_QOS_NULL_DATA = 31,
80 CMD_LNA_CONTROL = 32,
81 CMD_SET_BCN_MODE = 33,
82 CMD_MEASUREMENT = 34,
83 CMD_STOP_MEASUREMENT = 35,
84 CMD_DISCONNECT = 36,
85 CMD_SET_PS_MODE = 37,
86 CMD_CHANNEL_SWITCH = 38,
87 CMD_STOP_CHANNEL_SWICTH = 39,
88 CMD_AP_DISCOVERY = 40,
89 CMD_STOP_AP_DISCOVERY = 41,
90 CMD_SPS_SCAN = 42,
91 CMD_STOP_SPS_SCAN = 43,
92 CMD_HEALTH_CHECK = 45,
93 CMD_DEBUG = 46,
94 CMD_TRIGGER_SCAN_TO = 47,
95
96 NUM_COMMANDS,
97 MAX_COMMAND_ID = 0xFFFF,
98};
99
100#define MAX_CMD_PARAMS 572
101
Kalle Valo80301cd2009-06-12 14:17:39 +0300102struct wl1251_cmd_header {
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300103 u16 id;
104 u16 status;
Kalle Valoff258392009-06-12 14:14:19 +0300105 /* payload */
106 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000107} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300108
Kalle Valo80301cd2009-06-12 14:17:39 +0300109struct wl1251_command {
110 struct wl1251_cmd_header header;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300111 u8 parameters[MAX_CMD_PARAMS];
Grazvydas Ignotas8d5ad082010-08-17 22:46:52 +0300112} __packed;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300113
114enum {
115 CMD_MAILBOX_IDLE = 0,
116 CMD_STATUS_SUCCESS = 1,
117 CMD_STATUS_UNKNOWN_CMD = 2,
118 CMD_STATUS_UNKNOWN_IE = 3,
119 CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11,
120 CMD_STATUS_RX_BUSY = 13,
121 CMD_STATUS_INVALID_PARAM = 14,
122 CMD_STATUS_TEMPLATE_TOO_LARGE = 15,
123 CMD_STATUS_OUT_OF_MEMORY = 16,
124 CMD_STATUS_STA_TABLE_FULL = 17,
125 CMD_STATUS_RADIO_ERROR = 18,
126 CMD_STATUS_WRONG_NESTING = 19,
127 CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/
128 CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/
129 MAX_COMMAND_STATUS = 0xff
130};
131
132
133/*
134 * CMD_READ_MEMORY
135 *
136 * The host issues this command to read the WiLink device memory/registers.
137 *
138 * Note: The Base Band address has special handling (16 bits registers and
139 * addresses). For more information, see the hardware specification.
140 */
141/*
142 * CMD_WRITE_MEMORY
143 *
144 * The host issues this command to write the WiLink device memory/registers.
145 *
146 * The Base Band address has special handling (16 bits registers and
147 * addresses). For more information, see the hardware specification.
148 */
149#define MAX_READ_SIZE 256
150
151struct cmd_read_write_memory {
Kalle Valo80301cd2009-06-12 14:17:39 +0300152 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300153
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300154 /* The address of the memory to read from or write to.*/
155 u32 addr;
156
157 /* The amount of data in bytes to read from or write to the WiLink
158 * device.*/
159 u32 size;
160
161 /* The actual value read from or written to the Wilink. The source
162 of this field is the Host in WRITE command or the Wilink in READ
163 command. */
164 u8 value[MAX_READ_SIZE];
Grazvydas Ignotas8d5ad082010-08-17 22:46:52 +0300165} __packed;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300166
167#define CMDMBOX_HEADER_LEN 4
168#define CMDMBOX_INFO_ELEM_HEADER_LEN 4
169
Kalle Valo3a98c302010-01-05 20:16:51 +0200170#define WL1251_SCAN_MIN_DURATION 30000
171#define WL1251_SCAN_MAX_DURATION 60000
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300172
Kalle Valodc52f0a2010-01-05 20:17:03 +0200173#define WL1251_SCAN_NUM_PROBES 3
174
Kalle Valo3a98c302010-01-05 20:16:51 +0200175struct wl1251_scan_parameters {
John W. Linville1ab36d62010-07-21 12:25:10 -0400176 __le32 rx_config_options;
177 __le32 rx_filter_options;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300178
179 /*
180 * Scan options:
181 * bit 0: When this bit is set, passive scan.
182 * bit 1: Band, when this bit is set we scan
183 * in the 5Ghz band.
184 * bit 2: voice mode, 0 for normal scan.
185 * bit 3: scan priority, 1 for high priority.
186 */
John W. Linville1ab36d62010-07-21 12:25:10 -0400187 __le16 scan_options;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300188
189 /* Number of channels to scan */
190 u8 num_channels;
191
192 /* Number opf probe requests to send, per channel */
193 u8 num_probe_requests;
194
195 /* Rate and modulation for probe requests */
John W. Linville1ab36d62010-07-21 12:25:10 -0400196 __le16 tx_rate;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300197
198 u8 tid_trigger;
199 u8 ssid_len;
Kalle Valo3a98c302010-01-05 20:16:51 +0200200 u8 ssid[32];
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300201
Eric Dumazetba2d3582010-06-02 18:10:09 +0000202} __packed;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300203
Kalle Valo3a98c302010-01-05 20:16:51 +0200204struct wl1251_scan_ch_parameters {
John W. Linville1ab36d62010-07-21 12:25:10 -0400205 __le32 min_duration; /* in TU */
206 __le32 max_duration; /* in TU */
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300207 u32 bssid_lsb;
208 u16 bssid_msb;
209
210 /*
211 * bits 0-3: Early termination count.
212 * bits 4-5: Early termination condition.
213 */
214 u8 early_termination;
215
216 u8 tx_power_att;
217 u8 channel;
218 u8 pad[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000219} __packed;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300220
221/* SCAN parameters */
222#define SCAN_MAX_NUM_OF_CHANNELS 16
223
Kalle Valo3a98c302010-01-05 20:16:51 +0200224struct wl1251_cmd_scan {
Kalle Valo80301cd2009-06-12 14:17:39 +0300225 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300226
Kalle Valo3a98c302010-01-05 20:16:51 +0200227 struct wl1251_scan_parameters params;
228 struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000229} __packed;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300230
231enum {
232 BSS_TYPE_IBSS = 0,
233 BSS_TYPE_STA_BSS = 2,
234 BSS_TYPE_AP_BSS = 3,
235 MAX_BSS_TYPE = 0xFF
236};
237
238#define JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */
239#define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE 0x01 /* Early wakeup time */
240
241
242struct cmd_join {
Kalle Valo80301cd2009-06-12 14:17:39 +0300243 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300244
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300245 u32 bssid_lsb;
246 u16 bssid_msb;
247 u16 beacon_interval; /* in TBTTs */
248 u32 rx_config_options;
249 u32 rx_filter_options;
250
251 /*
252 * The target uses this field to determine the rate at
253 * which to transmit control frame responses (such as
254 * ACK or CTS frames).
255 */
256 u16 basic_rate_set;
257 u8 dtim_interval;
258 u8 tx_ctrl_frame_rate; /* OBSOLETE */
259 u8 tx_ctrl_frame_mod; /* OBSOLETE */
260 /*
261 * bits 0-2: This bitwise field specifies the type
262 * of BSS to start or join (BSS_TYPE_*).
263 * bit 4: Band - The radio band in which to join
264 * or start.
265 * 0 - 2.4GHz band
266 * 1 - 5GHz band
267 * bits 3, 5-7: Reserved
268 */
269 u8 bss_type;
270 u8 channel;
271 u8 ssid_len;
272 u8 ssid[IW_ESSID_MAX_SIZE];
273 u8 ctrl; /* JOIN_CMD_CTRL_* */
274 u8 tx_mgt_frame_rate; /* OBSOLETE */
275 u8 tx_mgt_frame_mod; /* OBSOLETE */
276 u8 reserved;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000277} __packed;
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300278
Kalle Valoff258392009-06-12 14:14:19 +0300279struct cmd_enabledisable_path {
Kalle Valo80301cd2009-06-12 14:17:39 +0300280 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300281
282 u8 channel;
283 u8 padding[3];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000284} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300285
Kalle Valo80301cd2009-06-12 14:17:39 +0300286#define WL1251_MAX_TEMPLATE_SIZE 300
Kalle Valoff258392009-06-12 14:14:19 +0300287
Kalle Valo80301cd2009-06-12 14:17:39 +0300288struct wl1251_cmd_packet_template {
289 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300290
291 __le16 size;
292 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000293} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300294
295#define TIM_ELE_ID 5
296#define PARTIAL_VBM_MAX 251
297
Kalle Valo80301cd2009-06-12 14:17:39 +0300298struct wl1251_tim {
Kalle Valoff258392009-06-12 14:14:19 +0300299 u8 identity;
300 u8 length;
301 u8 dtim_count;
302 u8 dtim_period;
303 u8 bitmap_ctrl;
304 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
Eric Dumazetba2d3582010-06-02 18:10:09 +0000305} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300306
307/* Virtual Bit Map update */
Kalle Valo80301cd2009-06-12 14:17:39 +0300308struct wl1251_cmd_vbm_update {
309 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300310 __le16 len;
311 u8 padding[2];
Kalle Valo80301cd2009-06-12 14:17:39 +0300312 struct wl1251_tim tim;
Eric Dumazetba2d3582010-06-02 18:10:09 +0000313} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300314
Kalle Valo80301cd2009-06-12 14:17:39 +0300315enum wl1251_cmd_ps_mode {
Kalle Valoff258392009-06-12 14:14:19 +0300316 STATION_ACTIVE_MODE,
317 STATION_POWER_SAVE_MODE
318};
319
Kalle Valo80301cd2009-06-12 14:17:39 +0300320struct wl1251_cmd_ps_params {
321 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300322
323 u8 ps_mode; /* STATION_* */
324 u8 send_null_data; /* Do we have to send NULL data packet ? */
325 u8 retries; /* Number of retires for the initial NULL data packet */
326
327 /*
328 * TUs during which the target stays awake after switching
329 * to power save mode.
330 */
331 u8 hang_over_period;
332 u16 null_data_rate;
333 u8 pad[2];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000334} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300335
Kalle Valo80301cd2009-06-12 14:17:39 +0300336struct wl1251_cmd_trigger_scan_to {
337 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300338
339 u32 timeout;
Grazvydas Ignotas8d5ad082010-08-17 22:46:52 +0300340} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300341
342/* HW encryption keys */
343#define NUM_ACCESS_CATEGORIES_COPY 4
344#define MAX_KEY_SIZE 32
345
346/* When set, disable HW encryption */
347#define DF_ENCRYPTION_DISABLE 0x01
348/* When set, disable HW decryption */
349#define DF_SNIFF_MODE_ENABLE 0x80
350
Kalle Valo80301cd2009-06-12 14:17:39 +0300351enum wl1251_cmd_key_action {
Kalle Valoff258392009-06-12 14:14:19 +0300352 KEY_ADD_OR_REPLACE = 1,
353 KEY_REMOVE = 2,
354 KEY_SET_ID = 3,
355 MAX_KEY_ACTION = 0xffff,
356};
357
Kalle Valo80301cd2009-06-12 14:17:39 +0300358enum wl1251_cmd_key_type {
Kalle Valoff258392009-06-12 14:14:19 +0300359 KEY_WEP_DEFAULT = 0,
360 KEY_WEP_ADDR = 1,
361 KEY_AES_GROUP = 4,
362 KEY_AES_PAIRWISE = 5,
363 KEY_WEP_GROUP = 6,
364 KEY_TKIP_MIC_GROUP = 10,
365 KEY_TKIP_MIC_PAIRWISE = 11,
366};
367
368/*
369 *
370 * key_type_e key size key format
371 * ---------- --------- ----------
372 * 0x00 5, 13, 29 Key data
373 * 0x01 5, 13, 29 Key data
374 * 0x04 16 16 bytes of key data
375 * 0x05 16 16 bytes of key data
376 * 0x0a 32 16 bytes of TKIP key data
377 * 8 bytes of RX MIC key data
378 * 8 bytes of TX MIC key data
379 * 0x0b 32 16 bytes of TKIP key data
380 * 8 bytes of RX MIC key data
381 * 8 bytes of TX MIC key data
382 *
383 */
384
Kalle Valo80301cd2009-06-12 14:17:39 +0300385struct wl1251_cmd_set_keys {
386 struct wl1251_cmd_header header;
Kalle Valoff258392009-06-12 14:14:19 +0300387
388 /* Ignored for default WEP key */
389 u8 addr[ETH_ALEN];
390
391 /* key_action_e */
392 u16 key_action;
393
394 u16 reserved_1;
395
396 /* key size in bytes */
397 u8 key_size;
398
399 /* key_type_e */
400 u8 key_type;
401 u8 ssid_profile;
402
403 /*
404 * TKIP, AES: frame's key id field.
405 * For WEP default key: key id;
406 */
407 u8 id;
408 u8 reserved_2[6];
409 u8 key[MAX_KEY_SIZE];
410 u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
411 u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000412} __packed;
Kalle Valoff258392009-06-12 14:14:19 +0300413
Kalle Valo2f01a1f2009-04-29 23:33:31 +0300414
Kalle Valo80301cd2009-06-12 14:17:39 +0300415#endif /* __WL1251_CMD_H__ */