Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 17 | * |
| 18 | * The full GNU General Public License is included in this distribution in the |
| 19 | * file called LICENSE. |
| 20 | * |
| 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 | * |
| 25 | *****************************************************************************/ |
| 26 | /* |
| 27 | * Please use this file (iwl-dev.h) for driver implementation definitions. |
| 28 | * Please use iwl-commands.h for uCode API definitions. |
Stanislaw Gruszka | af038f4 | 2011-08-30 13:58:27 +0200 | [diff] [blame] | 29 | * Please use 4965.h for hardware-related definitions. |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 30 | */ |
| 31 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 32 | #ifndef __il_dev_h__ |
| 33 | #define __il_dev_h__ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 34 | |
Alexey Dobriyan | a6b7a40 | 2011-06-06 10:43:46 +0000 | [diff] [blame] | 35 | #include <linux/interrupt.h> |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 36 | #include <linux/pci.h> /* for struct pci_device_id */ |
| 37 | #include <linux/kernel.h> |
| 38 | #include <linux/leds.h> |
| 39 | #include <linux/wait.h> |
| 40 | #include <net/ieee80211_radiotap.h> |
| 41 | |
| 42 | #include "iwl-eeprom.h" |
| 43 | #include "iwl-csr.h" |
| 44 | #include "iwl-prph.h" |
| 45 | #include "iwl-fh.h" |
| 46 | #include "iwl-debug.h" |
Stanislaw Gruszka | af038f4 | 2011-08-30 13:58:27 +0200 | [diff] [blame] | 47 | #include "4965.h" |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 48 | #include "iwl-led.h" |
| 49 | #include "iwl-power.h" |
| 50 | #include "iwl-legacy-rs.h" |
| 51 | |
Stanislaw Gruszka | 6bbb137 | 2011-08-30 14:12:12 +0200 | [diff] [blame] | 52 | #define U32_PAD(n) ((4-(n))&0x3) |
| 53 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 54 | struct il_tx_queue; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 55 | |
| 56 | /* CT-KILL constants */ |
| 57 | #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ |
| 58 | |
| 59 | /* Default noise level to report when noise measurement is not available. |
| 60 | * This may be because we're: |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 61 | * 1) Not associated (4965, no beacon stats being sent to driver) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 62 | * 2) Scanning (noise measurement does not apply to associated channel) |
| 63 | * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) |
| 64 | * Use default noise value of -127 ... this is below the range of measurable |
| 65 | * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. |
| 66 | * Also, -127 works better than 0 when averaging frames with/without |
| 67 | * noise info (e.g. averaging might be done in app); measured dBm values are |
| 68 | * always negative ... using a negative value as the default keeps all |
| 69 | * averages within an s8's (used in some apps) range of negative values. */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 70 | #define IL_NOISE_MEAS_NOT_AVAILABLE (-127) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | * RTS threshold here is total size [2347] minus 4 FCS bytes |
| 74 | * Per spec: |
| 75 | * a value of 0 means RTS on all data/management packets |
| 76 | * a value > max MSDU size means no RTS |
| 77 | * else RTS for data/management frames where MPDU is larger |
| 78 | * than RTS value. |
| 79 | */ |
| 80 | #define DEFAULT_RTS_THRESHOLD 2347U |
| 81 | #define MIN_RTS_THRESHOLD 0U |
| 82 | #define MAX_RTS_THRESHOLD 2347U |
| 83 | #define MAX_MSDU_SIZE 2304U |
| 84 | #define MAX_MPDU_SIZE 2346U |
| 85 | #define DEFAULT_BEACON_INTERVAL 100U |
| 86 | #define DEFAULT_SHORT_RETRY_LIMIT 7U |
| 87 | #define DEFAULT_LONG_RETRY_LIMIT 4U |
| 88 | |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 89 | struct il_rx_buf { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 90 | dma_addr_t page_dma; |
| 91 | struct page *page; |
| 92 | struct list_head list; |
| 93 | }; |
| 94 | |
| 95 | #define rxb_addr(r) page_address(r->page) |
| 96 | |
| 97 | /* defined below */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 98 | struct il_device_cmd; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 99 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 100 | struct il_cmd_meta { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 101 | /* only for SYNC commands, iff the reply skb is wanted */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 102 | struct il_host_cmd *source; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 103 | /* |
| 104 | * only for ASYNC commands |
| 105 | * (which is somewhat stupid -- look at iwl-sta.c for instance |
| 106 | * which duplicates a bunch of code because the callback isn't |
| 107 | * invoked for SYNC commands, if it were and its result passed |
| 108 | * through it would be simpler...) |
| 109 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 110 | void (*callback)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 111 | struct il_device_cmd *cmd, |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 112 | struct il_rx_pkt *pkt); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 113 | |
| 114 | /* The CMD_SIZE_HUGE flag bit indicates that the command |
| 115 | * structure is stored at the end of the shared queue memory. */ |
| 116 | u32 flags; |
| 117 | |
| 118 | DEFINE_DMA_UNMAP_ADDR(mapping); |
| 119 | DEFINE_DMA_UNMAP_LEN(len); |
| 120 | }; |
| 121 | |
| 122 | /* |
| 123 | * Generic queue structure |
| 124 | * |
| 125 | * Contains common data for Rx and Tx queues |
| 126 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 127 | struct il_queue { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 128 | int n_bd; /* number of BDs in this queue */ |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 129 | int write_ptr; /* 1-st empty entry (idx) host_w*/ |
| 130 | int read_ptr; /* last used entry (idx) host_r*/ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 131 | /* use for monitoring and recovering the stuck queue */ |
| 132 | dma_addr_t dma_addr; /* physical addr for BD's */ |
Stanislaw Gruszka | 6ce1dc4 | 2011-08-26 15:49:28 +0200 | [diff] [blame] | 133 | int n_win; /* safe queue win */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 134 | u32 id; |
| 135 | int low_mark; /* low watermark, resume queue if free |
| 136 | * space more than this */ |
| 137 | int high_mark; /* high watermark, stop queue if free |
| 138 | * space less than this */ |
Stanislaw Gruszka | 5855c7d | 2011-04-28 11:51:28 +0200 | [diff] [blame] | 139 | }; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 140 | |
| 141 | /* One for each TFD */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 142 | struct il_tx_info { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 143 | struct sk_buff *skb; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 144 | struct il_rxon_context *ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 148 | * struct il_tx_queue - Tx Queue for DMA |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 149 | * @q: generic Rx/Tx queue descriptor |
| 150 | * @bd: base of circular buffer of TFDs |
| 151 | * @cmd: array of command/TX buffer pointers |
| 152 | * @meta: array of meta data for each command/tx buffer |
| 153 | * @dma_addr_cmd: physical address of cmd/tx buffer array |
| 154 | * @txb: array of per-TFD driver data |
| 155 | * @time_stamp: time (in jiffies) of last read_ptr change |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 156 | * @need_update: indicates need to update read/write idx |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 157 | * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled |
| 158 | * |
| 159 | * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame |
| 160 | * descriptors) and required locking structures. |
| 161 | */ |
| 162 | #define TFD_TX_CMD_SLOTS 256 |
| 163 | #define TFD_CMD_SLOTS 32 |
| 164 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 165 | struct il_tx_queue { |
| 166 | struct il_queue q; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 167 | void *tfds; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 168 | struct il_device_cmd **cmd; |
| 169 | struct il_cmd_meta *meta; |
| 170 | struct il_tx_info *txb; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 171 | unsigned long time_stamp; |
| 172 | u8 need_update; |
| 173 | u8 sched_retry; |
| 174 | u8 active; |
| 175 | u8 swq_id; |
| 176 | }; |
| 177 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 178 | #define IL_NUM_SCAN_RATES (2) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 179 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 180 | struct il4965_channel_tgd_info { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 181 | u8 type; |
| 182 | s8 max_power; |
| 183 | }; |
| 184 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 185 | struct il4965_channel_tgh_info { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 186 | s64 last_radar_time; |
| 187 | }; |
| 188 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 189 | #define IL4965_MAX_RATE (33) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 190 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 191 | struct il3945_clip_group { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 192 | /* maximum power level to prevent clipping for each rate, derived by |
| 193 | * us from this band's saturation power in EEPROM */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 194 | const s8 clip_powers[IL_MAX_RATES]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | /* current Tx power values to use, one for each rate for each channel. |
| 198 | * requested power is limited by: |
| 199 | * -- regulatory EEPROM limits for this channel |
| 200 | * -- hardware capabilities (clip-powers) |
| 201 | * -- spectrum management |
| 202 | * -- user preference (e.g. iwconfig) |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 203 | * when requested power is set, base power idx must also be set. */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 204 | struct il3945_channel_power_info { |
| 205 | struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 206 | s8 power_table_idx; /* actual (compenst'd) idx into gain table */ |
| 207 | s8 base_power_idx; /* gain idx for power at factory temp. */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 208 | s8 requested_power; /* power (dBm) requested for this chnl/rate */ |
| 209 | }; |
| 210 | |
| 211 | /* current scan Tx power values to use, one for each scan rate for each |
| 212 | * channel. */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 213 | struct il3945_scan_power_info { |
| 214 | struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 215 | s8 power_table_idx; /* actual (compenst'd) idx into gain table */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 216 | s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ |
| 217 | }; |
| 218 | |
| 219 | /* |
| 220 | * One for each channel, holds all channel setup data |
| 221 | * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant |
| 222 | * with one another! |
| 223 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 224 | struct il_channel_info { |
| 225 | struct il4965_channel_tgd_info tgd; |
| 226 | struct il4965_channel_tgh_info tgh; |
| 227 | struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */ |
| 228 | struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 229 | * HT40 channel */ |
| 230 | |
| 231 | u8 channel; /* channel number */ |
| 232 | u8 flags; /* flags copied from EEPROM */ |
| 233 | s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ |
| 234 | s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ |
| 235 | s8 min_power; /* always 0 */ |
| 236 | s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ |
| 237 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 238 | u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ |
| 239 | u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 240 | enum ieee80211_band band; |
| 241 | |
| 242 | /* HT40 channel info */ |
| 243 | s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ |
| 244 | u8 ht40_flags; /* flags copied from EEPROM */ |
| 245 | u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ |
| 246 | |
| 247 | /* Radio/DSP gain settings for each "normal" data Tx rate. |
| 248 | * These include, in addition to RF and DSP gain, a few fields for |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 249 | * remembering/modifying gain settings (idxes). */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 250 | struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 251 | |
| 252 | /* Radio/DSP gain settings for each scan rate, for directed scans. */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 253 | struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 254 | }; |
| 255 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 256 | #define IL_TX_FIFO_BK 0 /* shared */ |
| 257 | #define IL_TX_FIFO_BE 1 |
| 258 | #define IL_TX_FIFO_VI 2 /* shared */ |
| 259 | #define IL_TX_FIFO_VO 3 |
| 260 | #define IL_TX_FIFO_UNUSED -1 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 261 | |
| 262 | /* Minimum number of queues. MAX_NUM is defined in hw specific files. |
| 263 | * Set the minimum to accommodate the 4 standard TX queues, 1 command |
| 264 | * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 265 | #define IL_MIN_NUM_QUEUES 10 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 266 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 267 | #define IL_DEFAULT_CMD_QUEUE_NUM 4 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 268 | |
| 269 | #define IEEE80211_DATA_LEN 2304 |
| 270 | #define IEEE80211_4ADDR_LEN 30 |
| 271 | #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) |
| 272 | #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) |
| 273 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 274 | struct il_frame { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 275 | union { |
| 276 | struct ieee80211_hdr frame; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 277 | struct il_tx_beacon_cmd beacon; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 278 | u8 raw[IEEE80211_FRAME_LEN]; |
| 279 | u8 cmd[360]; |
| 280 | } u; |
| 281 | struct list_head list; |
| 282 | }; |
| 283 | |
| 284 | #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) |
| 285 | #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) |
| 286 | #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) |
| 287 | |
| 288 | enum { |
| 289 | CMD_SYNC = 0, |
| 290 | CMD_SIZE_NORMAL = 0, |
| 291 | CMD_NO_SKB = 0, |
| 292 | CMD_SIZE_HUGE = (1 << 0), |
| 293 | CMD_ASYNC = (1 << 1), |
| 294 | CMD_WANT_SKB = (1 << 2), |
Stanislaw Gruszka | 81e6326 | 2011-04-28 11:51:31 +0200 | [diff] [blame] | 295 | CMD_MAPPED = (1 << 3), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 296 | }; |
| 297 | |
| 298 | #define DEF_CMD_PAYLOAD_SIZE 320 |
| 299 | |
| 300 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 301 | * struct il_device_cmd |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 302 | * |
| 303 | * For allocation of the command and tx queues, this establishes the overall |
| 304 | * size of the largest command we send to uCode, except for a scan command |
| 305 | * (which is relatively huge; space is allocated separately). |
| 306 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 307 | struct il_device_cmd { |
| 308 | struct il_cmd_header hdr; /* uCode API */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 309 | union { |
| 310 | u32 flags; |
| 311 | u8 val8; |
| 312 | u16 val16; |
| 313 | u32 val32; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 314 | struct il_tx_cmd tx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 315 | u8 payload[DEF_CMD_PAYLOAD_SIZE]; |
| 316 | } __packed cmd; |
| 317 | } __packed; |
| 318 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 319 | #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 320 | |
| 321 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 322 | struct il_host_cmd { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 323 | const void *data; |
| 324 | unsigned long reply_page; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 325 | void (*callback)(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 326 | struct il_device_cmd *cmd, |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 327 | struct il_rx_pkt *pkt); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 328 | u32 flags; |
| 329 | u16 len; |
| 330 | u8 id; |
| 331 | }; |
| 332 | |
| 333 | #define SUP_RATE_11A_MAX_NUM_CHANNELS 8 |
| 334 | #define SUP_RATE_11B_MAX_NUM_CHANNELS 4 |
| 335 | #define SUP_RATE_11G_MAX_NUM_CHANNELS 12 |
| 336 | |
| 337 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 338 | * struct il_rx_queue - Rx queue |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 339 | * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) |
| 340 | * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 341 | * @read: Shared idx to newest available Rx buffer |
| 342 | * @write: Shared idx to oldest written Rx packet |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 343 | * @free_count: Number of pre-allocated buffers in rx_free |
| 344 | * @rx_free: list of free SKBs for use |
| 345 | * @rx_used: List of Rx buffers with no SKB |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 346 | * @need_update: flag to indicate we need to update read/write idx |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 347 | * @rb_stts: driver's pointer to receive buffer status |
| 348 | * @rb_stts_dma: bus address of receive buffer status |
| 349 | * |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 350 | * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 351 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 352 | struct il_rx_queue { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 353 | __le32 *bd; |
| 354 | dma_addr_t bd_dma; |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 355 | struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; |
| 356 | struct il_rx_buf *queue[RX_QUEUE_SIZE]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 357 | u32 read; |
| 358 | u32 write; |
| 359 | u32 free_count; |
| 360 | u32 write_actual; |
| 361 | struct list_head rx_free; |
| 362 | struct list_head rx_used; |
| 363 | int need_update; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 364 | struct il_rb_status *rb_stts; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 365 | dma_addr_t rb_stts_dma; |
| 366 | spinlock_t lock; |
| 367 | }; |
| 368 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 369 | #define IL_SUPPORTED_RATES_IE_LEN 8 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 370 | |
| 371 | #define MAX_TID_COUNT 9 |
| 372 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 373 | #define IL_INVALID_RATE 0xFF |
| 374 | #define IL_INVALID_VALUE -1 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 375 | |
| 376 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 377 | * struct il_ht_agg -- aggregation status while waiting for block-ack |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 378 | * @txq_id: Tx queue used for Tx attempt |
| 379 | * @frame_count: # frames attempted by Tx command |
| 380 | * @wait_for_ba: Expect block-ack before next Tx reply |
Stanislaw Gruszka | 6ce1dc4 | 2011-08-26 15:49:28 +0200 | [diff] [blame] | 381 | * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win |
| 382 | * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win |
| 383 | * @bitmap1: High order, one bit for each frame pending ACK in Tx win |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 384 | * @rate_n_flags: Rate at which Tx was attempted |
| 385 | * |
Stanislaw Gruszka | 4d69c75 | 2011-08-30 15:26:35 +0200 | [diff] [blame] | 386 | * If C_TX indicates that aggregation was attempted, driver must wait |
| 387 | * for block ack (N_COMPRESSED_BA). This struct stores tx reply info |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 388 | * until block ack arrives. |
| 389 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 390 | struct il_ht_agg { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 391 | u16 txq_id; |
| 392 | u16 frame_count; |
| 393 | u16 wait_for_ba; |
| 394 | u16 start_idx; |
| 395 | u64 bitmap; |
| 396 | u32 rate_n_flags; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 397 | #define IL_AGG_OFF 0 |
| 398 | #define IL_AGG_ON 1 |
| 399 | #define IL_EMPTYING_HW_QUEUE_ADDBA 2 |
| 400 | #define IL_EMPTYING_HW_QUEUE_DELBA 3 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 401 | u8 state; |
| 402 | }; |
| 403 | |
| 404 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 405 | struct il_tid_data { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 406 | u16 seq_number; /* 4965 only */ |
| 407 | u16 tfds_in_queue; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 408 | struct il_ht_agg agg; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 409 | }; |
| 410 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 411 | struct il_hw_key { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 412 | u32 cipher; |
| 413 | int keylen; |
| 414 | u8 keyidx; |
| 415 | u8 key[32]; |
| 416 | }; |
| 417 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 418 | union il_ht_rate_supp { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 419 | u16 rates; |
| 420 | struct { |
| 421 | u8 siso_rate; |
| 422 | u8 mimo_rate; |
| 423 | }; |
| 424 | }; |
| 425 | |
| 426 | #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0) |
| 427 | #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1) |
| 428 | #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2) |
| 429 | #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3) |
| 430 | #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K |
| 431 | #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K |
| 432 | #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K |
| 433 | |
| 434 | /* |
| 435 | * Maximal MPDU density for TX aggregation |
| 436 | * 4 - 2us density |
| 437 | * 5 - 4us density |
| 438 | * 6 - 8us density |
| 439 | * 7 - 16us density |
| 440 | */ |
| 441 | #define CFG_HT_MPDU_DENSITY_2USEC (0x4) |
| 442 | #define CFG_HT_MPDU_DENSITY_4USEC (0x5) |
| 443 | #define CFG_HT_MPDU_DENSITY_8USEC (0x6) |
| 444 | #define CFG_HT_MPDU_DENSITY_16USEC (0x7) |
| 445 | #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC |
| 446 | #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC |
| 447 | #define CFG_HT_MPDU_DENSITY_MIN (0x1) |
| 448 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 449 | struct il_ht_config { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 450 | bool single_chain_sufficient; |
| 451 | enum ieee80211_smps_mode smps; /* current smps mode */ |
| 452 | }; |
| 453 | |
| 454 | /* QoS structures */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 455 | struct il_qos_info { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 456 | int qos_active; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 457 | struct il_qosparam_cmd def_qos_parm; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 458 | }; |
| 459 | |
| 460 | /* |
| 461 | * Structure should be accessed with sta_lock held. When station addition |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 462 | * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only |
| 463 | * the commands (il_addsta_cmd and il_link_quality_cmd) without |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 464 | * sta_lock held. |
| 465 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 466 | struct il_station_entry { |
| 467 | struct il_addsta_cmd sta; |
| 468 | struct il_tid_data tid[MAX_TID_COUNT]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 469 | u8 used, ctxid; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 470 | struct il_hw_key keyinfo; |
| 471 | struct il_link_quality_cmd *lq; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 472 | }; |
| 473 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 474 | struct il_station_priv_common { |
| 475 | struct il_rxon_context *ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 476 | u8 sta_id; |
| 477 | }; |
| 478 | |
| 479 | /* |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 480 | * il_station_priv: Driver's ilate station information |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 481 | * |
| 482 | * When mac80211 creates a station it reserves some space (hw->sta_data_size) |
| 483 | * in the structure for use by driver. This structure is places in that |
| 484 | * space. |
| 485 | * |
| 486 | * The common struct MUST be first because it is shared between |
| 487 | * 3945 and 4965! |
| 488 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 489 | struct il_station_priv { |
| 490 | struct il_station_priv_common common; |
| 491 | struct il_lq_sta lq_sta; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 492 | atomic_t pending_frames; |
| 493 | bool client; |
| 494 | bool asleep; |
| 495 | }; |
| 496 | |
| 497 | /** |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 498 | * struct il_vif_priv - driver's ilate per-interface information |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 499 | * |
| 500 | * When mac80211 allocates a virtual interface, it can allocate |
| 501 | * space for us to put data into. |
| 502 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 503 | struct il_vif_priv { |
| 504 | struct il_rxon_context *ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 505 | u8 ibss_bssid_sta_id; |
| 506 | }; |
| 507 | |
| 508 | /* one for each uCode image (inst/data, boot/init/runtime) */ |
| 509 | struct fw_desc { |
| 510 | void *v_addr; /* access by driver */ |
| 511 | dma_addr_t p_addr; /* access by card's busmaster DMA */ |
| 512 | u32 len; /* bytes */ |
| 513 | }; |
| 514 | |
| 515 | /* uCode file layout */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 516 | struct il_ucode_header { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 517 | __le32 ver; /* major/minor/API/serial */ |
| 518 | struct { |
| 519 | __le32 inst_size; /* bytes of runtime code */ |
| 520 | __le32 data_size; /* bytes of runtime data */ |
| 521 | __le32 init_size; /* bytes of init code */ |
| 522 | __le32 init_data_size; /* bytes of init data */ |
| 523 | __le32 boot_size; /* bytes of bootstrap code */ |
| 524 | u8 data[0]; /* in same order as sizes */ |
| 525 | } v1; |
| 526 | }; |
| 527 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 528 | struct il4965_ibss_seq { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 529 | u8 mac[ETH_ALEN]; |
| 530 | u16 seq_num; |
| 531 | u16 frag_num; |
| 532 | unsigned long packet_time; |
| 533 | struct list_head list; |
| 534 | }; |
| 535 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 536 | struct il_sensitivity_ranges { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 537 | u16 min_nrg_cck; |
| 538 | u16 max_nrg_cck; |
| 539 | |
| 540 | u16 nrg_th_cck; |
| 541 | u16 nrg_th_ofdm; |
| 542 | |
| 543 | u16 auto_corr_min_ofdm; |
| 544 | u16 auto_corr_min_ofdm_mrc; |
| 545 | u16 auto_corr_min_ofdm_x1; |
| 546 | u16 auto_corr_min_ofdm_mrc_x1; |
| 547 | |
| 548 | u16 auto_corr_max_ofdm; |
| 549 | u16 auto_corr_max_ofdm_mrc; |
| 550 | u16 auto_corr_max_ofdm_x1; |
| 551 | u16 auto_corr_max_ofdm_mrc_x1; |
| 552 | |
| 553 | u16 auto_corr_max_cck; |
| 554 | u16 auto_corr_max_cck_mrc; |
| 555 | u16 auto_corr_min_cck; |
| 556 | u16 auto_corr_min_cck_mrc; |
| 557 | |
| 558 | u16 barker_corr_th_min; |
| 559 | u16 barker_corr_th_min_mrc; |
| 560 | u16 nrg_th_cca; |
| 561 | }; |
| 562 | |
| 563 | |
| 564 | #define KELVIN_TO_CELSIUS(x) ((x)-273) |
| 565 | #define CELSIUS_TO_KELVIN(x) ((x)+273) |
| 566 | |
| 567 | |
| 568 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 569 | * struct il_hw_params |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 570 | * @max_txq_num: Max # Tx queues supported |
| 571 | * @dma_chnl_num: Number of Tx DMA/FIFO channels |
| 572 | * @scd_bc_tbls_size: size of scheduler byte count tables |
| 573 | * @tfd_size: TFD size |
| 574 | * @tx/rx_chains_num: Number of TX/RX chains |
| 575 | * @valid_tx/rx_ant: usable antennas |
| 576 | * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2) |
| 577 | * @max_rxq_log: Log-base-2 of max_rxq_size |
| 578 | * @rx_page_order: Rx buffer page order |
| 579 | * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR |
| 580 | * @max_stations: |
| 581 | * @ht40_channel: is 40MHz width possible in band 2.4 |
| 582 | * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ) |
| 583 | * @sw_crypto: 0 for hw, 1 for sw |
| 584 | * @max_xxx_size: for ucode uses |
| 585 | * @ct_kill_threshold: temperature threshold |
| 586 | * @beacon_time_tsf_bits: number of valid tsf bits for beacon time |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 587 | * @struct il_sensitivity_ranges: range of sensitivity values |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 588 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 589 | struct il_hw_params { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 590 | u8 max_txq_num; |
| 591 | u8 dma_chnl_num; |
| 592 | u16 scd_bc_tbls_size; |
| 593 | u32 tfd_size; |
| 594 | u8 tx_chains_num; |
| 595 | u8 rx_chains_num; |
| 596 | u8 valid_tx_ant; |
| 597 | u8 valid_rx_ant; |
| 598 | u16 max_rxq_size; |
| 599 | u16 max_rxq_log; |
| 600 | u32 rx_page_order; |
| 601 | u32 rx_wrt_ptr_reg; |
| 602 | u8 max_stations; |
| 603 | u8 ht40_channel; |
| 604 | u8 max_beacon_itrvl; /* in 1024 ms */ |
| 605 | u32 max_inst_size; |
| 606 | u32 max_data_size; |
| 607 | u32 max_bsm_size; |
| 608 | u32 ct_kill_threshold; /* value in hw-dependent units */ |
| 609 | u16 beacon_time_tsf_bits; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 610 | const struct il_sensitivity_ranges *sens; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 611 | }; |
| 612 | |
| 613 | |
| 614 | /****************************************************************************** |
| 615 | * |
| 616 | * Functions implemented in core module which are forward declared here |
| 617 | * for use by iwl-[4-5].c |
| 618 | * |
| 619 | * NOTE: The implementation of these functions are not hardware specific |
| 620 | * which is why they are in the core module files. |
| 621 | * |
| 622 | * Naming convention -- |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 623 | * il_ <-- Is part of iwlwifi |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 624 | * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 625 | * il4965_bg_ <-- Called from work queue context |
| 626 | * il4965_mac_ <-- mac80211 callback |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 627 | * |
| 628 | ****************************************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 629 | extern void il4965_update_chain_flags(struct il_priv *il); |
Stanislaw Gruszka | d2ddf62 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 630 | extern const u8 il_bcast_addr[ETH_ALEN]; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 631 | extern int il_queue_space(const struct il_queue *q); |
| 632 | static inline int il_queue_used(const struct il_queue *q, int i) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 633 | { |
| 634 | return q->write_ptr >= q->read_ptr ? |
| 635 | (i >= q->read_ptr && i < q->write_ptr) : |
| 636 | !(i < q->read_ptr && i >= q->write_ptr); |
| 637 | } |
| 638 | |
| 639 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 640 | static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 641 | int is_huge) |
| 642 | { |
| 643 | /* |
| 644 | * This is for init calibration result and scan command which |
| 645 | * required buffer > TFD_MAX_PAYLOAD_SIZE, |
| 646 | * the big buffer at end of command array |
| 647 | */ |
| 648 | if (is_huge) |
Stanislaw Gruszka | 6ce1dc4 | 2011-08-26 15:49:28 +0200 | [diff] [blame] | 649 | return q->n_win; /* must be power of 2 */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 650 | |
| 651 | /* Otherwise, use normal size buffers */ |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 652 | return idx & (q->n_win - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 656 | struct il_dma_ptr { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 657 | dma_addr_t dma; |
| 658 | void *addr; |
| 659 | size_t size; |
| 660 | }; |
| 661 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 662 | #define IL_OPERATION_MODE_AUTO 0 |
| 663 | #define IL_OPERATION_MODE_HT_ONLY 1 |
| 664 | #define IL_OPERATION_MODE_MIXED 2 |
| 665 | #define IL_OPERATION_MODE_20MHZ 3 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 666 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 667 | #define IL_TX_CRC_SIZE 4 |
| 668 | #define IL_TX_DELIMITER_SIZE 4 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 669 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 670 | #define TX_POWER_IL_ILLEGAL_VOLTAGE -10000 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 671 | |
| 672 | /* Sensitivity and chain noise calibration */ |
| 673 | #define INITIALIZATION_VALUE 0xFFFF |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 674 | #define IL4965_CAL_NUM_BEACONS 20 |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 675 | #define IL_CAL_NUM_BEACONS 16 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 676 | #define MAXIMUM_ALLOWED_PATHLOSS 15 |
| 677 | |
| 678 | #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 |
| 679 | |
| 680 | #define MAX_FA_OFDM 50 |
| 681 | #define MIN_FA_OFDM 5 |
| 682 | #define MAX_FA_CCK 50 |
| 683 | #define MIN_FA_CCK 5 |
| 684 | |
| 685 | #define AUTO_CORR_STEP_OFDM 1 |
| 686 | |
| 687 | #define AUTO_CORR_STEP_CCK 3 |
| 688 | #define AUTO_CORR_MAX_TH_CCK 160 |
| 689 | |
| 690 | #define NRG_DIFF 2 |
| 691 | #define NRG_STEP_CCK 2 |
| 692 | #define NRG_MARGIN 8 |
| 693 | #define MAX_NUMBER_CCK_NO_FA 100 |
| 694 | |
| 695 | #define AUTO_CORR_CCK_MIN_VAL_DEF (125) |
| 696 | |
| 697 | #define CHAIN_A 0 |
| 698 | #define CHAIN_B 1 |
| 699 | #define CHAIN_C 2 |
| 700 | #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4 |
| 701 | #define ALL_BAND_FILTER 0xFF00 |
| 702 | #define IN_BAND_FILTER 0xFF |
| 703 | #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF |
| 704 | |
| 705 | #define NRG_NUM_PREV_STAT_L 20 |
| 706 | #define NUM_RX_CHAINS 3 |
| 707 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 708 | enum il4965_false_alarm_state { |
| 709 | IL_FA_TOO_MANY = 0, |
| 710 | IL_FA_TOO_FEW = 1, |
| 711 | IL_FA_GOOD_RANGE = 2, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 712 | }; |
| 713 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 714 | enum il4965_chain_noise_state { |
| 715 | IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ |
| 716 | IL_CHAIN_NOISE_ACCUMULATE, |
| 717 | IL_CHAIN_NOISE_CALIBRATED, |
| 718 | IL_CHAIN_NOISE_DONE, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 719 | }; |
| 720 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 721 | enum il4965_calib_enabled_state { |
| 722 | IL_CALIB_DISABLED = 0, /* must be 0 */ |
| 723 | IL_CALIB_ENABLED = 1, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 724 | }; |
| 725 | |
| 726 | /* |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 727 | * enum il_calib |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 728 | * defines the order in which results of initial calibrations |
| 729 | * should be sent to the runtime uCode |
| 730 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 731 | enum il_calib { |
| 732 | IL_CALIB_MAX, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 733 | }; |
| 734 | |
| 735 | /* Opaque calibration results */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 736 | struct il_calib_result { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 737 | void *buf; |
| 738 | size_t buf_len; |
| 739 | }; |
| 740 | |
| 741 | enum ucode_type { |
| 742 | UCODE_NONE = 0, |
| 743 | UCODE_INIT, |
| 744 | UCODE_RT |
| 745 | }; |
| 746 | |
| 747 | /* Sensitivity calib data */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 748 | struct il_sensitivity_data { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 749 | u32 auto_corr_ofdm; |
| 750 | u32 auto_corr_ofdm_mrc; |
| 751 | u32 auto_corr_ofdm_x1; |
| 752 | u32 auto_corr_ofdm_mrc_x1; |
| 753 | u32 auto_corr_cck; |
| 754 | u32 auto_corr_cck_mrc; |
| 755 | |
| 756 | u32 last_bad_plcp_cnt_ofdm; |
| 757 | u32 last_fa_cnt_ofdm; |
| 758 | u32 last_bad_plcp_cnt_cck; |
| 759 | u32 last_fa_cnt_cck; |
| 760 | |
| 761 | u32 nrg_curr_state; |
| 762 | u32 nrg_prev_state; |
| 763 | u32 nrg_value[10]; |
| 764 | u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; |
| 765 | u32 nrg_silence_ref; |
| 766 | u32 nrg_energy_idx; |
| 767 | u32 nrg_silence_idx; |
| 768 | u32 nrg_th_cck; |
| 769 | s32 nrg_auto_corr_silence_diff; |
| 770 | u32 num_in_cck_no_fa; |
| 771 | u32 nrg_th_ofdm; |
| 772 | |
| 773 | u16 barker_corr_th_min; |
| 774 | u16 barker_corr_th_min_mrc; |
| 775 | u16 nrg_th_cca; |
| 776 | }; |
| 777 | |
| 778 | /* Chain noise (differential Rx gain) calib data */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 779 | struct il_chain_noise_data { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 780 | u32 active_chains; |
| 781 | u32 chain_noise_a; |
| 782 | u32 chain_noise_b; |
| 783 | u32 chain_noise_c; |
| 784 | u32 chain_signal_a; |
| 785 | u32 chain_signal_b; |
| 786 | u32 chain_signal_c; |
| 787 | u16 beacon_count; |
| 788 | u8 disconn_array[NUM_RX_CHAINS]; |
| 789 | u8 delta_gain_code[NUM_RX_CHAINS]; |
| 790 | u8 radio_write; |
| 791 | u8 state; |
| 792 | }; |
| 793 | |
| 794 | #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ |
| 795 | #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ |
| 796 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 797 | #define IL_TRAFFIC_ENTRIES (256) |
| 798 | #define IL_TRAFFIC_ENTRY_SIZE (64) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 799 | |
| 800 | enum { |
| 801 | MEASUREMENT_READY = (1 << 0), |
| 802 | MEASUREMENT_ACTIVE = (1 << 1), |
| 803 | }; |
| 804 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 805 | /* interrupt stats */ |
| 806 | struct isr_stats { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 807 | u32 hw; |
| 808 | u32 sw; |
| 809 | u32 err_code; |
| 810 | u32 sch; |
| 811 | u32 alive; |
| 812 | u32 rfkill; |
| 813 | u32 ctkill; |
| 814 | u32 wakeup; |
| 815 | u32 rx; |
Stanislaw Gruszka | d0c7234 | 2011-08-30 15:39:42 +0200 | [diff] [blame] | 816 | u32 handlers[IL_CN_MAX]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 817 | u32 tx; |
| 818 | u32 unhandled; |
| 819 | }; |
| 820 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 821 | /* management stats */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 822 | enum il_mgmt_stats { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 823 | MANAGEMENT_ASSOC_REQ = 0, |
| 824 | MANAGEMENT_ASSOC_RESP, |
| 825 | MANAGEMENT_REASSOC_REQ, |
| 826 | MANAGEMENT_REASSOC_RESP, |
| 827 | MANAGEMENT_PROBE_REQ, |
| 828 | MANAGEMENT_PROBE_RESP, |
| 829 | MANAGEMENT_BEACON, |
| 830 | MANAGEMENT_ATIM, |
| 831 | MANAGEMENT_DISASSOC, |
| 832 | MANAGEMENT_AUTH, |
| 833 | MANAGEMENT_DEAUTH, |
| 834 | MANAGEMENT_ACTION, |
| 835 | MANAGEMENT_MAX, |
| 836 | }; |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 837 | /* control stats */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 838 | enum il_ctrl_stats { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 839 | CONTROL_BACK_REQ = 0, |
| 840 | CONTROL_BACK, |
| 841 | CONTROL_PSPOLL, |
| 842 | CONTROL_RTS, |
| 843 | CONTROL_CTS, |
| 844 | CONTROL_ACK, |
| 845 | CONTROL_CFEND, |
| 846 | CONTROL_CFENDACK, |
| 847 | CONTROL_MAX, |
| 848 | }; |
| 849 | |
| 850 | struct traffic_stats { |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 851 | #ifdef CONFIG_IWLEGACY_DEBUGFS |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 852 | u32 mgmt[MANAGEMENT_MAX]; |
| 853 | u32 ctrl[CONTROL_MAX]; |
| 854 | u32 data_cnt; |
| 855 | u64 data_bytes; |
| 856 | #endif |
| 857 | }; |
| 858 | |
| 859 | /* |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 860 | * host interrupt timeout value |
| 861 | * used with setting interrupt coalescing timer |
| 862 | * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit |
| 863 | * |
| 864 | * default interrupt coalescing timer is 64 x 32 = 2048 usecs |
| 865 | * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs |
| 866 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 867 | #define IL_HOST_INT_TIMEOUT_MAX (0xFF) |
| 868 | #define IL_HOST_INT_TIMEOUT_DEF (0x40) |
| 869 | #define IL_HOST_INT_TIMEOUT_MIN (0x0) |
| 870 | #define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) |
| 871 | #define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) |
| 872 | #define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 873 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 874 | #define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 875 | |
| 876 | /* TX queue watchdog timeouts in mSecs */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 877 | #define IL_DEF_WD_TIMEOUT (2000) |
| 878 | #define IL_LONG_WD_TIMEOUT (10000) |
| 879 | #define IL_MAX_WD_TIMEOUT (120000) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 880 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 881 | struct il_force_reset { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 882 | int reset_request_count; |
| 883 | int reset_success_count; |
| 884 | int reset_reject_count; |
| 885 | unsigned long reset_duration; |
| 886 | unsigned long last_force_reset_jiffies; |
| 887 | }; |
| 888 | |
| 889 | /* extend beacon time format bit shifting */ |
| 890 | /* |
| 891 | * for _3945 devices |
| 892 | * bits 31:24 - extended |
| 893 | * bits 23:0 - interval |
| 894 | */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 895 | #define IL3945_EXT_BEACON_TIME_POS 24 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 896 | /* |
| 897 | * for _4965 devices |
| 898 | * bits 31:22 - extended |
| 899 | * bits 21:0 - interval |
| 900 | */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 901 | #define IL4965_EXT_BEACON_TIME_POS 22 |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 902 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 903 | struct il_rxon_context { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 904 | struct ieee80211_vif *vif; |
| 905 | |
| 906 | const u8 *ac_to_fifo; |
| 907 | const u8 *ac_to_queue; |
| 908 | u8 mcast_queue; |
| 909 | |
| 910 | /* |
| 911 | * We could use the vif to indicate active, but we |
| 912 | * also need it to be active during disabling when |
| 913 | * we already removed the vif for type setting. |
| 914 | */ |
| 915 | bool always_active, is_active; |
| 916 | |
| 917 | bool ht_need_multiple_chains; |
| 918 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 919 | int ctxid; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 920 | |
| 921 | u32 interface_modes, exclusive_interface_modes; |
| 922 | u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; |
| 923 | |
| 924 | /* |
| 925 | * We declare this const so it can only be |
| 926 | * changed via explicit cast within the |
| 927 | * routines that actually update the physical |
| 928 | * hardware. |
| 929 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 930 | const struct il_rxon_cmd active; |
| 931 | struct il_rxon_cmd staging; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 932 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 933 | struct il_rxon_time_cmd timing; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 934 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 935 | struct il_qos_info qos_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 936 | |
| 937 | u8 bcast_sta_id, ap_sta_id; |
| 938 | |
| 939 | u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; |
| 940 | u8 qos_cmd; |
| 941 | u8 wep_key_cmd; |
| 942 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 943 | struct il_wep_key wep_keys[WEP_KEYS_MAX]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 944 | u8 key_mapping_keys; |
| 945 | |
| 946 | __le32 station_flags; |
| 947 | |
| 948 | struct { |
| 949 | bool non_gf_sta_present; |
| 950 | u8 protection; |
| 951 | bool enabled, is_40mhz; |
| 952 | u8 extension_chan_offset; |
| 953 | } ht; |
| 954 | }; |
| 955 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 956 | struct il_priv { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 957 | |
| 958 | /* ieee device used by generic ieee processing code */ |
| 959 | struct ieee80211_hw *hw; |
| 960 | struct ieee80211_channel *ieee_channels; |
| 961 | struct ieee80211_rate *ieee_rates; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 962 | struct il_cfg *cfg; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 963 | |
| 964 | /* temporary frame storage list */ |
| 965 | struct list_head free_frames; |
| 966 | int frames_count; |
| 967 | |
| 968 | enum ieee80211_band band; |
| 969 | int alloc_rxb_page; |
| 970 | |
Stanislaw Gruszka | d0c7234 | 2011-08-30 15:39:42 +0200 | [diff] [blame] | 971 | void (*handlers[IL_CN_MAX])(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 972 | struct il_rx_buf *rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 973 | |
| 974 | struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; |
| 975 | |
| 976 | /* spectrum measurement report caching */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 977 | struct il_spectrum_notification measure_report; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 978 | u8 measurement_status; |
| 979 | |
| 980 | /* ucode beacon time */ |
| 981 | u32 ucode_beacon_time; |
| 982 | int missed_beacon_threshold; |
| 983 | |
| 984 | /* track IBSS manager (last beacon) status */ |
| 985 | u32 ibss_manager; |
| 986 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 987 | /* force reset */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 988 | struct il_force_reset force_reset; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 989 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 990 | /* we allocate array of il_channel_info for NIC's valid channels. |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 991 | * Access via channel # using indirect idx array */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 992 | struct il_channel_info *channel_info; /* channel info array */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 993 | u8 channel_count; /* # of channels */ |
| 994 | |
| 995 | /* thermal calibration */ |
| 996 | s32 temperature; /* degrees Kelvin */ |
| 997 | s32 last_temperature; |
| 998 | |
| 999 | /* init calibration results */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1000 | struct il_calib_result calib_results[IL_CALIB_MAX]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1001 | |
| 1002 | /* Scan related variables */ |
| 1003 | unsigned long scan_start; |
| 1004 | unsigned long scan_start_tsf; |
| 1005 | void *scan_cmd; |
| 1006 | enum ieee80211_band scan_band; |
| 1007 | struct cfg80211_scan_request *scan_request; |
| 1008 | struct ieee80211_vif *scan_vif; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1009 | u8 scan_tx_ant[IEEE80211_NUM_BANDS]; |
| 1010 | u8 mgmt_tx_ant; |
| 1011 | |
| 1012 | /* spinlock */ |
| 1013 | spinlock_t lock; /* protect general shared data */ |
| 1014 | spinlock_t hcmd_lock; /* protect hcmd */ |
| 1015 | spinlock_t reg_lock; /* protect hw register access */ |
| 1016 | struct mutex mutex; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1017 | |
| 1018 | /* basic pci-network driver stuff */ |
| 1019 | struct pci_dev *pci_dev; |
| 1020 | |
| 1021 | /* pci hardware address support */ |
| 1022 | void __iomem *hw_base; |
| 1023 | u32 hw_rev; |
| 1024 | u32 hw_wa_rev; |
| 1025 | u8 rev_id; |
| 1026 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1027 | /* command queue number */ |
| 1028 | u8 cmd_queue; |
| 1029 | |
| 1030 | /* max number of station keys */ |
| 1031 | u8 sta_key_max_num; |
| 1032 | |
| 1033 | /* EEPROM MAC addresses */ |
| 1034 | struct mac_address addresses[1]; |
| 1035 | |
| 1036 | /* uCode images, save to reload in case of failure */ |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1037 | int fw_idx; /* firmware we're trying to load */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1038 | u32 ucode_ver; /* version of ucode, copy of |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1039 | il_ucode.ver */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1040 | struct fw_desc ucode_code; /* runtime inst */ |
| 1041 | struct fw_desc ucode_data; /* runtime data original */ |
| 1042 | struct fw_desc ucode_data_backup; /* runtime data save/restore */ |
| 1043 | struct fw_desc ucode_init; /* initialization inst */ |
| 1044 | struct fw_desc ucode_init_data; /* initialization data */ |
| 1045 | struct fw_desc ucode_boot; /* bootstrap inst */ |
| 1046 | enum ucode_type ucode_type; |
| 1047 | u8 ucode_write_complete; /* the image write is complete */ |
| 1048 | char firmware_name[25]; |
| 1049 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 1050 | struct il_rxon_context ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1051 | |
Stanislaw Gruszka | 51e6525 | 2011-06-08 15:26:31 +0200 | [diff] [blame] | 1052 | __le16 switch_channel; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1053 | |
| 1054 | /* 1st responses from initialize and runtime uCode images. |
| 1055 | * _4965's initialize alive response contains some calibration data. */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1056 | struct il_init_alive_resp card_alive_init; |
| 1057 | struct il_alive_resp card_alive; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1058 | |
| 1059 | u16 active_rate; |
| 1060 | |
| 1061 | u8 start_calib; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1062 | struct il_sensitivity_data sensitivity_data; |
| 1063 | struct il_chain_noise_data chain_noise_data; |
Stanislaw Gruszka | 3b98c7f | 2011-08-26 16:29:35 +0200 | [diff] [blame] | 1064 | __le16 sensitivity_tbl[HD_TBL_SIZE]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1065 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1066 | struct il_ht_config current_ht_config; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1067 | |
| 1068 | /* Rate scaling data */ |
| 1069 | u8 retry_rate; |
| 1070 | |
| 1071 | wait_queue_head_t wait_command_queue; |
| 1072 | |
| 1073 | int activity_timer_active; |
| 1074 | |
| 1075 | /* Rx and Tx DMA processing queues */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1076 | struct il_rx_queue rxq; |
| 1077 | struct il_tx_queue *txq; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1078 | unsigned long txq_ctx_active_msk; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1079 | struct il_dma_ptr kw; /* keep warm address */ |
| 1080 | struct il_dma_ptr scd_bc_tbls; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1081 | |
| 1082 | u32 scd_base_addr; /* scheduler sram base address */ |
| 1083 | |
| 1084 | unsigned long status; |
| 1085 | |
| 1086 | /* counts mgmt, ctl, and data packets */ |
| 1087 | struct traffic_stats tx_stats; |
| 1088 | struct traffic_stats rx_stats; |
| 1089 | |
| 1090 | /* counts interrupts */ |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1091 | struct isr_stats isr_stats; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1092 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1093 | struct il_power_mgr power_data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1094 | |
| 1095 | /* context information */ |
| 1096 | u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ |
| 1097 | |
| 1098 | /* station table variables */ |
| 1099 | |
| 1100 | /* Note: if lock and sta_lock are needed, lock must be acquired first */ |
| 1101 | spinlock_t sta_lock; |
| 1102 | int num_stations; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1103 | struct il_station_entry stations[IL_STATION_COUNT]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1104 | unsigned long ucode_key_table; |
| 1105 | |
| 1106 | /* queue refcounts */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1107 | #define IL_MAX_HW_QUEUES 32 |
| 1108 | unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1109 | /* for each AC */ |
| 1110 | atomic_t queue_stop_count[4]; |
| 1111 | |
| 1112 | /* Indication if ieee80211_ops->open has been called */ |
| 1113 | u8 is_open; |
| 1114 | |
| 1115 | u8 mac80211_registered; |
| 1116 | |
| 1117 | /* eeprom -- this is in the card's little endian byte order */ |
| 1118 | u8 *eeprom; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1119 | struct il_eeprom_calib_info *calib_info; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1120 | |
| 1121 | enum nl80211_iftype iw_mode; |
| 1122 | |
| 1123 | /* Last Rx'd beacon timestamp */ |
| 1124 | u64 timestamp; |
| 1125 | |
| 1126 | union { |
| 1127 | #if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE) |
| 1128 | struct { |
| 1129 | void *shared_virt; |
| 1130 | dma_addr_t shared_phys; |
| 1131 | |
| 1132 | struct delayed_work thermal_periodic; |
| 1133 | struct delayed_work rfkill_poll; |
| 1134 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1135 | struct il3945_notif_stats stats; |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1136 | #ifdef CONFIG_IWLEGACY_DEBUGFS |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1137 | struct il3945_notif_stats accum_stats; |
| 1138 | struct il3945_notif_stats delta_stats; |
| 1139 | struct il3945_notif_stats max_delta; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1140 | #endif |
| 1141 | |
| 1142 | u32 sta_supp_rates; |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1143 | int last_rx_rssi; /* From Rx packet stats */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1144 | |
| 1145 | /* Rx'd packet timing information */ |
| 1146 | u32 last_beacon_time; |
| 1147 | u64 last_tsf; |
| 1148 | |
| 1149 | /* |
| 1150 | * each calibration channel group in the |
| 1151 | * EEPROM has a derived clip setting for |
| 1152 | * each rate. |
| 1153 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1154 | const struct il3945_clip_group clip_groups[5]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1155 | |
| 1156 | } _3945; |
| 1157 | #endif |
| 1158 | #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) |
| 1159 | struct { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1160 | struct il_rx_phy_res last_phy_res; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1161 | bool last_phy_res_valid; |
| 1162 | |
| 1163 | struct completion firmware_loading_complete; |
| 1164 | |
| 1165 | /* |
| 1166 | * chain noise reset and gain commands are the |
| 1167 | * two extra calibration commands follows the standard |
| 1168 | * phy calibration commands |
| 1169 | */ |
| 1170 | u8 phy_calib_chain_noise_reset_cmd; |
| 1171 | u8 phy_calib_chain_noise_gain_cmd; |
| 1172 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1173 | struct il_notif_stats stats; |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1174 | #ifdef CONFIG_IWLEGACY_DEBUGFS |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1175 | struct il_notif_stats accum_stats; |
| 1176 | struct il_notif_stats delta_stats; |
| 1177 | struct il_notif_stats max_delta; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1178 | #endif |
| 1179 | |
| 1180 | } _4965; |
| 1181 | #endif |
| 1182 | }; |
| 1183 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1184 | struct il_hw_params hw_params; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1185 | |
| 1186 | u32 inta_mask; |
| 1187 | |
| 1188 | struct workqueue_struct *workqueue; |
| 1189 | |
| 1190 | struct work_struct restart; |
| 1191 | struct work_struct scan_completed; |
| 1192 | struct work_struct rx_replenish; |
| 1193 | struct work_struct abort_scan; |
| 1194 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1195 | struct il_rxon_context *beacon_ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1196 | struct sk_buff *beacon_skb; |
| 1197 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1198 | struct work_struct tx_flush; |
| 1199 | |
| 1200 | struct tasklet_struct irq_tasklet; |
| 1201 | |
| 1202 | struct delayed_work init_alive_start; |
| 1203 | struct delayed_work alive_start; |
| 1204 | struct delayed_work scan_check; |
| 1205 | |
| 1206 | /* TX Power */ |
| 1207 | s8 tx_power_user_lmt; |
| 1208 | s8 tx_power_device_lmt; |
| 1209 | s8 tx_power_next; |
| 1210 | |
| 1211 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1212 | #ifdef CONFIG_IWLEGACY_DEBUG |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1213 | /* debugging info */ |
| 1214 | u32 debug_level; /* per device debugging will override global |
Stanislaw Gruszka | d2ddf62 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 1215 | il_debug_level if set */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1216 | #endif /* CONFIG_IWLEGACY_DEBUG */ |
| 1217 | #ifdef CONFIG_IWLEGACY_DEBUGFS |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1218 | /* debugfs */ |
| 1219 | u16 tx_traffic_idx; |
| 1220 | u16 rx_traffic_idx; |
| 1221 | u8 *tx_traffic; |
| 1222 | u8 *rx_traffic; |
| 1223 | struct dentry *debugfs_dir; |
| 1224 | u32 dbgfs_sram_offset, dbgfs_sram_len; |
| 1225 | bool disable_ht40; |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1226 | #endif /* CONFIG_IWLEGACY_DEBUGFS */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1227 | |
| 1228 | struct work_struct txpower_work; |
| 1229 | u32 disable_sens_cal; |
| 1230 | u32 disable_chain_noise_cal; |
| 1231 | u32 disable_tx_power_cal; |
| 1232 | struct work_struct run_time_calib_work; |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1233 | struct timer_list stats_periodic; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1234 | struct timer_list watchdog; |
| 1235 | bool hw_ready; |
| 1236 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1237 | struct led_classdev led; |
| 1238 | unsigned long blink_on, blink_off; |
| 1239 | bool led_registered; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1240 | }; /*il_priv */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1241 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1242 | static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1243 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1244 | set_bit(txq_id, &il->txq_ctx_active_msk); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1245 | } |
| 1246 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1247 | static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1248 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1249 | clear_bit(txq_id, &il->txq_ctx_active_msk); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1250 | } |
| 1251 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1252 | #ifdef CONFIG_IWLEGACY_DEBUG |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1253 | /* |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1254 | * il_get_debug_level: Return active debug level for device |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1255 | * |
| 1256 | * Using sysfs it is possible to set per device debug level. This debug |
| 1257 | * level will be used if set, otherwise the global debug level which can be |
| 1258 | * set via module parameter is used. |
| 1259 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1260 | static inline u32 il_get_debug_level(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1261 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1262 | if (il->debug_level) |
| 1263 | return il->debug_level; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1264 | else |
Stanislaw Gruszka | d2ddf62 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 1265 | return il_debug_level; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1266 | } |
| 1267 | #else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1268 | static inline u32 il_get_debug_level(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1269 | { |
Stanislaw Gruszka | d2ddf62 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 1270 | return il_debug_level; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1271 | } |
| 1272 | #endif |
| 1273 | |
| 1274 | |
| 1275 | static inline struct ieee80211_hdr * |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1276 | il_tx_queue_get_hdr(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1277 | int txq_id, int idx) |
| 1278 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1279 | if (il->txq[txq_id].txb[idx].skb) |
| 1280 | return (struct ieee80211_hdr *)il->txq[txq_id]. |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1281 | txb[idx].skb->data; |
| 1282 | return NULL; |
| 1283 | } |
| 1284 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1285 | static inline struct il_rxon_context * |
| 1286 | il_rxon_ctx_from_vif(struct ieee80211_vif *vif) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1287 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1288 | struct il_vif_priv *vif_priv = (void *)vif->drv_priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1289 | |
| 1290 | return vif_priv->ctx; |
| 1291 | } |
| 1292 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 1293 | #define for_each_context(il, _ctx) \ |
| 1294 | for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1295 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 1296 | static inline int il_is_associated(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1297 | { |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 1298 | return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1299 | } |
| 1300 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1301 | static inline int il_is_any_associated(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1302 | { |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 1303 | return il_is_associated(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1304 | } |
| 1305 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1306 | static inline int il_is_associated_ctx(struct il_rxon_context *ctx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1307 | { |
| 1308 | return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; |
| 1309 | } |
| 1310 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1311 | static inline int il_is_channel_valid(const struct il_channel_info *ch_info) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1312 | { |
| 1313 | if (ch_info == NULL) |
| 1314 | return 0; |
| 1315 | return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; |
| 1316 | } |
| 1317 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1318 | static inline int il_is_channel_radar(const struct il_channel_info *ch_info) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1319 | { |
| 1320 | return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; |
| 1321 | } |
| 1322 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1323 | static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1324 | { |
| 1325 | return ch_info->band == IEEE80211_BAND_5GHZ; |
| 1326 | } |
| 1327 | |
| 1328 | static inline int |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1329 | il_is_channel_passive(const struct il_channel_info *ch) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1330 | { |
| 1331 | return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; |
| 1332 | } |
| 1333 | |
Stanislaw Gruszka | eb85de3 | 2011-05-07 17:46:21 +0200 | [diff] [blame] | 1334 | static inline int |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1335 | il_is_channel_ibss(const struct il_channel_info *ch) |
Stanislaw Gruszka | eb85de3 | 2011-05-07 17:46:21 +0200 | [diff] [blame] | 1336 | { |
| 1337 | return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; |
| 1338 | } |
| 1339 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1340 | static inline void |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1341 | __il_free_pages(struct il_priv *il, struct page *page) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1342 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1343 | __free_pages(page, il->hw_params.rx_page_order); |
| 1344 | il->alloc_rxb_page--; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1345 | } |
| 1346 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1347 | static inline void il_free_pages(struct il_priv *il, unsigned long page) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1348 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1349 | free_pages(page, il->hw_params.rx_page_order); |
| 1350 | il->alloc_rxb_page--; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1351 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1352 | #endif /* __il_dev_h__ */ |