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
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]);
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
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]);
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
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) {
33 common->ani.checkani_timer = timestamp;
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
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);
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;
50 + /* disable ANI for 9340 */
51 + if (AR_SREV_9340(ah))
52 + ah->config.enable_ani = false;
54 ath9k_hw_init_mode_regs(ah);
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)
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);
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;
77 @@ -332,7 +332,8 @@ static int ath_reset_internal(struct ath
81 - if (fastcc && !ath9k_hw_check_alive(ah))
82 + if (fastcc && (ah->chip_fullsleep ||
83 + !ath9k_hw_check_alive(ah)))
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) {
91 - ath_dbg(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
92 common->ani.longcal_timer = timestamp;
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) {
99 - ath_dbg(common, ATH_DBG_ANI,
100 - "shortcal @%lu\n", jiffies);
101 common->ani.shortcal_timer = timestamp;
102 common->ani.resetcal_timer = timestamp;
104 @@ -584,8 +582,9 @@ void ath_ani_calibrate(unsigned long dat
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) {
114 common->ani.checkani_timer = timestamp;
116 @@ -605,6 +604,11 @@ void ath_ani_calibrate(unsigned long dat
117 ah->rxchainmask, longcal);
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");
125 ath9k_ps_restore(sc);
128 @@ -886,82 +890,6 @@ chip_reset:
132 -static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
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;
139 - ath9k_ps_wakeup(sc);
140 - spin_lock_bh(&sc->sc_pcu_lock);
141 - atomic_set(&ah->intr_ref_cnt, -1);
143 - ath9k_hw_configpcipowersave(ah, false);
146 - ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah);
148 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
151 - "Unable to reset channel (%u MHz), reset status %d\n",
152 - channel->center_freq, r);
155 - ath_complete_reset(sc, true);
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);
162 - spin_unlock_bh(&sc->sc_pcu_lock);
164 - ath9k_ps_restore(sc);
167 -void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
169 - struct ath_hw *ah = sc->sc_ah;
170 - struct ieee80211_channel *channel = hw->conf.channel;
173 - ath9k_ps_wakeup(sc);
175 - ath_cancel_work(sc);
177 - spin_lock_bh(&sc->sc_pcu_lock);
180 - * Keep the LED on when the radio is disabled
181 - * during idle unassociated state.
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);
188 - ath_prepare_reset(sc, false, true);
191 - ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
193 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
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);
200 - ath9k_hw_phy_disable(ah);
202 - ath9k_hw_configpcipowersave(ah, true);
204 - spin_unlock_bh(&sc->sc_pcu_lock);
205 - ath9k_ps_restore(sc);
208 static int ath_reset(struct ath_softc *sc, bool retry_tx)
211 @@ -1097,6 +1025,9 @@ static int ath9k_start(struct ieee80211_
212 * and then setup of the interrupt mask.
214 spin_lock_bh(&sc->sc_pcu_lock);
216 + atomic_set(&ah->intr_ref_cnt, -1);
218 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
221 @@ -1138,6 +1069,18 @@ static int ath9k_start(struct ieee80211_
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);
232 + * Reset key cache to sane defaults (all entries cleared) instead of
233 + * semi-random values after suspend/resume.
235 + ath9k_cmn_init_crypto(sc->sc_ah);
237 spin_unlock_bh(&sc->sc_pcu_lock);
239 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
240 @@ -1183,6 +1126,13 @@ static void ath9k_tx(struct ieee80211_hw
245 + * Cannot tx while the hardware is in full sleep, it first needs a full
246 + * chip reset to recover from that
248 + if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP))
251 if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
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);
260 mutex_lock(&sc->mutex);
262 @@ -1259,35 +1210,45 @@ static void ath9k_stop(struct ieee80211_
263 * before setting the invalid flag. */
264 ath9k_hw_disable_interrupts(ah);
266 - if (!(sc->sc_flags & SC_OP_INVALID)) {
267 - ath_drain_all_txq(sc, false);
269 - ath9k_hw_phy_disable(ah);
271 - sc->rx.rxlink = NULL;
272 + spin_unlock_bh(&sc->sc_pcu_lock);
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);
280 + prev_idle = sc->ps_idle;
281 + sc->ps_idle = true;
283 + spin_lock_bh(&sc->sc_pcu_lock);
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);
290 + ath_prepare_reset(sc, false, true);
293 dev_kfree_skb_any(sc->rx.frag);
297 - /* disable HAL and put h/w to sleep */
298 - ath9k_hw_disable(ah);
300 + ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
302 - spin_unlock_bh(&sc->sc_pcu_lock);
303 + ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
304 + ath9k_hw_phy_disable(ah);
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);
313 - ath9k_ps_restore(sc);
314 + spin_unlock_bh(&sc->sc_pcu_lock);
316 - sc->ps_idle = true;
317 - ath_radio_disable(sc, hw);
318 + ath9k_ps_restore(sc);
320 sc->sc_flags |= SC_OP_INVALID;
321 + sc->ps_idle = prev_idle;
323 mutex_unlock(&sc->mutex);
325 @@ -1627,8 +1588,8 @@ 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;
331 + ath9k_ps_wakeup(sc);
332 mutex_lock(&sc->mutex);
335 @@ -1639,13 +1600,8 @@ static int ath9k_config(struct ieee80211
337 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
338 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
339 - if (!sc->ps_idle) {
340 - ath_radio_enable(sc, hw);
341 - ath_dbg(common, ATH_DBG_CONFIG,
342 - "not-idle: enabling radio\n");
344 - disable_radio = true;
347 + ath_cancel_work(sc);
351 @@ -1678,7 +1634,6 @@ static int ath9k_config(struct ieee80211
353 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
354 struct ieee80211_channel *curchan = hw->conf.channel;
355 - struct ath9k_channel old_chan;
356 int pos = curchan->hw_value;
359 @@ -1704,11 +1659,8 @@ static int ath9k_config(struct ieee80211
360 * Preserve the current channel values, before updating
363 - if (old_pos == pos) {
364 - memcpy(&old_chan, &sc->sc_ah->channels[pos],
365 - sizeof(struct ath9k_channel));
366 - ah->curchan = &old_chan;
368 + if (ah->curchan && (old_pos == pos))
369 + ath9k_hw_getnf(ah, ah->curchan);
371 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
372 curchan, conf->channel_type);
373 @@ -1752,18 +1704,12 @@ static int ath9k_config(struct ieee80211
374 ath_dbg(common, ATH_DBG_CONFIG,
375 "Set power: %d\n", conf->power_level);
376 sc->config.txpowlimit = 2 * conf->power_level;
377 - ath9k_ps_wakeup(sc);
378 ath9k_cmn_update_txpow(ah, sc->curtxpow,
379 sc->config.txpowlimit, &sc->curtxpow);
380 - ath9k_ps_restore(sc);
383 - if (disable_radio) {
384 - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
385 - ath_radio_disable(sc, hw);
388 mutex_unlock(&sc->mutex);
389 + ath9k_ps_restore(sc);
393 @@ -2331,9 +2277,6 @@ static void ath9k_flush(struct ieee80211
400 for (j = 0; j < timeout; j++) {
403 @@ -2351,21 +2294,22 @@ static void ath9k_flush(struct ieee80211
411 - ath9k_ps_wakeup(sc);
412 - spin_lock_bh(&sc->sc_pcu_lock);
413 - drain_txq = ath_drain_all_txq(sc, false);
414 - spin_unlock_bh(&sc->sc_pcu_lock);
416 + ath9k_ps_wakeup(sc);
417 + spin_lock_bh(&sc->sc_pcu_lock);
418 + drain_txq = ath_drain_all_txq(sc, false);
419 + spin_unlock_bh(&sc->sc_pcu_lock);
422 - ath_reset(sc, false);
424 + ath_reset(sc, false);
426 - ath9k_ps_restore(sc);
427 - ieee80211_wake_queues(hw);
428 + ath9k_ps_restore(sc);
429 + ieee80211_wake_queues(hw);
433 ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
434 mutex_unlock(&sc->mutex);
436 --- a/drivers/net/wireless/ath/ath9k/pci.c
437 +++ b/drivers/net/wireless/ath/ath9k/pci.c
438 @@ -307,12 +307,11 @@ static int ath_pci_suspend(struct device
439 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
440 struct ath_softc *sc = hw->priv;
442 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
444 /* The device has to be moved to FULLSLEEP forcibly.
445 * Otherwise the chip never moved to full sleep,
446 * when no interface is up.
448 + ath9k_hw_disable(sc->sc_ah);
449 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
452 @@ -334,22 +333,6 @@ static int ath_pci_resume(struct device
453 if ((val & 0x0000ff00) != 0)
454 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
456 - ath9k_ps_wakeup(sc);
458 - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
459 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
460 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
463 - * Reset key cache to sane defaults (all entries cleared) instead of
464 - * semi-random values after suspend/resume.
466 - ath9k_cmn_init_crypto(sc->sc_ah);
467 - ath9k_ps_restore(sc);
469 - sc->ps_idle = true;
470 - ath_radio_disable(sc, hw);
475 --- a/drivers/net/wireless/ath/ath9k/xmit.c
476 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
477 @@ -1954,7 +1954,7 @@ static void ath_tx_complete(struct ath_s
478 skb_pull(skb, padsize);
481 - if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) {
482 + if ((sc->ps_flags & PS_WAIT_FOR_TX_ACK) && !txq->axq_depth) {
483 sc->ps_flags &= ~PS_WAIT_FOR_TX_ACK;
484 ath_dbg(common, ATH_DBG_PS,
485 "Going back to sleep after having received TX status (0x%lx)\n",
486 --- a/include/linux/nl80211.h
487 +++ b/include/linux/nl80211.h
488 @@ -2785,9 +2785,11 @@ enum nl80211_ap_sme_features {
489 * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
490 * TX status to the socket error queue when requested with the
492 + * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
494 enum nl80211_feature_flags {
495 NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
496 + NL80211_FEATURE_HT_IBSS = 1 << 1,
500 --- a/include/net/cfg80211.h
501 +++ b/include/net/cfg80211.h
502 @@ -1149,6 +1149,7 @@ struct cfg80211_ibss_params {
505 struct ieee80211_channel *channel;
506 + enum nl80211_channel_type channel_type;
510 @@ -3270,6 +3271,16 @@ void cfg80211_report_obss_beacon(struct
511 const u8 *frame, size_t len,
512 int freq, gfp_t gfp);
515 + * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
516 + * @wiphy: the wiphy
517 + * @chan: main channel
518 + * @channel_type: HT mode
520 +int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
521 + struct ieee80211_channel *chan,
522 + enum nl80211_channel_type channel_type);
524 /* Logging, debugging and troubleshooting/diagnostic helpers. */
526 /* wiphy_printk helpers, similar to dev_printk */
527 --- a/net/mac80211/agg-rx.c
528 +++ b/net/mac80211/agg-rx.c
529 @@ -185,6 +185,10 @@ static void ieee80211_send_addba_resp(st
530 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
531 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
532 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
533 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
534 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
535 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
536 + memcpy(mgmt->bssid, da, ETH_ALEN);
538 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
539 IEEE80211_STYPE_ACTION);
540 --- a/net/mac80211/agg-tx.c
541 +++ b/net/mac80211/agg-tx.c
543 * @ampdu_action function will be called with the action
544 * %IEEE80211_AMPDU_TX_STOP. In this case, the call must not fail,
545 * and the driver must later call ieee80211_stop_tx_ba_cb_irqsafe().
546 + * Note that the sta can get destroyed before the BA tear down is
550 static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
551 @@ -79,10 +81,13 @@ static void ieee80211_send_addba_request
552 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
553 if (sdata->vif.type == NL80211_IFTYPE_AP ||
554 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
555 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
556 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
557 + sdata->vif.type == NL80211_IFTYPE_WDS)
558 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
559 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
560 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
561 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
562 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
564 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
565 IEEE80211_STYPE_ACTION);
566 @@ -319,6 +324,38 @@ ieee80211_wake_queue_agg(struct ieee8021
567 __release(agg_queue);
571 + * splice packets from the STA's pending to the local pending,
572 + * requires a call to ieee80211_agg_splice_finish later
574 +static void __acquires(agg_queue)
575 +ieee80211_agg_splice_packets(struct ieee80211_local *local,
576 + struct tid_ampdu_tx *tid_tx, u16 tid)
578 + int queue = ieee80211_ac_from_tid(tid);
579 + unsigned long flags;
581 + ieee80211_stop_queue_agg(local, tid);
583 + if (WARN(!tid_tx, "TID %d gone but expected when splicing aggregates"
584 + " from the pending queue\n", tid))
587 + if (!skb_queue_empty(&tid_tx->pending)) {
588 + spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
589 + /* copy over remaining packets */
590 + skb_queue_splice_tail_init(&tid_tx->pending,
591 + &local->pending[queue]);
592 + spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
596 +static void __releases(agg_queue)
597 +ieee80211_agg_splice_finish(struct ieee80211_local *local, u16 tid)
599 + ieee80211_wake_queue_agg(local, tid);
602 void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
604 struct tid_ampdu_tx *tid_tx;
605 @@ -330,19 +367,17 @@ void ieee80211_tx_ba_session_handle_star
606 tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
609 - * While we're asking the driver about the aggregation,
610 - * stop the AC queue so that we don't have to worry
611 - * about frames that came in while we were doing that,
612 - * which would require us to put them to the AC pending
613 - * afterwards which just makes the code more complex.
614 + * Start queuing up packets for this aggregation session.
615 + * We're going to release them once the driver is OK with
618 - ieee80211_stop_queue_agg(local, tid);
620 clear_bit(HT_AGG_STATE_WANT_START, &tid_tx->state);
623 - * make sure no packets are being processed to get
624 - * valid starting sequence number
625 + * Make sure no packets are being processed. This ensures that
626 + * we have a valid starting sequence number and that in-flight
627 + * packets have been flushed out and no packets for this TID
628 + * will go into the driver during the ampdu_action call.
632 @@ -356,10 +391,11 @@ void ieee80211_tx_ba_session_handle_star
635 spin_lock_bh(&sta->lock);
636 + ieee80211_agg_splice_packets(local, tid_tx, tid);
637 ieee80211_assign_tid_tx(sta, tid, NULL);
638 + ieee80211_agg_splice_finish(local, tid);
639 spin_unlock_bh(&sta->lock);
641 - ieee80211_wake_queue_agg(local, tid);
642 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
643 kfree_rcu(tid_tx, rcu_head);
645 @@ -368,9 +404,6 @@ void ieee80211_tx_ba_session_handle_star
649 - /* we can take packets again now */
650 - ieee80211_wake_queue_agg(local, tid);
652 /* activate the timer for the recipient's addBA response */
653 mod_timer(&tid_tx->addba_resp_timer, jiffies + ADDBA_RESP_INTERVAL);
654 #ifdef CONFIG_MAC80211_HT_DEBUG
655 @@ -437,7 +470,9 @@ int ieee80211_start_tx_ba_session(struct
656 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
657 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
658 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
659 - sdata->vif.type != NL80211_IFTYPE_AP)
660 + sdata->vif.type != NL80211_IFTYPE_AP &&
661 + sdata->vif.type != NL80211_IFTYPE_WDS &&
662 + sdata->vif.type != NL80211_IFTYPE_ADHOC)
665 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
666 @@ -448,6 +483,27 @@ int ieee80211_start_tx_ba_session(struct
671 + * 802.11n-2009 11.5.1.1: If the initiating STA is an HT STA, is a
672 + * member of an IBSS, and has no other existing Block Ack agreement
673 + * with the recipient STA, then the initiating STA shall transmit a
674 + * Probe Request frame to the recipient STA and shall not transmit an
675 + * ADDBA Request frame unless it receives a Probe Response frame
676 + * from the recipient within dot11ADDBAFailureTimeout.
678 + * The probe request mechanism for ADDBA is currently not implemented,
679 + * but we only build up Block Ack session with HT STAs. This information
680 + * is set when we receive a bss info from a probe response or a beacon.
682 + if (sta->sdata->vif.type == NL80211_IFTYPE_ADHOC &&
683 + !sta->sta.ht_cap.ht_supported) {
684 +#ifdef CONFIG_MAC80211_HT_DEBUG
685 + printk(KERN_DEBUG "BA request denied - IBSS STA %pM"
686 + "does not advertise HT support\n", pubsta->addr);
687 +#endif /* CONFIG_MAC80211_HT_DEBUG */
691 spin_lock_bh(&sta->lock);
693 /* we have tried too many times, receiver does not want A-MPDU */
694 @@ -508,38 +564,6 @@ int ieee80211_start_tx_ba_session(struct
696 EXPORT_SYMBOL(ieee80211_start_tx_ba_session);
699 - * splice packets from the STA's pending to the local pending,
700 - * requires a call to ieee80211_agg_splice_finish later
702 -static void __acquires(agg_queue)
703 -ieee80211_agg_splice_packets(struct ieee80211_local *local,
704 - struct tid_ampdu_tx *tid_tx, u16 tid)
706 - int queue = ieee80211_ac_from_tid(tid);
707 - unsigned long flags;
709 - ieee80211_stop_queue_agg(local, tid);
711 - if (WARN(!tid_tx, "TID %d gone but expected when splicing aggregates"
712 - " from the pending queue\n", tid))
715 - if (!skb_queue_empty(&tid_tx->pending)) {
716 - spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
717 - /* copy over remaining packets */
718 - skb_queue_splice_tail_init(&tid_tx->pending,
719 - &local->pending[queue]);
720 - spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
724 -static void __releases(agg_queue)
725 -ieee80211_agg_splice_finish(struct ieee80211_local *local, u16 tid)
727 - ieee80211_wake_queue_agg(local, tid);
730 static void ieee80211_agg_tx_operational(struct ieee80211_local *local,
731 struct sta_info *sta, u16 tid)
733 --- a/net/mac80211/debugfs_sta.c
734 +++ b/net/mac80211/debugfs_sta.c
735 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
736 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
738 int res = scnprintf(buf, sizeof(buf),
739 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
740 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
741 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
742 TEST(PS_DRIVER), TEST(AUTHORIZED),
743 TEST(SHORT_PREAMBLE),
744 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
745 + TEST(WME), TEST(CLEAR_PS_FILT),
746 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
747 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
748 TEST(TDLS_PEER_AUTH));
749 --- a/net/mac80211/ht.c
750 +++ b/net/mac80211/ht.c
751 @@ -47,7 +47,9 @@ void ieee80211_apply_htcap_overrides(str
754 if (sdata->vif.type != NL80211_IFTYPE_STATION) {
755 - WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
756 + /* AP interfaces call this code when adding new stations,
757 + * so just silently ignore non station interfaces.
762 @@ -282,6 +284,8 @@ void ieee80211_send_delba(struct ieee802
763 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
764 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
765 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
766 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
767 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
769 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
770 IEEE80211_STYPE_ACTION);
771 --- a/net/mac80211/ibss.c
772 +++ b/net/mac80211/ibss.c
773 @@ -77,6 +77,7 @@ static void __ieee80211_sta_join_ibss(st
774 struct cfg80211_bss *bss;
776 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
777 + enum nl80211_channel_type channel_type;
779 lockdep_assert_held(&ifibss->mtx);
781 @@ -105,8 +106,16 @@ static void __ieee80211_sta_join_ibss(st
783 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
785 - local->oper_channel = chan;
786 - WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT));
787 + channel_type = ifibss->channel_type;
788 + if (channel_type > NL80211_CHAN_HT20 &&
789 + !cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
790 + channel_type = NL80211_CHAN_HT20;
791 + if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
792 + /* can only fail due to HT40+/- mismatch */
793 + channel_type = NL80211_CHAN_HT20;
794 + WARN_ON(!ieee80211_set_channel_type(local, sdata,
795 + NL80211_CHAN_HT20));
797 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
799 sband = local->hw.wiphy->bands[chan->band];
800 @@ -172,6 +181,19 @@ static void __ieee80211_sta_join_ibss(st
801 memcpy(skb_put(skb, ifibss->ie_len),
802 ifibss->ie, ifibss->ie_len);
804 + /* add HT capability and information IEs */
805 + if (channel_type && sband->ht_cap.ht_supported) {
806 + pos = skb_put(skb, 4 +
807 + sizeof(struct ieee80211_ht_cap) +
808 + sizeof(struct ieee80211_ht_info));
809 + pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap,
810 + sband->ht_cap.cap);
811 + pos = ieee80211_ie_build_ht_info(pos,
817 if (local->hw.queues >= 4) {
818 pos = skb_put(skb, 9);
819 *pos++ = WLAN_EID_VENDOR_SPECIFIC;
820 @@ -195,6 +217,7 @@ static void __ieee80211_sta_join_ibss(st
821 bss_change |= BSS_CHANGED_BEACON;
822 bss_change |= BSS_CHANGED_BEACON_ENABLED;
823 bss_change |= BSS_CHANGED_BASIC_RATES;
824 + bss_change |= BSS_CHANGED_HT;
825 bss_change |= BSS_CHANGED_IBSS;
826 sdata->vif.bss_conf.ibss_joined = true;
827 ieee80211_bss_info_change_notify(sdata, bss_change);
828 @@ -268,6 +291,8 @@ static void ieee80211_rx_bss_info(struct
829 u64 beacon_timestamp, rx_timestamp;
831 enum ieee80211_band band = rx_status->band;
832 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
833 + bool rates_updated = false;
835 if (elems->ds_params && elems->ds_params_len == 1)
836 freq = ieee80211_channel_to_frequency(elems->ds_params[0],
837 @@ -307,7 +332,7 @@ static void ieee80211_rx_bss_info(struct
839 sta->sta.supp_rates[band]);
841 - rate_control_rate_init(sta);
842 + rates_updated = true;
845 sta = ieee80211_ibss_add_sta(sdata, mgmt->bssid,
846 @@ -318,6 +343,39 @@ static void ieee80211_rx_bss_info(struct
847 if (sta && elems->wmm_info)
848 set_sta_flag(sta, WLAN_STA_WME);
850 + if (sta && elems->ht_info_elem && elems->ht_cap_elem &&
851 + sdata->u.ibss.channel_type != NL80211_CHAN_NO_HT) {
852 + /* we both use HT */
853 + struct ieee80211_sta_ht_cap sta_ht_cap_new;
854 + enum nl80211_channel_type channel_type =
855 + ieee80211_ht_info_to_channel_type(
856 + elems->ht_info_elem);
858 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
859 + elems->ht_cap_elem,
863 + * fall back to HT20 if we don't use or use
864 + * the other extension channel
866 + if ((channel_type == NL80211_CHAN_HT40MINUS ||
867 + channel_type == NL80211_CHAN_HT40PLUS) &&
868 + channel_type != sdata->u.ibss.channel_type)
869 + sta_ht_cap_new.cap &=
870 + ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
872 + if (memcmp(&sta->sta.ht_cap, &sta_ht_cap_new,
873 + sizeof(sta_ht_cap_new))) {
874 + memcpy(&sta->sta.ht_cap, &sta_ht_cap_new,
875 + sizeof(sta_ht_cap_new));
876 + rates_updated = true;
880 + if (sta && rates_updated)
881 + rate_control_rate_init(sta);
886 @@ -896,12 +954,18 @@ int ieee80211_ibss_join(struct ieee80211
887 struct cfg80211_ibss_params *params)
892 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom +
893 - 36 /* bitrates */ +
895 - 3 /* DS params */ +
896 - 4 /* IBSS params */ +
897 + sizeof(struct ieee80211_hdr_3addr) +
898 + 12 /* struct ieee80211_mgmt.u.beacon */ +
899 + 2 + IEEE80211_MAX_SSID_LEN /* max SSID */ +
900 + 2 + 8 /* max Supported Rates */ +
901 + 3 /* max DS params */ +
902 + 4 /* IBSS params */ +
903 + 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
904 + 2 + sizeof(struct ieee80211_ht_cap) +
905 + 2 + sizeof(struct ieee80211_ht_info) +
909 @@ -922,13 +986,15 @@ int ieee80211_ibss_join(struct ieee80211
910 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
912 sdata->u.ibss.channel = params->channel;
913 + sdata->u.ibss.channel_type = params->channel_type;
914 sdata->u.ibss.fixed_channel = params->channel_fixed;
916 /* fix ourselves to that channel now already */
917 if (params->channel_fixed) {
918 sdata->local->oper_channel = params->channel;
919 - WARN_ON(!ieee80211_set_channel_type(sdata->local, sdata,
920 - NL80211_CHAN_NO_HT));
921 + if (!ieee80211_set_channel_type(sdata->local, sdata,
922 + params->channel_type))
927 @@ -951,6 +1017,23 @@ int ieee80211_ibss_join(struct ieee80211
928 ieee80211_recalc_idle(sdata->local);
929 mutex_unlock(&sdata->local->mtx);
932 + * 802.11n-2009 9.13.3.1: In an IBSS, the HT Protection field is
933 + * reserved, but an HT STA shall protect HT transmissions as though
934 + * the HT Protection field were set to non-HT mixed mode.
936 + * In an IBSS, the RIFS Mode field of the HT Operation element is
937 + * also reserved, but an HT STA shall operate as though this field
941 + sdata->vif.bss_conf.ht_operation_mode |=
942 + IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
943 + | IEEE80211_HT_PARAM_RIFS_MODE;
945 + changed |= BSS_CHANGED_HT;
946 + ieee80211_bss_info_change_notify(sdata, changed);
948 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
951 --- a/net/mac80211/ieee80211_i.h
952 +++ b/net/mac80211/ieee80211_i.h
953 @@ -474,6 +474,7 @@ struct ieee80211_if_ibss {
956 struct ieee80211_channel *channel;
957 + enum nl80211_channel_type channel_type;
959 unsigned long ibss_join_req;
960 /* probe response/beacon for IBSS */
961 --- a/net/mac80211/iface.c
962 +++ b/net/mac80211/iface.c
963 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
965 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
966 struct ieee80211_local *local = sdata->local;
967 - struct sta_info *sta;
970 u32 hw_reconf_flags = 0;
971 @@ -309,27 +308,6 @@ static int ieee80211_do_open(struct net_
973 set_bit(SDATA_STATE_RUNNING, &sdata->state);
975 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
976 - /* Create STA entry for the WDS peer */
977 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
981 - goto err_del_interface;
984 - /* no atomic bitop required since STA is not live yet */
985 - set_sta_flag(sta, WLAN_STA_AUTHORIZED);
987 - res = sta_info_insert(sta);
989 - /* STA has been freed */
990 - goto err_del_interface;
993 - rate_control_rate_init(sta);
997 * set_multicast_list will be invoked by the networking core
998 * which will check whether any increments here were done in
999 @@ -356,8 +334,7 @@ static int ieee80211_do_open(struct net_
1000 netif_tx_start_all_queues(dev);
1003 - err_del_interface:
1004 - drv_remove_interface(local, sdata);
1007 if (!local->open_count)
1009 @@ -719,6 +696,70 @@ static void ieee80211_if_setup(struct ne
1010 dev->destructor = free_netdev;
1013 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1014 + struct sk_buff *skb)
1016 + struct ieee80211_local *local = sdata->local;
1017 + struct ieee80211_rx_status *rx_status;
1018 + struct ieee802_11_elems elems;
1019 + struct ieee80211_mgmt *mgmt;
1020 + struct sta_info *sta;
1025 + enum ieee80211_band band = local->hw.conf.channel->band;
1026 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
1028 + rx_status = IEEE80211_SKB_RXCB(skb);
1029 + mgmt = (struct ieee80211_mgmt *) skb->data;
1030 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
1032 + if (stype != IEEE80211_STYPE_BEACON)
1035 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1036 + if (baselen > skb->len)
1039 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1040 + skb->len - baselen, &elems);
1042 + rates = ieee80211_sta_get_rates(local, &elems, band);
1046 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1049 + rcu_read_unlock();
1050 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1058 + sta->last_rx = jiffies;
1059 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
1061 + if (elems.ht_cap_elem)
1062 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1063 + elems.ht_cap_elem, &sta->sta.ht_cap);
1065 + if (elems.wmm_param)
1066 + set_sta_flag(sta, WLAN_STA_WME);
1069 + set_sta_flag(sta, WLAN_STA_AUTHORIZED);
1070 + rate_control_rate_init(sta);
1071 + sta_info_insert_rcu(sta);
1074 + rcu_read_unlock();
1077 static void ieee80211_iface_work(struct work_struct *work)
1079 struct ieee80211_sub_if_data *sdata =
1080 @@ -823,6 +864,9 @@ static void ieee80211_iface_work(struct
1082 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1084 + case NL80211_IFTYPE_WDS:
1085 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1088 WARN(1, "frame for unexpected interface type");
1090 --- a/net/mac80211/main.c
1091 +++ b/net/mac80211/main.c
1092 @@ -574,7 +574,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(
1093 WIPHY_FLAG_OFFCHAN_TX |
1094 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
1096 - wiphy->features = NL80211_FEATURE_SK_TX_STATUS;
1097 + wiphy->features = NL80211_FEATURE_SK_TX_STATUS |
1098 + NL80211_FEATURE_HT_IBSS;
1101 wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
1102 --- a/net/mac80211/rx.c
1103 +++ b/net/mac80211/rx.c
1104 @@ -2237,7 +2237,9 @@ ieee80211_rx_h_action(struct ieee80211_r
1105 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
1106 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1107 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1108 - sdata->vif.type != NL80211_IFTYPE_AP)
1109 + sdata->vif.type != NL80211_IFTYPE_AP &&
1110 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1111 + sdata->vif.type != NL80211_IFTYPE_ADHOC)
1114 /* verify action_code is present */
1115 @@ -2452,13 +2454,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
1117 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
1118 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
1119 - sdata->vif.type != NL80211_IFTYPE_STATION)
1120 + sdata->vif.type != NL80211_IFTYPE_STATION &&
1121 + sdata->vif.type != NL80211_IFTYPE_WDS)
1122 return RX_DROP_MONITOR;
1125 case cpu_to_le16(IEEE80211_STYPE_BEACON):
1126 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
1127 - /* process for all: mesh, mlme, ibss */
1128 + /* process for all: mesh, mlme, ibss, wds */
1130 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
1131 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
1132 @@ -2796,19 +2799,32 @@ static int prepare_for_handlers(struct i
1134 } else if (!ieee80211_bssid_match(bssid,
1137 + * Accept public action frames even when the
1138 + * BSSID doesn't match, this is used for P2P
1139 + * and location updates. Note that mac80211
1140 + * itself never looks at these frames.
1142 if (!(status->rx_flags & IEEE80211_RX_IN_SCAN) &&
1143 - !ieee80211_is_beacon(hdr->frame_control) &&
1144 - !(ieee80211_is_action(hdr->frame_control) &&
1146 + ieee80211_is_public_action(hdr, skb->len))
1148 + if (!(status->rx_flags & IEEE80211_RX_IN_SCAN) &&
1149 + !ieee80211_is_beacon(hdr->frame_control))
1151 status->rx_flags &= ~IEEE80211_RX_RA_MATCH;
1154 case NL80211_IFTYPE_WDS:
1155 - if (bssid || !ieee80211_is_data(hdr->frame_control))
1157 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
1160 + if (ieee80211_is_data(hdr->frame_control) ||
1161 + ieee80211_is_action(hdr->frame_control)) {
1162 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
1164 + } else if (!ieee80211_is_beacon(hdr->frame_control))
1169 /* should never get here */
1170 --- a/net/mac80211/sta_info.h
1171 +++ b/net/mac80211/sta_info.h
1173 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
1175 * @WLAN_STA_WME: Station is a QoS-STA.
1176 - * @WLAN_STA_WDS: Station is one of our WDS peers.
1177 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
1178 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
1179 * frame to this station is transmitted.
1180 @@ -60,7 +59,6 @@ enum ieee80211_sta_info_flags {
1181 WLAN_STA_AUTHORIZED,
1182 WLAN_STA_SHORT_PREAMBLE,
1185 WLAN_STA_CLEAR_PS_FILT,
1188 --- a/net/mac80211/util.c
1189 +++ b/net/mac80211/util.c
1190 @@ -1612,6 +1612,11 @@ u8 *ieee80211_ie_build_ht_info(u8 *pos,
1192 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1193 ht_info->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
1196 + * Note: According to 802.11n-2009 9.13.3.1, HT Protection field and
1197 + * RIFS Mode are reserved in IBSS mode, therefore keep them at 0
1199 ht_info->operation_mode = 0x0000;
1200 ht_info->stbc_param = 0x0000;
1202 --- a/net/wireless/chan.c
1203 +++ b/net/wireless/chan.c
1205 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
1208 +#include <linux/export.h>
1209 #include <net/cfg80211.h>
1212 @@ -44,9 +45,9 @@ rdev_freq_to_chan(struct cfg80211_regist
1216 -static bool can_beacon_sec_chan(struct wiphy *wiphy,
1217 - struct ieee80211_channel *chan,
1218 - enum nl80211_channel_type channel_type)
1219 +int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
1220 + struct ieee80211_channel *chan,
1221 + enum nl80211_channel_type channel_type)
1223 struct ieee80211_channel *sec_chan;
1225 @@ -75,6 +76,7 @@ static bool can_beacon_sec_chan(struct w
1229 +EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan);
1231 int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
1232 struct wireless_dev *wdev, int freq,
1233 @@ -109,8 +111,8 @@ int cfg80211_set_freq(struct cfg80211_re
1234 switch (channel_type) {
1235 case NL80211_CHAN_HT40PLUS:
1236 case NL80211_CHAN_HT40MINUS:
1237 - if (!can_beacon_sec_chan(&rdev->wiphy, chan,
1239 + if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan,
1242 "cfg80211: Secondary channel not "
1243 "allowed to initiate communication\n");
1244 --- a/net/wireless/nl80211.c
1245 +++ b/net/wireless/nl80211.c
1246 @@ -4684,13 +4684,41 @@ static int nl80211_join_ibss(struct sk_b
1247 ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
1250 - ibss.channel = ieee80211_get_channel(wiphy,
1251 - nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
1252 + if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
1253 + enum nl80211_channel_type channel_type;
1255 + channel_type = nla_get_u32(
1256 + info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
1257 + if (channel_type != NL80211_CHAN_NO_HT &&
1258 + channel_type != NL80211_CHAN_HT20 &&
1259 + channel_type != NL80211_CHAN_HT40MINUS &&
1260 + channel_type != NL80211_CHAN_HT40PLUS)
1263 + if (channel_type != NL80211_CHAN_NO_HT &&
1264 + !(wiphy->features & NL80211_FEATURE_HT_IBSS))
1267 + ibss.channel_type = channel_type;
1269 + ibss.channel_type = NL80211_CHAN_NO_HT;
1272 + ibss.channel = rdev_freq_to_chan(rdev,
1273 + nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
1274 + ibss.channel_type);
1275 if (!ibss.channel ||
1276 ibss.channel->flags & IEEE80211_CHAN_NO_IBSS ||
1277 ibss.channel->flags & IEEE80211_CHAN_DISABLED)
1280 + /* Both channels should be able to initiate communication */
1281 + if ((ibss.channel_type == NL80211_CHAN_HT40PLUS ||
1282 + ibss.channel_type == NL80211_CHAN_HT40MINUS) &&
1283 + !cfg80211_can_beacon_sec_chan(&rdev->wiphy, ibss.channel,
1284 + ibss.channel_type))
1287 ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED];
1288 ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
1290 --- a/include/linux/ieee80211.h
1291 +++ b/include/linux/ieee80211.h
1292 @@ -1695,6 +1695,23 @@ static inline bool ieee80211_is_robust_m
1296 + * ieee80211_is_public_action - check if frame is a public action frame
1298 + * @len: length of the frame
1300 +static inline bool ieee80211_is_public_action(struct ieee80211_hdr *hdr,
1303 + struct ieee80211_mgmt *mgmt = (void *)hdr;
1307 + if (!ieee80211_is_action(hdr->frame_control))
1309 + return mgmt->u.action.category == WLAN_CATEGORY_PUBLIC;
1313 * ieee80211_fhss_chan_to_freq - get channel frequency
1314 * @channel: the FHSS channel
1316 --- a/net/mac80211/tx.c
1317 +++ b/net/mac80211/tx.c
1318 @@ -1332,8 +1332,11 @@ static int invoke_tx_handlers(struct iee
1319 if (!(tx->local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL))
1320 CALL_TXH(ieee80211_tx_h_rate_ctrl);
1322 - if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION))
1323 + if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) {
1324 + __skb_queue_tail(&tx->skbs, tx->skb);
1329 CALL_TXH(ieee80211_tx_h_michael_mic_add);
1330 CALL_TXH(ieee80211_tx_h_sequence);
1331 --- a/net/mac80211/sta_info.c
1332 +++ b/net/mac80211/sta_info.c
1333 @@ -851,6 +851,7 @@ static int __must_check __sta_info_destr
1334 struct ieee80211_sub_if_data *sdata;
1335 unsigned long flags;
1337 + struct tid_ampdu_tx *tid_tx;
1341 @@ -949,6 +950,30 @@ static int __must_check __sta_info_destr
1345 + /* There could be some memory leaks because of ampdu tx pending queue
1346 + * not being freed before destroying the station info.
1348 + * Make sure that such queues are purged before freeing the station
1350 + * TODO: We have to somehow postpone the full destruction
1351 + * until the aggregation stop completes. Refer
1352 + * http://thread.gmane.org/gmane.linux.kernel.wireless.general/81936
1354 + for (i = 0; i < STA_TID_NUM; i++) {
1355 + if (!sta->ampdu_mlme.tid_tx[i])
1357 + tid_tx = sta->ampdu_mlme.tid_tx[i];
1358 + if (skb_queue_len(&tid_tx->pending)) {
1359 +#ifdef CONFIG_MAC80211_HT_DEBUG
1360 + wiphy_debug(local->hw.wiphy, "TX A-MPDU purging %d "
1361 + "packets for tid=%d\n",
1362 + skb_queue_len(&tid_tx->pending), i);
1363 +#endif /* CONFIG_MAC80211_HT_DEBUG */
1364 + __skb_queue_purge(&tid_tx->pending);
1366 + kfree_rcu(tid_tx, rcu_head);
1369 __sta_info_free(local, sta);
1372 --- a/drivers/net/wireless/ath/ath9k/calib.c
1373 +++ b/drivers/net/wireless/ath/ath9k/calib.c
1374 @@ -402,6 +402,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, s
1375 ah->noise = ath9k_hw_getchan_noise(ah, chan);
1378 +EXPORT_SYMBOL(ath9k_hw_getnf);
1380 void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
1381 struct ath9k_channel *chan)