Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. |
| 4 | * |
| 5 | * 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: |
| 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | * |
| 28 | *****************************************************************************/ |
| 29 | |
| 30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 31 | |
| 32 | #include <linux/kernel.h> |
| 33 | #include <linux/module.h> |
| 34 | #include <linux/init.h> |
| 35 | #include <linux/pci.h> |
| 36 | #include <linux/pci-aspm.h> |
| 37 | #include <linux/slab.h> |
| 38 | #include <linux/dma-mapping.h> |
| 39 | #include <linux/delay.h> |
| 40 | #include <linux/sched.h> |
| 41 | #include <linux/skbuff.h> |
| 42 | #include <linux/netdevice.h> |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 43 | #include <linux/firmware.h> |
| 44 | #include <linux/etherdevice.h> |
| 45 | #include <linux/if_arp.h> |
| 46 | |
| 47 | #include <net/mac80211.h> |
| 48 | |
| 49 | #include <asm/div64.h> |
| 50 | |
| 51 | #define DRV_NAME "iwl4965" |
| 52 | |
| 53 | #include "iwl-eeprom.h" |
| 54 | #include "iwl-dev.h" |
| 55 | #include "iwl-core.h" |
| 56 | #include "iwl-io.h" |
| 57 | #include "iwl-helpers.h" |
| 58 | #include "iwl-sta.h" |
| 59 | #include "iwl-4965-calib.h" |
| 60 | #include "iwl-4965.h" |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 61 | |
| 62 | |
| 63 | /****************************************************************************** |
| 64 | * |
| 65 | * module boiler plate |
| 66 | * |
| 67 | ******************************************************************************/ |
| 68 | |
| 69 | /* |
| 70 | * module name, copyright, version, etc. |
| 71 | */ |
| 72 | #define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux" |
| 73 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 74 | #ifdef CONFIG_IWLEGACY_DEBUG |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 75 | #define VD "d" |
| 76 | #else |
| 77 | #define VD |
| 78 | #endif |
| 79 | |
| 80 | #define DRV_VERSION IWLWIFI_VERSION VD |
| 81 | |
| 82 | |
| 83 | MODULE_DESCRIPTION(DRV_DESCRIPTION); |
| 84 | MODULE_VERSION(DRV_VERSION); |
| 85 | MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); |
| 86 | MODULE_LICENSE("GPL"); |
| 87 | MODULE_ALIAS("iwl4965"); |
| 88 | |
Stanislaw Gruszka | eb3cdfb | 2011-08-30 12:58:35 +0200 | [diff] [blame^] | 89 | static struct il_link_quality_cmd * |
| 90 | il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) |
| 91 | { |
| 92 | int i, r; |
| 93 | struct il_link_quality_cmd *link_cmd; |
| 94 | u32 rate_flags = 0; |
| 95 | __le32 rate_n_flags; |
| 96 | |
| 97 | link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); |
| 98 | if (!link_cmd) { |
| 99 | IL_ERR("Unable to allocate memory for LQ cmd.\n"); |
| 100 | return NULL; |
| 101 | } |
| 102 | /* Set up the rate scaling to start at selected rate, fall back |
| 103 | * all the way down to 1M in IEEE order, and then spin on 1M */ |
| 104 | if (il->band == IEEE80211_BAND_5GHZ) |
| 105 | r = RATE_6M_IDX; |
| 106 | else |
| 107 | r = RATE_1M_IDX; |
| 108 | |
| 109 | if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) |
| 110 | rate_flags |= RATE_MCS_CCK_MSK; |
| 111 | |
| 112 | rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << |
| 113 | RATE_MCS_ANT_POS; |
| 114 | rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, |
| 115 | rate_flags); |
| 116 | for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) |
| 117 | link_cmd->rs_table[i].rate_n_flags = rate_n_flags; |
| 118 | |
| 119 | link_cmd->general_params.single_stream_ant_msk = |
| 120 | il4965_first_antenna(il->hw_params.valid_tx_ant); |
| 121 | |
| 122 | link_cmd->general_params.dual_stream_ant_msk = |
| 123 | il->hw_params.valid_tx_ant & |
| 124 | ~il4965_first_antenna(il->hw_params.valid_tx_ant); |
| 125 | if (!link_cmd->general_params.dual_stream_ant_msk) { |
| 126 | link_cmd->general_params.dual_stream_ant_msk = ANT_AB; |
| 127 | } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { |
| 128 | link_cmd->general_params.dual_stream_ant_msk = |
| 129 | il->hw_params.valid_tx_ant; |
| 130 | } |
| 131 | |
| 132 | link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; |
| 133 | link_cmd->agg_params.agg_time_limit = |
| 134 | cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); |
| 135 | |
| 136 | link_cmd->sta_id = sta_id; |
| 137 | |
| 138 | return link_cmd; |
| 139 | } |
| 140 | |
| 141 | /* |
| 142 | * il4965_add_bssid_station - Add the special IBSS BSSID station |
| 143 | * |
| 144 | * Function sleeps. |
| 145 | */ |
| 146 | int |
| 147 | il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, |
| 148 | const u8 *addr, u8 *sta_id_r) |
| 149 | { |
| 150 | int ret; |
| 151 | u8 sta_id; |
| 152 | struct il_link_quality_cmd *link_cmd; |
| 153 | unsigned long flags; |
| 154 | |
| 155 | if (sta_id_r) |
| 156 | *sta_id_r = IL_INVALID_STATION; |
| 157 | |
| 158 | ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); |
| 159 | if (ret) { |
| 160 | IL_ERR("Unable to add station %pM\n", addr); |
| 161 | return ret; |
| 162 | } |
| 163 | |
| 164 | if (sta_id_r) |
| 165 | *sta_id_r = sta_id; |
| 166 | |
| 167 | spin_lock_irqsave(&il->sta_lock, flags); |
| 168 | il->stations[sta_id].used |= IL_STA_LOCAL; |
| 169 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 170 | |
| 171 | /* Set up default rate scaling table in device's station table */ |
| 172 | link_cmd = il4965_sta_alloc_lq(il, sta_id); |
| 173 | if (!link_cmd) { |
| 174 | IL_ERR( |
| 175 | "Unable to initialize rate scaling for station %pM.\n", |
| 176 | addr); |
| 177 | return -ENOMEM; |
| 178 | } |
| 179 | |
| 180 | ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); |
| 181 | if (ret) |
| 182 | IL_ERR("Link quality command failed (%d)\n", ret); |
| 183 | |
| 184 | spin_lock_irqsave(&il->sta_lock, flags); |
| 185 | il->stations[sta_id].lq = link_cmd; |
| 186 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | static int il4965_static_wepkey_cmd(struct il_priv *il, |
| 192 | struct il_rxon_context *ctx, |
| 193 | bool send_if_empty) |
| 194 | { |
| 195 | int i, not_empty = 0; |
| 196 | u8 buff[sizeof(struct il_wep_cmd) + |
| 197 | sizeof(struct il_wep_key) * WEP_KEYS_MAX]; |
| 198 | struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; |
| 199 | size_t cmd_size = sizeof(struct il_wep_cmd); |
| 200 | struct il_host_cmd cmd = { |
| 201 | .id = ctx->wep_key_cmd, |
| 202 | .data = wep_cmd, |
| 203 | .flags = CMD_SYNC, |
| 204 | }; |
| 205 | |
| 206 | might_sleep(); |
| 207 | |
| 208 | memset(wep_cmd, 0, cmd_size + |
| 209 | (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); |
| 210 | |
| 211 | for (i = 0; i < WEP_KEYS_MAX ; i++) { |
| 212 | wep_cmd->key[i].key_idx = i; |
| 213 | if (ctx->wep_keys[i].key_size) { |
| 214 | wep_cmd->key[i].key_offset = i; |
| 215 | not_empty = 1; |
| 216 | } else { |
| 217 | wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; |
| 218 | } |
| 219 | |
| 220 | wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; |
| 221 | memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, |
| 222 | ctx->wep_keys[i].key_size); |
| 223 | } |
| 224 | |
| 225 | wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; |
| 226 | wep_cmd->num_keys = WEP_KEYS_MAX; |
| 227 | |
| 228 | cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; |
| 229 | |
| 230 | cmd.len = cmd_size; |
| 231 | |
| 232 | if (not_empty || send_if_empty) |
| 233 | return il_send_cmd(il, &cmd); |
| 234 | else |
| 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | int il4965_restore_default_wep_keys(struct il_priv *il, |
| 239 | struct il_rxon_context *ctx) |
| 240 | { |
| 241 | lockdep_assert_held(&il->mutex); |
| 242 | |
| 243 | return il4965_static_wepkey_cmd(il, ctx, false); |
| 244 | } |
| 245 | |
| 246 | int il4965_remove_default_wep_key(struct il_priv *il, |
| 247 | struct il_rxon_context *ctx, |
| 248 | struct ieee80211_key_conf *keyconf) |
| 249 | { |
| 250 | int ret; |
| 251 | |
| 252 | lockdep_assert_held(&il->mutex); |
| 253 | |
| 254 | D_WEP("Removing default WEP key: idx=%d\n", |
| 255 | keyconf->keyidx); |
| 256 | |
| 257 | memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); |
| 258 | if (il_is_rfkill(il)) { |
| 259 | D_WEP( |
| 260 | "Not sending REPLY_WEPKEY command due to RFKILL.\n"); |
| 261 | /* but keys in device are clear anyway so return success */ |
| 262 | return 0; |
| 263 | } |
| 264 | ret = il4965_static_wepkey_cmd(il, ctx, 1); |
| 265 | D_WEP("Remove default WEP key: idx=%d ret=%d\n", |
| 266 | keyconf->keyidx, ret); |
| 267 | |
| 268 | return ret; |
| 269 | } |
| 270 | |
| 271 | int il4965_set_default_wep_key(struct il_priv *il, |
| 272 | struct il_rxon_context *ctx, |
| 273 | struct ieee80211_key_conf *keyconf) |
| 274 | { |
| 275 | int ret; |
| 276 | |
| 277 | lockdep_assert_held(&il->mutex); |
| 278 | |
| 279 | if (keyconf->keylen != WEP_KEY_LEN_128 && |
| 280 | keyconf->keylen != WEP_KEY_LEN_64) { |
| 281 | D_WEP("Bad WEP key length %d\n", keyconf->keylen); |
| 282 | return -EINVAL; |
| 283 | } |
| 284 | |
| 285 | keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; |
| 286 | keyconf->hw_key_idx = HW_KEY_DEFAULT; |
| 287 | il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; |
| 288 | |
| 289 | ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; |
| 290 | memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, |
| 291 | keyconf->keylen); |
| 292 | |
| 293 | ret = il4965_static_wepkey_cmd(il, ctx, false); |
| 294 | D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", |
| 295 | keyconf->keylen, keyconf->keyidx, ret); |
| 296 | |
| 297 | return ret; |
| 298 | } |
| 299 | |
| 300 | static int il4965_set_wep_dynamic_key_info(struct il_priv *il, |
| 301 | struct il_rxon_context *ctx, |
| 302 | struct ieee80211_key_conf *keyconf, |
| 303 | u8 sta_id) |
| 304 | { |
| 305 | unsigned long flags; |
| 306 | __le16 key_flags = 0; |
| 307 | struct il_addsta_cmd sta_cmd; |
| 308 | |
| 309 | lockdep_assert_held(&il->mutex); |
| 310 | |
| 311 | keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; |
| 312 | |
| 313 | key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); |
| 314 | key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); |
| 315 | key_flags &= ~STA_KEY_FLG_INVALID; |
| 316 | |
| 317 | if (keyconf->keylen == WEP_KEY_LEN_128) |
| 318 | key_flags |= STA_KEY_FLG_KEY_SIZE_MSK; |
| 319 | |
| 320 | if (sta_id == ctx->bcast_sta_id) |
| 321 | key_flags |= STA_KEY_MULTICAST_MSK; |
| 322 | |
| 323 | spin_lock_irqsave(&il->sta_lock, flags); |
| 324 | |
| 325 | il->stations[sta_id].keyinfo.cipher = keyconf->cipher; |
| 326 | il->stations[sta_id].keyinfo.keylen = keyconf->keylen; |
| 327 | il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; |
| 328 | |
| 329 | memcpy(il->stations[sta_id].keyinfo.key, |
| 330 | keyconf->key, keyconf->keylen); |
| 331 | |
| 332 | memcpy(&il->stations[sta_id].sta.key.key[3], |
| 333 | keyconf->key, keyconf->keylen); |
| 334 | |
| 335 | if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) |
| 336 | == STA_KEY_FLG_NO_ENC) |
| 337 | il->stations[sta_id].sta.key.key_offset = |
| 338 | il_get_free_ucode_key_idx(il); |
| 339 | /* else, we are overriding an existing key => no need to allocated room |
| 340 | * in uCode. */ |
| 341 | |
| 342 | WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, |
| 343 | "no space for a new key"); |
| 344 | |
| 345 | il->stations[sta_id].sta.key.key_flags = key_flags; |
| 346 | il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; |
| 347 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 348 | |
| 349 | memcpy(&sta_cmd, &il->stations[sta_id].sta, |
| 350 | sizeof(struct il_addsta_cmd)); |
| 351 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 352 | |
| 353 | return il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
| 354 | } |
| 355 | |
| 356 | static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, |
| 357 | struct il_rxon_context *ctx, |
| 358 | struct ieee80211_key_conf *keyconf, |
| 359 | u8 sta_id) |
| 360 | { |
| 361 | unsigned long flags; |
| 362 | __le16 key_flags = 0; |
| 363 | struct il_addsta_cmd sta_cmd; |
| 364 | |
| 365 | lockdep_assert_held(&il->mutex); |
| 366 | |
| 367 | key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); |
| 368 | key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); |
| 369 | key_flags &= ~STA_KEY_FLG_INVALID; |
| 370 | |
| 371 | if (sta_id == ctx->bcast_sta_id) |
| 372 | key_flags |= STA_KEY_MULTICAST_MSK; |
| 373 | |
| 374 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
| 375 | |
| 376 | spin_lock_irqsave(&il->sta_lock, flags); |
| 377 | il->stations[sta_id].keyinfo.cipher = keyconf->cipher; |
| 378 | il->stations[sta_id].keyinfo.keylen = keyconf->keylen; |
| 379 | |
| 380 | memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, |
| 381 | keyconf->keylen); |
| 382 | |
| 383 | memcpy(il->stations[sta_id].sta.key.key, keyconf->key, |
| 384 | keyconf->keylen); |
| 385 | |
| 386 | if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) |
| 387 | == STA_KEY_FLG_NO_ENC) |
| 388 | il->stations[sta_id].sta.key.key_offset = |
| 389 | il_get_free_ucode_key_idx(il); |
| 390 | /* else, we are overriding an existing key => no need to allocated room |
| 391 | * in uCode. */ |
| 392 | |
| 393 | WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, |
| 394 | "no space for a new key"); |
| 395 | |
| 396 | il->stations[sta_id].sta.key.key_flags = key_flags; |
| 397 | il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; |
| 398 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 399 | |
| 400 | memcpy(&sta_cmd, &il->stations[sta_id].sta, |
| 401 | sizeof(struct il_addsta_cmd)); |
| 402 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 403 | |
| 404 | return il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
| 405 | } |
| 406 | |
| 407 | static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, |
| 408 | struct il_rxon_context *ctx, |
| 409 | struct ieee80211_key_conf *keyconf, |
| 410 | u8 sta_id) |
| 411 | { |
| 412 | unsigned long flags; |
| 413 | int ret = 0; |
| 414 | __le16 key_flags = 0; |
| 415 | |
| 416 | key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); |
| 417 | key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); |
| 418 | key_flags &= ~STA_KEY_FLG_INVALID; |
| 419 | |
| 420 | if (sta_id == ctx->bcast_sta_id) |
| 421 | key_flags |= STA_KEY_MULTICAST_MSK; |
| 422 | |
| 423 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
| 424 | keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
| 425 | |
| 426 | spin_lock_irqsave(&il->sta_lock, flags); |
| 427 | |
| 428 | il->stations[sta_id].keyinfo.cipher = keyconf->cipher; |
| 429 | il->stations[sta_id].keyinfo.keylen = 16; |
| 430 | |
| 431 | if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) |
| 432 | == STA_KEY_FLG_NO_ENC) |
| 433 | il->stations[sta_id].sta.key.key_offset = |
| 434 | il_get_free_ucode_key_idx(il); |
| 435 | /* else, we are overriding an existing key => no need to allocated room |
| 436 | * in uCode. */ |
| 437 | |
| 438 | WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, |
| 439 | "no space for a new key"); |
| 440 | |
| 441 | il->stations[sta_id].sta.key.key_flags = key_flags; |
| 442 | |
| 443 | |
| 444 | /* This copy is acutally not needed: we get the key with each TX */ |
| 445 | memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); |
| 446 | |
| 447 | memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); |
| 448 | |
| 449 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 450 | |
| 451 | return ret; |
| 452 | } |
| 453 | |
| 454 | void il4965_update_tkip_key(struct il_priv *il, |
| 455 | struct il_rxon_context *ctx, |
| 456 | struct ieee80211_key_conf *keyconf, |
| 457 | struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) |
| 458 | { |
| 459 | u8 sta_id; |
| 460 | unsigned long flags; |
| 461 | int i; |
| 462 | |
| 463 | if (il_scan_cancel(il)) { |
| 464 | /* cancel scan failed, just live w/ bad key and rely |
| 465 | briefly on SW decryption */ |
| 466 | return; |
| 467 | } |
| 468 | |
| 469 | sta_id = il_sta_id_or_broadcast(il, ctx, sta); |
| 470 | if (sta_id == IL_INVALID_STATION) |
| 471 | return; |
| 472 | |
| 473 | spin_lock_irqsave(&il->sta_lock, flags); |
| 474 | |
| 475 | il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; |
| 476 | |
| 477 | for (i = 0; i < 5; i++) |
| 478 | il->stations[sta_id].sta.key.tkip_rx_ttak[i] = |
| 479 | cpu_to_le16(phase1key[i]); |
| 480 | |
| 481 | il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; |
| 482 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 483 | |
| 484 | il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); |
| 485 | |
| 486 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 487 | |
| 488 | } |
| 489 | |
| 490 | int il4965_remove_dynamic_key(struct il_priv *il, |
| 491 | struct il_rxon_context *ctx, |
| 492 | struct ieee80211_key_conf *keyconf, |
| 493 | u8 sta_id) |
| 494 | { |
| 495 | unsigned long flags; |
| 496 | u16 key_flags; |
| 497 | u8 keyidx; |
| 498 | struct il_addsta_cmd sta_cmd; |
| 499 | |
| 500 | lockdep_assert_held(&il->mutex); |
| 501 | |
| 502 | ctx->key_mapping_keys--; |
| 503 | |
| 504 | spin_lock_irqsave(&il->sta_lock, flags); |
| 505 | key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); |
| 506 | keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; |
| 507 | |
| 508 | D_WEP("Remove dynamic key: idx=%d sta=%d\n", |
| 509 | keyconf->keyidx, sta_id); |
| 510 | |
| 511 | if (keyconf->keyidx != keyidx) { |
| 512 | /* We need to remove a key with idx different that the one |
| 513 | * in the uCode. This means that the key we need to remove has |
| 514 | * been replaced by another one with different idx. |
| 515 | * Don't do anything and return ok |
| 516 | */ |
| 517 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { |
| 522 | IL_WARN("Removing wrong key %d 0x%x\n", |
| 523 | keyconf->keyidx, key_flags); |
| 524 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, |
| 529 | &il->ucode_key_table)) |
| 530 | IL_ERR("idx %d not used in uCode key table.\n", |
| 531 | il->stations[sta_id].sta.key.key_offset); |
| 532 | memset(&il->stations[sta_id].keyinfo, 0, |
| 533 | sizeof(struct il_hw_key)); |
| 534 | memset(&il->stations[sta_id].sta.key, 0, |
| 535 | sizeof(struct il4965_keyinfo)); |
| 536 | il->stations[sta_id].sta.key.key_flags = |
| 537 | STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; |
| 538 | il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; |
| 539 | il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; |
| 540 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 541 | |
| 542 | if (il_is_rfkill(il)) { |
| 543 | D_WEP( |
| 544 | "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); |
| 545 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 546 | return 0; |
| 547 | } |
| 548 | memcpy(&sta_cmd, &il->stations[sta_id].sta, |
| 549 | sizeof(struct il_addsta_cmd)); |
| 550 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 551 | |
| 552 | return il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
| 553 | } |
| 554 | |
| 555 | int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, |
| 556 | struct ieee80211_key_conf *keyconf, u8 sta_id) |
| 557 | { |
| 558 | int ret; |
| 559 | |
| 560 | lockdep_assert_held(&il->mutex); |
| 561 | |
| 562 | ctx->key_mapping_keys++; |
| 563 | keyconf->hw_key_idx = HW_KEY_DYNAMIC; |
| 564 | |
| 565 | switch (keyconf->cipher) { |
| 566 | case WLAN_CIPHER_SUITE_CCMP: |
| 567 | ret = il4965_set_ccmp_dynamic_key_info(il, ctx, |
| 568 | keyconf, sta_id); |
| 569 | break; |
| 570 | case WLAN_CIPHER_SUITE_TKIP: |
| 571 | ret = il4965_set_tkip_dynamic_key_info(il, ctx, |
| 572 | keyconf, sta_id); |
| 573 | break; |
| 574 | case WLAN_CIPHER_SUITE_WEP40: |
| 575 | case WLAN_CIPHER_SUITE_WEP104: |
| 576 | ret = il4965_set_wep_dynamic_key_info(il, ctx, |
| 577 | keyconf, sta_id); |
| 578 | break; |
| 579 | default: |
| 580 | IL_ERR( |
| 581 | "Unknown alg: %s cipher = %x\n", __func__, |
| 582 | keyconf->cipher); |
| 583 | ret = -EINVAL; |
| 584 | } |
| 585 | |
| 586 | D_WEP( |
| 587 | "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", |
| 588 | keyconf->cipher, keyconf->keylen, keyconf->keyidx, |
| 589 | sta_id, ret); |
| 590 | |
| 591 | return ret; |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * il4965_alloc_bcast_station - add broadcast station into driver's station table. |
| 596 | * |
| 597 | * This adds the broadcast station into the driver's station table |
| 598 | * and marks it driver active, so that it will be restored to the |
| 599 | * device at the next best time. |
| 600 | */ |
| 601 | int il4965_alloc_bcast_station(struct il_priv *il, |
| 602 | struct il_rxon_context *ctx) |
| 603 | { |
| 604 | struct il_link_quality_cmd *link_cmd; |
| 605 | unsigned long flags; |
| 606 | u8 sta_id; |
| 607 | |
| 608 | spin_lock_irqsave(&il->sta_lock, flags); |
| 609 | sta_id = il_prep_station(il, ctx, il_bcast_addr, |
| 610 | false, NULL); |
| 611 | if (sta_id == IL_INVALID_STATION) { |
| 612 | IL_ERR("Unable to prepare broadcast station\n"); |
| 613 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 614 | |
| 615 | return -EINVAL; |
| 616 | } |
| 617 | |
| 618 | il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; |
| 619 | il->stations[sta_id].used |= IL_STA_BCAST; |
| 620 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 621 | |
| 622 | link_cmd = il4965_sta_alloc_lq(il, sta_id); |
| 623 | if (!link_cmd) { |
| 624 | IL_ERR( |
| 625 | "Unable to initialize rate scaling for bcast station.\n"); |
| 626 | return -ENOMEM; |
| 627 | } |
| 628 | |
| 629 | spin_lock_irqsave(&il->sta_lock, flags); |
| 630 | il->stations[sta_id].lq = link_cmd; |
| 631 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 632 | |
| 633 | return 0; |
| 634 | } |
| 635 | |
| 636 | /** |
| 637 | * il4965_update_bcast_station - update broadcast station's LQ command |
| 638 | * |
| 639 | * Only used by iwl4965. Placed here to have all bcast station management |
| 640 | * code together. |
| 641 | */ |
| 642 | static int il4965_update_bcast_station(struct il_priv *il, |
| 643 | struct il_rxon_context *ctx) |
| 644 | { |
| 645 | unsigned long flags; |
| 646 | struct il_link_quality_cmd *link_cmd; |
| 647 | u8 sta_id = ctx->bcast_sta_id; |
| 648 | |
| 649 | link_cmd = il4965_sta_alloc_lq(il, sta_id); |
| 650 | if (!link_cmd) { |
| 651 | IL_ERR( |
| 652 | "Unable to initialize rate scaling for bcast station.\n"); |
| 653 | return -ENOMEM; |
| 654 | } |
| 655 | |
| 656 | spin_lock_irqsave(&il->sta_lock, flags); |
| 657 | if (il->stations[sta_id].lq) |
| 658 | kfree(il->stations[sta_id].lq); |
| 659 | else |
| 660 | D_INFO( |
| 661 | "Bcast station rate scaling has not been initialized yet.\n"); |
| 662 | il->stations[sta_id].lq = link_cmd; |
| 663 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 664 | |
| 665 | return 0; |
| 666 | } |
| 667 | |
| 668 | int il4965_update_bcast_stations(struct il_priv *il) |
| 669 | { |
| 670 | return il4965_update_bcast_station(il, &il->ctx); |
| 671 | } |
| 672 | |
| 673 | /** |
| 674 | * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table |
| 675 | */ |
| 676 | int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) |
| 677 | { |
| 678 | unsigned long flags; |
| 679 | struct il_addsta_cmd sta_cmd; |
| 680 | |
| 681 | lockdep_assert_held(&il->mutex); |
| 682 | |
| 683 | /* Remove "disable" flag, to enable Tx for this TID */ |
| 684 | spin_lock_irqsave(&il->sta_lock, flags); |
| 685 | il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; |
| 686 | il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); |
| 687 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 688 | memcpy(&sta_cmd, &il->stations[sta_id].sta, |
| 689 | sizeof(struct il_addsta_cmd)); |
| 690 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 691 | |
| 692 | return il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
| 693 | } |
| 694 | |
| 695 | int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, |
| 696 | int tid, u16 ssn) |
| 697 | { |
| 698 | unsigned long flags; |
| 699 | int sta_id; |
| 700 | struct il_addsta_cmd sta_cmd; |
| 701 | |
| 702 | lockdep_assert_held(&il->mutex); |
| 703 | |
| 704 | sta_id = il_sta_id(sta); |
| 705 | if (sta_id == IL_INVALID_STATION) |
| 706 | return -ENXIO; |
| 707 | |
| 708 | spin_lock_irqsave(&il->sta_lock, flags); |
| 709 | il->stations[sta_id].sta.station_flags_msk = 0; |
| 710 | il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; |
| 711 | il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; |
| 712 | il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); |
| 713 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 714 | memcpy(&sta_cmd, &il->stations[sta_id].sta, |
| 715 | sizeof(struct il_addsta_cmd)); |
| 716 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 717 | |
| 718 | return il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
| 719 | } |
| 720 | |
| 721 | int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, |
| 722 | int tid) |
| 723 | { |
| 724 | unsigned long flags; |
| 725 | int sta_id; |
| 726 | struct il_addsta_cmd sta_cmd; |
| 727 | |
| 728 | lockdep_assert_held(&il->mutex); |
| 729 | |
| 730 | sta_id = il_sta_id(sta); |
| 731 | if (sta_id == IL_INVALID_STATION) { |
| 732 | IL_ERR("Invalid station for AGG tid %d\n", tid); |
| 733 | return -ENXIO; |
| 734 | } |
| 735 | |
| 736 | spin_lock_irqsave(&il->sta_lock, flags); |
| 737 | il->stations[sta_id].sta.station_flags_msk = 0; |
| 738 | il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; |
| 739 | il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; |
| 740 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 741 | memcpy(&sta_cmd, &il->stations[sta_id].sta, |
| 742 | sizeof(struct il_addsta_cmd)); |
| 743 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 744 | |
| 745 | return il_send_add_sta(il, &sta_cmd, CMD_SYNC); |
| 746 | } |
| 747 | |
| 748 | void |
| 749 | il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) |
| 750 | { |
| 751 | unsigned long flags; |
| 752 | |
| 753 | spin_lock_irqsave(&il->sta_lock, flags); |
| 754 | il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; |
| 755 | il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; |
| 756 | il->stations[sta_id].sta.sta.modify_mask = |
| 757 | STA_MODIFY_SLEEP_TX_COUNT_MSK; |
| 758 | il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); |
| 759 | il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; |
| 760 | il_send_add_sta(il, |
| 761 | &il->stations[sta_id].sta, CMD_ASYNC); |
| 762 | spin_unlock_irqrestore(&il->sta_lock, flags); |
| 763 | |
| 764 | } |
| 765 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 766 | void il4965_update_chain_flags(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 767 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 768 | if (il->cfg->ops->hcmd->set_rxon_chain) { |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 769 | il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); |
| 770 | if (il->ctx.active.rx_chain != il->ctx.staging.rx_chain) |
| 771 | il_commit_rxon(il, &il->ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 772 | } |
| 773 | } |
| 774 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 775 | static void il4965_clear_free_frames(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 776 | { |
| 777 | struct list_head *element; |
| 778 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 779 | D_INFO("%d frames on pre-allocated heap on clear.\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 780 | il->frames_count); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 781 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 782 | while (!list_empty(&il->free_frames)) { |
| 783 | element = il->free_frames.next; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 784 | list_del(element); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 785 | kfree(list_entry(element, struct il_frame, list)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 786 | il->frames_count--; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 787 | } |
| 788 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 789 | if (il->frames_count) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 790 | IL_WARN("%d frames still in use. Did we lose one?\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 791 | il->frames_count); |
| 792 | il->frames_count = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 793 | } |
| 794 | } |
| 795 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 796 | static struct il_frame *il4965_get_free_frame(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 797 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 798 | struct il_frame *frame; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 799 | struct list_head *element; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 800 | if (list_empty(&il->free_frames)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 801 | frame = kzalloc(sizeof(*frame), GFP_KERNEL); |
| 802 | if (!frame) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 803 | IL_ERR("Could not allocate frame!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 804 | return NULL; |
| 805 | } |
| 806 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 807 | il->frames_count++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 808 | return frame; |
| 809 | } |
| 810 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 811 | element = il->free_frames.next; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 812 | list_del(element); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 813 | return list_entry(element, struct il_frame, list); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 814 | } |
| 815 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 816 | static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 817 | { |
| 818 | memset(frame, 0, sizeof(*frame)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 819 | list_add(&frame->list, &il->free_frames); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 820 | } |
| 821 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 822 | static u32 il4965_fill_beacon_frame(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 823 | struct ieee80211_hdr *hdr, |
| 824 | int left) |
| 825 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 826 | lockdep_assert_held(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 827 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 828 | if (!il->beacon_skb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 829 | return 0; |
| 830 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 831 | if (il->beacon_skb->len > left) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 832 | return 0; |
| 833 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 834 | memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 835 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 836 | return il->beacon_skb->len; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 840 | static void il4965_set_beacon_tim(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 841 | struct il_tx_beacon_cmd *tx_beacon_cmd, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 842 | u8 *beacon, u32 frame_size) |
| 843 | { |
| 844 | u16 tim_idx; |
| 845 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; |
| 846 | |
| 847 | /* |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 848 | * The idx is relative to frame start but we start looking at the |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 849 | * variable-length part of the beacon. |
| 850 | */ |
| 851 | tim_idx = mgmt->u.beacon.variable - beacon; |
| 852 | |
| 853 | /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ |
| 854 | while ((tim_idx < (frame_size - 2)) && |
| 855 | (beacon[tim_idx] != WLAN_EID_TIM)) |
| 856 | tim_idx += beacon[tim_idx+1] + 2; |
| 857 | |
| 858 | /* If TIM field was found, set variables */ |
| 859 | if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { |
| 860 | tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); |
| 861 | tx_beacon_cmd->tim_size = beacon[tim_idx+1]; |
| 862 | } else |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 863 | IL_WARN("Unable to find TIM Element in beacon\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 864 | } |
| 865 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 866 | static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 867 | struct il_frame *frame) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 868 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 869 | struct il_tx_beacon_cmd *tx_beacon_cmd; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 870 | u32 frame_size; |
| 871 | u32 rate_flags; |
| 872 | u32 rate; |
| 873 | /* |
| 874 | * We have to set up the TX command, the TX Beacon command, and the |
| 875 | * beacon contents. |
| 876 | */ |
| 877 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 878 | lockdep_assert_held(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 879 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 880 | if (!il->beacon_ctx) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 881 | IL_ERR("trying to build beacon w/o beacon context!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 882 | return 0; |
| 883 | } |
| 884 | |
| 885 | /* Initialize memory */ |
| 886 | tx_beacon_cmd = &frame->u.beacon; |
| 887 | memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); |
| 888 | |
| 889 | /* Set up TX beacon contents */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 890 | frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 891 | sizeof(frame->u) - sizeof(*tx_beacon_cmd)); |
| 892 | if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) |
| 893 | return 0; |
| 894 | if (!frame_size) |
| 895 | return 0; |
| 896 | |
| 897 | /* Set up TX command fields */ |
| 898 | tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 899 | tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 900 | tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; |
| 901 | tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | |
| 902 | TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; |
| 903 | |
| 904 | /* Set up TX beacon command fields */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 905 | il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 906 | frame_size); |
| 907 | |
| 908 | /* Set up packet rate and flags */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 909 | rate = il_get_lowest_plcp(il, il->beacon_ctx); |
| 910 | il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, |
| 911 | il->hw_params.valid_tx_ant); |
| 912 | rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 913 | if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 914 | rate_flags |= RATE_MCS_CCK_MSK; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 915 | tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 916 | rate_flags); |
| 917 | |
| 918 | return sizeof(*tx_beacon_cmd) + frame_size; |
| 919 | } |
| 920 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 921 | int il4965_send_beacon_cmd(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 922 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 923 | struct il_frame *frame; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 924 | unsigned int frame_size; |
| 925 | int rc; |
| 926 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 927 | frame = il4965_get_free_frame(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 928 | if (!frame) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 929 | IL_ERR("Could not obtain free frame buffer for beacon " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 930 | "command.\n"); |
| 931 | return -ENOMEM; |
| 932 | } |
| 933 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 934 | frame_size = il4965_hw_get_beacon_cmd(il, frame); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 935 | if (!frame_size) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 936 | IL_ERR("Error configuring the beacon command\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 937 | il4965_free_frame(il, frame); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 938 | return -EINVAL; |
| 939 | } |
| 940 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 941 | rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 942 | &frame->u.cmd[0]); |
| 943 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 944 | il4965_free_frame(il, frame); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 945 | |
| 946 | return rc; |
| 947 | } |
| 948 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 949 | static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 950 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 951 | struct il_tfd_tb *tb = &tfd->tbs[idx]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 952 | |
| 953 | dma_addr_t addr = get_unaligned_le32(&tb->lo); |
| 954 | if (sizeof(dma_addr_t) > sizeof(u32)) |
| 955 | addr |= |
| 956 | ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; |
| 957 | |
| 958 | return addr; |
| 959 | } |
| 960 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 961 | static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 962 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 963 | struct il_tfd_tb *tb = &tfd->tbs[idx]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 964 | |
| 965 | return le16_to_cpu(tb->hi_n_len) >> 4; |
| 966 | } |
| 967 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 968 | static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 969 | dma_addr_t addr, u16 len) |
| 970 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 971 | struct il_tfd_tb *tb = &tfd->tbs[idx]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 972 | u16 hi_n_len = len << 4; |
| 973 | |
| 974 | put_unaligned_le32(addr, &tb->lo); |
| 975 | if (sizeof(dma_addr_t) > sizeof(u32)) |
| 976 | hi_n_len |= ((addr >> 16) >> 16) & 0xF; |
| 977 | |
| 978 | tb->hi_n_len = cpu_to_le16(hi_n_len); |
| 979 | |
| 980 | tfd->num_tbs = idx + 1; |
| 981 | } |
| 982 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 983 | static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 984 | { |
| 985 | return tfd->num_tbs & 0x1f; |
| 986 | } |
| 987 | |
| 988 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 989 | * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 990 | * @il - driver ilate data |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 991 | * @txq - tx queue |
| 992 | * |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 993 | * Does NOT advance any TFD circular buffer read/write idxes |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 994 | * Does NOT free the TFD itself (which is within circular buffer) |
| 995 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 996 | void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 997 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 998 | struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; |
| 999 | struct il_tfd *tfd; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1000 | struct pci_dev *dev = il->pci_dev; |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1001 | int idx = txq->q.read_ptr; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1002 | int i; |
| 1003 | int num_tbs; |
| 1004 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1005 | tfd = &tfd_tmp[idx]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1006 | |
| 1007 | /* Sanity check on number of chunks */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1008 | num_tbs = il4965_tfd_get_num_tbs(tfd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1009 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1010 | if (num_tbs >= IL_NUM_OF_TBS) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1011 | IL_ERR("Too many chunks: %i\n", num_tbs); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1012 | /* @todo issue fatal error, it is quite serious situation */ |
| 1013 | return; |
| 1014 | } |
| 1015 | |
| 1016 | /* Unmap tx_cmd */ |
| 1017 | if (num_tbs) |
| 1018 | pci_unmap_single(dev, |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1019 | dma_unmap_addr(&txq->meta[idx], mapping), |
| 1020 | dma_unmap_len(&txq->meta[idx], len), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1021 | PCI_DMA_BIDIRECTIONAL); |
| 1022 | |
| 1023 | /* Unmap chunks, if any. */ |
| 1024 | for (i = 1; i < num_tbs; i++) |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1025 | pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), |
| 1026 | il4965_tfd_tb_get_len(tfd, i), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1027 | PCI_DMA_TODEVICE); |
| 1028 | |
| 1029 | /* free SKB */ |
| 1030 | if (txq->txb) { |
| 1031 | struct sk_buff *skb; |
| 1032 | |
| 1033 | skb = txq->txb[txq->q.read_ptr].skb; |
| 1034 | |
| 1035 | /* can be called from irqs-disabled context */ |
| 1036 | if (skb) { |
| 1037 | dev_kfree_skb_any(skb); |
| 1038 | txq->txb[txq->q.read_ptr].skb = NULL; |
| 1039 | } |
| 1040 | } |
| 1041 | } |
| 1042 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1043 | int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1044 | struct il_tx_queue *txq, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1045 | dma_addr_t addr, u16 len, |
| 1046 | u8 reset, u8 pad) |
| 1047 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1048 | struct il_queue *q; |
| 1049 | struct il_tfd *tfd, *tfd_tmp; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1050 | u32 num_tbs; |
| 1051 | |
| 1052 | q = &txq->q; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1053 | tfd_tmp = (struct il_tfd *)txq->tfds; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1054 | tfd = &tfd_tmp[q->write_ptr]; |
| 1055 | |
| 1056 | if (reset) |
| 1057 | memset(tfd, 0, sizeof(*tfd)); |
| 1058 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1059 | num_tbs = il4965_tfd_get_num_tbs(tfd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1060 | |
| 1061 | /* Each TFD can point to a maximum 20 Tx buffers */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1062 | if (num_tbs >= IL_NUM_OF_TBS) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1063 | IL_ERR("Error can not send more than %d chunks\n", |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1064 | IL_NUM_OF_TBS); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1065 | return -EINVAL; |
| 1066 | } |
| 1067 | |
| 1068 | BUG_ON(addr & ~DMA_BIT_MASK(36)); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1069 | if (unlikely(addr & ~IL_TX_DMA_MASK)) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1070 | IL_ERR("Unaligned address = %llx\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1071 | (unsigned long long)addr); |
| 1072 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1073 | il4965_tfd_set_tb(tfd, num_tbs, addr, len); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1074 | |
| 1075 | return 0; |
| 1076 | } |
| 1077 | |
| 1078 | /* |
| 1079 | * Tell nic where to find circular buffer of Tx Frame Descriptors for |
| 1080 | * given Tx queue, and enable the DMA channel used for that queue. |
| 1081 | * |
| 1082 | * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA |
| 1083 | * channels supported in hardware. |
| 1084 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1085 | int il4965_hw_tx_queue_init(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1086 | struct il_tx_queue *txq) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1087 | { |
| 1088 | int txq_id = txq->q.id; |
| 1089 | |
| 1090 | /* Circular buffer (TFD queue in DRAM) physical base address */ |
Stanislaw Gruszka | 0c1a94e | 2011-08-24 17:37:16 +0200 | [diff] [blame] | 1091 | il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1092 | txq->q.dma_addr >> 8); |
| 1093 | |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
| 1097 | /****************************************************************************** |
| 1098 | * |
| 1099 | * Generic RX handler implementations |
| 1100 | * |
| 1101 | ******************************************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1102 | static void il4965_rx_reply_alive(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 1103 | struct il_rx_buf *rxb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1104 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 1105 | struct il_rx_pkt *pkt = rxb_addr(rxb); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1106 | struct il_alive_resp *palive; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1107 | struct delayed_work *pwork; |
| 1108 | |
| 1109 | palive = &pkt->u.alive_frame; |
| 1110 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1111 | D_INFO("Alive ucode status 0x%08X revision " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1112 | "0x%01X 0x%01X\n", |
| 1113 | palive->is_valid, palive->ver_type, |
| 1114 | palive->ver_subtype); |
| 1115 | |
| 1116 | if (palive->ver_subtype == INITIALIZE_SUBTYPE) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1117 | D_INFO("Initialization Alive received.\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1118 | memcpy(&il->card_alive_init, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1119 | &pkt->u.alive_frame, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1120 | sizeof(struct il_init_alive_resp)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1121 | pwork = &il->init_alive_start; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1122 | } else { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1123 | D_INFO("Runtime Alive received.\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1124 | memcpy(&il->card_alive, &pkt->u.alive_frame, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1125 | sizeof(struct il_alive_resp)); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1126 | pwork = &il->alive_start; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1127 | } |
| 1128 | |
| 1129 | /* We delay the ALIVE response by 5ms to |
| 1130 | * give the HW RF Kill time to activate... */ |
| 1131 | if (palive->is_valid == UCODE_VALID_OK) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1132 | queue_delayed_work(il->workqueue, pwork, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1133 | msecs_to_jiffies(5)); |
| 1134 | else |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1135 | IL_WARN("uCode did not respond OK.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | /** |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1139 | * il4965_bg_stats_periodic - Timer callback to queue stats |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1140 | * |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1141 | * This callback is provided in order to send a stats request. |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1142 | * |
| 1143 | * This timer function is continually reset to execute within |
| 1144 | * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1145 | * was received. We need to ensure we receive the stats in order |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1146 | * to update the temperature used for calibrating the TXPOWER. |
| 1147 | */ |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1148 | static void il4965_bg_stats_periodic(unsigned long data) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1149 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1150 | struct il_priv *il = (struct il_priv *)data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1151 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1152 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1153 | return; |
| 1154 | |
| 1155 | /* dont send host command if rf-kill is on */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1156 | if (!il_is_ready_rf(il)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1157 | return; |
| 1158 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1159 | il_send_stats_request(il, CMD_ASYNC, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1160 | } |
| 1161 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1162 | static void il4965_rx_beacon_notif(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 1163 | struct il_rx_buf *rxb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1164 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 1165 | struct il_rx_pkt *pkt = rxb_addr(rxb); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1166 | struct il4965_beacon_notif *beacon = |
| 1167 | (struct il4965_beacon_notif *)pkt->u.raw; |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1168 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1169 | u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1170 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1171 | D_RX("beacon status %x retries %d iss %d " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1172 | "tsf %d %d rate %d\n", |
| 1173 | le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, |
| 1174 | beacon->beacon_notify_hdr.failure_frame, |
| 1175 | le32_to_cpu(beacon->ibss_mgr_status), |
| 1176 | le32_to_cpu(beacon->high_tsf), |
| 1177 | le32_to_cpu(beacon->low_tsf), rate); |
| 1178 | #endif |
| 1179 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1180 | il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1181 | } |
| 1182 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1183 | static void il4965_perform_ct_kill_task(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1184 | { |
| 1185 | unsigned long flags; |
| 1186 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1187 | D_POWER("Stop all queues\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1188 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1189 | if (il->mac80211_registered) |
| 1190 | ieee80211_stop_queues(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1191 | |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1192 | _il_wr(il, CSR_UCODE_DRV_GP1_SET, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1193 | CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1194 | _il_rd(il, CSR_UCODE_DRV_GP1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1195 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1196 | spin_lock_irqsave(&il->reg_lock, flags); |
Stanislaw Gruszka | 1388226 | 2011-08-24 15:39:23 +0200 | [diff] [blame] | 1197 | if (!_il_grab_nic_access(il)) |
| 1198 | _il_release_nic_access(il); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1199 | spin_unlock_irqrestore(&il->reg_lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1200 | } |
| 1201 | |
| 1202 | /* Handle notification from uCode that card's power state is changing |
| 1203 | * due to software, hardware, or critical temperature RFKILL */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1204 | static void il4965_rx_card_state_notif(struct il_priv *il, |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 1205 | struct il_rx_buf *rxb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1206 | { |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 1207 | struct il_rx_pkt *pkt = rxb_addr(rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1208 | u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1209 | unsigned long status = il->status; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1210 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1211 | D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1212 | (flags & HW_CARD_DISABLED) ? "Kill" : "On", |
| 1213 | (flags & SW_CARD_DISABLED) ? "Kill" : "On", |
| 1214 | (flags & CT_CARD_DISABLED) ? |
| 1215 | "Reached" : "Not reached"); |
| 1216 | |
| 1217 | if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | |
| 1218 | CT_CARD_DISABLED)) { |
| 1219 | |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1220 | _il_wr(il, CSR_UCODE_DRV_GP1_SET, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1221 | CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); |
| 1222 | |
Stanislaw Gruszka | 0c1a94e | 2011-08-24 17:37:16 +0200 | [diff] [blame] | 1223 | il_wr(il, HBUS_TARG_MBX_C, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1224 | HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); |
| 1225 | |
| 1226 | if (!(flags & RXON_CARD_DISABLED)) { |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1227 | _il_wr(il, CSR_UCODE_DRV_GP1_CLR, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1228 | CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); |
Stanislaw Gruszka | 0c1a94e | 2011-08-24 17:37:16 +0200 | [diff] [blame] | 1229 | il_wr(il, HBUS_TARG_MBX_C, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1230 | HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | if (flags & CT_CARD_DISABLED) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1235 | il4965_perform_ct_kill_task(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1236 | |
| 1237 | if (flags & HW_CARD_DISABLED) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1238 | set_bit(STATUS_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1239 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1240 | clear_bit(STATUS_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1241 | |
| 1242 | if (!(flags & RXON_CARD_DISABLED)) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1243 | il_scan_cancel(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1244 | |
| 1245 | if ((test_bit(STATUS_RF_KILL_HW, &status) != |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1246 | test_bit(STATUS_RF_KILL_HW, &il->status))) |
| 1247 | wiphy_rfkill_set_hw_state(il->hw->wiphy, |
| 1248 | test_bit(STATUS_RF_KILL_HW, &il->status)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1249 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1250 | wake_up(&il->wait_command_queue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1254 | * il4965_setup_rx_handlers - Initialize Rx handler callbacks |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1255 | * |
| 1256 | * Setup the RX handlers for each of the reply types sent from the uCode |
| 1257 | * to the host. |
| 1258 | * |
| 1259 | * This function chains into the hardware specific files for them to setup |
| 1260 | * any hardware specific handlers as well. |
| 1261 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1262 | static void il4965_setup_rx_handlers(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1263 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1264 | il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; |
| 1265 | il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; |
| 1266 | il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; |
| 1267 | il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1268 | il_rx_spectrum_measure_notif; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1269 | il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; |
| 1270 | il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1271 | il_rx_pm_debug_stats_notif; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1272 | il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1273 | |
| 1274 | /* |
| 1275 | * The same handler is used for both the REPLY to a discrete |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1276 | * stats request from the host as well as for the periodic |
| 1277 | * stats notifications (after received beacons) from the uCode. |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1278 | */ |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 1279 | il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; |
| 1280 | il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1281 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1282 | il_setup_rx_scan_handlers(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1283 | |
| 1284 | /* status change handler */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1285 | il->rx_handlers[CARD_STATE_NOTIFICATION] = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1286 | il4965_rx_card_state_notif; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1287 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1288 | il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1289 | il4965_rx_missed_beacon_notif; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1290 | /* Rx handlers */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1291 | il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; |
| 1292 | il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1293 | /* block ack */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1294 | il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1295 | /* Set up hardware specific Rx handlers */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1296 | il->cfg->ops->lib->rx_handler_setup(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1297 | } |
| 1298 | |
| 1299 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1300 | * il4965_rx_handle - Main entry function for receiving responses from uCode |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1301 | * |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1302 | * Uses the il->rx_handlers callback function array to invoke |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1303 | * the appropriate handlers, including command responses, |
| 1304 | * frame-received notifications, and other notifications. |
| 1305 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1306 | void il4965_rx_handle(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1307 | { |
Stanislaw Gruszka | b73bb5f | 2011-08-26 14:37:54 +0200 | [diff] [blame] | 1308 | struct il_rx_buf *rxb; |
Stanislaw Gruszka | dcae1c6 | 2011-08-26 14:36:21 +0200 | [diff] [blame] | 1309 | struct il_rx_pkt *pkt; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1310 | struct il_rx_queue *rxq = &il->rxq; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1311 | u32 r, i; |
| 1312 | int reclaim; |
| 1313 | unsigned long flags; |
| 1314 | u8 fill_rx = 0; |
| 1315 | u32 count = 8; |
| 1316 | int total_empty; |
| 1317 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1318 | /* uCode's read idx (stored in shared DRAM) indicates the last Rx |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1319 | * buffer that the driver may process (last buffer filled by ucode). */ |
| 1320 | r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; |
| 1321 | i = rxq->read; |
| 1322 | |
| 1323 | /* Rx interrupt, but nothing sent from uCode */ |
| 1324 | if (i == r) |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1325 | D_RX("r = %d, i = %d\n", r, i); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1326 | |
| 1327 | /* calculate total frames need to be restock after handling RX */ |
| 1328 | total_empty = r - rxq->write_actual; |
| 1329 | if (total_empty < 0) |
| 1330 | total_empty += RX_QUEUE_SIZE; |
| 1331 | |
| 1332 | if (total_empty > (RX_QUEUE_SIZE / 2)) |
| 1333 | fill_rx = 1; |
| 1334 | |
| 1335 | while (i != r) { |
| 1336 | int len; |
| 1337 | |
| 1338 | rxb = rxq->queue[i]; |
| 1339 | |
| 1340 | /* If an RXB doesn't have a Rx queue slot associated with it, |
| 1341 | * then a bug has been introduced in the queue refilling |
| 1342 | * routines -- catch it here */ |
| 1343 | BUG_ON(rxb == NULL); |
| 1344 | |
| 1345 | rxq->queue[i] = NULL; |
| 1346 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1347 | pci_unmap_page(il->pci_dev, rxb->page_dma, |
| 1348 | PAGE_SIZE << il->hw_params.rx_page_order, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1349 | PCI_DMA_FROMDEVICE); |
| 1350 | pkt = rxb_addr(rxb); |
| 1351 | |
| 1352 | len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; |
| 1353 | len += sizeof(u32); /* account for status word */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1354 | |
| 1355 | /* Reclaim a command buffer only if this packet is a response |
| 1356 | * to a (driver-originated) command. |
| 1357 | * If the packet (e.g. Rx frame) originated from uCode, |
| 1358 | * there is no command buffer to reclaim. |
| 1359 | * Ucode should set SEQ_RX_FRAME bit if ucode-originated, |
| 1360 | * but apparently a few don't get set; catch them here. */ |
| 1361 | reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && |
| 1362 | (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && |
| 1363 | (pkt->hdr.cmd != REPLY_RX) && |
| 1364 | (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && |
| 1365 | (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && |
| 1366 | (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && |
| 1367 | (pkt->hdr.cmd != REPLY_TX); |
| 1368 | |
| 1369 | /* Based on type of command response or notification, |
| 1370 | * handle those that need handling via function in |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1371 | * rx_handlers table. See il4965_setup_rx_handlers() */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1372 | if (il->rx_handlers[pkt->hdr.cmd]) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1373 | D_RX("r = %d, i = %d, %s, 0x%02x\n", r, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1374 | i, il_get_cmd_string(pkt->hdr.cmd), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1375 | pkt->hdr.cmd); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1376 | il->isr_stats.rx_handlers[pkt->hdr.cmd]++; |
| 1377 | il->rx_handlers[pkt->hdr.cmd] (il, rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1378 | } else { |
| 1379 | /* No handling needed */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1380 | D_RX( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1381 | "r %d i %d No handler needed for %s, 0x%02x\n", |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1382 | r, i, il_get_cmd_string(pkt->hdr.cmd), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1383 | pkt->hdr.cmd); |
| 1384 | } |
| 1385 | |
| 1386 | /* |
| 1387 | * XXX: After here, we should always check rxb->page |
| 1388 | * against NULL before touching it or its virtual |
| 1389 | * memory (pkt). Because some rx_handler might have |
| 1390 | * already taken or freed the pages. |
| 1391 | */ |
| 1392 | |
| 1393 | if (reclaim) { |
| 1394 | /* Invoke any callbacks, transfer the buffer to caller, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1395 | * and fire off the (possibly) blocking il_send_cmd() |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1396 | * as we reclaim the driver command queue */ |
| 1397 | if (rxb->page) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1398 | il_tx_cmd_complete(il, rxb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1399 | else |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1400 | IL_WARN("Claim null rxb?\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | /* Reuse the page if possible. For notification packets and |
| 1404 | * SKBs that fail to Rx correctly, add them back into the |
| 1405 | * rx_free list for reuse later. */ |
| 1406 | spin_lock_irqsave(&rxq->lock, flags); |
| 1407 | if (rxb->page != NULL) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1408 | rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, |
| 1409 | 0, PAGE_SIZE << il->hw_params.rx_page_order, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1410 | PCI_DMA_FROMDEVICE); |
| 1411 | list_add_tail(&rxb->list, &rxq->rx_free); |
| 1412 | rxq->free_count++; |
| 1413 | } else |
| 1414 | list_add_tail(&rxb->list, &rxq->rx_used); |
| 1415 | |
| 1416 | spin_unlock_irqrestore(&rxq->lock, flags); |
| 1417 | |
| 1418 | i = (i + 1) & RX_QUEUE_MASK; |
| 1419 | /* If there are a lot of unused frames, |
| 1420 | * restock the Rx queue so ucode wont assert. */ |
| 1421 | if (fill_rx) { |
| 1422 | count++; |
| 1423 | if (count >= 8) { |
| 1424 | rxq->read = i; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1425 | il4965_rx_replenish_now(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1426 | count = 0; |
| 1427 | } |
| 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | /* Backtrack one entry */ |
| 1432 | rxq->read = i; |
| 1433 | if (fill_rx) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1434 | il4965_rx_replenish_now(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1435 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1436 | il4965_rx_queue_restock(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1437 | } |
| 1438 | |
| 1439 | /* call this function to flush any scheduled tasklet */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1440 | static inline void il4965_synchronize_irq(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1441 | { |
| 1442 | /* wait to make sure we flush pending tasklet*/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1443 | synchronize_irq(il->pci_dev->irq); |
| 1444 | tasklet_kill(&il->irq_tasklet); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1445 | } |
| 1446 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1447 | static void il4965_irq_tasklet(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1448 | { |
| 1449 | u32 inta, handled = 0; |
| 1450 | u32 inta_fh; |
| 1451 | unsigned long flags; |
| 1452 | u32 i; |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1453 | #ifdef CONFIG_IWLEGACY_DEBUG |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1454 | u32 inta_mask; |
| 1455 | #endif |
| 1456 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1457 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1458 | |
| 1459 | /* Ack/clear/reset pending uCode interrupts. |
| 1460 | * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, |
| 1461 | * and will clear only when CSR_FH_INT_STATUS gets cleared. */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1462 | inta = _il_rd(il, CSR_INT); |
| 1463 | _il_wr(il, CSR_INT, inta); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1464 | |
| 1465 | /* Ack/clear/reset pending flow-handler (DMA) interrupts. |
| 1466 | * Any new interrupts that happen after this, either while we're |
| 1467 | * in this tasklet, or later, will show up in next ISR/tasklet. */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1468 | inta_fh = _il_rd(il, CSR_FH_INT_STATUS); |
| 1469 | _il_wr(il, CSR_FH_INT_STATUS, inta_fh); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1470 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1471 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1472 | if (il_get_debug_level(il) & IL_DL_ISR) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1473 | /* just for debug */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1474 | inta_mask = _il_rd(il, CSR_INT_MASK); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1475 | D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1476 | inta, inta_mask, inta_fh); |
| 1477 | } |
| 1478 | #endif |
| 1479 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1480 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1481 | |
| 1482 | /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not |
| 1483 | * atomic, make sure that inta covers all the interrupts that |
| 1484 | * we've discovered, even if FH interrupt came in just after |
| 1485 | * reading CSR_INT. */ |
| 1486 | if (inta_fh & CSR49_FH_INT_RX_MASK) |
| 1487 | inta |= CSR_INT_BIT_FH_RX; |
| 1488 | if (inta_fh & CSR49_FH_INT_TX_MASK) |
| 1489 | inta |= CSR_INT_BIT_FH_TX; |
| 1490 | |
| 1491 | /* Now service all interrupt bits discovered above. */ |
| 1492 | if (inta & CSR_INT_BIT_HW_ERR) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1493 | IL_ERR("Hardware error detected. Restarting.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1494 | |
| 1495 | /* Tell the device to stop sending interrupts */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1496 | il_disable_interrupts(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1497 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1498 | il->isr_stats.hw++; |
| 1499 | il_irq_handle_error(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1500 | |
| 1501 | handled |= CSR_INT_BIT_HW_ERR; |
| 1502 | |
| 1503 | return; |
| 1504 | } |
| 1505 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1506 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1507 | if (il_get_debug_level(il) & (IL_DL_ISR)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1508 | /* NIC fires this, but we don't use it, redundant with WAKEUP */ |
| 1509 | if (inta & CSR_INT_BIT_SCD) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1510 | D_ISR("Scheduler finished to transmit " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1511 | "the frame/frames.\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1512 | il->isr_stats.sch++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1513 | } |
| 1514 | |
| 1515 | /* Alive notification via Rx interrupt will do the real work */ |
| 1516 | if (inta & CSR_INT_BIT_ALIVE) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1517 | D_ISR("Alive interrupt\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1518 | il->isr_stats.alive++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1519 | } |
| 1520 | } |
| 1521 | #endif |
| 1522 | /* Safely ignore these bits for debug checks below */ |
| 1523 | inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); |
| 1524 | |
| 1525 | /* HW RF KILL switch toggled */ |
| 1526 | if (inta & CSR_INT_BIT_RF_KILL) { |
| 1527 | int hw_rf_kill = 0; |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1528 | if (!(_il_rd(il, CSR_GP_CNTRL) & |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1529 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) |
| 1530 | hw_rf_kill = 1; |
| 1531 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1532 | IL_WARN("RF_KILL bit toggled to %s.\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1533 | hw_rf_kill ? "disable radio" : "enable radio"); |
| 1534 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1535 | il->isr_stats.rfkill++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1536 | |
| 1537 | /* driver only loads ucode once setting the interface up. |
| 1538 | * the driver allows loading the ucode even if the radio |
| 1539 | * is killed. Hence update the killswitch state here. The |
| 1540 | * rfkill handler will care about restarting if needed. |
| 1541 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1542 | if (!test_bit(STATUS_ALIVE, &il->status)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1543 | if (hw_rf_kill) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1544 | set_bit(STATUS_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1545 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1546 | clear_bit(STATUS_RF_KILL_HW, &il->status); |
| 1547 | wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1548 | } |
| 1549 | |
| 1550 | handled |= CSR_INT_BIT_RF_KILL; |
| 1551 | } |
| 1552 | |
| 1553 | /* Chip got too hot and stopped itself */ |
| 1554 | if (inta & CSR_INT_BIT_CT_KILL) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1555 | IL_ERR("Microcode CT kill error detected.\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1556 | il->isr_stats.ctkill++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1557 | handled |= CSR_INT_BIT_CT_KILL; |
| 1558 | } |
| 1559 | |
| 1560 | /* Error detected by uCode */ |
| 1561 | if (inta & CSR_INT_BIT_SW_ERR) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1562 | IL_ERR("Microcode SW error detected. " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1563 | " Restarting 0x%X.\n", inta); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1564 | il->isr_stats.sw++; |
| 1565 | il_irq_handle_error(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1566 | handled |= CSR_INT_BIT_SW_ERR; |
| 1567 | } |
| 1568 | |
| 1569 | /* |
| 1570 | * uCode wakes up after power-down sleep. |
| 1571 | * Tell device about any new tx or host commands enqueued, |
| 1572 | * and about any Rx buffers made available while asleep. |
| 1573 | */ |
| 1574 | if (inta & CSR_INT_BIT_WAKEUP) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1575 | D_ISR("Wakeup interrupt\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1576 | il_rx_queue_update_write_ptr(il, &il->rxq); |
| 1577 | for (i = 0; i < il->hw_params.max_txq_num; i++) |
| 1578 | il_txq_update_write_ptr(il, &il->txq[i]); |
| 1579 | il->isr_stats.wakeup++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1580 | handled |= CSR_INT_BIT_WAKEUP; |
| 1581 | } |
| 1582 | |
| 1583 | /* All uCode command responses, including Tx command responses, |
| 1584 | * Rx "responses" (frame-received notification), and other |
| 1585 | * notifications from uCode come through here*/ |
| 1586 | if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1587 | il4965_rx_handle(il); |
| 1588 | il->isr_stats.rx++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1589 | handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); |
| 1590 | } |
| 1591 | |
| 1592 | /* This "Tx" DMA channel is used only for loading uCode */ |
| 1593 | if (inta & CSR_INT_BIT_FH_TX) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1594 | D_ISR("uCode load interrupt\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1595 | il->isr_stats.tx++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1596 | handled |= CSR_INT_BIT_FH_TX; |
| 1597 | /* Wake up uCode load routine, now that load is complete */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1598 | il->ucode_write_complete = 1; |
| 1599 | wake_up(&il->wait_command_queue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1600 | } |
| 1601 | |
| 1602 | if (inta & ~handled) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1603 | IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1604 | il->isr_stats.unhandled++; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1605 | } |
| 1606 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1607 | if (inta & ~(il->inta_mask)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1608 | IL_WARN("Disabled INTA bits 0x%08x were pending\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1609 | inta & ~il->inta_mask); |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1610 | IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1611 | } |
| 1612 | |
| 1613 | /* Re-enable all interrupts */ |
Stanislaw Gruszka | 93fd74e | 2011-04-28 11:51:30 +0200 | [diff] [blame] | 1614 | /* only Re-enable if disabled by irq */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1615 | if (test_bit(STATUS_INT_ENABLED, &il->status)) |
| 1616 | il_enable_interrupts(il); |
Stanislaw Gruszka | a078a1f | 2011-04-28 11:51:25 +0200 | [diff] [blame] | 1617 | /* Re-enable RF_KILL if it occurred */ |
| 1618 | else if (handled & CSR_INT_BIT_RF_KILL) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1619 | il_enable_rfkill_int(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1620 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1621 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1622 | if (il_get_debug_level(il) & (IL_DL_ISR)) { |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1623 | inta = _il_rd(il, CSR_INT); |
| 1624 | inta_mask = _il_rd(il, CSR_INT_MASK); |
| 1625 | inta_fh = _il_rd(il, CSR_FH_INT_STATUS); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1626 | D_ISR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1627 | "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " |
| 1628 | "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); |
| 1629 | } |
| 1630 | #endif |
| 1631 | } |
| 1632 | |
| 1633 | /***************************************************************************** |
| 1634 | * |
| 1635 | * sysfs attributes |
| 1636 | * |
| 1637 | *****************************************************************************/ |
| 1638 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1639 | #ifdef CONFIG_IWLEGACY_DEBUG |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1640 | |
| 1641 | /* |
| 1642 | * The following adds a new attribute to the sysfs representation |
| 1643 | * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/) |
| 1644 | * used for controlling the debug level. |
| 1645 | * |
| 1646 | * See the level definitions in iwl for details. |
| 1647 | * |
| 1648 | * The debug_level being managed using sysfs below is a per device debug |
| 1649 | * level that is used instead of the global debug level if it (the per |
| 1650 | * device debug level) is set. |
| 1651 | */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1652 | static ssize_t il4965_show_debug_level(struct device *d, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1653 | struct device_attribute *attr, char *buf) |
| 1654 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1655 | struct il_priv *il = dev_get_drvdata(d); |
| 1656 | return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1657 | } |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1658 | static ssize_t il4965_store_debug_level(struct device *d, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1659 | struct device_attribute *attr, |
| 1660 | const char *buf, size_t count) |
| 1661 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1662 | struct il_priv *il = dev_get_drvdata(d); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1663 | unsigned long val; |
| 1664 | int ret; |
| 1665 | |
| 1666 | ret = strict_strtoul(buf, 0, &val); |
| 1667 | if (ret) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1668 | IL_ERR("%s is not in hex or decimal form.\n", buf); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1669 | else { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1670 | il->debug_level = val; |
| 1671 | if (il_alloc_traffic_mem(il)) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1672 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1673 | "Not enough memory to generate traffic log\n"); |
| 1674 | } |
| 1675 | return strnlen(buf, count); |
| 1676 | } |
| 1677 | |
| 1678 | static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1679 | il4965_show_debug_level, il4965_store_debug_level); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1680 | |
| 1681 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1682 | #endif /* CONFIG_IWLEGACY_DEBUG */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1683 | |
| 1684 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1685 | static ssize_t il4965_show_temperature(struct device *d, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1686 | struct device_attribute *attr, char *buf) |
| 1687 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1688 | struct il_priv *il = dev_get_drvdata(d); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1689 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1690 | if (!il_is_alive(il)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1691 | return -EAGAIN; |
| 1692 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1693 | return sprintf(buf, "%d\n", il->temperature); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1694 | } |
| 1695 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1696 | static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1697 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1698 | static ssize_t il4965_show_tx_power(struct device *d, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1699 | struct device_attribute *attr, char *buf) |
| 1700 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1701 | struct il_priv *il = dev_get_drvdata(d); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1702 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1703 | if (!il_is_ready_rf(il)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1704 | return sprintf(buf, "off\n"); |
| 1705 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1706 | return sprintf(buf, "%d\n", il->tx_power_user_lmt); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1707 | } |
| 1708 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1709 | static ssize_t il4965_store_tx_power(struct device *d, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1710 | struct device_attribute *attr, |
| 1711 | const char *buf, size_t count) |
| 1712 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1713 | struct il_priv *il = dev_get_drvdata(d); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1714 | unsigned long val; |
| 1715 | int ret; |
| 1716 | |
| 1717 | ret = strict_strtoul(buf, 10, &val); |
| 1718 | if (ret) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1719 | IL_INFO("%s is not in decimal form.\n", buf); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1720 | else { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1721 | ret = il_set_tx_power(il, val, false); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1722 | if (ret) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1723 | IL_ERR("failed setting tx power (0x%d).\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1724 | ret); |
| 1725 | else |
| 1726 | ret = count; |
| 1727 | } |
| 1728 | return ret; |
| 1729 | } |
| 1730 | |
| 1731 | static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1732 | il4965_show_tx_power, il4965_store_tx_power); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1733 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1734 | static struct attribute *il_sysfs_entries[] = { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1735 | &dev_attr_temperature.attr, |
| 1736 | &dev_attr_tx_power.attr, |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 1737 | #ifdef CONFIG_IWLEGACY_DEBUG |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1738 | &dev_attr_debug_level.attr, |
| 1739 | #endif |
| 1740 | NULL |
| 1741 | }; |
| 1742 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1743 | static struct attribute_group il_attribute_group = { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1744 | .name = NULL, /* put in device directory */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1745 | .attrs = il_sysfs_entries, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1746 | }; |
| 1747 | |
| 1748 | /****************************************************************************** |
| 1749 | * |
| 1750 | * uCode download functions |
| 1751 | * |
| 1752 | ******************************************************************************/ |
| 1753 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1754 | static void il4965_dealloc_ucode_pci(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1755 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1756 | il_free_fw_desc(il->pci_dev, &il->ucode_code); |
| 1757 | il_free_fw_desc(il->pci_dev, &il->ucode_data); |
| 1758 | il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); |
| 1759 | il_free_fw_desc(il->pci_dev, &il->ucode_init); |
| 1760 | il_free_fw_desc(il->pci_dev, &il->ucode_init_data); |
| 1761 | il_free_fw_desc(il->pci_dev, &il->ucode_boot); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1762 | } |
| 1763 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1764 | static void il4965_nic_start(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1765 | { |
| 1766 | /* Remove all resets to allow NIC to operate */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 1767 | _il_wr(il, CSR_RESET, 0); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1768 | } |
| 1769 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1770 | static void il4965_ucode_callback(const struct firmware *ucode_raw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1771 | void *context); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1772 | static int il4965_mac_setup_register(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1773 | u32 max_probe_length); |
| 1774 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1775 | static int __must_check il4965_request_firmware(struct il_priv *il, bool first) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1776 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1777 | const char *name_pre = il->cfg->fw_name_pre; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1778 | char tag[8]; |
| 1779 | |
| 1780 | if (first) { |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1781 | il->fw_idx = il->cfg->ucode_api_max; |
| 1782 | sprintf(tag, "%d", il->fw_idx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1783 | } else { |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1784 | il->fw_idx--; |
| 1785 | sprintf(tag, "%d", il->fw_idx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1786 | } |
| 1787 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1788 | if (il->fw_idx < il->cfg->ucode_api_min) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1789 | IL_ERR("no suitable firmware found!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1790 | return -ENOENT; |
| 1791 | } |
| 1792 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1793 | sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1794 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1795 | D_INFO("attempting to load firmware '%s'\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1796 | il->firmware_name); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1797 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1798 | return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, |
| 1799 | &il->pci_dev->dev, GFP_KERNEL, il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1800 | il4965_ucode_callback); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1801 | } |
| 1802 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1803 | struct il4965_firmware_pieces { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1804 | const void *inst, *data, *init, *init_data, *boot; |
| 1805 | size_t inst_size, data_size, init_size, init_data_size, boot_size; |
| 1806 | }; |
| 1807 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1808 | static int il4965_load_firmware(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1809 | const struct firmware *ucode_raw, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1810 | struct il4965_firmware_pieces *pieces) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1811 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1812 | struct il_ucode_header *ucode = (void *)ucode_raw->data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1813 | u32 api_ver, hdr_size; |
| 1814 | const u8 *src; |
| 1815 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1816 | il->ucode_ver = le32_to_cpu(ucode->ver); |
| 1817 | api_ver = IL_UCODE_API(il->ucode_ver); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1818 | |
| 1819 | switch (api_ver) { |
| 1820 | default: |
| 1821 | case 0: |
| 1822 | case 1: |
| 1823 | case 2: |
| 1824 | hdr_size = 24; |
| 1825 | if (ucode_raw->size < hdr_size) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1826 | IL_ERR("File size too small!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1827 | return -EINVAL; |
| 1828 | } |
| 1829 | pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); |
| 1830 | pieces->data_size = le32_to_cpu(ucode->v1.data_size); |
| 1831 | pieces->init_size = le32_to_cpu(ucode->v1.init_size); |
| 1832 | pieces->init_data_size = |
| 1833 | le32_to_cpu(ucode->v1.init_data_size); |
| 1834 | pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); |
| 1835 | src = ucode->v1.data; |
| 1836 | break; |
| 1837 | } |
| 1838 | |
| 1839 | /* Verify size of file vs. image size info in file's header */ |
| 1840 | if (ucode_raw->size != hdr_size + pieces->inst_size + |
| 1841 | pieces->data_size + pieces->init_size + |
| 1842 | pieces->init_data_size + pieces->boot_size) { |
| 1843 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1844 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1845 | "uCode file size %d does not match expected size\n", |
| 1846 | (int)ucode_raw->size); |
| 1847 | return -EINVAL; |
| 1848 | } |
| 1849 | |
| 1850 | pieces->inst = src; |
| 1851 | src += pieces->inst_size; |
| 1852 | pieces->data = src; |
| 1853 | src += pieces->data_size; |
| 1854 | pieces->init = src; |
| 1855 | src += pieces->init_size; |
| 1856 | pieces->init_data = src; |
| 1857 | src += pieces->init_data_size; |
| 1858 | pieces->boot = src; |
| 1859 | src += pieces->boot_size; |
| 1860 | |
| 1861 | return 0; |
| 1862 | } |
| 1863 | |
| 1864 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1865 | * il4965_ucode_callback - callback when firmware was loaded |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1866 | * |
| 1867 | * If loaded successfully, copies the firmware into buffers |
| 1868 | * for the card to fetch (via DMA). |
| 1869 | */ |
| 1870 | static void |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1871 | il4965_ucode_callback(const struct firmware *ucode_raw, void *context) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1872 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1873 | struct il_priv *il = context; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1874 | struct il_ucode_header *ucode; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1875 | int err; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1876 | struct il4965_firmware_pieces pieces; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1877 | const unsigned int api_max = il->cfg->ucode_api_max; |
| 1878 | const unsigned int api_min = il->cfg->ucode_api_min; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1879 | u32 api_ver; |
| 1880 | |
| 1881 | u32 max_probe_length = 200; |
| 1882 | u32 standard_phy_calibration_size = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1883 | IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1884 | |
| 1885 | memset(&pieces, 0, sizeof(pieces)); |
| 1886 | |
| 1887 | if (!ucode_raw) { |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 1888 | if (il->fw_idx <= il->cfg->ucode_api_max) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1889 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1890 | "request for firmware file '%s' failed.\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1891 | il->firmware_name); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1892 | goto try_again; |
| 1893 | } |
| 1894 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1895 | D_INFO("Loaded firmware file '%s' (%zd bytes).\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1896 | il->firmware_name, ucode_raw->size); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1897 | |
| 1898 | /* Make sure that we got at least the API version number */ |
| 1899 | if (ucode_raw->size < 4) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1900 | IL_ERR("File size way too small!\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1901 | goto try_again; |
| 1902 | } |
| 1903 | |
| 1904 | /* Data from ucode file: header followed by uCode images */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 1905 | ucode = (struct il_ucode_header *)ucode_raw->data; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1906 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1907 | err = il4965_load_firmware(il, ucode_raw, &pieces); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1908 | |
| 1909 | if (err) |
| 1910 | goto try_again; |
| 1911 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1912 | api_ver = IL_UCODE_API(il->ucode_ver); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1913 | |
| 1914 | /* |
| 1915 | * api_ver should match the api version forming part of the |
| 1916 | * firmware filename ... but we don't check for that and only rely |
| 1917 | * on the API version read from firmware header from here on forward |
| 1918 | */ |
| 1919 | if (api_ver < api_min || api_ver > api_max) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1920 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1921 | "Driver unable to support your firmware API. " |
| 1922 | "Driver supports v%u, firmware is v%u.\n", |
| 1923 | api_max, api_ver); |
| 1924 | goto try_again; |
| 1925 | } |
| 1926 | |
| 1927 | if (api_ver != api_max) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1928 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1929 | "Firmware has old API version. Expected v%u, " |
| 1930 | "got v%u. New firmware can be obtained " |
| 1931 | "from http://www.intellinuxwireless.org.\n", |
| 1932 | api_max, api_ver); |
| 1933 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1934 | IL_INFO("loaded firmware version %u.%u.%u.%u\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1935 | IL_UCODE_MAJOR(il->ucode_ver), |
| 1936 | IL_UCODE_MINOR(il->ucode_ver), |
| 1937 | IL_UCODE_API(il->ucode_ver), |
| 1938 | IL_UCODE_SERIAL(il->ucode_ver)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1939 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1940 | snprintf(il->hw->wiphy->fw_version, |
| 1941 | sizeof(il->hw->wiphy->fw_version), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1942 | "%u.%u.%u.%u", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1943 | IL_UCODE_MAJOR(il->ucode_ver), |
| 1944 | IL_UCODE_MINOR(il->ucode_ver), |
| 1945 | IL_UCODE_API(il->ucode_ver), |
| 1946 | IL_UCODE_SERIAL(il->ucode_ver)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1947 | |
| 1948 | /* |
| 1949 | * For any of the failures below (before allocating pci memory) |
| 1950 | * we will try to load a version with a smaller API -- maybe the |
| 1951 | * user just got a corrupted version of the latest API. |
| 1952 | */ |
| 1953 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1954 | D_INFO("f/w package hdr ucode version raw = 0x%x\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1955 | il->ucode_ver); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1956 | D_INFO("f/w package hdr runtime inst size = %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1957 | pieces.inst_size); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1958 | D_INFO("f/w package hdr runtime data size = %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1959 | pieces.data_size); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1960 | D_INFO("f/w package hdr init inst size = %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1961 | pieces.init_size); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1962 | D_INFO("f/w package hdr init data size = %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1963 | pieces.init_data_size); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 1964 | D_INFO("f/w package hdr boot inst size = %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1965 | pieces.boot_size); |
| 1966 | |
| 1967 | /* Verify that uCode images will fit in card's SRAM */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1968 | if (pieces.inst_size > il->hw_params.max_inst_size) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1969 | IL_ERR("uCode instr len %Zd too large to fit in\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1970 | pieces.inst_size); |
| 1971 | goto try_again; |
| 1972 | } |
| 1973 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1974 | if (pieces.data_size > il->hw_params.max_data_size) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1975 | IL_ERR("uCode data len %Zd too large to fit in\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1976 | pieces.data_size); |
| 1977 | goto try_again; |
| 1978 | } |
| 1979 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1980 | if (pieces.init_size > il->hw_params.max_inst_size) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1981 | IL_ERR("uCode init instr len %Zd too large to fit in\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1982 | pieces.init_size); |
| 1983 | goto try_again; |
| 1984 | } |
| 1985 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1986 | if (pieces.init_data_size > il->hw_params.max_data_size) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1987 | IL_ERR("uCode init data len %Zd too large to fit in\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1988 | pieces.init_data_size); |
| 1989 | goto try_again; |
| 1990 | } |
| 1991 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 1992 | if (pieces.boot_size > il->hw_params.max_bsm_size) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 1993 | IL_ERR("uCode boot instr len %Zd too large to fit in\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 1994 | pieces.boot_size); |
| 1995 | goto try_again; |
| 1996 | } |
| 1997 | |
| 1998 | /* Allocate ucode buffers for card's bus-master loading ... */ |
| 1999 | |
| 2000 | /* Runtime instructions and 2 copies of data: |
| 2001 | * 1) unmodified from disk |
| 2002 | * 2) backup cache for save/restore during power-downs */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2003 | il->ucode_code.len = pieces.inst_size; |
| 2004 | il_alloc_fw_desc(il->pci_dev, &il->ucode_code); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2005 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2006 | il->ucode_data.len = pieces.data_size; |
| 2007 | il_alloc_fw_desc(il->pci_dev, &il->ucode_data); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2008 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2009 | il->ucode_data_backup.len = pieces.data_size; |
| 2010 | il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2011 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2012 | if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || |
| 2013 | !il->ucode_data_backup.v_addr) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2014 | goto err_pci_alloc; |
| 2015 | |
| 2016 | /* Initialization instructions and data */ |
| 2017 | if (pieces.init_size && pieces.init_data_size) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2018 | il->ucode_init.len = pieces.init_size; |
| 2019 | il_alloc_fw_desc(il->pci_dev, &il->ucode_init); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2020 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2021 | il->ucode_init_data.len = pieces.init_data_size; |
| 2022 | il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2023 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2024 | if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2025 | goto err_pci_alloc; |
| 2026 | } |
| 2027 | |
| 2028 | /* Bootstrap (instructions only, no data) */ |
| 2029 | if (pieces.boot_size) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2030 | il->ucode_boot.len = pieces.boot_size; |
| 2031 | il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2032 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2033 | if (!il->ucode_boot.v_addr) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2034 | goto err_pci_alloc; |
| 2035 | } |
| 2036 | |
| 2037 | /* Now that we can no longer fail, copy information */ |
| 2038 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2039 | il->sta_key_max_num = STA_KEY_MAX_NUM; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2040 | |
| 2041 | /* Copy images into buffers for card's bus-master reads ... */ |
| 2042 | |
| 2043 | /* Runtime instructions (first block of data in file) */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2044 | D_INFO("Copying (but not loading) uCode instr len %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2045 | pieces.inst_size); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2046 | memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2047 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2048 | D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2049 | il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2050 | |
| 2051 | /* |
| 2052 | * Runtime data |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2053 | * NOTE: Copy into backup buffer will be done in il_up() |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2054 | */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2055 | D_INFO("Copying (but not loading) uCode data len %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2056 | pieces.data_size); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2057 | memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); |
| 2058 | memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2059 | |
| 2060 | /* Initialization instructions */ |
| 2061 | if (pieces.init_size) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2062 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2063 | "Copying (but not loading) init instr len %Zd\n", |
| 2064 | pieces.init_size); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2065 | memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2066 | } |
| 2067 | |
| 2068 | /* Initialization data */ |
| 2069 | if (pieces.init_data_size) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2070 | D_INFO( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2071 | "Copying (but not loading) init data len %Zd\n", |
| 2072 | pieces.init_data_size); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2073 | memcpy(il->ucode_init_data.v_addr, pieces.init_data, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2074 | pieces.init_data_size); |
| 2075 | } |
| 2076 | |
| 2077 | /* Bootstrap instructions */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2078 | D_INFO("Copying (but not loading) boot instr len %Zd\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2079 | pieces.boot_size); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2080 | memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2081 | |
| 2082 | /* |
| 2083 | * figure out the offset of chain noise reset and gain commands |
| 2084 | * base on the size of standard phy calibration commands table size |
| 2085 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2086 | il->_4965.phy_calib_chain_noise_reset_cmd = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2087 | standard_phy_calibration_size; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2088 | il->_4965.phy_calib_chain_noise_gain_cmd = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2089 | standard_phy_calibration_size + 1; |
| 2090 | |
| 2091 | /************************************************** |
| 2092 | * This is still part of probe() in a sense... |
| 2093 | * |
| 2094 | * 9. Setup and register with mac80211 and debugfs |
| 2095 | **************************************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2096 | err = il4965_mac_setup_register(il, max_probe_length); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2097 | if (err) |
| 2098 | goto out_unbind; |
| 2099 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2100 | err = il_dbgfs_register(il, DRV_NAME); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2101 | if (err) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2102 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2103 | "failed to create debugfs files. Ignoring error: %d\n", err); |
| 2104 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2105 | err = sysfs_create_group(&il->pci_dev->dev.kobj, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2106 | &il_attribute_group); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2107 | if (err) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2108 | IL_ERR("failed to create sysfs device attributes\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2109 | goto out_unbind; |
| 2110 | } |
| 2111 | |
| 2112 | /* We have our copies now, allow OS release its copies */ |
| 2113 | release_firmware(ucode_raw); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2114 | complete(&il->_4965.firmware_loading_complete); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2115 | return; |
| 2116 | |
| 2117 | try_again: |
| 2118 | /* try next, if any */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2119 | if (il4965_request_firmware(il, false)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2120 | goto out_unbind; |
| 2121 | release_firmware(ucode_raw); |
| 2122 | return; |
| 2123 | |
| 2124 | err_pci_alloc: |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2125 | IL_ERR("failed to allocate pci memory\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2126 | il4965_dealloc_ucode_pci(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2127 | out_unbind: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2128 | complete(&il->_4965.firmware_loading_complete); |
| 2129 | device_release_driver(&il->pci_dev->dev); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2130 | release_firmware(ucode_raw); |
| 2131 | } |
| 2132 | |
| 2133 | static const char * const desc_lookup_text[] = { |
| 2134 | "OK", |
| 2135 | "FAIL", |
| 2136 | "BAD_PARAM", |
| 2137 | "BAD_CHECKSUM", |
| 2138 | "NMI_INTERRUPT_WDG", |
| 2139 | "SYSASSERT", |
| 2140 | "FATAL_ERROR", |
| 2141 | "BAD_COMMAND", |
| 2142 | "HW_ERROR_TUNE_LOCK", |
| 2143 | "HW_ERROR_TEMPERATURE", |
| 2144 | "ILLEGAL_CHAN_FREQ", |
Stanislaw Gruszka | 3b98c7f | 2011-08-26 16:29:35 +0200 | [diff] [blame] | 2145 | "VCC_NOT_STBL", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2146 | "FH_ERROR", |
| 2147 | "NMI_INTERRUPT_HOST", |
| 2148 | "NMI_INTERRUPT_ACTION_PT", |
| 2149 | "NMI_INTERRUPT_UNKNOWN", |
| 2150 | "UCODE_VERSION_MISMATCH", |
| 2151 | "HW_ERROR_ABS_LOCK", |
| 2152 | "HW_ERROR_CAL_LOCK_FAIL", |
| 2153 | "NMI_INTERRUPT_INST_ACTION_PT", |
| 2154 | "NMI_INTERRUPT_DATA_ACTION_PT", |
| 2155 | "NMI_TRM_HW_ER", |
| 2156 | "NMI_INTERRUPT_TRM", |
Joe Perches | 861d9c3 | 2011-07-08 23:20:24 -0700 | [diff] [blame] | 2157 | "NMI_INTERRUPT_BREAK_POINT", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2158 | "DEBUG_0", |
| 2159 | "DEBUG_1", |
| 2160 | "DEBUG_2", |
| 2161 | "DEBUG_3", |
| 2162 | }; |
| 2163 | |
| 2164 | static struct { char *name; u8 num; } advanced_lookup[] = { |
| 2165 | { "NMI_INTERRUPT_WDG", 0x34 }, |
| 2166 | { "SYSASSERT", 0x35 }, |
| 2167 | { "UCODE_VERSION_MISMATCH", 0x37 }, |
| 2168 | { "BAD_COMMAND", 0x38 }, |
| 2169 | { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, |
| 2170 | { "FATAL_ERROR", 0x3D }, |
| 2171 | { "NMI_TRM_HW_ERR", 0x46 }, |
| 2172 | { "NMI_INTERRUPT_TRM", 0x4C }, |
| 2173 | { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, |
| 2174 | { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, |
| 2175 | { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, |
| 2176 | { "NMI_INTERRUPT_HOST", 0x66 }, |
| 2177 | { "NMI_INTERRUPT_ACTION_PT", 0x7C }, |
| 2178 | { "NMI_INTERRUPT_UNKNOWN", 0x84 }, |
| 2179 | { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, |
| 2180 | { "ADVANCED_SYSASSERT", 0 }, |
| 2181 | }; |
| 2182 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2183 | static const char *il4965_desc_lookup(u32 num) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2184 | { |
| 2185 | int i; |
| 2186 | int max = ARRAY_SIZE(desc_lookup_text); |
| 2187 | |
| 2188 | if (num < max) |
| 2189 | return desc_lookup_text[num]; |
| 2190 | |
| 2191 | max = ARRAY_SIZE(advanced_lookup) - 1; |
| 2192 | for (i = 0; i < max; i++) { |
| 2193 | if (advanced_lookup[i].num == num) |
| 2194 | break; |
| 2195 | } |
| 2196 | return advanced_lookup[i].name; |
| 2197 | } |
| 2198 | |
| 2199 | #define ERROR_START_OFFSET (1 * sizeof(u32)) |
| 2200 | #define ERROR_ELEM_SIZE (7 * sizeof(u32)) |
| 2201 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2202 | void il4965_dump_nic_error_log(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2203 | { |
| 2204 | u32 data2, line; |
| 2205 | u32 desc, time, count, base, data1; |
| 2206 | u32 blink1, blink2, ilink1, ilink2; |
| 2207 | u32 pc, hcmd; |
| 2208 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2209 | if (il->ucode_type == UCODE_INIT) { |
| 2210 | base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2211 | } else { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2212 | base = le32_to_cpu(il->card_alive.error_event_table_ptr); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2213 | } |
| 2214 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2215 | if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2216 | IL_ERR( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2217 | "Not valid error log pointer 0x%08X for %s uCode\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2218 | base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2219 | return; |
| 2220 | } |
| 2221 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2222 | count = il_read_targ_mem(il, base); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2223 | |
| 2224 | if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2225 | IL_ERR("Start IWL Error Log Dump:\n"); |
| 2226 | IL_ERR("Status: 0x%08lX, count: %d\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2227 | il->status, count); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2228 | } |
| 2229 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2230 | desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); |
| 2231 | il->isr_stats.err_code = desc; |
| 2232 | pc = il_read_targ_mem(il, base + 2 * sizeof(u32)); |
| 2233 | blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32)); |
| 2234 | blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32)); |
| 2235 | ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32)); |
| 2236 | ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32)); |
| 2237 | data1 = il_read_targ_mem(il, base + 7 * sizeof(u32)); |
| 2238 | data2 = il_read_targ_mem(il, base + 8 * sizeof(u32)); |
| 2239 | line = il_read_targ_mem(il, base + 9 * sizeof(u32)); |
| 2240 | time = il_read_targ_mem(il, base + 11 * sizeof(u32)); |
| 2241 | hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2242 | |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2243 | IL_ERR("Desc Time " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2244 | "data1 data2 line\n"); |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2245 | IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2246 | il4965_desc_lookup(desc), desc, time, data1, data2, line); |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2247 | IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); |
| 2248 | IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2249 | pc, blink1, blink2, ilink1, ilink2, hcmd); |
| 2250 | } |
| 2251 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2252 | static void il4965_rf_kill_ct_config(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2253 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2254 | struct il_ct_kill_config cmd; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2255 | unsigned long flags; |
| 2256 | int ret = 0; |
| 2257 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2258 | spin_lock_irqsave(&il->lock, flags); |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2259 | _il_wr(il, CSR_UCODE_DRV_GP1_CLR, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2260 | CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2261 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2262 | |
| 2263 | cmd.critical_temperature_R = |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2264 | cpu_to_le32(il->hw_params.ct_kill_threshold); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2265 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2266 | ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2267 | sizeof(cmd), &cmd); |
| 2268 | if (ret) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2269 | IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2270 | else |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2271 | D_INFO("REPLY_CT_KILL_CONFIG_CMD " |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2272 | "succeeded, " |
| 2273 | "critical temperature is %d\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2274 | il->hw_params.ct_kill_threshold); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2275 | } |
| 2276 | |
| 2277 | static const s8 default_queue_to_tx_fifo[] = { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2278 | IL_TX_FIFO_VO, |
| 2279 | IL_TX_FIFO_VI, |
| 2280 | IL_TX_FIFO_BE, |
| 2281 | IL_TX_FIFO_BK, |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2282 | IL49_CMD_FIFO_NUM, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2283 | IL_TX_FIFO_UNUSED, |
| 2284 | IL_TX_FIFO_UNUSED, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2285 | }; |
| 2286 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2287 | static int il4965_alive_notify(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2288 | { |
| 2289 | u32 a; |
| 2290 | unsigned long flags; |
| 2291 | int i, chan; |
| 2292 | u32 reg_val; |
| 2293 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2294 | spin_lock_irqsave(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2295 | |
| 2296 | /* Clear 4965's internal Tx Scheduler data base */ |
Stanislaw Gruszka | db54eb5 | 2011-08-24 21:06:33 +0200 | [diff] [blame] | 2297 | il->scd_base_addr = il_rd_prph(il, |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2298 | IL49_SCD_SRAM_BASE_ADDR); |
| 2299 | a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; |
| 2300 | for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2301 | il_write_targ_mem(il, a, 0); |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2302 | for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2303 | il_write_targ_mem(il, a, 0); |
| 2304 | for (; a < il->scd_base_addr + |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2305 | IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2306 | il_write_targ_mem(il, a, 0); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2307 | |
| 2308 | /* Tel 4965 where to find Tx byte count tables */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2309 | il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2310 | il->scd_bc_tbls.dma >> 10); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2311 | |
| 2312 | /* Enable DMA channel */ |
| 2313 | for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) |
Stanislaw Gruszka | 0c1a94e | 2011-08-24 17:37:16 +0200 | [diff] [blame] | 2314 | il_wr(il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2315 | FH_TCSR_CHNL_TX_CONFIG_REG(chan), |
| 2316 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | |
| 2317 | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); |
| 2318 | |
| 2319 | /* Update FH chicken bits */ |
Stanislaw Gruszka | 0c1a94e | 2011-08-24 17:37:16 +0200 | [diff] [blame] | 2320 | reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); |
| 2321 | il_wr(il, FH_TX_CHICKEN_BITS_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2322 | reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); |
| 2323 | |
| 2324 | /* Disable chain mode for all queues */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2325 | il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2326 | |
| 2327 | /* Initialize each Tx queue (including the command queue) */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2328 | for (i = 0; i < il->hw_params.max_txq_num; i++) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2329 | |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 2330 | /* TFD circular buffer read/write idxes */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2331 | il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); |
Stanislaw Gruszka | 0c1a94e | 2011-08-24 17:37:16 +0200 | [diff] [blame] | 2332 | il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2333 | |
| 2334 | /* Max Tx Window size for Scheduler-ACK mode */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2335 | il_write_targ_mem(il, il->scd_base_addr + |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2336 | IL49_SCD_CONTEXT_QUEUE_OFFSET(i), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2337 | (SCD_WIN_SIZE << |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2338 | IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & |
| 2339 | IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2340 | |
| 2341 | /* Frame limit */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2342 | il_write_targ_mem(il, il->scd_base_addr + |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2343 | IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2344 | sizeof(u32), |
| 2345 | (SCD_FRAME_LIMIT << |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2346 | IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & |
| 2347 | IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2348 | |
| 2349 | } |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 2350 | il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2351 | (1 << il->hw_params.max_txq_num) - 1); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2352 | |
| 2353 | /* Activate all Tx DMA/FIFO channels */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2354 | il4965_txq_set_sched(il, IL_MASK(0, 6)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2355 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2356 | il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2357 | |
| 2358 | /* make sure all queue are not stopped */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2359 | memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2360 | for (i = 0; i < 4; i++) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2361 | atomic_set(&il->queue_stop_count[i], 0); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2362 | |
| 2363 | /* reset to 0 to enable all the queue first */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2364 | il->txq_ctx_active_msk = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2365 | /* Map each Tx/cmd queue to its corresponding fifo */ |
| 2366 | BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); |
| 2367 | |
| 2368 | for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { |
| 2369 | int ac = default_queue_to_tx_fifo[i]; |
| 2370 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2371 | il_txq_ctx_activate(il, i); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2372 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2373 | if (ac == IL_TX_FIFO_UNUSED) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2374 | continue; |
| 2375 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2376 | il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2377 | } |
| 2378 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2379 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2380 | |
| 2381 | return 0; |
| 2382 | } |
| 2383 | |
| 2384 | /** |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2385 | * il4965_alive_start - called after REPLY_ALIVE notification received |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2386 | * from protocol/runtime uCode (initialization uCode's |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2387 | * Alive gets handled by il_init_alive_start()). |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2388 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2389 | static void il4965_alive_start(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2390 | { |
| 2391 | int ret = 0; |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 2392 | struct il_rxon_context *ctx = &il->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2393 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2394 | D_INFO("Runtime Alive received.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2395 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2396 | if (il->card_alive.is_valid != UCODE_VALID_OK) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2397 | /* We had an error bringing up the hardware, so take it |
| 2398 | * all the way back down so we can try again */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2399 | D_INFO("Alive failed.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2400 | goto restart; |
| 2401 | } |
| 2402 | |
| 2403 | /* Initialize uCode has loaded Runtime uCode ... verify inst image. |
| 2404 | * This is a paranoid check, because we would not have gotten the |
| 2405 | * "runtime" alive if code weren't properly loaded. */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2406 | if (il4965_verify_ucode(il)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2407 | /* Runtime instruction load was bad; |
| 2408 | * take it all the way back down so we can try again */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2409 | D_INFO("Bad runtime uCode load.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2410 | goto restart; |
| 2411 | } |
| 2412 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2413 | ret = il4965_alive_notify(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2414 | if (ret) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2415 | IL_WARN( |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2416 | "Could not complete ALIVE transition [ntf]: %d\n", ret); |
| 2417 | goto restart; |
| 2418 | } |
| 2419 | |
| 2420 | |
| 2421 | /* After the ALIVE response, we can send host commands to the uCode */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2422 | set_bit(STATUS_ALIVE, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2423 | |
| 2424 | /* Enable watchdog to monitor the driver tx queues */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2425 | il_setup_watchdog(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2426 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2427 | if (il_is_rfkill(il)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2428 | return; |
| 2429 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2430 | ieee80211_wake_queues(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2431 | |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 2432 | il->active_rate = RATES_MASK; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2433 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2434 | if (il_is_associated_ctx(ctx)) { |
| 2435 | struct il_rxon_cmd *active_rxon = |
| 2436 | (struct il_rxon_cmd *)&ctx->active; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2437 | /* apply any changes in staging */ |
| 2438 | ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; |
| 2439 | active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; |
| 2440 | } else { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2441 | /* Initialize our rx_config data */ |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2442 | il_connection_init_rx_config(il, &il->ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2443 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2444 | if (il->cfg->ops->hcmd->set_rxon_chain) |
| 2445 | il->cfg->ops->hcmd->set_rxon_chain(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2446 | } |
| 2447 | |
| 2448 | /* Configure bluetooth coexistence if enabled */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2449 | il_send_bt_config(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2450 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2451 | il4965_reset_run_time_calib(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2452 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2453 | set_bit(STATUS_READY, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2454 | |
| 2455 | /* Configure the adapter for unassociated operation */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2456 | il_commit_rxon(il, ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2457 | |
| 2458 | /* At this point, the NIC is initialized and operational */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2459 | il4965_rf_kill_ct_config(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2460 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2461 | D_INFO("ALIVE processing complete.\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2462 | wake_up(&il->wait_command_queue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2463 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2464 | il_power_update_mode(il, true); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2465 | D_INFO("Updated power mode\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2466 | |
| 2467 | return; |
| 2468 | |
| 2469 | restart: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2470 | queue_work(il->workqueue, &il->restart); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2471 | } |
| 2472 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2473 | static void il4965_cancel_deferred_work(struct il_priv *il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2474 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2475 | static void __il4965_down(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2476 | { |
| 2477 | unsigned long flags; |
Stanislaw Gruszka | ab42b40 | 2011-04-28 11:51:24 +0200 | [diff] [blame] | 2478 | int exit_pending; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2479 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2480 | D_INFO(DRV_NAME " is going down\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2481 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2482 | il_scan_cancel_timeout(il, 200); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2483 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2484 | exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2485 | |
| 2486 | /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set |
| 2487 | * to prevent rearm timer */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2488 | del_timer_sync(&il->watchdog); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2489 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2490 | il_clear_ucode_stations(il, NULL); |
| 2491 | il_dealloc_bcast_stations(il); |
| 2492 | il_clear_driver_stations(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2493 | |
| 2494 | /* Unblock any waiting calls */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2495 | wake_up_all(&il->wait_command_queue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2496 | |
| 2497 | /* Wipe out the EXIT_PENDING status bit if we are not actually |
| 2498 | * exiting the module */ |
| 2499 | if (!exit_pending) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2500 | clear_bit(STATUS_EXIT_PENDING, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2501 | |
| 2502 | /* stop and reset the on-board processor */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2503 | _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2504 | |
| 2505 | /* tell the device to stop sending interrupts */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2506 | spin_lock_irqsave(&il->lock, flags); |
| 2507 | il_disable_interrupts(il); |
| 2508 | spin_unlock_irqrestore(&il->lock, flags); |
| 2509 | il4965_synchronize_irq(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2510 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2511 | if (il->mac80211_registered) |
| 2512 | ieee80211_stop_queues(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2513 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2514 | /* If we have not previously called il_init() then |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2515 | * clear all bits but the RF Kill bit and return */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2516 | if (!il_is_init(il)) { |
| 2517 | il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2518 | STATUS_RF_KILL_HW | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2519 | test_bit(STATUS_GEO_CONFIGURED, &il->status) << |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2520 | STATUS_GEO_CONFIGURED | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2521 | test_bit(STATUS_EXIT_PENDING, &il->status) << |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2522 | STATUS_EXIT_PENDING; |
| 2523 | goto exit; |
| 2524 | } |
| 2525 | |
| 2526 | /* ...otherwise clear out all the status bits but the RF Kill |
| 2527 | * bit and continue taking the NIC down. */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2528 | il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2529 | STATUS_RF_KILL_HW | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2530 | test_bit(STATUS_GEO_CONFIGURED, &il->status) << |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2531 | STATUS_GEO_CONFIGURED | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2532 | test_bit(STATUS_FW_ERROR, &il->status) << |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2533 | STATUS_FW_ERROR | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2534 | test_bit(STATUS_EXIT_PENDING, &il->status) << |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2535 | STATUS_EXIT_PENDING; |
| 2536 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2537 | il4965_txq_ctx_stop(il); |
| 2538 | il4965_rxq_stop(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2539 | |
| 2540 | /* Power-down device's busmaster DMA clocks */ |
Stanislaw Gruszka | db54eb5 | 2011-08-24 21:06:33 +0200 | [diff] [blame] | 2541 | il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2542 | udelay(5); |
| 2543 | |
| 2544 | /* Make sure (redundant) we've released our request to stay awake */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2545 | il_clear_bit(il, CSR_GP_CNTRL, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2546 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
| 2547 | |
| 2548 | /* Stop the device, and put it in low power state */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2549 | il_apm_stop(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2550 | |
| 2551 | exit: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2552 | memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2553 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2554 | dev_kfree_skb(il->beacon_skb); |
| 2555 | il->beacon_skb = NULL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2556 | |
| 2557 | /* clear out any free frames */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2558 | il4965_clear_free_frames(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2559 | } |
| 2560 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2561 | static void il4965_down(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2562 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2563 | mutex_lock(&il->mutex); |
| 2564 | __il4965_down(il); |
| 2565 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2566 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2567 | il4965_cancel_deferred_work(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2568 | } |
| 2569 | |
| 2570 | #define HW_READY_TIMEOUT (50) |
| 2571 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2572 | static int il4965_set_hw_ready(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2573 | { |
| 2574 | int ret = 0; |
| 2575 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2576 | il_set_bit(il, CSR_HW_IF_CONFIG_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2577 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); |
| 2578 | |
| 2579 | /* See if we got it */ |
Stanislaw Gruszka | 142b343 | 2011-08-24 15:22:57 +0200 | [diff] [blame] | 2580 | ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2581 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, |
| 2582 | CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, |
| 2583 | HW_READY_TIMEOUT); |
| 2584 | if (ret != -ETIMEDOUT) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2585 | il->hw_ready = true; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2586 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2587 | il->hw_ready = false; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2588 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2589 | D_INFO("hardware %s\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2590 | (il->hw_ready == 1) ? "ready" : "not ready"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2591 | return ret; |
| 2592 | } |
| 2593 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2594 | static int il4965_prepare_card_hw(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2595 | { |
| 2596 | int ret = 0; |
| 2597 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2598 | D_INFO("il4965_prepare_card_hw enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2599 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2600 | ret = il4965_set_hw_ready(il); |
| 2601 | if (il->hw_ready) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2602 | return ret; |
| 2603 | |
| 2604 | /* If HW is not ready, prepare the conditions to check again */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2605 | il_set_bit(il, CSR_HW_IF_CONFIG_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2606 | CSR_HW_IF_CONFIG_REG_PREPARE); |
| 2607 | |
Stanislaw Gruszka | 142b343 | 2011-08-24 15:22:57 +0200 | [diff] [blame] | 2608 | ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2609 | ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, |
| 2610 | CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); |
| 2611 | |
| 2612 | /* HW should be ready by now, check again. */ |
| 2613 | if (ret != -ETIMEDOUT) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2614 | il4965_set_hw_ready(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2615 | |
| 2616 | return ret; |
| 2617 | } |
| 2618 | |
| 2619 | #define MAX_HW_RESTARTS 5 |
| 2620 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2621 | static int __il4965_up(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2622 | { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2623 | int i; |
| 2624 | int ret; |
| 2625 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2626 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2627 | IL_WARN("Exit pending; will not bring the NIC up\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2628 | return -EIO; |
| 2629 | } |
| 2630 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2631 | if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2632 | IL_ERR("ucode not available for device bringup\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2633 | return -EIO; |
| 2634 | } |
| 2635 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2636 | ret = il4965_alloc_bcast_station(il, &il->ctx); |
| 2637 | if (ret) { |
| 2638 | il_dealloc_bcast_stations(il); |
| 2639 | return ret; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2640 | } |
| 2641 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2642 | il4965_prepare_card_hw(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2643 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2644 | if (!il->hw_ready) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2645 | IL_WARN("Exit HW not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2646 | return -EIO; |
| 2647 | } |
| 2648 | |
| 2649 | /* If platform's RF_KILL switch is NOT set to KILL */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2650 | if (_il_rd(il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2651 | CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2652 | clear_bit(STATUS_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2653 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2654 | set_bit(STATUS_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2655 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2656 | if (il_is_rfkill(il)) { |
| 2657 | wiphy_rfkill_set_hw_state(il->hw->wiphy, true); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2658 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2659 | il_enable_interrupts(il); |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2660 | IL_WARN("Radio disabled by HW RF Kill switch\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2661 | return 0; |
| 2662 | } |
| 2663 | |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2664 | _il_wr(il, CSR_INT, 0xFFFFFFFF); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2665 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2666 | /* must be initialised before il_hw_nic_init */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2667 | il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2668 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2669 | ret = il4965_hw_nic_init(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2670 | if (ret) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2671 | IL_ERR("Unable to init nic\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2672 | return ret; |
| 2673 | } |
| 2674 | |
| 2675 | /* make sure rfkill handshake bits are cleared */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2676 | _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); |
| 2677 | _il_wr(il, CSR_UCODE_DRV_GP1_CLR, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2678 | CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); |
| 2679 | |
| 2680 | /* clear (again), then enable host interrupts */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2681 | _il_wr(il, CSR_INT, 0xFFFFFFFF); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2682 | il_enable_interrupts(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2683 | |
| 2684 | /* really make sure rfkill handshake bits are cleared */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2685 | _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); |
| 2686 | _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2687 | |
| 2688 | /* Copy original ucode data image from disk into backup cache. |
| 2689 | * This will be used to initialize the on-board processor's |
| 2690 | * data SRAM for a clean start when the runtime program first loads. */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2691 | memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, |
| 2692 | il->ucode_data.len); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2693 | |
| 2694 | for (i = 0; i < MAX_HW_RESTARTS; i++) { |
| 2695 | |
| 2696 | /* load bootstrap state machine, |
| 2697 | * load bootstrap program into processor's memory, |
| 2698 | * prepare to load the "initialize" uCode */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2699 | ret = il->cfg->ops->lib->load_ucode(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2700 | |
| 2701 | if (ret) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2702 | IL_ERR("Unable to set up bootstrap uCode: %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2703 | ret); |
| 2704 | continue; |
| 2705 | } |
| 2706 | |
| 2707 | /* start card; "initialize" will load runtime ucode */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2708 | il4965_nic_start(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2709 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2710 | D_INFO(DRV_NAME " is coming up\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2711 | |
| 2712 | return 0; |
| 2713 | } |
| 2714 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2715 | set_bit(STATUS_EXIT_PENDING, &il->status); |
| 2716 | __il4965_down(il); |
| 2717 | clear_bit(STATUS_EXIT_PENDING, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2718 | |
| 2719 | /* tried to restart and config the device for as long as our |
| 2720 | * patience could withstand */ |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2721 | IL_ERR("Unable to initialize device after %d attempts.\n", i); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2722 | return -EIO; |
| 2723 | } |
| 2724 | |
| 2725 | |
| 2726 | /***************************************************************************** |
| 2727 | * |
| 2728 | * Workqueue callbacks |
| 2729 | * |
| 2730 | *****************************************************************************/ |
| 2731 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2732 | static void il4965_bg_init_alive_start(struct work_struct *data) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2733 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2734 | struct il_priv *il = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2735 | container_of(data, struct il_priv, init_alive_start.work); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2736 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2737 | mutex_lock(&il->mutex); |
| 2738 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 2739 | goto out; |
| 2740 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2741 | il->cfg->ops->lib->init_alive_start(il); |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 2742 | out: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2743 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2744 | } |
| 2745 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2746 | static void il4965_bg_alive_start(struct work_struct *data) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2747 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2748 | struct il_priv *il = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2749 | container_of(data, struct il_priv, alive_start.work); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2750 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2751 | mutex_lock(&il->mutex); |
| 2752 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 2753 | goto out; |
| 2754 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2755 | il4965_alive_start(il); |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 2756 | out: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2757 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2758 | } |
| 2759 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2760 | static void il4965_bg_run_time_calib_work(struct work_struct *work) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2761 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2762 | struct il_priv *il = container_of(work, struct il_priv, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2763 | run_time_calib_work); |
| 2764 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2765 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2766 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2767 | if (test_bit(STATUS_EXIT_PENDING, &il->status) || |
| 2768 | test_bit(STATUS_SCANNING, &il->status)) { |
| 2769 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2770 | return; |
| 2771 | } |
| 2772 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2773 | if (il->start_calib) { |
| 2774 | il4965_chain_noise_calibration(il, |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 2775 | (void *)&il->_4965.stats); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2776 | il4965_sensitivity_calibration(il, |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 2777 | (void *)&il->_4965.stats); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2778 | } |
| 2779 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2780 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2781 | } |
| 2782 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2783 | static void il4965_bg_restart(struct work_struct *data) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2784 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2785 | struct il_priv *il = container_of(data, struct il_priv, restart); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2786 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2787 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2788 | return; |
| 2789 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2790 | if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2791 | mutex_lock(&il->mutex); |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2792 | il->ctx.vif = NULL; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2793 | il->is_open = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2794 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2795 | __il4965_down(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2796 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2797 | mutex_unlock(&il->mutex); |
| 2798 | il4965_cancel_deferred_work(il); |
| 2799 | ieee80211_restart_hw(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2800 | } else { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2801 | il4965_down(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2802 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2803 | mutex_lock(&il->mutex); |
| 2804 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) { |
| 2805 | mutex_unlock(&il->mutex); |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 2806 | return; |
| 2807 | } |
| 2808 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2809 | __il4965_up(il); |
| 2810 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2811 | } |
| 2812 | } |
| 2813 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2814 | static void il4965_bg_rx_replenish(struct work_struct *data) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2815 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2816 | struct il_priv *il = |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2817 | container_of(data, struct il_priv, rx_replenish); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2818 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2819 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2820 | return; |
| 2821 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2822 | mutex_lock(&il->mutex); |
| 2823 | il4965_rx_replenish(il); |
| 2824 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2825 | } |
| 2826 | |
| 2827 | /***************************************************************************** |
| 2828 | * |
| 2829 | * mac80211 entry point functions |
| 2830 | * |
| 2831 | *****************************************************************************/ |
| 2832 | |
| 2833 | #define UCODE_READY_TIMEOUT (4 * HZ) |
| 2834 | |
| 2835 | /* |
| 2836 | * Not a mac80211 entry point function, but it fits in with all the |
| 2837 | * other mac80211 functions grouped here. |
| 2838 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2839 | static int il4965_mac_setup_register(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2840 | u32 max_probe_length) |
| 2841 | { |
| 2842 | int ret; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2843 | struct ieee80211_hw *hw = il->hw; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2844 | |
| 2845 | hw->rate_control_algorithm = "iwl-4965-rs"; |
| 2846 | |
| 2847 | /* Tell mac80211 our characteristics */ |
| 2848 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
| 2849 | IEEE80211_HW_AMPDU_AGGREGATION | |
| 2850 | IEEE80211_HW_NEED_DTIM_PERIOD | |
| 2851 | IEEE80211_HW_SPECTRUM_MGMT | |
| 2852 | IEEE80211_HW_REPORTS_TX_ACK_STATUS; |
| 2853 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2854 | if (il->cfg->sku & IL_SKU_N) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2855 | hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | |
| 2856 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; |
| 2857 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2858 | hw->sta_data_size = sizeof(struct il_station_priv); |
| 2859 | hw->vif_data_size = sizeof(struct il_vif_priv); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2860 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 2861 | hw->wiphy->interface_modes |= il->ctx.interface_modes; |
| 2862 | hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2863 | |
| 2864 | hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | |
| 2865 | WIPHY_FLAG_DISABLE_BEACON_HINTS; |
| 2866 | |
| 2867 | /* |
| 2868 | * For now, disable PS by default because it affects |
| 2869 | * RX performance significantly. |
| 2870 | */ |
| 2871 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
| 2872 | |
| 2873 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
| 2874 | /* we create the 802.11 header and a zero-length SSID element */ |
| 2875 | hw->wiphy->max_scan_ie_len = max_probe_length - 24 - 2; |
| 2876 | |
| 2877 | /* Default value; 4 EDCA QOS priorities */ |
| 2878 | hw->queues = 4; |
| 2879 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2880 | hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2881 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2882 | if (il->bands[IEEE80211_BAND_2GHZ].n_channels) |
| 2883 | il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 2884 | &il->bands[IEEE80211_BAND_2GHZ]; |
| 2885 | if (il->bands[IEEE80211_BAND_5GHZ].n_channels) |
| 2886 | il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 2887 | &il->bands[IEEE80211_BAND_5GHZ]; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2888 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2889 | il_leds_init(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2890 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2891 | ret = ieee80211_register_hw(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2892 | if (ret) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2893 | IL_ERR("Failed to register hw (error %d)\n", ret); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2894 | return ret; |
| 2895 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2896 | il->mac80211_registered = 1; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2897 | |
| 2898 | return 0; |
| 2899 | } |
| 2900 | |
| 2901 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2902 | int il4965_mac_start(struct ieee80211_hw *hw) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2903 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2904 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2905 | int ret; |
| 2906 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2907 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2908 | |
| 2909 | /* we should be verifying the device is ready to be opened */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2910 | mutex_lock(&il->mutex); |
| 2911 | ret = __il4965_up(il); |
| 2912 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2913 | |
| 2914 | if (ret) |
| 2915 | return ret; |
| 2916 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2917 | if (il_is_rfkill(il)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2918 | goto out; |
| 2919 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2920 | D_INFO("Start UP work done.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2921 | |
| 2922 | /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from |
| 2923 | * mac80211 will not be run successfully. */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2924 | ret = wait_event_timeout(il->wait_command_queue, |
| 2925 | test_bit(STATUS_READY, &il->status), |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2926 | UCODE_READY_TIMEOUT); |
| 2927 | if (!ret) { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2928 | if (!test_bit(STATUS_READY, &il->status)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 2929 | IL_ERR("START_ALIVE timeout after %dms.\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2930 | jiffies_to_msecs(UCODE_READY_TIMEOUT)); |
| 2931 | return -ETIMEDOUT; |
| 2932 | } |
| 2933 | } |
| 2934 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2935 | il4965_led_enable(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2936 | |
| 2937 | out: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2938 | il->is_open = 1; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2939 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2940 | return 0; |
| 2941 | } |
| 2942 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2943 | void il4965_mac_stop(struct ieee80211_hw *hw) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2944 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2945 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2946 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2947 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2948 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2949 | if (!il->is_open) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2950 | return; |
| 2951 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2952 | il->is_open = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2953 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2954 | il4965_down(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2955 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2956 | flush_workqueue(il->workqueue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2957 | |
Stanislaw Gruszka | a078a1f | 2011-04-28 11:51:25 +0200 | [diff] [blame] | 2958 | /* User space software may expect getting rfkill changes |
| 2959 | * even if interface is down */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 2960 | _il_wr(il, CSR_INT, 0xFFFFFFFF); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2961 | il_enable_rfkill_int(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2962 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2963 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2964 | } |
| 2965 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2966 | void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2967 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2968 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2969 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2970 | D_MACDUMP("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2971 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2972 | D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2973 | ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); |
| 2974 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2975 | if (il4965_tx_skb(il, skb)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2976 | dev_kfree_skb_any(skb); |
| 2977 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2978 | D_MACDUMP("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2979 | } |
| 2980 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2981 | void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2982 | struct ieee80211_vif *vif, |
| 2983 | struct ieee80211_key_conf *keyconf, |
| 2984 | struct ieee80211_sta *sta, |
| 2985 | u32 iv32, u16 *phase1key) |
| 2986 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2987 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2988 | struct il_vif_priv *vif_priv = (void *)vif->drv_priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2989 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2990 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2991 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 2992 | il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2993 | iv32, phase1key); |
| 2994 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 2995 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2996 | } |
| 2997 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 2998 | int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 2999 | struct ieee80211_vif *vif, struct ieee80211_sta *sta, |
| 3000 | struct ieee80211_key_conf *key) |
| 3001 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3002 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3003 | struct il_vif_priv *vif_priv = (void *)vif->drv_priv; |
| 3004 | struct il_rxon_context *ctx = vif_priv->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3005 | int ret; |
| 3006 | u8 sta_id; |
| 3007 | bool is_default_wep_key = false; |
| 3008 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3009 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3010 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3011 | if (il->cfg->mod_params->sw_crypto) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3012 | D_MAC80211("leave - hwcrypto disabled\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3013 | return -EOPNOTSUPP; |
| 3014 | } |
| 3015 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3016 | sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3017 | if (sta_id == IL_INVALID_STATION) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3018 | return -EINVAL; |
| 3019 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3020 | mutex_lock(&il->mutex); |
| 3021 | il_scan_cancel_timeout(il, 100); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3022 | |
| 3023 | /* |
| 3024 | * If we are getting WEP group key and we didn't receive any key mapping |
| 3025 | * so far, we are in legacy wep mode (group key only), otherwise we are |
| 3026 | * in 1X mode. |
| 3027 | * In legacy wep mode, we use another host command to the uCode. |
| 3028 | */ |
| 3029 | if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || |
| 3030 | key->cipher == WLAN_CIPHER_SUITE_WEP104) && |
| 3031 | !sta) { |
| 3032 | if (cmd == SET_KEY) |
| 3033 | is_default_wep_key = !ctx->key_mapping_keys; |
| 3034 | else |
| 3035 | is_default_wep_key = |
| 3036 | (key->hw_key_idx == HW_KEY_DEFAULT); |
| 3037 | } |
| 3038 | |
| 3039 | switch (cmd) { |
| 3040 | case SET_KEY: |
| 3041 | if (is_default_wep_key) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3042 | ret = il4965_set_default_wep_key(il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3043 | vif_priv->ctx, key); |
| 3044 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3045 | ret = il4965_set_dynamic_key(il, vif_priv->ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3046 | key, sta_id); |
| 3047 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3048 | D_MAC80211("enable hwcrypto key\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3049 | break; |
| 3050 | case DISABLE_KEY: |
| 3051 | if (is_default_wep_key) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3052 | ret = il4965_remove_default_wep_key(il, ctx, key); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3053 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3054 | ret = il4965_remove_dynamic_key(il, ctx, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3055 | key, sta_id); |
| 3056 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3057 | D_MAC80211("disable hwcrypto key\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3058 | break; |
| 3059 | default: |
| 3060 | ret = -EINVAL; |
| 3061 | } |
| 3062 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3063 | mutex_unlock(&il->mutex); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3064 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3065 | |
| 3066 | return ret; |
| 3067 | } |
| 3068 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3069 | int il4965_mac_ampdu_action(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3070 | struct ieee80211_vif *vif, |
| 3071 | enum ieee80211_ampdu_mlme_action action, |
| 3072 | struct ieee80211_sta *sta, u16 tid, u16 *ssn, |
| 3073 | u8 buf_size) |
| 3074 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3075 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3076 | int ret = -EINVAL; |
| 3077 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3078 | D_HT("A-MPDU action on addr %pM tid %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3079 | sta->addr, tid); |
| 3080 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3081 | if (!(il->cfg->sku & IL_SKU_N)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3082 | return -EACCES; |
| 3083 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3084 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3085 | |
| 3086 | switch (action) { |
| 3087 | case IEEE80211_AMPDU_RX_START: |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3088 | D_HT("start Rx\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3089 | ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3090 | break; |
| 3091 | case IEEE80211_AMPDU_RX_STOP: |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3092 | D_HT("stop Rx\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3093 | ret = il4965_sta_rx_agg_stop(il, sta, tid); |
| 3094 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3095 | ret = 0; |
| 3096 | break; |
| 3097 | case IEEE80211_AMPDU_TX_START: |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3098 | D_HT("start Tx\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3099 | ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3100 | break; |
| 3101 | case IEEE80211_AMPDU_TX_STOP: |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3102 | D_HT("stop Tx\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3103 | ret = il4965_tx_agg_stop(il, vif, sta, tid); |
| 3104 | if (test_bit(STATUS_EXIT_PENDING, &il->status)) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3105 | ret = 0; |
| 3106 | break; |
| 3107 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 3108 | ret = 0; |
| 3109 | break; |
| 3110 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3111 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3112 | |
| 3113 | return ret; |
| 3114 | } |
| 3115 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3116 | int il4965_mac_sta_add(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3117 | struct ieee80211_vif *vif, |
| 3118 | struct ieee80211_sta *sta) |
| 3119 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3120 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3121 | struct il_station_priv *sta_priv = (void *)sta->drv_priv; |
| 3122 | struct il_vif_priv *vif_priv = (void *)vif->drv_priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3123 | bool is_ap = vif->type == NL80211_IFTYPE_STATION; |
| 3124 | int ret; |
| 3125 | u8 sta_id; |
| 3126 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3127 | D_INFO("received request to add station %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3128 | sta->addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3129 | mutex_lock(&il->mutex); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3130 | D_INFO("proceeding to add station %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3131 | sta->addr); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3132 | sta_priv->common.sta_id = IL_INVALID_STATION; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3133 | |
| 3134 | atomic_set(&sta_priv->pending_frames, 0); |
| 3135 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3136 | ret = il_add_station_common(il, vif_priv->ctx, sta->addr, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3137 | is_ap, sta, &sta_id); |
| 3138 | if (ret) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3139 | IL_ERR("Unable to add station %pM (%d)\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3140 | sta->addr, ret); |
| 3141 | /* Should we return success if return code is EEXIST ? */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3142 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3143 | return ret; |
| 3144 | } |
| 3145 | |
| 3146 | sta_priv->common.sta_id = sta_id; |
| 3147 | |
| 3148 | /* Initialize rate scaling */ |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3149 | D_INFO("Initializing rate scaling for station %pM\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3150 | sta->addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3151 | il4965_rs_rate_init(il, sta, sta_id); |
| 3152 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3153 | |
| 3154 | return 0; |
| 3155 | } |
| 3156 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3157 | void il4965_mac_channel_switch(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3158 | struct ieee80211_channel_switch *ch_switch) |
| 3159 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3160 | struct il_priv *il = hw->priv; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3161 | const struct il_channel_info *ch_info; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3162 | struct ieee80211_conf *conf = &hw->conf; |
| 3163 | struct ieee80211_channel *channel = ch_switch->channel; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3164 | struct il_ht_config *ht_conf = &il->current_ht_config; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3165 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 3166 | struct il_rxon_context *ctx = &il->ctx; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3167 | u16 ch; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3168 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3169 | D_MAC80211("enter\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3170 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3171 | mutex_lock(&il->mutex); |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 3172 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3173 | if (il_is_rfkill(il)) |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 3174 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3175 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3176 | if (test_bit(STATUS_EXIT_PENDING, &il->status) || |
| 3177 | test_bit(STATUS_SCANNING, &il->status) || |
| 3178 | test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 3179 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3180 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3181 | if (!il_is_associated_ctx(ctx)) |
Stanislaw Gruszka | 28a6e57 | 2011-04-28 11:51:32 +0200 | [diff] [blame] | 3182 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3183 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3184 | if (!il->cfg->ops->lib->set_channel_switch) |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3185 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3186 | |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3187 | ch = channel->hw_value; |
| 3188 | if (le16_to_cpu(ctx->active.channel) == ch) |
| 3189 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3190 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3191 | ch_info = il_get_channel_info(il, channel->band, ch); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3192 | if (!il_is_channel_valid(ch_info)) { |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3193 | D_MAC80211("invalid channel\n"); |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3194 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3195 | } |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3196 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3197 | spin_lock_irq(&il->lock); |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3198 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3199 | il->current_ht_config.smps = conf->smps_mode; |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3200 | |
| 3201 | /* Configure HT40 channels */ |
| 3202 | ctx->ht.enabled = conf_is_ht(conf); |
| 3203 | if (ctx->ht.enabled) { |
| 3204 | if (conf_is_ht40_minus(conf)) { |
| 3205 | ctx->ht.extension_chan_offset = |
| 3206 | IEEE80211_HT_PARAM_CHA_SEC_BELOW; |
| 3207 | ctx->ht.is_40mhz = true; |
| 3208 | } else if (conf_is_ht40_plus(conf)) { |
| 3209 | ctx->ht.extension_chan_offset = |
| 3210 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE; |
| 3211 | ctx->ht.is_40mhz = true; |
| 3212 | } else { |
| 3213 | ctx->ht.extension_chan_offset = |
| 3214 | IEEE80211_HT_PARAM_CHA_SEC_NONE; |
| 3215 | ctx->ht.is_40mhz = false; |
| 3216 | } |
| 3217 | } else |
| 3218 | ctx->ht.is_40mhz = false; |
| 3219 | |
| 3220 | if ((le16_to_cpu(ctx->staging.channel) != ch)) |
| 3221 | ctx->staging.flags = 0; |
| 3222 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3223 | il_set_rxon_channel(il, channel, ctx); |
| 3224 | il_set_rxon_ht(il, ht_conf); |
| 3225 | il_set_flags_for_band(il, ctx, channel->band, ctx->vif); |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3226 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3227 | spin_unlock_irq(&il->lock); |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3228 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3229 | il_set_rate(il); |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3230 | /* |
| 3231 | * at this point, staging_rxon has the |
| 3232 | * configuration for channel switch |
| 3233 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3234 | set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); |
| 3235 | il->switch_channel = cpu_to_le16(ch); |
| 3236 | if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { |
| 3237 | clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); |
| 3238 | il->switch_channel = 0; |
Stanislaw Gruszka | 7f1f974 | 2011-06-08 15:28:29 +0200 | [diff] [blame] | 3239 | ieee80211_chswitch_done(ctx->vif, false); |
| 3240 | } |
| 3241 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3242 | out: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3243 | mutex_unlock(&il->mutex); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3244 | D_MAC80211("leave\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3245 | } |
| 3246 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3247 | void il4965_configure_filter(struct ieee80211_hw *hw, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3248 | unsigned int changed_flags, |
| 3249 | unsigned int *total_flags, |
| 3250 | u64 multicast) |
| 3251 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3252 | struct il_priv *il = hw->priv; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3253 | __le32 filter_or = 0, filter_nand = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3254 | |
| 3255 | #define CHK(test, flag) do { \ |
| 3256 | if (*total_flags & (test)) \ |
| 3257 | filter_or |= (flag); \ |
| 3258 | else \ |
| 3259 | filter_nand |= (flag); \ |
| 3260 | } while (0) |
| 3261 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3262 | D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3263 | changed_flags, *total_flags); |
| 3264 | |
| 3265 | CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); |
| 3266 | /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ |
| 3267 | CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); |
| 3268 | CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); |
| 3269 | |
| 3270 | #undef CHK |
| 3271 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3272 | mutex_lock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3273 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 3274 | il->ctx.staging.filter_flags &= ~filter_nand; |
| 3275 | il->ctx.staging.filter_flags |= filter_or; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3276 | |
Stanislaw Gruszka | 17d6e55 | 2011-08-29 12:52:20 +0200 | [diff] [blame] | 3277 | /* |
| 3278 | * Not committing directly because hardware can perform a scan, |
| 3279 | * but we'll eventually commit the filter flags change anyway. |
| 3280 | */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3281 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3282 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3283 | |
| 3284 | /* |
| 3285 | * Receiving all multicast frames is always enabled by the |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3286 | * default flags setup in il_connection_init_rx_config() |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3287 | * since we currently do not support programming multicast |
| 3288 | * filters into the device. |
| 3289 | */ |
| 3290 | *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | |
| 3291 | FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; |
| 3292 | } |
| 3293 | |
| 3294 | /***************************************************************************** |
| 3295 | * |
| 3296 | * driver setup and teardown |
| 3297 | * |
| 3298 | *****************************************************************************/ |
| 3299 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3300 | static void il4965_bg_txpower_work(struct work_struct *work) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3301 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3302 | struct il_priv *il = container_of(work, struct il_priv, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3303 | txpower_work); |
| 3304 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3305 | mutex_lock(&il->mutex); |
Stanislaw Gruszka | f325757 | 2011-04-28 11:36:54 +0200 | [diff] [blame] | 3306 | |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3307 | /* If a scan happened to start before we got here |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 3308 | * then just return; the stats notification will |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3309 | * kick off another scheduled work to compensate for |
| 3310 | * any temperature delta we missed here. */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3311 | if (test_bit(STATUS_EXIT_PENDING, &il->status) || |
| 3312 | test_bit(STATUS_SCANNING, &il->status)) |
Stanislaw Gruszka | f325757 | 2011-04-28 11:36:54 +0200 | [diff] [blame] | 3313 | goto out; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3314 | |
| 3315 | /* Regardless of if we are associated, we must reconfigure the |
| 3316 | * TX power since frames can be sent on non-radar channels while |
| 3317 | * not associated */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3318 | il->cfg->ops->lib->send_tx_power(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3319 | |
| 3320 | /* Update last_temperature to keep is_calib_needed from running |
| 3321 | * when it isn't needed... */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3322 | il->last_temperature = il->temperature; |
Stanislaw Gruszka | f325757 | 2011-04-28 11:36:54 +0200 | [diff] [blame] | 3323 | out: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3324 | mutex_unlock(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3325 | } |
| 3326 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3327 | static void il4965_setup_deferred_work(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3328 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3329 | il->workqueue = create_singlethread_workqueue(DRV_NAME); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3330 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3331 | init_waitqueue_head(&il->wait_command_queue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3332 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3333 | INIT_WORK(&il->restart, il4965_bg_restart); |
| 3334 | INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); |
| 3335 | INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); |
| 3336 | INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); |
| 3337 | INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3338 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3339 | il_setup_scan_deferred_work(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3340 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3341 | INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3342 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 3343 | init_timer(&il->stats_periodic); |
| 3344 | il->stats_periodic.data = (unsigned long)il; |
| 3345 | il->stats_periodic.function = il4965_bg_stats_periodic; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3346 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3347 | init_timer(&il->watchdog); |
| 3348 | il->watchdog.data = (unsigned long)il; |
| 3349 | il->watchdog.function = il_bg_watchdog; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3350 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3351 | tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) |
| 3352 | il4965_irq_tasklet, (unsigned long)il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3353 | } |
| 3354 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3355 | static void il4965_cancel_deferred_work(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3356 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3357 | cancel_work_sync(&il->txpower_work); |
| 3358 | cancel_delayed_work_sync(&il->init_alive_start); |
| 3359 | cancel_delayed_work(&il->alive_start); |
| 3360 | cancel_work_sync(&il->run_time_calib_work); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3361 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3362 | il_cancel_scan_deferred_work(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3363 | |
Stanislaw Gruszka | ebf0d90 | 2011-08-26 15:43:47 +0200 | [diff] [blame] | 3364 | del_timer_sync(&il->stats_periodic); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3365 | } |
| 3366 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3367 | static void il4965_init_hw_rates(struct il_priv *il, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3368 | struct ieee80211_rate *rates) |
| 3369 | { |
| 3370 | int i; |
| 3371 | |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 3372 | for (i = 0; i < RATE_COUNT_LEGACY; i++) { |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 3373 | rates[i].bitrate = il_rates[i].ieee * 5; |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 3374 | rates[i].hw_value = i; /* Rate scaling will work on idxes */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3375 | rates[i].hw_value_short = i; |
| 3376 | rates[i].flags = 0; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3377 | if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3378 | /* |
| 3379 | * If CCK != 1M then set short preamble rate flag. |
| 3380 | */ |
| 3381 | rates[i].flags |= |
Stanislaw Gruszka | 2eb0581 | 2011-08-26 16:07:43 +0200 | [diff] [blame] | 3382 | (il_rates[i].plcp == RATE_1M_PLCP) ? |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3383 | 0 : IEEE80211_RATE_SHORT_PREAMBLE; |
| 3384 | } |
| 3385 | } |
| 3386 | } |
| 3387 | /* |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3388 | * Acquire il->lock before calling this function ! |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3389 | */ |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 3390 | void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3391 | { |
Stanislaw Gruszka | 0c1a94e | 2011-08-24 17:37:16 +0200 | [diff] [blame] | 3392 | il_wr(il, HBUS_TARG_WRPTR, |
Stanislaw Gruszka | 0c2c885 | 2011-11-15 12:30:17 +0100 | [diff] [blame] | 3393 | (idx & 0xff) | (txq_id << 8)); |
| 3394 | il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3395 | } |
| 3396 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3397 | void il4965_tx_queue_set_status(struct il_priv *il, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3398 | struct il_tx_queue *txq, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3399 | int tx_fifo_id, int scd_retry) |
| 3400 | { |
| 3401 | int txq_id = txq->q.id; |
| 3402 | |
| 3403 | /* Find out whether to activate Tx queue */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3404 | int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3405 | |
| 3406 | /* Set up and activate */ |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 3407 | il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), |
| 3408 | (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | |
| 3409 | (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | |
| 3410 | (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | |
| 3411 | (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | |
| 3412 | IL49_SCD_QUEUE_STTS_REG_MSK); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3413 | |
| 3414 | txq->sched_retry = scd_retry; |
| 3415 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3416 | D_INFO("%s %s Queue %d on AC %d\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3417 | active ? "Activate" : "Deactivate", |
| 3418 | scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); |
| 3419 | } |
| 3420 | |
| 3421 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3422 | static int il4965_init_drv(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3423 | { |
| 3424 | int ret; |
| 3425 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3426 | spin_lock_init(&il->sta_lock); |
| 3427 | spin_lock_init(&il->hcmd_lock); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3428 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3429 | INIT_LIST_HEAD(&il->free_frames); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3430 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3431 | mutex_init(&il->mutex); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3432 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3433 | il->ieee_channels = NULL; |
| 3434 | il->ieee_rates = NULL; |
| 3435 | il->band = IEEE80211_BAND_2GHZ; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3436 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3437 | il->iw_mode = NL80211_IFTYPE_STATION; |
| 3438 | il->current_ht_config.smps = IEEE80211_SMPS_STATIC; |
| 3439 | il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3440 | |
| 3441 | /* initialize force reset */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3442 | il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3443 | |
| 3444 | /* Choose which receivers/antennas to use */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3445 | if (il->cfg->ops->hcmd->set_rxon_chain) |
| 3446 | il->cfg->ops->hcmd->set_rxon_chain(il, |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 3447 | &il->ctx); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3448 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3449 | il_init_scan_params(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3450 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3451 | ret = il_init_channel_map(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3452 | if (ret) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3453 | IL_ERR("initializing regulatory failed: %d\n", ret); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3454 | goto err; |
| 3455 | } |
| 3456 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3457 | ret = il_init_geos(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3458 | if (ret) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3459 | IL_ERR("initializing geos failed: %d\n", ret); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3460 | goto err_free_channel_map; |
| 3461 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3462 | il4965_init_hw_rates(il, il->ieee_rates); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3463 | |
| 3464 | return 0; |
| 3465 | |
| 3466 | err_free_channel_map: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3467 | il_free_channel_map(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3468 | err: |
| 3469 | return ret; |
| 3470 | } |
| 3471 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3472 | static void il4965_uninit_drv(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3473 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3474 | il4965_calib_free_results(il); |
| 3475 | il_free_geos(il); |
| 3476 | il_free_channel_map(il); |
| 3477 | kfree(il->scan_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3478 | } |
| 3479 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3480 | static void il4965_hw_detect(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3481 | { |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 3482 | il->hw_rev = _il_rd(il, CSR_HW_REV); |
| 3483 | il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3484 | il->rev_id = il->pci_dev->revision; |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3485 | D_INFO("HW Revision ID = 0x%X\n", il->rev_id); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3486 | } |
| 3487 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3488 | static int il4965_set_hw_params(struct il_priv *il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3489 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3490 | il->hw_params.max_rxq_size = RX_QUEUE_SIZE; |
| 3491 | il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; |
| 3492 | if (il->cfg->mod_params->amsdu_size_8K) |
| 3493 | il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3494 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3495 | il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3496 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3497 | il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3498 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3499 | if (il->cfg->mod_params->disable_11n) |
| 3500 | il->cfg->sku &= ~IL_SKU_N; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3501 | |
| 3502 | /* Device-specific setup */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3503 | return il->cfg->ops->lib->set_hw_params(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3504 | } |
| 3505 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3506 | static const u8 il4965_bss_ac_to_fifo[] = { |
| 3507 | IL_TX_FIFO_VO, |
| 3508 | IL_TX_FIFO_VI, |
| 3509 | IL_TX_FIFO_BE, |
| 3510 | IL_TX_FIFO_BK, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3511 | }; |
| 3512 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3513 | static const u8 il4965_bss_ac_to_queue[] = { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3514 | 0, 1, 2, 3, |
| 3515 | }; |
| 3516 | |
| 3517 | static int |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3518 | il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3519 | { |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 3520 | int err = 0; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3521 | struct il_priv *il; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3522 | struct ieee80211_hw *hw; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3523 | struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3524 | unsigned long flags; |
| 3525 | u16 pci_cmd; |
| 3526 | |
| 3527 | /************************ |
| 3528 | * 1. Allocating HW data |
| 3529 | ************************/ |
| 3530 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3531 | hw = il_alloc_all(cfg); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3532 | if (!hw) { |
| 3533 | err = -ENOMEM; |
| 3534 | goto out; |
| 3535 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3536 | il = hw->priv; |
| 3537 | /* At this point both hw and il are allocated. */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3538 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 3539 | il->ctx.ctxid = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3540 | |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 3541 | il->ctx.always_active = true; |
| 3542 | il->ctx.is_active = true; |
| 3543 | il->ctx.rxon_cmd = REPLY_RXON; |
| 3544 | il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; |
| 3545 | il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; |
| 3546 | il->ctx.qos_cmd = REPLY_QOS_PARAM; |
| 3547 | il->ctx.ap_sta_id = IL_AP_ID; |
| 3548 | il->ctx.wep_key_cmd = REPLY_WEPKEY; |
| 3549 | il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; |
| 3550 | il->ctx.ac_to_queue = il4965_bss_ac_to_queue; |
| 3551 | il->ctx.exclusive_interface_modes = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3552 | BIT(NL80211_IFTYPE_ADHOC); |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 3553 | il->ctx.interface_modes = |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3554 | BIT(NL80211_IFTYPE_STATION); |
Stanislaw Gruszka | 7c2cde2 | 2011-11-15 11:29:04 +0100 | [diff] [blame] | 3555 | il->ctx.ap_devtype = RXON_DEV_TYPE_AP; |
| 3556 | il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; |
| 3557 | il->ctx.station_devtype = RXON_DEV_TYPE_ESS; |
| 3558 | il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3559 | |
| 3560 | SET_IEEE80211_DEV(hw, &pdev->dev); |
| 3561 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3562 | D_INFO("*** LOAD DRIVER ***\n"); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3563 | il->cfg = cfg; |
| 3564 | il->pci_dev = pdev; |
| 3565 | il->inta_mask = CSR_INI_SET_MASK; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3566 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3567 | if (il_alloc_traffic_mem(il)) |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3568 | IL_ERR("Not enough memory to generate traffic log\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3569 | |
| 3570 | /************************** |
| 3571 | * 2. Initializing PCI bus |
| 3572 | **************************/ |
| 3573 | pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | |
| 3574 | PCIE_LINK_STATE_CLKPM); |
| 3575 | |
| 3576 | if (pci_enable_device(pdev)) { |
| 3577 | err = -ENODEV; |
| 3578 | goto out_ieee80211_free_hw; |
| 3579 | } |
| 3580 | |
| 3581 | pci_set_master(pdev); |
| 3582 | |
| 3583 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); |
| 3584 | if (!err) |
| 3585 | err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); |
| 3586 | if (err) { |
| 3587 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
| 3588 | if (!err) |
| 3589 | err = pci_set_consistent_dma_mask(pdev, |
| 3590 | DMA_BIT_MASK(32)); |
| 3591 | /* both attempts failed: */ |
| 3592 | if (err) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3593 | IL_WARN("No suitable DMA available.\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3594 | goto out_pci_disable_device; |
| 3595 | } |
| 3596 | } |
| 3597 | |
| 3598 | err = pci_request_regions(pdev, DRV_NAME); |
| 3599 | if (err) |
| 3600 | goto out_pci_disable_device; |
| 3601 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3602 | pci_set_drvdata(pdev, il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3603 | |
| 3604 | |
| 3605 | /*********************** |
| 3606 | * 3. Read REV register |
| 3607 | ***********************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3608 | il->hw_base = pci_iomap(pdev, 0, 0); |
| 3609 | if (!il->hw_base) { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3610 | err = -ENODEV; |
| 3611 | goto out_pci_release_regions; |
| 3612 | } |
| 3613 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3614 | D_INFO("pci_resource_len = 0x%08llx\n", |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3615 | (unsigned long long) pci_resource_len(pdev, 0)); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3616 | D_INFO("pci_resource_base = %p\n", il->hw_base); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3617 | |
| 3618 | /* these spin locks will be used in apm_ops.init and EEPROM access |
| 3619 | * we should init now |
| 3620 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3621 | spin_lock_init(&il->reg_lock); |
| 3622 | spin_lock_init(&il->lock); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3623 | |
| 3624 | /* |
| 3625 | * stop and reset the on-board processor just in case it is in a |
| 3626 | * strange state ... like being left stranded by a primary kernel |
| 3627 | * and this is now the kdump kernel trying to start up |
| 3628 | */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 3629 | _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3630 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3631 | il4965_hw_detect(il); |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3632 | IL_INFO("Detected %s, REV=0x%X\n", |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3633 | il->cfg->name, il->hw_rev); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3634 | |
| 3635 | /* We disable the RETRY_TIMEOUT register (0x41) to keep |
| 3636 | * PCI Tx retries from interfering with C3 CPU state */ |
| 3637 | pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); |
| 3638 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3639 | il4965_prepare_card_hw(il); |
| 3640 | if (!il->hw_ready) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3641 | IL_WARN("Failed, HW not ready\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3642 | goto out_iounmap; |
| 3643 | } |
| 3644 | |
| 3645 | /***************** |
| 3646 | * 4. Read EEPROM |
| 3647 | *****************/ |
| 3648 | /* Read the EEPROM */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3649 | err = il_eeprom_init(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3650 | if (err) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3651 | IL_ERR("Unable to init EEPROM\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3652 | goto out_iounmap; |
| 3653 | } |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3654 | err = il4965_eeprom_check_version(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3655 | if (err) |
| 3656 | goto out_free_eeprom; |
| 3657 | |
| 3658 | if (err) |
| 3659 | goto out_free_eeprom; |
| 3660 | |
| 3661 | /* extract MAC Address */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3662 | il4965_eeprom_get_mac(il, il->addresses[0].addr); |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3663 | D_INFO("MAC address: %pM\n", il->addresses[0].addr); |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3664 | il->hw->wiphy->addresses = il->addresses; |
| 3665 | il->hw->wiphy->n_addresses = 1; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3666 | |
| 3667 | /************************ |
| 3668 | * 5. Setup HW constants |
| 3669 | ************************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3670 | if (il4965_set_hw_params(il)) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3671 | IL_ERR("failed to set hw parameters\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3672 | goto out_free_eeprom; |
| 3673 | } |
| 3674 | |
| 3675 | /******************* |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3676 | * 6. Setup il |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3677 | *******************/ |
| 3678 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3679 | err = il4965_init_drv(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3680 | if (err) |
| 3681 | goto out_free_eeprom; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3682 | /* At this point both hw and il are initialized. */ |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3683 | |
| 3684 | /******************** |
| 3685 | * 7. Setup services |
| 3686 | ********************/ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3687 | spin_lock_irqsave(&il->lock, flags); |
| 3688 | il_disable_interrupts(il); |
| 3689 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3690 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3691 | pci_enable_msi(il->pci_dev); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3692 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3693 | err = request_irq(il->pci_dev->irq, il_isr, |
| 3694 | IRQF_SHARED, DRV_NAME, il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3695 | if (err) { |
Stanislaw Gruszka | 9406f79 | 2011-08-18 22:07:57 +0200 | [diff] [blame] | 3696 | IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3697 | goto out_disable_msi; |
| 3698 | } |
| 3699 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3700 | il4965_setup_deferred_work(il); |
| 3701 | il4965_setup_rx_handlers(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3702 | |
| 3703 | /********************************************* |
| 3704 | * 8. Enable interrupts and read RFKILL state |
| 3705 | *********************************************/ |
| 3706 | |
Stanislaw Gruszka | a078a1f | 2011-04-28 11:51:25 +0200 | [diff] [blame] | 3707 | /* enable rfkill interrupt: hw bug w/a */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3708 | pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3709 | if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { |
| 3710 | pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3711 | pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3712 | } |
| 3713 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3714 | il_enable_rfkill_int(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3715 | |
| 3716 | /* If platform's RF_KILL switch is NOT set to KILL */ |
Stanislaw Gruszka | 841b2cc | 2011-08-24 15:14:03 +0200 | [diff] [blame] | 3717 | if (_il_rd(il, CSR_GP_CNTRL) & |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3718 | CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3719 | clear_bit(STATUS_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3720 | else |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3721 | set_bit(STATUS_RF_KILL_HW, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3722 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3723 | wiphy_rfkill_set_hw_state(il->hw->wiphy, |
| 3724 | test_bit(STATUS_RF_KILL_HW, &il->status)); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3725 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3726 | il_power_initialize(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3727 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3728 | init_completion(&il->_4965.firmware_loading_complete); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3729 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3730 | err = il4965_request_firmware(il, true); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3731 | if (err) |
| 3732 | goto out_destroy_workqueue; |
| 3733 | |
| 3734 | return 0; |
| 3735 | |
| 3736 | out_destroy_workqueue: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3737 | destroy_workqueue(il->workqueue); |
| 3738 | il->workqueue = NULL; |
| 3739 | free_irq(il->pci_dev->irq, il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3740 | out_disable_msi: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3741 | pci_disable_msi(il->pci_dev); |
| 3742 | il4965_uninit_drv(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3743 | out_free_eeprom: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3744 | il_eeprom_free(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3745 | out_iounmap: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3746 | pci_iounmap(pdev, il->hw_base); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3747 | out_pci_release_regions: |
| 3748 | pci_set_drvdata(pdev, NULL); |
| 3749 | pci_release_regions(pdev); |
| 3750 | out_pci_disable_device: |
| 3751 | pci_disable_device(pdev); |
| 3752 | out_ieee80211_free_hw: |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3753 | il_free_traffic_mem(il); |
| 3754 | ieee80211_free_hw(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3755 | out: |
| 3756 | return err; |
| 3757 | } |
| 3758 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3759 | static void __devexit il4965_pci_remove(struct pci_dev *pdev) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3760 | { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3761 | struct il_priv *il = pci_get_drvdata(pdev); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3762 | unsigned long flags; |
| 3763 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3764 | if (!il) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3765 | return; |
| 3766 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3767 | wait_for_completion(&il->_4965.firmware_loading_complete); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3768 | |
Stanislaw Gruszka | 58de00a | 2011-11-15 11:21:01 +0100 | [diff] [blame] | 3769 | D_INFO("*** UNLOAD DRIVER ***\n"); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3770 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3771 | il_dbgfs_unregister(il); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3772 | sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3773 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3774 | /* ieee80211_unregister_hw call wil cause il_mac_stop to |
| 3775 | * to be called and il4965_down since we are removing the device |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3776 | * we need to set STATUS_EXIT_PENDING bit. |
| 3777 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3778 | set_bit(STATUS_EXIT_PENDING, &il->status); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3779 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3780 | il_leds_exit(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3781 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3782 | if (il->mac80211_registered) { |
| 3783 | ieee80211_unregister_hw(il->hw); |
| 3784 | il->mac80211_registered = 0; |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3785 | } else { |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3786 | il4965_down(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | /* |
| 3790 | * Make sure device is reset to low power before unloading driver. |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3791 | * This may be redundant with il4965_down(), but there are paths to |
| 3792 | * run il4965_down() without calling apm_ops.stop(), and there are |
| 3793 | * paths to avoid running il4965_down() at all before leaving driver. |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3794 | * This (inexpensive) call *makes sure* device is reset. |
| 3795 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3796 | il_apm_stop(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3797 | |
| 3798 | /* make sure we flush any pending irq or |
| 3799 | * tasklet for the driver |
| 3800 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3801 | spin_lock_irqsave(&il->lock, flags); |
| 3802 | il_disable_interrupts(il); |
| 3803 | spin_unlock_irqrestore(&il->lock, flags); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3804 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3805 | il4965_synchronize_irq(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3806 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3807 | il4965_dealloc_ucode_pci(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3808 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3809 | if (il->rxq.bd) |
| 3810 | il4965_rx_queue_free(il, &il->rxq); |
| 3811 | il4965_hw_txq_ctx_free(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3812 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3813 | il_eeprom_free(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3814 | |
| 3815 | |
| 3816 | /*netif_stop_queue(dev); */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3817 | flush_workqueue(il->workqueue); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3818 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3819 | /* ieee80211_unregister_hw calls il_mac_stop, which flushes |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3820 | * il->workqueue... so we can't take down the workqueue |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3821 | * until now... */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3822 | destroy_workqueue(il->workqueue); |
| 3823 | il->workqueue = NULL; |
| 3824 | il_free_traffic_mem(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3825 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3826 | free_irq(il->pci_dev->irq, il); |
| 3827 | pci_disable_msi(il->pci_dev); |
| 3828 | pci_iounmap(pdev, il->hw_base); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3829 | pci_release_regions(pdev); |
| 3830 | pci_disable_device(pdev); |
| 3831 | pci_set_drvdata(pdev, NULL); |
| 3832 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3833 | il4965_uninit_drv(il); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3834 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3835 | dev_kfree_skb(il->beacon_skb); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3836 | |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3837 | ieee80211_free_hw(il->hw); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3838 | } |
| 3839 | |
| 3840 | /* |
| 3841 | * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3842 | * must be called under il->lock and mac access |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3843 | */ |
Stanislaw Gruszka | 46bc8d4 | 2011-10-24 16:49:25 +0200 | [diff] [blame] | 3844 | void il4965_txq_set_sched(struct il_priv *il, u32 mask) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3845 | { |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 3846 | il_wr_prph(il, IL49_SCD_TXFACT, mask); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3847 | } |
| 3848 | |
| 3849 | /***************************************************************************** |
| 3850 | * |
| 3851 | * driver and module entry point |
| 3852 | * |
| 3853 | *****************************************************************************/ |
| 3854 | |
| 3855 | /* Hardware specific file defines the PCI IDs table for that hardware module */ |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3856 | static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3857 | {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, |
| 3858 | {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3859 | {0} |
| 3860 | }; |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3861 | MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3862 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3863 | static struct pci_driver il4965_driver = { |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3864 | .name = DRV_NAME, |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3865 | .id_table = il4965_hw_card_ids, |
| 3866 | .probe = il4965_pci_probe, |
| 3867 | .remove = __devexit_p(il4965_pci_remove), |
| 3868 | .driver.pm = IL_LEGACY_PM_OPS, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3869 | }; |
| 3870 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3871 | static int __init il4965_init(void) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3872 | { |
| 3873 | |
| 3874 | int ret; |
| 3875 | pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); |
| 3876 | pr_info(DRV_COPYRIGHT "\n"); |
| 3877 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3878 | ret = il4965_rate_control_register(); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3879 | if (ret) { |
| 3880 | pr_err("Unable to register rate control algorithm: %d\n", ret); |
| 3881 | return ret; |
| 3882 | } |
| 3883 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3884 | ret = pci_register_driver(&il4965_driver); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3885 | if (ret) { |
| 3886 | pr_err("Unable to initialize PCI module\n"); |
| 3887 | goto error_register; |
| 3888 | } |
| 3889 | |
| 3890 | return ret; |
| 3891 | |
| 3892 | error_register: |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3893 | il4965_rate_control_unregister(); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3894 | return ret; |
| 3895 | } |
| 3896 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3897 | static void __exit il4965_exit(void) |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3898 | { |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3899 | pci_unregister_driver(&il4965_driver); |
| 3900 | il4965_rate_control_unregister(); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3901 | } |
| 3902 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3903 | module_exit(il4965_exit); |
| 3904 | module_init(il4965_init); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3905 | |
Stanislaw Gruszka | d317516 | 2011-11-15 11:25:42 +0100 | [diff] [blame] | 3906 | #ifdef CONFIG_IWLEGACY_DEBUG |
Stanislaw Gruszka | d2ddf621 | 2011-08-16 14:17:04 +0200 | [diff] [blame] | 3907 | module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3908 | MODULE_PARM_DESC(debug, "debug output mask"); |
| 3909 | #endif |
| 3910 | |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3911 | module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3912 | MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3913 | module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3914 | MODULE_PARM_DESC(queues_num, "number of hw queues."); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3915 | module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3916 | MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3917 | module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3918 | int, S_IRUGO); |
| 3919 | MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); |
Stanislaw Gruszka | e2ebc83 | 2011-10-24 15:41:30 +0200 | [diff] [blame] | 3920 | module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); |
Wey-Yi Guy | be663ab | 2011-02-21 11:27:26 -0800 | [diff] [blame] | 3921 | MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); |