mac80211: adjust patches based on upstream feedback
[openwrt.git] / package / mac80211 / patches / 560-ath9k_rate_control_api.patch
1 --- a/drivers/net/wireless/ath/ath9k/rc.c
2 +++ b/drivers/net/wireless/ath/ath9k/rc.c
3 @@ -19,133 +19,92 @@
4
5 static const struct ath_rate_table ar5416_11na_ratetable = {
6 42,
7 + 8, /* MCS start */
8 {
9 { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
10 - 5400, 0x0b, 0x00, 12,
11 - 0, 0, 0, 0, 0, 0 },
12 + 5400, 0, 12, 0, 0, 0, 0, 0 },
13 { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
14 - 7800, 0x0f, 0x00, 18,
15 - 0, 1, 1, 1, 1, 0 },
16 + 7800, 1, 18, 0, 1, 1, 1, 1 },
17 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
18 - 10000, 0x0a, 0x00, 24,
19 - 2, 2, 2, 2, 2, 0 },
20 + 10000, 2, 24, 2, 2, 2, 2, 2 },
21 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
22 - 13900, 0x0e, 0x00, 36,
23 - 2, 3, 3, 3, 3, 0 },
24 + 13900, 3, 36, 2, 3, 3, 3, 3 },
25 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
26 - 17300, 0x09, 0x00, 48,
27 - 4, 4, 4, 4, 4, 0 },
28 + 17300, 4, 48, 4, 4, 4, 4, 4 },
29 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
30 - 23000, 0x0d, 0x00, 72,
31 - 4, 5, 5, 5, 5, 0 },
32 + 23000, 5, 72, 4, 5, 5, 5, 5 },
33 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
34 - 27400, 0x08, 0x00, 96,
35 - 4, 6, 6, 6, 6, 0 },
36 + 27400, 6, 96, 4, 6, 6, 6, 6 },
37 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
38 - 29300, 0x0c, 0x00, 108,
39 - 4, 7, 7, 7, 7, 0 },
40 + 29300, 7, 108, 4, 7, 7, 7, 7 },
41 { VALID_2040, VALID_2040, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
42 - 6400, 0x80, 0x00, 0,
43 - 0, 8, 24, 8, 24, 3216 },
44 + 6400, 0, 0, 0, 8, 24, 8, 24 },
45 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
46 - 12700, 0x81, 0x00, 1,
47 - 2, 9, 25, 9, 25, 6434 },
48 + 12700, 1, 1, 2, 9, 25, 9, 25 },
49 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
50 - 18800, 0x82, 0x00, 2,
51 - 2, 10, 26, 10, 26, 9650 },
52 + 18800, 2, 2, 2, 10, 26, 10, 26 },
53 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
54 - 25000, 0x83, 0x00, 3,
55 - 4, 11, 27, 11, 27, 12868 },
56 + 25000, 3, 3, 4, 11, 27, 11, 27 },
57 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
58 - 36700, 0x84, 0x00, 4,
59 - 4, 12, 28, 12, 28, 19304 },
60 + 36700, 4, 4, 4, 12, 28, 12, 28 },
61 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
62 - 48100, 0x85, 0x00, 5,
63 - 4, 13, 29, 13, 29, 25740 },
64 + 48100, 5, 5, 4, 13, 29, 13, 29 },
65 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
66 - 53500, 0x86, 0x00, 6,
67 - 4, 14, 30, 14, 30, 28956 },
68 + 53500, 6, 6, 4, 14, 30, 14, 30 },
69 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
70 - 59000, 0x87, 0x00, 7,
71 - 4, 15, 31, 15, 32, 32180 },
72 + 59000, 7, 7, 4, 15, 31, 15, 32 },
73 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
74 - 12700, 0x88, 0x00,
75 - 8, 3, 16, 33, 16, 33, 6430 },
76 + 12700, 8, 8, 3, 16, 33, 16, 33 },
77 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
78 - 24800, 0x89, 0x00, 9,
79 - 2, 17, 34, 17, 34, 12860 },
80 + 24800, 9, 9, 2, 17, 34, 17, 34 },
81 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
82 - 36600, 0x8a, 0x00, 10,
83 - 2, 18, 35, 18, 35, 19300 },
84 + 36600, 10, 10, 2, 18, 35, 18, 35 },
85 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
86 - 48100, 0x8b, 0x00, 11,
87 - 4, 19, 36, 19, 36, 25736 },
88 + 48100, 11, 11, 4, 19, 36, 19, 36 },
89 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
90 - 69500, 0x8c, 0x00, 12,
91 - 4, 20, 37, 20, 37, 38600 },
92 + 69500, 12, 12, 4, 20, 37, 20, 37 },
93 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
94 - 89500, 0x8d, 0x00, 13,
95 - 4, 21, 38, 21, 38, 51472 },
96 + 89500, 13, 13, 4, 21, 38, 21, 38 },
97 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
98 - 98900, 0x8e, 0x00, 14,
99 - 4, 22, 39, 22, 39, 57890 },
100 + 98900, 14, 14, 4, 22, 39, 22, 39 },
101 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
102 - 108300, 0x8f, 0x00, 15,
103 - 4, 23, 40, 23, 41, 64320 },
104 + 108300, 15, 15, 4, 23, 40, 23, 41 },
105 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
106 - 13200, 0x80, 0x00, 0,
107 - 0, 8, 24, 24, 24, 6684 },
108 + 13200, 0, 0, 0, 8, 24, 24, 24 },
109 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
110 - 25900, 0x81, 0x00, 1,
111 - 2, 9, 25, 25, 25, 13368 },
112 + 25900, 1, 1, 2, 9, 25, 25, 25 },
113 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
114 - 38600, 0x82, 0x00, 2,
115 - 2, 10, 26, 26, 26, 20052 },
116 + 38600, 2, 2, 2, 10, 26, 26, 26 },
117 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
118 - 49800, 0x83, 0x00, 3,
119 - 4, 11, 27, 27, 27, 26738 },
120 + 49800, 3, 3, 4, 11, 27, 27, 27 },
121 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
122 - 72200, 0x84, 0x00, 4,
123 - 4, 12, 28, 28, 28, 40104 },
124 + 72200, 4, 4, 4, 12, 28, 28, 28 },
125 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
126 - 92900, 0x85, 0x00, 5,
127 - 4, 13, 29, 29, 29, 53476 },
128 + 92900, 5, 5, 4, 13, 29, 29, 29 },
129 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
130 - 102700, 0x86, 0x00, 6,
131 - 4, 14, 30, 30, 30, 60156 },
132 + 102700, 6, 6, 4, 14, 30, 30, 30 },
133 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
134 - 112000, 0x87, 0x00, 7,
135 - 4, 15, 31, 32, 32, 66840 },
136 + 112000, 7, 7, 4, 15, 31, 32, 32 },
137 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
138 - 122000, 0x87, 0x00, 7,
139 - 4, 15, 31, 32, 32, 74200 },
140 + 122000, 7, 7, 4, 15, 31, 32, 32 },
141 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
142 - 25800, 0x88, 0x00, 8,
143 - 0, 16, 33, 33, 33, 13360 },
144 + 25800, 8, 8, 0, 16, 33, 33, 33 },
145 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
146 - 49800, 0x89, 0x00, 9,
147 - 2, 17, 34, 34, 34, 26720 },
148 + 49800, 9, 9, 2, 17, 34, 34, 34 },
149 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
150 - 71900, 0x8a, 0x00, 10,
151 - 2, 18, 35, 35, 35, 40080 },
152 + 71900, 10, 10, 2, 18, 35, 35, 35 },
153 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
154 - 92500, 0x8b, 0x00, 11,
155 - 4, 19, 36, 36, 36, 53440 },
156 + 92500, 11, 11, 4, 19, 36, 36, 36 },
157 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
158 - 130300, 0x8c, 0x00, 12,
159 - 4, 20, 37, 37, 37, 80160 },
160 + 130300, 12, 12, 4, 20, 37, 37, 37 },
161 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
162 - 162800, 0x8d, 0x00, 13,
163 - 4, 21, 38, 38, 38, 106880 },
164 + 162800, 13, 13, 4, 21, 38, 38, 38 },
165 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
166 - 178200, 0x8e, 0x00, 14,
167 - 4, 22, 39, 39, 39, 120240 },
168 + 178200, 14, 14, 4, 22, 39, 39, 39 },
169 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
170 - 192100, 0x8f, 0x00, 15,
171 - 4, 23, 40, 41, 41, 133600 },
172 + 192100, 15, 15, 4, 23, 40, 41, 41 },
173 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
174 - 207000, 0x8f, 0x00, 15,
175 - 4, 23, 40, 41, 41, 148400 },
176 + 207000, 15, 15, 4, 23, 40, 41, 41 },
177 },
178 50, /* probe interval */
179 WLAN_RC_HT_FLAG, /* Phy rates allowed initially */
180 @@ -156,177 +115,125 @@ static const struct ath_rate_table ar541
181
182 static const struct ath_rate_table ar5416_11ng_ratetable = {
183 46,
184 + 12, /* MCS start */
185 {
186 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
187 - 900, 0x1b, 0x00, 2,
188 - 0, 0, 0, 0, 0, 0 },
189 + 900, 0, 2, 0, 0, 0, 0, 0 },
190 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */
191 - 1900, 0x1a, 0x04, 4,
192 - 1, 1, 1, 1, 1, 0 },
193 + 1900, 1, 4, 1, 1, 1, 1, 1 },
194 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */
195 - 4900, 0x19, 0x04, 11,
196 - 2, 2, 2, 2, 2, 0 },
197 + 4900, 2, 11, 2, 2, 2, 2, 2 },
198 { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */
199 - 8100, 0x18, 0x04, 22,
200 - 3, 3, 3, 3, 3, 0 },
201 + 8100, 3, 22, 3, 3, 3, 3, 3 },
202 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
203 - 5400, 0x0b, 0x00, 12,
204 - 4, 4, 4, 4, 4, 0 },
205 + 5400, 4, 12, 4, 4, 4, 4, 4 },
206 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
207 - 7800, 0x0f, 0x00, 18,
208 - 4, 5, 5, 5, 5, 0 },
209 + 7800, 5, 18, 4, 5, 5, 5, 5 },
210 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
211 - 10100, 0x0a, 0x00, 24,
212 - 6, 6, 6, 6, 6, 0 },
213 + 10100, 6, 24, 6, 6, 6, 6, 6 },
214 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
215 - 14100, 0x0e, 0x00, 36,
216 - 6, 7, 7, 7, 7, 0 },
217 + 14100, 7, 36, 6, 7, 7, 7, 7 },
218 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
219 - 17700, 0x09, 0x00, 48,
220 - 8, 8, 8, 8, 8, 0 },
221 + 17700, 8, 48, 8, 8, 8, 8, 8 },
222 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
223 - 23700, 0x0d, 0x00, 72,
224 - 8, 9, 9, 9, 9, 0 },
225 + 23700, 9, 72, 8, 9, 9, 9, 9 },
226 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
227 - 27400, 0x08, 0x00, 96,
228 - 8, 10, 10, 10, 10, 0 },
229 + 27400, 10, 96, 8, 10, 10, 10, 10 },
230 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
231 - 30900, 0x0c, 0x00, 108,
232 - 8, 11, 11, 11, 11, 0 },
233 + 30900, 11, 108, 8, 11, 11, 11, 11 },
234 { INVALID, INVALID, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
235 - 6400, 0x80, 0x00, 0,
236 - 4, 12, 28, 12, 28, 3216 },
237 + 6400, 0, 0, 4, 12, 28, 12, 28 },
238 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
239 - 12700, 0x81, 0x00, 1,
240 - 6, 13, 29, 13, 29, 6434 },
241 + 12700, 1, 1, 6, 13, 29, 13, 29 },
242 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
243 - 18800, 0x82, 0x00, 2,
244 - 6, 14, 30, 14, 30, 9650 },
245 + 18800, 2, 2, 6, 14, 30, 14, 30 },
246 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
247 - 25000, 0x83, 0x00, 3,
248 - 8, 15, 31, 15, 31, 12868 },
249 + 25000, 3, 3, 8, 15, 31, 15, 31 },
250 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
251 - 36700, 0x84, 0x00, 4,
252 - 8, 16, 32, 16, 32, 19304 },
253 + 36700, 4, 4, 8, 16, 32, 16, 32 },
254 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
255 - 48100, 0x85, 0x00, 5,
256 - 8, 17, 33, 17, 33, 25740 },
257 + 48100, 5, 5, 8, 17, 33, 17, 33 },
258 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
259 - 53500, 0x86, 0x00, 6,
260 - 8, 18, 34, 18, 34, 28956 },
261 + 53500, 6, 6, 8, 18, 34, 18, 34 },
262 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
263 - 59000, 0x87, 0x00, 7,
264 - 8, 19, 35, 19, 36, 32180 },
265 + 59000, 7, 7, 8, 19, 35, 19, 36 },
266 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
267 - 12700, 0x88, 0x00, 8,
268 - 4, 20, 37, 20, 37, 6430 },
269 + 12700, 8, 8, 4, 20, 37, 20, 37 },
270 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
271 - 24800, 0x89, 0x00, 9,
272 - 6, 21, 38, 21, 38, 12860 },
273 + 24800, 9, 9, 6, 21, 38, 21, 38 },
274 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
275 - 36600, 0x8a, 0x00, 10,
276 - 6, 22, 39, 22, 39, 19300 },
277 + 36600, 10, 10, 6, 22, 39, 22, 39 },
278 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
279 - 48100, 0x8b, 0x00, 11,
280 - 8, 23, 40, 23, 40, 25736 },
281 + 48100, 11, 11, 8, 23, 40, 23, 40 },
282 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
283 - 69500, 0x8c, 0x00, 12,
284 - 8, 24, 41, 24, 41, 38600 },
285 + 69500, 12, 12, 8, 24, 41, 24, 41 },
286 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
287 - 89500, 0x8d, 0x00, 13,
288 - 8, 25, 42, 25, 42, 51472 },
289 + 89500, 13, 13, 8, 25, 42, 25, 42 },
290 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
291 - 98900, 0x8e, 0x00, 14,
292 - 8, 26, 43, 26, 44, 57890 },
293 + 98900, 14, 14, 8, 26, 43, 26, 44 },
294 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
295 - 108300, 0x8f, 0x00, 15,
296 - 8, 27, 44, 27, 45, 64320 },
297 + 108300, 15, 15, 8, 27, 44, 27, 45 },
298 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
299 - 13200, 0x80, 0x00, 0,
300 - 8, 12, 28, 28, 28, 6684 },
301 + 13200, 0, 0, 8, 12, 28, 28, 28 },
302 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
303 - 25900, 0x81, 0x00, 1,
304 - 8, 13, 29, 29, 29, 13368 },
305 + 25900, 1, 1, 8, 13, 29, 29, 29 },
306 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
307 - 38600, 0x82, 0x00, 2,
308 - 8, 14, 30, 30, 30, 20052 },
309 + 38600, 2, 2, 8, 14, 30, 30, 30 },
310 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
311 - 49800, 0x83, 0x00, 3,
312 - 8, 15, 31, 31, 31, 26738 },
313 + 49800, 3, 3, 8, 15, 31, 31, 31 },
314 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
315 - 72200, 0x84, 0x00, 4,
316 - 8, 16, 32, 32, 32, 40104 },
317 + 72200, 4, 4, 8, 16, 32, 32, 32 },
318 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
319 - 92900, 0x85, 0x00, 5,
320 - 8, 17, 33, 33, 33, 53476 },
321 + 92900, 5, 5, 8, 17, 33, 33, 33 },
322 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
323 - 102700, 0x86, 0x00, 6,
324 - 8, 18, 34, 34, 34, 60156 },
325 + 102700, 6, 6, 8, 18, 34, 34, 34 },
326 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
327 - 112000, 0x87, 0x00, 7,
328 - 8, 19, 35, 36, 36, 66840 },
329 + 112000, 7, 7, 8, 19, 35, 36, 36 },
330 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
331 - 122000, 0x87, 0x00, 7,
332 - 8, 19, 35, 36, 36, 74200 },
333 + 122000, 7, 7, 8, 19, 35, 36, 36 },
334 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
335 - 25800, 0x88, 0x00, 8,
336 - 8, 20, 37, 37, 37, 13360 },
337 + 25800, 8, 8, 8, 20, 37, 37, 37 },
338 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
339 - 49800, 0x89, 0x00, 9,
340 - 8, 21, 38, 38, 38, 26720 },
341 + 49800, 9, 9, 8, 21, 38, 38, 38 },
342 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
343 - 71900, 0x8a, 0x00, 10,
344 - 8, 22, 39, 39, 39, 40080 },
345 + 71900, 10, 10, 8, 22, 39, 39, 39 },
346 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
347 - 92500, 0x8b, 0x00, 11,
348 - 8, 23, 40, 40, 40, 53440 },
349 + 92500, 11, 11, 8, 23, 40, 40, 40 },
350 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
351 - 130300, 0x8c, 0x00, 12,
352 - 8, 24, 41, 41, 41, 80160 },
353 + 130300, 12, 12, 8, 24, 41, 41, 41 },
354 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
355 - 162800, 0x8d, 0x00, 13,
356 - 8, 25, 42, 42, 42, 106880 },
357 + 162800, 13, 13, 8, 25, 42, 42, 42 },
358 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
359 - 178200, 0x8e, 0x00, 14,
360 - 8, 26, 43, 43, 43, 120240 },
361 + 178200, 14, 14, 8, 26, 43, 43, 43 },
362 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
363 - 192100, 0x8f, 0x00, 15,
364 - 8, 27, 44, 45, 45, 133600 },
365 + 192100, 15, 15, 8, 27, 44, 45, 45 },
366 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
367 - 207000, 0x8f, 0x00, 15,
368 - 8, 27, 44, 45, 45, 148400 },
369 - },
370 + 207000, 15, 15, 8, 27, 44, 45, 45 },
371 + },
372 50, /* probe interval */
373 WLAN_RC_HT_FLAG, /* Phy rates allowed initially */
374 };
375
376 static const struct ath_rate_table ar5416_11a_ratetable = {
377 8,
378 + 0,
379 {
380 { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
381 - 5400, 0x0b, 0x00, (0x80|12),
382 - 0, 0, 0 },
383 + 5400, 0, 12, 0, 0, 0 },
384 { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
385 - 7800, 0x0f, 0x00, 18,
386 - 0, 1, 0 },
387 + 7800, 1, 18, 0, 1, 0 },
388 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
389 - 10000, 0x0a, 0x00, (0x80|24),
390 - 2, 2, 0 },
391 + 10000, 2, 24, 2, 2, 0 },
392 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
393 - 13900, 0x0e, 0x00, 36,
394 - 2, 3, 0 },
395 + 13900, 3, 36, 2, 3, 0 },
396 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
397 - 17300, 0x09, 0x00, (0x80|48),
398 - 4, 4, 0 },
399 + 17300, 4, 48, 4, 4, 0 },
400 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
401 - 23000, 0x0d, 0x00, 72,
402 - 4, 5, 0 },
403 + 23000, 5, 72, 4, 5, 0 },
404 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
405 - 27400, 0x08, 0x00, 96,
406 - 4, 6, 0 },
407 + 27400, 6, 96, 4, 6, 0 },
408 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
409 - 29300, 0x0c, 0x00, 108,
410 - 4, 7, 0 },
411 + 29300, 7, 108, 4, 7, 0 },
412 },
413 50, /* probe interval */
414 0, /* Phy rates allowed initially */
415 @@ -334,48 +241,51 @@ static const struct ath_rate_table ar541
416
417 static const struct ath_rate_table ar5416_11g_ratetable = {
418 12,
419 + 0,
420 {
421 { VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
422 - 900, 0x1b, 0x00, 2,
423 - 0, 0, 0 },
424 + 900, 0, 2, 0, 0, 0 },
425 { VALID, VALID, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */
426 - 1900, 0x1a, 0x04, 4,
427 - 1, 1, 0 },
428 + 1900, 1, 4, 1, 1, 0 },
429 { VALID, VALID, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */
430 - 4900, 0x19, 0x04, 11,
431 - 2, 2, 0 },
432 + 4900, 2, 11, 2, 2, 0 },
433 { VALID, VALID, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */
434 - 8100, 0x18, 0x04, 22,
435 - 3, 3, 0 },
436 + 8100, 3, 22, 3, 3, 0 },
437 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
438 - 5400, 0x0b, 0x00, 12,
439 - 4, 4, 0 },
440 + 5400, 4, 12, 4, 4, 0 },
441 { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
442 - 7800, 0x0f, 0x00, 18,
443 - 4, 5, 0 },
444 + 7800, 5, 18, 4, 5, 0 },
445 { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
446 - 10000, 0x0a, 0x00, 24,
447 - 6, 6, 0 },
448 + 10000, 6, 24, 6, 6, 0 },
449 { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
450 - 13900, 0x0e, 0x00, 36,
451 - 6, 7, 0 },
452 + 13900, 7, 36, 6, 7, 0 },
453 { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
454 - 17300, 0x09, 0x00, 48,
455 - 8, 8, 0 },
456 + 17300, 8, 48, 8, 8, 0 },
457 { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
458 - 23000, 0x0d, 0x00, 72,
459 - 8, 9, 0 },
460 + 23000, 9, 72, 8, 9, 0 },
461 { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
462 - 27400, 0x08, 0x00, 96,
463 - 8, 10, 0 },
464 + 27400, 10, 96, 8, 10, 0 },
465 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
466 - 29300, 0x0c, 0x00, 108,
467 - 8, 11, 0 },
468 + 29300, 11, 108, 8, 11, 0 },
469 },
470 50, /* probe interval */
471 0, /* Phy rates allowed initially */
472 };
473
474 +static const struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX] = {
475 + [ATH9K_MODE_11A] = &ar5416_11a_ratetable,
476 + [ATH9K_MODE_11G] = &ar5416_11g_ratetable,
477 + [ATH9K_MODE_11NA_HT20] = &ar5416_11na_ratetable,
478 + [ATH9K_MODE_11NG_HT20] = &ar5416_11ng_ratetable,
479 + [ATH9K_MODE_11NA_HT40PLUS] = &ar5416_11na_ratetable,
480 + [ATH9K_MODE_11NA_HT40MINUS] = &ar5416_11na_ratetable,
481 + [ATH9K_MODE_11NG_HT40PLUS] = &ar5416_11ng_ratetable,
482 + [ATH9K_MODE_11NG_HT40MINUS] = &ar5416_11ng_ratetable,
483 +};
484 +
485 +static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
486 + struct ieee80211_tx_rate *rate);
487 +
488 static inline int8_t median(int8_t a, int8_t b, int8_t c)
489 {
490 if (a >= b) {
491 @@ -534,7 +444,7 @@ static u8 ath_rc_setvalid_rates(struct a
492 * capflag matches one of the validity
493 * (VALID/VALID_20/VALID_40) flags */
494
495 - if (((rate & 0x7F) == (dot11rate & 0x7F)) &&
496 + if ((rate == dot11rate) &&
497 ((valid & WLAN_RC_CAP_MODE(capflag)) ==
498 WLAN_RC_CAP_MODE(capflag)) &&
499 !WLAN_RC_PHY_HT(phy)) {
500 @@ -576,8 +486,7 @@ static u8 ath_rc_setvalid_htrates(struct
501 u8 rate = rateset->rs_rates[i];
502 u8 dot11rate = rate_table->info[j].dot11rate;
503
504 - if (((rate & 0x7F) != (dot11rate & 0x7F)) ||
505 - !WLAN_RC_PHY_HT(phy) ||
506 + if ((rate != dot11rate) || !WLAN_RC_PHY_HT(phy) ||
507 !WLAN_RC_PHY_HT_VALID(valid, capflag))
508 continue;
509
510 @@ -696,18 +605,20 @@ static void ath_rc_rate_set_series(const
511 u8 tries, u8 rix, int rtsctsenable)
512 {
513 rate->count = tries;
514 - rate->idx = rix;
515 + rate->idx = rate_table->info[rix].ratecode;
516
517 if (txrc->short_preamble)
518 rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
519 if (txrc->rts || rtsctsenable)
520 rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
521 - if (WLAN_RC_PHY_40(rate_table->info[rix].phy))
522 - rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
523 - if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy))
524 - rate->flags |= IEEE80211_TX_RC_SHORT_GI;
525 - if (WLAN_RC_PHY_HT(rate_table->info[rix].phy))
526 +
527 + if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) {
528 rate->flags |= IEEE80211_TX_RC_MCS;
529 + if (WLAN_RC_PHY_40(rate_table->info[rix].phy))
530 + rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
531 + if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy))
532 + rate->flags |= IEEE80211_TX_RC_SHORT_GI;
533 + }
534 }
535
536 static void ath_rc_rate_set_rtscts(struct ath_softc *sc,
537 @@ -720,7 +631,7 @@ static void ath_rc_rate_set_rtscts(struc
538 /* get the cix for the lowest valid rix */
539 for (i = 3; i >= 0; i--) {
540 if (rates[i].count && (rates[i].idx >= 0)) {
541 - rix = rates[i].idx;
542 + rix = ath_rc_get_rateindex(rate_table, &rates[i]);
543 break;
544 }
545 }
546 @@ -1080,15 +991,19 @@ static int ath_rc_get_rateindex(const st
547 {
548 int rix;
549
550 + if (!(rate->flags & IEEE80211_TX_RC_MCS))
551 + return rate->idx;
552 +
553 + rix = rate->idx + rate_table->mcs_start;
554 if ((rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
555 (rate->flags & IEEE80211_TX_RC_SHORT_GI))
556 - rix = rate_table->info[rate->idx].ht_index;
557 + rix = rate_table->info[rix].ht_index;
558 else if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
559 - rix = rate_table->info[rate->idx].sgi_index;
560 + rix = rate_table->info[rix].sgi_index;
561 else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
562 - rix = rate_table->info[rate->idx].cw40index;
563 + rix = rate_table->info[rix].cw40index;
564 else
565 - rix = rate_table->info[rate->idx].base_index;
566 + rix = rate_table->info[rix].base_index;
567
568 return rix;
569 }
570 @@ -1183,7 +1098,9 @@ struct ath_rate_table *ath_choose_rate_t
571
572 ath_print(common, ATH_DBG_CONFIG,
573 "Choosing rate table for mode: %d\n", mode);
574 - return sc->hw_rate_table[mode];
575 +
576 + sc->cur_rate_mode = mode;
577 + return hw_rate_table[mode];
578 }
579
580 static void ath_rc_init(struct ath_softc *sc,
581 @@ -1197,12 +1114,6 @@ static void ath_rc_init(struct ath_softc
582 u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates;
583 u8 i, j, k, hi = 0, hthi = 0;
584
585 - if (!rate_table) {
586 - ath_print(common, ATH_DBG_FATAL,
587 - "Rate table not initialized\n");
588 - return;
589 - }
590 -
591 /* Initial rate table size. Will change depending
592 * on the working rate set */
593 ath_rc_priv->rate_table_size = RATE_TABLE_SIZE;
594 @@ -1357,7 +1268,8 @@ static void ath_tx_status(void *priv, st
595 }
596 }
597
598 - ath_debug_stat_rc(sc, skb);
599 + ath_debug_stat_rc(sc, ath_rc_get_rateindex(sc->cur_rate_table,
600 + &tx_info->status.rates[final_ts_idx]));
601 }
602
603 static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
604 @@ -1365,7 +1277,7 @@ static void ath_rate_init(void *priv, st
605 {
606 struct ath_softc *sc = priv;
607 struct ath_rate_priv *ath_rc_priv = priv_sta;
608 - const struct ath_rate_table *rate_table = NULL;
609 + const struct ath_rate_table *rate_table;
610 bool is_cw40, is_sgi40;
611 int i, j = 0;
612
613 @@ -1397,11 +1309,9 @@ static void ath_rate_init(void *priv, st
614 (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) ||
615 (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)) {
616 rate_table = ath_choose_rate_table(sc, sband->band,
617 - sta->ht_cap.ht_supported,
618 - is_cw40);
619 - } else if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
620 - /* cur_rate_table would be set on init through config() */
621 - rate_table = sc->cur_rate_table;
622 + sta->ht_cap.ht_supported, is_cw40);
623 + } else {
624 + rate_table = hw_rate_table[sc->cur_rate_mode];
625 }
626
627 ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi40);
628 @@ -1445,6 +1355,7 @@ static void ath_rate_update(void *priv,
629 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
630 "Operating HT Bandwidth changed to: %d\n",
631 sc->hw->conf.channel_type);
632 + sc->cur_rate_table = hw_rate_table[sc->cur_rate_mode];
633 }
634 }
635 }
636 @@ -1497,26 +1408,6 @@ static struct rate_control_ops ath_rate_
637 .free_sta = ath_rate_free_sta,
638 };
639
640 -void ath_rate_attach(struct ath_softc *sc)
641 -{
642 - sc->hw_rate_table[ATH9K_MODE_11A] =
643 - &ar5416_11a_ratetable;
644 - sc->hw_rate_table[ATH9K_MODE_11G] =
645 - &ar5416_11g_ratetable;
646 - sc->hw_rate_table[ATH9K_MODE_11NA_HT20] =
647 - &ar5416_11na_ratetable;
648 - sc->hw_rate_table[ATH9K_MODE_11NG_HT20] =
649 - &ar5416_11ng_ratetable;
650 - sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS] =
651 - &ar5416_11na_ratetable;
652 - sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS] =
653 - &ar5416_11na_ratetable;
654 - sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS] =
655 - &ar5416_11ng_ratetable;
656 - sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS] =
657 - &ar5416_11ng_ratetable;
658 -}
659 -
660 int ath_rate_control_register(void)
661 {
662 return ieee80211_rate_control_register(&ath_rate_ops);
663 --- a/drivers/net/wireless/ath/ath9k/xmit.c
664 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
665 @@ -70,6 +70,29 @@ static int ath_tx_num_badfrms(struct ath
666 static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds,
667 int nbad, int txok, bool update_rc);
668
669 +enum {
670 + MCS_DEFAULT,
671 + MCS_HT40,
672 + MCS_HT40_SGI,
673 +};
674 +
675 +static int ath_max_4ms_framelen[3][16] = {
676 + [MCS_DEFAULT] = {
677 + 3216, 6434, 9650, 12868, 19304, 25740, 28956, 32180,
678 + 6430, 12860, 19300, 25736, 38600, 51472, 57890, 64320,
679 + },
680 + [MCS_HT40] = {
681 + 6684, 13368, 20052, 26738, 40104, 53476, 60156, 66840,
682 + 13360, 26720, 40080, 53440, 80160, 106880, 120240, 133600,
683 + },
684 + [MCS_HT40_SGI] = {
685 + /* TODO: Only MCS 7 and 15 updated, recalculate the rest */
686 + 6684, 13368, 20052, 26738, 40104, 53476, 60156, 74200,
687 + 13360, 26720, 40080, 53440, 80160, 106880, 120240, 148400,
688 + }
689 +};
690 +
691 +
692 /*********************/
693 /* Aggregation logic */
694 /*********************/
695 @@ -459,7 +482,6 @@ static void ath_tx_complete_aggr(struct
696 static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
697 struct ath_atx_tid *tid)
698 {
699 - const struct ath_rate_table *rate_table = sc->cur_rate_table;
700 struct sk_buff *skb;
701 struct ieee80211_tx_info *tx_info;
702 struct ieee80211_tx_rate *rates;
703 @@ -480,12 +502,20 @@ static u32 ath_lookup_rate(struct ath_so
704
705 for (i = 0; i < 4; i++) {
706 if (rates[i].count) {
707 - if (!WLAN_RC_PHY_HT(rate_table->info[rates[i].idx].phy)) {
708 + int modeidx;
709 + if (!(rates[i].flags & IEEE80211_TX_RC_MCS)) {
710 legacy = 1;
711 break;
712 }
713
714 - frmlen = rate_table->info[rates[i].idx].max_4ms_framelen;
715 + if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI)
716 + modeidx = MCS_HT40_SGI;
717 + else if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
718 + modeidx = MCS_HT40;
719 + else
720 + modeidx = MCS_DEFAULT;
721 +
722 + frmlen = ath_max_4ms_framelen[modeidx][rates[i].idx];
723 max_4ms_framelen = min(max_4ms_framelen, frmlen);
724 }
725 }
726 @@ -523,12 +553,11 @@ static u32 ath_lookup_rate(struct ath_so
727 static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
728 struct ath_buf *bf, u16 frmlen)
729 {
730 - const struct ath_rate_table *rt = sc->cur_rate_table;
731 struct sk_buff *skb = bf->bf_mpdu;
732 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
733 u32 nsymbits, nsymbols;
734 u16 minlen;
735 - u8 rc, flags, rix;
736 + u8 flags, rix;
737 int width, half_gi, ndelim, mindelim;
738
739 /* Select standard number of delimiters based on frame length alone */
740 @@ -558,7 +587,6 @@ static int ath_compute_num_delims(struct
741
742 rix = tx_info->control.rates[0].idx;
743 flags = tx_info->control.rates[0].flags;
744 - rc = rt->info[rix].ratecode;
745 width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0;
746 half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0;
747
748 @@ -570,7 +598,7 @@ static int ath_compute_num_delims(struct
749 if (nsymbols == 0)
750 nsymbols = 1;
751
752 - nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width];
753 + nsymbits = bits_per_symbol[rix][width];
754 minlen = (nsymbols * nsymbits) / BITS_PER_BYTE;
755
756 if (frmlen < minlen) {
757 @@ -1430,22 +1458,14 @@ static int setup_tx_flags(struct ath_sof
758 static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
759 int width, int half_gi, bool shortPreamble)
760 {
761 - const struct ath_rate_table *rate_table = sc->cur_rate_table;
762 u32 nbits, nsymbits, duration, nsymbols;
763 - u8 rc;
764 int streams, pktlen;
765
766 pktlen = bf_isaggr(bf) ? bf->bf_al : bf->bf_frmlen;
767 - rc = rate_table->info[rix].ratecode;
768 -
769 - /* for legacy rates, use old function to compute packet duration */
770 - if (!IS_HT_RATE(rc))
771 - return ath9k_hw_computetxtime(sc->sc_ah, rate_table, pktlen,
772 - rix, shortPreamble);
773
774 /* find number of symbols: PLCP + data */
775 nbits = (pktlen << 3) + OFDM_PLCP_BITS;
776 - nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width];
777 + nsymbits = bits_per_symbol[rix][width];
778 nsymbols = (nbits + nsymbits - 1) / nsymbits;
779
780 if (!half_gi)
781 @@ -1454,7 +1474,7 @@ static u32 ath_pkt_duration(struct ath_s
782 duration = SYMBOL_TIME_HALFGI(nsymbols);
783
784 /* addup duration for legacy/ht training and signal fields */
785 - streams = HT_RC_2_STREAMS(rc);
786 + streams = HT_RC_2_STREAMS(rix);
787 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
788
789 return duration;
790 @@ -1463,11 +1483,11 @@ static u32 ath_pkt_duration(struct ath_s
791 static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
792 {
793 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
794 - const struct ath_rate_table *rt = sc->cur_rate_table;
795 struct ath9k_11n_rate_series series[4];
796 struct sk_buff *skb;
797 struct ieee80211_tx_info *tx_info;
798 struct ieee80211_tx_rate *rates;
799 + const struct ieee80211_rate *rate;
800 struct ieee80211_hdr *hdr;
801 int i, flags = 0;
802 u8 rix = 0, ctsrate = 0;
803 @@ -1486,11 +1506,10 @@ static void ath_buf_set_rate(struct ath_
804 * checking the BSS's global flag.
805 * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
806 */
807 + rate = ieee80211_get_rts_cts_rate(sc->hw, tx_info);
808 + ctsrate = rate->hw_value;
809 if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
810 - ctsrate = rt->info[tx_info->control.rts_cts_rate_idx].ratecode |
811 - rt->info[tx_info->control.rts_cts_rate_idx].short_preamble;
812 - else
813 - ctsrate = rt->info[tx_info->control.rts_cts_rate_idx].ratecode;
814 + ctsrate |= rate->hw_value_short;
815
816 /*
817 * ATH9K_TXDESC_RTSENA and ATH9K_TXDESC_CTSENA are mutually exclusive.
818 @@ -1513,6 +1532,9 @@ static void ath_buf_set_rate(struct ath_
819 flags &= ~(ATH9K_TXDESC_RTSENA);
820
821 for (i = 0; i < 4; i++) {
822 + bool is_40, is_sgi, is_sp;
823 + int phy;
824 +
825 if (!rates[i].count || (rates[i].idx < 0))
826 continue;
827
828 @@ -1520,12 +1542,6 @@ static void ath_buf_set_rate(struct ath_
829 series[i].Tries = rates[i].count;
830 series[i].ChSel = common->tx_chainmask;
831
832 - if (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
833 - series[i].Rate = rt->info[rix].ratecode |
834 - rt->info[rix].short_preamble;
835 - else
836 - series[i].Rate = rt->info[rix].ratecode;
837 -
838 if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS)
839 series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
840 if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
841 @@ -1533,10 +1549,36 @@ static void ath_buf_set_rate(struct ath_
842 if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI)
843 series[i].RateFlags |= ATH9K_RATESERIES_HALFGI;
844
845 - series[i].PktDuration = ath_pkt_duration(sc, rix, bf,
846 - (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) != 0,
847 - (rates[i].flags & IEEE80211_TX_RC_SHORT_GI),
848 - (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE));
849 + is_sgi = !!(rates[i].flags & IEEE80211_TX_RC_SHORT_GI);
850 + is_40 = !!(rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH);
851 + is_sp = !!(rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
852 +
853 + if (rates[i].flags & IEEE80211_TX_RC_MCS) {
854 + /* MCS rates */
855 + series[i].Rate = rix | 0x80;
856 + series[i].PktDuration = ath_pkt_duration(sc, rix, bf,
857 + is_40, is_sgi, is_sp);
858 + continue;
859 + }
860 +
861 + /* legcay rates */
862 + if ((tx_info->band == IEEE80211_BAND_2GHZ) &&
863 + !(rate->flags & IEEE80211_RATE_ERP_G))
864 + phy = WLAN_RC_PHY_CCK;
865 + else
866 + phy = WLAN_RC_PHY_OFDM;
867 +
868 + rate = &sc->sbands[tx_info->band].bitrates[rates[i].idx];
869 + series[i].Rate = rate->hw_value;
870 + if (rate->hw_value_short) {
871 + if (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
872 + series[i].Rate |= rate->hw_value_short;
873 + } else {
874 + is_sp = false;
875 + }
876 +
877 + series[i].PktDuration = ath9k_hw_computetxtime(sc->sc_ah,
878 + phy, rate->bitrate * 100, bf->bf_frmlen, rix, is_sp);
879 }
880
881 /* set dur_update_en for l-sig computation except for PS-Poll frames */
882 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
883 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
884 @@ -21,7 +21,6 @@
885 #include <linux/device.h>
886 #include <linux/leds.h>
887
888 -#include "rc.h"
889 #include "debug.h"
890 #include "common.h"
891
892 @@ -433,6 +432,7 @@ struct ath_led {
893 #define SC_OP_BT_PRIORITY_DETECTED BIT(21)
894
895 struct ath_wiphy;
896 +struct ath_rate_table;
897
898 struct ath_softc {
899 struct ieee80211_hw *hw;
900 @@ -477,9 +477,8 @@ struct ath_softc {
901 struct ath_rx rx;
902 struct ath_tx tx;
903 struct ath_beacon beacon;
904 - struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
905 - const struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
906 const struct ath_rate_table *cur_rate_table;
907 + enum wireless_mode cur_rate_mode;
908 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
909
910 struct ath_led radio_led;
911 --- a/drivers/net/wireless/ath/ath9k/main.c
912 +++ b/drivers/net/wireless/ath/ath9k/main.c
913 @@ -104,37 +104,71 @@ static struct ieee80211_channel ath9k_5g
914 CHAN5G(5825, 37), /* Channel 165 */
915 };
916
917 +static struct ieee80211_rate ath9k_legacy_rates[] = {
918 + { .bitrate = 10,
919 + .hw_value = 0x1b,
920 + .flags = 0 },
921 + { .bitrate = 20,
922 + .hw_value = 0x1a,
923 + .hw_value_short = 0x1a | 0x04,
924 + .flags = IEEE80211_RATE_SHORT_PREAMBLE },
925 + { .bitrate = 55,
926 + .hw_value = 0x19,
927 + .hw_value_short = 0x19 | 0x04,
928 + .flags = IEEE80211_RATE_SHORT_PREAMBLE },
929 + { .bitrate = 110,
930 + .hw_value = 0x18,
931 + .hw_value_short = 0x18 | 0x4,
932 + .flags = IEEE80211_RATE_SHORT_PREAMBLE },
933 + { .bitrate = 60,
934 + .hw_value = 0x0b,
935 + .flags = 0 },
936 + { .bitrate = 90,
937 + .hw_value = 0x0f,
938 + .flags = 0 },
939 + { .bitrate = 120,
940 + .hw_value = 0x0a,
941 + .flags = 0 },
942 + { .bitrate = 180,
943 + .hw_value = 0x0e,
944 + .flags = 0 },
945 + { .bitrate = 240,
946 + .hw_value = 0x09,
947 + .flags = 0 },
948 + { .bitrate = 360,
949 + .hw_value = 0x0d,
950 + .flags = 0 },
951 + { .bitrate = 480,
952 + .hw_value = 0x08,
953 + .flags = 0 },
954 + { .bitrate = 540,
955 + .hw_value = 0x0c,
956 + .flags = 0 },
957 +};
958 +
959 static void ath_cache_conf_rate(struct ath_softc *sc,
960 struct ieee80211_conf *conf)
961 {
962 switch (conf->channel->band) {
963 case IEEE80211_BAND_2GHZ:
964 if (conf_is_ht20(conf))
965 - sc->cur_rate_table =
966 - sc->hw_rate_table[ATH9K_MODE_11NG_HT20];
967 + sc->cur_rate_mode = ATH9K_MODE_11NG_HT20;
968 else if (conf_is_ht40_minus(conf))
969 - sc->cur_rate_table =
970 - sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS];
971 + sc->cur_rate_mode = ATH9K_MODE_11NG_HT40MINUS;
972 else if (conf_is_ht40_plus(conf))
973 - sc->cur_rate_table =
974 - sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS];
975 + sc->cur_rate_mode = ATH9K_MODE_11NG_HT40PLUS;
976 else
977 - sc->cur_rate_table =
978 - sc->hw_rate_table[ATH9K_MODE_11G];
979 + sc->cur_rate_mode = ATH9K_MODE_11G;
980 break;
981 case IEEE80211_BAND_5GHZ:
982 if (conf_is_ht20(conf))
983 - sc->cur_rate_table =
984 - sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
985 + sc->cur_rate_mode = ATH9K_MODE_11NA_HT20;
986 else if (conf_is_ht40_minus(conf))
987 - sc->cur_rate_table =
988 - sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS];
989 + sc->cur_rate_mode = ATH9K_MODE_11NA_HT40MINUS;
990 else if (conf_is_ht40_plus(conf))
991 - sc->cur_rate_table =
992 - sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS];
993 + sc->cur_rate_mode = ATH9K_MODE_11NA_HT40PLUS;
994 else
995 - sc->cur_rate_table =
996 - sc->hw_rate_table[ATH9K_MODE_11A];
997 + sc->cur_rate_mode = ATH9K_MODE_11A;
998 break;
999 default:
1000 BUG_ON(1);
1001 @@ -190,51 +224,6 @@ static u8 parse_mpdudensity(u8 mpdudensi
1002 }
1003 }
1004
1005 -static void ath_setup_rates(struct ath_softc *sc, enum ieee80211_band band)
1006 -{
1007 - const struct ath_rate_table *rate_table = NULL;
1008 - struct ieee80211_supported_band *sband;
1009 - struct ieee80211_rate *rate;
1010 - int i, maxrates;
1011 -
1012 - switch (band) {
1013 - case IEEE80211_BAND_2GHZ:
1014 - rate_table = sc->hw_rate_table[ATH9K_MODE_11G];
1015 - break;
1016 - case IEEE80211_BAND_5GHZ:
1017 - rate_table = sc->hw_rate_table[ATH9K_MODE_11A];
1018 - break;
1019 - default:
1020 - break;
1021 - }
1022 -
1023 - if (rate_table == NULL)
1024 - return;
1025 -
1026 - sband = &sc->sbands[band];
1027 - rate = sc->rates[band];
1028 -
1029 - if (rate_table->rate_cnt > ATH_RATE_MAX)
1030 - maxrates = ATH_RATE_MAX;
1031 - else
1032 - maxrates = rate_table->rate_cnt;
1033 -
1034 - for (i = 0; i < maxrates; i++) {
1035 - rate[i].bitrate = rate_table->info[i].ratekbps / 100;
1036 - rate[i].hw_value = rate_table->info[i].ratecode;
1037 - if (rate_table->info[i].short_preamble) {
1038 - rate[i].hw_value_short = rate_table->info[i].ratecode |
1039 - rate_table->info[i].short_preamble;
1040 - rate[i].flags = IEEE80211_RATE_SHORT_PREAMBLE;
1041 - }
1042 - sband->n_bitrates++;
1043 -
1044 - ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
1045 - "Rate: %2dMbps, ratecode: %2d\n",
1046 - rate[i].bitrate / 10, rate[i].hw_value);
1047 - }
1048 -}
1049 -
1050 static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc,
1051 struct ieee80211_hw *hw)
1052 {
1053 @@ -1707,12 +1696,6 @@ static int ath_init_softc(u16 devid, str
1054 /* default to MONITOR mode */
1055 sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR;
1056
1057 - /* Setup rate tables */
1058 -
1059 - ath_rate_attach(sc);
1060 - ath_setup_rates(sc, IEEE80211_BAND_2GHZ);
1061 - ath_setup_rates(sc, IEEE80211_BAND_5GHZ);
1062 -
1063 /*
1064 * Allocate hardware transmit queues: one queue for
1065 * beacon frames and one data queue for each QoS
1066 @@ -1833,19 +1816,22 @@ static int ath_init_softc(u16 devid, str
1067 /* setup channels and rates */
1068
1069 sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
1070 - sc->sbands[IEEE80211_BAND_2GHZ].bitrates =
1071 - sc->rates[IEEE80211_BAND_2GHZ];
1072 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
1073 sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
1074 ARRAY_SIZE(ath9k_2ghz_chantable);
1075 + sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
1076 + sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
1077 + ARRAY_SIZE(ath9k_legacy_rates);
1078
1079 if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
1080 sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable;
1081 - sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
1082 - sc->rates[IEEE80211_BAND_5GHZ];
1083 sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
1084 sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
1085 ARRAY_SIZE(ath9k_5ghz_chantable);
1086 + sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
1087 + ath9k_legacy_rates + 4;
1088 + sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
1089 + ARRAY_SIZE(ath9k_legacy_rates) - 4;
1090 }
1091
1092 switch (ah->btcoex_hw.scheme) {
1093 --- a/drivers/net/wireless/ath/ath9k/rc.h
1094 +++ b/drivers/net/wireless/ath/ath9k/rc.h
1095 @@ -104,6 +104,7 @@ enum {
1096 */
1097 struct ath_rate_table {
1098 int rate_cnt;
1099 + int mcs_start;
1100 struct {
1101 int valid;
1102 int valid_single_stream;
1103 @@ -111,14 +112,12 @@ struct ath_rate_table {
1104 u32 ratekbps;
1105 u32 user_ratekbps;
1106 u8 ratecode;
1107 - u8 short_preamble;
1108 u8 dot11rate;
1109 u8 ctrl_rate;
1110 u8 base_index;
1111 u8 cw40index;
1112 u8 sgi_index;
1113 u8 ht_index;
1114 - u32 max_4ms_framelen;
1115 } info[RATE_TABLE_SIZE];
1116 u32 probe_interval;
1117 u8 initial_ratemax;
1118 @@ -179,8 +178,6 @@ enum ath9k_internal_frame_type {
1119 ATH9K_INT_UNPAUSE
1120 };
1121
1122 -void ath_rate_attach(struct ath_softc *sc);
1123 -u8 ath_rate_findrateix(struct ath_softc *sc, u8 dot11_rate);
1124 int ath_rate_control_register(void);
1125 void ath_rate_control_unregister(void);
1126
1127 --- a/drivers/net/wireless/ath/ath9k/beacon.c
1128 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
1129 @@ -65,9 +65,9 @@ static void ath_beacon_setup(struct ath_
1130 struct ath_common *common = ath9k_hw_common(ah);
1131 struct ath_desc *ds;
1132 struct ath9k_11n_rate_series series[4];
1133 - const struct ath_rate_table *rt;
1134 int flags, antenna, ctsrate = 0, ctsduration = 0;
1135 - u8 rate;
1136 + struct ieee80211_supported_band *sband;
1137 + u8 rate = 0;
1138
1139 ds = bf->bf_desc;
1140 flags = ATH9K_TXDESC_NOACK;
1141 @@ -91,10 +91,10 @@ static void ath_beacon_setup(struct ath_
1142
1143 ds->ds_data = bf->bf_buf_addr;
1144
1145 - rt = sc->cur_rate_table;
1146 - rate = rt->info[0].ratecode;
1147 + sband = &sc->sbands[sc->hw->conf.channel->band];
1148 + rate = sband->bitrates[0].hw_value;
1149 if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
1150 - rate |= rt->info[0].short_preamble;
1151 + rate |= sband->bitrates[0].hw_value_short;
1152
1153 ath9k_hw_set11n_txdesc(ah, ds, skb->len + FCS_LEN,
1154 ATH9K_PKT_TYPE_BEACON,
1155 --- a/drivers/net/wireless/ath/ath9k/debug.h
1156 +++ b/drivers/net/wireless/ath/ath9k/debug.h
1157 @@ -18,6 +18,7 @@
1158 #define DEBUG_H
1159
1160 #include "hw.h"
1161 +#include "rc.h"
1162
1163 struct ath_txq;
1164 struct ath_buf;
1165 @@ -138,7 +139,7 @@ void ath9k_exit_debug(struct ath_hw *ah)
1166 int ath9k_debug_create_root(void);
1167 void ath9k_debug_remove_root(void);
1168 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
1169 -void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
1170 +void ath_debug_stat_rc(struct ath_softc *sc, int final_rate);
1171 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
1172 struct ath_buf *bf);
1173 void ath_debug_stat_retries(struct ath_softc *sc, int rix,
1174 --- a/drivers/net/wireless/ath/ath9k/debug.c
1175 +++ b/drivers/net/wireless/ath/ath9k/debug.c
1176 @@ -255,21 +255,11 @@ static const struct file_operations fops
1177 .owner = THIS_MODULE
1178 };
1179
1180 -void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb)
1181 +void ath_debug_stat_rc(struct ath_softc *sc, int final_rate)
1182 {
1183 - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1184 - struct ieee80211_tx_rate *rates = tx_info->status.rates;
1185 - int final_ts_idx = 0, idx, i;
1186 struct ath_rc_stats *stats;
1187
1188 - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
1189 - if (!rates[i].count)
1190 - break;
1191 -
1192 - final_ts_idx = i;
1193 - }
1194 - idx = rates[final_ts_idx].idx;
1195 - stats = &sc->debug.stats.rcstats[idx];
1196 + stats = &sc->debug.stats.rcstats[final_rate];
1197 stats->success++;
1198 }
1199
1200 --- a/drivers/net/wireless/ath/ath9k/hw.c
1201 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1202 @@ -149,22 +149,19 @@ bool ath9k_get_channel_edges(struct ath_
1203 }
1204
1205 u16 ath9k_hw_computetxtime(struct ath_hw *ah,
1206 - const struct ath_rate_table *rates,
1207 + u8 phy, int kbps,
1208 u32 frameLen, u16 rateix,
1209 bool shortPreamble)
1210 {
1211 u32 bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
1212 - u32 kbps;
1213 -
1214 - kbps = rates->info[rateix].ratekbps;
1215
1216 if (kbps == 0)
1217 return 0;
1218
1219 - switch (rates->info[rateix].phy) {
1220 + switch (phy) {
1221 case WLAN_RC_PHY_CCK:
1222 phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
1223 - if (shortPreamble && rates->info[rateix].short_preamble)
1224 + if (shortPreamble)
1225 phyTime >>= 1;
1226 numBits = frameLen << 3;
1227 txTime = CCK_SIFS_TIME + phyTime + ((numBits * 1000) / kbps);
1228 @@ -195,8 +192,7 @@ u16 ath9k_hw_computetxtime(struct ath_hw
1229 break;
1230 default:
1231 ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
1232 - "Unknown phy %u (rate ix %u)\n",
1233 - rates->info[rateix].phy, rateix);
1234 + "Unknown phy %u (rate ix %u)\n", phy, rateix);
1235 txTime = 0;
1236 break;
1237 }
1238 --- a/drivers/net/wireless/ath/ath9k/hw.h
1239 +++ b/drivers/net/wireless/ath/ath9k/hw.h
1240 @@ -670,7 +670,7 @@ bool ath9k_hw_wait(struct ath_hw *ah, u3
1241 u32 ath9k_hw_reverse_bits(u32 val, u32 n);
1242 bool ath9k_get_channel_edges(struct ath_hw *ah, u16 flags, u16 *low, u16 *high);
1243 u16 ath9k_hw_computetxtime(struct ath_hw *ah,
1244 - const struct ath_rate_table *rates,
1245 + u8 phy, int kbps,
1246 u32 frameLen, u16 rateix, bool shortPreamble);
1247 void ath9k_hw_get_channel_centers(struct ath_hw *ah,
1248 struct ath9k_channel *chan,
1249 --- a/drivers/net/wireless/ath/ath9k/mac.h
1250 +++ b/drivers/net/wireless/ath/ath9k/mac.h
1251 @@ -616,7 +616,6 @@ enum ath9k_cipher {
1252
1253 struct ath_hw;
1254 struct ath9k_channel;
1255 -struct ath_rate_table;
1256
1257 u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q);
1258 void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp);
This page took 0.124024 seconds and 5 git commands to generate.