ath9k: merge a pending aggregation fix
[openwrt.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/main.c
2 +++ b/drivers/net/wireless/ath/ath9k/main.c
3 @@ -118,7 +118,7 @@ void ath9k_ps_restore(struct ath_softc *
4 if (--sc->ps_usecount != 0)
5 goto unlock;
6
7 - if (sc->ps_idle)
8 + if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK))
9 mode = ATH9K_PM_FULL_SLEEP;
10 else if (sc->ps_enabled &&
11 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
12 @@ -332,7 +332,8 @@ static int ath_reset_internal(struct ath
13 hchan = ah->curchan;
14 }
15
16 - if (fastcc && !ath9k_hw_check_alive(ah))
17 + if (fastcc && (ah->chip_fullsleep ||
18 + !ath9k_hw_check_alive(ah)))
19 fastcc = false;
20
21 if (!ath_prepare_reset(sc, retry_tx, flush))
22 @@ -882,82 +883,6 @@ chip_reset:
23 #undef SCHED_INTR
24 }
25
26 -static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
27 -{
28 - struct ath_hw *ah = sc->sc_ah;
29 - struct ath_common *common = ath9k_hw_common(ah);
30 - struct ieee80211_channel *channel = hw->conf.channel;
31 - int r;
32 -
33 - ath9k_ps_wakeup(sc);
34 - spin_lock_bh(&sc->sc_pcu_lock);
35 - atomic_set(&ah->intr_ref_cnt, -1);
36 -
37 - ath9k_hw_configpcipowersave(ah, false);
38 -
39 - if (!ah->curchan)
40 - ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah);
41 -
42 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
43 - if (r) {
44 - ath_err(common,
45 - "Unable to reset channel (%u MHz), reset status %d\n",
46 - channel->center_freq, r);
47 - }
48 -
49 - ath_complete_reset(sc, true);
50 -
51 - /* Enable LED */
52 - ath9k_hw_cfg_output(ah, ah->led_pin,
53 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
54 - ath9k_hw_set_gpio(ah, ah->led_pin, 0);
55 -
56 - spin_unlock_bh(&sc->sc_pcu_lock);
57 -
58 - ath9k_ps_restore(sc);
59 -}
60 -
61 -void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
62 -{
63 - struct ath_hw *ah = sc->sc_ah;
64 - struct ieee80211_channel *channel = hw->conf.channel;
65 - int r;
66 -
67 - ath9k_ps_wakeup(sc);
68 -
69 - ath_cancel_work(sc);
70 -
71 - spin_lock_bh(&sc->sc_pcu_lock);
72 -
73 - /*
74 - * Keep the LED on when the radio is disabled
75 - * during idle unassociated state.
76 - */
77 - if (!sc->ps_idle) {
78 - ath9k_hw_set_gpio(ah, ah->led_pin, 1);
79 - ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
80 - }
81 -
82 - ath_prepare_reset(sc, false, true);
83 -
84 - if (!ah->curchan)
85 - ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
86 -
87 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
88 - if (r) {
89 - ath_err(ath9k_hw_common(sc->sc_ah),
90 - "Unable to reset channel (%u MHz), reset status %d\n",
91 - channel->center_freq, r);
92 - }
93 -
94 - ath9k_hw_phy_disable(ah);
95 -
96 - ath9k_hw_configpcipowersave(ah, true);
97 -
98 - spin_unlock_bh(&sc->sc_pcu_lock);
99 - ath9k_ps_restore(sc);
100 -}
101 -
102 static int ath_reset(struct ath_softc *sc, bool retry_tx)
103 {
104 int r;
105 @@ -1093,6 +1018,9 @@ static int ath9k_start(struct ieee80211_
106 * and then setup of the interrupt mask.
107 */
108 spin_lock_bh(&sc->sc_pcu_lock);
109 +
110 + atomic_set(&ah->intr_ref_cnt, -1);
111 +
112 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
113 if (r) {
114 ath_err(common,
115 @@ -1131,6 +1059,18 @@ static int ath9k_start(struct ieee80211_
116 goto mutex_unlock;
117 }
118
119 + if (ah->led_pin >= 0) {
120 + ath9k_hw_cfg_output(ah, ah->led_pin,
121 + AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
122 + ath9k_hw_set_gpio(ah, ah->led_pin, 0);
123 + }
124 +
125 + /*
126 + * Reset key cache to sane defaults (all entries cleared) instead of
127 + * semi-random values after suspend/resume.
128 + */
129 + ath9k_cmn_init_crypto(sc->sc_ah);
130 +
131 spin_unlock_bh(&sc->sc_pcu_lock);
132
133 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
134 @@ -1176,6 +1116,13 @@ static void ath9k_tx(struct ieee80211_hw
135 }
136 }
137
138 + /*
139 + * Cannot tx while the hardware is in full sleep, it first needs a full
140 + * chip reset to recover from that
141 + */
142 + if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP))
143 + goto exit;
144 +
145 if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
146 /*
147 * We are using PS-Poll and mac80211 can request TX while in
148 @@ -1222,6 +1169,7 @@ static void ath9k_stop(struct ieee80211_
149 struct ath_softc *sc = hw->priv;
150 struct ath_hw *ah = sc->sc_ah;
151 struct ath_common *common = ath9k_hw_common(ah);
152 + bool prev_idle;
153
154 mutex_lock(&sc->mutex);
155
156 @@ -1252,35 +1200,45 @@ static void ath9k_stop(struct ieee80211_
157 * before setting the invalid flag. */
158 ath9k_hw_disable_interrupts(ah);
159
160 - if (!(sc->sc_flags & SC_OP_INVALID)) {
161 - ath_drain_all_txq(sc, false);
162 - ath_stoprecv(sc);
163 - ath9k_hw_phy_disable(ah);
164 - } else
165 - sc->rx.rxlink = NULL;
166 + spin_unlock_bh(&sc->sc_pcu_lock);
167 +
168 + /* we can now sync irq and kill any running tasklets, since we already
169 + * disabled interrupts and not holding a spin lock */
170 + synchronize_irq(sc->irq);
171 + tasklet_kill(&sc->intr_tq);
172 + tasklet_kill(&sc->bcon_tasklet);
173 +
174 + prev_idle = sc->ps_idle;
175 + sc->ps_idle = true;
176 +
177 + spin_lock_bh(&sc->sc_pcu_lock);
178 +
179 + if (ah->led_pin >= 0) {
180 + ath9k_hw_set_gpio(ah, ah->led_pin, 1);
181 + ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
182 + }
183 +
184 + ath_prepare_reset(sc, false, true);
185
186 if (sc->rx.frag) {
187 dev_kfree_skb_any(sc->rx.frag);
188 sc->rx.frag = NULL;
189 }
190
191 - /* disable HAL and put h/w to sleep */
192 - ath9k_hw_disable(ah);
193 + if (!ah->curchan)
194 + ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
195
196 - spin_unlock_bh(&sc->sc_pcu_lock);
197 + ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
198 + ath9k_hw_phy_disable(ah);
199
200 - /* we can now sync irq and kill any running tasklets, since we already
201 - * disabled interrupts and not holding a spin lock */
202 - synchronize_irq(sc->irq);
203 - tasklet_kill(&sc->intr_tq);
204 - tasklet_kill(&sc->bcon_tasklet);
205 + ath9k_hw_configpcipowersave(ah, true);
206
207 - ath9k_ps_restore(sc);
208 + spin_unlock_bh(&sc->sc_pcu_lock);
209
210 - sc->ps_idle = true;
211 - ath_radio_disable(sc, hw);
212 + ath9k_ps_restore(sc);
213
214 sc->sc_flags |= SC_OP_INVALID;
215 + sc->ps_idle = prev_idle;
216
217 mutex_unlock(&sc->mutex);
218
219 @@ -1620,8 +1578,8 @@ static int ath9k_config(struct ieee80211
220 struct ath_hw *ah = sc->sc_ah;
221 struct ath_common *common = ath9k_hw_common(ah);
222 struct ieee80211_conf *conf = &hw->conf;
223 - bool disable_radio = false;
224
225 + ath9k_ps_wakeup(sc);
226 mutex_lock(&sc->mutex);
227
228 /*
229 @@ -1632,13 +1590,8 @@ static int ath9k_config(struct ieee80211
230 */
231 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
232 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
233 - if (!sc->ps_idle) {
234 - ath_radio_enable(sc, hw);
235 - ath_dbg(common, ATH_DBG_CONFIG,
236 - "not-idle: enabling radio\n");
237 - } else {
238 - disable_radio = true;
239 - }
240 + if (sc->ps_idle)
241 + ath_cancel_work(sc);
242 }
243
244 /*
245 @@ -1745,18 +1698,12 @@ static int ath9k_config(struct ieee80211
246 ath_dbg(common, ATH_DBG_CONFIG,
247 "Set power: %d\n", conf->power_level);
248 sc->config.txpowlimit = 2 * conf->power_level;
249 - ath9k_ps_wakeup(sc);
250 ath9k_cmn_update_txpow(ah, sc->curtxpow,
251 sc->config.txpowlimit, &sc->curtxpow);
252 - ath9k_ps_restore(sc);
253 - }
254 -
255 - if (disable_radio) {
256 - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
257 - ath_radio_disable(sc, hw);
258 }
259
260 mutex_unlock(&sc->mutex);
261 + ath9k_ps_restore(sc);
262
263 return 0;
264 }
265 @@ -2324,9 +2271,6 @@ static void ath9k_flush(struct ieee80211
266 return;
267 }
268
269 - if (drop)
270 - timeout = 1;
271 -
272 for (j = 0; j < timeout; j++) {
273 bool npend = false;
274
275 @@ -2344,21 +2288,22 @@ static void ath9k_flush(struct ieee80211
276 }
277
278 if (!npend)
279 - goto out;
280 + break;
281 }
282
283 - ath9k_ps_wakeup(sc);
284 - spin_lock_bh(&sc->sc_pcu_lock);
285 - drain_txq = ath_drain_all_txq(sc, false);
286 - spin_unlock_bh(&sc->sc_pcu_lock);
287 + if (drop) {
288 + ath9k_ps_wakeup(sc);
289 + spin_lock_bh(&sc->sc_pcu_lock);
290 + drain_txq = ath_drain_all_txq(sc, false);
291 + spin_unlock_bh(&sc->sc_pcu_lock);
292
293 - if (!drain_txq)
294 - ath_reset(sc, false);
295 + if (!drain_txq)
296 + ath_reset(sc, false);
297
298 - ath9k_ps_restore(sc);
299 - ieee80211_wake_queues(hw);
300 + ath9k_ps_restore(sc);
301 + ieee80211_wake_queues(hw);
302 + }
303
304 -out:
305 ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0);
306 mutex_unlock(&sc->mutex);
307 }
308 --- a/drivers/net/wireless/ath/ath9k/pci.c
309 +++ b/drivers/net/wireless/ath/ath9k/pci.c
310 @@ -307,12 +307,11 @@ static int ath_pci_suspend(struct device
311 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
312 struct ath_softc *sc = hw->priv;
313
314 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
315 -
316 /* The device has to be moved to FULLSLEEP forcibly.
317 * Otherwise the chip never moved to full sleep,
318 * when no interface is up.
319 */
320 + ath9k_hw_disable(sc->sc_ah);
321 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
322
323 return 0;
324 @@ -334,22 +333,6 @@ static int ath_pci_resume(struct device
325 if ((val & 0x0000ff00) != 0)
326 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
327
328 - ath9k_ps_wakeup(sc);
329 - /* Enable LED */
330 - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
331 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
332 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
333 -
334 - /*
335 - * Reset key cache to sane defaults (all entries cleared) instead of
336 - * semi-random values after suspend/resume.
337 - */
338 - ath9k_cmn_init_crypto(sc->sc_ah);
339 - ath9k_ps_restore(sc);
340 -
341 - sc->ps_idle = true;
342 - ath_radio_disable(sc, hw);
343 -
344 return 0;
345 }
346
347 --- a/drivers/net/wireless/ath/ath9k/xmit.c
348 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
349 @@ -179,6 +179,11 @@ static void ath_tx_flush_tid(struct ath_
350 spin_lock_bh(&txq->axq_lock);
351 }
352
353 + if (tid->baw_head == tid->baw_tail) {
354 + tid->state &= ~AGGR_ADDBA_COMPLETE;
355 + tid->state &= ~AGGR_CLEANUP;
356 + }
357 +
358 spin_unlock_bh(&txq->axq_lock);
359 }
360
361 @@ -556,15 +561,9 @@ static void ath_tx_complete_aggr(struct
362 spin_unlock_bh(&txq->axq_lock);
363 }
364
365 - if (tid->state & AGGR_CLEANUP) {
366 + if (tid->state & AGGR_CLEANUP)
367 ath_tx_flush_tid(sc, tid);
368
369 - if (tid->baw_head == tid->baw_tail) {
370 - tid->state &= ~AGGR_ADDBA_COMPLETE;
371 - tid->state &= ~AGGR_CLEANUP;
372 - }
373 - }
374 -
375 rcu_read_unlock();
376
377 if (needreset) {
378 @@ -1955,7 +1954,7 @@ static void ath_tx_complete(struct ath_s
379 skb_pull(skb, padsize);
380 }
381
382 - if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) {
383 + if ((sc->ps_flags & PS_WAIT_FOR_TX_ACK) && !txq->axq_depth) {
384 sc->ps_flags &= ~PS_WAIT_FOR_TX_ACK;
385 ath_dbg(common, ATH_DBG_PS,
386 "Going back to sleep after having received TX status (0x%lx)\n",
387 --- a/include/net/cfg80211.h
388 +++ b/include/net/cfg80211.h
389 @@ -1130,6 +1130,7 @@ struct cfg80211_ibss_params {
390 u8 *ssid;
391 u8 *bssid;
392 struct ieee80211_channel *channel;
393 + enum nl80211_channel_type channel_type;
394 u8 *ie;
395 u8 ssid_len, ie_len;
396 u16 beacon_interval;
397 @@ -3292,6 +3293,16 @@ void cfg80211_report_obss_beacon(struct
398 const u8 *frame, size_t len,
399 int freq, gfp_t gfp);
400
401 +/**
402 + * cfg80211_can_use_ext_chan - test if ht40 on extension channel can be used
403 + * @wiphy: the wiphy
404 + * @chan: main channel
405 + * @channel_type: HT mode
406 + */
407 +bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
408 + struct ieee80211_channel *chan,
409 + enum nl80211_channel_type channel_type);
410 +
411 /* Logging, debugging and troubleshooting/diagnostic helpers. */
412
413 /* wiphy_printk helpers, similar to dev_printk */
414 --- a/net/mac80211/agg-rx.c
415 +++ b/net/mac80211/agg-rx.c
416 @@ -182,6 +182,10 @@ static void ieee80211_send_addba_resp(st
417 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
418 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
419 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
420 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
421 + memcpy(mgmt->bssid, da, ETH_ALEN);
422 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
423 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
424
425 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
426 IEEE80211_STYPE_ACTION);
427 --- a/net/mac80211/agg-tx.c
428 +++ b/net/mac80211/agg-tx.c
429 @@ -79,10 +79,13 @@ static void ieee80211_send_addba_request
430 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
431 if (sdata->vif.type == NL80211_IFTYPE_AP ||
432 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
433 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
434 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
435 + sdata->vif.type == NL80211_IFTYPE_WDS)
436 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
437 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
438 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
439 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
440 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
441
442 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
443 IEEE80211_STYPE_ACTION);
444 @@ -394,7 +397,9 @@ int ieee80211_start_tx_ba_session(struct
445 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
446 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
447 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
448 - sdata->vif.type != NL80211_IFTYPE_AP)
449 + sdata->vif.type != NL80211_IFTYPE_AP &&
450 + sdata->vif.type != NL80211_IFTYPE_ADHOC &&
451 + sdata->vif.type != NL80211_IFTYPE_WDS)
452 return -EINVAL;
453
454 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
455 --- a/net/mac80211/debugfs_sta.c
456 +++ b/net/mac80211/debugfs_sta.c
457 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
458 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
459
460 int res = scnprintf(buf, sizeof(buf),
461 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
462 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
463 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
464 TEST(PS_DRIVER), TEST(AUTHORIZED),
465 TEST(SHORT_PREAMBLE), TEST(ASSOC_AP),
466 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
467 + TEST(WME), TEST(CLEAR_PS_FILT),
468 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
469 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
470 TEST(TDLS_PEER_AUTH));
471 --- a/net/mac80211/ht.c
472 +++ b/net/mac80211/ht.c
473 @@ -201,6 +201,8 @@ void ieee80211_send_delba(struct ieee802
474 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
475 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
476 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
477 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
478 + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
479
480 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
481 IEEE80211_STYPE_ACTION);
482 --- a/net/mac80211/ibss.c
483 +++ b/net/mac80211/ibss.c
484 @@ -77,6 +77,7 @@ static void __ieee80211_sta_join_ibss(st
485 struct cfg80211_bss *bss;
486 u32 bss_change;
487 u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
488 + enum nl80211_channel_type channel_type;
489
490 lockdep_assert_held(&ifibss->mtx);
491
492 @@ -105,8 +106,16 @@ static void __ieee80211_sta_join_ibss(st
493
494 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
495
496 - local->oper_channel = chan;
497 - WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT));
498 + channel_type = ifibss->channel_type;
499 + if (channel_type > NL80211_CHAN_HT20 &&
500 + !cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
501 + channel_type = NL80211_CHAN_HT20;
502 + if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
503 + /* can only fail due to HT40+/- mismatch */
504 + channel_type = NL80211_CHAN_HT20;
505 + WARN_ON(!ieee80211_set_channel_type(local, sdata,
506 + NL80211_CHAN_HT20));
507 + }
508 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
509
510 sband = local->hw.wiphy->bands[chan->band];
511 @@ -172,6 +181,18 @@ static void __ieee80211_sta_join_ibss(st
512 memcpy(skb_put(skb, ifibss->ie_len),
513 ifibss->ie, ifibss->ie_len);
514
515 + /* add HT capability and information IEs */
516 + if (channel_type && sband->ht_cap.ht_supported) {
517 + pos = skb_put(skb, 4 +
518 + sizeof(struct ieee80211_ht_cap) +
519 + sizeof(struct ieee80211_ht_info));
520 + pos = ieee80211_ie_build_ht_cap(pos, sband, sband->ht_cap.cap);
521 + pos = ieee80211_ie_build_ht_info(pos,
522 + &sband->ht_cap,
523 + chan,
524 + channel_type);
525 + }
526 +
527 if (local->hw.queues >= 4) {
528 pos = skb_put(skb, 9);
529 *pos++ = WLAN_EID_VENDOR_SPECIFIC;
530 @@ -195,6 +216,7 @@ static void __ieee80211_sta_join_ibss(st
531 bss_change |= BSS_CHANGED_BEACON;
532 bss_change |= BSS_CHANGED_BEACON_ENABLED;
533 bss_change |= BSS_CHANGED_BASIC_RATES;
534 + bss_change |= BSS_CHANGED_HT;
535 bss_change |= BSS_CHANGED_IBSS;
536 sdata->vif.bss_conf.ibss_joined = true;
537 ieee80211_bss_info_change_notify(sdata, bss_change);
538 @@ -268,6 +290,7 @@ static void ieee80211_rx_bss_info(struct
539 u64 beacon_timestamp, rx_timestamp;
540 u32 supp_rates = 0;
541 enum ieee80211_band band = rx_status->band;
542 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
543
544 if (elems->ds_params && elems->ds_params_len == 1)
545 freq = ieee80211_channel_to_frequency(elems->ds_params[0],
546 @@ -277,7 +300,10 @@ static void ieee80211_rx_bss_info(struct
547
548 channel = ieee80211_get_channel(local->hw.wiphy, freq);
549
550 - if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
551 + if (!channel ||
552 + channel->flags & (IEEE80211_CHAN_DISABLED ||
553 + IEEE80211_CHAN_NO_IBSS ||
554 + IEEE80211_CHAN_RADAR))
555 return;
556
557 if (sdata->vif.type == NL80211_IFTYPE_ADHOC &&
558 @@ -315,8 +341,41 @@ static void ieee80211_rx_bss_info(struct
559 GFP_ATOMIC);
560 }
561
562 - if (sta && elems->wmm_info)
563 - set_sta_flag(sta, WLAN_STA_WME);
564 + if (sta) {
565 + if (elems->wmm_info)
566 + set_sta_flag(sta, WLAN_STA_WME);
567 +
568 + /* we both use HT */
569 + if (elems->ht_info_elem && elems->ht_cap_elem &&
570 + sdata->u.ibss.channel_type) {
571 + enum nl80211_channel_type channel_type =
572 + ieee80211_ht_info_to_channel_type(
573 + elems->ht_info_elem);
574 + struct ieee80211_sta_ht_cap sta_ht_cap_new;
575 +
576 + /*
577 + * fall back to HT20 if we don't use or use
578 + * the other extension channel
579 + */
580 + if (channel_type > NL80211_CHAN_HT20 &&
581 + channel_type != sdata->u.ibss.channel_type)
582 + channel_type = NL80211_CHAN_HT20;
583 +
584 + ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
585 + elems->ht_cap_elem,
586 + &sta_ht_cap_new);
587 + if (memcmp(&sta->sta.ht_cap, &sta_ht_cap_new,
588 + sizeof(sta_ht_cap_new))) {
589 + memcpy(&sta->sta.ht_cap,
590 + &sta_ht_cap_new,
591 + sizeof(sta_ht_cap_new));
592 + rate_control_rate_update(local, sband,
593 + sta,
594 + IEEE80211_RC_HT_CHANGED,
595 + channel_type);
596 + }
597 + }
598 + }
599
600 rcu_read_unlock();
601 }
602 @@ -898,10 +957,15 @@ int ieee80211_ibss_join(struct ieee80211
603 struct sk_buff *skb;
604
605 skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom +
606 - 36 /* bitrates */ +
607 - 34 /* SSID */ +
608 - 3 /* DS params */ +
609 - 4 /* IBSS params */ +
610 + sizeof(struct ieee80211_hdr_3addr) +
611 + 12 /* struct ieee80211_mgmt.u.beacon */ +
612 + 2 + IEEE80211_MAX_SSID_LEN /* max SSID */ +
613 + 2 + 8 /* max Supported Rates */ +
614 + 3 /* max DS params */ +
615 + 4 /* IBSS params */ +
616 + 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
617 + 2 + sizeof(struct ieee80211_ht_cap) +
618 + 2 + sizeof(struct ieee80211_ht_info) +
619 params->ie_len);
620 if (!skb)
621 return -ENOMEM;
622 @@ -922,13 +986,15 @@ int ieee80211_ibss_join(struct ieee80211
623 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
624
625 sdata->u.ibss.channel = params->channel;
626 + sdata->u.ibss.channel_type = params->channel_type;
627 sdata->u.ibss.fixed_channel = params->channel_fixed;
628
629 /* fix ourselves to that channel now already */
630 if (params->channel_fixed) {
631 sdata->local->oper_channel = params->channel;
632 - WARN_ON(!ieee80211_set_channel_type(sdata->local, sdata,
633 - NL80211_CHAN_NO_HT));
634 + if (!ieee80211_set_channel_type(sdata->local, sdata,
635 + params->channel_type))
636 + return -EINVAL;
637 }
638
639 if (params->ie) {
640 --- a/net/mac80211/ieee80211_i.h
641 +++ b/net/mac80211/ieee80211_i.h
642 @@ -470,6 +470,7 @@ struct ieee80211_if_ibss {
643 u8 ssid_len, ie_len;
644 u8 *ie;
645 struct ieee80211_channel *channel;
646 + enum nl80211_channel_type channel_type;
647
648 unsigned long ibss_join_req;
649 /* probe response/beacon for IBSS */
650 --- a/net/mac80211/iface.c
651 +++ b/net/mac80211/iface.c
652 @@ -178,7 +178,6 @@ static int ieee80211_do_open(struct net_
653 {
654 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
655 struct ieee80211_local *local = sdata->local;
656 - struct sta_info *sta;
657 u32 changed = 0;
658 int res;
659 u32 hw_reconf_flags = 0;
660 @@ -309,27 +308,6 @@ static int ieee80211_do_open(struct net_
661
662 set_bit(SDATA_STATE_RUNNING, &sdata->state);
663
664 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
665 - /* Create STA entry for the WDS peer */
666 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
667 - GFP_KERNEL);
668 - if (!sta) {
669 - res = -ENOMEM;
670 - goto err_del_interface;
671 - }
672 -
673 - /* no atomic bitop required since STA is not live yet */
674 - set_sta_flag(sta, WLAN_STA_AUTHORIZED);
675 -
676 - res = sta_info_insert(sta);
677 - if (res) {
678 - /* STA has been freed */
679 - goto err_del_interface;
680 - }
681 -
682 - rate_control_rate_init(sta);
683 - }
684 -
685 /*
686 * set_multicast_list will be invoked by the networking core
687 * which will check whether any increments here were done in
688 @@ -356,8 +334,7 @@ static int ieee80211_do_open(struct net_
689 netif_tx_start_all_queues(dev);
690
691 return 0;
692 - err_del_interface:
693 - drv_remove_interface(local, sdata);
694 +
695 err_stop:
696 if (!local->open_count)
697 drv_stop(local);
698 @@ -732,6 +709,70 @@ static void ieee80211_if_setup(struct ne
699 dev->destructor = free_netdev;
700 }
701
702 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
703 + struct sk_buff *skb)
704 +{
705 + struct ieee80211_local *local = sdata->local;
706 + struct ieee80211_rx_status *rx_status;
707 + struct ieee802_11_elems elems;
708 + struct ieee80211_mgmt *mgmt;
709 + struct sta_info *sta;
710 + size_t baselen;
711 + u32 rates = 0;
712 + u16 stype;
713 + bool new = false;
714 + enum ieee80211_band band = local->hw.conf.channel->band;
715 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
716 +
717 + rx_status = IEEE80211_SKB_RXCB(skb);
718 + mgmt = (struct ieee80211_mgmt *) skb->data;
719 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
720 +
721 + if (stype != IEEE80211_STYPE_BEACON)
722 + return;
723 +
724 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
725 + if (baselen > skb->len)
726 + return;
727 +
728 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
729 + skb->len - baselen, &elems);
730 +
731 + rates = ieee80211_sta_get_rates(local, &elems, band);
732 +
733 + rcu_read_lock();
734 +
735 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
736 +
737 + if (!sta) {
738 + rcu_read_unlock();
739 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
740 + GFP_KERNEL);
741 + if (!sta)
742 + return;
743 +
744 + new = true;
745 + }
746 +
747 + sta->last_rx = jiffies;
748 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
749 +
750 + if (elems.ht_cap_elem)
751 + ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
752 + elems.ht_cap_elem, &sta->sta.ht_cap);
753 +
754 + if (elems.wmm_param)
755 + set_sta_flag(sta, WLAN_STA_WME);
756 +
757 + if (new) {
758 + set_sta_flag(sta, WLAN_STA_AUTHORIZED);
759 + rate_control_rate_init(sta);
760 + sta_info_insert_rcu(sta);
761 + }
762 +
763 + rcu_read_unlock();
764 +}
765 +
766 static void ieee80211_iface_work(struct work_struct *work)
767 {
768 struct ieee80211_sub_if_data *sdata =
769 @@ -836,6 +877,9 @@ static void ieee80211_iface_work(struct
770 break;
771 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
772 break;
773 + case NL80211_IFTYPE_WDS:
774 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
775 + break;
776 default:
777 WARN(1, "frame for unexpected interface type");
778 break;
779 --- a/net/mac80211/mlme.c
780 +++ b/net/mac80211/mlme.c
781 @@ -1359,9 +1359,6 @@ static void __ieee80211_connection_loss(
782 ieee80211_set_disassoc(sdata, true, true);
783 mutex_unlock(&ifmgd->mtx);
784
785 - mutex_lock(&local->mtx);
786 - ieee80211_recalc_idle(local);
787 - mutex_unlock(&local->mtx);
788 /*
789 * must be outside lock due to cfg80211,
790 * but that's not a problem.
791 @@ -1370,6 +1367,10 @@ static void __ieee80211_connection_loss(
792 IEEE80211_STYPE_DEAUTH,
793 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY,
794 NULL, true);
795 +
796 + mutex_lock(&local->mtx);
797 + ieee80211_recalc_idle(local);
798 + mutex_unlock(&local->mtx);
799 }
800
801 void ieee80211_beacon_connection_loss_work(struct work_struct *work)
802 @@ -2136,9 +2137,6 @@ static void ieee80211_sta_connection_los
803
804 ieee80211_set_disassoc(sdata, true, true);
805 mutex_unlock(&ifmgd->mtx);
806 - mutex_lock(&local->mtx);
807 - ieee80211_recalc_idle(local);
808 - mutex_unlock(&local->mtx);
809 /*
810 * must be outside lock due to cfg80211,
811 * but that's not a problem.
812 @@ -2146,6 +2144,11 @@ static void ieee80211_sta_connection_los
813 ieee80211_send_deauth_disassoc(sdata, bssid,
814 IEEE80211_STYPE_DEAUTH, reason,
815 NULL, true);
816 +
817 + mutex_lock(&local->mtx);
818 + ieee80211_recalc_idle(local);
819 + mutex_unlock(&local->mtx);
820 +
821 mutex_lock(&ifmgd->mtx);
822 }
823
824 --- a/net/mac80211/offchannel.c
825 +++ b/net/mac80211/offchannel.c
826 @@ -212,8 +212,6 @@ static void ieee80211_hw_roc_start(struc
827 return;
828 }
829
830 - ieee80211_recalc_idle(local);
831 -
832 if (local->hw_roc_skb) {
833 sdata = IEEE80211_DEV_TO_SUB_IF(local->hw_roc_dev);
834 ieee80211_tx_skb(sdata, local->hw_roc_skb);
835 @@ -227,6 +225,8 @@ static void ieee80211_hw_roc_start(struc
836 GFP_KERNEL);
837 }
838
839 + ieee80211_recalc_idle(local);
840 +
841 mutex_unlock(&local->mtx);
842 }
843
844 --- a/net/mac80211/rx.c
845 +++ b/net/mac80211/rx.c
846 @@ -2250,7 +2250,9 @@ ieee80211_rx_h_action(struct ieee80211_r
847 if (sdata->vif.type != NL80211_IFTYPE_STATION &&
848 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
849 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
850 - sdata->vif.type != NL80211_IFTYPE_AP)
851 + sdata->vif.type != NL80211_IFTYPE_AP &&
852 + sdata->vif.type != NL80211_IFTYPE_ADHOC &&
853 + sdata->vif.type != NL80211_IFTYPE_WDS)
854 break;
855
856 /* verify action_code is present */
857 @@ -2465,13 +2467,14 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
858
859 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
860 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
861 - sdata->vif.type != NL80211_IFTYPE_STATION)
862 + sdata->vif.type != NL80211_IFTYPE_STATION &&
863 + sdata->vif.type != NL80211_IFTYPE_WDS)
864 return RX_DROP_MONITOR;
865
866 switch (stype) {
867 case cpu_to_le16(IEEE80211_STYPE_BEACON):
868 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
869 - /* process for all: mesh, mlme, ibss */
870 + /* process for all: mesh, mlme, ibss, wds */
871 break;
872 case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
873 case cpu_to_le16(IEEE80211_STYPE_DISASSOC):
874 @@ -2818,10 +2821,16 @@ static int prepare_for_handlers(struct i
875 }
876 break;
877 case NL80211_IFTYPE_WDS:
878 - if (bssid || !ieee80211_is_data(hdr->frame_control))
879 - return 0;
880 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
881 return 0;
882 +
883 + if (ieee80211_is_data(hdr->frame_control) ||
884 + ieee80211_is_action(hdr->frame_control)) {
885 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
886 + return 0;
887 + } else if (!ieee80211_is_beacon(hdr->frame_control))
888 + return 0;
889 +
890 break;
891 default:
892 /* should never get here */
893 --- a/net/mac80211/sta_info.h
894 +++ b/net/mac80211/sta_info.h
895 @@ -32,7 +32,6 @@
896 * frames.
897 * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP.
898 * @WLAN_STA_WME: Station is a QoS-STA.
899 - * @WLAN_STA_WDS: Station is one of our WDS peers.
900 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
901 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
902 * frame to this station is transmitted.
903 @@ -62,7 +61,6 @@ enum ieee80211_sta_info_flags {
904 WLAN_STA_SHORT_PREAMBLE,
905 WLAN_STA_ASSOC_AP,
906 WLAN_STA_WME,
907 - WLAN_STA_WDS,
908 WLAN_STA_CLEAR_PS_FILT,
909 WLAN_STA_MFP,
910 WLAN_STA_BLOCK_BA,
911 --- a/net/wireless/chan.c
912 +++ b/net/wireless/chan.c
913 @@ -44,9 +44,9 @@ rdev_freq_to_chan(struct cfg80211_regist
914 return chan;
915 }
916
917 -static bool can_beacon_sec_chan(struct wiphy *wiphy,
918 - struct ieee80211_channel *chan,
919 - enum nl80211_channel_type channel_type)
920 +bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
921 + struct ieee80211_channel *chan,
922 + enum nl80211_channel_type channel_type)
923 {
924 struct ieee80211_channel *sec_chan;
925 int diff;
926 @@ -75,6 +75,7 @@ static bool can_beacon_sec_chan(struct w
927
928 return true;
929 }
930 +EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan);
931
932 int cfg80211_set_freq(struct cfg80211_registered_device *rdev,
933 struct wireless_dev *wdev, int freq,
934 @@ -109,8 +110,8 @@ int cfg80211_set_freq(struct cfg80211_re
935 switch (channel_type) {
936 case NL80211_CHAN_HT40PLUS:
937 case NL80211_CHAN_HT40MINUS:
938 - if (!can_beacon_sec_chan(&rdev->wiphy, chan,
939 - channel_type)) {
940 + if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan,
941 + channel_type)) {
942 printk(KERN_DEBUG
943 "cfg80211: Secondary channel not "
944 "allowed to initiate communication\n");
945 --- a/net/wireless/nl80211.c
946 +++ b/net/wireless/nl80211.c
947 @@ -4604,13 +4604,34 @@ static int nl80211_join_ibss(struct sk_b
948 ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
949 }
950
951 - ibss.channel = ieee80211_get_channel(wiphy,
952 - nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
953 + if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
954 + enum nl80211_channel_type channel_type;
955 +
956 + channel_type = nla_get_u32(
957 + info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
958 + if (channel_type > NL80211_CHAN_HT40PLUS)
959 + return -EINVAL;
960 + ibss.channel_type = channel_type;
961 + } else {
962 + ibss.channel_type = NL80211_CHAN_NO_HT;
963 + }
964 +
965 + ibss.channel = rdev_freq_to_chan(rdev,
966 + nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
967 + ibss.channel_type);
968 if (!ibss.channel ||
969 + ibss.channel->flags & IEEE80211_CHAN_RADAR ||
970 ibss.channel->flags & IEEE80211_CHAN_NO_IBSS ||
971 ibss.channel->flags & IEEE80211_CHAN_DISABLED)
972 return -EINVAL;
973
974 + /* Both channels should be able to initiate communication */
975 + if ((ibss.channel_type == NL80211_CHAN_HT40PLUS ||
976 + ibss.channel_type == NL80211_CHAN_HT40MINUS) &&
977 + !cfg80211_can_beacon_sec_chan(&rdev->wiphy, ibss.channel,
978 + ibss.channel_type))
979 + return -EINVAL;
980 +
981 ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED];
982 ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
983
This page took 0.087866 seconds and 5 git commands to generate.