blob: df7c62d9bec40fd995c6df0b6b1920eb18604737 [file] [log] [blame]
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001/*
Sujithcee075a2009-03-13 09:07:23 +05302 * Copyright (c) 2008-2009 Atheros Communications Inc.
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07003 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
Luis R. Rodriguezf078f202008-08-04 00:16:41 -070017#include <linux/nl80211.h>
Sujith394cf0a2009-02-09 13:26:54 +053018#include "ath9k.h"
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -070019#include "btcoex.h"
Luis R. Rodriguezf078f202008-08-04 00:16:41 -070020
Sujithff37e332008-11-24 12:07:55 +053021static void ath_update_txpow(struct ath_softc *sc)
22{
Sujithcbe61d82009-02-09 13:27:12 +053023 struct ath_hw *ah = sc->sc_ah;
Sujithff37e332008-11-24 12:07:55 +053024
Sujith17d79042009-02-09 13:27:03 +053025 if (sc->curtxpow != sc->config.txpowlimit) {
Felix Fietkaude40f312010-10-20 03:08:53 +020026 ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit, false);
Sujithff37e332008-11-24 12:07:55 +053027 /* read back in case value is clamped */
Felix Fietkau9cc32712010-06-12 17:22:29 +020028 sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit;
Sujithff37e332008-11-24 12:07:55 +053029 }
30}
31
32static u8 parse_mpdudensity(u8 mpdudensity)
33{
34 /*
35 * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
36 * 0 for no restriction
37 * 1 for 1/4 us
38 * 2 for 1/2 us
39 * 3 for 1 us
40 * 4 for 2 us
41 * 5 for 4 us
42 * 6 for 8 us
43 * 7 for 16 us
44 */
45 switch (mpdudensity) {
46 case 0:
47 return 0;
48 case 1:
49 case 2:
50 case 3:
51 /* Our lower layer calculations limit our precision to
52 1 microsecond */
53 return 1;
54 case 4:
55 return 2;
56 case 5:
57 return 4;
58 case 6:
59 return 8;
60 case 7:
61 return 16;
62 default:
63 return 0;
64 }
65}
66
Vasanthakumar Thiagarajan82880a72009-06-13 14:50:24 +053067static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc,
68 struct ieee80211_hw *hw)
69{
70 struct ieee80211_channel *curchan = hw->conf.channel;
71 struct ath9k_channel *channel;
72 u8 chan_idx;
73
74 chan_idx = curchan->hw_value;
75 channel = &sc->sc_ah->channels[chan_idx];
76 ath9k_update_ichannel(sc, hw, channel);
77 return channel;
78}
79
Sujith55624202010-01-08 10:36:02 +053080bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode)
Luis R. Rodriguez8c77a562009-09-09 21:02:34 -070081{
82 unsigned long flags;
83 bool ret;
84
Luis R. Rodriguez9ecdef42009-09-09 21:10:09 -070085 spin_lock_irqsave(&sc->sc_pm_lock, flags);
86 ret = ath9k_hw_setpower(sc->sc_ah, mode);
87 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
Luis R. Rodriguez8c77a562009-09-09 21:02:34 -070088
89 return ret;
90}
91
Luis R. Rodrigueza91d75ae2009-09-09 20:29:18 -070092void ath9k_ps_wakeup(struct ath_softc *sc)
93{
Felix Fietkau898c9142010-10-12 14:02:53 +020094 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Luis R. Rodrigueza91d75ae2009-09-09 20:29:18 -070095 unsigned long flags;
96
97 spin_lock_irqsave(&sc->sc_pm_lock, flags);
98 if (++sc->ps_usecount != 1)
99 goto unlock;
100
Luis R. Rodriguez9ecdef42009-09-09 21:10:09 -0700101 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
Luis R. Rodrigueza91d75ae2009-09-09 20:29:18 -0700102
Felix Fietkau898c9142010-10-12 14:02:53 +0200103 /*
104 * While the hardware is asleep, the cycle counters contain no
105 * useful data. Better clear them now so that they don't mess up
106 * survey data results.
107 */
108 spin_lock(&common->cc_lock);
109 ath_hw_cycle_counters_update(common);
110 memset(&common->cc_survey, 0, sizeof(common->cc_survey));
111 spin_unlock(&common->cc_lock);
112
Luis R. Rodrigueza91d75ae2009-09-09 20:29:18 -0700113 unlock:
114 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
115}
116
117void ath9k_ps_restore(struct ath_softc *sc)
118{
Felix Fietkau898c9142010-10-12 14:02:53 +0200119 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Luis R. Rodrigueza91d75ae2009-09-09 20:29:18 -0700120 unsigned long flags;
121
122 spin_lock_irqsave(&sc->sc_pm_lock, flags);
123 if (--sc->ps_usecount != 0)
124 goto unlock;
125
Felix Fietkau898c9142010-10-12 14:02:53 +0200126 spin_lock(&common->cc_lock);
127 ath_hw_cycle_counters_update(common);
128 spin_unlock(&common->cc_lock);
129
Vivek Natarajan1dbfd9d2010-01-29 16:56:51 +0530130 if (sc->ps_idle)
131 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
132 else if (sc->ps_enabled &&
133 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
Sujith1b04b932010-01-08 10:36:05 +0530134 PS_WAIT_FOR_CAB |
135 PS_WAIT_FOR_PSPOLL_DATA |
136 PS_WAIT_FOR_TX_ACK)))
Luis R. Rodriguez9ecdef42009-09-09 21:10:09 -0700137 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
Luis R. Rodrigueza91d75ae2009-09-09 20:29:18 -0700138
139 unlock:
140 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
141}
142
Felix Fietkau5ee08652010-07-31 00:11:59 +0200143static void ath_start_ani(struct ath_common *common)
144{
145 struct ath_hw *ah = common->ah;
146 unsigned long timestamp = jiffies_to_msecs(jiffies);
147 struct ath_softc *sc = (struct ath_softc *) common->priv;
148
149 if (!(sc->sc_flags & SC_OP_ANI_RUN))
150 return;
151
152 if (sc->sc_flags & SC_OP_OFFCHANNEL)
153 return;
154
155 common->ani.longcal_timer = timestamp;
156 common->ani.shortcal_timer = timestamp;
157 common->ani.checkani_timer = timestamp;
158
159 mod_timer(&common->ani.timer,
160 jiffies +
161 msecs_to_jiffies((u32)ah->config.ani_poll_interval));
162}
163
Felix Fietkau34300982010-10-10 18:21:52 +0200164static void ath_update_survey_nf(struct ath_softc *sc, int channel)
165{
166 struct ath_hw *ah = sc->sc_ah;
167 struct ath9k_channel *chan = &ah->channels[channel];
168 struct survey_info *survey = &sc->survey[channel];
169
170 if (chan->noisefloor) {
171 survey->filled |= SURVEY_INFO_NOISE_DBM;
172 survey->noise = chan->noisefloor;
173 }
174}
175
176static void ath_update_survey_stats(struct ath_softc *sc)
177{
178 struct ath_hw *ah = sc->sc_ah;
179 struct ath_common *common = ath9k_hw_common(ah);
180 int pos = ah->curchan - &ah->channels[0];
181 struct survey_info *survey = &sc->survey[pos];
182 struct ath_cycle_counters *cc = &common->cc_survey;
183 unsigned int div = common->clockrate * 1000;
184
Felix Fietkau08457352010-10-20 15:59:28 +0200185 if (!ah->curchan)
186 return;
187
Felix Fietkau898c9142010-10-12 14:02:53 +0200188 if (ah->power_mode == ATH9K_PM_AWAKE)
189 ath_hw_cycle_counters_update(common);
Felix Fietkau34300982010-10-10 18:21:52 +0200190
191 if (cc->cycles > 0) {
192 survey->filled |= SURVEY_INFO_CHANNEL_TIME |
193 SURVEY_INFO_CHANNEL_TIME_BUSY |
194 SURVEY_INFO_CHANNEL_TIME_RX |
195 SURVEY_INFO_CHANNEL_TIME_TX;
196 survey->channel_time += cc->cycles / div;
197 survey->channel_time_busy += cc->rx_busy / div;
198 survey->channel_time_rx += cc->rx_frame / div;
199 survey->channel_time_tx += cc->tx_frame / div;
200 }
201 memset(cc, 0, sizeof(*cc));
202
203 ath_update_survey_nf(sc, pos);
204}
205
Sujithff37e332008-11-24 12:07:55 +0530206/*
207 * Set/change channels. If the channel is really being changed, it's done
208 * by reseting the chip. To accomplish this we must first cleanup any pending
209 * DMA, then restart stuff.
210*/
Jouni Malinen0e2dedf2009-03-03 19:23:32 +0200211int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
212 struct ath9k_channel *hchan)
Sujithff37e332008-11-24 12:07:55 +0530213{
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200214 struct ath_wiphy *aphy = hw->priv;
Sujithcbe61d82009-02-09 13:27:12 +0530215 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700216 struct ath_common *common = ath9k_hw_common(ah);
Luis R. Rodriguez25c56ee2009-09-13 23:04:44 -0700217 struct ieee80211_conf *conf = &common->hw->conf;
Sujithff37e332008-11-24 12:07:55 +0530218 bool fastcc = true, stopped;
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800219 struct ieee80211_channel *channel = hw->conf.channel;
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200220 struct ath9k_hw_cal_data *caldata = NULL;
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800221 int r;
Sujithff37e332008-11-24 12:07:55 +0530222
223 if (sc->sc_flags & SC_OP_INVALID)
224 return -EIO;
225
Felix Fietkau5ee08652010-07-31 00:11:59 +0200226 del_timer_sync(&common->ani.timer);
227 cancel_work_sync(&sc->paprd_work);
228 cancel_work_sync(&sc->hw_check_work);
229 cancel_delayed_work_sync(&sc->tx_complete_work);
230
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +0530231 ath9k_ps_wakeup(sc);
232
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700233 spin_lock_bh(&sc->sc_pcu_lock);
234
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800235 /*
236 * This is only performed if the channel settings have
237 * actually changed.
238 *
239 * To switch channels clear any pending DMA operations;
240 * wait long enough for the RX fifo to drain, reset the
241 * hardware at the new frequency, and then re-enable
242 * the relevant bits of the h/w.
243 */
Felix Fietkau4df30712010-11-08 20:54:47 +0100244 ath9k_hw_disable_interrupts(ah);
Sujith043a0402009-01-16 21:38:47 +0530245 ath_drain_all_txq(sc, false);
Luis R. Rodriguez5e848f72010-10-20 16:07:06 -0700246
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800247 stopped = ath_stoprecv(sc);
Sujithff37e332008-11-24 12:07:55 +0530248
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800249 /* XXX: do not flush receive queue here. We don't want
250 * to flush data frames already in queue because of
251 * changing channel. */
Sujithff37e332008-11-24 12:07:55 +0530252
Felix Fietkau5ee08652010-07-31 00:11:59 +0200253 if (!stopped || !(sc->sc_flags & SC_OP_OFFCHANNEL))
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800254 fastcc = false;
Sujithff37e332008-11-24 12:07:55 +0530255
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200256 if (!(sc->sc_flags & SC_OP_OFFCHANNEL))
257 caldata = &aphy->caldata;
258
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700259 ath_print(common, ATH_DBG_CONFIG,
Luis R. Rodriguez1e51b2f2010-07-29 22:56:22 -0400260 "(%u MHz) -> (%u MHz), conf_is_ht40: %d fastcc: %d\n",
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700261 sc->sc_ah->curchan->channel,
Luis R. Rodriguez1e51b2f2010-07-29 22:56:22 -0400262 channel->center_freq, conf_is_ht40(conf),
263 fastcc);
Sujith99405f92008-11-24 12:08:35 +0530264
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200265 r = ath9k_hw_reset(ah, hchan, caldata, fastcc);
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800266 if (r) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700267 ath_print(common, ATH_DBG_FATAL,
Pavel Roskinf643e512010-01-29 17:22:12 -0500268 "Unable to reset channel (%u MHz), "
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700269 "reset status %d\n",
270 channel->center_freq, r);
Gabor Juhos39892792009-06-15 17:49:09 +0200271 goto ps_restore;
Sujithff37e332008-11-24 12:07:55 +0530272 }
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800273
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800274 if (ath_startrecv(sc) != 0) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700275 ath_print(common, ATH_DBG_FATAL,
276 "Unable to restart recv logic\n");
Gabor Juhos39892792009-06-15 17:49:09 +0200277 r = -EIO;
278 goto ps_restore;
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800279 }
280
Luis R. Rodriguezc0d7c7a2008-12-23 15:58:50 -0800281 ath_update_txpow(sc);
Pavel Roskin30691682010-03-31 18:05:31 -0400282 ath9k_hw_set_interrupts(ah, ah->imask);
Gabor Juhos39892792009-06-15 17:49:09 +0200283
Luis R. Rodriguez48a6a462010-09-16 15:12:28 -0400284 if (!(sc->sc_flags & (SC_OP_OFFCHANNEL))) {
Luis R. Rodriguez52b8ac92010-09-16 15:12:27 -0400285 ath_beacon_config(sc, NULL);
Luis R. Rodriguez48a6a462010-09-16 15:12:28 -0400286 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
287 ath_start_ani(common);
288 }
Luis R. Rodriguez52b8ac92010-09-16 15:12:27 -0400289
Gabor Juhos39892792009-06-15 17:49:09 +0200290 ps_restore:
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700291 spin_unlock_bh(&sc->sc_pcu_lock);
292
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +0530293 ath9k_ps_restore(sc);
Gabor Juhos39892792009-06-15 17:49:09 +0200294 return r;
Sujithff37e332008-11-24 12:07:55 +0530295}
296
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400297static void ath_paprd_activate(struct ath_softc *sc)
298{
299 struct ath_hw *ah = sc->sc_ah;
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200300 struct ath9k_hw_cal_data *caldata = ah->caldata;
Vasanthakumar Thiagarajan90945372010-09-20 22:54:46 -0700301 struct ath_common *common = ath9k_hw_common(ah);
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400302 int chain;
303
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200304 if (!caldata || !caldata->paprd_done)
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400305 return;
306
307 ath9k_ps_wakeup(sc);
Felix Fietkauddfef7922010-07-30 21:02:11 +0200308 ar9003_paprd_enable(ah, false);
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400309 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
Vasanthakumar Thiagarajan90945372010-09-20 22:54:46 -0700310 if (!(common->tx_chainmask & BIT(chain)))
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400311 continue;
312
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200313 ar9003_paprd_populate_single_table(ah, caldata, chain);
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400314 }
315
316 ar9003_paprd_enable(ah, true);
317 ath9k_ps_restore(sc);
318}
319
320void ath_paprd_calibrate(struct work_struct *work)
321{
322 struct ath_softc *sc = container_of(work, struct ath_softc, paprd_work);
323 struct ieee80211_hw *hw = sc->hw;
324 struct ath_hw *ah = sc->sc_ah;
325 struct ieee80211_hdr *hdr;
326 struct sk_buff *skb = NULL;
327 struct ieee80211_tx_info *tx_info;
328 int band = hw->conf.channel->band;
329 struct ieee80211_supported_band *sband = &sc->sbands[band];
330 struct ath_tx_control txctl;
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200331 struct ath9k_hw_cal_data *caldata = ah->caldata;
Vasanthakumar Thiagarajan90945372010-09-20 22:54:46 -0700332 struct ath_common *common = ath9k_hw_common(ah);
Felix Fietkau066dae92010-11-07 14:59:39 +0100333 int ftype;
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400334 int chain_ok = 0;
335 int chain;
336 int len = 1800;
337 int time_left;
338 int i;
339
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200340 if (!caldata)
341 return;
342
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400343 skb = alloc_skb(len, GFP_KERNEL);
344 if (!skb)
345 return;
346
347 tx_info = IEEE80211_SKB_CB(skb);
348
349 skb_put(skb, len);
350 memset(skb->data, 0, len);
351 hdr = (struct ieee80211_hdr *)skb->data;
352 ftype = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC;
353 hdr->frame_control = cpu_to_le16(ftype);
John W. Linvillea3d3da12010-07-20 13:15:31 -0400354 hdr->duration_id = cpu_to_le16(10);
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400355 memcpy(hdr->addr1, hw->wiphy->perm_addr, ETH_ALEN);
356 memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
357 memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
358
359 memset(&txctl, 0, sizeof(txctl));
Felix Fietkau066dae92010-11-07 14:59:39 +0100360 txctl.txq = sc->tx.txq_map[WME_AC_BE];
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400361
Vasanthakumar Thiagarajan47399f12010-06-24 04:09:27 -0700362 ath9k_ps_wakeup(sc);
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400363 ar9003_paprd_init_table(ah);
364 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
Vasanthakumar Thiagarajan90945372010-09-20 22:54:46 -0700365 if (!(common->tx_chainmask & BIT(chain)))
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400366 continue;
367
368 chain_ok = 0;
369 memset(tx_info, 0, sizeof(*tx_info));
370 tx_info->band = band;
371
372 for (i = 0; i < 4; i++) {
373 tx_info->control.rates[i].idx = sband->n_bitrates - 1;
374 tx_info->control.rates[i].count = 6;
375 }
376
377 init_completion(&sc->paprd_complete);
378 ar9003_paprd_setup_gain_table(ah, chain);
379 txctl.paprd = BIT(chain);
380 if (ath_tx_start(hw, skb, &txctl) != 0)
381 break;
382
383 time_left = wait_for_completion_timeout(&sc->paprd_complete,
Vasanthakumar Thiagarajanca369eb2010-06-24 02:42:44 -0700384 msecs_to_jiffies(ATH_PAPRD_TIMEOUT));
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400385 if (!time_left) {
386 ath_print(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
387 "Timeout waiting for paprd training on "
388 "TX chain %d\n",
389 chain);
Vasanthakumar Thiagarajanca369eb2010-06-24 02:42:44 -0700390 goto fail_paprd;
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400391 }
392
393 if (!ar9003_paprd_is_done(ah))
394 break;
395
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200396 if (ar9003_paprd_create_curve(ah, caldata, chain) != 0)
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400397 break;
398
399 chain_ok = 1;
400 }
401 kfree_skb(skb);
402
403 if (chain_ok) {
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200404 caldata->paprd_done = true;
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400405 ath_paprd_activate(sc);
406 }
407
Vasanthakumar Thiagarajanca369eb2010-06-24 02:42:44 -0700408fail_paprd:
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400409 ath9k_ps_restore(sc);
410}
411
Sujithff37e332008-11-24 12:07:55 +0530412/*
413 * This routine performs the periodic noise floor calibration function
414 * that is used to adjust and optimize the chip performance. This
415 * takes environmental changes (location, temperature) into account.
416 * When the task is complete, it reschedules itself depending on the
417 * appropriate interval that was calculated.
418 */
Sujith55624202010-01-08 10:36:02 +0530419void ath_ani_calibrate(unsigned long data)
Sujithff37e332008-11-24 12:07:55 +0530420{
Sujith20977d32009-02-20 15:13:28 +0530421 struct ath_softc *sc = (struct ath_softc *)data;
422 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700423 struct ath_common *common = ath9k_hw_common(ah);
Sujithff37e332008-11-24 12:07:55 +0530424 bool longcal = false;
425 bool shortcal = false;
426 bool aniflag = false;
427 unsigned int timestamp = jiffies_to_msecs(jiffies);
Felix Fietkau60444742010-08-02 15:53:15 +0200428 u32 cal_interval, short_cal_interval, long_cal_interval;
Felix Fietkaub5bfc562010-10-08 22:13:53 +0200429 unsigned long flags;
Felix Fietkau60444742010-08-02 15:53:15 +0200430
431 if (ah->caldata && ah->caldata->nfcal_interference)
432 long_cal_interval = ATH_LONG_CALINTERVAL_INT;
433 else
434 long_cal_interval = ATH_LONG_CALINTERVAL;
Sujithff37e332008-11-24 12:07:55 +0530435
Sujith20977d32009-02-20 15:13:28 +0530436 short_cal_interval = (ah->opmode == NL80211_IFTYPE_AP) ?
437 ATH_AP_SHORT_CALINTERVAL : ATH_STA_SHORT_CALINTERVAL;
Sujithff37e332008-11-24 12:07:55 +0530438
Jouni Malinen1ffc1c62009-05-19 17:01:39 +0300439 /* Only calibrate if awake */
440 if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE)
441 goto set_timer;
442
443 ath9k_ps_wakeup(sc);
444
Sujithff37e332008-11-24 12:07:55 +0530445 /* Long calibration runs independently of short calibration. */
Felix Fietkau60444742010-08-02 15:53:15 +0200446 if ((timestamp - common->ani.longcal_timer) >= long_cal_interval) {
Sujithff37e332008-11-24 12:07:55 +0530447 longcal = true;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700448 ath_print(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800449 common->ani.longcal_timer = timestamp;
Sujithff37e332008-11-24 12:07:55 +0530450 }
451
Sujith17d79042009-02-09 13:27:03 +0530452 /* Short calibration applies only while caldone is false */
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800453 if (!common->ani.caldone) {
454 if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) {
Sujithff37e332008-11-24 12:07:55 +0530455 shortcal = true;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700456 ath_print(common, ATH_DBG_ANI,
457 "shortcal @%lu\n", jiffies);
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800458 common->ani.shortcal_timer = timestamp;
459 common->ani.resetcal_timer = timestamp;
Sujithff37e332008-11-24 12:07:55 +0530460 }
461 } else {
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800462 if ((timestamp - common->ani.resetcal_timer) >=
Sujithff37e332008-11-24 12:07:55 +0530463 ATH_RESTART_CALINTERVAL) {
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800464 common->ani.caldone = ath9k_hw_reset_calvalid(ah);
465 if (common->ani.caldone)
466 common->ani.resetcal_timer = timestamp;
Sujithff37e332008-11-24 12:07:55 +0530467 }
468 }
469
470 /* Verify whether we must check ANI */
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -0400471 if ((timestamp - common->ani.checkani_timer) >=
472 ah->config.ani_poll_interval) {
Sujithff37e332008-11-24 12:07:55 +0530473 aniflag = true;
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800474 common->ani.checkani_timer = timestamp;
Sujithff37e332008-11-24 12:07:55 +0530475 }
476
477 /* Skip all processing if there's nothing to do. */
478 if (longcal || shortcal || aniflag) {
479 /* Call ANI routine if necessary */
Felix Fietkaub5bfc562010-10-08 22:13:53 +0200480 if (aniflag) {
481 spin_lock_irqsave(&common->cc_lock, flags);
Vasanthakumar Thiagarajan22e66a42009-08-19 16:23:40 +0530482 ath9k_hw_ani_monitor(ah, ah->curchan);
Felix Fietkau34300982010-10-10 18:21:52 +0200483 ath_update_survey_stats(sc);
Felix Fietkaub5bfc562010-10-08 22:13:53 +0200484 spin_unlock_irqrestore(&common->cc_lock, flags);
485 }
Sujithff37e332008-11-24 12:07:55 +0530486
487 /* Perform calibration if necessary */
488 if (longcal || shortcal) {
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800489 common->ani.caldone =
Luis R. Rodriguez43c27612009-09-13 21:07:07 -0700490 ath9k_hw_calibrate(ah,
491 ah->curchan,
492 common->rx_chainmask,
493 longcal);
Sujithff37e332008-11-24 12:07:55 +0530494 }
495 }
496
Jouni Malinen1ffc1c62009-05-19 17:01:39 +0300497 ath9k_ps_restore(sc);
498
Sujith20977d32009-02-20 15:13:28 +0530499set_timer:
Sujithff37e332008-11-24 12:07:55 +0530500 /*
501 * Set timer interval based on previous results.
502 * The interval must be the shortest necessary to satisfy ANI,
503 * short calibration and long calibration.
504 */
Sujithaac92072008-12-02 18:37:54 +0530505 cal_interval = ATH_LONG_CALINTERVAL;
Sujith2660b812009-02-09 13:27:26 +0530506 if (sc->sc_ah->config.enable_ani)
Luis R. Rodrigueze36b27a2010-06-12 00:33:45 -0400507 cal_interval = min(cal_interval,
508 (u32)ah->config.ani_poll_interval);
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800509 if (!common->ani.caldone)
Sujith20977d32009-02-20 15:13:28 +0530510 cal_interval = min(cal_interval, (u32)short_cal_interval);
Sujithff37e332008-11-24 12:07:55 +0530511
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800512 mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval));
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200513 if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) {
514 if (!ah->caldata->paprd_done)
Felix Fietkau9f42c2b2010-06-12 00:34:01 -0400515 ieee80211_queue_work(sc->hw, &sc->paprd_work);
516 else
517 ath_paprd_activate(sc);
518 }
Sujithff37e332008-11-24 12:07:55 +0530519}
520
521/*
522 * Update tx/rx chainmask. For legacy association,
523 * hard code chainmask to 1x1, for 11n association, use
Vasanthakumar Thiagarajanc97c92d2009-01-02 15:35:46 +0530524 * the chainmask configuration, for bt coexistence, use
525 * the chainmask configuration even in legacy mode.
Sujithff37e332008-11-24 12:07:55 +0530526 */
Jouni Malinen0e2dedf2009-03-03 19:23:32 +0200527void ath_update_chainmask(struct ath_softc *sc, int is_ht)
Sujithff37e332008-11-24 12:07:55 +0530528{
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -0700529 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguez43c27612009-09-13 21:07:07 -0700530 struct ath_common *common = ath9k_hw_common(ah);
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -0700531
Felix Fietkau5ee08652010-07-31 00:11:59 +0200532 if ((sc->sc_flags & SC_OP_OFFCHANNEL) || is_ht ||
Luis R. Rodriguez766ec4a2009-09-09 14:52:02 -0700533 (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE)) {
Luis R. Rodriguez43c27612009-09-13 21:07:07 -0700534 common->tx_chainmask = ah->caps.tx_chainmask;
535 common->rx_chainmask = ah->caps.rx_chainmask;
Sujithff37e332008-11-24 12:07:55 +0530536 } else {
Luis R. Rodriguez43c27612009-09-13 21:07:07 -0700537 common->tx_chainmask = 1;
538 common->rx_chainmask = 1;
Sujithff37e332008-11-24 12:07:55 +0530539 }
540
Luis R. Rodriguez43c27612009-09-13 21:07:07 -0700541 ath_print(common, ATH_DBG_CONFIG,
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700542 "tx chmask: %d, rx chmask: %d\n",
Luis R. Rodriguez43c27612009-09-13 21:07:07 -0700543 common->tx_chainmask,
544 common->rx_chainmask);
Sujithff37e332008-11-24 12:07:55 +0530545}
546
547static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta)
548{
549 struct ath_node *an;
550
551 an = (struct ath_node *)sta->drv_priv;
552
Sujith87792ef2009-03-30 15:28:48 +0530553 if (sc->sc_flags & SC_OP_TXAGGR) {
Sujithff37e332008-11-24 12:07:55 +0530554 ath_tx_node_init(sc, an);
Sujith9e98ac62009-07-23 15:32:34 +0530555 an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
Sujith87792ef2009-03-30 15:28:48 +0530556 sta->ht_cap.ampdu_factor);
557 an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density);
558 }
Sujithff37e332008-11-24 12:07:55 +0530559}
560
561static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
562{
563 struct ath_node *an = (struct ath_node *)sta->drv_priv;
564
565 if (sc->sc_flags & SC_OP_TXAGGR)
566 ath_tx_node_cleanup(sc, an);
567}
568
Felix Fietkau347809f2010-07-02 00:09:52 +0200569void ath_hw_check(struct work_struct *work)
570{
571 struct ath_softc *sc = container_of(work, struct ath_softc, hw_check_work);
572 int i;
573
574 ath9k_ps_wakeup(sc);
575
576 for (i = 0; i < 3; i++) {
577 if (ath9k_hw_check_alive(sc->sc_ah))
578 goto out;
579
580 msleep(1);
581 }
Felix Fietkaufac6b6a2010-10-23 17:45:38 +0200582 ath_reset(sc, true);
Felix Fietkau347809f2010-07-02 00:09:52 +0200583
584out:
585 ath9k_ps_restore(sc);
586}
587
Sujith55624202010-01-08 10:36:02 +0530588void ath9k_tasklet(unsigned long data)
Sujithff37e332008-11-24 12:07:55 +0530589{
590 struct ath_softc *sc = (struct ath_softc *)data;
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -0700591 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700592 struct ath_common *common = ath9k_hw_common(ah);
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -0700593
Sujith17d79042009-02-09 13:27:03 +0530594 u32 status = sc->intrstatus;
Felix Fietkaub5c804752010-04-15 17:38:48 -0400595 u32 rxmask;
Sujithff37e332008-11-24 12:07:55 +0530596
Vasanthakumar Thiagarajan153e0802009-05-15 02:47:16 -0400597 ath9k_ps_wakeup(sc);
598
Felix Fietkau347809f2010-07-02 00:09:52 +0200599 if (status & ATH9K_INT_FATAL) {
Felix Fietkaufac6b6a2010-10-23 17:45:38 +0200600 ath_reset(sc, true);
Vasanthakumar Thiagarajan153e0802009-05-15 02:47:16 -0400601 ath9k_ps_restore(sc);
Sujithff37e332008-11-24 12:07:55 +0530602 return;
Sujithff37e332008-11-24 12:07:55 +0530603 }
604
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700605 spin_lock_bh(&sc->sc_pcu_lock);
606
Felix Fietkau347809f2010-07-02 00:09:52 +0200607 if (!ath9k_hw_check_alive(ah))
608 ieee80211_queue_work(sc->hw, &sc->hw_check_work);
609
Felix Fietkaub5c804752010-04-15 17:38:48 -0400610 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
611 rxmask = (ATH9K_INT_RXHP | ATH9K_INT_RXLP | ATH9K_INT_RXEOL |
612 ATH9K_INT_RXORN);
613 else
614 rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
615
616 if (status & rxmask) {
Felix Fietkaub5c804752010-04-15 17:38:48 -0400617 /* Check for high priority Rx first */
618 if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
619 (status & ATH9K_INT_RXHP))
620 ath_rx_tasklet(sc, 0, true);
621
622 ath_rx_tasklet(sc, 0, false);
Sujith063d8be2009-03-30 15:28:49 +0530623 }
624
Vasanthakumar Thiagarajane5003242010-04-15 17:39:36 -0400625 if (status & ATH9K_INT_TX) {
626 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
627 ath_tx_edma_tasklet(sc);
628 else
629 ath_tx_tasklet(sc);
630 }
Sujith063d8be2009-03-30 15:28:49 +0530631
Gabor Juhos96148322009-07-24 17:27:21 +0200632 if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
Jouni Malinen54ce8462009-05-19 17:01:40 +0300633 /*
634 * TSF sync does not look correct; remain awake to sync with
635 * the next Beacon.
636 */
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700637 ath_print(common, ATH_DBG_PS,
638 "TSFOOR - Sync with next Beacon\n");
Sujith1b04b932010-01-08 10:36:05 +0530639 sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
Jouni Malinen54ce8462009-05-19 17:01:40 +0300640 }
641
Luis R. Rodriguez766ec4a2009-09-09 14:52:02 -0700642 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
Vasanthakumar Thiagarajanebb8e1d2009-09-01 17:46:32 +0530643 if (status & ATH9K_INT_GENTIMER)
644 ath_gen_timer_isr(sc->sc_ah);
645
Sujithff37e332008-11-24 12:07:55 +0530646 /* re-enable hardware interrupt */
Felix Fietkau4df30712010-11-08 20:54:47 +0100647 ath9k_hw_enable_interrupts(ah);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700648
649 spin_unlock_bh(&sc->sc_pcu_lock);
Vasanthakumar Thiagarajan153e0802009-05-15 02:47:16 -0400650 ath9k_ps_restore(sc);
Sujithff37e332008-11-24 12:07:55 +0530651}
652
Gabor Juhos6baff7f2009-01-14 20:17:06 +0100653irqreturn_t ath_isr(int irq, void *dev)
Sujithff37e332008-11-24 12:07:55 +0530654{
Sujith063d8be2009-03-30 15:28:49 +0530655#define SCHED_INTR ( \
656 ATH9K_INT_FATAL | \
657 ATH9K_INT_RXORN | \
658 ATH9K_INT_RXEOL | \
659 ATH9K_INT_RX | \
Felix Fietkaub5c804752010-04-15 17:38:48 -0400660 ATH9K_INT_RXLP | \
661 ATH9K_INT_RXHP | \
Sujith063d8be2009-03-30 15:28:49 +0530662 ATH9K_INT_TX | \
663 ATH9K_INT_BMISS | \
664 ATH9K_INT_CST | \
Vasanthakumar Thiagarajanebb8e1d2009-09-01 17:46:32 +0530665 ATH9K_INT_TSFOOR | \
666 ATH9K_INT_GENTIMER)
Sujith063d8be2009-03-30 15:28:49 +0530667
Sujithff37e332008-11-24 12:07:55 +0530668 struct ath_softc *sc = dev;
Sujithcbe61d82009-02-09 13:27:12 +0530669 struct ath_hw *ah = sc->sc_ah;
Felix Fietkaub5bfc562010-10-08 22:13:53 +0200670 struct ath_common *common = ath9k_hw_common(ah);
Sujithff37e332008-11-24 12:07:55 +0530671 enum ath9k_int status;
672 bool sched = false;
673
Sujith063d8be2009-03-30 15:28:49 +0530674 /*
675 * The hardware is not ready/present, don't
676 * touch anything. Note this can happen early
677 * on if the IRQ is shared.
678 */
679 if (sc->sc_flags & SC_OP_INVALID)
680 return IRQ_NONE;
Sujithff37e332008-11-24 12:07:55 +0530681
Sujithff37e332008-11-24 12:07:55 +0530682
Sujith063d8be2009-03-30 15:28:49 +0530683 /* shared irq, not for us */
Sujithff37e332008-11-24 12:07:55 +0530684
Vasanthakumar Thiagarajan153e0802009-05-15 02:47:16 -0400685 if (!ath9k_hw_intrpend(ah))
Sujith063d8be2009-03-30 15:28:49 +0530686 return IRQ_NONE;
Sujithff37e332008-11-24 12:07:55 +0530687
Sujith063d8be2009-03-30 15:28:49 +0530688 /*
689 * Figure out the reason(s) for the interrupt. Note
690 * that the hal returns a pseudo-ISR that may include
691 * bits we haven't explicitly enabled so we mask the
692 * value to insure we only process bits we requested.
693 */
694 ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */
Pavel Roskin30691682010-03-31 18:05:31 -0400695 status &= ah->imask; /* discard unasked-for bits */
Sujith063d8be2009-03-30 15:28:49 +0530696
697 /*
698 * If there are no status bits set, then this interrupt was not
699 * for me (should have been caught above).
700 */
Vasanthakumar Thiagarajan153e0802009-05-15 02:47:16 -0400701 if (!status)
Sujith063d8be2009-03-30 15:28:49 +0530702 return IRQ_NONE;
Sujith063d8be2009-03-30 15:28:49 +0530703
704 /* Cache the status */
705 sc->intrstatus = status;
706
707 if (status & SCHED_INTR)
708 sched = true;
709
710 /*
711 * If a FATAL or RXORN interrupt is received, we have to reset the
712 * chip immediately.
713 */
Felix Fietkaub5c804752010-04-15 17:38:48 -0400714 if ((status & ATH9K_INT_FATAL) || ((status & ATH9K_INT_RXORN) &&
715 !(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)))
Sujith063d8be2009-03-30 15:28:49 +0530716 goto chip_reset;
717
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400718 if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
719 (status & ATH9K_INT_BB_WATCHDOG)) {
Felix Fietkaub5bfc562010-10-08 22:13:53 +0200720
721 spin_lock(&common->cc_lock);
722 ath_hw_cycle_counters_update(common);
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400723 ar9003_hw_bb_watchdog_dbg_info(ah);
Felix Fietkaub5bfc562010-10-08 22:13:53 +0200724 spin_unlock(&common->cc_lock);
725
Luis R. Rodriguez08578b82010-05-13 13:33:44 -0400726 goto chip_reset;
727 }
728
Sujith063d8be2009-03-30 15:28:49 +0530729 if (status & ATH9K_INT_SWBA)
730 tasklet_schedule(&sc->bcon_tasklet);
731
732 if (status & ATH9K_INT_TXURN)
733 ath9k_hw_updatetxtriglevel(ah, true);
734
Felix Fietkaub5c804752010-04-15 17:38:48 -0400735 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
736 if (status & ATH9K_INT_RXEOL) {
737 ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN);
738 ath9k_hw_set_interrupts(ah, ah->imask);
739 }
740 }
741
Sujith063d8be2009-03-30 15:28:49 +0530742 if (status & ATH9K_INT_MIB) {
743 /*
744 * Disable interrupts until we service the MIB
745 * interrupt; otherwise it will continue to
746 * fire.
747 */
Felix Fietkau4df30712010-11-08 20:54:47 +0100748 ath9k_hw_disable_interrupts(ah);
Sujith063d8be2009-03-30 15:28:49 +0530749 /*
750 * Let the hal handle the event. We assume
751 * it will clear whatever condition caused
752 * the interrupt.
753 */
Felix Fietkau88eac2d2010-10-12 16:08:03 +0200754 spin_lock(&common->cc_lock);
Felix Fietkaubfc472b2010-10-04 20:09:48 +0200755 ath9k_hw_proc_mib_event(ah);
Felix Fietkau88eac2d2010-10-12 16:08:03 +0200756 spin_unlock(&common->cc_lock);
Felix Fietkau4df30712010-11-08 20:54:47 +0100757 ath9k_hw_enable_interrupts(ah);
Sujith063d8be2009-03-30 15:28:49 +0530758 }
759
Vasanthakumar Thiagarajan153e0802009-05-15 02:47:16 -0400760 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
761 if (status & ATH9K_INT_TIM_TIMER) {
Sujith063d8be2009-03-30 15:28:49 +0530762 /* Clear RxAbort bit so that we can
763 * receive frames */
Luis R. Rodriguez9ecdef42009-09-09 21:10:09 -0700764 ath9k_setpower(sc, ATH9K_PM_AWAKE);
Vasanthakumar Thiagarajan153e0802009-05-15 02:47:16 -0400765 ath9k_hw_setrxabort(sc->sc_ah, 0);
Sujith1b04b932010-01-08 10:36:05 +0530766 sc->ps_flags |= PS_WAIT_FOR_BEACON;
Sujith063d8be2009-03-30 15:28:49 +0530767 }
Sujith063d8be2009-03-30 15:28:49 +0530768
769chip_reset:
770
Sujith817e11d2008-12-07 21:42:44 +0530771 ath_debug_stat_interrupt(sc, status);
772
Sujithff37e332008-11-24 12:07:55 +0530773 if (sched) {
Felix Fietkau4df30712010-11-08 20:54:47 +0100774 /* turn off every interrupt */
775 ath9k_hw_disable_interrupts(ah);
Sujithff37e332008-11-24 12:07:55 +0530776 tasklet_schedule(&sc->intr_tq);
777 }
778
779 return IRQ_HANDLED;
Sujith063d8be2009-03-30 15:28:49 +0530780
781#undef SCHED_INTR
Sujithff37e332008-11-24 12:07:55 +0530782}
783
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700784static u32 ath_get_extchanmode(struct ath_softc *sc,
Sujith99405f92008-11-24 12:08:35 +0530785 struct ieee80211_channel *chan,
Sujith094d05d2008-12-12 11:57:43 +0530786 enum nl80211_channel_type channel_type)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700787{
788 u32 chanmode = 0;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700789
790 switch (chan->band) {
791 case IEEE80211_BAND_2GHZ:
Sujith094d05d2008-12-12 11:57:43 +0530792 switch(channel_type) {
793 case NL80211_CHAN_NO_HT:
794 case NL80211_CHAN_HT20:
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700795 chanmode = CHANNEL_G_HT20;
Sujith094d05d2008-12-12 11:57:43 +0530796 break;
797 case NL80211_CHAN_HT40PLUS:
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700798 chanmode = CHANNEL_G_HT40PLUS;
Sujith094d05d2008-12-12 11:57:43 +0530799 break;
800 case NL80211_CHAN_HT40MINUS:
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700801 chanmode = CHANNEL_G_HT40MINUS;
Sujith094d05d2008-12-12 11:57:43 +0530802 break;
803 }
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700804 break;
805 case IEEE80211_BAND_5GHZ:
Sujith094d05d2008-12-12 11:57:43 +0530806 switch(channel_type) {
807 case NL80211_CHAN_NO_HT:
808 case NL80211_CHAN_HT20:
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700809 chanmode = CHANNEL_A_HT20;
Sujith094d05d2008-12-12 11:57:43 +0530810 break;
811 case NL80211_CHAN_HT40PLUS:
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700812 chanmode = CHANNEL_A_HT40PLUS;
Sujith094d05d2008-12-12 11:57:43 +0530813 break;
814 case NL80211_CHAN_HT40MINUS:
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700815 chanmode = CHANNEL_A_HT40MINUS;
Sujith094d05d2008-12-12 11:57:43 +0530816 break;
817 }
Luis R. Rodriguezf078f202008-08-04 00:16:41 -0700818 break;
819 default:
820 break;
821 }
822
823 return chanmode;
824}
825
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530826static void ath9k_bss_assoc_info(struct ath_softc *sc,
Felix Fietkau9fa23e12010-10-15 20:03:31 +0200827 struct ieee80211_hw *hw,
Sujith5640b082008-10-29 10:16:06 +0530828 struct ieee80211_vif *vif,
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530829 struct ieee80211_bss_conf *bss_conf)
830{
Felix Fietkau9fa23e12010-10-15 20:03:31 +0200831 struct ath_wiphy *aphy = hw->priv;
Luis R. Rodriguezf2b21432009-09-10 08:50:20 -0700832 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguez15107182009-09-10 09:22:37 -0700833 struct ath_common *common = ath9k_hw_common(ah);
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530834
835 if (bss_conf->assoc) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700836 ath_print(common, ATH_DBG_CONFIG,
837 "Bss Info ASSOC %d, bssid: %pM\n",
838 bss_conf->aid, common->curbssid);
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530839
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530840 /* New association, store aid */
Luis R. Rodriguez15107182009-09-10 09:22:37 -0700841 common->curaid = bss_conf->aid;
Luis R. Rodriguezf2b21432009-09-10 08:50:20 -0700842 ath9k_hw_write_associd(ah);
Jouni Malinenccdfeab2009-05-20 21:59:08 +0300843
Senthil Balasubramanian2664f202009-06-24 18:56:39 +0530844 /*
845 * Request a re-configuration of Beacon related timers
846 * on the receipt of the first Beacon frame (i.e.,
847 * after time sync with the AP).
848 */
Sujith1b04b932010-01-08 10:36:05 +0530849 sc->ps_flags |= PS_BEACON_SYNC;
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530850
851 /* Configure the beacon */
Jouni Malinen2c3db3d2009-03-03 19:23:26 +0200852 ath_beacon_config(sc, vif);
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530853
854 /* Reset rssi stats */
Felix Fietkau9fa23e12010-10-15 20:03:31 +0200855 aphy->last_rssi = ATH_RSSI_DUMMY_MARKER;
Vasanthakumar Thiagarajan22e66a42009-08-19 16:23:40 +0530856 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530857
Vasanthakumar Thiagarajan6c3118e2010-06-23 06:49:21 -0700858 sc->sc_flags |= SC_OP_ANI_RUN;
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800859 ath_start_ani(common);
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530860 } else {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700861 ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n");
Luis R. Rodriguez15107182009-09-10 09:22:37 -0700862 common->curaid = 0;
Senthil Balasubramanianf38faa32009-06-24 18:56:40 +0530863 /* Stop ANI */
Vasanthakumar Thiagarajan6c3118e2010-06-23 06:49:21 -0700864 sc->sc_flags &= ~SC_OP_ANI_RUN;
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -0800865 del_timer_sync(&common->ani.timer);
Vasanthakumar Thiagarajan8feceb62008-09-10 18:49:27 +0530866 }
867}
868
Luis R. Rodriguez68a89112009-11-02 14:35:42 -0800869void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530870{
Sujithcbe61d82009-02-09 13:27:12 +0530871 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700872 struct ath_common *common = ath9k_hw_common(ah);
Luis R. Rodriguez68a89112009-11-02 14:35:42 -0800873 struct ieee80211_channel *channel = hw->conf.channel;
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800874 int r;
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530875
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +0530876 ath9k_ps_wakeup(sc);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700877 spin_lock_bh(&sc->sc_pcu_lock);
878
Vivek Natarajan93b1b372009-09-17 09:24:58 +0530879 ath9k_hw_configpcipowersave(ah, 0, 0);
Sujithd2f5b3a2009-04-13 21:56:25 +0530880
Vasanthakumar Thiagarajan159cd462009-06-13 14:50:25 +0530881 if (!ah->curchan)
882 ah->curchan = ath_get_curchannel(sc, sc->hw);
883
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200884 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800885 if (r) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700886 ath_print(common, ATH_DBG_FATAL,
Pavel Roskinf643e512010-01-29 17:22:12 -0500887 "Unable to reset channel (%u MHz), "
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700888 "reset status %d\n",
889 channel->center_freq, r);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530890 }
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530891
892 ath_update_txpow(sc);
893 if (ath_startrecv(sc) != 0) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700894 ath_print(common, ATH_DBG_FATAL,
895 "Unable to restart recv logic\n");
Luis R. Rodriguez4bdd1e92010-10-26 15:27:24 -0700896 spin_unlock_bh(&sc->sc_pcu_lock);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530897 return;
898 }
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530899 if (sc->sc_flags & SC_OP_BEACONS)
Jouni Malinen2c3db3d2009-03-03 19:23:26 +0200900 ath_beacon_config(sc, NULL); /* restart beacons */
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530901
902 /* Re-Enable interrupts */
Pavel Roskin30691682010-03-31 18:05:31 -0400903 ath9k_hw_set_interrupts(ah, ah->imask);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530904
905 /* Enable LED */
Vivek Natarajan08fc5c12009-08-14 11:30:52 +0530906 ath9k_hw_cfg_output(ah, ah->led_pin,
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530907 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
Vivek Natarajan08fc5c12009-08-14 11:30:52 +0530908 ath9k_hw_set_gpio(ah, ah->led_pin, 0);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530909
Luis R. Rodriguez68a89112009-11-02 14:35:42 -0800910 ieee80211_wake_queues(hw);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700911 spin_unlock_bh(&sc->sc_pcu_lock);
912
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +0530913 ath9k_ps_restore(sc);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530914}
915
Luis R. Rodriguez68a89112009-11-02 14:35:42 -0800916void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530917{
Sujithcbe61d82009-02-09 13:27:12 +0530918 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguez68a89112009-11-02 14:35:42 -0800919 struct ieee80211_channel *channel = hw->conf.channel;
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800920 int r;
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530921
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +0530922 ath9k_ps_wakeup(sc);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700923 spin_lock_bh(&sc->sc_pcu_lock);
924
Luis R. Rodriguez68a89112009-11-02 14:35:42 -0800925 ieee80211_stop_queues(hw);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530926
Vivek Natarajan982723d2010-06-23 12:08:29 +0530927 /*
928 * Keep the LED on when the radio is disabled
929 * during idle unassociated state.
930 */
931 if (!sc->ps_idle) {
932 ath9k_hw_set_gpio(ah, ah->led_pin, 1);
933 ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
934 }
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530935
936 /* Disable interrupts */
Felix Fietkau4df30712010-11-08 20:54:47 +0100937 ath9k_hw_disable_interrupts(ah);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530938
Sujith043a0402009-01-16 21:38:47 +0530939 ath_drain_all_txq(sc, false); /* clear pending tx frames */
Luis R. Rodriguez5e848f72010-10-20 16:07:06 -0700940
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530941 ath_stoprecv(sc); /* turn off frame recv */
942 ath_flushrecv(sc); /* flush recv queue */
943
Vasanthakumar Thiagarajan159cd462009-06-13 14:50:25 +0530944 if (!ah->curchan)
Luis R. Rodriguez68a89112009-11-02 14:35:42 -0800945 ah->curchan = ath_get_curchannel(sc, hw);
Vasanthakumar Thiagarajan159cd462009-06-13 14:50:25 +0530946
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200947 r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800948 if (r) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700949 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
Pavel Roskinf643e512010-01-29 17:22:12 -0500950 "Unable to reset channel (%u MHz), "
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700951 "reset status %d\n",
952 channel->center_freq, r);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530953 }
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530954
955 ath9k_hw_phy_disable(ah);
Luis R. Rodriguez5e848f72010-10-20 16:07:06 -0700956
Vivek Natarajan93b1b372009-09-17 09:24:58 +0530957 ath9k_hw_configpcipowersave(ah, 1, 1);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700958
959 spin_unlock_bh(&sc->sc_pcu_lock);
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +0530960 ath9k_ps_restore(sc);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700961
Luis R. Rodriguez9ecdef42009-09-09 21:10:09 -0700962 ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
Vasanthakumar Thiagarajan500c0642008-09-10 18:50:17 +0530963}
964
Sujithff37e332008-11-24 12:07:55 +0530965int ath_reset(struct ath_softc *sc, bool retry_tx)
966{
Sujithcbe61d82009-02-09 13:27:12 +0530967 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700968 struct ath_common *common = ath9k_hw_common(ah);
Luis R. Rodriguez030bb492008-12-23 15:58:37 -0800969 struct ieee80211_hw *hw = sc->hw;
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800970 int r;
Sujithff37e332008-11-24 12:07:55 +0530971
Sujith2ab81d42009-12-14 16:34:56 +0530972 /* Stop ANI */
973 del_timer_sync(&common->ani.timer);
974
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -0700975 spin_lock_bh(&sc->sc_pcu_lock);
976
Sujithcc9c3782010-01-08 10:36:09 +0530977 ieee80211_stop_queues(hw);
978
Felix Fietkau4df30712010-11-08 20:54:47 +0100979 ath9k_hw_disable_interrupts(ah);
Sujith043a0402009-01-16 21:38:47 +0530980 ath_drain_all_txq(sc, retry_tx);
Luis R. Rodriguez5e848f72010-10-20 16:07:06 -0700981
Sujithff37e332008-11-24 12:07:55 +0530982 ath_stoprecv(sc);
983 ath_flushrecv(sc);
984
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200985 r = ath9k_hw_reset(ah, sc->sc_ah->curchan, ah->caldata, false);
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -0800986 if (r)
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700987 ath_print(common, ATH_DBG_FATAL,
988 "Unable to reset hardware; reset status %d\n", r);
Sujithff37e332008-11-24 12:07:55 +0530989
990 if (ath_startrecv(sc) != 0)
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -0700991 ath_print(common, ATH_DBG_FATAL,
992 "Unable to start recv logic\n");
Sujithff37e332008-11-24 12:07:55 +0530993
994 /*
995 * We may be doing a reset in response to a request
996 * that changes the channel so update any state that
997 * might change as a result.
998 */
Sujithff37e332008-11-24 12:07:55 +0530999 ath_update_txpow(sc);
1000
Luis R. Rodriguez52b8ac92010-09-16 15:12:27 -04001001 if ((sc->sc_flags & SC_OP_BEACONS) || !(sc->sc_flags & (SC_OP_OFFCHANNEL)))
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001002 ath_beacon_config(sc, NULL); /* restart beacons */
Sujithff37e332008-11-24 12:07:55 +05301003
Pavel Roskin30691682010-03-31 18:05:31 -04001004 ath9k_hw_set_interrupts(ah, ah->imask);
Sujithff37e332008-11-24 12:07:55 +05301005
1006 if (retry_tx) {
1007 int i;
1008 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1009 if (ATH_TXQ_SETUP(sc, i)) {
Sujithb77f4832008-12-07 21:44:03 +05301010 spin_lock_bh(&sc->tx.txq[i].axq_lock);
1011 ath_txq_schedule(sc, &sc->tx.txq[i]);
1012 spin_unlock_bh(&sc->tx.txq[i].axq_lock);
Sujithff37e332008-11-24 12:07:55 +05301013 }
1014 }
1015 }
1016
Sujithcc9c3782010-01-08 10:36:09 +05301017 ieee80211_wake_queues(hw);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -07001018 spin_unlock_bh(&sc->sc_pcu_lock);
Sujithcc9c3782010-01-08 10:36:09 +05301019
Sujith2ab81d42009-12-14 16:34:56 +05301020 /* Start ANI */
1021 ath_start_ani(common);
1022
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -08001023 return r;
Sujithff37e332008-11-24 12:07:55 +05301024}
1025
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001026/* XXX: Remove me once we don't depend on ath9k_channel for all
1027 * this redundant data */
Jouni Malinen0e2dedf2009-03-03 19:23:32 +02001028void ath9k_update_ichannel(struct ath_softc *sc, struct ieee80211_hw *hw,
1029 struct ath9k_channel *ichan)
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001030{
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001031 struct ieee80211_channel *chan = hw->conf.channel;
1032 struct ieee80211_conf *conf = &hw->conf;
1033
1034 ichan->channel = chan->center_freq;
1035 ichan->chan = chan;
1036
1037 if (chan->band == IEEE80211_BAND_2GHZ) {
1038 ichan->chanmode = CHANNEL_G;
Sujith88132622009-09-03 12:08:53 +05301039 ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM | CHANNEL_G;
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001040 } else {
1041 ichan->chanmode = CHANNEL_A;
1042 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
1043 }
1044
Luis R. Rodriguez25c56ee2009-09-13 23:04:44 -07001045 if (conf_is_ht(conf))
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001046 ichan->chanmode = ath_get_extchanmode(sc, chan,
1047 conf->channel_type);
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001048}
1049
Sujithff37e332008-11-24 12:07:55 +05301050/**********************/
1051/* mac80211 callbacks */
1052/**********************/
1053
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001054static int ath9k_start(struct ieee80211_hw *hw)
1055{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001056 struct ath_wiphy *aphy = hw->priv;
1057 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001058 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001059 struct ath_common *common = ath9k_hw_common(ah);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001060 struct ieee80211_channel *curchan = hw->conf.channel;
Sujithff37e332008-11-24 12:07:55 +05301061 struct ath9k_channel *init_channel;
Vasanthakumar Thiagarajan82880a72009-06-13 14:50:24 +05301062 int r;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001063
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001064 ath_print(common, ATH_DBG_CONFIG,
1065 "Starting driver with initial channel: %d MHz\n",
1066 curchan->center_freq);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001067
Sujith141b38b2009-02-04 08:10:07 +05301068 mutex_lock(&sc->mutex);
1069
Jouni Malinen9580a222009-03-03 19:23:33 +02001070 if (ath9k_wiphy_started(sc)) {
1071 if (sc->chan_idx == curchan->hw_value) {
1072 /*
1073 * Already on the operational channel, the new wiphy
1074 * can be marked active.
1075 */
1076 aphy->state = ATH_WIPHY_ACTIVE;
1077 ieee80211_wake_queues(hw);
1078 } else {
1079 /*
1080 * Another wiphy is on another channel, start the new
1081 * wiphy in paused state.
1082 */
1083 aphy->state = ATH_WIPHY_PAUSED;
1084 ieee80211_stop_queues(hw);
1085 }
1086 mutex_unlock(&sc->mutex);
1087 return 0;
1088 }
1089 aphy->state = ATH_WIPHY_ACTIVE;
1090
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001091 /* setup initial channel */
1092
Vasanthakumar Thiagarajan82880a72009-06-13 14:50:24 +05301093 sc->chan_idx = curchan->hw_value;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001094
Vasanthakumar Thiagarajan82880a72009-06-13 14:50:24 +05301095 init_channel = ath_get_curchannel(sc, hw);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001096
Sujithff37e332008-11-24 12:07:55 +05301097 /* Reset SERDES registers */
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001098 ath9k_hw_configpcipowersave(ah, 0, 0);
Sujithff37e332008-11-24 12:07:55 +05301099
1100 /*
1101 * The basic interface to setting the hardware in a good
1102 * state is ``reset''. On return the hardware is known to
1103 * be powered up and with interrupts disabled. This must
1104 * be followed by initialization of the appropriate bits
1105 * and then setup of the interrupt mask.
1106 */
Luis R. Rodriguez4bdd1e92010-10-26 15:27:24 -07001107 spin_lock_bh(&sc->sc_pcu_lock);
Felix Fietkau20bd2a02010-07-31 00:12:00 +02001108 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -08001109 if (r) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001110 ath_print(common, ATH_DBG_FATAL,
1111 "Unable to reset hardware; reset status %d "
1112 "(freq %u MHz)\n", r,
1113 curchan->center_freq);
Luis R. Rodriguez4bdd1e92010-10-26 15:27:24 -07001114 spin_unlock_bh(&sc->sc_pcu_lock);
Sujith141b38b2009-02-04 08:10:07 +05301115 goto mutex_unlock;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001116 }
Sujithff37e332008-11-24 12:07:55 +05301117
1118 /*
1119 * This is needed only to setup initial state
1120 * but it's best done after a reset.
1121 */
1122 ath_update_txpow(sc);
1123
1124 /*
1125 * Setup the hardware after reset:
1126 * The receive engine is set going.
1127 * Frame transmit is handled entirely
1128 * in the frame output path; there's nothing to do
1129 * here except setup the interrupt mask.
1130 */
1131 if (ath_startrecv(sc) != 0) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001132 ath_print(common, ATH_DBG_FATAL,
1133 "Unable to start recv logic\n");
Sujith141b38b2009-02-04 08:10:07 +05301134 r = -EIO;
Luis R. Rodriguez4bdd1e92010-10-26 15:27:24 -07001135 spin_unlock_bh(&sc->sc_pcu_lock);
Sujith141b38b2009-02-04 08:10:07 +05301136 goto mutex_unlock;
Sujithff37e332008-11-24 12:07:55 +05301137 }
Luis R. Rodriguez4bdd1e92010-10-26 15:27:24 -07001138 spin_unlock_bh(&sc->sc_pcu_lock);
Sujithff37e332008-11-24 12:07:55 +05301139
1140 /* Setup our intr mask. */
Felix Fietkaub5c804752010-04-15 17:38:48 -04001141 ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL |
1142 ATH9K_INT_RXORN | ATH9K_INT_FATAL |
1143 ATH9K_INT_GLOBAL;
1144
1145 if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
Luis R. Rodriguez08578b82010-05-13 13:33:44 -04001146 ah->imask |= ATH9K_INT_RXHP |
1147 ATH9K_INT_RXLP |
1148 ATH9K_INT_BB_WATCHDOG;
Felix Fietkaub5c804752010-04-15 17:38:48 -04001149 else
1150 ah->imask |= ATH9K_INT_RX;
Sujithff37e332008-11-24 12:07:55 +05301151
Felix Fietkau364734f2010-09-14 20:22:44 +02001152 ah->imask |= ATH9K_INT_GTT;
Sujithff37e332008-11-24 12:07:55 +05301153
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001154 if (ah->caps.hw_caps & ATH9K_HW_CAP_HT)
Pavel Roskin30691682010-03-31 18:05:31 -04001155 ah->imask |= ATH9K_INT_CST;
Sujithff37e332008-11-24 12:07:55 +05301156
Sujithff37e332008-11-24 12:07:55 +05301157 sc->sc_flags &= ~SC_OP_INVALID;
1158
1159 /* Disable BMISS interrupt when we're not associated */
Pavel Roskin30691682010-03-31 18:05:31 -04001160 ah->imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS);
1161 ath9k_hw_set_interrupts(ah, ah->imask);
Sujithff37e332008-11-24 12:07:55 +05301162
Jouni Malinenbce048d2009-03-03 19:23:28 +02001163 ieee80211_wake_queues(hw);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001164
Luis R. Rodriguez42935ec2009-07-29 20:08:07 -04001165 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
Senthil Balasubramanian164ace32009-07-14 20:17:09 -04001166
Luis R. Rodriguez766ec4a2009-09-09 14:52:02 -07001167 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
1168 !ah->btcoex_hw.enabled) {
Luis R. Rodriguez5e197292009-09-09 15:15:55 -07001169 ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT,
1170 AR_STOMP_LOW_WLAN_WGHT);
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001171 ath9k_hw_btcoex_enable(ah);
Vasanthakumar Thiagarajanf985ad12009-08-26 21:08:43 +05301172
Luis R. Rodriguez5bb12792009-09-14 00:55:09 -07001173 if (common->bus_ops->bt_coex_prep)
1174 common->bus_ops->bt_coex_prep(common);
Luis R. Rodriguez766ec4a2009-09-09 14:52:02 -07001175 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
Luis R. Rodriguez75d78392009-09-09 04:00:10 -07001176 ath9k_btcoex_timer_resume(sc);
Vasanthakumar Thiagarajan17739122009-08-26 21:08:50 +05301177 }
1178
Sujith141b38b2009-02-04 08:10:07 +05301179mutex_unlock:
1180 mutex_unlock(&sc->mutex);
1181
Luis R. Rodriguezae8d2852008-12-23 15:58:40 -08001182 return r;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001183}
1184
1185static int ath9k_tx(struct ieee80211_hw *hw,
1186 struct sk_buff *skb)
1187{
Jouni Malinen147583c2008-08-11 14:01:50 +03001188 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
Jouni Malinenbce048d2009-03-03 19:23:28 +02001189 struct ath_wiphy *aphy = hw->priv;
1190 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001191 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Sujith528f0c62008-10-29 10:14:26 +05301192 struct ath_tx_control txctl;
Benoit Papillault1bc14882009-11-24 15:49:18 +01001193 int padpos, padsize;
1194 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
Sujith528f0c62008-10-29 10:14:26 +05301195
Jouni Malinen8089cc42009-03-03 19:23:38 +02001196 if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001197 ath_print(common, ATH_DBG_XMIT,
1198 "ath9k: %s: TX in unexpected wiphy state "
1199 "%d\n", wiphy_name(hw->wiphy), aphy->state);
Jouni Malinenee166a02009-03-03 19:23:36 +02001200 goto exit;
1201 }
1202
Gabor Juhos96148322009-07-24 17:27:21 +02001203 if (sc->ps_enabled) {
Jouni Malinendc8c4582009-05-19 17:01:42 +03001204 /*
1205 * mac80211 does not set PM field for normal data frames, so we
1206 * need to update that based on the current PS mode.
1207 */
1208 if (ieee80211_is_data(hdr->frame_control) &&
1209 !ieee80211_is_nullfunc(hdr->frame_control) &&
1210 !ieee80211_has_pm(hdr->frame_control)) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001211 ath_print(common, ATH_DBG_PS, "Add PM=1 for a TX frame "
1212 "while in PS mode\n");
Jouni Malinendc8c4582009-05-19 17:01:42 +03001213 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
1214 }
1215 }
1216
Jouni Malinen9a23f9c2009-05-19 17:01:38 +03001217 if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
1218 /*
1219 * We are using PS-Poll and mac80211 can request TX while in
1220 * power save mode. Need to wake up hardware for the TX to be
1221 * completed and if needed, also for RX of buffered frames.
1222 */
Jouni Malinen9a23f9c2009-05-19 17:01:38 +03001223 ath9k_ps_wakeup(sc);
Vasanthakumar Thiagarajanfdf76622010-05-17 18:57:55 -07001224 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
1225 ath9k_hw_setrxabort(sc->sc_ah, 0);
Jouni Malinen9a23f9c2009-05-19 17:01:38 +03001226 if (ieee80211_is_pspoll(hdr->frame_control)) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001227 ath_print(common, ATH_DBG_PS,
1228 "Sending PS-Poll to pick a buffered frame\n");
Sujith1b04b932010-01-08 10:36:05 +05301229 sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
Jouni Malinen9a23f9c2009-05-19 17:01:38 +03001230 } else {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001231 ath_print(common, ATH_DBG_PS,
1232 "Wake up to complete TX\n");
Sujith1b04b932010-01-08 10:36:05 +05301233 sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
Jouni Malinen9a23f9c2009-05-19 17:01:38 +03001234 }
1235 /*
1236 * The actual restore operation will happen only after
1237 * the sc_flags bit is cleared. We are just dropping
1238 * the ps_usecount here.
1239 */
1240 ath9k_ps_restore(sc);
1241 }
1242
Sujith528f0c62008-10-29 10:14:26 +05301243 memset(&txctl, 0, sizeof(struct ath_tx_control));
Jouni Malinen147583c2008-08-11 14:01:50 +03001244
1245 /*
1246 * As a temporary workaround, assign seq# here; this will likely need
1247 * to be cleaned up to work better with Beacon transmission and virtual
1248 * BSSes.
1249 */
1250 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
Jouni Malinen147583c2008-08-11 14:01:50 +03001251 if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
Sujithb77f4832008-12-07 21:44:03 +05301252 sc->tx.seq_no += 0x10;
Jouni Malinen147583c2008-08-11 14:01:50 +03001253 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
Sujithb77f4832008-12-07 21:44:03 +05301254 hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
Jouni Malinen147583c2008-08-11 14:01:50 +03001255 }
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001256
1257 /* Add the padding after the header if this is not already done */
Benoit Papillault1bc14882009-11-24 15:49:18 +01001258 padpos = ath9k_cmn_padpos(hdr->frame_control);
1259 padsize = padpos & 3;
1260 if (padsize && skb->len>padpos) {
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001261 if (skb_headroom(skb) < padsize)
1262 return -1;
1263 skb_push(skb, padsize);
Benoit Papillault1bc14882009-11-24 15:49:18 +01001264 memmove(skb->data, skb->data + padsize, padpos);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001265 }
1266
Felix Fietkau066dae92010-11-07 14:59:39 +01001267 txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
Sujith528f0c62008-10-29 10:14:26 +05301268
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001269 ath_print(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001270
Jouni Malinenc52f33d2009-03-03 19:23:29 +02001271 if (ath_tx_start(hw, skb, &txctl) != 0) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001272 ath_print(common, ATH_DBG_XMIT, "TX failed\n");
Sujith528f0c62008-10-29 10:14:26 +05301273 goto exit;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001274 }
1275
1276 return 0;
Sujith528f0c62008-10-29 10:14:26 +05301277exit:
1278 dev_kfree_skb_any(skb);
1279 return 0;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001280}
1281
1282static void ath9k_stop(struct ieee80211_hw *hw)
1283{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001284 struct ath_wiphy *aphy = hw->priv;
1285 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001286 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001287 struct ath_common *common = ath9k_hw_common(ah);
Rajkumar Manoharan447a42c2010-07-08 12:12:29 +05301288 int i;
Sujith9c84b792008-10-29 10:17:13 +05301289
Sujith4c483812009-08-18 10:51:52 +05301290 mutex_lock(&sc->mutex);
1291
Jouni Malinen9580a222009-03-03 19:23:33 +02001292 aphy->state = ATH_WIPHY_INACTIVE;
1293
Vivek Natarajan9a75c2f2010-06-22 11:52:37 +05301294 if (led_blink)
1295 cancel_delayed_work_sync(&sc->ath_led_blink_work);
1296
Luis R. Rodriguezc94dbff2009-07-27 11:53:04 -07001297 cancel_delayed_work_sync(&sc->tx_complete_work);
Felix Fietkau9f42c2b2010-06-12 00:34:01 -04001298 cancel_work_sync(&sc->paprd_work);
Felix Fietkau347809f2010-07-02 00:09:52 +02001299 cancel_work_sync(&sc->hw_check_work);
Luis R. Rodriguezc94dbff2009-07-27 11:53:04 -07001300
Rajkumar Manoharan447a42c2010-07-08 12:12:29 +05301301 for (i = 0; i < sc->num_sec_wiphy; i++) {
1302 if (sc->sec_wiphy[i])
1303 break;
1304 }
1305
1306 if (i == sc->num_sec_wiphy) {
Luis R. Rodriguezc94dbff2009-07-27 11:53:04 -07001307 cancel_delayed_work_sync(&sc->wiphy_work);
1308 cancel_work_sync(&sc->chan_work);
1309 }
1310
Sujith9c84b792008-10-29 10:17:13 +05301311 if (sc->sc_flags & SC_OP_INVALID) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001312 ath_print(common, ATH_DBG_ANY, "Device not present\n");
Sujith4c483812009-08-18 10:51:52 +05301313 mutex_unlock(&sc->mutex);
Sujith9c84b792008-10-29 10:17:13 +05301314 return;
1315 }
1316
Jouni Malinen9580a222009-03-03 19:23:33 +02001317 if (ath9k_wiphy_started(sc)) {
1318 mutex_unlock(&sc->mutex);
1319 return; /* another wiphy still in use */
1320 }
1321
Sujith3867cf62009-12-23 20:03:27 -05001322 /* Ensure HW is awake when we try to shut it down. */
1323 ath9k_ps_wakeup(sc);
1324
Luis R. Rodriguez766ec4a2009-09-09 14:52:02 -07001325 if (ah->btcoex_hw.enabled) {
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001326 ath9k_hw_btcoex_disable(ah);
Luis R. Rodriguez766ec4a2009-09-09 14:52:02 -07001327 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
Luis R. Rodriguez75d78392009-09-09 04:00:10 -07001328 ath9k_btcoex_timer_pause(sc);
Vasanthakumar Thiagarajan17739122009-08-26 21:08:50 +05301329 }
1330
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -07001331 spin_lock_bh(&sc->sc_pcu_lock);
1332
Sujithff37e332008-11-24 12:07:55 +05301333 /* make sure h/w will not generate any interrupt
1334 * before setting the invalid flag. */
Felix Fietkau4df30712010-11-08 20:54:47 +01001335 ath9k_hw_disable_interrupts(ah);
Sujithff37e332008-11-24 12:07:55 +05301336
1337 if (!(sc->sc_flags & SC_OP_INVALID)) {
Sujith043a0402009-01-16 21:38:47 +05301338 ath_drain_all_txq(sc, false);
Sujithff37e332008-11-24 12:07:55 +05301339 ath_stoprecv(sc);
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001340 ath9k_hw_phy_disable(ah);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -07001341 } else
Sujithb77f4832008-12-07 21:44:03 +05301342 sc->rx.rxlink = NULL;
Sujithff37e332008-11-24 12:07:55 +05301343
Sujithff37e332008-11-24 12:07:55 +05301344 /* disable HAL and put h/w to sleep */
Luis R. Rodriguezaf03abe2009-09-09 02:33:11 -07001345 ath9k_hw_disable(ah);
1346 ath9k_hw_configpcipowersave(ah, 1, 1);
Luis R. Rodriguez6a6733f2010-10-26 15:27:25 -07001347
1348 spin_unlock_bh(&sc->sc_pcu_lock);
1349
Sujith3867cf62009-12-23 20:03:27 -05001350 ath9k_ps_restore(sc);
1351
1352 /* Finally, put the chip in FULL SLEEP mode */
Luis R. Rodriguez9ecdef42009-09-09 21:10:09 -07001353 ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
Sujithff37e332008-11-24 12:07:55 +05301354
1355 sc->sc_flags |= SC_OP_INVALID;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001356
Sujith141b38b2009-02-04 08:10:07 +05301357 mutex_unlock(&sc->mutex);
1358
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001359 ath_print(common, ATH_DBG_CONFIG, "Driver halt\n");
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001360}
1361
1362static int ath9k_add_interface(struct ieee80211_hw *hw,
Johannes Berg1ed32e42009-12-23 13:15:45 +01001363 struct ieee80211_vif *vif)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001364{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001365 struct ath_wiphy *aphy = hw->priv;
1366 struct ath_softc *sc = aphy->sc;
Pavel Roskin30691682010-03-31 18:05:31 -04001367 struct ath_hw *ah = sc->sc_ah;
1368 struct ath_common *common = ath9k_hw_common(ah);
Johannes Berg1ed32e42009-12-23 13:15:45 +01001369 struct ath_vif *avp = (void *)vif->drv_priv;
Colin McCabed97809d2008-12-01 13:38:55 -08001370 enum nl80211_iftype ic_opmode = NL80211_IFTYPE_UNSPECIFIED;
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001371 int ret = 0;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001372
Sujith141b38b2009-02-04 08:10:07 +05301373 mutex_lock(&sc->mutex);
1374
Johannes Berg1ed32e42009-12-23 13:15:45 +01001375 switch (vif->type) {
Johannes Berg05c914f2008-09-11 00:01:58 +02001376 case NL80211_IFTYPE_STATION:
Colin McCabed97809d2008-12-01 13:38:55 -08001377 ic_opmode = NL80211_IFTYPE_STATION;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001378 break;
Bill Jordane51f3ef2010-10-01 11:20:39 -04001379 case NL80211_IFTYPE_WDS:
1380 ic_opmode = NL80211_IFTYPE_WDS;
1381 break;
Johannes Berg05c914f2008-09-11 00:01:58 +02001382 case NL80211_IFTYPE_ADHOC:
Johannes Berg05c914f2008-09-11 00:01:58 +02001383 case NL80211_IFTYPE_AP:
Pat Erley9cb54122009-03-20 22:59:59 -04001384 case NL80211_IFTYPE_MESH_POINT:
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001385 if (sc->nbcnvifs >= ATH_BCBUF) {
1386 ret = -ENOBUFS;
1387 goto out;
1388 }
Johannes Berg1ed32e42009-12-23 13:15:45 +01001389 ic_opmode = vif->type;
Jouni Malinen2ad67de2008-08-11 14:01:47 +03001390 break;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001391 default:
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001392 ath_print(common, ATH_DBG_FATAL,
Johannes Berg1ed32e42009-12-23 13:15:45 +01001393 "Interface type %d not yet supported\n", vif->type);
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001394 ret = -EOPNOTSUPP;
1395 goto out;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001396 }
1397
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001398 ath_print(common, ATH_DBG_CONFIG,
1399 "Attach a VIF of type: %d\n", ic_opmode);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001400
Sujith17d79042009-02-09 13:27:03 +05301401 /* Set the VIF opmode */
Sujith5640b082008-10-29 10:16:06 +05301402 avp->av_opmode = ic_opmode;
1403 avp->av_bslot = -1;
1404
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001405 sc->nvifs++;
Jouni Malinen8ca21f02009-03-03 19:23:27 +02001406
Felix Fietkau364734f2010-09-14 20:22:44 +02001407 ath9k_set_bssid_mask(hw, vif);
Jouni Malinen8ca21f02009-03-03 19:23:27 +02001408
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001409 if (sc->nvifs > 1)
1410 goto out; /* skip global settings for secondary vif */
1411
Sujithb238e902009-03-03 10:16:56 +05301412 if (ic_opmode == NL80211_IFTYPE_AP) {
Pavel Roskin30691682010-03-31 18:05:31 -04001413 ath9k_hw_set_tsfadjust(ah, 1);
Sujithb238e902009-03-03 10:16:56 +05301414 sc->sc_flags |= SC_OP_TSF_RESET;
1415 }
Sujith5640b082008-10-29 10:16:06 +05301416
Sujith5640b082008-10-29 10:16:06 +05301417 /* Set the device opmode */
Pavel Roskin30691682010-03-31 18:05:31 -04001418 ah->opmode = ic_opmode;
Sujith5640b082008-10-29 10:16:06 +05301419
Vivek Natarajan4e30ffa2009-01-28 20:53:27 +05301420 /*
1421 * Enable MIB interrupts when there are hardware phy counters.
1422 * Note we only do this (at the moment) for station mode.
1423 */
Johannes Berg1ed32e42009-12-23 13:15:45 +01001424 if ((vif->type == NL80211_IFTYPE_STATION) ||
1425 (vif->type == NL80211_IFTYPE_ADHOC) ||
1426 (vif->type == NL80211_IFTYPE_MESH_POINT)) {
Luis R. Rodriguez3448f912010-04-15 17:38:23 -04001427 if (ah->config.enable_ani)
1428 ah->imask |= ATH9K_INT_MIB;
Pavel Roskin30691682010-03-31 18:05:31 -04001429 ah->imask |= ATH9K_INT_TSFOOR;
Sujith4af9cf42009-02-12 10:06:47 +05301430 }
1431
Pavel Roskin30691682010-03-31 18:05:31 -04001432 ath9k_hw_set_interrupts(ah, ah->imask);
Vivek Natarajan4e30ffa2009-01-28 20:53:27 +05301433
Johannes Berg1ed32e42009-12-23 13:15:45 +01001434 if (vif->type == NL80211_IFTYPE_AP ||
1435 vif->type == NL80211_IFTYPE_ADHOC ||
Vasanthakumar Thiagarajan6c3118e2010-06-23 06:49:21 -07001436 vif->type == NL80211_IFTYPE_MONITOR) {
1437 sc->sc_flags |= SC_OP_ANI_RUN;
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -08001438 ath_start_ani(common);
Vasanthakumar Thiagarajan6c3118e2010-06-23 06:49:21 -07001439 }
Luis R. Rodriguez6f255422008-10-03 15:45:27 -07001440
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001441out:
Sujith141b38b2009-02-04 08:10:07 +05301442 mutex_unlock(&sc->mutex);
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001443 return ret;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001444}
1445
1446static void ath9k_remove_interface(struct ieee80211_hw *hw,
Johannes Berg1ed32e42009-12-23 13:15:45 +01001447 struct ieee80211_vif *vif)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001448{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001449 struct ath_wiphy *aphy = hw->priv;
1450 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001451 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Johannes Berg1ed32e42009-12-23 13:15:45 +01001452 struct ath_vif *avp = (void *)vif->drv_priv;
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001453 int i;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001454
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001455 ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n");
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001456
Sujith141b38b2009-02-04 08:10:07 +05301457 mutex_lock(&sc->mutex);
1458
Luis R. Rodriguez6f255422008-10-03 15:45:27 -07001459 /* Stop ANI */
Vasanthakumar Thiagarajan6c3118e2010-06-23 06:49:21 -07001460 sc->sc_flags &= ~SC_OP_ANI_RUN;
Luis R. Rodriguez3d536ac2009-11-03 17:07:04 -08001461 del_timer_sync(&common->ani.timer);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001462
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001463 /* Reclaim beacon resources */
Pat Erley9cb54122009-03-20 22:59:59 -04001464 if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
1465 (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) ||
1466 (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) {
Luis R. Rodriguez5f70a882009-12-23 20:03:28 -05001467 ath9k_ps_wakeup(sc);
Sujithb77f4832008-12-07 21:44:03 +05301468 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
Luis R. Rodriguez5f70a882009-12-23 20:03:28 -05001469 ath9k_ps_restore(sc);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001470 }
1471
Felix Fietkau74401772010-01-19 20:51:32 +01001472 ath_beacon_return(sc, avp);
Sujith672840a2008-08-11 14:05:08 +05301473 sc->sc_flags &= ~SC_OP_BEACONS;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001474
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001475 for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) {
Johannes Berg1ed32e42009-12-23 13:15:45 +01001476 if (sc->beacon.bslot[i] == vif) {
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001477 printk(KERN_DEBUG "%s: vif had allocated beacon "
1478 "slot\n", __func__);
1479 sc->beacon.bslot[i] = NULL;
Jouni Malinenc52f33d2009-03-03 19:23:29 +02001480 sc->beacon.bslot_aphy[i] = NULL;
Jouni Malinen2c3db3d2009-03-03 19:23:26 +02001481 }
1482 }
1483
Sujith17d79042009-02-09 13:27:03 +05301484 sc->nvifs--;
Sujith141b38b2009-02-04 08:10:07 +05301485
1486 mutex_unlock(&sc->mutex);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001487}
1488
Senthil Balasubramanianfbab7392010-10-05 20:36:40 +05301489static void ath9k_enable_ps(struct ath_softc *sc)
Senthil Balasubramanian3f7c5c12010-02-03 22:51:13 +05301490{
Pavel Roskin30691682010-03-31 18:05:31 -04001491 struct ath_hw *ah = sc->sc_ah;
1492
Senthil Balasubramanian3f7c5c12010-02-03 22:51:13 +05301493 sc->ps_enabled = true;
Pavel Roskin30691682010-03-31 18:05:31 -04001494 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
1495 if ((ah->imask & ATH9K_INT_TIM_TIMER) == 0) {
1496 ah->imask |= ATH9K_INT_TIM_TIMER;
1497 ath9k_hw_set_interrupts(ah, ah->imask);
Senthil Balasubramanian3f7c5c12010-02-03 22:51:13 +05301498 }
Vasanthakumar Thiagarajanfdf76622010-05-17 18:57:55 -07001499 ath9k_hw_setrxabort(ah, 1);
Senthil Balasubramanian3f7c5c12010-02-03 22:51:13 +05301500 }
Senthil Balasubramanian3f7c5c12010-02-03 22:51:13 +05301501}
1502
Senthil Balasubramanian845d7082010-10-05 20:36:41 +05301503static void ath9k_disable_ps(struct ath_softc *sc)
1504{
1505 struct ath_hw *ah = sc->sc_ah;
1506
1507 sc->ps_enabled = false;
1508 ath9k_hw_setpower(ah, ATH9K_PM_AWAKE);
1509 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) {
1510 ath9k_hw_setrxabort(ah, 0);
1511 sc->ps_flags &= ~(PS_WAIT_FOR_BEACON |
1512 PS_WAIT_FOR_CAB |
1513 PS_WAIT_FOR_PSPOLL_DATA |
1514 PS_WAIT_FOR_TX_ACK);
1515 if (ah->imask & ATH9K_INT_TIM_TIMER) {
1516 ah->imask &= ~ATH9K_INT_TIM_TIMER;
1517 ath9k_hw_set_interrupts(ah, ah->imask);
1518 }
1519 }
1520
1521}
1522
Johannes Berge8975582008-10-09 12:18:51 +02001523static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001524{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001525 struct ath_wiphy *aphy = hw->priv;
1526 struct ath_softc *sc = aphy->sc;
Felix Fietkau34300982010-10-10 18:21:52 +02001527 struct ath_hw *ah = sc->sc_ah;
1528 struct ath_common *common = ath9k_hw_common(ah);
Johannes Berge8975582008-10-09 12:18:51 +02001529 struct ieee80211_conf *conf = &hw->conf;
Luis R. Rodriguez194b7c12009-10-29 10:41:15 -07001530 bool disable_radio;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001531
Sujithaa33de02008-12-18 11:40:16 +05301532 mutex_lock(&sc->mutex);
Sujith141b38b2009-02-04 08:10:07 +05301533
Luis R. Rodriguez194b7c12009-10-29 10:41:15 -07001534 /*
1535 * Leave this as the first check because we need to turn on the
1536 * radio if it was disabled before prior to processing the rest
1537 * of the changes. Likewise we must only disable the radio towards
1538 * the end.
1539 */
Luis R. Rodriguez64839172009-07-14 20:22:53 -04001540 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
Luis R. Rodriguez194b7c12009-10-29 10:41:15 -07001541 bool enable_radio;
1542 bool all_wiphys_idle;
1543 bool idle = !!(conf->flags & IEEE80211_CONF_IDLE);
Luis R. Rodriguez64839172009-07-14 20:22:53 -04001544
1545 spin_lock_bh(&sc->wiphy_lock);
1546 all_wiphys_idle = ath9k_all_wiphys_idle(sc);
Luis R. Rodriguez194b7c12009-10-29 10:41:15 -07001547 ath9k_set_wiphy_idle(aphy, idle);
1548
Felix Fietkau11446012010-04-06 12:05:01 -07001549 enable_radio = (!idle && all_wiphys_idle);
Luis R. Rodriguez194b7c12009-10-29 10:41:15 -07001550
1551 /*
1552 * After we unlock here its possible another wiphy
1553 * can be re-renabled so to account for that we will
1554 * only disable the radio toward the end of this routine
1555 * if by then all wiphys are still idle.
1556 */
Luis R. Rodriguez64839172009-07-14 20:22:53 -04001557 spin_unlock_bh(&sc->wiphy_lock);
1558
Luis R. Rodriguez194b7c12009-10-29 10:41:15 -07001559 if (enable_radio) {
Vivek Natarajan1dbfd9d2010-01-29 16:56:51 +05301560 sc->ps_idle = false;
Luis R. Rodriguez68a89112009-11-02 14:35:42 -08001561 ath_radio_enable(sc, hw);
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001562 ath_print(common, ATH_DBG_CONFIG,
1563 "not-idle: enabling radio\n");
Luis R. Rodriguez64839172009-07-14 20:22:53 -04001564 }
1565 }
1566
Luis R. Rodrigueze7824a52009-11-24 02:53:25 -05001567 /*
1568 * We just prepare to enable PS. We have to wait until our AP has
1569 * ACK'd our null data frame to disable RX otherwise we'll ignore
1570 * those ACKs and end up retransmitting the same null data frames.
1571 * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode.
1572 */
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +05301573 if (changed & IEEE80211_CONF_CHANGE_PS) {
Luis R. Rodriguez8ab2cd02010-09-16 15:12:26 -04001574 unsigned long flags;
1575 spin_lock_irqsave(&sc->sc_pm_lock, flags);
Senthil Balasubramanianfbab7392010-10-05 20:36:40 +05301576 if (conf->flags & IEEE80211_CONF_PS)
1577 ath9k_enable_ps(sc);
Senthil Balasubramanian845d7082010-10-05 20:36:41 +05301578 else
1579 ath9k_disable_ps(sc);
Luis R. Rodriguez8ab2cd02010-09-16 15:12:26 -04001580 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +05301581 }
1582
Sujith199afd92010-01-08 10:36:13 +05301583 if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
1584 if (conf->flags & IEEE80211_CONF_MONITOR) {
1585 ath_print(common, ATH_DBG_CONFIG,
1586 "HW opmode set to Monitor mode\n");
1587 sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR;
1588 }
1589 }
1590
Johannes Berg47979382009-01-07 10:13:27 +01001591 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
Sujith99405f92008-11-24 12:08:35 +05301592 struct ieee80211_channel *curchan = hw->conf.channel;
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001593 int pos = curchan->hw_value;
Felix Fietkau34300982010-10-10 18:21:52 +02001594 int old_pos = -1;
1595 unsigned long flags;
1596
1597 if (ah->curchan)
1598 old_pos = ah->curchan - &ah->channels[0];
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001599
Jouni Malinen0e2dedf2009-03-03 19:23:32 +02001600 aphy->chan_idx = pos;
1601 aphy->chan_is_ht = conf_is_ht(conf);
Felix Fietkau5ee08652010-07-31 00:11:59 +02001602 if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
1603 sc->sc_flags |= SC_OP_OFFCHANNEL;
1604 else
1605 sc->sc_flags &= ~SC_OP_OFFCHANNEL;
Jouni Malinen0e2dedf2009-03-03 19:23:32 +02001606
Jouni Malinen8089cc42009-03-03 19:23:38 +02001607 if (aphy->state == ATH_WIPHY_SCAN ||
1608 aphy->state == ATH_WIPHY_ACTIVE)
1609 ath9k_wiphy_pause_all_forced(sc, aphy);
1610 else {
1611 /*
1612 * Do not change operational channel based on a paused
1613 * wiphy changes.
1614 */
1615 goto skip_chan_change;
1616 }
Jouni Malinen0e2dedf2009-03-03 19:23:32 +02001617
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001618 ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
1619 curchan->center_freq);
Johannes Bergae5eb022008-10-14 16:58:37 +02001620
Luis R. Rodriguez5f8e0772009-01-22 15:16:48 -08001621 /* XXX: remove me eventualy */
Jouni Malinen0e2dedf2009-03-03 19:23:32 +02001622 ath9k_update_ichannel(sc, hw, &sc->sc_ah->channels[pos]);
Sujithe11602b2008-11-27 09:46:27 +05301623
Luis R. Rodriguezecf70442008-12-23 15:58:43 -08001624 ath_update_chainmask(sc, conf_is_ht(conf));
Sujith86060f02009-01-07 14:25:29 +05301625
Felix Fietkau34300982010-10-10 18:21:52 +02001626 /* update survey stats for the old channel before switching */
1627 spin_lock_irqsave(&common->cc_lock, flags);
1628 ath_update_survey_stats(sc);
1629 spin_unlock_irqrestore(&common->cc_lock, flags);
1630
1631 /*
1632 * If the operating channel changes, change the survey in-use flags
1633 * along with it.
1634 * Reset the survey data for the new channel, unless we're switching
1635 * back to the operating channel from an off-channel operation.
1636 */
1637 if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) &&
1638 sc->cur_survey != &sc->survey[pos]) {
1639
1640 if (sc->cur_survey)
1641 sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE;
1642
1643 sc->cur_survey = &sc->survey[pos];
1644
1645 memset(sc->cur_survey, 0, sizeof(struct survey_info));
1646 sc->cur_survey->filled |= SURVEY_INFO_IN_USE;
1647 } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) {
1648 memset(&sc->survey[pos], 0, sizeof(struct survey_info));
1649 }
1650
Jouni Malinen0e2dedf2009-03-03 19:23:32 +02001651 if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001652 ath_print(common, ATH_DBG_FATAL,
1653 "Unable to set channel\n");
Sujithaa33de02008-12-18 11:40:16 +05301654 mutex_unlock(&sc->mutex);
Sujithe11602b2008-11-27 09:46:27 +05301655 return -EINVAL;
1656 }
Felix Fietkau34300982010-10-10 18:21:52 +02001657
1658 /*
1659 * The most recent snapshot of channel->noisefloor for the old
1660 * channel is only available after the hardware reset. Copy it to
1661 * the survey stats now.
1662 */
1663 if (old_pos >= 0)
1664 ath_update_survey_nf(sc, old_pos);
Sujith094d05d2008-12-12 11:57:43 +05301665 }
Sujith86b89ee2008-08-07 10:54:57 +05301666
Jouni Malinen8089cc42009-03-03 19:23:38 +02001667skip_chan_change:
Luis R. Rodriguezc9f6a652010-01-19 14:04:19 -05001668 if (changed & IEEE80211_CONF_CHANGE_POWER) {
Sujith17d79042009-02-09 13:27:03 +05301669 sc->config.txpowlimit = 2 * conf->power_level;
Luis R. Rodriguezc9f6a652010-01-19 14:04:19 -05001670 ath_update_txpow(sc);
1671 }
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001672
Luis R. Rodriguez194b7c12009-10-29 10:41:15 -07001673 spin_lock_bh(&sc->wiphy_lock);
1674 disable_radio = ath9k_all_wiphys_idle(sc);
1675 spin_unlock_bh(&sc->wiphy_lock);
1676
Luis R. Rodriguez64839172009-07-14 20:22:53 -04001677 if (disable_radio) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001678 ath_print(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
Vivek Natarajan1dbfd9d2010-01-29 16:56:51 +05301679 sc->ps_idle = true;
Luis R. Rodriguez68a89112009-11-02 14:35:42 -08001680 ath_radio_disable(sc, hw);
Luis R. Rodriguez64839172009-07-14 20:22:53 -04001681 }
1682
Sujithaa33de02008-12-18 11:40:16 +05301683 mutex_unlock(&sc->mutex);
Sujith141b38b2009-02-04 08:10:07 +05301684
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001685 return 0;
1686}
1687
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001688#define SUPPORTED_FILTERS \
1689 (FIF_PROMISC_IN_BSS | \
1690 FIF_ALLMULTI | \
1691 FIF_CONTROL | \
Luis R. Rodriguezaf6a3fc2009-08-08 21:55:16 -04001692 FIF_PSPOLL | \
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001693 FIF_OTHER_BSS | \
1694 FIF_BCN_PRBRESP_PROMISC | \
Jouni Malinen9c1d8e42010-10-13 17:29:31 +03001695 FIF_PROBE_REQ | \
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001696 FIF_FCSFAIL)
1697
Sujith7dcfdcd2008-08-11 14:03:13 +05301698/* FIXME: sc->sc_full_reset ? */
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001699static void ath9k_configure_filter(struct ieee80211_hw *hw,
1700 unsigned int changed_flags,
1701 unsigned int *total_flags,
Johannes Berg3ac64be2009-08-17 16:16:53 +02001702 u64 multicast)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001703{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001704 struct ath_wiphy *aphy = hw->priv;
1705 struct ath_softc *sc = aphy->sc;
Sujith7dcfdcd2008-08-11 14:03:13 +05301706 u32 rfilt;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001707
1708 changed_flags &= SUPPORTED_FILTERS;
1709 *total_flags &= SUPPORTED_FILTERS;
1710
Sujithb77f4832008-12-07 21:44:03 +05301711 sc->rx.rxfilter = *total_flags;
Jouni Malinenaa68aea2009-05-19 17:01:41 +03001712 ath9k_ps_wakeup(sc);
Sujith7dcfdcd2008-08-11 14:03:13 +05301713 rfilt = ath_calcrxfilter(sc);
1714 ath9k_hw_setrxfilter(sc->sc_ah, rfilt);
Jouni Malinenaa68aea2009-05-19 17:01:41 +03001715 ath9k_ps_restore(sc);
Sujith7dcfdcd2008-08-11 14:03:13 +05301716
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001717 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
1718 "Set HW RX filter: 0x%x\n", rfilt);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001719}
1720
Johannes Berg4ca77862010-02-19 19:06:56 +01001721static int ath9k_sta_add(struct ieee80211_hw *hw,
1722 struct ieee80211_vif *vif,
1723 struct ieee80211_sta *sta)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001724{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001725 struct ath_wiphy *aphy = hw->priv;
1726 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001727
Johannes Berg4ca77862010-02-19 19:06:56 +01001728 ath_node_attach(sc, sta);
1729
1730 return 0;
1731}
1732
1733static int ath9k_sta_remove(struct ieee80211_hw *hw,
1734 struct ieee80211_vif *vif,
1735 struct ieee80211_sta *sta)
1736{
1737 struct ath_wiphy *aphy = hw->priv;
1738 struct ath_softc *sc = aphy->sc;
1739
1740 ath_node_detach(sc, sta);
1741
1742 return 0;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001743}
1744
Sujith141b38b2009-02-04 08:10:07 +05301745static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001746 const struct ieee80211_tx_queue_params *params)
1747{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001748 struct ath_wiphy *aphy = hw->priv;
1749 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001750 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Felix Fietkau066dae92010-11-07 14:59:39 +01001751 struct ath_txq *txq;
Sujithea9880f2008-08-07 10:53:10 +05301752 struct ath9k_tx_queue_info qi;
Felix Fietkau066dae92010-11-07 14:59:39 +01001753 int ret = 0;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001754
1755 if (queue >= WME_NUM_AC)
1756 return 0;
1757
Felix Fietkau066dae92010-11-07 14:59:39 +01001758 txq = sc->tx.txq_map[queue];
1759
Sujith141b38b2009-02-04 08:10:07 +05301760 mutex_lock(&sc->mutex);
1761
Sujith1ffb0612009-03-30 15:28:46 +05301762 memset(&qi, 0, sizeof(struct ath9k_tx_queue_info));
1763
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001764 qi.tqi_aifs = params->aifs;
1765 qi.tqi_cwmin = params->cw_min;
1766 qi.tqi_cwmax = params->cw_max;
1767 qi.tqi_burstTime = params->txop;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001768
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001769 ath_print(common, ATH_DBG_CONFIG,
1770 "Configure tx [queue/halq] [%d/%d], "
1771 "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n",
Felix Fietkau066dae92010-11-07 14:59:39 +01001772 queue, txq->axq_qnum, params->aifs, params->cw_min,
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001773 params->cw_max, params->txop);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001774
Felix Fietkau066dae92010-11-07 14:59:39 +01001775 ret = ath_txq_update(sc, txq->axq_qnum, &qi);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001776 if (ret)
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001777 ath_print(common, ATH_DBG_FATAL, "TXQ Update failed\n");
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001778
Vivek Natarajan94db2932009-11-25 12:01:54 +05301779 if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)
Felix Fietkau066dae92010-11-07 14:59:39 +01001780 if (queue == WME_AC_BE && !ret)
Vivek Natarajan94db2932009-11-25 12:01:54 +05301781 ath_beaconq_config(sc);
1782
Sujith141b38b2009-02-04 08:10:07 +05301783 mutex_unlock(&sc->mutex);
1784
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001785 return ret;
1786}
1787
1788static int ath9k_set_key(struct ieee80211_hw *hw,
1789 enum set_key_cmd cmd,
Johannes Bergdc822b52008-12-29 12:55:09 +01001790 struct ieee80211_vif *vif,
1791 struct ieee80211_sta *sta,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001792 struct ieee80211_key_conf *key)
1793{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001794 struct ath_wiphy *aphy = hw->priv;
1795 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001796 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001797 int ret = 0;
1798
Jouni Malinenb3bd89c2009-02-24 13:42:01 +02001799 if (modparam_nohwcrypt)
1800 return -ENOSPC;
1801
Sujith141b38b2009-02-04 08:10:07 +05301802 mutex_lock(&sc->mutex);
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +05301803 ath9k_ps_wakeup(sc);
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001804 ath_print(common, ATH_DBG_CONFIG, "Set HW Key\n");
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001805
1806 switch (cmd) {
1807 case SET_KEY:
Bruno Randolf040e5392010-09-08 16:05:04 +09001808 ret = ath_key_config(common, vif, sta, key);
Jouni Malinen6ace2892008-12-17 13:32:17 +02001809 if (ret >= 0) {
1810 key->hw_key_idx = ret;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001811 /* push IV and Michael MIC generation to stack */
1812 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
Johannes Berg97359d12010-08-10 09:46:38 +02001813 if (key->cipher == WLAN_CIPHER_SUITE_TKIP)
Senthil Balasubramanian1b961752008-09-01 19:45:21 +05301814 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
Johannes Berg97359d12010-08-10 09:46:38 +02001815 if (sc->sc_ah->sw_mgmt_crypto &&
1816 key->cipher == WLAN_CIPHER_SUITE_CCMP)
Jouni Malinen0ced0e12009-01-08 13:32:13 +02001817 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT;
Jouni Malinen6ace2892008-12-17 13:32:17 +02001818 ret = 0;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001819 }
1820 break;
1821 case DISABLE_KEY:
Bruno Randolf040e5392010-09-08 16:05:04 +09001822 ath_key_delete(common, key);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001823 break;
1824 default:
1825 ret = -EINVAL;
1826 }
1827
Vivek Natarajan3cbb5dd2009-01-20 11:17:08 +05301828 ath9k_ps_restore(sc);
Sujith141b38b2009-02-04 08:10:07 +05301829 mutex_unlock(&sc->mutex);
1830
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001831 return ret;
1832}
1833
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001834static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1835 struct ieee80211_vif *vif,
1836 struct ieee80211_bss_conf *bss_conf,
1837 u32 changed)
1838{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001839 struct ath_wiphy *aphy = hw->priv;
1840 struct ath_softc *sc = aphy->sc;
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001841 struct ath_hw *ah = sc->sc_ah;
Luis R. Rodriguez15107182009-09-10 09:22:37 -07001842 struct ath_common *common = ath9k_hw_common(ah);
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001843 struct ath_vif *avp = (void *)vif->drv_priv;
Felix Fietkau0005baf2010-01-15 02:33:40 +01001844 int slottime;
Sujithc6089cc2009-11-16 11:40:48 +05301845 int error;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001846
Sujith141b38b2009-02-04 08:10:07 +05301847 mutex_lock(&sc->mutex);
1848
Sujithc6089cc2009-11-16 11:40:48 +05301849 if (changed & BSS_CHANGED_BSSID) {
1850 /* Set BSSID */
1851 memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
1852 memcpy(avp->bssid, bss_conf->bssid, ETH_ALEN);
Luis R. Rodriguez15107182009-09-10 09:22:37 -07001853 common->curaid = 0;
Luis R. Rodriguezf2b21432009-09-10 08:50:20 -07001854 ath9k_hw_write_associd(ah);
Sujithc6089cc2009-11-16 11:40:48 +05301855
1856 /* Set aggregation protection mode parameters */
1857 sc->config.ath_aggr_prot = 0;
1858
1859 /* Only legacy IBSS for now */
1860 if (vif->type == NL80211_IFTYPE_ADHOC)
1861 ath_update_chainmask(sc, 0);
1862
1863 ath_print(common, ATH_DBG_CONFIG,
1864 "BSSID: %pM aid: 0x%x\n",
1865 common->curbssid, common->curaid);
1866
1867 /* need to reconfigure the beacon */
1868 sc->sc_flags &= ~SC_OP_BEACONS ;
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001869 }
1870
Sujithc6089cc2009-11-16 11:40:48 +05301871 /* Enable transmission of beacons (AP, IBSS, MESH) */
1872 if ((changed & BSS_CHANGED_BEACON) ||
1873 ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon)) {
1874 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
1875 error = ath_beacon_alloc(aphy, vif);
1876 if (!error)
1877 ath_beacon_config(sc, vif);
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001878 }
1879
Felix Fietkau0005baf2010-01-15 02:33:40 +01001880 if (changed & BSS_CHANGED_ERP_SLOT) {
1881 if (bss_conf->use_short_slot)
1882 slottime = 9;
1883 else
1884 slottime = 20;
1885 if (vif->type == NL80211_IFTYPE_AP) {
1886 /*
1887 * Defer update, so that connected stations can adjust
1888 * their settings at the same time.
1889 * See beacon.c for more details
1890 */
1891 sc->beacon.slottime = slottime;
1892 sc->beacon.updateslot = UPDATE;
1893 } else {
1894 ah->slottime = slottime;
1895 ath9k_hw_init_global_settings(ah);
1896 }
1897 }
1898
Sujithc6089cc2009-11-16 11:40:48 +05301899 /* Disable transmission of beacons */
1900 if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon)
1901 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
1902
1903 if (changed & BSS_CHANGED_BEACON_INT) {
1904 sc->beacon_interval = bss_conf->beacon_int;
1905 /*
1906 * In case of AP mode, the HW TSF has to be reset
1907 * when the beacon interval changes.
1908 */
1909 if (vif->type == NL80211_IFTYPE_AP) {
1910 sc->sc_flags |= SC_OP_TSF_RESET;
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001911 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001912 error = ath_beacon_alloc(aphy, vif);
1913 if (!error)
1914 ath_beacon_config(sc, vif);
Sujithc6089cc2009-11-16 11:40:48 +05301915 } else {
1916 ath_beacon_config(sc, vif);
Johannes Berg2d0ddec2009-04-23 16:13:26 +02001917 }
1918 }
1919
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001920 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001921 ath_print(common, ATH_DBG_CONFIG, "BSS Changed PREAMBLE %d\n",
1922 bss_conf->use_short_preamble);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001923 if (bss_conf->use_short_preamble)
Sujith672840a2008-08-11 14:05:08 +05301924 sc->sc_flags |= SC_OP_PREAMBLE_SHORT;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001925 else
Sujith672840a2008-08-11 14:05:08 +05301926 sc->sc_flags &= ~SC_OP_PREAMBLE_SHORT;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001927 }
1928
1929 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001930 ath_print(common, ATH_DBG_CONFIG, "BSS Changed CTS PROT %d\n",
1931 bss_conf->use_cts_prot);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001932 if (bss_conf->use_cts_prot &&
1933 hw->conf.channel->band != IEEE80211_BAND_5GHZ)
Sujith672840a2008-08-11 14:05:08 +05301934 sc->sc_flags |= SC_OP_PROTECT_ENABLE;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001935 else
Sujith672840a2008-08-11 14:05:08 +05301936 sc->sc_flags &= ~SC_OP_PROTECT_ENABLE;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001937 }
1938
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001939 if (changed & BSS_CHANGED_ASSOC) {
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07001940 ath_print(common, ATH_DBG_CONFIG, "BSS Changed ASSOC %d\n",
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001941 bss_conf->assoc);
Felix Fietkau9fa23e12010-10-15 20:03:31 +02001942 ath9k_bss_assoc_info(sc, hw, vif, bss_conf);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001943 }
Sujith141b38b2009-02-04 08:10:07 +05301944
1945 mutex_unlock(&sc->mutex);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001946}
1947
1948static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
1949{
1950 u64 tsf;
Jouni Malinenbce048d2009-03-03 19:23:28 +02001951 struct ath_wiphy *aphy = hw->priv;
1952 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001953
Sujith141b38b2009-02-04 08:10:07 +05301954 mutex_lock(&sc->mutex);
1955 tsf = ath9k_hw_gettsf64(sc->sc_ah);
1956 mutex_unlock(&sc->mutex);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001957
1958 return tsf;
1959}
1960
Alina Friedrichsen3b5d6652009-01-24 07:09:59 +01001961static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
1962{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001963 struct ath_wiphy *aphy = hw->priv;
1964 struct ath_softc *sc = aphy->sc;
Alina Friedrichsen3b5d6652009-01-24 07:09:59 +01001965
Sujith141b38b2009-02-04 08:10:07 +05301966 mutex_lock(&sc->mutex);
1967 ath9k_hw_settsf64(sc->sc_ah, tsf);
1968 mutex_unlock(&sc->mutex);
Alina Friedrichsen3b5d6652009-01-24 07:09:59 +01001969}
1970
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001971static void ath9k_reset_tsf(struct ieee80211_hw *hw)
1972{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001973 struct ath_wiphy *aphy = hw->priv;
1974 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001975
Sujith141b38b2009-02-04 08:10:07 +05301976 mutex_lock(&sc->mutex);
Luis R. Rodriguez21526d52009-09-09 20:05:39 -07001977
1978 ath9k_ps_wakeup(sc);
Sujith141b38b2009-02-04 08:10:07 +05301979 ath9k_hw_reset_tsf(sc->sc_ah);
Luis R. Rodriguez21526d52009-09-09 20:05:39 -07001980 ath9k_ps_restore(sc);
1981
Sujith141b38b2009-02-04 08:10:07 +05301982 mutex_unlock(&sc->mutex);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001983}
1984
1985static int ath9k_ampdu_action(struct ieee80211_hw *hw,
Johannes Bergc951ad32009-11-16 12:00:38 +01001986 struct ieee80211_vif *vif,
Sujith141b38b2009-02-04 08:10:07 +05301987 enum ieee80211_ampdu_mlme_action action,
1988 struct ieee80211_sta *sta,
1989 u16 tid, u16 *ssn)
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001990{
Jouni Malinenbce048d2009-03-03 19:23:28 +02001991 struct ath_wiphy *aphy = hw->priv;
1992 struct ath_softc *sc = aphy->sc;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001993 int ret = 0;
1994
Johannes Berg85ad1812010-06-10 10:21:49 +02001995 local_bh_disable();
1996
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07001997 switch (action) {
1998 case IEEE80211_AMPDU_RX_START:
Sujithdca3edb2008-10-29 10:19:01 +05301999 if (!(sc->sc_flags & SC_OP_RXAGGR))
2000 ret = -ENOTSUPP;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002001 break;
2002 case IEEE80211_AMPDU_RX_STOP:
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002003 break;
2004 case IEEE80211_AMPDU_TX_START:
Luis R. Rodriguez8b685ba2009-12-23 20:03:29 -05002005 ath9k_ps_wakeup(sc);
Felix Fietkau231c3a12010-09-20 19:35:28 +02002006 ret = ath_tx_aggr_start(sc, sta, tid, ssn);
2007 if (!ret)
2008 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
Luis R. Rodriguez8b685ba2009-12-23 20:03:29 -05002009 ath9k_ps_restore(sc);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002010 break;
2011 case IEEE80211_AMPDU_TX_STOP:
Luis R. Rodriguez8b685ba2009-12-23 20:03:29 -05002012 ath9k_ps_wakeup(sc);
Sujithf83da962009-07-23 15:32:37 +05302013 ath_tx_aggr_stop(sc, sta, tid);
Johannes Bergc951ad32009-11-16 12:00:38 +01002014 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
Luis R. Rodriguez8b685ba2009-12-23 20:03:29 -05002015 ath9k_ps_restore(sc);
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002016 break;
Johannes Bergb1720232009-03-23 17:28:39 +01002017 case IEEE80211_AMPDU_TX_OPERATIONAL:
Luis R. Rodriguez8b685ba2009-12-23 20:03:29 -05002018 ath9k_ps_wakeup(sc);
Sujith8469cde2008-10-29 10:19:28 +05302019 ath_tx_aggr_resume(sc, sta, tid);
Luis R. Rodriguez8b685ba2009-12-23 20:03:29 -05002020 ath9k_ps_restore(sc);
Sujith8469cde2008-10-29 10:19:28 +05302021 break;
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002022 default:
Luis R. Rodriguezc46917b2009-09-13 02:42:02 -07002023 ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
2024 "Unknown AMPDU action\n");
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002025 }
2026
Johannes Berg85ad1812010-06-10 10:21:49 +02002027 local_bh_enable();
2028
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002029 return ret;
2030}
2031
Benoit Papillault62dad5b2010-04-28 00:08:24 +02002032static int ath9k_get_survey(struct ieee80211_hw *hw, int idx,
2033 struct survey_info *survey)
2034{
2035 struct ath_wiphy *aphy = hw->priv;
2036 struct ath_softc *sc = aphy->sc;
Felix Fietkau34300982010-10-10 18:21:52 +02002037 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
Felix Fietkau39162db2010-09-29 19:12:06 +02002038 struct ieee80211_supported_band *sband;
Felix Fietkau34300982010-10-10 18:21:52 +02002039 struct ieee80211_channel *chan;
2040 unsigned long flags;
2041 int pos;
2042
2043 spin_lock_irqsave(&common->cc_lock, flags);
2044 if (idx == 0)
2045 ath_update_survey_stats(sc);
Benoit Papillault62dad5b2010-04-28 00:08:24 +02002046
Felix Fietkau39162db2010-09-29 19:12:06 +02002047 sband = hw->wiphy->bands[IEEE80211_BAND_2GHZ];
2048 if (sband && idx >= sband->n_channels) {
2049 idx -= sband->n_channels;
2050 sband = NULL;
2051 }
Benoit Papillault62dad5b2010-04-28 00:08:24 +02002052
Felix Fietkau39162db2010-09-29 19:12:06 +02002053 if (!sband)
2054 sband = hw->wiphy->bands[IEEE80211_BAND_5GHZ];
2055
Felix Fietkau34300982010-10-10 18:21:52 +02002056 if (!sband || idx >= sband->n_channels) {
2057 spin_unlock_irqrestore(&common->cc_lock, flags);
2058 return -ENOENT;
Felix Fietkau4f1a5a42010-09-29 17:15:28 +02002059 }
Benoit Papillault62dad5b2010-04-28 00:08:24 +02002060
Felix Fietkau34300982010-10-10 18:21:52 +02002061 chan = &sband->channels[idx];
2062 pos = chan->hw_value;
2063 memcpy(survey, &sc->survey[pos], sizeof(*survey));
2064 survey->channel = chan;
2065 spin_unlock_irqrestore(&common->cc_lock, flags);
2066
Benoit Papillault62dad5b2010-04-28 00:08:24 +02002067 return 0;
2068}
2069
Sujith0c98de62009-03-03 10:16:45 +05302070static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2071{
Jouni Malinenbce048d2009-03-03 19:23:28 +02002072 struct ath_wiphy *aphy = hw->priv;
2073 struct ath_softc *sc = aphy->sc;
Sujith0c98de62009-03-03 10:16:45 +05302074
Sujith3d832612009-08-21 12:00:28 +05302075 mutex_lock(&sc->mutex);
Jouni Malinen8089cc42009-03-03 19:23:38 +02002076 if (ath9k_wiphy_scanning(sc)) {
Jouni Malinen8089cc42009-03-03 19:23:38 +02002077 /*
Luis R. Rodriguez30888332010-07-27 16:33:06 -04002078 * There is a race here in mac80211 but fixing it requires
2079 * we revisit how we handle the scan complete callback.
2080 * After mac80211 fixes we will not have configured hardware
2081 * to the home channel nor would we have configured the RX
2082 * filter yet.
Jouni Malinen8089cc42009-03-03 19:23:38 +02002083 */
Sujith3d832612009-08-21 12:00:28 +05302084 mutex_unlock(&sc->mutex);
Jouni Malinen8089cc42009-03-03 19:23:38 +02002085 return;
2086 }
2087
2088 aphy->state = ATH_WIPHY_SCAN;
2089 ath9k_wiphy_pause_all_forced(sc, aphy);
Sujith3d832612009-08-21 12:00:28 +05302090 mutex_unlock(&sc->mutex);
Sujith0c98de62009-03-03 10:16:45 +05302091}
2092
Luis R. Rodriguez30888332010-07-27 16:33:06 -04002093/*
2094 * XXX: this requires a revisit after the driver
2095 * scan_complete gets moved to another place/removed in mac80211.
2096 */
Sujith0c98de62009-03-03 10:16:45 +05302097static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
2098{
Jouni Malinenbce048d2009-03-03 19:23:28 +02002099 struct ath_wiphy *aphy = hw->priv;
2100 struct ath_softc *sc = aphy->sc;
Sujith0c98de62009-03-03 10:16:45 +05302101
Sujith3d832612009-08-21 12:00:28 +05302102 mutex_lock(&sc->mutex);
Jouni Malinen8089cc42009-03-03 19:23:38 +02002103 aphy->state = ATH_WIPHY_ACTIVE;
Sujith3d832612009-08-21 12:00:28 +05302104 mutex_unlock(&sc->mutex);
Sujith0c98de62009-03-03 10:16:45 +05302105}
2106
Felix Fietkaue239d852010-01-15 02:34:58 +01002107static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
2108{
2109 struct ath_wiphy *aphy = hw->priv;
2110 struct ath_softc *sc = aphy->sc;
2111 struct ath_hw *ah = sc->sc_ah;
2112
2113 mutex_lock(&sc->mutex);
2114 ah->coverage_class = coverage_class;
2115 ath9k_hw_init_global_settings(ah);
2116 mutex_unlock(&sc->mutex);
2117}
2118
Gabor Juhos6baff7f2009-01-14 20:17:06 +01002119struct ieee80211_ops ath9k_ops = {
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002120 .tx = ath9k_tx,
2121 .start = ath9k_start,
2122 .stop = ath9k_stop,
2123 .add_interface = ath9k_add_interface,
2124 .remove_interface = ath9k_remove_interface,
2125 .config = ath9k_config,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002126 .configure_filter = ath9k_configure_filter,
Johannes Berg4ca77862010-02-19 19:06:56 +01002127 .sta_add = ath9k_sta_add,
2128 .sta_remove = ath9k_sta_remove,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002129 .conf_tx = ath9k_conf_tx,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002130 .bss_info_changed = ath9k_bss_info_changed,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002131 .set_key = ath9k_set_key,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002132 .get_tsf = ath9k_get_tsf,
Alina Friedrichsen3b5d6652009-01-24 07:09:59 +01002133 .set_tsf = ath9k_set_tsf,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002134 .reset_tsf = ath9k_reset_tsf,
Johannes Berg4233df62008-10-13 13:35:05 +02002135 .ampdu_action = ath9k_ampdu_action,
Benoit Papillault62dad5b2010-04-28 00:08:24 +02002136 .get_survey = ath9k_get_survey,
Sujith0c98de62009-03-03 10:16:45 +05302137 .sw_scan_start = ath9k_sw_scan_start,
2138 .sw_scan_complete = ath9k_sw_scan_complete,
Johannes Berg3b319aa2009-06-13 14:50:26 +05302139 .rfkill_poll = ath9k_rfkill_poll_state,
Felix Fietkaue239d852010-01-15 02:34:58 +01002140 .set_coverage_class = ath9k_set_coverage_class,
Luis R. Rodriguezf078f202008-08-04 00:16:41 -07002141};