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),
293 CMD_MAPPED
= (1 << 3),
296 #define DEF_CMD_PAYLOAD_SIZE 320
299 * struct iwl_device_cmd
301 * For allocation of the command and tx queues, this establishes the overall
302 * size of the largest command we send to uCode, except for a scan command
303 * (which is relatively huge; space is allocated separately).
305 struct iwl_device_cmd
{
306 struct iwl_cmd_header hdr
; /* uCode API */
312 struct iwl_tx_cmd tx
;
313 u8 payload
[DEF_CMD_PAYLOAD_SIZE
];
317 #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
320 struct iwl_host_cmd
{
322 unsigned long reply_page
;
323 void (*callback
)(struct iwl_priv
*priv
,
324 struct iwl_device_cmd
*cmd
,
325 struct iwl_rx_packet
*pkt
);
331 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
332 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
333 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
336 * struct iwl_rx_queue - Rx queue
337 * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
338 * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
339 * @read: Shared index to newest available Rx buffer
340 * @write: Shared index to oldest written Rx packet
341 * @free_count: Number of pre-allocated buffers in rx_free
342 * @rx_free: list of free SKBs for use
343 * @rx_used: List of Rx buffers with no SKB
344 * @need_update: flag to indicate we need to update read/write index
345 * @rb_stts: driver's pointer to receive buffer status
346 * @rb_stts_dma: bus address of receive buffer status
348 * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
350 struct iwl_rx_queue
{
353 struct iwl_rx_mem_buffer pool
[RX_QUEUE_SIZE
+ RX_FREE_BUFFERS
];
354 struct iwl_rx_mem_buffer
*queue
[RX_QUEUE_SIZE
];
359 struct list_head rx_free
;
360 struct list_head rx_used
;
362 struct iwl_rb_status
*rb_stts
;
363 dma_addr_t rb_stts_dma
;
367 #define IWL_SUPPORTED_RATES_IE_LEN 8
369 #define MAX_TID_COUNT 9
371 #define IWL_INVALID_RATE 0xFF
372 #define IWL_INVALID_VALUE -1
375 * struct iwl_ht_agg -- aggregation status while waiting for block-ack
376 * @txq_id: Tx queue used for Tx attempt
377 * @frame_count: # frames attempted by Tx command
378 * @wait_for_ba: Expect block-ack before next Tx reply
379 * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
380 * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
381 * @bitmap1: High order, one bit for each frame pending ACK in Tx window
382 * @rate_n_flags: Rate at which Tx was attempted
384 * If REPLY_TX indicates that aggregation was attempted, driver must wait
385 * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
386 * until block ack arrives.
395 #define IWL_AGG_OFF 0
397 #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
398 #define IWL_EMPTYING_HW_QUEUE_DELBA 3
403 struct iwl_tid_data
{
404 u16 seq_number
; /* 4965 only */
406 struct iwl_ht_agg agg
;
416 union iwl_ht_rate_supp
{
424 #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
425 #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
426 #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
427 #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
428 #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
429 #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
430 #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
433 * Maximal MPDU density for TX aggregation
439 #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
440 #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
441 #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
442 #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
443 #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
444 #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
445 #define CFG_HT_MPDU_DENSITY_MIN (0x1)
447 struct iwl_ht_config
{
448 bool single_chain_sufficient
;
449 enum ieee80211_smps_mode smps
; /* current smps mode */
453 struct iwl_qos_info
{
455 struct iwl_qosparam_cmd def_qos_parm
;
459 * Structure should be accessed with sta_lock held. When station addition
460 * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only
461 * the commands (iwl_legacy_addsta_cmd and iwl_link_quality_cmd) without
464 struct iwl_station_entry
{
465 struct iwl_legacy_addsta_cmd sta
;
466 struct iwl_tid_data tid
[MAX_TID_COUNT
];
468 struct iwl_hw_key keyinfo
;
469 struct iwl_link_quality_cmd
*lq
;
472 struct iwl_station_priv_common
{
473 struct iwl_rxon_context
*ctx
;
478 * iwl_station_priv: Driver's private station information
480 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
481 * in the structure for use by driver. This structure is places in that
484 * The common struct MUST be first because it is shared between
487 struct iwl_station_priv
{
488 struct iwl_station_priv_common common
;
489 struct iwl_lq_sta lq_sta
;
490 atomic_t pending_frames
;
496 * struct iwl_vif_priv - driver's private per-interface information
498 * When mac80211 allocates a virtual interface, it can allocate
499 * space for us to put data into.
501 struct iwl_vif_priv
{
502 struct iwl_rxon_context
*ctx
;
503 u8 ibss_bssid_sta_id
;
506 /* one for each uCode image (inst/data, boot/init/runtime) */
508 void *v_addr
; /* access by driver */
509 dma_addr_t p_addr
; /* access by card's busmaster DMA */
513 /* uCode file layout */
514 struct iwl_ucode_header
{
515 __le32 ver
; /* major/minor/API/serial */
517 __le32 inst_size
; /* bytes of runtime code */
518 __le32 data_size
; /* bytes of runtime data */
519 __le32 init_size
; /* bytes of init code */
520 __le32 init_data_size
; /* bytes of init data */
521 __le32 boot_size
; /* bytes of bootstrap code */
522 u8 data
[0]; /* in same order as sizes */
526 struct iwl4965_ibss_seq
{
530 unsigned long packet_time
;
531 struct list_head list
;
534 struct iwl_sensitivity_ranges
{
541 u16 auto_corr_min_ofdm
;
542 u16 auto_corr_min_ofdm_mrc
;
543 u16 auto_corr_min_ofdm_x1
;
544 u16 auto_corr_min_ofdm_mrc_x1
;
546 u16 auto_corr_max_ofdm
;
547 u16 auto_corr_max_ofdm_mrc
;
548 u16 auto_corr_max_ofdm_x1
;
549 u16 auto_corr_max_ofdm_mrc_x1
;
551 u16 auto_corr_max_cck
;
552 u16 auto_corr_max_cck_mrc
;
553 u16 auto_corr_min_cck
;
554 u16 auto_corr_min_cck_mrc
;
556 u16 barker_corr_th_min
;
557 u16 barker_corr_th_min_mrc
;
562 #define KELVIN_TO_CELSIUS(x) ((x)-273)
563 #define CELSIUS_TO_KELVIN(x) ((x)+273)
567 * struct iwl_hw_params
568 * @max_txq_num: Max # Tx queues supported
569 * @dma_chnl_num: Number of Tx DMA/FIFO channels
570 * @scd_bc_tbls_size: size of scheduler byte count tables
571 * @tfd_size: TFD size
572 * @tx/rx_chains_num: Number of TX/RX chains
573 * @valid_tx/rx_ant: usable antennas
574 * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
575 * @max_rxq_log: Log-base-2 of max_rxq_size
576 * @rx_page_order: Rx buffer page order
577 * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
579 * @ht40_channel: is 40MHz width possible in band 2.4
580 * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
581 * @sw_crypto: 0 for hw, 1 for sw
582 * @max_xxx_size: for ucode uses
583 * @ct_kill_threshold: temperature threshold
584 * @beacon_time_tsf_bits: number of valid tsf bits for beacon time
585 * @struct iwl_sensitivity_ranges: range of sensitivity values
587 struct iwl_hw_params
{
590 u16 scd_bc_tbls_size
;
602 u8 max_beacon_itrvl
; /* in 1024 ms */
606 u32 ct_kill_threshold
; /* value in hw-dependent units */
607 u16 beacon_time_tsf_bits
;
608 const struct iwl_sensitivity_ranges
*sens
;
612 /******************************************************************************
614 * Functions implemented in core module which are forward declared here
615 * for use by iwl-[4-5].c
617 * NOTE: The implementation of these functions are not hardware specific
618 * which is why they are in the core module files.
620 * Naming convention --
621 * iwl_ <-- Is part of iwlwifi
622 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
623 * iwl4965_bg_ <-- Called from work queue context
624 * iwl4965_mac_ <-- mac80211 callback
626 ****************************************************************************/
627 extern void iwl4965_update_chain_flags(struct iwl_priv
*priv
);
628 extern const u8 iwlegacy_bcast_addr
[ETH_ALEN
];
629 extern int iwl_legacy_queue_space(const struct iwl_queue
*q
);
630 static inline int iwl_legacy_queue_used(const struct iwl_queue
*q
, int i
)
632 return q
->write_ptr
>= q
->read_ptr
?
633 (i
>= q
->read_ptr
&& i
< q
->write_ptr
) :
634 !(i
< q
->read_ptr
&& i
>= q
->write_ptr
);
638 static inline u8
iwl_legacy_get_cmd_index(struct iwl_queue
*q
, u32 index
,
642 * This is for init calibration result and scan command which
643 * required buffer > TFD_MAX_PAYLOAD_SIZE,
644 * the big buffer at end of command array
647 return q
->n_window
; /* must be power of 2 */
649 /* Otherwise, use normal size buffers */
650 return index
& (q
->n_window
- 1);
660 #define IWL_OPERATION_MODE_AUTO 0
661 #define IWL_OPERATION_MODE_HT_ONLY 1
662 #define IWL_OPERATION_MODE_MIXED 2
663 #define IWL_OPERATION_MODE_20MHZ 3
665 #define IWL_TX_CRC_SIZE 4
666 #define IWL_TX_DELIMITER_SIZE 4
668 #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
670 /* Sensitivity and chain noise calibration */
671 #define INITIALIZATION_VALUE 0xFFFF
672 #define IWL4965_CAL_NUM_BEACONS 20
673 #define IWL_CAL_NUM_BEACONS 16
674 #define MAXIMUM_ALLOWED_PATHLOSS 15
676 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
678 #define MAX_FA_OFDM 50
679 #define MIN_FA_OFDM 5
680 #define MAX_FA_CCK 50
683 #define AUTO_CORR_STEP_OFDM 1
685 #define AUTO_CORR_STEP_CCK 3
686 #define AUTO_CORR_MAX_TH_CCK 160
689 #define NRG_STEP_CCK 2
691 #define MAX_NUMBER_CCK_NO_FA 100
693 #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
698 #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
699 #define ALL_BAND_FILTER 0xFF00
700 #define IN_BAND_FILTER 0xFF
701 #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
703 #define NRG_NUM_PREV_STAT_L 20
704 #define NUM_RX_CHAINS 3
706 enum iwl4965_false_alarm_state
{
709 IWL_FA_GOOD_RANGE
= 2,
712 enum iwl4965_chain_noise_state
{
713 IWL_CHAIN_NOISE_ALIVE
= 0, /* must be 0 */
714 IWL_CHAIN_NOISE_ACCUMULATE
,
715 IWL_CHAIN_NOISE_CALIBRATED
,
716 IWL_CHAIN_NOISE_DONE
,
719 enum iwl4965_calib_enabled_state
{
720 IWL_CALIB_DISABLED
= 0, /* must be 0 */
721 IWL_CALIB_ENABLED
= 1,
726 * defines the order in which results of initial calibrations
727 * should be sent to the runtime uCode
733 /* Opaque calibration results */
734 struct iwl_calib_result
{
745 /* Sensitivity calib data */
746 struct iwl_sensitivity_data
{
748 u32 auto_corr_ofdm_mrc
;
749 u32 auto_corr_ofdm_x1
;
750 u32 auto_corr_ofdm_mrc_x1
;
752 u32 auto_corr_cck_mrc
;
754 u32 last_bad_plcp_cnt_ofdm
;
755 u32 last_fa_cnt_ofdm
;
756 u32 last_bad_plcp_cnt_cck
;
762 u8 nrg_silence_rssi
[NRG_NUM_PREV_STAT_L
];
767 s32 nrg_auto_corr_silence_diff
;
768 u32 num_in_cck_no_fa
;
771 u16 barker_corr_th_min
;
772 u16 barker_corr_th_min_mrc
;
776 /* Chain noise (differential Rx gain) calib data */
777 struct iwl_chain_noise_data
{
786 u8 disconn_array
[NUM_RX_CHAINS
];
787 u8 delta_gain_code
[NUM_RX_CHAINS
];
792 #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
793 #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
795 #define IWL_TRAFFIC_ENTRIES (256)
796 #define IWL_TRAFFIC_ENTRY_SIZE (64)
799 MEASUREMENT_READY
= (1 << 0),
800 MEASUREMENT_ACTIVE
= (1 << 1),
803 /* interrupt statistics */
804 struct isr_statistics
{
814 u32 rx_handlers
[REPLY_MAX
];
819 /* management statistics */
820 enum iwl_mgmt_stats
{
821 MANAGEMENT_ASSOC_REQ
= 0,
822 MANAGEMENT_ASSOC_RESP
,
823 MANAGEMENT_REASSOC_REQ
,
824 MANAGEMENT_REASSOC_RESP
,
825 MANAGEMENT_PROBE_REQ
,
826 MANAGEMENT_PROBE_RESP
,
835 /* control statistics */
836 enum iwl_ctrl_stats
{
837 CONTROL_BACK_REQ
= 0,
848 struct traffic_stats
{
849 #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS
850 u32 mgmt
[MANAGEMENT_MAX
];
851 u32 ctrl
[CONTROL_MAX
];
858 * iwl_switch_rxon: "channel switch" structure
860 * @ switch_in_progress: channel switch in progress
861 * @ channel: new channel
863 struct iwl_switch_rxon
{
864 bool switch_in_progress
;
869 * schedule the timer to wake up every UCODE_TRACE_PERIOD milliseconds
870 * to perform continuous uCode event logging operation if enabled
872 #define UCODE_TRACE_PERIOD (100)
875 * iwl_event_log: current uCode event log position
877 * @ucode_trace: enable/disable ucode continuous trace timer
878 * @num_wraps: how many times the event buffer wraps
879 * @next_entry: the entry just before the next one that uCode would fill
880 * @non_wraps_count: counter for no wrap detected when dump ucode events
881 * @wraps_once_count: counter for wrap once detected when dump ucode events
882 * @wraps_more_count: counter for wrap more than once detected
883 * when dump ucode events
885 struct iwl_event_log
{
890 int wraps_once_count
;
891 int wraps_more_count
;
895 * host interrupt timeout value
896 * used with setting interrupt coalescing timer
897 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
899 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
900 * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
902 #define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
903 #define IWL_HOST_INT_TIMEOUT_DEF (0x40)
904 #define IWL_HOST_INT_TIMEOUT_MIN (0x0)
905 #define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
906 #define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
907 #define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
910 * This is the threshold value of plcp error rate per 100mSecs. It is
911 * used to set and check for the validity of plcp_delta.
913 #define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (1)
914 #define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
915 #define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
916 #define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
917 #define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
918 #define IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE (0)
920 #define IWL_DELAY_NEXT_FORCE_RF_RESET (HZ*3)
921 #define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
923 /* TX queue watchdog timeouts in mSecs */
924 #define IWL_DEF_WD_TIMEOUT (2000)
925 #define IWL_LONG_WD_TIMEOUT (10000)
926 #define IWL_MAX_WD_TIMEOUT (120000)
934 struct iwl_force_reset
{
935 int reset_request_count
;
936 int reset_success_count
;
937 int reset_reject_count
;
938 unsigned long reset_duration
;
939 unsigned long last_force_reset_jiffies
;
942 /* extend beacon time format bit shifting */
945 * bits 31:24 - extended
946 * bits 23:0 - interval
948 #define IWL3945_EXT_BEACON_TIME_POS 24
951 * bits 31:22 - extended
952 * bits 21:0 - interval
954 #define IWL4965_EXT_BEACON_TIME_POS 22
956 enum iwl_rxon_context_id
{
962 struct iwl_rxon_context
{
963 struct ieee80211_vif
*vif
;
965 const u8
*ac_to_fifo
;
966 const u8
*ac_to_queue
;
970 * We could use the vif to indicate active, but we
971 * also need it to be active during disabling when
972 * we already removed the vif for type setting.
974 bool always_active
, is_active
;
976 bool ht_need_multiple_chains
;
978 enum iwl_rxon_context_id ctxid
;
980 u32 interface_modes
, exclusive_interface_modes
;
981 u8 unused_devtype
, ap_devtype
, ibss_devtype
, station_devtype
;
984 * We declare this const so it can only be
985 * changed via explicit cast within the
986 * routines that actually update the physical
989 const struct iwl_legacy_rxon_cmd active
;
990 struct iwl_legacy_rxon_cmd staging
;
992 struct iwl_rxon_time_cmd timing
;
994 struct iwl_qos_info qos_data
;
996 u8 bcast_sta_id
, ap_sta_id
;
998 u8 rxon_cmd
, rxon_assoc_cmd
, rxon_timing_cmd
;
1002 struct iwl_wep_key wep_keys
[WEP_KEYS_MAX
];
1003 u8 key_mapping_keys
;
1005 __le32 station_flags
;
1008 bool non_gf_sta_present
;
1010 bool enabled
, is_40mhz
;
1011 u8 extension_chan_offset
;
1017 /* ieee device used by generic ieee processing code */
1018 struct ieee80211_hw
*hw
;
1019 struct ieee80211_channel
*ieee_channels
;
1020 struct ieee80211_rate
*ieee_rates
;
1021 struct iwl_cfg
*cfg
;
1023 /* temporary frame storage list */
1024 struct list_head free_frames
;
1027 enum ieee80211_band band
;
1030 void (*rx_handlers
[REPLY_MAX
])(struct iwl_priv
*priv
,
1031 struct iwl_rx_mem_buffer
*rxb
);
1033 struct ieee80211_supported_band bands
[IEEE80211_NUM_BANDS
];
1035 /* spectrum measurement report caching */
1036 struct iwl_spectrum_notification measure_report
;
1037 u8 measurement_status
;
1039 /* ucode beacon time */
1040 u32 ucode_beacon_time
;
1041 int missed_beacon_threshold
;
1043 /* track IBSS manager (last beacon) status */
1046 /* storing the jiffies when the plcp error rate is received */
1047 unsigned long plcp_jiffies
;
1050 struct iwl_force_reset force_reset
[IWL_MAX_FORCE_RESET
];
1052 /* we allocate array of iwl_channel_info for NIC's valid channels.
1053 * Access via channel # using indirect index array */
1054 struct iwl_channel_info
*channel_info
; /* channel info array */
1055 u8 channel_count
; /* # of channels */
1057 /* thermal calibration */
1058 s32 temperature
; /* degrees Kelvin */
1059 s32 last_temperature
;
1061 /* init calibration results */
1062 struct iwl_calib_result calib_results
[IWL_CALIB_MAX
];
1064 /* Scan related variables */
1065 unsigned long scan_start
;
1066 unsigned long scan_start_tsf
;
1068 enum ieee80211_band scan_band
;
1069 struct cfg80211_scan_request
*scan_request
;
1070 struct ieee80211_vif
*scan_vif
;
1071 bool is_internal_short_scan
;
1072 u8 scan_tx_ant
[IEEE80211_NUM_BANDS
];
1076 spinlock_t lock
; /* protect general shared data */
1077 spinlock_t hcmd_lock
; /* protect hcmd */
1078 spinlock_t reg_lock
; /* protect hw register access */
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_is_channel_ibss(const struct iwl_channel_info
*ch
)
1417 return (ch
->flags
& EEPROM_CHANNEL_IBSS
) ? 1 : 0;
1421 __iwl_legacy_free_pages(struct iwl_priv
*priv
, struct page
*page
)
1423 __free_pages(page
, priv
->hw_params
.rx_page_order
);
1424 priv
->alloc_rxb_page
--;
1427 static inline void iwl_legacy_free_pages(struct iwl_priv
*priv
, unsigned long page
)
1429 free_pages(page
, priv
->hw_params
.rx_page_order
);
1430 priv
->alloc_rxb_page
--;
1432 #endif /* __iwl_legacy_dev_h__ */