blob: 811e768637cb0a4d2690de7b2955e18c8b1849a7 [file] [log] [blame]
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001/******************************************************************************
2 *
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02003 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08004 *
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02005 * 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
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08007 * published by the Free Software Foundation.
8 *
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02009 * 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
12 * more details.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080013 *
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020014 * 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
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080017 *
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020018 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080020 *
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080025 *****************************************************************************/
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +020026#ifndef __il_core_h__
27#define __il_core_h__
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080028
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020029#include <linux/interrupt.h>
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010030#include <linux/pci.h> /* for struct pci_device_id */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020031#include <linux/kernel.h>
32#include <linux/leds.h>
33#include <linux/wait.h>
Stanislaw Gruszka17d4eca2011-12-23 08:13:43 +010034#include <linux/io.h>
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +020035#include <net/mac80211.h>
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020036#include <net/ieee80211_radiotap.h>
37
Stanislaw Gruszka99412002011-08-31 13:53:04 +020038#include "commands.h"
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020039#include "csr.h"
Stanislaw Gruszkae8c39d42011-08-31 14:09:39 +020040#include "prph.h"
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020041
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +020042struct il_host_cmd;
43struct il_cmd;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020044struct il_tx_queue;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -080045
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +020046#define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a)
47#define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a)
48#define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a)
49
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020050#define RX_QUEUE_SIZE 256
51#define RX_QUEUE_MASK 255
52#define RX_QUEUE_SIZE_LOG 8
53
54/*
55 * RX related structures and functions
56 */
57#define RX_FREE_BUFFERS 64
58#define RX_LOW_WATERMARK 8
59
60#define U32_PAD(n) ((4-(n))&0x3)
61
62/* CT-KILL constants */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010063#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020064
65/* Default noise level to report when noise measurement is not available.
66 * This may be because we're:
67 * 1) Not associated (4965, no beacon stats being sent to driver)
68 * 2) Scanning (noise measurement does not apply to associated channel)
69 * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
70 * Use default noise value of -127 ... this is below the range of measurable
71 * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
72 * Also, -127 works better than 0 when averaging frames with/without
73 * noise info (e.g. averaging might be done in app); measured dBm values are
74 * always negative ... using a negative value as the default keeps all
75 * averages within an s8's (used in some apps) range of negative values. */
76#define IL_NOISE_MEAS_NOT_AVAILABLE (-127)
77
78/*
79 * RTS threshold here is total size [2347] minus 4 FCS bytes
80 * Per spec:
81 * a value of 0 means RTS on all data/management packets
82 * a value > max MSDU size means no RTS
83 * else RTS for data/management frames where MPDU is larger
84 * than RTS value.
85 */
86#define DEFAULT_RTS_THRESHOLD 2347U
87#define MIN_RTS_THRESHOLD 0U
88#define MAX_RTS_THRESHOLD 2347U
89#define MAX_MSDU_SIZE 2304U
90#define MAX_MPDU_SIZE 2346U
91#define DEFAULT_BEACON_INTERVAL 100U
92#define DEFAULT_SHORT_RETRY_LIMIT 7U
93#define DEFAULT_LONG_RETRY_LIMIT 4U
94
95struct il_rx_buf {
96 dma_addr_t page_dma;
97 struct page *page;
98 struct list_head list;
99};
100
101#define rxb_addr(r) page_address(r->page)
102
103/* defined below */
104struct il_device_cmd;
105
106struct il_cmd_meta {
107 /* only for SYNC commands, iff the reply skb is wanted */
108 struct il_host_cmd *source;
109 /*
110 * only for ASYNC commands
111 * (which is somewhat stupid -- look at common.c for instance
112 * which duplicates a bunch of code because the callback isn't
113 * invoked for SYNC commands, if it were and its result passed
114 * through it would be simpler...)
115 */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100116 void (*callback) (struct il_priv *il, struct il_device_cmd *cmd,
117 struct il_rx_pkt *pkt);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200118
119 /* The CMD_SIZE_HUGE flag bit indicates that the command
120 * structure is stored at the end of the shared queue memory. */
121 u32 flags;
122
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100123 DEFINE_DMA_UNMAP_ADDR(mapping);
124 DEFINE_DMA_UNMAP_LEN(len);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200125};
126
127/*
128 * Generic queue structure
129 *
130 * Contains common data for Rx and Tx queues
131 */
132struct il_queue {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100133 int n_bd; /* number of BDs in this queue */
134 int write_ptr; /* 1-st empty entry (idx) host_w */
135 int read_ptr; /* last used entry (idx) host_r */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200136 /* use for monitoring and recovering the stuck queue */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100137 dma_addr_t dma_addr; /* physical addr for BD's */
138 int n_win; /* safe queue win */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200139 u32 id;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100140 int low_mark; /* low watermark, resume queue if free
141 * space more than this */
142 int high_mark; /* high watermark, stop queue if free
143 * space less than this */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200144};
145
146/* One for each TFD */
147struct il_tx_info {
148 struct sk_buff *skb;
149 struct il_rxon_context *ctx;
150};
151
152/**
153 * struct il_tx_queue - Tx Queue for DMA
154 * @q: generic Rx/Tx queue descriptor
155 * @bd: base of circular buffer of TFDs
156 * @cmd: array of command/TX buffer pointers
157 * @meta: array of meta data for each command/tx buffer
158 * @dma_addr_cmd: physical address of cmd/tx buffer array
159 * @txb: array of per-TFD driver data
160 * @time_stamp: time (in jiffies) of last read_ptr change
161 * @need_update: indicates need to update read/write idx
162 * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
163 *
164 * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
165 * descriptors) and required locking structures.
166 */
167#define TFD_TX_CMD_SLOTS 256
168#define TFD_CMD_SLOTS 32
169
170struct il_tx_queue {
171 struct il_queue q;
172 void *tfds;
173 struct il_device_cmd **cmd;
174 struct il_cmd_meta *meta;
175 struct il_tx_info *txb;
176 unsigned long time_stamp;
177 u8 need_update;
178 u8 sched_retry;
179 u8 active;
180 u8 swq_id;
181};
182
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200183/*
184 * EEPROM access time values:
185 *
186 * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG.
187 * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
188 * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
189 * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
190 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100191#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200192
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100193#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */
194#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200195
196/*
197 * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags.
198 *
199 * IBSS and/or AP operation is allowed *only* on those channels with
200 * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because
201 * RADAR detection is not supported by the 4965 driver, but is a
202 * requirement for establishing a new network for legal operation on channels
203 * requiring RADAR detection or restricting ACTIVE scanning.
204 *
205 * NOTE: "WIDE" flag does not indicate anything about "HT40" 40 MHz channels.
206 * It only indicates that 20 MHz channel use is supported; HT40 channel
207 * usage is indicated by a separate set of regulatory flags for each
208 * HT40 channel pair.
209 *
210 * NOTE: Using a channel inappropriately will result in a uCode error!
211 */
212#define IL_NUM_TX_CALIB_GROUPS 5
213enum {
214 EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100215 EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200216 /* Bit 2 Reserved */
217 EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
218 EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100219 EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200220 /* Bit 6 Reserved (was Narrow Channel) */
221 EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
222};
223
224/* SKU Capabilities */
225/* 3945 only */
226#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
227#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
228
229/* *regulatory* channel data format in eeprom, one for each channel.
230 * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */
231struct il_eeprom_channel {
232 u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */
233 s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
234} __packed;
235
236/* 3945 Specific */
237#define EEPROM_3945_EEPROM_VERSION (0x2f)
238
239/* 4965 has two radio transmitters (and 3 radio receivers) */
240#define EEPROM_TX_POWER_TX_CHAINS (2)
241
242/* 4965 has room for up to 8 sets of txpower calibration data */
243#define EEPROM_TX_POWER_BANDS (8)
244
245/* 4965 factory calibration measures txpower gain settings for
246 * each of 3 target output levels */
247#define EEPROM_TX_POWER_MEASUREMENTS (3)
248
249/* 4965 Specific */
250/* 4965 driver does not work with txpower calibration version < 5 */
251#define EEPROM_4965_TX_POWER_VERSION (5)
252#define EEPROM_4965_EEPROM_VERSION (0x2f)
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100253#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
254#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
255#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
256#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200257
258/* 2.4 GHz */
259extern const u8 il_eeprom_band_1[14];
260
261/*
262 * factory calibration data for one txpower level, on one channel,
263 * measured on one of the 2 tx chains (radio transmitter and associated
264 * antenna). EEPROM contains:
265 *
266 * 1) Temperature (degrees Celsius) of device when measurement was made.
267 *
268 * 2) Gain table idx used to achieve the target measurement power.
269 * This refers to the "well-known" gain tables (see 4965.h).
270 *
271 * 3) Actual measured output power, in half-dBm ("34" = 17 dBm).
272 *
273 * 4) RF power amplifier detector level measurement (not used).
274 */
275struct il_eeprom_calib_measure {
276 u8 temperature; /* Device temperature (Celsius) */
277 u8 gain_idx; /* Index into gain table */
278 u8 actual_pow; /* Measured RF output power, half-dBm */
279 s8 pa_det; /* Power amp detector level (not used) */
280} __packed;
281
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200282/*
283 * measurement set for one channel. EEPROM contains:
284 *
285 * 1) Channel number measured
286 *
287 * 2) Measurements for each of 3 power levels for each of 2 radio transmitters
288 * (a.k.a. "tx chains") (6 measurements altogether)
289 */
290struct il_eeprom_calib_ch_info {
291 u8 ch_num;
292 struct il_eeprom_calib_measure
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100293 measurements[EEPROM_TX_POWER_TX_CHAINS]
294 [EEPROM_TX_POWER_MEASUREMENTS];
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200295} __packed;
296
297/*
298 * txpower subband info.
299 *
300 * For each frequency subband, EEPROM contains the following:
301 *
302 * 1) First and last channels within range of the subband. "0" values
303 * indicate that this sample set is not being used.
304 *
305 * 2) Sample measurement sets for 2 channels close to the range endpoints.
306 */
307struct il_eeprom_calib_subband_info {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100308 u8 ch_from; /* channel number of lowest channel in subband */
309 u8 ch_to; /* channel number of highest channel in subband */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200310 struct il_eeprom_calib_ch_info ch1;
311 struct il_eeprom_calib_ch_info ch2;
312} __packed;
313
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200314/*
315 * txpower calibration info. EEPROM contains:
316 *
317 * 1) Factory-measured saturation power levels (maximum levels at which
318 * tx power amplifier can output a signal without too much distortion).
319 * There is one level for 2.4 GHz band and one for 5 GHz band. These
320 * values apply to all channels within each of the bands.
321 *
322 * 2) Factory-measured power supply voltage level. This is assumed to be
323 * constant (i.e. same value applies to all channels/bands) while the
324 * factory measurements are being made.
325 *
326 * 3) Up to 8 sets of factory-measured txpower calibration values.
327 * These are for different frequency ranges, since txpower gain
328 * characteristics of the analog radio circuitry vary with frequency.
329 *
330 * Not all sets need to be filled with data;
331 * struct il_eeprom_calib_subband_info contains range of channels
332 * (0 if unused) for each set of data.
333 */
334struct il_eeprom_calib_info {
335 u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
336 u8 saturation_power52; /* half-dBm */
337 __le16 voltage; /* signed */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100338 struct il_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS];
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200339} __packed;
340
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200341/* General */
342#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
343#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
344#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
345#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
346#define EEPROM_VERSION (2*0x44) /* 2 bytes */
347#define EEPROM_SKU_CAP (2*0x45) /* 2 bytes */
348#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
349#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
350#define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */
351#define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */
352
353/* The following masks are to be applied on EEPROM_RADIO_CONFIG */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100354#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */
355#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */
356#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */
357#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */
358#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */
359#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200360
361#define EEPROM_3945_RF_CFG_TYPE_MAX 0x0
362#define EEPROM_4965_RF_CFG_TYPE_MAX 0x1
363
364/*
365 * Per-channel regulatory data.
366 *
367 * Each channel that *might* be supported by iwl has a fixed location
368 * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
369 * txpower (MSB).
370 *
371 * Entries immediately below are for 20 MHz channel width. HT40 (40 MHz)
372 * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
373 *
374 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
375 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100376#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200377#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
378#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
379
380/*
381 * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
382 * 5.0 GHz channels 7, 8, 11, 12, 16
383 * (4915-5080MHz) (none of these is ever supported)
384 */
385#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
386#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
387
388/*
389 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
390 * (5170-5320MHz)
391 */
392#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
393#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
394
395/*
396 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
397 * (5500-5700MHz)
398 */
399#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
400#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
401
402/*
403 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
404 * (5725-5825MHz)
405 */
406#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
407#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
408
409/*
410 * 2.4 GHz HT40 channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11)
411 *
412 * The channel listed is the center of the lower 20 MHz half of the channel.
413 * The overall center frequency is actually 2 channels (10 MHz) above that,
414 * and the upper half of each HT40 channel is centered 4 channels (20 MHz) away
415 * from the lower half; e.g. the upper half of HT40 channel 1 is channel 5,
416 * and the overall HT40 channel width centers on channel 3.
417 *
418 * NOTE: The RXON command uses 20 MHz channel numbers to specify the
419 * control channel to which to tune. RXON also specifies whether the
420 * control channel is the upper or lower half of a HT40 channel.
421 *
422 * NOTE: 4965 does not support HT40 channels on 2.4 GHz.
423 */
424#define EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS (2*0xA0) /* 14 bytes */
425
426/*
427 * 5.2 GHz HT40 channels 36 (40), 44 (48), 52 (56), 60 (64),
428 * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161)
429 */
430#define EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS (2*0xA8) /* 22 bytes */
431
432#define EEPROM_REGULATORY_BAND_NO_HT40 (0)
433
434struct il_eeprom_ops {
435 const u32 regulatory_bands[7];
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100436 int (*acquire_semaphore) (struct il_priv *il);
437 void (*release_semaphore) (struct il_priv *il);
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200438};
439
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200440int il_eeprom_init(struct il_priv *il);
441void il_eeprom_free(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100442const u8 *il_eeprom_query_addr(const struct il_priv *il, size_t offset);
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200443u16 il_eeprom_query16(const struct il_priv *il, size_t offset);
444int il_init_channel_map(struct il_priv *il);
445void il_free_channel_map(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100446const struct il_channel_info *il_get_channel_info(const struct il_priv *il,
447 enum ieee80211_band band,
448 u16 channel);
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +0200449
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200450#define IL_NUM_SCAN_RATES (2)
451
452struct il4965_channel_tgd_info {
453 u8 type;
454 s8 max_power;
455};
456
457struct il4965_channel_tgh_info {
458 s64 last_radar_time;
459};
460
461#define IL4965_MAX_RATE (33)
462
463struct il3945_clip_group {
464 /* maximum power level to prevent clipping for each rate, derived by
465 * us from this band's saturation power in EEPROM */
466 const s8 clip_powers[IL_MAX_RATES];
467};
468
469/* current Tx power values to use, one for each rate for each channel.
470 * requested power is limited by:
471 * -- regulatory EEPROM limits for this channel
472 * -- hardware capabilities (clip-powers)
473 * -- spectrum management
474 * -- user preference (e.g. iwconfig)
475 * when requested power is set, base power idx must also be set. */
476struct il3945_channel_power_info {
477 struct il3945_tx_power tpc; /* actual radio and DSP gain settings */
478 s8 power_table_idx; /* actual (compenst'd) idx into gain table */
479 s8 base_power_idx; /* gain idx for power at factory temp. */
480 s8 requested_power; /* power (dBm) requested for this chnl/rate */
481};
482
483/* current scan Tx power values to use, one for each scan rate for each
484 * channel. */
485struct il3945_scan_power_info {
486 struct il3945_tx_power tpc; /* actual radio and DSP gain settings */
487 s8 power_table_idx; /* actual (compenst'd) idx into gain table */
488 s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
489};
490
491/*
492 * One for each channel, holds all channel setup data
493 * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
494 * with one another!
495 */
496struct il_channel_info {
497 struct il4965_channel_tgd_info tgd;
498 struct il4965_channel_tgh_info tgh;
499 struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */
500 struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for
501 * HT40 channel */
502
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100503 u8 channel; /* channel number */
504 u8 flags; /* flags copied from EEPROM */
505 s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
506 s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
507 s8 min_power; /* always 0 */
508 s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200509
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100510 u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */
511 u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200512 enum ieee80211_band band;
513
514 /* HT40 channel info */
515 s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
516 u8 ht40_flags; /* flags copied from EEPROM */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100517 u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200518
519 /* Radio/DSP gain settings for each "normal" data Tx rate.
520 * These include, in addition to RF and DSP gain, a few fields for
521 * remembering/modifying gain settings (idxes). */
522 struct il3945_channel_power_info power_info[IL4965_MAX_RATE];
523
524 /* Radio/DSP gain settings for each scan rate, for directed scans. */
525 struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES];
526};
527
528#define IL_TX_FIFO_BK 0 /* shared */
529#define IL_TX_FIFO_BE 1
530#define IL_TX_FIFO_VI 2 /* shared */
531#define IL_TX_FIFO_VO 3
532#define IL_TX_FIFO_UNUSED -1
533
534/* Minimum number of queues. MAX_NUM is defined in hw specific files.
535 * Set the minimum to accommodate the 4 standard TX queues, 1 command
536 * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
537#define IL_MIN_NUM_QUEUES 10
538
539#define IL_DEFAULT_CMD_QUEUE_NUM 4
540
541#define IEEE80211_DATA_LEN 2304
542#define IEEE80211_4ADDR_LEN 30
543#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
544#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
545
546struct il_frame {
547 union {
548 struct ieee80211_hdr frame;
549 struct il_tx_beacon_cmd beacon;
550 u8 raw[IEEE80211_FRAME_LEN];
551 u8 cmd[360];
552 } u;
553 struct list_head list;
554};
555
556#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
557#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
558#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
559
560enum {
561 CMD_SYNC = 0,
562 CMD_SIZE_NORMAL = 0,
563 CMD_NO_SKB = 0,
564 CMD_SIZE_HUGE = (1 << 0),
565 CMD_ASYNC = (1 << 1),
566 CMD_WANT_SKB = (1 << 2),
567 CMD_MAPPED = (1 << 3),
568};
569
570#define DEF_CMD_PAYLOAD_SIZE 320
571
572/**
573 * struct il_device_cmd
574 *
575 * For allocation of the command and tx queues, this establishes the overall
576 * size of the largest command we send to uCode, except for a scan command
577 * (which is relatively huge; space is allocated separately).
578 */
579struct il_device_cmd {
580 struct il_cmd_header hdr; /* uCode API */
581 union {
582 u32 flags;
583 u8 val8;
584 u16 val16;
585 u32 val32;
586 struct il_tx_cmd tx;
587 u8 payload[DEF_CMD_PAYLOAD_SIZE];
588 } __packed cmd;
589} __packed;
590
591#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd))
592
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200593struct il_host_cmd {
594 const void *data;
595 unsigned long reply_page;
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100596 void (*callback) (struct il_priv *il, struct il_device_cmd *cmd,
597 struct il_rx_pkt *pkt);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200598 u32 flags;
599 u16 len;
600 u8 id;
601};
602
603#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
604#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
605#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
606
607/**
608 * struct il_rx_queue - Rx queue
609 * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
610 * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
611 * @read: Shared idx to newest available Rx buffer
612 * @write: Shared idx to oldest written Rx packet
613 * @free_count: Number of pre-allocated buffers in rx_free
614 * @rx_free: list of free SKBs for use
615 * @rx_used: List of Rx buffers with no SKB
616 * @need_update: flag to indicate we need to update read/write idx
617 * @rb_stts: driver's pointer to receive buffer status
618 * @rb_stts_dma: bus address of receive buffer status
619 *
620 * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs
621 */
622struct il_rx_queue {
623 __le32 *bd;
624 dma_addr_t bd_dma;
625 struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
626 struct il_rx_buf *queue[RX_QUEUE_SIZE];
627 u32 read;
628 u32 write;
629 u32 free_count;
630 u32 write_actual;
631 struct list_head rx_free;
632 struct list_head rx_used;
633 int need_update;
634 struct il_rb_status *rb_stts;
635 dma_addr_t rb_stts_dma;
636 spinlock_t lock;
637};
638
639#define IL_SUPPORTED_RATES_IE_LEN 8
640
641#define MAX_TID_COUNT 9
642
643#define IL_INVALID_RATE 0xFF
644#define IL_INVALID_VALUE -1
645
646/**
647 * struct il_ht_agg -- aggregation status while waiting for block-ack
648 * @txq_id: Tx queue used for Tx attempt
649 * @frame_count: # frames attempted by Tx command
650 * @wait_for_ba: Expect block-ack before next Tx reply
651 * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win
652 * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win
653 * @bitmap1: High order, one bit for each frame pending ACK in Tx win
654 * @rate_n_flags: Rate at which Tx was attempted
655 *
656 * If C_TX indicates that aggregation was attempted, driver must wait
657 * for block ack (N_COMPRESSED_BA). This struct stores tx reply info
658 * until block ack arrives.
659 */
660struct il_ht_agg {
661 u16 txq_id;
662 u16 frame_count;
663 u16 wait_for_ba;
664 u16 start_idx;
665 u64 bitmap;
666 u32 rate_n_flags;
667#define IL_AGG_OFF 0
668#define IL_AGG_ON 1
669#define IL_EMPTYING_HW_QUEUE_ADDBA 2
670#define IL_EMPTYING_HW_QUEUE_DELBA 3
671 u8 state;
672};
673
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200674struct il_tid_data {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100675 u16 seq_number; /* 4965 only */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200676 u16 tfds_in_queue;
677 struct il_ht_agg agg;
678};
679
680struct il_hw_key {
681 u32 cipher;
682 int keylen;
683 u8 keyidx;
684 u8 key[32];
685};
686
687union il_ht_rate_supp {
688 u16 rates;
689 struct {
690 u8 siso_rate;
691 u8 mimo_rate;
692 };
693};
694
695#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
696#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
697#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
698#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
699#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
700#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
701#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
702
703/*
704 * Maximal MPDU density for TX aggregation
705 * 4 - 2us density
706 * 5 - 4us density
707 * 6 - 8us density
708 * 7 - 16us density
709 */
710#define CFG_HT_MPDU_DENSITY_2USEC (0x4)
711#define CFG_HT_MPDU_DENSITY_4USEC (0x5)
712#define CFG_HT_MPDU_DENSITY_8USEC (0x6)
713#define CFG_HT_MPDU_DENSITY_16USEC (0x7)
714#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
715#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
716#define CFG_HT_MPDU_DENSITY_MIN (0x1)
717
718struct il_ht_config {
719 bool single_chain_sufficient;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100720 enum ieee80211_smps_mode smps; /* current smps mode */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200721};
722
723/* QoS structures */
724struct il_qos_info {
725 int qos_active;
726 struct il_qosparam_cmd def_qos_parm;
727};
728
729/*
730 * Structure should be accessed with sta_lock held. When station addition
731 * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only
732 * the commands (il_addsta_cmd and il_link_quality_cmd) without
733 * sta_lock held.
734 */
735struct il_station_entry {
736 struct il_addsta_cmd sta;
737 struct il_tid_data tid[MAX_TID_COUNT];
Stanislaw Gruszka6aa0c252012-02-03 17:31:46 +0100738 u8 used;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200739 struct il_hw_key keyinfo;
740 struct il_link_quality_cmd *lq;
741};
742
743struct il_station_priv_common {
744 struct il_rxon_context *ctx;
745 u8 sta_id;
746};
747
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200748/**
749 * struct il_vif_priv - driver's ilate per-interface information
750 *
751 * When mac80211 allocates a virtual interface, it can allocate
752 * space for us to put data into.
753 */
754struct il_vif_priv {
755 struct il_rxon_context *ctx;
756 u8 ibss_bssid_sta_id;
757};
758
759/* one for each uCode image (inst/data, boot/init/runtime) */
760struct fw_desc {
761 void *v_addr; /* access by driver */
762 dma_addr_t p_addr; /* access by card's busmaster DMA */
763 u32 len; /* bytes */
764};
765
766/* uCode file layout */
767struct il_ucode_header {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100768 __le32 ver; /* major/minor/API/serial */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200769 struct {
770 __le32 inst_size; /* bytes of runtime code */
771 __le32 data_size; /* bytes of runtime data */
772 __le32 init_size; /* bytes of init code */
773 __le32 init_data_size; /* bytes of init data */
774 __le32 boot_size; /* bytes of bootstrap code */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100775 u8 data[0]; /* in same order as sizes */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200776 } v1;
777};
778
779struct il4965_ibss_seq {
780 u8 mac[ETH_ALEN];
781 u16 seq_num;
782 u16 frag_num;
783 unsigned long packet_time;
784 struct list_head list;
785};
786
787struct il_sensitivity_ranges {
788 u16 min_nrg_cck;
789 u16 max_nrg_cck;
790
791 u16 nrg_th_cck;
792 u16 nrg_th_ofdm;
793
794 u16 auto_corr_min_ofdm;
795 u16 auto_corr_min_ofdm_mrc;
796 u16 auto_corr_min_ofdm_x1;
797 u16 auto_corr_min_ofdm_mrc_x1;
798
799 u16 auto_corr_max_ofdm;
800 u16 auto_corr_max_ofdm_mrc;
801 u16 auto_corr_max_ofdm_x1;
802 u16 auto_corr_max_ofdm_mrc_x1;
803
804 u16 auto_corr_max_cck;
805 u16 auto_corr_max_cck_mrc;
806 u16 auto_corr_min_cck;
807 u16 auto_corr_min_cck_mrc;
808
809 u16 barker_corr_th_min;
810 u16 barker_corr_th_min_mrc;
811 u16 nrg_th_cca;
812};
813
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200814#define KELVIN_TO_CELSIUS(x) ((x)-273)
815#define CELSIUS_TO_KELVIN(x) ((x)+273)
816
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200817/**
818 * struct il_hw_params
Stanislaw Gruszkab16db502012-02-03 17:31:44 +0100819 * @bcast_id: f/w broadcast station ID
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200820 * @max_txq_num: Max # Tx queues supported
821 * @dma_chnl_num: Number of Tx DMA/FIFO channels
822 * @scd_bc_tbls_size: size of scheduler byte count tables
823 * @tfd_size: TFD size
824 * @tx/rx_chains_num: Number of TX/RX chains
825 * @valid_tx/rx_ant: usable antennas
826 * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
827 * @max_rxq_log: Log-base-2 of max_rxq_size
828 * @rx_page_order: Rx buffer page order
829 * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
830 * @max_stations:
831 * @ht40_channel: is 40MHz width possible in band 2.4
832 * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
833 * @sw_crypto: 0 for hw, 1 for sw
834 * @max_xxx_size: for ucode uses
835 * @ct_kill_threshold: temperature threshold
836 * @beacon_time_tsf_bits: number of valid tsf bits for beacon time
837 * @struct il_sensitivity_ranges: range of sensitivity values
838 */
839struct il_hw_params {
Stanislaw Gruszkab16db502012-02-03 17:31:44 +0100840 u8 bcast_id;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200841 u8 max_txq_num;
842 u8 dma_chnl_num;
843 u16 scd_bc_tbls_size;
844 u32 tfd_size;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100845 u8 tx_chains_num;
846 u8 rx_chains_num;
847 u8 valid_tx_ant;
848 u8 valid_rx_ant;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200849 u16 max_rxq_size;
850 u16 max_rxq_log;
851 u32 rx_page_order;
852 u32 rx_wrt_ptr_reg;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100853 u8 max_stations;
854 u8 ht40_channel;
855 u8 max_beacon_itrvl; /* in 1024 ms */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200856 u32 max_inst_size;
857 u32 max_data_size;
858 u32 max_bsm_size;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100859 u32 ct_kill_threshold; /* value in hw-dependent units */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200860 u16 beacon_time_tsf_bits;
861 const struct il_sensitivity_ranges *sens;
862};
863
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200864/******************************************************************************
865 *
866 * Functions implemented in core module which are forward declared here
867 * for use by iwl-[4-5].c
868 *
869 * NOTE: The implementation of these functions are not hardware specific
870 * which is why they are in the core module files.
871 *
872 * Naming convention --
873 * il_ <-- Is part of iwlwifi
874 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
875 * il4965_bg_ <-- Called from work queue context
876 * il4965_mac_ <-- mac80211 callback
877 *
878 ****************************************************************************/
879extern void il4965_update_chain_flags(struct il_priv *il);
880extern const u8 il_bcast_addr[ETH_ALEN];
881extern int il_queue_space(const struct il_queue *q);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100882static inline int
883il_queue_used(const struct il_queue *q, int i)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200884{
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100885 return q->write_ptr >= q->read_ptr ? (i >= q->read_ptr &&
886 i < q->write_ptr) : !(i <
887 q->read_ptr
888 && i >=
889 q->
890 write_ptr);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200891}
892
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100893static inline u8
894il_get_cmd_idx(struct il_queue *q, u32 idx, int is_huge)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200895{
896 /*
897 * This is for init calibration result and scan command which
898 * required buffer > TFD_MAX_PAYLOAD_SIZE,
899 * the big buffer at end of command array
900 */
901 if (is_huge)
902 return q->n_win; /* must be power of 2 */
903
904 /* Otherwise, use normal size buffers */
905 return idx & (q->n_win - 1);
906}
907
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200908struct il_dma_ptr {
909 dma_addr_t dma;
910 void *addr;
911 size_t size;
912};
913
914#define IL_OPERATION_MODE_AUTO 0
915#define IL_OPERATION_MODE_HT_ONLY 1
916#define IL_OPERATION_MODE_MIXED 2
917#define IL_OPERATION_MODE_20MHZ 3
918
919#define IL_TX_CRC_SIZE 4
920#define IL_TX_DELIMITER_SIZE 4
921
922#define TX_POWER_IL_ILLEGAL_VOLTAGE -10000
923
924/* Sensitivity and chain noise calibration */
925#define INITIALIZATION_VALUE 0xFFFF
926#define IL4965_CAL_NUM_BEACONS 20
927#define IL_CAL_NUM_BEACONS 16
928#define MAXIMUM_ALLOWED_PATHLOSS 15
929
930#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
931
932#define MAX_FA_OFDM 50
933#define MIN_FA_OFDM 5
934#define MAX_FA_CCK 50
935#define MIN_FA_CCK 5
936
937#define AUTO_CORR_STEP_OFDM 1
938
939#define AUTO_CORR_STEP_CCK 3
940#define AUTO_CORR_MAX_TH_CCK 160
941
942#define NRG_DIFF 2
943#define NRG_STEP_CCK 2
944#define NRG_MARGIN 8
945#define MAX_NUMBER_CCK_NO_FA 100
946
947#define AUTO_CORR_CCK_MIN_VAL_DEF (125)
948
949#define CHAIN_A 0
950#define CHAIN_B 1
951#define CHAIN_C 2
952#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
953#define ALL_BAND_FILTER 0xFF00
954#define IN_BAND_FILTER 0xFF
955#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
956
957#define NRG_NUM_PREV_STAT_L 20
958#define NUM_RX_CHAINS 3
959
960enum il4965_false_alarm_state {
961 IL_FA_TOO_MANY = 0,
962 IL_FA_TOO_FEW = 1,
963 IL_FA_GOOD_RANGE = 2,
964};
965
966enum il4965_chain_noise_state {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100967 IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200968 IL_CHAIN_NOISE_ACCUMULATE,
969 IL_CHAIN_NOISE_CALIBRATED,
970 IL_CHAIN_NOISE_DONE,
971};
972
973enum il4965_calib_enabled_state {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100974 IL_CALIB_DISABLED = 0, /* must be 0 */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +0200975 IL_CALIB_ENABLED = 1,
976};
977
978/*
979 * enum il_calib
980 * defines the order in which results of initial calibrations
981 * should be sent to the runtime uCode
982 */
983enum il_calib {
984 IL_CALIB_MAX,
985};
986
987/* Opaque calibration results */
988struct il_calib_result {
989 void *buf;
990 size_t buf_len;
991};
992
993enum ucode_type {
994 UCODE_NONE = 0,
995 UCODE_INIT,
996 UCODE_RT
997};
998
999/* Sensitivity calib data */
1000struct il_sensitivity_data {
1001 u32 auto_corr_ofdm;
1002 u32 auto_corr_ofdm_mrc;
1003 u32 auto_corr_ofdm_x1;
1004 u32 auto_corr_ofdm_mrc_x1;
1005 u32 auto_corr_cck;
1006 u32 auto_corr_cck_mrc;
1007
1008 u32 last_bad_plcp_cnt_ofdm;
1009 u32 last_fa_cnt_ofdm;
1010 u32 last_bad_plcp_cnt_cck;
1011 u32 last_fa_cnt_cck;
1012
1013 u32 nrg_curr_state;
1014 u32 nrg_prev_state;
1015 u32 nrg_value[10];
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001016 u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001017 u32 nrg_silence_ref;
1018 u32 nrg_energy_idx;
1019 u32 nrg_silence_idx;
1020 u32 nrg_th_cck;
1021 s32 nrg_auto_corr_silence_diff;
1022 u32 num_in_cck_no_fa;
1023 u32 nrg_th_ofdm;
1024
1025 u16 barker_corr_th_min;
1026 u16 barker_corr_th_min_mrc;
1027 u16 nrg_th_cca;
1028};
1029
1030/* Chain noise (differential Rx gain) calib data */
1031struct il_chain_noise_data {
1032 u32 active_chains;
1033 u32 chain_noise_a;
1034 u32 chain_noise_b;
1035 u32 chain_noise_c;
1036 u32 chain_signal_a;
1037 u32 chain_signal_b;
1038 u32 chain_signal_c;
1039 u16 beacon_count;
1040 u8 disconn_array[NUM_RX_CHAINS];
1041 u8 delta_gain_code[NUM_RX_CHAINS];
1042 u8 radio_write;
1043 u8 state;
1044};
1045
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001046#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001047#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
1048
1049#define IL_TRAFFIC_ENTRIES (256)
1050#define IL_TRAFFIC_ENTRY_SIZE (64)
1051
1052enum {
1053 MEASUREMENT_READY = (1 << 0),
1054 MEASUREMENT_ACTIVE = (1 << 1),
1055};
1056
1057/* interrupt stats */
1058struct isr_stats {
1059 u32 hw;
1060 u32 sw;
1061 u32 err_code;
1062 u32 sch;
1063 u32 alive;
1064 u32 rfkill;
1065 u32 ctkill;
1066 u32 wakeup;
1067 u32 rx;
1068 u32 handlers[IL_CN_MAX];
1069 u32 tx;
1070 u32 unhandled;
1071};
1072
1073/* management stats */
1074enum il_mgmt_stats {
1075 MANAGEMENT_ASSOC_REQ = 0,
1076 MANAGEMENT_ASSOC_RESP,
1077 MANAGEMENT_REASSOC_REQ,
1078 MANAGEMENT_REASSOC_RESP,
1079 MANAGEMENT_PROBE_REQ,
1080 MANAGEMENT_PROBE_RESP,
1081 MANAGEMENT_BEACON,
1082 MANAGEMENT_ATIM,
1083 MANAGEMENT_DISASSOC,
1084 MANAGEMENT_AUTH,
1085 MANAGEMENT_DEAUTH,
1086 MANAGEMENT_ACTION,
1087 MANAGEMENT_MAX,
1088};
1089/* control stats */
1090enum il_ctrl_stats {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001091 CONTROL_BACK_REQ = 0,
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001092 CONTROL_BACK,
1093 CONTROL_PSPOLL,
1094 CONTROL_RTS,
1095 CONTROL_CTS,
1096 CONTROL_ACK,
1097 CONTROL_CFEND,
1098 CONTROL_CFENDACK,
1099 CONTROL_MAX,
1100};
1101
1102struct traffic_stats {
1103#ifdef CONFIG_IWLEGACY_DEBUGFS
1104 u32 mgmt[MANAGEMENT_MAX];
1105 u32 ctrl[CONTROL_MAX];
1106 u32 data_cnt;
1107 u64 data_bytes;
1108#endif
1109};
1110
1111/*
1112 * host interrupt timeout value
1113 * used with setting interrupt coalescing timer
1114 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
1115 *
1116 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
1117 * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
1118 */
1119#define IL_HOST_INT_TIMEOUT_MAX (0xFF)
1120#define IL_HOST_INT_TIMEOUT_DEF (0x40)
1121#define IL_HOST_INT_TIMEOUT_MIN (0x0)
1122#define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
1123#define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
1124#define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
1125
1126#define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
1127
1128/* TX queue watchdog timeouts in mSecs */
1129#define IL_DEF_WD_TIMEOUT (2000)
1130#define IL_LONG_WD_TIMEOUT (10000)
1131#define IL_MAX_WD_TIMEOUT (120000)
1132
1133struct il_force_reset {
1134 int reset_request_count;
1135 int reset_success_count;
1136 int reset_reject_count;
1137 unsigned long reset_duration;
1138 unsigned long last_force_reset_jiffies;
1139};
1140
1141/* extend beacon time format bit shifting */
1142/*
1143 * for _3945 devices
1144 * bits 31:24 - extended
1145 * bits 23:0 - interval
1146 */
1147#define IL3945_EXT_BEACON_TIME_POS 24
1148/*
1149 * for _4965 devices
1150 * bits 31:22 - extended
1151 * bits 21:0 - interval
1152 */
1153#define IL4965_EXT_BEACON_TIME_POS 22
1154
1155struct il_rxon_context {
1156 struct ieee80211_vif *vif;
1157
1158 const u8 *ac_to_fifo;
1159 const u8 *ac_to_queue;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001160
1161 /*
1162 * We could use the vif to indicate active, but we
1163 * also need it to be active during disabling when
1164 * we already removed the vif for type setting.
1165 */
1166 bool always_active, is_active;
1167
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001168 u32 interface_modes, exclusive_interface_modes;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001169
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001170 struct il_qos_info qos_data;
1171
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001172 __le32 station_flags;
1173
1174 struct {
1175 bool non_gf_sta_present;
1176 u8 protection;
1177 bool enabled, is_40mhz;
1178 u8 extension_chan_offset;
1179 } ht;
1180};
1181
Stanislaw Gruszka99412002011-08-31 13:53:04 +02001182struct il_power_mgr {
1183 struct il_powertable_cmd sleep_cmd;
1184 struct il_powertable_cmd sleep_cmd_next;
1185 int debug_sleep_level_override;
1186 bool pci_pm;
1187};
1188
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001189struct il_priv {
1190
1191 /* ieee device used by generic ieee processing code */
1192 struct ieee80211_hw *hw;
1193 struct ieee80211_channel *ieee_channels;
1194 struct ieee80211_rate *ieee_rates;
1195 struct il_cfg *cfg;
1196
1197 /* temporary frame storage list */
1198 struct list_head free_frames;
1199 int frames_count;
1200
1201 enum ieee80211_band band;
1202 int alloc_rxb_page;
1203
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001204 void (*handlers[IL_CN_MAX]) (struct il_priv *il,
1205 struct il_rx_buf *rxb);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001206
1207 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
1208
1209 /* spectrum measurement report caching */
1210 struct il_spectrum_notification measure_report;
1211 u8 measurement_status;
1212
1213 /* ucode beacon time */
1214 u32 ucode_beacon_time;
1215 int missed_beacon_threshold;
1216
1217 /* track IBSS manager (last beacon) status */
1218 u32 ibss_manager;
1219
1220 /* force reset */
1221 struct il_force_reset force_reset;
1222
1223 /* we allocate array of il_channel_info for NIC's valid channels.
1224 * Access via channel # using indirect idx array */
1225 struct il_channel_info *channel_info; /* channel info array */
1226 u8 channel_count; /* # of channels */
1227
1228 /* thermal calibration */
1229 s32 temperature; /* degrees Kelvin */
1230 s32 last_temperature;
1231
1232 /* init calibration results */
1233 struct il_calib_result calib_results[IL_CALIB_MAX];
1234
1235 /* Scan related variables */
1236 unsigned long scan_start;
1237 unsigned long scan_start_tsf;
1238 void *scan_cmd;
1239 enum ieee80211_band scan_band;
1240 struct cfg80211_scan_request *scan_request;
1241 struct ieee80211_vif *scan_vif;
1242 u8 scan_tx_ant[IEEE80211_NUM_BANDS];
1243 u8 mgmt_tx_ant;
1244
1245 /* spinlock */
1246 spinlock_t lock; /* protect general shared data */
1247 spinlock_t hcmd_lock; /* protect hcmd */
1248 spinlock_t reg_lock; /* protect hw register access */
1249 struct mutex mutex;
1250
1251 /* basic pci-network driver stuff */
1252 struct pci_dev *pci_dev;
1253
1254 /* pci hardware address support */
1255 void __iomem *hw_base;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001256 u32 hw_rev;
1257 u32 hw_wa_rev;
1258 u8 rev_id;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001259
1260 /* command queue number */
1261 u8 cmd_queue;
1262
1263 /* max number of station keys */
1264 u8 sta_key_max_num;
1265
1266 /* EEPROM MAC addresses */
1267 struct mac_address addresses[1];
1268
1269 /* uCode images, save to reload in case of failure */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001270 int fw_idx; /* firmware we're trying to load */
1271 u32 ucode_ver; /* version of ucode, copy of
1272 il_ucode.ver */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001273 struct fw_desc ucode_code; /* runtime inst */
1274 struct fw_desc ucode_data; /* runtime data original */
1275 struct fw_desc ucode_data_backup; /* runtime data save/restore */
1276 struct fw_desc ucode_init; /* initialization inst */
1277 struct fw_desc ucode_init_data; /* initialization data */
1278 struct fw_desc ucode_boot; /* bootstrap inst */
1279 enum ucode_type ucode_type;
1280 u8 ucode_write_complete; /* the image write is complete */
1281 char firmware_name[25];
1282
1283 struct il_rxon_context ctx;
1284
Stanislaw Gruszkac8b03952012-02-03 17:31:37 +01001285 /*
1286 * We declare this const so it can only be
1287 * changed via explicit cast within the
1288 * routines that actually update the physical
1289 * hardware.
1290 */
1291 const struct il_rxon_cmd active;
1292 struct il_rxon_cmd staging;
1293
1294 struct il_rxon_time_cmd timing;
1295
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001296 __le16 switch_channel;
1297
1298 /* 1st responses from initialize and runtime uCode images.
1299 * _4965's initialize alive response contains some calibration data. */
1300 struct il_init_alive_resp card_alive_init;
1301 struct il_alive_resp card_alive;
1302
1303 u16 active_rate;
1304
1305 u8 start_calib;
1306 struct il_sensitivity_data sensitivity_data;
1307 struct il_chain_noise_data chain_noise_data;
1308 __le16 sensitivity_tbl[HD_TBL_SIZE];
1309
1310 struct il_ht_config current_ht_config;
1311
1312 /* Rate scaling data */
1313 u8 retry_rate;
1314
1315 wait_queue_head_t wait_command_queue;
1316
1317 int activity_timer_active;
1318
1319 /* Rx and Tx DMA processing queues */
1320 struct il_rx_queue rxq;
1321 struct il_tx_queue *txq;
1322 unsigned long txq_ctx_active_msk;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001323 struct il_dma_ptr kw; /* keep warm address */
1324 struct il_dma_ptr scd_bc_tbls;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001325
1326 u32 scd_base_addr; /* scheduler sram base address */
1327
1328 unsigned long status;
1329
1330 /* counts mgmt, ctl, and data packets */
1331 struct traffic_stats tx_stats;
1332 struct traffic_stats rx_stats;
1333
1334 /* counts interrupts */
1335 struct isr_stats isr_stats;
1336
1337 struct il_power_mgr power_data;
1338
1339 /* context information */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001340 u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001341
1342 /* station table variables */
1343
1344 /* Note: if lock and sta_lock are needed, lock must be acquired first */
1345 spinlock_t sta_lock;
1346 int num_stations;
1347 struct il_station_entry stations[IL_STATION_COUNT];
1348 unsigned long ucode_key_table;
1349
1350 /* queue refcounts */
1351#define IL_MAX_HW_QUEUES 32
1352 unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)];
1353 /* for each AC */
1354 atomic_t queue_stop_count[4];
1355
1356 /* Indication if ieee80211_ops->open has been called */
1357 u8 is_open;
1358
1359 u8 mac80211_registered;
1360
1361 /* eeprom -- this is in the card's little endian byte order */
1362 u8 *eeprom;
1363 struct il_eeprom_calib_info *calib_info;
1364
1365 enum nl80211_iftype iw_mode;
1366
1367 /* Last Rx'd beacon timestamp */
1368 u64 timestamp;
1369
1370 union {
1371#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
1372 struct {
1373 void *shared_virt;
1374 dma_addr_t shared_phys;
1375
1376 struct delayed_work thermal_periodic;
1377 struct delayed_work rfkill_poll;
1378
1379 struct il3945_notif_stats stats;
1380#ifdef CONFIG_IWLEGACY_DEBUGFS
1381 struct il3945_notif_stats accum_stats;
1382 struct il3945_notif_stats delta_stats;
1383 struct il3945_notif_stats max_delta;
1384#endif
1385
1386 u32 sta_supp_rates;
1387 int last_rx_rssi; /* From Rx packet stats */
1388
1389 /* Rx'd packet timing information */
1390 u32 last_beacon_time;
1391 u64 last_tsf;
1392
1393 /*
1394 * each calibration channel group in the
1395 * EEPROM has a derived clip setting for
1396 * each rate.
1397 */
1398 const struct il3945_clip_group clip_groups[5];
1399
1400 } _3945;
1401#endif
1402#if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE)
1403 struct {
1404 struct il_rx_phy_res last_phy_res;
1405 bool last_phy_res_valid;
1406
1407 struct completion firmware_loading_complete;
1408
1409 /*
1410 * chain noise reset and gain commands are the
1411 * two extra calibration commands follows the standard
1412 * phy calibration commands
1413 */
1414 u8 phy_calib_chain_noise_reset_cmd;
1415 u8 phy_calib_chain_noise_gain_cmd;
1416
Stanislaw Gruszkad735f922012-02-03 17:31:48 +01001417 u8 key_mapping_keys;
1418 struct il_wep_key wep_keys[WEP_KEYS_MAX];
1419
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001420 struct il_notif_stats stats;
1421#ifdef CONFIG_IWLEGACY_DEBUGFS
1422 struct il_notif_stats accum_stats;
1423 struct il_notif_stats delta_stats;
1424 struct il_notif_stats max_delta;
1425#endif
1426
1427 } _4965;
1428#endif
1429 };
1430
1431 struct il_hw_params hw_params;
1432
1433 u32 inta_mask;
1434
1435 struct workqueue_struct *workqueue;
1436
1437 struct work_struct restart;
1438 struct work_struct scan_completed;
1439 struct work_struct rx_replenish;
1440 struct work_struct abort_scan;
1441
1442 struct il_rxon_context *beacon_ctx;
1443 struct sk_buff *beacon_skb;
1444
1445 struct work_struct tx_flush;
1446
1447 struct tasklet_struct irq_tasklet;
1448
1449 struct delayed_work init_alive_start;
1450 struct delayed_work alive_start;
1451 struct delayed_work scan_check;
1452
1453 /* TX Power */
1454 s8 tx_power_user_lmt;
1455 s8 tx_power_device_lmt;
1456 s8 tx_power_next;
1457
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001458#ifdef CONFIG_IWLEGACY_DEBUG
1459 /* debugging info */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001460 u32 debug_level; /* per device debugging will override global
1461 il_debug_level if set */
1462#endif /* CONFIG_IWLEGACY_DEBUG */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001463#ifdef CONFIG_IWLEGACY_DEBUGFS
1464 /* debugfs */
1465 u16 tx_traffic_idx;
1466 u16 rx_traffic_idx;
1467 u8 *tx_traffic;
1468 u8 *rx_traffic;
1469 struct dentry *debugfs_dir;
1470 u32 dbgfs_sram_offset, dbgfs_sram_len;
1471 bool disable_ht40;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001472#endif /* CONFIG_IWLEGACY_DEBUGFS */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001473
1474 struct work_struct txpower_work;
1475 u32 disable_sens_cal;
1476 u32 disable_chain_noise_cal;
1477 u32 disable_tx_power_cal;
1478 struct work_struct run_time_calib_work;
1479 struct timer_list stats_periodic;
1480 struct timer_list watchdog;
1481 bool hw_ready;
1482
1483 struct led_classdev led;
1484 unsigned long blink_on, blink_off;
1485 bool led_registered;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001486}; /*il_priv */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001487
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001488static inline void
1489il_txq_ctx_activate(struct il_priv *il, int txq_id)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001490{
1491 set_bit(txq_id, &il->txq_ctx_active_msk);
1492}
1493
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001494static inline void
1495il_txq_ctx_deactivate(struct il_priv *il, int txq_id)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001496{
1497 clear_bit(txq_id, &il->txq_ctx_active_msk);
1498}
1499
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001500static inline struct ieee80211_hdr *
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001501il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001502{
1503 if (il->txq[txq_id].txb[idx].skb)
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001504 return (struct ieee80211_hdr *)il->txq[txq_id].txb[idx].skb->
1505 data;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001506 return NULL;
1507}
1508
1509static inline struct il_rxon_context *
1510il_rxon_ctx_from_vif(struct ieee80211_vif *vif)
1511{
1512 struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
1513
1514 return vif_priv->ctx;
1515}
1516
1517#define for_each_context(il, _ctx) \
1518 for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++)
1519
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001520static inline int
1521il_is_associated(struct il_priv *il)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001522{
Stanislaw Gruszkac8b03952012-02-03 17:31:37 +01001523 return (il->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001524}
1525
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001526static inline int
1527il_is_any_associated(struct il_priv *il)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001528{
1529 return il_is_associated(il);
1530}
1531
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001532static inline int
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001533il_is_channel_valid(const struct il_channel_info *ch_info)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001534{
1535 if (ch_info == NULL)
1536 return 0;
1537 return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
1538}
1539
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001540static inline int
1541il_is_channel_radar(const struct il_channel_info *ch_info)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001542{
1543 return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
1544}
1545
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001546static inline u8
1547il_is_channel_a_band(const struct il_channel_info *ch_info)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001548{
1549 return ch_info->band == IEEE80211_BAND_5GHZ;
1550}
1551
1552static inline int
1553il_is_channel_passive(const struct il_channel_info *ch)
1554{
1555 return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
1556}
1557
1558static inline int
1559il_is_channel_ibss(const struct il_channel_info *ch)
1560{
1561 return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0;
1562}
1563
1564static inline void
1565__il_free_pages(struct il_priv *il, struct page *page)
1566{
1567 __free_pages(page, il->hw_params.rx_page_order);
1568 il->alloc_rxb_page--;
1569}
1570
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001571static inline void
1572il_free_pages(struct il_priv *il, unsigned long page)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001573{
1574 free_pages(page, il->hw_params.rx_page_order);
1575 il->alloc_rxb_page--;
1576}
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001577
1578#define IWLWIFI_VERSION "in-tree:"
1579#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation"
1580#define DRV_AUTHOR "<ilw@linux.intel.com>"
1581
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001582#define IL_PCI_DEVICE(dev, subdev, cfg) \
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001583 .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
1584 .subvendor = PCI_ANY_ID, .subdevice = (subdev), \
1585 .driver_data = (kernel_ulong_t)&(cfg)
1586
1587#define TIME_UNIT 1024
1588
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001589#define IL_SKU_G 0x1
1590#define IL_SKU_A 0x2
1591#define IL_SKU_N 0x8
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001592
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001593#define IL_CMD(x) case x: return #x
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001594
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001595/* Size of one Rx buffer in host DRAM */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001596#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02001597#define IL_RX_BUF_SIZE_4K (4 * 1024)
1598#define IL_RX_BUF_SIZE_8K (8 * 1024)
1599
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001600struct il_hcmd_ops {
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001601 int (*rxon_assoc) (struct il_priv *il, struct il_rxon_context *ctx);
1602 int (*commit_rxon) (struct il_priv *il, struct il_rxon_context *ctx);
1603 void (*set_rxon_chain) (struct il_priv *il,
1604 struct il_rxon_context *ctx);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001605};
1606
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001607struct il_hcmd_utils_ops {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001608 u16(*get_hcmd_size) (u8 cmd_id, u16 len);
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001609 u16(*build_addsta_hcmd) (const struct il_addsta_cmd *cmd, u8 *data);
1610 int (*request_scan) (struct il_priv *il, struct ieee80211_vif *vif);
1611 void (*post_scan) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001612};
1613
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001614struct il_apm_ops {
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001615 int (*init) (struct il_priv *il);
1616 void (*config) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001617};
1618
Greg Dietsche9b5e2f42011-09-06 19:11:35 -05001619#ifdef CONFIG_IWLEGACY_DEBUGFS
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001620struct il_debugfs_ops {
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001621 ssize_t(*rx_stats_read) (struct file *file, char __user *user_buf,
1622 size_t count, loff_t *ppos);
1623 ssize_t(*tx_stats_read) (struct file *file, char __user *user_buf,
1624 size_t count, loff_t *ppos);
1625 ssize_t(*general_stats_read) (struct file *file,
1626 char __user *user_buf, size_t count,
1627 loff_t *ppos);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001628};
Greg Dietsche9b5e2f42011-09-06 19:11:35 -05001629#endif
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001630
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001631struct il_temp_ops {
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001632 void (*temperature) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001633};
1634
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001635struct il_lib_ops {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001636 /* set hw dependent parameters */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001637 int (*set_hw_params) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001638 /* Handling TX */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001639 void (*txq_update_byte_cnt_tbl) (struct il_priv *il,
1640 struct il_tx_queue *txq,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001641 u16 byte_cnt);
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001642 int (*txq_attach_buf_to_tfd) (struct il_priv *il,
1643 struct il_tx_queue *txq, dma_addr_t addr,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001644 u16 len, u8 reset, u8 pad);
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001645 void (*txq_free_tfd) (struct il_priv *il, struct il_tx_queue *txq);
1646 int (*txq_init) (struct il_priv *il, struct il_tx_queue *txq);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001647 /* setup Rx handler */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001648 void (*handler_setup) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001649 /* alive notification after init uCode load */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001650 void (*init_alive_start) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001651 /* check validity of rtc data address */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001652 int (*is_valid_rtc_data_addr) (u32 addr);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001653 /* 1st ucode load */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001654 int (*load_ucode) (struct il_priv *il);
Stanislaw Gruszka1ba2f122011-06-08 15:28:27 +02001655
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001656 void (*dump_nic_error_log) (struct il_priv *il);
1657 int (*dump_fh) (struct il_priv *il, char **buf, bool display);
1658 int (*set_channel_switch) (struct il_priv *il,
1659 struct ieee80211_channel_switch *ch_switch);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001660 /* power management */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001661 struct il_apm_ops apm_ops;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001662
1663 /* power */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001664 int (*send_tx_power) (struct il_priv *il);
1665 void (*update_chain_flags) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001666
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +02001667 /* eeprom operations */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001668 struct il_eeprom_ops eeprom_ops;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001669
1670 /* temperature */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001671 struct il_temp_ops temp_ops;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001672
Greg Dietsche9b5e2f42011-09-06 19:11:35 -05001673#ifdef CONFIG_IWLEGACY_DEBUGFS
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001674 struct il_debugfs_ops debugfs_ops;
Greg Dietsche9b5e2f42011-09-06 19:11:35 -05001675#endif
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001676
1677};
1678
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001679struct il_led_ops {
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001680 int (*cmd) (struct il_priv *il, struct il_led_cmd *led_cmd);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001681};
1682
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001683struct il_legacy_ops {
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001684 void (*post_associate) (struct il_priv *il);
1685 void (*config_ap) (struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001686 /* station management */
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001687 int (*update_bcast_stations) (struct il_priv *il);
1688 int (*manage_ibss_station) (struct il_priv *il,
1689 struct ieee80211_vif *vif, bool add);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001690};
1691
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001692struct il_ops {
1693 const struct il_lib_ops *lib;
1694 const struct il_hcmd_ops *hcmd;
1695 const struct il_hcmd_utils_ops *utils;
1696 const struct il_led_ops *led;
1697 const struct il_nic_ops *nic;
1698 const struct il_legacy_ops *legacy;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001699 const struct ieee80211_ops *ieee80211_ops;
1700};
1701
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001702struct il_mod_params {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001703 int sw_crypto; /* def: 0 = using hardware encryption */
1704 int disable_hw_scan; /* def: 0 = use h/w scan */
1705 int num_of_queues; /* def: HW dependent */
1706 int disable_11n; /* def: 0 = 11n capabilities enabled */
1707 int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001708 int antenna; /* def: 0 = both antennas (use diversity) */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001709 int restart_fw; /* def: 1 = restart firmware */
1710};
1711
1712/*
1713 * @led_compensation: compensate on the led on/off time per HW according
1714 * to the deviation to achieve the desired led frequency.
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +02001715 * The detail algorithm is described in common.c
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001716 * @chain_noise_num_beacons: number of beacons used to compute chain noise
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001717 * @wd_timeout: TX queues watchdog timeout
1718 * @temperature_kelvin: temperature report by uCode in kelvin
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001719 * @ucode_tracing: support ucode continuous tracing
1720 * @sensitivity_calib_by_driver: driver has the capability to perform
1721 * sensitivity calibration operation
1722 * @chain_noise_calib_by_driver: driver has the capability to perform
1723 * chain noise calibration operation
1724 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001725struct il_base_params {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001726 int eeprom_size;
1727 int num_of_queues; /* def: HW dependent */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001728 int num_of_ampdu_queues; /* def: HW dependent */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001729 /* for il_apm_init() */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001730 u32 pll_cfg_val;
1731 bool set_l0s;
1732 bool use_bsm;
1733
1734 u16 led_compensation;
1735 int chain_noise_num_beacons;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001736 unsigned int wd_timeout;
1737 bool temperature_kelvin;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001738 const bool ucode_tracing;
1739 const bool sensitivity_calib_by_driver;
1740 const bool chain_noise_calib_by_driver;
1741};
1742
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +02001743#define IL_LED_SOLID 11
1744#define IL_DEF_LED_INTRVL cpu_to_le32(1000)
1745
1746#define IL_LED_ACTIVITY (0<<1)
1747#define IL_LED_LINK (1<<1)
1748
1749/*
1750 * LED mode
1751 * IL_LED_DEFAULT: use device default
1752 * IL_LED_RF_STATE: turn LED on/off based on RF state
1753 * LED ON = RF ON
1754 * LED OFF = RF OFF
1755 * IL_LED_BLINK: adjust led blink rate based on blink table
1756 */
1757enum il_led_mode {
1758 IL_LED_DEFAULT,
1759 IL_LED_RF_STATE,
1760 IL_LED_BLINK,
1761};
1762
1763void il_leds_init(struct il_priv *il);
1764void il_leds_exit(struct il_priv *il);
1765
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001766/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001767 * struct il_cfg
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001768 * @fw_name_pre: Firmware filename prefix. The api version and extension
1769 * (.ucode) will be added to filename before loading from disk. The
1770 * filename is constructed as fw_name_pre<api>.ucode.
1771 * @ucode_api_max: Highest version of uCode API supported by driver.
1772 * @ucode_api_min: Lowest version of uCode API supported by driver.
1773 * @scan_antennas: available antenna for scan operation
1774 * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off)
1775 *
1776 * We enable the driver to be backward compatible wrt API version. The
1777 * driver specifies which APIs it supports (with @ucode_api_max being the
1778 * highest and @ucode_api_min the lowest). Firmware will only be loaded if
1779 * it has a supported API version. The firmware's API version will be
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001780 * stored in @il_priv, enabling the driver to make runtime changes based
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001781 * on firmware version used.
1782 *
1783 * For example,
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001784 * if (IL_UCODE_API(il->ucode_ver) >= 2) {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001785 * Driver interacts with Firmware API version >= 2.
1786 * } else {
1787 * Driver interacts with Firmware API version 1.
1788 * }
1789 *
1790 * The ideal usage of this infrastructure is to treat a new ucode API
1791 * release as a new hardware revision. That is, through utilizing the
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001792 * il_hcmd_utils_ops etc. we accommodate different command structures
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001793 * and flows between hardware versions as well as their API
1794 * versions.
1795 *
1796 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001797struct il_cfg {
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001798 /* params specific to an individual device within a device family */
1799 const char *name;
1800 const char *fw_name_pre;
1801 const unsigned int ucode_api_max;
1802 const unsigned int ucode_api_min;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001803 u8 valid_tx_ant;
1804 u8 valid_rx_ant;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001805 unsigned int sku;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001806 u16 eeprom_ver;
1807 u16 eeprom_calib_ver;
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001808 const struct il_ops *ops;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001809 /* module based parameters which can be set from modprobe cmd */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001810 const struct il_mod_params *mod_params;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001811 /* params not likely to change within a device family */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001812 struct il_base_params *base_params;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001813 /* params likely to change within a device family */
1814 u8 scan_rx_antennas[IEEE80211_NUM_BANDS];
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001815 enum il_led_mode led_mode;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001816};
1817
1818/***************************
1819 * L i b *
1820 ***************************/
1821
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001822struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001823int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1824 u16 queue, const struct ieee80211_tx_queue_params *params);
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001825int il_mac_tx_last_beacon(struct ieee80211_hw *hw);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001826
1827void il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx,
1828 int hw_decrypt);
1829int il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx);
1830int il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx);
1831int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch,
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001832 struct il_rxon_context *ctx);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001833void il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx,
1834 enum ieee80211_band band, struct ieee80211_vif *vif);
1835u8 il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band);
1836void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf);
1837bool il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx,
1838 struct ieee80211_sta_ht_cap *ht_cap);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001839void il_connection_init_rx_config(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001840 struct il_rxon_context *ctx);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001841void il_set_rate(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001842int il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr,
1843 u32 decrypt_res, struct ieee80211_rx_status *stats);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001844void il_irq_handle_error(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001845int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001846void il_mac_remove_interface(struct ieee80211_hw *hw,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001847 struct ieee80211_vif *vif);
1848int il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1849 enum nl80211_iftype newtype, bool newp2p);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001850int il_alloc_txq_mem(struct il_priv *il);
1851void il_txq_mem(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001852
Stanislaw Gruszkad3175162011-11-15 11:25:42 +01001853#ifdef CONFIG_IWLEGACY_DEBUGFS
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001854int il_alloc_traffic_mem(struct il_priv *il);
1855void il_free_traffic_mem(struct il_priv *il);
1856void il_reset_traffic_log(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001857void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length,
1858 struct ieee80211_hdr *header);
1859void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length,
1860 struct ieee80211_hdr *header);
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001861const char *il_get_mgmt_string(int cmd);
1862const char *il_get_ctrl_string(int cmd);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001863void il_clear_traffic_stats(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001864void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001865#else
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001866static inline int
1867il_alloc_traffic_mem(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001868{
1869 return 0;
1870}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001871
1872static inline void
1873il_free_traffic_mem(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001874{
1875}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001876
1877static inline void
1878il_reset_traffic_log(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001879{
1880}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001881
1882static inline void
1883il_dbg_log_tx_data_frame(struct il_priv *il, u16 length,
1884 struct ieee80211_hdr *header)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001885{
1886}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001887
1888static inline void
1889il_dbg_log_rx_data_frame(struct il_priv *il, u16 length,
1890 struct ieee80211_hdr *header)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001891{
1892}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001893
1894static inline void
1895il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001896{
1897}
1898#endif
1899/*****************************************************
1900 * RX handlers.
1901 * **************************************************/
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001902void il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb);
1903void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb);
1904void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001905
1906/*****************************************************
1907* RX
1908******************************************************/
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001909void il_cmd_queue_unmap(struct il_priv *il);
1910void il_cmd_queue_free(struct il_priv *il);
1911int il_rx_queue_alloc(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001912void il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q);
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001913int il_rx_queue_space(const struct il_rx_queue *q);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001914void il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001915/* Handlers */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001916void il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb);
1917void il_recover_from_stats(struct il_priv *il, struct il_rx_pkt *pkt);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001918void il_chswitch_done(struct il_priv *il, bool is_success);
Stanislaw Gruszkad2dfb332011-11-15 13:16:38 +01001919void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001920
1921/* TX helpers */
1922
1923/*****************************************************
1924* TX
1925******************************************************/
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001926void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq);
1927int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
1928 u32 txq_id);
1929void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq,
1930 int slots_num, u32 txq_id);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001931void il_tx_queue_unmap(struct il_priv *il, int txq_id);
1932void il_tx_queue_free(struct il_priv *il, int txq_id);
1933void il_setup_watchdog(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001934/*****************************************************
1935 * TX power
1936 ****************************************************/
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001937int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001938
1939/*******************************************************************************
1940 * Rate
1941 ******************************************************************************/
1942
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001943u8 il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001944
1945/*******************************************************************************
1946 * Scanning
1947 ******************************************************************************/
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001948void il_init_scan_params(struct il_priv *il);
1949int il_scan_cancel(struct il_priv *il);
1950int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms);
1951void il_force_scan_end(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001952int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1953 struct cfg80211_scan_request *req);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001954void il_internal_short_hw_scan(struct il_priv *il);
1955int il_force_reset(struct il_priv *il, bool external);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001956u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001957 const u8 *ta, const u8 *ie, int ie_len, int left);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001958void il_setup_rx_scan_handlers(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001959u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band,
1960 u8 n_probes);
1961u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band,
1962 struct ieee80211_vif *vif);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001963void il_setup_scan_deferred_work(struct il_priv *il);
1964void il_cancel_scan_deferred_work(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001965
1966/* For faster active scanning, scan will move to the next channel if fewer than
1967 * PLCP_QUIET_THRESH packets are heard on this channel within
1968 * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell
1969 * time if it's a quiet channel (nothing responded to our probe, and there's
1970 * no other traffic).
1971 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001972#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */
1973#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001974
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001975#define IL_SCAN_CHECK_WATCHDOG (HZ * 7)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001976
1977/*****************************************************
1978 * S e n d i n g H o s t C o m m a n d s *
1979 *****************************************************/
1980
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02001981const char *il_get_cmd_string(u8 cmd);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001982int __must_check il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001983int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001984int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len,
1985 const void *data);
1986int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01001987 void (*callback) (struct il_priv *il,
1988 struct il_device_cmd *cmd,
1989 struct il_rx_pkt *pkt));
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001990
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02001991int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001992
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001993/*****************************************************
1994 * PCI *
1995 *****************************************************/
1996
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001997static inline u16
1998il_pcie_link_ctl(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08001999{
2000 int pos;
2001 u16 pci_lnk_ctl;
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002002 pos = pci_pcie_cap(il->pci_dev);
2003 pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002004 return pci_lnk_ctl;
2005}
2006
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002007void il_bg_watchdog(unsigned long data);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002008u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval);
2009__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon,
2010 u32 beacon_interval);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002011
2012#ifdef CONFIG_PM
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002013int il_pci_suspend(struct device *device);
2014int il_pci_resume(struct device *device);
2015extern const struct dev_pm_ops il_pm_ops;
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002016
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002017#define IL_LEGACY_PM_OPS (&il_pm_ops)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002018
2019#else /* !CONFIG_PM */
2020
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002021#define IL_LEGACY_PM_OPS NULL
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002022
2023#endif /* !CONFIG_PM */
2024
2025/*****************************************************
2026* Error Handling Debugging
2027******************************************************/
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002028void il4965_dump_nic_error_log(struct il_priv *il);
Stanislaw Gruszkad3175162011-11-15 11:25:42 +01002029#ifdef CONFIG_IWLEGACY_DEBUG
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002030void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002031#else
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002032static inline void
2033il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002034{
2035}
2036#endif
2037
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002038void il_clear_isr_stats(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002039
2040/*****************************************************
2041* GEOS
2042******************************************************/
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002043int il_init_geos(struct il_priv *il);
2044void il_free_geos(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002045
2046/*************** DRIVER STATUS FUNCTIONS *****/
2047
Stanislaw Gruszkaa6766cc2011-11-15 13:09:01 +01002048#define S_HCMD_ACTIVE 0 /* host command in progress */
2049/* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */
2050#define S_INT_ENABLED 2
2051#define S_RF_KILL_HW 3
2052#define S_CT_KILL 4
2053#define S_INIT 5
2054#define S_ALIVE 6
2055#define S_READY 7
2056#define S_TEMPERATURE 8
2057#define S_GEO_CONFIGURED 9
2058#define S_EXIT_PENDING 10
Stanislaw Gruszkadb7746f2011-11-15 13:11:50 +01002059#define S_STATS 12
Stanislaw Gruszkaa6766cc2011-11-15 13:09:01 +01002060#define S_SCANNING 13
2061#define S_SCAN_ABORTING 14
2062#define S_SCAN_HW 15
2063#define S_POWER_PMI 16
2064#define S_FW_ERROR 17
2065#define S_CHANNEL_SWITCH_PENDING 18
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002066
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002067static inline int
2068il_is_ready(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002069{
2070 /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
2071 * set but EXIT_PENDING is not */
Stanislaw Gruszkaa6766cc2011-11-15 13:09:01 +01002072 return test_bit(S_READY, &il->status) &&
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002073 test_bit(S_GEO_CONFIGURED, &il->status) &&
2074 !test_bit(S_EXIT_PENDING, &il->status);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002075}
2076
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002077static inline int
2078il_is_alive(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002079{
Stanislaw Gruszkaa6766cc2011-11-15 13:09:01 +01002080 return test_bit(S_ALIVE, &il->status);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002081}
2082
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002083static inline int
2084il_is_init(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002085{
Stanislaw Gruszkaa6766cc2011-11-15 13:09:01 +01002086 return test_bit(S_INIT, &il->status);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002087}
2088
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002089static inline int
2090il_is_rfkill_hw(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002091{
Stanislaw Gruszkaa6766cc2011-11-15 13:09:01 +01002092 return test_bit(S_RF_KILL_HW, &il->status);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002093}
2094
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002095static inline int
2096il_is_rfkill(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002097{
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002098 return il_is_rfkill_hw(il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002099}
2100
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002101static inline int
2102il_is_ctkill(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002103{
Stanislaw Gruszkaa6766cc2011-11-15 13:09:01 +01002104 return test_bit(S_CT_KILL, &il->status);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002105}
2106
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002107static inline int
2108il_is_ready_rf(struct il_priv *il)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002109{
2110
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002111 if (il_is_rfkill(il))
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002112 return 0;
2113
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002114 return il_is_ready(il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002115}
2116
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002117extern void il_send_bt_config(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002118extern int il_send_stats_request(struct il_priv *il, u8 flags, bool clear);
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002119void il_apm_stop(struct il_priv *il);
2120int il_apm_init(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002121
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002122int il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx);
2123static inline int
2124il_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002125{
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002126 return il->cfg->ops->hcmd->rxon_assoc(il, ctx);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002127}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002128
2129static inline int
2130il_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002131{
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002132 return il->cfg->ops->hcmd->commit_rxon(il, ctx);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002133}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002134
2135static inline const struct ieee80211_supported_band *
2136il_get_hw_mode(struct il_priv *il, enum ieee80211_band band)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002137{
Stanislaw Gruszka46bc8d42011-10-24 16:49:25 +02002138 return il->hw->wiphy->bands[band];
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002139}
2140
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002141/* mac80211 handlers */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002142int il_mac_config(struct ieee80211_hw *hw, u32 changed);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002143void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
2144void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2145 struct ieee80211_bss_conf *bss_conf, u32 changes);
2146void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01002147 __le16 fc, __le32 *tx_flags);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002148
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02002149irqreturn_t il_isr(int irq, void *data);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -08002150
Stanislaw Gruszka17d4eca2011-12-23 08:13:43 +01002151extern void il_set_bit(struct il_priv *p, u32 r, u32 m);
2152extern void il_clear_bit(struct il_priv *p, u32 r, u32 m);
2153extern int _il_grab_nic_access(struct il_priv *il);
2154extern int _il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout);
2155extern int il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout);
2156extern u32 il_rd_prph(struct il_priv *il, u32 reg);
2157extern void il_wr_prph(struct il_priv *il, u32 addr, u32 val);
2158extern u32 il_read_targ_mem(struct il_priv *il, u32 addr);
2159extern void il_write_targ_mem(struct il_priv *il, u32 addr, u32 val);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002160
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002161static inline void
2162_il_write8(struct il_priv *il, u32 ofs, u8 val)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002163{
2164 iowrite8(val, il->hw_base + ofs);
2165}
2166#define il_write8(il, ofs, val) _il_write8(il, ofs, val)
2167
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002168static inline void
2169_il_wr(struct il_priv *il, u32 ofs, u32 val)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002170{
2171 iowrite32(val, il->hw_base + ofs);
2172}
2173
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002174static inline u32
2175_il_rd(struct il_priv *il, u32 ofs)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002176{
2177 return ioread32(il->hw_base + ofs);
2178}
2179
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002180static inline void
2181_il_clear_bit(struct il_priv *il, u32 reg, u32 mask)
2182{
2183 _il_wr(il, reg, _il_rd(il, reg) & ~mask);
2184}
2185
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002186static inline void
Stanislaw Gruszka17d4eca2011-12-23 08:13:43 +01002187_il_set_bit(struct il_priv *il, u32 reg, u32 mask)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002188{
Stanislaw Gruszka17d4eca2011-12-23 08:13:43 +01002189 _il_wr(il, reg, _il_rd(il, reg) | mask);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002190}
2191
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002192static inline void
2193_il_release_nic_access(struct il_priv *il)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002194{
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002195 _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002196}
2197
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002198static inline u32
2199il_rd(struct il_priv *il, u32 reg)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002200{
2201 u32 value;
2202 unsigned long reg_flags;
2203
2204 spin_lock_irqsave(&il->reg_lock, reg_flags);
2205 _il_grab_nic_access(il);
2206 value = _il_rd(il, reg);
2207 _il_release_nic_access(il);
2208 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2209 return value;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002210}
2211
2212static inline void
2213il_wr(struct il_priv *il, u32 reg, u32 value)
2214{
2215 unsigned long reg_flags;
2216
2217 spin_lock_irqsave(&il->reg_lock, reg_flags);
2218 if (!_il_grab_nic_access(il)) {
2219 _il_wr(il, reg, value);
2220 _il_release_nic_access(il);
2221 }
2222 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2223}
2224
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002225static inline u32
2226_il_rd_prph(struct il_priv *il, u32 reg)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002227{
2228 _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
2229 rmb();
2230 return _il_rd(il, HBUS_TARG_PRPH_RDAT);
2231}
2232
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002233static inline void
2234_il_wr_prph(struct il_priv *il, u32 addr, u32 val)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002235{
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002236 _il_wr(il, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24)));
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002237 wmb();
2238 _il_wr(il, HBUS_TARG_PRPH_WDAT, val);
2239}
2240
2241static inline void
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002242il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask)
2243{
2244 unsigned long reg_flags;
2245
2246 spin_lock_irqsave(&il->reg_lock, reg_flags);
2247 _il_grab_nic_access(il);
Stanislaw Gruszka17d4eca2011-12-23 08:13:43 +01002248 _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask));
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002249 _il_release_nic_access(il);
2250 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2251}
2252
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002253static inline void
2254il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002255{
2256 unsigned long reg_flags;
2257
2258 spin_lock_irqsave(&il->reg_lock, reg_flags);
2259 _il_grab_nic_access(il);
Stanislaw Gruszka17d4eca2011-12-23 08:13:43 +01002260 _il_wr_prph(il, reg, ((_il_rd_prph(il, reg) & mask) | bits));
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002261 _il_release_nic_access(il);
2262 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2263}
2264
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002265static inline void
2266il_clear_bits_prph(struct il_priv *il, u32 reg, u32 mask)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002267{
2268 unsigned long reg_flags;
2269 u32 val;
2270
2271 spin_lock_irqsave(&il->reg_lock, reg_flags);
2272 _il_grab_nic_access(il);
2273 val = _il_rd_prph(il, reg);
2274 _il_wr_prph(il, reg, (val & ~mask));
2275 _il_release_nic_access(il);
2276 spin_unlock_irqrestore(&il->reg_lock, reg_flags);
2277}
2278
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002279#define HW_KEY_DYNAMIC 0
2280#define HW_KEY_DEFAULT 1
2281
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002282#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
2283#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */
2284#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of
2285 being activated */
2286#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211;
2287 (this is for the IBSS BSSID stations) */
2288#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002289
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002290void il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx);
2291void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002292void il_dealloc_bcast_stations(struct il_priv *il);
2293int il_get_free_ucode_key_idx(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002294int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags);
2295int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01002296 const u8 *addr, bool is_ap,
2297 struct ieee80211_sta *sta, u8 *sta_id_r);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002298int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 * addr);
2299int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
2300 struct ieee80211_sta *sta);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002301
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002302u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01002303 const u8 *addr, bool is_ap, struct ieee80211_sta *sta);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002304
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002305int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx,
2306 struct il_link_quality_cmd *lq, u8 flags, bool init);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002307
2308/**
2309 * il_clear_driver_stations - clear knowledge of all stations from driver
2310 * @il: iwl il struct
2311 *
2312 * This is called during il_down() to make sure that in the case
2313 * we're coming there from a hardware restart mac80211 will be
2314 * able to reconfigure stations -- if we're getting there in the
2315 * normal down flow then the stations will already be cleared.
2316 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002317static inline void
2318il_clear_driver_stations(struct il_priv *il)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002319{
2320 unsigned long flags;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002321
2322 spin_lock_irqsave(&il->sta_lock, flags);
2323 memset(il->stations, 0, sizeof(il->stations));
2324 il->num_stations = 0;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002325 il->ucode_key_table = 0;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002326 spin_unlock_irqrestore(&il->sta_lock, flags);
2327}
2328
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002329static inline int
2330il_sta_id(struct ieee80211_sta *sta)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002331{
2332 if (WARN_ON(!sta))
2333 return IL_INVALID_STATION;
2334
2335 return ((struct il_station_priv_common *)sta->drv_priv)->sta_id;
2336}
2337
2338/**
2339 * il_sta_id_or_broadcast - return sta_id or broadcast sta
2340 * @il: iwl il
2341 * @context: the current context
2342 * @sta: mac80211 station
2343 *
2344 * In certain circumstances mac80211 passes a station pointer
2345 * that may be %NULL, for example during TX or key setup. In
2346 * that case, we need to use the broadcast station, so this
2347 * inline wraps that pattern.
2348 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002349static inline int
2350il_sta_id_or_broadcast(struct il_priv *il, struct il_rxon_context *context,
2351 struct ieee80211_sta *sta)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002352{
2353 int sta_id;
2354
2355 if (!sta)
Stanislaw Gruszkab16db502012-02-03 17:31:44 +01002356 return il->hw_params.bcast_id;
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002357
2358 sta_id = il_sta_id(sta);
2359
2360 /*
2361 * mac80211 should not be passing a partially
2362 * initialised station!
2363 */
2364 WARN_ON(sta_id == IL_INVALID_STATION);
2365
2366 return sta_id;
2367}
2368
2369/**
2370 * il_queue_inc_wrap - increment queue idx, wrap back to beginning
2371 * @idx -- current idx
2372 * @n_bd -- total number of entries in queue (must be power of 2)
2373 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002374static inline int
2375il_queue_inc_wrap(int idx, int n_bd)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002376{
2377 return ++idx & (n_bd - 1);
2378}
2379
2380/**
2381 * il_queue_dec_wrap - decrement queue idx, wrap back to end
2382 * @idx -- current idx
2383 * @n_bd -- total number of entries in queue (must be power of 2)
2384 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002385static inline int
2386il_queue_dec_wrap(int idx, int n_bd)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002387{
2388 return --idx & (n_bd - 1);
2389}
2390
2391/* TODO: Move fw_desc functions to iwl-pci.ko */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002392static inline void
2393il_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002394{
2395 if (desc->v_addr)
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002396 dma_free_coherent(&pci_dev->dev, desc->len, desc->v_addr,
2397 desc->p_addr);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002398 desc->v_addr = NULL;
2399 desc->len = 0;
2400}
2401
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002402static inline int
2403il_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002404{
2405 if (!desc->len) {
2406 desc->v_addr = NULL;
2407 return -EINVAL;
2408 }
2409
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002410 desc->v_addr =
2411 dma_alloc_coherent(&pci_dev->dev, desc->len, &desc->p_addr,
2412 GFP_KERNEL);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002413 return (desc->v_addr != NULL) ? 0 : -ENOMEM;
2414}
2415
2416/*
2417 * we have 8 bits used like this:
2418 *
2419 * 7 6 5 4 3 2 1 0
2420 * | | | | | | | |
2421 * | | | | | | +-+-------- AC queue (0-3)
2422 * | | | | | |
2423 * | +-+-+-+-+------------ HW queue ID
2424 * |
2425 * +---------------------- unused
2426 */
2427static inline void
2428il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq)
2429{
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002430 BUG_ON(ac > 3); /* only have 2 bits */
2431 BUG_ON(hwq > 31); /* only use 5 bits */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002432
2433 txq->swq_id = (hwq << 2) | ac;
2434}
2435
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002436static inline void
2437il_wake_queue(struct il_priv *il, struct il_tx_queue *txq)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002438{
2439 u8 queue = txq->swq_id;
2440 u8 ac = queue & 3;
2441 u8 hwq = (queue >> 2) & 0x1f;
2442
2443 if (test_and_clear_bit(hwq, il->queue_stopped))
2444 if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0)
2445 ieee80211_wake_queue(il->hw, ac);
2446}
2447
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002448static inline void
2449il_stop_queue(struct il_priv *il, struct il_tx_queue *txq)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002450{
2451 u8 queue = txq->swq_id;
2452 u8 ac = queue & 3;
2453 u8 hwq = (queue >> 2) & 0x1f;
2454
2455 if (!test_and_set_bit(hwq, il->queue_stopped))
2456 if (atomic_inc_return(&il->queue_stop_count[ac]) > 0)
2457 ieee80211_stop_queue(il->hw, ac);
2458}
2459
2460#ifdef ieee80211_stop_queue
2461#undef ieee80211_stop_queue
2462#endif
2463
2464#define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue
2465
2466#ifdef ieee80211_wake_queue
2467#undef ieee80211_wake_queue
2468#endif
2469
2470#define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue
2471
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002472static inline void
2473il_disable_interrupts(struct il_priv *il)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002474{
2475 clear_bit(S_INT_ENABLED, &il->status);
2476
2477 /* disable interrupts from uCode/NIC to host */
2478 _il_wr(il, CSR_INT_MASK, 0x00000000);
2479
2480 /* acknowledge/clear/reset any interrupts still pending
2481 * from uCode or flow handler (Rx/Tx DMA) */
2482 _il_wr(il, CSR_INT, 0xffffffff);
2483 _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff);
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002484}
2485
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002486static inline void
2487il_enable_rfkill_int(struct il_priv *il)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002488{
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002489 _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL);
2490}
2491
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002492static inline void
2493il_enable_interrupts(struct il_priv *il)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002494{
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002495 set_bit(S_INT_ENABLED, &il->status);
2496 _il_wr(il, CSR_INT_MASK, il->inta_mask);
2497}
2498
2499/**
2500 * il_beacon_time_mask_low - mask of lower 32 bit of beacon time
2501 * @il -- pointer to il_priv data structure
2502 * @tsf_bits -- number of bits need to shift for masking)
2503 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002504static inline u32
2505il_beacon_time_mask_low(struct il_priv *il, u16 tsf_bits)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002506{
2507 return (1 << tsf_bits) - 1;
2508}
2509
2510/**
2511 * il_beacon_time_mask_high - mask of higher 32 bit of beacon time
2512 * @il -- pointer to il_priv data structure
2513 * @tsf_bits -- number of bits need to shift for masking)
2514 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002515static inline u32
2516il_beacon_time_mask_high(struct il_priv *il, u16 tsf_bits)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002517{
2518 return ((1 << (32 - tsf_bits)) - 1) << tsf_bits;
2519}
2520
2521/**
2522 * struct il_rb_status - reseve buffer status host memory mapped FH registers
2523 *
2524 * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed
2525 * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed
2526 * @finished_rb_num [0:11] - Indicates the idx of the current RB
2527 * in which the last frame was written to
2528 * @finished_fr_num [0:11] - Indicates the idx of the RX Frame
2529 * which was transferred
2530 */
2531struct il_rb_status {
2532 __le16 closed_rb_num;
2533 __le16 closed_fr_num;
2534 __le16 finished_rb_num;
2535 __le16 finished_fr_nam;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002536 __le32 __unused; /* 3945 only */
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002537} __packed;
2538
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002539#define TFD_QUEUE_SIZE_MAX (256)
2540#define TFD_QUEUE_SIZE_BC_DUP (64)
2541#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
2542#define IL_TX_DMA_MASK DMA_BIT_MASK(36)
2543#define IL_NUM_OF_TBS 20
2544
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002545static inline u8
2546il_get_dma_hi_addr(dma_addr_t addr)
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002547{
2548 return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF;
2549}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002550
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002551/**
2552 * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor
2553 *
2554 * This structure contains dma address and length of transmission address
2555 *
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01002556 * @lo: low [31:0] portion of the dma address of TX buffer every even is
2557 * unaligned on 16 bit boundary
2558 * @hi_n_len: 0-3 [35:32] portion of dma
2559 * 4-15 length of the tx buffer
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002560 */
2561struct il_tfd_tb {
2562 __le32 lo;
2563 __le16 hi_n_len;
2564} __packed;
2565
2566/**
2567 * struct il_tfd
2568 *
2569 * Transmit Frame Descriptor (TFD)
2570 *
2571 * @ __reserved1[3] reserved
2572 * @ num_tbs 0-4 number of active tbs
2573 * 5 reserved
2574 * 6-7 padding (not used)
2575 * @ tbs[20] transmit frame buffer descriptors
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01002576 * @ __pad padding
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002577 *
2578 * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
2579 * Both driver and device share these circular buffers, each of which must be
2580 * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes
2581 *
2582 * Driver must indicate the physical address of the base of each
Stanislaw Gruszka9a95b372011-08-31 14:20:23 +02002583 * circular buffer via the FH49_MEM_CBBC_QUEUE registers.
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +02002584 *
2585 * Each TFD contains pointer/size information for up to 20 data buffers
2586 * in host DRAM. These buffers collectively contain the (one) frame described
2587 * by the TFD. Each buffer must be a single contiguous block of memory within
2588 * itself, but buffers may be scattered in host DRAM. Each buffer has max size
2589 * of (4K - 4). The concatenates all of a TFD's buffers into a single
2590 * Tx frame, up to 8 KBytes in size.
2591 *
2592 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
2593 */
2594struct il_tfd {
2595 u8 __reserved1[3];
2596 u8 num_tbs;
2597 struct il_tfd_tb tbs[IL_NUM_OF_TBS];
2598 __le32 __pad;
2599} __packed;
2600/* PCI registers */
2601#define PCI_CFG_RETRY_TIMEOUT 0x041
2602
2603/* PCI register values */
2604#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
2605#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
2606
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002607struct il_rate_info {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002608 u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */
2609 u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */
2610 u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */
2611 u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */
2612 u8 prev_ieee; /* previous rate in IEEE speeds */
2613 u8 next_ieee; /* next rate in IEEE speeds */
2614 u8 prev_rs; /* previous rate used in rs algo */
2615 u8 next_rs; /* next rate used in rs algo */
2616 u8 prev_rs_tgg; /* previous rate used in TGG rs algo */
2617 u8 next_rs_tgg; /* next rate used in TGG rs algo */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002618};
2619
2620struct il3945_rate_info {
2621 u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */
2622 u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */
2623 u8 prev_ieee; /* previous rate in IEEE speeds */
2624 u8 next_ieee; /* next rate in IEEE speeds */
2625 u8 prev_rs; /* previous rate used in rs algo */
2626 u8 next_rs; /* next rate used in rs algo */
2627 u8 prev_rs_tgg; /* previous rate used in TGG rs algo */
2628 u8 next_rs_tgg; /* next rate used in TGG rs algo */
2629 u8 table_rs_idx; /* idx in rate scale table cmd */
2630 u8 prev_table_rs; /* prev in rate table cmd */
2631};
2632
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002633/*
2634 * These serve as idxes into
2635 * struct il_rate_info il_rates[RATE_COUNT];
2636 */
2637enum {
2638 RATE_1M_IDX = 0,
2639 RATE_2M_IDX,
2640 RATE_5M_IDX,
2641 RATE_11M_IDX,
2642 RATE_6M_IDX,
2643 RATE_9M_IDX,
2644 RATE_12M_IDX,
2645 RATE_18M_IDX,
2646 RATE_24M_IDX,
2647 RATE_36M_IDX,
2648 RATE_48M_IDX,
2649 RATE_54M_IDX,
2650 RATE_60M_IDX,
2651 RATE_COUNT,
2652 RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */
2653 RATE_COUNT_3945 = RATE_COUNT - 1,
2654 RATE_INVM_IDX = RATE_COUNT,
2655 RATE_INVALID = RATE_COUNT,
2656};
2657
2658enum {
2659 RATE_6M_IDX_TBL = 0,
2660 RATE_9M_IDX_TBL,
2661 RATE_12M_IDX_TBL,
2662 RATE_18M_IDX_TBL,
2663 RATE_24M_IDX_TBL,
2664 RATE_36M_IDX_TBL,
2665 RATE_48M_IDX_TBL,
2666 RATE_54M_IDX_TBL,
2667 RATE_1M_IDX_TBL,
2668 RATE_2M_IDX_TBL,
2669 RATE_5M_IDX_TBL,
2670 RATE_11M_IDX_TBL,
2671 RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1,
2672};
2673
2674enum {
2675 IL_FIRST_OFDM_RATE = RATE_6M_IDX,
2676 IL39_LAST_OFDM_RATE = RATE_54M_IDX,
2677 IL_LAST_OFDM_RATE = RATE_60M_IDX,
2678 IL_FIRST_CCK_RATE = RATE_1M_IDX,
2679 IL_LAST_CCK_RATE = RATE_11M_IDX,
2680};
2681
2682/* #define vs. enum to keep from defaulting to 'large integer' */
2683#define RATE_6M_MASK (1 << RATE_6M_IDX)
2684#define RATE_9M_MASK (1 << RATE_9M_IDX)
2685#define RATE_12M_MASK (1 << RATE_12M_IDX)
2686#define RATE_18M_MASK (1 << RATE_18M_IDX)
2687#define RATE_24M_MASK (1 << RATE_24M_IDX)
2688#define RATE_36M_MASK (1 << RATE_36M_IDX)
2689#define RATE_48M_MASK (1 << RATE_48M_IDX)
2690#define RATE_54M_MASK (1 << RATE_54M_IDX)
2691#define RATE_60M_MASK (1 << RATE_60M_IDX)
2692#define RATE_1M_MASK (1 << RATE_1M_IDX)
2693#define RATE_2M_MASK (1 << RATE_2M_IDX)
2694#define RATE_5M_MASK (1 << RATE_5M_IDX)
2695#define RATE_11M_MASK (1 << RATE_11M_IDX)
2696
2697/* uCode API values for legacy bit rates, both OFDM and CCK */
2698enum {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002699 RATE_6M_PLCP = 13,
2700 RATE_9M_PLCP = 15,
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002701 RATE_12M_PLCP = 5,
2702 RATE_18M_PLCP = 7,
2703 RATE_24M_PLCP = 9,
2704 RATE_36M_PLCP = 11,
2705 RATE_48M_PLCP = 1,
2706 RATE_54M_PLCP = 3,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002707 RATE_60M_PLCP = 3, /*FIXME:RS:should be removed */
2708 RATE_1M_PLCP = 10,
2709 RATE_2M_PLCP = 20,
2710 RATE_5M_PLCP = 55,
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002711 RATE_11M_PLCP = 110,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002712 /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0, */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002713};
2714
2715/* uCode API values for OFDM high-throughput (HT) bit rates */
2716enum {
2717 RATE_SISO_6M_PLCP = 0,
2718 RATE_SISO_12M_PLCP = 1,
2719 RATE_SISO_18M_PLCP = 2,
2720 RATE_SISO_24M_PLCP = 3,
2721 RATE_SISO_36M_PLCP = 4,
2722 RATE_SISO_48M_PLCP = 5,
2723 RATE_SISO_54M_PLCP = 6,
2724 RATE_SISO_60M_PLCP = 7,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002725 RATE_MIMO2_6M_PLCP = 0x8,
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002726 RATE_MIMO2_12M_PLCP = 0x9,
2727 RATE_MIMO2_18M_PLCP = 0xa,
2728 RATE_MIMO2_24M_PLCP = 0xb,
2729 RATE_MIMO2_36M_PLCP = 0xc,
2730 RATE_MIMO2_48M_PLCP = 0xd,
2731 RATE_MIMO2_54M_PLCP = 0xe,
2732 RATE_MIMO2_60M_PLCP = 0xf,
2733 RATE_SISO_INVM_PLCP,
2734 RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP,
2735};
2736
2737/* MAC header values for bit rates */
2738enum {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002739 RATE_6M_IEEE = 12,
2740 RATE_9M_IEEE = 18,
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002741 RATE_12M_IEEE = 24,
2742 RATE_18M_IEEE = 36,
2743 RATE_24M_IEEE = 48,
2744 RATE_36M_IEEE = 72,
2745 RATE_48M_IEEE = 96,
2746 RATE_54M_IEEE = 108,
2747 RATE_60M_IEEE = 120,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002748 RATE_1M_IEEE = 2,
2749 RATE_2M_IEEE = 4,
2750 RATE_5M_IEEE = 11,
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002751 RATE_11M_IEEE = 22,
2752};
2753
2754#define IL_CCK_BASIC_RATES_MASK \
2755 (RATE_1M_MASK | \
2756 RATE_2M_MASK)
2757
2758#define IL_CCK_RATES_MASK \
2759 (IL_CCK_BASIC_RATES_MASK | \
2760 RATE_5M_MASK | \
2761 RATE_11M_MASK)
2762
2763#define IL_OFDM_BASIC_RATES_MASK \
2764 (RATE_6M_MASK | \
2765 RATE_12M_MASK | \
2766 RATE_24M_MASK)
2767
2768#define IL_OFDM_RATES_MASK \
2769 (IL_OFDM_BASIC_RATES_MASK | \
2770 RATE_9M_MASK | \
2771 RATE_18M_MASK | \
2772 RATE_36M_MASK | \
2773 RATE_48M_MASK | \
2774 RATE_54M_MASK)
2775
2776#define IL_BASIC_RATES_MASK \
2777 (IL_OFDM_BASIC_RATES_MASK | \
2778 IL_CCK_BASIC_RATES_MASK)
2779
2780#define RATES_MASK ((1 << RATE_COUNT) - 1)
2781#define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1)
2782
2783#define IL_INVALID_VALUE -1
2784
2785#define IL_MIN_RSSI_VAL -100
2786#define IL_MAX_RSSI_VAL 0
2787
2788/* These values specify how many Tx frame attempts before
2789 * searching for a new modulation mode */
2790#define IL_LEGACY_FAILURE_LIMIT 160
2791#define IL_LEGACY_SUCCESS_LIMIT 480
2792#define IL_LEGACY_TBL_COUNT 160
2793
2794#define IL_NONE_LEGACY_FAILURE_LIMIT 400
2795#define IL_NONE_LEGACY_SUCCESS_LIMIT 4500
2796#define IL_NONE_LEGACY_TBL_COUNT 1500
2797
2798/* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */
2799#define IL_RS_GOOD_RATIO 12800 /* 100% */
2800#define RATE_SCALE_SWITCH 10880 /* 85% */
2801#define RATE_HIGH_TH 10880 /* 85% */
2802#define RATE_INCREASE_TH 6400 /* 50% */
2803#define RATE_DECREASE_TH 1920 /* 15% */
2804
2805/* possible actions when in legacy mode */
2806#define IL_LEGACY_SWITCH_ANTENNA1 0
2807#define IL_LEGACY_SWITCH_ANTENNA2 1
2808#define IL_LEGACY_SWITCH_SISO 2
2809#define IL_LEGACY_SWITCH_MIMO2_AB 3
2810#define IL_LEGACY_SWITCH_MIMO2_AC 4
2811#define IL_LEGACY_SWITCH_MIMO2_BC 5
2812
2813/* possible actions when in siso mode */
2814#define IL_SISO_SWITCH_ANTENNA1 0
2815#define IL_SISO_SWITCH_ANTENNA2 1
2816#define IL_SISO_SWITCH_MIMO2_AB 2
2817#define IL_SISO_SWITCH_MIMO2_AC 3
2818#define IL_SISO_SWITCH_MIMO2_BC 4
2819#define IL_SISO_SWITCH_GI 5
2820
2821/* possible actions when in mimo mode */
2822#define IL_MIMO2_SWITCH_ANTENNA1 0
2823#define IL_MIMO2_SWITCH_ANTENNA2 1
2824#define IL_MIMO2_SWITCH_SISO_A 2
2825#define IL_MIMO2_SWITCH_SISO_B 3
2826#define IL_MIMO2_SWITCH_SISO_C 4
2827#define IL_MIMO2_SWITCH_GI 5
2828
2829#define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI
2830
2831#define IL_ACTION_LIMIT 3 /* # possible actions */
2832
2833#define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */
2834
2835/* load per tid defines for A-MPDU activation */
2836#define IL_AGG_TPT_THREHOLD 0
2837#define IL_AGG_LOAD_THRESHOLD 10
2838#define IL_AGG_ALL_TID 0xff
2839#define TID_QUEUE_CELL_SPACING 50 /*mS */
2840#define TID_QUEUE_MAX_SIZE 20
2841#define TID_ROUND_VALUE 5 /* mS */
2842#define TID_MAX_LOAD_COUNT 8
2843
2844#define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING)
2845#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
2846
2847extern const struct il_rate_info il_rates[RATE_COUNT];
2848
2849enum il_table_type {
2850 LQ_NONE,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002851 LQ_G, /* legacy types */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002852 LQ_A,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002853 LQ_SISO, /* high-throughput types */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002854 LQ_MIMO2,
2855 LQ_MAX,
2856};
2857
2858#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A)
2859#define is_siso(tbl) ((tbl) == LQ_SISO)
2860#define is_mimo2(tbl) ((tbl) == LQ_MIMO2)
2861#define is_mimo(tbl) (is_mimo2(tbl))
2862#define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
2863#define is_a_band(tbl) ((tbl) == LQ_A)
2864#define is_g_and(tbl) ((tbl) == LQ_G)
2865
2866#define ANT_NONE 0x0
2867#define ANT_A BIT(0)
2868#define ANT_B BIT(1)
2869#define ANT_AB (ANT_A | ANT_B)
2870#define ANT_C BIT(2)
2871#define ANT_AC (ANT_A | ANT_C)
2872#define ANT_BC (ANT_B | ANT_C)
2873#define ANT_ABC (ANT_AB | ANT_C)
2874
2875#define IL_MAX_MCS_DISPLAY_SIZE 12
2876
2877struct il_rate_mcs_info {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002878 char mbps[IL_MAX_MCS_DISPLAY_SIZE];
2879 char mcs[IL_MAX_MCS_DISPLAY_SIZE];
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002880};
2881
2882/**
2883 * struct il_rate_scale_data -- tx success history for one rate
2884 */
2885struct il_rate_scale_data {
2886 u64 data; /* bitmap of successful frames */
2887 s32 success_counter; /* number of frames successful */
2888 s32 success_ratio; /* per-cent * 128 */
2889 s32 counter; /* number of frames attempted */
2890 s32 average_tpt; /* success ratio * expected throughput */
2891 unsigned long stamp;
2892};
2893
2894/**
2895 * struct il_scale_tbl_info -- tx params and success history for all rates
2896 *
2897 * There are two of these in struct il_lq_sta,
2898 * one for "active", and one for "search".
2899 */
2900struct il_scale_tbl_info {
2901 enum il_table_type lq_type;
2902 u8 ant_type;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002903 u8 is_SGI; /* 1 = short guard interval */
2904 u8 is_ht40; /* 1 = 40 MHz channel width */
2905 u8 is_dup; /* 1 = duplicated data streams */
2906 u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */
2907 u8 max_search; /* maximun number of tables we can search */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002908 s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002909 u32 current_rate; /* rate_n_flags, uCode API format */
2910 struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002911};
2912
2913struct il_traffic_load {
2914 unsigned long time_stamp; /* age of the oldest stats */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002915 u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002916 * slice */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002917 u32 total; /* total num of packets during the
2918 * last TID_MAX_TIME_DIFF */
2919 u8 queue_count; /* number of queues that has
2920 * been used since the last cleanup */
2921 u8 head; /* start of the circular buffer */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002922};
2923
2924/**
2925 * struct il_lq_sta -- driver's rate scaling ilate structure
2926 *
2927 * Pointer to this gets passed back and forth between driver and mac80211.
2928 */
2929struct il_lq_sta {
2930 u8 active_tbl; /* idx of active table, range 0-1 */
2931 u8 enable_counter; /* indicates HT mode */
2932 u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */
2933 u8 search_better_tbl; /* 1: currently trying alternate mode */
2934 s32 last_tpt;
2935
2936 /* The following determine when to search for a new mode */
2937 u32 table_count_limit;
2938 u32 max_failure_limit; /* # failed frames before new search */
2939 u32 max_success_limit; /* # successful frames before new search */
2940 u32 table_count;
2941 u32 total_failed; /* total failed frames, any/all rates */
2942 u32 total_success; /* total successful frames, any/all rates */
2943 u64 flush_timer; /* time staying in mode before new search */
2944
2945 u8 action_counter; /* # mode-switch actions tried */
2946 u8 is_green;
2947 u8 is_dup;
2948 enum ieee80211_band band;
2949
2950 /* The following are bitmaps of rates; RATE_6M_MASK, etc. */
2951 u32 supp_rates;
2952 u16 active_legacy_rate;
2953 u16 active_siso_rate;
2954 u16 active_mimo2_rate;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002955 s8 max_rate_idx; /* Max rate set by user */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002956 u8 missed_rate_counter;
2957
2958 struct il_link_quality_cmd lq;
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002959 struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002960 struct il_traffic_load load[TID_MAX_LOAD_COUNT];
2961 u8 tx_agg_tid_en;
2962#ifdef CONFIG_MAC80211_DEBUGFS
2963 struct dentry *rs_sta_dbgfs_scale_table_file;
2964 struct dentry *rs_sta_dbgfs_stats_table_file;
2965 struct dentry *rs_sta_dbgfs_rate_scale_data_file;
2966 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
2967 u32 dbg_fixed_rate;
2968#endif
2969 struct il_priv *drv;
2970
2971 /* used to be in sta_info */
2972 int last_txrate_idx;
2973 /* last tx rate_n_flags */
2974 u32 last_rate_n_flags;
2975 /* packets destined for this STA are aggregated */
2976 u8 is_agg;
2977};
2978
2979/*
2980 * il_station_priv: Driver's ilate station information
2981 *
2982 * When mac80211 creates a station it reserves some space (hw->sta_data_size)
2983 * in the structure for use by driver. This structure is places in that
2984 * space.
2985 *
2986 * The common struct MUST be first because it is shared between
2987 * 3945 and 4965!
2988 */
2989struct il_station_priv {
2990 struct il_station_priv_common common;
2991 struct il_lq_sta lq_sta;
2992 atomic_t pending_frames;
2993 bool client;
2994 bool asleep;
2995};
2996
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01002997static inline u8
2998il4965_num_of_ant(u8 m)
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02002999{
3000 return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C);
3001}
3002
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003003static inline u8
3004il4965_first_antenna(u8 mask)
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02003005{
3006 if (mask & ANT_A)
3007 return ANT_A;
3008 if (mask & ANT_B)
3009 return ANT_B;
3010 return ANT_C;
3011}
3012
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02003013/**
3014 * il3945_rate_scale_init - Initialize the rate scale table based on assoc info
3015 *
3016 * The specific throughput table used is based on the type of network
3017 * the associated with, including A, B, G, and G w/ TGG protection
3018 */
3019extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id);
3020
3021/* Initialize station's rate scaling information after adding station */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003022extern void il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta,
3023 u8 sta_id);
3024extern void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta,
3025 u8 sta_id);
Stanislaw Gruszka3fbbf9a2011-08-31 13:39:29 +02003026
3027/**
3028 * il_rate_control_register - Register the rate control algorithm callbacks
3029 *
3030 * Since the rate control algorithm is hardware specific, there is no need
3031 * or reason to place it as a stand alone module. The driver can call
3032 * il_rate_control_register in order to register the rate control callbacks
3033 * with the mac80211 subsystem. This should be performed prior to calling
3034 * ieee80211_register_hw
3035 *
3036 */
3037extern int il4965_rate_control_register(void);
3038extern int il3945_rate_control_register(void);
3039
3040/**
3041 * il_rate_control_unregister - Unregister the rate control callbacks
3042 *
3043 * This should be called after calling ieee80211_unregister_hw, but before
3044 * the driver is unloaded.
3045 */
3046extern void il4965_rate_control_unregister(void);
3047extern void il3945_rate_control_unregister(void);
3048
Stanislaw Gruszka99412002011-08-31 13:53:04 +02003049extern int il_power_update_mode(struct il_priv *il, bool force);
3050extern void il_power_initialize(struct il_priv *il);
Stanislaw Gruszka47ef6942011-08-31 14:04:45 +02003051
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003052extern u32 il_debug_level;
3053
3054#ifdef CONFIG_IWLEGACY_DEBUG
3055/*
3056 * il_get_debug_level: Return active debug level for device
3057 *
3058 * Using sysfs it is possible to set per device debug level. This debug
3059 * level will be used if set, otherwise the global debug level which can be
3060 * set via module parameter is used.
3061 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003062static inline u32
3063il_get_debug_level(struct il_priv *il)
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003064{
3065 if (il->debug_level)
3066 return il->debug_level;
3067 else
3068 return il_debug_level;
3069}
3070#else
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003071static inline u32
3072il_get_debug_level(struct il_priv *il)
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003073{
3074 return il_debug_level;
3075}
3076#endif
3077
3078#define il_print_hex_error(il, p, len) \
3079do { \
3080 print_hex_dump(KERN_ERR, "iwl data: ", \
3081 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
3082} while (0)
3083
3084#ifdef CONFIG_IWLEGACY_DEBUG
3085#define IL_DBG(level, fmt, args...) \
3086do { \
3087 if (il_get_debug_level(il) & level) \
3088 dev_printk(KERN_ERR, &il->hw->wiphy->dev, \
3089 "%c %s " fmt, in_interrupt() ? 'I' : 'U', \
3090 __func__ , ## args); \
3091} while (0)
3092
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01003093#define il_print_hex_dump(il, level, p, len) \
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003094do { \
3095 if (il_get_debug_level(il) & level) \
3096 print_hex_dump(KERN_DEBUG, "iwl data: ", \
3097 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \
3098} while (0)
3099
3100#else
3101#define IL_DBG(level, fmt, args...)
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003102static inline void
3103il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len)
3104{
3105}
3106#endif /* CONFIG_IWLEGACY_DEBUG */
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003107
3108#ifdef CONFIG_IWLEGACY_DEBUGFS
3109int il_dbgfs_register(struct il_priv *il, const char *name);
3110void il_dbgfs_unregister(struct il_priv *il);
3111#else
3112static inline int
3113il_dbgfs_register(struct il_priv *il, const char *name)
3114{
3115 return 0;
3116}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003117
3118static inline void
3119il_dbgfs_unregister(struct il_priv *il)
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003120{
3121}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01003122#endif /* CONFIG_IWLEGACY_DEBUGFS */
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003123
3124/*
3125 * To use the debug system:
3126 *
3127 * If you are defining a new debug classification, simply add it to the #define
3128 * list here in the form of
3129 *
3130 * #define IL_DL_xxxx VALUE
3131 *
3132 * where xxxx should be the name of the classification (for example, WEP).
3133 *
3134 * You then need to either add a IL_xxxx_DEBUG() macro definition for your
3135 * classification, or use IL_DBG(IL_DL_xxxx, ...) whenever you want
3136 * to send output to that classification.
3137 *
3138 * The active debug levels can be accessed via files
3139 *
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01003140 * /sys/module/iwl4965/parameters/debug
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003141 * /sys/module/iwl3945/parameters/debug
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +01003142 * /sys/class/net/wlan0/device/debug_level
Stanislaw Gruszkaf02579e2011-08-31 14:49:56 +02003143 *
3144 * when CONFIG_IWLEGACY_DEBUG=y.
3145 */
3146
3147/* 0x0000000F - 0x00000001 */
3148#define IL_DL_INFO (1 << 0)
3149#define IL_DL_MAC80211 (1 << 1)
3150#define IL_DL_HCMD (1 << 2)
3151#define IL_DL_STATE (1 << 3)
3152/* 0x000000F0 - 0x00000010 */
3153#define IL_DL_MACDUMP (1 << 4)
3154#define IL_DL_HCMD_DUMP (1 << 5)
3155#define IL_DL_EEPROM (1 << 6)
3156#define IL_DL_RADIO (1 << 7)
3157/* 0x00000F00 - 0x00000100 */
3158#define IL_DL_POWER (1 << 8)
3159#define IL_DL_TEMP (1 << 9)
3160#define IL_DL_NOTIF (1 << 10)
3161#define IL_DL_SCAN (1 << 11)
3162/* 0x0000F000 - 0x00001000 */
3163#define IL_DL_ASSOC (1 << 12)
3164#define IL_DL_DROP (1 << 13)
3165#define IL_DL_TXPOWER (1 << 14)
3166#define IL_DL_AP (1 << 15)
3167/* 0x000F0000 - 0x00010000 */
3168#define IL_DL_FW (1 << 16)
3169#define IL_DL_RF_KILL (1 << 17)
3170#define IL_DL_FW_ERRORS (1 << 18)
3171#define IL_DL_LED (1 << 19)
3172/* 0x00F00000 - 0x00100000 */
3173#define IL_DL_RATE (1 << 20)
3174#define IL_DL_CALIB (1 << 21)
3175#define IL_DL_WEP (1 << 22)
3176#define IL_DL_TX (1 << 23)
3177/* 0x0F000000 - 0x01000000 */
3178#define IL_DL_RX (1 << 24)
3179#define IL_DL_ISR (1 << 25)
3180#define IL_DL_HT (1 << 26)
3181/* 0xF0000000 - 0x10000000 */
3182#define IL_DL_11H (1 << 28)
3183#define IL_DL_STATS (1 << 29)
3184#define IL_DL_TX_REPLY (1 << 30)
3185#define IL_DL_QOS (1 << 31)
3186
3187#define D_INFO(f, a...) IL_DBG(IL_DL_INFO, f, ## a)
3188#define D_MAC80211(f, a...) IL_DBG(IL_DL_MAC80211, f, ## a)
3189#define D_MACDUMP(f, a...) IL_DBG(IL_DL_MACDUMP, f, ## a)
3190#define D_TEMP(f, a...) IL_DBG(IL_DL_TEMP, f, ## a)
3191#define D_SCAN(f, a...) IL_DBG(IL_DL_SCAN, f, ## a)
3192#define D_RX(f, a...) IL_DBG(IL_DL_RX, f, ## a)
3193#define D_TX(f, a...) IL_DBG(IL_DL_TX, f, ## a)
3194#define D_ISR(f, a...) IL_DBG(IL_DL_ISR, f, ## a)
3195#define D_LED(f, a...) IL_DBG(IL_DL_LED, f, ## a)
3196#define D_WEP(f, a...) IL_DBG(IL_DL_WEP, f, ## a)
3197#define D_HC(f, a...) IL_DBG(IL_DL_HCMD, f, ## a)
3198#define D_HC_DUMP(f, a...) IL_DBG(IL_DL_HCMD_DUMP, f, ## a)
3199#define D_EEPROM(f, a...) IL_DBG(IL_DL_EEPROM, f, ## a)
3200#define D_CALIB(f, a...) IL_DBG(IL_DL_CALIB, f, ## a)
3201#define D_FW(f, a...) IL_DBG(IL_DL_FW, f, ## a)
3202#define D_RF_KILL(f, a...) IL_DBG(IL_DL_RF_KILL, f, ## a)
3203#define D_DROP(f, a...) IL_DBG(IL_DL_DROP, f, ## a)
3204#define D_AP(f, a...) IL_DBG(IL_DL_AP, f, ## a)
3205#define D_TXPOWER(f, a...) IL_DBG(IL_DL_TXPOWER, f, ## a)
3206#define D_RATE(f, a...) IL_DBG(IL_DL_RATE, f, ## a)
3207#define D_NOTIF(f, a...) IL_DBG(IL_DL_NOTIF, f, ## a)
3208#define D_ASSOC(f, a...) IL_DBG(IL_DL_ASSOC, f, ## a)
3209#define D_HT(f, a...) IL_DBG(IL_DL_HT, f, ## a)
3210#define D_STATS(f, a...) IL_DBG(IL_DL_STATS, f, ## a)
3211#define D_TX_REPLY(f, a...) IL_DBG(IL_DL_TX_REPLY, f, ## a)
3212#define D_QOS(f, a...) IL_DBG(IL_DL_QOS, f, ## a)
3213#define D_RADIO(f, a...) IL_DBG(IL_DL_RADIO, f, ## a)
3214#define D_POWER(f, a...) IL_DBG(IL_DL_POWER, f, ## a)
3215#define D_11H(f, a...) IL_DBG(IL_DL_11H, f, ## a)
3216
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +02003217#endif /* __il_core_h__ */