aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-io.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c50
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c121
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fh.h55
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c75
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c157
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c272
17 files changed, 466 insertions, 386 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-io.h b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
index 1daa3f05a775..7dea1552a906 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-io.h
@@ -107,7 +107,7 @@ static inline int __iwl3945_poll_bit(const char *f, u32 l,
107 int ret = _iwl3945_poll_bit(priv, addr, bits, mask, timeout); 107 int ret = _iwl3945_poll_bit(priv, addr, bits, mask, timeout);
108 IWL_DEBUG_IO("poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", 108 IWL_DEBUG_IO("poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n",
109 addr, bits, mask, 109 addr, bits, mask,
110 unlikely(ret == -ETIMEDOUT)?"timeout":"", f, l); 110 unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l);
111 return ret; 111 return ret;
112} 112}
113#define iwl3945_poll_bit(priv, addr, bits, mask, timeout) \ 113#define iwl3945_poll_bit(priv, addr, bits, mask, timeout) \
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 7187925bd0d5..2a924c10ff93 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -886,7 +886,6 @@ struct iwl3945_priv {
886 struct work_struct report_work; 886 struct work_struct report_work;
887 struct work_struct request_scan; 887 struct work_struct request_scan;
888 struct work_struct beacon_update; 888 struct work_struct beacon_update;
889 struct work_struct set_monitor;
890 889
891 struct tasklet_struct irq_tasklet; 890 struct tasklet_struct irq_tasklet;
892 891
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index c43cf2f072cd..ab0b40531989 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -53,6 +53,7 @@ static int iwl4965_hw_get_temperature(const struct iwl_priv *priv);
53 * is not compatible with earlier drivers. 53 * is not compatible with earlier drivers.
54 * This number will also appear in << 8 position of 1st dword of uCode file */ 54 * This number will also appear in << 8 position of 1st dword of uCode file */
55#define IWL4965_UCODE_API "-2" 55#define IWL4965_UCODE_API "-2"
56#define IWL4965_MODULE_FIRMWARE "iwlwifi-4965" IWL4965_UCODE_API ".ucode"
56 57
57 58
58/* module parameters */ 59/* module parameters */
@@ -661,7 +662,7 @@ static void iwl4965_tx_queue_set_status(struct iwl_priv *priv,
661 int txq_id = txq->q.id; 662 int txq_id = txq->q.id;
662 663
663 /* Find out whether to activate Tx queue */ 664 /* Find out whether to activate Tx queue */
664 int active = test_bit(txq_id, &priv->txq_ctx_active_msk)?1:0; 665 int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
665 666
666 /* Set up and activate */ 667 /* Set up and activate */
667 iwl_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), 668 iwl_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id),
@@ -691,9 +692,10 @@ static const u16 default_queue_to_tx_fifo[] = {
691static int iwl4965_alive_notify(struct iwl_priv *priv) 692static int iwl4965_alive_notify(struct iwl_priv *priv)
692{ 693{
693 u32 a; 694 u32 a;
694 int i = 0;
695 unsigned long flags; 695 unsigned long flags;
696 int ret; 696 int ret;
697 int i, chan;
698 u32 reg_val;
697 699
698 spin_lock_irqsave(&priv->lock, flags); 700 spin_lock_irqsave(&priv->lock, flags);
699 701
@@ -717,6 +719,17 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
717 iwl_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, 719 iwl_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR,
718 priv->scd_bc_tbls.dma >> 10); 720 priv->scd_bc_tbls.dma >> 10);
719 721
722 /* Enable DMA channel */
723 for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++)
724 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
725 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
726 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
727
728 /* Update FH chicken bits */
729 reg_val = iwl_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
730 iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
731 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
732
720 /* Disable chain mode for all queues */ 733 /* Disable chain mode for all queues */
721 iwl_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); 734 iwl_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0);
722 735
@@ -747,7 +760,7 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
747 (1 << priv->hw_params.max_txq_num) - 1); 760 (1 << priv->hw_params.max_txq_num) - 1);
748 761
749 /* Activate all Tx DMA/FIFO channels */ 762 /* Activate all Tx DMA/FIFO channels */
750 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7)); 763 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 6));
751 764
752 iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); 765 iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0);
753 766
@@ -1909,7 +1922,7 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id,
1909 ra_tid = BUILD_RAxTID(sta_id, tid); 1922 ra_tid = BUILD_RAxTID(sta_id, tid);
1910 1923
1911 /* Modify device's station table to Tx this TID */ 1924 /* Modify device's station table to Tx this TID */
1912 iwl_sta_modify_enable_tid_tx(priv, sta_id, tid); 1925 iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
1913 1926
1914 spin_lock_irqsave(&priv->lock, flags); 1927 spin_lock_irqsave(&priv->lock, flags);
1915 ret = iwl_grab_nic_access(priv); 1928 ret = iwl_grab_nic_access(priv);
@@ -2025,7 +2038,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2025 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); 2038 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
2026 info->status.rates[0].count = tx_resp->failure_frame + 1; 2039 info->status.rates[0].count = tx_resp->failure_frame + 1;
2027 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 2040 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
2028 info->flags |= iwl_is_tx_success(status)? 2041 info->flags |= iwl_is_tx_success(status) ?
2029 IEEE80211_TX_STAT_ACK : 0; 2042 IEEE80211_TX_STAT_ACK : 0;
2030 iwl_hwrate_to_tx_control(priv, rate_n_flags, info); 2043 iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
2031 /* FIXME: code repetition end */ 2044 /* FIXME: code repetition end */
@@ -2322,7 +2335,7 @@ static struct iwl_ops iwl4965_ops = {
2322 2335
2323struct iwl_cfg iwl4965_agn_cfg = { 2336struct iwl_cfg iwl4965_agn_cfg = {
2324 .name = "4965AGN", 2337 .name = "4965AGN",
2325 .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode", 2338 .fw_name = IWL4965_MODULE_FIRMWARE,
2326 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 2339 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
2327 .eeprom_size = IWL4965_EEPROM_IMG_SIZE, 2340 .eeprom_size = IWL4965_EEPROM_IMG_SIZE,
2328 .eeprom_ver = EEPROM_4965_EEPROM_VERSION, 2341 .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
@@ -2332,7 +2345,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
2332}; 2345};
2333 2346
2334/* Module firmware */ 2347/* Module firmware */
2335MODULE_FIRMWARE("iwlwifi-4965" IWL4965_UCODE_API ".ucode"); 2348MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE);
2336 2349
2337module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444); 2350module_param_named(antenna, iwl4965_mod_params.antenna, int, 0444);
2338MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); 2351MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index ee3613db3132..a738886b434f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -475,6 +475,9 @@ static void iwl5000_rx_calib_result(struct iwl_priv *priv,
475 case IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD: 475 case IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD:
476 index = IWL_CALIB_TX_IQ_PERD; 476 index = IWL_CALIB_TX_IQ_PERD;
477 break; 477 break;
478 case IWL_PHY_CALIBRATE_BASE_BAND_CMD:
479 index = IWL_CALIB_BASE_BAND;
480 break;
478 default: 481 default:
479 IWL_ERROR("Unknown calibration notification %d\n", 482 IWL_ERROR("Unknown calibration notification %d\n",
480 hdr->op_code); 483 hdr->op_code);
@@ -697,9 +700,10 @@ static int iwl5000_send_wimax_coex(struct iwl_priv *priv)
697static int iwl5000_alive_notify(struct iwl_priv *priv) 700static int iwl5000_alive_notify(struct iwl_priv *priv)
698{ 701{
699 u32 a; 702 u32 a;
700 int i = 0;
701 unsigned long flags; 703 unsigned long flags;
702 int ret; 704 int ret;
705 int i, chan;
706 u32 reg_val;
703 707
704 spin_lock_irqsave(&priv->lock, flags); 708 spin_lock_irqsave(&priv->lock, flags);
705 709
@@ -722,6 +726,18 @@ static int iwl5000_alive_notify(struct iwl_priv *priv)
722 726
723 iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR, 727 iwl_write_prph(priv, IWL50_SCD_DRAM_BASE_ADDR,
724 priv->scd_bc_tbls.dma >> 10); 728 priv->scd_bc_tbls.dma >> 10);
729
730 /* Enable DMA channel */
731 for (chan = 0; chan < FH50_TCSR_CHNL_NUM ; chan++)
732 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan),
733 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
734 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
735
736 /* Update FH chicken bits */
737 reg_val = iwl_read_direct32(priv, FH_TX_CHICKEN_BITS_REG);
738 iwl_write_direct32(priv, FH_TX_CHICKEN_BITS_REG,
739 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
740
725 iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL, 741 iwl_write_prph(priv, IWL50_SCD_QUEUECHAIN_SEL,
726 IWL50_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num)); 742 IWL50_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num));
727 iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0); 743 iwl_write_prph(priv, IWL50_SCD_AGGR_SEL, 0);
@@ -841,8 +857,9 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
841 priv->hw_params.calib_init_cfg = 857 priv->hw_params.calib_init_cfg =
842 BIT(IWL_CALIB_XTAL) | 858 BIT(IWL_CALIB_XTAL) |
843 BIT(IWL_CALIB_LO) | 859 BIT(IWL_CALIB_LO) |
844 BIT(IWL_CALIB_TX_IQ) | 860 BIT(IWL_CALIB_TX_IQ) |
845 BIT(IWL_CALIB_TX_IQ_PERD); 861 BIT(IWL_CALIB_TX_IQ_PERD) |
862 BIT(IWL_CALIB_BASE_BAND);
846 break; 863 break;
847 case CSR_HW_REV_TYPE_5150: 864 case CSR_HW_REV_TYPE_5150:
848 priv->hw_params.calib_init_cfg = 0; 865 priv->hw_params.calib_init_cfg = 0;
@@ -969,7 +986,7 @@ static int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
969 ra_tid = BUILD_RAxTID(sta_id, tid); 986 ra_tid = BUILD_RAxTID(sta_id, tid);
970 987
971 /* Modify device's station table to Tx this TID */ 988 /* Modify device's station table to Tx this TID */
972 iwl_sta_modify_enable_tid_tx(priv, sta_id, tid); 989 iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
973 990
974 spin_lock_irqsave(&priv->lock, flags); 991 spin_lock_irqsave(&priv->lock, flags);
975 ret = iwl_grab_nic_access(priv); 992 ret = iwl_grab_nic_access(priv);
@@ -1111,7 +1128,7 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1111 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); 1128 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
1112 info->status.rates[0].count = tx_resp->failure_frame + 1; 1129 info->status.rates[0].count = tx_resp->failure_frame + 1;
1113 info->flags &= ~IEEE80211_TX_CTL_AMPDU; 1130 info->flags &= ~IEEE80211_TX_CTL_AMPDU;
1114 info->flags |= iwl_is_tx_success(status)? 1131 info->flags |= iwl_is_tx_success(status) ?
1115 IEEE80211_TX_STAT_ACK : 0; 1132 IEEE80211_TX_STAT_ACK : 0;
1116 iwl_hwrate_to_tx_control(priv, rate_n_flags, info); 1133 iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
1117 1134
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 0332805cc630..3a2b81291d86 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -281,10 +281,9 @@ static u8 rs_tl_add_packet(struct iwl_lq_sta *lq_data,
281 u32 time_diff; 281 u32 time_diff;
282 s32 index; 282 s32 index;
283 struct iwl_traffic_load *tl = NULL; 283 struct iwl_traffic_load *tl = NULL;
284 __le16 fc = hdr->frame_control;
285 u8 tid; 284 u8 tid;
286 285
287 if (ieee80211_is_data_qos(fc)) { 286 if (ieee80211_is_data_qos(hdr->frame_control)) {
288 u8 *qc = ieee80211_get_qos_ctl(hdr); 287 u8 *qc = ieee80211_get_qos_ctl(hdr);
289 tid = qc[0] & 0xf; 288 tid = qc[0] & 0xf;
290 } else 289 } else
@@ -773,7 +772,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
773 int status; 772 int status;
774 u8 retries; 773 u8 retries;
775 int rs_index, index = 0; 774 int rs_index, index = 0;
776 struct iwl_lq_sta *lq_sta; 775 struct iwl_lq_sta *lq_sta = priv_sta;
777 struct iwl_link_quality_cmd *table; 776 struct iwl_link_quality_cmd *table;
778 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 777 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
779 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 778 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
@@ -785,12 +784,12 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
785 struct iwl_scale_tbl_info tbl_type; 784 struct iwl_scale_tbl_info tbl_type;
786 struct iwl_scale_tbl_info *curr_tbl, *search_tbl; 785 struct iwl_scale_tbl_info *curr_tbl, *search_tbl;
787 u8 active_index = 0; 786 u8 active_index = 0;
788 __le16 fc = hdr->frame_control;
789 s32 tpt = 0; 787 s32 tpt = 0;
790 788
791 IWL_DEBUG_RATE_LIMIT("get frame ack response, update rate scale window\n"); 789 IWL_DEBUG_RATE_LIMIT("get frame ack response, update rate scale window\n");
792 790
793 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) 791 if (!ieee80211_is_data(hdr->frame_control) ||
792 is_multicast_ether_addr(hdr->addr1))
794 return; 793 return;
795 794
796 /* This packet was aggregated but doesn't carry rate scale info */ 795 /* This packet was aggregated but doesn't carry rate scale info */
@@ -803,8 +802,6 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
803 if (retries > 15) 802 if (retries > 15)
804 retries = 15; 803 retries = 15;
805 804
806 lq_sta = (struct iwl_lq_sta *)priv_sta;
807
808 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && 805 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
809 !lq_sta->ibss_sta_added) 806 !lq_sta->ibss_sta_added)
810 goto out; 807 goto out;
@@ -1675,7 +1672,6 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1675 int high_tpt = IWL_INVALID_VALUE; 1672 int high_tpt = IWL_INVALID_VALUE;
1676 u32 fail_count; 1673 u32 fail_count;
1677 s8 scale_action = 0; 1674 s8 scale_action = 0;
1678 __le16 fc;
1679 u16 rate_mask; 1675 u16 rate_mask;
1680 u8 update_lq = 0; 1676 u8 update_lq = 0;
1681 struct iwl_scale_tbl_info *tbl, *tbl1; 1677 struct iwl_scale_tbl_info *tbl, *tbl1;
@@ -1690,13 +1686,12 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1690 1686
1691 IWL_DEBUG_RATE("rate scale calculate new rate for skb\n"); 1687 IWL_DEBUG_RATE("rate scale calculate new rate for skb\n");
1692 1688
1693 fc = hdr->frame_control; 1689 /* Send management frames and broadcast/multicast data using
1694 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) { 1690 * lowest rate. */
1695 /* Send management frames and broadcast/multicast data using 1691 /* TODO: this could probably be improved.. */
1696 * lowest rate. */ 1692 if (!ieee80211_is_data(hdr->frame_control) ||
1697 /* TODO: this could probably be improved.. */ 1693 is_multicast_ether_addr(hdr->addr1))
1698 return; 1694 return;
1699 }
1700 1695
1701 if (!sta || !lq_sta) 1696 if (!sta || !lq_sta)
1702 return; 1697 return;
@@ -2095,29 +2090,26 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2095 struct ieee80211_tx_rate_control *txrc) 2090 struct ieee80211_tx_rate_control *txrc)
2096{ 2091{
2097 2092
2098 int i;
2099 struct sk_buff *skb = txrc->skb; 2093 struct sk_buff *skb = txrc->skb;
2100 struct ieee80211_supported_band *sband = txrc->sband; 2094 struct ieee80211_supported_band *sband = txrc->sband;
2101 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 2095 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
2102 struct ieee80211_conf *conf = &priv->hw->conf; 2096 struct ieee80211_conf *conf = &priv->hw->conf;
2103 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 2097 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2104 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 2098 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2105 __le16 fc; 2099 struct iwl_lq_sta *lq_sta = priv_sta;
2106 struct iwl_lq_sta *lq_sta; 2100 int rate_idx;
2107 2101
2108 IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); 2102 IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n");
2109 2103
2110 /* Send management frames and broadcast/multicast data using lowest 2104 /* Send management frames and broadcast/multicast data using lowest
2111 * rate. */ 2105 * rate. */
2112 fc = hdr->frame_control; 2106 if (!ieee80211_is_data(hdr->frame_control) ||
2113 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || 2107 is_multicast_ether_addr(hdr->addr1) || !sta || !lq_sta) {
2114 !sta || !priv_sta) {
2115 info->control.rates[0].idx = rate_lowest_index(sband, sta); 2108 info->control.rates[0].idx = rate_lowest_index(sband, sta);
2116 return; 2109 return;
2117 } 2110 }
2118 2111
2119 lq_sta = (struct iwl_lq_sta *)priv_sta; 2112 rate_idx = lq_sta->last_txrate_idx;
2120 i = lq_sta->last_txrate_idx;
2121 2113
2122 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && 2114 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
2123 !lq_sta->ibss_sta_added) { 2115 !lq_sta->ibss_sta_added) {
@@ -2137,14 +2129,12 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2137 } 2129 }
2138 } 2130 }
2139 2131
2140 if ((i < 0) || (i > IWL_RATE_COUNT)) { 2132 if (rate_idx < 0 || rate_idx > IWL_RATE_COUNT)
2141 info->control.rates[0].idx = rate_lowest_index(sband, sta); 2133 rate_idx = rate_lowest_index(sband, sta);
2142 return; 2134 else if (sband->band == IEEE80211_BAND_5GHZ)
2143 } 2135 rate_idx -= IWL_FIRST_OFDM_RATE;
2144 2136
2145 if (sband->band == IEEE80211_BAND_5GHZ) 2137 info->control.rates[0].idx = rate_idx;
2146 i -= IWL_FIRST_OFDM_RATE;
2147 info->control.rates[0].idx = i;
2148} 2138}
2149 2139
2150static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, 2140static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
@@ -2525,7 +2515,7 @@ static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
2525 for (i = 0; i < LQ_SIZE; i++) { 2515 for (i = 0; i < LQ_SIZE; i++) {
2526 desc += sprintf(buff+desc, "%s type=%d SGI=%d FAT=%d DUP=%d\n" 2516 desc += sprintf(buff+desc, "%s type=%d SGI=%d FAT=%d DUP=%d\n"
2527 "rate=0x%X\n", 2517 "rate=0x%X\n",
2528 lq_sta->active_tbl == i?"*":"x", 2518 lq_sta->active_tbl == i ? "*" : "x",
2529 lq_sta->lq_info[i].lq_type, 2519 lq_sta->lq_info[i].lq_type,
2530 lq_sta->lq_info[i].is_SGI, 2520 lq_sta->lq_info[i].is_SGI,
2531 lq_sta->lq_info[i].is_fat, 2521 lq_sta->lq_info[i].is_fat,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 8fa4f7a2dc1a..c8ce84a1eef4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -466,9 +466,9 @@ static u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv)
466 466
467 /* Set rate mask*/ 467 /* Set rate mask*/
468 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) 468 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
469 rate_mask = priv->active_rate_basic & 0xF; 469 rate_mask = priv->active_rate_basic & IWL_CCK_RATES_MASK;
470 else 470 else
471 rate_mask = priv->active_rate_basic & 0xFF0; 471 rate_mask = priv->active_rate_basic & IWL_OFDM_RATES_MASK;
472 472
473 /* Find lowest valid rate */ 473 /* Find lowest valid rate */
474 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID; 474 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID;
@@ -1492,7 +1492,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1492 hw_rf_kill = 1; 1492 hw_rf_kill = 1;
1493 1493
1494 IWL_DEBUG(IWL_DL_RF_KILL, "RF_KILL bit toggled to %s.\n", 1494 IWL_DEBUG(IWL_DL_RF_KILL, "RF_KILL bit toggled to %s.\n",
1495 hw_rf_kill ? "disable radio":"enable radio"); 1495 hw_rf_kill ? "disable radio" : "enable radio");
1496 1496
1497 /* driver only loads ucode once setting the interface up. 1497 /* driver only loads ucode once setting the interface up.
1498 * the driver as well won't allow loading if RFKILL is set 1498 * the driver as well won't allow loading if RFKILL is set
@@ -2224,27 +2224,6 @@ static void iwl_bg_rf_kill(struct work_struct *work)
2224 iwl_rfkill_set_hw_state(priv); 2224 iwl_rfkill_set_hw_state(priv);
2225} 2225}
2226 2226
2227static void iwl_bg_set_monitor(struct work_struct *work)
2228{
2229 struct iwl_priv *priv = container_of(work,
2230 struct iwl_priv, set_monitor);
2231 int ret;
2232
2233 IWL_DEBUG(IWL_DL_STATE, "setting monitor mode\n");
2234
2235 mutex_lock(&priv->mutex);
2236
2237 ret = iwl_set_mode(priv, NL80211_IFTYPE_MONITOR);
2238 if (ret) {
2239 if (ret == -EAGAIN)
2240 IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n");
2241 else
2242 IWL_ERROR("iwl_set_mode() failed ret = %d\n", ret);
2243 }
2244
2245 mutex_unlock(&priv->mutex);
2246}
2247
2248static void iwl_bg_run_time_calib_work(struct work_struct *work) 2227static void iwl_bg_run_time_calib_work(struct work_struct *work)
2249{ 2228{
2250 struct iwl_priv *priv = container_of(work, struct iwl_priv, 2229 struct iwl_priv *priv = container_of(work, struct iwl_priv,
@@ -2890,16 +2869,43 @@ static void iwl_configure_filter(struct ieee80211_hw *hw,
2890 int mc_count, struct dev_addr_list *mc_list) 2869 int mc_count, struct dev_addr_list *mc_list)
2891{ 2870{
2892 struct iwl_priv *priv = hw->priv; 2871 struct iwl_priv *priv = hw->priv;
2872 __le32 *filter_flags = &priv->staging_rxon.filter_flags;
2873
2874 IWL_DEBUG_MAC80211("Enter: changed: 0x%x, total: 0x%x\n",
2875 changed_flags, *total_flags);
2893 2876
2894 if (changed_flags & (*total_flags) & FIF_OTHER_BSS) { 2877 if (changed_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) {
2895 IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n", 2878 if (*total_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS))
2896 NL80211_IFTYPE_MONITOR, 2879 *filter_flags |= RXON_FILTER_PROMISC_MSK;
2897 changed_flags, *total_flags); 2880 else
2898 /* queue work 'cuz mac80211 is holding a lock which 2881 *filter_flags &= ~RXON_FILTER_PROMISC_MSK;
2899 * prevents us from issuing (synchronous) f/w cmds */ 2882 }
2900 queue_work(priv->workqueue, &priv->set_monitor); 2883 if (changed_flags & FIF_ALLMULTI) {
2884 if (*total_flags & FIF_ALLMULTI)
2885 *filter_flags |= RXON_FILTER_ACCEPT_GRP_MSK;
2886 else
2887 *filter_flags &= ~RXON_FILTER_ACCEPT_GRP_MSK;
2888 }
2889 if (changed_flags & FIF_CONTROL) {
2890 if (*total_flags & FIF_CONTROL)
2891 *filter_flags |= RXON_FILTER_CTL2HOST_MSK;
2892 else
2893 *filter_flags &= ~RXON_FILTER_CTL2HOST_MSK;
2894 }
2895 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
2896 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
2897 *filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
2898 else
2899 *filter_flags &= ~RXON_FILTER_BCON_AWARE_MSK;
2901 } 2900 }
2902 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | 2901
2902 /* We avoid iwl_commit_rxon here to commit the new filter flags
2903 * since mac80211 will call ieee80211_hw_config immediately.
2904 * (mc_list is not supported at this time). Otherwise, we need to
2905 * queue a background iwl_commit_rxon work.
2906 */
2907
2908 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
2903 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 2909 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
2904} 2910}
2905 2911
@@ -3058,49 +3064,11 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
3058 struct ieee80211_key_conf *keyconf, const u8 *addr, 3064 struct ieee80211_key_conf *keyconf, const u8 *addr,
3059 u32 iv32, u16 *phase1key) 3065 u32 iv32, u16 *phase1key)
3060{ 3066{
3061 struct iwl_priv *priv = hw->priv;
3062 u8 sta_id = IWL_INVALID_STATION;
3063 unsigned long flags;
3064 __le16 key_flags = 0;
3065 int i;
3066 3067
3068 struct iwl_priv *priv = hw->priv;
3067 IWL_DEBUG_MAC80211("enter\n"); 3069 IWL_DEBUG_MAC80211("enter\n");
3068 3070
3069 sta_id = iwl_find_station(priv, addr); 3071 iwl_update_tkip_key(priv, keyconf, addr, iv32, phase1key);
3070 if (sta_id == IWL_INVALID_STATION) {
3071 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n",
3072 addr);
3073 return;
3074 }
3075
3076 if (iwl_scan_cancel(priv)) {
3077 /* cancel scan failed, just live w/ bad key and rely
3078 briefly on SW decryption */
3079 return;
3080 }
3081
3082 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
3083 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
3084 key_flags &= ~STA_KEY_FLG_INVALID;
3085
3086 if (sta_id == priv->hw_params.bcast_sta_id)
3087 key_flags |= STA_KEY_MULTICAST_MSK;
3088
3089 spin_lock_irqsave(&priv->sta_lock, flags);
3090
3091 priv->stations[sta_id].sta.key.key_flags = key_flags;
3092 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
3093
3094 for (i = 0; i < 5; i++)
3095 priv->stations[sta_id].sta.key.tkip_rx_ttak[i] =
3096 cpu_to_le16(phase1key[i]);
3097
3098 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
3099 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
3100
3101 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
3102
3103 spin_unlock_irqrestore(&priv->sta_lock, flags);
3104 3072
3105 IWL_DEBUG_MAC80211("leave\n"); 3073 IWL_DEBUG_MAC80211("leave\n");
3106} 3074}
@@ -3239,10 +3207,10 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3239 switch (action) { 3207 switch (action) {
3240 case IEEE80211_AMPDU_RX_START: 3208 case IEEE80211_AMPDU_RX_START:
3241 IWL_DEBUG_HT("start Rx\n"); 3209 IWL_DEBUG_HT("start Rx\n");
3242 return iwl_rx_agg_start(priv, sta->addr, tid, *ssn); 3210 return iwl_sta_rx_agg_start(priv, sta->addr, tid, *ssn);
3243 case IEEE80211_AMPDU_RX_STOP: 3211 case IEEE80211_AMPDU_RX_STOP:
3244 IWL_DEBUG_HT("stop Rx\n"); 3212 IWL_DEBUG_HT("stop Rx\n");
3245 return iwl_rx_agg_stop(priv, sta->addr, tid); 3213 return iwl_sta_rx_agg_stop(priv, sta->addr, tid);
3246 case IEEE80211_AMPDU_TX_START: 3214 case IEEE80211_AMPDU_TX_START:
3247 IWL_DEBUG_HT("start Tx\n"); 3215 IWL_DEBUG_HT("start Tx\n");
3248 return iwl_tx_agg_start(priv, sta->addr, tid, ssn); 3216 return iwl_tx_agg_start(priv, sta->addr, tid, ssn);
@@ -3256,6 +3224,7 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3256 } 3224 }
3257 return 0; 3225 return 0;
3258} 3226}
3227
3259static int iwl_mac_get_tx_stats(struct ieee80211_hw *hw, 3228static int iwl_mac_get_tx_stats(struct ieee80211_hw *hw,
3260 struct ieee80211_tx_queue_stats *stats) 3229 struct ieee80211_tx_queue_stats *stats)
3261{ 3230{
@@ -3694,7 +3663,8 @@ static ssize_t show_power_level(struct device *d,
3694 break; 3663 break;
3695 } 3664 }
3696 3665
3697 p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO)?"fixed":"auto"); 3666 p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO) ?
3667 "fixed" : "auto");
3698 p += sprintf(p, "\tINDEX:%d", level); 3668 p += sprintf(p, "\tINDEX:%d", level);
3699 p += sprintf(p, "\n"); 3669 p += sprintf(p, "\n");
3700 return p - buf + 1; 3670 return p - buf + 1;
@@ -3832,7 +3802,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
3832 INIT_WORK(&priv->rx_replenish, iwl_bg_rx_replenish); 3802 INIT_WORK(&priv->rx_replenish, iwl_bg_rx_replenish);
3833 INIT_WORK(&priv->rf_kill, iwl_bg_rf_kill); 3803 INIT_WORK(&priv->rf_kill, iwl_bg_rf_kill);
3834 INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update); 3804 INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update);
3835 INIT_WORK(&priv->set_monitor, iwl_bg_set_monitor);
3836 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); 3805 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work);
3837 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); 3806 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start);
3838 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); 3807 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 8bd4d087d4e2..6aa332bebc5f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -37,6 +37,7 @@
37#include "iwl-io.h" 37#include "iwl-io.h"
38#include "iwl-rfkill.h" 38#include "iwl-rfkill.h"
39#include "iwl-power.h" 39#include "iwl-power.h"
40#include "iwl-sta.h"
40 41
41 42
42MODULE_DESCRIPTION("iwl core"); 43MODULE_DESCRIPTION("iwl core");
@@ -237,28 +238,6 @@ int iwl_hw_nic_init(struct iwl_priv *priv)
237} 238}
238EXPORT_SYMBOL(iwl_hw_nic_init); 239EXPORT_SYMBOL(iwl_hw_nic_init);
239 240
240/**
241 * iwl_clear_stations_table - Clear the driver's station table
242 *
243 * NOTE: This does not clear or otherwise alter the device's station table.
244 */
245void iwl_clear_stations_table(struct iwl_priv *priv)
246{
247 unsigned long flags;
248
249 spin_lock_irqsave(&priv->sta_lock, flags);
250
251 if (iwl_is_alive(priv) &&
252 !test_bit(STATUS_EXIT_PENDING, &priv->status) &&
253 iwl_send_cmd_pdu_async(priv, REPLY_REMOVE_ALL_STA, 0, NULL, NULL))
254 IWL_ERROR("Couldn't clear the station table\n");
255
256 priv->num_stations = 0;
257 memset(priv->stations, 0, sizeof(priv->stations));
258
259 spin_unlock_irqrestore(&priv->sta_lock, flags);
260}
261EXPORT_SYMBOL(iwl_clear_stations_table);
262 241
263void iwl_reset_qos(struct iwl_priv *priv) 242void iwl_reset_qos(struct iwl_priv *priv)
264{ 243{
@@ -832,6 +811,9 @@ int iwl_setup_mac(struct iwl_priv *priv)
832 BIT(NL80211_IFTYPE_AP) | 811 BIT(NL80211_IFTYPE_AP) |
833 BIT(NL80211_IFTYPE_STATION) | 812 BIT(NL80211_IFTYPE_STATION) |
834 BIT(NL80211_IFTYPE_ADHOC); 813 BIT(NL80211_IFTYPE_ADHOC);
814
815 hw->wiphy->fw_handles_regulatory = true;
816
835 /* Default value; 4 EDCA QOS priorities */ 817 /* Default value; 4 EDCA QOS priorities */
836 hw->queues = 4; 818 hw->queues = 4;
837 /* queues to support 11n aggregation */ 819 /* queues to support 11n aggregation */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index ff966b8a0c6d..82bf263b6f5a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -182,7 +182,6 @@ struct iwl_cfg {
182struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg, 182struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
183 struct ieee80211_ops *hw_ops); 183 struct ieee80211_ops *hw_ops);
184void iwl_hw_detect(struct iwl_priv *priv); 184void iwl_hw_detect(struct iwl_priv *priv);
185void iwl_clear_stations_table(struct iwl_priv *priv);
186void iwl_reset_qos(struct iwl_priv *priv); 185void iwl_reset_qos(struct iwl_priv *priv);
187void iwl_set_rxon_chain(struct iwl_priv *priv); 186void iwl_set_rxon_chain(struct iwl_priv *priv);
188int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch); 187int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch);
@@ -206,8 +205,6 @@ int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
206void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); 205void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
207void iwl_rx_replenish(struct iwl_priv *priv); 206void iwl_rx_replenish(struct iwl_priv *priv);
208int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); 207int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
209int iwl_rx_agg_start(struct iwl_priv *priv, const u8 *addr, int tid, u16 ssn);
210int iwl_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid);
211int iwl_rx_queue_restock(struct iwl_priv *priv); 208int iwl_rx_queue_restock(struct iwl_priv *priv);
212int iwl_rx_queue_space(const struct iwl_rx_queue *q); 209int iwl_rx_queue_space(const struct iwl_rx_queue *q);
213void iwl_rx_allocate(struct iwl_priv *priv); 210void iwl_rx_allocate(struct iwl_priv *priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index bd3df55e4953..4da988e0eae0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -574,11 +574,6 @@ struct iwl_hw_params {
574 * iwl4965_mac_ <-- mac80211 callback 574 * iwl4965_mac_ <-- mac80211 callback
575 * 575 *
576 ****************************************************************************/ 576 ****************************************************************************/
577struct iwl_addsta_cmd;
578extern int iwl_send_add_sta(struct iwl_priv *priv,
579 struct iwl_addsta_cmd *sta, u8 flags);
580extern u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr,
581 int is_ap, u8 flags, struct ieee80211_sta_ht_cap *ht_info);
582extern void iwl_update_chain_flags(struct iwl_priv *priv); 577extern void iwl_update_chain_flags(struct iwl_priv *priv);
583extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src); 578extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
584extern const u8 iwl_bcast_addr[ETH_ALEN]; 579extern const u8 iwl_bcast_addr[ETH_ALEN];
@@ -700,6 +695,7 @@ enum iwl_calib {
700 IWL_CALIB_LO, 695 IWL_CALIB_LO,
701 IWL_CALIB_TX_IQ, 696 IWL_CALIB_TX_IQ,
702 IWL_CALIB_TX_IQ_PERD, 697 IWL_CALIB_TX_IQ_PERD,
698 IWL_CALIB_BASE_BAND,
703 IWL_CALIB_MAX 699 IWL_CALIB_MAX
704}; 700};
705 701
@@ -990,7 +986,6 @@ struct iwl_priv {
990 struct work_struct report_work; 986 struct work_struct report_work;
991 struct work_struct request_scan; 987 struct work_struct request_scan;
992 struct work_struct beacon_update; 988 struct work_struct beacon_update;
993 struct work_struct set_monitor;
994 989
995 struct tasklet_struct irq_tasklet; 990 struct tasklet_struct irq_tasklet;
996 991
diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h
index e46300c28a8f..c3dadb03701c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fh.h
@@ -72,7 +72,7 @@
72 * Addresses are offsets from device's PCI hardware base address. 72 * Addresses are offsets from device's PCI hardware base address.
73 */ 73 */
74#define FH_MEM_LOWER_BOUND (0x1000) 74#define FH_MEM_LOWER_BOUND (0x1000)
75#define FH_MEM_UPPER_BOUND (0x1EF0) 75#define FH_MEM_UPPER_BOUND (0x2000)
76 76
77/** 77/**
78 * Keep-Warm (KW) buffer base address. 78 * Keep-Warm (KW) buffer base address.
@@ -268,6 +268,8 @@
268 268
269#define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME (0x00008000) 269#define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME (0x00008000)
270 270
271#define FH_RSCSR_FRAME_SIZE_MSK (0x00003FFF) /* bits 0-13 */
272
271 273
272/** 274/**
273 * Rx Shared Status Registers (RSSR) 275 * Rx Shared Status Registers (RSSR)
@@ -294,6 +296,13 @@
294 296
295#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 297#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28
296 298
299/* TFDB Area - TFDs buffer table */
300#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
301#define FH_TFDIB_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x900)
302#define FH_TFDIB_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x958)
303#define FH_TFDIB_CTRL0_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
304#define FH_TFDIB_CTRL1_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
305
297/** 306/**
298 * Transmit DMA Channel Control/Status Registers (TCSR) 307 * Transmit DMA Channel Control/Status Registers (TCSR)
299 * 308 *
@@ -323,6 +332,7 @@
323#define FH49_TCSR_CHNL_NUM (7) 332#define FH49_TCSR_CHNL_NUM (7)
324#define FH50_TCSR_CHNL_NUM (8) 333#define FH50_TCSR_CHNL_NUM (8)
325 334
335/* TCSR: tx_config register values */
326#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ 336#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
327 (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl)) 337 (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl))
328#define FH_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ 338#define FH_TCSR_CHNL_TX_CREDIT_REG(_chnl) \
@@ -379,31 +389,18 @@
379 (FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \ 389 (FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
380 FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl)) 390 FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
381 391
382
383
384#define FH_REGS_LOWER_BOUND (0x1000)
385#define FH_REGS_UPPER_BOUND (0x2000)
386
387/* Tx service channels */ 392/* Tx service channels */
388#define FH_SRVC_CHNL (9) 393#define FH_SRVC_CHNL (9)
389#define FH_SRVC_LOWER_BOUND (FH_REGS_LOWER_BOUND + 0x9C8) 394#define FH_SRVC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9C8)
390#define FH_SRVC_UPPER_BOUND (FH_REGS_LOWER_BOUND + 0x9D0) 395#define FH_SRVC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
391#define FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ 396#define FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
392 (FH_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) 397 (FH_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
393 398
394/* TFDB Area - TFDs buffer table */ 399#define FH_TX_CHICKEN_BITS_REG (FH_MEM_LOWER_BOUND + 0xE98)
395#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) 400/* Instruct FH to increment the retry count of a packet when
396#define FH_TFDIB_LOWER_BOUND (FH_REGS_LOWER_BOUND + 0x900) 401 * it is brought from the memory to TX-FIFO
397#define FH_TFDIB_UPPER_BOUND (FH_REGS_LOWER_BOUND + 0x958) 402 */
398#define FH_TFDIB_CTRL0_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) 403#define FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002)
399#define FH_TFDIB_CTRL1_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
400
401/* TCSR: tx_config register values */
402#define FH_RSCSR_FRAME_SIZE_MSK (0x00003FFF) /* bits 0-13 */
403
404#define TFD_QUEUE_SIZE_MAX (256)
405#define TFD_QUEUE_SIZE_BC_DUP (64)
406#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
407 404
408/** 405/**
409 * struct iwl_rb_status - reseve buffer status 406 * struct iwl_rb_status - reseve buffer status
@@ -423,9 +420,10 @@ struct iwl_rb_status {
423} __attribute__ ((packed)); 420} __attribute__ ((packed));
424 421
425 422
426 423#define TFD_QUEUE_SIZE_MAX (256)
424#define TFD_QUEUE_SIZE_BC_DUP (64)
425#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
427#define IWL_TX_DMA_MASK DMA_BIT_MASK(36) 426#define IWL_TX_DMA_MASK DMA_BIT_MASK(36)
428
429#define IWL_NUM_OF_TBS 20 427#define IWL_NUM_OF_TBS 20
430 428
431static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr) 429static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr)
@@ -440,7 +438,7 @@ static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr)
440 * @lo: low [31:0] portion of the dma address of TX buffer 438 * @lo: low [31:0] portion of the dma address of TX buffer
441 * every even is unaligned on 16 bit boundary 439 * every even is unaligned on 16 bit boundary
442 * @hi_n_len 0-3 [35:32] portion of dma 440 * @hi_n_len 0-3 [35:32] portion of dma
443 * 4-16 length of the tx buffer 441 * 4-15 length of the tx buffer
444 */ 442 */
445struct iwl_tfd_tb { 443struct iwl_tfd_tb {
446 __le32 lo; 444 __le32 lo;
@@ -453,7 +451,8 @@ struct iwl_tfd_tb {
453 * Transmit Frame Descriptor (TFD) 451 * Transmit Frame Descriptor (TFD)
454 * 452 *
455 * @ __reserved1[3] reserved 453 * @ __reserved1[3] reserved
456 * @ num_tbs 0-5 number of active tbs 454 * @ num_tbs 0-4 number of active tbs
455 * 5 reserved
457 * 6-7 padding (not used) 456 * 6-7 padding (not used)
458 * @ tbs[20] transmit frame buffer descriptors 457 * @ tbs[20] transmit frame buffer descriptors
459 * @ __pad padding 458 * @ __pad padding
@@ -473,8 +472,6 @@ struct iwl_tfd_tb {
473 * Tx frame, up to 8 KBytes in size. 472 * Tx frame, up to 8 KBytes in size.
474 * 473 *
475 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. 474 * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
476 *
477 * Bit fields in the control dword (val0):
478 */ 475 */
479struct iwl_tfd { 476struct iwl_tfd {
480 u8 __reserved1[3]; 477 u8 __reserved1[3];
@@ -485,6 +482,6 @@ struct iwl_tfd {
485 482
486 483
487/* Keep Warm Size */ 484/* Keep Warm Size */
488#define IWL_KW_SIZE 0x1000 /*4k */ 485#define IWL_KW_SIZE 0x1000 /* 4k */
489 486
490#endif /* !__iwl_fh_h__ */ 487#endif /* !__iwl_fh_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index 8300f3d00a06..0008a35232b0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -36,7 +36,7 @@
36#include "iwl-core.h" 36#include "iwl-core.h"
37 37
38 38
39#define IWL_CMD(x) case x : return #x 39#define IWL_CMD(x) case x: return #x
40 40
41const char *get_cmd_string(u8 cmd) 41const char *get_cmd_string(u8 cmd)
42{ 42{
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index 40e0050b7536..bc10435d96e5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -109,7 +109,7 @@ static inline int __iwl_poll_bit(const char *f, u32 l,
109 int ret = _iwl_poll_bit(priv, addr, bits, mask, timeout); 109 int ret = _iwl_poll_bit(priv, addr, bits, mask, timeout);
110 IWL_DEBUG_IO("poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", 110 IWL_DEBUG_IO("poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n",
111 addr, bits, mask, 111 addr, bits, mask,
112 unlikely(ret == -ETIMEDOUT)?"timeout":"", f, l); 112 unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l);
113 return ret; 113 return ret;
114} 114}
115#define iwl_poll_bit(priv, addr, bits, mask, timeout) \ 115#define iwl_poll_bit(priv, addr, bits, mask, timeout) \
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 876afd4cab9e..8d2b73e194da 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -499,49 +499,6 @@ void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
499} 499}
500EXPORT_SYMBOL(iwl_rx_missed_beacon_notif); 500EXPORT_SYMBOL(iwl_rx_missed_beacon_notif);
501 501
502int iwl_rx_agg_start(struct iwl_priv *priv, const u8 *addr, int tid, u16 ssn)
503{
504 unsigned long flags;
505 int sta_id;
506
507 sta_id = iwl_find_station(priv, addr);
508 if (sta_id == IWL_INVALID_STATION)
509 return -ENXIO;
510
511 spin_lock_irqsave(&priv->sta_lock, flags);
512 priv->stations[sta_id].sta.station_flags_msk = 0;
513 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK;
514 priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid;
515 priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn);
516 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
517 spin_unlock_irqrestore(&priv->sta_lock, flags);
518
519 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
520 CMD_ASYNC);
521}
522EXPORT_SYMBOL(iwl_rx_agg_start);
523
524int iwl_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid)
525{
526 unsigned long flags;
527 int sta_id;
528
529 sta_id = iwl_find_station(priv, addr);
530 if (sta_id == IWL_INVALID_STATION)
531 return -ENXIO;
532
533 spin_lock_irqsave(&priv->sta_lock, flags);
534 priv->stations[sta_id].sta.station_flags_msk = 0;
535 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK;
536 priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid;
537 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
538 spin_unlock_irqrestore(&priv->sta_lock, flags);
539
540 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
541 CMD_ASYNC);
542}
543EXPORT_SYMBOL(iwl_rx_agg_stop);
544
545 502
546/* Calculate noise level, based on measurements during network silence just 503/* Calculate noise level, based on measurements during network silence just
547 * before arriving beacon. This measurement can be done only if we know 504 * before arriving beacon. This measurement can be done only if we know
@@ -1017,38 +974,6 @@ static inline int iwl_calc_rssi(struct iwl_priv *priv,
1017} 974}
1018 975
1019 976
1020static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
1021{
1022 unsigned long flags;
1023
1024 spin_lock_irqsave(&priv->sta_lock, flags);
1025 priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK;
1026 priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
1027 priv->stations[sta_id].sta.sta.modify_mask = 0;
1028 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1029 spin_unlock_irqrestore(&priv->sta_lock, flags);
1030
1031 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1032}
1033
1034static void iwl_update_ps_mode(struct iwl_priv *priv, u16 ps_bit, u8 *addr)
1035{
1036 /* FIXME: need locking over ps_status ??? */
1037 u8 sta_id = iwl_find_station(priv, addr);
1038
1039 if (sta_id != IWL_INVALID_STATION) {
1040 u8 sta_awake = priv->stations[sta_id].
1041 ps_status == STA_PS_STATUS_WAKE;
1042
1043 if (sta_awake && ps_bit)
1044 priv->stations[sta_id].ps_status = STA_PS_STATUS_SLEEP;
1045 else if (!sta_awake && !ps_bit) {
1046 iwl_sta_modify_ps_wake(priv, sta_id);
1047 priv->stations[sta_id].ps_status = STA_PS_STATUS_WAKE;
1048 }
1049 }
1050}
1051
1052/* This is necessary only for a number of statistics, see the caller. */ 977/* This is necessary only for a number of statistics, see the caller. */
1053static int iwl_is_network_packet(struct iwl_priv *priv, 978static int iwl_is_network_packet(struct iwl_priv *priv,
1054 struct ieee80211_hdr *header) 979 struct ieee80211_hdr *header)
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 0c5f1221b8f3..f86a8ca2aa3b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -132,7 +132,7 @@ static int iwl_add_sta_callback(struct iwl_priv *priv,
132 return 1; 132 return 1;
133} 133}
134 134
135int iwl_send_add_sta(struct iwl_priv *priv, 135static int iwl_send_add_sta(struct iwl_priv *priv,
136 struct iwl_addsta_cmd *sta, u8 flags) 136 struct iwl_addsta_cmd *sta, u8 flags)
137{ 137{
138 struct iwl_rx_packet *res = NULL; 138 struct iwl_rx_packet *res = NULL;
@@ -180,7 +180,6 @@ int iwl_send_add_sta(struct iwl_priv *priv,
180 180
181 return ret; 181 return ret;
182} 182}
183EXPORT_SYMBOL(iwl_send_add_sta);
184 183
185static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, 184static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
186 struct ieee80211_sta_ht_cap *sta_ht_inf) 185 struct ieee80211_sta_ht_cap *sta_ht_inf)
@@ -464,6 +463,29 @@ out:
464} 463}
465EXPORT_SYMBOL(iwl_remove_station); 464EXPORT_SYMBOL(iwl_remove_station);
466 465
466/**
467 * iwl_clear_stations_table - Clear the driver's station table
468 *
469 * NOTE: This does not clear or otherwise alter the device's station table.
470 */
471void iwl_clear_stations_table(struct iwl_priv *priv)
472{
473 unsigned long flags;
474
475 spin_lock_irqsave(&priv->sta_lock, flags);
476
477 if (iwl_is_alive(priv) &&
478 !test_bit(STATUS_EXIT_PENDING, &priv->status) &&
479 iwl_send_cmd_pdu_async(priv, REPLY_REMOVE_ALL_STA, 0, NULL, NULL))
480 IWL_ERROR("Couldn't clear the station table\n");
481
482 priv->num_stations = 0;
483 memset(priv->stations, 0, sizeof(priv->stations));
484
485 spin_unlock_irqrestore(&priv->sta_lock, flags);
486}
487EXPORT_SYMBOL(iwl_clear_stations_table);
488
467static int iwl_get_free_ucode_key_index(struct iwl_priv *priv) 489static int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
468{ 490{
469 int i; 491 int i;
@@ -703,6 +725,55 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
703 return ret; 725 return ret;
704} 726}
705 727
728void iwl_update_tkip_key(struct iwl_priv *priv,
729 struct ieee80211_key_conf *keyconf,
730 const u8 *addr, u32 iv32, u16 *phase1key)
731{
732 u8 sta_id = IWL_INVALID_STATION;
733 unsigned long flags;
734 __le16 key_flags = 0;
735 int i;
736 DECLARE_MAC_BUF(mac);
737
738 sta_id = iwl_find_station(priv, addr);
739 if (sta_id == IWL_INVALID_STATION) {
740 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n",
741 addr);
742 return;
743 }
744
745 if (iwl_scan_cancel(priv)) {
746 /* cancel scan failed, just live w/ bad key and rely
747 briefly on SW decryption */
748 return;
749 }
750
751 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
752 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
753 key_flags &= ~STA_KEY_FLG_INVALID;
754
755 if (sta_id == priv->hw_params.bcast_sta_id)
756 key_flags |= STA_KEY_MULTICAST_MSK;
757
758 spin_lock_irqsave(&priv->sta_lock, flags);
759
760 priv->stations[sta_id].sta.key.key_flags = key_flags;
761 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
762
763 for (i = 0; i < 5; i++)
764 priv->stations[sta_id].sta.key.tkip_rx_ttak[i] =
765 cpu_to_le16(phase1key[i]);
766
767 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
768 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
769
770 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
771
772 spin_unlock_irqrestore(&priv->sta_lock, flags);
773
774}
775EXPORT_SYMBOL(iwl_update_tkip_key);
776
706int iwl_remove_dynamic_key(struct iwl_priv *priv, 777int iwl_remove_dynamic_key(struct iwl_priv *priv,
707 struct ieee80211_key_conf *keyconf, 778 struct ieee80211_key_conf *keyconf,
708 u8 sta_id) 779 u8 sta_id)
@@ -989,9 +1060,9 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
989EXPORT_SYMBOL(iwl_get_sta_id); 1060EXPORT_SYMBOL(iwl_get_sta_id);
990 1061
991/** 1062/**
992 * iwl_sta_modify_enable_tid_tx - Enable Tx for this TID in station table 1063 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
993 */ 1064 */
994void iwl_sta_modify_enable_tid_tx(struct iwl_priv *priv, int sta_id, int tid) 1065void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid)
995{ 1066{
996 unsigned long flags; 1067 unsigned long flags;
997 1068
@@ -1004,5 +1075,81 @@ void iwl_sta_modify_enable_tid_tx(struct iwl_priv *priv, int sta_id, int tid)
1004 1075
1005 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 1076 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1006} 1077}
1007EXPORT_SYMBOL(iwl_sta_modify_enable_tid_tx); 1078EXPORT_SYMBOL(iwl_sta_tx_modify_enable_tid);
1079
1080int iwl_sta_rx_agg_start(struct iwl_priv *priv,
1081 const u8 *addr, int tid, u16 ssn)
1082{
1083 unsigned long flags;
1084 int sta_id;
1085
1086 sta_id = iwl_find_station(priv, addr);
1087 if (sta_id == IWL_INVALID_STATION)
1088 return -ENXIO;
1089
1090 spin_lock_irqsave(&priv->sta_lock, flags);
1091 priv->stations[sta_id].sta.station_flags_msk = 0;
1092 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK;
1093 priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid;
1094 priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn);
1095 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1096 spin_unlock_irqrestore(&priv->sta_lock, flags);
1097
1098 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
1099 CMD_ASYNC);
1100}
1101EXPORT_SYMBOL(iwl_sta_rx_agg_start);
1102
1103int iwl_sta_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid)
1104{
1105 unsigned long flags;
1106 int sta_id;
1107
1108 sta_id = iwl_find_station(priv, addr);
1109 if (sta_id == IWL_INVALID_STATION)
1110 return -ENXIO;
1111
1112 spin_lock_irqsave(&priv->sta_lock, flags);
1113 priv->stations[sta_id].sta.station_flags_msk = 0;
1114 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK;
1115 priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid;
1116 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1117 spin_unlock_irqrestore(&priv->sta_lock, flags);
1118
1119 return iwl_send_add_sta(priv, &priv->stations[sta_id].sta,
1120 CMD_ASYNC);
1121}
1122EXPORT_SYMBOL(iwl_sta_rx_agg_stop);
1123
1124static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id)
1125{
1126 unsigned long flags;
1127
1128 spin_lock_irqsave(&priv->sta_lock, flags);
1129 priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK;
1130 priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK;
1131 priv->stations[sta_id].sta.sta.modify_mask = 0;
1132 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
1133 spin_unlock_irqrestore(&priv->sta_lock, flags);
1134
1135 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
1136}
1137
1138void iwl_update_ps_mode(struct iwl_priv *priv, u16 ps_bit, u8 *addr)
1139{
1140 /* FIXME: need locking over ps_status ??? */
1141 u8 sta_id = iwl_find_station(priv, addr);
1142
1143 if (sta_id != IWL_INVALID_STATION) {
1144 u8 sta_awake = priv->stations[sta_id].
1145 ps_status == STA_PS_STATUS_WAKE;
1146
1147 if (sta_awake && ps_bit)
1148 priv->stations[sta_id].ps_status = STA_PS_STATUS_SLEEP;
1149 else if (!sta_awake && !ps_bit) {
1150 iwl_sta_modify_ps_wake(priv, sta_id);
1151 priv->stations[sta_id].ps_status = STA_PS_STATUS_WAKE;
1152 }
1153 }
1154}
1008 1155
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index 221b93e670a6..7b98ea4dfbc0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -47,9 +47,21 @@ int iwl_set_dynamic_key(struct iwl_priv *priv,
47 struct ieee80211_key_conf *key, u8 sta_id); 47 struct ieee80211_key_conf *key, u8 sta_id);
48int iwl_remove_dynamic_key(struct iwl_priv *priv, 48int iwl_remove_dynamic_key(struct iwl_priv *priv,
49 struct ieee80211_key_conf *key, u8 sta_id); 49 struct ieee80211_key_conf *key, u8 sta_id);
50void iwl_update_tkip_key(struct iwl_priv *priv,
51 struct ieee80211_key_conf *keyconf,
52 const u8 *addr, u32 iv32, u16 *phase1key);
53
50int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap); 54int iwl_rxon_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap);
51int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap); 55int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap);
56void iwl_clear_stations_table(struct iwl_priv *priv);
52int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); 57int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
53void iwl_sta_modify_enable_tid_tx(struct iwl_priv *priv, int sta_id, int tid);
54int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr); 58int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
59u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr,
60 int is_ap, u8 flags,
61 struct ieee80211_sta_ht_cap *ht_info);
62void iwl_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid);
63int iwl_sta_rx_agg_start(struct iwl_priv *priv,
64 const u8 *addr, int tid, u16 ssn);
65int iwl_sta_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid);
66void iwl_update_ps_mode(struct iwl_priv *priv, u16 ps_bit, u8 *addr);
55#endif /* __iwl_sta_h__ */ 67#endif /* __iwl_sta_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 166f0001e01d..e045dfeaa1fe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -449,11 +449,6 @@ static int iwl_hw_tx_queue_init(struct iwl_priv *priv,
449 iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), 449 iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id),
450 txq->q.dma_addr >> 8); 450 txq->q.dma_addr >> 8);
451 451
452 /* Enable DMA channel, using same id as for TFD queue */
453 iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(txq_id),
454 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
455 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE);
456
457 iwl_release_nic_access(priv); 452 iwl_release_nic_access(priv);
458 spin_unlock_irqrestore(&priv->lock, flags); 453 spin_unlock_irqrestore(&priv->lock, flags);
459 454
@@ -587,8 +582,6 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
587 iwl_release_nic_access(priv); 582 iwl_release_nic_access(priv);
588 spin_unlock_irqrestore(&priv->lock, flags); 583 spin_unlock_irqrestore(&priv->lock, flags);
589 584
590
591
592 /* Alloc and init all Tx queues, including the command queue (#4) */ 585 /* Alloc and init all Tx queues, including the command queue (#4) */
593 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { 586 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
594 slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ? 587 slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ?
@@ -618,11 +611,9 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
618 */ 611 */
619void iwl_txq_ctx_stop(struct iwl_priv *priv) 612void iwl_txq_ctx_stop(struct iwl_priv *priv)
620{ 613{
621
622 int txq_id; 614 int txq_id;
623 unsigned long flags; 615 unsigned long flags;
624 616
625
626 /* Turn off all Tx DMA fifos */ 617 /* Turn off all Tx DMA fifos */
627 spin_lock_irqsave(&priv->lock, flags); 618 spin_lock_irqsave(&priv->lock, flags);
628 if (iwl_grab_nic_access(priv)) { 619 if (iwl_grab_nic_access(priv)) {
@@ -1498,7 +1489,7 @@ static int iwl_tx_status_reply_compressed_ba(struct iwl_priv *priv,
1498 ack = bitmap & (1ULL << i); 1489 ack = bitmap & (1ULL << i);
1499 successes += !!ack; 1490 successes += !!ack;
1500 IWL_DEBUG_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", 1491 IWL_DEBUG_TX_REPLY("%s ON i=%d idx=%d raw=%d\n",
1501 ack? "ACK":"NACK", i, (agg->start_idx + i) & 0xff, 1492 ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff,
1502 agg->start_idx + i); 1493 agg->start_idx + i);
1503 } 1494 }
1504 1495
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 3344841b7662..69fda64c6503 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -519,7 +519,7 @@ static inline int iwl3945_is_ready_rf(struct iwl3945_priv *priv)
519 519
520/*************** HOST COMMAND QUEUE FUNCTIONS *****/ 520/*************** HOST COMMAND QUEUE FUNCTIONS *****/
521 521
522#define IWL_CMD(x) case x : return #x 522#define IWL_CMD(x) case x: return #x
523 523
524static const char *get_cmd_string(u8 cmd) 524static const char *get_cmd_string(u8 cmd)
525{ 525{
@@ -1425,9 +1425,9 @@ static u8 iwl3945_rate_get_lowest_plcp(struct iwl3945_priv *priv)
1425 1425
1426 /* Set rate mask*/ 1426 /* Set rate mask*/
1427 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) 1427 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
1428 rate_mask = priv->active_rate_basic & 0xF; 1428 rate_mask = priv->active_rate_basic & IWL_CCK_RATES_MASK;
1429 else 1429 else
1430 rate_mask = priv->active_rate_basic & 0xFF0; 1430 rate_mask = priv->active_rate_basic & IWL_OFDM_RATES_MASK;
1431 1431
1432 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID; 1432 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID;
1433 i = iwl3945_rates[i].next_ieee) { 1433 i = iwl3945_rates[i].next_ieee) {
@@ -4320,7 +4320,7 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
4320 4320
4321 IWL_DEBUG(IWL_DL_INFO | IWL_DL_RF_KILL | IWL_DL_ISR, 4321 IWL_DEBUG(IWL_DL_INFO | IWL_DL_RF_KILL | IWL_DL_ISR,
4322 "RF_KILL bit toggled to %s.\n", 4322 "RF_KILL bit toggled to %s.\n",
4323 hw_rf_kill ? "disable radio":"enable radio"); 4323 hw_rf_kill ? "disable radio" : "enable radio");
4324 4324
4325 /* Queue restart only if RF_KILL switch was set to "kill" 4325 /* Queue restart only if RF_KILL switch was set to "kill"
4326 * when we loaded driver, and is now set to "enable". 4326 * when we loaded driver, and is now set to "enable".
@@ -5996,24 +5996,6 @@ static void iwl3945_bg_rf_kill(struct work_struct *work)
5996 iwl3945_rfkill_set_hw_state(priv); 5996 iwl3945_rfkill_set_hw_state(priv);
5997} 5997}
5998 5998
5999static void iwl3945_bg_set_monitor(struct work_struct *work)
6000{
6001 struct iwl3945_priv *priv = container_of(work,
6002 struct iwl3945_priv, set_monitor);
6003
6004 IWL_DEBUG(IWL_DL_STATE, "setting monitor mode\n");
6005
6006 mutex_lock(&priv->mutex);
6007
6008 if (!iwl3945_is_ready(priv))
6009 IWL_DEBUG(IWL_DL_STATE, "leave - not ready\n");
6010 else
6011 if (iwl3945_set_mode(priv, NL80211_IFTYPE_MONITOR) != 0)
6012 IWL_ERROR("iwl3945_set_mode() failed\n");
6013
6014 mutex_unlock(&priv->mutex);
6015}
6016
6017#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 5999#define IWL_SCAN_CHECK_WATCHDOG (7 * HZ)
6018 6000
6019static void iwl3945_bg_scan_check(struct work_struct *data) 6001static void iwl3945_bg_scan_check(struct work_struct *data)
@@ -6339,10 +6321,7 @@ static void iwl3945_post_associate(struct iwl3945_priv *priv)
6339 6321
6340 case NL80211_IFTYPE_ADHOC: 6322 case NL80211_IFTYPE_ADHOC:
6341 6323
6342 /* clear out the station table */ 6324 priv->assoc_id = 1;
6343 iwl3945_clear_stations_table(priv);
6344
6345 iwl3945_add_station(priv, iwl3945_broadcast_addr, 0, 0);
6346 iwl3945_add_station(priv, priv->bssid, 0, 0); 6325 iwl3945_add_station(priv, priv->bssid, 0, 0);
6347 iwl3945_sync_sta(priv, IWL_STA_ID, 6326 iwl3945_sync_sta(priv, IWL_STA_ID,
6348 (priv->band == IEEE80211_BAND_5GHZ) ? 6327 (priv->band == IEEE80211_BAND_5GHZ) ?
@@ -6830,16 +6809,43 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw,
6830 int mc_count, struct dev_addr_list *mc_list) 6809 int mc_count, struct dev_addr_list *mc_list)
6831{ 6810{
6832 struct iwl3945_priv *priv = hw->priv; 6811 struct iwl3945_priv *priv = hw->priv;
6812 __le32 *filter_flags = &priv->staging_rxon.filter_flags;
6813
6814 IWL_DEBUG_MAC80211("Enter: changed: 0x%x, total: 0x%x\n",
6815 changed_flags, *total_flags);
6833 6816
6834 if (changed_flags & (*total_flags) & FIF_OTHER_BSS) { 6817 if (changed_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) {
6835 IWL_DEBUG_MAC80211("Enter: type %d (0x%x, 0x%x)\n", 6818 if (*total_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS))
6836 NL80211_IFTYPE_MONITOR, 6819 *filter_flags |= RXON_FILTER_PROMISC_MSK;
6837 changed_flags, *total_flags); 6820 else
6838 /* queue work 'cuz mac80211 is holding a lock which 6821 *filter_flags &= ~RXON_FILTER_PROMISC_MSK;
6839 * prevents us from issuing (synchronous) f/w cmds */ 6822 }
6840 queue_work(priv->workqueue, &priv->set_monitor); 6823 if (changed_flags & FIF_ALLMULTI) {
6824 if (*total_flags & FIF_ALLMULTI)
6825 *filter_flags |= RXON_FILTER_ACCEPT_GRP_MSK;
6826 else
6827 *filter_flags &= ~RXON_FILTER_ACCEPT_GRP_MSK;
6841 } 6828 }
6842 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | 6829 if (changed_flags & FIF_CONTROL) {
6830 if (*total_flags & FIF_CONTROL)
6831 *filter_flags |= RXON_FILTER_CTL2HOST_MSK;
6832 else
6833 *filter_flags &= ~RXON_FILTER_CTL2HOST_MSK;
6834 }
6835 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
6836 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
6837 *filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
6838 else
6839 *filter_flags &= ~RXON_FILTER_BCON_AWARE_MSK;
6840 }
6841
6842 /* We avoid iwl_commit_rxon here to commit the new filter flags
6843 * since mac80211 will call ieee80211_hw_config immediately.
6844 * (mc_list is not supported at this time). Otherwise, we need to
6845 * queue a background iwl_commit_rxon work.
6846 */
6847
6848 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
6843 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 6849 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
6844} 6850}
6845 6851
@@ -7715,7 +7721,6 @@ static void iwl3945_setup_deferred_work(struct iwl3945_priv *priv)
7715 INIT_WORK(&priv->abort_scan, iwl3945_bg_abort_scan); 7721 INIT_WORK(&priv->abort_scan, iwl3945_bg_abort_scan);
7716 INIT_WORK(&priv->rf_kill, iwl3945_bg_rf_kill); 7722 INIT_WORK(&priv->rf_kill, iwl3945_bg_rf_kill);
7717 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update); 7723 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update);
7718 INIT_WORK(&priv->set_monitor, iwl3945_bg_set_monitor);
7719 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); 7724 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start);
7720 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); 7725 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start);
7721 INIT_DELAYED_WORK(&priv->scan_check, iwl3945_bg_scan_check); 7726 INIT_DELAYED_WORK(&priv->scan_check, iwl3945_bg_scan_check);
@@ -7787,6 +7792,10 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7787 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data); 7792 struct iwl_3945_cfg *cfg = (struct iwl_3945_cfg *)(ent->driver_data);
7788 unsigned long flags; 7793 unsigned long flags;
7789 7794
7795 /***********************
7796 * 1. Allocating HW data
7797 * ********************/
7798
7790 /* Disabling hardware scan means that mac80211 will perform scans 7799 /* Disabling hardware scan means that mac80211 will perform scans
7791 * "the hard way", rather than using device's scan. */ 7800 * "the hard way", rather than using device's scan. */
7792 if (iwl3945_param_disable_hw_scan) { 7801 if (iwl3945_param_disable_hw_scan) {
@@ -7810,27 +7819,24 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7810 err = -ENOMEM; 7819 err = -ENOMEM;
7811 goto out; 7820 goto out;
7812 } 7821 }
7813 SET_IEEE80211_DEV(hw, &pdev->dev);
7814 7822
7815 hw->rate_control_algorithm = "iwl-3945-rs"; 7823 SET_IEEE80211_DEV(hw, &pdev->dev);
7816 hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
7817 7824
7818 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
7819 priv = hw->priv; 7825 priv = hw->priv;
7820 priv->hw = hw; 7826 priv->hw = hw;
7821
7822 priv->pci_dev = pdev; 7827 priv->pci_dev = pdev;
7823 priv->cfg = cfg; 7828 priv->cfg = cfg;
7824 7829
7830 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
7831 hw->rate_control_algorithm = "iwl-3945-rs";
7832 hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
7833
7825 /* Select antenna (may be helpful if only one antenna is connected) */ 7834 /* Select antenna (may be helpful if only one antenna is connected) */
7826 priv->antenna = (enum iwl3945_antenna)iwl3945_param_antenna; 7835 priv->antenna = (enum iwl3945_antenna)iwl3945_param_antenna;
7827#ifdef CONFIG_IWL3945_DEBUG 7836#ifdef CONFIG_IWL3945_DEBUG
7828 iwl3945_debug_level = iwl3945_param_debug; 7837 iwl3945_debug_level = iwl3945_param_debug;
7829 atomic_set(&priv->restrict_refcnt, 0); 7838 atomic_set(&priv->restrict_refcnt, 0);
7830#endif 7839#endif
7831 priv->retry_rate = 1;
7832
7833 priv->ibss_beacon = NULL;
7834 7840
7835 /* Tell mac80211 our characteristics */ 7841 /* Tell mac80211 our characteristics */
7836 hw->flags = IEEE80211_HW_SIGNAL_DBM | 7842 hw->flags = IEEE80211_HW_SIGNAL_DBM |
@@ -7841,17 +7847,14 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7841 BIT(NL80211_IFTYPE_STATION) | 7847 BIT(NL80211_IFTYPE_STATION) |
7842 BIT(NL80211_IFTYPE_ADHOC); 7848 BIT(NL80211_IFTYPE_ADHOC);
7843 7849
7850 hw->wiphy->fw_handles_regulatory = true;
7851
7844 /* 4 EDCA QOS priorities */ 7852 /* 4 EDCA QOS priorities */
7845 hw->queues = 4; 7853 hw->queues = 4;
7846 7854
7847 spin_lock_init(&priv->lock); 7855 /***************************
7848 spin_lock_init(&priv->power_data.lock); 7856 * 2. Initializing PCI bus
7849 spin_lock_init(&priv->sta_lock); 7857 * *************************/
7850 spin_lock_init(&priv->hcmd_lock);
7851
7852 INIT_LIST_HEAD(&priv->free_frames);
7853
7854 mutex_init(&priv->mutex);
7855 if (pci_enable_device(pdev)) { 7858 if (pci_enable_device(pdev)) {
7856 err = -ENODEV; 7859 err = -ENODEV;
7857 goto out_ieee80211_free_hw; 7860 goto out_ieee80211_free_hw;
@@ -7859,14 +7862,6 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7859 7862
7860 pci_set_master(pdev); 7863 pci_set_master(pdev);
7861 7864
7862 /* Clear the driver's (not device's) station table */
7863 iwl3945_clear_stations_table(priv);
7864
7865 priv->data_retry_limit = -1;
7866 priv->ieee_channels = NULL;
7867 priv->ieee_rates = NULL;
7868 priv->band = IEEE80211_BAND_2GHZ;
7869
7870 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 7865 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
7871 if (!err) 7866 if (!err)
7872 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 7867 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
@@ -7880,10 +7875,9 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7880 if (err) 7875 if (err)
7881 goto out_pci_disable_device; 7876 goto out_pci_disable_device;
7882 7877
7883 /* We disable the RETRY_TIMEOUT register (0x41) to keep 7878 /***********************
7884 * PCI Tx retries from interfering with C3 CPU state */ 7879 * 3. Read REV Register
7885 pci_write_config_byte(pdev, 0x41, 0x00); 7880 * ********************/
7886
7887 priv->hw_base = pci_iomap(pdev, 0, 0); 7881 priv->hw_base = pci_iomap(pdev, 0, 0);
7888 if (!priv->hw_base) { 7882 if (!priv->hw_base) {
7889 err = -ENODEV; 7883 err = -ENODEV;
@@ -7894,25 +7888,70 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7894 (unsigned long long) pci_resource_len(pdev, 0)); 7888 (unsigned long long) pci_resource_len(pdev, 0));
7895 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base); 7889 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base);
7896 7890
7897 /* Initialize module parameter values here */ 7891 /* We disable the RETRY_TIMEOUT register (0x41) to keep
7892 * PCI Tx retries from interfering with C3 CPU state */
7893 pci_write_config_byte(pdev, 0x41, 0x00);
7898 7894
7899 /* Disable radio (SW RF KILL) via parameter when loading driver */ 7895 /* nic init */
7900 if (iwl3945_param_disable) { 7896 iwl3945_set_bit(priv, CSR_GIO_CHICKEN_BITS,
7901 set_bit(STATUS_RF_KILL_SW, &priv->status); 7897 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
7902 IWL_DEBUG_INFO("Radio disabled.\n");
7903 }
7904 7898
7905 priv->iw_mode = NL80211_IFTYPE_STATION; 7899 iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
7900 err = iwl3945_poll_bit(priv, CSR_GP_CNTRL,
7901 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
7902 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
7903 if (err < 0) {
7904 IWL_DEBUG_INFO("Failed to init the card\n");
7905 goto out_remove_sysfs;
7906 }
7906 7907
7907 printk(KERN_INFO DRV_NAME 7908 /***********************
7908 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name); 7909 * 4. Read EEPROM
7910 * ********************/
7911 /* Read the EEPROM */
7912 err = iwl3945_eeprom_init(priv);
7913 if (err) {
7914 IWL_ERROR("Unable to init EEPROM\n");
7915 goto out_remove_sysfs;
7916 }
7917 /* MAC Address location in EEPROM same for 3945/4965 */
7918 get_eeprom_mac(priv, priv->mac_addr);
7919 IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr);
7920 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
7909 7921
7922 /***********************
7923 * 5. Setup HW Constants
7924 * ********************/
7910 /* Device-specific setup */ 7925 /* Device-specific setup */
7911 if (iwl3945_hw_set_hw_setting(priv)) { 7926 if (iwl3945_hw_set_hw_setting(priv)) {
7912 IWL_ERROR("failed to set hw settings\n"); 7927 IWL_ERROR("failed to set hw settings\n");
7913 goto out_iounmap; 7928 goto out_iounmap;
7914 } 7929 }
7915 7930
7931 /***********************
7932 * 6. Setup priv
7933 * ********************/
7934 priv->retry_rate = 1;
7935 priv->ibss_beacon = NULL;
7936
7937 spin_lock_init(&priv->lock);
7938 spin_lock_init(&priv->power_data.lock);
7939 spin_lock_init(&priv->sta_lock);
7940 spin_lock_init(&priv->hcmd_lock);
7941
7942 INIT_LIST_HEAD(&priv->free_frames);
7943 mutex_init(&priv->mutex);
7944
7945 /* Clear the driver's (not device's) station table */
7946 iwl3945_clear_stations_table(priv);
7947
7948 priv->data_retry_limit = -1;
7949 priv->ieee_channels = NULL;
7950 priv->ieee_rates = NULL;
7951 priv->band = IEEE80211_BAND_2GHZ;
7952
7953 priv->iw_mode = NL80211_IFTYPE_STATION;
7954
7916 if (iwl3945_param_qos_enable) 7955 if (iwl3945_param_qos_enable)
7917 priv->qos_data.qos_enable = 1; 7956 priv->qos_data.qos_enable = 1;
7918 7957
@@ -7921,70 +7960,76 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7921 priv->qos_data.qos_active = 0; 7960 priv->qos_data.qos_active = 0;
7922 priv->qos_data.qos_cap.val = 0; 7961 priv->qos_data.qos_cap.val = 0;
7923 7962
7924 iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
7925 iwl3945_setup_deferred_work(priv);
7926 iwl3945_setup_rx_handlers(priv);
7927 7963
7928 priv->rates_mask = IWL_RATES_MASK; 7964 priv->rates_mask = IWL_RATES_MASK;
7929 /* If power management is turned on, default to AC mode */ 7965 /* If power management is turned on, default to AC mode */
7930 priv->power_mode = IWL_POWER_AC; 7966 priv->power_mode = IWL_POWER_AC;
7931 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER; 7967 priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
7932 7968
7933 spin_lock_irqsave(&priv->lock, flags); 7969 err = iwl3945_init_channel_map(priv);
7934 iwl3945_disable_interrupts(priv);
7935 spin_unlock_irqrestore(&priv->lock, flags);
7936
7937 err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group);
7938 if (err) { 7970 if (err) {
7939 IWL_ERROR("failed to create sysfs device attributes\n"); 7971 IWL_ERROR("initializing regulatory failed: %d\n", err);
7940 goto out_release_irq; 7972 goto out_release_irq;
7941 } 7973 }
7942 7974
7943 /* nic init */ 7975 err = iwl3945_init_geos(priv);
7944 iwl3945_set_bit(priv, CSR_GIO_CHICKEN_BITS,
7945 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
7946
7947 iwl3945_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
7948 err = iwl3945_poll_bit(priv, CSR_GP_CNTRL,
7949 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
7950 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
7951 if (err < 0) {
7952 IWL_DEBUG_INFO("Failed to init the card\n");
7953 goto out_remove_sysfs;
7954 }
7955 /* Read the EEPROM */
7956 err = iwl3945_eeprom_init(priv);
7957 if (err) { 7976 if (err) {
7958 IWL_ERROR("Unable to init EEPROM\n"); 7977 IWL_ERROR("initializing geos failed: %d\n", err);
7959 goto out_remove_sysfs; 7978 goto out_free_channel_map;
7960 } 7979 }
7961 /* MAC Address location in EEPROM same for 3945/4965 */
7962 get_eeprom_mac(priv, priv->mac_addr);
7963 IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr);
7964 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
7965 7980
7966 err = iwl3945_init_channel_map(priv); 7981 printk(KERN_INFO DRV_NAME
7967 if (err) { 7982 ": Detected Intel Wireless WiFi Link %s\n", priv->cfg->name);
7968 IWL_ERROR("initializing regulatory failed: %d\n", err); 7983
7969 goto out_remove_sysfs; 7984 /***********************************
7985 * 7. Initialize Module Parameters
7986 * **********************************/
7987
7988 /* Initialize module parameter values here */
7989 /* Disable radio (SW RF KILL) via parameter when loading driver */
7990 if (iwl3945_param_disable) {
7991 set_bit(STATUS_RF_KILL_SW, &priv->status);
7992 IWL_DEBUG_INFO("Radio disabled.\n");
7970 } 7993 }
7971 7994
7972 err = iwl3945_init_geos(priv); 7995
7996 /***********************
7997 * 8. Setup Services
7998 * ********************/
7999
8000 spin_lock_irqsave(&priv->lock, flags);
8001 iwl3945_disable_interrupts(priv);
8002 spin_unlock_irqrestore(&priv->lock, flags);
8003
8004 err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group);
7973 if (err) { 8005 if (err) {
7974 IWL_ERROR("initializing geos failed: %d\n", err); 8006 IWL_ERROR("failed to create sysfs device attributes\n");
7975 goto out_free_channel_map; 8007 goto out_free_geos;
7976 } 8008 }
7977 8009
8010 iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6);
8011 iwl3945_setup_deferred_work(priv);
8012 iwl3945_setup_rx_handlers(priv);
8013
8014 /***********************
8015 * 9. Conclude
8016 * ********************/
8017 pci_save_state(pdev);
8018 pci_disable_device(pdev);
8019
8020 /*********************************
8021 * 10. Setup and Register mac80211
8022 * *******************************/
8023
7978 err = ieee80211_register_hw(priv->hw); 8024 err = ieee80211_register_hw(priv->hw);
7979 if (err) { 8025 if (err) {
7980 IWL_ERROR("Failed to register network device (error %d)\n", err); 8026 IWL_ERROR("Failed to register network device (error %d)\n", err);
7981 goto out_free_geos; 8027 goto out_remove_sysfs;
7982 } 8028 }
7983 8029
7984 priv->hw->conf.beacon_int = 100; 8030 priv->hw->conf.beacon_int = 100;
7985 priv->mac80211_registered = 1; 8031 priv->mac80211_registered = 1;
7986 pci_save_state(pdev); 8032
7987 pci_disable_device(pdev);
7988 8033
7989 err = iwl3945_rfkill_init(priv); 8034 err = iwl3945_rfkill_init(priv);
7990 if (err) 8035 if (err)
@@ -7993,12 +8038,13 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7993 8038
7994 return 0; 8039 return 0;
7995 8040
8041 out_remove_sysfs:
8042 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
7996 out_free_geos: 8043 out_free_geos:
7997 iwl3945_free_geos(priv); 8044 iwl3945_free_geos(priv);
7998 out_free_channel_map: 8045 out_free_channel_map:
7999 iwl3945_free_channel_map(priv); 8046 iwl3945_free_channel_map(priv);
8000 out_remove_sysfs: 8047
8001 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
8002 8048
8003 out_release_irq: 8049 out_release_irq:
8004 destroy_workqueue(priv->workqueue); 8050 destroy_workqueue(priv->workqueue);