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/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-100.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-led.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c86
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c130
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c130
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c165
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c42
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c109
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c104
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c644
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c85
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c482
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h103
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h19
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h20
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c35
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rfkill.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c37
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c62
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-spectrum.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c36
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c54
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c1392
33 files changed, 1650 insertions, 2239 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index fec2fbf8dc02..ddc8b31b2608 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -8,7 +8,7 @@ iwlcore-$(CONFIG_IWLWIFI_RFKILL) += iwl-rfkill.o
8iwlcore-$(CONFIG_IWLAGN_SPECTRUM_MEASUREMENT) += iwl-spectrum.o 8iwlcore-$(CONFIG_IWLAGN_SPECTRUM_MEASUREMENT) += iwl-spectrum.o
9 9
10obj-$(CONFIG_IWLAGN) += iwlagn.o 10obj-$(CONFIG_IWLAGN) += iwlagn.o
11iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-hcmd-check.o 11iwlagn-objs := iwl-agn.o iwl-agn-rs.o
12 12
13iwlagn-$(CONFIG_IWL4965) += iwl-4965.o 13iwlagn-$(CONFIG_IWL4965) += iwl-4965.o
14iwlagn-$(CONFIG_IWL5000) += iwl-5000.o 14iwlagn-$(CONFIG_IWL5000) += iwl-5000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-100.c b/drivers/net/wireless/iwlwifi/iwl-100.c
index dbadaf44f570..11d206abb710 100644
--- a/drivers/net/wireless/iwlwifi/iwl-100.c
+++ b/drivers/net/wireless/iwlwifi/iwl-100.c
@@ -46,7 +46,7 @@
46#include "iwl-5000-hw.h" 46#include "iwl-5000-hw.h"
47 47
48/* Highest firmware API version supported */ 48/* Highest firmware API version supported */
49#define IWL100_UCODE_API_MAX 1 49#define IWL100_UCODE_API_MAX 2
50 50
51/* Lowest firmware API version supported */ 51/* Lowest firmware API version supported */
52#define IWL100_UCODE_API_MIN 1 52#define IWL100_UCODE_API_MIN 1
@@ -66,5 +66,8 @@ struct iwl_cfg iwl100_bgn_cfg = {
66 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 66 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
67 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 67 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
68 .mod_params = &iwl50_mod_params, 68 .mod_params = &iwl50_mod_params,
69 .valid_tx_ant = ANT_A,
70 .valid_rx_ant = ANT_AB,
71 .need_pll_cfg = true,
69}; 72};
70 73
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-led.c b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
index fab137365000..a973ac13a1d5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-led.c
@@ -137,7 +137,7 @@ static int iwl3945_led_off(struct iwl_priv *priv, int led_id)
137 .off = 0, 137 .off = 0,
138 .interval = IWL_DEF_LED_INTRVL 138 .interval = IWL_DEF_LED_INTRVL
139 }; 139 };
140 IWL_DEBUG_LED("led off %d\n", led_id); 140 IWL_DEBUG_LED(priv, "led off %d\n", led_id);
141 return iwl_send_led_cmd(priv, &led_cmd); 141 return iwl_send_led_cmd(priv, &led_cmd);
142} 142}
143 143
@@ -174,7 +174,7 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
174 case LED_FULL: 174 case LED_FULL:
175 if (led->type == IWL_LED_TRG_ASSOC) { 175 if (led->type == IWL_LED_TRG_ASSOC) {
176 priv->allow_blinking = 1; 176 priv->allow_blinking = 1;
177 IWL_DEBUG_LED("MAC is associated\n"); 177 IWL_DEBUG_LED(priv, "MAC is associated\n");
178 } 178 }
179 if (led->led_on) 179 if (led->led_on)
180 led->led_on(priv, IWL_LED_LINK); 180 led->led_on(priv, IWL_LED_LINK);
@@ -182,7 +182,7 @@ static void iwl3945_led_brightness_set(struct led_classdev *led_cdev,
182 case LED_OFF: 182 case LED_OFF:
183 if (led->type == IWL_LED_TRG_ASSOC) { 183 if (led->type == IWL_LED_TRG_ASSOC) {
184 priv->allow_blinking = 0; 184 priv->allow_blinking = 0;
185 IWL_DEBUG_LED("MAC is disassociated\n"); 185 IWL_DEBUG_LED(priv, "MAC is disassociated\n");
186 } 186 }
187 if (led->led_off) 187 if (led->led_off)
188 led->led_off(priv, IWL_LED_LINK); 188 led->led_off(priv, IWL_LED_LINK);
@@ -316,7 +316,7 @@ int iwl3945_led_register(struct iwl_priv *priv)
316 316
317 trigger = ieee80211_get_radio_led_name(priv->hw); 317 trigger = ieee80211_get_radio_led_name(priv->hw);
318 snprintf(priv->led39[IWL_LED_TRG_RADIO].name, 318 snprintf(priv->led39[IWL_LED_TRG_RADIO].name,
319 sizeof(priv->led39[IWL_LED_TRG_RADIO].name), "iwl-%s:radio", 319 sizeof(priv->led39[IWL_LED_TRG_RADIO].name), "iwl-%s::radio",
320 wiphy_name(priv->hw->wiphy)); 320 wiphy_name(priv->hw->wiphy));
321 321
322 priv->led39[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on; 322 priv->led39[IWL_LED_TRG_RADIO].led_on = iwl3945_led_on;
@@ -332,7 +332,7 @@ int iwl3945_led_register(struct iwl_priv *priv)
332 332
333 trigger = ieee80211_get_assoc_led_name(priv->hw); 333 trigger = ieee80211_get_assoc_led_name(priv->hw);
334 snprintf(priv->led39[IWL_LED_TRG_ASSOC].name, 334 snprintf(priv->led39[IWL_LED_TRG_ASSOC].name,
335 sizeof(priv->led39[IWL_LED_TRG_ASSOC].name), "iwl-%s:assoc", 335 sizeof(priv->led39[IWL_LED_TRG_ASSOC].name), "iwl-%s::assoc",
336 wiphy_name(priv->hw->wiphy)); 336 wiphy_name(priv->hw->wiphy));
337 337
338 ret = iwl3945_led_register_led(priv, 338 ret = iwl3945_led_register_led(priv,
@@ -349,7 +349,7 @@ int iwl3945_led_register(struct iwl_priv *priv)
349 349
350 trigger = ieee80211_get_rx_led_name(priv->hw); 350 trigger = ieee80211_get_rx_led_name(priv->hw);
351 snprintf(priv->led39[IWL_LED_TRG_RX].name, 351 snprintf(priv->led39[IWL_LED_TRG_RX].name,
352 sizeof(priv->led39[IWL_LED_TRG_RX].name), "iwl-%s:RX", 352 sizeof(priv->led39[IWL_LED_TRG_RX].name), "iwl-%s::RX",
353 wiphy_name(priv->hw->wiphy)); 353 wiphy_name(priv->hw->wiphy));
354 354
355 ret = iwl3945_led_register_led(priv, 355 ret = iwl3945_led_register_led(priv,
@@ -365,7 +365,7 @@ int iwl3945_led_register(struct iwl_priv *priv)
365 365
366 trigger = ieee80211_get_tx_led_name(priv->hw); 366 trigger = ieee80211_get_tx_led_name(priv->hw);
367 snprintf(priv->led39[IWL_LED_TRG_TX].name, 367 snprintf(priv->led39[IWL_LED_TRG_TX].name,
368 sizeof(priv->led39[IWL_LED_TRG_TX].name), "iwl-%s:TX", 368 sizeof(priv->led39[IWL_LED_TRG_TX].name), "iwl-%s::TX",
369 wiphy_name(priv->hw->wiphy)); 369 wiphy_name(priv->hw->wiphy));
370 370
371 ret = iwl3945_led_register_led(priv, 371 ret = iwl3945_led_register_led(priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 044abf734eb6..7db8198c6253 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -183,7 +183,7 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta)
183 int unflushed = 0; 183 int unflushed = 0;
184 int i; 184 int i;
185 unsigned long flags; 185 unsigned long flags;
186 struct iwl_priv *priv = rs_sta->priv; 186 struct iwl_priv *priv __maybe_unused = rs_sta->priv;
187 187
188 /* 188 /*
189 * For each rate, if we have collected data on that rate 189 * For each rate, if we have collected data on that rate
@@ -197,7 +197,7 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta)
197 spin_lock_irqsave(&rs_sta->lock, flags); 197 spin_lock_irqsave(&rs_sta->lock, flags);
198 if (time_after(jiffies, rs_sta->win[i].stamp + 198 if (time_after(jiffies, rs_sta->win[i].stamp +
199 IWL_RATE_WIN_FLUSH)) { 199 IWL_RATE_WIN_FLUSH)) {
200 IWL_DEBUG_RATE("flushing %d samples of rate " 200 IWL_DEBUG_RATE(priv, "flushing %d samples of rate "
201 "index %d\n", 201 "index %d\n",
202 rs_sta->win[i].counter, i); 202 rs_sta->win[i].counter, i);
203 iwl3945_clear_window(&rs_sta->win[i]); 203 iwl3945_clear_window(&rs_sta->win[i]);
@@ -216,12 +216,12 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta)
216static void iwl3945_bg_rate_scale_flush(unsigned long data) 216static void iwl3945_bg_rate_scale_flush(unsigned long data)
217{ 217{
218 struct iwl3945_rs_sta *rs_sta = (void *)data; 218 struct iwl3945_rs_sta *rs_sta = (void *)data;
219 struct iwl_priv *priv = rs_sta->priv; 219 struct iwl_priv *priv __maybe_unused = rs_sta->priv;
220 int unflushed = 0; 220 int unflushed = 0;
221 unsigned long flags; 221 unsigned long flags;
222 u32 packet_count, duration, pps; 222 u32 packet_count, duration, pps;
223 223
224 IWL_DEBUG_RATE("enter\n"); 224 IWL_DEBUG_RATE(priv, "enter\n");
225 225
226 unflushed = iwl3945_rate_scale_flush_windows(rs_sta); 226 unflushed = iwl3945_rate_scale_flush_windows(rs_sta);
227 227
@@ -236,7 +236,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
236 duration = 236 duration =
237 jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); 237 jiffies_to_msecs(jiffies - rs_sta->last_partial_flush);
238 238
239 IWL_DEBUG_RATE("Tx'd %d packets in %dms\n", 239 IWL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n",
240 packet_count, duration); 240 packet_count, duration);
241 241
242 /* Determine packets per second */ 242 /* Determine packets per second */
@@ -256,7 +256,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
256 256
257 rs_sta->flush_time = msecs_to_jiffies(duration); 257 rs_sta->flush_time = msecs_to_jiffies(duration);
258 258
259 IWL_DEBUG_RATE("new flush period: %d msec ave %d\n", 259 IWL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n",
260 duration, packet_count); 260 duration, packet_count);
261 261
262 mod_timer(&rs_sta->rate_scale_flush, jiffies + 262 mod_timer(&rs_sta->rate_scale_flush, jiffies +
@@ -274,7 +274,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data)
274 274
275 spin_unlock_irqrestore(&rs_sta->lock, flags); 275 spin_unlock_irqrestore(&rs_sta->lock, flags);
276 276
277 IWL_DEBUG_RATE("leave\n"); 277 IWL_DEBUG_RATE(priv, "leave\n");
278} 278}
279 279
280/** 280/**
@@ -290,10 +290,10 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
290{ 290{
291 unsigned long flags; 291 unsigned long flags;
292 s32 fail_count; 292 s32 fail_count;
293 struct iwl_priv *priv = rs_sta->priv; 293 struct iwl_priv *priv __maybe_unused = rs_sta->priv;
294 294
295 if (!retries) { 295 if (!retries) {
296 IWL_DEBUG_RATE("leave: retries == 0 -- should be at least 1\n"); 296 IWL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n");
297 return; 297 return;
298 } 298 }
299 299
@@ -347,7 +347,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
347 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 347 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
348 int i; 348 int i;
349 349
350 IWL_DEBUG_RATE("enter\n"); 350 IWL_DEBUG_RATE(priv, "enter\n");
351 351
352 /* TODO: what is a good starting rate for STA? About middle? Maybe not 352 /* TODO: what is a good starting rate for STA? About middle? Maybe not
353 * the lowest or the highest rate.. Could consider using RSSI from 353 * the lowest or the highest rate.. Could consider using RSSI from
@@ -370,7 +370,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
370 } 370 }
371 371
372 372
373 IWL_DEBUG_RATE("leave\n"); 373 IWL_DEBUG_RATE(priv, "leave\n");
374} 374}
375 375
376static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) 376static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
@@ -396,11 +396,11 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp)
396 * as well just put all the information there. 396 * as well just put all the information there.
397 */ 397 */
398 398
399 IWL_DEBUG_RATE("enter\n"); 399 IWL_DEBUG_RATE(priv, "enter\n");
400 400
401 rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp); 401 rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp);
402 if (!rs_sta) { 402 if (!rs_sta) {
403 IWL_DEBUG_RATE("leave: ENOMEM\n"); 403 IWL_DEBUG_RATE(priv, "leave: ENOMEM\n");
404 return NULL; 404 return NULL;
405 } 405 }
406 406
@@ -428,7 +428,7 @@ static void *rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp)
428 for (i = 0; i < IWL_RATE_COUNT_3945; 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(priv, "leave\n");
432 432
433 return rs_sta; 433 return rs_sta;
434} 434}
@@ -438,14 +438,14 @@ static void rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta,
438{ 438{
439 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; 439 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv;
440 struct iwl3945_rs_sta *rs_sta = priv_sta; 440 struct iwl3945_rs_sta *rs_sta = priv_sta;
441 struct iwl_priv *priv = rs_sta->priv; 441 struct iwl_priv *priv __maybe_unused = rs_sta->priv;
442 442
443 psta->rs_sta = NULL; 443 psta->rs_sta = NULL;
444 444
445 IWL_DEBUG_RATE("enter\n"); 445 IWL_DEBUG_RATE(priv, "enter\n");
446 del_timer_sync(&rs_sta->rate_scale_flush); 446 del_timer_sync(&rs_sta->rate_scale_flush);
447 kfree(rs_sta); 447 kfree(rs_sta);
448 IWL_DEBUG_RATE("leave\n"); 448 IWL_DEBUG_RATE(priv, "leave\n");
449} 449}
450 450
451 451
@@ -466,18 +466,18 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
466 struct iwl3945_rs_sta *rs_sta = priv_sta; 466 struct iwl3945_rs_sta *rs_sta = priv_sta;
467 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 467 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
468 468
469 IWL_DEBUG_RATE("enter\n"); 469 IWL_DEBUG_RATE(priv, "enter\n");
470 470
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_3945)) { 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(priv, "leave: Rate out of bounds: %d\n", first_index);
476 return; 476 return;
477 } 477 }
478 478
479 if (!priv_sta) { 479 if (!priv_sta) {
480 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 480 IWL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n");
481 return; 481 return;
482 } 482 }
483 483
@@ -511,7 +511,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
511 iwl3945_collect_tx_data(rs_sta, 511 iwl3945_collect_tx_data(rs_sta,
512 &rs_sta->win[scale_rate_index], 512 &rs_sta->win[scale_rate_index],
513 0, current_count, scale_rate_index); 513 0, current_count, scale_rate_index);
514 IWL_DEBUG_RATE("Update rate %d for %d retries.\n", 514 IWL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n",
515 scale_rate_index, current_count); 515 scale_rate_index, current_count);
516 516
517 retries -= current_count; 517 retries -= current_count;
@@ -521,7 +521,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
521 521
522 522
523 /* Update the last index window with success/failure based on ACK */ 523 /* Update the last index window with success/failure based on ACK */
524 IWL_DEBUG_RATE("Update rate %d with %s.\n", 524 IWL_DEBUG_RATE(priv, "Update rate %d with %s.\n",
525 last_index, 525 last_index,
526 (info->flags & IEEE80211_TX_STAT_ACK) ? 526 (info->flags & IEEE80211_TX_STAT_ACK) ?
527 "success" : "failure"); 527 "success" : "failure");
@@ -546,7 +546,7 @@ static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband
546 546
547 spin_unlock_irqrestore(&rs_sta->lock, flags); 547 spin_unlock_irqrestore(&rs_sta->lock, flags);
548 548
549 IWL_DEBUG_RATE("leave\n"); 549 IWL_DEBUG_RATE(priv, "leave\n");
550 550
551 return; 551 return;
552} 552}
@@ -556,7 +556,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
556{ 556{
557 u8 high = IWL_RATE_INVALID; 557 u8 high = IWL_RATE_INVALID;
558 u8 low = IWL_RATE_INVALID; 558 u8 low = IWL_RATE_INVALID;
559 struct iwl_priv *priv = rs_sta->priv; 559 struct iwl_priv *priv __maybe_unused = rs_sta->priv;
560 560
561 /* 802.11A walks to the next literal adjacent rate in 561 /* 802.11A walks to the next literal adjacent rate in
562 * the rate table */ 562 * the rate table */
@@ -596,7 +596,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
596 break; 596 break;
597 if (rate_mask & (1 << low)) 597 if (rate_mask & (1 << low))
598 break; 598 break;
599 IWL_DEBUG_RATE("Skipping masked lower rate: %d\n", low); 599 IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low);
600 } 600 }
601 601
602 high = index; 602 high = index;
@@ -609,7 +609,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
609 break; 609 break;
610 if (rate_mask & (1 << high)) 610 if (rate_mask & (1 << high))
611 break; 611 break;
612 IWL_DEBUG_RATE("Skipping masked higher rate: %d\n", high); 612 IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high);
613 } 613 }
614 614
615 return (high << 8) | low; 615 return (high << 8) | low;
@@ -655,7 +655,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
655 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 655 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
656 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 656 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
657 657
658 IWL_DEBUG_RATE("enter\n"); 658 IWL_DEBUG_RATE(priv, "enter\n");
659 659
660 if (sta) 660 if (sta)
661 rate_mask = sta->supp_rates[sband->band]; 661 rate_mask = sta->supp_rates[sband->band];
@@ -666,7 +666,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
666 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || 666 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
667 is_multicast_ether_addr(hdr->addr1) || 667 is_multicast_ether_addr(hdr->addr1) ||
668 !sta || !priv_sta) { 668 !sta || !priv_sta) {
669 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 669 IWL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n");
670 if (!rate_mask) 670 if (!rate_mask)
671 info->control.rates[0].idx = 671 info->control.rates[0].idx =
672 rate_lowest_index(sband, NULL); 672 rate_lowest_index(sband, NULL);
@@ -693,7 +693,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
693 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1); 693 u8 sta_id = iwl3945_hw_find_station(priv, hdr->addr1);
694 694
695 if (sta_id == IWL_INVALID_STATION) { 695 if (sta_id == IWL_INVALID_STATION) {
696 IWL_DEBUG_RATE("LQ: ADD station %pm\n", 696 IWL_DEBUG_RATE(priv, "LQ: ADD station %pm\n",
697 hdr->addr1); 697 hdr->addr1);
698 sta_id = iwl3945_add_station(priv, 698 sta_id = iwl3945_add_station(priv,
699 hdr->addr1, 0, CMD_ASYNC); 699 hdr->addr1, 0, CMD_ASYNC);
@@ -728,7 +728,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
728 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { 728 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) {
729 spin_unlock_irqrestore(&rs_sta->lock, flags); 729 spin_unlock_irqrestore(&rs_sta->lock, flags);
730 730
731 IWL_DEBUG_RATE("Invalid average_tpt on rate %d: " 731 IWL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: "
732 "counter: %d, success_counter: %d, " 732 "counter: %d, success_counter: %d, "
733 "expected_tpt is %sNULL\n", 733 "expected_tpt is %sNULL\n",
734 index, 734 index,
@@ -761,7 +761,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
761 scale_action = 1; 761 scale_action = 1;
762 762
763 if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { 763 if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) {
764 IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); 764 IWL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n");
765 scale_action = -1; 765 scale_action = -1;
766 } else if ((low_tpt == IWL_INVALID_VALUE) && 766 } else if ((low_tpt == IWL_INVALID_VALUE) &&
767 (high_tpt == IWL_INVALID_VALUE)) 767 (high_tpt == IWL_INVALID_VALUE))
@@ -769,7 +769,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
769 else if ((low_tpt != IWL_INVALID_VALUE) && 769 else if ((low_tpt != IWL_INVALID_VALUE) &&
770 (high_tpt != IWL_INVALID_VALUE) && 770 (high_tpt != IWL_INVALID_VALUE) &&
771 (low_tpt < current_tpt) && (high_tpt < current_tpt)) { 771 (low_tpt < current_tpt) && (high_tpt < current_tpt)) {
772 IWL_DEBUG_RATE("No action -- low [%d] & high [%d] < " 772 IWL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < "
773 "current_tpt [%d]\n", 773 "current_tpt [%d]\n",
774 low_tpt, high_tpt, current_tpt); 774 low_tpt, high_tpt, current_tpt);
775 scale_action = 0; 775 scale_action = 0;
@@ -778,14 +778,14 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
778 if (high_tpt > current_tpt) 778 if (high_tpt > current_tpt)
779 scale_action = 1; 779 scale_action = 1;
780 else { 780 else {
781 IWL_DEBUG_RATE 781 IWL_DEBUG_RATE(priv,
782 ("decrease rate because of high tpt\n"); 782 "decrease rate because of high tpt\n");
783 scale_action = -1; 783 scale_action = -1;
784 } 784 }
785 } else if (low_tpt != IWL_INVALID_VALUE) { 785 } else if (low_tpt != IWL_INVALID_VALUE) {
786 if (low_tpt > current_tpt) { 786 if (low_tpt > current_tpt) {
787 IWL_DEBUG_RATE 787 IWL_DEBUG_RATE(priv,
788 ("decrease rate because of low tpt\n"); 788 "decrease rate because of low tpt\n");
789 scale_action = -1; 789 scale_action = -1;
790 } else 790 } else
791 scale_action = 1; 791 scale_action = 1;
@@ -797,7 +797,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
797 scale_action = 0; 797 scale_action = 0;
798 } else if (scale_action == 1) { 798 } else if (scale_action == 1) {
799 if (window->success_ratio < IWL_SUCCESS_UP_TH) { 799 if (window->success_ratio < IWL_SUCCESS_UP_TH) {
800 IWL_DEBUG_RATE("No action -- success_ratio [%d] < " 800 IWL_DEBUG_RATE(priv, "No action -- success_ratio [%d] < "
801 "SUCCESS UP\n", window->success_ratio); 801 "SUCCESS UP\n", window->success_ratio);
802 scale_action = 0; 802 scale_action = 0;
803 } 803 }
@@ -820,7 +820,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
820 break; 820 break;
821 } 821 }
822 822
823 IWL_DEBUG_RATE("Selected %d (action %d) - low %d high %d\n", 823 IWL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n",
824 index, scale_action, low, high); 824 index, scale_action, low, high);
825 825
826 out: 826 out:
@@ -832,7 +832,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta,
832 else 832 else
833 info->control.rates[0].idx = rs_sta->last_txrate_idx; 833 info->control.rates[0].idx = rs_sta->last_txrate_idx;
834 834
835 IWL_DEBUG_RATE("leave: %d\n", index); 835 IWL_DEBUG_RATE(priv, "leave: %d\n", index);
836} 836}
837 837
838#ifdef CONFIG_MAC80211_DEBUGFS 838#ifdef CONFIG_MAC80211_DEBUGFS
@@ -915,7 +915,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
915 struct ieee80211_sta *sta; 915 struct ieee80211_sta *sta;
916 struct iwl3945_sta_priv *psta; 916 struct iwl3945_sta_priv *psta;
917 917
918 IWL_DEBUG_RATE("enter\n"); 918 IWL_DEBUG_RATE(priv, "enter\n");
919 919
920 rcu_read_lock(); 920 rcu_read_lock();
921 921
@@ -934,7 +934,7 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
934 switch (priv->band) { 934 switch (priv->band) {
935 case IEEE80211_BAND_2GHZ: 935 case IEEE80211_BAND_2GHZ:
936 /* TODO: this always does G, not a regression */ 936 /* TODO: this always does G, not a regression */
937 if (priv->active39_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) { 937 if (priv->active_rxon.flags & RXON_FLG_TGG_PROTECT_MSK) {
938 rs_sta->tgg = 1; 938 rs_sta->tgg = 1;
939 rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; 939 rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot;
940 } else 940 } else
@@ -955,11 +955,11 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
955 if (rssi == 0) 955 if (rssi == 0)
956 rssi = IWL_MIN_RSSI_VAL; 956 rssi = IWL_MIN_RSSI_VAL;
957 957
958 IWL_DEBUG(IWL_DL_INFO | IWL_DL_RATE, "Network RSSI: %d\n", rssi); 958 IWL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi);
959 959
960 rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band); 960 rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band);
961 961
962 IWL_DEBUG_RATE("leave: rssi %d assign rate index: " 962 IWL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: "
963 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, 963 "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate,
964 iwl3945_rates[rs_sta->start_rate].plcp); 964 iwl3945_rates[rs_sta->start_rate].plcp);
965 rcu_read_unlock(); 965 rcu_read_unlock();
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 12f93b6207d6..cb6db4525dc3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -170,7 +170,7 @@ void iwl3945_disable_events(struct iwl_priv *priv)
170 iwl_release_nic_access(priv); 170 iwl_release_nic_access(priv);
171 171
172 if (IWL_EVT_DISABLE && (array_size == IWL_EVT_DISABLE_SIZE)) { 172 if (IWL_EVT_DISABLE && (array_size == IWL_EVT_DISABLE_SIZE)) {
173 IWL_DEBUG_INFO("Disabling selected uCode log events at 0x%x\n", 173 IWL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n",
174 disable_ptr); 174 disable_ptr);
175 ret = iwl_grab_nic_access(priv); 175 ret = iwl_grab_nic_access(priv);
176 for (i = 0; i < IWL_EVT_DISABLE_SIZE; i++) 176 for (i = 0; i < IWL_EVT_DISABLE_SIZE; i++)
@@ -180,9 +180,9 @@ void iwl3945_disable_events(struct iwl_priv *priv)
180 180
181 iwl_release_nic_access(priv); 181 iwl_release_nic_access(priv);
182 } else { 182 } else {
183 IWL_DEBUG_INFO("Selected uCode log events may be disabled\n"); 183 IWL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n");
184 IWL_DEBUG_INFO(" by writing \"1\"s into disable bitmap\n"); 184 IWL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n");
185 IWL_DEBUG_INFO(" in SRAM at 0x%x, size %d u32s\n", 185 IWL_DEBUG_INFO(priv, " in SRAM at 0x%x, size %d u32s\n",
186 disable_ptr, array_size); 186 disable_ptr, array_size);
187 } 187 }
188 188
@@ -251,7 +251,7 @@ int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate)
251 break; 251 break;
252 case IEEE80211_BAND_2GHZ: 252 case IEEE80211_BAND_2GHZ:
253 if (!(priv->sta_supp_rates & IWL_OFDM_RATES_MASK) && 253 if (!(priv->sta_supp_rates & IWL_OFDM_RATES_MASK) &&
254 iwl3945_is_associated(priv)) { 254 iwl_is_associated(priv)) {
255 if (rate == IWL_RATE_11M_INDEX) 255 if (rate == IWL_RATE_11M_INDEX)
256 next_rate = IWL_RATE_5M_INDEX; 256 next_rate = IWL_RATE_5M_INDEX;
257 } 257 }
@@ -338,11 +338,11 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv,
338 info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? 338 info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ?
339 IEEE80211_TX_STAT_ACK : 0; 339 IEEE80211_TX_STAT_ACK : 0;
340 340
341 IWL_DEBUG_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", 341 IWL_DEBUG_TX(priv, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n",
342 txq_id, iwl3945_get_tx_fail_reason(status), status, 342 txq_id, iwl3945_get_tx_fail_reason(status), status,
343 tx_resp->rate, tx_resp->failure_frame); 343 tx_resp->rate, tx_resp->failure_frame);
344 344
345 IWL_DEBUG_TX_REPLY("Tx queue reclaim %d\n", index); 345 IWL_DEBUG_TX_REPLY(priv, "Tx queue reclaim %d\n", index);
346 iwl3945_tx_queue_reclaim(priv, txq_id, index); 346 iwl3945_tx_queue_reclaim(priv, txq_id, index);
347 347
348 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK)) 348 if (iwl_check_bits(status, TX_ABORT_REQUIRED_MSK))
@@ -362,7 +362,7 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv,
362void iwl3945_hw_rx_statistics(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) 362void iwl3945_hw_rx_statistics(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
363{ 363{
364 struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 364 struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
365 IWL_DEBUG_RX("Statistics notification received (%d vs %d).\n", 365 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
366 (int)sizeof(struct iwl3945_notif_statistics), 366 (int)sizeof(struct iwl3945_notif_statistics),
367 le32_to_cpu(pkt->len)); 367 le32_to_cpu(pkt->len));
368 368
@@ -496,13 +496,13 @@ static void _iwl3945_dbg_report_frame(struct iwl_priv *priv,
496 * MAC addresses show just the last byte (for brevity), 496 * MAC addresses show just the last byte (for brevity),
497 * but you can hack it to show more, if you'd like to. */ 497 * but you can hack it to show more, if you'd like to. */
498 if (dataframe) 498 if (dataframe)
499 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, " 499 IWL_DEBUG_RX(priv, "%s: mhd=0x%04x, dst=0x%02x, "
500 "len=%u, rssi=%d, chnl=%d, rate=%d, \n", 500 "len=%u, rssi=%d, chnl=%d, rate=%d, \n",
501 title, le16_to_cpu(fc), header->addr1[5], 501 title, le16_to_cpu(fc), header->addr1[5],
502 length, rssi, channel, rate); 502 length, rssi, channel, rate);
503 else { 503 else {
504 /* src/dst addresses assume managed mode */ 504 /* src/dst addresses assume managed mode */
505 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, " 505 IWL_DEBUG_RX(priv, "%s: 0x%04x, dst=0x%02x, "
506 "src=0x%02x, rssi=%u, tim=%lu usec, " 506 "src=0x%02x, rssi=%u, tim=%lu usec, "
507 "phy=0x%02x, chnl=%d\n", 507 "phy=0x%02x, chnl=%d\n",
508 title, le16_to_cpu(fc), header->addr1[5], 508 title, le16_to_cpu(fc), header->addr1[5],
@@ -563,14 +563,14 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv,
563 563
564 /* We received data from the HW, so stop the watchdog */ 564 /* We received data from the HW, so stop the watchdog */
565 if (unlikely((len + IWL39_RX_FRAME_SIZE) > skb_tailroom(rxb->skb))) { 565 if (unlikely((len + IWL39_RX_FRAME_SIZE) > skb_tailroom(rxb->skb))) {
566 IWL_DEBUG_DROP("Corruption detected!\n"); 566 IWL_DEBUG_DROP(priv, "Corruption detected!\n");
567 return; 567 return;
568 } 568 }
569 569
570 /* We only process data packets if the interface is open */ 570 /* We only process data packets if the interface is open */
571 if (unlikely(!priv->is_open)) { 571 if (unlikely(!priv->is_open)) {
572 IWL_DEBUG_DROP_LIMIT 572 IWL_DEBUG_DROP_LIMIT(priv,
573 ("Dropping packet while interface is not open.\n"); 573 "Dropping packet while interface is not open.\n");
574 return; 574 return;
575 } 575 }
576 576
@@ -579,7 +579,8 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv,
579 skb_put(rxb->skb, le16_to_cpu(rx_hdr->len)); 579 skb_put(rxb->skb, le16_to_cpu(rx_hdr->len));
580 580
581 if (!iwl3945_mod_params.sw_crypto) 581 if (!iwl3945_mod_params.sw_crypto)
582 iwl3945_set_decrypted_flag(priv, rxb->skb, 582 iwl_set_decrypted_flag(priv,
583 (struct ieee80211_hdr *)rxb->skb->data,
583 le32_to_cpu(rx_end->status), stats); 584 le32_to_cpu(rx_end->status), stats);
584 585
585#ifdef CONFIG_IWL3945_LEDS 586#ifdef CONFIG_IWL3945_LEDS
@@ -625,15 +626,14 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv,
625 rx_status.flag |= RX_FLAG_SHORTPRE; 626 rx_status.flag |= RX_FLAG_SHORTPRE;
626 627
627 if ((unlikely(rx_stats->phy_count > 20))) { 628 if ((unlikely(rx_stats->phy_count > 20))) {
628 IWL_DEBUG_DROP 629 IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n",
629 ("dsp size out of range [0,20]: " 630 rx_stats->phy_count);
630 "%d/n", rx_stats->phy_count);
631 return; 631 return;
632 } 632 }
633 633
634 if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) 634 if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR)
635 || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { 635 || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {
636 IWL_DEBUG_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); 636 IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status);
637 return; 637 return;
638 } 638 }
639 639
@@ -672,7 +672,7 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv,
672 } 672 }
673 673
674 674
675 IWL_DEBUG_STATS("Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n", 675 IWL_DEBUG_STATS(priv, "Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n",
676 rx_status.signal, rx_status.noise, rx_status.qual, 676 rx_status.signal, rx_status.noise, rx_status.qual,
677 rx_stats_sig_avg, rx_stats_noise_diff); 677 rx_stats_sig_avg, rx_stats_noise_diff);
678 678
@@ -680,7 +680,7 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv,
680 680
681 network_packet = iwl3945_is_network_packet(priv, header); 681 network_packet = iwl3945_is_network_packet(priv, header);
682 682
683 IWL_DEBUG_STATS_LIMIT("[%c] %d RSSI:%d Signal:%u, Noise:%u, Rate:%u\n", 683 IWL_DEBUG_STATS_LIMIT(priv, "[%c] %d RSSI:%d Signal:%u, Noise:%u, Rate:%u\n",
684 network_packet ? '*' : ' ', 684 network_packet ? '*' : ' ',
685 le16_to_cpu(rx_hdr->channel), 685 le16_to_cpu(rx_hdr->channel),
686 rx_status.signal, rx_status.signal, 686 rx_status.signal, rx_status.signal,
@@ -798,7 +798,7 @@ u8 iwl3945_hw_find_station(struct iwl_priv *priv, const u8 *addr)
798 goto out; 798 goto out;
799 } 799 }
800 800
801 IWL_DEBUG_INFO("can not find STA %pM (total %d)\n", 801 IWL_DEBUG_INFO(priv, "can not find STA %pM (total %d)\n",
802 addr, priv->num_stations); 802 addr, priv->num_stations);
803 out: 803 out:
804 spin_unlock_irqrestore(&priv->sta_lock, flags); 804 spin_unlock_irqrestore(&priv->sta_lock, flags);
@@ -873,7 +873,7 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, struct iwl_cmd *cmd,
873 /* CCK */ 873 /* CCK */
874 tx->supp_rates[1] = (rate_mask & 0xF); 874 tx->supp_rates[1] = (rate_mask & 0xF);
875 875
876 IWL_DEBUG_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " 876 IWL_DEBUG_RATE(priv, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X "
877 "cck/ofdm mask: 0x%x/0x%x\n", sta_id, 877 "cck/ofdm mask: 0x%x/0x%x\n", sta_id,
878 tx->rate, le32_to_cpu(tx->tx_flags), 878 tx->rate, le32_to_cpu(tx->tx_flags),
879 tx->supp_rates[1], tx->supp_rates[0]); 879 tx->supp_rates[1], tx->supp_rates[0]);
@@ -898,7 +898,7 @@ u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate, u8 flags)
898 898
899 iwl_send_add_sta(priv, 899 iwl_send_add_sta(priv,
900 (struct iwl_addsta_cmd *)&station->sta, flags); 900 (struct iwl_addsta_cmd *)&station->sta, flags);
901 IWL_DEBUG_RATE("SCALE sync station %d to rate %d\n", 901 IWL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n",
902 sta_id, tx_rate); 902 sta_id, tx_rate);
903 return sta_id; 903 return sta_id;
904} 904}
@@ -1063,7 +1063,7 @@ static int iwl3945_apm_init(struct iwl_priv *priv)
1063{ 1063{
1064 int ret = 0; 1064 int ret = 0;
1065 1065
1066 iwl3945_power_init_handle(priv); 1066 iwl_power_initialize(priv);
1067 1067
1068 iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS, 1068 iwl_set_bit(priv, CSR_GIO_CHICKEN_BITS,
1069 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); 1069 CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
@@ -1079,7 +1079,7 @@ static int iwl3945_apm_init(struct iwl_priv *priv)
1079 iwl_poll_direct_bit(priv, CSR_GP_CNTRL, 1079 iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
1080 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); 1080 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
1081 if (ret < 0) { 1081 if (ret < 0) {
1082 IWL_DEBUG_INFO("Failed to init the card\n"); 1082 IWL_DEBUG_INFO(priv, "Failed to init the card\n");
1083 goto out; 1083 goto out;
1084 } 1084 }
1085 1085
@@ -1111,31 +1111,31 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
1111 spin_lock_irqsave(&priv->lock, flags); 1111 spin_lock_irqsave(&priv->lock, flags);
1112 1112
1113 if (rev_id & PCI_CFG_REV_ID_BIT_RTP) 1113 if (rev_id & PCI_CFG_REV_ID_BIT_RTP)
1114 IWL_DEBUG_INFO("RTP type \n"); 1114 IWL_DEBUG_INFO(priv, "RTP type \n");
1115 else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { 1115 else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) {
1116 IWL_DEBUG_INFO("3945 RADIO-MB type\n"); 1116 IWL_DEBUG_INFO(priv, "3945 RADIO-MB type\n");
1117 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1117 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1118 CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); 1118 CSR39_HW_IF_CONFIG_REG_BIT_3945_MB);
1119 } else { 1119 } else {
1120 IWL_DEBUG_INFO("3945 RADIO-MM type\n"); 1120 IWL_DEBUG_INFO(priv, "3945 RADIO-MM type\n");
1121 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1121 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1122 CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); 1122 CSR39_HW_IF_CONFIG_REG_BIT_3945_MM);
1123 } 1123 }
1124 1124
1125 if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { 1125 if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) {
1126 IWL_DEBUG_INFO("SKU OP mode is mrc\n"); 1126 IWL_DEBUG_INFO(priv, "SKU OP mode is mrc\n");
1127 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1127 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1128 CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); 1128 CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC);
1129 } else 1129 } else
1130 IWL_DEBUG_INFO("SKU OP mode is basic\n"); 1130 IWL_DEBUG_INFO(priv, "SKU OP mode is basic\n");
1131 1131
1132 if ((eeprom->board_revision & 0xF0) == 0xD0) { 1132 if ((eeprom->board_revision & 0xF0) == 0xD0) {
1133 IWL_DEBUG_INFO("3945ABG revision is 0x%X\n", 1133 IWL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n",
1134 eeprom->board_revision); 1134 eeprom->board_revision);
1135 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1135 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1136 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); 1136 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE);
1137 } else { 1137 } else {
1138 IWL_DEBUG_INFO("3945ABG revision is 0x%X\n", 1138 IWL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n",
1139 eeprom->board_revision); 1139 eeprom->board_revision);
1140 iwl_clear_bit(priv, CSR_HW_IF_CONFIG_REG, 1140 iwl_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
1141 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); 1141 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE);
@@ -1144,10 +1144,10 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
1144 if (eeprom->almgor_m_version <= 1) { 1144 if (eeprom->almgor_m_version <= 1) {
1145 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1145 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1146 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); 1146 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A);
1147 IWL_DEBUG_INFO("Card M type A version is 0x%X\n", 1147 IWL_DEBUG_INFO(priv, "Card M type A version is 0x%X\n",
1148 eeprom->almgor_m_version); 1148 eeprom->almgor_m_version);
1149 } else { 1149 } else {
1150 IWL_DEBUG_INFO("Card M type B version is 0x%X\n", 1150 IWL_DEBUG_INFO(priv, "Card M type B version is 0x%X\n",
1151 eeprom->almgor_m_version); 1151 eeprom->almgor_m_version);
1152 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1152 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1153 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); 1153 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B);
@@ -1155,10 +1155,10 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
1155 spin_unlock_irqrestore(&priv->lock, flags); 1155 spin_unlock_irqrestore(&priv->lock, flags);
1156 1156
1157 if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) 1157 if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE)
1158 IWL_DEBUG_RF_KILL("SW RF KILL supported in EEPROM.\n"); 1158 IWL_DEBUG_RF_KILL(priv, "SW RF KILL supported in EEPROM.\n");
1159 1159
1160 if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) 1160 if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE)
1161 IWL_DEBUG_RF_KILL("HW RF KILL supported in EEPROM.\n"); 1161 IWL_DEBUG_RF_KILL(priv, "HW RF KILL supported in EEPROM.\n");
1162} 1162}
1163 1163
1164int iwl3945_hw_nic_init(struct iwl_priv *priv) 1164int iwl3945_hw_nic_init(struct iwl_priv *priv)
@@ -1176,7 +1176,7 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv)
1176 rc = pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id); 1176 rc = pci_read_config_byte(priv->pci_dev, PCI_REVISION_ID, &rev_id);
1177 if (rc) 1177 if (rc)
1178 return rc; 1178 return rc;
1179 IWL_DEBUG_INFO("HW Revision ID = 0x%X\n", rev_id); 1179 IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id);
1180 1180
1181 rc = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN); 1181 rc = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN);
1182 if(rc) 1182 if(rc)
@@ -1285,7 +1285,7 @@ static int iwl3945_apm_stop_master(struct iwl_priv *priv)
1285 1285
1286out: 1286out:
1287 spin_unlock_irqrestore(&priv->lock, flags); 1287 spin_unlock_irqrestore(&priv->lock, flags);
1288 IWL_DEBUG_INFO("stop master\n"); 1288 IWL_DEBUG_INFO(priv, "stop master\n");
1289 1289
1290 return ret; 1290 return ret;
1291} 1291}
@@ -1390,7 +1390,7 @@ static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv)
1390 1390
1391 /* driver's okay range is -260 to +25. 1391 /* driver's okay range is -260 to +25.
1392 * human readable okay range is 0 to +285 */ 1392 * human readable okay range is 0 to +285 */
1393 IWL_DEBUG_INFO("Temperature: %d\n", temperature + IWL_TEMP_CONVERT); 1393 IWL_DEBUG_INFO(priv, "Temperature: %d\n", temperature + IWL_TEMP_CONVERT);
1394 1394
1395 /* handle insane temp reading */ 1395 /* handle insane temp reading */
1396 if (iwl3945_hw_reg_temp_out_of_range(temperature)) { 1396 if (iwl3945_hw_reg_temp_out_of_range(temperature)) {
@@ -1427,20 +1427,20 @@ static int is_temp_calib_needed(struct iwl_priv *priv)
1427 1427
1428 /* get absolute value */ 1428 /* get absolute value */
1429 if (temp_diff < 0) { 1429 if (temp_diff < 0) {
1430 IWL_DEBUG_POWER("Getting cooler, delta %d,\n", temp_diff); 1430 IWL_DEBUG_POWER(priv, "Getting cooler, delta %d,\n", temp_diff);
1431 temp_diff = -temp_diff; 1431 temp_diff = -temp_diff;
1432 } else if (temp_diff == 0) 1432 } else if (temp_diff == 0)
1433 IWL_DEBUG_POWER("Same temp,\n"); 1433 IWL_DEBUG_POWER(priv, "Same temp,\n");
1434 else 1434 else
1435 IWL_DEBUG_POWER("Getting warmer, delta %d,\n", temp_diff); 1435 IWL_DEBUG_POWER(priv, "Getting warmer, delta %d,\n", temp_diff);
1436 1436
1437 /* if we don't need calibration, *don't* update last_temperature */ 1437 /* if we don't need calibration, *don't* update last_temperature */
1438 if (temp_diff < IWL_TEMPERATURE_LIMIT_TIMER) { 1438 if (temp_diff < IWL_TEMPERATURE_LIMIT_TIMER) {
1439 IWL_DEBUG_POWER("Timed thermal calib not needed\n"); 1439 IWL_DEBUG_POWER(priv, "Timed thermal calib not needed\n");
1440 return 0; 1440 return 0;
1441 } 1441 }
1442 1442
1443 IWL_DEBUG_POWER("Timed thermal calib needed\n"); 1443 IWL_DEBUG_POWER(priv, "Timed thermal calib needed\n");
1444 1444
1445 /* assume that caller will actually do calib ... 1445 /* assume that caller will actually do calib ...
1446 * update the "last temperature" value */ 1446 * update the "last temperature" value */
@@ -1689,27 +1689,27 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in
1689 * Configures power settings for all rates for the current channel, 1689 * Configures power settings for all rates for the current channel,
1690 * using values from channel info struct, and send to NIC 1690 * using values from channel info struct, and send to NIC
1691 */ 1691 */
1692int iwl3945_send_tx_power(struct iwl_priv *priv) 1692static int iwl3945_send_tx_power(struct iwl_priv *priv)
1693{ 1693{
1694 int rate_idx, i; 1694 int rate_idx, i;
1695 const struct iwl_channel_info *ch_info = NULL; 1695 const struct iwl_channel_info *ch_info = NULL;
1696 struct iwl3945_txpowertable_cmd txpower = { 1696 struct iwl3945_txpowertable_cmd txpower = {
1697 .channel = priv->active39_rxon.channel, 1697 .channel = priv->active_rxon.channel,
1698 }; 1698 };
1699 1699
1700 txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; 1700 txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1;
1701 ch_info = iwl_get_channel_info(priv, 1701 ch_info = iwl_get_channel_info(priv,
1702 priv->band, 1702 priv->band,
1703 le16_to_cpu(priv->active39_rxon.channel)); 1703 le16_to_cpu(priv->active_rxon.channel));
1704 if (!ch_info) { 1704 if (!ch_info) {
1705 IWL_ERR(priv, 1705 IWL_ERR(priv,
1706 "Failed to get channel info for channel %d [%d]\n", 1706 "Failed to get channel info for channel %d [%d]\n",
1707 le16_to_cpu(priv->active39_rxon.channel), priv->band); 1707 le16_to_cpu(priv->active_rxon.channel), priv->band);
1708 return -EINVAL; 1708 return -EINVAL;
1709 } 1709 }
1710 1710
1711 if (!is_channel_valid(ch_info)) { 1711 if (!is_channel_valid(ch_info)) {
1712 IWL_DEBUG_POWER("Not calling TX_PWR_TABLE_CMD on " 1712 IWL_DEBUG_POWER(priv, "Not calling TX_PWR_TABLE_CMD on "
1713 "non-Tx channel.\n"); 1713 "non-Tx channel.\n");
1714 return 0; 1714 return 0;
1715 } 1715 }
@@ -1722,7 +1722,7 @@ int iwl3945_send_tx_power(struct iwl_priv *priv)
1722 txpower.power[i].tpc = ch_info->power_info[i].tpc; 1722 txpower.power[i].tpc = ch_info->power_info[i].tpc;
1723 txpower.power[i].rate = iwl3945_rates[rate_idx].plcp; 1723 txpower.power[i].rate = iwl3945_rates[rate_idx].plcp;
1724 1724
1725 IWL_DEBUG_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", 1725 IWL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n",
1726 le16_to_cpu(txpower.channel), 1726 le16_to_cpu(txpower.channel),
1727 txpower.band, 1727 txpower.band,
1728 txpower.power[i].tpc.tx_gain, 1728 txpower.power[i].tpc.tx_gain,
@@ -1735,7 +1735,7 @@ int iwl3945_send_tx_power(struct iwl_priv *priv)
1735 txpower.power[i].tpc = ch_info->power_info[i].tpc; 1735 txpower.power[i].tpc = ch_info->power_info[i].tpc;
1736 txpower.power[i].rate = iwl3945_rates[rate_idx].plcp; 1736 txpower.power[i].rate = iwl3945_rates[rate_idx].plcp;
1737 1737
1738 IWL_DEBUG_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", 1738 IWL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n",
1739 le16_to_cpu(txpower.channel), 1739 le16_to_cpu(txpower.channel),
1740 txpower.band, 1740 txpower.band,
1741 txpower.power[i].tpc.tx_gain, 1741 txpower.power[i].tpc.tx_gain,
@@ -1926,12 +1926,12 @@ int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power)
1926 u8 i; 1926 u8 i;
1927 1927
1928 if (priv->tx_power_user_lmt == power) { 1928 if (priv->tx_power_user_lmt == power) {
1929 IWL_DEBUG_POWER("Requested Tx power same as current " 1929 IWL_DEBUG_POWER(priv, "Requested Tx power same as current "
1930 "limit: %ddBm.\n", power); 1930 "limit: %ddBm.\n", power);
1931 return 0; 1931 return 0;
1932 } 1932 }
1933 1933
1934 IWL_DEBUG_POWER("Setting upper limit clamp to %ddBm.\n", power); 1934 IWL_DEBUG_POWER(priv, "Setting upper limit clamp to %ddBm.\n", power);
1935 priv->tx_power_user_lmt = power; 1935 priv->tx_power_user_lmt = power;
1936 1936
1937 /* set up new Tx powers for each and every channel, 2.4 and 5.x */ 1937 /* set up new Tx powers for each and every channel, 2.4 and 5.x */
@@ -2041,7 +2041,7 @@ static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv,
2041 } else 2041 } else
2042 group_index = 0; /* 2.4 GHz, group 0 */ 2042 group_index = 0; /* 2.4 GHz, group 0 */
2043 2043
2044 IWL_DEBUG_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, 2044 IWL_DEBUG_POWER(priv, "Chnl %d mapped to grp %d\n", ch_info->channel,
2045 group_index); 2045 group_index);
2046 return group_index; 2046 return group_index;
2047} 2047}
@@ -2108,7 +2108,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv)
2108 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; 2108 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
2109 const struct iwl3945_eeprom_txpower_group *group; 2109 const struct iwl3945_eeprom_txpower_group *group;
2110 2110
2111 IWL_DEBUG_POWER("Initializing factory calib info from EEPROM\n"); 2111 IWL_DEBUG_POWER(priv, "Initializing factory calib info from EEPROM\n");
2112 2112
2113 for (i = 0; i < IWL_NUM_TX_CALIB_GROUPS; i++) { 2113 for (i = 0; i < IWL_NUM_TX_CALIB_GROUPS; i++) {
2114 s8 *clip_pwrs; /* table of power levels for each rate */ 2114 s8 *clip_pwrs; /* table of power levels for each rate */
@@ -2224,7 +2224,7 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv)
2224 eeprom->groups[ch_info->group_index]. 2224 eeprom->groups[ch_info->group_index].
2225 temperature); 2225 temperature);
2226 2226
2227 IWL_DEBUG_POWER("Delta index for channel %d: %d [%d]\n", 2227 IWL_DEBUG_POWER(priv, "Delta index for channel %d: %d [%d]\n",
2228 ch_info->channel, delta_index, temperature + 2228 ch_info->channel, delta_index, temperature +
2229 IWL_TEMP_CONVERT); 2229 IWL_TEMP_CONVERT);
2230 2230
@@ -2372,7 +2372,9 @@ static u16 iwl3945_get_hcmd_size(u8 cmd_id, u16 len)
2372{ 2372{
2373 switch (cmd_id) { 2373 switch (cmd_id) {
2374 case REPLY_RXON: 2374 case REPLY_RXON:
2375 return (u16) sizeof(struct iwl3945_rxon_cmd); 2375 return sizeof(struct iwl3945_rxon_cmd);
2376 case POWER_TABLE_CMD:
2377 return sizeof(struct iwl3945_powertable_cmd);
2376 default: 2378 default:
2377 return len; 2379 return len;
2378 } 2380 }
@@ -2409,7 +2411,7 @@ int iwl3945_init_hw_rate_table(struct iwl_priv *priv)
2409 2411
2410 switch (priv->band) { 2412 switch (priv->band) {
2411 case IEEE80211_BAND_5GHZ: 2413 case IEEE80211_BAND_5GHZ:
2412 IWL_DEBUG_RATE("Select A mode rate scale\n"); 2414 IWL_DEBUG_RATE(priv, "Select A mode rate scale\n");
2413 /* If one of the following CCK rates is used, 2415 /* If one of the following CCK rates is used,
2414 * have it fall back to the 6M OFDM rate */ 2416 * have it fall back to the 6M OFDM rate */
2415 for (i = IWL_RATE_1M_INDEX_TABLE; 2417 for (i = IWL_RATE_1M_INDEX_TABLE;
@@ -2427,12 +2429,12 @@ int iwl3945_init_hw_rate_table(struct iwl_priv *priv)
2427 break; 2429 break;
2428 2430
2429 case IEEE80211_BAND_2GHZ: 2431 case IEEE80211_BAND_2GHZ:
2430 IWL_DEBUG_RATE("Select B/G mode rate scale\n"); 2432 IWL_DEBUG_RATE(priv, "Select B/G mode rate scale\n");
2431 /* If an OFDM rate is used, have it fall back to the 2433 /* If an OFDM rate is used, have it fall back to the
2432 * 1M CCK rates */ 2434 * 1M CCK rates */
2433 2435
2434 if (!(priv->sta_supp_rates & IWL_OFDM_RATES_MASK) && 2436 if (!(priv->sta_supp_rates & IWL_OFDM_RATES_MASK) &&
2435 iwl3945_is_associated(priv)) { 2437 iwl_is_associated(priv)) {
2436 2438
2437 index = IWL_FIRST_CCK_RATE; 2439 index = IWL_FIRST_CCK_RATE;
2438 for (i = IWL_RATE_6M_INDEX_TABLE; 2440 for (i = IWL_RATE_6M_INDEX_TABLE;
@@ -2552,7 +2554,7 @@ static int iwl3945_verify_bsm(struct iwl_priv *priv)
2552 u32 reg; 2554 u32 reg;
2553 u32 val; 2555 u32 val;
2554 2556
2555 IWL_DEBUG_INFO("Begin verify bsm\n"); 2557 IWL_DEBUG_INFO(priv, "Begin verify bsm\n");
2556 2558
2557 /* verify BSM SRAM contents */ 2559 /* verify BSM SRAM contents */
2558 val = iwl_read_prph(priv, BSM_WR_DWCOUNT_REG); 2560 val = iwl_read_prph(priv, BSM_WR_DWCOUNT_REG);
@@ -2570,7 +2572,7 @@ static int iwl3945_verify_bsm(struct iwl_priv *priv)
2570 } 2572 }
2571 } 2573 }
2572 2574
2573 IWL_DEBUG_INFO("BSM bootstrap uCode image OK\n"); 2575 IWL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n");
2574 2576
2575 return 0; 2577 return 0;
2576} 2578}
@@ -2647,7 +2649,7 @@ static int iwl3945_load_bsm(struct iwl_priv *priv)
2647 u32 done; 2649 u32 done;
2648 u32 reg_offset; 2650 u32 reg_offset;
2649 2651
2650 IWL_DEBUG_INFO("Begin load bsm\n"); 2652 IWL_DEBUG_INFO(priv, "Begin load bsm\n");
2651 2653
2652 /* make sure bootstrap program is no larger than BSM's SRAM size */ 2654 /* make sure bootstrap program is no larger than BSM's SRAM size */
2653 if (len > IWL39_MAX_BSM_SIZE) 2655 if (len > IWL39_MAX_BSM_SIZE)
@@ -2704,7 +2706,7 @@ static int iwl3945_load_bsm(struct iwl_priv *priv)
2704 udelay(10); 2706 udelay(10);
2705 } 2707 }
2706 if (i < 100) 2708 if (i < 100)
2707 IWL_DEBUG_INFO("BSM write complete, poll %d iterations\n", i); 2709 IWL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i);
2708 else { 2710 else {
2709 IWL_ERR(priv, "BSM write did not complete!\n"); 2711 IWL_ERR(priv, "BSM write did not complete!\n");
2710 return -EIO; 2712 return -EIO;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index fef54e9cf8a8..ab7aaf6872c7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -222,9 +222,6 @@ extern int __must_check iwl3945_send_cmd(struct iwl_priv *priv,
222 struct iwl_host_cmd *cmd); 222 struct iwl_host_cmd *cmd);
223extern unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv, 223extern unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv,
224 struct ieee80211_hdr *hdr,int left); 224 struct ieee80211_hdr *hdr,int left);
225extern void iwl3945_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
226 u32 decrypt_res,
227 struct ieee80211_rx_status *stats);
228 225
229/* 226/*
230 * Currently used by iwl-3945-rs... look at restructuring so that it doesn't 227 * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
@@ -303,11 +300,6 @@ extern int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv);
303extern u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, 300extern u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id,
304 u16 tx_rate, u8 flags); 301 u16 tx_rate, u8 flags);
305 302
306static inline int iwl3945_is_associated(struct iwl_priv *priv)
307{
308 return (priv->active39_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
309}
310
311extern const struct iwl_channel_info *iwl3945_get_channel_info( 303extern const struct iwl_channel_info *iwl3945_get_channel_info(
312 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel); 304 const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
313 305
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index d7d956db19d1..0638f3e37602 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -76,7 +76,7 @@ static int iwl4965_verify_bsm(struct iwl_priv *priv)
76 u32 reg; 76 u32 reg;
77 u32 val; 77 u32 val;
78 78
79 IWL_DEBUG_INFO("Begin verify bsm\n"); 79 IWL_DEBUG_INFO(priv, "Begin verify bsm\n");
80 80
81 /* verify BSM SRAM contents */ 81 /* verify BSM SRAM contents */
82 val = iwl_read_prph(priv, BSM_WR_DWCOUNT_REG); 82 val = iwl_read_prph(priv, BSM_WR_DWCOUNT_REG);
@@ -94,7 +94,7 @@ static int iwl4965_verify_bsm(struct iwl_priv *priv)
94 } 94 }
95 } 95 }
96 96
97 IWL_DEBUG_INFO("BSM bootstrap uCode image OK\n"); 97 IWL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n");
98 98
99 return 0; 99 return 0;
100} 100}
@@ -144,7 +144,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv)
144 u32 reg_offset; 144 u32 reg_offset;
145 int ret; 145 int ret;
146 146
147 IWL_DEBUG_INFO("Begin load bsm\n"); 147 IWL_DEBUG_INFO(priv, "Begin load bsm\n");
148 148
149 priv->ucode_type = UCODE_RT; 149 priv->ucode_type = UCODE_RT;
150 150
@@ -201,7 +201,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv)
201 udelay(10); 201 udelay(10);
202 } 202 }
203 if (i < 100) 203 if (i < 100)
204 IWL_DEBUG_INFO("BSM write complete, poll %d iterations\n", i); 204 IWL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i);
205 else { 205 else {
206 IWL_ERR(priv, "BSM write did not complete!\n"); 206 IWL_ERR(priv, "BSM write did not complete!\n");
207 return -EIO; 207 return -EIO;
@@ -257,7 +257,7 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv)
257 257
258 spin_unlock_irqrestore(&priv->lock, flags); 258 spin_unlock_irqrestore(&priv->lock, flags);
259 259
260 IWL_DEBUG_INFO("Runtime uCode pointers are set.\n"); 260 IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n");
261 261
262 return ret; 262 return ret;
263} 263}
@@ -279,7 +279,7 @@ static void iwl4965_init_alive_start(struct iwl_priv *priv)
279 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { 279 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
280 /* We had an error bringing up the hardware, so take it 280 /* We had an error bringing up the hardware, so take it
281 * all the way back down so we can try again */ 281 * all the way back down so we can try again */
282 IWL_DEBUG_INFO("Initialize Alive failed.\n"); 282 IWL_DEBUG_INFO(priv, "Initialize Alive failed.\n");
283 goto restart; 283 goto restart;
284 } 284 }
285 285
@@ -289,7 +289,7 @@ static void iwl4965_init_alive_start(struct iwl_priv *priv)
289 if (iwl_verify_ucode(priv)) { 289 if (iwl_verify_ucode(priv)) {
290 /* Runtime instruction load was bad; 290 /* Runtime instruction load was bad;
291 * take it all the way back down so we can try again */ 291 * take it all the way back down so we can try again */
292 IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n"); 292 IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n");
293 goto restart; 293 goto restart;
294 } 294 }
295 295
@@ -299,11 +299,11 @@ static void iwl4965_init_alive_start(struct iwl_priv *priv)
299 /* Send pointers to protocol/runtime uCode image ... init code will 299 /* Send pointers to protocol/runtime uCode image ... init code will
300 * load and launch runtime uCode, which will send us another "Alive" 300 * load and launch runtime uCode, which will send us another "Alive"
301 * notification. */ 301 * notification. */
302 IWL_DEBUG_INFO("Initialization Alive received.\n"); 302 IWL_DEBUG_INFO(priv, "Initialization Alive received.\n");
303 if (iwl4965_set_ucode_ptrs(priv)) { 303 if (iwl4965_set_ucode_ptrs(priv)) {
304 /* Runtime instruction load won't happen; 304 /* Runtime instruction load won't happen;
305 * take it all the way back down so we can try again */ 305 * take it all the way back down so we can try again */
306 IWL_DEBUG_INFO("Couldn't set up uCode pointers.\n"); 306 IWL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n");
307 goto restart; 307 goto restart;
308 } 308 }
309 return; 309 return;
@@ -354,7 +354,7 @@ static int iwl4965_apm_init(struct iwl_priv *priv)
354 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL, 354 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
355 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); 355 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
356 if (ret < 0) { 356 if (ret < 0) {
357 IWL_DEBUG_INFO("Failed to init the card\n"); 357 IWL_DEBUG_INFO(priv, "Failed to init the card\n");
358 goto out; 358 goto out;
359 } 359 }
360 360
@@ -437,7 +437,7 @@ static int iwl4965_apm_stop_master(struct iwl_priv *priv)
437 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); 437 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
438 438
439 spin_unlock_irqrestore(&priv->lock, flags); 439 spin_unlock_irqrestore(&priv->lock, flags);
440 IWL_DEBUG_INFO("stop master\n"); 440 IWL_DEBUG_INFO(priv, "stop master\n");
441 441
442 return 0; 442 return 0;
443} 443}
@@ -526,7 +526,7 @@ static void iwl4965_chain_noise_reset(struct iwl_priv *priv)
526 IWL_ERR(priv, 526 IWL_ERR(priv,
527 "Could not send REPLY_PHY_CALIBRATION_CMD\n"); 527 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
528 data->state = IWL_CHAIN_NOISE_ACCUMULATE; 528 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
529 IWL_DEBUG_CALIB("Run chain_noise_calibrate\n"); 529 IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n");
530 } 530 }
531} 531}
532 532
@@ -558,7 +558,7 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
558 data->delta_gain_code[i] = 0; 558 data->delta_gain_code[i] = 0;
559 } 559 }
560 } 560 }
561 IWL_DEBUG_CALIB("delta_gain_codes: a %d b %d c %d\n", 561 IWL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n",
562 data->delta_gain_code[0], 562 data->delta_gain_code[0],
563 data->delta_gain_code[1], 563 data->delta_gain_code[1],
564 data->delta_gain_code[2]); 564 data->delta_gain_code[2]);
@@ -576,7 +576,7 @@ static void iwl4965_gain_computation(struct iwl_priv *priv,
576 ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, 576 ret = iwl_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD,
577 sizeof(cmd), &cmd); 577 sizeof(cmd), &cmd);
578 if (ret) 578 if (ret)
579 IWL_DEBUG_CALIB("fail sending cmd " 579 IWL_DEBUG_CALIB(priv, "fail sending cmd "
580 "REPLY_PHY_CALIBRATION_CMD \n"); 580 "REPLY_PHY_CALIBRATION_CMD \n");
581 581
582 /* TODO we might want recalculate 582 /* TODO we might want recalculate
@@ -669,7 +669,7 @@ static void iwl4965_tx_queue_set_status(struct iwl_priv *priv,
669 669
670 txq->sched_retry = scd_retry; 670 txq->sched_retry = scd_retry;
671 671
672 IWL_DEBUG_INFO("%s %s Queue %d on AC %d\n", 672 IWL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n",
673 active ? "Activate" : "Deactivate", 673 active ? "Activate" : "Deactivate",
674 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); 674 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
675} 675}
@@ -968,7 +968,7 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel,
968 ch_i2 = priv->calib_info->band_info[s].ch2.ch_num; 968 ch_i2 = priv->calib_info->band_info[s].ch2.ch_num;
969 chan_info->ch_num = (u8) channel; 969 chan_info->ch_num = (u8) channel;
970 970
971 IWL_DEBUG_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", 971 IWL_DEBUG_TXPOWER(priv, "channel %d subband %d factory cal ch %d & %d\n",
972 channel, s, ch_i1, ch_i2); 972 channel, s, ch_i1, ch_i2);
973 973
974 for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { 974 for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) {
@@ -998,19 +998,19 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel,
998 m1->pa_det, ch_i2, 998 m1->pa_det, ch_i2,
999 m2->pa_det); 999 m2->pa_det);
1000 1000
1001 IWL_DEBUG_TXPOWER 1001 IWL_DEBUG_TXPOWER(priv,
1002 ("chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, 1002 "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m,
1003 m1->actual_pow, m2->actual_pow, omeas->actual_pow); 1003 m1->actual_pow, m2->actual_pow, omeas->actual_pow);
1004 IWL_DEBUG_TXPOWER 1004 IWL_DEBUG_TXPOWER(priv,
1005 ("chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, 1005 "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m,
1006 m1->gain_idx, m2->gain_idx, omeas->gain_idx); 1006 m1->gain_idx, m2->gain_idx, omeas->gain_idx);
1007 IWL_DEBUG_TXPOWER 1007 IWL_DEBUG_TXPOWER(priv,
1008 ("chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, 1008 "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m,
1009 m1->pa_det, m2->pa_det, omeas->pa_det); 1009 m1->pa_det, m2->pa_det, omeas->pa_det);
1010 IWL_DEBUG_TXPOWER 1010 IWL_DEBUG_TXPOWER(priv,
1011 ("chain %d meas %d T1=%d T2=%d T=%d\n", c, m, 1011 "chain %d meas %d T1=%d T2=%d T=%d\n", c, m,
1012 m1->temperature, m2->temperature, 1012 m1->temperature, m2->temperature,
1013 omeas->temperature); 1013 omeas->temperature);
1014 } 1014 }
1015 } 1015 }
1016 1016
@@ -1312,7 +1312,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1312 user_target_power = 2 * priv->tx_power_user_lmt; 1312 user_target_power = 2 * priv->tx_power_user_lmt;
1313 1313
1314 /* Get current (RXON) channel, band, width */ 1314 /* Get current (RXON) channel, band, width */
1315 IWL_DEBUG_TXPOWER("chan %d band %d is_fat %d\n", channel, band, 1315 IWL_DEBUG_TXPOWER(priv, "chan %d band %d is_fat %d\n", channel, band,
1316 is_fat); 1316 is_fat);
1317 1317
1318 ch_info = iwl_get_channel_info(priv, priv->band, channel); 1318 ch_info = iwl_get_channel_info(priv, priv->band, channel);
@@ -1329,7 +1329,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1329 return -EINVAL; 1329 return -EINVAL;
1330 } 1330 }
1331 1331
1332 IWL_DEBUG_TXPOWER("channel %d belongs to txatten group %d\n", 1332 IWL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n",
1333 channel, txatten_grp); 1333 channel, txatten_grp);
1334 1334
1335 if (is_fat) { 1335 if (is_fat) {
@@ -1379,7 +1379,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1379 voltage_compensation = 1379 voltage_compensation =
1380 iwl4965_get_voltage_compensation(voltage, init_voltage); 1380 iwl4965_get_voltage_compensation(voltage, init_voltage);
1381 1381
1382 IWL_DEBUG_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", 1382 IWL_DEBUG_TXPOWER(priv, "curr volt %d eeprom volt %d volt comp %d\n",
1383 init_voltage, 1383 init_voltage,
1384 voltage, voltage_compensation); 1384 voltage, voltage_compensation);
1385 1385
@@ -1410,13 +1410,13 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1410 factory_gain_index[c] = measurement->gain_idx; 1410 factory_gain_index[c] = measurement->gain_idx;
1411 factory_actual_pwr[c] = measurement->actual_pow; 1411 factory_actual_pwr[c] = measurement->actual_pow;
1412 1412
1413 IWL_DEBUG_TXPOWER("chain = %d\n", c); 1413 IWL_DEBUG_TXPOWER(priv, "chain = %d\n", c);
1414 IWL_DEBUG_TXPOWER("fctry tmp %d, " 1414 IWL_DEBUG_TXPOWER(priv, "fctry tmp %d, "
1415 "curr tmp %d, comp %d steps\n", 1415 "curr tmp %d, comp %d steps\n",
1416 factory_temp, current_temp, 1416 factory_temp, current_temp,
1417 temperature_comp[c]); 1417 temperature_comp[c]);
1418 1418
1419 IWL_DEBUG_TXPOWER("fctry idx %d, fctry pwr %d\n", 1419 IWL_DEBUG_TXPOWER(priv, "fctry idx %d, fctry pwr %d\n",
1420 factory_gain_index[c], 1420 factory_gain_index[c],
1421 factory_actual_pwr[c]); 1421 factory_actual_pwr[c]);
1422 } 1422 }
@@ -1449,7 +1449,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1449 if (target_power > power_limit) 1449 if (target_power > power_limit)
1450 target_power = power_limit; 1450 target_power = power_limit;
1451 1451
1452 IWL_DEBUG_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", 1452 IWL_DEBUG_TXPOWER(priv, "rate %d sat %d reg %d usr %d tgt %d\n",
1453 i, saturation_power - back_off_table[i], 1453 i, saturation_power - back_off_table[i],
1454 current_regulatory, user_target_power, 1454 current_regulatory, user_target_power,
1455 target_power); 1455 target_power);
@@ -1473,7 +1473,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1473 voltage_compensation + 1473 voltage_compensation +
1474 atten_value); 1474 atten_value);
1475 1475
1476/* IWL_DEBUG_TXPOWER("calculated txpower index %d\n", 1476/* IWL_DEBUG_TXPOWER(priv, "calculated txpower index %d\n",
1477 power_index); */ 1477 power_index); */
1478 1478
1479 if (power_index < get_min_power_index(i, band)) 1479 if (power_index < get_min_power_index(i, band))
@@ -1506,7 +1506,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
1506 tx_power.s.dsp_predis_atten[c] = 1506 tx_power.s.dsp_predis_atten[c] =
1507 gain_table[band][power_index].dsp; 1507 gain_table[band][power_index].dsp;
1508 1508
1509 IWL_DEBUG_TXPOWER("chain %d mimo %d index %d " 1509 IWL_DEBUG_TXPOWER(priv, "chain %d mimo %d index %d "
1510 "gain 0x%02x dsp %d\n", 1510 "gain 0x%02x dsp %d\n",
1511 c, atten_value, power_index, 1511 c, atten_value, power_index,
1512 tx_power.s.radio_tx_gain[c], 1512 tx_power.s.radio_tx_gain[c],
@@ -1581,7 +1581,7 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv)
1581 rxon2->ofdm_ht_dual_stream_basic_rates) && 1581 rxon2->ofdm_ht_dual_stream_basic_rates) &&
1582 (rxon1->rx_chain == rxon2->rx_chain) && 1582 (rxon1->rx_chain == rxon2->rx_chain) &&
1583 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { 1583 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
1584 IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n"); 1584 IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n");
1585 return 0; 1585 return 0;
1586 } 1586 }
1587 1587
@@ -1638,7 +1638,7 @@ static int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
1638 rc = iwl4965_fill_txpower_tbl(priv, band, channel, is_fat, 1638 rc = iwl4965_fill_txpower_tbl(priv, band, channel, is_fat,
1639 ctrl_chan_high, &cmd.tx_power); 1639 ctrl_chan_high, &cmd.tx_power);
1640 if (rc) { 1640 if (rc) {
1641 IWL_DEBUG_11H("error:%d fill txpower_tbl\n", rc); 1641 IWL_DEBUG_11H(priv, "error:%d fill txpower_tbl\n", rc);
1642 return rc; 1642 return rc;
1643 } 1643 }
1644 1644
@@ -1703,13 +1703,13 @@ static int iwl4965_hw_get_temperature(const struct iwl_priv *priv)
1703 1703
1704 if (test_bit(STATUS_TEMPERATURE, &priv->status) && 1704 if (test_bit(STATUS_TEMPERATURE, &priv->status) &&
1705 (priv->statistics.flag & STATISTICS_REPLY_FLG_FAT_MODE_MSK)) { 1705 (priv->statistics.flag & STATISTICS_REPLY_FLG_FAT_MODE_MSK)) {
1706 IWL_DEBUG_TEMP("Running FAT temperature calibration\n"); 1706 IWL_DEBUG_TEMP(priv, "Running FAT temperature calibration\n");
1707 R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[1]); 1707 R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[1]);
1708 R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[1]); 1708 R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[1]);
1709 R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[1]); 1709 R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[1]);
1710 R4 = le32_to_cpu(priv->card_alive_init.therm_r4[1]); 1710 R4 = le32_to_cpu(priv->card_alive_init.therm_r4[1]);
1711 } else { 1711 } else {
1712 IWL_DEBUG_TEMP("Running temperature calibration\n"); 1712 IWL_DEBUG_TEMP(priv, "Running temperature calibration\n");
1713 R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[0]); 1713 R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[0]);
1714 R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[0]); 1714 R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[0]);
1715 R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[0]); 1715 R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[0]);
@@ -1729,7 +1729,7 @@ static int iwl4965_hw_get_temperature(const struct iwl_priv *priv)
1729 vt = sign_extend( 1729 vt = sign_extend(
1730 le32_to_cpu(priv->statistics.general.temperature), 23); 1730 le32_to_cpu(priv->statistics.general.temperature), 23);
1731 1731
1732 IWL_DEBUG_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); 1732 IWL_DEBUG_TEMP(priv, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt);
1733 1733
1734 if (R3 == R1) { 1734 if (R3 == R1) {
1735 IWL_ERR(priv, "Calibration conflict R1 == R3\n"); 1735 IWL_ERR(priv, "Calibration conflict R1 == R3\n");
@@ -1742,7 +1742,7 @@ static int iwl4965_hw_get_temperature(const struct iwl_priv *priv)
1742 temperature /= (R3 - R1); 1742 temperature /= (R3 - R1);
1743 temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; 1743 temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET;
1744 1744
1745 IWL_DEBUG_TEMP("Calibrated temperature: %dK, %dC\n", 1745 IWL_DEBUG_TEMP(priv, "Calibrated temperature: %dK, %dC\n",
1746 temperature, KELVIN_TO_CELSIUS(temperature)); 1746 temperature, KELVIN_TO_CELSIUS(temperature));
1747 1747
1748 return temperature; 1748 return temperature;
@@ -1765,7 +1765,7 @@ static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv)
1765 int temp_diff; 1765 int temp_diff;
1766 1766
1767 if (!test_bit(STATUS_STATISTICS, &priv->status)) { 1767 if (!test_bit(STATUS_STATISTICS, &priv->status)) {
1768 IWL_DEBUG_TEMP("Temperature not updated -- no statistics.\n"); 1768 IWL_DEBUG_TEMP(priv, "Temperature not updated -- no statistics.\n");
1769 return 0; 1769 return 0;
1770 } 1770 }
1771 1771
@@ -1773,19 +1773,19 @@ static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv)
1773 1773
1774 /* get absolute value */ 1774 /* get absolute value */
1775 if (temp_diff < 0) { 1775 if (temp_diff < 0) {
1776 IWL_DEBUG_POWER("Getting cooler, delta %d, \n", temp_diff); 1776 IWL_DEBUG_POWER(priv, "Getting cooler, delta %d, \n", temp_diff);
1777 temp_diff = -temp_diff; 1777 temp_diff = -temp_diff;
1778 } else if (temp_diff == 0) 1778 } else if (temp_diff == 0)
1779 IWL_DEBUG_POWER("Same temp, \n"); 1779 IWL_DEBUG_POWER(priv, "Same temp, \n");
1780 else 1780 else
1781 IWL_DEBUG_POWER("Getting warmer, delta %d, \n", temp_diff); 1781 IWL_DEBUG_POWER(priv, "Getting warmer, delta %d, \n", temp_diff);
1782 1782
1783 if (temp_diff < IWL_TEMPERATURE_THRESHOLD) { 1783 if (temp_diff < IWL_TEMPERATURE_THRESHOLD) {
1784 IWL_DEBUG_POWER("Thermal txpower calib not needed\n"); 1784 IWL_DEBUG_POWER(priv, "Thermal txpower calib not needed\n");
1785 return 0; 1785 return 0;
1786 } 1786 }
1787 1787
1788 IWL_DEBUG_POWER("Thermal txpower calib needed\n"); 1788 IWL_DEBUG_POWER(priv, "Thermal txpower calib needed\n");
1789 1789
1790 return 1; 1790 return 1;
1791} 1791}
@@ -1800,12 +1800,12 @@ static void iwl4965_temperature_calib(struct iwl_priv *priv)
1800 1800
1801 if (priv->temperature != temp) { 1801 if (priv->temperature != temp) {
1802 if (priv->temperature) 1802 if (priv->temperature)
1803 IWL_DEBUG_TEMP("Temperature changed " 1803 IWL_DEBUG_TEMP(priv, "Temperature changed "
1804 "from %dC to %dC\n", 1804 "from %dC to %dC\n",
1805 KELVIN_TO_CELSIUS(priv->temperature), 1805 KELVIN_TO_CELSIUS(priv->temperature),
1806 KELVIN_TO_CELSIUS(temp)); 1806 KELVIN_TO_CELSIUS(temp));
1807 else 1807 else
1808 IWL_DEBUG_TEMP("Temperature " 1808 IWL_DEBUG_TEMP(priv, "Temperature "
1809 "initialized to %dC\n", 1809 "initialized to %dC\n",
1810 KELVIN_TO_CELSIUS(temp)); 1810 KELVIN_TO_CELSIUS(temp));
1811 } 1811 }
@@ -1995,8 +1995,8 @@ static u16 iwl4965_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
1995 addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; 1995 addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid;
1996 addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; 1996 addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid;
1997 addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; 1997 addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn;
1998 addsta->reserved1 = __constant_cpu_to_le16(0); 1998 addsta->reserved1 = cpu_to_le16(0);
1999 addsta->reserved2 = __constant_cpu_to_le32(0); 1999 addsta->reserved2 = cpu_to_le32(0);
2000 2000
2001 return (u16)sizeof(struct iwl4965_addsta_cmd); 2001 return (u16)sizeof(struct iwl4965_addsta_cmd);
2002} 2002}
@@ -2022,7 +2022,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2022 int i, sh, idx; 2022 int i, sh, idx;
2023 u16 seq; 2023 u16 seq;
2024 if (agg->wait_for_ba) 2024 if (agg->wait_for_ba)
2025 IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); 2025 IWL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n");
2026 2026
2027 agg->frame_count = tx_resp->frame_count; 2027 agg->frame_count = tx_resp->frame_count;
2028 agg->start_idx = start_idx; 2028 agg->start_idx = start_idx;
@@ -2036,7 +2036,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2036 idx = start_idx; 2036 idx = start_idx;
2037 2037
2038 /* FIXME: code repetition */ 2038 /* FIXME: code repetition */
2039 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", 2039 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n",
2040 agg->frame_count, agg->start_idx, idx); 2040 agg->frame_count, agg->start_idx, idx);
2041 2041
2042 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); 2042 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
@@ -2047,9 +2047,9 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2047 iwl_hwrate_to_tx_control(priv, rate_n_flags, info); 2047 iwl_hwrate_to_tx_control(priv, rate_n_flags, info);
2048 /* FIXME: code repetition end */ 2048 /* FIXME: code repetition end */
2049 2049
2050 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", 2050 IWL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n",
2051 status & 0xff, tx_resp->failure_frame); 2051 status & 0xff, tx_resp->failure_frame);
2052 IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); 2052 IWL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags);
2053 2053
2054 agg->wait_for_ba = 0; 2054 agg->wait_for_ba = 0;
2055 } else { 2055 } else {
@@ -2069,7 +2069,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2069 AGG_TX_STATE_ABORT_MSK)) 2069 AGG_TX_STATE_ABORT_MSK))
2070 continue; 2070 continue;
2071 2071
2072 IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", 2072 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n",
2073 agg->frame_count, txq_id, idx); 2073 agg->frame_count, txq_id, idx);
2074 2074
2075 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx); 2075 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
@@ -2083,7 +2083,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2083 return -1; 2083 return -1;
2084 } 2084 }
2085 2085
2086 IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", 2086 IWL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n",
2087 i, idx, SEQ_TO_SN(sc)); 2087 i, idx, SEQ_TO_SN(sc));
2088 2088
2089 sh = idx - start; 2089 sh = idx - start;
@@ -2101,13 +2101,13 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv,
2101 sh = 0; 2101 sh = 0;
2102 } 2102 }
2103 bitmap |= 1ULL << sh; 2103 bitmap |= 1ULL << sh;
2104 IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%llx\n", 2104 IWL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n",
2105 start, (unsigned long long)bitmap); 2105 start, (unsigned long long)bitmap);
2106 } 2106 }
2107 2107
2108 agg->bitmap = bitmap; 2108 agg->bitmap = bitmap;
2109 agg->start_idx = start; 2109 agg->start_idx = start;
2110 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", 2110 IWL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n",
2111 agg->frame_count, agg->start_idx, 2111 agg->frame_count, agg->start_idx,
2112 (unsigned long long)agg->bitmap); 2112 (unsigned long long)agg->bitmap);
2113 2113
@@ -2176,7 +2176,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2176 2176
2177 if (txq->q.read_ptr != (scd_ssn & 0xff)) { 2177 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
2178 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); 2178 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
2179 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim scd_ssn " 2179 IWL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn "
2180 "%d index %d\n", scd_ssn , index); 2180 "%d index %d\n", scd_ssn , index);
2181 freed = iwl_tx_queue_reclaim(priv, txq_id, index); 2181 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
2182 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 2182 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
@@ -2199,7 +2199,7 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2199 le32_to_cpu(tx_resp->rate_n_flags), 2199 le32_to_cpu(tx_resp->rate_n_flags),
2200 info); 2200 info);
2201 2201
2202 IWL_DEBUG_TX_REPLY("TXQ %d status %s (0x%08x) " 2202 IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) "
2203 "rate_n_flags 0x%x retries %d\n", 2203 "rate_n_flags 0x%x retries %d\n",
2204 txq_id, 2204 txq_id,
2205 iwl_get_tx_fail_reason(status), status, 2205 iwl_get_tx_fail_reason(status), status,
@@ -2247,7 +2247,7 @@ static int iwl4965_calc_rssi(struct iwl_priv *priv,
2247 if (valid_antennae & (1 << i)) 2247 if (valid_antennae & (1 << i))
2248 max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); 2248 max_rssi = max(ncphy->rssi_info[i << 1], max_rssi);
2249 2249
2250 IWL_DEBUG_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", 2250 IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
2251 ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], 2251 ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4],
2252 max_rssi, agc); 2252 max_rssi, agc);
2253 2253
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 89d92a8ca157..e3cba61d1543 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -43,6 +43,7 @@
43#include "iwl-sta.h" 43#include "iwl-sta.h"
44#include "iwl-helpers.h" 44#include "iwl-helpers.h"
45#include "iwl-5000-hw.h" 45#include "iwl-5000-hw.h"
46#include "iwl-6000-hw.h"
46 47
47/* Highest firmware API version supported */ 48/* Highest firmware API version supported */
48#define IWL5000_UCODE_API_MAX 1 49#define IWL5000_UCODE_API_MAX 1
@@ -84,7 +85,7 @@ static int iwl5000_apm_stop_master(struct iwl_priv *priv)
84 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); 85 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
85 86
86 spin_unlock_irqrestore(&priv->lock, flags); 87 spin_unlock_irqrestore(&priv->lock, flags);
87 IWL_DEBUG_INFO("stop master\n"); 88 IWL_DEBUG_INFO(priv, "stop master\n");
88 89
89 return 0; 90 return 0;
90} 91}
@@ -108,7 +109,8 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
108 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 109 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
109 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); 110 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
110 111
111 iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL); 112 if (priv->cfg->need_pll_cfg)
113 iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL);
112 114
113 /* set "initialization complete" bit to move adapter 115 /* set "initialization complete" bit to move adapter
114 * D0U* --> D0A* state */ 116 * D0U* --> D0A* state */
@@ -118,7 +120,7 @@ static int iwl5000_apm_init(struct iwl_priv *priv)
118 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL, 120 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
119 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); 121 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
120 if (ret < 0) { 122 if (ret < 0) {
121 IWL_DEBUG_INFO("Failed to init the card\n"); 123 IWL_DEBUG_INFO(priv, "Failed to init the card\n");
122 return ret; 124 return ret;
123 } 125 }
124 126
@@ -176,7 +178,8 @@ static int iwl5000_apm_reset(struct iwl_priv *priv)
176 178
177 /* FIXME: put here L1A -L0S w/a */ 179 /* FIXME: put here L1A -L0S w/a */
178 180
179 iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL); 181 if (priv->cfg->need_pll_cfg)
182 iwl_set_bit(priv, CSR_ANA_PLL_CFG, CSR50_ANA_PLL_CFG_VAL);
180 183
181 /* set "initialization complete" bit to move adapter 184 /* set "initialization complete" bit to move adapter
182 * D0U* --> D0A* state */ 185 * D0U* --> D0A* state */
@@ -186,7 +189,7 @@ static int iwl5000_apm_reset(struct iwl_priv *priv)
186 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL, 189 ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL,
187 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); 190 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
188 if (ret < 0) { 191 if (ret < 0) {
189 IWL_DEBUG_INFO("Failed to init the card\n"); 192 IWL_DEBUG_INFO(priv, "Failed to init the card\n");
190 goto out; 193 goto out;
191 } 194 }
192 195
@@ -338,7 +341,7 @@ static void iwl5000_gain_computation(struct iwl_priv *priv,
338 data->delta_gain_code[i] |= (1 << 2); 341 data->delta_gain_code[i] |= (1 << 2);
339 } 342 }
340 343
341 IWL_DEBUG_CALIB("Delta gains: ANT_B = %d ANT_C = %d\n", 344 IWL_DEBUG_CALIB(priv, "Delta gains: ANT_B = %d ANT_C = %d\n",
342 data->delta_gain_code[1], data->delta_gain_code[2]); 345 data->delta_gain_code[1], data->delta_gain_code[2]);
343 346
344 if (!data->radio_write) { 347 if (!data->radio_write) {
@@ -387,11 +390,11 @@ static void iwl5000_chain_noise_reset(struct iwl_priv *priv)
387 IWL_ERR(priv, 390 IWL_ERR(priv,
388 "Could not send REPLY_PHY_CALIBRATION_CMD\n"); 391 "Could not send REPLY_PHY_CALIBRATION_CMD\n");
389 data->state = IWL_CHAIN_NOISE_ACCUMULATE; 392 data->state = IWL_CHAIN_NOISE_ACCUMULATE;
390 IWL_DEBUG_CALIB("Run chain_noise_calibrate\n"); 393 IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n");
391 } 394 }
392} 395}
393 396
394static void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info, 397void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
395 __le32 *tx_flags) 398 __le32 *tx_flags)
396{ 399{
397 if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || 400 if ((info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) ||
@@ -518,7 +521,7 @@ static void iwl5000_rx_calib_result(struct iwl_priv *priv,
518static void iwl5000_rx_calib_complete(struct iwl_priv *priv, 521static void iwl5000_rx_calib_complete(struct iwl_priv *priv,
519 struct iwl_rx_mem_buffer *rxb) 522 struct iwl_rx_mem_buffer *rxb)
520{ 523{
521 IWL_DEBUG_INFO("Init. calibration is completed, restarting fw.\n"); 524 IWL_DEBUG_INFO(priv, "Init. calibration is completed, restarting fw.\n");
522 queue_work(priv->workqueue, &priv->restart); 525 queue_work(priv->workqueue, &priv->restart);
523} 526}
524 527
@@ -586,7 +589,7 @@ static int iwl5000_load_given_ucode(struct iwl_priv *priv,
586 if (ret) 589 if (ret)
587 return ret; 590 return ret;
588 591
589 IWL_DEBUG_INFO("INST uCode section being loaded...\n"); 592 IWL_DEBUG_INFO(priv, "INST uCode section being loaded...\n");
590 ret = wait_event_interruptible_timeout(priv->wait_command_queue, 593 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
591 priv->ucode_write_complete, 5 * HZ); 594 priv->ucode_write_complete, 5 * HZ);
592 if (ret == -ERESTARTSYS) { 595 if (ret == -ERESTARTSYS) {
@@ -606,7 +609,7 @@ static int iwl5000_load_given_ucode(struct iwl_priv *priv,
606 if (ret) 609 if (ret)
607 return ret; 610 return ret;
608 611
609 IWL_DEBUG_INFO("DATA uCode section being loaded...\n"); 612 IWL_DEBUG_INFO(priv, "DATA uCode section being loaded...\n");
610 613
611 ret = wait_event_interruptible_timeout(priv->wait_command_queue, 614 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
612 priv->ucode_write_complete, 5 * HZ); 615 priv->ucode_write_complete, 5 * HZ);
@@ -631,20 +634,20 @@ static int iwl5000_load_ucode(struct iwl_priv *priv)
631 634
632 /* check whether init ucode should be loaded, or rather runtime ucode */ 635 /* check whether init ucode should be loaded, or rather runtime ucode */
633 if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) { 636 if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) {
634 IWL_DEBUG_INFO("Init ucode found. Loading init ucode...\n"); 637 IWL_DEBUG_INFO(priv, "Init ucode found. Loading init ucode...\n");
635 ret = iwl5000_load_given_ucode(priv, 638 ret = iwl5000_load_given_ucode(priv,
636 &priv->ucode_init, &priv->ucode_init_data); 639 &priv->ucode_init, &priv->ucode_init_data);
637 if (!ret) { 640 if (!ret) {
638 IWL_DEBUG_INFO("Init ucode load complete.\n"); 641 IWL_DEBUG_INFO(priv, "Init ucode load complete.\n");
639 priv->ucode_type = UCODE_INIT; 642 priv->ucode_type = UCODE_INIT;
640 } 643 }
641 } else { 644 } else {
642 IWL_DEBUG_INFO("Init ucode not found, or already loaded. " 645 IWL_DEBUG_INFO(priv, "Init ucode not found, or already loaded. "
643 "Loading runtime ucode...\n"); 646 "Loading runtime ucode...\n");
644 ret = iwl5000_load_given_ucode(priv, 647 ret = iwl5000_load_given_ucode(priv,
645 &priv->ucode_code, &priv->ucode_data); 648 &priv->ucode_code, &priv->ucode_data);
646 if (!ret) { 649 if (!ret) {
647 IWL_DEBUG_INFO("Runtime ucode load complete.\n"); 650 IWL_DEBUG_INFO(priv, "Runtime ucode load complete.\n");
648 priv->ucode_type = UCODE_RT; 651 priv->ucode_type = UCODE_RT;
649 } 652 }
650 } 653 }
@@ -660,7 +663,7 @@ static void iwl5000_init_alive_start(struct iwl_priv *priv)
660 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { 663 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
661 /* We had an error bringing up the hardware, so take it 664 /* We had an error bringing up the hardware, so take it
662 * all the way back down so we can try again */ 665 * all the way back down so we can try again */
663 IWL_DEBUG_INFO("Initialize Alive failed.\n"); 666 IWL_DEBUG_INFO(priv, "Initialize Alive failed.\n");
664 goto restart; 667 goto restart;
665 } 668 }
666 669
@@ -670,7 +673,7 @@ static void iwl5000_init_alive_start(struct iwl_priv *priv)
670 if (iwl_verify_ucode(priv)) { 673 if (iwl_verify_ucode(priv)) {
671 /* Runtime instruction load was bad; 674 /* Runtime instruction load was bad;
672 * take it all the way back down so we can try again */ 675 * take it all the way back down so we can try again */
673 IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n"); 676 IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n");
674 goto restart; 677 goto restart;
675 } 678 }
676 679
@@ -713,7 +716,7 @@ static void iwl5000_tx_queue_set_status(struct iwl_priv *priv,
713 716
714 txq->sched_retry = scd_retry; 717 txq->sched_retry = scd_retry;
715 718
716 IWL_DEBUG_INFO("%s %s Queue %d on AC %d\n", 719 IWL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n",
717 active ? "Activate" : "Deactivate", 720 active ? "Activate" : "Deactivate",
718 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); 721 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
719} 722}
@@ -840,8 +843,18 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
840 priv->hw_params.tfd_size = sizeof(struct iwl_tfd); 843 priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
841 priv->hw_params.max_stations = IWL5000_STATION_COUNT; 844 priv->hw_params.max_stations = IWL5000_STATION_COUNT;
842 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID; 845 priv->hw_params.bcast_sta_id = IWL5000_BROADCAST_ID;
843 priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE; 846
844 priv->hw_params.max_inst_size = IWL50_RTC_INST_SIZE; 847 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
848 case CSR_HW_REV_TYPE_6x00:
849 case CSR_HW_REV_TYPE_6x50:
850 priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
851 priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
852 break;
853 default:
854 priv->hw_params.max_data_size = IWL50_RTC_DATA_SIZE;
855 priv->hw_params.max_inst_size = IWL50_RTC_INST_SIZE;
856 }
857
845 priv->hw_params.max_bsm_size = 0; 858 priv->hw_params.max_bsm_size = 0;
846 priv->hw_params.fat_channel = BIT(IEEE80211_BAND_2GHZ) | 859 priv->hw_params.fat_channel = BIT(IEEE80211_BAND_2GHZ) |
847 BIT(IEEE80211_BAND_5GHZ); 860 BIT(IEEE80211_BAND_5GHZ);
@@ -849,61 +862,40 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
849 862
850 priv->hw_params.sens = &iwl5000_sensitivity; 863 priv->hw_params.sens = &iwl5000_sensitivity;
851 864
852 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 865 priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
853 case CSR_HW_REV_TYPE_5100: 866 priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
854 priv->hw_params.tx_chains_num = 1; 867 priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
855 priv->hw_params.rx_chains_num = 2; 868 priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
856 priv->hw_params.valid_tx_ant = ANT_B;
857 priv->hw_params.valid_rx_ant = ANT_AB;
858 break;
859 case CSR_HW_REV_TYPE_5150:
860 priv->hw_params.tx_chains_num = 1;
861 priv->hw_params.rx_chains_num = 2;
862 priv->hw_params.valid_tx_ant = ANT_A;
863 priv->hw_params.valid_rx_ant = ANT_AB;
864 break;
865 case CSR_HW_REV_TYPE_5300:
866 case CSR_HW_REV_TYPE_5350:
867 priv->hw_params.tx_chains_num = 3;
868 priv->hw_params.rx_chains_num = 3;
869 priv->hw_params.valid_tx_ant = ANT_ABC;
870 priv->hw_params.valid_rx_ant = ANT_ABC;
871 break;
872 }
873 869
874 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 870 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
875 case CSR_HW_REV_TYPE_5100:
876 case CSR_HW_REV_TYPE_5300:
877 case CSR_HW_REV_TYPE_5350:
878 /* 5X00 and 5350 wants in Celsius */
879 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
880 break;
881 case CSR_HW_REV_TYPE_5150: 871 case CSR_HW_REV_TYPE_5150:
882 /* 5150 wants in Kelvin */ 872 /* 5150 wants in Kelvin */
883 priv->hw_params.ct_kill_threshold = 873 priv->hw_params.ct_kill_threshold =
884 iwl5150_get_ct_threshold(priv); 874 iwl5150_get_ct_threshold(priv);
885 break; 875 break;
876 default:
877 /* all others want Celsius */
878 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
879 break;
886 } 880 }
887 881
888 /* Set initial calibration set */ 882 /* Set initial calibration set */
889 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { 883 switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) {
890 case CSR_HW_REV_TYPE_5100: 884 case CSR_HW_REV_TYPE_5150:
891 case CSR_HW_REV_TYPE_5300:
892 case CSR_HW_REV_TYPE_5350:
893 priv->hw_params.calib_init_cfg = 885 priv->hw_params.calib_init_cfg =
894 BIT(IWL_CALIB_XTAL) | 886 BIT(IWL_CALIB_DC) |
895 BIT(IWL_CALIB_LO) | 887 BIT(IWL_CALIB_LO) |
896 BIT(IWL_CALIB_TX_IQ) | 888 BIT(IWL_CALIB_TX_IQ) |
897 BIT(IWL_CALIB_TX_IQ_PERD) |
898 BIT(IWL_CALIB_BASE_BAND); 889 BIT(IWL_CALIB_BASE_BAND);
890
899 break; 891 break;
900 case CSR_HW_REV_TYPE_5150: 892 default:
901 priv->hw_params.calib_init_cfg = 893 priv->hw_params.calib_init_cfg =
902 BIT(IWL_CALIB_DC) | 894 BIT(IWL_CALIB_XTAL) |
903 BIT(IWL_CALIB_LO) | 895 BIT(IWL_CALIB_LO) |
904 BIT(IWL_CALIB_TX_IQ) | 896 BIT(IWL_CALIB_TX_IQ) |
897 BIT(IWL_CALIB_TX_IQ_PERD) |
905 BIT(IWL_CALIB_BASE_BAND); 898 BIT(IWL_CALIB_BASE_BAND);
906
907 break; 899 break;
908 } 900 }
909 901
@@ -1113,7 +1105,7 @@ static int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
1113 return 0; 1105 return 0;
1114} 1106}
1115 1107
1116static u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) 1108u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
1117{ 1109{
1118 u16 size = (u16)sizeof(struct iwl_addsta_cmd); 1110 u16 size = (u16)sizeof(struct iwl_addsta_cmd);
1119 memcpy(data, cmd, size); 1111 memcpy(data, cmd, size);
@@ -1151,7 +1143,7 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1151 u16 seq; 1143 u16 seq;
1152 1144
1153 if (agg->wait_for_ba) 1145 if (agg->wait_for_ba)
1154 IWL_DEBUG_TX_REPLY("got tx response w/o block-ack\n"); 1146 IWL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n");
1155 1147
1156 agg->frame_count = tx_resp->frame_count; 1148 agg->frame_count = tx_resp->frame_count;
1157 agg->start_idx = start_idx; 1149 agg->start_idx = start_idx;
@@ -1165,7 +1157,7 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1165 idx = start_idx; 1157 idx = start_idx;
1166 1158
1167 /* FIXME: code repetition */ 1159 /* FIXME: code repetition */
1168 IWL_DEBUG_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", 1160 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n",
1169 agg->frame_count, agg->start_idx, idx); 1161 agg->frame_count, agg->start_idx, idx);
1170 1162
1171 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]); 1163 info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb[0]);
@@ -1177,9 +1169,9 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1177 1169
1178 /* FIXME: code repetition end */ 1170 /* FIXME: code repetition end */
1179 1171
1180 IWL_DEBUG_TX_REPLY("1 Frame 0x%x failure :%d\n", 1172 IWL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n",
1181 status & 0xff, tx_resp->failure_frame); 1173 status & 0xff, tx_resp->failure_frame);
1182 IWL_DEBUG_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); 1174 IWL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags);
1183 1175
1184 agg->wait_for_ba = 0; 1176 agg->wait_for_ba = 0;
1185 } else { 1177 } else {
@@ -1199,7 +1191,7 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1199 AGG_TX_STATE_ABORT_MSK)) 1191 AGG_TX_STATE_ABORT_MSK))
1200 continue; 1192 continue;
1201 1193
1202 IWL_DEBUG_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", 1194 IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n",
1203 agg->frame_count, txq_id, idx); 1195 agg->frame_count, txq_id, idx);
1204 1196
1205 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx); 1197 hdr = iwl_tx_queue_get_hdr(priv, txq_id, idx);
@@ -1214,7 +1206,7 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1214 return -1; 1206 return -1;
1215 } 1207 }
1216 1208
1217 IWL_DEBUG_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", 1209 IWL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n",
1218 i, idx, SEQ_TO_SN(sc)); 1210 i, idx, SEQ_TO_SN(sc));
1219 1211
1220 sh = idx - start; 1212 sh = idx - start;
@@ -1232,13 +1224,13 @@ static int iwl5000_tx_status_reply_tx(struct iwl_priv *priv,
1232 sh = 0; 1224 sh = 0;
1233 } 1225 }
1234 bitmap |= 1ULL << sh; 1226 bitmap |= 1ULL << sh;
1235 IWL_DEBUG_TX_REPLY("start=%d bitmap=0x%llx\n", 1227 IWL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n",
1236 start, (unsigned long long)bitmap); 1228 start, (unsigned long long)bitmap);
1237 } 1229 }
1238 1230
1239 agg->bitmap = bitmap; 1231 agg->bitmap = bitmap;
1240 agg->start_idx = start; 1232 agg->start_idx = start;
1241 IWL_DEBUG_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", 1233 IWL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n",
1242 agg->frame_count, agg->start_idx, 1234 agg->frame_count, agg->start_idx,
1243 (unsigned long long)agg->bitmap); 1235 (unsigned long long)agg->bitmap);
1244 1236
@@ -1291,7 +1283,7 @@ static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
1291 1283
1292 if (txq->q.read_ptr != (scd_ssn & 0xff)) { 1284 if (txq->q.read_ptr != (scd_ssn & 0xff)) {
1293 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); 1285 index = iwl_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd);
1294 IWL_DEBUG_TX_REPLY("Retry scheduler reclaim " 1286 IWL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim "
1295 "scd_ssn=%d idx=%d txq=%d swq=%d\n", 1287 "scd_ssn=%d idx=%d txq=%d swq=%d\n",
1296 scd_ssn , index, txq_id, txq->swq_id); 1288 scd_ssn , index, txq_id, txq->swq_id);
1297 1289
@@ -1318,7 +1310,7 @@ static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
1318 le32_to_cpu(tx_resp->rate_n_flags), 1310 le32_to_cpu(tx_resp->rate_n_flags),
1319 info); 1311 info);
1320 1312
1321 IWL_DEBUG_TX_REPLY("TXQ %d status %s (0x%08x) rate_n_flags " 1313 IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) rate_n_flags "
1322 "0x%x retries %d\n", 1314 "0x%x retries %d\n",
1323 txq_id, 1315 txq_id,
1324 iwl_get_tx_fail_reason(status), status, 1316 iwl_get_tx_fail_reason(status), status,
@@ -1342,7 +1334,7 @@ static void iwl5000_rx_reply_tx(struct iwl_priv *priv,
1342} 1334}
1343 1335
1344/* Currently 5000 is the superset of everything */ 1336/* Currently 5000 is the superset of everything */
1345static u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len) 1337u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len)
1346{ 1338{
1347 return len; 1339 return len;
1348} 1340}
@@ -1389,7 +1381,7 @@ static int iwl5000_send_rxon_assoc(struct iwl_priv *priv)
1389 (rxon1->acquisition_data == rxon2->acquisition_data) && 1381 (rxon1->acquisition_data == rxon2->acquisition_data) &&
1390 (rxon1->rx_chain == rxon2->rx_chain) && 1382 (rxon1->rx_chain == rxon2->rx_chain) &&
1391 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { 1383 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
1392 IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n"); 1384 IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n");
1393 return 0; 1385 return 0;
1394 } 1386 }
1395 1387
@@ -1419,12 +1411,19 @@ static int iwl5000_send_rxon_assoc(struct iwl_priv *priv)
1419static int iwl5000_send_tx_power(struct iwl_priv *priv) 1411static int iwl5000_send_tx_power(struct iwl_priv *priv)
1420{ 1412{
1421 struct iwl5000_tx_power_dbm_cmd tx_power_cmd; 1413 struct iwl5000_tx_power_dbm_cmd tx_power_cmd;
1414 u8 tx_ant_cfg_cmd;
1422 1415
1423 /* half dBm need to multiply */ 1416 /* half dBm need to multiply */
1424 tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt); 1417 tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);
1425 tx_power_cmd.flags = IWL50_TX_POWER_NO_CLOSED; 1418 tx_power_cmd.flags = IWL50_TX_POWER_NO_CLOSED;
1426 tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO; 1419 tx_power_cmd.srv_chan_lmt = IWL50_TX_POWER_AUTO;
1427 return iwl_send_cmd_pdu_async(priv, REPLY_TX_POWER_DBM_CMD, 1420
1421 if (IWL_UCODE_API(priv->ucode_ver) == 1)
1422 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD_V1;
1423 else
1424 tx_ant_cfg_cmd = REPLY_TX_POWER_DBM_CMD;
1425
1426 return iwl_send_cmd_pdu_async(priv, tx_ant_cfg_cmd,
1428 sizeof(tx_power_cmd), &tx_power_cmd, 1427 sizeof(tx_power_cmd), &tx_power_cmd,
1429 NULL); 1428 NULL);
1430} 1429}
@@ -1436,7 +1435,7 @@ static void iwl5000_temperature(struct iwl_priv *priv)
1436} 1435}
1437 1436
1438/* Calc max signal level (dBm) among 3 possible receivers */ 1437/* Calc max signal level (dBm) among 3 possible receivers */
1439static int iwl5000_calc_rssi(struct iwl_priv *priv, 1438int iwl5000_calc_rssi(struct iwl_priv *priv,
1440 struct iwl_rx_phy_res *rx_resp) 1439 struct iwl_rx_phy_res *rx_resp)
1441{ 1440{
1442 /* data from PHY/DSP regarding signal strength, etc., 1441 /* data from PHY/DSP regarding signal strength, etc.,
@@ -1465,7 +1464,7 @@ static int iwl5000_calc_rssi(struct iwl_priv *priv,
1465 max_rssi = max_t(u32, rssi_a, rssi_b); 1464 max_rssi = max_t(u32, rssi_a, rssi_b);
1466 max_rssi = max_t(u32, max_rssi, rssi_c); 1465 max_rssi = max_t(u32, max_rssi, rssi_c);
1467 1466
1468 IWL_DEBUG_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", 1467 IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n",
1469 rssi_a, rssi_b, rssi_c, max_rssi, agc); 1468 rssi_a, rssi_b, rssi_c, max_rssi, agc);
1470 1469
1471 /* dBm = max_rssi dB - agc dB - constant. 1470 /* dBm = max_rssi dB - agc dB - constant.
@@ -1473,11 +1472,11 @@ static int iwl5000_calc_rssi(struct iwl_priv *priv,
1473 return max_rssi - agc - IWL49_RSSI_OFFSET; 1472 return max_rssi - agc - IWL49_RSSI_OFFSET;
1474} 1473}
1475 1474
1476static struct iwl_hcmd_ops iwl5000_hcmd = { 1475struct iwl_hcmd_ops iwl5000_hcmd = {
1477 .rxon_assoc = iwl5000_send_rxon_assoc, 1476 .rxon_assoc = iwl5000_send_rxon_assoc,
1478}; 1477};
1479 1478
1480static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = { 1479struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
1481 .get_hcmd_size = iwl5000_get_hcmd_size, 1480 .get_hcmd_size = iwl5000_get_hcmd_size,
1482 .build_addsta_hcmd = iwl5000_build_addsta_hcmd, 1481 .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
1483 .gain_computation = iwl5000_gain_computation, 1482 .gain_computation = iwl5000_gain_computation,
@@ -1486,7 +1485,7 @@ static struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
1486 .calc_rssi = iwl5000_calc_rssi, 1485 .calc_rssi = iwl5000_calc_rssi,
1487}; 1486};
1488 1487
1489static struct iwl_lib_ops iwl5000_lib = { 1488struct iwl_lib_ops iwl5000_lib = {
1490 .set_hw_params = iwl5000_hw_set_hw_params, 1489 .set_hw_params = iwl5000_hw_set_hw_params,
1491 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, 1490 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
1492 .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl, 1491 .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
@@ -1556,6 +1555,9 @@ struct iwl_cfg iwl5300_agn_cfg = {
1556 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 1555 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1557 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 1556 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1558 .mod_params = &iwl50_mod_params, 1557 .mod_params = &iwl50_mod_params,
1558 .valid_tx_ant = ANT_ABC,
1559 .valid_rx_ant = ANT_ABC,
1560 .need_pll_cfg = true,
1559}; 1561};
1560 1562
1561struct iwl_cfg iwl5100_bg_cfg = { 1563struct iwl_cfg iwl5100_bg_cfg = {
@@ -1569,6 +1571,9 @@ struct iwl_cfg iwl5100_bg_cfg = {
1569 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 1571 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1570 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 1572 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1571 .mod_params = &iwl50_mod_params, 1573 .mod_params = &iwl50_mod_params,
1574 .valid_tx_ant = ANT_B,
1575 .valid_rx_ant = ANT_AB,
1576 .need_pll_cfg = true,
1572}; 1577};
1573 1578
1574struct iwl_cfg iwl5100_abg_cfg = { 1579struct iwl_cfg iwl5100_abg_cfg = {
@@ -1582,6 +1587,9 @@ struct iwl_cfg iwl5100_abg_cfg = {
1582 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 1587 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1583 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 1588 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1584 .mod_params = &iwl50_mod_params, 1589 .mod_params = &iwl50_mod_params,
1590 .valid_tx_ant = ANT_B,
1591 .valid_rx_ant = ANT_AB,
1592 .need_pll_cfg = true,
1585}; 1593};
1586 1594
1587struct iwl_cfg iwl5100_agn_cfg = { 1595struct iwl_cfg iwl5100_agn_cfg = {
@@ -1595,6 +1603,9 @@ struct iwl_cfg iwl5100_agn_cfg = {
1595 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 1603 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
1596 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 1604 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
1597 .mod_params = &iwl50_mod_params, 1605 .mod_params = &iwl50_mod_params,
1606 .valid_tx_ant = ANT_B,
1607 .valid_rx_ant = ANT_AB,
1608 .need_pll_cfg = true,
1598}; 1609};
1599 1610
1600struct iwl_cfg iwl5350_agn_cfg = { 1611struct iwl_cfg iwl5350_agn_cfg = {
@@ -1608,6 +1619,9 @@ struct iwl_cfg iwl5350_agn_cfg = {
1608 .eeprom_ver = EEPROM_5050_EEPROM_VERSION, 1619 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1609 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, 1620 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
1610 .mod_params = &iwl50_mod_params, 1621 .mod_params = &iwl50_mod_params,
1622 .valid_tx_ant = ANT_ABC,
1623 .valid_rx_ant = ANT_ABC,
1624 .need_pll_cfg = true,
1611}; 1625};
1612 1626
1613struct iwl_cfg iwl5150_agn_cfg = { 1627struct iwl_cfg iwl5150_agn_cfg = {
@@ -1621,6 +1635,9 @@ struct iwl_cfg iwl5150_agn_cfg = {
1621 .eeprom_ver = EEPROM_5050_EEPROM_VERSION, 1635 .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
1622 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, 1636 .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
1623 .mod_params = &iwl50_mod_params, 1637 .mod_params = &iwl50_mod_params,
1638 .valid_tx_ant = ANT_A,
1639 .valid_rx_ant = ANT_AB,
1640 .need_pll_cfg = true,
1624}; 1641};
1625 1642
1626MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX)); 1643MODULE_FIRMWARE(IWL5000_MODULE_FIRMWARE(IWL5000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 4515a6053dd0..edfa5e149f71 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -46,8 +46,8 @@
46#include "iwl-5000-hw.h" 46#include "iwl-5000-hw.h"
47 47
48/* Highest firmware API version supported */ 48/* Highest firmware API version supported */
49#define IWL6000_UCODE_API_MAX 1 49#define IWL6000_UCODE_API_MAX 2
50#define IWL6050_UCODE_API_MAX 1 50#define IWL6050_UCODE_API_MAX 2
51 51
52/* Lowest firmware API version supported */ 52/* Lowest firmware API version supported */
53#define IWL6000_UCODE_API_MIN 1 53#define IWL6000_UCODE_API_MIN 1
@@ -61,17 +61,33 @@
61#define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode" 61#define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode"
62#define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api) 62#define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api)
63 63
64static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
65 .get_hcmd_size = iwl5000_get_hcmd_size,
66 .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
67 .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
68 .calc_rssi = iwl5000_calc_rssi,
69};
70
71static struct iwl_ops iwl6000_ops = {
72 .lib = &iwl5000_lib,
73 .hcmd = &iwl5000_hcmd,
74 .utils = &iwl6000_hcmd_utils,
75};
76
64struct iwl_cfg iwl6000_2ag_cfg = { 77struct iwl_cfg iwl6000_2ag_cfg = {
65 .name = "6000 Series 2x2 AG", 78 .name = "6000 Series 2x2 AG",
66 .fw_name_pre = IWL6000_FW_PRE, 79 .fw_name_pre = IWL6000_FW_PRE,
67 .ucode_api_max = IWL6000_UCODE_API_MAX, 80 .ucode_api_max = IWL6000_UCODE_API_MAX,
68 .ucode_api_min = IWL6000_UCODE_API_MIN, 81 .ucode_api_min = IWL6000_UCODE_API_MIN,
69 .sku = IWL_SKU_A|IWL_SKU_G, 82 .sku = IWL_SKU_A|IWL_SKU_G,
70 .ops = &iwl5000_ops, 83 .ops = &iwl6000_ops,
71 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 84 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
72 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 85 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
73 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 86 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
74 .mod_params = &iwl50_mod_params, 87 .mod_params = &iwl50_mod_params,
88 .valid_tx_ant = ANT_BC,
89 .valid_rx_ant = ANT_BC,
90 .need_pll_cfg = false,
75}; 91};
76 92
77struct iwl_cfg iwl6000_2agn_cfg = { 93struct iwl_cfg iwl6000_2agn_cfg = {
@@ -80,11 +96,14 @@ struct iwl_cfg iwl6000_2agn_cfg = {
80 .ucode_api_max = IWL6000_UCODE_API_MAX, 96 .ucode_api_max = IWL6000_UCODE_API_MAX,
81 .ucode_api_min = IWL6000_UCODE_API_MIN, 97 .ucode_api_min = IWL6000_UCODE_API_MIN,
82 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 98 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
83 .ops = &iwl5000_ops, 99 .ops = &iwl6000_ops,
84 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 100 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
85 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 101 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
86 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 102 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
87 .mod_params = &iwl50_mod_params, 103 .mod_params = &iwl50_mod_params,
104 .valid_tx_ant = ANT_BC,
105 .valid_rx_ant = ANT_BC,
106 .need_pll_cfg = false,
88}; 107};
89 108
90struct iwl_cfg iwl6050_2agn_cfg = { 109struct iwl_cfg iwl6050_2agn_cfg = {
@@ -93,11 +112,14 @@ struct iwl_cfg iwl6050_2agn_cfg = {
93 .ucode_api_max = IWL6050_UCODE_API_MAX, 112 .ucode_api_max = IWL6050_UCODE_API_MAX,
94 .ucode_api_min = IWL6050_UCODE_API_MIN, 113 .ucode_api_min = IWL6050_UCODE_API_MIN,
95 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 114 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
96 .ops = &iwl5000_ops, 115 .ops = &iwl6000_ops,
97 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 116 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
98 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 117 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
99 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 118 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
100 .mod_params = &iwl50_mod_params, 119 .mod_params = &iwl50_mod_params,
120 .valid_tx_ant = ANT_BC,
121 .valid_rx_ant = ANT_BC,
122 .need_pll_cfg = false,
101}; 123};
102 124
103struct iwl_cfg iwl6000_3agn_cfg = { 125struct iwl_cfg iwl6000_3agn_cfg = {
@@ -106,11 +128,14 @@ struct iwl_cfg iwl6000_3agn_cfg = {
106 .ucode_api_max = IWL6000_UCODE_API_MAX, 128 .ucode_api_max = IWL6000_UCODE_API_MAX,
107 .ucode_api_min = IWL6000_UCODE_API_MIN, 129 .ucode_api_min = IWL6000_UCODE_API_MIN,
108 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 130 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
109 .ops = &iwl5000_ops, 131 .ops = &iwl6000_ops,
110 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 132 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
111 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 133 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
112 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 134 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
113 .mod_params = &iwl50_mod_params, 135 .mod_params = &iwl50_mod_params,
136 .valid_tx_ant = ANT_ABC,
137 .valid_rx_ant = ANT_ABC,
138 .need_pll_cfg = false,
114}; 139};
115 140
116struct iwl_cfg iwl6050_3agn_cfg = { 141struct iwl_cfg iwl6050_3agn_cfg = {
@@ -119,11 +144,14 @@ struct iwl_cfg iwl6050_3agn_cfg = {
119 .ucode_api_max = IWL6050_UCODE_API_MAX, 144 .ucode_api_max = IWL6050_UCODE_API_MAX,
120 .ucode_api_min = IWL6050_UCODE_API_MIN, 145 .ucode_api_min = IWL6050_UCODE_API_MIN,
121 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, 146 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
122 .ops = &iwl5000_ops, 147 .ops = &iwl6000_ops,
123 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE, 148 .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
124 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 149 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
125 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 150 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
126 .mod_params = &iwl50_mod_params, 151 .mod_params = &iwl50_mod_params,
152 .valid_tx_ant = ANT_ABC,
153 .valid_rx_ant = ANT_ABC,
154 .need_pll_cfg = false,
127}; 155};
128 156
129MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); 157MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c b/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c
deleted file mode 100644
index 1217a1da88f5..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-agn-hcmd-check.c
+++ /dev/null
@@ -1,109 +0,0 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2009 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/
28
29#include <linux/kernel.h>
30#include <net/mac80211.h>
31#include "iwl-dev.h"
32#include "iwl-debug.h"
33#include "iwl-commands.h"
34
35
36/**
37 * iwl_check_rxon_cmd - validate RXON structure is valid
38 *
39 * NOTE: This is really only useful during development and can eventually
40 * be #ifdef'd out once the driver is stable and folks aren't actively
41 * making changes
42 */
43int iwl_agn_check_rxon_cmd(struct iwl_priv *priv)
44{
45 int error = 0;
46 int counter = 1;
47 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
48
49 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
50 error |= le32_to_cpu(rxon->flags &
51 (RXON_FLG_TGJ_NARROW_BAND_MSK |
52 RXON_FLG_RADAR_DETECT_MSK));
53 if (error)
54 IWL_WARN(priv, "check 24G fields %d | %d\n",
55 counter++, error);
56 } else {
57 error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
58 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
59 if (error)
60 IWL_WARN(priv, "check 52 fields %d | %d\n",
61 counter++, error);
62 error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
63 if (error)
64 IWL_WARN(priv, "check 52 CCK %d | %d\n",
65 counter++, error);
66 }
67 error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
68 if (error)
69 IWL_WARN(priv, "check mac addr %d | %d\n", counter++, error);
70
71 /* make sure basic rates 6Mbps and 1Mbps are supported */
72 error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
73 ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
74 if (error)
75 IWL_WARN(priv, "check basic rate %d | %d\n", counter++, error);
76
77 error |= (le16_to_cpu(rxon->assoc_id) > 2007);
78 if (error)
79 IWL_WARN(priv, "check assoc id %d | %d\n", counter++, error);
80
81 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
82 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
83 if (error)
84 IWL_WARN(priv, "check CCK and short slot %d | %d\n",
85 counter++, error);
86
87 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
88 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
89 if (error)
90 IWL_WARN(priv, "check CCK & auto detect %d | %d\n",
91 counter++, error);
92
93 error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
94 RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
95 if (error)
96 IWL_WARN(priv, "check TGG and auto detect %d | %d\n",
97 counter++, error);
98
99 if (error)
100 IWL_WARN(priv, "Tuning to channel %d\n",
101 le16_to_cpu(rxon->channel));
102
103 if (error) {
104 IWL_ERR(priv, "Not a valid iwl_rxon_assoc_cmd field values\n");
105 return -1;
106 }
107 return 0;
108}
109
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 13039a024473..04b42c8a7705 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -360,7 +360,7 @@ static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
360 struct ieee80211_sta *sta) 360 struct ieee80211_sta *sta)
361{ 361{
362 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) { 362 if (rs_tl_get_load(lq_data, tid) > IWL_AGG_LOAD_THRESHOLD) {
363 IWL_DEBUG_HT("Starting Tx agg: STA: %pM tid: %d\n", 363 IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n",
364 sta->addr, tid); 364 sta->addr, tid);
365 ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid); 365 ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid);
366 } 366 }
@@ -693,7 +693,7 @@ static u16 rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask,
693 break; 693 break;
694 if (rate_mask & (1 << low)) 694 if (rate_mask & (1 << low))
695 break; 695 break;
696 IWL_DEBUG_RATE("Skipping masked lower rate: %d\n", low); 696 IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low);
697 } 697 }
698 698
699 high = index; 699 high = index;
@@ -703,7 +703,7 @@ static u16 rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask,
703 break; 703 break;
704 if (rate_mask & (1 << high)) 704 if (rate_mask & (1 << high))
705 break; 705 break;
706 IWL_DEBUG_RATE("Skipping masked higher rate: %d\n", high); 706 IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high);
707 } 707 }
708 708
709 return (high << 8) | low; 709 return (high << 8) | low;
@@ -790,7 +790,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
790 u8 active_index = 0; 790 u8 active_index = 0;
791 s32 tpt = 0; 791 s32 tpt = 0;
792 792
793 IWL_DEBUG_RATE_LIMIT("get frame ack response, update rate scale window\n"); 793 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n");
794 794
795 if (!ieee80211_is_data(hdr->frame_control) || 795 if (!ieee80211_is_data(hdr->frame_control) ||
796 is_multicast_ether_addr(hdr->addr1)) 796 is_multicast_ether_addr(hdr->addr1))
@@ -840,7 +840,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
840 (!!(tx_rate & RATE_MCS_GF_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)) || 840 (!!(tx_rate & RATE_MCS_GF_MSK) != !!(info->status.rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD)) ||
841 (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate != 841 (hw->wiphy->bands[priv->band]->bitrates[rs_index].bitrate !=
842 hw->wiphy->bands[info->band]->bitrates[info->status.rates[0].idx].bitrate)) { 842 hw->wiphy->bands[info->band]->bitrates[info->status.rates[0].idx].bitrate)) {
843 IWL_DEBUG_RATE("initial rate does not match 0x%x\n", tx_rate); 843 IWL_DEBUG_RATE(priv, "initial rate does not match 0x%x\n", tx_rate);
844 /* the last LQ command could failed so the LQ in ucode not 844 /* the last LQ command could failed so the LQ in ucode not
845 * the same in driver sync up 845 * the same in driver sync up
846 */ 846 */
@@ -971,7 +971,7 @@ out:
971static void rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy, 971static void rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy,
972 struct iwl_lq_sta *lq_sta) 972 struct iwl_lq_sta *lq_sta)
973{ 973{
974 IWL_DEBUG_RATE("we are staying in the same table\n"); 974 IWL_DEBUG_RATE(priv, "we are staying in the same table\n");
975 lq_sta->stay_in_tbl = 1; /* only place this gets set */ 975 lq_sta->stay_in_tbl = 1; /* only place this gets set */
976 if (is_legacy) { 976 if (is_legacy) {
977 lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT; 977 lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT;
@@ -1150,7 +1150,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1150 if (priv->hw_params.tx_chains_num < 2) 1150 if (priv->hw_params.tx_chains_num < 2)
1151 return -1; 1151 return -1;
1152 1152
1153 IWL_DEBUG_RATE("LQ: try to switch to MIMO2\n"); 1153 IWL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n");
1154 1154
1155 tbl->lq_type = LQ_MIMO2; 1155 tbl->lq_type = LQ_MIMO2;
1156 tbl->is_dup = lq_sta->is_dup; 1156 tbl->is_dup = lq_sta->is_dup;
@@ -1179,16 +1179,16 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1179 1179
1180 rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); 1180 rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index);
1181 1181
1182 IWL_DEBUG_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); 1182 IWL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask);
1183 1183
1184 if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { 1184 if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) {
1185 IWL_DEBUG_RATE("Can't switch with index %d rate mask %x\n", 1185 IWL_DEBUG_RATE(priv, "Can't switch with index %d rate mask %x\n",
1186 rate, rate_mask); 1186 rate, rate_mask);
1187 return -1; 1187 return -1;
1188 } 1188 }
1189 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green); 1189 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green);
1190 1190
1191 IWL_DEBUG_RATE("LQ: Switch to new mcs %X index is green %X\n", 1191 IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n",
1192 tbl->current_rate, is_green); 1192 tbl->current_rate, is_green);
1193 return 0; 1193 return 0;
1194} 1194}
@@ -1209,7 +1209,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1209 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) 1209 if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported)
1210 return -1; 1210 return -1;
1211 1211
1212 IWL_DEBUG_RATE("LQ: try to switch to SISO\n"); 1212 IWL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n");
1213 1213
1214 tbl->is_dup = lq_sta->is_dup; 1214 tbl->is_dup = lq_sta->is_dup;
1215 tbl->lq_type = LQ_SISO; 1215 tbl->lq_type = LQ_SISO;
@@ -1240,14 +1240,14 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1240 rs_set_expected_tpt_table(lq_sta, tbl); 1240 rs_set_expected_tpt_table(lq_sta, tbl);
1241 rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); 1241 rate = rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index);
1242 1242
1243 IWL_DEBUG_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); 1243 IWL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask);
1244 if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { 1244 if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) {
1245 IWL_DEBUG_RATE("can not switch with index %d rate mask %x\n", 1245 IWL_DEBUG_RATE(priv, "can not switch with index %d rate mask %x\n",
1246 rate, rate_mask); 1246 rate, rate_mask);
1247 return -1; 1247 return -1;
1248 } 1248 }
1249 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green); 1249 tbl->current_rate = rate_n_flags_from_tbl(priv, tbl, rate, is_green);
1250 IWL_DEBUG_RATE("LQ: Switch to new mcs %X index is green %X\n", 1250 IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n",
1251 tbl->current_rate, is_green); 1251 tbl->current_rate, is_green);
1252 return 0; 1252 return 0;
1253} 1253}
@@ -1276,7 +1276,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1276 switch (tbl->action) { 1276 switch (tbl->action) {
1277 case IWL_LEGACY_SWITCH_ANTENNA1: 1277 case IWL_LEGACY_SWITCH_ANTENNA1:
1278 case IWL_LEGACY_SWITCH_ANTENNA2: 1278 case IWL_LEGACY_SWITCH_ANTENNA2:
1279 IWL_DEBUG_RATE("LQ: Legacy toggle Antenna\n"); 1279 IWL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n");
1280 1280
1281 lq_sta->action_counter++; 1281 lq_sta->action_counter++;
1282 1282
@@ -1300,7 +1300,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1300 } 1300 }
1301 break; 1301 break;
1302 case IWL_LEGACY_SWITCH_SISO: 1302 case IWL_LEGACY_SWITCH_SISO:
1303 IWL_DEBUG_RATE("LQ: Legacy switch to SISO\n"); 1303 IWL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n");
1304 1304
1305 /* Set up search table to try SISO */ 1305 /* Set up search table to try SISO */
1306 memcpy(search_tbl, tbl, sz); 1306 memcpy(search_tbl, tbl, sz);
@@ -1316,7 +1316,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1316 case IWL_LEGACY_SWITCH_MIMO2_AB: 1316 case IWL_LEGACY_SWITCH_MIMO2_AB:
1317 case IWL_LEGACY_SWITCH_MIMO2_AC: 1317 case IWL_LEGACY_SWITCH_MIMO2_AC:
1318 case IWL_LEGACY_SWITCH_MIMO2_BC: 1318 case IWL_LEGACY_SWITCH_MIMO2_BC:
1319 IWL_DEBUG_RATE("LQ: Legacy switch to MIMO2\n"); 1319 IWL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n");
1320 1320
1321 /* Set up search table to try MIMO */ 1321 /* Set up search table to try MIMO */
1322 memcpy(search_tbl, tbl, sz); 1322 memcpy(search_tbl, tbl, sz);
@@ -1385,7 +1385,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1385 switch (tbl->action) { 1385 switch (tbl->action) {
1386 case IWL_SISO_SWITCH_ANTENNA1: 1386 case IWL_SISO_SWITCH_ANTENNA1:
1387 case IWL_SISO_SWITCH_ANTENNA2: 1387 case IWL_SISO_SWITCH_ANTENNA2:
1388 IWL_DEBUG_RATE("LQ: SISO toggle Antenna\n"); 1388 IWL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n");
1389 1389
1390 if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 && 1390 if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 &&
1391 tx_chains_num <= 1) || 1391 tx_chains_num <= 1) ||
@@ -1404,7 +1404,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1404 case IWL_SISO_SWITCH_MIMO2_AB: 1404 case IWL_SISO_SWITCH_MIMO2_AB:
1405 case IWL_SISO_SWITCH_MIMO2_AC: 1405 case IWL_SISO_SWITCH_MIMO2_AC:
1406 case IWL_SISO_SWITCH_MIMO2_BC: 1406 case IWL_SISO_SWITCH_MIMO2_BC:
1407 IWL_DEBUG_RATE("LQ: SISO switch to MIMO2\n"); 1407 IWL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n");
1408 memcpy(search_tbl, tbl, sz); 1408 memcpy(search_tbl, tbl, sz);
1409 search_tbl->is_SGI = 0; 1409 search_tbl->is_SGI = 0;
1410 1410
@@ -1433,7 +1433,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1433 HT_SHORT_GI_40MHZ)) 1433 HT_SHORT_GI_40MHZ))
1434 break; 1434 break;
1435 1435
1436 IWL_DEBUG_RATE("LQ: SISO toggle SGI/NGI\n"); 1436 IWL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n");
1437 1437
1438 memcpy(search_tbl, tbl, sz); 1438 memcpy(search_tbl, tbl, sz);
1439 if (is_green) { 1439 if (is_green) {
@@ -1498,7 +1498,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
1498 switch (tbl->action) { 1498 switch (tbl->action) {
1499 case IWL_MIMO2_SWITCH_ANTENNA1: 1499 case IWL_MIMO2_SWITCH_ANTENNA1:
1500 case IWL_MIMO2_SWITCH_ANTENNA2: 1500 case IWL_MIMO2_SWITCH_ANTENNA2:
1501 IWL_DEBUG_RATE("LQ: MIMO toggle Antennas\n"); 1501 IWL_DEBUG_RATE(priv, "LQ: MIMO toggle Antennas\n");
1502 1502
1503 if (tx_chains_num <= 2) 1503 if (tx_chains_num <= 2)
1504 break; 1504 break;
@@ -1514,7 +1514,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
1514 case IWL_MIMO2_SWITCH_SISO_A: 1514 case IWL_MIMO2_SWITCH_SISO_A:
1515 case IWL_MIMO2_SWITCH_SISO_B: 1515 case IWL_MIMO2_SWITCH_SISO_B:
1516 case IWL_MIMO2_SWITCH_SISO_C: 1516 case IWL_MIMO2_SWITCH_SISO_C:
1517 IWL_DEBUG_RATE("LQ: MIMO2 switch to SISO\n"); 1517 IWL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n");
1518 1518
1519 /* Set up new search table for SISO */ 1519 /* Set up new search table for SISO */
1520 memcpy(search_tbl, tbl, sz); 1520 memcpy(search_tbl, tbl, sz);
@@ -1546,7 +1546,7 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
1546 HT_SHORT_GI_40MHZ)) 1546 HT_SHORT_GI_40MHZ))
1547 break; 1547 break;
1548 1548
1549 IWL_DEBUG_RATE("LQ: MIMO toggle SGI/NGI\n"); 1549 IWL_DEBUG_RATE(priv, "LQ: MIMO toggle SGI/NGI\n");
1550 1550
1551 /* Set up new search table for MIMO */ 1551 /* Set up new search table for MIMO */
1552 memcpy(search_tbl, tbl, sz); 1552 memcpy(search_tbl, tbl, sz);
@@ -1629,7 +1629,7 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta)
1629 (lq_sta->total_success > lq_sta->max_success_limit) || 1629 (lq_sta->total_success > lq_sta->max_success_limit) ||
1630 ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) 1630 ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer)
1631 && (flush_interval_passed))) { 1631 && (flush_interval_passed))) {
1632 IWL_DEBUG_RATE("LQ: stay is expired %d %d %d\n:", 1632 IWL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:",
1633 lq_sta->total_failed, 1633 lq_sta->total_failed,
1634 lq_sta->total_success, 1634 lq_sta->total_success,
1635 flush_interval_passed); 1635 flush_interval_passed);
@@ -1652,7 +1652,7 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta)
1652 lq_sta->table_count_limit) { 1652 lq_sta->table_count_limit) {
1653 lq_sta->table_count = 0; 1653 lq_sta->table_count = 0;
1654 1654
1655 IWL_DEBUG_RATE("LQ: stay in table clear win\n"); 1655 IWL_DEBUG_RATE(priv, "LQ: stay in table clear win\n");
1656 for (i = 0; i < IWL_RATE_COUNT; i++) 1656 for (i = 0; i < IWL_RATE_COUNT; i++)
1657 rs_rate_scale_clear_window( 1657 rs_rate_scale_clear_window(
1658 &(tbl->win[i])); 1658 &(tbl->win[i]));
@@ -1701,7 +1701,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1701 s32 sr; 1701 s32 sr;
1702 u8 tid = MAX_TID_COUNT; 1702 u8 tid = MAX_TID_COUNT;
1703 1703
1704 IWL_DEBUG_RATE("rate scale calculate new rate for skb\n"); 1704 IWL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n");
1705 1705
1706 /* Send management frames and broadcast/multicast data using 1706 /* Send management frames and broadcast/multicast data using
1707 * lowest rate. */ 1707 * lowest rate. */
@@ -1733,13 +1733,13 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1733 /* current tx rate */ 1733 /* current tx rate */
1734 index = lq_sta->last_txrate_idx; 1734 index = lq_sta->last_txrate_idx;
1735 1735
1736 IWL_DEBUG_RATE("Rate scale index %d for type %d\n", index, 1736 IWL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index,
1737 tbl->lq_type); 1737 tbl->lq_type);
1738 1738
1739 /* rates available for this association, and for modulation mode */ 1739 /* rates available for this association, and for modulation mode */
1740 rate_mask = rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); 1740 rate_mask = rs_get_supported_rates(lq_sta, hdr, tbl->lq_type);
1741 1741
1742 IWL_DEBUG_RATE("mask 0x%04X \n", rate_mask); 1742 IWL_DEBUG_RATE(priv, "mask 0x%04X \n", rate_mask);
1743 1743
1744 /* mask with station rate restriction */ 1744 /* mask with station rate restriction */
1745 if (is_legacy(tbl->lq_type)) { 1745 if (is_legacy(tbl->lq_type)) {
@@ -1789,7 +1789,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1789 fail_count = window->counter - window->success_counter; 1789 fail_count = window->counter - window->success_counter;
1790 if ((fail_count < IWL_RATE_MIN_FAILURE_TH) && 1790 if ((fail_count < IWL_RATE_MIN_FAILURE_TH) &&
1791 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) { 1791 (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) {
1792 IWL_DEBUG_RATE("LQ: still below TH. succ=%d total=%d " 1792 IWL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d "
1793 "for index %d\n", 1793 "for index %d\n",
1794 window->success_counter, window->counter, index); 1794 window->success_counter, window->counter, index);
1795 1795
@@ -1817,7 +1817,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1817 * continuing to use the setup that we've been trying. */ 1817 * continuing to use the setup that we've been trying. */
1818 if (window->average_tpt > lq_sta->last_tpt) { 1818 if (window->average_tpt > lq_sta->last_tpt) {
1819 1819
1820 IWL_DEBUG_RATE("LQ: SWITCHING TO NEW TABLE " 1820 IWL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE "
1821 "suc=%d cur-tpt=%d old-tpt=%d\n", 1821 "suc=%d cur-tpt=%d old-tpt=%d\n",
1822 window->success_ratio, 1822 window->success_ratio,
1823 window->average_tpt, 1823 window->average_tpt,
@@ -1833,7 +1833,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1833 /* Else poor success; go back to mode in "active" table */ 1833 /* Else poor success; go back to mode in "active" table */
1834 } else { 1834 } else {
1835 1835
1836 IWL_DEBUG_RATE("LQ: GOING BACK TO THE OLD TABLE " 1836 IWL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE "
1837 "suc=%d cur-tpt=%d old-tpt=%d\n", 1837 "suc=%d cur-tpt=%d old-tpt=%d\n",
1838 window->success_ratio, 1838 window->success_ratio,
1839 window->average_tpt, 1839 window->average_tpt,
@@ -1886,7 +1886,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1886 1886
1887 /* Too many failures, decrease rate */ 1887 /* Too many failures, decrease rate */
1888 if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) { 1888 if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) {
1889 IWL_DEBUG_RATE("decrease rate because of low success_ratio\n"); 1889 IWL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n");
1890 scale_action = -1; 1890 scale_action = -1;
1891 1891
1892 /* No throughput measured yet for adjacent rates; try increase. */ 1892 /* No throughput measured yet for adjacent rates; try increase. */
@@ -1917,8 +1917,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1917 sr >= IWL_RATE_INCREASE_TH) { 1917 sr >= IWL_RATE_INCREASE_TH) {
1918 scale_action = 1; 1918 scale_action = 1;
1919 } else { 1919 } else {
1920 IWL_DEBUG_RATE 1920 IWL_DEBUG_RATE(priv,
1921 ("decrease rate because of high tpt\n"); 1921 "decrease rate because of high tpt\n");
1922 scale_action = -1; 1922 scale_action = -1;
1923 } 1923 }
1924 1924
@@ -1926,8 +1926,8 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1926 } else if (low_tpt != IWL_INVALID_VALUE) { 1926 } else if (low_tpt != IWL_INVALID_VALUE) {
1927 /* Lower rate has better throughput */ 1927 /* Lower rate has better throughput */
1928 if (low_tpt > current_tpt) { 1928 if (low_tpt > current_tpt) {
1929 IWL_DEBUG_RATE 1929 IWL_DEBUG_RATE(priv,
1930 ("decrease rate because of low tpt\n"); 1930 "decrease rate because of low tpt\n");
1931 scale_action = -1; 1931 scale_action = -1;
1932 } else if (sr >= IWL_RATE_INCREASE_TH) { 1932 } else if (sr >= IWL_RATE_INCREASE_TH) {
1933 scale_action = 1; 1933 scale_action = 1;
@@ -1964,7 +1964,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1964 break; 1964 break;
1965 } 1965 }
1966 1966
1967 IWL_DEBUG_RATE("choose rate scale index %d action %d low %d " 1967 IWL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d "
1968 "high %d type %d\n", 1968 "high %d type %d\n",
1969 index, scale_action, low, high, tbl->lq_type); 1969 index, scale_action, low, high, tbl->lq_type);
1970 1970
@@ -2008,7 +2008,7 @@ lq_update:
2008 /* Use new "search" start rate */ 2008 /* Use new "search" start rate */
2009 index = iwl_hwrate_to_plcp_idx(tbl->current_rate); 2009 index = iwl_hwrate_to_plcp_idx(tbl->current_rate);
2010 2010
2011 IWL_DEBUG_RATE("Switch current mcs: %X index: %d\n", 2011 IWL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n",
2012 tbl->current_rate, index); 2012 tbl->current_rate, index);
2013 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); 2013 rs_fill_link_cmd(priv, lq_sta, tbl->current_rate);
2014 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC); 2014 iwl_send_lq_cmd(priv, &lq_sta->lq, CMD_ASYNC);
@@ -2023,7 +2023,7 @@ lq_update:
2023 if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && 2023 if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) &&
2024 lq_sta->action_counter >= 1) { 2024 lq_sta->action_counter >= 1) {
2025 lq_sta->action_counter = 0; 2025 lq_sta->action_counter = 0;
2026 IWL_DEBUG_RATE("LQ: STAY in legacy table\n"); 2026 IWL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n");
2027 rs_set_stay_in_table(priv, 1, lq_sta); 2027 rs_set_stay_in_table(priv, 1, lq_sta);
2028 } 2028 }
2029 2029
@@ -2035,7 +2035,7 @@ lq_update:
2035 if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && 2035 if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) &&
2036 (lq_sta->tx_agg_tid_en & (1 << tid)) && 2036 (lq_sta->tx_agg_tid_en & (1 << tid)) &&
2037 (tid != MAX_TID_COUNT)) { 2037 (tid != MAX_TID_COUNT)) {
2038 IWL_DEBUG_RATE("try to aggregate tid %d\n", tid); 2038 IWL_DEBUG_RATE(priv, "try to aggregate tid %d\n", tid);
2039 rs_tl_turn_on_agg(priv, tid, lq_sta, sta); 2039 rs_tl_turn_on_agg(priv, tid, lq_sta, sta);
2040 } 2040 }
2041 lq_sta->action_counter = 0; 2041 lq_sta->action_counter = 0;
@@ -2131,7 +2131,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2131 int rate_idx; 2131 int rate_idx;
2132 u64 mask_bit = 0; 2132 u64 mask_bit = 0;
2133 2133
2134 IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); 2134 IWL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n");
2135 2135
2136 /* Get max rate if user set max rate */ 2136 /* Get max rate if user set max rate */
2137 if (lq_sta) { 2137 if (lq_sta) {
@@ -2167,7 +2167,7 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
2167 u8 sta_id = iwl_find_station(priv, hdr->addr1); 2167 u8 sta_id = iwl_find_station(priv, hdr->addr1);
2168 2168
2169 if (sta_id == IWL_INVALID_STATION) { 2169 if (sta_id == IWL_INVALID_STATION) {
2170 IWL_DEBUG_RATE("LQ: ADD station %pM\n", 2170 IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n",
2171 hdr->addr1); 2171 hdr->addr1);
2172 sta_id = iwl_add_station_flags(priv, hdr->addr1, 2172 sta_id = iwl_add_station_flags(priv, hdr->addr1,
2173 0, CMD_ASYNC, NULL); 2173 0, CMD_ASYNC, NULL);
@@ -2196,7 +2196,7 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
2196 int i, j; 2196 int i, j;
2197 2197
2198 priv = (struct iwl_priv *)priv_rate; 2198 priv = (struct iwl_priv *)priv_rate;
2199 IWL_DEBUG_RATE("create station rate scale window\n"); 2199 IWL_DEBUG_RATE(priv, "create station rate scale window\n");
2200 2200
2201 lq_sta = kzalloc(sizeof(struct iwl_lq_sta), gfp); 2201 lq_sta = kzalloc(sizeof(struct iwl_lq_sta), gfp);
2202 2202
@@ -2229,7 +2229,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2229 for (i = 0; i < IWL_RATE_COUNT; i++) 2229 for (i = 0; i < IWL_RATE_COUNT; i++)
2230 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); 2230 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]);
2231 2231
2232 IWL_DEBUG_RATE("LQ: *** rate scale station global init ***\n"); 2232 IWL_DEBUG_RATE(priv, "LQ: *** rate scale station global init ***\n");
2233 /* TODO: what is a good starting rate for STA? About middle? Maybe not 2233 /* TODO: what is a good starting rate for STA? About middle? Maybe not
2234 * the lowest or the highest rate.. Could consider using RSSI from 2234 * the lowest or the highest rate.. Could consider using RSSI from
2235 * previous packets? Need to have IEEE 802.1X auth succeed immediately 2235 * previous packets? Need to have IEEE 802.1X auth succeed immediately
@@ -2240,10 +2240,10 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2240 u8 sta_id = iwl_find_station(priv, sta->addr); 2240 u8 sta_id = iwl_find_station(priv, sta->addr);
2241 2241
2242 /* for IBSS the call are from tasklet */ 2242 /* for IBSS the call are from tasklet */
2243 IWL_DEBUG_RATE("LQ: ADD station %pM\n", sta->addr); 2243 IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr);
2244 2244
2245 if (sta_id == IWL_INVALID_STATION) { 2245 if (sta_id == IWL_INVALID_STATION) {
2246 IWL_DEBUG_RATE("LQ: ADD station %pM\n", sta->addr); 2246 IWL_DEBUG_RATE(priv, "LQ: ADD station %pM\n", sta->addr);
2247 sta_id = iwl_add_station_flags(priv, sta->addr, 2247 sta_id = iwl_add_station_flags(priv, sta->addr,
2248 0, CMD_ASYNC, NULL); 2248 0, CMD_ASYNC, NULL);
2249 } 2249 }
@@ -2282,7 +2282,7 @@ static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2282 lq_sta->active_mimo3_rate &= ~((u16)0x2); 2282 lq_sta->active_mimo3_rate &= ~((u16)0x2);
2283 lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE; 2283 lq_sta->active_mimo3_rate <<= IWL_FIRST_OFDM_RATE;
2284 2284
2285 IWL_DEBUG_RATE("SISO-RATE=%X MIMO2-RATE=%X MIMO3-RATE=%X\n", 2285 IWL_DEBUG_RATE(priv, "SISO-RATE=%X MIMO2-RATE=%X MIMO3-RATE=%X\n",
2286 lq_sta->active_siso_rate, 2286 lq_sta->active_siso_rate,
2287 lq_sta->active_mimo2_rate, 2287 lq_sta->active_mimo2_rate,
2288 lq_sta->active_mimo3_rate); 2288 lq_sta->active_mimo3_rate);
@@ -2448,9 +2448,9 @@ static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
2448 struct iwl_lq_sta *lq_sta = priv_sta; 2448 struct iwl_lq_sta *lq_sta = priv_sta;
2449 struct iwl_priv *priv __maybe_unused = priv_r; 2449 struct iwl_priv *priv __maybe_unused = priv_r;
2450 2450
2451 IWL_DEBUG_RATE("enter\n"); 2451 IWL_DEBUG_RATE(priv, "enter\n");
2452 kfree(lq_sta); 2452 kfree(lq_sta);
2453 IWL_DEBUG_RATE("leave\n"); 2453 IWL_DEBUG_RATE(priv, "leave\n");
2454} 2454}
2455 2455
2456 2456
@@ -2475,9 +2475,9 @@ static void rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta,
2475 else 2475 else
2476 *rate_n_flags = 0x820A; 2476 *rate_n_flags = 0x820A;
2477 } 2477 }
2478 IWL_DEBUG_RATE("Fixed rate ON\n"); 2478 IWL_DEBUG_RATE(priv, "Fixed rate ON\n");
2479 } else { 2479 } else {
2480 IWL_DEBUG_RATE("Fixed rate OFF\n"); 2480 IWL_DEBUG_RATE(priv, "Fixed rate OFF\n");
2481 } 2481 }
2482} 2482}
2483 2483
@@ -2506,7 +2506,7 @@ static ssize_t rs_sta_dbgfs_scale_table_write(struct file *file,
2506 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 2506 lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
2507 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ 2507 lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */
2508 2508
2509 IWL_DEBUG_RATE("sta_id %d rate 0x%X\n", 2509 IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n",
2510 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); 2510 lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate);
2511 2511
2512 if (lq_sta->dbg_fixed_rate) { 2512 if (lq_sta->dbg_fixed_rate) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 6b7120a41ab2..c196abc6db7a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -94,66 +94,6 @@ MODULE_ALIAS("iwl4965");
94 94
95/**************************************************************/ 95/**************************************************************/
96 96
97
98
99static void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
100{
101 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
102
103 if (hw_decrypt)
104 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
105 else
106 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK;
107
108}
109
110/**
111 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
112 * @priv: staging_rxon is compared to active_rxon
113 *
114 * If the RXON structure is changing enough to require a new tune,
115 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
116 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
117 */
118static int iwl_full_rxon_required(struct iwl_priv *priv)
119{
120
121 /* These items are only settable from the full RXON command */
122 if (!(iwl_is_associated(priv)) ||
123 compare_ether_addr(priv->staging_rxon.bssid_addr,
124 priv->active_rxon.bssid_addr) ||
125 compare_ether_addr(priv->staging_rxon.node_addr,
126 priv->active_rxon.node_addr) ||
127 compare_ether_addr(priv->staging_rxon.wlap_bssid_addr,
128 priv->active_rxon.wlap_bssid_addr) ||
129 (priv->staging_rxon.dev_type != priv->active_rxon.dev_type) ||
130 (priv->staging_rxon.channel != priv->active_rxon.channel) ||
131 (priv->staging_rxon.air_propagation !=
132 priv->active_rxon.air_propagation) ||
133 (priv->staging_rxon.ofdm_ht_single_stream_basic_rates !=
134 priv->active_rxon.ofdm_ht_single_stream_basic_rates) ||
135 (priv->staging_rxon.ofdm_ht_dual_stream_basic_rates !=
136 priv->active_rxon.ofdm_ht_dual_stream_basic_rates) ||
137 (priv->staging_rxon.assoc_id != priv->active_rxon.assoc_id))
138 return 1;
139
140 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can
141 * be updated with the RXON_ASSOC command -- however only some
142 * flag transitions are allowed using RXON_ASSOC */
143
144 /* Check if we are not switching bands */
145 if ((priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) !=
146 (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK))
147 return 1;
148
149 /* Check if we are switching association toggle */
150 if ((priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) !=
151 (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK))
152 return 1;
153
154 return 0;
155}
156
157/** 97/**
158 * iwl_commit_rxon - commit staging_rxon to hardware 98 * iwl_commit_rxon - commit staging_rxon to hardware
159 * 99 *
@@ -179,7 +119,7 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
179 * 5000, but will not damage 4965 */ 119 * 5000, but will not damage 4965 */
180 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN; 120 priv->staging_rxon.flags |= RXON_FLG_SELF_CTS_EN;
181 121
182 ret = iwl_agn_check_rxon_cmd(priv); 122 ret = iwl_check_rxon_cmd(priv);
183 if (ret) { 123 if (ret) {
184 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); 124 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
185 return -EINVAL; 125 return -EINVAL;
@@ -207,7 +147,7 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
207 * we must clear the associated from the active configuration 147 * we must clear the associated from the active configuration
208 * before we apply the new config */ 148 * before we apply the new config */
209 if (iwl_is_associated(priv) && new_assoc) { 149 if (iwl_is_associated(priv) && new_assoc) {
210 IWL_DEBUG_INFO("Toggling associated bit on current RXON\n"); 150 IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n");
211 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 151 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
212 152
213 ret = iwl_send_cmd_pdu(priv, REPLY_RXON, 153 ret = iwl_send_cmd_pdu(priv, REPLY_RXON,
@@ -223,7 +163,7 @@ static int iwl_commit_rxon(struct iwl_priv *priv)
223 } 163 }
224 } 164 }
225 165
226 IWL_DEBUG_INFO("Sending RXON\n" 166 IWL_DEBUG_INFO(priv, "Sending RXON\n"
227 "* with%s RXON_FILTER_ASSOC_MSK\n" 167 "* with%s RXON_FILTER_ASSOC_MSK\n"
228 "* channel = %d\n" 168 "* channel = %d\n"
229 "* bssid = %pM\n", 169 "* bssid = %pM\n",
@@ -314,7 +254,7 @@ static void iwl_clear_free_frames(struct iwl_priv *priv)
314{ 254{
315 struct list_head *element; 255 struct list_head *element;
316 256
317 IWL_DEBUG_INFO("%d frames on pre-allocated heap on clear.\n", 257 IWL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n",
318 priv->frames_count); 258 priv->frames_count);
319 259
320 while (!list_empty(&priv->free_frames)) { 260 while (!list_empty(&priv->free_frames)) {
@@ -374,31 +314,6 @@ static unsigned int iwl_fill_beacon_frame(struct iwl_priv *priv,
374 return priv->ibss_beacon->len; 314 return priv->ibss_beacon->len;
375} 315}
376 316
377static u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv)
378{
379 int i;
380 int rate_mask;
381
382 /* Set rate mask*/
383 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
384 rate_mask = priv->active_rate_basic & IWL_CCK_RATES_MASK;
385 else
386 rate_mask = priv->active_rate_basic & IWL_OFDM_RATES_MASK;
387
388 /* Find lowest valid rate */
389 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID;
390 i = iwl_rates[i].next_ieee) {
391 if (rate_mask & (1 << i))
392 return iwl_rates[i].plcp;
393 }
394
395 /* No valid rate was found. Assign the lowest one */
396 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
397 return IWL_RATE_1M_PLCP;
398 else
399 return IWL_RATE_6M_PLCP;
400}
401
402static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv, 317static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
403 struct iwl_frame *frame, u8 rate) 318 struct iwl_frame *frame, u8 rate)
404{ 319{
@@ -623,7 +538,7 @@ static void iwl_ht_conf(struct iwl_priv *priv,
623 struct iwl_ht_info *iwl_conf = &priv->current_ht_config; 538 struct iwl_ht_info *iwl_conf = &priv->current_ht_config;
624 struct ieee80211_sta *sta; 539 struct ieee80211_sta *sta;
625 540
626 IWL_DEBUG_MAC80211("enter: \n"); 541 IWL_DEBUG_MAC80211(priv, "enter: \n");
627 542
628 if (!iwl_conf->is_ht) 543 if (!iwl_conf->is_ht)
629 return; 544 return;
@@ -683,7 +598,7 @@ static void iwl_ht_conf(struct iwl_priv *priv,
683 598
684 rcu_read_unlock(); 599 rcu_read_unlock();
685 600
686 IWL_DEBUG_MAC80211("leave\n"); 601 IWL_DEBUG_MAC80211(priv, "leave\n");
687} 602}
688 603
689/* 604/*
@@ -708,7 +623,7 @@ static void iwl_activate_qos(struct iwl_priv *priv, u8 force)
708 priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; 623 priv->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK;
709 624
710 if (force || iwl_is_associated(priv)) { 625 if (force || iwl_is_associated(priv)) {
711 IWL_DEBUG_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", 626 IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n",
712 priv->qos_data.qos_active, 627 priv->qos_data.qos_active,
713 priv->qos_data.def_qos_parm.qos_flags); 628 priv->qos_data.def_qos_parm.qos_flags);
714 629
@@ -765,117 +680,16 @@ static void iwl_setup_rxon_timing(struct iwl_priv *priv)
765 priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem); 680 priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem);
766 681
767 spin_unlock_irqrestore(&priv->lock, flags); 682 spin_unlock_irqrestore(&priv->lock, flags);
768 IWL_DEBUG_ASSOC("beacon interval %d beacon timer %d beacon tim %d\n", 683 IWL_DEBUG_ASSOC(priv, "beacon interval %d beacon timer %d beacon tim %d\n",
769 le16_to_cpu(priv->rxon_timing.beacon_interval), 684 le16_to_cpu(priv->rxon_timing.beacon_interval),
770 le32_to_cpu(priv->rxon_timing.beacon_init_val), 685 le32_to_cpu(priv->rxon_timing.beacon_init_val),
771 le16_to_cpu(priv->rxon_timing.atim_window)); 686 le16_to_cpu(priv->rxon_timing.atim_window));
772} 687}
773 688
774static void iwl_set_flags_for_band(struct iwl_priv *priv,
775 enum ieee80211_band band)
776{
777 if (band == IEEE80211_BAND_5GHZ) {
778 priv->staging_rxon.flags &=
779 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK
780 | RXON_FLG_CCK_MSK);
781 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
782 } else {
783 /* Copied from iwl_post_associate() */
784 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
785 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
786 else
787 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
788
789 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
790 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
791
792 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
793 priv->staging_rxon.flags |= RXON_FLG_AUTO_DETECT_MSK;
794 priv->staging_rxon.flags &= ~RXON_FLG_CCK_MSK;
795 }
796}
797
798/*
799 * initialize rxon structure with default values from eeprom
800 */
801static void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
802{
803 const struct iwl_channel_info *ch_info;
804
805 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
806
807 switch (mode) {
808 case NL80211_IFTYPE_AP:
809 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
810 break;
811
812 case NL80211_IFTYPE_STATION:
813 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS;
814 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
815 break;
816
817 case NL80211_IFTYPE_ADHOC:
818 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS;
819 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
820 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
821 RXON_FILTER_ACCEPT_GRP_MSK;
822 break;
823
824 case NL80211_IFTYPE_MONITOR:
825 priv->staging_rxon.dev_type = RXON_DEV_TYPE_SNIFFER;
826 priv->staging_rxon.filter_flags = RXON_FILTER_PROMISC_MSK |
827 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
828 break;
829 default:
830 IWL_ERR(priv, "Unsupported interface type %d\n", mode);
831 break;
832 }
833
834#if 0
835 /* TODO: Figure out when short_preamble would be set and cache from
836 * that */
837 if (!hw_to_local(priv->hw)->short_preamble)
838 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
839 else
840 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
841#endif
842
843 ch_info = iwl_get_channel_info(priv, priv->band,
844 le16_to_cpu(priv->active_rxon.channel));
845
846 if (!ch_info)
847 ch_info = &priv->channel_info[0];
848
849 /*
850 * in some case A channels are all non IBSS
851 * in this case force B/G channel
852 */
853 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
854 !(is_channel_ibss(ch_info)))
855 ch_info = &priv->channel_info[0];
856
857 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
858 priv->band = ch_info->band;
859
860 iwl_set_flags_for_band(priv, priv->band);
861
862 priv->staging_rxon.ofdm_basic_rates =
863 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
864 priv->staging_rxon.cck_basic_rates =
865 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
866
867 priv->staging_rxon.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK |
868 RXON_FLG_CHANNEL_MODE_PURE_40_MSK);
869 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
870 memcpy(priv->staging_rxon.wlap_bssid_addr, priv->mac_addr, ETH_ALEN);
871 priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff;
872 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff;
873 iwl_set_rxon_chain(priv);
874}
875
876static int iwl_set_mode(struct iwl_priv *priv, int mode) 689static int iwl_set_mode(struct iwl_priv *priv, int mode)
877{ 690{
878 iwl_connection_init_rx_config(priv, mode); 691 iwl_connection_init_rx_config(priv, mode);
692 iwl_set_rxon_chain(priv);
879 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 693 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
880 694
881 iwl_clear_stations_table(priv); 695 iwl_clear_stations_table(priv);
@@ -887,7 +701,7 @@ static int iwl_set_mode(struct iwl_priv *priv, int mode)
887 cancel_delayed_work(&priv->scan_check); 701 cancel_delayed_work(&priv->scan_check);
888 if (iwl_scan_cancel_timeout(priv, 100)) { 702 if (iwl_scan_cancel_timeout(priv, 100)) {
889 IWL_WARN(priv, "Aborted scan still in progress after 100ms\n"); 703 IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
890 IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); 704 IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
891 return -EAGAIN; 705 return -EAGAIN;
892 } 706 }
893 707
@@ -896,54 +710,6 @@ static int iwl_set_mode(struct iwl_priv *priv, int mode)
896 return 0; 710 return 0;
897} 711}
898 712
899static void iwl_set_rate(struct iwl_priv *priv)
900{
901 const struct ieee80211_supported_band *hw = NULL;
902 struct ieee80211_rate *rate;
903 int i;
904
905 hw = iwl_get_hw_mode(priv, priv->band);
906 if (!hw) {
907 IWL_ERR(priv, "Failed to set rate: unable to get hw mode\n");
908 return;
909 }
910
911 priv->active_rate = 0;
912 priv->active_rate_basic = 0;
913
914 for (i = 0; i < hw->n_bitrates; i++) {
915 rate = &(hw->bitrates[i]);
916 if (rate->hw_value < IWL_RATE_COUNT)
917 priv->active_rate |= (1 << rate->hw_value);
918 }
919
920 IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n",
921 priv->active_rate, priv->active_rate_basic);
922
923 /*
924 * If a basic rate is configured, then use it (adding IWL_RATE_1M_MASK)
925 * otherwise set it to the default of all CCK rates and 6, 12, 24 for
926 * OFDM
927 */
928 if (priv->active_rate_basic & IWL_CCK_BASIC_RATES_MASK)
929 priv->staging_rxon.cck_basic_rates =
930 ((priv->active_rate_basic &
931 IWL_CCK_RATES_MASK) >> IWL_FIRST_CCK_RATE) & 0xF;
932 else
933 priv->staging_rxon.cck_basic_rates =
934 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
935
936 if (priv->active_rate_basic & IWL_OFDM_BASIC_RATES_MASK)
937 priv->staging_rxon.ofdm_basic_rates =
938 ((priv->active_rate_basic &
939 (IWL_OFDM_BASIC_RATES_MASK | IWL_RATE_6M_MASK)) >>
940 IWL_FIRST_OFDM_RATE) & 0xFF;
941 else
942 priv->staging_rxon.ofdm_basic_rates =
943 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
944}
945
946
947/****************************************************************************** 713/******************************************************************************
948 * 714 *
949 * Generic RX handler implementations 715 * Generic RX handler implementations
@@ -958,19 +724,19 @@ static void iwl_rx_reply_alive(struct iwl_priv *priv,
958 724
959 palive = &pkt->u.alive_frame; 725 palive = &pkt->u.alive_frame;
960 726
961 IWL_DEBUG_INFO("Alive ucode status 0x%08X revision " 727 IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision "
962 "0x%01X 0x%01X\n", 728 "0x%01X 0x%01X\n",
963 palive->is_valid, palive->ver_type, 729 palive->is_valid, palive->ver_type,
964 palive->ver_subtype); 730 palive->ver_subtype);
965 731
966 if (palive->ver_subtype == INITIALIZE_SUBTYPE) { 732 if (palive->ver_subtype == INITIALIZE_SUBTYPE) {
967 IWL_DEBUG_INFO("Initialization Alive received.\n"); 733 IWL_DEBUG_INFO(priv, "Initialization Alive received.\n");
968 memcpy(&priv->card_alive_init, 734 memcpy(&priv->card_alive_init,
969 &pkt->u.alive_frame, 735 &pkt->u.alive_frame,
970 sizeof(struct iwl_init_alive_resp)); 736 sizeof(struct iwl_init_alive_resp));
971 pwork = &priv->init_alive_start; 737 pwork = &priv->init_alive_start;
972 } else { 738 } else {
973 IWL_DEBUG_INFO("Runtime Alive received.\n"); 739 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
974 memcpy(&priv->card_alive, &pkt->u.alive_frame, 740 memcpy(&priv->card_alive, &pkt->u.alive_frame,
975 sizeof(struct iwl_alive_resp)); 741 sizeof(struct iwl_alive_resp));
976 pwork = &priv->alive_start; 742 pwork = &priv->alive_start;
@@ -999,26 +765,13 @@ static void iwl_rx_reply_error(struct iwl_priv *priv,
999 le32_to_cpu(pkt->u.err_resp.error_info)); 765 le32_to_cpu(pkt->u.err_resp.error_info));
1000} 766}
1001 767
1002#define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x
1003
1004static void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1005{
1006 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
1007 struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon;
1008 struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
1009 IWL_DEBUG_11H("CSA notif: channel %d, status %d\n",
1010 le16_to_cpu(csa->channel), le32_to_cpu(csa->status));
1011 rxon->channel = csa->channel;
1012 priv->staging_rxon.channel = csa->channel;
1013}
1014
1015static void iwl_rx_pm_sleep_notif(struct iwl_priv *priv, 768static void iwl_rx_pm_sleep_notif(struct iwl_priv *priv,
1016 struct iwl_rx_mem_buffer *rxb) 769 struct iwl_rx_mem_buffer *rxb)
1017{ 770{
1018#ifdef CONFIG_IWLWIFI_DEBUG 771#ifdef CONFIG_IWLWIFI_DEBUG
1019 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 772 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
1020 struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); 773 struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);
1021 IWL_DEBUG_RX("sleep mode: %d, src: %d\n", 774 IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",
1022 sleep->pm_sleep_mode, sleep->pm_wakeup_src); 775 sleep->pm_sleep_mode, sleep->pm_wakeup_src);
1023#endif 776#endif
1024} 777}
@@ -1027,7 +780,7 @@ static void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
1027 struct iwl_rx_mem_buffer *rxb) 780 struct iwl_rx_mem_buffer *rxb)
1028{ 781{
1029 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 782 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
1030 IWL_DEBUG_RADIO("Dumping %d bytes of unhandled " 783 IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "
1031 "notification for %s:\n", 784 "notification for %s:\n",
1032 le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); 785 le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd));
1033 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len)); 786 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len));
@@ -1091,7 +844,7 @@ static void iwl_rx_beacon_notif(struct iwl_priv *priv,
1091 (struct iwl4965_beacon_notif *)pkt->u.raw; 844 (struct iwl4965_beacon_notif *)pkt->u.raw;
1092 u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); 845 u8 rate = iwl_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags);
1093 846
1094 IWL_DEBUG_RX("beacon status %x retries %d iss %d " 847 IWL_DEBUG_RX(priv, "beacon status %x retries %d iss %d "
1095 "tsf %d %d rate %d\n", 848 "tsf %d %d rate %d\n",
1096 le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, 849 le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK,
1097 beacon->beacon_notify_hdr.failure_frame, 850 beacon->beacon_notify_hdr.failure_frame,
@@ -1114,7 +867,7 @@ static void iwl_rx_card_state_notif(struct iwl_priv *priv,
1114 u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); 867 u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
1115 unsigned long status = priv->status; 868 unsigned long status = priv->status;
1116 869
1117 IWL_DEBUG_RF_KILL("Card state received: HW:%s SW:%s\n", 870 IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s\n",
1118 (flags & HW_CARD_DISABLED) ? "Kill" : "On", 871 (flags & HW_CARD_DISABLED) ? "Kill" : "On",
1119 (flags & SW_CARD_DISABLED) ? "Kill" : "On"); 872 (flags & SW_CARD_DISABLED) ? "Kill" : "On");
1120 873
@@ -1276,7 +1029,7 @@ void iwl_rx_handle(struct iwl_priv *priv)
1276 1029
1277 /* Rx interrupt, but nothing sent from uCode */ 1030 /* Rx interrupt, but nothing sent from uCode */
1278 if (i == r) 1031 if (i == r)
1279 IWL_DEBUG(IWL_DL_RX, "r = %d, i = %d\n", r, i); 1032 IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i);
1280 1033
1281 if (iwl_rx_queue_space(rxq) > (RX_QUEUE_SIZE / 2)) 1034 if (iwl_rx_queue_space(rxq) > (RX_QUEUE_SIZE / 2))
1282 fill_rx = 1; 1035 fill_rx = 1;
@@ -1316,12 +1069,12 @@ void iwl_rx_handle(struct iwl_priv *priv)
1316 * handle those that need handling via function in 1069 * handle those that need handling via function in
1317 * rx_handlers table. See iwl_setup_rx_handlers() */ 1070 * rx_handlers table. See iwl_setup_rx_handlers() */
1318 if (priv->rx_handlers[pkt->hdr.cmd]) { 1071 if (priv->rx_handlers[pkt->hdr.cmd]) {
1319 IWL_DEBUG(IWL_DL_RX, "r = %d, i = %d, %s, 0x%02x\n", r, 1072 IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r,
1320 i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); 1073 i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
1321 priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); 1074 priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
1322 } else { 1075 } else {
1323 /* No handling needed */ 1076 /* No handling needed */
1324 IWL_DEBUG(IWL_DL_RX, 1077 IWL_DEBUG_RX(priv,
1325 "r %d i %d No handler needed for %s, 0x%02x\n", 1078 "r %d i %d No handler needed for %s, 0x%02x\n",
1326 r, i, get_cmd_string(pkt->hdr.cmd), 1079 r, i, get_cmd_string(pkt->hdr.cmd),
1327 pkt->hdr.cmd); 1080 pkt->hdr.cmd);
@@ -1370,27 +1123,6 @@ void iwl_rx_handle(struct iwl_priv *priv)
1370 iwl_rx_queue_restock(priv); 1123 iwl_rx_queue_restock(priv);
1371} 1124}
1372 1125
1373#ifdef CONFIG_IWLWIFI_DEBUG
1374static void iwl_print_rx_config_cmd(struct iwl_priv *priv)
1375{
1376 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
1377
1378 IWL_DEBUG_RADIO("RX CONFIG:\n");
1379 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
1380 IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel));
1381 IWL_DEBUG_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags));
1382 IWL_DEBUG_RADIO("u32 filter_flags: 0x%08x\n",
1383 le32_to_cpu(rxon->filter_flags));
1384 IWL_DEBUG_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type);
1385 IWL_DEBUG_RADIO("u8 ofdm_basic_rates: 0x%02x\n",
1386 rxon->ofdm_basic_rates);
1387 IWL_DEBUG_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates);
1388 IWL_DEBUG_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr);
1389 IWL_DEBUG_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr);
1390 IWL_DEBUG_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id));
1391}
1392#endif
1393
1394/* call this function to flush any scheduled tasklet */ 1126/* call this function to flush any scheduled tasklet */
1395static inline void iwl_synchronize_irq(struct iwl_priv *priv) 1127static inline void iwl_synchronize_irq(struct iwl_priv *priv)
1396{ 1128{
@@ -1399,45 +1131,6 @@ static inline void iwl_synchronize_irq(struct iwl_priv *priv)
1399 tasklet_kill(&priv->irq_tasklet); 1131 tasklet_kill(&priv->irq_tasklet);
1400} 1132}
1401 1133
1402/**
1403 * iwl_irq_handle_error - called for HW or SW error interrupt from card
1404 */
1405static void iwl_irq_handle_error(struct iwl_priv *priv)
1406{
1407 /* Set the FW error flag -- cleared on iwl_down */
1408 set_bit(STATUS_FW_ERROR, &priv->status);
1409
1410 /* Cancel currently queued command. */
1411 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
1412
1413#ifdef CONFIG_IWLWIFI_DEBUG
1414 if (priv->debug_level & IWL_DL_FW_ERRORS) {
1415 iwl_dump_nic_error_log(priv);
1416 iwl_dump_nic_event_log(priv);
1417 iwl_print_rx_config_cmd(priv);
1418 }
1419#endif
1420
1421 wake_up_interruptible(&priv->wait_command_queue);
1422
1423 /* Keep the restart process from trying to send host
1424 * commands by clearing the INIT status bit */
1425 clear_bit(STATUS_READY, &priv->status);
1426
1427 if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) {
1428 IWL_DEBUG(IWL_DL_FW_ERRORS,
1429 "Restarting adapter due to uCode error.\n");
1430
1431 if (iwl_is_associated(priv)) {
1432 memcpy(&priv->recovery_rxon, &priv->active_rxon,
1433 sizeof(priv->recovery_rxon));
1434 priv->error_recovering = 1;
1435 }
1436 if (priv->cfg->mod_params->restart_fw)
1437 queue_work(priv->workqueue, &priv->restart);
1438 }
1439}
1440
1441static void iwl_error_recovery(struct iwl_priv *priv) 1134static void iwl_error_recovery(struct iwl_priv *priv)
1442{ 1135{
1443 unsigned long flags; 1136 unsigned long flags;
@@ -1482,7 +1175,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1482 if (priv->debug_level & IWL_DL_ISR) { 1175 if (priv->debug_level & IWL_DL_ISR) {
1483 /* just for debug */ 1176 /* just for debug */
1484 inta_mask = iwl_read32(priv, CSR_INT_MASK); 1177 inta_mask = iwl_read32(priv, CSR_INT_MASK);
1485 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 1178 IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
1486 inta, inta_mask, inta_fh); 1179 inta, inta_mask, inta_fh);
1487 } 1180 }
1488#endif 1181#endif
@@ -1516,12 +1209,12 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1516 if (priv->debug_level & (IWL_DL_ISR)) { 1209 if (priv->debug_level & (IWL_DL_ISR)) {
1517 /* NIC fires this, but we don't use it, redundant with WAKEUP */ 1210 /* NIC fires this, but we don't use it, redundant with WAKEUP */
1518 if (inta & CSR_INT_BIT_SCD) 1211 if (inta & CSR_INT_BIT_SCD)
1519 IWL_DEBUG_ISR("Scheduler finished to transmit " 1212 IWL_DEBUG_ISR(priv, "Scheduler finished to transmit "
1520 "the frame/frames.\n"); 1213 "the frame/frames.\n");
1521 1214
1522 /* Alive notification via Rx interrupt will do the real work */ 1215 /* Alive notification via Rx interrupt will do the real work */
1523 if (inta & CSR_INT_BIT_ALIVE) 1216 if (inta & CSR_INT_BIT_ALIVE)
1524 IWL_DEBUG_ISR("Alive interrupt\n"); 1217 IWL_DEBUG_ISR(priv, "Alive interrupt\n");
1525 } 1218 }
1526#endif 1219#endif
1527 /* Safely ignore these bits for debug checks below */ 1220 /* Safely ignore these bits for debug checks below */
@@ -1534,7 +1227,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1534 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) 1227 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
1535 hw_rf_kill = 1; 1228 hw_rf_kill = 1;
1536 1229
1537 IWL_DEBUG(IWL_DL_RF_KILL, "RF_KILL bit toggled to %s.\n", 1230 IWL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n",
1538 hw_rf_kill ? "disable radio" : "enable radio"); 1231 hw_rf_kill ? "disable radio" : "enable radio");
1539 1232
1540 /* driver only loads ucode once setting the interface up. 1233 /* driver only loads ucode once setting the interface up.
@@ -1569,7 +1262,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1569 1262
1570 /* uCode wakes up after power-down sleep */ 1263 /* uCode wakes up after power-down sleep */
1571 if (inta & CSR_INT_BIT_WAKEUP) { 1264 if (inta & CSR_INT_BIT_WAKEUP) {
1572 IWL_DEBUG_ISR("Wakeup interrupt\n"); 1265 IWL_DEBUG_ISR(priv, "Wakeup interrupt\n");
1573 iwl_rx_queue_update_write_ptr(priv, &priv->rxq); 1266 iwl_rx_queue_update_write_ptr(priv, &priv->rxq);
1574 iwl_txq_update_write_ptr(priv, &priv->txq[0]); 1267 iwl_txq_update_write_ptr(priv, &priv->txq[0]);
1575 iwl_txq_update_write_ptr(priv, &priv->txq[1]); 1268 iwl_txq_update_write_ptr(priv, &priv->txq[1]);
@@ -1590,7 +1283,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1590 } 1283 }
1591 1284
1592 if (inta & CSR_INT_BIT_FH_TX) { 1285 if (inta & CSR_INT_BIT_FH_TX) {
1593 IWL_DEBUG_ISR("Tx interrupt\n"); 1286 IWL_DEBUG_ISR(priv, "Tx interrupt\n");
1594 handled |= CSR_INT_BIT_FH_TX; 1287 handled |= CSR_INT_BIT_FH_TX;
1595 /* FH finished to write, send event */ 1288 /* FH finished to write, send event */
1596 priv->ucode_write_complete = 1; 1289 priv->ucode_write_complete = 1;
@@ -1616,7 +1309,7 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1616 inta = iwl_read32(priv, CSR_INT); 1309 inta = iwl_read32(priv, CSR_INT);
1617 inta_mask = iwl_read32(priv, CSR_INT_MASK); 1310 inta_mask = iwl_read32(priv, CSR_INT_MASK);
1618 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); 1311 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
1619 IWL_DEBUG_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " 1312 IWL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, "
1620 "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); 1313 "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags);
1621 } 1314 }
1622#endif 1315#endif
@@ -1648,7 +1341,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
1648 * This may be due to IRQ shared with another device, 1341 * This may be due to IRQ shared with another device,
1649 * or due to sporadic interrupts thrown from our NIC. */ 1342 * or due to sporadic interrupts thrown from our NIC. */
1650 if (!inta && !inta_fh) { 1343 if (!inta && !inta_fh) {
1651 IWL_DEBUG_ISR("Ignore interrupt, inta == 0, inta_fh == 0\n"); 1344 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n");
1652 goto none; 1345 goto none;
1653 } 1346 }
1654 1347
@@ -1659,7 +1352,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
1659 goto unplugged; 1352 goto unplugged;
1660 } 1353 }
1661 1354
1662 IWL_DEBUG_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 1355 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
1663 inta, inta_mask, inta_fh); 1356 inta, inta_mask, inta_fh);
1664 1357
1665 inta &= ~CSR_INT_BIT_SCD; 1358 inta &= ~CSR_INT_BIT_SCD;
@@ -1741,7 +1434,7 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1741 "Please use API v%u instead.\n", 1434 "Please use API v%u instead.\n",
1742 buf, api_max); 1435 buf, api_max);
1743 1436
1744 IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n", 1437 IWL_DEBUG_INFO(priv, "Got firmware '%s' file (%zd bytes) from disk\n",
1745 buf, ucode_raw->size); 1438 buf, ucode_raw->size);
1746 break; 1439 break;
1747 } 1440 }
@@ -1792,17 +1485,17 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1792 IWL_UCODE_API(priv->ucode_ver), 1485 IWL_UCODE_API(priv->ucode_ver),
1793 IWL_UCODE_SERIAL(priv->ucode_ver)); 1486 IWL_UCODE_SERIAL(priv->ucode_ver));
1794 1487
1795 IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n", 1488 IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n",
1796 priv->ucode_ver); 1489 priv->ucode_ver);
1797 IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n", 1490 IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n",
1798 inst_size); 1491 inst_size);
1799 IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n", 1492 IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n",
1800 data_size); 1493 data_size);
1801 IWL_DEBUG_INFO("f/w package hdr init inst size = %u\n", 1494 IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n",
1802 init_size); 1495 init_size);
1803 IWL_DEBUG_INFO("f/w package hdr init data size = %u\n", 1496 IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n",
1804 init_data_size); 1497 init_data_size);
1805 IWL_DEBUG_INFO("f/w package hdr boot inst size = %u\n", 1498 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n",
1806 boot_size); 1499 boot_size);
1807 1500
1808 /* Verify size of file vs. image size info in file's header */ 1501 /* Verify size of file vs. image size info in file's header */
@@ -1810,7 +1503,7 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1810 inst_size + data_size + init_size + 1503 inst_size + data_size + init_size +
1811 init_data_size + boot_size) { 1504 init_data_size + boot_size) {
1812 1505
1813 IWL_DEBUG_INFO("uCode file size %d too small\n", 1506 IWL_DEBUG_INFO(priv, "uCode file size %d too small\n",
1814 (int)ucode_raw->size); 1507 (int)ucode_raw->size);
1815 ret = -EINVAL; 1508 ret = -EINVAL;
1816 goto err_release; 1509 goto err_release;
@@ -1818,36 +1511,33 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1818 1511
1819 /* Verify that uCode images will fit in card's SRAM */ 1512 /* Verify that uCode images will fit in card's SRAM */
1820 if (inst_size > priv->hw_params.max_inst_size) { 1513 if (inst_size > priv->hw_params.max_inst_size) {
1821 IWL_DEBUG_INFO("uCode instr len %d too large to fit in\n", 1514 IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n",
1822 inst_size); 1515 inst_size);
1823 ret = -EINVAL; 1516 ret = -EINVAL;
1824 goto err_release; 1517 goto err_release;
1825 } 1518 }
1826 1519
1827 if (data_size > priv->hw_params.max_data_size) { 1520 if (data_size > priv->hw_params.max_data_size) {
1828 IWL_DEBUG_INFO("uCode data len %d too large to fit in\n", 1521 IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n",
1829 data_size); 1522 data_size);
1830 ret = -EINVAL; 1523 ret = -EINVAL;
1831 goto err_release; 1524 goto err_release;
1832 } 1525 }
1833 if (init_size > priv->hw_params.max_inst_size) { 1526 if (init_size > priv->hw_params.max_inst_size) {
1834 IWL_DEBUG_INFO 1527 IWL_INFO(priv, "uCode init instr len %d too large to fit in\n",
1835 ("uCode init instr len %d too large to fit in\n", 1528 init_size);
1836 init_size);
1837 ret = -EINVAL; 1529 ret = -EINVAL;
1838 goto err_release; 1530 goto err_release;
1839 } 1531 }
1840 if (init_data_size > priv->hw_params.max_data_size) { 1532 if (init_data_size > priv->hw_params.max_data_size) {
1841 IWL_DEBUG_INFO 1533 IWL_INFO(priv, "uCode init data len %d too large to fit in\n",
1842 ("uCode init data len %d too large to fit in\n",
1843 init_data_size); 1534 init_data_size);
1844 ret = -EINVAL; 1535 ret = -EINVAL;
1845 goto err_release; 1536 goto err_release;
1846 } 1537 }
1847 if (boot_size > priv->hw_params.max_bsm_size) { 1538 if (boot_size > priv->hw_params.max_bsm_size) {
1848 IWL_DEBUG_INFO 1539 IWL_INFO(priv, "uCode boot instr len %d too large to fit in\n",
1849 ("uCode boot instr len %d too large to fit in\n", 1540 boot_size);
1850 boot_size);
1851 ret = -EINVAL; 1541 ret = -EINVAL;
1852 goto err_release; 1542 goto err_release;
1853 } 1543 }
@@ -1896,16 +1586,16 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1896 /* Runtime instructions (first block of data in file) */ 1586 /* Runtime instructions (first block of data in file) */
1897 src = &ucode->data[0]; 1587 src = &ucode->data[0];
1898 len = priv->ucode_code.len; 1588 len = priv->ucode_code.len;
1899 IWL_DEBUG_INFO("Copying (but not loading) uCode instr len %Zd\n", len); 1589 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", len);
1900 memcpy(priv->ucode_code.v_addr, src, len); 1590 memcpy(priv->ucode_code.v_addr, src, len);
1901 IWL_DEBUG_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", 1591 IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
1902 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); 1592 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);
1903 1593
1904 /* Runtime data (2nd block) 1594 /* Runtime data (2nd block)
1905 * NOTE: Copy into backup buffer will be done in iwl_up() */ 1595 * NOTE: Copy into backup buffer will be done in iwl_up() */
1906 src = &ucode->data[inst_size]; 1596 src = &ucode->data[inst_size];
1907 len = priv->ucode_data.len; 1597 len = priv->ucode_data.len;
1908 IWL_DEBUG_INFO("Copying (but not loading) uCode data len %Zd\n", len); 1598 IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", len);
1909 memcpy(priv->ucode_data.v_addr, src, len); 1599 memcpy(priv->ucode_data.v_addr, src, len);
1910 memcpy(priv->ucode_data_backup.v_addr, src, len); 1600 memcpy(priv->ucode_data_backup.v_addr, src, len);
1911 1601
@@ -1913,7 +1603,7 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1913 if (init_size) { 1603 if (init_size) {
1914 src = &ucode->data[inst_size + data_size]; 1604 src = &ucode->data[inst_size + data_size];
1915 len = priv->ucode_init.len; 1605 len = priv->ucode_init.len;
1916 IWL_DEBUG_INFO("Copying (but not loading) init instr len %Zd\n", 1606 IWL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n",
1917 len); 1607 len);
1918 memcpy(priv->ucode_init.v_addr, src, len); 1608 memcpy(priv->ucode_init.v_addr, src, len);
1919 } 1609 }
@@ -1922,7 +1612,7 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1922 if (init_data_size) { 1612 if (init_data_size) {
1923 src = &ucode->data[inst_size + data_size + init_size]; 1613 src = &ucode->data[inst_size + data_size + init_size];
1924 len = priv->ucode_init_data.len; 1614 len = priv->ucode_init_data.len;
1925 IWL_DEBUG_INFO("Copying (but not loading) init data len %Zd\n", 1615 IWL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n",
1926 len); 1616 len);
1927 memcpy(priv->ucode_init_data.v_addr, src, len); 1617 memcpy(priv->ucode_init_data.v_addr, src, len);
1928 } 1618 }
@@ -1930,7 +1620,7 @@ static int iwl_read_ucode(struct iwl_priv *priv)
1930 /* Bootstrap instructions (5th block) */ 1620 /* Bootstrap instructions (5th block) */
1931 src = &ucode->data[inst_size + data_size + init_size + init_data_size]; 1621 src = &ucode->data[inst_size + data_size + init_size + init_data_size];
1932 len = priv->ucode_boot.len; 1622 len = priv->ucode_boot.len;
1933 IWL_DEBUG_INFO("Copying (but not loading) boot instr len %Zd\n", len); 1623 IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", len);
1934 memcpy(priv->ucode_boot.v_addr, src, len); 1624 memcpy(priv->ucode_boot.v_addr, src, len);
1935 1625
1936 /* We have our copies now, allow OS release its copies */ 1626 /* We have our copies now, allow OS release its copies */
@@ -1962,12 +1652,12 @@ static void iwl_alive_start(struct iwl_priv *priv)
1962{ 1652{
1963 int ret = 0; 1653 int ret = 0;
1964 1654
1965 IWL_DEBUG_INFO("Runtime Alive received.\n"); 1655 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
1966 1656
1967 if (priv->card_alive.is_valid != UCODE_VALID_OK) { 1657 if (priv->card_alive.is_valid != UCODE_VALID_OK) {
1968 /* We had an error bringing up the hardware, so take it 1658 /* We had an error bringing up the hardware, so take it
1969 * all the way back down so we can try again */ 1659 * all the way back down so we can try again */
1970 IWL_DEBUG_INFO("Alive failed.\n"); 1660 IWL_DEBUG_INFO(priv, "Alive failed.\n");
1971 goto restart; 1661 goto restart;
1972 } 1662 }
1973 1663
@@ -1977,7 +1667,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
1977 if (iwl_verify_ucode(priv)) { 1667 if (iwl_verify_ucode(priv)) {
1978 /* Runtime instruction load was bad; 1668 /* Runtime instruction load was bad;
1979 * take it all the way back down so we can try again */ 1669 * take it all the way back down so we can try again */
1980 IWL_DEBUG_INFO("Bad runtime uCode load.\n"); 1670 IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n");
1981 goto restart; 1671 goto restart;
1982 } 1672 }
1983 1673
@@ -2010,6 +1700,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2010 } else { 1700 } else {
2011 /* Initialize our rx_config data */ 1701 /* Initialize our rx_config data */
2012 iwl_connection_init_rx_config(priv, priv->iw_mode); 1702 iwl_connection_init_rx_config(priv, priv->iw_mode);
1703 iwl_set_rxon_chain(priv);
2013 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN); 1704 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
2014 } 1705 }
2015 1706
@@ -2026,7 +1717,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
2026 1717
2027 iwl_leds_register(priv); 1718 iwl_leds_register(priv);
2028 1719
2029 IWL_DEBUG_INFO("ALIVE processing complete.\n"); 1720 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
2030 set_bit(STATUS_READY, &priv->status); 1721 set_bit(STATUS_READY, &priv->status);
2031 wake_up_interruptible(&priv->wait_command_queue); 1722 wake_up_interruptible(&priv->wait_command_queue);
2032 1723
@@ -2060,7 +1751,7 @@ static void __iwl_down(struct iwl_priv *priv)
2060 unsigned long flags; 1751 unsigned long flags;
2061 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); 1752 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status);
2062 1753
2063 IWL_DEBUG_INFO(DRV_NAME " is going down\n"); 1754 IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n");
2064 1755
2065 if (!exit_pending) 1756 if (!exit_pending)
2066 set_bit(STATUS_EXIT_PENDING, &priv->status); 1757 set_bit(STATUS_EXIT_PENDING, &priv->status);
@@ -2241,7 +1932,7 @@ static int __iwl_up(struct iwl_priv *priv)
2241 /* start card; "initialize" will load runtime ucode */ 1932 /* start card; "initialize" will load runtime ucode */
2242 iwl_nic_start(priv); 1933 iwl_nic_start(priv);
2243 1934
2244 IWL_DEBUG_INFO(DRV_NAME " is coming up\n"); 1935 IWL_DEBUG_INFO(priv, DRV_NAME " is coming up\n");
2245 1936
2246 return 0; 1937 return 0;
2247 } 1938 }
@@ -2362,7 +2053,7 @@ static void iwl_post_associate(struct iwl_priv *priv)
2362 return; 2053 return;
2363 } 2054 }
2364 2055
2365 IWL_DEBUG_ASSOC("Associated as %d to: %pM\n", 2056 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
2366 priv->assoc_id, priv->active_rxon.bssid_addr); 2057 priv->assoc_id, priv->active_rxon.bssid_addr);
2367 2058
2368 2059
@@ -2395,7 +2086,7 @@ static void iwl_post_associate(struct iwl_priv *priv)
2395 iwl_set_rxon_chain(priv); 2086 iwl_set_rxon_chain(priv);
2396 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 2087 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
2397 2088
2398 IWL_DEBUG_ASSOC("assoc id %d beacon interval %d\n", 2089 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
2399 priv->assoc_id, priv->beacon_int); 2090 priv->assoc_id, priv->beacon_int);
2400 2091
2401 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 2092 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
@@ -2468,7 +2159,7 @@ static int iwl_mac_start(struct ieee80211_hw *hw)
2468 struct iwl_priv *priv = hw->priv; 2159 struct iwl_priv *priv = hw->priv;
2469 int ret; 2160 int ret;
2470 2161
2471 IWL_DEBUG_MAC80211("enter\n"); 2162 IWL_DEBUG_MAC80211(priv, "enter\n");
2472 2163
2473 /* we should be verifying the device is ready to be opened */ 2164 /* we should be verifying the device is ready to be opened */
2474 mutex_lock(&priv->mutex); 2165 mutex_lock(&priv->mutex);
@@ -2498,7 +2189,7 @@ static int iwl_mac_start(struct ieee80211_hw *hw)
2498 if (iwl_is_rfkill(priv)) 2189 if (iwl_is_rfkill(priv))
2499 goto out; 2190 goto out;
2500 2191
2501 IWL_DEBUG_INFO("Start UP work done.\n"); 2192 IWL_DEBUG_INFO(priv, "Start UP work done.\n");
2502 2193
2503 if (test_bit(STATUS_IN_SUSPEND, &priv->status)) 2194 if (test_bit(STATUS_IN_SUSPEND, &priv->status))
2504 return 0; 2195 return 0;
@@ -2518,7 +2209,7 @@ static int iwl_mac_start(struct ieee80211_hw *hw)
2518 2209
2519out: 2210out:
2520 priv->is_open = 1; 2211 priv->is_open = 1;
2521 IWL_DEBUG_MAC80211("leave\n"); 2212 IWL_DEBUG_MAC80211(priv, "leave\n");
2522 return 0; 2213 return 0;
2523} 2214}
2524 2215
@@ -2526,10 +2217,10 @@ static void iwl_mac_stop(struct ieee80211_hw *hw)
2526{ 2217{
2527 struct iwl_priv *priv = hw->priv; 2218 struct iwl_priv *priv = hw->priv;
2528 2219
2529 IWL_DEBUG_MAC80211("enter\n"); 2220 IWL_DEBUG_MAC80211(priv, "enter\n");
2530 2221
2531 if (!priv->is_open) { 2222 if (!priv->is_open) {
2532 IWL_DEBUG_MAC80211("leave - skip\n"); 2223 IWL_DEBUG_MAC80211(priv, "leave - skip\n");
2533 return; 2224 return;
2534 } 2225 }
2535 2226
@@ -2552,22 +2243,22 @@ static void iwl_mac_stop(struct ieee80211_hw *hw)
2552 iwl_write32(priv, CSR_INT, 0xFFFFFFFF); 2243 iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
2553 iwl_enable_interrupts(priv); 2244 iwl_enable_interrupts(priv);
2554 2245
2555 IWL_DEBUG_MAC80211("leave\n"); 2246 IWL_DEBUG_MAC80211(priv, "leave\n");
2556} 2247}
2557 2248
2558static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 2249static int iwl_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2559{ 2250{
2560 struct iwl_priv *priv = hw->priv; 2251 struct iwl_priv *priv = hw->priv;
2561 2252
2562 IWL_DEBUG_MACDUMP("enter\n"); 2253 IWL_DEBUG_MACDUMP(priv, "enter\n");
2563 2254
2564 IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 2255 IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
2565 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 2256 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
2566 2257
2567 if (iwl_tx_skb(priv, skb)) 2258 if (iwl_tx_skb(priv, skb))
2568 dev_kfree_skb_any(skb); 2259 dev_kfree_skb_any(skb);
2569 2260
2570 IWL_DEBUG_MACDUMP("leave\n"); 2261 IWL_DEBUG_MACDUMP(priv, "leave\n");
2571 return NETDEV_TX_OK; 2262 return NETDEV_TX_OK;
2572} 2263}
2573 2264
@@ -2577,10 +2268,10 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
2577 struct iwl_priv *priv = hw->priv; 2268 struct iwl_priv *priv = hw->priv;
2578 unsigned long flags; 2269 unsigned long flags;
2579 2270
2580 IWL_DEBUG_MAC80211("enter: type %d\n", conf->type); 2271 IWL_DEBUG_MAC80211(priv, "enter: type %d\n", conf->type);
2581 2272
2582 if (priv->vif) { 2273 if (priv->vif) {
2583 IWL_DEBUG_MAC80211("leave - vif != NULL\n"); 2274 IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
2584 return -EOPNOTSUPP; 2275 return -EOPNOTSUPP;
2585 } 2276 }
2586 2277
@@ -2593,7 +2284,7 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
2593 mutex_lock(&priv->mutex); 2284 mutex_lock(&priv->mutex);
2594 2285
2595 if (conf->mac_addr) { 2286 if (conf->mac_addr) {
2596 IWL_DEBUG_MAC80211("Set %pM\n", conf->mac_addr); 2287 IWL_DEBUG_MAC80211(priv, "Set %pM\n", conf->mac_addr);
2597 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); 2288 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
2598 } 2289 }
2599 2290
@@ -2603,7 +2294,7 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
2603 2294
2604 mutex_unlock(&priv->mutex); 2295 mutex_unlock(&priv->mutex);
2605 2296
2606 IWL_DEBUG_MAC80211("leave\n"); 2297 IWL_DEBUG_MAC80211(priv, "leave\n");
2607 return 0; 2298 return 0;
2608} 2299}
2609 2300
@@ -2624,12 +2315,12 @@ static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2624 u16 channel; 2315 u16 channel;
2625 2316
2626 mutex_lock(&priv->mutex); 2317 mutex_lock(&priv->mutex);
2627 IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); 2318 IWL_DEBUG_MAC80211(priv, "enter to channel %d\n", conf->channel->hw_value);
2628 2319
2629 priv->current_ht_config.is_ht = conf_is_ht(conf); 2320 priv->current_ht_config.is_ht = conf_is_ht(conf);
2630 2321
2631 if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) { 2322 if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) {
2632 IWL_DEBUG_MAC80211("leave - RF-KILL - waiting for uCode\n"); 2323 IWL_DEBUG_MAC80211(priv, "leave - RF-KILL - waiting for uCode\n");
2633 goto out; 2324 goto out;
2634 } 2325 }
2635 2326
@@ -2637,14 +2328,14 @@ static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2637 iwl_radio_kill_sw_disable_radio(priv); 2328 iwl_radio_kill_sw_disable_radio(priv);
2638 2329
2639 if (!iwl_is_ready(priv)) { 2330 if (!iwl_is_ready(priv)) {
2640 IWL_DEBUG_MAC80211("leave - not ready\n"); 2331 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
2641 ret = -EIO; 2332 ret = -EIO;
2642 goto out; 2333 goto out;
2643 } 2334 }
2644 2335
2645 if (unlikely(!priv->cfg->mod_params->disable_hw_scan && 2336 if (unlikely(!priv->cfg->mod_params->disable_hw_scan &&
2646 test_bit(STATUS_SCANNING, &priv->status))) { 2337 test_bit(STATUS_SCANNING, &priv->status))) {
2647 IWL_DEBUG_MAC80211("leave - scanning\n"); 2338 IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
2648 mutex_unlock(&priv->mutex); 2339 mutex_unlock(&priv->mutex);
2649 return 0; 2340 return 0;
2650 } 2341 }
@@ -2652,7 +2343,7 @@ static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2652 channel = ieee80211_frequency_to_channel(conf->channel->center_freq); 2343 channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
2653 ch_info = iwl_get_channel_info(priv, conf->channel->band, channel); 2344 ch_info = iwl_get_channel_info(priv, conf->channel->band, channel);
2654 if (!is_channel_valid(ch_info)) { 2345 if (!is_channel_valid(ch_info)) {
2655 IWL_DEBUG_MAC80211("leave - invalid channel\n"); 2346 IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
2656 ret = -EINVAL; 2347 ret = -EINVAL;
2657 goto out; 2348 goto out;
2658 } 2349 }
@@ -2697,12 +2388,12 @@ static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2697#endif 2388#endif
2698 2389
2699 if (!conf->radio_enabled) { 2390 if (!conf->radio_enabled) {
2700 IWL_DEBUG_MAC80211("leave - radio disabled\n"); 2391 IWL_DEBUG_MAC80211(priv, "leave - radio disabled\n");
2701 goto out; 2392 goto out;
2702 } 2393 }
2703 2394
2704 if (iwl_is_rfkill(priv)) { 2395 if (iwl_is_rfkill(priv)) {
2705 IWL_DEBUG_MAC80211("leave - RF kill\n"); 2396 IWL_DEBUG_MAC80211(priv, "leave - RF kill\n");
2706 ret = -EIO; 2397 ret = -EIO;
2707 goto out; 2398 goto out;
2708 } 2399 }
@@ -2712,9 +2403,9 @@ static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2712 else 2403 else
2713 ret = iwl_power_set_user_mode(priv, IWL_POWER_MODE_CAM); 2404 ret = iwl_power_set_user_mode(priv, IWL_POWER_MODE_CAM);
2714 if (ret) 2405 if (ret)
2715 IWL_DEBUG_MAC80211("Error setting power level\n"); 2406 IWL_DEBUG_MAC80211(priv, "Error setting power level\n");
2716 2407
2717 IWL_DEBUG_MAC80211("TX Power old=%d new=%d\n", 2408 IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n",
2718 priv->tx_power_user_lmt, conf->power_level); 2409 priv->tx_power_user_lmt, conf->power_level);
2719 2410
2720 iwl_set_tx_power(priv, conf->power_level, false); 2411 iwl_set_tx_power(priv, conf->power_level, false);
@@ -2728,9 +2419,9 @@ static int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
2728 &priv->staging_rxon, sizeof(priv->staging_rxon))) 2419 &priv->staging_rxon, sizeof(priv->staging_rxon)))
2729 iwl_commit_rxon(priv); 2420 iwl_commit_rxon(priv);
2730 else 2421 else
2731 IWL_DEBUG_INFO("No re-sending same RXON configuration.\n"); 2422 IWL_DEBUG_INFO(priv, "No re-sending same RXON configuration.\n");
2732 2423
2733 IWL_DEBUG_MAC80211("leave\n"); 2424 IWL_DEBUG_MAC80211(priv, "leave\n");
2734 2425
2735out: 2426out:
2736 mutex_unlock(&priv->mutex); 2427 mutex_unlock(&priv->mutex);
@@ -2811,7 +2502,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw,
2811 return -EIO; 2502 return -EIO;
2812 2503
2813 if (priv->vif != vif) { 2504 if (priv->vif != vif) {
2814 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n"); 2505 IWL_DEBUG_MAC80211(priv, "leave - priv->vif != vif\n");
2815 return 0; 2506 return 0;
2816 } 2507 }
2817 2508
@@ -2833,7 +2524,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw,
2833 mutex_lock(&priv->mutex); 2524 mutex_lock(&priv->mutex);
2834 2525
2835 if (conf->bssid) 2526 if (conf->bssid)
2836 IWL_DEBUG_MAC80211("bssid: %pM\n", conf->bssid); 2527 IWL_DEBUG_MAC80211(priv, "bssid: %pM\n", conf->bssid);
2837 2528
2838/* 2529/*
2839 * very dubious code was here; the probe filtering flag is never set: 2530 * very dubious code was here; the probe filtering flag is never set:
@@ -2846,7 +2537,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw,
2846 if (!conf->bssid) { 2537 if (!conf->bssid) {
2847 conf->bssid = priv->mac_addr; 2538 conf->bssid = priv->mac_addr;
2848 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN); 2539 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
2849 IWL_DEBUG_MAC80211("bssid was set to: %pM\n", 2540 IWL_DEBUG_MAC80211(priv, "bssid was set to: %pM\n",
2850 conf->bssid); 2541 conf->bssid);
2851 } 2542 }
2852 if (priv->ibss_beacon) 2543 if (priv->ibss_beacon)
@@ -2865,7 +2556,7 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw,
2865 if (iwl_scan_cancel_timeout(priv, 100)) { 2556 if (iwl_scan_cancel_timeout(priv, 100)) {
2866 IWL_WARN(priv, "Aborted scan still in progress " 2557 IWL_WARN(priv, "Aborted scan still in progress "
2867 "after 100ms\n"); 2558 "after 100ms\n");
2868 IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); 2559 IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
2869 mutex_unlock(&priv->mutex); 2560 mutex_unlock(&priv->mutex);
2870 return -EAGAIN; 2561 return -EAGAIN;
2871 } 2562 }
@@ -2893,64 +2584,18 @@ static int iwl_mac_config_interface(struct ieee80211_hw *hw,
2893 } 2584 }
2894 2585
2895 done: 2586 done:
2896 IWL_DEBUG_MAC80211("leave\n"); 2587 IWL_DEBUG_MAC80211(priv, "leave\n");
2897 mutex_unlock(&priv->mutex); 2588 mutex_unlock(&priv->mutex);
2898 2589
2899 return 0; 2590 return 0;
2900} 2591}
2901 2592
2902static void iwl_configure_filter(struct ieee80211_hw *hw,
2903 unsigned int changed_flags,
2904 unsigned int *total_flags,
2905 int mc_count, struct dev_addr_list *mc_list)
2906{
2907 struct iwl_priv *priv = hw->priv;
2908 __le32 *filter_flags = &priv->staging_rxon.filter_flags;
2909
2910 IWL_DEBUG_MAC80211("Enter: changed: 0x%x, total: 0x%x\n",
2911 changed_flags, *total_flags);
2912
2913 if (changed_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) {
2914 if (*total_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS))
2915 *filter_flags |= RXON_FILTER_PROMISC_MSK;
2916 else
2917 *filter_flags &= ~RXON_FILTER_PROMISC_MSK;
2918 }
2919 if (changed_flags & FIF_ALLMULTI) {
2920 if (*total_flags & FIF_ALLMULTI)
2921 *filter_flags |= RXON_FILTER_ACCEPT_GRP_MSK;
2922 else
2923 *filter_flags &= ~RXON_FILTER_ACCEPT_GRP_MSK;
2924 }
2925 if (changed_flags & FIF_CONTROL) {
2926 if (*total_flags & FIF_CONTROL)
2927 *filter_flags |= RXON_FILTER_CTL2HOST_MSK;
2928 else
2929 *filter_flags &= ~RXON_FILTER_CTL2HOST_MSK;
2930 }
2931 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
2932 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
2933 *filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
2934 else
2935 *filter_flags &= ~RXON_FILTER_BCON_AWARE_MSK;
2936 }
2937
2938 /* We avoid iwl_commit_rxon here to commit the new filter flags
2939 * since mac80211 will call ieee80211_hw_config immediately.
2940 * (mc_list is not supported at this time). Otherwise, we need to
2941 * queue a background iwl_commit_rxon work.
2942 */
2943
2944 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
2945 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
2946}
2947
2948static void iwl_mac_remove_interface(struct ieee80211_hw *hw, 2593static void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2949 struct ieee80211_if_init_conf *conf) 2594 struct ieee80211_if_init_conf *conf)
2950{ 2595{
2951 struct iwl_priv *priv = hw->priv; 2596 struct iwl_priv *priv = hw->priv;
2952 2597
2953 IWL_DEBUG_MAC80211("enter\n"); 2598 IWL_DEBUG_MAC80211(priv, "enter\n");
2954 2599
2955 mutex_lock(&priv->mutex); 2600 mutex_lock(&priv->mutex);
2956 2601
@@ -2965,7 +2610,7 @@ static void iwl_mac_remove_interface(struct ieee80211_hw *hw,
2965 } 2610 }
2966 mutex_unlock(&priv->mutex); 2611 mutex_unlock(&priv->mutex);
2967 2612
2968 IWL_DEBUG_MAC80211("leave\n"); 2613 IWL_DEBUG_MAC80211(priv, "leave\n");
2969 2614
2970} 2615}
2971 2616
@@ -2977,10 +2622,10 @@ static void iwl_bss_info_changed(struct ieee80211_hw *hw,
2977{ 2622{
2978 struct iwl_priv *priv = hw->priv; 2623 struct iwl_priv *priv = hw->priv;
2979 2624
2980 IWL_DEBUG_MAC80211("changes = 0x%X\n", changes); 2625 IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
2981 2626
2982 if (changes & BSS_CHANGED_ERP_PREAMBLE) { 2627 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
2983 IWL_DEBUG_MAC80211("ERP_PREAMBLE %d\n", 2628 IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
2984 bss_conf->use_short_preamble); 2629 bss_conf->use_short_preamble);
2985 if (bss_conf->use_short_preamble) 2630 if (bss_conf->use_short_preamble)
2986 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 2631 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
@@ -2989,7 +2634,7 @@ static void iwl_bss_info_changed(struct ieee80211_hw *hw,
2989 } 2634 }
2990 2635
2991 if (changes & BSS_CHANGED_ERP_CTS_PROT) { 2636 if (changes & BSS_CHANGED_ERP_CTS_PROT) {
2992 IWL_DEBUG_MAC80211("ERP_CTS %d\n", bss_conf->use_cts_prot); 2637 IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot);
2993 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) 2638 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
2994 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK; 2639 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
2995 else 2640 else
@@ -3002,7 +2647,7 @@ static void iwl_bss_info_changed(struct ieee80211_hw *hw,
3002 } 2647 }
3003 2648
3004 if (changes & BSS_CHANGED_ASSOC) { 2649 if (changes & BSS_CHANGED_ASSOC) {
3005 IWL_DEBUG_MAC80211("ASSOC %d\n", bss_conf->assoc); 2650 IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
3006 /* This should never happen as this function should 2651 /* This should never happen as this function should
3007 * never be called from interrupt context. */ 2652 * never be called from interrupt context. */
3008 if (WARN_ON_ONCE(in_interrupt())) 2653 if (WARN_ON_ONCE(in_interrupt()))
@@ -3024,10 +2669,10 @@ static void iwl_bss_info_changed(struct ieee80211_hw *hw,
3024 mutex_unlock(&priv->mutex); 2669 mutex_unlock(&priv->mutex);
3025 } else { 2670 } else {
3026 priv->assoc_id = 0; 2671 priv->assoc_id = 0;
3027 IWL_DEBUG_MAC80211("DISASSOC %d\n", bss_conf->assoc); 2672 IWL_DEBUG_MAC80211(priv, "DISASSOC %d\n", bss_conf->assoc);
3028 } 2673 }
3029 } else if (changes && iwl_is_associated(priv) && priv->assoc_id) { 2674 } else if (changes && iwl_is_associated(priv) && priv->assoc_id) {
3030 IWL_DEBUG_MAC80211("Associated Changes %d\n", changes); 2675 IWL_DEBUG_MAC80211(priv, "Associated Changes %d\n", changes);
3031 iwl_send_rxon_assoc(priv); 2676 iwl_send_rxon_assoc(priv);
3032 } 2677 }
3033 2678
@@ -3039,14 +2684,14 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
3039 struct iwl_priv *priv = hw->priv; 2684 struct iwl_priv *priv = hw->priv;
3040 int ret; 2685 int ret;
3041 2686
3042 IWL_DEBUG_MAC80211("enter\n"); 2687 IWL_DEBUG_MAC80211(priv, "enter\n");
3043 2688
3044 mutex_lock(&priv->mutex); 2689 mutex_lock(&priv->mutex);
3045 spin_lock_irqsave(&priv->lock, flags); 2690 spin_lock_irqsave(&priv->lock, flags);
3046 2691
3047 if (!iwl_is_ready_rf(priv)) { 2692 if (!iwl_is_ready_rf(priv)) {
3048 ret = -EIO; 2693 ret = -EIO;
3049 IWL_DEBUG_MAC80211("leave - not ready or exit pending\n"); 2694 IWL_DEBUG_MAC80211(priv, "leave - not ready or exit pending\n");
3050 goto out_unlock; 2695 goto out_unlock;
3051 } 2696 }
3052 2697
@@ -3056,7 +2701,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
3056 */ 2701 */
3057 if (priv->next_scan_jiffies && 2702 if (priv->next_scan_jiffies &&
3058 time_after(priv->next_scan_jiffies, jiffies)) { 2703 time_after(priv->next_scan_jiffies, jiffies)) {
3059 IWL_DEBUG_SCAN("scan rejected: within next scan period\n"); 2704 IWL_DEBUG_SCAN(priv, "scan rejected: within next scan period\n");
3060 queue_work(priv->workqueue, &priv->scan_completed); 2705 queue_work(priv->workqueue, &priv->scan_completed);
3061 ret = 0; 2706 ret = 0;
3062 goto out_unlock; 2707 goto out_unlock;
@@ -3065,7 +2710,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
3065 /* if we just finished scan ask for delay */ 2710 /* if we just finished scan ask for delay */
3066 if (iwl_is_associated(priv) && priv->last_scan_jiffies && 2711 if (iwl_is_associated(priv) && priv->last_scan_jiffies &&
3067 time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, jiffies)) { 2712 time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, jiffies)) {
3068 IWL_DEBUG_SCAN("scan rejected: within previous scan period\n"); 2713 IWL_DEBUG_SCAN(priv, "scan rejected: within previous scan period\n");
3069 queue_work(priv->workqueue, &priv->scan_completed); 2714 queue_work(priv->workqueue, &priv->scan_completed);
3070 ret = 0; 2715 ret = 0;
3071 goto out_unlock; 2716 goto out_unlock;
@@ -3081,7 +2726,7 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
3081 2726
3082 ret = iwl_scan_initiate(priv); 2727 ret = iwl_scan_initiate(priv);
3083 2728
3084 IWL_DEBUG_MAC80211("leave\n"); 2729 IWL_DEBUG_MAC80211(priv, "leave\n");
3085 2730
3086out_unlock: 2731out_unlock:
3087 spin_unlock_irqrestore(&priv->lock, flags); 2732 spin_unlock_irqrestore(&priv->lock, flags);
@@ -3096,11 +2741,11 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
3096{ 2741{
3097 2742
3098 struct iwl_priv *priv = hw->priv; 2743 struct iwl_priv *priv = hw->priv;
3099 IWL_DEBUG_MAC80211("enter\n"); 2744 IWL_DEBUG_MAC80211(priv, "enter\n");
3100 2745
3101 iwl_update_tkip_key(priv, keyconf, addr, iv32, phase1key); 2746 iwl_update_tkip_key(priv, keyconf, addr, iv32, phase1key);
3102 2747
3103 IWL_DEBUG_MAC80211("leave\n"); 2748 IWL_DEBUG_MAC80211(priv, "leave\n");
3104} 2749}
3105 2750
3106static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 2751static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
@@ -3114,16 +2759,16 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3114 u8 sta_id; 2759 u8 sta_id;
3115 bool is_default_wep_key = false; 2760 bool is_default_wep_key = false;
3116 2761
3117 IWL_DEBUG_MAC80211("enter\n"); 2762 IWL_DEBUG_MAC80211(priv, "enter\n");
3118 2763
3119 if (priv->hw_params.sw_crypto) { 2764 if (priv->hw_params.sw_crypto) {
3120 IWL_DEBUG_MAC80211("leave - hwcrypto disabled\n"); 2765 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
3121 return -EOPNOTSUPP; 2766 return -EOPNOTSUPP;
3122 } 2767 }
3123 addr = sta ? sta->addr : iwl_bcast_addr; 2768 addr = sta ? sta->addr : iwl_bcast_addr;
3124 sta_id = iwl_find_station(priv, addr); 2769 sta_id = iwl_find_station(priv, addr);
3125 if (sta_id == IWL_INVALID_STATION) { 2770 if (sta_id == IWL_INVALID_STATION) {
3126 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n", 2771 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
3127 addr); 2772 addr);
3128 return -EINVAL; 2773 return -EINVAL;
3129 2774
@@ -3153,7 +2798,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3153 else 2798 else
3154 ret = iwl_set_dynamic_key(priv, key, sta_id); 2799 ret = iwl_set_dynamic_key(priv, key, sta_id);
3155 2800
3156 IWL_DEBUG_MAC80211("enable hwcrypto key\n"); 2801 IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n");
3157 break; 2802 break;
3158 case DISABLE_KEY: 2803 case DISABLE_KEY:
3159 if (is_default_wep_key) 2804 if (is_default_wep_key)
@@ -3161,13 +2806,13 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
3161 else 2806 else
3162 ret = iwl_remove_dynamic_key(priv, key, sta_id); 2807 ret = iwl_remove_dynamic_key(priv, key, sta_id);
3163 2808
3164 IWL_DEBUG_MAC80211("disable hwcrypto key\n"); 2809 IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n");
3165 break; 2810 break;
3166 default: 2811 default:
3167 ret = -EINVAL; 2812 ret = -EINVAL;
3168 } 2813 }
3169 2814
3170 IWL_DEBUG_MAC80211("leave\n"); 2815 IWL_DEBUG_MAC80211(priv, "leave\n");
3171 2816
3172 return ret; 2817 return ret;
3173} 2818}
@@ -3179,15 +2824,15 @@ static int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
3179 unsigned long flags; 2824 unsigned long flags;
3180 int q; 2825 int q;
3181 2826
3182 IWL_DEBUG_MAC80211("enter\n"); 2827 IWL_DEBUG_MAC80211(priv, "enter\n");
3183 2828
3184 if (!iwl_is_ready_rf(priv)) { 2829 if (!iwl_is_ready_rf(priv)) {
3185 IWL_DEBUG_MAC80211("leave - RF not ready\n"); 2830 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
3186 return -EIO; 2831 return -EIO;
3187 } 2832 }
3188 2833
3189 if (queue >= AC_NUM) { 2834 if (queue >= AC_NUM) {
3190 IWL_DEBUG_MAC80211("leave - queue >= AC_NUM %d\n", queue); 2835 IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue);
3191 return 0; 2836 return 0;
3192 } 2837 }
3193 2838
@@ -3211,7 +2856,7 @@ static int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
3211 2856
3212 spin_unlock_irqrestore(&priv->lock, flags); 2857 spin_unlock_irqrestore(&priv->lock, flags);
3213 2858
3214 IWL_DEBUG_MAC80211("leave\n"); 2859 IWL_DEBUG_MAC80211(priv, "leave\n");
3215 return 0; 2860 return 0;
3216} 2861}
3217 2862
@@ -3221,7 +2866,7 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3221{ 2866{
3222 struct iwl_priv *priv = hw->priv; 2867 struct iwl_priv *priv = hw->priv;
3223 2868
3224 IWL_DEBUG_HT("A-MPDU action on addr %pM tid %d\n", 2869 IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n",
3225 sta->addr, tid); 2870 sta->addr, tid);
3226 2871
3227 if (!(priv->cfg->sku & IWL_SKU_N)) 2872 if (!(priv->cfg->sku & IWL_SKU_N))
@@ -3229,19 +2874,19 @@ static int iwl_mac_ampdu_action(struct ieee80211_hw *hw,
3229 2874
3230 switch (action) { 2875 switch (action) {
3231 case IEEE80211_AMPDU_RX_START: 2876 case IEEE80211_AMPDU_RX_START:
3232 IWL_DEBUG_HT("start Rx\n"); 2877 IWL_DEBUG_HT(priv, "start Rx\n");
3233 return iwl_sta_rx_agg_start(priv, sta->addr, tid, *ssn); 2878 return iwl_sta_rx_agg_start(priv, sta->addr, tid, *ssn);
3234 case IEEE80211_AMPDU_RX_STOP: 2879 case IEEE80211_AMPDU_RX_STOP:
3235 IWL_DEBUG_HT("stop Rx\n"); 2880 IWL_DEBUG_HT(priv, "stop Rx\n");
3236 return iwl_sta_rx_agg_stop(priv, sta->addr, tid); 2881 return iwl_sta_rx_agg_stop(priv, sta->addr, tid);
3237 case IEEE80211_AMPDU_TX_START: 2882 case IEEE80211_AMPDU_TX_START:
3238 IWL_DEBUG_HT("start Tx\n"); 2883 IWL_DEBUG_HT(priv, "start Tx\n");
3239 return iwl_tx_agg_start(priv, sta->addr, tid, ssn); 2884 return iwl_tx_agg_start(priv, sta->addr, tid, ssn);
3240 case IEEE80211_AMPDU_TX_STOP: 2885 case IEEE80211_AMPDU_TX_STOP:
3241 IWL_DEBUG_HT("stop Tx\n"); 2886 IWL_DEBUG_HT(priv, "stop Tx\n");
3242 return iwl_tx_agg_stop(priv, sta->addr, tid); 2887 return iwl_tx_agg_stop(priv, sta->addr, tid);
3243 default: 2888 default:
3244 IWL_DEBUG_HT("unknown\n"); 2889 IWL_DEBUG_HT(priv, "unknown\n");
3245 return -EINVAL; 2890 return -EINVAL;
3246 break; 2891 break;
3247 } 2892 }
@@ -3257,10 +2902,10 @@ static int iwl_mac_get_tx_stats(struct ieee80211_hw *hw,
3257 struct iwl_queue *q; 2902 struct iwl_queue *q;
3258 unsigned long flags; 2903 unsigned long flags;
3259 2904
3260 IWL_DEBUG_MAC80211("enter\n"); 2905 IWL_DEBUG_MAC80211(priv, "enter\n");
3261 2906
3262 if (!iwl_is_ready_rf(priv)) { 2907 if (!iwl_is_ready_rf(priv)) {
3263 IWL_DEBUG_MAC80211("leave - RF not ready\n"); 2908 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
3264 return -EIO; 2909 return -EIO;
3265 } 2910 }
3266 2911
@@ -3278,7 +2923,7 @@ static int iwl_mac_get_tx_stats(struct ieee80211_hw *hw,
3278 } 2923 }
3279 spin_unlock_irqrestore(&priv->lock, flags); 2924 spin_unlock_irqrestore(&priv->lock, flags);
3280 2925
3281 IWL_DEBUG_MAC80211("leave\n"); 2926 IWL_DEBUG_MAC80211(priv, "leave\n");
3282 2927
3283 return 0; 2928 return 0;
3284} 2929}
@@ -3289,8 +2934,8 @@ static int iwl_mac_get_stats(struct ieee80211_hw *hw,
3289 struct iwl_priv *priv = hw->priv; 2934 struct iwl_priv *priv = hw->priv;
3290 2935
3291 priv = hw->priv; 2936 priv = hw->priv;
3292 IWL_DEBUG_MAC80211("enter\n"); 2937 IWL_DEBUG_MAC80211(priv, "enter\n");
3293 IWL_DEBUG_MAC80211("leave\n"); 2938 IWL_DEBUG_MAC80211(priv, "leave\n");
3294 2939
3295 return 0; 2940 return 0;
3296} 2941}
@@ -3301,7 +2946,7 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
3301 unsigned long flags; 2946 unsigned long flags;
3302 2947
3303 mutex_lock(&priv->mutex); 2948 mutex_lock(&priv->mutex);
3304 IWL_DEBUG_MAC80211("enter\n"); 2949 IWL_DEBUG_MAC80211(priv, "enter\n");
3305 2950
3306 spin_lock_irqsave(&priv->lock, flags); 2951 spin_lock_irqsave(&priv->lock, flags);
3307 memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info)); 2952 memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info));
@@ -3328,7 +2973,7 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
3328 spin_unlock_irqrestore(&priv->lock, flags); 2973 spin_unlock_irqrestore(&priv->lock, flags);
3329 2974
3330 if (!iwl_is_ready_rf(priv)) { 2975 if (!iwl_is_ready_rf(priv)) {
3331 IWL_DEBUG_MAC80211("leave - not ready\n"); 2976 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
3332 mutex_unlock(&priv->mutex); 2977 mutex_unlock(&priv->mutex);
3333 return; 2978 return;
3334 } 2979 }
@@ -3357,7 +3002,7 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
3357 IEEE80211_CHAN_RADAR)) 3002 IEEE80211_CHAN_RADAR))
3358 iwl_power_disable_management(priv, 3000); 3003 iwl_power_disable_management(priv, 3000);
3359 3004
3360 IWL_DEBUG_MAC80211("leave - not in IBSS\n"); 3005 IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n");
3361 mutex_unlock(&priv->mutex); 3006 mutex_unlock(&priv->mutex);
3362 return; 3007 return;
3363 } 3008 }
@@ -3366,7 +3011,7 @@ static void iwl_mac_reset_tsf(struct ieee80211_hw *hw)
3366 3011
3367 mutex_unlock(&priv->mutex); 3012 mutex_unlock(&priv->mutex);
3368 3013
3369 IWL_DEBUG_MAC80211("leave\n"); 3014 IWL_DEBUG_MAC80211(priv, "leave\n");
3370} 3015}
3371 3016
3372static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb) 3017static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
@@ -3375,15 +3020,15 @@ static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
3375 unsigned long flags; 3020 unsigned long flags;
3376 __le64 timestamp; 3021 __le64 timestamp;
3377 3022
3378 IWL_DEBUG_MAC80211("enter\n"); 3023 IWL_DEBUG_MAC80211(priv, "enter\n");
3379 3024
3380 if (!iwl_is_ready_rf(priv)) { 3025 if (!iwl_is_ready_rf(priv)) {
3381 IWL_DEBUG_MAC80211("leave - RF not ready\n"); 3026 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
3382 return -EIO; 3027 return -EIO;
3383 } 3028 }
3384 3029
3385 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) { 3030 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
3386 IWL_DEBUG_MAC80211("leave - not IBSS\n"); 3031 IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
3387 return -EIO; 3032 return -EIO;
3388 } 3033 }
3389 3034
@@ -3398,7 +3043,7 @@ static int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
3398 timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; 3043 timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
3399 priv->timestamp = le64_to_cpu(timestamp); 3044 priv->timestamp = le64_to_cpu(timestamp);
3400 3045
3401 IWL_DEBUG_MAC80211("leave\n"); 3046 IWL_DEBUG_MAC80211(priv, "leave\n");
3402 spin_unlock_irqrestore(&priv->lock, flags); 3047 spin_unlock_irqrestore(&priv->lock, flags);
3403 3048
3404 iwl_reset_qos(priv); 3049 iwl_reset_qos(priv);
@@ -3556,7 +3201,7 @@ static ssize_t store_flags(struct device *d,
3556 if (iwl_scan_cancel_timeout(priv, 100)) 3201 if (iwl_scan_cancel_timeout(priv, 100))
3557 IWL_WARN(priv, "Could not cancel scan.\n"); 3202 IWL_WARN(priv, "Could not cancel scan.\n");
3558 else { 3203 else {
3559 IWL_DEBUG_INFO("Commit rxon.flags = 0x%04X\n", flags); 3204 IWL_DEBUG_INFO(priv, "Commit rxon.flags = 0x%04X\n", flags);
3560 priv->staging_rxon.flags = cpu_to_le32(flags); 3205 priv->staging_rxon.flags = cpu_to_le32(flags);
3561 iwl_commit_rxon(priv); 3206 iwl_commit_rxon(priv);
3562 } 3207 }
@@ -3595,7 +3240,7 @@ static ssize_t store_filter_flags(struct device *d,
3595 if (iwl_scan_cancel_timeout(priv, 100)) 3240 if (iwl_scan_cancel_timeout(priv, 100))
3596 IWL_WARN(priv, "Could not cancel scan.\n"); 3241 IWL_WARN(priv, "Could not cancel scan.\n");
3597 else { 3242 else {
3598 IWL_DEBUG_INFO("Committing rxon.filter_flags = " 3243 IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = "
3599 "0x%04X\n", filter_flags); 3244 "0x%04X\n", filter_flags);
3600 priv->staging_rxon.filter_flags = 3245 priv->staging_rxon.filter_flags =
3601 cpu_to_le32(filter_flags); 3246 cpu_to_le32(filter_flags);
@@ -3632,7 +3277,7 @@ static ssize_t store_power_level(struct device *d,
3632 3277
3633 ret = iwl_power_set_user_mode(priv, mode); 3278 ret = iwl_power_set_user_mode(priv, mode);
3634 if (ret) { 3279 if (ret) {
3635 IWL_DEBUG_MAC80211("failed setting power mode.\n"); 3280 IWL_DEBUG_MAC80211(priv, "failed setting power mode.\n");
3636 goto out; 3281 goto out;
3637 } 3282 }
3638 ret = count; 3283 ret = count;
@@ -3833,7 +3478,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3833 3478
3834 SET_IEEE80211_DEV(hw, &pdev->dev); 3479 SET_IEEE80211_DEV(hw, &pdev->dev);
3835 3480
3836 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 3481 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
3837 priv->cfg = cfg; 3482 priv->cfg = cfg;
3838 priv->pci_dev = pdev; 3483 priv->pci_dev = pdev;
3839 3484
@@ -3882,9 +3527,9 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3882 goto out_pci_release_regions; 3527 goto out_pci_release_regions;
3883 } 3528 }
3884 3529
3885 IWL_DEBUG_INFO("pci_resource_len = 0x%08llx\n", 3530 IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n",
3886 (unsigned long long) pci_resource_len(pdev, 0)); 3531 (unsigned long long) pci_resource_len(pdev, 0));
3887 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base); 3532 IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base);
3888 3533
3889 iwl_hw_detect(priv); 3534 iwl_hw_detect(priv);
3890 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n", 3535 IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n",
@@ -3897,7 +3542,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3897 /* amp init */ 3542 /* amp init */
3898 err = priv->cfg->ops->lib->apm_ops.init(priv); 3543 err = priv->cfg->ops->lib->apm_ops.init(priv);
3899 if (err < 0) { 3544 if (err < 0) {
3900 IWL_DEBUG_INFO("Failed to init APMG\n"); 3545 IWL_DEBUG_INFO(priv, "Failed to init APMG\n");
3901 goto out_iounmap; 3546 goto out_iounmap;
3902 } 3547 }
3903 /***************** 3548 /*****************
@@ -3915,7 +3560,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3915 3560
3916 /* extract MAC Address */ 3561 /* extract MAC Address */
3917 iwl_eeprom_get_mac(priv, priv->mac_addr); 3562 iwl_eeprom_get_mac(priv, priv->mac_addr);
3918 IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr); 3563 IWL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->mac_addr);
3919 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 3564 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
3920 3565
3921 /************************ 3566 /************************
@@ -3942,7 +3587,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3942 /* Disable radio (SW RF KILL) via parameter when loading driver */ 3587 /* Disable radio (SW RF KILL) via parameter when loading driver */
3943 if (priv->cfg->mod_params->disable) { 3588 if (priv->cfg->mod_params->disable) {
3944 set_bit(STATUS_RF_KILL_SW, &priv->status); 3589 set_bit(STATUS_RF_KILL_SW, &priv->status);
3945 IWL_DEBUG_INFO("Radio disabled.\n"); 3590 IWL_DEBUG_INFO(priv, "Radio disabled.\n");
3946 } 3591 }
3947 3592
3948 /******************** 3593 /********************
@@ -4036,7 +3681,7 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
4036 if (!priv) 3681 if (!priv)
4037 return; 3682 return;
4038 3683
4039 IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n"); 3684 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
4040 3685
4041 iwl_dbgfs_unregister(priv); 3686 iwl_dbgfs_unregister(priv);
4042 sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group); 3687 sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group);
@@ -4119,9 +3764,12 @@ static int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
4119static int iwl_pci_resume(struct pci_dev *pdev) 3764static int iwl_pci_resume(struct pci_dev *pdev)
4120{ 3765{
4121 struct iwl_priv *priv = pci_get_drvdata(pdev); 3766 struct iwl_priv *priv = pci_get_drvdata(pdev);
3767 int ret;
4122 3768
4123 pci_set_power_state(pdev, PCI_D0); 3769 pci_set_power_state(pdev, PCI_D0);
4124 pci_enable_device(pdev); 3770 ret = pci_enable_device(pdev);
3771 if (ret)
3772 return ret;
4125 pci_restore_state(pdev); 3773 pci_restore_state(pdev);
4126 iwl_enable_interrupts(priv); 3774 iwl_enable_interrupts(priv);
4127 3775
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 8e5e6663be35..735f3f19928c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -202,7 +202,7 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv,
202 val = data->nrg_silence_rssi[i]; 202 val = data->nrg_silence_rssi[i];
203 silence_ref = max(silence_ref, val); 203 silence_ref = max(silence_ref, val);
204 } 204 }
205 IWL_DEBUG_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", 205 IWL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n",
206 silence_rssi_a, silence_rssi_b, silence_rssi_c, 206 silence_rssi_a, silence_rssi_b, silence_rssi_c,
207 silence_ref); 207 silence_ref);
208 208
@@ -226,7 +226,7 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv,
226 max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); 226 max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i]));
227 max_nrg_cck += 6; 227 max_nrg_cck += 6;
228 228
229 IWL_DEBUG_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", 229 IWL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n",
230 rx_info->beacon_energy_a, rx_info->beacon_energy_b, 230 rx_info->beacon_energy_a, rx_info->beacon_energy_b,
231 rx_info->beacon_energy_c, max_nrg_cck - 6); 231 rx_info->beacon_energy_c, max_nrg_cck - 6);
232 232
@@ -236,15 +236,15 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv,
236 data->num_in_cck_no_fa++; 236 data->num_in_cck_no_fa++;
237 else 237 else
238 data->num_in_cck_no_fa = 0; 238 data->num_in_cck_no_fa = 0;
239 IWL_DEBUG_CALIB("consecutive bcns with few false alarms = %u\n", 239 IWL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n",
240 data->num_in_cck_no_fa); 240 data->num_in_cck_no_fa);
241 241
242 /* If we got too many false alarms this time, reduce sensitivity */ 242 /* If we got too many false alarms this time, reduce sensitivity */
243 if ((false_alarms > max_false_alarms) && 243 if ((false_alarms > max_false_alarms) &&
244 (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { 244 (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) {
245 IWL_DEBUG_CALIB("norm FA %u > max FA %u\n", 245 IWL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n",
246 false_alarms, max_false_alarms); 246 false_alarms, max_false_alarms);
247 IWL_DEBUG_CALIB("... reducing sensitivity\n"); 247 IWL_DEBUG_CALIB(priv, "... reducing sensitivity\n");
248 data->nrg_curr_state = IWL_FA_TOO_MANY; 248 data->nrg_curr_state = IWL_FA_TOO_MANY;
249 /* Store for "fewer than desired" on later beacon */ 249 /* Store for "fewer than desired" on later beacon */
250 data->nrg_silence_ref = silence_ref; 250 data->nrg_silence_ref = silence_ref;
@@ -266,7 +266,7 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv,
266 data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - 266 data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref -
267 (s32)silence_ref; 267 (s32)silence_ref;
268 268
269 IWL_DEBUG_CALIB("norm FA %u < min FA %u, silence diff %d\n", 269 IWL_DEBUG_CALIB(priv, "norm FA %u < min FA %u, silence diff %d\n",
270 false_alarms, min_false_alarms, 270 false_alarms, min_false_alarms,
271 data->nrg_auto_corr_silence_diff); 271 data->nrg_auto_corr_silence_diff);
272 272
@@ -280,17 +280,17 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv,
280 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || 280 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) ||
281 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { 281 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) {
282 282
283 IWL_DEBUG_CALIB("... increasing sensitivity\n"); 283 IWL_DEBUG_CALIB(priv, "... increasing sensitivity\n");
284 /* Increase nrg value to increase sensitivity */ 284 /* Increase nrg value to increase sensitivity */
285 val = data->nrg_th_cck + NRG_STEP_CCK; 285 val = data->nrg_th_cck + NRG_STEP_CCK;
286 data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); 286 data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val);
287 } else { 287 } else {
288 IWL_DEBUG_CALIB("... but not changing sensitivity\n"); 288 IWL_DEBUG_CALIB(priv, "... but not changing sensitivity\n");
289 } 289 }
290 290
291 /* Else we got a healthy number of false alarms, keep status quo */ 291 /* Else we got a healthy number of false alarms, keep status quo */
292 } else { 292 } else {
293 IWL_DEBUG_CALIB(" FA in safe zone\n"); 293 IWL_DEBUG_CALIB(priv, " FA in safe zone\n");
294 data->nrg_curr_state = IWL_FA_GOOD_RANGE; 294 data->nrg_curr_state = IWL_FA_GOOD_RANGE;
295 295
296 /* Store for use in "fewer than desired" with later beacon */ 296 /* Store for use in "fewer than desired" with later beacon */
@@ -300,7 +300,7 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv,
300 * give it some extra margin by reducing sensitivity again 300 * give it some extra margin by reducing sensitivity again
301 * (but don't go below measured energy of desired Rx) */ 301 * (but don't go below measured energy of desired Rx) */
302 if (IWL_FA_TOO_MANY == data->nrg_prev_state) { 302 if (IWL_FA_TOO_MANY == data->nrg_prev_state) {
303 IWL_DEBUG_CALIB("... increasing margin\n"); 303 IWL_DEBUG_CALIB(priv, "... increasing margin\n");
304 if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) 304 if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN))
305 data->nrg_th_cck -= NRG_MARGIN; 305 data->nrg_th_cck -= NRG_MARGIN;
306 else 306 else
@@ -314,7 +314,7 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv,
314 * Lower value is higher energy, so we use max()! 314 * Lower value is higher energy, so we use max()!
315 */ 315 */
316 data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); 316 data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck);
317 IWL_DEBUG_CALIB("new nrg_th_cck %u\n", data->nrg_th_cck); 317 IWL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck);
318 318
319 data->nrg_prev_state = data->nrg_curr_state; 319 data->nrg_prev_state = data->nrg_curr_state;
320 320
@@ -367,7 +367,7 @@ static int iwl_sens_auto_corr_ofdm(struct iwl_priv *priv,
367 /* If we got too many false alarms this time, reduce sensitivity */ 367 /* If we got too many false alarms this time, reduce sensitivity */
368 if (false_alarms > max_false_alarms) { 368 if (false_alarms > max_false_alarms) {
369 369
370 IWL_DEBUG_CALIB("norm FA %u > max FA %u)\n", 370 IWL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n",
371 false_alarms, max_false_alarms); 371 false_alarms, max_false_alarms);
372 372
373 val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; 373 val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM;
@@ -390,7 +390,7 @@ static int iwl_sens_auto_corr_ofdm(struct iwl_priv *priv,
390 /* Else if we got fewer than desired, increase sensitivity */ 390 /* Else if we got fewer than desired, increase sensitivity */
391 else if (false_alarms < min_false_alarms) { 391 else if (false_alarms < min_false_alarms) {
392 392
393 IWL_DEBUG_CALIB("norm FA %u < min FA %u\n", 393 IWL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n",
394 false_alarms, min_false_alarms); 394 false_alarms, min_false_alarms);
395 395
396 val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; 396 val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM;
@@ -409,7 +409,7 @@ static int iwl_sens_auto_corr_ofdm(struct iwl_priv *priv,
409 data->auto_corr_ofdm_mrc_x1 = 409 data->auto_corr_ofdm_mrc_x1 =
410 max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); 410 max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val);
411 } else { 411 } else {
412 IWL_DEBUG_CALIB("min FA %u < norm FA %u < max FA %u OK\n", 412 IWL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n",
413 min_false_alarms, false_alarms, max_false_alarms); 413 min_false_alarms, false_alarms, max_false_alarms);
414 } 414 }
415 return 0; 415 return 0;
@@ -452,18 +452,18 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
452 cpu_to_le16((u16)data->nrg_th_ofdm); 452 cpu_to_le16((u16)data->nrg_th_ofdm);
453 453
454 cmd.table[HD_BARKER_CORR_TH_ADD_MIN_INDEX] = 454 cmd.table[HD_BARKER_CORR_TH_ADD_MIN_INDEX] =
455 __constant_cpu_to_le16(190); 455 cpu_to_le16(190);
456 cmd.table[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] = 456 cmd.table[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] =
457 __constant_cpu_to_le16(390); 457 cpu_to_le16(390);
458 cmd.table[HD_OFDM_ENERGY_TH_IN_INDEX] = 458 cmd.table[HD_OFDM_ENERGY_TH_IN_INDEX] =
459 __constant_cpu_to_le16(62); 459 cpu_to_le16(62);
460 460
461 IWL_DEBUG_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", 461 IWL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n",
462 data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, 462 data->auto_corr_ofdm, data->auto_corr_ofdm_mrc,
463 data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, 463 data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1,
464 data->nrg_th_ofdm); 464 data->nrg_th_ofdm);
465 465
466 IWL_DEBUG_CALIB("cck: ac %u mrc %u thresh %u\n", 466 IWL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n",
467 data->auto_corr_cck, data->auto_corr_cck_mrc, 467 data->auto_corr_cck, data->auto_corr_cck_mrc,
468 data->nrg_th_cck); 468 data->nrg_th_cck);
469 469
@@ -473,7 +473,7 @@ static int iwl_sensitivity_write(struct iwl_priv *priv)
473 /* Don't send command to uCode if nothing has changed */ 473 /* Don't send command to uCode if nothing has changed */
474 if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]), 474 if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]),
475 sizeof(u16)*HD_TABLE_SIZE)) { 475 sizeof(u16)*HD_TABLE_SIZE)) {
476 IWL_DEBUG_CALIB("No change in SENSITIVITY_CMD\n"); 476 IWL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n");
477 return 0; 477 return 0;
478 } 478 }
479 479
@@ -498,7 +498,7 @@ void iwl_init_sensitivity(struct iwl_priv *priv)
498 if (priv->disable_sens_cal) 498 if (priv->disable_sens_cal)
499 return; 499 return;
500 500
501 IWL_DEBUG_CALIB("Start iwl_init_sensitivity\n"); 501 IWL_DEBUG_CALIB(priv, "Start iwl_init_sensitivity\n");
502 502
503 /* Clear driver's sensitivity algo data */ 503 /* Clear driver's sensitivity algo data */
504 data = &(priv->sensitivity_data); 504 data = &(priv->sensitivity_data);
@@ -536,7 +536,7 @@ void iwl_init_sensitivity(struct iwl_priv *priv)
536 data->last_fa_cnt_cck = 0; 536 data->last_fa_cnt_cck = 0;
537 537
538 ret |= iwl_sensitivity_write(priv); 538 ret |= iwl_sensitivity_write(priv);
539 IWL_DEBUG_CALIB("<<return 0x%X\n", ret); 539 IWL_DEBUG_CALIB(priv, "<<return 0x%X\n", ret);
540} 540}
541EXPORT_SYMBOL(iwl_init_sensitivity); 541EXPORT_SYMBOL(iwl_init_sensitivity);
542 542
@@ -562,13 +562,13 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv,
562 data = &(priv->sensitivity_data); 562 data = &(priv->sensitivity_data);
563 563
564 if (!iwl_is_associated(priv)) { 564 if (!iwl_is_associated(priv)) {
565 IWL_DEBUG_CALIB("<< - not associated\n"); 565 IWL_DEBUG_CALIB(priv, "<< - not associated\n");
566 return; 566 return;
567 } 567 }
568 568
569 spin_lock_irqsave(&priv->lock, flags); 569 spin_lock_irqsave(&priv->lock, flags);
570 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { 570 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
571 IWL_DEBUG_CALIB("<< invalid data.\n"); 571 IWL_DEBUG_CALIB(priv, "<< invalid data.\n");
572 spin_unlock_irqrestore(&priv->lock, flags); 572 spin_unlock_irqrestore(&priv->lock, flags);
573 return; 573 return;
574 } 574 }
@@ -595,10 +595,10 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv,
595 595
596 spin_unlock_irqrestore(&priv->lock, flags); 596 spin_unlock_irqrestore(&priv->lock, flags);
597 597
598 IWL_DEBUG_CALIB("rx_enable_time = %u usecs\n", rx_enable_time); 598 IWL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time);
599 599
600 if (!rx_enable_time) { 600 if (!rx_enable_time) {
601 IWL_DEBUG_CALIB("<< RX Enable Time == 0! \n"); 601 IWL_DEBUG_CALIB(priv, "<< RX Enable Time == 0! \n");
602 return; 602 return;
603 } 603 }
604 604
@@ -637,7 +637,7 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv,
637 norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; 637 norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm;
638 norm_fa_cck = fa_cck + bad_plcp_cck; 638 norm_fa_cck = fa_cck + bad_plcp_cck;
639 639
640 IWL_DEBUG_CALIB("cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, 640 IWL_DEBUG_CALIB(priv, "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck,
641 bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); 641 bad_plcp_cck, fa_ofdm, bad_plcp_ofdm);
642 642
643 iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); 643 iwl_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time);
@@ -690,13 +690,13 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
690 * then we're done forever. */ 690 * then we're done forever. */
691 if (data->state != IWL_CHAIN_NOISE_ACCUMULATE) { 691 if (data->state != IWL_CHAIN_NOISE_ACCUMULATE) {
692 if (data->state == IWL_CHAIN_NOISE_ALIVE) 692 if (data->state == IWL_CHAIN_NOISE_ALIVE)
693 IWL_DEBUG_CALIB("Wait for noise calib reset\n"); 693 IWL_DEBUG_CALIB(priv, "Wait for noise calib reset\n");
694 return; 694 return;
695 } 695 }
696 696
697 spin_lock_irqsave(&priv->lock, flags); 697 spin_lock_irqsave(&priv->lock, flags);
698 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { 698 if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) {
699 IWL_DEBUG_CALIB(" << Interference data unavailable\n"); 699 IWL_DEBUG_CALIB(priv, " << Interference data unavailable\n");
700 spin_unlock_irqrestore(&priv->lock, flags); 700 spin_unlock_irqrestore(&priv->lock, flags);
701 return; 701 return;
702 } 702 }
@@ -709,7 +709,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
709 /* Make sure we accumulate data for just the associated channel 709 /* Make sure we accumulate data for just the associated channel
710 * (even if scanning). */ 710 * (even if scanning). */
711 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { 711 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) {
712 IWL_DEBUG_CALIB("Stats not from chan=%d, band24=%d\n", 712 IWL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n",
713 rxon_chnum, rxon_band24); 713 rxon_chnum, rxon_band24);
714 spin_unlock_irqrestore(&priv->lock, flags); 714 spin_unlock_irqrestore(&priv->lock, flags);
715 return; 715 return;
@@ -739,11 +739,11 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
739 data->chain_signal_b = (chain_sig_b + data->chain_signal_b); 739 data->chain_signal_b = (chain_sig_b + data->chain_signal_b);
740 data->chain_signal_c = (chain_sig_c + data->chain_signal_c); 740 data->chain_signal_c = (chain_sig_c + data->chain_signal_c);
741 741
742 IWL_DEBUG_CALIB("chan=%d, band24=%d, beacon=%d\n", 742 IWL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n",
743 rxon_chnum, rxon_band24, data->beacon_count); 743 rxon_chnum, rxon_band24, data->beacon_count);
744 IWL_DEBUG_CALIB("chain_sig: a %d b %d c %d\n", 744 IWL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n",
745 chain_sig_a, chain_sig_b, chain_sig_c); 745 chain_sig_a, chain_sig_b, chain_sig_c);
746 IWL_DEBUG_CALIB("chain_noise: a %d b %d c %d\n", 746 IWL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n",
747 chain_noise_a, chain_noise_b, chain_noise_c); 747 chain_noise_a, chain_noise_b, chain_noise_c);
748 748
749 /* If this is the 20th beacon, determine: 749 /* If this is the 20th beacon, determine:
@@ -773,9 +773,9 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
773 active_chains = (1 << max_average_sig_antenna_i); 773 active_chains = (1 << max_average_sig_antenna_i);
774 } 774 }
775 775
776 IWL_DEBUG_CALIB("average_sig: a %d b %d c %d\n", 776 IWL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n",
777 average_sig[0], average_sig[1], average_sig[2]); 777 average_sig[0], average_sig[1], average_sig[2]);
778 IWL_DEBUG_CALIB("max_average_sig = %d, antenna %d\n", 778 IWL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n",
779 max_average_sig, max_average_sig_antenna_i); 779 max_average_sig, max_average_sig_antenna_i);
780 780
781 /* Compare signal strengths for all 3 receivers. */ 781 /* Compare signal strengths for all 3 receivers. */
@@ -789,7 +789,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
789 data->disconn_array[i] = 1; 789 data->disconn_array[i] = 1;
790 else 790 else
791 active_chains |= (1 << i); 791 active_chains |= (1 << i);
792 IWL_DEBUG_CALIB("i = %d rssiDelta = %d " 792 IWL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d "
793 "disconn_array[i] = %d\n", 793 "disconn_array[i] = %d\n",
794 i, rssi_delta, data->disconn_array[i]); 794 i, rssi_delta, data->disconn_array[i]);
795 } 795 }
@@ -813,7 +813,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
813 * disconnected connect it anyway */ 813 * disconnected connect it anyway */
814 data->disconn_array[i] = 0; 814 data->disconn_array[i] = 0;
815 active_chains |= ant_msk; 815 active_chains |= ant_msk;
816 IWL_DEBUG_CALIB("All Tx chains are disconnected W/A - " 816 IWL_DEBUG_CALIB(priv, "All Tx chains are disconnected W/A - "
817 "declare %d as connected\n", i); 817 "declare %d as connected\n", i);
818 break; 818 break;
819 } 819 }
@@ -821,7 +821,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
821 821
822 /* Save for use within RXON, TX, SCAN commands, etc. */ 822 /* Save for use within RXON, TX, SCAN commands, etc. */
823 priv->chain_noise_data.active_chains = active_chains; 823 priv->chain_noise_data.active_chains = active_chains;
824 IWL_DEBUG_CALIB("active_chains (bitwise) = 0x%x\n", 824 IWL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n",
825 active_chains); 825 active_chains);
826 826
827 /* Analyze noise for rx balance */ 827 /* Analyze noise for rx balance */
@@ -839,15 +839,16 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
839 } 839 }
840 } 840 }
841 841
842 IWL_DEBUG_CALIB("average_noise: a %d b %d c %d\n", 842 IWL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n",
843 average_noise[0], average_noise[1], 843 average_noise[0], average_noise[1],
844 average_noise[2]); 844 average_noise[2]);
845 845
846 IWL_DEBUG_CALIB("min_average_noise = %d, antenna %d\n", 846 IWL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n",
847 min_average_noise, min_average_noise_antenna_i); 847 min_average_noise, min_average_noise_antenna_i);
848 848
849 priv->cfg->ops->utils->gain_computation(priv, average_noise, 849 if (priv->cfg->ops->utils->gain_computation)
850 min_average_noise_antenna_i, min_average_noise); 850 priv->cfg->ops->utils->gain_computation(priv, average_noise,
851 min_average_noise_antenna_i, min_average_noise);
851 852
852 /* Some power changes may have been made during the calibration. 853 /* Some power changes may have been made during the calibration.
853 * Update and commit the RXON 854 * Update and commit the RXON
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index e49415c7fb2a..29d40746da6a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -144,9 +144,11 @@ enum {
144 WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */ 144 WHO_IS_AWAKE_NOTIFICATION = 0x94, /* not used */
145 145
146 /* Miscellaneous commands */ 146 /* Miscellaneous commands */
147 REPLY_TX_POWER_DBM_CMD = 0x95,
147 QUIET_NOTIFICATION = 0x96, /* not used */ 148 QUIET_NOTIFICATION = 0x96, /* not used */
148 REPLY_TX_PWR_TABLE_CMD = 0x97, 149 REPLY_TX_PWR_TABLE_CMD = 0x97,
149 REPLY_TX_POWER_DBM_CMD = 0x98, 150 REPLY_TX_POWER_DBM_CMD_V1 = 0x98, /* old version of API */
151 TX_ANT_CONFIGURATION_CMD = 0x98, /* not used */
150 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */ 152 MEASURE_ABORT_NOTIFICATION = 0x99, /* not used */
151 153
152 /* Bluetooth device coexistence config command */ 154 /* Bluetooth device coexistence config command */
@@ -2846,7 +2848,7 @@ struct statistics_rx_ht_phy {
2846 __le32 reserved2; 2848 __le32 reserved2;
2847} __attribute__ ((packed)); 2849} __attribute__ ((packed));
2848 2850
2849#define INTERFERENCE_DATA_AVAILABLE __constant_cpu_to_le32(1) 2851#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1)
2850 2852
2851struct statistics_rx_non_phy { 2853struct statistics_rx_non_phy {
2852 __le32 bogus_cts; /* CTS received when not expecting CTS */ 2854 __le32 bogus_cts; /* CTS received when not expecting CTS */
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 21f386568c9c..e18c3f326f71 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/etherdevice.h>
31#include <net/mac80211.h> 32#include <net/mac80211.h>
32 33
33#include "iwl-eeprom.h" 34#include "iwl-eeprom.h"
@@ -322,7 +323,7 @@ void iwl_reset_qos(struct iwl_priv *priv)
322 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0; 323 priv->qos_data.def_qos_parm.ac[i].reserved1 = 0;
323 } 324 }
324 } 325 }
325 IWL_DEBUG_QOS("set QoS to default \n"); 326 IWL_DEBUG_QOS(priv, "set QoS to default \n");
326 327
327 spin_unlock_irqrestore(&priv->lock, flags); 328 spin_unlock_irqrestore(&priv->lock, flags);
328} 329}
@@ -403,6 +404,7 @@ static void iwlcore_init_hw_rates(struct iwl_priv *priv,
403 } 404 }
404} 405}
405 406
407
406/** 408/**
407 * iwlcore_init_geos - Initialize mac80211's geo/channel info based from eeprom 409 * iwlcore_init_geos - Initialize mac80211's geo/channel info based from eeprom
408 */ 410 */
@@ -417,7 +419,7 @@ int iwlcore_init_geos(struct iwl_priv *priv)
417 419
418 if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || 420 if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
419 priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { 421 priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
420 IWL_DEBUG_INFO("Geography modes already initialized.\n"); 422 IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n");
421 set_bit(STATUS_GEO_CONFIGURED, &priv->status); 423 set_bit(STATUS_GEO_CONFIGURED, &priv->status);
422 return 0; 424 return 0;
423 } 425 }
@@ -499,7 +501,7 @@ int iwlcore_init_geos(struct iwl_priv *priv)
499 /* Save flags for reg domain usage */ 501 /* Save flags for reg domain usage */
500 geo_ch->orig_flags = geo_ch->flags; 502 geo_ch->orig_flags = geo_ch->flags;
501 503
502 IWL_DEBUG_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", 504 IWL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n",
503 ch->channel, geo_ch->center_freq, 505 ch->channel, geo_ch->center_freq,
504 is_channel_a_band(ch) ? "5.2" : "2.4", 506 is_channel_a_band(ch) ? "5.2" : "2.4",
505 geo_ch->flags & IEEE80211_CHAN_DISABLED ? 507 geo_ch->flags & IEEE80211_CHAN_DISABLED ?
@@ -586,6 +588,167 @@ u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv,
586} 588}
587EXPORT_SYMBOL(iwl_is_fat_tx_allowed); 589EXPORT_SYMBOL(iwl_is_fat_tx_allowed);
588 590
591void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
592{
593 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
594
595 if (hw_decrypt)
596 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
597 else
598 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK;
599
600}
601EXPORT_SYMBOL(iwl_set_rxon_hwcrypto);
602
603/**
604 * iwl_check_rxon_cmd - validate RXON structure is valid
605 *
606 * NOTE: This is really only useful during development and can eventually
607 * be #ifdef'd out once the driver is stable and folks aren't actively
608 * making changes
609 */
610int iwl_check_rxon_cmd(struct iwl_priv *priv)
611{
612 int error = 0;
613 int counter = 1;
614 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
615
616 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
617 error |= le32_to_cpu(rxon->flags &
618 (RXON_FLG_TGJ_NARROW_BAND_MSK |
619 RXON_FLG_RADAR_DETECT_MSK));
620 if (error)
621 IWL_WARN(priv, "check 24G fields %d | %d\n",
622 counter++, error);
623 } else {
624 error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
625 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
626 if (error)
627 IWL_WARN(priv, "check 52 fields %d | %d\n",
628 counter++, error);
629 error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
630 if (error)
631 IWL_WARN(priv, "check 52 CCK %d | %d\n",
632 counter++, error);
633 }
634 error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
635 if (error)
636 IWL_WARN(priv, "check mac addr %d | %d\n", counter++, error);
637
638 /* make sure basic rates 6Mbps and 1Mbps are supported */
639 error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
640 ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
641 if (error)
642 IWL_WARN(priv, "check basic rate %d | %d\n", counter++, error);
643
644 error |= (le16_to_cpu(rxon->assoc_id) > 2007);
645 if (error)
646 IWL_WARN(priv, "check assoc id %d | %d\n", counter++, error);
647
648 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
649 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
650 if (error)
651 IWL_WARN(priv, "check CCK and short slot %d | %d\n",
652 counter++, error);
653
654 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
655 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
656 if (error)
657 IWL_WARN(priv, "check CCK & auto detect %d | %d\n",
658 counter++, error);
659
660 error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
661 RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
662 if (error)
663 IWL_WARN(priv, "check TGG and auto detect %d | %d\n",
664 counter++, error);
665
666 if (error)
667 IWL_WARN(priv, "Tuning to channel %d\n",
668 le16_to_cpu(rxon->channel));
669
670 if (error) {
671 IWL_ERR(priv, "Not a valid iwl_rxon_assoc_cmd field values\n");
672 return -1;
673 }
674 return 0;
675}
676EXPORT_SYMBOL(iwl_check_rxon_cmd);
677
678/**
679 * iwl_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
680 * @priv: staging_rxon is compared to active_rxon
681 *
682 * If the RXON structure is changing enough to require a new tune,
683 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
684 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
685 */
686int iwl_full_rxon_required(struct iwl_priv *priv)
687{
688
689 /* These items are only settable from the full RXON command */
690 if (!(iwl_is_associated(priv)) ||
691 compare_ether_addr(priv->staging_rxon.bssid_addr,
692 priv->active_rxon.bssid_addr) ||
693 compare_ether_addr(priv->staging_rxon.node_addr,
694 priv->active_rxon.node_addr) ||
695 compare_ether_addr(priv->staging_rxon.wlap_bssid_addr,
696 priv->active_rxon.wlap_bssid_addr) ||
697 (priv->staging_rxon.dev_type != priv->active_rxon.dev_type) ||
698 (priv->staging_rxon.channel != priv->active_rxon.channel) ||
699 (priv->staging_rxon.air_propagation !=
700 priv->active_rxon.air_propagation) ||
701 (priv->staging_rxon.ofdm_ht_single_stream_basic_rates !=
702 priv->active_rxon.ofdm_ht_single_stream_basic_rates) ||
703 (priv->staging_rxon.ofdm_ht_dual_stream_basic_rates !=
704 priv->active_rxon.ofdm_ht_dual_stream_basic_rates) ||
705 (priv->staging_rxon.assoc_id != priv->active_rxon.assoc_id))
706 return 1;
707
708 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can
709 * be updated with the RXON_ASSOC command -- however only some
710 * flag transitions are allowed using RXON_ASSOC */
711
712 /* Check if we are not switching bands */
713 if ((priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) !=
714 (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK))
715 return 1;
716
717 /* Check if we are switching association toggle */
718 if ((priv->staging_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) !=
719 (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK))
720 return 1;
721
722 return 0;
723}
724EXPORT_SYMBOL(iwl_full_rxon_required);
725
726u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv)
727{
728 int i;
729 int rate_mask;
730
731 /* Set rate mask*/
732 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
733 rate_mask = priv->active_rate_basic & IWL_CCK_RATES_MASK;
734 else
735 rate_mask = priv->active_rate_basic & IWL_OFDM_RATES_MASK;
736
737 /* Find lowest valid rate */
738 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID;
739 i = iwl_rates[i].next_ieee) {
740 if (rate_mask & (1 << i))
741 return iwl_rates[i].plcp;
742 }
743
744 /* No valid rate was found. Assign the lowest one */
745 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
746 return IWL_RATE_1M_PLCP;
747 else
748 return IWL_RATE_6M_PLCP;
749}
750EXPORT_SYMBOL(iwl_rate_get_lowest_plcp);
751
589void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info) 752void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
590{ 753{
591 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 754 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
@@ -627,7 +790,7 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
627 790
628 iwl_set_rxon_chain(priv); 791 iwl_set_rxon_chain(priv);
629 792
630 IWL_DEBUG_ASSOC("supported HT rate 0x%X 0x%X 0x%X " 793 IWL_DEBUG_ASSOC(priv, "supported HT rate 0x%X 0x%X 0x%X "
631 "rxon flags 0x%X operation mode :0x%X " 794 "rxon flags 0x%X operation mode :0x%X "
632 "extension channel offset 0x%x\n", 795 "extension channel offset 0x%x\n",
633 ht_info->mcs.rx_mask[0], 796 ht_info->mcs.rx_mask[0],
@@ -773,7 +936,7 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
773 else 936 else
774 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; 937 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK;
775 938
776 IWL_DEBUG_ASSOC("rx_chain=0x%X active=%d idle=%d\n", 939 IWL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n",
777 priv->staging_rxon.rx_chain, 940 priv->staging_rxon.rx_chain,
778 active_rx_cnt, idle_rx_cnt); 941 active_rx_cnt, idle_rx_cnt);
779 942
@@ -798,7 +961,7 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch)
798 u16 channel = ieee80211_frequency_to_channel(ch->center_freq); 961 u16 channel = ieee80211_frequency_to_channel(ch->center_freq);
799 962
800 if (!iwl_get_channel_info(priv, band, channel)) { 963 if (!iwl_get_channel_info(priv, band, channel)) {
801 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", 964 IWL_DEBUG_INFO(priv, "Could not set channel to %d [%d]\n",
802 channel, band); 965 channel, band);
803 return -EINVAL; 966 return -EINVAL;
804 } 967 }
@@ -815,12 +978,283 @@ int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch)
815 978
816 priv->band = band; 979 priv->band = band;
817 980
818 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band); 981 IWL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band);
819 982
820 return 0; 983 return 0;
821} 984}
822EXPORT_SYMBOL(iwl_set_rxon_channel); 985EXPORT_SYMBOL(iwl_set_rxon_channel);
823 986
987void iwl_set_flags_for_band(struct iwl_priv *priv,
988 enum ieee80211_band band)
989{
990 if (band == IEEE80211_BAND_5GHZ) {
991 priv->staging_rxon.flags &=
992 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK
993 | RXON_FLG_CCK_MSK);
994 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
995 } else {
996 /* Copied from iwl_post_associate() */
997 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
998 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
999 else
1000 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
1001
1002 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
1003 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
1004
1005 priv->staging_rxon.flags |= RXON_FLG_BAND_24G_MSK;
1006 priv->staging_rxon.flags |= RXON_FLG_AUTO_DETECT_MSK;
1007 priv->staging_rxon.flags &= ~RXON_FLG_CCK_MSK;
1008 }
1009}
1010EXPORT_SYMBOL(iwl_set_flags_for_band);
1011
1012/*
1013 * initialize rxon structure with default values from eeprom
1014 */
1015void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode)
1016{
1017 const struct iwl_channel_info *ch_info;
1018
1019 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
1020
1021 switch (mode) {
1022 case NL80211_IFTYPE_AP:
1023 priv->staging_rxon.dev_type = RXON_DEV_TYPE_AP;
1024 break;
1025
1026 case NL80211_IFTYPE_STATION:
1027 priv->staging_rxon.dev_type = RXON_DEV_TYPE_ESS;
1028 priv->staging_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
1029 break;
1030
1031 case NL80211_IFTYPE_ADHOC:
1032 priv->staging_rxon.dev_type = RXON_DEV_TYPE_IBSS;
1033 priv->staging_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
1034 priv->staging_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
1035 RXON_FILTER_ACCEPT_GRP_MSK;
1036 break;
1037
1038 case NL80211_IFTYPE_MONITOR:
1039 priv->staging_rxon.dev_type = RXON_DEV_TYPE_SNIFFER;
1040 priv->staging_rxon.filter_flags = RXON_FILTER_PROMISC_MSK |
1041 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
1042 break;
1043 default:
1044 IWL_ERR(priv, "Unsupported interface type %d\n", mode);
1045 break;
1046 }
1047
1048#if 0
1049 /* TODO: Figure out when short_preamble would be set and cache from
1050 * that */
1051 if (!hw_to_local(priv->hw)->short_preamble)
1052 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
1053 else
1054 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
1055#endif
1056
1057 ch_info = iwl_get_channel_info(priv, priv->band,
1058 le16_to_cpu(priv->active_rxon.channel));
1059
1060 if (!ch_info)
1061 ch_info = &priv->channel_info[0];
1062
1063 /*
1064 * in some case A channels are all non IBSS
1065 * in this case force B/G channel
1066 */
1067 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
1068 !(is_channel_ibss(ch_info)))
1069 ch_info = &priv->channel_info[0];
1070
1071 priv->staging_rxon.channel = cpu_to_le16(ch_info->channel);
1072 priv->band = ch_info->band;
1073
1074 iwl_set_flags_for_band(priv, priv->band);
1075
1076 priv->staging_rxon.ofdm_basic_rates =
1077 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1078 priv->staging_rxon.cck_basic_rates =
1079 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1080
1081 priv->staging_rxon.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK |
1082 RXON_FLG_CHANNEL_MODE_PURE_40_MSK);
1083 memcpy(priv->staging_rxon.node_addr, priv->mac_addr, ETH_ALEN);
1084 memcpy(priv->staging_rxon.wlap_bssid_addr, priv->mac_addr, ETH_ALEN);
1085 priv->staging_rxon.ofdm_ht_single_stream_basic_rates = 0xff;
1086 priv->staging_rxon.ofdm_ht_dual_stream_basic_rates = 0xff;
1087}
1088EXPORT_SYMBOL(iwl_connection_init_rx_config);
1089
1090void iwl_set_rate(struct iwl_priv *priv)
1091{
1092 const struct ieee80211_supported_band *hw = NULL;
1093 struct ieee80211_rate *rate;
1094 int i;
1095
1096 hw = iwl_get_hw_mode(priv, priv->band);
1097 if (!hw) {
1098 IWL_ERR(priv, "Failed to set rate: unable to get hw mode\n");
1099 return;
1100 }
1101
1102 priv->active_rate = 0;
1103 priv->active_rate_basic = 0;
1104
1105 for (i = 0; i < hw->n_bitrates; i++) {
1106 rate = &(hw->bitrates[i]);
1107 if (rate->hw_value < IWL_RATE_COUNT)
1108 priv->active_rate |= (1 << rate->hw_value);
1109 }
1110
1111 IWL_DEBUG_RATE(priv, "Set active_rate = %0x, active_rate_basic = %0x\n",
1112 priv->active_rate, priv->active_rate_basic);
1113
1114 /*
1115 * If a basic rate is configured, then use it (adding IWL_RATE_1M_MASK)
1116 * otherwise set it to the default of all CCK rates and 6, 12, 24 for
1117 * OFDM
1118 */
1119 if (priv->active_rate_basic & IWL_CCK_BASIC_RATES_MASK)
1120 priv->staging_rxon.cck_basic_rates =
1121 ((priv->active_rate_basic &
1122 IWL_CCK_RATES_MASK) >> IWL_FIRST_CCK_RATE) & 0xF;
1123 else
1124 priv->staging_rxon.cck_basic_rates =
1125 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1126
1127 if (priv->active_rate_basic & IWL_OFDM_BASIC_RATES_MASK)
1128 priv->staging_rxon.ofdm_basic_rates =
1129 ((priv->active_rate_basic &
1130 (IWL_OFDM_BASIC_RATES_MASK | IWL_RATE_6M_MASK)) >>
1131 IWL_FIRST_OFDM_RATE) & 0xFF;
1132 else
1133 priv->staging_rxon.ofdm_basic_rates =
1134 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1135}
1136EXPORT_SYMBOL(iwl_set_rate);
1137
1138void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1139{
1140 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
1141 struct iwl_rxon_cmd *rxon = (void *)&priv->active_rxon;
1142 struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
1143 IWL_DEBUG_11H(priv, "CSA notif: channel %d, status %d\n",
1144 le16_to_cpu(csa->channel), le32_to_cpu(csa->status));
1145 rxon->channel = csa->channel;
1146 priv->staging_rxon.channel = csa->channel;
1147}
1148EXPORT_SYMBOL(iwl_rx_csa);
1149
1150#ifdef CONFIG_IWLWIFI_DEBUG
1151static void iwl_print_rx_config_cmd(struct iwl_priv *priv)
1152{
1153 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
1154
1155 IWL_DEBUG_RADIO(priv, "RX CONFIG:\n");
1156 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
1157 IWL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", le16_to_cpu(rxon->channel));
1158 IWL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags));
1159 IWL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n",
1160 le32_to_cpu(rxon->filter_flags));
1161 IWL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type);
1162 IWL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n",
1163 rxon->ofdm_basic_rates);
1164 IWL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates);
1165 IWL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr);
1166 IWL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr);
1167 IWL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id));
1168}
1169#endif
1170
1171/**
1172 * iwl_irq_handle_error - called for HW or SW error interrupt from card
1173 */
1174void iwl_irq_handle_error(struct iwl_priv *priv)
1175{
1176 /* Set the FW error flag -- cleared on iwl_down */
1177 set_bit(STATUS_FW_ERROR, &priv->status);
1178
1179 /* Cancel currently queued command. */
1180 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
1181
1182#ifdef CONFIG_IWLWIFI_DEBUG
1183 if (priv->debug_level & IWL_DL_FW_ERRORS) {
1184 iwl_dump_nic_error_log(priv);
1185 iwl_dump_nic_event_log(priv);
1186 iwl_print_rx_config_cmd(priv);
1187 }
1188#endif
1189
1190 wake_up_interruptible(&priv->wait_command_queue);
1191
1192 /* Keep the restart process from trying to send host
1193 * commands by clearing the INIT status bit */
1194 clear_bit(STATUS_READY, &priv->status);
1195
1196 if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) {
1197 IWL_DEBUG(priv, IWL_DL_FW_ERRORS,
1198 "Restarting adapter due to uCode error.\n");
1199
1200 if (iwl_is_associated(priv)) {
1201 memcpy(&priv->recovery_rxon, &priv->active_rxon,
1202 sizeof(priv->recovery_rxon));
1203 priv->error_recovering = 1;
1204 }
1205 if (priv->cfg->mod_params->restart_fw)
1206 queue_work(priv->workqueue, &priv->restart);
1207 }
1208}
1209EXPORT_SYMBOL(iwl_irq_handle_error);
1210
1211void iwl_configure_filter(struct ieee80211_hw *hw,
1212 unsigned int changed_flags,
1213 unsigned int *total_flags,
1214 int mc_count, struct dev_addr_list *mc_list)
1215{
1216 struct iwl_priv *priv = hw->priv;
1217 __le32 *filter_flags = &priv->staging_rxon.filter_flags;
1218
1219 IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n",
1220 changed_flags, *total_flags);
1221
1222 if (changed_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) {
1223 if (*total_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS))
1224 *filter_flags |= RXON_FILTER_PROMISC_MSK;
1225 else
1226 *filter_flags &= ~RXON_FILTER_PROMISC_MSK;
1227 }
1228 if (changed_flags & FIF_ALLMULTI) {
1229 if (*total_flags & FIF_ALLMULTI)
1230 *filter_flags |= RXON_FILTER_ACCEPT_GRP_MSK;
1231 else
1232 *filter_flags &= ~RXON_FILTER_ACCEPT_GRP_MSK;
1233 }
1234 if (changed_flags & FIF_CONTROL) {
1235 if (*total_flags & FIF_CONTROL)
1236 *filter_flags |= RXON_FILTER_CTL2HOST_MSK;
1237 else
1238 *filter_flags &= ~RXON_FILTER_CTL2HOST_MSK;
1239 }
1240 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
1241 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
1242 *filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
1243 else
1244 *filter_flags &= ~RXON_FILTER_BCON_AWARE_MSK;
1245 }
1246
1247 /* We avoid iwl_commit_rxon here to commit the new filter flags
1248 * since mac80211 will call ieee80211_hw_config immediately.
1249 * (mc_list is not supported at this time). Otherwise, we need to
1250 * queue a background iwl_commit_rxon work.
1251 */
1252
1253 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
1254 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
1255}
1256EXPORT_SYMBOL(iwl_configure_filter);
1257
824int iwl_setup_mac(struct iwl_priv *priv) 1258int iwl_setup_mac(struct iwl_priv *priv)
825{ 1259{
826 int ret; 1260 int ret;
@@ -921,8 +1355,8 @@ int iwl_init_drv(struct iwl_priv *priv)
921 priv->qos_data.qos_cap.val = 0; 1355 priv->qos_data.qos_cap.val = 0;
922 1356
923 priv->rates_mask = IWL_RATES_MASK; 1357 priv->rates_mask = IWL_RATES_MASK;
924 /* If power management is turned on, default to AC mode */ 1358 /* If power management is turned on, default to CAM mode */
925 priv->power_mode = IWL_POWER_AC; 1359 priv->power_mode = IWL_POWER_MODE_CAM;
926 priv->tx_power_user_lmt = IWL_TX_POWER_TARGET_POWER_MAX; 1360 priv->tx_power_user_lmt = IWL_TX_POWER_TARGET_POWER_MAX;
927 1361
928 ret = iwl_init_channel_map(priv); 1362 ret = iwl_init_channel_map(priv);
@@ -995,13 +1429,13 @@ void iwl_disable_interrupts(struct iwl_priv *priv)
995 * from uCode or flow handler (Rx/Tx DMA) */ 1429 * from uCode or flow handler (Rx/Tx DMA) */
996 iwl_write32(priv, CSR_INT, 0xffffffff); 1430 iwl_write32(priv, CSR_INT, 0xffffffff);
997 iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); 1431 iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff);
998 IWL_DEBUG_ISR("Disabled interrupts\n"); 1432 IWL_DEBUG_ISR(priv, "Disabled interrupts\n");
999} 1433}
1000EXPORT_SYMBOL(iwl_disable_interrupts); 1434EXPORT_SYMBOL(iwl_disable_interrupts);
1001 1435
1002void iwl_enable_interrupts(struct iwl_priv *priv) 1436void iwl_enable_interrupts(struct iwl_priv *priv)
1003{ 1437{
1004 IWL_DEBUG_ISR("Enabling interrupts\n"); 1438 IWL_DEBUG_ISR(priv, "Enabling interrupts\n");
1005 set_bit(STATUS_INT_ENABLED, &priv->status); 1439 set_bit(STATUS_INT_ENABLED, &priv->status);
1006 iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK); 1440 iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
1007} 1441}
@@ -1047,7 +1481,7 @@ static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
1047 u32 errcnt = 0; 1481 u32 errcnt = 0;
1048 u32 i; 1482 u32 i;
1049 1483
1050 IWL_DEBUG_INFO("ucode inst image size is %u\n", len); 1484 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
1051 1485
1052 ret = iwl_grab_nic_access(priv); 1486 ret = iwl_grab_nic_access(priv);
1053 if (ret) 1487 if (ret)
@@ -1085,7 +1519,7 @@ static int iwl_verify_inst_full(struct iwl_priv *priv, __le32 *image,
1085 int ret = 0; 1519 int ret = 0;
1086 u32 errcnt; 1520 u32 errcnt;
1087 1521
1088 IWL_DEBUG_INFO("ucode inst image size is %u\n", len); 1522 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
1089 1523
1090 ret = iwl_grab_nic_access(priv); 1524 ret = iwl_grab_nic_access(priv);
1091 if (ret) 1525 if (ret)
@@ -1114,8 +1548,8 @@ static int iwl_verify_inst_full(struct iwl_priv *priv, __le32 *image,
1114 iwl_release_nic_access(priv); 1548 iwl_release_nic_access(priv);
1115 1549
1116 if (!errcnt) 1550 if (!errcnt)
1117 IWL_DEBUG_INFO 1551 IWL_DEBUG_INFO(priv,
1118 ("ucode image in INSTRUCTION memory is good\n"); 1552 "ucode image in INSTRUCTION memory is good\n");
1119 1553
1120 return ret; 1554 return ret;
1121} 1555}
@@ -1135,7 +1569,7 @@ int iwl_verify_ucode(struct iwl_priv *priv)
1135 len = priv->ucode_boot.len; 1569 len = priv->ucode_boot.len;
1136 ret = iwlcore_verify_inst_sparse(priv, image, len); 1570 ret = iwlcore_verify_inst_sparse(priv, image, len);
1137 if (!ret) { 1571 if (!ret) {
1138 IWL_DEBUG_INFO("Bootstrap uCode is good in inst SRAM\n"); 1572 IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n");
1139 return 0; 1573 return 0;
1140 } 1574 }
1141 1575
@@ -1144,7 +1578,7 @@ int iwl_verify_ucode(struct iwl_priv *priv)
1144 len = priv->ucode_init.len; 1578 len = priv->ucode_init.len;
1145 ret = iwlcore_verify_inst_sparse(priv, image, len); 1579 ret = iwlcore_verify_inst_sparse(priv, image, len);
1146 if (!ret) { 1580 if (!ret) {
1147 IWL_DEBUG_INFO("Initialize uCode is good in inst SRAM\n"); 1581 IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n");
1148 return 0; 1582 return 0;
1149 } 1583 }
1150 1584
@@ -1153,7 +1587,7 @@ int iwl_verify_ucode(struct iwl_priv *priv)
1153 len = priv->ucode_code.len; 1587 len = priv->ucode_code.len;
1154 ret = iwlcore_verify_inst_sparse(priv, image, len); 1588 ret = iwlcore_verify_inst_sparse(priv, image, len);
1155 if (!ret) { 1589 if (!ret) {
1156 IWL_DEBUG_INFO("Runtime uCode is good in inst SRAM\n"); 1590 IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n");
1157 return 0; 1591 return 0;
1158 } 1592 }
1159 1593
@@ -1393,7 +1827,7 @@ void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1393 if (ret) 1827 if (ret)
1394 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); 1828 IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n");
1395 else 1829 else
1396 IWL_DEBUG_INFO("REPLY_CT_KILL_CONFIG_CMD succeeded, " 1830 IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD succeeded, "
1397 "critical temperature is %d\n", 1831 "critical temperature is %d\n",
1398 cmd.critical_temperature_R); 1832 cmd.critical_temperature_R);
1399} 1833}
@@ -1430,7 +1864,7 @@ void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv)
1430 if (test_bit(STATUS_RF_KILL_SW, &priv->status)) 1864 if (test_bit(STATUS_RF_KILL_SW, &priv->status))
1431 return; 1865 return;
1432 1866
1433 IWL_DEBUG_RF_KILL("Manual SW RF KILL set to: RADIO OFF\n"); 1867 IWL_DEBUG_RF_KILL(priv, "Manual SW RF KILL set to: RADIO OFF\n");
1434 1868
1435 iwl_scan_cancel(priv); 1869 iwl_scan_cancel(priv);
1436 /* FIXME: This is a workaround for AP */ 1870 /* FIXME: This is a workaround for AP */
@@ -1459,7 +1893,7 @@ int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv)
1459 if (!test_bit(STATUS_RF_KILL_SW, &priv->status)) 1893 if (!test_bit(STATUS_RF_KILL_SW, &priv->status))
1460 return 0; 1894 return 0;
1461 1895
1462 IWL_DEBUG_RF_KILL("Manual SW RF KILL set to: RADIO ON\n"); 1896 IWL_DEBUG_RF_KILL(priv, "Manual SW RF KILL set to: RADIO ON\n");
1463 1897
1464 spin_lock_irqsave(&priv->lock, flags); 1898 spin_lock_irqsave(&priv->lock, flags);
1465 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); 1899 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
@@ -1484,7 +1918,7 @@ int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv)
1484 spin_unlock_irqrestore(&priv->lock, flags); 1918 spin_unlock_irqrestore(&priv->lock, flags);
1485 1919
1486 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { 1920 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
1487 IWL_DEBUG_RF_KILL("Can not turn radio back on - " 1921 IWL_DEBUG_RF_KILL(priv, "Can not turn radio back on - "
1488 "disabled by HW switch\n"); 1922 "disabled by HW switch\n");
1489 return 0; 1923 return 0;
1490 } 1924 }
@@ -1519,7 +1953,7 @@ void iwl_bg_rf_kill(struct work_struct *work)
1519 mutex_lock(&priv->mutex); 1953 mutex_lock(&priv->mutex);
1520 1954
1521 if (!iwl_is_rfkill(priv)) { 1955 if (!iwl_is_rfkill(priv)) {
1522 IWL_DEBUG(IWL_DL_RF_KILL, 1956 IWL_DEBUG_RF_KILL(priv,
1523 "HW and/or SW RF Kill no longer active, restarting " 1957 "HW and/or SW RF Kill no longer active, restarting "
1524 "device\n"); 1958 "device\n");
1525 if (!test_bit(STATUS_EXIT_PENDING, &priv->status) && 1959 if (!test_bit(STATUS_EXIT_PENDING, &priv->status) &&
@@ -1531,7 +1965,7 @@ void iwl_bg_rf_kill(struct work_struct *work)
1531 ieee80211_stop_queues(priv->hw); 1965 ieee80211_stop_queues(priv->hw);
1532 1966
1533 if (!test_bit(STATUS_RF_KILL_HW, &priv->status)) 1967 if (!test_bit(STATUS_RF_KILL_HW, &priv->status))
1534 IWL_DEBUG_RF_KILL("Can not turn radio back on - " 1968 IWL_DEBUG_RF_KILL(priv, "Can not turn radio back on - "
1535 "disabled by SW switch\n"); 1969 "disabled by SW switch\n");
1536 else 1970 else
1537 IWL_WARN(priv, "Radio Frequency Kill Switch is On:\n" 1971 IWL_WARN(priv, "Radio Frequency Kill Switch is On:\n"
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 3c6a4b0c2c3b..d79912ba6a2f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -211,6 +211,9 @@ struct iwl_cfg {
211 u16 eeprom_calib_ver; 211 u16 eeprom_calib_ver;
212 const struct iwl_ops *ops; 212 const struct iwl_ops *ops;
213 const struct iwl_mod_params *mod_params; 213 const struct iwl_mod_params *mod_params;
214 u8 valid_tx_ant;
215 u8 valid_rx_ant;
216 bool need_pll_cfg;
214}; 217};
215 218
216/*************************** 219/***************************
@@ -221,11 +224,25 @@ struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
221 struct ieee80211_ops *hw_ops); 224 struct ieee80211_ops *hw_ops);
222void iwl_hw_detect(struct iwl_priv *priv); 225void iwl_hw_detect(struct iwl_priv *priv);
223void iwl_reset_qos(struct iwl_priv *priv); 226void iwl_reset_qos(struct iwl_priv *priv);
227void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt);
228int iwl_check_rxon_cmd(struct iwl_priv *priv);
229int iwl_full_rxon_required(struct iwl_priv *priv);
224void iwl_set_rxon_chain(struct iwl_priv *priv); 230void iwl_set_rxon_chain(struct iwl_priv *priv);
225int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch); 231int iwl_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch);
226void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info); 232void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info);
227u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv, 233u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv,
228 struct ieee80211_sta_ht_cap *sta_ht_inf); 234 struct ieee80211_sta_ht_cap *sta_ht_inf);
235void iwl_set_flags_for_band(struct iwl_priv *priv, enum ieee80211_band band);
236void iwl_connection_init_rx_config(struct iwl_priv *priv, int mode);
237int iwl_set_decrypted_flag(struct iwl_priv *priv,
238 struct ieee80211_hdr *hdr,
239 u32 decrypt_res,
240 struct ieee80211_rx_status *stats);
241void iwl_irq_handle_error(struct iwl_priv *priv);
242void iwl_configure_filter(struct ieee80211_hw *hw,
243 unsigned int changed_flags,
244 unsigned int *total_flags,
245 int mc_count, struct dev_addr_list *mc_list);
229int iwl_hw_nic_init(struct iwl_priv *priv); 246int iwl_hw_nic_init(struct iwl_priv *priv);
230int iwl_setup_mac(struct iwl_priv *priv); 247int iwl_setup_mac(struct iwl_priv *priv);
231int iwl_set_hw_params(struct iwl_priv *priv); 248int iwl_set_hw_params(struct iwl_priv *priv);
@@ -253,6 +270,7 @@ void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
253 struct iwl_rx_mem_buffer *rxb); 270 struct iwl_rx_mem_buffer *rxb);
254void iwl_rx_statistics(struct iwl_priv *priv, 271void iwl_rx_statistics(struct iwl_priv *priv,
255 struct iwl_rx_mem_buffer *rxb); 272 struct iwl_rx_mem_buffer *rxb);
273void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
256 274
257/* TX helpers */ 275/* TX helpers */
258 276
@@ -296,6 +314,10 @@ void iwl_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
296 struct ieee80211_tx_info *info); 314 struct ieee80211_tx_info *info);
297int iwl_hwrate_to_plcp_idx(u32 rate_n_flags); 315int iwl_hwrate_to_plcp_idx(u32 rate_n_flags);
298 316
317u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv);
318
319void iwl_set_rate(struct iwl_priv *priv);
320
299u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx); 321u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx);
300 322
301static inline u32 iwl_ant_idx_to_flags(u8 ant_idx) 323static inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
@@ -343,8 +365,8 @@ int iwl_send_scan_abort(struct iwl_priv *priv);
343 * time if it's a quiet channel (nothing responded to our probe, and there's 365 * time if it's a quiet channel (nothing responded to our probe, and there's
344 * no other traffic). 366 * no other traffic).
345 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ 367 * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
346#define IWL_ACTIVE_QUIET_TIME __constant_cpu_to_le16(10) /* msec */ 368#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */
347#define IWL_PLCP_QUIET_THRESH __constant_cpu_to_le16(1) /* packets */ 369#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */
348 370
349 371
350/******************************************************************************* 372/*******************************************************************************
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 74d3d43fa67d..5028c781275b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -211,6 +211,9 @@
211#define CSR_HW_REV_TYPE_5350 (0x0000030) 211#define CSR_HW_REV_TYPE_5350 (0x0000030)
212#define CSR_HW_REV_TYPE_5100 (0x0000050) 212#define CSR_HW_REV_TYPE_5100 (0x0000050)
213#define CSR_HW_REV_TYPE_5150 (0x0000040) 213#define CSR_HW_REV_TYPE_5150 (0x0000040)
214#define CSR_HW_REV_TYPE_100 (0x0000060)
215#define CSR_HW_REV_TYPE_6x00 (0x0000070)
216#define CSR_HW_REV_TYPE_6x50 (0x0000080)
214#define CSR_HW_REV_TYPE_NONE (0x00000F0) 217#define CSR_HW_REV_TYPE_NONE (0x00000F0)
215 218
216/* EEPROM REG */ 219/* EEPROM REG */
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index 7192d3249caf..65d1a7f2db9e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -37,18 +37,20 @@ struct iwl_priv;
37#define IWL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) 37#define IWL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a)
38 38
39#ifdef CONFIG_IWLWIFI_DEBUG 39#ifdef CONFIG_IWLWIFI_DEBUG
40#define IWL_DEBUG(level, fmt, args...) \ 40#define IWL_DEBUG(__priv, level, fmt, args...) \
41do { \ 41do { \
42 if (priv->debug_level & (level)) \ 42 if (__priv->debug_level & (level)) \
43 dev_printk(KERN_ERR, &(priv->hw->wiphy->dev), "%c %s " fmt, \ 43 dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \
44 in_interrupt() ? 'I' : 'U', __func__ , ## args); \ 44 "%c %s " fmt, in_interrupt() ? 'I' : 'U', \
45 __func__ , ## args); \
45} while (0) 46} while (0)
46 47
47#define IWL_DEBUG_LIMIT(level, fmt, args...) \ 48#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...) \
48do { \ 49do { \
49 if ((priv->debug_level & (level)) && net_ratelimit()) \ 50 if ((__priv->debug_level & (level)) && net_ratelimit()) \
50 dev_printk(KERN_ERR, &(priv->hw->wiphy->dev), "%c %s " fmt, \ 51 dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \
51 in_interrupt() ? 'I' : 'U', __func__ , ## args); \ 52 "%c %s " fmt, in_interrupt() ? 'I' : 'U', \
53 __func__ , ## args); \
52} while (0) 54} while (0)
53 55
54#define iwl_print_hex_dump(priv, level, p, len) \ 56#define iwl_print_hex_dump(priv, level, p, len) \
@@ -88,8 +90,8 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv);
88#endif 90#endif
89 91
90#else 92#else
91#define IWL_DEBUG(level, fmt, args...) 93#define IWL_DEBUG(__priv, level, fmt, args...)
92#define IWL_DEBUG_LIMIT(level, fmt, args...) 94#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...)
93static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level, 95static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
94 void *p, u32 len) 96 void *p, u32 len)
95{} 97{}
@@ -169,42 +171,45 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv)
169#define IWL_DL_TX_REPLY (1 << 30) 171#define IWL_DL_TX_REPLY (1 << 30)
170#define IWL_DL_QOS (1 << 31) 172#define IWL_DL_QOS (1 << 31)
171 173
172#define IWL_DEBUG_INFO(f, a...) IWL_DEBUG(IWL_DL_INFO, f, ## a) 174#define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a)
173#define IWL_DEBUG_MAC80211(f, a...) IWL_DEBUG(IWL_DL_MAC80211, f, ## a) 175#define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a)
174#define IWL_DEBUG_MACDUMP(f, a...) IWL_DEBUG(IWL_DL_MACDUMP, f, ## a) 176#define IWL_DEBUG_MACDUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_MACDUMP, f, ## a)
175#define IWL_DEBUG_TEMP(f, a...) IWL_DEBUG(IWL_DL_TEMP, f, ## a) 177#define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a)
176#define IWL_DEBUG_SCAN(f, a...) IWL_DEBUG(IWL_DL_SCAN, f, ## a) 178#define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a)
177#define IWL_DEBUG_RX(f, a...) IWL_DEBUG(IWL_DL_RX, f, ## a) 179#define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a)
178#define IWL_DEBUG_TX(f, a...) IWL_DEBUG(IWL_DL_TX, f, ## a) 180#define IWL_DEBUG_TX(p, f, a...) IWL_DEBUG(p, IWL_DL_TX, f, ## a)
179#define IWL_DEBUG_ISR(f, a...) IWL_DEBUG(IWL_DL_ISR, f, ## a) 181#define IWL_DEBUG_ISR(p, f, a...) IWL_DEBUG(p, IWL_DL_ISR, f, ## a)
180#define IWL_DEBUG_LED(f, a...) IWL_DEBUG(IWL_DL_LED, f, ## a) 182#define IWL_DEBUG_LED(p, f, a...) IWL_DEBUG(p, IWL_DL_LED, f, ## a)
181#define IWL_DEBUG_WEP(f, a...) IWL_DEBUG(IWL_DL_WEP, f, ## a) 183#define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a)
182#define IWL_DEBUG_HC(f, a...) IWL_DEBUG(IWL_DL_HCMD, f, ## a) 184#define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a)
183#define IWL_DEBUG_HC_DUMP(f, a...) IWL_DEBUG(IWL_DL_HCMD_DUMP, f, ## a) 185#define IWL_DEBUG_HC_DUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD_DUMP, f, ## a)
184#define IWL_DEBUG_CALIB(f, a...) IWL_DEBUG(IWL_DL_CALIB, f, ## a) 186#define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a)
185#define IWL_DEBUG_FW(f, a...) IWL_DEBUG(IWL_DL_FW, f, ## a) 187#define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a)
186#define IWL_DEBUG_RF_KILL(f, a...) IWL_DEBUG(IWL_DL_RF_KILL, f, ## a) 188#define IWL_DEBUG_RF_KILL(p, f, a...) IWL_DEBUG(p, IWL_DL_RF_KILL, f, ## a)
187#define IWL_DEBUG_DROP(f, a...) IWL_DEBUG(IWL_DL_DROP, f, ## a) 189#define IWL_DEBUG_DROP(p, f, a...) IWL_DEBUG(p, IWL_DL_DROP, f, ## a)
188#define IWL_DEBUG_DROP_LIMIT(f, a...) IWL_DEBUG_LIMIT(IWL_DL_DROP, f, ## a) 190#define IWL_DEBUG_DROP_LIMIT(p, f, a...) \
189#define IWL_DEBUG_AP(f, a...) IWL_DEBUG(IWL_DL_AP, f, ## a) 191 IWL_DEBUG_LIMIT(p, IWL_DL_DROP, f, ## a)
190#define IWL_DEBUG_TXPOWER(f, a...) IWL_DEBUG(IWL_DL_TXPOWER, f, ## a) 192#define IWL_DEBUG_AP(p, f, a...) IWL_DEBUG(p, IWL_DL_AP, f, ## a)
191#define IWL_DEBUG_IO(f, a...) IWL_DEBUG(IWL_DL_IO, f, ## a) 193#define IWL_DEBUG_TXPOWER(p, f, a...) IWL_DEBUG(p, IWL_DL_TXPOWER, f, ## a)
192#define IWL_DEBUG_RATE(f, a...) IWL_DEBUG(IWL_DL_RATE, f, ## a) 194#define IWL_DEBUG_IO(p, f, a...) IWL_DEBUG(p, IWL_DL_IO, f, ## a)
193#define IWL_DEBUG_RATE_LIMIT(f, a...) IWL_DEBUG_LIMIT(IWL_DL_RATE, f, ## a) 195#define IWL_DEBUG_RATE(p, f, a...) IWL_DEBUG(p, IWL_DL_RATE, f, ## a)
194#define IWL_DEBUG_NOTIF(f, a...) IWL_DEBUG(IWL_DL_NOTIF, f, ## a) 196#define IWL_DEBUG_RATE_LIMIT(p, f, a...) \
195#define IWL_DEBUG_ASSOC(f, a...) \ 197 IWL_DEBUG_LIMIT(p, IWL_DL_RATE, f, ## a)
196 IWL_DEBUG(IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) 198#define IWL_DEBUG_NOTIF(p, f, a...) IWL_DEBUG(p, IWL_DL_NOTIF, f, ## a)
197#define IWL_DEBUG_ASSOC_LIMIT(f, a...) \ 199#define IWL_DEBUG_ASSOC(p, f, a...) \
198 IWL_DEBUG_LIMIT(IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) 200 IWL_DEBUG(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
199#define IWL_DEBUG_HT(f, a...) IWL_DEBUG(IWL_DL_HT, f, ## a) 201#define IWL_DEBUG_ASSOC_LIMIT(p, f, a...) \
200#define IWL_DEBUG_STATS(f, a...) IWL_DEBUG(IWL_DL_STATS, f, ## a) 202 IWL_DEBUG_LIMIT(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a)
201#define IWL_DEBUG_STATS_LIMIT(f, a...) IWL_DEBUG_LIMIT(IWL_DL_STATS, f, ## a) 203#define IWL_DEBUG_HT(p, f, a...) IWL_DEBUG(p, IWL_DL_HT, f, ## a)
202#define IWL_DEBUG_TX_REPLY(f, a...) IWL_DEBUG(IWL_DL_TX_REPLY, f, ## a) 204#define IWL_DEBUG_STATS(p, f, a...) IWL_DEBUG(p, IWL_DL_STATS, f, ## a)
203#define IWL_DEBUG_TX_REPLY_LIMIT(f, a...) \ 205#define IWL_DEBUG_STATS_LIMIT(p, f, a...) \
204 IWL_DEBUG_LIMIT(IWL_DL_TX_REPLY, f, ## a) 206 IWL_DEBUG_LIMIT(p, IWL_DL_STATS, f, ## a)
205#define IWL_DEBUG_QOS(f, a...) IWL_DEBUG(IWL_DL_QOS, f, ## a) 207#define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a)
206#define IWL_DEBUG_RADIO(f, a...) IWL_DEBUG(IWL_DL_RADIO, f, ## a) 208#define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \
207#define IWL_DEBUG_POWER(f, a...) IWL_DEBUG(IWL_DL_POWER, f, ## a) 209 IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a)
208#define IWL_DEBUG_11H(f, a...) IWL_DEBUG(IWL_DL_11H, f, ## a) 210#define IWL_DEBUG_QOS(p, f, a...) IWL_DEBUG(p, IWL_DL_QOS, f, ## a)
211#define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a)
212#define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a)
213#define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a)
209 214
210#endif 215#endif
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 437c05b9a335..afde713c806f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -67,6 +67,18 @@ extern struct iwl_cfg iwl100_bgn_cfg;
67/* shared structures from iwl-5000.c */ 67/* shared structures from iwl-5000.c */
68extern struct iwl_mod_params iwl50_mod_params; 68extern struct iwl_mod_params iwl50_mod_params;
69extern struct iwl_ops iwl5000_ops; 69extern struct iwl_ops iwl5000_ops;
70extern struct iwl_lib_ops iwl5000_lib;
71extern struct iwl_hcmd_ops iwl5000_hcmd;
72extern struct iwl_hcmd_utils_ops iwl5000_hcmd_utils;
73
74/* shared functions from iwl-5000.c */
75extern u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len);
76extern u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd,
77 u8 *data);
78extern void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
79 __le32 *tx_flags);
80extern int iwl5000_calc_rssi(struct iwl_priv *priv,
81 struct iwl_rx_phy_res *rx_resp);
70 82
71/* CT-KILL constants */ 83/* CT-KILL constants */
72#define CT_KILL_THRESHOLD 110 /* in Celsius */ 84#define CT_KILL_THRESHOLD 110 /* in Celsius */
@@ -1078,13 +1090,6 @@ struct iwl_priv {
1078 1090
1079 /*For 3945*/ 1091 /*For 3945*/
1080#define IWL_DEFAULT_TX_POWER 0x0F 1092#define IWL_DEFAULT_TX_POWER 0x0F
1081 /* We declare this const so it can only be
1082 * changed via explicit cast within the
1083 * routines that actually update the physical
1084 * hardware */
1085 const struct iwl3945_rxon_cmd active39_rxon;
1086 struct iwl3945_rxon_cmd staging39_rxon;
1087 struct iwl3945_rxon_cmd recovery39_rxon;
1088 1093
1089 struct iwl3945_notif_statistics statistics_39; 1094 struct iwl3945_notif_statistics statistics_39;
1090 1095
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index eaa658f9e54c..d1d1d9bcfeae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -173,7 +173,7 @@ int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv)
173 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, 173 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
174 EEPROM_SEM_TIMEOUT); 174 EEPROM_SEM_TIMEOUT);
175 if (ret >= 0) { 175 if (ret >= 0) {
176 IWL_DEBUG_IO("Acquired semaphore after %d tries.\n", 176 IWL_DEBUG_IO(priv, "Acquired semaphore after %d tries.\n",
177 count+1); 177 count+1);
178 return ret; 178 return ret;
179 } 179 }
@@ -390,7 +390,7 @@ static int iwl_set_fat_chan_info(struct iwl_priv *priv,
390 if (!is_channel_valid(ch_info)) 390 if (!is_channel_valid(ch_info))
391 return -1; 391 return -1;
392 392
393 IWL_DEBUG_INFO("FAT Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" 393 IWL_DEBUG_INFO(priv, "FAT Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):"
394 " Ad-Hoc %ssupported\n", 394 " Ad-Hoc %ssupported\n",
395 ch_info->channel, 395 ch_info->channel,
396 is_channel_a_band(ch_info) ? 396 is_channel_a_band(ch_info) ?
@@ -432,11 +432,11 @@ int iwl_init_channel_map(struct iwl_priv *priv)
432 struct iwl_channel_info *ch_info; 432 struct iwl_channel_info *ch_info;
433 433
434 if (priv->channel_count) { 434 if (priv->channel_count) {
435 IWL_DEBUG_INFO("Channel map already initialized.\n"); 435 IWL_DEBUG_INFO(priv, "Channel map already initialized.\n");
436 return 0; 436 return 0;
437 } 437 }
438 438
439 IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n"); 439 IWL_DEBUG_INFO(priv, "Initializing regulatory info from EEPROM\n");
440 440
441 priv->channel_count = 441 priv->channel_count =
442 ARRAY_SIZE(iwl_eeprom_band_1) + 442 ARRAY_SIZE(iwl_eeprom_band_1) +
@@ -445,7 +445,7 @@ int iwl_init_channel_map(struct iwl_priv *priv)
445 ARRAY_SIZE(iwl_eeprom_band_4) + 445 ARRAY_SIZE(iwl_eeprom_band_4) +
446 ARRAY_SIZE(iwl_eeprom_band_5); 446 ARRAY_SIZE(iwl_eeprom_band_5);
447 447
448 IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count); 448 IWL_DEBUG_INFO(priv, "Parsing data for %d channels.\n", priv->channel_count);
449 449
450 priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) * 450 priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) *
451 priv->channel_count, GFP_KERNEL); 451 priv->channel_count, GFP_KERNEL);
@@ -485,7 +485,7 @@ int iwl_init_channel_map(struct iwl_priv *priv)
485 IEEE80211_CHAN_NO_FAT_BELOW); 485 IEEE80211_CHAN_NO_FAT_BELOW);
486 486
487 if (!(is_channel_valid(ch_info))) { 487 if (!(is_channel_valid(ch_info))) {
488 IWL_DEBUG_INFO("Ch. %d Flags %x [%sGHz] - " 488 IWL_DEBUG_INFO(priv, "Ch. %d Flags %x [%sGHz] - "
489 "No traffic\n", 489 "No traffic\n",
490 ch_info->channel, 490 ch_info->channel,
491 ch_info->flags, 491 ch_info->flags,
@@ -501,7 +501,7 @@ int iwl_init_channel_map(struct iwl_priv *priv)
501 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; 501 ch_info->scan_power = eeprom_ch_info[ch].max_power_avg;
502 ch_info->min_power = 0; 502 ch_info->min_power = 0;
503 503
504 IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm):" 504 IWL_DEBUG_INFO(priv, "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm):"
505 " Ad-Hoc %ssupported\n", 505 " Ad-Hoc %ssupported\n",
506 ch_info->channel, 506 ch_info->channel,
507 is_channel_a_band(ch_info) ? 507 is_channel_a_band(ch_info) ?
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index 65ae2af61c8d..17d61ac8ed61 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -125,11 +125,11 @@ static int iwl_generic_cmd_callback(struct iwl_priv *priv,
125 switch (cmd->hdr.cmd) { 125 switch (cmd->hdr.cmd) {
126 case REPLY_TX_LINK_QUALITY_CMD: 126 case REPLY_TX_LINK_QUALITY_CMD:
127 case SENSITIVITY_CMD: 127 case SENSITIVITY_CMD:
128 IWL_DEBUG_HC_DUMP("back from %s (0x%08X)\n", 128 IWL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n",
129 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); 129 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
130 break; 130 break;
131 default: 131 default:
132 IWL_DEBUG_HC("back from %s (0x%08X)\n", 132 IWL_DEBUG_HC(priv, "back from %s (0x%08X)\n",
133 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); 133 get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags);
134 } 134 }
135#endif 135#endif
@@ -211,13 +211,13 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
211 } 211 }
212 212
213 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { 213 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
214 IWL_DEBUG_INFO("Command %s aborted: RF KILL Switch\n", 214 IWL_DEBUG_INFO(priv, "Command %s aborted: RF KILL Switch\n",
215 get_cmd_string(cmd->id)); 215 get_cmd_string(cmd->id));
216 ret = -ECANCELED; 216 ret = -ECANCELED;
217 goto fail; 217 goto fail;
218 } 218 }
219 if (test_bit(STATUS_FW_ERROR, &priv->status)) { 219 if (test_bit(STATUS_FW_ERROR, &priv->status)) {
220 IWL_DEBUG_INFO("Command %s failed: FW Error\n", 220 IWL_DEBUG_INFO(priv, "Command %s failed: FW Error\n",
221 get_cmd_string(cmd->id)); 221 get_cmd_string(cmd->id));
222 ret = -EIO; 222 ret = -EIO;
223 goto fail; 223 goto fail;
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index 7341a2da8431..c7b8e5bb4e42 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -66,7 +66,7 @@
66static inline void __iwl_write32(const char *f, u32 l, struct iwl_priv *priv, 66static inline void __iwl_write32(const char *f, u32 l, struct iwl_priv *priv,
67 u32 ofs, u32 val) 67 u32 ofs, u32 val)
68{ 68{
69 IWL_DEBUG_IO("write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); 69 IWL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l);
70 _iwl_write32(priv, ofs, val); 70 _iwl_write32(priv, ofs, val);
71} 71}
72#define iwl_write32(priv, ofs, val) \ 72#define iwl_write32(priv, ofs, val) \
@@ -79,7 +79,7 @@ static inline void __iwl_write32(const char *f, u32 l, struct iwl_priv *priv,
79#ifdef CONFIG_IWLWIFI_DEBUG 79#ifdef CONFIG_IWLWIFI_DEBUG
80static inline u32 __iwl_read32(char *f, u32 l, struct iwl_priv *priv, u32 ofs) 80static inline u32 __iwl_read32(char *f, u32 l, struct iwl_priv *priv, u32 ofs)
81{ 81{
82 IWL_DEBUG_IO("read_direct32(0x%08X) - %s %d\n", ofs, f, l); 82 IWL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l);
83 return _iwl_read32(priv, ofs); 83 return _iwl_read32(priv, ofs);
84} 84}
85#define iwl_read32(priv, ofs) __iwl_read32(__FILE__, __LINE__, priv, ofs) 85#define iwl_read32(priv, ofs) __iwl_read32(__FILE__, __LINE__, priv, ofs)
@@ -108,7 +108,7 @@ static inline int __iwl_poll_bit(const char *f, u32 l,
108 u32 bits, u32 mask, int timeout) 108 u32 bits, u32 mask, int timeout)
109{ 109{
110 int ret = _iwl_poll_bit(priv, addr, bits, mask, timeout); 110 int ret = _iwl_poll_bit(priv, addr, bits, mask, timeout);
111 IWL_DEBUG_IO("poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", 111 IWL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n",
112 addr, bits, mask, 112 addr, bits, mask,
113 unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l); 113 unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l);
114 return ret; 114 return ret;
@@ -128,7 +128,7 @@ static inline void __iwl_set_bit(const char *f, u32 l,
128 struct iwl_priv *priv, u32 reg, u32 mask) 128 struct iwl_priv *priv, u32 reg, u32 mask)
129{ 129{
130 u32 val = _iwl_read32(priv, reg) | mask; 130 u32 val = _iwl_read32(priv, reg) | mask;
131 IWL_DEBUG_IO("set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); 131 IWL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
132 _iwl_write32(priv, reg, val); 132 _iwl_write32(priv, reg, val);
133} 133}
134#define iwl_set_bit(p, r, m) __iwl_set_bit(__FILE__, __LINE__, p, r, m) 134#define iwl_set_bit(p, r, m) __iwl_set_bit(__FILE__, __LINE__, p, r, m)
@@ -145,7 +145,7 @@ static inline void __iwl_clear_bit(const char *f, u32 l,
145 struct iwl_priv *priv, u32 reg, u32 mask) 145 struct iwl_priv *priv, u32 reg, u32 mask)
146{ 146{
147 u32 val = _iwl_read32(priv, reg) & ~mask; 147 u32 val = _iwl_read32(priv, reg) & ~mask;
148 IWL_DEBUG_IO("clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); 148 IWL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val);
149 _iwl_write32(priv, reg, val); 149 _iwl_write32(priv, reg, val);
150} 150}
151#define iwl_clear_bit(p, r, m) __iwl_clear_bit(__FILE__, __LINE__, p, r, m) 151#define iwl_clear_bit(p, r, m) __iwl_clear_bit(__FILE__, __LINE__, p, r, m)
@@ -184,7 +184,7 @@ static inline int __iwl_grab_nic_access(const char *f, u32 l,
184 if (atomic_read(&priv->restrict_refcnt)) 184 if (atomic_read(&priv->restrict_refcnt))
185 IWL_ERR(priv, "Grabbing access while already held %s %d.\n", f, l); 185 IWL_ERR(priv, "Grabbing access while already held %s %d.\n", f, l);
186 186
187 IWL_DEBUG_IO("grabbing nic access - %s %d\n", f, l); 187 IWL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l);
188 return _iwl_grab_nic_access(priv); 188 return _iwl_grab_nic_access(priv);
189} 189}
190#define iwl_grab_nic_access(priv) \ 190#define iwl_grab_nic_access(priv) \
@@ -209,7 +209,7 @@ static inline void __iwl_release_nic_access(const char *f, u32 l,
209 if (atomic_read(&priv->restrict_refcnt) <= 0) 209 if (atomic_read(&priv->restrict_refcnt) <= 0)
210 IWL_ERR(priv, "Release unheld nic access at line %s %d.\n", f, l); 210 IWL_ERR(priv, "Release unheld nic access at line %s %d.\n", f, l);
211 211
212 IWL_DEBUG_IO("releasing nic access - %s %d\n", f, l); 212 IWL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l);
213 _iwl_release_nic_access(priv); 213 _iwl_release_nic_access(priv);
214} 214}
215#define iwl_release_nic_access(priv) \ 215#define iwl_release_nic_access(priv) \
@@ -230,7 +230,7 @@ static inline u32 __iwl_read_direct32(const char *f, u32 l,
230 u32 value = _iwl_read_direct32(priv, reg); 230 u32 value = _iwl_read_direct32(priv, reg);
231 if (!atomic_read(&priv->restrict_refcnt)) 231 if (!atomic_read(&priv->restrict_refcnt))
232 IWL_ERR(priv, "Nic access not held from %s %d\n", f, l); 232 IWL_ERR(priv, "Nic access not held from %s %d\n", f, l);
233 IWL_DEBUG_IO("read_direct32(0x%4X) = 0x%08x - %s %d \n", reg, value, 233 IWL_DEBUG_IO(priv, "read_direct32(0x%4X) = 0x%08x - %s %d \n", reg, value,
234 f, l); 234 f, l);
235 return value; 235 return value;
236} 236}
@@ -284,10 +284,10 @@ static inline int __iwl_poll_direct_bit(const char *f, u32 l,
284 int ret = _iwl_poll_direct_bit(priv, addr, mask, timeout); 284 int ret = _iwl_poll_direct_bit(priv, addr, mask, timeout);
285 285
286 if (unlikely(ret == -ETIMEDOUT)) 286 if (unlikely(ret == -ETIMEDOUT))
287 IWL_DEBUG_IO("poll_direct_bit(0x%08X, 0x%08X) - " 287 IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - "
288 "timedout - %s %d\n", addr, mask, f, l); 288 "timedout - %s %d\n", addr, mask, f, l);
289 else 289 else
290 IWL_DEBUG_IO("poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " 290 IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X "
291 "- %s %d\n", addr, mask, ret, f, l); 291 "- %s %d\n", addr, mask, ret, f, l);
292 return ret; 292 return ret;
293} 293}
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 501cffeff5f2..19680f72087f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -123,7 +123,7 @@ static int iwl4965_led_pattern(struct iwl_priv *priv, int led_id,
123/* Set led register off */ 123/* Set led register off */
124static int iwl4965_led_on_reg(struct iwl_priv *priv, int led_id) 124static int iwl4965_led_on_reg(struct iwl_priv *priv, int led_id)
125{ 125{
126 IWL_DEBUG_LED("led on %d\n", led_id); 126 IWL_DEBUG_LED(priv, "led on %d\n", led_id);
127 iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); 127 iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
128 return 0; 128 return 0;
129} 129}
@@ -150,7 +150,7 @@ int iwl4965_led_off(struct iwl_priv *priv, int led_id)
150 .off = 0, 150 .off = 0,
151 .interval = IWL_DEF_LED_INTRVL 151 .interval = IWL_DEF_LED_INTRVL
152 }; 152 };
153 IWL_DEBUG_LED("led off %d\n", led_id); 153 IWL_DEBUG_LED(priv, "led off %d\n", led_id);
154 return iwl_send_led_cmd(priv, &led_cmd); 154 return iwl_send_led_cmd(priv, &led_cmd);
155} 155}
156#endif 156#endif
@@ -159,7 +159,7 @@ int iwl4965_led_off(struct iwl_priv *priv, int led_id)
159/* Set led register off */ 159/* Set led register off */
160static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id) 160static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id)
161{ 161{
162 IWL_DEBUG_LED("LED Reg off\n"); 162 IWL_DEBUG_LED(priv, "LED Reg off\n");
163 iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF); 163 iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_OFF);
164 return 0; 164 return 0;
165} 165}
@@ -169,7 +169,7 @@ static int iwl4965_led_off_reg(struct iwl_priv *priv, int led_id)
169 */ 169 */
170static int iwl_led_associate(struct iwl_priv *priv, int led_id) 170static int iwl_led_associate(struct iwl_priv *priv, int led_id)
171{ 171{
172 IWL_DEBUG_LED("Associated\n"); 172 IWL_DEBUG_LED(priv, "Associated\n");
173 priv->allow_blinking = 1; 173 priv->allow_blinking = 1;
174 return iwl4965_led_on_reg(priv, led_id); 174 return iwl4965_led_on_reg(priv, led_id);
175} 175}
@@ -213,7 +213,7 @@ static void iwl_led_brightness_set(struct led_classdev *led_cdev,
213 return; 213 return;
214 214
215 215
216 IWL_DEBUG_LED("Led type = %s brightness = %d\n", 216 IWL_DEBUG_LED(priv, "Led type = %s brightness = %d\n",
217 led_type_str[led->type], brightness); 217 led_type_str[led->type], brightness);
218 switch (brightness) { 218 switch (brightness) {
219 case LED_FULL: 219 case LED_FULL:
@@ -280,7 +280,7 @@ static int iwl_get_blink_rate(struct iwl_priv *priv)
280 if (tpt < 0) /* wraparound */ 280 if (tpt < 0) /* wraparound */
281 tpt = -tpt; 281 tpt = -tpt;
282 282
283 IWL_DEBUG_LED("tpt %lld current_tpt %llu\n", 283 IWL_DEBUG_LED(priv, "tpt %lld current_tpt %llu\n",
284 (long long)tpt, 284 (long long)tpt,
285 (unsigned long long)current_tpt); 285 (unsigned long long)current_tpt);
286 priv->led_tpt = current_tpt; 286 priv->led_tpt = current_tpt;
@@ -292,7 +292,7 @@ static int iwl_get_blink_rate(struct iwl_priv *priv)
292 if (tpt > (blink_tbl[i].tpt * IWL_1MB_RATE)) 292 if (tpt > (blink_tbl[i].tpt * IWL_1MB_RATE))
293 break; 293 break;
294 294
295 IWL_DEBUG_LED("LED BLINK IDX=%d\n", i); 295 IWL_DEBUG_LED(priv, "LED BLINK IDX=%d\n", i);
296 return i; 296 return i;
297} 297}
298 298
@@ -352,7 +352,7 @@ int iwl_leds_register(struct iwl_priv *priv)
352 352
353 trigger = ieee80211_get_radio_led_name(priv->hw); 353 trigger = ieee80211_get_radio_led_name(priv->hw);
354 snprintf(priv->led[IWL_LED_TRG_RADIO].name, 354 snprintf(priv->led[IWL_LED_TRG_RADIO].name,
355 sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s:radio", 355 sizeof(priv->led[IWL_LED_TRG_RADIO].name), "iwl-%s::radio",
356 wiphy_name(priv->hw->wiphy)); 356 wiphy_name(priv->hw->wiphy));
357 357
358 priv->led[IWL_LED_TRG_RADIO].led_on = iwl4965_led_on_reg; 358 priv->led[IWL_LED_TRG_RADIO].led_on = iwl4965_led_on_reg;
@@ -366,7 +366,7 @@ int iwl_leds_register(struct iwl_priv *priv)
366 366
367 trigger = ieee80211_get_assoc_led_name(priv->hw); 367 trigger = ieee80211_get_assoc_led_name(priv->hw);
368 snprintf(priv->led[IWL_LED_TRG_ASSOC].name, 368 snprintf(priv->led[IWL_LED_TRG_ASSOC].name,
369 sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s:assoc", 369 sizeof(priv->led[IWL_LED_TRG_ASSOC].name), "iwl-%s::assoc",
370 wiphy_name(priv->hw->wiphy)); 370 wiphy_name(priv->hw->wiphy));
371 371
372 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC], 372 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_ASSOC],
@@ -382,7 +382,7 @@ int iwl_leds_register(struct iwl_priv *priv)
382 382
383 trigger = ieee80211_get_rx_led_name(priv->hw); 383 trigger = ieee80211_get_rx_led_name(priv->hw);
384 snprintf(priv->led[IWL_LED_TRG_RX].name, 384 snprintf(priv->led[IWL_LED_TRG_RX].name,
385 sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s:RX", 385 sizeof(priv->led[IWL_LED_TRG_RX].name), "iwl-%s::RX",
386 wiphy_name(priv->hw->wiphy)); 386 wiphy_name(priv->hw->wiphy));
387 387
388 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX], 388 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_RX],
@@ -397,7 +397,7 @@ int iwl_leds_register(struct iwl_priv *priv)
397 397
398 trigger = ieee80211_get_tx_led_name(priv->hw); 398 trigger = ieee80211_get_tx_led_name(priv->hw);
399 snprintf(priv->led[IWL_LED_TRG_TX].name, 399 snprintf(priv->led[IWL_LED_TRG_TX].name,
400 sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s:TX", 400 sizeof(priv->led[IWL_LED_TRG_TX].name), "iwl-%s::TX",
401 wiphy_name(priv->hw->wiphy)); 401 wiphy_name(priv->hw->wiphy));
402 402
403 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX], 403 ret = iwl_leds_register_led(priv, &priv->led[IWL_LED_TRG_TX],
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h
index 1d798d086695..140fd8fa4855 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.h
+++ b/drivers/net/wireless/iwlwifi/iwl-led.h
@@ -35,7 +35,7 @@ struct iwl_priv;
35 35
36#define IWL_LED_SOLID 11 36#define IWL_LED_SOLID 11
37#define IWL_LED_NAME_LEN 31 37#define IWL_LED_NAME_LEN 31
38#define IWL_DEF_LED_INTRVL __constant_cpu_to_le32(1000) 38#define IWL_DEF_LED_INTRVL cpu_to_le32(1000)
39 39
40#define IWL_LED_ACTIVITY (0<<1) 40#define IWL_LED_ACTIVITY (0<<1)
41#define IWL_LED_LINK (1<<1) 41#define IWL_LED_LINK (1<<1)
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index a4634595c59f..4c5a775f48b7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -102,6 +102,7 @@ static struct iwl_power_vec_entry range_2[IWL_POWER_MAX] = {
102 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 0xFF)}, 0} 102 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 0xFF)}, 0}
103}; 103};
104 104
105
105/* set card power command */ 106/* set card power command */
106static int iwl_set_power(struct iwl_priv *priv, void *cmd) 107static int iwl_set_power(struct iwl_priv *priv, void *cmd)
107{ 108{
@@ -126,13 +127,6 @@ static u16 iwl_get_auto_power_mode(struct iwl_priv *priv)
126 else 127 else
127 mode = IWL_POWER_ON_AC_DISASSOC; 128 mode = IWL_POWER_ON_AC_DISASSOC;
128 break; 129 break;
129 /* FIXME: remove battery and ac from here */
130 case IWL_POWER_BATTERY:
131 mode = IWL_POWER_INDEX_3;
132 break;
133 case IWL_POWER_AC:
134 mode = IWL_POWER_MODE_CAM;
135 break;
136 default: 130 default:
137 mode = priv->power_data.user_power_setting; 131 mode = priv->power_data.user_power_setting;
138 break; 132 break;
@@ -149,7 +143,7 @@ static void iwl_power_init_handle(struct iwl_priv *priv)
149 int i; 143 int i;
150 u16 pci_pm; 144 u16 pci_pm;
151 145
152 IWL_DEBUG_POWER("Initialize power \n"); 146 IWL_DEBUG_POWER(priv, "Initialize power \n");
153 147
154 pow_data = &priv->power_data; 148 pow_data = &priv->power_data;
155 149
@@ -161,7 +155,7 @@ static void iwl_power_init_handle(struct iwl_priv *priv)
161 155
162 pci_read_config_word(priv->pci_dev, PCI_CFG_LINK_CTRL, &pci_pm); 156 pci_read_config_word(priv->pci_dev, PCI_CFG_LINK_CTRL, &pci_pm);
163 157
164 IWL_DEBUG_POWER("adjust power command flags\n"); 158 IWL_DEBUG_POWER(priv, "adjust power command flags\n");
165 159
166 for (i = 0; i < IWL_POWER_MAX; i++) { 160 for (i = 0; i < IWL_POWER_MAX; i++) {
167 cmd = &pow_data->pwr_range_0[i].cmd; 161 cmd = &pow_data->pwr_range_0[i].cmd;
@@ -185,7 +179,7 @@ static int iwl_update_power_cmd(struct iwl_priv *priv,
185 bool skip; 179 bool skip;
186 180
187 if (mode > IWL_POWER_INDEX_5) { 181 if (mode > IWL_POWER_INDEX_5) {
188 IWL_DEBUG_POWER("Error invalid power mode \n"); 182 IWL_DEBUG_POWER(priv, "Error invalid power mode \n");
189 return -EINVAL; 183 return -EINVAL;
190 } 184 }
191 185
@@ -225,10 +219,10 @@ static int iwl_update_power_cmd(struct iwl_priv *priv,
225 if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep) 219 if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep)
226 cmd->sleep_interval[i] = cpu_to_le32(max_sleep); 220 cmd->sleep_interval[i] = cpu_to_le32(max_sleep);
227 221
228 IWL_DEBUG_POWER("Flags value = 0x%08X\n", cmd->flags); 222 IWL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags);
229 IWL_DEBUG_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); 223 IWL_DEBUG_POWER(priv, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout));
230 IWL_DEBUG_POWER("Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); 224 IWL_DEBUG_POWER(priv, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout));
231 IWL_DEBUG_POWER("Sleep interval vector = { %d , %d , %d , %d , %d }\n", 225 IWL_DEBUG_POWER(priv, "Sleep interval vector = { %d , %d , %d , %d , %d }\n",
232 le32_to_cpu(cmd->sleep_interval[0]), 226 le32_to_cpu(cmd->sleep_interval[0]),
233 le32_to_cpu(cmd->sleep_interval[1]), 227 le32_to_cpu(cmd->sleep_interval[1]),
234 le32_to_cpu(cmd->sleep_interval[2]), 228 le32_to_cpu(cmd->sleep_interval[2]),
@@ -302,7 +296,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
302 if (priv->cfg->ops->lib->update_chain_flags && update_chains) 296 if (priv->cfg->ops->lib->update_chain_flags && update_chains)
303 priv->cfg->ops->lib->update_chain_flags(priv); 297 priv->cfg->ops->lib->update_chain_flags(priv);
304 else 298 else
305 IWL_DEBUG_POWER("Cannot update the power, chain noise " 299 IWL_DEBUG_POWER(priv, "Cannot update the power, chain noise "
306 "calibration running: %d\n", 300 "calibration running: %d\n",
307 priv->chain_noise_data.state); 301 priv->chain_noise_data.state);
308 if (!ret) 302 if (!ret)
@@ -357,7 +351,7 @@ EXPORT_SYMBOL(iwl_power_enable_management);
357/* set user_power_setting */ 351/* set user_power_setting */
358int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode) 352int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode)
359{ 353{
360 if (mode > IWL_POWER_LIMIT) 354 if (mode > IWL_POWER_MAX)
361 return -EINVAL; 355 return -EINVAL;
362 356
363 priv->power_data.user_power_setting = mode; 357 priv->power_data.user_power_setting = mode;
@@ -371,11 +365,10 @@ EXPORT_SYMBOL(iwl_power_set_user_mode);
371 */ 365 */
372int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode) 366int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode)
373{ 367{
374 if (mode > IWL_POWER_LIMIT) 368 if (mode < IWL_POWER_SYS_MAX)
369 priv->power_data.system_power_setting = mode;
370 else
375 return -EINVAL; 371 return -EINVAL;
376
377 priv->power_data.system_power_setting = mode;
378
379 return iwl_power_update_mode(priv, 0); 372 return iwl_power_update_mode(priv, 0);
380} 373}
381EXPORT_SYMBOL(iwl_power_set_system_mode); 374EXPORT_SYMBOL(iwl_power_set_system_mode);
@@ -423,7 +416,7 @@ static void iwl_bg_set_power_save(struct work_struct *work)
423{ 416{
424 struct iwl_priv *priv = container_of(work, 417 struct iwl_priv *priv = container_of(work,
425 struct iwl_priv, set_power_save.work); 418 struct iwl_priv, set_power_save.work);
426 IWL_DEBUG(IWL_DL_STATE, "update power\n"); 419 IWL_DEBUG_POWER(priv, "update power\n");
427 420
428 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 421 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
429 return; 422 return;
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index 859b60b5335c..18963392121e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -42,38 +42,26 @@ enum {
42 IWL_POWER_INDEX_5, 42 IWL_POWER_INDEX_5,
43 IWL_POWER_AUTO, 43 IWL_POWER_AUTO,
44 IWL_POWER_MAX = IWL_POWER_AUTO, 44 IWL_POWER_MAX = IWL_POWER_AUTO,
45 IWL39_POWER_AC = IWL_POWER_AUTO, /* 0x06 */
46 IWL_POWER_AC,
47 IWL39_POWER_BATTERY = IWL_POWER_AC, /* 0x07 */
48 IWL39_POWER_LIMIT = IWL_POWER_AC,
49 IWL_POWER_BATTERY,
50}; 45};
51 46
52enum { 47enum {
53 IWL_POWER_SYS_AUTO, 48 IWL_POWER_SYS_AUTO,
54 IWL_POWER_SYS_AC, 49 IWL_POWER_SYS_AC,
55 IWL_POWER_SYS_BATTERY, 50 IWL_POWER_SYS_BATTERY,
51 IWL_POWER_SYS_MAX,
56}; 52};
57 53
58#define IWL_POWER_LIMIT 0x08
59#define IWL_POWER_MASK 0x0F
60#define IWL_POWER_ENABLED 0x10
61
62#define IWL_POWER_RANGE_0 (0)
63#define IWL_POWER_RANGE_1 (1)
64
65#define IWL_POWER_LEVEL(x) ((x) & IWL_POWER_MASK)
66 54
67/* Power management (not Tx power) structures */ 55/* Power management (not Tx power) structures */
68 56
69#define NOSLP __constant_cpu_to_le16(0), 0, 0 57#define NOSLP cpu_to_le16(0), 0, 0
70#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0 58#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
71#define SLP_TOUT(T) __constant_cpu_to_le32((T) * MSEC_TO_USEC) 59#define SLP_TOUT(T) cpu_to_le32((T) * MSEC_TO_USEC)
72#define SLP_VEC(X0, X1, X2, X3, X4) {__constant_cpu_to_le32(X0), \ 60#define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \
73 __constant_cpu_to_le32(X1), \ 61 cpu_to_le32(X1), \
74 __constant_cpu_to_le32(X2), \ 62 cpu_to_le32(X2), \
75 __constant_cpu_to_le32(X3), \ 63 cpu_to_le32(X3), \
76 __constant_cpu_to_le32(X4)} 64 cpu_to_le32(X4)}
77struct iwl_power_vec_entry { 65struct iwl_power_vec_entry {
78 struct iwl_powertable_cmd cmd; 66 struct iwl_powertable_cmd cmd;
79 u8 no_dtim; 67 u8 no_dtim;
diff --git a/drivers/net/wireless/iwlwifi/iwl-rfkill.c b/drivers/net/wireless/iwlwifi/iwl-rfkill.c
index f67d7be10748..2ad9faf1508a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rfkill.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rfkill.c
@@ -47,7 +47,7 @@ static int iwl_rfkill_soft_rf_kill(void *data, enum rfkill_state state)
47 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 47 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
48 return 0; 48 return 0;
49 49
50 IWL_DEBUG_RF_KILL("we received soft RFKILL set to state %d\n", state); 50 IWL_DEBUG_RF_KILL(priv, "we received soft RFKILL set to state %d\n", state);
51 mutex_lock(&priv->mutex); 51 mutex_lock(&priv->mutex);
52 52
53 switch (state) { 53 switch (state) {
@@ -79,7 +79,7 @@ int iwl_rfkill_init(struct iwl_priv *priv)
79 79
80 BUG_ON(device == NULL); 80 BUG_ON(device == NULL);
81 81
82 IWL_DEBUG_RF_KILL("Initializing RFKILL.\n"); 82 IWL_DEBUG_RF_KILL(priv, "Initializing RFKILL.\n");
83 priv->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN); 83 priv->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
84 if (!priv->rfkill) { 84 if (!priv->rfkill) {
85 IWL_ERR(priv, "Unable to allocate RFKILL device.\n"); 85 IWL_ERR(priv, "Unable to allocate RFKILL device.\n");
@@ -102,7 +102,7 @@ int iwl_rfkill_init(struct iwl_priv *priv)
102 goto free_rfkill; 102 goto free_rfkill;
103 } 103 }
104 104
105 IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n"); 105 IWL_DEBUG_RF_KILL(priv, "RFKILL initialization complete.\n");
106 return ret; 106 return ret;
107 107
108free_rfkill: 108free_rfkill:
@@ -111,7 +111,7 @@ free_rfkill:
111 priv->rfkill = NULL; 111 priv->rfkill = NULL;
112 112
113error: 113error:
114 IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n"); 114 IWL_DEBUG_RF_KILL(priv, "RFKILL initialization complete.\n");
115 return ret; 115 return ret;
116} 116}
117EXPORT_SYMBOL(iwl_rfkill_init); 117EXPORT_SYMBOL(iwl_rfkill_init);
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index 33145207fc15..8f65908f66f1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -494,7 +494,7 @@ void iwl_rx_missed_beacon_notif(struct iwl_priv *priv,
494 494
495 missed_beacon = &pkt->u.missed_beacon; 495 missed_beacon = &pkt->u.missed_beacon;
496 if (le32_to_cpu(missed_beacon->consequtive_missed_beacons) > 5) { 496 if (le32_to_cpu(missed_beacon->consequtive_missed_beacons) > 5) {
497 IWL_DEBUG_CALIB("missed bcn cnsq %d totl %d rcd %d expctd %d\n", 497 IWL_DEBUG_CALIB(priv, "missed bcn cnsq %d totl %d rcd %d expctd %d\n",
498 le32_to_cpu(missed_beacon->consequtive_missed_beacons), 498 le32_to_cpu(missed_beacon->consequtive_missed_beacons),
499 le32_to_cpu(missed_beacon->total_missed_becons), 499 le32_to_cpu(missed_beacon->total_missed_becons),
500 le32_to_cpu(missed_beacon->num_recvd_beacons), 500 le32_to_cpu(missed_beacon->num_recvd_beacons),
@@ -541,7 +541,7 @@ static void iwl_rx_calc_noise(struct iwl_priv *priv)
541 else 541 else
542 priv->last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; 542 priv->last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
543 543
544 IWL_DEBUG_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", 544 IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n",
545 bcn_silence_a, bcn_silence_b, bcn_silence_c, 545 bcn_silence_a, bcn_silence_b, bcn_silence_c,
546 priv->last_rx_noise); 546 priv->last_rx_noise);
547} 547}
@@ -554,7 +554,7 @@ void iwl_rx_statistics(struct iwl_priv *priv,
554 int change; 554 int change;
555 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 555 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
556 556
557 IWL_DEBUG_RX("Statistics notification received (%d vs %d).\n", 557 IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n",
558 (int)sizeof(priv->statistics), pkt->len); 558 (int)sizeof(priv->statistics), pkt->len);
559 559
560 change = ((priv->statistics.general.temperature != 560 change = ((priv->statistics.general.temperature !=
@@ -741,13 +741,13 @@ static void iwl_dbg_report_frame(struct iwl_priv *priv,
741 * MAC addresses show just the last byte (for brevity), 741 * MAC addresses show just the last byte (for brevity),
742 * but you can hack it to show more, if you'd like to. */ 742 * but you can hack it to show more, if you'd like to. */
743 if (dataframe) 743 if (dataframe)
744 IWL_DEBUG_RX("%s: mhd=0x%04x, dst=0x%02x, " 744 IWL_DEBUG_RX(priv, "%s: mhd=0x%04x, dst=0x%02x, "
745 "len=%u, rssi=%d, chnl=%d, rate=%u, \n", 745 "len=%u, rssi=%d, chnl=%d, rate=%u, \n",
746 title, le16_to_cpu(fc), header->addr1[5], 746 title, le16_to_cpu(fc), header->addr1[5],
747 length, rssi, channel, bitrate); 747 length, rssi, channel, bitrate);
748 else { 748 else {
749 /* src/dst addresses assume managed mode */ 749 /* src/dst addresses assume managed mode */
750 IWL_DEBUG_RX("%s: 0x%04x, dst=0x%02x, src=0x%02x, " 750 IWL_DEBUG_RX(priv, "%s: 0x%04x, dst=0x%02x, src=0x%02x, "
751 "len=%u, rssi=%d, tim=%lu usec, " 751 "len=%u, rssi=%d, tim=%lu usec, "
752 "phy=0x%02x, chnl=%d\n", 752 "phy=0x%02x, chnl=%d\n",
753 title, le16_to_cpu(fc), header->addr1[5], 753 title, le16_to_cpu(fc), header->addr1[5],
@@ -772,10 +772,10 @@ static void iwl_update_rx_stats(struct iwl_priv *priv, u16 fc, u16 len)
772/* 772/*
773 * returns non-zero if packet should be dropped 773 * returns non-zero if packet should be dropped
774 */ 774 */
775static int iwl_set_decrypted_flag(struct iwl_priv *priv, 775int iwl_set_decrypted_flag(struct iwl_priv *priv,
776 struct ieee80211_hdr *hdr, 776 struct ieee80211_hdr *hdr,
777 u32 decrypt_res, 777 u32 decrypt_res,
778 struct ieee80211_rx_status *stats) 778 struct ieee80211_rx_status *stats)
779{ 779{
780 u16 fc = le16_to_cpu(hdr->frame_control); 780 u16 fc = le16_to_cpu(hdr->frame_control);
781 781
@@ -785,7 +785,7 @@ static int iwl_set_decrypted_flag(struct iwl_priv *priv,
785 if (!(fc & IEEE80211_FCTL_PROTECTED)) 785 if (!(fc & IEEE80211_FCTL_PROTECTED))
786 return 0; 786 return 0;
787 787
788 IWL_DEBUG_RX("decrypt_res:0x%x\n", decrypt_res); 788 IWL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res);
789 switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { 789 switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) {
790 case RX_RES_STATUS_SEC_TYPE_TKIP: 790 case RX_RES_STATUS_SEC_TYPE_TKIP:
791 /* The uCode has got a bad phase 1 Key, pushes the packet. 791 /* The uCode has got a bad phase 1 Key, pushes the packet.
@@ -799,13 +799,13 @@ static int iwl_set_decrypted_flag(struct iwl_priv *priv,
799 RX_RES_STATUS_BAD_ICV_MIC) { 799 RX_RES_STATUS_BAD_ICV_MIC) {
800 /* bad ICV, the packet is destroyed since the 800 /* bad ICV, the packet is destroyed since the
801 * decryption is inplace, drop it */ 801 * decryption is inplace, drop it */
802 IWL_DEBUG_RX("Packet destroyed\n"); 802 IWL_DEBUG_RX(priv, "Packet destroyed\n");
803 return -1; 803 return -1;
804 } 804 }
805 case RX_RES_STATUS_SEC_TYPE_CCMP: 805 case RX_RES_STATUS_SEC_TYPE_CCMP:
806 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == 806 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
807 RX_RES_STATUS_DECRYPT_OK) { 807 RX_RES_STATUS_DECRYPT_OK) {
808 IWL_DEBUG_RX("hw decrypt successfully!!!\n"); 808 IWL_DEBUG_RX(priv, "hw decrypt successfully!!!\n");
809 stats->flag |= RX_FLAG_DECRYPTED; 809 stats->flag |= RX_FLAG_DECRYPTED;
810 } 810 }
811 break; 811 break;
@@ -815,6 +815,7 @@ static int iwl_set_decrypted_flag(struct iwl_priv *priv,
815 } 815 }
816 return 0; 816 return 0;
817} 817}
818EXPORT_SYMBOL(iwl_set_decrypted_flag);
818 819
819static u32 iwl_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in) 820static u32 iwl_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
820{ 821{
@@ -869,7 +870,7 @@ static u32 iwl_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in)
869 break; 870 break;
870 }; 871 };
871 872
872 IWL_DEBUG_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", 873 IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n",
873 decrypt_in, decrypt_out); 874 decrypt_in, decrypt_out);
874 875
875 return decrypt_out; 876 return decrypt_out;
@@ -933,8 +934,8 @@ static void iwl_pass_packet_to_mac80211(struct iwl_priv *priv,
933 934
934 /* We only process data packets if the interface is open */ 935 /* We only process data packets if the interface is open */
935 if (unlikely(!priv->is_open)) { 936 if (unlikely(!priv->is_open)) {
936 IWL_DEBUG_DROP_LIMIT 937 IWL_DEBUG_DROP_LIMIT(priv,
937 ("Dropping packet while interface is not open.\n"); 938 "Dropping packet while interface is not open.\n");
938 return; 939 return;
939 } 940 }
940 941
@@ -1006,7 +1007,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1006 /*rx_status.flag |= RX_FLAG_TSFT;*/ 1007 /*rx_status.flag |= RX_FLAG_TSFT;*/
1007 1008
1008 if ((unlikely(rx_start->cfg_phy_cnt > 20))) { 1009 if ((unlikely(rx_start->cfg_phy_cnt > 20))) {
1009 IWL_DEBUG_DROP("dsp size out of range [0,20]: %d/n", 1010 IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n",
1010 rx_start->cfg_phy_cnt); 1011 rx_start->cfg_phy_cnt);
1011 return; 1012 return;
1012 } 1013 }
@@ -1044,7 +1045,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1044 1045
1045 if (!(*rx_end & RX_RES_STATUS_NO_CRC32_ERROR) || 1046 if (!(*rx_end & RX_RES_STATUS_NO_CRC32_ERROR) ||
1046 !(*rx_end & RX_RES_STATUS_NO_RXE_OVERFLOW)) { 1047 !(*rx_end & RX_RES_STATUS_NO_RXE_OVERFLOW)) {
1047 IWL_DEBUG_RX("Bad CRC or FIFO: 0x%08X.\n", 1048 IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n",
1048 le32_to_cpu(*rx_end)); 1049 le32_to_cpu(*rx_end));
1049 return; 1050 return;
1050 } 1051 }
@@ -1077,7 +1078,7 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
1077 if (unlikely(priv->debug_level & IWL_DL_RX)) 1078 if (unlikely(priv->debug_level & IWL_DL_RX))
1078 iwl_dbg_report_frame(priv, rx_start, len, header, 1); 1079 iwl_dbg_report_frame(priv, rx_start, len, header, 1);
1079#endif 1080#endif
1080 IWL_DEBUG_STATS_LIMIT("Rssi %d, noise %d, qual %d, TSF %llu\n", 1081 IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, noise %d, qual %d, TSF %llu\n",
1081 rx_status.signal, rx_status.noise, rx_status.signal, 1082 rx_status.signal, rx_status.noise, rx_status.signal,
1082 (unsigned long long)rx_status.mactime); 1083 (unsigned long long)rx_status.mactime);
1083 1084
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index c282d1d294e6..22bad3ce7d6a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -70,12 +70,12 @@ int iwl_scan_cancel(struct iwl_priv *priv)
70 70
71 if (test_bit(STATUS_SCANNING, &priv->status)) { 71 if (test_bit(STATUS_SCANNING, &priv->status)) {
72 if (!test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 72 if (!test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
73 IWL_DEBUG_SCAN("Queuing scan abort.\n"); 73 IWL_DEBUG_SCAN(priv, "Queuing scan abort.\n");
74 set_bit(STATUS_SCAN_ABORTING, &priv->status); 74 set_bit(STATUS_SCAN_ABORTING, &priv->status);
75 queue_work(priv->workqueue, &priv->abort_scan); 75 queue_work(priv->workqueue, &priv->abort_scan);
76 76
77 } else 77 } else
78 IWL_DEBUG_SCAN("Scan abort already in progress.\n"); 78 IWL_DEBUG_SCAN(priv, "Scan abort already in progress.\n");
79 79
80 return test_bit(STATUS_SCANNING, &priv->status); 80 return test_bit(STATUS_SCANNING, &priv->status);
81 } 81 }
@@ -140,7 +140,7 @@ int iwl_send_scan_abort(struct iwl_priv *priv)
140 * can occur if we send the scan abort before we 140 * can occur if we send the scan abort before we
141 * the microcode has notified us that a scan is 141 * the microcode has notified us that a scan is
142 * completed. */ 142 * completed. */
143 IWL_DEBUG_INFO("SCAN_ABORT returned %d.\n", res->u.status); 143 IWL_DEBUG_INFO(priv, "SCAN_ABORT returned %d.\n", res->u.status);
144 clear_bit(STATUS_SCAN_ABORTING, &priv->status); 144 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
145 clear_bit(STATUS_SCAN_HW, &priv->status); 145 clear_bit(STATUS_SCAN_HW, &priv->status);
146 } 146 }
@@ -161,7 +161,7 @@ static void iwl_rx_reply_scan(struct iwl_priv *priv,
161 struct iwl_scanreq_notification *notif = 161 struct iwl_scanreq_notification *notif =
162 (struct iwl_scanreq_notification *)pkt->u.raw; 162 (struct iwl_scanreq_notification *)pkt->u.raw;
163 163
164 IWL_DEBUG_RX("Scan request status = 0x%x\n", notif->status); 164 IWL_DEBUG_RX(priv, "Scan request status = 0x%x\n", notif->status);
165#endif 165#endif
166} 166}
167 167
@@ -173,7 +173,7 @@ static void iwl_rx_scan_start_notif(struct iwl_priv *priv,
173 struct iwl_scanstart_notification *notif = 173 struct iwl_scanstart_notification *notif =
174 (struct iwl_scanstart_notification *)pkt->u.raw; 174 (struct iwl_scanstart_notification *)pkt->u.raw;
175 priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); 175 priv->scan_start_tsf = le32_to_cpu(notif->tsf_low);
176 IWL_DEBUG_SCAN("Scan start: " 176 IWL_DEBUG_SCAN(priv, "Scan start: "
177 "%d [802.11%s] " 177 "%d [802.11%s] "
178 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", 178 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n",
179 notif->channel, 179 notif->channel,
@@ -192,7 +192,7 @@ static void iwl_rx_scan_results_notif(struct iwl_priv *priv,
192 struct iwl_scanresults_notification *notif = 192 struct iwl_scanresults_notification *notif =
193 (struct iwl_scanresults_notification *)pkt->u.raw; 193 (struct iwl_scanresults_notification *)pkt->u.raw;
194 194
195 IWL_DEBUG_SCAN("Scan ch.res: " 195 IWL_DEBUG_SCAN(priv, "Scan ch.res: "
196 "%d [802.11%s] " 196 "%d [802.11%s] "
197 "(TSF: 0x%08X:%08X) - %d " 197 "(TSF: 0x%08X:%08X) - %d "
198 "elapsed=%lu usec (%dms since last)\n", 198 "elapsed=%lu usec (%dms since last)\n",
@@ -218,7 +218,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
218 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 218 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
219 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 219 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
220 220
221 IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", 221 IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
222 scan_notif->scanned_channels, 222 scan_notif->scanned_channels,
223 scan_notif->tsf_low, 223 scan_notif->tsf_low,
224 scan_notif->tsf_high, scan_notif->status); 224 scan_notif->tsf_high, scan_notif->status);
@@ -230,7 +230,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
230 /* The scan completion notification came in, so kill that timer... */ 230 /* The scan completion notification came in, so kill that timer... */
231 cancel_delayed_work(&priv->scan_check); 231 cancel_delayed_work(&priv->scan_check);
232 232
233 IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", 233 IWL_DEBUG_INFO(priv, "Scan pass on %sGHz took %dms\n",
234 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ? 234 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ?
235 "2.4" : "5.2", 235 "2.4" : "5.2",
236 jiffies_to_msecs(elapsed_jiffies 236 jiffies_to_msecs(elapsed_jiffies
@@ -248,7 +248,7 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
248 * then we reset the scan state machine and terminate, 248 * then we reset the scan state machine and terminate,
249 * re-queuing another scan if one has been requested */ 249 * re-queuing another scan if one has been requested */
250 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 250 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
251 IWL_DEBUG_INFO("Aborted scan completed.\n"); 251 IWL_DEBUG_INFO(priv, "Aborted scan completed.\n");
252 clear_bit(STATUS_SCAN_ABORTING, &priv->status); 252 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
253 } else { 253 } else {
254 /* If there are more bands on this scan pass reschedule */ 254 /* If there are more bands on this scan pass reschedule */
@@ -258,11 +258,11 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
258 258
259 priv->last_scan_jiffies = jiffies; 259 priv->last_scan_jiffies = jiffies;
260 priv->next_scan_jiffies = 0; 260 priv->next_scan_jiffies = 0;
261 IWL_DEBUG_INFO("Setting scan to off\n"); 261 IWL_DEBUG_INFO(priv, "Setting scan to off\n");
262 262
263 clear_bit(STATUS_SCANNING, &priv->status); 263 clear_bit(STATUS_SCANNING, &priv->status);
264 264
265 IWL_DEBUG_INFO("Scan took %dms\n", 265 IWL_DEBUG_INFO(priv, "Scan took %dms\n",
266 jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies))); 266 jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies)));
267 267
268 queue_work(priv->workqueue, &priv->scan_completed); 268 queue_work(priv->workqueue, &priv->scan_completed);
@@ -355,7 +355,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
355 355
356 ch_info = iwl_get_channel_info(priv, band, channel); 356 ch_info = iwl_get_channel_info(priv, band, channel);
357 if (!is_channel_valid(ch_info)) { 357 if (!is_channel_valid(ch_info)) {
358 IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n", 358 IWL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n",
359 channel); 359 channel);
360 continue; 360 continue;
361 } 361 }
@@ -384,7 +384,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
384 else 384 else
385 scan_ch->tx_gain = ((1 << 5) | (5 << 3)); 385 scan_ch->tx_gain = ((1 << 5) | (5 << 3));
386 386
387 IWL_DEBUG_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", 387 IWL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n",
388 channel, le32_to_cpu(scan_ch->type), 388 channel, le32_to_cpu(scan_ch->type),
389 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? 389 (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ?
390 "ACTIVE" : "PASSIVE", 390 "ACTIVE" : "PASSIVE",
@@ -395,7 +395,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
395 added++; 395 added++;
396 } 396 }
397 397
398 IWL_DEBUG_SCAN("total channels to scan %d \n", added); 398 IWL_DEBUG_SCAN(priv, "total channels to scan %d \n", added);
399 return added; 399 return added;
400} 400}
401 401
@@ -411,21 +411,21 @@ void iwl_init_scan_params(struct iwl_priv *priv)
411int iwl_scan_initiate(struct iwl_priv *priv) 411int iwl_scan_initiate(struct iwl_priv *priv)
412{ 412{
413 if (!iwl_is_ready_rf(priv)) { 413 if (!iwl_is_ready_rf(priv)) {
414 IWL_DEBUG_SCAN("Aborting scan due to not ready.\n"); 414 IWL_DEBUG_SCAN(priv, "Aborting scan due to not ready.\n");
415 return -EIO; 415 return -EIO;
416 } 416 }
417 417
418 if (test_bit(STATUS_SCANNING, &priv->status)) { 418 if (test_bit(STATUS_SCANNING, &priv->status)) {
419 IWL_DEBUG_SCAN("Scan already in progress.\n"); 419 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
420 return -EAGAIN; 420 return -EAGAIN;
421 } 421 }
422 422
423 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 423 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
424 IWL_DEBUG_SCAN("Scan request while abort pending\n"); 424 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
425 return -EAGAIN; 425 return -EAGAIN;
426 } 426 }
427 427
428 IWL_DEBUG_INFO("Starting scan...\n"); 428 IWL_DEBUG_INFO(priv, "Starting scan...\n");
429 if (priv->cfg->sku & IWL_SKU_G) 429 if (priv->cfg->sku & IWL_SKU_G)
430 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ); 430 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
431 if (priv->cfg->sku & IWL_SKU_A) 431 if (priv->cfg->sku & IWL_SKU_A)
@@ -453,7 +453,7 @@ void iwl_bg_scan_check(struct work_struct *data)
453 mutex_lock(&priv->mutex); 453 mutex_lock(&priv->mutex);
454 if (test_bit(STATUS_SCANNING, &priv->status) || 454 if (test_bit(STATUS_SCANNING, &priv->status) ||
455 test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 455 test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
456 IWL_DEBUG(IWL_DL_SCAN, "Scan completion watchdog resetting " 456 IWL_DEBUG_SCAN(priv, "Scan completion watchdog resetting "
457 "adapter (%dms)\n", 457 "adapter (%dms)\n",
458 jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG)); 458 jiffies_to_msecs(IWL_SCAN_CHECK_WATCHDOG));
459 459
@@ -657,34 +657,34 @@ static void iwl_bg_request_scan(struct work_struct *data)
657 /* This should never be called or scheduled if there is currently 657 /* This should never be called or scheduled if there is currently
658 * a scan active in the hardware. */ 658 * a scan active in the hardware. */
659 if (test_bit(STATUS_SCAN_HW, &priv->status)) { 659 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
660 IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. " 660 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests in parallel. "
661 "Ignoring second request.\n"); 661 "Ignoring second request.\n");
662 ret = -EIO; 662 ret = -EIO;
663 goto done; 663 goto done;
664 } 664 }
665 665
666 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 666 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
667 IWL_DEBUG_SCAN("Aborting scan due to device shutdown\n"); 667 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
668 goto done; 668 goto done;
669 } 669 }
670 670
671 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 671 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
672 IWL_DEBUG_HC("Scan request while abort pending. Queuing.\n"); 672 IWL_DEBUG_HC(priv, "Scan request while abort pending. Queuing.\n");
673 goto done; 673 goto done;
674 } 674 }
675 675
676 if (iwl_is_rfkill(priv)) { 676 if (iwl_is_rfkill(priv)) {
677 IWL_DEBUG_HC("Aborting scan due to RF Kill activation\n"); 677 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
678 goto done; 678 goto done;
679 } 679 }
680 680
681 if (!test_bit(STATUS_READY, &priv->status)) { 681 if (!test_bit(STATUS_READY, &priv->status)) {
682 IWL_DEBUG_HC("Scan request while uninitialized. Queuing.\n"); 682 IWL_DEBUG_HC(priv, "Scan request while uninitialized. Queuing.\n");
683 goto done; 683 goto done;
684 } 684 }
685 685
686 if (!priv->scan_bands) { 686 if (!priv->scan_bands) {
687 IWL_DEBUG_HC("Aborting scan due to no requested bands\n"); 687 IWL_DEBUG_HC(priv, "Aborting scan due to no requested bands\n");
688 goto done; 688 goto done;
689 } 689 }
690 690
@@ -709,7 +709,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
709 u32 scan_suspend_time = 100; 709 u32 scan_suspend_time = 100;
710 unsigned long flags; 710 unsigned long flags;
711 711
712 IWL_DEBUG_INFO("Scanning while associated...\n"); 712 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
713 713
714 spin_lock_irqsave(&priv->lock, flags); 714 spin_lock_irqsave(&priv->lock, flags);
715 interval = priv->beacon_int; 715 interval = priv->beacon_int;
@@ -724,13 +724,13 @@ static void iwl_bg_request_scan(struct work_struct *data)
724 scan_suspend_time = (extra | 724 scan_suspend_time = (extra |
725 ((suspend_time % interval) * 1024)); 725 ((suspend_time % interval) * 1024));
726 scan->suspend_time = cpu_to_le32(scan_suspend_time); 726 scan->suspend_time = cpu_to_le32(scan_suspend_time);
727 IWL_DEBUG_SCAN("suspend_time 0x%X beacon interval %d\n", 727 IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n",
728 scan_suspend_time, interval); 728 scan_suspend_time, interval);
729 } 729 }
730 730
731 /* We should add the ability for user to lock to PASSIVE ONLY */ 731 /* We should add the ability for user to lock to PASSIVE ONLY */
732 if (priv->one_direct_scan) { 732 if (priv->one_direct_scan) {
733 IWL_DEBUG_SCAN("Start direct scan for '%s'\n", 733 IWL_DEBUG_SCAN(priv, "Start direct scan for '%s'\n",
734 print_ssid(ssid, priv->direct_ssid, 734 print_ssid(ssid, priv->direct_ssid,
735 priv->direct_ssid_len)); 735 priv->direct_ssid_len));
736 scan->direct_scan[0].id = WLAN_EID_SSID; 736 scan->direct_scan[0].id = WLAN_EID_SSID;
@@ -739,7 +739,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
739 priv->direct_ssid, priv->direct_ssid_len); 739 priv->direct_ssid, priv->direct_ssid_len);
740 n_probes++; 740 n_probes++;
741 } else { 741 } else {
742 IWL_DEBUG_SCAN("Start indirect scan.\n"); 742 IWL_DEBUG_SCAN(priv, "Start indirect scan.\n");
743 } 743 }
744 744
745 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; 745 scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
@@ -801,7 +801,7 @@ static void iwl_bg_request_scan(struct work_struct *data)
801 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 801 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
802 802
803 if (scan->channel_count == 0) { 803 if (scan->channel_count == 0) {
804 IWL_DEBUG_SCAN("channel count %d\n", scan->channel_count); 804 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
805 goto done; 805 goto done;
806 } 806 }
807 807
@@ -855,7 +855,7 @@ void iwl_bg_scan_completed(struct work_struct *work)
855 struct iwl_priv *priv = 855 struct iwl_priv *priv =
856 container_of(work, struct iwl_priv, scan_completed); 856 container_of(work, struct iwl_priv, scan_completed);
857 857
858 IWL_DEBUG_SCAN("SCAN complete scan\n"); 858 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n");
859 859
860 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 860 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
861 return; 861 return;
diff --git a/drivers/net/wireless/iwlwifi/iwl-spectrum.c b/drivers/net/wireless/iwlwifi/iwl-spectrum.c
index aba1ef22fc61..022bcf115731 100644
--- a/drivers/net/wireless/iwlwifi/iwl-spectrum.c
+++ b/drivers/net/wireless/iwlwifi/iwl-spectrum.c
@@ -154,9 +154,9 @@ static int iwl_get_measurement(struct iwl_priv *priv,
154 switch (spectrum_resp_status) { 154 switch (spectrum_resp_status) {
155 case 0: /* Command will be handled */ 155 case 0: /* Command will be handled */
156 if (res->u.spectrum.id != 0xff) { 156 if (res->u.spectrum.id != 0xff) {
157 IWL_DEBUG_INFO 157 IWL_DEBUG_INFO(priv,
158 ("Replaced existing measurement: %d\n", 158 "Replaced existing measurement: %d\n",
159 res->u.spectrum.id); 159 res->u.spectrum.id);
160 priv->measurement_status &= ~MEASUREMENT_READY; 160 priv->measurement_status &= ~MEASUREMENT_READY;
161 } 161 }
162 priv->measurement_status |= MEASUREMENT_ACTIVE; 162 priv->measurement_status |= MEASUREMENT_ACTIVE;
@@ -181,7 +181,7 @@ static void iwl_rx_spectrum_measure_notif(struct iwl_priv *priv,
181 struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif); 181 struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif);
182 182
183 if (!report->state) { 183 if (!report->state) {
184 IWL_DEBUG(IWL_DL_11H, 184 IWL_DEBUG_11H(priv,
185 "Spectrum Measure Notification: Start\n"); 185 "Spectrum Measure Notification: Start\n");
186 return; 186 return;
187 } 187 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 20dc84152d4f..1fae3a6bd8d5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -60,7 +60,7 @@ u8 iwl_find_station(struct iwl_priv *priv, const u8 *addr)
60 goto out; 60 goto out;
61 } 61 }
62 62
63 IWL_DEBUG_ASSOC_LIMIT("can not find STA %pM total %d\n", 63 IWL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n",
64 addr, priv->num_stations); 64 addr, priv->num_stations);
65 65
66 out: 66 out:
@@ -92,7 +92,7 @@ static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
92 sta_id); 92 sta_id);
93 93
94 priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE; 94 priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE;
95 IWL_DEBUG_ASSOC("Added STA to Ucode: %pM\n", 95 IWL_DEBUG_ASSOC(priv, "Added STA to Ucode: %pM\n",
96 priv->stations[sta_id].sta.sta.addr); 96 priv->stations[sta_id].sta.sta.addr);
97 97
98 spin_unlock_irqrestore(&priv->sta_lock, flags); 98 spin_unlock_irqrestore(&priv->sta_lock, flags);
@@ -123,7 +123,7 @@ static int iwl_add_sta_callback(struct iwl_priv *priv,
123 iwl_sta_ucode_activate(priv, sta_id); 123 iwl_sta_ucode_activate(priv, sta_id);
124 /* fall through */ 124 /* fall through */
125 default: 125 default:
126 IWL_DEBUG_HC("Received REPLY_ADD_STA:(0x%08X)\n", 126 IWL_DEBUG_HC(priv, "Received REPLY_ADD_STA:(0x%08X)\n",
127 res->u.add_sta.status); 127 res->u.add_sta.status);
128 break; 128 break;
129 } 129 }
@@ -166,7 +166,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
166 switch (res->u.add_sta.status) { 166 switch (res->u.add_sta.status) {
167 case ADD_STA_SUCCESS_MSK: 167 case ADD_STA_SUCCESS_MSK:
168 iwl_sta_ucode_activate(priv, sta->sta.sta_id); 168 iwl_sta_ucode_activate(priv, sta->sta.sta_id);
169 IWL_DEBUG_INFO("REPLY_ADD_STA PASSED\n"); 169 IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n");
170 break; 170 break;
171 default: 171 default:
172 ret = -EIO; 172 ret = -EIO;
@@ -272,7 +272,7 @@ u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
272 272
273 station = &priv->stations[sta_id]; 273 station = &priv->stations[sta_id];
274 station->used = IWL_STA_DRIVER_ACTIVE; 274 station->used = IWL_STA_DRIVER_ACTIVE;
275 IWL_DEBUG_ASSOC("Add STA to driver ID %d: %pM\n", 275 IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n",
276 sta_id, addr); 276 sta_id, addr);
277 priv->num_stations++; 277 priv->num_stations++;
278 278
@@ -304,7 +304,7 @@ static void iwl_sta_ucode_deactivate(struct iwl_priv *priv, const char *addr)
304 304
305 BUG_ON(sta_id == IWL_INVALID_STATION); 305 BUG_ON(sta_id == IWL_INVALID_STATION);
306 306
307 IWL_DEBUG_ASSOC("Removed STA from Ucode: %pM\n", addr); 307 IWL_DEBUG_ASSOC(priv, "Removed STA from Ucode: %pM\n", addr);
308 308
309 spin_lock_irqsave(&priv->sta_lock, flags); 309 spin_lock_irqsave(&priv->sta_lock, flags);
310 310
@@ -390,7 +390,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr,
390 switch (res->u.rem_sta.status) { 390 switch (res->u.rem_sta.status) {
391 case REM_STA_SUCCESS_MSK: 391 case REM_STA_SUCCESS_MSK:
392 iwl_sta_ucode_deactivate(priv, addr); 392 iwl_sta_ucode_deactivate(priv, addr);
393 IWL_DEBUG_ASSOC("REPLY_REMOVE_STA PASSED\n"); 393 IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n");
394 break; 394 break;
395 default: 395 default:
396 ret = -EIO; 396 ret = -EIO;
@@ -432,7 +432,7 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap)
432 if (unlikely(sta_id == IWL_INVALID_STATION)) 432 if (unlikely(sta_id == IWL_INVALID_STATION))
433 goto out; 433 goto out;
434 434
435 IWL_DEBUG_ASSOC("Removing STA from driver:%d %pM\n", 435 IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n",
436 sta_id, addr); 436 sta_id, addr);
437 437
438 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { 438 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) {
@@ -560,7 +560,7 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
560 priv->default_wep_key--; 560 priv->default_wep_key--;
561 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); 561 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0]));
562 ret = iwl_send_static_wepkey_cmd(priv, 1); 562 ret = iwl_send_static_wepkey_cmd(priv, 1);
563 IWL_DEBUG_WEP("Remove default WEP key: idx=%d ret=%d\n", 563 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n",
564 keyconf->keyidx, ret); 564 keyconf->keyidx, ret);
565 spin_unlock_irqrestore(&priv->sta_lock, flags); 565 spin_unlock_irqrestore(&priv->sta_lock, flags);
566 566
@@ -576,7 +576,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
576 576
577 if (keyconf->keylen != WEP_KEY_LEN_128 && 577 if (keyconf->keylen != WEP_KEY_LEN_128 &&
578 keyconf->keylen != WEP_KEY_LEN_64) { 578 keyconf->keylen != WEP_KEY_LEN_64) {
579 IWL_DEBUG_WEP("Bad WEP key length %d\n", keyconf->keylen); 579 IWL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen);
580 return -EINVAL; 580 return -EINVAL;
581 } 581 }
582 582
@@ -596,7 +596,7 @@ int iwl_set_default_wep_key(struct iwl_priv *priv,
596 keyconf->keylen); 596 keyconf->keylen);
597 597
598 ret = iwl_send_static_wepkey_cmd(priv, 0); 598 ret = iwl_send_static_wepkey_cmd(priv, 0);
599 IWL_DEBUG_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", 599 IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n",
600 keyconf->keylen, keyconf->keyidx, ret); 600 keyconf->keylen, keyconf->keyidx, ret);
601 spin_unlock_irqrestore(&priv->sta_lock, flags); 601 spin_unlock_irqrestore(&priv->sta_lock, flags);
602 602
@@ -752,7 +752,7 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
752 752
753 sta_id = iwl_find_station(priv, addr); 753 sta_id = iwl_find_station(priv, addr);
754 if (sta_id == IWL_INVALID_STATION) { 754 if (sta_id == IWL_INVALID_STATION) {
755 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n", 755 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
756 addr); 756 addr);
757 return; 757 return;
758 } 758 }
@@ -804,7 +804,7 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
804 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); 804 key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags);
805 keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; 805 keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3;
806 806
807 IWL_DEBUG_WEP("Remove dynamic key: idx=%d sta=%d\n", 807 IWL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n",
808 keyconf->keyidx, sta_id); 808 keyconf->keyidx, sta_id);
809 809
810 if (keyconf->keyidx != keyidx) { 810 if (keyconf->keyidx != keyidx) {
@@ -868,7 +868,7 @@ int iwl_set_dynamic_key(struct iwl_priv *priv,
868 ret = -EINVAL; 868 ret = -EINVAL;
869 } 869 }
870 870
871 IWL_DEBUG_WEP("Set dynamic key: alg= %d len=%d idx=%d sta=%d ret=%d\n", 871 IWL_DEBUG_WEP(priv, "Set dynamic key: alg= %d len=%d idx=%d sta=%d ret=%d\n",
872 keyconf->alg, keyconf->keylen, keyconf->keyidx, 872 keyconf->alg, keyconf->keylen, keyconf->keyidx,
873 sta_id, ret); 873 sta_id, ret);
874 874
@@ -881,13 +881,13 @@ static void iwl_dump_lq_cmd(struct iwl_priv *priv,
881 struct iwl_link_quality_cmd *lq) 881 struct iwl_link_quality_cmd *lq)
882{ 882{
883 int i; 883 int i;
884 IWL_DEBUG_RATE("lq station id 0x%x\n", lq->sta_id); 884 IWL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id);
885 IWL_DEBUG_RATE("lq ant 0x%X 0x%X\n", 885 IWL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n",
886 lq->general_params.single_stream_ant_msk, 886 lq->general_params.single_stream_ant_msk,
887 lq->general_params.dual_stream_ant_msk); 887 lq->general_params.dual_stream_ant_msk);
888 888
889 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) 889 for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++)
890 IWL_DEBUG_RATE("lq index %d 0x%X\n", 890 IWL_DEBUG_RATE(priv, "lq index %d 0x%X\n",
891 i, lq->rs_table[i].rate_n_flags); 891 i, lq->rs_table[i].rate_n_flags);
892} 892}
893#else 893#else
@@ -1064,7 +1064,7 @@ int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
1064 if (sta_id != IWL_INVALID_STATION) 1064 if (sta_id != IWL_INVALID_STATION)
1065 return sta_id; 1065 return sta_id;
1066 1066
1067 IWL_DEBUG_DROP("Station %pM not in station map. " 1067 IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
1068 "Defaulting to broadcast...\n", 1068 "Defaulting to broadcast...\n",
1069 hdr->addr1); 1069 hdr->addr1);
1070 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); 1070 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 7d2b6e11f73e..ae04c2086f70 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -96,7 +96,7 @@ int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq)
96 reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); 96 reg = iwl_read32(priv, CSR_UCODE_DRV_GP1);
97 97
98 if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { 98 if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
99 IWL_DEBUG_INFO("Requesting wakeup, GP1 = 0x%x\n", reg); 99 IWL_DEBUG_INFO(priv, "Requesting wakeup, GP1 = 0x%x\n", reg);
100 iwl_set_bit(priv, CSR_GP_CNTRL, 100 iwl_set_bit(priv, CSR_GP_CNTRL,
101 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); 101 CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
102 return ret; 102 return ret;
@@ -638,14 +638,14 @@ static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
638 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); 638 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
639 if (info->flags & IEEE80211_TX_CTL_AMPDU) 639 if (info->flags & IEEE80211_TX_CTL_AMPDU)
640 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; 640 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK;
641 IWL_DEBUG_TX("tx_cmd with AES hwcrypto\n"); 641 IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n");
642 break; 642 break;
643 643
644 case ALG_TKIP: 644 case ALG_TKIP:
645 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; 645 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
646 ieee80211_get_tkip_key(keyconf, skb_frag, 646 ieee80211_get_tkip_key(keyconf, skb_frag,
647 IEEE80211_TKIP_P2_KEY, tx_cmd->key); 647 IEEE80211_TKIP_P2_KEY, tx_cmd->key);
648 IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n"); 648 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
649 break; 649 break;
650 650
651 case ALG_WEP: 651 case ALG_WEP:
@@ -657,7 +657,7 @@ static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
657 657
658 memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); 658 memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen);
659 659
660 IWL_DEBUG_TX("Configuring packet for WEP encryption " 660 IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption "
661 "with key %d\n", keyconf->keyidx); 661 "with key %d\n", keyconf->keyidx);
662 break; 662 break;
663 663
@@ -703,7 +703,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
703 703
704 spin_lock_irqsave(&priv->lock, flags); 704 spin_lock_irqsave(&priv->lock, flags);
705 if (iwl_is_rfkill(priv)) { 705 if (iwl_is_rfkill(priv)) {
706 IWL_DEBUG_DROP("Dropping - RF KILL\n"); 706 IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n");
707 goto drop_unlock; 707 goto drop_unlock;
708 } 708 }
709 709
@@ -717,11 +717,11 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
717 717
718#ifdef CONFIG_IWLWIFI_DEBUG 718#ifdef CONFIG_IWLWIFI_DEBUG
719 if (ieee80211_is_auth(fc)) 719 if (ieee80211_is_auth(fc))
720 IWL_DEBUG_TX("Sending AUTH frame\n"); 720 IWL_DEBUG_TX(priv, "Sending AUTH frame\n");
721 else if (ieee80211_is_assoc_req(fc)) 721 else if (ieee80211_is_assoc_req(fc))
722 IWL_DEBUG_TX("Sending ASSOC frame\n"); 722 IWL_DEBUG_TX(priv, "Sending ASSOC frame\n");
723 else if (ieee80211_is_reassoc_req(fc)) 723 else if (ieee80211_is_reassoc_req(fc))
724 IWL_DEBUG_TX("Sending REASSOC frame\n"); 724 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
725#endif 725#endif
726 726
727 /* drop all data frame if we are not associated */ 727 /* drop all data frame if we are not associated */
@@ -731,7 +731,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
731 (!iwl_is_associated(priv) || 731 (!iwl_is_associated(priv) ||
732 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) || 732 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) ||
733 !priv->assoc_station_added)) { 733 !priv->assoc_station_added)) {
734 IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n"); 734 IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n");
735 goto drop_unlock; 735 goto drop_unlock;
736 } 736 }
737 737
@@ -742,12 +742,12 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
742 /* Find (or create) index into station table for destination station */ 742 /* Find (or create) index into station table for destination station */
743 sta_id = iwl_get_sta_id(priv, hdr); 743 sta_id = iwl_get_sta_id(priv, hdr);
744 if (sta_id == IWL_INVALID_STATION) { 744 if (sta_id == IWL_INVALID_STATION) {
745 IWL_DEBUG_DROP("Dropping - INVALID STATION: %pM\n", 745 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
746 hdr->addr1); 746 hdr->addr1);
747 goto drop; 747 goto drop;
748 } 748 }
749 749
750 IWL_DEBUG_TX("station Id %d\n", sta_id); 750 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id);
751 751
752 swq_id = skb_get_queue_mapping(skb); 752 swq_id = skb_get_queue_mapping(skb);
753 txq_id = swq_id; 753 txq_id = swq_id;
@@ -757,7 +757,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
757 seq_number = priv->stations[sta_id].tid[tid].seq_number; 757 seq_number = priv->stations[sta_id].tid[tid].seq_number;
758 seq_number &= IEEE80211_SCTL_SEQ; 758 seq_number &= IEEE80211_SCTL_SEQ;
759 hdr->seq_ctrl = hdr->seq_ctrl & 759 hdr->seq_ctrl = hdr->seq_ctrl &
760 __constant_cpu_to_le16(IEEE80211_SCTL_FRAG); 760 cpu_to_le16(IEEE80211_SCTL_FRAG);
761 hdr->seq_ctrl |= cpu_to_le16(seq_number); 761 hdr->seq_ctrl |= cpu_to_le16(seq_number);
762 seq_number += 0x10; 762 seq_number += 0x10;
763 /* aggregation is on for this <sta,tid> */ 763 /* aggregation is on for this <sta,tid> */
@@ -938,7 +938,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
938 !(cmd->meta.flags & CMD_SIZE_HUGE)); 938 !(cmd->meta.flags & CMD_SIZE_HUGE));
939 939
940 if (iwl_is_rfkill(priv)) { 940 if (iwl_is_rfkill(priv)) {
941 IWL_DEBUG_INFO("Not sending command - RF KILL"); 941 IWL_DEBUG_INFO(priv, "Not sending command - RF KILL");
942 return -EIO; 942 return -EIO;
943 } 943 }
944 944
@@ -981,7 +981,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
981 switch (out_cmd->hdr.cmd) { 981 switch (out_cmd->hdr.cmd) {
982 case REPLY_TX_LINK_QUALITY_CMD: 982 case REPLY_TX_LINK_QUALITY_CMD:
983 case SENSITIVITY_CMD: 983 case SENSITIVITY_CMD:
984 IWL_DEBUG_HC_DUMP("Sending command %s (#%x), seq: 0x%04X, " 984 IWL_DEBUG_HC_DUMP(priv, "Sending command %s (#%x), seq: 0x%04X, "
985 "%d bytes at %d[%d]:%d\n", 985 "%d bytes at %d[%d]:%d\n",
986 get_cmd_string(out_cmd->hdr.cmd), 986 get_cmd_string(out_cmd->hdr.cmd),
987 out_cmd->hdr.cmd, 987 out_cmd->hdr.cmd,
@@ -989,7 +989,7 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
989 q->write_ptr, idx, IWL_CMD_QUEUE_NUM); 989 q->write_ptr, idx, IWL_CMD_QUEUE_NUM);
990 break; 990 break;
991 default: 991 default:
992 IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, " 992 IWL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, "
993 "%d bytes at %d[%d]:%d\n", 993 "%d bytes at %d[%d]:%d\n",
994 get_cmd_string(out_cmd->hdr.cmd), 994 get_cmd_string(out_cmd->hdr.cmd),
995 out_cmd->hdr.cmd, 995 out_cmd->hdr.cmd,
@@ -1194,7 +1194,7 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
1194 tid_data->agg.state = IWL_AGG_ON; 1194 tid_data->agg.state = IWL_AGG_ON;
1195 ieee80211_start_tx_ba_cb_irqsafe(priv->hw, ra, tid); 1195 ieee80211_start_tx_ba_cb_irqsafe(priv->hw, ra, tid);
1196 } else { 1196 } else {
1197 IWL_DEBUG_HT("HW queue is NOT empty: %d packets in HW queue\n", 1197 IWL_DEBUG_HT(priv, "HW queue is NOT empty: %d packets in HW queue\n",
1198 tid_data->tfds_in_queue); 1198 tid_data->tfds_in_queue);
1199 tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; 1199 tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA;
1200 } 1200 }
@@ -1235,13 +1235,13 @@ int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
1235 1235
1236 /* The queue is not empty */ 1236 /* The queue is not empty */
1237 if (write_ptr != read_ptr) { 1237 if (write_ptr != read_ptr) {
1238 IWL_DEBUG_HT("Stopping a non empty AGG HW QUEUE\n"); 1238 IWL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n");
1239 priv->stations[sta_id].tid[tid].agg.state = 1239 priv->stations[sta_id].tid[tid].agg.state =
1240 IWL_EMPTYING_HW_QUEUE_DELBA; 1240 IWL_EMPTYING_HW_QUEUE_DELBA;
1241 return 0; 1241 return 0;
1242 } 1242 }
1243 1243
1244 IWL_DEBUG_HT("HW queue is empty\n"); 1244 IWL_DEBUG_HT(priv, "HW queue is empty\n");
1245 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; 1245 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
1246 1246
1247 spin_lock_irqsave(&priv->lock, flags); 1247 spin_lock_irqsave(&priv->lock, flags);
@@ -1272,7 +1272,7 @@ int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id)
1272 (q->read_ptr == q->write_ptr)) { 1272 (q->read_ptr == q->write_ptr)) {
1273 u16 ssn = SEQ_TO_SN(tid_data->seq_number); 1273 u16 ssn = SEQ_TO_SN(tid_data->seq_number);
1274 int tx_fifo = default_tid_to_tx_fifo[tid]; 1274 int tx_fifo = default_tid_to_tx_fifo[tid];
1275 IWL_DEBUG_HT("HW queue empty: continue DELBA flow\n"); 1275 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n");
1276 priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, 1276 priv->cfg->ops->lib->txq_agg_disable(priv, txq_id,
1277 ssn, tx_fifo); 1277 ssn, tx_fifo);
1278 tid_data->agg.state = IWL_AGG_OFF; 1278 tid_data->agg.state = IWL_AGG_OFF;
@@ -1282,7 +1282,7 @@ int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id)
1282 case IWL_EMPTYING_HW_QUEUE_ADDBA: 1282 case IWL_EMPTYING_HW_QUEUE_ADDBA:
1283 /* We are reclaiming the last packet of the queue */ 1283 /* We are reclaiming the last packet of the queue */
1284 if (tid_data->tfds_in_queue == 0) { 1284 if (tid_data->tfds_in_queue == 0) {
1285 IWL_DEBUG_HT("HW queue empty: continue ADDBA flow\n"); 1285 IWL_DEBUG_HT(priv, "HW queue empty: continue ADDBA flow\n");
1286 tid_data->agg.state = IWL_AGG_ON; 1286 tid_data->agg.state = IWL_AGG_ON;
1287 ieee80211_start_tx_ba_cb_irqsafe(priv->hw, addr, tid); 1287 ieee80211_start_tx_ba_cb_irqsafe(priv->hw, addr, tid);
1288 } 1288 }
@@ -1317,7 +1317,7 @@ static int iwl_tx_status_reply_compressed_ba(struct iwl_priv *priv,
1317 1317
1318 /* Mark that the expected block-ack response arrived */ 1318 /* Mark that the expected block-ack response arrived */
1319 agg->wait_for_ba = 0; 1319 agg->wait_for_ba = 0;
1320 IWL_DEBUG_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); 1320 IWL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, ba_resp->seq_ctl);
1321 1321
1322 /* Calculate shift to align block-ack bits with our Tx window bits */ 1322 /* Calculate shift to align block-ack bits with our Tx window bits */
1323 sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4); 1323 sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4);
@@ -1328,7 +1328,7 @@ static int iwl_tx_status_reply_compressed_ba(struct iwl_priv *priv,
1328 bitmap = le64_to_cpu(ba_resp->bitmap) >> sh; 1328 bitmap = le64_to_cpu(ba_resp->bitmap) >> sh;
1329 1329
1330 if (agg->frame_count > (64 - sh)) { 1330 if (agg->frame_count > (64 - sh)) {
1331 IWL_DEBUG_TX_REPLY("more frames than bitmap size"); 1331 IWL_DEBUG_TX_REPLY(priv, "more frames than bitmap size");
1332 return -1; 1332 return -1;
1333 } 1333 }
1334 1334
@@ -1341,7 +1341,7 @@ static int iwl_tx_status_reply_compressed_ba(struct iwl_priv *priv,
1341 for (i = 0; i < agg->frame_count ; i++) { 1341 for (i = 0; i < agg->frame_count ; i++) {
1342 ack = bitmap & (1ULL << i); 1342 ack = bitmap & (1ULL << i);
1343 successes += !!ack; 1343 successes += !!ack;
1344 IWL_DEBUG_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", 1344 IWL_DEBUG_TX_REPLY(priv, "%s ON i=%d idx=%d raw=%d\n",
1345 ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff, 1345 ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff,
1346 agg->start_idx + i); 1346 agg->start_idx + i);
1347 } 1347 }
@@ -1354,7 +1354,7 @@ static int iwl_tx_status_reply_compressed_ba(struct iwl_priv *priv,
1354 info->status.ampdu_ack_len = agg->frame_count; 1354 info->status.ampdu_ack_len = agg->frame_count;
1355 iwl_hwrate_to_tx_control(priv, agg->rate_n_flags, info); 1355 iwl_hwrate_to_tx_control(priv, agg->rate_n_flags, info);
1356 1356
1357 IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); 1357 IWL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", (unsigned long long)bitmap);
1358 1358
1359 return 0; 1359 return 0;
1360} 1360}
@@ -1399,19 +1399,19 @@ void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
1399 1399
1400 /* TODO: Need to get this copy more safely - now good for debug */ 1400 /* TODO: Need to get this copy more safely - now good for debug */
1401 1401
1402 IWL_DEBUG_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " 1402 IWL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, "
1403 "sta_id = %d\n", 1403 "sta_id = %d\n",
1404 agg->wait_for_ba, 1404 agg->wait_for_ba,
1405 (u8 *) &ba_resp->sta_addr_lo32, 1405 (u8 *) &ba_resp->sta_addr_lo32,
1406 ba_resp->sta_id); 1406 ba_resp->sta_id);
1407 IWL_DEBUG_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = " 1407 IWL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = "
1408 "%d, scd_ssn = %d\n", 1408 "%d, scd_ssn = %d\n",
1409 ba_resp->tid, 1409 ba_resp->tid,
1410 ba_resp->seq_ctl, 1410 ba_resp->seq_ctl,
1411 (unsigned long long)le64_to_cpu(ba_resp->bitmap), 1411 (unsigned long long)le64_to_cpu(ba_resp->bitmap),
1412 ba_resp->scd_flow, 1412 ba_resp->scd_flow,
1413 ba_resp->scd_ssn); 1413 ba_resp->scd_ssn);
1414 IWL_DEBUG_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx \n", 1414 IWL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx \n",
1415 agg->start_idx, 1415 agg->start_idx,
1416 (unsigned long long)agg->bitmap); 1416 (unsigned long long)agg->bitmap);
1417 1417
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 25a350810a10..42cc2884971c 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -203,7 +203,7 @@ u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap, u8 flag
203 return index; 203 return index;
204 } 204 }
205 205
206 IWL_DEBUG_ASSOC("Add STA ID %d: %pM\n", index, addr); 206 IWL_DEBUG_ASSOC(priv, "Add STA ID %d: %pM\n", index, addr);
207 station = &priv->stations_39[index]; 207 station = &priv->stations_39[index];
208 station->used = 1; 208 station->used = 1;
209 priv->num_stations++; 209 priv->num_stations++;
@@ -233,166 +233,6 @@ u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap, u8 flag
233 233
234} 234}
235 235
236/**
237 * iwl3945_set_rxon_channel - Set the phymode and channel values in staging RXON
238 * @band: 2.4 or 5 GHz band
239 * @channel: Any channel valid for the requested band
240
241 * In addition to setting the staging RXON, priv->band is also set.
242 *
243 * NOTE: Does not commit to the hardware; it sets appropriate bit fields
244 * in the staging RXON flag structure based on the band
245 */
246static int iwl3945_set_rxon_channel(struct iwl_priv *priv,
247 enum ieee80211_band band,
248 u16 channel)
249{
250 if (!iwl_get_channel_info(priv, band, channel)) {
251 IWL_DEBUG_INFO("Could not set channel to %d [%d]\n",
252 channel, band);
253 return -EINVAL;
254 }
255
256 if ((le16_to_cpu(priv->staging39_rxon.channel) == channel) &&
257 (priv->band == band))
258 return 0;
259
260 priv->staging39_rxon.channel = cpu_to_le16(channel);
261 if (band == IEEE80211_BAND_5GHZ)
262 priv->staging39_rxon.flags &= ~RXON_FLG_BAND_24G_MSK;
263 else
264 priv->staging39_rxon.flags |= RXON_FLG_BAND_24G_MSK;
265
266 priv->band = band;
267
268 IWL_DEBUG_INFO("Staging channel set to %d [%d]\n", channel, band);
269
270 return 0;
271}
272
273/**
274 * iwl3945_check_rxon_cmd - validate RXON structure is valid
275 *
276 * NOTE: This is really only useful during development and can eventually
277 * be #ifdef'd out once the driver is stable and folks aren't actively
278 * making changes
279 */
280static int iwl3945_check_rxon_cmd(struct iwl_priv *priv)
281{
282 int error = 0;
283 int counter = 1;
284 struct iwl3945_rxon_cmd *rxon = &priv->staging39_rxon;
285
286 if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
287 error |= le32_to_cpu(rxon->flags &
288 (RXON_FLG_TGJ_NARROW_BAND_MSK |
289 RXON_FLG_RADAR_DETECT_MSK));
290 if (error)
291 IWL_WARN(priv, "check 24G fields %d | %d\n",
292 counter++, error);
293 } else {
294 error |= (rxon->flags & RXON_FLG_SHORT_SLOT_MSK) ?
295 0 : le32_to_cpu(RXON_FLG_SHORT_SLOT_MSK);
296 if (error)
297 IWL_WARN(priv, "check 52 fields %d | %d\n",
298 counter++, error);
299 error |= le32_to_cpu(rxon->flags & RXON_FLG_CCK_MSK);
300 if (error)
301 IWL_WARN(priv, "check 52 CCK %d | %d\n",
302 counter++, error);
303 }
304 error |= (rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1;
305 if (error)
306 IWL_WARN(priv, "check mac addr %d | %d\n", counter++, error);
307
308 /* make sure basic rates 6Mbps and 1Mbps are supported */
309 error |= (((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0) &&
310 ((rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0));
311 if (error)
312 IWL_WARN(priv, "check basic rate %d | %d\n", counter++, error);
313
314 error |= (le16_to_cpu(rxon->assoc_id) > 2007);
315 if (error)
316 IWL_WARN(priv, "check assoc id %d | %d\n", counter++, error);
317
318 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK))
319 == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK));
320 if (error)
321 IWL_WARN(priv, "check CCK and short slot %d | %d\n",
322 counter++, error);
323
324 error |= ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK))
325 == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK));
326 if (error)
327 IWL_WARN(priv, "check CCK & auto detect %d | %d\n",
328 counter++, error);
329
330 error |= ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK |
331 RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK);
332 if (error)
333 IWL_WARN(priv, "check TGG and auto detect %d | %d\n",
334 counter++, error);
335
336 if ((rxon->flags & RXON_FLG_DIS_DIV_MSK))
337 error |= ((rxon->flags & (RXON_FLG_ANT_B_MSK |
338 RXON_FLG_ANT_A_MSK)) == 0);
339 if (error)
340 IWL_WARN(priv, "check antenna %d %d\n", counter++, error);
341
342 if (error)
343 IWL_WARN(priv, "Tuning to channel %d\n",
344 le16_to_cpu(rxon->channel));
345
346 if (error) {
347 IWL_ERR(priv, "Not a valid rxon_assoc_cmd field values\n");
348 return -1;
349 }
350 return 0;
351}
352
353/**
354 * iwl3945_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed
355 * @priv: staging_rxon is compared to active_rxon
356 *
357 * If the RXON structure is changing enough to require a new tune,
358 * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that
359 * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required.
360 */
361static int iwl3945_full_rxon_required(struct iwl_priv *priv)
362{
363
364 /* These items are only settable from the full RXON command */
365 if (!(iwl3945_is_associated(priv)) ||
366 compare_ether_addr(priv->staging39_rxon.bssid_addr,
367 priv->active39_rxon.bssid_addr) ||
368 compare_ether_addr(priv->staging39_rxon.node_addr,
369 priv->active39_rxon.node_addr) ||
370 compare_ether_addr(priv->staging39_rxon.wlap_bssid_addr,
371 priv->active39_rxon.wlap_bssid_addr) ||
372 (priv->staging39_rxon.dev_type != priv->active39_rxon.dev_type) ||
373 (priv->staging39_rxon.channel != priv->active39_rxon.channel) ||
374 (priv->staging39_rxon.air_propagation !=
375 priv->active39_rxon.air_propagation) ||
376 (priv->staging39_rxon.assoc_id != priv->active39_rxon.assoc_id))
377 return 1;
378
379 /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can
380 * be updated with the RXON_ASSOC command -- however only some
381 * flag transitions are allowed using RXON_ASSOC */
382
383 /* Check if we are not switching bands */
384 if ((priv->staging39_rxon.flags & RXON_FLG_BAND_24G_MSK) !=
385 (priv->active39_rxon.flags & RXON_FLG_BAND_24G_MSK))
386 return 1;
387
388 /* Check if we are switching association toggle */
389 if ((priv->staging39_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) !=
390 (priv->active39_rxon.filter_flags & RXON_FILTER_ASSOC_MSK))
391 return 1;
392
393 return 0;
394}
395
396static int iwl3945_send_rxon_assoc(struct iwl_priv *priv) 236static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
397{ 237{
398 int rc = 0; 238 int rc = 0;
@@ -404,21 +244,21 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
404 .meta.flags = CMD_WANT_SKB, 244 .meta.flags = CMD_WANT_SKB,
405 .data = &rxon_assoc, 245 .data = &rxon_assoc,
406 }; 246 };
407 const struct iwl3945_rxon_cmd *rxon1 = &priv->staging39_rxon; 247 const struct iwl_rxon_cmd *rxon1 = &priv->staging_rxon;
408 const struct iwl3945_rxon_cmd *rxon2 = &priv->active39_rxon; 248 const struct iwl_rxon_cmd *rxon2 = &priv->active_rxon;
409 249
410 if ((rxon1->flags == rxon2->flags) && 250 if ((rxon1->flags == rxon2->flags) &&
411 (rxon1->filter_flags == rxon2->filter_flags) && 251 (rxon1->filter_flags == rxon2->filter_flags) &&
412 (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && 252 (rxon1->cck_basic_rates == rxon2->cck_basic_rates) &&
413 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { 253 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) {
414 IWL_DEBUG_INFO("Using current RXON_ASSOC. Not resending.\n"); 254 IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n");
415 return 0; 255 return 0;
416 } 256 }
417 257
418 rxon_assoc.flags = priv->staging39_rxon.flags; 258 rxon_assoc.flags = priv->staging_rxon.flags;
419 rxon_assoc.filter_flags = priv->staging39_rxon.filter_flags; 259 rxon_assoc.filter_flags = priv->staging_rxon.filter_flags;
420 rxon_assoc.ofdm_basic_rates = priv->staging39_rxon.ofdm_basic_rates; 260 rxon_assoc.ofdm_basic_rates = priv->staging_rxon.ofdm_basic_rates;
421 rxon_assoc.cck_basic_rates = priv->staging39_rxon.cck_basic_rates; 261 rxon_assoc.cck_basic_rates = priv->staging_rxon.cck_basic_rates;
422 rxon_assoc.reserved = 0; 262 rxon_assoc.reserved = 0;
423 263
424 rc = iwl_send_cmd_sync(priv, &cmd); 264 rc = iwl_send_cmd_sync(priv, &cmd);
@@ -485,21 +325,22 @@ __le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv)
485static int iwl3945_commit_rxon(struct iwl_priv *priv) 325static int iwl3945_commit_rxon(struct iwl_priv *priv)
486{ 326{
487 /* cast away the const for active_rxon in this function */ 327 /* cast away the const for active_rxon in this function */
488 struct iwl3945_rxon_cmd *active_rxon = (void *)&priv->active39_rxon; 328 struct iwl3945_rxon_cmd *active_rxon = (void *)&priv->active_rxon;
329 struct iwl3945_rxon_cmd *staging_rxon = (void *)&priv->staging_rxon;
489 int rc = 0; 330 int rc = 0;
490 331
491 if (!iwl_is_alive(priv)) 332 if (!iwl_is_alive(priv))
492 return -1; 333 return -1;
493 334
494 /* always get timestamp with Rx frame */ 335 /* always get timestamp with Rx frame */
495 priv->staging39_rxon.flags |= RXON_FLG_TSF2HOST_MSK; 336 staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK;
496 337
497 /* select antenna */ 338 /* select antenna */
498 priv->staging39_rxon.flags &= 339 staging_rxon->flags &=
499 ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); 340 ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK);
500 priv->staging39_rxon.flags |= iwl3945_get_antenna_flags(priv); 341 staging_rxon->flags |= iwl3945_get_antenna_flags(priv);
501 342
502 rc = iwl3945_check_rxon_cmd(priv); 343 rc = iwl_check_rxon_cmd(priv);
503 if (rc) { 344 if (rc) {
504 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); 345 IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n");
505 return -EINVAL; 346 return -EINVAL;
@@ -508,7 +349,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
508 /* If we don't need to send a full RXON, we can use 349 /* If we don't need to send a full RXON, we can use
509 * iwl3945_rxon_assoc_cmd which is used to reconfigure filter 350 * iwl3945_rxon_assoc_cmd which is used to reconfigure filter
510 * and other flags for the current radio configuration. */ 351 * and other flags for the current radio configuration. */
511 if (!iwl3945_full_rxon_required(priv)) { 352 if (!iwl_full_rxon_required(priv)) {
512 rc = iwl3945_send_rxon_assoc(priv); 353 rc = iwl3945_send_rxon_assoc(priv);
513 if (rc) { 354 if (rc) {
514 IWL_ERR(priv, "Error setting RXON_ASSOC " 355 IWL_ERR(priv, "Error setting RXON_ASSOC "
@@ -516,7 +357,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
516 return rc; 357 return rc;
517 } 358 }
518 359
519 memcpy(active_rxon, &priv->staging39_rxon, sizeof(*active_rxon)); 360 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
520 361
521 return 0; 362 return 0;
522 } 363 }
@@ -525,14 +366,20 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
525 * an RXON_ASSOC and the new config wants the associated mask enabled, 366 * an RXON_ASSOC and the new config wants the associated mask enabled,
526 * we must clear the associated from the active configuration 367 * we must clear the associated from the active configuration
527 * before we apply the new config */ 368 * before we apply the new config */
528 if (iwl3945_is_associated(priv) && 369 if (iwl_is_associated(priv) &&
529 (priv->staging39_rxon.filter_flags & RXON_FILTER_ASSOC_MSK)) { 370 (staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK)) {
530 IWL_DEBUG_INFO("Toggling associated bit on current RXON\n"); 371 IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n");
531 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 372 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
532 373
374 /*
375 * reserved4 and 5 could have been filled by the iwlcore code.
376 * Let's clear them before pushing to the 3945.
377 */
378 active_rxon->reserved4 = 0;
379 active_rxon->reserved5 = 0;
533 rc = iwl_send_cmd_pdu(priv, REPLY_RXON, 380 rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
534 sizeof(struct iwl3945_rxon_cmd), 381 sizeof(struct iwl3945_rxon_cmd),
535 &priv->active39_rxon); 382 &priv->active_rxon);
536 383
537 /* If the mask clearing failed then we set 384 /* If the mask clearing failed then we set
538 * active_rxon back to what it was previously */ 385 * active_rxon back to what it was previously */
@@ -544,24 +391,32 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
544 } 391 }
545 } 392 }
546 393
547 IWL_DEBUG_INFO("Sending RXON\n" 394 IWL_DEBUG_INFO(priv, "Sending RXON\n"
548 "* with%s RXON_FILTER_ASSOC_MSK\n" 395 "* with%s RXON_FILTER_ASSOC_MSK\n"
549 "* channel = %d\n" 396 "* channel = %d\n"
550 "* bssid = %pM\n", 397 "* bssid = %pM\n",
551 ((priv->staging39_rxon.filter_flags & 398 ((priv->staging_rxon.filter_flags &
552 RXON_FILTER_ASSOC_MSK) ? "" : "out"), 399 RXON_FILTER_ASSOC_MSK) ? "" : "out"),
553 le16_to_cpu(priv->staging39_rxon.channel), 400 le16_to_cpu(staging_rxon->channel),
554 priv->staging_rxon.bssid_addr); 401 staging_rxon->bssid_addr);
402
403 /*
404 * reserved4 and 5 could have been filled by the iwlcore code.
405 * Let's clear them before pushing to the 3945.
406 */
407 staging_rxon->reserved4 = 0;
408 staging_rxon->reserved5 = 0;
555 409
556 /* Apply the new configuration */ 410 /* Apply the new configuration */
557 rc = iwl_send_cmd_pdu(priv, REPLY_RXON, 411 rc = iwl_send_cmd_pdu(priv, REPLY_RXON,
558 sizeof(struct iwl3945_rxon_cmd), &priv->staging39_rxon); 412 sizeof(struct iwl3945_rxon_cmd),
413 staging_rxon);
559 if (rc) { 414 if (rc) {
560 IWL_ERR(priv, "Error setting new configuration (%d).\n", rc); 415 IWL_ERR(priv, "Error setting new configuration (%d).\n", rc);
561 return rc; 416 return rc;
562 } 417 }
563 418
564 memcpy(active_rxon, &priv->staging39_rxon, sizeof(*active_rxon)); 419 memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
565 420
566 iwl3945_clear_stations_table(priv); 421 iwl3945_clear_stations_table(priv);
567 422
@@ -582,9 +437,10 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
582 437
583 /* If we have set the ASSOC_MSK and we are in BSS mode then 438 /* If we have set the ASSOC_MSK and we are in BSS mode then
584 * add the IWL_AP_ID to the station rate table */ 439 * add the IWL_AP_ID to the station rate table */
585 if (iwl3945_is_associated(priv) && 440 if (iwl_is_associated(priv) &&
586 (priv->iw_mode == NL80211_IFTYPE_STATION)) 441 (priv->iw_mode == NL80211_IFTYPE_STATION))
587 if (iwl3945_add_station(priv, priv->active39_rxon.bssid_addr, 1, 0) 442 if (iwl3945_add_station(priv, priv->active_rxon.bssid_addr,
443 1, 0)
588 == IWL_INVALID_STATION) { 444 == IWL_INVALID_STATION) {
589 IWL_ERR(priv, "Error adding AP address for transmit\n"); 445 IWL_ERR(priv, "Error adding AP address for transmit\n");
590 return -EIO; 446 return -EIO;
@@ -633,7 +489,7 @@ static int iwl3945_update_sta_key_info(struct iwl_priv *priv,
633 489
634 spin_unlock_irqrestore(&priv->sta_lock, flags); 490 spin_unlock_irqrestore(&priv->sta_lock, flags);
635 491
636 IWL_DEBUG_INFO("hwcrypto: modify ucode station key info\n"); 492 IWL_DEBUG_INFO(priv, "hwcrypto: modify ucode station key info\n");
637 iwl_send_add_sta(priv, 493 iwl_send_add_sta(priv,
638 (struct iwl_addsta_cmd *)&priv->stations_39[sta_id].sta, 0); 494 (struct iwl_addsta_cmd *)&priv->stations_39[sta_id].sta, 0);
639 return 0; 495 return 0;
@@ -652,7 +508,7 @@ static int iwl3945_clear_sta_key_info(struct iwl_priv *priv, u8 sta_id)
652 priv->stations_39[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 508 priv->stations_39[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
653 spin_unlock_irqrestore(&priv->sta_lock, flags); 509 spin_unlock_irqrestore(&priv->sta_lock, flags);
654 510
655 IWL_DEBUG_INFO("hwcrypto: clear ucode station key info\n"); 511 IWL_DEBUG_INFO(priv, "hwcrypto: clear ucode station key info\n");
656 iwl_send_add_sta(priv, 512 iwl_send_add_sta(priv,
657 (struct iwl_addsta_cmd *)&priv->stations_39[sta_id].sta, 0); 513 (struct iwl_addsta_cmd *)&priv->stations_39[sta_id].sta, 0);
658 return 0; 514 return 0;
@@ -662,7 +518,7 @@ static void iwl3945_clear_free_frames(struct iwl_priv *priv)
662{ 518{
663 struct list_head *element; 519 struct list_head *element;
664 520
665 IWL_DEBUG_INFO("%d frames on pre-allocated heap on clear.\n", 521 IWL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n",
666 priv->frames_count); 522 priv->frames_count);
667 523
668 while (!list_empty(&priv->free_frames)) { 524 while (!list_empty(&priv->free_frames)) {
@@ -710,7 +566,7 @@ unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv,
710 int left) 566 int left)
711{ 567{
712 568
713 if (!iwl3945_is_associated(priv) || !priv->ibss_beacon || 569 if (!iwl_is_associated(priv) || !priv->ibss_beacon ||
714 ((priv->iw_mode != NL80211_IFTYPE_ADHOC) && 570 ((priv->iw_mode != NL80211_IFTYPE_ADHOC) &&
715 (priv->iw_mode != NL80211_IFTYPE_AP))) 571 (priv->iw_mode != NL80211_IFTYPE_AP)))
716 return 0; 572 return 0;
@@ -723,30 +579,6 @@ unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv,
723 return priv->ibss_beacon->len; 579 return priv->ibss_beacon->len;
724} 580}
725 581
726static u8 iwl3945_rate_get_lowest_plcp(struct iwl_priv *priv)
727{
728 u8 i;
729 int rate_mask;
730
731 /* Set rate mask*/
732 if (priv->staging39_rxon.flags & RXON_FLG_BAND_24G_MSK)
733 rate_mask = priv->active_rate_basic & IWL_CCK_RATES_MASK;
734 else
735 rate_mask = priv->active_rate_basic & IWL_OFDM_RATES_MASK;
736
737 for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID;
738 i = iwl3945_rates[i].next_ieee) {
739 if (rate_mask & (1 << i))
740 return iwl3945_rates[i].plcp;
741 }
742
743 /* No valid rate was found. Assign the lowest one */
744 if (priv->staging39_rxon.flags & RXON_FLG_BAND_24G_MSK)
745 return IWL_RATE_1M_PLCP;
746 else
747 return IWL_RATE_6M_PLCP;
748}
749
750static int iwl3945_send_beacon_cmd(struct iwl_priv *priv) 582static int iwl3945_send_beacon_cmd(struct iwl_priv *priv)
751{ 583{
752 struct iwl3945_frame *frame; 584 struct iwl3945_frame *frame;
@@ -762,7 +594,7 @@ static int iwl3945_send_beacon_cmd(struct iwl_priv *priv)
762 return -ENOMEM; 594 return -ENOMEM;
763 } 595 }
764 596
765 rate = iwl3945_rate_get_lowest_plcp(priv); 597 rate = iwl_rate_get_lowest_plcp(priv);
766 598
767 frame_size = iwl3945_hw_get_beacon_cmd(priv, frame, rate); 599 frame_size = iwl3945_hw_get_beacon_cmd(priv, frame, rate);
768 600
@@ -815,8 +647,8 @@ static void iwl3945_activate_qos(struct iwl_priv *priv, u8 force)
815 647
816 spin_unlock_irqrestore(&priv->lock, flags); 648 spin_unlock_irqrestore(&priv->lock, flags);
817 649
818 if (force || iwl3945_is_associated(priv)) { 650 if (force || iwl_is_associated(priv)) {
819 IWL_DEBUG_QOS("send QoS cmd with QoS active %d \n", 651 IWL_DEBUG_QOS(priv, "send QoS cmd with QoS active %d \n",
820 priv->qos_data.qos_active); 652 priv->qos_data.qos_active);
821 653
822 iwl3945_send_qos_params_command(priv, 654 iwl3945_send_qos_params_command(priv,
@@ -824,165 +656,9 @@ static void iwl3945_activate_qos(struct iwl_priv *priv, u8 force)
824 } 656 }
825} 657}
826 658
827/*
828 * Power management (not Tx power!) functions
829 */
830#define MSEC_TO_USEC 1024
831
832
833/* default power management (not Tx power) table values */
834/* for TIM 0-10 */
835static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
836 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
837 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
838 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 7)}, 0},
839 {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 6, 9, 9, 10)}, 0},
840 {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 7, 9, 9, 10)}, 1},
841 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 10)}, 1}
842};
843
844/* for TIM > 10 */
845static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
846 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
847 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
848 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0},
849 {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 6, 9, 9, 0xFF)}, 0},
850 {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0},
851 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 0xFF)}, 0}
852};
853
854int iwl3945_power_init_handle(struct iwl_priv *priv)
855{
856 int rc = 0, i;
857 struct iwl_power_mgr *pow_data;
858 int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX;
859 u16 pci_pm;
860
861 IWL_DEBUG_POWER("Initialize power \n");
862
863 pow_data = &priv->power_data;
864
865 memset(pow_data, 0, sizeof(*pow_data));
866
867 pow_data->dtim_period = 1;
868
869 memcpy(&pow_data->pwr_range_0[0], &range_0[0], size);
870 memcpy(&pow_data->pwr_range_1[0], &range_1[0], size);
871
872 rc = pci_read_config_word(priv->pci_dev, PCI_LINK_CTRL, &pci_pm);
873 if (rc != 0)
874 return 0;
875 else {
876 struct iwl_powertable_cmd *cmd;
877
878 IWL_DEBUG_POWER("adjust power command flags\n");
879
880 for (i = 0; i < IWL_POWER_MAX; i++) {
881 cmd = &pow_data->pwr_range_0[i].cmd;
882
883 if (pci_pm & 0x1)
884 cmd->flags &= ~IWL_POWER_PCI_PM_MSK;
885 else
886 cmd->flags |= IWL_POWER_PCI_PM_MSK;
887 }
888 }
889 return rc;
890}
891
892static int iwl3945_update_power_cmd(struct iwl_priv *priv,
893 struct iwl_powertable_cmd *cmd, u32 mode)
894{
895 struct iwl_power_mgr *pow_data;
896 struct iwl_power_vec_entry *range;
897 u32 max_sleep = 0;
898 int i;
899 u8 period = 0;
900 bool skip;
901
902 if (mode > IWL_POWER_INDEX_5) {
903 IWL_DEBUG_POWER("Error invalid power mode \n");
904 return -EINVAL;
905 }
906 pow_data = &priv->power_data;
907
908 if (pow_data->dtim_period < 10)
909 range = &pow_data->pwr_range_0[0];
910 else
911 range = &pow_data->pwr_range_1[1];
912
913 memcpy(cmd, &range[mode].cmd, sizeof(struct iwl3945_powertable_cmd));
914
915
916 if (period == 0) {
917 period = 1;
918 skip = false;
919 } else {
920 skip = !!range[mode].no_dtim;
921 }
922
923 if (skip) {
924 __le32 slp_itrvl = cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1];
925 max_sleep = (le32_to_cpu(slp_itrvl) / period) * period;
926 cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK;
927 } else {
928 max_sleep = period;
929 cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
930 }
931
932 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
933 if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep)
934 cmd->sleep_interval[i] = cpu_to_le32(max_sleep);
935
936 IWL_DEBUG_POWER("Flags value = 0x%08X\n", cmd->flags);
937 IWL_DEBUG_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout));
938 IWL_DEBUG_POWER("Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout));
939 IWL_DEBUG_POWER("Sleep interval vector = { %d , %d , %d , %d , %d }\n",
940 le32_to_cpu(cmd->sleep_interval[0]),
941 le32_to_cpu(cmd->sleep_interval[1]),
942 le32_to_cpu(cmd->sleep_interval[2]),
943 le32_to_cpu(cmd->sleep_interval[3]),
944 le32_to_cpu(cmd->sleep_interval[4]));
945
946 return 0;
947}
948
949static int iwl3945_send_power_mode(struct iwl_priv *priv, u32 mode)
950{
951 u32 uninitialized_var(final_mode);
952 int rc;
953 struct iwl_powertable_cmd cmd;
954
955 /* If on battery, set to 3,
956 * if plugged into AC power, set to CAM ("continuously aware mode"),
957 * else user level */
958 switch (mode) {
959 case IWL39_POWER_BATTERY:
960 final_mode = IWL_POWER_INDEX_3;
961 break;
962 case IWL39_POWER_AC:
963 final_mode = IWL_POWER_MODE_CAM;
964 break;
965 default:
966 final_mode = mode;
967 break;
968 }
969
970 iwl3945_update_power_cmd(priv, &cmd, final_mode);
971
972 /* FIXME use get_hcmd_size 3945 command is 4 bytes shorter */
973 rc = iwl_send_cmd_pdu(priv, POWER_TABLE_CMD,
974 sizeof(struct iwl3945_powertable_cmd), &cmd);
975
976 if (final_mode == IWL_POWER_MODE_CAM)
977 clear_bit(STATUS_POWER_PMI, &priv->status);
978 else
979 set_bit(STATUS_POWER_PMI, &priv->status);
980
981 return rc;
982}
983 659
984#define MAX_UCODE_BEACON_INTERVAL 1024 660#define MAX_UCODE_BEACON_INTERVAL 1024
985#define INTEL_CONN_LISTEN_INTERVAL __constant_cpu_to_le16(0xA) 661#define INTEL_CONN_LISTEN_INTERVAL cpu_to_le16(0xA)
986 662
987static __le16 iwl3945_adjust_beacon_interval(u16 beacon_val) 663static __le16 iwl3945_adjust_beacon_interval(u16 beacon_val)
988{ 664{
@@ -1043,8 +719,8 @@ static void iwl3945_setup_rxon_timing(struct iwl_priv *priv)
1043 priv->rxon_timing.beacon_init_val = 719 priv->rxon_timing.beacon_init_val =
1044 cpu_to_le32((u32) ((u64) interval_tm_unit - result)); 720 cpu_to_le32((u32) ((u64) interval_tm_unit - result));
1045 721
1046 IWL_DEBUG_ASSOC 722 IWL_DEBUG_ASSOC(priv,
1047 ("beacon interval %d beacon timer %d beacon tim %d\n", 723 "beacon interval %d beacon timer %d beacon tim %d\n",
1048 le16_to_cpu(priv->rxon_timing.beacon_interval), 724 le16_to_cpu(priv->rxon_timing.beacon_interval),
1049 le32_to_cpu(priv->rxon_timing.beacon_init_val), 725 le32_to_cpu(priv->rxon_timing.beacon_init_val),
1050 le16_to_cpu(priv->rxon_timing.atim_window)); 726 le16_to_cpu(priv->rxon_timing.atim_window));
@@ -1053,22 +729,22 @@ static void iwl3945_setup_rxon_timing(struct iwl_priv *priv)
1053static int iwl3945_scan_initiate(struct iwl_priv *priv) 729static int iwl3945_scan_initiate(struct iwl_priv *priv)
1054{ 730{
1055 if (!iwl_is_ready_rf(priv)) { 731 if (!iwl_is_ready_rf(priv)) {
1056 IWL_DEBUG_SCAN("Aborting scan due to not ready.\n"); 732 IWL_DEBUG_SCAN(priv, "Aborting scan due to not ready.\n");
1057 return -EIO; 733 return -EIO;
1058 } 734 }
1059 735
1060 if (test_bit(STATUS_SCANNING, &priv->status)) { 736 if (test_bit(STATUS_SCANNING, &priv->status)) {
1061 IWL_DEBUG_SCAN("Scan already in progress.\n"); 737 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
1062 return -EAGAIN; 738 return -EAGAIN;
1063 } 739 }
1064 740
1065 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 741 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
1066 IWL_DEBUG_SCAN("Scan request while abort pending. " 742 IWL_DEBUG_SCAN(priv, "Scan request while abort pending. "
1067 "Queuing.\n"); 743 "Queuing.\n");
1068 return -EAGAIN; 744 return -EAGAIN;
1069 } 745 }
1070 746
1071 IWL_DEBUG_INFO("Starting scan...\n"); 747 IWL_DEBUG_INFO(priv, "Starting scan...\n");
1072 if (priv->cfg->sku & IWL_SKU_G) 748 if (priv->cfg->sku & IWL_SKU_G)
1073 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ); 749 priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ);
1074 if (priv->cfg->sku & IWL_SKU_A) 750 if (priv->cfg->sku & IWL_SKU_A)
@@ -1082,115 +758,6 @@ static int iwl3945_scan_initiate(struct iwl_priv *priv)
1082 return 0; 758 return 0;
1083} 759}
1084 760
1085static int iwl3945_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt)
1086{
1087 struct iwl3945_rxon_cmd *rxon = &priv->staging39_rxon;
1088
1089 if (hw_decrypt)
1090 rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK;
1091 else
1092 rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK;
1093
1094 return 0;
1095}
1096
1097static void iwl3945_set_flags_for_phymode(struct iwl_priv *priv,
1098 enum ieee80211_band band)
1099{
1100 if (band == IEEE80211_BAND_5GHZ) {
1101 priv->staging39_rxon.flags &=
1102 ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK
1103 | RXON_FLG_CCK_MSK);
1104 priv->staging39_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
1105 } else {
1106 /* Copied from iwl3945_bg_post_associate() */
1107 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
1108 priv->staging39_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
1109 else
1110 priv->staging39_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
1111
1112 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
1113 priv->staging39_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
1114
1115 priv->staging39_rxon.flags |= RXON_FLG_BAND_24G_MSK;
1116 priv->staging39_rxon.flags |= RXON_FLG_AUTO_DETECT_MSK;
1117 priv->staging39_rxon.flags &= ~RXON_FLG_CCK_MSK;
1118 }
1119}
1120
1121/*
1122 * initialize rxon structure with default values from eeprom
1123 */
1124static void iwl3945_connection_init_rx_config(struct iwl_priv *priv,
1125 int mode)
1126{
1127 const struct iwl_channel_info *ch_info;
1128
1129 memset(&priv->staging39_rxon, 0, sizeof(priv->staging39_rxon));
1130
1131 switch (mode) {
1132 case NL80211_IFTYPE_AP:
1133 priv->staging39_rxon.dev_type = RXON_DEV_TYPE_AP;
1134 break;
1135
1136 case NL80211_IFTYPE_STATION:
1137 priv->staging39_rxon.dev_type = RXON_DEV_TYPE_ESS;
1138 priv->staging39_rxon.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
1139 break;
1140
1141 case NL80211_IFTYPE_ADHOC:
1142 priv->staging39_rxon.dev_type = RXON_DEV_TYPE_IBSS;
1143 priv->staging39_rxon.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
1144 priv->staging39_rxon.filter_flags = RXON_FILTER_BCON_AWARE_MSK |
1145 RXON_FILTER_ACCEPT_GRP_MSK;
1146 break;
1147
1148 case NL80211_IFTYPE_MONITOR:
1149 priv->staging39_rxon.dev_type = RXON_DEV_TYPE_SNIFFER;
1150 priv->staging39_rxon.filter_flags = RXON_FILTER_PROMISC_MSK |
1151 RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
1152 break;
1153 default:
1154 IWL_ERR(priv, "Unsupported interface type %d\n", mode);
1155 break;
1156 }
1157
1158#if 0
1159 /* TODO: Figure out when short_preamble would be set and cache from
1160 * that */
1161 if (!hw_to_local(priv->hw)->short_preamble)
1162 priv->staging39_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
1163 else
1164 priv->staging39_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
1165#endif
1166
1167 ch_info = iwl_get_channel_info(priv, priv->band,
1168 le16_to_cpu(priv->active39_rxon.channel));
1169
1170 if (!ch_info)
1171 ch_info = &priv->channel_info[0];
1172
1173 /*
1174 * in some case A channels are all non IBSS
1175 * in this case force B/G channel
1176 */
1177 if ((mode == NL80211_IFTYPE_ADHOC) && !(is_channel_ibss(ch_info)))
1178 ch_info = &priv->channel_info[0];
1179
1180 priv->staging39_rxon.channel = cpu_to_le16(ch_info->channel);
1181 if (is_channel_a_band(ch_info))
1182 priv->band = IEEE80211_BAND_5GHZ;
1183 else
1184 priv->band = IEEE80211_BAND_2GHZ;
1185
1186 iwl3945_set_flags_for_phymode(priv, priv->band);
1187
1188 priv->staging39_rxon.ofdm_basic_rates =
1189 (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1190 priv->staging39_rxon.cck_basic_rates =
1191 (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1192}
1193
1194static int iwl3945_set_mode(struct iwl_priv *priv, int mode) 761static int iwl3945_set_mode(struct iwl_priv *priv, int mode)
1195{ 762{
1196 if (mode == NL80211_IFTYPE_ADHOC) { 763 if (mode == NL80211_IFTYPE_ADHOC) {
@@ -1198,17 +765,16 @@ static int iwl3945_set_mode(struct iwl_priv *priv, int mode)
1198 765
1199 ch_info = iwl_get_channel_info(priv, 766 ch_info = iwl_get_channel_info(priv,
1200 priv->band, 767 priv->band,
1201 le16_to_cpu(priv->staging39_rxon.channel)); 768 le16_to_cpu(priv->staging_rxon.channel));
1202 769
1203 if (!ch_info || !is_channel_ibss(ch_info)) { 770 if (!ch_info || !is_channel_ibss(ch_info)) {
1204 IWL_ERR(priv, "channel %d not IBSS channel\n", 771 IWL_ERR(priv, "channel %d not IBSS channel\n",
1205 le16_to_cpu(priv->staging39_rxon.channel)); 772 le16_to_cpu(priv->staging_rxon.channel));
1206 return -EINVAL; 773 return -EINVAL;
1207 } 774 }
1208 } 775 }
1209 776
1210 iwl3945_connection_init_rx_config(priv, mode); 777 iwl_connection_init_rx_config(priv, mode);
1211 memcpy(priv->staging39_rxon.node_addr, priv->mac_addr, ETH_ALEN);
1212 778
1213 iwl3945_clear_stations_table(priv); 779 iwl3945_clear_stations_table(priv);
1214 780
@@ -1219,7 +785,7 @@ static int iwl3945_set_mode(struct iwl_priv *priv, int mode)
1219 cancel_delayed_work(&priv->scan_check); 785 cancel_delayed_work(&priv->scan_check);
1220 if (iwl_scan_cancel_timeout(priv, 100)) { 786 if (iwl_scan_cancel_timeout(priv, 100)) {
1221 IWL_WARN(priv, "Aborted scan still in progress after 100ms\n"); 787 IWL_WARN(priv, "Aborted scan still in progress after 100ms\n");
1222 IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); 788 IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n");
1223 return -EAGAIN; 789 return -EAGAIN;
1224 } 790 }
1225 791
@@ -1242,7 +808,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
1242 case ALG_CCMP: 808 case ALG_CCMP:
1243 tx->sec_ctl = TX_CMD_SEC_CCM; 809 tx->sec_ctl = TX_CMD_SEC_CCM;
1244 memcpy(tx->key, keyinfo->key, keyinfo->keylen); 810 memcpy(tx->key, keyinfo->key, keyinfo->keylen);
1245 IWL_DEBUG_TX("tx_cmd with AES hwcrypto\n"); 811 IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n");
1246 break; 812 break;
1247 813
1248 case ALG_TKIP: 814 case ALG_TKIP:
@@ -1266,7 +832,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
1266 832
1267 memcpy(&tx->key[3], keyinfo->key, keyinfo->keylen); 833 memcpy(&tx->key[3], keyinfo->key, keyinfo->keylen);
1268 834
1269 IWL_DEBUG_TX("Configuring packet for WEP encryption " 835 IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption "
1270 "with key %d\n", info->control.hw_key->hw_key_idx); 836 "with key %d\n", info->control.hw_key->hw_key_idx);
1271 break; 837 break;
1272 838
@@ -1383,7 +949,7 @@ static int iwl3945_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr)
1383 if (sta_id != IWL_INVALID_STATION) 949 if (sta_id != IWL_INVALID_STATION)
1384 return sta_id; 950 return sta_id;
1385 951
1386 IWL_DEBUG_DROP("Station %pM not in station map. " 952 IWL_DEBUG_DROP(priv, "Station %pM not in station map. "
1387 "Defaulting to broadcast...\n", 953 "Defaulting to broadcast...\n",
1388 hdr->addr1); 954 hdr->addr1);
1389 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr)); 955 iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
@@ -1429,7 +995,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
1429 995
1430 spin_lock_irqsave(&priv->lock, flags); 996 spin_lock_irqsave(&priv->lock, flags);
1431 if (iwl_is_rfkill(priv)) { 997 if (iwl_is_rfkill(priv)) {
1432 IWL_DEBUG_DROP("Dropping - RF KILL\n"); 998 IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n");
1433 goto drop_unlock; 999 goto drop_unlock;
1434 } 1000 }
1435 1001
@@ -1445,19 +1011,19 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
1445 1011
1446#ifdef CONFIG_IWLWIFI_DEBUG 1012#ifdef CONFIG_IWLWIFI_DEBUG
1447 if (ieee80211_is_auth(fc)) 1013 if (ieee80211_is_auth(fc))
1448 IWL_DEBUG_TX("Sending AUTH frame\n"); 1014 IWL_DEBUG_TX(priv, "Sending AUTH frame\n");
1449 else if (ieee80211_is_assoc_req(fc)) 1015 else if (ieee80211_is_assoc_req(fc))
1450 IWL_DEBUG_TX("Sending ASSOC frame\n"); 1016 IWL_DEBUG_TX(priv, "Sending ASSOC frame\n");
1451 else if (ieee80211_is_reassoc_req(fc)) 1017 else if (ieee80211_is_reassoc_req(fc))
1452 IWL_DEBUG_TX("Sending REASSOC frame\n"); 1018 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
1453#endif 1019#endif
1454 1020
1455 /* drop all data frame if we are not associated */ 1021 /* drop all data frame if we are not associated */
1456 if (ieee80211_is_data(fc) && 1022 if (ieee80211_is_data(fc) &&
1457 (priv->iw_mode != NL80211_IFTYPE_MONITOR) && /* packet injection */ 1023 (priv->iw_mode != NL80211_IFTYPE_MONITOR) && /* packet injection */
1458 (!iwl3945_is_associated(priv) || 1024 (!iwl_is_associated(priv) ||
1459 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) { 1025 ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id))) {
1460 IWL_DEBUG_DROP("Dropping - !iwl3945_is_associated\n"); 1026 IWL_DEBUG_DROP(priv, "Dropping - !iwl_is_associated\n");
1461 goto drop_unlock; 1027 goto drop_unlock;
1462 } 1028 }
1463 1029
@@ -1468,12 +1034,12 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
1468 /* Find (or create) index into station table for destination station */ 1034 /* Find (or create) index into station table for destination station */
1469 sta_id = iwl3945_get_sta_id(priv, hdr); 1035 sta_id = iwl3945_get_sta_id(priv, hdr);
1470 if (sta_id == IWL_INVALID_STATION) { 1036 if (sta_id == IWL_INVALID_STATION) {
1471 IWL_DEBUG_DROP("Dropping - INVALID STATION: %pM\n", 1037 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
1472 hdr->addr1); 1038 hdr->addr1);
1473 goto drop; 1039 goto drop;
1474 } 1040 }
1475 1041
1476 IWL_DEBUG_RATE("station Id %d\n", sta_id); 1042 IWL_DEBUG_RATE(priv, "station Id %d\n", sta_id);
1477 1043
1478 if (ieee80211_is_data_qos(fc)) { 1044 if (ieee80211_is_data_qos(fc)) {
1479 qc = ieee80211_get_qos_ctl(hdr); 1045 qc = ieee80211_get_qos_ctl(hdr);
@@ -1482,7 +1048,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
1482 IEEE80211_SCTL_SEQ; 1048 IEEE80211_SCTL_SEQ;
1483 hdr->seq_ctrl = cpu_to_le16(seq_number) | 1049 hdr->seq_ctrl = cpu_to_le16(seq_number) |
1484 (hdr->seq_ctrl & 1050 (hdr->seq_ctrl &
1485 __constant_cpu_to_le16(IEEE80211_SCTL_FRAG)); 1051 cpu_to_le16(IEEE80211_SCTL_FRAG));
1486 seq_number += 0x10; 1052 seq_number += 0x10;
1487 } 1053 }
1488 1054
@@ -1622,60 +1188,6 @@ drop:
1622 return -1; 1188 return -1;
1623} 1189}
1624 1190
1625static void iwl3945_set_rate(struct iwl_priv *priv)
1626{
1627 const struct ieee80211_supported_band *sband = NULL;
1628 struct ieee80211_rate *rate;
1629 int i;
1630
1631 sband = iwl_get_hw_mode(priv, priv->band);
1632 if (!sband) {
1633 IWL_ERR(priv, "Failed to set rate: unable to get hw mode\n");
1634 return;
1635 }
1636
1637 priv->active_rate = 0;
1638 priv->active_rate_basic = 0;
1639
1640 IWL_DEBUG_RATE("Setting rates for %s GHz\n",
1641 sband->band == IEEE80211_BAND_2GHZ ? "2.4" : "5");
1642
1643 for (i = 0; i < sband->n_bitrates; i++) {
1644 rate = &sband->bitrates[i];
1645 if ((rate->hw_value < IWL_RATE_COUNT) &&
1646 !(rate->flags & IEEE80211_CHAN_DISABLED)) {
1647 IWL_DEBUG_RATE("Adding rate index %d (plcp %d)\n",
1648 rate->hw_value, iwl3945_rates[rate->hw_value].plcp);
1649 priv->active_rate |= (1 << rate->hw_value);
1650 }
1651 }
1652
1653 IWL_DEBUG_RATE("Set active_rate = %0x, active_rate_basic = %0x\n",
1654 priv->active_rate, priv->active_rate_basic);
1655
1656 /*
1657 * If a basic rate is configured, then use it (adding IWL_RATE_1M_MASK)
1658 * otherwise set it to the default of all CCK rates and 6, 12, 24 for
1659 * OFDM
1660 */
1661 if (priv->active_rate_basic & IWL_CCK_BASIC_RATES_MASK)
1662 priv->staging39_rxon.cck_basic_rates =
1663 ((priv->active_rate_basic &
1664 IWL_CCK_RATES_MASK) >> IWL_FIRST_CCK_RATE) & 0xF;
1665 else
1666 priv->staging39_rxon.cck_basic_rates =
1667 (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
1668
1669 if (priv->active_rate_basic & IWL_OFDM_BASIC_RATES_MASK)
1670 priv->staging39_rxon.ofdm_basic_rates =
1671 ((priv->active_rate_basic &
1672 (IWL_OFDM_BASIC_RATES_MASK | IWL_RATE_6M_MASK)) >>
1673 IWL_FIRST_OFDM_RATE) & 0xFF;
1674 else
1675 priv->staging39_rxon.ofdm_basic_rates =
1676 (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
1677}
1678
1679static void iwl3945_radio_kill_sw(struct iwl_priv *priv, int disable_radio) 1191static void iwl3945_radio_kill_sw(struct iwl_priv *priv, int disable_radio)
1680{ 1192{
1681 unsigned long flags; 1193 unsigned long flags;
@@ -1683,7 +1195,7 @@ static void iwl3945_radio_kill_sw(struct iwl_priv *priv, int disable_radio)
1683 if (!!disable_radio == test_bit(STATUS_RF_KILL_SW, &priv->status)) 1195 if (!!disable_radio == test_bit(STATUS_RF_KILL_SW, &priv->status))
1684 return; 1196 return;
1685 1197
1686 IWL_DEBUG_RF_KILL("Manual SW RF KILL set to: RADIO %s\n", 1198 IWL_DEBUG_RF_KILL(priv, "Manual SW RF KILL set to: RADIO %s\n",
1687 disable_radio ? "OFF" : "ON"); 1199 disable_radio ? "OFF" : "ON");
1688 1200
1689 if (disable_radio) { 1201 if (disable_radio) {
@@ -1716,7 +1228,7 @@ static void iwl3945_radio_kill_sw(struct iwl_priv *priv, int disable_radio)
1716 spin_unlock_irqrestore(&priv->lock, flags); 1228 spin_unlock_irqrestore(&priv->lock, flags);
1717 1229
1718 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { 1230 if (test_bit(STATUS_RF_KILL_HW, &priv->status)) {
1719 IWL_DEBUG_RF_KILL("Can not turn radio back on - " 1231 IWL_DEBUG_RF_KILL(priv, "Can not turn radio back on - "
1720 "disabled by HW switch\n"); 1232 "disabled by HW switch\n");
1721 return; 1233 return;
1722 } 1234 }
@@ -1726,38 +1238,6 @@ static void iwl3945_radio_kill_sw(struct iwl_priv *priv, int disable_radio)
1726 return; 1238 return;
1727} 1239}
1728 1240
1729void iwl3945_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
1730 u32 decrypt_res, struct ieee80211_rx_status *stats)
1731{
1732 u16 fc =
1733 le16_to_cpu(((struct ieee80211_hdr *)skb->data)->frame_control);
1734
1735 if (priv->active39_rxon.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK)
1736 return;
1737
1738 if (!(fc & IEEE80211_FCTL_PROTECTED))
1739 return;
1740
1741 IWL_DEBUG_RX("decrypt_res:0x%x\n", decrypt_res);
1742 switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) {
1743 case RX_RES_STATUS_SEC_TYPE_TKIP:
1744 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
1745 RX_RES_STATUS_BAD_ICV_MIC)
1746 stats->flag |= RX_FLAG_MMIC_ERROR;
1747 case RX_RES_STATUS_SEC_TYPE_WEP:
1748 case RX_RES_STATUS_SEC_TYPE_CCMP:
1749 if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) ==
1750 RX_RES_STATUS_DECRYPT_OK) {
1751 IWL_DEBUG_RX("hw decrypt successfully!!!\n");
1752 stats->flag |= RX_FLAG_DECRYPTED;
1753 }
1754 break;
1755
1756 default:
1757 break;
1758 }
1759}
1760
1761#ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT 1241#ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT
1762 1242
1763#include "iwl-spectrum.h" 1243#include "iwl-spectrum.h"
@@ -1827,7 +1307,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
1827 int spectrum_resp_status; 1307 int spectrum_resp_status;
1828 int duration = le16_to_cpu(params->duration); 1308 int duration = le16_to_cpu(params->duration);
1829 1309
1830 if (iwl3945_is_associated(priv)) 1310 if (iwl_is_associated(priv))
1831 add_time = 1311 add_time =
1832 iwl3945_usecs_to_beacons( 1312 iwl3945_usecs_to_beacons(
1833 le64_to_cpu(params->start_time) - priv->last_tsf, 1313 le64_to_cpu(params->start_time) - priv->last_tsf,
@@ -1842,7 +1322,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
1842 cmd.len = sizeof(spectrum); 1322 cmd.len = sizeof(spectrum);
1843 spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); 1323 spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len));
1844 1324
1845 if (iwl3945_is_associated(priv)) 1325 if (iwl_is_associated(priv))
1846 spectrum.start_time = 1326 spectrum.start_time =
1847 iwl3945_add_beacon_time(priv->last_beacon_time, 1327 iwl3945_add_beacon_time(priv->last_beacon_time,
1848 add_time, 1328 add_time,
@@ -1853,7 +1333,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
1853 spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT); 1333 spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT);
1854 spectrum.channels[0].channel = params->channel; 1334 spectrum.channels[0].channel = params->channel;
1855 spectrum.channels[0].type = type; 1335 spectrum.channels[0].type = type;
1856 if (priv->active39_rxon.flags & RXON_FLG_BAND_24G_MSK) 1336 if (priv->active_rxon.flags & RXON_FLG_BAND_24G_MSK)
1857 spectrum.flags |= RXON_FLG_BAND_24G_MSK | 1337 spectrum.flags |= RXON_FLG_BAND_24G_MSK |
1858 RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; 1338 RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK;
1859 1339
@@ -1871,7 +1351,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
1871 switch (spectrum_resp_status) { 1351 switch (spectrum_resp_status) {
1872 case 0: /* Command will be handled */ 1352 case 0: /* Command will be handled */
1873 if (res->u.spectrum.id != 0xff) { 1353 if (res->u.spectrum.id != 0xff) {
1874 IWL_DEBUG_INFO("Replaced existing measurement: %d\n", 1354 IWL_DEBUG_INFO(priv, "Replaced existing measurement: %d\n",
1875 res->u.spectrum.id); 1355 res->u.spectrum.id);
1876 priv->measurement_status &= ~MEASUREMENT_READY; 1356 priv->measurement_status &= ~MEASUREMENT_READY;
1877 } 1357 }
@@ -1899,18 +1379,18 @@ static void iwl3945_rx_reply_alive(struct iwl_priv *priv,
1899 1379
1900 palive = &pkt->u.alive_frame; 1380 palive = &pkt->u.alive_frame;
1901 1381
1902 IWL_DEBUG_INFO("Alive ucode status 0x%08X revision " 1382 IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision "
1903 "0x%01X 0x%01X\n", 1383 "0x%01X 0x%01X\n",
1904 palive->is_valid, palive->ver_type, 1384 palive->is_valid, palive->ver_type,
1905 palive->ver_subtype); 1385 palive->ver_subtype);
1906 1386
1907 if (palive->ver_subtype == INITIALIZE_SUBTYPE) { 1387 if (palive->ver_subtype == INITIALIZE_SUBTYPE) {
1908 IWL_DEBUG_INFO("Initialization Alive received.\n"); 1388 IWL_DEBUG_INFO(priv, "Initialization Alive received.\n");
1909 memcpy(&priv->card_alive_init, &pkt->u.alive_frame, 1389 memcpy(&priv->card_alive_init, &pkt->u.alive_frame,
1910 sizeof(struct iwl_alive_resp)); 1390 sizeof(struct iwl_alive_resp));
1911 pwork = &priv->init_alive_start; 1391 pwork = &priv->init_alive_start;
1912 } else { 1392 } else {
1913 IWL_DEBUG_INFO("Runtime Alive received.\n"); 1393 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
1914 memcpy(&priv->card_alive, &pkt->u.alive_frame, 1394 memcpy(&priv->card_alive, &pkt->u.alive_frame,
1915 sizeof(struct iwl_alive_resp)); 1395 sizeof(struct iwl_alive_resp));
1916 pwork = &priv->alive_start; 1396 pwork = &priv->alive_start;
@@ -1933,7 +1413,7 @@ static void iwl3945_rx_reply_add_sta(struct iwl_priv *priv,
1933 struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1413 struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
1934#endif 1414#endif
1935 1415
1936 IWL_DEBUG_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); 1416 IWL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status);
1937 return; 1417 return;
1938} 1418}
1939 1419
@@ -1951,19 +1431,6 @@ static void iwl3945_rx_reply_error(struct iwl_priv *priv,
1951 le32_to_cpu(pkt->u.err_resp.error_info)); 1431 le32_to_cpu(pkt->u.err_resp.error_info));
1952} 1432}
1953 1433
1954#define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x
1955
1956static void iwl3945_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1957{
1958 struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
1959 struct iwl3945_rxon_cmd *rxon = (void *)&priv->active39_rxon;
1960 struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
1961 IWL_DEBUG_11H("CSA notif: channel %d, status %d\n",
1962 le16_to_cpu(csa->channel), le32_to_cpu(csa->status));
1963 rxon->channel = csa->channel;
1964 priv->staging39_rxon.channel = csa->channel;
1965}
1966
1967static void iwl3945_rx_spectrum_measure_notif(struct iwl_priv *priv, 1434static void iwl3945_rx_spectrum_measure_notif(struct iwl_priv *priv,
1968 struct iwl_rx_mem_buffer *rxb) 1435 struct iwl_rx_mem_buffer *rxb)
1969{ 1436{
@@ -1972,7 +1439,7 @@ static void iwl3945_rx_spectrum_measure_notif(struct iwl_priv *priv,
1972 struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif); 1439 struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif);
1973 1440
1974 if (!report->state) { 1441 if (!report->state) {
1975 IWL_DEBUG(IWL_DL_11H | IWL_DL_INFO, 1442 IWL_DEBUG(priv, IWL_DL_11H | IWL_DL_INFO,
1976 "Spectrum Measure Notification: Start\n"); 1443 "Spectrum Measure Notification: Start\n");
1977 return; 1444 return;
1978 } 1445 }
@@ -1988,7 +1455,7 @@ static void iwl3945_rx_pm_sleep_notif(struct iwl_priv *priv,
1988#ifdef CONFIG_IWLWIFI_DEBUG 1455#ifdef CONFIG_IWLWIFI_DEBUG
1989 struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1456 struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
1990 struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); 1457 struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);
1991 IWL_DEBUG_RX("sleep mode: %d, src: %d\n", 1458 IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n",
1992 sleep->pm_sleep_mode, sleep->pm_wakeup_src); 1459 sleep->pm_sleep_mode, sleep->pm_wakeup_src);
1993#endif 1460#endif
1994} 1461}
@@ -1997,7 +1464,7 @@ static void iwl3945_rx_pm_debug_statistics_notif(struct iwl_priv *priv,
1997 struct iwl_rx_mem_buffer *rxb) 1464 struct iwl_rx_mem_buffer *rxb)
1998{ 1465{
1999 struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1466 struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
2000 IWL_DEBUG_RADIO("Dumping %d bytes of unhandled " 1467 IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled "
2001 "notification for %s:\n", 1468 "notification for %s:\n",
2002 le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); 1469 le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd));
2003 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, 1470 iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw,
@@ -2037,7 +1504,7 @@ static void iwl3945_rx_beacon_notif(struct iwl_priv *priv,
2037 struct iwl3945_beacon_notif *beacon = &(pkt->u.beacon_status); 1504 struct iwl3945_beacon_notif *beacon = &(pkt->u.beacon_status);
2038 u8 rate = beacon->beacon_notify_hdr.rate; 1505 u8 rate = beacon->beacon_notify_hdr.rate;
2039 1506
2040 IWL_DEBUG_RX("beacon status %x retries %d iss %d " 1507 IWL_DEBUG_RX(priv, "beacon status %x retries %d iss %d "
2041 "tsf %d %d rate %d\n", 1508 "tsf %d %d rate %d\n",
2042 le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, 1509 le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK,
2043 beacon->beacon_notify_hdr.failure_frame, 1510 beacon->beacon_notify_hdr.failure_frame,
@@ -2060,7 +1527,7 @@ static void iwl3945_rx_reply_scan(struct iwl_priv *priv,
2060 struct iwl_scanreq_notification *notif = 1527 struct iwl_scanreq_notification *notif =
2061 (struct iwl_scanreq_notification *)pkt->u.raw; 1528 (struct iwl_scanreq_notification *)pkt->u.raw;
2062 1529
2063 IWL_DEBUG_RX("Scan request status = 0x%x\n", notif->status); 1530 IWL_DEBUG_RX(priv, "Scan request status = 0x%x\n", notif->status);
2064#endif 1531#endif
2065} 1532}
2066 1533
@@ -2072,7 +1539,7 @@ static void iwl3945_rx_scan_start_notif(struct iwl_priv *priv,
2072 struct iwl_scanstart_notification *notif = 1539 struct iwl_scanstart_notification *notif =
2073 (struct iwl_scanstart_notification *)pkt->u.raw; 1540 (struct iwl_scanstart_notification *)pkt->u.raw;
2074 priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); 1541 priv->scan_start_tsf = le32_to_cpu(notif->tsf_low);
2075 IWL_DEBUG_SCAN("Scan start: " 1542 IWL_DEBUG_SCAN(priv, "Scan start: "
2076 "%d [802.11%s] " 1543 "%d [802.11%s] "
2077 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", 1544 "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n",
2078 notif->channel, 1545 notif->channel,
@@ -2091,7 +1558,7 @@ static void iwl3945_rx_scan_results_notif(struct iwl_priv *priv,
2091 (struct iwl_scanresults_notification *)pkt->u.raw; 1558 (struct iwl_scanresults_notification *)pkt->u.raw;
2092#endif 1559#endif
2093 1560
2094 IWL_DEBUG_SCAN("Scan ch.res: " 1561 IWL_DEBUG_SCAN(priv, "Scan ch.res: "
2095 "%d [802.11%s] " 1562 "%d [802.11%s] "
2096 "(TSF: 0x%08X:%08X) - %d " 1563 "(TSF: 0x%08X:%08X) - %d "
2097 "elapsed=%lu usec (%dms since last)\n", 1564 "elapsed=%lu usec (%dms since last)\n",
@@ -2117,7 +1584,7 @@ static void iwl3945_rx_scan_complete_notif(struct iwl_priv *priv,
2117 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 1584 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
2118#endif 1585#endif
2119 1586
2120 IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", 1587 IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
2121 scan_notif->scanned_channels, 1588 scan_notif->scanned_channels,
2122 scan_notif->tsf_low, 1589 scan_notif->tsf_low,
2123 scan_notif->tsf_high, scan_notif->status); 1590 scan_notif->tsf_high, scan_notif->status);
@@ -2128,7 +1595,7 @@ static void iwl3945_rx_scan_complete_notif(struct iwl_priv *priv,
2128 /* The scan completion notification came in, so kill that timer... */ 1595 /* The scan completion notification came in, so kill that timer... */
2129 cancel_delayed_work(&priv->scan_check); 1596 cancel_delayed_work(&priv->scan_check);
2130 1597
2131 IWL_DEBUG_INFO("Scan pass on %sGHz took %dms\n", 1598 IWL_DEBUG_INFO(priv, "Scan pass on %sGHz took %dms\n",
2132 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ? 1599 (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ?
2133 "2.4" : "5.2", 1600 "2.4" : "5.2",
2134 jiffies_to_msecs(elapsed_jiffies 1601 jiffies_to_msecs(elapsed_jiffies
@@ -2146,7 +1613,7 @@ static void iwl3945_rx_scan_complete_notif(struct iwl_priv *priv,
2146 * then we reset the scan state machine and terminate, 1613 * then we reset the scan state machine and terminate,
2147 * re-queuing another scan if one has been requested */ 1614 * re-queuing another scan if one has been requested */
2148 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 1615 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
2149 IWL_DEBUG_INFO("Aborted scan completed.\n"); 1616 IWL_DEBUG_INFO(priv, "Aborted scan completed.\n");
2150 clear_bit(STATUS_SCAN_ABORTING, &priv->status); 1617 clear_bit(STATUS_SCAN_ABORTING, &priv->status);
2151 } else { 1618 } else {
2152 /* If there are more bands on this scan pass reschedule */ 1619 /* If there are more bands on this scan pass reschedule */
@@ -2156,11 +1623,11 @@ static void iwl3945_rx_scan_complete_notif(struct iwl_priv *priv,
2156 1623
2157 priv->last_scan_jiffies = jiffies; 1624 priv->last_scan_jiffies = jiffies;
2158 priv->next_scan_jiffies = 0; 1625 priv->next_scan_jiffies = 0;
2159 IWL_DEBUG_INFO("Setting scan to off\n"); 1626 IWL_DEBUG_INFO(priv, "Setting scan to off\n");
2160 1627
2161 clear_bit(STATUS_SCANNING, &priv->status); 1628 clear_bit(STATUS_SCANNING, &priv->status);
2162 1629
2163 IWL_DEBUG_INFO("Scan took %dms\n", 1630 IWL_DEBUG_INFO(priv, "Scan took %dms\n",
2164 jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies))); 1631 jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies)));
2165 1632
2166 queue_work(priv->workqueue, &priv->scan_completed); 1633 queue_work(priv->workqueue, &priv->scan_completed);
@@ -2181,7 +1648,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv,
2181 u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); 1648 u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
2182 unsigned long status = priv->status; 1649 unsigned long status = priv->status;
2183 1650
2184 IWL_DEBUG_RF_KILL("Card state received: HW:%s SW:%s\n", 1651 IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s\n",
2185 (flags & HW_CARD_DISABLED) ? "Kill" : "On", 1652 (flags & HW_CARD_DISABLED) ? "Kill" : "On",
2186 (flags & SW_CARD_DISABLED) ? "Kill" : "On"); 1653 (flags & SW_CARD_DISABLED) ? "Kill" : "On");
2187 1654
@@ -2224,7 +1691,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv)
2224 priv->rx_handlers[REPLY_ALIVE] = iwl3945_rx_reply_alive; 1691 priv->rx_handlers[REPLY_ALIVE] = iwl3945_rx_reply_alive;
2225 priv->rx_handlers[REPLY_ADD_STA] = iwl3945_rx_reply_add_sta; 1692 priv->rx_handlers[REPLY_ADD_STA] = iwl3945_rx_reply_add_sta;
2226 priv->rx_handlers[REPLY_ERROR] = iwl3945_rx_reply_error; 1693 priv->rx_handlers[REPLY_ERROR] = iwl3945_rx_reply_error;
2227 priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl3945_rx_csa; 1694 priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_rx_csa;
2228 priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = 1695 priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] =
2229 iwl3945_rx_spectrum_measure_notif; 1696 iwl3945_rx_spectrum_measure_notif;
2230 priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl3945_rx_pm_sleep_notif; 1697 priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl3945_rx_pm_sleep_notif;
@@ -2642,7 +2109,7 @@ static void iwl3945_rx_handle(struct iwl_priv *priv)
2642 fill_rx = 1; 2109 fill_rx = 1;
2643 /* Rx interrupt, but nothing sent from uCode */ 2110 /* Rx interrupt, but nothing sent from uCode */
2644 if (i == r) 2111 if (i == r)
2645 IWL_DEBUG(IWL_DL_RX | IWL_DL_ISR, "r = %d, i = %d\n", r, i); 2112 IWL_DEBUG(priv, IWL_DL_RX | IWL_DL_ISR, "r = %d, i = %d\n", r, i);
2646 2113
2647 while (i != r) { 2114 while (i != r) {
2648 rxb = rxq->queue[i]; 2115 rxb = rxq->queue[i];
@@ -2673,13 +2140,13 @@ static void iwl3945_rx_handle(struct iwl_priv *priv)
2673 * handle those that need handling via function in 2140 * handle those that need handling via function in
2674 * rx_handlers table. See iwl3945_setup_rx_handlers() */ 2141 * rx_handlers table. See iwl3945_setup_rx_handlers() */
2675 if (priv->rx_handlers[pkt->hdr.cmd]) { 2142 if (priv->rx_handlers[pkt->hdr.cmd]) {
2676 IWL_DEBUG(IWL_DL_HCMD | IWL_DL_RX | IWL_DL_ISR, 2143 IWL_DEBUG(priv, IWL_DL_HCMD | IWL_DL_RX | IWL_DL_ISR,
2677 "r = %d, i = %d, %s, 0x%02x\n", r, i, 2144 "r = %d, i = %d, %s, 0x%02x\n", r, i,
2678 get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); 2145 get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
2679 priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); 2146 priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
2680 } else { 2147 } else {
2681 /* No handling needed */ 2148 /* No handling needed */
2682 IWL_DEBUG(IWL_DL_HCMD | IWL_DL_RX | IWL_DL_ISR, 2149 IWL_DEBUG(priv, IWL_DL_HCMD | IWL_DL_RX | IWL_DL_ISR,
2683 "r %d i %d No handler needed for %s, 0x%02x\n", 2150 "r %d i %d No handler needed for %s, 0x%02x\n",
2684 r, i, get_cmd_string(pkt->hdr.cmd), 2151 r, i, get_cmd_string(pkt->hdr.cmd),
2685 pkt->hdr.cmd); 2152 pkt->hdr.cmd);
@@ -2728,29 +2195,9 @@ static void iwl3945_rx_handle(struct iwl_priv *priv)
2728 iwl3945_rx_queue_restock(priv); 2195 iwl3945_rx_queue_restock(priv);
2729} 2196}
2730 2197
2731#ifdef CONFIG_IWLWIFI_DEBUG
2732static void iwl3945_print_rx_config_cmd(struct iwl_priv *priv,
2733 struct iwl3945_rxon_cmd *rxon)
2734{
2735 IWL_DEBUG_RADIO("RX CONFIG:\n");
2736 iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
2737 IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel));
2738 IWL_DEBUG_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags));
2739 IWL_DEBUG_RADIO("u32 filter_flags: 0x%08x\n",
2740 le32_to_cpu(rxon->filter_flags));
2741 IWL_DEBUG_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type);
2742 IWL_DEBUG_RADIO("u8 ofdm_basic_rates: 0x%02x\n",
2743 rxon->ofdm_basic_rates);
2744 IWL_DEBUG_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates);
2745 IWL_DEBUG_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr);
2746 IWL_DEBUG_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr);
2747 IWL_DEBUG_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id));
2748}
2749#endif
2750
2751static void iwl3945_enable_interrupts(struct iwl_priv *priv) 2198static void iwl3945_enable_interrupts(struct iwl_priv *priv)
2752{ 2199{
2753 IWL_DEBUG_ISR("Enabling interrupts\n"); 2200 IWL_DEBUG_ISR(priv, "Enabling interrupts\n");
2754 set_bit(STATUS_INT_ENABLED, &priv->status); 2201 set_bit(STATUS_INT_ENABLED, &priv->status);
2755 iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK); 2202 iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK);
2756} 2203}
@@ -2776,7 +2223,7 @@ static inline void iwl3945_disable_interrupts(struct iwl_priv *priv)
2776 * from uCode or flow handler (Rx/Tx DMA) */ 2223 * from uCode or flow handler (Rx/Tx DMA) */
2777 iwl_write32(priv, CSR_INT, 0xffffffff); 2224 iwl_write32(priv, CSR_INT, 0xffffffff);
2778 iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); 2225 iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff);
2779 IWL_DEBUG_ISR("Disabled interrupts\n"); 2226 IWL_DEBUG_ISR(priv, "Disabled interrupts\n");
2780} 2227}
2781 2228
2782static const char *desc_lookup(int i) 2229static const char *desc_lookup(int i)
@@ -2957,58 +2404,19 @@ static void iwl3945_dump_nic_event_log(struct iwl_priv *priv)
2957 iwl_release_nic_access(priv); 2404 iwl_release_nic_access(priv);
2958} 2405}
2959 2406
2960/**
2961 * iwl3945_irq_handle_error - called for HW or SW error interrupt from card
2962 */
2963static void iwl3945_irq_handle_error(struct iwl_priv *priv)
2964{
2965 /* Set the FW error flag -- cleared on iwl3945_down */
2966 set_bit(STATUS_FW_ERROR, &priv->status);
2967
2968 /* Cancel currently queued command. */
2969 clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
2970
2971#ifdef CONFIG_IWLWIFI_DEBUG
2972 if (priv->debug_level & IWL_DL_FW_ERRORS) {
2973 iwl3945_dump_nic_error_log(priv);
2974 iwl3945_dump_nic_event_log(priv);
2975 iwl3945_print_rx_config_cmd(priv, &priv->staging39_rxon);
2976 }
2977#endif
2978
2979 wake_up_interruptible(&priv->wait_command_queue);
2980
2981 /* Keep the restart process from trying to send host
2982 * commands by clearing the INIT status bit */
2983 clear_bit(STATUS_READY, &priv->status);
2984
2985 if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) {
2986 IWL_DEBUG(IWL_DL_INFO | IWL_DL_FW_ERRORS,
2987 "Restarting adapter due to uCode error.\n");
2988
2989 if (iwl3945_is_associated(priv)) {
2990 memcpy(&priv->recovery39_rxon, &priv->active39_rxon,
2991 sizeof(priv->recovery39_rxon));
2992 priv->error_recovering = 1;
2993 }
2994 if (priv->cfg->mod_params->restart_fw)
2995 queue_work(priv->workqueue, &priv->restart);
2996 }
2997}
2998
2999static void iwl3945_error_recovery(struct iwl_priv *priv) 2407static void iwl3945_error_recovery(struct iwl_priv *priv)
3000{ 2408{
3001 unsigned long flags; 2409 unsigned long flags;
3002 2410
3003 memcpy(&priv->staging39_rxon, &priv->recovery39_rxon, 2411 memcpy(&priv->staging_rxon, &priv->recovery_rxon,
3004 sizeof(priv->staging39_rxon)); 2412 sizeof(priv->staging_rxon));
3005 priv->staging39_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2413 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3006 iwl3945_commit_rxon(priv); 2414 iwl3945_commit_rxon(priv);
3007 2415
3008 iwl3945_add_station(priv, priv->bssid, 1, 0); 2416 iwl3945_add_station(priv, priv->bssid, 1, 0);
3009 2417
3010 spin_lock_irqsave(&priv->lock, flags); 2418 spin_lock_irqsave(&priv->lock, flags);
3011 priv->assoc_id = le16_to_cpu(priv->staging39_rxon.assoc_id); 2419 priv->assoc_id = le16_to_cpu(priv->staging_rxon.assoc_id);
3012 priv->error_recovering = 0; 2420 priv->error_recovering = 0;
3013 spin_unlock_irqrestore(&priv->lock, flags); 2421 spin_unlock_irqrestore(&priv->lock, flags);
3014} 2422}
@@ -3040,7 +2448,7 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
3040 if (priv->debug_level & IWL_DL_ISR) { 2448 if (priv->debug_level & IWL_DL_ISR) {
3041 /* just for debug */ 2449 /* just for debug */
3042 inta_mask = iwl_read32(priv, CSR_INT_MASK); 2450 inta_mask = iwl_read32(priv, CSR_INT_MASK);
3043 IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 2451 IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
3044 inta, inta_mask, inta_fh); 2452 inta, inta_mask, inta_fh);
3045 } 2453 }
3046#endif 2454#endif
@@ -3061,7 +2469,7 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
3061 /* Tell the device to stop sending interrupts */ 2469 /* Tell the device to stop sending interrupts */
3062 iwl3945_disable_interrupts(priv); 2470 iwl3945_disable_interrupts(priv);
3063 2471
3064 iwl3945_irq_handle_error(priv); 2472 iwl_irq_handle_error(priv);
3065 2473
3066 handled |= CSR_INT_BIT_HW_ERR; 2474 handled |= CSR_INT_BIT_HW_ERR;
3067 2475
@@ -3074,12 +2482,12 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
3074 if (priv->debug_level & (IWL_DL_ISR)) { 2482 if (priv->debug_level & (IWL_DL_ISR)) {
3075 /* NIC fires this, but we don't use it, redundant with WAKEUP */ 2483 /* NIC fires this, but we don't use it, redundant with WAKEUP */
3076 if (inta & CSR_INT_BIT_SCD) 2484 if (inta & CSR_INT_BIT_SCD)
3077 IWL_DEBUG_ISR("Scheduler finished to transmit " 2485 IWL_DEBUG_ISR(priv, "Scheduler finished to transmit "
3078 "the frame/frames.\n"); 2486 "the frame/frames.\n");
3079 2487
3080 /* Alive notification via Rx interrupt will do the real work */ 2488 /* Alive notification via Rx interrupt will do the real work */
3081 if (inta & CSR_INT_BIT_ALIVE) 2489 if (inta & CSR_INT_BIT_ALIVE)
3082 IWL_DEBUG_ISR("Alive interrupt\n"); 2490 IWL_DEBUG_ISR(priv, "Alive interrupt\n");
3083 } 2491 }
3084#endif 2492#endif
3085 /* Safely ignore these bits for debug checks below */ 2493 /* Safely ignore these bits for debug checks below */
@@ -3089,13 +2497,13 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
3089 if (inta & CSR_INT_BIT_SW_ERR) { 2497 if (inta & CSR_INT_BIT_SW_ERR) {
3090 IWL_ERR(priv, "Microcode SW error detected. " 2498 IWL_ERR(priv, "Microcode SW error detected. "
3091 "Restarting 0x%X.\n", inta); 2499 "Restarting 0x%X.\n", inta);
3092 iwl3945_irq_handle_error(priv); 2500 iwl_irq_handle_error(priv);
3093 handled |= CSR_INT_BIT_SW_ERR; 2501 handled |= CSR_INT_BIT_SW_ERR;
3094 } 2502 }
3095 2503
3096 /* uCode wakes up after power-down sleep */ 2504 /* uCode wakes up after power-down sleep */
3097 if (inta & CSR_INT_BIT_WAKEUP) { 2505 if (inta & CSR_INT_BIT_WAKEUP) {
3098 IWL_DEBUG_ISR("Wakeup interrupt\n"); 2506 IWL_DEBUG_ISR(priv, "Wakeup interrupt\n");
3099 iwl_rx_queue_update_write_ptr(priv, &priv->rxq); 2507 iwl_rx_queue_update_write_ptr(priv, &priv->rxq);
3100 iwl_txq_update_write_ptr(priv, &priv->txq[0]); 2508 iwl_txq_update_write_ptr(priv, &priv->txq[0]);
3101 iwl_txq_update_write_ptr(priv, &priv->txq[1]); 2509 iwl_txq_update_write_ptr(priv, &priv->txq[1]);
@@ -3116,7 +2524,7 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
3116 } 2524 }
3117 2525
3118 if (inta & CSR_INT_BIT_FH_TX) { 2526 if (inta & CSR_INT_BIT_FH_TX) {
3119 IWL_DEBUG_ISR("Tx interrupt\n"); 2527 IWL_DEBUG_ISR(priv, "Tx interrupt\n");
3120 2528
3121 iwl_write32(priv, CSR_FH_INT_STATUS, (1 << 6)); 2529 iwl_write32(priv, CSR_FH_INT_STATUS, (1 << 6));
3122 if (!iwl_grab_nic_access(priv)) { 2530 if (!iwl_grab_nic_access(priv)) {
@@ -3146,7 +2554,7 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv)
3146 inta = iwl_read32(priv, CSR_INT); 2554 inta = iwl_read32(priv, CSR_INT);
3147 inta_mask = iwl_read32(priv, CSR_INT_MASK); 2555 inta_mask = iwl_read32(priv, CSR_INT_MASK);
3148 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); 2556 inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS);
3149 IWL_DEBUG_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " 2557 IWL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, "
3150 "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); 2558 "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags);
3151 } 2559 }
3152#endif 2560#endif
@@ -3178,7 +2586,7 @@ static irqreturn_t iwl3945_isr(int irq, void *data)
3178 * This may be due to IRQ shared with another device, 2586 * This may be due to IRQ shared with another device,
3179 * or due to sporadic interrupts thrown from our NIC. */ 2587 * or due to sporadic interrupts thrown from our NIC. */
3180 if (!inta && !inta_fh) { 2588 if (!inta && !inta_fh) {
3181 IWL_DEBUG_ISR("Ignore interrupt, inta == 0, inta_fh == 0\n"); 2589 IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n");
3182 goto none; 2590 goto none;
3183 } 2591 }
3184 2592
@@ -3188,7 +2596,7 @@ static irqreturn_t iwl3945_isr(int irq, void *data)
3188 goto unplugged; 2596 goto unplugged;
3189 } 2597 }
3190 2598
3191 IWL_DEBUG_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 2599 IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
3192 inta, inta_mask, inta_fh); 2600 inta, inta_mask, inta_fh);
3193 2601
3194 inta &= ~CSR_INT_BIT_SCD; 2602 inta &= ~CSR_INT_BIT_SCD;
@@ -3242,7 +2650,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
3242 2650
3243 ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); 2651 ch_info = iwl_get_channel_info(priv, band, scan_ch->channel);
3244 if (!is_channel_valid(ch_info)) { 2652 if (!is_channel_valid(ch_info)) {
3245 IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n", 2653 IWL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n",
3246 scan_ch->channel); 2654 scan_ch->channel);
3247 continue; 2655 continue;
3248 } 2656 }
@@ -3290,7 +2698,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
3290 */ 2698 */
3291 } 2699 }
3292 2700
3293 IWL_DEBUG_SCAN("Scanning %d [%s %d]\n", 2701 IWL_DEBUG_SCAN(priv, "Scanning %d [%s %d]\n",
3294 scan_ch->channel, 2702 scan_ch->channel,
3295 (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", 2703 (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE",
3296 (scan_ch->type & 1) ? 2704 (scan_ch->type & 1) ?
@@ -3300,7 +2708,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv,
3300 added++; 2708 added++;
3301 } 2709 }
3302 2710
3303 IWL_DEBUG_SCAN("total channels to scan %d \n", added); 2711 IWL_DEBUG_SCAN(priv, "total channels to scan %d \n", added);
3304 return added; 2712 return added;
3305} 2713}
3306 2714
@@ -3351,7 +2759,7 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le
3351 int rc = 0; 2759 int rc = 0;
3352 u32 errcnt; 2760 u32 errcnt;
3353 2761
3354 IWL_DEBUG_INFO("ucode inst image size is %u\n", len); 2762 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
3355 2763
3356 rc = iwl_grab_nic_access(priv); 2764 rc = iwl_grab_nic_access(priv);
3357 if (rc) 2765 if (rc)
@@ -3380,7 +2788,8 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le
3380 iwl_release_nic_access(priv); 2788 iwl_release_nic_access(priv);
3381 2789
3382 if (!errcnt) 2790 if (!errcnt)
3383 IWL_DEBUG_INFO("ucode image in INSTRUCTION memory is good\n"); 2791 IWL_DEBUG_INFO(priv,
2792 "ucode image in INSTRUCTION memory is good\n");
3384 2793
3385 return rc; 2794 return rc;
3386} 2795}
@@ -3398,7 +2807,7 @@ static int iwl3945_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32
3398 u32 errcnt = 0; 2807 u32 errcnt = 0;
3399 u32 i; 2808 u32 i;
3400 2809
3401 IWL_DEBUG_INFO("ucode inst image size is %u\n", len); 2810 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
3402 2811
3403 rc = iwl_grab_nic_access(priv); 2812 rc = iwl_grab_nic_access(priv);
3404 if (rc) 2813 if (rc)
@@ -3445,7 +2854,7 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv)
3445 len = priv->ucode_boot.len; 2854 len = priv->ucode_boot.len;
3446 rc = iwl3945_verify_inst_sparse(priv, image, len); 2855 rc = iwl3945_verify_inst_sparse(priv, image, len);
3447 if (rc == 0) { 2856 if (rc == 0) {
3448 IWL_DEBUG_INFO("Bootstrap uCode is good in inst SRAM\n"); 2857 IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n");
3449 return 0; 2858 return 0;
3450 } 2859 }
3451 2860
@@ -3454,7 +2863,7 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv)
3454 len = priv->ucode_init.len; 2863 len = priv->ucode_init.len;
3455 rc = iwl3945_verify_inst_sparse(priv, image, len); 2864 rc = iwl3945_verify_inst_sparse(priv, image, len);
3456 if (rc == 0) { 2865 if (rc == 0) {
3457 IWL_DEBUG_INFO("Initialize uCode is good in inst SRAM\n"); 2866 IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n");
3458 return 0; 2867 return 0;
3459 } 2868 }
3460 2869
@@ -3463,7 +2872,7 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv)
3463 len = priv->ucode_code.len; 2872 len = priv->ucode_code.len;
3464 rc = iwl3945_verify_inst_sparse(priv, image, len); 2873 rc = iwl3945_verify_inst_sparse(priv, image, len);
3465 if (rc == 0) { 2874 if (rc == 0) {
3466 IWL_DEBUG_INFO("Runtime uCode is good in inst SRAM\n"); 2875 IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n");
3467 return 0; 2876 return 0;
3468 } 2877 }
3469 2878
@@ -3522,7 +2931,8 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
3522 "which is deprecated. " 2931 "which is deprecated. "
3523 " Please use API v%u instead.\n", 2932 " Please use API v%u instead.\n",
3524 buf, api_max); 2933 buf, api_max);
3525 IWL_DEBUG_INFO("Got firmware '%s' file (%zd bytes) from disk\n", 2934 IWL_DEBUG_INFO(priv, "Got firmware '%s' file "
2935 "(%zd bytes) from disk\n",
3526 buf, ucode_raw->size); 2936 buf, ucode_raw->size);
3527 break; 2937 break;
3528 } 2938 }
@@ -3573,13 +2983,18 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
3573 IWL_UCODE_API(priv->ucode_ver), 2983 IWL_UCODE_API(priv->ucode_ver),
3574 IWL_UCODE_SERIAL(priv->ucode_ver)); 2984 IWL_UCODE_SERIAL(priv->ucode_ver));
3575 2985
3576 IWL_DEBUG_INFO("f/w package hdr ucode version raw = 0x%x\n", 2986 IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n",
3577 priv->ucode_ver); 2987 priv->ucode_ver);
3578 IWL_DEBUG_INFO("f/w package hdr runtime inst size = %u\n", inst_size); 2988 IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n",
3579 IWL_DEBUG_INFO("f/w package hdr runtime data size = %u\n", data_size); 2989 inst_size);
3580 IWL_DEBUG_INFO("f/w package hdr init inst size = %u\n", init_size); 2990 IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n",
3581 IWL_DEBUG_INFO("f/w package hdr init data size = %u\n", init_data_size); 2991 data_size);
3582 IWL_DEBUG_INFO("f/w package hdr boot inst size = %u\n", boot_size); 2992 IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n",
2993 init_size);
2994 IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n",
2995 init_data_size);
2996 IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n",
2997 boot_size);
3583 2998
3584 2999
3585 /* Verify size of file vs. image size info in file's header */ 3000 /* Verify size of file vs. image size info in file's header */
@@ -3587,40 +3002,43 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
3587 inst_size + data_size + init_size + 3002 inst_size + data_size + init_size +
3588 init_data_size + boot_size) { 3003 init_data_size + boot_size) {
3589 3004
3590 IWL_DEBUG_INFO("uCode file size %d too small\n", 3005 IWL_DEBUG_INFO(priv, "uCode file size %zd too small\n",
3591 (int)ucode_raw->size); 3006 ucode_raw->size);
3592 ret = -EINVAL; 3007 ret = -EINVAL;
3593 goto err_release; 3008 goto err_release;
3594 } 3009 }
3595 3010
3596 /* Verify that uCode images will fit in card's SRAM */ 3011 /* Verify that uCode images will fit in card's SRAM */
3597 if (inst_size > IWL39_MAX_INST_SIZE) { 3012 if (inst_size > IWL39_MAX_INST_SIZE) {
3598 IWL_DEBUG_INFO("uCode instr len %d too large to fit in\n", 3013 IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n",
3599 inst_size); 3014 inst_size);
3600 ret = -EINVAL; 3015 ret = -EINVAL;
3601 goto err_release; 3016 goto err_release;
3602 } 3017 }
3603 3018
3604 if (data_size > IWL39_MAX_DATA_SIZE) { 3019 if (data_size > IWL39_MAX_DATA_SIZE) {
3605 IWL_DEBUG_INFO("uCode data len %d too large to fit in\n", 3020 IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n",
3606 data_size); 3021 data_size);
3607 ret = -EINVAL; 3022 ret = -EINVAL;
3608 goto err_release; 3023 goto err_release;
3609 } 3024 }
3610 if (init_size > IWL39_MAX_INST_SIZE) { 3025 if (init_size > IWL39_MAX_INST_SIZE) {
3611 IWL_DEBUG_INFO("uCode init instr len %d too large to fit in\n", 3026 IWL_DEBUG_INFO(priv,
3027 "uCode init instr len %d too large to fit in\n",
3612 init_size); 3028 init_size);
3613 ret = -EINVAL; 3029 ret = -EINVAL;
3614 goto err_release; 3030 goto err_release;
3615 } 3031 }
3616 if (init_data_size > IWL39_MAX_DATA_SIZE) { 3032 if (init_data_size > IWL39_MAX_DATA_SIZE) {
3617 IWL_DEBUG_INFO("uCode init data len %d too large to fit in\n", 3033 IWL_DEBUG_INFO(priv,
3034 "uCode init data len %d too large to fit in\n",
3618 init_data_size); 3035 init_data_size);
3619 ret = -EINVAL; 3036 ret = -EINVAL;
3620 goto err_release; 3037 goto err_release;
3621 } 3038 }
3622 if (boot_size > IWL39_MAX_BSM_SIZE) { 3039 if (boot_size > IWL39_MAX_BSM_SIZE) {
3623 IWL_DEBUG_INFO("uCode boot instr len %d too large to fit in\n", 3040 IWL_DEBUG_INFO(priv,
3041 "uCode boot instr len %d too large to fit in\n",
3624 boot_size); 3042 boot_size);
3625 ret = -EINVAL; 3043 ret = -EINVAL;
3626 goto err_release; 3044 goto err_release;
@@ -3670,16 +3088,18 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
3670 /* Runtime instructions (first block of data in file) */ 3088 /* Runtime instructions (first block of data in file) */
3671 src = &ucode->data[0]; 3089 src = &ucode->data[0];
3672 len = priv->ucode_code.len; 3090 len = priv->ucode_code.len;
3673 IWL_DEBUG_INFO("Copying (but not loading) uCode instr len %Zd\n", len); 3091 IWL_DEBUG_INFO(priv,
3092 "Copying (but not loading) uCode instr len %zd\n", len);
3674 memcpy(priv->ucode_code.v_addr, src, len); 3093 memcpy(priv->ucode_code.v_addr, src, len);
3675 IWL_DEBUG_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", 3094 IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n",
3676 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); 3095 priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr);
3677 3096
3678 /* Runtime data (2nd block) 3097 /* Runtime data (2nd block)
3679 * NOTE: Copy into backup buffer will be done in iwl3945_up() */ 3098 * NOTE: Copy into backup buffer will be done in iwl3945_up() */
3680 src = &ucode->data[inst_size]; 3099 src = &ucode->data[inst_size];
3681 len = priv->ucode_data.len; 3100 len = priv->ucode_data.len;
3682 IWL_DEBUG_INFO("Copying (but not loading) uCode data len %Zd\n", len); 3101 IWL_DEBUG_INFO(priv,
3102 "Copying (but not loading) uCode data len %zd\n", len);
3683 memcpy(priv->ucode_data.v_addr, src, len); 3103 memcpy(priv->ucode_data.v_addr, src, len);
3684 memcpy(priv->ucode_data_backup.v_addr, src, len); 3104 memcpy(priv->ucode_data_backup.v_addr, src, len);
3685 3105
@@ -3687,8 +3107,8 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
3687 if (init_size) { 3107 if (init_size) {
3688 src = &ucode->data[inst_size + data_size]; 3108 src = &ucode->data[inst_size + data_size];
3689 len = priv->ucode_init.len; 3109 len = priv->ucode_init.len;
3690 IWL_DEBUG_INFO("Copying (but not loading) init instr len %Zd\n", 3110 IWL_DEBUG_INFO(priv,
3691 len); 3111 "Copying (but not loading) init instr len %zd\n", len);
3692 memcpy(priv->ucode_init.v_addr, src, len); 3112 memcpy(priv->ucode_init.v_addr, src, len);
3693 } 3113 }
3694 3114
@@ -3696,16 +3116,16 @@ static int iwl3945_read_ucode(struct iwl_priv *priv)
3696 if (init_data_size) { 3116 if (init_data_size) {
3697 src = &ucode->data[inst_size + data_size + init_size]; 3117 src = &ucode->data[inst_size + data_size + init_size];
3698 len = priv->ucode_init_data.len; 3118 len = priv->ucode_init_data.len;
3699 IWL_DEBUG_INFO("Copying (but not loading) init data len %d\n", 3119 IWL_DEBUG_INFO(priv,
3700 (int)len); 3120 "Copying (but not loading) init data len %zd\n", len);
3701 memcpy(priv->ucode_init_data.v_addr, src, len); 3121 memcpy(priv->ucode_init_data.v_addr, src, len);
3702 } 3122 }
3703 3123
3704 /* Bootstrap instructions (5th block) */ 3124 /* Bootstrap instructions (5th block) */
3705 src = &ucode->data[inst_size + data_size + init_size + init_data_size]; 3125 src = &ucode->data[inst_size + data_size + init_size + init_data_size];
3706 len = priv->ucode_boot.len; 3126 len = priv->ucode_boot.len;
3707 IWL_DEBUG_INFO("Copying (but not loading) boot instr len %d\n", 3127 IWL_DEBUG_INFO(priv,
3708 (int)len); 3128 "Copying (but not loading) boot instr len %zd\n", len);
3709 memcpy(priv->ucode_boot.v_addr, src, len); 3129 memcpy(priv->ucode_boot.v_addr, src, len);
3710 3130
3711 /* We have our copies now, allow OS release its copies */ 3131 /* We have our copies now, allow OS release its copies */
@@ -3767,7 +3187,7 @@ static int iwl3945_set_ucode_ptrs(struct iwl_priv *priv)
3767 3187
3768 spin_unlock_irqrestore(&priv->lock, flags); 3188 spin_unlock_irqrestore(&priv->lock, flags);
3769 3189
3770 IWL_DEBUG_INFO("Runtime uCode pointers are set.\n"); 3190 IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n");
3771 3191
3772 return rc; 3192 return rc;
3773} 3193}
@@ -3785,7 +3205,7 @@ static void iwl3945_init_alive_start(struct iwl_priv *priv)
3785 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { 3205 if (priv->card_alive_init.is_valid != UCODE_VALID_OK) {
3786 /* We had an error bringing up the hardware, so take it 3206 /* We had an error bringing up the hardware, so take it
3787 * all the way back down so we can try again */ 3207 * all the way back down so we can try again */
3788 IWL_DEBUG_INFO("Initialize Alive failed.\n"); 3208 IWL_DEBUG_INFO(priv, "Initialize Alive failed.\n");
3789 goto restart; 3209 goto restart;
3790 } 3210 }
3791 3211
@@ -3795,18 +3215,18 @@ static void iwl3945_init_alive_start(struct iwl_priv *priv)
3795 if (iwl3945_verify_ucode(priv)) { 3215 if (iwl3945_verify_ucode(priv)) {
3796 /* Runtime instruction load was bad; 3216 /* Runtime instruction load was bad;
3797 * take it all the way back down so we can try again */ 3217 * take it all the way back down so we can try again */
3798 IWL_DEBUG_INFO("Bad \"initialize\" uCode load.\n"); 3218 IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n");
3799 goto restart; 3219 goto restart;
3800 } 3220 }
3801 3221
3802 /* Send pointers to protocol/runtime uCode image ... init code will 3222 /* Send pointers to protocol/runtime uCode image ... init code will
3803 * load and launch runtime uCode, which will send us another "Alive" 3223 * load and launch runtime uCode, which will send us another "Alive"
3804 * notification. */ 3224 * notification. */
3805 IWL_DEBUG_INFO("Initialization Alive received.\n"); 3225 IWL_DEBUG_INFO(priv, "Initialization Alive received.\n");
3806 if (iwl3945_set_ucode_ptrs(priv)) { 3226 if (iwl3945_set_ucode_ptrs(priv)) {
3807 /* Runtime instruction load won't happen; 3227 /* Runtime instruction load won't happen;
3808 * take it all the way back down so we can try again */ 3228 * take it all the way back down so we can try again */
3809 IWL_DEBUG_INFO("Couldn't set up uCode pointers.\n"); 3229 IWL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n");
3810 goto restart; 3230 goto restart;
3811 } 3231 }
3812 return; 3232 return;
@@ -3831,12 +3251,12 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
3831 int thermal_spin = 0; 3251 int thermal_spin = 0;
3832 u32 rfkill; 3252 u32 rfkill;
3833 3253
3834 IWL_DEBUG_INFO("Runtime Alive received.\n"); 3254 IWL_DEBUG_INFO(priv, "Runtime Alive received.\n");
3835 3255
3836 if (priv->card_alive.is_valid != UCODE_VALID_OK) { 3256 if (priv->card_alive.is_valid != UCODE_VALID_OK) {
3837 /* We had an error bringing up the hardware, so take it 3257 /* We had an error bringing up the hardware, so take it
3838 * all the way back down so we can try again */ 3258 * all the way back down so we can try again */
3839 IWL_DEBUG_INFO("Alive failed.\n"); 3259 IWL_DEBUG_INFO(priv, "Alive failed.\n");
3840 goto restart; 3260 goto restart;
3841 } 3261 }
3842 3262
@@ -3846,7 +3266,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
3846 if (iwl3945_verify_ucode(priv)) { 3266 if (iwl3945_verify_ucode(priv)) {
3847 /* Runtime instruction load was bad; 3267 /* Runtime instruction load was bad;
3848 * take it all the way back down so we can try again */ 3268 * take it all the way back down so we can try again */
3849 IWL_DEBUG_INFO("Bad runtime uCode load.\n"); 3269 IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n");
3850 goto restart; 3270 goto restart;
3851 } 3271 }
3852 3272
@@ -3859,7 +3279,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
3859 } 3279 }
3860 3280
3861 rfkill = iwl_read_prph(priv, APMG_RFKILL_REG); 3281 rfkill = iwl_read_prph(priv, APMG_RFKILL_REG);
3862 IWL_DEBUG_INFO("RFKILL status: 0x%x\n", rfkill); 3282 IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill);
3863 iwl_release_nic_access(priv); 3283 iwl_release_nic_access(priv);
3864 3284
3865 if (rfkill & 0x1) { 3285 if (rfkill & 0x1) {
@@ -3872,7 +3292,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
3872 } 3292 }
3873 3293
3874 if (thermal_spin) 3294 if (thermal_spin)
3875 IWL_DEBUG_INFO("Thermal calibration took %dus\n", 3295 IWL_DEBUG_INFO(priv, "Thermal calibration took %dus\n",
3876 thermal_spin * 10); 3296 thermal_spin * 10);
3877 } else 3297 } else
3878 set_bit(STATUS_RF_KILL_HW, &priv->status); 3298 set_bit(STATUS_RF_KILL_HW, &priv->status);
@@ -3891,19 +3311,18 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
3891 priv->active_rate = priv->rates_mask; 3311 priv->active_rate = priv->rates_mask;
3892 priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK; 3312 priv->active_rate_basic = priv->rates_mask & IWL_BASIC_RATES_MASK;
3893 3313
3894 iwl3945_send_power_mode(priv, IWL_POWER_LEVEL(priv->power_mode)); 3314 iwl_power_update_mode(priv, false);
3895 3315
3896 if (iwl3945_is_associated(priv)) { 3316 if (iwl_is_associated(priv)) {
3897 struct iwl3945_rxon_cmd *active_rxon = 3317 struct iwl3945_rxon_cmd *active_rxon =
3898 (struct iwl3945_rxon_cmd *)(&priv->active39_rxon); 3318 (struct iwl3945_rxon_cmd *)(&priv->active_rxon);
3899 3319
3900 memcpy(&priv->staging39_rxon, &priv->active39_rxon, 3320 memcpy(&priv->staging_rxon, &priv->active_rxon,
3901 sizeof(priv->staging39_rxon)); 3321 sizeof(priv->staging_rxon));
3902 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3322 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
3903 } else { 3323 } else {
3904 /* Initialize our rx_config data */ 3324 /* Initialize our rx_config data */
3905 iwl3945_connection_init_rx_config(priv, priv->iw_mode); 3325 iwl_connection_init_rx_config(priv, priv->iw_mode);
3906 memcpy(priv->staging39_rxon.node_addr, priv->mac_addr, ETH_ALEN);
3907 } 3326 }
3908 3327
3909 /* Configure Bluetooth device coexistence support */ 3328 /* Configure Bluetooth device coexistence support */
@@ -3916,7 +3335,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
3916 3335
3917 iwl3945_led_register(priv); 3336 iwl3945_led_register(priv);
3918 3337
3919 IWL_DEBUG_INFO("ALIVE processing complete.\n"); 3338 IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n");
3920 set_bit(STATUS_READY, &priv->status); 3339 set_bit(STATUS_READY, &priv->status);
3921 wake_up_interruptible(&priv->wait_command_queue); 3340 wake_up_interruptible(&priv->wait_command_queue);
3922 3341
@@ -3945,7 +3364,7 @@ static void __iwl3945_down(struct iwl_priv *priv)
3945 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status); 3364 int exit_pending = test_bit(STATUS_EXIT_PENDING, &priv->status);
3946 struct ieee80211_conf *conf = NULL; 3365 struct ieee80211_conf *conf = NULL;
3947 3366
3948 IWL_DEBUG_INFO(DRV_NAME " is going down\n"); 3367 IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n");
3949 3368
3950 conf = ieee80211_get_hw_conf(priv->hw); 3369 conf = ieee80211_get_hw_conf(priv->hw);
3951 3370
@@ -4132,7 +3551,7 @@ static int __iwl3945_up(struct iwl_priv *priv)
4132 /* start card; "initialize" will load runtime ucode */ 3551 /* start card; "initialize" will load runtime ucode */
4133 iwl3945_nic_start(priv); 3552 iwl3945_nic_start(priv);
4134 3553
4135 IWL_DEBUG_INFO(DRV_NAME " is coming up\n"); 3554 IWL_DEBUG_INFO(priv, DRV_NAME " is coming up\n");
4136 3555
4137 return 0; 3556 return 0;
4138 } 3557 }
@@ -4233,34 +3652,36 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
4233 /* This should never be called or scheduled if there is currently 3652 /* This should never be called or scheduled if there is currently
4234 * a scan active in the hardware. */ 3653 * a scan active in the hardware. */
4235 if (test_bit(STATUS_SCAN_HW, &priv->status)) { 3654 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
4236 IWL_DEBUG_INFO("Multiple concurrent scan requests in parallel. " 3655 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests "
4237 "Ignoring second request.\n"); 3656 "Ignoring second request.\n");
4238 rc = -EIO; 3657 rc = -EIO;
4239 goto done; 3658 goto done;
4240 } 3659 }
4241 3660
4242 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { 3661 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
4243 IWL_DEBUG_SCAN("Aborting scan due to device shutdown\n"); 3662 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
4244 goto done; 3663 goto done;
4245 } 3664 }
4246 3665
4247 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 3666 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
4248 IWL_DEBUG_HC("Scan request while abort pending. Queuing.\n"); 3667 IWL_DEBUG_HC(priv,
3668 "Scan request while abort pending. Queuing.\n");
4249 goto done; 3669 goto done;
4250 } 3670 }
4251 3671
4252 if (iwl_is_rfkill(priv)) { 3672 if (iwl_is_rfkill(priv)) {
4253 IWL_DEBUG_HC("Aborting scan due to RF Kill activation\n"); 3673 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
4254 goto done; 3674 goto done;
4255 } 3675 }
4256 3676
4257 if (!test_bit(STATUS_READY, &priv->status)) { 3677 if (!test_bit(STATUS_READY, &priv->status)) {
4258 IWL_DEBUG_HC("Scan request while uninitialized. Queuing.\n"); 3678 IWL_DEBUG_HC(priv,
3679 "Scan request while uninitialized. Queuing.\n");
4259 goto done; 3680 goto done;
4260 } 3681 }
4261 3682
4262 if (!priv->scan_bands) { 3683 if (!priv->scan_bands) {
4263 IWL_DEBUG_HC("Aborting scan due to no requested bands\n"); 3684 IWL_DEBUG_HC(priv, "Aborting scan due to no requested bands\n");
4264 goto done; 3685 goto done;
4265 } 3686 }
4266 3687
@@ -4278,14 +3699,14 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
4278 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 3699 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
4279 scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 3700 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
4280 3701
4281 if (iwl3945_is_associated(priv)) { 3702 if (iwl_is_associated(priv)) {
4282 u16 interval = 0; 3703 u16 interval = 0;
4283 u32 extra; 3704 u32 extra;
4284 u32 suspend_time = 100; 3705 u32 suspend_time = 100;
4285 u32 scan_suspend_time = 100; 3706 u32 scan_suspend_time = 100;
4286 unsigned long flags; 3707 unsigned long flags;
4287 3708
4288 IWL_DEBUG_INFO("Scanning while associated...\n"); 3709 IWL_DEBUG_INFO(priv, "Scanning while associated...\n");
4289 3710
4290 spin_lock_irqsave(&priv->lock, flags); 3711 spin_lock_irqsave(&priv->lock, flags);
4291 interval = priv->beacon_int; 3712 interval = priv->beacon_int;
@@ -4307,15 +3728,14 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
4307 (extra | ((suspend_time % interval) * 1024)); 3728 (extra | ((suspend_time % interval) * 1024));
4308 3729
4309 scan->suspend_time = cpu_to_le32(scan_suspend_time); 3730 scan->suspend_time = cpu_to_le32(scan_suspend_time);
4310 IWL_DEBUG_SCAN("suspend_time 0x%X beacon interval %d\n", 3731 IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n",
4311 scan_suspend_time, interval); 3732 scan_suspend_time, interval);
4312 } 3733 }
4313 3734
4314 /* We should add the ability for user to lock to PASSIVE ONLY */ 3735 /* We should add the ability for user to lock to PASSIVE ONLY */
4315 if (priv->one_direct_scan) { 3736 if (priv->one_direct_scan) {
4316 IWL_DEBUG_SCAN 3737 IWL_DEBUG_SCAN(priv, "Kicking off one direct scan for '%s'\n",
4317 ("Kicking off one direct scan for '%s'\n", 3738 print_ssid(ssid, priv->direct_ssid,
4318 print_ssid(ssid, priv->direct_ssid,
4319 priv->direct_ssid_len)); 3739 priv->direct_ssid_len));
4320 scan->direct_scan[0].id = WLAN_EID_SSID; 3740 scan->direct_scan[0].id = WLAN_EID_SSID;
4321 scan->direct_scan[0].len = priv->direct_ssid_len; 3741 scan->direct_scan[0].len = priv->direct_ssid_len;
@@ -4323,7 +3743,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
4323 priv->direct_ssid, priv->direct_ssid_len); 3743 priv->direct_ssid, priv->direct_ssid_len);
4324 n_probes++; 3744 n_probes++;
4325 } else 3745 } else
4326 IWL_DEBUG_SCAN("Kicking off one indirect scan.\n"); 3746 IWL_DEBUG_SCAN(priv, "Kicking off one indirect scan.\n");
4327 3747
4328 /* We don't build a direct scan probe request; the uCode will do 3748 /* We don't build a direct scan probe request; the uCode will do
4329 * that based on the direct_mask added to each channel entry */ 3749 * that based on the direct_mask added to each channel entry */
@@ -4364,7 +3784,7 @@ static void iwl3945_bg_request_scan(struct work_struct *data)
4364 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]); 3784 (void *)&scan->data[le16_to_cpu(scan->tx_cmd.len)]);
4365 3785
4366 if (scan->channel_count == 0) { 3786 if (scan->channel_count == 0) {
4367 IWL_DEBUG_SCAN("channel count %d\n", scan->channel_count); 3787 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
4368 goto done; 3788 goto done;
4369 } 3789 }
4370 3790
@@ -4448,8 +3868,8 @@ static void iwl3945_post_associate(struct iwl_priv *priv)
4448 } 3868 }
4449 3869
4450 3870
4451 IWL_DEBUG_ASSOC("Associated as %d to: %pM\n", 3871 IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n",
4452 priv->assoc_id, priv->active39_rxon.bssid_addr); 3872 priv->assoc_id, priv->active_rxon.bssid_addr);
4453 3873
4454 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 3874 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
4455 return; 3875 return;
@@ -4461,7 +3881,7 @@ static void iwl3945_post_associate(struct iwl_priv *priv)
4461 3881
4462 conf = ieee80211_get_hw_conf(priv->hw); 3882 conf = ieee80211_get_hw_conf(priv->hw);
4463 3883
4464 priv->staging39_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 3884 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
4465 iwl3945_commit_rxon(priv); 3885 iwl3945_commit_rxon(priv);
4466 3886
4467 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); 3887 memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
@@ -4472,26 +3892,26 @@ static void iwl3945_post_associate(struct iwl_priv *priv)
4472 IWL_WARN(priv, "REPLY_RXON_TIMING failed - " 3892 IWL_WARN(priv, "REPLY_RXON_TIMING failed - "
4473 "Attempting to continue.\n"); 3893 "Attempting to continue.\n");
4474 3894
4475 priv->staging39_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 3895 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
4476 3896
4477 priv->staging39_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 3897 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
4478 3898
4479 IWL_DEBUG_ASSOC("assoc id %d beacon interval %d\n", 3899 IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n",
4480 priv->assoc_id, priv->beacon_int); 3900 priv->assoc_id, priv->beacon_int);
4481 3901
4482 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 3902 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
4483 priv->staging39_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 3903 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
4484 else 3904 else
4485 priv->staging39_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 3905 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK;
4486 3906
4487 if (priv->staging39_rxon.flags & RXON_FLG_BAND_24G_MSK) { 3907 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
4488 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME) 3908 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)
4489 priv->staging39_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK; 3909 priv->staging_rxon.flags |= RXON_FLG_SHORT_SLOT_MSK;
4490 else 3910 else
4491 priv->staging39_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3911 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
4492 3912
4493 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 3913 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
4494 priv->staging39_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK; 3914 priv->staging_rxon.flags &= ~RXON_FLG_SHORT_SLOT_MSK;
4495 3915
4496 } 3916 }
4497 3917
@@ -4542,12 +3962,12 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
4542 struct iwl_priv *priv = hw->priv; 3962 struct iwl_priv *priv = hw->priv;
4543 int ret; 3963 int ret;
4544 3964
4545 IWL_DEBUG_MAC80211("enter\n"); 3965 IWL_DEBUG_MAC80211(priv, "enter\n");
4546 3966
4547 /* we should be verifying the device is ready to be opened */ 3967 /* we should be verifying the device is ready to be opened */
4548 mutex_lock(&priv->mutex); 3968 mutex_lock(&priv->mutex);
4549 3969
4550 memset(&priv->staging39_rxon, 0, sizeof(struct iwl3945_rxon_cmd)); 3970 memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
4551 /* fetch ucode file from disk, alloc and copy to bus-master buffers ... 3971 /* fetch ucode file from disk, alloc and copy to bus-master buffers ...
4552 * ucode filename and max sizes are card-specific. */ 3972 * ucode filename and max sizes are card-specific. */
4553 3973
@@ -4569,7 +3989,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
4569 if (ret) 3989 if (ret)
4570 goto out_release_irq; 3990 goto out_release_irq;
4571 3991
4572 IWL_DEBUG_INFO("Start UP work.\n"); 3992 IWL_DEBUG_INFO(priv, "Start UP work.\n");
4573 3993
4574 if (test_bit(STATUS_IN_SUSPEND, &priv->status)) 3994 if (test_bit(STATUS_IN_SUSPEND, &priv->status))
4575 return 0; 3995 return 0;
@@ -4594,12 +4014,12 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
4594 cancel_delayed_work(&priv->rfkill_poll); 4014 cancel_delayed_work(&priv->rfkill_poll);
4595 4015
4596 priv->is_open = 1; 4016 priv->is_open = 1;
4597 IWL_DEBUG_MAC80211("leave\n"); 4017 IWL_DEBUG_MAC80211(priv, "leave\n");
4598 return 0; 4018 return 0;
4599 4019
4600out_release_irq: 4020out_release_irq:
4601 priv->is_open = 0; 4021 priv->is_open = 0;
4602 IWL_DEBUG_MAC80211("leave - failed\n"); 4022 IWL_DEBUG_MAC80211(priv, "leave - failed\n");
4603 return ret; 4023 return ret;
4604} 4024}
4605 4025
@@ -4607,10 +4027,10 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw)
4607{ 4027{
4608 struct iwl_priv *priv = hw->priv; 4028 struct iwl_priv *priv = hw->priv;
4609 4029
4610 IWL_DEBUG_MAC80211("enter\n"); 4030 IWL_DEBUG_MAC80211(priv, "enter\n");
4611 4031
4612 if (!priv->is_open) { 4032 if (!priv->is_open) {
4613 IWL_DEBUG_MAC80211("leave - skip\n"); 4033 IWL_DEBUG_MAC80211(priv, "leave - skip\n");
4614 return; 4034 return;
4615 } 4035 }
4616 4036
@@ -4633,22 +4053,22 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw)
4633 queue_delayed_work(priv->workqueue, &priv->rfkill_poll, 4053 queue_delayed_work(priv->workqueue, &priv->rfkill_poll,
4634 round_jiffies_relative(2 * HZ)); 4054 round_jiffies_relative(2 * HZ));
4635 4055
4636 IWL_DEBUG_MAC80211("leave\n"); 4056 IWL_DEBUG_MAC80211(priv, "leave\n");
4637} 4057}
4638 4058
4639static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 4059static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
4640{ 4060{
4641 struct iwl_priv *priv = hw->priv; 4061 struct iwl_priv *priv = hw->priv;
4642 4062
4643 IWL_DEBUG_MAC80211("enter\n"); 4063 IWL_DEBUG_MAC80211(priv, "enter\n");
4644 4064
4645 IWL_DEBUG_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 4065 IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len,
4646 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 4066 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
4647 4067
4648 if (iwl3945_tx_skb(priv, skb)) 4068 if (iwl3945_tx_skb(priv, skb))
4649 dev_kfree_skb_any(skb); 4069 dev_kfree_skb_any(skb);
4650 4070
4651 IWL_DEBUG_MAC80211("leave\n"); 4071 IWL_DEBUG_MAC80211(priv, "leave\n");
4652 return NETDEV_TX_OK; 4072 return NETDEV_TX_OK;
4653} 4073}
4654 4074
@@ -4658,10 +4078,10 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
4658 struct iwl_priv *priv = hw->priv; 4078 struct iwl_priv *priv = hw->priv;
4659 unsigned long flags; 4079 unsigned long flags;
4660 4080
4661 IWL_DEBUG_MAC80211("enter: type %d\n", conf->type); 4081 IWL_DEBUG_MAC80211(priv, "enter: type %d\n", conf->type);
4662 4082
4663 if (priv->vif) { 4083 if (priv->vif) {
4664 IWL_DEBUG_MAC80211("leave - vif != NULL\n"); 4084 IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
4665 return -EOPNOTSUPP; 4085 return -EOPNOTSUPP;
4666 } 4086 }
4667 4087
@@ -4674,7 +4094,7 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
4674 mutex_lock(&priv->mutex); 4094 mutex_lock(&priv->mutex);
4675 4095
4676 if (conf->mac_addr) { 4096 if (conf->mac_addr) {
4677 IWL_DEBUG_MAC80211("Set: %pM\n", conf->mac_addr); 4097 IWL_DEBUG_MAC80211(priv, "Set: %pM\n", conf->mac_addr);
4678 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); 4098 memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
4679 } 4099 }
4680 4100
@@ -4683,7 +4103,7 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
4683 4103
4684 mutex_unlock(&priv->mutex); 4104 mutex_unlock(&priv->mutex);
4685 4105
4686 IWL_DEBUG_MAC80211("leave\n"); 4106 IWL_DEBUG_MAC80211(priv, "leave\n");
4687 return 0; 4107 return 0;
4688} 4108}
4689 4109
@@ -4703,17 +4123,18 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
4703 int ret = 0; 4123 int ret = 0;
4704 4124
4705 mutex_lock(&priv->mutex); 4125 mutex_lock(&priv->mutex);
4706 IWL_DEBUG_MAC80211("enter to channel %d\n", conf->channel->hw_value); 4126 IWL_DEBUG_MAC80211(priv, "enter to channel %d\n",
4127 conf->channel->hw_value);
4707 4128
4708 if (!iwl_is_ready(priv)) { 4129 if (!iwl_is_ready(priv)) {
4709 IWL_DEBUG_MAC80211("leave - not ready\n"); 4130 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
4710 ret = -EIO; 4131 ret = -EIO;
4711 goto out; 4132 goto out;
4712 } 4133 }
4713 4134
4714 if (unlikely(!iwl3945_mod_params.disable_hw_scan && 4135 if (unlikely(!iwl3945_mod_params.disable_hw_scan &&
4715 test_bit(STATUS_SCANNING, &priv->status))) { 4136 test_bit(STATUS_SCANNING, &priv->status))) {
4716 IWL_DEBUG_MAC80211("leave - scanning\n"); 4137 IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
4717 set_bit(STATUS_CONF_PENDING, &priv->status); 4138 set_bit(STATUS_CONF_PENDING, &priv->status);
4718 mutex_unlock(&priv->mutex); 4139 mutex_unlock(&priv->mutex);
4719 return 0; 4140 return 0;
@@ -4724,22 +4145,23 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
4724 ch_info = iwl_get_channel_info(priv, conf->channel->band, 4145 ch_info = iwl_get_channel_info(priv, conf->channel->band,
4725 conf->channel->hw_value); 4146 conf->channel->hw_value);
4726 if (!is_channel_valid(ch_info)) { 4147 if (!is_channel_valid(ch_info)) {
4727 IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this band.\n", 4148 IWL_DEBUG_SCAN(priv,
4728 conf->channel->hw_value, conf->channel->band); 4149 "Channel %d [%d] is INVALID for this band.\n",
4729 IWL_DEBUG_MAC80211("leave - invalid channel\n"); 4150 conf->channel->hw_value, conf->channel->band);
4151 IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n");
4730 spin_unlock_irqrestore(&priv->lock, flags); 4152 spin_unlock_irqrestore(&priv->lock, flags);
4731 ret = -EINVAL; 4153 ret = -EINVAL;
4732 goto out; 4154 goto out;
4733 } 4155 }
4734 4156
4735 iwl3945_set_rxon_channel(priv, conf->channel->band, conf->channel->hw_value); 4157 iwl_set_rxon_channel(priv, conf->channel);
4736 4158
4737 iwl3945_set_flags_for_phymode(priv, conf->channel->band); 4159 iwl_set_flags_for_band(priv, conf->channel->band);
4738 4160
4739 /* The list of supported rates and rate mask can be different 4161 /* The list of supported rates and rate mask can be different
4740 * for each phymode; since the phymode may have changed, reset 4162 * for each phymode; since the phymode may have changed, reset
4741 * the rate mask to what mac80211 lists */ 4163 * the rate mask to what mac80211 lists */
4742 iwl3945_set_rate(priv); 4164 iwl_set_rate(priv);
4743 4165
4744 spin_unlock_irqrestore(&priv->lock, flags); 4166 spin_unlock_irqrestore(&priv->lock, flags);
4745 4167
@@ -4753,25 +4175,25 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
4753 iwl3945_radio_kill_sw(priv, !conf->radio_enabled); 4175 iwl3945_radio_kill_sw(priv, !conf->radio_enabled);
4754 4176
4755 if (!conf->radio_enabled) { 4177 if (!conf->radio_enabled) {
4756 IWL_DEBUG_MAC80211("leave - radio disabled\n"); 4178 IWL_DEBUG_MAC80211(priv, "leave - radio disabled\n");
4757 goto out; 4179 goto out;
4758 } 4180 }
4759 4181
4760 if (iwl_is_rfkill(priv)) { 4182 if (iwl_is_rfkill(priv)) {
4761 IWL_DEBUG_MAC80211("leave - RF kill\n"); 4183 IWL_DEBUG_MAC80211(priv, "leave - RF kill\n");
4762 ret = -EIO; 4184 ret = -EIO;
4763 goto out; 4185 goto out;
4764 } 4186 }
4765 4187
4766 iwl3945_set_rate(priv); 4188 iwl_set_rate(priv);
4767 4189
4768 if (memcmp(&priv->active39_rxon, 4190 if (memcmp(&priv->active_rxon,
4769 &priv->staging39_rxon, sizeof(priv->staging39_rxon))) 4191 &priv->staging_rxon, sizeof(priv->staging_rxon)))
4770 iwl3945_commit_rxon(priv); 4192 iwl3945_commit_rxon(priv);
4771 else 4193 else
4772 IWL_DEBUG_INFO("No re-sending same RXON configuration.\n"); 4194 IWL_DEBUG_INFO(priv, "Not re-sending same RXON configuration\n");
4773 4195
4774 IWL_DEBUG_MAC80211("leave\n"); 4196 IWL_DEBUG_MAC80211(priv, "leave\n");
4775 4197
4776out: 4198out:
4777 clear_bit(STATUS_CONF_PENDING, &priv->status); 4199 clear_bit(STATUS_CONF_PENDING, &priv->status);
@@ -4787,10 +4209,10 @@ static void iwl3945_config_ap(struct iwl_priv *priv)
4787 return; 4209 return;
4788 4210
4789 /* The following should be done only at AP bring up */ 4211 /* The following should be done only at AP bring up */
4790 if (!(iwl3945_is_associated(priv))) { 4212 if (!(iwl_is_associated(priv))) {
4791 4213
4792 /* RXON - unassoc (to set timing command) */ 4214 /* RXON - unassoc (to set timing command) */
4793 priv->staging39_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 4215 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
4794 iwl3945_commit_rxon(priv); 4216 iwl3945_commit_rxon(priv);
4795 4217
4796 /* RXON Timing */ 4218 /* RXON Timing */
@@ -4804,29 +4226,29 @@ static void iwl3945_config_ap(struct iwl_priv *priv)
4804 "Attempting to continue.\n"); 4226 "Attempting to continue.\n");
4805 4227
4806 /* FIXME: what should be the assoc_id for AP? */ 4228 /* FIXME: what should be the assoc_id for AP? */
4807 priv->staging39_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 4229 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
4808 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 4230 if (priv->assoc_capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
4809 priv->staging39_rxon.flags |= 4231 priv->staging_rxon.flags |=
4810 RXON_FLG_SHORT_PREAMBLE_MSK; 4232 RXON_FLG_SHORT_PREAMBLE_MSK;
4811 else 4233 else
4812 priv->staging39_rxon.flags &= 4234 priv->staging_rxon.flags &=
4813 ~RXON_FLG_SHORT_PREAMBLE_MSK; 4235 ~RXON_FLG_SHORT_PREAMBLE_MSK;
4814 4236
4815 if (priv->staging39_rxon.flags & RXON_FLG_BAND_24G_MSK) { 4237 if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK) {
4816 if (priv->assoc_capability & 4238 if (priv->assoc_capability &
4817 WLAN_CAPABILITY_SHORT_SLOT_TIME) 4239 WLAN_CAPABILITY_SHORT_SLOT_TIME)
4818 priv->staging39_rxon.flags |= 4240 priv->staging_rxon.flags |=
4819 RXON_FLG_SHORT_SLOT_MSK; 4241 RXON_FLG_SHORT_SLOT_MSK;
4820 else 4242 else
4821 priv->staging39_rxon.flags &= 4243 priv->staging_rxon.flags &=
4822 ~RXON_FLG_SHORT_SLOT_MSK; 4244 ~RXON_FLG_SHORT_SLOT_MSK;
4823 4245
4824 if (priv->iw_mode == NL80211_IFTYPE_ADHOC) 4246 if (priv->iw_mode == NL80211_IFTYPE_ADHOC)
4825 priv->staging39_rxon.flags &= 4247 priv->staging_rxon.flags &=
4826 ~RXON_FLG_SHORT_SLOT_MSK; 4248 ~RXON_FLG_SHORT_SLOT_MSK;
4827 } 4249 }
4828 /* restore RXON assoc */ 4250 /* restore RXON assoc */
4829 priv->staging39_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 4251 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
4830 iwl3945_commit_rxon(priv); 4252 iwl3945_commit_rxon(priv);
4831 iwl3945_add_station(priv, iwl_bcast_addr, 0, 0); 4253 iwl3945_add_station(priv, iwl_bcast_addr, 0, 0);
4832 } 4254 }
@@ -4848,7 +4270,7 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
4848 return -EIO; 4270 return -EIO;
4849 4271
4850 if (priv->vif != vif) { 4272 if (priv->vif != vif) {
4851 IWL_DEBUG_MAC80211("leave - priv->vif != vif\n"); 4273 IWL_DEBUG_MAC80211(priv, "leave - priv->vif != vif\n");
4852 return 0; 4274 return 0;
4853 } 4275 }
4854 4276
@@ -4871,7 +4293,7 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
4871 mutex_lock(&priv->mutex); 4293 mutex_lock(&priv->mutex);
4872 4294
4873 if (conf->bssid) 4295 if (conf->bssid)
4874 IWL_DEBUG_MAC80211("bssid: %pM\n", conf->bssid); 4296 IWL_DEBUG_MAC80211(priv, "bssid: %pM\n", conf->bssid);
4875 4297
4876/* 4298/*
4877 * very dubious code was here; the probe filtering flag is never set: 4299 * very dubious code was here; the probe filtering flag is never set:
@@ -4884,7 +4306,7 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
4884 if (!conf->bssid) { 4306 if (!conf->bssid) {
4885 conf->bssid = priv->mac_addr; 4307 conf->bssid = priv->mac_addr;
4886 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN); 4308 memcpy(priv->bssid, priv->mac_addr, ETH_ALEN);
4887 IWL_DEBUG_MAC80211("bssid was set to: %pM\n", 4309 IWL_DEBUG_MAC80211(priv, "bssid was set to: %pM\n",
4888 conf->bssid); 4310 conf->bssid);
4889 } 4311 }
4890 if (priv->ibss_beacon) 4312 if (priv->ibss_beacon)
@@ -4903,11 +4325,11 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
4903 if (iwl_scan_cancel_timeout(priv, 100)) { 4325 if (iwl_scan_cancel_timeout(priv, 100)) {
4904 IWL_WARN(priv, "Aborted scan still in progress " 4326 IWL_WARN(priv, "Aborted scan still in progress "
4905 "after 100ms\n"); 4327 "after 100ms\n");
4906 IWL_DEBUG_MAC80211("leaving - scan abort failed.\n"); 4328 IWL_DEBUG_MAC80211(priv, "leaving:scan abort failed\n");
4907 mutex_unlock(&priv->mutex); 4329 mutex_unlock(&priv->mutex);
4908 return -EAGAIN; 4330 return -EAGAIN;
4909 } 4331 }
4910 memcpy(priv->staging39_rxon.bssid_addr, conf->bssid, ETH_ALEN); 4332 memcpy(priv->staging_rxon.bssid_addr, conf->bssid, ETH_ALEN);
4911 4333
4912 /* TODO: Audit driver for usage of these members and see 4334 /* TODO: Audit driver for usage of these members and see
4913 * if mac80211 deprecates them (priv->bssid looks like it 4335 * if mac80211 deprecates them (priv->bssid looks like it
@@ -4921,80 +4343,34 @@ static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
4921 rc = iwl3945_commit_rxon(priv); 4343 rc = iwl3945_commit_rxon(priv);
4922 if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc) 4344 if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc)
4923 iwl3945_add_station(priv, 4345 iwl3945_add_station(priv,
4924 priv->active39_rxon.bssid_addr, 1, 0); 4346 priv->active_rxon.bssid_addr, 1, 0);
4925 } 4347 }
4926 4348
4927 } else { 4349 } else {
4928 iwl_scan_cancel_timeout(priv, 100); 4350 iwl_scan_cancel_timeout(priv, 100);
4929 priv->staging39_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 4351 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
4930 iwl3945_commit_rxon(priv); 4352 iwl3945_commit_rxon(priv);
4931 } 4353 }
4932 4354
4933 done: 4355 done:
4934 IWL_DEBUG_MAC80211("leave\n"); 4356 IWL_DEBUG_MAC80211(priv, "leave\n");
4935 mutex_unlock(&priv->mutex); 4357 mutex_unlock(&priv->mutex);
4936 4358
4937 return 0; 4359 return 0;
4938} 4360}
4939 4361
4940static void iwl3945_configure_filter(struct ieee80211_hw *hw,
4941 unsigned int changed_flags,
4942 unsigned int *total_flags,
4943 int mc_count, struct dev_addr_list *mc_list)
4944{
4945 struct iwl_priv *priv = hw->priv;
4946 __le32 *filter_flags = &priv->staging39_rxon.filter_flags;
4947
4948 IWL_DEBUG_MAC80211("Enter: changed: 0x%x, total: 0x%x\n",
4949 changed_flags, *total_flags);
4950
4951 if (changed_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS)) {
4952 if (*total_flags & (FIF_OTHER_BSS | FIF_PROMISC_IN_BSS))
4953 *filter_flags |= RXON_FILTER_PROMISC_MSK;
4954 else
4955 *filter_flags &= ~RXON_FILTER_PROMISC_MSK;
4956 }
4957 if (changed_flags & FIF_ALLMULTI) {
4958 if (*total_flags & FIF_ALLMULTI)
4959 *filter_flags |= RXON_FILTER_ACCEPT_GRP_MSK;
4960 else
4961 *filter_flags &= ~RXON_FILTER_ACCEPT_GRP_MSK;
4962 }
4963 if (changed_flags & FIF_CONTROL) {
4964 if (*total_flags & FIF_CONTROL)
4965 *filter_flags |= RXON_FILTER_CTL2HOST_MSK;
4966 else
4967 *filter_flags &= ~RXON_FILTER_CTL2HOST_MSK;
4968 }
4969 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
4970 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
4971 *filter_flags |= RXON_FILTER_BCON_AWARE_MSK;
4972 else
4973 *filter_flags &= ~RXON_FILTER_BCON_AWARE_MSK;
4974 }
4975
4976 /* We avoid iwl_commit_rxon here to commit the new filter flags
4977 * since mac80211 will call ieee80211_hw_config immediately.
4978 * (mc_list is not supported at this time). Otherwise, we need to
4979 * queue a background iwl_commit_rxon work.
4980 */
4981
4982 *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS |
4983 FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL;
4984}
4985
4986static void iwl3945_mac_remove_interface(struct ieee80211_hw *hw, 4362static void iwl3945_mac_remove_interface(struct ieee80211_hw *hw,
4987 struct ieee80211_if_init_conf *conf) 4363 struct ieee80211_if_init_conf *conf)
4988{ 4364{
4989 struct iwl_priv *priv = hw->priv; 4365 struct iwl_priv *priv = hw->priv;
4990 4366
4991 IWL_DEBUG_MAC80211("enter\n"); 4367 IWL_DEBUG_MAC80211(priv, "enter\n");
4992 4368
4993 mutex_lock(&priv->mutex); 4369 mutex_lock(&priv->mutex);
4994 4370
4995 if (iwl_is_ready_rf(priv)) { 4371 if (iwl_is_ready_rf(priv)) {
4996 iwl_scan_cancel_timeout(priv, 100); 4372 iwl_scan_cancel_timeout(priv, 100);
4997 priv->staging39_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 4373 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
4998 iwl3945_commit_rxon(priv); 4374 iwl3945_commit_rxon(priv);
4999 } 4375 }
5000 if (priv->vif == conf->vif) { 4376 if (priv->vif == conf->vif) {
@@ -5003,7 +4379,7 @@ static void iwl3945_mac_remove_interface(struct ieee80211_hw *hw,
5003 } 4379 }
5004 mutex_unlock(&priv->mutex); 4380 mutex_unlock(&priv->mutex);
5005 4381
5006 IWL_DEBUG_MAC80211("leave\n"); 4382 IWL_DEBUG_MAC80211(priv, "leave\n");
5007} 4383}
5008 4384
5009#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) 4385#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
@@ -5015,27 +4391,29 @@ static void iwl3945_bss_info_changed(struct ieee80211_hw *hw,
5015{ 4391{
5016 struct iwl_priv *priv = hw->priv; 4392 struct iwl_priv *priv = hw->priv;
5017 4393
5018 IWL_DEBUG_MAC80211("changes = 0x%X\n", changes); 4394 IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes);
5019 4395
5020 if (changes & BSS_CHANGED_ERP_PREAMBLE) { 4396 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
5021 IWL_DEBUG_MAC80211("ERP_PREAMBLE %d\n", 4397 IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n",
5022 bss_conf->use_short_preamble); 4398 bss_conf->use_short_preamble);
5023 if (bss_conf->use_short_preamble) 4399 if (bss_conf->use_short_preamble)
5024 priv->staging39_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; 4400 priv->staging_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK;
5025 else 4401 else
5026 priv->staging39_rxon.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; 4402 priv->staging_rxon.flags &=
4403 ~RXON_FLG_SHORT_PREAMBLE_MSK;
5027 } 4404 }
5028 4405
5029 if (changes & BSS_CHANGED_ERP_CTS_PROT) { 4406 if (changes & BSS_CHANGED_ERP_CTS_PROT) {
5030 IWL_DEBUG_MAC80211("ERP_CTS %d\n", bss_conf->use_cts_prot); 4407 IWL_DEBUG_MAC80211(priv, "ERP_CTS %d\n",
4408 bss_conf->use_cts_prot);
5031 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) 4409 if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ))
5032 priv->staging39_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK; 4410 priv->staging_rxon.flags |= RXON_FLG_TGG_PROTECT_MSK;
5033 else 4411 else
5034 priv->staging39_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK; 4412 priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
5035 } 4413 }
5036 4414
5037 if (changes & BSS_CHANGED_ASSOC) { 4415 if (changes & BSS_CHANGED_ASSOC) {
5038 IWL_DEBUG_MAC80211("ASSOC %d\n", bss_conf->assoc); 4416 IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc);
5039 /* This should never happen as this function should 4417 /* This should never happen as this function should
5040 * never be called from interrupt context. */ 4418 * never be called from interrupt context. */
5041 if (WARN_ON_ONCE(in_interrupt())) 4419 if (WARN_ON_ONCE(in_interrupt()))
@@ -5053,10 +4431,12 @@ static void iwl3945_bss_info_changed(struct ieee80211_hw *hw,
5053 mutex_unlock(&priv->mutex); 4431 mutex_unlock(&priv->mutex);
5054 } else { 4432 } else {
5055 priv->assoc_id = 0; 4433 priv->assoc_id = 0;
5056 IWL_DEBUG_MAC80211("DISASSOC %d\n", bss_conf->assoc); 4434 IWL_DEBUG_MAC80211(priv,
4435 "DISASSOC %d\n", bss_conf->assoc);
5057 } 4436 }
5058 } else if (changes && iwl3945_is_associated(priv) && priv->assoc_id) { 4437 } else if (changes && iwl_is_associated(priv) && priv->assoc_id) {
5059 IWL_DEBUG_MAC80211("Associated Changes %d\n", changes); 4438 IWL_DEBUG_MAC80211(priv,
4439 "Associated Changes %d\n", changes);
5060 iwl3945_send_rxon_assoc(priv); 4440 iwl3945_send_rxon_assoc(priv);
5061 } 4441 }
5062 4442
@@ -5069,14 +4449,14 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
5069 struct iwl_priv *priv = hw->priv; 4449 struct iwl_priv *priv = hw->priv;
5070 DECLARE_SSID_BUF(ssid_buf); 4450 DECLARE_SSID_BUF(ssid_buf);
5071 4451
5072 IWL_DEBUG_MAC80211("enter\n"); 4452 IWL_DEBUG_MAC80211(priv, "enter\n");
5073 4453
5074 mutex_lock(&priv->mutex); 4454 mutex_lock(&priv->mutex);
5075 spin_lock_irqsave(&priv->lock, flags); 4455 spin_lock_irqsave(&priv->lock, flags);
5076 4456
5077 if (!iwl_is_ready_rf(priv)) { 4457 if (!iwl_is_ready_rf(priv)) {
5078 rc = -EIO; 4458 rc = -EIO;
5079 IWL_DEBUG_MAC80211("leave - not ready or exit pending\n"); 4459 IWL_DEBUG_MAC80211(priv, "leave - not ready or exit pending\n");
5080 goto out_unlock; 4460 goto out_unlock;
5081 } 4461 }
5082 4462
@@ -5094,8 +4474,8 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
5094 goto out_unlock; 4474 goto out_unlock;
5095 } 4475 }
5096 if (len) { 4476 if (len) {
5097 IWL_DEBUG_SCAN("direct scan for %s [%d]\n ", 4477 IWL_DEBUG_SCAN(priv, "direct scan for %s [%zd]\n ",
5098 print_ssid(ssid_buf, ssid, len), (int)len); 4478 print_ssid(ssid_buf, ssid, len), len);
5099 4479
5100 priv->one_direct_scan = 1; 4480 priv->one_direct_scan = 1;
5101 priv->direct_ssid_len = (u8) 4481 priv->direct_ssid_len = (u8)
@@ -5106,7 +4486,7 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
5106 4486
5107 rc = iwl3945_scan_initiate(priv); 4487 rc = iwl3945_scan_initiate(priv);
5108 4488
5109 IWL_DEBUG_MAC80211("leave\n"); 4489 IWL_DEBUG_MAC80211(priv, "leave\n");
5110 4490
5111out_unlock: 4491out_unlock:
5112 spin_unlock_irqrestore(&priv->lock, flags); 4492 spin_unlock_irqrestore(&priv->lock, flags);
@@ -5125,17 +4505,17 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
5125 int ret; 4505 int ret;
5126 u8 sta_id; 4506 u8 sta_id;
5127 4507
5128 IWL_DEBUG_MAC80211("enter\n"); 4508 IWL_DEBUG_MAC80211(priv, "enter\n");
5129 4509
5130 if (iwl3945_mod_params.sw_crypto) { 4510 if (iwl3945_mod_params.sw_crypto) {
5131 IWL_DEBUG_MAC80211("leave - hwcrypto disabled\n"); 4511 IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n");
5132 return -EOPNOTSUPP; 4512 return -EOPNOTSUPP;
5133 } 4513 }
5134 4514
5135 addr = sta ? sta->addr : iwl_bcast_addr; 4515 addr = sta ? sta->addr : iwl_bcast_addr;
5136 sta_id = iwl3945_hw_find_station(priv, addr); 4516 sta_id = iwl3945_hw_find_station(priv, addr);
5137 if (sta_id == IWL_INVALID_STATION) { 4517 if (sta_id == IWL_INVALID_STATION) {
5138 IWL_DEBUG_MAC80211("leave - %pM not in station map.\n", 4518 IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
5139 addr); 4519 addr);
5140 return -EINVAL; 4520 return -EINVAL;
5141 } 4521 }
@@ -5148,26 +4528,27 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
5148 case SET_KEY: 4528 case SET_KEY:
5149 ret = iwl3945_update_sta_key_info(priv, key, sta_id); 4529 ret = iwl3945_update_sta_key_info(priv, key, sta_id);
5150 if (!ret) { 4530 if (!ret) {
5151 iwl3945_set_rxon_hwcrypto(priv, 1); 4531 iwl_set_rxon_hwcrypto(priv, 1);
5152 iwl3945_commit_rxon(priv); 4532 iwl3945_commit_rxon(priv);
5153 key->hw_key_idx = sta_id; 4533 key->hw_key_idx = sta_id;
5154 IWL_DEBUG_MAC80211("set_key success, using hwcrypto\n"); 4534 IWL_DEBUG_MAC80211(priv,
4535 "set_key success, using hwcrypto\n");
5155 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 4536 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
5156 } 4537 }
5157 break; 4538 break;
5158 case DISABLE_KEY: 4539 case DISABLE_KEY:
5159 ret = iwl3945_clear_sta_key_info(priv, sta_id); 4540 ret = iwl3945_clear_sta_key_info(priv, sta_id);
5160 if (!ret) { 4541 if (!ret) {
5161 iwl3945_set_rxon_hwcrypto(priv, 0); 4542 iwl_set_rxon_hwcrypto(priv, 0);
5162 iwl3945_commit_rxon(priv); 4543 iwl3945_commit_rxon(priv);
5163 IWL_DEBUG_MAC80211("disable hwcrypto key\n"); 4544 IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n");
5164 } 4545 }
5165 break; 4546 break;
5166 default: 4547 default:
5167 ret = -EINVAL; 4548 ret = -EINVAL;
5168 } 4549 }
5169 4550
5170 IWL_DEBUG_MAC80211("leave\n"); 4551 IWL_DEBUG_MAC80211(priv, "leave\n");
5171 mutex_unlock(&priv->mutex); 4552 mutex_unlock(&priv->mutex);
5172 4553
5173 return ret; 4554 return ret;
@@ -5180,15 +4561,15 @@ static int iwl3945_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
5180 unsigned long flags; 4561 unsigned long flags;
5181 int q; 4562 int q;
5182 4563
5183 IWL_DEBUG_MAC80211("enter\n"); 4564 IWL_DEBUG_MAC80211(priv, "enter\n");
5184 4565
5185 if (!iwl_is_ready_rf(priv)) { 4566 if (!iwl_is_ready_rf(priv)) {
5186 IWL_DEBUG_MAC80211("leave - RF not ready\n"); 4567 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
5187 return -EIO; 4568 return -EIO;
5188 } 4569 }
5189 4570
5190 if (queue >= AC_NUM) { 4571 if (queue >= AC_NUM) {
5191 IWL_DEBUG_MAC80211("leave - queue >= AC_NUM %d\n", queue); 4572 IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue);
5192 return 0; 4573 return 0;
5193 } 4574 }
5194 4575
@@ -5210,12 +4591,12 @@ static int iwl3945_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
5210 mutex_lock(&priv->mutex); 4591 mutex_lock(&priv->mutex);
5211 if (priv->iw_mode == NL80211_IFTYPE_AP) 4592 if (priv->iw_mode == NL80211_IFTYPE_AP)
5212 iwl3945_activate_qos(priv, 1); 4593 iwl3945_activate_qos(priv, 1);
5213 else if (priv->assoc_id && iwl3945_is_associated(priv)) 4594 else if (priv->assoc_id && iwl_is_associated(priv))
5214 iwl3945_activate_qos(priv, 0); 4595 iwl3945_activate_qos(priv, 0);
5215 4596
5216 mutex_unlock(&priv->mutex); 4597 mutex_unlock(&priv->mutex);
5217 4598
5218 IWL_DEBUG_MAC80211("leave\n"); 4599 IWL_DEBUG_MAC80211(priv, "leave\n");
5219 return 0; 4600 return 0;
5220} 4601}
5221 4602
@@ -5228,10 +4609,10 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
5228 struct iwl_queue *q; 4609 struct iwl_queue *q;
5229 unsigned long flags; 4610 unsigned long flags;
5230 4611
5231 IWL_DEBUG_MAC80211("enter\n"); 4612 IWL_DEBUG_MAC80211(priv, "enter\n");
5232 4613
5233 if (!iwl_is_ready_rf(priv)) { 4614 if (!iwl_is_ready_rf(priv)) {
5234 IWL_DEBUG_MAC80211("leave - RF not ready\n"); 4615 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
5235 return -EIO; 4616 return -EIO;
5236 } 4617 }
5237 4618
@@ -5249,7 +4630,7 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
5249 } 4630 }
5250 spin_unlock_irqrestore(&priv->lock, flags); 4631 spin_unlock_irqrestore(&priv->lock, flags);
5251 4632
5252 IWL_DEBUG_MAC80211("leave\n"); 4633 IWL_DEBUG_MAC80211(priv, "leave\n");
5253 4634
5254 return 0; 4635 return 0;
5255} 4636}
@@ -5260,7 +4641,7 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
5260 unsigned long flags; 4641 unsigned long flags;
5261 4642
5262 mutex_lock(&priv->mutex); 4643 mutex_lock(&priv->mutex);
5263 IWL_DEBUG_MAC80211("enter\n"); 4644 IWL_DEBUG_MAC80211(priv, "enter\n");
5264 4645
5265 iwl_reset_qos(priv); 4646 iwl_reset_qos(priv);
5266 4647
@@ -5282,7 +4663,7 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
5282 spin_unlock_irqrestore(&priv->lock, flags); 4663 spin_unlock_irqrestore(&priv->lock, flags);
5283 4664
5284 if (!iwl_is_ready_rf(priv)) { 4665 if (!iwl_is_ready_rf(priv)) {
5285 IWL_DEBUG_MAC80211("leave - not ready\n"); 4666 IWL_DEBUG_MAC80211(priv, "leave - not ready\n");
5286 mutex_unlock(&priv->mutex); 4667 mutex_unlock(&priv->mutex);
5287 return; 4668 return;
5288 } 4669 }
@@ -5292,23 +4673,23 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
5292 */ 4673 */
5293 if (priv->iw_mode != NL80211_IFTYPE_AP) { 4674 if (priv->iw_mode != NL80211_IFTYPE_AP) {
5294 iwl_scan_cancel_timeout(priv, 100); 4675 iwl_scan_cancel_timeout(priv, 100);
5295 priv->staging39_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 4676 priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
5296 iwl3945_commit_rxon(priv); 4677 iwl3945_commit_rxon(priv);
5297 } 4678 }
5298 4679
5299 /* Per mac80211.h: This is only used in IBSS mode... */ 4680 /* Per mac80211.h: This is only used in IBSS mode... */
5300 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) { 4681 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
5301 4682
5302 IWL_DEBUG_MAC80211("leave - not in IBSS\n"); 4683 IWL_DEBUG_MAC80211(priv, "leave - not in IBSS\n");
5303 mutex_unlock(&priv->mutex); 4684 mutex_unlock(&priv->mutex);
5304 return; 4685 return;
5305 } 4686 }
5306 4687
5307 iwl3945_set_rate(priv); 4688 iwl_set_rate(priv);
5308 4689
5309 mutex_unlock(&priv->mutex); 4690 mutex_unlock(&priv->mutex);
5310 4691
5311 IWL_DEBUG_MAC80211("leave\n"); 4692 IWL_DEBUG_MAC80211(priv, "leave\n");
5312 4693
5313} 4694}
5314 4695
@@ -5317,15 +4698,15 @@ static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
5317 struct iwl_priv *priv = hw->priv; 4698 struct iwl_priv *priv = hw->priv;
5318 unsigned long flags; 4699 unsigned long flags;
5319 4700
5320 IWL_DEBUG_MAC80211("enter\n"); 4701 IWL_DEBUG_MAC80211(priv, "enter\n");
5321 4702
5322 if (!iwl_is_ready_rf(priv)) { 4703 if (!iwl_is_ready_rf(priv)) {
5323 IWL_DEBUG_MAC80211("leave - RF not ready\n"); 4704 IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n");
5324 return -EIO; 4705 return -EIO;
5325 } 4706 }
5326 4707
5327 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) { 4708 if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
5328 IWL_DEBUG_MAC80211("leave - not IBSS\n"); 4709 IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
5329 return -EIO; 4710 return -EIO;
5330 } 4711 }
5331 4712
@@ -5338,7 +4719,7 @@ static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
5338 4719
5339 priv->assoc_id = 0; 4720 priv->assoc_id = 0;
5340 4721
5341 IWL_DEBUG_MAC80211("leave\n"); 4722 IWL_DEBUG_MAC80211(priv, "leave\n");
5342 spin_unlock_irqrestore(&priv->lock, flags); 4723 spin_unlock_irqrestore(&priv->lock, flags);
5343 4724
5344 iwl_reset_qos(priv); 4725 iwl_reset_qos(priv);
@@ -5437,7 +4818,7 @@ static ssize_t show_flags(struct device *d,
5437{ 4818{
5438 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data; 4819 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
5439 4820
5440 return sprintf(buf, "0x%04X\n", priv->active39_rxon.flags); 4821 return sprintf(buf, "0x%04X\n", priv->active_rxon.flags);
5441} 4822}
5442 4823
5443static ssize_t store_flags(struct device *d, 4824static ssize_t store_flags(struct device *d,
@@ -5448,14 +4829,14 @@ static ssize_t store_flags(struct device *d,
5448 u32 flags = simple_strtoul(buf, NULL, 0); 4829 u32 flags = simple_strtoul(buf, NULL, 0);
5449 4830
5450 mutex_lock(&priv->mutex); 4831 mutex_lock(&priv->mutex);
5451 if (le32_to_cpu(priv->staging39_rxon.flags) != flags) { 4832 if (le32_to_cpu(priv->staging_rxon.flags) != flags) {
5452 /* Cancel any currently running scans... */ 4833 /* Cancel any currently running scans... */
5453 if (iwl_scan_cancel_timeout(priv, 100)) 4834 if (iwl_scan_cancel_timeout(priv, 100))
5454 IWL_WARN(priv, "Could not cancel scan.\n"); 4835 IWL_WARN(priv, "Could not cancel scan.\n");
5455 else { 4836 else {
5456 IWL_DEBUG_INFO("Committing rxon.flags = 0x%04X\n", 4837 IWL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n",
5457 flags); 4838 flags);
5458 priv->staging39_rxon.flags = cpu_to_le32(flags); 4839 priv->staging_rxon.flags = cpu_to_le32(flags);
5459 iwl3945_commit_rxon(priv); 4840 iwl3945_commit_rxon(priv);
5460 } 4841 }
5461 } 4842 }
@@ -5472,7 +4853,7 @@ static ssize_t show_filter_flags(struct device *d,
5472 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data; 4853 struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
5473 4854
5474 return sprintf(buf, "0x%04X\n", 4855 return sprintf(buf, "0x%04X\n",
5475 le32_to_cpu(priv->active39_rxon.filter_flags)); 4856 le32_to_cpu(priv->active_rxon.filter_flags));
5476} 4857}
5477 4858
5478static ssize_t store_filter_flags(struct device *d, 4859static ssize_t store_filter_flags(struct device *d,
@@ -5483,14 +4864,14 @@ static ssize_t store_filter_flags(struct device *d,
5483 u32 filter_flags = simple_strtoul(buf, NULL, 0); 4864 u32 filter_flags = simple_strtoul(buf, NULL, 0);
5484 4865
5485 mutex_lock(&priv->mutex); 4866 mutex_lock(&priv->mutex);
5486 if (le32_to_cpu(priv->staging39_rxon.filter_flags) != filter_flags) { 4867 if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) {
5487 /* Cancel any currently running scans... */ 4868 /* Cancel any currently running scans... */
5488 if (iwl_scan_cancel_timeout(priv, 100)) 4869 if (iwl_scan_cancel_timeout(priv, 100))
5489 IWL_WARN(priv, "Could not cancel scan.\n"); 4870 IWL_WARN(priv, "Could not cancel scan.\n");
5490 else { 4871 else {
5491 IWL_DEBUG_INFO("Committing rxon.filter_flags = " 4872 IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = "
5492 "0x%04X\n", filter_flags); 4873 "0x%04X\n", filter_flags);
5493 priv->staging39_rxon.filter_flags = 4874 priv->staging_rxon.filter_flags =
5494 cpu_to_le32(filter_flags); 4875 cpu_to_le32(filter_flags);
5495 iwl3945_commit_rxon(priv); 4876 iwl3945_commit_rxon(priv);
5496 } 4877 }
@@ -5543,7 +4924,7 @@ static ssize_t store_measurement(struct device *d,
5543{ 4924{
5544 struct iwl_priv *priv = dev_get_drvdata(d); 4925 struct iwl_priv *priv = dev_get_drvdata(d);
5545 struct ieee80211_measurement_params params = { 4926 struct ieee80211_measurement_params params = {
5546 .channel = le16_to_cpu(priv->active39_rxon.channel), 4927 .channel = le16_to_cpu(priv->active_rxon.channel),
5547 .start_time = cpu_to_le64(priv->last_tsf), 4928 .start_time = cpu_to_le64(priv->last_tsf),
5548 .duration = cpu_to_le16(1), 4929 .duration = cpu_to_le16(1),
5549 }; 4930 };
@@ -5565,7 +4946,7 @@ static ssize_t store_measurement(struct device *d,
5565 type = simple_strtoul(p + 1, NULL, 0); 4946 type = simple_strtoul(p + 1, NULL, 0);
5566 } 4947 }
5567 4948
5568 IWL_DEBUG_INFO("Invoking measurement of type %d on " 4949 IWL_DEBUG_INFO(priv, "Invoking measurement of type %d on "
5569 "channel %d (for '%s')\n", type, params.channel, buf); 4950 "channel %d (for '%s')\n", type, params.channel, buf);
5570 iwl3945_get_measurement(priv, &params, type); 4951 iwl3945_get_measurement(priv, &params, type);
5571 4952
@@ -5599,44 +4980,70 @@ static ssize_t show_retry_rate(struct device *d,
5599static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, show_retry_rate, 4980static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, show_retry_rate,
5600 store_retry_rate); 4981 store_retry_rate);
5601 4982
4983
5602static ssize_t store_power_level(struct device *d, 4984static ssize_t store_power_level(struct device *d,
5603 struct device_attribute *attr, 4985 struct device_attribute *attr,
5604 const char *buf, size_t count) 4986 const char *buf, size_t count)
5605{ 4987{
5606 struct iwl_priv *priv = dev_get_drvdata(d); 4988 struct iwl_priv *priv = dev_get_drvdata(d);
5607 int rc; 4989 int ret;
5608 int mode; 4990 unsigned long mode;
4991
5609 4992
5610 mode = simple_strtoul(buf, NULL, 0);
5611 mutex_lock(&priv->mutex); 4993 mutex_lock(&priv->mutex);
5612 4994
5613 if (!iwl_is_ready(priv)) { 4995 if (!iwl_is_ready(priv)) {
5614 rc = -EAGAIN; 4996 ret = -EAGAIN;
5615 goto out; 4997 goto out;
5616 } 4998 }
5617 4999
5618 if ((mode < 1) || (mode > IWL39_POWER_LIMIT) || 5000 ret = strict_strtoul(buf, 10, &mode);
5619 (mode == IWL39_POWER_AC)) 5001 if (ret)
5620 mode = IWL39_POWER_AC; 5002 goto out;
5621 else
5622 mode |= IWL_POWER_ENABLED;
5623 5003
5624 if (mode != priv->power_mode) { 5004 ret = iwl_power_set_user_mode(priv, mode);
5625 rc = iwl3945_send_power_mode(priv, IWL_POWER_LEVEL(mode)); 5005 if (ret) {
5626 if (rc) { 5006 IWL_DEBUG_MAC80211(priv, "failed setting power mode.\n");
5627 IWL_DEBUG_MAC80211("failed setting power mode.\n"); 5007 goto out;
5628 goto out;
5629 }
5630 priv->power_mode = mode;
5631 } 5008 }
5632 5009 ret = count;
5633 rc = count;
5634 5010
5635 out: 5011 out:
5636 mutex_unlock(&priv->mutex); 5012 mutex_unlock(&priv->mutex);
5637 return rc; 5013 return ret;
5638} 5014}
5639 5015
5016static ssize_t show_power_level(struct device *d,
5017 struct device_attribute *attr, char *buf)
5018{
5019 struct iwl_priv *priv = dev_get_drvdata(d);
5020 int mode = priv->power_data.user_power_setting;
5021 int system = priv->power_data.system_power_setting;
5022 int level = priv->power_data.power_mode;
5023 char *p = buf;
5024
5025 switch (system) {
5026 case IWL_POWER_SYS_AUTO:
5027 p += sprintf(p, "SYSTEM:auto");
5028 break;
5029 case IWL_POWER_SYS_AC:
5030 p += sprintf(p, "SYSTEM:ac");
5031 break;
5032 case IWL_POWER_SYS_BATTERY:
5033 p += sprintf(p, "SYSTEM:battery");
5034 break;
5035 }
5036
5037 p += sprintf(p, "\tMODE:%s", (mode < IWL_POWER_AUTO) ?
5038 "fixed" : "auto");
5039 p += sprintf(p, "\tINDEX:%d", level);
5040 p += sprintf(p, "\n");
5041 return p - buf + 1;
5042}
5043
5044static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR,
5045 show_power_level, store_power_level);
5046
5640#define MAX_WX_STRING 80 5047#define MAX_WX_STRING 80
5641 5048
5642/* Values are in microsecond */ 5049/* Values are in microsecond */
@@ -5655,41 +5062,6 @@ static const s32 period_duration[] = {
5655 1000000 5062 1000000
5656}; 5063};
5657 5064
5658static ssize_t show_power_level(struct device *d,
5659 struct device_attribute *attr, char *buf)
5660{
5661 struct iwl_priv *priv = dev_get_drvdata(d);
5662 int level = IWL_POWER_LEVEL(priv->power_mode);
5663 char *p = buf;
5664
5665 p += sprintf(p, "%d ", level);
5666 switch (level) {
5667 case IWL_POWER_MODE_CAM:
5668 case IWL39_POWER_AC:
5669 p += sprintf(p, "(AC)");
5670 break;
5671 case IWL39_POWER_BATTERY:
5672 p += sprintf(p, "(BATTERY)");
5673 break;
5674 default:
5675 p += sprintf(p,
5676 "(Timeout %dms, Period %dms)",
5677 timeout_duration[level - 1] / 1000,
5678 period_duration[level - 1] / 1000);
5679 }
5680
5681 if (!(priv->power_mode & IWL_POWER_ENABLED))
5682 p += sprintf(p, " OFF\n");
5683 else
5684 p += sprintf(p, " \n");
5685
5686 return p - buf + 1;
5687
5688}
5689
5690static DEVICE_ATTR(power_level, S_IWUSR | S_IRUSR, show_power_level,
5691 store_power_level);
5692
5693static ssize_t show_channels(struct device *d, 5065static ssize_t show_channels(struct device *d,
5694 struct device_attribute *attr, char *buf) 5066 struct device_attribute *attr, char *buf)
5695{ 5067{
@@ -5752,22 +5124,22 @@ static ssize_t store_antenna(struct device *d,
5752 struct device_attribute *attr, 5124 struct device_attribute *attr,
5753 const char *buf, size_t count) 5125 const char *buf, size_t count)
5754{ 5126{
5127 struct iwl_priv *priv __maybe_unused = dev_get_drvdata(d);
5755 int ant; 5128 int ant;
5756 struct iwl_priv *priv = dev_get_drvdata(d);
5757 5129
5758 if (count == 0) 5130 if (count == 0)
5759 return 0; 5131 return 0;
5760 5132
5761 if (sscanf(buf, "%1i", &ant) != 1) { 5133 if (sscanf(buf, "%1i", &ant) != 1) {
5762 IWL_DEBUG_INFO("not in hex or decimal form.\n"); 5134 IWL_DEBUG_INFO(priv, "not in hex or decimal form.\n");
5763 return count; 5135 return count;
5764 } 5136 }
5765 5137
5766 if ((ant >= 0) && (ant <= 2)) { 5138 if ((ant >= 0) && (ant <= 2)) {
5767 IWL_DEBUG_INFO("Setting antenna select to %d.\n", ant); 5139 IWL_DEBUG_INFO(priv, "Setting antenna select to %d.\n", ant);
5768 iwl3945_mod_params.antenna = (enum iwl3945_antenna)ant; 5140 iwl3945_mod_params.antenna = (enum iwl3945_antenna)ant;
5769 } else 5141 } else
5770 IWL_DEBUG_INFO("Bad antenna select value %d.\n", ant); 5142 IWL_DEBUG_INFO(priv, "Bad antenna select value %d.\n", ant);
5771 5143
5772 5144
5773 return count; 5145 return count;
@@ -5890,7 +5262,7 @@ static struct ieee80211_ops iwl3945_hw_ops = {
5890 .remove_interface = iwl3945_mac_remove_interface, 5262 .remove_interface = iwl3945_mac_remove_interface,
5891 .config = iwl3945_mac_config, 5263 .config = iwl3945_mac_config,
5892 .config_interface = iwl3945_mac_config_interface, 5264 .config_interface = iwl3945_mac_config_interface,
5893 .configure_filter = iwl3945_configure_filter, 5265 .configure_filter = iwl_configure_filter,
5894 .set_key = iwl3945_mac_set_key, 5266 .set_key = iwl3945_mac_set_key,
5895 .get_tx_stats = iwl3945_mac_get_tx_stats, 5267 .get_tx_stats = iwl3945_mac_get_tx_stats,
5896 .conf_tx = iwl3945_mac_conf_tx, 5268 .conf_tx = iwl3945_mac_conf_tx,
@@ -5932,8 +5304,8 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
5932 priv->qos_data.qos_cap.val = 0; 5304 priv->qos_data.qos_cap.val = 0;
5933 5305
5934 priv->rates_mask = IWL_RATES_MASK; 5306 priv->rates_mask = IWL_RATES_MASK;
5935 /* If power management is turned on, default to AC mode */ 5307 /* If power management is turned on, default to CAM mode */
5936 priv->power_mode = IWL39_POWER_AC; 5308 priv->power_mode = IWL_POWER_MODE_CAM;
5937 priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER; 5309 priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER;
5938 5310
5939 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { 5311 if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
@@ -6014,12 +5386,12 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
6014 * "the hard way", rather than using device's scan. 5386 * "the hard way", rather than using device's scan.
6015 */ 5387 */
6016 if (iwl3945_mod_params.disable_hw_scan) { 5388 if (iwl3945_mod_params.disable_hw_scan) {
6017 IWL_DEBUG_INFO("Disabling hw_scan\n"); 5389 IWL_DEBUG_INFO(priv, "Disabling hw_scan\n");
6018 iwl3945_hw_ops.hw_scan = NULL; 5390 iwl3945_hw_ops.hw_scan = NULL;
6019 } 5391 }
6020 5392
6021 5393
6022 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 5394 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
6023 priv->cfg = cfg; 5395 priv->cfg = cfg;
6024 priv->pci_dev = pdev; 5396 priv->pci_dev = pdev;
6025 5397
@@ -6075,9 +5447,9 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
6075 goto out_pci_release_regions; 5447 goto out_pci_release_regions;
6076 } 5448 }
6077 5449
6078 IWL_DEBUG_INFO("pci_resource_len = 0x%08llx\n", 5450 IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n",
6079 (unsigned long long) pci_resource_len(pdev, 0)); 5451 (unsigned long long) pci_resource_len(pdev, 0));
6080 IWL_DEBUG_INFO("pci_resource_base = %p\n", priv->hw_base); 5452 IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base);
6081 5453
6082 /* We disable the RETRY_TIMEOUT register (0x41) to keep 5454 /* We disable the RETRY_TIMEOUT register (0x41) to keep
6083 * PCI Tx retries from interfering with C3 CPU state */ 5455 * PCI Tx retries from interfering with C3 CPU state */
@@ -6086,7 +5458,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
6086 /* amp init */ 5458 /* amp init */
6087 err = priv->cfg->ops->lib->apm_ops.init(priv); 5459 err = priv->cfg->ops->lib->apm_ops.init(priv);
6088 if (err < 0) { 5460 if (err < 0) {
6089 IWL_DEBUG_INFO("Failed to init APMG\n"); 5461 IWL_DEBUG_INFO(priv, "Failed to init APMG\n");
6090 goto out_iounmap; 5462 goto out_iounmap;
6091 } 5463 }
6092 5464
@@ -6103,7 +5475,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
6103 /* MAC Address location in EEPROM same for 3945/4965 */ 5475 /* MAC Address location in EEPROM same for 3945/4965 */
6104 eeprom = (struct iwl3945_eeprom *)priv->eeprom; 5476 eeprom = (struct iwl3945_eeprom *)priv->eeprom;
6105 memcpy(priv->mac_addr, eeprom->mac_address, ETH_ALEN); 5477 memcpy(priv->mac_addr, eeprom->mac_address, ETH_ALEN);
6106 IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr); 5478 IWL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->mac_addr);
6107 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 5479 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
6108 5480
6109 /*********************** 5481 /***********************
@@ -6136,7 +5508,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
6136 /* Disable radio (SW RF KILL) via parameter when loading driver */ 5508 /* Disable radio (SW RF KILL) via parameter when loading driver */
6137 if (iwl3945_mod_params.disable) { 5509 if (iwl3945_mod_params.disable) {
6138 set_bit(STATUS_RF_KILL_SW, &priv->status); 5510 set_bit(STATUS_RF_KILL_SW, &priv->status);
6139 IWL_DEBUG_INFO("Radio disabled.\n"); 5511 IWL_DEBUG_INFO(priv, "Radio disabled.\n");
6140 } 5512 }
6141 5513
6142 5514
@@ -6163,7 +5535,8 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
6163 goto out_release_irq; 5535 goto out_release_irq;
6164 } 5536 }
6165 5537
6166 iwl3945_set_rxon_channel(priv, IEEE80211_BAND_2GHZ, 6); 5538 iwl_set_rxon_channel(priv,
5539 &priv->bands[IEEE80211_BAND_2GHZ].channels[5]);
6167 iwl3945_setup_deferred_work(priv); 5540 iwl3945_setup_deferred_work(priv);
6168 iwl3945_setup_rx_handlers(priv); 5541 iwl3945_setup_rx_handlers(priv);
6169 5542
@@ -6224,7 +5597,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
6224 if (!priv) 5597 if (!priv)
6225 return; 5598 return;
6226 5599
6227 IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n"); 5600 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
6228 5601
6229 set_bit(STATUS_EXIT_PENDING, &priv->status); 5602 set_bit(STATUS_EXIT_PENDING, &priv->status);
6230 5603
@@ -6305,9 +5678,12 @@ static int iwl3945_pci_suspend(struct pci_dev *pdev, pm_message_t state)
6305static int iwl3945_pci_resume(struct pci_dev *pdev) 5678static int iwl3945_pci_resume(struct pci_dev *pdev)
6306{ 5679{
6307 struct iwl_priv *priv = pci_get_drvdata(pdev); 5680 struct iwl_priv *priv = pci_get_drvdata(pdev);
5681 int ret;
6308 5682
6309 pci_set_power_state(pdev, PCI_D0); 5683 pci_set_power_state(pdev, PCI_D0);
6310 pci_enable_device(pdev); 5684 ret = pci_enable_device(pdev);
5685 if (ret)
5686 return ret;
6311 pci_restore_state(pdev); 5687 pci_restore_state(pdev);
6312 5688
6313 if (priv->is_open) 5689 if (priv->is_open)