iwlwifi: Change define and struct names in iwl-eeprom-parse.h
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / dvm / dev.h
CommitLineData
b481de9c
ZY
1/******************************************************************************
2 *
4e318262 3 * Copyright(c) 2003 - 2012 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 <ilw@linux.intel.com>
b481de9c
ZY
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
fcd427bb 26/*
1023fdc4
JB
27 * Please use this file (dev.h) for driver implementation definitions.
28 * Please use 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>
b1eea297 39#include <linux/mutex.h>
5d08cd1d 40
6238b008 41#include "iwl-fw.h"
26a7ca9a 42#include "iwl-eeprom-parse.h"
6f83eaa1 43#include "iwl-csr.h"
0a6857e7 44#include "iwl-debug.h"
b744cb79 45#include "iwl-agn-hw.h"
d0f76d68 46#include "iwl-op-mode.h"
4bd14dd5 47#include "iwl-notif-wait.h"
1023fdc4
JB
48#include "iwl-trans.h"
49
1023fdc4
JB
50#include "led.h"
51#include "power.h"
52#include "rs.h"
53#include "tt.h"
5d08cd1d 54
3a6490c0
IP
55#include "iwl-test.h"
56
099b40b7 57/* CT-KILL constants */
672639de
WYG
58#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 */
4bf775cd 61
5d08cd1d
CH
62/* Default noise level to report when noise measurement is not available.
63 * This may be because we're:
c4db6166 64 * 1) Not associated no beacon statistics being sent to driver)
5d08cd1d 65 * 2) Scanning (noise measurement does not apply to associated channel)
5d08cd1d 66 * Use default noise value of -127 ... this is below the range of measurable
c4db6166 67 * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
5d08cd1d
CH
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
bd35f150 93
5d08cd1d
CH
94#define IEEE80211_DATA_LEN 2304
95#define IEEE80211_4ADDR_LEN 30
96#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
97#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
98
5d08cd1d
CH
99#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
100#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
101#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
102
5d08cd1d
CH
103#define IWL_SUPPORTED_RATES_IE_LEN 8
104
5d08cd1d
CH
105#define IWL_INVALID_RATE 0xFF
106#define IWL_INVALID_VALUE -1
107
a78fe754 108union iwl_ht_rate_supp {
5d08cd1d
CH
109 u16 rates;
110 struct {
111 u8 siso_rate;
112 u8 mimo_rate;
113 };
114};
115
fad95bf5 116struct iwl_ht_config {
02bb1bea 117 bool single_chain_sufficient;
ba37a3d0 118 enum ieee80211_smps_mode smps; /* current smps mode */
5d08cd1d 119};
5d08cd1d 120
5d08cd1d 121/* QoS structures */
1ff50bda 122struct iwl_qos_info {
5d08cd1d 123 int qos_active;
1ff50bda 124 struct iwl_qosparam_cmd def_qos_parm;
5d08cd1d 125};
5d08cd1d 126
04cf6824
EG
127/**
128 * enum iwl_agg_state
129 *
130 * The state machine of the BA agreement establishment / tear down.
131 * These states relate to a specific RA / TID.
132 *
133 * @IWL_AGG_OFF: aggregation is not used
682e5f64 134 * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
04cf6824
EG
135 * @IWL_AGG_ON: aggregation session is up
136 * @IWL_EMPTYING_HW_QUEUE_ADDBA: establishing a BA session - waiting for the
137 * HW queue to be empty from packets for this RA /TID.
138 * @IWL_EMPTYING_HW_QUEUE_DELBA: tearing down a BA session - waiting for the
139 * HW queue to be empty from packets for this RA /TID.
140 */
141enum iwl_agg_state {
142 IWL_AGG_OFF = 0,
682e5f64 143 IWL_AGG_STARTING,
04cf6824
EG
144 IWL_AGG_ON,
145 IWL_EMPTYING_HW_QUEUE_ADDBA,
146 IWL_EMPTYING_HW_QUEUE_DELBA,
147};
148
149/**
150 * struct iwl_ht_agg - aggregation state machine
151
152 * This structs holds the states for the BA agreement establishment and tear
153 * down. It also holds the state during the BA session itself. This struct is
154 * duplicated for each RA / TID.
155
156 * @rate_n_flags: Rate at which Tx was attempted. Holds the data between the
157 * Tx response (REPLY_TX), and the block ack notification
158 * (REPLY_COMPRESSED_BA).
159 * @state: state of the BA agreement establishment / tear down.
9eae88fa 160 * @txq_id: Tx queue used by the BA session
04cf6824
EG
161 * @ssn: the first packet to be sent in AGG HW queue in Tx AGG start flow, or
162 * the first packet to be sent in legacy HW queue in Tx AGG stop flow.
163 * Basically when next_reclaimed reaches ssn, we can tell mac80211 that
164 * we are ready to finish the Tx AGG stop / start flow.
165 * @wait_for_ba: Expect block-ack before next Tx reply
166 */
167struct iwl_ht_agg {
168 u32 rate_n_flags;
169 enum iwl_agg_state state;
170 u16 txq_id;
171 u16 ssn;
172 bool wait_for_ba;
173};
174
175/**
176 * struct iwl_tid_data - one for each RA / TID
177
178 * This structs holds the states for each RA / TID.
179
180 * @seq_number: the next WiFi sequence number to use
181 * @next_reclaimed: the WiFi sequence number of the next packet to be acked.
182 * This is basically (last acked packet++).
183 * @agg: aggregation state machine
184 */
185struct iwl_tid_data {
186 u16 seq_number;
187 u16 next_reclaimed;
188 struct iwl_ht_agg agg;
189};
190
fe6b23dd
RC
191/*
192 * Structure should be accessed with sta_lock held. When station addition
193 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
194 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
195 * held.
196 */
6def9761 197struct iwl_station_entry {
133636de 198 struct iwl_addsta_cmd sta;
dcef732c 199 u8 used, ctxid;
fe6b23dd 200 struct iwl_link_quality_cmd *lq;
5d08cd1d
CH
201};
202
8d9698b3
RC
203/*
204 * iwl_station_priv: Driver's private station information
205 *
206 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
207 * in the structure for use by driver. This structure is places in that
208 * space.
8d9698b3
RC
209 */
210struct iwl_station_priv {
c6892906 211 struct iwl_rxon_context *ctx;
8d9698b3 212 struct iwl_lq_sta lq_sta;
6ab10ff8
JB
213 atomic_t pending_frames;
214 bool client;
215 bool asleep;
7b090687 216 u8 max_agg_bufsize;
c6892906 217 u8 sta_id;
8d9698b3
RC
218};
219
fd1af15d
JB
220/**
221 * struct iwl_vif_priv - driver's private per-interface information
222 *
223 * When mac80211 allocates a virtual interface, it can allocate
224 * space for us to put data into.
225 */
226struct iwl_vif_priv {
246ed355 227 struct iwl_rxon_context *ctx;
fd1af15d
JB
228 u8 ibss_bssid_sta_id;
229};
230
f0832f13
EG
231struct iwl_sensitivity_ranges {
232 u16 min_nrg_cck;
f0832f13
EG
233
234 u16 nrg_th_cck;
235 u16 nrg_th_ofdm;
236
237 u16 auto_corr_min_ofdm;
238 u16 auto_corr_min_ofdm_mrc;
239 u16 auto_corr_min_ofdm_x1;
240 u16 auto_corr_min_ofdm_mrc_x1;
241
242 u16 auto_corr_max_ofdm;
243 u16 auto_corr_max_ofdm_mrc;
244 u16 auto_corr_max_ofdm_x1;
245 u16 auto_corr_max_ofdm_mrc_x1;
246
247 u16 auto_corr_max_cck;
248 u16 auto_corr_max_cck_mrc;
249 u16 auto_corr_min_cck;
250 u16 auto_corr_min_cck_mrc;
55036d66
WYG
251
252 u16 barker_corr_th_min;
253 u16 barker_corr_th_min_mrc;
254 u16 nrg_th_cca;
f0832f13
EG
255};
256
099b40b7 257
b5047f78
TW
258#define KELVIN_TO_CELSIUS(x) ((x)-273)
259#define CELSIUS_TO_KELVIN(x) ((x)+273)
260
261
5d08cd1d
CH
262/******************************************************************************
263 *
a33c2f47
EG
264 * Functions implemented in core module which are forward declared here
265 * for use by iwl-[4-5].c
5d08cd1d 266 *
a33c2f47
EG
267 * NOTE: The implementation of these functions are not hardware specific
268 * which is why they are in the core module files.
5d08cd1d
CH
269 *
270 * Naming convention --
a33c2f47 271 * iwl_ <-- Is part of iwlwifi
5d08cd1d 272 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
5d08cd1d
CH
273 *
274 ****************************************************************************/
5b9f8cd3 275extern void iwl_update_chain_flags(struct iwl_priv *priv);
a33c2f47 276extern const u8 iwl_bcast_addr[ETH_ALEN];
fd4abac5 277
b481de9c
ZY
278#define IWL_OPERATION_MODE_AUTO 0
279#define IWL_OPERATION_MODE_HT_ONLY 1
280#define IWL_OPERATION_MODE_MIXED 2
281#define IWL_OPERATION_MODE_20MHZ 3
282
b481de9c 283#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
b481de9c 284
b481de9c 285/* Sensitivity and chain noise calibration */
b481de9c 286#define INITIALIZATION_VALUE 0xFFFF
d8c07e7a 287#define IWL_CAL_NUM_BEACONS 16
b481de9c
ZY
288#define MAXIMUM_ALLOWED_PATHLOSS 15
289
b481de9c
ZY
290#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
291
292#define MAX_FA_OFDM 50
293#define MIN_FA_OFDM 5
294#define MAX_FA_CCK 50
295#define MIN_FA_CCK 5
296
b481de9c
ZY
297#define AUTO_CORR_STEP_OFDM 1
298
b481de9c
ZY
299#define AUTO_CORR_STEP_CCK 3
300#define AUTO_CORR_MAX_TH_CCK 160
301
b481de9c
ZY
302#define NRG_DIFF 2
303#define NRG_STEP_CCK 2
304#define NRG_MARGIN 8
305#define MAX_NUMBER_CCK_NO_FA 100
306
307#define AUTO_CORR_CCK_MIN_VAL_DEF (125)
308
309#define CHAIN_A 0
310#define CHAIN_B 1
311#define CHAIN_C 2
312#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
313#define ALL_BAND_FILTER 0xFF00
314#define IN_BAND_FILTER 0xFF
315#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
316
3195cdb7
TW
317#define NRG_NUM_PREV_STAT_L 20
318#define NUM_RX_CHAINS 3
319
3240cab3 320enum iwlagn_false_alarm_state {
b481de9c
ZY
321 IWL_FA_TOO_MANY = 0,
322 IWL_FA_TOO_FEW = 1,
323 IWL_FA_GOOD_RANGE = 2,
324};
325
3240cab3 326enum iwlagn_chain_noise_state {
b481de9c 327 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
04816448
GE
328 IWL_CHAIN_NOISE_ACCUMULATE,
329 IWL_CHAIN_NOISE_CALIBRATED,
330 IWL_CHAIN_NOISE_DONE,
b481de9c
ZY
331};
332
b481de9c 333/* Sensitivity calib data */
f0832f13 334struct iwl_sensitivity_data {
b481de9c
ZY
335 u32 auto_corr_ofdm;
336 u32 auto_corr_ofdm_mrc;
337 u32 auto_corr_ofdm_x1;
338 u32 auto_corr_ofdm_mrc_x1;
339 u32 auto_corr_cck;
340 u32 auto_corr_cck_mrc;
341
342 u32 last_bad_plcp_cnt_ofdm;
343 u32 last_fa_cnt_ofdm;
344 u32 last_bad_plcp_cnt_cck;
345 u32 last_fa_cnt_cck;
346
347 u32 nrg_curr_state;
348 u32 nrg_prev_state;
349 u32 nrg_value[10];
350 u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
351 u32 nrg_silence_ref;
352 u32 nrg_energy_idx;
353 u32 nrg_silence_idx;
354 u32 nrg_th_cck;
355 s32 nrg_auto_corr_silence_diff;
356 u32 num_in_cck_no_fa;
357 u32 nrg_th_ofdm;
55036d66
WYG
358
359 u16 barker_corr_th_min;
360 u16 barker_corr_th_min_mrc;
361 u16 nrg_th_cca;
b481de9c
ZY
362};
363
364/* Chain noise (differential Rx gain) calib data */
f0832f13 365struct iwl_chain_noise_data {
04816448 366 u32 active_chains;
b481de9c
ZY
367 u32 chain_noise_a;
368 u32 chain_noise_b;
369 u32 chain_noise_c;
370 u32 chain_signal_a;
371 u32 chain_signal_b;
372 u32 chain_signal_c;
04816448 373 u16 beacon_count;
b481de9c
ZY
374 u8 disconn_array[NUM_RX_CHAINS];
375 u8 delta_gain_code[NUM_RX_CHAINS];
376 u8 radio_write;
04816448 377 u8 state;
b481de9c
ZY
378};
379
5d08cd1d
CH
380enum {
381 MEASUREMENT_READY = (1 << 0),
382 MEASUREMENT_ACTIVE = (1 << 1),
383};
384
91835ba4
WYG
385/* reply_tx_statistics (for _agn devices) */
386struct reply_tx_error_statistics {
387 u32 pp_delay;
388 u32 pp_few_bytes;
389 u32 pp_bt_prio;
390 u32 pp_quiet_period;
391 u32 pp_calc_ttak;
392 u32 int_crossed_retry;
393 u32 short_limit;
394 u32 long_limit;
395 u32 fifo_underrun;
396 u32 drain_flow;
397 u32 rfkill_flush;
398 u32 life_expire;
399 u32 dest_ps;
400 u32 host_abort;
401 u32 bt_retry;
402 u32 sta_invalid;
403 u32 frag_drop;
404 u32 tid_disable;
405 u32 fifo_flush;
406 u32 insuff_cf_poll;
407 u32 fail_hw_drop;
408 u32 sta_color_mismatch;
409 u32 unknown;
410};
411
814665fe
WYG
412/* reply_agg_tx_statistics (for _agn devices) */
413struct reply_agg_tx_error_statistics {
414 u32 underrun;
415 u32 bt_prio;
416 u32 few_bytes;
417 u32 abort;
418 u32 last_sent_ttl;
419 u32 last_sent_try;
420 u32 last_sent_bt_kill;
421 u32 scd_query;
422 u32 bad_crc32;
423 u32 response;
424 u32 dump_tx;
425 u32 delay_tx;
426 u32 unknown;
427};
428
a9e1cb6a
WYG
429/*
430 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
431 * to perform continuous uCode event logging operation if enabled
432 */
98d4bf0c 433#define UCODE_TRACE_PERIOD (10)
a9e1cb6a
WYG
434
435/*
436 * iwl_event_log: current uCode event log position
437 *
438 * @ucode_trace: enable/disable ucode continuous trace timer
439 * @num_wraps: how many times the event buffer wraps
440 * @next_entry: the entry just before the next one that uCode would fill
441 * @non_wraps_count: counter for no wrap detected when dump ucode events
442 * @wraps_once_count: counter for wrap once detected when dump ucode events
443 * @wraps_more_count: counter for wrap more than once detected
444 * when dump ucode events
445 */
446struct iwl_event_log {
447 bool ucode_trace;
448 u32 num_wraps;
449 u32 next_entry;
450 int non_wraps_count;
451 int wraps_once_count;
452 int wraps_more_count;
453};
454
8a472da4 455#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
8a472da4 456
bee008b7
WYG
457/* BT Antenna Coupling Threshold (dB) */
458#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
459
491bc292
WYG
460/* Firmware reload counter and Timestamp */
461#define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
462#define IWL_MAX_CONTINUE_RELOAD_CNT 4
463
464
48dffd39 465struct iwl_rf_reset {
8a472da4
WYG
466 int reset_request_count;
467 int reset_success_count;
468 int reset_reject_count;
48dffd39 469 unsigned long last_reset_jiffies;
a93e7973
WYG
470};
471
4806f626
EG
472enum iwl_rxon_context_id {
473 IWL_RXON_CTX_BSS,
474 IWL_RXON_CTX_PAN,
475
476 NUM_IWL_RXON_CTX
477};
478
a0ee74cf 479/* extend beacon time format bit shifting */
a0ee74cf
WYG
480/*
481 * for _agn devices
482 * bits 31:22 - extended
483 * bits 21:0 - interval
484 */
485#define IWLAGN_EXT_BEACON_TIME_POS 22
486
246ed355 487struct iwl_rxon_context {
8bd413e6 488 struct ieee80211_vif *vif;
e72f368b 489
9eae88fa
JB
490 u8 mcast_queue;
491 u8 ac_to_queue[IEEE80211_NUM_ACS];
492 u8 ac_to_fifo[IEEE80211_NUM_ACS];
493
763cc3bf
JB
494 /*
495 * We could use the vif to indicate active, but we
496 * also need it to be active during disabling when
497 * we already removed the vif for type setting.
498 */
499 bool always_active, is_active;
500
2295c66b
JB
501 bool ht_need_multiple_chains;
502
246ed355 503 enum iwl_rxon_context_id ctxid;
d0fe478c
JB
504
505 u32 interface_modes, exclusive_interface_modes;
506 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
507
246ed355
JB
508 /*
509 * We declare this const so it can only be
510 * changed via explicit cast within the
511 * routines that actually update the physical
512 * hardware.
513 */
514 const struct iwl_rxon_cmd active;
515 struct iwl_rxon_cmd staging;
516
517 struct iwl_rxon_time_cmd timing;
a194e324 518
8dfdb9d5
JB
519 struct iwl_qos_info qos_data;
520
2995bafa 521 u8 bcast_sta_id, ap_sta_id;
8f2d3d2a
JB
522
523 u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
8dfdb9d5 524 u8 qos_cmd;
c10afb6e
JB
525 u8 wep_key_cmd;
526
527 struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
528 u8 key_mapping_keys;
770e13bd
JB
529
530 __le32 station_flags;
7e6a5886 531
bbb05cb5
JB
532 int beacon_int;
533
7e6a5886
JB
534 struct {
535 bool non_gf_sta_present;
536 u8 protection;
537 bool enabled, is_40mhz;
538 u8 extension_chan_offset;
539 } ht;
246ed355
JB
540};
541
266af4c7
JB
542enum iwl_scan_type {
543 IWL_SCAN_NORMAL,
544 IWL_SCAN_RADIO_RESET,
c6baf7fb 545 IWL_SCAN_ROC,
266af4c7
JB
546};
547
9e295116
JB
548/**
549 * struct iwl_hw_params
550 *
551 * Holds the module parameters
552 *
553 * @tx_chains_num: Number of TX chains
554 * @rx_chains_num: Number of RX chains
9e295116
JB
555 * @ct_kill_threshold: temperature threshold - in hw dependent unit
556 * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit
557 * relevant for 1000, 6000 and up
558 * @struct iwl_sensitivity_ranges: range of sensitivity values
559 * @use_rts_for_aggregation: use rts/cts protection for HT traffic
560 */
561struct iwl_hw_params {
562 u8 tx_chains_num;
563 u8 rx_chains_num;
9e295116 564 bool use_rts_for_aggregation;
9e295116
JB
565 u32 ct_kill_threshold;
566 u32 ct_kill_exit_threshold;
567
568 const struct iwl_sensitivity_ranges *sens;
569};
570
e9676695
JB
571struct iwl_lib_ops {
572 /* set hw dependent parameters */
573 void (*set_hw_params)(struct iwl_priv *priv);
574 int (*set_channel_switch)(struct iwl_priv *priv,
575 struct ieee80211_channel_switch *ch_switch);
576 /* device specific configuration */
577 void (*nic_config)(struct iwl_priv *priv);
578
e9676695
JB
579 /* temperature */
580 void (*temperature)(struct iwl_priv *priv);
581};
582
79d3eef8
JB
583struct iwl_wipan_noa_data {
584 struct rcu_head rcu_head;
585 u32 length;
586 u8 data[];
587};
588
bfb45f54 589/* Calibration disabling bit mask */
5c457d03
DS
590enum {
591 IWL_CALIB_ENABLE_ALL = 0,
592
593 IWL_SENSITIVITY_CALIB_DISABLED = BIT(0),
594 IWL_CHAIN_NOISE_CALIB_DISABLED = BIT(1),
595 IWL_TX_POWER_CALIB_DISABLED = BIT(2),
bfb45f54 596
5c457d03
DS
597 IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF,
598};
bfb45f54 599
d0f76d68
EG
600#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
601 ((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))
602
603#define IWL_MAC80211_GET_DVM(_hw) \
604 ((struct iwl_priv *) ((struct iwl_op_mode *) \
605 (_hw)->priv)->op_mode_specific)
606
c79dd5b5 607struct iwl_priv {
5d08cd1d 608
68e8dfda 609 struct iwl_trans *trans;
4b9844f5 610 struct device *dev; /* for debug prints only */
2152268f 611 const struct iwl_cfg *cfg;
0692fe41 612 const struct iwl_fw *fw;
e9676695 613 const struct iwl_lib_ops *lib;
9a716863 614 unsigned long status;
cac988a6 615
fa23cb04 616 spinlock_t sta_lock;
b1eea297 617 struct mutex mutex;
fa23cb04 618
e755f882
JB
619 unsigned long transport_queue_stop;
620 bool passive_no_rx;
1479177b
JB
621#define IWL_INVALID_MAC80211_QUEUE 0xff
622 u8 queue_to_mac80211[IWL_MAX_HW_QUEUES];
623 atomic_t queue_stop_count[IWL_MAX_HW_QUEUES];
9eae88fa
JB
624
625 unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
e755f882 626
5d08cd1d
CH
627 /* ieee device used by generic ieee processing code */
628 struct ieee80211_hw *hw;
5d08cd1d 629
e1991885
JB
630 struct list_head calib_results;
631
1ee158d8
JB
632 struct workqueue_struct *workqueue;
633
9e295116
JB
634 struct iwl_hw_params hw_params;
635
8318d78a 636 enum ieee80211_band band;
a18f61bc 637 u8 valid_contexts;
5d08cd1d 638
247c61d6 639 int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
48a2d66f 640 struct iwl_rx_cmd_buffer *rxb,
247c61d6 641 struct iwl_device_cmd *cmd);
5d08cd1d 642
4bd14dd5
JB
643 struct iwl_notif_wait_data notif_wait;
644
5d08cd1d 645 /* spectrum measurement report caching */
2aa6ab86 646 struct iwl_spectrum_notification measure_report;
5d08cd1d 647 u8 measurement_status;
81963d68 648
947a9407
JB
649#define IWL_OWNERSHIP_DRIVER 0
650#define IWL_OWNERSHIP_TM 1
651 u8 ucode_owner;
652
5d08cd1d
CH
653 /* ucode beacon time */
654 u32 ucode_beacon_time;
a13d276f 655 int missed_beacon_threshold;
5d08cd1d 656
a85d7cca
JB
657 /* track IBSS manager (last beacon) status */
658 u32 ibss_manager;
659
410f2bb3
SG
660 /* jiffies when last recovery from statistics was performed */
661 unsigned long rx_statistics_jiffies;
3e4fb5fa 662
1f7b6172
EG
663 /*counters */
664 u32 rx_handlers_stats[REPLY_MAX];
665
48dffd39
JB
666 /* rf reset */
667 struct iwl_rf_reset rf_reset;
a93e7973 668
491bc292
WYG
669 /* firmware reload counter and timestamp */
670 unsigned long reload_jiffies;
671 int reload_count;
8f7ffbe2 672 bool ucode_loaded;
b5ea1624 673 bool init_ucode_run; /* Don't run init uCode again */
491bc292 674
ab5c0f1f
JB
675 u8 plcp_delta_threshold;
676
5d08cd1d 677 /* thermal calibration */
02883562 678 s32 temperature; /* Celsius */
5d08cd1d
CH
679 s32 last_temperature;
680
79d3eef8
JB
681 struct iwl_wipan_noa_data __rcu *noa_data;
682
5d08cd1d 683 /* Scan related variables */
5d08cd1d 684 unsigned long scan_start;
5d08cd1d 685 unsigned long scan_start_tsf;
811ecc99 686 void *scan_cmd;
00700ee0 687 enum ieee80211_band scan_band;
1ecf9fc1 688 struct cfg80211_scan_request *scan_request;
f84b29ec 689 struct ieee80211_vif *scan_vif;
266af4c7 690 enum iwl_scan_type scan_type;
76eff18b
TW
691 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
692 u8 mgmt_tx_ant;
5d08cd1d 693
c10afb6e
JB
694 /* max number of station keys */
695 u8 sta_key_max_num;
696
d2690c0d
JB
697 bool new_scan_threshold_behaviour;
698
15b86bff
JB
699 bool wowlan;
700
c6fa17ed
WYG
701 /* EEPROM MAC addresses */
702 struct mac_address addresses[2];
703
246ed355 704 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
5d08cd1d 705
6f213ff1 706 __le16 switch_channel;
0924e519 707
5d08cd1d 708 u8 start_calib;
f0832f13
EG
709 struct iwl_sensitivity_data sensitivity_data;
710 struct iwl_chain_noise_data chain_noise_data;
5d08cd1d 711 __le16 sensitivity_tbl[HD_TABLE_SIZE];
c8312fac 712 __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
5d08cd1d 713
fad95bf5 714 struct iwl_ht_config current_ht_config;
5d08cd1d 715
5d08cd1d 716 /* Rate scaling data */
5d08cd1d
CH
717 u8 retry_rate;
718
5d08cd1d
CH
719 int activity_timer_active;
720
5da4b55f 721 struct iwl_power_mgr power_data;
3ad3b92a 722 struct iwl_tt_mgmt thermal_throttle;
5d08cd1d 723
9c5ac091 724 /* station table variables */
5d08cd1d 725 int num_stations;
3240cab3 726 struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
80fb47a1 727 unsigned long ucode_key_table;
04cf6824 728 struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT];
622a9268 729 atomic_t num_aux_in_flight;
5d08cd1d 730
859cfb0a
EG
731 u8 mac80211_registered;
732
5d08cd1d 733 /* Indication if ieee80211_ops->open has been called */
69dc5d9d 734 u8 is_open;
5d08cd1d 735
05c914fe 736 enum nl80211_iftype iw_mode;
5d08cd1d 737
5d08cd1d 738 /* Last Rx'd beacon timestamp */
3109ece1 739 u64 timestamp;
5d08cd1d 740
0da0e5bf
JB
741 struct {
742 __le32 flag;
743 struct statistics_general_common common;
744 struct statistics_rx_non_phy rx_non_phy;
745 struct statistics_rx_phy rx_ofdm;
746 struct statistics_rx_ht_phy rx_ofdm_ht;
747 struct statistics_rx_phy rx_cck;
748 struct statistics_tx tx;
749#ifdef CONFIG_IWLWIFI_DEBUGFS
750 struct statistics_bt_activity bt_activity;
751 __le32 num_bt_kills, accum_num_bt_kills;
752#endif
4ff70fcd 753 spinlock_t lock;
0da0e5bf
JB
754 } statistics;
755#ifdef CONFIG_IWLWIFI_DEBUGFS
756 struct {
757 struct statistics_general_common common;
758 struct statistics_rx_non_phy rx_non_phy;
759 struct statistics_rx_phy rx_ofdm;
760 struct statistics_rx_ht_phy rx_ofdm_ht;
761 struct statistics_rx_phy rx_cck;
762 struct statistics_tx tx;
763 struct statistics_bt_activity bt_activity;
764 } accum_stats, delta_stats, max_delta_stats;
765#endif
766
898ed67b
WYG
767 /*
768 * reporting the number of tids has AGG on. 0 means
769 * no AGGREGATION
770 */
771 u8 agg_tids_count;
772
773 struct iwl_rx_phy_res last_phy_res;
12bf6f45 774 u32 ampdu_ref;
898ed67b
WYG
775 bool last_phy_res_valid;
776
898ed67b
WYG
777 /*
778 * chain noise reset and gain commands are the
779 * two extra calibration commands follows the standard
780 * phy calibration commands
781 */
782 u8 phy_calib_chain_noise_reset_cmd;
783 u8 phy_calib_chain_noise_gain_cmd;
784
785 /* counts reply_tx error */
786 struct reply_tx_error_statistics reply_tx_stats;
787 struct reply_agg_tx_error_statistics reply_agg_tx_stats;
898ed67b
WYG
788
789 /* remain-on-channel offload support */
790 struct ieee80211_channel *hw_roc_channel;
c6baf7fb 791 struct delayed_work hw_roc_disable_work;
898ed67b
WYG
792 enum nl80211_channel_type hw_roc_chantype;
793 int hw_roc_duration;
390808db 794 bool hw_roc_setup, hw_roc_start_notified;
898ed67b 795
22bf59a0 796 /* bt coex */
f21dd005 797 u8 bt_enable_flag;
da5dbb97 798 u8 bt_status;
66e863a5 799 u8 bt_traffic_load, last_bt_traffic_load;
f37837c9 800 bool bt_ch_announce;
bee008b7
WYG
801 bool bt_full_concurrent;
802 bool bt_ant_couple_ok;
fbba9410
WYG
803 __le32 kill_ack_mask;
804 __le32 kill_cts_mask;
805 __le16 bt_valid;
354ce4a4 806 bool reduced_txpower;
22bf59a0
WYG
807 u16 bt_on_thresh;
808 u16 bt_duration;
809 u16 dynamic_frag_thresh;
bee008b7 810 u8 bt_ci_compliance;
9e4afc21 811 struct work_struct bt_traffic_change_work;
207ecc5e
MV
812 bool bt_enable_pspoll;
813 struct iwl_rxon_context *cur_rssi_ctx;
814 bool bt_is_sco;
9e4afc21 815
5d08cd1d 816 struct work_struct restart;
5d08cd1d 817 struct work_struct scan_completed;
5d08cd1d 818 struct work_struct abort_scan;
12e934dc 819
5d08cd1d 820 struct work_struct beacon_update;
76d04815 821 struct iwl_rxon_context *beacon_ctx;
12e934dc 822 struct sk_buff *beacon_skb;
4ce7cc2b 823 void *beacon_cmd;
76d04815 824
a28027cd
WYG
825 struct work_struct tt_work;
826 struct work_struct ct_enter;
827 struct work_struct ct_exit;
88be0264 828 struct work_struct start_internal_scan;
65550636 829 struct work_struct tx_flush;
bee008b7 830 struct work_struct bt_full_concurrency;
fbba9410 831 struct work_struct bt_runtime_config;
5d08cd1d 832
5d08cd1d 833 struct delayed_work scan_check;
4a8a4322 834
26a7ca9a 835 /* TX Power settings */
630fe9b6 836 s8 tx_power_user_lmt;
a25a66ac 837 s8 tx_power_next;
5d08cd1d 838
712b6cf5
TW
839#ifdef CONFIG_IWLWIFI_DEBUGFS
840 /* debugfs */
4c84a8f1
JB
841 struct dentry *debugfs_dir;
842 u32 dbgfs_sram_offset, dbgfs_sram_len;
d73e4923 843 bool disable_ht40;
c8ac61cf 844 void *wowlan_sram;
712b6cf5 845#endif /* CONFIG_IWLWIFI_DEBUGFS */
5d08cd1d 846
b7998c8b 847 struct iwl_nvm_data *nvm_data;
26a7ca9a
JB
848 /* eeprom blob for debugfs/testmode */
849 u8 *eeprom_blob;
850 size_t eeprom_blob_size;
11483b5c 851
5d08cd1d 852 struct work_struct txpower_work;
bfb45f54 853 u32 calib_disabled;
16e727e8 854 struct work_struct run_time_calib_work;
5d08cd1d 855 struct timer_list statistics_periodic;
a9e1cb6a 856 struct timer_list ucode_trace;
a9e1cb6a
WYG
857
858 struct iwl_event_log event_log;
5ed540ae
WYG
859
860 struct led_classdev led;
861 unsigned long blink_on, blink_off;
862 bool led_registered;
3a6490c0 863
5ef15ccc 864#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
3a6490c0 865 struct iwl_test tst;
4e308119 866 u32 tm_fixed_rate;
c10e2c10 867#endif
6489854b 868
c8ac61cf
JB
869 /* WoWLAN GTK rekey data */
870 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
871 __le64 replay_ctr;
872 __le16 last_seq_ctl;
873 bool have_rekey_data;
2fdfc476
MV
874
875 /* device_pointers: pointers to ucode event tables */
876 struct {
877 u32 error_event_table;
878 u32 log_event_table;
879 } device_pointers;
a42506eb
MV
880
881 /* indicator of loaded ucode image */
882 enum iwl_ucode_type cur_ucode;
c79dd5b5 883}; /*iwl_priv */
5d08cd1d 884
246ed355
JB
885static inline struct iwl_rxon_context *
886iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
887{
888 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
889
890 return vif_priv->ctx;
891}
892
893#define for_each_context(priv, ctx) \
894 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
895 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
a18f61bc 896 if (priv->valid_contexts & BIT(ctx->ctxid))
246ed355 897
054ec924 898static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
246ed355 899{
054ec924 900 return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
246ed355
JB
901}
902
054ec924
JB
903static inline int iwl_is_associated(struct iwl_priv *priv,
904 enum iwl_rxon_context_id ctxid)
246ed355 905{
054ec924 906 return iwl_is_associated_ctx(&priv->contexts[ctxid]);
246ed355 907}
a332f8d6 908
054ec924 909static inline int iwl_is_any_associated(struct iwl_priv *priv)
5d08cd1d 910{
054ec924
JB
911 struct iwl_rxon_context *ctx;
912 for_each_context(priv, ctx)
913 if (iwl_is_associated_ctx(ctx))
914 return true;
915 return false;
5d08cd1d
CH
916}
917
be1f3ab6 918#endif /* __iwl_dev_h__ */
This page took 1.097478 seconds and 5 git commands to generate.