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
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) {
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
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)
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 \*************************/
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) },
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,
39 ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops)
41 @@ -2437,6 +2450,9 @@ ath5k_init_ah(struct ath5k_hw *ah, const
42 BIT(NL80211_IFTYPE_ADHOC) |
43 BIT(NL80211_IFTYPE_MESH_POINT);
45 + hw->wiphy->iface_combinations = &if_comb;
46 + hw->wiphy->n_iface_combinations = 1;
48 /* SW support for IBSS_RSN is provided by mac80211 */
49 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
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);
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;
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;
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;
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
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;
86 - if (IS_CHAN_HALF_RATE(chan))
88 - else if (IS_CHAN_QUARTER_RATE(chan))
91 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
93 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
94 + ath9k_hw_synth_delay(ah, chan, synthDelay);
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);
102 - ath9k_hw_apply_txpower(ah, chan);
103 + ath9k_hw_apply_txpower(ah, chan, false);
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)
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;
116 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
117 + ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
119 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
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);
127 - txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
128 - REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
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);
135 + REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
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 *
145 ah->paprd_table_write_done = true;
146 - ath9k_hw_apply_txpower(ah, chan);
147 + ath9k_hw_apply_txpower(ah, chan, false);
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.
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;
162 /* Activate the PHY (includes baseband activate + synthesizer on) */
163 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
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
172 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
173 + ath9k_hw_synth_delay(ah, chan, synthDelay);
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);
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
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;
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);
199 REG_WRITE(ah, AR_PHY_MODE, rfMode);
201 @@ -791,12 +787,8 @@ static bool ar9003_hw_rfbus_req(struct a
202 static void ar9003_hw_rfbus_done(struct ath_hw *ah)
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;
210 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
211 + ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
213 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
215 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
216 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
218 #define AR_PHY_ADDAC_PARA_CTL (AR_SM_BASE + 0x150)
219 #define AR_PHY_XPA_CFG (AR_SM_BASE + 0x158)
221 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW 3
222 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW_S 0
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.
246 #define BSTUCK_THRESH 9
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;
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
267 + if (work_pending(&sc->hw_reset_work)) {
268 + ath_dbg(common, RESET,
269 + "reset work is pending, skip beaconing now\n");
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++;
279 + if (!ath9k_hw_check_alive(ah))
280 + ieee80211_queue_work(sc->hw, &sc->hw_check_work);
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);
293 @@ -650,6 +659,8 @@ static void ath_beacon_config_adhoc(stru
294 u32 tsf, intval, nexttbtt;
296 ath9k_reset_beacon_status(sc);
297 + if (!(sc->sc_flags & SC_OP_BEACONS))
298 + ath9k_hw_settsf64(ah, sc->beacon.bc_tstamp);
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];
308 + ath9k_hw_update_regulatory_maxpower(ah);
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)
319 + if (AR_SREV_9100(sc->sc_ah))
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
329 EXPORT_SYMBOL(ath9k_hw_wait);
331 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
334 + if (IS_CHAN_B(chan))
335 + hw_delay = (4 * hw_delay) / 22;
339 + if (IS_CHAN_HALF_RATE(chan))
341 + else if (IS_CHAN_QUARTER_RATE(chan))
344 + udelay(hw_delay + BASE_ACTIVATE_DELAY);
347 void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
348 int column, unsigned int *writecnt)
350 @@ -388,8 +404,8 @@ static void ath9k_hw_init_config(struct
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;
369 int rx_lat = 0, tx_lat = 0, eifs = 0;
370 @@ -992,6 +1008,11 @@ void ath9k_hw_init_global_settings(struc
374 + if (IS_CHAN_5GHZ(chan))
379 if (IS_CHAN_HALF_RATE(chan)) {
382 @@ -999,8 +1020,9 @@ void ath9k_hw_init_global_settings(struc
383 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
390 } else if (IS_CHAN_QUARTER_RATE(chan)) {
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))
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);
407 slottime = ah->slottime;
408 - if (IS_CHAN_5GHZ(chan))
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;
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.
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;
430 @@ -1420,6 +1440,10 @@ static bool ath9k_hw_channel_change(stru
432 mode_diff = (chan->chanmode != ah->curchan->chanmode);
434 + if ((ah->curchan->channelFlags | chan->channelFlags) &
435 + (CHANNEL_HALF | CHANNEL_QUARTER))
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
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);
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);
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,
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
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);
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
471 channel->max_power = MAX_RATE_POWER / 2;
473 - ath9k_hw_apply_txpower(ah, chan);
474 + ath9k_hw_apply_txpower(ah, chan, 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);
483 /* General Operation */
484 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
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
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,
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
503 void ath9k_hw_abort_tx_dma(struct ath_hw *ah)
505 + int maxdelay = 1000;
509 + if (IS_CHAN_HALF_RATE(ah->curchan))
511 + else if (IS_CHAN_QUARTER_RATE(ah->curchan))
515 REG_WRITE(ah, AR_Q_TXD, AR_Q_TXD_M);
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);
521 for (q = 0; q < AR_NUM_QCU; q++) {
522 - for (i = 0; i < 1000; i++) {
523 + for (i = 0; i < maxdelay; i++) {
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)
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
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);
544 if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
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);
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)
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" : ""
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
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;
606 @@ -281,7 +282,6 @@ static int ieee80211_do_open(struct net_
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;
613 u32 hw_reconf_flags = 0;
614 @@ -427,28 +427,6 @@ static int ieee80211_do_open(struct net_
616 set_bit(SDATA_STATE_RUNNING, &sdata->state);
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,
624 - goto err_del_interface;
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);
631 - res = sta_info_insert(sta);
633 - /* STA has been freed */
634 - goto err_del_interface;
637 - rate_control_rate_init(sta);
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;
647 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
648 + struct sk_buff *skb)
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;
659 + enum ieee80211_band band = local->hw.conf.channel->band;
660 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
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;
666 + if (stype != IEEE80211_STYPE_BEACON)
669 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
670 + if (baselen > skb->len)
673 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
674 + skb->len - baselen, &elems);
676 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
680 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
684 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
692 + sta->last_rx = jiffies;
693 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
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);
699 + if (elems.wmm_param)
700 + set_sta_flag(sta, WLAN_STA_WME);
703 + set_sta_flag(sta, WLAN_STA_AUTHORIZED);
704 + rate_control_rate_init(sta);
705 + sta_info_insert_rcu(sta);
711 static void ieee80211_iface_work(struct work_struct *work)
713 struct ieee80211_sub_if_data *sdata =
714 @@ -949,6 +991,9 @@ static void ieee80211_iface_work(struct
716 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
718 + case NL80211_IFTYPE_WDS:
719 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
722 WARN(1, "frame for unexpected interface type");
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,
729 struct ieee80211_rate *rate,
731 + int rtap_len, bool has_fcs)
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
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
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,
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)
762 @@ -2496,14 +2498,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
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;
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 */
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(
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,
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
793 case NL80211_IFTYPE_WDS:
794 - if (bssid || !ieee80211_is_data(hdr->frame_control))
796 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
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))
803 + } else if (!ieee80211_is_beacon(hdr->frame_control))
808 /* should never get here */
809 --- a/net/mac80211/sta_info.h
810 +++ b/net/mac80211/sta_info.h
812 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
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 {
821 WLAN_STA_SHORT_PREAMBLE,
824 WLAN_STA_CLEAR_PS_FILT,
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);
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) },
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,
849 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
851 @@ -676,6 +691,9 @@ void ath9k_set_hw_capab(struct ath_softc
852 BIT(NL80211_IFTYPE_ADHOC) |
853 BIT(NL80211_IFTYPE_MESH_POINT);
855 + hw->wiphy->iface_combinations = &if_comb;
856 + hw->wiphy->n_iface_combinations = 1;
858 if (AR_SREV_5416(sc->sc_ah))
859 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
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
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;