aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c45
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.h206
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h53
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c2
6 files changed, 80 insertions, 234 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 42b8bc495d8f..3fa9570f82b4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -64,7 +64,7 @@ struct iwl3945_rs_sta {
64 u8 start_rate; 64 u8 start_rate;
65 u8 ibss_sta_added; 65 u8 ibss_sta_added;
66 struct timer_list rate_scale_flush; 66 struct timer_list rate_scale_flush;
67 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT]; 67 struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945];
68#ifdef CONFIG_MAC80211_DEBUGFS 68#ifdef CONFIG_MAC80211_DEBUGFS
69 struct dentry *rs_sta_dbgfs_stats_table_file; 69 struct dentry *rs_sta_dbgfs_stats_table_file;
70#endif 70#endif
@@ -73,19 +73,19 @@ struct iwl3945_rs_sta {
73 int last_txrate_idx; 73 int last_txrate_idx;
74}; 74};
75 75
76static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT] = { 76static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT_3945] = {
77 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 77 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202
78}; 78};
79 79
80static s32 iwl3945_expected_tpt_g_prot[IWL_RATE_COUNT] = { 80static s32 iwl3945_expected_tpt_g_prot[IWL_RATE_COUNT_3945] = {
81 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 81 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125
82}; 82};
83 83
84static s32 iwl3945_expected_tpt_a[IWL_RATE_COUNT] = { 84static s32 iwl3945_expected_tpt_a[IWL_RATE_COUNT_3945] = {
85 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 85 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186
86}; 86};
87 87
88static s32 iwl3945_expected_tpt_b[IWL_RATE_COUNT] = { 88static s32 iwl3945_expected_tpt_b[IWL_RATE_COUNT_3945] = {
89 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 89 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0
90}; 90};
91 91
@@ -121,7 +121,7 @@ static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = {
121#define IWL_RATE_MAX_WINDOW 62 121#define IWL_RATE_MAX_WINDOW 62
122#define IWL_RATE_FLUSH (3*HZ) 122#define IWL_RATE_FLUSH (3*HZ)
123#define IWL_RATE_WIN_FLUSH (HZ/2) 123#define IWL_RATE_WIN_FLUSH (HZ/2)
124#define IWL_RATE_HIGH_TH 11520 124#define IWL39_RATE_HIGH_TH 11520
125#define IWL_SUCCESS_UP_TH 8960 125#define IWL_SUCCESS_UP_TH 8960
126#define IWL_SUCCESS_DOWN_TH 10880 126#define IWL_SUCCESS_DOWN_TH 10880
127#define IWL_RATE_MIN_FAILURE_TH 8 127#define IWL_RATE_MIN_FAILURE_TH 8
@@ -167,7 +167,7 @@ static void iwl3945_clear_window(struct iwl3945_rate_scale_data *window)
167 window->success_counter = 0; 167 window->success_counter = 0;
168 window->success_ratio = -1; 168 window->success_ratio = -1;
169 window->counter = 0; 169 window->counter = 0;
170 window->average_tpt = IWL_INV_TPT; 170 window->average_tpt = IWL_INVALID_VALUE;
171 window->stamp = 0; 171 window->stamp = 0;
172} 172}
173 173
@@ -190,7 +190,7 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta)
190 * and it has been more than IWL_RATE_WIN_FLUSH 190 * and it has been more than IWL_RATE_WIN_FLUSH
191 * since we flushed, clear out the gathered statistics 191 * since we flushed, clear out the gathered statistics
192 */ 192 */
193 for (i = 0; i < IWL_RATE_COUNT; i++) { 193 for (i = 0; i < IWL_RATE_COUNT_3945; i++) {
194 if (!rs_sta->win[i].counter) 194 if (!rs_sta->win[i].counter)
195 continue; 195 continue;
196 196
@@ -334,7 +334,7 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
334 window->average_tpt = ((window->success_ratio * 334 window->average_tpt = ((window->success_ratio *
335 rs_sta->expected_tpt[index] + 64) / 128); 335 rs_sta->expected_tpt[index] + 64) / 128);
336 else 336 else
337 window->average_tpt = IWL_INV_TPT; 337 window->average_tpt = IWL_INVALID_VALUE;
338 338
339 spin_unlock_irqrestore(&rs_sta->lock, flags); 339 spin_unlock_irqrestore(&rs_sta->lock, flags);
340 340
@@ -425,7 +425,7 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp)
425 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; 425 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta;
426 rs_sta->rate_scale_flush.function = &iwl3945_bg_rate_scale_flush; 426 rs_sta->rate_scale_flush.function = &iwl3945_bg_rate_scale_flush;
427 427
428 for (i = 0; i < IWL_RATE_COUNT; i++) 428 for (i = 0; i < IWL_RATE_COUNT_3945; i++)
429 iwl3945_clear_window(&rs_sta->win[i]); 429 iwl3945_clear_window(&rs_sta->win[i]);
430 430
431 IWL_DEBUG_RATE("leave\n"); 431 IWL_DEBUG_RATE("leave\n");
@@ -471,7 +471,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
471 retries = info->status.rates[0].count; 471 retries = info->status.rates[0].count;
472 472
473 first_index = sband->bitrates[info->status.rates[0].idx].hw_value; 473 first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
474 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { 474 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT_3945)) {
475 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index); 475 IWL_DEBUG_RATE("leave: Rate out of bounds: %d\n", first_index);
476 return; 476 return;
477 } 477 }
@@ -575,7 +575,8 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
575 575
576 /* Find the next rate that is in the rate mask */ 576 /* Find the next rate that is in the rate mask */
577 i = index + 1; 577 i = index + 1;
578 for (mask = (1 << i); i < IWL_RATE_COUNT; i++, mask <<= 1) { 578 for (mask = (1 << i); i < IWL_RATE_COUNT_3945;
579 i++, mask <<= 1) {
579 if (rate_mask & mask) { 580 if (rate_mask & mask) {
580 high = i; 581 high = i;
581 break; 582 break;
@@ -641,9 +642,9 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
641 int index; 642 int index;
642 struct iwl3945_rs_sta *rs_sta = priv_sta; 643 struct iwl3945_rs_sta *rs_sta = priv_sta;
643 struct iwl3945_rate_scale_data *window = NULL; 644 struct iwl3945_rate_scale_data *window = NULL;
644 int current_tpt = IWL_INV_TPT; 645 int current_tpt = IWL_INVALID_VALUE;
645 int low_tpt = IWL_INV_TPT; 646 int low_tpt = IWL_INVALID_VALUE;
646 int high_tpt = IWL_INV_TPT; 647 int high_tpt = IWL_INVALID_VALUE;
647 u32 fail_count; 648 u32 fail_count;
648 s8 scale_action = 0; 649 s8 scale_action = 0;
649 unsigned long flags; 650 unsigned long flags;
@@ -674,7 +675,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
674 return; 675 return;
675 } 676 }
676 677
677 index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); 678 index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT_3945 - 1);
678 679
679 if (sband->band == IEEE80211_BAND_5GHZ) 680 if (sband->band == IEEE80211_BAND_5GHZ)
680 rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; 681 rate_mask = rate_mask << IWL_FIRST_OFDM_RATE;
@@ -744,16 +745,18 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
744 if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { 745 if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) {
745 IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); 746 IWL_DEBUG_RATE("decrease rate because of low success_ratio\n");
746 scale_action = -1; 747 scale_action = -1;
747 } else if ((low_tpt == IWL_INV_TPT) && (high_tpt == IWL_INV_TPT)) 748 } else if ((low_tpt == IWL_INVALID_VALUE) &&
749 (high_tpt == IWL_INVALID_VALUE))
748 scale_action = 1; 750 scale_action = 1;
749 else if ((low_tpt != IWL_INV_TPT) && (high_tpt != IWL_INV_TPT) && 751 else if ((low_tpt != IWL_INVALID_VALUE) &&
752 (high_tpt != IWL_INVALID_VALUE) &&
750 (low_tpt < current_tpt) && (high_tpt < current_tpt)) { 753 (low_tpt < current_tpt) && (high_tpt < current_tpt)) {
751 IWL_DEBUG_RATE("No action -- low [%d] & high [%d] < " 754 IWL_DEBUG_RATE("No action -- low [%d] & high [%d] < "
752 "current_tpt [%d]\n", 755 "current_tpt [%d]\n",
753 low_tpt, high_tpt, current_tpt); 756 low_tpt, high_tpt, current_tpt);
754 scale_action = 0; 757 scale_action = 0;
755 } else { 758 } else {
756 if (high_tpt != IWL_INV_TPT) { 759 if (high_tpt != IWL_INVALID_VALUE) {
757 if (high_tpt > current_tpt) 760 if (high_tpt > current_tpt)
758 scale_action = 1; 761 scale_action = 1;
759 else { 762 else {
@@ -761,7 +764,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
761 ("decrease rate because of high tpt\n"); 764 ("decrease rate because of high tpt\n");
762 scale_action = -1; 765 scale_action = -1;
763 } 766 }
764 } else if (low_tpt != IWL_INV_TPT) { 767 } else if (low_tpt != IWL_INVALID_VALUE) {
765 if (low_tpt > current_tpt) { 768 if (low_tpt > current_tpt) {
766 IWL_DEBUG_RATE 769 IWL_DEBUG_RATE
767 ("decrease rate because of low tpt\n"); 770 ("decrease rate because of low tpt\n");
@@ -835,7 +838,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file,
835 lq_sta->tx_packets, 838 lq_sta->tx_packets,
836 lq_sta->last_txrate_idx, 839 lq_sta->last_txrate_idx,
837 lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); 840 lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time));
838 for (j = 0; j < IWL_RATE_COUNT; j++) { 841 for (j = 0; j < IWL_RATE_COUNT_3945; j++) {
839 desc += sprintf(buff+desc, 842 desc += sprintf(buff+desc,
840 "counter=%d success=%d %%=%d\n", 843 "counter=%d success=%d %%=%d\n",
841 lq_sta->win[j].counter, 844 lq_sta->win[j].counter,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
deleted file mode 100644
index b5a66135dedd..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
+++ /dev/null
@@ -1,206 +0,0 @@
1/******************************************************************************
2 *
3 * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
27#ifndef __iwl_3945_rs_h__
28#define __iwl_3945_rs_h__
29
30struct iwl3945_rate_info {
31 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
32 u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
33 u8 prev_ieee; /* previous rate in IEEE speeds */
34 u8 next_ieee; /* next rate in IEEE speeds */
35 u8 prev_rs; /* previous rate used in rs algo */
36 u8 next_rs; /* next rate used in rs algo */
37 u8 prev_rs_tgg; /* previous rate used in TGG rs algo */
38 u8 next_rs_tgg; /* next rate used in TGG rs algo */
39 u8 table_rs_index; /* index in rate scale table cmd */
40 u8 prev_table_rs; /* prev in rate table cmd */
41};
42
43/*
44 * These serve as indexes into
45 * struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT];
46 */
47enum {
48 IWL_RATE_1M_INDEX = 0,
49 IWL_RATE_2M_INDEX,
50 IWL_RATE_5M_INDEX,
51 IWL_RATE_11M_INDEX,
52 IWL_RATE_6M_INDEX,
53 IWL_RATE_9M_INDEX,
54 IWL_RATE_12M_INDEX,
55 IWL_RATE_18M_INDEX,
56 IWL_RATE_24M_INDEX,
57 IWL_RATE_36M_INDEX,
58 IWL_RATE_48M_INDEX,
59 IWL_RATE_54M_INDEX,
60 IWL_RATE_COUNT,
61 IWL_RATE_INVM_INDEX,
62 IWL_RATE_INVALID = IWL_RATE_INVM_INDEX
63};
64
65enum {
66 IWL_RATE_6M_INDEX_TABLE = 0,
67 IWL_RATE_9M_INDEX_TABLE,
68 IWL_RATE_12M_INDEX_TABLE,
69 IWL_RATE_18M_INDEX_TABLE,
70 IWL_RATE_24M_INDEX_TABLE,
71 IWL_RATE_36M_INDEX_TABLE,
72 IWL_RATE_48M_INDEX_TABLE,
73 IWL_RATE_54M_INDEX_TABLE,
74 IWL_RATE_1M_INDEX_TABLE,
75 IWL_RATE_2M_INDEX_TABLE,
76 IWL_RATE_5M_INDEX_TABLE,
77 IWL_RATE_11M_INDEX_TABLE,
78 IWL_RATE_INVM_INDEX_TABLE = IWL_RATE_INVM_INDEX,
79};
80
81enum {
82 IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX,
83 IWL_LAST_OFDM_RATE = IWL_RATE_54M_INDEX,
84 IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX,
85 IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX,
86};
87
88/* #define vs. enum to keep from defaulting to 'large integer' */
89#define IWL_RATE_6M_MASK (1 << IWL_RATE_6M_INDEX)
90#define IWL_RATE_9M_MASK (1 << IWL_RATE_9M_INDEX)
91#define IWL_RATE_12M_MASK (1 << IWL_RATE_12M_INDEX)
92#define IWL_RATE_18M_MASK (1 << IWL_RATE_18M_INDEX)
93#define IWL_RATE_24M_MASK (1 << IWL_RATE_24M_INDEX)
94#define IWL_RATE_36M_MASK (1 << IWL_RATE_36M_INDEX)
95#define IWL_RATE_48M_MASK (1 << IWL_RATE_48M_INDEX)
96#define IWL_RATE_54M_MASK (1 << IWL_RATE_54M_INDEX)
97#define IWL_RATE_1M_MASK (1 << IWL_RATE_1M_INDEX)
98#define IWL_RATE_2M_MASK (1 << IWL_RATE_2M_INDEX)
99#define IWL_RATE_5M_MASK (1 << IWL_RATE_5M_INDEX)
100#define IWL_RATE_11M_MASK (1 << IWL_RATE_11M_INDEX)
101
102/* 3945 uCode API values for (legacy) bit rates, both OFDM and CCK */
103enum {
104 IWL_RATE_6M_PLCP = 13,
105 IWL_RATE_9M_PLCP = 15,
106 IWL_RATE_12M_PLCP = 5,
107 IWL_RATE_18M_PLCP = 7,
108 IWL_RATE_24M_PLCP = 9,
109 IWL_RATE_36M_PLCP = 11,
110 IWL_RATE_48M_PLCP = 1,
111 IWL_RATE_54M_PLCP = 3,
112 IWL_RATE_1M_PLCP = 10,
113 IWL_RATE_2M_PLCP = 20,
114 IWL_RATE_5M_PLCP = 55,
115 IWL_RATE_11M_PLCP = 110,
116};
117
118/* MAC header values for bit rates */
119enum {
120 IWL_RATE_6M_IEEE = 12,
121 IWL_RATE_9M_IEEE = 18,
122 IWL_RATE_12M_IEEE = 24,
123 IWL_RATE_18M_IEEE = 36,
124 IWL_RATE_24M_IEEE = 48,
125 IWL_RATE_36M_IEEE = 72,
126 IWL_RATE_48M_IEEE = 96,
127 IWL_RATE_54M_IEEE = 108,
128 IWL_RATE_1M_IEEE = 2,
129 IWL_RATE_2M_IEEE = 4,
130 IWL_RATE_5M_IEEE = 11,
131 IWL_RATE_11M_IEEE = 22,
132};
133
134#define IWL_CCK_BASIC_RATES_MASK \
135 (IWL_RATE_1M_MASK | \
136 IWL_RATE_2M_MASK)
137
138#define IWL_CCK_RATES_MASK \
139 (IWL_BASIC_RATES_MASK | \
140 IWL_RATE_5M_MASK | \
141 IWL_RATE_11M_MASK)
142
143#define IWL_OFDM_BASIC_RATES_MASK \
144 (IWL_RATE_6M_MASK | \
145 IWL_RATE_12M_MASK | \
146 IWL_RATE_24M_MASK)
147
148#define IWL_OFDM_RATES_MASK \
149 (IWL_OFDM_BASIC_RATES_MASK | \
150 IWL_RATE_9M_MASK | \
151 IWL_RATE_18M_MASK | \
152 IWL_RATE_36M_MASK | \
153 IWL_RATE_48M_MASK | \
154 IWL_RATE_54M_MASK)
155
156#define IWL_BASIC_RATES_MASK \
157 (IWL_OFDM_BASIC_RATES_MASK | \
158 IWL_CCK_BASIC_RATES_MASK)
159
160#define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1)
161
162#define IWL_INV_TPT -1
163
164#define IWL_MIN_RSSI_VAL -100
165#define IWL_MAX_RSSI_VAL 0
166
167extern const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT];
168
169static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index)
170{
171 u8 rate = iwl3945_rates[rate_index].prev_ieee;
172
173 if (rate == IWL_RATE_INVALID)
174 rate = rate_index;
175 return rate;
176}
177
178/**
179 * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info
180 *
181 * The specific throughput table used is based on the type of network
182 * the associated with, including A, B, G, and G w/ TGG protection
183 */
184extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id);
185
186/**
187 * iwl3945_rate_control_register - Register the rate control algorithm callbacks
188 *
189 * Since the rate control algorithm is hardware specific, there is no need
190 * or reason to place it as a stand alone module. The driver can call
191 * iwl3945_rate_control_register in order to register the rate control callbacks
192 * with the mac80211 subsystem. This should be performed prior to calling
193 * ieee80211_register_hw
194 *
195 */
196extern int iwl3945_rate_control_register(void);
197
198/**
199 * iwl3945_rate_control_unregister - Unregister the rate control callbacks
200 *
201 * This should be called after calling ieee80211_unregister_hw, but before
202 * the driver is unloaded.
203 */
204extern void iwl3945_rate_control_unregister(void);
205
206#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 7ce43cbf0faa..d7d40ecc6b64 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -43,7 +43,7 @@
43#include "iwl-commands.h" 43#include "iwl-commands.h"
44#include "iwl-3945.h" 44#include "iwl-3945.h"
45#include "iwl-helpers.h" 45#include "iwl-helpers.h"
46#include "iwl-3945-rs.h" 46#include "iwl-agn-rs.h"
47 47
48#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ 48#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \
49 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ 49 [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \
@@ -65,7 +65,7 @@
65 * maps to IWL_RATE_INVALID 65 * maps to IWL_RATE_INVALID
66 * 66 *
67 */ 67 */
68const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT] = { 68const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT_3945] = {
69 IWL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ 69 IWL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */
70 IWL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ 70 IWL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */
71 IWL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ 71 IWL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */
@@ -1700,7 +1700,7 @@ int iwl3945_hw_reg_send_txpower(struct iwl3945_priv *priv)
1700 /* fill cmd with power settings for all rates for current channel */ 1700 /* fill cmd with power settings for all rates for current channel */
1701 /* Fill OFDM rate */ 1701 /* Fill OFDM rate */
1702 for (rate_idx = IWL_FIRST_OFDM_RATE, i = 0; 1702 for (rate_idx = IWL_FIRST_OFDM_RATE, i = 0;
1703 rate_idx <= IWL_LAST_OFDM_RATE; rate_idx++, i++) { 1703 rate_idx <= IWL39_LAST_OFDM_RATE; rate_idx++, i++) {
1704 1704
1705 txpower.power[i].tpc = ch_info->power_info[i].tpc; 1705 txpower.power[i].tpc = ch_info->power_info[i].tpc;
1706 txpower.power[i].rate = iwl3945_rates[rate_idx].plcp; 1706 txpower.power[i].rate = iwl3945_rates[rate_idx].plcp;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 3295244caf40..6d0ec0a65b14 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -233,7 +233,7 @@ struct iwl3945_clip_group {
233 const s8 clip_powers[IWL_MAX_RATES]; 233 const s8 clip_powers[IWL_MAX_RATES];
234}; 234};
235 235
236#include "iwl-3945-rs.h" 236#include "iwl-agn-rs.h"
237 237
238#define IWL_TX_FIFO_AC0 0 238#define IWL_TX_FIFO_AC0 0
239#define IWL_TX_FIFO_AC1 1 239#define IWL_TX_FIFO_AC1 1
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index 78ee83adf742..7c21292b3aeb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -27,8 +27,6 @@
27#ifndef __iwl_agn_rs_h__ 27#ifndef __iwl_agn_rs_h__
28#define __iwl_agn_rs_h__ 28#define __iwl_agn_rs_h__
29 29
30#include "iwl-dev.h"
31
32struct iwl_rate_info { 30struct iwl_rate_info {
33 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ 31 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
34 u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ 32 u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */
@@ -43,6 +41,19 @@ struct iwl_rate_info {
43 u8 next_rs_tgg; /* next rate used in TGG rs algo */ 41 u8 next_rs_tgg; /* next rate used in TGG rs algo */
44}; 42};
45 43
44struct iwl3945_rate_info {
45 u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */
46 u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */
47 u8 prev_ieee; /* previous rate in IEEE speeds */
48 u8 next_ieee; /* next rate in IEEE speeds */
49 u8 prev_rs; /* previous rate used in rs algo */
50 u8 next_rs; /* next rate used in rs algo */
51 u8 prev_rs_tgg; /* previous rate used in TGG rs algo */
52 u8 next_rs_tgg; /* next rate used in TGG rs algo */
53 u8 table_rs_index; /* index in rate scale table cmd */
54 u8 prev_table_rs; /* prev in rate table cmd */
55};
56
46/* 57/*
47 * These serve as indexes into 58 * These serve as indexes into
48 * struct iwl_rate_info iwl_rates[IWL_RATE_COUNT]; 59 * struct iwl_rate_info iwl_rates[IWL_RATE_COUNT];
@@ -62,12 +73,30 @@ enum {
62 IWL_RATE_54M_INDEX, 73 IWL_RATE_54M_INDEX,
63 IWL_RATE_60M_INDEX, 74 IWL_RATE_60M_INDEX,
64 IWL_RATE_COUNT, /*FIXME:RS:change to IWL_RATE_INDEX_COUNT,*/ 75 IWL_RATE_COUNT, /*FIXME:RS:change to IWL_RATE_INDEX_COUNT,*/
76 IWL_RATE_COUNT_3945 = IWL_RATE_COUNT - 1,
65 IWL_RATE_INVM_INDEX = IWL_RATE_COUNT, 77 IWL_RATE_INVM_INDEX = IWL_RATE_COUNT,
66 IWL_RATE_INVALID = IWL_RATE_COUNT, 78 IWL_RATE_INVALID = IWL_RATE_COUNT,
67}; 79};
68 80
69enum { 81enum {
82 IWL_RATE_6M_INDEX_TABLE = 0,
83 IWL_RATE_9M_INDEX_TABLE,
84 IWL_RATE_12M_INDEX_TABLE,
85 IWL_RATE_18M_INDEX_TABLE,
86 IWL_RATE_24M_INDEX_TABLE,
87 IWL_RATE_36M_INDEX_TABLE,
88 IWL_RATE_48M_INDEX_TABLE,
89 IWL_RATE_54M_INDEX_TABLE,
90 IWL_RATE_1M_INDEX_TABLE,
91 IWL_RATE_2M_INDEX_TABLE,
92 IWL_RATE_5M_INDEX_TABLE,
93 IWL_RATE_11M_INDEX_TABLE,
94 IWL_RATE_INVM_INDEX_TABLE = IWL_RATE_INVM_INDEX - 1,
95};
96
97enum {
70 IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX, 98 IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX,
99 IWL39_LAST_OFDM_RATE = IWL_RATE_54M_INDEX,
71 IWL_LAST_OFDM_RATE = IWL_RATE_60M_INDEX, 100 IWL_LAST_OFDM_RATE = IWL_RATE_60M_INDEX,
72 IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX, 101 IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX,
73 IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX, 102 IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX,
@@ -248,6 +277,7 @@ enum {
248#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) 277#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
249 278
250extern const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT]; 279extern const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT];
280extern const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT_3945];
251 281
252enum iwl_table_type { 282enum iwl_table_type {
253 LQ_NONE, 283 LQ_NONE,
@@ -303,6 +333,23 @@ static inline u8 iwl_get_prev_ieee_rate(u8 rate_index)
303 return rate; 333 return rate;
304} 334}
305 335
336static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index)
337{
338 u8 rate = iwl3945_rates[rate_index].prev_ieee;
339
340 if (rate == IWL_RATE_INVALID)
341 rate = rate_index;
342 return rate;
343}
344
345/**
346 * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info
347 *
348 * The specific throughput table used is based on the type of network
349 * the associated with, including A, B, G, and G w/ TGG protection
350 */
351extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id);
352
306/** 353/**
307 * iwl_rate_control_register - Register the rate control algorithm callbacks 354 * iwl_rate_control_register - Register the rate control algorithm callbacks
308 * 355 *
@@ -314,6 +361,7 @@ static inline u8 iwl_get_prev_ieee_rate(u8 rate_index)
314 * 361 *
315 */ 362 */
316extern int iwlagn_rate_control_register(void); 363extern int iwlagn_rate_control_register(void);
364extern int iwl3945_rate_control_register(void);
317 365
318/** 366/**
319 * iwl_rate_control_unregister - Unregister the rate control callbacks 367 * iwl_rate_control_unregister - Unregister the rate control callbacks
@@ -322,5 +370,6 @@ extern int iwlagn_rate_control_register(void);
322 * the driver is unloaded. 370 * the driver is unloaded.
323 */ 371 */
324extern void iwlagn_rate_control_unregister(void); 372extern void iwlagn_rate_control_unregister(void);
373extern void iwl3945_rate_control_unregister(void);
325 374
326#endif /* __iwl_agn__rs__ */ 375#endif /* __iwl_agn__rs__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 3738ffa2dcde..df785246ba1f 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -4843,7 +4843,7 @@ static void iwl3945_init_hw_rates(struct iwl3945_priv *priv,
4843 rates[i].hw_value = i; /* Rate scaling will work on indexes */ 4843 rates[i].hw_value = i; /* Rate scaling will work on indexes */
4844 rates[i].hw_value_short = i; 4844 rates[i].hw_value_short = i;
4845 rates[i].flags = 0; 4845 rates[i].flags = 0;
4846 if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) { 4846 if ((i > IWL39_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) {
4847 /* 4847 /*
4848 * If CCK != 1M then set short preamble rate flag. 4848 * If CCK != 1M then set short preamble rate flag.
4849 */ 4849 */