aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2011-11-15 05:29:04 -0500
committerStanislaw Gruszka <sgruszka@redhat.com>2011-11-15 05:29:04 -0500
commit7c2cde2ef278cb833581fe599c6654fc28b11a7e (patch)
treeacc1efd4d4bf4bddc0543c1fb659f73f6e8bb2a5
parentdcae1c641a4d7b7a00b1a566355ffaa517588aa6 (diff)
iwlegacy: partial rxon context cleanup
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945-rs.c6
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945.c30
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-calib.c2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-lib.c4
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-tx.c4
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965.c14
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-core.c17
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-debugfs.c6
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-dev.h27
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-rx.c2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl3945-base.c84
-rw-r--r--drivers/net/wireless/iwlegacy/iwl4965-base.c54
12 files changed, 111 insertions, 139 deletions
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
index 345beb7d3e83..070730183c9c 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
@@ -342,7 +342,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i
342 int i; 342 int i;
343 343
344 D_INFO("enter\n"); 344 D_INFO("enter\n");
345 if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) 345 if (sta_id == il->ctx.bcast_sta_id)
346 goto out; 346 goto out;
347 347
348 psta = (struct il3945_sta_priv *) sta->drv_priv; 348 psta = (struct il3945_sta_priv *) sta->drv_priv;
@@ -936,7 +936,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
936 936
937 rcu_read_lock(); 937 rcu_read_lock();
938 938
939 sta = ieee80211_find_sta(il->contexts[IL_RXON_CTX_BSS].vif, 939 sta = ieee80211_find_sta(il->ctx.vif,
940 il->stations[sta_id].sta.sta.addr); 940 il->stations[sta_id].sta.sta.addr);
941 if (!sta) { 941 if (!sta) {
942 D_RATE("Unable to find station to initialize rate scaling.\n"); 942 D_RATE("Unable to find station to initialize rate scaling.\n");
@@ -953,7 +953,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
953 switch (il->band) { 953 switch (il->band) {
954 case IEEE80211_BAND_2GHZ: 954 case IEEE80211_BAND_2GHZ:
955 /* TODO: this always does G, not a regression */ 955 /* TODO: this always does G, not a regression */
956 if (il->contexts[IL_RXON_CTX_BSS].active.flags & 956 if (il->ctx.active.flags &
957 RXON_FLG_TGG_PROTECT_MSK) { 957 RXON_FLG_TGG_PROTECT_MSK) {
958 rs_sta->tgg = 1; 958 rs_sta->tgg = 1;
959 rs_sta->expected_tpt = il3945_expected_tpt_g_prot; 959 rs_sta->expected_tpt = il3945_expected_tpt_g_prot;
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c
index 98c74e09510c..ff006e7ba6a5 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945.c
@@ -253,7 +253,7 @@ int il3945_rs_next_rate(struct il_priv *il, int rate)
253 break; 253 break;
254 case IEEE80211_BAND_2GHZ: 254 case IEEE80211_BAND_2GHZ:
255 if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && 255 if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) &&
256 il_is_associated(il, IL_RXON_CTX_BSS)) { 256 il_is_associated(il)) {
257 if (rate == IL_RATE_11M_INDEX) 257 if (rate == IL_RATE_11M_INDEX)
258 next_rate = IL_RATE_5M_INDEX; 258 next_rate = IL_RATE_5M_INDEX;
259 } 259 }
@@ -1374,7 +1374,7 @@ static int il3945_send_tx_power(struct il_priv *il)
1374 int rate_idx, i; 1374 int rate_idx, i;
1375 const struct il_channel_info *ch_info = NULL; 1375 const struct il_channel_info *ch_info = NULL;
1376 struct il3945_txpowertable_cmd txpower = { 1376 struct il3945_txpowertable_cmd txpower = {
1377 .channel = il->contexts[IL_RXON_CTX_BSS].active.channel, 1377 .channel = il->ctx.active.channel,
1378 }; 1378 };
1379 u16 chan; 1379 u16 chan;
1380 1380
@@ -1382,7 +1382,7 @@ static int il3945_send_tx_power(struct il_priv *il)
1382 "TX Power requested while scanning!\n")) 1382 "TX Power requested while scanning!\n"))
1383 return -EAGAIN; 1383 return -EAGAIN;
1384 1384
1385 chan = le16_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.channel); 1385 chan = le16_to_cpu(il->ctx.active.channel);
1386 1386
1387 txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; 1387 txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1;
1388 ch_info = il_get_channel_info(il, il->band, chan); 1388 ch_info = il_get_channel_info(il, il->band, chan);
@@ -1734,9 +1734,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
1734 * il3945_rxon_assoc_cmd which is used to reconfigure filter 1734 * il3945_rxon_assoc_cmd which is used to reconfigure filter
1735 * and other flags for the current radio configuration. */ 1735 * and other flags for the current radio configuration. */
1736 if (!il_full_rxon_required(il, 1736 if (!il_full_rxon_required(il,
1737 &il->contexts[IL_RXON_CTX_BSS])) { 1737 &il->ctx)) {
1738 rc = il_send_rxon_assoc(il, 1738 rc = il_send_rxon_assoc(il,
1739 &il->contexts[IL_RXON_CTX_BSS]); 1739 &il->ctx);
1740 if (rc) { 1740 if (rc) {
1741 IL_ERR("Error setting RXON_ASSOC " 1741 IL_ERR("Error setting RXON_ASSOC "
1742 "configuration (%d).\n", rc); 1742 "configuration (%d).\n", rc);
@@ -1756,7 +1756,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
1756 * an RXON_ASSOC and the new config wants the associated mask enabled, 1756 * an RXON_ASSOC and the new config wants the associated mask enabled,
1757 * we must clear the associated from the active configuration 1757 * we must clear the associated from the active configuration
1758 * before we apply the new config */ 1758 * before we apply the new config */
1759 if (il_is_associated(il, IL_RXON_CTX_BSS) && new_assoc) { 1759 if (il_is_associated(il) && new_assoc) {
1760 D_INFO("Toggling associated bit on current RXON\n"); 1760 D_INFO("Toggling associated bit on current RXON\n");
1761 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 1761 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
1762 1762
@@ -1768,7 +1768,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
1768 active_rxon->reserved5 = 0; 1768 active_rxon->reserved5 = 0;
1769 rc = il_send_cmd_pdu(il, REPLY_RXON, 1769 rc = il_send_cmd_pdu(il, REPLY_RXON,
1770 sizeof(struct il3945_rxon_cmd), 1770 sizeof(struct il3945_rxon_cmd),
1771 &il->contexts[IL_RXON_CTX_BSS].active); 1771 &il->ctx.active);
1772 1772
1773 /* If the mask clearing failed then we set 1773 /* If the mask clearing failed then we set
1774 * active_rxon back to what it was previously */ 1774 * active_rxon back to what it was previously */
@@ -1779,9 +1779,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
1779 return rc; 1779 return rc;
1780 } 1780 }
1781 il_clear_ucode_stations(il, 1781 il_clear_ucode_stations(il,
1782 &il->contexts[IL_RXON_CTX_BSS]); 1782 &il->ctx);
1783 il_restore_stations(il, 1783 il_restore_stations(il,
1784 &il->contexts[IL_RXON_CTX_BSS]); 1784 &il->ctx);
1785 } 1785 }
1786 1786
1787 D_INFO("Sending RXON\n" 1787 D_INFO("Sending RXON\n"
@@ -1814,9 +1814,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
1814 1814
1815 if (!new_assoc) { 1815 if (!new_assoc) {
1816 il_clear_ucode_stations(il, 1816 il_clear_ucode_stations(il,
1817 &il->contexts[IL_RXON_CTX_BSS]); 1817 &il->ctx);
1818 il_restore_stations(il, 1818 il_restore_stations(il,
1819 &il->contexts[IL_RXON_CTX_BSS]); 1819 &il->ctx);
1820 } 1820 }
1821 1821
1822 /* If we issue a new RXON command which required a tune then we must 1822 /* If we issue a new RXON command which required a tune then we must
@@ -2252,7 +2252,7 @@ static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd,
2252static int il3945_add_bssid_station(struct il_priv *il, 2252static int il3945_add_bssid_station(struct il_priv *il,
2253 const u8 *addr, u8 *sta_id_r) 2253 const u8 *addr, u8 *sta_id_r)
2254{ 2254{
2255 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2255 struct il_rxon_context *ctx = &il->ctx;
2256 int ret; 2256 int ret;
2257 u8 sta_id; 2257 u8 sta_id;
2258 unsigned long flags; 2258 unsigned long flags;
@@ -2346,7 +2346,7 @@ int il3945_init_hw_rate_table(struct il_priv *il)
2346 * 1M CCK rates */ 2346 * 1M CCK rates */
2347 2347
2348 if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && 2348 if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) &&
2349 il_is_associated(il, IL_RXON_CTX_BSS)) { 2349 il_is_associated(il)) {
2350 2350
2351 index = IL_FIRST_CCK_RATE; 2351 index = IL_FIRST_CCK_RATE;
2352 for (i = IL_RATE_6M_INDEX_TABLE; 2352 for (i = IL_RATE_6M_INDEX_TABLE;
@@ -2401,7 +2401,7 @@ int il3945_hw_set_hw_params(struct il_priv *il)
2401 il->hw_params.max_rxq_size = RX_QUEUE_SIZE; 2401 il->hw_params.max_rxq_size = RX_QUEUE_SIZE;
2402 il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; 2402 il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
2403 il->hw_params.max_stations = IL3945_STATION_COUNT; 2403 il->hw_params.max_stations = IL3945_STATION_COUNT;
2404 il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL3945_BROADCAST_ID; 2404 il->ctx.bcast_sta_id = IL3945_BROADCAST_ID;
2405 2405
2406 il->sta_key_max_num = STA_KEY_MAX_NUM; 2406 il->sta_key_max_num = STA_KEY_MAX_NUM;
2407 2407
@@ -2422,7 +2422,7 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il,
2422 memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); 2422 memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd));
2423 2423
2424 tx_beacon_cmd->tx.sta_id = 2424 tx_beacon_cmd->tx.sta_id =
2425 il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; 2425 il->ctx.bcast_sta_id;
2426 tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 2426 tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
2427 2427
2428 frame_size = il3945_fill_beacon_frame(il, 2428 frame_size = il3945_fill_beacon_frame(il,
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
index c055a153f7df..4c2b491b4c27 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
@@ -820,7 +820,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp)
820 unsigned long flags; 820 unsigned long flags;
821 struct statistics_rx_non_phy *rx_info; 821 struct statistics_rx_non_phy *rx_info;
822 822
823 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 823 struct il_rxon_context *ctx = &il->ctx;
824 824
825 if (il->disable_chain_noise_cal) 825 if (il->disable_chain_noise_cal)
826 return; 826 return;
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
index da4ea244ca21..1182bc0f54b7 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
@@ -782,7 +782,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
782 .flags = CMD_SIZE_HUGE, 782 .flags = CMD_SIZE_HUGE,
783 }; 783 };
784 struct il_scan_cmd *scan; 784 struct il_scan_cmd *scan;
785 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 785 struct il_rxon_context *ctx = &il->ctx;
786 u32 rate_flags = 0; 786 u32 rate_flags = 0;
787 u16 cmd_len; 787 u16 cmd_len;
788 u16 rx_chain = 0; 788 u16 rx_chain = 0;
@@ -866,7 +866,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
866 case IEEE80211_BAND_2GHZ: 866 case IEEE80211_BAND_2GHZ:
867 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; 867 scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
868 chan_mod = le32_to_cpu( 868 chan_mod = le32_to_cpu(
869 il->contexts[IL_RXON_CTX_BSS].active.flags & 869 il->ctx.active.flags &
870 RXON_FLG_CHANNEL_MODE_MSK) 870 RXON_FLG_CHANNEL_MODE_MSK)
871 >> RXON_FLG_CHANNEL_MODE_POS; 871 >> RXON_FLG_CHANNEL_MODE_POS;
872 if (chan_mod == CHANNEL_MODE_PURE_40) { 872 if (chan_mod == CHANNEL_MODE_PURE_40) {
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
index cbc6febd6582..94d77e2003ae 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
@@ -277,7 +277,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
277 struct il_device_cmd *out_cmd; 277 struct il_device_cmd *out_cmd;
278 struct il_cmd_meta *out_meta; 278 struct il_cmd_meta *out_meta;
279 struct il_tx_cmd *tx_cmd; 279 struct il_tx_cmd *tx_cmd;
280 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 280 struct il_rxon_context *ctx = &il->ctx;
281 int txq_id; 281 int txq_id;
282 dma_addr_t phys_addr; 282 dma_addr_t phys_addr;
283 dma_addr_t txcmd_phys; 283 dma_addr_t txcmd_phys;
@@ -1041,7 +1041,7 @@ int il4965_txq_check_empty(struct il_priv *il,
1041 struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; 1041 struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid];
1042 struct il_rxon_context *ctx; 1042 struct il_rxon_context *ctx;
1043 1043
1044 ctx = &il->contexts[il->stations[sta_id].ctxid]; 1044 ctx = &il->ctx;
1045 1045
1046 lockdep_assert_held(&il->sta_lock); 1046 lockdep_assert_held(&il->sta_lock);
1047 1047
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c
index 4917b0de92db..457aa4077120 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965.c
@@ -403,7 +403,7 @@ static int il4965_hw_set_hw_params(struct il_priv *il)
403 sizeof(struct il4965_scd_bc_tbl); 403 sizeof(struct il4965_scd_bc_tbl);
404 il->hw_params.tfd_size = sizeof(struct il_tfd); 404 il->hw_params.tfd_size = sizeof(struct il_tfd);
405 il->hw_params.max_stations = IL4965_STATION_COUNT; 405 il->hw_params.max_stations = IL4965_STATION_COUNT;
406 il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL4965_BROADCAST_ID; 406 il->ctx.bcast_sta_id = IL4965_BROADCAST_ID;
407 il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; 407 il->hw_params.max_data_size = IL49_RTC_DATA_SIZE;
408 il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; 408 il->hw_params.max_inst_size = IL49_RTC_INST_SIZE;
409 il->hw_params.max_bsm_size = BSM_SRAM_SIZE; 409 il->hw_params.max_bsm_size = BSM_SRAM_SIZE;
@@ -1121,7 +1121,7 @@ static int il4965_send_tx_power(struct il_priv *il)
1121 u8 band = 0; 1121 u8 band = 0;
1122 bool is_ht40 = false; 1122 bool is_ht40 = false;
1123 u8 ctrl_chan_high = 0; 1123 u8 ctrl_chan_high = 0;
1124 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 1124 struct il_rxon_context *ctx = &il->ctx;
1125 1125
1126 if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), 1126 if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status),
1127 "TX Power requested while scanning!\n")) 1127 "TX Power requested while scanning!\n"))
@@ -1333,7 +1333,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
1333static int il4965_hw_channel_switch(struct il_priv *il, 1333static int il4965_hw_channel_switch(struct il_priv *il,
1334 struct ieee80211_channel_switch *ch_switch) 1334 struct ieee80211_channel_switch *ch_switch)
1335{ 1335{
1336 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 1336 struct il_rxon_context *ctx = &il->ctx;
1337 int rc; 1337 int rc;
1338 u8 band = 0; 1338 u8 band = 0;
1339 bool is_ht40 = false; 1339 bool is_ht40 = false;
@@ -1726,7 +1726,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr)
1726 start = IL_STA_ID; 1726 start = IL_STA_ID;
1727 1727
1728 if (is_broadcast_ether_addr(addr)) 1728 if (is_broadcast_ether_addr(addr))
1729 return il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; 1729 return il->ctx.bcast_sta_id;
1730 1730
1731 spin_lock_irqsave(&il->sta_lock, flags); 1731 spin_lock_irqsave(&il->sta_lock, flags);
1732 for (i = start; i < il->hw_params.max_stations; i++) 1732 for (i = start; i < il->hw_params.max_stations; i++)
@@ -1911,7 +1911,7 @@ static struct il_hcmd_ops il4965_hcmd = {
1911 1911
1912static void il4965_post_scan(struct il_priv *il) 1912static void il4965_post_scan(struct il_priv *il)
1913{ 1913{
1914 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 1914 struct il_rxon_context *ctx = &il->ctx;
1915 1915
1916 /* 1916 /*
1917 * Since setting the RXON may have been deferred while 1917 * Since setting the RXON may have been deferred while
@@ -1923,7 +1923,7 @@ static void il4965_post_scan(struct il_priv *il)
1923 1923
1924static void il4965_post_associate(struct il_priv *il) 1924static void il4965_post_associate(struct il_priv *il)
1925{ 1925{
1926 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 1926 struct il_rxon_context *ctx = &il->ctx;
1927 struct ieee80211_vif *vif = ctx->vif; 1927 struct ieee80211_vif *vif = ctx->vif;
1928 struct ieee80211_conf *conf = NULL; 1928 struct ieee80211_conf *conf = NULL;
1929 int ret = 0; 1929 int ret = 0;
@@ -2000,7 +2000,7 @@ static void il4965_post_associate(struct il_priv *il)
2000 2000
2001static void il4965_config_ap(struct il_priv *il) 2001static void il4965_config_ap(struct il_priv *il)
2002{ 2002{
2003 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2003 struct il_rxon_context *ctx = &il->ctx;
2004 struct ieee80211_vif *vif = ctx->vif; 2004 struct ieee80211_vif *vif = ctx->vif;
2005 int ret = 0; 2005 int ret = 0;
2006 2006
diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c
index e9ca265a4bb6..7afdd802b33f 100644
--- a/drivers/net/wireless/iwlegacy/iwl-core.c
+++ b/drivers/net/wireless/iwlegacy/iwl-core.c
@@ -853,7 +853,7 @@ EXPORT_SYMBOL(il_set_rate);
853 853
854void il_chswitch_done(struct il_priv *il, bool is_success) 854void il_chswitch_done(struct il_priv *il, bool is_success)
855{ 855{
856 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 856 struct il_rxon_context *ctx = &il->ctx;
857 857
858 if (test_bit(STATUS_EXIT_PENDING, &il->status)) 858 if (test_bit(STATUS_EXIT_PENDING, &il->status))
859 return; 859 return;
@@ -868,7 +868,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb)
868 struct il_rx_pkt *pkt = rxb_addr(rxb); 868 struct il_rx_pkt *pkt = rxb_addr(rxb);
869 struct il_csa_notification *csa = &(pkt->u.csa_notif); 869 struct il_csa_notification *csa = &(pkt->u.csa_notif);
870 870
871 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 871 struct il_rxon_context *ctx = &il->ctx;
872 struct il_rxon_cmd *rxon = (void *)&ctx->active; 872 struct il_rxon_cmd *rxon = (void *)&ctx->active;
873 873
874 if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) 874 if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status))
@@ -933,7 +933,7 @@ void il_irq_handle_error(struct il_priv *il)
933#ifdef CONFIG_IWLEGACY_DEBUG 933#ifdef CONFIG_IWLEGACY_DEBUG
934 if (il_get_debug_level(il) & IL_DL_FW_ERRORS) 934 if (il_get_debug_level(il) & IL_DL_FW_ERRORS)
935 il_print_rx_config_cmd(il, 935 il_print_rx_config_cmd(il,
936 &il->contexts[IL_RXON_CTX_BSS]); 936 &il->ctx);
937#endif 937#endif
938 938
939 wake_up(&il->wait_command_queue); 939 wake_up(&il->wait_command_queue);
@@ -1110,7 +1110,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force)
1110 int ret; 1110 int ret;
1111 s8 prev_tx_power; 1111 s8 prev_tx_power;
1112 bool defer; 1112 bool defer;
1113 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 1113 struct il_rxon_context *ctx = &il->ctx;
1114 1114
1115 lockdep_assert_held(&il->mutex); 1115 lockdep_assert_held(&il->mutex);
1116 1116
@@ -2069,7 +2069,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed)
2069 int ret = 0; 2069 int ret = 0;
2070 u16 ch; 2070 u16 ch;
2071 int scan_active = 0; 2071 int scan_active = 0;
2072 bool ht_changed[NUM_IL_RXON_CTX] = {}; 2072 bool ht_changed = false;
2073 2073
2074 if (WARN_ON(!il->cfg->ops->legacy)) 2074 if (WARN_ON(!il->cfg->ops->legacy))
2075 return -EOPNOTSUPP; 2075 return -EOPNOTSUPP;
@@ -2129,7 +2129,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed)
2129 /* Configure HT40 channels */ 2129 /* Configure HT40 channels */
2130 if (ctx->ht.enabled != conf_is_ht(conf)) { 2130 if (ctx->ht.enabled != conf_is_ht(conf)) {
2131 ctx->ht.enabled = conf_is_ht(conf); 2131 ctx->ht.enabled = conf_is_ht(conf);
2132 ht_changed[ctx->ctxid] = true; 2132 ht_changed = true;
2133 } 2133 }
2134 if (ctx->ht.enabled) { 2134 if (ctx->ht.enabled) {
2135 if (conf_is_ht40_minus(conf)) { 2135 if (conf_is_ht40_minus(conf)) {
@@ -2209,7 +2209,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed)
2209 else 2209 else
2210 D_INFO( 2210 D_INFO(
2211 "Not re-sending same RXON configuration.\n"); 2211 "Not re-sending same RXON configuration.\n");
2212 if (ht_changed[ctx->ctxid]) 2212 if (ht_changed)
2213 il_update_qos(il, ctx); 2213 il_update_qos(il, ctx);
2214 } 2214 }
2215 2215
@@ -2225,8 +2225,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw,
2225{ 2225{
2226 struct il_priv *il = hw->priv; 2226 struct il_priv *il = hw->priv;
2227 unsigned long flags; 2227 unsigned long flags;
2228 /* IBSS can only be the IL_RXON_CTX_BSS context */ 2228 struct il_rxon_context *ctx = &il->ctx;
2229 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
2230 2229
2231 if (WARN_ON(!il->cfg->ops->legacy)) 2230 if (WARN_ON(!il->cfg->ops->legacy))
2232 return; 2231 return;
diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c
index 736b00bc7bfb..a4b1f37f48e5 100644
--- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c
@@ -601,7 +601,7 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf,
601 struct il_priv *il = file->private_data; 601 struct il_priv *il = file->private_data;
602 struct il_rxon_context *ctx; 602 struct il_rxon_context *ctx;
603 int pos = 0, i; 603 int pos = 0, i;
604 char buf[256 * NUM_IL_RXON_CTX]; 604 char buf[256];
605 const size_t bufsz = sizeof(buf); 605 const size_t bufsz = sizeof(buf);
606 606
607 for_each_context(il, ctx) { 607 for_each_context(il, ctx) {
@@ -1064,7 +1064,7 @@ static ssize_t il_dbgfs_rxon_flags_read(struct file *file,
1064 char buf[20]; 1064 char buf[20];
1065 1065
1066 len = sprintf(buf, "0x%04X\n", 1066 len = sprintf(buf, "0x%04X\n",
1067 le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.flags)); 1067 le32_to_cpu(il->ctx.active.flags));
1068 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1068 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1069} 1069}
1070 1070
@@ -1077,7 +1077,7 @@ static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file,
1077 char buf[20]; 1077 char buf[20];
1078 1078
1079 len = sprintf(buf, "0x%04X\n", 1079 len = sprintf(buf, "0x%04X\n",
1080 le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.filter_flags)); 1080 le32_to_cpu(il->ctx.active.filter_flags));
1081 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1081 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1082} 1082}
1083 1083
diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h
index 4c7ccd589a1f..d15dcbd40086 100644
--- a/drivers/net/wireless/iwlegacy/iwl-dev.h
+++ b/drivers/net/wireless/iwlegacy/iwl-dev.h
@@ -899,12 +899,6 @@ struct il_force_reset {
899 */ 899 */
900#define IL4965_EXT_BEACON_TIME_POS 22 900#define IL4965_EXT_BEACON_TIME_POS 22
901 901
902enum il_rxon_context_id {
903 IL_RXON_CTX_BSS,
904
905 NUM_IL_RXON_CTX
906};
907
908struct il_rxon_context { 902struct il_rxon_context {
909 struct ieee80211_vif *vif; 903 struct ieee80211_vif *vif;
910 904
@@ -921,7 +915,7 @@ struct il_rxon_context {
921 915
922 bool ht_need_multiple_chains; 916 bool ht_need_multiple_chains;
923 917
924 enum il_rxon_context_id ctxid; 918 int ctxid;
925 919
926 u32 interface_modes, exclusive_interface_modes; 920 u32 interface_modes, exclusive_interface_modes;
927 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; 921 u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
@@ -1029,9 +1023,6 @@ struct il_priv {
1029 u32 hw_wa_rev; 1023 u32 hw_wa_rev;
1030 u8 rev_id; 1024 u8 rev_id;
1031 1025
1032 /* microcode/device supports multiple contexts */
1033 u8 valid_contexts;
1034
1035 /* command queue number */ 1026 /* command queue number */
1036 u8 cmd_queue; 1027 u8 cmd_queue;
1037 1028
@@ -1055,7 +1046,7 @@ struct il_priv {
1055 u8 ucode_write_complete; /* the image write is complete */ 1046 u8 ucode_write_complete; /* the image write is complete */
1056 char firmware_name[25]; 1047 char firmware_name[25];
1057 1048
1058 struct il_rxon_context contexts[NUM_IL_RXON_CTX]; 1049 struct il_rxon_context ctx;
1059 1050
1060 __le16 switch_channel; 1051 __le16 switch_channel;
1061 1052
@@ -1298,21 +1289,17 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif)
1298 return vif_priv->ctx; 1289 return vif_priv->ctx;
1299} 1290}
1300 1291
1301#define for_each_context(il, ctx) \ 1292#define for_each_context(il, _ctx) \
1302 for (ctx = &il->contexts[IL_RXON_CTX_BSS]; \ 1293 for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++)
1303 ctx < &il->contexts[NUM_IL_RXON_CTX]; ctx++) \
1304 if (il->valid_contexts & BIT(ctx->ctxid))
1305 1294
1306static inline int il_is_associated(struct il_priv *il, 1295static inline int il_is_associated(struct il_priv *il)
1307 enum il_rxon_context_id ctxid)
1308{ 1296{
1309 return (il->contexts[ctxid].active.filter_flags & 1297 return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
1310 RXON_FILTER_ASSOC_MSK) ? 1 : 0;
1311} 1298}
1312 1299
1313static inline int il_is_any_associated(struct il_priv *il) 1300static inline int il_is_any_associated(struct il_priv *il)
1314{ 1301{
1315 return il_is_associated(il, IL_RXON_CTX_BSS); 1302 return il_is_associated(il);
1316} 1303}
1317 1304
1318static inline int il_is_associated_ctx(struct il_rxon_context *ctx) 1305static inline int il_is_associated_ctx(struct il_rxon_context *ctx)
diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c
index 746b5a7e4e07..2e7c87f6104f 100644
--- a/drivers/net/wireless/iwlegacy/iwl-rx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-rx.c
@@ -241,7 +241,7 @@ int il_set_decrypted_flag(struct il_priv *il,
241 * All contexts have the same setting here due to it being 241 * All contexts have the same setting here due to it being
242 * a module parameter, so OK to check any context. 242 * a module parameter, so OK to check any context.
243 */ 243 */
244 if (il->contexts[IL_RXON_CTX_BSS].active.filter_flags & 244 if (il->ctx.active.filter_flags &
245 RXON_FILTER_DIS_DECRYPT_MSK) 245 RXON_FILTER_DIS_DECRYPT_MSK)
246 return 0; 246 return 0;
247 247
diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
index 216c86fb0929..dd8ce29ce84b 100644
--- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
@@ -144,7 +144,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il,
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 == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) 147 if (sta_id == il->ctx.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;
@@ -318,7 +318,7 @@ unsigned int il3945_fill_beacon_frame(struct il_priv *il,
318 int left) 318 int left)
319{ 319{
320 320
321 if (!il_is_associated(il, IL_RXON_CTX_BSS) || !il->beacon_skb) 321 if (!il_is_associated(il) || !il->beacon_skb)
322 return 0; 322 return 0;
323 323
324 if (il->beacon_skb->len > left) 324 if (il->beacon_skb->len > left)
@@ -345,7 +345,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il)
345 } 345 }
346 346
347 rate = il_get_lowest_plcp(il, 347 rate = il_get_lowest_plcp(il,
348 &il->contexts[IL_RXON_CTX_BSS]); 348 &il->ctx);
349 349
350 frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); 350 frame_size = il3945_hw_get_beacon_cmd(il, frame, rate);
351 351
@@ -515,7 +515,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
515 515
516 /* Find index into station table for destination station */ 516 /* Find index into station table for destination station */
517 sta_id = il_sta_id_or_broadcast( 517 sta_id = il_sta_id_or_broadcast(
518 il, &il->contexts[IL_RXON_CTX_BSS], 518 il, &il->ctx,
519 info->control.sta); 519 info->control.sta);
520 if (sta_id == IL_INVALID_STATION) { 520 if (sta_id == IL_INVALID_STATION) {
521 D_DROP("Dropping - INVALID STATION: %pM\n", 521 D_DROP("Dropping - INVALID STATION: %pM\n",
@@ -546,7 +546,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
546 /* Set up driver data for this TFD */ 546 /* Set up driver data for this TFD */
547 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); 547 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info));
548 txq->txb[q->write_ptr].skb = skb; 548 txq->txb[q->write_ptr].skb = skb;
549 txq->txb[q->write_ptr].ctx = &il->contexts[IL_RXON_CTX_BSS]; 549 txq->txb[q->write_ptr].ctx = &il->ctx;
550 550
551 /* Init first empty entry in queue's array of Tx/cmd buffers */ 551 /* Init first empty entry in queue's array of Tx/cmd buffers */
552 out_cmd = txq->cmd[idx]; 552 out_cmd = txq->cmd[idx];
@@ -681,9 +681,9 @@ static int il3945_get_measurement(struct il_priv *il,
681 int rc; 681 int rc;
682 int spectrum_resp_status; 682 int spectrum_resp_status;
683 int duration = le16_to_cpu(params->duration); 683 int duration = le16_to_cpu(params->duration);
684 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 684 struct il_rxon_context *ctx = &il->ctx;
685 685
686 if (il_is_associated(il, IL_RXON_CTX_BSS)) 686 if (il_is_associated(il))
687 add_time = il_usecs_to_beacons(il, 687 add_time = il_usecs_to_beacons(il,
688 le64_to_cpu(params->start_time) - il->_3945.last_tsf, 688 le64_to_cpu(params->start_time) - il->_3945.last_tsf,
689 le16_to_cpu(ctx->timing.beacon_interval)); 689 le16_to_cpu(ctx->timing.beacon_interval));
@@ -697,7 +697,7 @@ static int il3945_get_measurement(struct il_priv *il,
697 cmd.len = sizeof(spectrum); 697 cmd.len = sizeof(spectrum);
698 spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); 698 spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len));
699 699
700 if (il_is_associated(il, IL_RXON_CTX_BSS)) 700 if (il_is_associated(il))
701 spectrum.start_time = 701 spectrum.start_time =
702 il_add_beacon_time(il, 702 il_add_beacon_time(il,
703 il->_3945.last_beacon_time, add_time, 703 il->_3945.last_beacon_time, add_time,
@@ -2189,7 +2189,7 @@ static void il3945_alive_start(struct il_priv *il)
2189{ 2189{
2190 int thermal_spin = 0; 2190 int thermal_spin = 0;
2191 u32 rfkill; 2191 u32 rfkill;
2192 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2192 struct il_rxon_context *ctx = &il->ctx;
2193 2193
2194 D_INFO("Runtime Alive received.\n"); 2194 D_INFO("Runtime Alive received.\n");
2195 2195
@@ -2243,7 +2243,7 @@ static void il3945_alive_start(struct il_priv *il)
2243 2243
2244 il_power_update_mode(il, true); 2244 il_power_update_mode(il, true);
2245 2245
2246 if (il_is_associated(il, IL_RXON_CTX_BSS)) { 2246 if (il_is_associated(il)) {
2247 struct il3945_rxon_cmd *active_rxon = 2247 struct il3945_rxon_cmd *active_rxon =
2248 (struct il3945_rxon_cmd *)(&ctx->active); 2248 (struct il3945_rxon_cmd *)(&ctx->active);
2249 2249
@@ -2372,7 +2372,7 @@ static void il3945_down(struct il_priv *il)
2372 2372
2373static int il3945_alloc_bcast_station(struct il_priv *il) 2373static int il3945_alloc_bcast_station(struct il_priv *il)
2374{ 2374{
2375 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2375 struct il_rxon_context *ctx = &il->ctx;
2376 unsigned long flags; 2376 unsigned long flags;
2377 u8 sta_id; 2377 u8 sta_id;
2378 2378
@@ -2581,7 +2581,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
2581 scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; 2581 scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH;
2582 scan->quiet_time = IL_ACTIVE_QUIET_TIME; 2582 scan->quiet_time = IL_ACTIVE_QUIET_TIME;
2583 2583
2584 if (il_is_associated(il, IL_RXON_CTX_BSS)) { 2584 if (il_is_associated(il)) {
2585 u16 interval; 2585 u16 interval;
2586 u32 extra; 2586 u32 extra;
2587 u32 suspend_time = 100; 2587 u32 suspend_time = 100;
@@ -2634,7 +2634,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
2634 /* We don't build a direct scan probe request; the uCode will do 2634 /* We don't build a direct scan probe request; the uCode will do
2635 * that based on the direct_mask added to each channel entry */ 2635 * that based on the direct_mask added to each channel entry */
2636 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 2636 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
2637 scan->tx_cmd.sta_id = il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; 2637 scan->tx_cmd.sta_id = il->ctx.bcast_sta_id;
2638 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; 2638 scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
2639 2639
2640 /* flags + rate selection */ 2640 /* flags + rate selection */
@@ -2692,7 +2692,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
2692 2692
2693void il3945_post_scan(struct il_priv *il) 2693void il3945_post_scan(struct il_priv *il)
2694{ 2694{
2695 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2695 struct il_rxon_context *ctx = &il->ctx;
2696 2696
2697 /* 2697 /*
2698 * Since setting the RXON may have been deferred while 2698 * Since setting the RXON may have been deferred while
@@ -2750,7 +2750,7 @@ void il3945_post_associate(struct il_priv *il)
2750{ 2750{
2751 int rc = 0; 2751 int rc = 0;
2752 struct ieee80211_conf *conf = NULL; 2752 struct ieee80211_conf *conf = NULL;
2753 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2753 struct il_rxon_context *ctx = &il->ctx;
2754 2754
2755 if (!ctx->vif || !il->is_open) 2755 if (!ctx->vif || !il->is_open)
2756 return; 2756 return;
@@ -2917,7 +2917,7 @@ static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2917 2917
2918void il3945_config_ap(struct il_priv *il) 2918void il3945_config_ap(struct il_priv *il)
2919{ 2919{
2920 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2920 struct il_rxon_context *ctx = &il->ctx;
2921 struct ieee80211_vif *vif = ctx->vif; 2921 struct ieee80211_vif *vif = ctx->vif;
2922 int rc = 0; 2922 int rc = 0;
2923 2923
@@ -2925,7 +2925,7 @@ void il3945_config_ap(struct il_priv *il)
2925 return; 2925 return;
2926 2926
2927 /* The following should be done only at AP bring up */ 2927 /* The following should be done only at AP bring up */
2928 if (!(il_is_associated(il, IL_RXON_CTX_BSS))) { 2928 if (!(il_is_associated(il))) {
2929 2929
2930 /* RXON - unassoc (to set timing command) */ 2930 /* RXON - unassoc (to set timing command) */
2931 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2931 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
@@ -2986,11 +2986,11 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2986 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) 2986 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
2987 return -EOPNOTSUPP; 2987 return -EOPNOTSUPP;
2988 2988
2989 static_key = !il_is_associated(il, IL_RXON_CTX_BSS); 2989 static_key = !il_is_associated(il);
2990 2990
2991 if (!static_key) { 2991 if (!static_key) {
2992 sta_id = il_sta_id_or_broadcast( 2992 sta_id = il_sta_id_or_broadcast(
2993 il, &il->contexts[IL_RXON_CTX_BSS], sta); 2993 il, &il->ctx, sta);
2994 if (sta_id == IL_INVALID_STATION) 2994 if (sta_id == IL_INVALID_STATION)
2995 return -EINVAL; 2995 return -EINVAL;
2996 } 2996 }
@@ -3042,7 +3042,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw,
3042 3042
3043 3043
3044 ret = il_add_station_common(il, 3044 ret = il_add_station_common(il,
3045 &il->contexts[IL_RXON_CTX_BSS], 3045 &il->ctx,
3046 sta->addr, is_ap, sta, &sta_id); 3046 sta->addr, is_ap, sta, &sta_id);
3047 if (ret) { 3047 if (ret) {
3048 IL_ERR("Unable to add station %pM (%d)\n", 3048 IL_ERR("Unable to add station %pM (%d)\n",
@@ -3070,7 +3070,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw,
3070{ 3070{
3071 struct il_priv *il = hw->priv; 3071 struct il_priv *il = hw->priv;
3072 __le32 filter_or = 0, filter_nand = 0; 3072 __le32 filter_or = 0, filter_nand = 0;
3073 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 3073 struct il_rxon_context *ctx = &il->ctx;
3074 3074
3075#define CHK(test, flag) do { \ 3075#define CHK(test, flag) do { \
3076 if (*total_flags & (test)) \ 3076 if (*total_flags & (test)) \
@@ -3205,7 +3205,7 @@ static ssize_t il3945_show_flags(struct device *d,
3205 struct device_attribute *attr, char *buf) 3205 struct device_attribute *attr, char *buf)
3206{ 3206{
3207 struct il_priv *il = dev_get_drvdata(d); 3207 struct il_priv *il = dev_get_drvdata(d);
3208 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 3208 struct il_rxon_context *ctx = &il->ctx;
3209 3209
3210 return sprintf(buf, "0x%04X\n", ctx->active.flags); 3210 return sprintf(buf, "0x%04X\n", ctx->active.flags);
3211} 3211}
@@ -3216,7 +3216,7 @@ static ssize_t il3945_store_flags(struct device *d,
3216{ 3216{
3217 struct il_priv *il = dev_get_drvdata(d); 3217 struct il_priv *il = dev_get_drvdata(d);
3218 u32 flags = simple_strtoul(buf, NULL, 0); 3218 u32 flags = simple_strtoul(buf, NULL, 0);
3219 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 3219 struct il_rxon_context *ctx = &il->ctx;
3220 3220
3221 mutex_lock(&il->mutex); 3221 mutex_lock(&il->mutex);
3222 if (le32_to_cpu(ctx->staging.flags) != flags) { 3222 if (le32_to_cpu(ctx->staging.flags) != flags) {
@@ -3241,7 +3241,7 @@ static ssize_t il3945_show_filter_flags(struct device *d,
3241 struct device_attribute *attr, char *buf) 3241 struct device_attribute *attr, char *buf)
3242{ 3242{
3243 struct il_priv *il = dev_get_drvdata(d); 3243 struct il_priv *il = dev_get_drvdata(d);
3244 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 3244 struct il_rxon_context *ctx = &il->ctx;
3245 3245
3246 return sprintf(buf, "0x%04X\n", 3246 return sprintf(buf, "0x%04X\n",
3247 le32_to_cpu(ctx->active.filter_flags)); 3247 le32_to_cpu(ctx->active.filter_flags));
@@ -3252,7 +3252,7 @@ static ssize_t il3945_store_filter_flags(struct device *d,
3252 const char *buf, size_t count) 3252 const char *buf, size_t count)
3253{ 3253{
3254 struct il_priv *il = dev_get_drvdata(d); 3254 struct il_priv *il = dev_get_drvdata(d);
3255 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 3255 struct il_rxon_context *ctx = &il->ctx;
3256 u32 filter_flags = simple_strtoul(buf, NULL, 0); 3256 u32 filter_flags = simple_strtoul(buf, NULL, 0);
3257 3257
3258 mutex_lock(&il->mutex); 3258 mutex_lock(&il->mutex);
@@ -3313,7 +3313,7 @@ static ssize_t il3945_store_measurement(struct device *d,
3313 const char *buf, size_t count) 3313 const char *buf, size_t count)
3314{ 3314{
3315 struct il_priv *il = dev_get_drvdata(d); 3315 struct il_priv *il = dev_get_drvdata(d);
3316 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 3316 struct il_rxon_context *ctx = &il->ctx;
3317 struct ieee80211_measurement_params params = { 3317 struct ieee80211_measurement_params params = {
3318 .channel = le16_to_cpu(ctx->active.channel), 3318 .channel = le16_to_cpu(ctx->active.channel),
3319 .start_time = cpu_to_le64(il->_3945.last_tsf), 3319 .start_time = cpu_to_le64(il->_3945.last_tsf),
@@ -3599,7 +3599,7 @@ static int il3945_setup_mac(struct il_priv *il)
3599 IEEE80211_HW_SPECTRUM_MGMT; 3599 IEEE80211_HW_SPECTRUM_MGMT;
3600 3600
3601 hw->wiphy->interface_modes = 3601 hw->wiphy->interface_modes =
3602 il->contexts[IL_RXON_CTX_BSS].interface_modes; 3602 il->ctx.interface_modes;
3603 3603
3604 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | 3604 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
3605 WIPHY_FLAG_DISABLE_BEACON_HINTS | 3605 WIPHY_FLAG_DISABLE_BEACON_HINTS |
@@ -3634,7 +3634,7 @@ static int il3945_setup_mac(struct il_priv *il)
3634 3634
3635static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 3635static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3636{ 3636{
3637 int err = 0, i; 3637 int err = 0;
3638 struct il_priv *il; 3638 struct il_priv *il;
3639 struct ieee80211_hw *hw; 3639 struct ieee80211_hw *hw;
3640 struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); 3640 struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data);
@@ -3658,24 +3658,20 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en
3658 3658
3659 il->cmd_queue = IL39_CMD_QUEUE_NUM; 3659 il->cmd_queue = IL39_CMD_QUEUE_NUM;
3660 3660
3661 /* 3945 has only one valid context */ 3661 il->ctx.ctxid = 0;
3662 il->valid_contexts = BIT(IL_RXON_CTX_BSS);
3663 3662
3664 for (i = 0; i < NUM_IL_RXON_CTX; i++) 3663 il->ctx.rxon_cmd = REPLY_RXON;
3665 il->contexts[i].ctxid = i; 3664 il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING;
3666 3665 il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC;
3667 il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; 3666 il->ctx.qos_cmd = REPLY_QOS_PARAM;
3668 il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; 3667 il->ctx.ap_sta_id = IL_AP_ID;
3669 il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; 3668 il->ctx.wep_key_cmd = REPLY_WEPKEY;
3670 il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; 3669 il->ctx.interface_modes =
3671 il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID;
3672 il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
3673 il->contexts[IL_RXON_CTX_BSS].interface_modes =
3674 BIT(NL80211_IFTYPE_STATION) | 3670 BIT(NL80211_IFTYPE_STATION) |
3675 BIT(NL80211_IFTYPE_ADHOC); 3671 BIT(NL80211_IFTYPE_ADHOC);
3676 il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; 3672 il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS;
3677 il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; 3673 il->ctx.station_devtype = RXON_DEV_TYPE_ESS;
3678 il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; 3674 il->ctx.unused_devtype = RXON_DEV_TYPE_ESS;
3679 3675
3680 /* 3676 /*
3681 * Disabling hardware scan means that mac80211 will perform scans 3677 * Disabling hardware scan means that mac80211 will perform scans
@@ -3812,7 +3808,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en
3812 3808
3813 il_set_rxon_channel(il, 3809 il_set_rxon_channel(il,
3814 &il->bands[IEEE80211_BAND_2GHZ].channels[5], 3810 &il->bands[IEEE80211_BAND_2GHZ].channels[5],
3815 &il->contexts[IL_RXON_CTX_BSS]); 3811 &il->ctx);
3816 il3945_setup_deferred_work(il); 3812 il3945_setup_deferred_work(il);
3817 il3945_setup_rx_handlers(il); 3813 il3945_setup_rx_handlers(il);
3818 il_power_initialize(il); 3814 il_power_initialize(il);
diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c
index d5f91800d32b..131d6e920195 100644
--- a/drivers/net/wireless/iwlegacy/iwl4965-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c
@@ -1717,7 +1717,7 @@ static int il4965_alive_notify(struct il_priv *il)
1717static void il4965_alive_start(struct il_priv *il) 1717static void il4965_alive_start(struct il_priv *il)
1718{ 1718{
1719 int ret = 0; 1719 int ret = 0;
1720 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 1720 struct il_rxon_context *ctx = &il->ctx;
1721 1721
1722 D_INFO("Runtime Alive received.\n"); 1722 D_INFO("Runtime Alive received.\n");
1723 1723
@@ -2502,7 +2502,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw,
2502 struct ieee80211_channel *channel = ch_switch->channel; 2502 struct ieee80211_channel *channel = ch_switch->channel;
2503 struct il_ht_config *ht_conf = &il->current_ht_config; 2503 struct il_ht_config *ht_conf = &il->current_ht_config;
2504 2504
2505 struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; 2505 struct il_rxon_context *ctx = &il->ctx;
2506 u16 ch; 2506 u16 ch;
2507 2507
2508 D_MAC80211("enter\n"); 2508 D_MAC80211("enter\n");
@@ -2786,7 +2786,7 @@ static int il4965_init_drv(struct il_priv *il)
2786 /* Choose which receivers/antennas to use */ 2786 /* Choose which receivers/antennas to use */
2787 if (il->cfg->ops->hcmd->set_rxon_chain) 2787 if (il->cfg->ops->hcmd->set_rxon_chain)
2788 il->cfg->ops->hcmd->set_rxon_chain(il, 2788 il->cfg->ops->hcmd->set_rxon_chain(il,
2789 &il->contexts[IL_RXON_CTX_BSS]); 2789 &il->ctx);
2790 2790
2791 il_init_scan_params(il); 2791 il_init_scan_params(il);
2792 2792
@@ -2859,7 +2859,7 @@ static const u8 il4965_bss_ac_to_queue[] = {
2859static int 2859static int
2860il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 2860il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2861{ 2861{
2862 int err = 0, i; 2862 int err = 0;
2863 struct il_priv *il; 2863 struct il_priv *il;
2864 struct ieee80211_hw *hw; 2864 struct ieee80211_hw *hw;
2865 struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); 2865 struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data);
@@ -2878,36 +2878,26 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2878 il = hw->priv; 2878 il = hw->priv;
2879 /* At this point both hw and il are allocated. */ 2879 /* At this point both hw and il are allocated. */
2880 2880
2881 /* 2881 il->ctx.ctxid = 0;
2882 * The default context is always valid, 2882
2883 * more may be discovered when firmware 2883 il->ctx.always_active = true;
2884 * is loaded. 2884 il->ctx.is_active = true;
2885 */ 2885 il->ctx.rxon_cmd = REPLY_RXON;
2886 il->valid_contexts = BIT(IL_RXON_CTX_BSS); 2886 il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING;
2887 2887 il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC;
2888 for (i = 0; i < NUM_IL_RXON_CTX; i++) 2888 il->ctx.qos_cmd = REPLY_QOS_PARAM;
2889 il->contexts[i].ctxid = i; 2889 il->ctx.ap_sta_id = IL_AP_ID;
2890 2890 il->ctx.wep_key_cmd = REPLY_WEPKEY;
2891 il->contexts[IL_RXON_CTX_BSS].always_active = true; 2891 il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo;
2892 il->contexts[IL_RXON_CTX_BSS].is_active = true; 2892 il->ctx.ac_to_queue = il4965_bss_ac_to_queue;
2893 il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; 2893 il->ctx.exclusive_interface_modes =
2894 il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING;
2895 il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC;
2896 il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM;
2897 il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID;
2898 il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
2899 il->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo;
2900 il->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue;
2901 il->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes =
2902 BIT(NL80211_IFTYPE_ADHOC); 2894 BIT(NL80211_IFTYPE_ADHOC);
2903 il->contexts[IL_RXON_CTX_BSS].interface_modes = 2895 il->ctx.interface_modes =
2904 BIT(NL80211_IFTYPE_STATION); 2896 BIT(NL80211_IFTYPE_STATION);
2905 il->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; 2897 il->ctx.ap_devtype = RXON_DEV_TYPE_AP;
2906 il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; 2898 il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS;
2907 il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; 2899 il->ctx.station_devtype = RXON_DEV_TYPE_ESS;
2908 il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; 2900 il->ctx.unused_devtype = RXON_DEV_TYPE_ESS;
2909
2910 BUILD_BUG_ON(NUM_IL_RXON_CTX != 1);
2911 2901
2912 SET_IEEE80211_DEV(hw, &pdev->dev); 2902 SET_IEEE80211_DEV(hw, &pdev->dev);
2913 2903