1 --- a/drivers/net/wireless/ath/ath5k/base.c
2 +++ b/drivers/net/wireless/ath/ath5k/base.c
3 @@ -2416,6 +2416,22 @@ ath5k_tx_complete_poll_work(struct work_
4 * Initialization routines *
5 \*************************/
7 +static const struct ieee80211_iface_limit if_limits[] = {
8 + { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) },
10 +#ifdef CONFIG_MAC80211_MESH
11 + BIT(NL80211_IFTYPE_MESH_POINT) |
13 + BIT(NL80211_IFTYPE_AP) },
16 +static const struct ieee80211_iface_combination if_comb = {
17 + .limits = if_limits,
18 + .n_limits = ARRAY_SIZE(if_limits),
19 + .max_interfaces = 2048,
20 + .num_different_channels = 1,
24 ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops)
26 @@ -2437,6 +2453,9 @@ ath5k_init_ah(struct ath5k_hw *ah, const
27 BIT(NL80211_IFTYPE_ADHOC) |
28 BIT(NL80211_IFTYPE_MESH_POINT);
30 + hw->wiphy->iface_combinations = &if_comb;
31 + hw->wiphy->n_iface_combinations = 1;
33 /* SW support for IBSS_RSN is provided by mac80211 */
34 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
36 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
37 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
38 @@ -618,19 +618,10 @@ static void ar5008_hw_init_bb(struct ath
41 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
42 - if (IS_CHAN_B(chan))
43 - synthDelay = (4 * synthDelay) / 22;
47 - if (IS_CHAN_HALF_RATE(chan))
49 - else if (IS_CHAN_QUARTER_RATE(chan))
52 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
54 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
55 + ath9k_hw_synth_delay(ah, chan, synthDelay);
58 static void ar5008_hw_init_chain_masks(struct ath_hw *ah)
59 @@ -868,7 +859,7 @@ static int ar5008_hw_process_ini(struct
60 ar5008_hw_set_channel_regs(ah, chan);
61 ar5008_hw_init_chain_masks(ah);
63 - ath9k_hw_apply_txpower(ah, chan);
64 + ath9k_hw_apply_txpower(ah, chan, false);
66 /* Write analog registers */
67 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
68 @@ -948,12 +939,8 @@ static bool ar5008_hw_rfbus_req(struct a
69 static void ar5008_hw_rfbus_done(struct ath_hw *ah)
71 u32 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
72 - if (IS_CHAN_B(ah->curchan))
73 - synthDelay = (4 * synthDelay) / 22;
77 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
78 + ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
80 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
82 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
83 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
84 @@ -1000,10 +1000,12 @@ static bool ar9003_hw_init_cal(struct at
85 if (mci && IS_CHAN_2GHZ(chan) && run_agc_cal)
86 ar9003_mci_init_cal_req(ah, &is_reusable);
88 - txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
89 - REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
91 - REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
92 + if (!(IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))) {
93 + txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
94 + REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
96 + REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
100 if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
101 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
102 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
103 @@ -4281,18 +4281,10 @@ static int ar9003_hw_tx_power_regwrite(s
107 -static void ar9003_hw_set_target_power_eeprom(struct ath_hw *ah, u16 freq,
108 - u8 *targetPowerValT2)
109 +static void ar9003_hw_get_legacy_target_powers(struct ath_hw *ah, u16 freq,
110 + u8 *targetPowerValT2,
113 - /* XXX: hard code for now, need to get from eeprom struct */
114 - u8 ht40PowerIncForPdadc = 0;
115 - bool is2GHz = false;
116 - unsigned int i = 0;
117 - struct ath_common *common = ath9k_hw_common(ah);
122 targetPowerValT2[ALL_TARGET_LEGACY_6_24] =
123 ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_6_24, freq,
125 @@ -4305,6 +4297,11 @@ static void ar9003_hw_set_target_power_e
126 targetPowerValT2[ALL_TARGET_LEGACY_54] =
127 ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_54, freq,
131 +static void ar9003_hw_get_cck_target_powers(struct ath_hw *ah, u16 freq,
132 + u8 *targetPowerValT2)
134 targetPowerValT2[ALL_TARGET_LEGACY_1L_5L] =
135 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_1L_5L,
137 @@ -4314,6 +4311,11 @@ static void ar9003_hw_set_target_power_e
138 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11L, freq);
139 targetPowerValT2[ALL_TARGET_LEGACY_11S] =
140 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11S, freq);
143 +static void ar9003_hw_get_ht20_target_powers(struct ath_hw *ah, u16 freq,
144 + u8 *targetPowerValT2, bool is2GHz)
146 targetPowerValT2[ALL_TARGET_HT20_0_8_16] =
147 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
149 @@ -4356,6 +4358,16 @@ static void ar9003_hw_set_target_power_e
150 targetPowerValT2[ALL_TARGET_HT20_23] =
151 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
155 +static void ar9003_hw_get_ht40_target_powers(struct ath_hw *ah,
157 + u8 *targetPowerValT2,
160 + /* XXX: hard code for now, need to get from eeprom struct */
161 + u8 ht40PowerIncForPdadc = 0;
163 targetPowerValT2[ALL_TARGET_HT40_0_8_16] =
164 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
165 is2GHz) + ht40PowerIncForPdadc;
166 @@ -4399,6 +4411,26 @@ static void ar9003_hw_set_target_power_e
167 targetPowerValT2[ALL_TARGET_HT40_23] =
168 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
169 is2GHz) + ht40PowerIncForPdadc;
172 +static void ar9003_hw_get_target_power_eeprom(struct ath_hw *ah,
173 + struct ath9k_channel *chan,
174 + u8 *targetPowerValT2)
176 + bool is2GHz = IS_CHAN_2GHZ(chan);
177 + unsigned int i = 0;
178 + struct ath_common *common = ath9k_hw_common(ah);
179 + u16 freq = chan->channel;
182 + ar9003_hw_get_cck_target_powers(ah, freq, targetPowerValT2);
184 + ar9003_hw_get_legacy_target_powers(ah, freq, targetPowerValT2, is2GHz);
185 + ar9003_hw_get_ht20_target_powers(ah, freq, targetPowerValT2, is2GHz);
187 + if (IS_CHAN_HT40(chan))
188 + ar9003_hw_get_ht40_target_powers(ah, freq, targetPowerValT2,
191 for (i = 0; i < ar9300RateSize; i++) {
192 ath_dbg(common, EEPROM, "TPC[%02d] 0x%08x\n",
193 @@ -4778,9 +4810,6 @@ static void ar9003_hw_set_power_per_rate
194 scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
198 - * Get target powers from EEPROM - our baseline for TX Power
201 /* Setup for CTL modes */
202 /* CTL_11B, CTL_11G, CTL_2GHT20 */
203 @@ -4952,7 +4981,12 @@ static void ath9k_hw_ar9300_set_txpower(
204 unsigned int i = 0, paprd_scale_factor = 0;
205 u8 pwr_idx, min_pwridx = 0;
207 - ar9003_hw_set_target_power_eeprom(ah, chan->channel, targetPowerValT2);
208 + memset(targetPowerValT2, 0 , sizeof(targetPowerValT2));
211 + * Get target powers from EEPROM - our baseline for TX Power
213 + ar9003_hw_get_target_power_eeprom(ah, chan, targetPowerValT2);
215 if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) {
216 if (IS_CHAN_2GHZ(chan))
217 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
218 +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
219 @@ -54,7 +54,7 @@ void ar9003_paprd_enable(struct ath_hw *
222 ah->paprd_table_write_done = true;
223 - ath9k_hw_apply_txpower(ah, chan);
224 + ath9k_hw_apply_txpower(ah, chan, false);
227 REG_RMW_FIELD(ah, AR_PHY_PAPRD_CTRL0_B0,
228 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
229 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
230 @@ -373,7 +373,7 @@ static void ar9003_hw_spur_ofdm_work(str
232 spur_subchannel_sd = 0;
234 - spur_freq_sd = (freq_offset << 9) / 11;
235 + spur_freq_sd = ((freq_offset + 10) << 9) / 11;
238 if (REG_READ_FIELD(ah, AR_PHY_GEN_CTRL,
239 @@ -382,7 +382,7 @@ static void ar9003_hw_spur_ofdm_work(str
241 spur_subchannel_sd = 1;
243 - spur_freq_sd = (freq_offset << 9) / 11;
244 + spur_freq_sd = ((freq_offset - 10) << 9) / 11;
248 @@ -526,22 +526,10 @@ static void ar9003_hw_init_bb(struct ath
249 * Value is in 100ns increments.
251 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
252 - if (IS_CHAN_B(chan))
253 - synthDelay = (4 * synthDelay) / 22;
257 /* Activate the PHY (includes baseband activate + synthesizer on) */
258 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
261 - * There is an issue if the AP starts the calibration before
262 - * the base band timeout completes. This could result in the
263 - * rx_clear false triggering. As a workaround we add delay an
264 - * extra BASE_ACTIVATE_DELAY usecs to ensure this condition
267 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
268 + ath9k_hw_synth_delay(ah, chan, synthDelay);
271 static void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
272 @@ -692,7 +680,7 @@ static int ar9003_hw_process_ini(struct
273 ar9003_hw_override_ini(ah);
274 ar9003_hw_set_channel_regs(ah, chan);
275 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
276 - ath9k_hw_apply_txpower(ah, chan);
277 + ath9k_hw_apply_txpower(ah, chan, false);
279 if (AR_SREV_9462(ah)) {
280 if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
281 @@ -723,6 +711,14 @@ static void ar9003_hw_set_rfmode(struct
283 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
284 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
285 + if (IS_CHAN_QUARTER_RATE(chan))
286 + rfMode |= AR_PHY_MODE_QUARTER;
287 + if (IS_CHAN_HALF_RATE(chan))
288 + rfMode |= AR_PHY_MODE_HALF;
290 + if (rfMode & (AR_PHY_MODE_QUARTER | AR_PHY_MODE_HALF))
291 + REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL,
292 + AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW, 3);
294 REG_WRITE(ah, AR_PHY_MODE, rfMode);
296 @@ -793,12 +789,8 @@ static bool ar9003_hw_rfbus_req(struct a
297 static void ar9003_hw_rfbus_done(struct ath_hw *ah)
299 u32 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
300 - if (IS_CHAN_B(ah->curchan))
301 - synthDelay = (4 * synthDelay) / 22;
305 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
306 + ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
308 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
310 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
311 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
313 #define AR_PHY_ADDAC_PARA_CTL (AR_SM_BASE + 0x150)
314 #define AR_PHY_XPA_CFG (AR_SM_BASE + 0x158)
316 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW 3
317 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW_S 0
319 #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_IDX_A 0x0001FC00
320 #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_S 10
321 #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_A 0x3FF
322 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
323 +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
324 @@ -798,6 +798,8 @@ static void ath9k_hw_ar9287_set_txpower(
325 regulatory->max_power_level = ratesArray[i];
328 + ath9k_hw_update_regulatory_maxpower(ah);
333 --- a/drivers/net/wireless/ath/ath9k/hw.c
334 +++ b/drivers/net/wireless/ath/ath9k/hw.c
335 @@ -191,6 +191,22 @@ bool ath9k_hw_wait(struct ath_hw *ah, u3
337 EXPORT_SYMBOL(ath9k_hw_wait);
339 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
342 + if (IS_CHAN_B(chan))
343 + hw_delay = (4 * hw_delay) / 22;
347 + if (IS_CHAN_HALF_RATE(chan))
349 + else if (IS_CHAN_QUARTER_RATE(chan))
352 + udelay(hw_delay + BASE_ACTIVATE_DELAY);
355 void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
356 int column, unsigned int *writecnt)
358 @@ -1020,7 +1036,7 @@ void ath9k_hw_init_global_settings(struc
359 struct ath_common *common = ath9k_hw_common(ah);
360 struct ieee80211_conf *conf = &common->hw->conf;
361 const struct ath9k_channel *chan = ah->curchan;
362 - int acktimeout, ctstimeout;
363 + int acktimeout, ctstimeout, ack_offset = 0;
366 int rx_lat = 0, tx_lat = 0, eifs = 0;
367 @@ -1041,6 +1057,11 @@ void ath9k_hw_init_global_settings(struc
371 + if (IS_CHAN_5GHZ(chan))
376 if (IS_CHAN_HALF_RATE(chan)) {
379 @@ -1048,8 +1069,9 @@ void ath9k_hw_init_global_settings(struc
380 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
387 } else if (IS_CHAN_QUARTER_RATE(chan)) {
389 rx_lat = (rx_lat * 4) - 1;
390 @@ -1057,8 +1079,9 @@ void ath9k_hw_init_global_settings(struc
391 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
399 if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah)) {
400 eifs = AR_D_GBL_IFS_EIFS_ASYNC_FIFO;
401 @@ -1072,14 +1095,10 @@ void ath9k_hw_init_global_settings(struc
402 tx_lat = MS(reg, AR_USEC_TX_LAT);
404 slottime = ah->slottime;
405 - if (IS_CHAN_5GHZ(chan))
411 /* As defined by IEEE 802.11-2007 17.3.8.6 */
412 - acktimeout = slottime + sifstime + 3 * ah->coverage_class;
413 + acktimeout = slottime + sifstime + 3 * ah->coverage_class + ack_offset;
414 ctstimeout = acktimeout;
417 @@ -1089,7 +1108,8 @@ void ath9k_hw_init_global_settings(struc
418 * BA frames in some implementations, but it has been found to fix ACK
419 * timeout issues in other cases as well.
421 - if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ) {
422 + if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ &&
423 + !IS_CHAN_HALF_RATE(chan) && !IS_CHAN_QUARTER_RATE(chan)) {
424 acktimeout += 64 - sifstime - ah->slottime;
425 ctstimeout += 48 - sifstime - ah->slottime;
427 @@ -1469,6 +1489,10 @@ static bool ath9k_hw_channel_change(stru
429 mode_diff = (chan->chanmode != ah->curchan->chanmode);
431 + if ((ah->curchan->channelFlags | chan->channelFlags) &
432 + (CHANNEL_HALF | CHANNEL_QUARTER))
435 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
436 if (ath9k_hw_numtxpending(ah, qnum)) {
437 ath_dbg(common, QUEUE,
438 @@ -1502,7 +1526,7 @@ static bool ath9k_hw_channel_change(stru
441 ath9k_hw_set_clockrate(ah);
442 - ath9k_hw_apply_txpower(ah, chan);
443 + ath9k_hw_apply_txpower(ah, chan, false);
444 ath9k_hw_rfbus_done(ah);
446 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
447 @@ -2773,7 +2797,8 @@ static int get_antenna_gain(struct ath_h
448 return ah->eep_ops->get_eeprom(ah, gain_param);
451 -void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan)
452 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
455 struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
456 struct ieee80211_channel *channel;
457 @@ -2794,7 +2819,7 @@ void ath9k_hw_apply_txpower(struct ath_h
459 ah->eep_ops->set_txpower(ah, chan,
460 ath9k_regd_get_ctl(reg, chan),
461 - ant_reduction, new_pwr, false);
462 + ant_reduction, new_pwr, test);
465 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
466 @@ -2807,7 +2832,7 @@ void ath9k_hw_set_txpowerlimit(struct at
468 channel->max_power = MAX_RATE_POWER / 2;
470 - ath9k_hw_apply_txpower(ah, chan);
471 + ath9k_hw_apply_txpower(ah, chan, test);
474 channel->max_power = DIV_ROUND_UP(reg->max_power_level, 2);
475 --- a/drivers/net/wireless/ath/ath9k/hw.h
476 +++ b/drivers/net/wireless/ath/ath9k/hw.h
477 @@ -923,6 +923,8 @@ void ath9k_hw_set_gpio(struct ath_hw *ah
478 void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna);
480 /* General Operation */
481 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
483 bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
484 void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
485 int column, unsigned int *writecnt);
486 @@ -982,7 +984,8 @@ void ath9k_hw_name(struct ath_hw *ah, ch
488 void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
489 u32 *coef_mantissa, u32 *coef_exponent);
490 -void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan);
491 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
495 * Code Specific to AR5008, AR9001 or AR9002,
496 --- a/drivers/net/wireless/ath/ath9k/init.c
497 +++ b/drivers/net/wireless/ath/ath9k/init.c
498 @@ -647,6 +647,24 @@ void ath9k_reload_chainmask_settings(str
499 setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
502 +static const struct ieee80211_iface_limit if_limits[] = {
503 + { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) |
504 + BIT(NL80211_IFTYPE_P2P_CLIENT) |
505 + BIT(NL80211_IFTYPE_WDS) },
506 + { .max = 8, .types =
507 +#ifdef CONFIG_MAC80211_MESH
508 + BIT(NL80211_IFTYPE_MESH_POINT) |
510 + BIT(NL80211_IFTYPE_AP) |
511 + BIT(NL80211_IFTYPE_P2P_GO) },
514 +static const struct ieee80211_iface_combination if_comb = {
515 + .limits = if_limits,
516 + .n_limits = ARRAY_SIZE(if_limits),
517 + .max_interfaces = 2048,
518 + .num_different_channels = 1,
521 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
523 @@ -676,6 +694,9 @@ void ath9k_set_hw_capab(struct ath_softc
524 BIT(NL80211_IFTYPE_ADHOC) |
525 BIT(NL80211_IFTYPE_MESH_POINT);
527 + hw->wiphy->iface_combinations = &if_comb;
528 + hw->wiphy->n_iface_combinations = 1;
530 if (AR_SREV_5416(sc->sc_ah))
531 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
533 --- a/drivers/net/wireless/ath/ath9k/mac.c
534 +++ b/drivers/net/wireless/ath/ath9k/mac.c
535 @@ -133,8 +133,16 @@ EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel
537 void ath9k_hw_abort_tx_dma(struct ath_hw *ah)
539 + int maxdelay = 1000;
543 + if (IS_CHAN_HALF_RATE(ah->curchan))
545 + else if (IS_CHAN_QUARTER_RATE(ah->curchan))
549 REG_WRITE(ah, AR_Q_TXD, AR_Q_TXD_M);
551 REG_SET_BIT(ah, AR_PCU_MISC, AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF);
552 @@ -142,7 +150,7 @@ void ath9k_hw_abort_tx_dma(struct ath_hw
553 REG_SET_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
555 for (q = 0; q < AR_NUM_QCU; q++) {
556 - for (i = 0; i < 1000; i++) {
557 + for (i = 0; i < maxdelay; i++) {
561 --- a/net/mac80211/agg-rx.c
562 +++ b/net/mac80211/agg-rx.c
563 @@ -200,6 +200,8 @@ static void ieee80211_send_addba_resp(st
564 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
565 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
566 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
567 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
568 + memcpy(mgmt->bssid, da, ETH_ALEN);
570 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
571 IEEE80211_STYPE_ACTION);
572 --- a/net/mac80211/agg-tx.c
573 +++ b/net/mac80211/agg-tx.c
574 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
575 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
576 if (sdata->vif.type == NL80211_IFTYPE_AP ||
577 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
578 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
579 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
580 + sdata->vif.type == NL80211_IFTYPE_WDS)
581 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
582 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
583 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
584 @@ -484,6 +485,7 @@ int ieee80211_start_tx_ba_session(struct
585 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
586 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
587 sdata->vif.type != NL80211_IFTYPE_AP &&
588 + sdata->vif.type != NL80211_IFTYPE_WDS &&
589 sdata->vif.type != NL80211_IFTYPE_ADHOC)
592 --- a/net/mac80211/debugfs_sta.c
593 +++ b/net/mac80211/debugfs_sta.c
594 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
595 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
597 int res = scnprintf(buf, sizeof(buf),
598 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
599 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
600 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
601 TEST(PS_DRIVER), TEST(AUTHORIZED),
602 TEST(SHORT_PREAMBLE),
603 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
604 + TEST(WME), TEST(CLEAR_PS_FILT),
605 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
606 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
607 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
608 --- a/net/mac80211/iface.c
609 +++ b/net/mac80211/iface.c
610 @@ -282,7 +282,6 @@ static int ieee80211_do_open(struct net_
612 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
613 struct ieee80211_local *local = sdata->local;
614 - struct sta_info *sta;
617 u32 hw_reconf_flags = 0;
618 @@ -428,28 +427,6 @@ static int ieee80211_do_open(struct net_
620 set_bit(SDATA_STATE_RUNNING, &sdata->state);
622 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
623 - /* Create STA entry for the WDS peer */
624 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
628 - goto err_del_interface;
631 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
632 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
633 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
635 - res = sta_info_insert(sta);
637 - /* STA has been freed */
638 - goto err_del_interface;
641 - rate_control_rate_init(sta);
645 * set_multicast_list will be invoked by the networking core
646 * which will check whether any increments here were done in
647 @@ -846,6 +823,72 @@ static void ieee80211_if_setup(struct ne
648 dev->destructor = free_netdev;
651 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
652 + struct sk_buff *skb)
654 + struct ieee80211_local *local = sdata->local;
655 + struct ieee80211_rx_status *rx_status;
656 + struct ieee802_11_elems elems;
657 + struct ieee80211_mgmt *mgmt;
658 + struct sta_info *sta;
663 + enum ieee80211_band band = local->hw.conf.channel->band;
664 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
666 + rx_status = IEEE80211_SKB_RXCB(skb);
667 + mgmt = (struct ieee80211_mgmt *) skb->data;
668 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
670 + if (stype != IEEE80211_STYPE_BEACON)
673 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
674 + if (baselen > skb->len)
677 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
678 + skb->len - baselen, &elems);
680 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
684 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
688 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
696 + sta->last_rx = jiffies;
697 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
699 + if (elems.ht_cap_elem)
700 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
701 + elems.ht_cap_elem, &sta->sta.ht_cap);
703 + if (elems.wmm_param)
704 + set_sta_flag(sta, WLAN_STA_WME);
707 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
708 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
709 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
710 + rate_control_rate_init(sta);
711 + sta_info_insert_rcu(sta);
717 static void ieee80211_iface_work(struct work_struct *work)
719 struct ieee80211_sub_if_data *sdata =
720 @@ -950,6 +993,9 @@ static void ieee80211_iface_work(struct
722 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
724 + case NL80211_IFTYPE_WDS:
725 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
728 WARN(1, "frame for unexpected interface type");
730 --- a/net/mac80211/rx.c
731 +++ b/net/mac80211/rx.c
732 @@ -2283,6 +2283,7 @@ ieee80211_rx_h_action(struct ieee80211_r
733 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
734 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
735 sdata->vif.type != NL80211_IFTYPE_AP &&
736 + sdata->vif.type != NL80211_IFTYPE_WDS &&
737 sdata->vif.type != NL80211_IFTYPE_ADHOC)
740 @@ -2497,14 +2498,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
742 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
743 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
744 - sdata->vif.type != NL80211_IFTYPE_STATION)
745 + sdata->vif.type != NL80211_IFTYPE_STATION &&
746 + sdata->vif.type != NL80211_IFTYPE_WDS)
747 return RX_DROP_MONITOR;
750 case cpu_to_le16(IEEE80211_STYPE_AUTH):
751 case cpu_to_le16(IEEE80211_STYPE_BEACON):
752 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
753 - /* process for all: mesh, mlme, ibss */
754 + /* process for all: mesh, mlme, ibss, wds */
756 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
757 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
758 @@ -2838,10 +2840,16 @@ static int prepare_for_handlers(struct i
761 case NL80211_IFTYPE_WDS:
762 - if (bssid || !ieee80211_is_data(hdr->frame_control))
764 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
767 + if (ieee80211_is_data(hdr->frame_control) ||
768 + ieee80211_is_action(hdr->frame_control)) {
769 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
771 + } else if (!ieee80211_is_beacon(hdr->frame_control))
776 /* should never get here */
777 --- a/net/mac80211/sta_info.h
778 +++ b/net/mac80211/sta_info.h
780 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
782 * @WLAN_STA_WME: Station is a QoS-STA.
783 - * @WLAN_STA_WDS: Station is one of our WDS peers.
784 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
785 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
786 * frame to this station is transmitted.
787 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
789 WLAN_STA_SHORT_PREAMBLE,
792 WLAN_STA_CLEAR_PS_FILT,
795 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h
796 +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
797 @@ -425,6 +425,7 @@ void iwl_testmode_cleanup(struct iwl_pri
798 #ifdef CONFIG_IWLWIFI_DEBUG
799 void iwl_print_rx_config_cmd(struct iwl_priv *priv,
800 enum iwl_rxon_context_id ctxid);
801 +int iwl_alloc_traffic_mem(struct iwl_priv *priv);
803 static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
804 enum iwl_rxon_context_id ctxid)
805 @@ -510,7 +511,6 @@ void iwl_setup_deferred_work(struct iwl_
806 int iwl_send_wimax_coex(struct iwl_priv *priv);
807 int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
808 void iwl_debug_config(struct iwl_priv *priv);
809 -int iwl_alloc_traffic_mem(struct iwl_priv *priv);
810 void iwl_set_hw_params(struct iwl_priv *priv);
811 void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags);
812 int iwl_init_drv(struct iwl_priv *priv);
813 --- a/drivers/net/wireless/libertas/firmware.c
814 +++ b/drivers/net/wireless/libertas/firmware.c
816 #include <linux/firmware.h>
817 #include <linux/firmware.h>
818 #include <linux/module.h>
819 +#include <linux/sched.h>
823 --- a/drivers/net/wireless/ath/ath9k/recv.c
824 +++ b/drivers/net/wireless/ath/ath9k/recv.c
825 @@ -812,6 +812,7 @@ static bool ath9k_rx_accept(struct ath_c
826 is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
827 test_bit(rx_stats->rs_keyix, common->tkip_keymap);
828 strip_mic = is_valid_tkip && ieee80211_is_data(fc) &&
829 + ieee80211_has_protected(fc) &&
830 !(rx_stats->rs_status &
831 (ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC |
832 ATH9K_RXERR_KEYMISS));
833 --- a/net/mac80211/cfg.c
834 +++ b/net/mac80211/cfg.c
835 @@ -1005,6 +1005,9 @@ static int ieee80211_change_station(stru
838 if (params->vlan && params->vlan != sta->sdata->dev) {
839 + bool prev_4addr = false;
840 + bool new_4addr = false;
842 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
844 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
845 @@ -1020,9 +1023,25 @@ static int ieee80211_change_station(stru
848 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
852 + if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
853 + sta->sdata->u.vlan.sta) {
854 + rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL);
858 sta->sdata = vlansdata;
860 + if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
861 + prev_4addr != new_4addr) {
863 + atomic_dec(&sta->sdata->bss->num_mcast_sta);
865 + atomic_inc(&sta->sdata->bss->num_mcast_sta);
868 ieee80211_send_layer2_update(sta);
871 --- a/net/mac80211/debugfs_netdev.c
872 +++ b/net/mac80211/debugfs_netdev.c
873 @@ -394,7 +394,7 @@ static ssize_t ieee80211_if_parse_uapsd_
874 __IEEE80211_IF_FILE_W(uapsd_max_sp_len);
877 -IEEE80211_IF_FILE(num_sta_authorized, u.ap.num_sta_authorized, ATOMIC);
878 +IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC);
879 IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC);
880 IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC);
882 @@ -540,7 +540,7 @@ static void add_sta_files(struct ieee802
884 static void add_ap_files(struct ieee80211_sub_if_data *sdata)
886 - DEBUGFS_ADD(num_sta_authorized);
887 + DEBUGFS_ADD(num_mcast_sta);
888 DEBUGFS_ADD(num_sta_ps);
889 DEBUGFS_ADD(dtim_count);
890 DEBUGFS_ADD(num_buffered_multicast);
891 --- a/net/mac80211/ieee80211_i.h
892 +++ b/net/mac80211/ieee80211_i.h
893 @@ -282,7 +282,7 @@ struct ieee80211_if_ap {
894 u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)];
895 struct sk_buff_head ps_bc_buf;
896 atomic_t num_sta_ps; /* number of stations in PS mode */
897 - atomic_t num_sta_authorized; /* number of authorized stations */
898 + atomic_t num_mcast_sta; /* number of stations receiving multicast */
902 --- a/net/mac80211/sta_info.c
903 +++ b/net/mac80211/sta_info.c
904 @@ -1417,15 +1417,19 @@ int sta_info_move_state(struct sta_info
905 if (sta->sta_state == IEEE80211_STA_AUTH) {
906 set_bit(WLAN_STA_ASSOC, &sta->_flags);
907 } else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
908 - if (sta->sdata->vif.type == NL80211_IFTYPE_AP)
909 - atomic_dec(&sta->sdata->u.ap.num_sta_authorized);
910 + if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
911 + (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
912 + !sta->sdata->u.vlan.sta))
913 + atomic_dec(&sta->sdata->bss->num_mcast_sta);
914 clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
917 case IEEE80211_STA_AUTHORIZED:
918 if (sta->sta_state == IEEE80211_STA_ASSOC) {
919 - if (sta->sdata->vif.type == NL80211_IFTYPE_AP)
920 - atomic_inc(&sta->sdata->u.ap.num_sta_authorized);
921 + if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
922 + (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
923 + !sta->sdata->u.vlan.sta))
924 + atomic_inc(&sta->sdata->bss->num_mcast_sta);
925 set_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
928 --- a/net/mac80211/tx.c
929 +++ b/net/mac80211/tx.c
930 @@ -306,7 +306,7 @@ ieee80211_tx_h_check_assoc(struct ieee80
932 } else if (unlikely(tx->sdata->vif.type == NL80211_IFTYPE_AP &&
933 ieee80211_is_data(hdr->frame_control) &&
934 - !atomic_read(&tx->sdata->u.ap.num_sta_authorized))) {
935 + !atomic_read(&tx->sdata->u.ap.num_mcast_sta))) {
937 * No associated STAs - no need to send multicast
939 @@ -1159,7 +1159,8 @@ ieee80211_tx_prepare(struct ieee80211_su
940 tx->sta = rcu_dereference(sdata->u.vlan.sta);
941 if (!tx->sta && sdata->dev->ieee80211_ptr->use_4addr)
943 - } else if (info->flags & IEEE80211_TX_CTL_INJECTED) {
944 + } else if (info->flags & IEEE80211_TX_CTL_INJECTED ||
945 + tx->sdata->control_port_protocol == tx->skb->protocol) {
946 tx->sta = sta_info_get_bss(sdata, hdr->addr1);
949 --- a/net/wireless/scan.c
950 +++ b/net/wireless/scan.c
951 @@ -378,7 +378,11 @@ static int cmp_bss_core(struct cfg80211_
952 b->len_information_elements);
955 - return compare_ether_addr(a->bssid, b->bssid);
957 + * we can't use compare_ether_addr here since we need a < > operator.
958 + * The binary return value of compare_ether_addr isn't enough
960 + return memcmp(a->bssid, b->bssid, sizeof(a->bssid));
963 static int cmp_bss(struct cfg80211_bss *a,