diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-rs.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index a8223c4cc97c..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,22 +459,23 @@ 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; |
472 | } | 472 | } |
473 | 473 | ||
474 | rcu_read_lock(); | ||
475 | |||
474 | sta = sta_info_get(local, hdr->addr1); | 476 | sta = sta_info_get(local, hdr->addr1); |
475 | if (!sta || !sta->rate_ctrl_priv) { | 477 | if (!sta || !sta->rate_ctrl_priv) { |
476 | if (sta) | 478 | rcu_read_unlock(); |
477 | sta_info_put(sta); | ||
478 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 479 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
479 | return; | 480 | return; |
480 | } | 481 | } |
@@ -547,7 +548,7 @@ static void rs_tx_status(void *priv_rate, | |||
547 | 548 | ||
548 | spin_unlock_irqrestore(&rs_sta->lock, flags); | 549 | spin_unlock_irqrestore(&rs_sta->lock, flags); |
549 | 550 | ||
550 | sta_info_put(sta); | 551 | rcu_read_unlock(); |
551 | 552 | ||
552 | IWL_DEBUG_RATE("leave\n"); | 553 | IWL_DEBUG_RATE("leave\n"); |
553 | 554 | ||
@@ -633,7 +634,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | |||
633 | * | 634 | * |
634 | */ | 635 | */ |
635 | 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, |
636 | struct ieee80211_supported_band *band, | 637 | struct ieee80211_supported_band *sband, |
637 | struct sk_buff *skb, | 638 | struct sk_buff *skb, |
638 | struct rate_selection *sel) | 639 | struct rate_selection *sel) |
639 | { | 640 | { |
@@ -643,9 +644,9 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
643 | int index; | 644 | int index; |
644 | struct iwl3945_rs_sta *rs_sta; | 645 | struct iwl3945_rs_sta *rs_sta; |
645 | struct iwl3945_rate_scale_data *window = NULL; | 646 | struct iwl3945_rate_scale_data *window = NULL; |
646 | int current_tpt = IWL_INVALID_VALUE; | 647 | int current_tpt = IWL_INV_TPT; |
647 | int low_tpt = IWL_INVALID_VALUE; | 648 | int low_tpt = IWL_INV_TPT; |
648 | int high_tpt = IWL_INVALID_VALUE; | 649 | int high_tpt = IWL_INV_TPT; |
649 | u32 fail_count; | 650 | u32 fail_count; |
650 | s8 scale_action = 0; | 651 | s8 scale_action = 0; |
651 | unsigned long flags; | 652 | unsigned long flags; |
@@ -658,6 +659,8 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
658 | 659 | ||
659 | IWL_DEBUG_RATE("enter\n"); | 660 | IWL_DEBUG_RATE("enter\n"); |
660 | 661 | ||
662 | rcu_read_lock(); | ||
663 | |||
661 | sta = sta_info_get(local, hdr->addr1); | 664 | sta = sta_info_get(local, hdr->addr1); |
662 | 665 | ||
663 | /* Send management frames and broadcast/multicast data using lowest | 666 | /* Send management frames and broadcast/multicast data using lowest |
@@ -667,16 +670,15 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
667 | is_multicast_ether_addr(hdr->addr1) || | 670 | is_multicast_ether_addr(hdr->addr1) || |
668 | !sta || !sta->rate_ctrl_priv) { | 671 | !sta || !sta->rate_ctrl_priv) { |
669 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 672 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
670 | sel->rate = rate_lowest(local, band, sta); | 673 | sel->rate = rate_lowest(local, sband, sta); |
671 | if (sta) | 674 | rcu_read_unlock(); |
672 | sta_info_put(sta); | ||
673 | return; | 675 | return; |
674 | } | 676 | } |
675 | 677 | ||
676 | rate_mask = sta->supp_rates[band->band]; | 678 | rate_mask = sta->supp_rates[sband->band]; |
677 | index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); | 679 | index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); |
678 | 680 | ||
679 | if (priv->band == IEEE80211_BAND_5GHZ) | 681 | if (sband->band == IEEE80211_BAND_5GHZ) |
680 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; | 682 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; |
681 | 683 | ||
682 | rs_sta = (void *)sta->rate_ctrl_priv; | 684 | rs_sta = (void *)sta->rate_ctrl_priv; |
@@ -708,7 +710,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
708 | 710 | ||
709 | if (((fail_count <= IWL_RATE_MIN_FAILURE_TH) && | 711 | if (((fail_count <= IWL_RATE_MIN_FAILURE_TH) && |
710 | (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { | 712 | (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { |
711 | window->average_tpt = IWL_INVALID_VALUE; | 713 | window->average_tpt = IWL_INV_TPT; |
712 | spin_unlock_irqrestore(&rs_sta->lock, flags); | 714 | spin_unlock_irqrestore(&rs_sta->lock, flags); |
713 | 715 | ||
714 | IWL_DEBUG_RATE("Invalid average_tpt on rate %d: " | 716 | IWL_DEBUG_RATE("Invalid average_tpt on rate %d: " |
@@ -727,7 +729,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
727 | current_tpt = window->average_tpt; | 729 | current_tpt = window->average_tpt; |
728 | 730 | ||
729 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, | 731 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, |
730 | band->band); | 732 | sband->band); |
731 | low = high_low & 0xff; | 733 | low = high_low & 0xff; |
732 | high = (high_low >> 8) & 0xff; | 734 | high = (high_low >> 8) & 0xff; |
733 | 735 | ||
@@ -744,19 +746,16 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
744 | if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { | 746 | if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { |
745 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); | 747 | IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); |
746 | scale_action = -1; | 748 | scale_action = -1; |
747 | } else if ((low_tpt == IWL_INVALID_VALUE) && | 749 | } else if ((low_tpt == IWL_INV_TPT) && (high_tpt == IWL_INV_TPT)) |
748 | (high_tpt == IWL_INVALID_VALUE)) | ||
749 | scale_action = 1; | 750 | scale_action = 1; |
750 | else if ((low_tpt != IWL_INVALID_VALUE) && | 751 | else if ((low_tpt != IWL_INV_TPT) && (high_tpt != IWL_INV_TPT) && |
751 | (high_tpt != IWL_INVALID_VALUE) | 752 | (low_tpt < current_tpt) && (high_tpt < current_tpt)) { |
752 | && (low_tpt < current_tpt) | ||
753 | && (high_tpt < current_tpt)) { | ||
754 | IWL_DEBUG_RATE("No action -- low [%d] & high [%d] < " | 753 | IWL_DEBUG_RATE("No action -- low [%d] & high [%d] < " |
755 | "current_tpt [%d]\n", | 754 | "current_tpt [%d]\n", |
756 | low_tpt, high_tpt, current_tpt); | 755 | low_tpt, high_tpt, current_tpt); |
757 | scale_action = 0; | 756 | scale_action = 0; |
758 | } else { | 757 | } else { |
759 | if (high_tpt != IWL_INVALID_VALUE) { | 758 | if (high_tpt != IWL_INV_TPT) { |
760 | if (high_tpt > current_tpt) | 759 | if (high_tpt > current_tpt) |
761 | scale_action = 1; | 760 | scale_action = 1; |
762 | else { | 761 | else { |
@@ -764,7 +763,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
764 | ("decrease rate because of high tpt\n"); | 763 | ("decrease rate because of high tpt\n"); |
765 | scale_action = -1; | 764 | scale_action = -1; |
766 | } | 765 | } |
767 | } else if (low_tpt != IWL_INVALID_VALUE) { | 766 | } else if (low_tpt != IWL_INV_TPT) { |
768 | if (low_tpt > current_tpt) { | 767 | if (low_tpt > current_tpt) { |
769 | IWL_DEBUG_RATE | 768 | IWL_DEBUG_RATE |
770 | ("decrease rate because of low tpt\n"); | 769 | ("decrease rate because of low tpt\n"); |
@@ -806,16 +805,16 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
806 | out: | 805 | out: |
807 | 806 | ||
808 | sta->last_txrate_idx = index; | 807 | sta->last_txrate_idx = index; |
809 | if (priv->band == IEEE80211_BAND_5GHZ) | 808 | if (sband->band == IEEE80211_BAND_5GHZ) |
810 | sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; | 809 | sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; |
811 | else | 810 | else |
812 | sta->txrate_idx = sta->last_txrate_idx; | 811 | sta->txrate_idx = sta->last_txrate_idx; |
813 | 812 | ||
814 | sta_info_put(sta); | 813 | rcu_read_unlock(); |
815 | 814 | ||
816 | IWL_DEBUG_RATE("leave: %d\n", index); | 815 | IWL_DEBUG_RATE("leave: %d\n", index); |
817 | 816 | ||
818 | sel->rate = &priv->ieee_rates[index]; | 817 | sel->rate = &sband->bitrates[sta->txrate_idx]; |
819 | } | 818 | } |
820 | 819 | ||
821 | static struct rate_control_ops rs_ops = { | 820 | static struct rate_control_ops rs_ops = { |
@@ -843,13 +842,15 @@ int iwl3945_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | |||
843 | unsigned long now = jiffies; | 842 | unsigned long now = jiffies; |
844 | u32 max_time = 0; | 843 | u32 max_time = 0; |
845 | 844 | ||
845 | rcu_read_lock(); | ||
846 | |||
846 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); | 847 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); |
847 | if (!sta || !sta->rate_ctrl_priv) { | 848 | if (!sta || !sta->rate_ctrl_priv) { |
848 | if (sta) { | 849 | if (sta) |
849 | sta_info_put(sta); | ||
850 | IWL_DEBUG_RATE("leave - no private rate data!\n"); | 850 | IWL_DEBUG_RATE("leave - no private rate data!\n"); |
851 | } else | 851 | else |
852 | IWL_DEBUG_RATE("leave - no station!\n"); | 852 | IWL_DEBUG_RATE("leave - no station!\n"); |
853 | rcu_read_unlock(); | ||
853 | return sprintf(buf, "station %d not found\n", sta_id); | 854 | return sprintf(buf, "station %d not found\n", sta_id); |
854 | } | 855 | } |
855 | 856 | ||
@@ -890,7 +891,7 @@ int iwl3945_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | |||
890 | i = j; | 891 | i = j; |
891 | } | 892 | } |
892 | spin_unlock_irqrestore(&rs_sta->lock, flags); | 893 | spin_unlock_irqrestore(&rs_sta->lock, flags); |
893 | sta_info_put(sta); | 894 | rcu_read_unlock(); |
894 | 895 | ||
895 | /* Display the average rate of all samples taken. | 896 | /* Display the average rate of all samples taken. |
896 | * | 897 | * |
@@ -927,11 +928,12 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
927 | return; | 928 | return; |
928 | } | 929 | } |
929 | 930 | ||
931 | rcu_read_lock(); | ||
932 | |||
930 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); | 933 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); |
931 | if (!sta || !sta->rate_ctrl_priv) { | 934 | if (!sta || !sta->rate_ctrl_priv) { |
932 | if (sta) | ||
933 | sta_info_put(sta); | ||
934 | IWL_DEBUG_RATE("leave - no private rate data!\n"); | 935 | IWL_DEBUG_RATE("leave - no private rate data!\n"); |
936 | rcu_read_unlock(); | ||
935 | return; | 937 | return; |
936 | } | 938 | } |
937 | 939 | ||
@@ -958,7 +960,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
958 | break; | 960 | break; |
959 | } | 961 | } |
960 | 962 | ||
961 | sta_info_put(sta); | 963 | rcu_read_unlock(); |
962 | spin_unlock_irqrestore(&rs_sta->lock, flags); | 964 | spin_unlock_irqrestore(&rs_sta->lock, flags); |
963 | 965 | ||
964 | rssi = priv->last_rx_rssi; | 966 | rssi = priv->last_rx_rssi; |