aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2011-08-26 09:49:28 -0400
committerStanislaw Gruszka <sgruszka@redhat.com>2011-11-15 06:26:33 -0500
commit6ce1dc45304eece672a36241cda587ba056d2b1f (patch)
treec6a7837c8d6af9f932f7cde0d235e10c4fb4a205 /drivers/net/wireless/iwlegacy/iwl-3945-rs.c
parentebf0d90d12cf013019005a8ee7d1bc8599935356 (diff)
iwlegacy: s/window/win/
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/iwl-3945-rs.c')
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945-rs.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
index ebee6c350dbe..5c855e88b95e 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
@@ -131,24 +131,24 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band)
131 return tpt_table[index].index; 131 return tpt_table[index].index;
132} 132}
133 133
134static void il3945_clear_window(struct il3945_rate_scale_data *window) 134static void il3945_clear_win(struct il3945_rate_scale_data *win)
135{ 135{
136 window->data = 0; 136 win->data = 0;
137 window->success_counter = 0; 137 win->success_counter = 0;
138 window->success_ratio = -1; 138 win->success_ratio = -1;
139 window->counter = 0; 139 win->counter = 0;
140 window->average_tpt = IL_INVALID_VALUE; 140 win->average_tpt = IL_INVALID_VALUE;
141 window->stamp = 0; 141 win->stamp = 0;
142} 142}
143 143
144/** 144/**
145 * il3945_rate_scale_flush_windows - flush out the rate scale windows 145 * il3945_rate_scale_flush_wins - flush out the rate scale wins
146 * 146 *
147 * Returns the number of windows that have gathered data but were 147 * Returns the number of wins that have gathered data but were
148 * not flushed. If there were any that were not flushed, then 148 * not flushed. If there were any that were not flushed, then
149 * reschedule the rate flushing routine. 149 * reschedule the rate flushing routine.
150 */ 150 */
151static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) 151static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta)
152{ 152{
153 int unflushed = 0; 153 int unflushed = 0;
154 int i; 154 int i;
@@ -170,7 +170,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta)
170 D_RATE("flushing %d samples of rate " 170 D_RATE("flushing %d samples of rate "
171 "index %d\n", 171 "index %d\n",
172 rs_sta->win[i].counter, i); 172 rs_sta->win[i].counter, i);
173 il3945_clear_window(&rs_sta->win[i]); 173 il3945_clear_win(&rs_sta->win[i]);
174 } else 174 } else
175 unflushed++; 175 unflushed++;
176 spin_unlock_irqrestore(&rs_sta->lock, flags); 176 spin_unlock_irqrestore(&rs_sta->lock, flags);
@@ -193,7 +193,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data)
193 193
194 D_RATE("enter\n"); 194 D_RATE("enter\n");
195 195
196 unflushed = il3945_rate_scale_flush_windows(rs_sta); 196 unflushed = il3945_rate_scale_flush_wins(rs_sta);
197 197
198 spin_lock_irqsave(&rs_sta->lock, flags); 198 spin_lock_irqsave(&rs_sta->lock, flags);
199 199
@@ -248,14 +248,14 @@ static void il3945_bg_rate_scale_flush(unsigned long data)
248} 248}
249 249
250/** 250/**
251 * il3945_collect_tx_data - Update the success/failure sliding window 251 * il3945_collect_tx_data - Update the success/failure sliding win
252 * 252 *
253 * We keep a sliding window of the last 64 packets transmitted 253 * We keep a sliding win of the last 64 packets transmitted
254 * at this rate. window->data contains the bitmask of successful 254 * at this rate. win->data contains the bitmask of successful
255 * packets. 255 * packets.
256 */ 256 */
257static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, 257static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta,
258 struct il3945_rate_scale_data *window, 258 struct il3945_rate_scale_data *win,
259 int success, int retries, int index) 259 int success, int retries, int index)
260{ 260{
261 unsigned long flags; 261 unsigned long flags;
@@ -271,34 +271,34 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta,
271 271
272 /* 272 /*
273 * Keep track of only the latest 62 tx frame attempts in this rate's 273 * Keep track of only the latest 62 tx frame attempts in this rate's
274 * history window; anything older isn't really relevant any more. 274 * history win; anything older isn't really relevant any more.
275 * If we have filled up the sliding window, drop the oldest attempt; 275 * If we have filled up the sliding win, drop the oldest attempt;
276 * if the oldest attempt (highest bit in bitmap) shows "success", 276 * if the oldest attempt (highest bit in bitmap) shows "success",
277 * subtract "1" from the success counter (this is the main reason 277 * subtract "1" from the success counter (this is the main reason
278 * we keep these bitmaps!). 278 * we keep these bitmaps!).
279 * */ 279 * */
280 while (retries > 0) { 280 while (retries > 0) {
281 if (window->counter >= IL_RATE_MAX_WINDOW) { 281 if (win->counter >= IL_RATE_MAX_WINDOW) {
282 282
283 /* remove earliest */ 283 /* remove earliest */
284 window->counter = IL_RATE_MAX_WINDOW - 1; 284 win->counter = IL_RATE_MAX_WINDOW - 1;
285 285
286 if (window->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { 286 if (win->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) {
287 window->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); 287 win->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1));
288 window->success_counter--; 288 win->success_counter--;
289 } 289 }
290 } 290 }
291 291
292 /* Increment frames-attempted counter */ 292 /* Increment frames-attempted counter */
293 window->counter++; 293 win->counter++;
294 294
295 /* Shift bitmap by one frame (throw away oldest history), 295 /* Shift bitmap by one frame (throw away oldest history),
296 * OR in "1", and increment "success" if this 296 * OR in "1", and increment "success" if this
297 * frame was successful. */ 297 * frame was successful. */
298 window->data <<= 1; 298 win->data <<= 1;
299 if (success > 0) { 299 if (success > 0) {
300 window->success_counter++; 300 win->success_counter++;
301 window->data |= 0x1; 301 win->data |= 0x1;
302 success--; 302 success--;
303 } 303 }
304 304
@@ -306,24 +306,24 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta,
306 } 306 }
307 307
308 /* Calculate current success ratio, avoid divide-by-0! */ 308 /* Calculate current success ratio, avoid divide-by-0! */
309 if (window->counter > 0) 309 if (win->counter > 0)
310 window->success_ratio = 128 * (100 * window->success_counter) 310 win->success_ratio = 128 * (100 * win->success_counter)
311 / window->counter; 311 / win->counter;
312 else 312 else
313 window->success_ratio = IL_INVALID_VALUE; 313 win->success_ratio = IL_INVALID_VALUE;
314 314
315 fail_count = window->counter - window->success_counter; 315 fail_count = win->counter - win->success_counter;
316 316
317 /* Calculate average throughput, if we have enough history. */ 317 /* Calculate average throughput, if we have enough history. */
318 if (fail_count >= IL_RATE_MIN_FAILURE_TH || 318 if (fail_count >= IL_RATE_MIN_FAILURE_TH ||
319 window->success_counter >= IL_RATE_MIN_SUCCESS_TH) 319 win->success_counter >= IL_RATE_MIN_SUCCESS_TH)
320 window->average_tpt = ((window->success_ratio * 320 win->average_tpt = ((win->success_ratio *
321 rs_sta->expected_tpt[index] + 64) / 128); 321 rs_sta->expected_tpt[index] + 64) / 128);
322 else 322 else
323 window->average_tpt = IL_INVALID_VALUE; 323 win->average_tpt = IL_INVALID_VALUE;
324 324
325 /* Tag this window as having been updated */ 325 /* Tag this win as having been updated */
326 window->stamp = jiffies; 326 win->stamp = jiffies;
327 327
328 spin_unlock_irqrestore(&rs_sta->lock, flags); 328 spin_unlock_irqrestore(&rs_sta->lock, flags);
329 329
@@ -365,7 +365,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i
365 rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; 365 rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush;
366 366
367 for (i = 0; i < IL_RATE_COUNT_3945; i++) 367 for (i = 0; i < IL_RATE_COUNT_3945; i++)
368 il3945_clear_window(&rs_sta->win[i]); 368 il3945_clear_win(&rs_sta->win[i]);
369 369
370 /* TODO: what is a good starting rate for STA? About middle? Maybe not 370 /* TODO: what is a good starting rate for STA? About middle? Maybe not
371 * the lowest or the highest rate.. Could consider using RSSI from 371 * the lowest or the highest rate.. Could consider using RSSI from
@@ -484,7 +484,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
484 last_index = first_index; 484 last_index = first_index;
485 485
486 /* 486 /*
487 * Update the window for each rate. We determine which rates 487 * Update the win for each rate. We determine which rates
488 * were Tx'd based on the total number of retries vs. the number 488 * were Tx'd based on the total number of retries vs. the number
489 * of retries configured for each rate -- currently set to the 489 * of retries configured for each rate -- currently set to the
490 * il value 'retry_rate' vs. rate specific 490 * il value 'retry_rate' vs. rate specific
@@ -517,7 +517,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
517 } 517 }
518 518
519 519
520 /* Update the last index window with success/failure based on ACK */ 520 /* Update the last index win with success/failure based on ACK */
521 D_RATE("Update rate %d with %s.\n", 521 D_RATE("Update rate %d with %s.\n",
522 last_index, 522 last_index,
523 (info->flags & IEEE80211_TX_STAT_ACK) ? 523 (info->flags & IEEE80211_TX_STAT_ACK) ?
@@ -526,7 +526,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
526 &rs_sta->win[last_index], 526 &rs_sta->win[last_index],
527 info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); 527 info->flags & IEEE80211_TX_STAT_ACK, 1, last_index);
528 528
529 /* We updated the rate scale window -- if its been more than 529 /* We updated the rate scale win -- if its been more than
530 * flush_time since the last run, schedule the flush 530 * flush_time since the last run, schedule the flush
531 * again */ 531 * again */
532 spin_lock_irqsave(&rs_sta->lock, flags); 532 spin_lock_irqsave(&rs_sta->lock, flags);
@@ -636,7 +636,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
636 u16 high_low; 636 u16 high_low;
637 int index; 637 int index;
638 struct il3945_rs_sta *rs_sta = il_sta; 638 struct il3945_rs_sta *rs_sta = il_sta;
639 struct il3945_rate_scale_data *window = NULL; 639 struct il3945_rate_scale_data *win = NULL;
640 int current_tpt = IL_INVALID_VALUE; 640 int current_tpt = IL_INVALID_VALUE;
641 int low_tpt = IL_INVALID_VALUE; 641 int low_tpt = IL_INVALID_VALUE;
642 int high_tpt = IL_INVALID_VALUE; 642 int high_tpt = IL_INVALID_VALUE;
@@ -691,29 +691,29 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
691 index = max_rate_idx; 691 index = max_rate_idx;
692 } 692 }
693 693
694 window = &(rs_sta->win[index]); 694 win = &(rs_sta->win[index]);
695 695
696 fail_count = window->counter - window->success_counter; 696 fail_count = win->counter - win->success_counter;
697 697
698 if (fail_count < IL_RATE_MIN_FAILURE_TH && 698 if (fail_count < IL_RATE_MIN_FAILURE_TH &&
699 window->success_counter < IL_RATE_MIN_SUCCESS_TH) { 699 win->success_counter < IL_RATE_MIN_SUCCESS_TH) {
700 spin_unlock_irqrestore(&rs_sta->lock, flags); 700 spin_unlock_irqrestore(&rs_sta->lock, flags);
701 701
702 D_RATE("Invalid average_tpt on rate %d: " 702 D_RATE("Invalid average_tpt on rate %d: "
703 "counter: %d, success_counter: %d, " 703 "counter: %d, success_counter: %d, "
704 "expected_tpt is %sNULL\n", 704 "expected_tpt is %sNULL\n",
705 index, 705 index,
706 window->counter, 706 win->counter,
707 window->success_counter, 707 win->success_counter,
708 rs_sta->expected_tpt ? "not " : ""); 708 rs_sta->expected_tpt ? "not " : "");
709 709
710 /* Can't calculate this yet; not enough history */ 710 /* Can't calculate this yet; not enough history */
711 window->average_tpt = IL_INVALID_VALUE; 711 win->average_tpt = IL_INVALID_VALUE;
712 goto out; 712 goto out;
713 713
714 } 714 }
715 715
716 current_tpt = window->average_tpt; 716 current_tpt = win->average_tpt;
717 717
718 high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask, 718 high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask,
719 sband->band); 719 sband->band);
@@ -736,7 +736,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
736 scale_action = 0; 736 scale_action = 0;
737 737
738 /* Low success ratio , need to drop the rate */ 738 /* Low success ratio , need to drop the rate */
739 if (window->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { 739 if (win->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) {
740 D_RATE("decrease rate because of low success_ratio\n"); 740 D_RATE("decrease rate because of low success_ratio\n");
741 scale_action = -1; 741 scale_action = -1;
742 /* No throughput measured yet for adjacent rates, 742 /* No throughput measured yet for adjacent rates,
@@ -744,7 +744,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
744 } else if (low_tpt == IL_INVALID_VALUE && 744 } else if (low_tpt == IL_INVALID_VALUE &&
745 high_tpt == IL_INVALID_VALUE) { 745 high_tpt == IL_INVALID_VALUE) {
746 746
747 if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) 747 if (high != IL_RATE_INVALID && win->success_ratio >= IL_RATE_INCREASE_TH)
748 scale_action = 1; 748 scale_action = 1;
749 else if (low != IL_RATE_INVALID) 749 else if (low != IL_RATE_INVALID)
750 scale_action = 0; 750 scale_action = 0;
@@ -768,7 +768,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
768 /* High rate has better throughput, Increase 768 /* High rate has better throughput, Increase
769 * rate */ 769 * rate */
770 if (high_tpt > current_tpt && 770 if (high_tpt > current_tpt &&
771 window->success_ratio >= IL_RATE_INCREASE_TH) 771 win->success_ratio >= IL_RATE_INCREASE_TH)
772 scale_action = 1; 772 scale_action = 1;
773 else { 773 else {
774 D_RATE( 774 D_RATE(
@@ -780,7 +780,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
780 D_RATE( 780 D_RATE(
781 "decrease rate because of low tpt\n"); 781 "decrease rate because of low tpt\n");
782 scale_action = -1; 782 scale_action = -1;
783 } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { 783 } else if (win->success_ratio >= IL_RATE_INCREASE_TH) {
784 /* Lower rate has better 784 /* Lower rate has better
785 * throughput,decrease rate */ 785 * throughput,decrease rate */
786 scale_action = 1; 786 scale_action = 1;
@@ -791,7 +791,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
791 /* Sanity check; asked for decrease, but success rate or throughput 791 /* Sanity check; asked for decrease, but success rate or throughput
792 * has been good at old rate. Don't change it. */ 792 * has been good at old rate. Don't change it. */
793 if (scale_action == -1 && low != IL_RATE_INVALID && 793 if (scale_action == -1 && low != IL_RATE_INVALID &&
794 (window->success_ratio > IL_RATE_HIGH_TH || 794 (win->success_ratio > IL_RATE_HIGH_TH ||
795 current_tpt > 100 * rs_sta->expected_tpt[low])) 795 current_tpt > 100 * rs_sta->expected_tpt[low]))
796 scale_action = 0; 796 scale_action = 0;
797 797