wl12xx.h 17.0 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) 2008-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 __WL12XX_H__
#define __WL12XX_H__
L
Luciano Coelho 已提交
27 28 29 30 31 32 33 34

#include <linux/mutex.h>
#include <linux/completion.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/bitops.h>
#include <net/mac80211.h>

S
Shahar Levi 已提交
35 36
#include "conf.h"
#include "ini.h"
37

L
Luciano Coelho 已提交
38 39 40
#define DRIVER_NAME "wl1271"
#define DRIVER_PREFIX DRIVER_NAME ": "

L
Levi, Shahar 已提交
41 42 43 44 45 46 47
/*
 * FW versions support BA 11n
 * versions marks x.x.x.50-60.x
 */
#define WL12XX_BA_SUPPORT_FW_COST_VER2_START    50
#define WL12XX_BA_SUPPORT_FW_COST_VER2_END      60

L
Luciano Coelho 已提交
48 49 50 51 52 53
enum {
	DEBUG_NONE	= 0,
	DEBUG_IRQ	= BIT(0),
	DEBUG_SPI	= BIT(1),
	DEBUG_BOOT	= BIT(2),
	DEBUG_MAILBOX	= BIT(3),
K
Kalle Valo 已提交
54
	DEBUG_TESTMODE	= BIT(4),
L
Luciano Coelho 已提交
55 56 57 58 59 60 61 62 63
	DEBUG_EVENT	= BIT(5),
	DEBUG_TX	= BIT(6),
	DEBUG_RX	= BIT(7),
	DEBUG_SCAN	= BIT(8),
	DEBUG_CRYPT	= BIT(9),
	DEBUG_PSM	= BIT(10),
	DEBUG_MAC80211	= BIT(11),
	DEBUG_CMD	= BIT(12),
	DEBUG_ACX	= BIT(13),
T
Teemu Paasikivi 已提交
64
	DEBUG_SDIO	= BIT(14),
65
	DEBUG_FILTERS   = BIT(15),
66
	DEBUG_ADHOC     = BIT(16),
67 68
	DEBUG_AP	= BIT(17),
	DEBUG_MASTER	= (DEBUG_ADHOC | DEBUG_AP),
L
Luciano Coelho 已提交
69 70 71
	DEBUG_ALL	= ~0,
};

72
extern u32 wl12xx_debug_level;
L
Luciano Coelho 已提交
73 74 75 76

#define DEBUG_DUMP_LIMIT 1024

#define wl1271_error(fmt, arg...) \
77
	pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
L
Luciano Coelho 已提交
78 79

#define wl1271_warning(fmt, arg...) \
80
	pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
L
Luciano Coelho 已提交
81 82

#define wl1271_notice(fmt, arg...) \
83
	pr_info(DRIVER_PREFIX fmt "\n", ##arg)
L
Luciano Coelho 已提交
84 85

#define wl1271_info(fmt, arg...) \
86
	pr_info(DRIVER_PREFIX fmt "\n", ##arg)
L
Luciano Coelho 已提交
87 88 89

#define wl1271_debug(level, fmt, arg...) \
	do { \
90 91
		if (level & wl12xx_debug_level) \
			pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \
L
Luciano Coelho 已提交
92 93
	} while (0)

94
/* TODO: use pr_debug_hex_dump when it will be available */
L
Luciano Coelho 已提交
95 96
#define wl1271_dump(level, prefix, buf, len)	\
	do { \
97
		if (level & wl12xx_debug_level) \
L
Luciano Coelho 已提交
98 99 100 101 102 103 104 105 106
			print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
				       DUMP_PREFIX_OFFSET, 16, 1,	\
				       buf,				\
				       min_t(size_t, len, DEBUG_DUMP_LIMIT), \
				       0);				\
	} while (0)

#define wl1271_dump_ascii(level, prefix, buf, len)	\
	do { \
107
		if (level & wl12xx_debug_level) \
L
Luciano Coelho 已提交
108 109 110 111 112 113 114
			print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
				       DUMP_PREFIX_OFFSET, 16, 1,	\
				       buf,				\
				       min_t(size_t, len, DEBUG_DUMP_LIMIT), \
				       true);				\
	} while (0)

115 116
#define WL127X_FW_NAME "ti-connectivity/wl127x-fw-3.bin"
#define WL128X_FW_NAME "ti-connectivity/wl128x-fw-3.bin"
117

118 119 120 121 122 123
/*
 * wl127x and wl128x are using the same NVS file name. However, the
 * ini parameters between them are different.  The driver validates
 * the correct NVS size in wl1271_boot_upload_nvs().
 */
#define WL12XX_NVS_NAME "ti-connectivity/wl1271-nvs.bin"
124

125 126
#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))
#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))
127
#define WL1271_TX_SQN_POST_RECOVERY_PADDING 0xff
128

129 130
#define WL1271_CIPHER_SUITE_GEM 0x00147201

131
#define WL1271_BUSY_WORD_CNT 1
132
#define WL1271_BUSY_WORD_LEN (WL1271_BUSY_WORD_CNT * sizeof(u32))
L
Luciano Coelho 已提交
133 134 135 136

#define WL1271_ELP_HW_STATE_ASLEEP 0
#define WL1271_ELP_HW_STATE_IRQ    1

J
Juuso Oikarinen 已提交
137 138 139
#define WL1271_DEFAULT_BEACON_INT  100
#define WL1271_DEFAULT_DTIM_PERIOD 1

E
Eliad Peller 已提交
140
#define WL12XX_MAX_ROLES           4
141
#define WL12XX_MAX_LINKS           12
E
Eliad Peller 已提交
142 143
#define WL12XX_INVALID_ROLE_ID     0xff
#define WL12XX_INVALID_LINK_ID     0xff
144 145

/* Defined by FW as 0. Will not be freed or allocated. */
E
Eliad Peller 已提交
146
#define WL12XX_SYSTEM_HLID         0
147

148
/*
149
 * When in AP-mode, we allow (at least) this number of packets
150 151 152
 * to be transmitted to FW for a STA in PS-mode. Only when packets are
 * present in the FW buffers it will wake the sleeping STA. We want to put
 * enough packets for the driver to transmit all of its buffered data before
153
 * the STA goes to sleep again. But we don't want to take too much memory
154 155
 * as it might hurt the throughput of active STAs.
 */
156
#define WL1271_PS_STA_MAX_PACKETS  2
157

158 159 160
#define WL1271_AP_BSS_INDEX        0
#define WL1271_AP_DEF_BEACON_EXP   20

E
Eliad Peller 已提交
161
#define ACX_TX_DESCRIPTORS         16
J
Juuso Oikarinen 已提交
162

163 164
#define WL1271_AGGR_BUFFER_SIZE (4 * PAGE_SIZE)

L
Luciano Coelho 已提交
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
enum wl1271_state {
	WL1271_STATE_OFF,
	WL1271_STATE_ON,
	WL1271_STATE_PLT,
};

enum wl1271_partition_type {
	PART_DOWN,
	PART_WORK,
	PART_DRPW,

	PART_TABLE_LEN
};

struct wl1271_partition {
	u32 size;
	u32 start;
};

struct wl1271_partition_set {
	struct wl1271_partition mem;
	struct wl1271_partition reg;
187 188
	struct wl1271_partition mem2;
	struct wl1271_partition mem3;
L
Luciano Coelho 已提交
189 190 191 192
};

struct wl1271;

193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
enum {
	FW_VER_CHIP,
	FW_VER_IF_TYPE,
	FW_VER_MAJOR,
	FW_VER_SUBTYPE,
	FW_VER_MINOR,

	NUM_FW_VER
};

#define FW_VER_CHIP_WL127X 6
#define FW_VER_CHIP_WL128X 7

#define FW_VER_IF_TYPE_STA 1
#define FW_VER_IF_TYPE_AP  2

#define FW_VER_MINOR_1_SPARE_STA_MIN 58
#define FW_VER_MINOR_1_SPARE_AP_MIN  47
L
Levi, Shahar 已提交
211

212 213
#define FW_VER_MINOR_FWLOG_STA_MIN 70

L
Luciano Coelho 已提交
214 215
struct wl1271_chip {
	u32 id;
L
Levi, Shahar 已提交
216
	char fw_ver_str[ETHTOOL_BUSINFO_LEN];
217
	unsigned int fw_ver[NUM_FW_VER];
L
Luciano Coelho 已提交
218 219 220 221 222 223 224 225 226 227 228 229 230
};

struct wl1271_stats {
	struct acx_statistics *fw_stats;
	unsigned long fw_stats_update;

	unsigned int retry_count;
	unsigned int excessive_retries;
};

#define NUM_TX_QUEUES              4
#define NUM_RX_PKT_DESC            8

231
#define AP_MAX_STATIONS            8
232

E
Eliad Peller 已提交
233 234
/* FW status registers */
struct wl12xx_fw_status {
L
Luciano Coelho 已提交
235
	__le32 intr;
L
Luciano Coelho 已提交
236 237 238 239
	u8  fw_rx_counter;
	u8  drv_rx_counter;
	u8  reserved;
	u8  tx_results_counter;
L
Luciano Coelho 已提交
240 241
	__le32 rx_pkt_descs[NUM_RX_PKT_DESC];
	__le32 fw_localtime;
242 243 244 245 246 247 248

	/*
	 * A bitmap (where each bit represents a single HLID)
	 * to indicate if the station is in PS mode.
	 */
	__le32 link_ps_bitmap;

E
Eliad Peller 已提交
249 250 251 252 253
	/*
	 * A bitmap (where each bit represents a single HLID) to indicate
	 * if the station is in Fast mode
	 */
	__le32 link_fast_bitmap;
L
Luciano Coelho 已提交
254

E
Eliad Peller 已提交
255 256
	/* Cumulative counter of total released mem blocks since FW-reset */
	__le32 total_released_blks;
257

E
Eliad Peller 已提交
258 259
	/* Size (in Memory Blocks) of TX pool */
	__le32 tx_total;
260

261 262
	/* Cumulative counter of released packets per AC */
	u8 tx_released_pkts[NUM_TX_QUEUES];
263

264 265
	/* Cumulative counter of freed packets per HLID */
	u8 tx_lnk_free_pkts[WL12XX_MAX_LINKS];
E
Eliad Peller 已提交
266 267 268

	/* Cumulative counter of released Voice memory blocks */
	u8 tx_voice_released_blks;
269
	u8 padding_1[3];
E
Eliad Peller 已提交
270 271
	__le32 log_start_addr;
} __packed;
272

L
Luciano Coelho 已提交
273 274 275 276 277
struct wl1271_rx_mem_pool_addr {
	u32 addr;
	u32 addr_extra;
};

278
#define WL1271_MAX_CHANNELS 64
279
struct wl1271_scan {
280
	struct cfg80211_scan_request *req;
281
	unsigned long scanned_ch[BITS_TO_LONGS(WL1271_MAX_CHANNELS)];
282
	bool failed;
283
	u8 state;
J
Johannes Berg 已提交
284
	u8 ssid[IEEE80211_MAX_SSID_LEN+1];
285 286 287
	size_t ssid_len;
};

288 289 290 291 292 293 294
struct wl1271_if_operations {
	void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len,
		     bool fixed);
	void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len,
		     bool fixed);
	void (*reset)(struct wl1271 *wl);
	void (*init)(struct wl1271 *wl);
295
	int (*power)(struct wl1271 *wl, bool enable);
296 297 298
	struct device* (*dev)(struct wl1271 *wl);
	void (*enable_irq)(struct wl1271 *wl);
	void (*disable_irq)(struct wl1271 *wl);
299
	void (*set_block_size) (struct wl1271 *wl, unsigned int blksz);
300 301
};

302 303 304 305 306 307 308 309 310 311 312 313 314
#define MAX_NUM_KEYS 14
#define MAX_KEY_SIZE 32

struct wl1271_ap_key {
	u8 id;
	u8 key_type;
	u8 key_size;
	u8 key[MAX_KEY_SIZE];
	u8 hlid;
	u32 tx_seq_32;
	u16 tx_seq_16;
};

315 316 317
enum wl12xx_flags {
	WL1271_FLAG_GPIO_POWER,
	WL1271_FLAG_TX_QUEUE_STOPPED,
I
Ido Yariv 已提交
318
	WL1271_FLAG_TX_PENDING,
319
	WL1271_FLAG_IN_ELP,
320
	WL1271_FLAG_ELP_REQUESTED,
321 322 323 324 325 326 327
	WL1271_FLAG_PSM,
	WL1271_FLAG_PSM_REQUESTED,
	WL1271_FLAG_IRQ_RUNNING,
	WL1271_FLAG_IDLE,
	WL1271_FLAG_PSPOLL_FAILURE,
	WL1271_FLAG_STA_STATE_SENT,
	WL1271_FLAG_FW_TX_BUSY,
328
	WL1271_FLAG_IF_INITIALIZED,
329
	WL1271_FLAG_DUMMY_PACKET_PENDING,
330 331
	WL1271_FLAG_SUSPENDED,
	WL1271_FLAG_PENDING_WORK,
332 333
	WL1271_FLAG_SOFT_GEMINI,
	WL1271_FLAG_RX_STREAMING_STARTED,
334
	WL1271_FLAG_RECOVERY_IN_PROGRESS,
335
	WL1271_FLAG_CS_PROGRESS,
336 337
};

338 339
enum wl12xx_vif_flags {
	WLVIF_FLAG_STA_ASSOCIATED,
340
	WLVIF_FLAG_IBSS_JOINED,
341
	WLVIF_FLAG_AP_STARTED,
342 343
};

344 345 346
struct wl1271_link {
	/* AP-mode - TX queue per AC in link */
	struct sk_buff_head tx_queue[NUM_TX_QUEUES];
347

348 349 350
	/* accounting for allocated / freed packets in FW */
	u8 allocated_pkts;
	u8 prev_freed_pkts;
351 352

	u8 addr[ETH_ALEN];
353 354 355

	/* bitmap of TIDs where RX BA sessions are active for this link */
	u8 ba_bitmap;
356 357
};

L
Luciano Coelho 已提交
358
struct wl1271 {
359
	struct platform_device *plat_dev;
L
Luciano Coelho 已提交
360 361 362
	struct ieee80211_hw *hw;
	bool mac80211_registered;

363 364 365
	void *if_priv;

	struct wl1271_if_operations *if_ops;
L
Luciano Coelho 已提交
366 367 368

	void (*set_power)(bool enable);
	int irq;
369
	int ref_clock;
L
Luciano Coelho 已提交
370 371 372 373 374 375

	spinlock_t wl_lock;

	enum wl1271_state state;
	struct mutex mutex;

376 377
	unsigned long flags;

378
	struct wl1271_partition_set part;
L
Luciano Coelho 已提交
379 380 381 382 383 384 385 386

	struct wl1271_chip chip;

	int cmd_box_addr;
	int event_box_addr;

	u8 *fw;
	size_t fw_len;
387
	void *nvs;
388
	size_t nvs_len;
L
Luciano Coelho 已提交
389

390 391
	s8 hw_pg_ver;

L
Luciano Coelho 已提交
392 393
	u8 mac_addr[ETH_ALEN];
	int channel;
E
Eliad Peller 已提交
394
	u8 system_hlid;
E
Eliad Peller 已提交
395 396 397

	unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)];
	unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)];
398
	unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)];
L
Luciano Coelho 已提交
399

E
Eliad Peller 已提交
400
	struct list_head wlvif_list;
401 402
	u8 sta_count;
	u8 ap_count;
E
Eliad Peller 已提交
403

L
Luciano Coelho 已提交
404 405 406
	struct wl1271_acx_mem_map *target_mem_map;

	/* Accounting for allocated / available TX blocks on HW */
E
Eliad Peller 已提交
407
	u32 tx_blocks_freed;
L
Luciano Coelho 已提交
408
	u32 tx_blocks_available;
409
	u32 tx_allocated_blocks;
410
	u32 tx_results_count;
L
Luciano Coelho 已提交
411

412 413 414
	/* amount of spare TX blocks to use */
	u32 tx_spare_blocks;

415 416
	/* Accounting for allocated / available Tx packets in HW */
	u32 tx_pkts_freed[NUM_TX_QUEUES];
417
	u32 tx_allocated_pkts[NUM_TX_QUEUES];
418

L
Luciano Coelho 已提交
419
	/* Transmitted TX packets counter for chipset interface */
420
	u32 tx_packets_count;
L
Luciano Coelho 已提交
421 422

	/* Time-offset between host and chipset clocks */
423
	s64 time_offset;
L
Luciano Coelho 已提交
424 425

	/* Frames scheduled for transmission, not handled yet */
426
	int tx_queue_count[NUM_TX_QUEUES];
427
	long stopped_queues_map;
L
Luciano Coelho 已提交
428

429 430 431 432 433 434
	/* Frames received, not handled yet by mac80211 */
	struct sk_buff_head deferred_rx_queue;

	/* Frames sent, not returned yet to mac80211 */
	struct sk_buff_head deferred_tx_queue;

L
Luciano Coelho 已提交
435
	struct work_struct tx_work;
436
	struct workqueue_struct *freezable_wq;
437

L
Luciano Coelho 已提交
438
	/* Pending TX frames */
439
	unsigned long tx_frames_map[BITS_TO_LONGS(ACX_TX_DESCRIPTORS)];
J
Juuso Oikarinen 已提交
440
	struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS];
441
	int tx_frames_cnt;
L
Luciano Coelho 已提交
442 443 444 445 446 447 448

	/* FW Rx counter */
	u32 rx_counter;

	/* Rx memory pool address */
	struct wl1271_rx_mem_pool_addr rx_mem_pool_addr;

449 450 451
	/* Intermediate buffer, used for packet aggregation */
	u8 *aggr_buf;

452 453 454
	/* Reusable dummy packet template */
	struct sk_buff *dummy_packet;

455 456
	/* Network stack work  */
	struct work_struct netstack_work;
L
Luciano Coelho 已提交
457

458 459 460 461 462 463 464 465 466
	/* FW log buffer */
	u8 *fwlog;

	/* Number of valid bytes in the FW log buffer */
	ssize_t fwlog_size;

	/* Sysfs FW log entry readers wait queue */
	wait_queue_head_t fwlog_waitq;

467 468 469
	/* Hardware recovery work */
	struct work_struct recovery_work;

L
Luciano Coelho 已提交
470 471 472 473 474 475 476
	/* The mbox event mask */
	u32 event_mask;

	/* Mailbox pointers */
	u32 mbox_ptr[2];

	/* Are we currently scanning */
477
	struct ieee80211_vif *scan_vif;
478
	struct wl1271_scan scan;
479
	struct delayed_work scan_complete_work;
L
Luciano Coelho 已提交
480

481 482
	bool sched_scanning;

483 484 485
	/* The current band */
	enum ieee80211_band band;

L
Luciano Coelho 已提交
486
	struct completion *elp_compl;
487
	struct delayed_work elp_work;
488

L
Luciano Coelho 已提交
489 490 491 492 493
	/* in dBm */
	int power_level;

	struct wl1271_stats stats;

494
	__le32 buffer_32;
L
Luciano Coelho 已提交
495
	u32 buffer_cmd;
496
	u32 buffer_busyword[WL1271_BUSY_WORD_CNT];
L
Luciano Coelho 已提交
497

E
Eliad Peller 已提交
498
	struct wl12xx_fw_status *fw_status;
L
Luciano Coelho 已提交
499
	struct wl1271_tx_hw_res_if *tx_res_if;
500 501

	struct ieee80211_vif *vif;
502

503 504
	/* Current chipset configuration */
	struct conf_drv_settings conf;
505

506 507
	bool sg_enabled;

508 509
	bool enable_11a;

510
	struct list_head list;
511 512 513

	/* Most recently reported noise in dBm */
	s8 noise;
514

515 516
	/* bands supported by this instance of wl12xx */
	struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
L
Levi, Shahar 已提交
517

518
	int tcxo_clock;
519

520 521 522 523 524
	/*
	 * wowlan trigger was configured during suspend.
	 * (currently, only "ANY" trigger is supported)
	 */
	bool wow_enabled;
525
	bool irq_wake_enabled;
526

527 528 529 530
	/*
	 * AP-mode - links indexed by HLID. The global and broadcast links
	 * are always active.
	 */
531
	struct wl1271_link links[WL12XX_MAX_LINKS];
532

533 534 535 536 537
	/* AP-mode - a bitmap of links currently in PS mode according to FW */
	u32 ap_fw_ps_map;

	/* AP-mode - a bitmap of links currently in PS mode in mac80211 */
	unsigned long ap_ps_map;
538 539 540

	/* Quirks of specific hardware revisions */
	unsigned int quirks;
541 542 543

	/* Platform limitations */
	unsigned int platform_quirks;
544 545 546

	/* number of currently active RX BA sessions */
	int ba_rx_session_count;
547 548 549

	/* AP-mode - number of currently connected stations */
	int active_sta_count;
550 551 552 553
};

struct wl1271_station {
	u8 hlid;
L
Luciano Coelho 已提交
554 555
};

E
Eliad Peller 已提交
556
struct wl12xx_vif {
E
Eliad Peller 已提交
557
	struct wl1271 *wl;
E
Eliad Peller 已提交
558
	struct list_head list;
559
	unsigned long flags;
E
Eliad Peller 已提交
560
	u8 bss_type;
E
Eliad Peller 已提交
561
	u8 p2p; /* we are using p2p role */
E
Eliad Peller 已提交
562
	u8 role_id;
E
Eliad Peller 已提交
563

E
Eliad Peller 已提交
564 565
	/* sta/ibss specific */
	u8 dev_role_id;
E
Eliad Peller 已提交
566
	u8 dev_hlid;
E
Eliad Peller 已提交
567

E
Eliad Peller 已提交
568 569 570
	union {
		struct {
			u8 hlid;
E
Eliad Peller 已提交
571
			u8 ba_rx_bitmap;
E
Eliad Peller 已提交
572
		} sta;
573 574 575
		struct {
			u8 global_hlid;
			u8 bcast_hlid;
576 577 578 579

			/* HLIDs bitmap of associated stations */
			unsigned long sta_hlid_map[BITS_TO_LONGS(
							WL12XX_MAX_LINKS)];
580 581 582

			/* recoreded keys - set here before AP startup */
			struct wl1271_ap_key *recorded_keys[MAX_NUM_KEYS];
583
		} ap;
E
Eliad Peller 已提交
584 585
	};

586 587 588
	/* the hlid of the last transmitted skb */
	int last_tx_hlid;

589 590
	unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)];

591 592 593
	u8 ssid[IEEE80211_MAX_SSID_LEN + 1];
	u8 ssid_len;

594
	u32 bitrate_masks[IEEE80211_NUM_BANDS];
E
Eliad Peller 已提交
595
	u32 basic_rate_set;
E
Eliad Peller 已提交
596 597 598 599 600 601 602

	/*
	 * currently configured rate set:
	 *	bits  0-15 - 802.11abg rates
	 *	bits 16-23 - 802.11n   MCS index mask
	 * support only 1 stream, thus only 8 bits for the MCS rates (0-7).
	 */
E
Eliad Peller 已提交
603
	u32 basic_rate;
E
Eliad Peller 已提交
604
	u32 rate_set;
E
Eliad Peller 已提交
605 606 607

	/* probe-req template for the current AP */
	struct sk_buff *probereq;
E
Eliad Peller 已提交
608

E
Eliad Peller 已提交
609 610 611
	/* Beaconing interval (needed for ad-hoc) */
	u32 beacon_int;

E
Eliad Peller 已提交
612 613 614
	/* Default key (for WEP) */
	u32 default_key;

E
Eliad Peller 已提交
615 616
	/* Our association ID */
	u16 aid;
617 618 619

	/* Session counter for the chipset */
	int session_counter;
E
Eliad Peller 已提交
620

E
Eliad Peller 已提交
621
	struct completion *ps_compl;
E
Eliad Peller 已提交
622
	struct delayed_work pspoll_work;
623 624 625 626 627 628

	/* counter for ps-poll delivery failures */
	int ps_poll_failures;

	/* retry counter for PSM entries */
	u8 psm_entry_retry;
629 630 631

	int rssi_thold;
	int last_rssi_event;
E
Eliad Peller 已提交
632 633 634 635

	/* RX BA constraint value */
	bool ba_support;
	bool ba_allowed;
636

E
Eliad Peller 已提交
637 638 639 640 641
	/* Rx Streaming */
	struct work_struct rx_streaming_enable_work;
	struct work_struct rx_streaming_disable_work;
	struct timer_list rx_streaming_timer;

642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
	/*
	 * This struct must be last!
	 * data that has to be saved acrossed reconfigs (e.g. recovery)
	 * should be declared in this struct.
	 */
	struct {
		u8 persistent[0];
		/*
		 * Security sequence number
		 *     bits 0-15: lower 16 bits part of sequence number
		 *     bits 16-47: higher 32 bits part of sequence number
		 *     bits 48-63: not in use
		 */
		u64 tx_security_seq;

		/* 8 bits of the last sequence number in use */
		u8 tx_security_last_seq_lsb;
	};
E
Eliad Peller 已提交
660 661 662 663 664 665 666 667 668 669 670 671 672
};

static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif)
{
	return (struct wl12xx_vif *)vif->drv_priv;
}

static inline
struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif)
{
	return container_of((void *)wlvif, struct ieee80211_vif, drv_priv);
}

E
Eliad Peller 已提交
673 674 675
#define wl12xx_for_each_wlvif(wl, wlvif) \
		list_for_each_entry(wlvif, &wl->wlvif_list, list)

676 677 678 679 680 681 682 683 684 685
#define wl12xx_for_each_wlvif_bss_type(wl, wlvif, _bss_type)	\
		wl12xx_for_each_wlvif(wl, wlvif)		\
			if (wlvif->bss_type == _bss_type)

#define wl12xx_for_each_wlvif_sta(wl, wlvif)	\
		wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_STA_BSS)

#define wl12xx_for_each_wlvif_ap(wl, wlvif)	\
		wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_AP_BSS)

L
Luciano Coelho 已提交
686 687
int wl1271_plt_start(struct wl1271 *wl);
int wl1271_plt_stop(struct wl1271 *wl);
E
Eliad Peller 已提交
688
int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif);
689
void wl12xx_queue_recovery_work(struct wl1271 *wl);
690
size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
L
Luciano Coelho 已提交
691 692 693

#define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */

694 695
#define SESSION_COUNTER_MAX 6 /* maximum value for the session counter */
#define SESSION_COUNTER_INVALID 7 /* used with dummy_packet */
L
Luciano Coelho 已提交
696 697 698

#define WL1271_DEFAULT_POWER_LEVEL 0

699 700
#define WL1271_TX_QUEUE_LOW_WATERMARK  32
#define WL1271_TX_QUEUE_HIGH_WATERMARK 256
L
Luciano Coelho 已提交
701

702 703
#define WL1271_DEFERRED_QUEUE_LIMIT    64

J
Juuso Oikarinen 已提交
704 705
/* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power
   on in case is has been shut down shortly before */
S
Stefan Weil 已提交
706 707
#define WL1271_PRE_POWER_ON_SLEEP 20 /* in milliseconds */
#define WL1271_POWER_ON_SLEEP 200 /* in milliseconds */
L
Luciano Coelho 已提交
708

S
Shahar Levi 已提交
709 710 711 712
/* Macros to handle wl1271.sta_rate_set */
#define HW_BG_RATES_MASK	0xffff
#define HW_HT_RATES_OFFSET	16

713 714 715
/* Quirks */

/* Each RX/TX transaction requires an end-of-transaction transfer */
716
#define WL12XX_QUIRK_END_OF_TRANSACTION		BIT(0)
717

718 719
/* WL128X requires aggregated packets to be aligned to the SDIO block size */
#define WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT	BIT(2)
720

721 722 723 724 725
/* Older firmwares did not implement the FW logger over bus feature */
#define WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED	BIT(4)

#define WL12XX_HW_BLOCK_SIZE	256

L
Luciano Coelho 已提交
726
#endif