diff options
author | Sujith <Sujith.Manoharan@atheros.com> | 2008-11-17 22:33:12 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-26 09:47:22 -0500 |
commit | 256b77593f3ec07f58cd1f0d573ffe9ccd941b5b (patch) | |
tree | 024d9dfaa62878bbf54d71012405f72ad44709b7 /drivers | |
parent | 3fcdfb4b940a226184bc01bfc5c58b32b509b965 (diff) |
ath9k: Merge struct ath_tx_ratectrl with ath_rate_node
Avoid casting of ath_tx_ratctrl and access the elements directly.
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/ath9k/rc.c | 346 | ||||
-rw-r--r-- | drivers/net/wireless/ath9k/rc.h | 71 |
2 files changed, 192 insertions, 225 deletions
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c index 517992d1480..21116c51758 100644 --- a/drivers/net/wireless/ath9k/rc.c +++ b/drivers/net/wireless/ath9k/rc.c | |||
@@ -542,19 +542,19 @@ static inline int8_t median(int8_t a, int8_t b, int8_t c) | |||
542 | } | 542 | } |
543 | 543 | ||
544 | static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table, | 544 | static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table, |
545 | struct ath_tx_ratectrl *rate_ctrl) | 545 | struct ath_rate_node *ath_rc_priv) |
546 | { | 546 | { |
547 | u8 i, j, idx, idx_next; | 547 | u8 i, j, idx, idx_next; |
548 | 548 | ||
549 | for (i = rate_ctrl->max_valid_rate - 1; i > 0; i--) { | 549 | for (i = ath_rc_priv->max_valid_rate - 1; i > 0; i--) { |
550 | for (j = 0; j <= i-1; j++) { | 550 | for (j = 0; j <= i-1; j++) { |
551 | idx = rate_ctrl->valid_rate_index[j]; | 551 | idx = ath_rc_priv->valid_rate_index[j]; |
552 | idx_next = rate_ctrl->valid_rate_index[j+1]; | 552 | idx_next = ath_rc_priv->valid_rate_index[j+1]; |
553 | 553 | ||
554 | if (rate_table->info[idx].ratekbps > | 554 | if (rate_table->info[idx].ratekbps > |
555 | rate_table->info[idx_next].ratekbps) { | 555 | rate_table->info[idx_next].ratekbps) { |
556 | rate_ctrl->valid_rate_index[j] = idx_next; | 556 | ath_rc_priv->valid_rate_index[j] = idx_next; |
557 | rate_ctrl->valid_rate_index[j+1] = idx; | 557 | ath_rc_priv->valid_rate_index[j+1] = idx; |
558 | } | 558 | } |
559 | } | 559 | } |
560 | } | 560 | } |
@@ -562,40 +562,40 @@ static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table, | |||
562 | 562 | ||
563 | /* Access functions for valid_txrate_mask */ | 563 | /* Access functions for valid_txrate_mask */ |
564 | 564 | ||
565 | static void ath_rc_init_valid_txmask(struct ath_tx_ratectrl *rate_ctrl) | 565 | static void ath_rc_init_valid_txmask(struct ath_rate_node *ath_rc_priv) |
566 | { | 566 | { |
567 | u8 i; | 567 | u8 i; |
568 | 568 | ||
569 | for (i = 0; i < rate_ctrl->rate_table_size; i++) | 569 | for (i = 0; i < ath_rc_priv->rate_table_size; i++) |
570 | rate_ctrl->valid_rate_index[i] = FALSE; | 570 | ath_rc_priv->valid_rate_index[i] = FALSE; |
571 | } | 571 | } |
572 | 572 | ||
573 | static inline void ath_rc_set_valid_txmask(struct ath_tx_ratectrl *rate_ctrl, | 573 | static inline void ath_rc_set_valid_txmask(struct ath_rate_node *ath_rc_priv, |
574 | u8 index, int valid_tx_rate) | 574 | u8 index, int valid_tx_rate) |
575 | { | 575 | { |
576 | ASSERT(index <= rate_ctrl->rate_table_size); | 576 | ASSERT(index <= ath_rc_priv->rate_table_size); |
577 | rate_ctrl->valid_rate_index[index] = valid_tx_rate ? TRUE : FALSE; | 577 | ath_rc_priv->valid_rate_index[index] = valid_tx_rate ? TRUE : FALSE; |
578 | } | 578 | } |
579 | 579 | ||
580 | static inline int ath_rc_isvalid_txmask(struct ath_tx_ratectrl *rate_ctrl, | 580 | static inline int ath_rc_isvalid_txmask(struct ath_rate_node *ath_rc_priv, |
581 | u8 index) | 581 | u8 index) |
582 | { | 582 | { |
583 | ASSERT(index <= rate_ctrl->rate_table_size); | 583 | ASSERT(index <= ath_rc_priv->rate_table_size); |
584 | return rate_ctrl->valid_rate_index[index]; | 584 | return ath_rc_priv->valid_rate_index[index]; |
585 | } | 585 | } |
586 | 586 | ||
587 | /* Iterators for valid_txrate_mask */ | 587 | /* Iterators for valid_txrate_mask */ |
588 | static inline int | 588 | static inline int |
589 | ath_rc_get_nextvalid_txrate(const struct ath_rate_table *rate_table, | 589 | ath_rc_get_nextvalid_txrate(const struct ath_rate_table *rate_table, |
590 | struct ath_tx_ratectrl *rate_ctrl, | 590 | struct ath_rate_node *ath_rc_priv, |
591 | u8 cur_valid_txrate, | 591 | u8 cur_valid_txrate, |
592 | u8 *next_idx) | 592 | u8 *next_idx) |
593 | { | 593 | { |
594 | u8 i; | 594 | u8 i; |
595 | 595 | ||
596 | for (i = 0; i < rate_ctrl->max_valid_rate - 1; i++) { | 596 | for (i = 0; i < ath_rc_priv->max_valid_rate - 1; i++) { |
597 | if (rate_ctrl->valid_rate_index[i] == cur_valid_txrate) { | 597 | if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) { |
598 | *next_idx = rate_ctrl->valid_rate_index[i+1]; | 598 | *next_idx = ath_rc_priv->valid_rate_index[i+1]; |
599 | return TRUE; | 599 | return TRUE; |
600 | } | 600 | } |
601 | } | 601 | } |
@@ -625,14 +625,14 @@ static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw) | |||
625 | 625 | ||
626 | static inline int | 626 | static inline int |
627 | ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table, | 627 | ath_rc_get_nextlowervalid_txrate(const struct ath_rate_table *rate_table, |
628 | struct ath_tx_ratectrl *rate_ctrl, | 628 | struct ath_rate_node *ath_rc_priv, |
629 | u8 cur_valid_txrate, u8 *next_idx) | 629 | u8 cur_valid_txrate, u8 *next_idx) |
630 | { | 630 | { |
631 | int8_t i; | 631 | int8_t i; |
632 | 632 | ||
633 | for (i = 1; i < rate_ctrl->max_valid_rate ; i++) { | 633 | for (i = 1; i < ath_rc_priv->max_valid_rate ; i++) { |
634 | if (rate_ctrl->valid_rate_index[i] == cur_valid_txrate) { | 634 | if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) { |
635 | *next_idx = rate_ctrl->valid_rate_index[i-1]; | 635 | *next_idx = ath_rc_priv->valid_rate_index[i-1]; |
636 | return TRUE; | 636 | return TRUE; |
637 | } | 637 | } |
638 | } | 638 | } |
@@ -647,11 +647,9 @@ ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv, | |||
647 | const struct ath_rate_table *rate_table, | 647 | const struct ath_rate_table *rate_table, |
648 | u32 capflag) | 648 | u32 capflag) |
649 | { | 649 | { |
650 | struct ath_tx_ratectrl *rate_ctrl; | ||
651 | u8 i, hi = 0; | 650 | u8 i, hi = 0; |
652 | u32 valid; | 651 | u32 valid; |
653 | 652 | ||
654 | rate_ctrl = (struct ath_tx_ratectrl *)(ath_rc_priv); | ||
655 | for (i = 0; i < rate_table->rate_cnt; i++) { | 653 | for (i = 0; i < rate_table->rate_cnt; i++) { |
656 | valid = (ath_rc_priv->single_stream ? | 654 | valid = (ath_rc_priv->single_stream ? |
657 | rate_table->info[i].valid_single_stream : | 655 | rate_table->info[i].valid_single_stream : |
@@ -663,11 +661,11 @@ ath_rc_sib_init_validrates(struct ath_rate_node *ath_rc_priv, | |||
663 | if (!ath_rc_valid_phyrate(phy, capflag, FALSE)) | 661 | if (!ath_rc_valid_phyrate(phy, capflag, FALSE)) |
664 | continue; | 662 | continue; |
665 | 663 | ||
666 | valid_rate_count = rate_ctrl->valid_phy_ratecnt[phy]; | 664 | valid_rate_count = ath_rc_priv->valid_phy_ratecnt[phy]; |
667 | 665 | ||
668 | rate_ctrl->valid_phy_rateidx[phy][valid_rate_count] = i; | 666 | ath_rc_priv->valid_phy_rateidx[phy][valid_rate_count] = i; |
669 | rate_ctrl->valid_phy_ratecnt[phy] += 1; | 667 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
670 | ath_rc_set_valid_txmask(rate_ctrl, i, TRUE); | 668 | ath_rc_set_valid_txmask(ath_rc_priv, i, TRUE); |
671 | hi = A_MAX(hi, i); | 669 | hi = A_MAX(hi, i); |
672 | } | 670 | } |
673 | } | 671 | } |
@@ -685,8 +683,6 @@ ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv, | |||
685 | { | 683 | { |
686 | /* XXX: Clean me up and make identation friendly */ | 684 | /* XXX: Clean me up and make identation friendly */ |
687 | u8 i, j, hi = 0; | 685 | u8 i, j, hi = 0; |
688 | struct ath_tx_ratectrl *rate_ctrl = | ||
689 | (struct ath_tx_ratectrl *)(ath_rc_priv); | ||
690 | 686 | ||
691 | /* Use intersection of working rates and valid rates */ | 687 | /* Use intersection of working rates and valid rates */ |
692 | for (i = 0; i < rateset->rs_nrates; i++) { | 688 | for (i = 0; i < rateset->rs_nrates; i++) { |
@@ -714,12 +710,12 @@ ath_rc_sib_setvalid_rates(struct ath_rate_node *ath_rc_priv, | |||
714 | continue; | 710 | continue; |
715 | 711 | ||
716 | valid_rate_count = | 712 | valid_rate_count = |
717 | rate_ctrl->valid_phy_ratecnt[phy]; | 713 | ath_rc_priv->valid_phy_ratecnt[phy]; |
718 | 714 | ||
719 | rate_ctrl->valid_phy_rateidx[phy] | 715 | ath_rc_priv->valid_phy_rateidx[phy] |
720 | [valid_rate_count] = j; | 716 | [valid_rate_count] = j; |
721 | rate_ctrl->valid_phy_ratecnt[phy] += 1; | 717 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
722 | ath_rc_set_valid_txmask(rate_ctrl, j, TRUE); | 718 | ath_rc_set_valid_txmask(ath_rc_priv, j, TRUE); |
723 | hi = A_MAX(hi, j); | 719 | hi = A_MAX(hi, j); |
724 | } | 720 | } |
725 | } | 721 | } |
@@ -733,8 +729,6 @@ ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv, | |||
733 | u8 *mcs_set, u32 capflag) | 729 | u8 *mcs_set, u32 capflag) |
734 | { | 730 | { |
735 | u8 i, j, hi = 0; | 731 | u8 i, j, hi = 0; |
736 | struct ath_tx_ratectrl *rate_ctrl = | ||
737 | (struct ath_tx_ratectrl *)(ath_rc_priv); | ||
738 | 732 | ||
739 | /* Use intersection of working rates and valid rates */ | 733 | /* Use intersection of working rates and valid rates */ |
740 | for (i = 0; i < ((struct ath_rateset *)mcs_set)->rs_nrates; i++) { | 734 | for (i = 0; i < ((struct ath_rateset *)mcs_set)->rs_nrates; i++) { |
@@ -754,10 +748,10 @@ ath_rc_sib_setvalid_htrates(struct ath_rate_node *ath_rc_priv, | |||
754 | if (!ath_rc_valid_phyrate(phy, capflag, FALSE)) | 748 | if (!ath_rc_valid_phyrate(phy, capflag, FALSE)) |
755 | continue; | 749 | continue; |
756 | 750 | ||
757 | rate_ctrl->valid_phy_rateidx[phy] | 751 | ath_rc_priv->valid_phy_rateidx[phy] |
758 | [rate_ctrl->valid_phy_ratecnt[phy]] = j; | 752 | [ath_rc_priv->valid_phy_ratecnt[phy]] = j; |
759 | rate_ctrl->valid_phy_ratecnt[phy] += 1; | 753 | ath_rc_priv->valid_phy_ratecnt[phy] += 1; |
760 | ath_rc_set_valid_txmask(rate_ctrl, j, TRUE); | 754 | ath_rc_set_valid_txmask(ath_rc_priv, j, TRUE); |
761 | hi = A_MAX(hi, j); | 755 | hi = A_MAX(hi, j); |
762 | } | 756 | } |
763 | } | 757 | } |
@@ -875,16 +869,12 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, | |||
875 | u32 dt, best_thruput, this_thruput, now_msec; | 869 | u32 dt, best_thruput, this_thruput, now_msec; |
876 | u8 rate, next_rate, best_rate, maxindex, minindex; | 870 | u8 rate, next_rate, best_rate, maxindex, minindex; |
877 | int8_t rssi_last, rssi_reduce = 0, index = 0; | 871 | int8_t rssi_last, rssi_reduce = 0, index = 0; |
878 | struct ath_tx_ratectrl *rate_ctrl = NULL; | ||
879 | |||
880 | rate_ctrl = (struct ath_tx_ratectrl *)(ath_rc_priv ? | ||
881 | (ath_rc_priv) : NULL); | ||
882 | 872 | ||
883 | *is_probing = FALSE; | 873 | *is_probing = FALSE; |
884 | 874 | ||
885 | rssi_last = median(rate_ctrl->rssi_last, | 875 | rssi_last = median(ath_rc_priv->rssi_last, |
886 | rate_ctrl->rssi_last_prev, | 876 | ath_rc_priv->rssi_last_prev, |
887 | rate_ctrl->rssi_last_prev2); | 877 | ath_rc_priv->rssi_last_prev2); |
888 | 878 | ||
889 | /* | 879 | /* |
890 | * Age (reduce) last ack rssi based on how old it is. | 880 | * Age (reduce) last ack rssi based on how old it is. |
@@ -896,7 +886,7 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, | |||
896 | */ | 886 | */ |
897 | 887 | ||
898 | now_msec = jiffies_to_msecs(jiffies); | 888 | now_msec = jiffies_to_msecs(jiffies); |
899 | dt = now_msec - rate_ctrl->rssi_time; | 889 | dt = now_msec - ath_rc_priv->rssi_time; |
900 | 890 | ||
901 | if (dt >= 185) | 891 | if (dt >= 185) |
902 | rssi_reduce = 10; | 892 | rssi_reduce = 10; |
@@ -915,7 +905,7 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, | |||
915 | */ | 905 | */ |
916 | 906 | ||
917 | best_thruput = 0; | 907 | best_thruput = 0; |
918 | maxindex = rate_ctrl->max_valid_rate-1; | 908 | maxindex = ath_rc_priv->max_valid_rate-1; |
919 | 909 | ||
920 | minindex = 0; | 910 | minindex = 0; |
921 | best_rate = minindex; | 911 | best_rate = minindex; |
@@ -927,8 +917,8 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, | |||
927 | for (index = maxindex; index >= minindex ; index--) { | 917 | for (index = maxindex; index >= minindex ; index--) { |
928 | u8 per_thres; | 918 | u8 per_thres; |
929 | 919 | ||
930 | rate = rate_ctrl->valid_rate_index[index]; | 920 | rate = ath_rc_priv->valid_rate_index[index]; |
931 | if (rate > rate_ctrl->rate_max_phy) | 921 | if (rate > ath_rc_priv->rate_max_phy) |
932 | continue; | 922 | continue; |
933 | 923 | ||
934 | /* | 924 | /* |
@@ -942,7 +932,7 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, | |||
942 | * 10-15 and we would be worse off then staying | 932 | * 10-15 and we would be worse off then staying |
943 | * at the current rate. | 933 | * at the current rate. |
944 | */ | 934 | */ |
945 | per_thres = rate_ctrl->state[rate].per; | 935 | per_thres = ath_rc_priv->state[rate].per; |
946 | if (per_thres < 12) | 936 | if (per_thres < 12) |
947 | per_thres = 12; | 937 | per_thres = 12; |
948 | 938 | ||
@@ -961,29 +951,29 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, | |||
961 | * of max retries, use the min rate for the next retry | 951 | * of max retries, use the min rate for the next retry |
962 | */ | 952 | */ |
963 | if (is_retry) | 953 | if (is_retry) |
964 | rate = rate_ctrl->valid_rate_index[minindex]; | 954 | rate = ath_rc_priv->valid_rate_index[minindex]; |
965 | 955 | ||
966 | rate_ctrl->rssi_last_lookup = rssi_last; | 956 | ath_rc_priv->rssi_last_lookup = rssi_last; |
967 | 957 | ||
968 | /* | 958 | /* |
969 | * Must check the actual rate (ratekbps) to account for | 959 | * Must check the actual rate (ratekbps) to account for |
970 | * non-monoticity of 11g's rate table | 960 | * non-monoticity of 11g's rate table |
971 | */ | 961 | */ |
972 | 962 | ||
973 | if (rate >= rate_ctrl->rate_max_phy && probe_allowed) { | 963 | if (rate >= ath_rc_priv->rate_max_phy && probe_allowed) { |
974 | rate = rate_ctrl->rate_max_phy; | 964 | rate = ath_rc_priv->rate_max_phy; |
975 | 965 | ||
976 | /* Probe the next allowed phy state */ | 966 | /* Probe the next allowed phy state */ |
977 | /* FIXME:XXXX Check to make sure ratMax is checked properly */ | 967 | /* FIXME:XXXX Check to make sure ratMax is checked properly */ |
978 | if (ath_rc_get_nextvalid_txrate(rate_table, | 968 | if (ath_rc_get_nextvalid_txrate(rate_table, |
979 | rate_ctrl, rate, &next_rate) && | 969 | ath_rc_priv, rate, &next_rate) && |
980 | (now_msec - rate_ctrl->probe_time > | 970 | (now_msec - ath_rc_priv->probe_time > |
981 | rate_table->probe_interval) && | 971 | rate_table->probe_interval) && |
982 | (rate_ctrl->hw_maxretry_pktcnt >= 1)) { | 972 | (ath_rc_priv->hw_maxretry_pktcnt >= 1)) { |
983 | rate = next_rate; | 973 | rate = next_rate; |
984 | rate_ctrl->probe_rate = rate; | 974 | ath_rc_priv->probe_rate = rate; |
985 | rate_ctrl->probe_time = now_msec; | 975 | ath_rc_priv->probe_time = now_msec; |
986 | rate_ctrl->hw_maxretry_pktcnt = 0; | 976 | ath_rc_priv->hw_maxretry_pktcnt = 0; |
987 | *is_probing = TRUE; | 977 | *is_probing = TRUE; |
988 | } | 978 | } |
989 | } | 979 | } |
@@ -994,8 +984,8 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc, | |||
994 | * normally 1 rather than 0 because of the rate 9 vs 6 issue | 984 | * normally 1 rather than 0 because of the rate 9 vs 6 issue |
995 | * in the old code. | 985 | * in the old code. |
996 | */ | 986 | */ |
997 | if (rate > (rate_ctrl->rate_table_size - 1)) | 987 | if (rate > (ath_rc_priv->rate_table_size - 1)) |
998 | rate = rate_ctrl->rate_table_size - 1; | 988 | rate = ath_rc_priv->rate_table_size - 1; |
999 | 989 | ||
1000 | ASSERT((rate_table->info[rate].valid && !ath_rc_priv->single_stream) || | 990 | ASSERT((rate_table->info[rate].valid && !ath_rc_priv->single_stream) || |
1001 | (rate_table->info[rate].valid_single_stream && | 991 | (rate_table->info[rate].valid_single_stream && |
@@ -1031,13 +1021,11 @@ static u8 ath_rc_rate_getidx(struct ath_softc *sc, | |||
1031 | { | 1021 | { |
1032 | u32 j; | 1022 | u32 j; |
1033 | u8 nextindex; | 1023 | u8 nextindex; |
1034 | struct ath_tx_ratectrl *rate_ctrl = | ||
1035 | (struct ath_tx_ratectrl *)(ath_rc_priv); | ||
1036 | 1024 | ||
1037 | if (min_rate) { | 1025 | if (min_rate) { |
1038 | for (j = RATE_TABLE_SIZE; j > 0; j--) { | 1026 | for (j = RATE_TABLE_SIZE; j > 0; j--) { |
1039 | if (ath_rc_get_nextlowervalid_txrate(rate_table, | 1027 | if (ath_rc_get_nextlowervalid_txrate(rate_table, |
1040 | rate_ctrl, rix, &nextindex)) | 1028 | ath_rc_priv, rix, &nextindex)) |
1041 | rix = nextindex; | 1029 | rix = nextindex; |
1042 | else | 1030 | else |
1043 | break; | 1031 | break; |
@@ -1045,7 +1033,7 @@ static u8 ath_rc_rate_getidx(struct ath_softc *sc, | |||
1045 | } else { | 1033 | } else { |
1046 | for (j = stepdown; j > 0; j--) { | 1034 | for (j = stepdown; j > 0; j--) { |
1047 | if (ath_rc_get_nextlowervalid_txrate(rate_table, | 1035 | if (ath_rc_get_nextlowervalid_txrate(rate_table, |
1048 | rate_ctrl, rix, &nextindex)) | 1036 | ath_rc_priv, rix, &nextindex)) |
1049 | rix = nextindex; | 1037 | rix = nextindex; |
1050 | else | 1038 | else |
1051 | break; | 1039 | break; |
@@ -1225,7 +1213,6 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1225 | struct ath_tx_info_priv *info_priv, | 1213 | struct ath_tx_info_priv *info_priv, |
1226 | int tx_rate, int xretries, int retries) | 1214 | int tx_rate, int xretries, int retries) |
1227 | { | 1215 | { |
1228 | struct ath_tx_ratectrl *rate_ctrl; | ||
1229 | u32 now_msec = jiffies_to_msecs(jiffies); | 1216 | u32 now_msec = jiffies_to_msecs(jiffies); |
1230 | int state_change = FALSE, rate, count; | 1217 | int state_change = FALSE, rate, count; |
1231 | u8 last_per; | 1218 | u8 last_per; |
@@ -1249,8 +1236,6 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1249 | if (!ath_rc_priv) | 1236 | if (!ath_rc_priv) |
1250 | return; | 1237 | return; |
1251 | 1238 | ||
1252 | rate_ctrl = (struct ath_tx_ratectrl *)(ath_rc_priv); | ||
1253 | |||
1254 | ASSERT(tx_rate >= 0); | 1239 | ASSERT(tx_rate >= 0); |
1255 | if (tx_rate < 0) | 1240 | if (tx_rate < 0) |
1256 | return; | 1241 | return; |
@@ -1262,30 +1247,30 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1262 | info_priv->tx.ts_rssi < 3 ? 0 : | 1247 | info_priv->tx.ts_rssi < 3 ? 0 : |
1263 | info_priv->tx.ts_rssi - 3; | 1248 | info_priv->tx.ts_rssi - 3; |
1264 | 1249 | ||
1265 | last_per = rate_ctrl->state[tx_rate].per; | 1250 | last_per = ath_rc_priv->state[tx_rate].per; |
1266 | 1251 | ||
1267 | if (xretries) { | 1252 | if (xretries) { |
1268 | /* Update the PER. */ | 1253 | /* Update the PER. */ |
1269 | if (xretries == 1) { | 1254 | if (xretries == 1) { |
1270 | rate_ctrl->state[tx_rate].per += 30; | 1255 | ath_rc_priv->state[tx_rate].per += 30; |
1271 | if (rate_ctrl->state[tx_rate].per > 100) | 1256 | if (ath_rc_priv->state[tx_rate].per > 100) |
1272 | rate_ctrl->state[tx_rate].per = 100; | 1257 | ath_rc_priv->state[tx_rate].per = 100; |
1273 | } else { | 1258 | } else { |
1274 | /* xretries == 2 */ | 1259 | /* xretries == 2 */ |
1275 | count = ARRAY_SIZE(nretry_to_per_lookup); | 1260 | count = ARRAY_SIZE(nretry_to_per_lookup); |
1276 | if (retries >= count) | 1261 | if (retries >= count) |
1277 | retries = count - 1; | 1262 | retries = count - 1; |
1278 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) */ | 1263 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) */ |
1279 | rate_ctrl->state[tx_rate].per = | 1264 | ath_rc_priv->state[tx_rate].per = |
1280 | (u8)(rate_ctrl->state[tx_rate].per - | 1265 | (u8)(ath_rc_priv->state[tx_rate].per - |
1281 | (rate_ctrl->state[tx_rate].per >> 3) + | 1266 | (ath_rc_priv->state[tx_rate].per >> 3) + |
1282 | ((100) >> 3)); | 1267 | ((100) >> 3)); |
1283 | } | 1268 | } |
1284 | 1269 | ||
1285 | /* xretries == 1 or 2 */ | 1270 | /* xretries == 1 or 2 */ |
1286 | 1271 | ||
1287 | if (rate_ctrl->probe_rate == tx_rate) | 1272 | if (ath_rc_priv->probe_rate == tx_rate) |
1288 | rate_ctrl->probe_rate = 0; | 1273 | ath_rc_priv->probe_rate = 0; |
1289 | 1274 | ||
1290 | } else { /* xretries == 0 */ | 1275 | } else { /* xretries == 0 */ |
1291 | /* Update the PER. */ | 1276 | /* Update the PER. */ |
@@ -1307,10 +1292,10 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1307 | * simplified version of the sum of these two terms. | 1292 | * simplified version of the sum of these two terms. |
1308 | */ | 1293 | */ |
1309 | if (info_priv->n_frames > 0) | 1294 | if (info_priv->n_frames > 0) |
1310 | rate_ctrl->state[tx_rate].per | 1295 | ath_rc_priv->state[tx_rate].per |
1311 | = (u8) | 1296 | = (u8) |
1312 | (rate_ctrl->state[tx_rate].per - | 1297 | (ath_rc_priv->state[tx_rate].per - |
1313 | (rate_ctrl->state[tx_rate].per >> 3) + | 1298 | (ath_rc_priv->state[tx_rate].per >> 3) + |
1314 | ((100*(retries*info_priv->n_frames + | 1299 | ((100*(retries*info_priv->n_frames + |
1315 | info_priv->n_bad_frames) / | 1300 | info_priv->n_bad_frames) / |
1316 | (info_priv->n_frames * | 1301 | (info_priv->n_frames * |
@@ -1318,23 +1303,23 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1318 | } else { | 1303 | } else { |
1319 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) */ | 1304 | /* new_PER = 7/8*old_PER + 1/8*(currentPER) */ |
1320 | 1305 | ||
1321 | rate_ctrl->state[tx_rate].per = (u8) | 1306 | ath_rc_priv->state[tx_rate].per = (u8) |
1322 | (rate_ctrl->state[tx_rate].per - | 1307 | (ath_rc_priv->state[tx_rate].per - |
1323 | (rate_ctrl->state[tx_rate].per >> 3) + | 1308 | (ath_rc_priv->state[tx_rate].per >> 3) + |
1324 | (nretry_to_per_lookup[retries] >> 3)); | 1309 | (nretry_to_per_lookup[retries] >> 3)); |
1325 | } | 1310 | } |
1326 | 1311 | ||
1327 | rate_ctrl->rssi_last_prev2 = rate_ctrl->rssi_last_prev; | 1312 | ath_rc_priv->rssi_last_prev2 = ath_rc_priv->rssi_last_prev; |
1328 | rate_ctrl->rssi_last_prev = rate_ctrl->rssi_last; | 1313 | ath_rc_priv->rssi_last_prev = ath_rc_priv->rssi_last; |
1329 | rate_ctrl->rssi_last = info_priv->tx.ts_rssi; | 1314 | ath_rc_priv->rssi_last = info_priv->tx.ts_rssi; |
1330 | rate_ctrl->rssi_time = now_msec; | 1315 | ath_rc_priv->rssi_time = now_msec; |
1331 | 1316 | ||
1332 | /* | 1317 | /* |
1333 | * If we got at most one retry then increase the max rate if | 1318 | * If we got at most one retry then increase the max rate if |
1334 | * this was a probe. Otherwise, ignore the probe. | 1319 | * this was a probe. Otherwise, ignore the probe. |
1335 | */ | 1320 | */ |
1336 | 1321 | ||
1337 | if (rate_ctrl->probe_rate && rate_ctrl->probe_rate == tx_rate) { | 1322 | if (ath_rc_priv->probe_rate && ath_rc_priv->probe_rate == tx_rate) { |
1338 | if (retries > 0 || 2 * info_priv->n_bad_frames > | 1323 | if (retries > 0 || 2 * info_priv->n_bad_frames > |
1339 | info_priv->n_frames) { | 1324 | info_priv->n_frames) { |
1340 | /* | 1325 | /* |
@@ -1344,17 +1329,17 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1344 | * the subframes were bad then also consider | 1329 | * the subframes were bad then also consider |
1345 | * the probe a failure. | 1330 | * the probe a failure. |
1346 | */ | 1331 | */ |
1347 | rate_ctrl->probe_rate = 0; | 1332 | ath_rc_priv->probe_rate = 0; |
1348 | } else { | 1333 | } else { |
1349 | u8 probe_rate = 0; | 1334 | u8 probe_rate = 0; |
1350 | 1335 | ||
1351 | rate_ctrl->rate_max_phy = rate_ctrl->probe_rate; | 1336 | ath_rc_priv->rate_max_phy = ath_rc_priv->probe_rate; |
1352 | probe_rate = rate_ctrl->probe_rate; | 1337 | probe_rate = ath_rc_priv->probe_rate; |
1353 | 1338 | ||
1354 | if (rate_ctrl->state[probe_rate].per > 30) | 1339 | if (ath_rc_priv->state[probe_rate].per > 30) |
1355 | rate_ctrl->state[probe_rate].per = 20; | 1340 | ath_rc_priv->state[probe_rate].per = 20; |
1356 | 1341 | ||
1357 | rate_ctrl->probe_rate = 0; | 1342 | ath_rc_priv->probe_rate = 0; |
1358 | 1343 | ||
1359 | /* | 1344 | /* |
1360 | * Since this probe succeeded, we allow the next | 1345 | * Since this probe succeeded, we allow the next |
@@ -1362,7 +1347,7 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1362 | * to move up faster if the probes are | 1347 | * to move up faster if the probes are |
1363 | * succesful. | 1348 | * succesful. |
1364 | */ | 1349 | */ |
1365 | rate_ctrl->probe_time = now_msec - | 1350 | ath_rc_priv->probe_time = now_msec - |
1366 | rate_table->probe_interval / 2; | 1351 | rate_table->probe_interval / 2; |
1367 | } | 1352 | } |
1368 | } | 1353 | } |
@@ -1373,51 +1358,51 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1373 | * this was because of collisions or poor signal. | 1358 | * this was because of collisions or poor signal. |
1374 | * | 1359 | * |
1375 | * Later: if rssi_ack is close to | 1360 | * Later: if rssi_ack is close to |
1376 | * rate_ctrl->state[txRate].rssi_thres and we see lots | 1361 | * ath_rc_priv->state[txRate].rssi_thres and we see lots |
1377 | * of retries, then we could increase | 1362 | * of retries, then we could increase |
1378 | * rate_ctrl->state[txRate].rssi_thres. | 1363 | * ath_rc_priv->state[txRate].rssi_thres. |
1379 | */ | 1364 | */ |
1380 | rate_ctrl->hw_maxretry_pktcnt = 0; | 1365 | ath_rc_priv->hw_maxretry_pktcnt = 0; |
1381 | } else { | 1366 | } else { |
1382 | /* | 1367 | /* |
1383 | * It worked with no retries. First ignore bogus (small) | 1368 | * It worked with no retries. First ignore bogus (small) |
1384 | * rssi_ack values. | 1369 | * rssi_ack values. |
1385 | */ | 1370 | */ |
1386 | if (tx_rate == rate_ctrl->rate_max_phy && | 1371 | if (tx_rate == ath_rc_priv->rate_max_phy && |
1387 | rate_ctrl->hw_maxretry_pktcnt < 255) { | 1372 | ath_rc_priv->hw_maxretry_pktcnt < 255) { |
1388 | rate_ctrl->hw_maxretry_pktcnt++; | 1373 | ath_rc_priv->hw_maxretry_pktcnt++; |
1389 | } | 1374 | } |
1390 | 1375 | ||
1391 | if (info_priv->tx.ts_rssi >= | 1376 | if (info_priv->tx.ts_rssi >= |
1392 | rate_table->info[tx_rate].rssi_ack_validmin) { | 1377 | rate_table->info[tx_rate].rssi_ack_validmin) { |
1393 | /* Average the rssi */ | 1378 | /* Average the rssi */ |
1394 | if (tx_rate != rate_ctrl->rssi_sum_rate) { | 1379 | if (tx_rate != ath_rc_priv->rssi_sum_rate) { |
1395 | rate_ctrl->rssi_sum_rate = tx_rate; | 1380 | ath_rc_priv->rssi_sum_rate = tx_rate; |
1396 | rate_ctrl->rssi_sum = | 1381 | ath_rc_priv->rssi_sum = |
1397 | rate_ctrl->rssi_sum_cnt = 0; | 1382 | ath_rc_priv->rssi_sum_cnt = 0; |
1398 | } | 1383 | } |
1399 | 1384 | ||
1400 | rate_ctrl->rssi_sum += info_priv->tx.ts_rssi; | 1385 | ath_rc_priv->rssi_sum += info_priv->tx.ts_rssi; |
1401 | rate_ctrl->rssi_sum_cnt++; | 1386 | ath_rc_priv->rssi_sum_cnt++; |
1402 | 1387 | ||
1403 | if (rate_ctrl->rssi_sum_cnt > 4) { | 1388 | if (ath_rc_priv->rssi_sum_cnt > 4) { |
1404 | int32_t rssi_ackAvg = | 1389 | int32_t rssi_ackAvg = |
1405 | (rate_ctrl->rssi_sum + 2) / 4; | 1390 | (ath_rc_priv->rssi_sum + 2) / 4; |
1406 | int8_t rssi_thres = | 1391 | int8_t rssi_thres = |
1407 | rate_ctrl->state[tx_rate]. | 1392 | ath_rc_priv->state[tx_rate]. |
1408 | rssi_thres; | 1393 | rssi_thres; |
1409 | int8_t rssi_ack_vmin = | 1394 | int8_t rssi_ack_vmin = |
1410 | rate_table->info[tx_rate]. | 1395 | rate_table->info[tx_rate]. |
1411 | rssi_ack_validmin; | 1396 | rssi_ack_validmin; |
1412 | 1397 | ||
1413 | rate_ctrl->rssi_sum = | 1398 | ath_rc_priv->rssi_sum = |
1414 | rate_ctrl->rssi_sum_cnt = 0; | 1399 | ath_rc_priv->rssi_sum_cnt = 0; |
1415 | 1400 | ||
1416 | /* Now reduce the current | 1401 | /* Now reduce the current |
1417 | * rssi threshold. */ | 1402 | * rssi threshold. */ |
1418 | if ((rssi_ackAvg < rssi_thres + 2) && | 1403 | if ((rssi_ackAvg < rssi_thres + 2) && |
1419 | (rssi_thres > rssi_ack_vmin)) { | 1404 | (rssi_thres > rssi_ack_vmin)) { |
1420 | rate_ctrl->state[tx_rate]. | 1405 | ath_rc_priv->state[tx_rate]. |
1421 | rssi_thres--; | 1406 | rssi_thres--; |
1422 | } | 1407 | } |
1423 | 1408 | ||
@@ -1433,14 +1418,14 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1433 | * If this rate looks bad (high PER) then stop using it for | 1418 | * If this rate looks bad (high PER) then stop using it for |
1434 | * a while (except if we are probing). | 1419 | * a while (except if we are probing). |
1435 | */ | 1420 | */ |
1436 | if (rate_ctrl->state[tx_rate].per >= 55 && tx_rate > 0 && | 1421 | if (ath_rc_priv->state[tx_rate].per >= 55 && tx_rate > 0 && |
1437 | rate_table->info[tx_rate].ratekbps <= | 1422 | rate_table->info[tx_rate].ratekbps <= |
1438 | rate_table->info[rate_ctrl->rate_max_phy].ratekbps) { | 1423 | rate_table->info[ath_rc_priv->rate_max_phy].ratekbps) { |
1439 | ath_rc_get_nextlowervalid_txrate(rate_table, rate_ctrl, | 1424 | ath_rc_get_nextlowervalid_txrate(rate_table, ath_rc_priv, |
1440 | (u8) tx_rate, &rate_ctrl->rate_max_phy); | 1425 | (u8) tx_rate, &ath_rc_priv->rate_max_phy); |
1441 | 1426 | ||
1442 | /* Don't probe for a little while. */ | 1427 | /* Don't probe for a little while. */ |
1443 | rate_ctrl->probe_time = now_msec; | 1428 | ath_rc_priv->probe_time = now_msec; |
1444 | } | 1429 | } |
1445 | 1430 | ||
1446 | if (state_change) { | 1431 | if (state_change) { |
@@ -1452,16 +1437,16 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1452 | * increasing between the CCK and OFDM rates.) | 1437 | * increasing between the CCK and OFDM rates.) |
1453 | */ | 1438 | */ |
1454 | for (rate = tx_rate; rate < | 1439 | for (rate = tx_rate; rate < |
1455 | rate_ctrl->rate_table_size - 1; rate++) { | 1440 | ath_rc_priv->rate_table_size - 1; rate++) { |
1456 | if (rate_table->info[rate+1].phy != | 1441 | if (rate_table->info[rate+1].phy != |
1457 | rate_table->info[tx_rate].phy) | 1442 | rate_table->info[tx_rate].phy) |
1458 | break; | 1443 | break; |
1459 | 1444 | ||
1460 | if (rate_ctrl->state[rate].rssi_thres + | 1445 | if (ath_rc_priv->state[rate].rssi_thres + |
1461 | rate_table->info[rate].rssi_ack_deltamin > | 1446 | rate_table->info[rate].rssi_ack_deltamin > |
1462 | rate_ctrl->state[rate+1].rssi_thres) { | 1447 | ath_rc_priv->state[rate+1].rssi_thres) { |
1463 | rate_ctrl->state[rate+1].rssi_thres = | 1448 | ath_rc_priv->state[rate+1].rssi_thres = |
1464 | rate_ctrl->state[rate]. | 1449 | ath_rc_priv->state[rate]. |
1465 | rssi_thres + | 1450 | rssi_thres + |
1466 | rate_table->info[rate]. | 1451 | rate_table->info[rate]. |
1467 | rssi_ack_deltamin; | 1452 | rssi_ack_deltamin; |
@@ -1474,25 +1459,25 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1474 | rate_table->info[tx_rate].phy) | 1459 | rate_table->info[tx_rate].phy) |
1475 | break; | 1460 | break; |
1476 | 1461 | ||
1477 | if (rate_ctrl->state[rate].rssi_thres + | 1462 | if (ath_rc_priv->state[rate].rssi_thres + |
1478 | rate_table->info[rate].rssi_ack_deltamin > | 1463 | rate_table->info[rate].rssi_ack_deltamin > |
1479 | rate_ctrl->state[rate+1].rssi_thres) { | 1464 | ath_rc_priv->state[rate+1].rssi_thres) { |
1480 | if (rate_ctrl->state[rate+1].rssi_thres < | 1465 | if (ath_rc_priv->state[rate+1].rssi_thres < |
1481 | rate_table->info[rate]. | 1466 | rate_table->info[rate]. |
1482 | rssi_ack_deltamin) | 1467 | rssi_ack_deltamin) |
1483 | rate_ctrl->state[rate].rssi_thres = 0; | 1468 | ath_rc_priv->state[rate].rssi_thres = 0; |
1484 | else { | 1469 | else { |
1485 | rate_ctrl->state[rate].rssi_thres = | 1470 | ath_rc_priv->state[rate].rssi_thres = |
1486 | rate_ctrl->state[rate+1]. | 1471 | ath_rc_priv->state[rate+1]. |
1487 | rssi_thres - | 1472 | rssi_thres - |
1488 | rate_table->info[rate]. | 1473 | rate_table->info[rate]. |
1489 | rssi_ack_deltamin; | 1474 | rssi_ack_deltamin; |
1490 | } | 1475 | } |
1491 | 1476 | ||
1492 | if (rate_ctrl->state[rate].rssi_thres < | 1477 | if (ath_rc_priv->state[rate].rssi_thres < |
1493 | rate_table->info[rate]. | 1478 | rate_table->info[rate]. |
1494 | rssi_ack_validmin) { | 1479 | rssi_ack_validmin) { |
1495 | rate_ctrl->state[rate].rssi_thres = | 1480 | ath_rc_priv->state[rate].rssi_thres = |
1496 | rate_table->info[rate]. | 1481 | rate_table->info[rate]. |
1497 | rssi_ack_validmin; | 1482 | rssi_ack_validmin; |
1498 | } | 1483 | } |
@@ -1502,50 +1487,50 @@ static void ath_rc_update_ht(struct ath_softc *sc, | |||
1502 | 1487 | ||
1503 | /* Make sure the rates below this have lower PER */ | 1488 | /* Make sure the rates below this have lower PER */ |
1504 | /* Monotonicity is kept only for rates below the current rate. */ | 1489 | /* Monotonicity is kept only for rates below the current rate. */ |
1505 | if (rate_ctrl->state[tx_rate].per < last_per) { | 1490 | if (ath_rc_priv->state[tx_rate].per < last_per) { |
1506 | for (rate = tx_rate - 1; rate >= 0; rate--) { | 1491 | for (rate = tx_rate - 1; rate >= 0; rate--) { |
1507 | if (rate_table->info[rate].phy != | 1492 | if (rate_table->info[rate].phy != |
1508 | rate_table->info[tx_rate].phy) | 1493 | rate_table->info[tx_rate].phy) |
1509 | break; | 1494 | break; |
1510 | 1495 | ||
1511 | if (rate_ctrl->state[rate].per > | 1496 | if (ath_rc_priv->state[rate].per > |
1512 | rate_ctrl->state[rate+1].per) { | 1497 | ath_rc_priv->state[rate+1].per) { |
1513 | rate_ctrl->state[rate].per = | 1498 | ath_rc_priv->state[rate].per = |
1514 | rate_ctrl->state[rate+1].per; | 1499 | ath_rc_priv->state[rate+1].per; |
1515 | } | 1500 | } |
1516 | } | 1501 | } |
1517 | } | 1502 | } |
1518 | 1503 | ||
1519 | /* Maintain monotonicity for rates above the current rate */ | 1504 | /* Maintain monotonicity for rates above the current rate */ |
1520 | for (rate = tx_rate; rate < rate_ctrl->rate_table_size - 1; rate++) { | 1505 | for (rate = tx_rate; rate < ath_rc_priv->rate_table_size - 1; rate++) { |
1521 | if (rate_ctrl->state[rate+1].per < rate_ctrl->state[rate].per) | 1506 | if (ath_rc_priv->state[rate+1].per < ath_rc_priv->state[rate].per) |
1522 | rate_ctrl->state[rate+1].per = | 1507 | ath_rc_priv->state[rate+1].per = |
1523 | rate_ctrl->state[rate].per; | 1508 | ath_rc_priv->state[rate].per; |
1524 | } | 1509 | } |
1525 | 1510 | ||
1526 | /* Every so often, we reduce the thresholds and | 1511 | /* Every so often, we reduce the thresholds and |
1527 | * PER (different for CCK and OFDM). */ | 1512 | * PER (different for CCK and OFDM). */ |
1528 | if (now_msec - rate_ctrl->rssi_down_time >= | 1513 | if (now_msec - ath_rc_priv->rssi_down_time >= |
1529 | rate_table->rssi_reduce_interval) { | 1514 | rate_table->rssi_reduce_interval) { |
1530 | 1515 | ||
1531 | for (rate = 0; rate < rate_ctrl->rate_table_size; rate++) { | 1516 | for (rate = 0; rate < ath_rc_priv->rate_table_size; rate++) { |
1532 | if (rate_ctrl->state[rate].rssi_thres > | 1517 | if (ath_rc_priv->state[rate].rssi_thres > |
1533 | rate_table->info[rate].rssi_ack_validmin) | 1518 | rate_table->info[rate].rssi_ack_validmin) |
1534 | rate_ctrl->state[rate].rssi_thres -= 1; | 1519 | ath_rc_priv->state[rate].rssi_thres -= 1; |
1535 | } | 1520 | } |
1536 | rate_ctrl->rssi_down_time = now_msec; | 1521 | ath_rc_priv->rssi_down_time = now_msec; |
1537 | } | 1522 | } |
1538 | 1523 | ||
1539 | /* Every so often, we reduce the thresholds | 1524 | /* Every so often, we reduce the thresholds |
1540 | * and PER (different for CCK and OFDM). */ | 1525 | * and PER (different for CCK and OFDM). */ |
1541 | if (now_msec - rate_ctrl->per_down_time >= | 1526 | if (now_msec - ath_rc_priv->per_down_time >= |
1542 | rate_table->rssi_reduce_interval) { | 1527 | rate_table->rssi_reduce_interval) { |
1543 | for (rate = 0; rate < rate_ctrl->rate_table_size; rate++) { | 1528 | for (rate = 0; rate < ath_rc_priv->rate_table_size; rate++) { |
1544 | rate_ctrl->state[rate].per = | 1529 | ath_rc_priv->state[rate].per = |
1545 | 7 * rate_ctrl->state[rate].per / 8; | 1530 | 7 * ath_rc_priv->state[rate].per / 8; |
1546 | } | 1531 | } |
1547 | 1532 | ||
1548 | rate_ctrl->per_down_time = now_msec; | 1533 | ath_rc_priv->per_down_time = now_msec; |
1549 | } | 1534 | } |
1550 | } | 1535 | } |
1551 | 1536 | ||
@@ -1560,7 +1545,6 @@ static void ath_rc_update(struct ath_softc *sc, | |||
1560 | { | 1545 | { |
1561 | struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc; | 1546 | struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc; |
1562 | struct ath_rate_table *rate_table; | 1547 | struct ath_rate_table *rate_table; |
1563 | struct ath_tx_ratectrl *rate_ctrl; | ||
1564 | struct ath_rc_series rcs[4]; | 1548 | struct ath_rc_series rcs[4]; |
1565 | u8 flags; | 1549 | u8 flags; |
1566 | u32 series = 0, rix; | 1550 | u32 series = 0, rix; |
@@ -1568,7 +1552,6 @@ static void ath_rc_update(struct ath_softc *sc, | |||
1568 | memcpy(rcs, info_priv->rcs, 4 * sizeof(rcs[0])); | 1552 | memcpy(rcs, info_priv->rcs, 4 * sizeof(rcs[0])); |
1569 | rate_table = (struct ath_rate_table *) | 1553 | rate_table = (struct ath_rate_table *) |
1570 | asc->hw_rate_table[sc->sc_curmode]; | 1554 | asc->hw_rate_table[sc->sc_curmode]; |
1571 | rate_ctrl = (struct ath_tx_ratectrl *)(ath_rc_priv); | ||
1572 | ASSERT(rcs[0].tries != 0); | 1555 | ASSERT(rcs[0].tries != 0); |
1573 | 1556 | ||
1574 | /* | 1557 | /* |
@@ -1583,7 +1566,7 @@ static void ath_rc_update(struct ath_softc *sc, | |||
1583 | /* If HT40 and we have switched mode from | 1566 | /* If HT40 and we have switched mode from |
1584 | * 40 to 20 => don't update */ | 1567 | * 40 to 20 => don't update */ |
1585 | if ((flags & ATH_RC_CW40_FLAG) && | 1568 | if ((flags & ATH_RC_CW40_FLAG) && |
1586 | (rate_ctrl->rc_phy_mode != | 1569 | (ath_rc_priv->rc_phy_mode != |
1587 | (flags & ATH_RC_CW40_FLAG))) | 1570 | (flags & ATH_RC_CW40_FLAG))) |
1588 | return; | 1571 | return; |
1589 | if ((flags & ATH_RC_CW40_FLAG) && | 1572 | if ((flags & ATH_RC_CW40_FLAG) && |
@@ -1619,7 +1602,7 @@ static void ath_rc_update(struct ath_softc *sc, | |||
1619 | flags = rcs[series].flags; | 1602 | flags = rcs[series].flags; |
1620 | /* If HT40 and we have switched mode from 40 to 20 => don't update */ | 1603 | /* If HT40 and we have switched mode from 40 to 20 => don't update */ |
1621 | if ((flags & ATH_RC_CW40_FLAG) && | 1604 | if ((flags & ATH_RC_CW40_FLAG) && |
1622 | (rate_ctrl->rc_phy_mode != (flags & ATH_RC_CW40_FLAG))) | 1605 | (ath_rc_priv->rc_phy_mode != (flags & ATH_RC_CW40_FLAG))) |
1623 | return; | 1606 | return; |
1624 | 1607 | ||
1625 | if ((flags & ATH_RC_CW40_FLAG) && (flags & ATH_RC_SGI_FLAG)) | 1608 | if ((flags & ATH_RC_CW40_FLAG) && (flags & ATH_RC_SGI_FLAG)) |
@@ -1697,8 +1680,6 @@ static void ath_rc_sib_update(struct ath_softc *sc, | |||
1697 | struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc; | 1680 | struct ath_rate_softc *asc = (struct ath_rate_softc *)sc->sc_rc; |
1698 | struct ath_rateset *rateset = negotiated_rates; | 1681 | struct ath_rateset *rateset = negotiated_rates; |
1699 | u8 *ht_mcs = (u8 *)negotiated_htrates; | 1682 | u8 *ht_mcs = (u8 *)negotiated_htrates; |
1700 | struct ath_tx_ratectrl *rate_ctrl = | ||
1701 | (struct ath_tx_ratectrl *)ath_rc_priv; | ||
1702 | u8 i, j, k, hi = 0, hthi = 0; | 1683 | u8 i, j, k, hi = 0, hthi = 0; |
1703 | 1684 | ||
1704 | rate_table = (struct ath_rate_table *) | 1685 | rate_table = (struct ath_rate_table *) |
@@ -1706,24 +1687,24 @@ static void ath_rc_sib_update(struct ath_softc *sc, | |||
1706 | 1687 | ||
1707 | /* Initial rate table size. Will change depending | 1688 | /* Initial rate table size. Will change depending |
1708 | * on the working rate set */ | 1689 | * on the working rate set */ |
1709 | rate_ctrl->rate_table_size = MAX_TX_RATE_TBL; | 1690 | ath_rc_priv->rate_table_size = MAX_TX_RATE_TBL; |
1710 | 1691 | ||
1711 | /* Initialize thresholds according to the global rate table */ | 1692 | /* Initialize thresholds according to the global rate table */ |
1712 | for (i = 0 ; (i < rate_ctrl->rate_table_size) && (!keep_state); i++) { | 1693 | for (i = 0 ; (i < ath_rc_priv->rate_table_size) && (!keep_state); i++) { |
1713 | rate_ctrl->state[i].rssi_thres = | 1694 | ath_rc_priv->state[i].rssi_thres = |
1714 | rate_table->info[i].rssi_ack_validmin; | 1695 | rate_table->info[i].rssi_ack_validmin; |
1715 | rate_ctrl->state[i].per = 0; | 1696 | ath_rc_priv->state[i].per = 0; |
1716 | } | 1697 | } |
1717 | 1698 | ||
1718 | /* Determine the valid rates */ | 1699 | /* Determine the valid rates */ |
1719 | ath_rc_init_valid_txmask(rate_ctrl); | 1700 | ath_rc_init_valid_txmask(ath_rc_priv); |
1720 | 1701 | ||
1721 | for (i = 0; i < WLAN_RC_PHY_MAX; i++) { | 1702 | for (i = 0; i < WLAN_RC_PHY_MAX; i++) { |
1722 | for (j = 0; j < MAX_TX_RATE_PHY; j++) | 1703 | for (j = 0; j < MAX_TX_RATE_PHY; j++) |
1723 | rate_ctrl->valid_phy_rateidx[i][j] = 0; | 1704 | ath_rc_priv->valid_phy_rateidx[i][j] = 0; |
1724 | rate_ctrl->valid_phy_ratecnt[i] = 0; | 1705 | ath_rc_priv->valid_phy_ratecnt[i] = 0; |
1725 | } | 1706 | } |
1726 | rate_ctrl->rc_phy_mode = (capflag & WLAN_RC_40_FLAG); | 1707 | ath_rc_priv->rc_phy_mode = (capflag & WLAN_RC_40_FLAG); |
1727 | 1708 | ||
1728 | /* Set stream capability */ | 1709 | /* Set stream capability */ |
1729 | ath_rc_priv->single_stream = (capflag & WLAN_RC_DS_FLAG) ? 0 : 1; | 1710 | ath_rc_priv->single_stream = (capflag & WLAN_RC_DS_FLAG) ? 0 : 1; |
@@ -1745,33 +1726,33 @@ static void ath_rc_sib_update(struct ath_softc *sc, | |||
1745 | hi = A_MAX(hi, hthi); | 1726 | hi = A_MAX(hi, hthi); |
1746 | } | 1727 | } |
1747 | 1728 | ||
1748 | rate_ctrl->rate_table_size = hi + 1; | 1729 | ath_rc_priv->rate_table_size = hi + 1; |
1749 | rate_ctrl->rate_max_phy = 0; | 1730 | ath_rc_priv->rate_max_phy = 0; |
1750 | ASSERT(rate_ctrl->rate_table_size <= MAX_TX_RATE_TBL); | 1731 | ASSERT(ath_rc_priv->rate_table_size <= MAX_TX_RATE_TBL); |
1751 | 1732 | ||
1752 | for (i = 0, k = 0; i < WLAN_RC_PHY_MAX; i++) { | 1733 | for (i = 0, k = 0; i < WLAN_RC_PHY_MAX; i++) { |
1753 | for (j = 0; j < rate_ctrl->valid_phy_ratecnt[i]; j++) { | 1734 | for (j = 0; j < ath_rc_priv->valid_phy_ratecnt[i]; j++) { |
1754 | rate_ctrl->valid_rate_index[k++] = | 1735 | ath_rc_priv->valid_rate_index[k++] = |
1755 | rate_ctrl->valid_phy_rateidx[i][j]; | 1736 | ath_rc_priv->valid_phy_rateidx[i][j]; |
1756 | } | 1737 | } |
1757 | 1738 | ||
1758 | if (!ath_rc_valid_phyrate(i, rate_table->initial_ratemax, TRUE) | 1739 | if (!ath_rc_valid_phyrate(i, rate_table->initial_ratemax, TRUE) |
1759 | || !rate_ctrl->valid_phy_ratecnt[i]) | 1740 | || !ath_rc_priv->valid_phy_ratecnt[i]) |
1760 | continue; | 1741 | continue; |
1761 | 1742 | ||
1762 | rate_ctrl->rate_max_phy = rate_ctrl->valid_phy_rateidx[i][j-1]; | 1743 | ath_rc_priv->rate_max_phy = ath_rc_priv->valid_phy_rateidx[i][j-1]; |
1763 | } | 1744 | } |
1764 | ASSERT(rate_ctrl->rate_table_size <= MAX_TX_RATE_TBL); | 1745 | ASSERT(ath_rc_priv->rate_table_size <= MAX_TX_RATE_TBL); |
1765 | ASSERT(k <= MAX_TX_RATE_TBL); | 1746 | ASSERT(k <= MAX_TX_RATE_TBL); |
1766 | 1747 | ||
1767 | rate_ctrl->max_valid_rate = k; | 1748 | ath_rc_priv->max_valid_rate = k; |
1768 | /* | 1749 | /* |
1769 | * Some third party vendors don't send the supported rate series in | 1750 | * Some third party vendors don't send the supported rate series in |
1770 | * order. So sorting to make sure its in order, otherwise our RateFind | 1751 | * order. So sorting to make sure its in order, otherwise our RateFind |
1771 | * Algo will select wrong rates | 1752 | * Algo will select wrong rates |
1772 | */ | 1753 | */ |
1773 | ath_rc_sort_validrates(rate_table, rate_ctrl); | 1754 | ath_rc_sort_validrates(rate_table, ath_rc_priv); |
1774 | rate_ctrl->rate_max_phy = rate_ctrl->valid_rate_index[k-4]; | 1755 | ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4]; |
1775 | } | 1756 | } |
1776 | 1757 | ||
1777 | /* | 1758 | /* |
@@ -1804,10 +1785,7 @@ static int ath_rate_newassoc(struct ath_softc *sc, | |||
1804 | */ | 1785 | */ |
1805 | static void ath_rc_sib_init(struct ath_rate_node *ath_rc_priv) | 1786 | static void ath_rc_sib_init(struct ath_rate_node *ath_rc_priv) |
1806 | { | 1787 | { |
1807 | struct ath_tx_ratectrl *rate_ctrl; | 1788 | ath_rc_priv->rssi_down_time = jiffies_to_msecs(jiffies); |
1808 | |||
1809 | rate_ctrl = (struct ath_tx_ratectrl *)(ath_rc_priv); | ||
1810 | rate_ctrl->rssi_down_time = jiffies_to_msecs(jiffies); | ||
1811 | } | 1789 | } |
1812 | 1790 | ||
1813 | 1791 | ||
diff --git a/drivers/net/wireless/ath9k/rc.h b/drivers/net/wireless/ath9k/rc.h index 6671097fad7..2166243045d 100644 --- a/drivers/net/wireless/ath9k/rc.h +++ b/drivers/net/wireless/ath9k/rc.h | |||
@@ -204,8 +204,22 @@ struct ath_tx_ratectrl_state { | |||
204 | u8 per; /* recent estimate of packet error rate (%) */ | 204 | u8 per; /* recent estimate of packet error rate (%) */ |
205 | }; | 205 | }; |
206 | 206 | ||
207 | struct ath_rateset { | ||
208 | u8 rs_nrates; | ||
209 | u8 rs_rates[ATH_RATE_MAX]; | ||
210 | }; | ||
211 | |||
212 | /* per-device state */ | ||
213 | struct ath_rate_softc { | ||
214 | /* phy tables that contain rate control data */ | ||
215 | const void *hw_rate_table[ATH9K_MODE_MAX]; | ||
216 | |||
217 | /* -1 or index of fixed rate */ | ||
218 | int fixedrix; | ||
219 | }; | ||
220 | |||
207 | /** | 221 | /** |
208 | * struct ath_tx_ratectrl - TX Rate control Information | 222 | * struct ath_rate_node - Rate Control priv data |
209 | * @state: RC state | 223 | * @state: RC state |
210 | * @rssi_last: last ACK rssi | 224 | * @rssi_last: last ACK rssi |
211 | * @rssi_last_lookup: last ACK rssi used for lookup | 225 | * @rssi_last_lookup: last ACK rssi used for lookup |
@@ -224,9 +238,15 @@ struct ath_tx_ratectrl_state { | |||
224 | * @valid_phy_ratecnt: valid rate count | 238 | * @valid_phy_ratecnt: valid rate count |
225 | * @rate_max_phy: phy index for the max rate | 239 | * @rate_max_phy: phy index for the max rate |
226 | * @probe_interval: interval for ratectrl to probe for other rates | 240 | * @probe_interval: interval for ratectrl to probe for other rates |
241 | * @prev_data_rix: rate idx of last data frame | ||
242 | * @ht_cap: HT capabilities | ||
243 | * @single_stream: When TRUE, only single TX stream possible | ||
244 | * @neg_rates: Negotatied rates | ||
245 | * @neg_ht_rates: Negotiated HT rates | ||
227 | */ | 246 | */ |
228 | struct ath_tx_ratectrl { | 247 | |
229 | struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL]; | 248 | /* per-node state */ |
249 | struct ath_rate_node { | ||
230 | int8_t rssi_last; | 250 | int8_t rssi_last; |
231 | int8_t rssi_last_lookup; | 251 | int8_t rssi_last_lookup; |
232 | int8_t rssi_last_prev; | 252 | int8_t rssi_last_prev; |
@@ -236,55 +256,24 @@ struct ath_tx_ratectrl { | |||
236 | int32_t rssi_sum; | 256 | int32_t rssi_sum; |
237 | u8 rate_table_size; | 257 | u8 rate_table_size; |
238 | u8 probe_rate; | 258 | u8 probe_rate; |
239 | u32 rssi_time; | ||
240 | u32 rssi_down_time; | ||
241 | u32 probe_time; | ||
242 | u8 hw_maxretry_pktcnt; | 259 | u8 hw_maxretry_pktcnt; |
243 | u8 max_valid_rate; | 260 | u8 max_valid_rate; |
244 | u8 valid_rate_index[MAX_TX_RATE_TBL]; | 261 | u8 valid_rate_index[MAX_TX_RATE_TBL]; |
245 | u32 per_down_time; | 262 | u8 ht_cap; |
246 | 263 | u8 single_stream; | |
247 | /* 11n state */ | ||
248 | u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; | 264 | u8 valid_phy_ratecnt[WLAN_RC_PHY_MAX]; |
249 | u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][MAX_TX_RATE_TBL]; | 265 | u8 valid_phy_rateidx[WLAN_RC_PHY_MAX][MAX_TX_RATE_TBL]; |
250 | u8 rc_phy_mode; | 266 | u8 rc_phy_mode; |
251 | u8 rate_max_phy; | 267 | u8 rate_max_phy; |
268 | u32 rssi_time; | ||
269 | u32 rssi_down_time; | ||
270 | u32 probe_time; | ||
271 | u32 per_down_time; | ||
252 | u32 probe_interval; | 272 | u32 probe_interval; |
253 | }; | ||
254 | |||
255 | struct ath_rateset { | ||
256 | u8 rs_nrates; | ||
257 | u8 rs_rates[ATH_RATE_MAX]; | ||
258 | }; | ||
259 | |||
260 | /* per-device state */ | ||
261 | struct ath_rate_softc { | ||
262 | /* phy tables that contain rate control data */ | ||
263 | const void *hw_rate_table[ATH9K_MODE_MAX]; | ||
264 | |||
265 | /* -1 or index of fixed rate */ | ||
266 | int fixedrix; | ||
267 | }; | ||
268 | |||
269 | /* per-node state */ | ||
270 | struct ath_rate_node { | ||
271 | struct ath_tx_ratectrl tx_ratectrl; | ||
272 | |||
273 | /* rate idx of last data frame */ | ||
274 | u32 prev_data_rix; | 273 | u32 prev_data_rix; |
275 | 274 | struct ath_tx_ratectrl_state state[MAX_TX_RATE_TBL]; | |
276 | /* ht capabilities */ | ||
277 | u8 ht_cap; | ||
278 | |||
279 | /* When TRUE, only single stream Tx possible */ | ||
280 | u8 single_stream; | ||
281 | |||
282 | /* Negotiated rates */ | ||
283 | struct ath_rateset neg_rates; | 275 | struct ath_rateset neg_rates; |
284 | |||
285 | /* Negotiated HT rates */ | ||
286 | struct ath_rateset neg_ht_rates; | 276 | struct ath_rateset neg_ht_rates; |
287 | |||
288 | struct ath_rate_softc *asc; | 277 | struct ath_rate_softc *asc; |
289 | struct ath_vap *avp; | 278 | struct ath_vap *avp; |
290 | }; | 279 | }; |