ath9k: merge a tkip related stability fix
[openwrt/svn-archive/archive.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 @@ -2416,6 +2416,22 @@ ath5k_tx_complete_poll_work(struct work_
4 * Initialization routines *
5 \*************************/
6
7 +static const struct ieee80211_iface_limit if_limits[] = {
8 + { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) },
9 + { .max = 4, .types =
10 +#ifdef CONFIG_MAC80211_MESH
11 + BIT(NL80211_IFTYPE_MESH_POINT) |
12 +#endif
13 + BIT(NL80211_IFTYPE_AP) },
14 +};
15 +
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,
21 +};
22 +
23 int __devinit
24 ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops)
25 {
26 @@ -2437,6 +2453,9 @@ ath5k_init_ah(struct ath5k_hw *ah, const
27 BIT(NL80211_IFTYPE_ADHOC) |
28 BIT(NL80211_IFTYPE_MESH_POINT);
29
30 + hw->wiphy->iface_combinations = &if_comb;
31 + hw->wiphy->n_iface_combinations = 1;
32 +
33 /* SW support for IBSS_RSN is provided by mac80211 */
34 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
35
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
39 u32 synthDelay;
40
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;
44 - else
45 - synthDelay /= 10;
46 -
47 - if (IS_CHAN_HALF_RATE(chan))
48 - synthDelay *= 2;
49 - else if (IS_CHAN_QUARTER_RATE(chan))
50 - synthDelay *= 4;
51
52 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
53
54 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
55 + ath9k_hw_synth_delay(ah, chan, synthDelay);
56 }
57
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);
62 ath9k_olc_init(ah);
63 - ath9k_hw_apply_txpower(ah, chan);
64 + ath9k_hw_apply_txpower(ah, chan, false);
65
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)
70 {
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;
74 - else
75 - synthDelay /= 10;
76
77 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
78 + ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
79
80 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
81 }
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);
87
88 - txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
89 - REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
90 - udelay(5);
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);
95 + udelay(5);
96 + REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
97 + }
98
99 skip_tx_iqcal:
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
104 #undef POW_SM
105 }
106
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,
111 + bool is2GHz)
112 {
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);
118 -
119 - if (freq < 4000)
120 - is2GHz = true;
121 -
122 targetPowerValT2[ALL_TARGET_LEGACY_6_24] =
123 ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_6_24, freq,
124 is2GHz);
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,
128 is2GHz);
129 +}
130 +
131 +static void ar9003_hw_get_cck_target_powers(struct ath_hw *ah, u16 freq,
132 + u8 *targetPowerValT2)
133 +{
134 targetPowerValT2[ALL_TARGET_LEGACY_1L_5L] =
135 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_1L_5L,
136 freq);
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);
141 +}
142 +
143 +static void ar9003_hw_get_ht20_target_powers(struct ath_hw *ah, u16 freq,
144 + u8 *targetPowerValT2, bool is2GHz)
145 +{
146 targetPowerValT2[ALL_TARGET_HT20_0_8_16] =
147 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
148 is2GHz);
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,
152 is2GHz);
153 +}
154 +
155 +static void ar9003_hw_get_ht40_target_powers(struct ath_hw *ah,
156 + u16 freq,
157 + u8 *targetPowerValT2,
158 + bool is2GHz)
159 +{
160 + /* XXX: hard code for now, need to get from eeprom struct */
161 + u8 ht40PowerIncForPdadc = 0;
162 +
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;
170 +}
171 +
172 +static void ar9003_hw_get_target_power_eeprom(struct ath_hw *ah,
173 + struct ath9k_channel *chan,
174 + u8 *targetPowerValT2)
175 +{
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;
180 +
181 + if (is2GHz)
182 + ar9003_hw_get_cck_target_powers(ah, freq, targetPowerValT2);
183 +
184 + ar9003_hw_get_legacy_target_powers(ah, freq, targetPowerValT2, is2GHz);
185 + ar9003_hw_get_ht20_target_powers(ah, freq, targetPowerValT2, is2GHz);
186 +
187 + if (IS_CHAN_HT40(chan))
188 + ar9003_hw_get_ht40_target_powers(ah, freq, targetPowerValT2,
189 + is2GHz);
190
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,
195 antenna_reduction);
196
197 - /*
198 - * Get target powers from EEPROM - our baseline for TX Power
199 - */
200 if (is2ghz) {
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;
206
207 - ar9003_hw_set_target_power_eeprom(ah, chan->channel, targetPowerValT2);
208 + memset(targetPowerValT2, 0 , sizeof(targetPowerValT2));
209 +
210 + /*
211 + * Get target powers from EEPROM - our baseline for TX Power
212 + */
213 + ar9003_hw_get_target_power_eeprom(ah, chan, targetPowerValT2);
214
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 *
220
221 if (val) {
222 ah->paprd_table_write_done = true;
223 - ath9k_hw_apply_txpower(ah, chan);
224 + ath9k_hw_apply_txpower(ah, chan, false);
225 }
226
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 @@ -526,22 +526,10 @@ static void ar9003_hw_init_bb(struct ath
231 * Value is in 100ns increments.
232 */
233 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
234 - if (IS_CHAN_B(chan))
235 - synthDelay = (4 * synthDelay) / 22;
236 - else
237 - synthDelay /= 10;
238
239 /* Activate the PHY (includes baseband activate + synthesizer on) */
240 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
241 -
242 - /*
243 - * There is an issue if the AP starts the calibration before
244 - * the base band timeout completes. This could result in the
245 - * rx_clear false triggering. As a workaround we add delay an
246 - * extra BASE_ACTIVATE_DELAY usecs to ensure this condition
247 - * does not happen.
248 - */
249 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
250 + ath9k_hw_synth_delay(ah, chan, synthDelay);
251 }
252
253 static void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx)
254 @@ -692,7 +680,7 @@ static int ar9003_hw_process_ini(struct
255 ar9003_hw_override_ini(ah);
256 ar9003_hw_set_channel_regs(ah, chan);
257 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
258 - ath9k_hw_apply_txpower(ah, chan);
259 + ath9k_hw_apply_txpower(ah, chan, false);
260
261 if (AR_SREV_9462(ah)) {
262 if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
263 @@ -723,6 +711,14 @@ static void ar9003_hw_set_rfmode(struct
264
265 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
266 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
267 + if (IS_CHAN_QUARTER_RATE(chan))
268 + rfMode |= AR_PHY_MODE_QUARTER;
269 + if (IS_CHAN_HALF_RATE(chan))
270 + rfMode |= AR_PHY_MODE_HALF;
271 +
272 + if (rfMode & (AR_PHY_MODE_QUARTER | AR_PHY_MODE_HALF))
273 + REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL,
274 + AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW, 3);
275
276 REG_WRITE(ah, AR_PHY_MODE, rfMode);
277 }
278 @@ -793,12 +789,8 @@ static bool ar9003_hw_rfbus_req(struct a
279 static void ar9003_hw_rfbus_done(struct ath_hw *ah)
280 {
281 u32 synthDelay = REG_READ(ah, AR_PHY_RX_DELAY) & AR_PHY_RX_DELAY_DELAY;
282 - if (IS_CHAN_B(ah->curchan))
283 - synthDelay = (4 * synthDelay) / 22;
284 - else
285 - synthDelay /= 10;
286
287 - udelay(synthDelay + BASE_ACTIVATE_DELAY);
288 + ath9k_hw_synth_delay(ah, ah->curchan, synthDelay);
289
290 REG_WRITE(ah, AR_PHY_RFBUS_REQ, 0);
291 }
292 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
293 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
294 @@ -468,6 +468,9 @@
295 #define AR_PHY_ADDAC_PARA_CTL (AR_SM_BASE + 0x150)
296 #define AR_PHY_XPA_CFG (AR_SM_BASE + 0x158)
297
298 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW 3
299 +#define AR_PHY_FRAME_CTL_CF_OVERLAP_WINDOW_S 0
300 +
301 #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_IDX_A 0x0001FC00
302 #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_IDX_A_S 10
303 #define AR_PHY_SPUR_MASK_A_CF_PUNC_MASK_A 0x3FF
304 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
305 +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
306 @@ -798,6 +798,8 @@ static void ath9k_hw_ar9287_set_txpower(
307 regulatory->max_power_level = ratesArray[i];
308 }
309
310 + ath9k_hw_update_regulatory_maxpower(ah);
311 +
312 if (test)
313 return;
314
315 --- a/drivers/net/wireless/ath/ath9k/hw.c
316 +++ b/drivers/net/wireless/ath/ath9k/hw.c
317 @@ -191,6 +191,22 @@ bool ath9k_hw_wait(struct ath_hw *ah, u3
318 }
319 EXPORT_SYMBOL(ath9k_hw_wait);
320
321 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
322 + int hw_delay)
323 +{
324 + if (IS_CHAN_B(chan))
325 + hw_delay = (4 * hw_delay) / 22;
326 + else
327 + hw_delay /= 10;
328 +
329 + if (IS_CHAN_HALF_RATE(chan))
330 + hw_delay *= 2;
331 + else if (IS_CHAN_QUARTER_RATE(chan))
332 + hw_delay *= 4;
333 +
334 + udelay(hw_delay + BASE_ACTIVATE_DELAY);
335 +}
336 +
337 void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
338 int column, unsigned int *writecnt)
339 {
340 @@ -1020,7 +1036,7 @@ void ath9k_hw_init_global_settings(struc
341 struct ath_common *common = ath9k_hw_common(ah);
342 struct ieee80211_conf *conf = &common->hw->conf;
343 const struct ath9k_channel *chan = ah->curchan;
344 - int acktimeout, ctstimeout;
345 + int acktimeout, ctstimeout, ack_offset = 0;
346 int slottime;
347 int sifstime;
348 int rx_lat = 0, tx_lat = 0, eifs = 0;
349 @@ -1041,6 +1057,11 @@ void ath9k_hw_init_global_settings(struc
350 rx_lat = 37;
351 tx_lat = 54;
352
353 + if (IS_CHAN_5GHZ(chan))
354 + sifstime = 16;
355 + else
356 + sifstime = 10;
357 +
358 if (IS_CHAN_HALF_RATE(chan)) {
359 eifs = 175;
360 rx_lat *= 2;
361 @@ -1048,8 +1069,9 @@ void ath9k_hw_init_global_settings(struc
362 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
363 tx_lat += 11;
364
365 + sifstime *= 2;
366 + ack_offset = 16;
367 slottime = 13;
368 - sifstime = 32;
369 } else if (IS_CHAN_QUARTER_RATE(chan)) {
370 eifs = 340;
371 rx_lat = (rx_lat * 4) - 1;
372 @@ -1057,8 +1079,9 @@ void ath9k_hw_init_global_settings(struc
373 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
374 tx_lat += 22;
375
376 + sifstime *= 4;
377 + ack_offset = 32;
378 slottime = 21;
379 - sifstime = 64;
380 } else {
381 if (AR_SREV_9287(ah) && AR_SREV_9287_13_OR_LATER(ah)) {
382 eifs = AR_D_GBL_IFS_EIFS_ASYNC_FIFO;
383 @@ -1072,14 +1095,10 @@ void ath9k_hw_init_global_settings(struc
384 tx_lat = MS(reg, AR_USEC_TX_LAT);
385
386 slottime = ah->slottime;
387 - if (IS_CHAN_5GHZ(chan))
388 - sifstime = 16;
389 - else
390 - sifstime = 10;
391 }
392
393 /* As defined by IEEE 802.11-2007 17.3.8.6 */
394 - acktimeout = slottime + sifstime + 3 * ah->coverage_class;
395 + acktimeout = slottime + sifstime + 3 * ah->coverage_class + ack_offset;
396 ctstimeout = acktimeout;
397
398 /*
399 @@ -1089,7 +1108,8 @@ void ath9k_hw_init_global_settings(struc
400 * BA frames in some implementations, but it has been found to fix ACK
401 * timeout issues in other cases as well.
402 */
403 - if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ) {
404 + if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ &&
405 + !IS_CHAN_HALF_RATE(chan) && !IS_CHAN_QUARTER_RATE(chan)) {
406 acktimeout += 64 - sifstime - ah->slottime;
407 ctstimeout += 48 - sifstime - ah->slottime;
408 }
409 @@ -1469,6 +1489,10 @@ static bool ath9k_hw_channel_change(stru
410 CHANNEL_5GHZ));
411 mode_diff = (chan->chanmode != ah->curchan->chanmode);
412
413 + if ((ah->curchan->channelFlags | chan->channelFlags) &
414 + (CHANNEL_HALF | CHANNEL_QUARTER))
415 + return false;
416 +
417 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
418 if (ath9k_hw_numtxpending(ah, qnum)) {
419 ath_dbg(common, QUEUE,
420 @@ -1502,7 +1526,7 @@ static bool ath9k_hw_channel_change(stru
421 return false;
422 }
423 ath9k_hw_set_clockrate(ah);
424 - ath9k_hw_apply_txpower(ah, chan);
425 + ath9k_hw_apply_txpower(ah, chan, false);
426 ath9k_hw_rfbus_done(ah);
427
428 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
429 @@ -2773,7 +2797,8 @@ static int get_antenna_gain(struct ath_h
430 return ah->eep_ops->get_eeprom(ah, gain_param);
431 }
432
433 -void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan)
434 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
435 + bool test)
436 {
437 struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
438 struct ieee80211_channel *channel;
439 @@ -2794,7 +2819,7 @@ void ath9k_hw_apply_txpower(struct ath_h
440
441 ah->eep_ops->set_txpower(ah, chan,
442 ath9k_regd_get_ctl(reg, chan),
443 - ant_reduction, new_pwr, false);
444 + ant_reduction, new_pwr, test);
445 }
446
447 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
448 @@ -2807,7 +2832,7 @@ void ath9k_hw_set_txpowerlimit(struct at
449 if (test)
450 channel->max_power = MAX_RATE_POWER / 2;
451
452 - ath9k_hw_apply_txpower(ah, chan);
453 + ath9k_hw_apply_txpower(ah, chan, test);
454
455 if (test)
456 channel->max_power = DIV_ROUND_UP(reg->max_power_level, 2);
457 --- a/drivers/net/wireless/ath/ath9k/hw.h
458 +++ b/drivers/net/wireless/ath/ath9k/hw.h
459 @@ -923,6 +923,8 @@ void ath9k_hw_set_gpio(struct ath_hw *ah
460 void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna);
461
462 /* General Operation */
463 +void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan,
464 + int hw_delay);
465 bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
466 void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
467 int column, unsigned int *writecnt);
468 @@ -982,7 +984,8 @@ void ath9k_hw_name(struct ath_hw *ah, ch
469 /* PHY */
470 void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
471 u32 *coef_mantissa, u32 *coef_exponent);
472 -void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan);
473 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan,
474 + bool test);
475
476 /*
477 * Code Specific to AR5008, AR9001 or AR9002,
478 --- a/drivers/net/wireless/ath/ath9k/init.c
479 +++ b/drivers/net/wireless/ath/ath9k/init.c
480 @@ -647,6 +647,24 @@ void ath9k_reload_chainmask_settings(str
481 setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap);
482 }
483
484 +static const struct ieee80211_iface_limit if_limits[] = {
485 + { .max = 2048, .types = BIT(NL80211_IFTYPE_STATION) |
486 + BIT(NL80211_IFTYPE_P2P_CLIENT) |
487 + BIT(NL80211_IFTYPE_WDS) },
488 + { .max = 8, .types =
489 +#ifdef CONFIG_MAC80211_MESH
490 + BIT(NL80211_IFTYPE_MESH_POINT) |
491 +#endif
492 + BIT(NL80211_IFTYPE_AP) |
493 + BIT(NL80211_IFTYPE_P2P_GO) },
494 +};
495 +
496 +static const struct ieee80211_iface_combination if_comb = {
497 + .limits = if_limits,
498 + .n_limits = ARRAY_SIZE(if_limits),
499 + .max_interfaces = 2048,
500 + .num_different_channels = 1,
501 +};
502
503 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
504 {
505 @@ -676,6 +694,9 @@ void ath9k_set_hw_capab(struct ath_softc
506 BIT(NL80211_IFTYPE_ADHOC) |
507 BIT(NL80211_IFTYPE_MESH_POINT);
508
509 + hw->wiphy->iface_combinations = &if_comb;
510 + hw->wiphy->n_iface_combinations = 1;
511 +
512 if (AR_SREV_5416(sc->sc_ah))
513 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
514
515 --- a/drivers/net/wireless/ath/ath9k/mac.c
516 +++ b/drivers/net/wireless/ath/ath9k/mac.c
517 @@ -133,8 +133,16 @@ EXPORT_SYMBOL(ath9k_hw_updatetxtriglevel
518
519 void ath9k_hw_abort_tx_dma(struct ath_hw *ah)
520 {
521 + int maxdelay = 1000;
522 int i, q;
523
524 + if (ah->curchan) {
525 + if (IS_CHAN_HALF_RATE(ah->curchan))
526 + maxdelay *= 2;
527 + else if (IS_CHAN_QUARTER_RATE(ah->curchan))
528 + maxdelay *= 4;
529 + }
530 +
531 REG_WRITE(ah, AR_Q_TXD, AR_Q_TXD_M);
532
533 REG_SET_BIT(ah, AR_PCU_MISC, AR_PCU_FORCE_QUIET_COLL | AR_PCU_CLEAR_VMF);
534 @@ -142,7 +150,7 @@ void ath9k_hw_abort_tx_dma(struct ath_hw
535 REG_SET_BIT(ah, AR_D_GBL_IFS_MISC, AR_D_GBL_IFS_MISC_IGNORE_BACKOFF);
536
537 for (q = 0; q < AR_NUM_QCU; q++) {
538 - for (i = 0; i < 1000; i++) {
539 + for (i = 0; i < maxdelay; i++) {
540 if (i)
541 udelay(5);
542
543 --- a/net/mac80211/agg-rx.c
544 +++ b/net/mac80211/agg-rx.c
545 @@ -200,6 +200,8 @@ static void ieee80211_send_addba_resp(st
546 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
547 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
548 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
549 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
550 + memcpy(mgmt->bssid, da, ETH_ALEN);
551
552 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
553 IEEE80211_STYPE_ACTION);
554 --- a/net/mac80211/agg-tx.c
555 +++ b/net/mac80211/agg-tx.c
556 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
557 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
558 if (sdata->vif.type == NL80211_IFTYPE_AP ||
559 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
560 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
561 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
562 + sdata->vif.type == NL80211_IFTYPE_WDS)
563 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
564 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
565 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
566 @@ -484,6 +485,7 @@ int ieee80211_start_tx_ba_session(struct
567 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
568 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
569 sdata->vif.type != NL80211_IFTYPE_AP &&
570 + sdata->vif.type != NL80211_IFTYPE_WDS &&
571 sdata->vif.type != NL80211_IFTYPE_ADHOC)
572 return -EINVAL;
573
574 --- a/net/mac80211/debugfs_sta.c
575 +++ b/net/mac80211/debugfs_sta.c
576 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
577 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
578
579 int res = scnprintf(buf, sizeof(buf),
580 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
581 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
582 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
583 TEST(PS_DRIVER), TEST(AUTHORIZED),
584 TEST(SHORT_PREAMBLE),
585 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
586 + TEST(WME), TEST(CLEAR_PS_FILT),
587 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
588 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
589 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
590 --- a/net/mac80211/iface.c
591 +++ b/net/mac80211/iface.c
592 @@ -282,7 +282,6 @@ static int ieee80211_do_open(struct net_
593 {
594 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
595 struct ieee80211_local *local = sdata->local;
596 - struct sta_info *sta;
597 u32 changed = 0;
598 int res;
599 u32 hw_reconf_flags = 0;
600 @@ -428,28 +427,6 @@ static int ieee80211_do_open(struct net_
601
602 set_bit(SDATA_STATE_RUNNING, &sdata->state);
603
604 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
605 - /* Create STA entry for the WDS peer */
606 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
607 - GFP_KERNEL);
608 - if (!sta) {
609 - res = -ENOMEM;
610 - goto err_del_interface;
611 - }
612 -
613 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
614 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
615 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
616 -
617 - res = sta_info_insert(sta);
618 - if (res) {
619 - /* STA has been freed */
620 - goto err_del_interface;
621 - }
622 -
623 - rate_control_rate_init(sta);
624 - }
625 -
626 /*
627 * set_multicast_list will be invoked by the networking core
628 * which will check whether any increments here were done in
629 @@ -846,6 +823,72 @@ static void ieee80211_if_setup(struct ne
630 dev->destructor = free_netdev;
631 }
632
633 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
634 + struct sk_buff *skb)
635 +{
636 + struct ieee80211_local *local = sdata->local;
637 + struct ieee80211_rx_status *rx_status;
638 + struct ieee802_11_elems elems;
639 + struct ieee80211_mgmt *mgmt;
640 + struct sta_info *sta;
641 + size_t baselen;
642 + u32 rates = 0;
643 + u16 stype;
644 + bool new = false;
645 + enum ieee80211_band band = local->hw.conf.channel->band;
646 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
647 +
648 + rx_status = IEEE80211_SKB_RXCB(skb);
649 + mgmt = (struct ieee80211_mgmt *) skb->data;
650 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
651 +
652 + if (stype != IEEE80211_STYPE_BEACON)
653 + return;
654 +
655 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
656 + if (baselen > skb->len)
657 + return;
658 +
659 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
660 + skb->len - baselen, &elems);
661 +
662 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
663 +
664 + rcu_read_lock();
665 +
666 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
667 +
668 + if (!sta) {
669 + rcu_read_unlock();
670 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
671 + GFP_KERNEL);
672 + if (!sta)
673 + return;
674 +
675 + new = true;
676 + }
677 +
678 + sta->last_rx = jiffies;
679 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
680 +
681 + if (elems.ht_cap_elem)
682 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
683 + elems.ht_cap_elem, &sta->sta.ht_cap);
684 +
685 + if (elems.wmm_param)
686 + set_sta_flag(sta, WLAN_STA_WME);
687 +
688 + if (new) {
689 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
690 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
691 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
692 + rate_control_rate_init(sta);
693 + sta_info_insert_rcu(sta);
694 + }
695 +
696 + rcu_read_unlock();
697 +}
698 +
699 static void ieee80211_iface_work(struct work_struct *work)
700 {
701 struct ieee80211_sub_if_data *sdata =
702 @@ -950,6 +993,9 @@ static void ieee80211_iface_work(struct
703 break;
704 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
705 break;
706 + case NL80211_IFTYPE_WDS:
707 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
708 + break;
709 default:
710 WARN(1, "frame for unexpected interface type");
711 break;
712 --- a/net/mac80211/rx.c
713 +++ b/net/mac80211/rx.c
714 @@ -2283,6 +2283,7 @@ ieee80211_rx_h_action(struct ieee80211_r
715 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
716 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
717 sdata->vif.type != NL80211_IFTYPE_AP &&
718 + sdata->vif.type != NL80211_IFTYPE_WDS &&
719 sdata->vif.type != NL80211_IFTYPE_ADHOC)
720 break;
721
722 @@ -2497,14 +2498,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
723
724 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
725 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
726 - sdata->vif.type != NL80211_IFTYPE_STATION)
727 + sdata->vif.type != NL80211_IFTYPE_STATION &&
728 + sdata->vif.type != NL80211_IFTYPE_WDS)
729 return RX_DROP_MONITOR;
730
731 switch (stype) {
732 case cpu_to_le16(IEEE80211_STYPE_AUTH):
733 case cpu_to_le16(IEEE80211_STYPE_BEACON):
734 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
735 - /* process for all: mesh, mlme, ibss */
736 + /* process for all: mesh, mlme, ibss, wds */
737 break;
738 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
739 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
740 @@ -2838,10 +2840,16 @@ static int prepare_for_handlers(struct i
741 }
742 break;
743 case NL80211_IFTYPE_WDS:
744 - if (bssid || !ieee80211_is_data(hdr->frame_control))
745 - return 0;
746 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
747 return 0;
748 +
749 + if (ieee80211_is_data(hdr->frame_control) ||
750 + ieee80211_is_action(hdr->frame_control)) {
751 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
752 + return 0;
753 + } else if (!ieee80211_is_beacon(hdr->frame_control))
754 + return 0;
755 +
756 break;
757 default:
758 /* should never get here */
759 --- a/net/mac80211/sta_info.h
760 +++ b/net/mac80211/sta_info.h
761 @@ -32,7 +32,6 @@
762 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
763 * frames.
764 * @WLAN_STA_WME: Station is a QoS-STA.
765 - * @WLAN_STA_WDS: Station is one of our WDS peers.
766 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
767 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
768 * frame to this station is transmitted.
769 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
770 WLAN_STA_AUTHORIZED,
771 WLAN_STA_SHORT_PREAMBLE,
772 WLAN_STA_WME,
773 - WLAN_STA_WDS,
774 WLAN_STA_CLEAR_PS_FILT,
775 WLAN_STA_MFP,
776 WLAN_STA_BLOCK_BA,
777 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h
778 +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
779 @@ -425,6 +425,7 @@ void iwl_testmode_cleanup(struct iwl_pri
780 #ifdef CONFIG_IWLWIFI_DEBUG
781 void iwl_print_rx_config_cmd(struct iwl_priv *priv,
782 enum iwl_rxon_context_id ctxid);
783 +int iwl_alloc_traffic_mem(struct iwl_priv *priv);
784 #else
785 static inline void iwl_print_rx_config_cmd(struct iwl_priv *priv,
786 enum iwl_rxon_context_id ctxid)
787 @@ -510,7 +511,6 @@ void iwl_setup_deferred_work(struct iwl_
788 int iwl_send_wimax_coex(struct iwl_priv *priv);
789 int iwl_send_bt_env(struct iwl_priv *priv, u8 action, u8 type);
790 void iwl_debug_config(struct iwl_priv *priv);
791 -int iwl_alloc_traffic_mem(struct iwl_priv *priv);
792 void iwl_set_hw_params(struct iwl_priv *priv);
793 void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags);
794 int iwl_init_drv(struct iwl_priv *priv);
795 --- a/drivers/net/wireless/libertas/firmware.c
796 +++ b/drivers/net/wireless/libertas/firmware.c
797 @@ -5,6 +5,7 @@
798 #include <linux/firmware.h>
799 #include <linux/firmware.h>
800 #include <linux/module.h>
801 +#include <linux/sched.h>
802
803 #include "dev.h"
804 #include "decl.h"
805 --- a/drivers/net/wireless/ath/ath9k/recv.c
806 +++ b/drivers/net/wireless/ath/ath9k/recv.c
807 @@ -812,6 +812,7 @@ static bool ath9k_rx_accept(struct ath_c
808 is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
809 test_bit(rx_stats->rs_keyix, common->tkip_keymap);
810 strip_mic = is_valid_tkip && ieee80211_is_data(fc) &&
811 + ieee80211_has_protected(fc) &&
812 !(rx_stats->rs_status &
813 (ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC |
814 ATH9K_RXERR_KEYMISS));