blob: 0ba3e56d6015b16feb34acc71c36a81d42453eb6 [file] [log] [blame]
Zhu Yib481de92007-09-25 17:54:57 -07001/******************************************************************************
2 *
Emmanuel Grumbach51368bf2013-12-30 13:15:54 +02003 * Copyright(c) 2003 - 2014 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/*
Johannes Berg1023fdc2012-05-15 12:16:34 +020027 * Please use this file (dev.h) for driver implementation definitions.
28 * Please use 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/kernel.h>
Johannes Berg7194207c2011-01-04 16:22:00 -080036#include <linux/wait.h>
Wey-Yi Guy5ed540a2011-01-21 15:26:39 -080037#include <linux/leds.h>
Emmanuel Grumbachdfa2bdb2011-08-25 23:11:23 -070038#include <linux/slab.h>
Johannes Bergb1eea292012-03-06 13:30:42 -080039#include <linux/mutex.h>
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080040
Johannes Berg6238b002012-04-02 15:04:33 +020041#include "iwl-fw.h"
Johannes Berg26a7ca92012-05-21 11:55:54 +020042#include "iwl-eeprom-parse.h"
Winkler, Tomasdbb66542008-12-22 11:31:14 +080043#include "iwl-csr.h"
Winkler, Tomasdbb66542008-12-22 11:31:14 +080044#include "iwl-debug.h"
Wey-Yi Guyb744cb72010-03-23 11:37:59 -070045#include "iwl-agn-hw.h"
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +020046#include "iwl-op-mode.h"
Johannes Berg4bd14dd2012-03-06 13:30:58 -080047#include "iwl-notif-wait.h"
Johannes Berg1023fdc2012-05-15 12:16:34 +020048#include "iwl-trans.h"
49
Johannes Berg1023fdc2012-05-15 12:16:34 +020050#include "led.h"
51#include "power.h"
52#include "rs.h"
53#include "tt.h"
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080054
Ron Rindjunsky099b40b2008-04-21 15:41:53 -070055/* CT-KILL constants */
Wey-Yi Guy672639d2009-07-24 11:13:01 -070056#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
57#define CT_KILL_THRESHOLD 114 /* in Celsius */
58#define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
Tomas Winkler4bf775c2008-03-04 18:09:31 -080059
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080060/* Default noise level to report when noise measurement is not available.
61 * This may be because we're:
Wey-Yi Guyc4db6162011-11-30 00:14:53 -080062 * 1) Not associated no beacon statistics being sent to driver)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080063 * 2) Scanning (noise measurement does not apply to associated channel)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080064 * Use default noise value of -127 ... this is below the range of measurable
Wey-Yi Guyc4db6162011-11-30 00:14:53 -080065 * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080066 * Also, -127 works better than 0 when averaging frames with/without
67 * noise info (e.g. averaging might be done in app); measured dBm values are
68 * always negative ... using a negative value as the default keeps all
69 * averages within an s8's (used in some apps) range of negative values. */
70#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
71
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080072/*
73 * RTS threshold here is total size [2347] minus 4 FCS bytes
74 * Per spec:
75 * a value of 0 means RTS on all data/management packets
76 * a value > max MSDU size means no RTS
77 * else RTS for data/management frames where MPDU is larger
78 * than RTS value.
79 */
80#define DEFAULT_RTS_THRESHOLD 2347U
81#define MIN_RTS_THRESHOLD 0U
82#define MAX_RTS_THRESHOLD 2347U
83#define MAX_MSDU_SIZE 2304U
84#define MAX_MPDU_SIZE 2346U
Johannes Berg51b7ef02011-05-11 08:17:20 -070085#define DEFAULT_BEACON_INTERVAL 200U
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080086#define DEFAULT_SHORT_RETRY_LIMIT 7U
87#define DEFAULT_LONG_RETRY_LIMIT 4U
88
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080089#define IWL_NUM_SCAN_RATES (2)
90
Wey-Yi Guybd35f152009-10-09 13:20:23 -070091
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080092#define IEEE80211_DATA_LEN 2304
93#define IEEE80211_4ADDR_LEN 30
94#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
95#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
96
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080097#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
98#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
99#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
100
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800101#define IWL_SUPPORTED_RATES_IE_LEN 8
102
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800103#define IWL_INVALID_RATE 0xFF
104#define IWL_INVALID_VALUE -1
105
Kolekar, Abhijeeta78fe752008-12-19 10:37:21 +0800106union iwl_ht_rate_supp {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800107 u16 rates;
108 struct {
109 u8 siso_rate;
110 u8 mimo_rate;
111 };
112};
113
Johannes Bergfad95bf2009-09-11 10:38:15 -0700114struct iwl_ht_config {
Johannes Berg02bb1be2009-09-11 10:38:17 -0700115 bool single_chain_sufficient;
Johannes Bergba37a3d2009-12-10 14:37:27 -0800116 enum ieee80211_smps_mode smps; /* current smps mode */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800117};
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800118
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800119/* QoS structures */
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800120struct iwl_qos_info {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800121 int qos_active;
Emmanuel Grumbach1ff50bd2008-07-11 11:53:34 +0800122 struct iwl_qosparam_cmd def_qos_parm;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800123};
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800124
Emmanuel Grumbach04cf6822011-11-23 11:06:12 +0200125/**
126 * enum iwl_agg_state
127 *
128 * The state machine of the BA agreement establishment / tear down.
129 * These states relate to a specific RA / TID.
130 *
131 * @IWL_AGG_OFF: aggregation is not used
Emmanuel Grumbach682e5f62012-03-26 15:50:55 +0200132 * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
Emmanuel Grumbach04cf6822011-11-23 11:06:12 +0200133 * @IWL_AGG_ON: aggregation session is up
134 * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the
135 * HW queue to be empty from packets for this RA /TID.
136 * @IWL_EMPTYING_HW_QUEUE_DELBA: tearing down a BA session - waiting for the
137 * HW queue to be empty from packets for this RA /TID.
138 */
139enum iwl_agg_state {
140 IWL_AGG_OFF = 0,
Emmanuel Grumbach682e5f62012-03-26 15:50:55 +0200141 IWL_AGG_STARTING,
Emmanuel Grumbach04cf6822011-11-23 11:06:12 +0200142 IWL_AGG_ON,
143 IWL_EMPTYING_HW_QUEUE_ADDBA,
144 IWL_EMPTYING_HW_QUEUE_DELBA,
145};
146
147/**
148 * struct iwl_ht_agg - aggregation state machine
149
150 * This structs holds the states for the BA agreement establishment and tear
151 * down. It also holds the state during the BA session itself. This struct is
152 * duplicated for each RA / TID.
153
154 * @rate_n_flags: Rate at which Tx was attempted. Holds the data between the
155 * Tx response (REPLY_TX), and the block ack notification
156 * (REPLY_COMPRESSED_BA).
157 * @state: state of the BA agreement establishment / tear down.
Johannes Berg9eae88f2012-03-15 13:26:52 -0700158 * @txq_id: Tx queue used by the BA session
Emmanuel Grumbach04cf6822011-11-23 11:06:12 +0200159 * @ssn: the first packet to be sent in AGG HW queue in Tx AGG start flow, or
160 * the first packet to be sent in legacy HW queue in Tx AGG stop flow.
161 * Basically when next_reclaimed reaches ssn, we can tell mac80211 that
162 * we are ready to finish the Tx AGG stop / start flow.
163 * @wait_for_ba: Expect block-ack before next Tx reply
164 */
165struct iwl_ht_agg {
166 u32 rate_n_flags;
167 enum iwl_agg_state state;
168 u16 txq_id;
169 u16 ssn;
170 bool wait_for_ba;
171};
172
173/**
174 * struct iwl_tid_data - one for each RA / TID
175
176 * This structs holds the states for each RA / TID.
177
178 * @seq_number: the next WiFi sequence number to use
179 * @next_reclaimed: the WiFi sequence number of the next packet to be acked.
180 * This is basically (last acked packet++).
181 * @agg: aggregation state machine
182 */
183struct iwl_tid_data {
184 u16 seq_number;
185 u16 next_reclaimed;
186 struct iwl_ht_agg agg;
187};
188
Reinette Chatrefe6b23d2010-02-22 16:24:47 -0800189/*
190 * Structure should be accessed with sta_lock held. When station addition
191 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
192 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
193 * held.
194 */
Tomas Winkler6def9762008-05-05 10:22:31 +0800195struct iwl_station_entry {
Tomas Winkler133636d2008-05-05 10:22:34 +0800196 struct iwl_addsta_cmd sta;
Johannes Bergdcef7322010-08-27 08:55:52 -0700197 u8 used, ctxid;
Reinette Chatrefe6b23d2010-02-22 16:24:47 -0800198 struct iwl_link_quality_cmd *lq;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800199};
200
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700201/*
202 * iwl_station_priv: Driver's private station information
203 *
204 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
205 * in the structure for use by driver. This structure is places in that
206 * space.
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700207 */
208struct iwl_station_priv {
Johannes Bergc6892902011-09-20 15:37:21 -0700209 struct iwl_rxon_context *ctx;
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700210 struct iwl_lq_sta lq_sta;
Johannes Berg6ab10ff2009-11-13 11:56:37 -0800211 atomic_t pending_frames;
212 bool client;
213 bool asleep;
Johannes Berg7b090682011-01-19 02:53:54 -0800214 u8 max_agg_bufsize;
Johannes Bergc6892902011-09-20 15:37:21 -0700215 u8 sta_id;
Reinette Chatre8d9698b2009-10-16 14:25:55 -0700216};
217
Johannes Bergfd1af152010-04-30 11:30:43 -0700218/**
219 * struct iwl_vif_priv - driver's private per-interface information
220 *
221 * When mac80211 allocates a virtual interface, it can allocate
222 * space for us to put data into.
223 */
224struct iwl_vif_priv {
Johannes Berg246ed352010-08-23 10:46:32 +0200225 struct iwl_rxon_context *ctx;
Johannes Bergfd1af152010-04-30 11:30:43 -0700226 u8 ibss_bssid_sta_id;
227};
228
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700229struct iwl_sensitivity_ranges {
230 u16 min_nrg_cck;
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700231
232 u16 nrg_th_cck;
233 u16 nrg_th_ofdm;
234
235 u16 auto_corr_min_ofdm;
236 u16 auto_corr_min_ofdm_mrc;
237 u16 auto_corr_min_ofdm_x1;
238 u16 auto_corr_min_ofdm_mrc_x1;
239
240 u16 auto_corr_max_ofdm;
241 u16 auto_corr_max_ofdm_mrc;
242 u16 auto_corr_max_ofdm_x1;
243 u16 auto_corr_max_ofdm_mrc_x1;
244
245 u16 auto_corr_max_cck;
246 u16 auto_corr_max_cck_mrc;
247 u16 auto_corr_min_cck;
248 u16 auto_corr_min_cck_mrc;
Wey-Yi Guy55036d62009-10-09 13:20:24 -0700249
250 u16 barker_corr_th_min;
251 u16 barker_corr_th_min_mrc;
252 u16 nrg_th_cca;
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700253};
254
Ron Rindjunsky099b40b2008-04-21 15:41:53 -0700255
Tomas Winklerb5047f72008-12-11 10:33:39 -0800256#define KELVIN_TO_CELSIUS(x) ((x)-273)
257#define CELSIUS_TO_KELVIN(x) ((x)+273)
258
259
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800260/******************************************************************************
261 *
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800262 * Functions implemented in core module which are forward declared here
263 * for use by iwl-[4-5].c
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800264 *
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800265 * NOTE: The implementation of these functions are not hardware specific
266 * which is why they are in the core module files.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800267 *
268 * Naming convention --
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800269 * iwl_ <-- Is part of iwlwifi
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800270 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800271 *
272 ****************************************************************************/
Joe Perchesb3818392013-09-23 11:37:59 -0700273void iwl_update_chain_flags(struct iwl_priv *priv);
Emmanuel Grumbacha33c2f42008-09-03 11:26:56 +0800274extern const u8 iwl_bcast_addr[ETH_ALEN];
Tomas Winklerfd4abac2008-05-15 13:54:07 +0800275
Zhu Yib481de92007-09-25 17:54:57 -0700276#define IWL_OPERATION_MODE_AUTO 0
277#define IWL_OPERATION_MODE_HT_ONLY 1
278#define IWL_OPERATION_MODE_MIXED 2
279#define IWL_OPERATION_MODE_20MHZ 3
280
Zhu Yib481de92007-09-25 17:54:57 -0700281#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
Zhu Yib481de92007-09-25 17:54:57 -0700282
Zhu Yib481de92007-09-25 17:54:57 -0700283/* Sensitivity and chain noise calibration */
Zhu Yib481de92007-09-25 17:54:57 -0700284#define INITIALIZATION_VALUE 0xFFFF
Wey-Yi Guyd8c07e72009-09-25 14:24:26 -0700285#define IWL_CAL_NUM_BEACONS 16
Zhu Yib481de92007-09-25 17:54:57 -0700286#define MAXIMUM_ALLOWED_PATHLOSS 15
287
Zhu Yib481de92007-09-25 17:54:57 -0700288#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
289
290#define MAX_FA_OFDM 50
291#define MIN_FA_OFDM 5
292#define MAX_FA_CCK 50
293#define MIN_FA_CCK 5
294
Zhu Yib481de92007-09-25 17:54:57 -0700295#define AUTO_CORR_STEP_OFDM 1
296
Zhu Yib481de92007-09-25 17:54:57 -0700297#define AUTO_CORR_STEP_CCK 3
298#define AUTO_CORR_MAX_TH_CCK 160
299
Zhu Yib481de92007-09-25 17:54:57 -0700300#define NRG_DIFF 2
301#define NRG_STEP_CCK 2
302#define NRG_MARGIN 8
303#define MAX_NUMBER_CCK_NO_FA 100
304
305#define AUTO_CORR_CCK_MIN_VAL_DEF (125)
306
307#define CHAIN_A 0
308#define CHAIN_B 1
309#define CHAIN_C 2
310#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
311#define ALL_BAND_FILTER 0xFF00
312#define IN_BAND_FILTER 0xFF
313#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
314
Tomas Winkler3195cdb2008-04-23 17:15:00 -0700315#define NRG_NUM_PREV_STAT_L 20
316#define NUM_RX_CHAINS 3
317
Johannes Berg3240cab2011-04-05 09:41:49 -0700318enum iwlagn_false_alarm_state {
Zhu Yib481de92007-09-25 17:54:57 -0700319 IWL_FA_TOO_MANY = 0,
320 IWL_FA_TOO_FEW = 1,
321 IWL_FA_GOOD_RANGE = 2,
322};
323
Johannes Berg3240cab2011-04-05 09:41:49 -0700324enum iwlagn_chain_noise_state {
Zhu Yib481de92007-09-25 17:54:57 -0700325 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800326 IWL_CHAIN_NOISE_ACCUMULATE,
327 IWL_CHAIN_NOISE_CALIBRATED,
328 IWL_CHAIN_NOISE_DONE,
Zhu Yib481de92007-09-25 17:54:57 -0700329};
330
Zhu Yib481de92007-09-25 17:54:57 -0700331/* Sensitivity calib data */
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700332struct iwl_sensitivity_data {
Zhu Yib481de92007-09-25 17:54:57 -0700333 u32 auto_corr_ofdm;
334 u32 auto_corr_ofdm_mrc;
335 u32 auto_corr_ofdm_x1;
336 u32 auto_corr_ofdm_mrc_x1;
337 u32 auto_corr_cck;
338 u32 auto_corr_cck_mrc;
339
340 u32 last_bad_plcp_cnt_ofdm;
341 u32 last_fa_cnt_ofdm;
342 u32 last_bad_plcp_cnt_cck;
343 u32 last_fa_cnt_cck;
344
345 u32 nrg_curr_state;
346 u32 nrg_prev_state;
347 u32 nrg_value[10];
348 u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
349 u32 nrg_silence_ref;
350 u32 nrg_energy_idx;
351 u32 nrg_silence_idx;
352 u32 nrg_th_cck;
353 s32 nrg_auto_corr_silence_diff;
354 u32 num_in_cck_no_fa;
355 u32 nrg_th_ofdm;
Wey-Yi Guy55036d62009-10-09 13:20:24 -0700356
357 u16 barker_corr_th_min;
358 u16 barker_corr_th_min_mrc;
359 u16 nrg_th_cca;
Zhu Yib481de92007-09-25 17:54:57 -0700360};
361
362/* Chain noise (differential Rx gain) calib data */
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700363struct iwl_chain_noise_data {
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800364 u32 active_chains;
Zhu Yib481de92007-09-25 17:54:57 -0700365 u32 chain_noise_a;
366 u32 chain_noise_b;
367 u32 chain_noise_c;
368 u32 chain_signal_a;
369 u32 chain_signal_b;
370 u32 chain_signal_c;
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800371 u16 beacon_count;
Zhu Yib481de92007-09-25 17:54:57 -0700372 u8 disconn_array[NUM_RX_CHAINS];
373 u8 delta_gain_code[NUM_RX_CHAINS];
374 u8 radio_write;
Grumbach, Emmanuel04816442008-09-03 11:26:53 +0800375 u8 state;
Zhu Yib481de92007-09-25 17:54:57 -0700376};
377
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800378enum {
379 MEASUREMENT_READY = (1 << 0),
380 MEASUREMENT_ACTIVE = (1 << 1),
381};
382
Wey-Yi Guy91835ba2010-09-05 10:49:41 -0700383/* reply_tx_statistics (for _agn devices) */
384struct reply_tx_error_statistics {
385 u32 pp_delay;
386 u32 pp_few_bytes;
387 u32 pp_bt_prio;
388 u32 pp_quiet_period;
389 u32 pp_calc_ttak;
390 u32 int_crossed_retry;
391 u32 short_limit;
392 u32 long_limit;
393 u32 fifo_underrun;
394 u32 drain_flow;
395 u32 rfkill_flush;
396 u32 life_expire;
397 u32 dest_ps;
398 u32 host_abort;
399 u32 bt_retry;
400 u32 sta_invalid;
401 u32 frag_drop;
402 u32 tid_disable;
403 u32 fifo_flush;
404 u32 insuff_cf_poll;
405 u32 fail_hw_drop;
406 u32 sta_color_mismatch;
407 u32 unknown;
408};
409
Wey-Yi Guy814665f2010-09-05 10:49:44 -0700410/* reply_agg_tx_statistics (for _agn devices) */
411struct reply_agg_tx_error_statistics {
412 u32 underrun;
413 u32 bt_prio;
414 u32 few_bytes;
415 u32 abort;
416 u32 last_sent_ttl;
417 u32 last_sent_try;
418 u32 last_sent_bt_kill;
419 u32 scd_query;
420 u32 bad_crc32;
421 u32 response;
422 u32 dump_tx;
423 u32 delay_tx;
424 u32 unknown;
425};
426
Wey-Yi Guy0924e5192009-11-06 14:52:54 -0800427/*
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -0800428 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
429 * to perform continuous uCode event logging operation if enabled
430 */
Johannes Berg98d4bf02012-01-13 11:56:11 +0100431#define UCODE_TRACE_PERIOD (10)
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -0800432
433/*
434 * iwl_event_log: current uCode event log position
435 *
436 * @ucode_trace: enable/disable ucode continuous trace timer
437 * @num_wraps: how many times the event buffer wraps
438 * @next_entry: the entry just before the next one that uCode would fill
439 * @non_wraps_count: counter for no wrap detected when dump ucode events
440 * @wraps_once_count: counter for wrap once detected when dump ucode events
441 * @wraps_more_count: counter for wrap more than once detected
442 * when dump ucode events
443 */
444struct iwl_event_log {
445 bool ucode_trace;
446 u32 num_wraps;
447 u32 next_entry;
448 int non_wraps_count;
449 int wraps_once_count;
450 int wraps_more_count;
451};
452
Wey-Yi Guy8a472da2010-02-18 22:03:06 -0800453#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
Wey-Yi Guy8a472da2010-02-18 22:03:06 -0800454
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700455/* BT Antenna Coupling Threshold (dB) */
456#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
457
Wey-Yi Guy491bc292011-02-09 09:37:46 -0800458/* Firmware reload counter and Timestamp */
459#define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
460#define IWL_MAX_CONTINUE_RELOAD_CNT 4
461
462
Johannes Berg48dffd32012-04-09 17:46:57 -0700463struct iwl_rf_reset {
Wey-Yi Guy8a472da2010-02-18 22:03:06 -0800464 int reset_request_count;
465 int reset_success_count;
466 int reset_reject_count;
Johannes Berg48dffd32012-04-09 17:46:57 -0700467 unsigned long last_reset_jiffies;
Wey-Yi Guya93e7972010-02-03 11:47:19 -0800468};
469
Emmanuel Grumbach4806f622012-03-25 22:01:28 +0200470enum iwl_rxon_context_id {
471 IWL_RXON_CTX_BSS,
472 IWL_RXON_CTX_PAN,
473
474 NUM_IWL_RXON_CTX
475};
476
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -0700477/* extend beacon time format bit shifting */
478/*
Wey-Yi Guya0ee74c2010-05-06 08:54:10 -0700479 * for _agn devices
480 * bits 31:22 - extended
481 * bits 21:0 - interval
482 */
483#define IWLAGN_EXT_BEACON_TIME_POS 22
484
Johannes Berg246ed352010-08-23 10:46:32 +0200485struct iwl_rxon_context {
Johannes Berg8bd413e2010-08-23 10:46:40 +0200486 struct ieee80211_vif *vif;
Johannes Berge72f3682010-08-23 10:46:51 +0200487
Johannes Berg9eae88f2012-03-15 13:26:52 -0700488 u8 mcast_queue;
489 u8 ac_to_queue[IEEE80211_NUM_ACS];
490 u8 ac_to_fifo[IEEE80211_NUM_ACS];
491
Johannes Berg763cc3b2010-09-03 06:32:21 -0700492 /*
493 * We could use the vif to indicate active, but we
494 * also need it to be active during disabling when
495 * we already removed the vif for type setting.
496 */
497 bool always_active, is_active;
498
Johannes Berg2295c662010-10-23 09:15:41 -0700499 bool ht_need_multiple_chains;
500
Johannes Berg246ed352010-08-23 10:46:32 +0200501 enum iwl_rxon_context_id ctxid;
Johannes Bergd0fe4782010-08-23 10:46:58 +0200502
503 u32 interface_modes, exclusive_interface_modes;
504 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
505
Johannes Berg246ed352010-08-23 10:46:32 +0200506 /*
507 * We declare this const so it can only be
508 * changed via explicit cast within the
509 * routines that actually update the physical
510 * hardware.
511 */
512 const struct iwl_rxon_cmd active;
513 struct iwl_rxon_cmd staging;
514
515 struct iwl_rxon_time_cmd timing;
Johannes Berga194e322010-08-27 08:53:46 -0700516
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200517 struct iwl_qos_info qos_data;
518
Johannes Berg2995baf2010-08-23 10:46:42 +0200519 u8 bcast_sta_id, ap_sta_id;
Johannes Berg8f2d3d22010-08-23 10:46:37 +0200520
521 u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
Johannes Berg8dfdb9d2010-08-23 10:46:38 +0200522 u8 qos_cmd;
Johannes Bergc10afb62010-08-23 10:46:43 +0200523 u8 wep_key_cmd;
524
525 struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
526 u8 key_mapping_keys;
Johannes Berg770e13b2010-08-23 10:46:44 +0200527
528 __le32 station_flags;
Johannes Berg7e6a5882010-08-23 10:46:46 +0200529
Johannes Bergbbb05cb2011-07-18 01:59:22 -0700530 int beacon_int;
531
Johannes Berg7e6a5882010-08-23 10:46:46 +0200532 struct {
533 bool non_gf_sta_present;
534 u8 protection;
535 bool enabled, is_40mhz;
536 u8 extension_chan_offset;
537 } ht;
Johannes Berg246ed352010-08-23 10:46:32 +0200538};
539
Johannes Berg266af4c72011-03-10 20:13:26 -0800540enum iwl_scan_type {
541 IWL_SCAN_NORMAL,
542 IWL_SCAN_RADIO_RESET,
Johannes Berg266af4c72011-03-10 20:13:26 -0800543};
544
Johannes Berg9e295112012-04-09 17:46:55 -0700545/**
546 * struct iwl_hw_params
547 *
548 * Holds the module parameters
549 *
550 * @tx_chains_num: Number of TX chains
551 * @rx_chains_num: Number of RX chains
Johannes Berg9e295112012-04-09 17:46:55 -0700552 * @ct_kill_threshold: temperature threshold - in hw dependent unit
553 * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit
554 * relevant for 1000, 6000 and up
555 * @struct iwl_sensitivity_ranges: range of sensitivity values
556 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
557 */
558struct iwl_hw_params {
559 u8 tx_chains_num;
560 u8 rx_chains_num;
Johannes Berg9e295112012-04-09 17:46:55 -0700561 bool use_rts_for_aggregation;
Johannes Berg9e295112012-04-09 17:46:55 -0700562 u32 ct_kill_threshold;
563 u32 ct_kill_exit_threshold;
564
565 const struct iwl_sensitivity_ranges *sens;
566};
567
Johannes Berg0d8877a2013-05-17 10:36:29 +0200568/**
569 * struct iwl_dvm_bt_params - DVM specific BT (coex) parameters
570 * @advanced_bt_coexist: support advanced bt coexist
571 * @bt_init_traffic_load: specify initial bt traffic load
572 * @bt_prio_boost: default bt priority boost value
573 * @agg_time_limit: maximum number of uSec in aggregation
574 * @bt_sco_disable: uCode should not response to BT in SCO/ESCO mode
575 */
576struct iwl_dvm_bt_params {
577 bool advanced_bt_coexist;
578 u8 bt_init_traffic_load;
579 u32 bt_prio_boost;
580 u16 agg_time_limit;
581 bool bt_sco_disable;
582 bool bt_session_2;
583};
584
585/**
586 * struct iwl_dvm_cfg - DVM firmware specific device configuration
587 * @set_hw_params: set hardware parameters
588 * @set_channel_switch: send channel switch command
589 * @nic_config: apply device specific configuration
590 * @temperature: read temperature
591 * @adv_thermal_throttle: support advance thermal throttle
592 * @support_ct_kill_exit: support ct kill exit condition
593 * @plcp_delta_threshold: plcp error rate threshold used to trigger
594 * radio tuning when there is a high receiving plcp error rate
595 * @chain_noise_scale: default chain noise scale used for gain computation
596 * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up
597 * @no_idle_support: do not support idle mode
598 * @bt_params: pointer to BT parameters
599 * @need_temp_offset_calib: need to perform temperature offset calibration
600 * @no_xtal_calib: some devices do not need crystal calibration data,
601 * don't send it to those
602 * @temp_offset_v2: support v2 of temperature offset calibration
603 * @adv_pm: advanced power management
604 */
Johannes Bergee4d5472013-05-17 09:58:27 +0200605struct iwl_dvm_cfg {
Johannes Berge9676692012-04-10 14:10:28 -0700606 void (*set_hw_params)(struct iwl_priv *priv);
607 int (*set_channel_switch)(struct iwl_priv *priv,
608 struct ieee80211_channel_switch *ch_switch);
Johannes Berge9676692012-04-10 14:10:28 -0700609 void (*nic_config)(struct iwl_priv *priv);
Johannes Berge9676692012-04-10 14:10:28 -0700610 void (*temperature)(struct iwl_priv *priv);
Johannes Berg0d8877a2013-05-17 10:36:29 +0200611
612 const struct iwl_dvm_bt_params *bt_params;
613 s32 chain_noise_scale;
614 u8 plcp_delta_threshold;
615 bool adv_thermal_throttle;
616 bool support_ct_kill_exit;
617 bool hd_v2;
618 bool no_idle_support;
619 bool need_temp_offset_calib;
620 bool no_xtal_calib;
621 bool temp_offset_v2;
622 bool adv_pm;
Johannes Berge9676692012-04-10 14:10:28 -0700623};
624
Johannes Berg79d3eef2011-11-10 06:55:01 -0800625struct iwl_wipan_noa_data {
626 struct rcu_head rcu_head;
627 u32 length;
628 u8 data[];
629};
630
Dor Shaishbfb45f52012-03-26 08:20:55 -0700631/* Calibration disabling bit mask */
David Spinadel5c457d02012-03-26 07:30:54 +0200632enum {
633 IWL_CALIB_ENABLE_ALL = 0,
Dor Shaishbfb45f52012-03-26 08:20:55 -0700634
David Spinadel5c457d02012-03-26 07:30:54 +0200635 IWL_SENSITIVITY_CALIB_DISABLED = BIT(0),
636 IWL_CHAIN_NOISE_CALIB_DISABLED = BIT(1),
637 IWL_TX_POWER_CALIB_DISABLED = BIT(2),
638
639 IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF,
640};
Dor Shaishbfb45f52012-03-26 08:20:55 -0700641
Emmanuel Grumbachd0f76d62012-02-09 16:08:15 +0200642#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
643 ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
644
645#define IWL_MAC80211_GET_DVM(_hw) \
646 ((struct iwl_priv *) ((struct iwl_op_mode *) \
647 (_hw)->priv)->op_mode_specific)
648
Tomas Winklerc79dd5b2008-03-12 16:58:50 -0700649struct iwl_priv {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800650
Emmanuel Grumbach68e8dfd2012-04-18 07:28:17 -0700651 struct iwl_trans *trans;
Emmanuel Grumbach4b9844f2012-03-22 23:59:52 +0200652 struct device *dev; /* for debug prints only */
Emmanuel Grumbach21522682012-03-22 17:51:44 +0200653 const struct iwl_cfg *cfg;
Johannes Berg0692fe42012-03-06 13:30:37 -0800654 const struct iwl_fw *fw;
Johannes Bergee4d5472013-05-17 09:58:27 +0200655 const struct iwl_dvm_cfg *lib;
Don Fry9a716862012-03-07 09:52:32 -0800656 unsigned long status;
Emmanuel Grumbachcac988a2011-08-25 23:10:37 -0700657
Johannes Bergfa23cb02012-03-05 11:24:25 -0800658 spinlock_t sta_lock;
Johannes Bergb1eea292012-03-06 13:30:42 -0800659 struct mutex mutex;
Johannes Bergfa23cb02012-03-05 11:24:25 -0800660
Johannes Berge755f882012-03-07 09:52:16 -0800661 unsigned long transport_queue_stop;
662 bool passive_no_rx;
Johannes Berg14791772012-04-17 07:39:03 -0700663#define IWL_INVALID_MAC80211_QUEUE 0xff
664 u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
665 atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
Johannes Berg9eae88f2012-03-15 13:26:52 -0700666
667 unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
Johannes Berge755f882012-03-07 09:52:16 -0800668
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800669 /* ieee device used by generic ieee processing code */
670 struct ieee80211_hw *hw;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800671
Johannes Bergaf9f9b22015-06-11 16:02:32 +0200672 struct napi_struct *napi;
673
Johannes Berge1991882012-03-06 13:30:36 -0800674 struct list_head calib_results;
675
Johannes Berg1ee158d2012-02-17 10:07:44 -0800676 struct workqueue_struct *workqueue;
677
Johannes Berg9e295112012-04-09 17:46:55 -0700678 struct iwl_hw_params hw_params;
679
Johannes Berg8318d782008-01-24 19:38:38 +0100680 enum ieee80211_band band;
Johannes Berga18f61b2012-03-15 13:26:53 -0700681 u8 valid_contexts;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800682
Johannes Berg73e686f2015-06-23 21:22:09 +0200683 void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
684 struct iwl_rx_cmd_buffer *rxb);
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800685
Johannes Berg4bd14dd2012-03-06 13:30:58 -0800686 struct iwl_notif_wait_data notif_wait;
687
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800688 /* spectrum measurement report caching */
Tomas Winkler2aa6ab82008-12-11 10:33:40 -0800689 struct iwl_spectrum_notification measure_report;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800690 u8 measurement_status;
Reinette Chatre81963d62010-01-22 14:22:57 -0800691
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800692 /* ucode beacon time */
693 u32 ucode_beacon_time;
Wey-Yi Guya13d2762010-01-22 14:22:42 -0800694 int missed_beacon_threshold;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800695
Johannes Berga85d7cc2010-07-31 08:34:10 -0700696 /* track IBSS manager (last beacon) status */
697 u32 ibss_manager;
698
Stanislaw Gruszka410f2bb2011-03-04 17:51:51 +0100699 /* jiffies when last recovery from statistics was performed */
700 unsigned long rx_statistics_jiffies;
Trieu 'Andrew' Nguyen3e4fb5f2010-01-22 14:22:46 -0800701
Emmanuel Grumbach1f7b6172011-08-25 23:10:59 -0700702 /*counters */
703 u32 rx_handlers_stats[REPLY_MAX];
704
Johannes Berg48dffd32012-04-09 17:46:57 -0700705 /* rf reset */
706 struct iwl_rf_reset rf_reset;
Wey-Yi Guya93e7972010-02-03 11:47:19 -0800707
Wey-Yi Guy491bc292011-02-09 09:37:46 -0800708 /* firmware reload counter and timestamp */
709 unsigned long reload_jiffies;
710 int reload_count;
David Spinadel8f7ffbe2012-03-10 13:00:10 -0800711 bool ucode_loaded;
Wey-Yi Guy491bc292011-02-09 09:37:46 -0800712
Johannes Bergab5c0f12012-03-06 13:30:53 -0800713 u8 plcp_delta_threshold;
714
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800715 /* thermal calibration */
Johannes Berg02883562011-09-22 15:14:56 -0700716 s32 temperature; /* Celsius */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800717 s32 last_temperature;
718
Johannes Berg79d3eef2011-11-10 06:55:01 -0800719 struct iwl_wipan_noa_data __rcu *noa_data;
720
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800721 /* Scan related variables */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800722 unsigned long scan_start;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800723 unsigned long scan_start_tsf;
Johannes Berg811ecc92010-04-06 04:12:41 -0700724 void *scan_cmd;
Johannes Berg00700ee2010-04-06 04:12:37 -0700725 enum ieee80211_band scan_band;
Johannes Berg1ecf9fc2009-04-20 14:36:56 -0700726 struct cfg80211_scan_request *scan_request;
Johannes Bergf84b29e2010-05-18 02:29:13 -0700727 struct ieee80211_vif *scan_vif;
Johannes Berg266af4c72011-03-10 20:13:26 -0800728 enum iwl_scan_type scan_type;
Tomas Winkler76eff182008-10-14 12:32:45 -0700729 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
730 u8 mgmt_tx_ant;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800731
Johannes Bergc10afb62010-08-23 10:46:43 +0200732 /* max number of station keys */
733 u8 sta_key_max_num;
734
Johannes Bergd2690c02011-04-20 09:10:39 -0700735 bool new_scan_threshold_behaviour;
736
Johannes Berg15b86bf2012-03-05 11:24:36 -0800737 bool wowlan;
738
Wey-Yi Guyc6fa17e2010-07-15 05:58:30 -0700739 /* EEPROM MAC addresses */
740 struct mac_address addresses[2];
741
Johannes Berg246ed352010-08-23 10:46:32 +0200742 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800743
Stanislaw Gruszka6f213ff2011-06-02 18:17:15 +0200744 __le16 switch_channel;
Wey-Yi Guy0924e5192009-11-06 14:52:54 -0800745
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800746 u8 start_calib;
Emmanuel Grumbachf0832f12008-04-16 16:34:47 -0700747 struct iwl_sensitivity_data sensitivity_data;
748 struct iwl_chain_noise_data chain_noise_data;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800749 __le16 sensitivity_tbl[HD_TABLE_SIZE];
Wey-Yi Guyc8312fa2010-06-28 13:05:17 -0700750 __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800751
Johannes Bergfad95bf2009-09-11 10:38:15 -0700752 struct iwl_ht_config current_ht_config;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800753
754 /* Rate scaling data */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800755 u8 retry_rate;
756
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800757 int activity_timer_active;
758
Mohamed Abbas5da4b552008-04-21 15:41:51 -0700759 struct iwl_power_mgr power_data;
Johannes Berg3ad3b922009-08-07 15:41:48 -0700760 struct iwl_tt_mgmt thermal_throttle;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800761
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700762 /* station table variables */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800763 int num_stations;
Johannes Berg3240cab2011-04-05 09:41:49 -0700764 struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
Emmanuel Grumbach80fb47a2008-04-14 21:16:08 -0700765 unsigned long ucode_key_table;
Emmanuel Grumbach04cf6822011-11-23 11:06:12 +0200766 struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT];
Ilan Peer622a9262012-05-09 16:11:55 +0300767 atomic_t num_aux_in_flight;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800768
Emmanuel Grumbach859cfb02011-09-15 11:46:31 -0700769 u8 mac80211_registered;
770
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800771 /* Indication if ieee80211_ops->open has been called */
Tomas Winkler69dc5d92008-03-25 16:33:41 -0700772 u8 is_open;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800773
Johannes Berg05c914f2008-09-11 00:01:58 +0200774 enum nl80211_iftype iw_mode;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800775
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800776 /* Last Rx'd beacon timestamp */
Tomas Winkler3109ece2008-03-28 16:33:35 -0700777 u64 timestamp;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800778
Johannes Berg3240cab2011-04-05 09:41:49 -0700779 struct {
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700780 __le32 flag;
781 struct statistics_general_common common;
782 struct statistics_rx_non_phy rx_non_phy;
783 struct statistics_rx_phy rx_ofdm;
784 struct statistics_rx_ht_phy rx_ofdm_ht;
785 struct statistics_rx_phy rx_cck;
786 struct statistics_tx tx;
787#ifdef CONFIG_IWLWIFI_DEBUGFS
788 struct statistics_bt_activity bt_activity;
789 __le32 num_bt_kills, accum_num_bt_kills;
790#endif
Johannes Berg4ff70fc2012-03-05 11:24:26 -0800791 spinlock_t lock;
Johannes Berg0da0e5b2011-04-08 08:14:56 -0700792 } statistics;
793#ifdef CONFIG_IWLWIFI_DEBUGFS
794 struct {
795 struct statistics_general_common common;
796 struct statistics_rx_non_phy rx_non_phy;
797 struct statistics_rx_phy rx_ofdm;
798 struct statistics_rx_ht_phy rx_ofdm_ht;
799 struct statistics_rx_phy rx_cck;
800 struct statistics_tx tx;
801 struct statistics_bt_activity bt_activity;
802 } accum_stats, delta_stats, max_delta_stats;
803#endif
804
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700805 /*
806 * reporting the number of tids has AGG on. 0 means
807 * no AGGREGATION
808 */
809 u8 agg_tids_count;
Johannes Bergee525d12010-01-21 06:09:28 -0800810
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700811 struct iwl_rx_phy_res last_phy_res;
Johannes Berg12bf6f42012-07-05 13:05:08 +0200812 u32 ampdu_ref;
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700813 bool last_phy_res_valid;
Johannes Bergee525d12010-01-21 06:09:28 -0800814
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700815 /*
816 * chain noise reset and gain commands are the
817 * two extra calibration commands follows the standard
818 * phy calibration commands
819 */
820 u8 phy_calib_chain_noise_reset_cmd;
821 u8 phy_calib_chain_noise_gain_cmd;
Johannes Berg3240cab2011-04-05 09:41:49 -0700822
Wey-Yi Guy898ed672011-07-13 08:38:57 -0700823 /* counts reply_tx error */
824 struct reply_tx_error_statistics reply_tx_stats;
825 struct reply_agg_tx_error_statistics reply_agg_tx_stats;
Johannes Bergee525d12010-01-21 06:09:28 -0800826
Wey-Yi Guy22bf59a2010-08-23 07:57:11 -0700827 /* bt coex */
Wey-Yi Guyf21dd002010-12-08 15:34:52 -0800828 u8 bt_enable_flag;
Wey-Yi Guyda5dbb92010-08-23 07:57:13 -0700829 u8 bt_status;
Wey-Yi Guy66e863a52010-11-08 14:54:37 -0800830 u8 bt_traffic_load, last_bt_traffic_load;
Wey-Yi Guyf37837c2010-08-23 07:57:12 -0700831 bool bt_ch_announce;
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700832 bool bt_full_concurrent;
833 bool bt_ant_couple_ok;
Wey-Yi Guyfbba9412010-08-23 07:57:10 -0700834 __le32 kill_ack_mask;
835 __le32 kill_cts_mask;
836 __le16 bt_valid;
Wey-Yi Guy354ce4a2012-04-19 09:48:01 -0700837 bool reduced_txpower;
Wey-Yi Guy22bf59a2010-08-23 07:57:11 -0700838 u16 bt_on_thresh;
839 u16 bt_duration;
840 u16 dynamic_frag_thresh;
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700841 u8 bt_ci_compliance;
Johannes Berg9e4afc22010-08-23 07:56:57 -0700842 struct work_struct bt_traffic_change_work;
Meenakshi Venkataraman207ecc52011-07-08 08:46:23 -0700843 bool bt_enable_pspoll;
844 struct iwl_rxon_context *cur_rssi_ctx;
845 bool bt_is_sco;
Johannes Berg9e4afc22010-08-23 07:56:57 -0700846
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800847 struct work_struct restart;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800848 struct work_struct scan_completed;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800849 struct work_struct abort_scan;
Johannes Berg12e934d2010-10-04 05:50:06 -0700850
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800851 struct work_struct beacon_update;
Johannes Berg76d04812010-08-23 10:46:47 +0200852 struct iwl_rxon_context *beacon_ctx;
Johannes Berg12e934d2010-10-04 05:50:06 -0700853 struct sk_buff *beacon_skb;
Johannes Berg4ce7cc22011-05-13 11:57:40 -0700854 void *beacon_cmd;
Johannes Berg76d04812010-08-23 10:46:47 +0200855
Wey-Yi Guya28027cd2009-08-07 15:41:45 -0700856 struct work_struct tt_work;
857 struct work_struct ct_enter;
858 struct work_struct ct_exit;
Johannes Berg88be0262010-04-07 00:21:36 -0700859 struct work_struct start_internal_scan;
Wey-Yi Guy65550632010-06-24 13:18:35 -0700860 struct work_struct tx_flush;
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700861 struct work_struct bt_full_concurrency;
Wey-Yi Guyfbba9412010-08-23 07:57:10 -0700862 struct work_struct bt_runtime_config;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800863
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800864 struct delayed_work scan_check;
Abhijeet Kolekar4a8a4322008-12-19 10:37:28 +0800865
Johannes Berg26a7ca92012-05-21 11:55:54 +0200866 /* TX Power settings */
Tomas Winkler630fe9b2008-06-12 09:47:08 +0800867 s8 tx_power_user_lmt;
Stanislaw Gruszkaa25a66a2010-10-22 17:04:26 +0200868 s8 tx_power_next;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800869
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700870#ifdef CONFIG_IWLWIFI_DEBUGFS
871 /* debugfs */
Johannes Berg4c84a8f2010-01-22 14:22:54 -0800872 struct dentry *debugfs_dir;
873 u32 dbgfs_sram_offset, dbgfs_sram_len;
Johannes Bergd73e4922010-05-06 12:18:41 -0700874 bool disable_ht40;
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700875 void *wowlan_sram;
Tomas Winkler712b6cf2008-03-12 16:58:52 -0700876#endif /* CONFIG_IWLWIFI_DEBUGFS */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800877
Eytan Lifshitzb7998c82012-12-01 20:59:49 +0200878 struct iwl_nvm_data *nvm_data;
Johannes Berg49464ae2013-06-17 23:13:31 +0200879 /* eeprom blob for debugfs */
Johannes Berg26a7ca92012-05-21 11:55:54 +0200880 u8 *eeprom_blob;
881 size_t eeprom_blob_size;
Johannes Berg11483b52012-04-09 17:46:58 -0700882
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800883 struct work_struct txpower_work;
Dor Shaishbfb45f52012-03-26 08:20:55 -0700884 u32 calib_disabled;
Emmanuel Grumbach16e727e2008-06-12 09:46:52 +0800885 struct work_struct run_time_calib_work;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800886 struct timer_list statistics_periodic;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -0800887 struct timer_list ucode_trace;
Wey-Yi Guya9e1cb62009-12-10 14:37:26 -0800888
889 struct iwl_event_log event_log;
Wey-Yi Guy5ed540a2011-01-21 15:26:39 -0800890
Johannes Bergc43e9332014-04-24 16:31:08 +0200891#ifdef CONFIG_IWLWIFI_LEDS
Wey-Yi Guy5ed540a2011-01-21 15:26:39 -0800892 struct led_classdev led;
893 unsigned long blink_on, blink_off;
894 bool led_registered;
Johannes Bergc43e9332014-04-24 16:31:08 +0200895#endif
Ilan Peer3a6490c2012-06-03 13:36:51 +0300896
Johannes Bergc8ac61c2011-07-15 13:23:45 -0700897 /* WoWLAN GTK rekey data */
898 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
899 __le64 replay_ctr;
900 __le16 last_seq_ctl;
901 bool have_rekey_data;
Johannes Berg964dc9e2013-06-03 17:25:34 +0200902#ifdef CONFIG_PM_SLEEP
903 struct wiphy_wowlan_support wowlan_support;
904#endif
Meenakshi Venkataraman2fdfc472012-03-15 13:26:56 -0700905
906 /* device_pointers: pointers to ucode event tables */
907 struct {
908 u32 error_event_table;
909 u32 log_event_table;
910 } device_pointers;
Meenakshi Venkataramana42506e2012-03-15 13:26:57 -0700911
912 /* indicator of loaded ucode image */
913 enum iwl_ucode_type cur_ucode;
Tomas Winklerc79dd5b2008-03-12 16:58:50 -0700914}; /*iwl_priv */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800915
Johannes Berg246ed352010-08-23 10:46:32 +0200916static inline struct iwl_rxon_context *
917iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800918{
Johannes Berg246ed352010-08-23 10:46:32 +0200919 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
920
921 return vif_priv->ctx;
922}
923
924#define for_each_context(priv, ctx) \
925 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
926 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
Johannes Berga18f61b2012-03-15 13:26:53 -0700927 if (priv->valid_contexts & BIT(ctx->ctxid))
Johannes Berg246ed352010-08-23 10:46:32 +0200928
Johannes Berg054ec922011-05-06 11:11:20 -0700929static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
930{
931 return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
932}
933
Johannes Berg246ed352010-08-23 10:46:32 +0200934static inline int iwl_is_associated(struct iwl_priv *priv,
935 enum iwl_rxon_context_id ctxid)
936{
Johannes Berg054ec922011-05-06 11:11:20 -0700937 return iwl_is_associated_ctx(&priv->contexts[ctxid]);
Johannes Berg246ed352010-08-23 10:46:32 +0200938}
939
940static inline int iwl_is_any_associated(struct iwl_priv *priv)
941{
Johannes Berg054ec922011-05-06 11:11:20 -0700942 struct iwl_rxon_context *ctx;
943 for_each_context(priv, ctx)
944 if (iwl_is_associated_ctx(ctx))
945 return true;
946 return false;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800947}
948
Emmanuel Grumbachbe1f3ab62008-06-12 09:47:18 +0800949#endif /* __iwl_dev_h__ */