diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945-rs.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 182 |
1 files changed, 40 insertions, 142 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index a279bf1dc9b0..6fc5e7361f26 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c | |||
@@ -36,8 +36,6 @@ | |||
36 | 36 | ||
37 | #include <linux/workqueue.h> | 37 | #include <linux/workqueue.h> |
38 | 38 | ||
39 | #include "../net/mac80211/rate.h" | ||
40 | |||
41 | #include "iwl-3945.h" | 39 | #include "iwl-3945.h" |
42 | 40 | ||
43 | #define RS_NAME "iwl-3945-rs" | 41 | #define RS_NAME "iwl-3945-rs" |
@@ -319,10 +317,10 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, | |||
319 | } | 317 | } |
320 | } | 318 | } |
321 | 319 | ||
322 | static void rs_rate_init(void *priv_rate, void *priv_sta, | 320 | static void rs_rate_init(void *priv, struct ieee80211_supported_band *sband, |
323 | struct ieee80211_local *local, struct sta_info *sta) | 321 | struct ieee80211_sta *sta, void *priv_sta) |
324 | { | 322 | { |
325 | struct iwl3945_rs_sta *rs_sta = (void *)sta->rate_ctrl_priv; | 323 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
326 | int i; | 324 | int i; |
327 | 325 | ||
328 | IWL_DEBUG_RATE("enter\n"); | 326 | IWL_DEBUG_RATE("enter\n"); |
@@ -333,22 +331,22 @@ static void rs_rate_init(void *priv_rate, void *priv_sta, | |||
333 | * after assoc.. */ | 331 | * after assoc.. */ |
334 | 332 | ||
335 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { | 333 | for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { |
336 | if (sta->sta.supp_rates[local->hw.conf.channel->band] & (1 << i)) { | 334 | if (sta->supp_rates[sband->band] & (1 << i)) { |
337 | rs_sta->last_txrate_idx = i; | 335 | rs_sta->last_txrate_idx = i; |
338 | break; | 336 | break; |
339 | } | 337 | } |
340 | } | 338 | } |
341 | 339 | ||
342 | /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ | 340 | /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ |
343 | if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) | 341 | if (sband->band == IEEE80211_BAND_5GHZ) |
344 | rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; | 342 | rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; |
345 | 343 | ||
346 | IWL_DEBUG_RATE("leave\n"); | 344 | IWL_DEBUG_RATE("leave\n"); |
347 | } | 345 | } |
348 | 346 | ||
349 | static void *rs_alloc(struct ieee80211_local *local) | 347 | static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) |
350 | { | 348 | { |
351 | return local->hw.priv; | 349 | return hw->priv; |
352 | } | 350 | } |
353 | 351 | ||
354 | /* rate scale requires free function to be implemented */ | 352 | /* rate scale requires free function to be implemented */ |
@@ -356,17 +354,24 @@ static void rs_free(void *priv) | |||
356 | { | 354 | { |
357 | return; | 355 | return; |
358 | } | 356 | } |
357 | |||
359 | static void rs_clear(void *priv) | 358 | static void rs_clear(void *priv) |
360 | { | 359 | { |
361 | return; | 360 | return; |
362 | } | 361 | } |
363 | 362 | ||
364 | 363 | ||
365 | static void *rs_alloc_sta(void *priv, gfp_t gfp) | 364 | static void *rs_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) |
366 | { | 365 | { |
367 | struct iwl3945_rs_sta *rs_sta; | 366 | struct iwl3945_rs_sta *rs_sta; |
367 | struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; | ||
368 | int i; | 368 | int i; |
369 | 369 | ||
370 | /* | ||
371 | * XXX: If it's using sta->drv_priv anyway, it might | ||
372 | * as well just put all the information there. | ||
373 | */ | ||
374 | |||
370 | IWL_DEBUG_RATE("enter\n"); | 375 | IWL_DEBUG_RATE("enter\n"); |
371 | 376 | ||
372 | rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp); | 377 | rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp); |
@@ -375,6 +380,8 @@ static void *rs_alloc_sta(void *priv, gfp_t gfp) | |||
375 | return NULL; | 380 | return NULL; |
376 | } | 381 | } |
377 | 382 | ||
383 | psta->rs_sta = rs_sta; | ||
384 | |||
378 | spin_lock_init(&rs_sta->lock); | 385 | spin_lock_init(&rs_sta->lock); |
379 | 386 | ||
380 | rs_sta->start_rate = IWL_RATE_INVALID; | 387 | rs_sta->start_rate = IWL_RATE_INVALID; |
@@ -400,10 +407,14 @@ static void *rs_alloc_sta(void *priv, gfp_t gfp) | |||
400 | return rs_sta; | 407 | return rs_sta; |
401 | } | 408 | } |
402 | 409 | ||
403 | static void rs_free_sta(void *priv, void *priv_sta) | 410 | static void rs_free_sta(void *priv, struct ieee80211_sta *sta, |
411 | void *priv_sta) | ||
404 | { | 412 | { |
413 | struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; | ||
405 | struct iwl3945_rs_sta *rs_sta = priv_sta; | 414 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
406 | 415 | ||
416 | psta->rs_sta = NULL; | ||
417 | |||
407 | IWL_DEBUG_RATE("enter\n"); | 418 | IWL_DEBUG_RATE("enter\n"); |
408 | del_timer_sync(&rs_sta->rate_scale_flush); | 419 | del_timer_sync(&rs_sta->rate_scale_flush); |
409 | kfree(rs_sta); | 420 | kfree(rs_sta); |
@@ -445,26 +456,19 @@ static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate) | |||
445 | * NOTE: Uses iwl3945_priv->retry_rate for the # of retries attempted by | 456 | * NOTE: Uses iwl3945_priv->retry_rate for the # of retries attempted by |
446 | * the hardware for each rate. | 457 | * the hardware for each rate. |
447 | */ | 458 | */ |
448 | static void rs_tx_status(void *priv_rate, | 459 | static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, |
449 | struct net_device *dev, | 460 | struct ieee80211_sta *sta, void *priv_sta, |
450 | struct sk_buff *skb) | 461 | struct sk_buff *skb) |
451 | { | 462 | { |
452 | u8 retries, current_count; | 463 | u8 retries, current_count; |
453 | int scale_rate_index, first_index, last_index; | 464 | int scale_rate_index, first_index, last_index; |
454 | unsigned long flags; | 465 | unsigned long flags; |
455 | struct sta_info *sta; | ||
456 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
457 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; | 466 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; |
458 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 467 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
459 | struct iwl3945_rs_sta *rs_sta; | ||
460 | struct ieee80211_supported_band *sband; | ||
461 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 468 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
462 | 469 | ||
463 | IWL_DEBUG_RATE("enter\n"); | 470 | IWL_DEBUG_RATE("enter\n"); |
464 | 471 | ||
465 | sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; | ||
466 | |||
467 | |||
468 | retries = info->status.retry_count; | 472 | retries = info->status.retry_count; |
469 | first_index = sband->bitrates[info->tx_rate_idx].hw_value; | 473 | first_index = sband->bitrates[info->tx_rate_idx].hw_value; |
470 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { | 474 | if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { |
@@ -472,17 +476,11 @@ static void rs_tx_status(void *priv_rate, | |||
472 | return; | 476 | return; |
473 | } | 477 | } |
474 | 478 | ||
475 | rcu_read_lock(); | 479 | if (!priv_sta) { |
476 | |||
477 | sta = sta_info_get(local, hdr->addr1); | ||
478 | if (!sta || !sta->rate_ctrl_priv) { | ||
479 | rcu_read_unlock(); | ||
480 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 480 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
481 | return; | 481 | return; |
482 | } | 482 | } |
483 | 483 | ||
484 | rs_sta = (void *)sta->rate_ctrl_priv; | ||
485 | |||
486 | rs_sta->tx_packets++; | 484 | rs_sta->tx_packets++; |
487 | 485 | ||
488 | scale_rate_index = first_index; | 486 | scale_rate_index = first_index; |
@@ -549,8 +547,6 @@ static void rs_tx_status(void *priv_rate, | |||
549 | 547 | ||
550 | spin_unlock_irqrestore(&rs_sta->lock, flags); | 548 | spin_unlock_irqrestore(&rs_sta->lock, flags); |
551 | 549 | ||
552 | rcu_read_unlock(); | ||
553 | |||
554 | IWL_DEBUG_RATE("leave\n"); | 550 | IWL_DEBUG_RATE("leave\n"); |
555 | 551 | ||
556 | return; | 552 | return; |
@@ -634,16 +630,15 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, | |||
634 | * rate table and must reference the driver allocated rate table | 630 | * rate table and must reference the driver allocated rate table |
635 | * | 631 | * |
636 | */ | 632 | */ |
637 | static void rs_get_rate(void *priv_rate, struct net_device *dev, | 633 | static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband, |
638 | struct ieee80211_supported_band *sband, | 634 | struct ieee80211_sta *sta, void *priv_sta, |
639 | struct sk_buff *skb, | 635 | struct sk_buff *skb, struct rate_selection *sel) |
640 | struct rate_selection *sel) | ||
641 | { | 636 | { |
642 | u8 low = IWL_RATE_INVALID; | 637 | u8 low = IWL_RATE_INVALID; |
643 | u8 high = IWL_RATE_INVALID; | 638 | u8 high = IWL_RATE_INVALID; |
644 | u16 high_low; | 639 | u16 high_low; |
645 | int index; | 640 | int index; |
646 | struct iwl3945_rs_sta *rs_sta; | 641 | struct iwl3945_rs_sta *rs_sta = priv_sta; |
647 | struct iwl3945_rate_scale_data *window = NULL; | 642 | struct iwl3945_rate_scale_data *window = NULL; |
648 | int current_tpt = IWL_INV_TPT; | 643 | int current_tpt = IWL_INV_TPT; |
649 | int low_tpt = IWL_INV_TPT; | 644 | int low_tpt = IWL_INV_TPT; |
@@ -651,34 +646,25 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
651 | u32 fail_count; | 646 | u32 fail_count; |
652 | s8 scale_action = 0; | 647 | s8 scale_action = 0; |
653 | unsigned long flags; | 648 | unsigned long flags; |
654 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
655 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 649 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
656 | struct sta_info *sta; | ||
657 | u16 fc, rate_mask; | 650 | u16 fc, rate_mask; |
658 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; | 651 | struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r; |
659 | DECLARE_MAC_BUF(mac); | 652 | DECLARE_MAC_BUF(mac); |
660 | 653 | ||
661 | IWL_DEBUG_RATE("enter\n"); | 654 | IWL_DEBUG_RATE("enter\n"); |
662 | 655 | ||
663 | rcu_read_lock(); | ||
664 | |||
665 | sta = sta_info_get(local, hdr->addr1); | ||
666 | |||
667 | /* Send management frames and broadcast/multicast data using lowest | 656 | /* Send management frames and broadcast/multicast data using lowest |
668 | * rate. */ | 657 | * rate. */ |
669 | fc = le16_to_cpu(hdr->frame_control); | 658 | fc = le16_to_cpu(hdr->frame_control); |
670 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || | 659 | if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || |
671 | is_multicast_ether_addr(hdr->addr1) || | 660 | is_multicast_ether_addr(hdr->addr1) || |
672 | !sta || !sta->rate_ctrl_priv) { | 661 | !sta || !priv_sta) { |
673 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); | 662 | IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); |
674 | sel->rate_idx = rate_lowest_index(local, sband, sta); | 663 | sel->rate_idx = rate_lowest_index(sband, sta); |
675 | rcu_read_unlock(); | ||
676 | return; | 664 | return; |
677 | } | 665 | } |
678 | 666 | ||
679 | rs_sta = (void *)sta->rate_ctrl_priv; | 667 | rate_mask = sta->supp_rates[sband->band]; |
680 | |||
681 | rate_mask = sta->sta.supp_rates[sband->band]; | ||
682 | index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); | 668 | index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); |
683 | 669 | ||
684 | if (sband->band == IEEE80211_BAND_5GHZ) | 670 | if (sband->band == IEEE80211_BAND_5GHZ) |
@@ -811,8 +797,6 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev, | |||
811 | else | 797 | else |
812 | sel->rate_idx = rs_sta->last_txrate_idx; | 798 | sel->rate_idx = rs_sta->last_txrate_idx; |
813 | 799 | ||
814 | rcu_read_unlock(); | ||
815 | |||
816 | IWL_DEBUG_RATE("leave: %d\n", index); | 800 | IWL_DEBUG_RATE("leave: %d\n", index); |
817 | } | 801 | } |
818 | 802 | ||
@@ -829,114 +813,28 @@ static struct rate_control_ops rs_ops = { | |||
829 | .free_sta = rs_free_sta, | 813 | .free_sta = rs_free_sta, |
830 | }; | 814 | }; |
831 | 815 | ||
832 | int iwl3945_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id) | ||
833 | { | ||
834 | struct ieee80211_local *local = hw_to_local(hw); | ||
835 | struct iwl3945_priv *priv = hw->priv; | ||
836 | struct iwl3945_rs_sta *rs_sta; | ||
837 | struct sta_info *sta; | ||
838 | unsigned long flags; | ||
839 | int count = 0, i; | ||
840 | u32 samples = 0, success = 0, good = 0; | ||
841 | unsigned long now = jiffies; | ||
842 | u32 max_time = 0; | ||
843 | |||
844 | rcu_read_lock(); | ||
845 | |||
846 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); | ||
847 | if (!sta || !sta->rate_ctrl_priv) { | ||
848 | if (sta) | ||
849 | IWL_DEBUG_RATE("leave - no private rate data!\n"); | ||
850 | else | ||
851 | IWL_DEBUG_RATE("leave - no station!\n"); | ||
852 | rcu_read_unlock(); | ||
853 | return sprintf(buf, "station %d not found\n", sta_id); | ||
854 | } | ||
855 | |||
856 | rs_sta = (void *)sta->rate_ctrl_priv; | ||
857 | spin_lock_irqsave(&rs_sta->lock, flags); | ||
858 | i = IWL_RATE_54M_INDEX; | ||
859 | while (1) { | ||
860 | u64 mask; | ||
861 | int j; | ||
862 | |||
863 | count += | ||
864 | sprintf(&buf[count], " %2dMbs: ", iwl3945_rates[i].ieee / 2); | ||
865 | |||
866 | mask = (1ULL << (IWL_RATE_MAX_WINDOW - 1)); | ||
867 | for (j = 0; j < IWL_RATE_MAX_WINDOW; j++, mask >>= 1) | ||
868 | buf[count++] = | ||
869 | (rs_sta->win[i].data & mask) ? '1' : '0'; | ||
870 | |||
871 | samples += rs_sta->win[i].counter; | ||
872 | good += rs_sta->win[i].success_counter; | ||
873 | success += rs_sta->win[i].success_counter * | ||
874 | iwl3945_rates[i].ieee; | ||
875 | |||
876 | if (rs_sta->win[i].stamp) { | ||
877 | int delta = | ||
878 | jiffies_to_msecs(now - rs_sta->win[i].stamp); | ||
879 | |||
880 | if (delta > max_time) | ||
881 | max_time = delta; | ||
882 | |||
883 | count += sprintf(&buf[count], "%5dms\n", delta); | ||
884 | } else | ||
885 | buf[count++] = '\n'; | ||
886 | |||
887 | j = iwl3945_get_prev_ieee_rate(i); | ||
888 | if (j == i) | ||
889 | break; | ||
890 | i = j; | ||
891 | } | ||
892 | spin_unlock_irqrestore(&rs_sta->lock, flags); | ||
893 | rcu_read_unlock(); | ||
894 | |||
895 | /* Display the average rate of all samples taken. | ||
896 | * | ||
897 | * NOTE: We multiple # of samples by 2 since the IEEE measurement | ||
898 | * added from iwl3945_rates is actually 2X the rate */ | ||
899 | if (samples) | ||
900 | count += sprintf( | ||
901 | &buf[count], | ||
902 | "\nAverage rate is %3d.%02dMbs over last %4dms\n" | ||
903 | "%3d%% success (%d good packets over %d tries)\n", | ||
904 | success / (2 * samples), (success * 5 / samples) % 10, | ||
905 | max_time, good * 100 / samples, good, samples); | ||
906 | else | ||
907 | count += sprintf(&buf[count], "\nAverage rate: 0Mbs\n"); | ||
908 | |||
909 | return count; | ||
910 | } | ||
911 | |||
912 | void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) | 816 | void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) |
913 | { | 817 | { |
914 | struct iwl3945_priv *priv = hw->priv; | 818 | struct iwl3945_priv *priv = hw->priv; |
915 | s32 rssi = 0; | 819 | s32 rssi = 0; |
916 | unsigned long flags; | 820 | unsigned long flags; |
917 | struct ieee80211_local *local = hw_to_local(hw); | ||
918 | struct iwl3945_rs_sta *rs_sta; | 821 | struct iwl3945_rs_sta *rs_sta; |
919 | struct sta_info *sta; | 822 | struct ieee80211_sta *sta; |
823 | struct iwl3945_sta_priv *psta; | ||
920 | 824 | ||
921 | IWL_DEBUG_RATE("enter\n"); | 825 | IWL_DEBUG_RATE("enter\n"); |
922 | 826 | ||
923 | if (!local->rate_ctrl->ops->name || | ||
924 | strcmp(local->rate_ctrl->ops->name, RS_NAME)) { | ||
925 | IWL_WARNING("iwl-3945-rs not selected as rate control algo!\n"); | ||
926 | IWL_DEBUG_RATE("leave - mac80211 picked the wrong RC algo.\n"); | ||
927 | return; | ||
928 | } | ||
929 | |||
930 | rcu_read_lock(); | 827 | rcu_read_lock(); |
931 | 828 | ||
932 | sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); | 829 | sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr); |
933 | if (!sta || !sta->rate_ctrl_priv) { | 830 | psta = (void *) sta->drv_priv; |
831 | if (!sta || !psta) { | ||
934 | IWL_DEBUG_RATE("leave - no private rate data!\n"); | 832 | IWL_DEBUG_RATE("leave - no private rate data!\n"); |
935 | rcu_read_unlock(); | 833 | rcu_read_unlock(); |
936 | return; | 834 | return; |
937 | } | 835 | } |
938 | 836 | ||
939 | rs_sta = (void *)sta->rate_ctrl_priv; | 837 | rs_sta = psta->rs_sta; |
940 | 838 | ||
941 | spin_lock_irqsave(&rs_sta->lock, flags); | 839 | spin_lock_irqsave(&rs_sta->lock, flags); |
942 | 840 | ||