1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (c) 2008-2011 Atheros Communications Inc.
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Permission to use, copy, modify, and/or distribute this software for any
5*4882a593Smuzhiyun * purpose with or without fee is hereby granted, provided that the above
6*4882a593Smuzhiyun * copyright notice and this permission notice appear in all copies.
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*4882a593Smuzhiyun * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*4882a593Smuzhiyun * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*4882a593Smuzhiyun * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*4882a593Smuzhiyun * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*4882a593Smuzhiyun * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*4882a593Smuzhiyun * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*4882a593Smuzhiyun */
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #include <linux/dma-mapping.h>
18*4882a593Smuzhiyun #include "ath9k.h"
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun #define FUDGE 2
21*4882a593Smuzhiyun
ath9k_reset_beacon_status(struct ath_softc * sc)22*4882a593Smuzhiyun static void ath9k_reset_beacon_status(struct ath_softc *sc)
23*4882a593Smuzhiyun {
24*4882a593Smuzhiyun sc->beacon.tx_processed = false;
25*4882a593Smuzhiyun sc->beacon.tx_last = false;
26*4882a593Smuzhiyun }
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun * This function will modify certain transmit queue properties depending on
30*4882a593Smuzhiyun * the operating mode of the station (AP or AdHoc). Parameters are AIFS
31*4882a593Smuzhiyun * settings and channel width min/max
32*4882a593Smuzhiyun */
ath9k_beaconq_config(struct ath_softc * sc)33*4882a593Smuzhiyun static void ath9k_beaconq_config(struct ath_softc *sc)
34*4882a593Smuzhiyun {
35*4882a593Smuzhiyun struct ath_hw *ah = sc->sc_ah;
36*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(ah);
37*4882a593Smuzhiyun struct ath9k_tx_queue_info qi, qi_be;
38*4882a593Smuzhiyun struct ath_txq *txq;
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun ath9k_hw_get_txq_props(ah, sc->beacon.beaconq, &qi);
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun if (sc->sc_ah->opmode == NL80211_IFTYPE_AP ||
43*4882a593Smuzhiyun sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) {
44*4882a593Smuzhiyun /* Always burst out beacon and CAB traffic. */
45*4882a593Smuzhiyun qi.tqi_aifs = 1;
46*4882a593Smuzhiyun qi.tqi_cwmin = 0;
47*4882a593Smuzhiyun qi.tqi_cwmax = 0;
48*4882a593Smuzhiyun } else {
49*4882a593Smuzhiyun /* Adhoc mode; important thing is to use 2x cwmin. */
50*4882a593Smuzhiyun txq = sc->tx.txq_map[IEEE80211_AC_BE];
51*4882a593Smuzhiyun ath9k_hw_get_txq_props(ah, txq->axq_qnum, &qi_be);
52*4882a593Smuzhiyun qi.tqi_aifs = qi_be.tqi_aifs;
53*4882a593Smuzhiyun if (ah->slottime == 20)
54*4882a593Smuzhiyun qi.tqi_cwmin = 2*qi_be.tqi_cwmin;
55*4882a593Smuzhiyun else
56*4882a593Smuzhiyun qi.tqi_cwmin = 4*qi_be.tqi_cwmin;
57*4882a593Smuzhiyun qi.tqi_cwmax = qi_be.tqi_cwmax;
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun if (!ath9k_hw_set_txq_props(ah, sc->beacon.beaconq, &qi)) {
61*4882a593Smuzhiyun ath_err(common, "Unable to update h/w beacon queue parameters\n");
62*4882a593Smuzhiyun } else {
63*4882a593Smuzhiyun ath9k_hw_resettxqueue(ah, sc->beacon.beaconq);
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun }
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun /*
68*4882a593Smuzhiyun * Associates the beacon frame buffer with a transmit descriptor. Will set
69*4882a593Smuzhiyun * up rate codes, and channel flags. Beacons are always sent out at the
70*4882a593Smuzhiyun * lowest rate, and are not retried.
71*4882a593Smuzhiyun */
ath9k_beacon_setup(struct ath_softc * sc,struct ieee80211_vif * vif,struct ath_buf * bf,int rateidx)72*4882a593Smuzhiyun static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
73*4882a593Smuzhiyun struct ath_buf *bf, int rateidx)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun struct sk_buff *skb = bf->bf_mpdu;
76*4882a593Smuzhiyun struct ath_hw *ah = sc->sc_ah;
77*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(ah);
78*4882a593Smuzhiyun struct ath_tx_info info;
79*4882a593Smuzhiyun struct ieee80211_supported_band *sband;
80*4882a593Smuzhiyun u8 chainmask = ah->txchainmask;
81*4882a593Smuzhiyun u8 i, rate = 0;
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun sband = &common->sbands[sc->cur_chandef.chan->band];
84*4882a593Smuzhiyun rate = sband->bitrates[rateidx].hw_value;
85*4882a593Smuzhiyun if (vif->bss_conf.use_short_preamble)
86*4882a593Smuzhiyun rate |= sband->bitrates[rateidx].hw_value_short;
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun memset(&info, 0, sizeof(info));
89*4882a593Smuzhiyun info.pkt_len = skb->len + FCS_LEN;
90*4882a593Smuzhiyun info.type = ATH9K_PKT_TYPE_BEACON;
91*4882a593Smuzhiyun for (i = 0; i < 4; i++)
92*4882a593Smuzhiyun info.txpower[i] = MAX_RATE_POWER;
93*4882a593Smuzhiyun info.keyix = ATH9K_TXKEYIX_INVALID;
94*4882a593Smuzhiyun info.keytype = ATH9K_KEY_TYPE_CLEAR;
95*4882a593Smuzhiyun info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_CLRDMASK;
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun info.buf_addr[0] = bf->bf_buf_addr;
98*4882a593Smuzhiyun info.buf_len[0] = roundup(skb->len, 4);
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun info.is_first = true;
101*4882a593Smuzhiyun info.is_last = true;
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun info.qcu = sc->beacon.beaconq;
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun info.rates[0].Tries = 1;
106*4882a593Smuzhiyun info.rates[0].Rate = rate;
107*4882a593Smuzhiyun info.rates[0].ChSel = ath_txchainmask_reduction(sc, chainmask, rate);
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun ath9k_hw_set_txdesc(ah, bf->bf_desc, &info);
110*4882a593Smuzhiyun }
111*4882a593Smuzhiyun
ath9k_beacon_generate(struct ieee80211_hw * hw,struct ieee80211_vif * vif)112*4882a593Smuzhiyun static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
113*4882a593Smuzhiyun struct ieee80211_vif *vif)
114*4882a593Smuzhiyun {
115*4882a593Smuzhiyun struct ath_softc *sc = hw->priv;
116*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
117*4882a593Smuzhiyun struct ath_buf *bf;
118*4882a593Smuzhiyun struct ath_vif *avp = (void *)vif->drv_priv;
119*4882a593Smuzhiyun struct sk_buff *skb;
120*4882a593Smuzhiyun struct ath_txq *cabq = sc->beacon.cabq;
121*4882a593Smuzhiyun struct ieee80211_tx_info *info;
122*4882a593Smuzhiyun struct ieee80211_mgmt *mgmt_hdr;
123*4882a593Smuzhiyun int cabq_depth;
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun if (avp->av_bcbuf == NULL)
126*4882a593Smuzhiyun return NULL;
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun bf = avp->av_bcbuf;
129*4882a593Smuzhiyun skb = bf->bf_mpdu;
130*4882a593Smuzhiyun if (skb) {
131*4882a593Smuzhiyun dma_unmap_single(sc->dev, bf->bf_buf_addr,
132*4882a593Smuzhiyun skb->len, DMA_TO_DEVICE);
133*4882a593Smuzhiyun dev_kfree_skb_any(skb);
134*4882a593Smuzhiyun bf->bf_buf_addr = 0;
135*4882a593Smuzhiyun bf->bf_mpdu = NULL;
136*4882a593Smuzhiyun }
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun skb = ieee80211_beacon_get(hw, vif);
139*4882a593Smuzhiyun if (skb == NULL)
140*4882a593Smuzhiyun return NULL;
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun bf->bf_mpdu = skb;
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun mgmt_hdr = (struct ieee80211_mgmt *)skb->data;
145*4882a593Smuzhiyun mgmt_hdr->u.beacon.timestamp = avp->tsf_adjust;
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun info = IEEE80211_SKB_CB(skb);
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun ath_assign_seq(common, skb);
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun /* Always assign NOA attr when MCC enabled */
152*4882a593Smuzhiyun if (ath9k_is_chanctx_enabled())
153*4882a593Smuzhiyun ath9k_beacon_add_noa(sc, avp, skb);
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
156*4882a593Smuzhiyun skb->len, DMA_TO_DEVICE);
157*4882a593Smuzhiyun if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
158*4882a593Smuzhiyun dev_kfree_skb_any(skb);
159*4882a593Smuzhiyun bf->bf_mpdu = NULL;
160*4882a593Smuzhiyun bf->bf_buf_addr = 0;
161*4882a593Smuzhiyun ath_err(common, "dma_mapping_error on beaconing\n");
162*4882a593Smuzhiyun return NULL;
163*4882a593Smuzhiyun }
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun skb = ieee80211_get_buffered_bc(hw, vif);
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun /*
168*4882a593Smuzhiyun * if the CABQ traffic from previous DTIM is pending and the current
169*4882a593Smuzhiyun * beacon is also a DTIM.
170*4882a593Smuzhiyun * 1) if there is only one vif let the cab traffic continue.
171*4882a593Smuzhiyun * 2) if there are more than one vif and we are using staggered
172*4882a593Smuzhiyun * beacons, then drain the cabq by dropping all the frames in
173*4882a593Smuzhiyun * the cabq so that the current vifs cab traffic can be scheduled.
174*4882a593Smuzhiyun */
175*4882a593Smuzhiyun spin_lock_bh(&cabq->axq_lock);
176*4882a593Smuzhiyun cabq_depth = cabq->axq_depth;
177*4882a593Smuzhiyun spin_unlock_bh(&cabq->axq_lock);
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun if (skb && cabq_depth) {
180*4882a593Smuzhiyun if (sc->cur_chan->nvifs > 1) {
181*4882a593Smuzhiyun ath_dbg(common, BEACON,
182*4882a593Smuzhiyun "Flushing previous cabq traffic\n");
183*4882a593Smuzhiyun ath_draintxq(sc, cabq);
184*4882a593Smuzhiyun }
185*4882a593Smuzhiyun }
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun ath9k_beacon_setup(sc, vif, bf, info->control.rates[0].idx);
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun if (skb)
190*4882a593Smuzhiyun ath_tx_cabq(hw, vif, skb);
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun return bf;
193*4882a593Smuzhiyun }
194*4882a593Smuzhiyun
ath9k_beacon_assign_slot(struct ath_softc * sc,struct ieee80211_vif * vif)195*4882a593Smuzhiyun void ath9k_beacon_assign_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
196*4882a593Smuzhiyun {
197*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
198*4882a593Smuzhiyun struct ath_vif *avp = (void *)vif->drv_priv;
199*4882a593Smuzhiyun int slot;
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun avp->av_bcbuf = list_first_entry(&sc->beacon.bbuf, struct ath_buf, list);
202*4882a593Smuzhiyun list_del(&avp->av_bcbuf->list);
203*4882a593Smuzhiyun
204*4882a593Smuzhiyun for (slot = 0; slot < ATH_BCBUF; slot++) {
205*4882a593Smuzhiyun if (sc->beacon.bslot[slot] == NULL) {
206*4882a593Smuzhiyun avp->av_bslot = slot;
207*4882a593Smuzhiyun break;
208*4882a593Smuzhiyun }
209*4882a593Smuzhiyun }
210*4882a593Smuzhiyun
211*4882a593Smuzhiyun sc->beacon.bslot[avp->av_bslot] = vif;
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun ath_dbg(common, CONFIG, "Added interface at beacon slot: %d\n",
214*4882a593Smuzhiyun avp->av_bslot);
215*4882a593Smuzhiyun }
216*4882a593Smuzhiyun
ath9k_beacon_remove_slot(struct ath_softc * sc,struct ieee80211_vif * vif)217*4882a593Smuzhiyun void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
218*4882a593Smuzhiyun {
219*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
220*4882a593Smuzhiyun struct ath_vif *avp = (void *)vif->drv_priv;
221*4882a593Smuzhiyun struct ath_buf *bf = avp->av_bcbuf;
222*4882a593Smuzhiyun
223*4882a593Smuzhiyun ath_dbg(common, CONFIG, "Removing interface at beacon slot: %d\n",
224*4882a593Smuzhiyun avp->av_bslot);
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun tasklet_disable(&sc->bcon_tasklet);
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun if (bf && bf->bf_mpdu) {
229*4882a593Smuzhiyun struct sk_buff *skb = bf->bf_mpdu;
230*4882a593Smuzhiyun dma_unmap_single(sc->dev, bf->bf_buf_addr,
231*4882a593Smuzhiyun skb->len, DMA_TO_DEVICE);
232*4882a593Smuzhiyun dev_kfree_skb_any(skb);
233*4882a593Smuzhiyun bf->bf_mpdu = NULL;
234*4882a593Smuzhiyun bf->bf_buf_addr = 0;
235*4882a593Smuzhiyun }
236*4882a593Smuzhiyun
237*4882a593Smuzhiyun avp->av_bcbuf = NULL;
238*4882a593Smuzhiyun sc->beacon.bslot[avp->av_bslot] = NULL;
239*4882a593Smuzhiyun list_add_tail(&bf->list, &sc->beacon.bbuf);
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun tasklet_enable(&sc->bcon_tasklet);
242*4882a593Smuzhiyun }
243*4882a593Smuzhiyun
ath9k_beacon_ensure_primary_slot(struct ath_softc * sc)244*4882a593Smuzhiyun void ath9k_beacon_ensure_primary_slot(struct ath_softc *sc)
245*4882a593Smuzhiyun {
246*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
247*4882a593Smuzhiyun struct ieee80211_vif *vif;
248*4882a593Smuzhiyun struct ath_vif *avp;
249*4882a593Smuzhiyun s64 tsfadjust;
250*4882a593Smuzhiyun u32 offset;
251*4882a593Smuzhiyun int first_slot = ATH_BCBUF;
252*4882a593Smuzhiyun int slot;
253*4882a593Smuzhiyun
254*4882a593Smuzhiyun tasklet_disable(&sc->bcon_tasklet);
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun /* Find first taken slot. */
257*4882a593Smuzhiyun for (slot = 0; slot < ATH_BCBUF; slot++) {
258*4882a593Smuzhiyun if (sc->beacon.bslot[slot]) {
259*4882a593Smuzhiyun first_slot = slot;
260*4882a593Smuzhiyun break;
261*4882a593Smuzhiyun }
262*4882a593Smuzhiyun }
263*4882a593Smuzhiyun if (first_slot == 0)
264*4882a593Smuzhiyun goto out;
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun /* Re-enumarate all slots, moving them forward. */
267*4882a593Smuzhiyun for (slot = 0; slot < ATH_BCBUF; slot++) {
268*4882a593Smuzhiyun if (slot + first_slot < ATH_BCBUF) {
269*4882a593Smuzhiyun vif = sc->beacon.bslot[slot + first_slot];
270*4882a593Smuzhiyun sc->beacon.bslot[slot] = vif;
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun if (vif) {
273*4882a593Smuzhiyun avp = (void *)vif->drv_priv;
274*4882a593Smuzhiyun avp->av_bslot = slot;
275*4882a593Smuzhiyun }
276*4882a593Smuzhiyun } else {
277*4882a593Smuzhiyun sc->beacon.bslot[slot] = NULL;
278*4882a593Smuzhiyun }
279*4882a593Smuzhiyun }
280*4882a593Smuzhiyun
281*4882a593Smuzhiyun vif = sc->beacon.bslot[0];
282*4882a593Smuzhiyun if (WARN_ON(!vif))
283*4882a593Smuzhiyun goto out;
284*4882a593Smuzhiyun
285*4882a593Smuzhiyun /* Get the tsf_adjust value for the new first slot. */
286*4882a593Smuzhiyun avp = (void *)vif->drv_priv;
287*4882a593Smuzhiyun tsfadjust = le64_to_cpu(avp->tsf_adjust);
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun ath_dbg(common, CONFIG,
290*4882a593Smuzhiyun "Adjusting global TSF after beacon slot reassignment: %lld\n",
291*4882a593Smuzhiyun (signed long long)tsfadjust);
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun /* Modify TSF as required and update the HW. */
294*4882a593Smuzhiyun avp->chanctx->tsf_val += tsfadjust;
295*4882a593Smuzhiyun if (sc->cur_chan == avp->chanctx) {
296*4882a593Smuzhiyun offset = ath9k_hw_get_tsf_offset(&avp->chanctx->tsf_ts, NULL);
297*4882a593Smuzhiyun ath9k_hw_settsf64(sc->sc_ah, avp->chanctx->tsf_val + offset);
298*4882a593Smuzhiyun }
299*4882a593Smuzhiyun
300*4882a593Smuzhiyun /* The slots tsf_adjust will be updated by ath9k_beacon_config later. */
301*4882a593Smuzhiyun
302*4882a593Smuzhiyun out:
303*4882a593Smuzhiyun tasklet_enable(&sc->bcon_tasklet);
304*4882a593Smuzhiyun }
305*4882a593Smuzhiyun
ath9k_beacon_choose_slot(struct ath_softc * sc)306*4882a593Smuzhiyun static int ath9k_beacon_choose_slot(struct ath_softc *sc)
307*4882a593Smuzhiyun {
308*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
309*4882a593Smuzhiyun struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon;
310*4882a593Smuzhiyun u16 intval;
311*4882a593Smuzhiyun u32 tsftu;
312*4882a593Smuzhiyun u64 tsf;
313*4882a593Smuzhiyun int slot;
314*4882a593Smuzhiyun
315*4882a593Smuzhiyun if (sc->sc_ah->opmode != NL80211_IFTYPE_AP &&
316*4882a593Smuzhiyun sc->sc_ah->opmode != NL80211_IFTYPE_MESH_POINT) {
317*4882a593Smuzhiyun ath_dbg(common, BEACON, "slot 0, tsf: %llu\n",
318*4882a593Smuzhiyun ath9k_hw_gettsf64(sc->sc_ah));
319*4882a593Smuzhiyun return 0;
320*4882a593Smuzhiyun }
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun intval = cur_conf->beacon_interval ? : ATH_DEFAULT_BINTVAL;
323*4882a593Smuzhiyun tsf = ath9k_hw_gettsf64(sc->sc_ah);
324*4882a593Smuzhiyun tsf += TU_TO_USEC(sc->sc_ah->config.sw_beacon_response_time);
325*4882a593Smuzhiyun tsftu = TSF_TO_TU((tsf * ATH_BCBUF) >>32, tsf * ATH_BCBUF);
326*4882a593Smuzhiyun slot = (tsftu % (intval * ATH_BCBUF)) / intval;
327*4882a593Smuzhiyun
328*4882a593Smuzhiyun ath_dbg(common, BEACON, "slot: %d tsf: %llu tsftu: %u\n",
329*4882a593Smuzhiyun slot, tsf, tsftu / ATH_BCBUF);
330*4882a593Smuzhiyun
331*4882a593Smuzhiyun return slot;
332*4882a593Smuzhiyun }
333*4882a593Smuzhiyun
ath9k_set_tsfadjust(struct ath_softc * sc,struct ath_beacon_config * cur_conf)334*4882a593Smuzhiyun static void ath9k_set_tsfadjust(struct ath_softc *sc,
335*4882a593Smuzhiyun struct ath_beacon_config *cur_conf)
336*4882a593Smuzhiyun {
337*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
338*4882a593Smuzhiyun s64 tsfadjust;
339*4882a593Smuzhiyun int slot;
340*4882a593Smuzhiyun
341*4882a593Smuzhiyun for (slot = 0; slot < ATH_BCBUF; slot++) {
342*4882a593Smuzhiyun struct ath_vif *avp;
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun if (!sc->beacon.bslot[slot])
345*4882a593Smuzhiyun continue;
346*4882a593Smuzhiyun
347*4882a593Smuzhiyun avp = (void *)sc->beacon.bslot[slot]->drv_priv;
348*4882a593Smuzhiyun
349*4882a593Smuzhiyun /* tsf_adjust is added to the TSF value. We send out the
350*4882a593Smuzhiyun * beacon late, so need to adjust the TSF starting point to be
351*4882a593Smuzhiyun * later in time (i.e. the theoretical first beacon has a TSF
352*4882a593Smuzhiyun * of 0 after correction).
353*4882a593Smuzhiyun */
354*4882a593Smuzhiyun tsfadjust = cur_conf->beacon_interval * avp->av_bslot;
355*4882a593Smuzhiyun tsfadjust = -TU_TO_USEC(tsfadjust) / ATH_BCBUF;
356*4882a593Smuzhiyun avp->tsf_adjust = cpu_to_le64(tsfadjust);
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun ath_dbg(common, CONFIG, "tsfadjust is: %lld for bslot: %d\n",
359*4882a593Smuzhiyun (signed long long)tsfadjust, avp->av_bslot);
360*4882a593Smuzhiyun }
361*4882a593Smuzhiyun }
362*4882a593Smuzhiyun
ath9k_csa_is_finished(struct ath_softc * sc,struct ieee80211_vif * vif)363*4882a593Smuzhiyun bool ath9k_csa_is_finished(struct ath_softc *sc, struct ieee80211_vif *vif)
364*4882a593Smuzhiyun {
365*4882a593Smuzhiyun if (!vif || !vif->csa_active)
366*4882a593Smuzhiyun return false;
367*4882a593Smuzhiyun
368*4882a593Smuzhiyun if (!ieee80211_beacon_cntdwn_is_complete(vif))
369*4882a593Smuzhiyun return false;
370*4882a593Smuzhiyun
371*4882a593Smuzhiyun ieee80211_csa_finish(vif);
372*4882a593Smuzhiyun return true;
373*4882a593Smuzhiyun }
374*4882a593Smuzhiyun
ath9k_csa_update_vif(void * data,u8 * mac,struct ieee80211_vif * vif)375*4882a593Smuzhiyun static void ath9k_csa_update_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
376*4882a593Smuzhiyun {
377*4882a593Smuzhiyun struct ath_softc *sc = data;
378*4882a593Smuzhiyun ath9k_csa_is_finished(sc, vif);
379*4882a593Smuzhiyun }
380*4882a593Smuzhiyun
ath9k_csa_update(struct ath_softc * sc)381*4882a593Smuzhiyun void ath9k_csa_update(struct ath_softc *sc)
382*4882a593Smuzhiyun {
383*4882a593Smuzhiyun ieee80211_iterate_active_interfaces_atomic(sc->hw,
384*4882a593Smuzhiyun IEEE80211_IFACE_ITER_NORMAL,
385*4882a593Smuzhiyun ath9k_csa_update_vif, sc);
386*4882a593Smuzhiyun }
387*4882a593Smuzhiyun
ath9k_beacon_tasklet(struct tasklet_struct * t)388*4882a593Smuzhiyun void ath9k_beacon_tasklet(struct tasklet_struct *t)
389*4882a593Smuzhiyun {
390*4882a593Smuzhiyun struct ath_softc *sc = from_tasklet(sc, t, bcon_tasklet);
391*4882a593Smuzhiyun struct ath_hw *ah = sc->sc_ah;
392*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(ah);
393*4882a593Smuzhiyun struct ath_buf *bf = NULL;
394*4882a593Smuzhiyun struct ieee80211_vif *vif;
395*4882a593Smuzhiyun bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
396*4882a593Smuzhiyun int slot;
397*4882a593Smuzhiyun
398*4882a593Smuzhiyun if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) {
399*4882a593Smuzhiyun ath_dbg(common, RESET,
400*4882a593Smuzhiyun "reset work is pending, skip beaconing now\n");
401*4882a593Smuzhiyun return;
402*4882a593Smuzhiyun }
403*4882a593Smuzhiyun
404*4882a593Smuzhiyun /*
405*4882a593Smuzhiyun * Check if the previous beacon has gone out. If
406*4882a593Smuzhiyun * not don't try to post another, skip this period
407*4882a593Smuzhiyun * and wait for the next. Missed beacons indicate
408*4882a593Smuzhiyun * a problem and should not occur. If we miss too
409*4882a593Smuzhiyun * many consecutive beacons reset the device.
410*4882a593Smuzhiyun */
411*4882a593Smuzhiyun if (ath9k_hw_numtxpending(ah, sc->beacon.beaconq) != 0) {
412*4882a593Smuzhiyun sc->beacon.bmisscnt++;
413*4882a593Smuzhiyun
414*4882a593Smuzhiyun ath9k_hw_check_nav(ah);
415*4882a593Smuzhiyun
416*4882a593Smuzhiyun /*
417*4882a593Smuzhiyun * If the previous beacon has not been transmitted
418*4882a593Smuzhiyun * and a MAC/BB hang has been identified, return
419*4882a593Smuzhiyun * here because a chip reset would have been
420*4882a593Smuzhiyun * initiated.
421*4882a593Smuzhiyun */
422*4882a593Smuzhiyun if (!ath_hw_check(sc))
423*4882a593Smuzhiyun return;
424*4882a593Smuzhiyun
425*4882a593Smuzhiyun if (sc->beacon.bmisscnt < BSTUCK_THRESH * sc->nbcnvifs) {
426*4882a593Smuzhiyun ath_dbg(common, BSTUCK,
427*4882a593Smuzhiyun "missed %u consecutive beacons\n",
428*4882a593Smuzhiyun sc->beacon.bmisscnt);
429*4882a593Smuzhiyun ath9k_hw_stop_dma_queue(ah, sc->beacon.beaconq);
430*4882a593Smuzhiyun if (sc->beacon.bmisscnt > 3)
431*4882a593Smuzhiyun ath9k_hw_bstuck_nfcal(ah);
432*4882a593Smuzhiyun } else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) {
433*4882a593Smuzhiyun ath_dbg(common, BSTUCK, "beacon is officially stuck\n");
434*4882a593Smuzhiyun sc->beacon.bmisscnt = 0;
435*4882a593Smuzhiyun ath9k_queue_reset(sc, RESET_TYPE_BEACON_STUCK);
436*4882a593Smuzhiyun }
437*4882a593Smuzhiyun
438*4882a593Smuzhiyun return;
439*4882a593Smuzhiyun }
440*4882a593Smuzhiyun
441*4882a593Smuzhiyun slot = ath9k_beacon_choose_slot(sc);
442*4882a593Smuzhiyun vif = sc->beacon.bslot[slot];
443*4882a593Smuzhiyun
444*4882a593Smuzhiyun /* EDMA devices check that in the tx completion function. */
445*4882a593Smuzhiyun if (!edma) {
446*4882a593Smuzhiyun if (ath9k_is_chanctx_enabled()) {
447*4882a593Smuzhiyun ath_chanctx_beacon_sent_ev(sc,
448*4882a593Smuzhiyun ATH_CHANCTX_EVENT_BEACON_SENT);
449*4882a593Smuzhiyun }
450*4882a593Smuzhiyun
451*4882a593Smuzhiyun if (ath9k_csa_is_finished(sc, vif))
452*4882a593Smuzhiyun return;
453*4882a593Smuzhiyun }
454*4882a593Smuzhiyun
455*4882a593Smuzhiyun if (!vif || !vif->bss_conf.enable_beacon)
456*4882a593Smuzhiyun return;
457*4882a593Smuzhiyun
458*4882a593Smuzhiyun if (ath9k_is_chanctx_enabled()) {
459*4882a593Smuzhiyun ath_chanctx_event(sc, vif, ATH_CHANCTX_EVENT_BEACON_PREPARE);
460*4882a593Smuzhiyun }
461*4882a593Smuzhiyun
462*4882a593Smuzhiyun bf = ath9k_beacon_generate(sc->hw, vif);
463*4882a593Smuzhiyun
464*4882a593Smuzhiyun if (sc->beacon.bmisscnt != 0) {
465*4882a593Smuzhiyun ath_dbg(common, BSTUCK, "resume beacon xmit after %u misses\n",
466*4882a593Smuzhiyun sc->beacon.bmisscnt);
467*4882a593Smuzhiyun sc->beacon.bmisscnt = 0;
468*4882a593Smuzhiyun }
469*4882a593Smuzhiyun
470*4882a593Smuzhiyun /*
471*4882a593Smuzhiyun * Handle slot time change when a non-ERP station joins/leaves
472*4882a593Smuzhiyun * an 11g network. The 802.11 layer notifies us via callback,
473*4882a593Smuzhiyun * we mark updateslot, then wait one beacon before effecting
474*4882a593Smuzhiyun * the change. This gives associated stations at least one
475*4882a593Smuzhiyun * beacon interval to note the state change.
476*4882a593Smuzhiyun *
477*4882a593Smuzhiyun * NB: The slot time change state machine is clocked according
478*4882a593Smuzhiyun * to whether we are bursting or staggering beacons. We
479*4882a593Smuzhiyun * recognize the request to update and record the current
480*4882a593Smuzhiyun * slot then don't transition until that slot is reached
481*4882a593Smuzhiyun * again. If we miss a beacon for that slot then we'll be
482*4882a593Smuzhiyun * slow to transition but we'll be sure at least one beacon
483*4882a593Smuzhiyun * interval has passed. When bursting slot is always left
484*4882a593Smuzhiyun * set to ATH_BCBUF so this check is a noop.
485*4882a593Smuzhiyun */
486*4882a593Smuzhiyun if (sc->beacon.updateslot == UPDATE) {
487*4882a593Smuzhiyun sc->beacon.updateslot = COMMIT;
488*4882a593Smuzhiyun sc->beacon.slotupdate = slot;
489*4882a593Smuzhiyun } else if (sc->beacon.updateslot == COMMIT &&
490*4882a593Smuzhiyun sc->beacon.slotupdate == slot) {
491*4882a593Smuzhiyun ah->slottime = sc->beacon.slottime;
492*4882a593Smuzhiyun ath9k_hw_init_global_settings(ah);
493*4882a593Smuzhiyun sc->beacon.updateslot = OK;
494*4882a593Smuzhiyun }
495*4882a593Smuzhiyun
496*4882a593Smuzhiyun if (bf) {
497*4882a593Smuzhiyun ath9k_reset_beacon_status(sc);
498*4882a593Smuzhiyun
499*4882a593Smuzhiyun ath_dbg(common, BEACON,
500*4882a593Smuzhiyun "Transmitting beacon for slot: %d\n", slot);
501*4882a593Smuzhiyun
502*4882a593Smuzhiyun /* NB: cabq traffic should already be queued and primed */
503*4882a593Smuzhiyun ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bf->bf_daddr);
504*4882a593Smuzhiyun
505*4882a593Smuzhiyun if (!edma)
506*4882a593Smuzhiyun ath9k_hw_txstart(ah, sc->beacon.beaconq);
507*4882a593Smuzhiyun }
508*4882a593Smuzhiyun }
509*4882a593Smuzhiyun
510*4882a593Smuzhiyun /*
511*4882a593Smuzhiyun * Both nexttbtt and intval have to be in usecs.
512*4882a593Smuzhiyun */
ath9k_beacon_init(struct ath_softc * sc,u32 nexttbtt,u32 intval)513*4882a593Smuzhiyun static void ath9k_beacon_init(struct ath_softc *sc, u32 nexttbtt,
514*4882a593Smuzhiyun u32 intval)
515*4882a593Smuzhiyun {
516*4882a593Smuzhiyun struct ath_hw *ah = sc->sc_ah;
517*4882a593Smuzhiyun
518*4882a593Smuzhiyun ath9k_hw_disable_interrupts(ah);
519*4882a593Smuzhiyun ath9k_beaconq_config(sc);
520*4882a593Smuzhiyun ath9k_hw_beaconinit(ah, nexttbtt, intval);
521*4882a593Smuzhiyun ah->imask |= ATH9K_INT_SWBA;
522*4882a593Smuzhiyun sc->beacon.bmisscnt = 0;
523*4882a593Smuzhiyun ath9k_hw_set_interrupts(ah);
524*4882a593Smuzhiyun ath9k_hw_enable_interrupts(ah);
525*4882a593Smuzhiyun }
526*4882a593Smuzhiyun
ath9k_beacon_stop(struct ath_softc * sc)527*4882a593Smuzhiyun static void ath9k_beacon_stop(struct ath_softc *sc)
528*4882a593Smuzhiyun {
529*4882a593Smuzhiyun ath9k_hw_disable_interrupts(sc->sc_ah);
530*4882a593Smuzhiyun sc->sc_ah->imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS);
531*4882a593Smuzhiyun sc->beacon.bmisscnt = 0;
532*4882a593Smuzhiyun ath9k_hw_set_interrupts(sc->sc_ah);
533*4882a593Smuzhiyun ath9k_hw_enable_interrupts(sc->sc_ah);
534*4882a593Smuzhiyun }
535*4882a593Smuzhiyun
536*4882a593Smuzhiyun /*
537*4882a593Smuzhiyun * For multi-bss ap support beacons are either staggered evenly over N slots or
538*4882a593Smuzhiyun * burst together. For the former arrange for the SWBA to be delivered for each
539*4882a593Smuzhiyun * slot. Slots that are not occupied will generate nothing.
540*4882a593Smuzhiyun */
ath9k_beacon_config_ap(struct ath_softc * sc,struct ath_beacon_config * conf)541*4882a593Smuzhiyun static void ath9k_beacon_config_ap(struct ath_softc *sc,
542*4882a593Smuzhiyun struct ath_beacon_config *conf)
543*4882a593Smuzhiyun {
544*4882a593Smuzhiyun struct ath_hw *ah = sc->sc_ah;
545*4882a593Smuzhiyun
546*4882a593Smuzhiyun ath9k_cmn_beacon_config_ap(ah, conf, ATH_BCBUF);
547*4882a593Smuzhiyun ath9k_beacon_init(sc, conf->nexttbtt, conf->intval);
548*4882a593Smuzhiyun }
549*4882a593Smuzhiyun
ath9k_beacon_config_sta(struct ath_hw * ah,struct ath_beacon_config * conf)550*4882a593Smuzhiyun static void ath9k_beacon_config_sta(struct ath_hw *ah,
551*4882a593Smuzhiyun struct ath_beacon_config *conf)
552*4882a593Smuzhiyun {
553*4882a593Smuzhiyun struct ath9k_beacon_state bs;
554*4882a593Smuzhiyun
555*4882a593Smuzhiyun if (ath9k_cmn_beacon_config_sta(ah, conf, &bs) == -EPERM)
556*4882a593Smuzhiyun return;
557*4882a593Smuzhiyun
558*4882a593Smuzhiyun ath9k_hw_disable_interrupts(ah);
559*4882a593Smuzhiyun ath9k_hw_set_sta_beacon_timers(ah, &bs);
560*4882a593Smuzhiyun ah->imask |= ATH9K_INT_BMISS;
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun ath9k_hw_set_interrupts(ah);
563*4882a593Smuzhiyun ath9k_hw_enable_interrupts(ah);
564*4882a593Smuzhiyun }
565*4882a593Smuzhiyun
ath9k_beacon_config_adhoc(struct ath_softc * sc,struct ath_beacon_config * conf)566*4882a593Smuzhiyun static void ath9k_beacon_config_adhoc(struct ath_softc *sc,
567*4882a593Smuzhiyun struct ath_beacon_config *conf)
568*4882a593Smuzhiyun {
569*4882a593Smuzhiyun struct ath_hw *ah = sc->sc_ah;
570*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(ah);
571*4882a593Smuzhiyun
572*4882a593Smuzhiyun ath9k_reset_beacon_status(sc);
573*4882a593Smuzhiyun
574*4882a593Smuzhiyun ath9k_cmn_beacon_config_adhoc(ah, conf);
575*4882a593Smuzhiyun
576*4882a593Smuzhiyun ath9k_beacon_init(sc, conf->nexttbtt, conf->intval);
577*4882a593Smuzhiyun
578*4882a593Smuzhiyun /*
579*4882a593Smuzhiyun * Set the global 'beacon has been configured' flag for the
580*4882a593Smuzhiyun * joiner case in IBSS mode.
581*4882a593Smuzhiyun */
582*4882a593Smuzhiyun if (!conf->ibss_creator && conf->enable_beacon)
583*4882a593Smuzhiyun set_bit(ATH_OP_BEACONS, &common->op_flags);
584*4882a593Smuzhiyun }
585*4882a593Smuzhiyun
ath9k_cache_beacon_config(struct ath_softc * sc,struct ath_chanctx * ctx,struct ieee80211_bss_conf * bss_conf)586*4882a593Smuzhiyun static void ath9k_cache_beacon_config(struct ath_softc *sc,
587*4882a593Smuzhiyun struct ath_chanctx *ctx,
588*4882a593Smuzhiyun struct ieee80211_bss_conf *bss_conf)
589*4882a593Smuzhiyun {
590*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
591*4882a593Smuzhiyun struct ath_beacon_config *cur_conf = &ctx->beacon;
592*4882a593Smuzhiyun
593*4882a593Smuzhiyun ath_dbg(common, BEACON,
594*4882a593Smuzhiyun "Caching beacon data for BSS: %pM\n", bss_conf->bssid);
595*4882a593Smuzhiyun
596*4882a593Smuzhiyun cur_conf->beacon_interval = bss_conf->beacon_int;
597*4882a593Smuzhiyun cur_conf->dtim_period = bss_conf->dtim_period;
598*4882a593Smuzhiyun cur_conf->dtim_count = 1;
599*4882a593Smuzhiyun cur_conf->ibss_creator = bss_conf->ibss_creator;
600*4882a593Smuzhiyun
601*4882a593Smuzhiyun /*
602*4882a593Smuzhiyun * It looks like mac80211 may end up using beacon interval of zero in
603*4882a593Smuzhiyun * some cases (at least for mesh point). Avoid getting into an
604*4882a593Smuzhiyun * infinite loop by using a bit safer value instead. To be safe,
605*4882a593Smuzhiyun * do sanity check on beacon interval for all operating modes.
606*4882a593Smuzhiyun */
607*4882a593Smuzhiyun if (cur_conf->beacon_interval == 0)
608*4882a593Smuzhiyun cur_conf->beacon_interval = 100;
609*4882a593Smuzhiyun
610*4882a593Smuzhiyun cur_conf->bmiss_timeout =
611*4882a593Smuzhiyun ATH_DEFAULT_BMISS_LIMIT * cur_conf->beacon_interval;
612*4882a593Smuzhiyun
613*4882a593Smuzhiyun /*
614*4882a593Smuzhiyun * We don't parse dtim period from mac80211 during the driver
615*4882a593Smuzhiyun * initialization as it breaks association with hidden-ssid
616*4882a593Smuzhiyun * AP and it causes latency in roaming
617*4882a593Smuzhiyun */
618*4882a593Smuzhiyun if (cur_conf->dtim_period == 0)
619*4882a593Smuzhiyun cur_conf->dtim_period = 1;
620*4882a593Smuzhiyun
621*4882a593Smuzhiyun ath9k_set_tsfadjust(sc, cur_conf);
622*4882a593Smuzhiyun }
623*4882a593Smuzhiyun
ath9k_beacon_config(struct ath_softc * sc,struct ieee80211_vif * main_vif,bool beacons)624*4882a593Smuzhiyun void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *main_vif,
625*4882a593Smuzhiyun bool beacons)
626*4882a593Smuzhiyun {
627*4882a593Smuzhiyun struct ath_hw *ah = sc->sc_ah;
628*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(ah);
629*4882a593Smuzhiyun struct ath_vif *avp;
630*4882a593Smuzhiyun struct ath_chanctx *ctx;
631*4882a593Smuzhiyun struct ath_beacon_config *cur_conf;
632*4882a593Smuzhiyun unsigned long flags;
633*4882a593Smuzhiyun bool enabled;
634*4882a593Smuzhiyun bool skip_beacon = false;
635*4882a593Smuzhiyun
636*4882a593Smuzhiyun if (!beacons) {
637*4882a593Smuzhiyun clear_bit(ATH_OP_BEACONS, &common->op_flags);
638*4882a593Smuzhiyun ath9k_beacon_stop(sc);
639*4882a593Smuzhiyun return;
640*4882a593Smuzhiyun }
641*4882a593Smuzhiyun
642*4882a593Smuzhiyun if (WARN_ON(!main_vif))
643*4882a593Smuzhiyun return;
644*4882a593Smuzhiyun
645*4882a593Smuzhiyun avp = (void *)main_vif->drv_priv;
646*4882a593Smuzhiyun ctx = avp->chanctx;
647*4882a593Smuzhiyun cur_conf = &ctx->beacon;
648*4882a593Smuzhiyun enabled = cur_conf->enable_beacon;
649*4882a593Smuzhiyun cur_conf->enable_beacon = beacons;
650*4882a593Smuzhiyun
651*4882a593Smuzhiyun if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION) {
652*4882a593Smuzhiyun ath9k_cache_beacon_config(sc, ctx, &main_vif->bss_conf);
653*4882a593Smuzhiyun
654*4882a593Smuzhiyun ath9k_set_beacon(sc);
655*4882a593Smuzhiyun set_bit(ATH_OP_BEACONS, &common->op_flags);
656*4882a593Smuzhiyun return;
657*4882a593Smuzhiyun }
658*4882a593Smuzhiyun
659*4882a593Smuzhiyun /* Update the beacon configuration. */
660*4882a593Smuzhiyun ath9k_cache_beacon_config(sc, ctx, &main_vif->bss_conf);
661*4882a593Smuzhiyun
662*4882a593Smuzhiyun /*
663*4882a593Smuzhiyun * Configure the HW beacon registers only when we have a valid
664*4882a593Smuzhiyun * beacon interval.
665*4882a593Smuzhiyun */
666*4882a593Smuzhiyun if (cur_conf->beacon_interval) {
667*4882a593Smuzhiyun /* Special case to sync the TSF when joining an existing IBSS.
668*4882a593Smuzhiyun * This is only done if no AP interface is active.
669*4882a593Smuzhiyun * Note that mac80211 always resets the TSF when creating a new
670*4882a593Smuzhiyun * IBSS interface.
671*4882a593Smuzhiyun */
672*4882a593Smuzhiyun if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC &&
673*4882a593Smuzhiyun !enabled && beacons && !main_vif->bss_conf.ibss_creator) {
674*4882a593Smuzhiyun spin_lock_irqsave(&sc->sc_pm_lock, flags);
675*4882a593Smuzhiyun sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
676*4882a593Smuzhiyun spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
677*4882a593Smuzhiyun skip_beacon = true;
678*4882a593Smuzhiyun }
679*4882a593Smuzhiyun
680*4882a593Smuzhiyun /*
681*4882a593Smuzhiyun * Do not set the ATH_OP_BEACONS flag for IBSS joiner mode
682*4882a593Smuzhiyun * here, it is done in ath9k_beacon_config_adhoc().
683*4882a593Smuzhiyun */
684*4882a593Smuzhiyun if (beacons && !skip_beacon) {
685*4882a593Smuzhiyun set_bit(ATH_OP_BEACONS, &common->op_flags);
686*4882a593Smuzhiyun ath9k_set_beacon(sc);
687*4882a593Smuzhiyun } else {
688*4882a593Smuzhiyun clear_bit(ATH_OP_BEACONS, &common->op_flags);
689*4882a593Smuzhiyun ath9k_beacon_stop(sc);
690*4882a593Smuzhiyun }
691*4882a593Smuzhiyun } else {
692*4882a593Smuzhiyun clear_bit(ATH_OP_BEACONS, &common->op_flags);
693*4882a593Smuzhiyun ath9k_beacon_stop(sc);
694*4882a593Smuzhiyun }
695*4882a593Smuzhiyun }
696*4882a593Smuzhiyun
ath9k_set_beacon(struct ath_softc * sc)697*4882a593Smuzhiyun void ath9k_set_beacon(struct ath_softc *sc)
698*4882a593Smuzhiyun {
699*4882a593Smuzhiyun struct ath_common *common = ath9k_hw_common(sc->sc_ah);
700*4882a593Smuzhiyun struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon;
701*4882a593Smuzhiyun
702*4882a593Smuzhiyun switch (sc->sc_ah->opmode) {
703*4882a593Smuzhiyun case NL80211_IFTYPE_AP:
704*4882a593Smuzhiyun case NL80211_IFTYPE_MESH_POINT:
705*4882a593Smuzhiyun ath9k_beacon_config_ap(sc, cur_conf);
706*4882a593Smuzhiyun break;
707*4882a593Smuzhiyun case NL80211_IFTYPE_ADHOC:
708*4882a593Smuzhiyun ath9k_beacon_config_adhoc(sc, cur_conf);
709*4882a593Smuzhiyun break;
710*4882a593Smuzhiyun case NL80211_IFTYPE_STATION:
711*4882a593Smuzhiyun ath9k_beacon_config_sta(sc->sc_ah, cur_conf);
712*4882a593Smuzhiyun break;
713*4882a593Smuzhiyun default:
714*4882a593Smuzhiyun ath_dbg(common, CONFIG, "Unsupported beaconing mode\n");
715*4882a593Smuzhiyun return;
716*4882a593Smuzhiyun }
717*4882a593Smuzhiyun }
718