blob: 14fd1111cfd6b943174f6b73e2fb8a258e0755b3 [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) 2008-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
Luciano Coelho83885692012-05-10 12:13:42 +030025#ifndef __WLCORE_I_H__
26#define __WLCORE_I_H__
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030027
28#include <linux/mutex.h>
29#include <linux/completion.h>
30#include <linux/spinlock.h>
31#include <linux/list.h>
32#include <linux/bitops.h>
33#include <net/mac80211.h>
34
Shahar Levi00d20102010-11-08 11:20:10 +000035#include "conf.h"
36#include "ini.h"
Juuso Oikarinen2b60100b2009-10-13 12:47:39 +030037
Shahar Levi5aa42342011-03-06 16:32:07 +020038/*
39 * wl127x and wl128x are using the same NVS file name. However, the
40 * ini parameters between them are different. The driver validates
41 * the correct NVS size in wl1271_boot_upload_nvs().
42 */
43#define WL12XX_NVS_NAME "ti-connectivity/wl1271-nvs.bin"
Juuso Oikarinen152ee6e2010-02-18 13:25:42 +020044
Juuso Oikarinen04e36fc2010-02-22 08:38:40 +020045#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))
46#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))
Oz Krakowskib992c682011-06-26 10:36:02 +030047#define WL1271_TX_SQN_POST_RECOVERY_PADDING 0xff
Juuso Oikarinen04e36fc2010-02-22 08:38:40 +020048
Juuso Oikarinen7a557242010-09-27 12:42:07 +020049#define WL1271_CIPHER_SUITE_GEM 0x00147201
50
Juuso Oikarinen259da432010-03-26 12:53:18 +020051#define WL1271_BUSY_WORD_CNT 1
Juuso Oikarinen545f1da2009-10-08 21:56:23 +030052#define WL1271_BUSY_WORD_LEN (WL1271_BUSY_WORD_CNT * sizeof(u32))
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030053
54#define WL1271_ELP_HW_STATE_ASLEEP 0
55#define WL1271_ELP_HW_STATE_IRQ 1
56
Juuso Oikarinend94cd292009-10-08 21:56:25 +030057#define WL1271_DEFAULT_BEACON_INT 100
58#define WL1271_DEFAULT_DTIM_PERIOD 1
59
Eliad Pellerc690ec82011-08-14 13:17:07 +030060#define WL12XX_MAX_ROLES 4
Arik Nemtsovf80c2d12011-09-22 09:52:05 +030061#define WL12XX_MAX_LINKS 12
Eliad Peller7f0979882011-08-14 13:17:06 +030062#define WL12XX_INVALID_ROLE_ID 0xff
63#define WL12XX_INVALID_LINK_ID 0xff
Arik Nemtsove51ae9b2011-08-14 13:17:21 +030064
Arik Nemtsov091185d2012-07-03 09:11:03 +030065/* the driver supports the 2.4Ghz and 5Ghz bands */
66#define WLCORE_NUM_BANDS 2
67
Eliad Pellere5a359f2011-10-10 10:13:15 +020068#define WL12XX_MAX_RATE_POLICIES 16
Eliad Peller001e39a2012-08-16 13:52:47 +030069#define WLCORE_MAX_KLV_TEMPLATES 4
Eliad Pellere5a359f2011-10-10 10:13:15 +020070
Arik Nemtsove51ae9b2011-08-14 13:17:21 +030071/* Defined by FW as 0. Will not be freed or allocated. */
Eliad Pellerf4df1bd2011-08-14 13:17:15 +030072#define WL12XX_SYSTEM_HLID 0
Arik Nemtsove51ae9b2011-08-14 13:17:21 +030073
74/*
Arik Nemtsov9b17f1b2011-08-14 13:17:35 +030075 * When in AP-mode, we allow (at least) this number of packets
Arik Nemtsovb622d992011-02-23 00:22:31 +020076 * to be transmitted to FW for a STA in PS-mode. Only when packets are
77 * present in the FW buffers it will wake the sleeping STA. We want to put
78 * enough packets for the driver to transmit all of its buffered data before
Arik Nemtsov9b17f1b2011-08-14 13:17:35 +030079 * the STA goes to sleep again. But we don't want to take too much memory
Arik Nemtsovb622d992011-02-23 00:22:31 +020080 * as it might hurt the throughput of active STAs.
Arik Nemtsovb622d992011-02-23 00:22:31 +020081 */
Arik Nemtsov9b17f1b2011-08-14 13:17:35 +030082#define WL1271_PS_STA_MAX_PACKETS 2
Arik Nemtsovb622d992011-02-23 00:22:31 +020083
Arik Nemtsov98bdaab2010-10-16 18:08:58 +020084#define WL1271_AP_BSS_INDEX 0
Arik Nemtsov98bdaab2010-10-16 18:08:58 +020085#define WL1271_AP_DEF_BEACON_EXP 20
86
Ido Yariv4cc53382012-07-24 19:18:49 +030087enum wlcore_state {
88 WLCORE_STATE_OFF,
89 WLCORE_STATE_RESTARTING,
90 WLCORE_STATE_ON,
Eliad Peller3fcdab72012-02-06 12:47:54 +020091};
92
93enum wl12xx_fw_type {
94 WL12XX_FW_TYPE_NONE,
95 WL12XX_FW_TYPE_NORMAL,
Eliad Peller4549d092012-02-06 13:07:52 +020096 WL12XX_FW_TYPE_MULTI,
Eliad Peller3fcdab72012-02-06 12:47:54 +020097 WL12XX_FW_TYPE_PLT,
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030098};
99
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300100struct wl1271;
101
Luciano Coelhoe7ddf542011-03-10 15:24:57 +0200102enum {
103 FW_VER_CHIP,
104 FW_VER_IF_TYPE,
105 FW_VER_MAJOR,
106 FW_VER_SUBTYPE,
107 FW_VER_MINOR,
Levi, Shahar4b7fac72011-01-23 07:27:22 +0100108
Luciano Coelhoe7ddf542011-03-10 15:24:57 +0200109 NUM_FW_VER
110};
111
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300112struct wl1271_chip {
113 u32 id;
Jiri Pirko81135542013-01-06 02:12:51 +0000114 char fw_ver_str[ETHTOOL_FWVERS_LEN];
Luciano Coelhoe7ddf542011-03-10 15:24:57 +0200115 unsigned int fw_ver[NUM_FW_VER];
Jiri Pirko81135542013-01-06 02:12:51 +0000116 char phy_fw_ver_str[ETHTOOL_FWVERS_LEN];
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300117};
118
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300119#define NUM_TX_QUEUES 4
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300120
Arik Nemtsovc47e8222011-08-25 12:43:14 +0300121#define AP_MAX_STATIONS 8
Arik Nemtsovbeb6c882010-10-16 18:53:48 +0200122
Arik Nemtsov6bac40a2011-12-12 12:08:25 +0200123struct wl_fw_packet_counters {
124 /* Cumulative counter of released packets per AC */
125 u8 tx_released_pkts[NUM_TX_QUEUES];
126
127 /* Cumulative counter of freed packets per HLID */
128 u8 tx_lnk_free_pkts[WL12XX_MAX_LINKS];
129
130 /* Cumulative counter of released Voice memory blocks */
131 u8 tx_voice_released_blks;
132
Arik Nemtsov4d703842012-11-30 00:46:48 +0200133 /* Tx rate of the last transmitted packet */
134 u8 tx_last_rate;
135
136 u8 padding[2];
Arik Nemtsov6bac40a2011-12-12 12:08:25 +0200137} __packed;
138
Eliad Peller4d56ad92011-08-14 13:17:05 +0300139/* FW status registers */
Arik Nemtsov0afd04e2012-05-10 12:13:54 +0300140struct wl_fw_status_1 {
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300141 __le32 intr;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300142 u8 fw_rx_counter;
143 u8 drv_rx_counter;
144 u8 reserved;
145 u8 tx_results_counter;
Arik Nemtsov0afd04e2012-05-10 12:13:54 +0300146 __le32 rx_pkt_descs[0];
147} __packed;
148
149/*
150 * Each HW arch has a different number of Rx descriptors.
151 * The length of the status depends on it, since it holds an array
152 * of descriptors.
153 */
154#define WLCORE_FW_STATUS_1_LEN(num_rx_desc) \
155 (sizeof(struct wl_fw_status_1) + \
156 (sizeof(((struct wl_fw_status_1 *)0)->rx_pkt_descs[0])) * \
157 num_rx_desc)
158
159struct wl_fw_status_2 {
Luciano Coelhod0f63b22009-10-15 10:33:29 +0300160 __le32 fw_localtime;
Arik Nemtsovbeb6c882010-10-16 18:53:48 +0200161
162 /*
163 * A bitmap (where each bit represents a single HLID)
164 * to indicate if the station is in PS mode.
165 */
166 __le32 link_ps_bitmap;
167
Eliad Peller4d56ad92011-08-14 13:17:05 +0300168 /*
169 * A bitmap (where each bit represents a single HLID) to indicate
170 * if the station is in Fast mode
171 */
172 __le32 link_fast_bitmap;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300173
Eliad Peller4d56ad92011-08-14 13:17:05 +0300174 /* Cumulative counter of total released mem blocks since FW-reset */
175 __le32 total_released_blks;
Eliad Pellerc8bde242011-02-02 09:59:35 +0200176
Eliad Peller4d56ad92011-08-14 13:17:05 +0300177 /* Size (in Memory Blocks) of TX pool */
178 __le32 tx_total;
179
Arik Nemtsov6bac40a2011-12-12 12:08:25 +0200180 struct wl_fw_packet_counters counters;
Eliad Peller4d56ad92011-08-14 13:17:05 +0300181
Ido Yariv95dac04f2011-06-06 14:57:06 +0300182 __le32 log_start_addr;
Arik Nemtsov6bac40a2011-12-12 12:08:25 +0200183
184 /* Private status to be used by the lower drivers */
185 u8 priv[0];
Eliad Pellerc8bde242011-02-02 09:59:35 +0200186} __packed;
187
Luciano Coelho4a31c112011-03-21 23:16:14 +0200188#define WL1271_MAX_CHANNELS 64
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300189struct wl1271_scan {
Juuso Oikarinen4fb26fa2010-05-24 11:18:20 +0300190 struct cfg80211_scan_request *req;
Luciano Coelho4a31c112011-03-21 23:16:14 +0200191 unsigned long scanned_ch[BITS_TO_LONGS(WL1271_MAX_CHANNELS)];
Juuso Oikarinen78abd322010-09-21 06:23:32 +0200192 bool failed;
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300193 u8 state;
Johannes Berg3b40c042011-07-13 10:39:16 +0200194 u8 ssid[IEEE80211_MAX_SSID_LEN+1];
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300195 size_t ssid_len;
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +0300196};
197
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200198struct wl1271_if_operations {
Ido Yarivf1a26e62012-06-20 00:03:46 +0300199 int __must_check (*read)(struct device *child, int addr, void *buf,
200 size_t len, bool fixed);
201 int __must_check (*write)(struct device *child, int addr, void *buf,
202 size_t len, bool fixed);
Felipe Balbia390e852011-10-06 10:07:44 +0300203 void (*reset)(struct device *child);
204 void (*init)(struct device *child);
205 int (*power)(struct device *child, bool enable);
206 void (*set_block_size) (struct device *child, unsigned int blksz);
Teemu Paasikivi8197b712010-02-22 08:38:23 +0200207};
208
Luciano Coelhoafb43e62013-01-25 11:57:48 +0200209struct wlcore_platdev_data {
210 struct wl12xx_platform_data *pdata;
211 struct wl1271_if_operations *if_ops;
212};
213
Arik Nemtsov7f179b42010-10-16 21:39:06 +0200214#define MAX_NUM_KEYS 14
215#define MAX_KEY_SIZE 32
216
217struct wl1271_ap_key {
218 u8 id;
219 u8 key_type;
220 u8 key_size;
221 u8 key[MAX_KEY_SIZE];
222 u8 hlid;
223 u32 tx_seq_32;
224 u16 tx_seq_16;
225};
226
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200227enum wl12xx_flags {
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200228 WL1271_FLAG_GPIO_POWER,
229 WL1271_FLAG_TX_QUEUE_STOPPED,
Ido Yarivb07d4032011-03-01 15:14:43 +0200230 WL1271_FLAG_TX_PENDING,
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200231 WL1271_FLAG_IN_ELP,
Eliad Pellera665d6e2011-04-03 02:01:59 +0300232 WL1271_FLAG_ELP_REQUESTED,
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200233 WL1271_FLAG_IRQ_RUNNING,
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200234 WL1271_FLAG_FW_TX_BUSY,
Ido Yariv990f5de2011-03-31 10:06:59 +0200235 WL1271_FLAG_DUMMY_PACKET_PENDING,
Eliad Pellerf44e5862011-05-13 11:57:11 +0300236 WL1271_FLAG_SUSPENDED,
237 WL1271_FLAG_PENDING_WORK,
Eliad Peller77ddaa12011-05-15 11:10:29 +0300238 WL1271_FLAG_SOFT_GEMINI,
Ido Yarivbaacb9ae2011-06-06 14:57:05 +0300239 WL1271_FLAG_RECOVERY_IN_PROGRESS,
Eliad Peller4549d092012-02-06 13:07:52 +0200240 WL1271_FLAG_VIF_CHANGE_IN_PROGRESS,
Eliad Pellere9ba7152012-03-04 10:55:54 +0200241 WL1271_FLAG_INTENDED_FW_RECOVERY,
Arik Nemtsov44555562012-07-03 09:00:18 +0300242 WL1271_FLAG_IO_FAILED,
Eliad Peller72c2d9e2011-02-02 09:59:37 +0200243};
244
Eliad Pellerba8447f2011-10-10 10:13:00 +0200245enum wl12xx_vif_flags {
Eliad Peller10c8cd02011-10-10 10:13:06 +0200246 WLVIF_FLAG_INITIALIZED,
Eliad Pellerba8447f2011-10-10 10:13:00 +0200247 WLVIF_FLAG_STA_ASSOCIATED,
Eliad Peller9fd6f212012-03-04 10:55:48 +0200248 WLVIF_FLAG_STA_AUTHORIZED,
Eliad Pellereee514e2011-10-10 10:13:01 +0200249 WLVIF_FLAG_IBSS_JOINED,
Eliad Peller53d40d02011-10-10 10:13:02 +0200250 WLVIF_FLAG_AP_STARTED,
Eyal Shapira5c0dc2f2012-02-02 19:06:45 +0200251 WLVIF_FLAG_IN_PS,
Eliad Peller8181aec2011-10-10 10:13:04 +0200252 WLVIF_FLAG_STA_STATE_SENT,
Eliad Peller0744bdb2011-10-10 10:13:05 +0200253 WLVIF_FLAG_RX_STREAMING_STARTED,
Eliad Peller836d6602011-10-10 10:13:07 +0200254 WLVIF_FLAG_PSPOLL_FAILURE,
Eliad Peller52630c52011-10-10 10:13:08 +0200255 WLVIF_FLAG_CS_PROGRESS,
Arik Nemtsov560f002412011-11-08 18:46:54 +0200256 WLVIF_FLAG_AP_PROBE_RESP_SET,
Eliad Pellera0c7b782011-12-18 20:25:41 +0200257 WLVIF_FLAG_IN_USE,
Eliad Pellerba8447f2011-10-10 10:13:00 +0200258};
259
Arik Nemtsov1e0708a2012-11-27 08:44:57 +0200260struct wl12xx_vif;
261
Arik Nemtsova8c0ddb2011-02-23 00:22:26 +0200262struct wl1271_link {
263 /* AP-mode - TX queue per AC in link */
264 struct sk_buff_head tx_queue[NUM_TX_QUEUES];
Arik Nemtsov09039f42011-02-23 00:22:30 +0200265
Arik Nemtsov9b17f1b2011-08-14 13:17:35 +0300266 /* accounting for allocated / freed packets in FW */
267 u8 allocated_pkts;
268 u8 prev_freed_pkts;
Arik Nemtsovb622d992011-02-23 00:22:31 +0200269
270 u8 addr[ETH_ALEN];
Arik Nemtsov0f9c8252011-08-17 10:45:49 +0300271
272 /* bitmap of TIDs where RX BA sessions are active for this link */
273 u8 ba_bitmap;
Arik Nemtsov1e0708a2012-11-27 08:44:57 +0200274
275 /* The wlvif this link belongs to. Might be null for global links */
276 struct wl12xx_vif *wlvif;
Arik Nemtsov93d5d102013-03-12 17:19:38 +0200277
278 /*
279 * total freed FW packets on the link - used for tracking the
280 * AES/TKIP PN across recoveries. Re-initialized each time
281 * from the wl1271_station structure.
282 */
283 u64 total_freed_pkts;
Arik Nemtsova8c0ddb2011-02-23 00:22:26 +0200284};
285
Eyal Shapirac21eebb2012-03-14 06:32:08 +0200286#define WL1271_MAX_RX_FILTERS 5
Eyal Shapiraa6eab0c2012-03-14 06:32:07 +0200287#define WL1271_RX_FILTER_MAX_FIELDS 8
Eyal Shapirab95d7ce2012-03-14 06:32:10 +0200288
289#define WL1271_RX_FILTER_ETH_HEADER_SIZE 14
290#define WL1271_RX_FILTER_MAX_FIELDS_SIZE 95
291#define RX_FILTER_FIELD_OVERHEAD \
292 (sizeof(struct wl12xx_rx_filter_field) - sizeof(u8 *))
293#define WL1271_RX_FILTER_MAX_PATTERN_SIZE \
294 (WL1271_RX_FILTER_MAX_FIELDS_SIZE - RX_FILTER_FIELD_OVERHEAD)
295
296#define WL1271_RX_FILTER_FLAG_MASK BIT(0)
297#define WL1271_RX_FILTER_FLAG_IP_HEADER 0
298#define WL1271_RX_FILTER_FLAG_ETHERNET_HEADER BIT(1)
299
Eyal Shapiraa6eab0c2012-03-14 06:32:07 +0200300enum rx_filter_action {
301 FILTER_DROP = 0,
302 FILTER_SIGNAL = 1,
303 FILTER_FW_HANDLE = 2
304};
305
Yair Shapira7019c802012-07-11 18:48:04 +0300306enum plt_mode {
307 PLT_OFF = 0,
308 PLT_ON = 1,
309 PLT_FEM_DETECT = 2,
310};
311
Eyal Shapiraa6eab0c2012-03-14 06:32:07 +0200312struct wl12xx_rx_filter_field {
313 __le16 offset;
314 u8 len;
315 u8 flags;
316 u8 *pattern;
317} __packed;
318
319struct wl12xx_rx_filter {
320 u8 action;
321 int num_fields;
322 struct wl12xx_rx_filter_field fields[WL1271_RX_FILTER_MAX_FIELDS];
323};
324
Arik Nemtsovf84f7d72010-10-16 20:21:23 +0200325struct wl1271_station {
326 u8 hlid;
Eliad Peller426001a2012-11-26 18:05:45 +0200327 bool in_connection;
Arik Nemtsov0e752df2013-03-12 17:19:44 +0200328
329 /*
330 * total freed FW packets on the link to the STA - used for tracking the
331 * AES/TKIP PN across recoveries. Re-initialized each time from the
332 * wl1271_station structure.
333 */
334 u64 total_freed_pkts;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300335};
336
Eliad Peller87fbcb02011-10-05 11:55:41 +0200337struct wl12xx_vif {
Eliad Peller252efa42011-10-05 11:56:00 +0200338 struct wl1271 *wl;
Eliad Peller87627212011-10-10 10:12:54 +0200339 struct list_head list;
Eliad Pellerba8447f2011-10-10 10:13:00 +0200340 unsigned long flags;
Eliad Peller536129c2011-10-05 11:55:45 +0200341 u8 bss_type;
Eliad Pellerfb0e7072011-10-05 11:55:47 +0200342 u8 p2p; /* we are using p2p role */
Eliad Peller0603d892011-10-05 11:55:51 +0200343 u8 role_id;
Eliad Peller536129c2011-10-05 11:55:45 +0200344
Eliad Peller7edebf52011-10-05 11:55:52 +0200345 /* sta/ibss specific */
346 u8 dev_role_id;
Eliad Pellerafaf8bd2011-10-05 11:55:57 +0200347 u8 dev_hlid;
Eliad Peller7edebf52011-10-05 11:55:52 +0200348
Eliad Peller154da672011-10-05 11:55:53 +0200349 union {
350 struct {
351 u8 hlid;
Eliad Pellere5a359f2011-10-10 10:13:15 +0200352
353 u8 basic_rate_idx;
354 u8 ap_rate_idx;
355 u8 p2p_rate_idx;
Eliad Peller5ec8a442012-02-02 12:22:09 +0200356
Eliad Peller001e39a2012-08-16 13:52:47 +0300357 u8 klv_template_id;
358
Eliad Peller5ec8a442012-02-02 12:22:09 +0200359 bool qos;
Arik Nemtsov5f9b6772012-11-26 18:05:41 +0200360 /* channel type we started the STA role with */
361 enum nl80211_channel_type role_chan_type;
Eliad Peller154da672011-10-05 11:55:53 +0200362 } sta;
Eliad Pellera8ab39a2011-10-05 11:55:54 +0200363 struct {
364 u8 global_hlid;
365 u8 bcast_hlid;
Eliad Pellerc7ffb902011-10-05 11:56:05 +0200366
367 /* HLIDs bitmap of associated stations */
368 unsigned long sta_hlid_map[BITS_TO_LONGS(
369 WL12XX_MAX_LINKS)];
Eliad Peller170d0e62011-10-05 11:56:06 +0200370
371 /* recoreded keys - set here before AP startup */
372 struct wl1271_ap_key *recorded_keys[MAX_NUM_KEYS];
Eliad Pellere5a359f2011-10-10 10:13:15 +0200373
374 u8 mgmt_rate_idx;
375 u8 bcast_rate_idx;
376 u8 ucast_rate_idx[CONF_TX_MAX_AC_COUNT];
Eliad Pellera8ab39a2011-10-05 11:55:54 +0200377 } ap;
Eliad Peller154da672011-10-05 11:55:53 +0200378 };
379
Eliad Peller4438aca2011-10-10 10:12:50 +0200380 /* the hlid of the last transmitted skb */
381 int last_tx_hlid;
382
Arik Nemtsov8591d422012-11-27 08:44:58 +0200383 /* counters of packets per AC, across all links in the vif */
384 int tx_queue_count[NUM_TX_QUEUES];
385
Eliad Pellerc7ffb902011-10-05 11:56:05 +0200386 unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)];
387
Eliad Peller1fe9f162011-10-05 11:55:48 +0200388 u8 ssid[IEEE80211_MAX_SSID_LEN + 1];
389 u8 ssid_len;
390
Eliad Peller1b92f152011-10-10 10:13:09 +0200391 /* The current band */
392 enum ieee80211_band band;
Eliad Peller61f845f2011-10-10 10:13:10 +0200393 int channel;
Arik Nemtsov83d08d32012-05-10 12:13:30 +0300394 enum nl80211_channel_type channel_type;
Eliad Peller1b92f152011-10-10 10:13:09 +0200395
Arik Nemtsov091185d2012-07-03 09:11:03 +0300396 u32 bitrate_masks[WLCORE_NUM_BANDS];
Eliad Peller87fbcb02011-10-05 11:55:41 +0200397 u32 basic_rate_set;
Eliad Peller30d0c8f2011-10-05 11:55:42 +0200398
399 /*
400 * currently configured rate set:
401 * bits 0-15 - 802.11abg rates
402 * bits 16-23 - 802.11n MCS index mask
403 * support only 1 stream, thus only 8 bits for the MCS rates (0-7).
404 */
Eliad Pellerd2d66c52011-10-05 11:55:43 +0200405 u32 basic_rate;
Eliad Peller30d0c8f2011-10-05 11:55:42 +0200406 u32 rate_set;
Eliad Pellerbddb29b2011-10-05 11:55:49 +0200407
408 /* probe-req template for the current AP */
409 struct sk_buff *probereq;
Eliad Peller6840e372011-10-05 11:55:50 +0200410
Eliad Peller6a899792011-10-05 11:55:58 +0200411 /* Beaconing interval (needed for ad-hoc) */
412 u32 beacon_int;
413
Eliad Pellerf75c753f2011-10-05 11:55:59 +0200414 /* Default key (for WEP) */
415 u32 default_key;
416
Eliad Peller6840e372011-10-05 11:55:50 +0200417 /* Our association ID */
418 u16 aid;
Eliad Peller98b8625302011-10-05 11:55:55 +0200419
Eliad Peller74ec8392011-10-05 11:56:02 +0200420 /* retry counter for PSM entries */
421 u8 psm_entry_retry;
Eliad Peller04324d92011-10-05 11:56:03 +0200422
Eliad Peller6bd65022011-10-10 10:13:11 +0200423 /* in dBm */
424 int power_level;
425
Eliad Peller04324d92011-10-05 11:56:03 +0200426 int rssi_thold;
427 int last_rssi_event;
Eliad Pellerd0802ab2011-10-05 11:56:04 +0200428
Eliad Peller5ec8a442012-02-02 12:22:09 +0200429 /* save the current encryption type for auto-arp config */
430 u8 encryption_type;
431 __be32 ip_addr;
432
Eliad Pellerd0802ab2011-10-05 11:56:04 +0200433 /* RX BA constraint value */
434 bool ba_support;
435 bool ba_allowed;
Eliad Peller48e93e42011-10-10 10:12:58 +0200436
Eliad Pellerd50529c2012-11-22 18:06:20 +0200437 bool wmm_enabled;
438
Eliad Peller9eb599e2011-10-10 10:12:59 +0200439 /* Rx Streaming */
440 struct work_struct rx_streaming_enable_work;
441 struct work_struct rx_streaming_disable_work;
442 struct timer_list rx_streaming_timer;
443
Eliad Pellerc50a2822012-11-22 18:06:19 +0200444 struct delayed_work channel_switch_work;
445 struct delayed_work connection_loss_work;
446
Eliad Peller426001a2012-11-26 18:05:45 +0200447 /* number of in connection stations */
448 int inconn_count;
449
Eliad Peller48e93e42011-10-10 10:12:58 +0200450 /*
Arik Nemtsov1c33db72012-11-30 00:48:03 +0200451 * This vif's queues are mapped to mac80211 HW queues as:
452 * VO - hw_queue_base
453 * VI - hw_queue_base + 1
454 * BE - hw_queue_base + 2
455 * BK - hw_queue_base + 3
456 */
457 int hw_queue_base;
458
Arik Nemtsov187e52c2013-09-17 18:41:20 +0300459 /* do we have a pending auth reply? (and ROC) */
460 bool ap_pending_auth_reply;
461
462 /* time when we sent the pending auth reply */
463 unsigned long pending_auth_reply_time;
464
465 /* work for canceling ROC after pending auth reply */
466 struct delayed_work pending_auth_complete_work;
467
Eliad Peller48e93e42011-10-10 10:12:58 +0200468 /*
469 * This struct must be last!
470 * data that has to be saved acrossed reconfigs (e.g. recovery)
471 * should be declared in this struct.
472 */
473 struct {
474 u8 persistent[0];
Eliad Peller48e93e42011-10-10 10:12:58 +0200475
Arik Nemtsov93d5d102013-03-12 17:19:38 +0200476 /*
477 * total freed FW packets on the link - used for
478 * storing the AES/TKIP PN during recovery, as this
479 * structure is not zeroed out.
Arik Nemtsov0e752df2013-03-12 17:19:44 +0200480 * For STA this holds the PN of the link to the AP.
481 * For AP this holds the PN of the broadcast link.
Arik Nemtsov93d5d102013-03-12 17:19:38 +0200482 */
483 u64 total_freed_pkts;
Eliad Peller48e93e42011-10-10 10:12:58 +0200484 };
Eliad Peller87fbcb02011-10-05 11:55:41 +0200485};
486
487static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif)
488{
Arik Nemtsovf4d02002012-11-28 11:42:33 +0200489 WARN_ON(!vif);
Eliad Peller87fbcb02011-10-05 11:55:41 +0200490 return (struct wl12xx_vif *)vif->drv_priv;
491}
492
493static inline
494struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif)
495{
496 return container_of((void *)wlvif, struct ieee80211_vif, drv_priv);
497}
498
Eliad Peller87627212011-10-10 10:12:54 +0200499#define wl12xx_for_each_wlvif(wl, wlvif) \
500 list_for_each_entry(wlvif, &wl->wlvif_list, list)
501
Eliad Pellere4120df2011-10-10 10:13:17 +0200502#define wl12xx_for_each_wlvif_continue(wl, wlvif) \
503 list_for_each_entry_continue(wlvif, &wl->wlvif_list, list)
504
Eliad Peller4b730b62011-10-10 10:12:57 +0200505#define wl12xx_for_each_wlvif_bss_type(wl, wlvif, _bss_type) \
506 wl12xx_for_each_wlvif(wl, wlvif) \
507 if (wlvif->bss_type == _bss_type)
508
509#define wl12xx_for_each_wlvif_sta(wl, wlvif) \
510 wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_STA_BSS)
511
512#define wl12xx_for_each_wlvif_ap(wl, wlvif) \
513 wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_AP_BSS)
514
Yair Shapira7019c802012-07-11 18:48:04 +0300515int wl1271_plt_start(struct wl1271 *wl, const enum plt_mode plt_mode);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300516int wl1271_plt_stop(struct wl1271 *wl);
Eliad Peller9eb599e2011-10-10 10:12:59 +0200517int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif);
Ido Yarivbaacb9ae2011-06-06 14:57:05 +0300518void wl12xx_queue_recovery_work(struct wl1271 *wl);
Ido Yariv95dac04f2011-06-06 14:57:06 +0300519size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
Eyal Shapiraa6eab0c2012-03-14 06:32:07 +0200520int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
521 u16 offset, u8 flags,
522 u8 *pattern, u8 len);
523void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter);
524struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void);
525int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter);
526void wl1271_rx_filter_flatten_fields(struct wl12xx_rx_filter *filter,
527 u8 *buf);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300528
529#define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
530
Eliad Peller98b8625302011-10-05 11:55:55 +0200531#define SESSION_COUNTER_MAX 6 /* maximum value for the session counter */
532#define SESSION_COUNTER_INVALID 7 /* used with dummy_packet */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300533
534#define WL1271_DEFAULT_POWER_LEVEL 0
535
Ido Yariv787b2dc2011-06-24 13:03:36 +0300536#define WL1271_TX_QUEUE_LOW_WATERMARK 32
537#define WL1271_TX_QUEUE_HIGH_WATERMARK 256
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300538
Ido Yariva6208652011-03-01 15:14:41 +0200539#define WL1271_DEFERRED_QUEUE_LIMIT 64
540
Juuso Oikarinen01ac17e2009-12-11 15:41:02 +0200541/* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power
542 on in case is has been shut down shortly before */
Stefan Weile8a8b252011-01-02 15:12:42 +0100543#define WL1271_PRE_POWER_ON_SLEEP 20 /* in milliseconds */
544#define WL1271_POWER_ON_SLEEP 200 /* in milliseconds */
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300545
Shahar Levie8b03a22010-10-13 16:09:39 +0200546/* Macros to handle wl1271.sta_rate_set */
547#define HW_BG_RATES_MASK 0xffff
548#define HW_HT_RATES_OFFSET 16
Arik Nemtsovb3a47ee2012-05-10 12:13:33 +0300549#define HW_MIMO_RATES_OFFSET 24
Shahar Levie8b03a22010-10-13 16:09:39 +0200550
Ido Yariv95dac04f2011-06-06 14:57:06 +0300551#define WL12XX_HW_BLOCK_SIZE 256
552
Luciano Coelho83885692012-05-10 12:13:42 +0300553#endif /* __WLCORE_I_H__ */