Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Wey-Yi Guy | 901069c | 2011-04-05 09:42:00 -0700 | [diff] [blame] | 3 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4 | * |
| 5 | * Portions of this file are derived from the ipw3945 project, as well |
| 6 | * as portions of the ieee80211 subsystem header files. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of version 2 of the GNU General Public License as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 | * more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 20 | * |
| 21 | * The full GNU General Public License is included in this distribution in the |
| 22 | * file called LICENSE. |
| 23 | * |
| 24 | * Contact Information: |
Winkler, Tomas | 759ef89 | 2008-12-09 11:28:58 -0800 | [diff] [blame] | 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | * |
| 28 | *****************************************************************************/ |
| 29 | |
Joe Perches | c96c31e | 2010-07-26 14:39:58 -0700 | [diff] [blame] | 30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 31 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 32 | #include <linux/kernel.h> |
| 33 | #include <linux/module.h> |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 34 | #include <linux/init.h> |
| 35 | #include <linux/pci.h> |
John W. Linville | 1a7123c | 2010-08-05 14:39:31 -0400 | [diff] [blame] | 36 | #include <linux/pci-aspm.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 37 | #include <linux/slab.h> |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 38 | #include <linux/dma-mapping.h> |
| 39 | #include <linux/delay.h> |
Alexey Dobriyan | d43c36d | 2009-10-07 17:09:06 +0400 | [diff] [blame] | 40 | #include <linux/sched.h> |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 41 | #include <linux/skbuff.h> |
| 42 | #include <linux/netdevice.h> |
| 43 | #include <linux/wireless.h> |
| 44 | #include <linux/firmware.h> |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 45 | #include <linux/etherdevice.h> |
| 46 | #include <linux/if_arp.h> |
| 47 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 48 | #include <net/mac80211.h> |
| 49 | |
| 50 | #include <asm/div64.h> |
| 51 | |
Samuel Ortiz | a3139c5 | 2008-12-19 10:37:09 +0800 | [diff] [blame] | 52 | #define DRV_NAME "iwlagn" |
| 53 | |
Assaf Krauss | 6bc913b | 2008-03-11 16:17:18 -0700 | [diff] [blame] | 54 | #include "iwl-eeprom.h" |
Tomas Winkler | 3e0d4cb | 2008-04-24 11:55:38 -0700 | [diff] [blame] | 55 | #include "iwl-dev.h" |
Tomas Winkler | fee1247 | 2008-04-03 16:05:21 -0700 | [diff] [blame] | 56 | #include "iwl-core.h" |
Tomas Winkler | 3395f6e | 2008-03-25 16:33:37 -0700 | [diff] [blame] | 57 | #include "iwl-io.h" |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 58 | #include "iwl-helpers.h" |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 59 | #include "iwl-sta.h" |
Johannes Berg | 0de7673 | 2010-09-22 18:02:11 +0200 | [diff] [blame] | 60 | #include "iwl-agn-calib.h" |
Johannes Berg | a117512 | 2010-01-21 06:21:10 -0800 | [diff] [blame] | 61 | #include "iwl-agn.h" |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 62 | |
Christoph Hellwig | 416e143 | 2007-10-25 17:15:49 +0800 | [diff] [blame] | 63 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 64 | /****************************************************************************** |
| 65 | * |
| 66 | * module boiler plate |
| 67 | * |
| 68 | ******************************************************************************/ |
| 69 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 70 | /* |
| 71 | * module name, copyright, version, etc. |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 72 | */ |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 73 | #define DRV_DESCRIPTION "Intel(R) Wireless WiFi Link AGN driver for Linux" |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 74 | |
Tomas Winkler | 0a6857e | 2008-03-12 16:58:49 -0700 | [diff] [blame] | 75 | #ifdef CONFIG_IWLWIFI_DEBUG |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 76 | #define VD "d" |
| 77 | #else |
| 78 | #define VD |
| 79 | #endif |
| 80 | |
Reinette Chatre | 81963d6 | 2010-01-22 14:22:57 -0800 | [diff] [blame] | 81 | #define DRV_VERSION IWLWIFI_VERSION VD |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 82 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 83 | |
| 84 | MODULE_DESCRIPTION(DRV_DESCRIPTION); |
| 85 | MODULE_VERSION(DRV_VERSION); |
Tomas Winkler | a7b7520 | 2008-12-11 10:33:41 -0800 | [diff] [blame] | 86 | MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 87 | MODULE_LICENSE("GPL"); |
| 88 | |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 89 | static int iwlagn_ant_coupling; |
Wey-Yi Guy | f37837c | 2010-08-23 07:57:12 -0700 | [diff] [blame] | 90 | static bool iwlagn_bt_ch_announce = 1; |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 91 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 92 | void iwl_update_chain_flags(struct iwl_priv *priv) |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 93 | { |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 94 | struct iwl_rxon_context *ctx; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 95 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 96 | if (priv->cfg->ops->hcmd->set_rxon_chain) { |
| 97 | for_each_context(priv, ctx) { |
| 98 | priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); |
Shanyu Zhao | 6163a37 | 2010-11-12 13:48:13 -0800 | [diff] [blame] | 99 | if (ctx->active.rx_chain != ctx->staging.rx_chain) |
| 100 | iwlcore_commit_rxon(priv, ctx); |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 101 | } |
| 102 | } |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 105 | /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ |
| 106 | static void iwl_set_beacon_tim(struct iwl_priv *priv, |
Johannes Berg | 7783454 | 2010-10-04 05:50:36 -0700 | [diff] [blame] | 107 | struct iwl_tx_beacon_cmd *tx_beacon_cmd, |
| 108 | u8 *beacon, u32 frame_size) |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 109 | { |
| 110 | u16 tim_idx; |
| 111 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; |
| 112 | |
| 113 | /* |
| 114 | * The index is relative to frame start but we start looking at the |
| 115 | * variable-length part of the beacon. |
| 116 | */ |
| 117 | tim_idx = mgmt->u.beacon.variable - beacon; |
| 118 | |
| 119 | /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ |
| 120 | while ((tim_idx < (frame_size - 2)) && |
| 121 | (beacon[tim_idx] != WLAN_EID_TIM)) |
| 122 | tim_idx += beacon[tim_idx+1] + 2; |
| 123 | |
| 124 | /* If TIM field was found, set variables */ |
| 125 | if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { |
| 126 | tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); |
| 127 | tx_beacon_cmd->tim_size = beacon[tim_idx+1]; |
| 128 | } else |
| 129 | IWL_WARN(priv, "Unable to find TIM Element in beacon\n"); |
| 130 | } |
| 131 | |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 132 | int iwlagn_send_beacon_cmd(struct iwl_priv *priv) |
Tomas Winkler | 4bf64ef | 2008-07-18 13:53:03 +0800 | [diff] [blame] | 133 | { |
| 134 | struct iwl_tx_beacon_cmd *tx_beacon_cmd; |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 135 | struct iwl_host_cmd cmd = { |
| 136 | .id = REPLY_TX_BEACON, |
| 137 | .flags = CMD_SIZE_HUGE, |
| 138 | }; |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 139 | u32 frame_size; |
| 140 | u32 rate_flags; |
| 141 | u32 rate; |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 142 | int err; |
| 143 | |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 144 | /* |
| 145 | * We have to set up the TX command, the TX Beacon command, and the |
| 146 | * beacon contents. |
| 147 | */ |
Tomas Winkler | 4bf64ef | 2008-07-18 13:53:03 +0800 | [diff] [blame] | 148 | |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 149 | lockdep_assert_held(&priv->mutex); |
| 150 | |
| 151 | if (!priv->beacon_ctx) { |
| 152 | IWL_ERR(priv, "trying to build beacon w/o beacon context!\n"); |
Julia Lawall | 950094c | 2010-09-05 21:00:26 +0200 | [diff] [blame] | 153 | return 0; |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 154 | } |
| 155 | |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 156 | if (WARN_ON(!priv->beacon_skb)) |
| 157 | return -EINVAL; |
| 158 | |
| 159 | /* Allocate beacon memory */ |
| 160 | tx_beacon_cmd = kzalloc(sizeof(*tx_beacon_cmd) + priv->beacon_skb->len, |
| 161 | GFP_KERNEL); |
| 162 | if (!tx_beacon_cmd) |
| 163 | return -ENOMEM; |
| 164 | |
| 165 | frame_size = priv->beacon_skb->len; |
Tomas Winkler | 4bf64ef | 2008-07-18 13:53:03 +0800 | [diff] [blame] | 166 | |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 167 | /* Set up TX beacon contents */ |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 168 | memcpy(tx_beacon_cmd->frame, priv->beacon_skb->data, frame_size); |
Tomas Winkler | 4bf64ef | 2008-07-18 13:53:03 +0800 | [diff] [blame] | 169 | |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 170 | /* Set up TX command fields */ |
Tomas Winkler | 4bf64ef | 2008-07-18 13:53:03 +0800 | [diff] [blame] | 171 | tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 172 | tx_beacon_cmd->tx.sta_id = priv->beacon_ctx->bcast_sta_id; |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 173 | tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; |
Tomas Winkler | 4bf64ef | 2008-07-18 13:53:03 +0800 | [diff] [blame] | 174 | tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 175 | TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; |
| 176 | |
| 177 | /* Set up TX beacon command fields */ |
| 178 | iwl_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, |
Johannes Berg | 7783454 | 2010-10-04 05:50:36 -0700 | [diff] [blame] | 179 | frame_size); |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 180 | |
| 181 | /* Set up packet rate and flags */ |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 182 | rate = iwl_rate_get_lowest_plcp(priv, priv->beacon_ctx); |
Johannes Berg | 0e1654f | 2010-05-18 02:48:36 -0700 | [diff] [blame] | 183 | priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant, |
| 184 | priv->hw_params.valid_tx_ant); |
Daniel C Halperin | 47ff65c | 2009-11-13 11:56:33 -0800 | [diff] [blame] | 185 | rate_flags = iwl_ant_idx_to_flags(priv->mgmt_tx_ant); |
| 186 | if ((rate >= IWL_FIRST_CCK_RATE) && (rate <= IWL_LAST_CCK_RATE)) |
| 187 | rate_flags |= RATE_MCS_CCK_MSK; |
| 188 | tx_beacon_cmd->tx.rate_n_flags = iwl_hw_set_rate_n_flags(rate, |
| 189 | rate_flags); |
Tomas Winkler | 4bf64ef | 2008-07-18 13:53:03 +0800 | [diff] [blame] | 190 | |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 191 | /* Submit command */ |
Johannes Berg | 3fa5073 | 2011-05-04 07:50:38 -0700 | [diff] [blame^] | 192 | cmd.len[0] = sizeof(*tx_beacon_cmd) + frame_size; |
| 193 | cmd.data[0] = tx_beacon_cmd; |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 194 | |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 195 | err = iwl_send_cmd_sync(priv, &cmd); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 196 | |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 197 | /* Free temporary storage */ |
| 198 | kfree(tx_beacon_cmd); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 199 | |
Johannes Berg | 8a98d49 | 2011-04-29 09:48:14 -0700 | [diff] [blame] | 200 | return err; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 203 | static inline dma_addr_t iwl_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx) |
| 204 | { |
| 205 | struct iwl_tfd_tb *tb = &tfd->tbs[idx]; |
| 206 | |
| 207 | dma_addr_t addr = get_unaligned_le32(&tb->lo); |
| 208 | if (sizeof(dma_addr_t) > sizeof(u32)) |
| 209 | addr |= |
| 210 | ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; |
| 211 | |
| 212 | return addr; |
| 213 | } |
| 214 | |
| 215 | static inline u16 iwl_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx) |
| 216 | { |
| 217 | struct iwl_tfd_tb *tb = &tfd->tbs[idx]; |
| 218 | |
| 219 | return le16_to_cpu(tb->hi_n_len) >> 4; |
| 220 | } |
| 221 | |
| 222 | static inline void iwl_tfd_set_tb(struct iwl_tfd *tfd, u8 idx, |
| 223 | dma_addr_t addr, u16 len) |
| 224 | { |
| 225 | struct iwl_tfd_tb *tb = &tfd->tbs[idx]; |
| 226 | u16 hi_n_len = len << 4; |
| 227 | |
| 228 | put_unaligned_le32(addr, &tb->lo); |
| 229 | if (sizeof(dma_addr_t) > sizeof(u32)) |
| 230 | hi_n_len |= ((addr >> 16) >> 16) & 0xF; |
| 231 | |
| 232 | tb->hi_n_len = cpu_to_le16(hi_n_len); |
| 233 | |
| 234 | tfd->num_tbs = idx + 1; |
| 235 | } |
| 236 | |
| 237 | static inline u8 iwl_tfd_get_num_tbs(struct iwl_tfd *tfd) |
| 238 | { |
| 239 | return tfd->num_tbs & 0x1f; |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] |
| 244 | * @priv - driver private data |
| 245 | * @txq - tx queue |
| 246 | * |
| 247 | * Does NOT advance any TFD circular buffer read/write indexes |
| 248 | * Does NOT free the TFD itself (which is within circular buffer) |
| 249 | */ |
| 250 | void iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) |
| 251 | { |
Samuel Ortiz | 59606ff | 2009-01-23 13:45:13 -0800 | [diff] [blame] | 252 | struct iwl_tfd *tfd_tmp = (struct iwl_tfd *)txq->tfds; |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 253 | struct iwl_tfd *tfd; |
| 254 | struct pci_dev *dev = priv->pci_dev; |
| 255 | int index = txq->q.read_ptr; |
| 256 | int i; |
| 257 | int num_tbs; |
| 258 | |
| 259 | tfd = &tfd_tmp[index]; |
| 260 | |
| 261 | /* Sanity check on number of chunks */ |
| 262 | num_tbs = iwl_tfd_get_num_tbs(tfd); |
| 263 | |
| 264 | if (num_tbs >= IWL_NUM_OF_TBS) { |
| 265 | IWL_ERR(priv, "Too many chunks: %i\n", num_tbs); |
| 266 | /* @todo issue fatal error, it is quite serious situation */ |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | /* Unmap tx_cmd */ |
| 271 | if (num_tbs) |
| 272 | pci_unmap_single(dev, |
FUJITA Tomonori | 2e72444 | 2010-06-03 14:19:20 +0900 | [diff] [blame] | 273 | dma_unmap_addr(&txq->meta[index], mapping), |
| 274 | dma_unmap_len(&txq->meta[index], len), |
Fenghua Yu | 96891ce | 2009-02-18 15:54:33 -0800 | [diff] [blame] | 275 | PCI_DMA_BIDIRECTIONAL); |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 276 | |
| 277 | /* Unmap chunks, if any. */ |
Johannes Berg | ff0d91c | 2010-05-17 02:37:34 -0700 | [diff] [blame] | 278 | for (i = 1; i < num_tbs; i++) |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 279 | pci_unmap_single(dev, iwl_tfd_tb_get_addr(tfd, i), |
| 280 | iwl_tfd_tb_get_len(tfd, i), PCI_DMA_TODEVICE); |
| 281 | |
Johannes Berg | ff0d91c | 2010-05-17 02:37:34 -0700 | [diff] [blame] | 282 | /* free SKB */ |
| 283 | if (txq->txb) { |
| 284 | struct sk_buff *skb; |
Johannes Berg | 6f80240 | 2010-05-17 02:37:32 -0700 | [diff] [blame] | 285 | |
Johannes Berg | ff0d91c | 2010-05-17 02:37:34 -0700 | [diff] [blame] | 286 | skb = txq->txb[txq->q.read_ptr].skb; |
Johannes Berg | 6f80240 | 2010-05-17 02:37:32 -0700 | [diff] [blame] | 287 | |
Johannes Berg | ff0d91c | 2010-05-17 02:37:34 -0700 | [diff] [blame] | 288 | /* can be called from irqs-disabled context */ |
| 289 | if (skb) { |
| 290 | dev_kfree_skb_any(skb); |
| 291 | txq->txb[txq->q.read_ptr].skb = NULL; |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, |
| 297 | struct iwl_tx_queue *txq, |
| 298 | dma_addr_t addr, u16 len, |
| 299 | u8 reset, u8 pad) |
| 300 | { |
| 301 | struct iwl_queue *q; |
Samuel Ortiz | 59606ff | 2009-01-23 13:45:13 -0800 | [diff] [blame] | 302 | struct iwl_tfd *tfd, *tfd_tmp; |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 303 | u32 num_tbs; |
| 304 | |
| 305 | q = &txq->q; |
Samuel Ortiz | 59606ff | 2009-01-23 13:45:13 -0800 | [diff] [blame] | 306 | tfd_tmp = (struct iwl_tfd *)txq->tfds; |
| 307 | tfd = &tfd_tmp[q->write_ptr]; |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 308 | |
| 309 | if (reset) |
| 310 | memset(tfd, 0, sizeof(*tfd)); |
| 311 | |
| 312 | num_tbs = iwl_tfd_get_num_tbs(tfd); |
| 313 | |
| 314 | /* Each TFD can point to a maximum 20 Tx buffers */ |
| 315 | if (num_tbs >= IWL_NUM_OF_TBS) { |
| 316 | IWL_ERR(priv, "Error can not send more than %d chunks\n", |
| 317 | IWL_NUM_OF_TBS); |
| 318 | return -EINVAL; |
| 319 | } |
| 320 | |
Johannes Berg | 3e41ace | 2011-04-18 09:12:37 -0700 | [diff] [blame] | 321 | if (WARN_ON(addr & ~DMA_BIT_MASK(36))) |
| 322 | return -EINVAL; |
| 323 | |
Samuel Ortiz | 7aaa1d7 | 2009-01-19 15:30:26 -0800 | [diff] [blame] | 324 | if (unlikely(addr & ~IWL_TX_DMA_MASK)) |
| 325 | IWL_ERR(priv, "Unaligned address = %llx\n", |
| 326 | (unsigned long long)addr); |
| 327 | |
| 328 | iwl_tfd_set_tb(tfd, num_tbs, addr, len); |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
Samuel Ortiz | a8e74e27 | 2009-01-23 13:45:14 -0800 | [diff] [blame] | 333 | /* |
| 334 | * Tell nic where to find circular buffer of Tx Frame Descriptors for |
| 335 | * given Tx queue, and enable the DMA channel used for that queue. |
| 336 | * |
Wey-Yi Guy | f7d046f | 2011-03-22 08:05:37 -0700 | [diff] [blame] | 337 | * supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA |
Samuel Ortiz | a8e74e27 | 2009-01-23 13:45:14 -0800 | [diff] [blame] | 338 | * channels supported in hardware. |
| 339 | */ |
| 340 | int iwl_hw_tx_queue_init(struct iwl_priv *priv, |
| 341 | struct iwl_tx_queue *txq) |
| 342 | { |
Samuel Ortiz | a8e74e27 | 2009-01-23 13:45:14 -0800 | [diff] [blame] | 343 | int txq_id = txq->q.id; |
| 344 | |
Samuel Ortiz | a8e74e27 | 2009-01-23 13:45:14 -0800 | [diff] [blame] | 345 | /* Circular buffer (TFD queue in DRAM) physical base address */ |
| 346 | iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), |
| 347 | txq->q.dma_addr >> 8); |
| 348 | |
Samuel Ortiz | a8e74e27 | 2009-01-23 13:45:14 -0800 | [diff] [blame] | 349 | return 0; |
| 350 | } |
| 351 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 352 | static void iwl_bg_beacon_update(struct work_struct *work) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 353 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 354 | struct iwl_priv *priv = |
| 355 | container_of(work, struct iwl_priv, beacon_update); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 356 | struct sk_buff *beacon; |
| 357 | |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 358 | mutex_lock(&priv->mutex); |
| 359 | if (!priv->beacon_ctx) { |
| 360 | IWL_ERR(priv, "updating beacon w/o beacon context!\n"); |
| 361 | goto out; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 362 | } |
| 363 | |
Johannes Berg | 60744f6 | 2010-08-23 10:46:50 +0200 | [diff] [blame] | 364 | if (priv->beacon_ctx->vif->type != NL80211_IFTYPE_AP) { |
| 365 | /* |
| 366 | * The ucode will send beacon notifications even in |
| 367 | * IBSS mode, but we don't want to process them. But |
| 368 | * we need to defer the type check to here due to |
| 369 | * requiring locking around the beacon_ctx access. |
| 370 | */ |
| 371 | goto out; |
| 372 | } |
| 373 | |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 374 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ |
| 375 | beacon = ieee80211_beacon_get(priv->hw, priv->beacon_ctx->vif); |
| 376 | if (!beacon) { |
Johannes Berg | 7783454 | 2010-10-04 05:50:36 -0700 | [diff] [blame] | 377 | IWL_ERR(priv, "update beacon failed -- keeping old\n"); |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 378 | goto out; |
| 379 | } |
| 380 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 381 | /* new beacon skb is allocated every time; dispose previous.*/ |
Johannes Berg | 7783454 | 2010-10-04 05:50:36 -0700 | [diff] [blame] | 382 | dev_kfree_skb(priv->beacon_skb); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 383 | |
Johannes Berg | 12e934d | 2010-10-04 05:50:06 -0700 | [diff] [blame] | 384 | priv->beacon_skb = beacon; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 385 | |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 386 | iwlagn_send_beacon_cmd(priv); |
Johannes Berg | 76d0481 | 2010-08-23 10:46:47 +0200 | [diff] [blame] | 387 | out: |
| 388 | mutex_unlock(&priv->mutex); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Wey-Yi Guy | fbba941 | 2010-08-23 07:57:10 -0700 | [diff] [blame] | 391 | static void iwl_bg_bt_runtime_config(struct work_struct *work) |
| 392 | { |
| 393 | struct iwl_priv *priv = |
| 394 | container_of(work, struct iwl_priv, bt_runtime_config); |
| 395 | |
| 396 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 397 | return; |
| 398 | |
| 399 | /* dont send host command if rf-kill is on */ |
| 400 | if (!iwl_is_ready_rf(priv)) |
| 401 | return; |
| 402 | priv->cfg->ops->hcmd->send_bt_config(priv); |
| 403 | } |
| 404 | |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 405 | static void iwl_bg_bt_full_concurrency(struct work_struct *work) |
| 406 | { |
| 407 | struct iwl_priv *priv = |
| 408 | container_of(work, struct iwl_priv, bt_full_concurrency); |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 409 | struct iwl_rxon_context *ctx; |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 410 | |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 411 | mutex_lock(&priv->mutex); |
| 412 | |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 413 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 414 | goto out; |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 415 | |
| 416 | /* dont send host command if rf-kill is on */ |
| 417 | if (!iwl_is_ready_rf(priv)) |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 418 | goto out; |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 419 | |
| 420 | IWL_DEBUG_INFO(priv, "BT coex in %s mode\n", |
| 421 | priv->bt_full_concurrent ? |
| 422 | "full concurrency" : "3-wire"); |
| 423 | |
| 424 | /* |
| 425 | * LQ & RXON updated cmds must be sent before BT Config cmd |
| 426 | * to avoid 3-wire collisions |
| 427 | */ |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 428 | for_each_context(priv, ctx) { |
| 429 | if (priv->cfg->ops->hcmd->set_rxon_chain) |
| 430 | priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); |
| 431 | iwlcore_commit_rxon(priv, ctx); |
| 432 | } |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 433 | |
| 434 | priv->cfg->ops->hcmd->send_bt_config(priv); |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 435 | out: |
| 436 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 437 | } |
| 438 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 439 | /** |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 440 | * iwl_bg_statistics_periodic - Timer callback to queue statistics |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 441 | * |
| 442 | * This callback is provided in order to send a statistics request. |
| 443 | * |
| 444 | * This timer function is continually reset to execute within |
| 445 | * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION |
| 446 | * was received. We need to ensure we receive the statistics in order |
| 447 | * to update the temperature used for calibrating the TXPOWER. |
| 448 | */ |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 449 | static void iwl_bg_statistics_periodic(unsigned long data) |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 450 | { |
| 451 | struct iwl_priv *priv = (struct iwl_priv *)data; |
| 452 | |
| 453 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 454 | return; |
| 455 | |
Mohamed Abbas | 61780ee | 2008-10-29 14:05:49 -0700 | [diff] [blame] | 456 | /* dont send host command if rf-kill is on */ |
| 457 | if (!iwl_is_ready_rf(priv)) |
| 458 | return; |
| 459 | |
Wey-Yi Guy | ef8d552 | 2009-11-13 11:56:28 -0800 | [diff] [blame] | 460 | iwl_send_statistics_request(priv, CMD_ASYNC, false); |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 461 | } |
| 462 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 463 | |
| 464 | static void iwl_print_cont_event_trace(struct iwl_priv *priv, u32 base, |
| 465 | u32 start_idx, u32 num_events, |
| 466 | u32 mode) |
| 467 | { |
| 468 | u32 i; |
| 469 | u32 ptr; /* SRAM byte address of log data */ |
| 470 | u32 ev, time, data; /* event log data */ |
| 471 | unsigned long reg_flags; |
| 472 | |
| 473 | if (mode == 0) |
| 474 | ptr = base + (4 * sizeof(u32)) + (start_idx * 2 * sizeof(u32)); |
| 475 | else |
| 476 | ptr = base + (4 * sizeof(u32)) + (start_idx * 3 * sizeof(u32)); |
| 477 | |
| 478 | /* Make sure device is powered up for SRAM reads */ |
| 479 | spin_lock_irqsave(&priv->reg_lock, reg_flags); |
| 480 | if (iwl_grab_nic_access(priv)) { |
| 481 | spin_unlock_irqrestore(&priv->reg_lock, reg_flags); |
| 482 | return; |
| 483 | } |
| 484 | |
| 485 | /* Set starting address; reads will auto-increment */ |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 486 | iwl_write32(priv, HBUS_TARG_MEM_RADDR, ptr); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 487 | rmb(); |
| 488 | |
| 489 | /* |
| 490 | * "time" is actually "data" for mode 0 (no timestamp). |
| 491 | * place event id # at far right for easier visual parsing. |
| 492 | */ |
| 493 | for (i = 0; i < num_events; i++) { |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 494 | ev = iwl_read32(priv, HBUS_TARG_MEM_RDAT); |
| 495 | time = iwl_read32(priv, HBUS_TARG_MEM_RDAT); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 496 | if (mode == 0) { |
| 497 | trace_iwlwifi_dev_ucode_cont_event(priv, |
| 498 | 0, time, ev); |
| 499 | } else { |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 500 | data = iwl_read32(priv, HBUS_TARG_MEM_RDAT); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 501 | trace_iwlwifi_dev_ucode_cont_event(priv, |
| 502 | time, data, ev); |
| 503 | } |
| 504 | } |
| 505 | /* Allow device to power down */ |
| 506 | iwl_release_nic_access(priv); |
| 507 | spin_unlock_irqrestore(&priv->reg_lock, reg_flags); |
| 508 | } |
| 509 | |
Johannes Berg | 875295f | 2010-01-22 14:22:55 -0800 | [diff] [blame] | 510 | static void iwl_continuous_event_trace(struct iwl_priv *priv) |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 511 | { |
| 512 | u32 capacity; /* event log capacity in # entries */ |
| 513 | u32 base; /* SRAM byte address of event log header */ |
| 514 | u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ |
| 515 | u32 num_wraps; /* # times uCode wrapped to top of log */ |
| 516 | u32 next_entry; /* index of next entry to be written by uCode */ |
| 517 | |
Johannes Berg | d7d5783 | 2011-04-05 09:42:04 -0700 | [diff] [blame] | 518 | base = priv->device_pointers.error_event_table; |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 519 | if (priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { |
| 520 | capacity = iwl_read_targ_mem(priv, base); |
| 521 | num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); |
| 522 | mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32))); |
| 523 | next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32))); |
| 524 | } else |
| 525 | return; |
| 526 | |
| 527 | if (num_wraps == priv->event_log.num_wraps) { |
| 528 | iwl_print_cont_event_trace(priv, |
| 529 | base, priv->event_log.next_entry, |
| 530 | next_entry - priv->event_log.next_entry, |
| 531 | mode); |
| 532 | priv->event_log.non_wraps_count++; |
| 533 | } else { |
| 534 | if ((num_wraps - priv->event_log.num_wraps) > 1) |
| 535 | priv->event_log.wraps_more_count++; |
| 536 | else |
| 537 | priv->event_log.wraps_once_count++; |
| 538 | trace_iwlwifi_dev_ucode_wrap_event(priv, |
| 539 | num_wraps - priv->event_log.num_wraps, |
| 540 | next_entry, priv->event_log.next_entry); |
| 541 | if (next_entry < priv->event_log.next_entry) { |
| 542 | iwl_print_cont_event_trace(priv, base, |
| 543 | priv->event_log.next_entry, |
| 544 | capacity - priv->event_log.next_entry, |
| 545 | mode); |
| 546 | |
| 547 | iwl_print_cont_event_trace(priv, base, 0, |
| 548 | next_entry, mode); |
| 549 | } else { |
| 550 | iwl_print_cont_event_trace(priv, base, |
| 551 | next_entry, capacity - next_entry, |
| 552 | mode); |
| 553 | |
| 554 | iwl_print_cont_event_trace(priv, base, 0, |
| 555 | next_entry, mode); |
| 556 | } |
| 557 | } |
| 558 | priv->event_log.num_wraps = num_wraps; |
| 559 | priv->event_log.next_entry = next_entry; |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * iwl_bg_ucode_trace - Timer callback to log ucode event |
| 564 | * |
| 565 | * The timer is continually set to execute every |
| 566 | * UCODE_TRACE_PERIOD milliseconds after the last timer expired |
| 567 | * this function is to perform continuous uCode event logging operation |
| 568 | * if enabled |
| 569 | */ |
| 570 | static void iwl_bg_ucode_trace(unsigned long data) |
| 571 | { |
| 572 | struct iwl_priv *priv = (struct iwl_priv *)data; |
| 573 | |
| 574 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 575 | return; |
| 576 | |
| 577 | if (priv->event_log.ucode_trace) { |
| 578 | iwl_continuous_event_trace(priv); |
| 579 | /* Reschedule the timer to occur in UCODE_TRACE_PERIOD */ |
| 580 | mod_timer(&priv->ucode_trace, |
| 581 | jiffies + msecs_to_jiffies(UCODE_TRACE_PERIOD)); |
| 582 | } |
| 583 | } |
| 584 | |
Wey-Yi Guy | 6555063 | 2010-06-24 13:18:35 -0700 | [diff] [blame] | 585 | static void iwl_bg_tx_flush(struct work_struct *work) |
| 586 | { |
| 587 | struct iwl_priv *priv = |
| 588 | container_of(work, struct iwl_priv, tx_flush); |
| 589 | |
| 590 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 591 | return; |
| 592 | |
| 593 | /* do nothing if rf-kill is on */ |
| 594 | if (!iwl_is_ready_rf(priv)) |
| 595 | return; |
| 596 | |
| 597 | if (priv->cfg->ops->lib->txfifo_flush) { |
| 598 | IWL_DEBUG_INFO(priv, "device request: flush all tx frames\n"); |
| 599 | iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); |
| 600 | } |
| 601 | } |
| 602 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 603 | /** |
Tomas Winkler | a55360e | 2008-05-05 10:22:28 +0800 | [diff] [blame] | 604 | * iwl_rx_handle - Main entry function for receiving responses from uCode |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 605 | * |
| 606 | * Uses the priv->rx_handlers callback function array to invoke |
| 607 | * the appropriate handlers, including command responses, |
| 608 | * frame-received notifications, and other notifications. |
| 609 | */ |
Johannes Berg | f945f10 | 2011-01-04 16:21:59 -0800 | [diff] [blame] | 610 | static void iwl_rx_handle(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 611 | { |
Tomas Winkler | a55360e | 2008-05-05 10:22:28 +0800 | [diff] [blame] | 612 | struct iwl_rx_mem_buffer *rxb; |
Tomas Winkler | db11d63 | 2008-05-05 10:22:33 +0800 | [diff] [blame] | 613 | struct iwl_rx_packet *pkt; |
Tomas Winkler | a55360e | 2008-05-05 10:22:28 +0800 | [diff] [blame] | 614 | struct iwl_rx_queue *rxq = &priv->rxq; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 615 | u32 r, i; |
| 616 | int reclaim; |
| 617 | unsigned long flags; |
Mohamed Abbas | 5c0eef9 | 2007-11-29 11:10:14 +0800 | [diff] [blame] | 618 | u8 fill_rx = 0; |
Mohamed Abbas | d68ab68 | 2008-02-07 13:16:33 -0800 | [diff] [blame] | 619 | u32 count = 8; |
Mohamed Abbas | 4752c93 | 2009-05-22 11:01:51 -0700 | [diff] [blame] | 620 | int total_empty; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 621 | |
Cahill, Ben M | 6440adb | 2007-11-29 11:09:55 +0800 | [diff] [blame] | 622 | /* uCode's read index (stored in shared DRAM) indicates the last Rx |
| 623 | * buffer that the driver may process (last buffer filled by ucode). */ |
Winkler, Tomas | 8d86422 | 2008-11-07 09:58:39 -0800 | [diff] [blame] | 624 | r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 625 | i = rxq->read; |
| 626 | |
| 627 | /* Rx interrupt, but nothing sent from uCode */ |
| 628 | if (i == r) |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 629 | IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 630 | |
Mohamed Abbas | 4752c93 | 2009-05-22 11:01:51 -0700 | [diff] [blame] | 631 | /* calculate total frames need to be restock after handling RX */ |
Zhu Yi | 7300515 | 2009-10-23 13:42:32 -0700 | [diff] [blame] | 632 | total_empty = r - rxq->write_actual; |
Mohamed Abbas | 4752c93 | 2009-05-22 11:01:51 -0700 | [diff] [blame] | 633 | if (total_empty < 0) |
| 634 | total_empty += RX_QUEUE_SIZE; |
| 635 | |
| 636 | if (total_empty > (RX_QUEUE_SIZE / 2)) |
Mohamed Abbas | 5c0eef9 | 2007-11-29 11:10:14 +0800 | [diff] [blame] | 637 | fill_rx = 1; |
| 638 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 639 | while (i != r) { |
Johannes Berg | f4989d9 | 2010-05-28 04:08:30 -0700 | [diff] [blame] | 640 | int len; |
| 641 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 642 | rxb = rxq->queue[i]; |
| 643 | |
Ben Cahill | 9fbab51 | 2007-11-29 11:09:47 +0800 | [diff] [blame] | 644 | /* If an RXB doesn't have a Rx queue slot associated with it, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 645 | * then a bug has been introduced in the queue refilling |
| 646 | * routines -- catch it here */ |
Johannes Berg | 3e41ace | 2011-04-18 09:12:37 -0700 | [diff] [blame] | 647 | if (WARN_ON(rxb == NULL)) { |
| 648 | i = (i + 1) & RX_QUEUE_MASK; |
| 649 | continue; |
| 650 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 651 | |
| 652 | rxq->queue[i] = NULL; |
| 653 | |
Zhu Yi | 2f30122 | 2009-10-09 17:19:45 +0800 | [diff] [blame] | 654 | pci_unmap_page(priv->pci_dev, rxb->page_dma, |
| 655 | PAGE_SIZE << priv->hw_params.rx_page_order, |
| 656 | PCI_DMA_FROMDEVICE); |
| 657 | pkt = rxb_addr(rxb); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 658 | |
Johannes Berg | f4989d9 | 2010-05-28 04:08:30 -0700 | [diff] [blame] | 659 | len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; |
| 660 | len += sizeof(u32); /* account for status word */ |
| 661 | trace_iwlwifi_dev_rx(priv, pkt, len); |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 662 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 663 | /* Reclaim a command buffer only if this packet is a response |
| 664 | * to a (driver-originated) command. |
| 665 | * If the packet (e.g. Rx frame) originated from uCode, |
| 666 | * there is no command buffer to reclaim. |
| 667 | * Ucode should set SEQ_RX_FRAME bit if ucode-originated, |
| 668 | * but apparently a few don't get set; catch them here. */ |
| 669 | reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && |
| 670 | (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && |
Tomas Winkler | 857485c | 2008-03-21 13:53:44 -0700 | [diff] [blame] | 671 | (pkt->hdr.cmd != REPLY_RX) && |
Daniel Halperin | 7dddaf1 | 2008-10-23 23:48:58 -0700 | [diff] [blame] | 672 | (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && |
Zhu Yi | cfe0170 | 2007-09-27 11:27:31 +0800 | [diff] [blame] | 673 | (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 674 | (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && |
| 675 | (pkt->hdr.cmd != REPLY_TX); |
| 676 | |
Johannes Berg | 7194207c | 2011-01-04 16:22:00 -0800 | [diff] [blame] | 677 | /* |
| 678 | * Do the notification wait before RX handlers so |
| 679 | * even if the RX handler consumes the RXB we have |
| 680 | * access to it in the notification wait entry. |
| 681 | */ |
| 682 | if (!list_empty(&priv->_agn.notif_waits)) { |
| 683 | struct iwl_notification_wait *w; |
| 684 | |
| 685 | spin_lock(&priv->_agn.notif_wait_lock); |
| 686 | list_for_each_entry(w, &priv->_agn.notif_waits, list) { |
| 687 | if (w->cmd == pkt->hdr.cmd) { |
| 688 | w->triggered = true; |
| 689 | if (w->fn) |
Johannes Berg | 09f18af | 2011-04-13 03:14:47 -0700 | [diff] [blame] | 690 | w->fn(priv, pkt, w->fn_data); |
Johannes Berg | 7194207c | 2011-01-04 16:22:00 -0800 | [diff] [blame] | 691 | } |
| 692 | } |
| 693 | spin_unlock(&priv->_agn.notif_wait_lock); |
| 694 | |
| 695 | wake_up_all(&priv->_agn.notif_waitq); |
| 696 | } |
Cindy H. Kao | 4613e72 | 2011-05-06 10:40:15 -0700 | [diff] [blame] | 697 | if (priv->pre_rx_handler) |
| 698 | priv->pre_rx_handler(priv, rxb); |
Johannes Berg | 7194207c | 2011-01-04 16:22:00 -0800 | [diff] [blame] | 699 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 700 | /* Based on type of command response or notification, |
| 701 | * handle those that need handling via function in |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 702 | * rx_handlers table. See iwl_setup_rx_handlers() */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 703 | if (priv->rx_handlers[pkt->hdr.cmd]) { |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 704 | IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, |
Ester Kummer | f3d6799 | 2008-05-06 11:05:12 +0800 | [diff] [blame] | 705 | i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); |
Wey-Yi Guy | a83b914 | 2009-04-08 11:39:32 -0700 | [diff] [blame] | 706 | priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; |
Zhu Yi | 29b1b26 | 2009-10-23 13:42:25 -0700 | [diff] [blame] | 707 | priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 708 | } else { |
| 709 | /* No handling needed */ |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 710 | IWL_DEBUG_RX(priv, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 711 | "r %d i %d No handler needed for %s, 0x%02x\n", |
| 712 | r, i, get_cmd_string(pkt->hdr.cmd), |
| 713 | pkt->hdr.cmd); |
| 714 | } |
| 715 | |
Zhu Yi | 29b1b26 | 2009-10-23 13:42:25 -0700 | [diff] [blame] | 716 | /* |
| 717 | * XXX: After here, we should always check rxb->page |
| 718 | * against NULL before touching it or its virtual |
| 719 | * memory (pkt). Because some rx_handler might have |
| 720 | * already taken or freed the pages. |
| 721 | */ |
| 722 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 723 | if (reclaim) { |
Zhu Yi | 2f30122 | 2009-10-09 17:19:45 +0800 | [diff] [blame] | 724 | /* Invoke any callbacks, transfer the buffer to caller, |
| 725 | * and fire off the (possibly) blocking iwl_send_cmd() |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 726 | * as we reclaim the driver command queue */ |
Zhu Yi | 29b1b26 | 2009-10-23 13:42:25 -0700 | [diff] [blame] | 727 | if (rxb->page) |
Tomas Winkler | 17b8892 | 2008-05-29 16:35:12 +0800 | [diff] [blame] | 728 | iwl_tx_cmd_complete(priv, rxb); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 729 | else |
Winkler, Tomas | 39aadf8 | 2008-12-19 10:37:32 +0800 | [diff] [blame] | 730 | IWL_WARN(priv, "Claim null rxb?\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Zhu Yi | 7300515 | 2009-10-23 13:42:32 -0700 | [diff] [blame] | 733 | /* Reuse the page if possible. For notification packets and |
| 734 | * SKBs that fail to Rx correctly, add them back into the |
| 735 | * rx_free list for reuse later. */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 736 | spin_lock_irqsave(&rxq->lock, flags); |
Zhu Yi | 7300515 | 2009-10-23 13:42:32 -0700 | [diff] [blame] | 737 | if (rxb->page != NULL) { |
| 738 | rxb->page_dma = pci_map_page(priv->pci_dev, rxb->page, |
| 739 | 0, PAGE_SIZE << priv->hw_params.rx_page_order, |
| 740 | PCI_DMA_FROMDEVICE); |
| 741 | list_add_tail(&rxb->list, &rxq->rx_free); |
| 742 | rxq->free_count++; |
| 743 | } else |
| 744 | list_add_tail(&rxb->list, &rxq->rx_used); |
| 745 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 746 | spin_unlock_irqrestore(&rxq->lock, flags); |
Zhu Yi | 7300515 | 2009-10-23 13:42:32 -0700 | [diff] [blame] | 747 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 748 | i = (i + 1) & RX_QUEUE_MASK; |
Mohamed Abbas | 5c0eef9 | 2007-11-29 11:10:14 +0800 | [diff] [blame] | 749 | /* If there are a lot of unused frames, |
| 750 | * restock the Rx queue so ucode wont assert. */ |
| 751 | if (fill_rx) { |
| 752 | count++; |
| 753 | if (count >= 8) { |
Zhu Yi | 7300515 | 2009-10-23 13:42:32 -0700 | [diff] [blame] | 754 | rxq->read = i; |
Wey-Yi Guy | 54b8155 | 2010-03-17 13:34:35 -0700 | [diff] [blame] | 755 | iwlagn_rx_replenish_now(priv); |
Mohamed Abbas | 5c0eef9 | 2007-11-29 11:10:14 +0800 | [diff] [blame] | 756 | count = 0; |
| 757 | } |
| 758 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 759 | } |
| 760 | |
| 761 | /* Backtrack one entry */ |
Zhu Yi | 7300515 | 2009-10-23 13:42:32 -0700 | [diff] [blame] | 762 | rxq->read = i; |
Mohamed Abbas | 4752c93 | 2009-05-22 11:01:51 -0700 | [diff] [blame] | 763 | if (fill_rx) |
Wey-Yi Guy | 54b8155 | 2010-03-17 13:34:35 -0700 | [diff] [blame] | 764 | iwlagn_rx_replenish_now(priv); |
Mohamed Abbas | 4752c93 | 2009-05-22 11:01:51 -0700 | [diff] [blame] | 765 | else |
Wey-Yi Guy | 54b8155 | 2010-03-17 13:34:35 -0700 | [diff] [blame] | 766 | iwlagn_rx_queue_restock(priv); |
Tomas Winkler | a55360e | 2008-05-05 10:22:28 +0800 | [diff] [blame] | 767 | } |
Tomas Winkler | a55360e | 2008-05-05 10:22:28 +0800 | [diff] [blame] | 768 | |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 769 | /* tasklet for iwlagn interrupt */ |
| 770 | static void iwl_irq_tasklet(struct iwl_priv *priv) |
| 771 | { |
| 772 | u32 inta = 0; |
| 773 | u32 handled = 0; |
| 774 | unsigned long flags; |
Ben Cahill | 8756990 | 2009-11-06 14:53:01 -0800 | [diff] [blame] | 775 | u32 i; |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 776 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 777 | u32 inta_mask; |
| 778 | #endif |
| 779 | |
| 780 | spin_lock_irqsave(&priv->lock, flags); |
| 781 | |
| 782 | /* Ack/clear/reset pending uCode interrupts. |
| 783 | * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, |
| 784 | */ |
Shanyu Zhao | 48a6be6 | 2010-03-16 10:22:26 -0700 | [diff] [blame] | 785 | /* There is a hardware bug in the interrupt mask function that some |
| 786 | * interrupts (i.e. CSR_INT_BIT_SCD) can still be generated even if |
| 787 | * they are disabled in the CSR_INT_MASK register. Furthermore the |
| 788 | * ICT interrupt handling mechanism has another bug that might cause |
| 789 | * these unmasked interrupts fail to be detected. We workaround the |
| 790 | * hardware bugs here by ACKing all the possible interrupts so that |
| 791 | * interrupt coalescing can still be achieved. |
| 792 | */ |
David S. Miller | 4a35ecf | 2010-04-06 23:53:30 -0700 | [diff] [blame] | 793 | iwl_write32(priv, CSR_INT, priv->_agn.inta | ~priv->inta_mask); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 794 | |
Johannes Berg | a4c8b2a | 2010-01-21 06:25:54 -0800 | [diff] [blame] | 795 | inta = priv->_agn.inta; |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 796 | |
| 797 | #ifdef CONFIG_IWLWIFI_DEBUG |
Reinette Chatre | 3d816c7 | 2009-08-07 15:41:37 -0700 | [diff] [blame] | 798 | if (iwl_get_debug_level(priv) & IWL_DL_ISR) { |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 799 | /* just for debug */ |
| 800 | inta_mask = iwl_read32(priv, CSR_INT_MASK); |
| 801 | IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x\n ", |
| 802 | inta, inta_mask); |
| 803 | } |
| 804 | #endif |
Zhu Yi | 2f30122 | 2009-10-09 17:19:45 +0800 | [diff] [blame] | 805 | |
| 806 | spin_unlock_irqrestore(&priv->lock, flags); |
| 807 | |
Johannes Berg | a4c8b2a | 2010-01-21 06:25:54 -0800 | [diff] [blame] | 808 | /* saved interrupt in inta variable now we can reset priv->_agn.inta */ |
| 809 | priv->_agn.inta = 0; |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 810 | |
| 811 | /* Now service all interrupt bits discovered above. */ |
| 812 | if (inta & CSR_INT_BIT_HW_ERR) { |
Reinette Chatre | 58dba72 | 2009-07-17 09:30:25 -0700 | [diff] [blame] | 813 | IWL_ERR(priv, "Hardware error detected. Restarting.\n"); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 814 | |
| 815 | /* Tell the device to stop sending interrupts */ |
| 816 | iwl_disable_interrupts(priv); |
| 817 | |
| 818 | priv->isr_stats.hw++; |
| 819 | iwl_irq_handle_error(priv); |
| 820 | |
| 821 | handled |= CSR_INT_BIT_HW_ERR; |
| 822 | |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 823 | return; |
| 824 | } |
| 825 | |
| 826 | #ifdef CONFIG_IWLWIFI_DEBUG |
Reinette Chatre | 3d816c7 | 2009-08-07 15:41:37 -0700 | [diff] [blame] | 827 | if (iwl_get_debug_level(priv) & (IWL_DL_ISR)) { |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 828 | /* NIC fires this, but we don't use it, redundant with WAKEUP */ |
| 829 | if (inta & CSR_INT_BIT_SCD) { |
| 830 | IWL_DEBUG_ISR(priv, "Scheduler finished to transmit " |
| 831 | "the frame/frames.\n"); |
| 832 | priv->isr_stats.sch++; |
| 833 | } |
| 834 | |
| 835 | /* Alive notification via Rx interrupt will do the real work */ |
| 836 | if (inta & CSR_INT_BIT_ALIVE) { |
| 837 | IWL_DEBUG_ISR(priv, "Alive interrupt\n"); |
| 838 | priv->isr_stats.alive++; |
| 839 | } |
| 840 | } |
| 841 | #endif |
| 842 | /* Safely ignore these bits for debug checks below */ |
| 843 | inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); |
| 844 | |
| 845 | /* HW RF KILL switch toggled */ |
| 846 | if (inta & CSR_INT_BIT_RF_KILL) { |
| 847 | int hw_rf_kill = 0; |
| 848 | if (!(iwl_read32(priv, CSR_GP_CNTRL) & |
| 849 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) |
| 850 | hw_rf_kill = 1; |
| 851 | |
Reinette Chatre | 4c423a2 | 2009-07-17 09:30:26 -0700 | [diff] [blame] | 852 | IWL_WARN(priv, "RF_KILL bit toggled to %s.\n", |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 853 | hw_rf_kill ? "disable radio" : "enable radio"); |
| 854 | |
| 855 | priv->isr_stats.rfkill++; |
| 856 | |
| 857 | /* driver only loads ucode once setting the interface up. |
| 858 | * the driver allows loading the ucode even if the radio |
| 859 | * is killed. Hence update the killswitch state here. The |
| 860 | * rfkill handler will care about restarting if needed. |
| 861 | */ |
| 862 | if (!test_bit(STATUS_ALIVE, &priv->status)) { |
| 863 | if (hw_rf_kill) |
| 864 | set_bit(STATUS_RF_KILL_HW, &priv->status); |
| 865 | else |
| 866 | clear_bit(STATUS_RF_KILL_HW, &priv->status); |
Johannes Berg | a60e77e | 2009-06-04 18:26:06 +0200 | [diff] [blame] | 867 | wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rf_kill); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | handled |= CSR_INT_BIT_RF_KILL; |
| 871 | } |
| 872 | |
| 873 | /* Chip got too hot and stopped itself */ |
| 874 | if (inta & CSR_INT_BIT_CT_KILL) { |
| 875 | IWL_ERR(priv, "Microcode CT kill error detected.\n"); |
| 876 | priv->isr_stats.ctkill++; |
| 877 | handled |= CSR_INT_BIT_CT_KILL; |
| 878 | } |
| 879 | |
| 880 | /* Error detected by uCode */ |
| 881 | if (inta & CSR_INT_BIT_SW_ERR) { |
| 882 | IWL_ERR(priv, "Microcode SW error detected. " |
| 883 | " Restarting 0x%X.\n", inta); |
| 884 | priv->isr_stats.sw++; |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 885 | iwl_irq_handle_error(priv); |
| 886 | handled |= CSR_INT_BIT_SW_ERR; |
| 887 | } |
| 888 | |
| 889 | /* uCode wakes up after power-down sleep */ |
| 890 | if (inta & CSR_INT_BIT_WAKEUP) { |
| 891 | IWL_DEBUG_ISR(priv, "Wakeup interrupt\n"); |
| 892 | iwl_rx_queue_update_write_ptr(priv, &priv->rxq); |
Ben Cahill | 8756990 | 2009-11-06 14:53:01 -0800 | [diff] [blame] | 893 | for (i = 0; i < priv->hw_params.max_txq_num; i++) |
| 894 | iwl_txq_update_write_ptr(priv, &priv->txq[i]); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 895 | |
| 896 | priv->isr_stats.wakeup++; |
| 897 | |
| 898 | handled |= CSR_INT_BIT_WAKEUP; |
| 899 | } |
| 900 | |
| 901 | /* All uCode command responses, including Tx command responses, |
| 902 | * Rx "responses" (frame-received notification), and other |
| 903 | * notifications from uCode come through here*/ |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 904 | if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX | |
| 905 | CSR_INT_BIT_RX_PERIODIC)) { |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 906 | IWL_DEBUG_ISR(priv, "Rx interrupt\n"); |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 907 | if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { |
| 908 | handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); |
| 909 | iwl_write32(priv, CSR_FH_INT_STATUS, |
Wey-Yi Guy | f7d046f | 2011-03-22 08:05:37 -0700 | [diff] [blame] | 910 | CSR_FH_INT_RX_MASK); |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 911 | } |
| 912 | if (inta & CSR_INT_BIT_RX_PERIODIC) { |
| 913 | handled |= CSR_INT_BIT_RX_PERIODIC; |
| 914 | iwl_write32(priv, CSR_INT, CSR_INT_BIT_RX_PERIODIC); |
| 915 | } |
| 916 | /* Sending RX interrupt require many steps to be done in the |
| 917 | * the device: |
| 918 | * 1- write interrupt to current index in ICT table. |
| 919 | * 2- dma RX frame. |
| 920 | * 3- update RX shared data to indicate last write index. |
| 921 | * 4- send interrupt. |
| 922 | * This could lead to RX race, driver could receive RX interrupt |
Ben Cahill | 74ba67e | 2009-11-20 12:04:53 -0800 | [diff] [blame] | 923 | * but the shared data changes does not reflect this; |
| 924 | * periodic interrupt will detect any dangling Rx activity. |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 925 | */ |
Ben Cahill | 74ba67e | 2009-11-20 12:04:53 -0800 | [diff] [blame] | 926 | |
| 927 | /* Disable periodic interrupt; we use it as just a one-shot. */ |
| 928 | iwl_write8(priv, CSR_INT_PERIODIC_REG, |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 929 | CSR_INT_PERIODIC_DIS); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 930 | iwl_rx_handle(priv); |
Ben Cahill | 74ba67e | 2009-11-20 12:04:53 -0800 | [diff] [blame] | 931 | |
| 932 | /* |
| 933 | * Enable periodic interrupt in 8 msec only if we received |
| 934 | * real RX interrupt (instead of just periodic int), to catch |
| 935 | * any dangling Rx interrupt. If it was just the periodic |
| 936 | * interrupt, there was no dangling Rx activity, and no need |
| 937 | * to extend the periodic interrupt; one-shot is enough. |
| 938 | */ |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 939 | if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) |
Ben Cahill | 74ba67e | 2009-11-20 12:04:53 -0800 | [diff] [blame] | 940 | iwl_write8(priv, CSR_INT_PERIODIC_REG, |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 941 | CSR_INT_PERIODIC_ENA); |
| 942 | |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 943 | priv->isr_stats.rx++; |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 944 | } |
| 945 | |
Ben Cahill | c72cd19 | 2009-10-30 14:36:08 -0700 | [diff] [blame] | 946 | /* This "Tx" DMA channel is used only for loading uCode */ |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 947 | if (inta & CSR_INT_BIT_FH_TX) { |
Wey-Yi Guy | f7d046f | 2011-03-22 08:05:37 -0700 | [diff] [blame] | 948 | iwl_write32(priv, CSR_FH_INT_STATUS, CSR_FH_INT_TX_MASK); |
Ben Cahill | c72cd19 | 2009-10-30 14:36:08 -0700 | [diff] [blame] | 949 | IWL_DEBUG_ISR(priv, "uCode load interrupt\n"); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 950 | priv->isr_stats.tx++; |
| 951 | handled |= CSR_INT_BIT_FH_TX; |
Ben Cahill | c72cd19 | 2009-10-30 14:36:08 -0700 | [diff] [blame] | 952 | /* Wake up uCode load routine, now that load is complete */ |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 953 | priv->ucode_write_complete = 1; |
| 954 | wake_up_interruptible(&priv->wait_command_queue); |
| 955 | } |
| 956 | |
| 957 | if (inta & ~handled) { |
| 958 | IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); |
| 959 | priv->isr_stats.unhandled++; |
| 960 | } |
| 961 | |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 962 | if (inta & ~(priv->inta_mask)) { |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 963 | IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 964 | inta & ~priv->inta_mask); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 965 | } |
| 966 | |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 967 | /* Re-enable all interrupts */ |
Justin P. Mattock | 62e45c1 | 2010-12-30 15:07:56 -0800 | [diff] [blame] | 968 | /* only Re-enable if disabled by irq */ |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 969 | if (test_bit(STATUS_INT_ENABLED, &priv->status)) |
| 970 | iwl_enable_interrupts(priv); |
Don Fry | 3dd823e | 2011-02-06 09:29:45 -0800 | [diff] [blame] | 971 | /* Re-enable RF_KILL if it occurred */ |
| 972 | else if (handled & CSR_INT_BIT_RF_KILL) |
| 973 | iwl_enable_rfkill_int(priv); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Emmanuel Grumbach | 7d47618 | 2010-05-23 00:14:08 -0700 | [diff] [blame] | 976 | /***************************************************************************** |
| 977 | * |
| 978 | * sysfs attributes |
| 979 | * |
| 980 | *****************************************************************************/ |
| 981 | |
| 982 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 983 | |
| 984 | /* |
| 985 | * The following adds a new attribute to the sysfs representation |
| 986 | * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/) |
| 987 | * used for controlling the debug level. |
| 988 | * |
| 989 | * See the level definitions in iwl for details. |
| 990 | * |
| 991 | * The debug_level being managed using sysfs below is a per device debug |
| 992 | * level that is used instead of the global debug level if it (the per |
| 993 | * device debug level) is set. |
| 994 | */ |
| 995 | static ssize_t show_debug_level(struct device *d, |
| 996 | struct device_attribute *attr, char *buf) |
| 997 | { |
| 998 | struct iwl_priv *priv = dev_get_drvdata(d); |
| 999 | return sprintf(buf, "0x%08X\n", iwl_get_debug_level(priv)); |
| 1000 | } |
| 1001 | static ssize_t store_debug_level(struct device *d, |
| 1002 | struct device_attribute *attr, |
| 1003 | const char *buf, size_t count) |
| 1004 | { |
| 1005 | struct iwl_priv *priv = dev_get_drvdata(d); |
| 1006 | unsigned long val; |
| 1007 | int ret; |
| 1008 | |
| 1009 | ret = strict_strtoul(buf, 0, &val); |
| 1010 | if (ret) |
| 1011 | IWL_ERR(priv, "%s is not in hex or decimal form.\n", buf); |
| 1012 | else { |
| 1013 | priv->debug_level = val; |
| 1014 | if (iwl_alloc_traffic_mem(priv)) |
| 1015 | IWL_ERR(priv, |
| 1016 | "Not enough memory to generate traffic log\n"); |
| 1017 | } |
| 1018 | return strnlen(buf, count); |
| 1019 | } |
| 1020 | |
| 1021 | static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, |
| 1022 | show_debug_level, store_debug_level); |
| 1023 | |
| 1024 | |
| 1025 | #endif /* CONFIG_IWLWIFI_DEBUG */ |
| 1026 | |
| 1027 | |
| 1028 | static ssize_t show_temperature(struct device *d, |
| 1029 | struct device_attribute *attr, char *buf) |
| 1030 | { |
| 1031 | struct iwl_priv *priv = dev_get_drvdata(d); |
| 1032 | |
| 1033 | if (!iwl_is_alive(priv)) |
| 1034 | return -EAGAIN; |
| 1035 | |
| 1036 | return sprintf(buf, "%d\n", priv->temperature); |
| 1037 | } |
| 1038 | |
| 1039 | static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL); |
| 1040 | |
| 1041 | static ssize_t show_tx_power(struct device *d, |
| 1042 | struct device_attribute *attr, char *buf) |
| 1043 | { |
| 1044 | struct iwl_priv *priv = dev_get_drvdata(d); |
| 1045 | |
| 1046 | if (!iwl_is_ready_rf(priv)) |
| 1047 | return sprintf(buf, "off\n"); |
| 1048 | else |
| 1049 | return sprintf(buf, "%d\n", priv->tx_power_user_lmt); |
| 1050 | } |
| 1051 | |
| 1052 | static ssize_t store_tx_power(struct device *d, |
| 1053 | struct device_attribute *attr, |
| 1054 | const char *buf, size_t count) |
| 1055 | { |
| 1056 | struct iwl_priv *priv = dev_get_drvdata(d); |
| 1057 | unsigned long val; |
| 1058 | int ret; |
| 1059 | |
| 1060 | ret = strict_strtoul(buf, 10, &val); |
| 1061 | if (ret) |
| 1062 | IWL_INFO(priv, "%s is not in decimal form.\n", buf); |
| 1063 | else { |
| 1064 | ret = iwl_set_tx_power(priv, val, false); |
| 1065 | if (ret) |
| 1066 | IWL_ERR(priv, "failed setting tx power (0x%d).\n", |
| 1067 | ret); |
| 1068 | else |
| 1069 | ret = count; |
| 1070 | } |
| 1071 | return ret; |
| 1072 | } |
| 1073 | |
| 1074 | static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power); |
| 1075 | |
Emmanuel Grumbach | 7d47618 | 2010-05-23 00:14:08 -0700 | [diff] [blame] | 1076 | static struct attribute *iwl_sysfs_entries[] = { |
| 1077 | &dev_attr_temperature.attr, |
| 1078 | &dev_attr_tx_power.attr, |
Emmanuel Grumbach | 7d47618 | 2010-05-23 00:14:08 -0700 | [diff] [blame] | 1079 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 1080 | &dev_attr_debug_level.attr, |
| 1081 | #endif |
| 1082 | NULL |
| 1083 | }; |
| 1084 | |
| 1085 | static struct attribute_group iwl_attribute_group = { |
| 1086 | .name = NULL, /* put in device directory */ |
| 1087 | .attrs = iwl_sysfs_entries, |
| 1088 | }; |
| 1089 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1090 | /****************************************************************************** |
| 1091 | * |
| 1092 | * uCode download functions |
| 1093 | * |
| 1094 | ******************************************************************************/ |
| 1095 | |
Johannes Berg | dbf28e21 | 2011-04-16 08:29:24 -0700 | [diff] [blame] | 1096 | static void iwl_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) |
| 1097 | { |
| 1098 | if (desc->v_addr) |
| 1099 | dma_free_coherent(&pci_dev->dev, desc->len, |
| 1100 | desc->v_addr, desc->p_addr); |
| 1101 | desc->v_addr = NULL; |
| 1102 | desc->len = 0; |
| 1103 | } |
| 1104 | |
| 1105 | static void iwl_free_fw_img(struct pci_dev *pci_dev, struct fw_img *img) |
| 1106 | { |
| 1107 | iwl_free_fw_desc(pci_dev, &img->code); |
| 1108 | iwl_free_fw_desc(pci_dev, &img->data); |
| 1109 | } |
| 1110 | |
| 1111 | static int iwl_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc, |
| 1112 | const void *data, size_t len) |
| 1113 | { |
| 1114 | if (!len) { |
| 1115 | desc->v_addr = NULL; |
| 1116 | return -EINVAL; |
| 1117 | } |
| 1118 | |
| 1119 | desc->v_addr = dma_alloc_coherent(&pci_dev->dev, len, |
| 1120 | &desc->p_addr, GFP_KERNEL); |
| 1121 | if (!desc->v_addr) |
| 1122 | return -ENOMEM; |
| 1123 | desc->len = len; |
| 1124 | memcpy(desc->v_addr, data, len); |
| 1125 | return 0; |
| 1126 | } |
| 1127 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 1128 | static void iwl_dealloc_ucode_pci(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1129 | { |
Johannes Berg | dbf28e21 | 2011-04-16 08:29:24 -0700 | [diff] [blame] | 1130 | iwl_free_fw_img(priv->pci_dev, &priv->ucode_rt); |
| 1131 | iwl_free_fw_img(priv->pci_dev, &priv->ucode_init); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1132 | } |
| 1133 | |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1134 | struct iwlagn_ucode_capabilities { |
| 1135 | u32 max_probe_length; |
Wey-Yi Guy | 6a822d0 | 2010-07-13 17:13:15 -0700 | [diff] [blame] | 1136 | u32 standard_phy_calibration_size; |
Johannes Berg | 3997ff3 | 2011-04-05 09:42:02 -0700 | [diff] [blame] | 1137 | u32 flags; |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1138 | }; |
Ron Rindjunsky | edcdf8b | 2008-05-15 13:53:55 +0800 | [diff] [blame] | 1139 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1140 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1141 | static int iwl_mac_setup_register(struct iwl_priv *priv, |
| 1142 | struct iwlagn_ucode_capabilities *capa); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1143 | |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1144 | #define UCODE_EXPERIMENTAL_INDEX 100 |
| 1145 | #define UCODE_EXPERIMENTAL_TAG "exp" |
| 1146 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1147 | static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1148 | { |
Reinette Chatre | a0987a8 | 2008-12-02 12:14:06 -0800 | [diff] [blame] | 1149 | const char *name_pre = priv->cfg->fw_name_pre; |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1150 | char tag[8]; |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1151 | |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1152 | if (first) { |
| 1153 | #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE |
| 1154 | priv->fw_index = UCODE_EXPERIMENTAL_INDEX; |
| 1155 | strcpy(tag, UCODE_EXPERIMENTAL_TAG); |
| 1156 | } else if (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) { |
| 1157 | #endif |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1158 | priv->fw_index = priv->cfg->ucode_api_max; |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1159 | sprintf(tag, "%d", priv->fw_index); |
| 1160 | } else { |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1161 | priv->fw_index--; |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1162 | sprintf(tag, "%d", priv->fw_index); |
| 1163 | } |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1164 | |
| 1165 | if (priv->fw_index < priv->cfg->ucode_api_min) { |
| 1166 | IWL_ERR(priv, "no suitable firmware found!\n"); |
| 1167 | return -ENOENT; |
| 1168 | } |
| 1169 | |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1170 | sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1171 | |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1172 | IWL_DEBUG_INFO(priv, "attempting to load firmware %s'%s'\n", |
| 1173 | (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
| 1174 | ? "EXPERIMENTAL " : "", |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1175 | priv->firmware_name); |
| 1176 | |
| 1177 | return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, |
| 1178 | &priv->pci_dev->dev, GFP_KERNEL, priv, |
| 1179 | iwl_ucode_callback); |
| 1180 | } |
| 1181 | |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1182 | struct iwlagn_firmware_pieces { |
Johannes Berg | 1fc3527 | 2011-04-05 09:41:57 -0700 | [diff] [blame] | 1183 | const void *inst, *data, *init, *init_data; |
| 1184 | size_t inst_size, data_size, init_size, init_data_size; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1185 | |
| 1186 | u32 build; |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1187 | |
| 1188 | u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; |
| 1189 | u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1190 | }; |
| 1191 | |
| 1192 | static int iwlagn_load_legacy_firmware(struct iwl_priv *priv, |
| 1193 | const struct firmware *ucode_raw, |
| 1194 | struct iwlagn_firmware_pieces *pieces) |
| 1195 | { |
| 1196 | struct iwl_ucode_header *ucode = (void *)ucode_raw->data; |
| 1197 | u32 api_ver, hdr_size; |
| 1198 | const u8 *src; |
| 1199 | |
| 1200 | priv->ucode_ver = le32_to_cpu(ucode->ver); |
| 1201 | api_ver = IWL_UCODE_API(priv->ucode_ver); |
| 1202 | |
| 1203 | switch (api_ver) { |
| 1204 | default: |
Wey-Yi Guy | f7d046f | 2011-03-22 08:05:37 -0700 | [diff] [blame] | 1205 | hdr_size = 28; |
| 1206 | if (ucode_raw->size < hdr_size) { |
| 1207 | IWL_ERR(priv, "File size too small!\n"); |
| 1208 | return -EINVAL; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1209 | } |
Wey-Yi Guy | f7d046f | 2011-03-22 08:05:37 -0700 | [diff] [blame] | 1210 | pieces->build = le32_to_cpu(ucode->u.v2.build); |
| 1211 | pieces->inst_size = le32_to_cpu(ucode->u.v2.inst_size); |
| 1212 | pieces->data_size = le32_to_cpu(ucode->u.v2.data_size); |
| 1213 | pieces->init_size = le32_to_cpu(ucode->u.v2.init_size); |
| 1214 | pieces->init_data_size = le32_to_cpu(ucode->u.v2.init_data_size); |
Wey-Yi Guy | f7d046f | 2011-03-22 08:05:37 -0700 | [diff] [blame] | 1215 | src = ucode->u.v2.data; |
| 1216 | break; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1217 | case 0: |
| 1218 | case 1: |
| 1219 | case 2: |
| 1220 | hdr_size = 24; |
| 1221 | if (ucode_raw->size < hdr_size) { |
| 1222 | IWL_ERR(priv, "File size too small!\n"); |
| 1223 | return -EINVAL; |
| 1224 | } |
| 1225 | pieces->build = 0; |
| 1226 | pieces->inst_size = le32_to_cpu(ucode->u.v1.inst_size); |
| 1227 | pieces->data_size = le32_to_cpu(ucode->u.v1.data_size); |
| 1228 | pieces->init_size = le32_to_cpu(ucode->u.v1.init_size); |
| 1229 | pieces->init_data_size = le32_to_cpu(ucode->u.v1.init_data_size); |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1230 | src = ucode->u.v1.data; |
| 1231 | break; |
| 1232 | } |
| 1233 | |
| 1234 | /* Verify size of file vs. image size info in file's header */ |
| 1235 | if (ucode_raw->size != hdr_size + pieces->inst_size + |
| 1236 | pieces->data_size + pieces->init_size + |
Johannes Berg | 1fc3527 | 2011-04-05 09:41:57 -0700 | [diff] [blame] | 1237 | pieces->init_data_size) { |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1238 | |
| 1239 | IWL_ERR(priv, |
| 1240 | "uCode file size %d does not match expected size\n", |
| 1241 | (int)ucode_raw->size); |
| 1242 | return -EINVAL; |
| 1243 | } |
| 1244 | |
| 1245 | pieces->inst = src; |
| 1246 | src += pieces->inst_size; |
| 1247 | pieces->data = src; |
| 1248 | src += pieces->data_size; |
| 1249 | pieces->init = src; |
| 1250 | src += pieces->init_size; |
| 1251 | pieces->init_data = src; |
| 1252 | src += pieces->init_data_size; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1253 | |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1257 | static int iwlagn_wanted_ucode_alternative = 1; |
| 1258 | |
| 1259 | static int iwlagn_load_firmware(struct iwl_priv *priv, |
| 1260 | const struct firmware *ucode_raw, |
| 1261 | struct iwlagn_firmware_pieces *pieces, |
| 1262 | struct iwlagn_ucode_capabilities *capa) |
| 1263 | { |
| 1264 | struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; |
| 1265 | struct iwl_ucode_tlv *tlv; |
| 1266 | size_t len = ucode_raw->size; |
| 1267 | const u8 *data; |
| 1268 | int wanted_alternative = iwlagn_wanted_ucode_alternative, tmp; |
| 1269 | u64 alternatives; |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1270 | u32 tlv_len; |
| 1271 | enum iwl_ucode_tlv_type tlv_type; |
| 1272 | const u8 *tlv_data; |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1273 | |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1274 | if (len < sizeof(*ucode)) { |
| 1275 | IWL_ERR(priv, "uCode has invalid length: %zd\n", len); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1276 | return -EINVAL; |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1277 | } |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1278 | |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1279 | if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { |
| 1280 | IWL_ERR(priv, "invalid uCode magic: 0X%x\n", |
| 1281 | le32_to_cpu(ucode->magic)); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1282 | return -EINVAL; |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1283 | } |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1284 | |
| 1285 | /* |
| 1286 | * Check which alternatives are present, and "downgrade" |
| 1287 | * when the chosen alternative is not present, warning |
| 1288 | * the user when that happens. Some files may not have |
| 1289 | * any alternatives, so don't warn in that case. |
| 1290 | */ |
| 1291 | alternatives = le64_to_cpu(ucode->alternatives); |
| 1292 | tmp = wanted_alternative; |
| 1293 | if (wanted_alternative > 63) |
| 1294 | wanted_alternative = 63; |
| 1295 | while (wanted_alternative && !(alternatives & BIT(wanted_alternative))) |
| 1296 | wanted_alternative--; |
| 1297 | if (wanted_alternative && wanted_alternative != tmp) |
| 1298 | IWL_WARN(priv, |
| 1299 | "uCode alternative %d not available, choosing %d\n", |
| 1300 | tmp, wanted_alternative); |
| 1301 | |
| 1302 | priv->ucode_ver = le32_to_cpu(ucode->ver); |
| 1303 | pieces->build = le32_to_cpu(ucode->build); |
| 1304 | data = ucode->data; |
| 1305 | |
| 1306 | len -= sizeof(*ucode); |
| 1307 | |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1308 | while (len >= sizeof(*tlv)) { |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1309 | u16 tlv_alt; |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1310 | |
| 1311 | len -= sizeof(*tlv); |
| 1312 | tlv = (void *)data; |
| 1313 | |
| 1314 | tlv_len = le32_to_cpu(tlv->length); |
| 1315 | tlv_type = le16_to_cpu(tlv->type); |
| 1316 | tlv_alt = le16_to_cpu(tlv->alternative); |
| 1317 | tlv_data = tlv->data; |
| 1318 | |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1319 | if (len < tlv_len) { |
| 1320 | IWL_ERR(priv, "invalid TLV len: %zd/%u\n", |
| 1321 | len, tlv_len); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1322 | return -EINVAL; |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1323 | } |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1324 | len -= ALIGN(tlv_len, 4); |
| 1325 | data += sizeof(*tlv) + ALIGN(tlv_len, 4); |
| 1326 | |
| 1327 | /* |
| 1328 | * Alternative 0 is always valid. |
| 1329 | * |
| 1330 | * Skip alternative TLVs that are not selected. |
| 1331 | */ |
| 1332 | if (tlv_alt != 0 && tlv_alt != wanted_alternative) |
| 1333 | continue; |
| 1334 | |
| 1335 | switch (tlv_type) { |
| 1336 | case IWL_UCODE_TLV_INST: |
| 1337 | pieces->inst = tlv_data; |
| 1338 | pieces->inst_size = tlv_len; |
| 1339 | break; |
| 1340 | case IWL_UCODE_TLV_DATA: |
| 1341 | pieces->data = tlv_data; |
| 1342 | pieces->data_size = tlv_len; |
| 1343 | break; |
| 1344 | case IWL_UCODE_TLV_INIT: |
| 1345 | pieces->init = tlv_data; |
| 1346 | pieces->init_size = tlv_len; |
| 1347 | break; |
| 1348 | case IWL_UCODE_TLV_INIT_DATA: |
| 1349 | pieces->init_data = tlv_data; |
| 1350 | pieces->init_data_size = tlv_len; |
| 1351 | break; |
| 1352 | case IWL_UCODE_TLV_BOOT: |
Johannes Berg | 1fc3527 | 2011-04-05 09:41:57 -0700 | [diff] [blame] | 1353 | IWL_ERR(priv, "Found unexpected BOOT ucode\n"); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1354 | break; |
| 1355 | case IWL_UCODE_TLV_PROBE_MAX_LEN: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1356 | if (tlv_len != sizeof(u32)) |
| 1357 | goto invalid_tlv_len; |
| 1358 | capa->max_probe_length = |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1359 | le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1360 | break; |
Johannes Berg | ece9c4e | 2010-08-23 10:46:49 +0200 | [diff] [blame] | 1361 | case IWL_UCODE_TLV_PAN: |
| 1362 | if (tlv_len) |
| 1363 | goto invalid_tlv_len; |
Johannes Berg | 3997ff3 | 2011-04-05 09:42:02 -0700 | [diff] [blame] | 1364 | capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; |
| 1365 | break; |
| 1366 | case IWL_UCODE_TLV_FLAGS: |
| 1367 | /* must be at least one u32 */ |
| 1368 | if (tlv_len < sizeof(u32)) |
| 1369 | goto invalid_tlv_len; |
| 1370 | /* and a proper number of u32s */ |
| 1371 | if (tlv_len % sizeof(u32)) |
| 1372 | goto invalid_tlv_len; |
| 1373 | /* |
| 1374 | * This driver only reads the first u32 as |
| 1375 | * right now no more features are defined, |
| 1376 | * if that changes then either the driver |
| 1377 | * will not work with the new firmware, or |
| 1378 | * it'll not take advantage of new features. |
| 1379 | */ |
| 1380 | capa->flags = le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | ece9c4e | 2010-08-23 10:46:49 +0200 | [diff] [blame] | 1381 | break; |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1382 | case IWL_UCODE_TLV_INIT_EVTLOG_PTR: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1383 | if (tlv_len != sizeof(u32)) |
| 1384 | goto invalid_tlv_len; |
| 1385 | pieces->init_evtlog_ptr = |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1386 | le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1387 | break; |
| 1388 | case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1389 | if (tlv_len != sizeof(u32)) |
| 1390 | goto invalid_tlv_len; |
| 1391 | pieces->init_evtlog_size = |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1392 | le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1393 | break; |
| 1394 | case IWL_UCODE_TLV_INIT_ERRLOG_PTR: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1395 | if (tlv_len != sizeof(u32)) |
| 1396 | goto invalid_tlv_len; |
| 1397 | pieces->init_errlog_ptr = |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1398 | le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1399 | break; |
| 1400 | case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1401 | if (tlv_len != sizeof(u32)) |
| 1402 | goto invalid_tlv_len; |
| 1403 | pieces->inst_evtlog_ptr = |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1404 | le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1405 | break; |
| 1406 | case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1407 | if (tlv_len != sizeof(u32)) |
| 1408 | goto invalid_tlv_len; |
| 1409 | pieces->inst_evtlog_size = |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1410 | le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1411 | break; |
| 1412 | case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1413 | if (tlv_len != sizeof(u32)) |
| 1414 | goto invalid_tlv_len; |
| 1415 | pieces->inst_errlog_ptr = |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1416 | le32_to_cpup((__le32 *)tlv_data); |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1417 | break; |
Wey-Yi Guy | c8312fa | 2010-06-28 13:05:17 -0700 | [diff] [blame] | 1418 | case IWL_UCODE_TLV_ENHANCE_SENS_TBL: |
| 1419 | if (tlv_len) |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1420 | goto invalid_tlv_len; |
| 1421 | priv->enhance_sensitivity_table = true; |
Wey-Yi Guy | c8312fa | 2010-06-28 13:05:17 -0700 | [diff] [blame] | 1422 | break; |
Wey-Yi Guy | 6a822d0 | 2010-07-13 17:13:15 -0700 | [diff] [blame] | 1423 | case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1424 | if (tlv_len != sizeof(u32)) |
| 1425 | goto invalid_tlv_len; |
| 1426 | capa->standard_phy_calibration_size = |
Wey-Yi Guy | 6a822d0 | 2010-07-13 17:13:15 -0700 | [diff] [blame] | 1427 | le32_to_cpup((__le32 *)tlv_data); |
| 1428 | break; |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1429 | default: |
Johannes Berg | 6fc3ba9 | 2011-04-04 06:16:29 -0700 | [diff] [blame] | 1430 | IWL_DEBUG_INFO(priv, "unknown TLV: %d\n", tlv_type); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1431 | break; |
| 1432 | } |
| 1433 | } |
| 1434 | |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1435 | if (len) { |
| 1436 | IWL_ERR(priv, "invalid TLV after parsing: %zd\n", len); |
| 1437 | iwl_print_hex_dump(priv, IWL_DL_FW, (u8 *)data, len); |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1438 | return -EINVAL; |
Wey-Yi Guy | ad8d833 | 2010-06-22 14:31:45 -0700 | [diff] [blame] | 1439 | } |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1440 | |
Johannes Berg | 704da53 | 2010-07-14 09:34:50 -0700 | [diff] [blame] | 1441 | return 0; |
| 1442 | |
| 1443 | invalid_tlv_len: |
| 1444 | IWL_ERR(priv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); |
| 1445 | iwl_print_hex_dump(priv, IWL_DL_FW, tlv_data, tlv_len); |
| 1446 | |
| 1447 | return -EINVAL; |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1448 | } |
| 1449 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1450 | /** |
| 1451 | * iwl_ucode_callback - callback when firmware was loaded |
| 1452 | * |
| 1453 | * If loaded successfully, copies the firmware into buffers |
| 1454 | * for the card to fetch (via DMA). |
| 1455 | */ |
| 1456 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) |
| 1457 | { |
| 1458 | struct iwl_priv *priv = context; |
| 1459 | struct iwl_ucode_header *ucode; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1460 | int err; |
| 1461 | struct iwlagn_firmware_pieces pieces; |
Reinette Chatre | a0987a8 | 2008-12-02 12:14:06 -0800 | [diff] [blame] | 1462 | const unsigned int api_max = priv->cfg->ucode_api_max; |
| 1463 | const unsigned int api_min = priv->cfg->ucode_api_min; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1464 | u32 api_ver; |
Johannes Berg | 3e4de76 | 2010-04-28 12:09:12 -0700 | [diff] [blame] | 1465 | char buildstr[25]; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1466 | u32 build; |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1467 | struct iwlagn_ucode_capabilities ucode_capa = { |
| 1468 | .max_probe_length = 200, |
Wey-Yi Guy | 6a822d0 | 2010-07-13 17:13:15 -0700 | [diff] [blame] | 1469 | .standard_phy_calibration_size = |
Shanyu Zhao | 642454c | 2010-09-21 12:06:18 -0700 | [diff] [blame] | 1470 | IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE, |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1471 | }; |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1472 | |
| 1473 | memset(&pieces, 0, sizeof(pieces)); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1474 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1475 | if (!ucode_raw) { |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1476 | if (priv->fw_index <= priv->cfg->ucode_api_max) |
| 1477 | IWL_ERR(priv, |
| 1478 | "request for firmware file '%s' failed.\n", |
| 1479 | priv->firmware_name); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1480 | goto try_again; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1481 | } |
| 1482 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1483 | IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", |
| 1484 | priv->firmware_name, ucode_raw->size); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1485 | |
Johannes Berg | 22adba2 | 2010-04-28 12:09:14 -0700 | [diff] [blame] | 1486 | /* Make sure that we got at least the API version number */ |
| 1487 | if (ucode_raw->size < 4) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 1488 | IWL_ERR(priv, "File size way too small!\n"); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1489 | goto try_again; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1490 | } |
| 1491 | |
| 1492 | /* Data from ucode file: header followed by uCode images */ |
Jay Sternberg | cc0f555 | 2009-07-17 09:30:16 -0700 | [diff] [blame] | 1493 | ucode = (struct iwl_ucode_header *)ucode_raw->data; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1494 | |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1495 | if (ucode->ver) |
| 1496 | err = iwlagn_load_legacy_firmware(priv, ucode_raw, &pieces); |
| 1497 | else |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1498 | err = iwlagn_load_firmware(priv, ucode_raw, &pieces, |
| 1499 | &ucode_capa); |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1500 | |
| 1501 | if (err) |
| 1502 | goto try_again; |
| 1503 | |
Reinette Chatre | a0987a8 | 2008-12-02 12:14:06 -0800 | [diff] [blame] | 1504 | api_ver = IWL_UCODE_API(priv->ucode_ver); |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1505 | build = pieces.build; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1506 | |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1507 | /* |
| 1508 | * api_ver should match the api version forming part of the |
Reinette Chatre | a0987a8 | 2008-12-02 12:14:06 -0800 | [diff] [blame] | 1509 | * firmware filename ... but we don't check for that and only rely |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1510 | * on the API version read from firmware header from here on forward |
| 1511 | */ |
Wey-Yi Guy | 65cccfb | 2010-09-21 16:15:58 -0700 | [diff] [blame] | 1512 | /* no api version check required for experimental uCode */ |
| 1513 | if (priv->fw_index != UCODE_EXPERIMENTAL_INDEX) { |
| 1514 | if (api_ver < api_min || api_ver > api_max) { |
| 1515 | IWL_ERR(priv, |
| 1516 | "Driver unable to support your firmware API. " |
| 1517 | "Driver supports v%u, firmware is v%u.\n", |
| 1518 | api_max, api_ver); |
| 1519 | goto try_again; |
| 1520 | } |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1521 | |
Wey-Yi Guy | 65cccfb | 2010-09-21 16:15:58 -0700 | [diff] [blame] | 1522 | if (api_ver != api_max) |
| 1523 | IWL_ERR(priv, |
| 1524 | "Firmware has old API version. Expected v%u, " |
| 1525 | "got v%u. New firmware can be obtained " |
| 1526 | "from http://www.intellinuxwireless.org.\n", |
| 1527 | api_max, api_ver); |
| 1528 | } |
Reinette Chatre | a0987a8 | 2008-12-02 12:14:06 -0800 | [diff] [blame] | 1529 | |
Johannes Berg | 3e4de76 | 2010-04-28 12:09:12 -0700 | [diff] [blame] | 1530 | if (build) |
Jay Sternberg | 3939608 | 2010-08-12 10:24:07 -0700 | [diff] [blame] | 1531 | sprintf(buildstr, " build %u%s", build, |
| 1532 | (priv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
| 1533 | ? " (EXP)" : ""); |
Johannes Berg | 3e4de76 | 2010-04-28 12:09:12 -0700 | [diff] [blame] | 1534 | else |
| 1535 | buildstr[0] = '\0'; |
Reinette Chatre | a0987a8 | 2008-12-02 12:14:06 -0800 | [diff] [blame] | 1536 | |
Johannes Berg | 3e4de76 | 2010-04-28 12:09:12 -0700 | [diff] [blame] | 1537 | IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u%s\n", |
Reinette Chatre | 5ebeb5a | 2009-10-30 14:36:04 -0700 | [diff] [blame] | 1538 | IWL_UCODE_MAJOR(priv->ucode_ver), |
| 1539 | IWL_UCODE_MINOR(priv->ucode_ver), |
| 1540 | IWL_UCODE_API(priv->ucode_ver), |
Johannes Berg | 3e4de76 | 2010-04-28 12:09:12 -0700 | [diff] [blame] | 1541 | IWL_UCODE_SERIAL(priv->ucode_ver), |
| 1542 | buildstr); |
Reinette Chatre | 5ebeb5a | 2009-10-30 14:36:04 -0700 | [diff] [blame] | 1543 | |
Johannes Berg | 3e4de76 | 2010-04-28 12:09:12 -0700 | [diff] [blame] | 1544 | snprintf(priv->hw->wiphy->fw_version, |
| 1545 | sizeof(priv->hw->wiphy->fw_version), |
| 1546 | "%u.%u.%u.%u%s", |
| 1547 | IWL_UCODE_MAJOR(priv->ucode_ver), |
| 1548 | IWL_UCODE_MINOR(priv->ucode_ver), |
| 1549 | IWL_UCODE_API(priv->ucode_ver), |
| 1550 | IWL_UCODE_SERIAL(priv->ucode_ver), |
| 1551 | buildstr); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1552 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1553 | /* |
| 1554 | * For any of the failures below (before allocating pci memory) |
| 1555 | * we will try to load a version with a smaller API -- maybe the |
| 1556 | * user just got a corrupted version of the latest API. |
| 1557 | */ |
| 1558 | |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1559 | IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", |
| 1560 | priv->ucode_ver); |
| 1561 | IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", |
| 1562 | pieces.inst_size); |
| 1563 | IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", |
| 1564 | pieces.data_size); |
| 1565 | IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", |
| 1566 | pieces.init_size); |
| 1567 | IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", |
| 1568 | pieces.init_data_size); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1569 | |
| 1570 | /* Verify that uCode images will fit in card's SRAM */ |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1571 | if (pieces.inst_size > priv->hw_params.max_inst_size) { |
| 1572 | IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n", |
| 1573 | pieces.inst_size); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1574 | goto try_again; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1575 | } |
| 1576 | |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1577 | if (pieces.data_size > priv->hw_params.max_data_size) { |
| 1578 | IWL_ERR(priv, "uCode data len %Zd too large to fit in\n", |
| 1579 | pieces.data_size); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1580 | goto try_again; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1581 | } |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1582 | |
| 1583 | if (pieces.init_size > priv->hw_params.max_inst_size) { |
| 1584 | IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", |
| 1585 | pieces.init_size); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1586 | goto try_again; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1587 | } |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1588 | |
| 1589 | if (pieces.init_data_size > priv->hw_params.max_data_size) { |
| 1590 | IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n", |
| 1591 | pieces.init_data_size); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1592 | goto try_again; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1593 | } |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1594 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1595 | /* Allocate ucode buffers for card's bus-master loading ... */ |
| 1596 | |
| 1597 | /* Runtime instructions and 2 copies of data: |
| 1598 | * 1) unmodified from disk |
| 1599 | * 2) backup cache for save/restore during power-downs */ |
Johannes Berg | dbf28e21 | 2011-04-16 08:29:24 -0700 | [diff] [blame] | 1600 | if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_rt.code, |
| 1601 | pieces.inst, pieces.inst_size)) |
| 1602 | goto err_pci_alloc; |
| 1603 | if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_rt.data, |
| 1604 | pieces.data, pieces.data_size)) |
Zhu, Yi | 1f304e4 | 2009-01-23 13:45:22 -0800 | [diff] [blame] | 1605 | goto err_pci_alloc; |
| 1606 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1607 | /* Initialization instructions and data */ |
Johannes Berg | 0e9a44d | 2010-04-28 12:09:16 -0700 | [diff] [blame] | 1608 | if (pieces.init_size && pieces.init_data_size) { |
Johannes Berg | dbf28e21 | 2011-04-16 08:29:24 -0700 | [diff] [blame] | 1609 | if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init.code, |
| 1610 | pieces.init, pieces.init_size)) |
| 1611 | goto err_pci_alloc; |
| 1612 | if (iwl_alloc_fw_desc(priv->pci_dev, &priv->ucode_init.data, |
| 1613 | pieces.init_data, pieces.init_data_size)) |
Tomas Winkler | 90e759d | 2007-11-29 11:09:41 +0800 | [diff] [blame] | 1614 | goto err_pci_alloc; |
| 1615 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1616 | |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1617 | /* Now that we can no longer fail, copy information */ |
| 1618 | |
| 1619 | /* |
| 1620 | * The (size - 16) / 12 formula is based on the information recorded |
| 1621 | * for each event, which is of mode 1 (including timestamp) for all |
| 1622 | * new microcodes that include this information. |
| 1623 | */ |
| 1624 | priv->_agn.init_evtlog_ptr = pieces.init_evtlog_ptr; |
| 1625 | if (pieces.init_evtlog_size) |
| 1626 | priv->_agn.init_evtlog_size = (pieces.init_evtlog_size - 16)/12; |
| 1627 | else |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1628 | priv->_agn.init_evtlog_size = |
| 1629 | priv->cfg->base_params->max_event_log_size; |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1630 | priv->_agn.init_errlog_ptr = pieces.init_errlog_ptr; |
| 1631 | priv->_agn.inst_evtlog_ptr = pieces.inst_evtlog_ptr; |
| 1632 | if (pieces.inst_evtlog_size) |
| 1633 | priv->_agn.inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; |
| 1634 | else |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 1635 | priv->_agn.inst_evtlog_size = |
| 1636 | priv->cfg->base_params->max_event_log_size; |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1637 | priv->_agn.inst_errlog_ptr = pieces.inst_errlog_ptr; |
| 1638 | |
Johannes Berg | d2690c0 | 2011-04-20 09:10:39 -0700 | [diff] [blame] | 1639 | priv->new_scan_threshold_behaviour = |
| 1640 | !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); |
| 1641 | |
Johannes Berg | 3997ff3 | 2011-04-05 09:42:02 -0700 | [diff] [blame] | 1642 | if (ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PAN) { |
Johannes Berg | ece9c4e | 2010-08-23 10:46:49 +0200 | [diff] [blame] | 1643 | priv->valid_contexts |= BIT(IWL_RXON_CTX_PAN); |
Johannes Berg | c10afb6 | 2010-08-23 10:46:43 +0200 | [diff] [blame] | 1644 | priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN; |
Johannes Berg | ece9c4e | 2010-08-23 10:46:49 +0200 | [diff] [blame] | 1645 | } else |
| 1646 | priv->sta_key_max_num = STA_KEY_MAX_NUM; |
Johannes Berg | c10afb6 | 2010-08-23 10:46:43 +0200 | [diff] [blame] | 1647 | |
Johannes Berg | 17445b8 | 2011-04-05 09:42:05 -0700 | [diff] [blame] | 1648 | if (priv->valid_contexts != BIT(IWL_RXON_CTX_BSS)) |
| 1649 | priv->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM; |
| 1650 | else |
| 1651 | priv->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; |
| 1652 | |
Wey-Yi Guy | 6a822d0 | 2010-07-13 17:13:15 -0700 | [diff] [blame] | 1653 | /* |
| 1654 | * figure out the offset of chain noise reset and gain commands |
| 1655 | * base on the size of standard phy calibration commands table size |
| 1656 | */ |
| 1657 | if (ucode_capa.standard_phy_calibration_size > |
| 1658 | IWL_MAX_PHY_CALIBRATE_TBL_SIZE) |
| 1659 | ucode_capa.standard_phy_calibration_size = |
| 1660 | IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
| 1661 | |
| 1662 | priv->_agn.phy_calib_chain_noise_reset_cmd = |
| 1663 | ucode_capa.standard_phy_calibration_size; |
| 1664 | priv->_agn.phy_calib_chain_noise_gain_cmd = |
| 1665 | ucode_capa.standard_phy_calibration_size + 1; |
| 1666 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1667 | /************************************************** |
| 1668 | * This is still part of probe() in a sense... |
| 1669 | * |
| 1670 | * 9. Setup and register with mac80211 and debugfs |
| 1671 | **************************************************/ |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 1672 | err = iwl_mac_setup_register(priv, &ucode_capa); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1673 | if (err) |
| 1674 | goto out_unbind; |
| 1675 | |
| 1676 | err = iwl_dbgfs_register(priv, DRV_NAME); |
| 1677 | if (err) |
| 1678 | IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); |
| 1679 | |
Emmanuel Grumbach | 7d47618 | 2010-05-23 00:14:08 -0700 | [diff] [blame] | 1680 | err = sysfs_create_group(&priv->pci_dev->dev.kobj, |
| 1681 | &iwl_attribute_group); |
| 1682 | if (err) { |
| 1683 | IWL_ERR(priv, "failed to create sysfs device attributes\n"); |
| 1684 | goto out_unbind; |
| 1685 | } |
| 1686 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1687 | /* We have our copies now, allow OS release its copies */ |
| 1688 | release_firmware(ucode_raw); |
Reinette Chatre | a15707d | 2010-05-10 15:08:11 -0700 | [diff] [blame] | 1689 | complete(&priv->_agn.firmware_loading_complete); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1690 | return; |
| 1691 | |
| 1692 | try_again: |
| 1693 | /* try next, if any */ |
| 1694 | if (iwl_request_firmware(priv, false)) |
| 1695 | goto out_unbind; |
| 1696 | release_firmware(ucode_raw); |
| 1697 | return; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1698 | |
| 1699 | err_pci_alloc: |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 1700 | IWL_ERR(priv, "failed to allocate pci memory\n"); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 1701 | iwl_dealloc_ucode_pci(priv); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1702 | out_unbind: |
Reinette Chatre | a15707d | 2010-05-10 15:08:11 -0700 | [diff] [blame] | 1703 | complete(&priv->_agn.firmware_loading_complete); |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 1704 | device_release_driver(&priv->pci_dev->dev); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1705 | release_firmware(ucode_raw); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1706 | } |
| 1707 | |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1708 | static const char *desc_lookup_text[] = { |
| 1709 | "OK", |
| 1710 | "FAIL", |
| 1711 | "BAD_PARAM", |
| 1712 | "BAD_CHECKSUM", |
| 1713 | "NMI_INTERRUPT_WDG", |
| 1714 | "SYSASSERT", |
| 1715 | "FATAL_ERROR", |
| 1716 | "BAD_COMMAND", |
| 1717 | "HW_ERROR_TUNE_LOCK", |
| 1718 | "HW_ERROR_TEMPERATURE", |
| 1719 | "ILLEGAL_CHAN_FREQ", |
| 1720 | "VCC_NOT_STABLE", |
| 1721 | "FH_ERROR", |
| 1722 | "NMI_INTERRUPT_HOST", |
| 1723 | "NMI_INTERRUPT_ACTION_PT", |
| 1724 | "NMI_INTERRUPT_UNKNOWN", |
| 1725 | "UCODE_VERSION_MISMATCH", |
| 1726 | "HW_ERROR_ABS_LOCK", |
| 1727 | "HW_ERROR_CAL_LOCK_FAIL", |
| 1728 | "NMI_INTERRUPT_INST_ACTION_PT", |
| 1729 | "NMI_INTERRUPT_DATA_ACTION_PT", |
| 1730 | "NMI_TRM_HW_ER", |
| 1731 | "NMI_INTERRUPT_TRM", |
| 1732 | "NMI_INTERRUPT_BREAK_POINT" |
| 1733 | "DEBUG_0", |
| 1734 | "DEBUG_1", |
| 1735 | "DEBUG_2", |
| 1736 | "DEBUG_3", |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1737 | }; |
| 1738 | |
Jay Sternberg | 4b58645 | 2010-07-02 15:49:10 -0700 | [diff] [blame] | 1739 | static struct { char *name; u8 num; } advanced_lookup[] = { |
| 1740 | { "NMI_INTERRUPT_WDG", 0x34 }, |
| 1741 | { "SYSASSERT", 0x35 }, |
| 1742 | { "UCODE_VERSION_MISMATCH", 0x37 }, |
| 1743 | { "BAD_COMMAND", 0x38 }, |
| 1744 | { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, |
| 1745 | { "FATAL_ERROR", 0x3D }, |
| 1746 | { "NMI_TRM_HW_ERR", 0x46 }, |
| 1747 | { "NMI_INTERRUPT_TRM", 0x4C }, |
| 1748 | { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, |
| 1749 | { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, |
| 1750 | { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, |
| 1751 | { "NMI_INTERRUPT_HOST", 0x66 }, |
| 1752 | { "NMI_INTERRUPT_ACTION_PT", 0x7C }, |
| 1753 | { "NMI_INTERRUPT_UNKNOWN", 0x84 }, |
| 1754 | { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, |
| 1755 | { "ADVANCED_SYSASSERT", 0 }, |
| 1756 | }; |
| 1757 | |
| 1758 | static const char *desc_lookup(u32 num) |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1759 | { |
Jay Sternberg | 4b58645 | 2010-07-02 15:49:10 -0700 | [diff] [blame] | 1760 | int i; |
| 1761 | int max = ARRAY_SIZE(desc_lookup_text); |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1762 | |
Jay Sternberg | 4b58645 | 2010-07-02 15:49:10 -0700 | [diff] [blame] | 1763 | if (num < max) |
| 1764 | return desc_lookup_text[num]; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1765 | |
Jay Sternberg | 4b58645 | 2010-07-02 15:49:10 -0700 | [diff] [blame] | 1766 | max = ARRAY_SIZE(advanced_lookup) - 1; |
| 1767 | for (i = 0; i < max; i++) { |
| 1768 | if (advanced_lookup[i].num == num) |
| 1769 | break;; |
| 1770 | } |
| 1771 | return advanced_lookup[i].name; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1772 | } |
| 1773 | |
| 1774 | #define ERROR_START_OFFSET (1 * sizeof(u32)) |
| 1775 | #define ERROR_ELEM_SIZE (7 * sizeof(u32)) |
| 1776 | |
| 1777 | void iwl_dump_nic_error_log(struct iwl_priv *priv) |
| 1778 | { |
| 1779 | u32 data2, line; |
| 1780 | u32 desc, time, count, base, data1; |
| 1781 | u32 blink1, blink2, ilink1, ilink2; |
Wey-Yi Guy | 461ef38 | 2010-03-30 17:57:53 -0700 | [diff] [blame] | 1782 | u32 pc, hcmd; |
Johannes Berg | e46f653 | 2011-04-13 03:14:43 -0700 | [diff] [blame] | 1783 | struct iwl_error_event_table table; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1784 | |
Johannes Berg | d7d5783 | 2011-04-05 09:42:04 -0700 | [diff] [blame] | 1785 | base = priv->device_pointers.error_event_table; |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 1786 | if (priv->ucode_type == UCODE_SUBTYPE_INIT) { |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1787 | if (!base) |
| 1788 | base = priv->_agn.init_errlog_ptr; |
| 1789 | } else { |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1790 | if (!base) |
| 1791 | base = priv->_agn.inst_errlog_ptr; |
| 1792 | } |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1793 | |
| 1794 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { |
Wey-Yi Guy | 212fb57 | 2009-12-02 12:53:00 -0800 | [diff] [blame] | 1795 | IWL_ERR(priv, |
| 1796 | "Not valid error log pointer 0x%08X for %s uCode\n", |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 1797 | base, |
| 1798 | (priv->ucode_type == UCODE_SUBTYPE_INIT) |
| 1799 | ? "Init" : "RT"); |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1800 | return; |
| 1801 | } |
| 1802 | |
Johannes Berg | e46f653 | 2011-04-13 03:14:43 -0700 | [diff] [blame] | 1803 | iwl_read_targ_mem_words(priv, base, &table, sizeof(table)); |
| 1804 | |
| 1805 | count = table.valid; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1806 | |
| 1807 | if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { |
| 1808 | IWL_ERR(priv, "Start IWL Error Log Dump:\n"); |
| 1809 | IWL_ERR(priv, "Status: 0x%08lX, count: %d\n", |
| 1810 | priv->status, count); |
| 1811 | } |
| 1812 | |
Johannes Berg | e46f653 | 2011-04-13 03:14:43 -0700 | [diff] [blame] | 1813 | desc = table.error_id; |
Wey-Yi Guy | 6e6ebf4 | 2010-08-27 10:41:37 -0700 | [diff] [blame] | 1814 | priv->isr_stats.err_code = desc; |
Johannes Berg | e46f653 | 2011-04-13 03:14:43 -0700 | [diff] [blame] | 1815 | pc = table.pc; |
| 1816 | blink1 = table.blink1; |
| 1817 | blink2 = table.blink2; |
| 1818 | ilink1 = table.ilink1; |
| 1819 | ilink2 = table.ilink2; |
| 1820 | data1 = table.data1; |
| 1821 | data2 = table.data2; |
| 1822 | line = table.line; |
| 1823 | time = table.tsf_low; |
| 1824 | hcmd = table.hcmd; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1825 | |
Johannes Berg | be1a71a | 2009-10-02 13:44:02 -0700 | [diff] [blame] | 1826 | trace_iwlwifi_dev_ucode_error(priv, desc, time, data1, data2, line, |
| 1827 | blink1, blink2, ilink1, ilink2); |
| 1828 | |
Jay Sternberg | 8756371 | 2010-06-14 14:40:40 -0700 | [diff] [blame] | 1829 | IWL_ERR(priv, "Desc Time " |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1830 | "data1 data2 line\n"); |
Jay Sternberg | 8756371 | 2010-06-14 14:40:40 -0700 | [diff] [blame] | 1831 | IWL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1832 | desc_lookup(desc), desc, time, data1, data2, line); |
Wey-Yi Guy | 461ef38 | 2010-03-30 17:57:53 -0700 | [diff] [blame] | 1833 | IWL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); |
| 1834 | IWL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", |
| 1835 | pc, blink1, blink2, ilink1, ilink2, hcmd); |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1836 | } |
| 1837 | |
| 1838 | #define EVENT_START_OFFSET (4 * sizeof(u32)) |
| 1839 | |
| 1840 | /** |
| 1841 | * iwl_print_event_log - Dump error event log to syslog |
| 1842 | * |
| 1843 | */ |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1844 | static int iwl_print_event_log(struct iwl_priv *priv, u32 start_idx, |
| 1845 | u32 num_events, u32 mode, |
| 1846 | int pos, char **buf, size_t bufsz) |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1847 | { |
| 1848 | u32 i; |
| 1849 | u32 base; /* SRAM byte address of event log header */ |
| 1850 | u32 event_size; /* 2 u32s, or 3 u32s if timestamp recorded */ |
| 1851 | u32 ptr; /* SRAM byte address of log data */ |
| 1852 | u32 ev, time, data; /* event log data */ |
Ben Cahill | e585447 | 2009-11-06 14:52:58 -0800 | [diff] [blame] | 1853 | unsigned long reg_flags; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1854 | |
| 1855 | if (num_events == 0) |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1856 | return pos; |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1857 | |
Johannes Berg | d7d5783 | 2011-04-05 09:42:04 -0700 | [diff] [blame] | 1858 | base = priv->device_pointers.log_event_table; |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 1859 | if (priv->ucode_type == UCODE_SUBTYPE_INIT) { |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1860 | if (!base) |
| 1861 | base = priv->_agn.init_evtlog_ptr; |
| 1862 | } else { |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1863 | if (!base) |
| 1864 | base = priv->_agn.inst_evtlog_ptr; |
| 1865 | } |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1866 | |
| 1867 | if (mode == 0) |
| 1868 | event_size = 2 * sizeof(u32); |
| 1869 | else |
| 1870 | event_size = 3 * sizeof(u32); |
| 1871 | |
| 1872 | ptr = base + EVENT_START_OFFSET + (start_idx * event_size); |
| 1873 | |
Ben Cahill | e585447 | 2009-11-06 14:52:58 -0800 | [diff] [blame] | 1874 | /* Make sure device is powered up for SRAM reads */ |
| 1875 | spin_lock_irqsave(&priv->reg_lock, reg_flags); |
| 1876 | iwl_grab_nic_access(priv); |
| 1877 | |
| 1878 | /* Set starting address; reads will auto-increment */ |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 1879 | iwl_write32(priv, HBUS_TARG_MEM_RADDR, ptr); |
Ben Cahill | e585447 | 2009-11-06 14:52:58 -0800 | [diff] [blame] | 1880 | rmb(); |
| 1881 | |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1882 | /* "time" is actually "data" for mode 0 (no timestamp). |
| 1883 | * place event id # at far right for easier visual parsing. */ |
| 1884 | for (i = 0; i < num_events; i++) { |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 1885 | ev = iwl_read32(priv, HBUS_TARG_MEM_RDAT); |
| 1886 | time = iwl_read32(priv, HBUS_TARG_MEM_RDAT); |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1887 | if (mode == 0) { |
| 1888 | /* data, ev */ |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1889 | if (bufsz) { |
| 1890 | pos += scnprintf(*buf + pos, bufsz - pos, |
| 1891 | "EVT_LOG:0x%08x:%04u\n", |
| 1892 | time, ev); |
| 1893 | } else { |
| 1894 | trace_iwlwifi_dev_ucode_event(priv, 0, |
| 1895 | time, ev); |
| 1896 | IWL_ERR(priv, "EVT_LOG:0x%08x:%04u\n", |
| 1897 | time, ev); |
| 1898 | } |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1899 | } else { |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 1900 | data = iwl_read32(priv, HBUS_TARG_MEM_RDAT); |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1901 | if (bufsz) { |
| 1902 | pos += scnprintf(*buf + pos, bufsz - pos, |
| 1903 | "EVT_LOGT:%010u:0x%08x:%04u\n", |
| 1904 | time, data, ev); |
| 1905 | } else { |
| 1906 | IWL_ERR(priv, "EVT_LOGT:%010u:0x%08x:%04u\n", |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1907 | time, data, ev); |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1908 | trace_iwlwifi_dev_ucode_event(priv, time, |
| 1909 | data, ev); |
| 1910 | } |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1911 | } |
| 1912 | } |
Ben Cahill | e585447 | 2009-11-06 14:52:58 -0800 | [diff] [blame] | 1913 | |
| 1914 | /* Allow device to power down */ |
| 1915 | iwl_release_nic_access(priv); |
| 1916 | spin_unlock_irqrestore(&priv->reg_lock, reg_flags); |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1917 | return pos; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1918 | } |
| 1919 | |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 1920 | /** |
| 1921 | * iwl_print_last_event_logs - Dump the newest # of event log to syslog |
| 1922 | */ |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1923 | static int iwl_print_last_event_logs(struct iwl_priv *priv, u32 capacity, |
| 1924 | u32 num_wraps, u32 next_entry, |
| 1925 | u32 size, u32 mode, |
| 1926 | int pos, char **buf, size_t bufsz) |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 1927 | { |
| 1928 | /* |
| 1929 | * display the newest DEFAULT_LOG_ENTRIES entries |
| 1930 | * i.e the entries just before the next ont that uCode would fill. |
| 1931 | */ |
| 1932 | if (num_wraps) { |
| 1933 | if (next_entry < size) { |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1934 | pos = iwl_print_event_log(priv, |
| 1935 | capacity - (size - next_entry), |
| 1936 | size - next_entry, mode, |
| 1937 | pos, buf, bufsz); |
| 1938 | pos = iwl_print_event_log(priv, 0, |
| 1939 | next_entry, mode, |
| 1940 | pos, buf, bufsz); |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 1941 | } else |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1942 | pos = iwl_print_event_log(priv, next_entry - size, |
| 1943 | size, mode, pos, buf, bufsz); |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 1944 | } else { |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1945 | if (next_entry < size) { |
| 1946 | pos = iwl_print_event_log(priv, 0, next_entry, |
| 1947 | mode, pos, buf, bufsz); |
| 1948 | } else { |
| 1949 | pos = iwl_print_event_log(priv, next_entry - size, |
| 1950 | size, mode, pos, buf, bufsz); |
| 1951 | } |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 1952 | } |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1953 | return pos; |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 1954 | } |
| 1955 | |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 1956 | #define DEFAULT_DUMP_EVENT_LOG_ENTRIES (20) |
| 1957 | |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1958 | int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log, |
| 1959 | char **buf, bool display) |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1960 | { |
| 1961 | u32 base; /* SRAM byte address of event log header */ |
| 1962 | u32 capacity; /* event log capacity in # entries */ |
| 1963 | u32 mode; /* 0 - no timestamp, 1 - timestamp recorded */ |
| 1964 | u32 num_wraps; /* # times uCode wrapped to top of log */ |
| 1965 | u32 next_entry; /* index of next entry to be written by uCode */ |
| 1966 | u32 size; /* # entries that we'll print */ |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1967 | u32 logsize; |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 1968 | int pos = 0; |
| 1969 | size_t bufsz = 0; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1970 | |
Johannes Berg | d7d5783 | 2011-04-05 09:42:04 -0700 | [diff] [blame] | 1971 | base = priv->device_pointers.log_event_table; |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 1972 | if (priv->ucode_type == UCODE_SUBTYPE_INIT) { |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1973 | logsize = priv->_agn.init_evtlog_size; |
| 1974 | if (!base) |
| 1975 | base = priv->_agn.init_evtlog_ptr; |
| 1976 | } else { |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1977 | logsize = priv->_agn.inst_evtlog_size; |
| 1978 | if (!base) |
| 1979 | base = priv->_agn.inst_evtlog_ptr; |
| 1980 | } |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1981 | |
| 1982 | if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { |
Wey-Yi Guy | 212fb57 | 2009-12-02 12:53:00 -0800 | [diff] [blame] | 1983 | IWL_ERR(priv, |
| 1984 | "Invalid event log pointer 0x%08X for %s uCode\n", |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 1985 | base, |
| 1986 | (priv->ucode_type == UCODE_SUBTYPE_INIT) |
| 1987 | ? "Init" : "RT"); |
Wey-Yi Guy | 937c397 | 2010-01-15 13:43:36 -0800 | [diff] [blame] | 1988 | return -EINVAL; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 1989 | } |
| 1990 | |
| 1991 | /* event log header */ |
| 1992 | capacity = iwl_read_targ_mem(priv, base); |
| 1993 | mode = iwl_read_targ_mem(priv, base + (1 * sizeof(u32))); |
| 1994 | num_wraps = iwl_read_targ_mem(priv, base + (2 * sizeof(u32))); |
| 1995 | next_entry = iwl_read_targ_mem(priv, base + (3 * sizeof(u32))); |
| 1996 | |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1997 | if (capacity > logsize) { |
Ben Cahill | 84c4069 | 2009-11-06 14:52:57 -0800 | [diff] [blame] | 1998 | IWL_ERR(priv, "Log capacity %d is bogus, limit to %d entries\n", |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 1999 | capacity, logsize); |
| 2000 | capacity = logsize; |
Ben Cahill | 84c4069 | 2009-11-06 14:52:57 -0800 | [diff] [blame] | 2001 | } |
| 2002 | |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 2003 | if (next_entry > logsize) { |
Ben Cahill | 84c4069 | 2009-11-06 14:52:57 -0800 | [diff] [blame] | 2004 | IWL_ERR(priv, "Log write index %d is bogus, limit to %d\n", |
Johannes Berg | b2e640d | 2010-05-05 23:24:54 -0700 | [diff] [blame] | 2005 | next_entry, logsize); |
| 2006 | next_entry = logsize; |
Ben Cahill | 84c4069 | 2009-11-06 14:52:57 -0800 | [diff] [blame] | 2007 | } |
| 2008 | |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 2009 | size = num_wraps ? capacity : next_entry; |
| 2010 | |
| 2011 | /* bail out if nothing in log */ |
| 2012 | if (size == 0) { |
| 2013 | IWL_ERR(priv, "Start IWL Event Log Dump: nothing in log\n"); |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2014 | return pos; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 2015 | } |
| 2016 | |
Wey-Yi Guy | 9f28ebc | 2010-11-26 13:24:19 -0800 | [diff] [blame] | 2017 | /* enable/disable bt channel inhibition */ |
Wey-Yi Guy | f37837c | 2010-08-23 07:57:12 -0700 | [diff] [blame] | 2018 | priv->bt_ch_announce = iwlagn_bt_ch_announce; |
| 2019 | |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2020 | #ifdef CONFIG_IWLWIFI_DEBUG |
Wey-Yi Guy | 521d9bc | 2009-12-10 14:37:23 -0800 | [diff] [blame] | 2021 | if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log) |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2022 | size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES) |
| 2023 | ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size; |
| 2024 | #else |
| 2025 | size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES) |
| 2026 | ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size; |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 2027 | #endif |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2028 | IWL_ERR(priv, "Start IWL Event Log Dump: display last %u entries\n", |
| 2029 | size); |
| 2030 | |
| 2031 | #ifdef CONFIG_IWLWIFI_DEBUG |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2032 | if (display) { |
| 2033 | if (full_log) |
| 2034 | bufsz = capacity * 48; |
| 2035 | else |
| 2036 | bufsz = size * 48; |
| 2037 | *buf = kmalloc(bufsz, GFP_KERNEL); |
| 2038 | if (!*buf) |
Wey-Yi Guy | 937c397 | 2010-01-15 13:43:36 -0800 | [diff] [blame] | 2039 | return -ENOMEM; |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2040 | } |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2041 | if ((iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) || full_log) { |
| 2042 | /* |
| 2043 | * if uCode has wrapped back to top of log, |
| 2044 | * start at the oldest entry, |
| 2045 | * i.e the next one that uCode would fill. |
| 2046 | */ |
| 2047 | if (num_wraps) |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2048 | pos = iwl_print_event_log(priv, next_entry, |
| 2049 | capacity - next_entry, mode, |
| 2050 | pos, buf, bufsz); |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2051 | /* (then/else) start at top of log */ |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2052 | pos = iwl_print_event_log(priv, 0, |
| 2053 | next_entry, mode, pos, buf, bufsz); |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2054 | } else |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2055 | pos = iwl_print_last_event_logs(priv, capacity, num_wraps, |
| 2056 | next_entry, size, mode, |
| 2057 | pos, buf, bufsz); |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2058 | #else |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2059 | pos = iwl_print_last_event_logs(priv, capacity, num_wraps, |
| 2060 | next_entry, size, mode, |
| 2061 | pos, buf, bufsz); |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2062 | #endif |
Wey-Yi Guy | b03d7d0 | 2009-12-14 14:12:20 -0800 | [diff] [blame] | 2063 | return pos; |
Wey-Yi Guy | c341ddb | 2009-11-20 12:05:07 -0800 | [diff] [blame] | 2064 | } |
Reinette Chatre | b7a7940 | 2009-09-25 14:24:23 -0700 | [diff] [blame] | 2065 | |
Wey-Yi Guy | 0975cc8 | 2010-07-31 08:34:07 -0700 | [diff] [blame] | 2066 | static void iwl_rf_kill_ct_config(struct iwl_priv *priv) |
| 2067 | { |
| 2068 | struct iwl_ct_kill_config cmd; |
| 2069 | struct iwl_ct_kill_throttling_config adv_cmd; |
| 2070 | unsigned long flags; |
| 2071 | int ret = 0; |
| 2072 | |
| 2073 | spin_lock_irqsave(&priv->lock, flags); |
| 2074 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, |
| 2075 | CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); |
| 2076 | spin_unlock_irqrestore(&priv->lock, flags); |
| 2077 | priv->thermal_throttle.ct_kill_toggle = false; |
| 2078 | |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2079 | if (priv->cfg->base_params->support_ct_kill_exit) { |
Wey-Yi Guy | 0975cc8 | 2010-07-31 08:34:07 -0700 | [diff] [blame] | 2080 | adv_cmd.critical_temperature_enter = |
| 2081 | cpu_to_le32(priv->hw_params.ct_kill_threshold); |
| 2082 | adv_cmd.critical_temperature_exit = |
| 2083 | cpu_to_le32(priv->hw_params.ct_kill_exit_threshold); |
| 2084 | |
| 2085 | ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, |
| 2086 | sizeof(adv_cmd), &adv_cmd); |
| 2087 | if (ret) |
| 2088 | IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); |
| 2089 | else |
| 2090 | IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " |
| 2091 | "succeeded, " |
| 2092 | "critical temperature enter is %d," |
| 2093 | "exit is %d\n", |
| 2094 | priv->hw_params.ct_kill_threshold, |
| 2095 | priv->hw_params.ct_kill_exit_threshold); |
| 2096 | } else { |
| 2097 | cmd.critical_temperature_R = |
| 2098 | cpu_to_le32(priv->hw_params.ct_kill_threshold); |
| 2099 | |
| 2100 | ret = iwl_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, |
| 2101 | sizeof(cmd), &cmd); |
| 2102 | if (ret) |
| 2103 | IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); |
| 2104 | else |
| 2105 | IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " |
| 2106 | "succeeded, " |
| 2107 | "critical temperature is %d\n", |
| 2108 | priv->hw_params.ct_kill_threshold); |
| 2109 | } |
| 2110 | } |
| 2111 | |
Shanyu Zhao | 6d6a1af | 2010-09-14 18:13:31 -0700 | [diff] [blame] | 2112 | static int iwlagn_send_calib_cfg_rt(struct iwl_priv *priv, u32 cfg) |
| 2113 | { |
| 2114 | struct iwl_calib_cfg_cmd calib_cfg_cmd; |
| 2115 | struct iwl_host_cmd cmd = { |
| 2116 | .id = CALIBRATION_CFG_CMD, |
Johannes Berg | 3fa5073 | 2011-05-04 07:50:38 -0700 | [diff] [blame^] | 2117 | .len = { sizeof(struct iwl_calib_cfg_cmd), }, |
| 2118 | .data = { &calib_cfg_cmd, }, |
Shanyu Zhao | 6d6a1af | 2010-09-14 18:13:31 -0700 | [diff] [blame] | 2119 | }; |
| 2120 | |
| 2121 | memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd)); |
| 2122 | calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2123 | calib_cfg_cmd.ucd_calib_cfg.once.start = cpu_to_le32(cfg); |
Shanyu Zhao | 6d6a1af | 2010-09-14 18:13:31 -0700 | [diff] [blame] | 2124 | |
| 2125 | return iwl_send_cmd(priv, &cmd); |
| 2126 | } |
| 2127 | |
| 2128 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2129 | /** |
Tomas Winkler | 4a4a9e8 | 2008-05-29 16:34:54 +0800 | [diff] [blame] | 2130 | * iwl_alive_start - called after REPLY_ALIVE notification received |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2131 | * from protocol/runtime uCode (initialization uCode's |
Tomas Winkler | 4a4a9e8 | 2008-05-29 16:34:54 +0800 | [diff] [blame] | 2132 | * Alive gets handled by iwl_init_alive_start()). |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2133 | */ |
Cindy H. Kao | 4613e72 | 2011-05-06 10:40:15 -0700 | [diff] [blame] | 2134 | int iwl_alive_start(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2135 | { |
Tomas Winkler | 57aab75 | 2008-04-14 21:16:03 -0700 | [diff] [blame] | 2136 | int ret = 0; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2137 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2138 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2139 | iwl_reset_ict(priv); |
| 2140 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2141 | IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2142 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2143 | /* After the ALIVE response, we can send host commands to the uCode */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2144 | set_bit(STATUS_ALIVE, &priv->status); |
| 2145 | |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2146 | /* Enable watchdog to monitor the driver tx queues */ |
| 2147 | iwl_setup_watchdog(priv); |
Wey-Yi Guy | b74e31a | 2010-03-01 17:23:50 -0800 | [diff] [blame] | 2148 | |
Tomas Winkler | fee1247 | 2008-04-03 16:05:21 -0700 | [diff] [blame] | 2149 | if (iwl_is_rfkill(priv)) |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2150 | return -ERFKILL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2151 | |
Wey-Yi Guy | bc795df | 2010-10-11 14:24:05 -0700 | [diff] [blame] | 2152 | /* download priority table before any calibration request */ |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2153 | if (priv->cfg->bt_params && |
| 2154 | priv->cfg->bt_params->advanced_bt_coexist) { |
Wey-Yi Guy | f7322f8 | 2010-08-23 15:24:49 -0700 | [diff] [blame] | 2155 | /* Configure Bluetooth device coexistence support */ |
| 2156 | priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK; |
| 2157 | priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT; |
| 2158 | priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT; |
| 2159 | priv->cfg->ops->hcmd->send_bt_config(priv); |
| 2160 | priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS; |
Wey-Yi Guy | a5901cb | 2010-09-23 09:56:51 -0700 | [diff] [blame] | 2161 | iwlagn_send_prio_tbl(priv); |
Wey-Yi Guy | f7322f8 | 2010-08-23 15:24:49 -0700 | [diff] [blame] | 2162 | |
| 2163 | /* FIXME: w/a to force change uCode BT state machine */ |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2164 | ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, |
| 2165 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); |
| 2166 | if (ret) |
| 2167 | return ret; |
| 2168 | ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE, |
| 2169 | BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); |
| 2170 | if (ret) |
| 2171 | return ret; |
Wey-Yi Guy | f7322f8 | 2010-08-23 15:24:49 -0700 | [diff] [blame] | 2172 | } |
Wey-Yi Guy | bc795df | 2010-10-11 14:24:05 -0700 | [diff] [blame] | 2173 | if (priv->hw_params.calib_rt_cfg) |
| 2174 | iwlagn_send_calib_cfg_rt(priv, priv->hw_params.calib_rt_cfg); |
| 2175 | |
Johannes Berg | 36d6825 | 2008-05-15 12:55:26 +0200 | [diff] [blame] | 2176 | ieee80211_wake_queues(priv->hw); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2177 | |
Johannes Berg | 470ab2d | 2010-01-21 11:23:30 -0800 | [diff] [blame] | 2178 | priv->active_rate = IWL_RATES_MASK; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2179 | |
Wey-Yi Guy | 2f748de | 2009-09-17 10:43:51 -0700 | [diff] [blame] | 2180 | /* Configure Tx antenna selection based on H/W config */ |
| 2181 | if (priv->cfg->ops->hcmd->set_tx_ant) |
| 2182 | priv->cfg->ops->hcmd->set_tx_ant(priv, priv->cfg->valid_tx_ant); |
| 2183 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2184 | if (iwl_is_associated_ctx(ctx)) { |
Gregory Greenman | c1adf9f | 2008-05-15 13:53:59 +0800 | [diff] [blame] | 2185 | struct iwl_rxon_cmd *active_rxon = |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2186 | (struct iwl_rxon_cmd *)&ctx->active; |
Mohamed Abbas | 019fb97 | 2009-03-17 21:59:18 -0700 | [diff] [blame] | 2187 | /* apply any changes in staging */ |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2188 | ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2189 | active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
| 2190 | } else { |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 2191 | struct iwl_rxon_context *tmp; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2192 | /* Initialize our rx_config data */ |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 2193 | for_each_context(priv, tmp) |
| 2194 | iwl_connection_init_rx_config(priv, tmp); |
Abhijeet Kolekar | 4582353 | 2009-04-08 11:26:44 -0700 | [diff] [blame] | 2195 | |
| 2196 | if (priv->cfg->ops->hcmd->set_rxon_chain) |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2197 | priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2198 | } |
| 2199 | |
Wey-Yi Guy | 73b78a2 | 2011-02-11 08:13:14 -0800 | [diff] [blame] | 2200 | if (!priv->cfg->bt_params || (priv->cfg->bt_params && |
| 2201 | !priv->cfg->bt_params->advanced_bt_coexist)) { |
| 2202 | /* |
| 2203 | * default is 2-wire BT coexexistence support |
| 2204 | */ |
Wey-Yi Guy | aeb4a2e | 2010-08-23 07:57:05 -0700 | [diff] [blame] | 2205 | priv->cfg->ops->hcmd->send_bt_config(priv); |
| 2206 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2207 | |
Tomas Winkler | 4a4a9e8 | 2008-05-29 16:34:54 +0800 | [diff] [blame] | 2208 | iwl_reset_run_time_calib(priv); |
| 2209 | |
Wey-Yi Guy | 9e2e742 | 2010-11-12 13:52:37 -0800 | [diff] [blame] | 2210 | set_bit(STATUS_READY, &priv->status); |
| 2211 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2212 | /* Configure the adapter for unassociated operation */ |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2213 | ret = iwlcore_commit_rxon(priv, ctx); |
| 2214 | if (ret) |
| 2215 | return ret; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2216 | |
| 2217 | /* At this point, the NIC is initialized and operational */ |
Emmanuel Grumbach | 47f4a58 | 2008-06-12 09:47:13 +0800 | [diff] [blame] | 2218 | iwl_rf_kill_ct_config(priv); |
Zhu Yi | 5a66926a | 2008-01-14 17:46:18 -0800 | [diff] [blame] | 2219 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2220 | IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2221 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2222 | return iwl_power_update_mode(priv, true); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2223 | } |
| 2224 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 2225 | static void iwl_cancel_deferred_work(struct iwl_priv *priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2226 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2227 | static void __iwl_down(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2228 | { |
Dan Carpenter | 22dd2fd | 2011-03-15 10:03:24 +0300 | [diff] [blame] | 2229 | int exit_pending; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2230 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2231 | IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2232 | |
Stanislaw Gruszka | d745d47 | 2010-09-13 14:46:35 +0200 | [diff] [blame] | 2233 | iwl_scan_cancel_timeout(priv, 200); |
| 2234 | |
| 2235 | exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2236 | |
Stanislaw Gruszka | b62177a | 2010-08-20 15:23:47 +0200 | [diff] [blame] | 2237 | /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set |
| 2238 | * to prevent rearm timer */ |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 2239 | del_timer_sync(&priv->watchdog); |
Stanislaw Gruszka | b62177a | 2010-08-20 15:23:47 +0200 | [diff] [blame] | 2240 | |
Johannes Berg | dcef732 | 2010-08-27 08:55:52 -0700 | [diff] [blame] | 2241 | iwl_clear_ucode_stations(priv, NULL); |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2242 | iwl_dealloc_bcast_stations(priv); |
Johannes Berg | db125c7 | 2010-05-07 01:49:15 -0700 | [diff] [blame] | 2243 | iwl_clear_driver_stations(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2244 | |
Johannes Berg | a117413 | 2010-08-23 07:56:59 -0700 | [diff] [blame] | 2245 | /* reset BT coex data */ |
Wey-Yi Guy | da5dbb9 | 2010-08-23 07:57:13 -0700 | [diff] [blame] | 2246 | priv->bt_status = 0; |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2247 | if (priv->cfg->bt_params) |
| 2248 | priv->bt_traffic_load = |
| 2249 | priv->cfg->bt_params->bt_init_traffic_load; |
| 2250 | else |
| 2251 | priv->bt_traffic_load = 0; |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 2252 | priv->bt_full_concurrent = false; |
| 2253 | priv->bt_ci_compliance = 0; |
Johannes Berg | a117413 | 2010-08-23 07:56:59 -0700 | [diff] [blame] | 2254 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2255 | /* Wipe out the EXIT_PENDING status bit if we are not actually |
| 2256 | * exiting the module */ |
| 2257 | if (!exit_pending) |
| 2258 | clear_bit(STATUS_EXIT_PENDING, &priv->status); |
| 2259 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2260 | if (priv->mac80211_registered) |
| 2261 | ieee80211_stop_queues(priv->hw); |
| 2262 | |
Johannes Berg | 1a10f43 | 2011-04-13 03:14:44 -0700 | [diff] [blame] | 2263 | /* Clear out all status bits but a few that are stable across reset */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2264 | priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) << |
| 2265 | STATUS_RF_KILL_HW | |
Reinette Chatre | 9788864 | 2008-02-06 11:20:38 -0800 | [diff] [blame] | 2266 | test_bit(STATUS_GEO_CONFIGURED, &priv->status) << |
| 2267 | STATUS_GEO_CONFIGURED | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2268 | test_bit(STATUS_FW_ERROR, &priv->status) << |
Mohamed Abbas | 052ec3f | 2008-06-30 17:23:15 +0800 | [diff] [blame] | 2269 | STATUS_FW_ERROR | |
| 2270 | test_bit(STATUS_EXIT_PENDING, &priv->status) << |
| 2271 | STATUS_EXIT_PENDING; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2272 | |
Johannes Berg | bc4f8ad | 2011-04-13 03:14:45 -0700 | [diff] [blame] | 2273 | iwlagn_stop_device(priv); |
Ben Cahill | 4d2ccdb | 2009-10-09 13:20:20 -0700 | [diff] [blame] | 2274 | |
Johannes Berg | 7783454 | 2010-10-04 05:50:36 -0700 | [diff] [blame] | 2275 | dev_kfree_skb(priv->beacon_skb); |
Johannes Berg | 12e934d | 2010-10-04 05:50:06 -0700 | [diff] [blame] | 2276 | priv->beacon_skb = NULL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2277 | } |
| 2278 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2279 | static void iwl_down(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2280 | { |
| 2281 | mutex_lock(&priv->mutex); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2282 | __iwl_down(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2283 | mutex_unlock(&priv->mutex); |
Zhu Yi | b24d22b | 2007-12-19 13:59:52 +0800 | [diff] [blame] | 2284 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 2285 | iwl_cancel_deferred_work(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2286 | } |
| 2287 | |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2288 | #define HW_READY_TIMEOUT (50) |
| 2289 | |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2290 | /* Note: returns poll_bit return value, which is >= 0 if success */ |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2291 | static int iwl_set_hw_ready(struct iwl_priv *priv) |
| 2292 | { |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2293 | int ret; |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2294 | |
| 2295 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, |
| 2296 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); |
| 2297 | |
| 2298 | /* See if we got it */ |
| 2299 | ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, |
| 2300 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, |
| 2301 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, |
| 2302 | HW_READY_TIMEOUT); |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2303 | |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2304 | IWL_DEBUG_INFO(priv, "hardware%s ready\n", ret < 0 ? " not" : ""); |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2305 | return ret; |
| 2306 | } |
| 2307 | |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2308 | /* Note: returns standard 0/-ERROR code */ |
Johannes Berg | 3e14c1f | 2011-04-13 03:14:46 -0700 | [diff] [blame] | 2309 | int iwl_prepare_card_hw(struct iwl_priv *priv) |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2310 | { |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2311 | int ret; |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2312 | |
Frans Pop | 91dd6c2 | 2010-03-24 14:19:58 -0700 | [diff] [blame] | 2313 | IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter\n"); |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2314 | |
Mohamed Abbas | 3354a0f | 2009-06-19 13:52:41 -0700 | [diff] [blame] | 2315 | ret = iwl_set_hw_ready(priv); |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2316 | if (ret >= 0) |
| 2317 | return 0; |
Mohamed Abbas | 3354a0f | 2009-06-19 13:52:41 -0700 | [diff] [blame] | 2318 | |
| 2319 | /* If HW is not ready, prepare the conditions to check again */ |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2320 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, |
| 2321 | CSR_HW_IF_CONFIG_REG_PREPARE); |
| 2322 | |
| 2323 | ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, |
| 2324 | ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, |
| 2325 | CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); |
| 2326 | |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2327 | if (ret < 0) |
| 2328 | return ret; |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2329 | |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 2330 | /* HW should be ready by now, check again. */ |
| 2331 | ret = iwl_set_hw_ready(priv); |
| 2332 | if (ret >= 0) |
| 2333 | return 0; |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 2334 | return ret; |
| 2335 | } |
| 2336 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2337 | #define MAX_HW_RESTARTS 5 |
| 2338 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2339 | static int __iwl_up(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2340 | { |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2341 | struct iwl_rxon_context *ctx; |
Tomas Winkler | 57aab75 | 2008-04-14 21:16:03 -0700 | [diff] [blame] | 2342 | int ret; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2343 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2344 | lockdep_assert_held(&priv->mutex); |
| 2345 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2346 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { |
Winkler, Tomas | 39aadf8 | 2008-12-19 10:37:32 +0800 | [diff] [blame] | 2347 | IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2348 | return -EIO; |
| 2349 | } |
| 2350 | |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2351 | for_each_context(priv, ctx) { |
Johannes Berg | a30e311 | 2010-09-22 18:02:01 +0200 | [diff] [blame] | 2352 | ret = iwlagn_alloc_bcast_station(priv, ctx); |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2353 | if (ret) { |
| 2354 | iwl_dealloc_bcast_stations(priv); |
| 2355 | return ret; |
| 2356 | } |
| 2357 | } |
Johannes Berg | 2c810cc | 2010-04-29 00:53:29 -0700 | [diff] [blame] | 2358 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2359 | ret = iwlagn_run_init_ucode(priv); |
| 2360 | if (ret) { |
| 2361 | IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); |
| 2362 | goto error; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2363 | } |
| 2364 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2365 | ret = iwlagn_load_ucode_wait_alive(priv, |
Johannes Berg | dbf28e21 | 2011-04-16 08:29:24 -0700 | [diff] [blame] | 2366 | &priv->ucode_rt, |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2367 | UCODE_SUBTYPE_REGULAR, |
| 2368 | UCODE_SUBTYPE_REGULAR_NEW); |
| 2369 | if (ret) { |
| 2370 | IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); |
| 2371 | goto error; |
| 2372 | } |
| 2373 | |
| 2374 | ret = iwl_alive_start(priv); |
| 2375 | if (ret) |
| 2376 | goto error; |
| 2377 | return 0; |
| 2378 | |
| 2379 | error: |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2380 | set_bit(STATUS_EXIT_PENDING, &priv->status); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2381 | __iwl_down(priv); |
Mohamed Abbas | 64e72c3e | 2008-06-12 09:47:03 +0800 | [diff] [blame] | 2382 | clear_bit(STATUS_EXIT_PENDING, &priv->status); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2383 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2384 | IWL_ERR(priv, "Unable to initialize device.\n"); |
| 2385 | return ret; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2386 | } |
| 2387 | |
| 2388 | |
| 2389 | /***************************************************************************** |
| 2390 | * |
| 2391 | * Workqueue callbacks |
| 2392 | * |
| 2393 | *****************************************************************************/ |
| 2394 | |
Emmanuel Grumbach | 16e727e | 2008-06-12 09:46:52 +0800 | [diff] [blame] | 2395 | static void iwl_bg_run_time_calib_work(struct work_struct *work) |
| 2396 | { |
| 2397 | struct iwl_priv *priv = container_of(work, struct iwl_priv, |
| 2398 | run_time_calib_work); |
| 2399 | |
| 2400 | mutex_lock(&priv->mutex); |
| 2401 | |
| 2402 | if (test_bit(STATUS_EXIT_PENDING, &priv->status) || |
| 2403 | test_bit(STATUS_SCANNING, &priv->status)) { |
| 2404 | mutex_unlock(&priv->mutex); |
| 2405 | return; |
| 2406 | } |
| 2407 | |
| 2408 | if (priv->start_calib) { |
Johannes Berg | 0da0e5b | 2011-04-08 08:14:56 -0700 | [diff] [blame] | 2409 | iwl_chain_noise_calibration(priv); |
| 2410 | iwl_sensitivity_calibration(priv); |
Emmanuel Grumbach | 16e727e | 2008-06-12 09:46:52 +0800 | [diff] [blame] | 2411 | } |
| 2412 | |
| 2413 | mutex_unlock(&priv->mutex); |
Emmanuel Grumbach | 16e727e | 2008-06-12 09:46:52 +0800 | [diff] [blame] | 2414 | } |
| 2415 | |
Johannes Berg | e43e85c | 2011-04-19 07:45:16 -0700 | [diff] [blame] | 2416 | static void iwlagn_prepare_restart(struct iwl_priv *priv) |
| 2417 | { |
| 2418 | struct iwl_rxon_context *ctx; |
| 2419 | bool bt_full_concurrent; |
| 2420 | u8 bt_ci_compliance; |
| 2421 | u8 bt_load; |
| 2422 | u8 bt_status; |
| 2423 | |
| 2424 | lockdep_assert_held(&priv->mutex); |
| 2425 | |
| 2426 | for_each_context(priv, ctx) |
| 2427 | ctx->vif = NULL; |
| 2428 | priv->is_open = 0; |
| 2429 | |
| 2430 | /* |
| 2431 | * __iwl_down() will clear the BT status variables, |
| 2432 | * which is correct, but when we restart we really |
| 2433 | * want to keep them so restore them afterwards. |
| 2434 | * |
| 2435 | * The restart process will later pick them up and |
| 2436 | * re-configure the hw when we reconfigure the BT |
| 2437 | * command. |
| 2438 | */ |
| 2439 | bt_full_concurrent = priv->bt_full_concurrent; |
| 2440 | bt_ci_compliance = priv->bt_ci_compliance; |
| 2441 | bt_load = priv->bt_traffic_load; |
| 2442 | bt_status = priv->bt_status; |
| 2443 | |
| 2444 | __iwl_down(priv); |
| 2445 | |
| 2446 | priv->bt_full_concurrent = bt_full_concurrent; |
| 2447 | priv->bt_ci_compliance = bt_ci_compliance; |
| 2448 | priv->bt_traffic_load = bt_load; |
| 2449 | priv->bt_status = bt_status; |
| 2450 | } |
| 2451 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2452 | static void iwl_bg_restart(struct work_struct *data) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2453 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 2454 | struct iwl_priv *priv = container_of(data, struct iwl_priv, restart); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2455 | |
| 2456 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 2457 | return; |
| 2458 | |
Johannes Berg | 19cc108 | 2009-05-08 13:44:36 -0700 | [diff] [blame] | 2459 | if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { |
| 2460 | mutex_lock(&priv->mutex); |
Johannes Berg | e43e85c | 2011-04-19 07:45:16 -0700 | [diff] [blame] | 2461 | iwlagn_prepare_restart(priv); |
Johannes Berg | 19cc108 | 2009-05-08 13:44:36 -0700 | [diff] [blame] | 2462 | mutex_unlock(&priv->mutex); |
Johannes Berg | a117413 | 2010-08-23 07:56:59 -0700 | [diff] [blame] | 2463 | iwl_cancel_deferred_work(priv); |
Johannes Berg | 19cc108 | 2009-05-08 13:44:36 -0700 | [diff] [blame] | 2464 | ieee80211_restart_hw(priv->hw); |
| 2465 | } else { |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2466 | WARN_ON(1); |
Johannes Berg | 19cc108 | 2009-05-08 13:44:36 -0700 | [diff] [blame] | 2467 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2468 | } |
| 2469 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2470 | static void iwl_bg_rx_replenish(struct work_struct *data) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2471 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 2472 | struct iwl_priv *priv = |
| 2473 | container_of(data, struct iwl_priv, rx_replenish); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2474 | |
| 2475 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 2476 | return; |
| 2477 | |
| 2478 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | 54b8155 | 2010-03-17 13:34:35 -0700 | [diff] [blame] | 2479 | iwlagn_rx_replenish(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2480 | mutex_unlock(&priv->mutex); |
| 2481 | } |
| 2482 | |
Johannes Berg | 266af4c7 | 2011-03-10 20:13:26 -0800 | [diff] [blame] | 2483 | static int iwl_mac_offchannel_tx(struct ieee80211_hw *hw, struct sk_buff *skb, |
| 2484 | struct ieee80211_channel *chan, |
| 2485 | enum nl80211_channel_type channel_type, |
| 2486 | unsigned int wait) |
| 2487 | { |
| 2488 | struct iwl_priv *priv = hw->priv; |
| 2489 | int ret; |
| 2490 | |
| 2491 | /* Not supported if we don't have PAN */ |
| 2492 | if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN))) { |
| 2493 | ret = -EOPNOTSUPP; |
| 2494 | goto free; |
| 2495 | } |
| 2496 | |
| 2497 | /* Not supported on pre-P2P firmware */ |
| 2498 | if (!(priv->contexts[IWL_RXON_CTX_PAN].interface_modes & |
| 2499 | BIT(NL80211_IFTYPE_P2P_CLIENT))) { |
| 2500 | ret = -EOPNOTSUPP; |
| 2501 | goto free; |
| 2502 | } |
| 2503 | |
| 2504 | mutex_lock(&priv->mutex); |
| 2505 | |
| 2506 | if (!priv->contexts[IWL_RXON_CTX_PAN].is_active) { |
| 2507 | /* |
| 2508 | * If the PAN context is free, use the normal |
| 2509 | * way of doing remain-on-channel offload + TX. |
| 2510 | */ |
| 2511 | ret = 1; |
| 2512 | goto out; |
| 2513 | } |
| 2514 | |
| 2515 | /* TODO: queue up if scanning? */ |
| 2516 | if (test_bit(STATUS_SCANNING, &priv->status) || |
| 2517 | priv->_agn.offchan_tx_skb) { |
| 2518 | ret = -EBUSY; |
| 2519 | goto out; |
| 2520 | } |
| 2521 | |
| 2522 | /* |
| 2523 | * max_scan_ie_len doesn't include the blank SSID or the header, |
| 2524 | * so need to add that again here. |
| 2525 | */ |
| 2526 | if (skb->len > hw->wiphy->max_scan_ie_len + 24 + 2) { |
| 2527 | ret = -ENOBUFS; |
| 2528 | goto out; |
| 2529 | } |
| 2530 | |
| 2531 | priv->_agn.offchan_tx_skb = skb; |
| 2532 | priv->_agn.offchan_tx_timeout = wait; |
| 2533 | priv->_agn.offchan_tx_chan = chan; |
| 2534 | |
| 2535 | ret = iwl_scan_initiate(priv, priv->contexts[IWL_RXON_CTX_PAN].vif, |
| 2536 | IWL_SCAN_OFFCH_TX, chan->band); |
| 2537 | if (ret) |
| 2538 | priv->_agn.offchan_tx_skb = NULL; |
| 2539 | out: |
| 2540 | mutex_unlock(&priv->mutex); |
| 2541 | free: |
| 2542 | if (ret < 0) |
| 2543 | kfree_skb(skb); |
| 2544 | |
| 2545 | return ret; |
| 2546 | } |
| 2547 | |
| 2548 | static int iwl_mac_offchannel_tx_cancel_wait(struct ieee80211_hw *hw) |
| 2549 | { |
| 2550 | struct iwl_priv *priv = hw->priv; |
| 2551 | int ret; |
| 2552 | |
| 2553 | mutex_lock(&priv->mutex); |
| 2554 | |
Dan Carpenter | f8a22a2 | 2011-03-15 10:01:58 +0300 | [diff] [blame] | 2555 | if (!priv->_agn.offchan_tx_skb) { |
| 2556 | ret = -EINVAL; |
| 2557 | goto unlock; |
| 2558 | } |
Johannes Berg | 266af4c7 | 2011-03-10 20:13:26 -0800 | [diff] [blame] | 2559 | |
| 2560 | priv->_agn.offchan_tx_skb = NULL; |
| 2561 | |
| 2562 | ret = iwl_scan_cancel_timeout(priv, 200); |
| 2563 | if (ret) |
| 2564 | ret = -EIO; |
Dan Carpenter | f8a22a2 | 2011-03-15 10:01:58 +0300 | [diff] [blame] | 2565 | unlock: |
Johannes Berg | 266af4c7 | 2011-03-10 20:13:26 -0800 | [diff] [blame] | 2566 | mutex_unlock(&priv->mutex); |
| 2567 | |
| 2568 | return ret; |
| 2569 | } |
| 2570 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2571 | /***************************************************************************** |
| 2572 | * |
| 2573 | * mac80211 entry point functions |
| 2574 | * |
| 2575 | *****************************************************************************/ |
| 2576 | |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2577 | /* |
| 2578 | * Not a mac80211 entry point function, but it fits in with all the |
| 2579 | * other mac80211 functions grouped here. |
| 2580 | */ |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 2581 | static int iwl_mac_setup_register(struct iwl_priv *priv, |
| 2582 | struct iwlagn_ucode_capabilities *capa) |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2583 | { |
| 2584 | int ret; |
| 2585 | struct ieee80211_hw *hw = priv->hw; |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 2586 | struct iwl_rxon_context *ctx; |
| 2587 | |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2588 | hw->rate_control_algorithm = "iwl-agn-rs"; |
| 2589 | |
| 2590 | /* Tell mac80211 our characteristics */ |
| 2591 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2592 | IEEE80211_HW_AMPDU_AGGREGATION | |
Johannes Berg | 2491fa4 | 2010-08-23 10:46:52 +0200 | [diff] [blame] | 2593 | IEEE80211_HW_NEED_DTIM_PERIOD | |
Johannes Berg | 6fb5511 | 2010-11-16 11:55:02 -0800 | [diff] [blame] | 2594 | IEEE80211_HW_SPECTRUM_MGMT | |
| 2595 | IEEE80211_HW_REPORTS_TX_ACK_STATUS; |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2596 | |
Johannes Berg | 9b76883 | 2011-01-19 02:54:18 -0800 | [diff] [blame] | 2597 | hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; |
| 2598 | |
Wey-Yi Guy | 23c0fcc | 2011-04-01 16:29:53 -0700 | [diff] [blame] | 2599 | hw->flags |= IEEE80211_HW_SUPPORTS_PS | |
| 2600 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS; |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2601 | |
Johannes Berg | ba37a3d | 2009-12-10 14:37:27 -0800 | [diff] [blame] | 2602 | if (priv->cfg->sku & IWL_SKU_N) |
| 2603 | hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | |
| 2604 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; |
| 2605 | |
Johannes Berg | 3997ff3 | 2011-04-05 09:42:02 -0700 | [diff] [blame] | 2606 | if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) |
| 2607 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; |
| 2608 | |
Reinette Chatre | 8d9698b | 2009-10-16 14:25:55 -0700 | [diff] [blame] | 2609 | hw->sta_data_size = sizeof(struct iwl_station_priv); |
Johannes Berg | fd1af15 | 2010-04-30 11:30:43 -0700 | [diff] [blame] | 2610 | hw->vif_data_size = sizeof(struct iwl_vif_priv); |
| 2611 | |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 2612 | for_each_context(priv, ctx) { |
| 2613 | hw->wiphy->interface_modes |= ctx->interface_modes; |
| 2614 | hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; |
| 2615 | } |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2616 | |
Johannes Berg | 9b9190d | 2011-01-06 08:07:10 -0800 | [diff] [blame] | 2617 | hw->wiphy->max_remain_on_channel_duration = 1000; |
| 2618 | |
Reinette Chatre | f6c8f15 | 2010-03-12 11:13:26 -0800 | [diff] [blame] | 2619 | hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | |
Johannes Berg | 274102a | 2011-01-18 04:44:03 -0800 | [diff] [blame] | 2620 | WIPHY_FLAG_DISABLE_BEACON_HINTS | |
| 2621 | WIPHY_FLAG_IBSS_RSN; |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2622 | |
| 2623 | /* |
| 2624 | * For now, disable PS by default because it affects |
| 2625 | * RX performance significantly. |
| 2626 | */ |
Johannes Berg | 5be83de | 2009-11-19 00:56:28 +0100 | [diff] [blame] | 2627 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2628 | |
Reinette Chatre | 1382c71 | 2010-02-25 10:02:19 -0800 | [diff] [blame] | 2629 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2630 | /* we create the 802.11 header and a zero-length SSID element */ |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 2631 | hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2632 | |
| 2633 | /* Default value; 4 EDCA QOS priorities */ |
| 2634 | hw->queues = 4; |
| 2635 | |
| 2636 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
| 2637 | |
| 2638 | if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) |
| 2639 | priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 2640 | &priv->bands[IEEE80211_BAND_2GHZ]; |
| 2641 | if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) |
| 2642 | priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 2643 | &priv->bands[IEEE80211_BAND_5GHZ]; |
| 2644 | |
Wey-Yi Guy | 5ed540a | 2011-01-21 15:26:39 -0800 | [diff] [blame] | 2645 | iwl_leds_init(priv); |
| 2646 | |
Reinette Chatre | f0b6e2e | 2009-10-16 14:25:53 -0700 | [diff] [blame] | 2647 | ret = ieee80211_register_hw(priv->hw); |
| 2648 | if (ret) { |
| 2649 | IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); |
| 2650 | return ret; |
| 2651 | } |
| 2652 | priv->mac80211_registered = 1; |
| 2653 | |
| 2654 | return 0; |
| 2655 | } |
| 2656 | |
| 2657 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2658 | static int iwlagn_mac_start(struct ieee80211_hw *hw) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2659 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 2660 | struct iwl_priv *priv = hw->priv; |
Zhu Yi | 5a66926a | 2008-01-14 17:46:18 -0800 | [diff] [blame] | 2661 | int ret; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2662 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2663 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2664 | |
| 2665 | /* we should be verifying the device is ready to be opened */ |
| 2666 | mutex_lock(&priv->mutex); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2667 | ret = __iwl_up(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2668 | mutex_unlock(&priv->mutex); |
Zhu Yi | e655b9f | 2008-01-24 02:19:38 -0800 | [diff] [blame] | 2669 | if (ret) |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 2670 | return ret; |
Zhu Yi | e655b9f | 2008-01-24 02:19:38 -0800 | [diff] [blame] | 2671 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2672 | IWL_DEBUG_INFO(priv, "Start UP work done.\n"); |
Zhu Yi | e655b9f | 2008-01-24 02:19:38 -0800 | [diff] [blame] | 2673 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 2674 | /* Now we should be done, and the READY bit should be set. */ |
| 2675 | if (WARN_ON(!test_bit(STATUS_READY, &priv->status))) |
| 2676 | ret = -EIO; |
Tomas Winkler | 0a078ff | 2008-06-30 17:23:26 +0800 | [diff] [blame] | 2677 | |
Wey-Yi Guy | 5ed540a | 2011-01-21 15:26:39 -0800 | [diff] [blame] | 2678 | iwlagn_led_enable(priv); |
Johannes Berg | e932a60 | 2009-10-02 13:44:03 -0700 | [diff] [blame] | 2679 | |
Tomas Winkler | 0a078ff | 2008-06-30 17:23:26 +0800 | [diff] [blame] | 2680 | priv->is_open = 1; |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2681 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2682 | return 0; |
| 2683 | } |
| 2684 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2685 | static void iwlagn_mac_stop(struct ieee80211_hw *hw) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2686 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 2687 | struct iwl_priv *priv = hw->priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2688 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2689 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
Mohamed Abbas | 948c171 | 2007-10-25 17:15:45 +0800 | [diff] [blame] | 2690 | |
Johannes Berg | 19cc108 | 2009-05-08 13:44:36 -0700 | [diff] [blame] | 2691 | if (!priv->is_open) |
Zhu Yi | e655b9f | 2008-01-24 02:19:38 -0800 | [diff] [blame] | 2692 | return; |
Zhu Yi | e655b9f | 2008-01-24 02:19:38 -0800 | [diff] [blame] | 2693 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2694 | priv->is_open = 0; |
Zhu Yi | 5a66926a | 2008-01-14 17:46:18 -0800 | [diff] [blame] | 2695 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 2696 | iwl_down(priv); |
Zhu Yi | 5a66926a | 2008-01-14 17:46:18 -0800 | [diff] [blame] | 2697 | |
| 2698 | flush_workqueue(priv->workqueue); |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 2699 | |
Stanislaw Gruszka | 554d1d0 | 2010-12-23 12:38:21 +0100 | [diff] [blame] | 2700 | /* User space software may expect getting rfkill changes |
| 2701 | * even if interface is down */ |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 2702 | iwl_write32(priv, CSR_INT, 0xFFFFFFFF); |
Stanislaw Gruszka | 554d1d0 | 2010-12-23 12:38:21 +0100 | [diff] [blame] | 2703 | iwl_enable_rfkill_int(priv); |
Mohamed Abbas | 948c171 | 2007-10-25 17:15:45 +0800 | [diff] [blame] | 2704 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2705 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2706 | } |
| 2707 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2708 | static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2709 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 2710 | struct iwl_priv *priv = hw->priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2711 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2712 | IWL_DEBUG_MACDUMP(priv, "enter\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2713 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2714 | IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 2715 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2716 | |
Wey-Yi Guy | 74bcdb3 | 2010-03-17 13:34:34 -0700 | [diff] [blame] | 2717 | if (iwlagn_tx_skb(priv, skb)) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2718 | dev_kfree_skb_any(skb); |
| 2719 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2720 | IWL_DEBUG_MACDUMP(priv, "leave\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2721 | } |
| 2722 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2723 | static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, |
| 2724 | struct ieee80211_vif *vif, |
| 2725 | struct ieee80211_key_conf *keyconf, |
| 2726 | struct ieee80211_sta *sta, |
| 2727 | u32 iv32, u16 *phase1key) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2728 | { |
Tomas Winkler | 9f58671 | 2008-11-12 13:14:05 -0800 | [diff] [blame] | 2729 | struct iwl_priv *priv = hw->priv; |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2730 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; |
| 2731 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2732 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
Emmanuel Grumbach | ab885f8 | 2008-03-20 15:06:43 +0200 | [diff] [blame] | 2733 | |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2734 | iwl_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, |
Johannes Berg | b3fbdcf | 2010-01-21 11:40:47 +0100 | [diff] [blame] | 2735 | iv32, phase1key); |
Emmanuel Grumbach | ab885f8 | 2008-03-20 15:06:43 +0200 | [diff] [blame] | 2736 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2737 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
Emmanuel Grumbach | ab885f8 | 2008-03-20 15:06:43 +0200 | [diff] [blame] | 2738 | } |
| 2739 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2740 | static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
| 2741 | struct ieee80211_vif *vif, |
| 2742 | struct ieee80211_sta *sta, |
| 2743 | struct ieee80211_key_conf *key) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2744 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 2745 | struct iwl_priv *priv = hw->priv; |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2746 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; |
Johannes Berg | c10afb6 | 2010-08-23 10:46:43 +0200 | [diff] [blame] | 2747 | struct iwl_rxon_context *ctx = vif_priv->ctx; |
Winkler, Tomas | 4298679 | 2009-01-19 15:30:22 -0800 | [diff] [blame] | 2748 | int ret; |
| 2749 | u8 sta_id; |
| 2750 | bool is_default_wep_key = false; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2751 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2752 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2753 | |
Don Fry | 9d143e9 | 2011-04-20 15:23:57 -0700 | [diff] [blame] | 2754 | if (iwlagn_mod_params.sw_crypto) { |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2755 | IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2756 | return -EOPNOTSUPP; |
| 2757 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2758 | |
Johannes Berg | 274102a | 2011-01-18 04:44:03 -0800 | [diff] [blame] | 2759 | /* |
| 2760 | * To support IBSS RSN, don't program group keys in IBSS, the |
| 2761 | * hardware will then not attempt to decrypt the frames. |
| 2762 | */ |
| 2763 | if (vif->type == NL80211_IFTYPE_ADHOC && |
| 2764 | !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) |
| 2765 | return -EOPNOTSUPP; |
| 2766 | |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2767 | sta_id = iwl_sta_id_or_broadcast(priv, vif_priv->ctx, sta); |
Johannes Berg | 0af8bca | 2010-04-30 14:08:00 -0700 | [diff] [blame] | 2768 | if (sta_id == IWL_INVALID_STATION) |
| 2769 | return -EINVAL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2770 | |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2771 | mutex_lock(&priv->mutex); |
Tomas Winkler | 2a421b9 | 2008-06-12 09:47:10 +0800 | [diff] [blame] | 2772 | iwl_scan_cancel_timeout(priv, 100); |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2773 | |
Johannes Berg | a90178fa | 2010-03-30 02:44:16 -0700 | [diff] [blame] | 2774 | /* |
| 2775 | * If we are getting WEP group key and we didn't receive any key mapping |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2776 | * so far, we are in legacy wep mode (group key only), otherwise we are |
| 2777 | * in 1X mode. |
Johannes Berg | a90178fa | 2010-03-30 02:44:16 -0700 | [diff] [blame] | 2778 | * In legacy wep mode, we use another host command to the uCode. |
| 2779 | */ |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 2780 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || |
| 2781 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && |
Johannes Berg | 54c8067 | 2010-08-18 09:35:21 -0700 | [diff] [blame] | 2782 | !sta) { |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2783 | if (cmd == SET_KEY) |
Johannes Berg | c10afb6 | 2010-08-23 10:46:43 +0200 | [diff] [blame] | 2784 | is_default_wep_key = !ctx->key_mapping_keys; |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2785 | else |
Emmanuel Grumbach | ccc038a | 2008-05-15 13:54:09 +0800 | [diff] [blame] | 2786 | is_default_wep_key = |
| 2787 | (key->hw_key_idx == HW_KEY_DEFAULT); |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2788 | } |
mabbas | 052c4b9 | 2007-10-25 17:15:43 +0800 | [diff] [blame] | 2789 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2790 | switch (cmd) { |
Emmanuel Grumbach | deb09c4 | 2008-03-19 16:41:41 -0700 | [diff] [blame] | 2791 | case SET_KEY: |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2792 | if (is_default_wep_key) |
Johannes Berg | 2995baf | 2010-08-23 10:46:42 +0200 | [diff] [blame] | 2793 | ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); |
Emmanuel Grumbach | deb09c4 | 2008-03-19 16:41:41 -0700 | [diff] [blame] | 2794 | else |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2795 | ret = iwl_set_dynamic_key(priv, vif_priv->ctx, |
| 2796 | key, sta_id); |
Emmanuel Grumbach | deb09c4 | 2008-03-19 16:41:41 -0700 | [diff] [blame] | 2797 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2798 | IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2799 | break; |
| 2800 | case DISABLE_KEY: |
Emmanuel Grumbach | 6974e36 | 2008-04-14 21:16:06 -0700 | [diff] [blame] | 2801 | if (is_default_wep_key) |
Johannes Berg | c10afb6 | 2010-08-23 10:46:43 +0200 | [diff] [blame] | 2802 | ret = iwl_remove_default_wep_key(priv, ctx, key); |
Emmanuel Grumbach | deb09c4 | 2008-03-19 16:41:41 -0700 | [diff] [blame] | 2803 | else |
Johannes Berg | c10afb6 | 2010-08-23 10:46:43 +0200 | [diff] [blame] | 2804 | ret = iwl_remove_dynamic_key(priv, ctx, key, sta_id); |
Emmanuel Grumbach | deb09c4 | 2008-03-19 16:41:41 -0700 | [diff] [blame] | 2805 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2806 | IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2807 | break; |
| 2808 | default: |
Emmanuel Grumbach | deb09c4 | 2008-03-19 16:41:41 -0700 | [diff] [blame] | 2809 | ret = -EINVAL; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2810 | } |
| 2811 | |
Johannes Berg | 72e15d7 | 2010-02-19 11:42:32 -0800 | [diff] [blame] | 2812 | mutex_unlock(&priv->mutex); |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2813 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2814 | |
Emmanuel Grumbach | deb09c4 | 2008-03-19 16:41:41 -0700 | [diff] [blame] | 2815 | return ret; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 2816 | } |
| 2817 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2818 | static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, |
| 2819 | struct ieee80211_vif *vif, |
| 2820 | enum ieee80211_ampdu_mlme_action action, |
| 2821 | struct ieee80211_sta *sta, u16 tid, u16 *ssn, |
| 2822 | u8 buf_size) |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2823 | { |
| 2824 | struct iwl_priv *priv = hw->priv; |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2825 | int ret = -EINVAL; |
Johannes Berg | 7b09068 | 2011-01-19 02:53:54 -0800 | [diff] [blame] | 2826 | struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2827 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2828 | IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 2829 | sta->addr, tid); |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2830 | |
| 2831 | if (!(priv->cfg->sku & IWL_SKU_N)) |
| 2832 | return -EACCES; |
| 2833 | |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2834 | mutex_lock(&priv->mutex); |
| 2835 | |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2836 | switch (action) { |
| 2837 | case IEEE80211_AMPDU_RX_START: |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2838 | IWL_DEBUG_HT(priv, "start Rx\n"); |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2839 | ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); |
| 2840 | break; |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2841 | case IEEE80211_AMPDU_RX_STOP: |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2842 | IWL_DEBUG_HT(priv, "stop Rx\n"); |
Johannes Berg | 619753f | 2010-04-30 11:30:46 -0700 | [diff] [blame] | 2843 | ret = iwl_sta_rx_agg_stop(priv, sta, tid); |
Wey-Yi Guy | 5c2207c | 2009-03-17 21:51:43 -0700 | [diff] [blame] | 2844 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2845 | ret = 0; |
| 2846 | break; |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2847 | case IEEE80211_AMPDU_TX_START: |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2848 | IWL_DEBUG_HT(priv, "start Tx\n"); |
Johannes Berg | 619753f | 2010-04-30 11:30:46 -0700 | [diff] [blame] | 2849 | ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); |
Wey-Yi Guy | d5a0ffa | 2010-03-04 13:38:59 -0800 | [diff] [blame] | 2850 | if (ret == 0) { |
| 2851 | priv->_agn.agg_tids_count++; |
| 2852 | IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n", |
| 2853 | priv->_agn.agg_tids_count); |
| 2854 | } |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2855 | break; |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2856 | case IEEE80211_AMPDU_TX_STOP: |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 2857 | IWL_DEBUG_HT(priv, "stop Tx\n"); |
Johannes Berg | 619753f | 2010-04-30 11:30:46 -0700 | [diff] [blame] | 2858 | ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); |
Wey-Yi Guy | d5a0ffa | 2010-03-04 13:38:59 -0800 | [diff] [blame] | 2859 | if ((ret == 0) && (priv->_agn.agg_tids_count > 0)) { |
| 2860 | priv->_agn.agg_tids_count--; |
| 2861 | IWL_DEBUG_HT(priv, "priv->_agn.agg_tids_count = %u\n", |
| 2862 | priv->_agn.agg_tids_count); |
| 2863 | } |
Wey-Yi Guy | 5c2207c | 2009-03-17 21:51:43 -0700 | [diff] [blame] | 2864 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2865 | ret = 0; |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2866 | if (priv->cfg->ht_params && |
| 2867 | priv->cfg->ht_params->use_rts_for_aggregation) { |
Johannes Berg | 94597ab | 2010-08-09 10:57:02 -0700 | [diff] [blame] | 2868 | struct iwl_station_priv *sta_priv = |
| 2869 | (void *) sta->drv_priv; |
| 2870 | /* |
| 2871 | * switch off RTS/CTS if it was previously enabled |
| 2872 | */ |
| 2873 | |
| 2874 | sta_priv->lq_sta.lq.general_params.flags &= |
| 2875 | ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 2876 | iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), |
| 2877 | &sta_priv->lq_sta.lq, CMD_ASYNC, false); |
Johannes Berg | 94597ab | 2010-08-09 10:57:02 -0700 | [diff] [blame] | 2878 | } |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2879 | break; |
Wey-Yi Guy | f052797 | 2010-01-08 10:04:41 -0800 | [diff] [blame] | 2880 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
Johannes Berg | c8823ec | 2011-03-15 11:33:03 -0700 | [diff] [blame] | 2881 | buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); |
| 2882 | |
| 2883 | iwlagn_txq_agg_queue_setup(priv, sta, tid, buf_size); |
| 2884 | |
Johannes Berg | 7b09068 | 2011-01-19 02:53:54 -0800 | [diff] [blame] | 2885 | /* |
| 2886 | * If the limit is 0, then it wasn't initialised yet, |
| 2887 | * use the default. We can do that since we take the |
| 2888 | * minimum below, and we don't want to go above our |
| 2889 | * default due to hardware restrictions. |
| 2890 | */ |
| 2891 | if (sta_priv->max_agg_bufsize == 0) |
| 2892 | sta_priv->max_agg_bufsize = |
| 2893 | LINK_QUAL_AGG_FRAME_LIMIT_DEF; |
| 2894 | |
| 2895 | /* |
| 2896 | * Even though in theory the peer could have different |
| 2897 | * aggregation reorder buffer sizes for different sessions, |
| 2898 | * our ucode doesn't allow for that and has a global limit |
| 2899 | * for each station. Therefore, use the minimum of all the |
| 2900 | * aggregation sessions and our default value. |
| 2901 | */ |
| 2902 | sta_priv->max_agg_bufsize = |
| 2903 | min(sta_priv->max_agg_bufsize, buf_size); |
| 2904 | |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 2905 | if (priv->cfg->ht_params && |
| 2906 | priv->cfg->ht_params->use_rts_for_aggregation) { |
Wey-Yi Guy | cfecc6b | 2010-06-18 11:33:15 -0700 | [diff] [blame] | 2907 | /* |
| 2908 | * switch to RTS/CTS if it is the prefer protection |
| 2909 | * method for HT traffic |
| 2910 | */ |
Johannes Berg | 94597ab | 2010-08-09 10:57:02 -0700 | [diff] [blame] | 2911 | |
| 2912 | sta_priv->lq_sta.lq.general_params.flags |= |
| 2913 | LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; |
Wey-Yi Guy | cfecc6b | 2010-06-18 11:33:15 -0700 | [diff] [blame] | 2914 | } |
Johannes Berg | 7b09068 | 2011-01-19 02:53:54 -0800 | [diff] [blame] | 2915 | |
| 2916 | sta_priv->lq_sta.lq.agg_params.agg_frame_cnt_limit = |
| 2917 | sta_priv->max_agg_bufsize; |
| 2918 | |
| 2919 | iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), |
| 2920 | &sta_priv->lq_sta.lq, CMD_ASYNC, false); |
Wey-Yi Guy | cfecc6b | 2010-06-18 11:33:15 -0700 | [diff] [blame] | 2921 | ret = 0; |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2922 | break; |
| 2923 | } |
Johannes Berg | 4620fef | 2010-06-16 03:30:27 -0700 | [diff] [blame] | 2924 | mutex_unlock(&priv->mutex); |
| 2925 | |
| 2926 | return ret; |
Tomas Winkler | d783b06 | 2008-07-18 13:53:02 +0800 | [diff] [blame] | 2927 | } |
Tomas Winkler | 9f58671 | 2008-11-12 13:14:05 -0800 | [diff] [blame] | 2928 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2929 | static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, |
| 2930 | struct ieee80211_vif *vif, |
| 2931 | struct ieee80211_sta *sta) |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2932 | { |
| 2933 | struct iwl_priv *priv = hw->priv; |
| 2934 | struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2935 | struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; |
Johannes Berg | eafdfbd3 | 2010-04-29 04:43:04 -0700 | [diff] [blame] | 2936 | bool is_ap = vif->type == NL80211_IFTYPE_STATION; |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2937 | int ret; |
| 2938 | u8 sta_id; |
| 2939 | |
| 2940 | IWL_DEBUG_INFO(priv, "received request to add station %pM\n", |
| 2941 | sta->addr); |
Reinette Chatre | da5ae1c | 2010-05-28 09:28:39 -0700 | [diff] [blame] | 2942 | mutex_lock(&priv->mutex); |
| 2943 | IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", |
| 2944 | sta->addr); |
| 2945 | sta_priv->common.sta_id = IWL_INVALID_STATION; |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2946 | |
| 2947 | atomic_set(&sta_priv->pending_frames, 0); |
| 2948 | if (vif->type == NL80211_IFTYPE_AP) |
| 2949 | sta_priv->client = true; |
| 2950 | |
Johannes Berg | a194e32 | 2010-08-27 08:53:46 -0700 | [diff] [blame] | 2951 | ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr, |
Johannes Berg | 238d781 | 2010-08-23 10:46:45 +0200 | [diff] [blame] | 2952 | is_ap, sta, &sta_id); |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2953 | if (ret) { |
| 2954 | IWL_ERR(priv, "Unable to add station %pM (%d)\n", |
| 2955 | sta->addr, ret); |
| 2956 | /* Should we return success if return code is EEXIST ? */ |
Reinette Chatre | da5ae1c | 2010-05-28 09:28:39 -0700 | [diff] [blame] | 2957 | mutex_unlock(&priv->mutex); |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2958 | return ret; |
| 2959 | } |
| 2960 | |
Johannes Berg | fd1af15 | 2010-04-30 11:30:43 -0700 | [diff] [blame] | 2961 | sta_priv->common.sta_id = sta_id; |
| 2962 | |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2963 | /* Initialize rate scaling */ |
Frans Pop | 91dd6c2 | 2010-03-24 14:19:58 -0700 | [diff] [blame] | 2964 | IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2965 | sta->addr); |
| 2966 | iwl_rs_rate_init(priv, sta, sta_id); |
Reinette Chatre | da5ae1c | 2010-05-28 09:28:39 -0700 | [diff] [blame] | 2967 | mutex_unlock(&priv->mutex); |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2968 | |
Johannes Berg | fd1af15 | 2010-04-30 11:30:43 -0700 | [diff] [blame] | 2969 | return 0; |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 2970 | } |
| 2971 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 2972 | static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, |
| 2973 | struct ieee80211_channel_switch *ch_switch) |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 2974 | { |
| 2975 | struct iwl_priv *priv = hw->priv; |
| 2976 | const struct iwl_channel_info *ch_info; |
| 2977 | struct ieee80211_conf *conf = &hw->conf; |
Shanyu Zhao | aa2dc6b | 2010-07-28 13:40:39 -0700 | [diff] [blame] | 2978 | struct ieee80211_channel *channel = ch_switch->channel; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 2979 | struct iwl_ht_config *ht_conf = &priv->current_ht_config; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 2980 | /* |
| 2981 | * MULTI-FIXME |
| 2982 | * When we add support for multiple interfaces, we need to |
| 2983 | * revisit this. The channel switch command in the device |
| 2984 | * only affects the BSS context, but what does that really |
| 2985 | * mean? And what if we get a CSA on the second interface? |
| 2986 | * This needs a lot of work. |
| 2987 | */ |
| 2988 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 2989 | u16 ch; |
| 2990 | unsigned long flags = 0; |
| 2991 | |
| 2992 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
| 2993 | |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 2994 | mutex_lock(&priv->mutex); |
| 2995 | |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 2996 | if (iwl_is_rfkill(priv)) |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 2997 | goto out; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 2998 | |
| 2999 | if (test_bit(STATUS_EXIT_PENDING, &priv->status) || |
| 3000 | test_bit(STATUS_SCANNING, &priv->status)) |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 3001 | goto out; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3002 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3003 | if (!iwl_is_associated_ctx(ctx)) |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 3004 | goto out; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3005 | |
| 3006 | /* channel switch in progress */ |
| 3007 | if (priv->switch_rxon.switch_in_progress == true) |
Stanislaw Gruszka | dc1a406 | 2011-03-31 17:36:27 +0200 | [diff] [blame] | 3008 | goto out; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3009 | |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3010 | if (priv->cfg->ops->lib->set_channel_switch) { |
| 3011 | |
Shanyu Zhao | aa2dc6b | 2010-07-28 13:40:39 -0700 | [diff] [blame] | 3012 | ch = channel->hw_value; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3013 | if (le16_to_cpu(ctx->active.channel) != ch) { |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3014 | ch_info = iwl_get_channel_info(priv, |
Shanyu Zhao | aa2dc6b | 2010-07-28 13:40:39 -0700 | [diff] [blame] | 3015 | channel->band, |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3016 | ch); |
| 3017 | if (!is_channel_valid(ch_info)) { |
| 3018 | IWL_DEBUG_MAC80211(priv, "invalid channel\n"); |
| 3019 | goto out; |
| 3020 | } |
| 3021 | spin_lock_irqsave(&priv->lock, flags); |
| 3022 | |
| 3023 | priv->current_ht_config.smps = conf->smps_mode; |
| 3024 | |
| 3025 | /* Configure HT40 channels */ |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3026 | ctx->ht.enabled = conf_is_ht(conf); |
| 3027 | if (ctx->ht.enabled) { |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3028 | if (conf_is_ht40_minus(conf)) { |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3029 | ctx->ht.extension_chan_offset = |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3030 | IEEE80211_HT_PARAM_CHA_SEC_BELOW; |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3031 | ctx->ht.is_40mhz = true; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3032 | } else if (conf_is_ht40_plus(conf)) { |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3033 | ctx->ht.extension_chan_offset = |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3034 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE; |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3035 | ctx->ht.is_40mhz = true; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3036 | } else { |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3037 | ctx->ht.extension_chan_offset = |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3038 | IEEE80211_HT_PARAM_CHA_SEC_NONE; |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3039 | ctx->ht.is_40mhz = false; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3040 | } |
| 3041 | } else |
Johannes Berg | 7e6a588 | 2010-08-23 10:46:46 +0200 | [diff] [blame] | 3042 | ctx->ht.is_40mhz = false; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3043 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3044 | if ((le16_to_cpu(ctx->staging.channel) != ch)) |
| 3045 | ctx->staging.flags = 0; |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3046 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3047 | iwl_set_rxon_channel(priv, channel, ctx); |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3048 | iwl_set_rxon_ht(priv, ht_conf); |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3049 | iwl_set_flags_for_band(priv, ctx, channel->band, |
Johannes Berg | 8bd413e | 2010-08-23 10:46:40 +0200 | [diff] [blame] | 3050 | ctx->vif); |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3051 | spin_unlock_irqrestore(&priv->lock, flags); |
| 3052 | |
| 3053 | iwl_set_rate(priv); |
| 3054 | /* |
| 3055 | * at this point, staging_rxon has the |
| 3056 | * configuration for channel switch |
| 3057 | */ |
| 3058 | if (priv->cfg->ops->lib->set_channel_switch(priv, |
| 3059 | ch_switch)) |
| 3060 | priv->switch_rxon.switch_in_progress = false; |
| 3061 | } |
| 3062 | } |
| 3063 | out: |
| 3064 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3065 | if (!priv->switch_rxon.switch_in_progress) |
Johannes Berg | 8bd413e | 2010-08-23 10:46:40 +0200 | [diff] [blame] | 3066 | ieee80211_chswitch_done(ctx->vif, false); |
Wey-Yi Guy | 79d0732 | 2010-05-06 08:54:11 -0700 | [diff] [blame] | 3067 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
| 3068 | } |
| 3069 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 3070 | static void iwlagn_configure_filter(struct ieee80211_hw *hw, |
| 3071 | unsigned int changed_flags, |
| 3072 | unsigned int *total_flags, |
| 3073 | u64 multicast) |
Johannes Berg | 8b8ab9d | 2010-08-17 11:24:01 +0200 | [diff] [blame] | 3074 | { |
| 3075 | struct iwl_priv *priv = hw->priv; |
| 3076 | __le32 filter_or = 0, filter_nand = 0; |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3077 | struct iwl_rxon_context *ctx; |
Johannes Berg | 8b8ab9d | 2010-08-17 11:24:01 +0200 | [diff] [blame] | 3078 | |
| 3079 | #define CHK(test, flag) do { \ |
| 3080 | if (*total_flags & (test)) \ |
| 3081 | filter_or |= (flag); \ |
| 3082 | else \ |
| 3083 | filter_nand |= (flag); \ |
| 3084 | } while (0) |
| 3085 | |
| 3086 | IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", |
| 3087 | changed_flags, *total_flags); |
| 3088 | |
| 3089 | CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); |
Johannes Berg | bdb84fe | 2010-12-15 06:07:56 -0800 | [diff] [blame] | 3090 | /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ |
| 3091 | CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); |
Johannes Berg | 8b8ab9d | 2010-08-17 11:24:01 +0200 | [diff] [blame] | 3092 | CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); |
| 3093 | |
| 3094 | #undef CHK |
| 3095 | |
| 3096 | mutex_lock(&priv->mutex); |
| 3097 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3098 | for_each_context(priv, ctx) { |
| 3099 | ctx->staging.filter_flags &= ~filter_nand; |
| 3100 | ctx->staging.filter_flags |= filter_or; |
Stanislaw Gruszka | 749ff4ef | 2010-10-22 17:04:27 +0200 | [diff] [blame] | 3101 | |
| 3102 | /* |
| 3103 | * Not committing directly because hardware can perform a scan, |
| 3104 | * but we'll eventually commit the filter flags change anyway. |
| 3105 | */ |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3106 | } |
Johannes Berg | 8b8ab9d | 2010-08-17 11:24:01 +0200 | [diff] [blame] | 3107 | |
| 3108 | mutex_unlock(&priv->mutex); |
| 3109 | |
| 3110 | /* |
| 3111 | * Receiving all multicast frames is always enabled by the |
| 3112 | * default flags setup in iwl_connection_init_rx_config() |
| 3113 | * since we currently do not support programming multicast |
| 3114 | * filters into the device. |
| 3115 | */ |
| 3116 | *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | |
| 3117 | FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; |
| 3118 | } |
| 3119 | |
Johannes Berg | 2dedbf5 | 2011-04-05 09:41:50 -0700 | [diff] [blame] | 3120 | static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) |
Wey-Yi Guy | 716c74b | 2010-06-24 13:22:36 -0700 | [diff] [blame] | 3121 | { |
| 3122 | struct iwl_priv *priv = hw->priv; |
| 3123 | |
| 3124 | mutex_lock(&priv->mutex); |
| 3125 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
| 3126 | |
| 3127 | /* do not support "flush" */ |
| 3128 | if (!priv->cfg->ops->lib->txfifo_flush) |
| 3129 | goto done; |
| 3130 | |
| 3131 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { |
| 3132 | IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); |
| 3133 | goto done; |
| 3134 | } |
| 3135 | if (iwl_is_rfkill(priv)) { |
| 3136 | IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); |
| 3137 | goto done; |
| 3138 | } |
| 3139 | |
| 3140 | /* |
| 3141 | * mac80211 will not push any more frames for transmit |
| 3142 | * until the flush is completed |
| 3143 | */ |
| 3144 | if (drop) { |
| 3145 | IWL_DEBUG_MAC80211(priv, "send flush command\n"); |
| 3146 | if (priv->cfg->ops->lib->txfifo_flush(priv, IWL_DROP_ALL)) { |
| 3147 | IWL_ERR(priv, "flush request fail\n"); |
| 3148 | goto done; |
| 3149 | } |
| 3150 | } |
| 3151 | IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); |
| 3152 | iwlagn_wait_tx_queue_empty(priv); |
| 3153 | done: |
| 3154 | mutex_unlock(&priv->mutex); |
| 3155 | IWL_DEBUG_MAC80211(priv, "leave\n"); |
| 3156 | } |
| 3157 | |
Johannes Berg | 9b9190d | 2011-01-06 08:07:10 -0800 | [diff] [blame] | 3158 | static void iwlagn_disable_roc(struct iwl_priv *priv) |
| 3159 | { |
| 3160 | struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; |
| 3161 | struct ieee80211_channel *chan = ACCESS_ONCE(priv->hw->conf.channel); |
| 3162 | |
| 3163 | lockdep_assert_held(&priv->mutex); |
| 3164 | |
| 3165 | if (!ctx->is_active) |
| 3166 | return; |
| 3167 | |
| 3168 | ctx->staging.dev_type = RXON_DEV_TYPE_2STA; |
| 3169 | ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
| 3170 | iwl_set_rxon_channel(priv, chan, ctx); |
| 3171 | iwl_set_flags_for_band(priv, ctx, chan->band, NULL); |
| 3172 | |
| 3173 | priv->_agn.hw_roc_channel = NULL; |
| 3174 | |
Wey-Yi Guy | 80b38ff | 2011-02-04 10:46:41 -0800 | [diff] [blame] | 3175 | iwlcore_commit_rxon(priv, ctx); |
Johannes Berg | 9b9190d | 2011-01-06 08:07:10 -0800 | [diff] [blame] | 3176 | |
| 3177 | ctx->is_active = false; |
| 3178 | } |
| 3179 | |
| 3180 | static void iwlagn_bg_roc_done(struct work_struct *work) |
| 3181 | { |
| 3182 | struct iwl_priv *priv = container_of(work, struct iwl_priv, |
| 3183 | _agn.hw_roc_work.work); |
| 3184 | |
| 3185 | mutex_lock(&priv->mutex); |
| 3186 | ieee80211_remain_on_channel_expired(priv->hw); |
| 3187 | iwlagn_disable_roc(priv); |
| 3188 | mutex_unlock(&priv->mutex); |
| 3189 | } |
| 3190 | |
| 3191 | static int iwl_mac_remain_on_channel(struct ieee80211_hw *hw, |
| 3192 | struct ieee80211_channel *channel, |
| 3193 | enum nl80211_channel_type channel_type, |
| 3194 | int duration) |
| 3195 | { |
| 3196 | struct iwl_priv *priv = hw->priv; |
| 3197 | int err = 0; |
| 3198 | |
| 3199 | if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN))) |
| 3200 | return -EOPNOTSUPP; |
| 3201 | |
| 3202 | if (!(priv->contexts[IWL_RXON_CTX_PAN].interface_modes & |
| 3203 | BIT(NL80211_IFTYPE_P2P_CLIENT))) |
| 3204 | return -EOPNOTSUPP; |
| 3205 | |
| 3206 | mutex_lock(&priv->mutex); |
| 3207 | |
| 3208 | if (priv->contexts[IWL_RXON_CTX_PAN].is_active || |
| 3209 | test_bit(STATUS_SCAN_HW, &priv->status)) { |
| 3210 | err = -EBUSY; |
| 3211 | goto out; |
| 3212 | } |
| 3213 | |
| 3214 | priv->contexts[IWL_RXON_CTX_PAN].is_active = true; |
| 3215 | priv->_agn.hw_roc_channel = channel; |
| 3216 | priv->_agn.hw_roc_chantype = channel_type; |
| 3217 | priv->_agn.hw_roc_duration = DIV_ROUND_UP(duration * 1000, 1024); |
Wey-Yi Guy | 80b38ff | 2011-02-04 10:46:41 -0800 | [diff] [blame] | 3218 | iwlcore_commit_rxon(priv, &priv->contexts[IWL_RXON_CTX_PAN]); |
Johannes Berg | 9b9190d | 2011-01-06 08:07:10 -0800 | [diff] [blame] | 3219 | queue_delayed_work(priv->workqueue, &priv->_agn.hw_roc_work, |
| 3220 | msecs_to_jiffies(duration + 20)); |
| 3221 | |
Johannes Berg | 9407391 | 2011-01-06 08:07:11 -0800 | [diff] [blame] | 3222 | msleep(IWL_MIN_SLOT_TIME); /* TU is almost ms */ |
Johannes Berg | 9b9190d | 2011-01-06 08:07:10 -0800 | [diff] [blame] | 3223 | ieee80211_ready_on_channel(priv->hw); |
| 3224 | |
| 3225 | out: |
| 3226 | mutex_unlock(&priv->mutex); |
| 3227 | |
| 3228 | return err; |
| 3229 | } |
| 3230 | |
| 3231 | static int iwl_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) |
| 3232 | { |
| 3233 | struct iwl_priv *priv = hw->priv; |
| 3234 | |
| 3235 | if (!(priv->valid_contexts & BIT(IWL_RXON_CTX_PAN))) |
| 3236 | return -EOPNOTSUPP; |
| 3237 | |
| 3238 | cancel_delayed_work_sync(&priv->_agn.hw_roc_work); |
| 3239 | |
| 3240 | mutex_lock(&priv->mutex); |
| 3241 | iwlagn_disable_roc(priv); |
| 3242 | mutex_unlock(&priv->mutex); |
| 3243 | |
| 3244 | return 0; |
| 3245 | } |
| 3246 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3247 | /***************************************************************************** |
| 3248 | * |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3249 | * driver setup and teardown |
| 3250 | * |
| 3251 | *****************************************************************************/ |
| 3252 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 3253 | static void iwl_setup_deferred_work(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3254 | { |
Reinette Chatre | d21050c | 2009-02-13 11:51:18 -0800 | [diff] [blame] | 3255 | priv->workqueue = create_singlethread_workqueue(DRV_NAME); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3256 | |
| 3257 | init_waitqueue_head(&priv->wait_command_queue); |
| 3258 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3259 | INIT_WORK(&priv->restart, iwl_bg_restart); |
| 3260 | INIT_WORK(&priv->rx_replenish, iwl_bg_rx_replenish); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3261 | INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update); |
Emmanuel Grumbach | 16e727e | 2008-06-12 09:46:52 +0800 | [diff] [blame] | 3262 | INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); |
Wey-Yi Guy | 6555063 | 2010-06-24 13:18:35 -0700 | [diff] [blame] | 3263 | INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush); |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 3264 | INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency); |
Wey-Yi Guy | fbba941 | 2010-08-23 07:57:10 -0700 | [diff] [blame] | 3265 | INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config); |
Johannes Berg | 9b9190d | 2011-01-06 08:07:10 -0800 | [diff] [blame] | 3266 | INIT_DELAYED_WORK(&priv->_agn.hw_roc_work, iwlagn_bg_roc_done); |
Tomas Winkler | 2a421b9 | 2008-06-12 09:47:10 +0800 | [diff] [blame] | 3267 | |
Tomas Winkler | 2a421b9 | 2008-06-12 09:47:10 +0800 | [diff] [blame] | 3268 | iwl_setup_scan_deferred_work(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3269 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 3270 | if (priv->cfg->ops->lib->setup_deferred_work) |
| 3271 | priv->cfg->ops->lib->setup_deferred_work(priv); |
| 3272 | |
| 3273 | init_timer(&priv->statistics_periodic); |
| 3274 | priv->statistics_periodic.data = (unsigned long)priv; |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3275 | priv->statistics_periodic.function = iwl_bg_statistics_periodic; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3276 | |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 3277 | init_timer(&priv->ucode_trace); |
| 3278 | priv->ucode_trace.data = (unsigned long)priv; |
| 3279 | priv->ucode_trace.function = iwl_bg_ucode_trace; |
| 3280 | |
Stanislaw Gruszka | 22de94d | 2010-12-03 15:41:48 +0100 | [diff] [blame] | 3281 | init_timer(&priv->watchdog); |
| 3282 | priv->watchdog.data = (unsigned long)priv; |
| 3283 | priv->watchdog.function = iwl_bg_watchdog; |
Wey-Yi Guy | b74e31a | 2010-03-01 17:23:50 -0800 | [diff] [blame] | 3284 | |
Wey-Yi Guy | d6b8061 | 2011-03-21 16:53:38 -0700 | [diff] [blame] | 3285 | tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) |
| 3286 | iwl_irq_tasklet, (unsigned long)priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3287 | } |
| 3288 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 3289 | static void iwl_cancel_deferred_work(struct iwl_priv *priv) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3290 | { |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 3291 | if (priv->cfg->ops->lib->cancel_deferred_work) |
| 3292 | priv->cfg->ops->lib->cancel_deferred_work(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3293 | |
Wey-Yi Guy | 815e629 | 2010-06-03 10:14:01 -0700 | [diff] [blame] | 3294 | cancel_work_sync(&priv->run_time_calib_work); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3295 | cancel_work_sync(&priv->beacon_update); |
Stanislaw Gruszka | e7e16b9 | 2010-09-13 14:46:41 +0200 | [diff] [blame] | 3296 | |
| 3297 | iwl_cancel_scan_deferred_work(priv); |
| 3298 | |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 3299 | cancel_work_sync(&priv->bt_full_concurrency); |
Wey-Yi Guy | fbba941 | 2010-08-23 07:57:10 -0700 | [diff] [blame] | 3300 | cancel_work_sync(&priv->bt_runtime_config); |
Stanislaw Gruszka | e7e16b9 | 2010-09-13 14:46:41 +0200 | [diff] [blame] | 3301 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 3302 | del_timer_sync(&priv->statistics_periodic); |
Wey-Yi Guy | a9e1cb6 | 2009-12-10 14:37:26 -0800 | [diff] [blame] | 3303 | del_timer_sync(&priv->ucode_trace); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3304 | } |
| 3305 | |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3306 | static void iwl_init_hw_rates(struct iwl_priv *priv, |
| 3307 | struct ieee80211_rate *rates) |
| 3308 | { |
| 3309 | int i; |
| 3310 | |
| 3311 | for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) { |
| 3312 | rates[i].bitrate = iwl_rates[i].ieee * 5; |
| 3313 | rates[i].hw_value = i; /* Rate scaling will work on indexes */ |
| 3314 | rates[i].hw_value_short = i; |
| 3315 | rates[i].flags = 0; |
| 3316 | if ((i >= IWL_FIRST_CCK_RATE) && (i <= IWL_LAST_CCK_RATE)) { |
| 3317 | /* |
| 3318 | * If CCK != 1M then set short preamble rate flag. |
| 3319 | */ |
| 3320 | rates[i].flags |= |
| 3321 | (iwl_rates[i].plcp == IWL_RATE_1M_PLCP) ? |
| 3322 | 0 : IEEE80211_RATE_SHORT_PREAMBLE; |
| 3323 | } |
| 3324 | } |
| 3325 | } |
| 3326 | |
| 3327 | static int iwl_init_drv(struct iwl_priv *priv) |
| 3328 | { |
| 3329 | int ret; |
| 3330 | |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3331 | spin_lock_init(&priv->sta_lock); |
| 3332 | spin_lock_init(&priv->hcmd_lock); |
| 3333 | |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3334 | mutex_init(&priv->mutex); |
| 3335 | |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3336 | priv->ieee_channels = NULL; |
| 3337 | priv->ieee_rates = NULL; |
| 3338 | priv->band = IEEE80211_BAND_2GHZ; |
| 3339 | |
| 3340 | priv->iw_mode = NL80211_IFTYPE_STATION; |
Johannes Berg | ba37a3d | 2009-12-10 14:37:27 -0800 | [diff] [blame] | 3341 | priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; |
Wey-Yi Guy | a13d276 | 2010-01-22 14:22:42 -0800 | [diff] [blame] | 3342 | priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; |
Wey-Yi Guy | d5a0ffa | 2010-03-04 13:38:59 -0800 | [diff] [blame] | 3343 | priv->_agn.agg_tids_count = 0; |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3344 | |
Wey-Yi Guy | 8a472da | 2010-02-18 22:03:06 -0800 | [diff] [blame] | 3345 | /* initialize force reset */ |
| 3346 | priv->force_reset[IWL_RF_RESET].reset_duration = |
| 3347 | IWL_DELAY_NEXT_FORCE_RF_RESET; |
| 3348 | priv->force_reset[IWL_FW_RESET].reset_duration = |
| 3349 | IWL_DELAY_NEXT_FORCE_FW_RELOAD; |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3350 | |
Stanislaw Gruszka | 410f2bb | 2011-03-04 17:51:51 +0100 | [diff] [blame] | 3351 | priv->rx_statistics_jiffies = jiffies; |
| 3352 | |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3353 | /* Choose which receivers/antennas to use */ |
| 3354 | if (priv->cfg->ops->hcmd->set_rxon_chain) |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3355 | priv->cfg->ops->hcmd->set_rxon_chain(priv, |
| 3356 | &priv->contexts[IWL_RXON_CTX_BSS]); |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3357 | |
| 3358 | iwl_init_scan_params(priv); |
| 3359 | |
Wey-Yi Guy | 22bf59a | 2010-08-23 07:57:11 -0700 | [diff] [blame] | 3360 | /* init bt coex */ |
Wey-Yi Guy | 7cb1b08 | 2010-10-06 08:10:00 -0700 | [diff] [blame] | 3361 | if (priv->cfg->bt_params && |
| 3362 | priv->cfg->bt_params->advanced_bt_coexist) { |
Wey-Yi Guy | b6e116e | 2010-08-23 07:57:14 -0700 | [diff] [blame] | 3363 | priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT; |
| 3364 | priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT; |
| 3365 | priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK; |
Wey-Yi Guy | 22bf59a | 2010-08-23 07:57:11 -0700 | [diff] [blame] | 3366 | priv->bt_on_thresh = BT_ON_THRESHOLD_DEF; |
| 3367 | priv->bt_duration = BT_DURATION_LIMIT_DEF; |
| 3368 | priv->dynamic_frag_thresh = BT_FRAG_THRESHOLD_DEF; |
Wey-Yi Guy | 22bf59a | 2010-08-23 07:57:11 -0700 | [diff] [blame] | 3369 | } |
| 3370 | |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3371 | ret = iwl_init_channel_map(priv); |
| 3372 | if (ret) { |
| 3373 | IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); |
| 3374 | goto err; |
| 3375 | } |
| 3376 | |
| 3377 | ret = iwlcore_init_geos(priv); |
| 3378 | if (ret) { |
| 3379 | IWL_ERR(priv, "initializing geos failed: %d\n", ret); |
| 3380 | goto err_free_channel_map; |
| 3381 | } |
| 3382 | iwl_init_hw_rates(priv, priv->ieee_rates); |
| 3383 | |
| 3384 | return 0; |
| 3385 | |
| 3386 | err_free_channel_map: |
| 3387 | iwl_free_channel_map(priv); |
| 3388 | err: |
| 3389 | return ret; |
| 3390 | } |
| 3391 | |
| 3392 | static void iwl_uninit_drv(struct iwl_priv *priv) |
| 3393 | { |
| 3394 | iwl_calib_free_results(priv); |
| 3395 | iwlcore_free_geos(priv); |
| 3396 | iwl_free_channel_map(priv); |
Johannes Berg | 811ecc9 | 2010-04-06 04:12:41 -0700 | [diff] [blame] | 3397 | kfree(priv->scan_cmd); |
Reinette Chatre | 89f186a | 2009-10-30 14:36:11 -0700 | [diff] [blame] | 3398 | } |
| 3399 | |
Johannes Berg | dc21b54 | 2010-10-23 09:15:39 -0700 | [diff] [blame] | 3400 | struct ieee80211_ops iwlagn_hw_ops = { |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 3401 | .tx = iwlagn_mac_tx, |
| 3402 | .start = iwlagn_mac_start, |
| 3403 | .stop = iwlagn_mac_stop, |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3404 | .add_interface = iwl_mac_add_interface, |
| 3405 | .remove_interface = iwl_mac_remove_interface, |
Johannes Berg | d4daaea | 2010-10-23 09:15:43 -0700 | [diff] [blame] | 3406 | .change_interface = iwl_mac_change_interface, |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 3407 | .config = iwlagn_mac_config, |
Johannes Berg | 8b8ab9d | 2010-08-17 11:24:01 +0200 | [diff] [blame] | 3408 | .configure_filter = iwlagn_configure_filter, |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 3409 | .set_key = iwlagn_mac_set_key, |
| 3410 | .update_tkip_key = iwlagn_mac_update_tkip_key, |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3411 | .conf_tx = iwl_mac_conf_tx, |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 3412 | .bss_info_changed = iwlagn_bss_info_changed, |
| 3413 | .ampdu_action = iwlagn_mac_ampdu_action, |
Johannes Berg | 6ab10ff | 2009-11-13 11:56:37 -0800 | [diff] [blame] | 3414 | .hw_scan = iwl_mac_hw_scan, |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 3415 | .sta_notify = iwlagn_mac_sta_notify, |
Reinette Chatre | fe6b23d | 2010-02-22 16:24:47 -0800 | [diff] [blame] | 3416 | .sta_add = iwlagn_mac_sta_add, |
| 3417 | .sta_remove = iwl_mac_sta_remove, |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 3418 | .channel_switch = iwlagn_mac_channel_switch, |
| 3419 | .flush = iwlagn_mac_flush, |
Johannes Berg | a85d7cc | 2010-07-31 08:34:10 -0700 | [diff] [blame] | 3420 | .tx_last_beacon = iwl_mac_tx_last_beacon, |
Johannes Berg | 9b9190d | 2011-01-06 08:07:10 -0800 | [diff] [blame] | 3421 | .remain_on_channel = iwl_mac_remain_on_channel, |
| 3422 | .cancel_remain_on_channel = iwl_mac_cancel_remain_on_channel, |
Johannes Berg | 266af4c7 | 2011-03-10 20:13:26 -0800 | [diff] [blame] | 3423 | .offchannel_tx = iwl_mac_offchannel_tx, |
| 3424 | .offchannel_tx_cancel_wait = iwl_mac_offchannel_tx_cancel_wait, |
Cindy H. Kao | 4613e72 | 2011-05-06 10:40:15 -0700 | [diff] [blame] | 3425 | CFG80211_TESTMODE_CMD(iwl_testmode_cmd) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3426 | }; |
| 3427 | |
Johannes Berg | e98a130 | 2011-04-05 09:42:08 -0700 | [diff] [blame] | 3428 | static u32 iwl_hw_detect(struct iwl_priv *priv) |
Wey-Yi Guy | 3867fe0 | 2010-07-31 08:34:05 -0700 | [diff] [blame] | 3429 | { |
Johannes Berg | c2974a1 | 2011-04-05 09:42:09 -0700 | [diff] [blame] | 3430 | u8 rev_id; |
| 3431 | |
| 3432 | pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id); |
| 3433 | IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); |
Johannes Berg | 02a7fa0 | 2011-04-05 09:42:12 -0700 | [diff] [blame] | 3434 | return iwl_read32(priv, CSR_HW_REV); |
Wey-Yi Guy | 3867fe0 | 2010-07-31 08:34:05 -0700 | [diff] [blame] | 3435 | } |
| 3436 | |
Wey-Yi Guy | 07d4f1a | 2010-07-31 08:34:08 -0700 | [diff] [blame] | 3437 | static int iwl_set_hw_params(struct iwl_priv *priv) |
| 3438 | { |
| 3439 | priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; |
| 3440 | priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; |
Don Fry | 9d143e9 | 2011-04-20 15:23:57 -0700 | [diff] [blame] | 3441 | if (iwlagn_mod_params.amsdu_size_8K) |
Wey-Yi Guy | 07d4f1a | 2010-07-31 08:34:08 -0700 | [diff] [blame] | 3442 | priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_8K); |
| 3443 | else |
| 3444 | priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_4K); |
| 3445 | |
| 3446 | priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL; |
| 3447 | |
Don Fry | 9d143e9 | 2011-04-20 15:23:57 -0700 | [diff] [blame] | 3448 | if (iwlagn_mod_params.disable_11n) |
Wey-Yi Guy | 07d4f1a | 2010-07-31 08:34:08 -0700 | [diff] [blame] | 3449 | priv->cfg->sku &= ~IWL_SKU_N; |
| 3450 | |
| 3451 | /* Device-specific setup */ |
| 3452 | return priv->cfg->ops->lib->set_hw_params(priv); |
| 3453 | } |
| 3454 | |
Johannes Berg | e72f368 | 2010-08-23 10:46:51 +0200 | [diff] [blame] | 3455 | static const u8 iwlagn_bss_ac_to_fifo[] = { |
| 3456 | IWL_TX_FIFO_VO, |
| 3457 | IWL_TX_FIFO_VI, |
| 3458 | IWL_TX_FIFO_BE, |
| 3459 | IWL_TX_FIFO_BK, |
| 3460 | }; |
| 3461 | |
| 3462 | static const u8 iwlagn_bss_ac_to_queue[] = { |
| 3463 | 0, 1, 2, 3, |
| 3464 | }; |
| 3465 | |
| 3466 | static const u8 iwlagn_pan_ac_to_fifo[] = { |
| 3467 | IWL_TX_FIFO_VO_IPAN, |
| 3468 | IWL_TX_FIFO_VI_IPAN, |
| 3469 | IWL_TX_FIFO_BE_IPAN, |
| 3470 | IWL_TX_FIFO_BK_IPAN, |
| 3471 | }; |
| 3472 | |
| 3473 | static const u8 iwlagn_pan_ac_to_queue[] = { |
| 3474 | 7, 6, 5, 4, |
| 3475 | }; |
| 3476 | |
Wey-Yi Guy | 119ea18 | 2011-04-18 09:34:06 -0700 | [diff] [blame] | 3477 | /* This function both allocates and initializes hw and priv. */ |
| 3478 | static struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg) |
| 3479 | { |
| 3480 | struct iwl_priv *priv; |
| 3481 | /* mac80211 allocates memory for this device instance, including |
| 3482 | * space for this driver's private structure */ |
| 3483 | struct ieee80211_hw *hw; |
| 3484 | |
| 3485 | hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); |
| 3486 | if (hw == NULL) { |
| 3487 | pr_err("%s: Can not allocate network device\n", |
| 3488 | cfg->name); |
| 3489 | goto out; |
| 3490 | } |
| 3491 | |
| 3492 | priv = hw->priv; |
| 3493 | priv->hw = hw; |
| 3494 | |
| 3495 | out: |
| 3496 | return hw; |
| 3497 | } |
| 3498 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3499 | static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3500 | { |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3501 | int err = 0, i; |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 3502 | struct iwl_priv *priv; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3503 | struct ieee80211_hw *hw; |
Tomas Winkler | 82b9a12 | 2008-03-04 18:09:30 -0800 | [diff] [blame] | 3504 | struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); |
Mohamed Abbas | 0359fac | 2008-03-28 16:21:08 -0700 | [diff] [blame] | 3505 | unsigned long flags; |
Wey-Yi Guy | c6fa17e | 2010-07-15 05:58:30 -0700 | [diff] [blame] | 3506 | u16 pci_cmd, num_mac; |
Johannes Berg | e98a130 | 2011-04-05 09:42:08 -0700 | [diff] [blame] | 3507 | u32 hw_rev; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3508 | |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3509 | /************************ |
| 3510 | * 1. Allocating HW data |
| 3511 | ************************/ |
| 3512 | |
Johannes Berg | dc21b54 | 2010-10-23 09:15:39 -0700 | [diff] [blame] | 3513 | hw = iwl_alloc_all(cfg); |
Assaf Krauss | 1d0a082 | 2008-03-14 10:38:48 -0700 | [diff] [blame] | 3514 | if (!hw) { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3515 | err = -ENOMEM; |
| 3516 | goto out; |
| 3517 | } |
Assaf Krauss | 1d0a082 | 2008-03-14 10:38:48 -0700 | [diff] [blame] | 3518 | priv = hw->priv; |
| 3519 | /* At this point both hw and priv are allocated. */ |
| 3520 | |
Johannes Berg | ca7966c | 2011-04-22 10:15:23 -0700 | [diff] [blame] | 3521 | priv->ucode_type = UCODE_SUBTYPE_NONE_LOADED; |
| 3522 | |
Johannes Berg | 246ed35 | 2010-08-23 10:46:32 +0200 | [diff] [blame] | 3523 | /* |
| 3524 | * The default context is always valid, |
| 3525 | * more may be discovered when firmware |
| 3526 | * is loaded. |
| 3527 | */ |
| 3528 | priv->valid_contexts = BIT(IWL_RXON_CTX_BSS); |
| 3529 | |
| 3530 | for (i = 0; i < NUM_IWL_RXON_CTX; i++) |
| 3531 | priv->contexts[i].ctxid = i; |
| 3532 | |
Johannes Berg | 763cc3b | 2010-09-03 06:32:21 -0700 | [diff] [blame] | 3533 | priv->contexts[IWL_RXON_CTX_BSS].always_active = true; |
| 3534 | priv->contexts[IWL_RXON_CTX_BSS].is_active = true; |
Johannes Berg | 8f2d3d2 | 2010-08-23 10:46:37 +0200 | [diff] [blame] | 3535 | priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; |
| 3536 | priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; |
| 3537 | priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; |
Johannes Berg | 8dfdb9d | 2010-08-23 10:46:38 +0200 | [diff] [blame] | 3538 | priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; |
Johannes Berg | 2995baf | 2010-08-23 10:46:42 +0200 | [diff] [blame] | 3539 | priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID; |
Johannes Berg | c10afb6 | 2010-08-23 10:46:43 +0200 | [diff] [blame] | 3540 | priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; |
Johannes Berg | e72f368 | 2010-08-23 10:46:51 +0200 | [diff] [blame] | 3541 | priv->contexts[IWL_RXON_CTX_BSS].ac_to_fifo = iwlagn_bss_ac_to_fifo; |
| 3542 | priv->contexts[IWL_RXON_CTX_BSS].ac_to_queue = iwlagn_bss_ac_to_queue; |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 3543 | priv->contexts[IWL_RXON_CTX_BSS].exclusive_interface_modes = |
| 3544 | BIT(NL80211_IFTYPE_ADHOC); |
| 3545 | priv->contexts[IWL_RXON_CTX_BSS].interface_modes = |
| 3546 | BIT(NL80211_IFTYPE_STATION); |
Johannes Berg | 2295c66 | 2010-10-23 09:15:41 -0700 | [diff] [blame] | 3547 | priv->contexts[IWL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 3548 | priv->contexts[IWL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; |
| 3549 | priv->contexts[IWL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; |
| 3550 | priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; |
Johannes Berg | ece9c4e | 2010-08-23 10:46:49 +0200 | [diff] [blame] | 3551 | |
| 3552 | priv->contexts[IWL_RXON_CTX_PAN].rxon_cmd = REPLY_WIPAN_RXON; |
| 3553 | priv->contexts[IWL_RXON_CTX_PAN].rxon_timing_cmd = REPLY_WIPAN_RXON_TIMING; |
| 3554 | priv->contexts[IWL_RXON_CTX_PAN].rxon_assoc_cmd = REPLY_WIPAN_RXON_ASSOC; |
| 3555 | priv->contexts[IWL_RXON_CTX_PAN].qos_cmd = REPLY_WIPAN_QOS_PARAM; |
| 3556 | priv->contexts[IWL_RXON_CTX_PAN].ap_sta_id = IWL_AP_ID_PAN; |
| 3557 | priv->contexts[IWL_RXON_CTX_PAN].wep_key_cmd = REPLY_WIPAN_WEPKEY; |
| 3558 | priv->contexts[IWL_RXON_CTX_PAN].bcast_sta_id = IWLAGN_PAN_BCAST_ID; |
| 3559 | priv->contexts[IWL_RXON_CTX_PAN].station_flags = STA_FLG_PAN_STATION; |
Johannes Berg | e72f368 | 2010-08-23 10:46:51 +0200 | [diff] [blame] | 3560 | priv->contexts[IWL_RXON_CTX_PAN].ac_to_fifo = iwlagn_pan_ac_to_fifo; |
| 3561 | priv->contexts[IWL_RXON_CTX_PAN].ac_to_queue = iwlagn_pan_ac_to_queue; |
| 3562 | priv->contexts[IWL_RXON_CTX_PAN].mcast_queue = IWL_IPAN_MCAST_QUEUE; |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 3563 | priv->contexts[IWL_RXON_CTX_PAN].interface_modes = |
| 3564 | BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP); |
Wey-Yi Guy | f35c0c5 | 2011-01-13 17:09:29 -0800 | [diff] [blame] | 3565 | #ifdef CONFIG_IWL_P2P |
| 3566 | priv->contexts[IWL_RXON_CTX_PAN].interface_modes |= |
| 3567 | BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO); |
| 3568 | #endif |
Johannes Berg | d0fe478 | 2010-08-23 10:46:58 +0200 | [diff] [blame] | 3569 | priv->contexts[IWL_RXON_CTX_PAN].ap_devtype = RXON_DEV_TYPE_CP; |
| 3570 | priv->contexts[IWL_RXON_CTX_PAN].station_devtype = RXON_DEV_TYPE_2STA; |
| 3571 | priv->contexts[IWL_RXON_CTX_PAN].unused_devtype = RXON_DEV_TYPE_P2P; |
Johannes Berg | ece9c4e | 2010-08-23 10:46:49 +0200 | [diff] [blame] | 3572 | |
| 3573 | BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); |
Johannes Berg | 8f2d3d2 | 2010-08-23 10:46:37 +0200 | [diff] [blame] | 3574 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3575 | SET_IEEE80211_DEV(hw, &pdev->dev); |
| 3576 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 3577 | IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); |
Tomas Winkler | 82b9a12 | 2008-03-04 18:09:30 -0800 | [diff] [blame] | 3578 | priv->cfg = cfg; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3579 | priv->pci_dev = pdev; |
Mohamed Abbas | 40cefda | 2009-05-22 11:01:52 -0700 | [diff] [blame] | 3580 | priv->inta_mask = CSR_INI_SET_MASK; |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3581 | |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 3582 | /* is antenna coupling more than 35dB ? */ |
| 3583 | priv->bt_ant_couple_ok = |
| 3584 | (iwlagn_ant_coupling > IWL_BT_ANTENNA_COUPLING_THRESHOLD) ? |
| 3585 | true : false; |
| 3586 | |
Wey-Yi Guy | 9f28ebc | 2010-11-26 13:24:19 -0800 | [diff] [blame] | 3587 | /* enable/disable bt channel inhibition */ |
Wey-Yi Guy | f37837c | 2010-08-23 07:57:12 -0700 | [diff] [blame] | 3588 | priv->bt_ch_announce = iwlagn_bt_ch_announce; |
Wey-Yi Guy | 9f28ebc | 2010-11-26 13:24:19 -0800 | [diff] [blame] | 3589 | IWL_DEBUG_INFO(priv, "BT channel inhibition is %s\n", |
| 3590 | (priv->bt_ch_announce) ? "On" : "Off"); |
Wey-Yi Guy | f37837c | 2010-08-23 07:57:12 -0700 | [diff] [blame] | 3591 | |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 3592 | if (iwl_alloc_traffic_mem(priv)) |
| 3593 | IWL_ERR(priv, "Not enough memory to generate traffic log\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3594 | |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3595 | /************************** |
| 3596 | * 2. Initializing PCI bus |
| 3597 | **************************/ |
John W. Linville | 1a7123c | 2010-08-05 14:39:31 -0400 | [diff] [blame] | 3598 | pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | |
| 3599 | PCIE_LINK_STATE_CLKPM); |
| 3600 | |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3601 | if (pci_enable_device(pdev)) { |
| 3602 | err = -ENODEV; |
| 3603 | goto out_ieee80211_free_hw; |
| 3604 | } |
| 3605 | |
| 3606 | pci_set_master(pdev); |
| 3607 | |
Winkler, Tomas | 093d874c | 2008-09-26 15:09:34 +0800 | [diff] [blame] | 3608 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3609 | if (!err) |
Winkler, Tomas | 093d874c | 2008-09-26 15:09:34 +0800 | [diff] [blame] | 3610 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); |
Ron Rindjunsky | cc2a8ea | 2008-04-21 15:41:59 -0700 | [diff] [blame] | 3611 | if (err) { |
Winkler, Tomas | 093d874c | 2008-09-26 15:09:34 +0800 | [diff] [blame] | 3612 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
Ron Rindjunsky | cc2a8ea | 2008-04-21 15:41:59 -0700 | [diff] [blame] | 3613 | if (!err) |
Winkler, Tomas | 093d874c | 2008-09-26 15:09:34 +0800 | [diff] [blame] | 3614 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); |
Ron Rindjunsky | cc2a8ea | 2008-04-21 15:41:59 -0700 | [diff] [blame] | 3615 | /* both attempts failed: */ |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3616 | if (err) { |
Tomas Winkler | 978785a | 2008-12-19 10:37:31 +0800 | [diff] [blame] | 3617 | IWL_WARN(priv, "No suitable DMA available.\n"); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3618 | goto out_pci_disable_device; |
Ron Rindjunsky | cc2a8ea | 2008-04-21 15:41:59 -0700 | [diff] [blame] | 3619 | } |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3620 | } |
| 3621 | |
| 3622 | err = pci_request_regions(pdev, DRV_NAME); |
| 3623 | if (err) |
| 3624 | goto out_pci_disable_device; |
| 3625 | |
| 3626 | pci_set_drvdata(pdev, priv); |
| 3627 | |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3628 | |
| 3629 | /*********************** |
| 3630 | * 3. Read REV register |
| 3631 | ***********************/ |
| 3632 | priv->hw_base = pci_iomap(pdev, 0, 0); |
| 3633 | if (!priv->hw_base) { |
| 3634 | err = -ENODEV; |
| 3635 | goto out_pci_release_regions; |
| 3636 | } |
| 3637 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 3638 | IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3639 | (unsigned long long) pci_resource_len(pdev, 0)); |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 3640 | IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3641 | |
Reinette Chatre | 731a29b | 2009-12-14 14:12:11 -0800 | [diff] [blame] | 3642 | /* these spin locks will be used in apm_ops.init and EEPROM access |
Mohamed Abbas | a8b50a0 | 2009-05-22 11:01:47 -0700 | [diff] [blame] | 3643 | * we should init now |
| 3644 | */ |
| 3645 | spin_lock_init(&priv->reg_lock); |
Reinette Chatre | 731a29b | 2009-12-14 14:12:11 -0800 | [diff] [blame] | 3646 | spin_lock_init(&priv->lock); |
Reinette Chatre | 4843b5a | 2010-02-03 09:38:59 -0800 | [diff] [blame] | 3647 | |
| 3648 | /* |
| 3649 | * stop and reset the on-board processor just in case it is in a |
| 3650 | * strange state ... like being left stranded by a primary kernel |
| 3651 | * and this is now the kdump kernel trying to start up |
| 3652 | */ |
| 3653 | iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); |
| 3654 | |
Johannes Berg | e98a130 | 2011-04-05 09:42:08 -0700 | [diff] [blame] | 3655 | hw_rev = iwl_hw_detect(priv); |
Shanyu Zhao | c11362c | 2010-03-05 17:05:20 -0800 | [diff] [blame] | 3656 | IWL_INFO(priv, "Detected %s, REV=0x%X\n", |
Johannes Berg | e98a130 | 2011-04-05 09:42:08 -0700 | [diff] [blame] | 3657 | priv->cfg->name, hw_rev); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3658 | |
Tomas Winkler | e7b6358 | 2008-09-03 11:26:49 +0800 | [diff] [blame] | 3659 | /* We disable the RETRY_TIMEOUT register (0x41) to keep |
| 3660 | * PCI Tx retries from interfering with C3 CPU state */ |
| 3661 | pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); |
| 3662 | |
Johannes Berg | 4cd2bf7 | 2011-04-13 03:14:52 -0700 | [diff] [blame] | 3663 | if (iwl_prepare_card_hw(priv)) { |
Mohamed Abbas | 086ed11 | 2009-05-22 11:01:54 -0700 | [diff] [blame] | 3664 | IWL_WARN(priv, "Failed, HW not ready\n"); |
| 3665 | goto out_iounmap; |
| 3666 | } |
| 3667 | |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3668 | /***************** |
| 3669 | * 4. Read EEPROM |
| 3670 | *****************/ |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3671 | /* Read the EEPROM */ |
Johannes Berg | e98a130 | 2011-04-05 09:42:08 -0700 | [diff] [blame] | 3672 | err = iwl_eeprom_init(priv, hw_rev); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3673 | if (err) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 3674 | IWL_ERR(priv, "Unable to init EEPROM\n"); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3675 | goto out_iounmap; |
| 3676 | } |
Tomas Winkler | 8614f36 | 2008-04-23 17:14:55 -0700 | [diff] [blame] | 3677 | err = iwl_eeprom_check_version(priv); |
| 3678 | if (err) |
Reinette Chatre | c8f1613 | 2009-02-27 16:21:22 -0800 | [diff] [blame] | 3679 | goto out_free_eeprom; |
Tomas Winkler | 8614f36 | 2008-04-23 17:14:55 -0700 | [diff] [blame] | 3680 | |
Wey-Yi Guy | 21a5b3c | 2010-11-10 13:32:59 -0800 | [diff] [blame] | 3681 | err = iwl_eeprom_check_sku(priv); |
| 3682 | if (err) |
| 3683 | goto out_free_eeprom; |
| 3684 | |
Ron Rindjunsky | 0288301 | 2008-05-15 13:53:53 +0800 | [diff] [blame] | 3685 | /* extract MAC Address */ |
Wey-Yi Guy | c6fa17e | 2010-07-15 05:58:30 -0700 | [diff] [blame] | 3686 | iwl_eeprom_get_mac(priv, priv->addresses[0].addr); |
| 3687 | IWL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); |
| 3688 | priv->hw->wiphy->addresses = priv->addresses; |
| 3689 | priv->hw->wiphy->n_addresses = 1; |
| 3690 | num_mac = iwl_eeprom_query16(priv, EEPROM_NUM_MAC_ADDRESS); |
| 3691 | if (num_mac > 1) { |
| 3692 | memcpy(priv->addresses[1].addr, priv->addresses[0].addr, |
| 3693 | ETH_ALEN); |
| 3694 | priv->addresses[1].addr[5]++; |
| 3695 | priv->hw->wiphy->n_addresses++; |
| 3696 | } |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3697 | |
| 3698 | /************************ |
| 3699 | * 5. Setup HW constants |
| 3700 | ************************/ |
Ron Rindjunsky | da154e30 | 2008-06-30 17:23:20 +0800 | [diff] [blame] | 3701 | if (iwl_set_hw_params(priv)) { |
Winkler, Tomas | 15b1687 | 2008-12-19 10:37:33 +0800 | [diff] [blame] | 3702 | IWL_ERR(priv, "failed to set hw parameters\n"); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 3703 | goto out_free_eeprom; |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3704 | } |
| 3705 | |
| 3706 | /******************* |
Tomas Winkler | 6ba8795 | 2008-05-15 13:54:17 +0800 | [diff] [blame] | 3707 | * 6. Setup priv |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3708 | *******************/ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3709 | |
Tomas Winkler | 6ba8795 | 2008-05-15 13:54:17 +0800 | [diff] [blame] | 3710 | err = iwl_init_drv(priv); |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 3711 | if (err) |
Ron Rindjunsky | 399f490 | 2008-04-23 17:14:56 -0700 | [diff] [blame] | 3712 | goto out_free_eeprom; |
Assaf Krauss | bf85ea4 | 2008-03-14 10:38:49 -0700 | [diff] [blame] | 3713 | /* At this point both hw and priv are initialized. */ |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3714 | |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3715 | /******************** |
Abhijeet Kolekar | 09f9bf7 | 2009-04-20 14:37:03 -0700 | [diff] [blame] | 3716 | * 7. Setup services |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3717 | ********************/ |
Mohamed Abbas | 0359fac | 2008-03-28 16:21:08 -0700 | [diff] [blame] | 3718 | spin_lock_irqsave(&priv->lock, flags); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3719 | iwl_disable_interrupts(priv); |
Mohamed Abbas | 0359fac | 2008-03-28 16:21:08 -0700 | [diff] [blame] | 3720 | spin_unlock_irqrestore(&priv->lock, flags); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3721 | |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3722 | pci_enable_msi(priv->pci_dev); |
| 3723 | |
Johannes Berg | 519d8ab | 2011-04-05 09:42:11 -0700 | [diff] [blame] | 3724 | iwl_alloc_isr_ict(priv); |
Wey-Yi Guy | e39fdee | 2010-11-10 09:56:40 -0800 | [diff] [blame] | 3725 | |
Johannes Berg | 519d8ab | 2011-04-05 09:42:11 -0700 | [diff] [blame] | 3726 | err = request_irq(priv->pci_dev->irq, iwl_isr_ict, |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 3727 | IRQF_SHARED, DRV_NAME, priv); |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3728 | if (err) { |
| 3729 | IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); |
| 3730 | goto out_disable_msi; |
| 3731 | } |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3732 | |
Emmanuel Grumbach | 4e39317 | 2008-06-12 09:46:53 +0800 | [diff] [blame] | 3733 | iwl_setup_deferred_work(priv); |
Emmanuel Grumbach | 653fa4a | 2008-06-30 17:23:11 +0800 | [diff] [blame] | 3734 | iwl_setup_rx_handlers(priv); |
Cindy H. Kao | 4613e72 | 2011-05-06 10:40:15 -0700 | [diff] [blame] | 3735 | iwl_testmode_init(priv); |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3736 | |
Johannes Berg | 158bea0 | 2010-01-22 14:22:53 -0800 | [diff] [blame] | 3737 | /********************************************* |
| 3738 | * 8. Enable interrupts and read RFKILL state |
| 3739 | *********************************************/ |
Tomas Winkler | 6ba8795 | 2008-05-15 13:54:17 +0800 | [diff] [blame] | 3740 | |
Stanislaw Gruszka | 554d1d0 | 2010-12-23 12:38:21 +0100 | [diff] [blame] | 3741 | /* enable rfkill interrupt: hw bug w/a */ |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3742 | pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd); |
| 3743 | if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { |
| 3744 | pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; |
| 3745 | pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); |
| 3746 | } |
| 3747 | |
Stanislaw Gruszka | 554d1d0 | 2010-12-23 12:38:21 +0100 | [diff] [blame] | 3748 | iwl_enable_rfkill_int(priv); |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3749 | |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3750 | /* If platform's RF_KILL switch is NOT set to KILL */ |
| 3751 | if (iwl_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) |
| 3752 | clear_bit(STATUS_RF_KILL_HW, &priv->status); |
| 3753 | else |
| 3754 | set_bit(STATUS_RF_KILL_HW, &priv->status); |
Tomas Winkler | 6ba8795 | 2008-05-15 13:54:17 +0800 | [diff] [blame] | 3755 | |
Johannes Berg | a60e77e | 2009-06-04 18:26:06 +0200 | [diff] [blame] | 3756 | wiphy_rfkill_set_hw_state(priv->hw->wiphy, |
| 3757 | test_bit(STATUS_RF_KILL_HW, &priv->status)); |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3758 | |
Emmanuel Grumbach | 58d0f36 | 2008-06-12 09:47:19 +0800 | [diff] [blame] | 3759 | iwl_power_initialize(priv); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 3760 | iwl_tt_initialize(priv); |
Johannes Berg | 158bea0 | 2010-01-22 14:22:53 -0800 | [diff] [blame] | 3761 | |
Reinette Chatre | a15707d | 2010-05-10 15:08:11 -0700 | [diff] [blame] | 3762 | init_completion(&priv->_agn.firmware_loading_complete); |
Johannes Berg | 562db53 | 2010-04-29 07:41:53 -0700 | [diff] [blame] | 3763 | |
Johannes Berg | b08dfd0 | 2010-01-29 11:54:56 -0800 | [diff] [blame] | 3764 | err = iwl_request_firmware(priv, true); |
Johannes Berg | 158bea0 | 2010-01-22 14:22:53 -0800 | [diff] [blame] | 3765 | if (err) |
Emmanuel Grumbach | 7d47618 | 2010-05-23 00:14:08 -0700 | [diff] [blame] | 3766 | goto out_destroy_workqueue; |
Johannes Berg | 158bea0 | 2010-01-22 14:22:53 -0800 | [diff] [blame] | 3767 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3768 | return 0; |
| 3769 | |
Emmanuel Grumbach | 7d47618 | 2010-05-23 00:14:08 -0700 | [diff] [blame] | 3770 | out_destroy_workqueue: |
Reinette Chatre | c8f1613 | 2009-02-27 16:21:22 -0800 | [diff] [blame] | 3771 | destroy_workqueue(priv->workqueue); |
| 3772 | priv->workqueue = NULL; |
Helmut Schaa | 795cc0a | 2009-02-12 18:51:03 +0100 | [diff] [blame] | 3773 | free_irq(priv->pci_dev->irq, priv); |
Johannes Berg | 519d8ab | 2011-04-05 09:42:11 -0700 | [diff] [blame] | 3774 | iwl_free_isr_ict(priv); |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3775 | out_disable_msi: |
| 3776 | pci_disable_msi(priv->pci_dev); |
Tomas Winkler | 6ba8795 | 2008-05-15 13:54:17 +0800 | [diff] [blame] | 3777 | iwl_uninit_drv(priv); |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 3778 | out_free_eeprom: |
| 3779 | iwl_eeprom_free(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3780 | out_iounmap: |
| 3781 | pci_iounmap(pdev, priv->hw_base); |
| 3782 | out_pci_release_regions: |
Assaf Krauss | 316c30d | 2008-03-14 10:38:46 -0700 | [diff] [blame] | 3783 | pci_set_drvdata(pdev, NULL); |
Reinette Chatre | 623d563 | 2009-03-03 11:37:04 -0800 | [diff] [blame] | 3784 | pci_release_regions(pdev); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3785 | out_pci_disable_device: |
| 3786 | pci_disable_device(pdev); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3787 | out_ieee80211_free_hw: |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 3788 | iwl_free_traffic_mem(priv); |
Wey-Yi Guy | d7c76f4 | 2009-10-09 13:20:17 -0700 | [diff] [blame] | 3789 | ieee80211_free_hw(priv->hw); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3790 | out: |
| 3791 | return err; |
| 3792 | } |
| 3793 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3794 | static void __devexit iwl_pci_remove(struct pci_dev *pdev) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3795 | { |
Tomas Winkler | c79dd5b | 2008-03-12 16:58:50 -0700 | [diff] [blame] | 3796 | struct iwl_priv *priv = pci_get_drvdata(pdev); |
Mohamed Abbas | 0359fac | 2008-03-28 16:21:08 -0700 | [diff] [blame] | 3797 | unsigned long flags; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3798 | |
| 3799 | if (!priv) |
| 3800 | return; |
| 3801 | |
Reinette Chatre | a15707d | 2010-05-10 15:08:11 -0700 | [diff] [blame] | 3802 | wait_for_completion(&priv->_agn.firmware_loading_complete); |
Johannes Berg | 562db53 | 2010-04-29 07:41:53 -0700 | [diff] [blame] | 3803 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 3804 | IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3805 | |
Emmanuel Grumbach | 6724962 | 2008-05-29 16:35:26 +0800 | [diff] [blame] | 3806 | iwl_dbgfs_unregister(priv); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3807 | sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group); |
Emmanuel Grumbach | 6724962 | 2008-05-29 16:35:26 +0800 | [diff] [blame] | 3808 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3809 | /* ieee80211_unregister_hw call wil cause iwl_mac_stop to |
| 3810 | * to be called and iwl_down since we are removing the device |
Gregory Greenman | 0b124c3 | 2008-09-03 11:18:50 +0800 | [diff] [blame] | 3811 | * we need to set STATUS_EXIT_PENDING bit. |
| 3812 | */ |
| 3813 | set_bit(STATUS_EXIT_PENDING, &priv->status); |
Wey-Yi Guy | 5ed540a | 2011-01-21 15:26:39 -0800 | [diff] [blame] | 3814 | |
| 3815 | iwl_leds_exit(priv); |
| 3816 | |
Ron Rindjunsky | c4f5523 | 2008-03-28 16:21:10 -0700 | [diff] [blame] | 3817 | if (priv->mac80211_registered) { |
| 3818 | ieee80211_unregister_hw(priv->hw); |
| 3819 | priv->mac80211_registered = 0; |
| 3820 | } |
| 3821 | |
Johannes Berg | 1a10f43 | 2011-04-13 03:14:44 -0700 | [diff] [blame] | 3822 | /* Reset to low power before unloading driver. */ |
Johannes Berg | 14e8e4a | 2010-09-22 18:02:10 +0200 | [diff] [blame] | 3823 | iwl_apm_stop(priv); |
Ben Cahill | c166b25 | 2009-10-23 13:42:35 -0700 | [diff] [blame] | 3824 | |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 3825 | iwl_tt_exit(priv); |
| 3826 | |
Mohamed Abbas | 0359fac | 2008-03-28 16:21:08 -0700 | [diff] [blame] | 3827 | /* make sure we flush any pending irq or |
| 3828 | * tasklet for the driver |
| 3829 | */ |
| 3830 | spin_lock_irqsave(&priv->lock, flags); |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3831 | iwl_disable_interrupts(priv); |
Mohamed Abbas | 0359fac | 2008-03-28 16:21:08 -0700 | [diff] [blame] | 3832 | spin_unlock_irqrestore(&priv->lock, flags); |
| 3833 | |
| 3834 | iwl_synchronize_irq(priv); |
| 3835 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3836 | iwl_dealloc_ucode_pci(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3837 | |
| 3838 | if (priv->rxq.bd) |
Wey-Yi Guy | 54b8155 | 2010-03-17 13:34:35 -0700 | [diff] [blame] | 3839 | iwlagn_rx_queue_free(priv, &priv->rxq); |
Wey-Yi Guy | 74bcdb3 | 2010-03-17 13:34:34 -0700 | [diff] [blame] | 3840 | iwlagn_hw_txq_ctx_free(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3841 | |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame] | 3842 | iwl_eeprom_free(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3843 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3844 | |
Mohamed Abbas | 948c171 | 2007-10-25 17:15:45 +0800 | [diff] [blame] | 3845 | /*netif_stop_queue(dev); */ |
| 3846 | flush_workqueue(priv->workqueue); |
| 3847 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 3848 | /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3849 | * priv->workqueue... so we can't take down the workqueue |
| 3850 | * until now... */ |
| 3851 | destroy_workqueue(priv->workqueue); |
| 3852 | priv->workqueue = NULL; |
Wey-Yi Guy | 20594eb | 2009-08-07 15:41:39 -0700 | [diff] [blame] | 3853 | iwl_free_traffic_mem(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3854 | |
Helmut Schaa | 6cd0b1c | 2009-01-19 13:10:07 +0100 | [diff] [blame] | 3855 | free_irq(priv->pci_dev->irq, priv); |
| 3856 | pci_disable_msi(priv->pci_dev); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3857 | pci_iounmap(pdev, priv->hw_base); |
| 3858 | pci_release_regions(pdev); |
| 3859 | pci_disable_device(pdev); |
| 3860 | pci_set_drvdata(pdev, NULL); |
| 3861 | |
Tomas Winkler | 6ba8795 | 2008-05-15 13:54:17 +0800 | [diff] [blame] | 3862 | iwl_uninit_drv(priv); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3863 | |
Johannes Berg | 519d8ab | 2011-04-05 09:42:11 -0700 | [diff] [blame] | 3864 | iwl_free_isr_ict(priv); |
Mohamed Abbas | ef850d7 | 2009-05-22 11:01:50 -0700 | [diff] [blame] | 3865 | |
Johannes Berg | 7783454 | 2010-10-04 05:50:36 -0700 | [diff] [blame] | 3866 | dev_kfree_skb(priv->beacon_skb); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3867 | |
| 3868 | ieee80211_free_hw(priv->hw); |
| 3869 | } |
| 3870 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 3871 | |
| 3872 | /***************************************************************************** |
| 3873 | * |
| 3874 | * driver and module entry point |
| 3875 | * |
| 3876 | *****************************************************************************/ |
| 3877 | |
Ron Rindjunsky | fed9017 | 2008-04-15 16:01:41 -0700 | [diff] [blame] | 3878 | /* Hardware specific file defines the PCI IDs table for that hardware module */ |
Alexey Dobriyan | a3aa188 | 2010-01-07 11:58:11 +0000 | [diff] [blame] | 3879 | static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { |
Wey-Yi Guy | ac59257 | 2009-11-20 12:05:03 -0800 | [diff] [blame] | 3880 | {IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */ |
| 3881 | {IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */ |
| 3882 | {IWL_PCI_DEVICE(0x4232, 0x1204, iwl5100_agn_cfg)}, /* Mini Card */ |
| 3883 | {IWL_PCI_DEVICE(0x4232, 0x1304, iwl5100_agn_cfg)}, /* Half Mini Card */ |
| 3884 | {IWL_PCI_DEVICE(0x4232, 0x1205, iwl5100_bgn_cfg)}, /* Mini Card */ |
| 3885 | {IWL_PCI_DEVICE(0x4232, 0x1305, iwl5100_bgn_cfg)}, /* Half Mini Card */ |
| 3886 | {IWL_PCI_DEVICE(0x4232, 0x1206, iwl5100_abg_cfg)}, /* Mini Card */ |
| 3887 | {IWL_PCI_DEVICE(0x4232, 0x1306, iwl5100_abg_cfg)}, /* Half Mini Card */ |
| 3888 | {IWL_PCI_DEVICE(0x4232, 0x1221, iwl5100_agn_cfg)}, /* Mini Card */ |
| 3889 | {IWL_PCI_DEVICE(0x4232, 0x1321, iwl5100_agn_cfg)}, /* Half Mini Card */ |
| 3890 | {IWL_PCI_DEVICE(0x4232, 0x1224, iwl5100_agn_cfg)}, /* Mini Card */ |
| 3891 | {IWL_PCI_DEVICE(0x4232, 0x1324, iwl5100_agn_cfg)}, /* Half Mini Card */ |
| 3892 | {IWL_PCI_DEVICE(0x4232, 0x1225, iwl5100_bgn_cfg)}, /* Mini Card */ |
| 3893 | {IWL_PCI_DEVICE(0x4232, 0x1325, iwl5100_bgn_cfg)}, /* Half Mini Card */ |
| 3894 | {IWL_PCI_DEVICE(0x4232, 0x1226, iwl5100_abg_cfg)}, /* Mini Card */ |
| 3895 | {IWL_PCI_DEVICE(0x4232, 0x1326, iwl5100_abg_cfg)}, /* Half Mini Card */ |
| 3896 | {IWL_PCI_DEVICE(0x4237, 0x1211, iwl5100_agn_cfg)}, /* Mini Card */ |
| 3897 | {IWL_PCI_DEVICE(0x4237, 0x1311, iwl5100_agn_cfg)}, /* Half Mini Card */ |
| 3898 | {IWL_PCI_DEVICE(0x4237, 0x1214, iwl5100_agn_cfg)}, /* Mini Card */ |
| 3899 | {IWL_PCI_DEVICE(0x4237, 0x1314, iwl5100_agn_cfg)}, /* Half Mini Card */ |
| 3900 | {IWL_PCI_DEVICE(0x4237, 0x1215, iwl5100_bgn_cfg)}, /* Mini Card */ |
| 3901 | {IWL_PCI_DEVICE(0x4237, 0x1315, iwl5100_bgn_cfg)}, /* Half Mini Card */ |
| 3902 | {IWL_PCI_DEVICE(0x4237, 0x1216, iwl5100_abg_cfg)}, /* Mini Card */ |
| 3903 | {IWL_PCI_DEVICE(0x4237, 0x1316, iwl5100_abg_cfg)}, /* Half Mini Card */ |
| 3904 | |
| 3905 | /* 5300 Series WiFi */ |
| 3906 | {IWL_PCI_DEVICE(0x4235, 0x1021, iwl5300_agn_cfg)}, /* Mini Card */ |
| 3907 | {IWL_PCI_DEVICE(0x4235, 0x1121, iwl5300_agn_cfg)}, /* Half Mini Card */ |
| 3908 | {IWL_PCI_DEVICE(0x4235, 0x1024, iwl5300_agn_cfg)}, /* Mini Card */ |
| 3909 | {IWL_PCI_DEVICE(0x4235, 0x1124, iwl5300_agn_cfg)}, /* Half Mini Card */ |
| 3910 | {IWL_PCI_DEVICE(0x4235, 0x1001, iwl5300_agn_cfg)}, /* Mini Card */ |
| 3911 | {IWL_PCI_DEVICE(0x4235, 0x1101, iwl5300_agn_cfg)}, /* Half Mini Card */ |
| 3912 | {IWL_PCI_DEVICE(0x4235, 0x1004, iwl5300_agn_cfg)}, /* Mini Card */ |
| 3913 | {IWL_PCI_DEVICE(0x4235, 0x1104, iwl5300_agn_cfg)}, /* Half Mini Card */ |
| 3914 | {IWL_PCI_DEVICE(0x4236, 0x1011, iwl5300_agn_cfg)}, /* Mini Card */ |
| 3915 | {IWL_PCI_DEVICE(0x4236, 0x1111, iwl5300_agn_cfg)}, /* Half Mini Card */ |
| 3916 | {IWL_PCI_DEVICE(0x4236, 0x1014, iwl5300_agn_cfg)}, /* Mini Card */ |
| 3917 | {IWL_PCI_DEVICE(0x4236, 0x1114, iwl5300_agn_cfg)}, /* Half Mini Card */ |
| 3918 | |
| 3919 | /* 5350 Series WiFi/WiMax */ |
| 3920 | {IWL_PCI_DEVICE(0x423A, 0x1001, iwl5350_agn_cfg)}, /* Mini Card */ |
| 3921 | {IWL_PCI_DEVICE(0x423A, 0x1021, iwl5350_agn_cfg)}, /* Mini Card */ |
| 3922 | {IWL_PCI_DEVICE(0x423B, 0x1011, iwl5350_agn_cfg)}, /* Mini Card */ |
| 3923 | |
| 3924 | /* 5150 Series Wifi/WiMax */ |
| 3925 | {IWL_PCI_DEVICE(0x423C, 0x1201, iwl5150_agn_cfg)}, /* Mini Card */ |
| 3926 | {IWL_PCI_DEVICE(0x423C, 0x1301, iwl5150_agn_cfg)}, /* Half Mini Card */ |
| 3927 | {IWL_PCI_DEVICE(0x423C, 0x1206, iwl5150_abg_cfg)}, /* Mini Card */ |
| 3928 | {IWL_PCI_DEVICE(0x423C, 0x1306, iwl5150_abg_cfg)}, /* Half Mini Card */ |
| 3929 | {IWL_PCI_DEVICE(0x423C, 0x1221, iwl5150_agn_cfg)}, /* Mini Card */ |
| 3930 | {IWL_PCI_DEVICE(0x423C, 0x1321, iwl5150_agn_cfg)}, /* Half Mini Card */ |
| 3931 | |
| 3932 | {IWL_PCI_DEVICE(0x423D, 0x1211, iwl5150_agn_cfg)}, /* Mini Card */ |
| 3933 | {IWL_PCI_DEVICE(0x423D, 0x1311, iwl5150_agn_cfg)}, /* Half Mini Card */ |
| 3934 | {IWL_PCI_DEVICE(0x423D, 0x1216, iwl5150_abg_cfg)}, /* Mini Card */ |
| 3935 | {IWL_PCI_DEVICE(0x423D, 0x1316, iwl5150_abg_cfg)}, /* Half Mini Card */ |
Wey-Yi Guy | 5953a62 | 2009-09-17 10:43:53 -0700 | [diff] [blame] | 3936 | |
| 3937 | /* 6x00 Series */ |
Wey-Yi Guy | 5953a62 | 2009-09-17 10:43:53 -0700 | [diff] [blame] | 3938 | {IWL_PCI_DEVICE(0x422B, 0x1101, iwl6000_3agn_cfg)}, |
| 3939 | {IWL_PCI_DEVICE(0x422B, 0x1121, iwl6000_3agn_cfg)}, |
| 3940 | {IWL_PCI_DEVICE(0x422C, 0x1301, iwl6000i_2agn_cfg)}, |
| 3941 | {IWL_PCI_DEVICE(0x422C, 0x1306, iwl6000i_2abg_cfg)}, |
| 3942 | {IWL_PCI_DEVICE(0x422C, 0x1307, iwl6000i_2bg_cfg)}, |
| 3943 | {IWL_PCI_DEVICE(0x422C, 0x1321, iwl6000i_2agn_cfg)}, |
| 3944 | {IWL_PCI_DEVICE(0x422C, 0x1326, iwl6000i_2abg_cfg)}, |
| 3945 | {IWL_PCI_DEVICE(0x4238, 0x1111, iwl6000_3agn_cfg)}, |
| 3946 | {IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)}, |
| 3947 | {IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)}, |
Shanyu Zhao | 4b3e806 | 2010-04-07 18:06:36 -0700 | [diff] [blame] | 3948 | |
Wey-Yi Guy | 003ea98 | 2010-12-15 08:06:23 -0800 | [diff] [blame] | 3949 | /* 6x05 Series */ |
Wey-Yi Guy | 8b3ee29 | 2010-11-18 11:41:48 -0800 | [diff] [blame] | 3950 | {IWL_PCI_DEVICE(0x0082, 0x1301, iwl6005_2agn_cfg)}, |
| 3951 | {IWL_PCI_DEVICE(0x0082, 0x1306, iwl6005_2abg_cfg)}, |
| 3952 | {IWL_PCI_DEVICE(0x0082, 0x1307, iwl6005_2bg_cfg)}, |
| 3953 | {IWL_PCI_DEVICE(0x0082, 0x1321, iwl6005_2agn_cfg)}, |
| 3954 | {IWL_PCI_DEVICE(0x0082, 0x1326, iwl6005_2abg_cfg)}, |
| 3955 | {IWL_PCI_DEVICE(0x0085, 0x1311, iwl6005_2agn_cfg)}, |
| 3956 | {IWL_PCI_DEVICE(0x0085, 0x1316, iwl6005_2abg_cfg)}, |
Shanyu Zhao | 1808972 | 2010-05-06 10:15:21 -0700 | [diff] [blame] | 3957 | |
Wey-Yi Guy | 003ea98 | 2010-12-15 08:06:23 -0800 | [diff] [blame] | 3958 | /* 6x30 Series */ |
Wey-Yi Guy | 8b3ee29 | 2010-11-18 11:41:48 -0800 | [diff] [blame] | 3959 | {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, |
| 3960 | {IWL_PCI_DEVICE(0x008A, 0x5307, iwl1030_bg_cfg)}, |
| 3961 | {IWL_PCI_DEVICE(0x008A, 0x5325, iwl1030_bgn_cfg)}, |
| 3962 | {IWL_PCI_DEVICE(0x008A, 0x5327, iwl1030_bg_cfg)}, |
| 3963 | {IWL_PCI_DEVICE(0x008B, 0x5315, iwl1030_bgn_cfg)}, |
| 3964 | {IWL_PCI_DEVICE(0x008B, 0x5317, iwl1030_bg_cfg)}, |
| 3965 | {IWL_PCI_DEVICE(0x0090, 0x5211, iwl6030_2agn_cfg)}, |
| 3966 | {IWL_PCI_DEVICE(0x0090, 0x5215, iwl6030_2bgn_cfg)}, |
| 3967 | {IWL_PCI_DEVICE(0x0090, 0x5216, iwl6030_2abg_cfg)}, |
| 3968 | {IWL_PCI_DEVICE(0x0091, 0x5201, iwl6030_2agn_cfg)}, |
| 3969 | {IWL_PCI_DEVICE(0x0091, 0x5205, iwl6030_2bgn_cfg)}, |
| 3970 | {IWL_PCI_DEVICE(0x0091, 0x5206, iwl6030_2abg_cfg)}, |
| 3971 | {IWL_PCI_DEVICE(0x0091, 0x5207, iwl6030_2bg_cfg)}, |
| 3972 | {IWL_PCI_DEVICE(0x0091, 0x5221, iwl6030_2agn_cfg)}, |
| 3973 | {IWL_PCI_DEVICE(0x0091, 0x5225, iwl6030_2bgn_cfg)}, |
| 3974 | {IWL_PCI_DEVICE(0x0091, 0x5226, iwl6030_2abg_cfg)}, |
Wey-Yi Guy | 5953a62 | 2009-09-17 10:43:53 -0700 | [diff] [blame] | 3975 | |
| 3976 | /* 6x50 WiFi/WiMax Series */ |
Wey-Yi Guy | 5953a62 | 2009-09-17 10:43:53 -0700 | [diff] [blame] | 3977 | {IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)}, |
| 3978 | {IWL_PCI_DEVICE(0x0087, 0x1306, iwl6050_2abg_cfg)}, |
| 3979 | {IWL_PCI_DEVICE(0x0087, 0x1321, iwl6050_2agn_cfg)}, |
| 3980 | {IWL_PCI_DEVICE(0x0087, 0x1326, iwl6050_2abg_cfg)}, |
Wey-Yi Guy | 5953a62 | 2009-09-17 10:43:53 -0700 | [diff] [blame] | 3981 | {IWL_PCI_DEVICE(0x0089, 0x1311, iwl6050_2agn_cfg)}, |
| 3982 | {IWL_PCI_DEVICE(0x0089, 0x1316, iwl6050_2abg_cfg)}, |
| 3983 | |
Wey-Yi Guy | 003ea98 | 2010-12-15 08:06:23 -0800 | [diff] [blame] | 3984 | /* 6150 WiFi/WiMax Series */ |
Wey-Yi Guy | 8b3ee29 | 2010-11-18 11:41:48 -0800 | [diff] [blame] | 3985 | {IWL_PCI_DEVICE(0x0885, 0x1305, iwl6150_bgn_cfg)}, |
| 3986 | {IWL_PCI_DEVICE(0x0885, 0x1306, iwl6150_bgn_cfg)}, |
| 3987 | {IWL_PCI_DEVICE(0x0885, 0x1325, iwl6150_bgn_cfg)}, |
| 3988 | {IWL_PCI_DEVICE(0x0885, 0x1326, iwl6150_bgn_cfg)}, |
| 3989 | {IWL_PCI_DEVICE(0x0886, 0x1315, iwl6150_bgn_cfg)}, |
| 3990 | {IWL_PCI_DEVICE(0x0886, 0x1316, iwl6150_bgn_cfg)}, |
Shanyu Zhao | 0326433 | 2010-06-29 17:27:27 -0700 | [diff] [blame] | 3991 | |
Jay Sternberg | 77dcb6a | 2009-03-06 13:52:55 -0800 | [diff] [blame] | 3992 | /* 1000 Series WiFi */ |
Wey-Yi Guy | 4bd0914f | 2009-09-17 10:43:52 -0700 | [diff] [blame] | 3993 | {IWL_PCI_DEVICE(0x0083, 0x1205, iwl1000_bgn_cfg)}, |
| 3994 | {IWL_PCI_DEVICE(0x0083, 0x1305, iwl1000_bgn_cfg)}, |
| 3995 | {IWL_PCI_DEVICE(0x0083, 0x1225, iwl1000_bgn_cfg)}, |
| 3996 | {IWL_PCI_DEVICE(0x0083, 0x1325, iwl1000_bgn_cfg)}, |
| 3997 | {IWL_PCI_DEVICE(0x0084, 0x1215, iwl1000_bgn_cfg)}, |
| 3998 | {IWL_PCI_DEVICE(0x0084, 0x1315, iwl1000_bgn_cfg)}, |
| 3999 | {IWL_PCI_DEVICE(0x0083, 0x1206, iwl1000_bg_cfg)}, |
| 4000 | {IWL_PCI_DEVICE(0x0083, 0x1306, iwl1000_bg_cfg)}, |
| 4001 | {IWL_PCI_DEVICE(0x0083, 0x1226, iwl1000_bg_cfg)}, |
| 4002 | {IWL_PCI_DEVICE(0x0083, 0x1326, iwl1000_bg_cfg)}, |
| 4003 | {IWL_PCI_DEVICE(0x0084, 0x1216, iwl1000_bg_cfg)}, |
| 4004 | {IWL_PCI_DEVICE(0x0084, 0x1316, iwl1000_bg_cfg)}, |
Jay Sternberg | 1de19ec | 2010-09-14 15:21:20 -0700 | [diff] [blame] | 4005 | |
Wey-Yi Guy | 58a3909 | 2010-10-06 08:14:21 -0700 | [diff] [blame] | 4006 | /* 100 Series WiFi */ |
Jay Sternberg | 1de19ec | 2010-09-14 15:21:20 -0700 | [diff] [blame] | 4007 | {IWL_PCI_DEVICE(0x08AE, 0x1005, iwl100_bgn_cfg)}, |
Jay Sternberg | 1de19ec | 2010-09-14 15:21:20 -0700 | [diff] [blame] | 4008 | {IWL_PCI_DEVICE(0x08AE, 0x1007, iwl100_bg_cfg)}, |
Wey-Yi Guy | 2a21ff4 | 2010-11-10 09:56:37 -0800 | [diff] [blame] | 4009 | {IWL_PCI_DEVICE(0x08AF, 0x1015, iwl100_bgn_cfg)}, |
| 4010 | {IWL_PCI_DEVICE(0x08AF, 0x1017, iwl100_bg_cfg)}, |
| 4011 | {IWL_PCI_DEVICE(0x08AE, 0x1025, iwl100_bgn_cfg)}, |
| 4012 | {IWL_PCI_DEVICE(0x08AE, 0x1027, iwl100_bg_cfg)}, |
Wey-Yi Guy | 58a3909 | 2010-10-06 08:14:21 -0700 | [diff] [blame] | 4013 | |
| 4014 | /* 130 Series WiFi */ |
| 4015 | {IWL_PCI_DEVICE(0x0896, 0x5005, iwl130_bgn_cfg)}, |
| 4016 | {IWL_PCI_DEVICE(0x0896, 0x5007, iwl130_bg_cfg)}, |
| 4017 | {IWL_PCI_DEVICE(0x0897, 0x5015, iwl130_bgn_cfg)}, |
| 4018 | {IWL_PCI_DEVICE(0x0897, 0x5017, iwl130_bg_cfg)}, |
| 4019 | {IWL_PCI_DEVICE(0x0896, 0x5025, iwl130_bgn_cfg)}, |
| 4020 | {IWL_PCI_DEVICE(0x0896, 0x5027, iwl130_bg_cfg)}, |
| 4021 | |
Wey-Yi Guy | 04b8e75 | 2011-01-08 11:47:56 -0800 | [diff] [blame] | 4022 | /* 2x00 Series */ |
| 4023 | {IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)}, |
| 4024 | {IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)}, |
| 4025 | {IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)}, |
| 4026 | {IWL_PCI_DEVICE(0x0890, 0x4026, iwl2000_2bg_cfg)}, |
| 4027 | {IWL_PCI_DEVICE(0x0891, 0x4226, iwl2000_2bg_cfg)}, |
| 4028 | {IWL_PCI_DEVICE(0x0890, 0x4426, iwl2000_2bg_cfg)}, |
| 4029 | |
| 4030 | /* 2x30 Series */ |
| 4031 | {IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)}, |
| 4032 | {IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)}, |
| 4033 | {IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)}, |
| 4034 | {IWL_PCI_DEVICE(0x0887, 0x4066, iwl2030_2bg_cfg)}, |
| 4035 | {IWL_PCI_DEVICE(0x0888, 0x4266, iwl2030_2bg_cfg)}, |
| 4036 | {IWL_PCI_DEVICE(0x0887, 0x4466, iwl2030_2bg_cfg)}, |
| 4037 | |
| 4038 | /* 6x35 Series */ |
| 4039 | {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, |
| 4040 | {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, |
| 4041 | {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, |
| 4042 | {IWL_PCI_DEVICE(0x088E, 0x4064, iwl6035_2abg_cfg)}, |
| 4043 | {IWL_PCI_DEVICE(0x088F, 0x4264, iwl6035_2abg_cfg)}, |
| 4044 | {IWL_PCI_DEVICE(0x088E, 0x4464, iwl6035_2abg_cfg)}, |
| 4045 | {IWL_PCI_DEVICE(0x088E, 0x4066, iwl6035_2bg_cfg)}, |
| 4046 | {IWL_PCI_DEVICE(0x088F, 0x4266, iwl6035_2bg_cfg)}, |
| 4047 | {IWL_PCI_DEVICE(0x088E, 0x4466, iwl6035_2bg_cfg)}, |
| 4048 | |
Wey-Yi Guy | b4ed221 | 2011-04-30 08:55:16 -0700 | [diff] [blame] | 4049 | /* 105 Series */ |
| 4050 | {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, |
| 4051 | {IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)}, |
| 4052 | {IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)}, |
| 4053 | {IWL_PCI_DEVICE(0x0894, 0x0026, iwl105_bg_cfg)}, |
| 4054 | {IWL_PCI_DEVICE(0x0895, 0x0226, iwl105_bg_cfg)}, |
| 4055 | {IWL_PCI_DEVICE(0x0894, 0x0426, iwl105_bg_cfg)}, |
Wey-Yi Guy | 04b8e75 | 2011-01-08 11:47:56 -0800 | [diff] [blame] | 4056 | |
Wey-Yi Guy | b4ed221 | 2011-04-30 08:55:16 -0700 | [diff] [blame] | 4057 | /* 135 Series */ |
| 4058 | {IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)}, |
| 4059 | {IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)}, |
| 4060 | {IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)}, |
| 4061 | {IWL_PCI_DEVICE(0x0892, 0x0066, iwl135_bg_cfg)}, |
| 4062 | {IWL_PCI_DEVICE(0x0893, 0x0266, iwl135_bg_cfg)}, |
| 4063 | {IWL_PCI_DEVICE(0x0892, 0x0466, iwl135_bg_cfg)}, |
Wey-Yi Guy | 04b8e75 | 2011-01-08 11:47:56 -0800 | [diff] [blame] | 4064 | |
Ron Rindjunsky | fed9017 | 2008-04-15 16:01:41 -0700 | [diff] [blame] | 4065 | {0} |
| 4066 | }; |
| 4067 | MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids); |
| 4068 | |
| 4069 | static struct pci_driver iwl_driver = { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4070 | .name = DRV_NAME, |
Ron Rindjunsky | fed9017 | 2008-04-15 16:01:41 -0700 | [diff] [blame] | 4071 | .id_table = iwl_hw_card_ids, |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 4072 | .probe = iwl_pci_probe, |
| 4073 | .remove = __devexit_p(iwl_pci_remove), |
John W. Linville | f60dc01 | 2010-10-25 16:12:37 -0400 | [diff] [blame] | 4074 | .driver.pm = IWL_PM_OPS, |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4075 | }; |
| 4076 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 4077 | static int __init iwl_init(void) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4078 | { |
| 4079 | |
| 4080 | int ret; |
Joe Perches | c96c31e | 2010-07-26 14:39:58 -0700 | [diff] [blame] | 4081 | pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); |
| 4082 | pr_info(DRV_COPYRIGHT "\n"); |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 4083 | |
Tomas Winkler | e227cea | 2008-07-18 13:53:05 +0800 | [diff] [blame] | 4084 | ret = iwlagn_rate_control_register(); |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 4085 | if (ret) { |
Joe Perches | c96c31e | 2010-07-26 14:39:58 -0700 | [diff] [blame] | 4086 | pr_err("Unable to register rate control algorithm: %d\n", ret); |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 4087 | return ret; |
| 4088 | } |
| 4089 | |
Ron Rindjunsky | fed9017 | 2008-04-15 16:01:41 -0700 | [diff] [blame] | 4090 | ret = pci_register_driver(&iwl_driver); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4091 | if (ret) { |
Joe Perches | c96c31e | 2010-07-26 14:39:58 -0700 | [diff] [blame] | 4092 | pr_err("Unable to initialize PCI module\n"); |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 4093 | goto error_register; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4094 | } |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4095 | |
| 4096 | return ret; |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 4097 | |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 4098 | error_register: |
Tomas Winkler | e227cea | 2008-07-18 13:53:05 +0800 | [diff] [blame] | 4099 | iwlagn_rate_control_unregister(); |
Reinette Chatre | 897e1cf | 2008-03-28 16:21:09 -0700 | [diff] [blame] | 4100 | return ret; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4101 | } |
| 4102 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 4103 | static void __exit iwl_exit(void) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4104 | { |
Ron Rindjunsky | fed9017 | 2008-04-15 16:01:41 -0700 | [diff] [blame] | 4105 | pci_unregister_driver(&iwl_driver); |
Tomas Winkler | e227cea | 2008-07-18 13:53:05 +0800 | [diff] [blame] | 4106 | iwlagn_rate_control_unregister(); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 4107 | } |
| 4108 | |
Emmanuel Grumbach | 5b9f8cd | 2008-10-29 14:05:46 -0700 | [diff] [blame] | 4109 | module_exit(iwl_exit); |
| 4110 | module_init(iwl_init); |
Reinette Chatre | a562a9d | 2009-07-17 09:30:24 -0700 | [diff] [blame] | 4111 | |
| 4112 | #ifdef CONFIG_IWLWIFI_DEBUG |
Wey-Yi Guy | 4e30cb6 | 2009-09-17 10:43:47 -0700 | [diff] [blame] | 4113 | module_param_named(debug, iwl_debug_level, uint, S_IRUGO | S_IWUSR); |
Reinette Chatre | a562a9d | 2009-07-17 09:30:24 -0700 | [diff] [blame] | 4114 | MODULE_PARM_DESC(debug, "debug output mask"); |
| 4115 | #endif |
| 4116 | |
Wey-Yi Guy | 2b06861 | 2010-03-22 09:17:39 -0700 | [diff] [blame] | 4117 | module_param_named(swcrypto, iwlagn_mod_params.sw_crypto, int, S_IRUGO); |
| 4118 | MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); |
Wey-Yi Guy | 2b06861 | 2010-03-22 09:17:39 -0700 | [diff] [blame] | 4119 | module_param_named(queues_num, iwlagn_mod_params.num_of_queues, int, S_IRUGO); |
| 4120 | MODULE_PARM_DESC(queues_num, "number of hw queues."); |
Wey-Yi Guy | 2b06861 | 2010-03-22 09:17:39 -0700 | [diff] [blame] | 4121 | module_param_named(11n_disable, iwlagn_mod_params.disable_11n, int, S_IRUGO); |
| 4122 | MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); |
Wey-Yi Guy | 2b06861 | 2010-03-22 09:17:39 -0700 | [diff] [blame] | 4123 | module_param_named(amsdu_size_8K, iwlagn_mod_params.amsdu_size_8K, |
| 4124 | int, S_IRUGO); |
| 4125 | MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); |
Wey-Yi Guy | 2b06861 | 2010-03-22 09:17:39 -0700 | [diff] [blame] | 4126 | module_param_named(fw_restart, iwlagn_mod_params.restart_fw, int, S_IRUGO); |
| 4127 | MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); |
Johannes Berg | dd7a250 | 2010-04-28 23:33:10 -0700 | [diff] [blame] | 4128 | |
| 4129 | module_param_named(ucode_alternative, iwlagn_wanted_ucode_alternative, int, |
| 4130 | S_IRUGO); |
| 4131 | MODULE_PARM_DESC(ucode_alternative, |
| 4132 | "specify ucode alternative to use from ucode file"); |
Wey-Yi Guy | bee008b | 2010-08-23 07:57:04 -0700 | [diff] [blame] | 4133 | |
| 4134 | module_param_named(antenna_coupling, iwlagn_ant_coupling, int, S_IRUGO); |
| 4135 | MODULE_PARM_DESC(antenna_coupling, |
| 4136 | "specify antenna coupling in dB (defualt: 0 dB)"); |
Wey-Yi Guy | f37837c | 2010-08-23 07:57:12 -0700 | [diff] [blame] | 4137 | |
Wey-Yi Guy | 9f28ebc | 2010-11-26 13:24:19 -0800 | [diff] [blame] | 4138 | module_param_named(bt_ch_inhibition, iwlagn_bt_ch_announce, bool, S_IRUGO); |
| 4139 | MODULE_PARM_DESC(bt_ch_inhibition, |
| 4140 | "Disable BT channel inhibition (default: enable)"); |
Stanislaw Gruszka | b7977ff | 2011-02-28 14:33:15 +0100 | [diff] [blame] | 4141 | |
| 4142 | module_param_named(plcp_check, iwlagn_mod_params.plcp_check, bool, S_IRUGO); |
| 4143 | MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])"); |
| 4144 | |
| 4145 | module_param_named(ack_check, iwlagn_mod_params.ack_check, bool, S_IRUGO); |
| 4146 | MODULE_PARM_DESC(ack_check, "Check ack health (default: 0 [disabled])"); |