mac80211: update to wireless-testing 2012-04-13
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath5k/base.c
2 +++ b/drivers/net/wireless/ath/ath5k/base.c
3 @@ -1171,7 +1171,7 @@ ath5k_check_ibss_tsf(struct ath5k_hw *ah
4  
5         if (ieee80211_is_beacon(mgmt->frame_control) &&
6             le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS &&
7 -           memcmp(mgmt->bssid, common->curbssid, ETH_ALEN) == 0) {
8 +           compare_ether_addr(mgmt->bssid, common->curbssid) == 0) {
9                 /*
10                  * Received an IBSS beacon with the same BSSID. Hardware *must*
11                  * have updated the local TSF. We have to work around various
12 @@ -1235,7 +1235,7 @@ ath5k_update_beacon_rssi(struct ath5k_hw
13  
14         /* only beacons from our BSSID */
15         if (!ieee80211_is_beacon(mgmt->frame_control) ||
16 -           memcmp(mgmt->bssid, common->curbssid, ETH_ALEN) != 0)
17 +           compare_ether_addr(mgmt->bssid, common->curbssid) != 0)
18                 return;
19  
20         ewma_add(&ah->ah_beacon_rssi_avg, rssi);
21 @@ -2416,6 +2416,19 @@ ath5k_tx_complete_poll_work(struct work_
22  * Initialization routines *
23  \*************************/
24  
25 +static const struct ieee80211_iface_limit if_limits[] = {
26 +       { .max = 256,   .types = BIT(NL80211_IFTYPE_STATION) },
27 +       { .max = 4,     .types = BIT(NL80211_IFTYPE_AP) |
28 +                                BIT(NL80211_IFTYPE_MESH_POINT) },
29 +};
30 +
31 +static const struct ieee80211_iface_combination if_comb = {
32 +       .limits = if_limits,
33 +       .n_limits = ARRAY_SIZE(if_limits),
34 +       .max_interfaces = 256,
35 +       .num_different_channels = 1,
36 +};
37 +
38  int __devinit
39  ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops)
40  {
41 @@ -2437,6 +2450,9 @@ ath5k_init_ah(struct ath5k_hw *ah, const
42                 BIT(NL80211_IFTYPE_ADHOC) |
43                 BIT(NL80211_IFTYPE_MESH_POINT);
44  
45 +       hw->wiphy->iface_combinations = &if_comb;
46 +       hw->wiphy->n_iface_combinations = 1;
47 +
48         /* SW support for IBSS_RSN is provided by mac80211 */
49         hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
50  
51 --- a/drivers/net/wireless/ath/ath9k/ani.c
52 +++ b/drivers/net/wireless/ath/ath9k/ani.c
53 @@ -274,7 +274,9 @@ static void ath9k_hw_set_ofdm_nil(struct
54                 aniState->rssiThrLow, aniState->rssiThrHigh);
55  
56         if (aniState->update_ani)
57 -               aniState->ofdmNoiseImmunityLevel = immunityLevel;
58 +               aniState->ofdmNoiseImmunityLevel =
59 +                       (immunityLevel > ATH9K_ANI_OFDM_DEF_LEVEL) ?
60 +                       immunityLevel : ATH9K_ANI_OFDM_DEF_LEVEL;
61  
62         entry_ofdm = &ofdm_level_table[aniState->ofdmNoiseImmunityLevel];
63         entry_cck = &cck_level_table[aniState->cckNoiseImmunityLevel];
64 @@ -340,7 +342,9 @@ static void ath9k_hw_set_cck_nil(struct 
65                 immunityLevel = ATH9K_ANI_CCK_MAX_LEVEL_LOW_RSSI;
66  
67         if (aniState->update_ani)
68 -               aniState->cckNoiseImmunityLevel = immunityLevel;
69 +               aniState->cckNoiseImmunityLevel =
70 +                       (immunityLevel > ATH9K_ANI_CCK_DEF_LEVEL) ?
71 +                       immunityLevel : ATH9K_ANI_CCK_DEF_LEVEL;
72  
73         entry_ofdm = &ofdm_level_table[aniState->ofdmNoiseImmunityLevel];
74         entry_cck = &cck_level_table[aniState->cckNoiseImmunityLevel];
75 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
76 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
77 @@ -618,19 +618,10 @@ static void ar5008_hw_init_bb(struct ath
78         u32 synthDelay;
79  
80         synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
81 -       if (IS_CHAN_B(chan))
82 -               synthDelay = (4 * synthDelay) / 22;
83 -       else
84 -               synthDelay /= 10;
85 -
86 -       if (IS_CHAN_HALF_RATE(chan))
87 -               synthDelay *= 2;
88 -       else if (IS_CHAN_QUARTER_RATE(chan))
89 -               synthDelay *= 4;
90  
91         REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
92  
93 -       udelay(synthDelay + BASE_ACTIVATE_DELAY);
94 +       ath9k_hw_synth_delay(ah, chan, synthDelay);
95  }
96  
97  static void ar5008_hw_init_chain_masks(struct ath_hw *ah)
98 @@ -868,7 +859,7 @@ static int ar5008_hw_process_ini(struct 
99         ar5008_hw_set_channel_regs(ah, chan);
100         ar5008_hw_init_chain_masks(ah);
101         ath9k_olc_init(ah);
102 -       ath9k_hw_apply_txpower(ah, chan);
103 +       ath9k_hw_apply_txpower(ah, chan, false);
104  
105         /* Write analog registers */
106         if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
107 @@ -948,12 +939,8 @@ static bool ar5008_hw_rfbus_req(struct a
108  static void ar5008_hw_rfbus_done(struct ath_hw *ah)
109  {
110         u32 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
111 -       if (IS_CHAN_B(ah->curchan))
112 -               synthDelay = (4 * synthDelay) / 22;
113 -       else
114 -               synthDelay /= 10;
115  
116 -       udelay(synthDelay + BASE_ACTIVATE_DELAY);
117 +       ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
118  
119         REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
120  }
121 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
122 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
123 @@ -1000,10 +1000,12 @@ static bool ar9003_hw_init_cal(struct at
124         if (mci && IS_CHAN_2GHZ(chan) && run_agc_cal)
125                 ar9003_mci_init_cal_req(ah, &is_reusable);
126  
127 -       txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
128 -       REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
129 -       udelay(5);
130 -       REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
131 +       if (!(IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))) {
132 +               txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
133 +               REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
134 +               udelay(5);
135 +               REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
136 +       }
137  
138  skip_tx_iqcal:
139         if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
140 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
141 +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
142 @@ -54,7 +54,7 @@ void ar9003_paprd_enable(struct ath_hw *
143  
144         if (val) {
145                 ah->paprd_table_write_done = true;
146 -               ath9k_hw_apply_txpower(ah, chan);
147 +               ath9k_hw_apply_txpower(ah, chan, false);
148         }
149  
150         REG_RMW_FIELD(ah, AR_PHY_PAPRD_CTRL0_B0,
151 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
152 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
153 @@ -524,22 +524,10 @@ static void ar9003_hw_init_bb(struct ath
154          * Value is in 100ns increments.
155          */
156         synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
157 -       if (IS_CHAN_B(chan))
158 -               synthDelay = (4 * synthDelay) / 22;
159 -       else
160 -               synthDelay /= 10;
161  
162         /* Activate the PHY (includes baseband activate + synthesizer on) */
163         REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
164 -
165 -       /*
166 -        * There is an issue if the AP starts the calibration before
167 -        * the base band timeout completes.  This could result in the
168 -        * rx_clear false triggering.  As a workaround we add delay an
169 -        * extra BASE_ACTIVATE_DELAY usecs to ensure this condition
170 -        * does not happen.
171 -        */
172 -       udelay(synthDelay + BASE_ACTIVATE_DELAY);
173 +       ath9k_hw_synth_delay(ah, chan, synthDelay);
174  }
175  
176  static void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
177 @@ -690,7 +678,7 @@ static int ar9003_hw_process_ini(struct 
178         ar9003_hw_override_ini(ah);
179         ar9003_hw_set_channel_regs(ah, chan);
180         ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
181 -       ath9k_hw_apply_txpower(ah, chan);
182 +       ath9k_hw_apply_txpower(ah, chan, false);
183  
184         if (AR_SREV_9462(ah)) {
185                 if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
186 @@ -721,6 +709,14 @@ static void ar9003_hw_set_rfmode(struct 
187  
188         if (IS_CHAN_A_FAST_CLOCK(ah, chan))
189                 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
190 +       if (IS_CHAN_QUARTER_RATE(chan))
191 +               rfMode |= AR_PHY_MODE_QUARTER;
192 +       if (IS_CHAN_HALF_RATE(chan))
193 +               rfMode |= AR_PHY_MODE_HALF;
194 +
195 +       if (rfMode & (AR_PHY_MODE_QUARTER | AR_PHY_MODE_HALF))
196 +               REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL,
197 +                             AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW, 3);
198  
199         REG_WRITE(ah, AR_PHY_MODE, rfMode);
200  }
201 @@ -791,12 +787,8 @@ static bool ar9003_hw_rfbus_req(struct a
202  static void ar9003_hw_rfbus_done(struct ath_hw *ah)
203  {
204         u32 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
205 -       if (IS_CHAN_B(ah->curchan))
206 -               synthDelay = (4 * synthDelay) / 22;
207 -       else
208 -               synthDelay /= 10;
209  
210 -       udelay(synthDelay + BASE_ACTIVATE_DELAY);
211 +       ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
212  
213         REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
214  }
215 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
216 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
217 @@ -468,6 +468,9 @@
218  #define AR_PHY_ADDAC_PARA_CTL    (AR_SM_BASE + 0x150)
219  #define AR_PHY_XPA_CFG           (AR_SM_BASE + 0x158)
220  
221 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW  3
222 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW_S    0
223 +
224  #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_IDX_A           0x0001FC00
225  #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_S         10
226  #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_A                       0x3FF
227 --- a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
228 +++ b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
229 @@ -1115,9 +1115,9 @@ static const u32 ar9462_2p0_mac_core[][2
230         {0x000081f8, 0x00000000},
231         {0x000081fc, 0x00000000},
232         {0x00008240, 0x00100000},
233 -       {0x00008244, 0x0010f400},
234 +       {0x00008244, 0x0010f424},
235         {0x00008248, 0x00000800},
236 -       {0x0000824c, 0x0001e800},
237 +       {0x0000824c, 0x0001e848},
238         {0x00008250, 0x00000000},
239         {0x00008254, 0x00000000},
240         {0x00008258, 0x00000000},
241 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
242 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
243 @@ -370,7 +370,7 @@ struct ath_vif {
244   * number of beacon intervals, the game's up.
245   */
246  #define BSTUCK_THRESH                  9
247 -#define        ATH_BCBUF                       4
248 +#define        ATH_BCBUF                       8
249  #define ATH_DEFAULT_BINTVAL            100 /* TU */
250  #define ATH_DEFAULT_BMISS_LIMIT        10
251  #define IEEE80211_MS_TO_TU(x)           (((x) * 1000) / 1024)
252 --- a/drivers/net/wireless/ath/ath9k/beacon.c
253 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
254 @@ -91,7 +91,7 @@ static void ath_beacon_setup(struct ath_
255         info.txpower = MAX_RATE_POWER;
256         info.keyix = ATH9K_TXKEYIX_INVALID;
257         info.keytype = ATH9K_KEY_TYPE_CLEAR;
258 -       info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_INTREQ;
259 +       info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_CLRDMASK;
260  
261         info.buf_addr[0] = bf->bf_buf_addr;
262         info.buf_len[0] = roundup(skb->len, 4);
263 @@ -359,6 +359,11 @@ void ath_beacon_tasklet(unsigned long da
264         int slot;
265         u32 bfaddr, bc = 0;
266  
267 +       if (work_pending(&sc->hw_reset_work)) {
268 +               ath_dbg(common, RESET,
269 +                       "reset work is pending, skip beaconing now\n");
270 +               return;
271 +       }
272         /*
273          * Check if the previous beacon has gone out.  If
274          * not don't try to post another, skip this period
275 @@ -369,6 +374,9 @@ void ath_beacon_tasklet(unsigned long da
276         if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0) {
277                 sc->beacon.bmisscnt++;
278  
279 +               if (!ath9k_hw_check_alive(ah))
280 +                       ieee80211_queue_work(sc->hw, &sc->hw_check_work);
281 +
282                 if (sc->beacon.bmisscnt < BSTUCK_THRESH * sc->nbcnvifs) {
283                         ath_dbg(common, BSTUCK,
284                                 "missed %u consecutive beacons\n",
285 @@ -378,6 +386,7 @@ void ath_beacon_tasklet(unsigned long da
286                                 ath9k_hw_bstuck_nfcal(ah);
287                 } else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) {
288                         ath_dbg(common, BSTUCK, "beacon is officially stuck\n");
289 +                       sc->beacon.bmisscnt = 0;
290                         sc->sc_flags |= SC_OP_TSF_RESET;
291                         ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
292                 }
293 @@ -650,6 +659,8 @@ static void ath_beacon_config_adhoc(stru
294         u32 tsf, intval, nexttbtt;
295  
296         ath9k_reset_beacon_status(sc);
297 +       if (!(sc->sc_flags & SC_OP_BEACONS))
298 +               ath9k_hw_settsf64(ah, sc->beacon.bc_tstamp);
299  
300         intval = TU_TO_USEC(conf->beacon_interval);
301         tsf = roundup(ath9k_hw_gettsf32(ah) + TU_TO_USEC(FUDGE), intval);
302 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
303 +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
304 @@ -824,6 +824,8 @@ static void ath9k_hw_ar9287_set_txpower(
305                         regulatory->max_power_level = ratesArray[i];
306         }
307  
308 +       ath9k_hw_update_regulatory_maxpower(ah);
309 +
310         if (test)
311                 return;
312  
313 --- a/drivers/net/wireless/ath/ath9k/gpio.c
314 +++ b/drivers/net/wireless/ath/ath9k/gpio.c
315 @@ -41,6 +41,9 @@ void ath_init_leds(struct ath_softc *sc)
316  {
317         int ret;
318  
319 +       if (AR_SREV_9100(sc->sc_ah))
320 +               return;
321 +
322         if (sc->sc_ah->led_pin < 0) {
323                 if (AR_SREV_9287(sc->sc_ah))
324                         sc->sc_ah->led_pin = ATH_LED_PIN_9287;
325 --- a/drivers/net/wireless/ath/ath9k/hw.c
326 +++ b/drivers/net/wireless/ath/ath9k/hw.c
327 @@ -142,6 +142,22 @@ bool ath9k_hw_wait(struct ath_hw *ah, u3
328  }
329  EXPORT_SYMBOL(ath9k_hw_wait);
330  
331 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
332 +                         int hw_delay)
333 +{
334 +       if (IS_CHAN_B(chan))
335 +               hw_delay = (4 * hw_delay) / 22;
336 +       else
337 +               hw_delay /= 10;
338 +
339 +       if (IS_CHAN_HALF_RATE(chan))
340 +               hw_delay *= 2;
341 +       else if (IS_CHAN_QUARTER_RATE(chan))
342 +               hw_delay *= 4;
343 +
344 +       udelay(hw_delay + BASE_ACTIVATE_DELAY);
345 +}
346 +
347  void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
348                           int column, unsigned int *writecnt)
349  {
350 @@ -388,8 +404,8 @@ static void ath9k_hw_init_config(struct 
351  {
352         int i;
353  
354 -       ah->config.dma_beacon_response_time = 2;
355 -       ah->config.sw_beacon_response_time = 10;
356 +       ah->config.dma_beacon_response_time = 1;
357 +       ah->config.sw_beacon_response_time = 6;
358         ah->config.additional_swba_backoff = 0;
359         ah->config.ack_6mb = 0x0;
360         ah->config.cwm_ignore_extcca = 0;
361 @@ -971,7 +987,7 @@ void ath9k_hw_init_global_settings(struc
362         struct ath_common *common = ath9k_hw_common(ah);
363         struct ieee80211_conf *conf = &common->hw->conf;
364         const struct ath9k_channel *chan = ah->curchan;
365 -       int acktimeout, ctstimeout;
366 +       int acktimeout, ctstimeout, ack_offset = 0;
367         int slottime;
368         int sifstime;
369         int rx_lat = 0, tx_lat = 0, eifs = 0;
370 @@ -992,6 +1008,11 @@ void ath9k_hw_init_global_settings(struc
371                 rx_lat = 37;
372         tx_lat = 54;
373  
374 +       if (IS_CHAN_5GHZ(chan))
375 +               sifstime = 16;
376 +       else
377 +               sifstime = 10;
378 +
379         if (IS_CHAN_HALF_RATE(chan)) {
380                 eifs = 175;
381                 rx_lat *= 2;
382 @@ -999,8 +1020,9 @@ void ath9k_hw_init_global_settings(struc
383                 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
384                     tx_lat += 11;
385  
386 +               sifstime *= 2;
387 +               ack_offset = 16;
388                 slottime = 13;
389 -               sifstime = 32;
390         } else if (IS_CHAN_QUARTER_RATE(chan)) {
391                 eifs = 340;
392                 rx_lat = (rx_lat * 4) - 1;
393 @@ -1008,8 +1030,9 @@ void ath9k_hw_init_global_settings(struc
394                 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
395                     tx_lat += 22;
396  
397 +               sifstime *= 4;
398 +               ack_offset = 32;
399                 slottime = 21;
400 -               sifstime = 64;
401         } else {
402                 if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah)) {
403                         eifs = AR_D_GBL_IFS_EIFS_ASYNC_FIFO;
404 @@ -1023,14 +1046,10 @@ void ath9k_hw_init_global_settings(struc
405                 tx_lat = MS(reg, AR_USEC_TX_LAT);
406  
407                 slottime = ah->slottime;
408 -               if (IS_CHAN_5GHZ(chan))
409 -                       sifstime = 16;
410 -               else
411 -                       sifstime = 10;
412         }
413  
414         /* As defined by IEEE 802.11-2007 17.3.8.6 */
415 -       acktimeout = slottime + sifstime + 3 * ah->coverage_class;
416 +       acktimeout = slottime + sifstime + 3 * ah->coverage_class + ack_offset;
417         ctstimeout = acktimeout;
418  
419         /*
420 @@ -1040,7 +1059,8 @@ void ath9k_hw_init_global_settings(struc
421          * BA frames in some implementations, but it has been found to fix ACK
422          * timeout issues in other cases as well.
423          */
424 -       if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ) {
425 +       if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ &&
426 +           !IS_CHAN_HALF_RATE(chan) && !IS_CHAN_QUARTER_RATE(chan)) {
427                 acktimeout += 64 - sifstime - ah->slottime;
428                 ctstimeout += 48 - sifstime - ah->slottime;
429         }
430 @@ -1420,6 +1440,10 @@ static bool ath9k_hw_channel_change(stru
431                                                     CHANNEL_5GHZ));
432         mode_diff = (chan->chanmode != ah->curchan->chanmode);
433  
434 +       if ((ah->curchan->channelFlags | chan->channelFlags) &
435 +           (CHANNEL_HALF | CHANNEL_QUARTER))
436 +               return false;
437 +
438         for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
439                 if (ath9k_hw_numtxpending(ah, qnum)) {
440                         ath_dbg(common, QUEUE,
441 @@ -1453,7 +1477,7 @@ static bool ath9k_hw_channel_change(stru
442                 return false;
443         }
444         ath9k_hw_set_clockrate(ah);
445 -       ath9k_hw_apply_txpower(ah, chan);
446 +       ath9k_hw_apply_txpower(ah, chan, false);
447         ath9k_hw_rfbus_done(ah);
448  
449         if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
450 @@ -2724,7 +2748,8 @@ static int get_antenna_gain(struct ath_h
451         return ah->eep_ops->get_eeprom(ah, gain_param);
452  }
453  
454 -void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan)
455 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
456 +                           bool test)
457  {
458         struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
459         struct ieee80211_channel *channel;
460 @@ -2745,7 +2770,7 @@ void ath9k_hw_apply_txpower(struct ath_h
461  
462         ah->eep_ops->set_txpower(ah, chan,
463                                  ath9k_regd_get_ctl(reg, chan),
464 -                                ant_reduction, new_pwr, false);
465 +                                ant_reduction, new_pwr, test);
466  }
467  
468  void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
469 @@ -2758,7 +2783,7 @@ void ath9k_hw_set_txpowerlimit(struct at
470         if (test)
471                 channel->max_power = MAX_RATE_POWER / 2;
472  
473 -       ath9k_hw_apply_txpower(ah, chan);
474 +       ath9k_hw_apply_txpower(ah, chan, test);
475  
476         if (test)
477                 channel->max_power = DIV_ROUND_UP(reg->max_power_level, 2);
478 --- a/drivers/net/wireless/ath/ath9k/hw.h
479 +++ b/drivers/net/wireless/ath/ath9k/hw.h
480 @@ -923,6 +923,8 @@ void ath9k_hw_set_gpio(struct ath_hw *ah
481  void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna);
482  
483  /* General Operation */
484 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
485 +                         int hw_delay);
486  bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
487  void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
488                           int column, unsigned int *writecnt);
489 @@ -976,7 +978,8 @@ void ath9k_hw_name(struct ath_hw *ah, ch
490  /* PHY */
491  void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
492                                    u32 *coef_mantissa, u32 *coef_exponent);
493 -void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan);
494 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
495 +                           bool test);
496  
497  /*
498   * Code Specific to AR5008, AR9001 or AR9002,
499 --- a/drivers/net/wireless/ath/ath9k/mac.c
500 +++ b/drivers/net/wireless/ath/ath9k/mac.c
501 @@ -133,8 +133,16 @@ EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel
502  
503  void ath9k_hw_abort_tx_dma(struct ath_hw *ah)
504  {
505 +       int maxdelay = 1000;
506         int i, q;
507  
508 +       if (ah->curchan) {
509 +               if (IS_CHAN_HALF_RATE(ah->curchan))
510 +                       maxdelay *= 2;
511 +               else if (IS_CHAN_QUARTER_RATE(ah->curchan))
512 +                       maxdelay *= 4;
513 +       }
514 +
515         REG_WRITE(ah, AR_Q_TXD, AR_Q_TXD_M);
516  
517         REG_SET_BIT(ah, AR_PCU_MISC, AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF);
518 @@ -142,7 +150,7 @@ void ath9k_hw_abort_tx_dma(struct ath_hw
519         REG_SET_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
520  
521         for (q = 0; q < AR_NUM_QCU; q++) {
522 -               for (i = 0; i < 1000; i++) {
523 +               for (i = 0; i < maxdelay; i++) {
524                         if (i)
525                                 udelay(5);
526  
527 --- a/drivers/net/wireless/ath/ath9k/main.c
528 +++ b/drivers/net/wireless/ath/ath9k/main.c
529 @@ -692,17 +692,6 @@ void ath9k_tasklet(unsigned long data)
530                 goto out;
531         }
532  
533 -       /*
534 -        * Only run the baseband hang check if beacons stop working in AP or
535 -        * IBSS mode, because it has a high false positive rate. For station
536 -        * mode it should not be necessary, since the upper layers will detect
537 -        * this through a beacon miss automatically and the following channel
538 -        * change will trigger a hardware reset anyway
539 -        */
540 -       if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0 &&
541 -           !ath9k_hw_check_alive(ah))
542 -               ieee80211_queue_work(sc->hw, &sc->hw_check_work);
543 -
544         if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
545                 /*
546                  * TSF sync does not look correct; remain awake to sync with
547 --- a/net/mac80211/agg-rx.c
548 +++ b/net/mac80211/agg-rx.c
549 @@ -200,6 +200,8 @@ static void ieee80211_send_addba_resp(st
550                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
551         else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
552                 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
553 +       else if (sdata->vif.type == NL80211_IFTYPE_WDS)
554 +               memcpy(mgmt->bssid, da, ETH_ALEN);
555  
556         mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
557                                           IEEE80211_STYPE_ACTION);
558 --- a/net/mac80211/agg-tx.c
559 +++ b/net/mac80211/agg-tx.c
560 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
561         memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
562         if (sdata->vif.type == NL80211_IFTYPE_AP ||
563             sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
564 -           sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
565 +           sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
566 +           sdata->vif.type == NL80211_IFTYPE_WDS)
567                 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
568         else if (sdata->vif.type == NL80211_IFTYPE_STATION)
569                 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
570 @@ -484,6 +485,7 @@ int ieee80211_start_tx_ba_session(struct
571             sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
572             sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
573             sdata->vif.type != NL80211_IFTYPE_AP &&
574 +           sdata->vif.type != NL80211_IFTYPE_WDS &&
575             sdata->vif.type != NL80211_IFTYPE_ADHOC)
576                 return -EINVAL;
577  
578 --- a/net/mac80211/debugfs_sta.c
579 +++ b/net/mac80211/debugfs_sta.c
580 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
581         test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
582  
583         int res = scnprintf(buf, sizeof(buf),
584 -                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
585 +                           "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
586                             TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
587                             TEST(PS_DRIVER), TEST(AUTHORIZED),
588                             TEST(SHORT_PREAMBLE),
589 -                           TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
590 +                           TEST(WME), TEST(CLEAR_PS_FILT),
591                             TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
592                             TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
593                             TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
594 --- a/net/mac80211/iface.c
595 +++ b/net/mac80211/iface.c
596 @@ -163,7 +163,8 @@ static int ieee80211_check_queues(struct
597                         return -EINVAL;
598         }
599  
600 -       if (sdata->vif.type != NL80211_IFTYPE_AP) {
601 +       if ((sdata->vif.type != NL80211_IFTYPE_AP) ||
602 +           !(sdata->local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)) {
603                 sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE;
604                 return 0;
605         }
606 @@ -281,7 +282,6 @@ static int ieee80211_do_open(struct net_
607  {
608         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
609         struct ieee80211_local *local = sdata->local;
610 -       struct sta_info *sta;
611         u32 changed = 0;
612         int res;
613         u32 hw_reconf_flags = 0;
614 @@ -427,28 +427,6 @@ static int ieee80211_do_open(struct net_
615  
616         set_bit(SDATA_STATE_RUNNING, &sdata->state);
617  
618 -       if (sdata->vif.type == NL80211_IFTYPE_WDS) {
619 -               /* Create STA entry for the WDS peer */
620 -               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
621 -                                    GFP_KERNEL);
622 -               if (!sta) {
623 -                       res = -ENOMEM;
624 -                       goto err_del_interface;
625 -               }
626 -
627 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
628 -               sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
629 -               sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
630 -
631 -               res = sta_info_insert(sta);
632 -               if (res) {
633 -                       /* STA has been freed */
634 -                       goto err_del_interface;
635 -               }
636 -
637 -               rate_control_rate_init(sta);
638 -       }
639 -
640         /*
641          * set_multicast_list will be invoked by the networking core
642          * which will check whether any increments here were done in
643 @@ -845,6 +823,70 @@ static void ieee80211_if_setup(struct ne
644         dev->destructor = free_netdev;
645  }
646  
647 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
648 +                                        struct sk_buff *skb)
649 +{
650 +       struct ieee80211_local *local = sdata->local;
651 +       struct ieee80211_rx_status *rx_status;
652 +       struct ieee802_11_elems elems;
653 +       struct ieee80211_mgmt *mgmt;
654 +       struct sta_info *sta;
655 +       size_t baselen;
656 +       u32 rates = 0;
657 +       u16 stype;
658 +       bool new = false;
659 +       enum ieee80211_band band = local->hw.conf.channel->band;
660 +       struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
661 +
662 +       rx_status = IEEE80211_SKB_RXCB(skb);
663 +       mgmt = (struct ieee80211_mgmt *) skb->data;
664 +       stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
665 +
666 +       if (stype != IEEE80211_STYPE_BEACON)
667 +               return;
668 +
669 +       baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
670 +       if (baselen > skb->len)
671 +               return;
672 +
673 +       ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
674 +                              skb->len - baselen, &elems);
675 +
676 +       rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
677 +
678 +       rcu_read_lock();
679 +
680 +       sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
681 +
682 +       if (!sta) {
683 +               rcu_read_unlock();
684 +               sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
685 +                                    GFP_KERNEL);
686 +               if (!sta)
687 +                       return;
688 +
689 +               new = true;
690 +       }
691 +
692 +       sta->last_rx = jiffies;
693 +       sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
694 +
695 +       if (elems.ht_cap_elem)
696 +               ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
697 +                               elems.ht_cap_elem, &sta->sta.ht_cap);
698 +
699 +       if (elems.wmm_param)
700 +               set_sta_flag(sta, WLAN_STA_WME);
701 +
702 +       if (new) {
703 +               set_sta_flag(sta, WLAN_STA_AUTHORIZED);
704 +               rate_control_rate_init(sta);
705 +               sta_info_insert_rcu(sta);
706 +       }
707 +
708 +       rcu_read_unlock();
709 +}
710 +
711  static void ieee80211_iface_work(struct work_struct *work)
712  {
713         struct ieee80211_sub_if_data *sdata =
714 @@ -949,6 +991,9 @@ static void ieee80211_iface_work(struct 
715                                 break;
716                         ieee80211_mesh_rx_queued_mgmt(sdata, skb);
717                         break;
718 +               case NL80211_IFTYPE_WDS:
719 +                       ieee80211_wds_rx_queued_mgmt(sdata, skb);
720 +                       break;
721                 default:
722                         WARN(1, "frame for unexpected interface type");
723                         break;
724 --- a/net/mac80211/rx.c
725 +++ b/net/mac80211/rx.c
726 @@ -103,7 +103,7 @@ static void
727  ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
728                                  struct sk_buff *skb,
729                                  struct ieee80211_rate *rate,
730 -                                int rtap_len)
731 +                                int rtap_len, bool has_fcs)
732  {
733         struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
734         struct ieee80211_radiotap_header *rthdr;
735 @@ -134,7 +134,7 @@ ieee80211_add_rx_radiotap_header(struct 
736         }
737  
738         /* IEEE80211_RADIOTAP_FLAGS */
739 -       if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
740 +       if (has_fcs && (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS))
741                 *pos |= IEEE80211_RADIOTAP_F_FCS;
742         if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
743                 *pos |= IEEE80211_RADIOTAP_F_BADFCS;
744 @@ -294,7 +294,8 @@ ieee80211_rx_monitor(struct ieee80211_lo
745         }
746  
747         /* prepend radiotap information */
748 -       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom);
749 +       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom,
750 +                                        true);
751  
752         skb_reset_mac_header(skb);
753         skb->ip_summed = CHECKSUM_UNNECESSARY;
754 @@ -2282,6 +2283,7 @@ ieee80211_rx_h_action(struct ieee80211_r
755                     sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
756                     sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
757                     sdata->vif.type != NL80211_IFTYPE_AP &&
758 +                   sdata->vif.type != NL80211_IFTYPE_WDS &&
759                     sdata->vif.type != NL80211_IFTYPE_ADHOC)
760                         break;
761  
762 @@ -2496,14 +2498,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
763  
764         if (!ieee80211_vif_is_mesh(&sdata->vif) &&
765             sdata->vif.type != NL80211_IFTYPE_ADHOC &&
766 -           sdata->vif.type != NL80211_IFTYPE_STATION)
767 +           sdata->vif.type != NL80211_IFTYPE_STATION &&
768 +           sdata->vif.type != NL80211_IFTYPE_WDS)
769                 return RX_DROP_MONITOR;
770  
771         switch (stype) {
772         case cpu_to_le16(IEEE80211_STYPE_AUTH):
773         case cpu_to_le16(IEEE80211_STYPE_BEACON):
774         case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
775 -               /* process for all: mesh, mlme, ibss */
776 +               /* process for all: mesh, mlme, ibss, wds */
777                 break;
778         case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
779         case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
780 @@ -2567,7 +2570,8 @@ static void ieee80211_rx_cooked_monitor(
781                 goto out_free_skb;
782  
783         /* prepend radiotap information */
784 -       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom);
785 +       ieee80211_add_rx_radiotap_header(local, skb, rate, needed_headroom,
786 +                                        false);
787  
788         skb_set_mac_header(skb, 0);
789         skb->ip_summed = CHECKSUM_UNNECESSARY;
790 @@ -2836,10 +2840,16 @@ static int prepare_for_handlers(struct i
791                 }
792                 break;
793         case NL80211_IFTYPE_WDS:
794 -               if (bssid || !ieee80211_is_data(hdr->frame_control))
795 -                       return 0;
796                 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
797                         return 0;
798 +
799 +               if (ieee80211_is_data(hdr->frame_control) ||
800 +                   ieee80211_is_action(hdr->frame_control)) {
801 +                       if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
802 +                               return 0;
803 +               } else if (!ieee80211_is_beacon(hdr->frame_control))
804 +                       return 0;
805 +
806                 break;
807         default:
808                 /* should never get here */
809 --- a/net/mac80211/sta_info.h
810 +++ b/net/mac80211/sta_info.h
811 @@ -32,7 +32,6 @@
812   * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
813   *     frames.
814   * @WLAN_STA_WME: Station is a QoS-STA.
815 - * @WLAN_STA_WDS: Station is one of our WDS peers.
816   * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
817   *     IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
818   *     frame to this station is transmitted.
819 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
820         WLAN_STA_AUTHORIZED,
821         WLAN_STA_SHORT_PREAMBLE,
822         WLAN_STA_WME,
823 -       WLAN_STA_WDS,
824         WLAN_STA_CLEAR_PS_FILT,
825         WLAN_STA_MFP,
826         WLAN_STA_BLOCK_BA,
827 --- a/drivers/net/wireless/ath/ath9k/init.c
828 +++ b/drivers/net/wireless/ath/ath9k/init.c
829 @@ -647,6 +647,21 @@ void ath9k_reload_chainmask_settings(str
830                 setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
831  }
832  
833 +static const struct ieee80211_iface_limit if_limits[] = {
834 +       { .max = 256,   .types = BIT(NL80211_IFTYPE_STATION) |
835 +                                BIT(NL80211_IFTYPE_P2P_CLIENT) |
836 +                                BIT(NL80211_IFTYPE_WDS) },
837 +       { .max = 8,     .types = BIT(NL80211_IFTYPE_AP) |
838 +                                BIT(NL80211_IFTYPE_P2P_GO) |
839 +                                BIT(NL80211_IFTYPE_MESH_POINT) },
840 +};
841 +
842 +static const struct ieee80211_iface_combination if_comb = {
843 +       .limits = if_limits,
844 +       .n_limits = ARRAY_SIZE(if_limits),
845 +       .max_interfaces = 256,
846 +       .num_different_channels = 1,
847 +};
848  
849  void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
850  {
851 @@ -676,6 +691,9 @@ void ath9k_set_hw_capab(struct ath_softc
852                 BIT(NL80211_IFTYPE_ADHOC) |
853                 BIT(NL80211_IFTYPE_MESH_POINT);
854  
855 +       hw->wiphy->iface_combinations = &if_comb;
856 +       hw->wiphy->n_iface_combinations = 1;
857 +
858         if (AR_SREV_5416(sc->sc_ah))
859                 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
860  
861 --- a/net/mac80211/ibss.c
862 +++ b/net/mac80211/ibss.c
863 @@ -455,8 +455,8 @@ static void ieee80211_rx_bss_info(struct
864                          * fall back to HT20 if we don't use or use
865                          * the other extension channel
866                          */
867 -                       if ((channel_type == NL80211_CHAN_HT40MINUS ||
868 -                            channel_type == NL80211_CHAN_HT40PLUS) &&
869 +                       if (!(channel_type == NL80211_CHAN_HT40MINUS ||
870 +                             channel_type == NL80211_CHAN_HT40PLUS) ||
871                             channel_type != sdata->u.ibss.channel_type)
872                                 sta_ht_cap_new.cap &=
873                                         ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;