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