]> Git Repo - linux.git/blame - drivers/net/wireless/iwlwifi/iwl-dev.h
iwlagn: remove calibration knowledge
[linux.git] / drivers / net / wireless / iwlwifi / iwl-dev.h
CommitLineData
b481de9c
ZY
1/******************************************************************************
2 *
901069c7 3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
b481de9c
ZY
4 *
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:
759ef89f 22 * Intel Linux Wireless <[email protected]>
b481de9c
ZY
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
fcd427bb 26/*
3e0d4cb1 27 * Please use this file (iwl-dev.h) for driver implementation definitions.
5a36ba0e 28 * Please use iwl-commands.h for uCode API definitions.
fcd427bb
BC
29 */
30
be1f3ab6
EG
31#ifndef __iwl_dev_h__
32#define __iwl_dev_h__
b481de9c 33
a6b7a407 34#include <linux/interrupt.h>
5d08cd1d 35#include <linux/kernel.h>
7194207c 36#include <linux/wait.h>
5ed540ae 37#include <linux/leds.h>
dfa2bdba 38#include <linux/slab.h>
5d08cd1d
CH
39#include <net/ieee80211_radiotap.h>
40
6bc913bd 41#include "iwl-eeprom.h"
6f83eaa1 42#include "iwl-csr.h"
5d08cd1d 43#include "iwl-prph.h"
0a6857e7 44#include "iwl-debug.h"
b744cb79 45#include "iwl-agn-hw.h"
ab53d8af 46#include "iwl-led.h"
5da4b55f 47#include "iwl-power.h"
e227ceac 48#include "iwl-agn-rs.h"
0975cc8f 49#include "iwl-agn-tt.h"
d5934110 50#include "iwl-bus.h"
41c50542 51#include "iwl-trans.h"
48f20d35 52#include "iwl-shared.h"
5d08cd1d 53
672639de
WYG
54struct iwl_tx_queue;
55
099b40b7 56/* CT-KILL constants */
672639de
WYG
57#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
58#define CT_KILL_THRESHOLD 114 /* in Celsius */
59#define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
4bf775cd 60
5d08cd1d
CH
61/* Default noise level to report when noise measurement is not available.
62 * This may be because we're:
63 * 1) Not associated (4965, no beacon statistics being sent to driver)
64 * 2) Scanning (noise measurement does not apply to associated channel)
65 * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
66 * Use default noise value of -127 ... this is below the range of measurable
67 * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
68 * Also, -127 works better than 0 when averaging frames with/without
69 * noise info (e.g. averaging might be done in app); measured dBm values are
70 * always negative ... using a negative value as the default keeps all
71 * averages within an s8's (used in some apps) range of negative values. */
72#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
73
5d08cd1d
CH
74/*
75 * RTS threshold here is total size [2347] minus 4 FCS bytes
76 * Per spec:
77 * a value of 0 means RTS on all data/management packets
78 * a value > max MSDU size means no RTS
79 * else RTS for data/management frames where MPDU is larger
80 * than RTS value.
81 */
82#define DEFAULT_RTS_THRESHOLD 2347U
83#define MIN_RTS_THRESHOLD 0U
84#define MAX_RTS_THRESHOLD 2347U
85#define MAX_MSDU_SIZE 2304U
86#define MAX_MPDU_SIZE 2346U
51b7ef05 87#define DEFAULT_BEACON_INTERVAL 200U
5d08cd1d
CH
88#define DEFAULT_SHORT_RETRY_LIMIT 7U
89#define DEFAULT_LONG_RETRY_LIMIT 4U
90
5d08cd1d
CH
91#define IWL_NUM_SCAN_RATES (2)
92
5d08cd1d
CH
93/*
94 * One for each channel, holds all channel setup data
95 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
96 * with one another!
97 */
bf85ea4f 98struct iwl_channel_info {
073d3f5f 99 struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
7aafef1c
WYG
100 struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for
101 * HT40 channel */
5d08cd1d
CH
102
103 u8 channel; /* channel number */
104 u8 flags; /* flags copied from EEPROM */
105 s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
fcd427bb 106 s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
5d08cd1d
CH
107 s8 min_power; /* always 0 */
108 s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
109
110 u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
111 u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
8318d78a 112 enum ieee80211_band band;
5d08cd1d 113
7aafef1c
WYG
114 /* HT40 channel info */
115 s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
7aafef1c
WYG
116 u8 ht40_flags; /* flags copied from EEPROM */
117 u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
5d08cd1d
CH
118};
119
72c04ce0
JB
120/*
121 * Minimum number of queues. MAX_NUM is defined in hw specific files.
122 * Set the minimum to accommodate
123 * - 4 standard TX queues
124 * - the command queue
125 * - 4 PAN TX queues
126 * - the PAN multicast queue, and
127 * - the AUX (TX during scan dwell) queue.
128 */
129#define IWL_MIN_NUM_QUEUES 11
5d08cd1d 130
bd35f150 131/*
13bb9483 132 * Command queue depends on iPAN support.
bd35f150 133 */
13bb9483
JB
134#define IWL_DEFAULT_CMD_QUEUE_NUM 4
135#define IWL_IPAN_CMD_QUEUE_NUM 9
bd35f150 136
5d08cd1d
CH
137#define IEEE80211_DATA_LEN 2304
138#define IEEE80211_4ADDR_LEN 30
139#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
140#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
141
5d08cd1d
CH
142#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
143#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
144#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
145
5d08cd1d
CH
146#define IWL_SUPPORTED_RATES_IE_LEN 8
147
5d08cd1d
CH
148#define IWL_INVALID_RATE 0xFF
149#define IWL_INVALID_VALUE -1
150
a78fe754 151union iwl_ht_rate_supp {
5d08cd1d
CH
152 u16 rates;
153 struct {
154 u8 siso_rate;
155 u8 mimo_rate;
156 };
157};
158
172c1d11
WYG
159#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
160#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
161#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
162#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
163#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
164#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
165#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
bcc693a1
WYG
166
167/*
168 * Maximal MPDU density for TX aggregation
169 * 4 - 2us density
170 * 5 - 4us density
171 * 6 - 8us density
172 * 7 - 16us density
173 */
172c1d11 174#define CFG_HT_MPDU_DENSITY_2USEC (0x4)
bcc693a1 175#define CFG_HT_MPDU_DENSITY_4USEC (0x5)
172c1d11
WYG
176#define CFG_HT_MPDU_DENSITY_8USEC (0x6)
177#define CFG_HT_MPDU_DENSITY_16USEC (0x7)
bcc693a1 178#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
172c1d11
WYG
179#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
180#define CFG_HT_MPDU_DENSITY_MIN (0x1)
5d08cd1d 181
fad95bf5 182struct iwl_ht_config {
02bb1bea 183 bool single_chain_sufficient;
ba37a3d0 184 enum ieee80211_smps_mode smps; /* current smps mode */
5d08cd1d 185};
5d08cd1d 186
5d08cd1d 187/* QoS structures */
1ff50bda 188struct iwl_qos_info {
5d08cd1d 189 int qos_active;
1ff50bda 190 struct iwl_qosparam_cmd def_qos_parm;
5d08cd1d 191};
5d08cd1d 192
fe6b23dd
RC
193/*
194 * Structure should be accessed with sta_lock held. When station addition
195 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
196 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
197 * held.
198 */
6def9761 199struct iwl_station_entry {
133636de 200 struct iwl_addsta_cmd sta;
dcef732c 201 u8 used, ctxid;
fe6b23dd 202 struct iwl_link_quality_cmd *lq;
5d08cd1d
CH
203};
204
8d9698b3
RC
205/*
206 * iwl_station_priv: Driver's private station information
207 *
208 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
209 * in the structure for use by driver. This structure is places in that
210 * space.
8d9698b3
RC
211 */
212struct iwl_station_priv {
c6892906 213 struct iwl_rxon_context *ctx;
8d9698b3 214 struct iwl_lq_sta lq_sta;
6ab10ff8
JB
215 atomic_t pending_frames;
216 bool client;
217 bool asleep;
7b090687 218 u8 max_agg_bufsize;
c6892906 219 u8 sta_id;
8d9698b3
RC
220};
221
fd1af15d
JB
222/**
223 * struct iwl_vif_priv - driver's private per-interface information
224 *
225 * When mac80211 allocates a virtual interface, it can allocate
226 * space for us to put data into.
227 */
228struct iwl_vif_priv {
246ed355 229 struct iwl_rxon_context *ctx;
fd1af15d
JB
230 u8 ibss_bssid_sta_id;
231};
232
dd7a2509 233/* v1/v2 uCode file layout */
cc0f555d
JS
234struct iwl_ucode_header {
235 __le32 ver; /* major/minor/API/serial */
236 union {
237 struct {
238 __le32 inst_size; /* bytes of runtime code */
239 __le32 data_size; /* bytes of runtime data */
240 __le32 init_size; /* bytes of init code */
241 __le32 init_data_size; /* bytes of init data */
242 __le32 boot_size; /* bytes of bootstrap code */
243 u8 data[0]; /* in same order as sizes */
244 } v1;
245 struct {
246 __le32 build; /* build number */
247 __le32 inst_size; /* bytes of runtime code */
248 __le32 data_size; /* bytes of runtime data */
249 __le32 init_size; /* bytes of init code */
250 __le32 init_data_size; /* bytes of init data */
251 __le32 boot_size; /* bytes of bootstrap code */
252 u8 data[0]; /* in same order as sizes */
253 } v2;
254 } u;
5d08cd1d
CH
255};
256
dd7a2509
JB
257/*
258 * new TLV uCode file layout
259 *
260 * The new TLV file format contains TLVs, that each specify
261 * some piece of data. To facilitate "groups", for example
262 * different instruction image with different capabilities,
263 * bundled with the same init image, an alternative mechanism
264 * is provided:
265 * When the alternative field is 0, that means that the item
266 * is always valid. When it is non-zero, then it is only
267 * valid in conjunction with items of the same alternative,
268 * in which case the driver (user) selects one alternative
269 * to use.
270 */
271
272enum iwl_ucode_tlv_type {
273 IWL_UCODE_TLV_INVALID = 0, /* unused */
274 IWL_UCODE_TLV_INST = 1,
275 IWL_UCODE_TLV_DATA = 2,
276 IWL_UCODE_TLV_INIT = 3,
277 IWL_UCODE_TLV_INIT_DATA = 4,
278 IWL_UCODE_TLV_BOOT = 5,
279 IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
ece9c4ee 280 IWL_UCODE_TLV_PAN = 7,
b2e640d4
JB
281 IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8,
282 IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9,
283 IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10,
284 IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11,
285 IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12,
286 IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13,
c8312fac 287 IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14,
6a822d06 288 IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
c8ac61cf
JB
289 IWL_UCODE_TLV_WOWLAN_INST = 16,
290 IWL_UCODE_TLV_WOWLAN_DATA = 17,
3997ff39
JB
291 IWL_UCODE_TLV_FLAGS = 18,
292};
293
294/**
295 * enum iwl_ucode_tlv_flag - ucode API flags
296 * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
297 * was a separate TLV but moved here to save space.
d2690c0d
JB
298 * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
299 * treats good CRC threshold as a boolean
3997ff39 300 * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
c6baf7fb 301 * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
3997ff39
JB
302 */
303enum iwl_ucode_tlv_flag {
304 IWL_UCODE_TLV_FLAGS_PAN = BIT(0),
d2690c0d 305 IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1),
3997ff39 306 IWL_UCODE_TLV_FLAGS_MFP = BIT(2),
c6baf7fb 307 IWL_UCODE_TLV_FLAGS_P2P = BIT(3),
dd7a2509
JB
308};
309
310struct iwl_ucode_tlv {
311 __le16 type; /* see above */
312 __le16 alternative; /* see comment */
313 __le32 length; /* not including type/length fields */
314 u8 data[0];
ba2d3587 315} __packed;
dd7a2509
JB
316
317#define IWL_TLV_UCODE_MAGIC 0x0a4c5749
318
319struct iwl_tlv_ucode_header {
320 /*
321 * The TLV style ucode header is distinguished from
322 * the v1/v2 style header by first four bytes being
323 * zero, as such is an invalid combination of
324 * major/minor/API/serial versions.
325 */
326 __le32 zero;
327 __le32 magic;
328 u8 human_readable[64];
329 __le32 ver; /* major/minor/API/serial */
330 __le32 build;
331 __le64 alternatives; /* bitmask of valid alternatives */
332 /*
333 * The data contained herein has a TLV layout,
334 * see above for the TLV header and types.
335 * Note that each TLV is padded to a length
336 * that is a multiple of 4 for alignment.
337 */
338 u8 data[0];
339};
340
f0832f13
EG
341struct iwl_sensitivity_ranges {
342 u16 min_nrg_cck;
343 u16 max_nrg_cck;
344
345 u16 nrg_th_cck;
346 u16 nrg_th_ofdm;
347
348 u16 auto_corr_min_ofdm;
349 u16 auto_corr_min_ofdm_mrc;
350 u16 auto_corr_min_ofdm_x1;
351 u16 auto_corr_min_ofdm_mrc_x1;
352
353 u16 auto_corr_max_ofdm;
354 u16 auto_corr_max_ofdm_mrc;
355 u16 auto_corr_max_ofdm_x1;
356 u16 auto_corr_max_ofdm_mrc_x1;
357
358 u16 auto_corr_max_cck;
359 u16 auto_corr_max_cck_mrc;
360 u16 auto_corr_min_cck;
361 u16 auto_corr_min_cck_mrc;
55036d66
WYG
362
363 u16 barker_corr_th_min;
364 u16 barker_corr_th_min_mrc;
365 u16 nrg_th_cca;
f0832f13
EG
366};
367
099b40b7 368
b5047f78
TW
369#define KELVIN_TO_CELSIUS(x) ((x)-273)
370#define CELSIUS_TO_KELVIN(x) ((x)+273)
371
372
5d08cd1d
CH
373/******************************************************************************
374 *
a33c2f47
EG
375 * Functions implemented in core module which are forward declared here
376 * for use by iwl-[4-5].c
5d08cd1d 377 *
a33c2f47
EG
378 * NOTE: The implementation of these functions are not hardware specific
379 * which is why they are in the core module files.
5d08cd1d
CH
380 *
381 * Naming convention --
a33c2f47 382 * iwl_ <-- Is part of iwlwifi
5d08cd1d 383 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
5d08cd1d
CH
384 *
385 ****************************************************************************/
5b9f8cd3 386extern void iwl_update_chain_flags(struct iwl_priv *priv);
a33c2f47 387extern const u8 iwl_bcast_addr[ETH_ALEN];
fd4abac5 388
b481de9c
ZY
389#define IWL_OPERATION_MODE_AUTO 0
390#define IWL_OPERATION_MODE_HT_ONLY 1
391#define IWL_OPERATION_MODE_MIXED 2
392#define IWL_OPERATION_MODE_20MHZ 3
393
b481de9c 394#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
b481de9c 395
b481de9c 396/* Sensitivity and chain noise calibration */
b481de9c 397#define INITIALIZATION_VALUE 0xFFFF
d8c07e7a 398#define IWL_CAL_NUM_BEACONS 16
b481de9c
ZY
399#define MAXIMUM_ALLOWED_PATHLOSS 15
400
b481de9c
ZY
401#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
402
403#define MAX_FA_OFDM 50
404#define MIN_FA_OFDM 5
405#define MAX_FA_CCK 50
406#define MIN_FA_CCK 5
407
b481de9c
ZY
408#define AUTO_CORR_STEP_OFDM 1
409
b481de9c
ZY
410#define AUTO_CORR_STEP_CCK 3
411#define AUTO_CORR_MAX_TH_CCK 160
412
b481de9c
ZY
413#define NRG_DIFF 2
414#define NRG_STEP_CCK 2
415#define NRG_MARGIN 8
416#define MAX_NUMBER_CCK_NO_FA 100
417
418#define AUTO_CORR_CCK_MIN_VAL_DEF (125)
419
420#define CHAIN_A 0
421#define CHAIN_B 1
422#define CHAIN_C 2
423#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
424#define ALL_BAND_FILTER 0xFF00
425#define IN_BAND_FILTER 0xFF
426#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
427
3195cdb7
TW
428#define NRG_NUM_PREV_STAT_L 20
429#define NUM_RX_CHAINS 3
430
3240cab3 431enum iwlagn_false_alarm_state {
b481de9c
ZY
432 IWL_FA_TOO_MANY = 0,
433 IWL_FA_TOO_FEW = 1,
434 IWL_FA_GOOD_RANGE = 2,
435};
436
3240cab3 437enum iwlagn_chain_noise_state {
b481de9c 438 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
04816448
GE
439 IWL_CHAIN_NOISE_ACCUMULATE,
440 IWL_CHAIN_NOISE_CALIBRATED,
441 IWL_CHAIN_NOISE_DONE,
b481de9c
ZY
442};
443
f69f42a6
TW
444
445/*
446 * enum iwl_calib
447 * defines the order in which results of initial calibrations
448 * should be sent to the runtime uCode
449 */
450enum iwl_calib {
451 IWL_CALIB_XTAL,
819500c5 452 IWL_CALIB_DC,
f69f42a6
TW
453 IWL_CALIB_LO,
454 IWL_CALIB_TX_IQ,
455 IWL_CALIB_TX_IQ_PERD,
201706ac 456 IWL_CALIB_BASE_BAND,
bf53f939 457 IWL_CALIB_TEMP_OFFSET,
f69f42a6
TW
458 IWL_CALIB_MAX
459};
460
6e21f2c1
TW
461/* Opaque calibration results */
462struct iwl_calib_result {
463 void *buf;
464 size_t buf_len;
7c616cba
TW
465};
466
b481de9c 467/* Sensitivity calib data */
f0832f13 468struct iwl_sensitivity_data {
b481de9c
ZY
469 u32 auto_corr_ofdm;
470 u32 auto_corr_ofdm_mrc;
471 u32 auto_corr_ofdm_x1;
472 u32 auto_corr_ofdm_mrc_x1;
473 u32 auto_corr_cck;
474 u32 auto_corr_cck_mrc;
475
476 u32 last_bad_plcp_cnt_ofdm;
477 u32 last_fa_cnt_ofdm;
478 u32 last_bad_plcp_cnt_cck;
479 u32 last_fa_cnt_cck;
480
481 u32 nrg_curr_state;
482 u32 nrg_prev_state;
483 u32 nrg_value[10];
484 u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
485 u32 nrg_silence_ref;
486 u32 nrg_energy_idx;
487 u32 nrg_silence_idx;
488 u32 nrg_th_cck;
489 s32 nrg_auto_corr_silence_diff;
490 u32 num_in_cck_no_fa;
491 u32 nrg_th_ofdm;
55036d66
WYG
492
493 u16 barker_corr_th_min;
494 u16 barker_corr_th_min_mrc;
495 u16 nrg_th_cca;
b481de9c
ZY
496};
497
498/* Chain noise (differential Rx gain) calib data */
f0832f13 499struct iwl_chain_noise_data {
04816448 500 u32 active_chains;
b481de9c
ZY
501 u32 chain_noise_a;
502 u32 chain_noise_b;
503 u32 chain_noise_c;
504 u32 chain_signal_a;
505 u32 chain_signal_b;
506 u32 chain_signal_c;
04816448 507 u16 beacon_count;
b481de9c
ZY
508 u8 disconn_array[NUM_RX_CHAINS];
509 u8 delta_gain_code[NUM_RX_CHAINS];
510 u8 radio_write;
04816448 511 u8 state;
b481de9c
ZY
512};
513
abceddb4
BC
514#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
515#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
b481de9c 516
5d08cd1d
CH
517enum {
518 MEASUREMENT_READY = (1 << 0),
519 MEASUREMENT_ACTIVE = (1 << 1),
520};
521
0848e297
WYG
522enum iwl_nvm_type {
523 NVM_DEVICE_TYPE_EEPROM = 0,
524 NVM_DEVICE_TYPE_OTP,
525};
526
415e4993
WYG
527/*
528 * Two types of OTP memory access modes
529 * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
530 * based on physical memory addressing
531 * IWL_OTP_ACCESS_RELATIVE - relative address mode,
532 * based on logical memory addressing
533 */
534enum iwl_access_mode {
535 IWL_OTP_ACCESS_ABSOLUTE,
536 IWL_OTP_ACCESS_RELATIVE,
537};
65b7998a
WYG
538
539/**
540 * enum iwl_pa_type - Power Amplifier type
541 * @IWL_PA_SYSTEM: based on uCode configuration
65b7998a
WYG
542 * @IWL_PA_INTERNAL: use Internal only
543 */
544enum iwl_pa_type {
545 IWL_PA_SYSTEM = 0,
740e7f51 546 IWL_PA_INTERNAL = 1,
65b7998a
WYG
547};
548
91835ba4
WYG
549/* reply_tx_statistics (for _agn devices) */
550struct reply_tx_error_statistics {
551 u32 pp_delay;
552 u32 pp_few_bytes;
553 u32 pp_bt_prio;
554 u32 pp_quiet_period;
555 u32 pp_calc_ttak;
556 u32 int_crossed_retry;
557 u32 short_limit;
558 u32 long_limit;
559 u32 fifo_underrun;
560 u32 drain_flow;
561 u32 rfkill_flush;
562 u32 life_expire;
563 u32 dest_ps;
564 u32 host_abort;
565 u32 bt_retry;
566 u32 sta_invalid;
567 u32 frag_drop;
568 u32 tid_disable;
569 u32 fifo_flush;
570 u32 insuff_cf_poll;
571 u32 fail_hw_drop;
572 u32 sta_color_mismatch;
573 u32 unknown;
574};
575
814665fe
WYG
576/* reply_agg_tx_statistics (for _agn devices) */
577struct reply_agg_tx_error_statistics {
578 u32 underrun;
579 u32 bt_prio;
580 u32 few_bytes;
581 u32 abort;
582 u32 last_sent_ttl;
583 u32 last_sent_try;
584 u32 last_sent_bt_kill;
585 u32 scd_query;
586 u32 bad_crc32;
587 u32 response;
588 u32 dump_tx;
589 u32 delay_tx;
590 u32 unknown;
591};
592
22fdf3c9
WYG
593/* management statistics */
594enum iwl_mgmt_stats {
595 MANAGEMENT_ASSOC_REQ = 0,
596 MANAGEMENT_ASSOC_RESP,
597 MANAGEMENT_REASSOC_REQ,
598 MANAGEMENT_REASSOC_RESP,
599 MANAGEMENT_PROBE_REQ,
600 MANAGEMENT_PROBE_RESP,
601 MANAGEMENT_BEACON,
602 MANAGEMENT_ATIM,
603 MANAGEMENT_DISASSOC,
604 MANAGEMENT_AUTH,
605 MANAGEMENT_DEAUTH,
606 MANAGEMENT_ACTION,
607 MANAGEMENT_MAX,
608};
609/* control statistics */
610enum iwl_ctrl_stats {
611 CONTROL_BACK_REQ = 0,
612 CONTROL_BACK,
613 CONTROL_PSPOLL,
614 CONTROL_RTS,
615 CONTROL_CTS,
616 CONTROL_ACK,
617 CONTROL_CFEND,
618 CONTROL_CFENDACK,
619 CONTROL_MAX,
620};
621
622struct traffic_stats {
5ed540ae 623#ifdef CONFIG_IWLWIFI_DEBUGFS
22fdf3c9
WYG
624 u32 mgmt[MANAGEMENT_MAX];
625 u32 ctrl[CONTROL_MAX];
626 u32 data_cnt;
627 u64 data_bytes;
22fdf3c9 628#endif
5ed540ae 629};
22fdf3c9 630
a9e1cb6a
WYG
631/*
632 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
633 * to perform continuous uCode event logging operation if enabled
634 */
635#define UCODE_TRACE_PERIOD (100)
636
637/*
638 * iwl_event_log: current uCode event log position
639 *
640 * @ucode_trace: enable/disable ucode continuous trace timer
641 * @num_wraps: how many times the event buffer wraps
642 * @next_entry: the entry just before the next one that uCode would fill
643 * @non_wraps_count: counter for no wrap detected when dump ucode events
644 * @wraps_once_count: counter for wrap once detected when dump ucode events
645 * @wraps_more_count: counter for wrap more than once detected
646 * when dump ucode events
647 */
648struct iwl_event_log {
649 bool ucode_trace;
650 u32 num_wraps;
651 u32 next_entry;
652 int non_wraps_count;
653 int wraps_once_count;
654 int wraps_more_count;
655};
656
3e4fb5fa
TAN
657/*
658 * This is the threshold value of plcp error rate per 100mSecs. It is
659 * used to set and check for the validity of plcp_delta.
660 */
680788ac 661#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
3e4fb5fa
TAN
662#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
663#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
6c3872e1 664#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
3e4fb5fa 665#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
680788ac 666#define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
3e4fb5fa 667
8a472da4
WYG
668#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
669#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
670
22de94de
SG
671/* TX queue watchdog timeouts in mSecs */
672#define IWL_DEF_WD_TIMEOUT (2000)
673#define IWL_LONG_WD_TIMEOUT (10000)
674#define IWL_MAX_WD_TIMEOUT (120000)
b74e31a9 675
bee008b7
WYG
676/* BT Antenna Coupling Threshold (dB) */
677#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
678
491bc292
WYG
679/* Firmware reload counter and Timestamp */
680#define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
681#define IWL_MAX_CONTINUE_RELOAD_CNT 4
682
683
a93e7973
WYG
684enum iwl_reset {
685 IWL_RF_RESET = 0,
686 IWL_FW_RESET,
8a472da4
WYG
687 IWL_MAX_FORCE_RESET,
688};
689
690struct iwl_force_reset {
691 int reset_request_count;
692 int reset_success_count;
693 int reset_reject_count;
694 unsigned long reset_duration;
695 unsigned long last_force_reset_jiffies;
a93e7973
WYG
696};
697
a0ee74cf 698/* extend beacon time format bit shifting */
a0ee74cf
WYG
699/*
700 * for _agn devices
701 * bits 31:22 - extended
702 * bits 21:0 - interval
703 */
704#define IWLAGN_EXT_BEACON_TIME_POS 22
705
7194207c
JB
706/**
707 * struct iwl_notification_wait - notification wait entry
708 * @list: list head for global list
709 * @fn: function called with the notification
710 * @cmd: command ID
711 *
712 * This structure is not used directly, to wait for a
713 * notification declare it on the stack, and call
714 * iwlagn_init_notification_wait() with appropriate
715 * parameters. Then do whatever will cause the ucode
716 * to notify the driver, and to wait for that then
717 * call iwlagn_wait_notification().
718 *
719 * Each notification is one-shot. If at some point we
720 * need to support multi-shot notifications (which
721 * can't be allocated on the stack) we need to modify
722 * the code for them.
723 */
724struct iwl_notification_wait {
725 struct list_head list;
726
09f18afe
JB
727 void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt,
728 void *data);
729 void *fn_data;
7194207c
JB
730
731 u8 cmd;
e74fe233 732 bool triggered, aborted;
7194207c
JB
733};
734
246ed355 735struct iwl_rxon_context {
8bd413e6 736 struct ieee80211_vif *vif;
e72f368b 737
763cc3bf
JB
738 /*
739 * We could use the vif to indicate active, but we
740 * also need it to be active during disabling when
741 * we already removed the vif for type setting.
742 */
743 bool always_active, is_active;
744
2295c66b
JB
745 bool ht_need_multiple_chains;
746
246ed355 747 enum iwl_rxon_context_id ctxid;
d0fe478c
JB
748
749 u32 interface_modes, exclusive_interface_modes;
750 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
751
246ed355
JB
752 /*
753 * We declare this const so it can only be
754 * changed via explicit cast within the
755 * routines that actually update the physical
756 * hardware.
757 */
758 const struct iwl_rxon_cmd active;
759 struct iwl_rxon_cmd staging;
760
761 struct iwl_rxon_time_cmd timing;
a194e324 762
8dfdb9d5
JB
763 struct iwl_qos_info qos_data;
764
2995bafa 765 u8 bcast_sta_id, ap_sta_id;
8f2d3d2a
JB
766
767 u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
8dfdb9d5 768 u8 qos_cmd;
c10afb6e
JB
769 u8 wep_key_cmd;
770
771 struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
772 u8 key_mapping_keys;
770e13bd
JB
773
774 __le32 station_flags;
7e6a5886 775
bbb05cb5
JB
776 int beacon_int;
777
7e6a5886
JB
778 struct {
779 bool non_gf_sta_present;
780 u8 protection;
781 bool enabled, is_40mhz;
782 u8 extension_chan_offset;
783 } ht;
68b99311 784
debcf734
JB
785 u8 bssid[ETH_ALEN];
786 bool preauth_bssid;
787
68b99311 788 bool last_tx_rejected;
246ed355
JB
789};
790
266af4c7
JB
791enum iwl_scan_type {
792 IWL_SCAN_NORMAL,
793 IWL_SCAN_RADIO_RESET,
c6baf7fb 794 IWL_SCAN_ROC,
266af4c7
JB
795};
796
7a4e5281
WYG
797#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
798struct iwl_testmode_trace {
49b72100
WYG
799 u32 buff_size;
800 u32 total_size;
eb64dca0 801 u32 num_chunks;
7a4e5281
WYG
802 u8 *cpu_addr;
803 u8 *trace_addr;
804 dma_addr_t dma_addr;
805 bool trace_enabled;
806};
807#endif
a48709c5 808
79d3eef8
JB
809struct iwl_wipan_noa_data {
810 struct rcu_head rcu_head;
811 u32 length;
812 u8 data[];
813};
814
c79dd5b5 815struct iwl_priv {
5d08cd1d 816
cac988a6
EG
817 /*data shared among all the driver's layers */
818 struct iwl_shared _shrd;
819 struct iwl_shared *shrd;
820
5d08cd1d
CH
821 /* ieee device used by generic ieee processing code */
822 struct ieee80211_hw *hw;
823 struct ieee80211_channel *ieee_channels;
824 struct ieee80211_rate *ieee_rates;
dfa2bdba 825 struct kmem_cache *tx_cmd_pool;
82b9a121 826 struct iwl_cfg *cfg;
5d08cd1d 827
8318d78a 828 enum ieee80211_band band;
5d08cd1d 829
4613e72d
CK
830 void (*pre_rx_handler)(struct iwl_priv *priv,
831 struct iwl_rx_mem_buffer *rxb);
247c61d6
EG
832 int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
833 struct iwl_rx_mem_buffer *rxb,
834 struct iwl_device_cmd *cmd);
5d08cd1d 835
8318d78a 836 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
5d08cd1d 837
5d08cd1d 838 /* spectrum measurement report caching */
2aa6ab86 839 struct iwl_spectrum_notification measure_report;
5d08cd1d 840 u8 measurement_status;
81963d68 841
5d08cd1d
CH
842 /* ucode beacon time */
843 u32 ucode_beacon_time;
a13d276f 844 int missed_beacon_threshold;
5d08cd1d 845
a85d7cca
JB
846 /* track IBSS manager (last beacon) status */
847 u32 ibss_manager;
848
410f2bb3
SG
849 /* jiffies when last recovery from statistics was performed */
850 unsigned long rx_statistics_jiffies;
3e4fb5fa 851
1f7b6172
EG
852 /*counters */
853 u32 rx_handlers_stats[REPLY_MAX];
854
a93e7973 855 /* force reset */
8a472da4 856 struct iwl_force_reset force_reset[IWL_MAX_FORCE_RESET];
a93e7973 857
491bc292
WYG
858 /* firmware reload counter and timestamp */
859 unsigned long reload_jiffies;
860 int reload_count;
861
5a2a780c 862 /* we allocate array of iwl_channel_info for NIC's valid channels.
5d08cd1d 863 * Access via channel # using indirect index array */
bf85ea4f 864 struct iwl_channel_info *channel_info; /* channel info array */
5d08cd1d
CH
865 u8 channel_count; /* # of channels */
866
5d08cd1d 867 /* thermal calibration */
02883562 868 s32 temperature; /* Celsius */
5d08cd1d
CH
869 s32 last_temperature;
870
7c616cba 871 /* init calibration results */
6e21f2c1 872 struct iwl_calib_result calib_results[IWL_CALIB_MAX];
7c616cba 873
79d3eef8
JB
874 struct iwl_wipan_noa_data __rcu *noa_data;
875
5d08cd1d 876 /* Scan related variables */
5d08cd1d 877 unsigned long scan_start;
5d08cd1d 878 unsigned long scan_start_tsf;
811ecc99 879 void *scan_cmd;
00700ee0 880 enum ieee80211_band scan_band;
1ecf9fc1 881 struct cfg80211_scan_request *scan_request;
f84b29ec 882 struct ieee80211_vif *scan_vif;
266af4c7 883 enum iwl_scan_type scan_type;
76eff18b
TW
884 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
885 u8 mgmt_tx_ant;
5d08cd1d 886
c10afb6e
JB
887 /* max number of station keys */
888 u8 sta_key_max_num;
889
d2690c0d
JB
890 bool new_scan_threshold_behaviour;
891
c6fa17ed
WYG
892 /* EEPROM MAC addresses */
893 struct mac_address addresses[2];
894
5d08cd1d 895 /* uCode images, save to reload in case of failure */
b08dfd04 896 int fw_index; /* firmware we're trying to load */
c02b3acd
CR
897 u32 ucode_ver; /* version of ucode, copy of
898 iwl_ucode.ver */
e98a1939 899
de7f5f92 900 enum iwl_ucode_type ucode_type;
b08dfd04 901 char firmware_name[25];
5d08cd1d 902
246ed355 903 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
5d08cd1d 904
6f213ff1 905 __le16 switch_channel;
0924e519 906
d7d5783c
JB
907 struct {
908 u32 error_event_table;
909 u32 log_event_table;
910 } device_pointers;
5d08cd1d 911
5d08cd1d 912 u16 active_rate;
5d08cd1d 913
5d08cd1d 914 u8 start_calib;
f0832f13
EG
915 struct iwl_sensitivity_data sensitivity_data;
916 struct iwl_chain_noise_data chain_noise_data;
c8312fac 917 bool enhance_sensitivity_table;
5d08cd1d 918 __le16 sensitivity_tbl[HD_TABLE_SIZE];
c8312fac 919 __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
5d08cd1d 920
fad95bf5 921 struct iwl_ht_config current_ht_config;
5d08cd1d 922
5d08cd1d 923 /* Rate scaling data */
5d08cd1d
CH
924 u8 retry_rate;
925
5d08cd1d
CH
926 int activity_timer_active;
927
19758bef 928 /* counts mgmt, ctl, and data packets */
22fdf3c9
WYG
929 struct traffic_stats tx_stats;
930 struct traffic_stats rx_stats;
19758bef 931
5da4b55f 932 struct iwl_power_mgr power_data;
3ad3b92a 933 struct iwl_tt_mgmt thermal_throttle;
5d08cd1d 934
9c5ac091 935 /* station table variables */
5d08cd1d 936 int num_stations;
3240cab3 937 struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
80fb47a1 938 unsigned long ucode_key_table;
5d08cd1d 939
859cfb0a
EG
940 u8 mac80211_registered;
941
5d08cd1d 942 /* Indication if ieee80211_ops->open has been called */
69dc5d9d 943 u8 is_open;
5d08cd1d 944
af6b8ee3 945 /* eeprom -- this is in the card's little endian byte order */
073d3f5f
TW
946 u8 *eeprom;
947 struct iwl_eeprom_calib_info *calib_info;
5d08cd1d 948
05c914fe 949 enum nl80211_iftype iw_mode;
5d08cd1d 950
5d08cd1d 951 /* Last Rx'd beacon timestamp */
3109ece1 952 u64 timestamp;
5d08cd1d 953
0da0e5bf
JB
954 struct {
955 __le32 flag;
956 struct statistics_general_common common;
957 struct statistics_rx_non_phy rx_non_phy;
958 struct statistics_rx_phy rx_ofdm;
959 struct statistics_rx_ht_phy rx_ofdm_ht;
960 struct statistics_rx_phy rx_cck;
961 struct statistics_tx tx;
962#ifdef CONFIG_IWLWIFI_DEBUGFS
963 struct statistics_bt_activity bt_activity;
964 __le32 num_bt_kills, accum_num_bt_kills;
965#endif
966 } statistics;
967#ifdef CONFIG_IWLWIFI_DEBUGFS
968 struct {
969 struct statistics_general_common common;
970 struct statistics_rx_non_phy rx_non_phy;
971 struct statistics_rx_phy rx_ofdm;
972 struct statistics_rx_ht_phy rx_ofdm_ht;
973 struct statistics_rx_phy rx_cck;
974 struct statistics_tx tx;
975 struct statistics_bt_activity bt_activity;
976 } accum_stats, delta_stats, max_delta_stats;
977#endif
978
898ed67b
WYG
979 /*
980 * reporting the number of tids has AGG on. 0 means
981 * no AGGREGATION
982 */
983 u8 agg_tids_count;
984
985 struct iwl_rx_phy_res last_phy_res;
986 bool last_phy_res_valid;
987
988 struct completion firmware_loading_complete;
989
990 u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr;
991 u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr;
992
993 /*
994 * chain noise reset and gain commands are the
995 * two extra calibration commands follows the standard
996 * phy calibration commands
997 */
998 u8 phy_calib_chain_noise_reset_cmd;
999 u8 phy_calib_chain_noise_gain_cmd;
1000
1001 /* counts reply_tx error */
1002 struct reply_tx_error_statistics reply_tx_stats;
1003 struct reply_agg_tx_error_statistics reply_agg_tx_stats;
1004 /* notification wait support */
1005 struct list_head notif_waits;
1006 spinlock_t notif_wait_lock;
1007 wait_queue_head_t notif_waitq;
1008
1009 /* remain-on-channel offload support */
1010 struct ieee80211_channel *hw_roc_channel;
c6baf7fb 1011 struct delayed_work hw_roc_disable_work;
898ed67b
WYG
1012 enum nl80211_channel_type hw_roc_chantype;
1013 int hw_roc_duration;
390808db 1014 bool hw_roc_setup, hw_roc_start_notified;
898ed67b 1015
22bf59a0 1016 /* bt coex */
f21dd005 1017 u8 bt_enable_flag;
da5dbb97 1018 u8 bt_status;
66e863a5 1019 u8 bt_traffic_load, last_bt_traffic_load;
f37837c9 1020 bool bt_ch_announce;
bee008b7
WYG
1021 bool bt_full_concurrent;
1022 bool bt_ant_couple_ok;
fbba9410
WYG
1023 __le32 kill_ack_mask;
1024 __le32 kill_cts_mask;
1025 __le16 bt_valid;
22bf59a0
WYG
1026 u16 bt_on_thresh;
1027 u16 bt_duration;
1028 u16 dynamic_frag_thresh;
bee008b7 1029 u8 bt_ci_compliance;
9e4afc21 1030 struct work_struct bt_traffic_change_work;
207ecc5e
MV
1031 bool bt_enable_pspoll;
1032 struct iwl_rxon_context *cur_rssi_ctx;
1033 bool bt_is_sco;
9e4afc21 1034
5d08cd1d 1035 struct work_struct restart;
5d08cd1d 1036 struct work_struct scan_completed;
5d08cd1d 1037 struct work_struct abort_scan;
12e934dc 1038
5d08cd1d 1039 struct work_struct beacon_update;
76d04815 1040 struct iwl_rxon_context *beacon_ctx;
12e934dc 1041 struct sk_buff *beacon_skb;
4ce7cc2b 1042 void *beacon_cmd;
76d04815 1043
a28027cd
WYG
1044 struct work_struct tt_work;
1045 struct work_struct ct_enter;
1046 struct work_struct ct_exit;
88be0264 1047 struct work_struct start_internal_scan;
65550636 1048 struct work_struct tx_flush;
bee008b7 1049 struct work_struct bt_full_concurrency;
fbba9410 1050 struct work_struct bt_runtime_config;
5d08cd1d 1051
5d08cd1d 1052 struct delayed_work scan_check;
4a8a4322 1053
630fe9b6
TW
1054 /* TX Power */
1055 s8 tx_power_user_lmt;
dc1b0973 1056 s8 tx_power_device_lmt;
ae16fc3c 1057 s8 tx_power_lmt_in_half_dbm; /* max tx power in half-dBm format */
a25a66ac 1058 s8 tx_power_next;
5d08cd1d 1059
712b6cf5
TW
1060#ifdef CONFIG_IWLWIFI_DEBUGFS
1061 /* debugfs */
20594eb0
WYG
1062 u16 tx_traffic_idx;
1063 u16 rx_traffic_idx;
1064 u8 *tx_traffic;
1065 u8 *rx_traffic;
4c84a8f1
JB
1066 struct dentry *debugfs_dir;
1067 u32 dbgfs_sram_offset, dbgfs_sram_len;
d73e4923 1068 bool disable_ht40;
c8ac61cf 1069 void *wowlan_sram;
712b6cf5 1070#endif /* CONFIG_IWLWIFI_DEBUGFS */
5d08cd1d
CH
1071
1072 struct work_struct txpower_work;
445c2dff
TW
1073 u32 disable_sens_cal;
1074 u32 disable_chain_noise_cal;
16e727e8 1075 struct work_struct run_time_calib_work;
5d08cd1d 1076 struct timer_list statistics_periodic;
a9e1cb6a 1077 struct timer_list ucode_trace;
22de94de 1078 struct timer_list watchdog;
a9e1cb6a
WYG
1079
1080 struct iwl_event_log event_log;
5ed540ae
WYG
1081
1082 struct led_classdev led;
1083 unsigned long blink_on, blink_off;
1084 bool led_registered;
7a4e5281
WYG
1085#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL
1086 struct iwl_testmode_trace testmode_trace;
4e308119 1087 u32 tm_fixed_rate;
c10e2c10 1088#endif
6489854b 1089
c8ac61cf
JB
1090 /* WoWLAN GTK rekey data */
1091 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
1092 __le64 replay_ctr;
1093 __le16 last_seq_ctl;
1094 bool have_rekey_data;
c79dd5b5 1095}; /*iwl_priv */
5d08cd1d 1096
48f20d35
EG
1097extern struct iwl_mod_params iwlagn_mod_params;
1098
246ed355
JB
1099static inline struct iwl_rxon_context *
1100iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
1101{
1102 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1103
1104 return vif_priv->ctx;
1105}
1106
1107#define for_each_context(priv, ctx) \
1108 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
1109 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
7a10e3e4 1110 if (priv->shrd->valid_contexts & BIT(ctx->ctxid))
246ed355 1111
054ec924 1112static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
246ed355 1113{
054ec924 1114 return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
246ed355
JB
1115}
1116
054ec924
JB
1117static inline int iwl_is_associated(struct iwl_priv *priv,
1118 enum iwl_rxon_context_id ctxid)
246ed355 1119{
054ec924 1120 return iwl_is_associated_ctx(&priv->contexts[ctxid]);
246ed355 1121}
a332f8d6 1122
054ec924 1123static inline int iwl_is_any_associated(struct iwl_priv *priv)
5d08cd1d 1124{
054ec924
JB
1125 struct iwl_rxon_context *ctx;
1126 for_each_context(priv, ctx)
1127 if (iwl_is_associated_ctx(ctx))
1128 return true;
1129 return false;
5d08cd1d
CH
1130}
1131
bf85ea4f 1132static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
5d08cd1d
CH
1133{
1134 if (ch_info == NULL)
1135 return 0;
1136 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
1137}
1138
bf85ea4f 1139static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
5d08cd1d
CH
1140{
1141 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
1142}
1143
bf85ea4f 1144static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
5d08cd1d 1145{
8318d78a 1146 return ch_info->band == IEEE80211_BAND_5GHZ;
5d08cd1d
CH
1147}
1148
bf85ea4f 1149static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
5d08cd1d 1150{
8318d78a 1151 return ch_info->band == IEEE80211_BAND_2GHZ;
5d08cd1d
CH
1152}
1153
bf85ea4f 1154static inline int is_channel_passive(const struct iwl_channel_info *ch)
5d08cd1d
CH
1155{
1156 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
1157}
1158
bf85ea4f 1159static inline int is_channel_ibss(const struct iwl_channel_info *ch)
5d08cd1d
CH
1160{
1161 return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
1162}
1163
be1f3ab6 1164#endif /* __iwl_dev_h__ */
This page took 1.619643 seconds and 4 git commands to generate.