aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-rs.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c76
1 files changed, 23 insertions, 53 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 6fc5e7361f26..bfeef701b1fd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -355,12 +355,6 @@ static void rs_free(void *priv)
355 return; 355 return;
356} 356}
357 357
358static void rs_clear(void *priv)
359{
360 return;
361}
362
363
364static void *rs_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) 358static void *rs_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
365{ 359{
366 struct iwl3945_rs_sta *rs_sta; 360 struct iwl3945_rs_sta *rs_sta;
@@ -422,34 +416,6 @@ static void rs_free_sta(void *priv, struct ieee80211_sta *sta,
422} 416}
423 417
424 418
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/** 419/**
454 * rs_tx_status - Update rate control values based on Tx results 420 * rs_tx_status - Update rate control values based on Tx results
455 * 421 *
@@ -460,17 +426,21 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
460 struct ieee80211_sta *sta, void *priv_sta, 426 struct ieee80211_sta *sta, void *priv_sta,
461 struct sk_buff *skb) 427 struct sk_buff *skb)
462{ 428{
463 u8 retries, current_count; 429 u8 retries = 0, current_count;
464 int scale_rate_index, first_index, last_index; 430 int scale_rate_index, first_index, last_index;
465 unsigned long flags; 431 unsigned long flags;
466 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; 432 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate;
467 struct iwl3945_rs_sta *rs_sta = priv_sta; 433 struct iwl3945_rs_sta *rs_sta = priv_sta;
468 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 434 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
435 int i;
469 436
470 IWL_DEBUG_RATE("enter\n"); 437 IWL_DEBUG_RATE("enter\n");
471 438
472 retries = info->status.retry_count; 439 for (i = 0; i < IEEE80211_TX_MAX_RATES; i++)
473 first_index = sband->bitrates[info->tx_rate_idx].hw_value; 440 retries += info->status.rates[i].count;
441 retries--;
442
443 first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
474 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { 444 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) {
475 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); 445 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index);
476 return; 446 return;
@@ -502,7 +472,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
502 last_index = scale_rate_index; 472 last_index = scale_rate_index;
503 } else { 473 } else {
504 current_count = priv->retry_rate; 474 current_count = priv->retry_rate;
505 last_index = rs_adjust_next_rate(priv, 475 last_index = iwl3945_rs_next_rate(priv,
506 scale_rate_index); 476 scale_rate_index);
507 } 477 }
508 478
@@ -518,7 +488,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
518 488
519 if (retries) 489 if (retries)
520 scale_rate_index = 490 scale_rate_index =
521 rs_adjust_next_rate(priv, scale_rate_index); 491 iwl3945_rs_next_rate(priv, scale_rate_index);
522 } 492 }
523 493
524 494
@@ -630,10 +600,11 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
630 * rate table and must reference the driver allocated rate table 600 * rate table and must reference the driver allocated rate table
631 * 601 *
632 */ 602 */
633static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband, 603static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
634 struct ieee80211_sta *sta, void *priv_sta, 604 void *priv_sta, struct ieee80211_tx_rate_control *txrc)
635 struct sk_buff *skb, struct rate_selection *sel)
636{ 605{
606 struct ieee80211_supported_band *sband = txrc->sband;
607 struct sk_buff *skb = txrc->skb;
637 u8 low = IWL_RATE_INVALID; 608 u8 low = IWL_RATE_INVALID;
638 u8 high = IWL_RATE_INVALID; 609 u8 high = IWL_RATE_INVALID;
639 u16 high_low; 610 u16 high_low;
@@ -649,7 +620,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
649 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 620 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
650 u16 fc, rate_mask; 621 u16 fc, rate_mask;
651 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r; 622 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r;
652 DECLARE_MAC_BUF(mac); 623 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
653 624
654 IWL_DEBUG_RATE("enter\n"); 625 IWL_DEBUG_RATE("enter\n");
655 626
@@ -660,7 +631,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
660 is_multicast_ether_addr(hdr->addr1) || 631 is_multicast_ether_addr(hdr->addr1) ||
661 !sta || !priv_sta) { 632 !sta || !priv_sta) {
662 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 633 IWL_DEBUG_RATE("leave: No STA priv data to update!\n");
663 sel->rate_idx = rate_lowest_index(sband, sta); 634 info->control.rates[0].idx = rate_lowest_index(sband, sta);
664 return; 635 return;
665 } 636 }
666 637
@@ -675,8 +646,8 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
675 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1); 646 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
676 647
677 if (sta_id == IWL_INVALID_STATION) { 648 if (sta_id == IWL_INVALID_STATION) {
678 IWL_DEBUG_RATE("LQ: ADD station %s\n", 649 IWL_DEBUG_RATE("LQ: ADD station %pm\n",
679 print_mac(mac, hdr->addr1)); 650 hdr->addr1);
680 sta_id = iwl3945_add_station(priv, 651 sta_id = iwl3945_add_station(priv,
681 hdr->addr1, 0, CMD_ASYNC); 652 hdr->addr1, 0, CMD_ASYNC);
682 } 653 }
@@ -793,9 +764,10 @@ static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
793 764
794 rs_sta->last_txrate_idx = index; 765 rs_sta->last_txrate_idx = index;
795 if (sband->band == IEEE80211_BAND_5GHZ) 766 if (sband->band == IEEE80211_BAND_5GHZ)
796 sel->rate_idx = rs_sta->last_txrate_idx - IWL_FIRST_OFDM_RATE; 767 info->control.rates[0].idx = rs_sta->last_txrate_idx -
768 IWL_FIRST_OFDM_RATE;
797 else 769 else
798 sel->rate_idx = rs_sta->last_txrate_idx; 770 info->control.rates[0].idx = rs_sta->last_txrate_idx;
799 771
800 IWL_DEBUG_RATE("leave: %d\n", index); 772 IWL_DEBUG_RATE("leave: %d\n", index);
801} 773}
@@ -806,7 +778,6 @@ static struct rate_control_ops rs_ops = {
806 .tx_status = rs_tx_status, 778 .tx_status = rs_tx_status,
807 .get_rate = rs_get_rate, 779 .get_rate = rs_get_rate,
808 .rate_init = rs_rate_init, 780 .rate_init = rs_rate_init,
809 .clear = rs_clear,
810 .alloc = rs_alloc, 781 .alloc = rs_alloc,
811 .free = rs_free, 782 .free = rs_free,
812 .alloc_sta = rs_alloc_sta, 783 .alloc_sta = rs_alloc_sta,
@@ -827,13 +798,12 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
827 rcu_read_lock(); 798 rcu_read_lock();
828 799
829 sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr); 800 sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr);
830 psta = (void *) sta->drv_priv; 801 if (!sta) {
831 if (!sta || !psta) {
832 IWL_DEBUG_RATE("leave - no private rate data!\n");
833 rcu_read_unlock(); 802 rcu_read_unlock();
834 return; 803 return;
835 } 804 }
836 805
806 psta = (void *) sta->drv_priv;
837 rs_sta = psta->rs_sta; 807 rs_sta = psta->rs_sta;
838 808
839 spin_lock_irqsave(&rs_sta->lock, flags); 809 spin_lock_irqsave(&rs_sta->lock, flags);
@@ -857,7 +827,6 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
857 break; 827 break;
858 } 828 }
859 829
860 rcu_read_unlock();
861 spin_unlock_irqrestore(&rs_sta->lock, flags); 830 spin_unlock_irqrestore(&rs_sta->lock, flags);
862 831
863 rssi = priv->last_rx_rssi; 832 rssi = priv->last_rx_rssi;
@@ -871,6 +840,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
871 IWL_DEBUG_RATE("leave: rssi %d assign rate index: " 840 IWL_DEBUG_RATE("leave: rssi %d assign rate index: "
872 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, 841 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate,
873 iwl3945_rates[rs_sta->start_rate].plcp); 842 iwl3945_rates[rs_sta->start_rate].plcp);
843 rcu_read_unlock();
874} 844}
875 845
876int iwl3945_rate_control_register(void) 846int iwl3945_rate_control_register(void)