cmd.h 10.4 KB
Newer Older
L
Luciano Coelho 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * This file is part of wl1271
 *
 * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
 * Copyright (C) 2009 Nokia Corporation
 *
 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

S
Shahar Levi 已提交
25 26
#ifndef __CMD_H__
#define __CMD_H__
L
Luciano Coelho 已提交
27

S
Shahar Levi 已提交
28
#include "wl12xx.h"
L
Luciano Coelho 已提交
29 30 31

struct acx_header;

32 33
int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
		    size_t res_len);
34 35
int wl1271_cmd_general_parms(struct wl1271 *wl);
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);
L
Luciano Coelho 已提交
38 39 40
int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
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 43 44
int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, u32 rates, bool send);
int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
			   size_t len);
L
Luciano Coelho 已提交
45
int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
46
			    void *buf, size_t buf_len, int index, u32 rates);
L
Luciano Coelho 已提交
47 48
int wl1271_cmd_build_null_data(struct wl1271 *wl);
int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid);
49 50 51
int wl1271_cmd_build_probe_req(struct wl1271 *wl,
			       const u8 *ssid, size_t ssid_len,
			       const u8 *ie, size_t ie_len, u8 band);
52 53
struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl,
					      struct sk_buff *skb);
54
int wl1271_build_qos_null_data(struct wl1271 *wl);
55
int wl1271_cmd_build_klv_null_data(struct wl1271 *wl);
L
Luciano Coelho 已提交
56 57
int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id);
int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type,
58 59
		       u8 key_size, const u8 *key, const u8 *addr,
		       u32 tx_seq_32, u16 tx_seq_16);
L
Luciano Coelho 已提交
60
int wl1271_cmd_disconnect(struct wl1271 *wl);
61
int wl1271_cmd_set_sta_state(struct wl1271 *wl);
L
Luciano Coelho 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

enum wl1271_commands {
	CMD_INTERROGATE     = 1,    /*use this to read information elements*/
	CMD_CONFIGURE       = 2,    /*use this to write information elements*/
	CMD_ENABLE_RX       = 3,
	CMD_ENABLE_TX       = 4,
	CMD_DISABLE_RX      = 5,
	CMD_DISABLE_TX      = 6,
	CMD_SCAN            = 8,
	CMD_STOP_SCAN       = 9,
	CMD_START_JOIN      = 11,
	CMD_SET_KEYS        = 12,
	CMD_READ_MEMORY     = 13,
	CMD_WRITE_MEMORY    = 14,
	CMD_SET_TEMPLATE    = 19,
	CMD_TEST            = 23,
	CMD_NOISE_HIST      = 28,
	CMD_LNA_CONTROL     = 32,
	CMD_SET_BCN_MODE    = 33,
	CMD_MEASUREMENT      = 34,
	CMD_STOP_MEASUREMENT = 35,
	CMD_DISCONNECT       = 36,
	CMD_SET_PS_MODE      = 37,
	CMD_CHANNEL_SWITCH   = 38,
	CMD_STOP_CHANNEL_SWICTH = 39,
	CMD_AP_DISCOVERY     = 40,
	CMD_STOP_AP_DISCOVERY = 41,
	CMD_SPS_SCAN = 42,
	CMD_STOP_SPS_SCAN = 43,
	CMD_HEALTH_CHECK     = 45,
	CMD_DEBUG            = 46,
	CMD_TRIGGER_SCAN_TO  = 47,
	CMD_CONNECTION_SCAN_CFG      = 48,
	CMD_CONNECTION_SCAN_SSID_CFG = 49,
	CMD_START_PERIODIC_SCAN      = 50,
	CMD_STOP_PERIODIC_SCAN       = 51,
	CMD_SET_STA_STATE            = 52,

	NUM_COMMANDS,
	MAX_COMMAND_ID = 0xFFFF,
};

#define MAX_CMD_PARAMS 572

106 107 108 109 110
enum {
	CMD_TEMPL_KLV_IDX_NULL_DATA = 0,
	CMD_TEMPL_KLV_IDX_MAX = 4
};

L
Luciano Coelho 已提交
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
enum cmd_templ {
	CMD_TEMPL_NULL_DATA = 0,
	CMD_TEMPL_BEACON,
	CMD_TEMPL_CFG_PROBE_REQ_2_4,
	CMD_TEMPL_CFG_PROBE_REQ_5,
	CMD_TEMPL_PROBE_RESPONSE,
	CMD_TEMPL_QOS_NULL_DATA,
	CMD_TEMPL_PS_POLL,
	CMD_TEMPL_KLV,
	CMD_TEMPL_DISCONNECT,
	CMD_TEMPL_PROBE_REQ_2_4, /* for firmware internal use only */
	CMD_TEMPL_PROBE_REQ_5,   /* for firmware internal use only */
	CMD_TEMPL_BAR,           /* for firmware internal use only */
	CMD_TEMPL_CTS,           /*
				  * For CTS-to-self (FastCTS) mechanism
				  * for BT/WLAN coexistence (SoftGemini). */
	CMD_TEMPL_MAX = 0xff
};

/* unit ms */
#define WL1271_COMMAND_TIMEOUT     2000
#define WL1271_CMD_TEMPL_MAX_SIZE  252
133
#define WL1271_EVENT_TIMEOUT       750
L
Luciano Coelho 已提交
134 135

struct wl1271_cmd_header {
L
Luciano Coelho 已提交
136 137
	__le16 id;
	__le16 status;
L
Luciano Coelho 已提交
138 139
	/* payload */
	u8 data[0];
140
} __packed;
L
Luciano Coelho 已提交
141 142 143 144 145 146

#define WL1271_CMD_MAX_PARAMS 572

struct wl1271_command {
	struct wl1271_cmd_header header;
	u8  parameters[WL1271_CMD_MAX_PARAMS];
147
} __packed;
L
Luciano Coelho 已提交
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178

enum {
	CMD_MAILBOX_IDLE		=  0,
	CMD_STATUS_SUCCESS		=  1,
	CMD_STATUS_UNKNOWN_CMD		=  2,
	CMD_STATUS_UNKNOWN_IE		=  3,
	CMD_STATUS_REJECT_MEAS_SG_ACTIVE	= 11,
	CMD_STATUS_RX_BUSY		= 13,
	CMD_STATUS_INVALID_PARAM		= 14,
	CMD_STATUS_TEMPLATE_TOO_LARGE		= 15,
	CMD_STATUS_OUT_OF_MEMORY		= 16,
	CMD_STATUS_STA_TABLE_FULL		= 17,
	CMD_STATUS_RADIO_ERROR		= 18,
	CMD_STATUS_WRONG_NESTING		= 19,
	CMD_STATUS_TIMEOUT		= 21, /* Driver internal use.*/
	CMD_STATUS_FW_RESET		= 22, /* Driver internal use.*/
	MAX_COMMAND_STATUS		= 0xff
};

#define CMDMBOX_HEADER_LEN 4
#define CMDMBOX_INFO_ELEM_HEADER_LEN 4

enum {
	BSS_TYPE_IBSS = 0,
	BSS_TYPE_STA_BSS = 2,
	BSS_TYPE_AP_BSS = 3,
	MAX_BSS_TYPE = 0xFF
};

#define WL1271_JOIN_CMD_CTRL_TX_FLUSH     0x80 /* Firmware flushes all Tx */
#define WL1271_JOIN_CMD_TX_SESSION_OFFSET 1
179
#define WL1271_JOIN_CMD_BSS_TYPE_5GHZ 0x10
L
Luciano Coelho 已提交
180 181 182 183

struct wl1271_cmd_join {
	struct wl1271_cmd_header header;

L
Luciano Coelho 已提交
184 185 186 187 188
	__le32 bssid_lsb;
	__le16 bssid_msb;
	__le16 beacon_interval; /* in TBTTs */
	__le32 rx_config_options;
	__le32 rx_filter_options;
L
Luciano Coelho 已提交
189 190 191 192 193 194

	/*
	 * The target uses this field to determine the rate at
	 * which to transmit control frame responses (such as
	 * ACK or CTS frames).
	 */
L
Luciano Coelho 已提交
195
	__le32 basic_rate_set;
L
Luciano Coelho 已提交
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
	u8 dtim_interval;
	/*
	 * bits 0-2: This bitwise field specifies the type
	 * of BSS to start or join (BSS_TYPE_*).
	 * bit 4: Band - The radio band in which to join
	 * or start.
	 *  0 - 2.4GHz band
	 *  1 - 5GHz band
	 * bits 3, 5-7: Reserved
	 */
	u8 bss_type;
	u8 channel;
	u8 ssid_len;
	u8 ssid[IW_ESSID_MAX_SIZE];
	u8 ctrl; /* JOIN_CMD_CTRL_* */
	u8 reserved[3];
212
} __packed;
L
Luciano Coelho 已提交
213 214 215 216 217 218

struct cmd_enabledisable_path {
	struct wl1271_cmd_header header;

	u8 channel;
	u8 padding[3];
219
} __packed;
L
Luciano Coelho 已提交
220

221 222
#define WL1271_RATE_AUTOMATIC  0

L
Luciano Coelho 已提交
223 224 225
struct wl1271_cmd_template_set {
	struct wl1271_cmd_header header;

L
Luciano Coelho 已提交
226
	__le16 len;
L
Luciano Coelho 已提交
227 228
	u8 template_type;
	u8 index;  /* relevant only for KLV_TEMPLATE type */
L
Luciano Coelho 已提交
229
	__le32 enabled_rates;
L
Luciano Coelho 已提交
230 231 232 233 234
	u8 short_retry_limit;
	u8 long_retry_limit;
	u8 aflags;
	u8 reserved;
	u8 template_data[WL1271_CMD_TEMPL_MAX_SIZE];
235
} __packed;
L
Luciano Coelho 已提交
236 237 238 239 240 241 242 243 244 245 246

#define TIM_ELE_ID    5
#define PARTIAL_VBM_MAX    251

struct wl1271_tim {
	u8 identity;
	u8 length;
	u8 dtim_count;
	u8 dtim_period;
	u8 bitmap_ctrl;
	u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
247
} __packed;
L
Luciano Coelho 已提交
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

enum wl1271_cmd_ps_mode {
	STATION_ACTIVE_MODE,
	STATION_POWER_SAVE_MODE
};

struct wl1271_cmd_ps_params {
	struct wl1271_cmd_header header;

	u8 ps_mode; /* STATION_* */
	u8 send_null_data; /* Do we have to send NULL data packet ? */
	u8 retries; /* Number of retires for the initial NULL data packet */

	 /*
	  * TUs during which the target stays awake after switching
	  * to power save mode.
	  */
	u8 hang_over_period;
L
Luciano Coelho 已提交
266
	__le32 null_data_rate;
267
} __packed;
L
Luciano Coelho 已提交
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284

/* HW encryption keys */
#define NUM_ACCESS_CATEGORIES_COPY 4
#define MAX_KEY_SIZE 32

enum wl1271_cmd_key_action {
	KEY_ADD_OR_REPLACE = 1,
	KEY_REMOVE         = 2,
	KEY_SET_ID         = 3,
	MAX_KEY_ACTION     = 0xffff,
};

enum wl1271_cmd_key_type {
	KEY_NONE = 0,
	KEY_WEP  = 1,
	KEY_TKIP = 2,
	KEY_AES  = 3,
285
	KEY_GEM  = 4,
L
Luciano Coelho 已提交
286 287 288 289 290 291 292 293 294 295 296
};

/* FIXME: Add description for key-types */

struct wl1271_cmd_set_keys {
	struct wl1271_cmd_header header;

	/* Ignored for default WEP key */
	u8 addr[ETH_ALEN];

	/* key_action_e */
L
Luciano Coelho 已提交
297
	__le16 key_action;
L
Luciano Coelho 已提交
298

L
Luciano Coelho 已提交
299
	__le16 reserved_1;
L
Luciano Coelho 已提交
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314

	/* key size in bytes */
	u8 key_size;

	/* key_type_e */
	u8 key_type;
	u8 ssid_profile;

	/*
	 * TKIP, AES: frame's key id field.
	 * For WEP default key: key id;
	 */
	u8 id;
	u8 reserved_2[6];
	u8 key[MAX_KEY_SIZE];
L
Luciano Coelho 已提交
315 316
	__le16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
	__le32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
317
} __packed;
L
Luciano Coelho 已提交
318 319 320 321

struct wl1271_cmd_test_header {
	u8 id;
	u8 padding[3];
322
} __packed;
L
Luciano Coelho 已提交
323 324 325 326 327 328 329

enum wl1271_channel_tune_bands {
	WL1271_CHANNEL_TUNE_BAND_2_4,
	WL1271_CHANNEL_TUNE_BAND_5,
	WL1271_CHANNEL_TUNE_BAND_4_9
};

330
#define WL1271_PD_REFERENCE_POINT_BAND_B_G  0
L
Luciano Coelho 已提交
331

332 333 334
#define TEST_CMD_INI_FILE_RADIO_PARAM       0x19
#define TEST_CMD_INI_FILE_GENERAL_PARAM     0x1E
#define TEST_CMD_INI_FILE_RF_EXTENDED_PARAM 0x26
335 336 337 338 339 340

struct wl1271_general_parms_cmd {
	struct wl1271_cmd_header header;

	struct wl1271_cmd_test_header test;

341
	struct wl1271_ini_general_params general_params;
342

343 344 345 346 347 348
	u8 sr_debug_table[WL1271_INI_MAX_SMART_REFLEX_PARAM];
	u8 sr_sen_n_p;
	u8 sr_sen_n_p_gain;
	u8 sr_sen_nrn;
	u8 sr_sen_prn;
	u8 padding[3];
349
} __packed;
350

351 352 353 354 355
struct wl1271_radio_parms_cmd {
	struct wl1271_cmd_header header;

	struct wl1271_cmd_test_header test;

356 357 358
	/* Static radio parameters */
	struct wl1271_ini_band_params_2 static_params_2;
	struct wl1271_ini_band_params_5 static_params_5;
359

360 361 362 363 364
	/* Dynamic radio parameters */
	struct wl1271_ini_fem_params_2 dyn_params_2;
	u8 padding2;
	struct wl1271_ini_fem_params_5 dyn_params_5;
	u8 padding3[2];
365
} __packed;
L
Luciano Coelho 已提交
366

367 368 369 370 371 372 373 374 375 376
struct wl1271_ext_radio_parms_cmd {
	struct wl1271_cmd_header header;

	struct wl1271_cmd_test_header test;

	u8 tx_per_channel_power_compensation_2[CONF_TX_PWR_COMPENSATION_LEN_2];
	u8 tx_per_channel_power_compensation_5[CONF_TX_PWR_COMPENSATION_LEN_5];
	u8 padding[3];
} __packed;

L
Luciano Coelho 已提交
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
/*
 * There are three types of disconnections:
 *
 * DISCONNECT_IMMEDIATE: the fw doesn't send any frames
 * DISCONNECT_DEAUTH:    the fw generates a DEAUTH request with the reason
 *                       we have passed
 * DISCONNECT_DISASSOC:  the fw generates a DESASSOC request with the reason
 *                       we have passed
 */
enum wl1271_disconnect_type {
	DISCONNECT_IMMEDIATE,
	DISCONNECT_DEAUTH,
	DISCONNECT_DISASSOC
};

struct wl1271_cmd_disconnect {
393 394
	struct wl1271_cmd_header header;

L
Luciano Coelho 已提交
395 396
	__le32 rx_config_options;
	__le32 rx_filter_options;
L
Luciano Coelho 已提交
397

L
Luciano Coelho 已提交
398
	__le16 reason;
L
Luciano Coelho 已提交
399 400 401
	u8  type;

	u8  padding;
402
} __packed;
L
Luciano Coelho 已提交
403

404 405 406 407 408 409 410
#define WL1271_CMD_STA_STATE_CONNECTED  1

struct wl1271_cmd_set_sta_state {
	struct wl1271_cmd_header header;

	u8 state;
	u8 padding[3];
411
} __packed;
412

L
Luciano Coelho 已提交
413
#endif /* __WL1271_CMD_H__ */