aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2010-02-15 16:04:43 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-02-15 16:04:43 -0500
commitf318d658decb5789cfbb43041daf3dc3aade1df0 (patch)
tree96db512f43eb4213722e90f9340a4b94f453d04f
parent42c4568a4ace0adc27a9d6f02936e2047ba6fc7e (diff)
parent1db5950f1d0b82e07371b211a48317b8972da063 (diff)
Merge branch 'wireless-next-2.6' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-2.6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c56
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-helpers.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c80
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c37
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c62
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c39
16 files changed, 273 insertions, 124 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 694ceef88590..3bf2e6e9b2d9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -246,7 +246,7 @@ struct iwl_cfg iwl1000_bgn_cfg = {
246 .use_rts_for_ht = true, /* use rts/cts protection */ 246 .use_rts_for_ht = true, /* use rts/cts protection */
247 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 247 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
248 .support_ct_kill_exit = true, 248 .support_ct_kill_exit = true,
249 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 249 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
250 .chain_noise_scale = 1000, 250 .chain_noise_scale = 1000,
251}; 251};
252 252
@@ -274,7 +274,7 @@ struct iwl_cfg iwl1000_bg_cfg = {
274 .led_compensation = 51, 274 .led_compensation = 51,
275 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS, 275 .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
276 .support_ct_kill_exit = true, 276 .support_ct_kill_exit = true,
277 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 277 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF,
278 .chain_noise_scale = 1000, 278 .chain_noise_scale = 1000,
279}; 279};
280 280
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 57194bbd2762..5913418872ec 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2470,11 +2470,9 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv)
2470 memset((void *)&priv->hw_params, 0, 2470 memset((void *)&priv->hw_params, 0,
2471 sizeof(struct iwl_hw_params)); 2471 sizeof(struct iwl_hw_params));
2472 2472
2473 priv->shared_virt = 2473 priv->shared_virt = dma_alloc_coherent(&priv->pci_dev->dev,
2474 pci_alloc_consistent(priv->pci_dev, 2474 sizeof(struct iwl3945_shared),
2475 sizeof(struct iwl3945_shared), 2475 &priv->shared_phys, GFP_KERNEL);
2476 &priv->shared_phys);
2477
2478 if (!priv->shared_virt) { 2476 if (!priv->shared_virt) {
2479 IWL_ERR(priv, "failed to allocate pci memory\n"); 2477 IWL_ERR(priv, "failed to allocate pci memory\n");
2480 mutex_unlock(&priv->mutex); 2478 mutex_unlock(&priv->mutex);
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index aebe8c51d3e1..17e91ad3496c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -581,6 +581,13 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
581 581
582 iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); 582 iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
583 583
584 /* make sure all queue are not stopped */
585 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
586 for (i = 0; i < 4; i++)
587 atomic_set(&priv->queue_stop_count[i], 0);
588
589 /* reset to 0 to enable all the queue first */
590 priv->txq_ctx_active_msk = 0;
584 /* Map each Tx/cmd queue to its corresponding fifo */ 591 /* Map each Tx/cmd queue to its corresponding fifo */
585 for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { 592 for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) {
586 int ac = default_queue_to_tx_fifo[i]; 593 int ac = default_queue_to_tx_fifo[i];
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index f3d662c8cbcf..94fc83671f20 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -648,6 +648,13 @@ int iwl5000_alive_notify(struct iwl_priv *priv)
648 648
649 iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); 649 iwl5000_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
650 650
651 /* make sure all queue are not stopped */
652 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
653 for (i = 0; i < 4; i++)
654 atomic_set(&priv->queue_stop_count[i], 0);
655
656 /* reset to 0 to enable all the queue first */
657 priv->txq_ctx_active_msk = 0;
651 /* map qos queues to fifos one-to-one */ 658 /* map qos queues to fifos one-to-one */
652 for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) { 659 for (i = 0; i < ARRAY_SIZE(iwl5000_default_queue_to_tx_fifo); i++) {
653 int ac = iwl5000_default_queue_to_tx_fifo[i]; 660 int ac = iwl5000_default_queue_to_tx_fifo[i];
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 6aebcedaca8d..8bf7c20b9d39 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -298,10 +298,23 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
298 struct iwl_lq_sta *lq_data, u8 tid, 298 struct iwl_lq_sta *lq_data, u8 tid,
299 struct ieee80211_sta *sta) 299 struct ieee80211_sta *sta)
300{ 300{
301 int ret;
302
301 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { 303 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) {
302 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", 304 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n",
303 sta->addr, tid); 305 sta->addr, tid);
304 ieee80211_start_tx_ba_session(sta, tid); 306 ret = ieee80211_start_tx_ba_session(sta, tid);
307 if (ret == -EAGAIN) {
308 /*
309 * driver and mac80211 is out of sync
310 * this might be cause by reloading firmware
311 * stop the tx ba session here
312 */
313 IWL_DEBUG_HT(priv, "Fail start Tx agg on tid: %d\n",
314 tid);
315 ret = ieee80211_stop_tx_ba_session(sta, tid,
316 WLAN_BACK_INITIATOR);
317 }
305 } 318 }
306} 319}
307 320
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index c1eff4c5b448..4157c6c8645f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2941,10 +2941,21 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
2941 return ret; 2941 return ret;
2942 case IEEE80211_AMPDU_TX_START: 2942 case IEEE80211_AMPDU_TX_START:
2943 IWL_DEBUG_HT(priv, "start Tx\n"); 2943 IWL_DEBUG_HT(priv, "start Tx\n");
2944 return iwl_tx_agg_start(priv, sta->addr, tid, ssn); 2944 ret = iwl_tx_agg_start(priv, sta->addr, tid, ssn);
2945 if (ret == 0) {
2946 priv->agg_tids_count++;
2947 IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n",
2948 priv->agg_tids_count);
2949 }
2950 return ret;
2945 case IEEE80211_AMPDU_TX_STOP: 2951 case IEEE80211_AMPDU_TX_STOP:
2946 IWL_DEBUG_HT(priv, "stop Tx\n"); 2952 IWL_DEBUG_HT(priv, "stop Tx\n");
2947 ret = iwl_tx_agg_stop(priv, sta->addr, tid); 2953 ret = iwl_tx_agg_stop(priv, sta->addr, tid);
2954 if ((ret == 0) && (priv->agg_tids_count > 0)) {
2955 priv->agg_tids_count--;
2956 IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n",
2957 priv->agg_tids_count);
2958 }
2948 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2959 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2949 return 0; 2960 return 0;
2950 else 2961 else
@@ -3364,6 +3375,7 @@ static int iwl_init_drv(struct iwl_priv *priv)
3364 priv->iw_mode = NL80211_IFTYPE_STATION; 3375 priv->iw_mode = NL80211_IFTYPE_STATION;
3365 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; 3376 priv->current_ht_config.smps = IEEE80211_SMPS_STATIC;
3366 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; 3377 priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF;
3378 priv->agg_tids_count = 0;
3367 3379
3368 /* Choose which receivers/antennas to use */ 3380 /* Choose which receivers/antennas to use */
3369 if (priv->cfg->ops->hcmd->set_rxon_chain) 3381 if (priv->cfg->ops->hcmd->set_rxon_chain)
@@ -3540,6 +3552,14 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3540 */ 3552 */
3541 spin_lock_init(&priv->reg_lock); 3553 spin_lock_init(&priv->reg_lock);
3542 spin_lock_init(&priv->lock); 3554 spin_lock_init(&priv->lock);
3555
3556 /*
3557 * stop and reset the on-board processor just in case it is in a
3558 * strange state ... like being left stranded by a primary kernel
3559 * and this is now the kdump kernel trying to start up
3560 */
3561 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
3562
3543 iwl_hw_detect(priv); 3563 iwl_hw_detect(priv);
3544 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n", 3564 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n",
3545 priv->cfg->name, priv->hw_rev); 3565 priv->cfg->name, priv->hw_rev);
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index c2f31eb26bef..ab3c77b92cc8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -3470,11 +3470,7 @@ enum {
3470 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, 3470 IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7,
3471 IWL_PHY_CALIBRATE_DC_CMD = 8, 3471 IWL_PHY_CALIBRATE_DC_CMD = 8,
3472 IWL_PHY_CALIBRATE_LO_CMD = 9, 3472 IWL_PHY_CALIBRATE_LO_CMD = 9,
3473 IWL_PHY_CALIBRATE_RX_BB_CMD = 10,
3474 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11, 3473 IWL_PHY_CALIBRATE_TX_IQ_CMD = 11,
3475 IWL_PHY_CALIBRATE_RX_IQ_CMD = 12,
3476 IWL_PHY_CALIBRATION_NOISE_CMD = 13,
3477 IWL_PHY_CALIBRATE_AGC_TABLE_CMD = 14,
3478 IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15, 3474 IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD = 15,
3479 IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16, 3475 IWL_PHY_CALIBRATE_BASE_BAND_CMD = 16,
3480 IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17, 3476 IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD = 17,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index d390eef2efe5..bd56827b8fef 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1670,9 +1670,9 @@ EXPORT_SYMBOL(iwl_set_tx_power);
1670void iwl_free_isr_ict(struct iwl_priv *priv) 1670void iwl_free_isr_ict(struct iwl_priv *priv)
1671{ 1671{
1672 if (priv->ict_tbl_vir) { 1672 if (priv->ict_tbl_vir) {
1673 pci_free_consistent(priv->pci_dev, (sizeof(u32) * ICT_COUNT) + 1673 dma_free_coherent(&priv->pci_dev->dev,
1674 PAGE_SIZE, priv->ict_tbl_vir, 1674 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
1675 priv->ict_tbl_dma); 1675 priv->ict_tbl_vir, priv->ict_tbl_dma);
1676 priv->ict_tbl_vir = NULL; 1676 priv->ict_tbl_vir = NULL;
1677 } 1677 }
1678} 1678}
@@ -1688,9 +1688,9 @@ int iwl_alloc_isr_ict(struct iwl_priv *priv)
1688 if (priv->cfg->use_isr_legacy) 1688 if (priv->cfg->use_isr_legacy)
1689 return 0; 1689 return 0;
1690 /* allocate shrared data table */ 1690 /* allocate shrared data table */
1691 priv->ict_tbl_vir = pci_alloc_consistent(priv->pci_dev, (sizeof(u32) * 1691 priv->ict_tbl_vir = dma_alloc_coherent(&priv->pci_dev->dev,
1692 ICT_COUNT) + PAGE_SIZE, 1692 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
1693 &priv->ict_tbl_dma); 1693 &priv->ict_tbl_dma, GFP_KERNEL);
1694 if (!priv->ict_tbl_vir) 1694 if (!priv->ict_tbl_vir)
1695 return -ENOMEM; 1695 return -ENOMEM;
1696 1696
@@ -3334,7 +3334,7 @@ int iwl_dump_fh(struct iwl_priv *priv, char **buf, bool display)
3334} 3334}
3335EXPORT_SYMBOL(iwl_dump_fh); 3335EXPORT_SYMBOL(iwl_dump_fh);
3336 3336
3337void iwl_force_rf_reset(struct iwl_priv *priv) 3337static void iwl_force_rf_reset(struct iwl_priv *priv)
3338{ 3338{
3339 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3339 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3340 return; 3340 return;
@@ -3356,7 +3356,47 @@ void iwl_force_rf_reset(struct iwl_priv *priv)
3356 iwl_internal_short_hw_scan(priv); 3356 iwl_internal_short_hw_scan(priv);
3357 return; 3357 return;
3358} 3358}
3359EXPORT_SYMBOL(iwl_force_rf_reset); 3359
3360#define IWL_DELAY_NEXT_FORCE_RESET (HZ*3)
3361
3362int iwl_force_reset(struct iwl_priv *priv, int mode)
3363{
3364 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3365 return -EINVAL;
3366
3367 if (priv->last_force_reset_jiffies &&
3368 time_after(priv->last_force_reset_jiffies +
3369 IWL_DELAY_NEXT_FORCE_RESET, jiffies)) {
3370 IWL_DEBUG_INFO(priv, "force reset rejected\n");
3371 return -EAGAIN;
3372 }
3373
3374 IWL_DEBUG_INFO(priv, "perform force reset (%d)\n", mode);
3375
3376 switch (mode) {
3377 case IWL_RF_RESET:
3378 iwl_force_rf_reset(priv);
3379 break;
3380 case IWL_FW_RESET:
3381 IWL_ERR(priv, "On demand firmware reload\n");
3382 /* Set the FW error flag -- cleared on iwl_down */
3383 set_bit(STATUS_FW_ERROR, &priv->status);
3384 wake_up_interruptible(&priv->wait_command_queue);
3385 /*
3386 * Keep the restart process from trying to send host
3387 * commands by clearing the INIT status bit
3388 */
3389 clear_bit(STATUS_READY, &priv->status);
3390 queue_work(priv->workqueue, &priv->restart);
3391 break;
3392 default:
3393 IWL_DEBUG_INFO(priv, "invalid reset request.\n");
3394 return -EINVAL;
3395 }
3396 priv->last_force_reset_jiffies = jiffies;
3397
3398 return 0;
3399}
3360 3400
3361#ifdef CONFIG_PM 3401#ifdef CONFIG_PM
3362 3402
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 8f0c564e68b0..530fae8cf16d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -414,13 +414,13 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
414void iwl_cmd_queue_free(struct iwl_priv *priv); 414void iwl_cmd_queue_free(struct iwl_priv *priv);
415int iwl_rx_queue_alloc(struct iwl_priv *priv); 415int iwl_rx_queue_alloc(struct iwl_priv *priv);
416void iwl_rx_handle(struct iwl_priv *priv); 416void iwl_rx_handle(struct iwl_priv *priv);
417int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, 417void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
418 struct iwl_rx_queue *q); 418 struct iwl_rx_queue *q);
419void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); 419void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
420void iwl_rx_replenish(struct iwl_priv *priv); 420void iwl_rx_replenish(struct iwl_priv *priv);
421void iwl_rx_replenish_now(struct iwl_priv *priv); 421void iwl_rx_replenish_now(struct iwl_priv *priv);
422int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); 422int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
423int iwl_rx_queue_restock(struct iwl_priv *priv); 423void iwl_rx_queue_restock(struct iwl_priv *priv);
424int iwl_rx_queue_space(const struct iwl_rx_queue *q); 424int iwl_rx_queue_space(const struct iwl_rx_queue *q);
425void iwl_rx_allocate(struct iwl_priv *priv, gfp_t priority); 425void iwl_rx_allocate(struct iwl_priv *priv, gfp_t priority);
426void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); 426void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
@@ -450,7 +450,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb);
450void iwl_hw_txq_ctx_free(struct iwl_priv *priv); 450void iwl_hw_txq_ctx_free(struct iwl_priv *priv);
451int iwl_hw_tx_queue_init(struct iwl_priv *priv, 451int iwl_hw_tx_queue_init(struct iwl_priv *priv,
452 struct iwl_tx_queue *txq); 452 struct iwl_tx_queue *txq);
453int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); 453void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
454int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, 454int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
455 int slots_num, u32 txq_id); 455 int slots_num, u32 txq_id);
456void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id); 456void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id);
@@ -501,7 +501,7 @@ int iwl_scan_cancel(struct iwl_priv *priv);
501int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 501int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
502int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); 502int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req);
503int iwl_internal_short_hw_scan(struct iwl_priv *priv); 503int iwl_internal_short_hw_scan(struct iwl_priv *priv);
504void iwl_force_rf_reset(struct iwl_priv *priv); 504int iwl_force_reset(struct iwl_priv *priv, int mode);
505u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, 505u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
506 const u8 *ie, int ie_len, int left); 506 const u8 *ie, int ie_len, int left);
507void iwl_setup_rx_scan_handlers(struct iwl_priv *priv); 507void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index d134301b553c..78298be0bdb6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -2223,6 +2223,32 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
2223 return count; 2223 return count;
2224} 2224}
2225 2225
2226static ssize_t iwl_dbgfs_force_reset_write(struct file *file,
2227 const char __user *user_buf,
2228 size_t count, loff_t *ppos) {
2229
2230 struct iwl_priv *priv = file->private_data;
2231 char buf[8];
2232 int buf_size;
2233 int reset, ret;
2234
2235 memset(buf, 0, sizeof(buf));
2236 buf_size = min(count, sizeof(buf) - 1);
2237 if (copy_from_user(buf, user_buf, buf_size))
2238 return -EFAULT;
2239 if (sscanf(buf, "%d", &reset) != 1)
2240 return -EINVAL;
2241 switch (reset) {
2242 case IWL_RF_RESET:
2243 case IWL_FW_RESET:
2244 ret = iwl_force_reset(priv, reset);
2245 break;
2246 default:
2247 return -EINVAL;
2248 }
2249 return ret ? ret : count;
2250}
2251
2226DEBUGFS_READ_FILE_OPS(rx_statistics); 2252DEBUGFS_READ_FILE_OPS(rx_statistics);
2227DEBUGFS_READ_FILE_OPS(tx_statistics); 2253DEBUGFS_READ_FILE_OPS(tx_statistics);
2228DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 2254DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
@@ -2243,6 +2269,7 @@ DEBUGFS_READ_FILE_OPS(fh_reg);
2243DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); 2269DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon);
2244DEBUGFS_WRITE_FILE_OPS(internal_scan); 2270DEBUGFS_WRITE_FILE_OPS(internal_scan);
2245DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta); 2271DEBUGFS_READ_WRITE_FILE_OPS(plcp_delta);
2272DEBUGFS_WRITE_FILE_OPS(force_reset);
2246 2273
2247/* 2274/*
2248 * Create the debugfs files and directories 2275 * Create the debugfs files and directories
@@ -2296,6 +2323,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
2296 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); 2323 DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR);
2297 DEBUGFS_ADD_FILE(internal_scan, dir_debug, S_IWUSR); 2324 DEBUGFS_ADD_FILE(internal_scan, dir_debug, S_IWUSR);
2298 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR); 2325 DEBUGFS_ADD_FILE(plcp_delta, dir_debug, S_IWUSR | S_IRUSR);
2326 DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR);
2299 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) { 2327 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) != CSR_HW_REV_TYPE_3945) {
2300 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); 2328 DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR);
2301 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); 2329 DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 55dc5a866542..f81317d478ee 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1033,8 +1033,14 @@ struct iwl_event_log {
1033#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (0) 1033#define IWL_MAX_PLCP_ERR_THRESHOLD_MIN (0)
1034#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50) 1034#define IWL_MAX_PLCP_ERR_THRESHOLD_DEF (50)
1035#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100) 1035#define IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF (100)
1036#define IWL_MAX_PLCP_ERR_EXT_LONG_THRESHOLD_DEF (200)
1036#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255) 1037#define IWL_MAX_PLCP_ERR_THRESHOLD_MAX (255)
1037 1038
1039enum iwl_reset {
1040 IWL_RF_RESET = 0,
1041 IWL_FW_RESET,
1042};
1043
1038struct iwl_priv { 1044struct iwl_priv {
1039 1045
1040 /* ieee device used by generic ieee processing code */ 1046 /* ieee device used by generic ieee processing code */
@@ -1066,6 +1072,12 @@ struct iwl_priv {
1066 /* storing the jiffies when the plcp error rate is received */ 1072 /* storing the jiffies when the plcp error rate is received */
1067 unsigned long plcp_jiffies; 1073 unsigned long plcp_jiffies;
1068 1074
1075 /* reporting the number of tids has AGG on. 0 means no AGGREGATION */
1076 u8 agg_tids_count;
1077
1078 /* force reset */
1079 unsigned long last_force_reset_jiffies;
1080
1069 /* we allocate array of iwl4965_channel_info for NIC's valid channels. 1081 /* we allocate array of iwl4965_channel_info for NIC's valid channels.
1070 * Access via channel # using indirect index array */ 1082 * Access via channel # using indirect index array */
1071 struct iwl_channel_info *channel_info; /* channel info array */ 1083 struct iwl_channel_info *channel_info; /* channel info array */
@@ -1087,7 +1099,6 @@ struct iwl_priv {
1087 unsigned long scan_start; 1099 unsigned long scan_start;
1088 unsigned long scan_pass_start; 1100 unsigned long scan_pass_start;
1089 unsigned long scan_start_tsf; 1101 unsigned long scan_start_tsf;
1090 unsigned long last_internal_scan_jiffies;
1091 void *scan; 1102 void *scan;
1092 int scan_bands; 1103 int scan_bands;
1093 struct cfg80211_scan_request *scan_request; 1104 struct cfg80211_scan_request *scan_request;
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h
index 45af5bbc1c56..51a67fb2e185 100644
--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
@@ -80,8 +80,8 @@ static inline void iwl_free_fw_desc(struct pci_dev *pci_dev,
80 struct fw_desc *desc) 80 struct fw_desc *desc)
81{ 81{
82 if (desc->v_addr) 82 if (desc->v_addr)
83 pci_free_consistent(pci_dev, desc->len, 83 dma_free_coherent(&pci_dev->dev, desc->len,
84 desc->v_addr, desc->p_addr); 84 desc->v_addr, desc->p_addr);
85 desc->v_addr = NULL; 85 desc->v_addr = NULL;
86 desc->len = 0; 86 desc->len = 0;
87} 87}
@@ -89,7 +89,8 @@ static inline void iwl_free_fw_desc(struct pci_dev *pci_dev,
89static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev, 89static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev,
90 struct fw_desc *desc) 90 struct fw_desc *desc)
91{ 91{
92 desc->v_addr = pci_alloc_consistent(pci_dev, desc->len, &desc->p_addr); 92 desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len,
93 &desc->p_addr, GFP_KERNEL);
93 return (desc->v_addr != NULL) ? 0 : -ENOMEM; 94 return (desc->v_addr != NULL) ? 0 : -ENOMEM;
94} 95}
95 96
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 5df66382d922..fed554accedc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -123,12 +123,11 @@ EXPORT_SYMBOL(iwl_rx_queue_space);
123/** 123/**
124 * iwl_rx_queue_update_write_ptr - Update the write pointer for the RX queue 124 * iwl_rx_queue_update_write_ptr - Update the write pointer for the RX queue
125 */ 125 */
126int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q) 126void iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q)
127{ 127{
128 unsigned long flags; 128 unsigned long flags;
129 u32 rx_wrt_ptr_reg = priv->hw_params.rx_wrt_ptr_reg; 129 u32 rx_wrt_ptr_reg = priv->hw_params.rx_wrt_ptr_reg;
130 u32 reg; 130 u32 reg;
131 int ret = 0;
132 131
133 spin_lock_irqsave(&q->lock, flags); 132 spin_lock_irqsave(&q->lock, flags);
134 133
@@ -161,7 +160,6 @@ int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv, struct iwl_rx_queue *q)
161 160
162 exit_unlock: 161 exit_unlock:
163 spin_unlock_irqrestore(&q->lock, flags); 162 spin_unlock_irqrestore(&q->lock, flags);
164 return ret;
165} 163}
166EXPORT_SYMBOL(iwl_rx_queue_update_write_ptr); 164EXPORT_SYMBOL(iwl_rx_queue_update_write_ptr);
167/** 165/**
@@ -184,14 +182,13 @@ static inline __le32 iwl_dma_addr2rbd_ptr(struct iwl_priv *priv,
184 * also updates the memory address in the firmware to reference the new 182 * also updates the memory address in the firmware to reference the new
185 * target buffer. 183 * target buffer.
186 */ 184 */
187int iwl_rx_queue_restock(struct iwl_priv *priv) 185void iwl_rx_queue_restock(struct iwl_priv *priv)
188{ 186{
189 struct iwl_rx_queue *rxq = &priv->rxq; 187 struct iwl_rx_queue *rxq = &priv->rxq;
190 struct list_head *element; 188 struct list_head *element;
191 struct iwl_rx_mem_buffer *rxb; 189 struct iwl_rx_mem_buffer *rxb;
192 unsigned long flags; 190 unsigned long flags;
193 int write; 191 int write;
194 int ret = 0;
195 192
196 spin_lock_irqsave(&rxq->lock, flags); 193 spin_lock_irqsave(&rxq->lock, flags);
197 write = rxq->write & ~0x7; 194 write = rxq->write & ~0x7;
@@ -220,10 +217,8 @@ int iwl_rx_queue_restock(struct iwl_priv *priv)
220 spin_lock_irqsave(&rxq->lock, flags); 217 spin_lock_irqsave(&rxq->lock, flags);
221 rxq->need_update = 1; 218 rxq->need_update = 1;
222 spin_unlock_irqrestore(&rxq->lock, flags); 219 spin_unlock_irqrestore(&rxq->lock, flags);
223 ret = iwl_rx_queue_update_write_ptr(priv, rxq); 220 iwl_rx_queue_update_write_ptr(priv, rxq);
224 } 221 }
225
226 return ret;
227} 222}
228EXPORT_SYMBOL(iwl_rx_queue_restock); 223EXPORT_SYMBOL(iwl_rx_queue_restock);
229 224
@@ -350,10 +345,10 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
350 } 345 }
351 } 346 }
352 347
353 pci_free_consistent(priv->pci_dev, 4 * RX_QUEUE_SIZE, rxq->bd, 348 dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd,
354 rxq->dma_addr); 349 rxq->dma_addr);
355 pci_free_consistent(priv->pci_dev, sizeof(struct iwl_rb_status), 350 dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status),
356 rxq->rb_stts, rxq->rb_stts_dma); 351 rxq->rb_stts, rxq->rb_stts_dma);
357 rxq->bd = NULL; 352 rxq->bd = NULL;
358 rxq->rb_stts = NULL; 353 rxq->rb_stts = NULL;
359} 354}
@@ -362,7 +357,7 @@ EXPORT_SYMBOL(iwl_rx_queue_free);
362int iwl_rx_queue_alloc(struct iwl_priv *priv) 357int iwl_rx_queue_alloc(struct iwl_priv *priv)
363{ 358{
364 struct iwl_rx_queue *rxq = &priv->rxq; 359 struct iwl_rx_queue *rxq = &priv->rxq;
365 struct pci_dev *dev = priv->pci_dev; 360 struct device *dev = &priv->pci_dev->dev;
366 int i; 361 int i;
367 362
368 spin_lock_init(&rxq->lock); 363 spin_lock_init(&rxq->lock);
@@ -370,12 +365,13 @@ int iwl_rx_queue_alloc(struct iwl_priv *priv)
370 INIT_LIST_HEAD(&rxq->rx_used); 365 INIT_LIST_HEAD(&rxq->rx_used);
371 366
372 /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ 367 /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */
373 rxq->bd = pci_alloc_consistent(dev, 4 * RX_QUEUE_SIZE, &rxq->dma_addr); 368 rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->dma_addr,
369 GFP_KERNEL);
374 if (!rxq->bd) 370 if (!rxq->bd)
375 goto err_bd; 371 goto err_bd;
376 372
377 rxq->rb_stts = pci_alloc_consistent(dev, sizeof(struct iwl_rb_status), 373 rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct iwl_rb_status),
378 &rxq->rb_stts_dma); 374 &rxq->rb_stts_dma, GFP_KERNEL);
379 if (!rxq->rb_stts) 375 if (!rxq->rb_stts)
380 goto err_rb; 376 goto err_rb;
381 377
@@ -392,8 +388,8 @@ int iwl_rx_queue_alloc(struct iwl_priv *priv)
392 return 0; 388 return 0;
393 389
394err_rb: 390err_rb:
395 pci_free_consistent(priv->pci_dev, 4 * RX_QUEUE_SIZE, rxq->bd, 391 dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd,
396 rxq->dma_addr); 392 rxq->dma_addr);
397err_bd: 393err_bd:
398 return -ENOMEM; 394 return -ENOMEM;
399} 395}
@@ -620,6 +616,11 @@ static void iwl_accumulative_statistics(struct iwl_priv *priv,
620 616
621#define REG_RECALIB_PERIOD (60) 617#define REG_RECALIB_PERIOD (60)
622 618
619/* the threshold ratio of actual_ack_cnt to expected_ack_cnt in percent */
620#define ACK_CNT_RATIO (50)
621#define BA_TIMEOUT_CNT (5)
622#define BA_TIMEOUT_MAX (16)
623
623#define PLCP_MSG "plcp_err exceeded %u, %u, %u, %u, %u, %d, %u mSecs\n" 624#define PLCP_MSG "plcp_err exceeded %u, %u, %u, %u, %u, %d, %u mSecs\n"
624void iwl_rx_statistics(struct iwl_priv *priv, 625void iwl_rx_statistics(struct iwl_priv *priv,
625 struct iwl_rx_mem_buffer *rxb) 626 struct iwl_rx_mem_buffer *rxb)
@@ -629,6 +630,9 @@ void iwl_rx_statistics(struct iwl_priv *priv,
629 int combined_plcp_delta; 630 int combined_plcp_delta;
630 unsigned int plcp_msec; 631 unsigned int plcp_msec;
631 unsigned long plcp_received_jiffies; 632 unsigned long plcp_received_jiffies;
633 int actual_ack_cnt_delta;
634 int expected_ack_cnt_delta;
635 int ba_timeout_delta;
632 636
633 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", 637 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
634 (int)sizeof(priv->statistics), 638 (int)sizeof(priv->statistics),
@@ -643,6 +647,44 @@ void iwl_rx_statistics(struct iwl_priv *priv,
643#ifdef CONFIG_IWLWIFI_DEBUG 647#ifdef CONFIG_IWLWIFI_DEBUG
644 iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); 648 iwl_accumulative_statistics(priv, (__le32 *)&pkt->u.stats);
645#endif 649#endif
650 actual_ack_cnt_delta = le32_to_cpu(pkt->u.stats.tx.actual_ack_cnt) -
651 le32_to_cpu(priv->statistics.tx.actual_ack_cnt);
652 expected_ack_cnt_delta = le32_to_cpu(
653 pkt->u.stats.tx.expected_ack_cnt) -
654 le32_to_cpu(priv->statistics.tx.expected_ack_cnt);
655 ba_timeout_delta = le32_to_cpu(
656 pkt->u.stats.tx.agg.ba_timeout) -
657 le32_to_cpu(priv->statistics.tx.agg.ba_timeout);
658 if ((priv->agg_tids_count > 0) &&
659 (expected_ack_cnt_delta > 0) &&
660 (((actual_ack_cnt_delta * 100) / expected_ack_cnt_delta) <
661 ACK_CNT_RATIO) &&
662 (ba_timeout_delta > BA_TIMEOUT_CNT)) {
663 IWL_DEBUG_RADIO(priv,
664 "actual_ack_cnt delta = %d, expected_ack_cnt = %d\n",
665 actual_ack_cnt_delta, expected_ack_cnt_delta);
666
667#ifdef CONFIG_IWLWIFI_DEBUG
668 IWL_DEBUG_RADIO(priv, "rx_detected_cnt delta = %d\n",
669 priv->delta_statistics.tx.rx_detected_cnt);
670 IWL_DEBUG_RADIO(priv,
671 "ack_or_ba_timeout_collision delta = %d\n",
672 priv->delta_statistics.tx.ack_or_ba_timeout_collision);
673#endif
674 IWL_DEBUG_RADIO(priv, "agg ba_timeout delta = %d\n",
675 ba_timeout_delta);
676 if ((actual_ack_cnt_delta == 0) &&
677 (ba_timeout_delta >=
678 BA_TIMEOUT_MAX)) {
679 IWL_DEBUG_RADIO(priv,
680 "call iwl_force_reset(IWL_FW_RESET)\n");
681 iwl_force_reset(priv, IWL_FW_RESET);
682 } else {
683 IWL_DEBUG_RADIO(priv,
684 "call iwl_force_reset(IWL_RF_RESET)\n");
685 iwl_force_reset(priv, IWL_RF_RESET);
686 }
687 }
646 /* 688 /*
647 * check for plcp_err and trigger radio reset if it exceeds 689 * check for plcp_err and trigger radio reset if it exceeds
648 * the plcp error threshold plcp_delta. 690 * the plcp error threshold plcp_delta.
@@ -689,7 +731,7 @@ void iwl_rx_statistics(struct iwl_priv *priv,
689 * Reset the RF radio due to the high plcp 731 * Reset the RF radio due to the high plcp
690 * error rate 732 * error rate
691 */ 733 */
692 iwl_force_rf_reset(priv); 734 iwl_force_reset(priv, IWL_RF_RESET);
693 } 735 }
694 } 736 }
695 737
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index f786a407638f..dd9ff2ed645a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -250,8 +250,6 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
250 250
251 if (!priv->is_internal_short_scan) 251 if (!priv->is_internal_short_scan)
252 priv->next_scan_jiffies = 0; 252 priv->next_scan_jiffies = 0;
253 else
254 priv->last_internal_scan_jiffies = jiffies;
255 253
256 IWL_DEBUG_INFO(priv, "Setting scan to off\n"); 254 IWL_DEBUG_INFO(priv, "Setting scan to off\n");
257 255
@@ -471,21 +469,6 @@ EXPORT_SYMBOL(iwl_init_scan_params);
471 469
472static int iwl_scan_initiate(struct iwl_priv *priv) 470static int iwl_scan_initiate(struct iwl_priv *priv)
473{ 471{
474 if (!iwl_is_ready_rf(priv)) {
475 IWL_DEBUG_SCAN(priv, "Aborting scan due to not ready.\n");
476 return -EIO;
477 }
478
479 if (test_bit(STATUS_SCANNING, &priv->status)) {
480 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
481 return -EAGAIN;
482 }
483
484 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
485 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
486 return -EAGAIN;
487 }
488
489 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 472 IWL_DEBUG_INFO(priv, "Starting scan...\n");
490 set_bit(STATUS_SCANNING, &priv->status); 473 set_bit(STATUS_SCANNING, &priv->status);
491 priv->is_internal_short_scan = false; 474 priv->is_internal_short_scan = false;
@@ -517,6 +500,18 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
517 goto out_unlock; 500 goto out_unlock;
518 } 501 }
519 502
503 if (test_bit(STATUS_SCANNING, &priv->status)) {
504 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
505 ret = -EAGAIN;
506 goto out_unlock;
507 }
508
509 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
510 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
511 ret = -EAGAIN;
512 goto out_unlock;
513 }
514
520 /* We don't schedule scan within next_scan_jiffies period. 515 /* We don't schedule scan within next_scan_jiffies period.
521 * Avoid scanning during possible EAPOL exchange, return 516 * Avoid scanning during possible EAPOL exchange, return
522 * success immediately. 517 * success immediately.
@@ -551,8 +546,6 @@ EXPORT_SYMBOL(iwl_mac_hw_scan);
551 * internal short scan, this function should only been called while associated. 546 * internal short scan, this function should only been called while associated.
552 * It will reset and tune the radio to prevent possible RF related problem 547 * It will reset and tune the radio to prevent possible RF related problem
553 */ 548 */
554#define IWL_DELAY_NEXT_INTERNAL_SCAN (HZ*1)
555
556int iwl_internal_short_hw_scan(struct iwl_priv *priv) 549int iwl_internal_short_hw_scan(struct iwl_priv *priv)
557{ 550{
558 int ret = 0; 551 int ret = 0;
@@ -572,12 +565,6 @@ int iwl_internal_short_hw_scan(struct iwl_priv *priv)
572 ret = -EAGAIN; 565 ret = -EAGAIN;
573 goto out; 566 goto out;
574 } 567 }
575 if (priv->last_internal_scan_jiffies &&
576 time_after(priv->last_internal_scan_jiffies +
577 IWL_DELAY_NEXT_INTERNAL_SCAN, jiffies)) {
578 IWL_DEBUG_SCAN(priv, "internal scan rejected\n");
579 goto out;
580 }
581 568
582 priv->scan_bands = 0; 569 priv->scan_bands = 0;
583 if (priv->band == IEEE80211_BAND_5GHZ) 570 if (priv->band == IEEE80211_BAND_5GHZ)
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index d365d13e3291..d8c11f955e42 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -60,7 +60,8 @@ static const u16 default_tid_to_tx_fifo[] = {
60static inline int iwl_alloc_dma_ptr(struct iwl_priv *priv, 60static inline int iwl_alloc_dma_ptr(struct iwl_priv *priv,
61 struct iwl_dma_ptr *ptr, size_t size) 61 struct iwl_dma_ptr *ptr, size_t size)
62{ 62{
63 ptr->addr = pci_alloc_consistent(priv->pci_dev, size, &ptr->dma); 63 ptr->addr = dma_alloc_coherent(&priv->pci_dev->dev, size, &ptr->dma,
64 GFP_KERNEL);
64 if (!ptr->addr) 65 if (!ptr->addr)
65 return -ENOMEM; 66 return -ENOMEM;
66 ptr->size = size; 67 ptr->size = size;
@@ -73,21 +74,20 @@ static inline void iwl_free_dma_ptr(struct iwl_priv *priv,
73 if (unlikely(!ptr->addr)) 74 if (unlikely(!ptr->addr))
74 return; 75 return;
75 76
76 pci_free_consistent(priv->pci_dev, ptr->size, ptr->addr, ptr->dma); 77 dma_free_coherent(&priv->pci_dev->dev, ptr->size, ptr->addr, ptr->dma);
77 memset(ptr, 0, sizeof(*ptr)); 78 memset(ptr, 0, sizeof(*ptr));
78} 79}
79 80
80/** 81/**
81 * iwl_txq_update_write_ptr - Send new write index to hardware 82 * iwl_txq_update_write_ptr - Send new write index to hardware
82 */ 83 */
83int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) 84void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq)
84{ 85{
85 u32 reg = 0; 86 u32 reg = 0;
86 int ret = 0;
87 int txq_id = txq->q.id; 87 int txq_id = txq->q.id;
88 88
89 if (txq->need_update == 0) 89 if (txq->need_update == 0)
90 return ret; 90 return;
91 91
92 /* if we're trying to save power */ 92 /* if we're trying to save power */
93 if (test_bit(STATUS_POWER_PMI, &priv->status)) { 93 if (test_bit(STATUS_POWER_PMI, &priv->status)) {
@@ -101,7 +101,7 @@ int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq)
101 txq_id, reg); 101 txq_id, reg);
102 iwl_set_bit(priv, CSR_GP_CNTRL, 102 iwl_set_bit(priv, CSR_GP_CNTRL,
103 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 103 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
104 return ret; 104 return;
105 } 105 }
106 106
107 iwl_write_direct32(priv, HBUS_TARG_WRPTR, 107 iwl_write_direct32(priv, HBUS_TARG_WRPTR,
@@ -114,8 +114,6 @@ int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq)
114 txq->q.write_ptr | (txq_id << 8)); 114 txq->q.write_ptr | (txq_id << 8));
115 115
116 txq->need_update = 0; 116 txq->need_update = 0;
117
118 return ret;
119} 117}
120EXPORT_SYMBOL(iwl_txq_update_write_ptr); 118EXPORT_SYMBOL(iwl_txq_update_write_ptr);
121 119
@@ -132,7 +130,7 @@ void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
132{ 130{
133 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 131 struct iwl_tx_queue *txq = &priv->txq[txq_id];
134 struct iwl_queue *q = &txq->q; 132 struct iwl_queue *q = &txq->q;
135 struct pci_dev *dev = priv->pci_dev; 133 struct device *dev = &priv->pci_dev->dev;
136 int i; 134 int i;
137 135
138 if (q->n_bd == 0) 136 if (q->n_bd == 0)
@@ -149,8 +147,8 @@ void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
149 147
150 /* De-alloc circular buffer of TFDs */ 148 /* De-alloc circular buffer of TFDs */
151 if (txq->q.n_bd) 149 if (txq->q.n_bd)
152 pci_free_consistent(dev, priv->hw_params.tfd_size * 150 dma_free_coherent(dev, priv->hw_params.tfd_size *
153 txq->q.n_bd, txq->tfds, txq->q.dma_addr); 151 txq->q.n_bd, txq->tfds, txq->q.dma_addr);
154 152
155 /* De-alloc array of per-TFD driver data */ 153 /* De-alloc array of per-TFD driver data */
156 kfree(txq->txb); 154 kfree(txq->txb);
@@ -179,7 +177,7 @@ void iwl_cmd_queue_free(struct iwl_priv *priv)
179{ 177{
180 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; 178 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
181 struct iwl_queue *q = &txq->q; 179 struct iwl_queue *q = &txq->q;
182 struct pci_dev *dev = priv->pci_dev; 180 struct device *dev = &priv->pci_dev->dev;
183 int i; 181 int i;
184 182
185 if (q->n_bd == 0) 183 if (q->n_bd == 0)
@@ -191,8 +189,8 @@ void iwl_cmd_queue_free(struct iwl_priv *priv)
191 189
192 /* De-alloc circular buffer of TFDs */ 190 /* De-alloc circular buffer of TFDs */
193 if (txq->q.n_bd) 191 if (txq->q.n_bd)
194 pci_free_consistent(dev, priv->hw_params.tfd_size * 192 dma_free_coherent(dev, priv->hw_params.tfd_size * txq->q.n_bd,
195 txq->q.n_bd, txq->tfds, txq->q.dma_addr); 193 txq->tfds, txq->q.dma_addr);
196 194
197 /* deallocate arrays */ 195 /* deallocate arrays */
198 kfree(txq->cmd); 196 kfree(txq->cmd);
@@ -283,7 +281,7 @@ static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
283static int iwl_tx_queue_alloc(struct iwl_priv *priv, 281static int iwl_tx_queue_alloc(struct iwl_priv *priv,
284 struct iwl_tx_queue *txq, u32 id) 282 struct iwl_tx_queue *txq, u32 id)
285{ 283{
286 struct pci_dev *dev = priv->pci_dev; 284 struct device *dev = &priv->pci_dev->dev;
287 size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; 285 size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX;
288 286
289 /* Driver private data, only for Tx (not command) queues, 287 /* Driver private data, only for Tx (not command) queues,
@@ -302,8 +300,8 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
302 300
303 /* Circular buffer of transmit frame descriptors (TFDs), 301 /* Circular buffer of transmit frame descriptors (TFDs),
304 * shared with device */ 302 * shared with device */
305 txq->tfds = pci_alloc_consistent(dev, tfd_sz, &txq->q.dma_addr); 303 txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr,
306 304 GFP_KERNEL);
307 if (!txq->tfds) { 305 if (!txq->tfds) {
308 IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); 306 IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz);
309 goto error; 307 goto error;
@@ -731,7 +729,6 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
731 u8 tid = 0; 729 u8 tid = 0;
732 u8 *qc = NULL; 730 u8 *qc = NULL;
733 unsigned long flags; 731 unsigned long flags;
734 int ret;
735 732
736 spin_lock_irqsave(&priv->lock, flags); 733 spin_lock_irqsave(&priv->lock, flags);
737 if (iwl_is_rfkill(priv)) { 734 if (iwl_is_rfkill(priv)) {
@@ -806,8 +803,10 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
806 hdr->seq_ctrl |= cpu_to_le16(seq_number); 803 hdr->seq_ctrl |= cpu_to_le16(seq_number);
807 seq_number += 0x10; 804 seq_number += 0x10;
808 /* aggregation is on for this <sta,tid> */ 805 /* aggregation is on for this <sta,tid> */
809 if (info->flags & IEEE80211_TX_CTL_AMPDU) 806 if (info->flags & IEEE80211_TX_CTL_AMPDU &&
807 priv->stations[sta_id].tid[tid].agg.state == IWL_AGG_ON) {
810 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; 808 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id;
809 }
811 } 810 }
812 811
813 txq = &priv->txq[txq_id]; 812 txq = &priv->txq[txq_id];
@@ -949,7 +948,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
949 948
950 /* Tell device the write index *just past* this latest filled TFD */ 949 /* Tell device the write index *just past* this latest filled TFD */
951 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); 950 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
952 ret = iwl_txq_update_write_ptr(priv, txq); 951 iwl_txq_update_write_ptr(priv, txq);
953 spin_unlock_irqrestore(&priv->lock, flags); 952 spin_unlock_irqrestore(&priv->lock, flags);
954 953
955 /* 954 /*
@@ -963,9 +962,6 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
963 if (sta_priv && sta_priv->client) 962 if (sta_priv && sta_priv->client)
964 atomic_inc(&sta_priv->pending_frames); 963 atomic_inc(&sta_priv->pending_frames);
965 964
966 if (ret)
967 return ret;
968
969 if ((iwl_queue_space(q) < q->high_mark) && priv->mac80211_registered) { 965 if ((iwl_queue_space(q) < q->high_mark) && priv->mac80211_registered) {
970 if (wait_write_ptr) { 966 if (wait_write_ptr) {
971 spin_lock_irqsave(&priv->lock, flags); 967 spin_lock_irqsave(&priv->lock, flags);
@@ -1004,7 +1000,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1004 struct iwl_cmd_meta *out_meta; 1000 struct iwl_cmd_meta *out_meta;
1005 dma_addr_t phys_addr; 1001 dma_addr_t phys_addr;
1006 unsigned long flags; 1002 unsigned long flags;
1007 int len, ret; 1003 int len;
1008 u32 idx; 1004 u32 idx;
1009 u16 fix_size; 1005 u16 fix_size;
1010 1006
@@ -1101,10 +1097,10 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1101 1097
1102 /* Increment and update queue's write index */ 1098 /* Increment and update queue's write index */
1103 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); 1099 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
1104 ret = iwl_txq_update_write_ptr(priv, txq); 1100 iwl_txq_update_write_ptr(priv, txq);
1105 1101
1106 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 1102 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
1107 return ret ? ret : idx; 1103 return idx;
1108} 1104}
1109 1105
1110static void iwl_tx_status(struct iwl_priv *priv, struct sk_buff *skb) 1106static void iwl_tx_status(struct iwl_priv *priv, struct sk_buff *skb)
@@ -1328,7 +1324,7 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1328{ 1324{
1329 int tx_fifo_id, txq_id, sta_id, ssn = -1; 1325 int tx_fifo_id, txq_id, sta_id, ssn = -1;
1330 struct iwl_tid_data *tid_data; 1326 struct iwl_tid_data *tid_data;
1331 int ret, write_ptr, read_ptr; 1327 int write_ptr, read_ptr;
1332 unsigned long flags; 1328 unsigned long flags;
1333 1329
1334 if (!ra) { 1330 if (!ra) {
@@ -1380,13 +1376,17 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1380 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; 1376 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1381 1377
1382 spin_lock_irqsave(&priv->lock, flags); 1378 spin_lock_irqsave(&priv->lock, flags);
1383 ret = priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, ssn, 1379 /*
1380 * the only reason this call can fail is queue number out of range,
1381 * which can happen if uCode is reloaded and all the station
1382 * information are lost. if it is outside the range, there is no need
1383 * to deactivate the uCode queue, just return "success" to allow
1384 * mac80211 to clean up it own data.
1385 */
1386 priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, ssn,
1384 tx_fifo_id); 1387 tx_fifo_id);
1385 spin_unlock_irqrestore(&priv->lock, flags); 1388 spin_unlock_irqrestore(&priv->lock, flags);
1386 1389
1387 if (ret)
1388 return ret;
1389
1390 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, ra, tid); 1390 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, ra, tid);
1391 1391
1392 return 0; 1392 return 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index eac2b9a95711..3df488a8cf75 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -352,10 +352,10 @@ static int iwl3945_send_beacon_cmd(struct iwl_priv *priv)
352static void iwl3945_unset_hw_params(struct iwl_priv *priv) 352static void iwl3945_unset_hw_params(struct iwl_priv *priv)
353{ 353{
354 if (priv->shared_virt) 354 if (priv->shared_virt)
355 pci_free_consistent(priv->pci_dev, 355 dma_free_coherent(&priv->pci_dev->dev,
356 sizeof(struct iwl3945_shared), 356 sizeof(struct iwl3945_shared),
357 priv->shared_virt, 357 priv->shared_virt,
358 priv->shared_phys); 358 priv->shared_phys);
359} 359}
360 360
361static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, 361static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
@@ -478,7 +478,6 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
478 u8 wait_write_ptr = 0; 478 u8 wait_write_ptr = 0;
479 u8 *qc = NULL; 479 u8 *qc = NULL;
480 unsigned long flags; 480 unsigned long flags;
481 int rc;
482 481
483 spin_lock_irqsave(&priv->lock, flags); 482 spin_lock_irqsave(&priv->lock, flags);
484 if (iwl_is_rfkill(priv)) { 483 if (iwl_is_rfkill(priv)) {
@@ -663,12 +662,9 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
663 662
664 /* Tell device the write index *just past* this latest filled TFD */ 663 /* Tell device the write index *just past* this latest filled TFD */
665 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); 664 q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
666 rc = iwl_txq_update_write_ptr(priv, txq); 665 iwl_txq_update_write_ptr(priv, txq);
667 spin_unlock_irqrestore(&priv->lock, flags); 666 spin_unlock_irqrestore(&priv->lock, flags);
668 667
669 if (rc)
670 return rc;
671
672 if ((iwl_queue_space(q) < q->high_mark) 668 if ((iwl_queue_space(q) < q->high_mark)
673 && priv->mac80211_registered) { 669 && priv->mac80211_registered) {
674 if (wait_write_ptr) { 670 if (wait_write_ptr) {
@@ -1063,13 +1059,13 @@ static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl_priv *priv,
1063 * also updates the memory address in the firmware to reference the new 1059 * also updates the memory address in the firmware to reference the new
1064 * target buffer. 1060 * target buffer.
1065 */ 1061 */
1066static int iwl3945_rx_queue_restock(struct iwl_priv *priv) 1062static void iwl3945_rx_queue_restock(struct iwl_priv *priv)
1067{ 1063{
1068 struct iwl_rx_queue *rxq = &priv->rxq; 1064 struct iwl_rx_queue *rxq = &priv->rxq;
1069 struct list_head *element; 1065 struct list_head *element;
1070 struct iwl_rx_mem_buffer *rxb; 1066 struct iwl_rx_mem_buffer *rxb;
1071 unsigned long flags; 1067 unsigned long flags;
1072 int write, rc; 1068 int write;
1073 1069
1074 spin_lock_irqsave(&rxq->lock, flags); 1070 spin_lock_irqsave(&rxq->lock, flags);
1075 write = rxq->write & ~0x7; 1071 write = rxq->write & ~0x7;
@@ -1099,12 +1095,8 @@ static int iwl3945_rx_queue_restock(struct iwl_priv *priv)
1099 spin_lock_irqsave(&rxq->lock, flags); 1095 spin_lock_irqsave(&rxq->lock, flags);
1100 rxq->need_update = 1; 1096 rxq->need_update = 1;
1101 spin_unlock_irqrestore(&rxq->lock, flags); 1097 spin_unlock_irqrestore(&rxq->lock, flags);
1102 rc = iwl_rx_queue_update_write_ptr(priv, rxq); 1098 iwl_rx_queue_update_write_ptr(priv, rxq);
1103 if (rc)
1104 return rc;
1105 } 1099 }
1106
1107 return 0;
1108} 1100}
1109 1101
1110/** 1102/**
@@ -1249,10 +1241,10 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx
1249 } 1241 }
1250 } 1242 }
1251 1243
1252 pci_free_consistent(priv->pci_dev, 4 * RX_QUEUE_SIZE, rxq->bd, 1244 dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd,
1253 rxq->dma_addr); 1245 rxq->dma_addr);
1254 pci_free_consistent(priv->pci_dev, sizeof(struct iwl_rb_status), 1246 dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status),
1255 rxq->rb_stts, rxq->rb_stts_dma); 1247 rxq->rb_stts, rxq->rb_stts_dma);
1256 rxq->bd = NULL; 1248 rxq->bd = NULL;
1257 rxq->rb_stts = NULL; 1249 rxq->rb_stts = NULL;
1258} 1250}
@@ -4047,6 +4039,13 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4047 spin_lock_init(&priv->reg_lock); 4039 spin_lock_init(&priv->reg_lock);
4048 spin_lock_init(&priv->lock); 4040 spin_lock_init(&priv->lock);
4049 4041
4042 /*
4043 * stop and reset the on-board processor just in case it is in a
4044 * strange state ... like being left stranded by a primary kernel
4045 * and this is now the kdump kernel trying to start up
4046 */
4047 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
4048
4050 /*********************** 4049 /***********************
4051 * 4. Read EEPROM 4050 * 4. Read EEPROM
4052 * ********************/ 4051 * ********************/