Merge tag 'for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux...
[deliverable/linux.git] / drivers / net / wireless / iwlwifi / dvm / dev.h
CommitLineData
b481de9c
ZY
1/******************************************************************************
2 *
51368bf7 3 * Copyright(c) 2003 - 2014 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
099b40b7 55/* CT-KILL constants */
672639de
WYG
56#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 */
4bf775cd 59
5d08cd1d
CH
60/* Default noise level to report when noise measurement is not available.
61 * This may be because we're:
c4db6166 62 * 1) Not associated no beacon statistics being sent to driver)
5d08cd1d 63 * 2) Scanning (noise measurement does not apply to associated channel)
5d08cd1d 64 * Use default noise value of -127 ... this is below the range of measurable
c4db6166 65 * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
5d08cd1d
CH
66 * 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
5d08cd1d
CH
72/*
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
51b7ef05 85#define DEFAULT_BEACON_INTERVAL 200U
5d08cd1d
CH
86#define DEFAULT_SHORT_RETRY_LIMIT 7U
87#define DEFAULT_LONG_RETRY_LIMIT 4U
88
5d08cd1d
CH
89#define IWL_NUM_SCAN_RATES (2)
90
bd35f150 91
5d08cd1d
CH
92#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
5d08cd1d
CH
97#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
5d08cd1d
CH
101#define IWL_SUPPORTED_RATES_IE_LEN 8
102
5d08cd1d
CH
103#define IWL_INVALID_RATE 0xFF
104#define IWL_INVALID_VALUE -1
105
a78fe754 106union iwl_ht_rate_supp {
5d08cd1d
CH
107 u16 rates;
108 struct {
109 u8 siso_rate;
110 u8 mimo_rate;
111 };
112};
113
fad95bf5 114struct iwl_ht_config {
02bb1bea 115 bool single_chain_sufficient;
ba37a3d0 116 enum ieee80211_smps_mode smps; /* current smps mode */
5d08cd1d 117};
5d08cd1d 118
5d08cd1d 119/* QoS structures */
1ff50bda 120struct iwl_qos_info {
5d08cd1d 121 int qos_active;
1ff50bda 122 struct iwl_qosparam_cmd def_qos_parm;
5d08cd1d 123};
5d08cd1d 124
04cf6824
EG
125/**
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
682e5f64 132 * @IWL_AGG_STARTING: aggregation are starting (between start and oper)
04cf6824
EG
133 * @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,
682e5f64 141 IWL_AGG_STARTING,
04cf6824
EG
142 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.
9eae88fa 158 * @txq_id: Tx queue used by the BA session
04cf6824
EG
159 * @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
fe6b23dd
RC
189/*
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 */
6def9761 195struct iwl_station_entry {
133636de 196 struct iwl_addsta_cmd sta;
dcef732c 197 u8 used, ctxid;
fe6b23dd 198 struct iwl_link_quality_cmd *lq;
5d08cd1d
CH
199};
200
8d9698b3
RC
201/*
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.
8d9698b3
RC
207 */
208struct iwl_station_priv {
c6892906 209 struct iwl_rxon_context *ctx;
8d9698b3 210 struct iwl_lq_sta lq_sta;
6ab10ff8
JB
211 atomic_t pending_frames;
212 bool client;
213 bool asleep;
7b090687 214 u8 max_agg_bufsize;
c6892906 215 u8 sta_id;
8d9698b3
RC
216};
217
fd1af15d
JB
218/**
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 {
246ed355 225 struct iwl_rxon_context *ctx;
fd1af15d
JB
226 u8 ibss_bssid_sta_id;
227};
228
f0832f13
EG
229struct iwl_sensitivity_ranges {
230 u16 min_nrg_cck;
f0832f13
EG
231
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;
55036d66
WYG
249
250 u16 barker_corr_th_min;
251 u16 barker_corr_th_min_mrc;
252 u16 nrg_th_cca;
f0832f13
EG
253};
254
099b40b7 255
b5047f78
TW
256#define KELVIN_TO_CELSIUS(x) ((x)-273)
257#define CELSIUS_TO_KELVIN(x) ((x)+273)
258
259
5d08cd1d
CH
260/******************************************************************************
261 *
a33c2f47
EG
262 * Functions implemented in core module which are forward declared here
263 * for use by iwl-[4-5].c
5d08cd1d 264 *
a33c2f47
EG
265 * NOTE: The implementation of these functions are not hardware specific
266 * which is why they are in the core module files.
5d08cd1d
CH
267 *
268 * Naming convention --
a33c2f47 269 * iwl_ <-- Is part of iwlwifi
5d08cd1d 270 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
5d08cd1d
CH
271 *
272 ****************************************************************************/
b3818394 273void iwl_update_chain_flags(struct iwl_priv *priv);
a33c2f47 274extern const u8 iwl_bcast_addr[ETH_ALEN];
fd4abac5 275
b481de9c
ZY
276#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
b481de9c 281#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
b481de9c 282
b481de9c 283/* Sensitivity and chain noise calibration */
b481de9c 284#define INITIALIZATION_VALUE 0xFFFF
d8c07e7a 285#define IWL_CAL_NUM_BEACONS 16
b481de9c
ZY
286#define MAXIMUM_ALLOWED_PATHLOSS 15
287
b481de9c
ZY
288#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
b481de9c
ZY
295#define AUTO_CORR_STEP_OFDM 1
296
b481de9c
ZY
297#define AUTO_CORR_STEP_CCK 3
298#define AUTO_CORR_MAX_TH_CCK 160
299
b481de9c
ZY
300#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
3195cdb7
TW
315#define NRG_NUM_PREV_STAT_L 20
316#define NUM_RX_CHAINS 3
317
3240cab3 318enum iwlagn_false_alarm_state {
b481de9c
ZY
319 IWL_FA_TOO_MANY = 0,
320 IWL_FA_TOO_FEW = 1,
321 IWL_FA_GOOD_RANGE = 2,
322};
323
3240cab3 324enum iwlagn_chain_noise_state {
b481de9c 325 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
04816448
GE
326 IWL_CHAIN_NOISE_ACCUMULATE,
327 IWL_CHAIN_NOISE_CALIBRATED,
328 IWL_CHAIN_NOISE_DONE,
b481de9c
ZY
329};
330
b481de9c 331/* Sensitivity calib data */
f0832f13 332struct iwl_sensitivity_data {
b481de9c
ZY
333 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;
55036d66
WYG
356
357 u16 barker_corr_th_min;
358 u16 barker_corr_th_min_mrc;
359 u16 nrg_th_cca;
b481de9c
ZY
360};
361
362/* Chain noise (differential Rx gain) calib data */
f0832f13 363struct iwl_chain_noise_data {
04816448 364 u32 active_chains;
b481de9c
ZY
365 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;
04816448 371 u16 beacon_count;
b481de9c
ZY
372 u8 disconn_array[NUM_RX_CHAINS];
373 u8 delta_gain_code[NUM_RX_CHAINS];
374 u8 radio_write;
04816448 375 u8 state;
b481de9c
ZY
376};
377
5d08cd1d
CH
378enum {
379 MEASUREMENT_READY = (1 << 0),
380 MEASUREMENT_ACTIVE = (1 << 1),
381};
382
91835ba4
WYG
383/* 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
814665fe
WYG
410/* 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
a9e1cb6a
WYG
427/*
428 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
429 * to perform continuous uCode event logging operation if enabled
430 */
98d4bf0c 431#define UCODE_TRACE_PERIOD (10)
a9e1cb6a
WYG
432
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
8a472da4 453#define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
8a472da4 454
bee008b7
WYG
455/* BT Antenna Coupling Threshold (dB) */
456#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
457
491bc292
WYG
458/* Firmware reload counter and Timestamp */
459#define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
460#define IWL_MAX_CONTINUE_RELOAD_CNT 4
461
462
48dffd39 463struct iwl_rf_reset {
8a472da4
WYG
464 int reset_request_count;
465 int reset_success_count;
466 int reset_reject_count;
48dffd39 467 unsigned long last_reset_jiffies;
a93e7973
WYG
468};
469
4806f626
EG
470enum iwl_rxon_context_id {
471 IWL_RXON_CTX_BSS,
472 IWL_RXON_CTX_PAN,
473
474 NUM_IWL_RXON_CTX
475};
476
a0ee74cf 477/* extend beacon time format bit shifting */
a0ee74cf
WYG
478/*
479 * for _agn devices
480 * bits 31:22 - extended
481 * bits 21:0 - interval
482 */
483#define IWLAGN_EXT_BEACON_TIME_POS 22
484
246ed355 485struct iwl_rxon_context {
8bd413e6 486 struct ieee80211_vif *vif;
e72f368b 487
9eae88fa
JB
488 u8 mcast_queue;
489 u8 ac_to_queue[IEEE80211_NUM_ACS];
490 u8 ac_to_fifo[IEEE80211_NUM_ACS];
491
763cc3bf
JB
492 /*
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
2295c66b
JB
499 bool ht_need_multiple_chains;
500
246ed355 501 enum iwl_rxon_context_id ctxid;
d0fe478c
JB
502
503 u32 interface_modes, exclusive_interface_modes;
504 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
505
246ed355
JB
506 /*
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;
a194e324 516
8dfdb9d5
JB
517 struct iwl_qos_info qos_data;
518
2995bafa 519 u8 bcast_sta_id, ap_sta_id;
8f2d3d2a
JB
520
521 u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
8dfdb9d5 522 u8 qos_cmd;
c10afb6e
JB
523 u8 wep_key_cmd;
524
525 struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
526 u8 key_mapping_keys;
770e13bd
JB
527
528 __le32 station_flags;
7e6a5886 529
bbb05cb5
JB
530 int beacon_int;
531
7e6a5886
JB
532 struct {
533 bool non_gf_sta_present;
534 u8 protection;
535 bool enabled, is_40mhz;
536 u8 extension_chan_offset;
537 } ht;
246ed355
JB
538};
539
266af4c7
JB
540enum iwl_scan_type {
541 IWL_SCAN_NORMAL,
542 IWL_SCAN_RADIO_RESET,
266af4c7
JB
543};
544
9e295116
JB
545/**
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
9e295116
JB
552 * @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;
9e295116 561 bool use_rts_for_aggregation;
9e295116
JB
562 u32 ct_kill_threshold;
563 u32 ct_kill_exit_threshold;
564
565 const struct iwl_sensitivity_ranges *sens;
566};
567
0d8877a1
JB
568/**
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 */
ee4d5471 605struct iwl_dvm_cfg {
e9676695
JB
606 void (*set_hw_params)(struct iwl_priv *priv);
607 int (*set_channel_switch)(struct iwl_priv *priv,
608 struct ieee80211_channel_switch *ch_switch);
e9676695 609 void (*nic_config)(struct iwl_priv *priv);
e9676695 610 void (*temperature)(struct iwl_priv *priv);
0d8877a1
JB
611
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;
e9676695
JB
623};
624
79d3eef8
JB
625struct iwl_wipan_noa_data {
626 struct rcu_head rcu_head;
627 u32 length;
628 u8 data[];
629};
630
bfb45f54 631/* Calibration disabling bit mask */
5c457d03
DS
632enum {
633 IWL_CALIB_ENABLE_ALL = 0,
634
635 IWL_SENSITIVITY_CALIB_DISABLED = BIT(0),
636 IWL_CHAIN_NOISE_CALIB_DISABLED = BIT(1),
637 IWL_TX_POWER_CALIB_DISABLED = BIT(2),
bfb45f54 638
5c457d03
DS
639 IWL_CALIB_DISABLE_ALL = 0xFFFFFFFF,
640};
bfb45f54 641
d0f76d68
EG
642#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
c79dd5b5 649struct iwl_priv {
5d08cd1d 650
68e8dfda 651 struct iwl_trans *trans;
4b9844f5 652 struct device *dev; /* for debug prints only */
2152268f 653 const struct iwl_cfg *cfg;
0692fe41 654 const struct iwl_fw *fw;
ee4d5471 655 const struct iwl_dvm_cfg *lib;
9a716863 656 unsigned long status;
cac988a6 657
fa23cb04 658 spinlock_t sta_lock;
b1eea297 659 struct mutex mutex;
fa23cb04 660
e755f882
JB
661 unsigned long transport_queue_stop;
662 bool passive_no_rx;
1479177b
JB
663#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];
9eae88fa
JB
666
667 unsigned long agg_q_alloc[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
e755f882 668
5d08cd1d
CH
669 /* ieee device used by generic ieee processing code */
670 struct ieee80211_hw *hw;
5d08cd1d 671
e1991885
JB
672 struct list_head calib_results;
673
1ee158d8
JB
674 struct workqueue_struct *workqueue;
675
9e295116
JB
676 struct iwl_hw_params hw_params;
677
8318d78a 678 enum ieee80211_band band;
a18f61bc 679 u8 valid_contexts;
5d08cd1d 680
247c61d6 681 int (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
48a2d66f 682 struct iwl_rx_cmd_buffer *rxb,
247c61d6 683 struct iwl_device_cmd *cmd);
5d08cd1d 684
4bd14dd5
JB
685 struct iwl_notif_wait_data notif_wait;
686
5d08cd1d 687 /* spectrum measurement report caching */
2aa6ab86 688 struct iwl_spectrum_notification measure_report;
5d08cd1d 689 u8 measurement_status;
81963d68 690
5d08cd1d
CH
691 /* ucode beacon time */
692 u32 ucode_beacon_time;
a13d276f 693 int missed_beacon_threshold;
5d08cd1d 694
a85d7cca
JB
695 /* track IBSS manager (last beacon) status */
696 u32 ibss_manager;
697
410f2bb3
SG
698 /* jiffies when last recovery from statistics was performed */
699 unsigned long rx_statistics_jiffies;
3e4fb5fa 700
1f7b6172
EG
701 /*counters */
702 u32 rx_handlers_stats[REPLY_MAX];
703
48dffd39
JB
704 /* rf reset */
705 struct iwl_rf_reset rf_reset;
a93e7973 706
491bc292
WYG
707 /* firmware reload counter and timestamp */
708 unsigned long reload_jiffies;
709 int reload_count;
8f7ffbe2 710 bool ucode_loaded;
491bc292 711
ab5c0f1f
JB
712 u8 plcp_delta_threshold;
713
5d08cd1d 714 /* thermal calibration */
02883562 715 s32 temperature; /* Celsius */
5d08cd1d
CH
716 s32 last_temperature;
717
79d3eef8
JB
718 struct iwl_wipan_noa_data __rcu *noa_data;
719
5d08cd1d 720 /* Scan related variables */
5d08cd1d 721 unsigned long scan_start;
5d08cd1d 722 unsigned long scan_start_tsf;
811ecc99 723 void *scan_cmd;
00700ee0 724 enum ieee80211_band scan_band;
1ecf9fc1 725 struct cfg80211_scan_request *scan_request;
f84b29ec 726 struct ieee80211_vif *scan_vif;
266af4c7 727 enum iwl_scan_type scan_type;
76eff18b
TW
728 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
729 u8 mgmt_tx_ant;
5d08cd1d 730
c10afb6e
JB
731 /* max number of station keys */
732 u8 sta_key_max_num;
733
d2690c0d
JB
734 bool new_scan_threshold_behaviour;
735
15b86bff
JB
736 bool wowlan;
737
c6fa17ed
WYG
738 /* EEPROM MAC addresses */
739 struct mac_address addresses[2];
740
246ed355 741 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
5d08cd1d 742
6f213ff1 743 __le16 switch_channel;
0924e519 744
5d08cd1d 745 u8 start_calib;
f0832f13
EG
746 struct iwl_sensitivity_data sensitivity_data;
747 struct iwl_chain_noise_data chain_noise_data;
5d08cd1d 748 __le16 sensitivity_tbl[HD_TABLE_SIZE];
c8312fac 749 __le16 enhance_sensitivity_tbl[ENHANCE_HD_TABLE_ENTRIES];
5d08cd1d 750
fad95bf5 751 struct iwl_ht_config current_ht_config;
5d08cd1d 752
5d08cd1d 753 /* Rate scaling data */
5d08cd1d
CH
754 u8 retry_rate;
755
5d08cd1d
CH
756 int activity_timer_active;
757
5da4b55f 758 struct iwl_power_mgr power_data;
3ad3b92a 759 struct iwl_tt_mgmt thermal_throttle;
5d08cd1d 760
9c5ac091 761 /* station table variables */
5d08cd1d 762 int num_stations;
3240cab3 763 struct iwl_station_entry stations[IWLAGN_STATION_COUNT];
80fb47a1 764 unsigned long ucode_key_table;
04cf6824 765 struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT];
622a9268 766 atomic_t num_aux_in_flight;
5d08cd1d 767
859cfb0a
EG
768 u8 mac80211_registered;
769
5d08cd1d 770 /* Indication if ieee80211_ops->open has been called */
69dc5d9d 771 u8 is_open;
5d08cd1d 772
05c914fe 773 enum nl80211_iftype iw_mode;
5d08cd1d 774
5d08cd1d 775 /* Last Rx'd beacon timestamp */
3109ece1 776 u64 timestamp;
5d08cd1d 777
0da0e5bf
JB
778 struct {
779 __le32 flag;
780 struct statistics_general_common common;
781 struct statistics_rx_non_phy rx_non_phy;
782 struct statistics_rx_phy rx_ofdm;
783 struct statistics_rx_ht_phy rx_ofdm_ht;
784 struct statistics_rx_phy rx_cck;
785 struct statistics_tx tx;
786#ifdef CONFIG_IWLWIFI_DEBUGFS
787 struct statistics_bt_activity bt_activity;
788 __le32 num_bt_kills, accum_num_bt_kills;
789#endif
4ff70fcd 790 spinlock_t lock;
0da0e5bf
JB
791 } statistics;
792#ifdef CONFIG_IWLWIFI_DEBUGFS
793 struct {
794 struct statistics_general_common common;
795 struct statistics_rx_non_phy rx_non_phy;
796 struct statistics_rx_phy rx_ofdm;
797 struct statistics_rx_ht_phy rx_ofdm_ht;
798 struct statistics_rx_phy rx_cck;
799 struct statistics_tx tx;
800 struct statistics_bt_activity bt_activity;
801 } accum_stats, delta_stats, max_delta_stats;
802#endif
803
898ed67b
WYG
804 /*
805 * reporting the number of tids has AGG on. 0 means
806 * no AGGREGATION
807 */
808 u8 agg_tids_count;
809
810 struct iwl_rx_phy_res last_phy_res;
12bf6f45 811 u32 ampdu_ref;
898ed67b
WYG
812 bool last_phy_res_valid;
813
898ed67b
WYG
814 /*
815 * chain noise reset and gain commands are the
816 * two extra calibration commands follows the standard
817 * phy calibration commands
818 */
819 u8 phy_calib_chain_noise_reset_cmd;
820 u8 phy_calib_chain_noise_gain_cmd;
821
822 /* counts reply_tx error */
823 struct reply_tx_error_statistics reply_tx_stats;
824 struct reply_agg_tx_error_statistics reply_agg_tx_stats;
898ed67b 825
22bf59a0 826 /* bt coex */
f21dd005 827 u8 bt_enable_flag;
da5dbb97 828 u8 bt_status;
66e863a5 829 u8 bt_traffic_load, last_bt_traffic_load;
f37837c9 830 bool bt_ch_announce;
bee008b7
WYG
831 bool bt_full_concurrent;
832 bool bt_ant_couple_ok;
fbba9410
WYG
833 __le32 kill_ack_mask;
834 __le32 kill_cts_mask;
835 __le16 bt_valid;
354ce4a4 836 bool reduced_txpower;
22bf59a0
WYG
837 u16 bt_on_thresh;
838 u16 bt_duration;
839 u16 dynamic_frag_thresh;
bee008b7 840 u8 bt_ci_compliance;
9e4afc21 841 struct work_struct bt_traffic_change_work;
207ecc5e
MV
842 bool bt_enable_pspoll;
843 struct iwl_rxon_context *cur_rssi_ctx;
844 bool bt_is_sco;
9e4afc21 845
5d08cd1d 846 struct work_struct restart;
5d08cd1d 847 struct work_struct scan_completed;
5d08cd1d 848 struct work_struct abort_scan;
12e934dc 849
5d08cd1d 850 struct work_struct beacon_update;
76d04815 851 struct iwl_rxon_context *beacon_ctx;
12e934dc 852 struct sk_buff *beacon_skb;
4ce7cc2b 853 void *beacon_cmd;
76d04815 854
a28027cd
WYG
855 struct work_struct tt_work;
856 struct work_struct ct_enter;
857 struct work_struct ct_exit;
88be0264 858 struct work_struct start_internal_scan;
65550636 859 struct work_struct tx_flush;
bee008b7 860 struct work_struct bt_full_concurrency;
fbba9410 861 struct work_struct bt_runtime_config;
5d08cd1d 862
5d08cd1d 863 struct delayed_work scan_check;
4a8a4322 864
26a7ca9a 865 /* TX Power settings */
630fe9b6 866 s8 tx_power_user_lmt;
a25a66ac 867 s8 tx_power_next;
5d08cd1d 868
712b6cf5
TW
869#ifdef CONFIG_IWLWIFI_DEBUGFS
870 /* debugfs */
4c84a8f1
JB
871 struct dentry *debugfs_dir;
872 u32 dbgfs_sram_offset, dbgfs_sram_len;
d73e4923 873 bool disable_ht40;
c8ac61cf 874 void *wowlan_sram;
712b6cf5 875#endif /* CONFIG_IWLWIFI_DEBUGFS */
5d08cd1d 876
b7998c8b 877 struct iwl_nvm_data *nvm_data;
49464ae5 878 /* eeprom blob for debugfs */
26a7ca9a
JB
879 u8 *eeprom_blob;
880 size_t eeprom_blob_size;
11483b5c 881
5d08cd1d 882 struct work_struct txpower_work;
bfb45f54 883 u32 calib_disabled;
16e727e8 884 struct work_struct run_time_calib_work;
5d08cd1d 885 struct timer_list statistics_periodic;
a9e1cb6a 886 struct timer_list ucode_trace;
a9e1cb6a
WYG
887
888 struct iwl_event_log event_log;
5ed540ae 889
c43e9330 890#ifdef CONFIG_IWLWIFI_LEDS
5ed540ae
WYG
891 struct led_classdev led;
892 unsigned long blink_on, blink_off;
893 bool led_registered;
c43e9330 894#endif
3a6490c0 895
c8ac61cf
JB
896 /* WoWLAN GTK rekey data */
897 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
898 __le64 replay_ctr;
899 __le16 last_seq_ctl;
900 bool have_rekey_data;
964dc9e2
JB
901#ifdef CONFIG_PM_SLEEP
902 struct wiphy_wowlan_support wowlan_support;
903#endif
2fdfc476
MV
904
905 /* device_pointers: pointers to ucode event tables */
906 struct {
907 u32 error_event_table;
908 u32 log_event_table;
909 } device_pointers;
a42506eb
MV
910
911 /* indicator of loaded ucode image */
912 enum iwl_ucode_type cur_ucode;
c79dd5b5 913}; /*iwl_priv */
5d08cd1d 914
246ed355
JB
915static inline struct iwl_rxon_context *
916iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
917{
918 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
919
920 return vif_priv->ctx;
921}
922
923#define for_each_context(priv, ctx) \
924 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
925 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
a18f61bc 926 if (priv->valid_contexts & BIT(ctx->ctxid))
246ed355 927
054ec924 928static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
246ed355 929{
054ec924 930 return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
246ed355
JB
931}
932
054ec924
JB
933static inline int iwl_is_associated(struct iwl_priv *priv,
934 enum iwl_rxon_context_id ctxid)
246ed355 935{
054ec924 936 return iwl_is_associated_ctx(&priv->contexts[ctxid]);
246ed355 937}
a332f8d6 938
054ec924 939static inline int iwl_is_any_associated(struct iwl_priv *priv)
5d08cd1d 940{
054ec924
JB
941 struct iwl_rxon_context *ctx;
942 for_each_context(priv, ctx)
943 if (iwl_is_associated_ctx(ctx))
944 return true;
945 return false;
5d08cd1d
CH
946}
947
be1f3ab6 948#endif /* __iwl_dev_h__ */
This page took 1.109836 seconds and 5 git commands to generate.