ath9k: fix antenna configuration on ar9285 for devices without antenna diversity
[openwrt/staging/dedeckeh.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,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;
330
331 + ath9k_ps_wakeup(sc);
332 mutex_lock(&sc->mutex);
333
334 /*
335 @@ -1639,13 +1600,8 @@ static int ath9k_config(struct ieee80211
336 */
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");
343 - } else {
344 - disable_radio = true;
345 - }
346 + if (sc->ps_idle)
347 + ath_cancel_work(sc);
348 }
349
350 /*
351 @@ -1752,18 +1708,12 @@ static int ath9k_config(struct ieee80211
352 ath_dbg(common, ATH_DBG_CONFIG,
353 "Set power: %d\n", conf->power_level);
354 sc->config.txpowlimit = 2 * conf->power_level;
355 - ath9k_ps_wakeup(sc);
356 ath9k_cmn_update_txpow(ah, sc->curtxpow,
357 sc->config.txpowlimit, &sc->curtxpow);
358 - ath9k_ps_restore(sc);
359 - }
360 -
361 - if (disable_radio) {
362 - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
363 - ath_radio_disable(sc, hw);
364 }
365
366 mutex_unlock(&sc->mutex);
367 + ath9k_ps_restore(sc);
368
369 return 0;
370 }
371 @@ -2331,9 +2281,6 @@ static void ath9k_flush(struct ieee80211
372 return;
373 }
374
375 - if (drop)
376 - timeout = 1;
377 -
378 for (j = 0; j < timeout; j++) {
379 bool npend = false;
380
381 @@ -2351,21 +2298,22 @@ static void ath9k_flush(struct ieee80211
382 }
383
384 if (!npend)
385 - goto out;
386 + break;
387 }
388
389 - ath9k_ps_wakeup(sc);
390 - spin_lock_bh(&sc->sc_pcu_lock);
391 - drain_txq = ath_drain_all_txq(sc, false);
392 - spin_unlock_bh(&sc->sc_pcu_lock);
393 + if (drop) {
394 + ath9k_ps_wakeup(sc);
395 + spin_lock_bh(&sc->sc_pcu_lock);
396 + drain_txq = ath_drain_all_txq(sc, false);
397 + spin_unlock_bh(&sc->sc_pcu_lock);
398
399 - if (!drain_txq)
400 - ath_reset(sc, false);
401 + if (!drain_txq)
402 + ath_reset(sc, false);
403
404 - ath9k_ps_restore(sc);
405 - ieee80211_wake_queues(hw);
406 + ath9k_ps_restore(sc);
407 + ieee80211_wake_queues(hw);
408 + }
409
410 -out:
411 ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
412 mutex_unlock(&sc->mutex);
413 }
414 --- a/drivers/net/wireless/ath/ath9k/pci.c
415 +++ b/drivers/net/wireless/ath/ath9k/pci.c
416 @@ -307,12 +307,11 @@ static int ath_pci_suspend(struct device
417 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
418 struct ath_softc *sc = hw->priv;
419
420 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
421 -
422 /* The device has to be moved to FULLSLEEP forcibly.
423 * Otherwise the chip never moved to full sleep,
424 * when no interface is up.
425 */
426 + ath9k_hw_disable(sc->sc_ah);
427 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
428
429 return 0;
430 @@ -334,22 +333,6 @@ static int ath_pci_resume(struct device
431 if ((val & 0x0000ff00) != 0)
432 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
433
434 - ath9k_ps_wakeup(sc);
435 - /* Enable LED */
436 - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
437 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
438 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
439 -
440 - /*
441 - * Reset key cache to sane defaults (all entries cleared) instead of
442 - * semi-random values after suspend/resume.
443 - */
444 - ath9k_cmn_init_crypto(sc->sc_ah);
445 - ath9k_ps_restore(sc);
446 -
447 - sc->ps_idle = true;
448 - ath_radio_disable(sc, hw);
449 -
450 return 0;
451 }
452
453 --- a/drivers/net/wireless/ath/ath9k/xmit.c
454 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
455 @@ -1954,7 +1954,7 @@ static void ath_tx_complete(struct ath_s
456 skb_pull(skb, padsize);
457 }
458
459 - if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) {
460 + if ((sc->ps_flags & PS_WAIT_FOR_TX_ACK) && !txq->axq_depth) {
461 sc->ps_flags &= ~PS_WAIT_FOR_TX_ACK;
462 ath_dbg(common, ATH_DBG_PS,
463 "Going back to sleep after having received TX status (0x%lx)\n",
464 --- a/include/linux/nl80211.h
465 +++ b/include/linux/nl80211.h
466 @@ -2785,9 +2785,11 @@ enum nl80211_ap_sme_features {
467 * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back
468 * TX status to the socket error queue when requested with the
469 * socket option.
470 + * @NL80211_FEATURE_HT_IBSS: This driver supports IBSS with HT datarates.
471 */
472 enum nl80211_feature_flags {
473 NL80211_FEATURE_SK_TX_STATUS = 1 << 0,
474 + NL80211_FEATURE_HT_IBSS = 1 << 1,
475 };
476
477 /**
478 --- a/include/net/cfg80211.h
479 +++ b/include/net/cfg80211.h
480 @@ -1149,6 +1149,7 @@ struct cfg80211_ibss_params {
481 u8 *ssid;
482 u8 *bssid;
483 struct ieee80211_channel *channel;
484 + enum nl80211_channel_type channel_type;
485 u8 *ie;
486 u8 ssid_len, ie_len;
487 u16 beacon_interval;
488 @@ -3270,6 +3271,16 @@ void cfg80211_report_obss_beacon(struct
489 const u8 *frame, size_t len,
490 int freq, gfp_t gfp);
491
492 +/*
493 + * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used
494 + * @wiphy: the wiphy
495 + * @chan: main channel
496 + * @channel_type: HT mode
497 + */
498 +int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
499 + struct ieee80211_channel *chan,
500 + enum nl80211_channel_type channel_type);
501 +
502 /* Logging, debugging and troubleshooting/diagnostic helpers. */
503
504 /* wiphy_printk helpers, similar to dev_printk */
505 --- a/net/mac80211/agg-rx.c
506 +++ b/net/mac80211/agg-rx.c
507 @@ -185,6 +185,10 @@ static void ieee80211_send_addba_resp(st
508 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
509 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
510 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
511 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
512 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
513 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
514 + memcpy(mgmt->bssid, da, ETH_ALEN);
515
516 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
517 IEEE80211_STYPE_ACTION);
518 --- a/net/mac80211/agg-tx.c
519 +++ b/net/mac80211/agg-tx.c
520 @@ -79,10 +79,13 @@ static void ieee80211_send_addba_request
521 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
522 if (sdata->vif.type == NL80211_IFTYPE_AP ||
523 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
524 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
525 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
526 + sdata->vif.type == NL80211_IFTYPE_WDS)
527 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
528 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
529 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
530 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
531 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
532
533 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
534 IEEE80211_STYPE_ACTION);
535 @@ -437,7 +440,9 @@ int ieee80211_start_tx_ba_session(struct
536 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
537 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
538 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
539 - sdata->vif.type != NL80211_IFTYPE_AP)
540 + sdata->vif.type != NL80211_IFTYPE_AP &&
541 + sdata->vif.type != NL80211_IFTYPE_WDS &&
542 + sdata->vif.type != NL80211_IFTYPE_ADHOC)
543 return -EINVAL;
544
545 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
546 @@ -448,6 +453,27 @@ int ieee80211_start_tx_ba_session(struct
547 return -EINVAL;
548 }
549
550 + /*
551 + * 802.11n-2009 11.5.1.1: If the initiating STA is an HT STA, is a
552 + * member of an IBSS, and has no other existing Block Ack agreement
553 + * with the recipient STA, then the initiating STA shall transmit a
554 + * Probe Request frame to the recipient STA and shall not transmit an
555 + * ADDBA Request frame unless it receives a Probe Response frame
556 + * from the recipient within dot11ADDBAFailureTimeout.
557 + *
558 + * The probe request mechanism for ADDBA is currently not implemented,
559 + * but we only build up Block Ack session with HT STAs. This information
560 + * is set when we receive a bss info from a probe response or a beacon.
561 + */
562 + if (sta->sdata->vif.type == NL80211_IFTYPE_ADHOC &&
563 + !sta->sta.ht_cap.ht_supported) {
564 +#ifdef CONFIG_MAC80211_HT_DEBUG
565 + printk(KERN_DEBUG "BA request denied - IBSS STA %pM"
566 + "does not advertise HT support\n", pubsta->addr);
567 +#endif /* CONFIG_MAC80211_HT_DEBUG */
568 + return -EINVAL;
569 + }
570 +
571 spin_lock_bh(&sta->lock);
572
573 /* we have tried too many times, receiver does not want A-MPDU */
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",
581 + "%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));
590 --- a/net/mac80211/ht.c
591 +++ b/net/mac80211/ht.c
592 @@ -282,6 +282,8 @@ void ieee80211_send_delba(struct ieee802
593 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
594 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
595 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
596 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
597 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
598
599 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
600 IEEE80211_STYPE_ACTION);
601 --- a/net/mac80211/ibss.c
602 +++ b/net/mac80211/ibss.c
603 @@ -77,6 +77,7 @@ static void __ieee80211_sta_join_ibss(st
604 struct cfg80211_bss *bss;
605 u32 bss_change;
606 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
607 + enum nl80211_channel_type channel_type;
608
609 lockdep_assert_held(&ifibss->mtx);
610
611 @@ -105,8 +106,16 @@ static void __ieee80211_sta_join_ibss(st
612
613 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
614
615 - local->oper_channel = chan;
616 - WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT));
617 + channel_type = ifibss->channel_type;
618 + if (channel_type > NL80211_CHAN_HT20 &&
619 + !cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
620 + channel_type = NL80211_CHAN_HT20;
621 + if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
622 + /* can only fail due to HT40+/- mismatch */
623 + channel_type = NL80211_CHAN_HT20;
624 + WARN_ON(!ieee80211_set_channel_type(local, sdata,
625 + NL80211_CHAN_HT20));
626 + }
627 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
628
629 sband = local->hw.wiphy->bands[chan->band];
630 @@ -172,6 +181,19 @@ static void __ieee80211_sta_join_ibss(st
631 memcpy(skb_put(skb, ifibss->ie_len),
632 ifibss->ie, ifibss->ie_len);
633
634 + /* add HT capability and information IEs */
635 + if (channel_type && sband->ht_cap.ht_supported) {
636 + pos = skb_put(skb, 4 +
637 + sizeof(struct ieee80211_ht_cap) +
638 + sizeof(struct ieee80211_ht_info));
639 + pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap,
640 + sband->ht_cap.cap);
641 + pos = ieee80211_ie_build_ht_info(pos,
642 + &sband->ht_cap,
643 + chan,
644 + channel_type);
645 + }
646 +
647 if (local->hw.queues >= 4) {
648 pos = skb_put(skb, 9);
649 *pos++ = WLAN_EID_VENDOR_SPECIFIC;
650 @@ -195,6 +217,7 @@ static void __ieee80211_sta_join_ibss(st
651 bss_change |= BSS_CHANGED_BEACON;
652 bss_change |= BSS_CHANGED_BEACON_ENABLED;
653 bss_change |= BSS_CHANGED_BASIC_RATES;
654 + bss_change |= BSS_CHANGED_HT;
655 bss_change |= BSS_CHANGED_IBSS;
656 sdata->vif.bss_conf.ibss_joined = true;
657 ieee80211_bss_info_change_notify(sdata, bss_change);
658 @@ -268,6 +291,8 @@ static void ieee80211_rx_bss_info(struct
659 u64 beacon_timestamp, rx_timestamp;
660 u32 supp_rates = 0;
661 enum ieee80211_band band = rx_status->band;
662 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
663 + bool rates_updated = false;
664
665 if (elems->ds_params && elems->ds_params_len == 1)
666 freq = ieee80211_channel_to_frequency(elems->ds_params[0],
667 @@ -307,7 +332,7 @@ static void ieee80211_rx_bss_info(struct
668 prev_rates,
669 sta->sta.supp_rates[band]);
670 #endif
671 - rate_control_rate_init(sta);
672 + rates_updated = true;
673 }
674 } else
675 sta = ieee80211_ibss_add_sta(sdata, mgmt->bssid,
676 @@ -318,6 +343,39 @@ static void ieee80211_rx_bss_info(struct
677 if (sta && elems->wmm_info)
678 set_sta_flag(sta, WLAN_STA_WME);
679
680 + if (sta && elems->ht_info_elem && elems->ht_cap_elem &&
681 + sdata->u.ibss.channel_type != NL80211_CHAN_NO_HT) {
682 + /* we both use HT */
683 + struct ieee80211_sta_ht_cap sta_ht_cap_new;
684 + enum nl80211_channel_type channel_type =
685 + ieee80211_ht_info_to_channel_type(
686 + elems->ht_info_elem);
687 +
688 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
689 + elems->ht_cap_elem,
690 + &sta_ht_cap_new);
691 +
692 + /*
693 + * fall back to HT20 if we don't use or use
694 + * the other extension channel
695 + */
696 + if ((channel_type == NL80211_CHAN_HT40MINUS ||
697 + channel_type == NL80211_CHAN_HT40PLUS) &&
698 + channel_type != sdata->u.ibss.channel_type)
699 + sta_ht_cap_new.cap &=
700 + ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
701 +
702 + if (memcmp(&sta->sta.ht_cap, &sta_ht_cap_new,
703 + sizeof(sta_ht_cap_new))) {
704 + memcpy(&sta->sta.ht_cap, &sta_ht_cap_new,
705 + sizeof(sta_ht_cap_new));
706 + rates_updated = true;
707 + }
708 + }
709 +
710 + if (sta && rates_updated)
711 + rate_control_rate_init(sta);
712 +
713 rcu_read_unlock();
714 }
715
716 @@ -896,12 +954,18 @@ int ieee80211_ibss_join(struct ieee80211
717 struct cfg80211_ibss_params *params)
718 {
719 struct sk_buff *skb;
720 + u32 changed = 0;
721
722 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom +
723 - 36 /* bitrates */ +
724 - 34 /* SSID */ +
725 - 3 /* DS params */ +
726 - 4 /* IBSS params */ +
727 + sizeof(struct ieee80211_hdr_3addr) +
728 + 12 /* struct ieee80211_mgmt.u.beacon */ +
729 + 2 + IEEE80211_MAX_SSID_LEN /* max SSID */ +
730 + 2 + 8 /* max Supported Rates */ +
731 + 3 /* max DS params */ +
732 + 4 /* IBSS params */ +
733 + 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
734 + 2 + sizeof(struct ieee80211_ht_cap) +
735 + 2 + sizeof(struct ieee80211_ht_info) +
736 params->ie_len);
737 if (!skb)
738 return -ENOMEM;
739 @@ -922,13 +986,15 @@ int ieee80211_ibss_join(struct ieee80211
740 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
741
742 sdata->u.ibss.channel = params->channel;
743 + sdata->u.ibss.channel_type = params->channel_type;
744 sdata->u.ibss.fixed_channel = params->channel_fixed;
745
746 /* fix ourselves to that channel now already */
747 if (params->channel_fixed) {
748 sdata->local->oper_channel = params->channel;
749 - WARN_ON(!ieee80211_set_channel_type(sdata->local, sdata,
750 - NL80211_CHAN_NO_HT));
751 + if (!ieee80211_set_channel_type(sdata->local, sdata,
752 + params->channel_type))
753 + return -EINVAL;
754 }
755
756 if (params->ie) {
757 @@ -951,6 +1017,23 @@ int ieee80211_ibss_join(struct ieee80211
758 ieee80211_recalc_idle(sdata->local);
759 mutex_unlock(&sdata->local->mtx);
760
761 + /*
762 + * 802.11n-2009 9.13.3.1: In an IBSS, the HT Protection field is
763 + * reserved, but an HT STA shall protect HT transmissions as though
764 + * the HT Protection field were set to non-HT mixed mode.
765 + *
766 + * In an IBSS, the RIFS Mode field of the HT Operation element is
767 + * also reserved, but an HT STA shall operate as though this field
768 + * were set to 1.
769 + */
770 +
771 + sdata->vif.bss_conf.ht_operation_mode |=
772 + IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
773 + | IEEE80211_HT_PARAM_RIFS_MODE;
774 +
775 + changed |= BSS_CHANGED_HT;
776 + ieee80211_bss_info_change_notify(sdata, changed);
777 +
778 ieee80211_queue_work(&sdata->local->hw, &sdata->work);
779
780 return 0;
781 --- a/net/mac80211/ieee80211_i.h
782 +++ b/net/mac80211/ieee80211_i.h
783 @@ -474,6 +474,7 @@ struct ieee80211_if_ibss {
784 u8 ssid_len, ie_len;
785 u8 *ie;
786 struct ieee80211_channel *channel;
787 + enum nl80211_channel_type channel_type;
788
789 unsigned long ibss_join_req;
790 /* probe response/beacon for IBSS */
791 --- a/net/mac80211/iface.c
792 +++ b/net/mac80211/iface.c
793 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
794 {
795 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
796 struct ieee80211_local *local = sdata->local;
797 - struct sta_info *sta;
798 u32 changed = 0;
799 int res;
800 u32 hw_reconf_flags = 0;
801 @@ -309,27 +308,6 @@ static int ieee80211_do_open(struct net_
802
803 set_bit(SDATA_STATE_RUNNING, &sdata->state);
804
805 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
806 - /* Create STA entry for the WDS peer */
807 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
808 - GFP_KERNEL);
809 - if (!sta) {
810 - res = -ENOMEM;
811 - goto err_del_interface;
812 - }
813 -
814 - /* no atomic bitop required since STA is not live yet */
815 - set_sta_flag(sta, WLAN_STA_AUTHORIZED);
816 -
817 - res = sta_info_insert(sta);
818 - if (res) {
819 - /* STA has been freed */
820 - goto err_del_interface;
821 - }
822 -
823 - rate_control_rate_init(sta);
824 - }
825 -
826 /*
827 * set_multicast_list will be invoked by the networking core
828 * which will check whether any increments here were done in
829 @@ -356,8 +334,7 @@ static int ieee80211_do_open(struct net_
830 netif_tx_start_all_queues(dev);
831
832 return 0;
833 - err_del_interface:
834 - drv_remove_interface(local, sdata);
835 +
836 err_stop:
837 if (!local->open_count)
838 drv_stop(local);
839 @@ -719,6 +696,70 @@ static void ieee80211_if_setup(struct ne
840 dev->destructor = free_netdev;
841 }
842
843 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
844 + struct sk_buff *skb)
845 +{
846 + struct ieee80211_local *local = sdata->local;
847 + struct ieee80211_rx_status *rx_status;
848 + struct ieee802_11_elems elems;
849 + struct ieee80211_mgmt *mgmt;
850 + struct sta_info *sta;
851 + size_t baselen;
852 + u32 rates = 0;
853 + u16 stype;
854 + bool new = false;
855 + enum ieee80211_band band = local->hw.conf.channel->band;
856 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
857 +
858 + rx_status = IEEE80211_SKB_RXCB(skb);
859 + mgmt = (struct ieee80211_mgmt *) skb->data;
860 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
861 +
862 + if (stype != IEEE80211_STYPE_BEACON)
863 + return;
864 +
865 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
866 + if (baselen > skb->len)
867 + return;
868 +
869 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
870 + skb->len - baselen, &elems);
871 +
872 + rates = ieee80211_sta_get_rates(local, &elems, band);
873 +
874 + rcu_read_lock();
875 +
876 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
877 +
878 + if (!sta) {
879 + rcu_read_unlock();
880 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
881 + GFP_KERNEL);
882 + if (!sta)
883 + return;
884 +
885 + new = true;
886 + }
887 +
888 + sta->last_rx = jiffies;
889 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
890 +
891 + if (elems.ht_cap_elem)
892 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
893 + elems.ht_cap_elem, &sta->sta.ht_cap);
894 +
895 + if (elems.wmm_param)
896 + set_sta_flag(sta, WLAN_STA_WME);
897 +
898 + if (new) {
899 + set_sta_flag(sta, WLAN_STA_AUTHORIZED);
900 + rate_control_rate_init(sta);
901 + sta_info_insert_rcu(sta);
902 + }
903 +
904 + rcu_read_unlock();
905 +}
906 +
907 static void ieee80211_iface_work(struct work_struct *work)
908 {
909 struct ieee80211_sub_if_data *sdata =
910 @@ -823,6 +864,9 @@ static void ieee80211_iface_work(struct
911 break;
912 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
913 break;
914 + case NL80211_IFTYPE_WDS:
915 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
916 + break;
917 default:
918 WARN(1, "frame for unexpected interface type");
919 break;
920 --- a/net/mac80211/main.c
921 +++ b/net/mac80211/main.c
922 @@ -574,7 +574,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(
923 WIPHY_FLAG_OFFCHAN_TX |
924 WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
925
926 - wiphy->features = NL80211_FEATURE_SK_TX_STATUS;
927 + wiphy->features = NL80211_FEATURE_SK_TX_STATUS |
928 + NL80211_FEATURE_HT_IBSS;
929
930 if (!ops->set_key)
931 wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
932 --- a/net/mac80211/rx.c
933 +++ b/net/mac80211/rx.c
934 @@ -2237,7 +2237,9 @@ ieee80211_rx_h_action(struct ieee80211_r
935 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
936 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
937 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
938 - sdata->vif.type != NL80211_IFTYPE_AP)
939 + sdata->vif.type != NL80211_IFTYPE_AP &&
940 + sdata->vif.type != NL80211_IFTYPE_WDS &&
941 + sdata->vif.type != NL80211_IFTYPE_ADHOC)
942 break;
943
944 /* verify action_code is present */
945 @@ -2452,13 +2454,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
946
947 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
948 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
949 - sdata->vif.type != NL80211_IFTYPE_STATION)
950 + sdata->vif.type != NL80211_IFTYPE_STATION &&
951 + sdata->vif.type != NL80211_IFTYPE_WDS)
952 return RX_DROP_MONITOR;
953
954 switch (stype) {
955 case cpu_to_le16(IEEE80211_STYPE_BEACON):
956 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
957 - /* process for all: mesh, mlme, ibss */
958 + /* process for all: mesh, mlme, ibss, wds */
959 break;
960 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
961 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
962 @@ -2805,10 +2808,16 @@ static int prepare_for_handlers(struct i
963 }
964 break;
965 case NL80211_IFTYPE_WDS:
966 - if (bssid || !ieee80211_is_data(hdr->frame_control))
967 - return 0;
968 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
969 return 0;
970 +
971 + if (ieee80211_is_data(hdr->frame_control) ||
972 + ieee80211_is_action(hdr->frame_control)) {
973 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
974 + return 0;
975 + } else if (!ieee80211_is_beacon(hdr->frame_control))
976 + return 0;
977 +
978 break;
979 default:
980 /* should never get here */
981 --- a/net/mac80211/sta_info.h
982 +++ b/net/mac80211/sta_info.h
983 @@ -31,7 +31,6 @@
984 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
985 * frames.
986 * @WLAN_STA_WME: Station is a QoS-STA.
987 - * @WLAN_STA_WDS: Station is one of our WDS peers.
988 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
989 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
990 * frame to this station is transmitted.
991 @@ -60,7 +59,6 @@ enum ieee80211_sta_info_flags {
992 WLAN_STA_AUTHORIZED,
993 WLAN_STA_SHORT_PREAMBLE,
994 WLAN_STA_WME,
995 - WLAN_STA_WDS,
996 WLAN_STA_CLEAR_PS_FILT,
997 WLAN_STA_MFP,
998 WLAN_STA_BLOCK_BA,
999 --- a/net/mac80211/util.c
1000 +++ b/net/mac80211/util.c
1001 @@ -1612,6 +1612,11 @@ u8 *ieee80211_ie_build_ht_info(u8 *pos,
1002 }
1003 if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
1004 ht_info->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
1005 +
1006 + /*
1007 + * Note: According to 802.11n-2009 9.13.3.1, HT Protection field and
1008 + * RIFS Mode are reserved in IBSS mode, therefore keep them at 0
1009 + */
1010 ht_info->operation_mode = 0x0000;
1011 ht_info->stbc_param = 0x0000;
1012
1013 --- a/net/wireless/chan.c
1014 +++ b/net/wireless/chan.c
1015 @@ -6,6 +6,7 @@
1016 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
1017 */
1018
1019 +#include <linux/export.h>
1020 #include <net/cfg80211.h>
1021 #include "core.h"
1022
1023 @@ -44,9 +45,9 @@ rdev_freq_to_chan(struct cfg80211_regist
1024 return chan;
1025 }
1026
1027 -static bool can_beacon_sec_chan(struct wiphy *wiphy,
1028 - struct ieee80211_channel *chan,
1029 - enum nl80211_channel_type channel_type)
1030 +int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
1031 + struct ieee80211_channel *chan,
1032 + enum nl80211_channel_type channel_type)
1033 {
1034 struct ieee80211_channel *sec_chan;
1035 int diff;
1036 @@ -75,6 +76,7 @@ static bool can_beacon_sec_chan(struct w
1037
1038 return true;
1039 }
1040 +EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan);
1041
1042 int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
1043 struct wireless_dev *wdev, int freq,
1044 @@ -109,8 +111,8 @@ int cfg80211_set_freq(struct cfg80211_re
1045 switch (channel_type) {
1046 case NL80211_CHAN_HT40PLUS:
1047 case NL80211_CHAN_HT40MINUS:
1048 - if (!can_beacon_sec_chan(&rdev->wiphy, chan,
1049 - channel_type)) {
1050 + if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan,
1051 + channel_type)) {
1052 printk(KERN_DEBUG
1053 "cfg80211: Secondary channel not "
1054 "allowed to initiate communication\n");
1055 --- a/net/wireless/nl80211.c
1056 +++ b/net/wireless/nl80211.c
1057 @@ -4684,13 +4684,41 @@ static int nl80211_join_ibss(struct sk_b
1058 ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
1059 }
1060
1061 - ibss.channel = ieee80211_get_channel(wiphy,
1062 - nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
1063 + if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
1064 + enum nl80211_channel_type channel_type;
1065 +
1066 + channel_type = nla_get_u32(
1067 + info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
1068 + if (channel_type != NL80211_CHAN_NO_HT &&
1069 + channel_type != NL80211_CHAN_HT20 &&
1070 + channel_type != NL80211_CHAN_HT40MINUS &&
1071 + channel_type != NL80211_CHAN_HT40PLUS)
1072 + return -EINVAL;
1073 +
1074 + if (channel_type != NL80211_CHAN_NO_HT &&
1075 + !(wiphy->features & NL80211_FEATURE_HT_IBSS))
1076 + return -EINVAL;
1077 +
1078 + ibss.channel_type = channel_type;
1079 + } else {
1080 + ibss.channel_type = NL80211_CHAN_NO_HT;
1081 + }
1082 +
1083 + ibss.channel = rdev_freq_to_chan(rdev,
1084 + nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
1085 + ibss.channel_type);
1086 if (!ibss.channel ||
1087 ibss.channel->flags & IEEE80211_CHAN_NO_IBSS ||
1088 ibss.channel->flags & IEEE80211_CHAN_DISABLED)
1089 return -EINVAL;
1090
1091 + /* Both channels should be able to initiate communication */
1092 + if ((ibss.channel_type == NL80211_CHAN_HT40PLUS ||
1093 + ibss.channel_type == NL80211_CHAN_HT40MINUS) &&
1094 + !cfg80211_can_beacon_sec_chan(&rdev->wiphy, ibss.channel,
1095 + ibss.channel_type))
1096 + return -EINVAL;
1097 +
1098 ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED];
1099 ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
1100