diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-rs.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 88 |
1 files changed, 40 insertions, 48 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index 80d31ae51e77..f018ce464d97 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -100,14 +100,6 @@ static struct iwl3945_tpt_entry iwl3945_tpt_table_a[] = { | |||
100 | {-89, IWL_RATE_6M_INDEX} | 100 | {-89, IWL_RATE_6M_INDEX} |
101 | }; | 101 | }; |
102 | 102 | ||
103 | static struct iwl3945_tpt_entry iwl3945_tpt_table_b[] = { | ||
104 | {-86, IWL_RATE_11M_INDEX}, | ||
105 | {-88, IWL_RATE_5M_INDEX}, | ||
106 | {-90, IWL_RATE_2M_INDEX}, | ||
107 | {-92, IWL_RATE_1M_INDEX} | ||
108 | |||
109 | }; | ||
110 | |||
111 | static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { | 103 | static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { |
112 | {-60, IWL_RATE_54M_INDEX}, | 104 | {-60, IWL_RATE_54M_INDEX}, |
113 | {-64, IWL_RATE_48M_INDEX}, | 105 | {-64, IWL_RATE_48M_INDEX}, |
@@ -129,7 +121,7 @@ static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { | |||
129 | #define IWL_RATE_MIN_SUCCESS_TH 8 | 121 | #define IWL_RATE_MIN_SUCCESS_TH 8 |
130 | #define IWL_RATE_DECREASE_TH 1920 | 122 | #define IWL_RATE_DECREASE_TH 1920 |
131 | 123 | ||
132 | static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, u8 mode) | 124 | static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) |
133 | { | 125 | { |
134 | u32 index = 0; | 126 | u32 index = 0; |
135 | u32 table_size = 0; | 127 | u32 table_size = 0; |
@@ -138,21 +130,19 @@ static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, u8 mode) | |||
138 | if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) | 130 | if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) |
139 | rssi = IWL_MIN_RSSI_VAL; | 131 | rssi = IWL_MIN_RSSI_VAL; |
140 | 132 | ||
141 | switch (mode) { | 133 | switch (band) { |
142 | case MODE_IEEE80211G: | 134 | case IEEE80211_BAND_2GHZ: |
143 | tpt_table = iwl3945_tpt_table_g; | 135 | tpt_table = iwl3945_tpt_table_g; |
144 | table_size = ARRAY_SIZE(iwl3945_tpt_table_g); | 136 | table_size = ARRAY_SIZE(iwl3945_tpt_table_g); |
145 | break; | 137 | break; |
146 | 138 | ||
147 | case MODE_IEEE80211A: | 139 | case IEEE80211_BAND_5GHZ: |
148 | tpt_table = iwl3945_tpt_table_a; | 140 | tpt_table = iwl3945_tpt_table_a; |
149 | table_size = ARRAY_SIZE(iwl3945_tpt_table_a); | 141 | table_size = ARRAY_SIZE(iwl3945_tpt_table_a); |
150 | break; | 142 | break; |
151 | 143 | ||
152 | default: | 144 | default: |
153 | case MODE_IEEE80211B: | 145 | BUG(); |
154 | tpt_table = iwl3945_tpt_table_b; | ||
155 | table_size = ARRAY_SIZE(iwl3945_tpt_table_b); | ||
156 | break; | 146 | break; |
157 | } | 147 | } |
158 | 148 | ||
@@ -340,17 +330,17 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
340 | * after assoc.. */ | 330 | * after assoc.. */ |
341 | 331 | ||
342 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { | 332 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { |
343 | if (sta->supp_rates & (1 << i)) { | 333 | if (sta->supp_rates[local->hw.conf.channel->band] & (1 << i)) { |
344 | sta->txrate = i; | 334 | sta->txrate_idx = i; |
345 | break; | 335 | break; |
346 | } | 336 | } |
347 | } | 337 | } |
348 | 338 | ||
349 | sta->last_txrate = sta->txrate; | 339 | sta->last_txrate_idx = sta->txrate_idx; |
350 | 340 | ||
351 | /* For MODE_IEEE80211A mode it start at IWL_FIRST_OFDM_RATE */ | 341 | /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ |
352 | if (local->hw.conf.phymode == MODE_IEEE80211A) | 342 | if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) |
353 | sta->last_txrate += IWL_FIRST_OFDM_RATE; | 343 | sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; |
354 | 344 | ||
355 | IWL_DEBUG_RATE("leave\n"); | 345 | IWL_DEBUG_RATE("leave\n"); |
356 | } | 346 | } |
@@ -429,17 +419,19 @@ static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate) | |||
429 | { | 419 | { |
430 | int next_rate = iwl3945_get_prev_ieee_rate(rate); | 420 | int next_rate = iwl3945_get_prev_ieee_rate(rate); |
431 | 421 | ||
432 | switch (priv->phymode) { | 422 | switch (priv->band) { |
433 | case MODE_IEEE80211A: | 423 | case IEEE80211_BAND_5GHZ: |
434 | if (rate == IWL_RATE_12M_INDEX) | 424 | if (rate == IWL_RATE_12M_INDEX) |
435 | next_rate = IWL_RATE_9M_INDEX; | 425 | next_rate = IWL_RATE_9M_INDEX; |
436 | else if (rate == IWL_RATE_6M_INDEX) | 426 | else if (rate == IWL_RATE_6M_INDEX) |
437 | next_rate = IWL_RATE_6M_INDEX; | 427 | next_rate = IWL_RATE_6M_INDEX; |
438 | break; | 428 | break; |
429 | /* XXX cannot be invoked in current mac80211 so not a regression | ||
439 | case MODE_IEEE80211B: | 430 | case MODE_IEEE80211B: |
440 | if (rate == IWL_RATE_11M_INDEX_TABLE) | 431 | if (rate == IWL_RATE_11M_INDEX_TABLE) |
441 | next_rate = IWL_RATE_5M_INDEX_TABLE; | 432 | next_rate = IWL_RATE_5M_INDEX_TABLE; |
442 | break; | 433 | break; |
434 | */ | ||
443 | default: | 435 | default: |
444 | break; | 436 | break; |
445 | } | 437 | } |
@@ -465,15 +457,17 @@ static void rs_tx_status(void *priv_rate, | |||
465 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; | 457 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; |
466 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 458 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
467 | struct iwl3945_rs_sta *rs_sta; | 459 | struct iwl3945_rs_sta *rs_sta; |
460 | struct ieee80211_supported_band *sband; | ||
461 | |||
462 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
468 | 463 | ||
469 | IWL_DEBUG_RATE("enter\n"); | 464 | IWL_DEBUG_RATE("enter\n"); |
470 | 465 | ||
471 | retries = tx_resp->retry_count; | 466 | retries = tx_resp->retry_count; |
472 | 467 | ||
473 | first_index = tx_resp->control.tx_rate; | 468 | first_index = &sband->bitrates[0] - tx_resp->control.tx_rate; |
474 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { | 469 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { |
475 | IWL_DEBUG_RATE("leave: Rate out of bounds: %0x for %d\n", | 470 | IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); |
476 | tx_resp->control.tx_rate, first_index); | ||
477 | return; | 471 | return; |
478 | } | 472 | } |
479 | 473 | ||
@@ -561,14 +555,14 @@ static void rs_tx_status(void *priv_rate, | |||
561 | } | 555 | } |
562 | 556 | ||
563 | static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | 557 | static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, |
564 | u8 index, u16 rate_mask, int phymode) | 558 | u8 index, u16 rate_mask, enum ieee80211_band band) |
565 | { | 559 | { |
566 | u8 high = IWL_RATE_INVALID; | 560 | u8 high = IWL_RATE_INVALID; |
567 | u8 low = IWL_RATE_INVALID; | 561 | u8 low = IWL_RATE_INVALID; |
568 | 562 | ||
569 | /* 802.11A walks to the next literal adjacent rate in | 563 | /* 802.11A walks to the next literal adjacent rate in |
570 | * the rate table */ | 564 | * the rate table */ |
571 | if (unlikely(phymode == MODE_IEEE80211A)) { | 565 | if (unlikely(band == IEEE80211_BAND_5GHZ)) { |
572 | int i; | 566 | int i; |
573 | u32 mask; | 567 | u32 mask; |
574 | 568 | ||
@@ -639,7 +633,8 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | |||
639 | * | 633 | * |
640 | */ | 634 | */ |
641 | static void rs_get_rate(void *priv_rate, struct net_device *dev, | 635 | static void rs_get_rate(void *priv_rate, struct net_device *dev, |
642 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, | 636 | struct ieee80211_supported_band *band, |
637 | struct sk_buff *skb, | ||
643 | struct rate_selection *sel) | 638 | struct rate_selection *sel) |
644 | { | 639 | { |
645 | u8 low = IWL_RATE_INVALID; | 640 | u8 low = IWL_RATE_INVALID; |
@@ -672,16 +667,16 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
672 | is_multicast_ether_addr(hdr->addr1) || | 667 | is_multicast_ether_addr(hdr->addr1) || |
673 | !sta || !sta->rate_ctrl_priv) { | 668 | !sta || !sta->rate_ctrl_priv) { |
674 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 669 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
675 | sel->rate = rate_lowest(local, local->oper_hw_mode, sta); | 670 | sel->rate = rate_lowest(local, band, sta); |
676 | if (sta) | 671 | if (sta) |
677 | sta_info_put(sta); | 672 | sta_info_put(sta); |
678 | return; | 673 | return; |
679 | } | 674 | } |
680 | 675 | ||
681 | rate_mask = sta->supp_rates; | 676 | rate_mask = sta->supp_rates[band->band]; |
682 | index = min(sta->last_txrate & 0xffff, IWL_RATE_COUNT - 1); | 677 | index = min(sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); |
683 | 678 | ||
684 | if (priv->phymode == (u8) MODE_IEEE80211A) | 679 | if (priv->band == IEEE80211_BAND_5GHZ) |
685 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; | 680 | rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; |
686 | 681 | ||
687 | rs_sta = (void *)sta->rate_ctrl_priv; | 682 | rs_sta = (void *)sta->rate_ctrl_priv; |
@@ -732,7 +727,7 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
732 | current_tpt = window->average_tpt; | 727 | current_tpt = window->average_tpt; |
733 | 728 | ||
734 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, | 729 | high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, |
735 | local->hw.conf.phymode); | 730 | band->band); |
736 | low = high_low & 0xff; | 731 | low = high_low & 0xff; |
737 | high = (high_low >> 8) & 0xff; | 732 | high = (high_low >> 8) & 0xff; |
738 | 733 | ||
@@ -810,11 +805,11 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
810 | 805 | ||
811 | out: | 806 | out: |
812 | 807 | ||
813 | sta->last_txrate = index; | 808 | sta->last_txrate_idx = index; |
814 | if (priv->phymode == (u8) MODE_IEEE80211A) | 809 | if (priv->band == IEEE80211_BAND_5GHZ) |
815 | sta->txrate = sta->last_txrate - IWL_FIRST_OFDM_RATE; | 810 | sta->txrate_idx = sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; |
816 | else | 811 | else |
817 | sta->txrate = sta->last_txrate; | 812 | sta->txrate_idx = sta->last_txrate_idx; |
818 | 813 | ||
819 | sta_info_put(sta); | 814 | sta_info_put(sta); |
820 | 815 | ||
@@ -945,8 +940,9 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
945 | spin_lock_irqsave(&rs_sta->lock, flags); | 940 | spin_lock_irqsave(&rs_sta->lock, flags); |
946 | 941 | ||
947 | rs_sta->tgg = 0; | 942 | rs_sta->tgg = 0; |
948 | switch (priv->phymode) { | 943 | switch (priv->band) { |
949 | case MODE_IEEE80211G: | 944 | case IEEE80211_BAND_2GHZ: |
945 | /* TODO: this always does G, not a regression */ | ||
950 | if (priv->active_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) { | 946 | if (priv->active_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) { |
951 | rs_sta->tgg = 1; | 947 | rs_sta->tgg = 1; |
952 | rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; | 948 | rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; |
@@ -954,14 +950,11 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
954 | rs_sta->expected_tpt = iwl3945_expected_tpt_g; | 950 | rs_sta->expected_tpt = iwl3945_expected_tpt_g; |
955 | break; | 951 | break; |
956 | 952 | ||
957 | case MODE_IEEE80211A: | 953 | case IEEE80211_BAND_5GHZ: |
958 | rs_sta->expected_tpt = iwl3945_expected_tpt_a; | 954 | rs_sta->expected_tpt = iwl3945_expected_tpt_a; |
959 | break; | 955 | break; |
960 | 956 | case IEEE80211_NUM_BANDS: | |
961 | default: | 957 | BUG(); |
962 | IWL_WARNING("Invalid phymode. Defaulting to 802.11b\n"); | ||
963 | case MODE_IEEE80211B: | ||
964 | rs_sta->expected_tpt = iwl3945_expected_tpt_b; | ||
965 | break; | 958 | break; |
966 | } | 959 | } |
967 | 960 | ||
@@ -974,8 +967,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | |||
974 | 967 | ||
975 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_RATE, "Network RSSI: %d\n", rssi); | 968 | IWL_DEBUG(IWL_DL_INFO | IWL_DL_RATE, "Network RSSI: %d\n", rssi); |
976 | 969 | ||
977 | rs_sta->start_rate = | 970 | rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band); |
978 | iwl3945_get_rate_index_by_rssi(rssi, priv->phymode); | ||
979 | 971 | ||
980 | IWL_DEBUG_RATE("leave: rssi %d assign rate index: " | 972 | IWL_DEBUG_RATE("leave: rssi %d assign rate index: " |
981 | "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, | 973 | "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, |