aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlegacy/common.c')
-rw-r--r--drivers/net/wireless/iwlegacy/common.c656
1 files changed, 263 insertions, 393 deletions
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index 36454d0bbeed..04ec38e5eaaf 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -512,15 +512,15 @@ il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off)
512 } 512 }
513 513
514 D_LED("Led blink time compensation=%u\n", 514 D_LED("Led blink time compensation=%u\n",
515 il->cfg->base_params->led_compensation); 515 il->cfg->led_compensation);
516 led_cmd.on = 516 led_cmd.on =
517 il_blink_compensation(il, on, 517 il_blink_compensation(il, on,
518 il->cfg->base_params->led_compensation); 518 il->cfg->led_compensation);
519 led_cmd.off = 519 led_cmd.off =
520 il_blink_compensation(il, off, 520 il_blink_compensation(il, off,
521 il->cfg->base_params->led_compensation); 521 il->cfg->led_compensation);
522 522
523 ret = il->cfg->ops->led->cmd(il, &led_cmd); 523 ret = il->ops->led->cmd(il, &led_cmd);
524 if (!ret) { 524 if (!ret) {
525 il->blink_on = on; 525 il->blink_on = on;
526 il->blink_off = off; 526 il->blink_off = off;
@@ -691,7 +691,7 @@ il_eeprom_verify_signature(struct il_priv *il)
691const u8 * 691const u8 *
692il_eeprom_query_addr(const struct il_priv *il, size_t offset) 692il_eeprom_query_addr(const struct il_priv *il, size_t offset)
693{ 693{
694 BUG_ON(offset >= il->cfg->base_params->eeprom_size); 694 BUG_ON(offset >= il->cfg->eeprom_size);
695 return &il->eeprom[offset]; 695 return &il->eeprom[offset];
696} 696}
697EXPORT_SYMBOL(il_eeprom_query_addr); 697EXPORT_SYMBOL(il_eeprom_query_addr);
@@ -722,7 +722,7 @@ il_eeprom_init(struct il_priv *il)
722 u16 addr; 722 u16 addr;
723 723
724 /* allocate eeprom */ 724 /* allocate eeprom */
725 sz = il->cfg->base_params->eeprom_size; 725 sz = il->cfg->eeprom_size;
726 D_EEPROM("NVM size = %d\n", sz); 726 D_EEPROM("NVM size = %d\n", sz);
727 il->eeprom = kzalloc(sz, GFP_KERNEL); 727 il->eeprom = kzalloc(sz, GFP_KERNEL);
728 if (!il->eeprom) { 728 if (!il->eeprom) {
@@ -731,7 +731,7 @@ il_eeprom_init(struct il_priv *il)
731 } 731 }
732 e = (__le16 *) il->eeprom; 732 e = (__le16 *) il->eeprom;
733 733
734 il->cfg->ops->lib->apm_ops.init(il); 734 il->ops->lib->apm_ops.init(il);
735 735
736 ret = il_eeprom_verify_signature(il); 736 ret = il_eeprom_verify_signature(il);
737 if (ret < 0) { 737 if (ret < 0) {
@@ -741,7 +741,7 @@ il_eeprom_init(struct il_priv *il)
741 } 741 }
742 742
743 /* Make sure driver (instead of uCode) is allowed to read EEPROM */ 743 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
744 ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); 744 ret = il->ops->lib->eeprom_ops.acquire_semaphore(il);
745 if (ret < 0) { 745 if (ret < 0) {
746 IL_ERR("Failed to acquire EEPROM semaphore.\n"); 746 IL_ERR("Failed to acquire EEPROM semaphore.\n");
747 ret = -ENOENT; 747 ret = -ENOENT;
@@ -773,7 +773,7 @@ il_eeprom_init(struct il_priv *il)
773 773
774 ret = 0; 774 ret = 0;
775done: 775done:
776 il->cfg->ops->lib->eeprom_ops.release_semaphore(il); 776 il->ops->lib->eeprom_ops.release_semaphore(il);
777 777
778err: 778err:
779 if (ret) 779 if (ret)
@@ -800,7 +800,7 @@ il_init_band_reference(const struct il_priv *il, int eep_band,
800 const u8 **eeprom_ch_idx) 800 const u8 **eeprom_ch_idx)
801{ 801{
802 u32 offset = 802 u32 offset =
803 il->cfg->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; 803 il->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1];
804 switch (eep_band) { 804 switch (eep_band) {
805 case 1: /* 2.4GHz band */ 805 case 1: /* 2.4GHz band */
806 *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); 806 *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1);
@@ -1001,9 +1001,9 @@ il_init_channel_map(struct il_priv *il)
1001 } 1001 }
1002 1002
1003 /* Check if we do have HT40 channels */ 1003 /* Check if we do have HT40 channels */
1004 if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == 1004 if (il->ops->lib->eeprom_ops.regulatory_bands[5] ==
1005 EEPROM_REGULATORY_BAND_NO_HT40 && 1005 EEPROM_REGULATORY_BAND_NO_HT40 &&
1006 il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == 1006 il->ops->lib->eeprom_ops.regulatory_bands[6] ==
1007 EEPROM_REGULATORY_BAND_NO_HT40) 1007 EEPROM_REGULATORY_BAND_NO_HT40)
1008 return 0; 1008 return 0;
1009 1009
@@ -1158,9 +1158,9 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force)
1158 if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) 1158 if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK))
1159 clear_bit(S_POWER_PMI, &il->status); 1159 clear_bit(S_POWER_PMI, &il->status);
1160 1160
1161 if (il->cfg->ops->lib->update_chain_flags && update_chains) 1161 if (il->ops->lib->update_chain_flags && update_chains)
1162 il->cfg->ops->lib->update_chain_flags(il); 1162 il->ops->lib->update_chain_flags(il);
1163 else if (il->cfg->ops->lib->update_chain_flags) 1163 else if (il->ops->lib->update_chain_flags)
1164 D_POWER("Cannot update the power, chain noise " 1164 D_POWER("Cannot update the power, chain noise "
1165 "calibration running: %d\n", 1165 "calibration running: %d\n",
1166 il->chain_noise_data.state); 1166 il->chain_noise_data.state);
@@ -1442,7 +1442,6 @@ u16
1442il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, 1442il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band,
1443 struct ieee80211_vif *vif) 1443 struct ieee80211_vif *vif)
1444{ 1444{
1445 struct il_rxon_context *ctx = &il->ctx;
1446 u16 value; 1445 u16 value;
1447 1446
1448 u16 passive = 1447 u16 passive =
@@ -1457,7 +1456,7 @@ il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band,
1457 * dwell time to be 98% of the smallest beacon interval 1456 * dwell time to be 98% of the smallest beacon interval
1458 * (minus 2 * channel tune time) 1457 * (minus 2 * channel tune time)
1459 */ 1458 */
1460 value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; 1459 value = il->vif ? il->vif->bss_conf.beacon_int : 0;
1461 if (value > IL_PASSIVE_DWELL_BASE || !value) 1460 if (value > IL_PASSIVE_DWELL_BASE || !value)
1462 value = IL_PASSIVE_DWELL_BASE; 1461 value = IL_PASSIVE_DWELL_BASE;
1463 value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; 1462 value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2;
@@ -1486,7 +1485,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif)
1486 1485
1487 lockdep_assert_held(&il->mutex); 1486 lockdep_assert_held(&il->mutex);
1488 1487
1489 if (WARN_ON(!il->cfg->ops->utils->request_scan)) 1488 if (WARN_ON(!il->ops->utils->request_scan))
1490 return -EOPNOTSUPP; 1489 return -EOPNOTSUPP;
1491 1490
1492 cancel_delayed_work(&il->scan_check); 1491 cancel_delayed_work(&il->scan_check);
@@ -1511,7 +1510,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif)
1511 set_bit(S_SCANNING, &il->status); 1510 set_bit(S_SCANNING, &il->status);
1512 il->scan_start = jiffies; 1511 il->scan_start = jiffies;
1513 1512
1514 ret = il->cfg->ops->utils->request_scan(il, vif); 1513 ret = il->ops->utils->request_scan(il, vif);
1515 if (ret) { 1514 if (ret) {
1516 clear_bit(S_SCANNING, &il->status); 1515 clear_bit(S_SCANNING, &il->status);
1517 return ret; 1516 return ret;
@@ -1673,7 +1672,7 @@ out_settings:
1673 il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); 1672 il_power_set_mode(il, &il->power_data.sleep_cmd_next, false);
1674 il_set_tx_power(il, il->tx_power_next, false); 1673 il_set_tx_power(il, il->tx_power_next, false);
1675 1674
1676 il->cfg->ops->utils->post_scan(il); 1675 il->ops->utils->post_scan(il);
1677 1676
1678out: 1677out:
1679 mutex_unlock(&il->mutex); 1678 mutex_unlock(&il->mutex);
@@ -1815,7 +1814,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags)
1815 might_sleep(); 1814 might_sleep();
1816 } 1815 }
1817 1816
1818 cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); 1817 cmd.len = il->ops->utils->build_addsta_hcmd(sta, data);
1819 ret = il_send_cmd(il, &cmd); 1818 ret = il_send_cmd(il, &cmd);
1820 1819
1821 if (ret || (flags & CMD_ASYNC)) 1820 if (ret || (flags & CMD_ASYNC))
@@ -1832,8 +1831,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags)
1832EXPORT_SYMBOL(il_send_add_sta); 1831EXPORT_SYMBOL(il_send_add_sta);
1833 1832
1834static void 1833static void
1835il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, 1834il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta)
1836 struct il_rxon_context *ctx)
1837{ 1835{
1838 struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; 1836 struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap;
1839 __le32 sta_flags; 1837 __le32 sta_flags;
@@ -1874,7 +1872,7 @@ il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta,
1874 cpu_to_le32((u32) sta_ht_inf-> 1872 cpu_to_le32((u32) sta_ht_inf->
1875 ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); 1873 ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS);
1876 1874
1877 if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) 1875 if (il_is_ht40_tx_allowed(il, &sta->ht_cap))
1878 sta_flags |= STA_FLG_HT40_EN_MSK; 1876 sta_flags |= STA_FLG_HT40_EN_MSK;
1879 else 1877 else
1880 sta_flags &= ~STA_FLG_HT40_EN_MSK; 1878 sta_flags &= ~STA_FLG_HT40_EN_MSK;
@@ -1890,8 +1888,8 @@ done:
1890 * should be called with sta_lock held 1888 * should be called with sta_lock held
1891 */ 1889 */
1892u8 1890u8
1893il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, 1891il_prep_station(struct il_priv *il, const u8 *addr, bool is_ap,
1894 const u8 *addr, bool is_ap, struct ieee80211_sta *sta) 1892 struct ieee80211_sta *sta)
1895{ 1893{
1896 struct il_station_entry *station; 1894 struct il_station_entry *station;
1897 int i; 1895 int i;
@@ -1899,9 +1897,9 @@ il_prep_station(struct il_priv *il, struct il_rxon_context *ctx,
1899 u16 rate; 1897 u16 rate;
1900 1898
1901 if (is_ap) 1899 if (is_ap)
1902 sta_id = ctx->ap_sta_id; 1900 sta_id = IL_AP_ID;
1903 else if (is_broadcast_ether_addr(addr)) 1901 else if (is_broadcast_ether_addr(addr))
1904 sta_id = ctx->bcast_sta_id; 1902 sta_id = il->hw_params.bcast_id;
1905 else 1903 else
1906 for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { 1904 for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) {
1907 if (!compare_ether_addr 1905 if (!compare_ether_addr
@@ -1950,22 +1948,14 @@ il_prep_station(struct il_priv *il, struct il_rxon_context *ctx,
1950 memcpy(station->sta.sta.addr, addr, ETH_ALEN); 1948 memcpy(station->sta.sta.addr, addr, ETH_ALEN);
1951 station->sta.mode = 0; 1949 station->sta.mode = 0;
1952 station->sta.sta.sta_id = sta_id; 1950 station->sta.sta.sta_id = sta_id;
1953 station->sta.station_flags = ctx->station_flags; 1951 station->sta.station_flags = 0;
1954 station->ctxid = ctx->ctxid;
1955
1956 if (sta) {
1957 struct il_station_priv_common *sta_priv;
1958
1959 sta_priv = (void *)sta->drv_priv;
1960 sta_priv->ctx = ctx;
1961 }
1962 1952
1963 /* 1953 /*
1964 * OK to call unconditionally, since local stations (IBSS BSSID 1954 * OK to call unconditionally, since local stations (IBSS BSSID
1965 * STA and broadcast STA) pass in a NULL sta, and mac80211 1955 * STA and broadcast STA) pass in a NULL sta, and mac80211
1966 * doesn't allow HT IBSS. 1956 * doesn't allow HT IBSS.
1967 */ 1957 */
1968 il_set_ht_add_station(il, sta_id, sta, ctx); 1958 il_set_ht_add_station(il, sta_id, sta);
1969 1959
1970 /* 3945 only */ 1960 /* 3945 only */
1971 rate = (il->band == IEEE80211_BAND_5GHZ) ? RATE_6M_PLCP : RATE_1M_PLCP; 1961 rate = (il->band == IEEE80211_BAND_5GHZ) ? RATE_6M_PLCP : RATE_1M_PLCP;
@@ -1983,9 +1973,8 @@ EXPORT_SYMBOL_GPL(il_prep_station);
1983 * il_add_station_common - 1973 * il_add_station_common -
1984 */ 1974 */
1985int 1975int
1986il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, 1976il_add_station_common(struct il_priv *il, const u8 *addr, bool is_ap,
1987 const u8 *addr, bool is_ap, struct ieee80211_sta *sta, 1977 struct ieee80211_sta *sta, u8 *sta_id_r)
1988 u8 *sta_id_r)
1989{ 1978{
1990 unsigned long flags_spin; 1979 unsigned long flags_spin;
1991 int ret = 0; 1980 int ret = 0;
@@ -1994,7 +1983,7 @@ il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx,
1994 1983
1995 *sta_id_r = 0; 1984 *sta_id_r = 0;
1996 spin_lock_irqsave(&il->sta_lock, flags_spin); 1985 spin_lock_irqsave(&il->sta_lock, flags_spin);
1997 sta_id = il_prep_station(il, ctx, addr, is_ap, sta); 1986 sta_id = il_prep_station(il, addr, is_ap, sta);
1998 if (sta_id == IL_INVALID_STATION) { 1987 if (sta_id == IL_INVALID_STATION) {
1999 IL_ERR("Unable to prepare station %pM for addition\n", addr); 1988 IL_ERR("Unable to prepare station %pM for addition\n", addr);
2000 spin_unlock_irqrestore(&il->sta_lock, flags_spin); 1989 spin_unlock_irqrestore(&il->sta_lock, flags_spin);
@@ -2181,7 +2170,7 @@ EXPORT_SYMBOL_GPL(il_remove_station);
2181 * the ucode, e.g. unassociated RXON. 2170 * the ucode, e.g. unassociated RXON.
2182 */ 2171 */
2183void 2172void
2184il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) 2173il_clear_ucode_stations(struct il_priv *il)
2185{ 2174{
2186 int i; 2175 int i;
2187 unsigned long flags_spin; 2176 unsigned long flags_spin;
@@ -2191,9 +2180,6 @@ il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx)
2191 2180
2192 spin_lock_irqsave(&il->sta_lock, flags_spin); 2181 spin_lock_irqsave(&il->sta_lock, flags_spin);
2193 for (i = 0; i < il->hw_params.max_stations; i++) { 2182 for (i = 0; i < il->hw_params.max_stations; i++) {
2194 if (ctx && ctx->ctxid != il->stations[i].ctxid)
2195 continue;
2196
2197 if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { 2183 if (il->stations[i].used & IL_STA_UCODE_ACTIVE) {
2198 D_INFO("Clearing ucode active for station %d\n", i); 2184 D_INFO("Clearing ucode active for station %d\n", i);
2199 il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; 2185 il->stations[i].used &= ~IL_STA_UCODE_ACTIVE;
@@ -2216,7 +2202,7 @@ EXPORT_SYMBOL(il_clear_ucode_stations);
2216 * Function sleeps. 2202 * Function sleeps.
2217 */ 2203 */
2218void 2204void
2219il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) 2205il_restore_stations(struct il_priv *il)
2220{ 2206{
2221 struct il_addsta_cmd sta_cmd; 2207 struct il_addsta_cmd sta_cmd;
2222 struct il_link_quality_cmd lq; 2208 struct il_link_quality_cmd lq;
@@ -2234,8 +2220,6 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx)
2234 D_ASSOC("Restoring all known stations ... start.\n"); 2220 D_ASSOC("Restoring all known stations ... start.\n");
2235 spin_lock_irqsave(&il->sta_lock, flags_spin); 2221 spin_lock_irqsave(&il->sta_lock, flags_spin);
2236 for (i = 0; i < il->hw_params.max_stations; i++) { 2222 for (i = 0; i < il->hw_params.max_stations; i++) {
2237 if (ctx->ctxid != il->stations[i].ctxid)
2238 continue;
2239 if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && 2223 if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) &&
2240 !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { 2224 !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) {
2241 D_ASSOC("Restoring sta %pM\n", 2225 D_ASSOC("Restoring sta %pM\n",
@@ -2273,7 +2257,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx)
2273 * current LQ command 2257 * current LQ command
2274 */ 2258 */
2275 if (send_lq) 2259 if (send_lq)
2276 il_send_lq_cmd(il, ctx, &lq, CMD_SYNC, true); 2260 il_send_lq_cmd(il, &lq, CMD_SYNC, true);
2277 spin_lock_irqsave(&il->sta_lock, flags_spin); 2261 spin_lock_irqsave(&il->sta_lock, flags_spin);
2278 il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; 2262 il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS;
2279 } 2263 }
@@ -2353,15 +2337,14 @@ il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq)
2353 * RXON flags are updated and when LQ command is updated. 2337 * RXON flags are updated and when LQ command is updated.
2354 */ 2338 */
2355static bool 2339static bool
2356il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, 2340il_is_lq_table_valid(struct il_priv *il, struct il_link_quality_cmd *lq)
2357 struct il_link_quality_cmd *lq)
2358{ 2341{
2359 int i; 2342 int i;
2360 2343
2361 if (ctx->ht.enabled) 2344 if (il->ht.enabled)
2362 return true; 2345 return true;
2363 2346
2364 D_INFO("Channel %u is not an HT channel\n", ctx->active.channel); 2347 D_INFO("Channel %u is not an HT channel\n", il->active.channel);
2365 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { 2348 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
2366 if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { 2349 if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) {
2367 D_INFO("idx %d of LQ expects HT channel\n", i); 2350 D_INFO("idx %d of LQ expects HT channel\n", i);
@@ -2382,8 +2365,8 @@ il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx,
2382 * progress. 2365 * progress.
2383 */ 2366 */
2384int 2367int
2385il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, 2368il_send_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq,
2386 struct il_link_quality_cmd *lq, u8 flags, bool init) 2369 u8 flags, bool init)
2387{ 2370{
2388 int ret = 0; 2371 int ret = 0;
2389 unsigned long flags_spin; 2372 unsigned long flags_spin;
@@ -2408,7 +2391,7 @@ il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx,
2408 il_dump_lq_cmd(il, lq); 2391 il_dump_lq_cmd(il, lq);
2409 BUG_ON(init && (cmd.flags & CMD_ASYNC)); 2392 BUG_ON(init && (cmd.flags & CMD_ASYNC));
2410 2393
2411 if (il_is_lq_table_valid(il, ctx, lq)) 2394 if (il_is_lq_table_valid(il, lq))
2412 ret = il_send_cmd(il, &cmd); 2395 ret = il_send_cmd(il, &cmd);
2413 else 2396 else
2414 ret = -EINVAL; 2397 ret = -EINVAL;
@@ -2648,7 +2631,7 @@ il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr,
2648 * All contexts have the same setting here due to it being 2631 * All contexts have the same setting here due to it being
2649 * a module parameter, so OK to check any context. 2632 * a module parameter, so OK to check any context.
2650 */ 2633 */
2651 if (il->ctx.active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) 2634 if (il->active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK)
2652 return 0; 2635 return 0;
2653 2636
2654 if (!(fc & IEEE80211_FCTL_PROTECTED)) 2637 if (!(fc & IEEE80211_FCTL_PROTECTED))
@@ -2739,7 +2722,7 @@ il_tx_queue_unmap(struct il_priv *il, int txq_id)
2739 return; 2722 return;
2740 2723
2741 while (q->write_ptr != q->read_ptr) { 2724 while (q->write_ptr != q->read_ptr) {
2742 il->cfg->ops->lib->txq_free_tfd(il, txq); 2725 il->ops->lib->txq_free_tfd(il, txq);
2743 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); 2726 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd);
2744 } 2727 }
2745} 2728}
@@ -2772,8 +2755,8 @@ il_tx_queue_free(struct il_priv *il, int txq_id)
2772 txq->tfds, txq->q.dma_addr); 2755 txq->tfds, txq->q.dma_addr);
2773 2756
2774 /* De-alloc array of per-TFD driver data */ 2757 /* De-alloc array of per-TFD driver data */
2775 kfree(txq->txb); 2758 kfree(txq->skbs);
2776 txq->txb = NULL; 2759 txq->skbs = NULL;
2777 2760
2778 /* deallocate arrays */ 2761 /* deallocate arrays */
2779 kfree(txq->cmd); 2762 kfree(txq->cmd);
@@ -2947,23 +2930,21 @@ il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id)
2947 /* Driver ilate data, only for Tx (not command) queues, 2930 /* Driver ilate data, only for Tx (not command) queues,
2948 * not shared with device. */ 2931 * not shared with device. */
2949 if (id != il->cmd_queue) { 2932 if (id != il->cmd_queue) {
2950 txq->txb = kcalloc(TFD_QUEUE_SIZE_MAX, sizeof(txq->txb[0]), 2933 txq->skbs = kcalloc(TFD_QUEUE_SIZE_MAX, sizeof(struct skb *),
2951 GFP_KERNEL); 2934 GFP_KERNEL);
2952 if (!txq->txb) { 2935 if (!txq->skbs) {
2953 IL_ERR("kmalloc for auxiliary BD " 2936 IL_ERR("Fail to alloc skbs\n");
2954 "structures failed\n");
2955 goto error; 2937 goto error;
2956 } 2938 }
2957 } else { 2939 } else
2958 txq->txb = NULL; 2940 txq->skbs = NULL;
2959 }
2960 2941
2961 /* Circular buffer of transmit frame descriptors (TFDs), 2942 /* Circular buffer of transmit frame descriptors (TFDs),
2962 * shared with device */ 2943 * shared with device */
2963 txq->tfds = 2944 txq->tfds =
2964 dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); 2945 dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL);
2965 if (!txq->tfds) { 2946 if (!txq->tfds) {
2966 IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); 2947 IL_ERR("Fail to alloc TFDs\n");
2967 goto error; 2948 goto error;
2968 } 2949 }
2969 txq->q.id = id; 2950 txq->q.id = id;
@@ -2971,8 +2952,8 @@ il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id)
2971 return 0; 2952 return 0;
2972 2953
2973error: 2954error:
2974 kfree(txq->txb); 2955 kfree(txq->skbs);
2975 txq->txb = NULL; 2956 txq->skbs = NULL;
2976 2957
2977 return -ENOMEM; 2958 return -ENOMEM;
2978} 2959}
@@ -3041,7 +3022,7 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
3041 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); 3022 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
3042 3023
3043 /* Tell device where to find queue */ 3024 /* Tell device where to find queue */
3044 il->cfg->ops->lib->txq_init(il, txq); 3025 il->ops->lib->txq_init(il, txq);
3045 3026
3046 return 0; 3027 return 0;
3047err: 3028err:
@@ -3072,7 +3053,7 @@ il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
3072 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); 3053 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
3073 3054
3074 /* Tell device where to find queue */ 3055 /* Tell device where to find queue */
3075 il->cfg->ops->lib->txq_init(il, txq); 3056 il->ops->lib->txq_init(il, txq);
3076} 3057}
3077EXPORT_SYMBOL(il_tx_queue_reset); 3058EXPORT_SYMBOL(il_tx_queue_reset);
3078 3059
@@ -3100,7 +3081,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
3100 u32 idx; 3081 u32 idx;
3101 u16 fix_size; 3082 u16 fix_size;
3102 3083
3103 cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); 3084 cmd->len = il->ops->utils->get_hcmd_size(cmd->id, cmd->len);
3104 fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr)); 3085 fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr));
3105 3086
3106 /* If any of the command structures end up being larger than 3087 /* If any of the command structures end up being larger than
@@ -3179,9 +3160,9 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
3179#endif 3160#endif
3180 txq->need_update = 1; 3161 txq->need_update = 1;
3181 3162
3182 if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) 3163 if (il->ops->lib->txq_update_byte_cnt_tbl)
3183 /* Set up entry in queue's byte count circular buffer */ 3164 /* Set up entry in queue's byte count circular buffer */
3184 il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); 3165 il->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0);
3185 3166
3186 phys_addr = 3167 phys_addr =
3187 pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, 3168 pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size,
@@ -3189,8 +3170,8 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
3189 dma_unmap_addr_set(out_meta, mapping, phys_addr); 3170 dma_unmap_addr_set(out_meta, mapping, phys_addr);
3190 dma_unmap_len_set(out_meta, len, fix_size); 3171 dma_unmap_len_set(out_meta, len, fix_size);
3191 3172
3192 il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 3173 il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1,
3193 1, U32_PAD(cmd->len)); 3174 U32_PAD(cmd->len));
3194 3175
3195 /* Increment and update queue's write idx */ 3176 /* Increment and update queue's write idx */
3196 q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); 3177 q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd);
@@ -3332,30 +3313,6 @@ EXPORT_SYMBOL(il_debug_level);
3332const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 3313const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3333EXPORT_SYMBOL(il_bcast_addr); 3314EXPORT_SYMBOL(il_bcast_addr);
3334 3315
3335/* This function both allocates and initializes hw and il. */
3336struct ieee80211_hw *
3337il_alloc_all(struct il_cfg *cfg)
3338{
3339 struct il_priv *il;
3340 /* mac80211 allocates memory for this device instance, including
3341 * space for this driver's ilate structure */
3342 struct ieee80211_hw *hw;
3343
3344 hw = ieee80211_alloc_hw(sizeof(struct il_priv),
3345 cfg->ops->ieee80211_ops);
3346 if (hw == NULL) {
3347 pr_err("%s: Can not allocate network device\n", cfg->name);
3348 goto out;
3349 }
3350
3351 il = hw->priv;
3352 il->hw = hw;
3353
3354out:
3355 return hw;
3356}
3357EXPORT_SYMBOL(il_alloc_all);
3358
3359#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ 3316#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
3360#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ 3317#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
3361static void 3318static void
@@ -3562,10 +3519,9 @@ il_is_channel_extension(struct il_priv *il, enum ieee80211_band band,
3562} 3519}
3563 3520
3564bool 3521bool
3565il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, 3522il_is_ht40_tx_allowed(struct il_priv *il, struct ieee80211_sta_ht_cap *ht_cap)
3566 struct ieee80211_sta_ht_cap *ht_cap)
3567{ 3523{
3568 if (!ctx->ht.enabled || !ctx->ht.is_40mhz) 3524 if (!il->ht.enabled || !il->ht.is_40mhz)
3569 return false; 3525 return false;
3570 3526
3571 /* 3527 /*
@@ -3581,8 +3537,8 @@ il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx,
3581#endif 3537#endif
3582 3538
3583 return il_is_channel_extension(il, il->band, 3539 return il_is_channel_extension(il, il->band,
3584 le16_to_cpu(ctx->staging.channel), 3540 le16_to_cpu(il->staging.channel),
3585 ctx->ht.extension_chan_offset); 3541 il->ht.extension_chan_offset);
3586} 3542}
3587EXPORT_SYMBOL(il_is_ht40_tx_allowed); 3543EXPORT_SYMBOL(il_is_ht40_tx_allowed);
3588 3544
@@ -3621,22 +3577,22 @@ il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val)
3621} 3577}
3622 3578
3623int 3579int
3624il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) 3580il_send_rxon_timing(struct il_priv *il)
3625{ 3581{
3626 u64 tsf; 3582 u64 tsf;
3627 s32 interval_tm, rem; 3583 s32 interval_tm, rem;
3628 struct ieee80211_conf *conf = NULL; 3584 struct ieee80211_conf *conf = NULL;
3629 u16 beacon_int; 3585 u16 beacon_int;
3630 struct ieee80211_vif *vif = ctx->vif; 3586 struct ieee80211_vif *vif = il->vif;
3631 3587
3632 conf = &il->hw->conf; 3588 conf = &il->hw->conf;
3633 3589
3634 lockdep_assert_held(&il->mutex); 3590 lockdep_assert_held(&il->mutex);
3635 3591
3636 memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); 3592 memset(&il->timing, 0, sizeof(struct il_rxon_time_cmd));
3637 3593
3638 ctx->timing.timestamp = cpu_to_le64(il->timestamp); 3594 il->timing.timestamp = cpu_to_le64(il->timestamp);
3639 ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); 3595 il->timing.listen_interval = cpu_to_le16(conf->listen_interval);
3640 3596
3641 beacon_int = vif ? vif->bss_conf.beacon_int : 0; 3597 beacon_int = vif ? vif->bss_conf.beacon_int : 0;
3642 3598
@@ -3644,36 +3600,35 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx)
3644 * TODO: For IBSS we need to get atim_win from mac80211, 3600 * TODO: For IBSS we need to get atim_win from mac80211,
3645 * for now just always use 0 3601 * for now just always use 0
3646 */ 3602 */
3647 ctx->timing.atim_win = 0; 3603 il->timing.atim_win = 0;
3648 3604
3649 beacon_int = 3605 beacon_int =
3650 il_adjust_beacon_interval(beacon_int, 3606 il_adjust_beacon_interval(beacon_int,
3651 il->hw_params.max_beacon_itrvl * 3607 il->hw_params.max_beacon_itrvl *
3652 TIME_UNIT); 3608 TIME_UNIT);
3653 ctx->timing.beacon_interval = cpu_to_le16(beacon_int); 3609 il->timing.beacon_interval = cpu_to_le16(beacon_int);
3654 3610
3655 tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ 3611 tsf = il->timestamp; /* tsf is modifed by do_div: copy it */
3656 interval_tm = beacon_int * TIME_UNIT; 3612 interval_tm = beacon_int * TIME_UNIT;
3657 rem = do_div(tsf, interval_tm); 3613 rem = do_div(tsf, interval_tm);
3658 ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); 3614 il->timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
3659 3615
3660 ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ? : 1) : 1; 3616 il->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ? : 1) : 1;
3661 3617
3662 D_ASSOC("beacon interval %d beacon timer %d beacon tim %d\n", 3618 D_ASSOC("beacon interval %d beacon timer %d beacon tim %d\n",
3663 le16_to_cpu(ctx->timing.beacon_interval), 3619 le16_to_cpu(il->timing.beacon_interval),
3664 le32_to_cpu(ctx->timing.beacon_init_val), 3620 le32_to_cpu(il->timing.beacon_init_val),
3665 le16_to_cpu(ctx->timing.atim_win)); 3621 le16_to_cpu(il->timing.atim_win));
3666 3622
3667 return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), 3623 return il_send_cmd_pdu(il, C_RXON_TIMING, sizeof(il->timing),
3668 &ctx->timing); 3624 &il->timing);
3669} 3625}
3670EXPORT_SYMBOL(il_send_rxon_timing); 3626EXPORT_SYMBOL(il_send_rxon_timing);
3671 3627
3672void 3628void
3673il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, 3629il_set_rxon_hwcrypto(struct il_priv *il, int hw_decrypt)
3674 int hw_decrypt)
3675{ 3630{
3676 struct il_rxon_cmd *rxon = &ctx->staging; 3631 struct il_rxon_cmd *rxon = &il->staging;
3677 3632
3678 if (hw_decrypt) 3633 if (hw_decrypt)
3679 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; 3634 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
@@ -3685,9 +3640,9 @@ EXPORT_SYMBOL(il_set_rxon_hwcrypto);
3685 3640
3686/* validate RXON structure is valid */ 3641/* validate RXON structure is valid */
3687int 3642int
3688il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) 3643il_check_rxon_cmd(struct il_priv *il)
3689{ 3644{
3690 struct il_rxon_cmd *rxon = &ctx->staging; 3645 struct il_rxon_cmd *rxon = &il->staging;
3691 bool error = false; 3646 bool error = false;
3692 3647
3693 if (rxon->flags & RXON_FLG_BAND_24G_MSK) { 3648 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
@@ -3765,10 +3720,10 @@ EXPORT_SYMBOL(il_check_rxon_cmd);
3765 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. 3720 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
3766 */ 3721 */
3767int 3722int
3768il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) 3723il_full_rxon_required(struct il_priv *il)
3769{ 3724{
3770 const struct il_rxon_cmd *staging = &ctx->staging; 3725 const struct il_rxon_cmd *staging = &il->staging;
3771 const struct il_rxon_cmd *active = &ctx->active; 3726 const struct il_rxon_cmd *active = &il->active;
3772 3727
3773#define CHK(cond) \ 3728#define CHK(cond) \
3774 if ((cond)) { \ 3729 if ((cond)) { \
@@ -3785,7 +3740,7 @@ il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx)
3785 } 3740 }
3786 3741
3787 /* These items are only settable from the full RXON command */ 3742 /* These items are only settable from the full RXON command */
3788 CHK(!il_is_associated_ctx(ctx)); 3743 CHK(!il_is_associated(il));
3789 CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); 3744 CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr));
3790 CHK(compare_ether_addr(staging->node_addr, active->node_addr)); 3745 CHK(compare_ether_addr(staging->node_addr, active->node_addr));
3791 CHK(compare_ether_addr 3746 CHK(compare_ether_addr
@@ -3819,13 +3774,13 @@ il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx)
3819EXPORT_SYMBOL(il_full_rxon_required); 3774EXPORT_SYMBOL(il_full_rxon_required);
3820 3775
3821u8 3776u8
3822il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx) 3777il_get_lowest_plcp(struct il_priv *il)
3823{ 3778{
3824 /* 3779 /*
3825 * Assign the lowest rate -- should really get this from 3780 * Assign the lowest rate -- should really get this from
3826 * the beacon skb from mac80211. 3781 * the beacon skb from mac80211.
3827 */ 3782 */
3828 if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) 3783 if (il->staging.flags & RXON_FLG_BAND_24G_MSK)
3829 return RATE_1M_PLCP; 3784 return RATE_1M_PLCP;
3830 else 3785 else
3831 return RATE_6M_PLCP; 3786 return RATE_6M_PLCP;
@@ -3833,12 +3788,11 @@ il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx)
3833EXPORT_SYMBOL(il_get_lowest_plcp); 3788EXPORT_SYMBOL(il_get_lowest_plcp);
3834 3789
3835static void 3790static void
3836_il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, 3791_il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf)
3837 struct il_rxon_context *ctx)
3838{ 3792{
3839 struct il_rxon_cmd *rxon = &ctx->staging; 3793 struct il_rxon_cmd *rxon = &il->staging;
3840 3794
3841 if (!ctx->ht.enabled) { 3795 if (!il->ht.enabled) {
3842 rxon->flags &= 3796 rxon->flags &=
3843 ~(RXON_FLG_CHANNEL_MODE_MSK | 3797 ~(RXON_FLG_CHANNEL_MODE_MSK |
3844 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | RXON_FLG_HT40_PROT_MSK 3798 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | RXON_FLG_HT40_PROT_MSK
@@ -3847,19 +3801,19 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf,
3847 } 3801 }
3848 3802
3849 rxon->flags |= 3803 rxon->flags |=
3850 cpu_to_le32(ctx->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS); 3804 cpu_to_le32(il->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS);
3851 3805
3852 /* Set up channel bandwidth: 3806 /* Set up channel bandwidth:
3853 * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ 3807 * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */
3854 /* clear the HT channel mode before set the mode */ 3808 /* clear the HT channel mode before set the mode */
3855 rxon->flags &= 3809 rxon->flags &=
3856 ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); 3810 ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
3857 if (il_is_ht40_tx_allowed(il, ctx, NULL)) { 3811 if (il_is_ht40_tx_allowed(il, NULL)) {
3858 /* pure ht40 */ 3812 /* pure ht40 */
3859 if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { 3813 if (il->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) {
3860 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; 3814 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40;
3861 /* Note: control channel is opposite of extension channel */ 3815 /* Note: control channel is opposite of extension channel */
3862 switch (ctx->ht.extension_chan_offset) { 3816 switch (il->ht.extension_chan_offset) {
3863 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 3817 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
3864 rxon->flags &= 3818 rxon->flags &=
3865 ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; 3819 ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK;
@@ -3870,7 +3824,7 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf,
3870 } 3824 }
3871 } else { 3825 } else {
3872 /* Note: control channel is opposite of extension channel */ 3826 /* Note: control channel is opposite of extension channel */
3873 switch (ctx->ht.extension_chan_offset) { 3827 switch (il->ht.extension_chan_offset) {
3874 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 3828 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
3875 rxon->flags &= 3829 rxon->flags &=
3876 ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); 3830 ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK);
@@ -3891,18 +3845,18 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf,
3891 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; 3845 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY;
3892 } 3846 }
3893 3847
3894 if (il->cfg->ops->hcmd->set_rxon_chain) 3848 if (il->ops->hcmd->set_rxon_chain)
3895 il->cfg->ops->hcmd->set_rxon_chain(il, ctx); 3849 il->ops->hcmd->set_rxon_chain(il);
3896 3850
3897 D_ASSOC("rxon flags 0x%X operation mode :0x%X " 3851 D_ASSOC("rxon flags 0x%X operation mode :0x%X "
3898 "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), 3852 "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags),
3899 ctx->ht.protection, ctx->ht.extension_chan_offset); 3853 il->ht.protection, il->ht.extension_chan_offset);
3900} 3854}
3901 3855
3902void 3856void
3903il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) 3857il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf)
3904{ 3858{
3905 _il_set_rxon_ht(il, ht_conf, &il->ctx); 3859 _il_set_rxon_ht(il, ht_conf);
3906} 3860}
3907EXPORT_SYMBOL(il_set_rxon_ht); 3861EXPORT_SYMBOL(il_set_rxon_ht);
3908 3862
@@ -3925,7 +3879,7 @@ il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band)
3925 3879
3926 for (i = min; i < max; i++) { 3880 for (i = min; i < max; i++) {
3927 channel = il->channel_info[i].channel; 3881 channel = il->channel_info[i].channel;
3928 if (channel == le16_to_cpu(il->ctx.staging.channel)) 3882 if (channel == le16_to_cpu(il->staging.channel))
3929 continue; 3883 continue;
3930 3884
3931 ch_info = il_get_channel_info(il, band, channel); 3885 ch_info = il_get_channel_info(il, band, channel);
@@ -3945,20 +3899,19 @@ EXPORT_SYMBOL(il_get_single_channel_number);
3945 * in the staging RXON flag structure based on the ch->band 3899 * in the staging RXON flag structure based on the ch->band
3946 */ 3900 */
3947int 3901int
3948il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, 3902il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch)
3949 struct il_rxon_context *ctx)
3950{ 3903{
3951 enum ieee80211_band band = ch->band; 3904 enum ieee80211_band band = ch->band;
3952 u16 channel = ch->hw_value; 3905 u16 channel = ch->hw_value;
3953 3906
3954 if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) 3907 if (le16_to_cpu(il->staging.channel) == channel && il->band == band)
3955 return 0; 3908 return 0;
3956 3909
3957 ctx->staging.channel = cpu_to_le16(channel); 3910 il->staging.channel = cpu_to_le16(channel);
3958 if (band == IEEE80211_BAND_5GHZ) 3911 if (band == IEEE80211_BAND_5GHZ)
3959 ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; 3912 il->staging.flags &= ~RXON_FLG_BAND_24G_MSK;
3960 else 3913 else
3961 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; 3914 il->staging.flags |= RXON_FLG_BAND_24G_MSK;
3962 3915
3963 il->band = band; 3916 il->band = band;
3964 3917
@@ -3969,24 +3922,24 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch,
3969EXPORT_SYMBOL(il_set_rxon_channel); 3922EXPORT_SYMBOL(il_set_rxon_channel);
3970 3923
3971void 3924void
3972il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, 3925il_set_flags_for_band(struct il_priv *il, enum ieee80211_band band,
3973 enum ieee80211_band band, struct ieee80211_vif *vif) 3926 struct ieee80211_vif *vif)
3974{ 3927{
3975 if (band == IEEE80211_BAND_5GHZ) { 3928 if (band == IEEE80211_BAND_5GHZ) {
3976 ctx->staging.flags &= 3929 il->staging.flags &=
3977 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | 3930 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK |
3978 RXON_FLG_CCK_MSK); 3931 RXON_FLG_CCK_MSK);
3979 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; 3932 il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
3980 } else { 3933 } else {
3981 /* Copied from il_post_associate() */ 3934 /* Copied from il_post_associate() */
3982 if (vif && vif->bss_conf.use_short_slot) 3935 if (vif && vif->bss_conf.use_short_slot)
3983 ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; 3936 il->staging.flags |= RXON_FLG_SHORT_SLOT_MSK;
3984 else 3937 else
3985 ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3938 il->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
3986 3939
3987 ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; 3940 il->staging.flags |= RXON_FLG_BAND_24G_MSK;
3988 ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; 3941 il->staging.flags |= RXON_FLG_AUTO_DETECT_MSK;
3989 ctx->staging.flags &= ~RXON_FLG_CCK_MSK; 3942 il->staging.flags &= ~RXON_FLG_CCK_MSK;
3990 } 3943 }
3991} 3944}
3992EXPORT_SYMBOL(il_set_flags_for_band); 3945EXPORT_SYMBOL(il_set_flags_for_band);
@@ -3995,69 +3948,60 @@ EXPORT_SYMBOL(il_set_flags_for_band);
3995 * initialize rxon structure with default values from eeprom 3948 * initialize rxon structure with default values from eeprom
3996 */ 3949 */
3997void 3950void
3998il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) 3951il_connection_init_rx_config(struct il_priv *il)
3999{ 3952{
4000 const struct il_channel_info *ch_info; 3953 const struct il_channel_info *ch_info;
4001 3954
4002 memset(&ctx->staging, 0, sizeof(ctx->staging)); 3955 memset(&il->staging, 0, sizeof(il->staging));
4003 3956
4004 if (!ctx->vif) { 3957 if (!il->vif) {
4005 ctx->staging.dev_type = ctx->unused_devtype; 3958 il->staging.dev_type = RXON_DEV_TYPE_ESS;
4006 } else 3959 } else if (il->vif->type == NL80211_IFTYPE_STATION) {
4007 switch (ctx->vif->type) { 3960 il->staging.dev_type = RXON_DEV_TYPE_ESS;
4008 3961 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
4009 case NL80211_IFTYPE_STATION: 3962 } else if (il->vif->type == NL80211_IFTYPE_ADHOC) {
4010 ctx->staging.dev_type = ctx->station_devtype; 3963 il->staging.dev_type = RXON_DEV_TYPE_IBSS;
4011 ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; 3964 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
4012 break; 3965 il->staging.filter_flags =
4013 3966 RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
4014 case NL80211_IFTYPE_ADHOC: 3967 } else {
4015 ctx->staging.dev_type = ctx->ibss_devtype; 3968 IL_ERR("Unsupported interface type %d\n", il->vif->type);
4016 ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; 3969 return;
4017 ctx->staging.filter_flags = 3970 }
4018 RXON_FILTER_BCON_AWARE_MSK |
4019 RXON_FILTER_ACCEPT_GRP_MSK;
4020 break;
4021
4022 default:
4023 IL_ERR("Unsupported interface type %d\n",
4024 ctx->vif->type);
4025 break;
4026 }
4027 3971
4028#if 0 3972#if 0
4029 /* TODO: Figure out when short_preamble would be set and cache from 3973 /* TODO: Figure out when short_preamble would be set and cache from
4030 * that */ 3974 * that */
4031 if (!hw_to_local(il->hw)->short_preamble) 3975 if (!hw_to_local(il->hw)->short_preamble)
4032 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 3976 il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
4033 else 3977 else
4034 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 3978 il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
4035#endif 3979#endif
4036 3980
4037 ch_info = 3981 ch_info =
4038 il_get_channel_info(il, il->band, le16_to_cpu(ctx->active.channel)); 3982 il_get_channel_info(il, il->band, le16_to_cpu(il->active.channel));
4039 3983
4040 if (!ch_info) 3984 if (!ch_info)
4041 ch_info = &il->channel_info[0]; 3985 ch_info = &il->channel_info[0];
4042 3986
4043 ctx->staging.channel = cpu_to_le16(ch_info->channel); 3987 il->staging.channel = cpu_to_le16(ch_info->channel);
4044 il->band = ch_info->band; 3988 il->band = ch_info->band;
4045 3989
4046 il_set_flags_for_band(il, ctx, il->band, ctx->vif); 3990 il_set_flags_for_band(il, il->band, il->vif);
4047 3991
4048 ctx->staging.ofdm_basic_rates = 3992 il->staging.ofdm_basic_rates =
4049 (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; 3993 (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF;
4050 ctx->staging.cck_basic_rates = 3994 il->staging.cck_basic_rates =
4051 (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; 3995 (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF;
4052 3996
4053 /* clear both MIX and PURE40 mode flag */ 3997 /* clear both MIX and PURE40 mode flag */
4054 ctx->staging.flags &= 3998 il->staging.flags &=
4055 ~(RXON_FLG_CHANNEL_MODE_MIXED | RXON_FLG_CHANNEL_MODE_PURE_40); 3999 ~(RXON_FLG_CHANNEL_MODE_MIXED | RXON_FLG_CHANNEL_MODE_PURE_40);
4056 if (ctx->vif) 4000 if (il->vif)
4057 memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); 4001 memcpy(il->staging.node_addr, il->vif->addr, ETH_ALEN);
4058 4002
4059 ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; 4003 il->staging.ofdm_ht_single_stream_basic_rates = 0xff;
4060 ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; 4004 il->staging.ofdm_ht_dual_stream_basic_rates = 0xff;
4061} 4005}
4062EXPORT_SYMBOL(il_connection_init_rx_config); 4006EXPORT_SYMBOL(il_connection_init_rx_config);
4063 4007
@@ -4084,10 +4028,10 @@ il_set_rate(struct il_priv *il)
4084 4028
4085 D_RATE("Set active_rate = %0x\n", il->active_rate); 4029 D_RATE("Set active_rate = %0x\n", il->active_rate);
4086 4030
4087 il->ctx.staging.cck_basic_rates = 4031 il->staging.cck_basic_rates =
4088 (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; 4032 (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF;
4089 4033
4090 il->ctx.staging.ofdm_basic_rates = 4034 il->staging.ofdm_basic_rates =
4091 (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; 4035 (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF;
4092} 4036}
4093EXPORT_SYMBOL(il_set_rate); 4037EXPORT_SYMBOL(il_set_rate);
@@ -4095,13 +4039,11 @@ EXPORT_SYMBOL(il_set_rate);
4095void 4039void
4096il_chswitch_done(struct il_priv *il, bool is_success) 4040il_chswitch_done(struct il_priv *il, bool is_success)
4097{ 4041{
4098 struct il_rxon_context *ctx = &il->ctx;
4099
4100 if (test_bit(S_EXIT_PENDING, &il->status)) 4042 if (test_bit(S_EXIT_PENDING, &il->status))
4101 return; 4043 return;
4102 4044
4103 if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) 4045 if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status))
4104 ieee80211_chswitch_done(ctx->vif, is_success); 4046 ieee80211_chswitch_done(il->vif, is_success);
4105} 4047}
4106EXPORT_SYMBOL(il_chswitch_done); 4048EXPORT_SYMBOL(il_chswitch_done);
4107 4049
@@ -4110,16 +4052,14 @@ il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb)
4110{ 4052{
4111 struct il_rx_pkt *pkt = rxb_addr(rxb); 4053 struct il_rx_pkt *pkt = rxb_addr(rxb);
4112 struct il_csa_notification *csa = &(pkt->u.csa_notif); 4054 struct il_csa_notification *csa = &(pkt->u.csa_notif);
4113 4055 struct il_rxon_cmd *rxon = (void *)&il->active;
4114 struct il_rxon_context *ctx = &il->ctx;
4115 struct il_rxon_cmd *rxon = (void *)&ctx->active;
4116 4056
4117 if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) 4057 if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status))
4118 return; 4058 return;
4119 4059
4120 if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { 4060 if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) {
4121 rxon->channel = csa->channel; 4061 rxon->channel = csa->channel;
4122 ctx->staging.channel = csa->channel; 4062 il->staging.channel = csa->channel;
4123 D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel)); 4063 D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel));
4124 il_chswitch_done(il, true); 4064 il_chswitch_done(il, true);
4125 } else { 4065 } else {
@@ -4132,9 +4072,9 @@ EXPORT_SYMBOL(il_hdl_csa);
4132 4072
4133#ifdef CONFIG_IWLEGACY_DEBUG 4073#ifdef CONFIG_IWLEGACY_DEBUG
4134void 4074void
4135il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) 4075il_print_rx_config_cmd(struct il_priv *il)
4136{ 4076{
4137 struct il_rxon_cmd *rxon = &ctx->staging; 4077 struct il_rxon_cmd *rxon = &il->staging;
4138 4078
4139 D_RADIO("RX CONFIG:\n"); 4079 D_RADIO("RX CONFIG:\n");
4140 il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); 4080 il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
@@ -4164,12 +4104,12 @@ il_irq_handle_error(struct il_priv *il)
4164 4104
4165 IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); 4105 IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version);
4166 4106
4167 il->cfg->ops->lib->dump_nic_error_log(il); 4107 il->ops->lib->dump_nic_error_log(il);
4168 if (il->cfg->ops->lib->dump_fh) 4108 if (il->ops->lib->dump_fh)
4169 il->cfg->ops->lib->dump_fh(il, NULL, false); 4109 il->ops->lib->dump_fh(il, NULL, false);
4170#ifdef CONFIG_IWLEGACY_DEBUG 4110#ifdef CONFIG_IWLEGACY_DEBUG
4171 if (il_get_debug_level(il) & IL_DL_FW_ERRORS) 4111 if (il_get_debug_level(il) & IL_DL_FW_ERRORS)
4172 il_print_rx_config_cmd(il, &il->ctx); 4112 il_print_rx_config_cmd(il);
4173#endif 4113#endif
4174 4114
4175 wake_up(&il->wait_command_queue); 4115 wake_up(&il->wait_command_queue);
@@ -4276,7 +4216,7 @@ il_apm_init(struct il_priv *il)
4276 * If not (unlikely), enable L0S, so there is at least some 4216 * If not (unlikely), enable L0S, so there is at least some
4277 * power savings, even without L1. 4217 * power savings, even without L1.
4278 */ 4218 */
4279 if (il->cfg->base_params->set_l0s) { 4219 if (il->cfg->set_l0s) {
4280 lctl = il_pcie_link_ctl(il); 4220 lctl = il_pcie_link_ctl(il);
4281 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == 4221 if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
4282 PCI_CFG_LINK_CTRL_VAL_L1_EN) { 4222 PCI_CFG_LINK_CTRL_VAL_L1_EN) {
@@ -4293,9 +4233,9 @@ il_apm_init(struct il_priv *il)
4293 } 4233 }
4294 4234
4295 /* Configure analog phase-lock-loop before activating to D0A */ 4235 /* Configure analog phase-lock-loop before activating to D0A */
4296 if (il->cfg->base_params->pll_cfg_val) 4236 if (il->cfg->pll_cfg_val)
4297 il_set_bit(il, CSR_ANA_PLL_CFG, 4237 il_set_bit(il, CSR_ANA_PLL_CFG,
4298 il->cfg->base_params->pll_cfg_val); 4238 il->cfg->pll_cfg_val);
4299 4239
4300 /* 4240 /*
4301 * Set "initialization complete" bit to move adapter from 4241 * Set "initialization complete" bit to move adapter from
@@ -4325,7 +4265,7 @@ il_apm_init(struct il_priv *il)
4325 * do not disable clocks. This preserves any hardware bits already 4265 * do not disable clocks. This preserves any hardware bits already
4326 * set by default in "CLK_CTRL_REG" after reset. 4266 * set by default in "CLK_CTRL_REG" after reset.
4327 */ 4267 */
4328 if (il->cfg->base_params->use_bsm) 4268 if (il->cfg->use_bsm)
4329 il_wr_prph(il, APMG_CLK_EN_REG, 4269 il_wr_prph(il, APMG_CLK_EN_REG,
4330 APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); 4270 APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT);
4331 else 4271 else
@@ -4347,14 +4287,13 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force)
4347 int ret; 4287 int ret;
4348 s8 prev_tx_power; 4288 s8 prev_tx_power;
4349 bool defer; 4289 bool defer;
4350 struct il_rxon_context *ctx = &il->ctx;
4351 4290
4352 lockdep_assert_held(&il->mutex); 4291 lockdep_assert_held(&il->mutex);
4353 4292
4354 if (il->tx_power_user_lmt == tx_power && !force) 4293 if (il->tx_power_user_lmt == tx_power && !force)
4355 return 0; 4294 return 0;
4356 4295
4357 if (!il->cfg->ops->lib->send_tx_power) 4296 if (!il->ops->lib->send_tx_power)
4358 return -EOPNOTSUPP; 4297 return -EOPNOTSUPP;
4359 4298
4360 /* 0 dBm mean 1 milliwatt */ 4299 /* 0 dBm mean 1 milliwatt */
@@ -4378,7 +4317,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force)
4378 4317
4379 /* do not set tx power when scanning or channel changing */ 4318 /* do not set tx power when scanning or channel changing */
4380 defer = test_bit(S_SCANNING, &il->status) || 4319 defer = test_bit(S_SCANNING, &il->status) ||
4381 memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); 4320 memcmp(&il->active, &il->staging, sizeof(il->staging));
4382 if (defer && !force) { 4321 if (defer && !force) {
4383 D_INFO("Deferring tx power set\n"); 4322 D_INFO("Deferring tx power set\n");
4384 return 0; 4323 return 0;
@@ -4387,7 +4326,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force)
4387 prev_tx_power = il->tx_power_user_lmt; 4326 prev_tx_power = il->tx_power_user_lmt;
4388 il->tx_power_user_lmt = tx_power; 4327 il->tx_power_user_lmt = tx_power;
4389 4328
4390 ret = il->cfg->ops->lib->send_tx_power(il); 4329 ret = il->ops->lib->send_tx_power(il);
4391 4330
4392 /* if fail to set tx_power, restore the orig. tx power */ 4331 /* if fail to set tx_power, restore the orig. tx power */
4393 if (ret) { 4332 if (ret) {
@@ -4505,15 +4444,15 @@ il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
4505 4444
4506 spin_lock_irqsave(&il->lock, flags); 4445 spin_lock_irqsave(&il->lock, flags);
4507 4446
4508 il->ctx.qos_data.def_qos_parm.ac[q].cw_min = 4447 il->qos_data.def_qos_parm.ac[q].cw_min =
4509 cpu_to_le16(params->cw_min); 4448 cpu_to_le16(params->cw_min);
4510 il->ctx.qos_data.def_qos_parm.ac[q].cw_max = 4449 il->qos_data.def_qos_parm.ac[q].cw_max =
4511 cpu_to_le16(params->cw_max); 4450 cpu_to_le16(params->cw_max);
4512 il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; 4451 il->qos_data.def_qos_parm.ac[q].aifsn = params->aifs;
4513 il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = 4452 il->qos_data.def_qos_parm.ac[q].edca_txop =
4514 cpu_to_le16((params->txop * 32)); 4453 cpu_to_le16((params->txop * 32));
4515 4454
4516 il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; 4455 il->qos_data.def_qos_parm.ac[q].reserved1 = 0;
4517 4456
4518 spin_unlock_irqrestore(&il->lock, flags); 4457 spin_unlock_irqrestore(&il->lock, flags);
4519 4458
@@ -4532,50 +4471,21 @@ il_mac_tx_last_beacon(struct ieee80211_hw *hw)
4532EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); 4471EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon);
4533 4472
4534static int 4473static int
4535il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) 4474il_set_mode(struct il_priv *il)
4536{
4537 il_connection_init_rx_config(il, ctx);
4538
4539 if (il->cfg->ops->hcmd->set_rxon_chain)
4540 il->cfg->ops->hcmd->set_rxon_chain(il, ctx);
4541
4542 return il_commit_rxon(il, ctx);
4543}
4544
4545static int
4546il_setup_interface(struct il_priv *il, struct il_rxon_context *ctx)
4547{ 4475{
4548 struct ieee80211_vif *vif = ctx->vif; 4476 il_connection_init_rx_config(il);
4549 int err;
4550
4551 lockdep_assert_held(&il->mutex);
4552
4553 /*
4554 * This variable will be correct only when there's just
4555 * a single context, but all code using it is for hardware
4556 * that supports only one context.
4557 */
4558 il->iw_mode = vif->type;
4559 4477
4560 ctx->is_active = true; 4478 if (il->ops->hcmd->set_rxon_chain)
4479 il->ops->hcmd->set_rxon_chain(il);
4561 4480
4562 err = il_set_mode(il, ctx); 4481 return il_commit_rxon(il);
4563 if (err) {
4564 if (!ctx->always_active)
4565 ctx->is_active = false;
4566 return err;
4567 }
4568
4569 return 0;
4570} 4482}
4571 4483
4572int 4484int
4573il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 4485il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4574{ 4486{
4575 struct il_priv *il = hw->priv; 4487 struct il_priv *il = hw->priv;
4576 struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
4577 int err; 4488 int err;
4578 u32 modes;
4579 4489
4580 D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); 4490 D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr);
4581 4491
@@ -4587,25 +4497,17 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4587 goto out; 4497 goto out;
4588 } 4498 }
4589 4499
4590 /* check if busy context is exclusive */ 4500 if (il->vif) {
4591 if (il->ctx.vif &&
4592 (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) {
4593 err = -EINVAL;
4594 goto out;
4595 }
4596
4597 modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes;
4598 if (!(modes & BIT(vif->type))) {
4599 err = -EOPNOTSUPP; 4501 err = -EOPNOTSUPP;
4600 goto out; 4502 goto out;
4601 } 4503 }
4602 4504
4603 vif_priv->ctx = &il->ctx; 4505 il->vif = vif;
4604 il->ctx.vif = vif; 4506 il->iw_mode = vif->type;
4605 4507
4606 err = il_setup_interface(il, &il->ctx); 4508 err = il_set_mode(il);
4607 if (err) { 4509 if (err) {
4608 il->ctx.vif = NULL; 4510 il->vif = NULL;
4609 il->iw_mode = NL80211_IFTYPE_STATION; 4511 il->iw_mode = NL80211_IFTYPE_STATION;
4610 } 4512 }
4611 4513
@@ -4621,8 +4523,6 @@ static void
4621il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, 4523il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
4622 bool mode_change) 4524 bool mode_change)
4623{ 4525{
4624 struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif);
4625
4626 lockdep_assert_held(&il->mutex); 4526 lockdep_assert_held(&il->mutex);
4627 4527
4628 if (il->scan_vif == vif) { 4528 if (il->scan_vif == vif) {
@@ -4630,25 +4530,22 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
4630 il_force_scan_end(il); 4530 il_force_scan_end(il);
4631 } 4531 }
4632 4532
4633 if (!mode_change) { 4533 if (!mode_change)
4634 il_set_mode(il, ctx); 4534 il_set_mode(il);
4635 if (!ctx->always_active) 4535
4636 ctx->is_active = false;
4637 }
4638} 4536}
4639 4537
4640void 4538void
4641il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 4539il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
4642{ 4540{
4643 struct il_priv *il = hw->priv; 4541 struct il_priv *il = hw->priv;
4644 struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif);
4645 4542
4646 D_MAC80211("enter\n"); 4543 D_MAC80211("enter\n");
4647 4544
4648 mutex_lock(&il->mutex); 4545 mutex_lock(&il->mutex);
4649 4546
4650 WARN_ON(ctx->vif != vif); 4547 WARN_ON(il->vif != vif);
4651 ctx->vif = NULL; 4548 il->vif = NULL;
4652 4549
4653 il_teardown_interface(il, vif, false); 4550 il_teardown_interface(il, vif, false);
4654 4551
@@ -4666,7 +4563,7 @@ il_alloc_txq_mem(struct il_priv *il)
4666 if (!il->txq) 4563 if (!il->txq)
4667 il->txq = 4564 il->txq =
4668 kzalloc(sizeof(struct il_tx_queue) * 4565 kzalloc(sizeof(struct il_tx_queue) *
4669 il->cfg->base_params->num_of_queues, GFP_KERNEL); 4566 il->cfg->num_of_queues, GFP_KERNEL);
4670 if (!il->txq) { 4567 if (!il->txq) {
4671 IL_ERR("Not enough memory for txq\n"); 4568 IL_ERR("Not enough memory for txq\n");
4672 return -ENOMEM; 4569 return -ENOMEM;
@@ -4987,15 +4884,14 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
4987 enum nl80211_iftype newtype, bool newp2p) 4884 enum nl80211_iftype newtype, bool newp2p)
4988{ 4885{
4989 struct il_priv *il = hw->priv; 4886 struct il_priv *il = hw->priv;
4990 struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif);
4991 u32 modes;
4992 int err; 4887 int err;
4993 4888
4994 newtype = ieee80211_iftype_p2p(newtype, newp2p); 4889 if (newp2p)
4890 return -EOPNOTSUPP;
4995 4891
4996 mutex_lock(&il->mutex); 4892 mutex_lock(&il->mutex);
4997 4893
4998 if (!ctx->vif || !il_is_ready_rf(il)) { 4894 if (!il->vif || !il_is_ready_rf(il)) {
4999 /* 4895 /*
5000 * Huh? But wait ... this can maybe happen when 4896 * Huh? But wait ... this can maybe happen when
5001 * we're in the middle of a firmware restart! 4897 * we're in the middle of a firmware restart!
@@ -5004,23 +4900,11 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5004 goto out; 4900 goto out;
5005 } 4901 }
5006 4902
5007 modes = ctx->interface_modes | ctx->exclusive_interface_modes;
5008 if (!(modes & BIT(newtype))) {
5009 err = -EOPNOTSUPP;
5010 goto out;
5011 }
5012
5013 if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) ||
5014 (il->ctx.exclusive_interface_modes & BIT(newtype))) {
5015 err = -EINVAL;
5016 goto out;
5017 }
5018
5019 /* success */ 4903 /* success */
5020 il_teardown_interface(il, vif, true); 4904 il_teardown_interface(il, vif, true);
5021 vif->type = newtype; 4905 vif->type = newtype;
5022 vif->p2p = newp2p; 4906 vif->p2p = false;
5023 err = il_setup_interface(il, ctx); 4907 err = il_set_mode(il);
5024 WARN_ON(err); 4908 WARN_ON(err);
5025 /* 4909 /*
5026 * We've switched internally, but submitting to the 4910 * We've switched internally, but submitting to the
@@ -5056,11 +4940,11 @@ il_check_stuck_queue(struct il_priv *il, int cnt)
5056 4940
5057 timeout = 4941 timeout =
5058 txq->time_stamp + 4942 txq->time_stamp +
5059 msecs_to_jiffies(il->cfg->base_params->wd_timeout); 4943 msecs_to_jiffies(il->cfg->wd_timeout);
5060 4944
5061 if (time_after(jiffies, timeout)) { 4945 if (time_after(jiffies, timeout)) {
5062 IL_ERR("Queue %d stuck for %u ms.\n", q->id, 4946 IL_ERR("Queue %d stuck for %u ms.\n", q->id,
5063 il->cfg->base_params->wd_timeout); 4947 il->cfg->wd_timeout);
5064 ret = il_force_reset(il, false); 4948 ret = il_force_reset(il, false);
5065 return (ret == -EAGAIN) ? 0 : 1; 4949 return (ret == -EAGAIN) ? 0 : 1;
5066 } 4950 }
@@ -5088,7 +4972,7 @@ il_bg_watchdog(unsigned long data)
5088 if (test_bit(S_EXIT_PENDING, &il->status)) 4972 if (test_bit(S_EXIT_PENDING, &il->status))
5089 return; 4973 return;
5090 4974
5091 timeout = il->cfg->base_params->wd_timeout; 4975 timeout = il->cfg->wd_timeout;
5092 if (timeout == 0) 4976 if (timeout == 0)
5093 return; 4977 return;
5094 4978
@@ -5115,7 +4999,7 @@ EXPORT_SYMBOL(il_bg_watchdog);
5115void 4999void
5116il_setup_watchdog(struct il_priv *il) 5000il_setup_watchdog(struct il_priv *il)
5117{ 5001{
5118 unsigned int timeout = il->cfg->base_params->wd_timeout; 5002 unsigned int timeout = il->cfg->wd_timeout;
5119 5003
5120 if (timeout) 5004 if (timeout)
5121 mod_timer(&il->watchdog, 5005 mod_timer(&il->watchdog,
@@ -5252,28 +5136,25 @@ EXPORT_SYMBOL(il_pm_ops);
5252#endif /* CONFIG_PM */ 5136#endif /* CONFIG_PM */
5253 5137
5254static void 5138static void
5255il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) 5139il_update_qos(struct il_priv *il)
5256{ 5140{
5257 if (test_bit(S_EXIT_PENDING, &il->status)) 5141 if (test_bit(S_EXIT_PENDING, &il->status))
5258 return; 5142 return;
5259 5143
5260 if (!ctx->is_active) 5144 il->qos_data.def_qos_parm.qos_flags = 0;
5261 return;
5262 5145
5263 ctx->qos_data.def_qos_parm.qos_flags = 0; 5146 if (il->qos_data.qos_active)
5264 5147 il->qos_data.def_qos_parm.qos_flags |=
5265 if (ctx->qos_data.qos_active)
5266 ctx->qos_data.def_qos_parm.qos_flags |=
5267 QOS_PARAM_FLG_UPDATE_EDCA_MSK; 5148 QOS_PARAM_FLG_UPDATE_EDCA_MSK;
5268 5149
5269 if (ctx->ht.enabled) 5150 if (il->ht.enabled)
5270 ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; 5151 il->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
5271 5152
5272 D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", 5153 D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n",
5273 ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); 5154 il->qos_data.qos_active, il->qos_data.def_qos_parm.qos_flags);
5274 5155
5275 il_send_cmd_pdu_async(il, ctx->qos_cmd, sizeof(struct il_qosparam_cmd), 5156 il_send_cmd_pdu_async(il, C_QOS_PARAM, sizeof(struct il_qosparam_cmd),
5276 &ctx->qos_data.def_qos_parm, NULL); 5157 &il->qos_data.def_qos_parm, NULL);
5277} 5158}
5278 5159
5279/** 5160/**
@@ -5287,14 +5168,13 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
5287 struct ieee80211_conf *conf = &hw->conf; 5168 struct ieee80211_conf *conf = &hw->conf;
5288 struct ieee80211_channel *channel = conf->channel; 5169 struct ieee80211_channel *channel = conf->channel;
5289 struct il_ht_config *ht_conf = &il->current_ht_config; 5170 struct il_ht_config *ht_conf = &il->current_ht_config;
5290 struct il_rxon_context *ctx = &il->ctx;
5291 unsigned long flags = 0; 5171 unsigned long flags = 0;
5292 int ret = 0; 5172 int ret = 0;
5293 u16 ch; 5173 u16 ch;
5294 int scan_active = 0; 5174 int scan_active = 0;
5295 bool ht_changed = false; 5175 bool ht_changed = false;
5296 5176
5297 if (WARN_ON(!il->cfg->ops->legacy)) 5177 if (WARN_ON(!il->ops->legacy))
5298 return -EOPNOTSUPP; 5178 return -EOPNOTSUPP;
5299 5179
5300 mutex_lock(&il->mutex); 5180 mutex_lock(&il->mutex);
@@ -5319,8 +5199,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
5319 * set up the SM PS mode to OFF if an HT channel is 5199 * set up the SM PS mode to OFF if an HT channel is
5320 * configured. 5200 * configured.
5321 */ 5201 */
5322 if (il->cfg->ops->hcmd->set_rxon_chain) 5202 if (il->ops->hcmd->set_rxon_chain)
5323 il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); 5203 il->ops->hcmd->set_rxon_chain(il);
5324 } 5204 }
5325 5205
5326 /* during scanning mac80211 will delay channel setting until 5206 /* during scanning mac80211 will delay channel setting until
@@ -5349,48 +5229,48 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
5349 spin_lock_irqsave(&il->lock, flags); 5229 spin_lock_irqsave(&il->lock, flags);
5350 5230
5351 /* Configure HT40 channels */ 5231 /* Configure HT40 channels */
5352 if (ctx->ht.enabled != conf_is_ht(conf)) { 5232 if (il->ht.enabled != conf_is_ht(conf)) {
5353 ctx->ht.enabled = conf_is_ht(conf); 5233 il->ht.enabled = conf_is_ht(conf);
5354 ht_changed = true; 5234 ht_changed = true;
5355 } 5235 }
5356 if (ctx->ht.enabled) { 5236 if (il->ht.enabled) {
5357 if (conf_is_ht40_minus(conf)) { 5237 if (conf_is_ht40_minus(conf)) {
5358 ctx->ht.extension_chan_offset = 5238 il->ht.extension_chan_offset =
5359 IEEE80211_HT_PARAM_CHA_SEC_BELOW; 5239 IEEE80211_HT_PARAM_CHA_SEC_BELOW;
5360 ctx->ht.is_40mhz = true; 5240 il->ht.is_40mhz = true;
5361 } else if (conf_is_ht40_plus(conf)) { 5241 } else if (conf_is_ht40_plus(conf)) {
5362 ctx->ht.extension_chan_offset = 5242 il->ht.extension_chan_offset =
5363 IEEE80211_HT_PARAM_CHA_SEC_ABOVE; 5243 IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
5364 ctx->ht.is_40mhz = true; 5244 il->ht.is_40mhz = true;
5365 } else { 5245 } else {
5366 ctx->ht.extension_chan_offset = 5246 il->ht.extension_chan_offset =
5367 IEEE80211_HT_PARAM_CHA_SEC_NONE; 5247 IEEE80211_HT_PARAM_CHA_SEC_NONE;
5368 ctx->ht.is_40mhz = false; 5248 il->ht.is_40mhz = false;
5369 } 5249 }
5370 } else 5250 } else
5371 ctx->ht.is_40mhz = false; 5251 il->ht.is_40mhz = false;
5372 5252
5373 /* 5253 /*
5374 * Default to no protection. Protection mode will 5254 * Default to no protection. Protection mode will
5375 * later be set from BSS config in il_ht_conf 5255 * later be set from BSS config in il_ht_conf
5376 */ 5256 */
5377 ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; 5257 il->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
5378 5258
5379 /* if we are switching from ht to 2.4 clear flags 5259 /* if we are switching from ht to 2.4 clear flags
5380 * from any ht related info since 2.4 does not 5260 * from any ht related info since 2.4 does not
5381 * support ht */ 5261 * support ht */
5382 if ((le16_to_cpu(ctx->staging.channel) != ch)) 5262 if ((le16_to_cpu(il->staging.channel) != ch))
5383 ctx->staging.flags = 0; 5263 il->staging.flags = 0;
5384 5264
5385 il_set_rxon_channel(il, channel, ctx); 5265 il_set_rxon_channel(il, channel);
5386 il_set_rxon_ht(il, ht_conf); 5266 il_set_rxon_ht(il, ht_conf);
5387 5267
5388 il_set_flags_for_band(il, ctx, channel->band, ctx->vif); 5268 il_set_flags_for_band(il, channel->band, il->vif);
5389 5269
5390 spin_unlock_irqrestore(&il->lock, flags); 5270 spin_unlock_irqrestore(&il->lock, flags);
5391 5271
5392 if (il->cfg->ops->legacy->update_bcast_stations) 5272 if (il->ops->legacy->update_bcast_stations)
5393 ret = il->cfg->ops->legacy->update_bcast_stations(il); 5273 ret = il->ops->legacy->update_bcast_stations(il);
5394 5274
5395set_ch_out: 5275set_ch_out:
5396 /* The list of supported rates and rate mask can be different 5276 /* The list of supported rates and rate mask can be different
@@ -5420,12 +5300,12 @@ set_ch_out:
5420 if (scan_active) 5300 if (scan_active)
5421 goto out; 5301 goto out;
5422 5302
5423 if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) 5303 if (memcmp(&il->active, &il->staging, sizeof(il->staging)))
5424 il_commit_rxon(il, ctx); 5304 il_commit_rxon(il);
5425 else 5305 else
5426 D_INFO("Not re-sending same RXON configuration.\n"); 5306 D_INFO("Not re-sending same RXON configuration.\n");
5427 if (ht_changed) 5307 if (ht_changed)
5428 il_update_qos(il, ctx); 5308 il_update_qos(il);
5429 5309
5430out: 5310out:
5431 D_MAC80211("leave\n"); 5311 D_MAC80211("leave\n");
@@ -5439,9 +5319,8 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
5439{ 5319{
5440 struct il_priv *il = hw->priv; 5320 struct il_priv *il = hw->priv;
5441 unsigned long flags; 5321 unsigned long flags;
5442 struct il_rxon_context *ctx = &il->ctx;
5443 5322
5444 if (WARN_ON(!il->cfg->ops->legacy)) 5323 if (WARN_ON(!il->ops->legacy))
5445 return; 5324 return;
5446 5325
5447 mutex_lock(&il->mutex); 5326 mutex_lock(&il->mutex);
@@ -5473,8 +5352,8 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
5473 /* we are restarting association process 5352 /* we are restarting association process
5474 * clear RXON_FILTER_ASSOC_MSK bit 5353 * clear RXON_FILTER_ASSOC_MSK bit
5475 */ 5354 */
5476 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 5355 il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
5477 il_commit_rxon(il, ctx); 5356 il_commit_rxon(il);
5478 5357
5479 il_set_rate(il); 5358 il_set_rate(il);
5480 5359
@@ -5490,16 +5369,15 @@ il_ht_conf(struct il_priv *il, struct ieee80211_vif *vif)
5490 struct il_ht_config *ht_conf = &il->current_ht_config; 5369 struct il_ht_config *ht_conf = &il->current_ht_config;
5491 struct ieee80211_sta *sta; 5370 struct ieee80211_sta *sta;
5492 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; 5371 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
5493 struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif);
5494 5372
5495 D_ASSOC("enter:\n"); 5373 D_ASSOC("enter:\n");
5496 5374
5497 if (!ctx->ht.enabled) 5375 if (!il->ht.enabled)
5498 return; 5376 return;
5499 5377
5500 ctx->ht.protection = 5378 il->ht.protection =
5501 bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; 5379 bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
5502 ctx->ht.non_gf_sta_present = 5380 il->ht.non_gf_sta_present =
5503 !!(bss_conf-> 5381 !!(bss_conf->
5504 ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); 5382 ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
5505 5383
@@ -5548,16 +5426,14 @@ il_ht_conf(struct il_priv *il, struct ieee80211_vif *vif)
5548static inline void 5426static inline void
5549il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif) 5427il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif)
5550{ 5428{
5551 struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif);
5552
5553 /* 5429 /*
5554 * inform the ucode that there is no longer an 5430 * inform the ucode that there is no longer an
5555 * association and that no more packets should be 5431 * association and that no more packets should be
5556 * sent 5432 * sent
5557 */ 5433 */
5558 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 5434 il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
5559 ctx->staging.assoc_id = 0; 5435 il->staging.assoc_id = 0;
5560 il_commit_rxon(il, ctx); 5436 il_commit_rxon(il);
5561} 5437}
5562 5438
5563static void 5439static void
@@ -5575,8 +5451,8 @@ il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
5575 5451
5576 lockdep_assert_held(&il->mutex); 5452 lockdep_assert_held(&il->mutex);
5577 5453
5578 if (!il->beacon_ctx) { 5454 if (!il->beacon_enabled) {
5579 IL_ERR("update beacon but no beacon context!\n"); 5455 IL_ERR("update beacon with no beaconing enabled\n");
5580 dev_kfree_skb(skb); 5456 dev_kfree_skb(skb);
5581 return; 5457 return;
5582 } 5458 }
@@ -5599,7 +5475,7 @@ il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
5599 return; 5475 return;
5600 } 5476 }
5601 5477
5602 il->cfg->ops->legacy->post_associate(il); 5478 il->ops->legacy->post_associate(il);
5603} 5479}
5604 5480
5605void 5481void
@@ -5607,10 +5483,9 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5607 struct ieee80211_bss_conf *bss_conf, u32 changes) 5483 struct ieee80211_bss_conf *bss_conf, u32 changes)
5608{ 5484{
5609 struct il_priv *il = hw->priv; 5485 struct il_priv *il = hw->priv;
5610 struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif);
5611 int ret; 5486 int ret;
5612 5487
5613 if (WARN_ON(!il->cfg->ops->legacy)) 5488 if (WARN_ON(!il->ops->legacy))
5614 return; 5489 return;
5615 5490
5616 D_MAC80211("changes = 0x%X\n", changes); 5491 D_MAC80211("changes = 0x%X\n", changes);
@@ -5626,21 +5501,17 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5626 unsigned long flags; 5501 unsigned long flags;
5627 5502
5628 spin_lock_irqsave(&il->lock, flags); 5503 spin_lock_irqsave(&il->lock, flags);
5629 ctx->qos_data.qos_active = bss_conf->qos; 5504 il->qos_data.qos_active = bss_conf->qos;
5630 il_update_qos(il, ctx); 5505 il_update_qos(il);
5631 spin_unlock_irqrestore(&il->lock, flags); 5506 spin_unlock_irqrestore(&il->lock, flags);
5632 } 5507 }
5633 5508
5634 if (changes & BSS_CHANGED_BEACON_ENABLED) { 5509 if (changes & BSS_CHANGED_BEACON_ENABLED) {
5635 /* 5510 /* FIXME: can we remove beacon_enabled ? */
5636 * the add_interface code must make sure we only ever
5637 * have a single interface that could be beaconing at
5638 * any time.
5639 */
5640 if (vif->bss_conf.enable_beacon) 5511 if (vif->bss_conf.enable_beacon)
5641 il->beacon_ctx = ctx; 5512 il->beacon_enabled = true;
5642 else 5513 else
5643 il->beacon_ctx = NULL; 5514 il->beacon_enabled = false;
5644 } 5515 }
5645 5516
5646 if (changes & BSS_CHANGED_BSSID) { 5517 if (changes & BSS_CHANGED_BSSID) {
@@ -5660,13 +5531,13 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5660 5531
5661 /* mac80211 only sets assoc when in STATION mode */ 5532 /* mac80211 only sets assoc when in STATION mode */
5662 if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { 5533 if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) {
5663 memcpy(ctx->staging.bssid_addr, bss_conf->bssid, 5534 memcpy(il->staging.bssid_addr, bss_conf->bssid,
5664 ETH_ALEN); 5535 ETH_ALEN);
5665 5536
5666 /* currently needed in a few places */ 5537 /* currently needed in a few places */
5667 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); 5538 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN);
5668 } else { 5539 } else {
5669 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 5540 il->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
5670 } 5541 }
5671 5542
5672 } 5543 }
@@ -5682,21 +5553,21 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5682 if (changes & BSS_CHANGED_ERP_PREAMBLE) { 5553 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
5683 D_MAC80211("ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); 5554 D_MAC80211("ERP_PREAMBLE %d\n", bss_conf->use_short_preamble);
5684 if (bss_conf->use_short_preamble) 5555 if (bss_conf->use_short_preamble)
5685 ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 5556 il->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
5686 else 5557 else
5687 ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 5558 il->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
5688 } 5559 }
5689 5560
5690 if (changes & BSS_CHANGED_ERP_CTS_PROT) { 5561 if (changes & BSS_CHANGED_ERP_CTS_PROT) {
5691 D_MAC80211("ERP_CTS %d\n", bss_conf->use_cts_prot); 5562 D_MAC80211("ERP_CTS %d\n", bss_conf->use_cts_prot);
5692 if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) 5563 if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ)
5693 ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; 5564 il->staging.flags |= RXON_FLG_TGG_PROTECT_MSK;
5694 else 5565 else
5695 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; 5566 il->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
5696 if (bss_conf->use_cts_prot) 5567 if (bss_conf->use_cts_prot)
5697 ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; 5568 il->staging.flags |= RXON_FLG_SELF_CTS_EN;
5698 else 5569 else
5699 ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; 5570 il->staging.flags &= ~RXON_FLG_SELF_CTS_EN;
5700 } 5571 }
5701 5572
5702 if (changes & BSS_CHANGED_BASIC_RATES) { 5573 if (changes & BSS_CHANGED_BASIC_RATES) {
@@ -5706,12 +5577,12 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5706 * like this here: 5577 * like this here:
5707 * 5578 *
5708 if (A-band) 5579 if (A-band)
5709 ctx->staging.ofdm_basic_rates = 5580 il->staging.ofdm_basic_rates =
5710 bss_conf->basic_rates; 5581 bss_conf->basic_rates;
5711 else 5582 else
5712 ctx->staging.ofdm_basic_rates = 5583 il->staging.ofdm_basic_rates =
5713 bss_conf->basic_rates >> 4; 5584 bss_conf->basic_rates >> 4;
5714 ctx->staging.cck_basic_rates = 5585 il->staging.cck_basic_rates =
5715 bss_conf->basic_rates & 0xF; 5586 bss_conf->basic_rates & 0xF;
5716 */ 5587 */
5717 } 5588 }
@@ -5719,8 +5590,8 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5719 if (changes & BSS_CHANGED_HT) { 5590 if (changes & BSS_CHANGED_HT) {
5720 il_ht_conf(il, vif); 5591 il_ht_conf(il, vif);
5721 5592
5722 if (il->cfg->ops->hcmd->set_rxon_chain) 5593 if (il->ops->hcmd->set_rxon_chain)
5723 il->cfg->ops->hcmd->set_rxon_chain(il, ctx); 5594 il->ops->hcmd->set_rxon_chain(il);
5724 } 5595 }
5725 5596
5726 if (changes & BSS_CHANGED_ASSOC) { 5597 if (changes & BSS_CHANGED_ASSOC) {
@@ -5729,36 +5600,35 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5729 il->timestamp = bss_conf->timestamp; 5600 il->timestamp = bss_conf->timestamp;
5730 5601
5731 if (!il_is_rfkill(il)) 5602 if (!il_is_rfkill(il))
5732 il->cfg->ops->legacy->post_associate(il); 5603 il->ops->legacy->post_associate(il);
5733 } else 5604 } else
5734 il_set_no_assoc(il, vif); 5605 il_set_no_assoc(il, vif);
5735 } 5606 }
5736 5607
5737 if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { 5608 if (changes && il_is_associated(il) && bss_conf->aid) {
5738 D_MAC80211("Changes (%#x) while associated\n", changes); 5609 D_MAC80211("Changes (%#x) while associated\n", changes);
5739 ret = il_send_rxon_assoc(il, ctx); 5610 ret = il_send_rxon_assoc(il);
5740 if (!ret) { 5611 if (!ret) {
5741 /* Sync active_rxon with latest change. */ 5612 /* Sync active_rxon with latest change. */
5742 memcpy((void *)&ctx->active, &ctx->staging, 5613 memcpy((void *)&il->active, &il->staging,
5743 sizeof(struct il_rxon_cmd)); 5614 sizeof(struct il_rxon_cmd));
5744 } 5615 }
5745 } 5616 }
5746 5617
5747 if (changes & BSS_CHANGED_BEACON_ENABLED) { 5618 if (changes & BSS_CHANGED_BEACON_ENABLED) {
5748 if (vif->bss_conf.enable_beacon) { 5619 if (vif->bss_conf.enable_beacon) {
5749 memcpy(ctx->staging.bssid_addr, bss_conf->bssid, 5620 memcpy(il->staging.bssid_addr, bss_conf->bssid,
5750 ETH_ALEN); 5621 ETH_ALEN);
5751 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); 5622 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN);
5752 il->cfg->ops->legacy->config_ap(il); 5623 il->ops->legacy->config_ap(il);
5753 } else 5624 } else
5754 il_set_no_assoc(il, vif); 5625 il_set_no_assoc(il, vif);
5755 } 5626 }
5756 5627
5757 if (changes & BSS_CHANGED_IBSS) { 5628 if (changes & BSS_CHANGED_IBSS) {
5758 ret = 5629 ret =
5759 il->cfg->ops->legacy->manage_ibss_station(il, vif, 5630 il->ops->legacy->manage_ibss_station(il, vif,
5760 bss_conf-> 5631 bss_conf->ibss_joined);
5761 ibss_joined);
5762 if (ret) 5632 if (ret)
5763 IL_ERR("failed to %s IBSS station %pM\n", 5633 IL_ERR("failed to %s IBSS station %pM\n",
5764 bss_conf->ibss_joined ? "add" : "remove", 5634 bss_conf->ibss_joined ? "add" : "remove",