aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-02-10 02:30:44 -0500
committerDavid S. Miller <davem@davemloft.net>2009-02-10 02:30:44 -0500
commit4b53b361e0fbb2390f1d98ed9eede8e0c9a887b6 (patch)
treebf4b8635de66f50eb1d28f2d9e93a04adc4053f5 /drivers/net
parent4cdc44a231f906a6ec586637e6e4c4c216679da4 (diff)
parent99e0fca6740b98aed1f604fc2e0acbdbc9e7578a (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath5k/base.c15
-rw-r--r--drivers/net/wireless/ath9k/core.h35
-rw-r--r--drivers/net/wireless/ath9k/debug.c100
-rw-r--r--drivers/net/wireless/ath9k/hw.c2
-rw-r--r--drivers/net/wireless/ath9k/mac.c3
-rw-r--r--drivers/net/wireless/ath9k/main.c102
-rw-r--r--drivers/net/wireless/ath9k/rc.c173
-rw-r--r--drivers/net/wireless/ath9k/reg.h11
-rw-r--r--drivers/net/wireless/ath9k/regd.c33
-rw-r--r--drivers/net/wireless/ath9k/xmit.c136
-rw-r--r--drivers/net/wireless/b43/Makefile1
-rw-r--r--drivers/net/wireless/b43/phy_lp.c220
-rw-r--r--drivers/net/wireless/b43/phy_lp.h315
-rw-r--r--drivers/net/wireless/b43/tables_lpphy.c333
-rw-r--r--drivers/net/wireless/b43/tables_lpphy.h23
-rw-r--r--drivers/net/wireless/b43legacy/leds.c8
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_rx.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c8
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c6
-rw-r--r--drivers/net/wireless/ipw2x00/Kconfig1
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c2
-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
-rw-r--r--drivers/net/wireless/libertas/if_spi.c15
-rw-r--r--drivers/net/wireless/libertas/scan.c2
-rw-r--r--drivers/net/wireless/orinoco/airport.c35
-rw-r--r--drivers/net/wireless/orinoco/hermes.c102
-rw-r--r--drivers/net/wireless/orinoco/hermes.h35
-rw-r--r--drivers/net/wireless/orinoco/hermes_dld.c4
-rw-r--r--drivers/net/wireless/orinoco/orinoco.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco.h17
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c31
-rw-r--r--drivers/net/wireless/orinoco/orinoco_nortel.c7
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.c5
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.h10
-rw-r--r--drivers/net/wireless/orinoco/orinoco_plx.c3
-rw-r--r--drivers/net/wireless/orinoco/orinoco_tmd.c2
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c15
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c30
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c30
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h9
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00firmware.c27
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00leds.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h13
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c19
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00reg.h10
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c62
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.h11
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c66
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c31
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c2
85 files changed, 3322 insertions, 2713 deletions
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index bd2c580d1f19..f9d486ff04f2 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -310,6 +310,19 @@ static inline void ath5k_txbuf_free(struct ath5k_softc *sc,
310 bf->skb = NULL; 310 bf->skb = NULL;
311} 311}
312 312
313static inline void ath5k_rxbuf_free(struct ath5k_softc *sc,
314 struct ath5k_buf *bf)
315{
316 BUG_ON(!bf);
317 if (!bf->skb)
318 return;
319 pci_unmap_single(sc->pdev, bf->skbaddr, sc->rxbufsize,
320 PCI_DMA_FROMDEVICE);
321 dev_kfree_skb_any(bf->skb);
322 bf->skb = NULL;
323}
324
325
313/* Queues setup */ 326/* Queues setup */
314static struct ath5k_txq *ath5k_txq_setup(struct ath5k_softc *sc, 327static struct ath5k_txq *ath5k_txq_setup(struct ath5k_softc *sc,
315 int qtype, int subtype); 328 int qtype, int subtype);
@@ -1343,7 +1356,7 @@ ath5k_desc_free(struct ath5k_softc *sc, struct pci_dev *pdev)
1343 list_for_each_entry(bf, &sc->txbuf, list) 1356 list_for_each_entry(bf, &sc->txbuf, list)
1344 ath5k_txbuf_free(sc, bf); 1357 ath5k_txbuf_free(sc, bf);
1345 list_for_each_entry(bf, &sc->rxbuf, list) 1358 list_for_each_entry(bf, &sc->rxbuf, list)
1346 ath5k_txbuf_free(sc, bf); 1359 ath5k_rxbuf_free(sc, bf);
1347 1360
1348 /* Free memory associated with all descriptors */ 1361 /* Free memory associated with all descriptors */
1349 pci_free_consistent(pdev, sc->desc_len, sc->desc, sc->desc_daddr); 1362 pci_free_consistent(pdev, sc->desc_len, sc->desc, sc->desc_daddr);
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index 29251f8dabb0..791f1acc0bb3 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -131,8 +131,18 @@ struct ath_interrupt_stats {
131 u32 dtim; 131 u32 dtim;
132}; 132};
133 133
134struct ath_legacy_rc_stats {
135 u32 success;
136};
137
138struct ath_11n_rc_stats {
139 u32 success;
140};
141
134struct ath_stats { 142struct ath_stats {
135 struct ath_interrupt_stats istats; 143 struct ath_interrupt_stats istats;
144 struct ath_legacy_rc_stats legacy_rcstats[12]; /* max(11a,11b,11g) */
145 struct ath_11n_rc_stats n_rcstats[16]; /* 0..15 MCS rates */
136}; 146};
137 147
138struct ath9k_debug { 148struct ath9k_debug {
@@ -141,6 +151,7 @@ struct ath9k_debug {
141 struct dentry *debugfs_phy; 151 struct dentry *debugfs_phy;
142 struct dentry *debugfs_dma; 152 struct dentry *debugfs_dma;
143 struct dentry *debugfs_interrupt; 153 struct dentry *debugfs_interrupt;
154 struct dentry *debugfs_rcstat;
144 struct ath_stats stats; 155 struct ath_stats stats;
145}; 156};
146 157
@@ -148,6 +159,7 @@ void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...);
148int ath9k_init_debug(struct ath_softc *sc); 159int ath9k_init_debug(struct ath_softc *sc);
149void ath9k_exit_debug(struct ath_softc *sc); 160void ath9k_exit_debug(struct ath_softc *sc);
150void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); 161void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
162void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb);
151 163
152#else 164#else
153 165
@@ -170,6 +182,11 @@ static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
170{ 182{
171} 183}
172 184
185static inline void ath_debug_stat_rc(struct ath_softc *sc,
186 struct sk_buff *skb)
187{
188}
189
173#endif /* CONFIG_ATH9K_DEBUG */ 190#endif /* CONFIG_ATH9K_DEBUG */
174 191
175struct ath_config { 192struct ath_config {
@@ -233,7 +250,6 @@ struct ath_buf_state {
233#define bf_isht(bf) (bf->bf_state.bf_type & BUF_HT) 250#define bf_isht(bf) (bf->bf_state.bf_type & BUF_HT)
234#define bf_isretried(bf) (bf->bf_state.bf_type & BUF_RETRY) 251#define bf_isretried(bf) (bf->bf_state.bf_type & BUF_RETRY)
235#define bf_isxretried(bf) (bf->bf_state.bf_type & BUF_XRETRY) 252#define bf_isxretried(bf) (bf->bf_state.bf_type & BUF_XRETRY)
236#define bf_isshpreamble(bf) (bf->bf_state.bf_type & BUF_SHORT_PREAMBLE)
237#define bf_isbar(bf) (bf->bf_state.bf_type & BUF_BAR) 253#define bf_isbar(bf) (bf->bf_state.bf_type & BUF_BAR)
238#define bf_ispspoll(bf) (bf->bf_state.bf_type & BUF_PSPOLL) 254#define bf_ispspoll(bf) (bf->bf_state.bf_type & BUF_PSPOLL)
239#define bf_isaggrburst(bf) (bf->bf_state.bf_type & BUF_AGGR_BURST) 255#define bf_isaggrburst(bf) (bf->bf_state.bf_type & BUF_AGGR_BURST)
@@ -600,6 +616,8 @@ struct ath_ani {
600/********************/ 616/********************/
601 617
602#define ATH_LED_PIN 1 618#define ATH_LED_PIN 1
619#define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */
620#define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */
603 621
604enum ath_led_type { 622enum ath_led_type {
605 ATH_LED_RADIO, 623 ATH_LED_RADIO,
@@ -656,12 +674,6 @@ struct ath_rfkill {
656#define ATH_RSSI_DUMMY_MARKER 0x127 674#define ATH_RSSI_DUMMY_MARKER 0x127
657#define ATH_RATE_DUMMY_MARKER 0 675#define ATH_RATE_DUMMY_MARKER 0
658 676
659enum PROT_MODE {
660 PROT_M_NONE = 0,
661 PROT_M_RTSCTS,
662 PROT_M_CTSONLY
663};
664
665#define SC_OP_INVALID BIT(0) 677#define SC_OP_INVALID BIT(0)
666#define SC_OP_BEACONS BIT(1) 678#define SC_OP_BEACONS BIT(1)
667#define SC_OP_RXAGGR BIT(2) 679#define SC_OP_RXAGGR BIT(2)
@@ -677,6 +689,7 @@ enum PROT_MODE {
677#define SC_OP_RFKILL_SW_BLOCKED BIT(12) 689#define SC_OP_RFKILL_SW_BLOCKED BIT(12)
678#define SC_OP_RFKILL_HW_BLOCKED BIT(13) 690#define SC_OP_RFKILL_HW_BLOCKED BIT(13)
679#define SC_OP_WAIT_FOR_BEACON BIT(14) 691#define SC_OP_WAIT_FOR_BEACON BIT(14)
692#define SC_OP_LED_ON BIT(15)
680 693
681struct ath_bus_ops { 694struct ath_bus_ops {
682 void (*read_cachesize)(struct ath_softc *sc, int *csz); 695 void (*read_cachesize)(struct ath_softc *sc, int *csz);
@@ -712,7 +725,6 @@ struct ath_softc {
712 u8 sc_splitmic; 725 u8 sc_splitmic;
713 atomic_t ps_usecount; 726 atomic_t ps_usecount;
714 enum ath9k_int sc_imask; 727 enum ath9k_int sc_imask;
715 enum PROT_MODE sc_protmode;
716 enum ath9k_ht_extprotspacing sc_ht_extprotspacing; 728 enum ath9k_ht_extprotspacing sc_ht_extprotspacing;
717 enum ath9k_ht_macmode tx_chan_width; 729 enum ath9k_ht_macmode tx_chan_width;
718 730
@@ -725,10 +737,17 @@ struct ath_softc {
725 struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX]; 737 struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
726 struct ath_rate_table *cur_rate_table; 738 struct ath_rate_table *cur_rate_table;
727 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; 739 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
740
728 struct ath_led radio_led; 741 struct ath_led radio_led;
729 struct ath_led assoc_led; 742 struct ath_led assoc_led;
730 struct ath_led tx_led; 743 struct ath_led tx_led;
731 struct ath_led rx_led; 744 struct ath_led rx_led;
745 struct delayed_work ath_led_blink_work;
746 int led_on_duration;
747 int led_off_duration;
748 int led_on_cnt;
749 int led_off_cnt;
750
732 struct ath_rfkill rf_kill; 751 struct ath_rfkill rf_kill;
733 struct ath_ani sc_ani; 752 struct ath_ani sc_ani;
734 struct ath9k_node_stats sc_halstats; 753 struct ath9k_node_stats sc_halstats;
diff --git a/drivers/net/wireless/ath9k/debug.c b/drivers/net/wireless/ath9k/debug.c
index 1680164b4adb..6181e49eecba 100644
--- a/drivers/net/wireless/ath9k/debug.c
+++ b/drivers/net/wireless/ath9k/debug.c
@@ -222,6 +222,98 @@ static const struct file_operations fops_interrupt = {
222 .owner = THIS_MODULE 222 .owner = THIS_MODULE
223}; 223};
224 224
225static void ath_debug_stat_11n_rc(struct ath_softc *sc, struct sk_buff *skb)
226{
227 struct ath_tx_info_priv *tx_info_priv = NULL;
228 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
229 struct ieee80211_tx_rate *rates = tx_info->status.rates;
230 int final_ts_idx, idx;
231
232 tx_info_priv = ATH_TX_INFO_PRIV(tx_info);
233 final_ts_idx = tx_info_priv->tx.ts_rateindex;
234 idx = sc->cur_rate_table->info[rates[final_ts_idx].idx].dot11rate;
235
236 sc->sc_debug.stats.n_rcstats[idx].success++;
237}
238
239static void ath_debug_stat_legacy_rc(struct ath_softc *sc, struct sk_buff *skb)
240{
241 struct ath_tx_info_priv *tx_info_priv = NULL;
242 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
243 struct ieee80211_tx_rate *rates = tx_info->status.rates;
244 int final_ts_idx, idx;
245
246 tx_info_priv = ATH_TX_INFO_PRIV(tx_info);
247 final_ts_idx = tx_info_priv->tx.ts_rateindex;
248 idx = rates[final_ts_idx].idx;
249
250 sc->sc_debug.stats.legacy_rcstats[idx].success++;
251}
252
253void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb)
254{
255 if (conf_is_ht(&sc->hw->conf))
256 ath_debug_stat_11n_rc(sc, skb);
257 else
258 ath_debug_stat_legacy_rc(sc, skb);
259}
260
261static ssize_t ath_read_file_stat_11n_rc(struct file *file,
262 char __user *user_buf,
263 size_t count, loff_t *ppos)
264{
265 struct ath_softc *sc = file->private_data;
266 char buf[512];
267 unsigned int len = 0;
268 int i = 0;
269
270 len += sprintf(buf, "%7s %13s\n\n", "Rate", "Success");
271
272 for (i = 0; i <= 15; i++) {
273 len += snprintf(buf + len, sizeof(buf) - len,
274 "%5s%3d: %8u\n", "MCS", i,
275 sc->sc_debug.stats.n_rcstats[i].success);
276 }
277
278 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
279}
280
281static ssize_t ath_read_file_stat_legacy_rc(struct file *file,
282 char __user *user_buf,
283 size_t count, loff_t *ppos)
284{
285 struct ath_softc *sc = file->private_data;
286 char buf[512];
287 unsigned int len = 0;
288 int i = 0;
289
290 len += sprintf(buf, "%7s %13s\n\n", "Rate", "Success");
291
292 for (i = 0; i < sc->cur_rate_table->rate_cnt; i++) {
293 len += snprintf(buf + len, sizeof(buf) - len, "%5u: %12u\n",
294 sc->cur_rate_table->info[i].ratekbps / 1000,
295 sc->sc_debug.stats.legacy_rcstats[i].success);
296 }
297
298 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
299}
300
301static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
302 size_t count, loff_t *ppos)
303{
304 struct ath_softc *sc = file->private_data;
305
306 if (conf_is_ht(&sc->hw->conf))
307 return ath_read_file_stat_11n_rc(file, user_buf, count, ppos);
308 else
309 return ath_read_file_stat_legacy_rc(file, user_buf, count ,ppos);
310}
311
312static const struct file_operations fops_rcstat = {
313 .read = read_file_rcstat,
314 .open = ath9k_debugfs_open,
315 .owner = THIS_MODULE
316};
225 317
226int ath9k_init_debug(struct ath_softc *sc) 318int ath9k_init_debug(struct ath_softc *sc)
227{ 319{
@@ -248,6 +340,13 @@ int ath9k_init_debug(struct ath_softc *sc)
248 if (!sc->sc_debug.debugfs_interrupt) 340 if (!sc->sc_debug.debugfs_interrupt)
249 goto err; 341 goto err;
250 342
343 sc->sc_debug.debugfs_rcstat = debugfs_create_file("rcstat",
344 S_IRUGO,
345 sc->sc_debug.debugfs_phy,
346 sc, &fops_rcstat);
347 if (!sc->sc_debug.debugfs_rcstat)
348 goto err;
349
251 return 0; 350 return 0;
252err: 351err:
253 ath9k_exit_debug(sc); 352 ath9k_exit_debug(sc);
@@ -256,6 +355,7 @@ err:
256 355
257void ath9k_exit_debug(struct ath_softc *sc) 356void ath9k_exit_debug(struct ath_softc *sc)
258{ 357{
358 debugfs_remove(sc->sc_debug.debugfs_rcstat);
259 debugfs_remove(sc->sc_debug.debugfs_interrupt); 359 debugfs_remove(sc->sc_debug.debugfs_interrupt);
260 debugfs_remove(sc->sc_debug.debugfs_dma); 360 debugfs_remove(sc->sc_debug.debugfs_dma);
261 debugfs_remove(sc->sc_debug.debugfs_phy); 361 debugfs_remove(sc->sc_debug.debugfs_phy);
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index 77282345efc1..00ed44a0c313 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -267,7 +267,7 @@ static int ath9k_hw_get_radiorev(struct ath_hal *ah)
267 267
268static void ath9k_hw_disablepcie(struct ath_hal *ah) 268static void ath9k_hw_disablepcie(struct ath_hal *ah)
269{ 269{
270 if (!AR_SREV_9100(ah)) 270 if (AR_SREV_9100(ah))
271 return; 271 return;
272 272
273 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00); 273 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
diff --git a/drivers/net/wireless/ath9k/mac.c b/drivers/net/wireless/ath9k/mac.c
index ef832a5ebbd8..2427c44a8c35 100644
--- a/drivers/net/wireless/ath9k/mac.c
+++ b/drivers/net/wireless/ath9k/mac.c
@@ -344,9 +344,6 @@ void ath9k_hw_set11n_ratescenario(struct ath_hal *ah, struct ath_desc *ds,
344 struct ar5416_desc *last_ads = AR5416DESC(lastds); 344 struct ar5416_desc *last_ads = AR5416DESC(lastds);
345 u32 ds_ctl0; 345 u32 ds_ctl0;
346 346
347 (void) nseries;
348 (void) rtsctsDuration;
349
350 if (flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)) { 347 if (flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA)) {
351 ds_ctl0 = ads->ds_ctl0; 348 ds_ctl0 = ads->ds_ctl0;
352 349
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index d8e826659c15..1c0f893e1c0a 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -935,6 +935,32 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
935/* LED functions */ 935/* LED functions */
936/********************************/ 936/********************************/
937 937
938static void ath_led_blink_work(struct work_struct *work)
939{
940 struct ath_softc *sc = container_of(work, struct ath_softc,
941 ath_led_blink_work.work);
942
943 if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED))
944 return;
945 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
946 (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0);
947
948 queue_delayed_work(sc->hw->workqueue, &sc->ath_led_blink_work,
949 (sc->sc_flags & SC_OP_LED_ON) ?
950 msecs_to_jiffies(sc->led_off_duration) :
951 msecs_to_jiffies(sc->led_on_duration));
952
953 sc->led_on_duration =
954 max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25);
955 sc->led_off_duration =
956 max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10);
957 sc->led_on_cnt = sc->led_off_cnt = 0;
958 if (sc->sc_flags & SC_OP_LED_ON)
959 sc->sc_flags &= ~SC_OP_LED_ON;
960 else
961 sc->sc_flags |= SC_OP_LED_ON;
962}
963
938static void ath_led_brightness(struct led_classdev *led_cdev, 964static void ath_led_brightness(struct led_classdev *led_cdev,
939 enum led_brightness brightness) 965 enum led_brightness brightness)
940{ 966{
@@ -944,16 +970,27 @@ static void ath_led_brightness(struct led_classdev *led_cdev,
944 switch (brightness) { 970 switch (brightness) {
945 case LED_OFF: 971 case LED_OFF:
946 if (led->led_type == ATH_LED_ASSOC || 972 if (led->led_type == ATH_LED_ASSOC ||
947 led->led_type == ATH_LED_RADIO) 973 led->led_type == ATH_LED_RADIO) {
974 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
975 (led->led_type == ATH_LED_RADIO));
948 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; 976 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
949 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 977 if (led->led_type == ATH_LED_RADIO)
950 (led->led_type == ATH_LED_RADIO) ? 1 : 978 sc->sc_flags &= ~SC_OP_LED_ON;
951 !!(sc->sc_flags & SC_OP_LED_ASSOCIATED)); 979 } else {
980 sc->led_off_cnt++;
981 }
952 break; 982 break;
953 case LED_FULL: 983 case LED_FULL:
954 if (led->led_type == ATH_LED_ASSOC) 984 if (led->led_type == ATH_LED_ASSOC) {
955 sc->sc_flags |= SC_OP_LED_ASSOCIATED; 985 sc->sc_flags |= SC_OP_LED_ASSOCIATED;
956 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0); 986 queue_delayed_work(sc->hw->workqueue,
987 &sc->ath_led_blink_work, 0);
988 } else if (led->led_type == ATH_LED_RADIO) {
989 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0);
990 sc->sc_flags |= SC_OP_LED_ON;
991 } else {
992 sc->led_on_cnt++;
993 }
957 break; 994 break;
958 default: 995 default:
959 break; 996 break;
@@ -989,6 +1026,7 @@ static void ath_unregister_led(struct ath_led *led)
989 1026
990static void ath_deinit_leds(struct ath_softc *sc) 1027static void ath_deinit_leds(struct ath_softc *sc)
991{ 1028{
1029 cancel_delayed_work_sync(&sc->ath_led_blink_work);
992 ath_unregister_led(&sc->assoc_led); 1030 ath_unregister_led(&sc->assoc_led);
993 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; 1031 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
994 ath_unregister_led(&sc->tx_led); 1032 ath_unregister_led(&sc->tx_led);
@@ -1008,9 +1046,11 @@ static void ath_init_leds(struct ath_softc *sc)
1008 /* LED off, active low */ 1046 /* LED off, active low */
1009 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1); 1047 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
1010 1048
1049 INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work);
1050
1011 trigger = ieee80211_get_radio_led_name(sc->hw); 1051 trigger = ieee80211_get_radio_led_name(sc->hw);
1012 snprintf(sc->radio_led.name, sizeof(sc->radio_led.name), 1052 snprintf(sc->radio_led.name, sizeof(sc->radio_led.name),
1013 "ath9k-%s:radio", wiphy_name(sc->hw->wiphy)); 1053 "ath9k-%s::radio", wiphy_name(sc->hw->wiphy));
1014 ret = ath_register_led(sc, &sc->radio_led, trigger); 1054 ret = ath_register_led(sc, &sc->radio_led, trigger);
1015 sc->radio_led.led_type = ATH_LED_RADIO; 1055 sc->radio_led.led_type = ATH_LED_RADIO;
1016 if (ret) 1056 if (ret)
@@ -1018,7 +1058,7 @@ static void ath_init_leds(struct ath_softc *sc)
1018 1058
1019 trigger = ieee80211_get_assoc_led_name(sc->hw); 1059 trigger = ieee80211_get_assoc_led_name(sc->hw);
1020 snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name), 1060 snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name),
1021 "ath9k-%s:assoc", wiphy_name(sc->hw->wiphy)); 1061 "ath9k-%s::assoc", wiphy_name(sc->hw->wiphy));
1022 ret = ath_register_led(sc, &sc->assoc_led, trigger); 1062 ret = ath_register_led(sc, &sc->assoc_led, trigger);
1023 sc->assoc_led.led_type = ATH_LED_ASSOC; 1063 sc->assoc_led.led_type = ATH_LED_ASSOC;
1024 if (ret) 1064 if (ret)
@@ -1026,7 +1066,7 @@ static void ath_init_leds(struct ath_softc *sc)
1026 1066
1027 trigger = ieee80211_get_tx_led_name(sc->hw); 1067 trigger = ieee80211_get_tx_led_name(sc->hw);
1028 snprintf(sc->tx_led.name, sizeof(sc->tx_led.name), 1068 snprintf(sc->tx_led.name, sizeof(sc->tx_led.name),
1029 "ath9k-%s:tx", wiphy_name(sc->hw->wiphy)); 1069 "ath9k-%s::tx", wiphy_name(sc->hw->wiphy));
1030 ret = ath_register_led(sc, &sc->tx_led, trigger); 1070 ret = ath_register_led(sc, &sc->tx_led, trigger);
1031 sc->tx_led.led_type = ATH_LED_TX; 1071 sc->tx_led.led_type = ATH_LED_TX;
1032 if (ret) 1072 if (ret)
@@ -1034,7 +1074,7 @@ static void ath_init_leds(struct ath_softc *sc)
1034 1074
1035 trigger = ieee80211_get_rx_led_name(sc->hw); 1075 trigger = ieee80211_get_rx_led_name(sc->hw);
1036 snprintf(sc->rx_led.name, sizeof(sc->rx_led.name), 1076 snprintf(sc->rx_led.name, sizeof(sc->rx_led.name),
1037 "ath9k-%s:rx", wiphy_name(sc->hw->wiphy)); 1077 "ath9k-%s::rx", wiphy_name(sc->hw->wiphy));
1038 ret = ath_register_led(sc, &sc->rx_led, trigger); 1078 ret = ath_register_led(sc, &sc->rx_led, trigger);
1039 sc->rx_led.led_type = ATH_LED_RX; 1079 sc->rx_led.led_type = ATH_LED_RX;
1040 if (ret) 1080 if (ret)
@@ -1217,7 +1257,7 @@ static int ath_init_sw_rfkill(struct ath_softc *sc)
1217 } 1257 }
1218 1258
1219 snprintf(sc->rf_kill.rfkill_name, sizeof(sc->rf_kill.rfkill_name), 1259 snprintf(sc->rf_kill.rfkill_name, sizeof(sc->rf_kill.rfkill_name),
1220 "ath9k-%s:rfkill", wiphy_name(sc->hw->wiphy)); 1260 "ath9k-%s::rfkill", wiphy_name(sc->hw->wiphy));
1221 sc->rf_kill.rfkill->name = sc->rf_kill.rfkill_name; 1261 sc->rf_kill.rfkill->name = sc->rf_kill.rfkill_name;
1222 sc->rf_kill.rfkill->data = sc; 1262 sc->rf_kill.rfkill->data = sc;
1223 sc->rf_kill.rfkill->toggle_radio = ath_sw_toggle_radio; 1263 sc->rf_kill.rfkill->toggle_radio = ath_sw_toggle_radio;
@@ -1957,25 +1997,6 @@ static int ath9k_start(struct ieee80211_hw *hw)
1957 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) 1997 if (sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
1958 sc->sc_imask |= ATH9K_INT_CST; 1998 sc->sc_imask |= ATH9K_INT_CST;
1959 1999
1960 /*
1961 * Enable MIB interrupts when there are hardware phy counters.
1962 * Note we only do this (at the moment) for station mode.
1963 */
1964 if (ath9k_hw_phycounters(sc->sc_ah) &&
1965 ((sc->sc_ah->ah_opmode == NL80211_IFTYPE_STATION) ||
1966 (sc->sc_ah->ah_opmode == NL80211_IFTYPE_ADHOC)))
1967 sc->sc_imask |= ATH9K_INT_MIB;
1968 /*
1969 * Some hardware processes the TIM IE and fires an
1970 * interrupt when the TIM bit is set. For hardware
1971 * that does, if not overridden by configuration,
1972 * enable the TIM interrupt when operating as station.
1973 */
1974 if ((sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_ENHANCEDPM) &&
1975 (sc->sc_ah->ah_opmode == NL80211_IFTYPE_STATION) &&
1976 !sc->sc_config.swBeaconProcess)
1977 sc->sc_imask |= ATH9K_INT_TIM;
1978
1979 ath_cache_conf_rate(sc, &hw->conf); 2000 ath_cache_conf_rate(sc, &hw->conf);
1980 2001
1981 sc->sc_flags &= ~SC_OP_INVALID; 2002 sc->sc_flags &= ~SC_OP_INVALID;
@@ -2124,6 +2145,27 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
2124 /* Set the device opmode */ 2145 /* Set the device opmode */
2125 sc->sc_ah->ah_opmode = ic_opmode; 2146 sc->sc_ah->ah_opmode = ic_opmode;
2126 2147
2148 /*
2149 * Enable MIB interrupts when there are hardware phy counters.
2150 * Note we only do this (at the moment) for station mode.
2151 */
2152 if (ath9k_hw_phycounters(sc->sc_ah) &&
2153 ((conf->type == NL80211_IFTYPE_STATION) ||
2154 (conf->type == NL80211_IFTYPE_ADHOC)))
2155 sc->sc_imask |= ATH9K_INT_MIB;
2156 /*
2157 * Some hardware processes the TIM IE and fires an
2158 * interrupt when the TIM bit is set. For hardware
2159 * that does, if not overridden by configuration,
2160 * enable the TIM interrupt when operating as station.
2161 */
2162 if ((sc->sc_ah->ah_caps.hw_caps & ATH9K_HW_CAP_ENHANCEDPM) &&
2163 (conf->type == NL80211_IFTYPE_STATION) &&
2164 !sc->sc_config.swBeaconProcess)
2165 sc->sc_imask |= ATH9K_INT_TIM;
2166
2167 ath9k_hw_set_interrupts(sc->sc_ah, sc->sc_imask);
2168
2127 if (conf->type == NL80211_IFTYPE_AP) { 2169 if (conf->type == NL80211_IFTYPE_AP) {
2128 /* TODO: is this a suitable place to start ANI for AP mode? */ 2170 /* TODO: is this a suitable place to start ANI for AP mode? */
2129 /* Start ANI */ 2171 /* Start ANI */
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index eb557add6567..704b62778142 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -631,8 +631,7 @@ static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv,
631static u8 ath_rc_ratefind_ht(struct ath_softc *sc, 631static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
632 struct ath_rate_priv *ath_rc_priv, 632 struct ath_rate_priv *ath_rc_priv,
633 struct ath_rate_table *rate_table, 633 struct ath_rate_table *rate_table,
634 int probe_allowed, int *is_probing, 634 int *is_probing)
635 int is_retry)
636{ 635{
637 u32 dt, best_thruput, this_thruput, now_msec; 636 u32 dt, best_thruput, this_thruput, now_msec;
638 u8 rate, next_rate, best_rate, maxindex, minindex; 637 u8 rate, next_rate, best_rate, maxindex, minindex;
@@ -714,13 +713,6 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
714 } 713 }
715 714
716 rate = best_rate; 715 rate = best_rate;
717
718 /* if we are retrying for more than half the number
719 * of max retries, use the min rate for the next retry
720 */
721 if (is_retry)
722 rate = ath_rc_priv->valid_rate_index[minindex];
723
724 ath_rc_priv->rssi_last_lookup = rssi_last; 716 ath_rc_priv->rssi_last_lookup = rssi_last;
725 717
726 /* 718 /*
@@ -728,13 +720,12 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
728 * non-monoticity of 11g's rate table 720 * non-monoticity of 11g's rate table
729 */ 721 */
730 722
731 if (rate >= ath_rc_priv->rate_max_phy && probe_allowed) { 723 if (rate >= ath_rc_priv->rate_max_phy) {
732 rate = ath_rc_priv->rate_max_phy; 724 rate = ath_rc_priv->rate_max_phy;
733 725
734 /* Probe the next allowed phy state */ 726 /* Probe the next allowed phy state */
735 /* FIXME:XXXX Check to make sure ratMax is checked properly */
736 if (ath_rc_get_nextvalid_txrate(rate_table, 727 if (ath_rc_get_nextvalid_txrate(rate_table,
737 ath_rc_priv, rate, &next_rate) && 728 ath_rc_priv, rate, &next_rate) &&
738 (now_msec - ath_rc_priv->probe_time > 729 (now_msec - ath_rc_priv->probe_time >
739 rate_table->probe_interval) && 730 rate_table->probe_interval) &&
740 (ath_rc_priv->hw_maxretry_pktcnt >= 1)) { 731 (ath_rc_priv->hw_maxretry_pktcnt >= 1)) {
@@ -756,14 +747,17 @@ static u8 ath_rc_ratefind_ht(struct ath_softc *sc,
756 return rate; 747 return rate;
757} 748}
758 749
759static void ath_rc_rate_set_series(struct ath_rate_table *rate_table , 750static void ath_rc_rate_set_series(struct ath_rate_table *rate_table,
760 struct ieee80211_tx_rate *rate, 751 struct ieee80211_tx_rate *rate,
752 struct ieee80211_tx_rate_control *txrc,
761 u8 tries, u8 rix, int rtsctsenable) 753 u8 tries, u8 rix, int rtsctsenable)
762{ 754{
763 rate->count = tries; 755 rate->count = tries;
764 rate->idx = rix; 756 rate->idx = rix;
765 757
766 if (rtsctsenable) 758 if (txrc->short_preamble)
759 rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
760 if (txrc->rts || rtsctsenable)
767 rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS; 761 rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
768 if (WLAN_RC_PHY_40(rate_table->info[rix].phy)) 762 if (WLAN_RC_PHY_40(rate_table->info[rix].phy))
769 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; 763 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
@@ -773,6 +767,43 @@ static void ath_rc_rate_set_series(struct ath_rate_table *rate_table ,
773 rate->flags |= IEEE80211_TX_RC_MCS; 767 rate->flags |= IEEE80211_TX_RC_MCS;
774} 768}
775 769
770static void ath_rc_rate_set_rtscts(struct ath_softc *sc,
771 struct ath_rate_table *rate_table,
772 struct ieee80211_tx_info *tx_info)
773{
774 struct ieee80211_tx_rate *rates = tx_info->control.rates;
775 int i = 0, rix = 0, cix, enable_g_protection = 0;
776
777 /* get the cix for the lowest valid rix */
778 for (i = 3; i >= 0; i--) {
779 if (rates[i].count && (rates[i].idx >= 0)) {
780 rix = rates[i].idx;
781 break;
782 }
783 }
784 cix = rate_table->info[rix].ctrl_rate;
785
786 /* All protection frames are transmited at 2Mb/s for 802.11g,
787 * otherwise we transmit them at 1Mb/s */
788 if (sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ &&
789 !conf_is_ht(&sc->hw->conf))
790 enable_g_protection = 1;
791
792 /*
793 * If 802.11g protection is enabled, determine whether to use RTS/CTS or
794 * just CTS. Note that this is only done for OFDM/HT unicast frames.
795 */
796 if ((sc->sc_flags & SC_OP_PROTECT_ENABLE) &&
797 !(tx_info->flags & IEEE80211_TX_CTL_NO_ACK) &&
798 (rate_table->info[rix].phy == WLAN_RC_PHY_OFDM ||
799 WLAN_RC_PHY_HT(rate_table->info[rix].phy))) {
800 rates[0].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT;
801 cix = rate_table->info[enable_g_protection].ctrl_rate;
802 }
803
804 tx_info->control.rts_cts_rate_idx = cix;
805}
806
776static u8 ath_rc_rate_getidx(struct ath_softc *sc, 807static u8 ath_rc_rate_getidx(struct ath_softc *sc,
777 struct ath_rate_priv *ath_rc_priv, 808 struct ath_rate_priv *ath_rc_priv,
778 struct ath_rate_table *rate_table, 809 struct ath_rate_table *rate_table,
@@ -804,54 +835,56 @@ static u8 ath_rc_rate_getidx(struct ath_softc *sc,
804 835
805static void ath_rc_ratefind(struct ath_softc *sc, 836static void ath_rc_ratefind(struct ath_softc *sc,
806 struct ath_rate_priv *ath_rc_priv, 837 struct ath_rate_priv *ath_rc_priv,
807 int num_tries, int num_rates, 838 struct ieee80211_tx_rate_control *txrc)
808 struct ieee80211_tx_info *tx_info, int *is_probe,
809 int is_retry)
810{ 839{
811 u8 try_per_rate = 0, i = 0, rix, nrix;
812 struct ath_rate_table *rate_table; 840 struct ath_rate_table *rate_table;
841 struct sk_buff *skb = txrc->skb;
842 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
813 struct ieee80211_tx_rate *rates = tx_info->control.rates; 843 struct ieee80211_tx_rate *rates = tx_info->control.rates;
844 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
845 __le16 fc = hdr->frame_control;
846 u8 try_per_rate = 0, i = 0, rix, nrix;
847 int is_probe = 0;
814 848
815 rate_table = sc->cur_rate_table; 849 rate_table = sc->cur_rate_table;
816 rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table, 1, 850 rix = ath_rc_ratefind_ht(sc, ath_rc_priv, rate_table, &is_probe);
817 is_probe, is_retry);
818 nrix = rix; 851 nrix = rix;
819 852
820 if (*is_probe) { 853 if (is_probe) {
821 /* set one try for probe rates. For the 854 /* set one try for probe rates. For the
822 * probes don't enable rts */ 855 * probes don't enable rts */
823 ath_rc_rate_set_series(rate_table, 856 ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
824 &rates[i++], 1, nrix, 0); 857 1, nrix, 0);
825 858
826 try_per_rate = (num_tries/num_rates); 859 try_per_rate = (ATH_11N_TXMAXTRY/4);
827 /* Get the next tried/allowed rate. No RTS for the next series 860 /* Get the next tried/allowed rate. No RTS for the next series
828 * after the probe rate 861 * after the probe rate
829 */ 862 */
830 nrix = ath_rc_rate_getidx(sc, 863 nrix = ath_rc_rate_getidx(sc, ath_rc_priv,
831 ath_rc_priv, rate_table, nrix, 1, 0); 864 rate_table, nrix, 1, 0);
832 ath_rc_rate_set_series(rate_table, 865 ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
833 &rates[i++], try_per_rate, nrix, 0); 866 try_per_rate, nrix, 0);
834 } else { 867 } else {
835 try_per_rate = (num_tries/num_rates); 868 try_per_rate = (ATH_11N_TXMAXTRY/4);
836 /* Set the choosen rate. No RTS for first series entry. */ 869 /* Set the choosen rate. No RTS for first series entry. */
837 ath_rc_rate_set_series(rate_table, 870 ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
838 &rates[i++], try_per_rate, nrix, 0); 871 try_per_rate, nrix, 0);
839 } 872 }
840 873
841 /* Fill in the other rates for multirate retry */ 874 /* Fill in the other rates for multirate retry */
842 for ( ; i < num_rates; i++) { 875 for ( ; i < 4; i++) {
843 u8 try_num; 876 u8 try_num;
844 u8 min_rate; 877 u8 min_rate;
845 878
846 try_num = ((i + 1) == num_rates) ? 879 try_num = ((i + 1) == 4) ?
847 num_tries - (try_per_rate * i) : try_per_rate ; 880 ATH_11N_TXMAXTRY - (try_per_rate * i) : try_per_rate ;
848 min_rate = (((i + 1) == num_rates) && 0); 881 min_rate = (((i + 1) == 4) && 0);
849 882
850 nrix = ath_rc_rate_getidx(sc, ath_rc_priv, 883 nrix = ath_rc_rate_getidx(sc, ath_rc_priv,
851 rate_table, nrix, 1, min_rate); 884 rate_table, nrix, 1, min_rate);
852 /* All other rates in the series have RTS enabled */ 885 /* All other rates in the series have RTS enabled */
853 ath_rc_rate_set_series(rate_table, 886 ath_rc_rate_set_series(rate_table, &rates[i], txrc,
854 &rates[i], try_num, nrix, 1); 887 try_num, nrix, 1);
855 } 888 }
856 889
857 /* 890 /*
@@ -880,6 +913,24 @@ static void ath_rc_ratefind(struct ath_softc *sc,
880 rates[3].flags = rates[2].flags; 913 rates[3].flags = rates[2].flags;
881 } 914 }
882 } 915 }
916
917 /*
918 * Force hardware to use computed duration for next
919 * fragment by disabling multi-rate retry, which
920 * updates duration based on the multi-rate duration table.
921 *
922 * FIXME: Fix duration
923 */
924 if (!(tx_info->flags & IEEE80211_TX_CTL_NO_ACK) &&
925 (ieee80211_has_morefrags(fc) ||
926 (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG))) {
927 rates[1].count = rates[2].count = rates[3].count = 0;
928 rates[1].idx = rates[2].idx = rates[3].idx = 0;
929 rates[0].count = ATH_TXMAXTRY;
930 }
931
932 /* Setup RTS/CTS */
933 ath_rc_rate_set_rtscts(sc, rate_table, tx_info);
883} 934}
884 935
885static bool ath_rc_update_per(struct ath_softc *sc, 936static bool ath_rc_update_per(struct ath_softc *sc,
@@ -1394,16 +1445,16 @@ static void ath_rc_init(struct ath_softc *sc,
1394 if (!rateset->rs_nrates) { 1445 if (!rateset->rs_nrates) {
1395 /* No working rate, just initialize valid rates */ 1446 /* No working rate, just initialize valid rates */
1396 hi = ath_rc_init_validrates(ath_rc_priv, rate_table, 1447 hi = ath_rc_init_validrates(ath_rc_priv, rate_table,
1397 ath_rc_priv->ht_cap); 1448 ath_rc_priv->ht_cap);
1398 } else { 1449 } else {
1399 /* Use intersection of working rates and valid rates */ 1450 /* Use intersection of working rates and valid rates */
1400 hi = ath_rc_setvalid_rates(ath_rc_priv, rate_table, 1451 hi = ath_rc_setvalid_rates(ath_rc_priv, rate_table,
1401 rateset, ath_rc_priv->ht_cap); 1452 rateset, ath_rc_priv->ht_cap);
1402 if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG) { 1453 if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG) {
1403 hthi = ath_rc_setvalid_htrates(ath_rc_priv, 1454 hthi = ath_rc_setvalid_htrates(ath_rc_priv,
1404 rate_table, 1455 rate_table,
1405 ht_mcs, 1456 ht_mcs,
1406 ath_rc_priv->ht_cap); 1457 ath_rc_priv->ht_cap);
1407 } 1458 }
1408 hi = A_MAX(hi, hthi); 1459 hi = A_MAX(hi, hthi);
1409 } 1460 }
@@ -1479,6 +1530,22 @@ static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1479 (is_underrun) ? ATH_11N_TXMAXTRY : 1530 (is_underrun) ? ATH_11N_TXMAXTRY :
1480 tx_info_priv->tx.ts_longretry); 1531 tx_info_priv->tx.ts_longretry);
1481 1532
1533 /* Check if aggregation has to be enabled for this tid */
1534 if (conf_is_ht(&sc->hw->conf)) {
1535 if (ieee80211_is_data_qos(fc)) {
1536 u8 *qc, tid;
1537 struct ath_node *an;
1538
1539 qc = ieee80211_get_qos_ctl(hdr);
1540 tid = qc[0] & 0xf;
1541 an = (struct ath_node *)sta->drv_priv;
1542
1543 if(ath_tx_aggr_check(sc, an, tid))
1544 ieee80211_start_tx_ba_session(sc->hw, hdr->addr1, tid);
1545 }
1546 }
1547
1548 ath_debug_stat_rc(sc, skb);
1482exit: 1549exit:
1483 kfree(tx_info_priv); 1550 kfree(tx_info_priv);
1484} 1551}
@@ -1489,11 +1556,9 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
1489 struct ieee80211_supported_band *sband = txrc->sband; 1556 struct ieee80211_supported_band *sband = txrc->sband;
1490 struct sk_buff *skb = txrc->skb; 1557 struct sk_buff *skb = txrc->skb;
1491 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1558 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1559 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1492 struct ath_softc *sc = priv; 1560 struct ath_softc *sc = priv;
1493 struct ieee80211_hw *hw = sc->hw;
1494 struct ath_rate_priv *ath_rc_priv = priv_sta; 1561 struct ath_rate_priv *ath_rc_priv = priv_sta;
1495 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1496 int is_probe = 0;
1497 __le16 fc = hdr->frame_control; 1562 __le16 fc = hdr->frame_control;
1498 1563
1499 /* lowest rate for management and multicast/broadcast frames */ 1564 /* lowest rate for management and multicast/broadcast frames */
@@ -1506,23 +1571,7 @@ static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
1506 } 1571 }
1507 1572
1508 /* Find tx rate for unicast frames */ 1573 /* Find tx rate for unicast frames */
1509 ath_rc_ratefind(sc, ath_rc_priv, ATH_11N_TXMAXTRY, 4, 1574 ath_rc_ratefind(sc, ath_rc_priv, txrc);
1510 tx_info, &is_probe, false);
1511
1512 /* Check if aggregation has to be enabled for this tid */
1513 if (conf_is_ht(&hw->conf)) {
1514 if (ieee80211_is_data_qos(fc)) {
1515 u8 *qc, tid;
1516 struct ath_node *an;
1517
1518 qc = ieee80211_get_qos_ctl(hdr);
1519 tid = qc[0] & 0xf;
1520 an = (struct ath_node *)sta->drv_priv;
1521
1522 if(ath_tx_aggr_check(sc, an, tid))
1523 ieee80211_start_tx_ba_session(hw, hdr->addr1, tid);
1524 }
1525 }
1526} 1575}
1527 1576
1528static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband, 1577static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
diff --git a/drivers/net/wireless/ath9k/reg.h b/drivers/net/wireless/ath9k/reg.h
index 150eda56055a..c967b7926e33 100644
--- a/drivers/net/wireless/ath9k/reg.h
+++ b/drivers/net/wireless/ath9k/reg.h
@@ -1198,18 +1198,7 @@ enum {
1198#define AR_CFP_VAL 0x0000FFFF 1198#define AR_CFP_VAL 0x0000FFFF
1199 1199
1200#define AR_RX_FILTER 0x803C 1200#define AR_RX_FILTER 0x803C
1201#define AR_RX_FILTER_ALL 0x00000000
1202#define AR_RX_UCAST 0x00000001
1203#define AR_RX_MCAST 0x00000002
1204#define AR_RX_BCAST 0x00000004
1205#define AR_RX_CONTROL 0x00000008
1206#define AR_RX_BEACON 0x00000010
1207#define AR_RX_PROM 0x00000020
1208#define AR_RX_PROBE_REQ 0x00000080
1209#define AR_RX_MY_BEACON 0x00000200
1210#define AR_RX_COMPR_BAR 0x00000400 1201#define AR_RX_COMPR_BAR 0x00000400
1211#define AR_RX_COMPR_BA 0x00000800
1212#define AR_RX_UNCOM_BA_BAR 0x00001000
1213 1202
1214#define AR_MCAST_FIL0 0x8040 1203#define AR_MCAST_FIL0 0x8040
1215#define AR_MCAST_FIL1 0x8044 1204#define AR_MCAST_FIL1 0x8044
diff --git a/drivers/net/wireless/ath9k/regd.c b/drivers/net/wireless/ath9k/regd.c
index ec88f78743e9..fe08a4fdf770 100644
--- a/drivers/net/wireless/ath9k/regd.c
+++ b/drivers/net/wireless/ath9k/regd.c
@@ -154,12 +154,20 @@ const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hal *ah)
154 } 154 }
155} 155}
156 156
157/* Enable adhoc on 5 GHz if allowed by 11d */ 157/* Frequency is one where radar detection is required */
158static void ath9k_reg_apply_5ghz_adhoc_flags(struct wiphy *wiphy, 158static bool ath9k_is_radar_freq(u16 center_freq)
159{
160 return (center_freq >= 5260 && center_freq <= 5700);
161}
162
163/*
164 * Enable adhoc on 5 GHz if allowed by 11d.
165 * Remove passive scan if channel is allowed by 11d,
166 * except when on radar frequencies.
167 */
168static void ath9k_reg_apply_5ghz_beaconing_flags(struct wiphy *wiphy,
159 enum reg_set_by setby) 169 enum reg_set_by setby)
160{ 170{
161 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
162 struct ath_softc *sc = hw->priv;
163 struct ieee80211_supported_band *sband; 171 struct ieee80211_supported_band *sband;
164 const struct ieee80211_reg_rule *reg_rule; 172 const struct ieee80211_reg_rule *reg_rule;
165 struct ieee80211_channel *ch; 173 struct ieee80211_channel *ch;
@@ -169,8 +177,7 @@ static void ath9k_reg_apply_5ghz_adhoc_flags(struct wiphy *wiphy,
169 177
170 if (setby != REGDOM_SET_BY_COUNTRY_IE) 178 if (setby != REGDOM_SET_BY_COUNTRY_IE)
171 return; 179 return;
172 if (!test_bit(ATH9K_MODE_11A, 180 if (!wiphy->bands[IEEE80211_BAND_5GHZ])
173 sc->sc_ah->ah_caps.wireless_modes))
174 return; 181 return;
175 182
176 sband = wiphy->bands[IEEE80211_BAND_5GHZ]; 183 sband = wiphy->bands[IEEE80211_BAND_5GHZ];
@@ -185,7 +192,11 @@ static void ath9k_reg_apply_5ghz_adhoc_flags(struct wiphy *wiphy,
185 * it by applying our static world regdomain by default during 192 * it by applying our static world regdomain by default during
186 * probe */ 193 * probe */
187 if (!(reg_rule->flags & NL80211_RRF_NO_IBSS)) 194 if (!(reg_rule->flags & NL80211_RRF_NO_IBSS))
188 ch->flags &= ~NL80211_RRF_NO_IBSS; 195 ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
196 if (!ath9k_is_radar_freq(ch->center_freq))
197 continue;
198 if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
199 ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
189 } 200 }
190} 201}
191 202
@@ -250,9 +261,7 @@ void ath9k_reg_apply_radar_flags(struct wiphy *wiphy)
250 261
251 for (i = 0; i < sband->n_channels; i++) { 262 for (i = 0; i < sband->n_channels; i++) {
252 ch = &sband->channels[i]; 263 ch = &sband->channels[i];
253 if (ch->center_freq < 5260) 264 if (!ath9k_is_radar_freq(ch->center_freq))
254 continue;
255 if (ch->center_freq > 5700)
256 continue; 265 continue;
257 /* We always enable radar detection/DFS on this 266 /* We always enable radar detection/DFS on this
258 * frequency range. Additionally we also apply on 267 * frequency range. Additionally we also apply on
@@ -282,10 +291,10 @@ void ath9k_reg_apply_world_flags(struct wiphy *wiphy, enum reg_set_by setby)
282 case 0x63: 291 case 0x63:
283 case 0x66: 292 case 0x66:
284 case 0x67: 293 case 0x67:
285 ath9k_reg_apply_5ghz_adhoc_flags(wiphy, setby); 294 ath9k_reg_apply_5ghz_beaconing_flags(wiphy, setby);
286 break; 295 break;
287 case 0x68: 296 case 0x68:
288 ath9k_reg_apply_5ghz_adhoc_flags(wiphy, setby); 297 ath9k_reg_apply_5ghz_beaconing_flags(wiphy, setby);
289 ath9k_reg_apply_active_scan_flags(wiphy, setby); 298 ath9k_reg_apply_active_scan_flags(wiphy, setby);
290 break; 299 break;
291 } 300 }
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index 007ca91188d1..e14bceaef125 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -677,6 +677,7 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
677 txtid = ATH_AN_2_TID(an, tid); 677 txtid = ATH_AN_2_TID(an, tid);
678 txtid->state |= AGGR_ADDBA_PROGRESS; 678 txtid->state |= AGGR_ADDBA_PROGRESS;
679 ath_tx_pause_tid(sc, txtid); 679 ath_tx_pause_tid(sc, txtid);
680 *ssn = txtid->seq_start;
680 } 681 }
681 682
682 return 0; 683 return 0;
@@ -1385,8 +1386,6 @@ static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb,
1385 1386
1386 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) 1387 if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
1387 flags |= ATH9K_TXDESC_NOACK; 1388 flags |= ATH9K_TXDESC_NOACK;
1388 if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
1389 flags |= ATH9K_TXDESC_RTSENA;
1390 1389
1391 return flags; 1390 return flags;
1392} 1391}
@@ -1432,137 +1431,86 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
1432 1431
1433static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) 1432static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
1434{ 1433{
1435 struct ath_hal *ah = sc->sc_ah; 1434 struct ath_rate_table *rt = sc->cur_rate_table;
1436 struct ath_rate_table *rt;
1437 struct ath_desc *ds = bf->bf_desc;
1438 struct ath_desc *lastds = bf->bf_lastbf->bf_desc;
1439 struct ath9k_11n_rate_series series[4]; 1435 struct ath9k_11n_rate_series series[4];
1440 struct sk_buff *skb; 1436 struct sk_buff *skb;
1441 struct ieee80211_tx_info *tx_info; 1437 struct ieee80211_tx_info *tx_info;
1442 struct ieee80211_tx_rate *rates; 1438 struct ieee80211_tx_rate *rates;
1443 struct ieee80211_hdr *hdr; 1439 int i, flags = 0;
1444 struct ieee80211_hw *hw = sc->hw; 1440 u8 rix = 0, ctsrate = 0;
1445 int i, flags, rtsctsena = 0, enable_g_protection = 0;
1446 u32 ctsduration = 0;
1447 u8 rix = 0, cix, ctsrate = 0;
1448 __le16 fc;
1449 1441
1450 memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4); 1442 memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4);
1451 1443
1452 skb = (struct sk_buff *)bf->bf_mpdu; 1444 skb = (struct sk_buff *)bf->bf_mpdu;
1453 hdr = (struct ieee80211_hdr *)skb->data;
1454 fc = hdr->frame_control;
1455 tx_info = IEEE80211_SKB_CB(skb); 1445 tx_info = IEEE80211_SKB_CB(skb);
1456 rates = tx_info->control.rates; 1446 rates = tx_info->control.rates;
1457 1447
1458 if (ieee80211_has_morefrags(fc) ||
1459 (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG)) {
1460 rates[1].count = rates[2].count = rates[3].count = 0;
1461 rates[1].idx = rates[2].idx = rates[3].idx = 0;
1462 rates[0].count = ATH_TXMAXTRY;
1463 }
1464
1465 /* get the cix for the lowest valid rix */
1466 rt = sc->cur_rate_table;
1467 for (i = 3; i >= 0; i--) {
1468 if (rates[i].count && (rates[i].idx >= 0)) {
1469 rix = rates[i].idx;
1470 break;
1471 }
1472 }
1473
1474 flags = (bf->bf_flags & (ATH9K_TXDESC_RTSENA | ATH9K_TXDESC_CTSENA));
1475 cix = rt->info[rix].ctrl_rate;
1476
1477 /* All protection frames are transmited at 2Mb/s for 802.11g,
1478 * otherwise we transmit them at 1Mb/s */
1479 if (hw->conf.channel->band == IEEE80211_BAND_2GHZ &&
1480 !conf_is_ht(&hw->conf))
1481 enable_g_protection = 1;
1482
1483 /* 1448 /*
1484 * If 802.11g protection is enabled, determine whether to use RTS/CTS or 1449 * We check if Short Preamble is needed for the CTS rate by
1485 * just CTS. Note that this is only done for OFDM/HT unicast frames. 1450 * checking the BSS's global flag.
1451 * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
1486 */ 1452 */
1487 if (sc->sc_protmode != PROT_M_NONE && !(bf->bf_flags & ATH9K_TXDESC_NOACK) 1453 if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
1488 && (rt->info[rix].phy == WLAN_RC_PHY_OFDM || 1454 ctsrate = rt->info[tx_info->control.rts_cts_rate_idx].ratecode |
1489 WLAN_RC_PHY_HT(rt->info[rix].phy))) { 1455 rt->info[tx_info->control.rts_cts_rate_idx].short_preamble;
1490 if (sc->sc_protmode == PROT_M_RTSCTS) 1456 else
1491 flags = ATH9K_TXDESC_RTSENA; 1457 ctsrate = rt->info[tx_info->control.rts_cts_rate_idx].ratecode;
1492 else if (sc->sc_protmode == PROT_M_CTSONLY)
1493 flags = ATH9K_TXDESC_CTSENA;
1494
1495 cix = rt->info[enable_g_protection].ctrl_rate;
1496 rtsctsena = 1;
1497 }
1498 1458
1499 /* For 11n, the default behavior is to enable RTS for hw retried frames. 1459 /*
1500 * We enable the global flag here and let rate series flags determine 1460 * ATH9K_TXDESC_RTSENA and ATH9K_TXDESC_CTSENA are mutually exclusive.
1501 * which rates will actually use RTS. 1461 * Check the first rate in the series to decide whether RTS/CTS
1462 * or CTS-to-self has to be used.
1502 */ 1463 */
1503 if ((ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) && bf_isdata(bf)) { 1464 if (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
1504 /* 802.11g protection not needed, use our default behavior */ 1465 flags = ATH9K_TXDESC_CTSENA;
1505 if (!rtsctsena) 1466 else if (rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
1506 flags = ATH9K_TXDESC_RTSENA; 1467 flags = ATH9K_TXDESC_RTSENA;
1507 }
1508 1468
1509 /* Set protection if aggregate protection on */ 1469 /* FIXME: Handle aggregation protection */
1510 if (sc->sc_config.ath_aggr_prot && 1470 if (sc->sc_config.ath_aggr_prot &&
1511 (!bf_isaggr(bf) || (bf_isaggr(bf) && bf->bf_al < 8192))) { 1471 (!bf_isaggr(bf) || (bf_isaggr(bf) && bf->bf_al < 8192))) {
1512 flags = ATH9K_TXDESC_RTSENA; 1472 flags = ATH9K_TXDESC_RTSENA;
1513 cix = rt->info[enable_g_protection].ctrl_rate;
1514 rtsctsena = 1;
1515 } 1473 }
1516 1474
1517 /* For AR5416 - RTS cannot be followed by a frame larger than 8K */ 1475 /* For AR5416 - RTS cannot be followed by a frame larger than 8K */
1518 if (bf_isaggr(bf) && (bf->bf_al > ah->ah_caps.rts_aggr_limit)) 1476 if (bf_isaggr(bf) && (bf->bf_al > sc->sc_ah->ah_caps.rts_aggr_limit))
1519 flags &= ~(ATH9K_TXDESC_RTSENA); 1477 flags &= ~(ATH9K_TXDESC_RTSENA);
1520 1478
1521 /*
1522 * CTS transmit rate is derived from the transmit rate by looking in the
1523 * h/w rate table. We must also factor in whether or not a short
1524 * preamble is to be used. NB: cix is set above where RTS/CTS is enabled
1525 */
1526 ctsrate = rt->info[cix].ratecode |
1527 (bf_isshpreamble(bf) ? rt->info[cix].short_preamble : 0);
1528
1529 for (i = 0; i < 4; i++) { 1479 for (i = 0; i < 4; i++) {
1530 if (!rates[i].count || (rates[i].idx < 0)) 1480 if (!rates[i].count || (rates[i].idx < 0))
1531 continue; 1481 continue;
1532 1482
1533 rix = rates[i].idx; 1483 rix = rates[i].idx;
1534
1535 series[i].Rate = rt->info[rix].ratecode |
1536 (bf_isshpreamble(bf) ? rt->info[rix].short_preamble : 0);
1537
1538 series[i].Tries = rates[i].count; 1484 series[i].Tries = rates[i].count;
1485 series[i].ChSel = sc->sc_tx_chainmask;
1539 1486
1540 series[i].RateFlags = ( 1487 if (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
1541 (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) ? 1488 series[i].Rate = rt->info[rix].ratecode |
1542 ATH9K_RATESERIES_RTS_CTS : 0) | 1489 rt->info[rix].short_preamble;
1543 ((rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1490 else
1544 ATH9K_RATESERIES_2040 : 0) | 1491 series[i].Rate = rt->info[rix].ratecode;
1545 ((rates[i].flags & IEEE80211_TX_RC_SHORT_GI) ? 1492
1546 ATH9K_RATESERIES_HALFGI : 0); 1493 if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS)
1494 series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
1495 if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
1496 series[i].RateFlags |= ATH9K_RATESERIES_2040;
1497 if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI)
1498 series[i].RateFlags |= ATH9K_RATESERIES_HALFGI;
1547 1499
1548 series[i].PktDuration = ath_pkt_duration(sc, rix, bf, 1500 series[i].PktDuration = ath_pkt_duration(sc, rix, bf,
1549 (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) != 0, 1501 (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) != 0,
1550 (rates[i].flags & IEEE80211_TX_RC_SHORT_GI), 1502 (rates[i].flags & IEEE80211_TX_RC_SHORT_GI),
1551 bf_isshpreamble(bf)); 1503 (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE));
1552
1553 series[i].ChSel = sc->sc_tx_chainmask;
1554
1555 if (rtsctsena)
1556 series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
1557 } 1504 }
1558 1505
1559 /* set dur_update_en for l-sig computation except for PS-Poll frames */ 1506 /* set dur_update_en for l-sig computation except for PS-Poll frames */
1560 ath9k_hw_set11n_ratescenario(ah, ds, lastds, !bf_ispspoll(bf), 1507 ath9k_hw_set11n_ratescenario(sc->sc_ah, bf->bf_desc,
1561 ctsrate, ctsduration, 1508 bf->bf_lastbf->bf_desc,
1562 series, 4, flags); 1509 !bf_ispspoll(bf), ctsrate,
1510 0, series, 4, flags);
1563 1511
1564 if (sc->sc_config.ath_aggr_prot && flags) 1512 if (sc->sc_config.ath_aggr_prot && flags)
1565 ath9k_hw_set11n_burstduration(ah, ds, 8192); 1513 ath9k_hw_set11n_burstduration(sc->sc_ah, bf->bf_desc, 8192);
1566} 1514}
1567 1515
1568static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf, 1516static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
@@ -1592,8 +1540,6 @@ static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
1592 bf->bf_state.bf_type |= BUF_BAR; 1540 bf->bf_state.bf_type |= BUF_BAR;
1593 if (ieee80211_is_pspoll(fc)) 1541 if (ieee80211_is_pspoll(fc))
1594 bf->bf_state.bf_type |= BUF_PSPOLL; 1542 bf->bf_state.bf_type |= BUF_PSPOLL;
1595 if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
1596 bf->bf_state.bf_type |= BUF_SHORT_PREAMBLE;
1597 if ((conf_is_ht(&sc->hw->conf) && !is_pae(skb) && 1543 if ((conf_is_ht(&sc->hw->conf) && !is_pae(skb) &&
1598 (tx_info->flags & IEEE80211_TX_CTL_AMPDU))) 1544 (tx_info->flags & IEEE80211_TX_CTL_AMPDU)))
1599 bf->bf_state.bf_type |= BUF_HT; 1545 bf->bf_state.bf_type |= BUF_HT;
diff --git a/drivers/net/wireless/b43/Makefile b/drivers/net/wireless/b43/Makefile
index 14a02b3aea53..281ef8310350 100644
--- a/drivers/net/wireless/b43/Makefile
+++ b/drivers/net/wireless/b43/Makefile
@@ -6,6 +6,7 @@ b43-y += phy_g.o
6b43-y += phy_a.o 6b43-y += phy_a.o
7b43-$(CONFIG_B43_NPHY) += phy_n.o 7b43-$(CONFIG_B43_NPHY) += phy_n.o
8b43-$(CONFIG_B43_PHY_LP) += phy_lp.o 8b43-$(CONFIG_B43_PHY_LP) += phy_lp.o
9b43-$(CONFIG_B43_PHY_LP) += tables_lpphy.o
9b43-y += sysfs.o 10b43-y += sysfs.o
10b43-y += xmit.o 11b43-y += xmit.o
11b43-y += lo.o 12b43-y += lo.o
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
index c5d9dc3667c0..94d9e8b215e3 100644
--- a/drivers/net/wireless/b43/phy_lp.c
+++ b/drivers/net/wireless/b43/phy_lp.c
@@ -3,7 +3,7 @@
3 Broadcom B43 wireless driver 3 Broadcom B43 wireless driver
4 IEEE 802.11g LP-PHY driver 4 IEEE 802.11g LP-PHY driver
5 5
6 Copyright (c) 2008 Michael Buesch <mb@bu3sch.de> 6 Copyright (c) 2008-2009 Michael Buesch <mb@bu3sch.de>
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
@@ -25,6 +25,7 @@
25#include "b43.h" 25#include "b43.h"
26#include "phy_lp.h" 26#include "phy_lp.h"
27#include "phy_common.h" 27#include "phy_common.h"
28#include "tables_lpphy.h"
28 29
29 30
30static int b43_lpphy_op_allocate(struct b43_wldev *dev) 31static int b43_lpphy_op_allocate(struct b43_wldev *dev)
@@ -57,8 +58,221 @@ static void b43_lpphy_op_free(struct b43_wldev *dev)
57 dev->phy.lp = NULL; 58 dev->phy.lp = NULL;
58} 59}
59 60
61static void lpphy_table_init(struct b43_wldev *dev)
62{
63 //TODO
64}
65
66static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev)
67{
68 B43_WARN_ON(1);//TODO rev < 2 not supported, yet.
69}
70
71static void lpphy_baseband_rev2plus_init(struct b43_wldev *dev)
72{
73 struct ssb_bus *bus = dev->dev->bus;
74 struct b43_phy_lp *lpphy = dev->phy.lp;
75
76 b43_phy_write(dev, B43_LPPHY_AFE_DAC_CTL, 0x50);
77 b43_phy_write(dev, B43_LPPHY_AFE_CTL, 0x8800);
78 b43_phy_write(dev, B43_LPPHY_AFE_CTL_OVR, 0);
79 b43_phy_write(dev, B43_LPPHY_AFE_CTL_OVRVAL, 0);
80 b43_phy_write(dev, B43_LPPHY_RF_OVERRIDE_0, 0);
81 b43_phy_write(dev, B43_LPPHY_RF_OVERRIDE_2, 0);
82 b43_phy_write(dev, B43_PHY_OFDM(0xF9), 0);
83 b43_phy_write(dev, B43_LPPHY_TR_LOOKUP_1, 0);
84 b43_phy_set(dev, B43_LPPHY_ADC_COMPENSATION_CTL, 0x10);
85 b43_phy_maskset(dev, B43_LPPHY_OFDMSYNCTHRESH0, 0xFF00, 0x78);
86 b43_phy_maskset(dev, B43_LPPHY_DCOFFSETTRANSIENT, 0xF8FF, 0x200);
87 b43_phy_maskset(dev, B43_LPPHY_DCOFFSETTRANSIENT, 0xFF00, 0x7F);
88 b43_phy_maskset(dev, B43_LPPHY_GAINDIRECTMISMATCH, 0xFF0F, 0x40);
89 b43_phy_maskset(dev, B43_LPPHY_PREAMBLECONFIRMTO, 0xFF00, 0x2);
90 b43_phy_mask(dev, B43_LPPHY_CRSGAIN_CTL, ~0x4000);
91 b43_phy_mask(dev, B43_LPPHY_CRSGAIN_CTL, ~0x2000);
92 b43_phy_set(dev, B43_PHY_OFDM(0x10A), 0x1);
93 b43_phy_maskset(dev, B43_PHY_OFDM(0x10A), 0xFF01, 0x10);
94 b43_phy_maskset(dev, B43_PHY_OFDM(0xDF), 0xFF00, 0xF4);
95 b43_phy_maskset(dev, B43_PHY_OFDM(0xDF), 0x00FF, 0xF100);
96 b43_phy_write(dev, B43_LPPHY_CLIPTHRESH, 0x48);
97 b43_phy_maskset(dev, B43_LPPHY_HIGAINDB, 0xFF00, 0x46);
98 b43_phy_maskset(dev, B43_PHY_OFDM(0xE4), 0xFF00, 0x10);
99 b43_phy_maskset(dev, B43_LPPHY_PWR_THRESH1, 0xFFF0, 0x9);
100 b43_phy_mask(dev, B43_LPPHY_GAINDIRECTMISMATCH, ~0xF);
101 b43_phy_maskset(dev, B43_LPPHY_VERYLOWGAINDB, 0x00FF, 0x5500);
102 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xF81F, 0xA0);
103 b43_phy_maskset(dev, B43_LPPHY_GAINDIRECTMISMATCH, 0xE0FF, 0x300);
104 b43_phy_maskset(dev, B43_LPPHY_HIGAINDB, 0x00FF, 0x2A00);
105 if ((bus->chip_id == 0x4325) && (bus->chip_rev == 0)) {
106 b43_phy_maskset(dev, B43_LPPHY_LOWGAINDB, 0x00FF, 0x2100);
107 b43_phy_maskset(dev, B43_LPPHY_VERYLOWGAINDB, 0xFF00, 0xA);
108 } else {
109 b43_phy_maskset(dev, B43_LPPHY_LOWGAINDB, 0x00FF, 0x1E00);
110 b43_phy_maskset(dev, B43_LPPHY_VERYLOWGAINDB, 0xFF00, 0xD);
111 }
112 b43_phy_maskset(dev, B43_PHY_OFDM(0xFE), 0xFFE0, 0x1F);
113 b43_phy_maskset(dev, B43_PHY_OFDM(0xFF), 0xFFE0, 0xC);
114 b43_phy_maskset(dev, B43_PHY_OFDM(0x100), 0xFF00, 0x19);
115 b43_phy_maskset(dev, B43_PHY_OFDM(0xFF), 0x03FF, 0x3C00);
116 b43_phy_maskset(dev, B43_PHY_OFDM(0xFE), 0xFC1F, 0x3E0);
117 b43_phy_maskset(dev, B43_PHY_OFDM(0xFF), 0xFFE0, 0xC);
118 b43_phy_maskset(dev, B43_PHY_OFDM(0x100), 0x00FF, 0x1900);
119 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0x83FF, 0x5800);
120 b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFFE0, 0x12);
121 b43_phy_maskset(dev, B43_LPPHY_GAINMISMATCH, 0x0FFF, 0x9000);
122
123 b43_lptab_write(dev, B43_LPTAB16(0x08, 0x14), 0);
124 b43_lptab_write(dev, B43_LPTAB16(0x08, 0x12), 0x40);
125
126 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
127 b43_phy_set(dev, B43_LPPHY_CRSGAIN_CTL, 0x40);
128 b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xF0FF, 0xB00);
129 b43_phy_maskset(dev, B43_LPPHY_SYNCPEAKCNT, 0xFFF8, 0x6);
130 b43_phy_maskset(dev, B43_LPPHY_MINPWR_LEVEL, 0x00FF, 0x9D00);
131 b43_phy_maskset(dev, B43_LPPHY_MINPWR_LEVEL, 0xFF00, 0xA1);
132 } else /* 5GHz */
133 b43_phy_mask(dev, B43_LPPHY_CRSGAIN_CTL, ~0x40);
134
135 b43_phy_maskset(dev, B43_LPPHY_CRS_ED_THRESH, 0xFF00, 0xB3);
136 b43_phy_maskset(dev, B43_LPPHY_CRS_ED_THRESH, 0x00FF, 0xAD00);
137 b43_phy_maskset(dev, B43_LPPHY_INPUT_PWRDB, 0xFF00, lpphy->rx_pwr_offset);
138 b43_phy_set(dev, B43_LPPHY_RESET_CTL, 0x44);
139 b43_phy_write(dev, B43_LPPHY_RESET_CTL, 0x80);
140 b43_phy_write(dev, B43_LPPHY_AFE_RSSI_CTL_0, 0xA954);
141 b43_phy_write(dev, B43_LPPHY_AFE_RSSI_CTL_1,
142 0x2000 | ((u16)lpphy->rssi_gs << 10) |
143 ((u16)lpphy->rssi_vc << 4) | lpphy->rssi_vf);
144}
145
146static void lpphy_baseband_init(struct b43_wldev *dev)
147{
148 lpphy_table_init(dev);
149 if (dev->phy.rev >= 2)
150 lpphy_baseband_rev2plus_init(dev);
151 else
152 lpphy_baseband_rev0_1_init(dev);
153}
154
155struct b2062_freqdata {
156 u16 freq;
157 u8 data[6];
158};
159
160/* Initialize the 2062 radio. */
161static void lpphy_2062_init(struct b43_wldev *dev)
162{
163 struct ssb_bus *bus = dev->dev->bus;
164 u32 crystalfreq, pdiv, tmp, ref;
165 unsigned int i;
166 const struct b2062_freqdata *fd = NULL;
167
168 static const struct b2062_freqdata freqdata_tab[] = {
169 { .freq = 12000, .data[0] = 6, .data[1] = 6, .data[2] = 6,
170 .data[3] = 6, .data[4] = 10, .data[5] = 6, },
171 { .freq = 13000, .data[0] = 4, .data[1] = 4, .data[2] = 4,
172 .data[3] = 4, .data[4] = 11, .data[5] = 7, },
173 { .freq = 14400, .data[0] = 3, .data[1] = 3, .data[2] = 3,
174 .data[3] = 3, .data[4] = 12, .data[5] = 7, },
175 { .freq = 16200, .data[0] = 3, .data[1] = 3, .data[2] = 3,
176 .data[3] = 3, .data[4] = 13, .data[5] = 8, },
177 { .freq = 18000, .data[0] = 2, .data[1] = 2, .data[2] = 2,
178 .data[3] = 2, .data[4] = 14, .data[5] = 8, },
179 { .freq = 19200, .data[0] = 1, .data[1] = 1, .data[2] = 1,
180 .data[3] = 1, .data[4] = 14, .data[5] = 9, },
181 };
182
183 b2062_upload_init_table(dev);
184
185 b43_radio_write(dev, B2062_N_TX_CTL3, 0);
186 b43_radio_write(dev, B2062_N_TX_CTL4, 0);
187 b43_radio_write(dev, B2062_N_TX_CTL5, 0);
188 b43_radio_write(dev, B2062_N_PDN_CTL0, 0x40);
189 b43_radio_write(dev, B2062_N_PDN_CTL0, 0);
190 b43_radio_write(dev, B2062_N_CALIB_TS, 0x10);
191 b43_radio_write(dev, B2062_N_CALIB_TS, 0);
192 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
193 b43_radio_set(dev, B2062_N_TSSI_CTL0, 0x1);
194 else
195 b43_radio_mask(dev, B2062_N_TSSI_CTL0, ~0x1);
196
197 /* Get the crystal freq, in Hz. */
198 crystalfreq = bus->chipco.pmu.crystalfreq * 1000;
199
200 B43_WARN_ON(!(bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU));
201 B43_WARN_ON(crystalfreq == 0);
202
203 if (crystalfreq >= 30000000) {
204 pdiv = 1;
205 b43_radio_mask(dev, B2062_S_RFPLL_CTL1, 0xFFFB);
206 } else {
207 pdiv = 2;
208 b43_radio_set(dev, B2062_S_RFPLL_CTL1, 0x4);
209 }
210
211 tmp = (800000000 * pdiv + crystalfreq) / (32000000 * pdiv);
212 tmp = (tmp - 1) & 0xFF;
213 b43_radio_write(dev, B2062_S_RFPLL_CTL18, tmp);
214
215 tmp = (2 * crystalfreq + 1000000 * pdiv) / (2000000 * pdiv);
216 tmp = ((tmp & 0xFF) - 1) & 0xFFFF;
217 b43_radio_write(dev, B2062_S_RFPLL_CTL19, tmp);
218
219 ref = (1000 * pdiv + 2 * crystalfreq) / (2000 * pdiv);
220 ref &= 0xFFFF;
221 for (i = 0; i < ARRAY_SIZE(freqdata_tab); i++) {
222 if (ref < freqdata_tab[i].freq) {
223 fd = &freqdata_tab[i];
224 break;
225 }
226 }
227 if (!fd)
228 fd = &freqdata_tab[ARRAY_SIZE(freqdata_tab) - 1];
229 b43dbg(dev->wl, "b2062: Using crystal tab entry %u kHz.\n",
230 fd->freq); /* FIXME: Keep this printk until the code is fully debugged. */
231
232 b43_radio_write(dev, B2062_S_RFPLL_CTL8,
233 ((u16)(fd->data[1]) << 4) | fd->data[0]);
234 b43_radio_write(dev, B2062_S_RFPLL_CTL9,
235 ((u16)(fd->data[3]) << 4) | fd->data[2]);
236 b43_radio_write(dev, B2062_S_RFPLL_CTL10, fd->data[4]);
237 b43_radio_write(dev, B2062_S_RFPLL_CTL11, fd->data[5]);
238}
239
240/* Initialize the 2063 radio. */
241static void lpphy_2063_init(struct b43_wldev *dev)
242{
243 //TODO
244}
245
246static void lpphy_sync_stx(struct b43_wldev *dev)
247{
248 //TODO
249}
250
251static void lpphy_radio_init(struct b43_wldev *dev)
252{
253 /* The radio is attached through the 4wire bus. */
254 b43_phy_set(dev, B43_LPPHY_FOURWIRE_CTL, 0x2);
255 udelay(1);
256 b43_phy_mask(dev, B43_LPPHY_FOURWIRE_CTL, 0xFFFD);
257 udelay(1);
258
259 if (dev->phy.rev < 2) {
260 lpphy_2062_init(dev);
261 } else {
262 lpphy_2063_init(dev);
263 lpphy_sync_stx(dev);
264 b43_phy_write(dev, B43_PHY_OFDM(0xF0), 0x5F80);
265 b43_phy_write(dev, B43_PHY_OFDM(0xF1), 0);
266 //TODO Do something on the backplane
267 }
268}
269
60static int b43_lpphy_op_init(struct b43_wldev *dev) 270static int b43_lpphy_op_init(struct b43_wldev *dev)
61{ 271{
272 /* TODO: band SPROM */
273 lpphy_baseband_init(dev);
274 lpphy_radio_init(dev);
275
62 //TODO 276 //TODO
63 277
64 return 0; 278 return 0;
@@ -115,7 +329,9 @@ static int b43_lpphy_op_switch_channel(struct b43_wldev *dev,
115 329
116static unsigned int b43_lpphy_op_get_default_chan(struct b43_wldev *dev) 330static unsigned int b43_lpphy_op_get_default_chan(struct b43_wldev *dev)
117{ 331{
118 return 1; /* Default to channel 1 */ 332 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
333 return 1;
334 return 36;
119} 335}
120 336
121static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) 337static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
diff --git a/drivers/net/wireless/b43/phy_lp.h b/drivers/net/wireless/b43/phy_lp.h
index b0b5357abf93..80703c58102e 100644
--- a/drivers/net/wireless/b43/phy_lp.h
+++ b/drivers/net/wireless/b43/phy_lp.h
@@ -4,8 +4,281 @@
4/* Definitions for the LP-PHY */ 4/* Definitions for the LP-PHY */
5 5
6 6
7/* The CCK PHY register range. */
8#define B43_LPPHY_B_VERSION B43_PHY_CCK(0x00) /* B PHY version */
9#define B43_LPPHY_B_BBCONFIG B43_PHY_CCK(0x01) /* B PHY BBConfig */
10#define B43_LPPHY_B_RX_STAT0 B43_PHY_CCK(0x04) /* B PHY RX Status0 */
11#define B43_LPPHY_B_RX_STAT1 B43_PHY_CCK(0x05) /* B PHY RX Status1 */
12#define B43_LPPHY_B_CRS_THRESH B43_PHY_CCK(0x06) /* B PHY CRS Thresh */
13#define B43_LPPHY_B_TXERROR B43_PHY_CCK(0x07) /* B PHY TxError */
14#define B43_LPPHY_B_CHANNEL B43_PHY_CCK(0x08) /* B PHY Channel */
15#define B43_LPPHY_B_WORKAROUND B43_PHY_CCK(0x09) /* B PHY workaround */
16#define B43_LPPHY_B_TEST B43_PHY_CCK(0x0A) /* B PHY Test */
17#define B43_LPPHY_B_FOURWIRE_ADDR B43_PHY_CCK(0x0B) /* B PHY Fourwire Address */
18#define B43_LPPHY_B_FOURWIRE_DATA_HI B43_PHY_CCK(0x0C) /* B PHY Fourwire Data Hi */
19#define B43_LPPHY_B_FOURWIRE_DATA_LO B43_PHY_CCK(0x0D) /* B PHY Fourwire Data Lo */
20#define B43_LPPHY_B_BIST_STAT B43_PHY_CCK(0x0E) /* B PHY Bist Status */
21#define B43_LPPHY_PA_RAMP_TX_TO B43_PHY_CCK(0x10) /* PA Ramp TX Timeout */
22#define B43_LPPHY_RF_SYNTH_DC_TIMER B43_PHY_CCK(0x11) /* RF Synth DC Timer */
23#define B43_LPPHY_PA_RAMP_TX_TIME_IN B43_PHY_CCK(0x12) /* PA ramp TX Time in */
24#define B43_LPPHY_RX_FILTER_TIME_IN B43_PHY_CCK(0x13) /* RX Filter Time in */
25#define B43_LPPHY_PLL_COEFF_S B43_PHY_CCK(0x18) /* PLL Coefficient(s) */
26#define B43_LPPHY_PLL_OUT B43_PHY_CCK(0x19) /* PLL Out */
27#define B43_LPPHY_RSSI_THRES B43_PHY_CCK(0x20) /* RSSI Threshold */
28#define B43_LPPHY_IQ_THRES_HH B43_PHY_CCK(0x21) /* IQ Threshold HH */
29#define B43_LPPHY_IQ_THRES_H B43_PHY_CCK(0x22) /* IQ Threshold H */
30#define B43_LPPHY_IQ_THRES_L B43_PHY_CCK(0x23) /* IQ Threshold L */
31#define B43_LPPHY_IQ_THRES_LL B43_PHY_CCK(0x24) /* IQ Threshold LL */
32#define B43_LPPHY_AGC_GAIN B43_PHY_CCK(0x25) /* AGC Gain */
33#define B43_LPPHY_LNA_GAIN_RANGE B43_PHY_CCK(0x26) /* LNA Gain Range */
34#define B43_LPPHY_JSSI B43_PHY_CCK(0x27) /* JSSI */
35#define B43_LPPHY_TSSI_CTL B43_PHY_CCK(0x28) /* TSSI Control */
36#define B43_LPPHY_TSSI B43_PHY_CCK(0x29) /* TSSI */
37#define B43_LPPHY_TR_LOSS B43_PHY_CCK(0x2A) /* TR Loss */
38#define B43_LPPHY_LO_LEAKAGE B43_PHY_CCK(0x2B) /* LO Leakage */
39#define B43_LPPHY_LO_RSSIACC B43_PHY_CCK(0x2C) /* LO RSSIAcc */
40#define B43_LPPHY_LO_IQ_MAG_ACC B43_PHY_CCK(0x2D) /* LO IQ Mag Acc */
41#define B43_LPPHY_TX_DCOFFSET1 B43_PHY_CCK(0x2E) /* TX DCOffset1 */
42#define B43_LPPHY_TX_DCOFFSET2 B43_PHY_CCK(0x2F) /* TX DCOffset2 */
43#define B43_LPPHY_SYNCPEAKCNT B43_PHY_CCK(0x30) /* SyncPeakCnt */
44#define B43_LPPHY_SYNCFREQ B43_PHY_CCK(0x31) /* SyncFreq */
45#define B43_LPPHY_SYNCDIVERSITYCTL B43_PHY_CCK(0x32) /* SyncDiversityControl */
46#define B43_LPPHY_PEAKENERGYL B43_PHY_CCK(0x33) /* PeakEnergyL */
47#define B43_LPPHY_PEAKENERGYH B43_PHY_CCK(0x34) /* PeakEnergyH */
48#define B43_LPPHY_SYNCCTL B43_PHY_CCK(0x35) /* SyncControl */
49#define B43_LPPHY_DSSSSTEP B43_PHY_CCK(0x38) /* DsssStep */
50#define B43_LPPHY_DSSSWARMUP B43_PHY_CCK(0x39) /* DsssWarmup */
51#define B43_LPPHY_DSSSSIGPOW B43_PHY_CCK(0x3D) /* DsssSigPow */
52#define B43_LPPHY_SFDDETECTBLOCKTIME B43_PHY_CCK(0x40) /* SfdDetectBlockTIme */
53#define B43_LPPHY_SFDTO B43_PHY_CCK(0x41) /* SFDTimeOut */
54#define B43_LPPHY_SFDCTL B43_PHY_CCK(0x42) /* SFDControl */
55#define B43_LPPHY_RXDBG B43_PHY_CCK(0x43) /* rxDebug */
56#define B43_LPPHY_RX_DELAYCOMP B43_PHY_CCK(0x44) /* RX DelayComp */
57#define B43_LPPHY_CRSDROPOUTTO B43_PHY_CCK(0x45) /* CRSDropoutTimeout */
58#define B43_LPPHY_PSEUDOSHORTTO B43_PHY_CCK(0x46) /* PseudoShortTimeout */
59#define B43_LPPHY_PR3931 B43_PHY_CCK(0x47) /* PR3931 */
60#define B43_LPPHY_DSSSCOEFF1 B43_PHY_CCK(0x48) /* DSSSCoeff1 */
61#define B43_LPPHY_DSSSCOEFF2 B43_PHY_CCK(0x49) /* DSSSCoeff2 */
62#define B43_LPPHY_CCKCOEFF1 B43_PHY_CCK(0x4A) /* CCKCoeff1 */
63#define B43_LPPHY_CCKCOEFF2 B43_PHY_CCK(0x4B) /* CCKCoeff2 */
64#define B43_LPPHY_TRCORR B43_PHY_CCK(0x4C) /* TRCorr */
65#define B43_LPPHY_ANGLESCALE B43_PHY_CCK(0x4D) /* AngleScale */
66#define B43_LPPHY_OPTIONALMODES2 B43_PHY_CCK(0x4F) /* OptionalModes2 */
67#define B43_LPPHY_CCKLMSSTEPSIZE B43_PHY_CCK(0x50) /* CCKLMSStepSize */
68#define B43_LPPHY_DFEBYPASS B43_PHY_CCK(0x51) /* DFEBypass */
69#define B43_LPPHY_CCKSTARTDELAYLONG B43_PHY_CCK(0x52) /* CCKStartDelayLong */
70#define B43_LPPHY_CCKSTARTDELAYSHORT B43_PHY_CCK(0x53) /* CCKStartDelayShort */
71#define B43_LPPHY_PPROCCHDELAY B43_PHY_CCK(0x54) /* PprocChDelay */
72#define B43_LPPHY_PPROCONOFF B43_PHY_CCK(0x55) /* PProcOnOff */
73#define B43_LPPHY_LNAGAINTWOBIT10 B43_PHY_CCK(0x5B) /* LNAGainTwoBit10 */
74#define B43_LPPHY_LNAGAINTWOBIT32 B43_PHY_CCK(0x5C) /* LNAGainTwoBit32 */
75#define B43_LPPHY_OPTIONALMODES B43_PHY_CCK(0x5D) /* OptionalModes */
76#define B43_LPPHY_B_RX_STAT2 B43_PHY_CCK(0x5E) /* B PHY RX Status2 */
77#define B43_LPPHY_B_RX_STAT3 B43_PHY_CCK(0x5F) /* B PHY RX Status3 */
78#define B43_LPPHY_PWDNDACDELAY B43_PHY_CCK(0x63) /* pwdnDacDelay */
79#define B43_LPPHY_FINEDIGIGAIN_CTL B43_PHY_CCK(0x67) /* FineDigiGain Control */
80#define B43_LPPHY_LG2GAINTBLLNA8 B43_PHY_CCK(0x68) /* Lg2GainTblLNA8 */
81#define B43_LPPHY_LG2GAINTBLLNA28 B43_PHY_CCK(0x69) /* Lg2GainTblLNA28 */
82#define B43_LPPHY_GAINTBLLNATRSW B43_PHY_CCK(0x6A) /* GainTblLNATrSw */
83#define B43_LPPHY_PEAKENERGY B43_PHY_CCK(0x6B) /* PeakEnergy */
84#define B43_LPPHY_LG2INITGAIN B43_PHY_CCK(0x6C) /* lg2InitGain */
85#define B43_LPPHY_BLANKCOUNTLNAPGA B43_PHY_CCK(0x6D) /* BlankCountLnaPga */
86#define B43_LPPHY_LNAGAINTWOBIT54 B43_PHY_CCK(0x6E) /* LNAGainTwoBit54 */
87#define B43_LPPHY_LNAGAINTWOBIT76 B43_PHY_CCK(0x6F) /* LNAGainTwoBit76 */
88#define B43_LPPHY_JSSICTL B43_PHY_CCK(0x70) /* JSSIControl */
89#define B43_LPPHY_LG2GAINTBLLNA44 B43_PHY_CCK(0x71) /* Lg2GainTblLNA44 */
90#define B43_LPPHY_LG2GAINTBLLNA62 B43_PHY_CCK(0x72) /* Lg2GainTblLNA62 */
7 91
92/* The OFDM PHY register range. */
93#define B43_LPPHY_VERSION B43_PHY_OFDM(0x00) /* Version */
94#define B43_LPPHY_BBCONFIG B43_PHY_OFDM(0x01) /* BBConfig */
95#define B43_LPPHY_RX_STAT0 B43_PHY_OFDM(0x04) /* RX Status0 */
96#define B43_LPPHY_RX_STAT1 B43_PHY_OFDM(0x05) /* RX Status1 */
97#define B43_LPPHY_TX_ERROR B43_PHY_OFDM(0x07) /* TX Error */
98#define B43_LPPHY_CHANNEL B43_PHY_OFDM(0x08) /* Channel */
99#define B43_LPPHY_WORKAROUND B43_PHY_OFDM(0x09) /* workaround */
100#define B43_LPPHY_FOURWIRE_ADDR B43_PHY_OFDM(0x0B) /* Fourwire Address */
101#define B43_LPPHY_FOURWIREDATAHI B43_PHY_OFDM(0x0C) /* FourwireDataHi */
102#define B43_LPPHY_FOURWIREDATALO B43_PHY_OFDM(0x0D) /* FourwireDataLo */
103#define B43_LPPHY_BISTSTAT0 B43_PHY_OFDM(0x0E) /* BistStatus0 */
104#define B43_LPPHY_BISTSTAT1 B43_PHY_OFDM(0x0F) /* BistStatus1 */
105#define B43_LPPHY_CRSGAIN_CTL B43_PHY_OFDM(0x10) /* crsgain Control */
106#define B43_LPPHY_OFDMPWR_THRESH0 B43_PHY_OFDM(0x11) /* ofdmPower Thresh0 */
107#define B43_LPPHY_OFDMPWR_THRESH1 B43_PHY_OFDM(0x12) /* ofdmPower Thresh1 */
108#define B43_LPPHY_OFDMPWR_THRESH2 B43_PHY_OFDM(0x13) /* ofdmPower Thresh2 */
109#define B43_LPPHY_DSSSPWR_THRESH0 B43_PHY_OFDM(0x14) /* dsssPower Thresh0 */
110#define B43_LPPHY_DSSSPWR_THRESH1 B43_PHY_OFDM(0x15) /* dsssPower Thresh1 */
111#define B43_LPPHY_MINPWR_LEVEL B43_PHY_OFDM(0x16) /* MinPower Level */
112#define B43_LPPHY_OFDMSYNCTHRESH0 B43_PHY_OFDM(0x17) /* ofdmSyncThresh0 */
113#define B43_LPPHY_OFDMSYNCTHRESH1 B43_PHY_OFDM(0x18) /* ofdmSyncThresh1 */
114#define B43_LPPHY_FINEFREQEST B43_PHY_OFDM(0x19) /* FineFreqEst */
115#define B43_LPPHY_IDLEAFTERPKTRXTO B43_PHY_OFDM(0x1A) /* IDLEafterPktRXTimeout */
116#define B43_LPPHY_LTRN_CTL B43_PHY_OFDM(0x1B) /* LTRN Control */
117#define B43_LPPHY_DCOFFSETTRANSIENT B43_PHY_OFDM(0x1C) /* DCOffsetTransient */
118#define B43_LPPHY_PREAMBLEINTO B43_PHY_OFDM(0x1D) /* PreambleInTimeout */
119#define B43_LPPHY_PREAMBLECONFIRMTO B43_PHY_OFDM(0x1E) /* PreambleConfirmTimeout */
120#define B43_LPPHY_CLIPTHRESH B43_PHY_OFDM(0x1F) /* ClipThresh */
121#define B43_LPPHY_CLIPCTRTHRESH B43_PHY_OFDM(0x20) /* ClipCtrThresh */
122#define B43_LPPHY_OFDMSYNCTIMER_CTL B43_PHY_OFDM(0x21) /* ofdmSyncTimer Control */
123#define B43_LPPHY_WAITFORPHYSELTO B43_PHY_OFDM(0x22) /* WaitforPHYSelTimeout */
124#define B43_LPPHY_HIGAINDB B43_PHY_OFDM(0x23) /* HiGainDB */
125#define B43_LPPHY_LOWGAINDB B43_PHY_OFDM(0x24) /* LowGainDB */
126#define B43_LPPHY_VERYLOWGAINDB B43_PHY_OFDM(0x25) /* VeryLowGainDB */
127#define B43_LPPHY_GAINMISMATCH B43_PHY_OFDM(0x26) /* gainMismatch */
128#define B43_LPPHY_GAINDIRECTMISMATCH B43_PHY_OFDM(0x27) /* gaindirectMismatch */
129#define B43_LPPHY_PWR_THRESH0 B43_PHY_OFDM(0x28) /* Power Thresh0 */
130#define B43_LPPHY_PWR_THRESH1 B43_PHY_OFDM(0x29) /* Power Thresh1 */
131#define B43_LPPHY_DETECTOR_DELAY_ADJUST B43_PHY_OFDM(0x2A) /* Detector Delay Adjust */
132#define B43_LPPHY_REDUCED_DETECTOR_DELAY B43_PHY_OFDM(0x2B) /* Reduced Detector Delay */
133#define B43_LPPHY_DATA_TO B43_PHY_OFDM(0x2C) /* data Timeout */
134#define B43_LPPHY_CORRELATOR_DIS_DELAY B43_PHY_OFDM(0x2D) /* correlator Dis Delay */
135#define B43_LPPHY_DIVERSITY_GAINBACK B43_PHY_OFDM(0x2E) /* Diversity GainBack */
136#define B43_LPPHY_DSSS_CONFIRM_CNT B43_PHY_OFDM(0x2F) /* DSSS Confirm Cnt */
137#define B43_LPPHY_DC_BLANK_INT B43_PHY_OFDM(0x30) /* DC Blank Interval */
138#define B43_LPPHY_GAIN_MISMATCH_LIMIT B43_PHY_OFDM(0x31) /* gain Mismatch Limit */
139#define B43_LPPHY_CRS_ED_THRESH B43_PHY_OFDM(0x32) /* crs ed thresh */
140#define B43_LPPHY_PHASE_SHIFT_CTL B43_PHY_OFDM(0x33) /* phase shift Control */
141#define B43_LPPHY_INPUT_PWRDB B43_PHY_OFDM(0x34) /* Input PowerDB */
142#define B43_LPPHY_OFDM_SYNC_CTL B43_PHY_OFDM(0x35) /* ofdm sync Control */
143#define B43_LPPHY_AFE_ADC_CTL_0 B43_PHY_OFDM(0x36) /* Afe ADC Control 0 */
144#define B43_LPPHY_AFE_ADC_CTL_1 B43_PHY_OFDM(0x37) /* Afe ADC Control 1 */
145#define B43_LPPHY_AFE_ADC_CTL_2 B43_PHY_OFDM(0x38) /* Afe ADC Control 2 */
146#define B43_LPPHY_AFE_DAC_CTL B43_PHY_OFDM(0x39) /* Afe DAC Control */
147#define B43_LPPHY_AFE_CTL B43_PHY_OFDM(0x3A) /* Afe Control */
148#define B43_LPPHY_AFE_CTL_OVR B43_PHY_OFDM(0x3B) /* Afe Control Ovr */
149#define B43_LPPHY_AFE_CTL_OVRVAL B43_PHY_OFDM(0x3C) /* Afe Control OvrVal */
150#define B43_LPPHY_AFE_RSSI_CTL_0 B43_PHY_OFDM(0x3D) /* Afe RSSI Control 0 */
151#define B43_LPPHY_AFE_RSSI_CTL_1 B43_PHY_OFDM(0x3E) /* Afe RSSI Control 1 */
152#define B43_LPPHY_AFE_RSSI_SEL B43_PHY_OFDM(0x3F) /* Afe RSSI Sel */
153#define B43_LPPHY_RADAR_THRESH B43_PHY_OFDM(0x40) /* Radar Thresh */
154#define B43_LPPHY_RADAR_BLANK_INT B43_PHY_OFDM(0x41) /* Radar blank Interval */
155#define B43_LPPHY_RADAR_MIN_FM_INT B43_PHY_OFDM(0x42) /* Radar min fm Interval */
156#define B43_LPPHY_RADAR_GAIN_TO B43_PHY_OFDM(0x43) /* Radar gain timeout */
157#define B43_LPPHY_RADAR_PULSE_TO B43_PHY_OFDM(0x44) /* Radar pulse timeout */
158#define B43_LPPHY_RADAR_DETECT_FM_CTL B43_PHY_OFDM(0x45) /* Radar detect FM Control */
159#define B43_LPPHY_RADAR_DETECT_EN B43_PHY_OFDM(0x46) /* Radar detect En */
160#define B43_LPPHY_RADAR_RD_DATA_REG B43_PHY_OFDM(0x47) /* Radar Rd Data Reg */
161#define B43_LPPHY_LP_PHY_CTL B43_PHY_OFDM(0x48) /* LP PHY Control */
162#define B43_LPPHY_CLASSIFIER_CTL B43_PHY_OFDM(0x49) /* classifier Control */
163#define B43_LPPHY_RESET_CTL B43_PHY_OFDM(0x4A) /* reset Control */
164#define B43_LPPHY_CLKEN_CTL B43_PHY_OFDM(0x4B) /* ClkEn Control */
165#define B43_LPPHY_RF_OVERRIDE_0 B43_PHY_OFDM(0x4C) /* RF Override 0 */
166#define B43_LPPHY_RF_OVERRIDE_VAL_0 B43_PHY_OFDM(0x4D) /* RF Override Val 0 */
167#define B43_LPPHY_TR_LOOKUP_1 B43_PHY_OFDM(0x4E) /* TR Lookup 1 */
168#define B43_LPPHY_TR_LOOKUP_2 B43_PHY_OFDM(0x4F) /* TR Lookup 2 */
169#define B43_LPPHY_RSSISELLOOKUP1 B43_PHY_OFDM(0x50) /* RssiSelLookup1 */
170#define B43_LPPHY_IQLO_CAL_CMD B43_PHY_OFDM(0x51) /* iqlo Cal Cmd */
171#define B43_LPPHY_IQLO_CAL_CMD_N_NUM B43_PHY_OFDM(0x52) /* iqlo Cal Cmd N num */
172#define B43_LPPHY_IQLO_CAL_CMD_G_CTL B43_PHY_OFDM(0x53) /* iqlo Cal Cmd G control */
173#define B43_LPPHY_MACINT_DBG_REGISTER B43_PHY_OFDM(0x54) /* macint Debug Register */
174#define B43_LPPHY_TABLE_ADDR B43_PHY_OFDM(0x55) /* Table Address */
175#define B43_LPPHY_TABLEDATALO B43_PHY_OFDM(0x56) /* TabledataLo */
176#define B43_LPPHY_TABLEDATAHI B43_PHY_OFDM(0x57) /* TabledataHi */
177#define B43_LPPHY_PHY_CRS_ENABLE_ADDR B43_PHY_OFDM(0x58) /* phy CRS Enable Address */
178#define B43_LPPHY_IDLETIME_CTL B43_PHY_OFDM(0x59) /* Idletime Control */
179#define B43_LPPHY_IDLETIME_CRS_ON_LO B43_PHY_OFDM(0x5A) /* Idletime CRS On Lo */
180#define B43_LPPHY_IDLETIME_CRS_ON_HI B43_PHY_OFDM(0x5B) /* Idletime CRS On Hi */
181#define B43_LPPHY_IDLETIME_MEAS_TIME_LO B43_PHY_OFDM(0x5C) /* Idletime Meas Time Lo */
182#define B43_LPPHY_IDLETIME_MEAS_TIME_HI B43_PHY_OFDM(0x5D) /* Idletime Meas Time Hi */
183#define B43_LPPHY_RESET_LEN_OFDM_TX_ADDR B43_PHY_OFDM(0x5E) /* Reset len Ofdm TX Address */
184#define B43_LPPHY_RESET_LEN_OFDM_RX_ADDR B43_PHY_OFDM(0x5F) /* Reset len Ofdm RX Address */
185#define B43_LPPHY_REG_CRS_ENABLE B43_PHY_OFDM(0x60) /* reg crs enable */
186#define B43_LPPHY_PLCP_TMT_STR0_CTR_MIN B43_PHY_OFDM(0x61) /* PLCP Tmt Str0 Ctr Min */
187#define B43_LPPHY_PKT_FSM_RESET_LEN_VAL B43_PHY_OFDM(0x62) /* Pkt fsm Reset Len Value */
188#define B43_LPPHY_READSYM2RESET_CTL B43_PHY_OFDM(0x63) /* readsym2reset Control */
189#define B43_LPPHY_DC_FILTER_DELAY1 B43_PHY_OFDM(0x64) /* Dc filter delay1 */
190#define B43_LPPHY_PACKET_RX_ACTIVE_TO B43_PHY_OFDM(0x65) /* packet rx Active timeout */
191#define B43_LPPHY_ED_TOVAL B43_PHY_OFDM(0x66) /* ed timeoutValue */
192#define B43_LPPHY_HOLD_CRS_ON_VAL B43_PHY_OFDM(0x67) /* hold CRS On Value */
193#define B43_LPPHY_OFDM_TX_PHY_CRS_DELAY_VAL B43_PHY_OFDM(0x69) /* ofdm tx phy CRS Delay Value */
194#define B43_LPPHY_CCK_TX_PHY_CRS_DELAY_VAL B43_PHY_OFDM(0x6A) /* cck tx phy CRS Delay Value */
195#define B43_LPPHY_ED_ON_CONFIRM_TIMER_VAL B43_PHY_OFDM(0x6B) /* Ed on confirm Timer Value */
196#define B43_LPPHY_ED_OFFSET_CONFIRM_TIMER_VAL B43_PHY_OFDM(0x6C) /* Ed offset confirm Timer Value */
197#define B43_LPPHY_PHY_CRS_OFFSET_TIMER_VAL B43_PHY_OFDM(0x6D) /* phy CRS offset Timer Value */
198#define B43_LPPHY_ADC_COMPENSATION_CTL B43_PHY_OFDM(0x70) /* ADC Compensation Control */
199#define B43_LPPHY_LOG2_RBPSK_ADDR B43_PHY_OFDM(0x71) /* log2 RBPSK Address */
200#define B43_LPPHY_LOG2_RQPSK_ADDR B43_PHY_OFDM(0x72) /* log2 RQPSK Address */
201#define B43_LPPHY_LOG2_R16QAM_ADDR B43_PHY_OFDM(0x73) /* log2 R16QAM Address */
202#define B43_LPPHY_LOG2_R64QAM_ADDR B43_PHY_OFDM(0x74) /* log2 R64QAM Address */
203#define B43_LPPHY_OFFSET_BPSK_ADDR B43_PHY_OFDM(0x75) /* offset BPSK Address */
204#define B43_LPPHY_OFFSET_QPSK_ADDR B43_PHY_OFDM(0x76) /* offset QPSK Address */
205#define B43_LPPHY_OFFSET_16QAM_ADDR B43_PHY_OFDM(0x77) /* offset 16QAM Address */
206#define B43_LPPHY_OFFSET_64QAM_ADDR B43_PHY_OFDM(0x78) /* offset 64QAM Address */
207#define B43_LPPHY_ALPHA1 B43_PHY_OFDM(0x79) /* Alpha1 */
208#define B43_LPPHY_ALPHA2 B43_PHY_OFDM(0x7A) /* Alpha2 */
209#define B43_LPPHY_BETA1 B43_PHY_OFDM(0x7B) /* Beta1 */
210#define B43_LPPHY_BETA2 B43_PHY_OFDM(0x7C) /* Beta2 */
211#define B43_LPPHY_LOOP_NUM_ADDR B43_PHY_OFDM(0x7D) /* Loop Num Address */
212#define B43_LPPHY_STR_COLLMAX_SMPL_ADDR B43_PHY_OFDM(0x7E) /* Str Collmax Sample Address */
213#define B43_LPPHY_MAX_SMPL_COARSE_FINE_ADDR B43_PHY_OFDM(0x7F) /* Max Sample Coarse/Fine Address */
214#define B43_LPPHY_MAX_SMPL_COARSE_STR0CTR_ADDR B43_PHY_OFDM(0x80) /* Max Sample Coarse/Str0Ctr Address */
215#define B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR B43_PHY_OFDM(0x81) /* IQ Enable Wait Time Address */
216#define B43_LPPHY_IQ_NUM_SMPLS_ADDR B43_PHY_OFDM(0x82) /* IQ Num Samples Address */
217#define B43_LPPHY_IQ_ACC_HI_ADDR B43_PHY_OFDM(0x83) /* IQ Acc Hi Address */
218#define B43_LPPHY_IQ_ACC_LO_ADDR B43_PHY_OFDM(0x84) /* IQ Acc Lo Address */
219#define B43_LPPHY_IQ_I_PWR_ACC_HI_ADDR B43_PHY_OFDM(0x85) /* IQ I PWR Acc Hi Address */
220#define B43_LPPHY_IQ_I_PWR_ACC_LO_ADDR B43_PHY_OFDM(0x86) /* IQ I PWR Acc Lo Address */
221#define B43_LPPHY_IQ_Q_PWR_ACC_HI_ADDR B43_PHY_OFDM(0x87) /* IQ Q PWR Acc Hi Address */
222#define B43_LPPHY_IQ_Q_PWR_ACC_LO_ADDR B43_PHY_OFDM(0x88) /* IQ Q PWR Acc Lo Address */
223#define B43_LPPHY_MAXNUMSTEPS B43_PHY_OFDM(0x89) /* MaxNumsteps */
224#define B43_LPPHY_ROTORPHASE_ADDR B43_PHY_OFDM(0x8A) /* RotorPhase Address */
225#define B43_LPPHY_ADVANCEDRETARDROTOR_ADDR B43_PHY_OFDM(0x8B) /* AdvancedRetardRotor Address */
226#define B43_LPPHY_RSSIADCDELAY_CTL_ADDR B43_PHY_OFDM(0x8D) /* rssiAdcdelay Control Address */
227#define B43_LPPHY_TSSISTAT_ADDR B43_PHY_OFDM(0x8E) /* tssiStatus Address */
228#define B43_LPPHY_TEMPSENSESTAT_ADDR B43_PHY_OFDM(0x8F) /* tempsenseStatus Address */
229#define B43_LPPHY_TEMPSENSE_CTL_ADDR B43_PHY_OFDM(0x90) /* tempsense Control Address */
230#define B43_LPPHY_WRSSISTAT_ADDR B43_PHY_OFDM(0x91) /* wrssistatus Address */
231#define B43_LPPHY_MUFACTORADDR B43_PHY_OFDM(0x92) /* mufactoraddr */
232#define B43_LPPHY_SCRAMSTATE_ADDR B43_PHY_OFDM(0x93) /* scramstate Address */
233#define B43_LPPHY_TXHOLDOFFADDR B43_PHY_OFDM(0x94) /* txholdoffaddr */
234#define B43_LPPHY_PKTGAINVAL_ADDR B43_PHY_OFDM(0x95) /* pktgainval Address */
235#define B43_LPPHY_COARSEESTIM_ADDR B43_PHY_OFDM(0x96) /* Coarseestim Address */
236#define B43_LPPHY_STATE_TRANSITION_ADDR B43_PHY_OFDM(0x97) /* state Transition Address */
237#define B43_LPPHY_TRN_OFFSET_ADDR B43_PHY_OFDM(0x98) /* TRN offset Address */
238#define B43_LPPHY_NUM_ROTOR_ADDR B43_PHY_OFDM(0x99) /* Num Rotor Address */
239#define B43_LPPHY_VITERBI_OFFSET_ADDR B43_PHY_OFDM(0x9A) /* Viterbi Offset Address */
240#define B43_LPPHY_SMPL_COLLECT_WAIT_ADDR B43_PHY_OFDM(0x9B) /* Sample collect wait Address */
241#define B43_LPPHY_A_PHY_CTL_ADDR B43_PHY_OFDM(0x9C) /* A PHY Control Address */
242#define B43_LPPHY_NUM_PASS_THROUGH_ADDR B43_PHY_OFDM(0x9D) /* Num Pass Through Address */
243#define B43_LPPHY_RX_COMP_COEFF_S B43_PHY_OFDM(0x9E) /* RX Comp coefficient(s) */
244#define B43_LPPHY_CPAROTATEVAL B43_PHY_OFDM(0x9F) /* cpaRotateValue */
245#define B43_LPPHY_SMPL_PLAY_COUNT B43_PHY_OFDM(0xA0) /* Sample play count */
246#define B43_LPPHY_SMPL_PLAY_BUFFER_CTL B43_PHY_OFDM(0xA1) /* Sample play Buffer Control */
247#define B43_LPPHY_FOURWIRE_CTL B43_PHY_OFDM(0xA2) /* fourwire Control */
248#define B43_LPPHY_CPA_TAILCOUNT_VAL B43_PHY_OFDM(0xA3) /* CPA TailCount Value */
249#define B43_LPPHY_TX_PWR_CTL_CMD B43_PHY_OFDM(0xA4) /* TX Power Control Cmd */
250#define B43_LPPHY_TX_PWR_CTL_NNUM B43_PHY_OFDM(0xA5) /* TX Power Control Nnum */
251#define B43_LPPHY_TX_PWR_CTL_IDLETSSI B43_PHY_OFDM(0xA6) /* TX Power Control IdleTssi */
252#define B43_LPPHY_TX_PWR_CTL_TARGETPWR B43_PHY_OFDM(0xA7) /* TX Power Control TargetPower */
253#define B43_LPPHY_TX_PWR_CTL_DELTAPWR_LIMIT B43_PHY_OFDM(0xA8) /* TX Power Control DeltaPower Limit */
254#define B43_LPPHY_TX_PWR_CTL_BASEINDEX B43_PHY_OFDM(0xA9) /* TX Power Control BaseIndex */
255#define B43_LPPHY_TX_PWR_CTL_PWR_INDEX B43_PHY_OFDM(0xAA) /* TX Power Control Power Index */
256#define B43_LPPHY_TX_PWR_CTL_STAT B43_PHY_OFDM(0xAB) /* TX Power Control Status */
257#define B43_LPPHY_LP_RF_SIGNAL_LUT B43_PHY_OFDM(0xAC) /* LP RF signal LUT */
258#define B43_LPPHY_RX_RADIO_CTL_FILTER_STATE B43_PHY_OFDM(0xAD) /* RX Radio Control Filter State */
259#define B43_LPPHY_RX_RADIO_CTL B43_PHY_OFDM(0xAE) /* RX Radio Control */
260#define B43_LPPHY_NRSSI_STAT_ADDR B43_PHY_OFDM(0xAF) /* NRSSI status Address */
261#define B43_LPPHY_RF_OVERRIDE_2 B43_PHY_OFDM(0xB0) /* RF override 2 */
262#define B43_LPPHY_RF_OVERRIDE_2_VAL B43_PHY_OFDM(0xB1) /* RF override 2 val */
263#define B43_LPPHY_PS_CTL_OVERRIDE_VAL0 B43_PHY_OFDM(0xB2) /* PS Control override val0 */
264#define B43_LPPHY_PS_CTL_OVERRIDE_VAL1 B43_PHY_OFDM(0xB3) /* PS Control override val1 */
265#define B43_LPPHY_PS_CTL_OVERRIDE_VAL2 B43_PHY_OFDM(0xB4) /* PS Control override val2 */
266#define B43_LPPHY_TX_GAIN_CTL_OVERRIDE_VAL B43_PHY_OFDM(0xB5) /* TX gain Control override val */
267#define B43_LPPHY_RX_GAIN_CTL_OVERRIDE_VAL B43_PHY_OFDM(0xB6) /* RX gain Control override val */
268#define B43_LPPHY_AFE_DDFS B43_PHY_OFDM(0xB7) /* AFE DDFS */
269#define B43_LPPHY_AFE_DDFS_POINTER_INIT B43_PHY_OFDM(0xB8) /* AFE DDFS pointer init */
270#define B43_LPPHY_AFE_DDFS_INCR_INIT B43_PHY_OFDM(0xB9) /* AFE DDFS incr init */
271#define B43_LPPHY_MRCNOISEREDUCTION B43_PHY_OFDM(0xBA) /* mrcNoiseReduction */
272#define B43_LPPHY_TRLOOKUP3 B43_PHY_OFDM(0xBB) /* TRLookup3 */
273#define B43_LPPHY_TRLOOKUP4 B43_PHY_OFDM(0xBC) /* TRLookup4 */
274#define B43_LPPHY_RADAR_FIFO_STAT B43_PHY_OFDM(0xBD) /* Radar FIFO Status */
275#define B43_LPPHY_GPIO_OUTEN B43_PHY_OFDM(0xBE) /* GPIO Out enable */
276#define B43_LPPHY_GPIO_SELECT B43_PHY_OFDM(0xBF) /* GPIO Select */
277#define B43_LPPHY_GPIO_OUT B43_PHY_OFDM(0xC0) /* GPIO Out */
8 278
279
280
281/* Radio register access decorators. */
9#define B43_LP_RADIO(radio_reg) (radio_reg) 282#define B43_LP_RADIO(radio_reg) (radio_reg)
10#define B43_LP_NORTH(radio_reg) B43_LP_RADIO(radio_reg) 283#define B43_LP_NORTH(radio_reg) B43_LP_RADIO(radio_reg)
11#define B43_LP_SOUTH(radio_reg) B43_LP_RADIO((radio_reg) | 0x4000) 284#define B43_LP_SOUTH(radio_reg) B43_LP_RADIO((radio_reg) | 0x4000)
@@ -530,7 +803,47 @@
530 803
531 804
532struct b43_phy_lp { 805struct b43_phy_lp {
533 //TODO 806 /* Transmit isolation medium band */
807 u8 tx_isolation_med_band; /* FIXME initial value? */
808 /* Transmit isolation low band */
809 u8 tx_isolation_low_band; /* FIXME initial value? */
810 /* Transmit isolation high band */
811 u8 tx_isolation_hi_band; /* FIXME initial value? */
812
813 /* Receive power offset */
814 u8 rx_pwr_offset; /* FIXME initial value? */
815
816 /* TSSI transmit count */
817 u16 tssi_tx_count; /* FIXME initial value? */
818 /* TSSI index */
819 u16 tssi_idx; /* FIXME initial value? */
820 /* TSSI npt */
821 u16 tssi_npt; /* FIXME initial value? */
822
823 /* Target TX frequency */
824 u16 tgt_tx_freq; /* FIXME initial value? */
825
826 /* Transmit power index override */
827 s8 tx_pwr_idx_over; /* FIXME initial value? */
828
829 /* RSSI vf */
830 u8 rssi_vf; /* FIXME initial value? */
831 /* RSSI vc */
832 u8 rssi_vc; /* FIXME initial value? */
833 /* RSSI gs */
834 u8 rssi_gs; /* FIXME initial value? */
835
836 /* RC cap */
837 u8 rc_cap; /* FIXME initial value? */
838 /* BX arch */
839 u8 bx_arch; /* FIXME initial value? */
840
841 /* Full calibration channel */
842 u8 full_calib_chan; /* FIXME initial value? */
843
844 /* Transmit iqlocal best coeffs */
845 bool tx_iqloc_best_coeffs_valid;
846 u8 tx_iqloc_best_coeffs[11];
534}; 847};
535 848
536 849
diff --git a/drivers/net/wireless/b43/tables_lpphy.c b/drivers/net/wireless/b43/tables_lpphy.c
new file mode 100644
index 000000000000..18f6e3256766
--- /dev/null
+++ b/drivers/net/wireless/b43/tables_lpphy.c
@@ -0,0 +1,333 @@
1/*
2
3 Broadcom B43 wireless driver
4 IEEE 802.11g LP-PHY and radio device data tables
5
6 Copyright (c) 2009 Michael Buesch <mb@bu3sch.de>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22
23*/
24
25#include "b43.h"
26#include "tables_lpphy.h"
27#include "phy_common.h"
28#include "phy_lp.h"
29
30
31/* Entry of the 2062 radio init table */
32struct b2062_init_tab_entry {
33 u16 offset;
34 u16 value_a;
35 u16 value_g;
36 u8 flags;
37};
38#define B2062_FLAG_A 0x01 /* Flag: Init in A mode */
39#define B2062_FLAG_G 0x02 /* Flag: Init in G mode */
40
41static const struct b2062_init_tab_entry b2062_init_tab[] = {
42 /* { .offset = B2062_N_COMM1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
43 /* { .offset = 0x0001, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
44 /* { .offset = B2062_N_COMM2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
45 /* { .offset = B2062_N_COMM3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
46 { .offset = B2062_N_COMM4, .value_a = 0x0001, .value_g = 0x0000, .flags = B2062_FLAG_A | B2062_FLAG_G, },
47 /* { .offset = B2062_N_COMM5, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
48 /* { .offset = B2062_N_COMM6, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
49 /* { .offset = B2062_N_COMM7, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
50 /* { .offset = B2062_N_COMM8, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
51 /* { .offset = B2062_N_COMM9, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
52 /* { .offset = B2062_N_COMM10, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
53 /* { .offset = B2062_N_COMM11, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
54 /* { .offset = B2062_N_COMM12, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
55 /* { .offset = B2062_N_COMM13, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
56 /* { .offset = B2062_N_COMM14, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
57 /* { .offset = B2062_N_COMM15, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
58 /* { .offset = B2062_N_PDN_CTL0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
59 { .offset = B2062_N_PDN_CTL1, .value_a = 0x0000, .value_g = 0x00CA, .flags = B2062_FLAG_G, },
60 /* { .offset = B2062_N_PDN_CTL2, .value_a = 0x0018, .value_g = 0x0018, .flags = 0, }, */
61 { .offset = B2062_N_PDN_CTL3, .value_a = 0x0000, .value_g = 0x0000, .flags = B2062_FLAG_A | B2062_FLAG_G, },
62 { .offset = B2062_N_PDN_CTL4, .value_a = 0x0015, .value_g = 0x002A, .flags = B2062_FLAG_A | B2062_FLAG_G, },
63 /* { .offset = B2062_N_GEN_CTL0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
64 /* { .offset = B2062_N_IQ_CALIB, .value_a = 0x0001, .value_g = 0x0001, .flags = 0, }, */
65 { .offset = B2062_N_LGENC, .value_a = 0x00DB, .value_g = 0x00FF, .flags = B2062_FLAG_A, },
66 /* { .offset = B2062_N_LGENA_LPF, .value_a = 0x0001, .value_g = 0x0001, .flags = 0, }, */
67 /* { .offset = B2062_N_LGENA_BIAS0, .value_a = 0x0041, .value_g = 0x0041, .flags = 0, }, */
68 /* { .offset = B2062_N_LGNEA_BIAS1, .value_a = 0x0002, .value_g = 0x0002, .flags = 0, }, */
69 /* { .offset = B2062_N_LGENA_CTL0, .value_a = 0x0032, .value_g = 0x0032, .flags = 0, }, */
70 /* { .offset = B2062_N_LGENA_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
71 /* { .offset = B2062_N_LGENA_CTL2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
72 { .offset = B2062_N_LGENA_TUNE0, .value_a = 0x00DD, .value_g = 0x0000, .flags = B2062_FLAG_A | B2062_FLAG_G, },
73 /* { .offset = B2062_N_LGENA_TUNE1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
74 { .offset = B2062_N_LGENA_TUNE2, .value_a = 0x00DD, .value_g = 0x0000, .flags = B2062_FLAG_A | B2062_FLAG_G, },
75 { .offset = B2062_N_LGENA_TUNE3, .value_a = 0x0077, .value_g = 0x00B5, .flags = B2062_FLAG_A | B2062_FLAG_G, },
76 { .offset = B2062_N_LGENA_CTL3, .value_a = 0x0000, .value_g = 0x00FF, .flags = B2062_FLAG_A | B2062_FLAG_G, },
77 /* { .offset = B2062_N_LGENA_CTL4, .value_a = 0x001F, .value_g = 0x001F, .flags = 0, }, */
78 /* { .offset = B2062_N_LGENA_CTL5, .value_a = 0x0032, .value_g = 0x0032, .flags = 0, }, */
79 /* { .offset = B2062_N_LGENA_CTL6, .value_a = 0x0032, .value_g = 0x0032, .flags = 0, }, */
80 { .offset = B2062_N_LGENA_CTL7, .value_a = 0x0033, .value_g = 0x0033, .flags = B2062_FLAG_A | B2062_FLAG_G, },
81 /* { .offset = B2062_N_RXA_CTL0, .value_a = 0x0009, .value_g = 0x0009, .flags = 0, }, */
82 { .offset = B2062_N_RXA_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = B2062_FLAG_G, },
83 /* { .offset = B2062_N_RXA_CTL2, .value_a = 0x0018, .value_g = 0x0018, .flags = 0, }, */
84 /* { .offset = B2062_N_RXA_CTL3, .value_a = 0x0027, .value_g = 0x0027, .flags = 0, }, */
85 /* { .offset = B2062_N_RXA_CTL4, .value_a = 0x0028, .value_g = 0x0028, .flags = 0, }, */
86 /* { .offset = B2062_N_RXA_CTL5, .value_a = 0x0007, .value_g = 0x0007, .flags = 0, }, */
87 /* { .offset = B2062_N_RXA_CTL6, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
88 /* { .offset = B2062_N_RXA_CTL7, .value_a = 0x0008, .value_g = 0x0008, .flags = 0, }, */
89 { .offset = B2062_N_RXBB_CTL0, .value_a = 0x0082, .value_g = 0x0080, .flags = B2062_FLAG_A | B2062_FLAG_G, },
90 /* { .offset = B2062_N_RXBB_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
91 /* { .offset = B2062_N_RXBB_CTL2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
92 /* { .offset = B2062_N_RXBB_GAIN0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
93 { .offset = B2062_N_RXBB_GAIN1, .value_a = 0x0004, .value_g = 0x0004, .flags = B2062_FLAG_A | B2062_FLAG_G, },
94 { .offset = B2062_N_RXBB_GAIN2, .value_a = 0x0000, .value_g = 0x0000, .flags = B2062_FLAG_A | B2062_FLAG_G, },
95 /* { .offset = B2062_N_RXBB_GAIN3, .value_a = 0x0011, .value_g = 0x0011, .flags = 0, }, */
96 /* { .offset = B2062_N_RXBB_RSSI0, .value_a = 0x0043, .value_g = 0x0043, .flags = 0, }, */
97 /* { .offset = B2062_N_RXBB_RSSI1, .value_a = 0x0033, .value_g = 0x0033, .flags = 0, }, */
98 /* { .offset = B2062_N_RXBB_CALIB0, .value_a = 0x0010, .value_g = 0x0010, .flags = 0, }, */
99 /* { .offset = B2062_N_RXBB_CALIB1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
100 /* { .offset = B2062_N_RXBB_CALIB2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
101 /* { .offset = B2062_N_RXBB_BIAS0, .value_a = 0x0006, .value_g = 0x0006, .flags = 0, }, */
102 /* { .offset = B2062_N_RXBB_BIAS1, .value_a = 0x002A, .value_g = 0x002A, .flags = 0, }, */
103 /* { .offset = B2062_N_RXBB_BIAS2, .value_a = 0x00AA, .value_g = 0x00AA, .flags = 0, }, */
104 /* { .offset = B2062_N_RXBB_BIAS3, .value_a = 0x0021, .value_g = 0x0021, .flags = 0, }, */
105 /* { .offset = B2062_N_RXBB_BIAS4, .value_a = 0x00AA, .value_g = 0x00AA, .flags = 0, }, */
106 /* { .offset = B2062_N_RXBB_BIAS5, .value_a = 0x0022, .value_g = 0x0022, .flags = 0, }, */
107 /* { .offset = B2062_N_RXBB_RSSI2, .value_a = 0x0001, .value_g = 0x0001, .flags = 0, }, */
108 /* { .offset = B2062_N_RXBB_RSSI3, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
109 /* { .offset = B2062_N_RXBB_RSSI4, .value_a = 0x0001, .value_g = 0x0001, .flags = 0, }, */
110 /* { .offset = B2062_N_RXBB_RSSI5, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
111 /* { .offset = B2062_N_TX_CTL0, .value_a = 0x0001, .value_g = 0x0001, .flags = 0, }, */
112 /* { .offset = B2062_N_TX_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
113 /* { .offset = B2062_N_TX_CTL2, .value_a = 0x0084, .value_g = 0x0084, .flags = 0, }, */
114 /* { .offset = B2062_N_TX_CTL3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
115 { .offset = B2062_N_TX_CTL4, .value_a = 0x0003, .value_g = 0x0003, .flags = B2062_FLAG_A | B2062_FLAG_G, },
116 { .offset = B2062_N_TX_CTL5, .value_a = 0x0002, .value_g = 0x0002, .flags = B2062_FLAG_A | B2062_FLAG_G, },
117 /* { .offset = B2062_N_TX_CTL6, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
118 /* { .offset = B2062_N_TX_CTL7, .value_a = 0x0058, .value_g = 0x0058, .flags = 0, }, */
119 /* { .offset = B2062_N_TX_CTL8, .value_a = 0x0082, .value_g = 0x0082, .flags = 0, }, */
120 /* { .offset = B2062_N_TX_CTL9, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
121 /* { .offset = B2062_N_TX_CTL_A, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
122 /* { .offset = B2062_N_TX_GC2G, .value_a = 0x00FF, .value_g = 0x00FF, .flags = 0, }, */
123 /* { .offset = B2062_N_TX_GC5G, .value_a = 0x00FF, .value_g = 0x00FF, .flags = 0, }, */
124 { .offset = B2062_N_TX_TUNE, .value_a = 0x0088, .value_g = 0x001B, .flags = B2062_FLAG_A | B2062_FLAG_G, },
125 /* { .offset = B2062_N_TX_PAD, .value_a = 0x0088, .value_g = 0x0088, .flags = 0, }, */
126 /* { .offset = B2062_N_TX_PGA, .value_a = 0x0088, .value_g = 0x0088, .flags = 0, }, */
127 /* { .offset = B2062_N_TX_PADAUX, .value_a = 0x0033, .value_g = 0x0033, .flags = 0, }, */
128 /* { .offset = B2062_N_TX_PGAAUX, .value_a = 0x0033, .value_g = 0x0033, .flags = 0, }, */
129 /* { .offset = B2062_N_TSSI_CTL0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
130 /* { .offset = B2062_N_TSSI_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
131 /* { .offset = B2062_N_TSSI_CTL2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
132 /* { .offset = B2062_N_IQ_CALIB_CTL0, .value_a = 0x0033, .value_g = 0x0033, .flags = 0, }, */
133 /* { .offset = B2062_N_IQ_CALIB_CTL1, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
134 /* { .offset = B2062_N_IQ_CALIB_CTL2, .value_a = 0x0032, .value_g = 0x0032, .flags = 0, }, */
135 /* { .offset = B2062_N_CALIB_TS, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
136 /* { .offset = B2062_N_CALIB_CTL0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
137 /* { .offset = B2062_N_CALIB_CTL1, .value_a = 0x0015, .value_g = 0x0015, .flags = 0, }, */
138 /* { .offset = B2062_N_CALIB_CTL2, .value_a = 0x000F, .value_g = 0x000F, .flags = 0, }, */
139 /* { .offset = B2062_N_CALIB_CTL3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
140 /* { .offset = B2062_N_CALIB_CTL4, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
141 /* { .offset = B2062_N_CALIB_DBG0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
142 /* { .offset = B2062_N_CALIB_DBG1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
143 /* { .offset = B2062_N_CALIB_DBG2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
144 /* { .offset = B2062_N_CALIB_DBG3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
145 /* { .offset = B2062_N_PSENSE_CTL0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
146 /* { .offset = B2062_N_PSENSE_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
147 /* { .offset = B2062_N_PSENSE_CTL2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
148 /* { .offset = B2062_N_TEST_BUF0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
149 /* { .offset = B2062_S_COMM1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
150 /* { .offset = B2062_S_RADIO_ID_CODE, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
151 /* { .offset = B2062_S_COMM2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
152 /* { .offset = B2062_S_COMM3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
153 { .offset = B2062_S_COMM4, .value_a = 0x0001, .value_g = 0x0000, .flags = B2062_FLAG_A | B2062_FLAG_G, },
154 /* { .offset = B2062_S_COMM5, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
155 /* { .offset = B2062_S_COMM6, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
156 /* { .offset = B2062_S_COMM7, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
157 /* { .offset = B2062_S_COMM8, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
158 /* { .offset = B2062_S_COMM9, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
159 /* { .offset = B2062_S_COMM10, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
160 /* { .offset = B2062_S_COMM11, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
161 /* { .offset = B2062_S_COMM12, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
162 /* { .offset = B2062_S_COMM13, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
163 /* { .offset = B2062_S_COMM14, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
164 /* { .offset = B2062_S_COMM15, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
165 { .offset = B2062_S_PDS_CTL0, .value_a = 0x00FF, .value_g = 0x00FF, .flags = B2062_FLAG_A | B2062_FLAG_G, },
166 /* { .offset = B2062_S_PDS_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
167 /* { .offset = B2062_S_PDS_CTL2, .value_a = 0x008E, .value_g = 0x008E, .flags = 0, }, */
168 /* { .offset = B2062_S_PDS_CTL3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
169 /* { .offset = B2062_S_BG_CTL0, .value_a = 0x0006, .value_g = 0x0006, .flags = 0, }, */
170 /* { .offset = B2062_S_BG_CTL1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
171 /* { .offset = B2062_S_BG_CTL2, .value_a = 0x0011, .value_g = 0x0011, .flags = 0, }, */
172 { .offset = B2062_S_LGENG_CTL0, .value_a = 0x00F8, .value_g = 0x00D8, .flags = B2062_FLAG_A | B2062_FLAG_G, },
173 { .offset = B2062_S_LGENG_CTL1, .value_a = 0x003C, .value_g = 0x0024, .flags = B2062_FLAG_A | B2062_FLAG_G, },
174 /* { .offset = B2062_S_LGENG_CTL2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
175 /* { .offset = B2062_S_LGENG_CTL3, .value_a = 0x0041, .value_g = 0x0041, .flags = 0, }, */
176 /* { .offset = B2062_S_LGENG_CTL4, .value_a = 0x0002, .value_g = 0x0002, .flags = 0, }, */
177 /* { .offset = B2062_S_LGENG_CTL5, .value_a = 0x0033, .value_g = 0x0033, .flags = 0, }, */
178 /* { .offset = B2062_S_LGENG_CTL6, .value_a = 0x0022, .value_g = 0x0022, .flags = 0, }, */
179 /* { .offset = B2062_S_LGENG_CTL7, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
180 { .offset = B2062_S_LGENG_CTL8, .value_a = 0x0088, .value_g = 0x0080, .flags = B2062_FLAG_A | B2062_FLAG_G, },
181 /* { .offset = B2062_S_LGENG_CTL9, .value_a = 0x0088, .value_g = 0x0088, .flags = 0, }, */
182 { .offset = B2062_S_LGENG_CTL10, .value_a = 0x0088, .value_g = 0x0080, .flags = B2062_FLAG_A | B2062_FLAG_G, },
183 /* { .offset = B2062_S_LGENG_CTL11, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
184 /* { .offset = B2062_S_REFPLL_CTL0, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
185 /* { .offset = B2062_S_REFPLL_CTL1, .value_a = 0x0007, .value_g = 0x0007, .flags = 0, }, */
186 /* { .offset = B2062_S_REFPLL_CTL2, .value_a = 0x00AF, .value_g = 0x00AF, .flags = 0, }, */
187 /* { .offset = B2062_S_REFPLL_CTL3, .value_a = 0x0012, .value_g = 0x0012, .flags = 0, }, */
188 /* { .offset = B2062_S_REFPLL_CTL4, .value_a = 0x000B, .value_g = 0x000B, .flags = 0, }, */
189 /* { .offset = B2062_S_REFPLL_CTL5, .value_a = 0x005F, .value_g = 0x005F, .flags = 0, }, */
190 /* { .offset = B2062_S_REFPLL_CTL6, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
191 /* { .offset = B2062_S_REFPLL_CTL7, .value_a = 0x0040, .value_g = 0x0040, .flags = 0, }, */
192 /* { .offset = B2062_S_REFPLL_CTL8, .value_a = 0x0052, .value_g = 0x0052, .flags = 0, }, */
193 /* { .offset = B2062_S_REFPLL_CTL9, .value_a = 0x0026, .value_g = 0x0026, .flags = 0, }, */
194 /* { .offset = B2062_S_REFPLL_CTL10, .value_a = 0x0003, .value_g = 0x0003, .flags = 0, }, */
195 /* { .offset = B2062_S_REFPLL_CTL11, .value_a = 0x0036, .value_g = 0x0036, .flags = 0, }, */
196 /* { .offset = B2062_S_REFPLL_CTL12, .value_a = 0x0057, .value_g = 0x0057, .flags = 0, }, */
197 /* { .offset = B2062_S_REFPLL_CTL13, .value_a = 0x0011, .value_g = 0x0011, .flags = 0, }, */
198 /* { .offset = B2062_S_REFPLL_CTL14, .value_a = 0x0075, .value_g = 0x0075, .flags = 0, }, */
199 /* { .offset = B2062_S_REFPLL_CTL15, .value_a = 0x00B4, .value_g = 0x00B4, .flags = 0, }, */
200 /* { .offset = B2062_S_REFPLL_CTL16, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
201 { .offset = B2062_S_RFPLL_CTL0, .value_a = 0x0098, .value_g = 0x0098, .flags = B2062_FLAG_A | B2062_FLAG_G, },
202 { .offset = B2062_S_RFPLL_CTL1, .value_a = 0x0010, .value_g = 0x0010, .flags = B2062_FLAG_A | B2062_FLAG_G, },
203 /* { .offset = B2062_S_RFPLL_CTL2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
204 /* { .offset = B2062_S_RFPLL_CTL3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
205 /* { .offset = B2062_S_RFPLL_CTL4, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
206 { .offset = B2062_S_RFPLL_CTL5, .value_a = 0x0043, .value_g = 0x0043, .flags = B2062_FLAG_A | B2062_FLAG_G, },
207 { .offset = B2062_S_RFPLL_CTL6, .value_a = 0x0047, .value_g = 0x0047, .flags = B2062_FLAG_A | B2062_FLAG_G, },
208 { .offset = B2062_S_RFPLL_CTL7, .value_a = 0x000C, .value_g = 0x000C, .flags = B2062_FLAG_A | B2062_FLAG_G, },
209 { .offset = B2062_S_RFPLL_CTL8, .value_a = 0x0011, .value_g = 0x0011, .flags = B2062_FLAG_A | B2062_FLAG_G, },
210 { .offset = B2062_S_RFPLL_CTL9, .value_a = 0x0011, .value_g = 0x0011, .flags = B2062_FLAG_A | B2062_FLAG_G, },
211 { .offset = B2062_S_RFPLL_CTL10, .value_a = 0x000E, .value_g = 0x000E, .flags = B2062_FLAG_A | B2062_FLAG_G, },
212 { .offset = B2062_S_RFPLL_CTL11, .value_a = 0x0008, .value_g = 0x0008, .flags = B2062_FLAG_A | B2062_FLAG_G, },
213 { .offset = B2062_S_RFPLL_CTL12, .value_a = 0x0033, .value_g = 0x0033, .flags = B2062_FLAG_A | B2062_FLAG_G, },
214 { .offset = B2062_S_RFPLL_CTL13, .value_a = 0x000A, .value_g = 0x000A, .flags = B2062_FLAG_A | B2062_FLAG_G, },
215 { .offset = B2062_S_RFPLL_CTL14, .value_a = 0x0006, .value_g = 0x0006, .flags = B2062_FLAG_A | B2062_FLAG_G, },
216 /* { .offset = B2062_S_RFPLL_CTL15, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
217 /* { .offset = B2062_S_RFPLL_CTL16, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
218 /* { .offset = B2062_S_RFPLL_CTL17, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
219 { .offset = B2062_S_RFPLL_CTL18, .value_a = 0x003E, .value_g = 0x003E, .flags = B2062_FLAG_A | B2062_FLAG_G, },
220 { .offset = B2062_S_RFPLL_CTL19, .value_a = 0x0013, .value_g = 0x0013, .flags = B2062_FLAG_A | B2062_FLAG_G, },
221 /* { .offset = B2062_S_RFPLL_CTL20, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
222 { .offset = B2062_S_RFPLL_CTL21, .value_a = 0x0062, .value_g = 0x0062, .flags = B2062_FLAG_A | B2062_FLAG_G, },
223 { .offset = B2062_S_RFPLL_CTL22, .value_a = 0x0007, .value_g = 0x0007, .flags = B2062_FLAG_A | B2062_FLAG_G, },
224 { .offset = B2062_S_RFPLL_CTL23, .value_a = 0x0016, .value_g = 0x0016, .flags = B2062_FLAG_A | B2062_FLAG_G, },
225 { .offset = B2062_S_RFPLL_CTL24, .value_a = 0x005C, .value_g = 0x005C, .flags = B2062_FLAG_A | B2062_FLAG_G, },
226 { .offset = B2062_S_RFPLL_CTL25, .value_a = 0x0095, .value_g = 0x0095, .flags = B2062_FLAG_A | B2062_FLAG_G, },
227 /* { .offset = B2062_S_RFPLL_CTL26, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
228 /* { .offset = B2062_S_RFPLL_CTL27, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
229 /* { .offset = B2062_S_RFPLL_CTL28, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
230 /* { .offset = B2062_S_RFPLL_CTL29, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
231 { .offset = B2062_S_RFPLL_CTL30, .value_a = 0x00A0, .value_g = 0x00A0, .flags = B2062_FLAG_A | B2062_FLAG_G, },
232 { .offset = B2062_S_RFPLL_CTL31, .value_a = 0x0004, .value_g = 0x0004, .flags = B2062_FLAG_A | B2062_FLAG_G, },
233 /* { .offset = B2062_S_RFPLL_CTL32, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
234 { .offset = B2062_S_RFPLL_CTL33, .value_a = 0x00CC, .value_g = 0x00CC, .flags = B2062_FLAG_A | B2062_FLAG_G, },
235 { .offset = B2062_S_RFPLL_CTL34, .value_a = 0x0007, .value_g = 0x0007, .flags = B2062_FLAG_A | B2062_FLAG_G, },
236 /* { .offset = B2062_S_RXG_CNT0, .value_a = 0x0010, .value_g = 0x0010, .flags = 0, }, */
237 /* { .offset = B2062_S_RXG_CNT1, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
238 /* { .offset = B2062_S_RXG_CNT2, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
239 /* { .offset = B2062_S_RXG_CNT3, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
240 /* { .offset = B2062_S_RXG_CNT4, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
241 /* { .offset = B2062_S_RXG_CNT5, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
242 /* { .offset = B2062_S_RXG_CNT6, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
243 /* { .offset = B2062_S_RXG_CNT7, .value_a = 0x0005, .value_g = 0x0005, .flags = 0, }, */
244 { .offset = B2062_S_RXG_CNT8, .value_a = 0x000F, .value_g = 0x000F, .flags = B2062_FLAG_A, },
245 /* { .offset = B2062_S_RXG_CNT9, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
246 /* { .offset = B2062_S_RXG_CNT10, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
247 /* { .offset = B2062_S_RXG_CNT11, .value_a = 0x0066, .value_g = 0x0066, .flags = 0, }, */
248 /* { .offset = B2062_S_RXG_CNT12, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
249 /* { .offset = B2062_S_RXG_CNT13, .value_a = 0x0044, .value_g = 0x0044, .flags = 0, }, */
250 /* { .offset = B2062_S_RXG_CNT14, .value_a = 0x00A0, .value_g = 0x00A0, .flags = 0, }, */
251 /* { .offset = B2062_S_RXG_CNT15, .value_a = 0x0004, .value_g = 0x0004, .flags = 0, }, */
252 /* { .offset = B2062_S_RXG_CNT16, .value_a = 0x0000, .value_g = 0x0000, .flags = 0, }, */
253 /* { .offset = B2062_S_RXG_CNT17, .value_a = 0x0055, .value_g = 0x0055, .flags = 0, }, */
254};
255
256void b2062_upload_init_table(struct b43_wldev *dev)
257{
258 const struct b2062_init_tab_entry *e;
259 unsigned int i;
260
261 for (i = 0; i < ARRAY_SIZE(b2062_init_tab); i++) {
262 e = &b2062_init_tab[i];
263 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
264 if (!(e->flags & B2062_FLAG_G))
265 continue;
266 b43_radio_write(dev, e->offset, e->value_g);
267 } else {
268 if (!(e->flags & B2062_FLAG_A))
269 continue;
270 b43_radio_write(dev, e->offset, e->value_a);
271 }
272 }
273}
274
275u32 b43_lptab_read(struct b43_wldev *dev, u32 offset)
276{
277 u32 type, value;
278
279 type = offset & B43_LPTAB_TYPEMASK;
280 offset &= ~B43_LPTAB_TYPEMASK;
281 B43_WARN_ON(offset > 0xFFFF);
282
283 switch (type) {
284 case B43_LPTAB_8BIT:
285 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
286 value = b43_phy_read(dev, B43_LPPHY_TABLEDATALO) & 0xFF;
287 break;
288 case B43_LPTAB_16BIT:
289 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
290 value = b43_phy_read(dev, B43_LPPHY_TABLEDATALO);
291 break;
292 case B43_LPTAB_32BIT:
293 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
294 value = b43_phy_read(dev, B43_LPPHY_TABLEDATAHI);
295 value <<= 16;
296 value |= b43_phy_read(dev, B43_LPPHY_TABLEDATALO);
297 break;
298 default:
299 B43_WARN_ON(1);
300 value = 0;
301 }
302
303 return value;
304}
305
306void b43_lptab_write(struct b43_wldev *dev, u32 offset, u32 value)
307{
308 u32 type;
309
310 type = offset & B43_LPTAB_TYPEMASK;
311 offset &= ~B43_LPTAB_TYPEMASK;
312 B43_WARN_ON(offset > 0xFFFF);
313
314 switch (type) {
315 case B43_LPTAB_8BIT:
316 B43_WARN_ON(value & ~0xFF);
317 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
318 b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
319 break;
320 case B43_LPTAB_16BIT:
321 B43_WARN_ON(value & ~0xFFFF);
322 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
323 b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
324 break;
325 case B43_LPTAB_32BIT:
326 b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
327 b43_phy_write(dev, B43_LPPHY_TABLEDATAHI, value >> 16);
328 b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
329 break;
330 default:
331 B43_WARN_ON(1);
332 }
333}
diff --git a/drivers/net/wireless/b43/tables_lpphy.h b/drivers/net/wireless/b43/tables_lpphy.h
new file mode 100644
index 000000000000..03ea2ff5d13a
--- /dev/null
+++ b/drivers/net/wireless/b43/tables_lpphy.h
@@ -0,0 +1,23 @@
1#ifndef B43_TABLES_LPPHY_H_
2#define B43_TABLES_LPPHY_H_
3
4
5#define B43_LPTAB_TYPEMASK 0xF0000000
6#define B43_LPTAB_8BIT 0x10000000
7#define B43_LPTAB_16BIT 0x20000000
8#define B43_LPTAB_32BIT 0x30000000
9#define B43_LPTAB8(table, offset) (((table) << 10) | (offset) | B43_LPTAB_8BIT)
10#define B43_LPTAB16(table, offset) (((table) << 10) | (offset) | B43_LPTAB_16BIT)
11#define B43_LPTAB32(table, offset) (((table) << 10) | (offset) | B43_LPTAB_32BIT)
12
13/* Table definitions */
14#define B43_LPTAB_TXPWR_R2PLUS B43_LPTAB32(0x07, 0) /* TX power lookup table (rev >= 2) */
15#define B43_LPTAB_TXPWR_R0_1 B43_LPTAB32(0xA0, 0) /* TX power lookup table (rev < 2) */
16
17u32 b43_lptab_read(struct b43_wldev *dev, u32 offset);
18void b43_lptab_write(struct b43_wldev *dev, u32 offset, u32 value);
19
20void b2062_upload_init_table(struct b43_wldev *dev);
21
22
23#endif /* B43_TABLES_LPPHY_H_ */
diff --git a/drivers/net/wireless/b43legacy/leds.c b/drivers/net/wireless/b43legacy/leds.c
index cacb786d9713..3ea55b18c700 100644
--- a/drivers/net/wireless/b43legacy/leds.c
+++ b/drivers/net/wireless/b43legacy/leds.c
@@ -146,12 +146,12 @@ static void b43legacy_map_led(struct b43legacy_wldev *dev,
146 case B43legacy_LED_TRANSFER: 146 case B43legacy_LED_TRANSFER:
147 case B43legacy_LED_APTRANSFER: 147 case B43legacy_LED_APTRANSFER:
148 snprintf(name, sizeof(name), 148 snprintf(name, sizeof(name),
149 "b43legacy-%s:tx", wiphy_name(hw->wiphy)); 149 "b43legacy-%s::tx", wiphy_name(hw->wiphy));
150 b43legacy_register_led(dev, &dev->led_tx, name, 150 b43legacy_register_led(dev, &dev->led_tx, name,
151 ieee80211_get_tx_led_name(hw), 151 ieee80211_get_tx_led_name(hw),
152 led_index, activelow); 152 led_index, activelow);
153 snprintf(name, sizeof(name), 153 snprintf(name, sizeof(name),
154 "b43legacy-%s:rx", wiphy_name(hw->wiphy)); 154 "b43legacy-%s::rx", wiphy_name(hw->wiphy));
155 b43legacy_register_led(dev, &dev->led_rx, name, 155 b43legacy_register_led(dev, &dev->led_rx, name,
156 ieee80211_get_rx_led_name(hw), 156 ieee80211_get_rx_led_name(hw),
157 led_index, activelow); 157 led_index, activelow);
@@ -161,7 +161,7 @@ static void b43legacy_map_led(struct b43legacy_wldev *dev,
161 case B43legacy_LED_RADIO_B: 161 case B43legacy_LED_RADIO_B:
162 case B43legacy_LED_MODE_BG: 162 case B43legacy_LED_MODE_BG:
163 snprintf(name, sizeof(name), 163 snprintf(name, sizeof(name),
164 "b43legacy-%s:radio", wiphy_name(hw->wiphy)); 164 "b43legacy-%s::radio", wiphy_name(hw->wiphy));
165 b43legacy_register_led(dev, &dev->led_radio, name, 165 b43legacy_register_led(dev, &dev->led_radio, name,
166 b43legacy_rfkill_led_name(dev), 166 b43legacy_rfkill_led_name(dev),
167 led_index, activelow); 167 led_index, activelow);
@@ -172,7 +172,7 @@ static void b43legacy_map_led(struct b43legacy_wldev *dev,
172 case B43legacy_LED_WEIRD: 172 case B43legacy_LED_WEIRD:
173 case B43legacy_LED_ASSOC: 173 case B43legacy_LED_ASSOC:
174 snprintf(name, sizeof(name), 174 snprintf(name, sizeof(name),
175 "b43legacy-%s:assoc", wiphy_name(hw->wiphy)); 175 "b43legacy-%s::assoc", wiphy_name(hw->wiphy));
176 b43legacy_register_led(dev, &dev->led_assoc, name, 176 b43legacy_register_led(dev, &dev->led_assoc, name,
177 ieee80211_get_assoc_led_name(hw), 177 ieee80211_get_assoc_led_name(hw),
178 led_index, activelow); 178 led_index, activelow);
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index 19b1bf0478bd..241756318da4 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -193,7 +193,7 @@ hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
193 if (prism_header) 193 if (prism_header)
194 skb_pull(skb, phdrlen); 194 skb_pull(skb, phdrlen);
195 skb->pkt_type = PACKET_OTHERHOST; 195 skb->pkt_type = PACKET_OTHERHOST;
196 skb->protocol = __constant_htons(ETH_P_802_2); 196 skb->protocol = cpu_to_be16(ETH_P_802_2);
197 memset(skb->cb, 0, sizeof(skb->cb)); 197 memset(skb->cb, 0, sizeof(skb->cb));
198 netif_rx(skb); 198 netif_rx(skb);
199 199
@@ -1094,7 +1094,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
1094 if (skb2 != NULL) { 1094 if (skb2 != NULL) {
1095 /* send to wireless media */ 1095 /* send to wireless media */
1096 skb2->dev = dev; 1096 skb2->dev = dev;
1097 skb2->protocol = __constant_htons(ETH_P_802_3); 1097 skb2->protocol = cpu_to_be16(ETH_P_802_3);
1098 skb_reset_mac_header(skb2); 1098 skb_reset_mac_header(skb2);
1099 skb_reset_network_header(skb2); 1099 skb_reset_network_header(skb2);
1100 /* skb2->network_header += ETH_HLEN; */ 1100 /* skb2->network_header += ETH_HLEN; */
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index 0903db786d5f..0a4bf94dddfb 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -609,7 +609,7 @@ static void hostap_ap_tx_cb(struct sk_buff *skb, int ok, void *data)
609 skb->dev = ap->local->apdev; 609 skb->dev = ap->local->apdev;
610 skb_pull(skb, hostap_80211_get_hdrlen(fc)); 610 skb_pull(skb, hostap_80211_get_hdrlen(fc));
611 skb->pkt_type = PACKET_OTHERHOST; 611 skb->pkt_type = PACKET_OTHERHOST;
612 skb->protocol = __constant_htons(ETH_P_802_2); 612 skb->protocol = cpu_to_be16(ETH_P_802_2);
613 memset(skb->cb, 0, sizeof(skb->cb)); 613 memset(skb->cb, 0, sizeof(skb->cb));
614 netif_rx(skb); 614 netif_rx(skb);
615} 615}
@@ -2281,7 +2281,7 @@ void hostap_rx(struct net_device *dev, struct sk_buff *skb,
2281 WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_BEACON) 2281 WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_BEACON)
2282 goto drop; 2282 goto drop;
2283 2283
2284 skb->protocol = __constant_htons(ETH_P_HOSTAP); 2284 skb->protocol = cpu_to_be16(ETH_P_HOSTAP);
2285 handle_ap_item(local, skb, rx_stats); 2285 handle_ap_item(local, skb, rx_stats);
2286 return; 2286 return;
2287 2287
@@ -2310,7 +2310,7 @@ static void schedule_packet_send(local_info_t *local, struct sta_info *sta)
2310 hdr = (struct ieee80211_hdr_4addr *) skb_put(skb, 16); 2310 hdr = (struct ieee80211_hdr_4addr *) skb_put(skb, 16);
2311 2311
2312 /* Generate a fake pspoll frame to start packet delivery */ 2312 /* Generate a fake pspoll frame to start packet delivery */
2313 hdr->frame_ctl = __constant_cpu_to_le16( 2313 hdr->frame_ctl = cpu_to_le16(
2314 IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); 2314 IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
2315 memcpy(hdr->addr1, local->dev->dev_addr, ETH_ALEN); 2315 memcpy(hdr->addr1, local->dev->dev_addr, ETH_ALEN);
2316 memcpy(hdr->addr2, sta->addr, ETH_ALEN); 2316 memcpy(hdr->addr2, sta->addr, ETH_ALEN);
@@ -2754,7 +2754,7 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
2754 if (meta->flags & HOSTAP_TX_FLAGS_ADD_MOREDATA) { 2754 if (meta->flags & HOSTAP_TX_FLAGS_ADD_MOREDATA) {
2755 /* indicate to STA that more frames follow */ 2755 /* indicate to STA that more frames follow */
2756 hdr->frame_ctl |= 2756 hdr->frame_ctl |=
2757 __constant_cpu_to_le16(IEEE80211_FCTL_MOREDATA); 2757 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
2758 } 2758 }
2759 2759
2760 if (meta->flags & HOSTAP_TX_FLAGS_BUFFERED_FRAME) { 2760 if (meta->flags & HOSTAP_TX_FLAGS_BUFFERED_FRAME) {
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index c40fdf4c79de..8618b3355eb4 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -1638,7 +1638,7 @@ static int prism2_request_hostscan(struct net_device *dev,
1638 memset(&scan_req, 0, sizeof(scan_req)); 1638 memset(&scan_req, 0, sizeof(scan_req));
1639 scan_req.channel_list = cpu_to_le16(local->channel_mask & 1639 scan_req.channel_list = cpu_to_le16(local->channel_mask &
1640 local->scan_channel_mask); 1640 local->scan_channel_mask);
1641 scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS); 1641 scan_req.txrate = cpu_to_le16(HFA384X_RATES_1MBPS);
1642 if (ssid) { 1642 if (ssid) {
1643 if (ssid_len > 32) 1643 if (ssid_len > 32)
1644 return -EINVAL; 1644 return -EINVAL;
@@ -1668,7 +1668,7 @@ static int prism2_request_scan(struct net_device *dev)
1668 memset(&scan_req, 0, sizeof(scan_req)); 1668 memset(&scan_req, 0, sizeof(scan_req));
1669 scan_req.channel_list = cpu_to_le16(local->channel_mask & 1669 scan_req.channel_list = cpu_to_le16(local->channel_mask &
1670 local->scan_channel_mask); 1670 local->scan_channel_mask);
1671 scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS); 1671 scan_req.txrate = cpu_to_le16(HFA384X_RATES_1MBPS);
1672 1672
1673 /* FIX: 1673 /* FIX:
1674 * It seems to be enough to set roaming mode for a short moment to 1674 * It seems to be enough to set roaming mode for a short moment to
@@ -2514,7 +2514,7 @@ static int prism2_ioctl_priv_prism2_param(struct net_device *dev,
2514 u16 rate; 2514 u16 rate;
2515 2515
2516 memset(&scan_req, 0, sizeof(scan_req)); 2516 memset(&scan_req, 0, sizeof(scan_req));
2517 scan_req.channel_list = __constant_cpu_to_le16(0x3fff); 2517 scan_req.channel_list = cpu_to_le16(0x3fff);
2518 switch (value) { 2518 switch (value) {
2519 case 1: rate = HFA384X_RATES_1MBPS; break; 2519 case 1: rate = HFA384X_RATES_1MBPS; break;
2520 case 2: rate = HFA384X_RATES_2MBPS; break; 2520 case 2: rate = HFA384X_RATES_2MBPS; break;
diff --git a/drivers/net/wireless/ipw2x00/Kconfig b/drivers/net/wireless/ipw2x00/Kconfig
index 3d5cc4463d4d..1d5dc3e9c5fb 100644
--- a/drivers/net/wireless/ipw2x00/Kconfig
+++ b/drivers/net/wireless/ipw2x00/Kconfig
@@ -150,6 +150,7 @@ config IPW2200_DEBUG
150 150
151config LIBIPW 151config LIBIPW
152 tristate 152 tristate
153 depends on PCI && WLAN_80211
153 select WIRELESS_EXT 154 select WIRELESS_EXT
154 select CRYPTO 155 select CRYPTO
155 select CRYPTO_ARC4 156 select CRYPTO_ARC4
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 625f2cf99fa9..0420d3d35dd4 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -8272,7 +8272,7 @@ static void ipw_handle_mgmt_packet(struct ipw_priv *priv,
8272 skb_reset_mac_header(skb); 8272 skb_reset_mac_header(skb);
8273 8273
8274 skb->pkt_type = PACKET_OTHERHOST; 8274 skb->pkt_type = PACKET_OTHERHOST;
8275 skb->protocol = __constant_htons(ETH_P_80211_STATS); 8275 skb->protocol = cpu_to_be16(ETH_P_80211_STATS);
8276 memset(skb->cb, 0, sizeof(rxb->skb->cb)); 8276 memset(skb->cb, 0, sizeof(rxb->skb->cb));
8277 netif_rx(skb); 8277 netif_rx(skb);
8278 rxb->skb = NULL; 8278 rxb->skb = NULL;
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)
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index 7c02ea314fd1..07311e71af92 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -42,6 +42,7 @@ struct if_spi_packet {
42struct if_spi_card { 42struct if_spi_card {
43 struct spi_device *spi; 43 struct spi_device *spi;
44 struct lbs_private *priv; 44 struct lbs_private *priv;
45 struct libertas_spi_platform_data *pdata;
45 46
46 char helper_fw_name[FIRMWARE_NAME_MAX]; 47 char helper_fw_name[FIRMWARE_NAME_MAX];
47 char main_fw_name[FIRMWARE_NAME_MAX]; 48 char main_fw_name[FIRMWARE_NAME_MAX];
@@ -1022,6 +1023,17 @@ static int __devinit if_spi_probe(struct spi_device *spi)
1022 1023
1023 lbs_deb_enter(LBS_DEB_SPI); 1024 lbs_deb_enter(LBS_DEB_SPI);
1024 1025
1026 if (!pdata) {
1027 err = -EINVAL;
1028 goto out;
1029 }
1030
1031 if (pdata->setup) {
1032 err = pdata->setup(spi);
1033 if (err)
1034 goto out;
1035 }
1036
1025 /* Allocate card structure to represent this specific device */ 1037 /* Allocate card structure to represent this specific device */
1026 card = kzalloc(sizeof(struct if_spi_card), GFP_KERNEL); 1038 card = kzalloc(sizeof(struct if_spi_card), GFP_KERNEL);
1027 if (!card) { 1039 if (!card) {
@@ -1029,6 +1041,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
1029 goto out; 1041 goto out;
1030 } 1042 }
1031 spi_set_drvdata(spi, card); 1043 spi_set_drvdata(spi, card);
1044 card->pdata = pdata;
1032 card->spi = spi; 1045 card->spi = spi;
1033 card->gpio_cs = pdata->gpio_cs; 1046 card->gpio_cs = pdata->gpio_cs;
1034 card->prev_xfer_time = jiffies; 1047 card->prev_xfer_time = jiffies;
@@ -1158,6 +1171,8 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
1158 if_spi_terminate_spi_thread(card); 1171 if_spi_terminate_spi_thread(card);
1159 lbs_remove_card(priv); /* will call free_netdev */ 1172 lbs_remove_card(priv); /* will call free_netdev */
1160 gpio_free(card->gpio_cs); 1173 gpio_free(card->gpio_cs);
1174 if (card->pdata->teardown)
1175 card->pdata->teardown(spi);
1161 free_if_spi_card(card); 1176 free_if_spi_card(card);
1162 lbs_deb_leave(LBS_DEB_SPI); 1177 lbs_deb_leave(LBS_DEB_SPI);
1163 return 0; 1178 return 0;
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 57f6c12cda20..00a57ed78afc 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -692,7 +692,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
692 bss->wpa_ie_len); 692 bss->wpa_ie_len);
693 } else if (pos[1] >= MARVELL_MESH_IE_LENGTH && 693 } else if (pos[1] >= MARVELL_MESH_IE_LENGTH &&
694 pos[2] == 0x00 && pos[3] == 0x50 && 694 pos[2] == 0x00 && pos[3] == 0x50 &&
695 pos[4] == 0x43 && pos[4] == 0x04) { 695 pos[4] == 0x43 && pos[5] == 0x04) {
696 lbs_deb_scan("got mesh IE\n"); 696 lbs_deb_scan("got mesh IE\n");
697 bss->mesh = 1; 697 bss->mesh = 1;
698 } else { 698 } else {
diff --git a/drivers/net/wireless/orinoco/airport.c b/drivers/net/wireless/orinoco/airport.c
index 28f1cae48439..5582dca9f7f5 100644
--- a/drivers/net/wireless/orinoco/airport.c
+++ b/drivers/net/wireless/orinoco/airport.c
@@ -4,9 +4,9 @@
4 * card. 4 * card.
5 * 5 *
6 * Copyright notice & release notes in file orinoco.c 6 * Copyright notice & release notes in file orinoco.c
7 * 7 *
8 * Note specific to airport stub: 8 * Note specific to airport stub:
9 * 9 *
10 * 0.05 : first version of the new split driver 10 * 0.05 : first version of the new split driver
11 * 0.06 : fix possible hang on powerup, add sleep support 11 * 0.06 : fix possible hang on powerup, add sleep support
12 */ 12 */
@@ -60,7 +60,8 @@ airport_suspend(struct macio_dev *mdev, pm_message_t state)
60 orinoco_unlock(priv, &flags); 60 orinoco_unlock(priv, &flags);
61 61
62 disable_irq(dev->irq); 62 disable_irq(dev->irq);
63 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 0); 63 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
64 macio_get_of_node(mdev), 0, 0);
64 65
65 return 0; 66 return 0;
66} 67}
@@ -75,7 +76,8 @@ airport_resume(struct macio_dev *mdev)
75 76
76 printk(KERN_DEBUG "%s: Airport waking up\n", dev->name); 77 printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
77 78
78 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 1); 79 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
80 macio_get_of_node(mdev), 0, 1);
79 msleep(200); 81 msleep(200);
80 82
81 enable_irq(dev->irq); 83 enable_irq(dev->irq);
@@ -93,7 +95,7 @@ airport_resume(struct macio_dev *mdev)
93 95
94 priv->hw_unavailable--; 96 priv->hw_unavailable--;
95 97
96 if (priv->open && (! priv->hw_unavailable)) { 98 if (priv->open && (!priv->hw_unavailable)) {
97 err = __orinoco_up(dev); 99 err = __orinoco_up(dev);
98 if (err) 100 if (err)
99 printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n", 101 printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
@@ -127,7 +129,8 @@ airport_detach(struct macio_dev *mdev)
127 129
128 macio_release_resource(mdev, 0); 130 macio_release_resource(mdev, 0);
129 131
130 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 0); 132 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
133 macio_get_of_node(mdev), 0, 0);
131 ssleep(1); 134 ssleep(1);
132 135
133 macio_set_drvdata(mdev, NULL); 136 macio_set_drvdata(mdev, NULL);
@@ -153,9 +156,11 @@ static int airport_hard_reset(struct orinoco_private *priv)
153 * off. */ 156 * off. */
154 disable_irq(dev->irq); 157 disable_irq(dev->irq);
155 158
156 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(card->mdev), 0, 0); 159 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
160 macio_get_of_node(card->mdev), 0, 0);
157 ssleep(1); 161 ssleep(1);
158 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(card->mdev), 0, 1); 162 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
163 macio_get_of_node(card->mdev), 0, 1);
159 ssleep(1); 164 ssleep(1);
160 165
161 enable_irq(dev->irq); 166 enable_irq(dev->irq);
@@ -182,7 +187,7 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
182 /* Allocate space for private device-specific data */ 187 /* Allocate space for private device-specific data */
183 dev = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev, 188 dev = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev,
184 airport_hard_reset, NULL); 189 airport_hard_reset, NULL);
185 if (! dev) { 190 if (!dev) {
186 printk(KERN_ERR PFX "Cannot allocate network device\n"); 191 printk(KERN_ERR PFX "Cannot allocate network device\n");
187 return -ENODEV; 192 return -ENODEV;
188 } 193 }
@@ -214,9 +219,10 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
214 } 219 }
215 220
216 hermes_struct_init(hw, card->vaddr, HERMES_16BIT_REGSPACING); 221 hermes_struct_init(hw, card->vaddr, HERMES_16BIT_REGSPACING);
217 222
218 /* Power up card */ 223 /* Power up card */
219 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, macio_get_of_node(mdev), 0, 1); 224 pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE,
225 macio_get_of_node(mdev), 0, 1);
220 ssleep(1); 226 ssleep(1);
221 227
222 /* Reset it before we get the interrupt */ 228 /* Reset it before we get the interrupt */
@@ -248,7 +254,7 @@ MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
248MODULE_DESCRIPTION("Driver for the Apple Airport wireless card."); 254MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
249MODULE_LICENSE("Dual MPL/GPL"); 255MODULE_LICENSE("Dual MPL/GPL");
250 256
251static struct of_device_id airport_match[] = 257static struct of_device_id airport_match[] =
252{ 258{
253 { 259 {
254 .name = "radio", 260 .name = "radio",
@@ -256,10 +262,9 @@ static struct of_device_id airport_match[] =
256 {}, 262 {},
257}; 263};
258 264
259MODULE_DEVICE_TABLE (of, airport_match); 265MODULE_DEVICE_TABLE(of, airport_match);
260 266
261static struct macio_driver airport_driver = 267static struct macio_driver airport_driver = {
262{
263 .name = DRIVER_NAME, 268 .name = DRIVER_NAME,
264 .match_table = airport_match, 269 .match_table = airport_match,
265 .probe = airport_attach, 270 .probe = airport_attach,
diff --git a/drivers/net/wireless/orinoco/hermes.c b/drivers/net/wireless/orinoco/hermes.c
index bfa375369df3..f48358fed9f7 100644
--- a/drivers/net/wireless/orinoco/hermes.c
+++ b/drivers/net/wireless/orinoco/hermes.c
@@ -15,7 +15,7 @@
15 * 15 *
16 * Copyright (C) 2000, David Gibson, Linuxcare Australia. 16 * Copyright (C) 2000, David Gibson, Linuxcare Australia.
17 * (C) Copyright David Gibson, IBM Corp. 2001-2003. 17 * (C) Copyright David Gibson, IBM Corp. 2001-2003.
18 * 18 *
19 * The contents of this file are subject to the Mozilla Public License 19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in 20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License 21 * compliance with the License. You may obtain a copy of the License
@@ -45,7 +45,8 @@
45 45
46#include "hermes.h" 46#include "hermes.h"
47 47
48MODULE_DESCRIPTION("Low-level driver helper for Lucent Hermes chipset and Prism II HFA384x wireless MAC controller"); 48MODULE_DESCRIPTION("Low-level driver helper for Lucent Hermes chipset"
49 " and Prism II HFA384x wireless MAC controller");
49MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>" 50MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>"
50 " & David Gibson <hermes@gibson.dropbear.id.au>"); 51 " & David Gibson <hermes@gibson.dropbear.id.au>");
51MODULE_LICENSE("Dual MPL/GPL"); 52MODULE_LICENSE("Dual MPL/GPL");
@@ -61,13 +62,13 @@ MODULE_LICENSE("Dual MPL/GPL");
61 */ 62 */
62 63
63#define DMSG(stuff...) do {printk(KERN_DEBUG "hermes @ %p: " , hw->iobase); \ 64#define DMSG(stuff...) do {printk(KERN_DEBUG "hermes @ %p: " , hw->iobase); \
64 printk(stuff);} while (0) 65 printk(stuff); } while (0)
65 66
66#undef HERMES_DEBUG 67#undef HERMES_DEBUG
67#ifdef HERMES_DEBUG 68#ifdef HERMES_DEBUG
68#include <stdarg.h> 69#include <stdarg.h>
69 70
70#define DEBUG(lvl, stuff...) if ( (lvl) <= HERMES_DEBUG) DMSG(stuff) 71#define DEBUG(lvl, stuff...) if ((lvl) <= HERMES_DEBUG) DMSG(stuff)
71 72
72#else /* ! HERMES_DEBUG */ 73#else /* ! HERMES_DEBUG */
73 74
@@ -95,20 +96,19 @@ static int hermes_issue_cmd(hermes_t *hw, u16 cmd, u16 param0,
95 96
96 /* First wait for the command register to unbusy */ 97 /* First wait for the command register to unbusy */
97 reg = hermes_read_regn(hw, CMD); 98 reg = hermes_read_regn(hw, CMD);
98 while ( (reg & HERMES_CMD_BUSY) && k ) { 99 while ((reg & HERMES_CMD_BUSY) && k) {
99 k--; 100 k--;
100 udelay(1); 101 udelay(1);
101 reg = hermes_read_regn(hw, CMD); 102 reg = hermes_read_regn(hw, CMD);
102 } 103 }
103 if (reg & HERMES_CMD_BUSY) { 104 if (reg & HERMES_CMD_BUSY)
104 return -EBUSY; 105 return -EBUSY;
105 }
106 106
107 hermes_write_regn(hw, PARAM2, param2); 107 hermes_write_regn(hw, PARAM2, param2);
108 hermes_write_regn(hw, PARAM1, param1); 108 hermes_write_regn(hw, PARAM1, param1);
109 hermes_write_regn(hw, PARAM0, param0); 109 hermes_write_regn(hw, PARAM0, param0);
110 hermes_write_regn(hw, CMD, cmd); 110 hermes_write_regn(hw, CMD, cmd);
111 111
112 return 0; 112 return 0;
113} 113}
114 114
@@ -191,23 +191,23 @@ int hermes_init(hermes_t *hw)
191 hermes_write_regn(hw, EVACK, 0xffff); 191 hermes_write_regn(hw, EVACK, 0xffff);
192 192
193 /* Normally it's a "can't happen" for the command register to 193 /* Normally it's a "can't happen" for the command register to
194 be busy when we go to issue a command because we are 194 be busy when we go to issue a command because we are
195 serializing all commands. However we want to have some 195 serializing all commands. However we want to have some
196 chance of resetting the card even if it gets into a stupid 196 chance of resetting the card even if it gets into a stupid
197 state, so we actually wait to see if the command register 197 state, so we actually wait to see if the command register
198 will unbusy itself here. */ 198 will unbusy itself here. */
199 k = CMD_BUSY_TIMEOUT; 199 k = CMD_BUSY_TIMEOUT;
200 reg = hermes_read_regn(hw, CMD); 200 reg = hermes_read_regn(hw, CMD);
201 while (k && (reg & HERMES_CMD_BUSY)) { 201 while (k && (reg & HERMES_CMD_BUSY)) {
202 if (reg == 0xffff) /* Special case - the card has probably been removed, 202 if (reg == 0xffff) /* Special case - the card has probably been
203 so don't wait for the timeout */ 203 removed, so don't wait for the timeout */
204 return -ENODEV; 204 return -ENODEV;
205 205
206 k--; 206 k--;
207 udelay(1); 207 udelay(1);
208 reg = hermes_read_regn(hw, CMD); 208 reg = hermes_read_regn(hw, CMD);
209 } 209 }
210 210
211 /* No need to explicitly handle the timeout - if we've timed 211 /* No need to explicitly handle the timeout - if we've timed
212 out hermes_issue_cmd() will probably return -EBUSY below */ 212 out hermes_issue_cmd() will probably return -EBUSY below */
213 213
@@ -228,7 +228,10 @@ EXPORT_SYMBOL(hermes_init);
228/* Issue a command to the chip, and (busy!) wait for it to 228/* Issue a command to the chip, and (busy!) wait for it to
229 * complete. 229 * complete.
230 * 230 *
231 * Returns: < 0 on internal error, 0 on success, > 0 on error returned by the firmware 231 * Returns:
232 * < 0 on internal error
233 * 0 on success
234 * > 0 on error returned by the firmware
232 * 235 *
233 * Callable from any context, but locking is your problem. */ 236 * Callable from any context, but locking is your problem. */
234int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0, 237int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
@@ -241,13 +244,13 @@ int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
241 244
242 err = hermes_issue_cmd(hw, cmd, parm0, 0, 0); 245 err = hermes_issue_cmd(hw, cmd, parm0, 0, 0);
243 if (err) { 246 if (err) {
244 if (! hermes_present(hw)) { 247 if (!hermes_present(hw)) {
245 if (net_ratelimit()) 248 if (net_ratelimit())
246 printk(KERN_WARNING "hermes @ %p: " 249 printk(KERN_WARNING "hermes @ %p: "
247 "Card removed while issuing command " 250 "Card removed while issuing command "
248 "0x%04x.\n", hw->iobase, cmd); 251 "0x%04x.\n", hw->iobase, cmd);
249 err = -ENODEV; 252 err = -ENODEV;
250 } else 253 } else
251 if (net_ratelimit()) 254 if (net_ratelimit())
252 printk(KERN_ERR "hermes @ %p: " 255 printk(KERN_ERR "hermes @ %p: "
253 "Error %d issuing command 0x%04x.\n", 256 "Error %d issuing command 0x%04x.\n",
@@ -257,21 +260,21 @@ int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
257 260
258 reg = hermes_read_regn(hw, EVSTAT); 261 reg = hermes_read_regn(hw, EVSTAT);
259 k = CMD_COMPL_TIMEOUT; 262 k = CMD_COMPL_TIMEOUT;
260 while ( (! (reg & HERMES_EV_CMD)) && k) { 263 while ((!(reg & HERMES_EV_CMD)) && k) {
261 k--; 264 k--;
262 udelay(10); 265 udelay(10);
263 reg = hermes_read_regn(hw, EVSTAT); 266 reg = hermes_read_regn(hw, EVSTAT);
264 } 267 }
265 268
266 if (! hermes_present(hw)) { 269 if (!hermes_present(hw)) {
267 printk(KERN_WARNING "hermes @ %p: Card removed " 270 printk(KERN_WARNING "hermes @ %p: Card removed "
268 "while waiting for command 0x%04x completion.\n", 271 "while waiting for command 0x%04x completion.\n",
269 hw->iobase, cmd); 272 hw->iobase, cmd);
270 err = -ENODEV; 273 err = -ENODEV;
271 goto out; 274 goto out;
272 } 275 }
273 276
274 if (! (reg & HERMES_EV_CMD)) { 277 if (!(reg & HERMES_EV_CMD)) {
275 printk(KERN_ERR "hermes @ %p: Timeout waiting for " 278 printk(KERN_ERR "hermes @ %p: Timeout waiting for "
276 "command 0x%04x completion.\n", hw->iobase, cmd); 279 "command 0x%04x completion.\n", hw->iobase, cmd);
277 err = -ETIMEDOUT; 280 err = -ETIMEDOUT;
@@ -301,31 +304,30 @@ int hermes_allocate(hermes_t *hw, u16 size, u16 *fid)
301 int err = 0; 304 int err = 0;
302 int k; 305 int k;
303 u16 reg; 306 u16 reg;
304 307
305 if ( (size < HERMES_ALLOC_LEN_MIN) || (size > HERMES_ALLOC_LEN_MAX) ) 308 if ((size < HERMES_ALLOC_LEN_MIN) || (size > HERMES_ALLOC_LEN_MAX))
306 return -EINVAL; 309 return -EINVAL;
307 310
308 err = hermes_docmd_wait(hw, HERMES_CMD_ALLOC, size, NULL); 311 err = hermes_docmd_wait(hw, HERMES_CMD_ALLOC, size, NULL);
309 if (err) { 312 if (err)
310 return err; 313 return err;
311 }
312 314
313 reg = hermes_read_regn(hw, EVSTAT); 315 reg = hermes_read_regn(hw, EVSTAT);
314 k = ALLOC_COMPL_TIMEOUT; 316 k = ALLOC_COMPL_TIMEOUT;
315 while ( (! (reg & HERMES_EV_ALLOC)) && k) { 317 while ((!(reg & HERMES_EV_ALLOC)) && k) {
316 k--; 318 k--;
317 udelay(10); 319 udelay(10);
318 reg = hermes_read_regn(hw, EVSTAT); 320 reg = hermes_read_regn(hw, EVSTAT);
319 } 321 }
320 322
321 if (! hermes_present(hw)) { 323 if (!hermes_present(hw)) {
322 printk(KERN_WARNING "hermes @ %p: " 324 printk(KERN_WARNING "hermes @ %p: "
323 "Card removed waiting for frame allocation.\n", 325 "Card removed waiting for frame allocation.\n",
324 hw->iobase); 326 hw->iobase);
325 return -ENODEV; 327 return -ENODEV;
326 } 328 }
327 329
328 if (! (reg & HERMES_EV_ALLOC)) { 330 if (!(reg & HERMES_EV_ALLOC)) {
329 printk(KERN_ERR "hermes @ %p: " 331 printk(KERN_ERR "hermes @ %p: "
330 "Timeout waiting for frame allocation\n", 332 "Timeout waiting for frame allocation\n",
331 hw->iobase); 333 hw->iobase);
@@ -334,14 +336,17 @@ int hermes_allocate(hermes_t *hw, u16 size, u16 *fid)
334 336
335 *fid = hermes_read_regn(hw, ALLOCFID); 337 *fid = hermes_read_regn(hw, ALLOCFID);
336 hermes_write_regn(hw, EVACK, HERMES_EV_ALLOC); 338 hermes_write_regn(hw, EVACK, HERMES_EV_ALLOC);
337 339
338 return 0; 340 return 0;
339} 341}
340EXPORT_SYMBOL(hermes_allocate); 342EXPORT_SYMBOL(hermes_allocate);
341 343
342/* Set up a BAP to read a particular chunk of data from card's internal buffer. 344/* Set up a BAP to read a particular chunk of data from card's internal buffer.
343 * 345 *
344 * Returns: < 0 on internal failure (errno), 0 on success, >0 on error 346 * Returns:
347 * < 0 on internal failure (errno)
348 * 0 on success
349 * > 0 on error
345 * from firmware 350 * from firmware
346 * 351 *
347 * Callable from any context */ 352 * Callable from any context */
@@ -353,7 +358,7 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
353 u16 reg; 358 u16 reg;
354 359
355 /* Paranoia.. */ 360 /* Paranoia.. */
356 if ( (offset > HERMES_BAP_OFFSET_MAX) || (offset % 2) ) 361 if ((offset > HERMES_BAP_OFFSET_MAX) || (offset % 2))
357 return -EINVAL; 362 return -EINVAL;
358 363
359 k = HERMES_BAP_BUSY_TIMEOUT; 364 k = HERMES_BAP_BUSY_TIMEOUT;
@@ -374,7 +379,7 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
374 /* Wait for the BAP to be ready */ 379 /* Wait for the BAP to be ready */
375 k = HERMES_BAP_BUSY_TIMEOUT; 380 k = HERMES_BAP_BUSY_TIMEOUT;
376 reg = hermes_read_reg(hw, oreg); 381 reg = hermes_read_reg(hw, oreg);
377 while ( (reg & (HERMES_OFFSET_BUSY | HERMES_OFFSET_ERR)) && k) { 382 while ((reg & (HERMES_OFFSET_BUSY | HERMES_OFFSET_ERR)) && k) {
378 k--; 383 k--;
379 udelay(1); 384 udelay(1);
380 reg = hermes_read_reg(hw, oreg); 385 reg = hermes_read_reg(hw, oreg);
@@ -386,9 +391,8 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
386 (reg & HERMES_OFFSET_BUSY) ? "timeout" : "error", 391 (reg & HERMES_OFFSET_BUSY) ? "timeout" : "error",
387 reg, id, offset); 392 reg, id, offset);
388 393
389 if (reg & HERMES_OFFSET_BUSY) { 394 if (reg & HERMES_OFFSET_BUSY)
390 return -ETIMEDOUT; 395 return -ETIMEDOUT;
391 }
392 396
393 return -EIO; /* error or wrong offset */ 397 return -EIO; /* error or wrong offset */
394 } 398 }
@@ -400,7 +404,10 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
400 * BAP. Synchronization/serialization is the caller's problem. len 404 * BAP. Synchronization/serialization is the caller's problem. len
401 * must be even. 405 * must be even.
402 * 406 *
403 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 407 * Returns:
408 * < 0 on internal failure (errno)
409 * 0 on success
410 * > 0 on error from firmware
404 */ 411 */
405int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len, 412int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
406 u16 id, u16 offset) 413 u16 id, u16 offset)
@@ -408,7 +415,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
408 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 415 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
409 int err = 0; 416 int err = 0;
410 417
411 if ( (len < 0) || (len % 2) ) 418 if ((len < 0) || (len % 2))
412 return -EINVAL; 419 return -EINVAL;
413 420
414 err = hermes_bap_seek(hw, bap, id, offset); 421 err = hermes_bap_seek(hw, bap, id, offset);
@@ -426,7 +433,10 @@ EXPORT_SYMBOL(hermes_bap_pread);
426/* Write a block of data to the chip's buffer, via the 433/* Write a block of data to the chip's buffer, via the
427 * BAP. Synchronization/serialization is the caller's problem. 434 * BAP. Synchronization/serialization is the caller's problem.
428 * 435 *
429 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 436 * Returns:
437 * < 0 on internal failure (errno)
438 * 0 on success
439 * > 0 on error from firmware
430 */ 440 */
431int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, 441int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
432 u16 id, u16 offset) 442 u16 id, u16 offset)
@@ -440,11 +450,11 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
440 err = hermes_bap_seek(hw, bap, id, offset); 450 err = hermes_bap_seek(hw, bap, id, offset);
441 if (err) 451 if (err)
442 goto out; 452 goto out;
443 453
444 /* Actually do the transfer */ 454 /* Actually do the transfer */
445 hermes_write_bytes(hw, dreg, buf, len); 455 hermes_write_bytes(hw, dreg, buf, len);
446 456
447 out: 457 out:
448 return err; 458 return err;
449} 459}
450EXPORT_SYMBOL(hermes_bap_pwrite); 460EXPORT_SYMBOL(hermes_bap_pwrite);
@@ -465,7 +475,7 @@ int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
465 u16 rlength, rtype; 475 u16 rlength, rtype;
466 unsigned nwords; 476 unsigned nwords;
467 477
468 if ( (bufsize < 0) || (bufsize % 2) ) 478 if ((bufsize < 0) || (bufsize % 2))
469 return -EINVAL; 479 return -EINVAL;
470 480
471 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS, rid, NULL); 481 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS, rid, NULL);
@@ -478,7 +488,7 @@ int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
478 488
479 rlength = hermes_read_reg(hw, dreg); 489 rlength = hermes_read_reg(hw, dreg);
480 490
481 if (! rlength) 491 if (!rlength)
482 return -ENODATA; 492 return -ENODATA;
483 493
484 rtype = hermes_read_reg(hw, dreg); 494 rtype = hermes_read_reg(hw, dreg);
@@ -503,7 +513,7 @@ int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize,
503} 513}
504EXPORT_SYMBOL(hermes_read_ltv); 514EXPORT_SYMBOL(hermes_read_ltv);
505 515
506int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 516int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
507 u16 length, const void *value) 517 u16 length, const void *value)
508{ 518{
509 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 519 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
diff --git a/drivers/net/wireless/orinoco/hermes.h b/drivers/net/wireless/orinoco/hermes.h
index 8b13c8fef3dc..c78c442a02c8 100644
--- a/drivers/net/wireless/orinoco/hermes.h
+++ b/drivers/net/wireless/orinoco/hermes.h
@@ -15,7 +15,8 @@
15 * Copyright (C) 2000, David Gibson, Linuxcare Australia. 15 * Copyright (C) 2000, David Gibson, Linuxcare Australia.
16 * (C) Copyright David Gibson, IBM Corp. 2001-2003. 16 * (C) Copyright David Gibson, IBM Corp. 2001-2003.
17 * 17 *
18 * Portions taken from hfa384x.h, Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. 18 * Portions taken from hfa384x.h.
19 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
19 * 20 *
20 * This file distributed under the GPL, version 2. 21 * This file distributed under the GPL, version 2.
21 */ 22 */
@@ -31,7 +32,7 @@
31*/ 32*/
32 33
33#include <linux/if_ether.h> 34#include <linux/if_ether.h>
34#include <asm/io.h> 35#include <linux/io.h>
35 36
36/* 37/*
37 * Limits and constants 38 * Limits and constants
@@ -203,7 +204,7 @@ struct hermes_tx_descriptor {
203 __le32 sw_support; 204 __le32 sw_support;
204 u8 retry_count; 205 u8 retry_count;
205 u8 tx_rate; 206 u8 tx_rate;
206 __le16 tx_control; 207 __le16 tx_control;
207} __attribute__ ((packed)); 208} __attribute__ ((packed));
208 209
209#define HERMES_TXSTAT_RETRYERR (0x0001) 210#define HERMES_TXSTAT_RETRYERR (0x0001)
@@ -298,7 +299,7 @@ struct symbol_scan_apinfo {
298 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */ 299 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */
299 __le16 essid_len; /* ESSID length */ 300 __le16 essid_len; /* ESSID length */
300 u8 essid[32]; /* ESSID of the network */ 301 u8 essid[32]; /* ESSID of the network */
301 __le16 rates[5]; /* Bit rate supported */ 302 __le16 rates[5]; /* Bit rate supported */
302 __le16 basic_rates; /* Basic rates bitmask */ 303 __le16 basic_rates; /* Basic rates bitmask */
303 u8 unknown2[6]; /* Always FF:FF:FF:FF:00:00 */ 304 u8 unknown2[6]; /* Always FF:FF:FF:FF:00:00 */
304 u8 unknown3[8]; /* Always 0, appeared in f/w 3.91-68 */ 305 u8 unknown3[8]; /* Always 0, appeared in f/w 3.91-68 */
@@ -344,14 +345,14 @@ struct agere_ext_scan_info {
344 u8 data[316]; 345 u8 data[316];
345} __attribute__ ((packed)); 346} __attribute__ ((packed));
346 347
347#define HERMES_LINKSTATUS_NOT_CONNECTED (0x0000) 348#define HERMES_LINKSTATUS_NOT_CONNECTED (0x0000)
348#define HERMES_LINKSTATUS_CONNECTED (0x0001) 349#define HERMES_LINKSTATUS_CONNECTED (0x0001)
349#define HERMES_LINKSTATUS_DISCONNECTED (0x0002) 350#define HERMES_LINKSTATUS_DISCONNECTED (0x0002)
350#define HERMES_LINKSTATUS_AP_CHANGE (0x0003) 351#define HERMES_LINKSTATUS_AP_CHANGE (0x0003)
351#define HERMES_LINKSTATUS_AP_OUT_OF_RANGE (0x0004) 352#define HERMES_LINKSTATUS_AP_OUT_OF_RANGE (0x0004)
352#define HERMES_LINKSTATUS_AP_IN_RANGE (0x0005) 353#define HERMES_LINKSTATUS_AP_IN_RANGE (0x0005)
353#define HERMES_LINKSTATUS_ASSOC_FAILED (0x0006) 354#define HERMES_LINKSTATUS_ASSOC_FAILED (0x0006)
354 355
355struct hermes_linkstatus { 356struct hermes_linkstatus {
356 __le16 linkstatus; /* Link status */ 357 __le16 linkstatus; /* Link status */
357} __attribute__ ((packed)); 358} __attribute__ ((packed));
@@ -384,11 +385,12 @@ typedef struct hermes {
384 385
385/* Register access convenience macros */ 386/* Register access convenience macros */
386#define hermes_read_reg(hw, off) \ 387#define hermes_read_reg(hw, off) \
387 (ioread16((hw)->iobase + ( (off) << (hw)->reg_spacing ))) 388 (ioread16((hw)->iobase + ((off) << (hw)->reg_spacing)))
388#define hermes_write_reg(hw, off, val) \ 389#define hermes_write_reg(hw, off, val) \
389 (iowrite16((val), (hw)->iobase + ((off) << (hw)->reg_spacing))) 390 (iowrite16((val), (hw)->iobase + ((off) << (hw)->reg_spacing)))
390#define hermes_read_regn(hw, name) hermes_read_reg((hw), HERMES_##name) 391#define hermes_read_regn(hw, name) hermes_read_reg((hw), HERMES_##name)
391#define hermes_write_regn(hw, name, val) hermes_write_reg((hw), HERMES_##name, (val)) 392#define hermes_write_regn(hw, name, val) \
393 hermes_write_reg((hw), HERMES_##name, (val))
392 394
393/* Function prototypes */ 395/* Function prototypes */
394void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing); 396void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing);
@@ -430,7 +432,7 @@ static inline int hermes_enable_port(hermes_t *hw, int port)
430 432
431static inline int hermes_disable_port(hermes_t *hw, int port) 433static inline int hermes_disable_port(hermes_t *hw, int port)
432{ 434{
433 return hermes_docmd_wait(hw, HERMES_CMD_DISABLE | (port << 8), 435 return hermes_docmd_wait(hw, HERMES_CMD_DISABLE | (port << 8),
434 0, NULL); 436 0, NULL);
435} 437}
436 438
@@ -441,11 +443,12 @@ static inline int hermes_inquire(hermes_t *hw, u16 rid)
441 return hermes_docmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL); 443 return hermes_docmd_wait(hw, HERMES_CMD_INQUIRE, rid, NULL);
442} 444}
443 445
444#define HERMES_BYTES_TO_RECLEN(n) ( (((n)+1)/2) + 1 ) 446#define HERMES_BYTES_TO_RECLEN(n) ((((n)+1)/2) + 1)
445#define HERMES_RECLEN_TO_BYTES(n) ( ((n)-1) * 2 ) 447#define HERMES_RECLEN_TO_BYTES(n) (((n)-1) * 2)
446 448
447/* Note that for the next two, the count is in 16-bit words, not bytes */ 449/* Note that for the next two, the count is in 16-bit words, not bytes */
448static inline void hermes_read_words(struct hermes *hw, int off, void *buf, unsigned count) 450static inline void hermes_read_words(struct hermes *hw, int off,
451 void *buf, unsigned count)
449{ 452{
450 off = off << hw->reg_spacing; 453 off = off << hw->reg_spacing;
451 ioread16_rep(hw->iobase + off, buf, count); 454 ioread16_rep(hw->iobase + off, buf, count);
@@ -460,7 +463,8 @@ static inline void hermes_write_bytes(struct hermes *hw, int off,
460 iowrite8(buf[count - 1], hw->iobase + off); 463 iowrite8(buf[count - 1], hw->iobase + off);
461} 464}
462 465
463static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count) 466static inline void hermes_clear_words(struct hermes *hw, int off,
467 unsigned count)
464{ 468{
465 unsigned i; 469 unsigned i;
466 470
@@ -471,9 +475,10 @@ static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count
471} 475}
472 476
473#define HERMES_READ_RECORD(hw, bap, rid, buf) \ 477#define HERMES_READ_RECORD(hw, bap, rid, buf) \
474 (hermes_read_ltv((hw),(bap),(rid), sizeof(*buf), NULL, (buf))) 478 (hermes_read_ltv((hw), (bap), (rid), sizeof(*buf), NULL, (buf)))
475#define HERMES_WRITE_RECORD(hw, bap, rid, buf) \ 479#define HERMES_WRITE_RECORD(hw, bap, rid, buf) \
476 (hermes_write_ltv((hw),(bap),(rid),HERMES_BYTES_TO_RECLEN(sizeof(*buf)),(buf))) 480 (hermes_write_ltv((hw), (bap), (rid), \
481 HERMES_BYTES_TO_RECLEN(sizeof(*buf)), (buf)))
477 482
478static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word) 483static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word)
479{ 484{
diff --git a/drivers/net/wireless/orinoco/hermes_dld.c b/drivers/net/wireless/orinoco/hermes_dld.c
index d8c626e61a3a..45aed14bf110 100644
--- a/drivers/net/wireless/orinoco/hermes_dld.c
+++ b/drivers/net/wireless/orinoco/hermes_dld.c
@@ -573,9 +573,9 @@ static const struct { \
573 __le16 id; \ 573 __le16 id; \
574 u8 val[length]; \ 574 u8 val[length]; \
575} __attribute__ ((packed)) default_pdr_data_##pid = { \ 575} __attribute__ ((packed)) default_pdr_data_##pid = { \
576 __constant_cpu_to_le16((sizeof(default_pdr_data_##pid)/ \ 576 cpu_to_le16((sizeof(default_pdr_data_##pid)/ \
577 sizeof(__le16)) - 1), \ 577 sizeof(__le16)) - 1), \
578 __constant_cpu_to_le16(pid), \ 578 cpu_to_le16(pid), \
579 data \ 579 data \
580} 580}
581 581
diff --git a/drivers/net/wireless/orinoco/orinoco.c b/drivers/net/wireless/orinoco/orinoco.c
index 6514e4611b96..e082ef085116 100644
--- a/drivers/net/wireless/orinoco/orinoco.c
+++ b/drivers/net/wireless/orinoco/orinoco.c
@@ -1333,7 +1333,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
1333 skb->dev = dev; 1333 skb->dev = dev;
1334 skb->ip_summed = CHECKSUM_NONE; 1334 skb->ip_summed = CHECKSUM_NONE;
1335 skb->pkt_type = PACKET_OTHERHOST; 1335 skb->pkt_type = PACKET_OTHERHOST;
1336 skb->protocol = __constant_htons(ETH_P_802_2); 1336 skb->protocol = cpu_to_be16(ETH_P_802_2);
1337 1337
1338 stats->rx_packets++; 1338 stats->rx_packets++;
1339 stats->rx_bytes += skb->len; 1339 stats->rx_bytes += skb->len;
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index c653816ef5fe..f3f94b28ce6d 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -1,5 +1,5 @@
1/* orinoco.h 1/* orinoco.h
2 * 2 *
3 * Common definitions to all pieces of the various orinoco 3 * Common definitions to all pieces of the various orinoco
4 * drivers 4 * drivers
5 */ 5 */
@@ -18,9 +18,9 @@
18#include "hermes.h" 18#include "hermes.h"
19 19
20/* To enable debug messages */ 20/* To enable debug messages */
21//#define ORINOCO_DEBUG 3 21/*#define ORINOCO_DEBUG 3*/
22 22
23#define WIRELESS_SPY // enable iwspy support 23#define WIRELESS_SPY /* enable iwspy support */
24 24
25#define MAX_SCAN_LEN 4096 25#define MAX_SCAN_LEN 4096
26 26
@@ -121,7 +121,7 @@ struct orinoco_private {
121 u16 encode_alg, wep_restrict, tx_key; 121 u16 encode_alg, wep_restrict, tx_key;
122 struct orinoco_key keys[ORINOCO_MAX_KEYS]; 122 struct orinoco_key keys[ORINOCO_MAX_KEYS];
123 int bitratemode; 123 int bitratemode;
124 char nick[IW_ESSID_MAX_SIZE+1]; 124 char nick[IW_ESSID_MAX_SIZE+1];
125 char desired_essid[IW_ESSID_MAX_SIZE+1]; 125 char desired_essid[IW_ESSID_MAX_SIZE+1];
126 char desired_bssid[ETH_ALEN]; 126 char desired_bssid[ETH_ALEN];
127 int bssid_fixed; 127 int bssid_fixed;
@@ -131,7 +131,7 @@ struct orinoco_private {
131 u16 pm_on, pm_mcast, pm_period, pm_timeout; 131 u16 pm_on, pm_mcast, pm_period, pm_timeout;
132 u16 preamble; 132 u16 preamble;
133#ifdef WIRELESS_SPY 133#ifdef WIRELESS_SPY
134 struct iw_spy_data spy_data; /* iwspy support */ 134 struct iw_spy_data spy_data; /* iwspy support */
135 struct iw_public_data wireless_data; 135 struct iw_public_data wireless_data;
136#endif 136#endif
137 137
@@ -168,7 +168,10 @@ struct orinoco_private {
168 168
169#ifdef ORINOCO_DEBUG 169#ifdef ORINOCO_DEBUG
170extern int orinoco_debug; 170extern int orinoco_debug;
171#define DEBUG(n, args...) do { if (orinoco_debug>(n)) printk(KERN_DEBUG args); } while(0) 171#define DEBUG(n, args...) do { \
172 if (orinoco_debug > (n)) \
173 printk(KERN_DEBUG args); \
174} while (0)
172#else 175#else
173#define DEBUG(n, args...) do { } while (0) 176#define DEBUG(n, args...) do { } while (0)
174#endif /* ORINOCO_DEBUG */ 177#endif /* ORINOCO_DEBUG */
@@ -185,7 +188,7 @@ extern void free_orinocodev(struct net_device *dev);
185extern int __orinoco_up(struct net_device *dev); 188extern int __orinoco_up(struct net_device *dev);
186extern int __orinoco_down(struct net_device *dev); 189extern int __orinoco_down(struct net_device *dev);
187extern int orinoco_reinit_firmware(struct net_device *dev); 190extern int orinoco_reinit_firmware(struct net_device *dev);
188extern irqreturn_t orinoco_interrupt(int irq, void * dev_id); 191extern irqreturn_t orinoco_interrupt(int irq, void *dev_id);
189 192
190/********************************************************************/ 193/********************************************************************/
191/* Locking and synchronization functions */ 194/* Locking and synchronization functions */
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index 0b32215d3f5d..d194b3e0311d 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -6,7 +6,7 @@
6 * It should also be usable on various Prism II based cards such as the 6 * It should also be usable on various Prism II based cards such as the
7 * Linksys, D-Link and Farallon Skyline. It should also work on Symbol 7 * Linksys, D-Link and Farallon Skyline. It should also work on Symbol
8 * cards such as the 3Com AirConnect and Ericsson WLAN. 8 * cards such as the 3Com AirConnect and Ericsson WLAN.
9 * 9 *
10 * Copyright notice & release notes in file orinoco.c 10 * Copyright notice & release notes in file orinoco.c
11 */ 11 */
12 12
@@ -30,7 +30,8 @@
30/********************************************************************/ 30/********************************************************************/
31 31
32MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>"); 32MODULE_AUTHOR("David Gibson <hermes@gibson.dropbear.id.au>");
33MODULE_DESCRIPTION("Driver for PCMCIA Lucent Orinoco, Prism II based and similar wireless cards"); 33MODULE_DESCRIPTION("Driver for PCMCIA Lucent Orinoco,"
34 " Prism II based and similar wireless cards");
34MODULE_LICENSE("Dual MPL/GPL"); 35MODULE_LICENSE("Dual MPL/GPL");
35 36
36/* Module parameters */ 37/* Module parameters */
@@ -53,8 +54,8 @@ struct orinoco_pccard {
53 54
54 /* Used to handle hard reset */ 55 /* Used to handle hard reset */
55 /* yuck, we need this hack to work around the insanity of the 56 /* yuck, we need this hack to work around the insanity of the
56 * PCMCIA layer */ 57 * PCMCIA layer */
57 unsigned long hard_reset_in_progress; 58 unsigned long hard_reset_in_progress;
58}; 59};
59 60
60 61
@@ -98,7 +99,7 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
98 * This creates an "instance" of the driver, allocating local data 99 * This creates an "instance" of the driver, allocating local data
99 * structures for one device. The device is registered with Card 100 * structures for one device. The device is registered with Card
100 * Services. 101 * Services.
101 * 102 *
102 * The dev_link structure is initialized, but we don't actually 103 * The dev_link structure is initialized, but we don't actually
103 * configure the card at this point -- we wait until we receive a card 104 * configure the card at this point -- we wait until we receive a card
104 * insertion event. */ 105 * insertion event. */
@@ -111,7 +112,7 @@ orinoco_cs_probe(struct pcmcia_device *link)
111 112
112 dev = alloc_orinocodev(sizeof(*card), &handle_to_dev(link), 113 dev = alloc_orinocodev(sizeof(*card), &handle_to_dev(link),
113 orinoco_cs_hard_reset, NULL); 114 orinoco_cs_hard_reset, NULL);
114 if (! dev) 115 if (!dev)
115 return -ENOMEM; 116 return -ENOMEM;
116 priv = netdev_priv(dev); 117 priv = netdev_priv(dev);
117 card = priv->card; 118 card = priv->card;
@@ -124,7 +125,7 @@ orinoco_cs_probe(struct pcmcia_device *link)
124 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; 125 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
125 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 126 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
126 link->irq.Handler = orinoco_interrupt; 127 link->irq.Handler = orinoco_interrupt;
127 link->irq.Instance = dev; 128 link->irq.Instance = dev;
128 129
129 /* General socket configuration defaults can go here. In this 130 /* General socket configuration defaults can go here. In this
130 * client, we assume very little, and rely on the CIS for 131 * client, we assume very little, and rely on the CIS for
@@ -162,8 +163,10 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
162 */ 163 */
163 164
164#define CS_CHECK(fn, ret) do { \ 165#define CS_CHECK(fn, ret) do { \
165 last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ 166 last_fn = (fn); \
166 } while (0) 167 if ((last_ret = (ret)) != 0) \
168 goto cs_failed; \
169} while (0)
167 170
168static int orinoco_cs_config_check(struct pcmcia_device *p_dev, 171static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
169 cistpl_cftable_entry_t *cfg, 172 cistpl_cftable_entry_t *cfg,
@@ -307,8 +310,8 @@ orinoco_cs_config(struct pcmcia_device *link)
307 * initialized and arranged in a linked list at link->dev_node. */ 310 * initialized and arranged in a linked list at link->dev_node. */
308 strcpy(card->node.dev_name, dev->name); 311 strcpy(card->node.dev_name, dev->name);
309 link->dev_node = &card->node; /* link->dev_node being non-NULL is also 312 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
310 used to indicate that the 313 * used to indicate that the
311 net_device has been registered */ 314 * net_device has been registered */
312 315
313 /* Finally, report what we've done */ 316 /* Finally, report what we've done */
314 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 317 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
@@ -359,7 +362,7 @@ static int orinoco_cs_suspend(struct pcmcia_device *link)
359 /* This is probably racy, but I can't think of 362 /* This is probably racy, but I can't think of
360 a better way, short of rewriting the PCMCIA 363 a better way, short of rewriting the PCMCIA
361 layer to not suck :-( */ 364 layer to not suck :-( */
362 if (! test_bit(0, &card->hard_reset_in_progress)) { 365 if (!test_bit(0, &card->hard_reset_in_progress)) {
363 spin_lock_irqsave(&priv->lock, flags); 366 spin_lock_irqsave(&priv->lock, flags);
364 367
365 err = __orinoco_down(dev); 368 err = __orinoco_down(dev);
@@ -384,7 +387,7 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
384 int err = 0; 387 int err = 0;
385 unsigned long flags; 388 unsigned long flags;
386 389
387 if (! test_bit(0, &card->hard_reset_in_progress)) { 390 if (!test_bit(0, &card->hard_reset_in_progress)) {
388 err = orinoco_reinit_firmware(dev); 391 err = orinoco_reinit_firmware(dev);
389 if (err) { 392 if (err) {
390 printk(KERN_ERR "%s: Error %d re-initializing firmware\n", 393 printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
@@ -397,7 +400,7 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
397 netif_device_attach(dev); 400 netif_device_attach(dev);
398 priv->hw_unavailable--; 401 priv->hw_unavailable--;
399 402
400 if (priv->open && ! priv->hw_unavailable) { 403 if (priv->open && !priv->hw_unavailable) {
401 err = __orinoco_up(dev); 404 err = __orinoco_up(dev);
402 if (err) 405 if (err)
403 printk(KERN_ERR "%s: Error %d restarting card\n", 406 printk(KERN_ERR "%s: Error %d restarting card\n",
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index 2fc86596302e..b01726255c6f 100644
--- a/drivers/net/wireless/orinoco/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
@@ -9,12 +9,12 @@
9 * 9 *
10 * Some of this code is borrowed from orinoco_plx.c 10 * Some of this code is borrowed from orinoco_plx.c
11 * Copyright (C) 2001 Daniel Barlow 11 * Copyright (C) 2001 Daniel Barlow
12 * Some of this code is borrowed from orinoco_pci.c 12 * Some of this code is borrowed from orinoco_pci.c
13 * Copyright (C) 2001 Jean Tourrilhes 13 * Copyright (C) 2001 Jean Tourrilhes
14 * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing 14 * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing
15 * has been copied from it. linux-wlan-ng-0.1.10 is originally : 15 * has been copied from it. linux-wlan-ng-0.1.10 is originally :
16 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. 16 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
17 * 17 *
18 * The contents of this file are subject to the Mozilla Public License 18 * The contents of this file are subject to the Mozilla Public License
19 * Version 1.1 (the "License"); you may not use this file except in 19 * Version 1.1 (the "License"); you may not use this file except in
20 * compliance with the License. You may obtain a copy of the License 20 * compliance with the License. You may obtain a copy of the License
@@ -103,9 +103,8 @@ static int orinoco_nortel_hw_init(struct orinoco_pci_card *card)
103 iowrite16(0x8, card->bridge_io + 2); 103 iowrite16(0x8, card->bridge_io + 2);
104 for (i = 0; i < 30; i++) { 104 for (i = 0; i < 30; i++) {
105 mdelay(30); 105 mdelay(30);
106 if (ioread16(card->bridge_io) & 0x10) { 106 if (ioread16(card->bridge_io) & 0x10)
107 break; 107 break;
108 }
109 } 108 }
110 if (i == 30) { 109 if (i == 30) {
111 printk(KERN_ERR PFX "brg1 timed out\n"); 110 printk(KERN_ERR PFX "brg1 timed out\n");
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index 4ebd638a073e..78cafff1fb2e 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
@@ -1,5 +1,5 @@
1/* orinoco_pci.c 1/* orinoco_pci.c
2 * 2 *
3 * Driver for Prism 2.5/3 devices that have a direct PCI interface 3 * Driver for Prism 2.5/3 devices that have a direct PCI interface
4 * (i.e. these are not PCMCIA cards in a PCMCIA-to-PCI bridge). 4 * (i.e. these are not PCMCIA cards in a PCMCIA-to-PCI bridge).
5 * The card contains only one PCI region, which contains all the usual 5 * The card contains only one PCI region, which contains all the usual
@@ -237,7 +237,8 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
237 " (Pavel Roskin <proski@gnu.org>," 237 " (Pavel Roskin <proski@gnu.org>,"
238 " David Gibson <hermes@gibson.dropbear.id.au> &" 238 " David Gibson <hermes@gibson.dropbear.id.au> &"
239 " Jean Tourrilhes <jt@hpl.hp.com>)"; 239 " Jean Tourrilhes <jt@hpl.hp.com>)";
240MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> & David Gibson <hermes@gibson.dropbear.id.au>"); 240MODULE_AUTHOR("Pavel Roskin <proski@gnu.org> &"
241 " David Gibson <hermes@gibson.dropbear.id.au>");
241MODULE_DESCRIPTION("Driver for wireless LAN cards using direct PCI interface"); 242MODULE_DESCRIPTION("Driver for wireless LAN cards using direct PCI interface");
242MODULE_LICENSE("Dual MPL/GPL"); 243MODULE_LICENSE("Dual MPL/GPL");
243 244
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.h b/drivers/net/wireless/orinoco/orinoco_pci.h
index f4e5e06760c1..88df3ee98078 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.h
+++ b/drivers/net/wireless/orinoco/orinoco_pci.h
@@ -1,5 +1,5 @@
1/* orinoco_pci.h 1/* orinoco_pci.h
2 * 2 *
3 * Common code for all Orinoco drivers for PCI devices, including 3 * Common code for all Orinoco drivers for PCI devices, including
4 * both native PCI and PCMCIA-to-PCI bridges. 4 * both native PCI and PCMCIA-to-PCI bridges.
5 * 5 *
@@ -37,11 +37,11 @@ static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state)
37 if (err) 37 if (err)
38 printk(KERN_WARNING "%s: error %d bringing interface down " 38 printk(KERN_WARNING "%s: error %d bringing interface down "
39 "for suspend\n", dev->name, err); 39 "for suspend\n", dev->name, err);
40 40
41 netif_device_detach(dev); 41 netif_device_detach(dev);
42 42
43 priv->hw_unavailable++; 43 priv->hw_unavailable++;
44 44
45 orinoco_unlock(priv, &flags); 45 orinoco_unlock(priv, &flags);
46 46
47 free_irq(pdev->irq, dev); 47 free_irq(pdev->irq, dev);
@@ -90,13 +90,13 @@ static int orinoco_pci_resume(struct pci_dev *pdev)
90 90
91 priv->hw_unavailable--; 91 priv->hw_unavailable--;
92 92
93 if (priv->open && (! priv->hw_unavailable)) { 93 if (priv->open && (!priv->hw_unavailable)) {
94 err = __orinoco_up(dev); 94 err = __orinoco_up(dev);
95 if (err) 95 if (err)
96 printk(KERN_ERR "%s: Error %d restarting card on resume\n", 96 printk(KERN_ERR "%s: Error %d restarting card on resume\n",
97 dev->name, err); 97 dev->name, err);
98 } 98 }
99 99
100 spin_unlock_irqrestore(&priv->lock, flags); 100 spin_unlock_irqrestore(&priv->lock, flags);
101 101
102 return 0; 102 return 0;
diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index ef761857bb38..a2a4471c0337 100644
--- a/drivers/net/wireless/orinoco/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
@@ -146,9 +146,8 @@ static int orinoco_plx_hw_init(struct orinoco_pci_card *card)
146 }; 146 };
147 147
148 printk(KERN_DEBUG PFX "CIS: "); 148 printk(KERN_DEBUG PFX "CIS: ");
149 for (i = 0; i < 16; i++) { 149 for (i = 0; i < 16; i++)
150 printk("%02X:", ioread8(card->attr_io + (i << 1))); 150 printk("%02X:", ioread8(card->attr_io + (i << 1)));
151 }
152 printk("\n"); 151 printk("\n");
153 152
154 /* Verify whether a supported PC card is present */ 153 /* Verify whether a supported PC card is present */
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index ede24ec309c0..e77c4042d43a 100644
--- a/drivers/net/wireless/orinoco/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
@@ -1,7 +1,7 @@
1/* orinoco_tmd.c 1/* orinoco_tmd.c
2 * 2 *
3 * Driver for Prism II devices which would usually be driven by orinoco_cs, 3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a TMD7160. 4 * but are connected to the PCI bus by a TMD7160.
5 * 5 *
6 * Copyright (C) 2003 Joerg Dorchain <joerg AT dorchain.net> 6 * Copyright (C) 2003 Joerg Dorchain <joerg AT dorchain.net>
7 * based heavily upon orinoco_plx.c Copyright (C) 2001 Daniel Barlow 7 * based heavily upon orinoco_plx.c Copyright (C) 2001 Daniel Barlow
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index b2ca2e39c2cb..9aefe19dbac2 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -133,7 +133,7 @@ spectrum_reset(struct pcmcia_device *link, int idle)
133 udelay(1000); 133 udelay(1000);
134 return 0; 134 return 0;
135 135
136 cs_failed: 136cs_failed:
137 cs_error(link, last_fn, last_ret); 137 cs_error(link, last_fn, last_ret);
138 return -ENODEV; 138 return -ENODEV;
139} 139}
@@ -171,7 +171,7 @@ spectrum_cs_stop_firmware(struct orinoco_private *priv, int idle)
171 * This creates an "instance" of the driver, allocating local data 171 * This creates an "instance" of the driver, allocating local data
172 * structures for one device. The device is registered with Card 172 * structures for one device. The device is registered with Card
173 * Services. 173 * Services.
174 * 174 *
175 * The dev_link structure is initialized, but we don't actually 175 * The dev_link structure is initialized, but we don't actually
176 * configure the card at this point -- we wait until we receive a card 176 * configure the card at this point -- we wait until we receive a card
177 * insertion event. */ 177 * insertion event. */
@@ -185,7 +185,7 @@ spectrum_cs_probe(struct pcmcia_device *link)
185 dev = alloc_orinocodev(sizeof(*card), &handle_to_dev(link), 185 dev = alloc_orinocodev(sizeof(*card), &handle_to_dev(link),
186 spectrum_cs_hard_reset, 186 spectrum_cs_hard_reset,
187 spectrum_cs_stop_firmware); 187 spectrum_cs_stop_firmware);
188 if (! dev) 188 if (!dev)
189 return -ENOMEM; 189 return -ENOMEM;
190 priv = netdev_priv(dev); 190 priv = netdev_priv(dev);
191 card = priv->card; 191 card = priv->card;
@@ -198,7 +198,7 @@ spectrum_cs_probe(struct pcmcia_device *link)
198 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; 198 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
199 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 199 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
200 link->irq.Handler = orinoco_interrupt; 200 link->irq.Handler = orinoco_interrupt;
201 link->irq.Instance = dev; 201 link->irq.Instance = dev;
202 202
203 /* General socket configuration defaults can go here. In this 203 /* General socket configuration defaults can go here. In this
204 * client, we assume very little, and rely on the CIS for 204 * client, we assume very little, and rely on the CIS for
@@ -367,9 +367,8 @@ spectrum_cs_config(struct pcmcia_device *link)
367 card->node.major = card->node.minor = 0; 367 card->node.major = card->node.minor = 0;
368 368
369 /* Reset card */ 369 /* Reset card */
370 if (spectrum_cs_hard_reset(priv) != 0) { 370 if (spectrum_cs_hard_reset(priv) != 0)
371 goto failed; 371 goto failed;
372 }
373 372
374 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 373 SET_NETDEV_DEV(dev, &handle_to_dev(link));
375 /* Tell the stack we exist */ 374 /* Tell the stack we exist */
@@ -382,8 +381,8 @@ spectrum_cs_config(struct pcmcia_device *link)
382 * initialized and arranged in a linked list at link->dev_node. */ 381 * initialized and arranged in a linked list at link->dev_node. */
383 strcpy(card->node.dev_name, dev->name); 382 strcpy(card->node.dev_name, dev->name);
384 link->dev_node = &card->node; /* link->dev_node being non-NULL is also 383 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
385 used to indicate that the 384 * used to indicate that the
386 net_device has been registered */ 385 * net_device has been registered */
387 386
388 /* Finally, report what we've done */ 387 /* Finally, report what we've done */
389 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " 388 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 4a2c0b971ca8..b0848259b455 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -934,21 +934,10 @@ static int rt2400pci_enable_radio(struct rt2x00_dev *rt2x00dev)
934 934
935static void rt2400pci_disable_radio(struct rt2x00_dev *rt2x00dev) 935static void rt2400pci_disable_radio(struct rt2x00_dev *rt2x00dev)
936{ 936{
937 u32 reg;
938
939 rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0);
940
941 /* 937 /*
942 * Disable synchronisation. 938 * Disable power
943 */ 939 */
944 rt2x00pci_register_write(rt2x00dev, CSR14, 0); 940 rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0);
945
946 /*
947 * Cancel RX and TX.
948 */
949 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
950 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
951 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
952} 941}
953 942
954static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev, 943static int rt2400pci_set_state(struct rt2x00_dev *rt2x00dev,
@@ -1145,6 +1134,20 @@ static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1145 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); 1134 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1146} 1135}
1147 1136
1137static void rt2400pci_kill_tx_queue(struct rt2x00_dev *rt2x00dev,
1138 const enum data_queue_qid qid)
1139{
1140 u32 reg;
1141
1142 if (qid == QID_BEACON) {
1143 rt2x00pci_register_write(rt2x00dev, CSR14, 0);
1144 } else {
1145 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1146 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1147 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1148 }
1149}
1150
1148/* 1151/*
1149 * RX control handlers 1152 * RX control handlers
1150 */ 1153 */
@@ -1606,6 +1609,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1606 .write_tx_data = rt2x00pci_write_tx_data, 1609 .write_tx_data = rt2x00pci_write_tx_data,
1607 .write_beacon = rt2400pci_write_beacon, 1610 .write_beacon = rt2400pci_write_beacon,
1608 .kick_tx_queue = rt2400pci_kick_tx_queue, 1611 .kick_tx_queue = rt2400pci_kick_tx_queue,
1612 .kill_tx_queue = rt2400pci_kill_tx_queue,
1609 .fill_rxdone = rt2400pci_fill_rxdone, 1613 .fill_rxdone = rt2400pci_fill_rxdone,
1610 .config_filter = rt2400pci_config_filter, 1614 .config_filter = rt2400pci_config_filter,
1611 .config_intf = rt2400pci_config_intf, 1615 .config_intf = rt2400pci_config_intf,
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index b9104e28bc2e..eb82860c54f9 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1093,21 +1093,10 @@ static int rt2500pci_enable_radio(struct rt2x00_dev *rt2x00dev)
1093 1093
1094static void rt2500pci_disable_radio(struct rt2x00_dev *rt2x00dev) 1094static void rt2500pci_disable_radio(struct rt2x00_dev *rt2x00dev)
1095{ 1095{
1096 u32 reg;
1097
1098 rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0);
1099
1100 /* 1096 /*
1101 * Disable synchronisation. 1097 * Disable power
1102 */ 1098 */
1103 rt2x00pci_register_write(rt2x00dev, CSR14, 0); 1099 rt2x00pci_register_write(rt2x00dev, PWRCSR0, 0);
1104
1105 /*
1106 * Cancel RX and TX.
1107 */
1108 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1109 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1110 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1111} 1100}
1112 1101
1113static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev, 1102static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
@@ -1303,6 +1292,20 @@ static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1303 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); 1292 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1304} 1293}
1305 1294
1295static void rt2500pci_kill_tx_queue(struct rt2x00_dev *rt2x00dev,
1296 const enum data_queue_qid qid)
1297{
1298 u32 reg;
1299
1300 if (qid == QID_BEACON) {
1301 rt2x00pci_register_write(rt2x00dev, CSR14, 0);
1302 } else {
1303 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1304 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1305 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1306 }
1307}
1308
1306/* 1309/*
1307 * RX control handlers 1310 * RX control handlers
1308 */ 1311 */
@@ -1905,6 +1908,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
1905 .write_tx_data = rt2x00pci_write_tx_data, 1908 .write_tx_data = rt2x00pci_write_tx_data,
1906 .write_beacon = rt2500pci_write_beacon, 1909 .write_beacon = rt2500pci_write_beacon,
1907 .kick_tx_queue = rt2500pci_kick_tx_queue, 1910 .kick_tx_queue = rt2500pci_kick_tx_queue,
1911 .kill_tx_queue = rt2500pci_kill_tx_queue,
1908 .fill_rxdone = rt2500pci_fill_rxdone, 1912 .fill_rxdone = rt2500pci_fill_rxdone,
1909 .config_filter = rt2500pci_config_filter, 1913 .config_filter = rt2500pci_config_filter,
1910 .config_intf = rt2500pci_config_intf, 1914 .config_intf = rt2500pci_config_intf,
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index c526e737fcad..270691ac2361 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1935,6 +1935,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1935 .write_beacon = rt2500usb_write_beacon, 1935 .write_beacon = rt2500usb_write_beacon,
1936 .get_tx_data_len = rt2500usb_get_tx_data_len, 1936 .get_tx_data_len = rt2500usb_get_tx_data_len,
1937 .kick_tx_queue = rt2500usb_kick_tx_queue, 1937 .kick_tx_queue = rt2500usb_kick_tx_queue,
1938 .kill_tx_queue = rt2x00usb_kill_tx_queue,
1938 .fill_rxdone = rt2500usb_fill_rxdone, 1939 .fill_rxdone = rt2500usb_fill_rxdone,
1939 .config_shared_key = rt2500usb_config_key, 1940 .config_shared_key = rt2500usb_config_key,
1940 .config_pairwise_key = rt2500usb_config_key, 1941 .config_pairwise_key = rt2500usb_config_key,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index d0a825638188..84bd6f19acb0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -468,9 +468,10 @@ struct rt2x00lib_ops {
468 */ 468 */
469 int (*probe_hw) (struct rt2x00_dev *rt2x00dev); 469 int (*probe_hw) (struct rt2x00_dev *rt2x00dev);
470 char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev); 470 char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev);
471 u16 (*get_firmware_crc) (const void *data, const size_t len); 471 int (*check_firmware) (struct rt2x00_dev *rt2x00dev,
472 int (*load_firmware) (struct rt2x00_dev *rt2x00dev, const void *data, 472 const u8 *data, const size_t len);
473 const size_t len); 473 int (*load_firmware) (struct rt2x00_dev *rt2x00dev,
474 const u8 *data, const size_t len);
474 475
475 /* 476 /*
476 * Device initialization/deinitialization handlers. 477 * Device initialization/deinitialization handlers.
@@ -508,6 +509,8 @@ struct rt2x00lib_ops {
508 int (*get_tx_data_len) (struct queue_entry *entry); 509 int (*get_tx_data_len) (struct queue_entry *entry);
509 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, 510 void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
510 const enum data_queue_qid queue); 511 const enum data_queue_qid queue);
512 void (*kill_tx_queue) (struct rt2x00_dev *rt2x00dev,
513 const enum data_queue_qid queue);
511 514
512 /* 515 /*
513 * RX control handlers 516 * RX control handlers
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index e1b40545a9be..05f94e21b423 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -83,9 +83,10 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
83 return; 83 return;
84 84
85 /* 85 /*
86 * Stop the TX queues. 86 * Stop the TX queues in mac80211.
87 */ 87 */
88 ieee80211_stop_queues(rt2x00dev->hw); 88 ieee80211_stop_queues(rt2x00dev->hw);
89 rt2x00queue_stop_queues(rt2x00dev);
89 90
90 /* 91 /*
91 * Disable RX. 92 * Disable RX.
@@ -157,7 +158,7 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
157 return; 158 return;
158 159
159 if (delayed_flags & DELAYED_UPDATE_BEACON) 160 if (delayed_flags & DELAYED_UPDATE_BEACON)
160 rt2x00queue_update_beacon(rt2x00dev, vif); 161 rt2x00queue_update_beacon(rt2x00dev, vif, true);
161 162
162 if (delayed_flags & DELAYED_CONFIG_ERP) 163 if (delayed_flags & DELAYED_CONFIG_ERP)
163 rt2x00lib_config_erp(rt2x00dev, intf, &conf); 164 rt2x00lib_config_erp(rt2x00dev, intf, &conf);
@@ -215,7 +216,7 @@ void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev)
215 rt2x00lib_beacondone_iter, 216 rt2x00lib_beacondone_iter,
216 rt2x00dev); 217 rt2x00dev);
217 218
218 schedule_work(&rt2x00dev->intf_work); 219 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->intf_work);
219} 220}
220EXPORT_SYMBOL_GPL(rt2x00lib_beacondone); 221EXPORT_SYMBOL_GPL(rt2x00lib_beacondone);
221 222
diff --git a/drivers/net/wireless/rt2x00/rt2x00firmware.c b/drivers/net/wireless/rt2x00/rt2x00firmware.c
index 2a7e8bc0016b..d2deea2f2679 100644
--- a/drivers/net/wireless/rt2x00/rt2x00firmware.c
+++ b/drivers/net/wireless/rt2x00/rt2x00firmware.c
@@ -35,7 +35,6 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
35 const struct firmware *fw; 35 const struct firmware *fw;
36 char *fw_name; 36 char *fw_name;
37 int retval; 37 int retval;
38 u16 crc;
39 38
40 /* 39 /*
41 * Read correct firmware from harddisk. 40 * Read correct firmware from harddisk.
@@ -61,16 +60,26 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
61 return -ENOENT; 60 return -ENOENT;
62 } 61 }
63 62
64 crc = rt2x00dev->ops->lib->get_firmware_crc(fw->data, fw->size);
65 if (crc != (fw->data[fw->size - 2] << 8 | fw->data[fw->size - 1])) {
66 ERROR(rt2x00dev, "Firmware checksum error.\n");
67 retval = -ENOENT;
68 goto exit;
69 }
70
71 INFO(rt2x00dev, "Firmware detected - version: %d.%d.\n", 63 INFO(rt2x00dev, "Firmware detected - version: %d.%d.\n",
72 fw->data[fw->size - 4], fw->data[fw->size - 3]); 64 fw->data[fw->size - 4], fw->data[fw->size - 3]);
73 65
66 retval = rt2x00dev->ops->lib->check_firmware(rt2x00dev, fw->data, fw->size);
67 switch (retval) {
68 case FW_OK:
69 break;
70 case FW_BAD_CRC:
71 ERROR(rt2x00dev, "Firmware checksum error.\n");
72 goto exit;
73 case FW_BAD_LENGTH:
74 ERROR(rt2x00dev,
75 "Invalid firmware file length (len=%zu)\n", fw->size);
76 goto exit;
77 case FW_BAD_VERSION:
78 ERROR(rt2x00dev,
79 "Current firmware does not support detected chipset.\n");
80 goto exit;
81 };
82
74 rt2x00dev->fw = fw; 83 rt2x00dev->fw = fw;
75 84
76 return 0; 85 return 0;
@@ -78,7 +87,7 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
78exit: 87exit:
79 release_firmware(fw); 88 release_firmware(fw);
80 89
81 return retval; 90 return -ENOENT;
82} 91}
83 92
84int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev) 93int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev)
diff --git a/drivers/net/wireless/rt2x00/rt2x00leds.c b/drivers/net/wireless/rt2x00/rt2x00leds.c
index 9b531e0ca0cd..49671fed91d7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00leds.c
+++ b/drivers/net/wireless/rt2x00/rt2x00leds.c
@@ -134,7 +134,7 @@ void rt2x00leds_register(struct rt2x00_dev *rt2x00dev)
134 rt2x00dev->ops->name, wiphy_name(rt2x00dev->hw->wiphy)); 134 rt2x00dev->ops->name, wiphy_name(rt2x00dev->hw->wiphy));
135 135
136 if (rt2x00dev->led_radio.flags & LED_INITIALIZED) { 136 if (rt2x00dev->led_radio.flags & LED_INITIALIZED) {
137 snprintf(name, sizeof(name), "%s:radio", dev_name); 137 snprintf(name, sizeof(name), "%s::radio", dev_name);
138 138
139 retval = rt2x00leds_register_led(rt2x00dev, 139 retval = rt2x00leds_register_led(rt2x00dev,
140 &rt2x00dev->led_radio, 140 &rt2x00dev->led_radio,
@@ -144,7 +144,7 @@ void rt2x00leds_register(struct rt2x00_dev *rt2x00dev)
144 } 144 }
145 145
146 if (rt2x00dev->led_assoc.flags & LED_INITIALIZED) { 146 if (rt2x00dev->led_assoc.flags & LED_INITIALIZED) {
147 snprintf(name, sizeof(name), "%s:assoc", dev_name); 147 snprintf(name, sizeof(name), "%s::assoc", dev_name);
148 148
149 retval = rt2x00leds_register_led(rt2x00dev, 149 retval = rt2x00leds_register_led(rt2x00dev,
150 &rt2x00dev->led_assoc, 150 &rt2x00dev->led_assoc,
@@ -154,7 +154,7 @@ void rt2x00leds_register(struct rt2x00_dev *rt2x00dev)
154 } 154 }
155 155
156 if (rt2x00dev->led_qual.flags & LED_INITIALIZED) { 156 if (rt2x00dev->led_qual.flags & LED_INITIALIZED) {
157 snprintf(name, sizeof(name), "%s:quality", dev_name); 157 snprintf(name, sizeof(name), "%s::quality", dev_name);
158 158
159 retval = rt2x00leds_register_led(rt2x00dev, 159 retval = rt2x00leds_register_led(rt2x00dev,
160 &rt2x00dev->led_qual, 160 &rt2x00dev->led_qual,
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 34efe4653549..a631613177d0 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -123,9 +123,11 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb);
123 * rt2x00queue_update_beacon - Send new beacon from mac80211 to hardware 123 * rt2x00queue_update_beacon - Send new beacon from mac80211 to hardware
124 * @rt2x00dev: Pointer to &struct rt2x00_dev. 124 * @rt2x00dev: Pointer to &struct rt2x00_dev.
125 * @vif: Interface for which the beacon should be updated. 125 * @vif: Interface for which the beacon should be updated.
126 * @enable_beacon: Enable beaconing
126 */ 127 */
127int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, 128int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
128 struct ieee80211_vif *vif); 129 struct ieee80211_vif *vif,
130 const bool enable_beacon);
129 131
130/** 132/**
131 * rt2x00queue_index_inc - Index incrementation function 133 * rt2x00queue_index_inc - Index incrementation function
@@ -139,6 +141,15 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
139void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index); 141void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index);
140 142
141/** 143/**
144 * rt2x00queue_stop_queues - Halt all data queues
145 * @rt2x00dev: Pointer to &struct rt2x00_dev.
146 *
147 * This function will loop through all available queues to stop
148 * any pending outgoing frames.
149 */
150void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev);
151
152/**
142 * rt2x00queue_init_queues - Initialize all data queues 153 * rt2x00queue_init_queues - Initialize all data queues
143 * @rt2x00dev: Pointer to &struct rt2x00_dev. 154 * @rt2x00dev: Pointer to &struct rt2x00_dev.
144 * 155 *
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 71de8a7144f9..c41a0b9e473d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -431,8 +431,10 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
431 /* 431 /*
432 * Update the beacon. 432 * Update the beacon.
433 */ 433 */
434 if (conf->changed & IEEE80211_IFCC_BEACON) 434 if (conf->changed & (IEEE80211_IFCC_BEACON |
435 status = rt2x00queue_update_beacon(rt2x00dev, vif); 435 IEEE80211_IFCC_BEACON_ENABLED))
436 status = rt2x00queue_update_beacon(rt2x00dev, vif,
437 conf->enable_beacon);
436 438
437 return status; 439 return status;
438} 440}
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index c86fb6471754..a5664bd8493e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -443,7 +443,8 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
443} 443}
444 444
445int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, 445int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
446 struct ieee80211_vif *vif) 446 struct ieee80211_vif *vif,
447 const bool enable_beacon)
447{ 448{
448 struct rt2x00_intf *intf = vif_to_intf(vif); 449 struct rt2x00_intf *intf = vif_to_intf(vif);
449 struct skb_frame_desc *skbdesc; 450 struct skb_frame_desc *skbdesc;
@@ -453,6 +454,11 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
453 if (unlikely(!intf->beacon)) 454 if (unlikely(!intf->beacon))
454 return -ENOBUFS; 455 return -ENOBUFS;
455 456
457 if (!enable_beacon) {
458 rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev, QID_BEACON);
459 return 0;
460 }
461
456 intf->beacon->skb = ieee80211_beacon_get(rt2x00dev->hw, vif); 462 intf->beacon->skb = ieee80211_beacon_get(rt2x00dev->hw, vif);
457 if (!intf->beacon->skb) 463 if (!intf->beacon->skb)
458 return -ENOMEM; 464 return -ENOMEM;
@@ -501,6 +507,9 @@ struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
501{ 507{
502 int atim = test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags); 508 int atim = test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
503 509
510 if (queue == QID_RX)
511 return rt2x00dev->rx;
512
504 if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx) 513 if (queue < rt2x00dev->ops->tx_queues && rt2x00dev->tx)
505 return &rt2x00dev->tx[queue]; 514 return &rt2x00dev->tx[queue];
506 515
@@ -577,6 +586,14 @@ static void rt2x00queue_reset(struct data_queue *queue)
577 spin_unlock_irqrestore(&queue->lock, irqflags); 586 spin_unlock_irqrestore(&queue->lock, irqflags);
578} 587}
579 588
589void rt2x00queue_stop_queues(struct rt2x00_dev *rt2x00dev)
590{
591 struct data_queue *queue;
592
593 txall_queue_for_each(rt2x00dev, queue)
594 rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev, queue->qid);
595}
596
580void rt2x00queue_init_queues(struct rt2x00_dev *rt2x00dev) 597void rt2x00queue_init_queues(struct rt2x00_dev *rt2x00dev)
581{ 598{
582 struct data_queue *queue; 599 struct data_queue *queue;
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h
index 9ddc2d07eef8..861322d97fce 100644
--- a/drivers/net/wireless/rt2x00/rt2x00reg.h
+++ b/drivers/net/wireless/rt2x00/rt2x00reg.h
@@ -135,6 +135,16 @@ enum rate_modulation {
135}; 135};
136 136
137/* 137/*
138 * Firmware validation error codes
139 */
140enum firmware_errors {
141 FW_OK,
142 FW_BAD_CRC,
143 FW_BAD_LENGTH,
144 FW_BAD_VERSION,
145};
146
147/*
138 * Register handlers. 148 * Register handlers.
139 * We store the position of a register field inside a field structure, 149 * We store the position of a register field inside a field structure,
140 * This will simplify the process of setting and reading a certain field 150 * This will simplify the process of setting and reading a certain field
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index c89d1520838c..7d50ca82375e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -296,6 +296,41 @@ void rt2x00usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
296} 296}
297EXPORT_SYMBOL_GPL(rt2x00usb_kick_tx_queue); 297EXPORT_SYMBOL_GPL(rt2x00usb_kick_tx_queue);
298 298
299void rt2x00usb_kill_tx_queue(struct rt2x00_dev *rt2x00dev,
300 const enum data_queue_qid qid)
301{
302 struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, qid);
303 struct queue_entry_priv_usb *entry_priv;
304 struct queue_entry_priv_usb_bcn *bcn_priv;
305 unsigned int i;
306 bool kill_guard;
307
308 /*
309 * When killing the beacon queue, we must also kill
310 * the beacon guard byte.
311 */
312 kill_guard =
313 (qid == QID_BEACON) &&
314 (test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags));
315
316 /*
317 * Cancel all entries.
318 */
319 for (i = 0; i < queue->limit; i++) {
320 entry_priv = queue->entries[i].priv_data;
321 usb_kill_urb(entry_priv->urb);
322
323 /*
324 * Kill guardian urb (if required by driver).
325 */
326 if (kill_guard) {
327 bcn_priv = queue->entries[i].priv_data;
328 usb_kill_urb(bcn_priv->guardian_urb);
329 }
330 }
331}
332EXPORT_SYMBOL_GPL(rt2x00usb_kill_tx_queue);
333
299/* 334/*
300 * RX data handlers. 335 * RX data handlers.
301 */ 336 */
@@ -338,35 +373,14 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
338 */ 373 */
339void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev) 374void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev)
340{ 375{
341 struct queue_entry_priv_usb *entry_priv;
342 struct queue_entry_priv_usb_bcn *bcn_priv;
343 struct data_queue *queue;
344 unsigned int i;
345
346 rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0, 376 rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0,
347 REGISTER_TIMEOUT); 377 REGISTER_TIMEOUT);
348 378
349 /* 379 /*
350 * Cancel all queues. 380 * The USB version of kill_tx_queue also works
381 * on the RX queue.
351 */ 382 */
352 queue_for_each(rt2x00dev, queue) { 383 rt2x00dev->ops->lib->kill_tx_queue(rt2x00dev, QID_RX);
353 for (i = 0; i < queue->limit; i++) {
354 entry_priv = queue->entries[i].priv_data;
355 usb_kill_urb(entry_priv->urb);
356 }
357 }
358
359 /*
360 * Kill guardian urb (if required by driver).
361 */
362 if (!test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags))
363 return;
364
365 for (i = 0; i < rt2x00dev->bcn->limit; i++) {
366 bcn_priv = rt2x00dev->bcn->entries[i].priv_data;
367 if (bcn_priv->guardian_urb)
368 usb_kill_urb(bcn_priv->guardian_urb);
369 }
370} 384}
371EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio); 385EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio);
372 386
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
index fe4523887bdf..bd2d59c85f1b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.h
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -419,6 +419,17 @@ struct queue_entry_priv_usb_bcn {
419void rt2x00usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev, 419void rt2x00usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
420 const enum data_queue_qid qid); 420 const enum data_queue_qid qid);
421 421
422/**
423 * rt2x00usb_kill_tx_queue - Kill data queue
424 * @rt2x00dev: Pointer to &struct rt2x00_dev
425 * @qid: Data queue to kill
426 *
427 * This will walk through all entries of the queue and kill all
428 * previously kicked frames before they can be send.
429 */
430void rt2x00usb_kill_tx_queue(struct rt2x00_dev *rt2x00dev,
431 const enum data_queue_qid qid);
432
422/* 433/*
423 * Device initialization handlers. 434 * Device initialization handlers.
424 */ 435 */
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index d81a8de9dc17..0be147f364e7 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1176,34 +1176,41 @@ static char *rt61pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
1176 return fw_name; 1176 return fw_name;
1177} 1177}
1178 1178
1179static u16 rt61pci_get_firmware_crc(const void *data, const size_t len) 1179static int rt61pci_check_firmware(struct rt2x00_dev *rt2x00dev,
1180 const u8 *data, const size_t len)
1180{ 1181{
1182 u16 fw_crc;
1181 u16 crc; 1183 u16 crc;
1182 1184
1183 /* 1185 /*
1184 * Use the crc itu-t algorithm. 1186 * Only support 8kb firmware files.
1187 */
1188 if (len != 8192)
1189 return FW_BAD_LENGTH;
1190
1191 /*
1185 * The last 2 bytes in the firmware array are the crc checksum itself, 1192 * The last 2 bytes in the firmware array are the crc checksum itself,
1186 * this means that we should never pass those 2 bytes to the crc 1193 * this means that we should never pass those 2 bytes to the crc
1187 * algorithm. 1194 * algorithm.
1188 */ 1195 */
1196 fw_crc = (data[len - 2] << 8 | data[len - 1]);
1197
1198 /*
1199 * Use the crc itu-t algorithm.
1200 */
1189 crc = crc_itu_t(0, data, len - 2); 1201 crc = crc_itu_t(0, data, len - 2);
1190 crc = crc_itu_t_byte(crc, 0); 1202 crc = crc_itu_t_byte(crc, 0);
1191 crc = crc_itu_t_byte(crc, 0); 1203 crc = crc_itu_t_byte(crc, 0);
1192 1204
1193 return crc; 1205 return (fw_crc == crc) ? FW_OK : FW_BAD_CRC;
1194} 1206}
1195 1207
1196static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev, const void *data, 1208static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev,
1197 const size_t len) 1209 const u8 *data, const size_t len)
1198{ 1210{
1199 int i; 1211 int i;
1200 u32 reg; 1212 u32 reg;
1201 1213
1202 if (len != 8192) {
1203 ERROR(rt2x00dev, "Invalid firmware file length (len=%zu)\n", len);
1204 return -ENOENT;
1205 }
1206
1207 /* 1214 /*
1208 * Wait for stable hardware. 1215 * Wait for stable hardware.
1209 */ 1216 */
@@ -1696,24 +1703,10 @@ static int rt61pci_enable_radio(struct rt2x00_dev *rt2x00dev)
1696 1703
1697static void rt61pci_disable_radio(struct rt2x00_dev *rt2x00dev) 1704static void rt61pci_disable_radio(struct rt2x00_dev *rt2x00dev)
1698{ 1705{
1699 u32 reg;
1700
1701 rt2x00pci_register_write(rt2x00dev, MAC_CSR10, 0x00001818);
1702
1703 /*
1704 * Disable synchronisation.
1705 */
1706 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, 0);
1707
1708 /* 1706 /*
1709 * Cancel RX and TX. 1707 * Disable power
1710 */ 1708 */
1711 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg); 1709 rt2x00pci_register_write(rt2x00dev, MAC_CSR10, 0x00001818);
1712 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC0, 1);
1713 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC1, 1);
1714 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, 1);
1715 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, 1);
1716 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1717} 1710}
1718 1711
1719static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state) 1712static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
@@ -1936,6 +1929,24 @@ static void rt61pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1936 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg); 1929 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1937} 1930}
1938 1931
1932static void rt61pci_kill_tx_queue(struct rt2x00_dev *rt2x00dev,
1933 const enum data_queue_qid qid)
1934{
1935 u32 reg;
1936
1937 if (qid == QID_BEACON) {
1938 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, 0);
1939 return;
1940 }
1941
1942 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1943 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC0, (qid == QID_AC_BE));
1944 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC1, (qid == QID_AC_BK));
1945 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, (qid == QID_AC_VI));
1946 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, (qid == QID_AC_VO));
1947 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1948}
1949
1939/* 1950/*
1940 * RX control handlers 1951 * RX control handlers
1941 */ 1952 */
@@ -2746,7 +2757,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2746 .irq_handler = rt61pci_interrupt, 2757 .irq_handler = rt61pci_interrupt,
2747 .probe_hw = rt61pci_probe_hw, 2758 .probe_hw = rt61pci_probe_hw,
2748 .get_firmware_name = rt61pci_get_firmware_name, 2759 .get_firmware_name = rt61pci_get_firmware_name,
2749 .get_firmware_crc = rt61pci_get_firmware_crc, 2760 .check_firmware = rt61pci_check_firmware,
2750 .load_firmware = rt61pci_load_firmware, 2761 .load_firmware = rt61pci_load_firmware,
2751 .initialize = rt2x00pci_initialize, 2762 .initialize = rt2x00pci_initialize,
2752 .uninitialize = rt2x00pci_uninitialize, 2763 .uninitialize = rt2x00pci_uninitialize,
@@ -2761,6 +2772,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2761 .write_tx_data = rt2x00pci_write_tx_data, 2772 .write_tx_data = rt2x00pci_write_tx_data,
2762 .write_beacon = rt61pci_write_beacon, 2773 .write_beacon = rt61pci_write_beacon,
2763 .kick_tx_queue = rt61pci_kick_tx_queue, 2774 .kick_tx_queue = rt61pci_kick_tx_queue,
2775 .kill_tx_queue = rt61pci_kill_tx_queue,
2764 .fill_rxdone = rt61pci_fill_rxdone, 2776 .fill_rxdone = rt61pci_fill_rxdone,
2765 .config_shared_key = rt61pci_config_shared_key, 2777 .config_shared_key = rt61pci_config_shared_key,
2766 .config_pairwise_key = rt61pci_config_pairwise_key, 2778 .config_pairwise_key = rt61pci_config_pairwise_key,
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index f854551be75d..6521dac7ec4a 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -1061,35 +1061,42 @@ static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
1061 return FIRMWARE_RT2571; 1061 return FIRMWARE_RT2571;
1062} 1062}
1063 1063
1064static u16 rt73usb_get_firmware_crc(const void *data, const size_t len) 1064static int rt73usb_check_firmware(struct rt2x00_dev *rt2x00dev,
1065 const u8 *data, const size_t len)
1065{ 1066{
1067 u16 fw_crc;
1066 u16 crc; 1068 u16 crc;
1067 1069
1068 /* 1070 /*
1069 * Use the crc itu-t algorithm. 1071 * Only support 2kb firmware files.
1072 */
1073 if (len != 2048)
1074 return FW_BAD_LENGTH;
1075
1076 /*
1070 * The last 2 bytes in the firmware array are the crc checksum itself, 1077 * The last 2 bytes in the firmware array are the crc checksum itself,
1071 * this means that we should never pass those 2 bytes to the crc 1078 * this means that we should never pass those 2 bytes to the crc
1072 * algorithm. 1079 * algorithm.
1073 */ 1080 */
1081 fw_crc = (data[len - 2] << 8 | data[len - 1]);
1082
1083 /*
1084 * Use the crc itu-t algorithm.
1085 */
1074 crc = crc_itu_t(0, data, len - 2); 1086 crc = crc_itu_t(0, data, len - 2);
1075 crc = crc_itu_t_byte(crc, 0); 1087 crc = crc_itu_t_byte(crc, 0);
1076 crc = crc_itu_t_byte(crc, 0); 1088 crc = crc_itu_t_byte(crc, 0);
1077 1089
1078 return crc; 1090 return (fw_crc == crc) ? FW_OK : FW_BAD_CRC;
1079} 1091}
1080 1092
1081static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, const void *data, 1093static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev,
1082 const size_t len) 1094 const u8 *data, const size_t len)
1083{ 1095{
1084 unsigned int i; 1096 unsigned int i;
1085 int status; 1097 int status;
1086 u32 reg; 1098 u32 reg;
1087 1099
1088 if (len != 2048) {
1089 ERROR(rt2x00dev, "Invalid firmware file length (len=%zu)\n", len);
1090 return -ENOENT;
1091 }
1092
1093 /* 1100 /*
1094 * Wait for stable hardware. 1101 * Wait for stable hardware.
1095 */ 1102 */
@@ -2278,7 +2285,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
2278static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { 2285static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2279 .probe_hw = rt73usb_probe_hw, 2286 .probe_hw = rt73usb_probe_hw,
2280 .get_firmware_name = rt73usb_get_firmware_name, 2287 .get_firmware_name = rt73usb_get_firmware_name,
2281 .get_firmware_crc = rt73usb_get_firmware_crc, 2288 .check_firmware = rt73usb_check_firmware,
2282 .load_firmware = rt73usb_load_firmware, 2289 .load_firmware = rt73usb_load_firmware,
2283 .initialize = rt2x00usb_initialize, 2290 .initialize = rt2x00usb_initialize,
2284 .uninitialize = rt2x00usb_uninitialize, 2291 .uninitialize = rt2x00usb_uninitialize,
@@ -2293,6 +2300,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2293 .write_beacon = rt73usb_write_beacon, 2300 .write_beacon = rt73usb_write_beacon,
2294 .get_tx_data_len = rt73usb_get_tx_data_len, 2301 .get_tx_data_len = rt73usb_get_tx_data_len,
2295 .kick_tx_queue = rt73usb_kick_tx_queue, 2302 .kick_tx_queue = rt73usb_kick_tx_queue,
2303 .kill_tx_queue = rt2x00usb_kill_tx_queue,
2296 .fill_rxdone = rt73usb_fill_rxdone, 2304 .fill_rxdone = rt73usb_fill_rxdone,
2297 .config_shared_key = rt73usb_config_shared_key, 2305 .config_shared_key = rt73usb_config_shared_key,
2298 .config_pairwise_key = rt73usb_config_pairwise_key, 2306 .config_pairwise_key = rt73usb_config_pairwise_key,
@@ -2360,6 +2368,7 @@ static struct usb_device_id rt73usb_device_table[] = {
2360 /* Billionton */ 2368 /* Billionton */
2361 { USB_DEVICE(0x1631, 0xc019), USB_DEVICE_DATA(&rt73usb_ops) }, 2369 { USB_DEVICE(0x1631, 0xc019), USB_DEVICE_DATA(&rt73usb_ops) },
2362 /* Buffalo */ 2370 /* Buffalo */
2371 { USB_DEVICE(0x0411, 0x00d8), USB_DEVICE_DATA(&rt73usb_ops) },
2363 { USB_DEVICE(0x0411, 0x00f4), USB_DEVICE_DATA(&rt73usb_ops) }, 2372 { USB_DEVICE(0x0411, 0x00f4), USB_DEVICE_DATA(&rt73usb_ops) },
2364 /* CNet */ 2373 /* CNet */
2365 { USB_DEVICE(0x1371, 0x9022), USB_DEVICE_DATA(&rt73usb_ops) }, 2374 { USB_DEVICE(0x1371, 0x9022), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index a611ad857983..651807dfb508 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -967,7 +967,7 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
967 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; 967 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band;
968 968
969 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 969 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
970 IEEE80211_HW_SIGNAL_DB; 970 IEEE80211_HW_SIGNAL_UNSPEC;
971 971
972 hw->wiphy->interface_modes = 972 hw->wiphy->interface_modes =
973 BIT(NL80211_IFTYPE_MESH_POINT) | 973 BIT(NL80211_IFTYPE_MESH_POINT) |