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/pci.h> /* for struct pci_device_id */
36 #include <linux/kernel.h>
37 #include <linux/leds.h>
38 #include <linux/wait.h>
39 #include <net/ieee80211_radiotap.h>
41 #include "iwl-eeprom.h"
45 #include "iwl-debug.h"
46 #include "iwl-4965-hw.h"
47 #include "iwl-3945-hw.h"
49 #include "iwl-power.h"
50 #include "iwl-legacy-rs.h"
54 /* CT-KILL constants */
55 #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
57 /* Default noise level to report when noise measurement is not available.
58 * This may be because we're:
59 * 1) Not associated (4965, no beacon statistics being sent to driver)
60 * 2) Scanning (noise measurement does not apply to associated channel)
61 * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
62 * Use default noise value of -127 ... this is below the range of measurable
63 * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
64 * Also, -127 works better than 0 when averaging frames with/without
65 * noise info (e.g. averaging might be done in app); measured dBm values are
66 * always negative ... using a negative value as the default keeps all
67 * averages within an s8's (used in some apps) range of negative values. */
68 #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
71 * RTS threshold here is total size [2347] minus 4 FCS bytes
73 * a value of 0 means RTS on all data/management packets
74 * a value > max MSDU size means no RTS
75 * else RTS for data/management frames where MPDU is larger
78 #define DEFAULT_RTS_THRESHOLD 2347U
79 #define MIN_RTS_THRESHOLD 0U
80 #define MAX_RTS_THRESHOLD 2347U
81 #define MAX_MSDU_SIZE 2304U
82 #define MAX_MPDU_SIZE 2346U
83 #define DEFAULT_BEACON_INTERVAL 100U
84 #define DEFAULT_SHORT_RETRY_LIMIT 7U
85 #define DEFAULT_LONG_RETRY_LIMIT 4U
87 struct iwl_rx_mem_buffer
{
90 struct list_head list
;
93 #define rxb_addr(r) page_address(r->page)
96 struct iwl_device_cmd
;
99 /* only for SYNC commands, iff the reply skb is wanted */
100 struct iwl_host_cmd
*source
;
102 * only for ASYNC commands
103 * (which is somewhat stupid -- look at iwl-sta.c for instance
104 * which duplicates a bunch of code because the callback isn't
105 * invoked for SYNC commands, if it were and its result passed
106 * through it would be simpler...)
108 void (*callback
)(struct iwl_priv
*priv
,
109 struct iwl_device_cmd
*cmd
,
110 struct iwl_rx_packet
*pkt
);
112 /* The CMD_SIZE_HUGE flag bit indicates that the command
113 * structure is stored at the end of the shared queue memory. */
116 DEFINE_DMA_UNMAP_ADDR(mapping
);
117 DEFINE_DMA_UNMAP_LEN(len
);
121 * Generic queue structure
123 * Contains common data for Rx and Tx queues
126 int n_bd
; /* number of BDs in this queue */
127 int write_ptr
; /* 1-st empty entry (index) host_w*/
128 int read_ptr
; /* last used entry (index) host_r*/
129 /* use for monitoring and recovering the stuck queue */
130 dma_addr_t dma_addr
; /* physical addr for BD's */
131 int n_window
; /* safe queue window */
133 int low_mark
; /* low watermark, resume queue if free
134 * space more than this */
135 int high_mark
; /* high watermark, stop queue if free
136 * space less than this */
139 /* One for each TFD */
142 struct iwl_rxon_context
*ctx
;
146 * struct iwl_tx_queue - Tx Queue for DMA
147 * @q: generic Rx/Tx queue descriptor
148 * @bd: base of circular buffer of TFDs
149 * @cmd: array of command/TX buffer pointers
150 * @meta: array of meta data for each command/tx buffer
151 * @dma_addr_cmd: physical address of cmd/tx buffer array
152 * @txb: array of per-TFD driver data
153 * @time_stamp: time (in jiffies) of last read_ptr change
154 * @need_update: indicates need to update read/write index
155 * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
157 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
158 * descriptors) and required locking structures.
160 #define TFD_TX_CMD_SLOTS 256
161 #define TFD_CMD_SLOTS 32
163 struct iwl_tx_queue
{
166 struct iwl_device_cmd
**cmd
;
167 struct iwl_cmd_meta
*meta
;
168 struct iwl_tx_info
*txb
;
169 unsigned long time_stamp
;
176 #define IWL_NUM_SCAN_RATES (2)
178 struct iwl4965_channel_tgd_info
{
183 struct iwl4965_channel_tgh_info
{
187 #define IWL4965_MAX_RATE (33)
189 struct iwl3945_clip_group
{
190 /* maximum power level to prevent clipping for each rate, derived by
191 * us from this band's saturation power in EEPROM */
192 const s8 clip_powers
[IWL_MAX_RATES
];
195 /* current Tx power values to use, one for each rate for each channel.
196 * requested power is limited by:
197 * -- regulatory EEPROM limits for this channel
198 * -- hardware capabilities (clip-powers)
199 * -- spectrum management
200 * -- user preference (e.g. iwconfig)
201 * when requested power is set, base power index must also be set. */
202 struct iwl3945_channel_power_info
{
203 struct iwl3945_tx_power tpc
; /* actual radio and DSP gain settings */
204 s8 power_table_index
; /* actual (compenst'd) index into gain table */
205 s8 base_power_index
; /* gain index for power at factory temp. */
206 s8 requested_power
; /* power (dBm) requested for this chnl/rate */
209 /* current scan Tx power values to use, one for each scan rate for each
211 struct iwl3945_scan_power_info
{
212 struct iwl3945_tx_power tpc
; /* actual radio and DSP gain settings */
213 s8 power_table_index
; /* actual (compenst'd) index into gain table */
214 s8 requested_power
; /* scan pwr (dBm) requested for chnl/rate */
218 * One for each channel, holds all channel setup data
219 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
222 struct iwl_channel_info
{
223 struct iwl4965_channel_tgd_info tgd
;
224 struct iwl4965_channel_tgh_info tgh
;
225 struct iwl_eeprom_channel eeprom
; /* EEPROM regulatory limit */
226 struct iwl_eeprom_channel ht40_eeprom
; /* EEPROM regulatory limit for
229 u8 channel
; /* channel number */
230 u8 flags
; /* flags copied from EEPROM */
231 s8 max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
232 s8 curr_txpow
; /* (dBm) regulatory/spectrum/user (not h/w) limit */
233 s8 min_power
; /* always 0 */
234 s8 scan_power
; /* (dBm) regul. eeprom, direct scans, any rate */
236 u8 group_index
; /* 0-4, maps channel to group1/2/3/4/5 */
237 u8 band_index
; /* 0-4, maps channel to band1/2/3/4/5 */
238 enum ieee80211_band band
;
240 /* HT40 channel info */
241 s8 ht40_max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
242 u8 ht40_flags
; /* flags copied from EEPROM */
243 u8 ht40_extension_channel
; /* HT_IE_EXT_CHANNEL_* */
245 /* Radio/DSP gain settings for each "normal" data Tx rate.
246 * These include, in addition to RF and DSP gain, a few fields for
247 * remembering/modifying gain settings (indexes). */
248 struct iwl3945_channel_power_info power_info
[IWL4965_MAX_RATE
];
250 /* Radio/DSP gain settings for each scan rate, for directed scans. */
251 struct iwl3945_scan_power_info scan_pwr_info
[IWL_NUM_SCAN_RATES
];
254 #define IWL_TX_FIFO_BK 0 /* shared */
255 #define IWL_TX_FIFO_BE 1
256 #define IWL_TX_FIFO_VI 2 /* shared */
257 #define IWL_TX_FIFO_VO 3
258 #define IWL_TX_FIFO_UNUSED -1
260 /* Minimum number of queues. MAX_NUM is defined in hw specific files.
261 * Set the minimum to accommodate the 4 standard TX queues, 1 command
262 * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
263 #define IWL_MIN_NUM_QUEUES 10
265 #define IWL_DEFAULT_CMD_QUEUE_NUM 4
267 #define IEEE80211_DATA_LEN 2304
268 #define IEEE80211_4ADDR_LEN 30
269 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
270 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
274 struct ieee80211_hdr frame
;
275 struct iwl_tx_beacon_cmd beacon
;
276 u8 raw
[IEEE80211_FRAME_LEN
];
279 struct list_head list
;
282 #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
283 #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
284 #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
290 CMD_SIZE_HUGE
= (1 << 0),
291 CMD_ASYNC
= (1 << 1),
292 CMD_WANT_SKB
= (1 << 2),
295 #define DEF_CMD_PAYLOAD_SIZE 320
298 * struct iwl_device_cmd
300 * For allocation of the command and tx queues, this establishes the overall
301 * size of the largest command we send to uCode, except for a scan command
302 * (which is relatively huge; space is allocated separately).
304 struct iwl_device_cmd
{
305 struct iwl_cmd_header hdr
; /* uCode API */
311 struct iwl_tx_cmd tx
;
312 u8 payload
[DEF_CMD_PAYLOAD_SIZE
];
316 #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
319 struct iwl_host_cmd
{
321 unsigned long reply_page
;
322 void (*callback
)(struct iwl_priv
*priv
,
323 struct iwl_device_cmd
*cmd
,
324 struct iwl_rx_packet
*pkt
);
330 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
331 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
332 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
335 * struct iwl_rx_queue - Rx queue
336 * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
337 * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
338 * @read: Shared index to newest available Rx buffer
339 * @write: Shared index to oldest written Rx packet
340 * @free_count: Number of pre-allocated buffers in rx_free
341 * @rx_free: list of free SKBs for use
342 * @rx_used: List of Rx buffers with no SKB
343 * @need_update: flag to indicate we need to update read/write index
344 * @rb_stts: driver's pointer to receive buffer status
345 * @rb_stts_dma: bus address of receive buffer status
347 * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
349 struct iwl_rx_queue
{
352 struct iwl_rx_mem_buffer pool
[RX_QUEUE_SIZE
+ RX_FREE_BUFFERS
];
353 struct iwl_rx_mem_buffer
*queue
[RX_QUEUE_SIZE
];
358 struct list_head rx_free
;
359 struct list_head rx_used
;
361 struct iwl_rb_status
*rb_stts
;
362 dma_addr_t rb_stts_dma
;
366 #define IWL_SUPPORTED_RATES_IE_LEN 8
368 #define MAX_TID_COUNT 9
370 #define IWL_INVALID_RATE 0xFF
371 #define IWL_INVALID_VALUE -1
374 * struct iwl_ht_agg -- aggregation status while waiting for block-ack
375 * @txq_id: Tx queue used for Tx attempt
376 * @frame_count: # frames attempted by Tx command
377 * @wait_for_ba: Expect block-ack before next Tx reply
378 * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
379 * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
380 * @bitmap1: High order, one bit for each frame pending ACK in Tx window
381 * @rate_n_flags: Rate at which Tx was attempted
383 * If REPLY_TX indicates that aggregation was attempted, driver must wait
384 * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
385 * until block ack arrives.
394 #define IWL_AGG_OFF 0
396 #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
397 #define IWL_EMPTYING_HW_QUEUE_DELBA 3
402 struct iwl_tid_data
{
403 u16 seq_number
; /* 4965 only */
405 struct iwl_ht_agg agg
;
415 union iwl_ht_rate_supp
{
423 #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
424 #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
425 #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
426 #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
427 #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
428 #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
429 #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
432 * Maximal MPDU density for TX aggregation
438 #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
439 #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
440 #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
441 #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
442 #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
443 #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
444 #define CFG_HT_MPDU_DENSITY_MIN (0x1)
446 struct iwl_ht_config
{
447 bool single_chain_sufficient
;
448 enum ieee80211_smps_mode smps
; /* current smps mode */
452 struct iwl_qos_info
{
454 struct iwl_qosparam_cmd def_qos_parm
;
458 * Structure should be accessed with sta_lock held. When station addition
459 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
460 * the commands (iwl_legacy_addsta_cmd and iwl_link_quality_cmd) without
463 struct iwl_station_entry
{
464 struct iwl_legacy_addsta_cmd sta
;
465 struct iwl_tid_data tid
[MAX_TID_COUNT
];
467 struct iwl_hw_key keyinfo
;
468 struct iwl_link_quality_cmd
*lq
;
471 struct iwl_station_priv_common
{
472 struct iwl_rxon_context
*ctx
;
477 * iwl_station_priv: Driver's private station information
479 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
480 * in the structure for use by driver. This structure is places in that
483 * The common struct MUST be first because it is shared between
486 struct iwl_station_priv
{
487 struct iwl_station_priv_common common
;
488 struct iwl_lq_sta lq_sta
;
489 atomic_t pending_frames
;
495 * struct iwl_vif_priv - driver's private per-interface information
497 * When mac80211 allocates a virtual interface, it can allocate
498 * space for us to put data into.
500 struct iwl_vif_priv
{
501 struct iwl_rxon_context
*ctx
;
502 u8 ibss_bssid_sta_id
;
505 /* one for each uCode image (inst/data, boot/init/runtime) */
507 void *v_addr
; /* access by driver */
508 dma_addr_t p_addr
; /* access by card's busmaster DMA */
512 /* uCode file layout */
513 struct iwl_ucode_header
{
514 __le32 ver
; /* major/minor/API/serial */
516 __le32 inst_size
; /* bytes of runtime code */
517 __le32 data_size
; /* bytes of runtime data */
518 __le32 init_size
; /* bytes of init code */
519 __le32 init_data_size
; /* bytes of init data */
520 __le32 boot_size
; /* bytes of bootstrap code */
521 u8 data
[0]; /* in same order as sizes */
525 struct iwl4965_ibss_seq
{
529 unsigned long packet_time
;
530 struct list_head list
;
533 struct iwl_sensitivity_ranges
{
540 u16 auto_corr_min_ofdm
;
541 u16 auto_corr_min_ofdm_mrc
;
542 u16 auto_corr_min_ofdm_x1
;
543 u16 auto_corr_min_ofdm_mrc_x1
;
545 u16 auto_corr_max_ofdm
;
546 u16 auto_corr_max_ofdm_mrc
;
547 u16 auto_corr_max_ofdm_x1
;
548 u16 auto_corr_max_ofdm_mrc_x1
;
550 u16 auto_corr_max_cck
;
551 u16 auto_corr_max_cck_mrc
;
552 u16 auto_corr_min_cck
;
553 u16 auto_corr_min_cck_mrc
;
555 u16 barker_corr_th_min
;
556 u16 barker_corr_th_min_mrc
;
561 #define KELVIN_TO_CELSIUS(x) ((x)-273)
562 #define CELSIUS_TO_KELVIN(x) ((x)+273)
566 * struct iwl_hw_params
567 * @max_txq_num: Max # Tx queues supported
568 * @dma_chnl_num: Number of Tx DMA/FIFO channels
569 * @scd_bc_tbls_size: size of scheduler byte count tables
570 * @tfd_size: TFD size
571 * @tx/rx_chains_num: Number of TX/RX chains
572 * @valid_tx/rx_ant: usable antennas
573 * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
574 * @max_rxq_log: Log-base-2 of max_rxq_size
575 * @rx_page_order: Rx buffer page order
576 * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
578 * @ht40_channel: is 40MHz width possible in band 2.4
579 * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
580 * @sw_crypto: 0 for hw, 1 for sw
581 * @max_xxx_size: for ucode uses
582 * @ct_kill_threshold: temperature threshold
583 * @beacon_time_tsf_bits: number of valid tsf bits for beacon time
584 * @struct iwl_sensitivity_ranges: range of sensitivity values
586 struct iwl_hw_params
{
589 u16 scd_bc_tbls_size
;
601 u8 max_beacon_itrvl
; /* in 1024 ms */
605 u32 ct_kill_threshold
; /* value in hw-dependent units */
606 u16 beacon_time_tsf_bits
;
607 const struct iwl_sensitivity_ranges
*sens
;
611 /******************************************************************************
613 * Functions implemented in core module which are forward declared here
614 * for use by iwl-[4-5].c
616 * NOTE: The implementation of these functions are not hardware specific
617 * which is why they are in the core module files.
619 * Naming convention --
620 * iwl_ <-- Is part of iwlwifi
621 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
622 * iwl4965_bg_ <-- Called from work queue context
623 * iwl4965_mac_ <-- mac80211 callback
625 ****************************************************************************/
626 extern void iwl4965_update_chain_flags(struct iwl_priv
*priv
);
627 extern const u8 iwlegacy_bcast_addr
[ETH_ALEN
];
628 extern int iwl_legacy_queue_space(const struct iwl_queue
*q
);
629 static inline int iwl_legacy_queue_used(const struct iwl_queue
*q
, int i
)
631 return q
->write_ptr
>= q
->read_ptr
?
632 (i
>= q
->read_ptr
&& i
< q
->write_ptr
) :
633 !(i
< q
->read_ptr
&& i
>= q
->write_ptr
);
637 static inline u8
iwl_legacy_get_cmd_index(struct iwl_queue
*q
, u32 index
,
641 * This is for init calibration result and scan command which
642 * required buffer > TFD_MAX_PAYLOAD_SIZE,
643 * the big buffer at end of command array
646 return q
->n_window
; /* must be power of 2 */
648 /* Otherwise, use normal size buffers */
649 return index
& (q
->n_window
- 1);
659 #define IWL_OPERATION_MODE_AUTO 0
660 #define IWL_OPERATION_MODE_HT_ONLY 1
661 #define IWL_OPERATION_MODE_MIXED 2
662 #define IWL_OPERATION_MODE_20MHZ 3
664 #define IWL_TX_CRC_SIZE 4
665 #define IWL_TX_DELIMITER_SIZE 4
667 #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
669 /* Sensitivity and chain noise calibration */
670 #define INITIALIZATION_VALUE 0xFFFF
671 #define IWL4965_CAL_NUM_BEACONS 20
672 #define IWL_CAL_NUM_BEACONS 16
673 #define MAXIMUM_ALLOWED_PATHLOSS 15
675 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
677 #define MAX_FA_OFDM 50
678 #define MIN_FA_OFDM 5
679 #define MAX_FA_CCK 50
682 #define AUTO_CORR_STEP_OFDM 1
684 #define AUTO_CORR_STEP_CCK 3
685 #define AUTO_CORR_MAX_TH_CCK 160
688 #define NRG_STEP_CCK 2
690 #define MAX_NUMBER_CCK_NO_FA 100
692 #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
697 #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
698 #define ALL_BAND_FILTER 0xFF00
699 #define IN_BAND_FILTER 0xFF
700 #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
702 #define NRG_NUM_PREV_STAT_L 20
703 #define NUM_RX_CHAINS 3
705 enum iwl4965_false_alarm_state
{
708 IWL_FA_GOOD_RANGE
= 2,
711 enum iwl4965_chain_noise_state
{
712 IWL_CHAIN_NOISE_ALIVE
= 0, /* must be 0 */
713 IWL_CHAIN_NOISE_ACCUMULATE
,
714 IWL_CHAIN_NOISE_CALIBRATED
,
715 IWL_CHAIN_NOISE_DONE
,
718 enum iwl4965_calib_enabled_state
{
719 IWL_CALIB_DISABLED
= 0, /* must be 0 */
720 IWL_CALIB_ENABLED
= 1,
725 * defines the order in which results of initial calibrations
726 * should be sent to the runtime uCode
732 /* Opaque calibration results */
733 struct iwl_calib_result
{
744 /* Sensitivity calib data */
745 struct iwl_sensitivity_data
{
747 u32 auto_corr_ofdm_mrc
;
748 u32 auto_corr_ofdm_x1
;
749 u32 auto_corr_ofdm_mrc_x1
;
751 u32 auto_corr_cck_mrc
;
753 u32 last_bad_plcp_cnt_ofdm
;
754 u32 last_fa_cnt_ofdm
;
755 u32 last_bad_plcp_cnt_cck
;
761 u8 nrg_silence_rssi
[NRG_NUM_PREV_STAT_L
];
766 s32 nrg_auto_corr_silence_diff
;
767 u32 num_in_cck_no_fa
;
770 u16 barker_corr_th_min
;
771 u16 barker_corr_th_min_mrc
;
775 /* Chain noise (differential Rx gain) calib data */
776 struct iwl_chain_noise_data
{
785 u8 disconn_array
[NUM_RX_CHAINS
];
786 u8 delta_gain_code
[NUM_RX_CHAINS
];
791 #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
792 #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
794 #define IWL_TRAFFIC_ENTRIES (256)
795 #define IWL_TRAFFIC_ENTRY_SIZE (64)
798 MEASUREMENT_READY
= (1 << 0),
799 MEASUREMENT_ACTIVE
= (1 << 1),
802 /* interrupt statistics */
803 struct isr_statistics
{
813 u32 rx_handlers
[REPLY_MAX
];
818 /* management statistics */
819 enum iwl_mgmt_stats
{
820 MANAGEMENT_ASSOC_REQ
= 0,
821 MANAGEMENT_ASSOC_RESP
,
822 MANAGEMENT_REASSOC_REQ
,
823 MANAGEMENT_REASSOC_RESP
,
824 MANAGEMENT_PROBE_REQ
,
825 MANAGEMENT_PROBE_RESP
,
834 /* control statistics */
835 enum iwl_ctrl_stats
{
836 CONTROL_BACK_REQ
= 0,
847 struct traffic_stats
{
848 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
849 u32 mgmt
[MANAGEMENT_MAX
];
850 u32 ctrl
[CONTROL_MAX
];
857 * iwl_switch_rxon: "channel switch" structure
859 * @ switch_in_progress: channel switch in progress
860 * @ channel: new channel
862 struct iwl_switch_rxon
{
863 bool switch_in_progress
;
868 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
869 * to perform continuous uCode event logging operation if enabled
871 #define UCODE_TRACE_PERIOD (100)
874 * iwl_event_log: current uCode event log position
876 * @ucode_trace: enable/disable ucode continuous trace timer
877 * @num_wraps: how many times the event buffer wraps
878 * @next_entry: the entry just before the next one that uCode would fill
879 * @non_wraps_count: counter for no wrap detected when dump ucode events
880 * @wraps_once_count: counter for wrap once detected when dump ucode events
881 * @wraps_more_count: counter for wrap more than once detected
882 * when dump ucode events
884 struct iwl_event_log
{
889 int wraps_once_count
;
890 int wraps_more_count
;
894 * host interrupt timeout value
895 * used with setting interrupt coalescing timer
896 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
898 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
899 * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
901 #define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
902 #define IWL_HOST_INT_TIMEOUT_DEF (0x40)
903 #define IWL_HOST_INT_TIMEOUT_MIN (0x0)
904 #define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
905 #define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
906 #define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
909 * This is the threshold value of plcp error rate per 100mSecs. It is
910 * used to set and check for the validity of plcp_delta.
912 #define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
913 #define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
914 #define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
915 #define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
916 #define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
917 #define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
919 #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
920 #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
922 /* TX queue watchdog timeouts in mSecs */
923 #define IWL_DEF_WD_TIMEOUT (2000)
924 #define IWL_LONG_WD_TIMEOUT (10000)
925 #define IWL_MAX_WD_TIMEOUT (120000)
933 struct iwl_force_reset
{
934 int reset_request_count
;
935 int reset_success_count
;
936 int reset_reject_count
;
937 unsigned long reset_duration
;
938 unsigned long last_force_reset_jiffies
;
941 /* extend beacon time format bit shifting */
944 * bits 31:24 - extended
945 * bits 23:0 - interval
947 #define IWL3945_EXT_BEACON_TIME_POS 24
950 * bits 31:22 - extended
951 * bits 21:0 - interval
953 #define IWL4965_EXT_BEACON_TIME_POS 22
955 enum iwl_rxon_context_id
{
961 struct iwl_rxon_context
{
962 struct ieee80211_vif
*vif
;
964 const u8
*ac_to_fifo
;
965 const u8
*ac_to_queue
;
969 * We could use the vif to indicate active, but we
970 * also need it to be active during disabling when
971 * we already removed the vif for type setting.
973 bool always_active
, is_active
;
975 bool ht_need_multiple_chains
;
977 enum iwl_rxon_context_id ctxid
;
979 u32 interface_modes
, exclusive_interface_modes
;
980 u8 unused_devtype
, ap_devtype
, ibss_devtype
, station_devtype
;
983 * We declare this const so it can only be
984 * changed via explicit cast within the
985 * routines that actually update the physical
988 const struct iwl_legacy_rxon_cmd active
;
989 struct iwl_legacy_rxon_cmd staging
;
991 struct iwl_rxon_time_cmd timing
;
993 struct iwl_qos_info qos_data
;
995 u8 bcast_sta_id
, ap_sta_id
;
997 u8 rxon_cmd
, rxon_assoc_cmd
, rxon_timing_cmd
;
1001 struct iwl_wep_key wep_keys
[WEP_KEYS_MAX
];
1002 u8 key_mapping_keys
;
1004 __le32 station_flags
;
1007 bool non_gf_sta_present
;
1009 bool enabled
, is_40mhz
;
1010 u8 extension_chan_offset
;
1016 /* ieee device used by generic ieee processing code */
1017 struct ieee80211_hw
*hw
;
1018 struct ieee80211_channel
*ieee_channels
;
1019 struct ieee80211_rate
*ieee_rates
;
1020 struct iwl_cfg
*cfg
;
1022 /* temporary frame storage list */
1023 struct list_head free_frames
;
1026 enum ieee80211_band band
;
1029 void (*rx_handlers
[REPLY_MAX
])(struct iwl_priv
*priv
,
1030 struct iwl_rx_mem_buffer
*rxb
);
1032 struct ieee80211_supported_band bands
[IEEE80211_NUM_BANDS
];
1034 /* spectrum measurement report caching */
1035 struct iwl_spectrum_notification measure_report
;
1036 u8 measurement_status
;
1038 /* ucode beacon time */
1039 u32 ucode_beacon_time
;
1040 int missed_beacon_threshold
;
1042 /* track IBSS manager (last beacon) status */
1045 /* storing the jiffies when the plcp error rate is received */
1046 unsigned long plcp_jiffies
;
1049 struct iwl_force_reset force_reset
[IWL_MAX_FORCE_RESET
];
1051 /* we allocate array of iwl_channel_info for NIC's valid channels.
1052 * Access via channel # using indirect index array */
1053 struct iwl_channel_info
*channel_info
; /* channel info array */
1054 u8 channel_count
; /* # of channels */
1056 /* thermal calibration */
1057 s32 temperature
; /* degrees Kelvin */
1058 s32 last_temperature
;
1060 /* init calibration results */
1061 struct iwl_calib_result calib_results
[IWL_CALIB_MAX
];
1063 /* Scan related variables */
1064 unsigned long scan_start
;
1065 unsigned long scan_start_tsf
;
1067 enum ieee80211_band scan_band
;
1068 struct cfg80211_scan_request
*scan_request
;
1069 struct ieee80211_vif
*scan_vif
;
1070 bool is_internal_short_scan
;
1071 u8 scan_tx_ant
[IEEE80211_NUM_BANDS
];
1075 spinlock_t lock
; /* protect general shared data */
1076 spinlock_t hcmd_lock
; /* protect hcmd */
1077 spinlock_t reg_lock
; /* protect hw register access */
1079 struct mutex sync_cmd_mutex
; /* enable serialization of sync commands */
1081 /* basic pci-network driver stuff */
1082 struct pci_dev
*pci_dev
;
1084 /* pci hardware address support */
1085 void __iomem
*hw_base
;
1090 /* microcode/device supports multiple contexts */
1093 /* command queue number */
1096 /* max number of station keys */
1099 /* EEPROM MAC addresses */
1100 struct mac_address addresses
[1];
1102 /* uCode images, save to reload in case of failure */
1103 int fw_index
; /* firmware we're trying to load */
1104 u32 ucode_ver
; /* version of ucode, copy of
1106 struct fw_desc ucode_code
; /* runtime inst */
1107 struct fw_desc ucode_data
; /* runtime data original */
1108 struct fw_desc ucode_data_backup
; /* runtime data save/restore */
1109 struct fw_desc ucode_init
; /* initialization inst */
1110 struct fw_desc ucode_init_data
; /* initialization data */
1111 struct fw_desc ucode_boot
; /* bootstrap inst */
1112 enum ucode_type ucode_type
;
1113 u8 ucode_write_complete
; /* the image write is complete */
1114 char firmware_name
[25];
1116 struct iwl_rxon_context contexts
[NUM_IWL_RXON_CTX
];
1118 struct iwl_switch_rxon switch_rxon
;
1120 /* 1st responses from initialize and runtime uCode images.
1121 * _4965's initialize alive response contains some calibration data. */
1122 struct iwl_init_alive_resp card_alive_init
;
1123 struct iwl_alive_resp card_alive
;
1128 struct iwl_sensitivity_data sensitivity_data
;
1129 struct iwl_chain_noise_data chain_noise_data
;
1130 __le16 sensitivity_tbl
[HD_TABLE_SIZE
];
1132 struct iwl_ht_config current_ht_config
;
1134 /* Rate scaling data */
1137 wait_queue_head_t wait_command_queue
;
1139 int activity_timer_active
;
1141 /* Rx and Tx DMA processing queues */
1142 struct iwl_rx_queue rxq
;
1143 struct iwl_tx_queue
*txq
;
1144 unsigned long txq_ctx_active_msk
;
1145 struct iwl_dma_ptr kw
; /* keep warm address */
1146 struct iwl_dma_ptr scd_bc_tbls
;
1148 u32 scd_base_addr
; /* scheduler sram base address */
1150 unsigned long status
;
1152 /* counts mgmt, ctl, and data packets */
1153 struct traffic_stats tx_stats
;
1154 struct traffic_stats rx_stats
;
1156 /* counts interrupts */
1157 struct isr_statistics isr_stats
;
1159 struct iwl_power_mgr power_data
;
1161 /* context information */
1162 u8 bssid
[ETH_ALEN
]; /* used only on 3945 but filled by core */
1164 /* station table variables */
1166 /* Note: if lock and sta_lock are needed, lock must be acquired first */
1167 spinlock_t sta_lock
;
1169 struct iwl_station_entry stations
[IWL_STATION_COUNT
];
1170 unsigned long ucode_key_table
;
1172 /* queue refcounts */
1173 #define IWL_MAX_HW_QUEUES 32
1174 unsigned long queue_stopped
[BITS_TO_LONGS(IWL_MAX_HW_QUEUES
)];
1176 atomic_t queue_stop_count
[4];
1178 /* Indication if ieee80211_ops->open has been called */
1181 u8 mac80211_registered
;
1183 /* eeprom -- this is in the card's little endian byte order */
1185 struct iwl_eeprom_calib_info
*calib_info
;
1187 enum nl80211_iftype iw_mode
;
1189 /* Last Rx'd beacon timestamp */
1193 #if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
1196 dma_addr_t shared_phys
;
1198 struct delayed_work thermal_periodic
;
1199 struct delayed_work rfkill_poll
;
1201 struct iwl3945_notif_statistics statistics
;
1202 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
1203 struct iwl3945_notif_statistics accum_statistics
;
1204 struct iwl3945_notif_statistics delta_statistics
;
1205 struct iwl3945_notif_statistics max_delta
;
1209 int last_rx_rssi
; /* From Rx packet statistics */
1211 /* Rx'd packet timing information */
1212 u32 last_beacon_time
;
1216 * each calibration channel group in the
1217 * EEPROM has a derived clip setting for
1220 const struct iwl3945_clip_group clip_groups
[5];
1224 #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE)
1227 * reporting the number of tids has AGG on. 0 means
1232 struct iwl_rx_phy_res last_phy_res
;
1233 bool last_phy_res_valid
;
1235 struct completion firmware_loading_complete
;
1238 * chain noise reset and gain commands are the
1239 * two extra calibration commands follows the standard
1240 * phy calibration commands
1242 u8 phy_calib_chain_noise_reset_cmd
;
1243 u8 phy_calib_chain_noise_gain_cmd
;
1245 struct iwl_notif_statistics statistics
;
1246 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
1247 struct iwl_notif_statistics accum_statistics
;
1248 struct iwl_notif_statistics delta_statistics
;
1249 struct iwl_notif_statistics max_delta
;
1256 struct iwl_hw_params hw_params
;
1260 struct workqueue_struct
*workqueue
;
1262 struct work_struct restart
;
1263 struct work_struct scan_completed
;
1264 struct work_struct rx_replenish
;
1265 struct work_struct abort_scan
;
1267 struct iwl_rxon_context
*beacon_ctx
;
1268 struct sk_buff
*beacon_skb
;
1270 struct work_struct start_internal_scan
;
1271 struct work_struct tx_flush
;
1273 struct tasklet_struct irq_tasklet
;
1275 struct delayed_work init_alive_start
;
1276 struct delayed_work alive_start
;
1277 struct delayed_work scan_check
;
1280 s8 tx_power_user_lmt
;
1281 s8 tx_power_device_lmt
;
1285 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1286 /* debugging info */
1287 u32 debug_level
; /* per device debugging will override global
1288 iwlegacy_debug_level if set */
1289 #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */
1290 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
1296 struct dentry
*debugfs_dir
;
1297 u32 dbgfs_sram_offset
, dbgfs_sram_len
;
1299 #endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */
1301 struct work_struct txpower_work
;
1302 u32 disable_sens_cal
;
1303 u32 disable_chain_noise_cal
;
1304 u32 disable_tx_power_cal
;
1305 struct work_struct run_time_calib_work
;
1306 struct timer_list statistics_periodic
;
1307 struct timer_list ucode_trace
;
1308 struct timer_list watchdog
;
1311 struct iwl_event_log event_log
;
1313 struct led_classdev led
;
1314 unsigned long blink_on
, blink_off
;
1315 bool led_registered
;
1318 static inline void iwl_txq_ctx_activate(struct iwl_priv
*priv
, int txq_id
)
1320 set_bit(txq_id
, &priv
->txq_ctx_active_msk
);
1323 static inline void iwl_txq_ctx_deactivate(struct iwl_priv
*priv
, int txq_id
)
1325 clear_bit(txq_id
, &priv
->txq_ctx_active_msk
);
1328 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
1330 * iwl_legacy_get_debug_level: Return active debug level for device
1332 * Using sysfs it is possible to set per device debug level. This debug
1333 * level will be used if set, otherwise the global debug level which can be
1334 * set via module parameter is used.
1336 static inline u32
iwl_legacy_get_debug_level(struct iwl_priv
*priv
)
1338 if (priv
->debug_level
)
1339 return priv
->debug_level
;
1341 return iwlegacy_debug_level
;
1344 static inline u32
iwl_legacy_get_debug_level(struct iwl_priv
*priv
)
1346 return iwlegacy_debug_level
;
1351 static inline struct ieee80211_hdr
*
1352 iwl_legacy_tx_queue_get_hdr(struct iwl_priv
*priv
,
1353 int txq_id
, int idx
)
1355 if (priv
->txq
[txq_id
].txb
[idx
].skb
)
1356 return (struct ieee80211_hdr
*)priv
->txq
[txq_id
].
1361 static inline struct iwl_rxon_context
*
1362 iwl_legacy_rxon_ctx_from_vif(struct ieee80211_vif
*vif
)
1364 struct iwl_vif_priv
*vif_priv
= (void *)vif
->drv_priv
;
1366 return vif_priv
->ctx
;
1369 #define for_each_context(priv, ctx) \
1370 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
1371 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
1372 if (priv->valid_contexts & BIT(ctx->ctxid))
1374 static inline int iwl_legacy_is_associated(struct iwl_priv
*priv
,
1375 enum iwl_rxon_context_id ctxid
)
1377 return (priv
->contexts
[ctxid
].active
.filter_flags
&
1378 RXON_FILTER_ASSOC_MSK
) ? 1 : 0;
1381 static inline int iwl_legacy_is_any_associated(struct iwl_priv
*priv
)
1383 return iwl_legacy_is_associated(priv
, IWL_RXON_CTX_BSS
);
1386 static inline int iwl_legacy_is_associated_ctx(struct iwl_rxon_context
*ctx
)
1388 return (ctx
->active
.filter_flags
& RXON_FILTER_ASSOC_MSK
) ? 1 : 0;
1391 static inline int iwl_legacy_is_channel_valid(const struct iwl_channel_info
*ch_info
)
1393 if (ch_info
== NULL
)
1395 return (ch_info
->flags
& EEPROM_CHANNEL_VALID
) ? 1 : 0;
1398 static inline int iwl_legacy_is_channel_radar(const struct iwl_channel_info
*ch_info
)
1400 return (ch_info
->flags
& EEPROM_CHANNEL_RADAR
) ? 1 : 0;
1403 static inline u8
iwl_legacy_is_channel_a_band(const struct iwl_channel_info
*ch_info
)
1405 return ch_info
->band
== IEEE80211_BAND_5GHZ
;
1409 iwl_legacy_is_channel_passive(const struct iwl_channel_info
*ch
)
1411 return (!(ch
->flags
& EEPROM_CHANNEL_ACTIVE
)) ? 1 : 0;
1415 __iwl_legacy_free_pages(struct iwl_priv
*priv
, struct page
*page
)
1417 __free_pages(page
, priv
->hw_params
.rx_page_order
);
1418 priv
->alloc_rxb_page
--;
1421 static inline void iwl_legacy_free_pages(struct iwl_priv
*priv
, unsigned long page
)
1423 free_pages(page
, priv
->hw_params
.rx_page_order
);
1424 priv
->alloc_rxb_page
--;
1426 #endif /* __iwl_legacy_dev_h__ */