aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlegacy/iwl-3945-rs.c')
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945-rs.c468
1 files changed, 234 insertions, 234 deletions
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
index 8faeaf2dddec..d97f24bfc451 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
@@ -42,80 +42,80 @@
42 42
43#define RS_NAME "iwl-3945-rs" 43#define RS_NAME "iwl-3945-rs"
44 44
45static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT_3945] = { 45static s32 il3945_expected_tpt_g[IL_RATE_COUNT_3945] = {
46 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 46 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202
47}; 47};
48 48
49static s32 iwl3945_expected_tpt_g_prot[IWL_RATE_COUNT_3945] = { 49static s32 il3945_expected_tpt_g_prot[IL_RATE_COUNT_3945] = {
50 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 50 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125
51}; 51};
52 52
53static s32 iwl3945_expected_tpt_a[IWL_RATE_COUNT_3945] = { 53static s32 il3945_expected_tpt_a[IL_RATE_COUNT_3945] = {
54 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 54 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186
55}; 55};
56 56
57static s32 iwl3945_expected_tpt_b[IWL_RATE_COUNT_3945] = { 57static s32 il3945_expected_tpt_b[IL_RATE_COUNT_3945] = {
58 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 58 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0
59}; 59};
60 60
61struct iwl3945_tpt_entry { 61struct il3945_tpt_entry {
62 s8 min_rssi; 62 s8 min_rssi;
63 u8 index; 63 u8 index;
64}; 64};
65 65
66static struct iwl3945_tpt_entry iwl3945_tpt_table_a[] = { 66static struct il3945_tpt_entry il3945_tpt_table_a[] = {
67 {-60, IWL_RATE_54M_INDEX}, 67 {-60, IL_RATE_54M_INDEX},
68 {-64, IWL_RATE_48M_INDEX}, 68 {-64, IL_RATE_48M_INDEX},
69 {-72, IWL_RATE_36M_INDEX}, 69 {-72, IL_RATE_36M_INDEX},
70 {-80, IWL_RATE_24M_INDEX}, 70 {-80, IL_RATE_24M_INDEX},
71 {-84, IWL_RATE_18M_INDEX}, 71 {-84, IL_RATE_18M_INDEX},
72 {-85, IWL_RATE_12M_INDEX}, 72 {-85, IL_RATE_12M_INDEX},
73 {-87, IWL_RATE_9M_INDEX}, 73 {-87, IL_RATE_9M_INDEX},
74 {-89, IWL_RATE_6M_INDEX} 74 {-89, IL_RATE_6M_INDEX}
75}; 75};
76 76
77static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { 77static struct il3945_tpt_entry il3945_tpt_table_g[] = {
78 {-60, IWL_RATE_54M_INDEX}, 78 {-60, IL_RATE_54M_INDEX},
79 {-64, IWL_RATE_48M_INDEX}, 79 {-64, IL_RATE_48M_INDEX},
80 {-68, IWL_RATE_36M_INDEX}, 80 {-68, IL_RATE_36M_INDEX},
81 {-80, IWL_RATE_24M_INDEX}, 81 {-80, IL_RATE_24M_INDEX},
82 {-84, IWL_RATE_18M_INDEX}, 82 {-84, IL_RATE_18M_INDEX},
83 {-85, IWL_RATE_12M_INDEX}, 83 {-85, IL_RATE_12M_INDEX},
84 {-86, IWL_RATE_11M_INDEX}, 84 {-86, IL_RATE_11M_INDEX},
85 {-88, IWL_RATE_5M_INDEX}, 85 {-88, IL_RATE_5M_INDEX},
86 {-90, IWL_RATE_2M_INDEX}, 86 {-90, IL_RATE_2M_INDEX},
87 {-92, IWL_RATE_1M_INDEX} 87 {-92, IL_RATE_1M_INDEX}
88}; 88};
89 89
90#define IWL_RATE_MAX_WINDOW 62 90#define IL_RATE_MAX_WINDOW 62
91#define IWL_RATE_FLUSH (3*HZ) 91#define IL_RATE_FLUSH (3*HZ)
92#define IWL_RATE_WIN_FLUSH (HZ/2) 92#define IL_RATE_WIN_FLUSH (HZ/2)
93#define IWL39_RATE_HIGH_TH 11520 93#define IWL39_RATE_HIGH_TH 11520
94#define IWL_SUCCESS_UP_TH 8960 94#define IL_SUCCESS_UP_TH 8960
95#define IWL_SUCCESS_DOWN_TH 10880 95#define IL_SUCCESS_DOWN_TH 10880
96#define IWL_RATE_MIN_FAILURE_TH 6 96#define IL_RATE_MIN_FAILURE_TH 6
97#define IWL_RATE_MIN_SUCCESS_TH 8 97#define IL_RATE_MIN_SUCCESS_TH 8
98#define IWL_RATE_DECREASE_TH 1920 98#define IL_RATE_DECREASE_TH 1920
99#define IWL_RATE_RETRY_TH 15 99#define IL_RATE_RETRY_TH 15
100 100
101static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) 101static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band)
102{ 102{
103 u32 index = 0; 103 u32 index = 0;
104 u32 table_size = 0; 104 u32 table_size = 0;
105 struct iwl3945_tpt_entry *tpt_table = NULL; 105 struct il3945_tpt_entry *tpt_table = NULL;
106 106
107 if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) 107 if ((rssi < IL_MIN_RSSI_VAL) || (rssi > IL_MAX_RSSI_VAL))
108 rssi = IWL_MIN_RSSI_VAL; 108 rssi = IL_MIN_RSSI_VAL;
109 109
110 switch (band) { 110 switch (band) {
111 case IEEE80211_BAND_2GHZ: 111 case IEEE80211_BAND_2GHZ:
112 tpt_table = iwl3945_tpt_table_g; 112 tpt_table = il3945_tpt_table_g;
113 table_size = ARRAY_SIZE(iwl3945_tpt_table_g); 113 table_size = ARRAY_SIZE(il3945_tpt_table_g);
114 break; 114 break;
115 115
116 case IEEE80211_BAND_5GHZ: 116 case IEEE80211_BAND_5GHZ:
117 tpt_table = iwl3945_tpt_table_a; 117 tpt_table = il3945_tpt_table_a;
118 table_size = ARRAY_SIZE(iwl3945_tpt_table_a); 118 table_size = ARRAY_SIZE(il3945_tpt_table_a);
119 break; 119 break;
120 120
121 default: 121 default:
@@ -131,46 +131,46 @@ static u8 iwl3945_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 iwl3945_clear_window(struct iwl3945_rate_scale_data *window) 134static void il3945_clear_window(struct il3945_rate_scale_data *window)
135{ 135{
136 window->data = 0; 136 window->data = 0;
137 window->success_counter = 0; 137 window->success_counter = 0;
138 window->success_ratio = -1; 138 window->success_ratio = -1;
139 window->counter = 0; 139 window->counter = 0;
140 window->average_tpt = IWL_INVALID_VALUE; 140 window->average_tpt = IL_INVALID_VALUE;
141 window->stamp = 0; 141 window->stamp = 0;
142} 142}
143 143
144/** 144/**
145 * iwl3945_rate_scale_flush_windows - flush out the rate scale windows 145 * il3945_rate_scale_flush_windows - flush out the rate scale windows
146 * 146 *
147 * Returns the number of windows that have gathered data but were 147 * Returns the number of windows 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 iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta) 151static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta)
152{ 152{
153 int unflushed = 0; 153 int unflushed = 0;
154 int i; 154 int i;
155 unsigned long flags; 155 unsigned long flags;
156 struct iwl_priv *priv __maybe_unused = rs_sta->priv; 156 struct il_priv *priv __maybe_unused = rs_sta->priv;
157 157
158 /* 158 /*
159 * For each rate, if we have collected data on that rate 159 * For each rate, if we have collected data on that rate
160 * and it has been more than IWL_RATE_WIN_FLUSH 160 * and it has been more than IL_RATE_WIN_FLUSH
161 * since we flushed, clear out the gathered statistics 161 * since we flushed, clear out the gathered statistics
162 */ 162 */
163 for (i = 0; i < IWL_RATE_COUNT_3945; i++) { 163 for (i = 0; i < IL_RATE_COUNT_3945; i++) {
164 if (!rs_sta->win[i].counter) 164 if (!rs_sta->win[i].counter)
165 continue; 165 continue;
166 166
167 spin_lock_irqsave(&rs_sta->lock, flags); 167 spin_lock_irqsave(&rs_sta->lock, flags);
168 if (time_after(jiffies, rs_sta->win[i].stamp + 168 if (time_after(jiffies, rs_sta->win[i].stamp +
169 IWL_RATE_WIN_FLUSH)) { 169 IL_RATE_WIN_FLUSH)) {
170 IWL_DEBUG_RATE(priv, "flushing %d samples of rate " 170 IL_DEBUG_RATE(priv, "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 iwl3945_clear_window(&rs_sta->win[i]); 173 il3945_clear_window(&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);
@@ -179,21 +179,21 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta)
179 return unflushed; 179 return unflushed;
180} 180}
181 181
182#define IWL_RATE_FLUSH_MAX 5000 /* msec */ 182#define IL_RATE_FLUSH_MAX 5000 /* msec */
183#define IWL_RATE_FLUSH_MIN 50 /* msec */ 183#define IL_RATE_FLUSH_MIN 50 /* msec */
184#define IWL_AVERAGE_PACKETS 1500 184#define IL_AVERAGE_PACKETS 1500
185 185
186static void iwl3945_bg_rate_scale_flush(unsigned long data) 186static void il3945_bg_rate_scale_flush(unsigned long data)
187{ 187{
188 struct iwl3945_rs_sta *rs_sta = (void *)data; 188 struct il3945_rs_sta *rs_sta = (void *)data;
189 struct iwl_priv *priv __maybe_unused = rs_sta->priv; 189 struct il_priv *priv __maybe_unused = rs_sta->priv;
190 int unflushed = 0; 190 int unflushed = 0;
191 unsigned long flags; 191 unsigned long flags;
192 u32 packet_count, duration, pps; 192 u32 packet_count, duration, pps;
193 193
194 IWL_DEBUG_RATE(priv, "enter\n"); 194 IL_DEBUG_RATE(priv, "enter\n");
195 195
196 unflushed = iwl3945_rate_scale_flush_windows(rs_sta); 196 unflushed = il3945_rate_scale_flush_windows(rs_sta);
197 197
198 spin_lock_irqsave(&rs_sta->lock, flags); 198 spin_lock_irqsave(&rs_sta->lock, flags);
199 199
@@ -206,7 +206,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
206 duration = 206 duration =
207 jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); 207 jiffies_to_msecs(jiffies - rs_sta->last_partial_flush);
208 208
209 IWL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n", 209 IL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n",
210 packet_count, duration); 210 packet_count, duration);
211 211
212 /* Determine packets per second */ 212 /* Determine packets per second */
@@ -216,17 +216,17 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
216 pps = 0; 216 pps = 0;
217 217
218 if (pps) { 218 if (pps) {
219 duration = (IWL_AVERAGE_PACKETS * 1000) / pps; 219 duration = (IL_AVERAGE_PACKETS * 1000) / pps;
220 if (duration < IWL_RATE_FLUSH_MIN) 220 if (duration < IL_RATE_FLUSH_MIN)
221 duration = IWL_RATE_FLUSH_MIN; 221 duration = IL_RATE_FLUSH_MIN;
222 else if (duration > IWL_RATE_FLUSH_MAX) 222 else if (duration > IL_RATE_FLUSH_MAX)
223 duration = IWL_RATE_FLUSH_MAX; 223 duration = IL_RATE_FLUSH_MAX;
224 } else 224 } else
225 duration = IWL_RATE_FLUSH_MAX; 225 duration = IL_RATE_FLUSH_MAX;
226 226
227 rs_sta->flush_time = msecs_to_jiffies(duration); 227 rs_sta->flush_time = msecs_to_jiffies(duration);
228 228
229 IWL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n", 229 IL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n",
230 duration, packet_count); 230 duration, packet_count);
231 231
232 mod_timer(&rs_sta->rate_scale_flush, jiffies + 232 mod_timer(&rs_sta->rate_scale_flush, jiffies +
@@ -234,7 +234,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
234 234
235 rs_sta->last_partial_flush = jiffies; 235 rs_sta->last_partial_flush = jiffies;
236 } else { 236 } else {
237 rs_sta->flush_time = IWL_RATE_FLUSH; 237 rs_sta->flush_time = IL_RATE_FLUSH;
238 rs_sta->flush_pending = 0; 238 rs_sta->flush_pending = 0;
239 } 239 }
240 /* If there weren't any unflushed entries, we don't schedule the timer 240 /* If there weren't any unflushed entries, we don't schedule the timer
@@ -244,26 +244,26 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
244 244
245 spin_unlock_irqrestore(&rs_sta->lock, flags); 245 spin_unlock_irqrestore(&rs_sta->lock, flags);
246 246
247 IWL_DEBUG_RATE(priv, "leave\n"); 247 IL_DEBUG_RATE(priv, "leave\n");
248} 248}
249 249
250/** 250/**
251 * iwl3945_collect_tx_data - Update the success/failure sliding window 251 * il3945_collect_tx_data - Update the success/failure sliding window
252 * 252 *
253 * We keep a sliding window of the last 64 packets transmitted 253 * We keep a sliding window of the last 64 packets transmitted
254 * at this rate. window->data contains the bitmask of successful 254 * at this rate. window->data contains the bitmask of successful
255 * packets. 255 * packets.
256 */ 256 */
257static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, 257static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta,
258 struct iwl3945_rate_scale_data *window, 258 struct il3945_rate_scale_data *window,
259 int success, int retries, int index) 259 int success, int retries, int index)
260{ 260{
261 unsigned long flags; 261 unsigned long flags;
262 s32 fail_count; 262 s32 fail_count;
263 struct iwl_priv *priv __maybe_unused = rs_sta->priv; 263 struct il_priv *priv __maybe_unused = rs_sta->priv;
264 264
265 if (!retries) { 265 if (!retries) {
266 IWL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n"); 266 IL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n");
267 return; 267 return;
268 } 268 }
269 269
@@ -278,13 +278,13 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
278 * we keep these bitmaps!). 278 * we keep these bitmaps!).
279 * */ 279 * */
280 while (retries > 0) { 280 while (retries > 0) {
281 if (window->counter >= IWL_RATE_MAX_WINDOW) { 281 if (window->counter >= IL_RATE_MAX_WINDOW) {
282 282
283 /* remove earliest */ 283 /* remove earliest */
284 window->counter = IWL_RATE_MAX_WINDOW - 1; 284 window->counter = IL_RATE_MAX_WINDOW - 1;
285 285
286 if (window->data & (1ULL << (IWL_RATE_MAX_WINDOW - 1))) { 286 if (window->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) {
287 window->data &= ~(1ULL << (IWL_RATE_MAX_WINDOW - 1)); 287 window->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1));
288 window->success_counter--; 288 window->success_counter--;
289 } 289 }
290 } 290 }
@@ -310,17 +310,17 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
310 window->success_ratio = 128 * (100 * window->success_counter) 310 window->success_ratio = 128 * (100 * window->success_counter)
311 / window->counter; 311 / window->counter;
312 else 312 else
313 window->success_ratio = IWL_INVALID_VALUE; 313 window->success_ratio = IL_INVALID_VALUE;
314 314
315 fail_count = window->counter - window->success_counter; 315 fail_count = window->counter - window->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 >= IWL_RATE_MIN_FAILURE_TH) || 318 if ((fail_count >= IL_RATE_MIN_FAILURE_TH) ||
319 (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH)) 319 (window->success_counter >= IL_RATE_MIN_SUCCESS_TH))
320 window->average_tpt = ((window->success_ratio * 320 window->average_tpt = ((window->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 = IWL_INVALID_VALUE; 323 window->average_tpt = IL_INVALID_VALUE;
324 324
325 /* Tag this window as having been updated */ 325 /* Tag this window as having been updated */
326 window->stamp = jiffies; 326 window->stamp = jiffies;
@@ -332,40 +332,40 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
332/* 332/*
333 * Called after adding a new station to initialize rate scaling 333 * Called after adding a new station to initialize rate scaling
334 */ 334 */
335void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_id) 335void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id)
336{ 336{
337 struct ieee80211_hw *hw = priv->hw; 337 struct ieee80211_hw *hw = priv->hw;
338 struct ieee80211_conf *conf = &priv->hw->conf; 338 struct ieee80211_conf *conf = &priv->hw->conf;
339 struct iwl3945_sta_priv *psta; 339 struct il3945_sta_priv *psta;
340 struct iwl3945_rs_sta *rs_sta; 340 struct il3945_rs_sta *rs_sta;
341 struct ieee80211_supported_band *sband; 341 struct ieee80211_supported_band *sband;
342 int i; 342 int i;
343 343
344 IWL_DEBUG_INFO(priv, "enter\n"); 344 IL_DEBUG_INFO(priv, "enter\n");
345 if (sta_id == priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id) 345 if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id)
346 goto out; 346 goto out;
347 347
348 psta = (struct iwl3945_sta_priv *) sta->drv_priv; 348 psta = (struct il3945_sta_priv *) sta->drv_priv;
349 rs_sta = &psta->rs_sta; 349 rs_sta = &psta->rs_sta;
350 sband = hw->wiphy->bands[conf->channel->band]; 350 sband = hw->wiphy->bands[conf->channel->band];
351 351
352 rs_sta->priv = priv; 352 rs_sta->priv = priv;
353 353
354 rs_sta->start_rate = IWL_RATE_INVALID; 354 rs_sta->start_rate = IL_RATE_INVALID;
355 355
356 /* default to just 802.11b */ 356 /* default to just 802.11b */
357 rs_sta->expected_tpt = iwl3945_expected_tpt_b; 357 rs_sta->expected_tpt = il3945_expected_tpt_b;
358 358
359 rs_sta->last_partial_flush = jiffies; 359 rs_sta->last_partial_flush = jiffies;
360 rs_sta->last_flush = jiffies; 360 rs_sta->last_flush = jiffies;
361 rs_sta->flush_time = IWL_RATE_FLUSH; 361 rs_sta->flush_time = IL_RATE_FLUSH;
362 rs_sta->last_tx_packets = 0; 362 rs_sta->last_tx_packets = 0;
363 363
364 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; 364 rs_sta->rate_scale_flush.data = (unsigned long)rs_sta;
365 rs_sta->rate_scale_flush.function = iwl3945_bg_rate_scale_flush; 365 rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush;
366 366
367 for (i = 0; i < IWL_RATE_COUNT_3945; i++) 367 for (i = 0; i < IL_RATE_COUNT_3945; i++)
368 iwl3945_clear_window(&rs_sta->win[i]); 368 il3945_clear_window(&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
@@ -380,56 +380,56 @@ void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 s
380 } 380 }
381 381
382 priv->_3945.sta_supp_rates = sta->supp_rates[sband->band]; 382 priv->_3945.sta_supp_rates = sta->supp_rates[sband->band];
383 /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ 383 /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */
384 if (sband->band == IEEE80211_BAND_5GHZ) { 384 if (sband->band == IEEE80211_BAND_5GHZ) {
385 rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 385 rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE;
386 priv->_3945.sta_supp_rates = priv->_3945.sta_supp_rates << 386 priv->_3945.sta_supp_rates = priv->_3945.sta_supp_rates <<
387 IWL_FIRST_OFDM_RATE; 387 IL_FIRST_OFDM_RATE;
388 } 388 }
389 389
390out: 390out:
391 priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; 391 priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS;
392 392
393 IWL_DEBUG_INFO(priv, "leave\n"); 393 IL_DEBUG_INFO(priv, "leave\n");
394} 394}
395 395
396static void *iwl3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) 396static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
397{ 397{
398 return hw->priv; 398 return hw->priv;
399} 399}
400 400
401/* rate scale requires free function to be implemented */ 401/* rate scale requires free function to be implemented */
402static void iwl3945_rs_free(void *priv) 402static void il3945_rs_free(void *priv)
403{ 403{
404 return; 404 return;
405} 405}
406 406
407static void *iwl3945_rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp) 407static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp)
408{ 408{
409 struct iwl3945_rs_sta *rs_sta; 409 struct il3945_rs_sta *rs_sta;
410 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; 410 struct il3945_sta_priv *psta = (void *) sta->drv_priv;
411 struct iwl_priv *priv __maybe_unused = iwl_priv; 411 struct il_priv *priv __maybe_unused = il_priv;
412 412
413 IWL_DEBUG_RATE(priv, "enter\n"); 413 IL_DEBUG_RATE(priv, "enter\n");
414 414
415 rs_sta = &psta->rs_sta; 415 rs_sta = &psta->rs_sta;
416 416
417 spin_lock_init(&rs_sta->lock); 417 spin_lock_init(&rs_sta->lock);
418 init_timer(&rs_sta->rate_scale_flush); 418 init_timer(&rs_sta->rate_scale_flush);
419 419
420 IWL_DEBUG_RATE(priv, "leave\n"); 420 IL_DEBUG_RATE(priv, "leave\n");
421 421
422 return rs_sta; 422 return rs_sta;
423} 423}
424 424
425static void iwl3945_rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, 425static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta,
426 void *priv_sta) 426 void *priv_sta)
427{ 427{
428 struct iwl3945_rs_sta *rs_sta = priv_sta; 428 struct il3945_rs_sta *rs_sta = priv_sta;
429 429
430 /* 430 /*
431 * Be careful not to use any members of iwl3945_rs_sta (like trying 431 * Be careful not to use any members of il3945_rs_sta (like trying
432 * to use iwl_priv to print out debugging) since it may not be fully 432 * to use il_priv to print out debugging) since it may not be fully
433 * initialized at this point. 433 * initialized at this point.
434 */ 434 */
435 del_timer_sync(&rs_sta->rate_scale_flush); 435 del_timer_sync(&rs_sta->rate_scale_flush);
@@ -437,43 +437,43 @@ static void iwl3945_rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta,
437 437
438 438
439/** 439/**
440 * iwl3945_rs_tx_status - Update rate control values based on Tx results 440 * il3945_rs_tx_status - Update rate control values based on Tx results
441 * 441 *
442 * NOTE: Uses iwl_priv->retry_rate for the # of retries attempted by 442 * NOTE: Uses il_priv->retry_rate for the # of retries attempted by
443 * the hardware for each rate. 443 * the hardware for each rate.
444 */ 444 */
445static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, 445static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband,
446 struct ieee80211_sta *sta, void *priv_sta, 446 struct ieee80211_sta *sta, void *priv_sta,
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_index, first_index, last_index;
451 unsigned long flags; 451 unsigned long flags;
452 struct iwl_priv *priv = (struct iwl_priv *)priv_rate; 452 struct il_priv *priv = (struct il_priv *)priv_rate;
453 struct iwl3945_rs_sta *rs_sta = priv_sta; 453 struct il3945_rs_sta *rs_sta = priv_sta;
454 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 454 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
455 455
456 IWL_DEBUG_RATE(priv, "enter\n"); 456 IL_DEBUG_RATE(priv, "enter\n");
457 457
458 retries = info->status.rates[0].count; 458 retries = info->status.rates[0].count;
459 /* Sanity Check for retries */ 459 /* Sanity Check for retries */
460 if (retries > IWL_RATE_RETRY_TH) 460 if (retries > IL_RATE_RETRY_TH)
461 retries = IWL_RATE_RETRY_TH; 461 retries = IL_RATE_RETRY_TH;
462 462
463 first_index = sband->bitrates[info->status.rates[0].idx].hw_value; 463 first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
464 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT_3945)) { 464 if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) {
465 IWL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index); 465 IL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index);
466 return; 466 return;
467 } 467 }
468 468
469 if (!priv_sta) { 469 if (!priv_sta) {
470 IWL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n"); 470 IL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n");
471 return; 471 return;
472 } 472 }
473 473
474 /* Treat uninitialized rate scaling data same as non-existing. */ 474 /* Treat uninitialized rate scaling data same as non-existing. */
475 if (!rs_sta->priv) { 475 if (!rs_sta->priv) {
476 IWL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); 476 IL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n");
477 return; 477 return;
478 } 478 }
479 479
@@ -499,16 +499,16 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban
499 last_index = scale_rate_index; 499 last_index = scale_rate_index;
500 } else { 500 } else {
501 current_count = priv->retry_rate; 501 current_count = priv->retry_rate;
502 last_index = iwl3945_rs_next_rate(priv, 502 last_index = il3945_rs_next_rate(priv,
503 scale_rate_index); 503 scale_rate_index);
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 iwl3945_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_index],
510 0, current_count, scale_rate_index); 510 0, current_count, scale_rate_index);
511 IWL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n", 511 IL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n",
512 scale_rate_index, current_count); 512 scale_rate_index, current_count);
513 513
514 retries -= current_count; 514 retries -= current_count;
@@ -518,11 +518,11 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban
518 518
519 519
520 /* Update the last index window with success/failure based on ACK */ 520 /* Update the last index window with success/failure based on ACK */
521 IWL_DEBUG_RATE(priv, "Update rate %d with %s.\n", 521 IL_DEBUG_RATE(priv, "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) ?
524 "success" : "failure"); 524 "success" : "failure");
525 iwl3945_collect_tx_data(rs_sta, 525 il3945_collect_tx_data(rs_sta,
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
@@ -543,15 +543,15 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban
543 543
544 spin_unlock_irqrestore(&rs_sta->lock, flags); 544 spin_unlock_irqrestore(&rs_sta->lock, flags);
545 545
546 IWL_DEBUG_RATE(priv, "leave\n"); 546 IL_DEBUG_RATE(priv, "leave\n");
547} 547}
548 548
549static u16 iwl3945_get_adjacent_rate(struct iwl3945_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 index, u16 rate_mask, enum ieee80211_band band)
551{ 551{
552 u8 high = IWL_RATE_INVALID; 552 u8 high = IL_RATE_INVALID;
553 u8 low = IWL_RATE_INVALID; 553 u8 low = IL_RATE_INVALID;
554 struct iwl_priv *priv __maybe_unused = rs_sta->priv; 554 struct il_priv *priv __maybe_unused = rs_sta->priv;
555 555
556 /* 802.11A walks to the next literal adjacent rate in 556 /* 802.11A walks to the next literal adjacent rate in
557 * the rate table */ 557 * the rate table */
@@ -570,7 +570,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
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 = index + 1;
573 for (mask = (1 << i); i < IWL_RATE_COUNT_3945; 573 for (mask = (1 << i); i < IL_RATE_COUNT_3945;
574 i++, mask <<= 1) { 574 i++, mask <<= 1) {
575 if (rate_mask & mask) { 575 if (rate_mask & mask) {
576 high = i; 576 high = i;
@@ -582,36 +582,36 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
582 } 582 }
583 583
584 low = index; 584 low = index;
585 while (low != IWL_RATE_INVALID) { 585 while (low != IL_RATE_INVALID) {
586 if (rs_sta->tgg) 586 if (rs_sta->tgg)
587 low = iwl3945_rates[low].prev_rs_tgg; 587 low = il3945_rates[low].prev_rs_tgg;
588 else 588 else
589 low = iwl3945_rates[low].prev_rs; 589 low = il3945_rates[low].prev_rs;
590 if (low == IWL_RATE_INVALID) 590 if (low == IL_RATE_INVALID)
591 break; 591 break;
592 if (rate_mask & (1 << low)) 592 if (rate_mask & (1 << low))
593 break; 593 break;
594 IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); 594 IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low);
595 } 595 }
596 596
597 high = index; 597 high = index;
598 while (high != IWL_RATE_INVALID) { 598 while (high != IL_RATE_INVALID) {
599 if (rs_sta->tgg) 599 if (rs_sta->tgg)
600 high = iwl3945_rates[high].next_rs_tgg; 600 high = il3945_rates[high].next_rs_tgg;
601 else 601 else
602 high = iwl3945_rates[high].next_rs; 602 high = il3945_rates[high].next_rs;
603 if (high == IWL_RATE_INVALID) 603 if (high == IL_RATE_INVALID)
604 break; 604 break;
605 if (rate_mask & (1 << high)) 605 if (rate_mask & (1 << high))
606 break; 606 break;
607 IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); 607 IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high);
608 } 608 }
609 609
610 return (high << 8) | low; 610 return (high << 8) | low;
611} 611}
612 612
613/** 613/**
614 * iwl3945_rs_get_rate - find the rate for the requested packet 614 * il3945_rs_get_rate - find the rate for the requested packet
615 * 615 *
616 * Returns the ieee80211_rate structure allocated by the driver. 616 * Returns the ieee80211_rate structure allocated by the driver.
617 * 617 *
@@ -626,33 +626,33 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
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 */
629static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, 629static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
630 void *priv_sta, struct ieee80211_tx_rate_control *txrc) 630 void *priv_sta, struct ieee80211_tx_rate_control *txrc)
631{ 631{
632 struct ieee80211_supported_band *sband = txrc->sband; 632 struct ieee80211_supported_band *sband = txrc->sband;
633 struct sk_buff *skb = txrc->skb; 633 struct sk_buff *skb = txrc->skb;
634 u8 low = IWL_RATE_INVALID; 634 u8 low = IL_RATE_INVALID;
635 u8 high = IWL_RATE_INVALID; 635 u8 high = IL_RATE_INVALID;
636 u16 high_low; 636 u16 high_low;
637 int index; 637 int index;
638 struct iwl3945_rs_sta *rs_sta = priv_sta; 638 struct il3945_rs_sta *rs_sta = priv_sta;
639 struct iwl3945_rate_scale_data *window = NULL; 639 struct il3945_rate_scale_data *window = NULL;
640 int current_tpt = IWL_INVALID_VALUE; 640 int current_tpt = IL_INVALID_VALUE;
641 int low_tpt = IWL_INVALID_VALUE; 641 int low_tpt = IL_INVALID_VALUE;
642 int high_tpt = IWL_INVALID_VALUE; 642 int high_tpt = IL_INVALID_VALUE;
643 u32 fail_count; 643 u32 fail_count;
644 s8 scale_action = 0; 644 s8 scale_action = 0;
645 unsigned long flags; 645 unsigned long flags;
646 u16 rate_mask; 646 u16 rate_mask;
647 s8 max_rate_idx = -1; 647 s8 max_rate_idx = -1;
648 struct iwl_priv *priv __maybe_unused = (struct iwl_priv *)priv_r; 648 struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r;
649 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 649 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
650 650
651 IWL_DEBUG_RATE(priv, "enter\n"); 651 IL_DEBUG_RATE(priv, "enter\n");
652 652
653 /* Treat uninitialized rate scaling data same as non-existing. */ 653 /* Treat uninitialized rate scaling data same as non-existing. */
654 if (rs_sta && !rs_sta->priv) { 654 if (rs_sta && !rs_sta->priv) {
655 IWL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); 655 IL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n");
656 priv_sta = NULL; 656 priv_sta = NULL;
657 } 657 }
658 658
@@ -664,25 +664,25 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
664 /* get user max rate if set */ 664 /* get user max rate if set */
665 max_rate_idx = txrc->max_rate_idx; 665 max_rate_idx = txrc->max_rate_idx;
666 if ((sband->band == IEEE80211_BAND_5GHZ) && (max_rate_idx != -1)) 666 if ((sband->band == IEEE80211_BAND_5GHZ) && (max_rate_idx != -1))
667 max_rate_idx += IWL_FIRST_OFDM_RATE; 667 max_rate_idx += IL_FIRST_OFDM_RATE;
668 if ((max_rate_idx < 0) || (max_rate_idx >= IWL_RATE_COUNT)) 668 if ((max_rate_idx < 0) || (max_rate_idx >= IL_RATE_COUNT))
669 max_rate_idx = -1; 669 max_rate_idx = -1;
670 670
671 index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT_3945 - 1); 671 index = min(rs_sta->last_txrate_idx & 0xffff, IL_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 << IWL_FIRST_OFDM_RATE; 674 rate_mask = rate_mask << IL_FIRST_OFDM_RATE;
675 675
676 spin_lock_irqsave(&rs_sta->lock, flags); 676 spin_lock_irqsave(&rs_sta->lock, flags);
677 677
678 /* for recent assoc, choose best rate regarding 678 /* for recent assoc, choose best rate regarding
679 * to rssi value 679 * to rssi value
680 */ 680 */
681 if (rs_sta->start_rate != IWL_RATE_INVALID) { 681 if (rs_sta->start_rate != IL_RATE_INVALID) {
682 if (rs_sta->start_rate < index && 682 if (rs_sta->start_rate < index &&
683 (rate_mask & (1 << rs_sta->start_rate))) 683 (rate_mask & (1 << rs_sta->start_rate)))
684 index = rs_sta->start_rate; 684 index = rs_sta->start_rate;
685 rs_sta->start_rate = IWL_RATE_INVALID; 685 rs_sta->start_rate = IL_RATE_INVALID;
686 } 686 }
687 687
688 /* force user max rate if set by user */ 688 /* force user max rate if set by user */
@@ -695,11 +695,11 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
695 695
696 fail_count = window->counter - window->success_counter; 696 fail_count = window->counter - window->success_counter;
697 697
698 if (((fail_count < IWL_RATE_MIN_FAILURE_TH) && 698 if (((fail_count < IL_RATE_MIN_FAILURE_TH) &&
699 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { 699 (window->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 IWL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: " 702 IL_DEBUG_RATE(priv, "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,
@@ -708,27 +708,27 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
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 = IWL_INVALID_VALUE; 711 window->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 = window->average_tpt;
717 717
718 high_low = iwl3945_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);
720 low = high_low & 0xff; 720 low = high_low & 0xff;
721 high = (high_low >> 8) & 0xff; 721 high = (high_low >> 8) & 0xff;
722 722
723 /* If user set max rate, dont allow higher than user constrain */ 723 /* If user set max rate, dont allow higher than user constrain */
724 if ((max_rate_idx != -1) && (max_rate_idx < high)) 724 if ((max_rate_idx != -1) && (max_rate_idx < high))
725 high = IWL_RATE_INVALID; 725 high = IL_RATE_INVALID;
726 726
727 /* Collect Measured throughputs of adjacent rates */ 727 /* Collect Measured throughputs of adjacent rates */
728 if (low != IWL_RATE_INVALID) 728 if (low != IL_RATE_INVALID)
729 low_tpt = rs_sta->win[low].average_tpt; 729 low_tpt = rs_sta->win[low].average_tpt;
730 730
731 if (high != IWL_RATE_INVALID) 731 if (high != IL_RATE_INVALID)
732 high_tpt = rs_sta->win[high].average_tpt; 732 high_tpt = rs_sta->win[high].average_tpt;
733 733
734 spin_unlock_irqrestore(&rs_sta->lock, flags); 734 spin_unlock_irqrestore(&rs_sta->lock, flags);
@@ -736,51 +736,51 @@ static void iwl3945_rs_get_rate(void *priv_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 < IWL_RATE_DECREASE_TH) || !current_tpt) { 739 if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) {
740 IWL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); 740 IL_DEBUG_RATE(priv, "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,
743 * try increase */ 743 * try increase */
744 } else if ((low_tpt == IWL_INVALID_VALUE) && 744 } else if ((low_tpt == IL_INVALID_VALUE) &&
745 (high_tpt == IWL_INVALID_VALUE)) { 745 (high_tpt == IL_INVALID_VALUE)) {
746 746
747 if (high != IWL_RATE_INVALID && window->success_ratio >= IWL_RATE_INCREASE_TH) 747 if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH)
748 scale_action = 1; 748 scale_action = 1;
749 else if (low != IWL_RATE_INVALID) 749 else if (low != IL_RATE_INVALID)
750 scale_action = 0; 750 scale_action = 0;
751 751
752 /* Both adjacent throughputs are measured, but neither one has 752 /* Both adjacent throughputs are measured, but neither one has
753 * better throughput; we're using the best rate, don't change 753 * better throughput; we're using the best rate, don't change
754 * it! */ 754 * it! */
755 } else if ((low_tpt != IWL_INVALID_VALUE) && 755 } else if ((low_tpt != IL_INVALID_VALUE) &&
756 (high_tpt != IWL_INVALID_VALUE) && 756 (high_tpt != IL_INVALID_VALUE) &&
757 (low_tpt < current_tpt) && (high_tpt < current_tpt)) { 757 (low_tpt < current_tpt) && (high_tpt < current_tpt)) {
758 758
759 IWL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < " 759 IL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < "
760 "current_tpt [%d]\n", 760 "current_tpt [%d]\n",
761 low_tpt, high_tpt, current_tpt); 761 low_tpt, high_tpt, current_tpt);
762 scale_action = 0; 762 scale_action = 0;
763 763
764 /* At least one of the rates has better throughput */ 764 /* At least one of the rates has better throughput */
765 } else { 765 } else {
766 if (high_tpt != IWL_INVALID_VALUE) { 766 if (high_tpt != IL_INVALID_VALUE) {
767 767
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 >= IWL_RATE_INCREASE_TH) 771 window->success_ratio >= IL_RATE_INCREASE_TH)
772 scale_action = 1; 772 scale_action = 1;
773 else { 773 else {
774 IWL_DEBUG_RATE(priv, 774 IL_DEBUG_RATE(priv,
775 "decrease rate because of high tpt\n"); 775 "decrease rate because of high tpt\n");
776 scale_action = 0; 776 scale_action = 0;
777 } 777 }
778 } else if (low_tpt != IWL_INVALID_VALUE) { 778 } else if (low_tpt != IL_INVALID_VALUE) {
779 if (low_tpt > current_tpt) { 779 if (low_tpt > current_tpt) {
780 IWL_DEBUG_RATE(priv, 780 IL_DEBUG_RATE(priv,
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 >= IWL_RATE_INCREASE_TH) { 783 } else if (window->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;
@@ -790,8 +790,8 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
790 790
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 != IWL_RATE_INVALID) && 793 if ((scale_action == -1) && (low != IL_RATE_INVALID) &&
794 ((window->success_ratio > IWL_RATE_HIGH_TH) || 794 ((window->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
@@ -799,13 +799,13 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
799 case -1: 799 case -1:
800 800
801 /* Decrese rate */ 801 /* Decrese rate */
802 if (low != IWL_RATE_INVALID) 802 if (low != IL_RATE_INVALID)
803 index = low; 803 index = low;
804 break; 804 break;
805 805
806 case 1: 806 case 1:
807 /* Increase rate */ 807 /* Increase rate */
808 if (high != IWL_RATE_INVALID) 808 if (high != IL_RATE_INVALID)
809 index = high; 809 index = high;
810 810
811 break; 811 break;
@@ -816,32 +816,32 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
816 break; 816 break;
817 } 817 }
818 818
819 IWL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n", 819 IL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n",
820 index, scale_action, low, high); 820 index, 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 < IWL_FIRST_OFDM_RATE)) 825 if (WARN_ON_ONCE(index < IL_FIRST_OFDM_RATE))
826 index = IWL_FIRST_OFDM_RATE; 826 index = IL_FIRST_OFDM_RATE;
827 rs_sta->last_txrate_idx = index; 827 rs_sta->last_txrate_idx = index;
828 info->control.rates[0].idx = index - IWL_FIRST_OFDM_RATE; 828 info->control.rates[0].idx = index - IL_FIRST_OFDM_RATE;
829 } else { 829 } else {
830 rs_sta->last_txrate_idx = index; 830 rs_sta->last_txrate_idx = index;
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 IWL_DEBUG_RATE(priv, "leave: %d\n", index); 834 IL_DEBUG_RATE(priv, "leave: %d\n", index);
835} 835}
836 836
837#ifdef CONFIG_MAC80211_DEBUGFS 837#ifdef CONFIG_MAC80211_DEBUGFS
838static int iwl3945_open_file_generic(struct inode *inode, struct file *file) 838static int il3945_open_file_generic(struct inode *inode, struct file *file)
839{ 839{
840 file->private_data = inode->i_private; 840 file->private_data = inode->i_private;
841 return 0; 841 return 0;
842} 842}
843 843
844static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, 844static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file,
845 char __user *user_buf, 845 char __user *user_buf,
846 size_t count, loff_t *ppos) 846 size_t count, loff_t *ppos)
847{ 847{
@@ -849,7 +849,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file,
849 int desc = 0; 849 int desc = 0;
850 int j; 850 int j;
851 ssize_t ret; 851 ssize_t ret;
852 struct iwl3945_rs_sta *lq_sta = file->private_data; 852 struct il3945_rs_sta *lq_sta = file->private_data;
853 853
854 buff = kmalloc(1024, GFP_KERNEL); 854 buff = kmalloc(1024, GFP_KERNEL);
855 if (!buff) 855 if (!buff)
@@ -860,7 +860,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file,
860 lq_sta->tx_packets, 860 lq_sta->tx_packets,
861 lq_sta->last_txrate_idx, 861 lq_sta->last_txrate_idx,
862 lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); 862 lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time));
863 for (j = 0; j < IWL_RATE_COUNT_3945; j++) { 863 for (j = 0; j < IL_RATE_COUNT_3945; j++) {
864 desc += sprintf(buff+desc, 864 desc += sprintf(buff+desc,
865 "counter=%d success=%d %%=%d\n", 865 "counter=%d success=%d %%=%d\n",
866 lq_sta->win[j].counter, 866 lq_sta->win[j].counter,
@@ -873,15 +873,15 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file,
873} 873}
874 874
875static const struct file_operations rs_sta_dbgfs_stats_table_ops = { 875static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
876 .read = iwl3945_sta_dbgfs_stats_table_read, 876 .read = il3945_sta_dbgfs_stats_table_read,
877 .open = iwl3945_open_file_generic, 877 .open = il3945_open_file_generic,
878 .llseek = default_llseek, 878 .llseek = default_llseek,
879}; 879};
880 880
881static void iwl3945_add_debugfs(void *priv, void *priv_sta, 881static void il3945_add_debugfs(void *priv, void *priv_sta,
882 struct dentry *dir) 882 struct dentry *dir)
883{ 883{
884 struct iwl3945_rs_sta *lq_sta = priv_sta; 884 struct il3945_rs_sta *lq_sta = priv_sta;
885 885
886 lq_sta->rs_sta_dbgfs_stats_table_file = 886 lq_sta->rs_sta_dbgfs_stats_table_file =
887 debugfs_create_file("rate_stats_table", 0600, dir, 887 debugfs_create_file("rate_stats_table", 0600, dir,
@@ -889,9 +889,9 @@ static void iwl3945_add_debugfs(void *priv, void *priv_sta,
889 889
890} 890}
891 891
892static void iwl3945_remove_debugfs(void *priv, void *priv_sta) 892static void il3945_remove_debugfs(void *priv, void *priv_sta)
893{ 893{
894 struct iwl3945_rs_sta *lq_sta = priv_sta; 894 struct il3945_rs_sta *lq_sta = priv_sta;
895 debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); 895 debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file);
896} 896}
897#endif 897#endif
@@ -901,7 +901,7 @@ static void iwl3945_remove_debugfs(void *priv, void *priv_sta)
901 * the station is added. Since mac80211 calls this function before a 901 * the station is added. Since mac80211 calls this function before a
902 * station is added we ignore it. 902 * station is added we ignore it.
903 */ 903 */
904static void iwl3945_rs_rate_init_stub(void *priv_r, 904static void il3945_rs_rate_init_stub(void *priv_r,
905 struct ieee80211_supported_band *sband, 905 struct ieee80211_supported_band *sband,
906 struct ieee80211_sta *sta, void *priv_sta) 906 struct ieee80211_sta *sta, void *priv_sta)
907{ 907{
@@ -910,36 +910,36 @@ static void iwl3945_rs_rate_init_stub(void *priv_r,
910static struct rate_control_ops rs_ops = { 910static struct rate_control_ops rs_ops = {
911 .module = NULL, 911 .module = NULL,
912 .name = RS_NAME, 912 .name = RS_NAME,
913 .tx_status = iwl3945_rs_tx_status, 913 .tx_status = il3945_rs_tx_status,
914 .get_rate = iwl3945_rs_get_rate, 914 .get_rate = il3945_rs_get_rate,
915 .rate_init = iwl3945_rs_rate_init_stub, 915 .rate_init = il3945_rs_rate_init_stub,
916 .alloc = iwl3945_rs_alloc, 916 .alloc = il3945_rs_alloc,
917 .free = iwl3945_rs_free, 917 .free = il3945_rs_free,
918 .alloc_sta = iwl3945_rs_alloc_sta, 918 .alloc_sta = il3945_rs_alloc_sta,
919 .free_sta = iwl3945_rs_free_sta, 919 .free_sta = il3945_rs_free_sta,
920#ifdef CONFIG_MAC80211_DEBUGFS 920#ifdef CONFIG_MAC80211_DEBUGFS
921 .add_sta_debugfs = iwl3945_add_debugfs, 921 .add_sta_debugfs = il3945_add_debugfs,
922 .remove_sta_debugfs = iwl3945_remove_debugfs, 922 .remove_sta_debugfs = il3945_remove_debugfs,
923#endif 923#endif
924 924
925}; 925};
926void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) 926void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
927{ 927{
928 struct iwl_priv *priv = hw->priv; 928 struct il_priv *priv = hw->priv;
929 s32 rssi = 0; 929 s32 rssi = 0;
930 unsigned long flags; 930 unsigned long flags;
931 struct iwl3945_rs_sta *rs_sta; 931 struct il3945_rs_sta *rs_sta;
932 struct ieee80211_sta *sta; 932 struct ieee80211_sta *sta;
933 struct iwl3945_sta_priv *psta; 933 struct il3945_sta_priv *psta;
934 934
935 IWL_DEBUG_RATE(priv, "enter\n"); 935 IL_DEBUG_RATE(priv, "enter\n");
936 936
937 rcu_read_lock(); 937 rcu_read_lock();
938 938
939 sta = ieee80211_find_sta(priv->contexts[IWL_RXON_CTX_BSS].vif, 939 sta = ieee80211_find_sta(priv->contexts[IL_RXON_CTX_BSS].vif,
940 priv->stations[sta_id].sta.sta.addr); 940 priv->stations[sta_id].sta.sta.addr);
941 if (!sta) { 941 if (!sta) {
942 IWL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); 942 IL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n");
943 rcu_read_unlock(); 943 rcu_read_unlock();
944 return; 944 return;
945 } 945 }
@@ -953,16 +953,16 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
953 switch (priv->band) { 953 switch (priv->band) {
954 case IEEE80211_BAND_2GHZ: 954 case IEEE80211_BAND_2GHZ:
955 /* TODO: this always does G, not a regression */ 955 /* TODO: this always does G, not a regression */
956 if (priv->contexts[IWL_RXON_CTX_BSS].active.flags & 956 if (priv->contexts[IL_RXON_CTX_BSS].active.flags &
957 RXON_FLG_TGG_PROTECT_MSK) { 957 RXON_FLG_TGG_PROTECT_MSK) {
958 rs_sta->tgg = 1; 958 rs_sta->tgg = 1;
959 rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; 959 rs_sta->expected_tpt = il3945_expected_tpt_g_prot;
960 } else 960 } else
961 rs_sta->expected_tpt = iwl3945_expected_tpt_g; 961 rs_sta->expected_tpt = il3945_expected_tpt_g;
962 break; 962 break;
963 963
964 case IEEE80211_BAND_5GHZ: 964 case IEEE80211_BAND_5GHZ:
965 rs_sta->expected_tpt = iwl3945_expected_tpt_a; 965 rs_sta->expected_tpt = il3945_expected_tpt_a;
966 break; 966 break;
967 case IEEE80211_NUM_BANDS: 967 case IEEE80211_NUM_BANDS:
968 BUG(); 968 BUG();
@@ -973,24 +973,24 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
973 973
974 rssi = priv->_3945.last_rx_rssi; 974 rssi = priv->_3945.last_rx_rssi;
975 if (rssi == 0) 975 if (rssi == 0)
976 rssi = IWL_MIN_RSSI_VAL; 976 rssi = IL_MIN_RSSI_VAL;
977 977
978 IWL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi); 978 IL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi);
979 979
980 rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band); 980 rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, priv->band);
981 981
982 IWL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: " 982 IL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: "
983 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, 983 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate,
984 iwl3945_rates[rs_sta->start_rate].plcp); 984 il3945_rates[rs_sta->start_rate].plcp);
985 rcu_read_unlock(); 985 rcu_read_unlock();
986} 986}
987 987
988int iwl3945_rate_control_register(void) 988int il3945_rate_control_register(void)
989{ 989{
990 return ieee80211_rate_control_register(&rs_ops); 990 return ieee80211_rate_control_register(&rs_ops);
991} 991}
992 992
993void iwl3945_rate_control_unregister(void) 993void il3945_rate_control_unregister(void)
994{ 994{
995 ieee80211_rate_control_unregister(&rs_ops); 995 ieee80211_rate_control_unregister(&rs_ops);
996} 996}