OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From: Felix Fietkau <nbd@nbd.name> |
2 | Date: Sat, 10 Feb 2018 12:45:47 +0100 |
||
3 | Subject: [PATCH] mac80211: minstrel: reduce minstrel_mcs_groups size |
||
4 | |||
5 | By storing a shift value for all duration values of a group, we can |
||
6 | reduce precision by a neglegible amount to make it fit into a u16 value. |
||
7 | This improves cache footprint and reduces size: |
||
8 | |||
9 | Before: |
||
10 | text data bss dec hex filename |
||
11 | 10024 116 0 10140 279c rc80211_minstrel_ht.o |
||
12 | |||
13 | After: |
||
14 | text data bss dec hex filename |
||
15 | 9368 116 0 9484 250c rc80211_minstrel_ht.o |
||
16 | |||
17 | Signed-off-by: Felix Fietkau <nbd@nbd.name> |
||
18 | --- |
||
19 | |||
20 | --- a/net/mac80211/rc80211_minstrel_ht.c |
||
21 | +++ b/net/mac80211/rc80211_minstrel_ht.c |
||
22 | @@ -52,22 +52,23 @@ |
||
23 | _streams - 1 |
||
24 | |||
25 | /* MCS rate information for an MCS group */ |
||
26 | -#define MCS_GROUP(_streams, _sgi, _ht40) \ |
||
27 | +#define MCS_GROUP(_streams, _sgi, _ht40, _s) \ |
||
28 | [GROUP_IDX(_streams, _sgi, _ht40)] = { \ |
||
29 | .streams = _streams, \ |
||
30 | + .shift = _s, \ |
||
31 | .flags = \ |
||
32 | IEEE80211_TX_RC_MCS | \ |
||
33 | (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \ |
||
34 | (_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \ |
||
35 | .duration = { \ |
||
36 | - MCS_DURATION(_streams, _sgi, _ht40 ? 54 : 26), \ |
||
37 | - MCS_DURATION(_streams, _sgi, _ht40 ? 108 : 52), \ |
||
38 | - MCS_DURATION(_streams, _sgi, _ht40 ? 162 : 78), \ |
||
39 | - MCS_DURATION(_streams, _sgi, _ht40 ? 216 : 104), \ |
||
40 | - MCS_DURATION(_streams, _sgi, _ht40 ? 324 : 156), \ |
||
41 | - MCS_DURATION(_streams, _sgi, _ht40 ? 432 : 208), \ |
||
42 | - MCS_DURATION(_streams, _sgi, _ht40 ? 486 : 234), \ |
||
43 | - MCS_DURATION(_streams, _sgi, _ht40 ? 540 : 260) \ |
||
44 | + MCS_DURATION(_streams, _sgi, _ht40 ? 54 : 26) >> _s, \ |
||
45 | + MCS_DURATION(_streams, _sgi, _ht40 ? 108 : 52) >> _s, \ |
||
46 | + MCS_DURATION(_streams, _sgi, _ht40 ? 162 : 78) >> _s, \ |
||
47 | + MCS_DURATION(_streams, _sgi, _ht40 ? 216 : 104) >> _s, \ |
||
48 | + MCS_DURATION(_streams, _sgi, _ht40 ? 324 : 156) >> _s, \ |
||
49 | + MCS_DURATION(_streams, _sgi, _ht40 ? 432 : 208) >> _s, \ |
||
50 | + MCS_DURATION(_streams, _sgi, _ht40 ? 486 : 234) >> _s, \ |
||
51 | + MCS_DURATION(_streams, _sgi, _ht40 ? 540 : 260) >> _s \ |
||
52 | } \ |
||
53 | } |
||
54 | |||
55 | @@ -80,9 +81,10 @@ |
||
56 | #define BW2VBPS(_bw, r3, r2, r1) \ |
||
57 | (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1) |
||
58 | |||
59 | -#define VHT_GROUP(_streams, _sgi, _bw) \ |
||
60 | +#define VHT_GROUP(_streams, _sgi, _bw, _s) \ |
||
61 | [VHT_GROUP_IDX(_streams, _sgi, _bw)] = { \ |
||
62 | .streams = _streams, \ |
||
63 | + .shift = _s, \ |
||
64 | .flags = \ |
||
65 | IEEE80211_TX_RC_VHT_MCS | \ |
||
66 | (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \ |
||
67 | @@ -90,25 +92,25 @@ |
||
68 | _bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \ |
||
69 | .duration = { \ |
||
70 | MCS_DURATION(_streams, _sgi, \ |
||
71 | - BW2VBPS(_bw, 117, 54, 26)), \ |
||
72 | + BW2VBPS(_bw, 117, 54, 26)) >> _s, \ |
||
73 | MCS_DURATION(_streams, _sgi, \ |
||
74 | - BW2VBPS(_bw, 234, 108, 52)), \ |
||
75 | + BW2VBPS(_bw, 234, 108, 52)) >> _s, \ |
||
76 | MCS_DURATION(_streams, _sgi, \ |
||
77 | - BW2VBPS(_bw, 351, 162, 78)), \ |
||
78 | + BW2VBPS(_bw, 351, 162, 78)) >> _s, \ |
||
79 | MCS_DURATION(_streams, _sgi, \ |
||
80 | - BW2VBPS(_bw, 468, 216, 104)), \ |
||
81 | + BW2VBPS(_bw, 468, 216, 104)) >> _s, \ |
||
82 | MCS_DURATION(_streams, _sgi, \ |
||
83 | - BW2VBPS(_bw, 702, 324, 156)), \ |
||
84 | + BW2VBPS(_bw, 702, 324, 156)) >> _s, \ |
||
85 | MCS_DURATION(_streams, _sgi, \ |
||
86 | - BW2VBPS(_bw, 936, 432, 208)), \ |
||
87 | + BW2VBPS(_bw, 936, 432, 208)) >> _s, \ |
||
88 | MCS_DURATION(_streams, _sgi, \ |
||
89 | - BW2VBPS(_bw, 1053, 486, 234)), \ |
||
90 | + BW2VBPS(_bw, 1053, 486, 234)) >> _s, \ |
||
91 | MCS_DURATION(_streams, _sgi, \ |
||
92 | - BW2VBPS(_bw, 1170, 540, 260)), \ |
||
93 | + BW2VBPS(_bw, 1170, 540, 260)) >> _s, \ |
||
94 | MCS_DURATION(_streams, _sgi, \ |
||
95 | - BW2VBPS(_bw, 1404, 648, 312)), \ |
||
96 | + BW2VBPS(_bw, 1404, 648, 312)) >> _s, \ |
||
97 | MCS_DURATION(_streams, _sgi, \ |
||
98 | - BW2VBPS(_bw, 1560, 720, 346)) \ |
||
99 | + BW2VBPS(_bw, 1560, 720, 346)) >> _s \ |
||
100 | } \ |
||
101 | } |
||
102 | |||
103 | @@ -121,19 +123,20 @@ |
||
104 | (CCK_DURATION((_bitrate > 10 ? 20 : 10), false, 60) + \ |
||
105 | CCK_DURATION(_bitrate, _short, AVG_PKT_SIZE)) |
||
106 | |||
107 | -#define CCK_DURATION_LIST(_short) \ |
||
108 | - CCK_ACK_DURATION(10, _short), \ |
||
109 | - CCK_ACK_DURATION(20, _short), \ |
||
110 | - CCK_ACK_DURATION(55, _short), \ |
||
111 | - CCK_ACK_DURATION(110, _short) |
||
112 | +#define CCK_DURATION_LIST(_short, _s) \ |
||
113 | + CCK_ACK_DURATION(10, _short) >> _s, \ |
||
114 | + CCK_ACK_DURATION(20, _short) >> _s, \ |
||
115 | + CCK_ACK_DURATION(55, _short) >> _s, \ |
||
116 | + CCK_ACK_DURATION(110, _short) >> _s |
||
117 | |||
118 | -#define CCK_GROUP \ |
||
119 | +#define CCK_GROUP(_s) \ |
||
120 | [MINSTREL_CCK_GROUP] = { \ |
||
121 | .streams = 0, \ |
||
122 | .flags = 0, \ |
||
123 | + .shift = _s, \ |
||
124 | .duration = { \ |
||
125 | - CCK_DURATION_LIST(false), \ |
||
126 | - CCK_DURATION_LIST(true) \ |
||
127 | + CCK_DURATION_LIST(false, _s), \ |
||
128 | + CCK_DURATION_LIST(true, _s) \ |
||
129 | } \ |
||
130 | } |
||
131 | |||
132 | @@ -151,47 +154,47 @@ MODULE_PARM_DESC(minstrel_vht_only, |
||
133 | * BW -> SGI -> #streams |
||
134 | */ |
||
135 | const struct mcs_group minstrel_mcs_groups[] = { |
||
136 | - MCS_GROUP(1, 0, BW_20), |
||
137 | - MCS_GROUP(2, 0, BW_20), |
||
138 | - MCS_GROUP(3, 0, BW_20), |
||
139 | - |
||
140 | - MCS_GROUP(1, 1, BW_20), |
||
141 | - MCS_GROUP(2, 1, BW_20), |
||
142 | - MCS_GROUP(3, 1, BW_20), |
||
143 | - |
||
144 | - MCS_GROUP(1, 0, BW_40), |
||
145 | - MCS_GROUP(2, 0, BW_40), |
||
146 | - MCS_GROUP(3, 0, BW_40), |
||
147 | - |
||
148 | - MCS_GROUP(1, 1, BW_40), |
||
149 | - MCS_GROUP(2, 1, BW_40), |
||
150 | - MCS_GROUP(3, 1, BW_40), |
||
151 | - |
||
152 | - CCK_GROUP, |
||
153 | - |
||
154 | - VHT_GROUP(1, 0, BW_20), |
||
155 | - VHT_GROUP(2, 0, BW_20), |
||
156 | - VHT_GROUP(3, 0, BW_20), |
||
157 | - |
||
158 | - VHT_GROUP(1, 1, BW_20), |
||
159 | - VHT_GROUP(2, 1, BW_20), |
||
160 | - VHT_GROUP(3, 1, BW_20), |
||
161 | - |
||
162 | - VHT_GROUP(1, 0, BW_40), |
||
163 | - VHT_GROUP(2, 0, BW_40), |
||
164 | - VHT_GROUP(3, 0, BW_40), |
||
165 | - |
||
166 | - VHT_GROUP(1, 1, BW_40), |
||
167 | - VHT_GROUP(2, 1, BW_40), |
||
168 | - VHT_GROUP(3, 1, BW_40), |
||
169 | - |
||
170 | - VHT_GROUP(1, 0, BW_80), |
||
171 | - VHT_GROUP(2, 0, BW_80), |
||
172 | - VHT_GROUP(3, 0, BW_80), |
||
173 | - |
||
174 | - VHT_GROUP(1, 1, BW_80), |
||
175 | - VHT_GROUP(2, 1, BW_80), |
||
176 | - VHT_GROUP(3, 1, BW_80), |
||
177 | + MCS_GROUP(1, 0, BW_20, 5), |
||
178 | + MCS_GROUP(2, 0, BW_20, 4), |
||
179 | + MCS_GROUP(3, 0, BW_20, 4), |
||
180 | + |
||
181 | + MCS_GROUP(1, 1, BW_20, 5), |
||
182 | + MCS_GROUP(2, 1, BW_20, 4), |
||
183 | + MCS_GROUP(3, 1, BW_20, 4), |
||
184 | + |
||
185 | + MCS_GROUP(1, 0, BW_40, 4), |
||
186 | + MCS_GROUP(2, 0, BW_40, 4), |
||
187 | + MCS_GROUP(3, 0, BW_40, 4), |
||
188 | + |
||
189 | + MCS_GROUP(1, 1, BW_40, 4), |
||
190 | + MCS_GROUP(2, 1, BW_40, 4), |
||
191 | + MCS_GROUP(3, 1, BW_40, 4), |
||
192 | + |
||
193 | + CCK_GROUP(8), |
||
194 | + |
||
195 | + VHT_GROUP(1, 0, BW_20, 5), |
||
196 | + VHT_GROUP(2, 0, BW_20, 4), |
||
197 | + VHT_GROUP(3, 0, BW_20, 4), |
||
198 | + |
||
199 | + VHT_GROUP(1, 1, BW_20, 5), |
||
200 | + VHT_GROUP(2, 1, BW_20, 4), |
||
201 | + VHT_GROUP(3, 1, BW_20, 4), |
||
202 | + |
||
203 | + VHT_GROUP(1, 0, BW_40, 4), |
||
204 | + VHT_GROUP(2, 0, BW_40, 4), |
||
205 | + VHT_GROUP(3, 0, BW_40, 4), |
||
206 | + |
||
207 | + VHT_GROUP(1, 1, BW_40, 4), |
||
208 | + VHT_GROUP(2, 1, BW_40, 4), |
||
209 | + VHT_GROUP(3, 1, BW_40, 4), |
||
210 | + |
||
211 | + VHT_GROUP(1, 0, BW_80, 4), |
||
212 | + VHT_GROUP(2, 0, BW_80, 4), |
||
213 | + VHT_GROUP(3, 0, BW_80, 4), |
||
214 | + |
||
215 | + VHT_GROUP(1, 1, BW_80, 4), |
||
216 | + VHT_GROUP(2, 1, BW_80, 4), |
||
217 | + VHT_GROUP(3, 1, BW_80, 4), |
||
218 | }; |
||
219 | |||
220 | static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly; |
||
221 | @@ -307,7 +310,8 @@ minstrel_ht_get_tp_avg(struct minstrel_h |
||
222 | if (group != MINSTREL_CCK_GROUP) |
||
223 | nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); |
||
224 | |||
225 | - nsecs += minstrel_mcs_groups[group].duration[rate]; |
||
226 | + nsecs += minstrel_mcs_groups[group].duration[rate] << |
||
227 | + minstrel_mcs_groups[group].shift; |
||
228 | |||
229 | /* |
||
230 | * For the throughput calculation, limit the probability value to 90% to |
||
231 | @@ -755,12 +759,19 @@ minstrel_ht_tx_status(void *priv, struct |
||
232 | minstrel_ht_update_rates(mp, mi); |
||
233 | } |
||
234 | |||
235 | +static inline int |
||
236 | +minstrel_get_duration(int index) |
||
237 | +{ |
||
238 | + const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; |
||
239 | + unsigned int duration = group->duration[index % MCS_GROUP_RATES]; |
||
240 | + return duration << group->shift; |
||
241 | +} |
||
242 | + |
||
243 | static void |
||
244 | minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi, |
||
245 | int index) |
||
246 | { |
||
247 | struct minstrel_rate_stats *mrs; |
||
248 | - const struct mcs_group *group; |
||
249 | unsigned int tx_time, tx_time_rtscts, tx_time_data; |
||
250 | unsigned int cw = mp->cw_min; |
||
251 | unsigned int ctime = 0; |
||
252 | @@ -779,8 +790,7 @@ minstrel_calc_retransmit(struct minstrel |
||
253 | mrs->retry_count_rtscts = 2; |
||
254 | mrs->retry_updated = true; |
||
255 | |||
256 | - group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; |
||
257 | - tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len / 1000; |
||
258 | + tx_time_data = minstrel_get_duration(index) * ampdu_len / 1000; |
||
259 | |||
260 | /* Contention time for first 2 tries */ |
||
261 | ctime = (t_slot * cw) >> 1; |
||
262 | @@ -874,20 +884,24 @@ minstrel_ht_get_max_amsdu_len(struct min |
||
263 | int group = mi->max_prob_rate / MCS_GROUP_RATES; |
||
264 | const struct mcs_group *g = &minstrel_mcs_groups[group]; |
||
265 | int rate = mi->max_prob_rate % MCS_GROUP_RATES; |
||
266 | + unsigned int duration; |
||
267 | |||
268 | /* Disable A-MSDU if max_prob_rate is bad */ |
||
269 | if (mi->groups[group].rates[rate].prob_ewma < MINSTREL_FRAC(50, 100)) |
||
270 | return 1; |
||
271 | |||
272 | + duration = g->duration[rate]; |
||
273 | + duration <<= g->shift; |
||
274 | + |
||
275 | /* If the rate is slower than single-stream MCS1, make A-MSDU limit small */ |
||
276 | - if (g->duration[rate] > MCS_DURATION(1, 0, 52)) |
||
277 | + if (duration > MCS_DURATION(1, 0, 52)) |
||
278 | return 500; |
||
279 | |||
280 | /* |
||
281 | * If the rate is slower than single-stream MCS4, limit A-MSDU to usual |
||
282 | * data packet size |
||
283 | */ |
||
284 | - if (g->duration[rate] > MCS_DURATION(1, 0, 104)) |
||
285 | + if (duration > MCS_DURATION(1, 0, 104)) |
||
286 | return 1600; |
||
287 | |||
288 | /* |
||
289 | @@ -895,7 +909,7 @@ minstrel_ht_get_max_amsdu_len(struct min |
||
290 | * rate success probability is less than 75%, limit A-MSDU to twice the usual |
||
291 | * data packet size |
||
292 | */ |
||
293 | - if (g->duration[rate] > MCS_DURATION(1, 0, 260) || |
||
294 | + if (duration > MCS_DURATION(1, 0, 260) || |
||
295 | (minstrel_ht_get_prob_ewma(mi, mi->max_tp_rate[0]) < |
||
296 | MINSTREL_FRAC(75, 100))) |
||
297 | return 3200; |
||
298 | @@ -942,13 +956,6 @@ minstrel_ht_update_rates(struct minstrel |
||
299 | rate_control_set_rates(mp->hw, mi->sta, rates); |
||
300 | } |
||
301 | |||
302 | -static inline int |
||
303 | -minstrel_get_duration(int index) |
||
304 | -{ |
||
305 | - const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES]; |
||
306 | - return group->duration[index % MCS_GROUP_RATES]; |
||
307 | -} |
||
308 | - |
||
309 | static int |
||
310 | minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) |
||
311 | { |
||
312 | --- a/net/mac80211/rc80211_minstrel_ht.h |
||
313 | +++ b/net/mac80211/rc80211_minstrel_ht.h |
||
314 | @@ -33,9 +33,10 @@ |
||
315 | #define MCS_GROUP_RATES 10 |
||
316 | |||
317 | struct mcs_group { |
||
318 | - u32 flags; |
||
319 | - unsigned int streams; |
||
320 | - unsigned int duration[MCS_GROUP_RATES]; |
||
321 | + u16 flags; |
||
322 | + u8 streams; |
||
323 | + u8 shift; |
||
324 | + u16 duration[MCS_GROUP_RATES]; |
||
325 | }; |
||
326 | |||
327 | extern const struct mcs_group minstrel_mcs_groups[]; |
||
328 | --- a/net/mac80211/rc80211_minstrel_ht_debugfs.c |
||
329 | +++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c |
||
330 | @@ -58,6 +58,7 @@ minstrel_ht_stats_dump(struct minstrel_h |
||
331 | static const int bitrates[4] = { 10, 20, 55, 110 }; |
||
332 | int idx = i * MCS_GROUP_RATES + j; |
||
333 | unsigned int prob_ewmsd; |
||
334 | + unsigned int duration; |
||
335 | |||
336 | if (!(mi->supported[i] & BIT(j))) |
||
337 | continue; |
||
338 | @@ -95,7 +96,9 @@ minstrel_ht_stats_dump(struct minstrel_h |
||
339 | p += sprintf(p, " %3u ", idx); |
||
340 | |||
341 | /* tx_time[rate(i)] in usec */ |
||
342 | - tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000); |
||
343 | + duration = mg->duration[j]; |
||
344 | + duration <<= mg->shift; |
||
345 | + tx_time = DIV_ROUND_CLOSEST(duration, 1000); |
||
346 | p += sprintf(p, "%6u ", tx_time); |
||
347 | |||
348 | tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100)); |
||
349 | @@ -204,6 +207,7 @@ minstrel_ht_stats_csv_dump(struct minstr |
||
350 | static const int bitrates[4] = { 10, 20, 55, 110 }; |
||
351 | int idx = i * MCS_GROUP_RATES + j; |
||
352 | unsigned int prob_ewmsd; |
||
353 | + unsigned int duration; |
||
354 | |||
355 | if (!(mi->supported[i] & BIT(j))) |
||
356 | continue; |
||
357 | @@ -238,7 +242,10 @@ minstrel_ht_stats_csv_dump(struct minstr |
||
358 | } |
||
359 | |||
360 | p += sprintf(p, "%u,", idx); |
||
361 | - tx_time = DIV_ROUND_CLOSEST(mg->duration[j], 1000); |
||
362 | + |
||
363 | + duration = mg->duration[j]; |
||
364 | + duration <<= mg->shift; |
||
365 | + tx_time = DIV_ROUND_CLOSEST(duration, 1000); |
||
366 | p += sprintf(p, "%u,", tx_time); |
||
367 | |||
368 | tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100)); |