aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-05-18 17:48:30 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-18 17:48:30 -0400
commit82d048186e403f36e083b37ad42aa90abb7dcaac (patch)
treedc0b92ace036ef435318f38ef35b8c6e6b84103a /drivers/net
parent62551d3ea05242d97d47f26fb517b2dfdb752310 (diff)
parentd3707d9918d47c0997a6b1e4ae24e7ab55e43796 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c51
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c59
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/phy.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/phy.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c89
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c89
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c62
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c233
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h39
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c56
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c2
-rw-r--r--drivers/net/wireless/mwl8k.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c2
-rw-r--r--drivers/net/wireless/wl12xx/Kconfig2
23 files changed, 252 insertions, 483 deletions
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index 44fee5ae8925..a2fda702b620 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -694,7 +694,7 @@ static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
694#undef TMP_VAL_VPD_TABLE 694#undef TMP_VAL_VPD_TABLE
695} 695}
696 696
697static bool ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah, 697static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
698 struct ath9k_channel *chan, 698 struct ath9k_channel *chan,
699 int16_t *pTxPowerIndexOffset) 699 int16_t *pTxPowerIndexOffset)
700{ 700{
@@ -805,11 +805,9 @@ static bool ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
805 } 805 }
806 806
807 *pTxPowerIndexOffset = 0; 807 *pTxPowerIndexOffset = 0;
808
809 return true;
810} 808}
811 809
812static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah, 810static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
813 struct ath9k_channel *chan, 811 struct ath9k_channel *chan,
814 int16_t *ratesArray, 812 int16_t *ratesArray,
815 u16 cfgCtl, 813 u16 cfgCtl,
@@ -1041,10 +1039,9 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
1041 ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0]; 1039 ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0];
1042 ratesArray[rateExtCck] = targetPowerCckExt.tPow2x[0]; 1040 ratesArray[rateExtCck] = targetPowerCckExt.tPow2x[0];
1043 } 1041 }
1044 return true;
1045} 1042}
1046 1043
1047static int ath9k_hw_4k_set_txpower(struct ath_hw *ah, 1044static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
1048 struct ath9k_channel *chan, 1045 struct ath9k_channel *chan,
1049 u16 cfgCtl, 1046 u16 cfgCtl,
1050 u8 twiceAntennaReduction, 1047 u8 twiceAntennaReduction,
@@ -1065,22 +1062,13 @@ static int ath9k_hw_4k_set_txpower(struct ath_hw *ah,
1065 ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc; 1062 ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
1066 } 1063 }
1067 1064
1068 if (!ath9k_hw_set_4k_power_per_rate_table(ah, chan, 1065 ath9k_hw_set_4k_power_per_rate_table(ah, chan,
1069 &ratesArray[0], cfgCtl, 1066 &ratesArray[0], cfgCtl,
1070 twiceAntennaReduction, 1067 twiceAntennaReduction,
1071 twiceMaxRegulatoryPower, 1068 twiceMaxRegulatoryPower,
1072 powerLimit)) { 1069 powerLimit);
1073 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
1074 "ath9k_hw_set_txpower: unable to set "
1075 "tx power per rate table\n");
1076 return -EIO;
1077 }
1078 1070
1079 if (!ath9k_hw_set_4k_power_cal_table(ah, chan, &txPowerIndexOffset)) { 1071 ath9k_hw_set_4k_power_cal_table(ah, chan, &txPowerIndexOffset);
1080 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
1081 "ath9k_hw_set_txpower: unable to set power table\n");
1082 return -EIO;
1083 }
1084 1072
1085 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) { 1073 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
1086 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]); 1074 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
@@ -1168,7 +1156,6 @@ static int ath9k_hw_4k_set_txpower(struct ath_hw *ah,
1168 else 1156 else
1169 ah->regulatory.max_power_level = ratesArray[i]; 1157 ah->regulatory.max_power_level = ratesArray[i];
1170 1158
1171 return 0;
1172} 1159}
1173 1160
1174static void ath9k_hw_4k_set_addac(struct ath_hw *ah, 1161static void ath9k_hw_4k_set_addac(struct ath_hw *ah,
@@ -2103,7 +2090,7 @@ static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hw *ah,
2103 return; 2090 return;
2104} 2091}
2105 2092
2106static bool ath9k_hw_set_def_power_cal_table(struct ath_hw *ah, 2093static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
2107 struct ath9k_channel *chan, 2094 struct ath9k_channel *chan,
2108 int16_t *pTxPowerIndexOffset) 2095 int16_t *pTxPowerIndexOffset)
2109{ 2096{
@@ -2255,13 +2242,11 @@ static bool ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
2255 } 2242 }
2256 2243
2257 *pTxPowerIndexOffset = 0; 2244 *pTxPowerIndexOffset = 0;
2258
2259 return true;
2260#undef SM_PD_GAIN 2245#undef SM_PD_GAIN
2261#undef SM_PDGAIN_B 2246#undef SM_PDGAIN_B
2262} 2247}
2263 2248
2264static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah, 2249static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
2265 struct ath9k_channel *chan, 2250 struct ath9k_channel *chan,
2266 int16_t *ratesArray, 2251 int16_t *ratesArray,
2267 u16 cfgCtl, 2252 u16 cfgCtl,
@@ -2549,10 +2534,9 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
2549 targetPowerCckExt.tPow2x[0]; 2534 targetPowerCckExt.tPow2x[0];
2550 } 2535 }
2551 } 2536 }
2552 return true;
2553} 2537}
2554 2538
2555static int ath9k_hw_def_set_txpower(struct ath_hw *ah, 2539static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
2556 struct ath9k_channel *chan, 2540 struct ath9k_channel *chan,
2557 u16 cfgCtl, 2541 u16 cfgCtl,
2558 u8 twiceAntennaReduction, 2542 u8 twiceAntennaReduction,
@@ -2575,22 +2559,13 @@ static int ath9k_hw_def_set_txpower(struct ath_hw *ah,
2575 ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc; 2559 ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
2576 } 2560 }
2577 2561
2578 if (!ath9k_hw_set_def_power_per_rate_table(ah, chan, 2562 ath9k_hw_set_def_power_per_rate_table(ah, chan,
2579 &ratesArray[0], cfgCtl, 2563 &ratesArray[0], cfgCtl,
2580 twiceAntennaReduction, 2564 twiceAntennaReduction,
2581 twiceMaxRegulatoryPower, 2565 twiceMaxRegulatoryPower,
2582 powerLimit)) { 2566 powerLimit);
2583 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
2584 "ath9k_hw_set_txpower: unable to set "
2585 "tx power per rate table\n");
2586 return -EIO;
2587 }
2588 2567
2589 if (!ath9k_hw_set_def_power_cal_table(ah, chan, &txPowerIndexOffset)) { 2568 ath9k_hw_set_def_power_cal_table(ah, chan, &txPowerIndexOffset);
2590 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
2591 "ath9k_hw_set_txpower: unable to set power table\n");
2592 return -EIO;
2593 }
2594 2569
2595 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) { 2570 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
2596 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]); 2571 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
@@ -2717,8 +2692,6 @@ static int ath9k_hw_def_set_txpower(struct ath_hw *ah,
2717 "Invalid chainmask configuration\n"); 2692 "Invalid chainmask configuration\n");
2718 break; 2693 break;
2719 } 2694 }
2720
2721 return 0;
2722} 2695}
2723 2696
2724static u8 ath9k_hw_def_get_num_ant_config(struct ath_hw *ah, 2697static u8 ath9k_hw_def_get_num_ant_config(struct ath_hw *ah,
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.h b/drivers/net/wireless/ath/ath9k/eeprom.h
index 7c59dc47f912..67b8bd12941a 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/eeprom.h
@@ -494,7 +494,7 @@ struct eeprom_ops {
494 struct ath9k_channel *chan); 494 struct ath9k_channel *chan);
495 void (*set_board_values)(struct ath_hw *hw, struct ath9k_channel *chan); 495 void (*set_board_values)(struct ath_hw *hw, struct ath9k_channel *chan);
496 void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan); 496 void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
497 int (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan, 497 void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
498 u16 cfgCtl, u8 twiceAntennaReduction, 498 u16 cfgCtl, u8 twiceAntennaReduction,
499 u8 twiceMaxRegulatoryPower, u8 powerLimit); 499 u8 twiceMaxRegulatoryPower, u8 powerLimit);
500 u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz); 500 u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 5879c731e9e7..4acfab514916 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1274,7 +1274,6 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1274 int i, regWrites = 0; 1274 int i, regWrites = 0;
1275 struct ieee80211_channel *channel = chan->chan; 1275 struct ieee80211_channel *channel = chan->chan;
1276 u32 modesIndex, freqIndex; 1276 u32 modesIndex, freqIndex;
1277 int status;
1278 1277
1279 switch (chan->chanmode) { 1278 switch (chan->chanmode) {
1280 case CHANNEL_A: 1279 case CHANNEL_A:
@@ -1376,17 +1375,12 @@ static int ath9k_hw_process_ini(struct ath_hw *ah,
1376 if (OLC_FOR_AR9280_20_LATER) 1375 if (OLC_FOR_AR9280_20_LATER)
1377 ath9k_olc_init(ah); 1376 ath9k_olc_init(ah);
1378 1377
1379 status = ah->eep_ops->set_txpower(ah, chan, 1378 ah->eep_ops->set_txpower(ah, chan,
1380 ath9k_regd_get_ctl(&ah->regulatory, chan), 1379 ath9k_regd_get_ctl(&ah->regulatory, chan),
1381 channel->max_antenna_gain * 2, 1380 channel->max_antenna_gain * 2,
1382 channel->max_power * 2, 1381 channel->max_power * 2,
1383 min((u32) MAX_RATE_POWER, 1382 min((u32) MAX_RATE_POWER,
1384 (u32) ah->regulatory.power_limit)); 1383 (u32) ah->regulatory.power_limit));
1385 if (status != 0) {
1386 DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
1387 "Error initializing transmit power\n");
1388 return -EIO;
1389 }
1390 1384
1391 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) { 1385 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
1392 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, 1386 DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
@@ -1617,11 +1611,9 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)
1617 switch (type) { 1611 switch (type) {
1618 case ATH9K_RESET_POWER_ON: 1612 case ATH9K_RESET_POWER_ON:
1619 return ath9k_hw_set_reset_power_on(ah); 1613 return ath9k_hw_set_reset_power_on(ah);
1620 break;
1621 case ATH9K_RESET_WARM: 1614 case ATH9K_RESET_WARM:
1622 case ATH9K_RESET_COLD: 1615 case ATH9K_RESET_COLD:
1623 return ath9k_hw_set_reset(ah, type); 1616 return ath9k_hw_set_reset(ah, type);
1624 break;
1625 default: 1617 default:
1626 return false; 1618 return false;
1627 } 1619 }
@@ -1703,11 +1695,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
1703 ath9k_hw_set_regs(ah, chan, macmode); 1695 ath9k_hw_set_regs(ah, chan, macmode);
1704 1696
1705 if (AR_SREV_9280_10_OR_LATER(ah)) { 1697 if (AR_SREV_9280_10_OR_LATER(ah)) {
1706 if (!(ath9k_hw_ar9280_set_channel(ah, chan))) { 1698 ath9k_hw_ar9280_set_channel(ah, chan);
1707 DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
1708 "Failed to set channel\n");
1709 return false;
1710 }
1711 } else { 1699 } else {
1712 if (!(ath9k_hw_set_channel(ah, chan))) { 1700 if (!(ath9k_hw_set_channel(ah, chan))) {
1713 DPRINTF(ah->ah_sc, ATH_DBG_FATAL, 1701 DPRINTF(ah->ah_sc, ATH_DBG_FATAL,
@@ -1716,16 +1704,12 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
1716 } 1704 }
1717 } 1705 }
1718 1706
1719 if (ah->eep_ops->set_txpower(ah, chan, 1707 ah->eep_ops->set_txpower(ah, chan,
1720 ath9k_regd_get_ctl(&ah->regulatory, chan), 1708 ath9k_regd_get_ctl(&ah->regulatory, chan),
1721 channel->max_antenna_gain * 2, 1709 channel->max_antenna_gain * 2,
1722 channel->max_power * 2, 1710 channel->max_power * 2,
1723 min((u32) MAX_RATE_POWER, 1711 min((u32) MAX_RATE_POWER,
1724 (u32) ah->regulatory.power_limit)) != 0) { 1712 (u32) ah->regulatory.power_limit));
1725 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
1726 "Error initializing transmit power\n");
1727 return false;
1728 }
1729 1713
1730 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY; 1714 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
1731 if (IS_CHAN_B(chan)) 1715 if (IS_CHAN_B(chan))
@@ -2313,13 +2297,11 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
2313 2297
2314 REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR); 2298 REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
2315 2299
2316 if (AR_SREV_9280_10_OR_LATER(ah)) { 2300 if (AR_SREV_9280_10_OR_LATER(ah))
2317 if (!(ath9k_hw_ar9280_set_channel(ah, chan))) 2301 ath9k_hw_ar9280_set_channel(ah, chan);
2318 return -EIO; 2302 else
2319 } else {
2320 if (!(ath9k_hw_set_channel(ah, chan))) 2303 if (!(ath9k_hw_set_channel(ah, chan)))
2321 return -EIO; 2304 return -EIO;
2322 }
2323 2305
2324 for (i = 0; i < AR_NUM_DCU; i++) 2306 for (i = 0; i < AR_NUM_DCU; i++)
2325 REG_WRITE(ah, AR_DQCUMASK(i), 1 << i); 2307 REG_WRITE(ah, AR_DQCUMASK(i), 1 << i);
@@ -3750,22 +3732,19 @@ bool ath9k_hw_disable(struct ath_hw *ah)
3750 return ath9k_hw_set_reset_reg(ah, ATH9K_RESET_COLD); 3732 return ath9k_hw_set_reset_reg(ah, ATH9K_RESET_COLD);
3751} 3733}
3752 3734
3753bool ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit) 3735void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
3754{ 3736{
3755 struct ath9k_channel *chan = ah->curchan; 3737 struct ath9k_channel *chan = ah->curchan;
3756 struct ieee80211_channel *channel = chan->chan; 3738 struct ieee80211_channel *channel = chan->chan;
3757 3739
3758 ah->regulatory.power_limit = min(limit, (u32) MAX_RATE_POWER); 3740 ah->regulatory.power_limit = min(limit, (u32) MAX_RATE_POWER);
3759 3741
3760 if (ah->eep_ops->set_txpower(ah, chan, 3742 ah->eep_ops->set_txpower(ah, chan,
3761 ath9k_regd_get_ctl(&ah->regulatory, chan), 3743 ath9k_regd_get_ctl(&ah->regulatory, chan),
3762 channel->max_antenna_gain * 2, 3744 channel->max_antenna_gain * 2,
3763 channel->max_power * 2, 3745 channel->max_power * 2,
3764 min((u32) MAX_RATE_POWER, 3746 min((u32) MAX_RATE_POWER,
3765 (u32) ah->regulatory.power_limit)) != 0) 3747 (u32) ah->regulatory.power_limit));
3766 return false;
3767
3768 return true;
3769} 3748}
3770 3749
3771void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac) 3750void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac)
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index ddb24c47ebcf..dd8508ef6e05 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -590,7 +590,7 @@ u32 ath9k_hw_getrxfilter(struct ath_hw *ah);
590void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits); 590void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
591bool ath9k_hw_phy_disable(struct ath_hw *ah); 591bool ath9k_hw_phy_disable(struct ath_hw *ah);
592bool ath9k_hw_disable(struct ath_hw *ah); 592bool ath9k_hw_disable(struct ath_hw *ah);
593bool ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit); 593void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit);
594void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac); 594void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac);
595void ath9k_hw_setopmode(struct ath_hw *ah); 595void ath9k_hw_setopmode(struct ath_hw *ah);
596void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1); 596void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1);
diff --git a/drivers/net/wireless/ath/ath9k/phy.c b/drivers/net/wireless/ath/ath9k/phy.c
index 5ec9ce91d979..aaa941561c36 100644
--- a/drivers/net/wireless/ath/ath9k/phy.c
+++ b/drivers/net/wireless/ath/ath9k/phy.c
@@ -96,9 +96,8 @@ ath9k_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
96 return true; 96 return true;
97} 97}
98 98
99bool 99void ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
100ath9k_hw_ar9280_set_channel(struct ath_hw *ah, 100 struct ath9k_channel *chan)
101 struct ath9k_channel *chan)
102{ 101{
103 u16 bMode, fracMode, aModeRefSel = 0; 102 u16 bMode, fracMode, aModeRefSel = 0;
104 u32 freq, ndiv, channelSel = 0, channelFrac = 0, reg32 = 0; 103 u32 freq, ndiv, channelSel = 0, channelFrac = 0, reg32 = 0;
@@ -169,8 +168,6 @@ ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
169 168
170 ah->curchan = chan; 169 ah->curchan = chan;
171 ah->curchan_rad_index = -1; 170 ah->curchan_rad_index = -1;
172
173 return true;
174} 171}
175 172
176static void 173static void
diff --git a/drivers/net/wireless/ath/ath9k/phy.h b/drivers/net/wireless/ath/ath9k/phy.h
index 296d0e985f25..c70f530642f6 100644
--- a/drivers/net/wireless/ath/ath9k/phy.h
+++ b/drivers/net/wireless/ath/ath9k/phy.h
@@ -17,7 +17,7 @@
17#ifndef PHY_H 17#ifndef PHY_H
18#define PHY_H 18#define PHY_H
19 19
20bool ath9k_hw_ar9280_set_channel(struct ath_hw *ah, 20void ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
21 struct ath9k_channel 21 struct ath9k_channel
22 *chan); 22 *chan);
23bool ath9k_hw_set_channel(struct ath_hw *ah, 23bool ath9k_hw_set_channel(struct ath_hw *ah,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 41f1d66cfeba..5b0c6e5bda92 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -1110,6 +1110,11 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
1110 1110
1111 spin_lock_irqsave(&priv->lock, flags); 1111 spin_lock_irqsave(&priv->lock, flags);
1112 1112
1113 /* Determine HW type */
1114 pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id);
1115
1116 IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id);
1117
1113 if (rev_id & PCI_CFG_REV_ID_BIT_RTP) 1118 if (rev_id & PCI_CFG_REV_ID_BIT_RTP)
1114 IWL_DEBUG_INFO(priv, "RTP type \n"); 1119 IWL_DEBUG_INFO(priv, "RTP type \n");
1115 else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { 1120 else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) {
@@ -1163,7 +1168,6 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
1163 1168
1164int iwl3945_hw_nic_init(struct iwl_priv *priv) 1169int iwl3945_hw_nic_init(struct iwl_priv *priv)
1165{ 1170{
1166 u8 rev_id;
1167 int rc; 1171 int rc;
1168 unsigned long flags; 1172 unsigned long flags;
1169 struct iwl_rx_queue *rxq = &priv->rxq; 1173 struct iwl_rx_queue *rxq = &priv->rxq;
@@ -1172,12 +1176,6 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv)
1172 priv->cfg->ops->lib->apm_ops.init(priv); 1176 priv->cfg->ops->lib->apm_ops.init(priv);
1173 spin_unlock_irqrestore(&priv->lock, flags); 1177 spin_unlock_irqrestore(&priv->lock, flags);
1174 1178
1175 /* Determine HW type */
1176 rc = pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id);
1177 if (rc)
1178 return rc;
1179 IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id);
1180
1181 rc = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN); 1179 rc = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN);
1182 if (rc) 1180 if (rc)
1183 return rc; 1181 return rc;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 0a71bb55d0ee..4c88e8715df2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -100,6 +100,7 @@ struct iwl_scale_tbl_info {
100 u8 is_fat; /* 1 = 40 MHz channel width */ 100 u8 is_fat; /* 1 = 40 MHz channel width */
101 u8 is_dup; /* 1 = duplicated data streams */ 101 u8 is_dup; /* 1 = duplicated data streams */
102 u8 action; /* change modulation; IWL_[LEGACY/SISO/MIMO]_SWITCH_* */ 102 u8 action; /* change modulation; IWL_[LEGACY/SISO/MIMO]_SWITCH_* */
103 u8 max_search; /* maximun number of tables we can search */
103 s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ 104 s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */
104 u32 current_rate; /* rate_n_flags, uCode API format */ 105 u32 current_rate; /* rate_n_flags, uCode API format */
105 struct iwl_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */ 106 struct iwl_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */
@@ -160,6 +161,7 @@ struct iwl_lq_sta {
160#ifdef CONFIG_MAC80211_DEBUGFS 161#ifdef CONFIG_MAC80211_DEBUGFS
161 struct dentry *rs_sta_dbgfs_scale_table_file; 162 struct dentry *rs_sta_dbgfs_scale_table_file;
162 struct dentry *rs_sta_dbgfs_stats_table_file; 163 struct dentry *rs_sta_dbgfs_stats_table_file;
164 struct dentry *rs_sta_dbgfs_rate_scale_data_file;
163 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; 165 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
164 u32 dbg_fixed_rate; 166 u32 dbg_fixed_rate;
165#endif 167#endif
@@ -579,6 +581,7 @@ static int rs_get_tbl_info_from_mcs(const u32 rate_n_flags,
579 tbl->is_dup = 0; 581 tbl->is_dup = 0;
580 tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); 582 tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS);
581 tbl->lq_type = LQ_NONE; 583 tbl->lq_type = LQ_NONE;
584 tbl->max_search = IWL_MAX_SEARCH;
582 585
583 /* legacy rate format */ 586 /* legacy rate format */
584 if (!(rate_n_flags & RATE_MCS_HT_MSK)) { 587 if (!(rate_n_flags & RATE_MCS_HT_MSK)) {
@@ -612,8 +615,10 @@ static int rs_get_tbl_info_from_mcs(const u32 rate_n_flags,
612 tbl->lq_type = LQ_MIMO2; 615 tbl->lq_type = LQ_MIMO2;
613 /* MIMO3 */ 616 /* MIMO3 */
614 } else { 617 } else {
615 if (num_of_ant == 3) 618 if (num_of_ant == 3) {
619 tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH;
616 tbl->lq_type = LQ_MIMO3; 620 tbl->lq_type = LQ_MIMO3;
621 }
617 } 622 }
618 } 623 }
619 return 0; 624 return 0;
@@ -771,6 +776,7 @@ static u32 rs_get_lower_rate(struct iwl_lq_sta *lq_sta,
771 776
772 tbl->is_fat = 0; 777 tbl->is_fat = 0;
773 tbl->is_SGI = 0; 778 tbl->is_SGI = 0;
779 tbl->max_search = IWL_MAX_SEARCH;
774 } 780 }
775 781
776 rate_mask = rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); 782 rate_mask = rs_get_supported_rates(lq_sta, NULL, tbl->lq_type);
@@ -1026,6 +1032,7 @@ static void rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy,
1026 lq_sta->total_failed = 0; 1032 lq_sta->total_failed = 0;
1027 lq_sta->total_success = 0; 1033 lq_sta->total_success = 0;
1028 lq_sta->flush_timer = jiffies; 1034 lq_sta->flush_timer = jiffies;
1035 lq_sta->action_counter = 0;
1029} 1036}
1030 1037
1031/* 1038/*
@@ -1205,6 +1212,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1205 tbl->lq_type = LQ_MIMO2; 1212 tbl->lq_type = LQ_MIMO2;
1206 tbl->is_dup = lq_sta->is_dup; 1213 tbl->is_dup = lq_sta->is_dup;
1207 tbl->action = 0; 1214 tbl->action = 0;
1215 tbl->max_search = IWL_MAX_SEARCH;
1208 rate_mask = lq_sta->active_mimo2_rate; 1216 rate_mask = lq_sta->active_mimo2_rate;
1209 1217
1210 if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap)) 1218 if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap))
@@ -1270,6 +1278,7 @@ static int rs_switch_to_mimo3(struct iwl_priv *priv,
1270 tbl->lq_type = LQ_MIMO3; 1278 tbl->lq_type = LQ_MIMO3;
1271 tbl->is_dup = lq_sta->is_dup; 1279 tbl->is_dup = lq_sta->is_dup;
1272 tbl->action = 0; 1280 tbl->action = 0;
1281 tbl->max_search = IWL_MAX_11N_MIMO3_SEARCH;
1273 rate_mask = lq_sta->active_mimo3_rate; 1282 rate_mask = lq_sta->active_mimo3_rate;
1274 1283
1275 if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap)) 1284 if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap))
@@ -1328,6 +1337,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1328 tbl->is_dup = lq_sta->is_dup; 1337 tbl->is_dup = lq_sta->is_dup;
1329 tbl->lq_type = LQ_SISO; 1338 tbl->lq_type = LQ_SISO;
1330 tbl->action = 0; 1339 tbl->action = 0;
1340 tbl->max_search = IWL_MAX_SEARCH;
1331 rate_mask = lq_sta->active_siso_rate; 1341 rate_mask = lq_sta->active_siso_rate;
1332 1342
1333 if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap)) 1343 if (iwl_is_fat_tx_allowed(priv, &sta->ht_cap))
@@ -1384,15 +1394,15 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1384 u8 valid_tx_ant = priv->hw_params.valid_tx_ant; 1394 u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
1385 u8 tx_chains_num = priv->hw_params.tx_chains_num; 1395 u8 tx_chains_num = priv->hw_params.tx_chains_num;
1386 int ret = 0; 1396 int ret = 0;
1397 u8 update_search_tbl_counter = 0;
1387 1398
1388 for (; ;) { 1399 for (; ;) {
1400 lq_sta->action_counter++;
1389 switch (tbl->action) { 1401 switch (tbl->action) {
1390 case IWL_LEGACY_SWITCH_ANTENNA1: 1402 case IWL_LEGACY_SWITCH_ANTENNA1:
1391 case IWL_LEGACY_SWITCH_ANTENNA2: 1403 case IWL_LEGACY_SWITCH_ANTENNA2:
1392 IWL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); 1404 IWL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n");
1393 1405
1394 lq_sta->action_counter++;
1395
1396 if ((tbl->action == IWL_LEGACY_SWITCH_ANTENNA1 && 1406 if ((tbl->action == IWL_LEGACY_SWITCH_ANTENNA1 &&
1397 tx_chains_num <= 1) || 1407 tx_chains_num <= 1) ||
1398 (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2 && 1408 (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2 &&
@@ -1408,6 +1418,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1408 1418
1409 if (rs_toggle_antenna(valid_tx_ant, 1419 if (rs_toggle_antenna(valid_tx_ant,
1410 &search_tbl->current_rate, search_tbl)) { 1420 &search_tbl->current_rate, search_tbl)) {
1421 update_search_tbl_counter = 1;
1411 rs_set_expected_tpt_table(lq_sta, search_tbl); 1422 rs_set_expected_tpt_table(lq_sta, search_tbl);
1412 goto out; 1423 goto out;
1413 } 1424 }
@@ -1489,6 +1500,8 @@ out:
1489 tbl->action++; 1500 tbl->action++;
1490 if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC) 1501 if (tbl->action > IWL_LEGACY_SWITCH_MIMO3_ABC)
1491 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; 1502 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
1503 if (update_search_tbl_counter)
1504 search_tbl->action = tbl->action;
1492 return 0; 1505 return 0;
1493 1506
1494} 1507}
@@ -1511,6 +1524,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1511 u8 start_action = tbl->action; 1524 u8 start_action = tbl->action;
1512 u8 valid_tx_ant = priv->hw_params.valid_tx_ant; 1525 u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
1513 u8 tx_chains_num = priv->hw_params.tx_chains_num; 1526 u8 tx_chains_num = priv->hw_params.tx_chains_num;
1527 u8 update_search_tbl_counter = 0;
1514 int ret; 1528 int ret;
1515 1529
1516 for (;;) { 1530 for (;;) {
@@ -1531,8 +1545,10 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1531 1545
1532 memcpy(search_tbl, tbl, sz); 1546 memcpy(search_tbl, tbl, sz);
1533 if (rs_toggle_antenna(valid_tx_ant, 1547 if (rs_toggle_antenna(valid_tx_ant,
1534 &search_tbl->current_rate, search_tbl)) 1548 &search_tbl->current_rate, search_tbl)) {
1549 update_search_tbl_counter = 1;
1535 goto out; 1550 goto out;
1551 }
1536 break; 1552 break;
1537 case IWL_SISO_SWITCH_MIMO2_AB: 1553 case IWL_SISO_SWITCH_MIMO2_AB:
1538 case IWL_SISO_SWITCH_MIMO2_AC: 1554 case IWL_SISO_SWITCH_MIMO2_AC:
@@ -1586,6 +1602,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1586 search_tbl->current_rate = 1602 search_tbl->current_rate =
1587 rate_n_flags_from_tbl(priv, search_tbl, 1603 rate_n_flags_from_tbl(priv, search_tbl,
1588 index, is_green); 1604 index, is_green);
1605 update_search_tbl_counter = 1;
1589 goto out; 1606 goto out;
1590 case IWL_SISO_SWITCH_MIMO3_ABC: 1607 case IWL_SISO_SWITCH_MIMO3_ABC:
1591 IWL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO3\n"); 1608 IWL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO3\n");
@@ -1617,6 +1634,9 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1617 tbl->action++; 1634 tbl->action++;
1618 if (tbl->action > IWL_SISO_SWITCH_MIMO3_ABC) 1635 if (tbl->action > IWL_SISO_SWITCH_MIMO3_ABC)
1619 tbl->action = IWL_SISO_SWITCH_ANTENNA1; 1636 tbl->action = IWL_SISO_SWITCH_ANTENNA1;
1637 if (update_search_tbl_counter)
1638 search_tbl->action = tbl->action;
1639
1620 return 0; 1640 return 0;
1621} 1641}
1622 1642
@@ -1638,6 +1658,7 @@ static int rs_move_mimo2_to_other(struct iwl_priv *priv,
1638 u8 start_action = tbl->action; 1658 u8 start_action = tbl->action;
1639 u8 valid_tx_ant = priv->hw_params.valid_tx_ant; 1659 u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
1640 u8 tx_chains_num = priv->hw_params.tx_chains_num; 1660 u8 tx_chains_num = priv->hw_params.tx_chains_num;
1661 u8 update_search_tbl_counter = 0;
1641 int ret; 1662 int ret;
1642 1663
1643 for (;;) { 1664 for (;;) {
@@ -1655,8 +1676,10 @@ static int rs_move_mimo2_to_other(struct iwl_priv *priv,
1655 1676
1656 memcpy(search_tbl, tbl, sz); 1677 memcpy(search_tbl, tbl, sz);
1657 if (rs_toggle_antenna(valid_tx_ant, 1678 if (rs_toggle_antenna(valid_tx_ant,
1658 &search_tbl->current_rate, search_tbl)) 1679 &search_tbl->current_rate, search_tbl)) {
1680 update_search_tbl_counter = 1;
1659 goto out; 1681 goto out;
1682 }
1660 break; 1683 break;
1661 case IWL_MIMO2_SWITCH_SISO_A: 1684 case IWL_MIMO2_SWITCH_SISO_A:
1662 case IWL_MIMO2_SWITCH_SISO_B: 1685 case IWL_MIMO2_SWITCH_SISO_B:
@@ -1713,6 +1736,7 @@ static int rs_move_mimo2_to_other(struct iwl_priv *priv,
1713 search_tbl->current_rate = 1736 search_tbl->current_rate =
1714 rate_n_flags_from_tbl(priv, search_tbl, 1737 rate_n_flags_from_tbl(priv, search_tbl,
1715 index, is_green); 1738 index, is_green);
1739 update_search_tbl_counter = 1;
1716 goto out; 1740 goto out;
1717 1741
1718 case IWL_MIMO2_SWITCH_MIMO3_ABC: 1742 case IWL_MIMO2_SWITCH_MIMO3_ABC:
@@ -1745,6 +1769,9 @@ static int rs_move_mimo2_to_other(struct iwl_priv *priv,
1745 tbl->action++; 1769 tbl->action++;
1746 if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC) 1770 if (tbl->action > IWL_MIMO2_SWITCH_MIMO3_ABC)
1747 tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; 1771 tbl->action = IWL_MIMO2_SWITCH_ANTENNA1;
1772 if (update_search_tbl_counter)
1773 search_tbl->action = tbl->action;
1774
1748 return 0; 1775 return 0;
1749 1776
1750} 1777}
@@ -1768,6 +1795,7 @@ static int rs_move_mimo3_to_other(struct iwl_priv *priv,
1768 u8 valid_tx_ant = priv->hw_params.valid_tx_ant; 1795 u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
1769 u8 tx_chains_num = priv->hw_params.tx_chains_num; 1796 u8 tx_chains_num = priv->hw_params.tx_chains_num;
1770 int ret; 1797 int ret;
1798 u8 update_search_tbl_counter = 0;
1771 1799
1772 for (;;) { 1800 for (;;) {
1773 lq_sta->action_counter++; 1801 lq_sta->action_counter++;
@@ -1866,6 +1894,7 @@ static int rs_move_mimo3_to_other(struct iwl_priv *priv,
1866 search_tbl->current_rate = 1894 search_tbl->current_rate =
1867 rate_n_flags_from_tbl(priv, search_tbl, 1895 rate_n_flags_from_tbl(priv, search_tbl,
1868 index, is_green); 1896 index, is_green);
1897 update_search_tbl_counter = 1;
1869 goto out; 1898 goto out;
1870 } 1899 }
1871 tbl->action++; 1900 tbl->action++;
@@ -1882,6 +1911,9 @@ static int rs_move_mimo3_to_other(struct iwl_priv *priv,
1882 tbl->action++; 1911 tbl->action++;
1883 if (tbl->action > IWL_MIMO3_SWITCH_GI) 1912 if (tbl->action > IWL_MIMO3_SWITCH_GI)
1884 tbl->action = IWL_MIMO3_SWITCH_ANTENNA1; 1913 tbl->action = IWL_MIMO3_SWITCH_ANTENNA1;
1914 if (update_search_tbl_counter)
1915 search_tbl->action = tbl->action;
1916
1885 return 0; 1917 return 0;
1886 1918
1887} 1919}
@@ -2326,8 +2358,7 @@ lq_update:
2326 * before next round of mode comparisons. */ 2358 * before next round of mode comparisons. */
2327 tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); 2359 tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]);
2328 if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && 2360 if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) &&
2329 lq_sta->action_counter >= 1) { 2361 lq_sta->action_counter > tbl1->max_search) {
2330 lq_sta->action_counter = 0;
2331 IWL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); 2362 IWL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n");
2332 rs_set_stay_in_table(priv, 1, lq_sta); 2363 rs_set_stay_in_table(priv, 1, lq_sta);
2333 } 2364 }
@@ -2336,7 +2367,7 @@ lq_update:
2336 * have been tried and compared, stay in this best modulation 2367 * have been tried and compared, stay in this best modulation
2337 * mode for a while before next round of mode comparisons. */ 2368 * mode for a while before next round of mode comparisons. */
2338 if (lq_sta->enable_counter && 2369 if (lq_sta->enable_counter &&
2339 (lq_sta->action_counter >= IWL_ACTION_LIMIT)) { 2370 (lq_sta->action_counter >= tbl1->max_search)) {
2340 if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && 2371 if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) &&
2341 (lq_sta->tx_agg_tid_en & (1 << tid)) && 2372 (lq_sta->tx_agg_tid_en & (1 << tid)) &&
2342 (tid != MAX_TID_COUNT)) { 2373 (tid != MAX_TID_COUNT)) {
@@ -2350,7 +2381,6 @@ lq_update:
2350 lq_sta, sta); 2381 lq_sta, sta);
2351 } 2382 }
2352 } 2383 }
2353 lq_sta->action_counter = 0;
2354 rs_set_stay_in_table(priv, 0, lq_sta); 2384 rs_set_stay_in_table(priv, 0, lq_sta);
2355 } 2385 }
2356 } 2386 }
@@ -2955,6 +2985,43 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
2955 .open = open_file_generic, 2985 .open = open_file_generic,
2956}; 2986};
2957 2987
2988static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
2989 char __user *user_buf, size_t count, loff_t *ppos)
2990{
2991 char buff[120];
2992 int desc = 0;
2993 ssize_t ret;
2994
2995 struct iwl_lq_sta *lq_sta = file->private_data;
2996 struct iwl_priv *priv;
2997 struct iwl_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl];
2998
2999 priv = lq_sta->drv;
3000
3001 if (is_Ht(tbl->lq_type))
3002 desc += sprintf(buff+desc,
3003 "Bit Rate= %d Mb/s\n",
3004 tbl->expected_tpt[lq_sta->last_txrate_idx]);
3005 else
3006 desc += sprintf(buff+desc,
3007 "Bit Rate= %d Mb/s\n",
3008 iwl_rates[lq_sta->last_txrate_idx].ieee >> 1);
3009 desc += sprintf(buff+desc,
3010 "Signal Level= %d dBm\tNoise Level= %d dBm\n",
3011 priv->last_rx_rssi, priv->last_rx_noise);
3012 desc += sprintf(buff+desc,
3013 "Tsf= 0x%llx\tBeacon time= 0x%08X\n",
3014 priv->last_tsf, priv->last_beacon_time);
3015
3016 ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
3017 return ret;
3018}
3019
3020static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
3021 .read = rs_sta_dbgfs_rate_scale_data_read,
3022 .open = open_file_generic,
3023};
3024
2958static void rs_add_debugfs(void *priv, void *priv_sta, 3025static void rs_add_debugfs(void *priv, void *priv_sta,
2959 struct dentry *dir) 3026 struct dentry *dir)
2960{ 3027{
@@ -2965,6 +3032,9 @@ static void rs_add_debugfs(void *priv, void *priv_sta,
2965 lq_sta->rs_sta_dbgfs_stats_table_file = 3032 lq_sta->rs_sta_dbgfs_stats_table_file =
2966 debugfs_create_file("rate_stats_table", 0600, dir, 3033 debugfs_create_file("rate_stats_table", 0600, dir,
2967 lq_sta, &rs_sta_dbgfs_stats_table_ops); 3034 lq_sta, &rs_sta_dbgfs_stats_table_ops);
3035 lq_sta->rs_sta_dbgfs_rate_scale_data_file =
3036 debugfs_create_file("rate_scale_data", 0600, dir,
3037 lq_sta, &rs_sta_dbgfs_rate_scale_data_ops);
2968 lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = 3038 lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file =
2969 debugfs_create_u8("tx_agg_tid_enable", 0600, dir, 3039 debugfs_create_u8("tx_agg_tid_enable", 0600, dir,
2970 &lq_sta->tx_agg_tid_en); 3040 &lq_sta->tx_agg_tid_en);
@@ -2976,6 +3046,7 @@ static void rs_remove_debugfs(void *priv, void *priv_sta)
2976 struct iwl_lq_sta *lq_sta = priv_sta; 3046 struct iwl_lq_sta *lq_sta = priv_sta;
2977 debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); 3047 debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file);
2978 debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); 3048 debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file);
3049 debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file);
2979 debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); 3050 debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file);
2980} 3051}
2981#endif 3052#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index f875136bc5dc..25050bf315a2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -275,6 +275,8 @@ enum {
275#define IWL_MIMO3_SWITCH_GI 8 275#define IWL_MIMO3_SWITCH_GI 8
276 276
277 277
278#define IWL_MAX_11N_MIMO3_SEARCH IWL_MIMO3_SWITCH_GI
279#define IWL_MAX_SEARCH IWL_MIMO2_SWITCH_MIMO3_ABC
278 280
279/*FIXME:RS:add possible actions for MIMO3*/ 281/*FIXME:RS:add possible actions for MIMO3*/
280 282
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 6cdee0b4b486..3ebf6cf53a51 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -190,8 +190,7 @@ int iwl_commit_rxon(struct iwl_priv *priv)
190 190
191 priv->cfg->ops->smgmt->clear_station_table(priv); 191 priv->cfg->ops->smgmt->clear_station_table(priv);
192 192
193 if (!priv->error_recovering) 193 priv->start_calib = 0;
194 priv->start_calib = 0;
195 194
196 /* Add the broadcast address so we can send broadcast frames */ 195 /* Add the broadcast address so we can send broadcast frames */
197 if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) == 196 if (iwl_rxon_add_station(priv, iwl_bcast_addr, 0) ==
@@ -967,23 +966,6 @@ static inline void iwl_synchronize_irq(struct iwl_priv *priv)
967 tasklet_kill(&priv->irq_tasklet); 966 tasklet_kill(&priv->irq_tasklet);
968} 967}
969 968
970static void iwl_error_recovery(struct iwl_priv *priv)
971{
972 unsigned long flags;
973
974 memcpy(&priv->staging_rxon, &priv->recovery_rxon,
975 sizeof(priv->staging_rxon));
976 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
977 iwlcore_commit_rxon(priv);
978
979 iwl_rxon_add_station(priv, priv->bssid, 1);
980
981 spin_lock_irqsave(&priv->lock, flags);
982 priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id);
983 priv->error_recovering = 0;
984 spin_unlock_irqrestore(&priv->lock, flags);
985}
986
987static void iwl_irq_tasklet(struct iwl_priv *priv) 969static void iwl_irq_tasklet(struct iwl_priv *priv)
988{ 970{
989 u32 inta, handled = 0; 971 u32 inta, handled = 0;
@@ -1514,9 +1496,6 @@ static void iwl_alive_start(struct iwl_priv *priv)
1514 set_bit(STATUS_READY, &priv->status); 1496 set_bit(STATUS_READY, &priv->status);
1515 wake_up_interruptible(&priv->wait_command_queue); 1497 wake_up_interruptible(&priv->wait_command_queue);
1516 1498
1517 if (priv->error_recovering)
1518 iwl_error_recovery(priv);
1519
1520 iwl_power_update_mode(priv, 1); 1499 iwl_power_update_mode(priv, 1);
1521 1500
1522 /* reassociate for ADHOC mode */ 1501 /* reassociate for ADHOC mode */
@@ -1715,9 +1694,6 @@ static int __iwl_up(struct iwl_priv *priv)
1715 continue; 1694 continue;
1716 } 1695 }
1717 1696
1718 /* Clear out the uCode error bit if it is set */
1719 clear_bit(STATUS_FW_ERROR, &priv->status);
1720
1721 /* start card; "initialize" will load runtime ucode */ 1697 /* start card; "initialize" will load runtime ucode */
1722 iwl_nic_start(priv); 1698 iwl_nic_start(priv);
1723 1699
@@ -1812,8 +1788,17 @@ static void iwl_bg_restart(struct work_struct *data)
1812 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 1788 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1813 return; 1789 return;
1814 1790
1815 iwl_down(priv); 1791 if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
1816 queue_work(priv->workqueue, &priv->up); 1792 mutex_lock(&priv->mutex);
1793 priv->vif = NULL;
1794 priv->is_open = 0;
1795 mutex_unlock(&priv->mutex);
1796 iwl_down(priv);
1797 ieee80211_restart_hw(priv->hw);
1798 } else {
1799 iwl_down(priv);
1800 queue_work(priv->workqueue, &priv->up);
1801 }
1817} 1802}
1818 1803
1819static void iwl_bg_rx_replenish(struct work_struct *data) 1804static void iwl_bg_rx_replenish(struct work_struct *data)
@@ -1853,7 +1838,6 @@ void iwl_post_associate(struct iwl_priv *priv)
1853 if (!priv->vif || !priv->is_open) 1838 if (!priv->vif || !priv->is_open)
1854 return; 1839 return;
1855 1840
1856 iwl_power_cancel_timeout(priv);
1857 iwl_scan_cancel_timeout(priv, 200); 1841 iwl_scan_cancel_timeout(priv, 200);
1858 1842
1859 conf = ieee80211_get_hw_conf(priv->hw); 1843 conf = ieee80211_get_hw_conf(priv->hw);
@@ -1929,7 +1913,7 @@ void iwl_post_associate(struct iwl_priv *priv)
1929 * If chain noise has already been run, then we need to enable 1913 * If chain noise has already been run, then we need to enable
1930 * power management here */ 1914 * power management here */
1931 if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE) 1915 if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE)
1932 iwl_power_enable_management(priv); 1916 iwl_power_update_mode(priv, 0);
1933 1917
1934 /* Enable Rx differential gain and sensitivity calibrations */ 1918 /* Enable Rx differential gain and sensitivity calibrations */
1935 iwl_chain_noise_reset(priv); 1919 iwl_chain_noise_reset(priv);
@@ -2007,10 +1991,8 @@ static void iwl_mac_stop(struct ieee80211_hw *hw)
2007 1991
2008 IWL_DEBUG_MAC80211(priv, "enter\n"); 1992 IWL_DEBUG_MAC80211(priv, "enter\n");
2009 1993
2010 if (!priv->is_open) { 1994 if (!priv->is_open)
2011 IWL_DEBUG_MAC80211(priv, "leave - skip\n");
2012 return; 1995 return;
2013 }
2014 1996
2015 priv->is_open = 0; 1997 priv->is_open = 0;
2016 1998
@@ -2482,32 +2464,37 @@ static ssize_t show_power_level(struct device *d,
2482{ 2464{
2483 struct iwl_priv *priv = dev_get_drvdata(d); 2465 struct iwl_priv *priv = dev_get_drvdata(d);
2484 int mode = priv->power_data.user_power_setting; 2466 int mode = priv->power_data.user_power_setting;
2485 int system = priv->power_data.system_power_setting;
2486 int level = priv->power_data.power_mode; 2467 int level = priv->power_data.power_mode;
2487 char *p = buf; 2468 char *p = buf;
2488 2469
2489 switch (system) { 2470 p += sprintf(p, "INDEX:%d\t", level);
2490 case IWL_POWER_SYS_AUTO: 2471 p += sprintf(p, "USER:%d\n", mode);
2491 p += sprintf(p, "SYSTEM:auto");
2492 break;
2493 case IWL_POWER_SYS_AC:
2494 p += sprintf(p, "SYSTEM:ac");
2495 break;
2496 case IWL_POWER_SYS_BATTERY:
2497 p += sprintf(p, "SYSTEM:battery");
2498 break;
2499 }
2500
2501 p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO) ?
2502 "fixed" : "auto");
2503 p += sprintf(p, "\tINDEX:%d", level);
2504 p += sprintf(p, "\n");
2505 return p - buf + 1; 2472 return p - buf + 1;
2506} 2473}
2507 2474
2508static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level, 2475static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level,
2509 store_power_level); 2476 store_power_level);
2510 2477
2478static ssize_t show_qos(struct device *d,
2479 struct device_attribute *attr, char *buf)
2480{
2481 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
2482 char *p = buf;
2483 int q;
2484
2485 for (q = 0; q < AC_NUM; q++) {
2486 p += sprintf(p, "\tcw_min\tcw_max\taifsn\ttxop\n");
2487 p += sprintf(p, "AC[%d]\t%u\t%u\t%u\t%u\n", q,
2488 priv->qos_data.def_qos_parm.ac[q].cw_min,
2489 priv->qos_data.def_qos_parm.ac[q].cw_max,
2490 priv->qos_data.def_qos_parm.ac[q].aifsn,
2491 priv->qos_data.def_qos_parm.ac[q].edca_txop);
2492 }
2493
2494 return p - buf + 1;
2495}
2496
2497static DEVICE_ATTR(qos, S_IRUGO, show_qos, NULL);
2511 2498
2512static ssize_t show_statistics(struct device *d, 2499static ssize_t show_statistics(struct device *d,
2513 struct device_attribute *attr, char *buf) 2500 struct device_attribute *attr, char *buf)
@@ -2570,7 +2557,6 @@ static void iwl_setup_deferred_work(struct iwl_priv *priv)
2570 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start); 2557 INIT_DELAYED_WORK(&priv->alive_start, iwl_bg_alive_start);
2571 2558
2572 iwl_setup_scan_deferred_work(priv); 2559 iwl_setup_scan_deferred_work(priv);
2573 iwl_setup_power_deferred_work(priv);
2574 2560
2575 if (priv->cfg->ops->lib->setup_deferred_work) 2561 if (priv->cfg->ops->lib->setup_deferred_work)
2576 priv->cfg->ops->lib->setup_deferred_work(priv); 2562 priv->cfg->ops->lib->setup_deferred_work(priv);
@@ -2590,7 +2576,6 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
2590 2576
2591 cancel_delayed_work_sync(&priv->init_alive_start); 2577 cancel_delayed_work_sync(&priv->init_alive_start);
2592 cancel_delayed_work(&priv->scan_check); 2578 cancel_delayed_work(&priv->scan_check);
2593 cancel_delayed_work_sync(&priv->set_power_save);
2594 cancel_delayed_work(&priv->alive_start); 2579 cancel_delayed_work(&priv->alive_start);
2595 cancel_work_sync(&priv->beacon_update); 2580 cancel_work_sync(&priv->beacon_update);
2596 del_timer_sync(&priv->statistics_periodic); 2581 del_timer_sync(&priv->statistics_periodic);
@@ -2607,7 +2592,7 @@ static struct attribute *iwl_sysfs_entries[] = {
2607 &dev_attr_debug_level.attr, 2592 &dev_attr_debug_level.attr,
2608#endif 2593#endif
2609 &dev_attr_version.attr, 2594 &dev_attr_version.attr,
2610 2595 &dev_attr_qos.attr,
2611 NULL 2596 NULL
2612}; 2597};
2613 2598
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 735f3f19928c..a5d63672ad39 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -857,7 +857,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
857 priv->cfg->ops->lib->update_chain_flags(priv); 857 priv->cfg->ops->lib->update_chain_flags(priv);
858 858
859 data->state = IWL_CHAIN_NOISE_DONE; 859 data->state = IWL_CHAIN_NOISE_DONE;
860 iwl_power_enable_management(priv); 860 iwl_power_update_mode(priv, 0);
861} 861}
862EXPORT_SYMBOL(iwl_chain_noise_calibration); 862EXPORT_SYMBOL(iwl_chain_noise_calibration);
863 863
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 1366222bb50a..5393fb3f452c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -273,6 +273,14 @@ void iwl_activate_qos(struct iwl_priv *priv, u8 force)
273} 273}
274EXPORT_SYMBOL(iwl_activate_qos); 274EXPORT_SYMBOL(iwl_activate_qos);
275 275
276/*
277 * AC CWmin CW max AIFSN TXOP Limit TXOP Limit
278 * (802.11b) (802.11a/g)
279 * AC_BK 15 1023 7 0 0
280 * AC_BE 15 1023 3 0 0
281 * AC_VI 7 15 2 6.016ms 3.008ms
282 * AC_VO 3 7 2 3.264ms 1.504ms
283 */
276void iwl_reset_qos(struct iwl_priv *priv) 284void iwl_reset_qos(struct iwl_priv *priv)
277{ 285{
278 u16 cw_min = 15; 286 u16 cw_min = 15;
@@ -304,6 +312,7 @@ void iwl_reset_qos(struct iwl_priv *priv)
304 if (priv->qos_data.qos_active) 312 if (priv->qos_data.qos_active)
305 aifs = 3; 313 aifs = 3;
306 314
315 /* AC_BE */
307 priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min); 316 priv->qos_data.def_qos_parm.ac[0].cw_min = cpu_to_le16(cw_min);
308 priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max); 317 priv->qos_data.def_qos_parm.ac[0].cw_max = cpu_to_le16(cw_max);
309 priv->qos_data.def_qos_parm.ac[0].aifsn = aifs; 318 priv->qos_data.def_qos_parm.ac[0].aifsn = aifs;
@@ -311,6 +320,7 @@ void iwl_reset_qos(struct iwl_priv *priv)
311 priv->qos_data.def_qos_parm.ac[0].reserved1 = 0; 320 priv->qos_data.def_qos_parm.ac[0].reserved1 = 0;
312 321
313 if (priv->qos_data.qos_active) { 322 if (priv->qos_data.qos_active) {
323 /* AC_BK */
314 i = 1; 324 i = 1;
315 priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min); 325 priv->qos_data.def_qos_parm.ac[i].cw_min = cpu_to_le16(cw_min);
316 priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max); 326 priv->qos_data.def_qos_parm.ac[i].cw_max = cpu_to_le16(cw_max);
@@ -318,11 +328,12 @@ void iwl_reset_qos(struct iwl_priv *priv)
318 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0; 328 priv->qos_data.def_qos_parm.ac[i].edca_txop = 0;
319 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0; 329 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
320 330
331 /* AC_VI */
321 i = 2; 332 i = 2;
322 priv->qos_data.def_qos_parm.ac[i].cw_min = 333 priv->qos_data.def_qos_parm.ac[i].cw_min =
323 cpu_to_le16((cw_min + 1) / 2 - 1); 334 cpu_to_le16((cw_min + 1) / 2 - 1);
324 priv->qos_data.def_qos_parm.ac[i].cw_max = 335 priv->qos_data.def_qos_parm.ac[i].cw_max =
325 cpu_to_le16(cw_max); 336 cpu_to_le16(cw_min);
326 priv->qos_data.def_qos_parm.ac[i].aifsn = 2; 337 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
327 if (is_legacy) 338 if (is_legacy)
328 priv->qos_data.def_qos_parm.ac[i].edca_txop = 339 priv->qos_data.def_qos_parm.ac[i].edca_txop =
@@ -332,11 +343,12 @@ void iwl_reset_qos(struct iwl_priv *priv)
332 cpu_to_le16(3008); 343 cpu_to_le16(3008);
333 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0; 344 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
334 345
346 /* AC_VO */
335 i = 3; 347 i = 3;
336 priv->qos_data.def_qos_parm.ac[i].cw_min = 348 priv->qos_data.def_qos_parm.ac[i].cw_min =
337 cpu_to_le16((cw_min + 1) / 4 - 1); 349 cpu_to_le16((cw_min + 1) / 4 - 1);
338 priv->qos_data.def_qos_parm.ac[i].cw_max = 350 priv->qos_data.def_qos_parm.ac[i].cw_max =
339 cpu_to_le16((cw_max + 1) / 2 - 1); 351 cpu_to_le16((cw_min + 1) / 2 - 1);
340 priv->qos_data.def_qos_parm.ac[i].aifsn = 2; 352 priv->qos_data.def_qos_parm.ac[i].aifsn = 2;
341 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0; 353 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
342 if (is_legacy) 354 if (is_legacy)
@@ -960,10 +972,10 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
960 if (iwl_is_monitor_mode(priv) && 972 if (iwl_is_monitor_mode(priv) &&
961 !(priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) && 973 !(priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) &&
962 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)) { 974 ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)) {
963 rx_chain = 0x07 << RXON_RX_CHAIN_VALID_POS; 975 rx_chain = ANT_ABC << RXON_RX_CHAIN_VALID_POS;
964 rx_chain |= 0x06 << RXON_RX_CHAIN_FORCE_SEL_POS; 976 rx_chain |= ANT_BC << RXON_RX_CHAIN_FORCE_SEL_POS;
965 rx_chain |= 0x07 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; 977 rx_chain |= ANT_ABC << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
966 rx_chain |= 0x01 << RXON_RX_CHAIN_DRIVER_FORCE_POS; 978 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
967 } 979 }
968 980
969 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain); 981 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain);
@@ -1120,7 +1132,7 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
1120} 1132}
1121EXPORT_SYMBOL(iwl_connection_init_rx_config); 1133EXPORT_SYMBOL(iwl_connection_init_rx_config);
1122 1134
1123void iwl_set_rate(struct iwl_priv *priv) 1135static void iwl_set_rate(struct iwl_priv *priv)
1124{ 1136{
1125 const struct ieee80211_supported_band *hw = NULL; 1137 const struct ieee80211_supported_band *hw = NULL;
1126 struct ieee80211_rate *rate; 1138 struct ieee80211_rate *rate;
@@ -1166,7 +1178,6 @@ void iwl_set_rate(struct iwl_priv *priv)
1166 priv->staging_rxon.ofdm_basic_rates = 1178 priv->staging_rxon.ofdm_basic_rates =
1167 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; 1179 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1168} 1180}
1169EXPORT_SYMBOL(iwl_set_rate);
1170 1181
1171void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) 1182void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1172{ 1183{
@@ -1230,11 +1241,6 @@ void iwl_irq_handle_error(struct iwl_priv *priv)
1230 IWL_DEBUG(priv, IWL_DL_FW_ERRORS, 1241 IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
1231 "Restarting adapter due to uCode error.\n"); 1242 "Restarting adapter due to uCode error.\n");
1232 1243
1233 if (iwl_is_associated(priv)) {
1234 memcpy(&priv->recovery_rxon, &priv->active_rxon,
1235 sizeof(priv->recovery_rxon));
1236 priv->error_recovering = 1;
1237 }
1238 if (priv->cfg->mod_params->restart_fw) 1244 if (priv->cfg->mod_params->restart_fw)
1239 queue_work(priv->workqueue, &priv->restart); 1245 queue_work(priv->workqueue, &priv->restart);
1240 } 1246 }
@@ -1358,7 +1364,6 @@ int iwl_init_drv(struct iwl_priv *priv)
1358 priv->ibss_beacon = NULL; 1364 priv->ibss_beacon = NULL;
1359 1365
1360 spin_lock_init(&priv->lock); 1366 spin_lock_init(&priv->lock);
1361 spin_lock_init(&priv->power_data.lock);
1362 spin_lock_init(&priv->sta_lock); 1367 spin_lock_init(&priv->sta_lock);
1363 spin_lock_init(&priv->hcmd_lock); 1368 spin_lock_init(&priv->hcmd_lock);
1364 1369
@@ -2226,9 +2231,9 @@ static void iwl_ht_conf(struct iwl_priv *priv,
2226 2231
2227 iwl_conf->tx_chan_width = iwl_conf->supported_chan_width != 0; 2232 iwl_conf->tx_chan_width = iwl_conf->supported_chan_width != 0;
2228 iwl_conf->ht_protection = 2233 iwl_conf->ht_protection =
2229 bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; 2234 bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION;
2230 iwl_conf->non_GF_STA_present = 2235 iwl_conf->non_GF_STA_present =
2231 !!(bss_conf->ht.operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); 2236 !!(bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
2232 2237
2233 rcu_read_unlock(); 2238 rcu_read_unlock();
2234 2239
@@ -2582,14 +2587,13 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2582 iwl_set_rate(priv); 2587 iwl_set_rate(priv);
2583 } 2588 }
2584 2589
2585 if (changed & IEEE80211_CONF_CHANGE_PS) { 2590 if (changed & IEEE80211_CONF_CHANGE_PS &&
2586 if (conf->flags & IEEE80211_CONF_PS) 2591 priv->iw_mode == NL80211_IFTYPE_STATION) {
2587 ret = iwl_power_set_user_mode(priv, IWL_POWER_INDEX_3); 2592 priv->power_data.power_disabled =
2588 else 2593 !(conf->flags & IEEE80211_CONF_PS);
2589 ret = iwl_power_set_user_mode(priv, IWL_POWER_MODE_CAM); 2594 ret = iwl_power_update_mode(priv, 0);
2590 if (ret) 2595 if (ret)
2591 IWL_DEBUG_MAC80211(priv, "Error setting power level\n"); 2596 IWL_DEBUG_MAC80211(priv, "Error setting power level\n");
2592
2593 } 2597 }
2594 2598
2595 if (changed & IEEE80211_CONF_CHANGE_POWER) { 2599 if (changed & IEEE80211_CONF_CHANGE_POWER) {
@@ -2725,21 +2729,7 @@ void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
2725 iwlcore_commit_rxon(priv); 2729 iwlcore_commit_rxon(priv);
2726 } 2730 }
2727 2731
2728 iwl_power_update_mode(priv, 0);
2729
2730 /* Per mac80211.h: This is only used in IBSS mode... */
2731 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) { 2732 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
2732
2733 /* switch to CAM during association period.
2734 * the ucode will block any association/authentication
2735 * frome during assiciation period if it can not hear
2736 * the AP because of PM. the timer enable PM back is
2737 * association do not complete
2738 */
2739 if (priv->hw->conf.channel->flags &
2740 (IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_RADAR))
2741 iwl_power_disable_management(priv, 3000);
2742
2743 IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n"); 2733 IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n");
2744 mutex_unlock(&priv->mutex); 2734 mutex_unlock(&priv->mutex);
2745 return; 2735 return;
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index bd7f9d9616bc..f3544ea559a2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -363,8 +363,6 @@ int iwl_hwrate_to_plcp_idx(u32 rate_n_flags);
363 363
364u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv); 364u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv);
365 365
366void iwl_set_rate(struct iwl_priv *priv);
367
368u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx); 366u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx);
369 367
370static inline u32 iwl_ant_idx_to_flags(u8 ant_idx) 368static inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 5aa76a706320..3049ba25c3fc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -933,7 +933,6 @@ struct iwl_priv {
933 const struct iwl_rxon_cmd active_rxon; 933 const struct iwl_rxon_cmd active_rxon;
934 struct iwl_rxon_cmd staging_rxon; 934 struct iwl_rxon_cmd staging_rxon;
935 935
936 int error_recovering;
937 struct iwl_rxon_cmd recovery_rxon; 936 struct iwl_rxon_cmd recovery_rxon;
938 937
939 /* 1st responses from initialize and runtime uCode images. 938 /* 1st responses from initialize and runtime uCode images.
@@ -1076,7 +1075,6 @@ struct iwl_priv {
1076 1075
1077 struct tasklet_struct irq_tasklet; 1076 struct tasklet_struct irq_tasklet;
1078 1077
1079 struct delayed_work set_power_save;
1080 struct delayed_work init_alive_start; 1078 struct delayed_work init_alive_start;
1081 struct delayed_work alive_start; 1079 struct delayed_work alive_start;
1082 struct delayed_work scan_check; 1080 struct delayed_work scan_check;
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 75517d05df08..401438aec19c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -285,7 +285,7 @@ int iwl_eeprom_check_version(struct iwl_priv *priv)
285 285
286 return 0; 286 return 0;
287err: 287err:
288 IWL_ERR(priv, "Unsupported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n", 288 IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
289 eeprom_ver, priv->cfg->eeprom_ver, 289 eeprom_ver, priv->cfg->eeprom_ver,
290 calib_ver, priv->cfg->eeprom_calib_ver); 290 calib_ver, priv->cfg->eeprom_calib_ver);
291 return -EINVAL; 291 return -EINVAL;
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 47c894530eb5..f2ea3f05f6e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -41,38 +41,33 @@
41#include "iwl-power.h" 41#include "iwl-power.h"
42 42
43/* 43/*
44 * Setting power level allow the card to go to sleep when not busy 44 * Setting power level allow the card to go to sleep when not busy.
45 * there are three factor that decide the power level to go to, they
46 * are list here with its priority
47 * 1- critical_power_setting this will be set according to card temperature.
48 * 2- system_power_setting this will be set by system PM manager.
49 * 3- user_power_setting this will be set by user either by writing to sys or
50 * mac80211
51 * 45 *
52 * if system_power_setting and user_power_setting is set to auto 46 * The power level is set to INDEX_1 (the least deep state) by
53 * the power level will be decided according to association status and battery 47 * default, and will, in the future, be the deepest state unless
54 * status. 48 * otherwise required by pm_qos network latency requirements.
55 * 49 *
50 * Using INDEX_1 without pm_qos is ok because mac80211 will disable
51 * PS when even checking every beacon for the TIM bit would exceed
52 * the required latency.
56 */ 53 */
57 54
58#define MSEC_TO_USEC 1024
59#define IWL_POWER_RANGE_0_MAX (2) 55#define IWL_POWER_RANGE_0_MAX (2)
60#define IWL_POWER_RANGE_1_MAX (10) 56#define IWL_POWER_RANGE_1_MAX (10)
61 57
62 58
63 59#define NOSLP cpu_to_le16(0), 0, 0
64#define IWL_POWER_ON_BATTERY IWL_POWER_INDEX_5 60#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
65#define IWL_POWER_ON_AC_DISASSOC IWL_POWER_MODE_CAM 61#define TU_TO_USEC 1024
66#define IWL_POWER_ON_AC_ASSOC IWL_POWER_MODE_CAM 62#define SLP_TOUT(T) cpu_to_le32((T) * TU_TO_USEC)
67 63#define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \
68 64 cpu_to_le32(X1), \
69#define IWL_CT_KILL_TEMPERATURE 110 65 cpu_to_le32(X2), \
70#define IWL_MIN_POWER_TEMPERATURE 100 66 cpu_to_le32(X3), \
71#define IWL_REDUCED_POWER_TEMPERATURE 95 67 cpu_to_le32(X4)}
72
73/* default power management (not Tx power) table values */ 68/* default power management (not Tx power) table values */
74/* for TIM 0-10 */ 69/* for DTIM period 0 through IWL_POWER_RANGE_0_MAX */
75static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = { 70static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = {
76 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 71 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
77 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, 72 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
78 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, 73 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
@@ -82,8 +77,8 @@ static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
82}; 77};
83 78
84 79
85/* for TIM = 3-10 */ 80/* for DTIM period IWL_POWER_RANGE_0_MAX + 1 through IWL_POWER_RANGE_1_MAX */
86static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = { 81static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = {
87 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 82 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
88 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0}, 83 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
89 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0}, 84 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0},
@@ -92,8 +87,8 @@ static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
92 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 7, 10, 10)}, 2} 87 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 7, 10, 10)}, 2}
93}; 88};
94 89
95/* for TIM > 11 */ 90/* for DTIM period > IWL_POWER_RANGE_1_MAX */
96static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = { 91static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = {
97 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 92 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
98 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0}, 93 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
99 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0}, 94 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0},
@@ -106,39 +101,15 @@ static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = {
106/* set card power command */ 101/* set card power command */
107static int iwl_set_power(struct iwl_priv *priv, void *cmd) 102static int iwl_set_power(struct iwl_priv *priv, void *cmd)
108{ 103{
109 return iwl_send_cmd_pdu_async(priv, POWER_TABLE_CMD, 104 return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD,
110 sizeof(struct iwl_powertable_cmd), 105 sizeof(struct iwl_powertable_cmd), cmd);
111 cmd, NULL);
112}
113/* decide the right power level according to association status
114 * and battery status
115 */
116static u16 iwl_get_auto_power_mode(struct iwl_priv *priv)
117{
118 u16 mode;
119
120 switch (priv->power_data.user_power_setting) {
121 case IWL_POWER_AUTO:
122 /* if running on battery */
123 if (priv->power_data.is_battery_active)
124 mode = IWL_POWER_ON_BATTERY;
125 else if (iwl_is_associated(priv))
126 mode = IWL_POWER_ON_AC_ASSOC;
127 else
128 mode = IWL_POWER_ON_AC_DISASSOC;
129 break;
130 default:
131 mode = priv->power_data.user_power_setting;
132 break;
133 }
134 return mode;
135} 106}
136 107
137/* initialize to default */ 108/* initialize to default */
138static void iwl_power_init_handle(struct iwl_priv *priv) 109static void iwl_power_init_handle(struct iwl_priv *priv)
139{ 110{
140 struct iwl_power_mgr *pow_data; 111 struct iwl_power_mgr *pow_data;
141 int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX; 112 int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_NUM;
142 struct iwl_powertable_cmd *cmd; 113 struct iwl_powertable_cmd *cmd;
143 int i; 114 int i;
144 u16 lctl; 115 u16 lctl;
@@ -157,7 +128,7 @@ static void iwl_power_init_handle(struct iwl_priv *priv)
157 128
158 IWL_DEBUG_POWER(priv, "adjust power command flags\n"); 129 IWL_DEBUG_POWER(priv, "adjust power command flags\n");
159 130
160 for (i = 0; i < IWL_POWER_MAX; i++) { 131 for (i = 0; i < IWL_POWER_NUM; i++) {
161 cmd = &pow_data->pwr_range_0[i].cmd; 132 cmd = &pow_data->pwr_range_0[i].cmd;
162 133
163 if (lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN) 134 if (lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN)
@@ -247,33 +218,12 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
247 update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE || 218 update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
248 priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE; 219 priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
249 220
250 /* If on battery, set to 3, 221 final_mode = priv->power_data.user_power_setting;
251 * if plugged into AC power, set to CAM ("continuously aware mode"),
252 * else user level */
253
254 switch (setting->system_power_setting) {
255 case IWL_POWER_SYS_AUTO:
256 final_mode = iwl_get_auto_power_mode(priv);
257 break;
258 case IWL_POWER_SYS_BATTERY:
259 final_mode = IWL_POWER_INDEX_3;
260 break;
261 case IWL_POWER_SYS_AC:
262 final_mode = IWL_POWER_MODE_CAM;
263 break;
264 default:
265 final_mode = IWL_POWER_INDEX_3;
266 WARN_ON(1);
267 }
268
269 if (setting->critical_power_setting > final_mode)
270 final_mode = setting->critical_power_setting;
271 222
272 /* driver only support CAM for non STA network */ 223 if (setting->power_disabled)
273 if (priv->iw_mode != NL80211_IFTYPE_STATION)
274 final_mode = IWL_POWER_MODE_CAM; 224 final_mode = IWL_POWER_MODE_CAM;
275 225
276 if (iwl_is_ready_rf(priv) && !setting->power_disabled && 226 if (iwl_is_ready_rf(priv) &&
277 ((setting->power_mode != final_mode) || force)) { 227 ((setting->power_mode != final_mode) || force)) {
278 struct iwl_powertable_cmd cmd; 228 struct iwl_powertable_cmd cmd;
279 229
@@ -290,8 +240,6 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
290 240
291 if (final_mode == IWL_POWER_MODE_CAM) 241 if (final_mode == IWL_POWER_MODE_CAM)
292 clear_bit(STATUS_POWER_PMI, &priv->status); 242 clear_bit(STATUS_POWER_PMI, &priv->status);
293 else
294 set_bit(STATUS_POWER_PMI, &priv->status);
295 243
296 if (priv->cfg->ops->lib->update_chain_flags && update_chains) 244 if (priv->cfg->ops->lib->update_chain_flags && update_chains)
297 priv->cfg->ops->lib->update_chain_flags(priv); 245 priv->cfg->ops->lib->update_chain_flags(priv);
@@ -307,51 +255,10 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
307} 255}
308EXPORT_SYMBOL(iwl_power_update_mode); 256EXPORT_SYMBOL(iwl_power_update_mode);
309 257
310/* Allow other iwl code to disable/enable power management active
311 * this will be useful for rate scale to disable PM during heavy
312 * Tx/Rx activities
313 */
314int iwl_power_disable_management(struct iwl_priv *priv, u32 ms)
315{
316 u16 prev_mode;
317 int ret = 0;
318
319 if (priv->power_data.power_disabled)
320 return -EBUSY;
321
322 prev_mode = priv->power_data.user_power_setting;
323 priv->power_data.user_power_setting = IWL_POWER_MODE_CAM;
324 ret = iwl_power_update_mode(priv, 0);
325 priv->power_data.power_disabled = 1;
326 priv->power_data.user_power_setting = prev_mode;
327 cancel_delayed_work(&priv->set_power_save);
328 if (ms)
329 queue_delayed_work(priv->workqueue, &priv->set_power_save,
330 msecs_to_jiffies(ms));
331
332
333 return ret;
334}
335EXPORT_SYMBOL(iwl_power_disable_management);
336
337/* Allow other iwl code to disable/enable power management active
338 * this will be useful for rate scale to disable PM during high
339 * volume activities
340 */
341int iwl_power_enable_management(struct iwl_priv *priv)
342{
343 int ret = 0;
344
345 priv->power_data.power_disabled = 0;
346 ret = iwl_power_update_mode(priv, 0);
347 return ret;
348}
349EXPORT_SYMBOL(iwl_power_enable_management);
350
351/* set user_power_setting */ 258/* set user_power_setting */
352int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode) 259int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode)
353{ 260{
354 if (mode > IWL_POWER_MAX) 261 if (mode >= IWL_POWER_NUM)
355 return -EINVAL; 262 return -EINVAL;
356 263
357 priv->power_data.user_power_setting = mode; 264 priv->power_data.user_power_setting = mode;
@@ -360,86 +267,12 @@ int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode)
360} 267}
361EXPORT_SYMBOL(iwl_power_set_user_mode); 268EXPORT_SYMBOL(iwl_power_set_user_mode);
362 269
363/* set system_power_setting. This should be set by over all
364 * PM application.
365 */
366int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode)
367{
368 if (mode < IWL_POWER_SYS_MAX)
369 priv->power_data.system_power_setting = mode;
370 else
371 return -EINVAL;
372 return iwl_power_update_mode(priv, 0);
373}
374EXPORT_SYMBOL(iwl_power_set_system_mode);
375
376/* initialize to default */ 270/* initialize to default */
377void iwl_power_initialize(struct iwl_priv *priv) 271void iwl_power_initialize(struct iwl_priv *priv)
378{ 272{
379 iwl_power_init_handle(priv); 273 iwl_power_init_handle(priv);
380 priv->power_data.user_power_setting = IWL_POWER_AUTO; 274 priv->power_data.user_power_setting = IWL_POWER_INDEX_1;
381 priv->power_data.system_power_setting = IWL_POWER_SYS_AUTO; 275 /* default to disabled until mac80211 says otherwise */
382 priv->power_data.power_disabled = 0; 276 priv->power_data.power_disabled = 1;
383 priv->power_data.is_battery_active = 0;
384 priv->power_data.critical_power_setting = 0;
385} 277}
386EXPORT_SYMBOL(iwl_power_initialize); 278EXPORT_SYMBOL(iwl_power_initialize);
387
388/* set critical_power_setting according to temperature value */
389int iwl_power_temperature_change(struct iwl_priv *priv)
390{
391 int ret = 0;
392 s32 temperature = KELVIN_TO_CELSIUS(priv->last_temperature);
393 u16 new_critical = priv->power_data.critical_power_setting;
394
395 if (temperature > IWL_CT_KILL_TEMPERATURE)
396 return 0;
397 else if (temperature > IWL_MIN_POWER_TEMPERATURE)
398 new_critical = IWL_POWER_INDEX_5;
399 else if (temperature > IWL_REDUCED_POWER_TEMPERATURE)
400 new_critical = IWL_POWER_INDEX_3;
401 else
402 new_critical = IWL_POWER_MODE_CAM;
403
404 if (new_critical != priv->power_data.critical_power_setting)
405 priv->power_data.critical_power_setting = new_critical;
406
407 if (priv->power_data.critical_power_setting >
408 priv->power_data.power_mode)
409 ret = iwl_power_update_mode(priv, 0);
410
411 return ret;
412}
413EXPORT_SYMBOL(iwl_power_temperature_change);
414
415static void iwl_bg_set_power_save(struct work_struct *work)
416{
417 struct iwl_priv *priv = container_of(work,
418 struct iwl_priv, set_power_save.work);
419 IWL_DEBUG_POWER(priv, "update power\n");
420
421 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
422 return;
423
424 mutex_lock(&priv->mutex);
425
426 /* on starting association we disable power management
427 * until association, if association failed then this
428 * timer will expire and enable PM again.
429 */
430 if (!iwl_is_associated(priv))
431 iwl_power_enable_management(priv);
432
433 mutex_unlock(&priv->mutex);
434}
435void iwl_setup_power_deferred_work(struct iwl_priv *priv)
436{
437 INIT_DELAYED_WORK(&priv->set_power_save, iwl_bg_set_power_save);
438}
439EXPORT_SYMBOL(iwl_setup_power_deferred_work);
440
441void iwl_power_cancel_timeout(struct iwl_priv *priv)
442{
443 cancel_delayed_work(&priv->set_power_save);
444}
445EXPORT_SYMBOL(iwl_power_cancel_timeout);
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index 18963392121e..37ba3bb7a25a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -40,56 +40,29 @@ enum {
40 IWL_POWER_INDEX_3, 40 IWL_POWER_INDEX_3,
41 IWL_POWER_INDEX_4, 41 IWL_POWER_INDEX_4,
42 IWL_POWER_INDEX_5, 42 IWL_POWER_INDEX_5,
43 IWL_POWER_AUTO, 43 IWL_POWER_NUM
44 IWL_POWER_MAX = IWL_POWER_AUTO,
45}; 44};
46 45
47enum {
48 IWL_POWER_SYS_AUTO,
49 IWL_POWER_SYS_AC,
50 IWL_POWER_SYS_BATTERY,
51 IWL_POWER_SYS_MAX,
52};
53
54
55/* Power management (not Tx power) structures */ 46/* Power management (not Tx power) structures */
56 47
57#define NOSLP cpu_to_le16(0), 0, 0
58#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
59#define SLP_TOUT(T) cpu_to_le32((T) * MSEC_TO_USEC)
60#define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \
61 cpu_to_le32(X1), \
62 cpu_to_le32(X2), \
63 cpu_to_le32(X3), \
64 cpu_to_le32(X4)}
65struct iwl_power_vec_entry { 48struct iwl_power_vec_entry {
66 struct iwl_powertable_cmd cmd; 49 struct iwl_powertable_cmd cmd;
67 u8 no_dtim; 50 u8 no_dtim;
68}; 51};
69 52
70struct iwl_power_mgr { 53struct iwl_power_mgr {
71 spinlock_t lock; 54 struct iwl_power_vec_entry pwr_range_0[IWL_POWER_NUM];
72 struct iwl_power_vec_entry pwr_range_0[IWL_POWER_MAX]; 55 struct iwl_power_vec_entry pwr_range_1[IWL_POWER_NUM];
73 struct iwl_power_vec_entry pwr_range_1[IWL_POWER_MAX]; 56 struct iwl_power_vec_entry pwr_range_2[IWL_POWER_NUM];
74 struct iwl_power_vec_entry pwr_range_2[IWL_POWER_MAX];
75 u32 dtim_period; 57 u32 dtim_period;
76 /* final power level that used to calculate final power command */ 58 /* final power level that used to calculate final power command */
77 u8 power_mode; 59 u8 power_mode;
78 u8 user_power_setting; /* set by user through mac80211 or sysfs */ 60 u8 user_power_setting; /* set by user through sysfs */
79 u8 system_power_setting; /* set by kernel system tools */ 61 u8 power_disabled; /* set by mac80211's CONF_PS */
80 u8 critical_power_setting; /* set if driver over heated */
81 u8 is_battery_active; /* DC/AC power */
82 u8 power_disabled; /* flag to disable using power saving level */
83}; 62};
84 63
85void iwl_setup_power_deferred_work(struct iwl_priv *priv);
86void iwl_power_cancel_timeout(struct iwl_priv *priv);
87int iwl_power_update_mode(struct iwl_priv *priv, bool force); 64int iwl_power_update_mode(struct iwl_priv *priv, bool force);
88int iwl_power_disable_management(struct iwl_priv *priv, u32 ms);
89int iwl_power_enable_management(struct iwl_priv *priv);
90int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode); 65int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode);
91int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode);
92void iwl_power_initialize(struct iwl_priv *priv); 66void iwl_power_initialize(struct iwl_priv *priv);
93int iwl_power_temperature_change(struct iwl_priv *priv);
94 67
95#endif /* __iwl_power_setting_h__ */ 68#endif /* __iwl_power_setting_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index dd8766b80b34..065214b55895 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -580,9 +580,10 @@ static void iwl_bg_request_scan(struct work_struct *data)
580 int ret = 0; 580 int ret = 0;
581 u32 rate_flags = 0; 581 u32 rate_flags = 0;
582 u16 cmd_len; 582 u16 cmd_len;
583 u16 rx_chain = 0;
583 enum ieee80211_band band; 584 enum ieee80211_band band;
584 u8 n_probes = 0; 585 u8 n_probes = 0;
585 u8 rx_chain = priv->hw_params.valid_rx_ant; 586 u8 rx_ant = priv->hw_params.valid_rx_ant;
586 u8 rate; 587 u8 rate;
587 bool is_active = false; 588 bool is_active = false;
588 589
@@ -723,7 +724,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
723 * Avoid A (0x1) because of its off-channel reception on A-band. 724 * Avoid A (0x1) because of its off-channel reception on A-band.
724 */ 725 */
725 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) 726 if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965)
726 rx_chain = 0x6; 727 rx_ant = ANT_BC;
727 } else { 728 } else {
728 IWL_WARN(priv, "Invalid scan band count\n"); 729 IWL_WARN(priv, "Invalid scan band count\n");
729 goto done; 730 goto done;
@@ -735,10 +736,11 @@ static void iwl_bg_request_scan(struct work_struct *data)
735 scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags); 736 scan->tx_cmd.rate_n_flags = iwl_hw_set_rate_n_flags(rate, rate_flags);
736 737
737 /* MIMO is not used here, but value is required */ 738 /* MIMO is not used here, but value is required */
738 scan->rx_chain = RXON_RX_CHAIN_DRIVER_FORCE_MSK | 739 rx_chain |= ANT_ABC << RXON_RX_CHAIN_VALID_POS;
739 cpu_to_le16((0x7 << RXON_RX_CHAIN_VALID_POS) | 740 rx_chain |= ANT_ABC << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS;
740 (rx_chain << RXON_RX_CHAIN_FORCE_SEL_POS) | 741 rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS;
741 (0x7 << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS)); 742 rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS;
743 scan->rx_chain = cpu_to_le16(rx_chain);
742 cmd_len = iwl_fill_probe_req(priv, 744 cmd_len = iwl_fill_probe_req(priv,
743 (struct ieee80211_mgmt *)scan->data, 745 (struct ieee80211_mgmt *)scan->data,
744 priv->scan_request->ie, 746 priv->scan_request->ie,
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index f6c1489a0c4a..c32ec809053f 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1837,23 +1837,6 @@ static void iwl3945_dump_nic_event_log(struct iwl_priv *priv)
1837 iwl_release_nic_access(priv); 1837 iwl_release_nic_access(priv);
1838} 1838}
1839 1839
1840static void iwl3945_error_recovery(struct iwl_priv *priv)
1841{
1842 unsigned long flags;
1843
1844 memcpy(&priv->staging_rxon, &priv->recovery_rxon,
1845 sizeof(priv->staging_rxon));
1846 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
1847 iwlcore_commit_rxon(priv);
1848
1849 priv->cfg->ops->smgmt->add_station(priv, priv->bssid, 1, 0, NULL);
1850
1851 spin_lock_irqsave(&priv->lock, flags);
1852 priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id);
1853 priv->error_recovering = 0;
1854 spin_unlock_irqrestore(&priv->lock, flags);
1855}
1856
1857static void iwl3945_irq_tasklet(struct iwl_priv *priv) 1840static void iwl3945_irq_tasklet(struct iwl_priv *priv)
1858{ 1841{
1859 u32 inta, handled = 0; 1842 u32 inta, handled = 0;
@@ -2683,9 +2666,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2683 /* After the ALIVE response, we can send commands to 3945 uCode */ 2666 /* After the ALIVE response, we can send commands to 3945 uCode */
2684 set_bit(STATUS_ALIVE, &priv->status); 2667 set_bit(STATUS_ALIVE, &priv->status);
2685 2668
2686 /* Clear out the uCode error bit if it is set */
2687 clear_bit(STATUS_FW_ERROR, &priv->status);
2688
2689 if (iwl_is_rfkill(priv)) 2669 if (iwl_is_rfkill(priv))
2690 return; 2670 return;
2691 2671
@@ -2722,9 +2702,6 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
2722 set_bit(STATUS_READY, &priv->status); 2702 set_bit(STATUS_READY, &priv->status);
2723 wake_up_interruptible(&priv->wait_command_queue); 2703 wake_up_interruptible(&priv->wait_command_queue);
2724 2704
2725 if (priv->error_recovering)
2726 iwl3945_error_recovery(priv);
2727
2728 /* reassociate for ADHOC mode */ 2705 /* reassociate for ADHOC mode */
2729 if (priv->vif && (priv->iw_mode == NL80211_IFTYPE_ADHOC)) { 2706 if (priv->vif && (priv->iw_mode == NL80211_IFTYPE_ADHOC)) {
2730 struct sk_buff *beacon = ieee80211_beacon_get(priv->hw, 2707 struct sk_buff *beacon = ieee80211_beacon_get(priv->hw,
@@ -3231,8 +3208,17 @@ static void iwl3945_bg_restart(struct work_struct *data)
3231 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3208 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
3232 return; 3209 return;
3233 3210
3234 iwl3945_down(priv); 3211 if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) {
3235 queue_work(priv->workqueue, &priv->up); 3212 mutex_lock(&priv->mutex);
3213 priv->vif = NULL;
3214 priv->is_open = 0;
3215 mutex_unlock(&priv->mutex);
3216 iwl3945_down(priv);
3217 ieee80211_restart_hw(priv->hw);
3218 } else {
3219 iwl3945_down(priv);
3220 queue_work(priv->workqueue, &priv->up);
3221 }
3236} 3222}
3237 3223
3238static void iwl3945_bg_rx_replenish(struct work_struct *data) 3224static void iwl3945_bg_rx_replenish(struct work_struct *data)
@@ -3859,26 +3845,11 @@ static ssize_t show_power_level(struct device *d,
3859{ 3845{
3860 struct iwl_priv *priv = dev_get_drvdata(d); 3846 struct iwl_priv *priv = dev_get_drvdata(d);
3861 int mode = priv->power_data.user_power_setting; 3847 int mode = priv->power_data.user_power_setting;
3862 int system = priv->power_data.system_power_setting;
3863 int level = priv->power_data.power_mode; 3848 int level = priv->power_data.power_mode;
3864 char *p = buf; 3849 char *p = buf;
3865 3850
3866 switch (system) { 3851 p += sprintf(p, "INDEX:%d\t", level);
3867 case IWL_POWER_SYS_AUTO: 3852 p += sprintf(p, "USER:%d\n", mode);
3868 p += sprintf(p, "SYSTEM:auto");
3869 break;
3870 case IWL_POWER_SYS_AC:
3871 p += sprintf(p, "SYSTEM:ac");
3872 break;
3873 case IWL_POWER_SYS_BATTERY:
3874 p += sprintf(p, "SYSTEM:battery");
3875 break;
3876 }
3877
3878 p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO) ?
3879 "fixed" : "auto");
3880 p += sprintf(p, "\tINDEX:%d", level);
3881 p += sprintf(p, "\n");
3882 return p - buf + 1; 3853 return p - buf + 1;
3883} 3854}
3884 3855
@@ -4122,7 +4093,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
4122 priv->ibss_beacon = NULL; 4093 priv->ibss_beacon = NULL;
4123 4094
4124 spin_lock_init(&priv->lock); 4095 spin_lock_init(&priv->lock);
4125 spin_lock_init(&priv->power_data.lock);
4126 spin_lock_init(&priv->sta_lock); 4096 spin_lock_init(&priv->sta_lock);
4127 spin_lock_init(&priv->hcmd_lock); 4097 spin_lock_init(&priv->hcmd_lock);
4128 4098
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index b1213b6a6b9f..61a4ad7cc1c2 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -642,7 +642,7 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
642 if (changed & BSS_CHANGED_HT) { 642 if (changed & BSS_CHANGED_HT) {
643 printk(KERN_DEBUG " %s: HT: op_mode=0x%x\n", 643 printk(KERN_DEBUG " %s: HT: op_mode=0x%x\n",
644 wiphy_name(hw->wiphy), 644 wiphy_name(hw->wiphy),
645 info->ht.operation_mode); 645 info->ht_operation_mode);
646 } 646 }
647 647
648 if (changed & BSS_CHANGED_BASIC_RATES) { 648 if (changed & BSS_CHANGED_BASIC_RATES) {
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 46b288dc8f4d..a263d5c84c08 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -2369,7 +2369,7 @@ static int mwl8k_cmd_set_aid(struct ieee80211_hw *hw,
2369 if (info->use_cts_prot) { 2369 if (info->use_cts_prot) {
2370 prot_mode = MWL8K_FRAME_PROT_11G; 2370 prot_mode = MWL8K_FRAME_PROT_11G;
2371 } else { 2371 } else {
2372 switch (info->ht.operation_mode & 2372 switch (info->ht_operation_mode &
2373 IEEE80211_HT_OP_MODE_PROTECTION) { 2373 IEEE80211_HT_OP_MODE_PROTECTION) {
2374 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ: 2374 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
2375 prot_mode = MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY; 2375 prot_mode = MWL8K_FRAME_PROT_11N_HT_40MHZ_ONLY;
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index d10af3687a8e..270dd4e59f7f 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1847,7 +1847,7 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1847 rt2x00_set_chip(rt2x00dev, RT2571, value, reg); 1847 rt2x00_set_chip(rt2x00dev, RT2571, value, reg);
1848 1848
1849 if (!rt2x00_check_rev(&rt2x00dev->chip, 0x000ffff0, 0x25730) || 1849 if (!rt2x00_check_rev(&rt2x00dev->chip, 0x000ffff0, 0x25730) ||
1850 !rt2x00_check_rev(&rt2x00dev->chip, 0x0000000f, 0)) { 1850 rt2x00_check_rev(&rt2x00dev->chip, 0x0000000f, 0)) {
1851 ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); 1851 ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
1852 return -ENODEV; 1852 return -ENODEV;
1853 } 1853 }
diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig
index 20a9633569f2..a82c4cd436d8 100644
--- a/drivers/net/wireless/wl12xx/Kconfig
+++ b/drivers/net/wireless/wl12xx/Kconfig
@@ -1,6 +1,6 @@
1config WL12XX 1config WL12XX
2 tristate "TI wl1251/wl1271 support" 2 tristate "TI wl1251/wl1271 support"
3 depends on MAC80211 && WLAN_80211 && SPI_MASTER && EXPERIMENTAL 3 depends on MAC80211 && WLAN_80211 && SPI_MASTER && GENERIC_HARDIRQS && EXPERIMENTAL
4 select FW_LOADER 4 select FW_LOADER
5 select CRC7 5 select CRC7
6 ---help--- 6 ---help---