blob: 1e54293532b0f1f0d4aac3925af1c86d5a7fe69a [file] [log] [blame]
Zhu Yib481de92007-09-25 17:54:57 -07001/******************************************************************************
2 *
Wey-Yi Guy901069c2011-04-05 09:42:00 -07003 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
Zhu Yib481de92007-09-25 17:54:57 -07004 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
Winkler, Tomas759ef892008-12-09 11:28:58 -080022 * Intel Linux Wireless <ilw@linux.intel.com>
Zhu Yib481de92007-09-25 17:54:57 -070023 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
Ben Cahillfcd427b2007-11-29 11:10:00 +080026/*
Tomas Winkler3e0d4cb2008-04-24 11:55:38 -070027 * Please use this file (iwl-dev.h) for driver implementation definitions.
Tomas Winkler5a36ba02008-04-24 11:55:37 -070028 * Please use iwl-commands.h for uCode API definitions.
Ben Cahillfcd427b2007-11-29 11:10:00 +080029 */
30
Emmanuel Grumbachbe1f3ab62008-06-12 09:47:18 +080031#ifndef __iwl_dev_h__
32#define __iwl_dev_h__
Zhu Yib481de92007-09-25 17:54:57 -070033
Alexey Dobriyana6b7a402011-06-06 10:43:46 +000034#include <linux/interrupt.h>
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080035#include <linux/pci.h> /* for struct pci_device_id */
36#include <linux/kernel.h>
Johannes Berg7194207c2011-01-04 16:22:00 -080037#include <linux/wait.h>
Wey-Yi Guy5ed540a2011-01-21 15:26:39 -080038#include <linux/leds.h>
Emmanuel Grumbachdfa2bdb2011-08-25 23:11:23 -070039#include <linux/slab.h>
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080040#include <net/ieee80211_radiotap.h>
41
Assaf Krauss6bc913b2008-03-11 16:17:18 -070042#include "iwl-eeprom.h"
Winkler, Tomasdbb66542008-12-22 11:31:14 +080043#include "iwl-csr.h"
44#include "iwl-prph.h"
Winkler, Tomasdbb66542008-12-22 11:31:14 +080045#include "iwl-debug.h"
Wey-Yi Guyb744cb72010-03-23 11:37:59 -070046#include "iwl-agn-hw.h"
Mohamed Abbasab53d8a2008-03-25 16:33:36 -070047#include "iwl-led.h"
Mohamed Abbas5da4b552008-04-21 15:41:51 -070048#include "iwl-power.h"
Tomas Winklere227cea2008-07-18 13:53:05 +080049#include "iwl-agn-rs.h"
Wey-Yi Guy0975cc82010-07-31 08:34:07 -070050#include "iwl-agn-tt.h"
Emmanuel Grumbachd5934112011-07-11 10:48:51 +030051#include "iwl-bus.h"
Emmanuel Grumbach41c50542011-07-11 08:51:04 +030052#include "iwl-trans.h"
Emmanuel Grumbach48f20d32011-08-25 23:10:36 -070053#include "iwl-shared.h"
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080054
Wey-Yi Guy672639d2009-07-24 11:13:01 -070055struct iwl_tx_queue;
56
Ron Rindjunsky099b40b2008-04-21 15:41:53 -070057/* CT-KILL constants */
Wey-Yi Guy672639d2009-07-24 11:13:01 -070058#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
59#define CT_KILL_THRESHOLD 114 /* in Celsius */
60#define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
Tomas Winkler4bf775c2008-03-04 18:09:31 -080061
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080062/* Default noise level to report when noise measurement is not available.
63 * This may be because we're:
64 * 1) Not associated (4965, no beacon statistics being sent to driver)
65 * 2) Scanning (noise measurement does not apply to associated channel)
66 * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
67 * Use default noise value of -127 ... this is below the range of measurable
68 * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
69 * Also, -127 works better than 0 when averaging frames with/without
70 * noise info (e.g. averaging might be done in app); measured dBm values are
71 * always negative ... using a negative value as the default keeps all
72 * averages within an s8's (used in some apps) range of negative values. */
73#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
74
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080075/*
76 * RTS threshold here is total size [2347] minus 4 FCS bytes
77 * Per spec:
78 * a value of 0 means RTS on all data/management packets
79 * a value > max MSDU size means no RTS
80 * else RTS for data/management frames where MPDU is larger
81 * than RTS value.
82 */
83#define DEFAULT_RTS_THRESHOLD 2347U
84#define MIN_RTS_THRESHOLD 0U
85#define MAX_RTS_THRESHOLD 2347U
86#define MAX_MSDU_SIZE 2304U
87#define MAX_MPDU_SIZE 2346U
Johannes Berg51b7ef02011-05-11 08:17:20 -070088#define DEFAULT_BEACON_INTERVAL 200U
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080089#define DEFAULT_SHORT_RETRY_LIMIT 7U
90#define DEFAULT_LONG_RETRY_LIMIT 4U
91
Johannes Bergc2acea82009-07-24 11:13:05 -070092/* defined below */
93struct iwl_device_cmd;
94
95struct iwl_cmd_meta {
96 /* only for SYNC commands, iff the reply skb is wanted */
97 struct iwl_host_cmd *source;
98 /*
99 * only for ASYNC commands
100 * (which is somewhat stupid -- look at iwl-sta.c for instance
101 * which duplicates a bunch of code because the callback isn't
102 * invoked for SYNC commands, if it were and its result passed
103 * through it would be simpler...)
104 */
Johannes Berg5696aea2009-07-24 11:13:06 -0700105 void (*callback)(struct iwl_priv *priv,
106 struct iwl_device_cmd *cmd,
Zhu Yi2f301222009-10-09 17:19:45 +0800107 struct iwl_rx_packet *pkt);
Johannes Bergc2acea82009-07-24 11:13:05 -0700108
Johannes Bergc2acea82009-07-24 11:13:05 -0700109 u32 flags;
110
FUJITA Tomonori2e724442010-06-03 14:19:20 +0900111 DEFINE_DMA_UNMAP_ADDR(mapping);
112 DEFINE_DMA_UNMAP_LEN(len);
Johannes Bergc2acea82009-07-24 11:13:05 -0700113};
114
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800115/*
116 * Generic queue structure
117 *
Johannes Berg4ce7cc22011-05-13 11:57:40 -0700118 * Contains common data for Rx and Tx queues.
119 *
120 * Note the difference between n_bd and n_window: the hardware
121 * always assumes 256 descriptors, so n_bd is always 256 (unless
122 * there might be HW changes in the future). For the normal TX
123 * queues, n_window, which is the size of the software queue data
124 * is also 256; however, for the command queue, n_window is only
125 * 32 since we don't need so many commands pending. Since the HW
126 * still uses 256 BDs for DMA though, n_bd stays 256. As a result,
127 * the software buffers (in the variables @meta, @txb in struct
128 * iwl_tx_queue) only have 32 entries, while the HW buffers (@tfds
129 * in the same struct) have 256.
130 * This means that we end up with the following:
131 * HW entries: | 0 | ... | N * 32 | ... | N * 32 + 31 | ... | 255 |
132 * SW entries: | 0 | ... | 31 |
133 * where N is a number between 0 and 7. This means that the SW
134 * data is a window overlayed over the HW queue.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800135 */
Tomas Winkler443cfd42008-05-15 13:53:57 +0800136struct iwl_queue {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800137 int n_bd; /* number of BDs in this queue */
138 int write_ptr; /* 1-st empty entry (index) host_w*/
139 int read_ptr; /* last used entry (index) host_r*/
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800140 /* use for monitoring and recovering the stuck queue */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800141 dma_addr_t dma_addr; /* physical addr for BD's */
142 int n_window; /* safe queue window */
143 u32 id;
144 int low_mark; /* low watermark, resume queue if free
145 * space more than this */
146 int high_mark; /* high watermark, stop queue if free
147 * space less than this */
Stanislaw Gruszkaa839cf62011-01-28 16:47:46 +0100148};
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800149
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800150/**
Ron Rindjunsky16466902008-05-05 10:22:50 +0800151 * struct iwl_tx_queue - Tx Queue for DMA
Ben Cahillbc472792007-11-29 11:09:49 +0800152 * @q: generic Rx/Tx queue descriptor
153 * @bd: base of circular buffer of TFDs
Johannes Bergc2acea82009-07-24 11:13:05 -0700154 * @cmd: array of command/TX buffer pointers
155 * @meta: array of meta data for each command/tx buffer
Ben Cahillbc472792007-11-29 11:09:49 +0800156 * @dma_addr_cmd: physical address of cmd/tx buffer array
157 * @txb: array of per-TFD driver data
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100158 * @time_stamp: time (in jiffies) of last read_ptr change
Ben Cahillbc472792007-11-29 11:09:49 +0800159 * @need_update: indicates need to update read/write index
160 * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
Emmanuel Grumbacha0eaad72011-08-25 23:11:00 -0700161 * @sta_id: valid if sched_retry is set
162 * @tid: valid if sched_retry is set
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800163 *
Ben Cahillbc472792007-11-29 11:09:49 +0800164 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
165 * descriptors) and required locking structures.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800166 */
Samuel Ortiz188cf6c2008-12-22 11:31:16 +0800167#define TFD_TX_CMD_SLOTS 256
168#define TFD_CMD_SLOTS 32
169
Ron Rindjunsky16466902008-05-05 10:22:50 +0800170struct iwl_tx_queue {
Tomas Winkler443cfd42008-05-15 13:53:57 +0800171 struct iwl_queue q;
Johannes Berg4ce7cc22011-05-13 11:57:40 -0700172 struct iwl_tfd *tfds;
Johannes Bergc2acea82009-07-24 11:13:05 -0700173 struct iwl_device_cmd **cmd;
174 struct iwl_cmd_meta *meta;
Emmanuel Grumbach2c452292011-08-25 23:11:21 -0700175 struct sk_buff **skbs;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100176 unsigned long time_stamp;
Tomas Winkler3fd07a12008-10-23 23:48:49 -0700177 u8 need_update;
178 u8 sched_retry;
179 u8 active;
180 u8 swq_id;
Emmanuel Grumbacha0eaad72011-08-25 23:11:00 -0700181
182 u16 sta_id;
183 u16 tid;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800184};
185
186#define IWL_NUM_SCAN_RATES (2)
187
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800188/*
189 * One for each channel, holds all channel setup data
190 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
191 * with one another!
192 */
Assaf Kraussbf85ea42008-03-14 10:38:49 -0700193struct iwl_channel_info {
Tomas Winkler073d3f52008-04-21 15:41:52 -0700194 struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700195 struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for
196 * HT40 channel */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800197
198 u8 channel; /* channel number */
199 u8 flags; /* flags copied from EEPROM */
200 s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
Ben Cahillfcd427b2007-11-29 11:10:00 +0800201 s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800202 s8 min_power; /* always 0 */
203 s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
204
205 u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
206 u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
Johannes Berg8318d782008-01-24 19:38:38 +0100207 enum ieee80211_band band;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800208
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700209 /* HT40 channel info */
210 s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700211 u8 ht40_flags; /* flags copied from EEPROM */
212 u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800213};
214
Johannes Berg751ca302010-08-23 10:46:34 +0200215#define IWL_TX_FIFO_BK 0 /* shared */
Johannes Bergedc1a3a2010-02-24 01:57:19 -0800216#define IWL_TX_FIFO_BE 1
Johannes Berg751ca302010-08-23 10:46:34 +0200217#define IWL_TX_FIFO_VI 2 /* shared */
Johannes Bergedc1a3a2010-02-24 01:57:19 -0800218#define IWL_TX_FIFO_VO 3
Johannes Berg751ca302010-08-23 10:46:34 +0200219#define IWL_TX_FIFO_BK_IPAN IWL_TX_FIFO_BK
220#define IWL_TX_FIFO_BE_IPAN 4
221#define IWL_TX_FIFO_VI_IPAN IWL_TX_FIFO_VI
222#define IWL_TX_FIFO_VO_IPAN 5
Johannes Berg72c04ce2011-07-23 10:24:40 -0700223/* re-uses the VO FIFO, uCode will properly flush/schedule */
224#define IWL_TX_FIFO_AUX 5
Johannes Bergedc1a3a2010-02-24 01:57:19 -0800225#define IWL_TX_FIFO_UNUSED -1
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800226
Johannes Berg72c04ce2011-07-23 10:24:40 -0700227/* AUX (TX during scan dwell) queue */
228#define IWL_AUX_QUEUE 10
229
230/*
231 * Minimum number of queues. MAX_NUM is defined in hw specific files.
232 * Set the minimum to accommodate
233 * - 4 standard TX queues
234 * - the command queue
235 * - 4 PAN TX queues
236 * - the PAN multicast queue, and
237 * - the AUX (TX during scan dwell) queue.
238 */
239#define IWL_MIN_NUM_QUEUES 11
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800240
Wey-Yi Guybd35f152009-10-09 13:20:23 -0700241/*
Johannes Berg13bb9482010-08-23 10:46:33 +0200242 * Command queue depends on iPAN support.
Wey-Yi Guybd35f152009-10-09 13:20:23 -0700243 */
Johannes Berg13bb9482010-08-23 10:46:33 +0200244#define IWL_DEFAULT_CMD_QUEUE_NUM 4
245#define IWL_IPAN_CMD_QUEUE_NUM 9
Wey-Yi Guybd35f152009-10-09 13:20:23 -0700246
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800247#define IEEE80211_DATA_LEN 2304
248#define IEEE80211_4ADDR_LEN 30
249#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
250#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
251
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800252
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800253#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
254#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
255#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
256
257enum {
Tomas Winklerc587de02009-06-03 11:44:07 -0700258 CMD_SYNC = 0,
Emmanuel Grumbache419d622011-07-08 08:46:14 -0700259 CMD_ASYNC = BIT(0),
260 CMD_WANT_SKB = BIT(1),
Wey-Yi Guyc7c11152011-07-08 08:46:25 -0700261 CMD_ON_DEMAND = BIT(2),
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800262};
263
Wey-Yi Guyc8c24872009-10-23 13:42:26 -0700264#define DEF_CMD_PAYLOAD_SIZE 320
Ron Rindjunskybd68fb62008-05-29 16:34:49 +0800265
Ben Cahillbc472792007-11-29 11:09:49 +0800266/**
Johannes Bergc2acea82009-07-24 11:13:05 -0700267 * struct iwl_device_cmd
Ben Cahillbc472792007-11-29 11:09:49 +0800268 *
269 * For allocation of the command and tx queues, this establishes the overall
Johannes Berg4ce7cc22011-05-13 11:57:40 -0700270 * size of the largest command we send to uCode, except for commands that
271 * aren't fully copied and use other TFD space.
Ben Cahillbc472792007-11-29 11:09:49 +0800272 */
Johannes Bergc2acea82009-07-24 11:13:05 -0700273struct iwl_device_cmd {
Tomas Winkler857485c2008-03-21 13:53:44 -0700274 struct iwl_cmd_header hdr; /* uCode API */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800275 union {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800276 u32 flags;
277 u8 val8;
278 u16 val16;
279 u32 val32;
Tomas Winkler83d527d2008-05-15 13:54:05 +0800280 struct iwl_tx_cmd tx;
Wey-Yi Guyc8c24872009-10-23 13:42:26 -0700281 struct iwl6000_channel_switch_cmd chswitch;
282 u8 payload[DEF_CMD_PAYLOAD_SIZE];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000283 } __packed cmd;
284} __packed;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800285
Johannes Bergc2acea82009-07-24 11:13:05 -0700286#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
287
Johannes Berg4ce7cc22011-05-13 11:57:40 -0700288#define IWL_MAX_CMD_TFDS 2
289
290enum iwl_hcmd_dataflag {
291 IWL_HCMD_DFL_NOCOPY = BIT(0),
292};
Tomas Winkler3257e5d2008-10-14 12:32:43 -0700293
Emmanuel Grumbache419d622011-07-08 08:46:14 -0700294/**
295 * struct iwl_host_cmd - Host command to the uCode
296 * @data: array of chunks that composes the data of the host command
297 * @reply_page: pointer to the page that holds the response to the host command
298 * @callback:
299 * @flags: can be CMD_* note CMD_WANT_SKB is incompatible withe CMD_ASYNC
300 * @len: array of the lenths of the chunks in data
301 * @dataflags:
302 * @id: id of the host command
303 */
Tomas Winkler857485c2008-03-21 13:53:44 -0700304struct iwl_host_cmd {
Johannes Berg3fa50732011-05-04 07:50:38 -0700305 const void *data[IWL_MAX_CMD_TFDS];
Zhu Yi2f301222009-10-09 17:19:45 +0800306 unsigned long reply_page;
Johannes Berg5696aea2009-07-24 11:13:06 -0700307 void (*callback)(struct iwl_priv *priv,
308 struct iwl_device_cmd *cmd,
Zhu Yi2f301222009-10-09 17:19:45 +0800309 struct iwl_rx_packet *pkt);
Johannes Bergc2acea82009-07-24 11:13:05 -0700310 u32 flags;
Johannes Berg3fa50732011-05-04 07:50:38 -0700311 u16 len[IWL_MAX_CMD_TFDS];
Johannes Berg4ce7cc22011-05-13 11:57:40 -0700312 u8 dataflags[IWL_MAX_CMD_TFDS];
Johannes Bergc2acea82009-07-24 11:13:05 -0700313 u8 id;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800314};
315
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800316#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
317#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
318#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
319
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800320#define IWL_SUPPORTED_RATES_IE_LEN 8
321
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800322#define IWL_INVALID_RATE 0xFF
323#define IWL_INVALID_VALUE -1
324
Kolekar, Abhijeeta78fe752008-12-19 10:37:21 +0800325union iwl_ht_rate_supp {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800326 u16 rates;
327 struct {
328 u8 siso_rate;
329 u8 mimo_rate;
330 };
331};
332
Wey-Yi Guy172c1d12010-08-04 12:02:43 -0700333#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
334#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
335#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
336#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
337#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
338#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
339#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
Wey-Yi Guybcc693a2009-07-24 11:13:09 -0700340
341/*
342 * Maximal MPDU density for TX aggregation
343 * 4 - 2us density
344 * 5 - 4us density
345 * 6 - 8us density
346 * 7 - 16us density
347 */
Wey-Yi Guy172c1d12010-08-04 12:02:43 -0700348#define CFG_HT_MPDU_DENSITY_2USEC (0x4)
Wey-Yi Guybcc693a2009-07-24 11:13:09 -0700349#define CFG_HT_MPDU_DENSITY_4USEC (0x5)
Wey-Yi Guy172c1d12010-08-04 12:02:43 -0700350#define CFG_HT_MPDU_DENSITY_8USEC (0x6)
351#define CFG_HT_MPDU_DENSITY_16USEC (0x7)
Wey-Yi Guybcc693a2009-07-24 11:13:09 -0700352#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
Wey-Yi Guy172c1d12010-08-04 12:02:43 -0700353#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
354#define CFG_HT_MPDU_DENSITY_MIN (0x1)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800355
Johannes Bergfad95bf2009-09-11 10:38:15 -0700356struct iwl_ht_config {
Johannes Berg02bb1be2009-09-11 10:38:17 -0700357 bool single_chain_sufficient;
Johannes Bergba37a3d2009-12-10 14:37:27 -0800358 enum ieee80211_smps_mode smps; /* current smps mode */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800359};
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800360
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800361/* QoS structures */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800362struct iwl_qos_info {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800363 int qos_active;
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800364 struct iwl_qosparam_cmd def_qos_parm;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800365};
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800366
Reinette Chatrefe6b23d2010-02-22 16:24:47 -0800367/*
368 * Structure should be accessed with sta_lock held. When station addition
369 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
370 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
371 * held.
372 */
Tomas Winkler6def9762008-05-05 10:22:31 +0800373struct iwl_station_entry {
Tomas Winkler133636d2008-05-05 10:22:34 +0800374 struct iwl_addsta_cmd sta;
Johannes Bergdcef7322010-08-27 08:55:52 -0700375 u8 used, ctxid;
Reinette Chatrefe6b23d2010-02-22 16:24:47 -0800376 struct iwl_link_quality_cmd *lq;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800377};
378
Johannes Bergfd1af152010-04-30 11:30:43 -0700379struct iwl_station_priv_common {
Johannes Berg238d7812010-08-23 10:46:45 +0200380 struct iwl_rxon_context *ctx;
Johannes Bergfd1af152010-04-30 11:30:43 -0700381 u8 sta_id;
382};
383
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700384/*
385 * iwl_station_priv: Driver's private station information
386 *
387 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
388 * in the structure for use by driver. This structure is places in that
389 * space.
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700390 */
391struct iwl_station_priv {
Johannes Bergfd1af152010-04-30 11:30:43 -0700392 struct iwl_station_priv_common common;
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700393 struct iwl_lq_sta lq_sta;
Johannes Berg6ab10ff2009-11-13 11:56:37 -0800394 atomic_t pending_frames;
395 bool client;
396 bool asleep;
Johannes Berg7b090682011-01-19 02:53:54 -0800397 u8 max_agg_bufsize;
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700398};
399
Johannes Bergfd1af152010-04-30 11:30:43 -0700400/**
401 * struct iwl_vif_priv - driver's private per-interface information
402 *
403 * When mac80211 allocates a virtual interface, it can allocate
404 * space for us to put data into.
405 */
406struct iwl_vif_priv {
Johannes Berg246ed352010-08-23 10:46:32 +0200407 struct iwl_rxon_context *ctx;
Johannes Bergfd1af152010-04-30 11:30:43 -0700408 u8 ibss_bssid_sta_id;
409};
410
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800411/* one for each uCode image (inst/data, boot/init/runtime) */
412struct fw_desc {
413 void *v_addr; /* access by driver */
414 dma_addr_t p_addr; /* access by card's busmaster DMA */
415 u32 len; /* bytes */
416};
417
Johannes Bergdbf28e212011-04-16 08:29:24 -0700418struct fw_img {
419 struct fw_desc code, data;
420};
421
Johannes Bergdd7a2502010-04-28 23:33:10 -0700422/* v1/v2 uCode file layout */
Jay Sternbergcc0f5552009-07-17 09:30:16 -0700423struct iwl_ucode_header {
424 __le32 ver; /* major/minor/API/serial */
425 union {
426 struct {
427 __le32 inst_size; /* bytes of runtime code */
428 __le32 data_size; /* bytes of runtime data */
429 __le32 init_size; /* bytes of init code */
430 __le32 init_data_size; /* bytes of init data */
431 __le32 boot_size; /* bytes of bootstrap code */
432 u8 data[0]; /* in same order as sizes */
433 } v1;
434 struct {
435 __le32 build; /* build number */
436 __le32 inst_size; /* bytes of runtime code */
437 __le32 data_size; /* bytes of runtime data */
438 __le32 init_size; /* bytes of init code */
439 __le32 init_data_size; /* bytes of init data */
440 __le32 boot_size; /* bytes of bootstrap code */
441 u8 data[0]; /* in same order as sizes */
442 } v2;
443 } u;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800444};
445
Johannes Bergdd7a2502010-04-28 23:33:10 -0700446/*
447 * new TLV uCode file layout
448 *
449 * The new TLV file format contains TLVs, that each specify
450 * some piece of data. To facilitate "groups", for example
451 * different instruction image with different capabilities,
452 * bundled with the same init image, an alternative mechanism
453 * is provided:
454 * When the alternative field is 0, that means that the item
455 * is always valid. When it is non-zero, then it is only
456 * valid in conjunction with items of the same alternative,
457 * in which case the driver (user) selects one alternative
458 * to use.
459 */
460
461enum iwl_ucode_tlv_type {
462 IWL_UCODE_TLV_INVALID = 0, /* unused */
463 IWL_UCODE_TLV_INST = 1,
464 IWL_UCODE_TLV_DATA = 2,
465 IWL_UCODE_TLV_INIT = 3,
466 IWL_UCODE_TLV_INIT_DATA = 4,
467 IWL_UCODE_TLV_BOOT = 5,
468 IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
Johannes Bergece9c4e2010-08-23 10:46:49 +0200469 IWL_UCODE_TLV_PAN = 7,
Johannes Bergb2e640d42010-05-05 23:24:54 -0700470 IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8,
471 IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9,
472 IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10,
473 IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11,
474 IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12,
475 IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13,
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -0700476 IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14,
Wey-Yi Guy6a822d02010-07-13 17:13:15 -0700477 IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700478 IWL_UCODE_TLV_WOWLAN_INST = 16,
479 IWL_UCODE_TLV_WOWLAN_DATA = 17,
Johannes Berg3997ff32011-04-05 09:42:02 -0700480 IWL_UCODE_TLV_FLAGS = 18,
481};
482
483/**
484 * enum iwl_ucode_tlv_flag - ucode API flags
485 * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
486 * was a separate TLV but moved here to save space.
Johannes Bergd2690c02011-04-20 09:10:39 -0700487 * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
488 * treats good CRC threshold as a boolean
Johannes Berg3997ff32011-04-05 09:42:02 -0700489 * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
Johannes Bergc6baf7f2011-07-23 10:24:47 -0700490 * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
Johannes Berg3997ff32011-04-05 09:42:02 -0700491 */
492enum iwl_ucode_tlv_flag {
493 IWL_UCODE_TLV_FLAGS_PAN = BIT(0),
Johannes Bergd2690c02011-04-20 09:10:39 -0700494 IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1),
Johannes Berg3997ff32011-04-05 09:42:02 -0700495 IWL_UCODE_TLV_FLAGS_MFP = BIT(2),
Johannes Bergc6baf7f2011-07-23 10:24:47 -0700496 IWL_UCODE_TLV_FLAGS_P2P = BIT(3),
Johannes Bergdd7a2502010-04-28 23:33:10 -0700497};
498
499struct iwl_ucode_tlv {
500 __le16 type; /* see above */
501 __le16 alternative; /* see comment */
502 __le32 length; /* not including type/length fields */
503 u8 data[0];
Eric Dumazetba2d3582010-06-02 18:10:09 +0000504} __packed;
Johannes Bergdd7a2502010-04-28 23:33:10 -0700505
506#define IWL_TLV_UCODE_MAGIC 0x0a4c5749
507
508struct iwl_tlv_ucode_header {
509 /*
510 * The TLV style ucode header is distinguished from
511 * the v1/v2 style header by first four bytes being
512 * zero, as such is an invalid combination of
513 * major/minor/API/serial versions.
514 */
515 __le32 zero;
516 __le32 magic;
517 u8 human_readable[64];
518 __le32 ver; /* major/minor/API/serial */
519 __le32 build;
520 __le64 alternatives; /* bitmask of valid alternatives */
521 /*
522 * The data contained herein has a TLV layout,
523 * see above for the TLV header and types.
524 * Note that each TLV is padded to a length
525 * that is a multiple of 4 for alignment.
526 */
527 u8 data[0];
528};
529
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700530struct iwl_sensitivity_ranges {
531 u16 min_nrg_cck;
532 u16 max_nrg_cck;
533
534 u16 nrg_th_cck;
535 u16 nrg_th_ofdm;
536
537 u16 auto_corr_min_ofdm;
538 u16 auto_corr_min_ofdm_mrc;
539 u16 auto_corr_min_ofdm_x1;
540 u16 auto_corr_min_ofdm_mrc_x1;
541
542 u16 auto_corr_max_ofdm;
543 u16 auto_corr_max_ofdm_mrc;
544 u16 auto_corr_max_ofdm_x1;
545 u16 auto_corr_max_ofdm_mrc_x1;
546
547 u16 auto_corr_max_cck;
548 u16 auto_corr_max_cck_mrc;
549 u16 auto_corr_min_cck;
550 u16 auto_corr_min_cck_mrc;
Wey-Yi Guy55036d62009-10-09 13:20:24 -0700551
552 u16 barker_corr_th_min;
553 u16 barker_corr_th_min_mrc;
554 u16 nrg_th_cca;
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700555};
556
Ron Rindjunsky099b40b2008-04-21 15:41:53 -0700557
Tomas Winklerb5047f72008-12-11 10:33:39 -0800558#define KELVIN_TO_CELSIUS(x) ((x)-273)
559#define CELSIUS_TO_KELVIN(x) ((x)+273)
560
561
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800562/******************************************************************************
563 *
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800564 * Functions implemented in core module which are forward declared here
565 * for use by iwl-[4-5].c
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800566 *
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800567 * NOTE: The implementation of these functions are not hardware specific
568 * which is why they are in the core module files.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800569 *
570 * Naming convention --
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800571 * iwl_ <-- Is part of iwlwifi
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800572 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800573 *
574 ****************************************************************************/
Emmanuel Grumbach5b9f8cd2008-10-29 14:05:46 -0700575extern void iwl_update_chain_flags(struct iwl_priv *priv);
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800576extern const u8 iwl_bcast_addr[ETH_ALEN];
Tomas Winklerfd4abac2008-05-15 13:54:07 +0800577
Zhu Yib481de92007-09-25 17:54:57 -0700578#define IWL_OPERATION_MODE_AUTO 0
579#define IWL_OPERATION_MODE_HT_ONLY 1
580#define IWL_OPERATION_MODE_MIXED 2
581#define IWL_OPERATION_MODE_20MHZ 3
582
Tomas Winkler3195cdb2008-04-23 17:15:00 -0700583#define IWL_TX_CRC_SIZE 4
584#define IWL_TX_DELIMITER_SIZE 4
Zhu Yib481de92007-09-25 17:54:57 -0700585
Zhu Yib481de92007-09-25 17:54:57 -0700586#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
Zhu Yib481de92007-09-25 17:54:57 -0700587
Zhu Yib481de92007-09-25 17:54:57 -0700588/* Sensitivity and chain noise calibration */
Zhu Yib481de92007-09-25 17:54:57 -0700589#define INITIALIZATION_VALUE 0xFFFF
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -0700590#define IWL_CAL_NUM_BEACONS 16
Zhu Yib481de92007-09-25 17:54:57 -0700591#define MAXIMUM_ALLOWED_PATHLOSS 15
592
Zhu Yib481de92007-09-25 17:54:57 -0700593#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
594
595#define MAX_FA_OFDM 50
596#define MIN_FA_OFDM 5
597#define MAX_FA_CCK 50
598#define MIN_FA_CCK 5
599
Zhu Yib481de92007-09-25 17:54:57 -0700600#define AUTO_CORR_STEP_OFDM 1
601
Zhu Yib481de92007-09-25 17:54:57 -0700602#define AUTO_CORR_STEP_CCK 3
603#define AUTO_CORR_MAX_TH_CCK 160
604
Zhu Yib481de92007-09-25 17:54:57 -0700605#define NRG_DIFF 2
606#define NRG_STEP_CCK 2
607#define NRG_MARGIN 8
608#define MAX_NUMBER_CCK_NO_FA 100
609
610#define AUTO_CORR_CCK_MIN_VAL_DEF (125)
611
612#define CHAIN_A 0
613#define CHAIN_B 1
614#define CHAIN_C 2
615#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
616#define ALL_BAND_FILTER 0xFF00
617#define IN_BAND_FILTER 0xFF
618#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
619
Tomas Winkler3195cdb2008-04-23 17:15:00 -0700620#define NRG_NUM_PREV_STAT_L 20
621#define NUM_RX_CHAINS 3
622
Johannes Berg3240cab2011-04-05 09:41:49 -0700623enum iwlagn_false_alarm_state {
Zhu Yib481de92007-09-25 17:54:57 -0700624 IWL_FA_TOO_MANY = 0,
625 IWL_FA_TOO_FEW = 1,
626 IWL_FA_GOOD_RANGE = 2,
627};
628
Johannes Berg3240cab2011-04-05 09:41:49 -0700629enum iwlagn_chain_noise_state {
Zhu Yib481de92007-09-25 17:54:57 -0700630 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800631 IWL_CHAIN_NOISE_ACCUMULATE,
632 IWL_CHAIN_NOISE_CALIBRATED,
633 IWL_CHAIN_NOISE_DONE,
Zhu Yib481de92007-09-25 17:54:57 -0700634};
635
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700636
637/*
638 * enum iwl_calib
639 * defines the order in which results of initial calibrations
640 * should be sent to the runtime uCode
641 */
642enum iwl_calib {
643 IWL_CALIB_XTAL,
Tomas Winkler819500c2008-12-01 16:32:19 -0800644 IWL_CALIB_DC,
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700645 IWL_CALIB_LO,
646 IWL_CALIB_TX_IQ,
647 IWL_CALIB_TX_IQ_PERD,
Tomas Winkler201706a2008-11-19 15:32:24 -0800648 IWL_CALIB_BASE_BAND,
Shanyu Zhaobf53f932010-09-21 16:54:01 -0700649 IWL_CALIB_TEMP_OFFSET,
Tomas Winklerf69f42a2008-10-23 23:48:52 -0700650 IWL_CALIB_MAX
651};
652
Tomas Winkler6e21f2c2008-09-03 11:26:37 +0800653/* Opaque calibration results */
654struct iwl_calib_result {
655 void *buf;
656 size_t buf_len;
Tomas Winkler7c616cb2008-05-29 16:35:05 +0800657};
658
Zhu Yib481de92007-09-25 17:54:57 -0700659/* Sensitivity calib data */
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700660struct iwl_sensitivity_data {
Zhu Yib481de92007-09-25 17:54:57 -0700661 u32 auto_corr_ofdm;
662 u32 auto_corr_ofdm_mrc;
663 u32 auto_corr_ofdm_x1;
664 u32 auto_corr_ofdm_mrc_x1;
665 u32 auto_corr_cck;
666 u32 auto_corr_cck_mrc;
667
668 u32 last_bad_plcp_cnt_ofdm;
669 u32 last_fa_cnt_ofdm;
670 u32 last_bad_plcp_cnt_cck;
671 u32 last_fa_cnt_cck;
672
673 u32 nrg_curr_state;
674 u32 nrg_prev_state;
675 u32 nrg_value[10];
676 u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
677 u32 nrg_silence_ref;
678 u32 nrg_energy_idx;
679 u32 nrg_silence_idx;
680 u32 nrg_th_cck;
681 s32 nrg_auto_corr_silence_diff;
682 u32 num_in_cck_no_fa;
683 u32 nrg_th_ofdm;
Wey-Yi Guy55036d62009-10-09 13:20:24 -0700684
685 u16 barker_corr_th_min;
686 u16 barker_corr_th_min_mrc;
687 u16 nrg_th_cca;
Zhu Yib481de92007-09-25 17:54:57 -0700688};
689
690/* Chain noise (differential Rx gain) calib data */
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700691struct iwl_chain_noise_data {
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800692 u32 active_chains;
Zhu Yib481de92007-09-25 17:54:57 -0700693 u32 chain_noise_a;
694 u32 chain_noise_b;
695 u32 chain_noise_c;
696 u32 chain_signal_a;
697 u32 chain_signal_b;
698 u32 chain_signal_c;
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800699 u16 beacon_count;
Zhu Yib481de92007-09-25 17:54:57 -0700700 u8 disconn_array[NUM_RX_CHAINS];
701 u8 delta_gain_code[NUM_RX_CHAINS];
702 u8 radio_write;
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800703 u8 state;
Zhu Yib481de92007-09-25 17:54:57 -0700704};
705
Ben Cahillabceddb2007-11-29 11:09:50 +0800706#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
707#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
Zhu Yib481de92007-09-25 17:54:57 -0700708
Wey-Yi Guy20594eb2009-08-07 15:41:39 -0700709#define IWL_TRAFFIC_ENTRIES (256)
710#define IWL_TRAFFIC_ENTRY_SIZE (64)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800711
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800712enum {
713 MEASUREMENT_READY = (1 << 0),
714 MEASUREMENT_ACTIVE = (1 << 1),
715};
716
Wey-Yi Guy0848e292009-05-22 11:01:46 -0700717enum iwl_nvm_type {
718 NVM_DEVICE_TYPE_EEPROM = 0,
719 NVM_DEVICE_TYPE_OTP,
720};
721
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700722/*
723 * Two types of OTP memory access modes
724 * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
725 * based on physical memory addressing
726 * IWL_OTP_ACCESS_RELATIVE - relative address mode,
727 * based on logical memory addressing
728 */
729enum iwl_access_mode {
730 IWL_OTP_ACCESS_ABSOLUTE,
731 IWL_OTP_ACCESS_RELATIVE,
732};
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700733
734/**
735 * enum iwl_pa_type - Power Amplifier type
736 * @IWL_PA_SYSTEM: based on uCode configuration
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700737 * @IWL_PA_INTERNAL: use Internal only
738 */
739enum iwl_pa_type {
740 IWL_PA_SYSTEM = 0,
Wey-Yi Guy740e7f52009-11-06 14:52:55 -0800741 IWL_PA_INTERNAL = 1,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700742};
743
Wey-Yi Guy91835ba2010-09-05 10:49:41 -0700744/* reply_tx_statistics (for _agn devices) */
745struct reply_tx_error_statistics {
746 u32 pp_delay;
747 u32 pp_few_bytes;
748 u32 pp_bt_prio;
749 u32 pp_quiet_period;
750 u32 pp_calc_ttak;
751 u32 int_crossed_retry;
752 u32 short_limit;
753 u32 long_limit;
754 u32 fifo_underrun;
755 u32 drain_flow;
756 u32 rfkill_flush;
757 u32 life_expire;
758 u32 dest_ps;
759 u32 host_abort;
760 u32 bt_retry;
761 u32 sta_invalid;
762 u32 frag_drop;
763 u32 tid_disable;
764 u32 fifo_flush;
765 u32 insuff_cf_poll;
766 u32 fail_hw_drop;
767 u32 sta_color_mismatch;
768 u32 unknown;
769};
770
Wey-Yi Guy814665f2010-09-05 10:49:44 -0700771/* reply_agg_tx_statistics (for _agn devices) */
772struct reply_agg_tx_error_statistics {
773 u32 underrun;
774 u32 bt_prio;
775 u32 few_bytes;
776 u32 abort;
777 u32 last_sent_ttl;
778 u32 last_sent_try;
779 u32 last_sent_bt_kill;
780 u32 scd_query;
781 u32 bad_crc32;
782 u32 response;
783 u32 dump_tx;
784 u32 delay_tx;
785 u32 unknown;
786};
787
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700788/* management statistics */
789enum iwl_mgmt_stats {
790 MANAGEMENT_ASSOC_REQ = 0,
791 MANAGEMENT_ASSOC_RESP,
792 MANAGEMENT_REASSOC_REQ,
793 MANAGEMENT_REASSOC_RESP,
794 MANAGEMENT_PROBE_REQ,
795 MANAGEMENT_PROBE_RESP,
796 MANAGEMENT_BEACON,
797 MANAGEMENT_ATIM,
798 MANAGEMENT_DISASSOC,
799 MANAGEMENT_AUTH,
800 MANAGEMENT_DEAUTH,
801 MANAGEMENT_ACTION,
802 MANAGEMENT_MAX,
803};
804/* control statistics */
805enum iwl_ctrl_stats {
806 CONTROL_BACK_REQ = 0,
807 CONTROL_BACK,
808 CONTROL_PSPOLL,
809 CONTROL_RTS,
810 CONTROL_CTS,
811 CONTROL_ACK,
812 CONTROL_CFEND,
813 CONTROL_CFENDACK,
814 CONTROL_MAX,
815};
816
817struct traffic_stats {
Wey-Yi Guy5ed540a2011-01-21 15:26:39 -0800818#ifdef CONFIG_IWLWIFI_DEBUGFS
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700819 u32 mgmt[MANAGEMENT_MAX];
820 u32 ctrl[CONTROL_MAX];
821 u32 data_cnt;
822 u64 data_bytes;
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700823#endif
Wey-Yi Guy5ed540a2011-01-21 15:26:39 -0800824};
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -0700825
Wey-Yi Guy0924e5192009-11-06 14:52:54 -0800826/*
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -0800827 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
828 * to perform continuous uCode event logging operation if enabled
829 */
830#define UCODE_TRACE_PERIOD (100)
831
832/*
833 * iwl_event_log: current uCode event log position
834 *
835 * @ucode_trace: enable/disable ucode continuous trace timer
836 * @num_wraps: how many times the event buffer wraps
837 * @next_entry: the entry just before the next one that uCode would fill
838 * @non_wraps_count: counter for no wrap detected when dump ucode events
839 * @wraps_once_count: counter for wrap once detected when dump ucode events
840 * @wraps_more_count: counter for wrap more than once detected
841 * when dump ucode events
842 */
843struct iwl_event_log {
844 bool ucode_trace;
845 u32 num_wraps;
846 u32 next_entry;
847 int non_wraps_count;
848 int wraps_once_count;
849 int wraps_more_count;
850};
851
Wey-Yi Guy2be767032010-01-15 13:43:37 -0800852/*
853 * host interrupt timeout value
854 * used with setting interrupt coalescing timer
855 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
856 *
857 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
858 * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
859 */
860#define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
861#define IWL_HOST_INT_TIMEOUT_DEF (0x40)
862#define IWL_HOST_INT_TIMEOUT_MIN (0x0)
863#define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
864#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
865#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
866
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800867/*
868 * This is the threshold value of plcp error rate per 100mSecs. It is
869 * used to set and check for the validity of plcp_delta.
870 */
Wey-Yi Guy680788a2010-06-17 15:25:00 -0700871#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800872#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
873#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
Trieu 'Andrew' Nguyen6c3872e2010-02-08 13:53:05 -0800874#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800875#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
Wey-Yi Guy680788a2010-06-17 15:25:00 -0700876#define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800877
Wey-Yi Guy8a472da2010-02-18 22:03:06 -0800878#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
879#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
880
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +0100881/* TX queue watchdog timeouts in mSecs */
882#define IWL_DEF_WD_TIMEOUT (2000)
883#define IWL_LONG_WD_TIMEOUT (10000)
884#define IWL_MAX_WD_TIMEOUT (120000)
Wey-Yi Guyb74e31a2010-03-01 17:23:50 -0800885
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700886/* BT Antenna Coupling Threshold (dB) */
887#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
888
Wey-Yi Guy491bc292011-02-09 09:37:46 -0800889/* Firmware reload counter and Timestamp */
890#define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
891#define IWL_MAX_CONTINUE_RELOAD_CNT 4
892
893
Wey-Yi Guya93e7972010-02-03 11:47:19 -0800894enum iwl_reset {
895 IWL_RF_RESET = 0,
896 IWL_FW_RESET,
Wey-Yi Guy8a472da2010-02-18 22:03:06 -0800897 IWL_MAX_FORCE_RESET,
898};
899
900struct iwl_force_reset {
901 int reset_request_count;
902 int reset_success_count;
903 int reset_reject_count;
904 unsigned long reset_duration;
905 unsigned long last_force_reset_jiffies;
Wey-Yi Guya93e7972010-02-03 11:47:19 -0800906};
907
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -0700908/* extend beacon time format bit shifting */
909/*
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -0700910 * for _agn devices
911 * bits 31:22 - extended
912 * bits 21:0 - interval
913 */
914#define IWLAGN_EXT_BEACON_TIME_POS 22
915
Johannes Berg7194207c2011-01-04 16:22:00 -0800916/**
917 * struct iwl_notification_wait - notification wait entry
918 * @list: list head for global list
919 * @fn: function called with the notification
920 * @cmd: command ID
921 *
922 * This structure is not used directly, to wait for a
923 * notification declare it on the stack, and call
924 * iwlagn_init_notification_wait() with appropriate
925 * parameters. Then do whatever will cause the ucode
926 * to notify the driver, and to wait for that then
927 * call iwlagn_wait_notification().
928 *
929 * Each notification is one-shot. If at some point we
930 * need to support multi-shot notifications (which
931 * can't be allocated on the stack) we need to modify
932 * the code for them.
933 */
934struct iwl_notification_wait {
935 struct list_head list;
936
Johannes Berg09f18af2011-04-13 03:14:47 -0700937 void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt,
938 void *data);
939 void *fn_data;
Johannes Berg7194207c2011-01-04 16:22:00 -0800940
941 u8 cmd;
Johannes Berge74fe232011-04-13 03:14:49 -0700942 bool triggered, aborted;
Johannes Berg7194207c2011-01-04 16:22:00 -0800943};
944
Johannes Berg246ed352010-08-23 10:46:32 +0200945struct iwl_rxon_context {
Johannes Berg8bd413e2010-08-23 10:46:40 +0200946 struct ieee80211_vif *vif;
Johannes Berge72f3682010-08-23 10:46:51 +0200947
Johannes Berg763cc3b2010-09-03 06:32:21 -0700948 /*
949 * We could use the vif to indicate active, but we
950 * also need it to be active during disabling when
951 * we already removed the vif for type setting.
952 */
953 bool always_active, is_active;
954
Johannes Berg2295c662010-10-23 09:15:41 -0700955 bool ht_need_multiple_chains;
956
Johannes Berg246ed352010-08-23 10:46:32 +0200957 enum iwl_rxon_context_id ctxid;
Johannes Bergd0fe4782010-08-23 10:46:58 +0200958
959 u32 interface_modes, exclusive_interface_modes;
960 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
961
Johannes Berg246ed352010-08-23 10:46:32 +0200962 /*
963 * We declare this const so it can only be
964 * changed via explicit cast within the
965 * routines that actually update the physical
966 * hardware.
967 */
968 const struct iwl_rxon_cmd active;
969 struct iwl_rxon_cmd staging;
970
971 struct iwl_rxon_time_cmd timing;
Johannes Berga194e322010-08-27 08:53:46 -0700972
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200973 struct iwl_qos_info qos_data;
974
Johannes Berg2995baf2010-08-23 10:46:42 +0200975 u8 bcast_sta_id, ap_sta_id;
Johannes Berg8f2d3d22010-08-23 10:46:37 +0200976
977 u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200978 u8 qos_cmd;
Johannes Bergc10afb62010-08-23 10:46:43 +0200979 u8 wep_key_cmd;
980
981 struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
982 u8 key_mapping_keys;
Johannes Berg770e13b2010-08-23 10:46:44 +0200983
984 __le32 station_flags;
Johannes Berg7e6a5882010-08-23 10:46:46 +0200985
Johannes Bergbbb05cb2011-07-18 01:59:22 -0700986 int beacon_int;
987
Johannes Berg7e6a5882010-08-23 10:46:46 +0200988 struct {
989 bool non_gf_sta_present;
990 u8 protection;
991 bool enabled, is_40mhz;
992 u8 extension_chan_offset;
993 } ht;
Garen Tamrazian68b99312011-03-30 02:29:32 -0700994
Johannes Bergdebcf732011-08-25 23:13:56 -0700995 u8 bssid[ETH_ALEN];
996 bool preauth_bssid;
997
Garen Tamrazian68b99312011-03-30 02:29:32 -0700998 bool last_tx_rejected;
Johannes Berg246ed352010-08-23 10:46:32 +0200999};
1000
Johannes Berg266af4c72011-03-10 20:13:26 -08001001enum iwl_scan_type {
1002 IWL_SCAN_NORMAL,
1003 IWL_SCAN_RADIO_RESET,
Johannes Bergc6baf7f2011-07-23 10:24:47 -07001004 IWL_SCAN_ROC,
Johannes Berg266af4c72011-03-10 20:13:26 -08001005};
1006
Johannes Berg872907b2011-06-06 09:41:15 -07001007enum iwlagn_ucode_type {
1008 IWL_UCODE_NONE,
1009 IWL_UCODE_REGULAR,
1010 IWL_UCODE_INIT,
1011 IWL_UCODE_WOWLAN,
1012};
1013
Wey-Yi Guy7a4e5282011-05-06 10:21:28 -07001014#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
1015struct iwl_testmode_trace {
Wey-Yi Guy49b72102011-05-30 10:29:37 -07001016 u32 buff_size;
1017 u32 total_size;
Wey-Yi Guyeb64dca2011-05-31 08:03:02 -07001018 u32 num_chunks;
Wey-Yi Guy7a4e5282011-05-06 10:21:28 -07001019 u8 *cpu_addr;
1020 u8 *trace_addr;
1021 dma_addr_t dma_addr;
1022 bool trace_enabled;
1023};
1024#endif
Emmanuel Grumbacha48709c2011-05-31 08:22:30 +03001025
Tomas Winklerc79dd5b2008-03-12 16:58:50 -07001026struct iwl_priv {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001027
Emmanuel Grumbachcac988a2011-08-25 23:10:37 -07001028 /*data shared among all the driver's layers */
1029 struct iwl_shared _shrd;
1030 struct iwl_shared *shrd;
1031
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001032 /* ieee device used by generic ieee processing code */
1033 struct ieee80211_hw *hw;
1034 struct ieee80211_channel *ieee_channels;
1035 struct ieee80211_rate *ieee_rates;
Emmanuel Grumbachdfa2bdb2011-08-25 23:11:23 -07001036 struct kmem_cache *tx_cmd_pool;
Tomas Winkler82b9a122008-03-04 18:09:30 -08001037 struct iwl_cfg *cfg;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001038
Johannes Berg8318d782008-01-24 19:38:38 +01001039 enum ieee80211_band band;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001040
Cindy H. Kao4613e722011-05-06 10:40:15 -07001041 void (*pre_rx_handler)(struct iwl_priv *priv,
1042 struct iwl_rx_mem_buffer *rxb);
Tomas Winklerc79dd5b2008-03-12 16:58:50 -07001043 void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
Tomas Winklera55360e2008-05-05 10:22:28 +08001044 struct iwl_rx_mem_buffer *rxb);
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001045
Johannes Berg8318d782008-01-24 19:38:38 +01001046 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001047
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001048 /* spectrum measurement report caching */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -08001049 struct iwl_spectrum_notification measure_report;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001050 u8 measurement_status;
Reinette Chatre81963d62010-01-22 14:22:57 -08001051
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001052 /* ucode beacon time */
1053 u32 ucode_beacon_time;
Wey-Yi Guya13d2762010-01-22 14:22:42 -08001054 int missed_beacon_threshold;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001055
Johannes Berga85d7cc2010-07-31 08:34:10 -07001056 /* track IBSS manager (last beacon) status */
1057 u32 ibss_manager;
1058
Stanislaw Gruszka410f2bb2011-03-04 17:51:51 +01001059 /* jiffies when last recovery from statistics was performed */
1060 unsigned long rx_statistics_jiffies;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -08001061
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -07001062 /*counters */
1063 u32 rx_handlers_stats[REPLY_MAX];
1064
Wey-Yi Guya93e7972010-02-03 11:47:19 -08001065 /* force reset */
Wey-Yi Guy8a472da2010-02-18 22:03:06 -08001066 struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
Wey-Yi Guya93e7972010-02-03 11:47:19 -08001067
Wey-Yi Guy491bc292011-02-09 09:37:46 -08001068 /* firmware reload counter and timestamp */
1069 unsigned long reload_jiffies;
1070 int reload_count;
1071
Wey-Yi Guy5a2a7802010-05-06 12:10:42 -07001072 /* we allocate array of iwl_channel_info for NIC's valid channels.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001073 * Access via channel # using indirect index array */
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001074 struct iwl_channel_info *channel_info; /* channel info array */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001075 u8 channel_count; /* # of channels */
1076
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001077 /* thermal calibration */
1078 s32 temperature; /* degrees Kelvin */
1079 s32 last_temperature;
1080
Tomas Winkler7c616cb2008-05-29 16:35:05 +08001081 /* init calibration results */
Tomas Winkler6e21f2c2008-09-03 11:26:37 +08001082 struct iwl_calib_result calib_results[IWL_CALIB_MAX];
Tomas Winkler7c616cb2008-05-29 16:35:05 +08001083
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001084 /* Scan related variables */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001085 unsigned long scan_start;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001086 unsigned long scan_start_tsf;
Johannes Berg811ecc92010-04-06 04:12:41 -07001087 void *scan_cmd;
Johannes Berg00700ee2010-04-06 04:12:37 -07001088 enum ieee80211_band scan_band;
Johannes Berg1ecf9fc2009-04-20 14:36:56 -07001089 struct cfg80211_scan_request *scan_request;
Johannes Bergf84b29e2010-05-18 02:29:13 -07001090 struct ieee80211_vif *scan_vif;
Johannes Berg266af4c72011-03-10 20:13:26 -08001091 enum iwl_scan_type scan_type;
Tomas Winkler76eff182008-10-14 12:32:45 -07001092 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
1093 u8 mgmt_tx_ant;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001094
Emmanuel Grumbach6ac2f832011-08-25 23:10:44 -07001095 /*TODO: remove these pointers - use bus(priv) instead */
Emmanuel Grumbachd5934112011-07-11 10:48:51 +03001096 struct iwl_bus *bus; /* bus specific data */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001097
Johannes Berg246ed352010-08-23 10:46:32 +02001098 /* microcode/device supports multiple contexts */
1099 u8 valid_contexts;
1100
Johannes Bergc10afb62010-08-23 10:46:43 +02001101 /* max number of station keys */
1102 u8 sta_key_max_num;
1103
Johannes Bergd2690c02011-04-20 09:10:39 -07001104 bool new_scan_threshold_behaviour;
1105
Wey-Yi Guyc6fa17e2010-07-15 05:58:30 -07001106 /* EEPROM MAC addresses */
1107 struct mac_address addresses[2];
1108
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001109 /* uCode images, save to reload in case of failure */
Johannes Bergb08dfd02010-01-29 11:54:56 -08001110 int fw_index; /* firmware we're trying to load */
Chatre, Reinettec02b3ac2008-12-02 12:14:05 -08001111 u32 ucode_ver; /* version of ucode, copy of
1112 iwl_ucode.ver */
Wey-Yi Guye98a1932011-07-08 08:46:26 -07001113
Johannes Bergdbf28e212011-04-16 08:29:24 -07001114 struct fw_img ucode_rt;
1115 struct fw_img ucode_init;
Johannes Bergc8ac61c2011-07-15 13:23:45 -07001116 struct fw_img ucode_wowlan;
Johannes Bergdbf28e212011-04-16 08:29:24 -07001117
Johannes Berg872907b2011-06-06 09:41:15 -07001118 enum iwlagn_ucode_type ucode_type;
Ron Rindjunskydbb983b2008-05-15 13:54:12 +08001119 u8 ucode_write_complete; /* the image write is complete */
Johannes Bergb08dfd02010-01-29 11:54:56 -08001120 char firmware_name[25];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001121
Johannes Berg246ed352010-08-23 10:46:32 +02001122 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001123
Stanislaw Gruszka6f213ff2011-06-02 18:17:15 +02001124 __le16 switch_channel;
Wey-Yi Guy0924e5192009-11-06 14:52:54 -08001125
Johannes Bergd7d57832011-04-05 09:42:04 -07001126 struct {
1127 u32 error_event_table;
1128 u32 log_event_table;
1129 } device_pointers;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001130
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001131 u16 active_rate;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001132
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001133 u8 start_calib;
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -07001134 struct iwl_sensitivity_data sensitivity_data;
1135 struct iwl_chain_noise_data chain_noise_data;
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07001136 bool enhance_sensitivity_table;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001137 __le16 sensitivity_tbl[HD_TABLE_SIZE];
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -07001138 __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001139
Johannes Bergfad95bf2009-09-11 10:38:15 -07001140 struct iwl_ht_config current_ht_config;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001141
1142 /* Rate scaling data */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001143 u8 retry_rate;
1144
1145 wait_queue_head_t wait_command_queue;
1146
1147 int activity_timer_active;
1148
Tomas Winkler19758be2008-03-12 16:58:51 -07001149 /* counts mgmt, ctl, and data packets */
Wey-Yi Guy22fdf3c2009-08-07 15:41:40 -07001150 struct traffic_stats tx_stats;
1151 struct traffic_stats rx_stats;
Tomas Winkler19758be2008-03-12 16:58:51 -07001152
Mohamed Abbas5da4b552008-04-21 15:41:51 -07001153 struct iwl_power_mgr power_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -07001154 struct iwl_tt_mgmt thermal_throttle;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001155
Reinette Chatre9c5ac092010-05-05 02:26:06 -07001156 /* station table variables */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001157 int num_stations;
Johannes Berg3240cab2011-04-05 09:41:49 -07001158 struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
Emmanuel Grumbach80fb47a2008-04-14 21:16:08 -07001159 unsigned long ucode_key_table;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001160
1161 /* Indication if ieee80211_ops->open has been called */
Tomas Winkler69dc5d92008-03-25 16:33:41 -07001162 u8 is_open;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001163
Johannes Bergaf6b8ee2009-12-14 14:12:08 -08001164 /* eeprom -- this is in the card's little endian byte order */
Tomas Winkler073d3f52008-04-21 15:41:52 -07001165 u8 *eeprom;
Wey-Yi Guy0848e292009-05-22 11:01:46 -07001166 int nvm_device_type;
Tomas Winkler073d3f52008-04-21 15:41:52 -07001167 struct iwl_eeprom_calib_info *calib_info;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001168
Johannes Berg05c914f2008-09-11 00:01:58 +02001169 enum nl80211_iftype iw_mode;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001170
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001171 /* Last Rx'd beacon timestamp */
Tomas Winkler3109ece2008-03-28 16:33:35 -07001172 u64 timestamp;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001173
Johannes Berg3240cab2011-04-05 09:41:49 -07001174 struct {
Johannes Berg0da0e5b2011-04-08 08:14:56 -07001175 __le32 flag;
1176 struct statistics_general_common common;
1177 struct statistics_rx_non_phy rx_non_phy;
1178 struct statistics_rx_phy rx_ofdm;
1179 struct statistics_rx_ht_phy rx_ofdm_ht;
1180 struct statistics_rx_phy rx_cck;
1181 struct statistics_tx tx;
1182#ifdef CONFIG_IWLWIFI_DEBUGFS
1183 struct statistics_bt_activity bt_activity;
1184 __le32 num_bt_kills, accum_num_bt_kills;
1185#endif
1186 } statistics;
1187#ifdef CONFIG_IWLWIFI_DEBUGFS
1188 struct {
1189 struct statistics_general_common common;
1190 struct statistics_rx_non_phy rx_non_phy;
1191 struct statistics_rx_phy rx_ofdm;
1192 struct statistics_rx_ht_phy rx_ofdm_ht;
1193 struct statistics_rx_phy rx_cck;
1194 struct statistics_tx tx;
1195 struct statistics_bt_activity bt_activity;
1196 } accum_stats, delta_stats, max_delta_stats;
1197#endif
1198
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001199 /*
1200 * reporting the number of tids has AGG on. 0 means
1201 * no AGGREGATION
1202 */
1203 u8 agg_tids_count;
Johannes Bergee525d12010-01-21 06:09:28 -08001204
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001205 struct iwl_rx_phy_res last_phy_res;
1206 bool last_phy_res_valid;
Johannes Bergee525d12010-01-21 06:09:28 -08001207
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001208 struct completion firmware_loading_complete;
Johannes Berg3240cab2011-04-05 09:41:49 -07001209
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001210 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
1211 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
Johannes Berg3240cab2011-04-05 09:41:49 -07001212
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001213 /*
1214 * chain noise reset and gain commands are the
1215 * two extra calibration commands follows the standard
1216 * phy calibration commands
1217 */
1218 u8 phy_calib_chain_noise_reset_cmd;
1219 u8 phy_calib_chain_noise_gain_cmd;
Johannes Berg3240cab2011-04-05 09:41:49 -07001220
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001221 /* counts reply_tx error */
1222 struct reply_tx_error_statistics reply_tx_stats;
1223 struct reply_agg_tx_error_statistics reply_agg_tx_stats;
1224 /* notification wait support */
1225 struct list_head notif_waits;
1226 spinlock_t notif_wait_lock;
1227 wait_queue_head_t notif_waitq;
Johannes Bergee525d12010-01-21 06:09:28 -08001228
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001229 /* remain-on-channel offload support */
1230 struct ieee80211_channel *hw_roc_channel;
Johannes Bergc6baf7f2011-07-23 10:24:47 -07001231 struct delayed_work hw_roc_disable_work;
Wey-Yi Guy898ed672011-07-13 08:38:57 -07001232 enum nl80211_channel_type hw_roc_chantype;
1233 int hw_roc_duration;
1234 bool hw_roc_setup;
Johannes Berge99f168c2010-01-19 10:04:28 -08001235
Wey-Yi Guy22bf59a2010-08-23 07:57:11 -07001236 /* bt coex */
Wey-Yi Guyf21dd002010-12-08 15:34:52 -08001237 u8 bt_enable_flag;
Wey-Yi Guyda5dbb92010-08-23 07:57:13 -07001238 u8 bt_status;
Wey-Yi Guy66e863a52010-11-08 14:54:37 -08001239 u8 bt_traffic_load, last_bt_traffic_load;
Wey-Yi Guyf37837c2010-08-23 07:57:12 -07001240 bool bt_ch_announce;
Wey-Yi Guybee008b2010-08-23 07:57:04 -07001241 bool bt_full_concurrent;
1242 bool bt_ant_couple_ok;
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07001243 __le32 kill_ack_mask;
1244 __le32 kill_cts_mask;
1245 __le16 bt_valid;
Wey-Yi Guy22bf59a2010-08-23 07:57:11 -07001246 u16 bt_on_thresh;
1247 u16 bt_duration;
1248 u16 dynamic_frag_thresh;
Wey-Yi Guybee008b2010-08-23 07:57:04 -07001249 u8 bt_ci_compliance;
Johannes Berg9e4afc22010-08-23 07:56:57 -07001250 struct work_struct bt_traffic_change_work;
Meenakshi Venkataraman207ecc52011-07-08 08:46:23 -07001251 bool bt_enable_pspoll;
1252 struct iwl_rxon_context *cur_rssi_ctx;
1253 bool bt_is_sco;
Johannes Berg9e4afc22010-08-23 07:56:57 -07001254
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001255 struct work_struct restart;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001256 struct work_struct scan_completed;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001257 struct work_struct abort_scan;
Johannes Berg12e934d2010-10-04 05:50:06 -07001258
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001259 struct work_struct beacon_update;
Johannes Berg76d04812010-08-23 10:46:47 +02001260 struct iwl_rxon_context *beacon_ctx;
Johannes Berg12e934d2010-10-04 05:50:06 -07001261 struct sk_buff *beacon_skb;
Johannes Berg4ce7cc22011-05-13 11:57:40 -07001262 void *beacon_cmd;
Johannes Berg76d04812010-08-23 10:46:47 +02001263
Wey-Yi Guya28027cd2009-08-07 15:41:45 -07001264 struct work_struct tt_work;
1265 struct work_struct ct_enter;
1266 struct work_struct ct_exit;
Johannes Berg88be0262010-04-07 00:21:36 -07001267 struct work_struct start_internal_scan;
Wey-Yi Guy65550632010-06-24 13:18:35 -07001268 struct work_struct tx_flush;
Wey-Yi Guybee008b2010-08-23 07:57:04 -07001269 struct work_struct bt_full_concurrency;
Wey-Yi Guyfbba9412010-08-23 07:57:10 -07001270 struct work_struct bt_runtime_config;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001271
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001272 struct delayed_work scan_check;
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +08001273
Tomas Winkler630fe9b2008-06-12 09:47:08 +08001274 /* TX Power */
1275 s8 tx_power_user_lmt;
Wey-Yi Guydc1b0972009-08-21 13:34:16 -07001276 s8 tx_power_device_lmt;
Wey-Yi Guyae16fc3c2009-11-13 11:56:30 -08001277 s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */
Stanislaw Gruszkaa25a66a2010-10-22 17:04:26 +02001278 s8 tx_power_next;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001279
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001280#ifdef CONFIG_IWLWIFI_DEBUGFS
1281 /* debugfs */
Wey-Yi Guy20594eb2009-08-07 15:41:39 -07001282 u16 tx_traffic_idx;
1283 u16 rx_traffic_idx;
1284 u8 *tx_traffic;
1285 u8 *rx_traffic;
Johannes Berg4c84a8f2010-01-22 14:22:54 -08001286 struct dentry *debugfs_dir;
1287 u32 dbgfs_sram_offset, dbgfs_sram_len;
Johannes Bergd73e4922010-05-06 12:18:41 -07001288 bool disable_ht40;
Johannes Bergc8ac61c2011-07-15 13:23:45 -07001289 void *wowlan_sram;
Tomas Winkler712b6cf2008-03-12 16:58:52 -07001290#endif /* CONFIG_IWLWIFI_DEBUGFS */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001291
1292 struct work_struct txpower_work;
Tomas Winkler445c2df2008-05-15 13:54:16 +08001293 u32 disable_sens_cal;
1294 u32 disable_chain_noise_cal;
Emmanuel Grumbach16e727e2008-06-12 09:46:52 +08001295 struct work_struct run_time_calib_work;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001296 struct timer_list statistics_periodic;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001297 struct timer_list ucode_trace;
Stanislaw Gruszka22de94d2010-12-03 15:41:48 +01001298 struct timer_list watchdog;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -08001299
1300 struct iwl_event_log event_log;
Wey-Yi Guy5ed540a2011-01-21 15:26:39 -08001301
1302 struct led_classdev led;
1303 unsigned long blink_on, blink_off;
1304 bool led_registered;
Wey-Yi Guy7a4e5282011-05-06 10:21:28 -07001305#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
1306 struct iwl_testmode_trace testmode_trace;
Wey-Yi Guy4e308112011-07-08 08:46:28 -07001307 u32 tm_fixed_rate;
Wey-Yi Guyc10e2c12011-07-13 11:13:46 -07001308#endif
Wey-Yi Guy64898542011-05-03 18:05:13 -07001309
Johannes Bergc8ac61c2011-07-15 13:23:45 -07001310 /* WoWLAN GTK rekey data */
1311 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
1312 __le64 replay_ctr;
1313 __le16 last_seq_ctl;
1314 bool have_rekey_data;
Tomas Winklerc79dd5b2008-03-12 16:58:50 -07001315}; /*iwl_priv */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001316
Emmanuel Grumbach48f20d32011-08-25 23:10:36 -07001317extern struct iwl_mod_params iwlagn_mod_params;
1318
Johannes Berg246ed352010-08-23 10:46:32 +02001319static inline struct iwl_rxon_context *
1320iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001321{
Johannes Berg246ed352010-08-23 10:46:32 +02001322 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1323
1324 return vif_priv->ctx;
1325}
1326
1327#define for_each_context(priv, ctx) \
1328 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
1329 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
1330 if (priv->valid_contexts & BIT(ctx->ctxid))
1331
Johannes Berg054ec922011-05-06 11:11:20 -07001332static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
1333{
1334 return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
1335}
1336
Johannes Berg246ed352010-08-23 10:46:32 +02001337static inline int iwl_is_associated(struct iwl_priv *priv,
1338 enum iwl_rxon_context_id ctxid)
1339{
Johannes Berg054ec922011-05-06 11:11:20 -07001340 return iwl_is_associated_ctx(&priv->contexts[ctxid]);
Johannes Berg246ed352010-08-23 10:46:32 +02001341}
1342
1343static inline int iwl_is_any_associated(struct iwl_priv *priv)
1344{
Johannes Berg054ec922011-05-06 11:11:20 -07001345 struct iwl_rxon_context *ctx;
1346 for_each_context(priv, ctx)
1347 if (iwl_is_associated_ctx(ctx))
1348 return true;
1349 return false;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001350}
1351
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001352static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001353{
1354 if (ch_info == NULL)
1355 return 0;
1356 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
1357}
1358
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001359static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001360{
1361 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
1362}
1363
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001364static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001365{
Johannes Berg8318d782008-01-24 19:38:38 +01001366 return ch_info->band == IEEE80211_BAND_5GHZ;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001367}
1368
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001369static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001370{
Johannes Berg8318d782008-01-24 19:38:38 +01001371 return ch_info->band == IEEE80211_BAND_2GHZ;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001372}
1373
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001374static inline int is_channel_passive(const struct iwl_channel_info *ch)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001375{
1376 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
1377}
1378
Assaf Kraussbf85ea42008-03-14 10:38:49 -07001379static inline int is_channel_ibss(const struct iwl_channel_info *ch)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +08001380{
1381 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
1382}
1383
Emmanuel Grumbachbe1f3ab62008-06-12 09:47:18 +08001384#endif /* __iwl_dev_h__ */