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.
29 * Please use iwl-4965-hw.h for hardware-related definitions.
32 #ifndef __iwl_legacy_dev_h__
33 #define __iwl_legacy_dev_h__
35 #include <linux/interrupt.h>
36 #include <linux/pci.h> /* for struct pci_device_id */
37 #include <linux/kernel.h>
38 #include <linux/leds.h>
39 #include <linux/wait.h>
40 #include <net/ieee80211_radiotap.h>
42 #include "iwl-eeprom.h"
46 #include "iwl-debug.h"
47 #include "iwl-4965-hw.h"
48 #include "iwl-3945-hw.h"
50 #include "iwl-power.h"
51 #include "iwl-legacy-rs.h"
55 /* CT-KILL constants */
56 #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
58 /* Default noise level to report when noise measurement is not available.
59 * This may be because we're:
60 * 1) Not associated (4965, no beacon statistics being sent to driver)
61 * 2) Scanning (noise measurement does not apply to associated channel)
62 * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
63 * Use default noise value of -127 ... this is below the range of measurable
64 * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
65 * Also, -127 works better than 0 when averaging frames with/without
66 * noise info (e.g. averaging might be done in app); measured dBm values are
67 * always negative ... using a negative value as the default keeps all
68 * averages within an s8's (used in some apps) range of negative values. */
69 #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
72 * RTS threshold here is total size [2347] minus 4 FCS bytes
74 * a value of 0 means RTS on all data/management packets
75 * a value > max MSDU size means no RTS
76 * else RTS for data/management frames where MPDU is larger
79 #define DEFAULT_RTS_THRESHOLD 2347U
80 #define MIN_RTS_THRESHOLD 0U
81 #define MAX_RTS_THRESHOLD 2347U
82 #define MAX_MSDU_SIZE 2304U
83 #define MAX_MPDU_SIZE 2346U
84 #define DEFAULT_BEACON_INTERVAL 100U
85 #define DEFAULT_SHORT_RETRY_LIMIT 7U
86 #define DEFAULT_LONG_RETRY_LIMIT 4U
88 struct iwl_rx_mem_buffer
{
91 struct list_head list
;
94 #define rxb_addr(r) page_address(r->page)
97 struct iwl_device_cmd
;
100 /* only for SYNC commands, iff the reply skb is wanted */
101 struct iwl_host_cmd
*source
;
103 * only for ASYNC commands
104 * (which is somewhat stupid -- look at iwl-sta.c for instance
105 * which duplicates a bunch of code because the callback isn't
106 * invoked for SYNC commands, if it were and its result passed
107 * through it would be simpler...)
109 void (*callback
)(struct iwl_priv
*priv
,
110 struct iwl_device_cmd
*cmd
,
111 struct iwl_rx_packet
*pkt
);
113 /* The CMD_SIZE_HUGE flag bit indicates that the command
114 * structure is stored at the end of the shared queue memory. */
117 DEFINE_DMA_UNMAP_ADDR(mapping
);
118 DEFINE_DMA_UNMAP_LEN(len
);
122 * Generic queue structure
124 * Contains common data for Rx and Tx queues
127 int n_bd
; /* number of BDs in this queue */
128 int write_ptr
; /* 1-st empty entry (index) host_w*/
129 int read_ptr
; /* last used entry (index) host_r*/
130 /* use for monitoring and recovering the stuck queue */
131 dma_addr_t dma_addr
; /* physical addr for BD's */
132 int n_window
; /* safe queue window */
134 int low_mark
; /* low watermark, resume queue if free
135 * space more than this */
136 int high_mark
; /* high watermark, stop queue if free
137 * space less than this */
140 /* One for each TFD */
143 struct iwl_rxon_context
*ctx
;
147 * struct iwl_tx_queue - Tx Queue for DMA
148 * @q: generic Rx/Tx queue descriptor
149 * @bd: base of circular buffer of TFDs
150 * @cmd: array of command/TX buffer pointers
151 * @meta: array of meta data for each command/tx buffer
152 * @dma_addr_cmd: physical address of cmd/tx buffer array
153 * @txb: array of per-TFD driver data
154 * @time_stamp: time (in jiffies) of last read_ptr change
155 * @need_update: indicates need to update read/write index
156 * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
158 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
159 * descriptors) and required locking structures.
161 #define TFD_TX_CMD_SLOTS 256
162 #define TFD_CMD_SLOTS 32
164 struct iwl_tx_queue
{
167 struct iwl_device_cmd
**cmd
;
168 struct iwl_cmd_meta
*meta
;
169 struct iwl_tx_info
*txb
;
170 unsigned long time_stamp
;
177 #define IWL_NUM_SCAN_RATES (2)
179 struct iwl4965_channel_tgd_info
{
184 struct iwl4965_channel_tgh_info
{
188 #define IWL4965_MAX_RATE (33)
190 struct iwl3945_clip_group
{
191 /* maximum power level to prevent clipping for each rate, derived by
192 * us from this band's saturation power in EEPROM */
193 const s8 clip_powers
[IWL_MAX_RATES
];
196 /* current Tx power values to use, one for each rate for each channel.
197 * requested power is limited by:
198 * -- regulatory EEPROM limits for this channel
199 * -- hardware capabilities (clip-powers)
200 * -- spectrum management
201 * -- user preference (e.g. iwconfig)
202 * when requested power is set, base power index must also be set. */
203 struct iwl3945_channel_power_info
{
204 struct iwl3945_tx_power tpc
; /* actual radio and DSP gain settings */
205 s8 power_table_index
; /* actual (compenst'd) index into gain table */
206 s8 base_power_index
; /* gain index for power at factory temp. */
207 s8 requested_power
; /* power (dBm) requested for this chnl/rate */
210 /* current scan Tx power values to use, one for each scan rate for each
212 struct iwl3945_scan_power_info
{
213 struct iwl3945_tx_power tpc
; /* actual radio and DSP gain settings */
214 s8 power_table_index
; /* actual (compenst'd) index into gain table */
215 s8 requested_power
; /* scan pwr (dBm) requested for chnl/rate */
219 * One for each channel, holds all channel setup data
220 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
223 struct iwl_channel_info
{
224 struct iwl4965_channel_tgd_info tgd
;
225 struct iwl4965_channel_tgh_info tgh
;
226 struct iwl_eeprom_channel eeprom
; /* EEPROM regulatory limit */
227 struct iwl_eeprom_channel ht40_eeprom
; /* EEPROM regulatory limit for
230 u8 channel
; /* channel number */
231 u8 flags
; /* flags copied from EEPROM */
232 s8 max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
233 s8 curr_txpow
; /* (dBm) regulatory/spectrum/user (not h/w) limit */
234 s8 min_power
; /* always 0 */
235 s8 scan_power
; /* (dBm) regul. eeprom, direct scans, any rate */
237 u8 group_index
; /* 0-4, maps channel to group1/2/3/4/5 */
238 u8 band_index
; /* 0-4, maps channel to band1/2/3/4/5 */
239 enum ieee80211_band band
;
241 /* HT40 channel info */
242 s8 ht40_max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
243 u8 ht40_flags
; /* flags copied from EEPROM */
244 u8 ht40_extension_channel
; /* HT_IE_EXT_CHANNEL_* */
246 /* Radio/DSP gain settings for each "normal" data Tx rate.
247 * These include, in addition to RF and DSP gain, a few fields for
248 * remembering/modifying gain settings (indexes). */
249 struct iwl3945_channel_power_info power_info
[IWL4965_MAX_RATE
];
251 /* Radio/DSP gain settings for each scan rate, for directed scans. */
252 struct iwl3945_scan_power_info scan_pwr_info
[IWL_NUM_SCAN_RATES
];
255 #define IWL_TX_FIFO_BK 0 /* shared */
256 #define IWL_TX_FIFO_BE 1
257 #define IWL_TX_FIFO_VI 2 /* shared */
258 #define IWL_TX_FIFO_VO 3
259 #define IWL_TX_FIFO_UNUSED -1
261 /* Minimum number of queues. MAX_NUM is defined in hw specific files.
262 * Set the minimum to accommodate the 4 standard TX queues, 1 command
263 * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
264 #define IWL_MIN_NUM_QUEUES 10
266 #define IWL_DEFAULT_CMD_QUEUE_NUM 4
268 #define IEEE80211_DATA_LEN 2304
269 #define IEEE80211_4ADDR_LEN 30
270 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
271 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
275 struct ieee80211_hdr frame
;
276 struct iwl_tx_beacon_cmd beacon
;
277 u8 raw
[IEEE80211_FRAME_LEN
];
280 struct list_head list
;
283 #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
284 #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
285 #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
291 CMD_SIZE_HUGE
= (1 << 0),
292 CMD_ASYNC
= (1 << 1),
293 CMD_WANT_SKB
= (1 << 2),
294 CMD_MAPPED
= (1 << 3),
297 #define DEF_CMD_PAYLOAD_SIZE 320
300 * struct iwl_device_cmd
302 * For allocation of the command and tx queues, this establishes the overall
303 * size of the largest command we send to uCode, except for a scan command
304 * (which is relatively huge; space is allocated separately).
306 struct iwl_device_cmd
{
307 struct iwl_cmd_header hdr
; /* uCode API */
313 struct iwl_tx_cmd tx
;
314 u8 payload
[DEF_CMD_PAYLOAD_SIZE
];
318 #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
321 struct iwl_host_cmd
{
323 unsigned long reply_page
;
324 void (*callback
)(struct iwl_priv
*priv
,
325 struct iwl_device_cmd
*cmd
,
326 struct iwl_rx_packet
*pkt
);
332 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
333 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
334 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
337 * struct iwl_rx_queue - Rx queue
338 * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
339 * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
340 * @read: Shared index to newest available Rx buffer
341 * @write: Shared index to oldest written Rx packet
342 * @free_count: Number of pre-allocated buffers in rx_free
343 * @rx_free: list of free SKBs for use
344 * @rx_used: List of Rx buffers with no SKB
345 * @need_update: flag to indicate we need to update read/write index
346 * @rb_stts: driver's pointer to receive buffer status
347 * @rb_stts_dma: bus address of receive buffer status
349 * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
351 struct iwl_rx_queue
{
354 struct iwl_rx_mem_buffer pool
[RX_QUEUE_SIZE
+ RX_FREE_BUFFERS
];
355 struct iwl_rx_mem_buffer
*queue
[RX_QUEUE_SIZE
];
360 struct list_head rx_free
;
361 struct list_head rx_used
;
363 struct iwl_rb_status
*rb_stts
;
364 dma_addr_t rb_stts_dma
;
368 #define IWL_SUPPORTED_RATES_IE_LEN 8
370 #define MAX_TID_COUNT 9
372 #define IWL_INVALID_RATE 0xFF
373 #define IWL_INVALID_VALUE -1
376 * struct iwl_ht_agg -- aggregation status while waiting for block-ack
377 * @txq_id: Tx queue used for Tx attempt
378 * @frame_count: # frames attempted by Tx command
379 * @wait_for_ba: Expect block-ack before next Tx reply
380 * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
381 * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
382 * @bitmap1: High order, one bit for each frame pending ACK in Tx window
383 * @rate_n_flags: Rate at which Tx was attempted
385 * If REPLY_TX indicates that aggregation was attempted, driver must wait
386 * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
387 * until block ack arrives.
396 #define IWL_AGG_OFF 0
398 #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
399 #define IWL_EMPTYING_HW_QUEUE_DELBA 3
404 struct iwl_tid_data
{
405 u16 seq_number
; /* 4965 only */
407 struct iwl_ht_agg agg
;
417 union iwl_ht_rate_supp
{
425 #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
426 #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
427 #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
428 #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
429 #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
430 #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
431 #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
434 * Maximal MPDU density for TX aggregation
440 #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
441 #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
442 #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
443 #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
444 #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
445 #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
446 #define CFG_HT_MPDU_DENSITY_MIN (0x1)
448 struct iwl_ht_config
{
449 bool single_chain_sufficient
;
450 enum ieee80211_smps_mode smps
; /* current smps mode */
454 struct iwl_qos_info
{
456 struct iwl_qosparam_cmd def_qos_parm
;
460 * Structure should be accessed with sta_lock held. When station addition
461 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
462 * the commands (iwl_legacy_addsta_cmd and iwl_link_quality_cmd) without
465 struct iwl_station_entry
{
466 struct iwl_legacy_addsta_cmd sta
;
467 struct iwl_tid_data tid
[MAX_TID_COUNT
];
469 struct iwl_hw_key keyinfo
;
470 struct iwl_link_quality_cmd
*lq
;
473 struct iwl_station_priv_common
{
474 struct iwl_rxon_context
*ctx
;
479 * iwl_station_priv: Driver's private station information
481 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
482 * in the structure for use by driver. This structure is places in that
485 * The common struct MUST be first because it is shared between
488 struct iwl_station_priv
{
489 struct iwl_station_priv_common common
;
490 struct iwl_lq_sta lq_sta
;
491 atomic_t pending_frames
;
497 * struct iwl_vif_priv - driver's private per-interface information
499 * When mac80211 allocates a virtual interface, it can allocate
500 * space for us to put data into.
502 struct iwl_vif_priv
{
503 struct iwl_rxon_context
*ctx
;
504 u8 ibss_bssid_sta_id
;
507 /* one for each uCode image (inst/data, boot/init/runtime) */
509 void *v_addr
; /* access by driver */
510 dma_addr_t p_addr
; /* access by card's busmaster DMA */
514 /* uCode file layout */
515 struct iwl_ucode_header
{
516 __le32 ver
; /* major/minor/API/serial */
518 __le32 inst_size
; /* bytes of runtime code */
519 __le32 data_size
; /* bytes of runtime data */
520 __le32 init_size
; /* bytes of init code */
521 __le32 init_data_size
; /* bytes of init data */
522 __le32 boot_size
; /* bytes of bootstrap code */
523 u8 data
[0]; /* in same order as sizes */
527 struct iwl4965_ibss_seq
{
531 unsigned long packet_time
;
532 struct list_head list
;
535 struct iwl_sensitivity_ranges
{
542 u16 auto_corr_min_ofdm
;
543 u16 auto_corr_min_ofdm_mrc
;
544 u16 auto_corr_min_ofdm_x1
;
545 u16 auto_corr_min_ofdm_mrc_x1
;
547 u16 auto_corr_max_ofdm
;
548 u16 auto_corr_max_ofdm_mrc
;
549 u16 auto_corr_max_ofdm_x1
;
550 u16 auto_corr_max_ofdm_mrc_x1
;
552 u16 auto_corr_max_cck
;
553 u16 auto_corr_max_cck_mrc
;
554 u16 auto_corr_min_cck
;
555 u16 auto_corr_min_cck_mrc
;
557 u16 barker_corr_th_min
;
558 u16 barker_corr_th_min_mrc
;
563 #define KELVIN_TO_CELSIUS(x) ((x)-273)
564 #define CELSIUS_TO_KELVIN(x) ((x)+273)
568 * struct iwl_hw_params
569 * @max_txq_num: Max # Tx queues supported
570 * @dma_chnl_num: Number of Tx DMA/FIFO channels
571 * @scd_bc_tbls_size: size of scheduler byte count tables
572 * @tfd_size: TFD size
573 * @tx/rx_chains_num: Number of TX/RX chains
574 * @valid_tx/rx_ant: usable antennas
575 * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
576 * @max_rxq_log: Log-base-2 of max_rxq_size
577 * @rx_page_order: Rx buffer page order
578 * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
580 * @ht40_channel: is 40MHz width possible in band 2.4
581 * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
582 * @sw_crypto: 0 for hw, 1 for sw
583 * @max_xxx_size: for ucode uses
584 * @ct_kill_threshold: temperature threshold
585 * @beacon_time_tsf_bits: number of valid tsf bits for beacon time
586 * @struct iwl_sensitivity_ranges: range of sensitivity values
588 struct iwl_hw_params
{
591 u16 scd_bc_tbls_size
;
603 u8 max_beacon_itrvl
; /* in 1024 ms */
607 u32 ct_kill_threshold
; /* value in hw-dependent units */
608 u16 beacon_time_tsf_bits
;
609 const struct iwl_sensitivity_ranges
*sens
;
613 /******************************************************************************
615 * Functions implemented in core module which are forward declared here
616 * for use by iwl-[4-5].c
618 * NOTE: The implementation of these functions are not hardware specific
619 * which is why they are in the core module files.
621 * Naming convention --
622 * iwl_ <-- Is part of iwlwifi
623 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
624 * iwl4965_bg_ <-- Called from work queue context
625 * iwl4965_mac_ <-- mac80211 callback
627 ****************************************************************************/
628 extern void iwl4965_update_chain_flags(struct iwl_priv
*priv
);
629 extern const u8 iwlegacy_bcast_addr
[ETH_ALEN
];
630 extern int iwl_legacy_queue_space(const struct iwl_queue
*q
);
631 static inline int iwl_legacy_queue_used(const struct iwl_queue
*q
, int i
)
633 return q
->write_ptr
>= q
->read_ptr
?
634 (i
>= q
->read_ptr
&& i
< q
->write_ptr
) :
635 !(i
< q
->read_ptr
&& i
>= q
->write_ptr
);
639 static inline u8
iwl_legacy_get_cmd_index(struct iwl_queue
*q
, u32 index
,
643 * This is for init calibration result and scan command which
644 * required buffer > TFD_MAX_PAYLOAD_SIZE,
645 * the big buffer at end of command array
648 return q
->n_window
; /* must be power of 2 */
650 /* Otherwise, use normal size buffers */
651 return index
& (q
->n_window
- 1);
661 #define IWL_OPERATION_MODE_AUTO 0
662 #define IWL_OPERATION_MODE_HT_ONLY 1
663 #define IWL_OPERATION_MODE_MIXED 2
664 #define IWL_OPERATION_MODE_20MHZ 3
666 #define IWL_TX_CRC_SIZE 4
667 #define IWL_TX_DELIMITER_SIZE 4
669 #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
671 /* Sensitivity and chain noise calibration */
672 #define INITIALIZATION_VALUE 0xFFFF
673 #define IWL4965_CAL_NUM_BEACONS 20
674 #define IWL_CAL_NUM_BEACONS 16
675 #define MAXIMUM_ALLOWED_PATHLOSS 15
677 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
679 #define MAX_FA_OFDM 50
680 #define MIN_FA_OFDM 5
681 #define MAX_FA_CCK 50
684 #define AUTO_CORR_STEP_OFDM 1
686 #define AUTO_CORR_STEP_CCK 3
687 #define AUTO_CORR_MAX_TH_CCK 160
690 #define NRG_STEP_CCK 2
692 #define MAX_NUMBER_CCK_NO_FA 100
694 #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
699 #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
700 #define ALL_BAND_FILTER 0xFF00
701 #define IN_BAND_FILTER 0xFF
702 #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
704 #define NRG_NUM_PREV_STAT_L 20
705 #define NUM_RX_CHAINS 3
707 enum iwl4965_false_alarm_state
{
710 IWL_FA_GOOD_RANGE
= 2,
713 enum iwl4965_chain_noise_state
{
714 IWL_CHAIN_NOISE_ALIVE
= 0, /* must be 0 */
715 IWL_CHAIN_NOISE_ACCUMULATE
,
716 IWL_CHAIN_NOISE_CALIBRATED
,
717 IWL_CHAIN_NOISE_DONE
,
720 enum iwl4965_calib_enabled_state
{
721 IWL_CALIB_DISABLED
= 0, /* must be 0 */
722 IWL_CALIB_ENABLED
= 1,
727 * defines the order in which results of initial calibrations
728 * should be sent to the runtime uCode
734 /* Opaque calibration results */
735 struct iwl_calib_result
{
746 /* Sensitivity calib data */
747 struct iwl_sensitivity_data
{
749 u32 auto_corr_ofdm_mrc
;
750 u32 auto_corr_ofdm_x1
;
751 u32 auto_corr_ofdm_mrc_x1
;
753 u32 auto_corr_cck_mrc
;
755 u32 last_bad_plcp_cnt_ofdm
;
756 u32 last_fa_cnt_ofdm
;
757 u32 last_bad_plcp_cnt_cck
;
763 u8 nrg_silence_rssi
[NRG_NUM_PREV_STAT_L
];
768 s32 nrg_auto_corr_silence_diff
;
769 u32 num_in_cck_no_fa
;
772 u16 barker_corr_th_min
;
773 u16 barker_corr_th_min_mrc
;
777 /* Chain noise (differential Rx gain) calib data */
778 struct iwl_chain_noise_data
{
787 u8 disconn_array
[NUM_RX_CHAINS
];
788 u8 delta_gain_code
[NUM_RX_CHAINS
];
793 #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
794 #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
796 #define IWL_TRAFFIC_ENTRIES (256)
797 #define IWL_TRAFFIC_ENTRY_SIZE (64)
800 MEASUREMENT_READY
= (1 << 0),
801 MEASUREMENT_ACTIVE
= (1 << 1),
804 /* interrupt statistics */
805 struct isr_statistics
{
815 u32 rx_handlers
[REPLY_MAX
];
820 /* management statistics */
821 enum iwl_mgmt_stats
{
822 MANAGEMENT_ASSOC_REQ
= 0,
823 MANAGEMENT_ASSOC_RESP
,
824 MANAGEMENT_REASSOC_REQ
,
825 MANAGEMENT_REASSOC_RESP
,
826 MANAGEMENT_PROBE_REQ
,
827 MANAGEMENT_PROBE_RESP
,
836 /* control statistics */
837 enum iwl_ctrl_stats
{
838 CONTROL_BACK_REQ
= 0,
849 struct traffic_stats
{
850 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
851 u32 mgmt
[MANAGEMENT_MAX
];
852 u32 ctrl
[CONTROL_MAX
];
859 * host interrupt timeout value
860 * used with setting interrupt coalescing timer
861 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
863 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
864 * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
866 #define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
867 #define IWL_HOST_INT_TIMEOUT_DEF (0x40)
868 #define IWL_HOST_INT_TIMEOUT_MIN (0x0)
869 #define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
870 #define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
871 #define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
873 #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
875 /* TX queue watchdog timeouts in mSecs */
876 #define IWL_DEF_WD_TIMEOUT (2000)
877 #define IWL_LONG_WD_TIMEOUT (10000)
878 #define IWL_MAX_WD_TIMEOUT (120000)
880 struct iwl_force_reset
{
881 int reset_request_count
;
882 int reset_success_count
;
883 int reset_reject_count
;
884 unsigned long reset_duration
;
885 unsigned long last_force_reset_jiffies
;
888 /* extend beacon time format bit shifting */
891 * bits 31:24 - extended
892 * bits 23:0 - interval
894 #define IWL3945_EXT_BEACON_TIME_POS 24
897 * bits 31:22 - extended
898 * bits 21:0 - interval
900 #define IWL4965_EXT_BEACON_TIME_POS 22
902 enum iwl_rxon_context_id
{
908 struct iwl_rxon_context
{
909 struct ieee80211_vif
*vif
;
911 const u8
*ac_to_fifo
;
912 const u8
*ac_to_queue
;
916 * We could use the vif to indicate active, but we
917 * also need it to be active during disabling when
918 * we already removed the vif for type setting.
920 bool always_active
, is_active
;
922 bool ht_need_multiple_chains
;
924 enum iwl_rxon_context_id ctxid
;
926 u32 interface_modes
, exclusive_interface_modes
;
927 u8 unused_devtype
, ap_devtype
, ibss_devtype
, station_devtype
;
930 * We declare this const so it can only be
931 * changed via explicit cast within the
932 * routines that actually update the physical
935 const struct iwl_legacy_rxon_cmd active
;
936 struct iwl_legacy_rxon_cmd staging
;
938 struct iwl_rxon_time_cmd timing
;
940 struct iwl_qos_info qos_data
;
942 u8 bcast_sta_id
, ap_sta_id
;
944 u8 rxon_cmd
, rxon_assoc_cmd
, rxon_timing_cmd
;
948 struct iwl_wep_key wep_keys
[WEP_KEYS_MAX
];
951 __le32 station_flags
;
954 bool non_gf_sta_present
;
956 bool enabled
, is_40mhz
;
957 u8 extension_chan_offset
;
963 /* ieee device used by generic ieee processing code */
964 struct ieee80211_hw
*hw
;
965 struct ieee80211_channel
*ieee_channels
;
966 struct ieee80211_rate
*ieee_rates
;
969 /* temporary frame storage list */
970 struct list_head free_frames
;
973 enum ieee80211_band band
;
976 void (*rx_handlers
[REPLY_MAX
])(struct iwl_priv
*priv
,
977 struct iwl_rx_mem_buffer
*rxb
);
979 struct ieee80211_supported_band bands
[IEEE80211_NUM_BANDS
];
981 /* spectrum measurement report caching */
982 struct iwl_spectrum_notification measure_report
;
983 u8 measurement_status
;
985 /* ucode beacon time */
986 u32 ucode_beacon_time
;
987 int missed_beacon_threshold
;
989 /* track IBSS manager (last beacon) status */
993 struct iwl_force_reset force_reset
;
995 /* we allocate array of iwl_channel_info for NIC's valid channels.
996 * Access via channel # using indirect index array */
997 struct iwl_channel_info
*channel_info
; /* channel info array */
998 u8 channel_count
; /* # of channels */
1000 /* thermal calibration */
1001 s32 temperature
; /* degrees Kelvin */
1002 s32 last_temperature
;
1004 /* init calibration results */
1005 struct iwl_calib_result calib_results
[IWL_CALIB_MAX
];
1007 /* Scan related variables */
1008 unsigned long scan_start
;
1009 unsigned long scan_start_tsf
;
1011 enum ieee80211_band scan_band
;
1012 struct cfg80211_scan_request
*scan_request
;
1013 struct ieee80211_vif
*scan_vif
;
1014 u8 scan_tx_ant
[IEEE80211_NUM_BANDS
];
1018 spinlock_t lock
; /* protect general shared data */
1019 spinlock_t hcmd_lock
; /* protect hcmd */
1020 spinlock_t reg_lock
; /* protect hw register access */
1023 /* basic pci-network driver stuff */
1024 struct pci_dev
*pci_dev
;
1026 /* pci hardware address support */
1027 void __iomem
*hw_base
;
1032 /* microcode/device supports multiple contexts */
1035 /* command queue number */
1038 /* max number of station keys */
1041 /* EEPROM MAC addresses */
1042 struct mac_address addresses
[1];
1044 /* uCode images, save to reload in case of failure */
1045 int fw_index
; /* firmware we're trying to load */
1046 u32 ucode_ver
; /* version of ucode, copy of
1048 struct fw_desc ucode_code
; /* runtime inst */
1049 struct fw_desc ucode_data
; /* runtime data original */
1050 struct fw_desc ucode_data_backup
; /* runtime data save/restore */
1051 struct fw_desc ucode_init
; /* initialization inst */
1052 struct fw_desc ucode_init_data
; /* initialization data */
1053 struct fw_desc ucode_boot
; /* bootstrap inst */
1054 enum ucode_type ucode_type
;
1055 u8 ucode_write_complete
; /* the image write is complete */
1056 char firmware_name
[25];
1058 struct iwl_rxon_context contexts
[NUM_IWL_RXON_CTX
];
1060 __le16 switch_channel
;
1062 /* 1st responses from initialize and runtime uCode images.
1063 * _4965's initialize alive response contains some calibration data. */
1064 struct iwl_init_alive_resp card_alive_init
;
1065 struct iwl_alive_resp card_alive
;
1070 struct iwl_sensitivity_data sensitivity_data
;
1071 struct iwl_chain_noise_data chain_noise_data
;
1072 __le16 sensitivity_tbl
[HD_TABLE_SIZE
];
1074 struct iwl_ht_config current_ht_config
;
1076 /* Rate scaling data */
1079 wait_queue_head_t wait_command_queue
;
1081 int activity_timer_active
;
1083 /* Rx and Tx DMA processing queues */
1084 struct iwl_rx_queue rxq
;
1085 struct iwl_tx_queue
*txq
;
1086 unsigned long txq_ctx_active_msk
;
1087 struct iwl_dma_ptr kw
; /* keep warm address */
1088 struct iwl_dma_ptr scd_bc_tbls
;
1090 u32 scd_base_addr
; /* scheduler sram base address */
1092 unsigned long status
;
1094 /* counts mgmt, ctl, and data packets */
1095 struct traffic_stats tx_stats
;
1096 struct traffic_stats rx_stats
;
1098 /* counts interrupts */
1099 struct isr_statistics isr_stats
;
1101 struct iwl_power_mgr power_data
;
1103 /* context information */
1104 u8 bssid
[ETH_ALEN
]; /* used only on 3945 but filled by core */
1106 /* station table variables */
1108 /* Note: if lock and sta_lock are needed, lock must be acquired first */
1109 spinlock_t sta_lock
;
1111 struct iwl_station_entry stations
[IWL_STATION_COUNT
];
1112 unsigned long ucode_key_table
;
1114 /* queue refcounts */
1115 #define IWL_MAX_HW_QUEUES 32
1116 unsigned long queue_stopped
[BITS_TO_LONGS(IWL_MAX_HW_QUEUES
)];
1118 atomic_t queue_stop_count
[4];
1120 /* Indication if ieee80211_ops->open has been called */
1123 u8 mac80211_registered
;
1125 /* eeprom -- this is in the card's little endian byte order */
1127 struct iwl_eeprom_calib_info
*calib_info
;
1129 enum nl80211_iftype iw_mode
;
1131 /* Last Rx'd beacon timestamp */
1135 #if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
1138 dma_addr_t shared_phys
;
1140 struct delayed_work thermal_periodic
;
1141 struct delayed_work rfkill_poll
;
1143 struct iwl3945_notif_statistics statistics
;
1144 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
1145 struct iwl3945_notif_statistics accum_statistics
;
1146 struct iwl3945_notif_statistics delta_statistics
;
1147 struct iwl3945_notif_statistics max_delta
;
1151 int last_rx_rssi
; /* From Rx packet statistics */
1153 /* Rx'd packet timing information */
1154 u32 last_beacon_time
;
1158 * each calibration channel group in the
1159 * EEPROM has a derived clip setting for
1162 const struct iwl3945_clip_group clip_groups
[5];
1166 #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE)
1168 struct iwl_rx_phy_res last_phy_res
;
1169 bool last_phy_res_valid
;
1171 struct completion firmware_loading_complete
;
1174 * chain noise reset and gain commands are the
1175 * two extra calibration commands follows the standard
1176 * phy calibration commands
1178 u8 phy_calib_chain_noise_reset_cmd
;
1179 u8 phy_calib_chain_noise_gain_cmd
;
1181 struct iwl_notif_statistics statistics
;
1182 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
1183 struct iwl_notif_statistics accum_statistics
;
1184 struct iwl_notif_statistics delta_statistics
;
1185 struct iwl_notif_statistics max_delta
;
1192 struct iwl_hw_params hw_params
;
1196 struct workqueue_struct
*workqueue
;
1198 struct work_struct restart
;
1199 struct work_struct scan_completed
;
1200 struct work_struct rx_replenish
;
1201 struct work_struct abort_scan
;
1203 struct iwl_rxon_context
*beacon_ctx
;
1204 struct sk_buff
*beacon_skb
;
1206 struct work_struct tx_flush
;
1208 struct tasklet_struct irq_tasklet
;
1210 struct delayed_work init_alive_start
;
1211 struct delayed_work alive_start
;
1212 struct delayed_work scan_check
;
1215 s8 tx_power_user_lmt
;
1216 s8 tx_power_device_lmt
;
1220 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1221 /* debugging info */
1222 u32 debug_level
; /* per device debugging will override global
1223 iwlegacy_debug_level if set */
1224 #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */
1225 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
1231 struct dentry
*debugfs_dir
;
1232 u32 dbgfs_sram_offset
, dbgfs_sram_len
;
1234 #endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */
1236 struct work_struct txpower_work
;
1237 u32 disable_sens_cal
;
1238 u32 disable_chain_noise_cal
;
1239 u32 disable_tx_power_cal
;
1240 struct work_struct run_time_calib_work
;
1241 struct timer_list statistics_periodic
;
1242 struct timer_list watchdog
;
1245 struct led_classdev led
;
1246 unsigned long blink_on
, blink_off
;
1247 bool led_registered
;
1250 static inline void iwl_txq_ctx_activate(struct iwl_priv
*priv
, int txq_id
)
1252 set_bit(txq_id
, &priv
->txq_ctx_active_msk
);
1255 static inline void iwl_txq_ctx_deactivate(struct iwl_priv
*priv
, int txq_id
)
1257 clear_bit(txq_id
, &priv
->txq_ctx_active_msk
);
1260 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1262 * iwl_legacy_get_debug_level: Return active debug level for device
1264 * Using sysfs it is possible to set per device debug level. This debug
1265 * level will be used if set, otherwise the global debug level which can be
1266 * set via module parameter is used.
1268 static inline u32
iwl_legacy_get_debug_level(struct iwl_priv
*priv
)
1270 if (priv
->debug_level
)
1271 return priv
->debug_level
;
1273 return iwlegacy_debug_level
;
1276 static inline u32
iwl_legacy_get_debug_level(struct iwl_priv
*priv
)
1278 return iwlegacy_debug_level
;
1283 static inline struct ieee80211_hdr
*
1284 iwl_legacy_tx_queue_get_hdr(struct iwl_priv
*priv
,
1285 int txq_id
, int idx
)
1287 if (priv
->txq
[txq_id
].txb
[idx
].skb
)
1288 return (struct ieee80211_hdr
*)priv
->txq
[txq_id
].
1293 static inline struct iwl_rxon_context
*
1294 iwl_legacy_rxon_ctx_from_vif(struct ieee80211_vif
*vif
)
1296 struct iwl_vif_priv
*vif_priv
= (void *)vif
->drv_priv
;
1298 return vif_priv
->ctx
;
1301 #define for_each_context(priv, ctx) \
1302 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
1303 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
1304 if (priv->valid_contexts & BIT(ctx->ctxid))
1306 static inline int iwl_legacy_is_associated(struct iwl_priv
*priv
,
1307 enum iwl_rxon_context_id ctxid
)
1309 return (priv
->contexts
[ctxid
].active
.filter_flags
&
1310 RXON_FILTER_ASSOC_MSK
) ? 1 : 0;
1313 static inline int iwl_legacy_is_any_associated(struct iwl_priv
*priv
)
1315 return iwl_legacy_is_associated(priv
, IWL_RXON_CTX_BSS
);
1318 static inline int iwl_legacy_is_associated_ctx(struct iwl_rxon_context
*ctx
)
1320 return (ctx
->active
.filter_flags
& RXON_FILTER_ASSOC_MSK
) ? 1 : 0;
1323 static inline int iwl_legacy_is_channel_valid(const struct iwl_channel_info
*ch_info
)
1325 if (ch_info
== NULL
)
1327 return (ch_info
->flags
& EEPROM_CHANNEL_VALID
) ? 1 : 0;
1330 static inline int iwl_legacy_is_channel_radar(const struct iwl_channel_info
*ch_info
)
1332 return (ch_info
->flags
& EEPROM_CHANNEL_RADAR
) ? 1 : 0;
1335 static inline u8
iwl_legacy_is_channel_a_band(const struct iwl_channel_info
*ch_info
)
1337 return ch_info
->band
== IEEE80211_BAND_5GHZ
;
1341 iwl_legacy_is_channel_passive(const struct iwl_channel_info
*ch
)
1343 return (!(ch
->flags
& EEPROM_CHANNEL_ACTIVE
)) ? 1 : 0;
1347 iwl_legacy_is_channel_ibss(const struct iwl_channel_info
*ch
)
1349 return (ch
->flags
& EEPROM_CHANNEL_IBSS
) ? 1 : 0;
1353 __iwl_legacy_free_pages(struct iwl_priv
*priv
, struct page
*page
)
1355 __free_pages(page
, priv
->hw_params
.rx_page_order
);
1356 priv
->alloc_rxb_page
--;
1359 static inline void iwl_legacy_free_pages(struct iwl_priv
*priv
, unsigned long page
)
1361 free_pages(page
, priv
->hw_params
.rx_page_order
);
1362 priv
->alloc_rxb_page
--;
1364 #endif /* __iwl_legacy_dev_h__ */