mac80211: fix ad-hoc mode 802.11n channel type
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
2 +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
3 @@ -203,7 +203,7 @@ static void ar9002_hw_iqcalibrate(struct
4 i);
5
6 ath_dbg(common, ATH_DBG_CALIBRATE,
7 - "Orignal: Chn %diq_corr_meas = 0x%08x\n",
8 + "Original: Chn %d iq_corr_meas = 0x%08x\n",
9 i, ah->totalIqCorrMeas[i]);
10
11 iqCorrNeg = 0;
12 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
13 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
14 @@ -226,7 +226,7 @@ static void ar9003_hw_iqcalibrate(struct
15 i);
16
17 ath_dbg(common, ATH_DBG_CALIBRATE,
18 - "Orignal: Chn %diq_corr_meas = 0x%08x\n",
19 + "Original: Chn %d iq_corr_meas = 0x%08x\n",
20 i, ah->totalIqCorrMeas[i]);
21
22 iqCorrNeg = 0;
23 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
24 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
25 @@ -808,7 +808,8 @@ void ath9k_htc_ani_work(struct work_stru
26 }
27
28 /* Verify whether we must check ANI */
29 - if ((timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) {
30 + if (ah->config.enable_ani &&
31 + (timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) {
32 aniflag = true;
33 common->ani.checkani_timer = timestamp;
34 }
35 --- a/drivers/net/wireless/ath/ath9k/hw.c
36 +++ b/drivers/net/wireless/ath/ath9k/hw.c
37 @@ -504,7 +504,7 @@ static int ath9k_hw_post_init(struct ath
38 return ecode;
39 }
40
41 - if (!AR_SREV_9100(ah) && !AR_SREV_9340(ah)) {
42 + if (ah->config.enable_ani) {
43 ath9k_hw_ani_setup(ah);
44 ath9k_hw_ani_init(ah);
45 }
46 @@ -610,6 +610,10 @@ static int __ath9k_hw_init(struct ath_hw
47 if (!AR_SREV_9300_20_OR_LATER(ah))
48 ah->ani_function &= ~ATH9K_ANI_MRC_CCK;
49
50 + /* disable ANI for 9340 */
51 + if (AR_SREV_9340(ah))
52 + ah->config.enable_ani = false;
53 +
54 ath9k_hw_init_mode_regs(ah);
55
56 if (!ah->is_pciexpress)
57 --- a/drivers/net/wireless/ath/ath9k/main.c
58 +++ b/drivers/net/wireless/ath/ath9k/main.c
59 @@ -118,7 +118,7 @@ void ath9k_ps_restore(struct ath_softc *
60 if (--sc->ps_usecount != 0)
61 goto unlock;
62
63 - if (sc->ps_idle)
64 + if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK))
65 mode = ATH9K_PM_FULL_SLEEP;
66 else if (sc->ps_enabled &&
67 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
68 @@ -286,7 +286,7 @@ static bool ath_complete_reset(struct at
69 ath_start_ani(common);
70 }
71
72 - if (ath9k_hw_ops(ah)->antdiv_comb_conf_get && sc->ant_rx != 3) {
73 + if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3) {
74 struct ath_hw_antcomb_conf div_ant_conf;
75 u8 lna_conf;
76
77 @@ -332,7 +332,8 @@ static int ath_reset_internal(struct ath
78 hchan = ah->curchan;
79 }
80
81 - if (fastcc && !ath9k_hw_check_alive(ah))
82 + if (fastcc && (ah->chip_fullsleep ||
83 + !ath9k_hw_check_alive(ah)))
84 fastcc = false;
85
86 if (!ath_prepare_reset(sc, retry_tx, flush))
87 @@ -561,7 +562,6 @@ void ath_ani_calibrate(unsigned long dat
88 /* Long calibration runs independently of short calibration. */
89 if ((timestamp - common->ani.longcal_timer) >= long_cal_interval) {
90 longcal = true;
91 - ath_dbg(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
92 common->ani.longcal_timer = timestamp;
93 }
94
95 @@ -569,8 +569,6 @@ void ath_ani_calibrate(unsigned long dat
96 if (!common->ani.caldone) {
97 if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) {
98 shortcal = true;
99 - ath_dbg(common, ATH_DBG_ANI,
100 - "shortcal @%lu\n", jiffies);
101 common->ani.shortcal_timer = timestamp;
102 common->ani.resetcal_timer = timestamp;
103 }
104 @@ -584,8 +582,9 @@ void ath_ani_calibrate(unsigned long dat
105 }
106
107 /* Verify whether we must check ANI */
108 - if ((timestamp - common->ani.checkani_timer) >=
109 - ah->config.ani_poll_interval) {
110 + if (sc->sc_ah->config.enable_ani
111 + && (timestamp - common->ani.checkani_timer) >=
112 + ah->config.ani_poll_interval) {
113 aniflag = true;
114 common->ani.checkani_timer = timestamp;
115 }
116 @@ -605,6 +604,11 @@ void ath_ani_calibrate(unsigned long dat
117 ah->rxchainmask, longcal);
118 }
119
120 + ath_dbg(common, ATH_DBG_ANI,
121 + "Calibration @%lu finished: %s %s %s, caldone: %s\n", jiffies,
122 + longcal ? "long" : "", shortcal ? "short" : "",
123 + aniflag ? "ani" : "", common->ani.caldone ? "true" : "false");
124 +
125 ath9k_ps_restore(sc);
126
127 set_timer:
128 @@ -886,82 +890,6 @@ chip_reset:
129 #undef SCHED_INTR
130 }
131
132 -static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
133 -{
134 - struct ath_hw *ah = sc->sc_ah;
135 - struct ath_common *common = ath9k_hw_common(ah);
136 - struct ieee80211_channel *channel = hw->conf.channel;
137 - int r;
138 -
139 - ath9k_ps_wakeup(sc);
140 - spin_lock_bh(&sc->sc_pcu_lock);
141 - atomic_set(&ah->intr_ref_cnt, -1);
142 -
143 - ath9k_hw_configpcipowersave(ah, false);
144 -
145 - if (!ah->curchan)
146 - ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah);
147 -
148 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
149 - if (r) {
150 - ath_err(common,
151 - "Unable to reset channel (%u MHz), reset status %d\n",
152 - channel->center_freq, r);
153 - }
154 -
155 - ath_complete_reset(sc, true);
156 -
157 - /* Enable LED */
158 - ath9k_hw_cfg_output(ah, ah->led_pin,
159 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
160 - ath9k_hw_set_gpio(ah, ah->led_pin, 0);
161 -
162 - spin_unlock_bh(&sc->sc_pcu_lock);
163 -
164 - ath9k_ps_restore(sc);
165 -}
166 -
167 -void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
168 -{
169 - struct ath_hw *ah = sc->sc_ah;
170 - struct ieee80211_channel *channel = hw->conf.channel;
171 - int r;
172 -
173 - ath9k_ps_wakeup(sc);
174 -
175 - ath_cancel_work(sc);
176 -
177 - spin_lock_bh(&sc->sc_pcu_lock);
178 -
179 - /*
180 - * Keep the LED on when the radio is disabled
181 - * during idle unassociated state.
182 - */
183 - if (!sc->ps_idle) {
184 - ath9k_hw_set_gpio(ah, ah->led_pin, 1);
185 - ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
186 - }
187 -
188 - ath_prepare_reset(sc, false, true);
189 -
190 - if (!ah->curchan)
191 - ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
192 -
193 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
194 - if (r) {
195 - ath_err(ath9k_hw_common(sc->sc_ah),
196 - "Unable to reset channel (%u MHz), reset status %d\n",
197 - channel->center_freq, r);
198 - }
199 -
200 - ath9k_hw_phy_disable(ah);
201 -
202 - ath9k_hw_configpcipowersave(ah, true);
203 -
204 - spin_unlock_bh(&sc->sc_pcu_lock);
205 - ath9k_ps_restore(sc);
206 -}
207 -
208 static int ath_reset(struct ath_softc *sc, bool retry_tx)
209 {
210 int r;
211 @@ -1097,6 +1025,9 @@ static int ath9k_start(struct ieee80211_
212 * and then setup of the interrupt mask.
213 */
214 spin_lock_bh(&sc->sc_pcu_lock);
215 +
216 + atomic_set(&ah->intr_ref_cnt, -1);
217 +
218 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
219 if (r) {
220 ath_err(common,
221 @@ -1138,6 +1069,18 @@ static int ath9k_start(struct ieee80211_
222 goto mutex_unlock;
223 }
224
225 + if (ah->led_pin >= 0) {
226 + ath9k_hw_cfg_output(ah, ah->led_pin,
227 + AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
228 + ath9k_hw_set_gpio(ah, ah->led_pin, 0);
229 + }
230 +
231 + /*
232 + * Reset key cache to sane defaults (all entries cleared) instead of
233 + * semi-random values after suspend/resume.
234 + */
235 + ath9k_cmn_init_crypto(sc->sc_ah);
236 +
237 spin_unlock_bh(&sc->sc_pcu_lock);
238
239 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
240 @@ -1183,6 +1126,13 @@ static void ath9k_tx(struct ieee80211_hw
241 }
242 }
243
244 + /*
245 + * Cannot tx while the hardware is in full sleep, it first needs a full
246 + * chip reset to recover from that
247 + */
248 + if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP))
249 + goto exit;
250 +
251 if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
252 /*
253 * We are using PS-Poll and mac80211 can request TX while in
254 @@ -1229,6 +1179,7 @@ static void ath9k_stop(struct ieee80211_
255 struct ath_softc *sc = hw->priv;
256 struct ath_hw *ah = sc->sc_ah;
257 struct ath_common *common = ath9k_hw_common(ah);
258 + bool prev_idle;
259
260 mutex_lock(&sc->mutex);
261
262 @@ -1259,35 +1210,45 @@ static void ath9k_stop(struct ieee80211_
263 * before setting the invalid flag. */
264 ath9k_hw_disable_interrupts(ah);
265
266 - if (!(sc->sc_flags & SC_OP_INVALID)) {
267 - ath_drain_all_txq(sc, false);
268 - ath_stoprecv(sc);
269 - ath9k_hw_phy_disable(ah);
270 - } else
271 - sc->rx.rxlink = NULL;
272 + spin_unlock_bh(&sc->sc_pcu_lock);
273 +
274 + /* we can now sync irq and kill any running tasklets, since we already
275 + * disabled interrupts and not holding a spin lock */
276 + synchronize_irq(sc->irq);
277 + tasklet_kill(&sc->intr_tq);
278 + tasklet_kill(&sc->bcon_tasklet);
279 +
280 + prev_idle = sc->ps_idle;
281 + sc->ps_idle = true;
282 +
283 + spin_lock_bh(&sc->sc_pcu_lock);
284 +
285 + if (ah->led_pin >= 0) {
286 + ath9k_hw_set_gpio(ah, ah->led_pin, 1);
287 + ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
288 + }
289 +
290 + ath_prepare_reset(sc, false, true);
291
292 if (sc->rx.frag) {
293 dev_kfree_skb_any(sc->rx.frag);
294 sc->rx.frag = NULL;
295 }
296
297 - /* disable HAL and put h/w to sleep */
298 - ath9k_hw_disable(ah);
299 + if (!ah->curchan)
300 + ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
301
302 - spin_unlock_bh(&sc->sc_pcu_lock);
303 + ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
304 + ath9k_hw_phy_disable(ah);
305
306 - /* we can now sync irq and kill any running tasklets, since we already
307 - * disabled interrupts and not holding a spin lock */
308 - synchronize_irq(sc->irq);
309 - tasklet_kill(&sc->intr_tq);
310 - tasklet_kill(&sc->bcon_tasklet);
311 + ath9k_hw_configpcipowersave(ah, true);
312
313 - ath9k_ps_restore(sc);
314 + spin_unlock_bh(&sc->sc_pcu_lock);
315
316 - sc->ps_idle = true;
317 - ath_radio_disable(sc, hw);
318 + ath9k_ps_restore(sc);
319
320 sc->sc_flags |= SC_OP_INVALID;
321 + sc->ps_idle = prev_idle;
322
323 mutex_unlock(&sc->mutex);
324
325 @@ -1627,8 +1588,9 @@ static int ath9k_config(struct ieee80211
326 struct ath_hw *ah = sc->sc_ah;
327 struct ath_common *common = ath9k_hw_common(ah);
328 struct ieee80211_conf *conf = &hw->conf;
329 - bool disable_radio = false;
330 + bool reset_channel = false;
331
332 + ath9k_ps_wakeup(sc);
333 mutex_lock(&sc->mutex);
334
335 /*
336 @@ -1639,13 +1601,14 @@ static int ath9k_config(struct ieee80211
337 */
338 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
339 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
340 - if (!sc->ps_idle) {
341 - ath_radio_enable(sc, hw);
342 - ath_dbg(common, ATH_DBG_CONFIG,
343 - "not-idle: enabling radio\n");
344 - } else {
345 - disable_radio = true;
346 - }
347 + if (sc->ps_idle)
348 + ath_cancel_work(sc);
349 + else
350 + /*
351 + * The chip needs a reset to properly wake up from
352 + * full sleep
353 + */
354 + reset_channel = ah->chip_fullsleep;
355 }
356
357 /*
358 @@ -1676,9 +1639,8 @@ static int ath9k_config(struct ieee80211
359 }
360 }
361
362 - if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
363 + if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
364 struct ieee80211_channel *curchan = hw->conf.channel;
365 - struct ath9k_channel old_chan;
366 int pos = curchan->hw_value;
367 int old_pos = -1;
368 unsigned long flags;
369 @@ -1704,11 +1666,8 @@ static int ath9k_config(struct ieee80211
370 * Preserve the current channel values, before updating
371 * the same channel
372 */
373 - if (old_pos == pos) {
374 - memcpy(&old_chan, &sc->sc_ah->channels[pos],
375 - sizeof(struct ath9k_channel));
376 - ah->curchan = &old_chan;
377 - }
378 + if (ah->curchan && (old_pos == pos))
379 + ath9k_hw_getnf(ah, ah->curchan);
380
381 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
382 curchan, conf->channel_type);
383 @@ -1752,18 +1711,12 @@ static int ath9k_config(struct ieee80211
384 ath_dbg(common, ATH_DBG_CONFIG,
385 "Set power: %d\n", conf->power_level);
386 sc->config.txpowlimit = 2 * conf->power_level;
387 - ath9k_ps_wakeup(sc);
388 ath9k_cmn_update_txpow(ah, sc->curtxpow,
389 sc->config.txpowlimit, &sc->curtxpow);
390 - ath9k_ps_restore(sc);
391 - }
392 -
393 - if (disable_radio) {
394 - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
395 - ath_radio_disable(sc, hw);
396 }
397
398 mutex_unlock(&sc->mutex);
399 + ath9k_ps_restore(sc);
400
401 return 0;
402 }
403 @@ -2331,9 +2284,6 @@ static void ath9k_flush(struct ieee80211
404 return;
405 }
406
407 - if (drop)
408 - timeout = 1;
409 -
410 for (j = 0; j < timeout; j++) {
411 bool npend = false;
412
413 @@ -2351,21 +2301,22 @@ static void ath9k_flush(struct ieee80211
414 }
415
416 if (!npend)
417 - goto out;
418 + break;
419 }
420
421 - ath9k_ps_wakeup(sc);
422 - spin_lock_bh(&sc->sc_pcu_lock);
423 - drain_txq = ath_drain_all_txq(sc, false);
424 - spin_unlock_bh(&sc->sc_pcu_lock);
425 + if (drop) {
426 + ath9k_ps_wakeup(sc);
427 + spin_lock_bh(&sc->sc_pcu_lock);
428 + drain_txq = ath_drain_all_txq(sc, false);
429 + spin_unlock_bh(&sc->sc_pcu_lock);
430
431 - if (!drain_txq)
432 - ath_reset(sc, false);
433 + if (!drain_txq)
434 + ath_reset(sc, false);
435
436 - ath9k_ps_restore(sc);
437 - ieee80211_wake_queues(hw);
438 + ath9k_ps_restore(sc);
439 + ieee80211_wake_queues(hw);
440 + }
441
442 -out:
443 ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
444 mutex_unlock(&sc->mutex);
445 }
446 --- a/drivers/net/wireless/ath/ath9k/pci.c
447 +++ b/drivers/net/wireless/ath/ath9k/pci.c
448 @@ -307,12 +307,11 @@ static int ath_pci_suspend(struct device
449 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
450 struct ath_softc *sc = hw->priv;
451
452 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
453 -
454 /* The device has to be moved to FULLSLEEP forcibly.
455 * Otherwise the chip never moved to full sleep,
456 * when no interface is up.
457 */
458 + ath9k_hw_disable(sc->sc_ah);
459 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
460
461 return 0;
462 @@ -334,22 +333,6 @@ static int ath_pci_resume(struct device
463 if ((val & 0x0000ff00) != 0)
464 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
465
466 - ath9k_ps_wakeup(sc);
467 - /* Enable LED */
468 - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
469 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
470 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
471 -
472 - /*
473 - * Reset key cache to sane defaults (all entries cleared) instead of
474 - * semi-random values after suspend/resume.
475 - */
476 - ath9k_cmn_init_crypto(sc->sc_ah);
477 - ath9k_ps_restore(sc);
478 -
479 - sc->ps_idle = true;
480 - ath_radio_disable(sc, hw);
481 -
482 return 0;
483 }
484
485 --- a/drivers/net/wireless/ath/ath9k/xmit.c
486 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
487 @@ -1954,7 +1954,7 @@ static void ath_tx_complete(struct ath_s
488 skb_pull(skb, padsize);
489 }
490
491 - if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) {
492 + if ((sc->ps_flags & PS_WAIT_FOR_TX_ACK) && !txq->axq_depth) {
493 sc->ps_flags &= ~PS_WAIT_FOR_TX_ACK;
494 ath_dbg(common, ATH_DBG_PS,
495 "Going back to sleep after having received TX status (0x%lx)\n",
496 --- a/include/linux/nl80211.h
497 +++ b/include/linux/nl80211.h
498 @@ -2785,9 +2785,11 @@ enum nl80211_ap_sme_features {
499 * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
500 * TX status to the socket error queue when requested with the
501 * socket option.
502 + * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
503 */
504 enum nl80211_feature_flags {
505 NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
506 + NL80211_FEATURE_HT_IBSS = 1 << 1,
507 };
508
509 /**
510 --- a/include/net/cfg80211.h
511 +++ b/include/net/cfg80211.h
512 @@ -1149,6 +1149,7 @@ struct cfg80211_ibss_params {
513 u8 *ssid;
514 u8 *bssid;
515 struct ieee80211_channel *channel;
516 + enum nl80211_channel_type channel_type;
517 u8 *ie;
518 u8 ssid_len, ie_len;
519 u16 beacon_interval;
520 @@ -3270,6 +3271,16 @@ void cfg80211_report_obss_beacon(struct
521 const u8 *frame, size_t len,
522 int freq, gfp_t gfp);
523
524 +/*
525 + * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
526 + * @wiphy: the wiphy
527 + * @chan: main channel
528 + * @channel_type: HT mode
529 + */
530 +int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
531 + struct ieee80211_channel *chan,
532 + enum nl80211_channel_type channel_type);
533 +
534 /* Logging, debugging and troubleshooting/diagnostic helpers. */
535
536 /* wiphy_printk helpers, similar to dev_printk */
537 --- a/net/mac80211/agg-rx.c
538 +++ b/net/mac80211/agg-rx.c
539 @@ -185,6 +185,10 @@ static void ieee80211_send_addba_resp(st
540 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
541 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
542 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
543 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
544 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
545 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
546 + memcpy(mgmt->bssid, da, ETH_ALEN);
547
548 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
549 IEEE80211_STYPE_ACTION);
550 --- a/net/mac80211/agg-tx.c
551 +++ b/net/mac80211/agg-tx.c
552 @@ -55,6 +55,8 @@
553 * @ampdu_action function will be called with the action
554 * %IEEE80211_AMPDU_TX_STOP. In this case, the call must not fail,
555 * and the driver must later call ieee80211_stop_tx_ba_cb_irqsafe().
556 + * Note that the sta can get destroyed before the BA tear down is
557 + * complete.
558 */
559
560 static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
561 @@ -79,10 +81,13 @@ static void ieee80211_send_addba_request
562 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
563 if (sdata->vif.type == NL80211_IFTYPE_AP ||
564 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
565 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
566 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
567 + sdata->vif.type == NL80211_IFTYPE_WDS)
568 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
569 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
570 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
571 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
572 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
573
574 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
575 IEEE80211_STYPE_ACTION);
576 @@ -319,6 +324,38 @@ ieee80211_wake_queue_agg(struct ieee8021
577 __release(agg_queue);
578 }
579
580 +/*
581 + * splice packets from the STA's pending to the local pending,
582 + * requires a call to ieee80211_agg_splice_finish later
583 + */
584 +static void __acquires(agg_queue)
585 +ieee80211_agg_splice_packets(struct ieee80211_local *local,
586 + struct tid_ampdu_tx *tid_tx, u16 tid)
587 +{
588 + int queue = ieee80211_ac_from_tid(tid);
589 + unsigned long flags;
590 +
591 + ieee80211_stop_queue_agg(local, tid);
592 +
593 + if (WARN(!tid_tx, "TID %d gone but expected when splicing aggregates"
594 + " from the pending queue\n", tid))
595 + return;
596 +
597 + if (!skb_queue_empty(&tid_tx->pending)) {
598 + spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
599 + /* copy over remaining packets */
600 + skb_queue_splice_tail_init(&tid_tx->pending,
601 + &local->pending[queue]);
602 + spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
603 + }
604 +}
605 +
606 +static void __releases(agg_queue)
607 +ieee80211_agg_splice_finish(struct ieee80211_local *local, u16 tid)
608 +{
609 + ieee80211_wake_queue_agg(local, tid);
610 +}
611 +
612 void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
613 {
614 struct tid_ampdu_tx *tid_tx;
615 @@ -330,19 +367,17 @@ void ieee80211_tx_ba_session_handle_star
616 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
617
618 /*
619 - * While we're asking the driver about the aggregation,
620 - * stop the AC queue so that we don't have to worry
621 - * about frames that came in while we were doing that,
622 - * which would require us to put them to the AC pending
623 - * afterwards which just makes the code more complex.
624 + * Start queuing up packets for this aggregation session.
625 + * We're going to release them once the driver is OK with
626 + * that.
627 */
628 - ieee80211_stop_queue_agg(local, tid);
629 -
630 clear_bit(HT_AGG_STATE_WANT_START, &tid_tx->state);
631
632 /*
633 - * make sure no packets are being processed to get
634 - * valid starting sequence number
635 + * Make sure no packets are being processed. This ensures that
636 + * we have a valid starting sequence number and that in-flight
637 + * packets have been flushed out and no packets for this TID
638 + * will go into the driver during the ampdu_action call.
639 */
640 synchronize_net();
641
642 @@ -356,10 +391,11 @@ void ieee80211_tx_ba_session_handle_star
643 " tid %d\n", tid);
644 #endif
645 spin_lock_bh(&sta->lock);
646 + ieee80211_agg_splice_packets(local, tid_tx, tid);
647 ieee80211_assign_tid_tx(sta, tid, NULL);
648 + ieee80211_agg_splice_finish(local, tid);
649 spin_unlock_bh(&sta->lock);
650
651 - ieee80211_wake_queue_agg(local, tid);
652 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
653 kfree_rcu(tid_tx, rcu_head);
654 #else
655 @@ -368,9 +404,6 @@ void ieee80211_tx_ba_session_handle_star
656 return;
657 }
658
659 - /* we can take packets again now */
660 - ieee80211_wake_queue_agg(local, tid);
661 -
662 /* activate the timer for the recipient's addBA response */
663 mod_timer(&tid_tx->addba_resp_timer, jiffies + ADDBA_RESP_INTERVAL);
664 #ifdef CONFIG_MAC80211_HT_DEBUG
665 @@ -437,7 +470,9 @@ int ieee80211_start_tx_ba_session(struct
666 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
667 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
668 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
669 - sdata->vif.type != NL80211_IFTYPE_AP)
670 + sdata->vif.type != NL80211_IFTYPE_AP &&
671 + sdata->vif.type != NL80211_IFTYPE_WDS &&
672 + sdata->vif.type != NL80211_IFTYPE_ADHOC)
673 return -EINVAL;
674
675 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
676 @@ -448,6 +483,27 @@ int ieee80211_start_tx_ba_session(struct
677 return -EINVAL;
678 }
679
680 + /*
681 + * 802.11n-2009 11.5.1.1: If the initiating STA is an HT STA, is a
682 + * member of an IBSS, and has no other existing Block Ack agreement
683 + * with the recipient STA, then the initiating STA shall transmit a
684 + * Probe Request frame to the recipient STA and shall not transmit an
685 + * ADDBA Request frame unless it receives a Probe Response frame
686 + * from the recipient within dot11ADDBAFailureTimeout.
687 + *
688 + * The probe request mechanism for ADDBA is currently not implemented,
689 + * but we only build up Block Ack session with HT STAs. This information
690 + * is set when we receive a bss info from a probe response or a beacon.
691 + */
692 + if (sta->sdata->vif.type == NL80211_IFTYPE_ADHOC &&
693 + !sta->sta.ht_cap.ht_supported) {
694 +#ifdef CONFIG_MAC80211_HT_DEBUG
695 + printk(KERN_DEBUG "BA request denied - IBSS STA %pM"
696 + "does not advertise HT support\n", pubsta->addr);
697 +#endif /* CONFIG_MAC80211_HT_DEBUG */
698 + return -EINVAL;
699 + }
700 +
701 spin_lock_bh(&sta->lock);
702
703 /* we have tried too many times, receiver does not want A-MPDU */
704 @@ -508,38 +564,6 @@ int ieee80211_start_tx_ba_session(struct
705 }
706 EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
707
708 -/*
709 - * splice packets from the STA's pending to the local pending,
710 - * requires a call to ieee80211_agg_splice_finish later
711 - */
712 -static void __acquires(agg_queue)
713 -ieee80211_agg_splice_packets(struct ieee80211_local *local,
714 - struct tid_ampdu_tx *tid_tx, u16 tid)
715 -{
716 - int queue = ieee80211_ac_from_tid(tid);
717 - unsigned long flags;
718 -
719 - ieee80211_stop_queue_agg(local, tid);
720 -
721 - if (WARN(!tid_tx, "TID %d gone but expected when splicing aggregates"
722 - " from the pending queue\n", tid))
723 - return;
724 -
725 - if (!skb_queue_empty(&tid_tx->pending)) {
726 - spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
727 - /* copy over remaining packets */
728 - skb_queue_splice_tail_init(&tid_tx->pending,
729 - &local->pending[queue]);
730 - spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
731 - }
732 -}
733 -
734 -static void __releases(agg_queue)
735 -ieee80211_agg_splice_finish(struct ieee80211_local *local, u16 tid)
736 -{
737 - ieee80211_wake_queue_agg(local, tid);
738 -}
739 -
740 static void ieee80211_agg_tx_operational(struct ieee80211_local *local,
741 struct sta_info *sta, u16 tid)
742 {
743 --- a/net/mac80211/debugfs_sta.c
744 +++ b/net/mac80211/debugfs_sta.c
745 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
746 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
747
748 int res = scnprintf(buf, sizeof(buf),
749 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
750 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
751 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
752 TEST(PS_DRIVER), TEST(AUTHORIZED),
753 TEST(SHORT_PREAMBLE),
754 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
755 + TEST(WME), TEST(CLEAR_PS_FILT),
756 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
757 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
758 TEST(TDLS_PEER_AUTH));
759 --- a/net/mac80211/ht.c
760 +++ b/net/mac80211/ht.c
761 @@ -47,7 +47,9 @@ void ieee80211_apply_htcap_overrides(str
762 int i;
763
764 if (sdata->vif.type != NL80211_IFTYPE_STATION) {
765 - WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
766 + /* AP interfaces call this code when adding new stations,
767 + * so just silently ignore non station interfaces.
768 + */
769 return;
770 }
771
772 @@ -282,6 +284,8 @@ void ieee80211_send_delba(struct ieee802
773 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
774 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
775 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
776 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
777 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
778
779 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
780 IEEE80211_STYPE_ACTION);
781 --- a/net/mac80211/ibss.c
782 +++ b/net/mac80211/ibss.c
783 @@ -77,6 +77,7 @@ static void __ieee80211_sta_join_ibss(st
784 struct cfg80211_bss *bss;
785 u32 bss_change;
786 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
787 + enum nl80211_channel_type channel_type;
788
789 lockdep_assert_held(&ifibss->mtx);
790
791 @@ -105,8 +106,16 @@ static void __ieee80211_sta_join_ibss(st
792
793 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
794
795 - local->oper_channel = chan;
796 - WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT));
797 + channel_type = ifibss->channel_type;
798 + if (channel_type > NL80211_CHAN_HT20 &&
799 + !cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
800 + channel_type = NL80211_CHAN_HT20;
801 + if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
802 + /* can only fail due to HT40+/- mismatch */
803 + channel_type = NL80211_CHAN_HT20;
804 + WARN_ON(!ieee80211_set_channel_type(local, sdata,
805 + NL80211_CHAN_HT20));
806 + }
807 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
808
809 sband = local->hw.wiphy->bands[chan->band];
810 @@ -172,6 +181,19 @@ static void __ieee80211_sta_join_ibss(st
811 memcpy(skb_put(skb, ifibss->ie_len),
812 ifibss->ie, ifibss->ie_len);
813
814 + /* add HT capability and information IEs */
815 + if (channel_type && sband->ht_cap.ht_supported) {
816 + pos = skb_put(skb, 4 +
817 + sizeof(struct ieee80211_ht_cap) +
818 + sizeof(struct ieee80211_ht_info));
819 + pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap,
820 + sband->ht_cap.cap);
821 + pos = ieee80211_ie_build_ht_info(pos,
822 + &sband->ht_cap,
823 + chan,
824 + channel_type);
825 + }
826 +
827 if (local->hw.queues >= 4) {
828 pos = skb_put(skb, 9);
829 *pos++ = WLAN_EID_VENDOR_SPECIFIC;
830 @@ -195,6 +217,7 @@ static void __ieee80211_sta_join_ibss(st
831 bss_change |= BSS_CHANGED_BEACON;
832 bss_change |= BSS_CHANGED_BEACON_ENABLED;
833 bss_change |= BSS_CHANGED_BASIC_RATES;
834 + bss_change |= BSS_CHANGED_HT;
835 bss_change |= BSS_CHANGED_IBSS;
836 sdata->vif.bss_conf.ibss_joined = true;
837 ieee80211_bss_info_change_notify(sdata, bss_change);
838 @@ -268,6 +291,8 @@ static void ieee80211_rx_bss_info(struct
839 u64 beacon_timestamp, rx_timestamp;
840 u32 supp_rates = 0;
841 enum ieee80211_band band = rx_status->band;
842 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
843 + bool rates_updated = false;
844
845 if (elems->ds_params && elems->ds_params_len == 1)
846 freq = ieee80211_channel_to_frequency(elems->ds_params[0],
847 @@ -307,7 +332,7 @@ static void ieee80211_rx_bss_info(struct
848 prev_rates,
849 sta->sta.supp_rates[band]);
850 #endif
851 - rate_control_rate_init(sta);
852 + rates_updated = true;
853 }
854 } else
855 sta = ieee80211_ibss_add_sta(sdata, mgmt->bssid,
856 @@ -318,6 +343,39 @@ static void ieee80211_rx_bss_info(struct
857 if (sta && elems->wmm_info)
858 set_sta_flag(sta, WLAN_STA_WME);
859
860 + if (sta && elems->ht_info_elem && elems->ht_cap_elem &&
861 + sdata->u.ibss.channel_type != NL80211_CHAN_NO_HT) {
862 + /* we both use HT */
863 + struct ieee80211_sta_ht_cap sta_ht_cap_new;
864 + enum nl80211_channel_type channel_type =
865 + ieee80211_ht_info_to_channel_type(
866 + elems->ht_info_elem);
867 +
868 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
869 + elems->ht_cap_elem,
870 + &sta_ht_cap_new);
871 +
872 + /*
873 + * fall back to HT20 if we don't use or use
874 + * the other extension channel
875 + */
876 + if (!(channel_type == NL80211_CHAN_HT40MINUS ||
877 + channel_type == NL80211_CHAN_HT40PLUS) ||
878 + channel_type != sdata->u.ibss.channel_type)
879 + sta_ht_cap_new.cap &=
880 + ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
881 +
882 + if (memcmp(&sta->sta.ht_cap, &sta_ht_cap_new,
883 + sizeof(sta_ht_cap_new))) {
884 + memcpy(&sta->sta.ht_cap, &sta_ht_cap_new,
885 + sizeof(sta_ht_cap_new));
886 + rates_updated = true;
887 + }
888 + }
889 +
890 + if (sta && rates_updated)
891 + rate_control_rate_init(sta);
892 +
893 rcu_read_unlock();
894 }
895
896 @@ -896,12 +954,18 @@ int ieee80211_ibss_join(struct ieee80211
897 struct cfg80211_ibss_params *params)
898 {
899 struct sk_buff *skb;
900 + u32 changed = 0;
901
902 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom +
903 - 36 /* bitrates */ +
904 - 34 /* SSID */ +
905 - 3 /* DS params */ +
906 - 4 /* IBSS params */ +
907 + sizeof(struct ieee80211_hdr_3addr) +
908 + 12 /* struct ieee80211_mgmt.u.beacon */ +
909 + 2 + IEEE80211_MAX_SSID_LEN /* max SSID */ +
910 + 2 + 8 /* max Supported Rates */ +
911 + 3 /* max DS params */ +
912 + 4 /* IBSS params */ +
913 + 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
914 + 2 + sizeof(struct ieee80211_ht_cap) +
915 + 2 + sizeof(struct ieee80211_ht_info) +
916 params->ie_len);
917 if (!skb)
918 return -ENOMEM;
919 @@ -922,13 +986,15 @@ int ieee80211_ibss_join(struct ieee80211
920 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
921
922 sdata->u.ibss.channel = params->channel;
923 + sdata->u.ibss.channel_type = params->channel_type;
924 sdata->u.ibss.fixed_channel = params->channel_fixed;
925
926 /* fix ourselves to that channel now already */
927 if (params->channel_fixed) {
928 sdata->local->oper_channel = params->channel;
929 - WARN_ON(!ieee80211_set_channel_type(sdata->local, sdata,
930 - NL80211_CHAN_NO_HT));
931 + if (!ieee80211_set_channel_type(sdata->local, sdata,
932 + params->channel_type))
933 + return -EINVAL;
934 }
935
936 if (params->ie) {
937 @@ -951,6 +1017,23 @@ int ieee80211_ibss_join(struct ieee80211
938 ieee80211_recalc_idle(sdata->local);
939 mutex_unlock(&sdata->local->mtx);
940
941 + /*
942 + * 802.11n-2009 9.13.3.1: In an IBSS, the HT Protection field is
943 + * reserved, but an HT STA shall protect HT transmissions as though
944 + * the HT Protection field were set to non-HT mixed mode.
945 + *
946 + * In an IBSS, the RIFS Mode field of the HT Operation element is
947 + * also reserved, but an HT STA shall operate as though this field
948 + * were set to 1.
949 + */
950 +
951 + sdata->vif.bss_conf.ht_operation_mode |=
952 + IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
953 + | IEEE80211_HT_PARAM_RIFS_MODE;
954 +
955 + changed |= BSS_CHANGED_HT;
956 + ieee80211_bss_info_change_notify(sdata, changed);
957 +
958 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
959
960 return 0;
961 --- a/net/mac80211/ieee80211_i.h
962 +++ b/net/mac80211/ieee80211_i.h
963 @@ -474,6 +474,7 @@ struct ieee80211_if_ibss {
964 u8 ssid_len, ie_len;
965 u8 *ie;
966 struct ieee80211_channel *channel;
967 + enum nl80211_channel_type channel_type;
968
969 unsigned long ibss_join_req;
970 /* probe response/beacon for IBSS */
971 --- a/net/mac80211/iface.c
972 +++ b/net/mac80211/iface.c
973 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
974 {
975 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
976 struct ieee80211_local *local = sdata->local;
977 - struct sta_info *sta;
978 u32 changed = 0;
979 int res;
980 u32 hw_reconf_flags = 0;
981 @@ -309,27 +308,6 @@ static int ieee80211_do_open(struct net_
982
983 set_bit(SDATA_STATE_RUNNING, &sdata->state);
984
985 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
986 - /* Create STA entry for the WDS peer */
987 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
988 - GFP_KERNEL);
989 - if (!sta) {
990 - res = -ENOMEM;
991 - goto err_del_interface;
992 - }
993 -
994 - /* no atomic bitop required since STA is not live yet */
995 - set_sta_flag(sta, WLAN_STA_AUTHORIZED);
996 -
997 - res = sta_info_insert(sta);
998 - if (res) {
999 - /* STA has been freed */
1000 - goto err_del_interface;
1001 - }
1002 -
1003 - rate_control_rate_init(sta);
1004 - }
1005 -
1006 /*
1007 * set_multicast_list will be invoked by the networking core
1008 * which will check whether any increments here were done in
1009 @@ -356,8 +334,7 @@ static int ieee80211_do_open(struct net_
1010 netif_tx_start_all_queues(dev);
1011
1012 return 0;
1013 - err_del_interface:
1014 - drv_remove_interface(local, sdata);
1015 +
1016 err_stop:
1017 if (!local->open_count)
1018 drv_stop(local);
1019 @@ -719,6 +696,70 @@ static void ieee80211_if_setup(struct ne
1020 dev->destructor = free_netdev;
1021 }
1022
1023 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1024 + struct sk_buff *skb)
1025 +{
1026 + struct ieee80211_local *local = sdata->local;
1027 + struct ieee80211_rx_status *rx_status;
1028 + struct ieee802_11_elems elems;
1029 + struct ieee80211_mgmt *mgmt;
1030 + struct sta_info *sta;
1031 + size_t baselen;
1032 + u32 rates = 0;
1033 + u16 stype;
1034 + bool new = false;
1035 + enum ieee80211_band band = local->hw.conf.channel->band;
1036 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
1037 +
1038 + rx_status = IEEE80211_SKB_RXCB(skb);
1039 + mgmt = (struct ieee80211_mgmt *) skb->data;
1040 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
1041 +
1042 + if (stype != IEEE80211_STYPE_BEACON)
1043 + return;
1044 +
1045 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1046 + if (baselen > skb->len)
1047 + return;
1048 +
1049 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1050 + skb->len - baselen, &elems);
1051 +
1052 + rates = ieee80211_sta_get_rates(local, &elems, band);
1053 +
1054 + rcu_read_lock();
1055 +
1056 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1057 +
1058 + if (!sta) {
1059 + rcu_read_unlock();
1060 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1061 + GFP_KERNEL);
1062 + if (!sta)
1063 + return;
1064 +
1065 + new = true;
1066 + }
1067 +
1068 + sta->last_rx = jiffies;
1069 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
1070 +
1071 + if (elems.ht_cap_elem)
1072 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1073 + elems.ht_cap_elem, &sta->sta.ht_cap);
1074 +
1075 + if (elems.wmm_param)
1076 + set_sta_flag(sta, WLAN_STA_WME);
1077 +
1078 + if (new) {
1079 + set_sta_flag(sta, WLAN_STA_AUTHORIZED);
1080 + rate_control_rate_init(sta);
1081 + sta_info_insert_rcu(sta);
1082 + }
1083 +
1084 + rcu_read_unlock();
1085 +}
1086 +
1087 static void ieee80211_iface_work(struct work_struct *work)
1088 {
1089 struct ieee80211_sub_if_data *sdata =
1090 @@ -823,6 +864,9 @@ static void ieee80211_iface_work(struct
1091 break;
1092 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1093 break;
1094 + case NL80211_IFTYPE_WDS:
1095 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1096 + break;
1097 default:
1098 WARN(1, "frame for unexpected interface type");
1099 break;
1100 --- a/net/mac80211/main.c
1101 +++ b/net/mac80211/main.c
1102 @@ -574,7 +574,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(
1103 WIPHY_FLAG_OFFCHAN_TX |
1104 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
1105
1106 - wiphy->features = NL80211_FEATURE_SK_TX_STATUS;
1107 + wiphy->features = NL80211_FEATURE_SK_TX_STATUS |
1108 + NL80211_FEATURE_HT_IBSS;
1109
1110 if (!ops->set_key)
1111 wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
1112 --- a/net/mac80211/rx.c
1113 +++ b/net/mac80211/rx.c
1114 @@ -2237,7 +2237,9 @@ ieee80211_rx_h_action(struct ieee80211_r
1115 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
1116 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1117 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1118 - sdata->vif.type != NL80211_IFTYPE_AP)
1119 + sdata->vif.type != NL80211_IFTYPE_AP &&
1120 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1121 + sdata->vif.type != NL80211_IFTYPE_ADHOC)
1122 break;
1123
1124 /* verify action_code is present */
1125 @@ -2452,13 +2454,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
1126
1127 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
1128 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
1129 - sdata->vif.type != NL80211_IFTYPE_STATION)
1130 + sdata->vif.type != NL80211_IFTYPE_STATION &&
1131 + sdata->vif.type != NL80211_IFTYPE_WDS)
1132 return RX_DROP_MONITOR;
1133
1134 switch (stype) {
1135 case cpu_to_le16(IEEE80211_STYPE_BEACON):
1136 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
1137 - /* process for all: mesh, mlme, ibss */
1138 + /* process for all: mesh, mlme, ibss, wds */
1139 break;
1140 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
1141 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
1142 @@ -2796,19 +2799,32 @@ static int prepare_for_handlers(struct i
1143 return 0;
1144 } else if (!ieee80211_bssid_match(bssid,
1145 sdata->vif.addr)) {
1146 + /*
1147 + * Accept public action frames even when the
1148 + * BSSID doesn't match, this is used for P2P
1149 + * and location updates. Note that mac80211
1150 + * itself never looks at these frames.
1151 + */
1152 if (!(status->rx_flags & IEEE80211_RX_IN_SCAN) &&
1153 - !ieee80211_is_beacon(hdr->frame_control) &&
1154 - !(ieee80211_is_action(hdr->frame_control) &&
1155 - sdata->vif.p2p))
1156 + ieee80211_is_public_action(hdr, skb->len))
1157 + return 1;
1158 + if (!(status->rx_flags & IEEE80211_RX_IN_SCAN) &&
1159 + !ieee80211_is_beacon(hdr->frame_control))
1160 return 0;
1161 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
1162 }
1163 break;
1164 case NL80211_IFTYPE_WDS:
1165 - if (bssid || !ieee80211_is_data(hdr->frame_control))
1166 - return 0;
1167 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
1168 return 0;
1169 +
1170 + if (ieee80211_is_data(hdr->frame_control) ||
1171 + ieee80211_is_action(hdr->frame_control)) {
1172 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
1173 + return 0;
1174 + } else if (!ieee80211_is_beacon(hdr->frame_control))
1175 + return 0;
1176 +
1177 break;
1178 default:
1179 /* should never get here */
1180 --- a/net/mac80211/sta_info.h
1181 +++ b/net/mac80211/sta_info.h
1182 @@ -31,7 +31,6 @@
1183 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
1184 * frames.
1185 * @WLAN_STA_WME: Station is a QoS-STA.
1186 - * @WLAN_STA_WDS: Station is one of our WDS peers.
1187 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
1188 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
1189 * frame to this station is transmitted.
1190 @@ -60,7 +59,6 @@ enum ieee80211_sta_info_flags {
1191 WLAN_STA_AUTHORIZED,
1192 WLAN_STA_SHORT_PREAMBLE,
1193 WLAN_STA_WME,
1194 - WLAN_STA_WDS,
1195 WLAN_STA_CLEAR_PS_FILT,
1196 WLAN_STA_MFP,
1197 WLAN_STA_BLOCK_BA,
1198 --- a/net/mac80211/util.c
1199 +++ b/net/mac80211/util.c
1200 @@ -1612,6 +1612,11 @@ u8 *ieee80211_ie_build_ht_info(u8 *pos,
1201 }
1202 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1203 ht_info->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
1204 +
1205 + /*
1206 + * Note: According to 802.11n-2009 9.13.3.1, HT Protection field and
1207 + * RIFS Mode are reserved in IBSS mode, therefore keep them at 0
1208 + */
1209 ht_info->operation_mode = 0x0000;
1210 ht_info->stbc_param = 0x0000;
1211
1212 --- a/net/wireless/chan.c
1213 +++ b/net/wireless/chan.c
1214 @@ -6,6 +6,7 @@
1215 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
1216 */
1217
1218 +#include <linux/export.h>
1219 #include <net/cfg80211.h>
1220 #include "core.h"
1221
1222 @@ -44,9 +45,9 @@ rdev_freq_to_chan(struct cfg80211_regist
1223 return chan;
1224 }
1225
1226 -static bool can_beacon_sec_chan(struct wiphy *wiphy,
1227 - struct ieee80211_channel *chan,
1228 - enum nl80211_channel_type channel_type)
1229 +int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
1230 + struct ieee80211_channel *chan,
1231 + enum nl80211_channel_type channel_type)
1232 {
1233 struct ieee80211_channel *sec_chan;
1234 int diff;
1235 @@ -75,6 +76,7 @@ static bool can_beacon_sec_chan(struct w
1236
1237 return true;
1238 }
1239 +EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan);
1240
1241 int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
1242 struct wireless_dev *wdev, int freq,
1243 @@ -109,8 +111,8 @@ int cfg80211_set_freq(struct cfg80211_re
1244 switch (channel_type) {
1245 case NL80211_CHAN_HT40PLUS:
1246 case NL80211_CHAN_HT40MINUS:
1247 - if (!can_beacon_sec_chan(&rdev->wiphy, chan,
1248 - channel_type)) {
1249 + if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan,
1250 + channel_type)) {
1251 printk(KERN_DEBUG
1252 "cfg80211: Secondary channel not "
1253 "allowed to initiate communication\n");
1254 --- a/net/wireless/nl80211.c
1255 +++ b/net/wireless/nl80211.c
1256 @@ -4684,13 +4684,41 @@ static int nl80211_join_ibss(struct sk_b
1257 ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
1258 }
1259
1260 - ibss.channel = ieee80211_get_channel(wiphy,
1261 - nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
1262 + if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
1263 + enum nl80211_channel_type channel_type;
1264 +
1265 + channel_type = nla_get_u32(
1266 + info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
1267 + if (channel_type != NL80211_CHAN_NO_HT &&
1268 + channel_type != NL80211_CHAN_HT20 &&
1269 + channel_type != NL80211_CHAN_HT40MINUS &&
1270 + channel_type != NL80211_CHAN_HT40PLUS)
1271 + return -EINVAL;
1272 +
1273 + if (channel_type != NL80211_CHAN_NO_HT &&
1274 + !(wiphy->features & NL80211_FEATURE_HT_IBSS))
1275 + return -EINVAL;
1276 +
1277 + ibss.channel_type = channel_type;
1278 + } else {
1279 + ibss.channel_type = NL80211_CHAN_NO_HT;
1280 + }
1281 +
1282 + ibss.channel = rdev_freq_to_chan(rdev,
1283 + nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
1284 + ibss.channel_type);
1285 if (!ibss.channel ||
1286 ibss.channel->flags & IEEE80211_CHAN_NO_IBSS ||
1287 ibss.channel->flags & IEEE80211_CHAN_DISABLED)
1288 return -EINVAL;
1289
1290 + /* Both channels should be able to initiate communication */
1291 + if ((ibss.channel_type == NL80211_CHAN_HT40PLUS ||
1292 + ibss.channel_type == NL80211_CHAN_HT40MINUS) &&
1293 + !cfg80211_can_beacon_sec_chan(&rdev->wiphy, ibss.channel,
1294 + ibss.channel_type))
1295 + return -EINVAL;
1296 +
1297 ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED];
1298 ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
1299
1300 --- a/include/linux/ieee80211.h
1301 +++ b/include/linux/ieee80211.h
1302 @@ -1695,6 +1695,23 @@ static inline bool ieee80211_is_robust_m
1303 }
1304
1305 /**
1306 + * ieee80211_is_public_action - check if frame is a public action frame
1307 + * @hdr: the frame
1308 + * @len: length of the frame
1309 + */
1310 +static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
1311 + size_t len)
1312 +{
1313 + struct ieee80211_mgmt *mgmt = (void *)hdr;
1314 +
1315 + if (len < 25)
1316 + return false;
1317 + if (!ieee80211_is_action(hdr->frame_control))
1318 + return false;
1319 + return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
1320 +}
1321 +
1322 +/**
1323 * ieee80211_fhss_chan_to_freq - get channel frequency
1324 * @channel: the FHSS channel
1325 *
1326 --- a/net/mac80211/tx.c
1327 +++ b/net/mac80211/tx.c
1328 @@ -1332,8 +1332,11 @@ static int invoke_tx_handlers(struct iee
1329 if (!(tx->local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL))
1330 CALL_TXH(ieee80211_tx_h_rate_ctrl);
1331
1332 - if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION))
1333 + if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) {
1334 + __skb_queue_tail(&tx->skbs, tx->skb);
1335 + tx->skb = NULL;
1336 goto txh_done;
1337 + }
1338
1339 CALL_TXH(ieee80211_tx_h_michael_mic_add);
1340 CALL_TXH(ieee80211_tx_h_sequence);
1341 --- a/net/mac80211/sta_info.c
1342 +++ b/net/mac80211/sta_info.c
1343 @@ -851,6 +851,7 @@ static int __must_check __sta_info_destr
1344 struct ieee80211_sub_if_data *sdata;
1345 unsigned long flags;
1346 int ret, i, ac;
1347 + struct tid_ampdu_tx *tid_tx;
1348
1349 might_sleep();
1350
1351 @@ -949,6 +950,30 @@ static int __must_check __sta_info_destr
1352 }
1353 #endif
1354
1355 + /* There could be some memory leaks because of ampdu tx pending queue
1356 + * not being freed before destroying the station info.
1357 + *
1358 + * Make sure that such queues are purged before freeing the station
1359 + * info.
1360 + * TODO: We have to somehow postpone the full destruction
1361 + * until the aggregation stop completes. Refer
1362 + * http://thread.gmane.org/gmane.linux.kernel.wireless.general/81936
1363 + */
1364 + for (i = 0; i < STA_TID_NUM; i++) {
1365 + if (!sta->ampdu_mlme.tid_tx[i])
1366 + continue;
1367 + tid_tx = sta->ampdu_mlme.tid_tx[i];
1368 + if (skb_queue_len(&tid_tx->pending)) {
1369 +#ifdef CONFIG_MAC80211_HT_DEBUG
1370 + wiphy_debug(local->hw.wiphy, "TX A-MPDU purging %d "
1371 + "packets for tid=%d\n",
1372 + skb_queue_len(&tid_tx->pending), i);
1373 +#endif /* CONFIG_MAC80211_HT_DEBUG */
1374 + __skb_queue_purge(&tid_tx->pending);
1375 + }
1376 + kfree_rcu(tid_tx, rcu_head);
1377 + }
1378 +
1379 __sta_info_free(local, sta);
1380
1381 return 0;
1382 --- a/drivers/net/wireless/ath/ath9k/calib.c
1383 +++ b/drivers/net/wireless/ath/ath9k/calib.c
1384 @@ -402,6 +402,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, s
1385 ah->noise = ath9k_hw_getchan_noise(ah, chan);
1386 return true;
1387 }
1388 +EXPORT_SYMBOL(ath9k_hw_getnf);
1389
1390 void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
1391 struct ath9k_channel *chan)