aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-10-21 06:40:02 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 19:00:23 -0400
commite6a9854b05c1a6af1308fe2b8c68f35abf28a3ee (patch)
tree241f611f8194586ccabf61bacb060508773b9d05 /drivers/net/wireless/iwlwifi/iwl-3945-rs.c
parentcb121bad67a32cde37adc2729b7e18aa4fd3063e (diff)
mac80211/drivers: rewrite the rate control API
So after the previous changes we were still unhappy with how convoluted the API is and decided to make things simpler for everybody. This completely changes the rate control API, now taking into account 802.11n with MCS rates and more control, most drivers don't support that though. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-rs.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c57
1 files changed, 18 insertions, 39 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index c25daec4f93d..f440ed0fe543 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -422,34 +422,6 @@ static void rs_free_sta(void *priv, struct ieee80211_sta *sta,
422} 422}
423 423
424 424
425/*
426 * get ieee prev rate from rate scale table.
427 * for A and B mode we need to overright prev
428 * value
429 */
430static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate)
431{
432 int next_rate = iwl3945_get_prev_ieee_rate(rate);
433
434 switch (priv->band) {
435 case IEEE80211_BAND_5GHZ:
436 if (rate == IWL_RATE_12M_INDEX)
437 next_rate = IWL_RATE_9M_INDEX;
438 else if (rate == IWL_RATE_6M_INDEX)
439 next_rate = IWL_RATE_6M_INDEX;
440 break;
441/* XXX cannot be invoked in current mac80211 so not a regression
442 case MODE_IEEE80211B:
443 if (rate == IWL_RATE_11M_INDEX_TABLE)
444 next_rate = IWL_RATE_5M_INDEX_TABLE;
445 break;
446 */
447 default:
448 break;
449 }
450
451 return next_rate;
452}
453/** 425/**
454 * rs_tx_status - Update rate control values based on Tx results 426 * rs_tx_status - Update rate control values based on Tx results
455 * 427 *
@@ -460,17 +432,21 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
460 struct ieee80211_sta *sta, void *priv_sta, 432 struct ieee80211_sta *sta, void *priv_sta,
461 struct sk_buff *skb) 433 struct sk_buff *skb)
462{ 434{
463 u8 retries, current_count; 435 u8 retries = 0, current_count;
464 int scale_rate_index, first_index, last_index; 436 int scale_rate_index, first_index, last_index;
465 unsigned long flags; 437 unsigned long flags;
466 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; 438 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate;
467 struct iwl3945_rs_sta *rs_sta = priv_sta; 439 struct iwl3945_rs_sta *rs_sta = priv_sta;
468 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 440 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
441 int i;
469 442
470 IWL_DEBUG_RATE("enter\n"); 443 IWL_DEBUG_RATE("enter\n");
471 444
472 retries = info->status.retry_count; 445 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
473 first_index = sband->bitrates[info->tx_rate_idx].hw_value; 446 retries += info->status.rates[i].count;
447 retries--;
448
449 first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
474 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { 450 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) {
475 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); 451 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index);
476 return; 452 return;
@@ -502,7 +478,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
502 last_index = scale_rate_index; 478 last_index = scale_rate_index;
503 } else { 479 } else {
504 current_count = priv->retry_rate; 480 current_count = priv->retry_rate;
505 last_index = rs_adjust_next_rate(priv, 481 last_index = iwl3945_rs_next_rate(priv,
506 scale_rate_index); 482 scale_rate_index);
507 } 483 }
508 484
@@ -518,7 +494,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
518 494
519 if (retries) 495 if (retries)
520 scale_rate_index = 496 scale_rate_index =
521 rs_adjust_next_rate(priv, scale_rate_index); 497 iwl3945_rs_next_rate(priv, scale_rate_index);
522 } 498 }
523 499
524 500
@@ -630,10 +606,11 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
630 * rate table and must reference the driver allocated rate table 606 * rate table and must reference the driver allocated rate table
631 * 607 *
632 */ 608 */
633static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband, 609static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
634 struct ieee80211_sta *sta, void *priv_sta, 610 void *priv_sta, struct ieee80211_tx_rate_control *txrc)
635 struct sk_buff *skb, struct rate_selection *sel)
636{ 611{
612 struct ieee80211_supported_band *sband = txrc->sband;
613 struct sk_buff *skb = txrc->skb;
637 u8 low = IWL_RATE_INVALID; 614 u8 low = IWL_RATE_INVALID;
638 u8 high = IWL_RATE_INVALID; 615 u8 high = IWL_RATE_INVALID;
639 u16 high_low; 616 u16 high_low;
@@ -649,6 +626,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
649 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 626 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
650 u16 fc, rate_mask; 627 u16 fc, rate_mask;
651 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r; 628 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r;
629 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
652 630
653 IWL_DEBUG_RATE("enter\n"); 631 IWL_DEBUG_RATE("enter\n");
654 632
@@ -659,7 +637,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
659 is_multicast_ether_addr(hdr->addr1) || 637 is_multicast_ether_addr(hdr->addr1) ||
660 !sta || !priv_sta) { 638 !sta || !priv_sta) {
661 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 639 IWL_DEBUG_RATE("leave: No STA priv data to update!\n");
662 sel->rate_idx = rate_lowest_index(sband, sta); 640 info->control.rates[0].idx = rate_lowest_index(sband, sta);
663 return; 641 return;
664 } 642 }
665 643
@@ -792,9 +770,10 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
792 770
793 rs_sta->last_txrate_idx = index; 771 rs_sta->last_txrate_idx = index;
794 if (sband->band == IEEE80211_BAND_5GHZ) 772 if (sband->band == IEEE80211_BAND_5GHZ)
795 sel->rate_idx = rs_sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; 773 info->control.rates[0].idx = rs_sta->last_txrate_idx -
774 IWL_FIRST_OFDM_RATE;
796 else 775 else
797 sel->rate_idx = rs_sta->last_txrate_idx; 776 info->control.rates[0].idx = rs_sta->last_txrate_idx;
798 777
799 IWL_DEBUG_RATE("leave: %d\n", index); 778 IWL_DEBUG_RATE("leave: %d\n", index);
800} 779}