1 /******************************************************************************
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
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.
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
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
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 *****************************************************************************/
27 * Please use this file (iwl-dev.h) for driver implementation definitions.
28 * Please use iwl-commands.h for uCode API definitions.
34 #include <linux/interrupt.h>
35 #include <linux/kernel.h>
36 #include <linux/wait.h>
37 #include <linux/leds.h>
38 #include <linux/slab.h>
39 #include <net/ieee80211_radiotap.h>
41 #include "iwl-eeprom.h"
44 #include "iwl-debug.h"
45 #include "iwl-agn-hw.h"
47 #include "iwl-power.h"
48 #include "iwl-agn-rs.h"
49 #include "iwl-agn-tt.h"
51 #include "iwl-trans.h"
52 #include "iwl-shared.h"
56 /* CT-KILL constants */
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 */
61 /* Default noise level to report when noise measurement is not available.
62 * This may be because we're:
63 * 1) Not associated no beacon statistics being sent to driver)
64 * 2) Scanning (noise measurement does not apply to associated channel)
65 * Use default noise value of -127 ... this is below the range of measurable
66 * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user.
67 * Also, -127 works better than 0 when averaging frames with/without
68 * noise info (e.g. averaging might be done in app); measured dBm values are
69 * always negative ... using a negative value as the default keeps all
70 * averages within an s8's (used in some apps) range of negative values. */
71 #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
74 * RTS threshold here is total size [2347] minus 4 FCS bytes
76 * a value of 0 means RTS on all data/management packets
77 * a value > max MSDU size means no RTS
78 * else RTS for data/management frames where MPDU is larger
81 #define DEFAULT_RTS_THRESHOLD 2347U
82 #define MIN_RTS_THRESHOLD 0U
83 #define MAX_RTS_THRESHOLD 2347U
84 #define MAX_MSDU_SIZE 2304U
85 #define MAX_MPDU_SIZE 2346U
86 #define DEFAULT_BEACON_INTERVAL 200U
87 #define DEFAULT_SHORT_RETRY_LIMIT 7U
88 #define DEFAULT_LONG_RETRY_LIMIT 4U
90 #define IWL_NUM_SCAN_RATES (2)
93 * One for each channel, holds all channel setup data
94 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
97 struct iwl_channel_info
{
98 struct iwl_eeprom_channel eeprom
; /* EEPROM regulatory limit */
99 struct iwl_eeprom_channel ht40_eeprom
; /* EEPROM regulatory limit for
102 u8 channel
; /* channel number */
103 u8 flags
; /* flags copied from EEPROM */
104 s8 max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
105 s8 curr_txpow
; /* (dBm) regulatory/spectrum/user (not h/w) limit */
106 s8 min_power
; /* always 0 */
107 s8 scan_power
; /* (dBm) regul. eeprom, direct scans, any rate */
109 u8 group_index
; /* 0-4, maps channel to group1/2/3/4/5 */
110 u8 band_index
; /* 0-4, maps channel to band1/2/3/4/5 */
111 enum ieee80211_band band
;
113 /* HT40 channel info */
114 s8 ht40_max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
115 u8 ht40_flags
; /* flags copied from EEPROM */
116 u8 ht40_extension_channel
; /* HT_IE_EXT_CHANNEL_* */
120 * Minimum number of queues. MAX_NUM is defined in hw specific files.
121 * Set the minimum to accommodate
122 * - 4 standard TX queues
123 * - the command queue
125 * - the PAN multicast queue, and
126 * - the AUX (TX during scan dwell) queue.
128 #define IWL_MIN_NUM_QUEUES 11
131 * Command queue depends on iPAN support.
133 #define IWL_DEFAULT_CMD_QUEUE_NUM 4
134 #define IWL_IPAN_CMD_QUEUE_NUM 9
136 #define IEEE80211_DATA_LEN 2304
137 #define IEEE80211_4ADDR_LEN 30
138 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
139 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
141 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
142 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
143 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
145 #define IWL_SUPPORTED_RATES_IE_LEN 8
147 #define IWL_INVALID_RATE 0xFF
148 #define IWL_INVALID_VALUE -1
150 union iwl_ht_rate_supp
{
158 #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
159 #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
160 #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
161 #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
162 #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
163 #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
164 #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
167 * Maximal MPDU density for TX aggregation
173 #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
174 #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
175 #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
176 #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
177 #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
178 #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
179 #define CFG_HT_MPDU_DENSITY_MIN (0x1)
181 struct iwl_ht_config
{
182 bool single_chain_sufficient
;
183 enum ieee80211_smps_mode smps
; /* current smps mode */
187 struct iwl_qos_info
{
189 struct iwl_qosparam_cmd def_qos_parm
;
193 * Structure should be accessed with sta_lock held. When station addition
194 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
195 * the commands (iwl_addsta_cmd and iwl_link_quality_cmd) without sta_lock
198 struct iwl_station_entry
{
199 struct iwl_addsta_cmd sta
;
201 struct iwl_link_quality_cmd
*lq
;
205 * iwl_station_priv: Driver's private station information
207 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
208 * in the structure for use by driver. This structure is places in that
211 struct iwl_station_priv
{
212 struct iwl_rxon_context
*ctx
;
213 struct iwl_lq_sta lq_sta
;
214 atomic_t pending_frames
;
222 * struct iwl_vif_priv - driver's private per-interface information
224 * When mac80211 allocates a virtual interface, it can allocate
225 * space for us to put data into.
227 struct iwl_vif_priv
{
228 struct iwl_rxon_context
*ctx
;
229 u8 ibss_bssid_sta_id
;
232 /* v1/v2 uCode file layout */
233 struct iwl_ucode_header
{
234 __le32 ver
; /* major/minor/API/serial */
237 __le32 inst_size
; /* bytes of runtime code */
238 __le32 data_size
; /* bytes of runtime data */
239 __le32 init_size
; /* bytes of init code */
240 __le32 init_data_size
; /* bytes of init data */
241 __le32 boot_size
; /* bytes of bootstrap code */
242 u8 data
[0]; /* in same order as sizes */
245 __le32 build
; /* build number */
246 __le32 inst_size
; /* bytes of runtime code */
247 __le32 data_size
; /* bytes of runtime data */
248 __le32 init_size
; /* bytes of init code */
249 __le32 init_data_size
; /* bytes of init data */
250 __le32 boot_size
; /* bytes of bootstrap code */
251 u8 data
[0]; /* in same order as sizes */
257 * new TLV uCode file layout
259 * The new TLV file format contains TLVs, that each specify
260 * some piece of data. To facilitate "groups", for example
261 * different instruction image with different capabilities,
262 * bundled with the same init image, an alternative mechanism
264 * When the alternative field is 0, that means that the item
265 * is always valid. When it is non-zero, then it is only
266 * valid in conjunction with items of the same alternative,
267 * in which case the driver (user) selects one alternative
271 enum iwl_ucode_tlv_type
{
272 IWL_UCODE_TLV_INVALID
= 0, /* unused */
273 IWL_UCODE_TLV_INST
= 1,
274 IWL_UCODE_TLV_DATA
= 2,
275 IWL_UCODE_TLV_INIT
= 3,
276 IWL_UCODE_TLV_INIT_DATA
= 4,
277 IWL_UCODE_TLV_BOOT
= 5,
278 IWL_UCODE_TLV_PROBE_MAX_LEN
= 6, /* a u32 value */
279 IWL_UCODE_TLV_PAN
= 7,
280 IWL_UCODE_TLV_RUNT_EVTLOG_PTR
= 8,
281 IWL_UCODE_TLV_RUNT_EVTLOG_SIZE
= 9,
282 IWL_UCODE_TLV_RUNT_ERRLOG_PTR
= 10,
283 IWL_UCODE_TLV_INIT_EVTLOG_PTR
= 11,
284 IWL_UCODE_TLV_INIT_EVTLOG_SIZE
= 12,
285 IWL_UCODE_TLV_INIT_ERRLOG_PTR
= 13,
286 IWL_UCODE_TLV_ENHANCE_SENS_TBL
= 14,
287 IWL_UCODE_TLV_PHY_CALIBRATION_SIZE
= 15,
288 IWL_UCODE_TLV_WOWLAN_INST
= 16,
289 IWL_UCODE_TLV_WOWLAN_DATA
= 17,
290 IWL_UCODE_TLV_FLAGS
= 18,
294 * enum iwl_ucode_tlv_flag - ucode API flags
295 * @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
296 * was a separate TLV but moved here to save space.
297 * @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
298 * treats good CRC threshold as a boolean
299 * @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
300 * @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
302 enum iwl_ucode_tlv_flag
{
303 IWL_UCODE_TLV_FLAGS_PAN
= BIT(0),
304 IWL_UCODE_TLV_FLAGS_NEWSCAN
= BIT(1),
305 IWL_UCODE_TLV_FLAGS_MFP
= BIT(2),
306 IWL_UCODE_TLV_FLAGS_P2P
= BIT(3),
309 struct iwl_ucode_tlv
{
310 __le16 type
; /* see above */
311 __le16 alternative
; /* see comment */
312 __le32 length
; /* not including type/length fields */
316 #define IWL_TLV_UCODE_MAGIC 0x0a4c5749
318 struct iwl_tlv_ucode_header
{
320 * The TLV style ucode header is distinguished from
321 * the v1/v2 style header by first four bytes being
322 * zero, as such is an invalid combination of
323 * major/minor/API/serial versions.
327 u8 human_readable
[64];
328 __le32 ver
; /* major/minor/API/serial */
330 __le64 alternatives
; /* bitmask of valid alternatives */
332 * The data contained herein has a TLV layout,
333 * see above for the TLV header and types.
334 * Note that each TLV is padded to a length
335 * that is a multiple of 4 for alignment.
340 struct iwl_sensitivity_ranges
{
347 u16 auto_corr_min_ofdm
;
348 u16 auto_corr_min_ofdm_mrc
;
349 u16 auto_corr_min_ofdm_x1
;
350 u16 auto_corr_min_ofdm_mrc_x1
;
352 u16 auto_corr_max_ofdm
;
353 u16 auto_corr_max_ofdm_mrc
;
354 u16 auto_corr_max_ofdm_x1
;
355 u16 auto_corr_max_ofdm_mrc_x1
;
357 u16 auto_corr_max_cck
;
358 u16 auto_corr_max_cck_mrc
;
359 u16 auto_corr_min_cck
;
360 u16 auto_corr_min_cck_mrc
;
362 u16 barker_corr_th_min
;
363 u16 barker_corr_th_min_mrc
;
368 #define KELVIN_TO_CELSIUS(x) ((x)-273)
369 #define CELSIUS_TO_KELVIN(x) ((x)+273)
372 /******************************************************************************
374 * Functions implemented in core module which are forward declared here
375 * for use by iwl-[4-5].c
377 * NOTE: The implementation of these functions are not hardware specific
378 * which is why they are in the core module files.
380 * Naming convention --
381 * iwl_ <-- Is part of iwlwifi
382 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
384 ****************************************************************************/
385 extern void iwl_update_chain_flags(struct iwl_priv
*priv
);
386 extern const u8 iwl_bcast_addr
[ETH_ALEN
];
388 #define IWL_OPERATION_MODE_AUTO 0
389 #define IWL_OPERATION_MODE_HT_ONLY 1
390 #define IWL_OPERATION_MODE_MIXED 2
391 #define IWL_OPERATION_MODE_20MHZ 3
393 #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
395 /* Sensitivity and chain noise calibration */
396 #define INITIALIZATION_VALUE 0xFFFF
397 #define IWL_CAL_NUM_BEACONS 16
398 #define MAXIMUM_ALLOWED_PATHLOSS 15
400 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
402 #define MAX_FA_OFDM 50
403 #define MIN_FA_OFDM 5
404 #define MAX_FA_CCK 50
407 #define AUTO_CORR_STEP_OFDM 1
409 #define AUTO_CORR_STEP_CCK 3
410 #define AUTO_CORR_MAX_TH_CCK 160
413 #define NRG_STEP_CCK 2
415 #define MAX_NUMBER_CCK_NO_FA 100
417 #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
422 #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
423 #define ALL_BAND_FILTER 0xFF00
424 #define IN_BAND_FILTER 0xFF
425 #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
427 #define NRG_NUM_PREV_STAT_L 20
428 #define NUM_RX_CHAINS 3
430 enum iwlagn_false_alarm_state
{
433 IWL_FA_GOOD_RANGE
= 2,
436 enum iwlagn_chain_noise_state
{
437 IWL_CHAIN_NOISE_ALIVE
= 0, /* must be 0 */
438 IWL_CHAIN_NOISE_ACCUMULATE
,
439 IWL_CHAIN_NOISE_CALIBRATED
,
440 IWL_CHAIN_NOISE_DONE
,
444 /* Opaque calibration results */
445 struct iwl_calib_result
{
446 struct list_head list
;
448 struct iwl_calib_hdr hdr
;
452 /* Sensitivity calib data */
453 struct iwl_sensitivity_data
{
455 u32 auto_corr_ofdm_mrc
;
456 u32 auto_corr_ofdm_x1
;
457 u32 auto_corr_ofdm_mrc_x1
;
459 u32 auto_corr_cck_mrc
;
461 u32 last_bad_plcp_cnt_ofdm
;
462 u32 last_fa_cnt_ofdm
;
463 u32 last_bad_plcp_cnt_cck
;
469 u8 nrg_silence_rssi
[NRG_NUM_PREV_STAT_L
];
474 s32 nrg_auto_corr_silence_diff
;
475 u32 num_in_cck_no_fa
;
478 u16 barker_corr_th_min
;
479 u16 barker_corr_th_min_mrc
;
483 /* Chain noise (differential Rx gain) calib data */
484 struct iwl_chain_noise_data
{
493 u8 disconn_array
[NUM_RX_CHAINS
];
494 u8 delta_gain_code
[NUM_RX_CHAINS
];
499 #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
500 #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
503 MEASUREMENT_READY
= (1 << 0),
504 MEASUREMENT_ACTIVE
= (1 << 1),
508 NVM_DEVICE_TYPE_EEPROM
= 0,
513 * Two types of OTP memory access modes
514 * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
515 * based on physical memory addressing
516 * IWL_OTP_ACCESS_RELATIVE - relative address mode,
517 * based on logical memory addressing
519 enum iwl_access_mode
{
520 IWL_OTP_ACCESS_ABSOLUTE
,
521 IWL_OTP_ACCESS_RELATIVE
,
525 * enum iwl_pa_type - Power Amplifier type
526 * @IWL_PA_SYSTEM: based on uCode configuration
527 * @IWL_PA_INTERNAL: use Internal only
534 /* reply_tx_statistics (for _agn devices) */
535 struct reply_tx_error_statistics
{
541 u32 int_crossed_retry
;
557 u32 sta_color_mismatch
;
561 /* reply_agg_tx_statistics (for _agn devices) */
562 struct reply_agg_tx_error_statistics
{
569 u32 last_sent_bt_kill
;
578 /* management statistics */
579 enum iwl_mgmt_stats
{
580 MANAGEMENT_ASSOC_REQ
= 0,
581 MANAGEMENT_ASSOC_RESP
,
582 MANAGEMENT_REASSOC_REQ
,
583 MANAGEMENT_REASSOC_RESP
,
584 MANAGEMENT_PROBE_REQ
,
585 MANAGEMENT_PROBE_RESP
,
594 /* control statistics */
595 enum iwl_ctrl_stats
{
596 CONTROL_BACK_REQ
= 0,
607 struct traffic_stats
{
608 #ifdef CONFIG_IWLWIFI_DEBUGFS
609 u32 mgmt
[MANAGEMENT_MAX
];
610 u32 ctrl
[CONTROL_MAX
];
617 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
618 * to perform continuous uCode event logging operation if enabled
620 #define UCODE_TRACE_PERIOD (100)
623 * iwl_event_log: current uCode event log position
625 * @ucode_trace: enable/disable ucode continuous trace timer
626 * @num_wraps: how many times the event buffer wraps
627 * @next_entry: the entry just before the next one that uCode would fill
628 * @non_wraps_count: counter for no wrap detected when dump ucode events
629 * @wraps_once_count: counter for wrap once detected when dump ucode events
630 * @wraps_more_count: counter for wrap more than once detected
631 * when dump ucode events
633 struct iwl_event_log
{
638 int wraps_once_count
;
639 int wraps_more_count
;
643 * This is the threshold value of plcp error rate per 100mSecs. It is
644 * used to set and check for the validity of plcp_delta.
646 #define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
647 #define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
648 #define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
649 #define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
650 #define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
651 #define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
653 #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
654 #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
656 /* TX queue watchdog timeouts in mSecs */
657 #define IWL_DEF_WD_TIMEOUT (2000)
658 #define IWL_LONG_WD_TIMEOUT (10000)
659 #define IWL_MAX_WD_TIMEOUT (120000)
661 /* BT Antenna Coupling Threshold (dB) */
662 #define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
664 /* Firmware reload counter and Timestamp */
665 #define IWL_MIN_RELOAD_DURATION 1000 /* 1000 ms */
666 #define IWL_MAX_CONTINUE_RELOAD_CNT 4
675 struct iwl_force_reset
{
676 int reset_request_count
;
677 int reset_success_count
;
678 int reset_reject_count
;
679 unsigned long reset_duration
;
680 unsigned long last_force_reset_jiffies
;
683 /* extend beacon time format bit shifting */
686 * bits 31:22 - extended
687 * bits 21:0 - interval
689 #define IWLAGN_EXT_BEACON_TIME_POS 22
691 struct iwl_rxon_context
{
692 struct ieee80211_vif
*vif
;
695 * We could use the vif to indicate active, but we
696 * also need it to be active during disabling when
697 * we already removed the vif for type setting.
699 bool always_active
, is_active
;
701 bool ht_need_multiple_chains
;
703 enum iwl_rxon_context_id ctxid
;
705 u32 interface_modes
, exclusive_interface_modes
;
706 u8 unused_devtype
, ap_devtype
, ibss_devtype
, station_devtype
;
709 * We declare this const so it can only be
710 * changed via explicit cast within the
711 * routines that actually update the physical
714 const struct iwl_rxon_cmd active
;
715 struct iwl_rxon_cmd staging
;
717 struct iwl_rxon_time_cmd timing
;
719 struct iwl_qos_info qos_data
;
721 u8 bcast_sta_id
, ap_sta_id
;
723 u8 rxon_cmd
, rxon_assoc_cmd
, rxon_timing_cmd
;
727 struct iwl_wep_key wep_keys
[WEP_KEYS_MAX
];
730 __le32 station_flags
;
735 bool non_gf_sta_present
;
737 bool enabled
, is_40mhz
;
738 u8 extension_chan_offset
;
744 bool last_tx_rejected
;
749 IWL_SCAN_RADIO_RESET
,
753 #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
754 struct iwl_testmode_trace
{
763 struct iwl_testmode_sram
{
771 struct iwl_wipan_noa_data
{
772 struct rcu_head rcu_head
;
779 /*data shared among all the driver's layers */
780 struct iwl_shared _shrd
;
781 struct iwl_shared
*shrd
;
783 /* ieee device used by generic ieee processing code */
784 struct ieee80211_hw
*hw
;
785 struct ieee80211_channel
*ieee_channels
;
786 struct ieee80211_rate
*ieee_rates
;
787 struct kmem_cache
*tx_cmd_pool
;
790 enum ieee80211_band band
;
792 void (*pre_rx_handler
)(struct iwl_priv
*priv
,
793 struct iwl_rx_mem_buffer
*rxb
);
794 int (*rx_handlers
[REPLY_MAX
])(struct iwl_priv
*priv
,
795 struct iwl_rx_mem_buffer
*rxb
,
796 struct iwl_device_cmd
*cmd
);
798 struct ieee80211_supported_band bands
[IEEE80211_NUM_BANDS
];
800 /* spectrum measurement report caching */
801 struct iwl_spectrum_notification measure_report
;
802 u8 measurement_status
;
804 /* ucode beacon time */
805 u32 ucode_beacon_time
;
806 int missed_beacon_threshold
;
808 /* track IBSS manager (last beacon) status */
811 /* jiffies when last recovery from statistics was performed */
812 unsigned long rx_statistics_jiffies
;
815 u32 rx_handlers_stats
[REPLY_MAX
];
818 struct iwl_force_reset force_reset
[IWL_MAX_FORCE_RESET
];
820 /* firmware reload counter and timestamp */
821 unsigned long reload_jiffies
;
824 /* we allocate array of iwl_channel_info for NIC's valid channels.
825 * Access via channel # using indirect index array */
826 struct iwl_channel_info
*channel_info
; /* channel info array */
827 u8 channel_count
; /* # of channels */
829 /* thermal calibration */
830 s32 temperature
; /* Celsius */
831 s32 last_temperature
;
833 /* init calibration results */
834 struct list_head calib_results
;
836 struct iwl_wipan_noa_data __rcu
*noa_data
;
838 /* Scan related variables */
839 unsigned long scan_start
;
840 unsigned long scan_start_tsf
;
842 enum ieee80211_band scan_band
;
843 struct cfg80211_scan_request
*scan_request
;
844 struct ieee80211_vif
*scan_vif
;
845 enum iwl_scan_type scan_type
;
846 u8 scan_tx_ant
[IEEE80211_NUM_BANDS
];
849 /* max number of station keys */
852 bool new_scan_threshold_behaviour
;
854 /* EEPROM MAC addresses */
855 struct mac_address addresses
[2];
857 /* uCode images, save to reload in case of failure */
858 int fw_index
; /* firmware we're trying to load */
859 u32 ucode_ver
; /* version of ucode, copy of
862 char firmware_name
[25];
864 struct iwl_rxon_context contexts
[NUM_IWL_RXON_CTX
];
866 __le16 switch_channel
;
869 u32 error_event_table
;
876 struct iwl_sensitivity_data sensitivity_data
;
877 struct iwl_chain_noise_data chain_noise_data
;
878 bool enhance_sensitivity_table
;
879 __le16 sensitivity_tbl
[HD_TABLE_SIZE
];
880 __le16 enhance_sensitivity_tbl
[ENHANCE_HD_TABLE_ENTRIES
];
882 struct iwl_ht_config current_ht_config
;
884 /* Rate scaling data */
887 int activity_timer_active
;
889 /* counts mgmt, ctl, and data packets */
890 struct traffic_stats tx_stats
;
891 struct traffic_stats rx_stats
;
893 struct iwl_power_mgr power_data
;
894 struct iwl_tt_mgmt thermal_throttle
;
896 /* station table variables */
898 struct iwl_station_entry stations
[IWLAGN_STATION_COUNT
];
899 unsigned long ucode_key_table
;
901 u8 mac80211_registered
;
903 /* Indication if ieee80211_ops->open has been called */
906 enum nl80211_iftype iw_mode
;
908 /* Last Rx'd beacon timestamp */
913 struct statistics_general_common common
;
914 struct statistics_rx_non_phy rx_non_phy
;
915 struct statistics_rx_phy rx_ofdm
;
916 struct statistics_rx_ht_phy rx_ofdm_ht
;
917 struct statistics_rx_phy rx_cck
;
918 struct statistics_tx tx
;
919 #ifdef CONFIG_IWLWIFI_DEBUGFS
920 struct statistics_bt_activity bt_activity
;
921 __le32 num_bt_kills
, accum_num_bt_kills
;
924 #ifdef CONFIG_IWLWIFI_DEBUGFS
926 struct statistics_general_common common
;
927 struct statistics_rx_non_phy rx_non_phy
;
928 struct statistics_rx_phy rx_ofdm
;
929 struct statistics_rx_ht_phy rx_ofdm_ht
;
930 struct statistics_rx_phy rx_cck
;
931 struct statistics_tx tx
;
932 struct statistics_bt_activity bt_activity
;
933 } accum_stats
, delta_stats
, max_delta_stats
;
937 * reporting the number of tids has AGG on. 0 means
942 struct iwl_rx_phy_res last_phy_res
;
943 bool last_phy_res_valid
;
945 struct completion firmware_loading_complete
;
947 u32 init_evtlog_ptr
, init_evtlog_size
, init_errlog_ptr
;
948 u32 inst_evtlog_ptr
, inst_evtlog_size
, inst_errlog_ptr
;
951 * chain noise reset and gain commands are the
952 * two extra calibration commands follows the standard
953 * phy calibration commands
955 u8 phy_calib_chain_noise_reset_cmd
;
956 u8 phy_calib_chain_noise_gain_cmd
;
958 /* counts reply_tx error */
959 struct reply_tx_error_statistics reply_tx_stats
;
960 struct reply_agg_tx_error_statistics reply_agg_tx_stats
;
962 /* remain-on-channel offload support */
963 struct ieee80211_channel
*hw_roc_channel
;
964 struct delayed_work hw_roc_disable_work
;
965 enum nl80211_channel_type hw_roc_chantype
;
967 bool hw_roc_setup
, hw_roc_start_notified
;
972 u8 bt_traffic_load
, last_bt_traffic_load
;
974 bool bt_full_concurrent
;
975 bool bt_ant_couple_ok
;
976 __le32 kill_ack_mask
;
977 __le32 kill_cts_mask
;
981 u16 dynamic_frag_thresh
;
983 struct work_struct bt_traffic_change_work
;
984 bool bt_enable_pspoll
;
985 struct iwl_rxon_context
*cur_rssi_ctx
;
988 struct work_struct restart
;
989 struct work_struct scan_completed
;
990 struct work_struct abort_scan
;
992 struct work_struct beacon_update
;
993 struct iwl_rxon_context
*beacon_ctx
;
994 struct sk_buff
*beacon_skb
;
997 struct work_struct tt_work
;
998 struct work_struct ct_enter
;
999 struct work_struct ct_exit
;
1000 struct work_struct start_internal_scan
;
1001 struct work_struct tx_flush
;
1002 struct work_struct bt_full_concurrency
;
1003 struct work_struct bt_runtime_config
;
1005 struct delayed_work scan_check
;
1008 s8 tx_power_user_lmt
;
1009 s8 tx_power_device_lmt
;
1010 s8 tx_power_lmt_in_half_dbm
; /* max tx power in half-dBm format */
1013 #ifdef CONFIG_IWLWIFI_DEBUGFS
1019 struct dentry
*debugfs_dir
;
1020 u32 dbgfs_sram_offset
, dbgfs_sram_len
;
1023 #endif /* CONFIG_IWLWIFI_DEBUGFS */
1025 struct work_struct txpower_work
;
1026 u32 disable_sens_cal
;
1027 u32 disable_chain_noise_cal
;
1028 struct work_struct run_time_calib_work
;
1029 struct timer_list statistics_periodic
;
1030 struct timer_list ucode_trace
;
1031 struct timer_list watchdog
;
1033 struct iwl_event_log event_log
;
1035 struct led_classdev led
;
1036 unsigned long blink_on
, blink_off
;
1037 bool led_registered
;
1038 #ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE
1039 struct iwl_testmode_trace testmode_trace
;
1040 struct iwl_testmode_sram testmode_sram
;
1044 /* WoWLAN GTK rekey data */
1045 u8 kck
[NL80211_KCK_LEN
], kek
[NL80211_KEK_LEN
];
1047 __le16 last_seq_ctl
;
1048 bool have_rekey_data
;
1051 extern struct iwl_mod_params iwlagn_mod_params
;
1053 static inline struct iwl_rxon_context
*
1054 iwl_rxon_ctx_from_vif(struct ieee80211_vif
*vif
)
1056 struct iwl_vif_priv
*vif_priv
= (void *)vif
->drv_priv
;
1058 return vif_priv
->ctx
;
1061 #define for_each_context(priv, ctx) \
1062 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
1063 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
1064 if (priv->shrd->valid_contexts & BIT(ctx->ctxid))
1066 static inline int iwl_is_associated_ctx(struct iwl_rxon_context
*ctx
)
1068 return (ctx
->active
.filter_flags
& RXON_FILTER_ASSOC_MSK
) ? 1 : 0;
1071 static inline int iwl_is_associated(struct iwl_priv
*priv
,
1072 enum iwl_rxon_context_id ctxid
)
1074 return iwl_is_associated_ctx(&priv
->contexts
[ctxid
]);
1077 static inline int iwl_is_any_associated(struct iwl_priv
*priv
)
1079 struct iwl_rxon_context
*ctx
;
1080 for_each_context(priv
, ctx
)
1081 if (iwl_is_associated_ctx(ctx
))
1086 static inline int is_channel_valid(const struct iwl_channel_info
*ch_info
)
1088 if (ch_info
== NULL
)
1090 return (ch_info
->flags
& EEPROM_CHANNEL_VALID
) ? 1 : 0;
1093 static inline int is_channel_radar(const struct iwl_channel_info
*ch_info
)
1095 return (ch_info
->flags
& EEPROM_CHANNEL_RADAR
) ? 1 : 0;
1098 static inline u8
is_channel_a_band(const struct iwl_channel_info
*ch_info
)
1100 return ch_info
->band
== IEEE80211_BAND_5GHZ
;
1103 static inline u8
is_channel_bg_band(const struct iwl_channel_info
*ch_info
)
1105 return ch_info
->band
== IEEE80211_BAND_2GHZ
;
1108 static inline int is_channel_passive(const struct iwl_channel_info
*ch
)
1110 return (!(ch
->flags
& EEPROM_CHANNEL_ACTIVE
)) ? 1 : 0;
1113 static inline int is_channel_ibss(const struct iwl_channel_info
*ch
)
1115 return ((ch
->flags
& EEPROM_CHANNEL_IBSS
)) ? 1 : 0;
1118 #endif /* __iwl_dev_h__ */