aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/rc80211_pid_algo.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/rc80211_pid_algo.c')
-rw-r--r--net/mac80211/rc80211_pid_algo.c76
1 files changed, 41 insertions, 35 deletions
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c
index c339571632b2..c5a607ca8440 100644
--- a/net/mac80211/rc80211_pid_algo.c
+++ b/net/mac80211/rc80211_pid_algo.c
@@ -102,23 +102,23 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
102 struct rc_pid_rateinfo *rinfo) 102 struct rc_pid_rateinfo *rinfo)
103{ 103{
104 struct ieee80211_sub_if_data *sdata; 104 struct ieee80211_sub_if_data *sdata;
105 struct ieee80211_hw_mode *mode; 105 struct ieee80211_supported_band *sband;
106 int newidx; 106 int newidx;
107 int maxrate; 107 int maxrate;
108 int back = (adj > 0) ? 1 : -1; 108 int back = (adj > 0) ? 1 : -1;
109 109
110 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); 110 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
111 111
112 mode = local->oper_hw_mode; 112 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
113 maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; 113 maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1;
114 114
115 newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate, 115 newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate_idx,
116 mode->num_rates); 116 sband->n_bitrates);
117 117
118 while (newidx != sta->txrate) { 118 while (newidx != sta->txrate_idx) {
119 if (rate_supported(sta, mode, newidx) && 119 if (rate_supported(sta, sband->band, newidx) &&
120 (maxrate < 0 || newidx <= maxrate)) { 120 (maxrate < 0 || newidx <= maxrate)) {
121 sta->txrate = newidx; 121 sta->txrate_idx = newidx;
122 break; 122 break;
123 } 123 }
124 124
@@ -128,7 +128,7 @@ static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
128#ifdef CONFIG_MAC80211_DEBUGFS 128#ifdef CONFIG_MAC80211_DEBUGFS
129 rate_control_pid_event_rate_change( 129 rate_control_pid_event_rate_change(
130 &((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events, 130 &((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events,
131 newidx, mode->rates[newidx].rate); 131 newidx, sband->bitrates[newidx].bitrate);
132#endif 132#endif
133} 133}
134 134
@@ -155,7 +155,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
155{ 155{
156 struct rc_pid_sta_info *spinfo = sta->rate_ctrl_priv; 156 struct rc_pid_sta_info *spinfo = sta->rate_ctrl_priv;
157 struct rc_pid_rateinfo *rinfo = pinfo->rinfo; 157 struct rc_pid_rateinfo *rinfo = pinfo->rinfo;
158 struct ieee80211_hw_mode *mode; 158 struct ieee80211_supported_band *sband;
159 u32 pf; 159 u32 pf;
160 s32 err_avg; 160 s32 err_avg;
161 u32 err_prop; 161 u32 err_prop;
@@ -164,7 +164,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
164 int adj, i, j, tmp; 164 int adj, i, j, tmp;
165 unsigned long period; 165 unsigned long period;
166 166
167 mode = local->oper_hw_mode; 167 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
168 spinfo = sta->rate_ctrl_priv; 168 spinfo = sta->rate_ctrl_priv;
169 169
170 /* In case nothing happened during the previous control interval, turn 170 /* In case nothing happened during the previous control interval, turn
@@ -190,18 +190,18 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,
190 spinfo->tx_num_failed = 0; 190 spinfo->tx_num_failed = 0;
191 191
192 /* If we just switched rate, update the rate behaviour info. */ 192 /* If we just switched rate, update the rate behaviour info. */
193 if (pinfo->oldrate != sta->txrate) { 193 if (pinfo->oldrate != sta->txrate_idx) {
194 194
195 i = rinfo[pinfo->oldrate].rev_index; 195 i = rinfo[pinfo->oldrate].rev_index;
196 j = rinfo[sta->txrate].rev_index; 196 j = rinfo[sta->txrate_idx].rev_index;
197 197
198 tmp = (pf - spinfo->last_pf); 198 tmp = (pf - spinfo->last_pf);
199 tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT); 199 tmp = RC_PID_DO_ARITH_RIGHT_SHIFT(tmp, RC_PID_ARITH_SHIFT);
200 200
201 rinfo[j].diff = rinfo[i].diff + tmp; 201 rinfo[j].diff = rinfo[i].diff + tmp;
202 pinfo->oldrate = sta->txrate; 202 pinfo->oldrate = sta->txrate_idx;
203 } 203 }
204 rate_control_pid_normalize(pinfo, mode->num_rates); 204 rate_control_pid_normalize(pinfo, sband->n_bitrates);
205 205
206 /* Compute the proportional, integral and derivative errors. */ 206 /* Compute the proportional, integral and derivative errors. */
207 err_prop = (pinfo->target << RC_PID_ARITH_SHIFT) - pf; 207 err_prop = (pinfo->target << RC_PID_ARITH_SHIFT) - pf;
@@ -242,8 +242,10 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev,
242 struct sta_info *sta; 242 struct sta_info *sta;
243 struct rc_pid_sta_info *spinfo; 243 struct rc_pid_sta_info *spinfo;
244 unsigned long period; 244 unsigned long period;
245 struct ieee80211_supported_band *sband;
245 246
246 sta = sta_info_get(local, hdr->addr1); 247 sta = sta_info_get(local, hdr->addr1);
248 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
247 249
248 if (!sta) 250 if (!sta)
249 return; 251 return;
@@ -251,13 +253,13 @@ static void rate_control_pid_tx_status(void *priv, struct net_device *dev,
251 /* Don't update the state if we're not controlling the rate. */ 253 /* Don't update the state if we're not controlling the rate. */
252 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); 254 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
253 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { 255 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) {
254 sta->txrate = sdata->bss->max_ratectrl_rateidx; 256 sta->txrate_idx = sdata->bss->max_ratectrl_rateidx;
255 return; 257 return;
256 } 258 }
257 259
258 /* Ignore all frames that were sent with a different rate than the rate 260 /* Ignore all frames that were sent with a different rate than the rate
259 * we currently advise mac80211 to use. */ 261 * we currently advise mac80211 to use. */
260 if (status->control.rate != &local->oper_hw_mode->rates[sta->txrate]) 262 if (status->control.tx_rate != &sband->bitrates[sta->txrate_idx])
261 goto ignore; 263 goto ignore;
262 264
263 spinfo = sta->rate_ctrl_priv; 265 spinfo = sta->rate_ctrl_priv;
@@ -304,7 +306,7 @@ ignore:
304} 306}
305 307
306static void rate_control_pid_get_rate(void *priv, struct net_device *dev, 308static void rate_control_pid_get_rate(void *priv, struct net_device *dev,
307 struct ieee80211_hw_mode *mode, 309 struct ieee80211_supported_band *sband,
308 struct sk_buff *skb, 310 struct sk_buff *skb,
309 struct rate_selection *sel) 311 struct rate_selection *sel)
310{ 312{
@@ -322,7 +324,7 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,
322 fc = le16_to_cpu(hdr->frame_control); 324 fc = le16_to_cpu(hdr->frame_control);
323 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || 325 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
324 is_multicast_ether_addr(hdr->addr1) || !sta) { 326 is_multicast_ether_addr(hdr->addr1) || !sta) {
325 sel->rate = rate_lowest(local, mode, sta); 327 sel->rate = rate_lowest(local, sband, sta);
326 if (sta) 328 if (sta)
327 sta_info_put(sta); 329 sta_info_put(sta);
328 return; 330 return;
@@ -331,23 +333,23 @@ static void rate_control_pid_get_rate(void *priv, struct net_device *dev,
331 /* If a forced rate is in effect, select it. */ 333 /* If a forced rate is in effect, select it. */
332 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 334 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
333 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) 335 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1)
334 sta->txrate = sdata->bss->force_unicast_rateidx; 336 sta->txrate_idx = sdata->bss->force_unicast_rateidx;
335 337
336 rateidx = sta->txrate; 338 rateidx = sta->txrate_idx;
337 339
338 if (rateidx >= mode->num_rates) 340 if (rateidx >= sband->n_bitrates)
339 rateidx = mode->num_rates - 1; 341 rateidx = sband->n_bitrates - 1;
340 342
341 sta->last_txrate = rateidx; 343 sta->last_txrate_idx = rateidx;
342 344
343 sta_info_put(sta); 345 sta_info_put(sta);
344 346
345 sel->rate = &mode->rates[rateidx]; 347 sel->rate = &sband->bitrates[rateidx];
346 348
347#ifdef CONFIG_MAC80211_DEBUGFS 349#ifdef CONFIG_MAC80211_DEBUGFS
348 rate_control_pid_event_tx_rate( 350 rate_control_pid_event_tx_rate(
349 &((struct rc_pid_sta_info *) sta->rate_ctrl_priv)->events, 351 &((struct rc_pid_sta_info *) sta->rate_ctrl_priv)->events,
350 rateidx, mode->rates[rateidx].rate); 352 rateidx, sband->bitrates[rateidx].bitrate);
351#endif 353#endif
352} 354}
353 355
@@ -359,28 +361,32 @@ static void rate_control_pid_rate_init(void *priv, void *priv_sta,
359 * as we need to have IEEE 802.1X auth succeed immediately after assoc.. 361 * as we need to have IEEE 802.1X auth succeed immediately after assoc..
360 * Until that method is implemented, we will use the lowest supported 362 * Until that method is implemented, we will use the lowest supported
361 * rate as a workaround. */ 363 * rate as a workaround. */
362 sta->txrate = rate_lowest_index(local, local->oper_hw_mode, sta); 364 struct ieee80211_supported_band *sband;
365
366 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
367 sta->txrate_idx = rate_lowest_index(local, sband, sta);
363} 368}
364 369
365static void *rate_control_pid_alloc(struct ieee80211_local *local) 370static void *rate_control_pid_alloc(struct ieee80211_local *local)
366{ 371{
367 struct rc_pid_info *pinfo; 372 struct rc_pid_info *pinfo;
368 struct rc_pid_rateinfo *rinfo; 373 struct rc_pid_rateinfo *rinfo;
369 struct ieee80211_hw_mode *mode; 374 struct ieee80211_supported_band *sband;
370 int i, j, tmp; 375 int i, j, tmp;
371 bool s; 376 bool s;
372#ifdef CONFIG_MAC80211_DEBUGFS 377#ifdef CONFIG_MAC80211_DEBUGFS
373 struct rc_pid_debugfs_entries *de; 378 struct rc_pid_debugfs_entries *de;
374#endif 379#endif
375 380
381 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
382
376 pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC); 383 pinfo = kmalloc(sizeof(*pinfo), GFP_ATOMIC);
377 if (!pinfo) 384 if (!pinfo)
378 return NULL; 385 return NULL;
379 386
380 /* We can safely assume that oper_hw_mode won't change unless we get 387 /* We can safely assume that sband won't change unless we get
381 * reinitialized. */ 388 * reinitialized. */
382 mode = local->oper_hw_mode; 389 rinfo = kmalloc(sizeof(*rinfo) * sband->n_bitrates, GFP_ATOMIC);
383 rinfo = kmalloc(sizeof(*rinfo) * mode->num_rates, GFP_ATOMIC);
384 if (!rinfo) { 390 if (!rinfo) {
385 kfree(pinfo); 391 kfree(pinfo);
386 return NULL; 392 return NULL;
@@ -389,7 +395,7 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local)
389 /* Sort the rates. This is optimized for the most common case (i.e. 395 /* Sort the rates. This is optimized for the most common case (i.e.
390 * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed 396 * almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed
391 * mapping too. */ 397 * mapping too. */
392 for (i = 0; i < mode->num_rates; i++) { 398 for (i = 0; i < sband->n_bitrates; i++) {
393 rinfo[i].index = i; 399 rinfo[i].index = i;
394 rinfo[i].rev_index = i; 400 rinfo[i].rev_index = i;
395 if (pinfo->fast_start) 401 if (pinfo->fast_start)
@@ -397,11 +403,11 @@ static void *rate_control_pid_alloc(struct ieee80211_local *local)
397 else 403 else
398 rinfo[i].diff = i * pinfo->norm_offset; 404 rinfo[i].diff = i * pinfo->norm_offset;
399 } 405 }
400 for (i = 1; i < mode->num_rates; i++) { 406 for (i = 1; i < sband->n_bitrates; i++) {
401 s = 0; 407 s = 0;
402 for (j = 0; j < mode->num_rates - i; j++) 408 for (j = 0; j < sband->n_bitrates - i; j++)
403 if (unlikely(mode->rates[rinfo[j].index].rate > 409 if (unlikely(sband->bitrates[rinfo[j].index].bitrate >
404 mode->rates[rinfo[j + 1].index].rate)) { 410 sband->bitrates[rinfo[j + 1].index].bitrate)) {
405 tmp = rinfo[j].index; 411 tmp = rinfo[j].index;
406 rinfo[j].index = rinfo[j + 1].index; 412 rinfo[j].index = rinfo[j + 1].index;
407 rinfo[j + 1].index = tmp; 413 rinfo[j + 1].index = tmp;