mac80211: update to latest version, fix tx gain patch
[openwrt/staging/dedeckeh.git] / package / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -360,7 +360,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
4
5 struct ath_vif {
6 int av_bslot;
7 - bool is_bslot_active, primary_sta_vif;
8 + bool primary_sta_vif;
9 __le64 tsf_adjust; /* TSF adjustment for staggered beacons */
10 struct ath_buf *av_bcbuf;
11 };
12 @@ -386,6 +386,7 @@ struct ath_beacon_config {
13 u16 dtim_period;
14 u16 bmiss_timeout;
15 u8 dtim_count;
16 + bool enable_beacon;
17 };
18
19 struct ath_beacon {
20 @@ -397,7 +398,6 @@ struct ath_beacon {
21
22 u32 beaconq;
23 u32 bmisscnt;
24 - u32 ast_be_xmit;
25 u32 bc_tstamp;
26 struct ieee80211_vif *bslot[ATH_BCBUF];
27 int slottime;
28 @@ -411,12 +411,14 @@ struct ath_beacon {
29 bool tx_last;
30 };
31
32 -void ath_beacon_tasklet(unsigned long data);
33 -void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif);
34 -int ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_vif *vif);
35 -void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp);
36 -int ath_beaconq_config(struct ath_softc *sc);
37 -void ath_set_beacon(struct ath_softc *sc);
38 +void ath9k_beacon_tasklet(unsigned long data);
39 +bool ath9k_allow_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif);
40 +void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif,
41 + u32 changed);
42 +void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif);
43 +void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif);
44 +void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif);
45 +void ath9k_set_beacon(struct ath_softc *sc);
46 void ath9k_set_beaconing_status(struct ath_softc *sc, bool status);
47
48 /*******************/
49 @@ -442,9 +444,12 @@ void ath_rx_poll(unsigned long data);
50 void ath_start_rx_poll(struct ath_softc *sc, u8 nbeacon);
51 void ath_paprd_calibrate(struct work_struct *work);
52 void ath_ani_calibrate(unsigned long data);
53 -void ath_start_ani(struct ath_common *common);
54 +void ath_start_ani(struct ath_softc *sc);
55 +void ath_stop_ani(struct ath_softc *sc);
56 +void ath_check_ani(struct ath_softc *sc);
57 int ath_update_survey_stats(struct ath_softc *sc);
58 void ath_update_survey_nf(struct ath_softc *sc, int channel);
59 +void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type);
60
61 /**********/
62 /* BTCOEX */
63 @@ -613,7 +618,6 @@ enum sc_op_flags {
64 SC_OP_INVALID,
65 SC_OP_BEACONS,
66 SC_OP_RXFLUSH,
67 - SC_OP_TSF_RESET,
68 SC_OP_ANI_RUN,
69 SC_OP_PRIM_STA_VIF,
70 SC_OP_HW_RESET,
71 --- a/drivers/net/wireless/ath/ath9k/beacon.c
72 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
73 @@ -30,7 +30,7 @@ static void ath9k_reset_beacon_status(st
74 * the operating mode of the station (AP or AdHoc). Parameters are AIFS
75 * settings and channel width min/max
76 */
77 -int ath_beaconq_config(struct ath_softc *sc)
78 +static void ath9k_beaconq_config(struct ath_softc *sc)
79 {
80 struct ath_hw *ah = sc->sc_ah;
81 struct ath_common *common = ath9k_hw_common(ah);
82 @@ -38,6 +38,7 @@ int ath_beaconq_config(struct ath_softc
83 struct ath_txq *txq;
84
85 ath9k_hw_get_txq_props(ah, sc->beacon.beaconq, &qi);
86 +
87 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
88 /* Always burst out beacon and CAB traffic. */
89 qi.tqi_aifs = 1;
90 @@ -56,12 +57,9 @@ int ath_beaconq_config(struct ath_softc
91 }
92
93 if (!ath9k_hw_set_txq_props(ah, sc->beacon.beaconq, &qi)) {
94 - ath_err(common,
95 - "Unable to update h/w beacon queue parameters\n");
96 - return 0;
97 + ath_err(common, "Unable to update h/w beacon queue parameters\n");
98 } else {
99 ath9k_hw_resettxqueue(ah, sc->beacon.beaconq);
100 - return 1;
101 }
102 }
103
104 @@ -70,7 +68,7 @@ int ath_beaconq_config(struct ath_softc
105 * up rate codes, and channel flags. Beacons are always sent out at the
106 * lowest rate, and are not retried.
107 */
108 -static void ath_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
109 +static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
110 struct ath_buf *bf, int rateidx)
111 {
112 struct sk_buff *skb = bf->bf_mpdu;
113 @@ -81,8 +79,6 @@ static void ath_beacon_setup(struct ath_
114 u8 chainmask = ah->txchainmask;
115 u8 rate = 0;
116
117 - ath9k_reset_beacon_status(sc);
118 -
119 sband = &sc->sbands[common->hw->conf.channel->band];
120 rate = sband->bitrates[rateidx].hw_value;
121 if (vif->bss_conf.use_short_preamble)
122 @@ -111,7 +107,7 @@ static void ath_beacon_setup(struct ath_
123 ath9k_hw_set_txdesc(ah, bf->bf_desc, &info);
124 }
125
126 -static void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
127 +static void ath9k_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
128 {
129 struct ath_softc *sc = hw->priv;
130 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
131 @@ -128,28 +124,22 @@ static void ath_tx_cabq(struct ieee80211
132 }
133 }
134
135 -static struct ath_buf *ath_beacon_generate(struct ieee80211_hw *hw,
136 - struct ieee80211_vif *vif)
137 +static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
138 + struct ieee80211_vif *vif)
139 {
140 struct ath_softc *sc = hw->priv;
141 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
142 struct ath_buf *bf;
143 - struct ath_vif *avp;
144 + struct ath_vif *avp = (void *)vif->drv_priv;
145 struct sk_buff *skb;
146 - struct ath_txq *cabq;
147 + struct ath_txq *cabq = sc->beacon.cabq;
148 struct ieee80211_tx_info *info;
149 + struct ieee80211_mgmt *mgmt_hdr;
150 int cabq_depth;
151
152 - ath9k_reset_beacon_status(sc);
153 -
154 - avp = (void *)vif->drv_priv;
155 - cabq = sc->beacon.cabq;
156 -
157 - if ((avp->av_bcbuf == NULL) || !avp->is_bslot_active)
158 + if (avp->av_bcbuf == NULL)
159 return NULL;
160
161 - /* Release the old beacon first */
162 -
163 bf = avp->av_bcbuf;
164 skb = bf->bf_mpdu;
165 if (skb) {
166 @@ -159,14 +149,14 @@ static struct ath_buf *ath_beacon_genera
167 bf->bf_buf_addr = 0;
168 }
169
170 - /* Get a new beacon from mac80211 */
171 -
172 skb = ieee80211_beacon_get(hw, vif);
173 - bf->bf_mpdu = skb;
174 if (skb == NULL)
175 return NULL;
176 - ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp =
177 - avp->tsf_adjust;
178 +
179 + bf->bf_mpdu = skb;
180 +
181 + mgmt_hdr = (struct ieee80211_mgmt *)skb->data;
182 + mgmt_hdr->u.beacon.timestamp = avp->tsf_adjust;
183
184 info = IEEE80211_SKB_CB(skb);
185 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
186 @@ -212,61 +202,52 @@ static struct ath_buf *ath_beacon_genera
187 }
188 }
189
190 - ath_beacon_setup(sc, vif, bf, info->control.rates[0].idx);
191 + ath9k_beacon_setup(sc, vif, bf, info->control.rates[0].idx);
192
193 while (skb) {
194 - ath_tx_cabq(hw, skb);
195 + ath9k_tx_cabq(hw, skb);
196 skb = ieee80211_get_buffered_bc(hw, vif);
197 }
198
199 return bf;
200 }
201
202 -int ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_vif *vif)
203 +void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
204 {
205 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
206 - struct ath_vif *avp;
207 - struct ath_buf *bf;
208 - struct sk_buff *skb;
209 - struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
210 - __le64 tstamp;
211 + struct ath_vif *avp = (void *)vif->drv_priv;
212 + int slot;
213
214 - avp = (void *)vif->drv_priv;
215 + avp->av_bcbuf = list_first_entry(&sc->beacon.bbuf, struct ath_buf, list);
216 + list_del(&avp->av_bcbuf->list);
217
218 - /* Allocate a beacon descriptor if we haven't done so. */
219 - if (!avp->av_bcbuf) {
220 - /* Allocate beacon state for hostap/ibss. We know
221 - * a buffer is available. */
222 - avp->av_bcbuf = list_first_entry(&sc->beacon.bbuf,
223 - struct ath_buf, list);
224 - list_del(&avp->av_bcbuf->list);
225 -
226 - if (ath9k_uses_beacons(vif->type)) {
227 - int slot;
228 - /*
229 - * Assign the vif to a beacon xmit slot. As
230 - * above, this cannot fail to find one.
231 - */
232 - avp->av_bslot = 0;
233 - for (slot = 0; slot < ATH_BCBUF; slot++)
234 - if (sc->beacon.bslot[slot] == NULL) {
235 - avp->av_bslot = slot;
236 - avp->is_bslot_active = false;
237 -
238 - /* NB: keep looking for a double slot */
239 - if (slot == 0 || !sc->beacon.bslot[slot-1])
240 - break;
241 - }
242 - BUG_ON(sc->beacon.bslot[avp->av_bslot] != NULL);
243 - sc->beacon.bslot[avp->av_bslot] = vif;
244 - sc->nbcnvifs++;
245 + for (slot = 0; slot < ATH_BCBUF; slot++) {
246 + if (sc->beacon.bslot[slot] == NULL) {
247 + avp->av_bslot = slot;
248 + break;
249 }
250 }
251
252 - /* release the previous beacon frame, if it already exists. */
253 - bf = avp->av_bcbuf;
254 - if (bf->bf_mpdu != NULL) {
255 - skb = bf->bf_mpdu;
256 + sc->beacon.bslot[avp->av_bslot] = vif;
257 + sc->nbcnvifs++;
258 +
259 + ath_dbg(common, CONFIG, "Added interface at beacon slot: %d\n",
260 + avp->av_bslot);
261 +}
262 +
263 +void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
264 +{
265 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
266 + struct ath_vif *avp = (void *)vif->drv_priv;
267 + struct ath_buf *bf = avp->av_bcbuf;
268 +
269 + ath_dbg(common, CONFIG, "Removing interface at beacon slot: %d\n",
270 + avp->av_bslot);
271 +
272 + tasklet_disable(&sc->bcon_tasklet);
273 +
274 + if (bf && bf->bf_mpdu) {
275 + struct sk_buff *skb = bf->bf_mpdu;
276 dma_unmap_single(sc->dev, bf->bf_buf_addr,
277 skb->len, DMA_TO_DEVICE);
278 dev_kfree_skb_any(skb);
279 @@ -274,99 +255,74 @@ int ath_beacon_alloc(struct ath_softc *s
280 bf->bf_buf_addr = 0;
281 }
282
283 - /* NB: the beacon data buffer must be 32-bit aligned. */
284 - skb = ieee80211_beacon_get(sc->hw, vif);
285 - if (skb == NULL)
286 - return -ENOMEM;
287 -
288 - tstamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
289 - sc->beacon.bc_tstamp = (u32) le64_to_cpu(tstamp);
290 - /* Calculate a TSF adjustment factor required for staggered beacons. */
291 - if (avp->av_bslot > 0) {
292 - u64 tsfadjust;
293 - int intval;
294 + avp->av_bcbuf = NULL;
295 + sc->beacon.bslot[avp->av_bslot] = NULL;
296 + sc->nbcnvifs--;
297 + list_add_tail(&bf->list, &sc->beacon.bbuf);
298
299 - intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
300 + tasklet_enable(&sc->bcon_tasklet);
301 +}
302
303 - /*
304 - * Calculate the TSF offset for this beacon slot, i.e., the
305 - * number of usecs that need to be added to the timestamp field
306 - * in Beacon and Probe Response frames. Beacon slot 0 is
307 - * processed at the correct offset, so it does not require TSF
308 - * adjustment. Other slots are adjusted to get the timestamp
309 - * close to the TBTT for the BSS.
310 - */
311 - tsfadjust = TU_TO_USEC(intval * avp->av_bslot) / ATH_BCBUF;
312 - avp->tsf_adjust = cpu_to_le64(tsfadjust);
313 +static int ath9k_beacon_choose_slot(struct ath_softc *sc)
314 +{
315 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
316 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
317 + u16 intval;
318 + u32 tsftu;
319 + u64 tsf;
320 + int slot;
321
322 - ath_dbg(common, BEACON,
323 - "stagger beacons, bslot %d intval %u tsfadjust %llu\n",
324 - avp->av_bslot, intval, (unsigned long long)tsfadjust);
325 + if (sc->sc_ah->opmode != NL80211_IFTYPE_AP) {
326 + ath_dbg(common, BEACON, "slot 0, tsf: %llu\n",
327 + ath9k_hw_gettsf64(sc->sc_ah));
328 + return 0;
329 + }
330
331 - ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp =
332 - avp->tsf_adjust;
333 - } else
334 - avp->tsf_adjust = cpu_to_le64(0);
335 + intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
336 + tsf = ath9k_hw_gettsf64(sc->sc_ah);
337 + tsf += TU_TO_USEC(sc->sc_ah->config.sw_beacon_response_time);
338 + tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
339 + slot = (tsftu % (intval * ATH_BCBUF)) / intval;
340
341 - bf->bf_mpdu = skb;
342 - bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
343 - skb->len, DMA_TO_DEVICE);
344 - if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
345 - dev_kfree_skb_any(skb);
346 - bf->bf_mpdu = NULL;
347 - bf->bf_buf_addr = 0;
348 - ath_err(common, "dma_mapping_error on beacon alloc\n");
349 - return -ENOMEM;
350 - }
351 - avp->is_bslot_active = true;
352 + ath_dbg(common, BEACON, "slot: %d tsf: %llu tsftu: %u\n",
353 + slot, tsf, tsftu / ATH_BCBUF);
354
355 - return 0;
356 + return slot;
357 }
358
359 -void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp)
360 +void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif)
361 {
362 - if (avp->av_bcbuf != NULL) {
363 - struct ath_buf *bf;
364 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
365 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
366 + struct ath_vif *avp = (void *)vif->drv_priv;
367 + u64 tsfadjust;
368
369 - avp->is_bslot_active = false;
370 - if (avp->av_bslot != -1) {
371 - sc->beacon.bslot[avp->av_bslot] = NULL;
372 - sc->nbcnvifs--;
373 - avp->av_bslot = -1;
374 - }
375 + if (avp->av_bslot == 0)
376 + return;
377
378 - bf = avp->av_bcbuf;
379 - if (bf->bf_mpdu != NULL) {
380 - struct sk_buff *skb = bf->bf_mpdu;
381 - dma_unmap_single(sc->dev, bf->bf_buf_addr,
382 - skb->len, DMA_TO_DEVICE);
383 - dev_kfree_skb_any(skb);
384 - bf->bf_mpdu = NULL;
385 - bf->bf_buf_addr = 0;
386 - }
387 - list_add_tail(&bf->list, &sc->beacon.bbuf);
388 + tsfadjust = cur_conf->beacon_interval * avp->av_bslot / ATH_BCBUF;
389 + avp->tsf_adjust = cpu_to_le64(TU_TO_USEC(tsfadjust));
390
391 - avp->av_bcbuf = NULL;
392 - }
393 + ath_dbg(common, CONFIG, "tsfadjust is: %llu for bslot: %d\n",
394 + (unsigned long long)tsfadjust, avp->av_bslot);
395 }
396
397 -void ath_beacon_tasklet(unsigned long data)
398 +void ath9k_beacon_tasklet(unsigned long data)
399 {
400 struct ath_softc *sc = (struct ath_softc *)data;
401 - struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
402 struct ath_hw *ah = sc->sc_ah;
403 struct ath_common *common = ath9k_hw_common(ah);
404 struct ath_buf *bf = NULL;
405 struct ieee80211_vif *vif;
406 bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
407 int slot;
408 - u32 bfaddr, bc = 0;
409
410 - if (work_pending(&sc->hw_reset_work)) {
411 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags)) {
412 ath_dbg(common, RESET,
413 "reset work is pending, skip beaconing now\n");
414 return;
415 }
416 +
417 /*
418 * Check if the previous beacon has gone out. If
419 * not don't try to post another, skip this period
420 @@ -390,55 +346,25 @@ void ath_beacon_tasklet(unsigned long da
421 } else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) {
422 ath_dbg(common, BSTUCK, "beacon is officially stuck\n");
423 sc->beacon.bmisscnt = 0;
424 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags);
425 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
426 + ath9k_queue_reset(sc, RESET_TYPE_BEACON_STUCK);
427 }
428
429 return;
430 }
431
432 - /*
433 - * Generate beacon frames. we are sending frames
434 - * staggered so calculate the slot for this frame based
435 - * on the tsf to safeguard against missing an swba.
436 - */
437 -
438 -
439 - if (ah->opmode == NL80211_IFTYPE_AP) {
440 - u16 intval;
441 - u32 tsftu;
442 - u64 tsf;
443 -
444 - intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
445 - tsf = ath9k_hw_gettsf64(ah);
446 - tsf += TU_TO_USEC(ah->config.sw_beacon_response_time);
447 - tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
448 - slot = (tsftu % (intval * ATH_BCBUF)) / intval;
449 - vif = sc->beacon.bslot[slot];
450 -
451 - ath_dbg(common, BEACON,
452 - "slot %d [tsf %llu tsftu %u intval %u] vif %p\n",
453 - slot, tsf, tsftu / ATH_BCBUF, intval, vif);
454 - } else {
455 - slot = 0;
456 - vif = sc->beacon.bslot[slot];
457 - }
458 + slot = ath9k_beacon_choose_slot(sc);
459 + vif = sc->beacon.bslot[slot];
460
461 + if (!vif || !vif->bss_conf.enable_beacon)
462 + return;
463
464 - bfaddr = 0;
465 - if (vif) {
466 - bf = ath_beacon_generate(sc->hw, vif);
467 - if (bf != NULL) {
468 - bfaddr = bf->bf_daddr;
469 - bc = 1;
470 - }
471 + bf = ath9k_beacon_generate(sc->hw, vif);
472 + WARN_ON(!bf);
473
474 - if (sc->beacon.bmisscnt != 0) {
475 - ath_dbg(common, BSTUCK,
476 - "resume beacon xmit after %u misses\n",
477 - sc->beacon.bmisscnt);
478 - sc->beacon.bmisscnt = 0;
479 - }
480 + if (sc->beacon.bmisscnt != 0) {
481 + ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
482 + sc->beacon.bmisscnt);
483 + sc->beacon.bmisscnt = 0;
484 }
485
486 /*
487 @@ -458,39 +384,37 @@ void ath_beacon_tasklet(unsigned long da
488 * set to ATH_BCBUF so this check is a noop.
489 */
490 if (sc->beacon.updateslot == UPDATE) {
491 - sc->beacon.updateslot = COMMIT; /* commit next beacon */
492 + sc->beacon.updateslot = COMMIT;
493 sc->beacon.slotupdate = slot;
494 - } else if (sc->beacon.updateslot == COMMIT && sc->beacon.slotupdate == slot) {
495 + } else if (sc->beacon.updateslot == COMMIT &&
496 + sc->beacon.slotupdate == slot) {
497 ah->slottime = sc->beacon.slottime;
498 ath9k_hw_init_global_settings(ah);
499 sc->beacon.updateslot = OK;
500 }
501 - if (bfaddr != 0) {
502 +
503 + if (bf) {
504 + ath9k_reset_beacon_status(sc);
505 +
506 /* NB: cabq traffic should already be queued and primed */
507 - ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bfaddr);
508 + ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bf->bf_daddr);
509
510 if (!edma)
511 ath9k_hw_txstart(ah, sc->beacon.beaconq);
512 -
513 - sc->beacon.ast_be_xmit += bc; /* XXX per-vif? */
514 }
515 }
516
517 -static void ath9k_beacon_init(struct ath_softc *sc,
518 - u32 next_beacon,
519 - u32 beacon_period)
520 +static void ath9k_beacon_init(struct ath_softc *sc, u32 nexttbtt, u32 intval)
521 {
522 - if (test_bit(SC_OP_TSF_RESET, &sc->sc_flags)) {
523 - ath9k_ps_wakeup(sc);
524 - ath9k_hw_reset_tsf(sc->sc_ah);
525 - }
526 -
527 - ath9k_hw_beaconinit(sc->sc_ah, next_beacon, beacon_period);
528 + struct ath_hw *ah = sc->sc_ah;
529
530 - if (test_bit(SC_OP_TSF_RESET, &sc->sc_flags)) {
531 - ath9k_ps_restore(sc);
532 - clear_bit(SC_OP_TSF_RESET, &sc->sc_flags);
533 - }
534 + ath9k_hw_disable_interrupts(ah);
535 + ath9k_hw_reset_tsf(ah);
536 + ath9k_beaconq_config(sc);
537 + ath9k_hw_beaconinit(ah, nexttbtt, intval);
538 + sc->beacon.bmisscnt = 0;
539 + ath9k_hw_set_interrupts(ah);
540 + ath9k_hw_enable_interrupts(ah);
541 }
542
543 /*
544 @@ -498,32 +422,27 @@ static void ath9k_beacon_init(struct ath
545 * burst together. For the former arrange for the SWBA to be delivered for each
546 * slot. Slots that are not occupied will generate nothing.
547 */
548 -static void ath_beacon_config_ap(struct ath_softc *sc,
549 - struct ath_beacon_config *conf)
550 +static void ath9k_beacon_config_ap(struct ath_softc *sc,
551 + struct ath_beacon_config *conf)
552 {
553 struct ath_hw *ah = sc->sc_ah;
554 + struct ath_common *common = ath9k_hw_common(ah);
555 u32 nexttbtt, intval;
556
557 /* NB: the beacon interval is kept internally in TU's */
558 intval = TU_TO_USEC(conf->beacon_interval);
559 - intval /= ATH_BCBUF; /* for staggered beacons */
560 + intval /= ATH_BCBUF;
561 nexttbtt = intval;
562
563 - /*
564 - * In AP mode we enable the beacon timers and SWBA interrupts to
565 - * prepare beacon frames.
566 - */
567 - ah->imask |= ATH9K_INT_SWBA;
568 - ath_beaconq_config(sc);
569 + if (conf->enable_beacon)
570 + ah->imask |= ATH9K_INT_SWBA;
571 + else
572 + ah->imask &= ~ATH9K_INT_SWBA;
573
574 - /* Set the computed AP beacon timers */
575 + ath_dbg(common, BEACON, "AP nexttbtt: %u intval: %u conf_intval: %u\n",
576 + nexttbtt, intval, conf->beacon_interval);
577
578 - ath9k_hw_disable_interrupts(ah);
579 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags);
580 ath9k_beacon_init(sc, nexttbtt, intval);
581 - sc->beacon.bmisscnt = 0;
582 - ath9k_hw_set_interrupts(ah);
583 - ath9k_hw_enable_interrupts(ah);
584 }
585
586 /*
587 @@ -534,8 +453,8 @@ static void ath_beacon_config_ap(struct
588 * we'll receive a BMISS interrupt when we stop seeing beacons from the AP
589 * we've associated with.
590 */
591 -static void ath_beacon_config_sta(struct ath_softc *sc,
592 - struct ath_beacon_config *conf)
593 +static void ath9k_beacon_config_sta(struct ath_softc *sc,
594 + struct ath_beacon_config *conf)
595 {
596 struct ath_hw *ah = sc->sc_ah;
597 struct ath_common *common = ath9k_hw_common(ah);
598 @@ -654,8 +573,8 @@ static void ath_beacon_config_sta(struct
599 ath9k_hw_enable_interrupts(ah);
600 }
601
602 -static void ath_beacon_config_adhoc(struct ath_softc *sc,
603 - struct ath_beacon_config *conf)
604 +static void ath9k_beacon_config_adhoc(struct ath_softc *sc,
605 + struct ath_beacon_config *conf)
606 {
607 struct ath_hw *ah = sc->sc_ah;
608 struct ath_common *common = ath9k_hw_common(ah);
609 @@ -669,82 +588,53 @@ static void ath_beacon_config_adhoc(stru
610 tsf = roundup(ath9k_hw_gettsf32(ah) + TU_TO_USEC(FUDGE), intval);
611 nexttbtt = tsf + intval;
612
613 - ath_dbg(common, BEACON, "IBSS nexttbtt %u intval %u (%u)\n",
614 - nexttbtt, intval, conf->beacon_interval);
615 -
616 - /*
617 - * In IBSS mode enable the beacon timers but only enable SWBA interrupts
618 - * if we need to manually prepare beacon frames. Otherwise we use a
619 - * self-linked tx descriptor and let the hardware deal with things.
620 - */
621 - ah->imask |= ATH9K_INT_SWBA;
622 -
623 - ath_beaconq_config(sc);
624 + if (conf->enable_beacon)
625 + ah->imask |= ATH9K_INT_SWBA;
626 + else
627 + ah->imask &= ~ATH9K_INT_SWBA;
628
629 - /* Set the computed ADHOC beacon timers */
630 + ath_dbg(common, BEACON, "IBSS nexttbtt: %u intval: %u conf_intval: %u\n",
631 + nexttbtt, intval, conf->beacon_interval);
632
633 - ath9k_hw_disable_interrupts(ah);
634 ath9k_beacon_init(sc, nexttbtt, intval);
635 - sc->beacon.bmisscnt = 0;
636 -
637 - ath9k_hw_set_interrupts(ah);
638 - ath9k_hw_enable_interrupts(ah);
639 }
640
641 -static bool ath9k_allow_beacon_config(struct ath_softc *sc,
642 - struct ieee80211_vif *vif)
643 +bool ath9k_allow_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif)
644 {
645 - struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
646 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
647 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
648 struct ath_vif *avp = (void *)vif->drv_priv;
649
650 - /*
651 - * Can not have different beacon interval on multiple
652 - * AP interface case
653 - */
654 - if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
655 - (sc->nbcnvifs > 1) &&
656 - (vif->type == NL80211_IFTYPE_AP) &&
657 - (cur_conf->beacon_interval != bss_conf->beacon_int)) {
658 - ath_dbg(common, CONFIG,
659 - "Changing beacon interval of multiple AP interfaces !\n");
660 - return false;
661 - }
662 - /*
663 - * Can not configure station vif's beacon config
664 - * while on AP opmode
665 - */
666 - if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) &&
667 - (vif->type != NL80211_IFTYPE_AP)) {
668 - ath_dbg(common, CONFIG,
669 - "STA vif's beacon not allowed on AP mode\n");
670 - return false;
671 + if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
672 + if ((vif->type != NL80211_IFTYPE_AP) ||
673 + (sc->nbcnvifs > 1)) {
674 + ath_dbg(common, CONFIG,
675 + "An AP interface is already present !\n");
676 + return false;
677 + }
678 }
679 - /*
680 - * Do not allow beacon config if HW was already configured
681 - * with another STA vif
682 - */
683 - if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) &&
684 - (vif->type == NL80211_IFTYPE_STATION) &&
685 - test_bit(SC_OP_BEACONS, &sc->sc_flags) &&
686 - !avp->primary_sta_vif) {
687 - ath_dbg(common, CONFIG,
688 - "Beacon already configured for a station interface\n");
689 - return false;
690 +
691 + if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION) {
692 + if ((vif->type == NL80211_IFTYPE_STATION) &&
693 + test_bit(SC_OP_BEACONS, &sc->sc_flags) &&
694 + !avp->primary_sta_vif) {
695 + ath_dbg(common, CONFIG,
696 + "Beacon already configured for a station interface\n");
697 + return false;
698 + }
699 }
700 +
701 return true;
702 }
703
704 -void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif)
705 +static void ath9k_cache_beacon_config(struct ath_softc *sc,
706 + struct ieee80211_bss_conf *bss_conf)
707 {
708 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
709 struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
710 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
711
712 - if (!ath9k_allow_beacon_config(sc, vif))
713 - return;
714 + ath_dbg(common, BEACON,
715 + "Caching beacon data for BSS: %pM\n", bss_conf->bssid);
716
717 - /* Setup the beacon configuration parameters */
718 cur_conf->beacon_interval = bss_conf->beacon_int;
719 cur_conf->dtim_period = bss_conf->dtim_period;
720 cur_conf->listen_interval = 1;
721 @@ -769,73 +659,59 @@ void ath_beacon_config(struct ath_softc
722 if (cur_conf->dtim_period == 0)
723 cur_conf->dtim_period = 1;
724
725 - ath_set_beacon(sc);
726 }
727
728 -static bool ath_has_valid_bslot(struct ath_softc *sc)
729 +void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif,
730 + u32 changed)
731 {
732 - struct ath_vif *avp;
733 - int slot;
734 - bool found = false;
735 + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
736 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
737
738 - for (slot = 0; slot < ATH_BCBUF; slot++) {
739 - if (sc->beacon.bslot[slot]) {
740 - avp = (void *)sc->beacon.bslot[slot]->drv_priv;
741 - if (avp->is_bslot_active) {
742 - found = true;
743 - break;
744 - }
745 + ath9k_cache_beacon_config(sc, bss_conf);
746 +
747 + if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION) {
748 + ath9k_set_beacon(sc);
749 + set_bit(SC_OP_BEACONS, &sc->sc_flags);
750 + } else {
751 + /*
752 + * Take care of multiple interfaces when
753 + * enabling/disabling SWBA.
754 + */
755 + if (changed & BSS_CHANGED_BEACON_ENABLED) {
756 + if (!bss_conf->enable_beacon &&
757 + (sc->nbcnvifs <= 1))
758 + cur_conf->enable_beacon = false;
759 + else if (bss_conf->enable_beacon)
760 + cur_conf->enable_beacon = true;
761 }
762 +
763 + ath9k_set_beacon(sc);
764 +
765 + if (cur_conf->enable_beacon)
766 + set_bit(SC_OP_BEACONS, &sc->sc_flags);
767 + else
768 + clear_bit(SC_OP_BEACONS, &sc->sc_flags);
769 }
770 - return found;
771 }
772
773 -
774 -void ath_set_beacon(struct ath_softc *sc)
775 +void ath9k_set_beacon(struct ath_softc *sc)
776 {
777 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
778 struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
779
780 switch (sc->sc_ah->opmode) {
781 case NL80211_IFTYPE_AP:
782 - if (ath_has_valid_bslot(sc))
783 - ath_beacon_config_ap(sc, cur_conf);
784 + ath9k_beacon_config_ap(sc, cur_conf);
785 break;
786 case NL80211_IFTYPE_ADHOC:
787 case NL80211_IFTYPE_MESH_POINT:
788 - ath_beacon_config_adhoc(sc, cur_conf);
789 + ath9k_beacon_config_adhoc(sc, cur_conf);
790 break;
791 case NL80211_IFTYPE_STATION:
792 - ath_beacon_config_sta(sc, cur_conf);
793 + ath9k_beacon_config_sta(sc, cur_conf);
794 break;
795 default:
796 ath_dbg(common, CONFIG, "Unsupported beaconing mode\n");
797 return;
798 }
799 -
800 - set_bit(SC_OP_BEACONS, &sc->sc_flags);
801 -}
802 -
803 -void ath9k_set_beaconing_status(struct ath_softc *sc, bool status)
804 -{
805 - struct ath_hw *ah = sc->sc_ah;
806 -
807 - if (!ath_has_valid_bslot(sc)) {
808 - clear_bit(SC_OP_BEACONS, &sc->sc_flags);
809 - return;
810 - }
811 -
812 - ath9k_ps_wakeup(sc);
813 - if (status) {
814 - /* Re-enable beaconing */
815 - ah->imask |= ATH9K_INT_SWBA;
816 - ath9k_hw_set_interrupts(ah);
817 - } else {
818 - /* Disable SWBA interrupt */
819 - ah->imask &= ~ATH9K_INT_SWBA;
820 - ath9k_hw_set_interrupts(ah);
821 - tasklet_kill(&sc->bcon_tasklet);
822 - ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
823 - }
824 - ath9k_ps_restore(sc);
825 }
826 --- a/drivers/net/wireless/ath/ath9k/debug.c
827 +++ b/drivers/net/wireless/ath/ath9k/debug.c
828 @@ -206,10 +206,9 @@ static ssize_t write_file_disable_ani(st
829
830 if (disable_ani) {
831 clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
832 - del_timer_sync(&common->ani.timer);
833 + ath_stop_ani(sc);
834 } else {
835 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags);
836 - ath_start_ani(common);
837 + ath_check_ani(sc);
838 }
839
840 return count;
841 --- a/drivers/net/wireless/ath/ath9k/debug.h
842 +++ b/drivers/net/wireless/ath/ath9k/debug.h
843 @@ -32,6 +32,19 @@ struct ath_buf;
844 #define RESET_STAT_INC(sc, type) do { } while (0)
845 #endif
846
847 +enum ath_reset_type {
848 + RESET_TYPE_BB_HANG,
849 + RESET_TYPE_BB_WATCHDOG,
850 + RESET_TYPE_FATAL_INT,
851 + RESET_TYPE_TX_ERROR,
852 + RESET_TYPE_TX_HANG,
853 + RESET_TYPE_PLL_HANG,
854 + RESET_TYPE_MAC_HANG,
855 + RESET_TYPE_BEACON_STUCK,
856 + RESET_TYPE_MCI,
857 + __RESET_TYPE_MAX
858 +};
859 +
860 #ifdef CONFIG_ATH9K_DEBUGFS
861
862 /**
863 @@ -209,17 +222,6 @@ struct ath_rx_stats {
864 u32 rx_frags;
865 };
866
867 -enum ath_reset_type {
868 - RESET_TYPE_BB_HANG,
869 - RESET_TYPE_BB_WATCHDOG,
870 - RESET_TYPE_FATAL_INT,
871 - RESET_TYPE_TX_ERROR,
872 - RESET_TYPE_TX_HANG,
873 - RESET_TYPE_PLL_HANG,
874 - RESET_TYPE_MAC_HANG,
875 - __RESET_TYPE_MAX
876 -};
877 -
878 struct ath_stats {
879 struct ath_interrupt_stats istats;
880 struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
881 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
882 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
883 @@ -1111,7 +1111,7 @@ static int ath9k_htc_add_interface(struc
884
885 if ((priv->ah->opmode == NL80211_IFTYPE_AP) &&
886 !test_bit(OP_ANI_RUNNING, &priv->op_flags)) {
887 - ath9k_hw_set_tsfadjust(priv->ah, 1);
888 + ath9k_hw_set_tsfadjust(priv->ah, true);
889 ath9k_htc_start_ani(priv);
890 }
891
892 --- a/drivers/net/wireless/ath/ath9k/hw.c
893 +++ b/drivers/net/wireless/ath/ath9k/hw.c
894 @@ -2908,9 +2908,9 @@ void ath9k_hw_reset_tsf(struct ath_hw *a
895 }
896 EXPORT_SYMBOL(ath9k_hw_reset_tsf);
897
898 -void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting)
899 +void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set)
900 {
901 - if (setting)
902 + if (set)
903 ah->misc_mode |= AR_PCU_TX_ADD_TSF;
904 else
905 ah->misc_mode &= ~AR_PCU_TX_ADD_TSF;
906 --- a/drivers/net/wireless/ath/ath9k/hw.h
907 +++ b/drivers/net/wireless/ath/ath9k/hw.h
908 @@ -943,7 +943,7 @@ u32 ath9k_hw_gettsf32(struct ath_hw *ah)
909 u64 ath9k_hw_gettsf64(struct ath_hw *ah);
910 void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64);
911 void ath9k_hw_reset_tsf(struct ath_hw *ah);
912 -void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting);
913 +void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set);
914 void ath9k_hw_init_global_settings(struct ath_hw *ah);
915 u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah);
916 void ath9k_hw_set11nmac2040(struct ath_hw *ah);
917 --- a/drivers/net/wireless/ath/ath9k/init.c
918 +++ b/drivers/net/wireless/ath/ath9k/init.c
919 @@ -560,7 +560,7 @@ static int ath9k_init_softc(u16 devid, s
920 spin_lock_init(&sc->debug.samp_lock);
921 #endif
922 tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
923 - tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
924 + tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet,
925 (unsigned long)sc);
926
927 INIT_WORK(&sc->hw_reset_work, ath_reset_work);
928 --- a/drivers/net/wireless/ath/ath9k/link.c
929 +++ b/drivers/net/wireless/ath/ath9k/link.c
930 @@ -50,8 +50,7 @@ void ath_tx_complete_poll_work(struct wo
931 if (needreset) {
932 ath_dbg(ath9k_hw_common(sc->sc_ah), RESET,
933 "tx hung, resetting the chip\n");
934 - RESET_STAT_INC(sc, RESET_TYPE_TX_HANG);
935 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
936 + ath9k_queue_reset(sc, RESET_TYPE_TX_HANG);
937 return;
938 }
939
940 @@ -69,6 +68,7 @@ void ath_hw_check(struct work_struct *wo
941 unsigned long flags;
942 int busy;
943 u8 is_alive, nbeacon = 1;
944 + enum ath_reset_type type;
945
946 ath9k_ps_wakeup(sc);
947 is_alive = ath9k_hw_check_alive(sc->sc_ah);
948 @@ -78,7 +78,7 @@ void ath_hw_check(struct work_struct *wo
949 else if (!is_alive && AR_SREV_9300(sc->sc_ah)) {
950 ath_dbg(common, RESET,
951 "DCU stuck is detected. Schedule chip reset\n");
952 - RESET_STAT_INC(sc, RESET_TYPE_MAC_HANG);
953 + type = RESET_TYPE_MAC_HANG;
954 goto sched_reset;
955 }
956
957 @@ -90,7 +90,7 @@ void ath_hw_check(struct work_struct *wo
958 busy, sc->hw_busy_count + 1);
959 if (busy >= 99) {
960 if (++sc->hw_busy_count >= 3) {
961 - RESET_STAT_INC(sc, RESET_TYPE_BB_HANG);
962 + type = RESET_TYPE_BB_HANG;
963 goto sched_reset;
964 }
965 } else if (busy >= 0) {
966 @@ -102,7 +102,7 @@ void ath_hw_check(struct work_struct *wo
967 goto out;
968
969 sched_reset:
970 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
971 + ath9k_queue_reset(sc, type);
972 out:
973 ath9k_ps_restore(sc);
974 }
975 @@ -119,8 +119,7 @@ static bool ath_hw_pll_rx_hang_check(str
976 count++;
977 if (count == 3) {
978 ath_dbg(common, RESET, "PLL WAR, resetting the chip\n");
979 - RESET_STAT_INC(sc, RESET_TYPE_PLL_HANG);
980 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
981 + ath9k_queue_reset(sc, RESET_TYPE_PLL_HANG);
982 count = 0;
983 return true;
984 }
985 @@ -432,26 +431,69 @@ set_timer:
986 }
987 }
988
989 -void ath_start_ani(struct ath_common *common)
990 +void ath_start_ani(struct ath_softc *sc)
991 {
992 - struct ath_hw *ah = common->ah;
993 + struct ath_hw *ah = sc->sc_ah;
994 + struct ath_common *common = ath9k_hw_common(ah);
995 unsigned long timestamp = jiffies_to_msecs(jiffies);
996 - struct ath_softc *sc = (struct ath_softc *) common->priv;
997
998 - if (!test_bit(SC_OP_ANI_RUN, &sc->sc_flags))
999 - return;
1000 -
1001 - if (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
1002 + if (common->disable_ani ||
1003 + !test_bit(SC_OP_ANI_RUN, &sc->sc_flags) ||
1004 + (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL))
1005 return;
1006
1007 common->ani.longcal_timer = timestamp;
1008 common->ani.shortcal_timer = timestamp;
1009 common->ani.checkani_timer = timestamp;
1010
1011 + ath_dbg(common, ANI, "Starting ANI\n");
1012 mod_timer(&common->ani.timer,
1013 jiffies + msecs_to_jiffies((u32)ah->config.ani_poll_interval));
1014 }
1015
1016 +void ath_stop_ani(struct ath_softc *sc)
1017 +{
1018 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1019 +
1020 + ath_dbg(common, ANI, "Stopping ANI\n");
1021 + del_timer_sync(&common->ani.timer);
1022 +}
1023 +
1024 +void ath_check_ani(struct ath_softc *sc)
1025 +{
1026 + struct ath_hw *ah = sc->sc_ah;
1027 + struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
1028 +
1029 + /*
1030 + * Check for the various conditions in which ANI has to
1031 + * be stopped.
1032 + */
1033 + if (ah->opmode == NL80211_IFTYPE_ADHOC) {
1034 + if (!cur_conf->enable_beacon)
1035 + goto stop_ani;
1036 + } else if (ah->opmode == NL80211_IFTYPE_AP) {
1037 + if (!cur_conf->enable_beacon) {
1038 + /*
1039 + * Disable ANI only when there are no
1040 + * associated stations.
1041 + */
1042 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags))
1043 + goto stop_ani;
1044 + }
1045 + } else if (ah->opmode == NL80211_IFTYPE_STATION) {
1046 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags))
1047 + goto stop_ani;
1048 + }
1049 +
1050 + set_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1051 + ath_start_ani(sc);
1052 + return;
1053 +
1054 +stop_ani:
1055 + clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1056 + ath_stop_ani(sc);
1057 +}
1058 +
1059 void ath_update_survey_nf(struct ath_softc *sc, int channel)
1060 {
1061 struct ath_hw *ah = sc->sc_ah;
1062 --- a/drivers/net/wireless/ath/ath9k/main.c
1063 +++ b/drivers/net/wireless/ath/ath9k/main.c
1064 @@ -167,8 +167,6 @@ static void ath_cancel_work(struct ath_s
1065
1066 static void ath_restart_work(struct ath_softc *sc)
1067 {
1068 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1069 -
1070 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
1071
1072 if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9485(sc->sc_ah) ||
1073 @@ -177,21 +175,18 @@ static void ath_restart_work(struct ath_
1074 msecs_to_jiffies(ATH_PLL_WORK_INTERVAL));
1075
1076 ath_start_rx_poll(sc, 3);
1077 -
1078 - if (!common->disable_ani)
1079 - ath_start_ani(common);
1080 + ath_start_ani(sc);
1081 }
1082
1083 static bool ath_prepare_reset(struct ath_softc *sc, bool retry_tx, bool flush)
1084 {
1085 struct ath_hw *ah = sc->sc_ah;
1086 - struct ath_common *common = ath9k_hw_common(ah);
1087 bool ret = true;
1088
1089 ieee80211_stop_queues(sc->hw);
1090
1091 sc->hw_busy_count = 0;
1092 - del_timer_sync(&common->ani.timer);
1093 + ath_stop_ani(sc);
1094 del_timer_sync(&sc->rx_poll_timer);
1095
1096 ath9k_debug_samp_bb_mac(sc);
1097 @@ -236,7 +231,7 @@ static bool ath_complete_reset(struct at
1098 if (!test_bit(SC_OP_BEACONS, &sc->sc_flags))
1099 goto work;
1100
1101 - ath_set_beacon(sc);
1102 + ath9k_set_beacon(sc);
1103
1104 if (ah->opmode == NL80211_IFTYPE_STATION &&
1105 test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1106 @@ -365,6 +360,7 @@ void ath9k_tasklet(unsigned long data)
1107 struct ath_softc *sc = (struct ath_softc *)data;
1108 struct ath_hw *ah = sc->sc_ah;
1109 struct ath_common *common = ath9k_hw_common(ah);
1110 + enum ath_reset_type type;
1111 unsigned long flags;
1112 u32 status = sc->intrstatus;
1113 u32 rxmask;
1114 @@ -374,18 +370,13 @@ void ath9k_tasklet(unsigned long data)
1115
1116 if ((status & ATH9K_INT_FATAL) ||
1117 (status & ATH9K_INT_BB_WATCHDOG)) {
1118 -#ifdef CONFIG_ATH9K_DEBUGFS
1119 - enum ath_reset_type type;
1120
1121 if (status & ATH9K_INT_FATAL)
1122 type = RESET_TYPE_FATAL_INT;
1123 else
1124 type = RESET_TYPE_BB_WATCHDOG;
1125
1126 - RESET_STAT_INC(sc, type);
1127 -#endif
1128 - set_bit(SC_OP_HW_RESET, &sc->sc_flags);
1129 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
1130 + ath9k_queue_reset(sc, type);
1131 goto out;
1132 }
1133
1134 @@ -575,6 +566,15 @@ static int ath_reset(struct ath_softc *s
1135 return r;
1136 }
1137
1138 +void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type)
1139 +{
1140 +#ifdef CONFIG_ATH9K_DEBUGFS
1141 + RESET_STAT_INC(sc, type);
1142 +#endif
1143 + set_bit(SC_OP_HW_RESET, &sc->sc_flags);
1144 + ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
1145 +}
1146 +
1147 void ath_reset_work(struct work_struct *work)
1148 {
1149 struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work);
1150 @@ -841,16 +841,6 @@ bool ath9k_uses_beacons(int type)
1151 }
1152 }
1153
1154 -static void ath9k_reclaim_beacon(struct ath_softc *sc,
1155 - struct ieee80211_vif *vif)
1156 -{
1157 - struct ath_vif *avp = (void *)vif->drv_priv;
1158 -
1159 - ath9k_set_beaconing_status(sc, false);
1160 - ath_beacon_return(sc, avp);
1161 - ath9k_set_beaconing_status(sc, true);
1162 -}
1163 -
1164 static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
1165 {
1166 struct ath9k_vif_iter_data *iter_data = data;
1167 @@ -918,18 +908,14 @@ static void ath9k_calculate_summary_stat
1168
1169 ath9k_calculate_iter_data(hw, vif, &iter_data);
1170
1171 - /* Set BSSID mask. */
1172 memcpy(common->bssidmask, iter_data.mask, ETH_ALEN);
1173 ath_hw_setbssidmask(common);
1174
1175 - /* Set op-mode & TSF */
1176 if (iter_data.naps > 0) {
1177 - ath9k_hw_set_tsfadjust(ah, 1);
1178 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags);
1179 + ath9k_hw_set_tsfadjust(ah, true);
1180 ah->opmode = NL80211_IFTYPE_AP;
1181 } else {
1182 - ath9k_hw_set_tsfadjust(ah, 0);
1183 - clear_bit(SC_OP_TSF_RESET, &sc->sc_flags);
1184 + ath9k_hw_set_tsfadjust(ah, false);
1185
1186 if (iter_data.nmeshes)
1187 ah->opmode = NL80211_IFTYPE_MESH_POINT;
1188 @@ -941,45 +927,14 @@ static void ath9k_calculate_summary_stat
1189 ah->opmode = NL80211_IFTYPE_STATION;
1190 }
1191
1192 - /*
1193 - * Enable MIB interrupts when there are hardware phy counters.
1194 - */
1195 + ath9k_hw_setopmode(ah);
1196 +
1197 if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0)
1198 ah->imask |= ATH9K_INT_TSFOOR;
1199 else
1200 ah->imask &= ~ATH9K_INT_TSFOOR;
1201
1202 ath9k_hw_set_interrupts(ah);
1203 -
1204 - /* Set up ANI */
1205 - if (iter_data.naps > 0) {
1206 - sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
1207 -
1208 - if (!common->disable_ani) {
1209 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1210 - ath_start_ani(common);
1211 - }
1212 -
1213 - } else {
1214 - clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1215 - del_timer_sync(&common->ani.timer);
1216 - }
1217 -}
1218 -
1219 -/* Called with sc->mutex held, vif counts set up properly. */
1220 -static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw,
1221 - struct ieee80211_vif *vif)
1222 -{
1223 - struct ath_softc *sc = hw->priv;
1224 -
1225 - ath9k_calculate_summary_state(hw, vif);
1226 -
1227 - if (ath9k_uses_beacons(vif->type)) {
1228 - /* Reserve a beacon slot for the vif */
1229 - ath9k_set_beaconing_status(sc, false);
1230 - ath_beacon_alloc(sc, vif);
1231 - ath9k_set_beaconing_status(sc, true);
1232 - }
1233 }
1234
1235 static int ath9k_add_interface(struct ieee80211_hw *hw,
1236 @@ -1021,7 +976,10 @@ static int ath9k_add_interface(struct ie
1237
1238 sc->nvifs++;
1239
1240 - ath9k_do_vif_add_setup(hw, vif);
1241 + ath9k_calculate_summary_state(hw, vif);
1242 + if (ath9k_uses_beacons(vif->type))
1243 + ath9k_beacon_assign_slot(sc, vif);
1244 +
1245 out:
1246 mutex_unlock(&sc->mutex);
1247 ath9k_ps_restore(sc);
1248 @@ -1038,6 +996,7 @@ static int ath9k_change_interface(struct
1249 int ret = 0;
1250
1251 ath_dbg(common, CONFIG, "Change Interface\n");
1252 +
1253 mutex_lock(&sc->mutex);
1254 ath9k_ps_wakeup(sc);
1255
1256 @@ -1050,15 +1009,16 @@ static int ath9k_change_interface(struct
1257 }
1258 }
1259
1260 - /* Clean up old vif stuff */
1261 if (ath9k_uses_beacons(vif->type))
1262 - ath9k_reclaim_beacon(sc, vif);
1263 + ath9k_beacon_remove_slot(sc, vif);
1264
1265 - /* Add new settings */
1266 vif->type = new_type;
1267 vif->p2p = p2p;
1268
1269 - ath9k_do_vif_add_setup(hw, vif);
1270 + ath9k_calculate_summary_state(hw, vif);
1271 + if (ath9k_uses_beacons(vif->type))
1272 + ath9k_beacon_assign_slot(sc, vif);
1273 +
1274 out:
1275 ath9k_ps_restore(sc);
1276 mutex_unlock(&sc->mutex);
1277 @@ -1078,9 +1038,8 @@ static void ath9k_remove_interface(struc
1278
1279 sc->nvifs--;
1280
1281 - /* Reclaim beacon resources */
1282 if (ath9k_uses_beacons(vif->type))
1283 - ath9k_reclaim_beacon(sc, vif);
1284 + ath9k_beacon_remove_slot(sc, vif);
1285
1286 ath9k_calculate_summary_state(hw, NULL);
1287
1288 @@ -1388,10 +1347,6 @@ static int ath9k_conf_tx(struct ieee8021
1289 if (ret)
1290 ath_err(common, "TXQ Update failed\n");
1291
1292 - if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)
1293 - if (queue == WME_AC_BE && !ret)
1294 - ath_beaconq_config(sc);
1295 -
1296 mutex_unlock(&sc->mutex);
1297 ath9k_ps_restore(sc);
1298
1299 @@ -1460,85 +1415,36 @@ static int ath9k_set_key(struct ieee8021
1300
1301 return ret;
1302 }
1303 -static void ath9k_bss_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
1304 +
1305 +static void ath9k_bss_assoc_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
1306 {
1307 struct ath_softc *sc = data;
1308 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1309 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1310 struct ath_vif *avp = (void *)vif->drv_priv;
1311 + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1312 unsigned long flags;
1313 - /*
1314 - * Skip iteration if primary station vif's bss info
1315 - * was not changed
1316 - */
1317 +
1318 if (test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags))
1319 return;
1320
1321 if (bss_conf->assoc) {
1322 set_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags);
1323 avp->primary_sta_vif = true;
1324 +
1325 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
1326 common->curaid = bss_conf->aid;
1327 ath9k_hw_write_associd(sc->sc_ah);
1328 - ath_dbg(common, CONFIG, "Bss Info ASSOC %d, bssid: %pM\n",
1329 - bss_conf->aid, common->curbssid);
1330 - ath_beacon_config(sc, vif);
1331 - /*
1332 - * Request a re-configuration of Beacon related timers
1333 - * on the receipt of the first Beacon frame (i.e.,
1334 - * after time sync with the AP).
1335 - */
1336 - spin_lock_irqsave(&sc->sc_pm_lock, flags);
1337 - sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
1338 - spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1339
1340 - /* Reset rssi stats */
1341 sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
1342 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
1343
1344 - ath_start_rx_poll(sc, 3);
1345 -
1346 - if (!common->disable_ani) {
1347 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1348 - ath_start_ani(common);
1349 - }
1350 -
1351 - }
1352 -}
1353 -
1354 -static void ath9k_config_bss(struct ath_softc *sc, struct ieee80211_vif *vif)
1355 -{
1356 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1357 - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
1358 - struct ath_vif *avp = (void *)vif->drv_priv;
1359 -
1360 - if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION)
1361 - return;
1362 -
1363 - /* Reconfigure bss info */
1364 - if (avp->primary_sta_vif && !bss_conf->assoc) {
1365 - ath_dbg(common, CONFIG, "Bss Info DISASSOC %d, bssid %pM\n",
1366 - common->curaid, common->curbssid);
1367 - clear_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags);
1368 - clear_bit(SC_OP_BEACONS, &sc->sc_flags);
1369 - avp->primary_sta_vif = false;
1370 - memset(common->curbssid, 0, ETH_ALEN);
1371 - common->curaid = 0;
1372 - }
1373 -
1374 - ieee80211_iterate_active_interfaces_atomic(
1375 - sc->hw, ath9k_bss_iter, sc);
1376 + spin_lock_irqsave(&sc->sc_pm_lock, flags);
1377 + sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
1378 + spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1379
1380 - /*
1381 - * None of station vifs are associated.
1382 - * Clear bssid & aid
1383 - */
1384 - if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1385 - ath9k_hw_write_associd(sc->sc_ah);
1386 - clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1387 - del_timer_sync(&common->ani.timer);
1388 - del_timer_sync(&sc->rx_poll_timer);
1389 - memset(&sc->caldata, 0, sizeof(sc->caldata));
1390 + ath_dbg(common, CONFIG,
1391 + "Primary Station interface: %pM, BSSID: %pM\n",
1392 + vif->addr, common->curbssid);
1393 }
1394 }
1395
1396 @@ -1547,6 +1453,11 @@ static void ath9k_bss_info_changed(struc
1397 struct ieee80211_bss_conf *bss_conf,
1398 u32 changed)
1399 {
1400 +#define CHECK_ANI \
1401 + (BSS_CHANGED_ASSOC | \
1402 + BSS_CHANGED_IBSS | \
1403 + BSS_CHANGED_BEACON_ENABLED)
1404 +
1405 struct ath_softc *sc = hw->priv;
1406 struct ath_hw *ah = sc->sc_ah;
1407 struct ath_common *common = ath9k_hw_common(ah);
1408 @@ -1557,53 +1468,43 @@ static void ath9k_bss_info_changed(struc
1409 mutex_lock(&sc->mutex);
1410
1411 if (changed & BSS_CHANGED_ASSOC) {
1412 - ath9k_config_bss(sc, vif);
1413 + ath_dbg(common, CONFIG, "BSSID %pM Changed ASSOC %d\n",
1414 + bss_conf->bssid, bss_conf->assoc);
1415
1416 - ath_dbg(common, CONFIG, "BSSID: %pM aid: 0x%x\n",
1417 - common->curbssid, common->curaid);
1418 + /*
1419 + * Do not do anything when the opmode is not STATION.
1420 + */
1421 + if (ah->opmode == NL80211_IFTYPE_STATION) {
1422 + if (avp->primary_sta_vif && !bss_conf->assoc) {
1423 + clear_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags);
1424 + clear_bit(SC_OP_BEACONS, &sc->sc_flags);
1425 + avp->primary_sta_vif = false;
1426 + }
1427 +
1428 + ieee80211_iterate_active_interfaces_atomic(sc->hw,
1429 + ath9k_bss_assoc_iter, sc);
1430 +
1431 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1432 + memset(common->curbssid, 0, ETH_ALEN);
1433 + common->curaid = 0;
1434 + ath9k_hw_write_associd(sc->sc_ah);
1435 + }
1436 + }
1437 }
1438
1439 if (changed & BSS_CHANGED_IBSS) {
1440 - /* There can be only one vif available */
1441 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
1442 common->curaid = bss_conf->aid;
1443 ath9k_hw_write_associd(sc->sc_ah);
1444 -
1445 - if (bss_conf->ibss_joined) {
1446 - sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
1447 -
1448 - if (!common->disable_ani) {
1449 - set_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1450 - ath_start_ani(common);
1451 - }
1452 -
1453 - } else {
1454 - clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
1455 - del_timer_sync(&common->ani.timer);
1456 - del_timer_sync(&sc->rx_poll_timer);
1457 - }
1458 }
1459
1460 - /*
1461 - * In case of AP mode, the HW TSF has to be reset
1462 - * when the beacon interval changes.
1463 - */
1464 - if ((changed & BSS_CHANGED_BEACON_INT) &&
1465 - (vif->type == NL80211_IFTYPE_AP))
1466 - set_bit(SC_OP_TSF_RESET, &sc->sc_flags);
1467 -
1468 - /* Configure beaconing (AP, IBSS, MESH) */
1469 - if (ath9k_uses_beacons(vif->type) &&
1470 - ((changed & BSS_CHANGED_BEACON) ||
1471 - (changed & BSS_CHANGED_BEACON_ENABLED) ||
1472 - (changed & BSS_CHANGED_BEACON_INT))) {
1473 - ath9k_set_beaconing_status(sc, false);
1474 - if (bss_conf->enable_beacon)
1475 - ath_beacon_alloc(sc, vif);
1476 - else
1477 - avp->is_bslot_active = false;
1478 - ath_beacon_config(sc, vif);
1479 - ath9k_set_beaconing_status(sc, true);
1480 + if ((changed & BSS_CHANGED_BEACON) ||
1481 + (changed & BSS_CHANGED_BEACON_ENABLED) ||
1482 + (changed & BSS_CHANGED_BEACON_INT)) {
1483 + if (ah->opmode == NL80211_IFTYPE_AP)
1484 + ath9k_set_tsfadjust(sc, vif);
1485 + if (ath9k_allow_beacon_config(sc, vif))
1486 + ath9k_beacon_config(sc, vif, changed);
1487 }
1488
1489 if (changed & BSS_CHANGED_ERP_SLOT) {
1490 @@ -1625,8 +1526,13 @@ static void ath9k_bss_info_changed(struc
1491 }
1492 }
1493
1494 + if (changed & CHECK_ANI)
1495 + ath_check_ani(sc);
1496 +
1497 mutex_unlock(&sc->mutex);
1498 ath9k_ps_restore(sc);
1499 +
1500 +#undef CHECK_ANI
1501 }
1502
1503 static u64 ath9k_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1504 @@ -1855,10 +1761,11 @@ static int ath9k_tx_last_beacon(struct i
1505 if (!vif)
1506 return 0;
1507
1508 - avp = (void *)vif->drv_priv;
1509 - if (!avp->is_bslot_active)
1510 + if (!vif->bss_conf.enable_beacon)
1511 return 0;
1512
1513 + avp = (void *)vif->drv_priv;
1514 +
1515 if (!sc->beacon.tx_processed && !edma) {
1516 tasklet_disable(&sc->bcon_tasklet);
1517
1518 --- a/drivers/net/wireless/ath/ath9k/mci.c
1519 +++ b/drivers/net/wireless/ath/ath9k/mci.c
1520 @@ -202,7 +202,7 @@ static void ath_mci_cal_msg(struct ath_s
1521 case MCI_GPM_BT_CAL_REQ:
1522 if (mci_hw->bt_state == MCI_BT_AWAKE) {
1523 ar9003_mci_state(ah, MCI_STATE_SET_BT_CAL_START);
1524 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
1525 + ath9k_queue_reset(sc, RESET_TYPE_MCI);
1526 }
1527 ath_dbg(common, MCI, "MCI State : %d\n", mci_hw->bt_state);
1528 break;
1529 --- a/drivers/net/wireless/ath/ath9k/recv.c
1530 +++ b/drivers/net/wireless/ath/ath9k/recv.c
1531 @@ -553,7 +553,7 @@ static void ath_rx_ps_beacon(struct ath_
1532 sc->ps_flags &= ~PS_BEACON_SYNC;
1533 ath_dbg(common, PS,
1534 "Reconfigure Beacon timers based on timestamp from the AP\n");
1535 - ath_set_beacon(sc);
1536 + ath9k_set_beacon(sc);
1537 }
1538
1539 if (ath_beacon_dtim_pending_cab(skb)) {
1540 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1541 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1542 @@ -614,10 +614,8 @@ static void ath_tx_complete_aggr(struct
1543
1544 rcu_read_unlock();
1545
1546 - if (needreset) {
1547 - RESET_STAT_INC(sc, RESET_TYPE_TX_ERROR);
1548 - ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
1549 - }
1550 + if (needreset)
1551 + ath9k_queue_reset(sc, RESET_TYPE_TX_ERROR);
1552 }
1553
1554 static bool ath_lookup_legacy(struct ath_buf *bf)
1555 @@ -1586,7 +1584,8 @@ void ath_txq_schedule(struct ath_softc *
1556 struct ath_atx_ac *ac, *ac_tmp, *last_ac;
1557 struct ath_atx_tid *tid, *last_tid;
1558
1559 - if (work_pending(&sc->hw_reset_work) || list_empty(&txq->axq_acq) ||
1560 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags) ||
1561 + list_empty(&txq->axq_acq) ||
1562 txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH)
1563 return;
1564
1565 @@ -2191,7 +2190,7 @@ static void ath_tx_processq(struct ath_s
1566
1567 ath_txq_lock(sc, txq);
1568 for (;;) {
1569 - if (work_pending(&sc->hw_reset_work))
1570 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags))
1571 break;
1572
1573 if (list_empty(&txq->axq_q)) {
1574 @@ -2274,7 +2273,7 @@ void ath_tx_edma_tasklet(struct ath_soft
1575 int status;
1576
1577 for (;;) {
1578 - if (work_pending(&sc->hw_reset_work))
1579 + if (test_bit(SC_OP_HW_RESET, &sc->sc_flags))
1580 break;
1581
1582 status = ath9k_hw_txprocdesc(ah, NULL, (void *)&ts);
1583 --- a/include/net/mac80211.h
1584 +++ b/include/net/mac80211.h
1585 @@ -3596,22 +3596,6 @@ void ieee80211_request_smps(struct ieee8
1586 enum ieee80211_smps_mode smps_mode);
1587
1588 /**
1589 - * ieee80211_key_removed - disable hw acceleration for key
1590 - * @key_conf: The key hw acceleration should be disabled for
1591 - *
1592 - * This allows drivers to indicate that the given key has been
1593 - * removed from hardware acceleration, due to a new key that
1594 - * was added. Don't use this if the key can continue to be used
1595 - * for TX, if the key restriction is on RX only it is permitted
1596 - * to keep the key for TX only and not call this function.
1597 - *
1598 - * Due to locking constraints, it may only be called during
1599 - * @set_key. This function must be allowed to sleep, and the
1600 - * key it tries to disable may still be used until it returns.
1601 - */
1602 -void ieee80211_key_removed(struct ieee80211_key_conf *key_conf);
1603 -
1604 -/**
1605 * ieee80211_ready_on_channel - notification of remain-on-channel start
1606 * @hw: pointer as obtained from ieee80211_alloc_hw()
1607 */
1608 --- a/net/mac80211/agg-rx.c
1609 +++ b/net/mac80211/agg-rx.c
1610 @@ -203,6 +203,8 @@ static void ieee80211_send_addba_resp(st
1611 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1612 else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1613 memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN);
1614 + else if (sdata->vif.type == NL80211_IFTYPE_WDS)
1615 + memcpy(mgmt->bssid, da, ETH_ALEN);
1616
1617 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1618 IEEE80211_STYPE_ACTION);
1619 --- a/net/mac80211/agg-tx.c
1620 +++ b/net/mac80211/agg-tx.c
1621 @@ -81,7 +81,8 @@ static void ieee80211_send_addba_request
1622 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
1623 if (sdata->vif.type == NL80211_IFTYPE_AP ||
1624 sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
1625 - sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
1626 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
1627 + sdata->vif.type == NL80211_IFTYPE_WDS)
1628 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
1629 else if (sdata->vif.type == NL80211_IFTYPE_STATION)
1630 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
1631 @@ -459,6 +460,7 @@ int ieee80211_start_tx_ba_session(struct
1632 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1633 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1634 sdata->vif.type != NL80211_IFTYPE_AP &&
1635 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1636 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1637 return -EINVAL;
1638
1639 --- a/net/mac80211/cfg.c
1640 +++ b/net/mac80211/cfg.c
1641 @@ -1741,6 +1741,8 @@ static int ieee80211_set_txq_params(stru
1642 return -EINVAL;
1643 }
1644
1645 + ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_QOS);
1646 +
1647 return 0;
1648 }
1649
1650 --- a/net/mac80211/debugfs_sta.c
1651 +++ b/net/mac80211/debugfs_sta.c
1652 @@ -63,11 +63,11 @@ static ssize_t sta_flags_read(struct fil
1653 test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""
1654
1655 int res = scnprintf(buf, sizeof(buf),
1656 - "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1657 + "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
1658 TEST(AUTH), TEST(ASSOC), TEST(PS_STA),
1659 TEST(PS_DRIVER), TEST(AUTHORIZED),
1660 TEST(SHORT_PREAMBLE),
1661 - TEST(WME), TEST(WDS), TEST(CLEAR_PS_FILT),
1662 + TEST(WME), TEST(CLEAR_PS_FILT),
1663 TEST(MFP), TEST(BLOCK_BA), TEST(PSPOLL),
1664 TEST(UAPSD), TEST(SP), TEST(TDLS_PEER),
1665 TEST(TDLS_PEER_AUTH), TEST(4ADDR_EVENT),
1666 --- a/net/mac80211/iface.c
1667 +++ b/net/mac80211/iface.c
1668 @@ -400,7 +400,6 @@ static int ieee80211_do_open(struct net_
1669 {
1670 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1671 struct ieee80211_local *local = sdata->local;
1672 - struct sta_info *sta;
1673 u32 changed = 0;
1674 int res;
1675 u32 hw_reconf_flags = 0;
1676 @@ -538,28 +537,6 @@ static int ieee80211_do_open(struct net_
1677
1678 set_bit(SDATA_STATE_RUNNING, &sdata->state);
1679
1680 - if (sdata->vif.type == NL80211_IFTYPE_WDS) {
1681 - /* Create STA entry for the WDS peer */
1682 - sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1683 - GFP_KERNEL);
1684 - if (!sta) {
1685 - res = -ENOMEM;
1686 - goto err_del_interface;
1687 - }
1688 -
1689 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1690 - sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1691 - sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1692 -
1693 - res = sta_info_insert(sta);
1694 - if (res) {
1695 - /* STA has been freed */
1696 - goto err_del_interface;
1697 - }
1698 -
1699 - rate_control_rate_init(sta);
1700 - }
1701 -
1702 /*
1703 * set_multicast_list will be invoked by the networking core
1704 * which will check whether any increments here were done in
1705 @@ -949,6 +926,72 @@ static void ieee80211_if_setup(struct ne
1706 dev->destructor = free_netdev;
1707 }
1708
1709 +static void ieee80211_wds_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
1710 + struct sk_buff *skb)
1711 +{
1712 + struct ieee80211_local *local = sdata->local;
1713 + struct ieee80211_rx_status *rx_status;
1714 + struct ieee802_11_elems elems;
1715 + struct ieee80211_mgmt *mgmt;
1716 + struct sta_info *sta;
1717 + size_t baselen;
1718 + u32 rates = 0;
1719 + u16 stype;
1720 + bool new = false;
1721 + enum ieee80211_band band = local->hw.conf.channel->band;
1722 + struct ieee80211_supported_band *sband = local->hw.wiphy->bands[band];
1723 +
1724 + rx_status = IEEE80211_SKB_RXCB(skb);
1725 + mgmt = (struct ieee80211_mgmt *) skb->data;
1726 + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE;
1727 +
1728 + if (stype != IEEE80211_STYPE_BEACON)
1729 + return;
1730 +
1731 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
1732 + if (baselen > skb->len)
1733 + return;
1734 +
1735 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable,
1736 + skb->len - baselen, &elems);
1737 +
1738 + rates = ieee80211_sta_get_rates(local, &elems, band, NULL);
1739 +
1740 + rcu_read_lock();
1741 +
1742 + sta = sta_info_get(sdata, sdata->u.wds.remote_addr);
1743 +
1744 + if (!sta) {
1745 + rcu_read_unlock();
1746 + sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
1747 + GFP_KERNEL);
1748 + if (!sta)
1749 + return;
1750 +
1751 + new = true;
1752 + }
1753 +
1754 + sta->last_rx = jiffies;
1755 + sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
1756 +
1757 + if (elems.ht_cap_elem)
1758 + ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
1759 + elems.ht_cap_elem, &sta->sta.ht_cap);
1760 +
1761 + if (elems.wmm_param)
1762 + set_sta_flag(sta, WLAN_STA_WME);
1763 +
1764 + if (new) {
1765 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
1766 + sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
1767 + sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
1768 + rate_control_rate_init(sta);
1769 + sta_info_insert_rcu(sta);
1770 + }
1771 +
1772 + rcu_read_unlock();
1773 +}
1774 +
1775 static void ieee80211_iface_work(struct work_struct *work)
1776 {
1777 struct ieee80211_sub_if_data *sdata =
1778 @@ -1053,6 +1096,9 @@ static void ieee80211_iface_work(struct
1779 break;
1780 ieee80211_mesh_rx_queued_mgmt(sdata, skb);
1781 break;
1782 + case NL80211_IFTYPE_WDS:
1783 + ieee80211_wds_rx_queued_mgmt(sdata, skb);
1784 + break;
1785 default:
1786 WARN(1, "frame for unexpected interface type");
1787 break;
1788 --- a/net/mac80211/key.c
1789 +++ b/net/mac80211/key.c
1790 @@ -197,26 +197,6 @@ static void ieee80211_key_disable_hw_acc
1791 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
1792 }
1793
1794 -void ieee80211_key_removed(struct ieee80211_key_conf *key_conf)
1795 -{
1796 - struct ieee80211_key *key;
1797 -
1798 - key = container_of(key_conf, struct ieee80211_key, conf);
1799 -
1800 - might_sleep();
1801 - assert_key_lock(key->local);
1802 -
1803 - key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
1804 -
1805 - /*
1806 - * Flush TX path to avoid attempts to use this key
1807 - * after this function returns. Until then, drivers
1808 - * must be prepared to handle the key.
1809 - */
1810 - synchronize_rcu();
1811 -}
1812 -EXPORT_SYMBOL_GPL(ieee80211_key_removed);
1813 -
1814 static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
1815 int idx, bool uni, bool multi)
1816 {
1817 --- a/net/mac80211/mlme.c
1818 +++ b/net/mac80211/mlme.c
1819 @@ -1108,7 +1108,7 @@ void ieee80211_dynamic_ps_timer(unsigned
1820 }
1821
1822 /* MLME */
1823 -static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
1824 +static bool ieee80211_sta_wmm_params(struct ieee80211_local *local,
1825 struct ieee80211_sub_if_data *sdata,
1826 u8 *wmm_param, size_t wmm_param_len)
1827 {
1828 @@ -1119,23 +1119,23 @@ static void ieee80211_sta_wmm_params(str
1829 u8 *pos, uapsd_queues = 0;
1830
1831 if (!local->ops->conf_tx)
1832 - return;
1833 + return false;
1834
1835 if (local->hw.queues < IEEE80211_NUM_ACS)
1836 - return;
1837 + return false;
1838
1839 if (!wmm_param)
1840 - return;
1841 + return false;
1842
1843 if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1)
1844 - return;
1845 + return false;
1846
1847 if (ifmgd->flags & IEEE80211_STA_UAPSD_ENABLED)
1848 uapsd_queues = ifmgd->uapsd_queues;
1849
1850 count = wmm_param[6] & 0x0f;
1851 if (count == ifmgd->wmm_last_param_set)
1852 - return;
1853 + return false;
1854 ifmgd->wmm_last_param_set = count;
1855
1856 pos = wmm_param + 8;
1857 @@ -1202,6 +1202,7 @@ static void ieee80211_sta_wmm_params(str
1858
1859 /* enable WMM or activate new settings */
1860 sdata->vif.bss_conf.qos = true;
1861 + return true;
1862 }
1863
1864 static void __ieee80211_stop_poll(struct ieee80211_sub_if_data *sdata)
1865 @@ -2435,14 +2436,6 @@ static void ieee80211_rx_mgmt_beacon(str
1866 directed_tim = ieee80211_check_tim(elems.tim, elems.tim_len,
1867 ifmgd->aid);
1868
1869 - if (ncrc != ifmgd->beacon_crc || !ifmgd->beacon_crc_valid) {
1870 - ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems,
1871 - true);
1872 -
1873 - ieee80211_sta_wmm_params(local, sdata, elems.wmm_param,
1874 - elems.wmm_param_len);
1875 - }
1876 -
1877 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) {
1878 if (directed_tim) {
1879 if (local->hw.conf.dynamic_ps_timeout > 0) {
1880 @@ -2473,6 +2466,13 @@ static void ieee80211_rx_mgmt_beacon(str
1881 ifmgd->beacon_crc = ncrc;
1882 ifmgd->beacon_crc_valid = true;
1883
1884 + ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems,
1885 + true);
1886 +
1887 + if (ieee80211_sta_wmm_params(local, sdata, elems.wmm_param,
1888 + elems.wmm_param_len))
1889 + changed |= BSS_CHANGED_QOS;
1890 +
1891 if (elems.erp_info && elems.erp_info_len >= 1) {
1892 erp_valid = true;
1893 erp_value = elems.erp_info[0];
1894 --- a/net/mac80211/rc80211_minstrel_ht.c
1895 +++ b/net/mac80211/rc80211_minstrel_ht.c
1896 @@ -626,8 +626,12 @@ minstrel_ht_get_rate(void *priv, struct
1897
1898 #ifdef CONFIG_MAC80211_DEBUGFS
1899 /* use fixed index if set */
1900 - if (mp->fixed_rate_idx != -1)
1901 - sample_idx = mp->fixed_rate_idx;
1902 + if (mp->fixed_rate_idx != -1) {
1903 + mi->max_tp_rate = mp->fixed_rate_idx;
1904 + mi->max_tp_rate2 = mp->fixed_rate_idx;
1905 + mi->max_prob_rate = mp->fixed_rate_idx;
1906 + sample_idx = -1;
1907 + }
1908 #endif
1909
1910 if (sample_idx >= 0) {
1911 --- a/net/mac80211/rx.c
1912 +++ b/net/mac80211/rx.c
1913 @@ -2262,6 +2262,7 @@ ieee80211_rx_h_action(struct ieee80211_r
1914 sdata->vif.type != NL80211_IFTYPE_MESH_POINT &&
1915 sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
1916 sdata->vif.type != NL80211_IFTYPE_AP &&
1917 + sdata->vif.type != NL80211_IFTYPE_WDS &&
1918 sdata->vif.type != NL80211_IFTYPE_ADHOC)
1919 break;
1920
1921 @@ -2479,14 +2480,15 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_
1922
1923 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
1924 sdata->vif.type != NL80211_IFTYPE_ADHOC &&
1925 - sdata->vif.type != NL80211_IFTYPE_STATION)
1926 + sdata->vif.type != NL80211_IFTYPE_STATION &&
1927 + sdata->vif.type != NL80211_IFTYPE_WDS)
1928 return RX_DROP_MONITOR;
1929
1930 switch (stype) {
1931 case cpu_to_le16(IEEE80211_STYPE_AUTH):
1932 case cpu_to_le16(IEEE80211_STYPE_BEACON):
1933 case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP):
1934 - /* process for all: mesh, mlme, ibss */
1935 + /* process for all: mesh, mlme, ibss, wds */
1936 break;
1937 case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP):
1938 case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP):
1939 @@ -2817,10 +2819,16 @@ static int prepare_for_handlers(struct i
1940 }
1941 break;
1942 case NL80211_IFTYPE_WDS:
1943 - if (bssid || !ieee80211_is_data(hdr->frame_control))
1944 - return 0;
1945 if (!ether_addr_equal(sdata->u.wds.remote_addr, hdr->addr2))
1946 return 0;
1947 +
1948 + if (ieee80211_is_data(hdr->frame_control) ||
1949 + ieee80211_is_action(hdr->frame_control)) {
1950 + if (compare_ether_addr(sdata->vif.addr, hdr->addr1))
1951 + return 0;
1952 + } else if (!ieee80211_is_beacon(hdr->frame_control))
1953 + return 0;
1954 +
1955 break;
1956 default:
1957 /* should never get here */
1958 --- a/net/mac80211/sta_info.h
1959 +++ b/net/mac80211/sta_info.h
1960 @@ -32,7 +32,6 @@
1961 * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble
1962 * frames.
1963 * @WLAN_STA_WME: Station is a QoS-STA.
1964 - * @WLAN_STA_WDS: Station is one of our WDS peers.
1965 * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the
1966 * IEEE80211_TX_CTL_CLEAR_PS_FILT control flag) when the next
1967 * frame to this station is transmitted.
1968 @@ -64,7 +63,6 @@ enum ieee80211_sta_info_flags {
1969 WLAN_STA_AUTHORIZED,
1970 WLAN_STA_SHORT_PREAMBLE,
1971 WLAN_STA_WME,
1972 - WLAN_STA_WDS,
1973 WLAN_STA_CLEAR_PS_FILT,
1974 WLAN_STA_MFP,
1975 WLAN_STA_BLOCK_BA,
1976 --- a/net/mac80211/tx.c
1977 +++ b/net/mac80211/tx.c
1978 @@ -2716,7 +2716,7 @@ EXPORT_SYMBOL(ieee80211_get_buffered_bc)
1979 void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
1980 struct sk_buff *skb, int tid)
1981 {
1982 - int ac = ieee802_1d_to_ac[tid];
1983 + int ac = ieee802_1d_to_ac[tid & 7];
1984
1985 skb_set_mac_header(skb, 0);
1986 skb_set_network_header(skb, 0);