diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-03-06 20:36:54 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-03-07 16:03:01 -0500 |
commit | 28447f3cfdf72f6ea97b50cc1eefe35602107dff (patch) | |
tree | e9d1935258d51491de92e77ea65e838b8d589cb7 /drivers/net | |
parent | c54b679ddcd91604fd0d144cd793a0ddbd0ae03d (diff) |
iwlwifi: Fix 3945 rate scaling
This patch fix 3945 rate scaling after cfg80211 rate/band changes
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 45 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.h | 2 |
2 files changed, 22 insertions, 25 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index c4bfba6f3c2b..08604eb8291b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -158,9 +158,9 @@ static void iwl3945_clear_window(struct iwl3945_rate_scale_data *window) | |||
158 | { | 158 | { |
159 | window->data = 0; | 159 | window->data = 0; |
160 | window->success_counter = 0; | 160 | window->success_counter = 0; |
161 | window->success_ratio = IWL_INVALID_VALUE; | 161 | window->success_ratio = -1; |
162 | window->counter = 0; | 162 | window->counter = 0; |
163 | window->average_tpt = IWL_INVALID_VALUE; | 163 | window->average_tpt = IWL_INV_TPT; |
164 | window->stamp = 0; | 164 | window->stamp = 0; |
165 | } | 165 | } |
166 | 166 | ||
@@ -459,13 +459,13 @@ static void rs_tx_status(void *priv_rate, | |||
459 | struct iwl3945_rs_sta *rs_sta; | 459 | struct iwl3945_rs_sta *rs_sta; |
460 | struct ieee80211_supported_band *sband; | 460 | struct ieee80211_supported_band *sband; |
461 | 461 | ||
462 | IWL_DEBUG_RATE("enter\n"); | ||
463 | |||
462 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | 464 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; |
463 | 465 | ||
464 | IWL_DEBUG_RATE("enter\n"); | ||
465 | 466 | ||
466 | retries = tx_resp->retry_count; | 467 | retries = tx_resp->retry_count; |
467 | /* FIXME : this is wrong */ | 468 | first_index = tx_resp->control.tx_rate->hw_value; |
468 | first_index = &sband->bitrates[0] - tx_resp->control.tx_rate; | ||
469 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { | 469 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { |
470 | IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); | 470 | IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); |
471 | return; | 471 | return; |
@@ -634,7 +634,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | |||
634 | * | 634 | * |
635 | */ | 635 | */ |
636 | static void rs_get_rate(void *priv_rate, struct net_device *dev, | 636 | static void rs_get_rate(void *priv_rate, struct net_device *dev, |
637 | struct ieee80211_supported_band *band, | 637 | struct ieee80211_supported_band *sband, |
638 | struct sk_buff *skb, | 638 | struct sk_buff *skb, |
639 | struct rate_selection *sel) | 639 | struct rate_selection *sel) |
640 | { | 640 | { |
@@ -644,9 +644,9 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
644 | int index; | 644 | int index; |
645 | struct iwl3945_rs_sta *rs_sta; | 645 | struct iwl3945_rs_sta *rs_sta; |
646 | struct iwl3945_rate_scale_data *window = NULL; | 646 | struct iwl3945_rate_scale_data *window = NULL; |
647 | int current_tpt = IWL_INVALID_VALUE; | 647 | int current_tpt = IWL_INV_TPT; |
648 | int low_tpt = IWL_INVALID_VALUE; | 648 | int low_tpt = IWL_INV_TPT; |
649 | int high_tpt = IWL_INVALID_VALUE; | 649 | int high_tpt = IWL_INV_TPT; |
650 | u32 fail_count; | 650 | u32 fail_count; |
651 | s8 scale_action = 0; | 651 | s8 scale_action = 0; |
652 | unsigned long flags; | 652 | unsigned long flags; |
@@ -670,15 +670,15 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
670 | is_multicast_ether_addr(hdr->addr1) || | 670 | is_multicast_ether_addr(hdr->addr1) || |
671 | !sta || !sta->rate_ctrl_priv) { | 671 | !sta || !sta->rate_ctrl_priv) { |
672 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 672 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
673 | sel->rate = rate_lowest(local, band, sta); | 673 | sel->rate = rate_lowest(local, sband, sta); |
674 | rcu_read_unlock(); | 674 | rcu_read_unlock(); |
675 | return; | 675 | return; |
676 | } | 676 | } |
677 | 677 | ||
678 | rate_mask = sta->supp_rates[band->band]; | 678 | rate_mask = sta->supp_rates[sband->band]; |
679 | index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); | 679 | index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); |
680 | 680 | ||
681 | if (priv->band == IEEE80211_BAND_5GHZ) | 681 | if (sband->band == IEEE80211_BAND_5GHZ) |
682 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; | 682 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; |
683 | 683 | ||
684 | rs_sta = (void *)sta->rate_ctrl_priv; | 684 | rs_sta = (void *)sta->rate_ctrl_priv; |
@@ -710,7 +710,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
710 | 710 | ||
711 | if (((fail_count <= IWL_RATE_MIN_FAILURE_TH) && | 711 | if (((fail_count <= IWL_RATE_MIN_FAILURE_TH) && |
712 | (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { | 712 | (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { |
713 | window->average_tpt = IWL_INVALID_VALUE; | 713 | window->average_tpt = IWL_INV_TPT; |
714 | spin_unlock_irqrestore(&rs_sta->lock, flags); | 714 | spin_unlock_irqrestore(&rs_sta->lock, flags); |
715 | 715 | ||
716 | IWL_DEBUG_RATE("Invalid average_tpt on rate %d: " | 716 | IWL_DEBUG_RATE("Invalid average_tpt on rate %d: " |
@@ -729,7 +729,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
729 | current_tpt = window->average_tpt; | 729 | current_tpt = window->average_tpt; |
730 | 730 | ||
731 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, | 731 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, |
732 | band->band); | 732 | sband->band); |
733 | low = high_low & 0xff; | 733 | low = high_low & 0xff; |
734 | high = (high_low >> 8) & 0xff; | 734 | high = (high_low >> 8) & 0xff; |
735 | 735 | ||
@@ -746,19 +746,16 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
746 | if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { | 746 | if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { |
747 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); | 747 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); |
748 | scale_action = -1; | 748 | scale_action = -1; |
749 | } else if ((low_tpt == IWL_INVALID_VALUE) && | 749 | } else if ((low_tpt == IWL_INV_TPT) && (high_tpt == IWL_INV_TPT)) |
750 | (high_tpt == IWL_INVALID_VALUE)) | ||
751 | scale_action = 1; | 750 | scale_action = 1; |
752 | else if ((low_tpt != IWL_INVALID_VALUE) && | 751 | else if ((low_tpt != IWL_INV_TPT) && (high_tpt != IWL_INV_TPT) && |
753 | (high_tpt != IWL_INVALID_VALUE) | 752 | (low_tpt < current_tpt) && (high_tpt < current_tpt)) { |
754 | && (low_tpt < current_tpt) | ||
755 | && (high_tpt < current_tpt)) { | ||
756 | IWL_DEBUG_RATE("No action -- low [%d] & high [%d] < " | 753 | IWL_DEBUG_RATE("No action -- low [%d] & high [%d] < " |
757 | "current_tpt [%d]\n", | 754 | "current_tpt [%d]\n", |
758 | low_tpt, high_tpt, current_tpt); | 755 | low_tpt, high_tpt, current_tpt); |
759 | scale_action = 0; | 756 | scale_action = 0; |
760 | } else { | 757 | } else { |
761 | if (high_tpt != IWL_INVALID_VALUE) { | 758 | if (high_tpt != IWL_INV_TPT) { |
762 | if (high_tpt > current_tpt) | 759 | if (high_tpt > current_tpt) |
763 | scale_action = 1; | 760 | scale_action = 1; |
764 | else { | 761 | else { |
@@ -766,7 +763,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
766 | ("decrease rate because of high tpt\n"); | 763 | ("decrease rate because of high tpt\n"); |
767 | scale_action = -1; | 764 | scale_action = -1; |
768 | } | 765 | } |
769 | } else if (low_tpt != IWL_INVALID_VALUE) { | 766 | } else if (low_tpt != IWL_INV_TPT) { |
770 | if (low_tpt > current_tpt) { | 767 | if (low_tpt > current_tpt) { |
771 | IWL_DEBUG_RATE | 768 | IWL_DEBUG_RATE |
772 | ("decrease rate because of low tpt\n"); | 769 | ("decrease rate because of low tpt\n"); |
@@ -808,7 +805,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
808 | out: | 805 | out: |
809 | 806 | ||
810 | sta->last_txrate_idx = index; | 807 | sta->last_txrate_idx = index; |
811 | if (priv->band == IEEE80211_BAND_5GHZ) | 808 | if (sband->band == IEEE80211_BAND_5GHZ) |
812 | sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; | 809 | sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; |
813 | else | 810 | else |
814 | sta->txrate_idx = sta->last_txrate_idx; | 811 | sta->txrate_idx = sta->last_txrate_idx; |
@@ -817,7 +814,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
817 | 814 | ||
818 | IWL_DEBUG_RATE("leave: %d\n", index); | 815 | IWL_DEBUG_RATE("leave: %d\n", index); |
819 | 816 | ||
820 | sel->rate = &priv->ieee_rates[index]; | 817 | sel->rate = &sband->bitrates[sta->txrate_idx]; |
821 | } | 818 | } |
822 | 819 | ||
823 | static struct rate_control_ops rs_ops = { | 820 | static struct rate_control_ops rs_ops = { |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h index 3c61f08febe6..b082a093ee26 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h | |||
@@ -159,7 +159,7 @@ enum { | |||
159 | 159 | ||
160 | #define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) | 160 | #define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) |
161 | 161 | ||
162 | #define IWL_INVALID_VALUE -1 | 162 | #define IWL_INV_TPT -1 |
163 | 163 | ||
164 | #define IWL_MIN_RSSI_VAL -100 | 164 | #define IWL_MIN_RSSI_VAL -100 |
165 | #define IWL_MAX_RSSI_VAL 0 | 165 | #define IWL_MAX_RSSI_VAL 0 |