aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2011-11-15 06:30:17 -0500
committerStanislaw Gruszka <sgruszka@redhat.com>2011-11-15 06:30:17 -0500
commit0c2c885200057c44ac5660d123e199192689ca5d (patch)
treeca4d8a59465b35247f0ea434a4ef25f260f9303b /drivers/net/wireless/iwlegacy/iwl-3945-rs.c
parent2d09b0624a1048f6424b2c7ff60ad3a42d8036ff (diff)
iwlegacy: s/index/idx/
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.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
index 4d83c6292246..f84ed5ecc676 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
@@ -60,7 +60,7 @@ static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = {
60 60
61struct il3945_tpt_entry { 61struct il3945_tpt_entry {
62 s8 min_rssi; 62 s8 min_rssi;
63 u8 index; 63 u8 idx;
64}; 64};
65 65
66static struct il3945_tpt_entry il3945_tpt_table_a[] = { 66static struct il3945_tpt_entry il3945_tpt_table_a[] = {
@@ -98,9 +98,9 @@ static struct il3945_tpt_entry il3945_tpt_table_g[] = {
98#define RATE_DECREASE_TH 1920 98#define RATE_DECREASE_TH 1920
99#define RATE_RETRY_TH 15 99#define RATE_RETRY_TH 15
100 100
101static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) 101static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band)
102{ 102{
103 u32 index = 0; 103 u32 idx = 0;
104 u32 table_size = 0; 104 u32 table_size = 0;
105 struct il3945_tpt_entry *tpt_table = NULL; 105 struct il3945_tpt_entry *tpt_table = NULL;
106 106
@@ -123,12 +123,12 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band)
123 break; 123 break;
124 } 124 }
125 125
126 while (index < table_size && rssi < tpt_table[index].min_rssi) 126 while (idx < table_size && rssi < tpt_table[idx].min_rssi)
127 index++; 127 idx++;
128 128
129 index = min(index, (table_size - 1)); 129 idx = min(idx, (table_size - 1));
130 130
131 return tpt_table[index].index; 131 return tpt_table[idx].idx;
132} 132}
133 133
134static void il3945_clear_win(struct il3945_rate_scale_data *win) 134static void il3945_clear_win(struct il3945_rate_scale_data *win)
@@ -168,7 +168,7 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta)
168 if (time_after(jiffies, rs_sta->win[i].stamp + 168 if (time_after(jiffies, rs_sta->win[i].stamp +
169 RATE_WIN_FLUSH)) { 169 RATE_WIN_FLUSH)) {
170 D_RATE("flushing %d samples of rate " 170 D_RATE("flushing %d samples of rate "
171 "index %d\n", 171 "idx %d\n",
172 rs_sta->win[i].counter, i); 172 rs_sta->win[i].counter, i);
173 il3945_clear_win(&rs_sta->win[i]); 173 il3945_clear_win(&rs_sta->win[i]);
174 } else 174 } else
@@ -256,7 +256,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data)
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 *win, 258 struct il3945_rate_scale_data *win,
259 int success, int retries, int index) 259 int success, int retries, int idx)
260{ 260{
261 unsigned long flags; 261 unsigned long flags;
262 s32 fail_count; 262 s32 fail_count;
@@ -318,7 +318,7 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta,
318 if (fail_count >= RATE_MIN_FAILURE_TH || 318 if (fail_count >= RATE_MIN_FAILURE_TH ||
319 win->success_counter >= RATE_MIN_SUCCESS_TH) 319 win->success_counter >= RATE_MIN_SUCCESS_TH)
320 win->average_tpt = ((win->success_ratio * 320 win->average_tpt = ((win->success_ratio *
321 rs_sta->expected_tpt[index] + 64) / 128); 321 rs_sta->expected_tpt[idx] + 64) / 128);
322 else 322 else
323 win->average_tpt = IL_INVALID_VALUE; 323 win->average_tpt = IL_INVALID_VALUE;
324 324
@@ -447,7 +447,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
447 struct sk_buff *skb) 447 struct sk_buff *skb)
448{ 448{
449 s8 retries = 0, current_count; 449 s8 retries = 0, current_count;
450 int scale_rate_index, first_index, last_index; 450 int scale_rate_idx, first_idx, last_idx;
451 unsigned long flags; 451 unsigned long flags;
452 struct il_priv *il = (struct il_priv *)il_rate; 452 struct il_priv *il = (struct il_priv *)il_rate;
453 struct il3945_rs_sta *rs_sta = il_sta; 453 struct il3945_rs_sta *rs_sta = il_sta;
@@ -460,9 +460,9 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
460 if (retries > RATE_RETRY_TH) 460 if (retries > RATE_RETRY_TH)
461 retries = RATE_RETRY_TH; 461 retries = RATE_RETRY_TH;
462 462
463 first_index = sband->bitrates[info->status.rates[0].idx].hw_value; 463 first_idx = sband->bitrates[info->status.rates[0].idx].hw_value;
464 if (first_index < 0 || first_index >= RATE_COUNT_3945) { 464 if (first_idx < 0 || first_idx >= RATE_COUNT_3945) {
465 D_RATE("leave: Rate out of bounds: %d\n", first_index); 465 D_RATE("leave: Rate out of bounds: %d\n", first_idx);
466 return; 466 return;
467 } 467 }
468 468
@@ -480,8 +480,8 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
480 480
481 rs_sta->tx_packets++; 481 rs_sta->tx_packets++;
482 482
483 scale_rate_index = first_index; 483 scale_rate_idx = first_idx;
484 last_index = first_index; 484 last_idx = first_idx;
485 485
486 /* 486 /*
487 * Update the win for each rate. We determine which rates 487 * Update the win for each rate. We determine which rates
@@ -489,42 +489,42 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
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
491 * 491 *
492 * On exit from this while loop last_index indicates the rate 492 * On exit from this while loop last_idx indicates the rate
493 * at which the frame was finally transmitted (or failed if no 493 * at which the frame was finally transmitted (or failed if no
494 * ACK) 494 * ACK)
495 */ 495 */
496 while (retries > 1) { 496 while (retries > 1) {
497 if ((retries - 1) < il->retry_rate) { 497 if ((retries - 1) < il->retry_rate) {
498 current_count = (retries - 1); 498 current_count = (retries - 1);
499 last_index = scale_rate_index; 499 last_idx = scale_rate_idx;
500 } else { 500 } else {
501 current_count = il->retry_rate; 501 current_count = il->retry_rate;
502 last_index = il3945_rs_next_rate(il, 502 last_idx = il3945_rs_next_rate(il,
503 scale_rate_index); 503 scale_rate_idx);
504 } 504 }
505 505
506 /* Update this rate accounting for as many retries 506 /* Update this rate accounting for as many retries
507 * as was used for it (per current_count) */ 507 * as was used for it (per current_count) */
508 il3945_collect_tx_data(rs_sta, 508 il3945_collect_tx_data(rs_sta,
509 &rs_sta->win[scale_rate_index], 509 &rs_sta->win[scale_rate_idx],
510 0, current_count, scale_rate_index); 510 0, current_count, scale_rate_idx);
511 D_RATE("Update rate %d for %d retries.\n", 511 D_RATE("Update rate %d for %d retries.\n",
512 scale_rate_index, current_count); 512 scale_rate_idx, current_count);
513 513
514 retries -= current_count; 514 retries -= current_count;
515 515
516 scale_rate_index = last_index; 516 scale_rate_idx = last_idx;
517 } 517 }
518 518
519 519
520 /* Update the last index win with success/failure based on ACK */ 520 /* Update the last idx 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_idx,
523 (info->flags & IEEE80211_TX_STAT_ACK) ? 523 (info->flags & IEEE80211_TX_STAT_ACK) ?
524 "success" : "failure"); 524 "success" : "failure");
525 il3945_collect_tx_data(rs_sta, 525 il3945_collect_tx_data(rs_sta,
526 &rs_sta->win[last_index], 526 &rs_sta->win[last_idx],
527 info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); 527 info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx);
528 528
529 /* We updated the rate scale win -- 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
@@ -547,7 +547,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
547} 547}
548 548
549static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, 549static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta,
550 u8 index, u16 rate_mask, enum ieee80211_band band) 550 u8 idx, u16 rate_mask, enum ieee80211_band band)
551{ 551{
552 u8 high = RATE_INVALID; 552 u8 high = RATE_INVALID;
553 u8 low = RATE_INVALID; 553 u8 low = RATE_INVALID;
@@ -560,7 +560,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta,
560 u32 mask; 560 u32 mask;
561 561
562 /* Find the previous rate that is in the rate mask */ 562 /* Find the previous rate that is in the rate mask */
563 i = index - 1; 563 i = idx - 1;
564 for (mask = (1 << i); i >= 0; i--, mask >>= 1) { 564 for (mask = (1 << i); i >= 0; i--, mask >>= 1) {
565 if (rate_mask & mask) { 565 if (rate_mask & mask) {
566 low = i; 566 low = i;
@@ -569,7 +569,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta,
569 } 569 }
570 570
571 /* Find the next rate that is in the rate mask */ 571 /* Find the next rate that is in the rate mask */
572 i = index + 1; 572 i = idx + 1;
573 for (mask = (1 << i); i < RATE_COUNT_3945; 573 for (mask = (1 << i); i < RATE_COUNT_3945;
574 i++, mask <<= 1) { 574 i++, mask <<= 1) {
575 if (rate_mask & mask) { 575 if (rate_mask & mask) {
@@ -581,7 +581,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta,
581 return (high << 8) | low; 581 return (high << 8) | low;
582 } 582 }
583 583
584 low = index; 584 low = idx;
585 while (low != RATE_INVALID) { 585 while (low != RATE_INVALID) {
586 if (rs_sta->tgg) 586 if (rs_sta->tgg)
587 low = il3945_rates[low].prev_rs_tgg; 587 low = il3945_rates[low].prev_rs_tgg;
@@ -594,7 +594,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta,
594 D_RATE("Skipping masked lower rate: %d\n", low); 594 D_RATE("Skipping masked lower rate: %d\n", low);
595 } 595 }
596 596
597 high = index; 597 high = idx;
598 while (high != RATE_INVALID) { 598 while (high != RATE_INVALID) {
599 if (rs_sta->tgg) 599 if (rs_sta->tgg)
600 high = il3945_rates[high].next_rs_tgg; 600 high = il3945_rates[high].next_rs_tgg;
@@ -622,7 +622,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta,
622 * the entire A/B/G spectrum vs. being limited to just one particular 622 * the entire A/B/G spectrum vs. being limited to just one particular
623 * hw_mode. 623 * hw_mode.
624 * 624 *
625 * As such, we can't convert the index obtained below into the hw_mode's 625 * As such, we can't convert the idx obtained below into the hw_mode's
626 * rate table and must reference the driver allocated rate table 626 * rate table and must reference the driver allocated rate table
627 * 627 *
628 */ 628 */
@@ -634,7 +634,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
634 u8 low = RATE_INVALID; 634 u8 low = RATE_INVALID;
635 u8 high = RATE_INVALID; 635 u8 high = RATE_INVALID;
636 u16 high_low; 636 u16 high_low;
637 int index; 637 int idx;
638 struct il3945_rs_sta *rs_sta = il_sta; 638 struct il3945_rs_sta *rs_sta = il_sta;
639 struct il3945_rate_scale_data *win = NULL; 639 struct il3945_rate_scale_data *win = NULL;
640 int current_tpt = IL_INVALID_VALUE; 640 int current_tpt = IL_INVALID_VALUE;
@@ -668,7 +668,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
668 if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) 668 if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT)
669 max_rate_idx = -1; 669 max_rate_idx = -1;
670 670
671 index = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); 671 idx = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1);
672 672
673 if (sband->band == IEEE80211_BAND_5GHZ) 673 if (sband->band == IEEE80211_BAND_5GHZ)
674 rate_mask = rate_mask << IL_FIRST_OFDM_RATE; 674 rate_mask = rate_mask << IL_FIRST_OFDM_RATE;
@@ -679,19 +679,19 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
679 * to rssi value 679 * to rssi value
680 */ 680 */
681 if (rs_sta->start_rate != RATE_INVALID) { 681 if (rs_sta->start_rate != RATE_INVALID) {
682 if (rs_sta->start_rate < index && 682 if (rs_sta->start_rate < idx &&
683 (rate_mask & (1 << rs_sta->start_rate))) 683 (rate_mask & (1 << rs_sta->start_rate)))
684 index = rs_sta->start_rate; 684 idx = rs_sta->start_rate;
685 rs_sta->start_rate = RATE_INVALID; 685 rs_sta->start_rate = RATE_INVALID;
686 } 686 }
687 687
688 /* force user max rate if set by user */ 688 /* force user max rate if set by user */
689 if (max_rate_idx != -1 && max_rate_idx < index) { 689 if (max_rate_idx != -1 && max_rate_idx < idx) {
690 if (rate_mask & (1 << max_rate_idx)) 690 if (rate_mask & (1 << max_rate_idx))
691 index = max_rate_idx; 691 idx = max_rate_idx;
692 } 692 }
693 693
694 win = &(rs_sta->win[index]); 694 win = &(rs_sta->win[idx]);
695 695
696 fail_count = win->counter - win->success_counter; 696 fail_count = win->counter - win->success_counter;
697 697
@@ -702,7 +702,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
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 idx,
706 win->counter, 706 win->counter,
707 win->success_counter, 707 win->success_counter,
708 rs_sta->expected_tpt ? "not " : ""); 708 rs_sta->expected_tpt ? "not " : "");
@@ -715,7 +715,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
715 715
716 current_tpt = win->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, idx, rate_mask,
719 sband->band); 719 sband->band);
720 low = high_low & 0xff; 720 low = high_low & 0xff;
721 high = (high_low >> 8) & 0xff; 721 high = (high_low >> 8) & 0xff;
@@ -800,13 +800,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
800 800
801 /* Decrese rate */ 801 /* Decrese rate */
802 if (low != RATE_INVALID) 802 if (low != RATE_INVALID)
803 index = low; 803 idx = low;
804 break; 804 break;
805 805
806 case 1: 806 case 1:
807 /* Increase rate */ 807 /* Increase rate */
808 if (high != RATE_INVALID) 808 if (high != RATE_INVALID)
809 index = high; 809 idx = high;
810 810
811 break; 811 break;
812 812
@@ -817,21 +817,21 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
817 } 817 }
818 818
819 D_RATE("Selected %d (action %d) - low %d high %d\n", 819 D_RATE("Selected %d (action %d) - low %d high %d\n",
820 index, scale_action, low, high); 820 idx, scale_action, low, high);
821 821
822 out: 822 out:
823 823
824 if (sband->band == IEEE80211_BAND_5GHZ) { 824 if (sband->band == IEEE80211_BAND_5GHZ) {
825 if (WARN_ON_ONCE(index < IL_FIRST_OFDM_RATE)) 825 if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE))
826 index = IL_FIRST_OFDM_RATE; 826 idx = IL_FIRST_OFDM_RATE;
827 rs_sta->last_txrate_idx = index; 827 rs_sta->last_txrate_idx = idx;
828 info->control.rates[0].idx = index - IL_FIRST_OFDM_RATE; 828 info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE;
829 } else { 829 } else {
830 rs_sta->last_txrate_idx = index; 830 rs_sta->last_txrate_idx = idx;
831 info->control.rates[0].idx = rs_sta->last_txrate_idx; 831 info->control.rates[0].idx = rs_sta->last_txrate_idx;
832 } 832 }
833 833
834 D_RATE("leave: %d\n", index); 834 D_RATE("leave: %d\n", idx);
835} 835}
836 836
837#ifdef CONFIG_MAC80211_DEBUGFS 837#ifdef CONFIG_MAC80211_DEBUGFS
@@ -855,7 +855,7 @@ static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file,
855 if (!buff) 855 if (!buff)
856 return -ENOMEM; 856 return -ENOMEM;
857 857
858 desc += sprintf(buff + desc, "tx packets=%d last rate index=%d\n" 858 desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n"
859 "rate=0x%X flush time %d\n", 859 "rate=0x%X flush time %d\n",
860 lq_sta->tx_packets, 860 lq_sta->tx_packets,
861 lq_sta->last_txrate_idx, 861 lq_sta->last_txrate_idx,
@@ -977,9 +977,9 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
977 977
978 D_RATE("Network RSSI: %d\n", rssi); 978 D_RATE("Network RSSI: %d\n", rssi);
979 979
980 rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, il->band); 980 rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band);
981 981
982 D_RATE("leave: rssi %d assign rate index: " 982 D_RATE("leave: rssi %d assign rate idx: "
983 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, 983 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate,
984 il3945_rates[rs_sta->start_rate].plcp); 984 il3945_rates[rs_sta->start_rate].plcp);
985 rcu_read_unlock(); 985 rcu_read_unlock();