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 *****************************************************************************/
29 #include <linux/interrupt.h>
30 #include <linux/pci.h> /* for struct pci_device_id */
31 #include <linux/kernel.h>
32 #include <linux/leds.h>
33 #include <linux/wait.h>
34 #include <net/ieee80211_radiotap.h>
36 #include "iwl-eeprom.h"
39 #include "iwl-debug.h"
41 #include "iwl-power.h"
47 #define RX_QUEUE_SIZE 256
48 #define RX_QUEUE_MASK 255
49 #define RX_QUEUE_SIZE_LOG 8
52 * RX related structures and functions
54 #define RX_FREE_BUFFERS 64
55 #define RX_LOW_WATERMARK 8
57 #define U32_PAD(n) ((4-(n))&0x3)
59 /* CT-KILL constants */
60 #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
62 /* Default noise level to report when noise measurement is not available.
63 * This may be because we're:
64 * 1) Not associated (4965, no beacon stats being sent to driver)
65 * 2) Scanning (noise measurement does not apply to associated channel)
66 * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
67 * Use default noise value of -127 ... this is below the range of measurable
68 * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
69 * Also, -127 works better than 0 when averaging frames with/without
70 * noise info (e.g. averaging might be done in app); measured dBm values are
71 * always negative ... using a negative value as the default keeps all
72 * averages within an s8's (used in some apps) range of negative values. */
73 #define IL_NOISE_MEAS_NOT_AVAILABLE (-127)
76 * RTS threshold here is total size [2347] minus 4 FCS bytes
78 * a value of 0 means RTS on all data/management packets
79 * a value > max MSDU size means no RTS
80 * else RTS for data/management frames where MPDU is larger
83 #define DEFAULT_RTS_THRESHOLD 2347U
84 #define MIN_RTS_THRESHOLD 0U
85 #define MAX_RTS_THRESHOLD 2347U
86 #define MAX_MSDU_SIZE 2304U
87 #define MAX_MPDU_SIZE 2346U
88 #define DEFAULT_BEACON_INTERVAL 100U
89 #define DEFAULT_SHORT_RETRY_LIMIT 7U
90 #define DEFAULT_LONG_RETRY_LIMIT 4U
95 struct list_head list
;
98 #define rxb_addr(r) page_address(r->page)
101 struct il_device_cmd
;
104 /* only for SYNC commands, iff the reply skb is wanted */
105 struct il_host_cmd
*source
;
107 * only for ASYNC commands
108 * (which is somewhat stupid -- look at common.c for instance
109 * which duplicates a bunch of code because the callback isn't
110 * invoked for SYNC commands, if it were and its result passed
111 * through it would be simpler...)
113 void (*callback
)(struct il_priv
*il
,
114 struct il_device_cmd
*cmd
,
115 struct il_rx_pkt
*pkt
);
117 /* The CMD_SIZE_HUGE flag bit indicates that the command
118 * structure is stored at the end of the shared queue memory. */
121 DEFINE_DMA_UNMAP_ADDR(mapping
);
122 DEFINE_DMA_UNMAP_LEN(len
);
126 * Generic queue structure
128 * Contains common data for Rx and Tx queues
131 int n_bd
; /* number of BDs in this queue */
132 int write_ptr
; /* 1-st empty entry (idx) host_w*/
133 int read_ptr
; /* last used entry (idx) host_r*/
134 /* use for monitoring and recovering the stuck queue */
135 dma_addr_t dma_addr
; /* physical addr for BD's */
136 int n_win
; /* safe queue win */
138 int low_mark
; /* low watermark, resume queue if free
139 * space more than this */
140 int high_mark
; /* high watermark, stop queue if free
141 * space less than this */
144 /* One for each TFD */
147 struct il_rxon_context
*ctx
;
151 * struct il_tx_queue - Tx Queue for DMA
152 * @q: generic Rx/Tx queue descriptor
153 * @bd: base of circular buffer of TFDs
154 * @cmd: array of command/TX buffer pointers
155 * @meta: array of meta data for each command/tx buffer
156 * @dma_addr_cmd: physical address of cmd/tx buffer array
157 * @txb: array of per-TFD driver data
158 * @time_stamp: time (in jiffies) of last read_ptr change
159 * @need_update: indicates need to update read/write idx
160 * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
162 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
163 * descriptors) and required locking structures.
165 #define TFD_TX_CMD_SLOTS 256
166 #define TFD_CMD_SLOTS 32
171 struct il_device_cmd
**cmd
;
172 struct il_cmd_meta
*meta
;
173 struct il_tx_info
*txb
;
174 unsigned long time_stamp
;
181 #define IL_NUM_SCAN_RATES (2)
183 struct il4965_channel_tgd_info
{
188 struct il4965_channel_tgh_info
{
192 #define IL4965_MAX_RATE (33)
194 struct il3945_clip_group
{
195 /* maximum power level to prevent clipping for each rate, derived by
196 * us from this band's saturation power in EEPROM */
197 const s8 clip_powers
[IL_MAX_RATES
];
200 /* current Tx power values to use, one for each rate for each channel.
201 * requested power is limited by:
202 * -- regulatory EEPROM limits for this channel
203 * -- hardware capabilities (clip-powers)
204 * -- spectrum management
205 * -- user preference (e.g. iwconfig)
206 * when requested power is set, base power idx must also be set. */
207 struct il3945_channel_power_info
{
208 struct il3945_tx_power tpc
; /* actual radio and DSP gain settings */
209 s8 power_table_idx
; /* actual (compenst'd) idx into gain table */
210 s8 base_power_idx
; /* gain idx for power at factory temp. */
211 s8 requested_power
; /* power (dBm) requested for this chnl/rate */
214 /* current scan Tx power values to use, one for each scan rate for each
216 struct il3945_scan_power_info
{
217 struct il3945_tx_power tpc
; /* actual radio and DSP gain settings */
218 s8 power_table_idx
; /* actual (compenst'd) idx into gain table */
219 s8 requested_power
; /* scan pwr (dBm) requested for chnl/rate */
223 * One for each channel, holds all channel setup data
224 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
227 struct il_channel_info
{
228 struct il4965_channel_tgd_info tgd
;
229 struct il4965_channel_tgh_info tgh
;
230 struct il_eeprom_channel eeprom
; /* EEPROM regulatory limit */
231 struct il_eeprom_channel ht40_eeprom
; /* EEPROM regulatory limit for
234 u8 channel
; /* channel number */
235 u8 flags
; /* flags copied from EEPROM */
236 s8 max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
237 s8 curr_txpow
; /* (dBm) regulatory/spectrum/user (not h/w) limit */
238 s8 min_power
; /* always 0 */
239 s8 scan_power
; /* (dBm) regul. eeprom, direct scans, any rate */
241 u8 group_idx
; /* 0-4, maps channel to group1/2/3/4/5 */
242 u8 band_idx
; /* 0-4, maps channel to band1/2/3/4/5 */
243 enum ieee80211_band band
;
245 /* HT40 channel info */
246 s8 ht40_max_power_avg
; /* (dBm) regul. eeprom, normal Tx, any rate */
247 u8 ht40_flags
; /* flags copied from EEPROM */
248 u8 ht40_extension_channel
; /* HT_IE_EXT_CHANNEL_* */
250 /* Radio/DSP gain settings for each "normal" data Tx rate.
251 * These include, in addition to RF and DSP gain, a few fields for
252 * remembering/modifying gain settings (idxes). */
253 struct il3945_channel_power_info power_info
[IL4965_MAX_RATE
];
255 /* Radio/DSP gain settings for each scan rate, for directed scans. */
256 struct il3945_scan_power_info scan_pwr_info
[IL_NUM_SCAN_RATES
];
259 #define IL_TX_FIFO_BK 0 /* shared */
260 #define IL_TX_FIFO_BE 1
261 #define IL_TX_FIFO_VI 2 /* shared */
262 #define IL_TX_FIFO_VO 3
263 #define IL_TX_FIFO_UNUSED -1
265 /* Minimum number of queues. MAX_NUM is defined in hw specific files.
266 * Set the minimum to accommodate the 4 standard TX queues, 1 command
267 * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
268 #define IL_MIN_NUM_QUEUES 10
270 #define IL_DEFAULT_CMD_QUEUE_NUM 4
272 #define IEEE80211_DATA_LEN 2304
273 #define IEEE80211_4ADDR_LEN 30
274 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
275 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
279 struct ieee80211_hdr frame
;
280 struct il_tx_beacon_cmd beacon
;
281 u8 raw
[IEEE80211_FRAME_LEN
];
284 struct list_head list
;
287 #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
288 #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
289 #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
295 CMD_SIZE_HUGE
= (1 << 0),
296 CMD_ASYNC
= (1 << 1),
297 CMD_WANT_SKB
= (1 << 2),
298 CMD_MAPPED
= (1 << 3),
301 #define DEF_CMD_PAYLOAD_SIZE 320
304 * struct il_device_cmd
306 * For allocation of the command and tx queues, this establishes the overall
307 * size of the largest command we send to uCode, except for a scan command
308 * (which is relatively huge; space is allocated separately).
310 struct il_device_cmd
{
311 struct il_cmd_header hdr
; /* uCode API */
318 u8 payload
[DEF_CMD_PAYLOAD_SIZE
];
322 #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd))
327 unsigned long reply_page
;
328 void (*callback
)(struct il_priv
*il
,
329 struct il_device_cmd
*cmd
,
330 struct il_rx_pkt
*pkt
);
336 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
337 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
338 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
341 * struct il_rx_queue - Rx queue
342 * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
343 * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
344 * @read: Shared idx to newest available Rx buffer
345 * @write: Shared idx to oldest written Rx packet
346 * @free_count: Number of pre-allocated buffers in rx_free
347 * @rx_free: list of free SKBs for use
348 * @rx_used: List of Rx buffers with no SKB
349 * @need_update: flag to indicate we need to update read/write idx
350 * @rb_stts: driver's pointer to receive buffer status
351 * @rb_stts_dma: bus address of receive buffer status
353 * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs
358 struct il_rx_buf pool
[RX_QUEUE_SIZE
+ RX_FREE_BUFFERS
];
359 struct il_rx_buf
*queue
[RX_QUEUE_SIZE
];
364 struct list_head rx_free
;
365 struct list_head rx_used
;
367 struct il_rb_status
*rb_stts
;
368 dma_addr_t rb_stts_dma
;
372 #define IL_SUPPORTED_RATES_IE_LEN 8
374 #define MAX_TID_COUNT 9
376 #define IL_INVALID_RATE 0xFF
377 #define IL_INVALID_VALUE -1
380 * struct il_ht_agg -- aggregation status while waiting for block-ack
381 * @txq_id: Tx queue used for Tx attempt
382 * @frame_count: # frames attempted by Tx command
383 * @wait_for_ba: Expect block-ack before next Tx reply
384 * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win
385 * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win
386 * @bitmap1: High order, one bit for each frame pending ACK in Tx win
387 * @rate_n_flags: Rate at which Tx was attempted
389 * If C_TX indicates that aggregation was attempted, driver must wait
390 * for block ack (N_COMPRESSED_BA). This struct stores tx reply info
391 * until block ack arrives.
402 #define IL_EMPTYING_HW_QUEUE_ADDBA 2
403 #define IL_EMPTYING_HW_QUEUE_DELBA 3
409 u16 seq_number
; /* 4965 only */
411 struct il_ht_agg agg
;
421 union il_ht_rate_supp
{
429 #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
430 #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
431 #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
432 #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
433 #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
434 #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
435 #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
438 * Maximal MPDU density for TX aggregation
444 #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
445 #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
446 #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
447 #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
448 #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
449 #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
450 #define CFG_HT_MPDU_DENSITY_MIN (0x1)
452 struct il_ht_config
{
453 bool single_chain_sufficient
;
454 enum ieee80211_smps_mode smps
; /* current smps mode */
460 struct il_qosparam_cmd def_qos_parm
;
464 * Structure should be accessed with sta_lock held. When station addition
465 * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only
466 * the commands (il_addsta_cmd and il_link_quality_cmd) without
469 struct il_station_entry
{
470 struct il_addsta_cmd sta
;
471 struct il_tid_data tid
[MAX_TID_COUNT
];
473 struct il_hw_key keyinfo
;
474 struct il_link_quality_cmd
*lq
;
477 struct il_station_priv_common
{
478 struct il_rxon_context
*ctx
;
483 * struct il_vif_priv - driver's ilate per-interface information
485 * When mac80211 allocates a virtual interface, it can allocate
486 * space for us to put data into.
489 struct il_rxon_context
*ctx
;
490 u8 ibss_bssid_sta_id
;
493 /* one for each uCode image (inst/data, boot/init/runtime) */
495 void *v_addr
; /* access by driver */
496 dma_addr_t p_addr
; /* access by card's busmaster DMA */
500 /* uCode file layout */
501 struct il_ucode_header
{
502 __le32 ver
; /* major/minor/API/serial */
504 __le32 inst_size
; /* bytes of runtime code */
505 __le32 data_size
; /* bytes of runtime data */
506 __le32 init_size
; /* bytes of init code */
507 __le32 init_data_size
; /* bytes of init data */
508 __le32 boot_size
; /* bytes of bootstrap code */
509 u8 data
[0]; /* in same order as sizes */
513 struct il4965_ibss_seq
{
517 unsigned long packet_time
;
518 struct list_head list
;
521 struct il_sensitivity_ranges
{
528 u16 auto_corr_min_ofdm
;
529 u16 auto_corr_min_ofdm_mrc
;
530 u16 auto_corr_min_ofdm_x1
;
531 u16 auto_corr_min_ofdm_mrc_x1
;
533 u16 auto_corr_max_ofdm
;
534 u16 auto_corr_max_ofdm_mrc
;
535 u16 auto_corr_max_ofdm_x1
;
536 u16 auto_corr_max_ofdm_mrc_x1
;
538 u16 auto_corr_max_cck
;
539 u16 auto_corr_max_cck_mrc
;
540 u16 auto_corr_min_cck
;
541 u16 auto_corr_min_cck_mrc
;
543 u16 barker_corr_th_min
;
544 u16 barker_corr_th_min_mrc
;
549 #define KELVIN_TO_CELSIUS(x) ((x)-273)
550 #define CELSIUS_TO_KELVIN(x) ((x)+273)
554 * struct il_hw_params
555 * @max_txq_num: Max # Tx queues supported
556 * @dma_chnl_num: Number of Tx DMA/FIFO channels
557 * @scd_bc_tbls_size: size of scheduler byte count tables
558 * @tfd_size: TFD size
559 * @tx/rx_chains_num: Number of TX/RX chains
560 * @valid_tx/rx_ant: usable antennas
561 * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
562 * @max_rxq_log: Log-base-2 of max_rxq_size
563 * @rx_page_order: Rx buffer page order
564 * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
566 * @ht40_channel: is 40MHz width possible in band 2.4
567 * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
568 * @sw_crypto: 0 for hw, 1 for sw
569 * @max_xxx_size: for ucode uses
570 * @ct_kill_threshold: temperature threshold
571 * @beacon_time_tsf_bits: number of valid tsf bits for beacon time
572 * @struct il_sensitivity_ranges: range of sensitivity values
574 struct il_hw_params
{
577 u16 scd_bc_tbls_size
;
589 u8 max_beacon_itrvl
; /* in 1024 ms */
593 u32 ct_kill_threshold
; /* value in hw-dependent units */
594 u16 beacon_time_tsf_bits
;
595 const struct il_sensitivity_ranges
*sens
;
599 /******************************************************************************
601 * Functions implemented in core module which are forward declared here
602 * for use by iwl-[4-5].c
604 * NOTE: The implementation of these functions are not hardware specific
605 * which is why they are in the core module files.
607 * Naming convention --
608 * il_ <-- Is part of iwlwifi
609 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
610 * il4965_bg_ <-- Called from work queue context
611 * il4965_mac_ <-- mac80211 callback
613 ****************************************************************************/
614 extern void il4965_update_chain_flags(struct il_priv
*il
);
615 extern const u8 il_bcast_addr
[ETH_ALEN
];
616 extern int il_queue_space(const struct il_queue
*q
);
617 static inline int il_queue_used(const struct il_queue
*q
, int i
)
619 return q
->write_ptr
>= q
->read_ptr
?
620 (i
>= q
->read_ptr
&& i
< q
->write_ptr
) :
621 !(i
< q
->read_ptr
&& i
>= q
->write_ptr
);
625 static inline u8
il_get_cmd_idx(struct il_queue
*q
, u32 idx
,
629 * This is for init calibration result and scan command which
630 * required buffer > TFD_MAX_PAYLOAD_SIZE,
631 * the big buffer at end of command array
634 return q
->n_win
; /* must be power of 2 */
636 /* Otherwise, use normal size buffers */
637 return idx
& (q
->n_win
- 1);
647 #define IL_OPERATION_MODE_AUTO 0
648 #define IL_OPERATION_MODE_HT_ONLY 1
649 #define IL_OPERATION_MODE_MIXED 2
650 #define IL_OPERATION_MODE_20MHZ 3
652 #define IL_TX_CRC_SIZE 4
653 #define IL_TX_DELIMITER_SIZE 4
655 #define TX_POWER_IL_ILLEGAL_VOLTAGE -10000
657 /* Sensitivity and chain noise calibration */
658 #define INITIALIZATION_VALUE 0xFFFF
659 #define IL4965_CAL_NUM_BEACONS 20
660 #define IL_CAL_NUM_BEACONS 16
661 #define MAXIMUM_ALLOWED_PATHLOSS 15
663 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
665 #define MAX_FA_OFDM 50
666 #define MIN_FA_OFDM 5
667 #define MAX_FA_CCK 50
670 #define AUTO_CORR_STEP_OFDM 1
672 #define AUTO_CORR_STEP_CCK 3
673 #define AUTO_CORR_MAX_TH_CCK 160
676 #define NRG_STEP_CCK 2
678 #define MAX_NUMBER_CCK_NO_FA 100
680 #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
685 #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
686 #define ALL_BAND_FILTER 0xFF00
687 #define IN_BAND_FILTER 0xFF
688 #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
690 #define NRG_NUM_PREV_STAT_L 20
691 #define NUM_RX_CHAINS 3
693 enum il4965_false_alarm_state
{
696 IL_FA_GOOD_RANGE
= 2,
699 enum il4965_chain_noise_state
{
700 IL_CHAIN_NOISE_ALIVE
= 0, /* must be 0 */
701 IL_CHAIN_NOISE_ACCUMULATE
,
702 IL_CHAIN_NOISE_CALIBRATED
,
706 enum il4965_calib_enabled_state
{
707 IL_CALIB_DISABLED
= 0, /* must be 0 */
708 IL_CALIB_ENABLED
= 1,
713 * defines the order in which results of initial calibrations
714 * should be sent to the runtime uCode
720 /* Opaque calibration results */
721 struct il_calib_result
{
732 /* Sensitivity calib data */
733 struct il_sensitivity_data
{
735 u32 auto_corr_ofdm_mrc
;
736 u32 auto_corr_ofdm_x1
;
737 u32 auto_corr_ofdm_mrc_x1
;
739 u32 auto_corr_cck_mrc
;
741 u32 last_bad_plcp_cnt_ofdm
;
742 u32 last_fa_cnt_ofdm
;
743 u32 last_bad_plcp_cnt_cck
;
749 u8 nrg_silence_rssi
[NRG_NUM_PREV_STAT_L
];
754 s32 nrg_auto_corr_silence_diff
;
755 u32 num_in_cck_no_fa
;
758 u16 barker_corr_th_min
;
759 u16 barker_corr_th_min_mrc
;
763 /* Chain noise (differential Rx gain) calib data */
764 struct il_chain_noise_data
{
773 u8 disconn_array
[NUM_RX_CHAINS
];
774 u8 delta_gain_code
[NUM_RX_CHAINS
];
779 #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
780 #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
782 #define IL_TRAFFIC_ENTRIES (256)
783 #define IL_TRAFFIC_ENTRY_SIZE (64)
786 MEASUREMENT_READY
= (1 << 0),
787 MEASUREMENT_ACTIVE
= (1 << 1),
790 /* interrupt stats */
801 u32 handlers
[IL_CN_MAX
];
806 /* management stats */
808 MANAGEMENT_ASSOC_REQ
= 0,
809 MANAGEMENT_ASSOC_RESP
,
810 MANAGEMENT_REASSOC_REQ
,
811 MANAGEMENT_REASSOC_RESP
,
812 MANAGEMENT_PROBE_REQ
,
813 MANAGEMENT_PROBE_RESP
,
824 CONTROL_BACK_REQ
= 0,
835 struct traffic_stats
{
836 #ifdef CONFIG_IWLEGACY_DEBUGFS
837 u32 mgmt
[MANAGEMENT_MAX
];
838 u32 ctrl
[CONTROL_MAX
];
845 * host interrupt timeout value
846 * used with setting interrupt coalescing timer
847 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
849 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
850 * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
852 #define IL_HOST_INT_TIMEOUT_MAX (0xFF)
853 #define IL_HOST_INT_TIMEOUT_DEF (0x40)
854 #define IL_HOST_INT_TIMEOUT_MIN (0x0)
855 #define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
856 #define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
857 #define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
859 #define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
861 /* TX queue watchdog timeouts in mSecs */
862 #define IL_DEF_WD_TIMEOUT (2000)
863 #define IL_LONG_WD_TIMEOUT (10000)
864 #define IL_MAX_WD_TIMEOUT (120000)
866 struct il_force_reset
{
867 int reset_request_count
;
868 int reset_success_count
;
869 int reset_reject_count
;
870 unsigned long reset_duration
;
871 unsigned long last_force_reset_jiffies
;
874 /* extend beacon time format bit shifting */
877 * bits 31:24 - extended
878 * bits 23:0 - interval
880 #define IL3945_EXT_BEACON_TIME_POS 24
883 * bits 31:22 - extended
884 * bits 21:0 - interval
886 #define IL4965_EXT_BEACON_TIME_POS 22
888 struct il_rxon_context
{
889 struct ieee80211_vif
*vif
;
891 const u8
*ac_to_fifo
;
892 const u8
*ac_to_queue
;
896 * We could use the vif to indicate active, but we
897 * also need it to be active during disabling when
898 * we already removed the vif for type setting.
900 bool always_active
, is_active
;
902 bool ht_need_multiple_chains
;
906 u32 interface_modes
, exclusive_interface_modes
;
907 u8 unused_devtype
, ap_devtype
, ibss_devtype
, station_devtype
;
910 * We declare this const so it can only be
911 * changed via explicit cast within the
912 * routines that actually update the physical
915 const struct il_rxon_cmd active
;
916 struct il_rxon_cmd staging
;
918 struct il_rxon_time_cmd timing
;
920 struct il_qos_info qos_data
;
922 u8 bcast_sta_id
, ap_sta_id
;
924 u8 rxon_cmd
, rxon_assoc_cmd
, rxon_timing_cmd
;
928 struct il_wep_key wep_keys
[WEP_KEYS_MAX
];
931 __le32 station_flags
;
934 bool non_gf_sta_present
;
936 bool enabled
, is_40mhz
;
937 u8 extension_chan_offset
;
943 /* ieee device used by generic ieee processing code */
944 struct ieee80211_hw
*hw
;
945 struct ieee80211_channel
*ieee_channels
;
946 struct ieee80211_rate
*ieee_rates
;
949 /* temporary frame storage list */
950 struct list_head free_frames
;
953 enum ieee80211_band band
;
956 void (*handlers
[IL_CN_MAX
])(struct il_priv
*il
,
957 struct il_rx_buf
*rxb
);
959 struct ieee80211_supported_band bands
[IEEE80211_NUM_BANDS
];
961 /* spectrum measurement report caching */
962 struct il_spectrum_notification measure_report
;
963 u8 measurement_status
;
965 /* ucode beacon time */
966 u32 ucode_beacon_time
;
967 int missed_beacon_threshold
;
969 /* track IBSS manager (last beacon) status */
973 struct il_force_reset force_reset
;
975 /* we allocate array of il_channel_info for NIC's valid channels.
976 * Access via channel # using indirect idx array */
977 struct il_channel_info
*channel_info
; /* channel info array */
978 u8 channel_count
; /* # of channels */
980 /* thermal calibration */
981 s32 temperature
; /* degrees Kelvin */
982 s32 last_temperature
;
984 /* init calibration results */
985 struct il_calib_result calib_results
[IL_CALIB_MAX
];
987 /* Scan related variables */
988 unsigned long scan_start
;
989 unsigned long scan_start_tsf
;
991 enum ieee80211_band scan_band
;
992 struct cfg80211_scan_request
*scan_request
;
993 struct ieee80211_vif
*scan_vif
;
994 u8 scan_tx_ant
[IEEE80211_NUM_BANDS
];
998 spinlock_t lock
; /* protect general shared data */
999 spinlock_t hcmd_lock
; /* protect hcmd */
1000 spinlock_t reg_lock
; /* protect hw register access */
1003 /* basic pci-network driver stuff */
1004 struct pci_dev
*pci_dev
;
1006 /* pci hardware address support */
1007 void __iomem
*hw_base
;
1012 /* command queue number */
1015 /* max number of station keys */
1018 /* EEPROM MAC addresses */
1019 struct mac_address addresses
[1];
1021 /* uCode images, save to reload in case of failure */
1022 int fw_idx
; /* firmware we're trying to load */
1023 u32 ucode_ver
; /* version of ucode, copy of
1025 struct fw_desc ucode_code
; /* runtime inst */
1026 struct fw_desc ucode_data
; /* runtime data original */
1027 struct fw_desc ucode_data_backup
; /* runtime data save/restore */
1028 struct fw_desc ucode_init
; /* initialization inst */
1029 struct fw_desc ucode_init_data
; /* initialization data */
1030 struct fw_desc ucode_boot
; /* bootstrap inst */
1031 enum ucode_type ucode_type
;
1032 u8 ucode_write_complete
; /* the image write is complete */
1033 char firmware_name
[25];
1035 struct il_rxon_context ctx
;
1037 __le16 switch_channel
;
1039 /* 1st responses from initialize and runtime uCode images.
1040 * _4965's initialize alive response contains some calibration data. */
1041 struct il_init_alive_resp card_alive_init
;
1042 struct il_alive_resp card_alive
;
1047 struct il_sensitivity_data sensitivity_data
;
1048 struct il_chain_noise_data chain_noise_data
;
1049 __le16 sensitivity_tbl
[HD_TBL_SIZE
];
1051 struct il_ht_config current_ht_config
;
1053 /* Rate scaling data */
1056 wait_queue_head_t wait_command_queue
;
1058 int activity_timer_active
;
1060 /* Rx and Tx DMA processing queues */
1061 struct il_rx_queue rxq
;
1062 struct il_tx_queue
*txq
;
1063 unsigned long txq_ctx_active_msk
;
1064 struct il_dma_ptr kw
; /* keep warm address */
1065 struct il_dma_ptr scd_bc_tbls
;
1067 u32 scd_base_addr
; /* scheduler sram base address */
1069 unsigned long status
;
1071 /* counts mgmt, ctl, and data packets */
1072 struct traffic_stats tx_stats
;
1073 struct traffic_stats rx_stats
;
1075 /* counts interrupts */
1076 struct isr_stats isr_stats
;
1078 struct il_power_mgr power_data
;
1080 /* context information */
1081 u8 bssid
[ETH_ALEN
]; /* used only on 3945 but filled by core */
1083 /* station table variables */
1085 /* Note: if lock and sta_lock are needed, lock must be acquired first */
1086 spinlock_t sta_lock
;
1088 struct il_station_entry stations
[IL_STATION_COUNT
];
1089 unsigned long ucode_key_table
;
1091 /* queue refcounts */
1092 #define IL_MAX_HW_QUEUES 32
1093 unsigned long queue_stopped
[BITS_TO_LONGS(IL_MAX_HW_QUEUES
)];
1095 atomic_t queue_stop_count
[4];
1097 /* Indication if ieee80211_ops->open has been called */
1100 u8 mac80211_registered
;
1102 /* eeprom -- this is in the card's little endian byte order */
1104 struct il_eeprom_calib_info
*calib_info
;
1106 enum nl80211_iftype iw_mode
;
1108 /* Last Rx'd beacon timestamp */
1112 #if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
1115 dma_addr_t shared_phys
;
1117 struct delayed_work thermal_periodic
;
1118 struct delayed_work rfkill_poll
;
1120 struct il3945_notif_stats stats
;
1121 #ifdef CONFIG_IWLEGACY_DEBUGFS
1122 struct il3945_notif_stats accum_stats
;
1123 struct il3945_notif_stats delta_stats
;
1124 struct il3945_notif_stats max_delta
;
1128 int last_rx_rssi
; /* From Rx packet stats */
1130 /* Rx'd packet timing information */
1131 u32 last_beacon_time
;
1135 * each calibration channel group in the
1136 * EEPROM has a derived clip setting for
1139 const struct il3945_clip_group clip_groups
[5];
1143 #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE)
1145 struct il_rx_phy_res last_phy_res
;
1146 bool last_phy_res_valid
;
1148 struct completion firmware_loading_complete
;
1151 * chain noise reset and gain commands are the
1152 * two extra calibration commands follows the standard
1153 * phy calibration commands
1155 u8 phy_calib_chain_noise_reset_cmd
;
1156 u8 phy_calib_chain_noise_gain_cmd
;
1158 struct il_notif_stats stats
;
1159 #ifdef CONFIG_IWLEGACY_DEBUGFS
1160 struct il_notif_stats accum_stats
;
1161 struct il_notif_stats delta_stats
;
1162 struct il_notif_stats max_delta
;
1169 struct il_hw_params hw_params
;
1173 struct workqueue_struct
*workqueue
;
1175 struct work_struct restart
;
1176 struct work_struct scan_completed
;
1177 struct work_struct rx_replenish
;
1178 struct work_struct abort_scan
;
1180 struct il_rxon_context
*beacon_ctx
;
1181 struct sk_buff
*beacon_skb
;
1183 struct work_struct tx_flush
;
1185 struct tasklet_struct irq_tasklet
;
1187 struct delayed_work init_alive_start
;
1188 struct delayed_work alive_start
;
1189 struct delayed_work scan_check
;
1192 s8 tx_power_user_lmt
;
1193 s8 tx_power_device_lmt
;
1197 #ifdef CONFIG_IWLEGACY_DEBUG
1198 /* debugging info */
1199 u32 debug_level
; /* per device debugging will override global
1200 il_debug_level if set */
1201 #endif /* CONFIG_IWLEGACY_DEBUG */
1202 #ifdef CONFIG_IWLEGACY_DEBUGFS
1208 struct dentry
*debugfs_dir
;
1209 u32 dbgfs_sram_offset
, dbgfs_sram_len
;
1211 #endif /* CONFIG_IWLEGACY_DEBUGFS */
1213 struct work_struct txpower_work
;
1214 u32 disable_sens_cal
;
1215 u32 disable_chain_noise_cal
;
1216 u32 disable_tx_power_cal
;
1217 struct work_struct run_time_calib_work
;
1218 struct timer_list stats_periodic
;
1219 struct timer_list watchdog
;
1222 struct led_classdev led
;
1223 unsigned long blink_on
, blink_off
;
1224 bool led_registered
;
1227 static inline void il_txq_ctx_activate(struct il_priv
*il
, int txq_id
)
1229 set_bit(txq_id
, &il
->txq_ctx_active_msk
);
1232 static inline void il_txq_ctx_deactivate(struct il_priv
*il
, int txq_id
)
1234 clear_bit(txq_id
, &il
->txq_ctx_active_msk
);
1237 #ifdef CONFIG_IWLEGACY_DEBUG
1239 * il_get_debug_level: Return active debug level for device
1241 * Using sysfs it is possible to set per device debug level. This debug
1242 * level will be used if set, otherwise the global debug level which can be
1243 * set via module parameter is used.
1245 static inline u32
il_get_debug_level(struct il_priv
*il
)
1247 if (il
->debug_level
)
1248 return il
->debug_level
;
1250 return il_debug_level
;
1253 static inline u32
il_get_debug_level(struct il_priv
*il
)
1255 return il_debug_level
;
1260 static inline struct ieee80211_hdr
*
1261 il_tx_queue_get_hdr(struct il_priv
*il
,
1262 int txq_id
, int idx
)
1264 if (il
->txq
[txq_id
].txb
[idx
].skb
)
1265 return (struct ieee80211_hdr
*)il
->txq
[txq_id
].
1270 static inline struct il_rxon_context
*
1271 il_rxon_ctx_from_vif(struct ieee80211_vif
*vif
)
1273 struct il_vif_priv
*vif_priv
= (void *)vif
->drv_priv
;
1275 return vif_priv
->ctx
;
1278 #define for_each_context(il, _ctx) \
1279 for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++)
1281 static inline int il_is_associated(struct il_priv
*il
)
1283 return (il
->ctx
.active
.filter_flags
& RXON_FILTER_ASSOC_MSK
) ? 1 : 0;
1286 static inline int il_is_any_associated(struct il_priv
*il
)
1288 return il_is_associated(il
);
1291 static inline int il_is_associated_ctx(struct il_rxon_context
*ctx
)
1293 return (ctx
->active
.filter_flags
& RXON_FILTER_ASSOC_MSK
) ? 1 : 0;
1296 static inline int il_is_channel_valid(const struct il_channel_info
*ch_info
)
1298 if (ch_info
== NULL
)
1300 return (ch_info
->flags
& EEPROM_CHANNEL_VALID
) ? 1 : 0;
1303 static inline int il_is_channel_radar(const struct il_channel_info
*ch_info
)
1305 return (ch_info
->flags
& EEPROM_CHANNEL_RADAR
) ? 1 : 0;
1308 static inline u8
il_is_channel_a_band(const struct il_channel_info
*ch_info
)
1310 return ch_info
->band
== IEEE80211_BAND_5GHZ
;
1314 il_is_channel_passive(const struct il_channel_info
*ch
)
1316 return (!(ch
->flags
& EEPROM_CHANNEL_ACTIVE
)) ? 1 : 0;
1320 il_is_channel_ibss(const struct il_channel_info
*ch
)
1322 return (ch
->flags
& EEPROM_CHANNEL_IBSS
) ? 1 : 0;
1326 __il_free_pages(struct il_priv
*il
, struct page
*page
)
1328 __free_pages(page
, il
->hw_params
.rx_page_order
);
1329 il
->alloc_rxb_page
--;
1332 static inline void il_free_pages(struct il_priv
*il
, unsigned long page
)
1334 free_pages(page
, il
->hw_params
.rx_page_order
);
1335 il
->alloc_rxb_page
--;
1338 #define IWLWIFI_VERSION "in-tree:"
1339 #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation"
1340 #define DRV_AUTHOR "<ilw@linux.intel.com>"
1342 #define IL_PCI_DEVICE(dev, subdev, cfg) \
1343 .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
1344 .subvendor = PCI_ANY_ID, .subdevice = (subdev), \
1345 .driver_data = (kernel_ulong_t)&(cfg)
1347 #define TIME_UNIT 1024
1349 #define IL_SKU_G 0x1
1350 #define IL_SKU_A 0x2
1351 #define IL_SKU_N 0x8
1353 #define IL_CMD(x) case x: return #x
1355 /* Size of one Rx buffer in host DRAM */
1356 #define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */
1357 #define IL_RX_BUF_SIZE_4K (4 * 1024)
1358 #define IL_RX_BUF_SIZE_8K (8 * 1024)
1360 struct il_hcmd_ops
{
1361 int (*rxon_assoc
)(struct il_priv
*il
, struct il_rxon_context
*ctx
);
1362 int (*commit_rxon
)(struct il_priv
*il
, struct il_rxon_context
*ctx
);
1363 void (*set_rxon_chain
)(struct il_priv
*il
,
1364 struct il_rxon_context
*ctx
);
1367 struct il_hcmd_utils_ops
{
1368 u16 (*get_hcmd_size
)(u8 cmd_id
, u16 len
);
1369 u16 (*build_addsta_hcmd
)(const struct il_addsta_cmd
*cmd
,
1371 int (*request_scan
)(struct il_priv
*il
, struct ieee80211_vif
*vif
);
1372 void (*post_scan
)(struct il_priv
*il
);
1376 int (*init
)(struct il_priv
*il
);
1377 void (*config
)(struct il_priv
*il
);
1380 struct il_debugfs_ops
{
1381 ssize_t (*rx_stats_read
)(struct file
*file
, char __user
*user_buf
,
1382 size_t count
, loff_t
*ppos
);
1383 ssize_t (*tx_stats_read
)(struct file
*file
, char __user
*user_buf
,
1384 size_t count
, loff_t
*ppos
);
1385 ssize_t (*general_stats_read
)(struct file
*file
, char __user
*user_buf
,
1386 size_t count
, loff_t
*ppos
);
1389 struct il_temp_ops
{
1390 void (*temperature
)(struct il_priv
*il
);
1394 /* set hw dependent parameters */
1395 int (*set_hw_params
)(struct il_priv
*il
);
1397 void (*txq_update_byte_cnt_tbl
)(struct il_priv
*il
,
1398 struct il_tx_queue
*txq
,
1400 int (*txq_attach_buf_to_tfd
)(struct il_priv
*il
,
1401 struct il_tx_queue
*txq
,
1403 u16 len
, u8 reset
, u8 pad
);
1404 void (*txq_free_tfd
)(struct il_priv
*il
,
1405 struct il_tx_queue
*txq
);
1406 int (*txq_init
)(struct il_priv
*il
,
1407 struct il_tx_queue
*txq
);
1408 /* setup Rx handler */
1409 void (*handler_setup
)(struct il_priv
*il
);
1410 /* alive notification after init uCode load */
1411 void (*init_alive_start
)(struct il_priv
*il
);
1412 /* check validity of rtc data address */
1413 int (*is_valid_rtc_data_addr
)(u32 addr
);
1414 /* 1st ucode load */
1415 int (*load_ucode
)(struct il_priv
*il
);
1417 void (*dump_nic_error_log
)(struct il_priv
*il
);
1418 int (*dump_fh
)(struct il_priv
*il
, char **buf
, bool display
);
1419 int (*set_channel_switch
)(struct il_priv
*il
,
1420 struct ieee80211_channel_switch
*ch_switch
);
1421 /* power management */
1422 struct il_apm_ops apm_ops
;
1425 int (*send_tx_power
) (struct il_priv
*il
);
1426 void (*update_chain_flags
)(struct il_priv
*il
);
1428 /* eeprom operations (as defined in iwl-eeprom.h) */
1429 struct il_eeprom_ops eeprom_ops
;
1432 struct il_temp_ops temp_ops
;
1434 struct il_debugfs_ops debugfs_ops
;
1439 int (*cmd
)(struct il_priv
*il
, struct il_led_cmd
*led_cmd
);
1442 struct il_legacy_ops
{
1443 void (*post_associate
)(struct il_priv
*il
);
1444 void (*config_ap
)(struct il_priv
*il
);
1445 /* station management */
1446 int (*update_bcast_stations
)(struct il_priv
*il
);
1447 int (*manage_ibss_station
)(struct il_priv
*il
,
1448 struct ieee80211_vif
*vif
, bool add
);
1452 const struct il_lib_ops
*lib
;
1453 const struct il_hcmd_ops
*hcmd
;
1454 const struct il_hcmd_utils_ops
*utils
;
1455 const struct il_led_ops
*led
;
1456 const struct il_nic_ops
*nic
;
1457 const struct il_legacy_ops
*legacy
;
1458 const struct ieee80211_ops
*ieee80211_ops
;
1461 struct il_mod_params
{
1462 int sw_crypto
; /* def: 0 = using hardware encryption */
1463 int disable_hw_scan
; /* def: 0 = use h/w scan */
1464 int num_of_queues
; /* def: HW dependent */
1465 int disable_11n
; /* def: 0 = 11n capabilities enabled */
1466 int amsdu_size_8K
; /* def: 1 = enable 8K amsdu size */
1467 int antenna
; /* def: 0 = both antennas (use diversity) */
1468 int restart_fw
; /* def: 1 = restart firmware */
1472 * @led_compensation: compensate on the led on/off time per HW according
1473 * to the deviation to achieve the desired led frequency.
1474 * The detail algorithm is described in iwl-led.c
1475 * @chain_noise_num_beacons: number of beacons used to compute chain noise
1476 * @wd_timeout: TX queues watchdog timeout
1477 * @temperature_kelvin: temperature report by uCode in kelvin
1478 * @ucode_tracing: support ucode continuous tracing
1479 * @sensitivity_calib_by_driver: driver has the capability to perform
1480 * sensitivity calibration operation
1481 * @chain_noise_calib_by_driver: driver has the capability to perform
1482 * chain noise calibration operation
1484 struct il_base_params
{
1486 int num_of_queues
; /* def: HW dependent */
1487 int num_of_ampdu_queues
;/* def: HW dependent */
1488 /* for il_apm_init() */
1493 u16 led_compensation
;
1494 int chain_noise_num_beacons
;
1495 unsigned int wd_timeout
;
1496 bool temperature_kelvin
;
1497 const bool ucode_tracing
;
1498 const bool sensitivity_calib_by_driver
;
1499 const bool chain_noise_calib_by_driver
;
1504 * @fw_name_pre: Firmware filename prefix. The api version and extension
1505 * (.ucode) will be added to filename before loading from disk. The
1506 * filename is constructed as fw_name_pre<api>.ucode.
1507 * @ucode_api_max: Highest version of uCode API supported by driver.
1508 * @ucode_api_min: Lowest version of uCode API supported by driver.
1509 * @scan_antennas: available antenna for scan operation
1510 * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off)
1512 * We enable the driver to be backward compatible wrt API version. The
1513 * driver specifies which APIs it supports (with @ucode_api_max being the
1514 * highest and @ucode_api_min the lowest). Firmware will only be loaded if
1515 * it has a supported API version. The firmware's API version will be
1516 * stored in @il_priv, enabling the driver to make runtime changes based
1517 * on firmware version used.
1520 * if (IL_UCODE_API(il->ucode_ver) >= 2) {
1521 * Driver interacts with Firmware API version >= 2.
1523 * Driver interacts with Firmware API version 1.
1526 * The ideal usage of this infrastructure is to treat a new ucode API
1527 * release as a new hardware revision. That is, through utilizing the
1528 * il_hcmd_utils_ops etc. we accommodate different command structures
1529 * and flows between hardware versions as well as their API
1534 /* params specific to an individual device within a device family */
1536 const char *fw_name_pre
;
1537 const unsigned int ucode_api_max
;
1538 const unsigned int ucode_api_min
;
1543 u16 eeprom_calib_ver
;
1544 const struct il_ops
*ops
;
1545 /* module based parameters which can be set from modprobe cmd */
1546 const struct il_mod_params
*mod_params
;
1547 /* params not likely to change within a device family */
1548 struct il_base_params
*base_params
;
1549 /* params likely to change within a device family */
1550 u8 scan_rx_antennas
[IEEE80211_NUM_BANDS
];
1551 enum il_led_mode led_mode
;
1554 /***************************
1556 ***************************/
1558 struct ieee80211_hw
*il_alloc_all(struct il_cfg
*cfg
);
1559 int il_mac_conf_tx(struct ieee80211_hw
*hw
,
1560 struct ieee80211_vif
*vif
, u16 queue
,
1561 const struct ieee80211_tx_queue_params
*params
);
1562 int il_mac_tx_last_beacon(struct ieee80211_hw
*hw
);
1563 void il_set_rxon_hwcrypto(struct il_priv
*il
,
1564 struct il_rxon_context
*ctx
,
1566 int il_check_rxon_cmd(struct il_priv
*il
,
1567 struct il_rxon_context
*ctx
);
1568 int il_full_rxon_required(struct il_priv
*il
,
1569 struct il_rxon_context
*ctx
);
1570 int il_set_rxon_channel(struct il_priv
*il
,
1571 struct ieee80211_channel
*ch
,
1572 struct il_rxon_context
*ctx
);
1573 void il_set_flags_for_band(struct il_priv
*il
,
1574 struct il_rxon_context
*ctx
,
1575 enum ieee80211_band band
,
1576 struct ieee80211_vif
*vif
);
1577 u8
il_get_single_channel_number(struct il_priv
*il
,
1578 enum ieee80211_band band
);
1579 void il_set_rxon_ht(struct il_priv
*il
,
1580 struct il_ht_config
*ht_conf
);
1581 bool il_is_ht40_tx_allowed(struct il_priv
*il
,
1582 struct il_rxon_context
*ctx
,
1583 struct ieee80211_sta_ht_cap
*ht_cap
);
1584 void il_connection_init_rx_config(struct il_priv
*il
,
1585 struct il_rxon_context
*ctx
);
1586 void il_set_rate(struct il_priv
*il
);
1587 int il_set_decrypted_flag(struct il_priv
*il
,
1588 struct ieee80211_hdr
*hdr
,
1590 struct ieee80211_rx_status
*stats
);
1591 void il_irq_handle_error(struct il_priv
*il
);
1592 int il_mac_add_interface(struct ieee80211_hw
*hw
,
1593 struct ieee80211_vif
*vif
);
1594 void il_mac_remove_interface(struct ieee80211_hw
*hw
,
1595 struct ieee80211_vif
*vif
);
1596 int il_mac_change_interface(struct ieee80211_hw
*hw
,
1597 struct ieee80211_vif
*vif
,
1598 enum nl80211_iftype newtype
, bool newp2p
);
1599 int il_alloc_txq_mem(struct il_priv
*il
);
1600 void il_txq_mem(struct il_priv
*il
);
1602 #ifdef CONFIG_IWLEGACY_DEBUGFS
1603 int il_alloc_traffic_mem(struct il_priv
*il
);
1604 void il_free_traffic_mem(struct il_priv
*il
);
1605 void il_reset_traffic_log(struct il_priv
*il
);
1606 void il_dbg_log_tx_data_frame(struct il_priv
*il
,
1607 u16 length
, struct ieee80211_hdr
*header
);
1608 void il_dbg_log_rx_data_frame(struct il_priv
*il
,
1609 u16 length
, struct ieee80211_hdr
*header
);
1610 const char *il_get_mgmt_string(int cmd
);
1611 const char *il_get_ctrl_string(int cmd
);
1612 void il_clear_traffic_stats(struct il_priv
*il
);
1613 void il_update_stats(struct il_priv
*il
, bool is_tx
, __le16 fc
,
1616 static inline int il_alloc_traffic_mem(struct il_priv
*il
)
1620 static inline void il_free_traffic_mem(struct il_priv
*il
)
1623 static inline void il_reset_traffic_log(struct il_priv
*il
)
1626 static inline void il_dbg_log_tx_data_frame(struct il_priv
*il
,
1627 u16 length
, struct ieee80211_hdr
*header
)
1630 static inline void il_dbg_log_rx_data_frame(struct il_priv
*il
,
1631 u16 length
, struct ieee80211_hdr
*header
)
1634 static inline void il_update_stats(struct il_priv
*il
, bool is_tx
,
1639 /*****************************************************
1641 * **************************************************/
1642 void il_hdl_pm_sleep(struct il_priv
*il
,
1643 struct il_rx_buf
*rxb
);
1644 void il_hdl_pm_debug_stats(struct il_priv
*il
,
1645 struct il_rx_buf
*rxb
);
1646 void il_hdl_error(struct il_priv
*il
,
1647 struct il_rx_buf
*rxb
);
1649 /*****************************************************
1651 ******************************************************/
1652 void il_cmd_queue_unmap(struct il_priv
*il
);
1653 void il_cmd_queue_free(struct il_priv
*il
);
1654 int il_rx_queue_alloc(struct il_priv
*il
);
1655 void il_rx_queue_update_write_ptr(struct il_priv
*il
,
1656 struct il_rx_queue
*q
);
1657 int il_rx_queue_space(const struct il_rx_queue
*q
);
1658 void il_tx_cmd_complete(struct il_priv
*il
,
1659 struct il_rx_buf
*rxb
);
1661 void il_hdl_spectrum_measurement(struct il_priv
*il
,
1662 struct il_rx_buf
*rxb
);
1663 void il_recover_from_stats(struct il_priv
*il
,
1664 struct il_rx_pkt
*pkt
);
1665 void il_chswitch_done(struct il_priv
*il
, bool is_success
);
1666 void il_hdl_csa(struct il_priv
*il
, struct il_rx_buf
*rxb
);
1670 /*****************************************************
1672 ******************************************************/
1673 void il_txq_update_write_ptr(struct il_priv
*il
,
1674 struct il_tx_queue
*txq
);
1675 int il_tx_queue_init(struct il_priv
*il
, struct il_tx_queue
*txq
,
1676 int slots_num
, u32 txq_id
);
1677 void il_tx_queue_reset(struct il_priv
*il
,
1678 struct il_tx_queue
*txq
,
1679 int slots_num
, u32 txq_id
);
1680 void il_tx_queue_unmap(struct il_priv
*il
, int txq_id
);
1681 void il_tx_queue_free(struct il_priv
*il
, int txq_id
);
1682 void il_setup_watchdog(struct il_priv
*il
);
1683 /*****************************************************
1685 ****************************************************/
1686 int il_set_tx_power(struct il_priv
*il
, s8 tx_power
, bool force
);
1688 /*******************************************************************************
1690 ******************************************************************************/
1692 u8
il_get_lowest_plcp(struct il_priv
*il
,
1693 struct il_rxon_context
*ctx
);
1695 /*******************************************************************************
1697 ******************************************************************************/
1698 void il_init_scan_params(struct il_priv
*il
);
1699 int il_scan_cancel(struct il_priv
*il
);
1700 int il_scan_cancel_timeout(struct il_priv
*il
, unsigned long ms
);
1701 void il_force_scan_end(struct il_priv
*il
);
1702 int il_mac_hw_scan(struct ieee80211_hw
*hw
,
1703 struct ieee80211_vif
*vif
,
1704 struct cfg80211_scan_request
*req
);
1705 void il_internal_short_hw_scan(struct il_priv
*il
);
1706 int il_force_reset(struct il_priv
*il
, bool external
);
1707 u16
il_fill_probe_req(struct il_priv
*il
,
1708 struct ieee80211_mgmt
*frame
,
1709 const u8
*ta
, const u8
*ie
, int ie_len
, int left
);
1710 void il_setup_rx_scan_handlers(struct il_priv
*il
);
1711 u16
il_get_active_dwell_time(struct il_priv
*il
,
1712 enum ieee80211_band band
,
1714 u16
il_get_passive_dwell_time(struct il_priv
*il
,
1715 enum ieee80211_band band
,
1716 struct ieee80211_vif
*vif
);
1717 void il_setup_scan_deferred_work(struct il_priv
*il
);
1718 void il_cancel_scan_deferred_work(struct il_priv
*il
);
1720 /* For faster active scanning, scan will move to the next channel if fewer than
1721 * PLCP_QUIET_THRESH packets are heard on this channel within
1722 * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell
1723 * time if it's a quiet channel (nothing responded to our probe, and there's
1724 * no other traffic).
1725 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
1726 #define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */
1727 #define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */
1729 #define IL_SCAN_CHECK_WATCHDOG (HZ * 7)
1731 /*****************************************************
1732 * S e n d i n g H o s t C o m m a n d s *
1733 *****************************************************/
1735 const char *il_get_cmd_string(u8 cmd
);
1736 int __must_check
il_send_cmd_sync(struct il_priv
*il
,
1737 struct il_host_cmd
*cmd
);
1738 int il_send_cmd(struct il_priv
*il
, struct il_host_cmd
*cmd
);
1739 int __must_check
il_send_cmd_pdu(struct il_priv
*il
, u8 id
,
1740 u16 len
, const void *data
);
1741 int il_send_cmd_pdu_async(struct il_priv
*il
, u8 id
, u16 len
,
1743 void (*callback
)(struct il_priv
*il
,
1744 struct il_device_cmd
*cmd
,
1745 struct il_rx_pkt
*pkt
));
1747 int il_enqueue_hcmd(struct il_priv
*il
, struct il_host_cmd
*cmd
);
1750 /*****************************************************
1752 *****************************************************/
1754 static inline u16
il_pcie_link_ctl(struct il_priv
*il
)
1758 pos
= pci_pcie_cap(il
->pci_dev
);
1759 pci_read_config_word(il
->pci_dev
, pos
+ PCI_EXP_LNKCTL
, &pci_lnk_ctl
);
1763 void il_bg_watchdog(unsigned long data
);
1764 u32
il_usecs_to_beacons(struct il_priv
*il
,
1765 u32 usec
, u32 beacon_interval
);
1766 __le32
il_add_beacon_time(struct il_priv
*il
, u32 base
,
1767 u32 addon
, u32 beacon_interval
);
1770 int il_pci_suspend(struct device
*device
);
1771 int il_pci_resume(struct device
*device
);
1772 extern const struct dev_pm_ops il_pm_ops
;
1774 #define IL_LEGACY_PM_OPS (&il_pm_ops)
1776 #else /* !CONFIG_PM */
1778 #define IL_LEGACY_PM_OPS NULL
1780 #endif /* !CONFIG_PM */
1782 /*****************************************************
1783 * Error Handling Debugging
1784 ******************************************************/
1785 void il4965_dump_nic_error_log(struct il_priv
*il
);
1786 #ifdef CONFIG_IWLEGACY_DEBUG
1787 void il_print_rx_config_cmd(struct il_priv
*il
,
1788 struct il_rxon_context
*ctx
);
1790 static inline void il_print_rx_config_cmd(struct il_priv
*il
,
1791 struct il_rxon_context
*ctx
)
1796 void il_clear_isr_stats(struct il_priv
*il
);
1798 /*****************************************************
1800 ******************************************************/
1801 int il_init_geos(struct il_priv
*il
);
1802 void il_free_geos(struct il_priv
*il
);
1804 /*************** DRIVER STATUS FUNCTIONS *****/
1806 #define S_HCMD_ACTIVE 0 /* host command in progress */
1807 /* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */
1808 #define S_INT_ENABLED 2
1809 #define S_RF_KILL_HW 3
1814 #define S_TEMPERATURE 8
1815 #define S_GEO_CONFIGURED 9
1816 #define S_EXIT_PENDING 10
1818 #define S_SCANNING 13
1819 #define S_SCAN_ABORTING 14
1820 #define S_SCAN_HW 15
1821 #define S_POWER_PMI 16
1822 #define S_FW_ERROR 17
1823 #define S_CHANNEL_SWITCH_PENDING 18
1825 static inline int il_is_ready(struct il_priv
*il
)
1827 /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
1828 * set but EXIT_PENDING is not */
1829 return test_bit(S_READY
, &il
->status
) &&
1830 test_bit(S_GEO_CONFIGURED
, &il
->status
) &&
1831 !test_bit(S_EXIT_PENDING
, &il
->status
);
1834 static inline int il_is_alive(struct il_priv
*il
)
1836 return test_bit(S_ALIVE
, &il
->status
);
1839 static inline int il_is_init(struct il_priv
*il
)
1841 return test_bit(S_INIT
, &il
->status
);
1844 static inline int il_is_rfkill_hw(struct il_priv
*il
)
1846 return test_bit(S_RF_KILL_HW
, &il
->status
);
1849 static inline int il_is_rfkill(struct il_priv
*il
)
1851 return il_is_rfkill_hw(il
);
1854 static inline int il_is_ctkill(struct il_priv
*il
)
1856 return test_bit(S_CT_KILL
, &il
->status
);
1859 static inline int il_is_ready_rf(struct il_priv
*il
)
1862 if (il_is_rfkill(il
))
1865 return il_is_ready(il
);
1868 extern void il_send_bt_config(struct il_priv
*il
);
1869 extern int il_send_stats_request(struct il_priv
*il
,
1870 u8 flags
, bool clear
);
1871 void il_apm_stop(struct il_priv
*il
);
1872 int il_apm_init(struct il_priv
*il
);
1874 int il_send_rxon_timing(struct il_priv
*il
,
1875 struct il_rxon_context
*ctx
);
1876 static inline int il_send_rxon_assoc(struct il_priv
*il
,
1877 struct il_rxon_context
*ctx
)
1879 return il
->cfg
->ops
->hcmd
->rxon_assoc(il
, ctx
);
1881 static inline int il_commit_rxon(struct il_priv
*il
,
1882 struct il_rxon_context
*ctx
)
1884 return il
->cfg
->ops
->hcmd
->commit_rxon(il
, ctx
);
1886 static inline const struct ieee80211_supported_band
*il_get_hw_mode(
1887 struct il_priv
*il
, enum ieee80211_band band
)
1889 return il
->hw
->wiphy
->bands
[band
];
1892 /* mac80211 handlers */
1893 int il_mac_config(struct ieee80211_hw
*hw
, u32 changed
);
1894 void il_mac_reset_tsf(struct ieee80211_hw
*hw
,
1895 struct ieee80211_vif
*vif
);
1896 void il_mac_bss_info_changed(struct ieee80211_hw
*hw
,
1897 struct ieee80211_vif
*vif
,
1898 struct ieee80211_bss_conf
*bss_conf
,
1900 void il_tx_cmd_protection(struct il_priv
*il
,
1901 struct ieee80211_tx_info
*info
,
1902 __le16 fc
, __le32
*tx_flags
);
1904 irqreturn_t
il_isr(int irq
, void *data
);
1907 #include <linux/io.h>
1909 static inline void _il_write8(struct il_priv
*il
, u32 ofs
, u8 val
)
1911 iowrite8(val
, il
->hw_base
+ ofs
);
1913 #define il_write8(il, ofs, val) _il_write8(il, ofs, val)
1915 static inline void _il_wr(struct il_priv
*il
, u32 ofs
, u32 val
)
1917 iowrite32(val
, il
->hw_base
+ ofs
);
1920 static inline u32
_il_rd(struct il_priv
*il
, u32 ofs
)
1922 return ioread32(il
->hw_base
+ ofs
);
1925 #define IL_POLL_INTERVAL 10 /* microseconds */
1927 _il_poll_bit(struct il_priv
*il
, u32 addr
,
1928 u32 bits
, u32 mask
, int timeout
)
1933 if ((_il_rd(il
, addr
) & mask
) == (bits
& mask
))
1935 udelay(IL_POLL_INTERVAL
);
1936 t
+= IL_POLL_INTERVAL
;
1937 } while (t
< timeout
);
1942 static inline void _il_set_bit(struct il_priv
*il
, u32 reg
, u32 mask
)
1944 _il_wr(il
, reg
, _il_rd(il
, reg
) | mask
);
1947 static inline void il_set_bit(struct il_priv
*p
, u32 r
, u32 m
)
1949 unsigned long reg_flags
;
1951 spin_lock_irqsave(&p
->reg_lock
, reg_flags
);
1952 _il_set_bit(p
, r
, m
);
1953 spin_unlock_irqrestore(&p
->reg_lock
, reg_flags
);
1957 _il_clear_bit(struct il_priv
*il
, u32 reg
, u32 mask
)
1959 _il_wr(il
, reg
, _il_rd(il
, reg
) & ~mask
);
1962 static inline void il_clear_bit(struct il_priv
*p
, u32 r
, u32 m
)
1964 unsigned long reg_flags
;
1966 spin_lock_irqsave(&p
->reg_lock
, reg_flags
);
1967 _il_clear_bit(p
, r
, m
);
1968 spin_unlock_irqrestore(&p
->reg_lock
, reg_flags
);
1971 static inline int _il_grab_nic_access(struct il_priv
*il
)
1976 /* this bit wakes up the NIC */
1977 _il_set_bit(il
, CSR_GP_CNTRL
,
1978 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ
);
1981 * These bits say the device is running, and should keep running for
1982 * at least a short while (at least as long as MAC_ACCESS_REQ stays 1),
1983 * but they do not indicate that embedded SRAM is restored yet;
1984 * 3945 and 4965 have volatile SRAM, and must save/restore contents
1985 * to/from host DRAM when sleeping/waking for power-saving.
1986 * Each direction takes approximately 1/4 millisecond; with this
1987 * overhead, it's a good idea to grab and hold MAC_ACCESS_REQUEST if a
1988 * series of register accesses are expected (e.g. reading Event Log),
1989 * to keep device from sleeping.
1991 * CSR_UCODE_DRV_GP1 register bit MAC_SLEEP == 0 indicates that
1992 * SRAM is okay/restored. We don't check that here because this call
1993 * is just for hardware register access; but GP1 MAC_SLEEP check is a
1994 * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log).
1997 ret
= _il_poll_bit(il
, CSR_GP_CNTRL
,
1998 CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN
,
1999 (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY
|
2000 CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP
), 15000);
2002 val
= _il_rd(il
, CSR_GP_CNTRL
);
2004 "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val
);
2005 _il_wr(il
, CSR_RESET
,
2006 CSR_RESET_REG_FLAG_FORCE_NMI
);
2013 static inline void _il_release_nic_access(struct il_priv
*il
)
2015 _il_clear_bit(il
, CSR_GP_CNTRL
,
2016 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ
);
2019 static inline u32
il_rd(struct il_priv
*il
, u32 reg
)
2022 unsigned long reg_flags
;
2024 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2025 _il_grab_nic_access(il
);
2026 value
= _il_rd(il
, reg
);
2027 _il_release_nic_access(il
);
2028 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2034 il_wr(struct il_priv
*il
, u32 reg
, u32 value
)
2036 unsigned long reg_flags
;
2038 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2039 if (!_il_grab_nic_access(il
)) {
2040 _il_wr(il
, reg
, value
);
2041 _il_release_nic_access(il
);
2043 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2046 static inline void il_write_reg_buf(struct il_priv
*il
,
2047 u32 reg
, u32 len
, u32
*values
)
2049 u32 count
= sizeof(u32
);
2051 if (il
!= NULL
&& values
!= NULL
) {
2052 for (; 0 < len
; len
-= count
, reg
+= count
, values
++)
2053 il_wr(il
, reg
, *values
);
2057 static inline int il_poll_bit(struct il_priv
*il
, u32 addr
,
2058 u32 mask
, int timeout
)
2063 if ((il_rd(il
, addr
) & mask
) == mask
)
2065 udelay(IL_POLL_INTERVAL
);
2066 t
+= IL_POLL_INTERVAL
;
2067 } while (t
< timeout
);
2072 static inline u32
_il_rd_prph(struct il_priv
*il
, u32 reg
)
2074 _il_wr(il
, HBUS_TARG_PRPH_RADDR
, reg
| (3 << 24));
2076 return _il_rd(il
, HBUS_TARG_PRPH_RDAT
);
2079 static inline u32
il_rd_prph(struct il_priv
*il
, u32 reg
)
2081 unsigned long reg_flags
;
2084 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2085 _il_grab_nic_access(il
);
2086 val
= _il_rd_prph(il
, reg
);
2087 _il_release_nic_access(il
);
2088 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2092 static inline void _il_wr_prph(struct il_priv
*il
,
2095 _il_wr(il
, HBUS_TARG_PRPH_WADDR
,
2096 ((addr
& 0x0000FFFF) | (3 << 24)));
2098 _il_wr(il
, HBUS_TARG_PRPH_WDAT
, val
);
2102 il_wr_prph(struct il_priv
*il
, u32 addr
, u32 val
)
2104 unsigned long reg_flags
;
2106 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2107 if (!_il_grab_nic_access(il
)) {
2108 _il_wr_prph(il
, addr
, val
);
2109 _il_release_nic_access(il
);
2111 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2114 #define _il_set_bits_prph(il, reg, mask) \
2115 _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask))
2118 il_set_bits_prph(struct il_priv
*il
, u32 reg
, u32 mask
)
2120 unsigned long reg_flags
;
2122 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2123 _il_grab_nic_access(il
);
2124 _il_set_bits_prph(il
, reg
, mask
);
2125 _il_release_nic_access(il
);
2126 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2129 #define _il_set_bits_mask_prph(il, reg, bits, mask) \
2130 _il_wr_prph(il, reg, \
2131 ((_il_rd_prph(il, reg) & mask) | bits))
2133 static inline void il_set_bits_mask_prph(struct il_priv
*il
, u32 reg
,
2136 unsigned long reg_flags
;
2138 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2139 _il_grab_nic_access(il
);
2140 _il_set_bits_mask_prph(il
, reg
, bits
, mask
);
2141 _il_release_nic_access(il
);
2142 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2145 static inline void il_clear_bits_prph(struct il_priv
2146 *il
, u32 reg
, u32 mask
)
2148 unsigned long reg_flags
;
2151 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2152 _il_grab_nic_access(il
);
2153 val
= _il_rd_prph(il
, reg
);
2154 _il_wr_prph(il
, reg
, (val
& ~mask
));
2155 _il_release_nic_access(il
);
2156 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2159 static inline u32
il_read_targ_mem(struct il_priv
*il
, u32 addr
)
2161 unsigned long reg_flags
;
2164 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2165 _il_grab_nic_access(il
);
2167 _il_wr(il
, HBUS_TARG_MEM_RADDR
, addr
);
2169 value
= _il_rd(il
, HBUS_TARG_MEM_RDAT
);
2171 _il_release_nic_access(il
);
2172 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2177 il_write_targ_mem(struct il_priv
*il
, u32 addr
, u32 val
)
2179 unsigned long reg_flags
;
2181 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2182 if (!_il_grab_nic_access(il
)) {
2183 _il_wr(il
, HBUS_TARG_MEM_WADDR
, addr
);
2185 _il_wr(il
, HBUS_TARG_MEM_WDAT
, val
);
2186 _il_release_nic_access(il
);
2188 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2192 il_write_targ_mem_buf(struct il_priv
*il
, u32 addr
,
2193 u32 len
, u32
*values
)
2195 unsigned long reg_flags
;
2197 spin_lock_irqsave(&il
->reg_lock
, reg_flags
);
2198 if (!_il_grab_nic_access(il
)) {
2199 _il_wr(il
, HBUS_TARG_MEM_WADDR
, addr
);
2201 for (; 0 < len
; len
-= sizeof(u32
), values
++)
2203 HBUS_TARG_MEM_WDAT
, *values
);
2205 _il_release_nic_access(il
);
2207 spin_unlock_irqrestore(&il
->reg_lock
, reg_flags
);
2210 #define HW_KEY_DYNAMIC 0
2211 #define HW_KEY_DEFAULT 1
2213 #define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
2214 #define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */
2215 #define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of
2217 #define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211;
2218 (this is for the IBSS BSSID stations) */
2219 #define IL_STA_BCAST BIT(4) /* this station is the special bcast station */
2222 void il_restore_stations(struct il_priv
*il
,
2223 struct il_rxon_context
*ctx
);
2224 void il_clear_ucode_stations(struct il_priv
*il
,
2225 struct il_rxon_context
*ctx
);
2226 void il_dealloc_bcast_stations(struct il_priv
*il
);
2227 int il_get_free_ucode_key_idx(struct il_priv
*il
);
2228 int il_send_add_sta(struct il_priv
*il
,
2229 struct il_addsta_cmd
*sta
, u8 flags
);
2230 int il_add_station_common(struct il_priv
*il
,
2231 struct il_rxon_context
*ctx
,
2232 const u8
*addr
, bool is_ap
,
2233 struct ieee80211_sta
*sta
, u8
*sta_id_r
);
2234 int il_remove_station(struct il_priv
*il
,
2237 int il_mac_sta_remove(struct ieee80211_hw
*hw
,
2238 struct ieee80211_vif
*vif
,
2239 struct ieee80211_sta
*sta
);
2241 u8
il_prep_station(struct il_priv
*il
,
2242 struct il_rxon_context
*ctx
,
2243 const u8
*addr
, bool is_ap
,
2244 struct ieee80211_sta
*sta
);
2246 int il_send_lq_cmd(struct il_priv
*il
,
2247 struct il_rxon_context
*ctx
,
2248 struct il_link_quality_cmd
*lq
,
2249 u8 flags
, bool init
);
2252 * il_clear_driver_stations - clear knowledge of all stations from driver
2253 * @il: iwl il struct
2255 * This is called during il_down() to make sure that in the case
2256 * we're coming there from a hardware restart mac80211 will be
2257 * able to reconfigure stations -- if we're getting there in the
2258 * normal down flow then the stations will already be cleared.
2260 static inline void il_clear_driver_stations(struct il_priv
*il
)
2262 unsigned long flags
;
2263 struct il_rxon_context
*ctx
= &il
->ctx
;
2265 spin_lock_irqsave(&il
->sta_lock
, flags
);
2266 memset(il
->stations
, 0, sizeof(il
->stations
));
2267 il
->num_stations
= 0;
2269 il
->ucode_key_table
= 0;
2272 * Remove all key information that is not stored as part
2273 * of station information since mac80211 may not have had
2274 * a chance to remove all the keys. When device is
2275 * reconfigured by mac80211 after an error all keys will
2278 memset(ctx
->wep_keys
, 0, sizeof(ctx
->wep_keys
));
2279 ctx
->key_mapping_keys
= 0;
2281 spin_unlock_irqrestore(&il
->sta_lock
, flags
);
2284 static inline int il_sta_id(struct ieee80211_sta
*sta
)
2287 return IL_INVALID_STATION
;
2289 return ((struct il_station_priv_common
*)sta
->drv_priv
)->sta_id
;
2293 * il_sta_id_or_broadcast - return sta_id or broadcast sta
2295 * @context: the current context
2296 * @sta: mac80211 station
2298 * In certain circumstances mac80211 passes a station pointer
2299 * that may be %NULL, for example during TX or key setup. In
2300 * that case, we need to use the broadcast station, so this
2301 * inline wraps that pattern.
2303 static inline int il_sta_id_or_broadcast(struct il_priv
*il
,
2304 struct il_rxon_context
*context
,
2305 struct ieee80211_sta
*sta
)
2310 return context
->bcast_sta_id
;
2312 sta_id
= il_sta_id(sta
);
2315 * mac80211 should not be passing a partially
2316 * initialised station!
2318 WARN_ON(sta_id
== IL_INVALID_STATION
);
2324 * il_queue_inc_wrap - increment queue idx, wrap back to beginning
2325 * @idx -- current idx
2326 * @n_bd -- total number of entries in queue (must be power of 2)
2328 static inline int il_queue_inc_wrap(int idx
, int n_bd
)
2330 return ++idx
& (n_bd
- 1);
2334 * il_queue_dec_wrap - decrement queue idx, wrap back to end
2335 * @idx -- current idx
2336 * @n_bd -- total number of entries in queue (must be power of 2)
2338 static inline int il_queue_dec_wrap(int idx
, int n_bd
)
2340 return --idx
& (n_bd
- 1);
2343 /* TODO: Move fw_desc functions to iwl-pci.ko */
2344 static inline void il_free_fw_desc(struct pci_dev
*pci_dev
,
2345 struct fw_desc
*desc
)
2348 dma_free_coherent(&pci_dev
->dev
, desc
->len
,
2349 desc
->v_addr
, desc
->p_addr
);
2350 desc
->v_addr
= NULL
;
2354 static inline int il_alloc_fw_desc(struct pci_dev
*pci_dev
,
2355 struct fw_desc
*desc
)
2358 desc
->v_addr
= NULL
;
2362 desc
->v_addr
= dma_alloc_coherent(&pci_dev
->dev
, desc
->len
,
2363 &desc
->p_addr
, GFP_KERNEL
);
2364 return (desc
->v_addr
!= NULL
) ? 0 : -ENOMEM
;
2368 * we have 8 bits used like this:
2372 * | | | | | | +-+-------- AC queue (0-3)
2374 * | +-+-+-+-+------------ HW queue ID
2376 * +---------------------- unused
2379 il_set_swq_id(struct il_tx_queue
*txq
, u8 ac
, u8 hwq
)
2381 BUG_ON(ac
> 3); /* only have 2 bits */
2382 BUG_ON(hwq
> 31); /* only use 5 bits */
2384 txq
->swq_id
= (hwq
<< 2) | ac
;
2387 static inline void il_wake_queue(struct il_priv
*il
,
2388 struct il_tx_queue
*txq
)
2390 u8 queue
= txq
->swq_id
;
2392 u8 hwq
= (queue
>> 2) & 0x1f;
2394 if (test_and_clear_bit(hwq
, il
->queue_stopped
))
2395 if (atomic_dec_return(&il
->queue_stop_count
[ac
]) <= 0)
2396 ieee80211_wake_queue(il
->hw
, ac
);
2399 static inline void il_stop_queue(struct il_priv
*il
,
2400 struct il_tx_queue
*txq
)
2402 u8 queue
= txq
->swq_id
;
2404 u8 hwq
= (queue
>> 2) & 0x1f;
2406 if (!test_and_set_bit(hwq
, il
->queue_stopped
))
2407 if (atomic_inc_return(&il
->queue_stop_count
[ac
]) > 0)
2408 ieee80211_stop_queue(il
->hw
, ac
);
2411 #ifdef ieee80211_stop_queue
2412 #undef ieee80211_stop_queue
2415 #define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue
2417 #ifdef ieee80211_wake_queue
2418 #undef ieee80211_wake_queue
2421 #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue
2423 static inline void il_disable_interrupts(struct il_priv
*il
)
2425 clear_bit(S_INT_ENABLED
, &il
->status
);
2427 /* disable interrupts from uCode/NIC to host */
2428 _il_wr(il
, CSR_INT_MASK
, 0x00000000);
2430 /* acknowledge/clear/reset any interrupts still pending
2431 * from uCode or flow handler (Rx/Tx DMA) */
2432 _il_wr(il
, CSR_INT
, 0xffffffff);
2433 _il_wr(il
, CSR_FH_INT_STATUS
, 0xffffffff);
2434 D_ISR("Disabled interrupts\n");
2437 static inline void il_enable_rfkill_int(struct il_priv
*il
)
2439 D_ISR("Enabling rfkill interrupt\n");
2440 _il_wr(il
, CSR_INT_MASK
, CSR_INT_BIT_RF_KILL
);
2443 static inline void il_enable_interrupts(struct il_priv
*il
)
2445 D_ISR("Enabling interrupts\n");
2446 set_bit(S_INT_ENABLED
, &il
->status
);
2447 _il_wr(il
, CSR_INT_MASK
, il
->inta_mask
);
2451 * il_beacon_time_mask_low - mask of lower 32 bit of beacon time
2452 * @il -- pointer to il_priv data structure
2453 * @tsf_bits -- number of bits need to shift for masking)
2455 static inline u32
il_beacon_time_mask_low(struct il_priv
*il
,
2458 return (1 << tsf_bits
) - 1;
2462 * il_beacon_time_mask_high - mask of higher 32 bit of beacon time
2463 * @il -- pointer to il_priv data structure
2464 * @tsf_bits -- number of bits need to shift for masking)
2466 static inline u32
il_beacon_time_mask_high(struct il_priv
*il
,
2469 return ((1 << (32 - tsf_bits
)) - 1) << tsf_bits
;
2473 * struct il_rb_status - reseve buffer status host memory mapped FH registers
2475 * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed
2476 * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed
2477 * @finished_rb_num [0:11] - Indicates the idx of the current RB
2478 * in which the last frame was written to
2479 * @finished_fr_num [0:11] - Indicates the idx of the RX Frame
2480 * which was transferred
2482 struct il_rb_status
{
2483 __le16 closed_rb_num
;
2484 __le16 closed_fr_num
;
2485 __le16 finished_rb_num
;
2486 __le16 finished_fr_nam
;
2487 __le32 __unused
; /* 3945 only */
2491 #define TFD_QUEUE_SIZE_MAX (256)
2492 #define TFD_QUEUE_SIZE_BC_DUP (64)
2493 #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
2494 #define IL_TX_DMA_MASK DMA_BIT_MASK(36)
2495 #define IL_NUM_OF_TBS 20
2497 static inline u8
il_get_dma_hi_addr(dma_addr_t addr
)
2499 return (sizeof(addr
) > sizeof(u32
) ? (addr
>> 16) >> 16 : 0) & 0xF;
2502 * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor
2504 * This structure contains dma address and length of transmission address
2506 * @lo: low [31:0] portion of the dma address of TX buffer
2507 * every even is unaligned on 16 bit boundary
2508 * @hi_n_len 0-3 [35:32] portion of dma
2509 * 4-15 length of the tx buffer
2519 * Transmit Frame Descriptor (TFD)
2521 * @ __reserved1[3] reserved
2522 * @ num_tbs 0-4 number of active tbs
2524 * 6-7 padding (not used)
2525 * @ tbs[20] transmit frame buffer descriptors
2528 * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
2529 * Both driver and device share these circular buffers, each of which must be
2530 * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes
2532 * Driver must indicate the physical address of the base of each
2533 * circular buffer via the FH_MEM_CBBC_QUEUE registers.
2535 * Each TFD contains pointer/size information for up to 20 data buffers
2536 * in host DRAM. These buffers collectively contain the (one) frame described
2537 * by the TFD. Each buffer must be a single contiguous block of memory within
2538 * itself, but buffers may be scattered in host DRAM. Each buffer has max size
2539 * of (4K - 4). The concatenates all of a TFD's buffers into a single
2540 * Tx frame, up to 8 KBytes in size.
2542 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
2547 struct il_tfd_tb tbs
[IL_NUM_OF_TBS
];
2551 #define PCI_CFG_RETRY_TIMEOUT 0x041
2553 /* PCI register values */
2554 #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
2555 #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
2557 struct il_rate_info
{
2558 u8 plcp
; /* uCode API: RATE_6M_PLCP, etc. */
2559 u8 plcp_siso
; /* uCode API: RATE_SISO_6M_PLCP, etc. */
2560 u8 plcp_mimo2
; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */
2561 u8 ieee
; /* MAC header: RATE_6M_IEEE, etc. */
2562 u8 prev_ieee
; /* previous rate in IEEE speeds */
2563 u8 next_ieee
; /* next rate in IEEE speeds */
2564 u8 prev_rs
; /* previous rate used in rs algo */
2565 u8 next_rs
; /* next rate used in rs algo */
2566 u8 prev_rs_tgg
; /* previous rate used in TGG rs algo */
2567 u8 next_rs_tgg
; /* next rate used in TGG rs algo */
2570 struct il3945_rate_info
{
2571 u8 plcp
; /* uCode API: RATE_6M_PLCP, etc. */
2572 u8 ieee
; /* MAC header: RATE_6M_IEEE, etc. */
2573 u8 prev_ieee
; /* previous rate in IEEE speeds */
2574 u8 next_ieee
; /* next rate in IEEE speeds */
2575 u8 prev_rs
; /* previous rate used in rs algo */
2576 u8 next_rs
; /* next rate used in rs algo */
2577 u8 prev_rs_tgg
; /* previous rate used in TGG rs algo */
2578 u8 next_rs_tgg
; /* next rate used in TGG rs algo */
2579 u8 table_rs_idx
; /* idx in rate scale table cmd */
2580 u8 prev_table_rs
; /* prev in rate table cmd */
2585 * These serve as idxes into
2586 * struct il_rate_info il_rates[RATE_COUNT];
2603 RATE_COUNT_LEGACY
= RATE_COUNT
- 1, /* Excluding 60M */
2604 RATE_COUNT_3945
= RATE_COUNT
- 1,
2605 RATE_INVM_IDX
= RATE_COUNT
,
2606 RATE_INVALID
= RATE_COUNT
,
2610 RATE_6M_IDX_TBL
= 0,
2622 RATE_INVM_IDX_TBL
= RATE_INVM_IDX
- 1,
2626 IL_FIRST_OFDM_RATE
= RATE_6M_IDX
,
2627 IL39_LAST_OFDM_RATE
= RATE_54M_IDX
,
2628 IL_LAST_OFDM_RATE
= RATE_60M_IDX
,
2629 IL_FIRST_CCK_RATE
= RATE_1M_IDX
,
2630 IL_LAST_CCK_RATE
= RATE_11M_IDX
,
2633 /* #define vs. enum to keep from defaulting to 'large integer' */
2634 #define RATE_6M_MASK (1 << RATE_6M_IDX)
2635 #define RATE_9M_MASK (1 << RATE_9M_IDX)
2636 #define RATE_12M_MASK (1 << RATE_12M_IDX)
2637 #define RATE_18M_MASK (1 << RATE_18M_IDX)
2638 #define RATE_24M_MASK (1 << RATE_24M_IDX)
2639 #define RATE_36M_MASK (1 << RATE_36M_IDX)
2640 #define RATE_48M_MASK (1 << RATE_48M_IDX)
2641 #define RATE_54M_MASK (1 << RATE_54M_IDX)
2642 #define RATE_60M_MASK (1 << RATE_60M_IDX)
2643 #define RATE_1M_MASK (1 << RATE_1M_IDX)
2644 #define RATE_2M_MASK (1 << RATE_2M_IDX)
2645 #define RATE_5M_MASK (1 << RATE_5M_IDX)
2646 #define RATE_11M_MASK (1 << RATE_11M_IDX)
2648 /* uCode API values for legacy bit rates, both OFDM and CCK */
2658 RATE_60M_PLCP
= 3,/*FIXME:RS:should be removed*/
2662 RATE_11M_PLCP
= 110,
2663 /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/
2666 /* uCode API values for OFDM high-throughput (HT) bit rates */
2668 RATE_SISO_6M_PLCP
= 0,
2669 RATE_SISO_12M_PLCP
= 1,
2670 RATE_SISO_18M_PLCP
= 2,
2671 RATE_SISO_24M_PLCP
= 3,
2672 RATE_SISO_36M_PLCP
= 4,
2673 RATE_SISO_48M_PLCP
= 5,
2674 RATE_SISO_54M_PLCP
= 6,
2675 RATE_SISO_60M_PLCP
= 7,
2676 RATE_MIMO2_6M_PLCP
= 0x8,
2677 RATE_MIMO2_12M_PLCP
= 0x9,
2678 RATE_MIMO2_18M_PLCP
= 0xa,
2679 RATE_MIMO2_24M_PLCP
= 0xb,
2680 RATE_MIMO2_36M_PLCP
= 0xc,
2681 RATE_MIMO2_48M_PLCP
= 0xd,
2682 RATE_MIMO2_54M_PLCP
= 0xe,
2683 RATE_MIMO2_60M_PLCP
= 0xf,
2684 RATE_SISO_INVM_PLCP
,
2685 RATE_MIMO2_INVM_PLCP
= RATE_SISO_INVM_PLCP
,
2688 /* MAC header values for bit rates */
2697 RATE_54M_IEEE
= 108,
2698 RATE_60M_IEEE
= 120,
2705 #define IL_CCK_BASIC_RATES_MASK \
2709 #define IL_CCK_RATES_MASK \
2710 (IL_CCK_BASIC_RATES_MASK | \
2714 #define IL_OFDM_BASIC_RATES_MASK \
2719 #define IL_OFDM_RATES_MASK \
2720 (IL_OFDM_BASIC_RATES_MASK | \
2727 #define IL_BASIC_RATES_MASK \
2728 (IL_OFDM_BASIC_RATES_MASK | \
2729 IL_CCK_BASIC_RATES_MASK)
2731 #define RATES_MASK ((1 << RATE_COUNT) - 1)
2732 #define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1)
2734 #define IL_INVALID_VALUE -1
2736 #define IL_MIN_RSSI_VAL -100
2737 #define IL_MAX_RSSI_VAL 0
2739 /* These values specify how many Tx frame attempts before
2740 * searching for a new modulation mode */
2741 #define IL_LEGACY_FAILURE_LIMIT 160
2742 #define IL_LEGACY_SUCCESS_LIMIT 480
2743 #define IL_LEGACY_TBL_COUNT 160
2745 #define IL_NONE_LEGACY_FAILURE_LIMIT 400
2746 #define IL_NONE_LEGACY_SUCCESS_LIMIT 4500
2747 #define IL_NONE_LEGACY_TBL_COUNT 1500
2749 /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */
2750 #define IL_RS_GOOD_RATIO 12800 /* 100% */
2751 #define RATE_SCALE_SWITCH 10880 /* 85% */
2752 #define RATE_HIGH_TH 10880 /* 85% */
2753 #define RATE_INCREASE_TH 6400 /* 50% */
2754 #define RATE_DECREASE_TH 1920 /* 15% */
2756 /* possible actions when in legacy mode */
2757 #define IL_LEGACY_SWITCH_ANTENNA1 0
2758 #define IL_LEGACY_SWITCH_ANTENNA2 1
2759 #define IL_LEGACY_SWITCH_SISO 2
2760 #define IL_LEGACY_SWITCH_MIMO2_AB 3
2761 #define IL_LEGACY_SWITCH_MIMO2_AC 4
2762 #define IL_LEGACY_SWITCH_MIMO2_BC 5
2764 /* possible actions when in siso mode */
2765 #define IL_SISO_SWITCH_ANTENNA1 0
2766 #define IL_SISO_SWITCH_ANTENNA2 1
2767 #define IL_SISO_SWITCH_MIMO2_AB 2
2768 #define IL_SISO_SWITCH_MIMO2_AC 3
2769 #define IL_SISO_SWITCH_MIMO2_BC 4
2770 #define IL_SISO_SWITCH_GI 5
2772 /* possible actions when in mimo mode */
2773 #define IL_MIMO2_SWITCH_ANTENNA1 0
2774 #define IL_MIMO2_SWITCH_ANTENNA2 1
2775 #define IL_MIMO2_SWITCH_SISO_A 2
2776 #define IL_MIMO2_SWITCH_SISO_B 3
2777 #define IL_MIMO2_SWITCH_SISO_C 4
2778 #define IL_MIMO2_SWITCH_GI 5
2780 #define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI
2782 #define IL_ACTION_LIMIT 3 /* # possible actions */
2784 #define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */
2786 /* load per tid defines for A-MPDU activation */
2787 #define IL_AGG_TPT_THREHOLD 0
2788 #define IL_AGG_LOAD_THRESHOLD 10
2789 #define IL_AGG_ALL_TID 0xff
2790 #define TID_QUEUE_CELL_SPACING 50 /*mS */
2791 #define TID_QUEUE_MAX_SIZE 20
2792 #define TID_ROUND_VALUE 5 /* mS */
2793 #define TID_MAX_LOAD_COUNT 8
2795 #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING)
2796 #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
2798 extern const struct il_rate_info il_rates
[RATE_COUNT
];
2800 enum il_table_type
{
2802 LQ_G
, /* legacy types */
2804 LQ_SISO
, /* high-throughput types */
2809 #define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A)
2810 #define is_siso(tbl) ((tbl) == LQ_SISO)
2811 #define is_mimo2(tbl) ((tbl) == LQ_MIMO2)
2812 #define is_mimo(tbl) (is_mimo2(tbl))
2813 #define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
2814 #define is_a_band(tbl) ((tbl) == LQ_A)
2815 #define is_g_and(tbl) ((tbl) == LQ_G)
2817 #define ANT_NONE 0x0
2818 #define ANT_A BIT(0)
2819 #define ANT_B BIT(1)
2820 #define ANT_AB (ANT_A | ANT_B)
2821 #define ANT_C BIT(2)
2822 #define ANT_AC (ANT_A | ANT_C)
2823 #define ANT_BC (ANT_B | ANT_C)
2824 #define ANT_ABC (ANT_AB | ANT_C)
2826 #define IL_MAX_MCS_DISPLAY_SIZE 12
2828 struct il_rate_mcs_info
{
2829 char mbps
[IL_MAX_MCS_DISPLAY_SIZE
];
2830 char mcs
[IL_MAX_MCS_DISPLAY_SIZE
];
2834 * struct il_rate_scale_data -- tx success history for one rate
2836 struct il_rate_scale_data
{
2837 u64 data
; /* bitmap of successful frames */
2838 s32 success_counter
; /* number of frames successful */
2839 s32 success_ratio
; /* per-cent * 128 */
2840 s32 counter
; /* number of frames attempted */
2841 s32 average_tpt
; /* success ratio * expected throughput */
2842 unsigned long stamp
;
2846 * struct il_scale_tbl_info -- tx params and success history for all rates
2848 * There are two of these in struct il_lq_sta,
2849 * one for "active", and one for "search".
2851 struct il_scale_tbl_info
{
2852 enum il_table_type lq_type
;
2854 u8 is_SGI
; /* 1 = short guard interval */
2855 u8 is_ht40
; /* 1 = 40 MHz channel width */
2856 u8 is_dup
; /* 1 = duplicated data streams */
2857 u8 action
; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */
2858 u8 max_search
; /* maximun number of tables we can search */
2859 s32
*expected_tpt
; /* throughput metrics; expected_tpt_G, etc. */
2860 u32 current_rate
; /* rate_n_flags, uCode API format */
2861 struct il_rate_scale_data win
[RATE_COUNT
]; /* rate histories */
2864 struct il_traffic_load
{
2865 unsigned long time_stamp
; /* age of the oldest stats */
2866 u32 packet_count
[TID_QUEUE_MAX_SIZE
]; /* packet count in this time
2868 u32 total
; /* total num of packets during the
2869 * last TID_MAX_TIME_DIFF */
2870 u8 queue_count
; /* number of queues that has
2871 * been used since the last cleanup */
2872 u8 head
; /* start of the circular buffer */
2876 * struct il_lq_sta -- driver's rate scaling ilate structure
2878 * Pointer to this gets passed back and forth between driver and mac80211.
2881 u8 active_tbl
; /* idx of active table, range 0-1 */
2882 u8 enable_counter
; /* indicates HT mode */
2883 u8 stay_in_tbl
; /* 1: disallow, 0: allow search for new mode */
2884 u8 search_better_tbl
; /* 1: currently trying alternate mode */
2887 /* The following determine when to search for a new mode */
2888 u32 table_count_limit
;
2889 u32 max_failure_limit
; /* # failed frames before new search */
2890 u32 max_success_limit
; /* # successful frames before new search */
2892 u32 total_failed
; /* total failed frames, any/all rates */
2893 u32 total_success
; /* total successful frames, any/all rates */
2894 u64 flush_timer
; /* time staying in mode before new search */
2896 u8 action_counter
; /* # mode-switch actions tried */
2899 enum ieee80211_band band
;
2901 /* The following are bitmaps of rates; RATE_6M_MASK, etc. */
2903 u16 active_legacy_rate
;
2904 u16 active_siso_rate
;
2905 u16 active_mimo2_rate
;
2906 s8 max_rate_idx
; /* Max rate set by user */
2907 u8 missed_rate_counter
;
2909 struct il_link_quality_cmd lq
;
2910 struct il_scale_tbl_info lq_info
[LQ_SIZE
]; /* "active", "search" */
2911 struct il_traffic_load load
[TID_MAX_LOAD_COUNT
];
2913 #ifdef CONFIG_MAC80211_DEBUGFS
2914 struct dentry
*rs_sta_dbgfs_scale_table_file
;
2915 struct dentry
*rs_sta_dbgfs_stats_table_file
;
2916 struct dentry
*rs_sta_dbgfs_rate_scale_data_file
;
2917 struct dentry
*rs_sta_dbgfs_tx_agg_tid_en_file
;
2920 struct il_priv
*drv
;
2922 /* used to be in sta_info */
2923 int last_txrate_idx
;
2924 /* last tx rate_n_flags */
2925 u32 last_rate_n_flags
;
2926 /* packets destined for this STA are aggregated */
2931 * il_station_priv: Driver's ilate station information
2933 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
2934 * in the structure for use by driver. This structure is places in that
2937 * The common struct MUST be first because it is shared between
2940 struct il_station_priv
{
2941 struct il_station_priv_common common
;
2942 struct il_lq_sta lq_sta
;
2943 atomic_t pending_frames
;
2948 static inline u8
il4965_num_of_ant(u8 m
)
2950 return !!(m
& ANT_A
) + !!(m
& ANT_B
) + !!(m
& ANT_C
);
2953 static inline u8
il4965_first_antenna(u8 mask
)
2964 * il3945_rate_scale_init - Initialize the rate scale table based on assoc info
2966 * The specific throughput table used is based on the type of network
2967 * the associated with, including A, B, G, and G w/ TGG protection
2969 extern void il3945_rate_scale_init(struct ieee80211_hw
*hw
, s32 sta_id
);
2971 /* Initialize station's rate scaling information after adding station */
2972 extern void il4965_rs_rate_init(struct il_priv
*il
,
2973 struct ieee80211_sta
*sta
, u8 sta_id
);
2974 extern void il3945_rs_rate_init(struct il_priv
*il
,
2975 struct ieee80211_sta
*sta
, u8 sta_id
);
2978 * il_rate_control_register - Register the rate control algorithm callbacks
2980 * Since the rate control algorithm is hardware specific, there is no need
2981 * or reason to place it as a stand alone module. The driver can call
2982 * il_rate_control_register in order to register the rate control callbacks
2983 * with the mac80211 subsystem. This should be performed prior to calling
2984 * ieee80211_register_hw
2987 extern int il4965_rate_control_register(void);
2988 extern int il3945_rate_control_register(void);
2991 * il_rate_control_unregister - Unregister the rate control callbacks
2993 * This should be called after calling ieee80211_unregister_hw, but before
2994 * the driver is unloaded.
2996 extern void il4965_rate_control_unregister(void);
2997 extern void il3945_rate_control_unregister(void);
2999 #endif /* __il_core_h__ */