aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/rc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/rc.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c311
1 files changed, 155 insertions, 156 deletions
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 1d96777b4cd..66d3004af2b 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -19,132 +19,133 @@
19 19
20static const struct ath_rate_table ar5416_11na_ratetable = { 20static const struct ath_rate_table ar5416_11na_ratetable = {
21 42, 21 42,
22 8, /* MCS start */
22 { 23 {
23 { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ 24 { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
24 5400, 0x0b, 0x00, 12, 25 5400, 0, 0x00, 12,
25 0, 0, 0, 0, 0, 0 }, 26 0, 0, 0, 0, 0, 0 },
26 { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ 27 { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
27 7800, 0x0f, 0x00, 18, 28 7800, 1, 0x00, 18,
28 0, 1, 1, 1, 1, 0 }, 29 0, 1, 1, 1, 1, 0 },
29 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ 30 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
30 10000, 0x0a, 0x00, 24, 31 10000, 2, 0x00, 24,
31 2, 2, 2, 2, 2, 0 }, 32 2, 2, 2, 2, 2, 0 },
32 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ 33 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
33 13900, 0x0e, 0x00, 36, 34 13900, 3, 0x00, 36,
34 2, 3, 3, 3, 3, 0 }, 35 2, 3, 3, 3, 3, 0 },
35 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ 36 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
36 17300, 0x09, 0x00, 48, 37 17300, 4, 0x00, 48,
37 4, 4, 4, 4, 4, 0 }, 38 4, 4, 4, 4, 4, 0 },
38 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ 39 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
39 23000, 0x0d, 0x00, 72, 40 23000, 5, 0x00, 72,
40 4, 5, 5, 5, 5, 0 }, 41 4, 5, 5, 5, 5, 0 },
41 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ 42 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
42 27400, 0x08, 0x00, 96, 43 27400, 6, 0x00, 96,
43 4, 6, 6, 6, 6, 0 }, 44 4, 6, 6, 6, 6, 0 },
44 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ 45 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
45 29300, 0x0c, 0x00, 108, 46 29300, 7, 0x00, 108,
46 4, 7, 7, 7, 7, 0 }, 47 4, 7, 7, 7, 7, 0 },
47 { VALID_2040, VALID_2040, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */ 48 { VALID_2040, VALID_2040, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
48 6400, 0x80, 0x00, 0, 49 6400, 0, 0x00, 0,
49 0, 8, 24, 8, 24, 3216 }, 50 0, 8, 24, 8, 24, 3216 },
50 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */ 51 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
51 12700, 0x81, 0x00, 1, 52 12700, 1, 0x00, 1,
52 2, 9, 25, 9, 25, 6434 }, 53 2, 9, 25, 9, 25, 6434 },
53 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */ 54 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
54 18800, 0x82, 0x00, 2, 55 18800, 2, 0x00, 2,
55 2, 10, 26, 10, 26, 9650 }, 56 2, 10, 26, 10, 26, 9650 },
56 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */ 57 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
57 25000, 0x83, 0x00, 3, 58 25000, 3, 0x00, 3,
58 4, 11, 27, 11, 27, 12868 }, 59 4, 11, 27, 11, 27, 12868 },
59 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */ 60 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
60 36700, 0x84, 0x00, 4, 61 36700, 4, 0x00, 4,
61 4, 12, 28, 12, 28, 19304 }, 62 4, 12, 28, 12, 28, 19304 },
62 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */ 63 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
63 48100, 0x85, 0x00, 5, 64 48100, 5, 0x00, 5,
64 4, 13, 29, 13, 29, 25740 }, 65 4, 13, 29, 13, 29, 25740 },
65 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */ 66 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
66 53500, 0x86, 0x00, 6, 67 53500, 6, 0x00, 6,
67 4, 14, 30, 14, 30, 28956 }, 68 4, 14, 30, 14, 30, 28956 },
68 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */ 69 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
69 59000, 0x87, 0x00, 7, 70 59000, 7, 0x00, 7,
70 4, 15, 31, 15, 32, 32180 }, 71 4, 15, 31, 15, 32, 32180 },
71 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */ 72 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
72 12700, 0x88, 0x00, 73 12700, 8, 0x00,
73 8, 3, 16, 33, 16, 33, 6430 }, 74 8, 3, 16, 33, 16, 33, 6430 },
74 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */ 75 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
75 24800, 0x89, 0x00, 9, 76 24800, 9, 0x00, 9,
76 2, 17, 34, 17, 34, 12860 }, 77 2, 17, 34, 17, 34, 12860 },
77 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */ 78 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
78 36600, 0x8a, 0x00, 10, 79 36600, 10, 0x00, 10,
79 2, 18, 35, 18, 35, 19300 }, 80 2, 18, 35, 18, 35, 19300 },
80 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */ 81 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
81 48100, 0x8b, 0x00, 11, 82 48100, 11, 0x00, 11,
82 4, 19, 36, 19, 36, 25736 }, 83 4, 19, 36, 19, 36, 25736 },
83 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */ 84 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
84 69500, 0x8c, 0x00, 12, 85 69500, 12, 0x00, 12,
85 4, 20, 37, 20, 37, 38600 }, 86 4, 20, 37, 20, 37, 38600 },
86 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */ 87 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
87 89500, 0x8d, 0x00, 13, 88 89500, 13, 0x00, 13,
88 4, 21, 38, 21, 38, 51472 }, 89 4, 21, 38, 21, 38, 51472 },
89 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */ 90 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
90 98900, 0x8e, 0x00, 14, 91 98900, 14, 0x00, 14,
91 4, 22, 39, 22, 39, 57890 }, 92 4, 22, 39, 22, 39, 57890 },
92 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */ 93 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
93 108300, 0x8f, 0x00, 15, 94 108300, 15, 0x00, 15,
94 4, 23, 40, 23, 41, 64320 }, 95 4, 23, 40, 23, 41, 64320 },
95 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */ 96 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
96 13200, 0x80, 0x00, 0, 97 13200, 0, 0x00, 0,
97 0, 8, 24, 24, 24, 6684 }, 98 0, 8, 24, 24, 24, 6684 },
98 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */ 99 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
99 25900, 0x81, 0x00, 1, 100 25900, 1, 0x00, 1,
100 2, 9, 25, 25, 25, 13368 }, 101 2, 9, 25, 25, 25, 13368 },
101 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */ 102 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
102 38600, 0x82, 0x00, 2, 103 38600, 2, 0x00, 2,
103 2, 10, 26, 26, 26, 20052 }, 104 2, 10, 26, 26, 26, 20052 },
104 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */ 105 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
105 49800, 0x83, 0x00, 3, 106 49800, 3, 0x00, 3,
106 4, 11, 27, 27, 27, 26738 }, 107 4, 11, 27, 27, 27, 26738 },
107 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */ 108 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
108 72200, 0x84, 0x00, 4, 109 72200, 4, 0x00, 4,
109 4, 12, 28, 28, 28, 40104 }, 110 4, 12, 28, 28, 28, 40104 },
110 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */ 111 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
111 92900, 0x85, 0x00, 5, 112 92900, 5, 0x00, 5,
112 4, 13, 29, 29, 29, 53476 }, 113 4, 13, 29, 29, 29, 53476 },
113 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */ 114 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
114 102700, 0x86, 0x00, 6, 115 102700, 6, 0x00, 6,
115 4, 14, 30, 30, 30, 60156 }, 116 4, 14, 30, 30, 30, 60156 },
116 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */ 117 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
117 112000, 0x87, 0x00, 7, 118 112000, 7, 0x00, 7,
118 4, 15, 31, 32, 32, 66840 }, 119 4, 15, 31, 32, 32, 66840 },
119 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */ 120 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
120 122000, 0x87, 0x00, 7, 121 122000, 7, 0x00, 7,
121 4, 15, 31, 32, 32, 74200 }, 122 4, 15, 31, 32, 32, 74200 },
122 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */ 123 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
123 25800, 0x88, 0x00, 8, 124 25800, 8, 0x00, 8,
124 0, 16, 33, 33, 33, 13360 }, 125 0, 16, 33, 33, 33, 13360 },
125 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */ 126 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
126 49800, 0x89, 0x00, 9, 127 49800, 9, 0x00, 9,
127 2, 17, 34, 34, 34, 26720 }, 128 2, 17, 34, 34, 34, 26720 },
128 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */ 129 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
129 71900, 0x8a, 0x00, 10, 130 71900, 10, 0x00, 10,
130 2, 18, 35, 35, 35, 40080 }, 131 2, 18, 35, 35, 35, 40080 },
131 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */ 132 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
132 92500, 0x8b, 0x00, 11, 133 92500, 11, 0x00, 11,
133 4, 19, 36, 36, 36, 53440 }, 134 4, 19, 36, 36, 36, 53440 },
134 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */ 135 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
135 130300, 0x8c, 0x00, 12, 136 130300, 12, 0x00, 12,
136 4, 20, 37, 37, 37, 80160 }, 137 4, 20, 37, 37, 37, 80160 },
137 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */ 138 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
138 162800, 0x8d, 0x00, 13, 139 162800, 13, 0x00, 13,
139 4, 21, 38, 38, 38, 106880 }, 140 4, 21, 38, 38, 38, 106880 },
140 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */ 141 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
141 178200, 0x8e, 0x00, 14, 142 178200, 14, 0x00, 14,
142 4, 22, 39, 39, 39, 120240 }, 143 4, 22, 39, 39, 39, 120240 },
143 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */ 144 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
144 192100, 0x8f, 0x00, 15, 145 192100, 15, 0x00, 15,
145 4, 23, 40, 41, 41, 133600 }, 146 4, 23, 40, 41, 41, 133600 },
146 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */ 147 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
147 207000, 0x8f, 0x00, 15, 148 207000, 15, 0x00, 15,
148 4, 23, 40, 41, 41, 148400 }, 149 4, 23, 40, 41, 41, 148400 },
149 }, 150 },
150 50, /* probe interval */ 151 50, /* probe interval */
@@ -156,144 +157,145 @@ static const struct ath_rate_table ar5416_11na_ratetable = {
156 157
157static const struct ath_rate_table ar5416_11ng_ratetable = { 158static const struct ath_rate_table ar5416_11ng_ratetable = {
158 46, 159 46,
160 12, /* MCS start */
159 { 161 {
160 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */ 162 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
161 900, 0x1b, 0x00, 2, 163 900, 0, 0x00, 2,
162 0, 0, 0, 0, 0, 0 }, 164 0, 0, 0, 0, 0, 0 },
163 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */ 165 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */
164 1900, 0x1a, 0x04, 4, 166 1900, 1, 0x04, 4,
165 1, 1, 1, 1, 1, 0 }, 167 1, 1, 1, 1, 1, 0 },
166 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */ 168 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */
167 4900, 0x19, 0x04, 11, 169 4900, 2, 0x04, 11,
168 2, 2, 2, 2, 2, 0 }, 170 2, 2, 2, 2, 2, 0 },
169 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */ 171 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */
170 8100, 0x18, 0x04, 22, 172 8100, 3, 0x04, 22,
171 3, 3, 3, 3, 3, 0 }, 173 3, 3, 3, 3, 3, 0 },
172 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ 174 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
173 5400, 0x0b, 0x00, 12, 175 5400, 4, 0x00, 12,
174 4, 4, 4, 4, 4, 0 }, 176 4, 4, 4, 4, 4, 0 },
175 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ 177 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
176 7800, 0x0f, 0x00, 18, 178 7800, 5, 0x00, 18,
177 4, 5, 5, 5, 5, 0 }, 179 4, 5, 5, 5, 5, 0 },
178 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ 180 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
179 10100, 0x0a, 0x00, 24, 181 10100, 6, 0x00, 24,
180 6, 6, 6, 6, 6, 0 }, 182 6, 6, 6, 6, 6, 0 },
181 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ 183 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
182 14100, 0x0e, 0x00, 36, 184 14100, 7, 0x00, 36,
183 6, 7, 7, 7, 7, 0 }, 185 6, 7, 7, 7, 7, 0 },
184 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ 186 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
185 17700, 0x09, 0x00, 48, 187 17700, 8, 0x00, 48,
186 8, 8, 8, 8, 8, 0 }, 188 8, 8, 8, 8, 8, 0 },
187 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ 189 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
188 23700, 0x0d, 0x00, 72, 190 23700, 9, 0x00, 72,
189 8, 9, 9, 9, 9, 0 }, 191 8, 9, 9, 9, 9, 0 },
190 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ 192 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
191 27400, 0x08, 0x00, 96, 193 27400, 10, 0x00, 96,
192 8, 10, 10, 10, 10, 0 }, 194 8, 10, 10, 10, 10, 0 },
193 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ 195 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
194 30900, 0x0c, 0x00, 108, 196 30900, 11, 0x00, 108,
195 8, 11, 11, 11, 11, 0 }, 197 8, 11, 11, 11, 11, 0 },
196 { INVALID, INVALID, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */ 198 { INVALID, INVALID, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
197 6400, 0x80, 0x00, 0, 199 6400, 0, 0x00, 0,
198 4, 12, 28, 12, 28, 3216 }, 200 4, 12, 28, 12, 28, 3216 },
199 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */ 201 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
200 12700, 0x81, 0x00, 1, 202 12700, 1, 0x00, 1,
201 6, 13, 29, 13, 29, 6434 }, 203 6, 13, 29, 13, 29, 6434 },
202 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */ 204 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
203 18800, 0x82, 0x00, 2, 205 18800, 2, 0x00, 2,
204 6, 14, 30, 14, 30, 9650 }, 206 6, 14, 30, 14, 30, 9650 },
205 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */ 207 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
206 25000, 0x83, 0x00, 3, 208 25000, 3, 0x00, 3,
207 8, 15, 31, 15, 31, 12868 }, 209 8, 15, 31, 15, 31, 12868 },
208 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */ 210 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
209 36700, 0x84, 0x00, 4, 211 36700, 4, 0x00, 4,
210 8, 16, 32, 16, 32, 19304 }, 212 8, 16, 32, 16, 32, 19304 },
211 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */ 213 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
212 48100, 0x85, 0x00, 5, 214 48100, 5, 0x00, 5,
213 8, 17, 33, 17, 33, 25740 }, 215 8, 17, 33, 17, 33, 25740 },
214 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */ 216 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
215 53500, 0x86, 0x00, 6, 217 53500, 6, 0x00, 6,
216 8, 18, 34, 18, 34, 28956 }, 218 8, 18, 34, 18, 34, 28956 },
217 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */ 219 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
218 59000, 0x87, 0x00, 7, 220 59000, 7, 0x00, 7,
219 8, 19, 35, 19, 36, 32180 }, 221 8, 19, 35, 19, 36, 32180 },
220 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */ 222 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
221 12700, 0x88, 0x00, 8, 223 12700, 8, 0x00, 8,
222 4, 20, 37, 20, 37, 6430 }, 224 4, 20, 37, 20, 37, 6430 },
223 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */ 225 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
224 24800, 0x89, 0x00, 9, 226 24800, 9, 0x00, 9,
225 6, 21, 38, 21, 38, 12860 }, 227 6, 21, 38, 21, 38, 12860 },
226 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */ 228 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
227 36600, 0x8a, 0x00, 10, 229 36600, 10, 0x00, 10,
228 6, 22, 39, 22, 39, 19300 }, 230 6, 22, 39, 22, 39, 19300 },
229 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */ 231 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
230 48100, 0x8b, 0x00, 11, 232 48100, 11, 0x00, 11,
231 8, 23, 40, 23, 40, 25736 }, 233 8, 23, 40, 23, 40, 25736 },
232 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */ 234 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
233 69500, 0x8c, 0x00, 12, 235 69500, 12, 0x00, 12,
234 8, 24, 41, 24, 41, 38600 }, 236 8, 24, 41, 24, 41, 38600 },
235 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */ 237 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
236 89500, 0x8d, 0x00, 13, 238 89500, 13, 0x00, 13,
237 8, 25, 42, 25, 42, 51472 }, 239 8, 25, 42, 25, 42, 51472 },
238 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */ 240 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
239 98900, 0x8e, 0x00, 14, 241 98900, 14, 0x00, 14,
240 8, 26, 43, 26, 44, 57890 }, 242 8, 26, 43, 26, 44, 57890 },
241 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */ 243 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
242 108300, 0x8f, 0x00, 15, 244 108300, 15, 0x00, 15,
243 8, 27, 44, 27, 45, 64320 }, 245 8, 27, 44, 27, 45, 64320 },
244 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */ 246 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
245 13200, 0x80, 0x00, 0, 247 13200, 0, 0x00, 0,
246 8, 12, 28, 28, 28, 6684 }, 248 8, 12, 28, 28, 28, 6684 },
247 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */ 249 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
248 25900, 0x81, 0x00, 1, 250 25900, 1, 0x00, 1,
249 8, 13, 29, 29, 29, 13368 }, 251 8, 13, 29, 29, 29, 13368 },
250 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */ 252 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
251 38600, 0x82, 0x00, 2, 253 38600, 2, 0x00, 2,
252 8, 14, 30, 30, 30, 20052 }, 254 8, 14, 30, 30, 30, 20052 },
253 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */ 255 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
254 49800, 0x83, 0x00, 3, 256 49800, 3, 0x00, 3,
255 8, 15, 31, 31, 31, 26738 }, 257 8, 15, 31, 31, 31, 26738 },
256 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */ 258 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
257 72200, 0x84, 0x00, 4, 259 72200, 4, 0x00, 4,
258 8, 16, 32, 32, 32, 40104 }, 260 8, 16, 32, 32, 32, 40104 },
259 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */ 261 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
260 92900, 0x85, 0x00, 5, 262 92900, 5, 0x00, 5,
261 8, 17, 33, 33, 33, 53476 }, 263 8, 17, 33, 33, 33, 53476 },
262 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */ 264 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
263 102700, 0x86, 0x00, 6, 265 102700, 6, 0x00, 6,
264 8, 18, 34, 34, 34, 60156 }, 266 8, 18, 34, 34, 34, 60156 },
265 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */ 267 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
266 112000, 0x87, 0x00, 7, 268 112000, 7, 0x00, 7,
267 8, 19, 35, 36, 36, 66840 }, 269 8, 19, 35, 36, 36, 66840 },
268 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */ 270 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
269 122000, 0x87, 0x00, 7, 271 122000, 7, 0x00, 7,
270 8, 19, 35, 36, 36, 74200 }, 272 8, 19, 35, 36, 36, 74200 },
271 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */ 273 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
272 25800, 0x88, 0x00, 8, 274 25800, 8, 0x00, 8,
273 8, 20, 37, 37, 37, 13360 }, 275 8, 20, 37, 37, 37, 13360 },
274 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */ 276 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
275 49800, 0x89, 0x00, 9, 277 49800, 9, 0x00, 9,
276 8, 21, 38, 38, 38, 26720 }, 278 8, 21, 38, 38, 38, 26720 },
277 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */ 279 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
278 71900, 0x8a, 0x00, 10, 280 71900, 10, 0x00, 10,
279 8, 22, 39, 39, 39, 40080 }, 281 8, 22, 39, 39, 39, 40080 },
280 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */ 282 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
281 92500, 0x8b, 0x00, 11, 283 92500, 11, 0x00, 11,
282 8, 23, 40, 40, 40, 53440 }, 284 8, 23, 40, 40, 40, 53440 },
283 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */ 285 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
284 130300, 0x8c, 0x00, 12, 286 130300, 12, 0x00, 12,
285 8, 24, 41, 41, 41, 80160 }, 287 8, 24, 41, 41, 41, 80160 },
286 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */ 288 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
287 162800, 0x8d, 0x00, 13, 289 162800, 13, 0x00, 13,
288 8, 25, 42, 42, 42, 106880 }, 290 8, 25, 42, 42, 42, 106880 },
289 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */ 291 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
290 178200, 0x8e, 0x00, 14, 292 178200, 14, 0x00, 14,
291 8, 26, 43, 43, 43, 120240 }, 293 8, 26, 43, 43, 43, 120240 },
292 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */ 294 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
293 192100, 0x8f, 0x00, 15, 295 192100, 15, 0x00, 15,
294 8, 27, 44, 45, 45, 133600 }, 296 8, 27, 44, 45, 45, 133600 },
295 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */ 297 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
296 207000, 0x8f, 0x00, 15, 298 207000, 15, 0x00, 15,
297 8, 27, 44, 45, 45, 148400 }, 299 8, 27, 44, 45, 45, 148400 },
298 }, 300 },
299 50, /* probe interval */ 301 50, /* probe interval */
@@ -302,30 +304,31 @@ static const struct ath_rate_table ar5416_11ng_ratetable = {
302 304
303static const struct ath_rate_table ar5416_11a_ratetable = { 305static const struct ath_rate_table ar5416_11a_ratetable = {
304 8, 306 8,
307 0,
305 { 308 {
306 { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ 309 { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
307 5400, 0x0b, 0x00, (0x80|12), 310 5400, 0, 0x00, 12,
308 0, 0, 0 }, 311 0, 0, 0 },
309 { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ 312 { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
310 7800, 0x0f, 0x00, 18, 313 7800, 1, 0x00, 18,
311 0, 1, 0 }, 314 0, 1, 0 },
312 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ 315 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
313 10000, 0x0a, 0x00, (0x80|24), 316 10000, 2, 0x00, 24,
314 2, 2, 0 }, 317 2, 2, 0 },
315 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ 318 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
316 13900, 0x0e, 0x00, 36, 319 13900, 3, 0x00, 36,
317 2, 3, 0 }, 320 2, 3, 0 },
318 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ 321 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
319 17300, 0x09, 0x00, (0x80|48), 322 17300, 4, 0x00, 48,
320 4, 4, 0 }, 323 4, 4, 0 },
321 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ 324 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
322 23000, 0x0d, 0x00, 72, 325 23000, 5, 0x00, 72,
323 4, 5, 0 }, 326 4, 5, 0 },
324 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ 327 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
325 27400, 0x08, 0x00, 96, 328 27400, 6, 0x00, 96,
326 4, 6, 0 }, 329 4, 6, 0 },
327 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ 330 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
328 29300, 0x0c, 0x00, 108, 331 29300, 7, 0x00, 108,
329 4, 7, 0 }, 332 4, 7, 0 },
330 }, 333 },
331 50, /* probe interval */ 334 50, /* probe interval */
@@ -334,48 +337,63 @@ static const struct ath_rate_table ar5416_11a_ratetable = {
334 337
335static const struct ath_rate_table ar5416_11g_ratetable = { 338static const struct ath_rate_table ar5416_11g_ratetable = {
336 12, 339 12,
340 0,
337 { 341 {
338 { VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */ 342 { VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
339 900, 0x1b, 0x00, 2, 343 900, 0, 0x00, 2,
340 0, 0, 0 }, 344 0, 0, 0 },
341 { VALID, VALID, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */ 345 { VALID, VALID, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */
342 1900, 0x1a, 0x04, 4, 346 1900, 1, 0x04, 4,
343 1, 1, 0 }, 347 1, 1, 0 },
344 { VALID, VALID, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */ 348 { VALID, VALID, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */
345 4900, 0x19, 0x04, 11, 349 4900, 2, 0x04, 11,
346 2, 2, 0 }, 350 2, 2, 0 },
347 { VALID, VALID, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */ 351 { VALID, VALID, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */
348 8100, 0x18, 0x04, 22, 352 8100, 3, 0x04, 22,
349 3, 3, 0 }, 353 3, 3, 0 },
350 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */ 354 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
351 5400, 0x0b, 0x00, 12, 355 5400, 4, 0x00, 12,
352 4, 4, 0 }, 356 4, 4, 0 },
353 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */ 357 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
354 7800, 0x0f, 0x00, 18, 358 7800, 5, 0x00, 18,
355 4, 5, 0 }, 359 4, 5, 0 },
356 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */ 360 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
357 10000, 0x0a, 0x00, 24, 361 10000, 6, 0x00, 24,
358 6, 6, 0 }, 362 6, 6, 0 },
359 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */ 363 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
360 13900, 0x0e, 0x00, 36, 364 13900, 7, 0x00, 36,
361 6, 7, 0 }, 365 6, 7, 0 },
362 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */ 366 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
363 17300, 0x09, 0x00, 48, 367 17300, 8, 0x00, 48,
364 8, 8, 0 }, 368 8, 8, 0 },
365 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */ 369 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
366 23000, 0x0d, 0x00, 72, 370 23000, 9, 0x00, 72,
367 8, 9, 0 }, 371 8, 9, 0 },
368 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */ 372 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
369 27400, 0x08, 0x00, 96, 373 27400, 10, 0x00, 96,
370 8, 10, 0 }, 374 8, 10, 0 },
371 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */ 375 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
372 29300, 0x0c, 0x00, 108, 376 29300, 11, 0x00, 108,
373 8, 11, 0 }, 377 8, 11, 0 },
374 }, 378 },
375 50, /* probe interval */ 379 50, /* probe interval */
376 0, /* Phy rates allowed initially */ 380 0, /* Phy rates allowed initially */
377}; 381};
378 382
383static const struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX] = {
384 [ATH9K_MODE_11A] = &ar5416_11a_ratetable,
385 [ATH9K_MODE_11G] = &ar5416_11g_ratetable,
386 [ATH9K_MODE_11NA_HT20] = &ar5416_11na_ratetable,
387 [ATH9K_MODE_11NG_HT20] = &ar5416_11ng_ratetable,
388 [ATH9K_MODE_11NA_HT40PLUS] = &ar5416_11na_ratetable,
389 [ATH9K_MODE_11NA_HT40MINUS] = &ar5416_11na_ratetable,
390 [ATH9K_MODE_11NG_HT40PLUS] = &ar5416_11ng_ratetable,
391 [ATH9K_MODE_11NG_HT40MINUS] = &ar5416_11ng_ratetable,
392};
393
394static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
395 struct ieee80211_tx_rate *rate);
396
379static inline int8_t median(int8_t a, int8_t b, int8_t c) 397static inline int8_t median(int8_t a, int8_t b, int8_t c)
380{ 398{
381 if (a >= b) { 399 if (a >= b) {
@@ -534,7 +552,7 @@ static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv,
534 * capflag matches one of the validity 552 * capflag matches one of the validity
535 * (VALID/VALID_20/VALID_40) flags */ 553 * (VALID/VALID_20/VALID_40) flags */
536 554
537 if (((rate & 0x7F) == (dot11rate & 0x7F)) && 555 if ((rate == dot11rate) &&
538 ((valid & WLAN_RC_CAP_MODE(capflag)) == 556 ((valid & WLAN_RC_CAP_MODE(capflag)) ==
539 WLAN_RC_CAP_MODE(capflag)) && 557 WLAN_RC_CAP_MODE(capflag)) &&
540 !WLAN_RC_PHY_HT(phy)) { 558 !WLAN_RC_PHY_HT(phy)) {
@@ -576,8 +594,7 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv,
576 u8 rate = rateset->rs_rates[i]; 594 u8 rate = rateset->rs_rates[i];
577 u8 dot11rate = rate_table->info[j].dot11rate; 595 u8 dot11rate = rate_table->info[j].dot11rate;
578 596
579 if (((rate & 0x7F) != (dot11rate & 0x7F)) || 597 if ((rate != dot11rate) || !WLAN_RC_PHY_HT(phy) ||
580 !WLAN_RC_PHY_HT(phy) ||
581 !WLAN_RC_PHY_HT_VALID(valid, capflag)) 598 !WLAN_RC_PHY_HT_VALID(valid, capflag))
582 continue; 599 continue;
583 600
@@ -696,18 +713,20 @@ static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table,
696 u8 tries, u8 rix, int rtsctsenable) 713 u8 tries, u8 rix, int rtsctsenable)
697{ 714{
698 rate->count = tries; 715 rate->count = tries;
699 rate->idx = rix; 716 rate->idx = rate_table->info[rix].ratecode;
700 717
701 if (txrc->short_preamble) 718 if (txrc->short_preamble)
702 rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE; 719 rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
703 if (txrc->rts || rtsctsenable) 720 if (txrc->rts || rtsctsenable)
704 rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS; 721 rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
705 if (WLAN_RC_PHY_40(rate_table->info[rix].phy)) 722
706 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; 723 if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) {
707 if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy))
708 rate->flags |= IEEE80211_TX_RC_SHORT_GI;
709 if (WLAN_RC_PHY_HT(rate_table->info[rix].phy))
710 rate->flags |= IEEE80211_TX_RC_MCS; 724 rate->flags |= IEEE80211_TX_RC_MCS;
725 if (WLAN_RC_PHY_40(rate_table->info[rix].phy))
726 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
727 if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy))
728 rate->flags |= IEEE80211_TX_RC_SHORT_GI;
729 }
711} 730}
712 731
713static void ath_rc_rate_set_rtscts(struct ath_softc *sc, 732static void ath_rc_rate_set_rtscts(struct ath_softc *sc,
@@ -720,7 +739,7 @@ static void ath_rc_rate_set_rtscts(struct ath_softc *sc,
720 /* get the cix for the lowest valid rix */ 739 /* get the cix for the lowest valid rix */
721 for (i = 3; i >= 0; i--) { 740 for (i = 3; i >= 0; i--) {
722 if (rates[i].count && (rates[i].idx >= 0)) { 741 if (rates[i].count && (rates[i].idx >= 0)) {
723 rix = rates[i].idx; 742 rix = ath_rc_get_rateindex(rate_table, &rates[i]);
724 break; 743 break;
725 } 744 }
726 } 745 }
@@ -1080,15 +1099,19 @@ static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
1080{ 1099{
1081 int rix; 1100 int rix;
1082 1101
1102 if (!(rate->flags & IEEE80211_TX_RC_MCS))
1103 return rate->idx;
1104
1105 rix = rate->idx + rate_table->mcs_start;
1083 if ((rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) && 1106 if ((rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
1084 (rate->flags & IEEE80211_TX_RC_SHORT_GI)) 1107 (rate->flags & IEEE80211_TX_RC_SHORT_GI))
1085 rix = rate_table->info[rate->idx].ht_index; 1108 rix = rate_table->info[rix].ht_index;
1086 else if (rate->flags & IEEE80211_TX_RC_SHORT_GI) 1109 else if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
1087 rix = rate_table->info[rate->idx].sgi_index; 1110 rix = rate_table->info[rix].sgi_index;
1088 else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) 1111 else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
1089 rix = rate_table->info[rate->idx].cw40index; 1112 rix = rate_table->info[rix].cw40index;
1090 else 1113 else
1091 rix = rate_table->info[rate->idx].base_index; 1114 rix = rate_table->info[rix].base_index;
1092 1115
1093 return rix; 1116 return rix;
1094} 1117}
@@ -1183,7 +1206,9 @@ struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
1183 1206
1184 ath_print(common, ATH_DBG_CONFIG, 1207 ath_print(common, ATH_DBG_CONFIG,
1185 "Choosing rate table for mode: %d\n", mode); 1208 "Choosing rate table for mode: %d\n", mode);
1186 return sc->hw_rate_table[mode]; 1209
1210 sc->cur_rate_mode = mode;
1211 return hw_rate_table[mode];
1187} 1212}
1188 1213
1189static void ath_rc_init(struct ath_softc *sc, 1214static void ath_rc_init(struct ath_softc *sc,
@@ -1197,12 +1222,6 @@ static void ath_rc_init(struct ath_softc *sc,
1197 u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; 1222 u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates;
1198 u8 i, j, k, hi = 0, hthi = 0; 1223 u8 i, j, k, hi = 0, hthi = 0;
1199 1224
1200 if (!rate_table) {
1201 ath_print(common, ATH_DBG_FATAL,
1202 "Rate table not initialized\n");
1203 return;
1204 }
1205
1206 /* Initial rate table size. Will change depending 1225 /* Initial rate table size. Will change depending
1207 * on the working rate set */ 1226 * on the working rate set */
1208 ath_rc_priv->rate_table_size = RATE_TABLE_SIZE; 1227 ath_rc_priv->rate_table_size = RATE_TABLE_SIZE;
@@ -1357,7 +1376,8 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1357 } 1376 }
1358 } 1377 }
1359 1378
1360 ath_debug_stat_rc(sc, skb); 1379 ath_debug_stat_rc(sc, ath_rc_get_rateindex(sc->cur_rate_table,
1380 &tx_info->status.rates[final_ts_idx]));
1361} 1381}
1362 1382
1363static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband, 1383static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
@@ -1365,7 +1385,7 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
1365{ 1385{
1366 struct ath_softc *sc = priv; 1386 struct ath_softc *sc = priv;
1367 struct ath_rate_priv *ath_rc_priv = priv_sta; 1387 struct ath_rate_priv *ath_rc_priv = priv_sta;
1368 const struct ath_rate_table *rate_table = NULL; 1388 const struct ath_rate_table *rate_table;
1369 bool is_cw40, is_sgi40; 1389 bool is_cw40, is_sgi40;
1370 int i, j = 0; 1390 int i, j = 0;
1371 1391
@@ -1397,11 +1417,9 @@ static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
1397 (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) || 1417 (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) ||
1398 (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)) { 1418 (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)) {
1399 rate_table = ath_choose_rate_table(sc, sband->band, 1419 rate_table = ath_choose_rate_table(sc, sband->band,
1400 sta->ht_cap.ht_supported, 1420 sta->ht_cap.ht_supported, is_cw40);
1401 is_cw40); 1421 } else {
1402 } else if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) { 1422 rate_table = hw_rate_table[sc->cur_rate_mode];
1403 /* cur_rate_table would be set on init through config() */
1404 rate_table = sc->cur_rate_table;
1405 } 1423 }
1406 1424
1407 ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi40); 1425 ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi40);
@@ -1445,6 +1463,7 @@ static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
1445 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG, 1463 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
1446 "Operating HT Bandwidth changed to: %d\n", 1464 "Operating HT Bandwidth changed to: %d\n",
1447 sc->hw->conf.channel_type); 1465 sc->hw->conf.channel_type);
1466 sc->cur_rate_table = hw_rate_table[sc->cur_rate_mode];
1448 } 1467 }
1449 } 1468 }
1450} 1469}
@@ -1497,26 +1516,6 @@ static struct rate_control_ops ath_rate_ops = {
1497 .free_sta = ath_rate_free_sta, 1516 .free_sta = ath_rate_free_sta,
1498}; 1517};
1499 1518
1500void ath_rate_attach(struct ath_softc *sc)
1501{
1502 sc->hw_rate_table[ATH9K_MODE_11A] =
1503 &ar5416_11a_ratetable;
1504 sc->hw_rate_table[ATH9K_MODE_11G] =
1505 &ar5416_11g_ratetable;
1506 sc->hw_rate_table[ATH9K_MODE_11NA_HT20] =
1507 &ar5416_11na_ratetable;
1508 sc->hw_rate_table[ATH9K_MODE_11NG_HT20] =
1509 &ar5416_11ng_ratetable;
1510 sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] =
1511 &ar5416_11na_ratetable;
1512 sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] =
1513 &ar5416_11na_ratetable;
1514 sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] =
1515 &ar5416_11ng_ratetable;
1516 sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] =
1517 &ar5416_11ng_ratetable;
1518}
1519
1520int ath_rate_control_register(void) 1519int ath_rate_control_register(void)
1521{ 1520{
1522 return ieee80211_rate_control_register(&ath_rate_ops); 1521 return ieee80211_rate_control_register(&ath_rate_ops);