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-1000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-hw.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c86
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c57
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000-hw.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c25
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000-hw.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c156
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-calib.c18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c112
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c422
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c294
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tt.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-tx.c137
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c95
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c546
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h470
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c747
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h65
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c106
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h165
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-prph.h9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c57
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c183
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h64
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c34
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c175
32 files changed, 3153 insertions, 950 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 3bf5a30828be..674fb93ae17f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -130,7 +130,7 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
130 sizeof(struct iwlagn_scd_bc_tbl); 130 sizeof(struct iwlagn_scd_bc_tbl);
131 priv->hw_params.tfd_size = sizeof(struct iwl_tfd); 131 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
132 priv->hw_params.max_stations = IWLAGN_STATION_COUNT; 132 priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
133 priv->hw_params.bcast_sta_id = IWLAGN_BROADCAST_ID; 133 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
134 134
135 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE; 135 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
136 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE; 136 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
@@ -217,7 +217,7 @@ static struct iwl_lib_ops iwl1000_lib = {
217 .set_ct_kill = iwl1000_set_ct_threshold, 217 .set_ct_kill = iwl1000_set_ct_threshold,
218 }, 218 },
219 .manage_ibss_station = iwlagn_manage_ibss_station, 219 .manage_ibss_station = iwlagn_manage_ibss_station,
220 .update_bcast_station = iwl_update_bcast_station, 220 .update_bcast_stations = iwl_update_bcast_stations,
221 .debugfs_ops = { 221 .debugfs_ops = {
222 .rx_stats_read = iwl_ucode_rx_stats_read, 222 .rx_stats_read = iwl_ucode_rx_stats_read,
223 .tx_stats_read = iwl_ucode_tx_stats_read, 223 .tx_stats_read = iwl_ucode_tx_stats_read,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 7c731a793632..65b5834da28c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -62,7 +62,7 @@
62 *****************************************************************************/ 62 *****************************************************************************/
63/* 63/*
64 * Please use this file (iwl-3945-hw.h) only for hardware-related definitions. 64 * Please use this file (iwl-3945-hw.h) only for hardware-related definitions.
65 * Please use iwl-3945-commands.h for uCode API definitions. 65 * Please use iwl-commands.h for uCode API definitions.
66 * Please use iwl-3945.h for driver implementation definitions. 66 * Please use iwl-3945.h for driver implementation definitions.
67 */ 67 */
68 68
@@ -226,6 +226,7 @@ struct iwl3945_eeprom {
226 226
227/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */ 227/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */
228#define IWL39_NUM_QUEUES 5 228#define IWL39_NUM_QUEUES 5
229#define IWL39_CMD_QUEUE_NUM 4
229 230
230#define IWL_DEFAULT_TX_RETRY 15 231#define IWL_DEFAULT_TX_RETRY 15
231 232
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 8e84a08ff951..d707f5bb1a8b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -343,7 +343,7 @@ void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 s
343 int i; 343 int i;
344 344
345 IWL_DEBUG_INFO(priv, "enter\n"); 345 IWL_DEBUG_INFO(priv, "enter\n");
346 if (sta_id == priv->hw_params.bcast_sta_id) 346 if (sta_id == priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id)
347 goto out; 347 goto out;
348 348
349 psta = (struct iwl3945_sta_priv *) sta->drv_priv; 349 psta = (struct iwl3945_sta_priv *) sta->drv_priv;
@@ -932,7 +932,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
932 932
933 rcu_read_lock(); 933 rcu_read_lock();
934 934
935 sta = ieee80211_find_sta(priv->vif, 935 sta = ieee80211_find_sta(priv->contexts[IWL_RXON_CTX_BSS].vif,
936 priv->stations[sta_id].sta.sta.addr); 936 priv->stations[sta_id].sta.sta.addr);
937 if (!sta) { 937 if (!sta) {
938 IWL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); 938 IWL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n");
@@ -949,7 +949,8 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
949 switch (priv->band) { 949 switch (priv->band) {
950 case IEEE80211_BAND_2GHZ: 950 case IEEE80211_BAND_2GHZ:
951 /* TODO: this always does G, not a regression */ 951 /* TODO: this always does G, not a regression */
952 if (priv->active_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) { 952 if (priv->contexts[IWL_RXON_CTX_BSS].active.flags &
953 RXON_FLG_TGG_PROTECT_MSK) {
953 rs_sta->tgg = 1; 954 rs_sta->tgg = 1;
954 rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; 955 rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot;
955 } else 956 } else
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 8ccfcd08218d..5d09686c3389 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -245,7 +245,7 @@ int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate)
245 break; 245 break;
246 case IEEE80211_BAND_2GHZ: 246 case IEEE80211_BAND_2GHZ:
247 if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) && 247 if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) &&
248 iwl_is_associated(priv)) { 248 iwl_is_associated(priv, IWL_RXON_CTX_BSS)) {
249 if (rate == IWL_RATE_11M_INDEX) 249 if (rate == IWL_RATE_11M_INDEX)
250 next_rate = IWL_RATE_5M_INDEX; 250 next_rate = IWL_RATE_5M_INDEX;
251 } 251 }
@@ -273,7 +273,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv,
273 struct iwl_queue *q = &txq->q; 273 struct iwl_queue *q = &txq->q;
274 struct iwl_tx_info *tx_info; 274 struct iwl_tx_info *tx_info;
275 275
276 BUG_ON(txq_id == IWL_CMD_QUEUE_NUM); 276 BUG_ON(txq_id == IWL39_CMD_QUEUE_NUM);
277 277
278 for (index = iwl_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; 278 for (index = iwl_queue_inc_wrap(index, q->n_bd); q->read_ptr != index;
279 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 279 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
@@ -285,7 +285,7 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv,
285 } 285 }
286 286
287 if (iwl_queue_space(q) > q->low_mark && (txq_id >= 0) && 287 if (iwl_queue_space(q) > q->low_mark && (txq_id >= 0) &&
288 (txq_id != IWL_CMD_QUEUE_NUM) && 288 (txq_id != IWL39_CMD_QUEUE_NUM) &&
289 priv->mac80211_registered) 289 priv->mac80211_registered)
290 iwl_wake_queue(priv, txq_id); 290 iwl_wake_queue(priv, txq_id);
291} 291}
@@ -760,7 +760,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv,
760 data_retry_limit = IWL_DEFAULT_TX_RETRY; 760 data_retry_limit = IWL_DEFAULT_TX_RETRY;
761 tx_cmd->data_retry_limit = data_retry_limit; 761 tx_cmd->data_retry_limit = data_retry_limit;
762 762
763 if (tx_id >= IWL_CMD_QUEUE_NUM) 763 if (tx_id >= IWL39_CMD_QUEUE_NUM)
764 rts_retry_limit = 3; 764 rts_retry_limit = 3;
765 else 765 else
766 rts_retry_limit = 7; 766 rts_retry_limit = 7;
@@ -909,7 +909,7 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv)
909 909
910 /* Tx queue(s) */ 910 /* Tx queue(s) */
911 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { 911 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
912 slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ? 912 slots_num = (txq_id == IWL39_CMD_QUEUE_NUM) ?
913 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; 913 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
914 rc = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num, 914 rc = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num,
915 txq_id); 915 txq_id);
@@ -1072,7 +1072,7 @@ void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv)
1072 if (priv->txq) 1072 if (priv->txq)
1073 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; 1073 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num;
1074 txq_id++) 1074 txq_id++)
1075 if (txq_id == IWL_CMD_QUEUE_NUM) 1075 if (txq_id == IWL39_CMD_QUEUE_NUM)
1076 iwl_cmd_queue_free(priv); 1076 iwl_cmd_queue_free(priv);
1077 else 1077 else
1078 iwl_tx_queue_free(priv, txq_id); 1078 iwl_tx_queue_free(priv, txq_id);
@@ -1439,17 +1439,18 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv)
1439 int rate_idx, i; 1439 int rate_idx, i;
1440 const struct iwl_channel_info *ch_info = NULL; 1440 const struct iwl_channel_info *ch_info = NULL;
1441 struct iwl3945_txpowertable_cmd txpower = { 1441 struct iwl3945_txpowertable_cmd txpower = {
1442 .channel = priv->active_rxon.channel, 1442 .channel = priv->contexts[IWL_RXON_CTX_BSS].active.channel,
1443 }; 1443 };
1444 u16 chan;
1445
1446 chan = le16_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.channel);
1444 1447
1445 txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; 1448 txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1;
1446 ch_info = iwl_get_channel_info(priv, 1449 ch_info = iwl_get_channel_info(priv, priv->band, chan);
1447 priv->band,
1448 le16_to_cpu(priv->active_rxon.channel));
1449 if (!ch_info) { 1450 if (!ch_info) {
1450 IWL_ERR(priv, 1451 IWL_ERR(priv,
1451 "Failed to get channel info for channel %d [%d]\n", 1452 "Failed to get channel info for channel %d [%d]\n",
1452 le16_to_cpu(priv->active_rxon.channel), priv->band); 1453 chan, priv->band);
1453 return -EINVAL; 1454 return -EINVAL;
1454 } 1455 }
1455 1456
@@ -1710,7 +1711,8 @@ int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power)
1710 return 0; 1711 return 0;
1711} 1712}
1712 1713
1713static int iwl3945_send_rxon_assoc(struct iwl_priv *priv) 1714static int iwl3945_send_rxon_assoc(struct iwl_priv *priv,
1715 struct iwl_rxon_context *ctx)
1714{ 1716{
1715 int rc = 0; 1717 int rc = 0;
1716 struct iwl_rx_packet *pkt; 1718 struct iwl_rx_packet *pkt;
@@ -1721,8 +1723,8 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
1721 .flags = CMD_WANT_SKB, 1723 .flags = CMD_WANT_SKB,
1722 .data = &rxon_assoc, 1724 .data = &rxon_assoc,
1723 }; 1725 };
1724 const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon; 1726 const struct iwl_rxon_cmd *rxon1 = &ctx->staging;
1725 const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon; 1727 const struct iwl_rxon_cmd *rxon2 = &ctx->active;
1726 1728
1727 if ((rxon1->flags == rxon2->flags) && 1729 if ((rxon1->flags == rxon2->flags) &&
1728 (rxon1->filter_flags == rxon2->filter_flags) && 1730 (rxon1->filter_flags == rxon2->filter_flags) &&
@@ -1732,10 +1734,10 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
1732 return 0; 1734 return 0;
1733 } 1735 }
1734 1736
1735 rxon_assoc.flags = priv->staging_rxon.flags; 1737 rxon_assoc.flags = ctx->staging.flags;
1736 rxon_assoc.filter_flags = priv->staging_rxon.filter_flags; 1738 rxon_assoc.filter_flags = ctx->staging.filter_flags;
1737 rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates; 1739 rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates;
1738 rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates; 1740 rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates;
1739 rxon_assoc.reserved = 0; 1741 rxon_assoc.reserved = 0;
1740 1742
1741 rc = iwl_send_cmd_sync(priv, &cmd); 1743 rc = iwl_send_cmd_sync(priv, &cmd);
@@ -1761,14 +1763,14 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
1761 * function correctly transitions out of the RXON_ASSOC_MSK state if 1763 * function correctly transitions out of the RXON_ASSOC_MSK state if
1762 * a HW tune is required based on the RXON structure changes. 1764 * a HW tune is required based on the RXON structure changes.
1763 */ 1765 */
1764static int iwl3945_commit_rxon(struct iwl_priv *priv) 1766static int iwl3945_commit_rxon(struct iwl_priv *priv,
1767 struct iwl_rxon_context *ctx)
1765{ 1768{
1766 /* cast away the const for active_rxon in this function */ 1769 /* cast away the const for active_rxon in this function */
1767 struct iwl3945_rxon_cmd *active_rxon = (void *)&priv->active_rxon; 1770 struct iwl3945_rxon_cmd *active_rxon = (void *)&ctx->active;
1768 struct iwl3945_rxon_cmd *staging_rxon = (void *)&priv->staging_rxon; 1771 struct iwl3945_rxon_cmd *staging_rxon = (void *)&ctx->staging;
1769 int rc = 0; 1772 int rc = 0;
1770 bool new_assoc = 1773 bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK);
1771 !!(priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK);
1772 1774
1773 if (!iwl_is_alive(priv)) 1775 if (!iwl_is_alive(priv))
1774 return -1; 1776 return -1;
@@ -1781,7 +1783,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1781 ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); 1783 ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK);
1782 staging_rxon->flags |= iwl3945_get_antenna_flags(priv); 1784 staging_rxon->flags |= iwl3945_get_antenna_flags(priv);
1783 1785
1784 rc = iwl_check_rxon_cmd(priv); 1786 rc = iwl_check_rxon_cmd(priv, ctx);
1785 if (rc) { 1787 if (rc) {
1786 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); 1788 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
1787 return -EINVAL; 1789 return -EINVAL;
@@ -1790,8 +1792,9 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1790 /* If we don't need to send a full RXON, we can use 1792 /* If we don't need to send a full RXON, we can use
1791 * iwl3945_rxon_assoc_cmd which is used to reconfigure filter 1793 * iwl3945_rxon_assoc_cmd which is used to reconfigure filter
1792 * and other flags for the current radio configuration. */ 1794 * and other flags for the current radio configuration. */
1793 if (!iwl_full_rxon_required(priv)) { 1795 if (!iwl_full_rxon_required(priv, &priv->contexts[IWL_RXON_CTX_BSS])) {
1794 rc = iwl_send_rxon_assoc(priv); 1796 rc = iwl_send_rxon_assoc(priv,
1797 &priv->contexts[IWL_RXON_CTX_BSS]);
1795 if (rc) { 1798 if (rc) {
1796 IWL_ERR(priv, "Error setting RXON_ASSOC " 1799 IWL_ERR(priv, "Error setting RXON_ASSOC "
1797 "configuration (%d).\n", rc); 1800 "configuration (%d).\n", rc);
@@ -1807,7 +1810,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1807 * an RXON_ASSOC and the new config wants the associated mask enabled, 1810 * an RXON_ASSOC and the new config wants the associated mask enabled,
1808 * we must clear the associated from the active configuration 1811 * we must clear the associated from the active configuration
1809 * before we apply the new config */ 1812 * before we apply the new config */
1810 if (iwl_is_associated(priv) && new_assoc) { 1813 if (iwl_is_associated(priv, IWL_RXON_CTX_BSS) && new_assoc) {
1811 IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); 1814 IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n");
1812 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 1815 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
1813 1816
@@ -1819,7 +1822,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1819 active_rxon->reserved5 = 0; 1822 active_rxon->reserved5 = 0;
1820 rc = iwl_send_cmd_pdu(priv, REPLY_RXON, 1823 rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
1821 sizeof(struct iwl3945_rxon_cmd), 1824 sizeof(struct iwl3945_rxon_cmd),
1822 &priv->active_rxon); 1825 &priv->contexts[IWL_RXON_CTX_BSS].active);
1823 1826
1824 /* If the mask clearing failed then we set 1827 /* If the mask clearing failed then we set
1825 * active_rxon back to what it was previously */ 1828 * active_rxon back to what it was previously */
@@ -1829,8 +1832,9 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1829 "configuration (%d).\n", rc); 1832 "configuration (%d).\n", rc);
1830 return rc; 1833 return rc;
1831 } 1834 }
1832 iwl_clear_ucode_stations(priv); 1835 iwl_clear_ucode_stations(priv,
1833 iwl_restore_stations(priv); 1836 &priv->contexts[IWL_RXON_CTX_BSS]);
1837 iwl_restore_stations(priv, &priv->contexts[IWL_RXON_CTX_BSS]);
1834 } 1838 }
1835 1839
1836 IWL_DEBUG_INFO(priv, "Sending RXON\n" 1840 IWL_DEBUG_INFO(priv, "Sending RXON\n"
@@ -1848,7 +1852,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1848 staging_rxon->reserved4 = 0; 1852 staging_rxon->reserved4 = 0;
1849 staging_rxon->reserved5 = 0; 1853 staging_rxon->reserved5 = 0;
1850 1854
1851 iwl_set_rxon_hwcrypto(priv, !iwl3945_mod_params.sw_crypto); 1855 iwl_set_rxon_hwcrypto(priv, ctx, !iwl3945_mod_params.sw_crypto);
1852 1856
1853 /* Apply the new configuration */ 1857 /* Apply the new configuration */
1854 rc = iwl_send_cmd_pdu(priv, REPLY_RXON, 1858 rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
@@ -1862,8 +1866,9 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
1862 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); 1866 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
1863 1867
1864 if (!new_assoc) { 1868 if (!new_assoc) {
1865 iwl_clear_ucode_stations(priv); 1869 iwl_clear_ucode_stations(priv,
1866 iwl_restore_stations(priv); 1870 &priv->contexts[IWL_RXON_CTX_BSS]);
1871 iwl_restore_stations(priv, &priv->contexts[IWL_RXON_CTX_BSS]);
1867 } 1872 }
1868 1873
1869 /* If we issue a new RXON command which required a tune then we must 1874 /* If we issue a new RXON command which required a tune then we must
@@ -2302,8 +2307,10 @@ static int iwl3945_manage_ibss_station(struct iwl_priv *priv,
2302 int ret; 2307 int ret;
2303 2308
2304 if (add) { 2309 if (add) {
2305 ret = iwl_add_bssid_station(priv, vif->bss_conf.bssid, false, 2310 ret = iwl_add_bssid_station(
2306 &vif_priv->ibss_bssid_sta_id); 2311 priv, &priv->contexts[IWL_RXON_CTX_BSS],
2312 vif->bss_conf.bssid, false,
2313 &vif_priv->ibss_bssid_sta_id);
2307 if (ret) 2314 if (ret)
2308 return ret; 2315 return ret;
2309 2316
@@ -2366,7 +2373,7 @@ int iwl3945_init_hw_rate_table(struct iwl_priv *priv)
2366 * 1M CCK rates */ 2373 * 1M CCK rates */
2367 2374
2368 if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) && 2375 if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) &&
2369 iwl_is_associated(priv)) { 2376 iwl_is_associated(priv, IWL_RXON_CTX_BSS)) {
2370 2377
2371 index = IWL_FIRST_CCK_RATE; 2378 index = IWL_FIRST_CCK_RATE;
2372 for (i = IWL_RATE_6M_INDEX_TABLE; 2379 for (i = IWL_RATE_6M_INDEX_TABLE;
@@ -2421,7 +2428,9 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv)
2421 priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; 2428 priv->hw_params.max_rxq_size = RX_QUEUE_SIZE;
2422 priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; 2429 priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
2423 priv->hw_params.max_stations = IWL3945_STATION_COUNT; 2430 priv->hw_params.max_stations = IWL3945_STATION_COUNT;
2424 priv->hw_params.bcast_sta_id = IWL3945_BROADCAST_ID; 2431 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID;
2432
2433 priv->sta_key_max_num = STA_KEY_MAX_NUM;
2425 2434
2426 priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; 2435 priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR;
2427 priv->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; 2436 priv->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL;
@@ -2439,7 +2448,8 @@ unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv,
2439 tx_beacon_cmd = (struct iwl3945_tx_beacon_cmd *)&frame->u; 2448 tx_beacon_cmd = (struct iwl3945_tx_beacon_cmd *)&frame->u;
2440 memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); 2449 memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd));
2441 2450
2442 tx_beacon_cmd->tx.sta_id = priv->hw_params.bcast_sta_id; 2451 tx_beacon_cmd->tx.sta_id =
2452 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id;
2443 tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 2453 tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
2444 2454
2445 frame_size = iwl3945_fill_beacon_frame(priv, 2455 frame_size = iwl3945_fill_beacon_frame(priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index f0a47f42d4b8..1d6a46d4db59 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -347,7 +347,7 @@ static void iwl4965_chain_noise_reset(struct iwl_priv *priv)
347 struct iwl_chain_noise_data *data = &(priv->chain_noise_data); 347 struct iwl_chain_noise_data *data = &(priv->chain_noise_data);
348 348
349 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && 349 if ((data->state == IWL_CHAIN_NOISE_ALIVE) &&
350 iwl_is_associated(priv)) { 350 iwl_is_any_associated(priv)) {
351 struct iwl_calib_diff_gain_cmd cmd; 351 struct iwl_calib_diff_gain_cmd cmd;
352 352
353 /* clear data for chain noise calibration algorithm */ 353 /* clear data for chain noise calibration algorithm */
@@ -576,7 +576,7 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
576 /* Activate all Tx DMA/FIFO channels */ 576 /* Activate all Tx DMA/FIFO channels */
577 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 6)); 577 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 6));
578 578
579 iwl4965_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); 579 iwl4965_set_wr_ptrs(priv, IWL_DEFAULT_CMD_QUEUE_NUM, 0);
580 580
581 /* make sure all queue are not stopped */ 581 /* make sure all queue are not stopped */
582 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped)); 582 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
@@ -587,6 +587,7 @@ static int iwl4965_alive_notify(struct iwl_priv *priv)
587 priv->txq_ctx_active_msk = 0; 587 priv->txq_ctx_active_msk = 0;
588 /* Map each Tx/cmd queue to its corresponding fifo */ 588 /* Map each Tx/cmd queue to its corresponding fifo */
589 BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); 589 BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7);
590
590 for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { 591 for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) {
591 int ac = default_queue_to_tx_fifo[i]; 592 int ac = default_queue_to_tx_fifo[i];
592 593
@@ -656,7 +657,7 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv)
656 sizeof(struct iwl4965_scd_bc_tbl); 657 sizeof(struct iwl4965_scd_bc_tbl);
657 priv->hw_params.tfd_size = sizeof(struct iwl_tfd); 658 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
658 priv->hw_params.max_stations = IWL4965_STATION_COUNT; 659 priv->hw_params.max_stations = IWL4965_STATION_COUNT;
659 priv->hw_params.bcast_sta_id = IWL4965_BROADCAST_ID; 660 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID;
660 priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; 661 priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE;
661 priv->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; 662 priv->hw_params.max_inst_size = IWL49_RTC_INST_SIZE;
662 priv->hw_params.max_bsm_size = BSM_SRAM_SIZE; 663 priv->hw_params.max_bsm_size = BSM_SRAM_SIZE;
@@ -1374,6 +1375,7 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv)
1374 u8 band = 0; 1375 u8 band = 0;
1375 bool is_ht40 = false; 1376 bool is_ht40 = false;
1376 u8 ctrl_chan_high = 0; 1377 u8 ctrl_chan_high = 0;
1378 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
1377 1379
1378 if (test_bit(STATUS_SCANNING, &priv->status)) { 1380 if (test_bit(STATUS_SCANNING, &priv->status)) {
1379 /* If this gets hit a lot, switch it to a BUG() and catch 1381 /* If this gets hit a lot, switch it to a BUG() and catch
@@ -1385,17 +1387,16 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv)
1385 1387
1386 band = priv->band == IEEE80211_BAND_2GHZ; 1388 band = priv->band == IEEE80211_BAND_2GHZ;
1387 1389
1388 is_ht40 = is_ht40_channel(priv->active_rxon.flags); 1390 is_ht40 = is_ht40_channel(ctx->active.flags);
1389 1391
1390 if (is_ht40 && 1392 if (is_ht40 && (ctx->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK))
1391 (priv->active_rxon.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK))
1392 ctrl_chan_high = 1; 1393 ctrl_chan_high = 1;
1393 1394
1394 cmd.band = band; 1395 cmd.band = band;
1395 cmd.channel = priv->active_rxon.channel; 1396 cmd.channel = ctx->active.channel;
1396 1397
1397 ret = iwl4965_fill_txpower_tbl(priv, band, 1398 ret = iwl4965_fill_txpower_tbl(priv, band,
1398 le16_to_cpu(priv->active_rxon.channel), 1399 le16_to_cpu(ctx->active.channel),
1399 is_ht40, ctrl_chan_high, &cmd.tx_power); 1400 is_ht40, ctrl_chan_high, &cmd.tx_power);
1400 if (ret) 1401 if (ret)
1401 goto out; 1402 goto out;
@@ -1406,12 +1407,13 @@ out:
1406 return ret; 1407 return ret;
1407} 1408}
1408 1409
1409static int iwl4965_send_rxon_assoc(struct iwl_priv *priv) 1410static int iwl4965_send_rxon_assoc(struct iwl_priv *priv,
1411 struct iwl_rxon_context *ctx)
1410{ 1412{
1411 int ret = 0; 1413 int ret = 0;
1412 struct iwl4965_rxon_assoc_cmd rxon_assoc; 1414 struct iwl4965_rxon_assoc_cmd rxon_assoc;
1413 const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon; 1415 const struct iwl_rxon_cmd *rxon1 = &ctx->staging;
1414 const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon; 1416 const struct iwl_rxon_cmd *rxon2 = &ctx->active;
1415 1417
1416 if ((rxon1->flags == rxon2->flags) && 1418 if ((rxon1->flags == rxon2->flags) &&
1417 (rxon1->filter_flags == rxon2->filter_flags) && 1419 (rxon1->filter_flags == rxon2->filter_flags) &&
@@ -1426,16 +1428,16 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv)
1426 return 0; 1428 return 0;
1427 } 1429 }
1428 1430
1429 rxon_assoc.flags = priv->staging_rxon.flags; 1431 rxon_assoc.flags = ctx->staging.flags;
1430 rxon_assoc.filter_flags = priv->staging_rxon.filter_flags; 1432 rxon_assoc.filter_flags = ctx->staging.filter_flags;
1431 rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates; 1433 rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates;
1432 rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates; 1434 rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates;
1433 rxon_assoc.reserved = 0; 1435 rxon_assoc.reserved = 0;
1434 rxon_assoc.ofdm_ht_single_stream_basic_rates = 1436 rxon_assoc.ofdm_ht_single_stream_basic_rates =
1435 priv->staging_rxon.ofdm_ht_single_stream_basic_rates; 1437 ctx->staging.ofdm_ht_single_stream_basic_rates;
1436 rxon_assoc.ofdm_ht_dual_stream_basic_rates = 1438 rxon_assoc.ofdm_ht_dual_stream_basic_rates =
1437 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates; 1439 ctx->staging.ofdm_ht_dual_stream_basic_rates;
1438 rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain; 1440 rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain;
1439 1441
1440 ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, 1442 ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC,
1441 sizeof(rxon_assoc), &rxon_assoc, NULL); 1443 sizeof(rxon_assoc), &rxon_assoc, NULL);
@@ -1448,6 +1450,7 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv)
1448static int iwl4965_hw_channel_switch(struct iwl_priv *priv, 1450static int iwl4965_hw_channel_switch(struct iwl_priv *priv,
1449 struct ieee80211_channel_switch *ch_switch) 1451 struct ieee80211_channel_switch *ch_switch)
1450{ 1452{
1453 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
1451 int rc; 1454 int rc;
1452 u8 band = 0; 1455 u8 band = 0;
1453 bool is_ht40 = false; 1456 bool is_ht40 = false;
@@ -1458,22 +1461,22 @@ static int iwl4965_hw_channel_switch(struct iwl_priv *priv,
1458 u16 ch; 1461 u16 ch;
1459 u32 tsf_low; 1462 u32 tsf_low;
1460 u8 switch_count; 1463 u8 switch_count;
1461 u16 beacon_interval = le16_to_cpu(priv->rxon_timing.beacon_interval); 1464 u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
1462 struct ieee80211_vif *vif = priv->vif; 1465 struct ieee80211_vif *vif = ctx->vif;
1463 band = priv->band == IEEE80211_BAND_2GHZ; 1466 band = priv->band == IEEE80211_BAND_2GHZ;
1464 1467
1465 is_ht40 = is_ht40_channel(priv->staging_rxon.flags); 1468 is_ht40 = is_ht40_channel(ctx->staging.flags);
1466 1469
1467 if (is_ht40 && 1470 if (is_ht40 &&
1468 (priv->staging_rxon.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) 1471 (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK))
1469 ctrl_chan_high = 1; 1472 ctrl_chan_high = 1;
1470 1473
1471 cmd.band = band; 1474 cmd.band = band;
1472 cmd.expect_beacon = 0; 1475 cmd.expect_beacon = 0;
1473 ch = ch_switch->channel->hw_value; 1476 ch = ch_switch->channel->hw_value;
1474 cmd.channel = cpu_to_le16(ch); 1477 cmd.channel = cpu_to_le16(ch);
1475 cmd.rxon_flags = priv->staging_rxon.flags; 1478 cmd.rxon_flags = ctx->staging.flags;
1476 cmd.rxon_filter_flags = priv->staging_rxon.filter_flags; 1479 cmd.rxon_filter_flags = ctx->staging.filter_flags;
1477 switch_count = ch_switch->count; 1480 switch_count = ch_switch->count;
1478 tsf_low = ch_switch->timestamp & 0x0ffffffff; 1481 tsf_low = ch_switch->timestamp & 0x0ffffffff;
1479 /* 1482 /*
@@ -1508,7 +1511,7 @@ static int iwl4965_hw_channel_switch(struct iwl_priv *priv,
1508 cmd.expect_beacon = is_channel_radar(ch_info); 1511 cmd.expect_beacon = is_channel_radar(ch_info);
1509 else { 1512 else {
1510 IWL_ERR(priv, "invalid channel switch from %u to %u\n", 1513 IWL_ERR(priv, "invalid channel switch from %u to %u\n",
1511 priv->active_rxon.channel, ch); 1514 ctx->active.channel, ch);
1512 return -EFAULT; 1515 return -EFAULT;
1513 } 1516 }
1514 1517
@@ -2007,7 +2010,7 @@ static u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
2007 start = IWL_STA_ID; 2010 start = IWL_STA_ID;
2008 2011
2009 if (is_broadcast_ether_addr(addr)) 2012 if (is_broadcast_ether_addr(addr))
2010 return priv->hw_params.bcast_sta_id; 2013 return priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id;
2011 2014
2012 spin_lock_irqsave(&priv->sta_lock, flags); 2015 spin_lock_irqsave(&priv->sta_lock, flags);
2013 for (i = start; i < priv->hw_params.max_stations; i++) 2016 for (i = start; i < priv->hw_params.max_stations; i++)
@@ -2280,7 +2283,7 @@ static struct iwl_lib_ops iwl4965_lib = {
2280 .set_ct_kill = iwl4965_set_ct_threshold, 2283 .set_ct_kill = iwl4965_set_ct_threshold,
2281 }, 2284 },
2282 .manage_ibss_station = iwlagn_manage_ibss_station, 2285 .manage_ibss_station = iwlagn_manage_ibss_station,
2283 .update_bcast_station = iwl_update_bcast_station, 2286 .update_bcast_stations = iwl_update_bcast_stations,
2284 .debugfs_ops = { 2287 .debugfs_ops = {
2285 .rx_stats_read = iwl_ucode_rx_stats_read, 2288 .rx_stats_read = iwl_ucode_rx_stats_read,
2286 .tx_stats_read = iwl_ucode_tx_stats_read, 2289 .tx_stats_read = iwl_ucode_tx_stats_read,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
index 146e6431ae95..3975e45e7500 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-5000-hw.h
@@ -62,7 +62,7 @@
62 *****************************************************************************/ 62 *****************************************************************************/
63/* 63/*
64 * Please use this file (iwl-5000-hw.h) only for hardware-related definitions. 64 * Please use this file (iwl-5000-hw.h) only for hardware-related definitions.
65 * Use iwl-5000-commands.h for uCode API definitions. 65 * Use iwl-commands.h for uCode API definitions.
66 */ 66 */
67 67
68#ifndef __iwl_5000_hw_h__ 68#ifndef __iwl_5000_hw_h__
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 013f3dae69f1..1dbb1246c083 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -180,7 +180,7 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
180 sizeof(struct iwlagn_scd_bc_tbl); 180 sizeof(struct iwlagn_scd_bc_tbl);
181 priv->hw_params.tfd_size = sizeof(struct iwl_tfd); 181 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
182 priv->hw_params.max_stations = IWLAGN_STATION_COUNT; 182 priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
183 priv->hw_params.bcast_sta_id = IWLAGN_BROADCAST_ID; 183 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
184 184
185 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE; 185 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
186 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE; 186 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
@@ -227,7 +227,7 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv)
227 sizeof(struct iwlagn_scd_bc_tbl); 227 sizeof(struct iwlagn_scd_bc_tbl);
228 priv->hw_params.tfd_size = sizeof(struct iwl_tfd); 228 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
229 priv->hw_params.max_stations = IWLAGN_STATION_COUNT; 229 priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
230 priv->hw_params.bcast_sta_id = IWLAGN_BROADCAST_ID; 230 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
231 231
232 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE; 232 priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
233 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE; 233 priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
@@ -275,14 +275,19 @@ static void iwl5150_temperature(struct iwl_priv *priv)
275static int iwl5000_hw_channel_switch(struct iwl_priv *priv, 275static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
276 struct ieee80211_channel_switch *ch_switch) 276 struct ieee80211_channel_switch *ch_switch)
277{ 277{
278 /*
279 * MULTI-FIXME
280 * See iwl_mac_channel_switch.
281 */
282 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
278 struct iwl5000_channel_switch_cmd cmd; 283 struct iwl5000_channel_switch_cmd cmd;
279 const struct iwl_channel_info *ch_info; 284 const struct iwl_channel_info *ch_info;
280 u32 switch_time_in_usec, ucode_switch_time; 285 u32 switch_time_in_usec, ucode_switch_time;
281 u16 ch; 286 u16 ch;
282 u32 tsf_low; 287 u32 tsf_low;
283 u8 switch_count; 288 u8 switch_count;
284 u16 beacon_interval = le16_to_cpu(priv->rxon_timing.beacon_interval); 289 u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
285 struct ieee80211_vif *vif = priv->vif; 290 struct ieee80211_vif *vif = ctx->vif;
286 struct iwl_host_cmd hcmd = { 291 struct iwl_host_cmd hcmd = {
287 .id = REPLY_CHANNEL_SWITCH, 292 .id = REPLY_CHANNEL_SWITCH,
288 .len = sizeof(cmd), 293 .len = sizeof(cmd),
@@ -293,10 +298,10 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
293 cmd.band = priv->band == IEEE80211_BAND_2GHZ; 298 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
294 ch = ch_switch->channel->hw_value; 299 ch = ch_switch->channel->hw_value;
295 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n", 300 IWL_DEBUG_11H(priv, "channel switch from %d to %d\n",
296 priv->active_rxon.channel, ch); 301 ctx->active.channel, ch);
297 cmd.channel = cpu_to_le16(ch); 302 cmd.channel = cpu_to_le16(ch);
298 cmd.rxon_flags = priv->staging_rxon.flags; 303 cmd.rxon_flags = ctx->staging.flags;
299 cmd.rxon_filter_flags = priv->staging_rxon.filter_flags; 304 cmd.rxon_filter_flags = ctx->staging.filter_flags;
300 switch_count = ch_switch->count; 305 switch_count = ch_switch->count;
301 tsf_low = ch_switch->timestamp & 0x0ffffffff; 306 tsf_low = ch_switch->timestamp & 0x0ffffffff;
302 /* 307 /*
@@ -331,7 +336,7 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
331 cmd.expect_beacon = is_channel_radar(ch_info); 336 cmd.expect_beacon = is_channel_radar(ch_info);
332 else { 337 else {
333 IWL_ERR(priv, "invalid channel switch from %u to %u\n", 338 IWL_ERR(priv, "invalid channel switch from %u to %u\n",
334 priv->active_rxon.channel, ch); 339 ctx->active.channel, ch);
335 return -EFAULT; 340 return -EFAULT;
336 } 341 }
337 priv->switch_rxon.channel = cmd.channel; 342 priv->switch_rxon.channel = cmd.channel;
@@ -393,7 +398,7 @@ static struct iwl_lib_ops iwl5000_lib = {
393 .set_ct_kill = iwl5000_set_ct_threshold, 398 .set_ct_kill = iwl5000_set_ct_threshold,
394 }, 399 },
395 .manage_ibss_station = iwlagn_manage_ibss_station, 400 .manage_ibss_station = iwlagn_manage_ibss_station,
396 .update_bcast_station = iwl_update_bcast_station, 401 .update_bcast_stations = iwl_update_bcast_stations,
397 .debugfs_ops = { 402 .debugfs_ops = {
398 .rx_stats_read = iwl_ucode_rx_stats_read, 403 .rx_stats_read = iwl_ucode_rx_stats_read,
399 .tx_stats_read = iwl_ucode_tx_stats_read, 404 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -464,7 +469,7 @@ static struct iwl_lib_ops iwl5150_lib = {
464 .set_ct_kill = iwl5150_set_ct_threshold, 469 .set_ct_kill = iwl5150_set_ct_threshold,
465 }, 470 },
466 .manage_ibss_station = iwlagn_manage_ibss_station, 471 .manage_ibss_station = iwlagn_manage_ibss_station,
467 .update_bcast_station = iwl_update_bcast_station, 472 .update_bcast_stations = iwl_update_bcast_stations,
468 .debugfs_ops = { 473 .debugfs_ops = {
469 .rx_stats_read = iwl_ucode_rx_stats_read, 474 .rx_stats_read = iwl_ucode_rx_stats_read,
470 .tx_stats_read = iwl_ucode_tx_stats_read, 475 .tx_stats_read = iwl_ucode_tx_stats_read,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000-hw.h b/drivers/net/wireless/iwlwifi/iwl-6000-hw.h
index ddba39999997..47891e16a758 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-6000-hw.h
@@ -62,7 +62,7 @@
62 *****************************************************************************/ 62 *****************************************************************************/
63/* 63/*
64 * Please use this file (iwl-6000-hw.h) only for hardware-related definitions. 64 * Please use this file (iwl-6000-hw.h) only for hardware-related definitions.
65 * Use iwl-5000-commands.h for uCode API definitions. 65 * Use iwl-commands.h for uCode API definitions.
66 */ 66 */
67 67
68#ifndef __iwl_6000_hw_h__ 68#ifndef __iwl_6000_hw_h__
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 9e390f698641..2fdba088bd27 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -52,7 +52,7 @@
52/* Highest firmware API version supported */ 52/* Highest firmware API version supported */
53#define IWL6000_UCODE_API_MAX 4 53#define IWL6000_UCODE_API_MAX 4
54#define IWL6050_UCODE_API_MAX 4 54#define IWL6050_UCODE_API_MAX 4
55#define IWL6000G2_UCODE_API_MAX 4 55#define IWL6000G2_UCODE_API_MAX 5
56 56
57/* Lowest firmware API version supported */ 57/* Lowest firmware API version supported */
58#define IWL6000_UCODE_API_MIN 4 58#define IWL6000_UCODE_API_MIN 4
@@ -161,7 +161,7 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv)
161 sizeof(struct iwlagn_scd_bc_tbl); 161 sizeof(struct iwlagn_scd_bc_tbl);
162 priv->hw_params.tfd_size = sizeof(struct iwl_tfd); 162 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
163 priv->hw_params.max_stations = IWLAGN_STATION_COUNT; 163 priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
164 priv->hw_params.bcast_sta_id = IWLAGN_BROADCAST_ID; 164 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
165 165
166 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE; 166 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
167 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE; 167 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
@@ -198,14 +198,19 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv)
198static int iwl6000_hw_channel_switch(struct iwl_priv *priv, 198static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
199 struct ieee80211_channel_switch *ch_switch) 199 struct ieee80211_channel_switch *ch_switch)
200{ 200{
201 /*
202 * MULTI-FIXME
203 * See iwl_mac_channel_switch.
204 */
205 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
201 struct iwl6000_channel_switch_cmd cmd; 206 struct iwl6000_channel_switch_cmd cmd;
202 const struct iwl_channel_info *ch_info; 207 const struct iwl_channel_info *ch_info;
203 u32 switch_time_in_usec, ucode_switch_time; 208 u32 switch_time_in_usec, ucode_switch_time;
204 u16 ch; 209 u16 ch;
205 u32 tsf_low; 210 u32 tsf_low;
206 u8 switch_count; 211 u8 switch_count;
207 u16 beacon_interval = le16_to_cpu(priv->rxon_timing.beacon_interval); 212 u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval);
208 struct ieee80211_vif *vif = priv->vif; 213 struct ieee80211_vif *vif = ctx->vif;
209 struct iwl_host_cmd hcmd = { 214 struct iwl_host_cmd hcmd = {
210 .id = REPLY_CHANNEL_SWITCH, 215 .id = REPLY_CHANNEL_SWITCH,
211 .len = sizeof(cmd), 216 .len = sizeof(cmd),
@@ -216,10 +221,10 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
216 cmd.band = priv->band == IEEE80211_BAND_2GHZ; 221 cmd.band = priv->band == IEEE80211_BAND_2GHZ;
217 ch = ch_switch->channel->hw_value; 222 ch = ch_switch->channel->hw_value;
218 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n", 223 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
219 priv->active_rxon.channel, ch); 224 ctx->active.channel, ch);
220 cmd.channel = cpu_to_le16(ch); 225 cmd.channel = cpu_to_le16(ch);
221 cmd.rxon_flags = priv->staging_rxon.flags; 226 cmd.rxon_flags = ctx->staging.flags;
222 cmd.rxon_filter_flags = priv->staging_rxon.filter_flags; 227 cmd.rxon_filter_flags = ctx->staging.filter_flags;
223 switch_count = ch_switch->count; 228 switch_count = ch_switch->count;
224 tsf_low = ch_switch->timestamp & 0x0ffffffff; 229 tsf_low = ch_switch->timestamp & 0x0ffffffff;
225 /* 230 /*
@@ -254,7 +259,7 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
254 cmd.expect_beacon = is_channel_radar(ch_info); 259 cmd.expect_beacon = is_channel_radar(ch_info);
255 else { 260 else {
256 IWL_ERR(priv, "invalid channel switch from %u to %u\n", 261 IWL_ERR(priv, "invalid channel switch from %u to %u\n",
257 priv->active_rxon.channel, ch); 262 ctx->active.channel, ch);
258 return -EFAULT; 263 return -EFAULT;
259 } 264 }
260 priv->switch_rxon.channel = cmd.channel; 265 priv->switch_rxon.channel = cmd.channel;
@@ -318,7 +323,82 @@ static struct iwl_lib_ops iwl6000_lib = {
318 .set_calib_version = iwl6000_set_calib_version, 323 .set_calib_version = iwl6000_set_calib_version,
319 }, 324 },
320 .manage_ibss_station = iwlagn_manage_ibss_station, 325 .manage_ibss_station = iwlagn_manage_ibss_station,
321 .update_bcast_station = iwl_update_bcast_station, 326 .update_bcast_stations = iwl_update_bcast_stations,
327 .debugfs_ops = {
328 .rx_stats_read = iwl_ucode_rx_stats_read,
329 .tx_stats_read = iwl_ucode_tx_stats_read,
330 .general_stats_read = iwl_ucode_general_stats_read,
331 .bt_stats_read = iwl_ucode_bt_stats_read,
332 },
333 .recover_from_tx_stall = iwl_bg_monitor_recover,
334 .check_plcp_health = iwl_good_plcp_health,
335 .check_ack_health = iwl_good_ack_health,
336 .txfifo_flush = iwlagn_txfifo_flush,
337 .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
338 .tt_ops = {
339 .lower_power_detection = iwl_tt_is_low_power_state,
340 .tt_power_mode = iwl_tt_current_power_mode,
341 .ct_kill_check = iwl_check_for_ct_kill,
342 }
343};
344
345static struct iwl_lib_ops iwl6000g2b_lib = {
346 .set_hw_params = iwl6000_hw_set_hw_params,
347 .txq_update_byte_cnt_tbl = iwlagn_txq_update_byte_cnt_tbl,
348 .txq_inval_byte_cnt_tbl = iwlagn_txq_inval_byte_cnt_tbl,
349 .txq_set_sched = iwlagn_txq_set_sched,
350 .txq_agg_enable = iwlagn_txq_agg_enable,
351 .txq_agg_disable = iwlagn_txq_agg_disable,
352 .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
353 .txq_free_tfd = iwl_hw_txq_free_tfd,
354 .txq_init = iwl_hw_tx_queue_init,
355 .rx_handler_setup = iwlagn_bt_rx_handler_setup,
356 .setup_deferred_work = iwlagn_bt_setup_deferred_work,
357 .cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
358 .is_valid_rtc_data_addr = iwlagn_hw_valid_rtc_data_addr,
359 .load_ucode = iwlagn_load_ucode,
360 .dump_nic_event_log = iwl_dump_nic_event_log,
361 .dump_nic_error_log = iwl_dump_nic_error_log,
362 .dump_csr = iwl_dump_csr,
363 .dump_fh = iwl_dump_fh,
364 .init_alive_start = iwlagn_init_alive_start,
365 .alive_notify = iwlagn_alive_notify,
366 .send_tx_power = iwlagn_send_tx_power,
367 .update_chain_flags = iwl_update_chain_flags,
368 .set_channel_switch = iwl6000_hw_channel_switch,
369 .apm_ops = {
370 .init = iwl_apm_init,
371 .stop = iwl_apm_stop,
372 .config = iwl6000_nic_config,
373 .set_pwr_src = iwl_set_pwr_src,
374 },
375 .eeprom_ops = {
376 .regulatory_bands = {
377 EEPROM_REG_BAND_1_CHANNELS,
378 EEPROM_REG_BAND_2_CHANNELS,
379 EEPROM_REG_BAND_3_CHANNELS,
380 EEPROM_REG_BAND_4_CHANNELS,
381 EEPROM_REG_BAND_5_CHANNELS,
382 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
383 EEPROM_REG_BAND_52_HT40_CHANNELS
384 },
385 .verify_signature = iwlcore_eeprom_verify_signature,
386 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
387 .release_semaphore = iwlcore_eeprom_release_semaphore,
388 .calib_version = iwlagn_eeprom_calib_version,
389 .query_addr = iwlagn_eeprom_query_addr,
390 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
391 },
392 .post_associate = iwl_post_associate,
393 .isr = iwl_isr_ict,
394 .config_ap = iwl_config_ap,
395 .temp_ops = {
396 .temperature = iwlagn_temperature,
397 .set_ct_kill = iwl6000_set_ct_threshold,
398 .set_calib_version = iwl6000_set_calib_version,
399 },
400 .manage_ibss_station = iwlagn_manage_ibss_station,
401 .update_bcast_stations = iwl_update_bcast_stations,
322 .debugfs_ops = { 402 .debugfs_ops = {
323 .rx_stats_read = iwl_ucode_rx_stats_read, 403 .rx_stats_read = iwl_ucode_rx_stats_read,
324 .tx_stats_read = iwl_ucode_tx_stats_read, 404 .tx_stats_read = iwl_ucode_tx_stats_read,
@@ -344,21 +424,9 @@ static const struct iwl_ops iwl6000_ops = {
344 .led = &iwlagn_led_ops, 424 .led = &iwlagn_led_ops,
345}; 425};
346 426
347static void do_not_send_bt_config(struct iwl_priv *priv)
348{
349}
350
351static struct iwl_hcmd_ops iwl6000g2b_hcmd = {
352 .rxon_assoc = iwlagn_send_rxon_assoc,
353 .commit_rxon = iwl_commit_rxon,
354 .set_rxon_chain = iwl_set_rxon_chain,
355 .set_tx_ant = iwlagn_send_tx_ant_config,
356 .send_bt_config = do_not_send_bt_config,
357};
358
359static const struct iwl_ops iwl6000g2b_ops = { 427static const struct iwl_ops iwl6000g2b_ops = {
360 .lib = &iwl6000_lib, 428 .lib = &iwl6000g2b_lib,
361 .hcmd = &iwl6000g2b_hcmd, 429 .hcmd = &iwlagn_bt_hcmd,
362 .utils = &iwlagn_hcmd_utils, 430 .utils = &iwlagn_hcmd_utils,
363 .led = &iwlagn_led_ops, 431 .led = &iwlagn_led_ops,
364}; 432};
@@ -499,7 +567,7 @@ struct iwl_cfg iwl6000g2b_2agn_cfg = {
499 .supports_idle = true, 567 .supports_idle = true,
500 .adv_thermal_throttle = true, 568 .adv_thermal_throttle = true,
501 .support_ct_kill_exit = true, 569 .support_ct_kill_exit = true,
502 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 570 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE,
503 .chain_noise_scale = 1000, 571 .chain_noise_scale = 1000,
504 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD, 572 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD,
505 .max_event_log_size = 512, 573 .max_event_log_size = 512,
@@ -507,6 +575,11 @@ struct iwl_cfg iwl6000g2b_2agn_cfg = {
507 .chain_noise_calib_by_driver = true, 575 .chain_noise_calib_by_driver = true,
508 .need_dc_calib = true, 576 .need_dc_calib = true,
509 .bt_statistics = true, 577 .bt_statistics = true,
578 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
579 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
580 .advanced_bt_coexist = true,
581 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
582 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
510}; 583};
511 584
512struct iwl_cfg iwl6000g2b_2abg_cfg = { 585struct iwl_cfg iwl6000g2b_2abg_cfg = {
@@ -535,7 +608,7 @@ struct iwl_cfg iwl6000g2b_2abg_cfg = {
535 .supports_idle = true, 608 .supports_idle = true,
536 .adv_thermal_throttle = true, 609 .adv_thermal_throttle = true,
537 .support_ct_kill_exit = true, 610 .support_ct_kill_exit = true,
538 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 611 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE,
539 .chain_noise_scale = 1000, 612 .chain_noise_scale = 1000,
540 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD, 613 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD,
541 .max_event_log_size = 512, 614 .max_event_log_size = 512,
@@ -543,6 +616,11 @@ struct iwl_cfg iwl6000g2b_2abg_cfg = {
543 .chain_noise_calib_by_driver = true, 616 .chain_noise_calib_by_driver = true,
544 .need_dc_calib = true, 617 .need_dc_calib = true,
545 .bt_statistics = true, 618 .bt_statistics = true,
619 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
620 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
621 .advanced_bt_coexist = true,
622 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
623 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
546}; 624};
547 625
548struct iwl_cfg iwl6000g2b_2bgn_cfg = { 626struct iwl_cfg iwl6000g2b_2bgn_cfg = {
@@ -573,7 +651,7 @@ struct iwl_cfg iwl6000g2b_2bgn_cfg = {
573 .supports_idle = true, 651 .supports_idle = true,
574 .adv_thermal_throttle = true, 652 .adv_thermal_throttle = true,
575 .support_ct_kill_exit = true, 653 .support_ct_kill_exit = true,
576 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 654 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE,
577 .chain_noise_scale = 1000, 655 .chain_noise_scale = 1000,
578 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD, 656 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD,
579 .max_event_log_size = 512, 657 .max_event_log_size = 512,
@@ -581,6 +659,11 @@ struct iwl_cfg iwl6000g2b_2bgn_cfg = {
581 .chain_noise_calib_by_driver = true, 659 .chain_noise_calib_by_driver = true,
582 .need_dc_calib = true, 660 .need_dc_calib = true,
583 .bt_statistics = true, 661 .bt_statistics = true,
662 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
663 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
664 .advanced_bt_coexist = true,
665 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
666 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
584}; 667};
585 668
586struct iwl_cfg iwl6000g2b_2bg_cfg = { 669struct iwl_cfg iwl6000g2b_2bg_cfg = {
@@ -609,7 +692,7 @@ struct iwl_cfg iwl6000g2b_2bg_cfg = {
609 .supports_idle = true, 692 .supports_idle = true,
610 .adv_thermal_throttle = true, 693 .adv_thermal_throttle = true,
611 .support_ct_kill_exit = true, 694 .support_ct_kill_exit = true,
612 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 695 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE,
613 .chain_noise_scale = 1000, 696 .chain_noise_scale = 1000,
614 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD, 697 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD,
615 .max_event_log_size = 512, 698 .max_event_log_size = 512,
@@ -617,6 +700,11 @@ struct iwl_cfg iwl6000g2b_2bg_cfg = {
617 .chain_noise_calib_by_driver = true, 700 .chain_noise_calib_by_driver = true,
618 .need_dc_calib = true, 701 .need_dc_calib = true,
619 .bt_statistics = true, 702 .bt_statistics = true,
703 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
704 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
705 .advanced_bt_coexist = true,
706 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
707 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
620}; 708};
621 709
622struct iwl_cfg iwl6000g2b_bgn_cfg = { 710struct iwl_cfg iwl6000g2b_bgn_cfg = {
@@ -647,7 +735,7 @@ struct iwl_cfg iwl6000g2b_bgn_cfg = {
647 .supports_idle = true, 735 .supports_idle = true,
648 .adv_thermal_throttle = true, 736 .adv_thermal_throttle = true,
649 .support_ct_kill_exit = true, 737 .support_ct_kill_exit = true,
650 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 738 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE,
651 .chain_noise_scale = 1000, 739 .chain_noise_scale = 1000,
652 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD, 740 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD,
653 .max_event_log_size = 512, 741 .max_event_log_size = 512,
@@ -655,6 +743,11 @@ struct iwl_cfg iwl6000g2b_bgn_cfg = {
655 .chain_noise_calib_by_driver = true, 743 .chain_noise_calib_by_driver = true,
656 .need_dc_calib = true, 744 .need_dc_calib = true,
657 .bt_statistics = true, 745 .bt_statistics = true,
746 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
747 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
748 .advanced_bt_coexist = true,
749 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
750 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
658}; 751};
659 752
660struct iwl_cfg iwl6000g2b_bg_cfg = { 753struct iwl_cfg iwl6000g2b_bg_cfg = {
@@ -683,7 +776,7 @@ struct iwl_cfg iwl6000g2b_bg_cfg = {
683 .supports_idle = true, 776 .supports_idle = true,
684 .adv_thermal_throttle = true, 777 .adv_thermal_throttle = true,
685 .support_ct_kill_exit = true, 778 .support_ct_kill_exit = true,
686 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF, 779 .plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DISABLE,
687 .chain_noise_scale = 1000, 780 .chain_noise_scale = 1000,
688 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD, 781 .monitor_recover_period = IWL_LONG_MONITORING_PERIOD,
689 .max_event_log_size = 512, 782 .max_event_log_size = 512,
@@ -691,6 +784,11 @@ struct iwl_cfg iwl6000g2b_bg_cfg = {
691 .chain_noise_calib_by_driver = true, 784 .chain_noise_calib_by_driver = true,
692 .need_dc_calib = true, 785 .need_dc_calib = true,
693 .bt_statistics = true, 786 .bt_statistics = true,
787 /* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
788 .scan_tx_antennas[IEEE80211_BAND_2GHZ] = ANT_A,
789 .advanced_bt_coexist = true,
790 .bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
791 .bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
694}; 792};
695 793
696/* 794/*
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
index c4c5691032a6..84ad62958535 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c
@@ -625,7 +625,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv, void *resp)
625 625
626 data = &(priv->sensitivity_data); 626 data = &(priv->sensitivity_data);
627 627
628 if (!iwl_is_associated(priv)) { 628 if (!iwl_is_any_associated(priv)) {
629 IWL_DEBUG_CALIB(priv, "<< - not associated\n"); 629 IWL_DEBUG_CALIB(priv, "<< - not associated\n");
630 return; 630 return;
631 } 631 }
@@ -763,6 +763,12 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp)
763 unsigned long flags; 763 unsigned long flags;
764 struct statistics_rx_non_phy *rx_info; 764 struct statistics_rx_non_phy *rx_info;
765 u8 first_chain; 765 u8 first_chain;
766 /*
767 * MULTI-FIXME:
768 * When we support multiple interfaces on different channels,
769 * this must be modified/fixed.
770 */
771 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
766 772
767 if (priv->disable_chain_noise_cal) 773 if (priv->disable_chain_noise_cal)
768 return; 774 return;
@@ -793,8 +799,8 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp)
793 return; 799 return;
794 } 800 }
795 801
796 rxon_band24 = !!(priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK); 802 rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK);
797 rxon_chnum = le16_to_cpu(priv->staging_rxon.channel); 803 rxon_chnum = le16_to_cpu(ctx->staging.channel);
798 if (priv->cfg->bt_statistics) { 804 if (priv->cfg->bt_statistics) {
799 stat_band24 = !!(((struct iwl_bt_notif_statistics *) 805 stat_band24 = !!(((struct iwl_bt_notif_statistics *)
800 stat_resp)->flag & 806 stat_resp)->flag &
@@ -914,7 +920,11 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp)
914 * To be safe, simply mask out any chains that we know 920 * To be safe, simply mask out any chains that we know
915 * are not on the device. 921 * are not on the device.
916 */ 922 */
917 active_chains &= priv->hw_params.valid_rx_ant; 923 if (priv->cfg->advanced_bt_coexist && priv->bt_full_concurrent) {
924 /* operated as 1x1 in full concurrency mode */
925 active_chains &= first_antenna(priv->hw_params.valid_rx_ant);
926 } else
927 active_chains &= priv->hw_params.valid_rx_ant;
918 928
919 num_tx_chains = 0; 929 num_tx_chains = 0;
920 for (i = 0; i < NUM_RX_CHAINS; i++) { 930 for (i = 0; i < NUM_RX_CHAINS; i++) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
index 84939763d178..6fb52abafc8d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd.c
@@ -37,12 +37,13 @@
37#include "iwl-io.h" 37#include "iwl-io.h"
38#include "iwl-agn.h" 38#include "iwl-agn.h"
39 39
40int iwlagn_send_rxon_assoc(struct iwl_priv *priv) 40int iwlagn_send_rxon_assoc(struct iwl_priv *priv,
41 struct iwl_rxon_context *ctx)
41{ 42{
42 int ret = 0; 43 int ret = 0;
43 struct iwl5000_rxon_assoc_cmd rxon_assoc; 44 struct iwl5000_rxon_assoc_cmd rxon_assoc;
44 const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon; 45 const struct iwl_rxon_cmd *rxon1 = &ctx->staging;
45 const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon; 46 const struct iwl_rxon_cmd *rxon2 = &ctx->active;
46 47
47 if ((rxon1->flags == rxon2->flags) && 48 if ((rxon1->flags == rxon2->flags) &&
48 (rxon1->filter_flags == rxon2->filter_flags) && 49 (rxon1->filter_flags == rxon2->filter_flags) &&
@@ -60,23 +61,23 @@ int iwlagn_send_rxon_assoc(struct iwl_priv *priv)
60 return 0; 61 return 0;
61 } 62 }
62 63
63 rxon_assoc.flags = priv->staging_rxon.flags; 64 rxon_assoc.flags = ctx->staging.flags;
64 rxon_assoc.filter_flags = priv->staging_rxon.filter_flags; 65 rxon_assoc.filter_flags = ctx->staging.filter_flags;
65 rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates; 66 rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates;
66 rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates; 67 rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates;
67 rxon_assoc.reserved1 = 0; 68 rxon_assoc.reserved1 = 0;
68 rxon_assoc.reserved2 = 0; 69 rxon_assoc.reserved2 = 0;
69 rxon_assoc.reserved3 = 0; 70 rxon_assoc.reserved3 = 0;
70 rxon_assoc.ofdm_ht_single_stream_basic_rates = 71 rxon_assoc.ofdm_ht_single_stream_basic_rates =
71 priv->staging_rxon.ofdm_ht_single_stream_basic_rates; 72 ctx->staging.ofdm_ht_single_stream_basic_rates;
72 rxon_assoc.ofdm_ht_dual_stream_basic_rates = 73 rxon_assoc.ofdm_ht_dual_stream_basic_rates =
73 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates; 74 ctx->staging.ofdm_ht_dual_stream_basic_rates;
74 rxon_assoc.rx_chain_select_flags = priv->staging_rxon.rx_chain; 75 rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain;
75 rxon_assoc.ofdm_ht_triple_stream_basic_rates = 76 rxon_assoc.ofdm_ht_triple_stream_basic_rates =
76 priv->staging_rxon.ofdm_ht_triple_stream_basic_rates; 77 ctx->staging.ofdm_ht_triple_stream_basic_rates;
77 rxon_assoc.acquisition_data = priv->staging_rxon.acquisition_data; 78 rxon_assoc.acquisition_data = ctx->staging.acquisition_data;
78 79
79 ret = iwl_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, 80 ret = iwl_send_cmd_pdu_async(priv, ctx->rxon_assoc_cmd,
80 sizeof(rxon_assoc), &rxon_assoc, NULL); 81 sizeof(rxon_assoc), &rxon_assoc, NULL);
81 if (ret) 82 if (ret)
82 return ret; 83 return ret;
@@ -184,7 +185,7 @@ static void iwlagn_chain_noise_reset(struct iwl_priv *priv)
184 int ret; 185 int ret;
185 186
186 if ((data->state == IWL_CHAIN_NOISE_ALIVE) && 187 if ((data->state == IWL_CHAIN_NOISE_ALIVE) &&
187 iwl_is_associated(priv)) { 188 iwl_is_any_associated(priv)) {
188 struct iwl_calib_chain_noise_reset_cmd cmd; 189 struct iwl_calib_chain_noise_reset_cmd cmd;
189 190
190 /* clear data for chain noise calibration algorithm */ 191 /* clear data for chain noise calibration algorithm */
@@ -269,12 +270,95 @@ static int iwlagn_calc_rssi(struct iwl_priv *priv,
269 return max_rssi - agc - IWLAGN_RSSI_OFFSET; 270 return max_rssi - agc - IWLAGN_RSSI_OFFSET;
270} 271}
271 272
273static int iwlagn_set_pan_params(struct iwl_priv *priv)
274{
275 struct iwl_wipan_params_cmd cmd;
276 struct iwl_rxon_context *ctx_bss, *ctx_pan;
277 int slot0 = 300, slot1 = 0;
278 int ret;
279
280 if (priv->valid_contexts == BIT(IWL_RXON_CTX_BSS))
281 return 0;
282
283 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
284
285 lockdep_assert_held(&priv->mutex);
286
287 ctx_bss = &priv->contexts[IWL_RXON_CTX_BSS];
288 ctx_pan = &priv->contexts[IWL_RXON_CTX_PAN];
289
290 memset(&cmd, 0, sizeof(cmd));
291
292 /* only 2 slots are currently allowed */
293 cmd.num_slots = 2;
294
295 cmd.slots[0].type = 0; /* BSS */
296 cmd.slots[1].type = 1; /* PAN */
297
298 if (ctx_bss->vif && ctx_pan->vif) {
299 int bcnint = ctx_pan->vif->bss_conf.beacon_int;
300
301 /* should be set, but seems unused?? */
302 cmd.flags |= cpu_to_le16(IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE);
303
304 if (ctx_pan->vif->type == NL80211_IFTYPE_AP &&
305 bcnint &&
306 bcnint != ctx_bss->vif->bss_conf.beacon_int) {
307 IWL_ERR(priv,
308 "beacon intervals don't match (%d, %d)\n",
309 ctx_bss->vif->bss_conf.beacon_int,
310 ctx_pan->vif->bss_conf.beacon_int);
311 } else
312 bcnint = max_t(int, bcnint,
313 ctx_bss->vif->bss_conf.beacon_int);
314 if (!bcnint)
315 bcnint = 100;
316 slot0 = bcnint / 2;
317 slot1 = bcnint - slot0;
318
319 if (test_bit(STATUS_SCAN_HW, &priv->status) ||
320 (!ctx_bss->vif->bss_conf.idle &&
321 !ctx_bss->vif->bss_conf.assoc)) {
322 slot0 = bcnint * 3 - 20;
323 slot1 = 20;
324 } else if (!ctx_pan->vif->bss_conf.idle &&
325 !ctx_pan->vif->bss_conf.assoc) {
326 slot1 = bcnint * 3 - 20;
327 slot0 = 20;
328 }
329 } else if (ctx_pan->vif) {
330 slot0 = 0;
331 slot1 = max_t(int, 1, ctx_pan->vif->bss_conf.dtim_period) *
332 ctx_pan->vif->bss_conf.beacon_int;
333 slot1 = max_t(int, 100, slot1);
334 }
335
336 cmd.slots[0].width = cpu_to_le16(slot0);
337 cmd.slots[1].width = cpu_to_le16(slot1);
338
339 ret = iwl_send_cmd_pdu(priv, REPLY_WIPAN_PARAMS, sizeof(cmd), &cmd);
340 if (ret)
341 IWL_ERR(priv, "Error setting PAN parameters (%d)\n", ret);
342
343 return ret;
344}
345
272struct iwl_hcmd_ops iwlagn_hcmd = { 346struct iwl_hcmd_ops iwlagn_hcmd = {
273 .rxon_assoc = iwlagn_send_rxon_assoc, 347 .rxon_assoc = iwlagn_send_rxon_assoc,
274 .commit_rxon = iwl_commit_rxon, 348 .commit_rxon = iwl_commit_rxon,
275 .set_rxon_chain = iwl_set_rxon_chain, 349 .set_rxon_chain = iwl_set_rxon_chain,
276 .set_tx_ant = iwlagn_send_tx_ant_config, 350 .set_tx_ant = iwlagn_send_tx_ant_config,
277 .send_bt_config = iwl_send_bt_config, 351 .send_bt_config = iwl_send_bt_config,
352 .set_pan_params = iwlagn_set_pan_params,
353};
354
355struct iwl_hcmd_ops iwlagn_bt_hcmd = {
356 .rxon_assoc = iwlagn_send_rxon_assoc,
357 .commit_rxon = iwl_commit_rxon,
358 .set_rxon_chain = iwl_set_rxon_chain,
359 .set_tx_ant = iwlagn_send_tx_ant_config,
360 .send_bt_config = iwlagn_send_advance_bt_config,
361 .set_pan_params = iwlagn_set_pan_params,
278}; 362};
279 363
280struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = { 364struct iwl_hcmd_utils_ops iwlagn_hcmd_utils = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index eedd71f5506b..a8f2adfd799e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -247,7 +247,14 @@ static void iwlagn_rx_reply_tx(struct iwl_priv *priv,
247 struct iwl_ht_agg *agg; 247 struct iwl_ht_agg *agg;
248 248
249 agg = &priv->stations[sta_id].tid[tid].agg; 249 agg = &priv->stations[sta_id].tid[tid].agg;
250 250 /*
251 * If the BT kill count is non-zero, we'll get this
252 * notification again.
253 */
254 if (tx_resp->bt_kill_count && tx_resp->frame_count == 1 &&
255 priv->cfg->advanced_bt_coexist) {
256 IWL_WARN(priv, "receive reply tx with bt_kill\n");
257 }
251 iwlagn_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); 258 iwlagn_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index);
252 259
253 /* check if BAR is needed */ 260 /* check if BAR is needed */
@@ -1156,6 +1163,7 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1156 }; 1163 };
1157 struct iwl_scan_cmd *scan; 1164 struct iwl_scan_cmd *scan;
1158 struct ieee80211_conf *conf = NULL; 1165 struct ieee80211_conf *conf = NULL;
1166 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
1159 u32 rate_flags = 0; 1167 u32 rate_flags = 0;
1160 u16 cmd_len; 1168 u16 cmd_len;
1161 u16 rx_chain = 0; 1169 u16 rx_chain = 0;
@@ -1168,6 +1176,9 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1168 u8 active_chains; 1176 u8 active_chains;
1169 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant; 1177 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant;
1170 1178
1179 if (vif)
1180 ctx = iwl_rxon_ctx_from_vif(vif);
1181
1171 conf = ieee80211_get_hw_conf(priv->hw); 1182 conf = ieee80211_get_hw_conf(priv->hw);
1172 1183
1173 cancel_delayed_work(&priv->scan_check); 1184 cancel_delayed_work(&priv->scan_check);
@@ -1225,7 +1236,7 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1225 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 1236 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
1226 scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 1237 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
1227 1238
1228 if (iwl_is_associated(priv)) { 1239 if (iwl_is_any_associated(priv)) {
1229 u16 interval = 0; 1240 u16 interval = 0;
1230 u32 extra; 1241 u32 extra;
1231 u32 suspend_time = 100; 1242 u32 suspend_time = 100;
@@ -1276,13 +1287,15 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1276 IWL_DEBUG_SCAN(priv, "Start passive scan.\n"); 1287 IWL_DEBUG_SCAN(priv, "Start passive scan.\n");
1277 1288
1278 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 1289 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
1279 scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id; 1290 scan->tx_cmd.sta_id = ctx->bcast_sta_id;
1280 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 1291 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
1281 1292
1282 switch (priv->scan_band) { 1293 switch (priv->scan_band) {
1283 case IEEE80211_BAND_2GHZ: 1294 case IEEE80211_BAND_2GHZ:
1284 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 1295 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
1285 chan_mod = le32_to_cpu(priv->active_rxon.flags & RXON_FLG_CHANNEL_MODE_MSK) 1296 chan_mod = le32_to_cpu(
1297 priv->contexts[IWL_RXON_CTX_BSS].active.flags &
1298 RXON_FLG_CHANNEL_MODE_MSK)
1286 >> RXON_FLG_CHANNEL_MODE_POS; 1299 >> RXON_FLG_CHANNEL_MODE_POS;
1287 if (chan_mod == CHANNEL_MODE_PURE_40) { 1300 if (chan_mod == CHANNEL_MODE_PURE_40) {
1288 rate = IWL_RATE_6M_PLCP; 1301 rate = IWL_RATE_6M_PLCP;
@@ -1290,6 +1303,12 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1290 rate = IWL_RATE_1M_PLCP; 1303 rate = IWL_RATE_1M_PLCP;
1291 rate_flags = RATE_MCS_CCK_MSK; 1304 rate_flags = RATE_MCS_CCK_MSK;
1292 } 1305 }
1306 /*
1307 * Internal scans are passive, so we can indiscriminately set
1308 * the BT ignore flag on 2.4 GHz since it applies to TX only.
1309 */
1310 if (priv->cfg->advanced_bt_coexist)
1311 scan->tx_cmd.tx_flags |= TX_CMD_FLG_IGNORE_BT;
1293 scan->good_CRC_th = IWL_GOOD_CRC_TH_DISABLED; 1312 scan->good_CRC_th = IWL_GOOD_CRC_TH_DISABLED;
1294 break; 1313 break;
1295 case IEEE80211_BAND_5GHZ: 1314 case IEEE80211_BAND_5GHZ:
@@ -1327,6 +1346,12 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1327 if (priv->cfg->scan_tx_antennas[band]) 1346 if (priv->cfg->scan_tx_antennas[band])
1328 scan_tx_antennas = priv->cfg->scan_tx_antennas[band]; 1347 scan_tx_antennas = priv->cfg->scan_tx_antennas[band];
1329 1348
1349 if (priv->cfg->advanced_bt_coexist && priv->bt_full_concurrent) {
1350 /* operated as 1x1 in full concurrency mode */
1351 scan_tx_antennas =
1352 first_antenna(priv->cfg->scan_tx_antennas[band]);
1353 }
1354
1330 priv->scan_tx_ant[band] = iwl_toggle_tx_ant(priv, priv->scan_tx_ant[band], 1355 priv->scan_tx_ant[band] = iwl_toggle_tx_ant(priv, priv->scan_tx_ant[band],
1331 scan_tx_antennas); 1356 scan_tx_antennas);
1332 rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]); 1357 rate_flags |= iwl_ant_idx_to_flags(priv->scan_tx_ant[band]);
@@ -1345,6 +1370,11 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1345 1370
1346 rx_ant = first_antenna(active_chains); 1371 rx_ant = first_antenna(active_chains);
1347 } 1372 }
1373 if (priv->cfg->advanced_bt_coexist && priv->bt_full_concurrent) {
1374 /* operated as 1x1 in full concurrency mode */
1375 rx_ant = first_antenna(rx_ant);
1376 }
1377
1348 /* MIMO is not used here, but value is required */ 1378 /* MIMO is not used here, but value is required */
1349 rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; 1379 rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS;
1350 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; 1380 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
@@ -1394,6 +1424,11 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1394 scan->len = cpu_to_le16(cmd.len); 1424 scan->len = cpu_to_le16(cmd.len);
1395 1425
1396 set_bit(STATUS_SCAN_HW, &priv->status); 1426 set_bit(STATUS_SCAN_HW, &priv->status);
1427
1428 if (priv->cfg->ops->hcmd->set_pan_params &&
1429 priv->cfg->ops->hcmd->set_pan_params(priv))
1430 goto done;
1431
1397 if (iwl_send_cmd_sync(priv, &cmd)) 1432 if (iwl_send_cmd_sync(priv, &cmd))
1398 goto done; 1433 goto done;
1399 1434
@@ -1420,7 +1455,8 @@ int iwlagn_manage_ibss_station(struct iwl_priv *priv,
1420 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1455 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1421 1456
1422 if (add) 1457 if (add)
1423 return iwl_add_bssid_station(priv, vif->bss_conf.bssid, true, 1458 return iwl_add_bssid_station(priv, vif_priv->ctx,
1459 vif->bss_conf.bssid, true,
1424 &vif_priv->ibss_bssid_sta_id); 1460 &vif_priv->ibss_bssid_sta_id);
1425 return iwl_remove_station(priv, vif_priv->ibss_bssid_sta_id, 1461 return iwl_remove_station(priv, vif_priv->ibss_bssid_sta_id,
1426 vif->bss_conf.bssid); 1462 vif->bss_conf.bssid);
@@ -1453,7 +1489,7 @@ int iwlagn_wait_tx_queue_empty(struct iwl_priv *priv)
1453 1489
1454 /* waiting for all the tx frames complete might take a while */ 1490 /* waiting for all the tx frames complete might take a while */
1455 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { 1491 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
1456 if (cnt == IWL_CMD_QUEUE_NUM) 1492 if (cnt == priv->cmd_queue)
1457 continue; 1493 continue;
1458 txq = &priv->txq[cnt]; 1494 txq = &priv->txq[cnt];
1459 q = &txq->q; 1495 q = &txq->q;
@@ -1518,3 +1554,377 @@ done:
1518 ieee80211_wake_queues(priv->hw); 1554 ieee80211_wake_queues(priv->hw);
1519 mutex_unlock(&priv->mutex); 1555 mutex_unlock(&priv->mutex);
1520} 1556}
1557
1558/*
1559 * BT coex
1560 */
1561/*
1562 * Macros to access the lookup table.
1563 *
1564 * The lookup table has 7 inputs: bt3_prio, bt3_txrx, bt_rf_act, wifi_req,
1565* wifi_prio, wifi_txrx and wifi_sh_ant_req.
1566 *
1567 * It has three outputs: WLAN_ACTIVE, WLAN_KILL and ANT_SWITCH
1568 *
1569 * The format is that "registers" 8 through 11 contain the WLAN_ACTIVE bits
1570 * one after another in 32-bit registers, and "registers" 0 through 7 contain
1571 * the WLAN_KILL and ANT_SWITCH bits interleaved (in that order).
1572 *
1573 * These macros encode that format.
1574 */
1575#define LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, wifi_req, wifi_prio, \
1576 wifi_txrx, wifi_sh_ant_req) \
1577 (bt3_prio | (bt3_txrx << 1) | (bt_rf_act << 2) | (wifi_req << 3) | \
1578 (wifi_prio << 4) | (wifi_txrx << 5) | (wifi_sh_ant_req << 6))
1579
1580#define LUT_PTA_WLAN_ACTIVE_OP(lut, op, val) \
1581 lut[8 + ((val) >> 5)] op (cpu_to_le32(BIT((val) & 0x1f)))
1582#define LUT_TEST_PTA_WLAN_ACTIVE(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1583 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1584 (!!(LUT_PTA_WLAN_ACTIVE_OP(lut, &, LUT_VALUE(bt3_prio, bt3_txrx, \
1585 bt_rf_act, wifi_req, wifi_prio, wifi_txrx, \
1586 wifi_sh_ant_req))))
1587#define LUT_SET_PTA_WLAN_ACTIVE(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1588 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1589 LUT_PTA_WLAN_ACTIVE_OP(lut, |=, LUT_VALUE(bt3_prio, bt3_txrx, \
1590 bt_rf_act, wifi_req, wifi_prio, wifi_txrx, \
1591 wifi_sh_ant_req))
1592#define LUT_CLEAR_PTA_WLAN_ACTIVE(lut, bt3_prio, bt3_txrx, bt_rf_act, \
1593 wifi_req, wifi_prio, wifi_txrx, \
1594 wifi_sh_ant_req) \
1595 LUT_PTA_WLAN_ACTIVE_OP(lut, &= ~, LUT_VALUE(bt3_prio, bt3_txrx, \
1596 bt_rf_act, wifi_req, wifi_prio, wifi_txrx, \
1597 wifi_sh_ant_req))
1598
1599#define LUT_WLAN_KILL_OP(lut, op, val) \
1600 lut[(val) >> 4] op (cpu_to_le32(BIT(((val) << 1) & 0x1e)))
1601#define LUT_TEST_WLAN_KILL(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1602 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1603 (!!(LUT_WLAN_KILL_OP(lut, &, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
1604 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))))
1605#define LUT_SET_WLAN_KILL(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1606 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1607 LUT_WLAN_KILL_OP(lut, |=, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
1608 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
1609#define LUT_CLEAR_WLAN_KILL(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1610 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1611 LUT_WLAN_KILL_OP(lut, &= ~, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
1612 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
1613
1614#define LUT_ANT_SWITCH_OP(lut, op, val) \
1615 lut[(val) >> 4] op (cpu_to_le32(BIT((((val) << 1) & 0x1e) + 1)))
1616#define LUT_TEST_ANT_SWITCH(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1617 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1618 (!!(LUT_ANT_SWITCH_OP(lut, &, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
1619 wifi_req, wifi_prio, wifi_txrx, \
1620 wifi_sh_ant_req))))
1621#define LUT_SET_ANT_SWITCH(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1622 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1623 LUT_ANT_SWITCH_OP(lut, |=, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
1624 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
1625#define LUT_CLEAR_ANT_SWITCH(lut, bt3_prio, bt3_txrx, bt_rf_act, wifi_req, \
1626 wifi_prio, wifi_txrx, wifi_sh_ant_req) \
1627 LUT_ANT_SWITCH_OP(lut, &= ~, LUT_VALUE(bt3_prio, bt3_txrx, bt_rf_act, \
1628 wifi_req, wifi_prio, wifi_txrx, wifi_sh_ant_req))
1629
1630static const __le32 iwlagn_def_3w_lookup[12] = {
1631 cpu_to_le32(0xaaaaaaaa),
1632 cpu_to_le32(0xaaaaaaaa),
1633 cpu_to_le32(0xaeaaaaaa),
1634 cpu_to_le32(0xaaaaaaaa),
1635 cpu_to_le32(0xcc00ff28),
1636 cpu_to_le32(0x0000aaaa),
1637 cpu_to_le32(0xcc00aaaa),
1638 cpu_to_le32(0x0000aaaa),
1639 cpu_to_le32(0xc0004000),
1640 cpu_to_le32(0x00004000),
1641 cpu_to_le32(0xf0005000),
1642 cpu_to_le32(0xf0004000),
1643};
1644
1645static const __le32 iwlagn_concurrent_lookup[12] = {
1646 cpu_to_le32(0xaaaaaaaa),
1647 cpu_to_le32(0xaaaaaaaa),
1648 cpu_to_le32(0xaaaaaaaa),
1649 cpu_to_le32(0xaaaaaaaa),
1650 cpu_to_le32(0xaaaaaaaa),
1651 cpu_to_le32(0xaaaaaaaa),
1652 cpu_to_le32(0xaaaaaaaa),
1653 cpu_to_le32(0xaaaaaaaa),
1654 cpu_to_le32(0x00000000),
1655 cpu_to_le32(0x00000000),
1656 cpu_to_le32(0x00000000),
1657 cpu_to_le32(0x00000000),
1658};
1659
1660void iwlagn_send_advance_bt_config(struct iwl_priv *priv)
1661{
1662 struct iwlagn_bt_cmd bt_cmd = {
1663 .max_kill = IWLAGN_BT_MAX_KILL_DEFAULT,
1664 .bt3_timer_t7_value = IWLAGN_BT3_T7_DEFAULT,
1665 .bt3_prio_sample_time = IWLAGN_BT3_PRIO_SAMPLE_DEFAULT,
1666 .bt3_timer_t2_value = IWLAGN_BT3_T2_DEFAULT,
1667 };
1668
1669 BUILD_BUG_ON(sizeof(iwlagn_def_3w_lookup) !=
1670 sizeof(bt_cmd.bt3_lookup_table));
1671
1672 bt_cmd.prio_boost = priv->cfg->bt_prio_boost;
1673 bt_cmd.kill_ack_mask = priv->kill_ack_mask;
1674 bt_cmd.kill_cts_mask = priv->kill_cts_mask;
1675 bt_cmd.valid = priv->bt_valid;
1676
1677 /*
1678 * Configure BT coex mode to "no coexistence" when the
1679 * user disabled BT coexistence, we have no interface
1680 * (might be in monitor mode), or the interface is in
1681 * IBSS mode (no proper uCode support for coex then).
1682 */
1683 if (!bt_coex_active || priv->iw_mode == NL80211_IFTYPE_ADHOC) {
1684 bt_cmd.flags = 0;
1685 } else {
1686 bt_cmd.flags = IWLAGN_BT_FLAG_COEX_MODE_3W <<
1687 IWLAGN_BT_FLAG_COEX_MODE_SHIFT;
1688 if (priv->bt_ch_announce)
1689 bt_cmd.flags |= IWLAGN_BT_FLAG_CHANNEL_INHIBITION;
1690 IWL_DEBUG_INFO(priv, "BT coex flag: 0X%x\n", bt_cmd.flags);
1691 }
1692 if (priv->bt_full_concurrent)
1693 memcpy(bt_cmd.bt3_lookup_table, iwlagn_concurrent_lookup,
1694 sizeof(iwlagn_concurrent_lookup));
1695 else
1696 memcpy(bt_cmd.bt3_lookup_table, iwlagn_def_3w_lookup,
1697 sizeof(iwlagn_def_3w_lookup));
1698
1699 IWL_DEBUG_INFO(priv, "BT coex %s in %s mode\n",
1700 bt_cmd.flags ? "active" : "disabled",
1701 priv->bt_full_concurrent ?
1702 "full concurrency" : "3-wire");
1703
1704 if (iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG, sizeof(bt_cmd), &bt_cmd))
1705 IWL_ERR(priv, "failed to send BT Coex Config\n");
1706
1707 /*
1708 * When we are doing a restart, need to also reconfigure BT
1709 * SCO to the device. If not doing a restart, bt_sco_active
1710 * will always be false, so there's no need to have an extra
1711 * variable to check for it.
1712 */
1713 if (priv->bt_sco_active) {
1714 struct iwlagn_bt_sco_cmd sco_cmd = { .flags = 0 };
1715
1716 if (priv->bt_sco_active)
1717 sco_cmd.flags |= IWLAGN_BT_SCO_ACTIVE;
1718 if (iwl_send_cmd_pdu(priv, REPLY_BT_COEX_SCO,
1719 sizeof(sco_cmd), &sco_cmd))
1720 IWL_ERR(priv, "failed to send BT SCO command\n");
1721 }
1722}
1723
1724static void iwlagn_bt_traffic_change_work(struct work_struct *work)
1725{
1726 struct iwl_priv *priv =
1727 container_of(work, struct iwl_priv, bt_traffic_change_work);
1728 struct iwl_rxon_context *ctx;
1729 int smps_request = -1;
1730
1731 IWL_DEBUG_INFO(priv, "BT traffic load changes: %d\n",
1732 priv->bt_traffic_load);
1733
1734 switch (priv->bt_traffic_load) {
1735 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
1736 smps_request = IEEE80211_SMPS_AUTOMATIC;
1737 break;
1738 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
1739 smps_request = IEEE80211_SMPS_DYNAMIC;
1740 break;
1741 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
1742 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
1743 smps_request = IEEE80211_SMPS_STATIC;
1744 break;
1745 default:
1746 IWL_ERR(priv, "Invalid BT traffic load: %d\n",
1747 priv->bt_traffic_load);
1748 break;
1749 }
1750
1751 mutex_lock(&priv->mutex);
1752
1753 if (priv->cfg->ops->lib->update_chain_flags)
1754 priv->cfg->ops->lib->update_chain_flags(priv);
1755
1756 if (smps_request != -1) {
1757 for_each_context(priv, ctx) {
1758 if (ctx->vif && ctx->vif->type == NL80211_IFTYPE_STATION)
1759 ieee80211_request_smps(ctx->vif, smps_request);
1760 }
1761 }
1762
1763 mutex_unlock(&priv->mutex);
1764}
1765
1766static void iwlagn_print_uartmsg(struct iwl_priv *priv,
1767 struct iwl_bt_uart_msg *uart_msg)
1768{
1769 IWL_DEBUG_NOTIF(priv, "Message Type = 0x%X, SSN = 0x%X, "
1770 "Update Req = 0x%X",
1771 (BT_UART_MSG_FRAME1MSGTYPE_MSK & uart_msg->frame1) >>
1772 BT_UART_MSG_FRAME1MSGTYPE_POS,
1773 (BT_UART_MSG_FRAME1SSN_MSK & uart_msg->frame1) >>
1774 BT_UART_MSG_FRAME1SSN_POS,
1775 (BT_UART_MSG_FRAME1UPDATEREQ_MSK & uart_msg->frame1) >>
1776 BT_UART_MSG_FRAME1UPDATEREQ_POS);
1777
1778 IWL_DEBUG_NOTIF(priv, "Open connections = 0x%X, Traffic load = 0x%X, "
1779 "Chl_SeqN = 0x%X, In band = 0x%X",
1780 (BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK & uart_msg->frame2) >>
1781 BT_UART_MSG_FRAME2OPENCONNECTIONS_POS,
1782 (BT_UART_MSG_FRAME2TRAFFICLOAD_MSK & uart_msg->frame2) >>
1783 BT_UART_MSG_FRAME2TRAFFICLOAD_POS,
1784 (BT_UART_MSG_FRAME2CHLSEQN_MSK & uart_msg->frame2) >>
1785 BT_UART_MSG_FRAME2CHLSEQN_POS,
1786 (BT_UART_MSG_FRAME2INBAND_MSK & uart_msg->frame2) >>
1787 BT_UART_MSG_FRAME2INBAND_POS);
1788
1789 IWL_DEBUG_NOTIF(priv, "SCO/eSCO = 0x%X, Sniff = 0x%X, A2DP = 0x%X, "
1790 "ACL = 0x%X, Master = 0x%X, OBEX = 0x%X",
1791 (BT_UART_MSG_FRAME3SCOESCO_MSK & uart_msg->frame3) >>
1792 BT_UART_MSG_FRAME3SCOESCO_POS,
1793 (BT_UART_MSG_FRAME3SNIFF_MSK & uart_msg->frame3) >>
1794 BT_UART_MSG_FRAME3SNIFF_POS,
1795 (BT_UART_MSG_FRAME3A2DP_MSK & uart_msg->frame3) >>
1796 BT_UART_MSG_FRAME3A2DP_POS,
1797 (BT_UART_MSG_FRAME3ACL_MSK & uart_msg->frame3) >>
1798 BT_UART_MSG_FRAME3ACL_POS,
1799 (BT_UART_MSG_FRAME3MASTER_MSK & uart_msg->frame3) >>
1800 BT_UART_MSG_FRAME3MASTER_POS,
1801 (BT_UART_MSG_FRAME3OBEX_MSK & uart_msg->frame3) >>
1802 BT_UART_MSG_FRAME3OBEX_POS);
1803
1804 IWL_DEBUG_NOTIF(priv, "Idle duration = 0x%X",
1805 (BT_UART_MSG_FRAME4IDLEDURATION_MSK & uart_msg->frame4) >>
1806 BT_UART_MSG_FRAME4IDLEDURATION_POS);
1807
1808 IWL_DEBUG_NOTIF(priv, "Tx Activity = 0x%X, Rx Activity = 0x%X, "
1809 "eSCO Retransmissions = 0x%X",
1810 (BT_UART_MSG_FRAME5TXACTIVITY_MSK & uart_msg->frame5) >>
1811 BT_UART_MSG_FRAME5TXACTIVITY_POS,
1812 (BT_UART_MSG_FRAME5RXACTIVITY_MSK & uart_msg->frame5) >>
1813 BT_UART_MSG_FRAME5RXACTIVITY_POS,
1814 (BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK & uart_msg->frame5) >>
1815 BT_UART_MSG_FRAME5ESCORETRANSMIT_POS);
1816
1817 IWL_DEBUG_NOTIF(priv, "Sniff Interval = 0x%X, Discoverable = 0x%X",
1818 (BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK & uart_msg->frame6) >>
1819 BT_UART_MSG_FRAME6SNIFFINTERVAL_POS,
1820 (BT_UART_MSG_FRAME6DISCOVERABLE_MSK & uart_msg->frame6) >>
1821 BT_UART_MSG_FRAME6DISCOVERABLE_POS);
1822
1823 IWL_DEBUG_NOTIF(priv, "Sniff Activity = 0x%X, Inquiry/Page SR Mode = "
1824 "0x%X, Connectable = 0x%X",
1825 (BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK & uart_msg->frame7) >>
1826 BT_UART_MSG_FRAME7SNIFFACTIVITY_POS,
1827 (BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_MSK & uart_msg->frame7) >>
1828 BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS,
1829 (BT_UART_MSG_FRAME7CONNECTABLE_MSK & uart_msg->frame7) >>
1830 BT_UART_MSG_FRAME7CONNECTABLE_POS);
1831}
1832
1833static void iwlagn_set_kill_ack_msk(struct iwl_priv *priv,
1834 struct iwl_bt_uart_msg *uart_msg)
1835{
1836 u8 kill_ack_msk;
1837 __le32 bt_kill_ack_msg[2] = {
1838 cpu_to_le32(0xFFFFFFF), cpu_to_le32(0xFFFFFC00) };
1839
1840 kill_ack_msk = (((BT_UART_MSG_FRAME3A2DP_MSK |
1841 BT_UART_MSG_FRAME3SNIFF_MSK |
1842 BT_UART_MSG_FRAME3SCOESCO_MSK) &
1843 uart_msg->frame3) == 0) ? 1 : 0;
1844 if (priv->kill_ack_mask != bt_kill_ack_msg[kill_ack_msk]) {
1845 priv->bt_valid |= IWLAGN_BT_VALID_KILL_ACK_MASK;
1846 priv->kill_ack_mask = bt_kill_ack_msg[kill_ack_msk];
1847 /* schedule to send runtime bt_config */
1848 queue_work(priv->workqueue, &priv->bt_runtime_config);
1849 }
1850
1851}
1852
1853void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
1854 struct iwl_rx_mem_buffer *rxb)
1855{
1856 unsigned long flags;
1857 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1858 struct iwl_bt_coex_profile_notif *coex = &pkt->u.bt_coex_profile_notif;
1859 struct iwlagn_bt_sco_cmd sco_cmd = { .flags = 0 };
1860 struct iwl_bt_uart_msg *uart_msg = &coex->last_bt_uart_msg;
1861 u8 last_traffic_load;
1862
1863 IWL_DEBUG_NOTIF(priv, "BT Coex notification:\n");
1864 IWL_DEBUG_NOTIF(priv, " status: %d\n", coex->bt_status);
1865 IWL_DEBUG_NOTIF(priv, " traffic load: %d\n", coex->bt_traffic_load);
1866 IWL_DEBUG_NOTIF(priv, " CI compliance: %d\n",
1867 coex->bt_ci_compliance);
1868 iwlagn_print_uartmsg(priv, uart_msg);
1869
1870 last_traffic_load = priv->notif_bt_traffic_load;
1871 priv->notif_bt_traffic_load = coex->bt_traffic_load;
1872 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
1873 if (priv->bt_status != coex->bt_status ||
1874 last_traffic_load != coex->bt_traffic_load) {
1875 if (coex->bt_status) {
1876 /* BT on */
1877 if (!priv->bt_ch_announce)
1878 priv->bt_traffic_load =
1879 IWL_BT_COEX_TRAFFIC_LOAD_HIGH;
1880 else
1881 priv->bt_traffic_load =
1882 coex->bt_traffic_load;
1883 } else {
1884 /* BT off */
1885 priv->bt_traffic_load =
1886 IWL_BT_COEX_TRAFFIC_LOAD_NONE;
1887 }
1888 priv->bt_status = coex->bt_status;
1889 queue_work(priv->workqueue,
1890 &priv->bt_traffic_change_work);
1891 }
1892 if (priv->bt_sco_active !=
1893 (uart_msg->frame3 & BT_UART_MSG_FRAME3SCOESCO_MSK)) {
1894 priv->bt_sco_active = uart_msg->frame3 &
1895 BT_UART_MSG_FRAME3SCOESCO_MSK;
1896 if (priv->bt_sco_active)
1897 sco_cmd.flags |= IWLAGN_BT_SCO_ACTIVE;
1898 iwl_send_cmd_pdu_async(priv, REPLY_BT_COEX_SCO,
1899 sizeof(sco_cmd), &sco_cmd, NULL);
1900 }
1901 }
1902
1903 iwlagn_set_kill_ack_msk(priv, uart_msg);
1904
1905 /* FIXME: based on notification, adjust the prio_boost */
1906
1907 spin_lock_irqsave(&priv->lock, flags);
1908 priv->bt_ci_compliance = coex->bt_ci_compliance;
1909 spin_unlock_irqrestore(&priv->lock, flags);
1910}
1911
1912void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv)
1913{
1914 iwlagn_rx_handler_setup(priv);
1915 priv->rx_handlers[REPLY_BT_COEX_PROFILE_NOTIF] =
1916 iwlagn_bt_coex_profile_notif;
1917}
1918
1919void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv)
1920{
1921 iwlagn_setup_deferred_work(priv);
1922
1923 INIT_WORK(&priv->bt_traffic_change_work,
1924 iwlagn_bt_traffic_change_work);
1925}
1926
1927void iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv)
1928{
1929 cancel_work_sync(&priv->bt_traffic_change_work);
1930}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index a4563389bad0..57629fba3a7d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -82,7 +82,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
82 struct iwl_lq_sta *lq_sta); 82 struct iwl_lq_sta *lq_sta);
83static void rs_fill_link_cmd(struct iwl_priv *priv, 83static void rs_fill_link_cmd(struct iwl_priv *priv,
84 struct iwl_lq_sta *lq_sta, u32 rate_n_flags); 84 struct iwl_lq_sta *lq_sta, u32 rate_n_flags);
85static void rs_stay_in_table(struct iwl_lq_sta *lq_sta); 85static void rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search);
86 86
87 87
88#ifdef CONFIG_MAC80211_DEBUGFS 88#ifdef CONFIG_MAC80211_DEBUGFS
@@ -301,7 +301,19 @@ static int rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
301 struct ieee80211_sta *sta) 301 struct ieee80211_sta *sta)
302{ 302{
303 int ret = -EAGAIN; 303 int ret = -EAGAIN;
304 u32 load = rs_tl_get_load(lq_data, tid); 304 u32 load;
305
306 /*
307 * Don't create TX aggregation sessions when in high
308 * BT traffic, as they would just be disrupted by BT.
309 */
310 if (priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) {
311 IWL_ERR(priv, "BT traffic (%d), no aggregation allowed\n",
312 priv->bt_traffic_load);
313 return ret;
314 }
315
316 load = rs_tl_get_load(lq_data, tid);
305 317
306 if (load > IWL_AGG_LOAD_THRESHOLD) { 318 if (load > IWL_AGG_LOAD_THRESHOLD) {
307 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", 319 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n",
@@ -590,11 +602,13 @@ static int rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags,
590 * Green-field mode is valid if the station supports it and 602 * Green-field mode is valid if the station supports it and
591 * there are no non-GF stations present in the BSS. 603 * there are no non-GF stations present in the BSS.
592 */ 604 */
593static inline u8 rs_use_green(struct ieee80211_sta *sta, 605static bool rs_use_green(struct ieee80211_sta *sta)
594 struct iwl_ht_config *ht_conf)
595{ 606{
607 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
608 struct iwl_rxon_context *ctx = sta_priv->common.ctx;
609
596 return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && 610 return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) &&
597 !(ht_conf->non_GF_STA_present); 611 !(ctx->ht.non_gf_sta_present);
598} 612}
599 613
600/** 614/**
@@ -746,6 +760,32 @@ static bool table_type_matches(struct iwl_scale_tbl_info *a,
746 (a->is_SGI == b->is_SGI); 760 (a->is_SGI == b->is_SGI);
747} 761}
748 762
763static void rs_bt_update_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
764 struct iwl_lq_sta *lq_sta)
765{
766 struct iwl_scale_tbl_info *tbl;
767 bool full_concurrent;
768 unsigned long flags;
769
770 spin_lock_irqsave(&priv->lock, flags);
771 if (priv->bt_ci_compliance && priv->bt_ant_couple_ok)
772 full_concurrent = true;
773 else
774 full_concurrent = false;
775 spin_unlock_irqrestore(&priv->lock, flags);
776
777 if (priv->bt_full_concurrent != full_concurrent) {
778 priv->bt_full_concurrent = full_concurrent;
779
780 /* Update uCode's rate table. */
781 tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
782 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate);
783 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false);
784
785 queue_work(priv->workqueue, &priv->bt_full_concurrency);
786 }
787}
788
749/* 789/*
750 * mac80211 sends us Tx status 790 * mac80211 sends us Tx status
751 */ 791 */
@@ -765,6 +805,8 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
765 u32 tx_rate; 805 u32 tx_rate;
766 struct iwl_scale_tbl_info tbl_type; 806 struct iwl_scale_tbl_info tbl_type;
767 struct iwl_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; 807 struct iwl_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl;
808 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
809 struct iwl_rxon_context *ctx = sta_priv->common.ctx;
768 810
769 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); 811 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n");
770 812
@@ -831,7 +873,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
831 lq_sta->missed_rate_counter++; 873 lq_sta->missed_rate_counter++;
832 if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { 874 if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) {
833 lq_sta->missed_rate_counter = 0; 875 lq_sta->missed_rate_counter = 0;
834 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false); 876 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false);
835 } 877 }
836 /* Regardless, ignore this status info for outdated rate */ 878 /* Regardless, ignore this status info for outdated rate */
837 return; 879 return;
@@ -862,7 +904,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
862 * no matching table found, let's by-pass the data collection 904 * no matching table found, let's by-pass the data collection
863 * and continue to perform rate scale to find the rate table 905 * and continue to perform rate scale to find the rate table
864 */ 906 */
865 rs_stay_in_table(lq_sta); 907 rs_stay_in_table(lq_sta, true);
866 goto done; 908 goto done;
867 } 909 }
868 910
@@ -928,6 +970,10 @@ done:
928 /* See if there's a better rate or modulation mode to try. */ 970 /* See if there's a better rate or modulation mode to try. */
929 if (sta && sta->supp_rates[sband->band]) 971 if (sta && sta->supp_rates[sband->band])
930 rs_rate_scale_perform(priv, skb, sta, lq_sta); 972 rs_rate_scale_perform(priv, skb, sta, lq_sta);
973
974 /* Is there a need to switch between full concurrency and 3-wire? */
975 if (priv->bt_ant_couple_ok)
976 rs_bt_update_lq(priv, ctx, lq_sta);
931} 977}
932 978
933/* 979/*
@@ -1121,6 +1167,8 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1121 u16 rate_mask; 1167 u16 rate_mask;
1122 s32 rate; 1168 s32 rate;
1123 s8 is_green = lq_sta->is_green; 1169 s8 is_green = lq_sta->is_green;
1170 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
1171 struct iwl_rxon_context *ctx = sta_priv->common.ctx;
1124 1172
1125 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) 1173 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported)
1126 return -1; 1174 return -1;
@@ -1141,7 +1189,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1141 tbl->max_search = IWL_MAX_SEARCH; 1189 tbl->max_search = IWL_MAX_SEARCH;
1142 rate_mask = lq_sta->active_mimo2_rate; 1190 rate_mask = lq_sta->active_mimo2_rate;
1143 1191
1144 if (iwl_is_ht40_tx_allowed(priv, &sta->ht_cap)) 1192 if (iwl_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap))
1145 tbl->is_ht40 = 1; 1193 tbl->is_ht40 = 1;
1146 else 1194 else
1147 tbl->is_ht40 = 0; 1195 tbl->is_ht40 = 0;
@@ -1175,6 +1223,8 @@ static int rs_switch_to_mimo3(struct iwl_priv *priv,
1175 u16 rate_mask; 1223 u16 rate_mask;
1176 s32 rate; 1224 s32 rate;
1177 s8 is_green = lq_sta->is_green; 1225 s8 is_green = lq_sta->is_green;
1226 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
1227 struct iwl_rxon_context *ctx = sta_priv->common.ctx;
1178 1228
1179 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) 1229 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported)
1180 return -1; 1230 return -1;
@@ -1195,7 +1245,7 @@ static int rs_switch_to_mimo3(struct iwl_priv *priv,
1195 tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH; 1245 tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH;
1196 rate_mask = lq_sta->active_mimo3_rate; 1246 rate_mask = lq_sta->active_mimo3_rate;
1197 1247
1198 if (iwl_is_ht40_tx_allowed(priv, &sta->ht_cap)) 1248 if (iwl_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap))
1199 tbl->is_ht40 = 1; 1249 tbl->is_ht40 = 1;
1200 else 1250 else
1201 tbl->is_ht40 = 0; 1251 tbl->is_ht40 = 0;
@@ -1230,6 +1280,8 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1230 u16 rate_mask; 1280 u16 rate_mask;
1231 u8 is_green = lq_sta->is_green; 1281 u8 is_green = lq_sta->is_green;
1232 s32 rate; 1282 s32 rate;
1283 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
1284 struct iwl_rxon_context *ctx = sta_priv->common.ctx;
1233 1285
1234 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) 1286 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported)
1235 return -1; 1287 return -1;
@@ -1242,7 +1294,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1242 tbl->max_search = IWL_MAX_SEARCH; 1294 tbl->max_search = IWL_MAX_SEARCH;
1243 rate_mask = lq_sta->active_siso_rate; 1295 rate_mask = lq_sta->active_siso_rate;
1244 1296
1245 if (iwl_is_ht40_tx_allowed(priv, &sta->ht_cap)) 1297 if (iwl_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap))
1246 tbl->is_ht40 = 1; 1298 tbl->is_ht40 = 1;
1247 else 1299 else
1248 tbl->is_ht40 = 0; 1300 tbl->is_ht40 = 0;
@@ -1286,12 +1338,45 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1286 int ret = 0; 1338 int ret = 0;
1287 u8 update_search_tbl_counter = 0; 1339 u8 update_search_tbl_counter = 0;
1288 1340
1341 switch (priv->bt_traffic_load) {
1342 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
1343 /* nothing */
1344 break;
1345 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
1346 /* avoid antenna B unless MIMO */
1347 valid_tx_ant = first_antenna(priv->hw_params.valid_tx_ant);
1348 if (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2)
1349 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
1350 break;
1351 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
1352 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
1353 /* avoid antenna B and MIMO */
1354 valid_tx_ant = first_antenna(priv->hw_params.valid_tx_ant);
1355 if (tbl->action >= IWL_LEGACY_SWITCH_ANTENNA2 &&
1356 tbl->action != IWL_LEGACY_SWITCH_SISO)
1357 tbl->action = IWL_LEGACY_SWITCH_SISO;
1358 break;
1359 default:
1360 IWL_ERR(priv, "Invalid BT load %d", priv->bt_traffic_load);
1361 break;
1362 }
1363
1289 if (!iwl_ht_enabled(priv)) 1364 if (!iwl_ht_enabled(priv))
1290 /* stay in Legacy */ 1365 /* stay in Legacy */
1291 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; 1366 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
1292 else if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE && 1367 else if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE &&
1293 tbl->action > IWL_LEGACY_SWITCH_SISO) 1368 tbl->action > IWL_LEGACY_SWITCH_SISO)
1294 tbl->action = IWL_LEGACY_SWITCH_SISO; 1369 tbl->action = IWL_LEGACY_SWITCH_SISO;
1370
1371 /* configure as 1x1 if bt full concurrency */
1372 if (priv->bt_full_concurrent) {
1373 if (!iwl_ht_enabled(priv))
1374 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
1375 else if (tbl->action >= IWL_LEGACY_SWITCH_ANTENNA2)
1376 tbl->action = IWL_LEGACY_SWITCH_SISO;
1377 valid_tx_ant = first_antenna(priv->hw_params.valid_tx_ant);
1378 }
1379
1295 start_action = tbl->action; 1380 start_action = tbl->action;
1296 for (; ;) { 1381 for (; ;) {
1297 lq_sta->action_counter++; 1382 lq_sta->action_counter++;
@@ -1307,7 +1392,10 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1307 break; 1392 break;
1308 1393
1309 /* Don't change antenna if success has been great */ 1394 /* Don't change antenna if success has been great */
1310 if (window->success_ratio >= IWL_RS_GOOD_RATIO) 1395 if (window->success_ratio >= IWL_RS_GOOD_RATIO &&
1396 !priv->bt_full_concurrent &&
1397 priv->bt_traffic_load ==
1398 IWL_BT_COEX_TRAFFIC_LOAD_NONE)
1311 break; 1399 break;
1312 1400
1313 /* Set up search table to try other antenna */ 1401 /* Set up search table to try other antenna */
@@ -1425,11 +1513,41 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1425 u8 update_search_tbl_counter = 0; 1513 u8 update_search_tbl_counter = 0;
1426 int ret; 1514 int ret;
1427 1515
1516 switch (priv->bt_traffic_load) {
1517 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
1518 /* nothing */
1519 break;
1520 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
1521 /* avoid antenna B unless MIMO */
1522 valid_tx_ant = first_antenna(priv->hw_params.valid_tx_ant);
1523 if (tbl->action == IWL_SISO_SWITCH_ANTENNA2)
1524 tbl->action = IWL_SISO_SWITCH_ANTENNA1;
1525 break;
1526 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
1527 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
1528 /* avoid antenna B and MIMO */
1529 valid_tx_ant = first_antenna(priv->hw_params.valid_tx_ant);
1530 if (tbl->action != IWL_SISO_SWITCH_ANTENNA1)
1531 tbl->action = IWL_SISO_SWITCH_ANTENNA1;
1532 break;
1533 default:
1534 IWL_ERR(priv, "Invalid BT load %d", priv->bt_traffic_load);
1535 break;
1536 }
1537
1428 if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE && 1538 if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE &&
1429 tbl->action > IWL_SISO_SWITCH_ANTENNA2) { 1539 tbl->action > IWL_SISO_SWITCH_ANTENNA2) {
1430 /* stay in SISO */ 1540 /* stay in SISO */
1431 tbl->action = IWL_SISO_SWITCH_ANTENNA1; 1541 tbl->action = IWL_SISO_SWITCH_ANTENNA1;
1432 } 1542 }
1543
1544 /* configure as 1x1 if bt full concurrency */
1545 if (priv->bt_full_concurrent) {
1546 valid_tx_ant = first_antenna(priv->hw_params.valid_tx_ant);
1547 if (tbl->action >= IWL_LEGACY_SWITCH_ANTENNA2)
1548 tbl->action = IWL_SISO_SWITCH_ANTENNA1;
1549 }
1550
1433 start_action = tbl->action; 1551 start_action = tbl->action;
1434 for (;;) { 1552 for (;;) {
1435 lq_sta->action_counter++; 1553 lq_sta->action_counter++;
@@ -1437,14 +1555,16 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1437 case IWL_SISO_SWITCH_ANTENNA1: 1555 case IWL_SISO_SWITCH_ANTENNA1:
1438 case IWL_SISO_SWITCH_ANTENNA2: 1556 case IWL_SISO_SWITCH_ANTENNA2:
1439 IWL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); 1557 IWL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n");
1440
1441 if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 && 1558 if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 &&
1442 tx_chains_num <= 1) || 1559 tx_chains_num <= 1) ||
1443 (tbl->action == IWL_SISO_SWITCH_ANTENNA2 && 1560 (tbl->action == IWL_SISO_SWITCH_ANTENNA2 &&
1444 tx_chains_num <= 2)) 1561 tx_chains_num <= 2))
1445 break; 1562 break;
1446 1563
1447 if (window->success_ratio >= IWL_RS_GOOD_RATIO) 1564 if (window->success_ratio >= IWL_RS_GOOD_RATIO &&
1565 !priv->bt_full_concurrent &&
1566 priv->bt_traffic_load ==
1567 IWL_BT_COEX_TRAFFIC_LOAD_NONE)
1448 break; 1568 break;
1449 1569
1450 memcpy(search_tbl, tbl, sz); 1570 memcpy(search_tbl, tbl, sz);
@@ -1564,12 +1684,40 @@ static int rs_move_mimo2_to_other(struct iwl_priv *priv,
1564 u8 update_search_tbl_counter = 0; 1684 u8 update_search_tbl_counter = 0;
1565 int ret; 1685 int ret;
1566 1686
1687 switch (priv->bt_traffic_load) {
1688 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
1689 /* nothing */
1690 break;
1691 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
1692 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
1693 /* avoid antenna B and MIMO */
1694 if (tbl->action != IWL_MIMO2_SWITCH_SISO_A)
1695 tbl->action = IWL_MIMO2_SWITCH_SISO_A;
1696 break;
1697 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
1698 /* avoid antenna B unless MIMO */
1699 if (tbl->action == IWL_MIMO2_SWITCH_SISO_B ||
1700 tbl->action == IWL_MIMO2_SWITCH_SISO_C)
1701 tbl->action = IWL_MIMO2_SWITCH_SISO_A;
1702 break;
1703 default:
1704 IWL_ERR(priv, "Invalid BT load %d", priv->bt_traffic_load);
1705 break;
1706 }
1707
1567 if ((iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE) && 1708 if ((iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE) &&
1568 (tbl->action < IWL_MIMO2_SWITCH_SISO_A || 1709 (tbl->action < IWL_MIMO2_SWITCH_SISO_A ||
1569 tbl->action > IWL_MIMO2_SWITCH_SISO_C)) { 1710 tbl->action > IWL_MIMO2_SWITCH_SISO_C)) {
1570 /* switch in SISO */ 1711 /* switch in SISO */
1571 tbl->action = IWL_MIMO2_SWITCH_SISO_A; 1712 tbl->action = IWL_MIMO2_SWITCH_SISO_A;
1572 } 1713 }
1714
1715 /* configure as 1x1 if bt full concurrency */
1716 if (priv->bt_full_concurrent &&
1717 (tbl->action < IWL_MIMO2_SWITCH_SISO_A ||
1718 tbl->action > IWL_MIMO2_SWITCH_SISO_C))
1719 tbl->action = IWL_MIMO2_SWITCH_SISO_A;
1720
1573 start_action = tbl->action; 1721 start_action = tbl->action;
1574 for (;;) { 1722 for (;;) {
1575 lq_sta->action_counter++; 1723 lq_sta->action_counter++;
@@ -1706,12 +1854,40 @@ static int rs_move_mimo3_to_other(struct iwl_priv *priv,
1706 int ret; 1854 int ret;
1707 u8 update_search_tbl_counter = 0; 1855 u8 update_search_tbl_counter = 0;
1708 1856
1857 switch (priv->bt_traffic_load) {
1858 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
1859 /* nothing */
1860 break;
1861 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
1862 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
1863 /* avoid antenna B and MIMO */
1864 if (tbl->action != IWL_MIMO3_SWITCH_SISO_A)
1865 tbl->action = IWL_MIMO3_SWITCH_SISO_A;
1866 break;
1867 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
1868 /* avoid antenna B unless MIMO */
1869 if (tbl->action == IWL_MIMO3_SWITCH_SISO_B ||
1870 tbl->action == IWL_MIMO3_SWITCH_SISO_C)
1871 tbl->action = IWL_MIMO3_SWITCH_SISO_A;
1872 break;
1873 default:
1874 IWL_ERR(priv, "Invalid BT load %d", priv->bt_traffic_load);
1875 break;
1876 }
1877
1709 if ((iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE) && 1878 if ((iwl_tx_ant_restriction(priv) == IWL_ANT_OK_SINGLE) &&
1710 (tbl->action < IWL_MIMO3_SWITCH_SISO_A || 1879 (tbl->action < IWL_MIMO3_SWITCH_SISO_A ||
1711 tbl->action > IWL_MIMO3_SWITCH_SISO_C)) { 1880 tbl->action > IWL_MIMO3_SWITCH_SISO_C)) {
1712 /* switch in SISO */ 1881 /* switch in SISO */
1713 tbl->action = IWL_MIMO3_SWITCH_SISO_A; 1882 tbl->action = IWL_MIMO3_SWITCH_SISO_A;
1714 } 1883 }
1884
1885 /* configure as 1x1 if bt full concurrency */
1886 if (priv->bt_full_concurrent &&
1887 (tbl->action < IWL_MIMO3_SWITCH_SISO_A ||
1888 tbl->action > IWL_MIMO3_SWITCH_SISO_C))
1889 tbl->action = IWL_MIMO3_SWITCH_SISO_A;
1890
1715 start_action = tbl->action; 1891 start_action = tbl->action;
1716 for (;;) { 1892 for (;;) {
1717 lq_sta->action_counter++; 1893 lq_sta->action_counter++;
@@ -1839,7 +2015,7 @@ static int rs_move_mimo3_to_other(struct iwl_priv *priv,
1839 * 2) # times calling this function 2015 * 2) # times calling this function
1840 * 3) elapsed time in this mode (not used, for now) 2016 * 3) elapsed time in this mode (not used, for now)
1841 */ 2017 */
1842static void rs_stay_in_table(struct iwl_lq_sta *lq_sta) 2018static void rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search)
1843{ 2019{
1844 struct iwl_scale_tbl_info *tbl; 2020 struct iwl_scale_tbl_info *tbl;
1845 int i; 2021 int i;
@@ -1870,7 +2046,8 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta)
1870 * allow a new search. Also (below) reset all bitmaps and 2046 * allow a new search. Also (below) reset all bitmaps and
1871 * stats in active history. 2047 * stats in active history.
1872 */ 2048 */
1873 if ((lq_sta->total_failed > lq_sta->max_failure_limit) || 2049 if (force_search ||
2050 (lq_sta->total_failed > lq_sta->max_failure_limit) ||
1874 (lq_sta->total_success > lq_sta->max_success_limit) || 2051 (lq_sta->total_success > lq_sta->max_success_limit) ||
1875 ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) 2052 ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer)
1876 && (flush_interval_passed))) { 2053 && (flush_interval_passed))) {
@@ -1919,6 +2096,7 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta)
1919 * return rate_n_flags as used in the table 2096 * return rate_n_flags as used in the table
1920 */ 2097 */
1921static u32 rs_update_rate_tbl(struct iwl_priv *priv, 2098static u32 rs_update_rate_tbl(struct iwl_priv *priv,
2099 struct iwl_rxon_context *ctx,
1922 struct iwl_lq_sta *lq_sta, 2100 struct iwl_lq_sta *lq_sta,
1923 struct iwl_scale_tbl_info *tbl, 2101 struct iwl_scale_tbl_info *tbl,
1924 int index, u8 is_green) 2102 int index, u8 is_green)
@@ -1928,7 +2106,7 @@ static u32 rs_update_rate_tbl(struct iwl_priv *priv,
1928 /* Update uCode's rate table. */ 2106 /* Update uCode's rate table. */
1929 rate = rate_n_flags_from_tbl(priv, tbl, index, is_green); 2107 rate = rate_n_flags_from_tbl(priv, tbl, index, is_green);
1930 rs_fill_link_cmd(priv, lq_sta, rate); 2108 rs_fill_link_cmd(priv, lq_sta, rate);
1931 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false); 2109 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false);
1932 2110
1933 return rate; 2111 return rate;
1934} 2112}
@@ -1967,6 +2145,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1967 s32 sr; 2145 s32 sr;
1968 u8 tid = MAX_TID_COUNT; 2146 u8 tid = MAX_TID_COUNT;
1969 struct iwl_tid_data *tid_data; 2147 struct iwl_tid_data *tid_data;
2148 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
2149 struct iwl_rxon_context *ctx = sta_priv->common.ctx;
1970 2150
1971 IWL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); 2151 IWL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n");
1972 2152
@@ -2005,7 +2185,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
2005 if (is_legacy(tbl->lq_type)) 2185 if (is_legacy(tbl->lq_type))
2006 lq_sta->is_green = 0; 2186 lq_sta->is_green = 0;
2007 else 2187 else
2008 lq_sta->is_green = rs_use_green(sta, &priv->current_ht_config); 2188 lq_sta->is_green = rs_use_green(sta);
2009 is_green = lq_sta->is_green; 2189 is_green = lq_sta->is_green;
2010 2190
2011 /* current tx rate */ 2191 /* current tx rate */
@@ -2044,7 +2224,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
2044 tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); 2224 tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
2045 /* get "active" rate info */ 2225 /* get "active" rate info */
2046 index = iwl_hwrate_to_plcp_idx(tbl->current_rate); 2226 index = iwl_hwrate_to_plcp_idx(tbl->current_rate);
2047 rate = rs_update_rate_tbl(priv, lq_sta, 2227 rate = rs_update_rate_tbl(priv, ctx, lq_sta,
2048 tbl, index, is_green); 2228 tbl, index, is_green);
2049 } 2229 }
2050 return; 2230 return;
@@ -2086,7 +2266,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
2086 2266
2087 /* Should we stay with this modulation mode, 2267 /* Should we stay with this modulation mode,
2088 * or search for a new one? */ 2268 * or search for a new one? */
2089 rs_stay_in_table(lq_sta); 2269 rs_stay_in_table(lq_sta, false);
2090 2270
2091 goto out; 2271 goto out;
2092 } 2272 }
@@ -2234,6 +2414,28 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
2234 if (iwl_tx_ant_restriction(priv) != IWL_ANT_OK_MULTI && 2414 if (iwl_tx_ant_restriction(priv) != IWL_ANT_OK_MULTI &&
2235 (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) 2415 (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type)))
2236 scale_action = -1; 2416 scale_action = -1;
2417
2418 if ((priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) &&
2419 (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) {
2420 if (lq_sta->last_bt_traffic > priv->bt_traffic_load) {
2421 /*
2422 * don't set scale_action, don't want to scale up if
2423 * the rate scale doesn't otherwise think that is a
2424 * good idea.
2425 */
2426 } else if (lq_sta->last_bt_traffic <= priv->bt_traffic_load) {
2427 scale_action = -1;
2428 }
2429 }
2430 lq_sta->last_bt_traffic = priv->bt_traffic_load;
2431
2432 if ((priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH) &&
2433 (is_mimo2(tbl->lq_type) || is_mimo3(tbl->lq_type))) {
2434 /* search for a new modulation */
2435 rs_stay_in_table(lq_sta, true);
2436 goto lq_update;
2437 }
2438
2237 switch (scale_action) { 2439 switch (scale_action) {
2238 case -1: 2440 case -1:
2239 /* Decrease starting rate, update uCode's rate table */ 2441 /* Decrease starting rate, update uCode's rate table */
@@ -2264,13 +2466,13 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
2264lq_update: 2466lq_update:
2265 /* Replace uCode's rate table for the destination station. */ 2467 /* Replace uCode's rate table for the destination station. */
2266 if (update_lq) 2468 if (update_lq)
2267 rate = rs_update_rate_tbl(priv, lq_sta, 2469 rate = rs_update_rate_tbl(priv, ctx, lq_sta,
2268 tbl, index, is_green); 2470 tbl, index, is_green);
2269 2471
2270 if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_MULTI) { 2472 if (iwl_tx_ant_restriction(priv) == IWL_ANT_OK_MULTI) {
2271 /* Should we stay with this modulation mode, 2473 /* Should we stay with this modulation mode,
2272 * or search for a new one? */ 2474 * or search for a new one? */
2273 rs_stay_in_table(lq_sta); 2475 rs_stay_in_table(lq_sta, false);
2274 } 2476 }
2275 /* 2477 /*
2276 * Search for new modulation mode if we're: 2478 * Search for new modulation mode if we're:
@@ -2306,7 +2508,7 @@ lq_update:
2306 IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n", 2508 IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n",
2307 tbl->current_rate, index); 2509 tbl->current_rate, index);
2308 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); 2510 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate);
2309 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC, false); 2511 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false);
2310 } else 2512 } else
2311 done_search = 1; 2513 done_search = 1;
2312 } 2514 }
@@ -2376,12 +2578,17 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2376 int rate_idx; 2578 int rate_idx;
2377 int i; 2579 int i;
2378 u32 rate; 2580 u32 rate;
2379 u8 use_green = rs_use_green(sta, &priv->current_ht_config); 2581 u8 use_green = rs_use_green(sta);
2380 u8 active_tbl = 0; 2582 u8 active_tbl = 0;
2381 u8 valid_tx_ant; 2583 u8 valid_tx_ant;
2584 struct iwl_station_priv *sta_priv;
2585 struct iwl_rxon_context *ctx;
2382 2586
2383 if (!sta || !lq_sta) 2587 if (!sta || !lq_sta)
2384 goto out; 2588 return;
2589
2590 sta_priv = (void *)sta->drv_priv;
2591 ctx = sta_priv->common.ctx;
2385 2592
2386 i = lq_sta->last_txrate_idx; 2593 i = lq_sta->last_txrate_idx;
2387 2594
@@ -2413,9 +2620,7 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2413 rs_set_expected_tpt_table(lq_sta, tbl); 2620 rs_set_expected_tpt_table(lq_sta, tbl);
2414 rs_fill_link_cmd(NULL, lq_sta, rate); 2621 rs_fill_link_cmd(NULL, lq_sta, rate);
2415 priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; 2622 priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq;
2416 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_SYNC, true); 2623 iwl_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_SYNC, true);
2417 out:
2418 return;
2419} 2624}
2420 2625
2421static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, 2626static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
@@ -2543,7 +2748,7 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i
2543 lq_sta->is_dup = 0; 2748 lq_sta->is_dup = 0;
2544 lq_sta->max_rate_idx = -1; 2749 lq_sta->max_rate_idx = -1;
2545 lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; 2750 lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX;
2546 lq_sta->is_green = rs_use_green(sta, &priv->current_ht_config); 2751 lq_sta->is_green = rs_use_green(sta);
2547 lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); 2752 lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000);
2548 lq_sta->band = priv->band; 2753 lq_sta->band = priv->band;
2549 /* 2754 /*
@@ -2616,6 +2821,12 @@ static void rs_fill_link_cmd(struct iwl_priv *priv,
2616 rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, 2821 rs_get_tbl_info_from_mcs(new_rate, lq_sta->band,
2617 &tbl_type, &rate_idx); 2822 &tbl_type, &rate_idx);
2618 2823
2824 if (priv && priv->bt_full_concurrent) {
2825 /* 1x1 only */
2826 tbl_type.ant_type =
2827 first_antenna(priv->hw_params.valid_tx_ant);
2828 }
2829
2619 /* How many times should we repeat the initial rate? */ 2830 /* How many times should we repeat the initial rate? */
2620 if (is_legacy(tbl_type.lq_type)) { 2831 if (is_legacy(tbl_type.lq_type)) {
2621 ant_toggle_cnt = 1; 2832 ant_toggle_cnt = 1;
@@ -2640,9 +2851,12 @@ static void rs_fill_link_cmd(struct iwl_priv *priv,
2640 2851
2641 index++; 2852 index++;
2642 repeat_rate--; 2853 repeat_rate--;
2643 2854 if (priv) {
2644 if (priv) 2855 if (priv->bt_full_concurrent)
2645 valid_tx_ant = priv->hw_params.valid_tx_ant; 2856 valid_tx_ant = ANT_A;
2857 else
2858 valid_tx_ant = priv->hw_params.valid_tx_ant;
2859 }
2646 2860
2647 /* Fill rest of rate table */ 2861 /* Fill rest of rate table */
2648 while (index < LINK_QUAL_MAX_RETRY_NUM) { 2862 while (index < LINK_QUAL_MAX_RETRY_NUM) {
@@ -2657,7 +2871,7 @@ static void rs_fill_link_cmd(struct iwl_priv *priv,
2657 rs_toggle_antenna(valid_tx_ant, 2871 rs_toggle_antenna(valid_tx_ant,
2658 &new_rate, &tbl_type)) 2872 &new_rate, &tbl_type))
2659 ant_toggle_cnt = 1; 2873 ant_toggle_cnt = 1;
2660} 2874 }
2661 2875
2662 /* Override next rate if needed for debug purposes */ 2876 /* Override next rate if needed for debug purposes */
2663 rs_dbgfs_set_mcs(lq_sta, &new_rate, index); 2877 rs_dbgfs_set_mcs(lq_sta, &new_rate, index);
@@ -2672,6 +2886,12 @@ static void rs_fill_link_cmd(struct iwl_priv *priv,
2672 rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, 2886 rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type,
2673 &rate_idx); 2887 &rate_idx);
2674 2888
2889 if (priv && priv->bt_full_concurrent) {
2890 /* 1x1 only */
2891 tbl_type.ant_type =
2892 first_antenna(priv->hw_params.valid_tx_ant);
2893 }
2894
2675 /* Indicate to uCode which entries might be MIMO. 2895 /* Indicate to uCode which entries might be MIMO.
2676 * If initial rate was MIMO, this will finally end up 2896 * If initial rate was MIMO, this will finally end up
2677 * as (IWL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ 2897 * as (IWL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */
@@ -2788,6 +3008,9 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
2788 char buf[64]; 3008 char buf[64];
2789 int buf_size; 3009 int buf_size;
2790 u32 parsed_rate; 3010 u32 parsed_rate;
3011 struct iwl_station_priv *sta_priv =
3012 container_of(lq_sta, struct iwl_station_priv, lq_sta);
3013 struct iwl_rxon_context *ctx = sta_priv->common.ctx;
2791 3014
2792 priv = lq_sta->drv; 3015 priv = lq_sta->drv;
2793 memset(buf, 0, sizeof(buf)); 3016 memset(buf, 0, sizeof(buf));
@@ -2810,7 +3033,8 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
2810 3033
2811 if (lq_sta->dbg_fixed_rate) { 3034 if (lq_sta->dbg_fixed_rate) {
2812 rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); 3035 rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate);
2813 iwl_send_lq_cmd(lq_sta->drv, &lq_sta->lq, CMD_ASYNC, false); 3036 iwl_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC,
3037 false);
2814 } 3038 }
2815 3039
2816 return count; 3040 return count;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index 8292f6d48ec6..3970ab1deaf9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -432,6 +432,8 @@ struct iwl_lq_sta {
432 u32 last_rate_n_flags; 432 u32 last_rate_n_flags;
433 /* packets destined for this STA are aggregated */ 433 /* packets destined for this STA are aggregated */
434 u8 is_agg; 434 u8 is_agg;
435 /* BT traffic this sta was last updated in */
436 u8 last_bt_traffic;
435}; 437};
436 438
437static inline u8 num_of_ant(u8 mask) 439static inline u8 num_of_ant(u8 mask)
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
index 30298ea56a24..07b2c6cadf51 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tt.c
@@ -416,18 +416,26 @@ static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
416 /* stop ct_kill_waiting_tm timer */ 416 /* stop ct_kill_waiting_tm timer */
417 del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm); 417 del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm);
418 if (changed) { 418 if (changed) {
419 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
420
421 if (tt->state >= IWL_TI_1) { 419 if (tt->state >= IWL_TI_1) {
422 /* force PI = IWL_POWER_INDEX_5 in the case of TI > 0 */ 420 /* force PI = IWL_POWER_INDEX_5 in the case of TI > 0 */
423 tt->tt_power_mode = IWL_POWER_INDEX_5; 421 tt->tt_power_mode = IWL_POWER_INDEX_5;
424 if (!iwl_ht_enabled(priv)) 422
425 /* disable HT */ 423 if (!iwl_ht_enabled(priv)) {
426 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | 424 struct iwl_rxon_context *ctx;
427 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | 425
428 RXON_FLG_HT40_PROT_MSK | 426 for_each_context(priv, ctx) {
429 RXON_FLG_HT_PROT_MSK); 427 struct iwl_rxon_cmd *rxon;
430 else { 428
429 rxon = &ctx->staging;
430
431 /* disable HT */
432 rxon->flags &= ~(
433 RXON_FLG_CHANNEL_MODE_MSK |
434 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK |
435 RXON_FLG_HT40_PROT_MSK |
436 RXON_FLG_HT_PROT_MSK);
437 }
438 } else {
431 /* check HT capability and set 439 /* check HT capability and set
432 * according to the system HT capability 440 * according to the system HT capability
433 * in case get disabled before */ 441 * in case get disabled before */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
index 3fc982e87921..5950184d9860 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c
@@ -71,18 +71,6 @@ static const u8 tid_to_ac[] = {
71 2, 3, 3, 2, 1, 1, 0, 0 71 2, 3, 3, 2, 1, 1, 0, 0
72}; 72};
73 73
74static const u8 ac_to_fifo[] = {
75 IWL_TX_FIFO_VO,
76 IWL_TX_FIFO_VI,
77 IWL_TX_FIFO_BE,
78 IWL_TX_FIFO_BK,
79};
80
81static inline int get_fifo_from_ac(u8 ac)
82{
83 return ac_to_fifo[ac];
84}
85
86static inline int get_ac_from_tid(u16 tid) 74static inline int get_ac_from_tid(u16 tid)
87{ 75{
88 if (likely(tid < ARRAY_SIZE(tid_to_ac))) 76 if (likely(tid < ARRAY_SIZE(tid_to_ac)))
@@ -92,10 +80,10 @@ static inline int get_ac_from_tid(u16 tid)
92 return -EINVAL; 80 return -EINVAL;
93} 81}
94 82
95static inline int get_fifo_from_tid(u16 tid) 83static inline int get_fifo_from_tid(struct iwl_rxon_context *ctx, u16 tid)
96{ 84{
97 if (likely(tid < ARRAY_SIZE(tid_to_ac))) 85 if (likely(tid < ARRAY_SIZE(tid_to_ac)))
98 return get_fifo_from_ac(tid_to_ac[tid]); 86 return ctx->ac_to_fifo[tid_to_ac[tid]];
99 87
100 /* no support for TIDs 8-15 yet */ 88 /* no support for TIDs 8-15 yet */
101 return -EINVAL; 89 return -EINVAL;
@@ -118,7 +106,7 @@ void iwlagn_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
118 106
119 WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX); 107 WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
120 108
121 if (txq_id != IWL_CMD_QUEUE_NUM) { 109 if (txq_id != priv->cmd_queue) {
122 sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id; 110 sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id;
123 sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl; 111 sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl;
124 112
@@ -155,7 +143,7 @@ void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
155 143
156 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX); 144 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
157 145
158 if (txq_id != IWL_CMD_QUEUE_NUM) 146 if (txq_id != priv->cmd_queue)
159 sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id; 147 sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id;
160 148
161 bc_ent = cpu_to_le16(1 | (sta_id << 12)); 149 bc_ent = cpu_to_le16(1 | (sta_id << 12));
@@ -333,19 +321,15 @@ void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask)
333 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask); 321 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask);
334} 322}
335 323
336static inline int get_queue_from_ac(u16 ac)
337{
338 return ac;
339}
340
341/* 324/*
342 * handle build REPLY_TX command notification. 325 * handle build REPLY_TX command notification.
343 */ 326 */
344static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv, 327static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
345 struct iwl_tx_cmd *tx_cmd, 328 struct sk_buff *skb,
346 struct ieee80211_tx_info *info, 329 struct iwl_tx_cmd *tx_cmd,
347 struct ieee80211_hdr *hdr, 330 struct ieee80211_tx_info *info,
348 u8 std_id) 331 struct ieee80211_hdr *hdr,
332 u8 std_id)
349{ 333{
350 __le16 fc = hdr->frame_control; 334 __le16 fc = hdr->frame_control;
351 __le32 tx_flags = tx_cmd->tx_flags; 335 __le32 tx_flags = tx_cmd->tx_flags;
@@ -365,6 +349,12 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
365 349
366 if (ieee80211_is_back_req(fc)) 350 if (ieee80211_is_back_req(fc))
367 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; 351 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK;
352 else if (info->band == IEEE80211_BAND_2GHZ &&
353 priv->cfg->advanced_bt_coexist &&
354 (ieee80211_is_auth(fc) || ieee80211_is_assoc_req(fc) ||
355 ieee80211_is_reassoc_req(fc) ||
356 skb->protocol == cpu_to_be16(ETH_P_PAE)))
357 tx_flags |= TX_CMD_FLG_IGNORE_BT;
368 358
369 359
370 tx_cmd->sta_id = std_id; 360 tx_cmd->sta_id = std_id;
@@ -454,7 +444,12 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
454 rate_flags |= RATE_MCS_CCK_MSK; 444 rate_flags |= RATE_MCS_CCK_MSK;
455 445
456 /* Set up antennas */ 446 /* Set up antennas */
457 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant, 447 if (priv->cfg->advanced_bt_coexist && priv->bt_full_concurrent) {
448 /* operated as 1x1 in full concurrency mode */
449 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
450 first_antenna(priv->hw_params.valid_tx_ant));
451 } else
452 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
458 priv->hw_params.valid_tx_ant); 453 priv->hw_params.valid_tx_ant);
459 rate_flags |= iwl_ant_idx_to_flags(priv->mgmt_tx_ant); 454 rate_flags |= iwl_ant_idx_to_flags(priv->mgmt_tx_ant);
460 455
@@ -519,6 +514,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
519 struct iwl_device_cmd *out_cmd; 514 struct iwl_device_cmd *out_cmd;
520 struct iwl_cmd_meta *out_meta; 515 struct iwl_cmd_meta *out_meta;
521 struct iwl_tx_cmd *tx_cmd; 516 struct iwl_tx_cmd *tx_cmd;
517 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
522 int swq_id, txq_id; 518 int swq_id, txq_id;
523 dma_addr_t phys_addr; 519 dma_addr_t phys_addr;
524 dma_addr_t txcmd_phys; 520 dma_addr_t txcmd_phys;
@@ -533,6 +529,9 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
533 u8 *qc = NULL; 529 u8 *qc = NULL;
534 unsigned long flags; 530 unsigned long flags;
535 531
532 if (info->control.vif)
533 ctx = iwl_rxon_ctx_from_vif(info->control.vif);
534
536 spin_lock_irqsave(&priv->lock, flags); 535 spin_lock_irqsave(&priv->lock, flags);
537 if (iwl_is_rfkill(priv)) { 536 if (iwl_is_rfkill(priv)) {
538 IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); 537 IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n");
@@ -553,7 +552,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
553 hdr_len = ieee80211_hdrlen(fc); 552 hdr_len = ieee80211_hdrlen(fc);
554 553
555 /* Find index into station table for destination station */ 554 /* Find index into station table for destination station */
556 sta_id = iwl_sta_id_or_broadcast(priv, info->control.sta); 555 sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta);
557 if (sta_id == IWL_INVALID_STATION) { 556 if (sta_id == IWL_INVALID_STATION) {
558 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 557 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
559 hdr->addr1); 558 hdr->addr1);
@@ -565,8 +564,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
565 if (sta) 564 if (sta)
566 sta_priv = (void *)sta->drv_priv; 565 sta_priv = (void *)sta->drv_priv;
567 566
568 if (sta_priv && sta_id != priv->hw_params.bcast_sta_id && 567 if (sta_priv && sta_priv->asleep) {
569 sta_priv->asleep) {
570 WARN_ON(!(info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)); 568 WARN_ON(!(info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE));
571 /* 569 /*
572 * This sends an asynchronous command to the device, 570 * This sends an asynchronous command to the device,
@@ -580,7 +578,20 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
580 iwl_sta_modify_sleep_tx_count(priv, sta_id, 1); 578 iwl_sta_modify_sleep_tx_count(priv, sta_id, 1);
581 } 579 }
582 580
583 txq_id = get_queue_from_ac(skb_get_queue_mapping(skb)); 581 /*
582 * Send this frame after DTIM -- there's a special queue
583 * reserved for this for contexts that support AP mode.
584 */
585 if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) {
586 txq_id = ctx->mcast_queue;
587 /*
588 * The microcode will clear the more data
589 * bit in the last frame it transmits.
590 */
591 hdr->frame_control |=
592 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
593 } else
594 txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)];
584 595
585 /* irqs already disabled/saved above when locking priv->lock */ 596 /* irqs already disabled/saved above when locking priv->lock */
586 spin_lock(&priv->sta_lock); 597 spin_lock(&priv->sta_lock);
@@ -625,6 +636,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
625 /* Set up driver data for this TFD */ 636 /* Set up driver data for this TFD */
626 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); 637 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
627 txq->txb[q->write_ptr].skb = skb; 638 txq->txb[q->write_ptr].skb = skb;
639 txq->txb[q->write_ptr].ctx = ctx;
628 640
629 /* Set up first empty entry in queue's array of Tx/cmd buffers */ 641 /* Set up first empty entry in queue's array of Tx/cmd buffers */
630 out_cmd = txq->cmd[q->write_ptr]; 642 out_cmd = txq->cmd[q->write_ptr];
@@ -655,7 +667,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
655 iwlagn_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); 667 iwlagn_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id);
656 668
657 /* TODO need this for burst mode later on */ 669 /* TODO need this for burst mode later on */
658 iwlagn_tx_cmd_build_basic(priv, tx_cmd, info, hdr, sta_id); 670 iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id);
659 iwl_dbg_log_tx_data_frame(priv, len, hdr); 671 iwl_dbg_log_tx_data_frame(priv, len, hdr);
660 672
661 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc); 673 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc);
@@ -813,7 +825,7 @@ void iwlagn_hw_txq_ctx_free(struct iwl_priv *priv)
813 /* Tx queues */ 825 /* Tx queues */
814 if (priv->txq) { 826 if (priv->txq) {
815 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) 827 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
816 if (txq_id == IWL_CMD_QUEUE_NUM) 828 if (txq_id == priv->cmd_queue)
817 iwl_cmd_queue_free(priv); 829 iwl_cmd_queue_free(priv);
818 else 830 else
819 iwl_tx_queue_free(priv, txq_id); 831 iwl_tx_queue_free(priv, txq_id);
@@ -870,9 +882,9 @@ int iwlagn_txq_ctx_alloc(struct iwl_priv *priv)
870 882
871 spin_unlock_irqrestore(&priv->lock, flags); 883 spin_unlock_irqrestore(&priv->lock, flags);
872 884
873 /* Alloc and init all Tx queues, including the command queue (#4) */ 885 /* Alloc and init all Tx queues, including the command queue (#4/#9) */
874 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { 886 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
875 slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ? 887 slots_num = (txq_id == priv->cmd_queue) ?
876 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; 888 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
877 ret = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num, 889 ret = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num,
878 txq_id); 890 txq_id);
@@ -910,7 +922,7 @@ void iwlagn_txq_ctx_reset(struct iwl_priv *priv)
910 922
911 /* Alloc and init all Tx queues, including the command queue (#4) */ 923 /* Alloc and init all Tx queues, including the command queue (#4) */
912 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { 924 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
913 slots_num = txq_id == IWL_CMD_QUEUE_NUM ? 925 slots_num = txq_id == priv->cmd_queue ?
914 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; 926 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
915 iwl_tx_queue_reset(priv, &priv->txq[txq_id], slots_num, txq_id); 927 iwl_tx_queue_reset(priv, &priv->txq[txq_id], slots_num, txq_id);
916 } 928 }
@@ -968,7 +980,7 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
968 unsigned long flags; 980 unsigned long flags;
969 struct iwl_tid_data *tid_data; 981 struct iwl_tid_data *tid_data;
970 982
971 tx_fifo = get_fifo_from_tid(tid); 983 tx_fifo = get_fifo_from_tid(iwl_rxon_ctx_from_vif(vif), tid);
972 if (unlikely(tx_fifo < 0)) 984 if (unlikely(tx_fifo < 0))
973 return tx_fifo; 985 return tx_fifo;
974 986
@@ -1024,12 +1036,12 @@ int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
1024int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, 1036int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
1025 struct ieee80211_sta *sta, u16 tid) 1037 struct ieee80211_sta *sta, u16 tid)
1026{ 1038{
1027 int tx_fifo_id, txq_id, sta_id, ssn = -1; 1039 int tx_fifo_id, txq_id, sta_id, ssn;
1028 struct iwl_tid_data *tid_data; 1040 struct iwl_tid_data *tid_data;
1029 int write_ptr, read_ptr; 1041 int write_ptr, read_ptr;
1030 unsigned long flags; 1042 unsigned long flags;
1031 1043
1032 tx_fifo_id = get_fifo_from_tid(tid); 1044 tx_fifo_id = get_fifo_from_tid(iwl_rxon_ctx_from_vif(vif), tid);
1033 if (unlikely(tx_fifo_id < 0)) 1045 if (unlikely(tx_fifo_id < 0))
1034 return tx_fifo_id; 1046 return tx_fifo_id;
1035 1047
@@ -1042,21 +1054,26 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
1042 1054
1043 spin_lock_irqsave(&priv->sta_lock, flags); 1055 spin_lock_irqsave(&priv->sta_lock, flags);
1044 1056
1045 if (priv->stations[sta_id].tid[tid].agg.state ==
1046 IWL_EMPTYING_HW_QUEUE_ADDBA) {
1047 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
1048 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
1049 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1050 spin_unlock_irqrestore(&priv->sta_lock, flags);
1051 return 0;
1052 }
1053
1054 if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_ON)
1055 IWL_WARN(priv, "Stopping AGG while state not ON or starting\n");
1056
1057 tid_data = &priv->stations[sta_id].tid[tid]; 1057 tid_data = &priv->stations[sta_id].tid[tid];
1058 ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; 1058 ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4;
1059 txq_id = tid_data->agg.txq_id; 1059 txq_id = tid_data->agg.txq_id;
1060
1061 switch (priv->stations[sta_id].tid[tid].agg.state) {
1062 case IWL_EMPTYING_HW_QUEUE_ADDBA:
1063 /*
1064 * This can happen if the peer stops aggregation
1065 * again before we've had a chance to drain the
1066 * queue we selected previously, i.e. before the
1067 * session was really started completely.
1068 */
1069 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
1070 goto turn_off;
1071 case IWL_AGG_ON:
1072 break;
1073 default:
1074 IWL_WARN(priv, "Stopping AGG while state not ON or starting\n");
1075 }
1076
1060 write_ptr = priv->txq[txq_id].q.write_ptr; 1077 write_ptr = priv->txq[txq_id].q.write_ptr;
1061 read_ptr = priv->txq[txq_id].q.read_ptr; 1078 read_ptr = priv->txq[txq_id].q.read_ptr;
1062 1079
@@ -1070,6 +1087,7 @@ int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
1070 } 1087 }
1071 1088
1072 IWL_DEBUG_HT(priv, "HW queue is empty\n"); 1089 IWL_DEBUG_HT(priv, "HW queue is empty\n");
1090 turn_off:
1073 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; 1091 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1074 1092
1075 /* do not restore/save irqs */ 1093 /* do not restore/save irqs */
@@ -1098,6 +1116,9 @@ int iwlagn_txq_check_empty(struct iwl_priv *priv,
1098 struct iwl_queue *q = &priv->txq[txq_id].q; 1116 struct iwl_queue *q = &priv->txq[txq_id].q;
1099 u8 *addr = priv->stations[sta_id].sta.sta.addr; 1117 u8 *addr = priv->stations[sta_id].sta.sta.addr;
1100 struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; 1118 struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid];
1119 struct iwl_rxon_context *ctx;
1120
1121 ctx = &priv->contexts[priv->stations[sta_id].ctxid];
1101 1122
1102 lockdep_assert_held(&priv->sta_lock); 1123 lockdep_assert_held(&priv->sta_lock);
1103 1124
@@ -1108,12 +1129,12 @@ int iwlagn_txq_check_empty(struct iwl_priv *priv,
1108 if ((txq_id == tid_data->agg.txq_id) && 1129 if ((txq_id == tid_data->agg.txq_id) &&
1109 (q->read_ptr == q->write_ptr)) { 1130 (q->read_ptr == q->write_ptr)) {
1110 u16 ssn = SEQ_TO_SN(tid_data->seq_number); 1131 u16 ssn = SEQ_TO_SN(tid_data->seq_number);
1111 int tx_fifo = get_fifo_from_tid(tid); 1132 int tx_fifo = get_fifo_from_tid(ctx, tid);
1112 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n"); 1133 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n");
1113 priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, 1134 priv->cfg->ops->lib->txq_agg_disable(priv, txq_id,
1114 ssn, tx_fifo); 1135 ssn, tx_fifo);
1115 tid_data->agg.state = IWL_AGG_OFF; 1136 tid_data->agg.state = IWL_AGG_OFF;
1116 ieee80211_stop_tx_ba_cb_irqsafe(priv->vif, addr, tid); 1137 ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid);
1117 } 1138 }
1118 break; 1139 break;
1119 case IWL_EMPTYING_HW_QUEUE_ADDBA: 1140 case IWL_EMPTYING_HW_QUEUE_ADDBA:
@@ -1121,7 +1142,7 @@ int iwlagn_txq_check_empty(struct iwl_priv *priv,
1121 if (tid_data->tfds_in_queue == 0) { 1142 if (tid_data->tfds_in_queue == 0) {
1122 IWL_DEBUG_HT(priv, "HW queue empty: continue ADDBA flow\n"); 1143 IWL_DEBUG_HT(priv, "HW queue empty: continue ADDBA flow\n");
1123 tid_data->agg.state = IWL_AGG_ON; 1144 tid_data->agg.state = IWL_AGG_ON;
1124 ieee80211_start_tx_ba_cb_irqsafe(priv->vif, addr, tid); 1145 ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid);
1125 } 1146 }
1126 break; 1147 break;
1127 } 1148 }
@@ -1129,14 +1150,14 @@ int iwlagn_txq_check_empty(struct iwl_priv *priv,
1129 return 0; 1150 return 0;
1130} 1151}
1131 1152
1132static void iwlagn_tx_status(struct iwl_priv *priv, struct sk_buff *skb) 1153static void iwlagn_tx_status(struct iwl_priv *priv, struct iwl_tx_info *tx_info)
1133{ 1154{
1134 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1155 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data;
1135 struct ieee80211_sta *sta; 1156 struct ieee80211_sta *sta;
1136 struct iwl_station_priv *sta_priv; 1157 struct iwl_station_priv *sta_priv;
1137 1158
1138 rcu_read_lock(); 1159 rcu_read_lock();
1139 sta = ieee80211_find_sta(priv->vif, hdr->addr1); 1160 sta = ieee80211_find_sta(tx_info->ctx->vif, hdr->addr1);
1140 if (sta) { 1161 if (sta) {
1141 sta_priv = (void *)sta->drv_priv; 1162 sta_priv = (void *)sta->drv_priv;
1142 /* avoid atomic ops if this isn't a client */ 1163 /* avoid atomic ops if this isn't a client */
@@ -1146,7 +1167,7 @@ static void iwlagn_tx_status(struct iwl_priv *priv, struct sk_buff *skb)
1146 } 1167 }
1147 rcu_read_unlock(); 1168 rcu_read_unlock();
1148 1169
1149 ieee80211_tx_status_irqsafe(priv->hw, skb); 1170 ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb);
1150} 1171}
1151 1172
1152int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) 1173int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
@@ -1169,7 +1190,7 @@ int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
1169 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 1190 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
1170 1191
1171 tx_info = &txq->txb[txq->q.read_ptr]; 1192 tx_info = &txq->txb[txq->q.read_ptr];
1172 iwlagn_tx_status(priv, tx_info->skb); 1193 iwlagn_tx_status(priv, tx_info);
1173 1194
1174 hdr = (struct ieee80211_hdr *)tx_info->skb->data; 1195 hdr = (struct ieee80211_hdr *)tx_info->skb->data;
1175 if (hdr && ieee80211_is_data_qos(hdr->frame_control)) 1196 if (hdr && ieee80211_is_data_qos(hdr->frame_control))
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 6f77441cb65a..a7961bf395fc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -52,6 +52,19 @@ static const s8 iwlagn_default_queue_to_tx_fifo[] = {
52 IWL_TX_FIFO_UNUSED, 52 IWL_TX_FIFO_UNUSED,
53}; 53};
54 54
55static const s8 iwlagn_ipan_queue_to_tx_fifo[] = {
56 IWL_TX_FIFO_VO,
57 IWL_TX_FIFO_VI,
58 IWL_TX_FIFO_BE,
59 IWL_TX_FIFO_BK,
60 IWL_TX_FIFO_BK_IPAN,
61 IWL_TX_FIFO_BE_IPAN,
62 IWL_TX_FIFO_VI_IPAN,
63 IWL_TX_FIFO_VO_IPAN,
64 IWL_TX_FIFO_BE_IPAN,
65 IWLAGN_CMD_FIFO_NUM,
66};
67
55static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { 68static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = {
56 {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP, 69 {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP,
57 0, COEX_UNASSOC_IDLE_FLAGS}, 70 0, COEX_UNASSOC_IDLE_FLAGS},
@@ -329,8 +342,54 @@ static int iwlagn_send_wimax_coex(struct iwl_priv *priv)
329 sizeof(coex_cmd), &coex_cmd); 342 sizeof(coex_cmd), &coex_cmd);
330} 343}
331 344
345static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = {
346 ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
347 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
348 ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
349 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
350 ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
351 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
352 ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
353 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
354 ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
355 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
356 ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
357 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
358 ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
359 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
360 ((BT_COEX_PRIO_TBL_PRIO_COEX_OFF << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
361 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
362 ((BT_COEX_PRIO_TBL_PRIO_COEX_ON << IWL_BT_COEX_PRIO_TBL_PRIO_POS) |
363 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)),
364 0, 0, 0, 0, 0, 0, 0
365};
366
367static void iwlagn_send_prio_tbl(struct iwl_priv *priv)
368{
369 struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd;
370
371 memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl,
372 sizeof(iwlagn_bt_prio_tbl));
373 if (iwl_send_cmd_pdu(priv, REPLY_BT_COEX_PRIO_TABLE,
374 sizeof(prio_tbl_cmd), &prio_tbl_cmd))
375 IWL_ERR(priv, "failed to send BT prio tbl command\n");
376}
377
378static void iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type)
379{
380 struct iwl_bt_coex_prot_env_cmd env_cmd;
381
382 env_cmd.action = action;
383 env_cmd.type = type;
384 if (iwl_send_cmd_pdu(priv, REPLY_BT_COEX_PROT_ENV,
385 sizeof(env_cmd), &env_cmd))
386 IWL_ERR(priv, "failed to send BT env command\n");
387}
388
389
332int iwlagn_alive_notify(struct iwl_priv *priv) 390int iwlagn_alive_notify(struct iwl_priv *priv)
333{ 391{
392 const s8 *queues;
334 u32 a; 393 u32 a;
335 unsigned long flags; 394 unsigned long flags;
336 int i, chan; 395 int i, chan;
@@ -365,7 +424,7 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
365 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); 424 reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN);
366 425
367 iwl_write_prph(priv, IWLAGN_SCD_QUEUECHAIN_SEL, 426 iwl_write_prph(priv, IWLAGN_SCD_QUEUECHAIN_SEL,
368 IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv->hw_params.max_txq_num)); 427 IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv));
369 iwl_write_prph(priv, IWLAGN_SCD_AGGR_SEL, 0); 428 iwl_write_prph(priv, IWLAGN_SCD_AGGR_SEL, 0);
370 429
371 /* initiate the queues */ 430 /* initiate the queues */
@@ -391,7 +450,13 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
391 /* Activate all Tx DMA/FIFO channels */ 450 /* Activate all Tx DMA/FIFO channels */
392 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7)); 451 priv->cfg->ops->lib->txq_set_sched(priv, IWL_MASK(0, 7));
393 452
394 iwlagn_set_wr_ptrs(priv, IWL_CMD_QUEUE_NUM, 0); 453 /* map queues to FIFOs */
454 if (priv->valid_contexts != BIT(IWL_RXON_CTX_BSS))
455 queues = iwlagn_ipan_queue_to_tx_fifo;
456 else
457 queues = iwlagn_default_queue_to_tx_fifo;
458
459 iwlagn_set_wr_ptrs(priv, priv->cmd_queue, 0);
395 460
396 /* make sure all queue are not stopped */ 461 /* make sure all queue are not stopped */
397 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped)); 462 memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped));
@@ -400,11 +465,12 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
400 465
401 /* reset to 0 to enable all the queue first */ 466 /* reset to 0 to enable all the queue first */
402 priv->txq_ctx_active_msk = 0; 467 priv->txq_ctx_active_msk = 0;
403 /* map qos queues to fifos one-to-one */ 468
404 BUILD_BUG_ON(ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo) != 10); 469 BUILD_BUG_ON(ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo) != 10);
470 BUILD_BUG_ON(ARRAY_SIZE(iwlagn_ipan_queue_to_tx_fifo) != 10);
405 471
406 for (i = 0; i < ARRAY_SIZE(iwlagn_default_queue_to_tx_fifo); i++) { 472 for (i = 0; i < 10; i++) {
407 int ac = iwlagn_default_queue_to_tx_fifo[i]; 473 int ac = queues[i];
408 474
409 iwl_txq_ctx_activate(priv, i); 475 iwl_txq_ctx_activate(priv, i);
410 476
@@ -416,6 +482,25 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
416 482
417 spin_unlock_irqrestore(&priv->lock, flags); 483 spin_unlock_irqrestore(&priv->lock, flags);
418 484
485 if (priv->cfg->advanced_bt_coexist) {
486 /* Configure Bluetooth device coexistence support */
487 /* need to perform this before any calibration */
488 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK;
489 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT;
490 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT;
491 priv->cfg->ops->hcmd->send_bt_config(priv);
492 priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS;
493
494 if (bt_coex_active && priv->iw_mode != NL80211_IFTYPE_ADHOC) {
495 iwlagn_send_prio_tbl(priv);
496 iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN,
497 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
498 iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE,
499 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2);
500 }
501
502 }
503
419 iwlagn_send_wimax_coex(priv); 504 iwlagn_send_wimax_coex(priv);
420 505
421 iwlagn_set_Xtal_calib(priv); 506 iwlagn_set_Xtal_calib(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 3ced9ea9c5fe..ad0e67f5c0d4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -87,6 +87,9 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR);
87MODULE_LICENSE("GPL"); 87MODULE_LICENSE("GPL");
88MODULE_ALIAS("iwl4965"); 88MODULE_ALIAS("iwl4965");
89 89
90static int iwlagn_ant_coupling;
91static bool iwlagn_bt_ch_announce = 1;
92
90/** 93/**
91 * iwl_commit_rxon - commit staging_rxon to hardware 94 * iwl_commit_rxon - commit staging_rxon to hardware
92 * 95 *
@@ -95,21 +98,22 @@ MODULE_ALIAS("iwl4965");
95 * function correctly transitions out of the RXON_ASSOC_MSK state if 98 * function correctly transitions out of the RXON_ASSOC_MSK state if
96 * a HW tune is required based on the RXON structure changes. 99 * a HW tune is required based on the RXON structure changes.
97 */ 100 */
98int iwl_commit_rxon(struct iwl_priv *priv) 101int iwl_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
99{ 102{
100 /* cast away the const for active_rxon in this function */ 103 /* cast away the const for active_rxon in this function */
101 struct iwl_rxon_cmd *active_rxon = (void *)&priv->active_rxon; 104 struct iwl_rxon_cmd *active_rxon = (void *)&ctx->active;
102 int ret; 105 int ret;
103 bool new_assoc = 106 bool new_assoc =
104 !!(priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK); 107 !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK);
108 bool old_assoc = !!(ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK);
105 109
106 if (!iwl_is_alive(priv)) 110 if (!iwl_is_alive(priv))
107 return -EBUSY; 111 return -EBUSY;
108 112
109 /* always get timestamp with Rx frame */ 113 /* always get timestamp with Rx frame */
110 priv->staging_rxon.flags |= RXON_FLG_TSF2HOST_MSK; 114 ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK;
111 115
112 ret = iwl_check_rxon_cmd(priv); 116 ret = iwl_check_rxon_cmd(priv, ctx);
113 if (ret) { 117 if (ret) {
114 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); 118 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
115 return -EINVAL; 119 return -EINVAL;
@@ -120,7 +124,7 @@ int iwl_commit_rxon(struct iwl_priv *priv)
120 * abort any previous channel switch if still in process 124 * abort any previous channel switch if still in process
121 */ 125 */
122 if (priv->switch_rxon.switch_in_progress && 126 if (priv->switch_rxon.switch_in_progress &&
123 (priv->switch_rxon.channel != priv->staging_rxon.channel)) { 127 (priv->switch_rxon.channel != ctx->staging.channel)) {
124 IWL_DEBUG_11H(priv, "abort channel switch on %d\n", 128 IWL_DEBUG_11H(priv, "abort channel switch on %d\n",
125 le16_to_cpu(priv->switch_rxon.channel)); 129 le16_to_cpu(priv->switch_rxon.channel));
126 iwl_chswitch_done(priv, false); 130 iwl_chswitch_done(priv, false);
@@ -129,15 +133,15 @@ int iwl_commit_rxon(struct iwl_priv *priv)
129 /* If we don't need to send a full RXON, we can use 133 /* If we don't need to send a full RXON, we can use
130 * iwl_rxon_assoc_cmd which is used to reconfigure filter 134 * iwl_rxon_assoc_cmd which is used to reconfigure filter
131 * and other flags for the current radio configuration. */ 135 * and other flags for the current radio configuration. */
132 if (!iwl_full_rxon_required(priv)) { 136 if (!iwl_full_rxon_required(priv, ctx)) {
133 ret = iwl_send_rxon_assoc(priv); 137 ret = iwl_send_rxon_assoc(priv, ctx);
134 if (ret) { 138 if (ret) {
135 IWL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); 139 IWL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret);
136 return ret; 140 return ret;
137 } 141 }
138 142
139 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon)); 143 memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon));
140 iwl_print_rx_config_cmd(priv); 144 iwl_print_rx_config_cmd(priv, ctx);
141 return 0; 145 return 0;
142 } 146 }
143 147
@@ -145,13 +149,13 @@ int iwl_commit_rxon(struct iwl_priv *priv)
145 * an RXON_ASSOC and the new config wants the associated mask enabled, 149 * an RXON_ASSOC and the new config wants the associated mask enabled,
146 * we must clear the associated from the active configuration 150 * we must clear the associated from the active configuration
147 * before we apply the new config */ 151 * before we apply the new config */
148 if (iwl_is_associated(priv) && new_assoc) { 152 if (iwl_is_associated_ctx(ctx) && new_assoc) {
149 IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); 153 IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n");
150 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 154 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
151 155
152 ret = iwl_send_cmd_pdu(priv, REPLY_RXON, 156 ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd,
153 sizeof(struct iwl_rxon_cmd), 157 sizeof(struct iwl_rxon_cmd),
154 &priv->active_rxon); 158 active_rxon);
155 159
156 /* If the mask clearing failed then we set 160 /* If the mask clearing failed then we set
157 * active_rxon back to what it was previously */ 161 * active_rxon back to what it was previously */
@@ -160,9 +164,9 @@ int iwl_commit_rxon(struct iwl_priv *priv)
160 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); 164 IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret);
161 return ret; 165 return ret;
162 } 166 }
163 iwl_clear_ucode_stations(priv); 167 iwl_clear_ucode_stations(priv, ctx);
164 iwl_restore_stations(priv); 168 iwl_restore_stations(priv, ctx);
165 ret = iwl_restore_default_wep_keys(priv); 169 ret = iwl_restore_default_wep_keys(priv, ctx);
166 if (ret) { 170 if (ret) {
167 IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); 171 IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
168 return ret; 172 return ret;
@@ -174,27 +178,46 @@ int iwl_commit_rxon(struct iwl_priv *priv)
174 "* channel = %d\n" 178 "* channel = %d\n"
175 "* bssid = %pM\n", 179 "* bssid = %pM\n",
176 (new_assoc ? "" : "out"), 180 (new_assoc ? "" : "out"),
177 le16_to_cpu(priv->staging_rxon.channel), 181 le16_to_cpu(ctx->staging.channel),
178 priv->staging_rxon.bssid_addr); 182 ctx->staging.bssid_addr);
183
184 iwl_set_rxon_hwcrypto(priv, ctx, !priv->cfg->mod_params->sw_crypto);
185
186 if (!old_assoc) {
187 /*
188 * First of all, before setting associated, we need to
189 * send RXON timing so the device knows about the DTIM
190 * period and other timing values
191 */
192 ret = iwl_send_rxon_timing(priv, ctx);
193 if (ret) {
194 IWL_ERR(priv, "Error setting RXON timing!\n");
195 return ret;
196 }
197 }
179 198
180 iwl_set_rxon_hwcrypto(priv, !priv->cfg->mod_params->sw_crypto); 199 if (priv->cfg->ops->hcmd->set_pan_params) {
200 ret = priv->cfg->ops->hcmd->set_pan_params(priv);
201 if (ret)
202 return ret;
203 }
181 204
182 /* Apply the new configuration 205 /* Apply the new configuration
183 * RXON unassoc clears the station table in uCode so restoration of 206 * RXON unassoc clears the station table in uCode so restoration of
184 * stations is needed after it (the RXON command) completes 207 * stations is needed after it (the RXON command) completes
185 */ 208 */
186 if (!new_assoc) { 209 if (!new_assoc) {
187 ret = iwl_send_cmd_pdu(priv, REPLY_RXON, 210 ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd,
188 sizeof(struct iwl_rxon_cmd), &priv->staging_rxon); 211 sizeof(struct iwl_rxon_cmd), &ctx->staging);
189 if (ret) { 212 if (ret) {
190 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); 213 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
191 return ret; 214 return ret;
192 } 215 }
193 IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); 216 IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n");
194 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon)); 217 memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon));
195 iwl_clear_ucode_stations(priv); 218 iwl_clear_ucode_stations(priv, ctx);
196 iwl_restore_stations(priv); 219 iwl_restore_stations(priv, ctx);
197 ret = iwl_restore_default_wep_keys(priv); 220 ret = iwl_restore_default_wep_keys(priv, ctx);
198 if (ret) { 221 if (ret) {
199 IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); 222 IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
200 return ret; 223 return ret;
@@ -206,15 +229,15 @@ int iwl_commit_rxon(struct iwl_priv *priv)
206 /* Apply the new configuration 229 /* Apply the new configuration
207 * RXON assoc doesn't clear the station table in uCode, 230 * RXON assoc doesn't clear the station table in uCode,
208 */ 231 */
209 ret = iwl_send_cmd_pdu(priv, REPLY_RXON, 232 ret = iwl_send_cmd_pdu(priv, ctx->rxon_cmd,
210 sizeof(struct iwl_rxon_cmd), &priv->staging_rxon); 233 sizeof(struct iwl_rxon_cmd), &ctx->staging);
211 if (ret) { 234 if (ret) {
212 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); 235 IWL_ERR(priv, "Error setting new RXON (%d)\n", ret);
213 return ret; 236 return ret;
214 } 237 }
215 memcpy(active_rxon, &priv->staging_rxon, sizeof(*active_rxon)); 238 memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon));
216 } 239 }
217 iwl_print_rx_config_cmd(priv); 240 iwl_print_rx_config_cmd(priv, ctx);
218 241
219 iwl_init_sensitivity(priv); 242 iwl_init_sensitivity(priv);
220 243
@@ -231,10 +254,14 @@ int iwl_commit_rxon(struct iwl_priv *priv)
231 254
232void iwl_update_chain_flags(struct iwl_priv *priv) 255void iwl_update_chain_flags(struct iwl_priv *priv)
233{ 256{
257 struct iwl_rxon_context *ctx;
234 258
235 if (priv->cfg->ops->hcmd->set_rxon_chain) 259 if (priv->cfg->ops->hcmd->set_rxon_chain) {
236 priv->cfg->ops->hcmd->set_rxon_chain(priv); 260 for_each_context(priv, ctx) {
237 iwlcore_commit_rxon(priv); 261 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
262 iwlcore_commit_rxon(priv, ctx);
263 }
264 }
238} 265}
239 266
240static void iwl_clear_free_frames(struct iwl_priv *priv) 267static void iwl_clear_free_frames(struct iwl_priv *priv)
@@ -338,6 +365,13 @@ static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
338 * beacon contents. 365 * beacon contents.
339 */ 366 */
340 367
368 lockdep_assert_held(&priv->mutex);
369
370 if (!priv->beacon_ctx) {
371 IWL_ERR(priv, "trying to build beacon w/o beacon context!\n");
372 return -EINVAL;
373 }
374
341 /* Initialize memory */ 375 /* Initialize memory */
342 tx_beacon_cmd = &frame->u.beacon; 376 tx_beacon_cmd = &frame->u.beacon;
343 memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); 377 memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd));
@@ -350,7 +384,7 @@ static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
350 384
351 /* Set up TX command fields */ 385 /* Set up TX command fields */
352 tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); 386 tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size);
353 tx_beacon_cmd->tx.sta_id = priv->hw_params.bcast_sta_id; 387 tx_beacon_cmd->tx.sta_id = priv->beacon_ctx->bcast_sta_id;
354 tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 388 tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
355 tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | 389 tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK |
356 TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; 390 TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK;
@@ -360,7 +394,7 @@ static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
360 frame_size); 394 frame_size);
361 395
362 /* Set up packet rate and flags */ 396 /* Set up packet rate and flags */
363 rate = iwl_rate_get_lowest_plcp(priv); 397 rate = iwl_rate_get_lowest_plcp(priv, priv->beacon_ctx);
364 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant, 398 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
365 priv->hw_params.valid_tx_ant); 399 priv->hw_params.valid_tx_ant);
366 rate_flags = iwl_ant_idx_to_flags(priv->mgmt_tx_ant); 400 rate_flags = iwl_ant_idx_to_flags(priv->mgmt_tx_ant);
@@ -593,23 +627,84 @@ static void iwl_bg_beacon_update(struct work_struct *work)
593 container_of(work, struct iwl_priv, beacon_update); 627 container_of(work, struct iwl_priv, beacon_update);
594 struct sk_buff *beacon; 628 struct sk_buff *beacon;
595 629
596 /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ 630 mutex_lock(&priv->mutex);
597 beacon = ieee80211_beacon_get(priv->hw, priv->vif); 631 if (!priv->beacon_ctx) {
632 IWL_ERR(priv, "updating beacon w/o beacon context!\n");
633 goto out;
634 }
635
636 if (priv->beacon_ctx->vif->type != NL80211_IFTYPE_AP) {
637 /*
638 * The ucode will send beacon notifications even in
639 * IBSS mode, but we don't want to process them. But
640 * we need to defer the type check to here due to
641 * requiring locking around the beacon_ctx access.
642 */
643 goto out;
644 }
598 645
646 /* Pull updated AP beacon from mac80211. will fail if not in AP mode */
647 beacon = ieee80211_beacon_get(priv->hw, priv->beacon_ctx->vif);
599 if (!beacon) { 648 if (!beacon) {
600 IWL_ERR(priv, "update beacon failed\n"); 649 IWL_ERR(priv, "update beacon failed\n");
601 return; 650 goto out;
602 } 651 }
603 652
604 mutex_lock(&priv->mutex);
605 /* new beacon skb is allocated every time; dispose previous.*/ 653 /* new beacon skb is allocated every time; dispose previous.*/
606 if (priv->ibss_beacon) 654 if (priv->ibss_beacon)
607 dev_kfree_skb(priv->ibss_beacon); 655 dev_kfree_skb(priv->ibss_beacon);
608 656
609 priv->ibss_beacon = beacon; 657 priv->ibss_beacon = beacon;
610 mutex_unlock(&priv->mutex);
611 658
612 iwl_send_beacon_cmd(priv); 659 iwl_send_beacon_cmd(priv);
660 out:
661 mutex_unlock(&priv->mutex);
662}
663
664static void iwl_bg_bt_runtime_config(struct work_struct *work)
665{
666 struct iwl_priv *priv =
667 container_of(work, struct iwl_priv, bt_runtime_config);
668
669 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
670 return;
671
672 /* dont send host command if rf-kill is on */
673 if (!iwl_is_ready_rf(priv))
674 return;
675 priv->cfg->ops->hcmd->send_bt_config(priv);
676}
677
678static void iwl_bg_bt_full_concurrency(struct work_struct *work)
679{
680 struct iwl_priv *priv =
681 container_of(work, struct iwl_priv, bt_full_concurrency);
682 struct iwl_rxon_context *ctx;
683
684 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
685 return;
686
687 /* dont send host command if rf-kill is on */
688 if (!iwl_is_ready_rf(priv))
689 return;
690
691 IWL_DEBUG_INFO(priv, "BT coex in %s mode\n",
692 priv->bt_full_concurrent ?
693 "full concurrency" : "3-wire");
694
695 /*
696 * LQ & RXON updated cmds must be sent before BT Config cmd
697 * to avoid 3-wire collisions
698 */
699 mutex_lock(&priv->mutex);
700 for_each_context(priv, ctx) {
701 if (priv->cfg->ops->hcmd->set_rxon_chain)
702 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
703 iwlcore_commit_rxon(priv, ctx);
704 }
705 mutex_unlock(&priv->mutex);
706
707 priv->cfg->ops->hcmd->send_bt_config(priv);
613} 708}
614 709
615/** 710/**
@@ -781,8 +876,7 @@ static void iwl_rx_beacon_notif(struct iwl_priv *priv,
781 876
782 priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); 877 priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status);
783 878
784 if ((priv->iw_mode == NL80211_IFTYPE_AP) && 879 if (!test_bit(STATUS_EXIT_PENDING, &priv->status))
785 (!test_bit(STATUS_EXIT_PENDING, &priv->status)))
786 queue_work(priv->workqueue, &priv->beacon_update); 880 queue_work(priv->workqueue, &priv->beacon_update);
787} 881}
788 882
@@ -1653,6 +1747,7 @@ static void iwl_nic_start(struct iwl_priv *priv)
1653struct iwlagn_ucode_capabilities { 1747struct iwlagn_ucode_capabilities {
1654 u32 max_probe_length; 1748 u32 max_probe_length;
1655 u32 standard_phy_calibration_size; 1749 u32 standard_phy_calibration_size;
1750 bool pan;
1656}; 1751};
1657 1752
1658static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); 1753static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context);
@@ -1890,6 +1985,11 @@ static int iwlagn_load_firmware(struct iwl_priv *priv,
1890 capa->max_probe_length = 1985 capa->max_probe_length =
1891 le32_to_cpup((__le32 *)tlv_data); 1986 le32_to_cpup((__le32 *)tlv_data);
1892 break; 1987 break;
1988 case IWL_UCODE_TLV_PAN:
1989 if (tlv_len)
1990 goto invalid_tlv_len;
1991 capa->pan = true;
1992 break;
1893 case IWL_UCODE_TLV_INIT_EVTLOG_PTR: 1993 case IWL_UCODE_TLV_INIT_EVTLOG_PTR:
1894 if (tlv_len != sizeof(u32)) 1994 if (tlv_len != sizeof(u32))
1895 goto invalid_tlv_len; 1995 goto invalid_tlv_len;
@@ -2165,6 +2265,12 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
2165 priv->_agn.inst_evtlog_size = priv->cfg->max_event_log_size; 2265 priv->_agn.inst_evtlog_size = priv->cfg->max_event_log_size;
2166 priv->_agn.inst_errlog_ptr = pieces.inst_errlog_ptr; 2266 priv->_agn.inst_errlog_ptr = pieces.inst_errlog_ptr;
2167 2267
2268 if (ucode_capa.pan) {
2269 priv->valid_contexts |= BIT(IWL_RXON_CTX_PAN);
2270 priv->sta_key_max_num = STA_KEY_MAX_NUM_PAN;
2271 } else
2272 priv->sta_key_max_num = STA_KEY_MAX_NUM;
2273
2168 /* Copy images into buffers for card's bus-master reads ... */ 2274 /* Copy images into buffers for card's bus-master reads ... */
2169 2275
2170 /* Runtime instructions (first block of data in file) */ 2276 /* Runtime instructions (first block of data in file) */
@@ -2563,6 +2669,9 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
2563 return pos; 2669 return pos;
2564 } 2670 }
2565 2671
2672 /* enable/disable bt channel announcement */
2673 priv->bt_ch_announce = iwlagn_bt_ch_announce;
2674
2566#ifdef CONFIG_IWLWIFI_DEBUG 2675#ifdef CONFIG_IWLWIFI_DEBUG
2567 if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log) 2676 if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
2568 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES) 2677 size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
@@ -2663,6 +2772,7 @@ static void iwl_rf_kill_ct_config(struct iwl_priv *priv)
2663static void iwl_alive_start(struct iwl_priv *priv) 2772static void iwl_alive_start(struct iwl_priv *priv)
2664{ 2773{
2665 int ret = 0; 2774 int ret = 0;
2775 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
2666 2776
2667 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); 2777 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
2668 2778
@@ -2711,27 +2821,31 @@ static void iwl_alive_start(struct iwl_priv *priv)
2711 if (priv->cfg->ops->hcmd->set_tx_ant) 2821 if (priv->cfg->ops->hcmd->set_tx_ant)
2712 priv->cfg->ops->hcmd->set_tx_ant(priv, priv->cfg->valid_tx_ant); 2822 priv->cfg->ops->hcmd->set_tx_ant(priv, priv->cfg->valid_tx_ant);
2713 2823
2714 if (iwl_is_associated(priv)) { 2824 if (iwl_is_associated_ctx(ctx)) {
2715 struct iwl_rxon_cmd *active_rxon = 2825 struct iwl_rxon_cmd *active_rxon =
2716 (struct iwl_rxon_cmd *)&priv->active_rxon; 2826 (struct iwl_rxon_cmd *)&ctx->active;
2717 /* apply any changes in staging */ 2827 /* apply any changes in staging */
2718 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 2828 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
2719 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2829 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2720 } else { 2830 } else {
2831 struct iwl_rxon_context *tmp;
2721 /* Initialize our rx_config data */ 2832 /* Initialize our rx_config data */
2722 iwl_connection_init_rx_config(priv, NULL); 2833 for_each_context(priv, tmp)
2834 iwl_connection_init_rx_config(priv, tmp);
2723 2835
2724 if (priv->cfg->ops->hcmd->set_rxon_chain) 2836 if (priv->cfg->ops->hcmd->set_rxon_chain)
2725 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2837 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
2726 } 2838 }
2727 2839
2728 /* Configure Bluetooth device coexistence support */ 2840 if (!priv->cfg->advanced_bt_coexist) {
2729 priv->cfg->ops->hcmd->send_bt_config(priv); 2841 /* Configure Bluetooth device coexistence support */
2842 priv->cfg->ops->hcmd->send_bt_config(priv);
2843 }
2730 2844
2731 iwl_reset_run_time_calib(priv); 2845 iwl_reset_run_time_calib(priv);
2732 2846
2733 /* Configure the adapter for unassociated operation */ 2847 /* Configure the adapter for unassociated operation */
2734 iwlcore_commit_rxon(priv); 2848 iwlcore_commit_rxon(priv, ctx);
2735 2849
2736 /* At this point, the NIC is initialized and operational */ 2850 /* At this point, the NIC is initialized and operational */
2737 iwl_rf_kill_ct_config(priv); 2851 iwl_rf_kill_ct_config(priv);
@@ -2764,10 +2878,22 @@ static void __iwl_down(struct iwl_priv *priv)
2764 if (!exit_pending) 2878 if (!exit_pending)
2765 set_bit(STATUS_EXIT_PENDING, &priv->status); 2879 set_bit(STATUS_EXIT_PENDING, &priv->status);
2766 2880
2767 iwl_clear_ucode_stations(priv); 2881 /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
2768 iwl_dealloc_bcast_station(priv); 2882 * to prevent rearm timer */
2883 if (priv->cfg->ops->lib->recover_from_tx_stall)
2884 del_timer_sync(&priv->monitor_recover);
2885
2886 iwl_clear_ucode_stations(priv, NULL);
2887 iwl_dealloc_bcast_stations(priv);
2769 iwl_clear_driver_stations(priv); 2888 iwl_clear_driver_stations(priv);
2770 2889
2890 /* reset BT coex data */
2891 priv->bt_status = 0;
2892 priv->bt_traffic_load = priv->cfg->bt_init_traffic_load;
2893 priv->bt_sco_active = false;
2894 priv->bt_full_concurrent = false;
2895 priv->bt_ci_compliance = 0;
2896
2771 /* Unblock any waiting calls */ 2897 /* Unblock any waiting calls */
2772 wake_up_interruptible_all(&priv->wait_command_queue); 2898 wake_up_interruptible_all(&priv->wait_command_queue);
2773 2899
@@ -2900,6 +3026,7 @@ static int iwl_prepare_card_hw(struct iwl_priv *priv)
2900 3026
2901static int __iwl_up(struct iwl_priv *priv) 3027static int __iwl_up(struct iwl_priv *priv)
2902{ 3028{
3029 struct iwl_rxon_context *ctx;
2903 int i; 3030 int i;
2904 int ret; 3031 int ret;
2905 3032
@@ -2913,9 +3040,13 @@ static int __iwl_up(struct iwl_priv *priv)
2913 return -EIO; 3040 return -EIO;
2914 } 3041 }
2915 3042
2916 ret = iwl_alloc_bcast_station(priv, true); 3043 for_each_context(priv, ctx) {
2917 if (ret) 3044 ret = iwl_alloc_bcast_station(priv, ctx, true);
2918 return ret; 3045 if (ret) {
3046 iwl_dealloc_bcast_stations(priv);
3047 return ret;
3048 }
3049 }
2919 3050
2920 iwl_prepare_card_hw(priv); 3051 iwl_prepare_card_hw(priv);
2921 3052
@@ -2940,6 +3071,12 @@ static int __iwl_up(struct iwl_priv *priv)
2940 3071
2941 iwl_write32(priv, CSR_INT, 0xFFFFFFFF); 3072 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
2942 3073
3074 /* must be initialised before iwl_hw_nic_init */
3075 if (priv->valid_contexts != BIT(IWL_RXON_CTX_BSS))
3076 priv->cmd_queue = IWL_IPAN_CMD_QUEUE_NUM;
3077 else
3078 priv->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM;
3079
2943 ret = iwlagn_hw_nic_init(priv); 3080 ret = iwlagn_hw_nic_init(priv);
2944 if (ret) { 3081 if (ret) {
2945 IWL_ERR(priv, "Unable to init nic\n"); 3082 IWL_ERR(priv, "Unable to init nic\n");
@@ -3070,11 +3207,42 @@ static void iwl_bg_restart(struct work_struct *data)
3070 return; 3207 return;
3071 3208
3072 if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { 3209 if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
3210 struct iwl_rxon_context *ctx;
3211 bool bt_sco, bt_full_concurrent;
3212 u8 bt_ci_compliance;
3213 u8 bt_load;
3214 u8 bt_status;
3215
3073 mutex_lock(&priv->mutex); 3216 mutex_lock(&priv->mutex);
3074 priv->vif = NULL; 3217 for_each_context(priv, ctx)
3218 ctx->vif = NULL;
3075 priv->is_open = 0; 3219 priv->is_open = 0;
3220
3221 /*
3222 * __iwl_down() will clear the BT status variables,
3223 * which is correct, but when we restart we really
3224 * want to keep them so restore them afterwards.
3225 *
3226 * The restart process will later pick them up and
3227 * re-configure the hw when we reconfigure the BT
3228 * command.
3229 */
3230 bt_sco = priv->bt_sco_active;
3231 bt_full_concurrent = priv->bt_full_concurrent;
3232 bt_ci_compliance = priv->bt_ci_compliance;
3233 bt_load = priv->bt_traffic_load;
3234 bt_status = priv->bt_status;
3235
3236 __iwl_down(priv);
3237
3238 priv->bt_sco_active = bt_sco;
3239 priv->bt_full_concurrent = bt_full_concurrent;
3240 priv->bt_ci_compliance = bt_ci_compliance;
3241 priv->bt_traffic_load = bt_load;
3242 priv->bt_status = bt_status;
3243
3076 mutex_unlock(&priv->mutex); 3244 mutex_unlock(&priv->mutex);
3077 iwl_down(priv); 3245 iwl_cancel_deferred_work(priv);
3078 ieee80211_restart_hw(priv->hw); 3246 ieee80211_restart_hw(priv->hw);
3079 } else { 3247 } else {
3080 iwl_down(priv); 3248 iwl_down(priv);
@@ -3105,12 +3273,15 @@ static void iwl_bg_rx_replenish(struct work_struct *data)
3105 3273
3106void iwl_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif) 3274void iwl_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
3107{ 3275{
3276 struct iwl_rxon_context *ctx;
3108 struct ieee80211_conf *conf = NULL; 3277 struct ieee80211_conf *conf = NULL;
3109 int ret = 0; 3278 int ret = 0;
3110 3279
3111 if (!vif || !priv->is_open) 3280 if (!vif || !priv->is_open)
3112 return; 3281 return;
3113 3282
3283 ctx = iwl_rxon_ctx_from_vif(vif);
3284
3114 if (vif->type == NL80211_IFTYPE_AP) { 3285 if (vif->type == NL80211_IFTYPE_AP) {
3115 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__); 3286 IWL_ERR(priv, "%s Should not be called in AP mode\n", __func__);
3116 return; 3287 return;
@@ -3123,42 +3294,42 @@ void iwl_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
3123 3294
3124 conf = ieee80211_get_hw_conf(priv->hw); 3295 conf = ieee80211_get_hw_conf(priv->hw);
3125 3296
3126 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3297 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3127 iwlcore_commit_rxon(priv); 3298 iwlcore_commit_rxon(priv, ctx);
3128 3299
3129 ret = iwl_send_rxon_timing(priv, vif); 3300 ret = iwl_send_rxon_timing(priv, ctx);
3130 if (ret) 3301 if (ret)
3131 IWL_WARN(priv, "REPLY_RXON_TIMING failed - " 3302 IWL_WARN(priv, "RXON timing - "
3132 "Attempting to continue.\n"); 3303 "Attempting to continue.\n");
3133 3304
3134 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3305 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
3135 3306
3136 iwl_set_rxon_ht(priv, &priv->current_ht_config); 3307 iwl_set_rxon_ht(priv, &priv->current_ht_config);
3137 3308
3138 if (priv->cfg->ops->hcmd->set_rxon_chain) 3309 if (priv->cfg->ops->hcmd->set_rxon_chain)
3139 priv->cfg->ops->hcmd->set_rxon_chain(priv); 3310 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
3140 3311
3141 priv->staging_rxon.assoc_id = cpu_to_le16(vif->bss_conf.aid); 3312 ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid);
3142 3313
3143 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", 3314 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
3144 vif->bss_conf.aid, vif->bss_conf.beacon_int); 3315 vif->bss_conf.aid, vif->bss_conf.beacon_int);
3145 3316
3146 if (vif->bss_conf.use_short_preamble) 3317 if (vif->bss_conf.use_short_preamble)
3147 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 3318 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
3148 else 3319 else
3149 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 3320 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
3150 3321
3151 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3322 if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) {
3152 if (vif->bss_conf.use_short_slot) 3323 if (vif->bss_conf.use_short_slot)
3153 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 3324 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
3154 else 3325 else
3155 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3326 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
3156 } 3327 }
3157 3328
3158 iwlcore_commit_rxon(priv); 3329 iwlcore_commit_rxon(priv, ctx);
3159 3330
3160 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", 3331 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
3161 vif->bss_conf.aid, priv->active_rxon.bssid_addr); 3332 vif->bss_conf.aid, ctx->active.bssid_addr);
3162 3333
3163 switch (vif->type) { 3334 switch (vif->type) {
3164 case NL80211_IFTYPE_STATION: 3335 case NL80211_IFTYPE_STATION:
@@ -3201,11 +3372,14 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
3201{ 3372{
3202 int ret; 3373 int ret;
3203 struct ieee80211_hw *hw = priv->hw; 3374 struct ieee80211_hw *hw = priv->hw;
3375 struct iwl_rxon_context *ctx;
3376
3204 hw->rate_control_algorithm = "iwl-agn-rs"; 3377 hw->rate_control_algorithm = "iwl-agn-rs";
3205 3378
3206 /* Tell mac80211 our characteristics */ 3379 /* Tell mac80211 our characteristics */
3207 hw->flags = IEEE80211_HW_SIGNAL_DBM | 3380 hw->flags = IEEE80211_HW_SIGNAL_DBM |
3208 IEEE80211_HW_AMPDU_AGGREGATION | 3381 IEEE80211_HW_AMPDU_AGGREGATION |
3382 IEEE80211_HW_NEED_DTIM_PERIOD |
3209 IEEE80211_HW_SPECTRUM_MGMT; 3383 IEEE80211_HW_SPECTRUM_MGMT;
3210 3384
3211 if (!priv->cfg->broken_powersave) 3385 if (!priv->cfg->broken_powersave)
@@ -3219,9 +3393,10 @@ static int iwl_mac_setup_register(struct iwl_priv *priv,
3219 hw->sta_data_size = sizeof(struct iwl_station_priv); 3393 hw->sta_data_size = sizeof(struct iwl_station_priv);
3220 hw->vif_data_size = sizeof(struct iwl_vif_priv); 3394 hw->vif_data_size = sizeof(struct iwl_vif_priv);
3221 3395
3222 hw->wiphy->interface_modes = 3396 for_each_context(priv, ctx) {
3223 BIT(NL80211_IFTYPE_STATION) | 3397 hw->wiphy->interface_modes |= ctx->interface_modes;
3224 BIT(NL80211_IFTYPE_ADHOC); 3398 hw->wiphy->interface_modes |= ctx->exclusive_interface_modes;
3399 }
3225 3400
3226 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | 3401 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
3227 WIPHY_FLAG_DISABLE_BEACON_HINTS; 3402 WIPHY_FLAG_DISABLE_BEACON_HINTS;
@@ -3349,22 +3524,25 @@ static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3349 3524
3350void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif) 3525void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
3351{ 3526{
3527 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
3352 int ret = 0; 3528 int ret = 0;
3353 3529
3530 lockdep_assert_held(&priv->mutex);
3531
3354 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3532 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3355 return; 3533 return;
3356 3534
3357 /* The following should be done only at AP bring up */ 3535 /* The following should be done only at AP bring up */
3358 if (!iwl_is_associated(priv)) { 3536 if (!iwl_is_associated_ctx(ctx)) {
3359 3537
3360 /* RXON - unassoc (to set timing command) */ 3538 /* RXON - unassoc (to set timing command) */
3361 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3539 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3362 iwlcore_commit_rxon(priv); 3540 iwlcore_commit_rxon(priv, ctx);
3363 3541
3364 /* RXON Timing */ 3542 /* RXON Timing */
3365 ret = iwl_send_rxon_timing(priv, vif); 3543 ret = iwl_send_rxon_timing(priv, ctx);
3366 if (ret) 3544 if (ret)
3367 IWL_WARN(priv, "REPLY_RXON_TIMING failed - " 3545 IWL_WARN(priv, "RXON timing failed - "
3368 "Attempting to continue.\n"); 3546 "Attempting to continue.\n");
3369 3547
3370 /* AP has all antennas */ 3548 /* AP has all antennas */
@@ -3372,28 +3550,30 @@ void iwl_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
3372 priv->hw_params.valid_rx_ant; 3550 priv->hw_params.valid_rx_ant;
3373 iwl_set_rxon_ht(priv, &priv->current_ht_config); 3551 iwl_set_rxon_ht(priv, &priv->current_ht_config);
3374 if (priv->cfg->ops->hcmd->set_rxon_chain) 3552 if (priv->cfg->ops->hcmd->set_rxon_chain)
3375 priv->cfg->ops->hcmd->set_rxon_chain(priv); 3553 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
3376 3554
3377 priv->staging_rxon.assoc_id = 0; 3555 ctx->staging.assoc_id = 0;
3378 3556
3379 if (vif->bss_conf.use_short_preamble) 3557 if (vif->bss_conf.use_short_preamble)
3380 priv->staging_rxon.flags |= 3558 ctx->staging.flags |=
3381 RXON_FLG_SHORT_PREAMBLE_MSK; 3559 RXON_FLG_SHORT_PREAMBLE_MSK;
3382 else 3560 else
3383 priv->staging_rxon.flags &= 3561 ctx->staging.flags &=
3384 ~RXON_FLG_SHORT_PREAMBLE_MSK; 3562 ~RXON_FLG_SHORT_PREAMBLE_MSK;
3385 3563
3386 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3564 if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) {
3387 if (vif->bss_conf.use_short_slot) 3565 if (vif->bss_conf.use_short_slot)
3388 priv->staging_rxon.flags |= 3566 ctx->staging.flags |=
3389 RXON_FLG_SHORT_SLOT_MSK; 3567 RXON_FLG_SHORT_SLOT_MSK;
3390 else 3568 else
3391 priv->staging_rxon.flags &= 3569 ctx->staging.flags &=
3392 ~RXON_FLG_SHORT_SLOT_MSK; 3570 ~RXON_FLG_SHORT_SLOT_MSK;
3393 } 3571 }
3572 /* need to send beacon cmd before committing assoc RXON! */
3573 iwl_send_beacon_cmd(priv);
3394 /* restore RXON assoc */ 3574 /* restore RXON assoc */
3395 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3575 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
3396 iwlcore_commit_rxon(priv); 3576 iwlcore_commit_rxon(priv, ctx);
3397 } 3577 }
3398 iwl_send_beacon_cmd(priv); 3578 iwl_send_beacon_cmd(priv);
3399 3579
@@ -3410,9 +3590,11 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
3410{ 3590{
3411 3591
3412 struct iwl_priv *priv = hw->priv; 3592 struct iwl_priv *priv = hw->priv;
3593 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
3594
3413 IWL_DEBUG_MAC80211(priv, "enter\n"); 3595 IWL_DEBUG_MAC80211(priv, "enter\n");
3414 3596
3415 iwl_update_tkip_key(priv, keyconf, sta, 3597 iwl_update_tkip_key(priv, vif_priv->ctx, keyconf, sta,
3416 iv32, phase1key); 3598 iv32, phase1key);
3417 3599
3418 IWL_DEBUG_MAC80211(priv, "leave\n"); 3600 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -3424,6 +3606,8 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3424 struct ieee80211_key_conf *key) 3606 struct ieee80211_key_conf *key)
3425{ 3607{
3426 struct iwl_priv *priv = hw->priv; 3608 struct iwl_priv *priv = hw->priv;
3609 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
3610 struct iwl_rxon_context *ctx = vif_priv->ctx;
3427 int ret; 3611 int ret;
3428 u8 sta_id; 3612 u8 sta_id;
3429 bool is_default_wep_key = false; 3613 bool is_default_wep_key = false;
@@ -3435,7 +3619,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3435 return -EOPNOTSUPP; 3619 return -EOPNOTSUPP;
3436 } 3620 }
3437 3621
3438 sta_id = iwl_sta_id_or_broadcast(priv, sta); 3622 sta_id = iwl_sta_id_or_broadcast(priv, vif_priv->ctx, sta);
3439 if (sta_id == IWL_INVALID_STATION) 3623 if (sta_id == IWL_INVALID_STATION)
3440 return -EINVAL; 3624 return -EINVAL;
3441 3625
@@ -3452,7 +3636,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3452 key->cipher == WLAN_CIPHER_SUITE_WEP104) && 3636 key->cipher == WLAN_CIPHER_SUITE_WEP104) &&
3453 !sta) { 3637 !sta) {
3454 if (cmd == SET_KEY) 3638 if (cmd == SET_KEY)
3455 is_default_wep_key = !priv->key_mapping_key; 3639 is_default_wep_key = !ctx->key_mapping_keys;
3456 else 3640 else
3457 is_default_wep_key = 3641 is_default_wep_key =
3458 (key->hw_key_idx == HW_KEY_DEFAULT); 3642 (key->hw_key_idx == HW_KEY_DEFAULT);
@@ -3461,17 +3645,18 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3461 switch (cmd) { 3645 switch (cmd) {
3462 case SET_KEY: 3646 case SET_KEY:
3463 if (is_default_wep_key) 3647 if (is_default_wep_key)
3464 ret = iwl_set_default_wep_key(priv, key); 3648 ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key);
3465 else 3649 else
3466 ret = iwl_set_dynamic_key(priv, key, sta_id); 3650 ret = iwl_set_dynamic_key(priv, vif_priv->ctx,
3651 key, sta_id);
3467 3652
3468 IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); 3653 IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n");
3469 break; 3654 break;
3470 case DISABLE_KEY: 3655 case DISABLE_KEY:
3471 if (is_default_wep_key) 3656 if (is_default_wep_key)
3472 ret = iwl_remove_default_wep_key(priv, key); 3657 ret = iwl_remove_default_wep_key(priv, ctx, key);
3473 else 3658 else
3474 ret = iwl_remove_dynamic_key(priv, key, sta_id); 3659 ret = iwl_remove_dynamic_key(priv, ctx, key, sta_id);
3475 3660
3476 IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); 3661 IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n");
3477 break; 3662 break;
@@ -3540,8 +3725,8 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3540 3725
3541 sta_priv->lq_sta.lq.general_params.flags &= 3726 sta_priv->lq_sta.lq.general_params.flags &=
3542 ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; 3727 ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK;
3543 iwl_send_lq_cmd(priv, &sta_priv->lq_sta.lq, 3728 iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif),
3544 CMD_ASYNC, false); 3729 &sta_priv->lq_sta.lq, CMD_ASYNC, false);
3545 } 3730 }
3546 break; 3731 break;
3547 case IEEE80211_AMPDU_TX_OPERATIONAL: 3732 case IEEE80211_AMPDU_TX_OPERATIONAL:
@@ -3556,8 +3741,8 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3556 3741
3557 sta_priv->lq_sta.lq.general_params.flags |= 3742 sta_priv->lq_sta.lq.general_params.flags |=
3558 LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; 3743 LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK;
3559 iwl_send_lq_cmd(priv, &sta_priv->lq_sta.lq, 3744 iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif),
3560 CMD_ASYNC, false); 3745 &sta_priv->lq_sta.lq, CMD_ASYNC, false);
3561 } 3746 }
3562 ret = 0; 3747 ret = 0;
3563 break; 3748 break;
@@ -3603,6 +3788,7 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3603{ 3788{
3604 struct iwl_priv *priv = hw->priv; 3789 struct iwl_priv *priv = hw->priv;
3605 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 3790 struct iwl_station_priv *sta_priv = (void *)sta->drv_priv;
3791 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
3606 bool is_ap = vif->type == NL80211_IFTYPE_STATION; 3792 bool is_ap = vif->type == NL80211_IFTYPE_STATION;
3607 int ret; 3793 int ret;
3608 u8 sta_id; 3794 u8 sta_id;
@@ -3618,8 +3804,8 @@ static int iwlagn_mac_sta_add(struct ieee80211_hw *hw,
3618 if (vif->type == NL80211_IFTYPE_AP) 3804 if (vif->type == NL80211_IFTYPE_AP)
3619 sta_priv->client = true; 3805 sta_priv->client = true;
3620 3806
3621 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap, 3807 ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr,
3622 &sta_id); 3808 is_ap, sta, &sta_id);
3623 if (ret) { 3809 if (ret) {
3624 IWL_ERR(priv, "Unable to add station %pM (%d)\n", 3810 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3625 sta->addr, ret); 3811 sta->addr, ret);
@@ -3647,6 +3833,15 @@ static void iwl_mac_channel_switch(struct ieee80211_hw *hw,
3647 struct ieee80211_conf *conf = &hw->conf; 3833 struct ieee80211_conf *conf = &hw->conf;
3648 struct ieee80211_channel *channel = ch_switch->channel; 3834 struct ieee80211_channel *channel = ch_switch->channel;
3649 struct iwl_ht_config *ht_conf = &priv->current_ht_config; 3835 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
3836 /*
3837 * MULTI-FIXME
3838 * When we add support for multiple interfaces, we need to
3839 * revisit this. The channel switch command in the device
3840 * only affects the BSS context, but what does that really
3841 * mean? And what if we get a CSA on the second interface?
3842 * This needs a lot of work.
3843 */
3844 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3650 u16 ch; 3845 u16 ch;
3651 unsigned long flags = 0; 3846 unsigned long flags = 0;
3652 3847
@@ -3659,7 +3854,7 @@ static void iwl_mac_channel_switch(struct ieee80211_hw *hw,
3659 test_bit(STATUS_SCANNING, &priv->status)) 3854 test_bit(STATUS_SCANNING, &priv->status))
3660 goto out_exit; 3855 goto out_exit;
3661 3856
3662 if (!iwl_is_associated(priv)) 3857 if (!iwl_is_associated_ctx(ctx))
3663 goto out_exit; 3858 goto out_exit;
3664 3859
3665 /* channel switch in progress */ 3860 /* channel switch in progress */
@@ -3670,7 +3865,7 @@ static void iwl_mac_channel_switch(struct ieee80211_hw *hw,
3670 if (priv->cfg->ops->lib->set_channel_switch) { 3865 if (priv->cfg->ops->lib->set_channel_switch) {
3671 3866
3672 ch = channel->hw_value; 3867 ch = channel->hw_value;
3673 if (le16_to_cpu(priv->active_rxon.channel) != ch) { 3868 if (le16_to_cpu(ctx->active.channel) != ch) {
3674 ch_info = iwl_get_channel_info(priv, 3869 ch_info = iwl_get_channel_info(priv,
3675 channel->band, 3870 channel->band,
3676 ch); 3871 ch);
@@ -3683,31 +3878,31 @@ static void iwl_mac_channel_switch(struct ieee80211_hw *hw,
3683 priv->current_ht_config.smps = conf->smps_mode; 3878 priv->current_ht_config.smps = conf->smps_mode;
3684 3879
3685 /* Configure HT40 channels */ 3880 /* Configure HT40 channels */
3686 ht_conf->is_ht = conf_is_ht(conf); 3881 ctx->ht.enabled = conf_is_ht(conf);
3687 if (ht_conf->is_ht) { 3882 if (ctx->ht.enabled) {
3688 if (conf_is_ht40_minus(conf)) { 3883 if (conf_is_ht40_minus(conf)) {
3689 ht_conf->extension_chan_offset = 3884 ctx->ht.extension_chan_offset =
3690 IEEE80211_HT_PARAM_CHA_SEC_BELOW; 3885 IEEE80211_HT_PARAM_CHA_SEC_BELOW;
3691 ht_conf->is_40mhz = true; 3886 ctx->ht.is_40mhz = true;
3692 } else if (conf_is_ht40_plus(conf)) { 3887 } else if (conf_is_ht40_plus(conf)) {
3693 ht_conf->extension_chan_offset = 3888 ctx->ht.extension_chan_offset =
3694 IEEE80211_HT_PARAM_CHA_SEC_ABOVE; 3889 IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
3695 ht_conf->is_40mhz = true; 3890 ctx->ht.is_40mhz = true;
3696 } else { 3891 } else {
3697 ht_conf->extension_chan_offset = 3892 ctx->ht.extension_chan_offset =
3698 IEEE80211_HT_PARAM_CHA_SEC_NONE; 3893 IEEE80211_HT_PARAM_CHA_SEC_NONE;
3699 ht_conf->is_40mhz = false; 3894 ctx->ht.is_40mhz = false;
3700 } 3895 }
3701 } else 3896 } else
3702 ht_conf->is_40mhz = false; 3897 ctx->ht.is_40mhz = false;
3703 3898
3704 if (le16_to_cpu(priv->staging_rxon.channel) != ch) 3899 if ((le16_to_cpu(ctx->staging.channel) != ch))
3705 priv->staging_rxon.flags = 0; 3900 ctx->staging.flags = 0;
3706 3901
3707 iwl_set_rxon_channel(priv, channel); 3902 iwl_set_rxon_channel(priv, channel, ctx);
3708 iwl_set_rxon_ht(priv, ht_conf); 3903 iwl_set_rxon_ht(priv, ht_conf);
3709 iwl_set_flags_for_band(priv, channel->band, 3904 iwl_set_flags_for_band(priv, ctx, channel->band,
3710 priv->vif); 3905 ctx->vif);
3711 spin_unlock_irqrestore(&priv->lock, flags); 3906 spin_unlock_irqrestore(&priv->lock, flags);
3712 3907
3713 iwl_set_rate(priv); 3908 iwl_set_rate(priv);
@@ -3724,7 +3919,7 @@ out:
3724 mutex_unlock(&priv->mutex); 3919 mutex_unlock(&priv->mutex);
3725out_exit: 3920out_exit:
3726 if (!priv->switch_rxon.switch_in_progress) 3921 if (!priv->switch_rxon.switch_in_progress)
3727 ieee80211_chswitch_done(priv->vif, false); 3922 ieee80211_chswitch_done(ctx->vif, false);
3728 IWL_DEBUG_MAC80211(priv, "leave\n"); 3923 IWL_DEBUG_MAC80211(priv, "leave\n");
3729} 3924}
3730 3925
@@ -3735,6 +3930,7 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
3735{ 3930{
3736 struct iwl_priv *priv = hw->priv; 3931 struct iwl_priv *priv = hw->priv;
3737 __le32 filter_or = 0, filter_nand = 0; 3932 __le32 filter_or = 0, filter_nand = 0;
3933 struct iwl_rxon_context *ctx;
3738 3934
3739#define CHK(test, flag) do { \ 3935#define CHK(test, flag) do { \
3740 if (*total_flags & (test)) \ 3936 if (*total_flags & (test)) \
@@ -3754,10 +3950,11 @@ static void iwlagn_configure_filter(struct ieee80211_hw *hw,
3754 3950
3755 mutex_lock(&priv->mutex); 3951 mutex_lock(&priv->mutex);
3756 3952
3757 priv->staging_rxon.filter_flags &= ~filter_nand; 3953 for_each_context(priv, ctx) {
3758 priv->staging_rxon.filter_flags |= filter_or; 3954 ctx->staging.filter_flags &= ~filter_nand;
3759 3955 ctx->staging.filter_flags |= filter_or;
3760 iwlcore_commit_rxon(priv); 3956 iwlcore_commit_rxon(priv, ctx);
3957 }
3761 3958
3762 mutex_unlock(&priv->mutex); 3959 mutex_unlock(&priv->mutex);
3763 3960
@@ -3826,6 +4023,8 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
3826 INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update); 4023 INIT_WORK(&priv->beacon_update, iwl_bg_beacon_update);
3827 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work); 4024 INIT_WORK(&priv->run_time_calib_work, iwl_bg_run_time_calib_work);
3828 INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush); 4025 INIT_WORK(&priv->tx_flush, iwl_bg_tx_flush);
4026 INIT_WORK(&priv->bt_full_concurrency, iwl_bg_bt_full_concurrency);
4027 INIT_WORK(&priv->bt_runtime_config, iwl_bg_bt_runtime_config);
3829 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start); 4028 INIT_DELAYED_WORK(&priv->init_alive_start, iwl_bg_init_alive_start);
3830 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); 4029 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start);
3831 4030
@@ -3868,10 +4067,10 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3868 cancel_delayed_work(&priv->alive_start); 4067 cancel_delayed_work(&priv->alive_start);
3869 cancel_work_sync(&priv->run_time_calib_work); 4068 cancel_work_sync(&priv->run_time_calib_work);
3870 cancel_work_sync(&priv->beacon_update); 4069 cancel_work_sync(&priv->beacon_update);
4070 cancel_work_sync(&priv->bt_full_concurrency);
4071 cancel_work_sync(&priv->bt_runtime_config);
3871 del_timer_sync(&priv->statistics_periodic); 4072 del_timer_sync(&priv->statistics_periodic);
3872 del_timer_sync(&priv->ucode_trace); 4073 del_timer_sync(&priv->ucode_trace);
3873 if (priv->cfg->ops->lib->recover_from_tx_stall)
3874 del_timer_sync(&priv->monitor_recover);
3875} 4074}
3876 4075
3877static void iwl_init_hw_rates(struct iwl_priv *priv, 4076static void iwl_init_hw_rates(struct iwl_priv *priv,
@@ -3926,10 +4125,22 @@ static int iwl_init_drv(struct iwl_priv *priv)
3926 4125
3927 /* Choose which receivers/antennas to use */ 4126 /* Choose which receivers/antennas to use */
3928 if (priv->cfg->ops->hcmd->set_rxon_chain) 4127 if (priv->cfg->ops->hcmd->set_rxon_chain)
3929 priv->cfg->ops->hcmd->set_rxon_chain(priv); 4128 priv->cfg->ops->hcmd->set_rxon_chain(priv,
4129 &priv->contexts[IWL_RXON_CTX_BSS]);
3930 4130
3931 iwl_init_scan_params(priv); 4131 iwl_init_scan_params(priv);
3932 4132
4133 /* init bt coex */
4134 if (priv->cfg->advanced_bt_coexist) {
4135 priv->kill_ack_mask = IWLAGN_BT_KILL_ACK_MASK_DEFAULT;
4136 priv->kill_cts_mask = IWLAGN_BT_KILL_CTS_MASK_DEFAULT;
4137 priv->bt_valid = IWLAGN_BT_ALL_VALID_MSK;
4138 priv->bt_on_thresh = BT_ON_THRESHOLD_DEF;
4139 priv->bt_duration = BT_DURATION_LIMIT_DEF;
4140 priv->dynamic_frag_thresh = BT_FRAG_THRESHOLD_DEF;
4141 priv->dynamic_agg_thresh = BT_AGG_THRESHOLD_DEF;
4142 }
4143
3933 /* Set the tx_power_user_lmt to the lowest power level 4144 /* Set the tx_power_user_lmt to the lowest power level
3934 * this value will get overwritten by channel max power avg 4145 * this value will get overwritten by channel max power avg
3935 * from eeprom */ 4146 * from eeprom */
@@ -4013,9 +4224,31 @@ static int iwl_set_hw_params(struct iwl_priv *priv)
4013 return priv->cfg->ops->lib->set_hw_params(priv); 4224 return priv->cfg->ops->lib->set_hw_params(priv);
4014} 4225}
4015 4226
4227static const u8 iwlagn_bss_ac_to_fifo[] = {
4228 IWL_TX_FIFO_VO,
4229 IWL_TX_FIFO_VI,
4230 IWL_TX_FIFO_BE,
4231 IWL_TX_FIFO_BK,
4232};
4233
4234static const u8 iwlagn_bss_ac_to_queue[] = {
4235 0, 1, 2, 3,
4236};
4237
4238static const u8 iwlagn_pan_ac_to_fifo[] = {
4239 IWL_TX_FIFO_VO_IPAN,
4240 IWL_TX_FIFO_VI_IPAN,
4241 IWL_TX_FIFO_BE_IPAN,
4242 IWL_TX_FIFO_BK_IPAN,
4243};
4244
4245static const u8 iwlagn_pan_ac_to_queue[] = {
4246 7, 6, 5, 4,
4247};
4248
4016static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 4249static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4017{ 4250{
4018 int err = 0; 4251 int err = 0, i;
4019 struct iwl_priv *priv; 4252 struct iwl_priv *priv;
4020 struct ieee80211_hw *hw; 4253 struct ieee80211_hw *hw;
4021 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 4254 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
@@ -4043,6 +4276,51 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4043 priv = hw->priv; 4276 priv = hw->priv;
4044 /* At this point both hw and priv are allocated. */ 4277 /* At this point both hw and priv are allocated. */
4045 4278
4279 /*
4280 * The default context is always valid,
4281 * more may be discovered when firmware
4282 * is loaded.
4283 */
4284 priv->valid_contexts = BIT(IWL_RXON_CTX_BSS);
4285
4286 for (i = 0; i < NUM_IWL_RXON_CTX; i++)
4287 priv->contexts[i].ctxid = i;
4288
4289 priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON;
4290 priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING;
4291 priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC;
4292 priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM;
4293 priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID;
4294 priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
4295 priv->contexts[IWL_RXON_CTX_BSS].ac_to_fifo = iwlagn_bss_ac_to_fifo;
4296 priv->contexts[IWL_RXON_CTX_BSS].ac_to_queue = iwlagn_bss_ac_to_queue;
4297 priv->contexts[IWL_RXON_CTX_BSS].exclusive_interface_modes =
4298 BIT(NL80211_IFTYPE_ADHOC);
4299 priv->contexts[IWL_RXON_CTX_BSS].interface_modes =
4300 BIT(NL80211_IFTYPE_STATION);
4301 priv->contexts[IWL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS;
4302 priv->contexts[IWL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS;
4303 priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS;
4304
4305 priv->contexts[IWL_RXON_CTX_PAN].rxon_cmd = REPLY_WIPAN_RXON;
4306 priv->contexts[IWL_RXON_CTX_PAN].rxon_timing_cmd = REPLY_WIPAN_RXON_TIMING;
4307 priv->contexts[IWL_RXON_CTX_PAN].rxon_assoc_cmd = REPLY_WIPAN_RXON_ASSOC;
4308 priv->contexts[IWL_RXON_CTX_PAN].qos_cmd = REPLY_WIPAN_QOS_PARAM;
4309 priv->contexts[IWL_RXON_CTX_PAN].ap_sta_id = IWL_AP_ID_PAN;
4310 priv->contexts[IWL_RXON_CTX_PAN].wep_key_cmd = REPLY_WIPAN_WEPKEY;
4311 priv->contexts[IWL_RXON_CTX_PAN].bcast_sta_id = IWLAGN_PAN_BCAST_ID;
4312 priv->contexts[IWL_RXON_CTX_PAN].station_flags = STA_FLG_PAN_STATION;
4313 priv->contexts[IWL_RXON_CTX_PAN].ac_to_fifo = iwlagn_pan_ac_to_fifo;
4314 priv->contexts[IWL_RXON_CTX_PAN].ac_to_queue = iwlagn_pan_ac_to_queue;
4315 priv->contexts[IWL_RXON_CTX_PAN].mcast_queue = IWL_IPAN_MCAST_QUEUE;
4316 priv->contexts[IWL_RXON_CTX_PAN].interface_modes =
4317 BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP);
4318 priv->contexts[IWL_RXON_CTX_PAN].ap_devtype = RXON_DEV_TYPE_CP;
4319 priv->contexts[IWL_RXON_CTX_PAN].station_devtype = RXON_DEV_TYPE_2STA;
4320 priv->contexts[IWL_RXON_CTX_PAN].unused_devtype = RXON_DEV_TYPE_P2P;
4321
4322 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
4323
4046 SET_IEEE80211_DEV(hw, &pdev->dev); 4324 SET_IEEE80211_DEV(hw, &pdev->dev);
4047 4325
4048 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); 4326 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
@@ -4050,6 +4328,14 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4050 priv->pci_dev = pdev; 4328 priv->pci_dev = pdev;
4051 priv->inta_mask = CSR_INI_SET_MASK; 4329 priv->inta_mask = CSR_INI_SET_MASK;
4052 4330
4331 /* is antenna coupling more than 35dB ? */
4332 priv->bt_ant_couple_ok =
4333 (iwlagn_ant_coupling > IWL_BT_ANTENNA_COUPLING_THRESHOLD) ?
4334 true : false;
4335
4336 /* enable/disable bt channel announcement */
4337 priv->bt_ch_announce = iwlagn_bt_ch_announce;
4338
4053 if (iwl_alloc_traffic_mem(priv)) 4339 if (iwl_alloc_traffic_mem(priv))
4054 IWL_ERR(priv, "Not enough memory to generate traffic log\n"); 4340 IWL_ERR(priv, "Not enough memory to generate traffic log\n");
4055 4341
@@ -4583,3 +4869,11 @@ module_param_named(ucode_alternative, iwlagn_wanted_ucode_alternative, int,
4583 S_IRUGO); 4869 S_IRUGO);
4584MODULE_PARM_DESC(ucode_alternative, 4870MODULE_PARM_DESC(ucode_alternative,
4585 "specify ucode alternative to use from ucode file"); 4871 "specify ucode alternative to use from ucode file");
4872
4873module_param_named(antenna_coupling, iwlagn_ant_coupling, int, S_IRUGO);
4874MODULE_PARM_DESC(antenna_coupling,
4875 "specify antenna coupling in dB (defualt: 0 dB)");
4876
4877module_param_named(bt_ch_announce, iwlagn_bt_ch_announce, bool, S_IRUGO);
4878MODULE_PARM_DESC(bt_ch_announce,
4879 "Enable BT channel announcement mode (default: enable)");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index cc6464dc72e5..7c542a8c8f81 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -95,6 +95,7 @@ extern struct iwl_cfg iwl1000_bg_cfg;
95 95
96extern struct iwl_mod_params iwlagn_mod_params; 96extern struct iwl_mod_params iwlagn_mod_params;
97extern struct iwl_hcmd_ops iwlagn_hcmd; 97extern struct iwl_hcmd_ops iwlagn_hcmd;
98extern struct iwl_hcmd_ops iwlagn_bt_hcmd;
98extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils; 99extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils;
99 100
100int iwl_reset_ict(struct iwl_priv *priv); 101int iwl_reset_ict(struct iwl_priv *priv);
@@ -223,7 +224,16 @@ int iwlagn_manage_ibss_station(struct iwl_priv *priv,
223 struct ieee80211_vif *vif, bool add); 224 struct ieee80211_vif *vif, bool add);
224 225
225/* hcmd */ 226/* hcmd */
226int iwlagn_send_rxon_assoc(struct iwl_priv *priv); 227int iwlagn_send_rxon_assoc(struct iwl_priv *priv,
228 struct iwl_rxon_context *ctx);
227int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant); 229int iwlagn_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant);
228 230
231/* bt coex */
232void iwlagn_send_advance_bt_config(struct iwl_priv *priv);
233void iwlagn_bt_coex_profile_notif(struct iwl_priv *priv,
234 struct iwl_rx_mem_buffer *rxb);
235void iwlagn_bt_rx_handler_setup(struct iwl_priv *priv);
236void iwlagn_bt_setup_deferred_work(struct iwl_priv *priv);
237void iwlagn_bt_cancel_deferred_work(struct iwl_priv *priv);
238
229#endif /* __iwl_agn_h__ */ 239#endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 4083e4430827..3e4ba31b5d59 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -62,7 +62,7 @@
62 *****************************************************************************/ 62 *****************************************************************************/
63/* 63/*
64 * Please use this file (iwl-commands.h) only for uCode API definitions. 64 * Please use this file (iwl-commands.h) only for uCode API definitions.
65 * Please use iwl-4965-hw.h for hardware-related definitions. 65 * Please use iwl-xxxx-hw.h for hardware-related definitions.
66 * Please use iwl-dev.h for driver implementation definitions. 66 * Please use iwl-dev.h for driver implementation definitions.
67 */ 67 */
68 68
@@ -173,6 +173,23 @@ enum {
173 REPLY_RX_MPDU_CMD = 0xc1, 173 REPLY_RX_MPDU_CMD = 0xc1,
174 REPLY_RX = 0xc3, 174 REPLY_RX = 0xc3,
175 REPLY_COMPRESSED_BA = 0xc5, 175 REPLY_COMPRESSED_BA = 0xc5,
176
177 /* BT Coex */
178 REPLY_BT_COEX_PRIO_TABLE = 0xcc,
179 REPLY_BT_COEX_PROT_ENV = 0xcd,
180 REPLY_BT_COEX_PROFILE_NOTIF = 0xce,
181 REPLY_BT_COEX_SCO = 0xcf,
182
183 /* PAN commands */
184 REPLY_WIPAN_PARAMS = 0xb2,
185 REPLY_WIPAN_RXON = 0xb3, /* use REPLY_RXON structure */
186 REPLY_WIPAN_RXON_TIMING = 0xb4, /* use REPLY_RXON_TIMING structure */
187 REPLY_WIPAN_RXON_ASSOC = 0xb6, /* use REPLY_RXON_ASSOC structure */
188 REPLY_WIPAN_QOS_PARAM = 0xb7, /* use REPLY_QOS_PARAM structure */
189 REPLY_WIPAN_WEPKEY = 0xb8, /* use REPLY_WEPKEY structure */
190 REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9,
191 REPLY_WIPAN_NOA_NOTIFICATION = 0xbc,
192
176 REPLY_MAX = 0xff 193 REPLY_MAX = 0xff
177}; 194};
178 195
@@ -600,6 +617,9 @@ enum {
600 RXON_DEV_TYPE_ESS = 3, 617 RXON_DEV_TYPE_ESS = 3,
601 RXON_DEV_TYPE_IBSS = 4, 618 RXON_DEV_TYPE_IBSS = 4,
602 RXON_DEV_TYPE_SNIFFER = 6, 619 RXON_DEV_TYPE_SNIFFER = 6,
620 RXON_DEV_TYPE_CP = 7,
621 RXON_DEV_TYPE_2STA = 8,
622 RXON_DEV_TYPE_P2P = 9,
603}; 623};
604 624
605 625
@@ -816,7 +836,8 @@ struct iwl_rxon_time_cmd {
816 __le16 atim_window; 836 __le16 atim_window;
817 __le32 beacon_init_val; 837 __le32 beacon_init_val;
818 __le16 listen_interval; 838 __le16 listen_interval;
819 __le16 reserved; 839 u8 dtim_period;
840 u8 delta_cp_bss_tbtts;
820} __packed; 841} __packed;
821 842
822/* 843/*
@@ -953,11 +974,13 @@ struct iwl_qosparam_cmd {
953 974
954/* Special, dedicated locations within device's station table */ 975/* Special, dedicated locations within device's station table */
955#define IWL_AP_ID 0 976#define IWL_AP_ID 0
977#define IWL_AP_ID_PAN 1
956#define IWL_STA_ID 2 978#define IWL_STA_ID 2
957#define IWL3945_BROADCAST_ID 24 979#define IWL3945_BROADCAST_ID 24
958#define IWL3945_STATION_COUNT 25 980#define IWL3945_STATION_COUNT 25
959#define IWL4965_BROADCAST_ID 31 981#define IWL4965_BROADCAST_ID 31
960#define IWL4965_STATION_COUNT 32 982#define IWL4965_STATION_COUNT 32
983#define IWLAGN_PAN_BCAST_ID 14
961#define IWLAGN_BROADCAST_ID 15 984#define IWLAGN_BROADCAST_ID 15
962#define IWLAGN_STATION_COUNT 16 985#define IWLAGN_STATION_COUNT 16
963 986
@@ -966,6 +989,7 @@ struct iwl_qosparam_cmd {
966 989
967#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) 990#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2)
968#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) 991#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8)
992#define STA_FLG_PAN_STATION cpu_to_le32(1 << 13)
969#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17) 993#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17)
970#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18) 994#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18)
971#define STA_FLG_MAX_AGG_SIZE_POS (19) 995#define STA_FLG_MAX_AGG_SIZE_POS (19)
@@ -994,6 +1018,7 @@ struct iwl_qosparam_cmd {
994#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000) 1018#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000)
995#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000) 1019#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000)
996#define STA_KEY_MAX_NUM 8 1020#define STA_KEY_MAX_NUM 8
1021#define STA_KEY_MAX_NUM_PAN 16
997 1022
998/* Flags indicate whether to modify vs. don't change various station params */ 1023/* Flags indicate whether to modify vs. don't change various station params */
999#define STA_MODIFY_KEY_MASK 0x01 1024#define STA_MODIFY_KEY_MASK 0x01
@@ -1056,7 +1081,8 @@ struct sta_id_modify {
1056 * 1081 *
1057 * The device contains an internal table of per-station information, 1082 * The device contains an internal table of per-station information,
1058 * with info on security keys, aggregation parameters, and Tx rates for 1083 * with info on security keys, aggregation parameters, and Tx rates for
1059 * initial Tx attempt and any retries (4965 uses REPLY_TX_LINK_QUALITY_CMD, 1084 * initial Tx attempt and any retries (agn devices uses
1085 * REPLY_TX_LINK_QUALITY_CMD,
1060 * 3945 uses REPLY_RATE_SCALE to set up rate tables). 1086 * 3945 uses REPLY_RATE_SCALE to set up rate tables).
1061 * 1087 *
1062 * REPLY_ADD_STA sets up the table entry for one station, either creating 1088 * REPLY_ADD_STA sets up the table entry for one station, either creating
@@ -1427,12 +1453,12 @@ struct iwl_rx_mpdu_res_start {
1427 * uCode handles all timing and protocol related to control frames 1453 * uCode handles all timing and protocol related to control frames
1428 * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler 1454 * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler
1429 * handle reception of block-acks; uCode updates the host driver via 1455 * handle reception of block-acks; uCode updates the host driver via
1430 * REPLY_COMPRESSED_BA (4965). 1456 * REPLY_COMPRESSED_BA.
1431 * 1457 *
1432 * uCode handles retrying Tx when an ACK is expected but not received. 1458 * uCode handles retrying Tx when an ACK is expected but not received.
1433 * This includes trying lower data rates than the one requested in the Tx 1459 * This includes trying lower data rates than the one requested in the Tx
1434 * command, as set up by the REPLY_RATE_SCALE (for 3945) or 1460 * command, as set up by the REPLY_RATE_SCALE (for 3945) or
1435 * REPLY_TX_LINK_QUALITY_CMD (4965). 1461 * REPLY_TX_LINK_QUALITY_CMD (agn).
1436 * 1462 *
1437 * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD. 1463 * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD.
1438 * This command must be executed after every RXON command, before Tx can occur. 1464 * This command must be executed after every RXON command, before Tx can occur.
@@ -1468,7 +1494,7 @@ struct iwl_rx_mpdu_res_start {
1468 * Set this for unicast frames, but not broadcast/multicast. */ 1494 * Set this for unicast frames, but not broadcast/multicast. */
1469#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3) 1495#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3)
1470 1496
1471/* For 4965: 1497/* For agn devices:
1472 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD). 1498 * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD).
1473 * Tx command's initial_rate_index indicates first rate to try; 1499 * Tx command's initial_rate_index indicates first rate to try;
1474 * uCode walks through table for additional Tx attempts. 1500 * uCode walks through table for additional Tx attempts.
@@ -1487,7 +1513,7 @@ struct iwl_rx_mpdu_res_start {
1487 */ 1513 */
1488#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7) 1514#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7)
1489 1515
1490/* Tx antenna selection field; used only for 3945, reserved (0) for 4965. 1516/* Tx antenna selection field; used only for 3945, reserved (0) for agn devices.
1491 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ 1517 * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */
1492#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00) 1518#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00)
1493#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8) 1519#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8)
@@ -1870,9 +1896,10 @@ enum {
1870 * frame in this new agg block failed in previous agg block(s). 1896 * frame in this new agg block failed in previous agg block(s).
1871 * 1897 *
1872 * Note that, for aggregation, ACK (block-ack) status is not delivered here; 1898 * Note that, for aggregation, ACK (block-ack) status is not delivered here;
1873 * block-ack has not been received by the time the 4965 records this status. 1899 * block-ack has not been received by the time the agn device records
1900 * this status.
1874 * This status relates to reasons the tx might have been blocked or aborted 1901 * This status relates to reasons the tx might have been blocked or aborted
1875 * within the sending station (this 4965), rather than whether it was 1902 * within the sending station (this agn device), rather than whether it was
1876 * received successfully by the destination station. 1903 * received successfully by the destination station.
1877 */ 1904 */
1878struct agg_tx_status { 1905struct agg_tx_status {
@@ -2140,14 +2167,16 @@ struct iwl_link_qual_agg_params {
2140/* 2167/*
2141 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) 2168 * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response)
2142 * 2169 *
2143 * For 4965 only; 3945 uses REPLY_RATE_SCALE. 2170 * For agn devices only; 3945 uses REPLY_RATE_SCALE.
2144 * 2171 *
2145 * Each station in the 4965's internal station table has its own table of 16 2172 * Each station in the agn device's internal station table has its own table
2173 * of 16
2146 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when 2174 * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when
2147 * an ACK is not received. This command replaces the entire table for 2175 * an ACK is not received. This command replaces the entire table for
2148 * one station. 2176 * one station.
2149 * 2177 *
2150 * NOTE: Station must already be in 4965's station table. Use REPLY_ADD_STA. 2178 * NOTE: Station must already be in agn device's station table.
2179 * Use REPLY_ADD_STA.
2151 * 2180 *
2152 * The rate scaling procedures described below work well. Of course, other 2181 * The rate scaling procedures described below work well. Of course, other
2153 * procedures are possible, and may work better for particular environments. 2182 * procedures are possible, and may work better for particular environments.
@@ -2184,12 +2213,12 @@ struct iwl_link_qual_agg_params {
2184 * 2213 *
2185 * ACCUMULATING HISTORY 2214 * ACCUMULATING HISTORY
2186 * 2215 *
2187 * The rate scaling algorithm for 4965, as implemented in Linux driver, uses 2216 * The rate scaling algorithm for agn devices, as implemented in Linux driver,
2188 * two sets of frame Tx success history: One for the current/active modulation 2217 * uses two sets of frame Tx success history: One for the current/active
2189 * mode, and one for a speculative/search mode that is being attempted. If the 2218 * modulation mode, and one for a speculative/search mode that is being
2190 * speculative mode turns out to be more effective (i.e. actual transfer 2219 * attempted. If the speculative mode turns out to be more effective (i.e.
2191 * rate is better), then the driver continues to use the speculative mode 2220 * actual transfer rate is better), then the driver continues to use the
2192 * as the new current active mode. 2221 * speculative mode as the new current active mode.
2193 * 2222 *
2194 * Each history set contains, separately for each possible rate, data for a 2223 * Each history set contains, separately for each possible rate, data for a
2195 * sliding window of the 62 most recent tx attempts at that rate. The data 2224 * sliding window of the 62 most recent tx attempts at that rate. The data
@@ -2200,12 +2229,12 @@ struct iwl_link_qual_agg_params {
2200 * The driver uses the bit map to remove successes from the success sum, as 2229 * The driver uses the bit map to remove successes from the success sum, as
2201 * the oldest tx attempts fall out of the window. 2230 * the oldest tx attempts fall out of the window.
2202 * 2231 *
2203 * When the 4965 makes multiple tx attempts for a given frame, each attempt 2232 * When the agn device makes multiple tx attempts for a given frame, each
2204 * might be at a different rate, and have different modulation characteristics 2233 * attempt might be at a different rate, and have different modulation
2205 * (e.g. antenna, fat channel, short guard interval), as set up in the rate 2234 * characteristics (e.g. antenna, fat channel, short guard interval), as set
2206 * scaling table in the Link Quality command. The driver must determine 2235 * up in the rate scaling table in the Link Quality command. The driver must
2207 * which rate table entry was used for each tx attempt, to determine which 2236 * determine which rate table entry was used for each tx attempt, to determine
2208 * rate-specific history to update, and record only those attempts that 2237 * which rate-specific history to update, and record only those attempts that
2209 * match the modulation characteristics of the history set. 2238 * match the modulation characteristics of the history set.
2210 * 2239 *
2211 * When using block-ack (aggregation), all frames are transmitted at the same 2240 * When using block-ack (aggregation), all frames are transmitted at the same
@@ -2335,7 +2364,7 @@ struct iwl_link_quality_cmd {
2335 /* 2364 /*
2336 * Rate info; when using rate-scaling, Tx command's initial_rate_index 2365 * Rate info; when using rate-scaling, Tx command's initial_rate_index
2337 * specifies 1st Tx rate attempted, via index into this table. 2366 * specifies 1st Tx rate attempted, via index into this table.
2338 * 4965 works its way through table when retrying Tx. 2367 * agn devices works its way through table when retrying Tx.
2339 */ 2368 */
2340 struct { 2369 struct {
2341 __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */ 2370 __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */
@@ -2368,10 +2397,26 @@ struct iwl_link_quality_cmd {
2368#define BT_MAX_KILL_DEF (0x5) 2397#define BT_MAX_KILL_DEF (0x5)
2369#define BT_MAX_KILL_MAX (0xFF) 2398#define BT_MAX_KILL_MAX (0xFF)
2370 2399
2400#define BT_DURATION_LIMIT_DEF 625
2401#define BT_DURATION_LIMIT_MAX 1250
2402#define BT_DURATION_LIMIT_MIN 625
2403
2404#define BT_ON_THRESHOLD_DEF 4
2405#define BT_ON_THRESHOLD_MAX 1000
2406#define BT_ON_THRESHOLD_MIN 1
2407
2408#define BT_FRAG_THRESHOLD_DEF 0
2409#define BT_FRAG_THRESHOLD_MAX 0
2410#define BT_FRAG_THRESHOLD_MIN 0
2411
2412#define BT_AGG_THRESHOLD_DEF 0
2413#define BT_AGG_THRESHOLD_MAX 0
2414#define BT_AGG_THRESHOLD_MIN 0
2415
2371/* 2416/*
2372 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response) 2417 * REPLY_BT_CONFIG = 0x9b (command, has simple generic response)
2373 * 2418 *
2374 * 3945 and 4965 support hardware handshake with Bluetooth device on 2419 * 3945 and agn devices support hardware handshake with Bluetooth device on
2375 * same platform. Bluetooth device alerts wireless device when it will Tx; 2420 * same platform. Bluetooth device alerts wireless device when it will Tx;
2376 * wireless device can delay or kill its own Tx to accommodate. 2421 * wireless device can delay or kill its own Tx to accommodate.
2377 */ 2422 */
@@ -2384,6 +2429,74 @@ struct iwl_bt_cmd {
2384 __le32 kill_cts_mask; 2429 __le32 kill_cts_mask;
2385} __packed; 2430} __packed;
2386 2431
2432#define IWLAGN_BT_FLAG_CHANNEL_INHIBITION BIT(0)
2433
2434#define IWLAGN_BT_FLAG_COEX_MODE_MASK (BIT(3)|BIT(4)|BIT(5))
2435#define IWLAGN_BT_FLAG_COEX_MODE_SHIFT 3
2436#define IWLAGN_BT_FLAG_COEX_MODE_DISABLED 0
2437#define IWLAGN_BT_FLAG_COEX_MODE_LEGACY_2W 1
2438#define IWLAGN_BT_FLAG_COEX_MODE_3W 2
2439#define IWLAGN_BT_FLAG_COEX_MODE_4W 3
2440
2441#define IWLAGN_BT_FLAG_UCODE_DEFAULT BIT(6)
2442#define IWLAGN_BT_FLAG_NOCOEX_NOTIF BIT(7)
2443
2444#define IWLAGN_BT_PRIO_BOOST_MAX 0xFF
2445#define IWLAGN_BT_PRIO_BOOST_MIN 0x00
2446#define IWLAGN_BT_PRIO_BOOST_DEFAULT 0xF0
2447
2448#define IWLAGN_BT_MAX_KILL_DEFAULT 5
2449
2450#define IWLAGN_BT3_T7_DEFAULT 1
2451
2452#define IWLAGN_BT_KILL_ACK_MASK_DEFAULT cpu_to_le32(0xffffffff)
2453#define IWLAGN_BT_KILL_CTS_MASK_DEFAULT cpu_to_le32(0xffffffff)
2454
2455#define IWLAGN_BT3_PRIO_SAMPLE_DEFAULT 2
2456
2457#define IWLAGN_BT3_T2_DEFAULT 0xc
2458
2459#define IWLAGN_BT_VALID_ENABLE_FLAGS cpu_to_le16(BIT(0))
2460#define IWLAGN_BT_VALID_BOOST cpu_to_le16(BIT(1))
2461#define IWLAGN_BT_VALID_MAX_KILL cpu_to_le16(BIT(2))
2462#define IWLAGN_BT_VALID_3W_TIMERS cpu_to_le16(BIT(3))
2463#define IWLAGN_BT_VALID_KILL_ACK_MASK cpu_to_le16(BIT(4))
2464#define IWLAGN_BT_VALID_KILL_CTS_MASK cpu_to_le16(BIT(5))
2465#define IWLAGN_BT_VALID_BT4_TIMES cpu_to_le16(BIT(6))
2466#define IWLAGN_BT_VALID_3W_LUT cpu_to_le16(BIT(7))
2467
2468#define IWLAGN_BT_ALL_VALID_MSK (IWLAGN_BT_VALID_ENABLE_FLAGS | \
2469 IWLAGN_BT_VALID_BOOST | \
2470 IWLAGN_BT_VALID_MAX_KILL | \
2471 IWLAGN_BT_VALID_3W_TIMERS | \
2472 IWLAGN_BT_VALID_KILL_ACK_MASK | \
2473 IWLAGN_BT_VALID_KILL_CTS_MASK | \
2474 IWLAGN_BT_VALID_BT4_TIMES | \
2475 IWLAGN_BT_VALID_3W_LUT)
2476
2477struct iwlagn_bt_cmd {
2478 u8 flags;
2479 u8 ledtime; /* unused */
2480 u8 max_kill;
2481 u8 bt3_timer_t7_value;
2482 __le32 kill_ack_mask;
2483 __le32 kill_cts_mask;
2484 u8 bt3_prio_sample_time;
2485 u8 bt3_timer_t2_value;
2486 __le16 bt4_reaction_time; /* unused */
2487 __le32 bt3_lookup_table[12];
2488 __le16 bt4_decision_time; /* unused */
2489 __le16 valid;
2490 u8 prio_boost;
2491 u8 reserved[3];
2492};
2493
2494#define IWLAGN_BT_SCO_ACTIVE cpu_to_le32(BIT(0))
2495
2496struct iwlagn_bt_sco_cmd {
2497 __le32 flags;
2498};
2499
2387/****************************************************************************** 2500/******************************************************************************
2388 * (6) 2501 * (6)
2389 * Spectrum Management (802.11h) Commands, Responses, Notifications: 2502 * Spectrum Management (802.11h) Commands, Responses, Notifications:
@@ -2572,7 +2685,7 @@ struct iwl_powertable_cmd {
2572 2685
2573/* 2686/*
2574 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command) 2687 * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command)
2575 * 3945 and 4965 identical. 2688 * all devices identical.
2576 */ 2689 */
2577struct iwl_sleep_notification { 2690struct iwl_sleep_notification {
2578 u8 pm_sleep_mode; 2691 u8 pm_sleep_mode;
@@ -2583,7 +2696,7 @@ struct iwl_sleep_notification {
2583 __le32 bcon_timer; 2696 __le32 bcon_timer;
2584} __packed; 2697} __packed;
2585 2698
2586/* Sleep states. 3945 and 4965 identical. */ 2699/* Sleep states. all devices identical. */
2587enum { 2700enum {
2588 IWL_PM_NO_SLEEP = 0, 2701 IWL_PM_NO_SLEEP = 0,
2589 IWL_PM_SLP_MAC = 1, 2702 IWL_PM_SLP_MAC = 1,
@@ -2892,6 +3005,12 @@ struct iwl_scanstart_notification {
2892#define SCAN_OWNER_STATUS 0x1; 3005#define SCAN_OWNER_STATUS 0x1;
2893#define MEASURE_OWNER_STATUS 0x2; 3006#define MEASURE_OWNER_STATUS 0x2;
2894 3007
3008#define IWL_PROBE_STATUS_OK 0
3009#define IWL_PROBE_STATUS_TX_FAILED BIT(0)
3010/* error statuses combined with TX_FAILED */
3011#define IWL_PROBE_STATUS_FAIL_TTL BIT(1)
3012#define IWL_PROBE_STATUS_FAIL_BT BIT(2)
3013
2895#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */ 3014#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */
2896/* 3015/*
2897 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) 3016 * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command)
@@ -2899,7 +3018,8 @@ struct iwl_scanstart_notification {
2899struct iwl_scanresults_notification { 3018struct iwl_scanresults_notification {
2900 u8 channel; 3019 u8 channel;
2901 u8 band; 3020 u8 band;
2902 u8 reserved[2]; 3021 u8 probe_status;
3022 u8 num_probe_not_sent; /* not enough time to send */
2903 __le32 tsf_low; 3023 __le32 tsf_low;
2904 __le32 tsf_high; 3024 __le32 tsf_high;
2905 __le32 statistics[NUMBER_OF_STATISTICS]; 3025 __le32 statistics[NUMBER_OF_STATISTICS];
@@ -2911,7 +3031,7 @@ struct iwl_scanresults_notification {
2911struct iwl_scancomplete_notification { 3031struct iwl_scancomplete_notification {
2912 u8 scanned_channels; 3032 u8 scanned_channels;
2913 u8 status; 3033 u8 status;
2914 u8 reserved; 3034 u8 bt_status; /* BT On/Off status */
2915 u8 last_channel; 3035 u8 last_channel;
2916 __le32 tsf_low; 3036 __le32 tsf_low;
2917 __le32 tsf_high; 3037 __le32 tsf_high;
@@ -3270,7 +3390,7 @@ struct statistics_general_bt {
3270 3390
3271/* 3391/*
3272 * REPLY_STATISTICS_CMD = 0x9c, 3392 * REPLY_STATISTICS_CMD = 0x9c,
3273 * 3945 and 4965 identical. 3393 * all devices identical.
3274 * 3394 *
3275 * This command triggers an immediate response containing uCode statistics. 3395 * This command triggers an immediate response containing uCode statistics.
3276 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below. 3396 * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below.
@@ -3608,7 +3728,7 @@ struct iwl_enhance_sensitivity_cmd {
3608/** 3728/**
3609 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response) 3729 * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response)
3610 * 3730 *
3611 * This command sets the relative gains of 4965's 3 radio receiver chains. 3731 * This command sets the relative gains of agn device's 3 radio receiver chains.
3612 * 3732 *
3613 * After the first association, driver should accumulate signal and noise 3733 * After the first association, driver should accumulate signal and noise
3614 * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20 3734 * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20
@@ -3965,6 +4085,201 @@ struct iwl_coex_event_resp {
3965 4085
3966 4086
3967/****************************************************************************** 4087/******************************************************************************
4088 * Bluetooth Coexistence commands
4089 *
4090 *****************************************************************************/
4091
4092/*
4093 * BT Status notification
4094 * REPLY_BT_COEX_PROFILE_NOTIF = 0xce
4095 */
4096enum iwl_bt_coex_profile_traffic_load {
4097 IWL_BT_COEX_TRAFFIC_LOAD_NONE = 0,
4098 IWL_BT_COEX_TRAFFIC_LOAD_LOW = 1,
4099 IWL_BT_COEX_TRAFFIC_LOAD_HIGH = 2,
4100 IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS = 3,
4101/*
4102 * There are no more even though below is a u8, the
4103 * indication from the BT device only has two bits.
4104 */
4105};
4106
4107#define BT_UART_MSG_FRAME1MSGTYPE_POS (0)
4108#define BT_UART_MSG_FRAME1MSGTYPE_MSK \
4109 (0x7 << BT_UART_MSG_FRAME1MSGTYPE_POS)
4110#define BT_UART_MSG_FRAME1SSN_POS (3)
4111#define BT_UART_MSG_FRAME1SSN_MSK \
4112 (0x3 << BT_UART_MSG_FRAME1SSN_POS)
4113#define BT_UART_MSG_FRAME1UPDATEREQ_POS (5)
4114#define BT_UART_MSG_FRAME1UPDATEREQ_MSK \
4115 (0x1 << BT_UART_MSG_FRAME1UPDATEREQ_POS)
4116#define BT_UART_MSG_FRAME1RESERVED_POS (6)
4117#define BT_UART_MSG_FRAME1RESERVED_MSK \
4118 (0x3 << BT_UART_MSG_FRAME1RESERVED_POS)
4119
4120#define BT_UART_MSG_FRAME2OPENCONNECTIONS_POS (0)
4121#define BT_UART_MSG_FRAME2OPENCONNECTIONS_MSK \
4122 (0x3 << BT_UART_MSG_FRAME2OPENCONNECTIONS_POS)
4123#define BT_UART_MSG_FRAME2TRAFFICLOAD_POS (2)
4124#define BT_UART_MSG_FRAME2TRAFFICLOAD_MSK \
4125 (0x3 << BT_UART_MSG_FRAME2TRAFFICLOAD_POS)
4126#define BT_UART_MSG_FRAME2CHLSEQN_POS (4)
4127#define BT_UART_MSG_FRAME2CHLSEQN_MSK \
4128 (0x1 << BT_UART_MSG_FRAME2CHLSEQN_POS)
4129#define BT_UART_MSG_FRAME2INBAND_POS (5)
4130#define BT_UART_MSG_FRAME2INBAND_MSK \
4131 (0x1 << BT_UART_MSG_FRAME2INBAND_POS)
4132#define BT_UART_MSG_FRAME2RESERVED_POS (6)
4133#define BT_UART_MSG_FRAME2RESERVED_MSK \
4134 (0x3 << BT_UART_MSG_FRAME2RESERVED_POS)
4135
4136#define BT_UART_MSG_FRAME3SCOESCO_POS (0)
4137#define BT_UART_MSG_FRAME3SCOESCO_MSK \
4138 (0x1 << BT_UART_MSG_FRAME3SCOESCO_POS)
4139#define BT_UART_MSG_FRAME3SNIFF_POS (1)
4140#define BT_UART_MSG_FRAME3SNIFF_MSK \
4141 (0x1 << BT_UART_MSG_FRAME3SNIFF_POS)
4142#define BT_UART_MSG_FRAME3A2DP_POS (2)
4143#define BT_UART_MSG_FRAME3A2DP_MSK \
4144 (0x1 << BT_UART_MSG_FRAME3A2DP_POS)
4145#define BT_UART_MSG_FRAME3ACL_POS (3)
4146#define BT_UART_MSG_FRAME3ACL_MSK \
4147 (0x1 << BT_UART_MSG_FRAME3ACL_POS)
4148#define BT_UART_MSG_FRAME3MASTER_POS (4)
4149#define BT_UART_MSG_FRAME3MASTER_MSK \
4150 (0x1 << BT_UART_MSG_FRAME3MASTER_POS)
4151#define BT_UART_MSG_FRAME3OBEX_POS (5)
4152#define BT_UART_MSG_FRAME3OBEX_MSK \
4153 (0x1 << BT_UART_MSG_FRAME3OBEX_POS)
4154#define BT_UART_MSG_FRAME3RESERVED_POS (6)
4155#define BT_UART_MSG_FRAME3RESERVED_MSK \
4156 (0x3 << BT_UART_MSG_FRAME3RESERVED_POS)
4157
4158#define BT_UART_MSG_FRAME4IDLEDURATION_POS (0)
4159#define BT_UART_MSG_FRAME4IDLEDURATION_MSK \
4160 (0x3F << BT_UART_MSG_FRAME4IDLEDURATION_POS)
4161#define BT_UART_MSG_FRAME4RESERVED_POS (6)
4162#define BT_UART_MSG_FRAME4RESERVED_MSK \
4163 (0x3 << BT_UART_MSG_FRAME4RESERVED_POS)
4164
4165#define BT_UART_MSG_FRAME5TXACTIVITY_POS (0)
4166#define BT_UART_MSG_FRAME5TXACTIVITY_MSK \
4167 (0x3 << BT_UART_MSG_FRAME5TXACTIVITY_POS)
4168#define BT_UART_MSG_FRAME5RXACTIVITY_POS (2)
4169#define BT_UART_MSG_FRAME5RXACTIVITY_MSK \
4170 (0x3 << BT_UART_MSG_FRAME5RXACTIVITY_POS)
4171#define BT_UART_MSG_FRAME5ESCORETRANSMIT_POS (4)
4172#define BT_UART_MSG_FRAME5ESCORETRANSMIT_MSK \
4173 (0x3 << BT_UART_MSG_FRAME5ESCORETRANSMIT_POS)
4174#define BT_UART_MSG_FRAME5RESERVED_POS (6)
4175#define BT_UART_MSG_FRAME5RESERVED_MSK \
4176 (0x3 << BT_UART_MSG_FRAME5RESERVED_POS)
4177
4178#define BT_UART_MSG_FRAME6SNIFFINTERVAL_POS (0)
4179#define BT_UART_MSG_FRAME6SNIFFINTERVAL_MSK \
4180 (0x1F << BT_UART_MSG_FRAME6SNIFFINTERVAL_POS)
4181#define BT_UART_MSG_FRAME6DISCOVERABLE_POS (5)
4182#define BT_UART_MSG_FRAME6DISCOVERABLE_MSK \
4183 (0x1 << BT_UART_MSG_FRAME6DISCOVERABLE_POS)
4184#define BT_UART_MSG_FRAME6RESERVED_POS (6)
4185#define BT_UART_MSG_FRAME6RESERVED_MSK \
4186 (0x3 << BT_UART_MSG_FRAME6RESERVED_POS)
4187
4188#define BT_UART_MSG_FRAME7SNIFFACTIVITY_POS (0)
4189#define BT_UART_MSG_FRAME7SNIFFACTIVITY_MSK \
4190 (0x7 << BT_UART_MSG_FRAME7SNIFFACTIVITY_POS)
4191#define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS (3)
4192#define BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_MSK \
4193 (0x3 << BT_UART_MSG_FRAME7INQUIRYPAGESRMODE_POS)
4194#define BT_UART_MSG_FRAME7CONNECTABLE_POS (5)
4195#define BT_UART_MSG_FRAME7CONNECTABLE_MSK \
4196 (0x1 << BT_UART_MSG_FRAME7CONNECTABLE_POS)
4197#define BT_UART_MSG_FRAME7RESERVED_POS (6)
4198#define BT_UART_MSG_FRAME7RESERVED_MSK \
4199 (0x3 << BT_UART_MSG_FRAME7RESERVED_POS)
4200
4201
4202struct iwl_bt_uart_msg {
4203 u8 header;
4204 u8 frame1;
4205 u8 frame2;
4206 u8 frame3;
4207 u8 frame4;
4208 u8 frame5;
4209 u8 frame6;
4210 u8 frame7;
4211} __attribute__((packed));
4212
4213struct iwl_bt_coex_profile_notif {
4214 struct iwl_bt_uart_msg last_bt_uart_msg;
4215 u8 bt_status; /* 0 - off, 1 - on */
4216 u8 bt_traffic_load; /* 0 .. 3? */
4217 u8 bt_ci_compliance; /* 0 - not complied, 1 - complied */
4218 u8 reserved;
4219} __attribute__((packed));
4220
4221#define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS 0
4222#define IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_MSK 0x1
4223#define IWL_BT_COEX_PRIO_TBL_PRIO_POS 1
4224#define IWL_BT_COEX_PRIO_TBL_PRIO_MASK 0x0e
4225#define IWL_BT_COEX_PRIO_TBL_RESERVED_POS 4
4226#define IWL_BT_COEX_PRIO_TBL_RESERVED_MASK 0xf0
4227#define IWL_BT_COEX_PRIO_TBL_PRIO_SHIFT 1
4228
4229/*
4230 * BT Coexistence Priority table
4231 * REPLY_BT_COEX_PRIO_TABLE = 0xcc
4232 */
4233enum bt_coex_prio_table_events {
4234 BT_COEX_PRIO_TBL_EVT_INIT_CALIB1 = 0,
4235 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2 = 1,
4236 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW1 = 2,
4237 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_LOW2 = 3, /* DC calib */
4238 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH1 = 4,
4239 BT_COEX_PRIO_TBL_EVT_PERIODIC_CALIB_HIGH2 = 5,
4240 BT_COEX_PRIO_TBL_EVT_DTIM = 6,
4241 BT_COEX_PRIO_TBL_EVT_SCAN52 = 7,
4242 BT_COEX_PRIO_TBL_EVT_SCAN24 = 8,
4243 BT_COEX_PRIO_TBL_EVT_RESERVED0 = 9,
4244 BT_COEX_PRIO_TBL_EVT_RESERVED1 = 10,
4245 BT_COEX_PRIO_TBL_EVT_RESERVED2 = 11,
4246 BT_COEX_PRIO_TBL_EVT_RESERVED3 = 12,
4247 BT_COEX_PRIO_TBL_EVT_RESERVED4 = 13,
4248 BT_COEX_PRIO_TBL_EVT_RESERVED5 = 14,
4249 BT_COEX_PRIO_TBL_EVT_RESERVED6 = 15,
4250 /* BT_COEX_PRIO_TBL_EVT_MAX should always be last */
4251 BT_COEX_PRIO_TBL_EVT_MAX,
4252};
4253
4254enum bt_coex_prio_table_priorities {
4255 BT_COEX_PRIO_TBL_DISABLED = 0,
4256 BT_COEX_PRIO_TBL_PRIO_LOW = 1,
4257 BT_COEX_PRIO_TBL_PRIO_HIGH = 2,
4258 BT_COEX_PRIO_TBL_PRIO_BYPASS = 3,
4259 BT_COEX_PRIO_TBL_PRIO_COEX_OFF = 4,
4260 BT_COEX_PRIO_TBL_PRIO_COEX_ON = 5,
4261 BT_COEX_PRIO_TBL_PRIO_RSRVD1 = 6,
4262 BT_COEX_PRIO_TBL_PRIO_RSRVD2 = 7,
4263 BT_COEX_PRIO_TBL_MAX,
4264};
4265
4266struct iwl_bt_coex_prio_table_cmd {
4267 u8 prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX];
4268} __attribute__((packed));
4269
4270#define IWL_BT_COEX_ENV_CLOSE 0
4271#define IWL_BT_COEX_ENV_OPEN 1
4272/*
4273 * BT Protection Envelope
4274 * REPLY_BT_COEX_PROT_ENV = 0xcd
4275 */
4276struct iwl_bt_coex_prot_env_cmd {
4277 u8 action; /* 0 = closed, 1 = open */
4278 u8 type; /* 0 .. 15 */
4279 u8 reserved[2];
4280} __attribute__((packed));
4281
4282/******************************************************************************
3968 * (13) 4283 * (13)
3969 * Union of all expected notifications/responses: 4284 * Union of all expected notifications/responses:
3970 * 4285 *
@@ -4003,6 +4318,7 @@ struct iwl_rx_packet {
4003 struct iwl_missed_beacon_notif missed_beacon; 4318 struct iwl_missed_beacon_notif missed_beacon;
4004 struct iwl_coex_medium_notification coex_medium_notif; 4319 struct iwl_coex_medium_notification coex_medium_notif;
4005 struct iwl_coex_event_resp coex_event; 4320 struct iwl_coex_event_resp coex_event;
4321 struct iwl_bt_coex_profile_notif bt_coex_profile_notif;
4006 __le32 status; 4322 __le32 status;
4007 u8 raw[0]; 4323 u8 raw[0];
4008 } u; 4324 } u;
@@ -4010,4 +4326,94 @@ struct iwl_rx_packet {
4010 4326
4011int iwl_agn_check_rxon_cmd(struct iwl_priv *priv); 4327int iwl_agn_check_rxon_cmd(struct iwl_priv *priv);
4012 4328
4329/*
4330 * REPLY_WIPAN_PARAMS = 0xb2 (Commands and Notification)
4331 */
4332
4333/**
4334 * struct iwl_wipan_slot
4335 * @width: Time in TU
4336 * @type:
4337 * 0 - BSS
4338 * 1 - PAN
4339 */
4340struct iwl_wipan_slot {
4341 __le16 width;
4342 u8 type;
4343 u8 reserved;
4344} __packed;
4345
4346#define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_CTS BIT(1) /* reserved */
4347#define IWL_WIPAN_PARAMS_FLG_LEAVE_CHANNEL_QUIET BIT(2) /* reserved */
4348#define IWL_WIPAN_PARAMS_FLG_SLOTTED_MODE BIT(3) /* reserved */
4349#define IWL_WIPAN_PARAMS_FLG_FILTER_BEACON_NOTIF BIT(4)
4350#define IWL_WIPAN_PARAMS_FLG_FULL_SLOTTED_MODE BIT(5)
4351
4352/**
4353 * struct iwl_wipan_params_cmd
4354 * @flags:
4355 * bit0: reserved
4356 * bit1: CP leave channel with CTS
4357 * bit2: CP leave channel qith Quiet
4358 * bit3: slotted mode
4359 * 1 - work in slotted mode
4360 * 0 - work in non slotted mode
4361 * bit4: filter beacon notification
4362 * bit5: full tx slotted mode. if this flag is set,
4363 * uCode will perform leaving channel methods in context switch
4364 * also when working in same channel mode
4365 * @num_slots: 1 - 10
4366 */
4367struct iwl_wipan_params_cmd {
4368 __le16 flags;
4369 u8 reserved;
4370 u8 num_slots;
4371 struct iwl_wipan_slot slots[10];
4372} __packed;
4373
4374/*
4375 * REPLY_WIPAN_P2P_CHANNEL_SWITCH = 0xb9
4376 *
4377 * TODO: Figure out what this is used for,
4378 * it can only switch between 2.4 GHz
4379 * channels!!
4380 */
4381
4382struct iwl_wipan_p2p_channel_switch_cmd {
4383 __le16 channel;
4384 __le16 reserved;
4385};
4386
4387/*
4388 * REPLY_WIPAN_NOA_NOTIFICATION = 0xbc
4389 *
4390 * This is used by the device to notify us of the
4391 * NoA schedule it determined so we can forward it
4392 * to userspace for inclusion in probe responses.
4393 *
4394 * In beacons, the NoA schedule is simply appended
4395 * to the frame we give the device.
4396 */
4397
4398struct iwl_wipan_noa_descriptor {
4399 u8 count;
4400 __le32 duration;
4401 __le32 interval;
4402 __le32 starttime;
4403} __packed;
4404
4405struct iwl_wipan_noa_attribute {
4406 u8 id;
4407 __le16 length;
4408 u8 index;
4409 u8 ct_window;
4410 struct iwl_wipan_noa_descriptor descr0, descr1;
4411 u8 reserved;
4412} __packed;
4413
4414struct iwl_wipan_noa_notification {
4415 u32 noa_active;
4416 struct iwl_wipan_noa_attribute noa_attribute;
4417} __packed;
4418
4013#endif /* __iwl_commands_h__ */ 4419#endif /* __iwl_commands_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 3d9443b9bec1..87a2e40972ba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -64,7 +64,8 @@ MODULE_LICENSE("GPL");
64 * 64 *
65 * default: bt_coex_active = true (BT_COEX_ENABLE) 65 * default: bt_coex_active = true (BT_COEX_ENABLE)
66 */ 66 */
67static bool bt_coex_active = true; 67bool bt_coex_active = true;
68EXPORT_SYMBOL_GPL(bt_coex_active);
68module_param(bt_coex_active, bool, S_IRUGO); 69module_param(bt_coex_active, bool, S_IRUGO);
69MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); 70MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist");
70 71
@@ -146,6 +147,10 @@ u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid)
146 int i; 147 int i;
147 u8 ind = ant; 148 u8 ind = ant;
148 149
150 if (priv->band == IEEE80211_BAND_2GHZ &&
151 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)
152 return 0;
153
149 for (i = 0; i < RATE_ANT_NUM - 1; i++) { 154 for (i = 0; i < RATE_ANT_NUM - 1; i++) {
150 ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; 155 ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0;
151 if (valid & BIT(ind)) 156 if (valid & BIT(ind))
@@ -186,27 +191,27 @@ EXPORT_SYMBOL(iwl_alloc_all);
186/* 191/*
187 * QoS support 192 * QoS support
188*/ 193*/
189static void iwl_update_qos(struct iwl_priv *priv) 194static void iwl_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
190{ 195{
191 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 196 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
192 return; 197 return;
193 198
194 priv->qos_data.def_qos_parm.qos_flags = 0; 199 ctx->qos_data.def_qos_parm.qos_flags = 0;
195 200
196 if (priv->qos_data.qos_active) 201 if (ctx->qos_data.qos_active)
197 priv->qos_data.def_qos_parm.qos_flags |= 202 ctx->qos_data.def_qos_parm.qos_flags |=
198 QOS_PARAM_FLG_UPDATE_EDCA_MSK; 203 QOS_PARAM_FLG_UPDATE_EDCA_MSK;
199 204
200 if (priv->current_ht_config.is_ht) 205 if (ctx->ht.enabled)
201 priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; 206 ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
202 207
203 IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", 208 IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n",
204 priv->qos_data.qos_active, 209 ctx->qos_data.qos_active,
205 priv->qos_data.def_qos_parm.qos_flags); 210 ctx->qos_data.def_qos_parm.qos_flags);
206 211
207 iwl_send_cmd_pdu_async(priv, REPLY_QOS_PARAM, 212 iwl_send_cmd_pdu_async(priv, ctx->qos_cmd,
208 sizeof(struct iwl_qosparam_cmd), 213 sizeof(struct iwl_qosparam_cmd),
209 &priv->qos_data.def_qos_parm, NULL); 214 &ctx->qos_data.def_qos_parm, NULL);
210} 215}
211 216
212#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ 217#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
@@ -436,15 +441,15 @@ static bool is_single_rx_stream(struct iwl_priv *priv)
436 priv->current_ht_config.single_chain_sufficient; 441 priv->current_ht_config.single_chain_sufficient;
437} 442}
438 443
439static u8 iwl_is_channel_extension(struct iwl_priv *priv, 444static bool iwl_is_channel_extension(struct iwl_priv *priv,
440 enum ieee80211_band band, 445 enum ieee80211_band band,
441 u16 channel, u8 extension_chan_offset) 446 u16 channel, u8 extension_chan_offset)
442{ 447{
443 const struct iwl_channel_info *ch_info; 448 const struct iwl_channel_info *ch_info;
444 449
445 ch_info = iwl_get_channel_info(priv, band, channel); 450 ch_info = iwl_get_channel_info(priv, band, channel);
446 if (!is_channel_valid(ch_info)) 451 if (!is_channel_valid(ch_info))
447 return 0; 452 return false;
448 453
449 if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) 454 if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE)
450 return !(ch_info->ht40_extension_channel & 455 return !(ch_info->ht40_extension_channel &
@@ -453,31 +458,31 @@ static u8 iwl_is_channel_extension(struct iwl_priv *priv,
453 return !(ch_info->ht40_extension_channel & 458 return !(ch_info->ht40_extension_channel &
454 IEEE80211_CHAN_NO_HT40MINUS); 459 IEEE80211_CHAN_NO_HT40MINUS);
455 460
456 return 0; 461 return false;
457} 462}
458 463
459u8 iwl_is_ht40_tx_allowed(struct iwl_priv *priv, 464bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
460 struct ieee80211_sta_ht_cap *sta_ht_inf) 465 struct iwl_rxon_context *ctx,
466 struct ieee80211_sta_ht_cap *ht_cap)
461{ 467{
462 struct iwl_ht_config *ht_conf = &priv->current_ht_config; 468 if (!ctx->ht.enabled || !ctx->ht.is_40mhz)
463 469 return false;
464 if (!ht_conf->is_ht || !ht_conf->is_40mhz)
465 return 0;
466 470
467 /* We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40 471 /*
472 * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40
468 * the bit will not set if it is pure 40MHz case 473 * the bit will not set if it is pure 40MHz case
469 */ 474 */
470 if (sta_ht_inf) { 475 if (ht_cap && !ht_cap->ht_supported)
471 if (!sta_ht_inf->ht_supported) 476 return false;
472 return 0; 477
473 }
474#ifdef CONFIG_IWLWIFI_DEBUGFS 478#ifdef CONFIG_IWLWIFI_DEBUGFS
475 if (priv->disable_ht40) 479 if (priv->disable_ht40)
476 return 0; 480 return false;
477#endif 481#endif
482
478 return iwl_is_channel_extension(priv, priv->band, 483 return iwl_is_channel_extension(priv, priv->band,
479 le16_to_cpu(priv->staging_rxon.channel), 484 le16_to_cpu(ctx->staging.channel),
480 ht_conf->extension_chan_offset); 485 ctx->ht.extension_chan_offset);
481} 486}
482EXPORT_SYMBOL(iwl_is_ht40_tx_allowed); 487EXPORT_SYMBOL(iwl_is_ht40_tx_allowed);
483 488
@@ -495,55 +500,64 @@ static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
495 return new_val; 500 return new_val;
496} 501}
497 502
498int iwl_send_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif) 503int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
499{ 504{
500 u64 tsf; 505 u64 tsf;
501 s32 interval_tm, rem; 506 s32 interval_tm, rem;
502 struct ieee80211_conf *conf = NULL; 507 struct ieee80211_conf *conf = NULL;
503 u16 beacon_int; 508 u16 beacon_int;
509 struct ieee80211_vif *vif = ctx->vif;
504 510
505 conf = ieee80211_get_hw_conf(priv->hw); 511 conf = ieee80211_get_hw_conf(priv->hw);
506 512
507 lockdep_assert_held(&priv->mutex); 513 lockdep_assert_held(&priv->mutex);
508 514
509 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 515 memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd));
510 516
511 priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp); 517 ctx->timing.timestamp = cpu_to_le64(priv->timestamp);
512 priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval); 518 ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval);
513 519
514 beacon_int = vif->bss_conf.beacon_int; 520 beacon_int = vif ? vif->bss_conf.beacon_int : 0;
515 521
516 if (vif->type == NL80211_IFTYPE_ADHOC) { 522 /*
517 /* TODO: we need to get atim_window from upper stack 523 * TODO: For IBSS we need to get atim_window from mac80211,
518 * for now we set to 0 */ 524 * for now just always use 0
519 priv->rxon_timing.atim_window = 0; 525 */
520 } else { 526 ctx->timing.atim_window = 0;
521 priv->rxon_timing.atim_window = 0;
522 }
523 527
524 beacon_int = iwl_adjust_beacon_interval(beacon_int, 528 if (ctx->ctxid == IWL_RXON_CTX_PAN &&
529 (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION)) {
530 ctx->timing.beacon_interval =
531 priv->contexts[IWL_RXON_CTX_BSS].timing.beacon_interval;
532 beacon_int = le16_to_cpu(ctx->timing.beacon_interval);
533 } else {
534 beacon_int = iwl_adjust_beacon_interval(beacon_int,
525 priv->hw_params.max_beacon_itrvl * TIME_UNIT); 535 priv->hw_params.max_beacon_itrvl * TIME_UNIT);
526 priv->rxon_timing.beacon_interval = cpu_to_le16(beacon_int); 536 ctx->timing.beacon_interval = cpu_to_le16(beacon_int);
537 }
527 538
528 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ 539 tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */
529 interval_tm = beacon_int * TIME_UNIT; 540 interval_tm = beacon_int * TIME_UNIT;
530 rem = do_div(tsf, interval_tm); 541 rem = do_div(tsf, interval_tm);
531 priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem); 542 ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
543
544 ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1;
532 545
533 IWL_DEBUG_ASSOC(priv, 546 IWL_DEBUG_ASSOC(priv,
534 "beacon interval %d beacon timer %d beacon tim %d\n", 547 "beacon interval %d beacon timer %d beacon tim %d\n",
535 le16_to_cpu(priv->rxon_timing.beacon_interval), 548 le16_to_cpu(ctx->timing.beacon_interval),
536 le32_to_cpu(priv->rxon_timing.beacon_init_val), 549 le32_to_cpu(ctx->timing.beacon_init_val),
537 le16_to_cpu(priv->rxon_timing.atim_window)); 550 le16_to_cpu(ctx->timing.atim_window));
538 551
539 return iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, 552 return iwl_send_cmd_pdu(priv, ctx->rxon_timing_cmd,
540 sizeof(priv->rxon_timing), &priv->rxon_timing); 553 sizeof(ctx->timing), &ctx->timing);
541} 554}
542EXPORT_SYMBOL(iwl_send_rxon_timing); 555EXPORT_SYMBOL(iwl_send_rxon_timing);
543 556
544void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) 557void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
558 int hw_decrypt)
545{ 559{
546 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 560 struct iwl_rxon_cmd *rxon = &ctx->staging;
547 561
548 if (hw_decrypt) 562 if (hw_decrypt)
549 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; 563 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
@@ -560,11 +574,11 @@ EXPORT_SYMBOL(iwl_set_rxon_hwcrypto);
560 * be #ifdef'd out once the driver is stable and folks aren't actively 574 * be #ifdef'd out once the driver is stable and folks aren't actively
561 * making changes 575 * making changes
562 */ 576 */
563int iwl_check_rxon_cmd(struct iwl_priv *priv) 577int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
564{ 578{
565 int error = 0; 579 int error = 0;
566 int counter = 1; 580 int counter = 1;
567 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 581 struct iwl_rxon_cmd *rxon = &ctx->staging;
568 582
569 if (rxon->flags & RXON_FLG_BAND_24G_MSK) { 583 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
570 error |= le32_to_cpu(rxon->flags & 584 error |= le32_to_cpu(rxon->flags &
@@ -636,66 +650,83 @@ EXPORT_SYMBOL(iwl_check_rxon_cmd);
636 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that 650 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
637 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. 651 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
638 */ 652 */
639int iwl_full_rxon_required(struct iwl_priv *priv) 653int iwl_full_rxon_required(struct iwl_priv *priv,
654 struct iwl_rxon_context *ctx)
640{ 655{
656 const struct iwl_rxon_cmd *staging = &ctx->staging;
657 const struct iwl_rxon_cmd *active = &ctx->active;
658
659#define CHK(cond) \
660 if ((cond)) { \
661 IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \
662 return 1; \
663 }
664
665#define CHK_NEQ(c1, c2) \
666 if ((c1) != (c2)) { \
667 IWL_DEBUG_INFO(priv, "need full RXON - " \
668 #c1 " != " #c2 " - %d != %d\n", \
669 (c1), (c2)); \
670 return 1; \
671 }
641 672
642 /* These items are only settable from the full RXON command */ 673 /* These items are only settable from the full RXON command */
643 if (!(iwl_is_associated(priv)) || 674 CHK(!iwl_is_associated_ctx(ctx));
644 compare_ether_addr(priv->staging_rxon.bssid_addr, 675 CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr));
645 priv->active_rxon.bssid_addr) || 676 CHK(compare_ether_addr(staging->node_addr, active->node_addr));
646 compare_ether_addr(priv->staging_rxon.node_addr, 677 CHK(compare_ether_addr(staging->wlap_bssid_addr,
647 priv->active_rxon.node_addr) || 678 active->wlap_bssid_addr));
648 compare_ether_addr(priv->staging_rxon.wlap_bssid_addr, 679 CHK_NEQ(staging->dev_type, active->dev_type);
649 priv->active_rxon.wlap_bssid_addr) || 680 CHK_NEQ(staging->channel, active->channel);
650 (priv->staging_rxon.dev_type != priv->active_rxon.dev_type) || 681 CHK_NEQ(staging->air_propagation, active->air_propagation);
651 (priv->staging_rxon.channel != priv->active_rxon.channel) || 682 CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates,
652 (priv->staging_rxon.air_propagation != 683 active->ofdm_ht_single_stream_basic_rates);
653 priv->active_rxon.air_propagation) || 684 CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates,
654 (priv->staging_rxon.ofdm_ht_single_stream_basic_rates != 685 active->ofdm_ht_dual_stream_basic_rates);
655 priv->active_rxon.ofdm_ht_single_stream_basic_rates) || 686 CHK_NEQ(staging->ofdm_ht_triple_stream_basic_rates,
656 (priv->staging_rxon.ofdm_ht_dual_stream_basic_rates != 687 active->ofdm_ht_triple_stream_basic_rates);
657 priv->active_rxon.ofdm_ht_dual_stream_basic_rates) || 688 CHK_NEQ(staging->assoc_id, active->assoc_id);
658 (priv->staging_rxon.ofdm_ht_triple_stream_basic_rates !=
659 priv->active_rxon.ofdm_ht_triple_stream_basic_rates) ||
660 (priv->staging_rxon.assoc_id != priv->active_rxon.assoc_id))
661 return 1;
662 689
663 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can 690 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can
664 * be updated with the RXON_ASSOC command -- however only some 691 * be updated with the RXON_ASSOC command -- however only some
665 * flag transitions are allowed using RXON_ASSOC */ 692 * flag transitions are allowed using RXON_ASSOC */
666 693
667 /* Check if we are not switching bands */ 694 /* Check if we are not switching bands */
668 if ((priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) != 695 CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK,
669 (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK)) 696 active->flags & RXON_FLG_BAND_24G_MSK);
670 return 1;
671 697
672 /* Check if we are switching association toggle */ 698 /* Check if we are switching association toggle */
673 if ((priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) != 699 CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK,
674 (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK)) 700 active->filter_flags & RXON_FILTER_ASSOC_MSK);
675 return 1; 701
702#undef CHK
703#undef CHK_NEQ
676 704
677 return 0; 705 return 0;
678} 706}
679EXPORT_SYMBOL(iwl_full_rxon_required); 707EXPORT_SYMBOL(iwl_full_rxon_required);
680 708
681u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv) 709u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv,
710 struct iwl_rxon_context *ctx)
682{ 711{
683 /* 712 /*
684 * Assign the lowest rate -- should really get this from 713 * Assign the lowest rate -- should really get this from
685 * the beacon skb from mac80211. 714 * the beacon skb from mac80211.
686 */ 715 */
687 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) 716 if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK)
688 return IWL_RATE_1M_PLCP; 717 return IWL_RATE_1M_PLCP;
689 else 718 else
690 return IWL_RATE_6M_PLCP; 719 return IWL_RATE_6M_PLCP;
691} 720}
692EXPORT_SYMBOL(iwl_rate_get_lowest_plcp); 721EXPORT_SYMBOL(iwl_rate_get_lowest_plcp);
693 722
694void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf) 723static void _iwl_set_rxon_ht(struct iwl_priv *priv,
724 struct iwl_ht_config *ht_conf,
725 struct iwl_rxon_context *ctx)
695{ 726{
696 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 727 struct iwl_rxon_cmd *rxon = &ctx->staging;
697 728
698 if (!ht_conf->is_ht) { 729 if (!ctx->ht.enabled) {
699 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | 730 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
700 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | 731 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK |
701 RXON_FLG_HT40_PROT_MSK | 732 RXON_FLG_HT40_PROT_MSK |
@@ -703,22 +734,22 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf)
703 return; 734 return;
704 } 735 }
705 736
706 /* FIXME: if the definition of ht_protection changed, the "translation" 737 /* FIXME: if the definition of ht.protection changed, the "translation"
707 * will be needed for rxon->flags 738 * will be needed for rxon->flags
708 */ 739 */
709 rxon->flags |= cpu_to_le32(ht_conf->ht_protection << RXON_FLG_HT_OPERATING_MODE_POS); 740 rxon->flags |= cpu_to_le32(ctx->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS);
710 741
711 /* Set up channel bandwidth: 742 /* Set up channel bandwidth:
712 * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ 743 * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */
713 /* clear the HT channel mode before set the mode */ 744 /* clear the HT channel mode before set the mode */
714 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | 745 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
715 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); 746 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
716 if (iwl_is_ht40_tx_allowed(priv, NULL)) { 747 if (iwl_is_ht40_tx_allowed(priv, ctx, NULL)) {
717 /* pure ht40 */ 748 /* pure ht40 */
718 if (ht_conf->ht_protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { 749 if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) {
719 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; 750 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40;
720 /* Note: control channel is opposite of extension channel */ 751 /* Note: control channel is opposite of extension channel */
721 switch (ht_conf->extension_chan_offset) { 752 switch (ctx->ht.extension_chan_offset) {
722 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 753 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
723 rxon->flags &= ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; 754 rxon->flags &= ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
724 break; 755 break;
@@ -728,7 +759,7 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf)
728 } 759 }
729 } else { 760 } else {
730 /* Note: control channel is opposite of extension channel */ 761 /* Note: control channel is opposite of extension channel */
731 switch (ht_conf->extension_chan_offset) { 762 switch (ctx->ht.extension_chan_offset) {
732 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 763 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
733 rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); 764 rxon->flags &= ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
734 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; 765 rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED;
@@ -749,12 +780,20 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf)
749 } 780 }
750 781
751 if (priv->cfg->ops->hcmd->set_rxon_chain) 782 if (priv->cfg->ops->hcmd->set_rxon_chain)
752 priv->cfg->ops->hcmd->set_rxon_chain(priv); 783 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
753 784
754 IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " 785 IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X "
755 "extension channel offset 0x%x\n", 786 "extension channel offset 0x%x\n",
756 le32_to_cpu(rxon->flags), ht_conf->ht_protection, 787 le32_to_cpu(rxon->flags), ctx->ht.protection,
757 ht_conf->extension_chan_offset); 788 ctx->ht.extension_chan_offset);
789}
790
791void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf)
792{
793 struct iwl_rxon_context *ctx;
794
795 for_each_context(priv, ctx)
796 _iwl_set_rxon_ht(priv, ht_conf, ctx);
758} 797}
759EXPORT_SYMBOL(iwl_set_rxon_ht); 798EXPORT_SYMBOL(iwl_set_rxon_ht);
760 799
@@ -775,6 +814,14 @@ EXPORT_SYMBOL(iwl_set_rxon_ht);
775 */ 814 */
776static int iwl_get_active_rx_chain_count(struct iwl_priv *priv) 815static int iwl_get_active_rx_chain_count(struct iwl_priv *priv)
777{ 816{
817 if (priv->cfg->advanced_bt_coexist && (priv->bt_full_concurrent ||
818 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) {
819 /*
820 * only use chain 'A' in bt high traffic load or
821 * full concurrency mode
822 */
823 return IWL_NUM_RX_CHAINS_SINGLE;
824 }
778 /* # of Rx chains to use when expecting MIMO. */ 825 /* # of Rx chains to use when expecting MIMO. */
779 if (is_single_rx_stream(priv)) 826 if (is_single_rx_stream(priv))
780 return IWL_NUM_RX_CHAINS_SINGLE; 827 return IWL_NUM_RX_CHAINS_SINGLE;
@@ -819,7 +866,7 @@ static u8 iwl_count_chain_bitmap(u32 chain_bitmap)
819 * Selects how many and which Rx receivers/antennas/chains to use. 866 * Selects how many and which Rx receivers/antennas/chains to use.
820 * This should not be used for scan command ... it puts data in wrong place. 867 * This should not be used for scan command ... it puts data in wrong place.
821 */ 868 */
822void iwl_set_rxon_chain(struct iwl_priv *priv) 869void iwl_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
823{ 870{
824 bool is_single = is_single_rx_stream(priv); 871 bool is_single = is_single_rx_stream(priv);
825 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); 872 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status);
@@ -831,11 +878,20 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
831 * Before first association, we assume all antennas are connected. 878 * Before first association, we assume all antennas are connected.
832 * Just after first association, iwl_chain_noise_calibration() 879 * Just after first association, iwl_chain_noise_calibration()
833 * checks which antennas actually *are* connected. */ 880 * checks which antennas actually *are* connected. */
834 if (priv->chain_noise_data.active_chains) 881 if (priv->chain_noise_data.active_chains)
835 active_chains = priv->chain_noise_data.active_chains; 882 active_chains = priv->chain_noise_data.active_chains;
836 else 883 else
837 active_chains = priv->hw_params.valid_rx_ant; 884 active_chains = priv->hw_params.valid_rx_ant;
838 885
886 if (priv->cfg->advanced_bt_coexist && (priv->bt_full_concurrent ||
887 priv->bt_traffic_load >= IWL_BT_COEX_TRAFFIC_LOAD_HIGH)) {
888 /*
889 * only use chain 'A' in bt high traffic load or
890 * full concurrency mode
891 */
892 active_chains = first_antenna(active_chains);
893 }
894
839 rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; 895 rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS;
840 896
841 /* How many receivers should we use? */ 897 /* How many receivers should we use? */
@@ -856,15 +912,15 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
856 rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; 912 rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS;
857 rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; 913 rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS;
858 914
859 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain); 915 ctx->staging.rx_chain = cpu_to_le16(rx_chain);
860 916
861 if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam) 917 if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam)
862 priv->staging_rxon.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; 918 ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK;
863 else 919 else
864 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; 920 ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK;
865 921
866 IWL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", 922 IWL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n",
867 priv->staging_rxon.rx_chain, 923 ctx->staging.rx_chain,
868 active_rx_cnt, idle_rx_cnt); 924 active_rx_cnt, idle_rx_cnt);
869 925
870 WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || 926 WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 ||
@@ -872,39 +928,41 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
872} 928}
873EXPORT_SYMBOL(iwl_set_rxon_chain); 929EXPORT_SYMBOL(iwl_set_rxon_chain);
874 930
875/* Return valid channel */ 931/* Return valid, unused, channel for a passive scan to reset the RF */
876u8 iwl_get_single_channel_number(struct iwl_priv *priv, 932u8 iwl_get_single_channel_number(struct iwl_priv *priv,
877 enum ieee80211_band band) 933 enum ieee80211_band band)
878{ 934{
879 const struct iwl_channel_info *ch_info; 935 const struct iwl_channel_info *ch_info;
880 int i; 936 int i;
881 u8 channel = 0; 937 u8 channel = 0;
938 u8 min, max;
939 struct iwl_rxon_context *ctx;
882 940
883 /* only scan single channel, good enough to reset the RF */
884 /* pick the first valid not in-use channel */
885 if (band == IEEE80211_BAND_5GHZ) { 941 if (band == IEEE80211_BAND_5GHZ) {
886 for (i = 14; i < priv->channel_count; i++) { 942 min = 14;
887 if (priv->channel_info[i].channel != 943 max = priv->channel_count;
888 le16_to_cpu(priv->staging_rxon.channel)) {
889 channel = priv->channel_info[i].channel;
890 ch_info = iwl_get_channel_info(priv,
891 band, channel);
892 if (is_channel_valid(ch_info))
893 break;
894 }
895 }
896 } else { 944 } else {
897 for (i = 0; i < 14; i++) { 945 min = 0;
898 if (priv->channel_info[i].channel != 946 max = 14;
899 le16_to_cpu(priv->staging_rxon.channel)) { 947 }
900 channel = 948
901 priv->channel_info[i].channel; 949 for (i = min; i < max; i++) {
902 ch_info = iwl_get_channel_info(priv, 950 bool busy = false;
903 band, channel); 951
904 if (is_channel_valid(ch_info)) 952 for_each_context(priv, ctx) {
905 break; 953 busy = priv->channel_info[i].channel ==
906 } 954 le16_to_cpu(ctx->staging.channel);
955 if (busy)
956 break;
907 } 957 }
958
959 if (busy)
960 continue;
961
962 channel = priv->channel_info[i].channel;
963 ch_info = iwl_get_channel_info(priv, band, channel);
964 if (is_channel_valid(ch_info))
965 break;
908 } 966 }
909 967
910 return channel; 968 return channel;
@@ -915,25 +973,24 @@ EXPORT_SYMBOL(iwl_get_single_channel_number);
915 * iwl_set_rxon_channel - Set the band and channel values in staging RXON 973 * iwl_set_rxon_channel - Set the band and channel values in staging RXON
916 * @ch: requested channel as a pointer to struct ieee80211_channel 974 * @ch: requested channel as a pointer to struct ieee80211_channel
917 975
918 * In addition to setting the staging RXON, priv->band is also set.
919 *
920 * NOTE: Does not commit to the hardware; it sets appropriate bit fields 976 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
921 * in the staging RXON flag structure based on the ch->band 977 * in the staging RXON flag structure based on the ch->band
922 */ 978 */
923int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch) 979int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
980 struct iwl_rxon_context *ctx)
924{ 981{
925 enum ieee80211_band band = ch->band; 982 enum ieee80211_band band = ch->band;
926 u16 channel = ch->hw_value; 983 u16 channel = ch->hw_value;
927 984
928 if ((le16_to_cpu(priv->staging_rxon.channel) == channel) && 985 if ((le16_to_cpu(ctx->staging.channel) == channel) &&
929 (priv->band == band)) 986 (priv->band == band))
930 return 0; 987 return 0;
931 988
932 priv->staging_rxon.channel = cpu_to_le16(channel); 989 ctx->staging.channel = cpu_to_le16(channel);
933 if (band == IEEE80211_BAND_5GHZ) 990 if (band == IEEE80211_BAND_5GHZ)
934 priv->staging_rxon.flags &= ~RXON_FLG_BAND_24G_MSK; 991 ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK;
935 else 992 else
936 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 993 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK;
937 994
938 priv->band = band; 995 priv->band = band;
939 996
@@ -944,24 +1001,25 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch)
944EXPORT_SYMBOL(iwl_set_rxon_channel); 1001EXPORT_SYMBOL(iwl_set_rxon_channel);
945 1002
946void iwl_set_flags_for_band(struct iwl_priv *priv, 1003void iwl_set_flags_for_band(struct iwl_priv *priv,
1004 struct iwl_rxon_context *ctx,
947 enum ieee80211_band band, 1005 enum ieee80211_band band,
948 struct ieee80211_vif *vif) 1006 struct ieee80211_vif *vif)
949{ 1007{
950 if (band == IEEE80211_BAND_5GHZ) { 1008 if (band == IEEE80211_BAND_5GHZ) {
951 priv->staging_rxon.flags &= 1009 ctx->staging.flags &=
952 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK 1010 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK
953 | RXON_FLG_CCK_MSK); 1011 | RXON_FLG_CCK_MSK);
954 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 1012 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
955 } else { 1013 } else {
956 /* Copied from iwl_post_associate() */ 1014 /* Copied from iwl_post_associate() */
957 if (vif && vif->bss_conf.use_short_slot) 1015 if (vif && vif->bss_conf.use_short_slot)
958 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 1016 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
959 else 1017 else
960 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 1018 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
961 1019
962 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK; 1020 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK;
963 priv->staging_rxon.flags |= RXON_FLG_AUTO_DETECT_MSK; 1021 ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK;
964 priv->staging_rxon.flags &= ~RXON_FLG_CCK_MSK; 1022 ctx->staging.flags &= ~RXON_FLG_CCK_MSK;
965 } 1023 }
966} 1024}
967EXPORT_SYMBOL(iwl_set_flags_for_band); 1025EXPORT_SYMBOL(iwl_set_flags_for_band);
@@ -970,35 +1028,34 @@ EXPORT_SYMBOL(iwl_set_flags_for_band);
970 * initialize rxon structure with default values from eeprom 1028 * initialize rxon structure with default values from eeprom
971 */ 1029 */
972void iwl_connection_init_rx_config(struct iwl_priv *priv, 1030void iwl_connection_init_rx_config(struct iwl_priv *priv,
973 struct ieee80211_vif *vif) 1031 struct iwl_rxon_context *ctx)
974{ 1032{
975 const struct iwl_channel_info *ch_info; 1033 const struct iwl_channel_info *ch_info;
976 enum nl80211_iftype type = NL80211_IFTYPE_STATION;
977 1034
978 if (vif) 1035 memset(&ctx->staging, 0, sizeof(ctx->staging));
979 type = vif->type;
980 1036
981 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 1037 if (!ctx->vif) {
982 1038 ctx->staging.dev_type = ctx->unused_devtype;
983 switch (type) { 1039 } else switch (ctx->vif->type) {
984 case NL80211_IFTYPE_AP: 1040 case NL80211_IFTYPE_AP:
985 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP; 1041 ctx->staging.dev_type = ctx->ap_devtype;
986 break; 1042 break;
987 1043
988 case NL80211_IFTYPE_STATION: 1044 case NL80211_IFTYPE_STATION:
989 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS; 1045 ctx->staging.dev_type = ctx->station_devtype;
990 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; 1046 ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
991 break; 1047 break;
992 1048
993 case NL80211_IFTYPE_ADHOC: 1049 case NL80211_IFTYPE_ADHOC:
994 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS; 1050 ctx->staging.dev_type = ctx->ibss_devtype;
995 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK; 1051 ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
996 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK | 1052 ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
997 RXON_FILTER_ACCEPT_GRP_MSK; 1053 RXON_FILTER_ACCEPT_GRP_MSK;
998 break; 1054 break;
999 1055
1000 default: 1056 default:
1001 IWL_ERR(priv, "Unsupported interface type %d\n", type); 1057 IWL_ERR(priv, "Unsupported interface type %d\n",
1058 ctx->vif->type);
1002 break; 1059 break;
1003 } 1060 }
1004 1061
@@ -1006,37 +1063,36 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv,
1006 /* TODO: Figure out when short_preamble would be set and cache from 1063 /* TODO: Figure out when short_preamble would be set and cache from
1007 * that */ 1064 * that */
1008 if (!hw_to_local(priv->hw)->short_preamble) 1065 if (!hw_to_local(priv->hw)->short_preamble)
1009 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 1066 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
1010 else 1067 else
1011 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 1068 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
1012#endif 1069#endif
1013 1070
1014 ch_info = iwl_get_channel_info(priv, priv->band, 1071 ch_info = iwl_get_channel_info(priv, priv->band,
1015 le16_to_cpu(priv->active_rxon.channel)); 1072 le16_to_cpu(ctx->active.channel));
1016 1073
1017 if (!ch_info) 1074 if (!ch_info)
1018 ch_info = &priv->channel_info[0]; 1075 ch_info = &priv->channel_info[0];
1019 1076
1020 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel); 1077 ctx->staging.channel = cpu_to_le16(ch_info->channel);
1021 priv->band = ch_info->band; 1078 priv->band = ch_info->band;
1022 1079
1023 iwl_set_flags_for_band(priv, priv->band, vif); 1080 iwl_set_flags_for_band(priv, ctx, priv->band, ctx->vif);
1024 1081
1025 priv->staging_rxon.ofdm_basic_rates = 1082 ctx->staging.ofdm_basic_rates =
1026 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 1083 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1027 priv->staging_rxon.cck_basic_rates = 1084 ctx->staging.cck_basic_rates =
1028 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; 1085 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1029 1086
1030 /* clear both MIX and PURE40 mode flag */ 1087 /* clear both MIX and PURE40 mode flag */
1031 priv->staging_rxon.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | 1088 ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED |
1032 RXON_FLG_CHANNEL_MODE_PURE_40); 1089 RXON_FLG_CHANNEL_MODE_PURE_40);
1090 if (ctx->vif)
1091 memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN);
1033 1092
1034 if (vif) 1093 ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff;
1035 memcpy(priv->staging_rxon.node_addr, vif->addr, ETH_ALEN); 1094 ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff;
1036 1095 ctx->staging.ofdm_ht_triple_stream_basic_rates = 0xff;
1037 priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff;
1038 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff;
1039 priv->staging_rxon.ofdm_ht_triple_stream_basic_rates = 0xff;
1040} 1096}
1041EXPORT_SYMBOL(iwl_connection_init_rx_config); 1097EXPORT_SYMBOL(iwl_connection_init_rx_config);
1042 1098
@@ -1044,6 +1100,7 @@ void iwl_set_rate(struct iwl_priv *priv)
1044{ 1100{
1045 const struct ieee80211_supported_band *hw = NULL; 1101 const struct ieee80211_supported_band *hw = NULL;
1046 struct ieee80211_rate *rate; 1102 struct ieee80211_rate *rate;
1103 struct iwl_rxon_context *ctx;
1047 int i; 1104 int i;
1048 1105
1049 hw = iwl_get_hw_mode(priv, priv->band); 1106 hw = iwl_get_hw_mode(priv, priv->band);
@@ -1062,21 +1119,29 @@ void iwl_set_rate(struct iwl_priv *priv)
1062 1119
1063 IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); 1120 IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate);
1064 1121
1065 priv->staging_rxon.cck_basic_rates = 1122 for_each_context(priv, ctx) {
1066 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; 1123 ctx->staging.cck_basic_rates =
1124 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1067 1125
1068 priv->staging_rxon.ofdm_basic_rates = 1126 ctx->staging.ofdm_basic_rates =
1069 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 1127 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1128 }
1070} 1129}
1071EXPORT_SYMBOL(iwl_set_rate); 1130EXPORT_SYMBOL(iwl_set_rate);
1072 1131
1073void iwl_chswitch_done(struct iwl_priv *priv, bool is_success) 1132void iwl_chswitch_done(struct iwl_priv *priv, bool is_success)
1074{ 1133{
1134 /*
1135 * MULTI-FIXME
1136 * See iwl_mac_channel_switch.
1137 */
1138 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
1139
1075 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 1140 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1076 return; 1141 return;
1077 1142
1078 if (priv->switch_rxon.switch_in_progress) { 1143 if (priv->switch_rxon.switch_in_progress) {
1079 ieee80211_chswitch_done(priv->vif, is_success); 1144 ieee80211_chswitch_done(ctx->vif, is_success);
1080 mutex_lock(&priv->mutex); 1145 mutex_lock(&priv->mutex);
1081 priv->switch_rxon.switch_in_progress = false; 1146 priv->switch_rxon.switch_in_progress = false;
1082 mutex_unlock(&priv->mutex); 1147 mutex_unlock(&priv->mutex);
@@ -1087,14 +1152,19 @@ EXPORT_SYMBOL(iwl_chswitch_done);
1087void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) 1152void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1088{ 1153{
1089 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1154 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1090 struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon;
1091 struct iwl_csa_notification *csa = &(pkt->u.csa_notif); 1155 struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
1156 /*
1157 * MULTI-FIXME
1158 * See iwl_mac_channel_switch.
1159 */
1160 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
1161 struct iwl_rxon_cmd *rxon = (void *)&ctx->active;
1092 1162
1093 if (priv->switch_rxon.switch_in_progress) { 1163 if (priv->switch_rxon.switch_in_progress) {
1094 if (!le32_to_cpu(csa->status) && 1164 if (!le32_to_cpu(csa->status) &&
1095 (csa->channel == priv->switch_rxon.channel)) { 1165 (csa->channel == priv->switch_rxon.channel)) {
1096 rxon->channel = csa->channel; 1166 rxon->channel = csa->channel;
1097 priv->staging_rxon.channel = csa->channel; 1167 ctx->staging.channel = csa->channel;
1098 IWL_DEBUG_11H(priv, "CSA notif: channel %d\n", 1168 IWL_DEBUG_11H(priv, "CSA notif: channel %d\n",
1099 le16_to_cpu(csa->channel)); 1169 le16_to_cpu(csa->channel));
1100 iwl_chswitch_done(priv, true); 1170 iwl_chswitch_done(priv, true);
@@ -1108,9 +1178,10 @@ void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1108EXPORT_SYMBOL(iwl_rx_csa); 1178EXPORT_SYMBOL(iwl_rx_csa);
1109 1179
1110#ifdef CONFIG_IWLWIFI_DEBUG 1180#ifdef CONFIG_IWLWIFI_DEBUG
1111void iwl_print_rx_config_cmd(struct iwl_priv *priv) 1181void iwl_print_rx_config_cmd(struct iwl_priv *priv,
1182 struct iwl_rxon_context *ctx)
1112{ 1183{
1113 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 1184 struct iwl_rxon_cmd *rxon = &ctx->staging;
1114 1185
1115 IWL_DEBUG_RADIO(priv, "RX CONFIG:\n"); 1186 IWL_DEBUG_RADIO(priv, "RX CONFIG:\n");
1116 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); 1187 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
@@ -1150,7 +1221,8 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
1150 priv->cfg->ops->lib->dump_nic_event_log(priv, false, NULL, false); 1221 priv->cfg->ops->lib->dump_nic_event_log(priv, false, NULL, false);
1151#ifdef CONFIG_IWLWIFI_DEBUG 1222#ifdef CONFIG_IWLWIFI_DEBUG
1152 if (iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) 1223 if (iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS)
1153 iwl_print_rx_config_cmd(priv); 1224 iwl_print_rx_config_cmd(priv,
1225 &priv->contexts[IWL_RXON_CTX_BSS]);
1154#endif 1226#endif
1155 1227
1156 wake_up_interruptible(&priv->wait_command_queue); 1228 wake_up_interruptible(&priv->wait_command_queue);
@@ -1518,6 +1590,7 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
1518 const struct ieee80211_tx_queue_params *params) 1590 const struct ieee80211_tx_queue_params *params)
1519{ 1591{
1520 struct iwl_priv *priv = hw->priv; 1592 struct iwl_priv *priv = hw->priv;
1593 struct iwl_rxon_context *ctx;
1521 unsigned long flags; 1594 unsigned long flags;
1522 int q; 1595 int q;
1523 1596
@@ -1537,13 +1610,21 @@ int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
1537 1610
1538 spin_lock_irqsave(&priv->lock, flags); 1611 spin_lock_irqsave(&priv->lock, flags);
1539 1612
1540 priv->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min); 1613 /*
1541 priv->qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max); 1614 * MULTI-FIXME
1542 priv->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; 1615 * This may need to be done per interface in nl80211/cfg80211/mac80211.
1543 priv->qos_data.def_qos_parm.ac[q].edca_txop = 1616 */
1544 cpu_to_le16((params->txop * 32)); 1617 for_each_context(priv, ctx) {
1618 ctx->qos_data.def_qos_parm.ac[q].cw_min =
1619 cpu_to_le16(params->cw_min);
1620 ctx->qos_data.def_qos_parm.ac[q].cw_max =
1621 cpu_to_le16(params->cw_max);
1622 ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
1623 ctx->qos_data.def_qos_parm.ac[q].edca_txop =
1624 cpu_to_le16((params->txop * 32));
1545 1625
1546 priv->qos_data.def_qos_parm.ac[q].reserved1 = 0; 1626 ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0;
1627 }
1547 1628
1548 spin_unlock_irqrestore(&priv->lock, flags); 1629 spin_unlock_irqrestore(&priv->lock, flags);
1549 1630
@@ -1566,15 +1647,16 @@ static void iwl_ht_conf(struct iwl_priv *priv,
1566 struct iwl_ht_config *ht_conf = &priv->current_ht_config; 1647 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
1567 struct ieee80211_sta *sta; 1648 struct ieee80211_sta *sta;
1568 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 1649 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1650 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1569 1651
1570 IWL_DEBUG_MAC80211(priv, "enter:\n"); 1652 IWL_DEBUG_MAC80211(priv, "enter:\n");
1571 1653
1572 if (!ht_conf->is_ht) 1654 if (!ctx->ht.enabled)
1573 return; 1655 return;
1574 1656
1575 ht_conf->ht_protection = 1657 ctx->ht.protection =
1576 bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; 1658 bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
1577 ht_conf->non_GF_STA_present = 1659 ctx->ht.non_gf_sta_present =
1578 !!(bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); 1660 !!(bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
1579 1661
1580 ht_conf->single_chain_sufficient = false; 1662 ht_conf->single_chain_sufficient = false;
@@ -1618,18 +1700,20 @@ static void iwl_ht_conf(struct iwl_priv *priv,
1618 IWL_DEBUG_MAC80211(priv, "leave\n"); 1700 IWL_DEBUG_MAC80211(priv, "leave\n");
1619} 1701}
1620 1702
1621static inline void iwl_set_no_assoc(struct iwl_priv *priv) 1703static inline void iwl_set_no_assoc(struct iwl_priv *priv,
1704 struct ieee80211_vif *vif)
1622{ 1705{
1706 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1707
1623 iwl_led_disassociate(priv); 1708 iwl_led_disassociate(priv);
1624 /* 1709 /*
1625 * inform the ucode that there is no longer an 1710 * inform the ucode that there is no longer an
1626 * association and that no more packets should be 1711 * association and that no more packets should be
1627 * sent 1712 * sent
1628 */ 1713 */
1629 priv->staging_rxon.filter_flags &= 1714 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
1630 ~RXON_FILTER_ASSOC_MSK; 1715 ctx->staging.assoc_id = 0;
1631 priv->staging_rxon.assoc_id = 0; 1716 iwlcore_commit_rxon(priv, ctx);
1632 iwlcore_commit_rxon(priv);
1633} 1717}
1634 1718
1635static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) 1719static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
@@ -1640,6 +1724,14 @@ static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
1640 1724
1641 IWL_DEBUG_MAC80211(priv, "enter\n"); 1725 IWL_DEBUG_MAC80211(priv, "enter\n");
1642 1726
1727 lockdep_assert_held(&priv->mutex);
1728
1729 if (!priv->beacon_ctx) {
1730 IWL_ERR(priv, "update beacon but no beacon context!\n");
1731 dev_kfree_skb(skb);
1732 return -EINVAL;
1733 }
1734
1643 if (!iwl_is_ready_rf(priv)) { 1735 if (!iwl_is_ready_rf(priv)) {
1644 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); 1736 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
1645 return -EIO; 1737 return -EIO;
@@ -1658,7 +1750,7 @@ static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
1658 IWL_DEBUG_MAC80211(priv, "leave\n"); 1750 IWL_DEBUG_MAC80211(priv, "leave\n");
1659 spin_unlock_irqrestore(&priv->lock, flags); 1751 spin_unlock_irqrestore(&priv->lock, flags);
1660 1752
1661 priv->cfg->ops->lib->post_associate(priv, priv->vif); 1753 priv->cfg->ops->lib->post_associate(priv, priv->beacon_ctx->vif);
1662 1754
1663 return 0; 1755 return 0;
1664} 1756}
@@ -1669,6 +1761,7 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1669 u32 changes) 1761 u32 changes)
1670{ 1762{
1671 struct iwl_priv *priv = hw->priv; 1763 struct iwl_priv *priv = hw->priv;
1764 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1672 int ret; 1765 int ret;
1673 1766
1674 IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); 1767 IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
@@ -1682,11 +1775,23 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1682 unsigned long flags; 1775 unsigned long flags;
1683 1776
1684 spin_lock_irqsave(&priv->lock, flags); 1777 spin_lock_irqsave(&priv->lock, flags);
1685 priv->qos_data.qos_active = bss_conf->qos; 1778 ctx->qos_data.qos_active = bss_conf->qos;
1686 iwl_update_qos(priv); 1779 iwl_update_qos(priv, ctx);
1687 spin_unlock_irqrestore(&priv->lock, flags); 1780 spin_unlock_irqrestore(&priv->lock, flags);
1688 } 1781 }
1689 1782
1783 if (changes & BSS_CHANGED_BEACON_ENABLED) {
1784 /*
1785 * the add_interface code must make sure we only ever
1786 * have a single interface that could be beaconing at
1787 * any time.
1788 */
1789 if (vif->bss_conf.enable_beacon)
1790 priv->beacon_ctx = ctx;
1791 else
1792 priv->beacon_ctx = NULL;
1793 }
1794
1690 if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_AP) { 1795 if (changes & BSS_CHANGED_BEACON && vif->type == NL80211_IFTYPE_AP) {
1691 dev_kfree_skb(priv->ibss_beacon); 1796 dev_kfree_skb(priv->ibss_beacon);
1692 priv->ibss_beacon = ieee80211_beacon_get(hw, vif); 1797 priv->ibss_beacon = ieee80211_beacon_get(hw, vif);
@@ -1713,13 +1818,13 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1713 1818
1714 /* mac80211 only sets assoc when in STATION mode */ 1819 /* mac80211 only sets assoc when in STATION mode */
1715 if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { 1820 if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) {
1716 memcpy(priv->staging_rxon.bssid_addr, 1821 memcpy(ctx->staging.bssid_addr,
1717 bss_conf->bssid, ETH_ALEN); 1822 bss_conf->bssid, ETH_ALEN);
1718 1823
1719 /* currently needed in a few places */ 1824 /* currently needed in a few places */
1720 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); 1825 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
1721 } else { 1826 } else {
1722 priv->staging_rxon.filter_flags &= 1827 ctx->staging.filter_flags &=
1723 ~RXON_FILTER_ASSOC_MSK; 1828 ~RXON_FILTER_ASSOC_MSK;
1724 } 1829 }
1725 1830
@@ -1742,21 +1847,21 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1742 IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", 1847 IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
1743 bss_conf->use_short_preamble); 1848 bss_conf->use_short_preamble);
1744 if (bss_conf->use_short_preamble) 1849 if (bss_conf->use_short_preamble)
1745 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 1850 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
1746 else 1851 else
1747 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 1852 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
1748 } 1853 }
1749 1854
1750 if (changes & BSS_CHANGED_ERP_CTS_PROT) { 1855 if (changes & BSS_CHANGED_ERP_CTS_PROT) {
1751 IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot); 1856 IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
1752 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) 1857 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
1753 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK; 1858 ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK;
1754 else 1859 else
1755 priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK; 1860 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
1756 if (bss_conf->use_cts_prot) 1861 if (bss_conf->use_cts_prot)
1757 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN; 1862 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN;
1758 else 1863 else
1759 priv->staging_rxon.flags &= ~RXON_FLG_SELF_CTS_EN; 1864 ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
1760 } 1865 }
1761 1866
1762 if (changes & BSS_CHANGED_BASIC_RATES) { 1867 if (changes & BSS_CHANGED_BASIC_RATES) {
@@ -1766,12 +1871,12 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1766 * like this here: 1871 * like this here:
1767 * 1872 *
1768 if (A-band) 1873 if (A-band)
1769 priv->staging_rxon.ofdm_basic_rates = 1874 ctx->staging.ofdm_basic_rates =
1770 bss_conf->basic_rates; 1875 bss_conf->basic_rates;
1771 else 1876 else
1772 priv->staging_rxon.ofdm_basic_rates = 1877 ctx->staging.ofdm_basic_rates =
1773 bss_conf->basic_rates >> 4; 1878 bss_conf->basic_rates >> 4;
1774 priv->staging_rxon.cck_basic_rates = 1879 ctx->staging.cck_basic_rates =
1775 bss_conf->basic_rates & 0xF; 1880 bss_conf->basic_rates & 0xF;
1776 */ 1881 */
1777 } 1882 }
@@ -1780,7 +1885,7 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1780 iwl_ht_conf(priv, vif); 1885 iwl_ht_conf(priv, vif);
1781 1886
1782 if (priv->cfg->ops->hcmd->set_rxon_chain) 1887 if (priv->cfg->ops->hcmd->set_rxon_chain)
1783 priv->cfg->ops->hcmd->set_rxon_chain(priv); 1888 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
1784 } 1889 }
1785 1890
1786 if (changes & BSS_CHANGED_ASSOC) { 1891 if (changes & BSS_CHANGED_ASSOC) {
@@ -1793,29 +1898,29 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1793 if (!iwl_is_rfkill(priv)) 1898 if (!iwl_is_rfkill(priv))
1794 priv->cfg->ops->lib->post_associate(priv, vif); 1899 priv->cfg->ops->lib->post_associate(priv, vif);
1795 } else 1900 } else
1796 iwl_set_no_assoc(priv); 1901 iwl_set_no_assoc(priv, vif);
1797 } 1902 }
1798 1903
1799 if (changes && iwl_is_associated(priv) && bss_conf->aid) { 1904 if (changes && iwl_is_associated_ctx(ctx) && bss_conf->aid) {
1800 IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", 1905 IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n",
1801 changes); 1906 changes);
1802 ret = iwl_send_rxon_assoc(priv); 1907 ret = iwl_send_rxon_assoc(priv, ctx);
1803 if (!ret) { 1908 if (!ret) {
1804 /* Sync active_rxon with latest change. */ 1909 /* Sync active_rxon with latest change. */
1805 memcpy((void *)&priv->active_rxon, 1910 memcpy((void *)&ctx->active,
1806 &priv->staging_rxon, 1911 &ctx->staging,
1807 sizeof(struct iwl_rxon_cmd)); 1912 sizeof(struct iwl_rxon_cmd));
1808 } 1913 }
1809 } 1914 }
1810 1915
1811 if (changes & BSS_CHANGED_BEACON_ENABLED) { 1916 if (changes & BSS_CHANGED_BEACON_ENABLED) {
1812 if (vif->bss_conf.enable_beacon) { 1917 if (vif->bss_conf.enable_beacon) {
1813 memcpy(priv->staging_rxon.bssid_addr, 1918 memcpy(ctx->staging.bssid_addr,
1814 bss_conf->bssid, ETH_ALEN); 1919 bss_conf->bssid, ETH_ALEN);
1815 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); 1920 memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN);
1816 iwlcore_config_ap(priv, vif); 1921 iwlcore_config_ap(priv, vif);
1817 } else 1922 } else
1818 iwl_set_no_assoc(priv); 1923 iwl_set_no_assoc(priv, vif);
1819 } 1924 }
1820 1925
1821 if (changes & BSS_CHANGED_IBSS) { 1926 if (changes & BSS_CHANGED_IBSS) {
@@ -1827,6 +1932,12 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
1827 bss_conf->bssid); 1932 bss_conf->bssid);
1828 } 1933 }
1829 1934
1935 if (changes & BSS_CHANGED_IDLE &&
1936 priv->cfg->ops->hcmd->set_pan_params) {
1937 if (priv->cfg->ops->hcmd->set_pan_params(priv))
1938 IWL_ERR(priv, "failed to update PAN params\n");
1939 }
1940
1830 mutex_unlock(&priv->mutex); 1941 mutex_unlock(&priv->mutex);
1831 1942
1832 IWL_DEBUG_MAC80211(priv, "leave\n"); 1943 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -1835,17 +1946,21 @@ EXPORT_SYMBOL(iwl_bss_info_changed);
1835 1946
1836static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif) 1947static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif)
1837{ 1948{
1838 iwl_connection_init_rx_config(priv, vif); 1949 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1950
1951 iwl_connection_init_rx_config(priv, ctx);
1839 1952
1840 if (priv->cfg->ops->hcmd->set_rxon_chain) 1953 if (priv->cfg->ops->hcmd->set_rxon_chain)
1841 priv->cfg->ops->hcmd->set_rxon_chain(priv); 1954 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
1842 1955
1843 return iwlcore_commit_rxon(priv); 1956 return iwlcore_commit_rxon(priv, ctx);
1844} 1957}
1845 1958
1846int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 1959int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1847{ 1960{
1848 struct iwl_priv *priv = hw->priv; 1961 struct iwl_priv *priv = hw->priv;
1962 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1963 struct iwl_rxon_context *tmp, *ctx = NULL;
1849 int err = 0; 1964 int err = 0;
1850 1965
1851 IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", 1966 IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n",
@@ -1858,23 +1973,60 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1858 goto out; 1973 goto out;
1859 } 1974 }
1860 1975
1861 if (priv->vif) { 1976 for_each_context(priv, tmp) {
1862 IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n"); 1977 u32 possible_modes =
1978 tmp->interface_modes | tmp->exclusive_interface_modes;
1979
1980 if (tmp->vif) {
1981 /* check if this busy context is exclusive */
1982 if (tmp->exclusive_interface_modes &
1983 BIT(tmp->vif->type)) {
1984 err = -EINVAL;
1985 goto out;
1986 }
1987 continue;
1988 }
1989
1990 if (!(possible_modes & BIT(vif->type)))
1991 continue;
1992
1993 /* have maybe usable context w/o interface */
1994 ctx = tmp;
1995 break;
1996 }
1997
1998 if (!ctx) {
1863 err = -EOPNOTSUPP; 1999 err = -EOPNOTSUPP;
1864 goto out; 2000 goto out;
1865 } 2001 }
1866 2002
1867 priv->vif = vif; 2003 vif_priv->ctx = ctx;
2004 ctx->vif = vif;
2005 /*
2006 * This variable will be correct only when there's just
2007 * a single context, but all code using it is for hardware
2008 * that supports only one context.
2009 */
1868 priv->iw_mode = vif->type; 2010 priv->iw_mode = vif->type;
1869 2011
1870 err = iwl_set_mode(priv, vif); 2012 err = iwl_set_mode(priv, vif);
1871 if (err) 2013 if (err)
1872 goto out_err; 2014 goto out_err;
1873 2015
2016 if (priv->cfg->advanced_bt_coexist &&
2017 vif->type == NL80211_IFTYPE_ADHOC) {
2018 /*
2019 * pretend to have high BT traffic as long as we
2020 * are operating in IBSS mode, as this will cause
2021 * the rate scaling etc. to behave as intended.
2022 */
2023 priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH;
2024 }
2025
1874 goto out; 2026 goto out;
1875 2027
1876 out_err: 2028 out_err:
1877 priv->vif = NULL; 2029 ctx->vif = NULL;
1878 priv->iw_mode = NL80211_IFTYPE_STATION; 2030 priv->iw_mode = NL80211_IFTYPE_STATION;
1879 out: 2031 out:
1880 mutex_unlock(&priv->mutex); 2032 mutex_unlock(&priv->mutex);
@@ -1888,26 +2040,36 @@ void iwl_mac_remove_interface(struct ieee80211_hw *hw,
1888 struct ieee80211_vif *vif) 2040 struct ieee80211_vif *vif)
1889{ 2041{
1890 struct iwl_priv *priv = hw->priv; 2042 struct iwl_priv *priv = hw->priv;
2043 struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
1891 bool scan_completed = false; 2044 bool scan_completed = false;
1892 2045
1893 IWL_DEBUG_MAC80211(priv, "enter\n"); 2046 IWL_DEBUG_MAC80211(priv, "enter\n");
1894 2047
1895 mutex_lock(&priv->mutex); 2048 mutex_lock(&priv->mutex);
1896 2049
1897 if (iwl_is_ready_rf(priv)) { 2050 WARN_ON(ctx->vif != vif);
1898 iwl_scan_cancel_timeout(priv, 100); 2051 ctx->vif = NULL;
1899 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2052
1900 iwlcore_commit_rxon(priv); 2053 iwl_scan_cancel_timeout(priv, 100);
1901 } 2054 iwl_set_mode(priv, vif);
1902 if (priv->vif == vif) { 2055
1903 priv->vif = NULL; 2056 if (priv->scan_vif == vif) {
1904 if (priv->scan_vif == vif) { 2057 scan_completed = true;
1905 scan_completed = true; 2058 priv->scan_vif = NULL;
1906 priv->scan_vif = NULL; 2059 priv->scan_request = NULL;
1907 priv->scan_request = NULL;
1908 }
1909 memset(priv->bssid, 0, ETH_ALEN);
1910 } 2060 }
2061
2062 /*
2063 * When removing the IBSS interface, overwrite the
2064 * BT traffic load with the stored one from the last
2065 * notification, if any. If this is a device that
2066 * doesn't implement this, this has no effect since
2067 * both values are the same and zero.
2068 */
2069 if (vif->type == NL80211_IFTYPE_ADHOC)
2070 priv->bt_traffic_load = priv->notif_bt_traffic_load;
2071
2072 memset(priv->bssid, 0, ETH_ALEN);
1911 mutex_unlock(&priv->mutex); 2073 mutex_unlock(&priv->mutex);
1912 2074
1913 if (scan_completed) 2075 if (scan_completed)
@@ -1928,6 +2090,7 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
1928 struct ieee80211_conf *conf = &hw->conf; 2090 struct ieee80211_conf *conf = &hw->conf;
1929 struct ieee80211_channel *channel = conf->channel; 2091 struct ieee80211_channel *channel = conf->channel;
1930 struct iwl_ht_config *ht_conf = &priv->current_ht_config; 2092 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
2093 struct iwl_rxon_context *ctx;
1931 unsigned long flags = 0; 2094 unsigned long flags = 0;
1932 int ret = 0; 2095 int ret = 0;
1933 u16 ch; 2096 u16 ch;
@@ -1957,7 +2120,8 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
1957 * configured. 2120 * configured.
1958 */ 2121 */
1959 if (priv->cfg->ops->hcmd->set_rxon_chain) 2122 if (priv->cfg->ops->hcmd->set_rxon_chain)
1960 priv->cfg->ops->hcmd->set_rxon_chain(priv); 2123 for_each_context(priv, ctx)
2124 priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx);
1961 } 2125 }
1962 2126
1963 /* during scanning mac80211 will delay channel setting until 2127 /* during scanning mac80211 will delay channel setting until
@@ -1977,39 +2141,49 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
1977 2141
1978 spin_lock_irqsave(&priv->lock, flags); 2142 spin_lock_irqsave(&priv->lock, flags);
1979 2143
1980 /* Configure HT40 channels */ 2144 for_each_context(priv, ctx) {
1981 ht_conf->is_ht = conf_is_ht(conf); 2145 /* Configure HT40 channels */
1982 if (ht_conf->is_ht) { 2146 ctx->ht.enabled = conf_is_ht(conf);
1983 if (conf_is_ht40_minus(conf)) { 2147 if (ctx->ht.enabled) {
1984 ht_conf->extension_chan_offset = 2148 if (conf_is_ht40_minus(conf)) {
1985 IEEE80211_HT_PARAM_CHA_SEC_BELOW; 2149 ctx->ht.extension_chan_offset =
1986 ht_conf->is_40mhz = true; 2150 IEEE80211_HT_PARAM_CHA_SEC_BELOW;
1987 } else if (conf_is_ht40_plus(conf)) { 2151 ctx->ht.is_40mhz = true;
1988 ht_conf->extension_chan_offset = 2152 } else if (conf_is_ht40_plus(conf)) {
1989 IEEE80211_HT_PARAM_CHA_SEC_ABOVE; 2153 ctx->ht.extension_chan_offset =
1990 ht_conf->is_40mhz = true; 2154 IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
1991 } else { 2155 ctx->ht.is_40mhz = true;
1992 ht_conf->extension_chan_offset = 2156 } else {
1993 IEEE80211_HT_PARAM_CHA_SEC_NONE; 2157 ctx->ht.extension_chan_offset =
1994 ht_conf->is_40mhz = false; 2158 IEEE80211_HT_PARAM_CHA_SEC_NONE;
1995 } 2159 ctx->ht.is_40mhz = false;
1996 } else 2160 }
1997 ht_conf->is_40mhz = false; 2161 } else
1998 /* Default to no protection. Protection mode will later be set 2162 ctx->ht.is_40mhz = false;
1999 * from BSS config in iwl_ht_conf */
2000 ht_conf->ht_protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
2001 2163
2002 if ((le16_to_cpu(priv->staging_rxon.channel) != ch)) 2164 /*
2003 priv->staging_rxon.flags = 0; 2165 * Default to no protection. Protection mode will
2166 * later be set from BSS config in iwl_ht_conf
2167 */
2168 ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
2169
2170 /* if we are switching from ht to 2.4 clear flags
2171 * from any ht related info since 2.4 does not
2172 * support ht */
2173 if ((le16_to_cpu(ctx->staging.channel) != ch))
2174 ctx->staging.flags = 0;
2175
2176 iwl_set_rxon_channel(priv, channel, ctx);
2177 iwl_set_rxon_ht(priv, ht_conf);
2004 2178
2005 iwl_set_rxon_channel(priv, channel); 2179 iwl_set_flags_for_band(priv, ctx, channel->band,
2006 iwl_set_rxon_ht(priv, ht_conf); 2180 ctx->vif);
2181 }
2007 2182
2008 iwl_set_flags_for_band(priv, channel->band, priv->vif);
2009 spin_unlock_irqrestore(&priv->lock, flags); 2183 spin_unlock_irqrestore(&priv->lock, flags);
2010 2184
2011 if (priv->cfg->ops->lib->update_bcast_station) 2185 if (priv->cfg->ops->lib->update_bcast_stations)
2012 ret = priv->cfg->ops->lib->update_bcast_station(priv); 2186 ret = priv->cfg->ops->lib->update_bcast_stations(priv);
2013 2187
2014 set_ch_out: 2188 set_ch_out:
2015 /* The list of supported rates and rate mask can be different 2189 /* The list of supported rates and rate mask can be different
@@ -2040,12 +2214,13 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2040 if (scan_active) 2214 if (scan_active)
2041 goto out; 2215 goto out;
2042 2216
2043 if (memcmp(&priv->active_rxon, 2217 for_each_context(priv, ctx) {
2044 &priv->staging_rxon, sizeof(priv->staging_rxon))) 2218 if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)))
2045 iwlcore_commit_rxon(priv); 2219 iwlcore_commit_rxon(priv, ctx);
2046 else 2220 else
2047 IWL_DEBUG_INFO(priv, "Not re-sending same RXON configuration.\n"); 2221 IWL_DEBUG_INFO(priv,
2048 2222 "Not re-sending same RXON configuration.\n");
2223 }
2049 2224
2050out: 2225out:
2051 IWL_DEBUG_MAC80211(priv, "leave\n"); 2226 IWL_DEBUG_MAC80211(priv, "leave\n");
@@ -2058,6 +2233,8 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2058{ 2233{
2059 struct iwl_priv *priv = hw->priv; 2234 struct iwl_priv *priv = hw->priv;
2060 unsigned long flags; 2235 unsigned long flags;
2236 /* IBSS can only be the IWL_RXON_CTX_BSS context */
2237 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
2061 2238
2062 mutex_lock(&priv->mutex); 2239 mutex_lock(&priv->mutex);
2063 IWL_DEBUG_MAC80211(priv, "enter\n"); 2240 IWL_DEBUG_MAC80211(priv, "enter\n");
@@ -2088,8 +2265,8 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2088 * clear RXON_FILTER_ASSOC_MSK bit 2265 * clear RXON_FILTER_ASSOC_MSK bit
2089 */ 2266 */
2090 iwl_scan_cancel_timeout(priv, 100); 2267 iwl_scan_cancel_timeout(priv, 100);
2091 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2268 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2092 iwlcore_commit_rxon(priv); 2269 iwlcore_commit_rxon(priv, ctx);
2093 2270
2094 iwl_set_rate(priv); 2271 iwl_set_rate(priv);
2095 2272
@@ -2498,7 +2675,7 @@ static void iwl_force_rf_reset(struct iwl_priv *priv)
2498 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 2675 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2499 return; 2676 return;
2500 2677
2501 if (!iwl_is_associated(priv)) { 2678 if (!iwl_is_any_associated(priv)) {
2502 IWL_DEBUG_SCAN(priv, "force reset rejected: not associated\n"); 2679 IWL_DEBUG_SCAN(priv, "force reset rejected: not associated\n");
2503 return; 2680 return;
2504 } 2681 }
@@ -2624,10 +2801,14 @@ static int iwl_check_stuck_queue(struct iwl_priv *priv, int cnt)
2624 "queue %d, not read %d time\n", 2801 "queue %d, not read %d time\n",
2625 q->id, 2802 q->id,
2626 q->repeat_same_read_ptr); 2803 q->repeat_same_read_ptr);
2627 mod_timer(&priv->monitor_recover, jiffies + 2804 if (!priv->cfg->advanced_bt_coexist) {
2628 msecs_to_jiffies(IWL_ONE_HUNDRED_MSECS)); 2805 mod_timer(&priv->monitor_recover,
2806 jiffies + msecs_to_jiffies(
2807 IWL_ONE_HUNDRED_MSECS));
2808 return 1;
2809 }
2629 } 2810 }
2630 return 1; 2811 return 0;
2631 } else { 2812 } else {
2632 q->last_read_ptr = q->read_ptr; 2813 q->last_read_ptr = q->read_ptr;
2633 q->repeat_same_read_ptr = 0; 2814 q->repeat_same_read_ptr = 0;
@@ -2645,25 +2826,27 @@ void iwl_bg_monitor_recover(unsigned long data)
2645 return; 2826 return;
2646 2827
2647 /* monitor and check for stuck cmd queue */ 2828 /* monitor and check for stuck cmd queue */
2648 if (iwl_check_stuck_queue(priv, IWL_CMD_QUEUE_NUM)) 2829 if (iwl_check_stuck_queue(priv, priv->cmd_queue))
2649 return; 2830 return;
2650 2831
2651 /* monitor and check for other stuck queues */ 2832 /* monitor and check for other stuck queues */
2652 if (iwl_is_associated(priv)) { 2833 if (iwl_is_any_associated(priv)) {
2653 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { 2834 for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) {
2654 /* skip as we already checked the command queue */ 2835 /* skip as we already checked the command queue */
2655 if (cnt == IWL_CMD_QUEUE_NUM) 2836 if (cnt == priv->cmd_queue)
2656 continue; 2837 continue;
2657 if (iwl_check_stuck_queue(priv, cnt)) 2838 if (iwl_check_stuck_queue(priv, cnt))
2658 return; 2839 return;
2659 } 2840 }
2660 } 2841 }
2661 /* 2842 if (priv->cfg->monitor_recover_period) {
2662 * Reschedule the timer to occur in 2843 /*
2663 * priv->cfg->monitor_recover_period 2844 * Reschedule the timer to occur in
2664 */ 2845 * priv->cfg->monitor_recover_period
2665 mod_timer(&priv->monitor_recover, 2846 */
2666 jiffies + msecs_to_jiffies(priv->cfg->monitor_recover_period)); 2847 mod_timer(&priv->monitor_recover, jiffies + msecs_to_jiffies(
2848 priv->cfg->monitor_recover_period));
2849 }
2667} 2850}
2668EXPORT_SYMBOL(iwl_bg_monitor_recover); 2851EXPORT_SYMBOL(iwl_bg_monitor_recover);
2669 2852
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 7b1e832bae56..f7b57ed84f66 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -88,11 +88,13 @@ struct iwl_cmd;
88#define IWL_CMD(x) case x: return #x 88#define IWL_CMD(x) case x: return #x
89 89
90struct iwl_hcmd_ops { 90struct iwl_hcmd_ops {
91 int (*rxon_assoc)(struct iwl_priv *priv); 91 int (*rxon_assoc)(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
92 int (*commit_rxon)(struct iwl_priv *priv); 92 int (*commit_rxon)(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
93 void (*set_rxon_chain)(struct iwl_priv *priv); 93 void (*set_rxon_chain)(struct iwl_priv *priv,
94 struct iwl_rxon_context *ctx);
94 int (*set_tx_ant)(struct iwl_priv *priv, u8 valid_tx_ant); 95 int (*set_tx_ant)(struct iwl_priv *priv, u8 valid_tx_ant);
95 void (*send_bt_config)(struct iwl_priv *priv); 96 void (*send_bt_config)(struct iwl_priv *priv);
97 int (*set_pan_params)(struct iwl_priv *priv);
96}; 98};
97 99
98struct iwl_hcmd_utils_ops { 100struct iwl_hcmd_utils_ops {
@@ -205,7 +207,7 @@ struct iwl_lib_ops {
205 /* station management */ 207 /* station management */
206 int (*manage_ibss_station)(struct iwl_priv *priv, 208 int (*manage_ibss_station)(struct iwl_priv *priv,
207 struct ieee80211_vif *vif, bool add); 209 struct ieee80211_vif *vif, bool add);
208 int (*update_bcast_station)(struct iwl_priv *priv); 210 int (*update_bcast_stations)(struct iwl_priv *priv);
209 /* recover from tx queue stall */ 211 /* recover from tx queue stall */
210 void (*recover_from_tx_stall)(unsigned long data); 212 void (*recover_from_tx_stall)(unsigned long data);
211 /* check for plcp health */ 213 /* check for plcp health */
@@ -278,6 +280,9 @@ struct iwl_mod_params {
278 * @chain_noise_calib_by_driver: driver has the capability to perform 280 * @chain_noise_calib_by_driver: driver has the capability to perform
279 * chain noise calibration operation 281 * chain noise calibration operation
280 * @scan_antennas: available antenna for scan operation 282 * @scan_antennas: available antenna for scan operation
283 * @advanced_bt_coexist: support advanced bt coexist
284 * @bt_init_traffic_load: specify initial bt traffic load
285 * @bt_prio_boost: default bt priority boost value
281 * @need_dc_calib: need to perform init dc calibration 286 * @need_dc_calib: need to perform init dc calibration
282 * @bt_statistics: use BT version of statistics notification 287 * @bt_statistics: use BT version of statistics notification
283 * @agg_time_limit: maximum number of uSec in aggregation 288 * @agg_time_limit: maximum number of uSec in aggregation
@@ -351,6 +356,9 @@ struct iwl_cfg {
351 const bool chain_noise_calib_by_driver; 356 const bool chain_noise_calib_by_driver;
352 u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; 357 u8 scan_rx_antennas[IEEE80211_NUM_BANDS];
353 u8 scan_tx_antennas[IEEE80211_NUM_BANDS]; 358 u8 scan_tx_antennas[IEEE80211_NUM_BANDS];
359 bool advanced_bt_coexist;
360 u8 bt_init_traffic_load;
361 u8 bt_prio_boost;
354 const bool need_dc_calib; 362 const bool need_dc_calib;
355 const bool bt_statistics; 363 const bool bt_statistics;
356 u16 agg_time_limit; 364 u16 agg_time_limit;
@@ -368,21 +376,25 @@ void iwl_activate_qos(struct iwl_priv *priv);
368int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, 376int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
369 const struct ieee80211_tx_queue_params *params); 377 const struct ieee80211_tx_queue_params *params);
370int iwl_mac_tx_last_beacon(struct ieee80211_hw *hw); 378int iwl_mac_tx_last_beacon(struct ieee80211_hw *hw);
371void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt); 379void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
372int iwl_check_rxon_cmd(struct iwl_priv *priv); 380 int hw_decrypt);
373int iwl_full_rxon_required(struct iwl_priv *priv); 381int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
374void iwl_set_rxon_chain(struct iwl_priv *priv); 382int iwl_full_rxon_required(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
375int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch); 383void iwl_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
384int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch,
385 struct iwl_rxon_context *ctx);
376void iwl_set_flags_for_band(struct iwl_priv *priv, 386void iwl_set_flags_for_band(struct iwl_priv *priv,
387 struct iwl_rxon_context *ctx,
377 enum ieee80211_band band, 388 enum ieee80211_band band,
378 struct ieee80211_vif *vif); 389 struct ieee80211_vif *vif);
379u8 iwl_get_single_channel_number(struct iwl_priv *priv, 390u8 iwl_get_single_channel_number(struct iwl_priv *priv,
380 enum ieee80211_band band); 391 enum ieee80211_band band);
381void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf); 392void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf);
382u8 iwl_is_ht40_tx_allowed(struct iwl_priv *priv, 393bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
383 struct ieee80211_sta_ht_cap *sta_ht_inf); 394 struct iwl_rxon_context *ctx,
395 struct ieee80211_sta_ht_cap *ht_cap);
384void iwl_connection_init_rx_config(struct iwl_priv *priv, 396void iwl_connection_init_rx_config(struct iwl_priv *priv,
385 struct ieee80211_vif *vif); 397 struct iwl_rxon_context *ctx);
386void iwl_set_rate(struct iwl_priv *priv); 398void iwl_set_rate(struct iwl_priv *priv);
387int iwl_set_decrypted_flag(struct iwl_priv *priv, 399int iwl_set_decrypted_flag(struct iwl_priv *priv,
388 struct ieee80211_hdr *hdr, 400 struct ieee80211_hdr *hdr,
@@ -394,7 +406,7 @@ void iwl_bss_info_changed(struct ieee80211_hw *hw,
394 struct ieee80211_vif *vif, 406 struct ieee80211_vif *vif,
395 struct ieee80211_bss_conf *bss_conf, 407 struct ieee80211_bss_conf *bss_conf,
396 u32 changes); 408 u32 changes);
397int iwl_commit_rxon(struct iwl_priv *priv); 409int iwl_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
398int iwl_mac_add_interface(struct ieee80211_hw *hw, 410int iwl_mac_add_interface(struct ieee80211_hw *hw,
399 struct ieee80211_vif *vif); 411 struct ieee80211_vif *vif);
400void iwl_mac_remove_interface(struct ieee80211_hw *hw, 412void iwl_mac_remove_interface(struct ieee80211_hw *hw,
@@ -512,7 +524,8 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force);
512 524
513int iwl_hwrate_to_plcp_idx(u32 rate_n_flags); 525int iwl_hwrate_to_plcp_idx(u32 rate_n_flags);
514 526
515u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv); 527u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv,
528 struct iwl_rxon_context *ctx);
516 529
517u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid); 530u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid);
518 531
@@ -626,9 +639,11 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv,
626void iwl_dump_csr(struct iwl_priv *priv); 639void iwl_dump_csr(struct iwl_priv *priv);
627int iwl_dump_fh(struct iwl_priv *priv, char **buf, bool display); 640int iwl_dump_fh(struct iwl_priv *priv, char **buf, bool display);
628#ifdef CONFIG_IWLWIFI_DEBUG 641#ifdef CONFIG_IWLWIFI_DEBUG
629void iwl_print_rx_config_cmd(struct iwl_priv *priv); 642void iwl_print_rx_config_cmd(struct iwl_priv *priv,
643 struct iwl_rxon_context *ctx);
630#else 644#else
631static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv) 645static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
646 struct iwl_rxon_context *ctx)
632{ 647{
633} 648}
634#endif 649#endif
@@ -708,19 +723,21 @@ static inline int iwl_is_ready_rf(struct iwl_priv *priv)
708extern void iwl_send_bt_config(struct iwl_priv *priv); 723extern void iwl_send_bt_config(struct iwl_priv *priv);
709extern int iwl_send_statistics_request(struct iwl_priv *priv, 724extern int iwl_send_statistics_request(struct iwl_priv *priv,
710 u8 flags, bool clear); 725 u8 flags, bool clear);
711extern int iwl_send_lq_cmd(struct iwl_priv *priv, 726extern int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
712 struct iwl_link_quality_cmd *lq, u8 flags, bool init); 727 struct iwl_link_quality_cmd *lq, u8 flags, bool init);
713void iwl_apm_stop(struct iwl_priv *priv); 728void iwl_apm_stop(struct iwl_priv *priv);
714int iwl_apm_init(struct iwl_priv *priv); 729int iwl_apm_init(struct iwl_priv *priv);
715 730
716int iwl_send_rxon_timing(struct iwl_priv *priv, struct ieee80211_vif *vif); 731int iwl_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
717static inline int iwl_send_rxon_assoc(struct iwl_priv *priv) 732static inline int iwl_send_rxon_assoc(struct iwl_priv *priv,
733 struct iwl_rxon_context *ctx)
718{ 734{
719 return priv->cfg->ops->hcmd->rxon_assoc(priv); 735 return priv->cfg->ops->hcmd->rxon_assoc(priv, ctx);
720} 736}
721static inline int iwlcore_commit_rxon(struct iwl_priv *priv) 737static inline int iwlcore_commit_rxon(struct iwl_priv *priv,
738 struct iwl_rxon_context *ctx)
722{ 739{
723 return priv->cfg->ops->hcmd->commit_rxon(priv); 740 return priv->cfg->ops->hcmd->commit_rxon(priv, ctx);
724} 741}
725static inline void iwlcore_config_ap(struct iwl_priv *priv, 742static inline void iwlcore_config_ap(struct iwl_priv *priv,
726 struct ieee80211_vif *vif) 743 struct ieee80211_vif *vif)
@@ -732,4 +749,8 @@ static inline const struct ieee80211_supported_band *iwl_get_hw_mode(
732{ 749{
733 return priv->hw->wiphy->bands[band]; 750 return priv->hw->wiphy->bands[band];
734} 751}
752
753extern bool bt_coex_active;
754extern bool bt_siso_mode;
755
735#endif /* __iwl_core_h__ */ 756#endif /* __iwl_core_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index d3acdae72381..0ee8f516c4ab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -643,19 +643,25 @@ static ssize_t iwl_dbgfs_qos_read(struct file *file, char __user *user_buf,
643 size_t count, loff_t *ppos) 643 size_t count, loff_t *ppos)
644{ 644{
645 struct iwl_priv *priv = file->private_data; 645 struct iwl_priv *priv = file->private_data;
646 struct iwl_rxon_context *ctx;
646 int pos = 0, i; 647 int pos = 0, i;
647 char buf[256]; 648 char buf[256 * NUM_IWL_RXON_CTX];
648 const size_t bufsz = sizeof(buf); 649 const size_t bufsz = sizeof(buf);
649 650
650 for (i = 0; i < AC_NUM; i++) { 651 for_each_context(priv, ctx) {
651 pos += scnprintf(buf + pos, bufsz - pos, 652 pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n",
652 "\tcw_min\tcw_max\taifsn\ttxop\n"); 653 ctx->ctxid);
653 pos += scnprintf(buf + pos, bufsz - pos, 654 for (i = 0; i < AC_NUM; i++) {
655 pos += scnprintf(buf + pos, bufsz - pos,
656 "\tcw_min\tcw_max\taifsn\ttxop\n");
657 pos += scnprintf(buf + pos, bufsz - pos,
654 "AC[%d]\t%u\t%u\t%u\t%u\n", i, 658 "AC[%d]\t%u\t%u\t%u\t%u\n", i,
655 priv->qos_data.def_qos_parm.ac[i].cw_min, 659 ctx->qos_data.def_qos_parm.ac[i].cw_min,
656 priv->qos_data.def_qos_parm.ac[i].cw_max, 660 ctx->qos_data.def_qos_parm.ac[i].cw_max,
657 priv->qos_data.def_qos_parm.ac[i].aifsn, 661 ctx->qos_data.def_qos_parm.ac[i].aifsn,
658 priv->qos_data.def_qos_parm.ac[i].edca_txop); 662 ctx->qos_data.def_qos_parm.ac[i].edca_txop);
663 }
664 pos += scnprintf(buf + pos, bufsz - pos, "\n");
659 } 665 }
660 return simple_read_from_buffer(user_buf, count, ppos, buf, pos); 666 return simple_read_from_buffer(user_buf, count, ppos, buf, pos);
661} 667}
@@ -730,7 +736,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
730 return -EFAULT; 736 return -EFAULT;
731 if (sscanf(buf, "%d", &ht40) != 1) 737 if (sscanf(buf, "%d", &ht40) != 1)
732 return -EFAULT; 738 return -EFAULT;
733 if (!iwl_is_associated(priv)) 739 if (!iwl_is_any_associated(priv))
734 priv->disable_ht40 = ht40 ? true : false; 740 priv->disable_ht40 = ht40 ? true : false;
735 else { 741 else {
736 IWL_ERR(priv, "Sta associated with AP - " 742 IWL_ERR(priv, "Sta associated with AP - "
@@ -1319,7 +1325,8 @@ static ssize_t iwl_dbgfs_rxon_flags_read(struct file *file,
1319 int len = 0; 1325 int len = 0;
1320 char buf[20]; 1326 char buf[20];
1321 1327
1322 len = sprintf(buf, "0x%04X\n", le32_to_cpu(priv->active_rxon.flags)); 1328 len = sprintf(buf, "0x%04X\n",
1329 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags));
1323 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1330 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1324} 1331}
1325 1332
@@ -1332,7 +1339,7 @@ static ssize_t iwl_dbgfs_rxon_filter_flags_read(struct file *file,
1332 char buf[20]; 1339 char buf[20];
1333 1340
1334 len = sprintf(buf, "0x%04X\n", 1341 len = sprintf(buf, "0x%04X\n",
1335 le32_to_cpu(priv->active_rxon.filter_flags)); 1342 le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags));
1336 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1343 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1337} 1344}
1338 1345
@@ -1527,6 +1534,76 @@ static ssize_t iwl_dbgfs_ucode_bt_stats_read(struct file *file,
1527 user_buf, count, ppos); 1534 user_buf, count, ppos);
1528} 1535}
1529 1536
1537static ssize_t iwl_dbgfs_monitor_period_write(struct file *file,
1538 const char __user *user_buf,
1539 size_t count, loff_t *ppos) {
1540
1541 struct iwl_priv *priv = file->private_data;
1542 char buf[8];
1543 int buf_size;
1544 int period;
1545
1546 memset(buf, 0, sizeof(buf));
1547 buf_size = min(count, sizeof(buf) - 1);
1548 if (copy_from_user(buf, user_buf, buf_size))
1549 return -EFAULT;
1550 if (sscanf(buf, "%d", &period) != 1)
1551 return -EINVAL;
1552 if (period < 0 || period > IWL_MAX_MONITORING_PERIOD)
1553 priv->cfg->monitor_recover_period = IWL_DEF_MONITORING_PERIOD;
1554 else
1555 priv->cfg->monitor_recover_period = period;
1556
1557 if (priv->cfg->monitor_recover_period)
1558 mod_timer(&priv->monitor_recover, jiffies + msecs_to_jiffies(
1559 priv->cfg->monitor_recover_period));
1560 else
1561 del_timer_sync(&priv->monitor_recover);
1562 return count;
1563}
1564
1565static ssize_t iwl_dbgfs_bt_traffic_read(struct file *file,
1566 char __user *user_buf,
1567 size_t count, loff_t *ppos) {
1568
1569 struct iwl_priv *priv = (struct iwl_priv *)file->private_data;
1570 int pos = 0;
1571 char buf[200];
1572 const size_t bufsz = sizeof(buf);
1573 ssize_t ret;
1574
1575 pos += scnprintf(buf + pos, bufsz - pos, "BT in %s mode\n",
1576 priv->bt_full_concurrent ? "full concurrency" : "3-wire");
1577 pos += scnprintf(buf + pos, bufsz - pos, "BT status: %s, "
1578 "last traffic notif: %d\n",
1579 priv->bt_status ? "On" : "Off", priv->notif_bt_traffic_load);
1580 pos += scnprintf(buf + pos, bufsz - pos, "ch_announcement: %d, "
1581 "sco_active: %d, kill_ack_mask: %x, "
1582 "kill_cts_mask: %x\n",
1583 priv->bt_ch_announce, priv->bt_sco_active,
1584 priv->kill_ack_mask, priv->kill_cts_mask);
1585
1586 pos += scnprintf(buf + pos, bufsz - pos, "bluetooth traffic load: ");
1587 switch (priv->bt_traffic_load) {
1588 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
1589 pos += scnprintf(buf + pos, bufsz - pos, "Continuous\n");
1590 break;
1591 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH:
1592 pos += scnprintf(buf + pos, bufsz - pos, "High\n");
1593 break;
1594 case IWL_BT_COEX_TRAFFIC_LOAD_LOW:
1595 pos += scnprintf(buf + pos, bufsz - pos, "Low\n");
1596 break;
1597 case IWL_BT_COEX_TRAFFIC_LOAD_NONE:
1598 default:
1599 pos += scnprintf(buf + pos, bufsz - pos, "None\n");
1600 break;
1601 }
1602
1603 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1604 return ret;
1605}
1606
1530DEBUGFS_READ_FILE_OPS(rx_statistics); 1607DEBUGFS_READ_FILE_OPS(rx_statistics);
1531DEBUGFS_READ_FILE_OPS(tx_statistics); 1608DEBUGFS_READ_FILE_OPS(tx_statistics);
1532DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); 1609DEBUGFS_READ_WRITE_FILE_OPS(traffic_log);
@@ -1550,6 +1627,8 @@ DEBUGFS_READ_FILE_OPS(rxon_flags);
1550DEBUGFS_READ_FILE_OPS(rxon_filter_flags); 1627DEBUGFS_READ_FILE_OPS(rxon_filter_flags);
1551DEBUGFS_WRITE_FILE_OPS(txfifo_flush); 1628DEBUGFS_WRITE_FILE_OPS(txfifo_flush);
1552DEBUGFS_READ_FILE_OPS(ucode_bt_stats); 1629DEBUGFS_READ_FILE_OPS(ucode_bt_stats);
1630DEBUGFS_WRITE_FILE_OPS(monitor_period);
1631DEBUGFS_READ_FILE_OPS(bt_traffic);
1553 1632
1554/* 1633/*
1555 * Create the debugfs files and directories 1634 * Create the debugfs files and directories
@@ -1621,6 +1700,9 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1621 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); 1700 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
1622 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); 1701 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
1623 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); 1702 DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR);
1703 DEBUGFS_ADD_FILE(monitor_period, dir_debug, S_IWUSR);
1704 if (priv->cfg->advanced_bt_coexist)
1705 DEBUGFS_ADD_FILE(bt_traffic, dir_debug, S_IRUSR);
1624 if (priv->cfg->sensitivity_calib_by_driver) 1706 if (priv->cfg->sensitivity_calib_by_driver)
1625 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, 1707 DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf,
1626 &priv->disable_sens_cal); 1708 &priv->disable_sens_cal);
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 1ad330342ffc..4dd38b7b8b74 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -144,6 +144,7 @@ struct iwl_queue {
144/* One for each TFD */ 144/* One for each TFD */
145struct iwl_tx_info { 145struct iwl_tx_info {
146 struct sk_buff *skb; 146 struct sk_buff *skb;
147 struct iwl_rxon_context *ctx;
147}; 148};
148 149
149/** 150/**
@@ -253,10 +254,14 @@ struct iwl_channel_info {
253 struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES]; 254 struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
254}; 255};
255 256
256#define IWL_TX_FIFO_BK 0 257#define IWL_TX_FIFO_BK 0 /* shared */
257#define IWL_TX_FIFO_BE 1 258#define IWL_TX_FIFO_BE 1
258#define IWL_TX_FIFO_VI 2 259#define IWL_TX_FIFO_VI 2 /* shared */
259#define IWL_TX_FIFO_VO 3 260#define IWL_TX_FIFO_VO 3
261#define IWL_TX_FIFO_BK_IPAN IWL_TX_FIFO_BK
262#define IWL_TX_FIFO_BE_IPAN 4
263#define IWL_TX_FIFO_VI_IPAN IWL_TX_FIFO_VI
264#define IWL_TX_FIFO_VO_IPAN 5
260#define IWL_TX_FIFO_UNUSED -1 265#define IWL_TX_FIFO_UNUSED -1
261 266
262/* Minimum number of queues. MAX_NUM is defined in hw specific files. 267/* Minimum number of queues. MAX_NUM is defined in hw specific files.
@@ -265,11 +270,17 @@ struct iwl_channel_info {
265#define IWL_MIN_NUM_QUEUES 10 270#define IWL_MIN_NUM_QUEUES 10
266 271
267/* 272/*
268 * Queue #4 is the command queue for 3945/4965/5x00/1000/6x00, 273 * Command queue depends on iPAN support.
269 * the driver maps it into the appropriate device FIFO for the
270 * uCode.
271 */ 274 */
272#define IWL_CMD_QUEUE_NUM 4 275#define IWL_DEFAULT_CMD_QUEUE_NUM 4
276#define IWL_IPAN_CMD_QUEUE_NUM 9
277
278/*
279 * This queue number is required for proper operation
280 * because the ucode will stop/start the scheduler as
281 * required.
282 */
283#define IWL_IPAN_MCAST_QUEUE 8
273 284
274/* Power management (not Tx power) structures */ 285/* Power management (not Tx power) structures */
275 286
@@ -459,15 +470,8 @@ union iwl_ht_rate_supp {
459#define CFG_HT_MPDU_DENSITY_MIN (0x1) 470#define CFG_HT_MPDU_DENSITY_MIN (0x1)
460 471
461struct iwl_ht_config { 472struct iwl_ht_config {
462 /* self configuration data */
463 bool is_ht;
464 bool is_40mhz;
465 bool single_chain_sufficient; 473 bool single_chain_sufficient;
466 enum ieee80211_smps_mode smps; /* current smps mode */ 474 enum ieee80211_smps_mode smps; /* current smps mode */
467 /* BSS related data */
468 u8 extension_chan_offset;
469 u8 ht_protection;
470 u8 non_GF_STA_present;
471}; 475};
472 476
473/* QoS structures */ 477/* QoS structures */
@@ -485,12 +489,13 @@ struct iwl_qos_info {
485struct iwl_station_entry { 489struct iwl_station_entry {
486 struct iwl_addsta_cmd sta; 490 struct iwl_addsta_cmd sta;
487 struct iwl_tid_data tid[MAX_TID_COUNT]; 491 struct iwl_tid_data tid[MAX_TID_COUNT];
488 u8 used; 492 u8 used, ctxid;
489 struct iwl_hw_key keyinfo; 493 struct iwl_hw_key keyinfo;
490 struct iwl_link_quality_cmd *lq; 494 struct iwl_link_quality_cmd *lq;
491}; 495};
492 496
493struct iwl_station_priv_common { 497struct iwl_station_priv_common {
498 struct iwl_rxon_context *ctx;
494 u8 sta_id; 499 u8 sta_id;
495}; 500};
496 501
@@ -519,6 +524,7 @@ struct iwl_station_priv {
519 * space for us to put data into. 524 * space for us to put data into.
520 */ 525 */
521struct iwl_vif_priv { 526struct iwl_vif_priv {
527 struct iwl_rxon_context *ctx;
522 u8 ibss_bssid_sta_id; 528 u8 ibss_bssid_sta_id;
523}; 529};
524 530
@@ -576,6 +582,7 @@ enum iwl_ucode_tlv_type {
576 IWL_UCODE_TLV_INIT_DATA = 4, 582 IWL_UCODE_TLV_INIT_DATA = 4,
577 IWL_UCODE_TLV_BOOT = 5, 583 IWL_UCODE_TLV_BOOT = 5,
578 IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */ 584 IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
585 IWL_UCODE_TLV_PAN = 7,
579 IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8, 586 IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8,
580 IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9, 587 IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9,
581 IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10, 588 IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10,
@@ -670,7 +677,6 @@ struct iwl_sensitivity_ranges {
670 * @rx_page_order: Rx buffer page order 677 * @rx_page_order: Rx buffer page order
671 * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR 678 * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
672 * @max_stations: 679 * @max_stations:
673 * @bcast_sta_id:
674 * @ht40_channel: is 40MHz width possible in band 2.4 680 * @ht40_channel: is 40MHz width possible in band 2.4
675 * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ) 681 * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
676 * @sw_crypto: 0 for hw, 1 for sw 682 * @sw_crypto: 0 for hw, 1 for sw
@@ -694,7 +700,6 @@ struct iwl_hw_params {
694 u32 rx_page_order; 700 u32 rx_page_order;
695 u32 rx_wrt_ptr_reg; 701 u32 rx_wrt_ptr_reg;
696 u8 max_stations; 702 u8 max_stations;
697 u8 bcast_sta_id;
698 u8 ht40_channel; 703 u8 ht40_channel;
699 u8 max_beacon_itrvl; /* in 1024 ms */ 704 u8 max_beacon_itrvl; /* in 1024 ms */
700 u32 max_inst_size; 705 u32 max_inst_size;
@@ -1064,6 +1069,10 @@ struct iwl_event_log {
1064#define IWL_DEF_MONITORING_PERIOD (1000) 1069#define IWL_DEF_MONITORING_PERIOD (1000)
1065#define IWL_LONG_MONITORING_PERIOD (5000) 1070#define IWL_LONG_MONITORING_PERIOD (5000)
1066#define IWL_ONE_HUNDRED_MSECS (100) 1071#define IWL_ONE_HUNDRED_MSECS (100)
1072#define IWL_MAX_MONITORING_PERIOD (60000)
1073
1074/* BT Antenna Coupling Threshold (dB) */
1075#define IWL_BT_ANTENNA_COUPLING_THRESHOLD (35)
1067 1076
1068enum iwl_reset { 1077enum iwl_reset {
1069 IWL_RF_RESET = 0, 1078 IWL_RF_RESET = 0,
@@ -1093,6 +1102,57 @@ struct iwl_force_reset {
1093 */ 1102 */
1094#define IWLAGN_EXT_BEACON_TIME_POS 22 1103#define IWLAGN_EXT_BEACON_TIME_POS 22
1095 1104
1105enum iwl_rxon_context_id {
1106 IWL_RXON_CTX_BSS,
1107 IWL_RXON_CTX_PAN,
1108
1109 NUM_IWL_RXON_CTX
1110};
1111
1112struct iwl_rxon_context {
1113 struct ieee80211_vif *vif;
1114
1115 const u8 *ac_to_fifo;
1116 const u8 *ac_to_queue;
1117 u8 mcast_queue;
1118
1119 enum iwl_rxon_context_id ctxid;
1120
1121 u32 interface_modes, exclusive_interface_modes;
1122 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
1123
1124 /*
1125 * We declare this const so it can only be
1126 * changed via explicit cast within the
1127 * routines that actually update the physical
1128 * hardware.
1129 */
1130 const struct iwl_rxon_cmd active;
1131 struct iwl_rxon_cmd staging;
1132
1133 struct iwl_rxon_time_cmd timing;
1134
1135 struct iwl_qos_info qos_data;
1136
1137 u8 bcast_sta_id, ap_sta_id;
1138
1139 u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
1140 u8 qos_cmd;
1141 u8 wep_key_cmd;
1142
1143 struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
1144 u8 key_mapping_keys;
1145
1146 __le32 station_flags;
1147
1148 struct {
1149 bool non_gf_sta_present;
1150 u8 protection;
1151 bool enabled, is_40mhz;
1152 u8 extension_chan_offset;
1153 } ht;
1154};
1155
1096struct iwl_priv { 1156struct iwl_priv {
1097 1157
1098 /* ieee device used by generic ieee processing code */ 1158 /* ieee device used by generic ieee processing code */
@@ -1169,6 +1229,15 @@ struct iwl_priv {
1169 u32 hw_wa_rev; 1229 u32 hw_wa_rev;
1170 u8 rev_id; 1230 u8 rev_id;
1171 1231
1232 /* microcode/device supports multiple contexts */
1233 u8 valid_contexts;
1234
1235 /* command queue number */
1236 u8 cmd_queue;
1237
1238 /* max number of station keys */
1239 u8 sta_key_max_num;
1240
1172 /* EEPROM MAC addresses */ 1241 /* EEPROM MAC addresses */
1173 struct mac_address addresses[2]; 1242 struct mac_address addresses[2];
1174 1243
@@ -1186,15 +1255,7 @@ struct iwl_priv {
1186 u8 ucode_write_complete; /* the image write is complete */ 1255 u8 ucode_write_complete; /* the image write is complete */
1187 char firmware_name[25]; 1256 char firmware_name[25];
1188 1257
1189 1258 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX];
1190 struct iwl_rxon_time_cmd rxon_timing;
1191
1192 /* We declare this const so it can only be
1193 * changed via explicit cast within the
1194 * routines that actually update the physical
1195 * hardware */
1196 const struct iwl_rxon_cmd active_rxon;
1197 struct iwl_rxon_cmd staging_rxon;
1198 1259
1199 struct iwl_switch_rxon switch_rxon; 1260 struct iwl_switch_rxon switch_rxon;
1200 1261
@@ -1256,8 +1317,6 @@ struct iwl_priv {
1256 spinlock_t sta_lock; 1317 spinlock_t sta_lock;
1257 int num_stations; 1318 int num_stations;
1258 struct iwl_station_entry stations[IWL_STATION_COUNT]; 1319 struct iwl_station_entry stations[IWL_STATION_COUNT];
1259 struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; /* protected by mutex */
1260 u8 key_mapping_key;
1261 unsigned long ucode_key_table; 1320 unsigned long ucode_key_table;
1262 1321
1263 /* queue refcounts */ 1322 /* queue refcounts */
@@ -1282,7 +1341,6 @@ struct iwl_priv {
1282 1341
1283 /* Last Rx'd beacon timestamp */ 1342 /* Last Rx'd beacon timestamp */
1284 u64 timestamp; 1343 u64 timestamp;
1285 struct ieee80211_vif *vif;
1286 1344
1287 union { 1345 union {
1288#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE) 1346#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
@@ -1362,12 +1420,27 @@ struct iwl_priv {
1362#endif 1420#endif
1363 }; 1421 };
1364 1422
1423 /* bt coex */
1424 u8 bt_status;
1425 u8 bt_traffic_load, notif_bt_traffic_load;
1426 bool bt_ch_announce;
1427 bool bt_sco_active;
1428 bool bt_full_concurrent;
1429 bool bt_ant_couple_ok;
1430 __le32 kill_ack_mask;
1431 __le32 kill_cts_mask;
1432 __le16 bt_valid;
1433 u16 bt_on_thresh;
1434 u16 bt_duration;
1435 u16 dynamic_frag_thresh;
1436 u16 dynamic_agg_thresh;
1437 u8 bt_ci_compliance;
1438 struct work_struct bt_traffic_change_work;
1439
1365 struct iwl_hw_params hw_params; 1440 struct iwl_hw_params hw_params;
1366 1441
1367 u32 inta_mask; 1442 u32 inta_mask;
1368 1443
1369 struct iwl_qos_info qos_data;
1370
1371 struct workqueue_struct *workqueue; 1444 struct workqueue_struct *workqueue;
1372 1445
1373 struct work_struct restart; 1446 struct work_struct restart;
@@ -1375,11 +1448,15 @@ struct iwl_priv {
1375 struct work_struct rx_replenish; 1448 struct work_struct rx_replenish;
1376 struct work_struct abort_scan; 1449 struct work_struct abort_scan;
1377 struct work_struct beacon_update; 1450 struct work_struct beacon_update;
1451 struct iwl_rxon_context *beacon_ctx;
1452
1378 struct work_struct tt_work; 1453 struct work_struct tt_work;
1379 struct work_struct ct_enter; 1454 struct work_struct ct_enter;
1380 struct work_struct ct_exit; 1455 struct work_struct ct_exit;
1381 struct work_struct start_internal_scan; 1456 struct work_struct start_internal_scan;
1382 struct work_struct tx_flush; 1457 struct work_struct tx_flush;
1458 struct work_struct bt_full_concurrency;
1459 struct work_struct bt_runtime_config;
1383 1460
1384 struct tasklet_struct irq_tasklet; 1461 struct tasklet_struct irq_tasklet;
1385 1462
@@ -1467,10 +1544,34 @@ static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv,
1467 return NULL; 1544 return NULL;
1468} 1545}
1469 1546
1547static inline struct iwl_rxon_context *
1548iwl_rxon_ctx_from_vif(struct ieee80211_vif *vif)
1549{
1550 struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
1551
1552 return vif_priv->ctx;
1553}
1554
1555#define for_each_context(priv, ctx) \
1556 for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \
1557 ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \
1558 if (priv->valid_contexts & BIT(ctx->ctxid))
1559
1560static inline int iwl_is_associated(struct iwl_priv *priv,
1561 enum iwl_rxon_context_id ctxid)
1562{
1563 return (priv->contexts[ctxid].active.filter_flags &
1564 RXON_FILTER_ASSOC_MSK) ? 1 : 0;
1565}
1566
1567static inline int iwl_is_any_associated(struct iwl_priv *priv)
1568{
1569 return iwl_is_associated(priv, IWL_RXON_CTX_BSS);
1570}
1470 1571
1471static inline int iwl_is_associated(struct iwl_priv *priv) 1572static inline int iwl_is_associated_ctx(struct iwl_rxon_context *ctx)
1472{ 1573{
1473 return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; 1574 return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
1474} 1575}
1475 1576
1476static inline int is_channel_valid(const struct iwl_channel_info *ch_info) 1577static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index 258d059ef41f..c373b53babea 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -97,6 +97,17 @@ const char *get_cmd_string(u8 cmd)
97 IWL_CMD(REPLY_TX_POWER_DBM_CMD); 97 IWL_CMD(REPLY_TX_POWER_DBM_CMD);
98 IWL_CMD(TEMPERATURE_NOTIFICATION); 98 IWL_CMD(TEMPERATURE_NOTIFICATION);
99 IWL_CMD(TX_ANT_CONFIGURATION_CMD); 99 IWL_CMD(TX_ANT_CONFIGURATION_CMD);
100 IWL_CMD(REPLY_BT_COEX_PROFILE_NOTIF);
101 IWL_CMD(REPLY_BT_COEX_PRIO_TABLE);
102 IWL_CMD(REPLY_BT_COEX_PROT_ENV);
103 IWL_CMD(REPLY_WIPAN_PARAMS);
104 IWL_CMD(REPLY_WIPAN_RXON);
105 IWL_CMD(REPLY_WIPAN_RXON_TIMING);
106 IWL_CMD(REPLY_WIPAN_RXON_ASSOC);
107 IWL_CMD(REPLY_WIPAN_QOS_PARAM);
108 IWL_CMD(REPLY_WIPAN_WEPKEY);
109 IWL_CMD(REPLY_WIPAN_P2P_CHANNEL_SWITCH);
110 IWL_CMD(REPLY_WIPAN_NOA_NOTIFICATION);
100 default: 111 default:
101 return "UNKNOWN"; 112 return "UNKNOWN";
102 113
@@ -229,7 +240,7 @@ cancel:
229 * in later, it will possibly set an invalid 240 * in later, it will possibly set an invalid
230 * address (cmd->meta.source). 241 * address (cmd->meta.source).
231 */ 242 */
232 priv->txq[IWL_CMD_QUEUE_NUM].meta[cmd_idx].flags &= 243 priv->txq[priv->cmd_queue].meta[cmd_idx].flags &=
233 ~CMD_WANT_SKB; 244 ~CMD_WANT_SKB;
234 } 245 }
235fail: 246fail:
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index b1f101caf19d..5469655646ae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -306,7 +306,7 @@
306 * at a time, until receiving ACK from receiving station, or reaching 306 * at a time, until receiving ACK from receiving station, or reaching
307 * retry limit and giving up. 307 * retry limit and giving up.
308 * 308 *
309 * The command queue (#4) must use this mode! 309 * The command queue (#4/#9) must use this mode!
310 * This mode does not require use of the Byte Count table in host DRAM. 310 * This mode does not require use of the Byte Count table in host DRAM.
311 * 311 *
312 * Driver controls scheduler operation via 3 means: 312 * Driver controls scheduler operation via 3 means:
@@ -322,7 +322,7 @@
322 * (1024 bytes for each queue). 322 * (1024 bytes for each queue).
323 * 323 *
324 * After receiving "Alive" response from uCode, driver must initialize 324 * After receiving "Alive" response from uCode, driver must initialize
325 * the scheduler (especially for queue #4, the command queue, otherwise 325 * the scheduler (especially for queue #4/#9, the command queue, otherwise
326 * the driver can't issue commands!): 326 * the driver can't issue commands!):
327 */ 327 */
328 328
@@ -555,8 +555,9 @@
555#define IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ 555#define IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
556 ((IWLAGN_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffc) 556 ((IWLAGN_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffc)
557 557
558#define IWLAGN_SCD_QUEUECHAIN_SEL_ALL(x) (((1<<(x)) - 1) &\ 558#define IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv) \
559 (~(1<<IWL_CMD_QUEUE_NUM))) 559 (((1<<(priv)->hw_params.max_txq_num) - 1) &\
560 (~(1<<(priv)->cmd_queue)))
560 561
561#define IWLAGN_SCD_BASE (PRPH_BASE + 0xa02c00) 562#define IWLAGN_SCD_BASE (PRPH_BASE + 0xa02c00)
562 563
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 79773e353baa..10be197b0f22 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -228,7 +228,7 @@ void iwl_recover_from_statistics(struct iwl_priv *priv,
228{ 228{
229 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 229 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
230 return; 230 return;
231 if (iwl_is_associated(priv)) { 231 if (iwl_is_any_associated(priv)) {
232 if (priv->cfg->ops->lib->check_ack_health) { 232 if (priv->cfg->ops->lib->check_ack_health) {
233 if (!priv->cfg->ops->lib->check_ack_health( 233 if (!priv->cfg->ops->lib->check_ack_health(
234 priv, pkt)) { 234 priv, pkt)) {
@@ -266,7 +266,12 @@ int iwl_set_decrypted_flag(struct iwl_priv *priv,
266{ 266{
267 u16 fc = le16_to_cpu(hdr->frame_control); 267 u16 fc = le16_to_cpu(hdr->frame_control);
268 268
269 if (priv->active_rxon.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) 269 /*
270 * All contexts have the same setting here due to it being
271 * a module parameter, so OK to check any context.
272 */
273 if (priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags &
274 RXON_FILTER_DIS_DECRYPT_MSK)
270 return 0; 275 return 0;
271 276
272 if (!(fc & IEEE80211_FCTL_PROTECTED)) 277 if (!(fc & IEEE80211_FCTL_PROTECTED))
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 8d7fa59364fe..7727f0966d31 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -206,7 +206,6 @@ static void iwl_rx_scan_results_notif(struct iwl_priv *priv,
206static void iwl_rx_scan_complete_notif(struct iwl_priv *priv, 206static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
207 struct iwl_rx_mem_buffer *rxb) 207 struct iwl_rx_mem_buffer *rxb)
208{ 208{
209#ifdef CONFIG_IWLWIFI_DEBUG
210 struct iwl_rx_packet *pkt = rxb_addr(rxb); 209 struct iwl_rx_packet *pkt = rxb_addr(rxb);
211 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 210 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
212 211
@@ -214,7 +213,6 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
214 scan_notif->scanned_channels, 213 scan_notif->scanned_channels,
215 scan_notif->tsf_low, 214 scan_notif->tsf_low,
216 scan_notif->tsf_high, scan_notif->status); 215 scan_notif->tsf_high, scan_notif->status);
217#endif
218 216
219 /* The HW is no longer scanning */ 217 /* The HW is no longer scanning */
220 clear_bit(STATUS_SCAN_HW, &priv->status); 218 clear_bit(STATUS_SCAN_HW, &priv->status);
@@ -236,6 +234,26 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
236 234
237 clear_bit(STATUS_SCANNING, &priv->status); 235 clear_bit(STATUS_SCANNING, &priv->status);
238 236
237 if (priv->iw_mode != NL80211_IFTYPE_ADHOC &&
238 priv->cfg->advanced_bt_coexist && priv->bt_status !=
239 scan_notif->bt_status) {
240 if (scan_notif->bt_status) {
241 /* BT on */
242 if (!priv->bt_ch_announce)
243 priv->bt_traffic_load =
244 IWL_BT_COEX_TRAFFIC_LOAD_HIGH;
245 /*
246 * otherwise, no traffic load information provided
247 * no changes made
248 */
249 } else {
250 /* BT off */
251 priv->bt_traffic_load =
252 IWL_BT_COEX_TRAFFIC_LOAD_NONE;
253 }
254 priv->bt_status = scan_notif->bt_status;
255 queue_work(priv->workqueue, &priv->bt_traffic_change_work);
256 }
239 queue_work(priv->workqueue, &priv->scan_completed); 257 queue_work(priv->workqueue, &priv->scan_completed);
240} 258}
241 259
@@ -268,18 +286,28 @@ u16 iwl_get_passive_dwell_time(struct iwl_priv *priv,
268 enum ieee80211_band band, 286 enum ieee80211_band band,
269 struct ieee80211_vif *vif) 287 struct ieee80211_vif *vif)
270{ 288{
289 struct iwl_rxon_context *ctx;
271 u16 passive = (band == IEEE80211_BAND_2GHZ) ? 290 u16 passive = (band == IEEE80211_BAND_2GHZ) ?
272 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : 291 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 :
273 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; 292 IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52;
274 293
275 if (iwl_is_associated(priv)) { 294 if (iwl_is_any_associated(priv)) {
276 /* If we're associated, we clamp the maximum passive 295 /*
277 * dwell time to be 98% of the beacon interval (minus 296 * If we're associated, we clamp the maximum passive
278 * 2 * channel tune time) */ 297 * dwell time to be 98% of the smallest beacon interval
279 passive = vif ? vif->bss_conf.beacon_int : 0; 298 * (minus 2 * channel tune time)
280 if ((passive > IWL_PASSIVE_DWELL_BASE) || !passive) 299 */
281 passive = IWL_PASSIVE_DWELL_BASE; 300 for_each_context(priv, ctx) {
282 passive = (passive * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; 301 u16 value;
302
303 if (!iwl_is_associated_ctx(ctx))
304 continue;
305 value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0;
306 if ((value > IWL_PASSIVE_DWELL_BASE) || !value)
307 value = IWL_PASSIVE_DWELL_BASE;
308 value = (value * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2;
309 passive = min(value, passive);
310 }
283 } 311 }
284 312
285 return passive; 313 return passive;
@@ -509,6 +537,7 @@ static void iwl_bg_scan_completed(struct work_struct *work)
509 container_of(work, struct iwl_priv, scan_completed); 537 container_of(work, struct iwl_priv, scan_completed);
510 bool internal = false; 538 bool internal = false;
511 bool scan_completed = false; 539 bool scan_completed = false;
540 struct iwl_rxon_context *ctx;
512 541
513 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n"); 542 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n");
514 543
@@ -539,11 +568,13 @@ static void iwl_bg_scan_completed(struct work_struct *work)
539 * Since setting the RXON may have been deferred while 568 * Since setting the RXON may have been deferred while
540 * performing the scan, fire one off if needed 569 * performing the scan, fire one off if needed
541 */ 570 */
542 if (memcmp(&priv->active_rxon, 571 for_each_context(priv, ctx)
543 &priv->staging_rxon, sizeof(priv->staging_rxon))) 572 iwlcore_commit_rxon(priv, ctx);
544 iwlcore_commit_rxon(priv);
545 573
546 out: 574 out:
575 if (priv->cfg->ops->hcmd->set_pan_params)
576 priv->cfg->ops->hcmd->set_pan_params(priv);
577
547 mutex_unlock(&priv->mutex); 578 mutex_unlock(&priv->mutex);
548 579
549 /* 580 /*
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index d5e8db37b86e..ccd09027c7cd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -172,12 +172,14 @@ int iwl_send_add_sta(struct iwl_priv *priv,
172EXPORT_SYMBOL(iwl_send_add_sta); 172EXPORT_SYMBOL(iwl_send_add_sta);
173 173
174static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index, 174static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
175 struct ieee80211_sta_ht_cap *sta_ht_inf) 175 struct ieee80211_sta *sta,
176 struct iwl_rxon_context *ctx)
176{ 177{
178 struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap;
177 __le32 sta_flags; 179 __le32 sta_flags;
178 u8 mimo_ps_mode; 180 u8 mimo_ps_mode;
179 181
180 if (!sta_ht_inf || !sta_ht_inf->ht_supported) 182 if (!sta || !sta_ht_inf->ht_supported)
181 goto done; 183 goto done;
182 184
183 mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; 185 mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
@@ -211,7 +213,7 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
211 sta_flags |= cpu_to_le32( 213 sta_flags |= cpu_to_le32(
212 (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); 214 (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS);
213 215
214 if (iwl_is_ht40_tx_allowed(priv, sta_ht_inf)) 216 if (iwl_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap))
215 sta_flags |= STA_FLG_HT40_EN_MSK; 217 sta_flags |= STA_FLG_HT40_EN_MSK;
216 else 218 else
217 sta_flags &= ~STA_FLG_HT40_EN_MSK; 219 sta_flags &= ~STA_FLG_HT40_EN_MSK;
@@ -226,9 +228,9 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
226 * 228 *
227 * should be called with sta_lock held 229 * should be called with sta_lock held
228 */ 230 */
229static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr, 231static u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
230 bool is_ap, 232 const u8 *addr, bool is_ap,
231 struct ieee80211_sta_ht_cap *ht_info) 233 struct ieee80211_sta *sta)
232{ 234{
233 struct iwl_station_entry *station; 235 struct iwl_station_entry *station;
234 int i; 236 int i;
@@ -236,9 +238,9 @@ static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr,
236 u16 rate; 238 u16 rate;
237 239
238 if (is_ap) 240 if (is_ap)
239 sta_id = IWL_AP_ID; 241 sta_id = ctx->ap_sta_id;
240 else if (is_broadcast_ether_addr(addr)) 242 else if (is_broadcast_ether_addr(addr))
241 sta_id = priv->hw_params.bcast_sta_id; 243 sta_id = ctx->bcast_sta_id;
242 else 244 else
243 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) { 245 for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) {
244 if (!compare_ether_addr(priv->stations[i].sta.sta.addr, 246 if (!compare_ether_addr(priv->stations[i].sta.sta.addr,
@@ -289,14 +291,22 @@ static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr,
289 memcpy(station->sta.sta.addr, addr, ETH_ALEN); 291 memcpy(station->sta.sta.addr, addr, ETH_ALEN);
290 station->sta.mode = 0; 292 station->sta.mode = 0;
291 station->sta.sta.sta_id = sta_id; 293 station->sta.sta.sta_id = sta_id;
292 station->sta.station_flags = 0; 294 station->sta.station_flags = ctx->station_flags;
295 station->ctxid = ctx->ctxid;
296
297 if (sta) {
298 struct iwl_station_priv_common *sta_priv;
299
300 sta_priv = (void *)sta->drv_priv;
301 sta_priv->ctx = ctx;
302 }
293 303
294 /* 304 /*
295 * OK to call unconditionally, since local stations (IBSS BSSID 305 * OK to call unconditionally, since local stations (IBSS BSSID
296 * STA and broadcast STA) pass in a NULL ht_info, and mac80211 306 * STA and broadcast STA) pass in a NULL sta, and mac80211
297 * doesn't allow HT IBSS. 307 * doesn't allow HT IBSS.
298 */ 308 */
299 iwl_set_ht_add_station(priv, sta_id, ht_info); 309 iwl_set_ht_add_station(priv, sta_id, sta, ctx);
300 310
301 /* 3945 only */ 311 /* 3945 only */
302 rate = (priv->band == IEEE80211_BAND_5GHZ) ? 312 rate = (priv->band == IEEE80211_BAND_5GHZ) ?
@@ -313,10 +323,9 @@ static u8 iwl_prep_station(struct iwl_priv *priv, const u8 *addr,
313/** 323/**
314 * iwl_add_station_common - 324 * iwl_add_station_common -
315 */ 325 */
316int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr, 326int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
317 bool is_ap, 327 const u8 *addr, bool is_ap,
318 struct ieee80211_sta_ht_cap *ht_info, 328 struct ieee80211_sta *sta, u8 *sta_id_r)
319 u8 *sta_id_r)
320{ 329{
321 unsigned long flags_spin; 330 unsigned long flags_spin;
322 int ret = 0; 331 int ret = 0;
@@ -325,7 +334,7 @@ int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr,
325 334
326 *sta_id_r = 0; 335 *sta_id_r = 0;
327 spin_lock_irqsave(&priv->sta_lock, flags_spin); 336 spin_lock_irqsave(&priv->sta_lock, flags_spin);
328 sta_id = iwl_prep_station(priv, addr, is_ap, ht_info); 337 sta_id = iwl_prep_station(priv, ctx, addr, is_ap, sta);
329 if (sta_id == IWL_INVALID_STATION) { 338 if (sta_id == IWL_INVALID_STATION) {
330 IWL_ERR(priv, "Unable to prepare station %pM for addition\n", 339 IWL_ERR(priv, "Unable to prepare station %pM for addition\n",
331 addr); 340 addr);
@@ -431,8 +440,8 @@ static struct iwl_link_quality_cmd *iwl_sta_alloc_lq(struct iwl_priv *priv,
431 * 440 *
432 * Function sleeps. 441 * Function sleeps.
433 */ 442 */
434int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs, 443int iwl_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
435 u8 *sta_id_r) 444 const u8 *addr, bool init_rs, u8 *sta_id_r)
436{ 445{
437 int ret; 446 int ret;
438 u8 sta_id; 447 u8 sta_id;
@@ -442,7 +451,7 @@ int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs,
442 if (sta_id_r) 451 if (sta_id_r)
443 *sta_id_r = IWL_INVALID_STATION; 452 *sta_id_r = IWL_INVALID_STATION;
444 453
445 ret = iwl_add_station_common(priv, addr, 0, NULL, &sta_id); 454 ret = iwl_add_station_common(priv, ctx, addr, 0, NULL, &sta_id);
446 if (ret) { 455 if (ret) {
447 IWL_ERR(priv, "Unable to add station %pM\n", addr); 456 IWL_ERR(priv, "Unable to add station %pM\n", addr);
448 return ret; 457 return ret;
@@ -464,7 +473,7 @@ int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs,
464 return -ENOMEM; 473 return -ENOMEM;
465 } 474 }
466 475
467 ret = iwl_send_lq_cmd(priv, link_cmd, CMD_SYNC, true); 476 ret = iwl_send_lq_cmd(priv, ctx, link_cmd, CMD_SYNC, true);
468 if (ret) 477 if (ret)
469 IWL_ERR(priv, "Link quality command failed (%d)\n", ret); 478 IWL_ERR(priv, "Link quality command failed (%d)\n", ret);
470 479
@@ -616,7 +625,8 @@ EXPORT_SYMBOL_GPL(iwl_remove_station);
616 * other than explicit station management would cause this in 625 * other than explicit station management would cause this in
617 * the ucode, e.g. unassociated RXON. 626 * the ucode, e.g. unassociated RXON.
618 */ 627 */
619void iwl_clear_ucode_stations(struct iwl_priv *priv) 628void iwl_clear_ucode_stations(struct iwl_priv *priv,
629 struct iwl_rxon_context *ctx)
620{ 630{
621 int i; 631 int i;
622 unsigned long flags_spin; 632 unsigned long flags_spin;
@@ -626,6 +636,9 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv)
626 636
627 spin_lock_irqsave(&priv->sta_lock, flags_spin); 637 spin_lock_irqsave(&priv->sta_lock, flags_spin);
628 for (i = 0; i < priv->hw_params.max_stations; i++) { 638 for (i = 0; i < priv->hw_params.max_stations; i++) {
639 if (ctx && ctx->ctxid != priv->stations[i].ctxid)
640 continue;
641
629 if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) { 642 if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
630 IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i); 643 IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i);
631 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE; 644 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
@@ -647,7 +660,7 @@ EXPORT_SYMBOL(iwl_clear_ucode_stations);
647 * 660 *
648 * Function sleeps. 661 * Function sleeps.
649 */ 662 */
650void iwl_restore_stations(struct iwl_priv *priv) 663void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
651{ 664{
652 struct iwl_addsta_cmd sta_cmd; 665 struct iwl_addsta_cmd sta_cmd;
653 struct iwl_link_quality_cmd lq; 666 struct iwl_link_quality_cmd lq;
@@ -665,6 +678,8 @@ void iwl_restore_stations(struct iwl_priv *priv)
665 IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); 678 IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n");
666 spin_lock_irqsave(&priv->sta_lock, flags_spin); 679 spin_lock_irqsave(&priv->sta_lock, flags_spin);
667 for (i = 0; i < priv->hw_params.max_stations; i++) { 680 for (i = 0; i < priv->hw_params.max_stations; i++) {
681 if (ctx->ctxid != priv->stations[i].ctxid)
682 continue;
668 if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) && 683 if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) &&
669 !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) { 684 !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) {
670 IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n", 685 IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n",
@@ -700,7 +715,7 @@ void iwl_restore_stations(struct iwl_priv *priv)
700 * current LQ command 715 * current LQ command
701 */ 716 */
702 if (send_lq) 717 if (send_lq)
703 iwl_send_lq_cmd(priv, &lq, CMD_SYNC, true); 718 iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true);
704 spin_lock_irqsave(&priv->sta_lock, flags_spin); 719 spin_lock_irqsave(&priv->sta_lock, flags_spin);
705 priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; 720 priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS;
706 } 721 }
@@ -718,7 +733,7 @@ int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
718{ 733{
719 int i; 734 int i;
720 735
721 for (i = 0; i < STA_KEY_MAX_NUM; i++) 736 for (i = 0; i < priv->sta_key_max_num; i++)
722 if (!test_and_set_bit(i, &priv->ucode_key_table)) 737 if (!test_and_set_bit(i, &priv->ucode_key_table))
723 return i; 738 return i;
724 739
@@ -726,7 +741,9 @@ int iwl_get_free_ucode_key_index(struct iwl_priv *priv)
726} 741}
727EXPORT_SYMBOL(iwl_get_free_ucode_key_index); 742EXPORT_SYMBOL(iwl_get_free_ucode_key_index);
728 743
729static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty) 744static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv,
745 struct iwl_rxon_context *ctx,
746 bool send_if_empty)
730{ 747{
731 int i, not_empty = 0; 748 int i, not_empty = 0;
732 u8 buff[sizeof(struct iwl_wep_cmd) + 749 u8 buff[sizeof(struct iwl_wep_cmd) +
@@ -734,7 +751,7 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
734 struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff; 751 struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff;
735 size_t cmd_size = sizeof(struct iwl_wep_cmd); 752 size_t cmd_size = sizeof(struct iwl_wep_cmd);
736 struct iwl_host_cmd cmd = { 753 struct iwl_host_cmd cmd = {
737 .id = REPLY_WEPKEY, 754 .id = ctx->wep_key_cmd,
738 .data = wep_cmd, 755 .data = wep_cmd,
739 .flags = CMD_SYNC, 756 .flags = CMD_SYNC,
740 }; 757 };
@@ -746,16 +763,16 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
746 763
747 for (i = 0; i < WEP_KEYS_MAX ; i++) { 764 for (i = 0; i < WEP_KEYS_MAX ; i++) {
748 wep_cmd->key[i].key_index = i; 765 wep_cmd->key[i].key_index = i;
749 if (priv->wep_keys[i].key_size) { 766 if (ctx->wep_keys[i].key_size) {
750 wep_cmd->key[i].key_offset = i; 767 wep_cmd->key[i].key_offset = i;
751 not_empty = 1; 768 not_empty = 1;
752 } else { 769 } else {
753 wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; 770 wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET;
754 } 771 }
755 772
756 wep_cmd->key[i].key_size = priv->wep_keys[i].key_size; 773 wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size;
757 memcpy(&wep_cmd->key[i].key[3], priv->wep_keys[i].key, 774 memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key,
758 priv->wep_keys[i].key_size); 775 ctx->wep_keys[i].key_size);
759 } 776 }
760 777
761 wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; 778 wep_cmd->global_key_type = WEP_KEY_WEP_TYPE;
@@ -771,15 +788,17 @@ static int iwl_send_static_wepkey_cmd(struct iwl_priv *priv, u8 send_if_empty)
771 return 0; 788 return 0;
772} 789}
773 790
774int iwl_restore_default_wep_keys(struct iwl_priv *priv) 791int iwl_restore_default_wep_keys(struct iwl_priv *priv,
792 struct iwl_rxon_context *ctx)
775{ 793{
776 lockdep_assert_held(&priv->mutex); 794 lockdep_assert_held(&priv->mutex);
777 795
778 return iwl_send_static_wepkey_cmd(priv, 0); 796 return iwl_send_static_wepkey_cmd(priv, ctx, false);
779} 797}
780EXPORT_SYMBOL(iwl_restore_default_wep_keys); 798EXPORT_SYMBOL(iwl_restore_default_wep_keys);
781 799
782int iwl_remove_default_wep_key(struct iwl_priv *priv, 800int iwl_remove_default_wep_key(struct iwl_priv *priv,
801 struct iwl_rxon_context *ctx,
783 struct ieee80211_key_conf *keyconf) 802 struct ieee80211_key_conf *keyconf)
784{ 803{
785 int ret; 804 int ret;
@@ -789,13 +808,13 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
789 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", 808 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
790 keyconf->keyidx); 809 keyconf->keyidx);
791 810
792 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); 811 memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0]));
793 if (iwl_is_rfkill(priv)) { 812 if (iwl_is_rfkill(priv)) {
794 IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); 813 IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n");
795 /* but keys in device are clear anyway so return success */ 814 /* but keys in device are clear anyway so return success */
796 return 0; 815 return 0;
797 } 816 }
798 ret = iwl_send_static_wepkey_cmd(priv, 1); 817 ret = iwl_send_static_wepkey_cmd(priv, ctx, 1);
799 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", 818 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n",
800 keyconf->keyidx, ret); 819 keyconf->keyidx, ret);
801 820
@@ -804,6 +823,7 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
804EXPORT_SYMBOL(iwl_remove_default_wep_key); 823EXPORT_SYMBOL(iwl_remove_default_wep_key);
805 824
806int iwl_set_default_wep_key(struct iwl_priv *priv, 825int iwl_set_default_wep_key(struct iwl_priv *priv,
826 struct iwl_rxon_context *ctx,
807 struct ieee80211_key_conf *keyconf) 827 struct ieee80211_key_conf *keyconf)
808{ 828{
809 int ret; 829 int ret;
@@ -818,13 +838,13 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
818 838
819 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; 839 keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV;
820 keyconf->hw_key_idx = HW_KEY_DEFAULT; 840 keyconf->hw_key_idx = HW_KEY_DEFAULT;
821 priv->stations[IWL_AP_ID].keyinfo.cipher = keyconf->cipher; 841 priv->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher;
822 842
823 priv->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; 843 ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen;
824 memcpy(&priv->wep_keys[keyconf->keyidx].key, &keyconf->key, 844 memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key,
825 keyconf->keylen); 845 keyconf->keylen);
826 846
827 ret = iwl_send_static_wepkey_cmd(priv, 0); 847 ret = iwl_send_static_wepkey_cmd(priv, ctx, false);
828 IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", 848 IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n",
829 keyconf->keylen, keyconf->keyidx, ret); 849 keyconf->keylen, keyconf->keyidx, ret);
830 850
@@ -833,8 +853,9 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
833EXPORT_SYMBOL(iwl_set_default_wep_key); 853EXPORT_SYMBOL(iwl_set_default_wep_key);
834 854
835static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv, 855static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
836 struct ieee80211_key_conf *keyconf, 856 struct iwl_rxon_context *ctx,
837 u8 sta_id) 857 struct ieee80211_key_conf *keyconf,
858 u8 sta_id)
838{ 859{
839 unsigned long flags; 860 unsigned long flags;
840 __le16 key_flags = 0; 861 __le16 key_flags = 0;
@@ -851,7 +872,7 @@ static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
851 if (keyconf->keylen == WEP_KEY_LEN_128) 872 if (keyconf->keylen == WEP_KEY_LEN_128)
852 key_flags |= STA_KEY_FLG_KEY_SIZE_MSK; 873 key_flags |= STA_KEY_FLG_KEY_SIZE_MSK;
853 874
854 if (sta_id == priv->hw_params.bcast_sta_id) 875 if (sta_id == ctx->bcast_sta_id)
855 key_flags |= STA_KEY_MULTICAST_MSK; 876 key_flags |= STA_KEY_MULTICAST_MSK;
856 877
857 spin_lock_irqsave(&priv->sta_lock, flags); 878 spin_lock_irqsave(&priv->sta_lock, flags);
@@ -887,8 +908,9 @@ static int iwl_set_wep_dynamic_key_info(struct iwl_priv *priv,
887} 908}
888 909
889static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv, 910static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
890 struct ieee80211_key_conf *keyconf, 911 struct iwl_rxon_context *ctx,
891 u8 sta_id) 912 struct ieee80211_key_conf *keyconf,
913 u8 sta_id)
892{ 914{
893 unsigned long flags; 915 unsigned long flags;
894 __le16 key_flags = 0; 916 __le16 key_flags = 0;
@@ -900,7 +922,7 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
900 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); 922 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
901 key_flags &= ~STA_KEY_FLG_INVALID; 923 key_flags &= ~STA_KEY_FLG_INVALID;
902 924
903 if (sta_id == priv->hw_params.bcast_sta_id) 925 if (sta_id == ctx->bcast_sta_id)
904 key_flags |= STA_KEY_MULTICAST_MSK; 926 key_flags |= STA_KEY_MULTICAST_MSK;
905 927
906 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 928 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -936,8 +958,9 @@ static int iwl_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
936} 958}
937 959
938static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv, 960static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
939 struct ieee80211_key_conf *keyconf, 961 struct iwl_rxon_context *ctx,
940 u8 sta_id) 962 struct ieee80211_key_conf *keyconf,
963 u8 sta_id)
941{ 964{
942 unsigned long flags; 965 unsigned long flags;
943 int ret = 0; 966 int ret = 0;
@@ -947,7 +970,7 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
947 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); 970 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
948 key_flags &= ~STA_KEY_FLG_INVALID; 971 key_flags &= ~STA_KEY_FLG_INVALID;
949 972
950 if (sta_id == priv->hw_params.bcast_sta_id) 973 if (sta_id == ctx->bcast_sta_id)
951 key_flags |= STA_KEY_MULTICAST_MSK; 974 key_flags |= STA_KEY_MULTICAST_MSK;
952 975
953 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 976 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -982,8 +1005,9 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
982} 1005}
983 1006
984void iwl_update_tkip_key(struct iwl_priv *priv, 1007void iwl_update_tkip_key(struct iwl_priv *priv,
985 struct ieee80211_key_conf *keyconf, 1008 struct iwl_rxon_context *ctx,
986 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) 1009 struct ieee80211_key_conf *keyconf,
1010 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key)
987{ 1011{
988 u8 sta_id; 1012 u8 sta_id;
989 unsigned long flags; 1013 unsigned long flags;
@@ -995,7 +1019,7 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
995 return; 1019 return;
996 } 1020 }
997 1021
998 sta_id = iwl_sta_id_or_broadcast(priv, sta); 1022 sta_id = iwl_sta_id_or_broadcast(priv, ctx, sta);
999 if (sta_id == IWL_INVALID_STATION) 1023 if (sta_id == IWL_INVALID_STATION)
1000 return; 1024 return;
1001 1025
@@ -1018,8 +1042,9 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
1018EXPORT_SYMBOL(iwl_update_tkip_key); 1042EXPORT_SYMBOL(iwl_update_tkip_key);
1019 1043
1020int iwl_remove_dynamic_key(struct iwl_priv *priv, 1044int iwl_remove_dynamic_key(struct iwl_priv *priv,
1021 struct ieee80211_key_conf *keyconf, 1045 struct iwl_rxon_context *ctx,
1022 u8 sta_id) 1046 struct ieee80211_key_conf *keyconf,
1047 u8 sta_id)
1023{ 1048{
1024 unsigned long flags; 1049 unsigned long flags;
1025 u16 key_flags; 1050 u16 key_flags;
@@ -1028,7 +1053,7 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
1028 1053
1029 lockdep_assert_held(&priv->mutex); 1054 lockdep_assert_held(&priv->mutex);
1030 1055
1031 priv->key_mapping_key--; 1056 ctx->key_mapping_keys--;
1032 1057
1033 spin_lock_irqsave(&priv->sta_lock, flags); 1058 spin_lock_irqsave(&priv->sta_lock, flags);
1034 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); 1059 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags);
@@ -1080,26 +1105,26 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
1080} 1105}
1081EXPORT_SYMBOL(iwl_remove_dynamic_key); 1106EXPORT_SYMBOL(iwl_remove_dynamic_key);
1082 1107
1083int iwl_set_dynamic_key(struct iwl_priv *priv, 1108int iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
1084 struct ieee80211_key_conf *keyconf, u8 sta_id) 1109 struct ieee80211_key_conf *keyconf, u8 sta_id)
1085{ 1110{
1086 int ret; 1111 int ret;
1087 1112
1088 lockdep_assert_held(&priv->mutex); 1113 lockdep_assert_held(&priv->mutex);
1089 1114
1090 priv->key_mapping_key++; 1115 ctx->key_mapping_keys++;
1091 keyconf->hw_key_idx = HW_KEY_DYNAMIC; 1116 keyconf->hw_key_idx = HW_KEY_DYNAMIC;
1092 1117
1093 switch (keyconf->cipher) { 1118 switch (keyconf->cipher) {
1094 case WLAN_CIPHER_SUITE_CCMP: 1119 case WLAN_CIPHER_SUITE_CCMP:
1095 ret = iwl_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); 1120 ret = iwl_set_ccmp_dynamic_key_info(priv, ctx, keyconf, sta_id);
1096 break; 1121 break;
1097 case WLAN_CIPHER_SUITE_TKIP: 1122 case WLAN_CIPHER_SUITE_TKIP:
1098 ret = iwl_set_tkip_dynamic_key_info(priv, keyconf, sta_id); 1123 ret = iwl_set_tkip_dynamic_key_info(priv, ctx, keyconf, sta_id);
1099 break; 1124 break;
1100 case WLAN_CIPHER_SUITE_WEP40: 1125 case WLAN_CIPHER_SUITE_WEP40:
1101 case WLAN_CIPHER_SUITE_WEP104: 1126 case WLAN_CIPHER_SUITE_WEP104:
1102 ret = iwl_set_wep_dynamic_key_info(priv, keyconf, sta_id); 1127 ret = iwl_set_wep_dynamic_key_info(priv, ctx, keyconf, sta_id);
1103 break; 1128 break;
1104 default: 1129 default:
1105 IWL_ERR(priv, 1130 IWL_ERR(priv,
@@ -1149,16 +1174,16 @@ static inline void iwl_dump_lq_cmd(struct iwl_priv *priv,
1149 * RXON flags are updated and when LQ command is updated. 1174 * RXON flags are updated and when LQ command is updated.
1150 */ 1175 */
1151static bool is_lq_table_valid(struct iwl_priv *priv, 1176static bool is_lq_table_valid(struct iwl_priv *priv,
1177 struct iwl_rxon_context *ctx,
1152 struct iwl_link_quality_cmd *lq) 1178 struct iwl_link_quality_cmd *lq)
1153{ 1179{
1154 int i; 1180 int i;
1155 struct iwl_ht_config *ht_conf = &priv->current_ht_config;
1156 1181
1157 if (ht_conf->is_ht) 1182 if (ctx->ht.enabled)
1158 return true; 1183 return true;
1159 1184
1160 IWL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n", 1185 IWL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n",
1161 priv->active_rxon.channel); 1186 ctx->active.channel);
1162 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { 1187 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
1163 if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { 1188 if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) {
1164 IWL_DEBUG_INFO(priv, 1189 IWL_DEBUG_INFO(priv,
@@ -1180,7 +1205,7 @@ static bool is_lq_table_valid(struct iwl_priv *priv,
1180 * this case to clear the state indicating that station creation is in 1205 * this case to clear the state indicating that station creation is in
1181 * progress. 1206 * progress.
1182 */ 1207 */
1183int iwl_send_lq_cmd(struct iwl_priv *priv, 1208int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
1184 struct iwl_link_quality_cmd *lq, u8 flags, bool init) 1209 struct iwl_link_quality_cmd *lq, u8 flags, bool init)
1185{ 1210{
1186 int ret = 0; 1211 int ret = 0;
@@ -1199,7 +1224,7 @@ int iwl_send_lq_cmd(struct iwl_priv *priv,
1199 iwl_dump_lq_cmd(priv, lq); 1224 iwl_dump_lq_cmd(priv, lq);
1200 BUG_ON(init && (cmd.flags & CMD_ASYNC)); 1225 BUG_ON(init && (cmd.flags & CMD_ASYNC));
1201 1226
1202 if (is_lq_table_valid(priv, lq)) 1227 if (is_lq_table_valid(priv, ctx, lq))
1203 ret = iwl_send_cmd(priv, &cmd); 1228 ret = iwl_send_cmd(priv, &cmd);
1204 else 1229 else
1205 ret = -EINVAL; 1230 ret = -EINVAL;
@@ -1225,14 +1250,15 @@ EXPORT_SYMBOL(iwl_send_lq_cmd);
1225 * and marks it driver active, so that it will be restored to the 1250 * and marks it driver active, so that it will be restored to the
1226 * device at the next best time. 1251 * device at the next best time.
1227 */ 1252 */
1228int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq) 1253int iwl_alloc_bcast_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
1254 bool init_lq)
1229{ 1255{
1230 struct iwl_link_quality_cmd *link_cmd; 1256 struct iwl_link_quality_cmd *link_cmd;
1231 unsigned long flags; 1257 unsigned long flags;
1232 u8 sta_id; 1258 u8 sta_id;
1233 1259
1234 spin_lock_irqsave(&priv->sta_lock, flags); 1260 spin_lock_irqsave(&priv->sta_lock, flags);
1235 sta_id = iwl_prep_station(priv, iwl_bcast_addr, false, NULL); 1261 sta_id = iwl_prep_station(priv, ctx, iwl_bcast_addr, false, NULL);
1236 if (sta_id == IWL_INVALID_STATION) { 1262 if (sta_id == IWL_INVALID_STATION) {
1237 IWL_ERR(priv, "Unable to prepare broadcast station\n"); 1263 IWL_ERR(priv, "Unable to prepare broadcast station\n");
1238 spin_unlock_irqrestore(&priv->sta_lock, flags); 1264 spin_unlock_irqrestore(&priv->sta_lock, flags);
@@ -1267,11 +1293,12 @@ EXPORT_SYMBOL_GPL(iwl_alloc_bcast_station);
1267 * Only used by iwlagn. Placed here to have all bcast station management 1293 * Only used by iwlagn. Placed here to have all bcast station management
1268 * code together. 1294 * code together.
1269 */ 1295 */
1270int iwl_update_bcast_station(struct iwl_priv *priv) 1296static int iwl_update_bcast_station(struct iwl_priv *priv,
1297 struct iwl_rxon_context *ctx)
1271{ 1298{
1272 unsigned long flags; 1299 unsigned long flags;
1273 struct iwl_link_quality_cmd *link_cmd; 1300 struct iwl_link_quality_cmd *link_cmd;
1274 u8 sta_id = priv->hw_params.bcast_sta_id; 1301 u8 sta_id = ctx->bcast_sta_id;
1275 1302
1276 link_cmd = iwl_sta_alloc_lq(priv, sta_id); 1303 link_cmd = iwl_sta_alloc_lq(priv, sta_id);
1277 if (!link_cmd) { 1304 if (!link_cmd) {
@@ -1289,9 +1316,23 @@ int iwl_update_bcast_station(struct iwl_priv *priv)
1289 1316
1290 return 0; 1317 return 0;
1291} 1318}
1292EXPORT_SYMBOL_GPL(iwl_update_bcast_station);
1293 1319
1294void iwl_dealloc_bcast_station(struct iwl_priv *priv) 1320int iwl_update_bcast_stations(struct iwl_priv *priv)
1321{
1322 struct iwl_rxon_context *ctx;
1323 int ret = 0;
1324
1325 for_each_context(priv, ctx) {
1326 ret = iwl_update_bcast_station(priv, ctx);
1327 if (ret)
1328 break;
1329 }
1330
1331 return ret;
1332}
1333EXPORT_SYMBOL_GPL(iwl_update_bcast_stations);
1334
1335void iwl_dealloc_bcast_stations(struct iwl_priv *priv)
1295{ 1336{
1296 unsigned long flags; 1337 unsigned long flags;
1297 int i; 1338 int i;
@@ -1309,7 +1350,7 @@ void iwl_dealloc_bcast_station(struct iwl_priv *priv)
1309 } 1350 }
1310 spin_unlock_irqrestore(&priv->sta_lock, flags); 1351 spin_unlock_irqrestore(&priv->sta_lock, flags);
1311} 1352}
1312EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_station); 1353EXPORT_SYMBOL_GPL(iwl_dealloc_bcast_stations);
1313 1354
1314/** 1355/**
1315 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table 1356 * iwl_sta_tx_modify_enable_tid - Enable Tx for this TID in station table
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index d38a350ba0bd..56bad3f60d81 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -44,32 +44,37 @@
44 44
45 45
46int iwl_remove_default_wep_key(struct iwl_priv *priv, 46int iwl_remove_default_wep_key(struct iwl_priv *priv,
47 struct iwl_rxon_context *ctx,
47 struct ieee80211_key_conf *key); 48 struct ieee80211_key_conf *key);
48int iwl_set_default_wep_key(struct iwl_priv *priv, 49int iwl_set_default_wep_key(struct iwl_priv *priv,
50 struct iwl_rxon_context *ctx,
49 struct ieee80211_key_conf *key); 51 struct ieee80211_key_conf *key);
50int iwl_restore_default_wep_keys(struct iwl_priv *priv); 52int iwl_restore_default_wep_keys(struct iwl_priv *priv,
51int iwl_set_dynamic_key(struct iwl_priv *priv, 53 struct iwl_rxon_context *ctx);
54int iwl_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
52 struct ieee80211_key_conf *key, u8 sta_id); 55 struct ieee80211_key_conf *key, u8 sta_id);
53int iwl_remove_dynamic_key(struct iwl_priv *priv, 56int iwl_remove_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
54 struct ieee80211_key_conf *key, u8 sta_id); 57 struct ieee80211_key_conf *key, u8 sta_id);
55void iwl_update_tkip_key(struct iwl_priv *priv, 58void iwl_update_tkip_key(struct iwl_priv *priv,
56 struct ieee80211_key_conf *keyconf, 59 struct iwl_rxon_context *ctx,
57 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); 60 struct ieee80211_key_conf *keyconf,
58 61 struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
59void iwl_restore_stations(struct iwl_priv *priv); 62
60void iwl_clear_ucode_stations(struct iwl_priv *priv); 63void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
61int iwl_alloc_bcast_station(struct iwl_priv *priv, bool init_lq); 64void iwl_clear_ucode_stations(struct iwl_priv *priv,
62void iwl_dealloc_bcast_station(struct iwl_priv *priv); 65 struct iwl_rxon_context *ctx);
63int iwl_update_bcast_station(struct iwl_priv *priv); 66int iwl_alloc_bcast_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
67 bool init_lq);
68void iwl_dealloc_bcast_stations(struct iwl_priv *priv);
69int iwl_update_bcast_stations(struct iwl_priv *priv);
64int iwl_get_free_ucode_key_index(struct iwl_priv *priv); 70int iwl_get_free_ucode_key_index(struct iwl_priv *priv);
65int iwl_send_add_sta(struct iwl_priv *priv, 71int iwl_send_add_sta(struct iwl_priv *priv,
66 struct iwl_addsta_cmd *sta, u8 flags); 72 struct iwl_addsta_cmd *sta, u8 flags);
67int iwl_add_bssid_station(struct iwl_priv *priv, const u8 *addr, bool init_rs, 73int iwl_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
68 u8 *sta_id_r); 74 const u8 *addr, bool init_rs, u8 *sta_id_r);
69int iwl_add_station_common(struct iwl_priv *priv, const u8 *addr, 75int iwl_add_station_common(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
70 bool is_ap, 76 const u8 *addr, bool is_ap,
71 struct ieee80211_sta_ht_cap *ht_info, 77 struct ieee80211_sta *sta, u8 *sta_id_r);
72 u8 *sta_id_r);
73int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, 78int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
74 const u8 *addr); 79 const u8 *addr);
75int iwl_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 80int iwl_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
@@ -94,20 +99,25 @@ void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt);
94static inline void iwl_clear_driver_stations(struct iwl_priv *priv) 99static inline void iwl_clear_driver_stations(struct iwl_priv *priv)
95{ 100{
96 unsigned long flags; 101 unsigned long flags;
102 struct iwl_rxon_context *ctx;
97 103
98 spin_lock_irqsave(&priv->sta_lock, flags); 104 spin_lock_irqsave(&priv->sta_lock, flags);
99 memset(priv->stations, 0, sizeof(priv->stations)); 105 memset(priv->stations, 0, sizeof(priv->stations));
100 priv->num_stations = 0; 106 priv->num_stations = 0;
101 107
102 /*
103 * Remove all key information that is not stored as part of station
104 * information since mac80211 may not have had a
105 * chance to remove all the keys. When device is reconfigured by
106 * mac80211 after an error all keys will be reconfigured.
107 */
108 priv->ucode_key_table = 0; 108 priv->ucode_key_table = 0;
109 priv->key_mapping_key = 0; 109
110 memset(priv->wep_keys, 0, sizeof(priv->wep_keys)); 110 for_each_context(priv, ctx) {
111 /*
112 * Remove all key information that is not stored as part
113 * of station information since mac80211 may not have had
114 * a chance to remove all the keys. When device is
115 * reconfigured by mac80211 after an error all keys will
116 * be reconfigured.
117 */
118 memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys));
119 ctx->key_mapping_keys = 0;
120 }
111 121
112 spin_unlock_irqrestore(&priv->sta_lock, flags); 122 spin_unlock_irqrestore(&priv->sta_lock, flags);
113} 123}
@@ -123,6 +133,7 @@ static inline int iwl_sta_id(struct ieee80211_sta *sta)
123/** 133/**
124 * iwl_sta_id_or_broadcast - return sta_id or broadcast sta 134 * iwl_sta_id_or_broadcast - return sta_id or broadcast sta
125 * @priv: iwl priv 135 * @priv: iwl priv
136 * @context: the current context
126 * @sta: mac80211 station 137 * @sta: mac80211 station
127 * 138 *
128 * In certain circumstances mac80211 passes a station pointer 139 * In certain circumstances mac80211 passes a station pointer
@@ -131,12 +142,13 @@ static inline int iwl_sta_id(struct ieee80211_sta *sta)
131 * inline wraps that pattern. 142 * inline wraps that pattern.
132 */ 143 */
133static inline int iwl_sta_id_or_broadcast(struct iwl_priv *priv, 144static inline int iwl_sta_id_or_broadcast(struct iwl_priv *priv,
145 struct iwl_rxon_context *context,
134 struct ieee80211_sta *sta) 146 struct ieee80211_sta *sta)
135{ 147{
136 int sta_id; 148 int sta_id;
137 149
138 if (!sta) 150 if (!sta)
139 return priv->hw_params.bcast_sta_id; 151 return context->bcast_sta_id;
140 152
141 sta_id = iwl_sta_id(sta); 153 sta_id = iwl_sta_id(sta);
142 154
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index c308dab14673..347d3dc6a015 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -134,7 +134,7 @@ EXPORT_SYMBOL(iwl_tx_queue_free);
134 */ 134 */
135void iwl_cmd_queue_free(struct iwl_priv *priv) 135void iwl_cmd_queue_free(struct iwl_priv *priv)
136{ 136{
137 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; 137 struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
138 struct iwl_queue *q = &txq->q; 138 struct iwl_queue *q = &txq->q;
139 struct device *dev = &priv->pci_dev->dev; 139 struct device *dev = &priv->pci_dev->dev;
140 int i; 140 int i;
@@ -271,7 +271,7 @@ static int iwl_tx_queue_alloc(struct iwl_priv *priv,
271 271
272 /* Driver private data, only for Tx (not command) queues, 272 /* Driver private data, only for Tx (not command) queues,
273 * not shared with device. */ 273 * not shared with device. */
274 if (id != IWL_CMD_QUEUE_NUM) { 274 if (id != priv->cmd_queue) {
275 txq->txb = kzalloc(sizeof(txq->txb[0]) * 275 txq->txb = kzalloc(sizeof(txq->txb[0]) *
276 TFD_QUEUE_SIZE_MAX, GFP_KERNEL); 276 TFD_QUEUE_SIZE_MAX, GFP_KERNEL);
277 if (!txq->txb) { 277 if (!txq->txb) {
@@ -314,13 +314,13 @@ int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
314 314
315 /* 315 /*
316 * Alloc buffer array for commands (Tx or other types of commands). 316 * Alloc buffer array for commands (Tx or other types of commands).
317 * For the command queue (#4), allocate command space + one big 317 * For the command queue (#4/#9), allocate command space + one big
318 * command for scan, since scan command is very huge; the system will 318 * command for scan, since scan command is very huge; the system will
319 * not have two scans at the same time, so only one is needed. 319 * not have two scans at the same time, so only one is needed.
320 * For normal Tx queues (all other queues), no super-size command 320 * For normal Tx queues (all other queues), no super-size command
321 * space is needed. 321 * space is needed.
322 */ 322 */
323 if (txq_id == IWL_CMD_QUEUE_NUM) 323 if (txq_id == priv->cmd_queue)
324 actual_slots++; 324 actual_slots++;
325 325
326 txq->meta = kzalloc(sizeof(struct iwl_cmd_meta) * actual_slots, 326 txq->meta = kzalloc(sizeof(struct iwl_cmd_meta) * actual_slots,
@@ -355,7 +355,7 @@ int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
355 * need an swq_id so don't set one to catch errors, all others can 355 * need an swq_id so don't set one to catch errors, all others can
356 * be set up to the identity mapping. 356 * be set up to the identity mapping.
357 */ 357 */
358 if (txq_id != IWL_CMD_QUEUE_NUM) 358 if (txq_id != priv->cmd_queue)
359 txq->swq_id = txq_id; 359 txq->swq_id = txq_id;
360 360
361 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise 361 /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
@@ -385,7 +385,7 @@ void iwl_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq,
385{ 385{
386 int actual_slots = slots_num; 386 int actual_slots = slots_num;
387 387
388 if (txq_id == IWL_CMD_QUEUE_NUM) 388 if (txq_id == priv->cmd_queue)
389 actual_slots++; 389 actual_slots++;
390 390
391 memset(txq->meta, 0, sizeof(struct iwl_cmd_meta) * actual_slots); 391 memset(txq->meta, 0, sizeof(struct iwl_cmd_meta) * actual_slots);
@@ -413,7 +413,7 @@ EXPORT_SYMBOL(iwl_tx_queue_reset);
413 */ 413 */
414int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) 414int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
415{ 415{
416 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; 416 struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
417 struct iwl_queue *q = &txq->q; 417 struct iwl_queue *q = &txq->q;
418 struct iwl_device_cmd *out_cmd; 418 struct iwl_device_cmd *out_cmd;
419 struct iwl_cmd_meta *out_meta; 419 struct iwl_cmd_meta *out_meta;
@@ -483,7 +483,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
483 * information */ 483 * information */
484 484
485 out_cmd->hdr.flags = 0; 485 out_cmd->hdr.flags = 0;
486 out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) | 486 out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(priv->cmd_queue) |
487 INDEX_TO_SEQ(q->write_ptr)); 487 INDEX_TO_SEQ(q->write_ptr));
488 if (cmd->flags & CMD_SIZE_HUGE) 488 if (cmd->flags & CMD_SIZE_HUGE)
489 out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; 489 out_cmd->hdr.sequence |= SEQ_HUGE_FRAME;
@@ -500,15 +500,15 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
500 get_cmd_string(out_cmd->hdr.cmd), 500 get_cmd_string(out_cmd->hdr.cmd),
501 out_cmd->hdr.cmd, 501 out_cmd->hdr.cmd,
502 le16_to_cpu(out_cmd->hdr.sequence), fix_size, 502 le16_to_cpu(out_cmd->hdr.sequence), fix_size,
503 q->write_ptr, idx, IWL_CMD_QUEUE_NUM); 503 q->write_ptr, idx, priv->cmd_queue);
504 break; 504 break;
505 default: 505 default:
506 IWL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, " 506 IWL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, "
507 "%d bytes at %d[%d]:%d\n", 507 "%d bytes at %d[%d]:%d\n",
508 get_cmd_string(out_cmd->hdr.cmd), 508 get_cmd_string(out_cmd->hdr.cmd),
509 out_cmd->hdr.cmd, 509 out_cmd->hdr.cmd,
510 le16_to_cpu(out_cmd->hdr.sequence), fix_size, 510 le16_to_cpu(out_cmd->hdr.sequence), fix_size,
511 q->write_ptr, idx, IWL_CMD_QUEUE_NUM); 511 q->write_ptr, idx, priv->cmd_queue);
512 } 512 }
513#endif 513#endif
514 txq->need_update = 1; 514 txq->need_update = 1;
@@ -587,16 +587,16 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
587 bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); 587 bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME);
588 struct iwl_device_cmd *cmd; 588 struct iwl_device_cmd *cmd;
589 struct iwl_cmd_meta *meta; 589 struct iwl_cmd_meta *meta;
590 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM]; 590 struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue];
591 591
592 /* If a Tx command is being handled and it isn't in the actual 592 /* If a Tx command is being handled and it isn't in the actual
593 * command queue then there a command routing bug has been introduced 593 * command queue then there a command routing bug has been introduced
594 * in the queue management code. */ 594 * in the queue management code. */
595 if (WARN(txq_id != IWL_CMD_QUEUE_NUM, 595 if (WARN(txq_id != priv->cmd_queue,
596 "wrong command queue %d, sequence 0x%X readp=%d writep=%d\n", 596 "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n",
597 txq_id, sequence, 597 txq_id, priv->cmd_queue, sequence,
598 priv->txq[IWL_CMD_QUEUE_NUM].q.read_ptr, 598 priv->txq[priv->cmd_queue].q.read_ptr,
599 priv->txq[IWL_CMD_QUEUE_NUM].q.write_ptr)) { 599 priv->txq[priv->cmd_queue].q.write_ptr)) {
600 iwl_print_hex_error(priv, pkt, 32); 600 iwl_print_hex_error(priv, pkt, 32);
601 return; 601 return;
602 } 602 }
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 94d7e6e1323d..68e624afb987 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -144,7 +144,7 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv,
144 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); 144 key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
145 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); 145 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
146 146
147 if (sta_id == priv->hw_params.bcast_sta_id) 147 if (sta_id == priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id)
148 key_flags |= STA_KEY_MULTICAST_MSK; 148 key_flags |= STA_KEY_MULTICAST_MSK;
149 149
150 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 150 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -317,7 +317,7 @@ unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv,
317 int left) 317 int left)
318{ 318{
319 319
320 if (!iwl_is_associated(priv) || !priv->ibss_beacon) 320 if (!iwl_is_associated(priv, IWL_RXON_CTX_BSS) || !priv->ibss_beacon)
321 return 0; 321 return 0;
322 322
323 if (priv->ibss_beacon->len > left) 323 if (priv->ibss_beacon->len > left)
@@ -343,7 +343,8 @@ static int iwl3945_send_beacon_cmd(struct iwl_priv *priv)
343 return -ENOMEM; 343 return -ENOMEM;
344 } 344 }
345 345
346 rate = iwl_rate_get_lowest_plcp(priv); 346 rate = iwl_rate_get_lowest_plcp(priv,
347 &priv->contexts[IWL_RXON_CTX_BSS]);
347 348
348 frame_size = iwl3945_hw_get_beacon_cmd(priv, frame, rate); 349 frame_size = iwl3945_hw_get_beacon_cmd(priv, frame, rate);
349 350
@@ -512,7 +513,9 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
512 hdr_len = ieee80211_hdrlen(fc); 513 hdr_len = ieee80211_hdrlen(fc);
513 514
514 /* Find index into station table for destination station */ 515 /* Find index into station table for destination station */
515 sta_id = iwl_sta_id_or_broadcast(priv, info->control.sta); 516 sta_id = iwl_sta_id_or_broadcast(
517 priv, &priv->contexts[IWL_RXON_CTX_BSS],
518 info->control.sta);
516 if (sta_id == IWL_INVALID_STATION) { 519 if (sta_id == IWL_INVALID_STATION) {
517 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 520 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
518 hdr->addr1); 521 hdr->addr1);
@@ -542,6 +545,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
542 /* Set up driver data for this TFD */ 545 /* Set up driver data for this TFD */
543 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); 546 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
544 txq->txb[q->write_ptr].skb = skb; 547 txq->txb[q->write_ptr].skb = skb;
548 txq->txb[q->write_ptr].ctx = &priv->contexts[IWL_RXON_CTX_BSS];
545 549
546 /* Init first empty entry in queue's array of Tx/cmd buffers */ 550 /* Init first empty entry in queue's array of Tx/cmd buffers */
547 out_cmd = txq->cmd[idx]; 551 out_cmd = txq->cmd[idx];
@@ -683,11 +687,12 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
683 int rc; 687 int rc;
684 int spectrum_resp_status; 688 int spectrum_resp_status;
685 int duration = le16_to_cpu(params->duration); 689 int duration = le16_to_cpu(params->duration);
690 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
686 691
687 if (iwl_is_associated(priv)) 692 if (iwl_is_associated(priv, IWL_RXON_CTX_BSS))
688 add_time = iwl_usecs_to_beacons(priv, 693 add_time = iwl_usecs_to_beacons(priv,
689 le64_to_cpu(params->start_time) - priv->_3945.last_tsf, 694 le64_to_cpu(params->start_time) - priv->_3945.last_tsf,
690 le16_to_cpu(priv->rxon_timing.beacon_interval)); 695 le16_to_cpu(ctx->timing.beacon_interval));
691 696
692 memset(&spectrum, 0, sizeof(spectrum)); 697 memset(&spectrum, 0, sizeof(spectrum));
693 698
@@ -698,18 +703,18 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
698 cmd.len = sizeof(spectrum); 703 cmd.len = sizeof(spectrum);
699 spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); 704 spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len));
700 705
701 if (iwl_is_associated(priv)) 706 if (iwl_is_associated(priv, IWL_RXON_CTX_BSS))
702 spectrum.start_time = 707 spectrum.start_time =
703 iwl_add_beacon_time(priv, 708 iwl_add_beacon_time(priv,
704 priv->_3945.last_beacon_time, add_time, 709 priv->_3945.last_beacon_time, add_time,
705 le16_to_cpu(priv->rxon_timing.beacon_interval)); 710 le16_to_cpu(ctx->timing.beacon_interval));
706 else 711 else
707 spectrum.start_time = 0; 712 spectrum.start_time = 0;
708 713
709 spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT); 714 spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT);
710 spectrum.channels[0].channel = params->channel; 715 spectrum.channels[0].channel = params->channel;
711 spectrum.channels[0].type = type; 716 spectrum.channels[0].type = type;
712 if (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK) 717 if (ctx->active.flags & RXON_FLG_BAND_24G_MSK)
713 spectrum.flags |= RXON_FLG_BAND_24G_MSK | 718 spectrum.flags |= RXON_FLG_BAND_24G_MSK |
714 RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; 719 RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK;
715 720
@@ -798,7 +803,8 @@ static void iwl3945_bg_beacon_update(struct work_struct *work)
798 struct sk_buff *beacon; 803 struct sk_buff *beacon;
799 804
800 /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ 805 /* Pull updated AP beacon from mac80211. will fail if not in AP mode */
801 beacon = ieee80211_beacon_get(priv->hw, priv->vif); 806 beacon = ieee80211_beacon_get(priv->hw,
807 priv->contexts[IWL_RXON_CTX_BSS].vif);
802 808
803 if (!beacon) { 809 if (!beacon) {
804 IWL_ERR(priv, "update beacon failed\n"); 810 IWL_ERR(priv, "update beacon failed\n");
@@ -2468,6 +2474,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2468{ 2474{
2469 int thermal_spin = 0; 2475 int thermal_spin = 0;
2470 u32 rfkill; 2476 u32 rfkill;
2477 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
2471 2478
2472 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); 2479 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
2473 2480
@@ -2525,22 +2532,22 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2525 2532
2526 iwl_power_update_mode(priv, true); 2533 iwl_power_update_mode(priv, true);
2527 2534
2528 if (iwl_is_associated(priv)) { 2535 if (iwl_is_associated(priv, IWL_RXON_CTX_BSS)) {
2529 struct iwl3945_rxon_cmd *active_rxon = 2536 struct iwl3945_rxon_cmd *active_rxon =
2530 (struct iwl3945_rxon_cmd *)(&priv->active_rxon); 2537 (struct iwl3945_rxon_cmd *)(&ctx->active);
2531 2538
2532 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 2539 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
2533 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2540 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
2534 } else { 2541 } else {
2535 /* Initialize our rx_config data */ 2542 /* Initialize our rx_config data */
2536 iwl_connection_init_rx_config(priv, NULL); 2543 iwl_connection_init_rx_config(priv, ctx);
2537 } 2544 }
2538 2545
2539 /* Configure Bluetooth device coexistence support */ 2546 /* Configure Bluetooth device coexistence support */
2540 priv->cfg->ops->hcmd->send_bt_config(priv); 2547 priv->cfg->ops->hcmd->send_bt_config(priv);
2541 2548
2542 /* Configure the adapter for unassociated operation */ 2549 /* Configure the adapter for unassociated operation */
2543 iwlcore_commit_rxon(priv); 2550 iwlcore_commit_rxon(priv, ctx);
2544 2551
2545 iwl3945_reg_txpower_periodic(priv); 2552 iwl3945_reg_txpower_periodic(priv);
2546 2553
@@ -2571,9 +2578,14 @@ static void __iwl3945_down(struct iwl_priv *priv)
2571 if (!exit_pending) 2578 if (!exit_pending)
2572 set_bit(STATUS_EXIT_PENDING, &priv->status); 2579 set_bit(STATUS_EXIT_PENDING, &priv->status);
2573 2580
2581 /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set
2582 * to prevent rearm timer */
2583 if (priv->cfg->ops->lib->recover_from_tx_stall)
2584 del_timer_sync(&priv->monitor_recover);
2585
2574 /* Station information will now be cleared in device */ 2586 /* Station information will now be cleared in device */
2575 iwl_clear_ucode_stations(priv); 2587 iwl_clear_ucode_stations(priv, NULL);
2576 iwl_dealloc_bcast_station(priv); 2588 iwl_dealloc_bcast_stations(priv);
2577 iwl_clear_driver_stations(priv); 2589 iwl_clear_driver_stations(priv);
2578 2590
2579 /* Unblock any waiting calls */ 2591 /* Unblock any waiting calls */
@@ -2655,7 +2667,8 @@ static int __iwl3945_up(struct iwl_priv *priv)
2655{ 2667{
2656 int rc, i; 2668 int rc, i;
2657 2669
2658 rc = iwl_alloc_bcast_station(priv, false); 2670 rc = iwl_alloc_bcast_station(priv, &priv->contexts[IWL_RXON_CTX_BSS],
2671 false);
2659 if (rc) 2672 if (rc)
2660 return rc; 2673 return rc;
2661 2674
@@ -2878,7 +2891,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2878 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 2891 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
2879 scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 2892 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
2880 2893
2881 if (iwl_is_associated(priv)) { 2894 if (iwl_is_associated(priv, IWL_RXON_CTX_BSS)) {
2882 u16 interval = 0; 2895 u16 interval = 0;
2883 u32 extra; 2896 u32 extra;
2884 u32 suspend_time = 100; 2897 u32 suspend_time = 100;
@@ -2939,7 +2952,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2939 /* We don't build a direct scan probe request; the uCode will do 2952 /* We don't build a direct scan probe request; the uCode will do
2940 * that based on the direct_mask added to each channel entry */ 2953 * that based on the direct_mask added to each channel entry */
2941 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 2954 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
2942 scan->tx_cmd.sta_id = priv->hw_params.bcast_sta_id; 2955 scan->tx_cmd.sta_id = priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id;
2943 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 2956 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
2944 2957
2945 /* flags + rate selection */ 2958 /* flags + rate selection */
@@ -3037,8 +3050,10 @@ static void iwl3945_bg_restart(struct work_struct *data)
3037 return; 3050 return;
3038 3051
3039 if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { 3052 if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
3053 struct iwl_rxon_context *ctx;
3040 mutex_lock(&priv->mutex); 3054 mutex_lock(&priv->mutex);
3041 priv->vif = NULL; 3055 for_each_context(priv, ctx)
3056 ctx->vif = NULL;
3042 priv->is_open = 0; 3057 priv->is_open = 0;
3043 mutex_unlock(&priv->mutex); 3058 mutex_unlock(&priv->mutex);
3044 iwl3945_down(priv); 3059 iwl3945_down(priv);
@@ -3072,6 +3087,7 @@ void iwl3945_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
3072{ 3087{
3073 int rc = 0; 3088 int rc = 0;
3074 struct ieee80211_conf *conf = NULL; 3089 struct ieee80211_conf *conf = NULL;
3090 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3075 3091
3076 if (!vif || !priv->is_open) 3092 if (!vif || !priv->is_open)
3077 return; 3093 return;
@@ -3082,7 +3098,7 @@ void iwl3945_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
3082 } 3098 }
3083 3099
3084 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", 3100 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
3085 vif->bss_conf.aid, priv->active_rxon.bssid_addr); 3101 vif->bss_conf.aid, ctx->active.bssid_addr);
3086 3102
3087 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3103 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3088 return; 3104 return;
@@ -3091,34 +3107,34 @@ void iwl3945_post_associate(struct iwl_priv *priv, struct ieee80211_vif *vif)
3091 3107
3092 conf = ieee80211_get_hw_conf(priv->hw); 3108 conf = ieee80211_get_hw_conf(priv->hw);
3093 3109
3094 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3110 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3095 iwlcore_commit_rxon(priv); 3111 iwlcore_commit_rxon(priv, ctx);
3096 3112
3097 rc = iwl_send_rxon_timing(priv, vif); 3113 rc = iwl_send_rxon_timing(priv, ctx);
3098 if (rc) 3114 if (rc)
3099 IWL_WARN(priv, "REPLY_RXON_TIMING failed - " 3115 IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
3100 "Attempting to continue.\n"); 3116 "Attempting to continue.\n");
3101 3117
3102 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3118 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
3103 3119
3104 priv->staging_rxon.assoc_id = cpu_to_le16(vif->bss_conf.aid); 3120 ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid);
3105 3121
3106 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", 3122 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
3107 vif->bss_conf.aid, vif->bss_conf.beacon_int); 3123 vif->bss_conf.aid, vif->bss_conf.beacon_int);
3108 3124
3109 if (vif->bss_conf.use_short_preamble) 3125 if (vif->bss_conf.use_short_preamble)
3110 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 3126 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
3111 else 3127 else
3112 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 3128 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
3113 3129
3114 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3130 if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) {
3115 if (vif->bss_conf.use_short_slot) 3131 if (vif->bss_conf.use_short_slot)
3116 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 3132 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
3117 else 3133 else
3118 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3134 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
3119 } 3135 }
3120 3136
3121 iwlcore_commit_rxon(priv); 3137 iwlcore_commit_rxon(priv, ctx);
3122 3138
3123 switch (vif->type) { 3139 switch (vif->type) {
3124 case NL80211_IFTYPE_STATION: 3140 case NL80211_IFTYPE_STATION:
@@ -3255,44 +3271,45 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3255 3271
3256void iwl3945_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif) 3272void iwl3945_config_ap(struct iwl_priv *priv, struct ieee80211_vif *vif)
3257{ 3273{
3274 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3258 int rc = 0; 3275 int rc = 0;
3259 3276
3260 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3277 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3261 return; 3278 return;
3262 3279
3263 /* The following should be done only at AP bring up */ 3280 /* The following should be done only at AP bring up */
3264 if (!(iwl_is_associated(priv))) { 3281 if (!(iwl_is_associated(priv, IWL_RXON_CTX_BSS))) {
3265 3282
3266 /* RXON - unassoc (to set timing command) */ 3283 /* RXON - unassoc (to set timing command) */
3267 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3284 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3268 iwlcore_commit_rxon(priv); 3285 iwlcore_commit_rxon(priv, ctx);
3269 3286
3270 /* RXON Timing */ 3287 /* RXON Timing */
3271 rc = iwl_send_rxon_timing(priv, vif); 3288 rc = iwl_send_rxon_timing(priv, ctx);
3272 if (rc) 3289 if (rc)
3273 IWL_WARN(priv, "REPLY_RXON_TIMING failed - " 3290 IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
3274 "Attempting to continue.\n"); 3291 "Attempting to continue.\n");
3275 3292
3276 priv->staging_rxon.assoc_id = 0; 3293 ctx->staging.assoc_id = 0;
3277 3294
3278 if (vif->bss_conf.use_short_preamble) 3295 if (vif->bss_conf.use_short_preamble)
3279 priv->staging_rxon.flags |= 3296 ctx->staging.flags |=
3280 RXON_FLG_SHORT_PREAMBLE_MSK; 3297 RXON_FLG_SHORT_PREAMBLE_MSK;
3281 else 3298 else
3282 priv->staging_rxon.flags &= 3299 ctx->staging.flags &=
3283 ~RXON_FLG_SHORT_PREAMBLE_MSK; 3300 ~RXON_FLG_SHORT_PREAMBLE_MSK;
3284 3301
3285 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3302 if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) {
3286 if (vif->bss_conf.use_short_slot) 3303 if (vif->bss_conf.use_short_slot)
3287 priv->staging_rxon.flags |= 3304 ctx->staging.flags |=
3288 RXON_FLG_SHORT_SLOT_MSK; 3305 RXON_FLG_SHORT_SLOT_MSK;
3289 else 3306 else
3290 priv->staging_rxon.flags &= 3307 ctx->staging.flags &=
3291 ~RXON_FLG_SHORT_SLOT_MSK; 3308 ~RXON_FLG_SHORT_SLOT_MSK;
3292 } 3309 }
3293 /* restore RXON assoc */ 3310 /* restore RXON assoc */
3294 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3311 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
3295 iwlcore_commit_rxon(priv); 3312 iwlcore_commit_rxon(priv, ctx);
3296 } 3313 }
3297 iwl3945_send_beacon_cmd(priv); 3314 iwl3945_send_beacon_cmd(priv);
3298 3315
@@ -3318,10 +3335,11 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3318 return -EOPNOTSUPP; 3335 return -EOPNOTSUPP;
3319 } 3336 }
3320 3337
3321 static_key = !iwl_is_associated(priv); 3338 static_key = !iwl_is_associated(priv, IWL_RXON_CTX_BSS);
3322 3339
3323 if (!static_key) { 3340 if (!static_key) {
3324 sta_id = iwl_sta_id_or_broadcast(priv, sta); 3341 sta_id = iwl_sta_id_or_broadcast(
3342 priv, &priv->contexts[IWL_RXON_CTX_BSS], sta);
3325 if (sta_id == IWL_INVALID_STATION) 3343 if (sta_id == IWL_INVALID_STATION)
3326 return -EINVAL; 3344 return -EINVAL;
3327 } 3345 }
@@ -3372,8 +3390,8 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw,
3372 sta_priv->common.sta_id = IWL_INVALID_STATION; 3390 sta_priv->common.sta_id = IWL_INVALID_STATION;
3373 3391
3374 3392
3375 ret = iwl_add_station_common(priv, sta->addr, is_ap, &sta->ht_cap, 3393 ret = iwl_add_station_common(priv, &priv->contexts[IWL_RXON_CTX_BSS],
3376 &sta_id); 3394 sta->addr, is_ap, sta, &sta_id);
3377 if (ret) { 3395 if (ret) {
3378 IWL_ERR(priv, "Unable to add station %pM (%d)\n", 3396 IWL_ERR(priv, "Unable to add station %pM (%d)\n",
3379 sta->addr, ret); 3397 sta->addr, ret);
@@ -3400,6 +3418,7 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw,
3400{ 3418{
3401 struct iwl_priv *priv = hw->priv; 3419 struct iwl_priv *priv = hw->priv;
3402 __le32 filter_or = 0, filter_nand = 0; 3420 __le32 filter_or = 0, filter_nand = 0;
3421 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3403 3422
3404#define CHK(test, flag) do { \ 3423#define CHK(test, flag) do { \
3405 if (*total_flags & (test)) \ 3424 if (*total_flags & (test)) \
@@ -3419,8 +3438,8 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw,
3419 3438
3420 mutex_lock(&priv->mutex); 3439 mutex_lock(&priv->mutex);
3421 3440
3422 priv->staging_rxon.filter_flags &= ~filter_nand; 3441 ctx->staging.filter_flags &= ~filter_nand;
3423 priv->staging_rxon.filter_flags |= filter_or; 3442 ctx->staging.filter_flags |= filter_or;
3424 3443
3425 /* 3444 /*
3426 * Committing directly here breaks for some reason, 3445 * Committing directly here breaks for some reason,
@@ -3534,8 +3553,9 @@ static ssize_t show_flags(struct device *d,
3534 struct device_attribute *attr, char *buf) 3553 struct device_attribute *attr, char *buf)
3535{ 3554{
3536 struct iwl_priv *priv = dev_get_drvdata(d); 3555 struct iwl_priv *priv = dev_get_drvdata(d);
3556 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3537 3557
3538 return sprintf(buf, "0x%04X\n", priv->active_rxon.flags); 3558 return sprintf(buf, "0x%04X\n", ctx->active.flags);
3539} 3559}
3540 3560
3541static ssize_t store_flags(struct device *d, 3561static ssize_t store_flags(struct device *d,
@@ -3544,17 +3564,18 @@ static ssize_t store_flags(struct device *d,
3544{ 3564{
3545 struct iwl_priv *priv = dev_get_drvdata(d); 3565 struct iwl_priv *priv = dev_get_drvdata(d);
3546 u32 flags = simple_strtoul(buf, NULL, 0); 3566 u32 flags = simple_strtoul(buf, NULL, 0);
3567 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3547 3568
3548 mutex_lock(&priv->mutex); 3569 mutex_lock(&priv->mutex);
3549 if (le32_to_cpu(priv->staging_rxon.flags) != flags) { 3570 if (le32_to_cpu(ctx->staging.flags) != flags) {
3550 /* Cancel any currently running scans... */ 3571 /* Cancel any currently running scans... */
3551 if (iwl_scan_cancel_timeout(priv, 100)) 3572 if (iwl_scan_cancel_timeout(priv, 100))
3552 IWL_WARN(priv, "Could not cancel scan.\n"); 3573 IWL_WARN(priv, "Could not cancel scan.\n");
3553 else { 3574 else {
3554 IWL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n", 3575 IWL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n",
3555 flags); 3576 flags);
3556 priv->staging_rxon.flags = cpu_to_le32(flags); 3577 ctx->staging.flags = cpu_to_le32(flags);
3557 iwlcore_commit_rxon(priv); 3578 iwlcore_commit_rxon(priv, ctx);
3558 } 3579 }
3559 } 3580 }
3560 mutex_unlock(&priv->mutex); 3581 mutex_unlock(&priv->mutex);
@@ -3568,9 +3589,10 @@ static ssize_t show_filter_flags(struct device *d,
3568 struct device_attribute *attr, char *buf) 3589 struct device_attribute *attr, char *buf)
3569{ 3590{
3570 struct iwl_priv *priv = dev_get_drvdata(d); 3591 struct iwl_priv *priv = dev_get_drvdata(d);
3592 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3571 3593
3572 return sprintf(buf, "0x%04X\n", 3594 return sprintf(buf, "0x%04X\n",
3573 le32_to_cpu(priv->active_rxon.filter_flags)); 3595 le32_to_cpu(ctx->active.filter_flags));
3574} 3596}
3575 3597
3576static ssize_t store_filter_flags(struct device *d, 3598static ssize_t store_filter_flags(struct device *d,
@@ -3578,19 +3600,20 @@ static ssize_t store_filter_flags(struct device *d,
3578 const char *buf, size_t count) 3600 const char *buf, size_t count)
3579{ 3601{
3580 struct iwl_priv *priv = dev_get_drvdata(d); 3602 struct iwl_priv *priv = dev_get_drvdata(d);
3603 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3581 u32 filter_flags = simple_strtoul(buf, NULL, 0); 3604 u32 filter_flags = simple_strtoul(buf, NULL, 0);
3582 3605
3583 mutex_lock(&priv->mutex); 3606 mutex_lock(&priv->mutex);
3584 if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) { 3607 if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) {
3585 /* Cancel any currently running scans... */ 3608 /* Cancel any currently running scans... */
3586 if (iwl_scan_cancel_timeout(priv, 100)) 3609 if (iwl_scan_cancel_timeout(priv, 100))
3587 IWL_WARN(priv, "Could not cancel scan.\n"); 3610 IWL_WARN(priv, "Could not cancel scan.\n");
3588 else { 3611 else {
3589 IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = " 3612 IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = "
3590 "0x%04X\n", filter_flags); 3613 "0x%04X\n", filter_flags);
3591 priv->staging_rxon.filter_flags = 3614 ctx->staging.filter_flags =
3592 cpu_to_le32(filter_flags); 3615 cpu_to_le32(filter_flags);
3593 iwlcore_commit_rxon(priv); 3616 iwlcore_commit_rxon(priv, ctx);
3594 } 3617 }
3595 } 3618 }
3596 mutex_unlock(&priv->mutex); 3619 mutex_unlock(&priv->mutex);
@@ -3638,8 +3661,9 @@ static ssize_t store_measurement(struct device *d,
3638 const char *buf, size_t count) 3661 const char *buf, size_t count)
3639{ 3662{
3640 struct iwl_priv *priv = dev_get_drvdata(d); 3663 struct iwl_priv *priv = dev_get_drvdata(d);
3664 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
3641 struct ieee80211_measurement_params params = { 3665 struct ieee80211_measurement_params params = {
3642 .channel = le16_to_cpu(priv->active_rxon.channel), 3666 .channel = le16_to_cpu(ctx->active.channel),
3643 .start_time = cpu_to_le64(priv->_3945.last_tsf), 3667 .start_time = cpu_to_le64(priv->_3945.last_tsf),
3644 .duration = cpu_to_le16(1), 3668 .duration = cpu_to_le16(1),
3645 }; 3669 };
@@ -3811,8 +3835,6 @@ static void iwl3945_cancel_deferred_work(struct iwl_priv *priv)
3811 cancel_delayed_work(&priv->alive_start); 3835 cancel_delayed_work(&priv->alive_start);
3812 cancel_work_sync(&priv->start_internal_scan); 3836 cancel_work_sync(&priv->start_internal_scan);
3813 cancel_work_sync(&priv->beacon_update); 3837 cancel_work_sync(&priv->beacon_update);
3814 if (priv->cfg->ops->lib->recover_from_tx_stall)
3815 del_timer_sync(&priv->monitor_recover);
3816} 3838}
3817 3839
3818static struct attribute *iwl3945_sysfs_entries[] = { 3840static struct attribute *iwl3945_sysfs_entries[] = {
@@ -3933,8 +3955,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3933 IEEE80211_HW_SUPPORTS_DYNAMIC_PS; 3955 IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
3934 3956
3935 hw->wiphy->interface_modes = 3957 hw->wiphy->interface_modes =
3936 BIT(NL80211_IFTYPE_STATION) | 3958 priv->contexts[IWL_RXON_CTX_BSS].interface_modes;
3937 BIT(NL80211_IFTYPE_ADHOC);
3938 3959
3939 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | 3960 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
3940 WIPHY_FLAG_DISABLE_BEACON_HINTS; 3961 WIPHY_FLAG_DISABLE_BEACON_HINTS;
@@ -3966,7 +3987,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3966 3987
3967static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 3988static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3968{ 3989{
3969 int err = 0; 3990 int err = 0, i;
3970 struct iwl_priv *priv; 3991 struct iwl_priv *priv;
3971 struct ieee80211_hw *hw; 3992 struct ieee80211_hw *hw;
3972 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 3993 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
@@ -3988,6 +4009,27 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
3988 priv = hw->priv; 4009 priv = hw->priv;
3989 SET_IEEE80211_DEV(hw, &pdev->dev); 4010 SET_IEEE80211_DEV(hw, &pdev->dev);
3990 4011
4012 priv->cmd_queue = IWL39_CMD_QUEUE_NUM;
4013
4014 /* 3945 has only one valid context */
4015 priv->valid_contexts = BIT(IWL_RXON_CTX_BSS);
4016
4017 for (i = 0; i < NUM_IWL_RXON_CTX; i++)
4018 priv->contexts[i].ctxid = i;
4019
4020 priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON;
4021 priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING;
4022 priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC;
4023 priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM;
4024 priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID;
4025 priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
4026 priv->contexts[IWL_RXON_CTX_BSS].interface_modes =
4027 BIT(NL80211_IFTYPE_STATION) |
4028 BIT(NL80211_IFTYPE_ADHOC);
4029 priv->contexts[IWL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS;
4030 priv->contexts[IWL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS;
4031 priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS;
4032
3991 /* 4033 /*
3992 * Disabling hardware scan means that mac80211 will perform scans 4034 * Disabling hardware scan means that mac80211 will perform scans
3993 * "the hard way", rather than using device's scan. 4035 * "the hard way", rather than using device's scan.
@@ -4123,7 +4165,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4123 } 4165 }
4124 4166
4125 iwl_set_rxon_channel(priv, 4167 iwl_set_rxon_channel(priv,
4126 &priv->bands[IEEE80211_BAND_2GHZ].channels[5]); 4168 &priv->bands[IEEE80211_BAND_2GHZ].channels[5],
4169 &priv->contexts[IWL_RXON_CTX_BSS]);
4127 iwl3945_setup_deferred_work(priv); 4170 iwl3945_setup_deferred_work(priv);
4128 iwl3945_setup_rx_handlers(priv); 4171 iwl3945_setup_rx_handlers(priv);
4129 iwl_power_initialize(priv); 4172 iwl_power_initialize(priv);