aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-09-25 16:16:16 -0400
committerDavid S. Miller <davem@davemloft.net>2008-09-25 16:16:16 -0400
commitdb4148da2cc84c31419b5e3ae3115ac6e11817a1 (patch)
tree72d7d99cd7a4903e017169e0ae8e2b37027129c6 /drivers
parentef40a685311bef053dedd833a72dffaf25669dda (diff)
parent8d09a5e1c36d0dec5728e6c8b0bb5412de09b27b (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/airo.c2
-rw-r--r--drivers/net/wireless/airo_cs.c2
-rw-r--r--drivers/net/wireless/ath5k/phy.c2
-rw-r--r--drivers/net/wireless/ath5k/reg.h2
-rw-r--r--drivers/net/wireless/ath5k/reset.c20
-rw-r--r--drivers/net/wireless/ath9k/beacon.c145
-rw-r--r--drivers/net/wireless/ath9k/core.c3
-rw-r--r--drivers/net/wireless/ath9k/core.h1
-rw-r--r--drivers/net/wireless/ath9k/hw.c18
-rw-r--r--drivers/net/wireless/ath9k/rc.c98
-rw-r--r--drivers/net/wireless/atmel.c2
-rw-r--r--drivers/net/wireless/atmel_cs.c2
-rw-r--r--drivers/net/wireless/b43/rfkill.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c182
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.h9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c146
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c24
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c27
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c11
-rw-r--r--drivers/net/wireless/libertas/dev.h1
-rw-r--r--drivers/net/wireless/libertas/wext.c26
-rw-r--r--drivers/net/wireless/netwave_cs.c2
-rw-r--r--drivers/net/wireless/orinoco.c2
-rw-r--r--drivers/net/wireless/orinoco_cs.c2
-rw-r--r--drivers/net/wireless/ray_cs.c2
-rw-r--r--drivers/net/wireless/rndis_wlan.c3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c3
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c4
-rw-r--r--drivers/net/wireless/spectrum_cs.c2
-rw-r--r--drivers/net/wireless/wavelan_cs.c2
-rw-r--r--drivers/net/wireless/wl3501_cs.c2
35 files changed, 331 insertions, 444 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index ae58a12befd3..370133e492d2 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -7107,7 +7107,7 @@ static int airo_get_aplist(struct net_device *dev,
7107 */ 7107 */
7108static int airo_set_scan(struct net_device *dev, 7108static int airo_set_scan(struct net_device *dev,
7109 struct iw_request_info *info, 7109 struct iw_request_info *info,
7110 struct iw_param *vwrq, 7110 struct iw_point *dwrq,
7111 char *extra) 7111 char *extra)
7112{ 7112{
7113 struct airo_info *ai = dev->priv; 7113 struct airo_info *ai = dev->priv;
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index f12355398fe7..fd72e427cb28 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -147,7 +147,7 @@ static int airo_probe(struct pcmcia_device *p_dev)
147 DEBUG(0, "airo_attach()\n"); 147 DEBUG(0, "airo_attach()\n");
148 148
149 /* Interrupt setup */ 149 /* Interrupt setup */
150 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 150 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
151 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 151 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
152 p_dev->irq.Handler = NULL; 152 p_dev->irq.Handler = NULL;
153 153
diff --git a/drivers/net/wireless/ath5k/phy.c b/drivers/net/wireless/ath5k/phy.c
index 1ea8ed962d26..e43f6563e61a 100644
--- a/drivers/net/wireless/ath5k/phy.c
+++ b/drivers/net/wireless/ath5k/phy.c
@@ -2124,7 +2124,7 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah,
2124 beacon = ath5k_hw_reg_read(ah, AR5K_BEACON_5210); 2124 beacon = ath5k_hw_reg_read(ah, AR5K_BEACON_5210);
2125 ath5k_hw_reg_write(ah, beacon & ~AR5K_BEACON_ENABLE, AR5K_BEACON_5210); 2125 ath5k_hw_reg_write(ah, beacon & ~AR5K_BEACON_ENABLE, AR5K_BEACON_5210);
2126 2126
2127 udelay(2300); 2127 mdelay(2);
2128 2128
2129 /* 2129 /*
2130 * Set the channel (with AGC turned off) 2130 * Set the channel (with AGC turned off)
diff --git a/drivers/net/wireless/ath5k/reg.h b/drivers/net/wireless/ath5k/reg.h
index a98832364448..410f99a6d616 100644
--- a/drivers/net/wireless/ath5k/reg.h
+++ b/drivers/net/wireless/ath5k/reg.h
@@ -820,8 +820,6 @@
820#define AR5K_RESET_CTL_MAC 0x00000004 /* MAC reset (PCU+Baseband ?) [5210] */ 820#define AR5K_RESET_CTL_MAC 0x00000004 /* MAC reset (PCU+Baseband ?) [5210] */
821#define AR5K_RESET_CTL_PHY 0x00000008 /* PHY reset [5210] */ 821#define AR5K_RESET_CTL_PHY 0x00000008 /* PHY reset [5210] */
822#define AR5K_RESET_CTL_PCI 0x00000010 /* PCI Core reset (interrupts etc) */ 822#define AR5K_RESET_CTL_PCI 0x00000010 /* PCI Core reset (interrupts etc) */
823#define AR5K_RESET_CTL_CHIP (AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_DMA | \
824 AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_PHY)
825 823
826/* 824/*
827 * Sleep control register 825 * Sleep control register
diff --git a/drivers/net/wireless/ath5k/reset.c b/drivers/net/wireless/ath5k/reset.c
index f5c3de890cdb..953ba3b19ff7 100644
--- a/drivers/net/wireless/ath5k/reset.c
+++ b/drivers/net/wireless/ath5k/reset.c
@@ -173,8 +173,10 @@ static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val)
173 udelay(15); 173 udelay(15);
174 174
175 if (ah->ah_version == AR5K_AR5210) { 175 if (ah->ah_version == AR5K_AR5210) {
176 val &= AR5K_RESET_CTL_CHIP; 176 val &= AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_DMA
177 mask &= AR5K_RESET_CTL_CHIP; 177 | AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_PHY;
178 mask &= AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_DMA
179 | AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_PHY;
178 } else { 180 } else {
179 val &= AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_BASEBAND; 181 val &= AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_BASEBAND;
180 mask &= AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_BASEBAND; 182 mask &= AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_BASEBAND;
@@ -361,16 +363,20 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
361 bus_flags = (pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI; 363 bus_flags = (pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI;
362 364
363 /* Reset chipset */ 365 /* Reset chipset */
364 ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | 366 if (ah->ah_version == AR5K_AR5210) {
365 AR5K_RESET_CTL_BASEBAND | bus_flags); 367 ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
368 AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_DMA |
369 AR5K_RESET_CTL_PHY | AR5K_RESET_CTL_PCI);
370 mdelay(2);
371 } else {
372 ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
373 AR5K_RESET_CTL_BASEBAND | bus_flags);
374 }
366 if (ret) { 375 if (ret) {
367 ATH5K_ERR(ah->ah_sc, "failed to reset the MAC Chip\n"); 376 ATH5K_ERR(ah->ah_sc, "failed to reset the MAC Chip\n");
368 return -EIO; 377 return -EIO;
369 } 378 }
370 379
371 if (ah->ah_version == AR5K_AR5210)
372 udelay(2300);
373
374 /* ...wakeup again!*/ 380 /* ...wakeup again!*/
375 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 381 ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0);
376 if (ret) { 382 if (ret) {
diff --git a/drivers/net/wireless/ath9k/beacon.c b/drivers/net/wireless/ath9k/beacon.c
index c43fd5861163..eedb465d25d3 100644
--- a/drivers/net/wireless/ath9k/beacon.c
+++ b/drivers/net/wireless/ath9k/beacon.c
@@ -16,7 +16,6 @@
16 16
17 /* Implementation of beacon processing. */ 17 /* Implementation of beacon processing. */
18 18
19#include <asm/unaligned.h>
20#include "core.h" 19#include "core.h"
21 20
22/* 21/*
@@ -26,7 +25,6 @@
26 * the operating mode of the station (AP or AdHoc). Parameters are AIFS 25 * the operating mode of the station (AP or AdHoc). Parameters are AIFS
27 * settings and channel width min/max 26 * settings and channel width min/max
28*/ 27*/
29
30static int ath_beaconq_config(struct ath_softc *sc) 28static int ath_beaconq_config(struct ath_softc *sc)
31{ 29{
32 struct ath_hal *ah = sc->sc_ah; 30 struct ath_hal *ah = sc->sc_ah;
@@ -63,19 +61,18 @@ static int ath_beaconq_config(struct ath_softc *sc)
63 * up all required antenna switch parameters, rate codes, and channel flags. 61 * up all required antenna switch parameters, rate codes, and channel flags.
64 * Beacons are always sent out at the lowest rate, and are not retried. 62 * Beacons are always sent out at the lowest rate, and are not retried.
65*/ 63*/
66
67static void ath_beacon_setup(struct ath_softc *sc, 64static void ath_beacon_setup(struct ath_softc *sc,
68 struct ath_vap *avp, struct ath_buf *bf) 65 struct ath_vap *avp, struct ath_buf *bf)
69{ 66{
70 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu; 67 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
71 struct ath_hal *ah = sc->sc_ah; 68 struct ath_hal *ah = sc->sc_ah;
72 struct ath_desc *ds; 69 struct ath_desc *ds;
73 int flags, antenna; 70 struct ath9k_11n_rate_series series[4];
74 const struct ath9k_rate_table *rt; 71 const struct ath9k_rate_table *rt;
72 int flags, antenna;
75 u8 rix, rate; 73 u8 rix, rate;
76 int ctsrate = 0; 74 int ctsrate = 0;
77 int ctsduration = 0; 75 int ctsduration = 0;
78 struct ath9k_11n_rate_series series[4];
79 76
80 DPRINTF(sc, ATH_DBG_BEACON, "%s: m %p len %u\n", 77 DPRINTF(sc, ATH_DBG_BEACON, "%s: m %p len %u\n",
81 __func__, skb, skb->len); 78 __func__, skb, skb->len);
@@ -115,20 +112,21 @@ static void ath_beacon_setup(struct ath_softc *sc,
115 rate |= rt->info[rix].shortPreamble; 112 rate |= rt->info[rix].shortPreamble;
116 113
117 ath9k_hw_set11n_txdesc(ah, ds, 114 ath9k_hw_set11n_txdesc(ah, ds,
118 skb->len + FCS_LEN, /* frame length */ 115 skb->len + FCS_LEN, /* frame length */
119 ATH9K_PKT_TYPE_BEACON, /* Atheros packet type */ 116 ATH9K_PKT_TYPE_BEACON, /* Atheros packet type */
120 avp->av_btxctl.txpower, /* txpower XXX */ 117 avp->av_btxctl.txpower, /* txpower XXX */
121 ATH9K_TXKEYIX_INVALID, /* no encryption */ 118 ATH9K_TXKEYIX_INVALID, /* no encryption */
122 ATH9K_KEY_TYPE_CLEAR, /* no encryption */ 119 ATH9K_KEY_TYPE_CLEAR, /* no encryption */
123 flags /* no ack, veol for beacons */ 120 flags /* no ack,
121 veol for beacons */
124 ); 122 );
125 123
126 /* NB: beacon's BufLen must be a multiple of 4 bytes */ 124 /* NB: beacon's BufLen must be a multiple of 4 bytes */
127 ath9k_hw_filltxdesc(ah, ds, 125 ath9k_hw_filltxdesc(ah, ds,
128 roundup(skb->len, 4), /* buffer length */ 126 roundup(skb->len, 4), /* buffer length */
129 true, /* first segment */ 127 true, /* first segment */
130 true, /* last segment */ 128 true, /* last segment */
131 ds /* first descriptor */ 129 ds /* first descriptor */
132 ); 130 );
133 131
134 memzero(series, sizeof(struct ath9k_11n_rate_series) * 4); 132 memzero(series, sizeof(struct ath9k_11n_rate_series) * 4);
@@ -153,22 +151,23 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
153 struct ath_buf *bf; 151 struct ath_buf *bf;
154 struct ath_vap *avp; 152 struct ath_vap *avp;
155 struct sk_buff *skb; 153 struct sk_buff *skb;
156 int cabq_depth;
157 struct ath_txq *cabq; 154 struct ath_txq *cabq;
158 struct ieee80211_tx_info *info; 155 struct ieee80211_tx_info *info;
156 int cabq_depth;
157
159 avp = sc->sc_vaps[if_id]; 158 avp = sc->sc_vaps[if_id];
159 ASSERT(avp);
160 160
161 cabq = sc->sc_cabq; 161 cabq = sc->sc_cabq;
162 162
163 ASSERT(avp);
164
165 if (avp->av_bcbuf == NULL) { 163 if (avp->av_bcbuf == NULL) {
166 DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n", 164 DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n",
167 __func__, avp, avp->av_bcbuf); 165 __func__, avp, avp->av_bcbuf);
168 return NULL; 166 return NULL;
169 } 167 }
168
170 bf = avp->av_bcbuf; 169 bf = avp->av_bcbuf;
171 skb = (struct sk_buff *) bf->bf_mpdu; 170 skb = (struct sk_buff *)bf->bf_mpdu;
172 if (skb) { 171 if (skb) {
173 pci_unmap_single(sc->pdev, bf->bf_dmacontext, 172 pci_unmap_single(sc->pdev, bf->bf_dmacontext,
174 skb_end_pointer(skb) - skb->head, 173 skb_end_pointer(skb) - skb->head,
@@ -179,17 +178,19 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
179 bf->bf_mpdu = skb; 178 bf->bf_mpdu = skb;
180 if (skb == NULL) 179 if (skb == NULL)
181 return NULL; 180 return NULL;
181
182 info = IEEE80211_SKB_CB(skb); 182 info = IEEE80211_SKB_CB(skb);
183 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 183 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
184 /* 184 /*
185 * TODO: make sure the seq# gets assigned properly (vs. other 185 * TODO: make sure the seq# gets assigned properly (vs. other
186 * TX frames) 186 * TX frames)
187 */ 187 */
188 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 188 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
189 sc->seq_no += 0x10; 189 sc->seq_no += 0x10;
190 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 190 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
191 hdr->seq_ctrl |= cpu_to_le16(sc->seq_no); 191 hdr->seq_ctrl |= cpu_to_le16(sc->seq_no);
192 } 192 }
193
193 bf->bf_buf_addr = bf->bf_dmacontext = 194 bf->bf_buf_addr = bf->bf_dmacontext =
194 pci_map_single(sc->pdev, skb->data, 195 pci_map_single(sc->pdev, skb->data,
195 skb_end_pointer(skb) - skb->head, 196 skb_end_pointer(skb) - skb->head,
@@ -241,7 +242,6 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
241 * Startup beacon transmission for adhoc mode when they are sent entirely 242 * Startup beacon transmission for adhoc mode when they are sent entirely
242 * by the hardware using the self-linked descriptor + veol trick. 243 * by the hardware using the self-linked descriptor + veol trick.
243*/ 244*/
244
245static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id) 245static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
246{ 246{
247 struct ath_hal *ah = sc->sc_ah; 247 struct ath_hal *ah = sc->sc_ah;
@@ -278,7 +278,6 @@ static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
278 * min/max, and enable aifs). The info structure does not need to be 278 * min/max, and enable aifs). The info structure does not need to be
279 * persistant. 279 * persistant.
280*/ 280*/
281
282int ath_beaconq_setup(struct ath_hal *ah) 281int ath_beaconq_setup(struct ath_hal *ah)
283{ 282{
284 struct ath9k_tx_queue_info qi; 283 struct ath9k_tx_queue_info qi;
@@ -299,26 +298,24 @@ int ath_beaconq_setup(struct ath_hal *ah)
299 * the ATH interface. This routine also calculates the beacon "slot" for 298 * the ATH interface. This routine also calculates the beacon "slot" for
300 * staggared beacons in the mBSSID case. 299 * staggared beacons in the mBSSID case.
301*/ 300*/
302
303int ath_beacon_alloc(struct ath_softc *sc, int if_id) 301int ath_beacon_alloc(struct ath_softc *sc, int if_id)
304{ 302{
305 struct ath_vap *avp; 303 struct ath_vap *avp;
306 struct ieee80211_hdr *wh; 304 struct ieee80211_hdr *hdr;
307 struct ath_buf *bf; 305 struct ath_buf *bf;
308 struct sk_buff *skb; 306 struct sk_buff *skb;
307 __le64 tstamp;
309 308
310 avp = sc->sc_vaps[if_id]; 309 avp = sc->sc_vaps[if_id];
311 ASSERT(avp); 310 ASSERT(avp);
312 311
313 /* Allocate a beacon descriptor if we haven't done so. */ 312 /* Allocate a beacon descriptor if we haven't done so. */
314 if (!avp->av_bcbuf) { 313 if (!avp->av_bcbuf) {
315 /* 314 /* Allocate beacon state for hostap/ibss. We know
316 * Allocate beacon state for hostap/ibss. We know 315 * a buffer is available. */
317 * a buffer is available.
318 */
319 316
320 avp->av_bcbuf = list_first_entry(&sc->sc_bbuf, 317 avp->av_bcbuf = list_first_entry(&sc->sc_bbuf,
321 struct ath_buf, list); 318 struct ath_buf, list);
322 list_del(&avp->av_bcbuf->list); 319 list_del(&avp->av_bcbuf->list);
323 320
324 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP || 321 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP ||
@@ -362,9 +359,7 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
362 } 359 }
363 360
364 /* 361 /*
365 * NB: the beacon data buffer must be 32-bit aligned; 362 * NB: the beacon data buffer must be 32-bit aligned.
366 * we assume the wbuf routines will return us something
367 * with this alignment (perhaps should assert).
368 * FIXME: Fill avp->av_btxctl.txpower and 363 * FIXME: Fill avp->av_btxctl.txpower and
369 * avp->av_btxctl.shortPreamble 364 * avp->av_btxctl.shortPreamble
370 */ 365 */
@@ -375,6 +370,9 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
375 return -ENOMEM; 370 return -ENOMEM;
376 } 371 }
377 372
373 tstamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
374 sc->bc_tstamp = le64_to_cpu(tstamp);
375
378 /* 376 /*
379 * Calculate a TSF adjustment factor required for 377 * Calculate a TSF adjustment factor required for
380 * staggered beacons. Note that we assume the format 378 * staggered beacons. Note that we assume the format
@@ -408,8 +406,8 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
408 __func__, "stagger", 406 __func__, "stagger",
409 avp->av_bslot, intval, (unsigned long long)tsfadjust); 407 avp->av_bslot, intval, (unsigned long long)tsfadjust);
410 408
411 wh = (struct ieee80211_hdr *)skb->data; 409 hdr = (struct ieee80211_hdr *)skb->data;
412 memcpy(&wh[1], &val, sizeof(val)); 410 memcpy(&hdr[1], &val, sizeof(val));
413 } 411 }
414 412
415 bf->bf_buf_addr = bf->bf_dmacontext = 413 bf->bf_buf_addr = bf->bf_dmacontext =
@@ -425,9 +423,8 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
425 * Reclaim beacon resources and return buffer to the pool. 423 * Reclaim beacon resources and return buffer to the pool.
426 * 424 *
427 * Checks the VAP to put the beacon frame buffer back to the ATH object 425 * Checks the VAP to put the beacon frame buffer back to the ATH object
428 * queue, and de-allocates any wbuf frames that were sent as CAB traffic. 426 * queue, and de-allocates any skbs that were sent as CAB traffic.
429*/ 427*/
430
431void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp) 428void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
432{ 429{
433 if (avp->av_bcbuf != NULL) { 430 if (avp->av_bcbuf != NULL) {
@@ -459,10 +456,7 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
459 * Transmit one or more beacon frames at SWBA. Dynamic updates to the frame 456 * Transmit one or more beacon frames at SWBA. Dynamic updates to the frame
460 * contents are done as needed and the slot time is also adjusted based on 457 * contents are done as needed and the slot time is also adjusted based on
461 * current state. 458 * current state.
462 *
463 * This tasklet is not scheduled, it's called in ISR context.
464*/ 459*/
465
466void ath9k_beacon_tasklet(unsigned long data) 460void ath9k_beacon_tasklet(unsigned long data)
467{ 461{
468 struct ath_softc *sc = (struct ath_softc *)data; 462 struct ath_softc *sc = (struct ath_softc *)data;
@@ -490,6 +484,8 @@ void ath9k_beacon_tasklet(unsigned long data)
490 * and wait for the next. Missed beacons indicate 484 * and wait for the next. Missed beacons indicate
491 * a problem and should not occur. If we miss too 485 * a problem and should not occur. If we miss too
492 * many consecutive beacons reset the device. 486 * many consecutive beacons reset the device.
487 *
488 * FIXME: Clean up this mess !!
493 */ 489 */
494 if (ath9k_hw_numtxpending(ah, sc->sc_bhalq) != 0) { 490 if (ath9k_hw_numtxpending(ah, sc->sc_bhalq) != 0) {
495 sc->sc_bmisscount++; 491 sc->sc_bmisscount++;
@@ -505,19 +501,16 @@ void ath9k_beacon_tasklet(unsigned long data)
505 __func__, sc->sc_bmisscount); 501 __func__, sc->sc_bmisscount);
506 if (show_cycles) { 502 if (show_cycles) {
507 /* 503 /*
508 * Display cycle counter stats 504 * Display cycle counter stats from HW
509 * from HW to aide in debug of 505 * to aide in debug of stickiness.
510 * stickiness.
511 */ 506 */
512 DPRINTF(sc, 507 DPRINTF(sc, ATH_DBG_BEACON,
513 ATH_DBG_BEACON,
514 "%s: busy times: rx_clear=%d, " 508 "%s: busy times: rx_clear=%d, "
515 "rx_frame=%d, tx_frame=%d\n", 509 "rx_frame=%d, tx_frame=%d\n",
516 __func__, rx_clear, rx_frame, 510 __func__, rx_clear, rx_frame,
517 tx_frame); 511 tx_frame);
518 } else { 512 } else {
519 DPRINTF(sc, 513 DPRINTF(sc, ATH_DBG_BEACON,
520 ATH_DBG_BEACON,
521 "%s: unable to obtain " 514 "%s: unable to obtain "
522 "busy times\n", __func__); 515 "busy times\n", __func__);
523 } 516 }
@@ -529,8 +522,7 @@ void ath9k_beacon_tasklet(unsigned long data)
529 } else if (sc->sc_bmisscount >= BSTUCK_THRESH) { 522 } else if (sc->sc_bmisscount >= BSTUCK_THRESH) {
530 if (sc->sc_flags & SC_OP_NO_RESET) { 523 if (sc->sc_flags & SC_OP_NO_RESET) {
531 if (sc->sc_bmisscount == BSTUCK_THRESH) { 524 if (sc->sc_bmisscount == BSTUCK_THRESH) {
532 DPRINTF(sc, 525 DPRINTF(sc, ATH_DBG_BEACON,
533 ATH_DBG_BEACON,
534 "%s: beacon is officially " 526 "%s: beacon is officially "
535 "stuck\n", __func__); 527 "stuck\n", __func__);
536 ath9k_hw_dmaRegDump(ah); 528 ath9k_hw_dmaRegDump(ah);
@@ -542,13 +534,12 @@ void ath9k_beacon_tasklet(unsigned long data)
542 ath_bstuck_process(sc); 534 ath_bstuck_process(sc);
543 } 535 }
544 } 536 }
545
546 return; 537 return;
547 } 538 }
539
548 if (sc->sc_bmisscount != 0) { 540 if (sc->sc_bmisscount != 0) {
549 if (sc->sc_flags & SC_OP_NO_RESET) { 541 if (sc->sc_flags & SC_OP_NO_RESET) {
550 DPRINTF(sc, 542 DPRINTF(sc, ATH_DBG_BEACON,
551 ATH_DBG_BEACON,
552 "%s: resume beacon xmit after %u misses\n", 543 "%s: resume beacon xmit after %u misses\n",
553 __func__, sc->sc_bmisscount); 544 __func__, sc->sc_bmisscount);
554 } else { 545 } else {
@@ -572,10 +563,12 @@ void ath9k_beacon_tasklet(unsigned long data)
572 tsftu = TSF_TO_TU(tsf>>32, tsf); 563 tsftu = TSF_TO_TU(tsf>>32, tsf);
573 slot = ((tsftu % intval) * ATH_BCBUF) / intval; 564 slot = ((tsftu % intval) * ATH_BCBUF) / intval;
574 if_id = sc->sc_bslot[(slot + 1) % ATH_BCBUF]; 565 if_id = sc->sc_bslot[(slot + 1) % ATH_BCBUF];
566
575 DPRINTF(sc, ATH_DBG_BEACON, 567 DPRINTF(sc, ATH_DBG_BEACON,
576 "%s: slot %d [tsf %llu tsftu %u intval %u] if_id %d\n", 568 "%s: slot %d [tsf %llu tsftu %u intval %u] if_id %d\n",
577 __func__, slot, (unsigned long long) tsf, tsftu, 569 __func__, slot, (unsigned long long)tsf, tsftu,
578 intval, if_id); 570 intval, if_id);
571
579 bfaddr = 0; 572 bfaddr = 0;
580 if (if_id != ATH_IF_ID_ANY) { 573 if (if_id != ATH_IF_ID_ANY) {
581 bf = ath_beacon_generate(sc, if_id); 574 bf = ath_beacon_generate(sc, if_id);
@@ -632,9 +625,8 @@ void ath9k_beacon_tasklet(unsigned long data)
632 * Tasklet for Beacon Stuck processing 625 * Tasklet for Beacon Stuck processing
633 * 626 *
634 * Processing for Beacon Stuck. 627 * Processing for Beacon Stuck.
635 * Basically calls the ath_internal_reset function to reset the chip. 628 * Basically resets the chip.
636*/ 629*/
637
638void ath_bstuck_process(struct ath_softc *sc) 630void ath_bstuck_process(struct ath_softc *sc)
639{ 631{
640 DPRINTF(sc, ATH_DBG_BEACON, 632 DPRINTF(sc, ATH_DBG_BEACON,
@@ -658,13 +650,12 @@ void ath_bstuck_process(struct ath_softc *sc)
658 * interrupt when we stop seeing beacons from the AP 650 * interrupt when we stop seeing beacons from the AP
659 * we've associated with. 651 * we've associated with.
660 */ 652 */
661
662void ath_beacon_config(struct ath_softc *sc, int if_id) 653void ath_beacon_config(struct ath_softc *sc, int if_id)
663{ 654{
664 struct ath_hal *ah = sc->sc_ah; 655 struct ath_hal *ah = sc->sc_ah;
665 u32 nexttbtt, intval;
666 struct ath_beacon_config conf; 656 struct ath_beacon_config conf;
667 enum ath9k_opmode av_opmode; 657 enum ath9k_opmode av_opmode;
658 u32 nexttbtt, intval;
668 659
669 if (if_id != ATH_IF_ID_ANY) 660 if (if_id != ATH_IF_ID_ANY)
670 av_opmode = sc->sc_vaps[if_id]->av_opmode; 661 av_opmode = sc->sc_vaps[if_id]->av_opmode;
@@ -673,12 +664,6 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
673 664
674 memzero(&conf, sizeof(struct ath_beacon_config)); 665 memzero(&conf, sizeof(struct ath_beacon_config));
675 666
676 /* FIXME: Use default values for now - Sujith */
677 /* Query beacon configuration first */
678 /*
679 * Protocol stack doesn't support dynamic beacon configuration,
680 * use default configurations.
681 */
682 conf.beacon_interval = sc->hw->conf.beacon_int ? 667 conf.beacon_interval = sc->hw->conf.beacon_int ?
683 sc->hw->conf.beacon_int : ATH_DEFAULT_BINTVAL; 668 sc->hw->conf.beacon_int : ATH_DEFAULT_BINTVAL;
684 conf.listen_interval = 1; 669 conf.listen_interval = 1;
@@ -687,8 +672,8 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
687 conf.bmiss_timeout = ATH_DEFAULT_BMISS_LIMIT * conf.beacon_interval; 672 conf.bmiss_timeout = ATH_DEFAULT_BMISS_LIMIT * conf.beacon_interval;
688 673
689 /* extract tstamp from last beacon and convert to TU */ 674 /* extract tstamp from last beacon and convert to TU */
690 nexttbtt = TSF_TO_TU(get_unaligned_le32(conf.u.last_tstamp + 4), 675 nexttbtt = TSF_TO_TU(sc->bc_tstamp >> 32, sc->bc_tstamp);
691 get_unaligned_le32(conf.u.last_tstamp)); 676
692 /* XXX conditionalize multi-bss support? */ 677 /* XXX conditionalize multi-bss support? */
693 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP) { 678 if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP) {
694 /* 679 /*
@@ -704,12 +689,14 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
704 intval = conf.beacon_interval & ATH9K_BEACON_PERIOD; 689 intval = conf.beacon_interval & ATH9K_BEACON_PERIOD;
705 } 690 }
706 691
707 if (nexttbtt == 0) /* e.g. for ap mode */ 692 if (nexttbtt == 0) /* e.g. for ap mode */
708 nexttbtt = intval; 693 nexttbtt = intval;
709 else if (intval) /* NB: can be 0 for monitor mode */ 694 else if (intval) /* NB: can be 0 for monitor mode */
710 nexttbtt = roundup(nexttbtt, intval); 695 nexttbtt = roundup(nexttbtt, intval);
696
711 DPRINTF(sc, ATH_DBG_BEACON, "%s: nexttbtt %u intval %u (%u)\n", 697 DPRINTF(sc, ATH_DBG_BEACON, "%s: nexttbtt %u intval %u (%u)\n",
712 __func__, nexttbtt, intval, conf.beacon_interval); 698 __func__, nexttbtt, intval, conf.beacon_interval);
699
713 /* Check for ATH9K_M_HOSTAP and sc_nostabeacons for WDS client */ 700 /* Check for ATH9K_M_HOSTAP and sc_nostabeacons for WDS client */
714 if (sc->sc_ah->ah_opmode == ATH9K_M_STA) { 701 if (sc->sc_ah->ah_opmode == ATH9K_M_STA) {
715 struct ath9k_beacon_state bs; 702 struct ath9k_beacon_state bs;
@@ -723,19 +710,19 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
723 * last beacon we received (which may be none). 710 * last beacon we received (which may be none).
724 */ 711 */
725 dtimperiod = conf.dtim_period; 712 dtimperiod = conf.dtim_period;
726 if (dtimperiod <= 0) /* NB: 0 if not known */ 713 if (dtimperiod <= 0) /* NB: 0 if not known */
727 dtimperiod = 1; 714 dtimperiod = 1;
728 dtimcount = conf.dtim_count; 715 dtimcount = conf.dtim_count;
729 if (dtimcount >= dtimperiod) /* NB: sanity check */ 716 if (dtimcount >= dtimperiod) /* NB: sanity check */
730 dtimcount = 0; /* XXX? */ 717 dtimcount = 0;
731 cfpperiod = 1; /* NB: no PCF support yet */ 718 cfpperiod = 1; /* NB: no PCF support yet */
732 cfpcount = 0; 719 cfpcount = 0;
733 720
734 sleepduration = conf.listen_interval * intval; 721 sleepduration = conf.listen_interval * intval;
735 if (sleepduration <= 0) 722 if (sleepduration <= 0)
736 sleepduration = intval; 723 sleepduration = intval;
737 724
738#define FUDGE 2 725#define FUDGE 2
739 /* 726 /*
740 * Pull nexttbtt forward to reflect the current 727 * Pull nexttbtt forward to reflect the current
741 * TSF and calculate dtim+cfp state for the result. 728 * TSF and calculate dtim+cfp state for the result.
@@ -759,6 +746,7 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
759 bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod; 746 bs.bs_cfpperiod = cfpperiod*bs.bs_dtimperiod;
760 bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod; 747 bs.bs_cfpnext = bs.bs_nextdtim + cfpcount*bs.bs_dtimperiod;
761 bs.bs_cfpmaxduration = 0; 748 bs.bs_cfpmaxduration = 0;
749
762 /* 750 /*
763 * Calculate the number of consecutive beacons to miss 751 * Calculate the number of consecutive beacons to miss
764 * before taking a BMISS interrupt. The configuration 752 * before taking a BMISS interrupt. The configuration
@@ -767,9 +755,8 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
767 * result to at most 15 beacons. 755 * result to at most 15 beacons.
768 */ 756 */
769 if (sleepduration > intval) { 757 if (sleepduration > intval) {
770 bs.bs_bmissthreshold = 758 bs.bs_bmissthreshold = conf.listen_interval *
771 conf.listen_interval * 759 ATH_DEFAULT_BMISS_LIMIT / 2;
772 ATH_DEFAULT_BMISS_LIMIT / 2;
773 } else { 760 } else {
774 bs.bs_bmissthreshold = 761 bs.bs_bmissthreshold =
775 DIV_ROUND_UP(conf.bmiss_timeout, intval); 762 DIV_ROUND_UP(conf.bmiss_timeout, intval);
@@ -789,8 +776,8 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
789 * XXX fixed at 100ms 776 * XXX fixed at 100ms
790 */ 777 */
791 778
792 bs.bs_sleepduration = 779 bs.bs_sleepduration = roundup(IEEE80211_MS_TO_TU(100),
793 roundup(IEEE80211_MS_TO_TU(100), sleepduration); 780 sleepduration);
794 if (bs.bs_sleepduration > bs.bs_dtimperiod) 781 if (bs.bs_sleepduration > bs.bs_dtimperiod)
795 bs.bs_sleepduration = bs.bs_dtimperiod; 782 bs.bs_sleepduration = bs.bs_dtimperiod;
796 783
@@ -834,9 +821,9 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
834 if (sc->sc_ah->ah_opmode == ATH9K_M_IBSS) { 821 if (sc->sc_ah->ah_opmode == ATH9K_M_IBSS) {
835 /* 822 /*
836 * Pull nexttbtt forward to reflect the current 823 * Pull nexttbtt forward to reflect the current
837 * TSF . 824 * TSF
838 */ 825 */
839#define FUDGE 2 826#define FUDGE 2
840 if (!(intval & ATH9K_BEACON_RESET_TSF)) { 827 if (!(intval & ATH9K_BEACON_RESET_TSF)) {
841 tsf = ath9k_hw_gettsf64(ah); 828 tsf = ath9k_hw_gettsf64(ah);
842 tsftu = TSF_TO_TU((u32)(tsf>>32), 829 tsftu = TSF_TO_TU((u32)(tsf>>32),
diff --git a/drivers/net/wireless/ath9k/core.c b/drivers/net/wireless/ath9k/core.c
index c262ef279ff3..690f7c56af3d 100644
--- a/drivers/net/wireless/ath9k/core.c
+++ b/drivers/net/wireless/ath9k/core.c
@@ -534,7 +534,8 @@ int ath_vap_attach(struct ath_softc *sc,
534 avp->av_opmode = opmode; 534 avp->av_opmode = opmode;
535 avp->av_bslot = -1; 535 avp->av_bslot = -1;
536 536
537 ath9k_hw_set_tsfadjust(sc->sc_ah, 1); 537 if (opmode == ATH9K_M_HOSTAP)
538 ath9k_hw_set_tsfadjust(sc->sc_ah, 1);
538 539
539 sc->sc_vaps[if_id] = avp; 540 sc->sc_vaps[if_id] = avp;
540 sc->sc_nvaps++; 541 sc->sc_nvaps++;
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index b66de29cf662..6ff3befe39f7 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -1001,6 +1001,7 @@ struct ath_softc {
1001 u32 sc_bhalq; 1001 u32 sc_bhalq;
1002 u32 sc_bmisscount; 1002 u32 sc_bmisscount;
1003 u32 ast_be_xmit; /* beacons transmitted */ 1003 u32 ast_be_xmit; /* beacons transmitted */
1004 u64 bc_tstamp;
1004 1005
1005 /* Rate */ 1006 /* Rate */
1006 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX]; 1007 struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
diff --git a/drivers/net/wireless/ath9k/hw.c b/drivers/net/wireless/ath9k/hw.c
index 0251e59f2f84..272c75816609 100644
--- a/drivers/net/wireless/ath9k/hw.c
+++ b/drivers/net/wireless/ath9k/hw.c
@@ -2526,6 +2526,11 @@ static void ath9k_ani_reset(struct ath_hal *ah)
2526 } 2526 }
2527} 2527}
2528 2528
2529/*
2530 * Process a MIB interrupt. We may potentially be invoked because
2531 * any of the MIB counters overflow/trigger so don't assume we're
2532 * here because a PHY error counter triggered.
2533 */
2529void ath9k_hw_procmibevent(struct ath_hal *ah, 2534void ath9k_hw_procmibevent(struct ath_hal *ah,
2530 const struct ath9k_node_stats *stats) 2535 const struct ath9k_node_stats *stats)
2531{ 2536{
@@ -2533,18 +2538,20 @@ void ath9k_hw_procmibevent(struct ath_hal *ah,
2533 u32 phyCnt1, phyCnt2; 2538 u32 phyCnt1, phyCnt2;
2534 2539
2535 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Processing Mib Intr\n"); 2540 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Processing Mib Intr\n");
2536 2541 /* Reset these counters regardless */
2537 REG_WRITE(ah, AR_FILT_OFDM, 0); 2542 REG_WRITE(ah, AR_FILT_OFDM, 0);
2538 REG_WRITE(ah, AR_FILT_CCK, 0); 2543 REG_WRITE(ah, AR_FILT_CCK, 0);
2539 if (!(REG_READ(ah, AR_SLP_MIB_CTRL) & AR_SLP_MIB_PENDING)) 2544 if (!(REG_READ(ah, AR_SLP_MIB_CTRL) & AR_SLP_MIB_PENDING))
2540 REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR); 2545 REG_WRITE(ah, AR_SLP_MIB_CTRL, AR_SLP_MIB_CLEAR);
2541 2546
2547 /* Clear the mib counters and save them in the stats */
2542 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats); 2548 ath9k_hw_update_mibstats(ah, &ahp->ah_mibStats);
2543 ahp->ah_stats.ast_nodestats = *stats; 2549 ahp->ah_stats.ast_nodestats = *stats;
2544 2550
2545 if (!DO_ANI(ah)) 2551 if (!DO_ANI(ah))
2546 return; 2552 return;
2547 2553
2554 /* NB: these are not reset-on-read */
2548 phyCnt1 = REG_READ(ah, AR_PHY_ERR_1); 2555 phyCnt1 = REG_READ(ah, AR_PHY_ERR_1);
2549 phyCnt2 = REG_READ(ah, AR_PHY_ERR_2); 2556 phyCnt2 = REG_READ(ah, AR_PHY_ERR_2);
2550 if (((phyCnt1 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK) || 2557 if (((phyCnt1 & AR_MIBCNT_INTRMASK) == AR_MIBCNT_INTRMASK) ||
@@ -2552,6 +2559,7 @@ void ath9k_hw_procmibevent(struct ath_hal *ah,
2552 struct ar5416AniState *aniState = ahp->ah_curani; 2559 struct ar5416AniState *aniState = ahp->ah_curani;
2553 u32 ofdmPhyErrCnt, cckPhyErrCnt; 2560 u32 ofdmPhyErrCnt, cckPhyErrCnt;
2554 2561
2562 /* NB: only use ast_ani_*errs with AH_PRIVATE_DIAG */
2555 ofdmPhyErrCnt = phyCnt1 - aniState->ofdmPhyErrBase; 2563 ofdmPhyErrCnt = phyCnt1 - aniState->ofdmPhyErrBase;
2556 ahp->ah_stats.ast_ani_ofdmerrs += 2564 ahp->ah_stats.ast_ani_ofdmerrs +=
2557 ofdmPhyErrCnt - aniState->ofdmPhyErrCount; 2565 ofdmPhyErrCnt - aniState->ofdmPhyErrCount;
@@ -2562,11 +2570,17 @@ void ath9k_hw_procmibevent(struct ath_hal *ah,
2562 cckPhyErrCnt - aniState->cckPhyErrCount; 2570 cckPhyErrCnt - aniState->cckPhyErrCount;
2563 aniState->cckPhyErrCount = cckPhyErrCnt; 2571 aniState->cckPhyErrCount = cckPhyErrCnt;
2564 2572
2573 /*
2574 * NB: figure out which counter triggered. If both
2575 * trigger we'll only deal with one as the processing
2576 * clobbers the error counter so the trigger threshold
2577 * check will never be true.
2578 */
2565 if (aniState->ofdmPhyErrCount > aniState->ofdmTrigHigh) 2579 if (aniState->ofdmPhyErrCount > aniState->ofdmTrigHigh)
2566 ath9k_hw_ani_ofdm_err_trigger(ah); 2580 ath9k_hw_ani_ofdm_err_trigger(ah);
2567 if (aniState->cckPhyErrCount > aniState->cckTrigHigh) 2581 if (aniState->cckPhyErrCount > aniState->cckTrigHigh)
2568 ath9k_hw_ani_cck_err_trigger(ah); 2582 ath9k_hw_ani_cck_err_trigger(ah);
2569 2583 /* NB: always restart to insure the h/w counters are reset */
2570 ath9k_ani_restart(ah); 2584 ath9k_ani_restart(ah);
2571 } 2585 }
2572} 2586}
diff --git a/drivers/net/wireless/ath9k/rc.c b/drivers/net/wireless/ath9k/rc.c
index 1cc9daf44550..cca2fc5b0765 100644
--- a/drivers/net/wireless/ath9k/rc.c
+++ b/drivers/net/wireless/ath9k/rc.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include "core.h" 22#include "core.h"
23/* FIXME: remove this include! */
23#include "../net/mac80211/rate.h" 24#include "../net/mac80211/rate.h"
24 25
25static u32 tx_triglevel_max; 26static u32 tx_triglevel_max;
@@ -1812,20 +1813,18 @@ static void ath_rc_sib_init(struct ath_rate_node *ath_rc_priv)
1812} 1813}
1813 1814
1814 1815
1815static void ath_setup_rates(struct ieee80211_local *local, struct sta_info *sta) 1816static void ath_setup_rates(struct ath_softc *sc,
1817 struct ieee80211_supported_band *sband,
1818 struct ieee80211_sta *sta,
1819 struct ath_rate_node *rc_priv)
1816 1820
1817{ 1821{
1818 struct ieee80211_supported_band *sband;
1819 struct ieee80211_hw *hw = local_to_hw(local);
1820 struct ath_softc *sc = hw->priv;
1821 struct ath_rate_node *rc_priv = sta->rate_ctrl_priv;
1822 int i, j = 0; 1822 int i, j = 0;
1823 1823
1824 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 1824 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
1825 1825
1826 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1827 for (i = 0; i < sband->n_bitrates; i++) { 1826 for (i = 0; i < sband->n_bitrates; i++) {
1828 if (sta->sta.supp_rates[local->hw.conf.channel->band] & BIT(i)) { 1827 if (sta->supp_rates[sband->band] & BIT(i)) {
1829 rc_priv->neg_rates.rs_rates[j] 1828 rc_priv->neg_rates.rs_rates[j]
1830 = (sband->bitrates[i].bitrate * 2) / 10; 1829 = (sband->bitrates[i].bitrate * 2) / 10;
1831 j++; 1830 j++;
@@ -1852,19 +1851,17 @@ void ath_rc_node_update(struct ieee80211_hw *hw, struct ath_rate_node *rc_priv)
1852} 1851}
1853 1852
1854/* Rate Control callbacks */ 1853/* Rate Control callbacks */
1855static void ath_tx_status(void *priv, struct net_device *dev, 1854static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
1855 struct ieee80211_sta *sta, void *priv_sta,
1856 struct sk_buff *skb) 1856 struct sk_buff *skb)
1857{ 1857{
1858 struct ath_softc *sc = priv; 1858 struct ath_softc *sc = priv;
1859 struct ath_tx_info_priv *tx_info_priv; 1859 struct ath_tx_info_priv *tx_info_priv;
1860 struct ath_node *an; 1860 struct ath_node *an;
1861 struct sta_info *sta;
1862 struct ieee80211_local *local;
1863 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1861 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1864 struct ieee80211_hdr *hdr; 1862 struct ieee80211_hdr *hdr;
1865 __le16 fc; 1863 __le16 fc;
1866 1864
1867 local = hw_to_local(sc->hw);
1868 hdr = (struct ieee80211_hdr *)skb->data; 1865 hdr = (struct ieee80211_hdr *)skb->data;
1869 fc = hdr->frame_control; 1866 fc = hdr->frame_control;
1870 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 1867 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
@@ -1873,8 +1870,7 @@ static void ath_tx_status(void *priv, struct net_device *dev,
1873 an = ath_node_find(sc, hdr->addr1); 1870 an = ath_node_find(sc, hdr->addr1);
1874 spin_unlock_bh(&sc->node_lock); 1871 spin_unlock_bh(&sc->node_lock);
1875 1872
1876 sta = sta_info_get(local, hdr->addr1); 1873 if (!an || !priv_sta || !ieee80211_is_data(fc)) {
1877 if (!an || !sta || !ieee80211_is_data(fc)) {
1878 if (tx_info->driver_data[0] != NULL) { 1874 if (tx_info->driver_data[0] != NULL) {
1879 kfree(tx_info->driver_data[0]); 1875 kfree(tx_info->driver_data[0]);
1880 tx_info->driver_data[0] = NULL; 1876 tx_info->driver_data[0] = NULL;
@@ -1882,24 +1878,22 @@ static void ath_tx_status(void *priv, struct net_device *dev,
1882 return; 1878 return;
1883 } 1879 }
1884 if (tx_info->driver_data[0] != NULL) { 1880 if (tx_info->driver_data[0] != NULL) {
1885 ath_rate_tx_complete(sc, an, sta->rate_ctrl_priv, tx_info_priv); 1881 ath_rate_tx_complete(sc, an, priv_sta, tx_info_priv);
1886 kfree(tx_info->driver_data[0]); 1882 kfree(tx_info->driver_data[0]);
1887 tx_info->driver_data[0] = NULL; 1883 tx_info->driver_data[0] = NULL;
1888 } 1884 }
1889} 1885}
1890 1886
1891static void ath_tx_aggr_resp(struct ath_softc *sc, 1887static void ath_tx_aggr_resp(struct ath_softc *sc,
1892 struct sta_info *sta, 1888 struct ieee80211_supported_band *sband,
1889 struct ieee80211_sta *sta,
1893 struct ath_node *an, 1890 struct ath_node *an,
1894 u8 tidno) 1891 u8 tidno)
1895{ 1892{
1896 struct ieee80211_hw *hw = sc->hw;
1897 struct ieee80211_local *local;
1898 struct ath_atx_tid *txtid; 1893 struct ath_atx_tid *txtid;
1899 struct ieee80211_supported_band *sband;
1900 u16 buffersize = 0; 1894 u16 buffersize = 0;
1901 int state; 1895 int state;
1902 DECLARE_MAC_BUF(mac); 1896 struct sta_info *si;
1903 1897
1904 if (!(sc->sc_flags & SC_OP_TXAGGR)) 1898 if (!(sc->sc_flags & SC_OP_TXAGGR))
1905 return; 1899 return;
@@ -1908,11 +1902,16 @@ static void ath_tx_aggr_resp(struct ath_softc *sc,
1908 if (!txtid->paused) 1902 if (!txtid->paused)
1909 return; 1903 return;
1910 1904
1911 local = hw_to_local(sc->hw); 1905 /*
1912 sband = hw->wiphy->bands[hw->conf.channel->band]; 1906 * XXX: This is entirely busted, we aren't supposed to
1907 * access the sta from here because it's internal
1908 * to mac80211, and looking at the state without
1909 * locking is wrong too.
1910 */
1911 si = container_of(sta, struct sta_info, sta);
1913 buffersize = IEEE80211_MIN_AMPDU_BUF << 1912 buffersize = IEEE80211_MIN_AMPDU_BUF <<
1914 sband->ht_info.ampdu_factor; /* FIXME */ 1913 sband->ht_info.ampdu_factor; /* FIXME */
1915 state = sta->ampdu_mlme.tid_state_tx[tidno]; 1914 state = si->ampdu_mlme.tid_state_tx[tidno];
1916 1915
1917 if (state & HT_ADDBA_RECEIVED_MSK) { 1916 if (state & HT_ADDBA_RECEIVED_MSK) {
1918 txtid->addba_exchangecomplete = 1; 1917 txtid->addba_exchangecomplete = 1;
@@ -1928,18 +1927,15 @@ static void ath_tx_aggr_resp(struct ath_softc *sc,
1928 } 1927 }
1929} 1928}
1930 1929
1931static void ath_get_rate(void *priv, struct net_device *dev, 1930static void ath_get_rate(void *priv, struct ieee80211_supported_band *sband,
1932 struct ieee80211_supported_band *sband, 1931 struct ieee80211_sta *sta, void *priv_sta,
1933 struct sk_buff *skb, 1932 struct sk_buff *skb, struct rate_selection *sel)
1934 struct rate_selection *sel)
1935{ 1933{
1936 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1934 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1937 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1935 struct ath_softc *sc = priv;
1938 struct sta_info *sta;
1939 struct ath_softc *sc = (struct ath_softc *)priv;
1940 struct ieee80211_hw *hw = sc->hw; 1936 struct ieee80211_hw *hw = sc->hw;
1941 struct ath_tx_info_priv *tx_info_priv; 1937 struct ath_tx_info_priv *tx_info_priv;
1942 struct ath_rate_node *ath_rc_priv; 1938 struct ath_rate_node *ath_rc_priv = priv_sta;
1943 struct ath_node *an; 1939 struct ath_node *an;
1944 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1940 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
1945 int is_probe = FALSE, chk, ret; 1941 int is_probe = FALSE, chk, ret;
@@ -1955,8 +1951,7 @@ static void ath_get_rate(void *priv, struct net_device *dev,
1955 ASSERT(tx_info->driver_data[0] != NULL); 1951 ASSERT(tx_info->driver_data[0] != NULL);
1956 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0]; 1952 tx_info_priv = (struct ath_tx_info_priv *)tx_info->driver_data[0];
1957 1953
1958 sta = sta_info_get(local, hdr->addr1); 1954 lowest_idx = rate_lowest_index(sband, sta);
1959 lowest_idx = rate_lowest_index(local, sband, sta);
1960 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10; 1955 tx_info_priv->min_rate = (sband->bitrates[lowest_idx].bitrate * 2) / 10;
1961 /* lowest rate for management and multicast/broadcast frames */ 1956 /* lowest rate for management and multicast/broadcast frames */
1962 if (!ieee80211_is_data(fc) || 1957 if (!ieee80211_is_data(fc) ||
@@ -1965,8 +1960,6 @@ static void ath_get_rate(void *priv, struct net_device *dev,
1965 return; 1960 return;
1966 } 1961 }
1967 1962
1968 ath_rc_priv = sta->rate_ctrl_priv;
1969
1970 /* Find tx rate for unicast frames */ 1963 /* Find tx rate for unicast frames */
1971 ath_rate_findrate(sc, ath_rc_priv, 1964 ath_rate_findrate(sc, ath_rc_priv,
1972 ATH_11N_TXMAXTRY, 4, 1965 ATH_11N_TXMAXTRY, 4,
@@ -1975,8 +1968,7 @@ static void ath_get_rate(void *priv, struct net_device *dev,
1975 &is_probe, 1968 &is_probe,
1976 false); 1969 false);
1977 if (is_probe) 1970 if (is_probe)
1978 sel->probe_idx = ((struct ath_tx_ratectrl *) 1971 sel->probe_idx = ath_rc_priv->tx_ratectrl.probe_rate;
1979 sta->rate_ctrl_priv)->probe_rate;
1980 1972
1981 /* Ratecontrol sometimes returns invalid rate index */ 1973 /* Ratecontrol sometimes returns invalid rate index */
1982 if (tx_info_priv->rcs[0].rix != 0xff) 1974 if (tx_info_priv->rcs[0].rix != 0xff)
@@ -2020,37 +2012,31 @@ static void ath_get_rate(void *priv, struct net_device *dev,
2020 __func__, 2012 __func__,
2021 print_mac(mac, hdr->addr1)); 2013 print_mac(mac, hdr->addr1));
2022 } else if (chk == AGGR_EXCHANGE_PROGRESS) 2014 } else if (chk == AGGR_EXCHANGE_PROGRESS)
2023 ath_tx_aggr_resp(sc, sta, an, tid); 2015 ath_tx_aggr_resp(sc, sband, sta, an, tid);
2024 } 2016 }
2025 } 2017 }
2026} 2018}
2027 2019
2028static void ath_rate_init(void *priv, void *priv_sta, 2020static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
2029 struct ieee80211_local *local, 2021 struct ieee80211_sta *sta, void *priv_sta)
2030 struct sta_info *sta)
2031{ 2022{
2032 struct ieee80211_supported_band *sband; 2023 struct ath_softc *sc = priv;
2033 struct ieee80211_hw *hw = local_to_hw(local);
2034 struct ieee80211_conf *conf = &local->hw.conf;
2035 struct ath_softc *sc = hw->priv;
2036 struct ath_rate_node *ath_rc_priv = priv_sta; 2024 struct ath_rate_node *ath_rc_priv = priv_sta;
2037 int i, j = 0; 2025 int i, j = 0;
2038 2026
2039 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 2027 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
2040 2028
2041 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 2029 ath_setup_rates(sc, sband, sta, ath_rc_priv);
2042 2030 if (sc->hw->conf.flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
2043 ath_setup_rates(local, sta);
2044 if (conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) {
2045 for (i = 0; i < MCS_SET_SIZE; i++) { 2031 for (i = 0; i < MCS_SET_SIZE; i++) {
2046 if (conf->ht_conf.supp_mcs_set[i/8] & (1<<(i%8))) 2032 if (sc->hw->conf.ht_conf.supp_mcs_set[i/8] & (1<<(i%8)))
2047 ath_rc_priv->neg_ht_rates.rs_rates[j++] = i; 2033 ath_rc_priv->neg_ht_rates.rs_rates[j++] = i;
2048 if (j == ATH_RATE_MAX) 2034 if (j == ATH_RATE_MAX)
2049 break; 2035 break;
2050 } 2036 }
2051 ath_rc_priv->neg_ht_rates.rs_nrates = j; 2037 ath_rc_priv->neg_ht_rates.rs_nrates = j;
2052 } 2038 }
2053 ath_rc_node_update(hw, priv_sta); 2039 ath_rc_node_update(sc->hw, priv_sta);
2054} 2040}
2055 2041
2056static void ath_rate_clear(void *priv) 2042static void ath_rate_clear(void *priv)
@@ -2058,13 +2044,12 @@ static void ath_rate_clear(void *priv)
2058 return; 2044 return;
2059} 2045}
2060 2046
2061static void *ath_rate_alloc(struct ieee80211_local *local) 2047static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
2062{ 2048{
2063 struct ieee80211_hw *hw = local_to_hw(local);
2064 struct ath_softc *sc = hw->priv; 2049 struct ath_softc *sc = hw->priv;
2065 2050
2066 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__); 2051 DPRINTF(sc, ATH_DBG_RATE, "%s\n", __func__);
2067 return local->hw.priv; 2052 return hw->priv;
2068} 2053}
2069 2054
2070static void ath_rate_free(void *priv) 2055static void ath_rate_free(void *priv)
@@ -2072,7 +2057,7 @@ static void ath_rate_free(void *priv)
2072 return; 2057 return;
2073} 2058}
2074 2059
2075static void *ath_rate_alloc_sta(void *priv, gfp_t gfp) 2060static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
2076{ 2061{
2077 struct ath_softc *sc = priv; 2062 struct ath_softc *sc = priv;
2078 struct ath_vap *avp = sc->sc_vaps[0]; 2063 struct ath_vap *avp = sc->sc_vaps[0];
@@ -2092,7 +2077,8 @@ static void *ath_rate_alloc_sta(void *priv, gfp_t gfp)
2092 return rate_priv; 2077 return rate_priv;
2093} 2078}
2094 2079
2095static void ath_rate_free_sta(void *priv, void *priv_sta) 2080static void ath_rate_free_sta(void *priv, struct ieee80211_sta *sta,
2081 void *priv_sta)
2096{ 2082{
2097 struct ath_rate_node *rate_priv = priv_sta; 2083 struct ath_rate_node *rate_priv = priv_sta;
2098 struct ath_softc *sc = priv; 2084 struct ath_softc *sc = priv;
@@ -2111,7 +2097,7 @@ static struct rate_control_ops ath_rate_ops = {
2111 .alloc = ath_rate_alloc, 2097 .alloc = ath_rate_alloc,
2112 .free = ath_rate_free, 2098 .free = ath_rate_free,
2113 .alloc_sta = ath_rate_alloc_sta, 2099 .alloc_sta = ath_rate_alloc_sta,
2114 .free_sta = ath_rate_free_sta 2100 .free_sta = ath_rate_free_sta,
2115}; 2101};
2116 2102
2117int ath_rate_control_register(void) 2103int ath_rate_control_register(void)
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index bd65c485098c..ecb02bdaab5b 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -2258,7 +2258,7 @@ static int atmel_get_freq(struct net_device *dev,
2258 2258
2259static int atmel_set_scan(struct net_device *dev, 2259static int atmel_set_scan(struct net_device *dev,
2260 struct iw_request_info *info, 2260 struct iw_request_info *info,
2261 struct iw_param *vwrq, 2261 struct iw_point *dwrq,
2262 char *extra) 2262 char *extra)
2263{ 2263{
2264 struct atmel_private *priv = netdev_priv(dev); 2264 struct atmel_private *priv = netdev_priv(dev);
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 12617cd0b78e..d2388e8d179a 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -158,7 +158,7 @@ static int atmel_probe(struct pcmcia_device *p_dev)
158 DEBUG(0, "atmel_attach()\n"); 158 DEBUG(0, "atmel_attach()\n");
159 159
160 /* Interrupt setup */ 160 /* Interrupt setup */
161 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 161 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
162 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 162 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
163 p_dev->irq.Handler = NULL; 163 p_dev->irq.Handler = NULL;
164 164
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c
index 7b9e99adb8c3..96902da7d661 100644
--- a/drivers/net/wireless/b43/rfkill.c
+++ b/drivers/net/wireless/b43/rfkill.c
@@ -188,6 +188,11 @@ void b43_rfkill_init(struct b43_wldev *dev)
188 "The built-in radio LED will not work.\n"); 188 "The built-in radio LED will not work.\n");
189#endif /* CONFIG_RFKILL_INPUT */ 189#endif /* CONFIG_RFKILL_INPUT */
190 190
191#if !defined(CONFIG_RFKILL_INPUT) && !defined(CONFIG_RFKILL_INPUT_MODULE)
192 b43warn(wl, "The rfkill-input subsystem is not available. "
193 "The built-in radio LED will not work.\n");
194#endif
195
191 err = input_register_polled_device(rfk->poll_dev); 196 err = input_register_polled_device(rfk->poll_dev);
192 if (err) 197 if (err)
193 goto err_unreg_rfk; 198 goto err_unreg_rfk;
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index a279bf1dc9b0..6fc5e7361f26 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -36,8 +36,6 @@
36 36
37#include <linux/workqueue.h> 37#include <linux/workqueue.h>
38 38
39#include "../net/mac80211/rate.h"
40
41#include "iwl-3945.h" 39#include "iwl-3945.h"
42 40
43#define RS_NAME "iwl-3945-rs" 41#define RS_NAME "iwl-3945-rs"
@@ -319,10 +317,10 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta,
319 } 317 }
320} 318}
321 319
322static void rs_rate_init(void *priv_rate, void *priv_sta, 320static void rs_rate_init(void *priv, struct ieee80211_supported_band *sband,
323 struct ieee80211_local *local, struct sta_info *sta) 321 struct ieee80211_sta *sta, void *priv_sta)
324{ 322{
325 struct iwl3945_rs_sta *rs_sta = (void *)sta->rate_ctrl_priv; 323 struct iwl3945_rs_sta *rs_sta = priv_sta;
326 int i; 324 int i;
327 325
328 IWL_DEBUG_RATE("enter\n"); 326 IWL_DEBUG_RATE("enter\n");
@@ -333,22 +331,22 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
333 * after assoc.. */ 331 * after assoc.. */
334 332
335 for (i = IWL_RATE_COUNT - 1; i >= 0; i--) { 333 for (i = IWL_RATE_COUNT - 1; i >= 0; i--) {
336 if (sta->sta.supp_rates[local->hw.conf.channel->band] & (1 << i)) { 334 if (sta->supp_rates[sband->band] & (1 << i)) {
337 rs_sta->last_txrate_idx = i; 335 rs_sta->last_txrate_idx = i;
338 break; 336 break;
339 } 337 }
340 } 338 }
341 339
342 /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ 340 /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */
343 if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) 341 if (sband->band == IEEE80211_BAND_5GHZ)
344 rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 342 rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
345 343
346 IWL_DEBUG_RATE("leave\n"); 344 IWL_DEBUG_RATE("leave\n");
347} 345}
348 346
349static void *rs_alloc(struct ieee80211_local *local) 347static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
350{ 348{
351 return local->hw.priv; 349 return hw->priv;
352} 350}
353 351
354/* rate scale requires free function to be implemented */ 352/* rate scale requires free function to be implemented */
@@ -356,17 +354,24 @@ static void rs_free(void *priv)
356{ 354{
357 return; 355 return;
358} 356}
357
359static void rs_clear(void *priv) 358static void rs_clear(void *priv)
360{ 359{
361 return; 360 return;
362} 361}
363 362
364 363
365static void *rs_alloc_sta(void *priv, gfp_t gfp) 364static void *rs_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
366{ 365{
367 struct iwl3945_rs_sta *rs_sta; 366 struct iwl3945_rs_sta *rs_sta;
367 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv;
368 int i; 368 int i;
369 369
370 /*
371 * XXX: If it's using sta->drv_priv anyway, it might
372 * as well just put all the information there.
373 */
374
370 IWL_DEBUG_RATE("enter\n"); 375 IWL_DEBUG_RATE("enter\n");
371 376
372 rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp); 377 rs_sta = kzalloc(sizeof(struct iwl3945_rs_sta), gfp);
@@ -375,6 +380,8 @@ static void *rs_alloc_sta(void *priv, gfp_t gfp)
375 return NULL; 380 return NULL;
376 } 381 }
377 382
383 psta->rs_sta = rs_sta;
384
378 spin_lock_init(&rs_sta->lock); 385 spin_lock_init(&rs_sta->lock);
379 386
380 rs_sta->start_rate = IWL_RATE_INVALID; 387 rs_sta->start_rate = IWL_RATE_INVALID;
@@ -400,10 +407,14 @@ static void *rs_alloc_sta(void *priv, gfp_t gfp)
400 return rs_sta; 407 return rs_sta;
401} 408}
402 409
403static void rs_free_sta(void *priv, void *priv_sta) 410static void rs_free_sta(void *priv, struct ieee80211_sta *sta,
411 void *priv_sta)
404{ 412{
413 struct iwl3945_sta_priv *psta = (void *) sta->drv_priv;
405 struct iwl3945_rs_sta *rs_sta = priv_sta; 414 struct iwl3945_rs_sta *rs_sta = priv_sta;
406 415
416 psta->rs_sta = NULL;
417
407 IWL_DEBUG_RATE("enter\n"); 418 IWL_DEBUG_RATE("enter\n");
408 del_timer_sync(&rs_sta->rate_scale_flush); 419 del_timer_sync(&rs_sta->rate_scale_flush);
409 kfree(rs_sta); 420 kfree(rs_sta);
@@ -445,26 +456,19 @@ static int rs_adjust_next_rate(struct iwl3945_priv *priv, int rate)
445 * NOTE: Uses iwl3945_priv->retry_rate for the # of retries attempted by 456 * NOTE: Uses iwl3945_priv->retry_rate for the # of retries attempted by
446 * the hardware for each rate. 457 * the hardware for each rate.
447 */ 458 */
448static void rs_tx_status(void *priv_rate, 459static void rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband,
449 struct net_device *dev, 460 struct ieee80211_sta *sta, void *priv_sta,
450 struct sk_buff *skb) 461 struct sk_buff *skb)
451{ 462{
452 u8 retries, current_count; 463 u8 retries, current_count;
453 int scale_rate_index, first_index, last_index; 464 int scale_rate_index, first_index, last_index;
454 unsigned long flags; 465 unsigned long flags;
455 struct sta_info *sta;
456 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
457 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; 466 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate;
458 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 467 struct iwl3945_rs_sta *rs_sta = priv_sta;
459 struct iwl3945_rs_sta *rs_sta;
460 struct ieee80211_supported_band *sband;
461 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 468 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
462 469
463 IWL_DEBUG_RATE("enter\n"); 470 IWL_DEBUG_RATE("enter\n");
464 471
465 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
466
467
468 retries = info->status.retry_count; 472 retries = info->status.retry_count;
469 first_index = sband->bitrates[info->tx_rate_idx].hw_value; 473 first_index = sband->bitrates[info->tx_rate_idx].hw_value;
470 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) { 474 if ((first_index < 0) || (first_index >= IWL_RATE_COUNT)) {
@@ -472,17 +476,11 @@ static void rs_tx_status(void *priv_rate,
472 return; 476 return;
473 } 477 }
474 478
475 rcu_read_lock(); 479 if (!priv_sta) {
476
477 sta = sta_info_get(local, hdr->addr1);
478 if (!sta || !sta->rate_ctrl_priv) {
479 rcu_read_unlock();
480 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 480 IWL_DEBUG_RATE("leave: No STA priv data to update!\n");
481 return; 481 return;
482 } 482 }
483 483
484 rs_sta = (void *)sta->rate_ctrl_priv;
485
486 rs_sta->tx_packets++; 484 rs_sta->tx_packets++;
487 485
488 scale_rate_index = first_index; 486 scale_rate_index = first_index;
@@ -549,8 +547,6 @@ static void rs_tx_status(void *priv_rate,
549 547
550 spin_unlock_irqrestore(&rs_sta->lock, flags); 548 spin_unlock_irqrestore(&rs_sta->lock, flags);
551 549
552 rcu_read_unlock();
553
554 IWL_DEBUG_RATE("leave\n"); 550 IWL_DEBUG_RATE("leave\n");
555 551
556 return; 552 return;
@@ -634,16 +630,15 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta,
634 * rate table and must reference the driver allocated rate table 630 * rate table and must reference the driver allocated rate table
635 * 631 *
636 */ 632 */
637static void rs_get_rate(void *priv_rate, struct net_device *dev, 633static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
638 struct ieee80211_supported_band *sband, 634 struct ieee80211_sta *sta, void *priv_sta,
639 struct sk_buff *skb, 635 struct sk_buff *skb, struct rate_selection *sel)
640 struct rate_selection *sel)
641{ 636{
642 u8 low = IWL_RATE_INVALID; 637 u8 low = IWL_RATE_INVALID;
643 u8 high = IWL_RATE_INVALID; 638 u8 high = IWL_RATE_INVALID;
644 u16 high_low; 639 u16 high_low;
645 int index; 640 int index;
646 struct iwl3945_rs_sta *rs_sta; 641 struct iwl3945_rs_sta *rs_sta = priv_sta;
647 struct iwl3945_rate_scale_data *window = NULL; 642 struct iwl3945_rate_scale_data *window = NULL;
648 int current_tpt = IWL_INV_TPT; 643 int current_tpt = IWL_INV_TPT;
649 int low_tpt = IWL_INV_TPT; 644 int low_tpt = IWL_INV_TPT;
@@ -651,34 +646,25 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
651 u32 fail_count; 646 u32 fail_count;
652 s8 scale_action = 0; 647 s8 scale_action = 0;
653 unsigned long flags; 648 unsigned long flags;
654 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
655 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 649 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
656 struct sta_info *sta;
657 u16 fc, rate_mask; 650 u16 fc, rate_mask;
658 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_rate; 651 struct iwl3945_priv *priv = (struct iwl3945_priv *)priv_r;
659 DECLARE_MAC_BUF(mac); 652 DECLARE_MAC_BUF(mac);
660 653
661 IWL_DEBUG_RATE("enter\n"); 654 IWL_DEBUG_RATE("enter\n");
662 655
663 rcu_read_lock();
664
665 sta = sta_info_get(local, hdr->addr1);
666
667 /* Send management frames and broadcast/multicast data using lowest 656 /* Send management frames and broadcast/multicast data using lowest
668 * rate. */ 657 * rate. */
669 fc = le16_to_cpu(hdr->frame_control); 658 fc = le16_to_cpu(hdr->frame_control);
670 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || 659 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
671 is_multicast_ether_addr(hdr->addr1) || 660 is_multicast_ether_addr(hdr->addr1) ||
672 !sta || !sta->rate_ctrl_priv) { 661 !sta || !priv_sta) {
673 IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); 662 IWL_DEBUG_RATE("leave: No STA priv data to update!\n");
674 sel->rate_idx = rate_lowest_index(local, sband, sta); 663 sel->rate_idx = rate_lowest_index(sband, sta);
675 rcu_read_unlock();
676 return; 664 return;
677 } 665 }
678 666
679 rs_sta = (void *)sta->rate_ctrl_priv; 667 rate_mask = sta->supp_rates[sband->band];
680
681 rate_mask = sta->sta.supp_rates[sband->band];
682 index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1); 668 index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT - 1);
683 669
684 if (sband->band == IEEE80211_BAND_5GHZ) 670 if (sband->band == IEEE80211_BAND_5GHZ)
@@ -811,8 +797,6 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
811 else 797 else
812 sel->rate_idx = rs_sta->last_txrate_idx; 798 sel->rate_idx = rs_sta->last_txrate_idx;
813 799
814 rcu_read_unlock();
815
816 IWL_DEBUG_RATE("leave: %d\n", index); 800 IWL_DEBUG_RATE("leave: %d\n", index);
817} 801}
818 802
@@ -829,114 +813,28 @@ static struct rate_control_ops rs_ops = {
829 .free_sta = rs_free_sta, 813 .free_sta = rs_free_sta,
830}; 814};
831 815
832int iwl3945_fill_rs_info(struct ieee80211_hw *hw, char *buf, u8 sta_id)
833{
834 struct ieee80211_local *local = hw_to_local(hw);
835 struct iwl3945_priv *priv = hw->priv;
836 struct iwl3945_rs_sta *rs_sta;
837 struct sta_info *sta;
838 unsigned long flags;
839 int count = 0, i;
840 u32 samples = 0, success = 0, good = 0;
841 unsigned long now = jiffies;
842 u32 max_time = 0;
843
844 rcu_read_lock();
845
846 sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr);
847 if (!sta || !sta->rate_ctrl_priv) {
848 if (sta)
849 IWL_DEBUG_RATE("leave - no private rate data!\n");
850 else
851 IWL_DEBUG_RATE("leave - no station!\n");
852 rcu_read_unlock();
853 return sprintf(buf, "station %d not found\n", sta_id);
854 }
855
856 rs_sta = (void *)sta->rate_ctrl_priv;
857 spin_lock_irqsave(&rs_sta->lock, flags);
858 i = IWL_RATE_54M_INDEX;
859 while (1) {
860 u64 mask;
861 int j;
862
863 count +=
864 sprintf(&buf[count], " %2dMbs: ", iwl3945_rates[i].ieee / 2);
865
866 mask = (1ULL << (IWL_RATE_MAX_WINDOW - 1));
867 for (j = 0; j < IWL_RATE_MAX_WINDOW; j++, mask >>= 1)
868 buf[count++] =
869 (rs_sta->win[i].data & mask) ? '1' : '0';
870
871 samples += rs_sta->win[i].counter;
872 good += rs_sta->win[i].success_counter;
873 success += rs_sta->win[i].success_counter *
874 iwl3945_rates[i].ieee;
875
876 if (rs_sta->win[i].stamp) {
877 int delta =
878 jiffies_to_msecs(now - rs_sta->win[i].stamp);
879
880 if (delta > max_time)
881 max_time = delta;
882
883 count += sprintf(&buf[count], "%5dms\n", delta);
884 } else
885 buf[count++] = '\n';
886
887 j = iwl3945_get_prev_ieee_rate(i);
888 if (j == i)
889 break;
890 i = j;
891 }
892 spin_unlock_irqrestore(&rs_sta->lock, flags);
893 rcu_read_unlock();
894
895 /* Display the average rate of all samples taken.
896 *
897 * NOTE: We multiple # of samples by 2 since the IEEE measurement
898 * added from iwl3945_rates is actually 2X the rate */
899 if (samples)
900 count += sprintf(
901 &buf[count],
902 "\nAverage rate is %3d.%02dMbs over last %4dms\n"
903 "%3d%% success (%d good packets over %d tries)\n",
904 success / (2 * samples), (success * 5 / samples) % 10,
905 max_time, good * 100 / samples, good, samples);
906 else
907 count += sprintf(&buf[count], "\nAverage rate: 0Mbs\n");
908
909 return count;
910}
911
912void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) 816void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
913{ 817{
914 struct iwl3945_priv *priv = hw->priv; 818 struct iwl3945_priv *priv = hw->priv;
915 s32 rssi = 0; 819 s32 rssi = 0;
916 unsigned long flags; 820 unsigned long flags;
917 struct ieee80211_local *local = hw_to_local(hw);
918 struct iwl3945_rs_sta *rs_sta; 821 struct iwl3945_rs_sta *rs_sta;
919 struct sta_info *sta; 822 struct ieee80211_sta *sta;
823 struct iwl3945_sta_priv *psta;
920 824
921 IWL_DEBUG_RATE("enter\n"); 825 IWL_DEBUG_RATE("enter\n");
922 826
923 if (!local->rate_ctrl->ops->name ||
924 strcmp(local->rate_ctrl->ops->name, RS_NAME)) {
925 IWL_WARNING("iwl-3945-rs not selected as rate control algo!\n");
926 IWL_DEBUG_RATE("leave - mac80211 picked the wrong RC algo.\n");
927 return;
928 }
929
930 rcu_read_lock(); 827 rcu_read_lock();
931 828
932 sta = sta_info_get(local, priv->stations[sta_id].sta.sta.addr); 829 sta = ieee80211_find_sta(hw, priv->stations[sta_id].sta.sta.addr);
933 if (!sta || !sta->rate_ctrl_priv) { 830 psta = (void *) sta->drv_priv;
831 if (!sta || !psta) {
934 IWL_DEBUG_RATE("leave - no private rate data!\n"); 832 IWL_DEBUG_RATE("leave - no private rate data!\n");
935 rcu_read_unlock(); 833 rcu_read_unlock();
936 return; 834 return;
937 } 835 }
938 836
939 rs_sta = (void *)sta->rate_ctrl_priv; 837 rs_sta = psta->rs_sta;
940 838
941 spin_lock_irqsave(&rs_sta->lock, flags); 839 spin_lock_irqsave(&rs_sta->lock, flags);
942 840
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
index f085d330bdcf..98b17ae6ef24 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.h
@@ -176,15 +176,6 @@ static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index)
176} 176}
177 177
178/** 178/**
179 * iwl3945_fill_rs_info - Fill an output text buffer with the rate representation
180 *
181 * NOTE: This is provided as a quick mechanism for a user to visualize
182 * the performance of the rate control algorithm and is not meant to be
183 * parsed software.
184 */
185extern int iwl3945_fill_rs_info(struct ieee80211_hw *, char *buf, u8 sta_id);
186
187/**
188 * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info 179 * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info
189 * 180 *
190 * The specific throughput table used is based on the type of network 181 * The specific throughput table used is based on the type of network
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 2a4933b5fb64..bdd32475b99c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -73,6 +73,10 @@ extern struct pci_device_id iwl3945_hw_card_ids[];
73extern int iwl3945_param_hwcrypto; 73extern int iwl3945_param_hwcrypto;
74extern int iwl3945_param_queues_num; 74extern int iwl3945_param_queues_num;
75 75
76struct iwl3945_sta_priv {
77 struct iwl3945_rs_sta *rs_sta;
78};
79
76enum iwl3945_antenna { 80enum iwl3945_antenna {
77 IWL_ANTENNA_DIVERSITY, 81 IWL_ANTENNA_DIVERSITY,
78 IWL_ANTENNA_MAIN, 82 IWL_ANTENNA_MAIN,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 8b57b390c8ba..93944de923ca 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -35,8 +35,6 @@
35 35
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37 37
38#include "../net/mac80211/rate.h"
39
40#include "iwl-dev.h" 38#include "iwl-dev.h"
41#include "iwl-sta.h" 39#include "iwl-sta.h"
42#include "iwl-core.h" 40#include "iwl-core.h"
@@ -169,9 +167,9 @@ struct iwl_lq_sta {
169}; 167};
170 168
171static void rs_rate_scale_perform(struct iwl_priv *priv, 169static void rs_rate_scale_perform(struct iwl_priv *priv,
172 struct net_device *dev,
173 struct ieee80211_hdr *hdr, 170 struct ieee80211_hdr *hdr,
174 struct sta_info *sta); 171 struct ieee80211_sta *sta,
172 struct iwl_lq_sta *lq_sta);
175static void rs_fill_link_cmd(const struct iwl_priv *priv, 173static void rs_fill_link_cmd(const struct iwl_priv *priv,
176 struct iwl_lq_sta *lq_sta, u32 rate_n_flags); 174 struct iwl_lq_sta *lq_sta, u32 rate_n_flags);
177 175
@@ -357,20 +355,20 @@ static u32 rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid)
357 355
358static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, 356static void rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv,
359 struct iwl_lq_sta *lq_data, u8 tid, 357 struct iwl_lq_sta *lq_data, u8 tid,
360 struct sta_info *sta) 358 struct ieee80211_sta *sta)
361{ 359{
362 DECLARE_MAC_BUF(mac); 360 DECLARE_MAC_BUF(mac);
363 361
364 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) {
365 IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n", 363 IWL_DEBUG_HT("Starting Tx agg: STA: %s tid: %d\n",
366 print_mac(mac, sta->sta.addr), tid); 364 print_mac(mac, sta->addr), tid);
367 ieee80211_start_tx_ba_session(priv->hw, sta->sta.addr, tid); 365 ieee80211_start_tx_ba_session(priv->hw, sta->addr, tid);
368 } 366 }
369} 367}
370 368
371static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, 369static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid,
372 struct iwl_lq_sta *lq_data, 370 struct iwl_lq_sta *lq_data,
373 struct sta_info *sta) 371 struct ieee80211_sta *sta)
374{ 372{
375 if ((tid < TID_MAX_LOAD_COUNT)) 373 if ((tid < TID_MAX_LOAD_COUNT))
376 rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); 374 rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta);
@@ -770,7 +768,8 @@ out:
770/* 768/*
771 * mac80211 sends us Tx status 769 * mac80211 sends us Tx status
772 */ 770 */
773static void rs_tx_status(void *priv_rate, struct net_device *dev, 771static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
772 struct ieee80211_sta *sta, void *priv_sta,
774 struct sk_buff *skb) 773 struct sk_buff *skb)
775{ 774{
776 int status; 775 int status;
@@ -778,11 +777,9 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
778 int rs_index, index = 0; 777 int rs_index, index = 0;
779 struct iwl_lq_sta *lq_sta; 778 struct iwl_lq_sta *lq_sta;
780 struct iwl_link_quality_cmd *table; 779 struct iwl_link_quality_cmd *table;
781 struct sta_info *sta;
782 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 780 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
783 struct iwl_priv *priv = (struct iwl_priv *)priv_rate; 781 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
784 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 782 struct ieee80211_hw *hw = priv->hw;
785 struct ieee80211_hw *hw = local_to_hw(local);
786 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 783 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
787 struct iwl_rate_scale_data *window = NULL; 784 struct iwl_rate_scale_data *window = NULL;
788 struct iwl_rate_scale_data *search_win = NULL; 785 struct iwl_rate_scale_data *search_win = NULL;
@@ -808,15 +805,7 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
808 if (retries > 15) 805 if (retries > 15)
809 retries = 15; 806 retries = 15;
810 807
811 rcu_read_lock(); 808 lq_sta = (struct iwl_lq_sta *)priv_sta;
812
813 sta = sta_info_get(local, hdr->addr1);
814
815 if (!sta || !sta->rate_ctrl_priv)
816 goto out;
817
818
819 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv;
820 809
821 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && 810 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
822 !lq_sta->ibss_sta_added) 811 !lq_sta->ibss_sta_added)
@@ -962,9 +951,8 @@ static void rs_tx_status(void *priv_rate, struct net_device *dev,
962 } 951 }
963 952
964 /* See if there's a better rate or modulation mode to try. */ 953 /* See if there's a better rate or modulation mode to try. */
965 rs_rate_scale_perform(priv, dev, hdr, sta); 954 rs_rate_scale_perform(priv, hdr, sta, lq_sta);
966out: 955out:
967 rcu_read_unlock();
968 return; 956 return;
969} 957}
970 958
@@ -1140,7 +1128,7 @@ static s32 rs_get_best_rate(struct iwl_priv *priv,
1140static int rs_switch_to_mimo2(struct iwl_priv *priv, 1128static int rs_switch_to_mimo2(struct iwl_priv *priv,
1141 struct iwl_lq_sta *lq_sta, 1129 struct iwl_lq_sta *lq_sta,
1142 struct ieee80211_conf *conf, 1130 struct ieee80211_conf *conf,
1143 struct sta_info *sta, 1131 struct ieee80211_sta *sta,
1144 struct iwl_scale_tbl_info *tbl, int index) 1132 struct iwl_scale_tbl_info *tbl, int index)
1145{ 1133{
1146 u16 rate_mask; 1134 u16 rate_mask;
@@ -1148,10 +1136,10 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1148 s8 is_green = lq_sta->is_green; 1136 s8 is_green = lq_sta->is_green;
1149 1137
1150 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || 1138 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) ||
1151 !sta->sta.ht_info.ht_supported) 1139 !sta->ht_info.ht_supported)
1152 return -1; 1140 return -1;
1153 1141
1154 if (((sta->sta.ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2) 1142 if (((sta->ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2)
1155 == WLAN_HT_CAP_SM_PS_STATIC) 1143 == WLAN_HT_CAP_SM_PS_STATIC)
1156 return -1; 1144 return -1;
1157 1145
@@ -1208,7 +1196,7 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1208static int rs_switch_to_siso(struct iwl_priv *priv, 1196static int rs_switch_to_siso(struct iwl_priv *priv,
1209 struct iwl_lq_sta *lq_sta, 1197 struct iwl_lq_sta *lq_sta,
1210 struct ieee80211_conf *conf, 1198 struct ieee80211_conf *conf,
1211 struct sta_info *sta, 1199 struct ieee80211_sta *sta,
1212 struct iwl_scale_tbl_info *tbl, int index) 1200 struct iwl_scale_tbl_info *tbl, int index)
1213{ 1201{
1214 u16 rate_mask; 1202 u16 rate_mask;
@@ -1216,7 +1204,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1216 s32 rate; 1204 s32 rate;
1217 1205
1218 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) || 1206 if (!(conf->flags & IEEE80211_CONF_SUPPORT_HT_MODE) ||
1219 !sta->sta.ht_info.ht_supported) 1207 !sta->ht_info.ht_supported)
1220 return -1; 1208 return -1;
1221 1209
1222 IWL_DEBUG_RATE("LQ: try to switch to SISO\n"); 1210 IWL_DEBUG_RATE("LQ: try to switch to SISO\n");
@@ -1268,7 +1256,7 @@ static int rs_switch_to_siso(struct iwl_priv *priv,
1268static int rs_move_legacy_other(struct iwl_priv *priv, 1256static int rs_move_legacy_other(struct iwl_priv *priv,
1269 struct iwl_lq_sta *lq_sta, 1257 struct iwl_lq_sta *lq_sta,
1270 struct ieee80211_conf *conf, 1258 struct ieee80211_conf *conf,
1271 struct sta_info *sta, 1259 struct ieee80211_sta *sta,
1272 int index) 1260 int index)
1273{ 1261{
1274 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); 1262 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
@@ -1376,7 +1364,7 @@ out:
1376static int rs_move_siso_to_other(struct iwl_priv *priv, 1364static int rs_move_siso_to_other(struct iwl_priv *priv,
1377 struct iwl_lq_sta *lq_sta, 1365 struct iwl_lq_sta *lq_sta,
1378 struct ieee80211_conf *conf, 1366 struct ieee80211_conf *conf,
1379 struct sta_info *sta, int index) 1367 struct ieee80211_sta *sta, int index)
1380{ 1368{
1381 u8 is_green = lq_sta->is_green; 1369 u8 is_green = lq_sta->is_green;
1382 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); 1370 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
@@ -1487,7 +1475,7 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1487static int rs_move_mimo_to_other(struct iwl_priv *priv, 1475static int rs_move_mimo_to_other(struct iwl_priv *priv,
1488 struct iwl_lq_sta *lq_sta, 1476 struct iwl_lq_sta *lq_sta,
1489 struct ieee80211_conf *conf, 1477 struct ieee80211_conf *conf,
1490 struct sta_info *sta, int index) 1478 struct ieee80211_sta *sta, int index)
1491{ 1479{
1492 s8 is_green = lq_sta->is_green; 1480 s8 is_green = lq_sta->is_green;
1493 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); 1481 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
@@ -1680,12 +1668,11 @@ static void rs_stay_in_table(struct iwl_lq_sta *lq_sta)
1680 * Do rate scaling and search for new modulation mode. 1668 * Do rate scaling and search for new modulation mode.
1681 */ 1669 */
1682static void rs_rate_scale_perform(struct iwl_priv *priv, 1670static void rs_rate_scale_perform(struct iwl_priv *priv,
1683 struct net_device *dev,
1684 struct ieee80211_hdr *hdr, 1671 struct ieee80211_hdr *hdr,
1685 struct sta_info *sta) 1672 struct ieee80211_sta *sta,
1673 struct iwl_lq_sta *lq_sta)
1686{ 1674{
1687 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1675 struct ieee80211_hw *hw = priv->hw;
1688 struct ieee80211_hw *hw = local_to_hw(local);
1689 struct ieee80211_conf *conf = &hw->conf; 1676 struct ieee80211_conf *conf = &hw->conf;
1690 int low = IWL_RATE_INVALID; 1677 int low = IWL_RATE_INVALID;
1691 int high = IWL_RATE_INVALID; 1678 int high = IWL_RATE_INVALID;
@@ -1700,7 +1687,6 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1700 __le16 fc; 1687 __le16 fc;
1701 u16 rate_mask; 1688 u16 rate_mask;
1702 u8 update_lq = 0; 1689 u8 update_lq = 0;
1703 struct iwl_lq_sta *lq_sta;
1704 struct iwl_scale_tbl_info *tbl, *tbl1; 1690 struct iwl_scale_tbl_info *tbl, *tbl1;
1705 u16 rate_scale_index_msk = 0; 1691 u16 rate_scale_index_msk = 0;
1706 u32 rate; 1692 u32 rate;
@@ -1721,11 +1707,10 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1721 return; 1707 return;
1722 } 1708 }
1723 1709
1724 if (!sta || !sta->rate_ctrl_priv) 1710 if (!sta || !lq_sta)
1725 return; 1711 return;
1726 1712
1727 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; 1713 lq_sta->supp_rates = sta->supp_rates[lq_sta->band];
1728 lq_sta->supp_rates = sta->sta.supp_rates[lq_sta->band];
1729 1714
1730 tid = rs_tl_add_packet(lq_sta, hdr); 1715 tid = rs_tl_add_packet(lq_sta, hdr);
1731 1716
@@ -2064,9 +2049,9 @@ out:
2064 2049
2065static void rs_initialize_lq(struct iwl_priv *priv, 2050static void rs_initialize_lq(struct iwl_priv *priv,
2066 struct ieee80211_conf *conf, 2051 struct ieee80211_conf *conf,
2067 struct sta_info *sta) 2052 struct ieee80211_sta *sta,
2053 struct iwl_lq_sta *lq_sta)
2068{ 2054{
2069 struct iwl_lq_sta *lq_sta;
2070 struct iwl_scale_tbl_info *tbl; 2055 struct iwl_scale_tbl_info *tbl;
2071 int rate_idx; 2056 int rate_idx;
2072 int i; 2057 int i;
@@ -2075,10 +2060,9 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2075 u8 active_tbl = 0; 2060 u8 active_tbl = 0;
2076 u8 valid_tx_ant; 2061 u8 valid_tx_ant;
2077 2062
2078 if (!sta || !sta->rate_ctrl_priv) 2063 if (!sta || !lq_sta)
2079 goto out; 2064 goto out;
2080 2065
2081 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv;
2082 i = lq_sta->last_txrate_idx; 2066 i = lq_sta->last_txrate_idx;
2083 2067
2084 if ((lq_sta->lq.sta_id == 0xff) && 2068 if ((lq_sta->lq.sta_id == 0xff) &&
@@ -2119,37 +2103,30 @@ static void rs_initialize_lq(struct iwl_priv *priv,
2119 return; 2103 return;
2120} 2104}
2121 2105
2122static void rs_get_rate(void *priv_rate, struct net_device *dev, 2106static void rs_get_rate(void *priv_r, struct ieee80211_supported_band *sband,
2123 struct ieee80211_supported_band *sband, 2107 struct ieee80211_sta *sta, void *priv_sta,
2124 struct sk_buff *skb, 2108 struct sk_buff *skb, struct rate_selection *sel)
2125 struct rate_selection *sel)
2126{ 2109{
2127 2110
2128 int i; 2111 int i;
2129 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 2112 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
2130 struct ieee80211_conf *conf = &local->hw.conf; 2113 struct ieee80211_conf *conf = &priv->hw->conf;
2131 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 2114 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2132 struct sta_info *sta;
2133 __le16 fc; 2115 __le16 fc;
2134 struct iwl_priv *priv = (struct iwl_priv *)priv_rate;
2135 struct iwl_lq_sta *lq_sta; 2116 struct iwl_lq_sta *lq_sta;
2136 2117
2137 IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); 2118 IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n");
2138 2119
2139 rcu_read_lock();
2140
2141 sta = sta_info_get(local, hdr->addr1);
2142
2143 /* Send management frames and broadcast/multicast data using lowest 2120 /* Send management frames and broadcast/multicast data using lowest
2144 * rate. */ 2121 * rate. */
2145 fc = hdr->frame_control; 2122 fc = hdr->frame_control;
2146 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) || 2123 if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1) ||
2147 !sta || !sta->rate_ctrl_priv) { 2124 !sta || !priv_sta) {
2148 sel->rate_idx = rate_lowest_index(local, sband, sta); 2125 sel->rate_idx = rate_lowest_index(sband, sta);
2149 goto out; 2126 return;
2150 } 2127 }
2151 2128
2152 lq_sta = (struct iwl_lq_sta *)sta->rate_ctrl_priv; 2129 lq_sta = (struct iwl_lq_sta *)priv_sta;
2153 i = lq_sta->last_txrate_idx; 2130 i = lq_sta->last_txrate_idx;
2154 2131
2155 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) && 2132 if ((priv->iw_mode == NL80211_IFTYPE_ADHOC) &&
@@ -2167,23 +2144,22 @@ static void rs_get_rate(void *priv_rate, struct net_device *dev,
2167 lq_sta->lq.sta_id = sta_id; 2144 lq_sta->lq.sta_id = sta_id;
2168 lq_sta->lq.rs_table[0].rate_n_flags = 0; 2145 lq_sta->lq.rs_table[0].rate_n_flags = 0;
2169 lq_sta->ibss_sta_added = 1; 2146 lq_sta->ibss_sta_added = 1;
2170 rs_initialize_lq(priv, conf, sta); 2147 rs_initialize_lq(priv, conf, sta, lq_sta);
2171 } 2148 }
2172 } 2149 }
2173 2150
2174 if ((i < 0) || (i > IWL_RATE_COUNT)) { 2151 if ((i < 0) || (i > IWL_RATE_COUNT)) {
2175 sel->rate_idx = rate_lowest_index(local, sband, sta); 2152 sel->rate_idx = rate_lowest_index(sband, sta);
2176 goto out; 2153 return;
2177 } 2154 }
2178 2155
2179 if (sband->band == IEEE80211_BAND_5GHZ) 2156 if (sband->band == IEEE80211_BAND_5GHZ)
2180 i -= IWL_FIRST_OFDM_RATE; 2157 i -= IWL_FIRST_OFDM_RATE;
2181 sel->rate_idx = i; 2158 sel->rate_idx = i;
2182out:
2183 rcu_read_unlock();
2184} 2159}
2185 2160
2186static void *rs_alloc_sta(void *priv_rate, gfp_t gfp) 2161static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
2162 gfp_t gfp)
2187{ 2163{
2188 struct iwl_lq_sta *lq_sta; 2164 struct iwl_lq_sta *lq_sta;
2189 struct iwl_priv *priv; 2165 struct iwl_priv *priv;
@@ -2206,20 +2182,16 @@ static void *rs_alloc_sta(void *priv_rate, gfp_t gfp)
2206 return lq_sta; 2182 return lq_sta;
2207} 2183}
2208 2184
2209static void rs_rate_init(void *priv_rate, void *priv_sta, 2185static void rs_rate_init(void *priv_r, struct ieee80211_supported_band *sband,
2210 struct ieee80211_local *local, 2186 struct ieee80211_sta *sta, void *priv_sta)
2211 struct sta_info *sta)
2212{ 2187{
2213 int i, j; 2188 int i, j;
2214 struct ieee80211_conf *conf = &local->hw.conf; 2189 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
2215 struct ieee80211_supported_band *sband; 2190 struct ieee80211_conf *conf = &priv->hw->conf;
2216 struct iwl_priv *priv = (struct iwl_priv *)priv_rate;
2217 struct iwl_lq_sta *lq_sta = priv_sta; 2191 struct iwl_lq_sta *lq_sta = priv_sta;
2218 2192
2219 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
2220
2221 lq_sta->flush_timer = 0; 2193 lq_sta->flush_timer = 0;
2222 lq_sta->supp_rates = sta->sta.supp_rates[sband->band]; 2194 lq_sta->supp_rates = sta->supp_rates[sband->band];
2223 for (j = 0; j < LQ_SIZE; j++) 2195 for (j = 0; j < LQ_SIZE; j++)
2224 for (i = 0; i < IWL_RATE_COUNT; i++) 2196 for (i = 0; i < IWL_RATE_COUNT; i++)
2225 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); 2197 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]);
@@ -2232,17 +2204,17 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2232 2204
2233 lq_sta->ibss_sta_added = 0; 2205 lq_sta->ibss_sta_added = 0;
2234 if (priv->iw_mode == NL80211_IFTYPE_AP) { 2206 if (priv->iw_mode == NL80211_IFTYPE_AP) {
2235 u8 sta_id = iwl_find_station(priv, sta->sta.addr); 2207 u8 sta_id = iwl_find_station(priv, sta->addr);
2236 DECLARE_MAC_BUF(mac); 2208 DECLARE_MAC_BUF(mac);
2237 2209
2238 /* for IBSS the call are from tasklet */ 2210 /* for IBSS the call are from tasklet */
2239 IWL_DEBUG_RATE("LQ: ADD station %s\n", 2211 IWL_DEBUG_RATE("LQ: ADD station %s\n",
2240 print_mac(mac, sta->sta.addr)); 2212 print_mac(mac, sta->addr));
2241 2213
2242 if (sta_id == IWL_INVALID_STATION) { 2214 if (sta_id == IWL_INVALID_STATION) {
2243 IWL_DEBUG_RATE("LQ: ADD station %s\n", 2215 IWL_DEBUG_RATE("LQ: ADD station %s\n",
2244 print_mac(mac, sta->sta.addr)); 2216 print_mac(mac, sta->addr));
2245 sta_id = iwl_add_station_flags(priv, sta->sta.addr, 2217 sta_id = iwl_add_station_flags(priv, sta->addr,
2246 0, CMD_ASYNC, NULL); 2218 0, CMD_ASYNC, NULL);
2247 } 2219 }
2248 if ((sta_id != IWL_INVALID_STATION)) { 2220 if ((sta_id != IWL_INVALID_STATION)) {
@@ -2256,11 +2228,11 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2256 /* Find highest tx rate supported by hardware and destination station */ 2228 /* Find highest tx rate supported by hardware and destination station */
2257 lq_sta->last_txrate_idx = 3; 2229 lq_sta->last_txrate_idx = 3;
2258 for (i = 0; i < sband->n_bitrates; i++) 2230 for (i = 0; i < sband->n_bitrates; i++)
2259 if (sta->sta.supp_rates[sband->band] & BIT(i)) 2231 if (sta->supp_rates[sband->band] & BIT(i))
2260 lq_sta->last_txrate_idx = i; 2232 lq_sta->last_txrate_idx = i;
2261 2233
2262 /* For MODE_IEEE80211A, skip over cck rates in global rate table */ 2234 /* For MODE_IEEE80211A, skip over cck rates in global rate table */
2263 if (local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) 2235 if (sband->band == IEEE80211_BAND_5GHZ)
2264 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; 2236 lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE;
2265 2237
2266 lq_sta->is_dup = 0; 2238 lq_sta->is_dup = 0;
@@ -2301,7 +2273,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2301 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; 2273 lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID;
2302 lq_sta->drv = priv; 2274 lq_sta->drv = priv;
2303 2275
2304 rs_initialize_lq(priv, conf, sta); 2276 rs_initialize_lq(priv, conf, sta, lq_sta);
2305} 2277}
2306 2278
2307static void rs_fill_link_cmd(const struct iwl_priv *priv, 2279static void rs_fill_link_cmd(const struct iwl_priv *priv,
@@ -2423,9 +2395,9 @@ static void rs_fill_link_cmd(const struct iwl_priv *priv,
2423 lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000); 2395 lq_cmd->agg_params.agg_time_limit = cpu_to_le16(4000);
2424} 2396}
2425 2397
2426static void *rs_alloc(struct ieee80211_local *local) 2398static void *rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
2427{ 2399{
2428 return local->hw.priv; 2400 return hw->priv;
2429} 2401}
2430/* rate scale requires free function to be implemented */ 2402/* rate scale requires free function to be implemented */
2431static void rs_free(void *priv_rate) 2403static void rs_free(void *priv_rate)
@@ -2446,12 +2418,12 @@ static void rs_clear(void *priv_rate)
2446#endif /* CONFIG_IWLWIFI_DEBUG */ 2418#endif /* CONFIG_IWLWIFI_DEBUG */
2447} 2419}
2448 2420
2449static void rs_free_sta(void *priv_rate, void *priv_sta) 2421static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
2422 void *priv_sta)
2450{ 2423{
2451 struct iwl_lq_sta *lq_sta = priv_sta; 2424 struct iwl_lq_sta *lq_sta = priv_sta;
2452 struct iwl_priv *priv; 2425 struct iwl_priv *priv = priv_r;
2453 2426
2454 priv = (struct iwl_priv *)priv_rate;
2455 IWL_DEBUG_RATE("enter\n"); 2427 IWL_DEBUG_RATE("enter\n");
2456 kfree(lq_sta); 2428 kfree(lq_sta);
2457 IWL_DEBUG_RATE("leave\n"); 2429 IWL_DEBUG_RATE("leave\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 273762769767..7330890fd05e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2504,8 +2504,7 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2504 2504
2505 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 2505 priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK;
2506 2506
2507 if (priv->current_ht_config.is_ht) 2507 iwl_set_rxon_ht(priv, &priv->current_ht_config);
2508 iwl_set_rxon_ht(priv, &priv->current_ht_config);
2509 2508
2510 iwl_set_rxon_chain(priv); 2509 iwl_set_rxon_chain(priv);
2511 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id); 2510 priv->staging_rxon.assoc_id = cpu_to_le16(priv->assoc_id);
@@ -2568,8 +2567,6 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2568 iwl_chain_noise_reset(priv); 2567 iwl_chain_noise_reset(priv);
2569 priv->start_calib = 1; 2568 priv->start_calib = 1;
2570 2569
2571 /* we have just associated, don't start scan too early */
2572 priv->next_scan_jiffies = jiffies + IWL_DELAY_NEXT_SCAN;
2573} 2570}
2574 2571
2575static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 2572static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
@@ -3171,6 +3168,10 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
3171 priv->power_data.dtim_period = bss_conf->dtim_period; 3168 priv->power_data.dtim_period = bss_conf->dtim_period;
3172 priv->timestamp = bss_conf->timestamp; 3169 priv->timestamp = bss_conf->timestamp;
3173 priv->assoc_capability = bss_conf->assoc_capability; 3170 priv->assoc_capability = bss_conf->assoc_capability;
3171
3172 /* we have just associated, don't start scan too early
3173 * leave time for EAPOL exchange to complete
3174 */
3174 priv->next_scan_jiffies = jiffies + 3175 priv->next_scan_jiffies = jiffies +
3175 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC; 3176 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
3176 mutex_lock(&priv->mutex); 3177 mutex_lock(&priv->mutex);
@@ -3189,9 +3190,9 @@ static void iwl4965_bss_info_changed(struct ieee80211_hw *hw,
3189 3190
3190static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len) 3191static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
3191{ 3192{
3192 int ret;
3193 unsigned long flags; 3193 unsigned long flags;
3194 struct iwl_priv *priv = hw->priv; 3194 struct iwl_priv *priv = hw->priv;
3195 int ret;
3195 3196
3196 IWL_DEBUG_MAC80211("enter\n"); 3197 IWL_DEBUG_MAC80211("enter\n");
3197 3198
@@ -3210,20 +3211,27 @@ static int iwl_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t ssid_len)
3210 goto out_unlock; 3211 goto out_unlock;
3211 } 3212 }
3212 3213
3213 /* we don't schedule scan within next_scan_jiffies period */ 3214 /* We don't schedule scan within next_scan_jiffies period.
3215 * Avoid scanning during possible EAPOL exchange, return
3216 * success immediately.
3217 */
3214 if (priv->next_scan_jiffies && 3218 if (priv->next_scan_jiffies &&
3215 time_after(priv->next_scan_jiffies, jiffies)) { 3219 time_after(priv->next_scan_jiffies, jiffies)) {
3216 IWL_DEBUG_SCAN("scan rejected: within next scan period\n"); 3220 IWL_DEBUG_SCAN("scan rejected: within next scan period\n");
3217 ret = -EAGAIN; 3221 queue_work(priv->workqueue, &priv->scan_completed);
3222 ret = 0;
3218 goto out_unlock; 3223 goto out_unlock;
3219 } 3224 }
3225
3220 /* if we just finished scan ask for delay */ 3226 /* if we just finished scan ask for delay */
3221 if (iwl_is_associated(priv) && priv->last_scan_jiffies && 3227 if (iwl_is_associated(priv) && priv->last_scan_jiffies &&
3222 time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, jiffies)) { 3228 time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, jiffies)) {
3223 IWL_DEBUG_SCAN("scan rejected: within previous scan period\n"); 3229 IWL_DEBUG_SCAN("scan rejected: within previous scan period\n");
3224 ret = -EAGAIN; 3230 queue_work(priv->workqueue, &priv->scan_completed);
3231 ret = 0;
3225 goto out_unlock; 3232 goto out_unlock;
3226 } 3233 }
3234
3227 if (ssid_len) { 3235 if (ssid_len) {
3228 priv->one_direct_scan = 1; 3236 priv->one_direct_scan = 1;
3229 priv->direct_ssid_len = min_t(u8, ssid_len, IW_ESSID_MAX_SIZE); 3237 priv->direct_ssid_len = min_t(u8, ssid_len, IW_ESSID_MAX_SIZE);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index d80184ee911c..4c312c55f90c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -646,8 +646,14 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
646 struct iwl_rxon_cmd *rxon = &priv->staging_rxon; 646 struct iwl_rxon_cmd *rxon = &priv->staging_rxon;
647 u32 val; 647 u32 val;
648 648
649 if (!ht_info->is_ht) 649 if (!ht_info->is_ht) {
650 rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED_MSK |
651 RXON_FLG_CHANNEL_MODE_PURE_40_MSK |
652 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK |
653 RXON_FLG_FAT_PROT_MSK |
654 RXON_FLG_HT_PROT_MSK);
650 return; 655 return;
656 }
651 657
652 /* Set up channel bandwidth: 20 MHz only, or 20/40 mixed if fat ok */ 658 /* Set up channel bandwidth: 20 MHz only, or 20/40 mixed if fat ok */
653 if (iwl_is_fat_tx_allowed(priv, NULL)) 659 if (iwl_is_fat_tx_allowed(priv, NULL))
@@ -697,8 +703,12 @@ void iwl_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_info *ht_info)
697} 703}
698EXPORT_SYMBOL(iwl_set_rxon_ht); 704EXPORT_SYMBOL(iwl_set_rxon_ht);
699 705
700/* 706#define IWL_NUM_RX_CHAINS_MULTIPLE 3
701 * Determine how many receiver/antenna chains to use. 707#define IWL_NUM_RX_CHAINS_SINGLE 2
708#define IWL_NUM_IDLE_CHAINS_DUAL 2
709#define IWL_NUM_IDLE_CHAINS_SINGLE 1
710
711/* Determine how many receiver/antenna chains to use.
702 * More provides better reception via diversity. Fewer saves power. 712 * More provides better reception via diversity. Fewer saves power.
703 * MIMO (dual stream) requires at least 2, but works better with 3. 713 * MIMO (dual stream) requires at least 2, but works better with 3.
704 * This does not determine *which* chains to use, just how many. 714 * This does not determine *which* chains to use, just how many.
@@ -711,9 +721,9 @@ static int iwl_get_active_rx_chain_count(struct iwl_priv *priv)
711 /* # of Rx chains to use when expecting MIMO. */ 721 /* # of Rx chains to use when expecting MIMO. */
712 if (is_single || (!is_cam && (priv->current_ht_config.sm_ps == 722 if (is_single || (!is_cam && (priv->current_ht_config.sm_ps ==
713 WLAN_HT_CAP_SM_PS_STATIC))) 723 WLAN_HT_CAP_SM_PS_STATIC)))
714 return 2; 724 return IWL_NUM_RX_CHAINS_SINGLE;
715 else 725 else
716 return 3; 726 return IWL_NUM_RX_CHAINS_MULTIPLE;
717} 727}
718 728
719static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) 729static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt)
@@ -724,10 +734,11 @@ static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt)
724 switch (priv->current_ht_config.sm_ps) { 734 switch (priv->current_ht_config.sm_ps) {
725 case WLAN_HT_CAP_SM_PS_STATIC: 735 case WLAN_HT_CAP_SM_PS_STATIC:
726 case WLAN_HT_CAP_SM_PS_DYNAMIC: 736 case WLAN_HT_CAP_SM_PS_DYNAMIC:
727 idle_cnt = (is_cam) ? 2 : 1; 737 idle_cnt = (is_cam) ? IWL_NUM_IDLE_CHAINS_DUAL :
738 IWL_NUM_IDLE_CHAINS_SINGLE;
728 break; 739 break;
729 case WLAN_HT_CAP_SM_PS_DISABLED: 740 case WLAN_HT_CAP_SM_PS_DISABLED:
730 idle_cnt = (is_cam) ? active_cnt : 1; 741 idle_cnt = (is_cam) ? active_cnt : IWL_NUM_IDLE_CHAINS_SINGLE;
731 break; 742 break;
732 case WLAN_HT_CAP_SM_PS_INVALID: 743 case WLAN_HT_CAP_SM_PS_INVALID:
733 default: 744 default:
@@ -796,7 +807,7 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
796 807
797 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain); 808 priv->staging_rxon.rx_chain = cpu_to_le16(rx_chain);
798 809
799 if (!is_single && (active_rx_cnt >= 2) && is_cam) 810 if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam)
800 priv->staging_rxon.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; 811 priv->staging_rxon.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK;
801 else 812 else
802 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; 813 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK;
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 09c264be0496..bf855c35b0c1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -463,11 +463,6 @@ void iwl_init_scan_params(struct iwl_priv *priv)
463 463
464int iwl_scan_initiate(struct iwl_priv *priv) 464int iwl_scan_initiate(struct iwl_priv *priv)
465{ 465{
466 if (priv->iw_mode == NL80211_IFTYPE_AP) {
467 IWL_ERROR("APs don't scan.\n");
468 return 0;
469 }
470
471 if (!iwl_is_ready_rf(priv)) { 466 if (!iwl_is_ready_rf(priv)) {
472 IWL_DEBUG_SCAN("Aborting scan due to not ready.\n"); 467 IWL_DEBUG_SCAN("Aborting scan due to not ready.\n");
473 return -EIO; 468 return -EIO;
@@ -479,8 +474,7 @@ int iwl_scan_initiate(struct iwl_priv *priv)
479 } 474 }
480 475
481 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 476 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
482 IWL_DEBUG_SCAN("Scan request while abort pending. " 477 IWL_DEBUG_SCAN("Scan request while abort pending\n");
483 "Queuing.\n");
484 return -EAGAIN; 478 return -EAGAIN;
485 } 479 }
486 480
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index e9feca4033f9..907a53ebc6e4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -1200,10 +1200,9 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1200 /* If a Tx command is being handled and it isn't in the actual 1200 /* If a Tx command is being handled and it isn't in the actual
1201 * command queue then there a command routing bug has been introduced 1201 * command queue then there a command routing bug has been introduced
1202 * in the queue management code. */ 1202 * in the queue management code. */
1203 if (txq_id != IWL_CMD_QUEUE_NUM) 1203 if (WARN(txq_id != IWL_CMD_QUEUE_NUM,
1204 IWL_ERROR("Error wrong command queue %d command id 0x%X\n", 1204 "wrong command queue %d, command id 0x%X\n", txq_id, pkt->hdr.cmd))
1205 txq_id, pkt->hdr.cmd); 1205 return;
1206 BUG_ON(txq_id != IWL_CMD_QUEUE_NUM);
1207 1206
1208 cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge); 1207 cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge);
1209 cmd = priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index]; 1208 cmd = priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index];
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 62b26befddc5..d15a2c997954 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -7370,15 +7370,6 @@ static ssize_t show_temperature(struct device *d,
7370 7370
7371static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL); 7371static DEVICE_ATTR(temperature, S_IRUGO, show_temperature, NULL);
7372 7372
7373static ssize_t show_rs_window(struct device *d,
7374 struct device_attribute *attr,
7375 char *buf)
7376{
7377 struct iwl3945_priv *priv = d->driver_data;
7378 return iwl3945_fill_rs_info(priv->hw, buf, IWL_AP_ID);
7379}
7380static DEVICE_ATTR(rs_window, S_IRUGO, show_rs_window, NULL);
7381
7382static ssize_t show_tx_power(struct device *d, 7373static ssize_t show_tx_power(struct device *d,
7383 struct device_attribute *attr, char *buf) 7374 struct device_attribute *attr, char *buf)
7384{ 7375{
@@ -7840,7 +7831,6 @@ static struct attribute *iwl3945_sysfs_entries[] = {
7840#endif 7831#endif
7841 &dev_attr_power_level.attr, 7832 &dev_attr_power_level.attr,
7842 &dev_attr_retry_rate.attr, 7833 &dev_attr_retry_rate.attr,
7843 &dev_attr_rs_window.attr,
7844 &dev_attr_statistics.attr, 7834 &dev_attr_statistics.attr,
7845 &dev_attr_status.attr, 7835 &dev_attr_status.attr,
7846 &dev_attr_temperature.attr, 7836 &dev_attr_temperature.attr,
@@ -7908,6 +7898,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7908 SET_IEEE80211_DEV(hw, &pdev->dev); 7898 SET_IEEE80211_DEV(hw, &pdev->dev);
7909 7899
7910 hw->rate_control_algorithm = "iwl-3945-rs"; 7900 hw->rate_control_algorithm = "iwl-3945-rs";
7901 hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
7911 7902
7912 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 7903 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
7913 priv = hw->priv; 7904 priv = hw->priv;
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index acb889e25900..f6f3753da303 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -58,6 +58,7 @@ struct lbs_802_11_security {
58 u8 WPA2enabled; 58 u8 WPA2enabled;
59 u8 wep_enabled; 59 u8 wep_enabled;
60 u8 auth_mode; 60 u8 auth_mode;
61 u32 key_mgmt;
61}; 62};
62 63
63/** Current Basic Service Set State Structure */ 64/** Current Basic Service Set State Structure */
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 11297dcf9fc3..6ebdd7f161f1 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1598,8 +1598,20 @@ static int lbs_set_encodeext(struct net_device *dev,
1598 } 1598 }
1599 1599
1600out: 1600out:
1601 if (ret == 0) { /* key installation is time critical: postpone not! */ 1601 if (ret == 0) {
1602 lbs_do_association_work(priv); 1602 /* 802.1x and WPA rekeying must happen as quickly as possible,
1603 * especially during the 4-way handshake; thus if in
1604 * infrastructure mode, and either (a) 802.1x is enabled or
1605 * (b) WPA is being used, set the key right away.
1606 */
1607 if (assoc_req->mode == IW_MODE_INFRA &&
1608 ((assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_802_1X) ||
1609 (assoc_req->secinfo.key_mgmt & IW_AUTH_KEY_MGMT_PSK) ||
1610 assoc_req->secinfo.WPAenabled ||
1611 assoc_req->secinfo.WPA2enabled)) {
1612 lbs_do_association_work(priv);
1613 } else
1614 lbs_postpone_association_work(priv);
1603 } else { 1615 } else {
1604 lbs_cancel_association_work(priv); 1616 lbs_cancel_association_work(priv);
1605 } 1617 }
@@ -1707,13 +1719,17 @@ static int lbs_set_auth(struct net_device *dev,
1707 case IW_AUTH_TKIP_COUNTERMEASURES: 1719 case IW_AUTH_TKIP_COUNTERMEASURES:
1708 case IW_AUTH_CIPHER_PAIRWISE: 1720 case IW_AUTH_CIPHER_PAIRWISE:
1709 case IW_AUTH_CIPHER_GROUP: 1721 case IW_AUTH_CIPHER_GROUP:
1710 case IW_AUTH_KEY_MGMT:
1711 case IW_AUTH_DROP_UNENCRYPTED: 1722 case IW_AUTH_DROP_UNENCRYPTED:
1712 /* 1723 /*
1713 * libertas does not use these parameters 1724 * libertas does not use these parameters
1714 */ 1725 */
1715 break; 1726 break;
1716 1727
1728 case IW_AUTH_KEY_MGMT:
1729 assoc_req->secinfo.key_mgmt = dwrq->value;
1730 updated = 1;
1731 break;
1732
1717 case IW_AUTH_WPA_VERSION: 1733 case IW_AUTH_WPA_VERSION:
1718 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) { 1734 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
1719 assoc_req->secinfo.WPAenabled = 0; 1735 assoc_req->secinfo.WPAenabled = 0;
@@ -1793,6 +1809,10 @@ static int lbs_get_auth(struct net_device *dev,
1793 lbs_deb_enter(LBS_DEB_WEXT); 1809 lbs_deb_enter(LBS_DEB_WEXT);
1794 1810
1795 switch (dwrq->flags & IW_AUTH_INDEX) { 1811 switch (dwrq->flags & IW_AUTH_INDEX) {
1812 case IW_AUTH_KEY_MGMT:
1813 dwrq->value = priv->secinfo.key_mgmt;
1814 break;
1815
1796 case IW_AUTH_WPA_VERSION: 1816 case IW_AUTH_WPA_VERSION:
1797 dwrq->value = 0; 1817 dwrq->value = 0;
1798 if (priv->secinfo.WPAenabled) 1818 if (priv->secinfo.WPAenabled)
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index f479c1af6782..25bae7933aa5 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -398,7 +398,7 @@ static int netwave_probe(struct pcmcia_device *link)
398 link->io.IOAddrLines = 5; 398 link->io.IOAddrLines = 5;
399 399
400 /* Interrupt setup */ 400 /* Interrupt setup */
401 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 401 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
402 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 402 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
403 link->irq.Handler = &netwave_interrupt; 403 link->irq.Handler = &netwave_interrupt;
404 404
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 9a2fcc0163d6..50904771f291 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -5291,7 +5291,7 @@ static int orinoco_ioctl_getrid(struct net_device *dev,
5291/* Trigger a scan (look for other cells in the vicinity) */ 5291/* Trigger a scan (look for other cells in the vicinity) */
5292static int orinoco_ioctl_setscan(struct net_device *dev, 5292static int orinoco_ioctl_setscan(struct net_device *dev,
5293 struct iw_request_info *info, 5293 struct iw_request_info *info,
5294 struct iw_param *srq, 5294 struct iw_point *srq,
5295 char *extra) 5295 char *extra)
5296{ 5296{
5297 struct orinoco_private *priv = netdev_priv(dev); 5297 struct orinoco_private *priv = netdev_priv(dev);
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 1ccf5a40cf06..9eaa252c2430 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -121,7 +121,7 @@ orinoco_cs_probe(struct pcmcia_device *link)
121 link->priv = dev; 121 link->priv = dev;
122 122
123 /* Interrupt setup */ 123 /* Interrupt setup */
124 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 124 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
125 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 125 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
126 link->irq.Handler = orinoco_interrupt; 126 link->irq.Handler = orinoco_interrupt;
127 link->irq.Instance = dev; 127 link->irq.Instance = dev;
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 963960dc30f2..44da0d19b5c8 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -325,7 +325,7 @@ static int ray_probe(struct pcmcia_device *p_dev)
325 p_dev->io.IOAddrLines = 5; 325 p_dev->io.IOAddrLines = 5;
326 326
327 /* Interrupt setup. For PCMCIA, driver takes what's given */ 327 /* Interrupt setup. For PCMCIA, driver takes what's given */
328 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 328 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
329 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 329 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
330 p_dev->irq.Handler = &ray_interrupt; 330 p_dev->irq.Handler = &ray_interrupt;
331 331
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 00e965b9da75..2b414899dfa0 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -1627,7 +1627,6 @@ static int rndis_iw_set_encode_ext(struct net_device *dev,
1627static int rndis_iw_set_scan(struct net_device *dev, 1627static int rndis_iw_set_scan(struct net_device *dev,
1628 struct iw_request_info *info, union iwreq_data *wrqu, char *extra) 1628 struct iw_request_info *info, union iwreq_data *wrqu, char *extra)
1629{ 1629{
1630 struct iw_param *param = &wrqu->param;
1631 struct usbnet *usbdev = dev->priv; 1630 struct usbnet *usbdev = dev->priv;
1632 union iwreq_data evt; 1631 union iwreq_data evt;
1633 int ret = -EINVAL; 1632 int ret = -EINVAL;
@@ -1635,7 +1634,7 @@ static int rndis_iw_set_scan(struct net_device *dev,
1635 1634
1636 devdbg(usbdev, "SIOCSIWSCAN"); 1635 devdbg(usbdev, "SIOCSIWSCAN");
1637 1636
1638 if (param->flags == 0) { 1637 if (wrqu->data.flags == 0) {
1639 tmp = ccpu2(1); 1638 tmp = ccpu2(1);
1640 ret = rndis_set_oid(usbdev, OID_802_11_BSSID_LIST_SCAN, &tmp, 1639 ret = rndis_set_oid(usbdev, OID_802_11_BSSID_LIST_SCAN, &tmp,
1641 sizeof(tmp)); 1640 sizeof(tmp));
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 485c40de5cc0..2c6cc5c374ff 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -543,7 +543,8 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
543 * provided but key 0 is not, then the key is not found 543 * provided but key 0 is not, then the key is not found
544 * by the hardware during RX). 544 * by the hardware during RX).
545 */ 545 */
546 key->hw_key_idx = 0; 546 if (cmd == SET_KEY)
547 key->hw_key_idx = 0;
547 548
548 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) 549 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
549 set_key = rt2x00dev->ops->lib->config_pairwise_key; 550 set_key = rt2x00dev->ops->lib->config_pairwise_key;
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 2c36b91ff4c7..a461620b489f 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -381,7 +381,7 @@ static int rt61pci_config_shared_key(struct rt2x00_dev *rt2x00dev,
381 if (reg && reg == mask) 381 if (reg && reg == mask)
382 return -ENOSPC; 382 return -ENOSPC;
383 383
384 key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 384 key->hw_key_idx += reg ? ffz(reg) : 0;
385 385
386 /* 386 /*
387 * Upload key to hardware 387 * Upload key to hardware
@@ -477,7 +477,7 @@ static int rt61pci_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
477 return -ENOSPC; 477 return -ENOSPC;
478 } 478 }
479 479
480 key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 480 key->hw_key_idx += reg ? ffz(reg) : 0;
481 481
482 /* 482 /*
483 * Upload key to hardware 483 * Upload key to hardware
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 27dde3e34603..934f8e03c5aa 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -393,7 +393,7 @@ static int rt73usb_config_shared_key(struct rt2x00_dev *rt2x00dev,
393 if (reg && reg == mask) 393 if (reg && reg == mask)
394 return -ENOSPC; 394 return -ENOSPC;
395 395
396 key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 396 key->hw_key_idx += reg ? ffz(reg) : 0;
397 397
398 /* 398 /*
399 * Upload key to hardware 399 * Upload key to hardware
@@ -494,7 +494,7 @@ static int rt73usb_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
494 return -ENOSPC; 494 return -ENOSPC;
495 } 495 }
496 496
497 key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 497 key->hw_key_idx += reg ? ffz(reg) : 0;
498 498
499 /* 499 /*
500 * Upload key to hardware 500 * Upload key to hardware
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index e368759d1d89..67b26d3c3cd5 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -195,7 +195,7 @@ spectrum_cs_probe(struct pcmcia_device *link)
195 link->priv = dev; 195 link->priv = dev;
196 196
197 /* Interrupt setup */ 197 /* Interrupt setup */
198 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | 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;
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 00a3559e5aa4..b5de38a9b791 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4496,7 +4496,7 @@ wavelan_probe(struct pcmcia_device *p_dev)
4496 p_dev->io.IOAddrLines = 3; 4496 p_dev->io.IOAddrLines = 3;
4497 4497
4498 /* Interrupt setup */ 4498 /* Interrupt setup */
4499 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 4499 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
4500 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 4500 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
4501 p_dev->irq.Handler = wavelan_interrupt; 4501 p_dev->irq.Handler = wavelan_interrupt;
4502 4502
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index b6d4e04b8ab4..74a5ad2f1223 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1917,7 +1917,7 @@ static int wl3501_probe(struct pcmcia_device *p_dev)
1917 p_dev->io.IOAddrLines = 5; 1917 p_dev->io.IOAddrLines = 5;
1918 1918
1919 /* Interrupt setup */ 1919 /* Interrupt setup */
1920 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 1920 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
1921 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 1921 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
1922 p_dev->irq.Handler = wl3501_interrupt; 1922 p_dev->irq.Handler = wl3501_interrupt;
1923 1923