Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1 | /* |
Sujith Manoharan | 5b68138 | 2011-05-17 13:36:18 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2011 Atheros Communications Inc. |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 3 | * |
| 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. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 17 | #include <linux/nl80211.h> |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 18 | #include <linux/delay.h> |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 19 | #include "ath9k.h" |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 20 | #include "btcoex.h" |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 21 | |
Sven Eckelmann | 313eb87 | 2012-06-25 07:15:22 +0200 | [diff] [blame] | 22 | u8 ath9k_parse_mpdudensity(u8 mpdudensity) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 23 | { |
| 24 | /* |
| 25 | * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing": |
| 26 | * 0 for no restriction |
| 27 | * 1 for 1/4 us |
| 28 | * 2 for 1/2 us |
| 29 | * 3 for 1 us |
| 30 | * 4 for 2 us |
| 31 | * 5 for 4 us |
| 32 | * 6 for 8 us |
| 33 | * 7 for 16 us |
| 34 | */ |
| 35 | switch (mpdudensity) { |
| 36 | case 0: |
| 37 | return 0; |
| 38 | case 1: |
| 39 | case 2: |
| 40 | case 3: |
| 41 | /* Our lower layer calculations limit our precision to |
| 42 | 1 microsecond */ |
| 43 | return 1; |
| 44 | case 4: |
| 45 | return 2; |
| 46 | case 5: |
| 47 | return 4; |
| 48 | case 6: |
| 49 | return 8; |
| 50 | case 7: |
| 51 | return 16; |
| 52 | default: |
| 53 | return 0; |
| 54 | } |
| 55 | } |
| 56 | |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 57 | static bool ath9k_has_pending_frames(struct ath_softc *sc, struct ath_txq *txq) |
| 58 | { |
| 59 | bool pending = false; |
| 60 | |
| 61 | spin_lock_bh(&txq->axq_lock); |
| 62 | |
Felix Fietkau | 0453531 | 2014-06-11 16:17:51 +0530 | [diff] [blame] | 63 | if (txq->axq_depth) |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 64 | pending = true; |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 65 | |
Felix Fietkau | 0453531 | 2014-06-11 16:17:51 +0530 | [diff] [blame] | 66 | if (txq->mac80211_qnum >= 0) { |
| 67 | struct list_head *list; |
| 68 | |
| 69 | list = &sc->cur_chan->acq[txq->mac80211_qnum]; |
| 70 | if (!list_empty(list)) |
| 71 | pending = true; |
| 72 | } |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 73 | spin_unlock_bh(&txq->axq_lock); |
| 74 | return pending; |
| 75 | } |
| 76 | |
Mohammed Shafi Shajakhan | 6d79cb4 | 2011-05-19 17:40:46 +0530 | [diff] [blame] | 77 | static bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode) |
Luis R. Rodriguez | 8c77a56 | 2009-09-09 21:02:34 -0700 | [diff] [blame] | 78 | { |
| 79 | unsigned long flags; |
| 80 | bool ret; |
| 81 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 82 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 83 | ret = ath9k_hw_setpower(sc->sc_ah, mode); |
| 84 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
Luis R. Rodriguez | 8c77a56 | 2009-09-09 21:02:34 -0700 | [diff] [blame] | 85 | |
| 86 | return ret; |
| 87 | } |
| 88 | |
Felix Fietkau | bf3dac5 | 2013-11-11 22:23:33 +0100 | [diff] [blame] | 89 | void ath_ps_full_sleep(unsigned long data) |
| 90 | { |
| 91 | struct ath_softc *sc = (struct ath_softc *) data; |
| 92 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 93 | bool reset; |
| 94 | |
| 95 | spin_lock(&common->cc_lock); |
| 96 | ath_hw_cycle_counters_update(common); |
| 97 | spin_unlock(&common->cc_lock); |
| 98 | |
| 99 | ath9k_hw_setrxabort(sc->sc_ah, 1); |
| 100 | ath9k_hw_stopdmarecv(sc->sc_ah, &reset); |
| 101 | |
| 102 | ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP); |
| 103 | } |
| 104 | |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 105 | void ath9k_ps_wakeup(struct ath_softc *sc) |
| 106 | { |
Felix Fietkau | 898c914 | 2010-10-12 14:02:53 +0200 | [diff] [blame] | 107 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 108 | unsigned long flags; |
Felix Fietkau | fbb078f | 2010-11-03 01:36:51 +0100 | [diff] [blame] | 109 | enum ath9k_power_mode power_mode; |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 110 | |
| 111 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 112 | if (++sc->ps_usecount != 1) |
| 113 | goto unlock; |
| 114 | |
Felix Fietkau | bf3dac5 | 2013-11-11 22:23:33 +0100 | [diff] [blame] | 115 | del_timer_sync(&sc->sleep_timer); |
Felix Fietkau | fbb078f | 2010-11-03 01:36:51 +0100 | [diff] [blame] | 116 | power_mode = sc->sc_ah->power_mode; |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 117 | ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE); |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 118 | |
Felix Fietkau | 898c914 | 2010-10-12 14:02:53 +0200 | [diff] [blame] | 119 | /* |
| 120 | * While the hardware is asleep, the cycle counters contain no |
| 121 | * useful data. Better clear them now so that they don't mess up |
| 122 | * survey data results. |
| 123 | */ |
Felix Fietkau | fbb078f | 2010-11-03 01:36:51 +0100 | [diff] [blame] | 124 | if (power_mode != ATH9K_PM_AWAKE) { |
| 125 | spin_lock(&common->cc_lock); |
| 126 | ath_hw_cycle_counters_update(common); |
| 127 | memset(&common->cc_survey, 0, sizeof(common->cc_survey)); |
Rajkumar Manoharan | c9ae6ab | 2012-06-04 16:28:41 +0530 | [diff] [blame] | 128 | memset(&common->cc_ani, 0, sizeof(common->cc_ani)); |
Felix Fietkau | fbb078f | 2010-11-03 01:36:51 +0100 | [diff] [blame] | 129 | spin_unlock(&common->cc_lock); |
| 130 | } |
Felix Fietkau | 898c914 | 2010-10-12 14:02:53 +0200 | [diff] [blame] | 131 | |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 132 | unlock: |
| 133 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
| 134 | } |
| 135 | |
| 136 | void ath9k_ps_restore(struct ath_softc *sc) |
| 137 | { |
Felix Fietkau | 898c914 | 2010-10-12 14:02:53 +0200 | [diff] [blame] | 138 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | c6c539f | 2011-09-14 21:24:24 +0200 | [diff] [blame] | 139 | enum ath9k_power_mode mode; |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 140 | unsigned long flags; |
| 141 | |
| 142 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 143 | if (--sc->ps_usecount != 0) |
| 144 | goto unlock; |
| 145 | |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 146 | if (sc->ps_idle) { |
Felix Fietkau | bf3dac5 | 2013-11-11 22:23:33 +0100 | [diff] [blame] | 147 | mod_timer(&sc->sleep_timer, jiffies + HZ / 10); |
| 148 | goto unlock; |
| 149 | } |
| 150 | |
| 151 | if (sc->ps_enabled && |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 152 | !(sc->ps_flags & (PS_WAIT_FOR_BEACON | |
| 153 | PS_WAIT_FOR_CAB | |
| 154 | PS_WAIT_FOR_PSPOLL_DATA | |
Rajkumar Manoharan | 424749c | 2012-10-10 23:03:02 +0530 | [diff] [blame] | 155 | PS_WAIT_FOR_TX_ACK | |
| 156 | PS_WAIT_FOR_ANI))) { |
Felix Fietkau | c6c539f | 2011-09-14 21:24:24 +0200 | [diff] [blame] | 157 | mode = ATH9K_PM_NETWORK_SLEEP; |
Rajkumar Manoharan | 08d4df4 | 2012-07-01 19:53:54 +0530 | [diff] [blame] | 158 | if (ath9k_hw_btcoex_is_enabled(sc->sc_ah)) |
| 159 | ath9k_btcoex_stop_gen_timer(sc); |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 160 | } else { |
Felix Fietkau | c6c539f | 2011-09-14 21:24:24 +0200 | [diff] [blame] | 161 | goto unlock; |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 162 | } |
Felix Fietkau | c6c539f | 2011-09-14 21:24:24 +0200 | [diff] [blame] | 163 | |
| 164 | spin_lock(&common->cc_lock); |
| 165 | ath_hw_cycle_counters_update(common); |
| 166 | spin_unlock(&common->cc_lock); |
| 167 | |
Felix Fietkau | 1a8f0d39 | 2011-09-22 08:04:32 -0600 | [diff] [blame] | 168 | ath9k_hw_setpower(sc->sc_ah, mode); |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 169 | |
| 170 | unlock: |
| 171 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
| 172 | } |
| 173 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 174 | static void __ath_cancel_work(struct ath_softc *sc) |
| 175 | { |
| 176 | cancel_work_sync(&sc->paprd_work); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 177 | cancel_delayed_work_sync(&sc->tx_complete_work); |
| 178 | cancel_delayed_work_sync(&sc->hw_pll_work); |
Sujith Manoharan | fad29cd | 2012-06-25 13:54:22 +0530 | [diff] [blame] | 179 | |
Sujith Manoharan | bf52592 | 2012-06-27 14:15:59 +0530 | [diff] [blame] | 180 | #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT |
Sujith Manoharan | fad29cd | 2012-06-25 13:54:22 +0530 | [diff] [blame] | 181 | if (ath9k_hw_mci_is_enabled(sc->sc_ah)) |
| 182 | cancel_work_sync(&sc->mci_work); |
Sujith Manoharan | bf52592 | 2012-06-27 14:15:59 +0530 | [diff] [blame] | 183 | #endif |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 184 | } |
| 185 | |
Sujith Manoharan | e60001e | 2013-10-28 12:22:04 +0530 | [diff] [blame] | 186 | void ath_cancel_work(struct ath_softc *sc) |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 187 | { |
| 188 | __ath_cancel_work(sc); |
| 189 | cancel_work_sync(&sc->hw_reset_work); |
| 190 | } |
| 191 | |
Sujith Manoharan | e60001e | 2013-10-28 12:22:04 +0530 | [diff] [blame] | 192 | void ath_restart_work(struct ath_softc *sc) |
Sujith Manoharan | af68aba | 2012-06-04 20:23:43 +0530 | [diff] [blame] | 193 | { |
Sujith Manoharan | af68aba | 2012-06-04 20:23:43 +0530 | [diff] [blame] | 194 | ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); |
| 195 | |
Sujith Manoharan | 19c3616 | 2013-08-20 10:05:59 +0530 | [diff] [blame] | 196 | if (AR_SREV_9340(sc->sc_ah) || AR_SREV_9330(sc->sc_ah)) |
Sujith Manoharan | af68aba | 2012-06-04 20:23:43 +0530 | [diff] [blame] | 197 | ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, |
| 198 | msecs_to_jiffies(ATH_PLL_WORK_INTERVAL)); |
| 199 | |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 200 | ath_start_ani(sc); |
Sujith Manoharan | af68aba | 2012-06-04 20:23:43 +0530 | [diff] [blame] | 201 | } |
| 202 | |
John W. Linville | 9ebea38 | 2013-01-28 13:54:03 -0500 | [diff] [blame] | 203 | static bool ath_prepare_reset(struct ath_softc *sc) |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 204 | { |
| 205 | struct ath_hw *ah = sc->sc_ah; |
Felix Fietkau | ceea2a5 | 2012-05-24 14:32:19 +0200 | [diff] [blame] | 206 | bool ret = true; |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 207 | |
| 208 | ieee80211_stop_queues(sc->hw); |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 209 | ath_stop_ani(sc); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 210 | ath9k_hw_disable_interrupts(ah); |
| 211 | |
Felix Fietkau | 1381559 | 2013-01-20 18:51:53 +0100 | [diff] [blame] | 212 | if (!ath_drain_all_txq(sc)) |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 213 | ret = false; |
| 214 | |
Felix Fietkau | 0a62acb | 2013-01-20 18:51:52 +0100 | [diff] [blame] | 215 | if (!ath_stoprecv(sc)) |
Felix Fietkau | ceea2a5 | 2012-05-24 14:32:19 +0200 | [diff] [blame] | 216 | ret = false; |
| 217 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 218 | return ret; |
| 219 | } |
| 220 | |
| 221 | static bool ath_complete_reset(struct ath_softc *sc, bool start) |
| 222 | { |
| 223 | struct ath_hw *ah = sc->sc_ah; |
| 224 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith Manoharan | 196fb86 | 2012-06-04 20:24:13 +0530 | [diff] [blame] | 225 | unsigned long flags; |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 226 | int i; |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 227 | |
| 228 | if (ath_startrecv(sc) != 0) { |
| 229 | ath_err(common, "Unable to restart recv logic\n"); |
| 230 | return false; |
| 231 | } |
| 232 | |
| 233 | ath9k_cmn_update_txpow(ah, sc->curtxpow, |
Felix Fietkau | bc7e1be | 2014-06-11 16:17:50 +0530 | [diff] [blame] | 234 | sc->cur_chan->txpower, &sc->curtxpow); |
Sujith Manoharan | b74713d | 2012-06-04 20:24:01 +0530 | [diff] [blame] | 235 | |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 236 | clear_bit(ATH_OP_HW_RESET, &common->op_flags); |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 237 | ath9k_calculate_summary_state(sc, sc->cur_chan); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 238 | |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 239 | if (!sc->cur_chan->offchannel && start) { |
Felix Fietkau | 8d7e09d | 2014-06-11 16:18:01 +0530 | [diff] [blame] | 240 | /* restore per chanctx TSF timer */ |
| 241 | if (sc->cur_chan->tsf_val) { |
| 242 | u32 offset; |
| 243 | |
| 244 | offset = ath9k_hw_get_tsf_offset(&sc->cur_chan->tsf_ts, |
| 245 | NULL); |
| 246 | ath9k_hw_settsf64(ah, sc->cur_chan->tsf_val + offset); |
| 247 | } |
| 248 | |
| 249 | |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 250 | if (!test_bit(ATH_OP_BEACONS, &common->op_flags)) |
Sujith Manoharan | 196fb86 | 2012-06-04 20:24:13 +0530 | [diff] [blame] | 251 | goto work; |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 252 | |
Sujith Manoharan | 196fb86 | 2012-06-04 20:24:13 +0530 | [diff] [blame] | 253 | if (ah->opmode == NL80211_IFTYPE_STATION && |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 254 | test_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags)) { |
Sujith Manoharan | 196fb86 | 2012-06-04 20:24:13 +0530 | [diff] [blame] | 255 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 256 | sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; |
| 257 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
Sujith Manoharan | a676828 | 2013-05-06 10:09:03 +0530 | [diff] [blame] | 258 | } else { |
| 259 | ath9k_set_beacon(sc); |
Sujith Manoharan | 196fb86 | 2012-06-04 20:24:13 +0530 | [diff] [blame] | 260 | } |
| 261 | work: |
Sujith Manoharan | af68aba | 2012-06-04 20:23:43 +0530 | [diff] [blame] | 262 | ath_restart_work(sc); |
Felix Fietkau | 0453531 | 2014-06-11 16:17:51 +0530 | [diff] [blame] | 263 | ath_txq_schedule_all(sc); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 264 | } |
| 265 | |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 266 | sc->gtt_cnt = 0; |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 267 | |
| 268 | ath9k_hw_set_interrupts(ah); |
| 269 | ath9k_hw_enable_interrupts(ah); |
| 270 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 271 | if (!ath9k_is_chanctx_enabled()) |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 272 | ieee80211_wake_queues(sc->hw); |
| 273 | else { |
| 274 | if (sc->cur_chan == &sc->offchannel.chan) |
| 275 | ieee80211_wake_queue(sc->hw, |
| 276 | sc->hw->offchannel_tx_hw_queue); |
| 277 | else { |
| 278 | for (i = 0; i < IEEE80211_NUM_ACS; i++) |
| 279 | ieee80211_wake_queue(sc->hw, |
| 280 | sc->cur_chan->hw_queue_base + i); |
| 281 | } |
| 282 | if (ah->opmode == NL80211_IFTYPE_AP) |
| 283 | ieee80211_wake_queue(sc->hw, sc->hw->queues - 2); |
| 284 | } |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 285 | |
Felix Fietkau | d463af4 | 2014-04-06 00:37:03 +0200 | [diff] [blame] | 286 | ath9k_p2p_ps_timer(sc); |
| 287 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 288 | return true; |
| 289 | } |
| 290 | |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 291 | int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan) |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 292 | { |
| 293 | struct ath_hw *ah = sc->sc_ah; |
| 294 | struct ath_common *common = ath9k_hw_common(ah); |
| 295 | struct ath9k_hw_cal_data *caldata = NULL; |
| 296 | bool fastcc = true; |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 297 | int r; |
| 298 | |
| 299 | __ath_cancel_work(sc); |
| 300 | |
Felix Fietkau | 4668cce | 2013-01-14 16:56:46 +0100 | [diff] [blame] | 301 | tasklet_disable(&sc->intr_tq); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 302 | spin_lock_bh(&sc->sc_pcu_lock); |
| 303 | |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 304 | if (!sc->cur_chan->offchannel) { |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 305 | fastcc = false; |
Felix Fietkau | b01459e | 2014-06-11 16:17:59 +0530 | [diff] [blame] | 306 | caldata = &sc->cur_chan->caldata; |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | if (!hchan) { |
| 310 | fastcc = false; |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 311 | hchan = ah->curchan; |
| 312 | } |
| 313 | |
John W. Linville | 9ebea38 | 2013-01-28 13:54:03 -0500 | [diff] [blame] | 314 | if (!ath_prepare_reset(sc)) |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 315 | fastcc = false; |
| 316 | |
Rajkumar Manoharan | d6067f0 | 2014-06-20 22:47:49 +0530 | [diff] [blame] | 317 | spin_lock_bh(&sc->chan_lock); |
| 318 | sc->cur_chandef = sc->cur_chan->chandef; |
| 319 | spin_unlock_bh(&sc->chan_lock); |
Felix Fietkau | bff1176 | 2014-06-11 16:17:52 +0530 | [diff] [blame] | 320 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 321 | ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n", |
Sujith Manoharan | feced20 | 2012-01-30 14:21:42 +0530 | [diff] [blame] | 322 | hchan->channel, IS_CHAN_HT40(hchan), fastcc); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 323 | |
| 324 | r = ath9k_hw_reset(ah, hchan, caldata, fastcc); |
| 325 | if (r) { |
| 326 | ath_err(common, |
| 327 | "Unable to reset channel, reset status %d\n", r); |
Robert Shade | f50b1cd | 2013-04-02 19:52:45 -0400 | [diff] [blame] | 328 | |
| 329 | ath9k_hw_enable_interrupts(ah); |
| 330 | ath9k_queue_reset(sc, RESET_TYPE_BB_HANG); |
| 331 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 332 | goto out; |
| 333 | } |
| 334 | |
Rajkumar Manoharan | e82cb03 | 2012-10-12 14:07:25 +0530 | [diff] [blame] | 335 | if (ath9k_hw_mci_is_enabled(sc->sc_ah) && |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 336 | sc->cur_chan->offchannel) |
Rajkumar Manoharan | e82cb03 | 2012-10-12 14:07:25 +0530 | [diff] [blame] | 337 | ath9k_mci_set_txpower(sc, true, false); |
| 338 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 339 | if (!ath_complete_reset(sc, true)) |
| 340 | r = -EIO; |
| 341 | |
| 342 | out: |
| 343 | spin_unlock_bh(&sc->sc_pcu_lock); |
Felix Fietkau | 4668cce | 2013-01-14 16:56:46 +0100 | [diff] [blame] | 344 | tasklet_enable(&sc->intr_tq); |
| 345 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 346 | return r; |
| 347 | } |
| 348 | |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 349 | static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, |
| 350 | struct ieee80211_vif *vif) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 351 | { |
| 352 | struct ath_node *an; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 353 | an = (struct ath_node *)sta->drv_priv; |
| 354 | |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 355 | an->sc = sc; |
Ben Greear | 7f010c9 | 2011-01-09 23:11:49 -0800 | [diff] [blame] | 356 | an->sta = sta; |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 357 | an->vif = vif; |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 358 | memset(&an->key_idx, 0, sizeof(an->key_idx)); |
Sujith Manoharan | 3d4e20f | 2012-03-14 14:40:58 +0530 | [diff] [blame] | 359 | |
Sujith Manoharan | dd5ee59 | 2013-02-04 15:38:23 +0530 | [diff] [blame] | 360 | ath_tx_node_init(sc, an); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta) |
| 364 | { |
| 365 | struct ath_node *an = (struct ath_node *)sta->drv_priv; |
Sujith Manoharan | dd5ee59 | 2013-02-04 15:38:23 +0530 | [diff] [blame] | 366 | ath_tx_node_cleanup(sc, an); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 367 | } |
| 368 | |
Sujith | 5562420 | 2010-01-08 10:36:02 +0530 | [diff] [blame] | 369 | void ath9k_tasklet(unsigned long data) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 370 | { |
| 371 | struct ath_softc *sc = (struct ath_softc *)data; |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 372 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 373 | struct ath_common *common = ath9k_hw_common(ah); |
Rajkumar Manoharan | 124b979 | 2012-07-17 17:16:42 +0530 | [diff] [blame] | 374 | enum ath_reset_type type; |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 375 | unsigned long flags; |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 376 | u32 status = sc->intrstatus; |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 377 | u32 rxmask; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 378 | |
Felix Fietkau | e392700 | 2011-09-14 21:23:01 +0200 | [diff] [blame] | 379 | ath9k_ps_wakeup(sc); |
| 380 | spin_lock(&sc->sc_pcu_lock); |
| 381 | |
Sujith Manoharan | 6549a86 | 2013-12-24 10:44:24 +0530 | [diff] [blame] | 382 | if (status & ATH9K_INT_FATAL) { |
| 383 | type = RESET_TYPE_FATAL_INT; |
Rajkumar Manoharan | 124b979 | 2012-07-17 17:16:42 +0530 | [diff] [blame] | 384 | ath9k_queue_reset(sc, type); |
Sujith Manoharan | c6cc47b | 2013-09-16 10:37:00 +0530 | [diff] [blame] | 385 | |
| 386 | /* |
| 387 | * Increment the ref. counter here so that |
| 388 | * interrupts are enabled in the reset routine. |
| 389 | */ |
| 390 | atomic_inc(&ah->intr_ref_cnt); |
Felix Fietkau | affad45 | 2014-02-22 14:52:49 +0100 | [diff] [blame] | 391 | ath_dbg(common, RESET, "FATAL: Skipping interrupts\n"); |
Felix Fietkau | e392700 | 2011-09-14 21:23:01 +0200 | [diff] [blame] | 392 | goto out; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 393 | } |
| 394 | |
Sujith Manoharan | 6549a86 | 2013-12-24 10:44:24 +0530 | [diff] [blame] | 395 | if ((ah->config.hw_hang_checks & HW_BB_WATCHDOG) && |
| 396 | (status & ATH9K_INT_BB_WATCHDOG)) { |
Sujith Manoharan | 0c75997 | 2013-12-24 10:44:26 +0530 | [diff] [blame] | 397 | spin_lock(&common->cc_lock); |
| 398 | ath_hw_cycle_counters_update(common); |
| 399 | ar9003_hw_bb_watchdog_dbg_info(ah); |
| 400 | spin_unlock(&common->cc_lock); |
| 401 | |
Sujith Manoharan | 6549a86 | 2013-12-24 10:44:24 +0530 | [diff] [blame] | 402 | if (ar9003_hw_bb_watchdog_check(ah)) { |
| 403 | type = RESET_TYPE_BB_WATCHDOG; |
| 404 | ath9k_queue_reset(sc, type); |
| 405 | |
| 406 | /* |
| 407 | * Increment the ref. counter here so that |
| 408 | * interrupts are enabled in the reset routine. |
| 409 | */ |
| 410 | atomic_inc(&ah->intr_ref_cnt); |
Felix Fietkau | affad45 | 2014-02-22 14:52:49 +0100 | [diff] [blame] | 411 | ath_dbg(common, RESET, |
Sujith Manoharan | 6549a86 | 2013-12-24 10:44:24 +0530 | [diff] [blame] | 412 | "BB_WATCHDOG: Skipping interrupts\n"); |
| 413 | goto out; |
| 414 | } |
| 415 | } |
| 416 | |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 417 | if (status & ATH9K_INT_GTT) { |
| 418 | sc->gtt_cnt++; |
| 419 | |
| 420 | if ((sc->gtt_cnt >= MAX_GTT_CNT) && !ath9k_hw_check_alive(ah)) { |
| 421 | type = RESET_TYPE_TX_GTT; |
| 422 | ath9k_queue_reset(sc, type); |
| 423 | atomic_inc(&ah->intr_ref_cnt); |
Felix Fietkau | affad45 | 2014-02-22 14:52:49 +0100 | [diff] [blame] | 424 | ath_dbg(common, RESET, |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 425 | "GTT: Skipping interrupts\n"); |
| 426 | goto out; |
| 427 | } |
| 428 | } |
| 429 | |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 430 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
Rajkumar Manoharan | 4105f80 | 2011-05-06 18:27:47 +0530 | [diff] [blame] | 431 | if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) { |
| 432 | /* |
| 433 | * TSF sync does not look correct; remain awake to sync with |
| 434 | * the next Beacon. |
| 435 | */ |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 436 | ath_dbg(common, PS, "TSFOOR - Sync with next Beacon\n"); |
Rajkumar Manoharan | e8fe733 | 2011-08-05 18:59:41 +0530 | [diff] [blame] | 437 | sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC; |
Rajkumar Manoharan | 4105f80 | 2011-05-06 18:27:47 +0530 | [diff] [blame] | 438 | } |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 439 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
Rajkumar Manoharan | 4105f80 | 2011-05-06 18:27:47 +0530 | [diff] [blame] | 440 | |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 441 | if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) |
| 442 | rxmask = (ATH9K_INT_RXHP | ATH9K_INT_RXLP | ATH9K_INT_RXEOL | |
| 443 | ATH9K_INT_RXORN); |
| 444 | else |
| 445 | rxmask = (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN); |
| 446 | |
| 447 | if (status & rxmask) { |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 448 | /* Check for high priority Rx first */ |
| 449 | if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) && |
| 450 | (status & ATH9K_INT_RXHP)) |
| 451 | ath_rx_tasklet(sc, 0, true); |
| 452 | |
| 453 | ath_rx_tasklet(sc, 0, false); |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 454 | } |
| 455 | |
Vasanthakumar Thiagarajan | e500324 | 2010-04-15 17:39:36 -0400 | [diff] [blame] | 456 | if (status & ATH9K_INT_TX) { |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 457 | if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) { |
| 458 | /* |
| 459 | * For EDMA chips, TX completion is enabled for the |
| 460 | * beacon queue, so if a beacon has been transmitted |
| 461 | * successfully after a GTT interrupt, the GTT counter |
| 462 | * gets reset to zero here. |
| 463 | */ |
Sujith Manoharan | 3b745c7 | 2014-01-20 13:25:28 +0530 | [diff] [blame] | 464 | sc->gtt_cnt = 0; |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 465 | |
Vasanthakumar Thiagarajan | e500324 | 2010-04-15 17:39:36 -0400 | [diff] [blame] | 466 | ath_tx_edma_tasklet(sc); |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 467 | } else { |
Vasanthakumar Thiagarajan | e500324 | 2010-04-15 17:39:36 -0400 | [diff] [blame] | 468 | ath_tx_tasklet(sc); |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 469 | } |
Felix Fietkau | 10e2318 | 2013-11-11 22:23:35 +0100 | [diff] [blame] | 470 | |
| 471 | wake_up(&sc->tx_wait); |
Vasanthakumar Thiagarajan | e500324 | 2010-04-15 17:39:36 -0400 | [diff] [blame] | 472 | } |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 473 | |
Felix Fietkau | c67ce33 | 2013-12-14 18:03:38 +0100 | [diff] [blame] | 474 | if (status & ATH9K_INT_GENTIMER) |
| 475 | ath_gen_timer_isr(sc->sc_ah); |
| 476 | |
Sujith Manoharan | 56ca0db | 2012-02-22 12:40:32 +0530 | [diff] [blame] | 477 | ath9k_btcoex_handle_interrupt(sc, status); |
Mohammed Shafi Shajakhan | 19686dd | 2011-11-30 10:41:28 +0530 | [diff] [blame] | 478 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 479 | /* re-enable hardware interrupt */ |
Felix Fietkau | 4df3071 | 2010-11-08 20:54:47 +0100 | [diff] [blame] | 480 | ath9k_hw_enable_interrupts(ah); |
Sujith Manoharan | c6cc47b | 2013-09-16 10:37:00 +0530 | [diff] [blame] | 481 | out: |
Senthil Balasubramanian | 52671e4 | 2010-12-23 21:06:57 +0530 | [diff] [blame] | 482 | spin_unlock(&sc->sc_pcu_lock); |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 483 | ath9k_ps_restore(sc); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 484 | } |
| 485 | |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 486 | irqreturn_t ath_isr(int irq, void *dev) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 487 | { |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 488 | #define SCHED_INTR ( \ |
| 489 | ATH9K_INT_FATAL | \ |
Rajkumar Manoharan | a4d86d9 | 2011-05-20 17:52:10 +0530 | [diff] [blame] | 490 | ATH9K_INT_BB_WATCHDOG | \ |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 491 | ATH9K_INT_RXORN | \ |
| 492 | ATH9K_INT_RXEOL | \ |
| 493 | ATH9K_INT_RX | \ |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 494 | ATH9K_INT_RXLP | \ |
| 495 | ATH9K_INT_RXHP | \ |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 496 | ATH9K_INT_TX | \ |
| 497 | ATH9K_INT_BMISS | \ |
| 498 | ATH9K_INT_CST | \ |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 499 | ATH9K_INT_GTT | \ |
Vasanthakumar Thiagarajan | ebb8e1d | 2009-09-01 17:46:32 +0530 | [diff] [blame] | 500 | ATH9K_INT_TSFOOR | \ |
Mohammed Shafi Shajakhan | 40dc539 | 2011-11-30 10:41:18 +0530 | [diff] [blame] | 501 | ATH9K_INT_GENTIMER | \ |
| 502 | ATH9K_INT_MCI) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 503 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 504 | struct ath_softc *sc = dev; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 505 | struct ath_hw *ah = sc->sc_ah; |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 506 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 507 | enum ath9k_int status; |
Sujith Manoharan | 78c8a95 | 2013-12-28 09:47:15 +0530 | [diff] [blame] | 508 | u32 sync_cause = 0; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 509 | bool sched = false; |
| 510 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 511 | /* |
| 512 | * The hardware is not ready/present, don't |
| 513 | * touch anything. Note this can happen early |
| 514 | * on if the IRQ is shared. |
| 515 | */ |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 516 | if (test_bit(ATH_OP_INVALID, &common->op_flags)) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 517 | return IRQ_NONE; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 518 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 519 | /* shared irq, not for us */ |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 520 | |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 521 | if (!ath9k_hw_intrpend(ah)) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 522 | return IRQ_NONE; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 523 | |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 524 | if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) { |
Felix Fietkau | f41a9b3 | 2012-08-08 16:25:03 +0200 | [diff] [blame] | 525 | ath9k_hw_kill_interrupts(ah); |
Sujith Manoharan | b74713d | 2012-06-04 20:24:01 +0530 | [diff] [blame] | 526 | return IRQ_HANDLED; |
Felix Fietkau | f41a9b3 | 2012-08-08 16:25:03 +0200 | [diff] [blame] | 527 | } |
Sujith Manoharan | b74713d | 2012-06-04 20:24:01 +0530 | [diff] [blame] | 528 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 529 | /* |
| 530 | * Figure out the reason(s) for the interrupt. Note |
| 531 | * that the hal returns a pseudo-ISR that may include |
| 532 | * bits we haven't explicitly enabled so we mask the |
| 533 | * value to insure we only process bits we requested. |
| 534 | */ |
Felix Fietkau | 6a4d05d | 2013-12-19 18:01:48 +0100 | [diff] [blame] | 535 | ath9k_hw_getisr(ah, &status, &sync_cause); /* NB: clears ISR too */ |
| 536 | ath9k_debug_sync_cause(sc, sync_cause); |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame] | 537 | status &= ah->imask; /* discard unasked-for bits */ |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 538 | |
| 539 | /* |
| 540 | * If there are no status bits set, then this interrupt was not |
| 541 | * for me (should have been caught above). |
| 542 | */ |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 543 | if (!status) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 544 | return IRQ_NONE; |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 545 | |
| 546 | /* Cache the status */ |
| 547 | sc->intrstatus = status; |
| 548 | |
| 549 | if (status & SCHED_INTR) |
| 550 | sched = true; |
| 551 | |
| 552 | /* |
| 553 | * If a FATAL or RXORN interrupt is received, we have to reset the |
| 554 | * chip immediately. |
| 555 | */ |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 556 | if ((status & ATH9K_INT_FATAL) || ((status & ATH9K_INT_RXORN) && |
| 557 | !(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA))) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 558 | goto chip_reset; |
| 559 | |
Sujith Manoharan | a6bb860 | 2013-12-24 10:44:22 +0530 | [diff] [blame] | 560 | if ((ah->config.hw_hang_checks & HW_BB_WATCHDOG) && |
Sujith Manoharan | 0c75997 | 2013-12-24 10:44:26 +0530 | [diff] [blame] | 561 | (status & ATH9K_INT_BB_WATCHDOG)) |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 562 | goto chip_reset; |
Sujith Manoharan | e60001e | 2013-10-28 12:22:04 +0530 | [diff] [blame] | 563 | |
| 564 | #ifdef CONFIG_ATH9K_WOW |
Rajkumar Manoharan | ca90ef4 | 2012-11-20 18:29:59 +0530 | [diff] [blame] | 565 | if (status & ATH9K_INT_BMISS) { |
| 566 | if (atomic_read(&sc->wow_sleep_proc_intr) == 0) { |
Rajkumar Manoharan | ca90ef4 | 2012-11-20 18:29:59 +0530 | [diff] [blame] | 567 | atomic_inc(&sc->wow_got_bmiss_intr); |
| 568 | atomic_dec(&sc->wow_sleep_proc_intr); |
| 569 | } |
| 570 | } |
| 571 | #endif |
Sujith Manoharan | e60001e | 2013-10-28 12:22:04 +0530 | [diff] [blame] | 572 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 573 | if (status & ATH9K_INT_SWBA) |
| 574 | tasklet_schedule(&sc->bcon_tasklet); |
| 575 | |
| 576 | if (status & ATH9K_INT_TXURN) |
| 577 | ath9k_hw_updatetxtriglevel(ah, true); |
| 578 | |
Rajkumar Manoharan | 0682c9b | 2011-08-13 10:28:09 +0530 | [diff] [blame] | 579 | if (status & ATH9K_INT_RXEOL) { |
| 580 | ah->imask &= ~(ATH9K_INT_RXEOL | ATH9K_INT_RXORN); |
Felix Fietkau | 72d874c | 2011-10-08 20:06:19 +0200 | [diff] [blame] | 581 | ath9k_hw_set_interrupts(ah); |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 582 | } |
| 583 | |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 584 | if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) |
| 585 | if (status & ATH9K_INT_TIM_TIMER) { |
Luis R. Rodriguez | ff9f0b6 | 2010-12-07 15:13:22 -0800 | [diff] [blame] | 586 | if (ATH_DBG_WARN_ON_ONCE(sc->ps_idle)) |
| 587 | goto chip_reset; |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 588 | /* Clear RxAbort bit so that we can |
| 589 | * receive frames */ |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 590 | ath9k_setpower(sc, ATH9K_PM_AWAKE); |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 591 | spin_lock(&sc->sc_pm_lock); |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 592 | ath9k_hw_setrxabort(sc->sc_ah, 0); |
Sujith | 1b04b93 | 2010-01-08 10:36:05 +0530 | [diff] [blame] | 593 | sc->ps_flags |= PS_WAIT_FOR_BEACON; |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 594 | spin_unlock(&sc->sc_pm_lock); |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 595 | } |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 596 | |
| 597 | chip_reset: |
| 598 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 599 | ath_debug_stat_interrupt(sc, status); |
| 600 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 601 | if (sched) { |
Felix Fietkau | 4df3071 | 2010-11-08 20:54:47 +0100 | [diff] [blame] | 602 | /* turn off every interrupt */ |
| 603 | ath9k_hw_disable_interrupts(ah); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 604 | tasklet_schedule(&sc->intr_tq); |
| 605 | } |
| 606 | |
| 607 | return IRQ_HANDLED; |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 608 | |
| 609 | #undef SCHED_INTR |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 610 | } |
| 611 | |
Sujith Manoharan | ef6b19e | 2013-10-24 12:04:39 +0530 | [diff] [blame] | 612 | int ath_reset(struct ath_softc *sc) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 613 | { |
Felix Fietkau | ec30326 | 2013-10-05 14:09:30 +0200 | [diff] [blame] | 614 | int r; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 615 | |
Felix Fietkau | 783cd01 | 2011-01-21 18:52:38 +0100 | [diff] [blame] | 616 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 1381559 | 2013-01-20 18:51:53 +0100 | [diff] [blame] | 617 | r = ath_reset_internal(sc, NULL); |
Felix Fietkau | 783cd01 | 2011-01-21 18:52:38 +0100 | [diff] [blame] | 618 | ath9k_ps_restore(sc); |
Sujith | 2ab81d4 | 2009-12-14 16:34:56 +0530 | [diff] [blame] | 619 | |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 620 | return r; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 621 | } |
| 622 | |
Rajkumar Manoharan | 124b979 | 2012-07-17 17:16:42 +0530 | [diff] [blame] | 623 | void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type) |
| 624 | { |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 625 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Rajkumar Manoharan | 124b979 | 2012-07-17 17:16:42 +0530 | [diff] [blame] | 626 | #ifdef CONFIG_ATH9K_DEBUGFS |
| 627 | RESET_STAT_INC(sc, type); |
| 628 | #endif |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 629 | set_bit(ATH_OP_HW_RESET, &common->op_flags); |
Rajkumar Manoharan | 124b979 | 2012-07-17 17:16:42 +0530 | [diff] [blame] | 630 | ieee80211_queue_work(sc->hw, &sc->hw_reset_work); |
| 631 | } |
| 632 | |
Felix Fietkau | 236de51 | 2011-09-03 01:40:25 +0200 | [diff] [blame] | 633 | void ath_reset_work(struct work_struct *work) |
| 634 | { |
| 635 | struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work); |
| 636 | |
Felix Fietkau | 1381559 | 2013-01-20 18:51:53 +0100 | [diff] [blame] | 637 | ath_reset(sc); |
Felix Fietkau | 236de51 | 2011-09-03 01:40:25 +0200 | [diff] [blame] | 638 | } |
| 639 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 640 | /**********************/ |
| 641 | /* mac80211 callbacks */ |
| 642 | /**********************/ |
| 643 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 644 | static int ath9k_start(struct ieee80211_hw *hw) |
| 645 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 646 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 647 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 648 | struct ath_common *common = ath9k_hw_common(ah); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 649 | struct ieee80211_channel *curchan = sc->cur_chan->chandef.chan; |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 650 | struct ath_chanctx *ctx = sc->cur_chan; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 651 | struct ath9k_channel *init_channel; |
Vasanthakumar Thiagarajan | 82880a7 | 2009-06-13 14:50:24 +0530 | [diff] [blame] | 652 | int r; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 653 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 654 | ath_dbg(common, CONFIG, |
Joe Perches | 226afe6 | 2010-12-02 19:12:37 -0800 | [diff] [blame] | 655 | "Starting driver with initial channel: %d MHz\n", |
| 656 | curchan->center_freq); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 657 | |
Felix Fietkau | f62d816 | 2011-03-25 17:43:41 +0100 | [diff] [blame] | 658 | ath9k_ps_wakeup(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 659 | mutex_lock(&sc->mutex); |
| 660 | |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 661 | init_channel = ath9k_cmn_get_channel(hw, ah, &ctx->chandef); |
Felix Fietkau | bff1176 | 2014-06-11 16:17:52 +0530 | [diff] [blame] | 662 | sc->cur_chandef = hw->conf.chandef; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 663 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 664 | /* Reset SERDES registers */ |
Stanislaw Gruszka | 84c87dc | 2011-08-05 13:10:32 +0200 | [diff] [blame] | 665 | ath9k_hw_configpcipowersave(ah, false); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 666 | |
| 667 | /* |
| 668 | * The basic interface to setting the hardware in a good |
| 669 | * state is ``reset''. On return the hardware is known to |
| 670 | * be powered up and with interrupts disabled. This must |
| 671 | * be followed by initialization of the appropriate bits |
| 672 | * and then setup of the interrupt mask. |
| 673 | */ |
Luis R. Rodriguez | 4bdd1e9 | 2010-10-26 15:27:24 -0700 | [diff] [blame] | 674 | spin_lock_bh(&sc->sc_pcu_lock); |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 675 | |
| 676 | atomic_set(&ah->intr_ref_cnt, -1); |
| 677 | |
Felix Fietkau | 20bd2a0 | 2010-07-31 00:12:00 +0200 | [diff] [blame] | 678 | r = ath9k_hw_reset(ah, init_channel, ah->caldata, false); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 679 | if (r) { |
Joe Perches | 3800276 | 2010-12-02 19:12:36 -0800 | [diff] [blame] | 680 | ath_err(common, |
| 681 | "Unable to reset hardware; reset status %d (freq %u MHz)\n", |
| 682 | r, curchan->center_freq); |
Felix Fietkau | ceb26a6 | 2012-10-03 21:07:51 +0200 | [diff] [blame] | 683 | ah->reset_power_on = false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 684 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 685 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 686 | /* Setup our intr mask. */ |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 687 | ah->imask = ATH9K_INT_TX | ATH9K_INT_RXEOL | |
| 688 | ATH9K_INT_RXORN | ATH9K_INT_FATAL | |
| 689 | ATH9K_INT_GLOBAL; |
| 690 | |
| 691 | if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) |
Luis R. Rodriguez | 08578b8 | 2010-05-13 13:33:44 -0400 | [diff] [blame] | 692 | ah->imask |= ATH9K_INT_RXHP | |
Sujith Manoharan | a6bb860 | 2013-12-24 10:44:22 +0530 | [diff] [blame] | 693 | ATH9K_INT_RXLP; |
Felix Fietkau | b5c80475 | 2010-04-15 17:38:48 -0400 | [diff] [blame] | 694 | else |
| 695 | ah->imask |= ATH9K_INT_RX; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 696 | |
Sujith Manoharan | a6bb860 | 2013-12-24 10:44:22 +0530 | [diff] [blame] | 697 | if (ah->config.hw_hang_checks & HW_BB_WATCHDOG) |
| 698 | ah->imask |= ATH9K_INT_BB_WATCHDOG; |
| 699 | |
Sujith Manoharan | 071aa9a | 2014-01-13 13:55:11 +0530 | [diff] [blame] | 700 | /* |
| 701 | * Enable GTT interrupts only for AR9003/AR9004 chips |
| 702 | * for now. |
| 703 | */ |
| 704 | if (AR_SREV_9300_20_OR_LATER(ah)) |
| 705 | ah->imask |= ATH9K_INT_GTT; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 706 | |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 707 | if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame] | 708 | ah->imask |= ATH9K_INT_CST; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 709 | |
Sujith Manoharan | e270e77 | 2012-06-04 16:27:19 +0530 | [diff] [blame] | 710 | ath_mci_enable(sc); |
Mohammed Shafi Shajakhan | 40dc539 | 2011-11-30 10:41:18 +0530 | [diff] [blame] | 711 | |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 712 | clear_bit(ATH_OP_INVALID, &common->op_flags); |
Rajkumar Manoharan | 5f841b4 | 2010-10-27 18:31:15 +0530 | [diff] [blame] | 713 | sc->sc_ah->is_monitoring = false; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 714 | |
Felix Fietkau | ceb26a6 | 2012-10-03 21:07:51 +0200 | [diff] [blame] | 715 | if (!ath_complete_reset(sc, false)) |
| 716 | ah->reset_power_on = false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 717 | |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 718 | if (ah->led_pin >= 0) { |
| 719 | ath9k_hw_cfg_output(ah, ah->led_pin, |
| 720 | AR_GPIO_OUTPUT_MUX_AS_OUTPUT); |
| 721 | ath9k_hw_set_gpio(ah, ah->led_pin, 0); |
| 722 | } |
| 723 | |
| 724 | /* |
| 725 | * Reset key cache to sane defaults (all entries cleared) instead of |
| 726 | * semi-random values after suspend/resume. |
| 727 | */ |
| 728 | ath9k_cmn_init_crypto(sc->sc_ah); |
| 729 | |
Felix Fietkau | a35051c | 2013-12-14 18:03:45 +0100 | [diff] [blame] | 730 | ath9k_hw_reset_tsf(ah); |
| 731 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 732 | spin_unlock_bh(&sc->sc_pcu_lock); |
Senthil Balasubramanian | 164ace3 | 2009-07-14 20:17:09 -0400 | [diff] [blame] | 733 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 734 | mutex_unlock(&sc->mutex); |
| 735 | |
Felix Fietkau | f62d816 | 2011-03-25 17:43:41 +0100 | [diff] [blame] | 736 | ath9k_ps_restore(sc); |
| 737 | |
Felix Fietkau | ceb26a6 | 2012-10-03 21:07:51 +0200 | [diff] [blame] | 738 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 739 | } |
| 740 | |
Thomas Huehn | 36323f8 | 2012-07-23 21:33:42 +0200 | [diff] [blame] | 741 | static void ath9k_tx(struct ieee80211_hw *hw, |
| 742 | struct ieee80211_tx_control *control, |
| 743 | struct sk_buff *skb) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 744 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 745 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 746 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 747 | struct ath_tx_control txctl; |
Benoit Papillault | 1bc1488 | 2009-11-24 15:49:18 +0100 | [diff] [blame] | 748 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 749 | unsigned long flags; |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 750 | |
Gabor Juhos | 9614832 | 2009-07-24 17:27:21 +0200 | [diff] [blame] | 751 | if (sc->ps_enabled) { |
Jouni Malinen | dc8c458 | 2009-05-19 17:01:42 +0300 | [diff] [blame] | 752 | /* |
| 753 | * mac80211 does not set PM field for normal data frames, so we |
| 754 | * need to update that based on the current PS mode. |
| 755 | */ |
| 756 | if (ieee80211_is_data(hdr->frame_control) && |
| 757 | !ieee80211_is_nullfunc(hdr->frame_control) && |
| 758 | !ieee80211_has_pm(hdr->frame_control)) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 759 | ath_dbg(common, PS, |
Joe Perches | 226afe6 | 2010-12-02 19:12:37 -0800 | [diff] [blame] | 760 | "Add PM=1 for a TX frame while in PS mode\n"); |
Jouni Malinen | dc8c458 | 2009-05-19 17:01:42 +0300 | [diff] [blame] | 761 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
| 762 | } |
| 763 | } |
| 764 | |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 765 | if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP)) { |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 766 | /* |
| 767 | * We are using PS-Poll and mac80211 can request TX while in |
| 768 | * power save mode. Need to wake up hardware for the TX to be |
| 769 | * completed and if needed, also for RX of buffered frames. |
| 770 | */ |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 771 | ath9k_ps_wakeup(sc); |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 772 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
Vasanthakumar Thiagarajan | fdf7662 | 2010-05-17 18:57:55 -0700 | [diff] [blame] | 773 | if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) |
| 774 | ath9k_hw_setrxabort(sc->sc_ah, 0); |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 775 | if (ieee80211_is_pspoll(hdr->frame_control)) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 776 | ath_dbg(common, PS, |
Joe Perches | 226afe6 | 2010-12-02 19:12:37 -0800 | [diff] [blame] | 777 | "Sending PS-Poll to pick a buffered frame\n"); |
Sujith | 1b04b93 | 2010-01-08 10:36:05 +0530 | [diff] [blame] | 778 | sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA; |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 779 | } else { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 780 | ath_dbg(common, PS, "Wake up to complete TX\n"); |
Sujith | 1b04b93 | 2010-01-08 10:36:05 +0530 | [diff] [blame] | 781 | sc->ps_flags |= PS_WAIT_FOR_TX_ACK; |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 782 | } |
| 783 | /* |
| 784 | * The actual restore operation will happen only after |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 785 | * the ps_flags bit is cleared. We are just dropping |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 786 | * the ps_usecount here. |
| 787 | */ |
Sujith Manoharan | 07c15a3 | 2012-06-04 20:24:07 +0530 | [diff] [blame] | 788 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 789 | ath9k_ps_restore(sc); |
| 790 | } |
| 791 | |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 792 | /* |
| 793 | * Cannot tx while the hardware is in full sleep, it first needs a full |
| 794 | * chip reset to recover from that |
| 795 | */ |
| 796 | if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP)) { |
| 797 | ath_err(common, "TX while HW is in FULL_SLEEP mode\n"); |
| 798 | goto exit; |
| 799 | } |
| 800 | |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 801 | memset(&txctl, 0, sizeof(struct ath_tx_control)); |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 802 | txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)]; |
Thomas Huehn | 36323f8 | 2012-07-23 21:33:42 +0200 | [diff] [blame] | 803 | txctl.sta = control->sta; |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 804 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 805 | ath_dbg(common, XMIT, "transmitting packet, skb: %p\n", skb); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 806 | |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 807 | if (ath_tx_start(hw, skb, &txctl) != 0) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 808 | ath_dbg(common, XMIT, "TX failed\n"); |
Ben Greear | a5a0bca | 2012-04-03 09:16:55 -0700 | [diff] [blame] | 809 | TX_STAT_INC(txctl.txq->axq_qnum, txfailed); |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 810 | goto exit; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 811 | } |
| 812 | |
Johannes Berg | 7bb4568 | 2011-02-24 14:42:06 +0100 | [diff] [blame] | 813 | return; |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 814 | exit: |
Felix Fietkau | 249ee722 | 2012-10-03 21:07:52 +0200 | [diff] [blame] | 815 | ieee80211_free_txskb(hw, skb); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | static void ath9k_stop(struct ieee80211_hw *hw) |
| 819 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 820 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 821 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 822 | struct ath_common *common = ath9k_hw_common(ah); |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 823 | bool prev_idle; |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 824 | |
Sujith Manoharan | ea22df2 | 2014-08-23 13:29:07 +0530 | [diff] [blame^] | 825 | ath9k_deinit_channel_context(sc); |
| 826 | |
Sujith | 4c48381 | 2009-08-18 10:51:52 +0530 | [diff] [blame] | 827 | mutex_lock(&sc->mutex); |
| 828 | |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 829 | ath_cancel_work(sc); |
Luis R. Rodriguez | c94dbff | 2009-07-27 11:53:04 -0700 | [diff] [blame] | 830 | |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 831 | if (test_bit(ATH_OP_INVALID, &common->op_flags)) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 832 | ath_dbg(common, ANY, "Device not present\n"); |
Sujith | 4c48381 | 2009-08-18 10:51:52 +0530 | [diff] [blame] | 833 | mutex_unlock(&sc->mutex); |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 834 | return; |
| 835 | } |
| 836 | |
Sujith | 3867cf6 | 2009-12-23 20:03:27 -0500 | [diff] [blame] | 837 | /* Ensure HW is awake when we try to shut it down. */ |
| 838 | ath9k_ps_wakeup(sc); |
| 839 | |
Luis R. Rodriguez | 6a6733f | 2010-10-26 15:27:25 -0700 | [diff] [blame] | 840 | spin_lock_bh(&sc->sc_pcu_lock); |
| 841 | |
Stanislaw Gruszka | 203043f | 2011-01-25 14:08:40 +0100 | [diff] [blame] | 842 | /* prevent tasklets to enable interrupts once we disable them */ |
| 843 | ah->imask &= ~ATH9K_INT_GLOBAL; |
| 844 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 845 | /* make sure h/w will not generate any interrupt |
| 846 | * before setting the invalid flag. */ |
Felix Fietkau | 4df3071 | 2010-11-08 20:54:47 +0100 | [diff] [blame] | 847 | ath9k_hw_disable_interrupts(ah); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 848 | |
Luis R. Rodriguez | 6a6733f | 2010-10-26 15:27:25 -0700 | [diff] [blame] | 849 | spin_unlock_bh(&sc->sc_pcu_lock); |
| 850 | |
Stanislaw Gruszka | 203043f | 2011-01-25 14:08:40 +0100 | [diff] [blame] | 851 | /* we can now sync irq and kill any running tasklets, since we already |
| 852 | * disabled interrupts and not holding a spin lock */ |
| 853 | synchronize_irq(sc->irq); |
| 854 | tasklet_kill(&sc->intr_tq); |
| 855 | tasklet_kill(&sc->bcon_tasklet); |
| 856 | |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 857 | prev_idle = sc->ps_idle; |
| 858 | sc->ps_idle = true; |
| 859 | |
| 860 | spin_lock_bh(&sc->sc_pcu_lock); |
| 861 | |
| 862 | if (ah->led_pin >= 0) { |
| 863 | ath9k_hw_set_gpio(ah, ah->led_pin, 1); |
| 864 | ath9k_hw_cfg_gpio_input(ah, ah->led_pin); |
| 865 | } |
| 866 | |
John W. Linville | 9ebea38 | 2013-01-28 13:54:03 -0500 | [diff] [blame] | 867 | ath_prepare_reset(sc); |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 868 | |
| 869 | if (sc->rx.frag) { |
| 870 | dev_kfree_skb_any(sc->rx.frag); |
| 871 | sc->rx.frag = NULL; |
| 872 | } |
| 873 | |
| 874 | if (!ah->curchan) |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 875 | ah->curchan = ath9k_cmn_get_channel(hw, ah, |
| 876 | &sc->cur_chan->chandef); |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 877 | |
| 878 | ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); |
| 879 | ath9k_hw_phy_disable(ah); |
| 880 | |
| 881 | ath9k_hw_configpcipowersave(ah, true); |
| 882 | |
| 883 | spin_unlock_bh(&sc->sc_pcu_lock); |
| 884 | |
Sujith | 3867cf6 | 2009-12-23 20:03:27 -0500 | [diff] [blame] | 885 | ath9k_ps_restore(sc); |
| 886 | |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 887 | set_bit(ATH_OP_INVALID, &common->op_flags); |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 888 | sc->ps_idle = prev_idle; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 889 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 890 | mutex_unlock(&sc->mutex); |
| 891 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 892 | ath_dbg(common, CONFIG, "Driver halt\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 893 | } |
| 894 | |
Felix Fietkau | c648ecb | 2013-10-11 23:31:00 +0200 | [diff] [blame] | 895 | static bool ath9k_uses_beacons(int type) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 896 | { |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 897 | switch (type) { |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 898 | case NL80211_IFTYPE_AP: |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 899 | case NL80211_IFTYPE_ADHOC: |
Pat Erley | 9cb5412 | 2009-03-20 22:59:59 -0400 | [diff] [blame] | 900 | case NL80211_IFTYPE_MESH_POINT: |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 901 | return true; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 902 | default: |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 903 | return false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 904 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 905 | } |
| 906 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 907 | static void ath9k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif) |
| 908 | { |
| 909 | struct ath9k_vif_iter_data *iter_data = data; |
| 910 | int i; |
| 911 | |
Felix Fietkau | ab11bb2 | 2013-04-16 12:51:57 +0200 | [diff] [blame] | 912 | if (iter_data->has_hw_macaddr) { |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 913 | for (i = 0; i < ETH_ALEN; i++) |
| 914 | iter_data->mask[i] &= |
| 915 | ~(iter_data->hw_macaddr[i] ^ mac[i]); |
Felix Fietkau | ab11bb2 | 2013-04-16 12:51:57 +0200 | [diff] [blame] | 916 | } else { |
| 917 | memcpy(iter_data->hw_macaddr, mac, ETH_ALEN); |
| 918 | iter_data->has_hw_macaddr = true; |
| 919 | } |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 920 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 921 | if (!vif->bss_conf.use_short_slot) |
| 922 | iter_data->slottime = ATH9K_SLOT_TIME_20; |
| 923 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 924 | switch (vif->type) { |
| 925 | case NL80211_IFTYPE_AP: |
| 926 | iter_data->naps++; |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 927 | if (vif->bss_conf.enable_beacon) |
| 928 | iter_data->beacons = true; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 929 | break; |
| 930 | case NL80211_IFTYPE_STATION: |
| 931 | iter_data->nstations++; |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 932 | if (vif->bss_conf.assoc && !iter_data->primary_sta) |
| 933 | iter_data->primary_sta = vif; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 934 | break; |
| 935 | case NL80211_IFTYPE_ADHOC: |
| 936 | iter_data->nadhocs++; |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 937 | if (vif->bss_conf.enable_beacon) |
| 938 | iter_data->beacons = true; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 939 | break; |
| 940 | case NL80211_IFTYPE_MESH_POINT: |
| 941 | iter_data->nmeshes++; |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 942 | if (vif->bss_conf.enable_beacon) |
| 943 | iter_data->beacons = true; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 944 | break; |
| 945 | case NL80211_IFTYPE_WDS: |
| 946 | iter_data->nwds++; |
| 947 | break; |
| 948 | default: |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 949 | break; |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | /* Called with sc->mutex held. */ |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 954 | void ath9k_calculate_iter_data(struct ath_softc *sc, |
| 955 | struct ath_chanctx *ctx, |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 956 | struct ath9k_vif_iter_data *iter_data) |
| 957 | { |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 958 | struct ath_vif *avp; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 959 | |
| 960 | /* |
Mathy Vanhoef | 657eb17 | 2013-11-28 12:21:45 +0100 | [diff] [blame] | 961 | * Pick the MAC address of the first interface as the new hardware |
| 962 | * MAC address. The hardware will use it together with the BSSID mask |
| 963 | * when matching addresses. |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 964 | */ |
| 965 | memset(iter_data, 0, sizeof(*iter_data)); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 966 | memset(&iter_data->mask, 0xff, ETH_ALEN); |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 967 | iter_data->slottime = ATH9K_SLOT_TIME_9; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 968 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 969 | list_for_each_entry(avp, &ctx->vifs, list) |
| 970 | ath9k_vif_iter(iter_data, avp->vif->addr, avp->vif); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 971 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 972 | if (ctx == &sc->offchannel.chan) { |
| 973 | struct ieee80211_vif *vif; |
Felix Fietkau | ab11bb2 | 2013-04-16 12:51:57 +0200 | [diff] [blame] | 974 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 975 | if (sc->offchannel.state < ATH_OFFCHANNEL_ROC_START) |
| 976 | vif = sc->offchannel.scan_vif; |
| 977 | else |
| 978 | vif = sc->offchannel.roc_vif; |
| 979 | |
| 980 | if (vif) |
| 981 | ath9k_vif_iter(iter_data, vif->addr, vif); |
| 982 | iter_data->beacons = false; |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | static void ath9k_set_assoc_state(struct ath_softc *sc, |
| 987 | struct ieee80211_vif *vif, bool changed) |
| 988 | { |
| 989 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 990 | struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; |
| 991 | unsigned long flags; |
| 992 | |
| 993 | set_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags); |
| 994 | /* Set the AID, BSSID and do beacon-sync only when |
| 995 | * the HW opmode is STATION. |
| 996 | * |
| 997 | * But the primary bit is set above in any case. |
| 998 | */ |
| 999 | if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION) |
| 1000 | return; |
| 1001 | |
| 1002 | ether_addr_copy(common->curbssid, bss_conf->bssid); |
| 1003 | common->curaid = bss_conf->aid; |
| 1004 | ath9k_hw_write_associd(sc->sc_ah); |
| 1005 | |
| 1006 | if (changed) { |
| 1007 | common->last_rssi = ATH_RSSI_DUMMY_MARKER; |
| 1008 | sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; |
| 1009 | |
| 1010 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 1011 | sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; |
| 1012 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
| 1013 | } |
| 1014 | |
| 1015 | if (ath9k_hw_mci_is_enabled(sc->sc_ah)) |
| 1016 | ath9k_mci_update_wlan_channels(sc, false); |
| 1017 | |
| 1018 | ath_dbg(common, CONFIG, |
| 1019 | "Primary Station interface: %pM, BSSID: %pM\n", |
| 1020 | vif->addr, common->curbssid); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | /* Called with sc->mutex held. */ |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1024 | void ath9k_calculate_summary_state(struct ath_softc *sc, |
| 1025 | struct ath_chanctx *ctx) |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1026 | { |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1027 | struct ath_hw *ah = sc->sc_ah; |
| 1028 | struct ath_common *common = ath9k_hw_common(ah); |
| 1029 | struct ath9k_vif_iter_data iter_data; |
| 1030 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1031 | ath_chanctx_check_active(sc, ctx); |
| 1032 | |
| 1033 | if (ctx != sc->cur_chan) |
| 1034 | return; |
| 1035 | |
| 1036 | ath9k_ps_wakeup(sc); |
| 1037 | ath9k_calculate_iter_data(sc, ctx, &iter_data); |
| 1038 | |
| 1039 | if (iter_data.has_hw_macaddr) |
| 1040 | ether_addr_copy(common->macaddr, iter_data.hw_macaddr); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1041 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1042 | memcpy(common->bssidmask, iter_data.mask, ETH_ALEN); |
| 1043 | ath_hw_setbssidmask(common); |
| 1044 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1045 | if (iter_data.naps > 0) { |
Sujith Manoharan | 60ca9f8 | 2012-07-17 17:15:37 +0530 | [diff] [blame] | 1046 | ath9k_hw_set_tsfadjust(ah, true); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1047 | ah->opmode = NL80211_IFTYPE_AP; |
| 1048 | } else { |
Sujith Manoharan | 60ca9f8 | 2012-07-17 17:15:37 +0530 | [diff] [blame] | 1049 | ath9k_hw_set_tsfadjust(ah, false); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1050 | |
Javier Cardona | fd5999c | 2011-05-03 16:57:19 -0700 | [diff] [blame] | 1051 | if (iter_data.nmeshes) |
| 1052 | ah->opmode = NL80211_IFTYPE_MESH_POINT; |
| 1053 | else if (iter_data.nwds) |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1054 | ah->opmode = NL80211_IFTYPE_AP; |
| 1055 | else if (iter_data.nadhocs) |
| 1056 | ah->opmode = NL80211_IFTYPE_ADHOC; |
| 1057 | else |
| 1058 | ah->opmode = NL80211_IFTYPE_STATION; |
| 1059 | } |
| 1060 | |
Sujith Manoharan | df35d29 | 2012-07-17 17:15:43 +0530 | [diff] [blame] | 1061 | ath9k_hw_setopmode(ah); |
| 1062 | |
Felix Fietkau | 748299f | 2014-06-11 16:18:04 +0530 | [diff] [blame] | 1063 | ctx->switch_after_beacon = false; |
Felix Fietkau | 198823f | 2012-06-15 15:25:25 +0200 | [diff] [blame] | 1064 | if ((iter_data.nstations + iter_data.nadhocs + iter_data.nmeshes) > 0) |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1065 | ah->imask |= ATH9K_INT_TSFOOR; |
Felix Fietkau | 748299f | 2014-06-11 16:18:04 +0530 | [diff] [blame] | 1066 | else { |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1067 | ah->imask &= ~ATH9K_INT_TSFOOR; |
Felix Fietkau | 748299f | 2014-06-11 16:18:04 +0530 | [diff] [blame] | 1068 | if (iter_data.naps == 1 && iter_data.beacons) |
| 1069 | ctx->switch_after_beacon = true; |
| 1070 | } |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1071 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1072 | ah->imask &= ~ATH9K_INT_SWBA; |
| 1073 | if (ah->opmode == NL80211_IFTYPE_STATION) { |
| 1074 | bool changed = (iter_data.primary_sta != ctx->primary_sta); |
| 1075 | |
| 1076 | iter_data.beacons = true; |
| 1077 | if (iter_data.primary_sta) { |
| 1078 | ath9k_set_assoc_state(sc, iter_data.primary_sta, |
| 1079 | changed); |
| 1080 | if (!ctx->primary_sta || |
| 1081 | !ctx->primary_sta->bss_conf.assoc) |
| 1082 | ctx->primary_sta = iter_data.primary_sta; |
| 1083 | } else { |
| 1084 | ctx->primary_sta = NULL; |
| 1085 | memset(common->curbssid, 0, ETH_ALEN); |
| 1086 | common->curaid = 0; |
| 1087 | ath9k_hw_write_associd(sc->sc_ah); |
| 1088 | if (ath9k_hw_mci_is_enabled(sc->sc_ah)) |
| 1089 | ath9k_mci_update_wlan_channels(sc, true); |
| 1090 | } |
| 1091 | } else if (iter_data.beacons) { |
| 1092 | ah->imask |= ATH9K_INT_SWBA; |
| 1093 | } |
Felix Fietkau | 72d874c | 2011-10-08 20:06:19 +0200 | [diff] [blame] | 1094 | ath9k_hw_set_interrupts(ah); |
Sujith Manoharan | 6dcc344 | 2012-07-17 17:16:36 +0530 | [diff] [blame] | 1095 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1096 | if (iter_data.beacons) |
| 1097 | set_bit(ATH_OP_BEACONS, &common->op_flags); |
| 1098 | else |
| 1099 | clear_bit(ATH_OP_BEACONS, &common->op_flags); |
| 1100 | |
| 1101 | if (ah->slottime != iter_data.slottime) { |
| 1102 | ah->slottime = iter_data.slottime; |
| 1103 | ath9k_hw_init_global_settings(ah); |
Sujith Manoharan | 6dcc344 | 2012-07-17 17:16:36 +0530 | [diff] [blame] | 1104 | } |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1105 | |
| 1106 | if (iter_data.primary_sta) |
| 1107 | set_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags); |
| 1108 | else |
| 1109 | clear_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags); |
| 1110 | |
| 1111 | ctx->primary_sta = iter_data.primary_sta; |
| 1112 | |
| 1113 | ath9k_ps_restore(sc); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1116 | static int ath9k_add_interface(struct ieee80211_hw *hw, |
| 1117 | struct ieee80211_vif *vif) |
| 1118 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1119 | struct ath_softc *sc = hw->priv; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1120 | struct ath_hw *ah = sc->sc_ah; |
| 1121 | struct ath_common *common = ath9k_hw_common(ah); |
Felix Fietkau | f89d1bc | 2013-08-06 14:18:13 +0200 | [diff] [blame] | 1122 | struct ath_vif *avp = (void *)vif->drv_priv; |
| 1123 | struct ath_node *an = &avp->mcast_node; |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 1124 | int i; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1125 | |
| 1126 | mutex_lock(&sc->mutex); |
| 1127 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1128 | if (config_enabled(CONFIG_ATH9K_TX99)) { |
| 1129 | if (sc->nvifs >= 1) { |
| 1130 | mutex_unlock(&sc->mutex); |
| 1131 | return -EOPNOTSUPP; |
| 1132 | } |
| 1133 | sc->tx99_vif = vif; |
| 1134 | } |
| 1135 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1136 | ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1137 | sc->nvifs++; |
| 1138 | |
Sujith Manoharan | 130ef6e | 2012-07-17 17:15:30 +0530 | [diff] [blame] | 1139 | if (ath9k_uses_beacons(vif->type)) |
| 1140 | ath9k_beacon_assign_slot(sc, vif); |
| 1141 | |
Felix Fietkau | d463af4 | 2014-04-06 00:37:03 +0200 | [diff] [blame] | 1142 | avp->vif = vif; |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 1143 | if (!ath9k_is_chanctx_enabled()) { |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 1144 | avp->chanctx = sc->cur_chan; |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1145 | list_add_tail(&avp->list, &avp->chanctx->vifs); |
| 1146 | } |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 1147 | for (i = 0; i < IEEE80211_NUM_ACS; i++) |
| 1148 | vif->hw_queue[i] = i; |
| 1149 | if (vif->type == NL80211_IFTYPE_AP) |
| 1150 | vif->cab_queue = hw->queues - 2; |
| 1151 | else |
| 1152 | vif->cab_queue = IEEE80211_INVAL_HW_QUEUE; |
Felix Fietkau | 0453531 | 2014-06-11 16:17:51 +0530 | [diff] [blame] | 1153 | |
Felix Fietkau | f89d1bc | 2013-08-06 14:18:13 +0200 | [diff] [blame] | 1154 | an->sc = sc; |
| 1155 | an->sta = NULL; |
| 1156 | an->vif = vif; |
| 1157 | an->no_ps_filter = true; |
| 1158 | ath_tx_node_init(sc, an); |
| 1159 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1160 | mutex_unlock(&sc->mutex); |
Mohammed Shafi Shajakhan | 327967c | 2012-09-04 19:33:36 +0530 | [diff] [blame] | 1161 | return 0; |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1162 | } |
| 1163 | |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 1164 | static int ath9k_change_interface(struct ieee80211_hw *hw, |
| 1165 | struct ieee80211_vif *vif, |
| 1166 | enum nl80211_iftype new_type, |
| 1167 | bool p2p) |
| 1168 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1169 | struct ath_softc *sc = hw->priv; |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 1170 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | c083ce9 | 2014-06-11 16:17:54 +0530 | [diff] [blame] | 1171 | struct ath_vif *avp = (void *)vif->drv_priv; |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 1172 | int i; |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 1173 | |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 1174 | mutex_lock(&sc->mutex); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1175 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1176 | if (config_enabled(CONFIG_ATH9K_TX99)) { |
| 1177 | mutex_unlock(&sc->mutex); |
| 1178 | return -EOPNOTSUPP; |
| 1179 | } |
| 1180 | |
| 1181 | ath_dbg(common, CONFIG, "Change Interface\n"); |
| 1182 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1183 | if (ath9k_uses_beacons(vif->type)) |
Sujith Manoharan | 130ef6e | 2012-07-17 17:15:30 +0530 | [diff] [blame] | 1184 | ath9k_beacon_remove_slot(sc, vif); |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1185 | |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 1186 | vif->type = new_type; |
| 1187 | vif->p2p = p2p; |
| 1188 | |
Sujith Manoharan | 130ef6e | 2012-07-17 17:15:30 +0530 | [diff] [blame] | 1189 | if (ath9k_uses_beacons(vif->type)) |
| 1190 | ath9k_beacon_assign_slot(sc, vif); |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1191 | |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 1192 | for (i = 0; i < IEEE80211_NUM_ACS; i++) |
| 1193 | vif->hw_queue[i] = i; |
| 1194 | |
| 1195 | if (vif->type == NL80211_IFTYPE_AP) |
| 1196 | vif->cab_queue = hw->queues - 2; |
| 1197 | else |
| 1198 | vif->cab_queue = IEEE80211_INVAL_HW_QUEUE; |
| 1199 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1200 | ath9k_calculate_summary_state(sc, avp->chanctx); |
Sujith Manoharan | 130ef6e | 2012-07-17 17:15:30 +0530 | [diff] [blame] | 1201 | |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 1202 | mutex_unlock(&sc->mutex); |
Mohammed Shafi Shajakhan | 327967c | 2012-09-04 19:33:36 +0530 | [diff] [blame] | 1203 | return 0; |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 1204 | } |
| 1205 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1206 | static void ath9k_remove_interface(struct ieee80211_hw *hw, |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 1207 | struct ieee80211_vif *vif) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1208 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1209 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1210 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | f89d1bc | 2013-08-06 14:18:13 +0200 | [diff] [blame] | 1211 | struct ath_vif *avp = (void *)vif->drv_priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1212 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1213 | ath_dbg(common, CONFIG, "Detach Interface\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1214 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1215 | mutex_lock(&sc->mutex); |
| 1216 | |
Sujith Manoharan | c7dd40c | 2014-08-22 20:39:30 +0530 | [diff] [blame] | 1217 | ath9k_p2p_remove_vif(sc, vif); |
Felix Fietkau | d463af4 | 2014-04-06 00:37:03 +0200 | [diff] [blame] | 1218 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1219 | sc->nvifs--; |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1220 | sc->tx99_vif = NULL; |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 1221 | if (!ath9k_is_chanctx_enabled()) |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1222 | list_del(&avp->list); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1223 | |
Ben Greear | 4801416 | 2011-01-15 19:13:48 +0000 | [diff] [blame] | 1224 | if (ath9k_uses_beacons(vif->type)) |
Sujith Manoharan | 130ef6e | 2012-07-17 17:15:30 +0530 | [diff] [blame] | 1225 | ath9k_beacon_remove_slot(sc, vif); |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 1226 | |
Felix Fietkau | f89d1bc | 2013-08-06 14:18:13 +0200 | [diff] [blame] | 1227 | ath_tx_node_cleanup(sc, &avp->mcast_node); |
| 1228 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1229 | mutex_unlock(&sc->mutex); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1230 | } |
| 1231 | |
Senthil Balasubramanian | fbab739 | 2010-10-05 20:36:40 +0530 | [diff] [blame] | 1232 | static void ath9k_enable_ps(struct ath_softc *sc) |
Senthil Balasubramanian | 3f7c5c1 | 2010-02-03 22:51:13 +0530 | [diff] [blame] | 1233 | { |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame] | 1234 | struct ath_hw *ah = sc->sc_ah; |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 1235 | struct ath_common *common = ath9k_hw_common(ah); |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame] | 1236 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1237 | if (config_enabled(CONFIG_ATH9K_TX99)) |
| 1238 | return; |
| 1239 | |
Senthil Balasubramanian | 3f7c5c1 | 2010-02-03 22:51:13 +0530 | [diff] [blame] | 1240 | sc->ps_enabled = true; |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame] | 1241 | if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
| 1242 | if ((ah->imask & ATH9K_INT_TIM_TIMER) == 0) { |
| 1243 | ah->imask |= ATH9K_INT_TIM_TIMER; |
Felix Fietkau | 72d874c | 2011-10-08 20:06:19 +0200 | [diff] [blame] | 1244 | ath9k_hw_set_interrupts(ah); |
Senthil Balasubramanian | 3f7c5c1 | 2010-02-03 22:51:13 +0530 | [diff] [blame] | 1245 | } |
Vasanthakumar Thiagarajan | fdf7662 | 2010-05-17 18:57:55 -0700 | [diff] [blame] | 1246 | ath9k_hw_setrxabort(ah, 1); |
Senthil Balasubramanian | 3f7c5c1 | 2010-02-03 22:51:13 +0530 | [diff] [blame] | 1247 | } |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 1248 | ath_dbg(common, PS, "PowerSave enabled\n"); |
Senthil Balasubramanian | 3f7c5c1 | 2010-02-03 22:51:13 +0530 | [diff] [blame] | 1249 | } |
| 1250 | |
Senthil Balasubramanian | 845d708 | 2010-10-05 20:36:41 +0530 | [diff] [blame] | 1251 | static void ath9k_disable_ps(struct ath_softc *sc) |
| 1252 | { |
| 1253 | struct ath_hw *ah = sc->sc_ah; |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 1254 | struct ath_common *common = ath9k_hw_common(ah); |
Senthil Balasubramanian | 845d708 | 2010-10-05 20:36:41 +0530 | [diff] [blame] | 1255 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1256 | if (config_enabled(CONFIG_ATH9K_TX99)) |
| 1257 | return; |
| 1258 | |
Senthil Balasubramanian | 845d708 | 2010-10-05 20:36:41 +0530 | [diff] [blame] | 1259 | sc->ps_enabled = false; |
| 1260 | ath9k_hw_setpower(ah, ATH9K_PM_AWAKE); |
| 1261 | if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) { |
| 1262 | ath9k_hw_setrxabort(ah, 0); |
| 1263 | sc->ps_flags &= ~(PS_WAIT_FOR_BEACON | |
| 1264 | PS_WAIT_FOR_CAB | |
| 1265 | PS_WAIT_FOR_PSPOLL_DATA | |
| 1266 | PS_WAIT_FOR_TX_ACK); |
| 1267 | if (ah->imask & ATH9K_INT_TIM_TIMER) { |
| 1268 | ah->imask &= ~ATH9K_INT_TIM_TIMER; |
Felix Fietkau | 72d874c | 2011-10-08 20:06:19 +0200 | [diff] [blame] | 1269 | ath9k_hw_set_interrupts(ah); |
Senthil Balasubramanian | 845d708 | 2010-10-05 20:36:41 +0530 | [diff] [blame] | 1270 | } |
| 1271 | } |
Sujith Manoharan | ad12886 | 2012-04-24 10:23:20 +0530 | [diff] [blame] | 1272 | ath_dbg(common, PS, "PowerSave disabled\n"); |
Senthil Balasubramanian | 845d708 | 2010-10-05 20:36:41 +0530 | [diff] [blame] | 1273 | } |
| 1274 | |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1275 | void ath9k_spectral_scan_trigger(struct ieee80211_hw *hw) |
| 1276 | { |
| 1277 | struct ath_softc *sc = hw->priv; |
| 1278 | struct ath_hw *ah = sc->sc_ah; |
| 1279 | struct ath_common *common = ath9k_hw_common(ah); |
| 1280 | u32 rxfilter; |
| 1281 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1282 | if (config_enabled(CONFIG_ATH9K_TX99)) |
| 1283 | return; |
| 1284 | |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1285 | if (!ath9k_hw_ops(ah)->spectral_scan_trigger) { |
| 1286 | ath_err(common, "spectrum analyzer not implemented on this hardware\n"); |
| 1287 | return; |
| 1288 | } |
| 1289 | |
| 1290 | ath9k_ps_wakeup(sc); |
| 1291 | rxfilter = ath9k_hw_getrxfilter(ah); |
| 1292 | ath9k_hw_setrxfilter(ah, rxfilter | |
| 1293 | ATH9K_RX_FILTER_PHYRADAR | |
| 1294 | ATH9K_RX_FILTER_PHYERR); |
| 1295 | |
| 1296 | /* TODO: usually this should not be neccesary, but for some reason |
| 1297 | * (or in some mode?) the trigger must be called after the |
| 1298 | * configuration, otherwise the register will have its values reset |
| 1299 | * (on my ar9220 to value 0x01002310) |
| 1300 | */ |
| 1301 | ath9k_spectral_scan_config(hw, sc->spectral_mode); |
| 1302 | ath9k_hw_ops(ah)->spectral_scan_trigger(ah); |
| 1303 | ath9k_ps_restore(sc); |
| 1304 | } |
| 1305 | |
| 1306 | int ath9k_spectral_scan_config(struct ieee80211_hw *hw, |
| 1307 | enum spectral_mode spectral_mode) |
| 1308 | { |
| 1309 | struct ath_softc *sc = hw->priv; |
| 1310 | struct ath_hw *ah = sc->sc_ah; |
| 1311 | struct ath_common *common = ath9k_hw_common(ah); |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1312 | |
| 1313 | if (!ath9k_hw_ops(ah)->spectral_scan_trigger) { |
| 1314 | ath_err(common, "spectrum analyzer not implemented on this hardware\n"); |
| 1315 | return -1; |
| 1316 | } |
| 1317 | |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1318 | switch (spectral_mode) { |
| 1319 | case SPECTRAL_DISABLED: |
Simon Wunderlich | 04ccd4a | 2013-01-23 17:38:04 +0100 | [diff] [blame] | 1320 | sc->spec_config.enabled = 0; |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1321 | break; |
| 1322 | case SPECTRAL_BACKGROUND: |
| 1323 | /* send endless samples. |
| 1324 | * TODO: is this really useful for "background"? |
| 1325 | */ |
Simon Wunderlich | 04ccd4a | 2013-01-23 17:38:04 +0100 | [diff] [blame] | 1326 | sc->spec_config.endless = 1; |
| 1327 | sc->spec_config.enabled = 1; |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1328 | break; |
| 1329 | case SPECTRAL_CHANSCAN: |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1330 | case SPECTRAL_MANUAL: |
Simon Wunderlich | 04ccd4a | 2013-01-23 17:38:04 +0100 | [diff] [blame] | 1331 | sc->spec_config.endless = 0; |
| 1332 | sc->spec_config.enabled = 1; |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1333 | break; |
| 1334 | default: |
| 1335 | return -1; |
| 1336 | } |
| 1337 | |
| 1338 | ath9k_ps_wakeup(sc); |
Simon Wunderlich | 04ccd4a | 2013-01-23 17:38:04 +0100 | [diff] [blame] | 1339 | ath9k_hw_ops(ah)->spectral_scan_config(ah, &sc->spec_config); |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 1340 | ath9k_ps_restore(sc); |
| 1341 | |
| 1342 | sc->spectral_mode = spectral_mode; |
| 1343 | |
| 1344 | return 0; |
| 1345 | } |
| 1346 | |
Johannes Berg | e897558 | 2008-10-09 12:18:51 +0200 | [diff] [blame] | 1347 | static int ath9k_config(struct ieee80211_hw *hw, u32 changed) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1348 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1349 | struct ath_softc *sc = hw->priv; |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1350 | struct ath_hw *ah = sc->sc_ah; |
| 1351 | struct ath_common *common = ath9k_hw_common(ah); |
Johannes Berg | e897558 | 2008-10-09 12:18:51 +0200 | [diff] [blame] | 1352 | struct ieee80211_conf *conf = &hw->conf; |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 1353 | struct ath_chanctx *ctx = sc->cur_chan; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1354 | |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 1355 | ath9k_ps_wakeup(sc); |
Sujith | aa33de0 | 2008-12-18 11:40:16 +0530 | [diff] [blame] | 1356 | mutex_lock(&sc->mutex); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1357 | |
Felix Fietkau | daa1b6e | 2011-11-16 13:08:43 +0100 | [diff] [blame] | 1358 | if (changed & IEEE80211_CONF_CHANGE_IDLE) { |
Felix Fietkau | 7545daf | 2011-01-24 19:23:16 +0100 | [diff] [blame] | 1359 | sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE); |
Rajkumar Manoharan | b73f3e7 | 2012-07-01 19:53:53 +0530 | [diff] [blame] | 1360 | if (sc->ps_idle) { |
Felix Fietkau | daa1b6e | 2011-11-16 13:08:43 +0100 | [diff] [blame] | 1361 | ath_cancel_work(sc); |
Rajkumar Manoharan | b73f3e7 | 2012-07-01 19:53:53 +0530 | [diff] [blame] | 1362 | ath9k_stop_btcoex(sc); |
| 1363 | } else { |
| 1364 | ath9k_start_btcoex(sc); |
Felix Fietkau | 75600ab | 2012-04-12 20:36:31 +0200 | [diff] [blame] | 1365 | /* |
| 1366 | * The chip needs a reset to properly wake up from |
| 1367 | * full sleep |
| 1368 | */ |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 1369 | ath_chanctx_set_channel(sc, ctx, &ctx->chandef); |
Rajkumar Manoharan | b73f3e7 | 2012-07-01 19:53:53 +0530 | [diff] [blame] | 1370 | } |
Felix Fietkau | daa1b6e | 2011-11-16 13:08:43 +0100 | [diff] [blame] | 1371 | } |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 1372 | |
Luis R. Rodriguez | e7824a5 | 2009-11-24 02:53:25 -0500 | [diff] [blame] | 1373 | /* |
| 1374 | * We just prepare to enable PS. We have to wait until our AP has |
| 1375 | * ACK'd our null data frame to disable RX otherwise we'll ignore |
| 1376 | * those ACKs and end up retransmitting the same null data frames. |
| 1377 | * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode. |
| 1378 | */ |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1379 | if (changed & IEEE80211_CONF_CHANGE_PS) { |
Luis R. Rodriguez | 8ab2cd0 | 2010-09-16 15:12:26 -0400 | [diff] [blame] | 1380 | unsigned long flags; |
| 1381 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
Senthil Balasubramanian | fbab739 | 2010-10-05 20:36:40 +0530 | [diff] [blame] | 1382 | if (conf->flags & IEEE80211_CONF_PS) |
| 1383 | ath9k_enable_ps(sc); |
Senthil Balasubramanian | 845d708 | 2010-10-05 20:36:41 +0530 | [diff] [blame] | 1384 | else |
| 1385 | ath9k_disable_ps(sc); |
Luis R. Rodriguez | 8ab2cd0 | 2010-09-16 15:12:26 -0400 | [diff] [blame] | 1386 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1387 | } |
| 1388 | |
Sujith | 199afd9 | 2010-01-08 10:36:13 +0530 | [diff] [blame] | 1389 | if (changed & IEEE80211_CONF_CHANGE_MONITOR) { |
| 1390 | if (conf->flags & IEEE80211_CONF_MONITOR) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1391 | ath_dbg(common, CONFIG, "Monitor mode is enabled\n"); |
Rajkumar Manoharan | 5f841b4 | 2010-10-27 18:31:15 +0530 | [diff] [blame] | 1392 | sc->sc_ah->is_monitoring = true; |
| 1393 | } else { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1394 | ath_dbg(common, CONFIG, "Monitor mode is disabled\n"); |
Rajkumar Manoharan | 5f841b4 | 2010-10-27 18:31:15 +0530 | [diff] [blame] | 1395 | sc->sc_ah->is_monitoring = false; |
Sujith | 199afd9 | 2010-01-08 10:36:13 +0530 | [diff] [blame] | 1396 | } |
| 1397 | } |
| 1398 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 1399 | if (!ath9k_is_chanctx_enabled() && (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { |
Felix Fietkau | fbbcd14 | 2014-06-11 16:17:49 +0530 | [diff] [blame] | 1400 | ctx->offchannel = !!(conf->flags & IEEE80211_CONF_OFFCHANNEL); |
Felix Fietkau | bff1176 | 2014-06-11 16:17:52 +0530 | [diff] [blame] | 1401 | ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef); |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 1402 | } |
Sujith | 86b89ee | 2008-08-07 10:54:57 +0530 | [diff] [blame] | 1403 | |
Luis R. Rodriguez | c9f6a65 | 2010-01-19 14:04:19 -0500 | [diff] [blame] | 1404 | if (changed & IEEE80211_CONF_CHANGE_POWER) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1405 | ath_dbg(common, CONFIG, "Set power: %d\n", conf->power_level); |
Felix Fietkau | bc7e1be | 2014-06-11 16:17:50 +0530 | [diff] [blame] | 1406 | sc->cur_chan->txpower = 2 * conf->power_level; |
Rajkumar Manoharan | 5048e8c | 2011-01-31 23:47:44 +0530 | [diff] [blame] | 1407 | ath9k_cmn_update_txpow(ah, sc->curtxpow, |
Felix Fietkau | bc7e1be | 2014-06-11 16:17:50 +0530 | [diff] [blame] | 1408 | sc->cur_chan->txpower, &sc->curtxpow); |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 1409 | } |
| 1410 | |
Sujith | aa33de0 | 2008-12-18 11:40:16 +0530 | [diff] [blame] | 1411 | mutex_unlock(&sc->mutex); |
Felix Fietkau | c0c1174 | 2011-11-16 13:08:41 +0100 | [diff] [blame] | 1412 | ath9k_ps_restore(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1413 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1414 | return 0; |
| 1415 | } |
| 1416 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1417 | #define SUPPORTED_FILTERS \ |
| 1418 | (FIF_PROMISC_IN_BSS | \ |
| 1419 | FIF_ALLMULTI | \ |
| 1420 | FIF_CONTROL | \ |
Luis R. Rodriguez | af6a3fc | 2009-08-08 21:55:16 -0400 | [diff] [blame] | 1421 | FIF_PSPOLL | \ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1422 | FIF_OTHER_BSS | \ |
| 1423 | FIF_BCN_PRBRESP_PROMISC | \ |
Jouni Malinen | 9c1d8e4 | 2010-10-13 17:29:31 +0300 | [diff] [blame] | 1424 | FIF_PROBE_REQ | \ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1425 | FIF_FCSFAIL) |
| 1426 | |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 1427 | /* FIXME: sc->sc_full_reset ? */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1428 | static void ath9k_configure_filter(struct ieee80211_hw *hw, |
| 1429 | unsigned int changed_flags, |
| 1430 | unsigned int *total_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 1431 | u64 multicast) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1432 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1433 | struct ath_softc *sc = hw->priv; |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 1434 | u32 rfilt; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1435 | |
| 1436 | changed_flags &= SUPPORTED_FILTERS; |
| 1437 | *total_flags &= SUPPORTED_FILTERS; |
| 1438 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1439 | sc->rx.rxfilter = *total_flags; |
Jouni Malinen | aa68aea | 2009-05-19 17:01:41 +0300 | [diff] [blame] | 1440 | ath9k_ps_wakeup(sc); |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 1441 | rfilt = ath_calcrxfilter(sc); |
| 1442 | ath9k_hw_setrxfilter(sc->sc_ah, rfilt); |
Jouni Malinen | aa68aea | 2009-05-19 17:01:41 +0300 | [diff] [blame] | 1443 | ath9k_ps_restore(sc); |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 1444 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1445 | ath_dbg(ath9k_hw_common(sc->sc_ah), CONFIG, "Set HW RX filter: 0x%x\n", |
| 1446 | rfilt); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1447 | } |
| 1448 | |
Johannes Berg | 4ca7786 | 2010-02-19 19:06:56 +0100 | [diff] [blame] | 1449 | static int ath9k_sta_add(struct ieee80211_hw *hw, |
| 1450 | struct ieee80211_vif *vif, |
| 1451 | struct ieee80211_sta *sta) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1452 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1453 | struct ath_softc *sc = hw->priv; |
Felix Fietkau | 93ae2dd | 2011-04-17 23:28:10 +0200 | [diff] [blame] | 1454 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 1455 | struct ath_node *an = (struct ath_node *) sta->drv_priv; |
| 1456 | struct ieee80211_key_conf ps_key = { }; |
Felix Fietkau | 4ef69d0 | 2013-04-27 11:47:01 +0200 | [diff] [blame] | 1457 | int key; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1458 | |
Ben Greear | 7e1e386 | 2011-11-03 11:33:13 -0700 | [diff] [blame] | 1459 | ath_node_attach(sc, sta, vif); |
Felix Fietkau | f59a59f | 2011-05-10 20:52:22 +0200 | [diff] [blame] | 1460 | |
| 1461 | if (vif->type != NL80211_IFTYPE_AP && |
| 1462 | vif->type != NL80211_IFTYPE_AP_VLAN) |
| 1463 | return 0; |
| 1464 | |
Felix Fietkau | 4ef69d0 | 2013-04-27 11:47:01 +0200 | [diff] [blame] | 1465 | key = ath_key_config(common, vif, sta, &ps_key); |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1466 | if (key > 0) { |
Felix Fietkau | 4ef69d0 | 2013-04-27 11:47:01 +0200 | [diff] [blame] | 1467 | an->ps_key = key; |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1468 | an->key_idx[0] = key; |
| 1469 | } |
Johannes Berg | 4ca7786 | 2010-02-19 19:06:56 +0100 | [diff] [blame] | 1470 | |
| 1471 | return 0; |
| 1472 | } |
| 1473 | |
Felix Fietkau | 93ae2dd | 2011-04-17 23:28:10 +0200 | [diff] [blame] | 1474 | static void ath9k_del_ps_key(struct ath_softc *sc, |
| 1475 | struct ieee80211_vif *vif, |
| 1476 | struct ieee80211_sta *sta) |
| 1477 | { |
| 1478 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 1479 | struct ath_node *an = (struct ath_node *) sta->drv_priv; |
| 1480 | struct ieee80211_key_conf ps_key = { .hw_key_idx = an->ps_key }; |
| 1481 | |
| 1482 | if (!an->ps_key) |
| 1483 | return; |
| 1484 | |
| 1485 | ath_key_delete(common, &ps_key); |
Felix Fietkau | 4ef69d0 | 2013-04-27 11:47:01 +0200 | [diff] [blame] | 1486 | an->ps_key = 0; |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1487 | an->key_idx[0] = 0; |
Felix Fietkau | 93ae2dd | 2011-04-17 23:28:10 +0200 | [diff] [blame] | 1488 | } |
| 1489 | |
Johannes Berg | 4ca7786 | 2010-02-19 19:06:56 +0100 | [diff] [blame] | 1490 | static int ath9k_sta_remove(struct ieee80211_hw *hw, |
| 1491 | struct ieee80211_vif *vif, |
| 1492 | struct ieee80211_sta *sta) |
| 1493 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1494 | struct ath_softc *sc = hw->priv; |
Johannes Berg | 4ca7786 | 2010-02-19 19:06:56 +0100 | [diff] [blame] | 1495 | |
Felix Fietkau | 93ae2dd | 2011-04-17 23:28:10 +0200 | [diff] [blame] | 1496 | ath9k_del_ps_key(sc, vif, sta); |
Johannes Berg | 4ca7786 | 2010-02-19 19:06:56 +0100 | [diff] [blame] | 1497 | ath_node_detach(sc, sta); |
| 1498 | |
| 1499 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1500 | } |
| 1501 | |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1502 | static void ath9k_sta_set_tx_filter(struct ath_hw *ah, |
| 1503 | struct ath_node *an, |
| 1504 | bool set) |
| 1505 | { |
| 1506 | int i; |
| 1507 | |
| 1508 | for (i = 0; i < ARRAY_SIZE(an->key_idx); i++) { |
| 1509 | if (!an->key_idx[i]) |
| 1510 | continue; |
| 1511 | ath9k_hw_set_tx_filter(ah, an->key_idx[i], set); |
| 1512 | } |
| 1513 | } |
| 1514 | |
Felix Fietkau | 5519541 | 2011-04-17 23:28:09 +0200 | [diff] [blame] | 1515 | static void ath9k_sta_notify(struct ieee80211_hw *hw, |
| 1516 | struct ieee80211_vif *vif, |
| 1517 | enum sta_notify_cmd cmd, |
| 1518 | struct ieee80211_sta *sta) |
| 1519 | { |
| 1520 | struct ath_softc *sc = hw->priv; |
| 1521 | struct ath_node *an = (struct ath_node *) sta->drv_priv; |
| 1522 | |
| 1523 | switch (cmd) { |
| 1524 | case STA_NOTIFY_SLEEP: |
| 1525 | an->sleeping = true; |
Johannes Berg | 042ec45 | 2011-09-29 16:04:26 +0200 | [diff] [blame] | 1526 | ath_tx_aggr_sleep(sta, sc, an); |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1527 | ath9k_sta_set_tx_filter(sc->sc_ah, an, true); |
Felix Fietkau | 5519541 | 2011-04-17 23:28:09 +0200 | [diff] [blame] | 1528 | break; |
| 1529 | case STA_NOTIFY_AWAKE: |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1530 | ath9k_sta_set_tx_filter(sc->sc_ah, an, false); |
Felix Fietkau | 5519541 | 2011-04-17 23:28:09 +0200 | [diff] [blame] | 1531 | an->sleeping = false; |
| 1532 | ath_tx_aggr_wakeup(sc, an); |
| 1533 | break; |
| 1534 | } |
| 1535 | } |
| 1536 | |
Eliad Peller | 8a3a3c8 | 2011-10-02 10:15:52 +0200 | [diff] [blame] | 1537 | static int ath9k_conf_tx(struct ieee80211_hw *hw, |
| 1538 | struct ieee80211_vif *vif, u16 queue, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1539 | const struct ieee80211_tx_queue_params *params) |
| 1540 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1541 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1542 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 1543 | struct ath_txq *txq; |
Sujith | ea9880f | 2008-08-07 10:53:10 +0530 | [diff] [blame] | 1544 | struct ath9k_tx_queue_info qi; |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 1545 | int ret = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1546 | |
Sujith Manoharan | bea843c | 2012-11-21 18:13:10 +0530 | [diff] [blame] | 1547 | if (queue >= IEEE80211_NUM_ACS) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1548 | return 0; |
| 1549 | |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 1550 | txq = sc->tx.txq_map[queue]; |
| 1551 | |
Felix Fietkau | 96f372c | 2011-04-07 19:07:17 +0200 | [diff] [blame] | 1552 | ath9k_ps_wakeup(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1553 | mutex_lock(&sc->mutex); |
| 1554 | |
Sujith | 1ffb061 | 2009-03-30 15:28:46 +0530 | [diff] [blame] | 1555 | memset(&qi, 0, sizeof(struct ath9k_tx_queue_info)); |
| 1556 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1557 | qi.tqi_aifs = params->aifs; |
| 1558 | qi.tqi_cwmin = params->cw_min; |
| 1559 | qi.tqi_cwmax = params->cw_max; |
Felix Fietkau | 531bd07 | 2012-07-15 19:53:34 +0200 | [diff] [blame] | 1560 | qi.tqi_burstTime = params->txop * 32; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1561 | |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1562 | ath_dbg(common, CONFIG, |
Joe Perches | 226afe6 | 2010-12-02 19:12:37 -0800 | [diff] [blame] | 1563 | "Configure tx [queue/halq] [%d/%d], aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n", |
| 1564 | queue, txq->axq_qnum, params->aifs, params->cw_min, |
| 1565 | params->cw_max, params->txop); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1566 | |
Felix Fietkau | aa5955c | 2012-07-15 19:53:36 +0200 | [diff] [blame] | 1567 | ath_update_max_aggr_framelen(sc, queue, qi.tqi_burstTime); |
Felix Fietkau | 066dae9 | 2010-11-07 14:59:39 +0100 | [diff] [blame] | 1568 | ret = ath_txq_update(sc, txq->axq_qnum, &qi); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1569 | if (ret) |
Joe Perches | 3800276 | 2010-12-02 19:12:36 -0800 | [diff] [blame] | 1570 | ath_err(common, "TXQ Update failed\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1571 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1572 | mutex_unlock(&sc->mutex); |
Felix Fietkau | 96f372c | 2011-04-07 19:07:17 +0200 | [diff] [blame] | 1573 | ath9k_ps_restore(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1574 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1575 | return ret; |
| 1576 | } |
| 1577 | |
| 1578 | static int ath9k_set_key(struct ieee80211_hw *hw, |
| 1579 | enum set_key_cmd cmd, |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 1580 | struct ieee80211_vif *vif, |
| 1581 | struct ieee80211_sta *sta, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1582 | struct ieee80211_key_conf *key) |
| 1583 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1584 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1585 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1586 | struct ath_node *an = NULL; |
| 1587 | int ret = 0, i; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1588 | |
John W. Linville | 3e6109c | 2011-01-05 09:39:17 -0500 | [diff] [blame] | 1589 | if (ath9k_modparam_nohwcrypt) |
Jouni Malinen | b3bd89c | 2009-02-24 13:42:01 +0200 | [diff] [blame] | 1590 | return -ENOSPC; |
| 1591 | |
Chun-Yeow Yeoh | 5bd5e9a | 2011-12-07 12:45:46 -0800 | [diff] [blame] | 1592 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
| 1593 | vif->type == NL80211_IFTYPE_MESH_POINT) && |
Jouni Malinen | cfdc9a8 | 2011-03-23 14:52:19 +0200 | [diff] [blame] | 1594 | (key->cipher == WLAN_CIPHER_SUITE_TKIP || |
| 1595 | key->cipher == WLAN_CIPHER_SUITE_CCMP) && |
| 1596 | !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { |
| 1597 | /* |
| 1598 | * For now, disable hw crypto for the RSN IBSS group keys. This |
| 1599 | * could be optimized in the future to use a modified key cache |
| 1600 | * design to support per-STA RX GTK, but until that gets |
| 1601 | * implemented, use of software crypto for group addressed |
| 1602 | * frames is a acceptable to allow RSN IBSS to be used. |
| 1603 | */ |
| 1604 | return -EOPNOTSUPP; |
| 1605 | } |
| 1606 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1607 | mutex_lock(&sc->mutex); |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1608 | ath9k_ps_wakeup(sc); |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1609 | ath_dbg(common, CONFIG, "Set HW Key %d\n", cmd); |
| 1610 | if (sta) |
| 1611 | an = (struct ath_node *)sta->drv_priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1612 | |
| 1613 | switch (cmd) { |
| 1614 | case SET_KEY: |
Felix Fietkau | 93ae2dd | 2011-04-17 23:28:10 +0200 | [diff] [blame] | 1615 | if (sta) |
| 1616 | ath9k_del_ps_key(sc, vif, sta); |
| 1617 | |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1618 | key->hw_key_idx = 0; |
Bruno Randolf | 040e539 | 2010-09-08 16:05:04 +0900 | [diff] [blame] | 1619 | ret = ath_key_config(common, vif, sta, key); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 1620 | if (ret >= 0) { |
| 1621 | key->hw_key_idx = ret; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1622 | /* push IV and Michael MIC generation to stack */ |
| 1623 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 1624 | if (key->cipher == WLAN_CIPHER_SUITE_TKIP) |
Senthil Balasubramanian | 1b96175 | 2008-09-01 19:45:21 +0530 | [diff] [blame] | 1625 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
Johannes Berg | 97359d1 | 2010-08-10 09:46:38 +0200 | [diff] [blame] | 1626 | if (sc->sc_ah->sw_mgmt_crypto && |
| 1627 | key->cipher == WLAN_CIPHER_SUITE_CCMP) |
Johannes Berg | e548c49 | 2012-09-04 17:08:23 +0200 | [diff] [blame] | 1628 | key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX; |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 1629 | ret = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1630 | } |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1631 | if (an && key->hw_key_idx) { |
| 1632 | for (i = 0; i < ARRAY_SIZE(an->key_idx); i++) { |
| 1633 | if (an->key_idx[i]) |
| 1634 | continue; |
| 1635 | an->key_idx[i] = key->hw_key_idx; |
| 1636 | break; |
| 1637 | } |
| 1638 | WARN_ON(i == ARRAY_SIZE(an->key_idx)); |
| 1639 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1640 | break; |
| 1641 | case DISABLE_KEY: |
Bruno Randolf | 040e539 | 2010-09-08 16:05:04 +0900 | [diff] [blame] | 1642 | ath_key_delete(common, key); |
Rajkumar Manoharan | 4bbf441 | 2014-05-22 12:35:49 +0530 | [diff] [blame] | 1643 | if (an) { |
| 1644 | for (i = 0; i < ARRAY_SIZE(an->key_idx); i++) { |
| 1645 | if (an->key_idx[i] != key->hw_key_idx) |
| 1646 | continue; |
| 1647 | an->key_idx[i] = 0; |
| 1648 | break; |
| 1649 | } |
| 1650 | } |
| 1651 | key->hw_key_idx = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1652 | break; |
| 1653 | default: |
| 1654 | ret = -EINVAL; |
| 1655 | } |
| 1656 | |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1657 | ath9k_ps_restore(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1658 | mutex_unlock(&sc->mutex); |
| 1659 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1660 | return ret; |
| 1661 | } |
Sujith Manoharan | 6c43c090 | 2012-07-17 17:15:50 +0530 | [diff] [blame] | 1662 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1663 | static void ath9k_bss_info_changed(struct ieee80211_hw *hw, |
| 1664 | struct ieee80211_vif *vif, |
| 1665 | struct ieee80211_bss_conf *bss_conf, |
| 1666 | u32 changed) |
| 1667 | { |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 1668 | #define CHECK_ANI \ |
| 1669 | (BSS_CHANGED_ASSOC | \ |
| 1670 | BSS_CHANGED_IBSS | \ |
| 1671 | BSS_CHANGED_BEACON_ENABLED) |
| 1672 | |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1673 | struct ath_softc *sc = hw->priv; |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1674 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1675 | struct ath_common *common = ath9k_hw_common(ah); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1676 | struct ath_vif *avp = (void *)vif->drv_priv; |
Felix Fietkau | 0005baf | 2010-01-15 02:33:40 +0100 | [diff] [blame] | 1677 | int slottime; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1678 | |
Felix Fietkau | 96f372c | 2011-04-07 19:07:17 +0200 | [diff] [blame] | 1679 | ath9k_ps_wakeup(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1680 | mutex_lock(&sc->mutex); |
| 1681 | |
Rajkumar Manoharan | 9f61903 | 2012-03-10 05:06:49 +0530 | [diff] [blame] | 1682 | if (changed & BSS_CHANGED_ASSOC) { |
Sujith Manoharan | 6c43c090 | 2012-07-17 17:15:50 +0530 | [diff] [blame] | 1683 | ath_dbg(common, CONFIG, "BSSID %pM Changed ASSOC %d\n", |
| 1684 | bss_conf->bssid, bss_conf->assoc); |
Sujith | c6089cc | 2009-11-16 11:40:48 +0530 | [diff] [blame] | 1685 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1686 | ath9k_calculate_summary_state(sc, avp->chanctx); |
Felix Fietkau | 73fa2f2 | 2014-06-11 16:18:10 +0530 | [diff] [blame] | 1687 | if (bss_conf->assoc) |
| 1688 | ath_chanctx_event(sc, vif, ATH_CHANCTX_EVENT_ASSOC); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1689 | } |
| 1690 | |
Rajkumar Manoharan | 2e5ef45 | 2011-05-20 17:52:12 +0530 | [diff] [blame] | 1691 | if (changed & BSS_CHANGED_IBSS) { |
Rajkumar Manoharan | 2e5ef45 | 2011-05-20 17:52:12 +0530 | [diff] [blame] | 1692 | memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN); |
| 1693 | common->curaid = bss_conf->aid; |
| 1694 | ath9k_hw_write_associd(sc->sc_ah); |
Rajkumar Manoharan | 2e5ef45 | 2011-05-20 17:52:12 +0530 | [diff] [blame] | 1695 | } |
| 1696 | |
Sujith Manoharan | ef4ad63 | 2012-07-17 17:15:56 +0530 | [diff] [blame] | 1697 | if ((changed & BSS_CHANGED_BEACON_ENABLED) || |
Rajkumar Manoharan | 9198cf4 | 2014-06-26 16:54:40 +0530 | [diff] [blame] | 1698 | (changed & BSS_CHANGED_BEACON_INT) || |
| 1699 | (changed & BSS_CHANGED_BEACON_INFO)) { |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1700 | if (changed & BSS_CHANGED_BEACON_ENABLED) |
| 1701 | ath9k_calculate_summary_state(sc, avp->chanctx); |
Felix Fietkau | c32e4e5 | 2013-12-19 18:01:49 +0100 | [diff] [blame] | 1702 | ath9k_beacon_config(sc, vif, changed); |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1703 | } |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1704 | |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 1705 | if ((avp->chanctx == sc->cur_chan) && |
| 1706 | (changed & BSS_CHANGED_ERP_SLOT)) { |
Felix Fietkau | 0005baf | 2010-01-15 02:33:40 +0100 | [diff] [blame] | 1707 | if (bss_conf->use_short_slot) |
| 1708 | slottime = 9; |
| 1709 | else |
| 1710 | slottime = 20; |
| 1711 | if (vif->type == NL80211_IFTYPE_AP) { |
| 1712 | /* |
| 1713 | * Defer update, so that connected stations can adjust |
| 1714 | * their settings at the same time. |
| 1715 | * See beacon.c for more details |
| 1716 | */ |
| 1717 | sc->beacon.slottime = slottime; |
| 1718 | sc->beacon.updateslot = UPDATE; |
| 1719 | } else { |
| 1720 | ah->slottime = slottime; |
| 1721 | ath9k_hw_init_global_settings(ah); |
| 1722 | } |
| 1723 | } |
| 1724 | |
Sujith Manoharan | c7dd40c | 2014-08-22 20:39:30 +0530 | [diff] [blame] | 1725 | if (changed & BSS_CHANGED_P2P_PS) |
| 1726 | ath9k_p2p_bss_info_changed(sc, vif); |
Felix Fietkau | d463af4 | 2014-04-06 00:37:03 +0200 | [diff] [blame] | 1727 | |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 1728 | if (changed & CHECK_ANI) |
| 1729 | ath_check_ani(sc); |
| 1730 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1731 | mutex_unlock(&sc->mutex); |
Felix Fietkau | 96f372c | 2011-04-07 19:07:17 +0200 | [diff] [blame] | 1732 | ath9k_ps_restore(sc); |
Sujith Manoharan | da0d45f | 2012-07-17 17:16:29 +0530 | [diff] [blame] | 1733 | |
| 1734 | #undef CHECK_ANI |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1735 | } |
| 1736 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 1737 | static u64 ath9k_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1738 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1739 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1740 | u64 tsf; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1741 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1742 | mutex_lock(&sc->mutex); |
Sujith Manoharan | 9abbfb2 | 2010-12-10 11:27:06 +0530 | [diff] [blame] | 1743 | ath9k_ps_wakeup(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1744 | tsf = ath9k_hw_gettsf64(sc->sc_ah); |
Sujith Manoharan | 9abbfb2 | 2010-12-10 11:27:06 +0530 | [diff] [blame] | 1745 | ath9k_ps_restore(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1746 | mutex_unlock(&sc->mutex); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1747 | |
| 1748 | return tsf; |
| 1749 | } |
| 1750 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 1751 | static void ath9k_set_tsf(struct ieee80211_hw *hw, |
| 1752 | struct ieee80211_vif *vif, |
| 1753 | u64 tsf) |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 1754 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1755 | struct ath_softc *sc = hw->priv; |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 1756 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1757 | mutex_lock(&sc->mutex); |
Sujith Manoharan | 9abbfb2 | 2010-12-10 11:27:06 +0530 | [diff] [blame] | 1758 | ath9k_ps_wakeup(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1759 | ath9k_hw_settsf64(sc->sc_ah, tsf); |
Sujith Manoharan | 9abbfb2 | 2010-12-10 11:27:06 +0530 | [diff] [blame] | 1760 | ath9k_ps_restore(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1761 | mutex_unlock(&sc->mutex); |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 1762 | } |
| 1763 | |
Eliad Peller | 37a41b4 | 2011-09-21 14:06:11 +0300 | [diff] [blame] | 1764 | static void ath9k_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1765 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1766 | struct ath_softc *sc = hw->priv; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1767 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1768 | mutex_lock(&sc->mutex); |
Luis R. Rodriguez | 21526d5 | 2009-09-09 20:05:39 -0700 | [diff] [blame] | 1769 | |
| 1770 | ath9k_ps_wakeup(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1771 | ath9k_hw_reset_tsf(sc->sc_ah); |
Luis R. Rodriguez | 21526d5 | 2009-09-09 20:05:39 -0700 | [diff] [blame] | 1772 | ath9k_ps_restore(sc); |
| 1773 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1774 | mutex_unlock(&sc->mutex); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1775 | } |
| 1776 | |
| 1777 | static int ath9k_ampdu_action(struct ieee80211_hw *hw, |
Johannes Berg | c951ad3 | 2009-11-16 12:00:38 +0100 | [diff] [blame] | 1778 | struct ieee80211_vif *vif, |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1779 | enum ieee80211_ampdu_mlme_action action, |
| 1780 | struct ieee80211_sta *sta, |
Johannes Berg | 0b01f03 | 2011-01-18 13:51:05 +0100 | [diff] [blame] | 1781 | u16 tid, u16 *ssn, u8 buf_size) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1782 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1783 | struct ath_softc *sc = hw->priv; |
Felix Fietkau | 16e2342 | 2013-05-17 12:58:24 +0200 | [diff] [blame] | 1784 | bool flush = false; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1785 | int ret = 0; |
| 1786 | |
Sujith Manoharan | 7ca7c77 | 2013-05-08 05:03:32 +0530 | [diff] [blame] | 1787 | mutex_lock(&sc->mutex); |
Johannes Berg | 85ad181 | 2010-06-10 10:21:49 +0200 | [diff] [blame] | 1788 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1789 | switch (action) { |
| 1790 | case IEEE80211_AMPDU_RX_START: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1791 | break; |
| 1792 | case IEEE80211_AMPDU_RX_STOP: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1793 | break; |
| 1794 | case IEEE80211_AMPDU_TX_START: |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 1795 | ath9k_ps_wakeup(sc); |
Felix Fietkau | 231c3a1 | 2010-09-20 19:35:28 +0200 | [diff] [blame] | 1796 | ret = ath_tx_aggr_start(sc, sta, tid, ssn); |
| 1797 | if (!ret) |
| 1798 | ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 1799 | ath9k_ps_restore(sc); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1800 | break; |
Johannes Berg | 18b559d | 2012-07-18 13:51:25 +0200 | [diff] [blame] | 1801 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
| 1802 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: |
Felix Fietkau | 16e2342 | 2013-05-17 12:58:24 +0200 | [diff] [blame] | 1803 | flush = true; |
| 1804 | case IEEE80211_AMPDU_TX_STOP_CONT: |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 1805 | ath9k_ps_wakeup(sc); |
Sujith | f83da96 | 2009-07-23 15:32:37 +0530 | [diff] [blame] | 1806 | ath_tx_aggr_stop(sc, sta, tid); |
Felix Fietkau | 08c96ab | 2013-05-18 21:28:15 +0200 | [diff] [blame] | 1807 | if (!flush) |
Felix Fietkau | 16e2342 | 2013-05-17 12:58:24 +0200 | [diff] [blame] | 1808 | ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 1809 | ath9k_ps_restore(sc); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1810 | break; |
Johannes Berg | b172023 | 2009-03-23 17:28:39 +0100 | [diff] [blame] | 1811 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 1812 | ath9k_ps_wakeup(sc); |
Sujith | 8469cde | 2008-10-29 10:19:28 +0530 | [diff] [blame] | 1813 | ath_tx_aggr_resume(sc, sta, tid); |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 1814 | ath9k_ps_restore(sc); |
Sujith | 8469cde | 2008-10-29 10:19:28 +0530 | [diff] [blame] | 1815 | break; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1816 | default: |
Joe Perches | 3800276 | 2010-12-02 19:12:36 -0800 | [diff] [blame] | 1817 | ath_err(ath9k_hw_common(sc->sc_ah), "Unknown AMPDU action\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1818 | } |
| 1819 | |
Sujith Manoharan | 7ca7c77 | 2013-05-08 05:03:32 +0530 | [diff] [blame] | 1820 | mutex_unlock(&sc->mutex); |
Johannes Berg | 85ad181 | 2010-06-10 10:21:49 +0200 | [diff] [blame] | 1821 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1822 | return ret; |
| 1823 | } |
| 1824 | |
Benoit Papillault | 62dad5b | 2010-04-28 00:08:24 +0200 | [diff] [blame] | 1825 | static int ath9k_get_survey(struct ieee80211_hw *hw, int idx, |
| 1826 | struct survey_info *survey) |
| 1827 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1828 | struct ath_softc *sc = hw->priv; |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1829 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 39162db | 2010-09-29 19:12:06 +0200 | [diff] [blame] | 1830 | struct ieee80211_supported_band *sband; |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1831 | struct ieee80211_channel *chan; |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1832 | int pos; |
| 1833 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1834 | if (config_enabled(CONFIG_ATH9K_TX99)) |
| 1835 | return -EOPNOTSUPP; |
| 1836 | |
Sujith Manoharan | b7cc9b9 | 2013-12-26 08:14:40 +0530 | [diff] [blame] | 1837 | spin_lock_bh(&common->cc_lock); |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1838 | if (idx == 0) |
| 1839 | ath_update_survey_stats(sc); |
Benoit Papillault | 62dad5b | 2010-04-28 00:08:24 +0200 | [diff] [blame] | 1840 | |
Felix Fietkau | 39162db | 2010-09-29 19:12:06 +0200 | [diff] [blame] | 1841 | sband = hw->wiphy->bands[IEEE80211_BAND_2GHZ]; |
| 1842 | if (sband && idx >= sband->n_channels) { |
| 1843 | idx -= sband->n_channels; |
| 1844 | sband = NULL; |
| 1845 | } |
Benoit Papillault | 62dad5b | 2010-04-28 00:08:24 +0200 | [diff] [blame] | 1846 | |
Felix Fietkau | 39162db | 2010-09-29 19:12:06 +0200 | [diff] [blame] | 1847 | if (!sband) |
| 1848 | sband = hw->wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 1849 | |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1850 | if (!sband || idx >= sband->n_channels) { |
Sujith Manoharan | b7cc9b9 | 2013-12-26 08:14:40 +0530 | [diff] [blame] | 1851 | spin_unlock_bh(&common->cc_lock); |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1852 | return -ENOENT; |
Felix Fietkau | 4f1a5a4 | 2010-09-29 17:15:28 +0200 | [diff] [blame] | 1853 | } |
Benoit Papillault | 62dad5b | 2010-04-28 00:08:24 +0200 | [diff] [blame] | 1854 | |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1855 | chan = &sband->channels[idx]; |
| 1856 | pos = chan->hw_value; |
| 1857 | memcpy(survey, &sc->survey[pos], sizeof(*survey)); |
| 1858 | survey->channel = chan; |
Sujith Manoharan | b7cc9b9 | 2013-12-26 08:14:40 +0530 | [diff] [blame] | 1859 | spin_unlock_bh(&common->cc_lock); |
Felix Fietkau | 3430098 | 2010-10-10 18:21:52 +0200 | [diff] [blame] | 1860 | |
Benoit Papillault | 62dad5b | 2010-04-28 00:08:24 +0200 | [diff] [blame] | 1861 | return 0; |
| 1862 | } |
| 1863 | |
Felix Fietkau | e239d85 | 2010-01-15 02:34:58 +0100 | [diff] [blame] | 1864 | static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class) |
| 1865 | { |
Felix Fietkau | 9ac58615 | 2011-01-24 19:23:18 +0100 | [diff] [blame] | 1866 | struct ath_softc *sc = hw->priv; |
Felix Fietkau | e239d85 | 2010-01-15 02:34:58 +0100 | [diff] [blame] | 1867 | struct ath_hw *ah = sc->sc_ah; |
| 1868 | |
Luis R. Rodriguez | 89f927a | 2013-10-14 17:42:11 -0700 | [diff] [blame] | 1869 | if (config_enabled(CONFIG_ATH9K_TX99)) |
| 1870 | return; |
| 1871 | |
Felix Fietkau | e239d85 | 2010-01-15 02:34:58 +0100 | [diff] [blame] | 1872 | mutex_lock(&sc->mutex); |
| 1873 | ah->coverage_class = coverage_class; |
Mohammed Shafi Shajakhan | 8b2a3827 | 2011-08-24 21:38:07 +0530 | [diff] [blame] | 1874 | |
| 1875 | ath9k_ps_wakeup(sc); |
Felix Fietkau | e239d85 | 2010-01-15 02:34:58 +0100 | [diff] [blame] | 1876 | ath9k_hw_init_global_settings(ah); |
Mohammed Shafi Shajakhan | 8b2a3827 | 2011-08-24 21:38:07 +0530 | [diff] [blame] | 1877 | ath9k_ps_restore(sc); |
| 1878 | |
Felix Fietkau | e239d85 | 2010-01-15 02:34:58 +0100 | [diff] [blame] | 1879 | mutex_unlock(&sc->mutex); |
| 1880 | } |
| 1881 | |
Felix Fietkau | 10e2318 | 2013-11-11 22:23:35 +0100 | [diff] [blame] | 1882 | static bool ath9k_has_tx_pending(struct ath_softc *sc) |
| 1883 | { |
Geert Uytterhoeven | f783807 | 2014-01-26 11:53:21 +0100 | [diff] [blame] | 1884 | int i, npend = 0; |
Felix Fietkau | 10e2318 | 2013-11-11 22:23:35 +0100 | [diff] [blame] | 1885 | |
| 1886 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { |
| 1887 | if (!ATH_TXQ_SETUP(sc, i)) |
| 1888 | continue; |
| 1889 | |
| 1890 | if (!sc->tx.txq[i].axq_depth) |
| 1891 | continue; |
| 1892 | |
| 1893 | npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]); |
| 1894 | if (npend) |
| 1895 | break; |
| 1896 | } |
| 1897 | |
| 1898 | return !!npend; |
| 1899 | } |
| 1900 | |
Emmanuel Grumbach | 77be2c5 | 2014-03-27 11:30:29 +0200 | [diff] [blame] | 1901 | static void ath9k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 1902 | u32 queues, bool drop) |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 1903 | { |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 1904 | struct ath_softc *sc = hw->priv; |
Felix Fietkau | bff1176 | 2014-06-11 16:17:52 +0530 | [diff] [blame] | 1905 | |
| 1906 | mutex_lock(&sc->mutex); |
| 1907 | __ath9k_flush(hw, queues, drop); |
| 1908 | mutex_unlock(&sc->mutex); |
| 1909 | } |
| 1910 | |
| 1911 | void __ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop) |
| 1912 | { |
| 1913 | struct ath_softc *sc = hw->priv; |
Mohammed Shafi Shajakhan | 99aa55b | 2011-05-06 20:43:11 +0530 | [diff] [blame] | 1914 | struct ath_hw *ah = sc->sc_ah; |
| 1915 | struct ath_common *common = ath9k_hw_common(ah); |
Felix Fietkau | 10e2318 | 2013-11-11 22:23:35 +0100 | [diff] [blame] | 1916 | int timeout = HZ / 5; /* 200 ms */ |
Rajkumar Manoharan | 2f6fc35 | 2011-04-28 15:31:57 +0530 | [diff] [blame] | 1917 | bool drain_txq; |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 1918 | int i; |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 1919 | |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 1920 | cancel_delayed_work_sync(&sc->tx_complete_work); |
| 1921 | |
Mohammed Shafi Shajakhan | 6a6b3f3 | 2011-09-09 10:41:08 +0530 | [diff] [blame] | 1922 | if (ah->ah_flags & AH_UNPLUGGED) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1923 | ath_dbg(common, ANY, "Device has been unplugged!\n"); |
Mohammed Shafi Shajakhan | 6a6b3f3 | 2011-09-09 10:41:08 +0530 | [diff] [blame] | 1924 | return; |
| 1925 | } |
| 1926 | |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 1927 | if (test_bit(ATH_OP_INVALID, &common->op_flags)) { |
Joe Perches | d2182b6 | 2011-12-15 14:55:53 -0800 | [diff] [blame] | 1928 | ath_dbg(common, ANY, "Device not present\n"); |
Mohammed Shafi Shajakhan | 99aa55b | 2011-05-06 20:43:11 +0530 | [diff] [blame] | 1929 | return; |
| 1930 | } |
| 1931 | |
Felix Fietkau | 10e2318 | 2013-11-11 22:23:35 +0100 | [diff] [blame] | 1932 | if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc), |
| 1933 | timeout) > 0) |
| 1934 | drop = false; |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 1935 | |
Felix Fietkau | 9df0d6a | 2011-11-16 13:08:42 +0100 | [diff] [blame] | 1936 | if (drop) { |
| 1937 | ath9k_ps_wakeup(sc); |
| 1938 | spin_lock_bh(&sc->sc_pcu_lock); |
Felix Fietkau | 1381559 | 2013-01-20 18:51:53 +0100 | [diff] [blame] | 1939 | drain_txq = ath_drain_all_txq(sc); |
Felix Fietkau | 9df0d6a | 2011-11-16 13:08:42 +0100 | [diff] [blame] | 1940 | spin_unlock_bh(&sc->sc_pcu_lock); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 1941 | |
Felix Fietkau | 9df0d6a | 2011-11-16 13:08:42 +0100 | [diff] [blame] | 1942 | if (!drain_txq) |
Felix Fietkau | 1381559 | 2013-01-20 18:51:53 +0100 | [diff] [blame] | 1943 | ath_reset(sc); |
Felix Fietkau | 9adcf44 | 2011-09-03 01:40:26 +0200 | [diff] [blame] | 1944 | |
Felix Fietkau | 9df0d6a | 2011-11-16 13:08:42 +0100 | [diff] [blame] | 1945 | ath9k_ps_restore(sc); |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 1946 | for (i = 0; i < IEEE80211_NUM_ACS; i++) { |
| 1947 | ieee80211_wake_queue(sc->hw, |
| 1948 | sc->cur_chan->hw_queue_base + i); |
| 1949 | } |
Felix Fietkau | 9df0d6a | 2011-11-16 13:08:42 +0100 | [diff] [blame] | 1950 | } |
Senthil Balasubramanian | d78f4b3 | 2011-03-23 23:07:22 +0530 | [diff] [blame] | 1951 | |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 1952 | ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0); |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 1953 | } |
| 1954 | |
Vivek Natarajan | 15b91e8 | 2011-04-06 11:41:11 +0530 | [diff] [blame] | 1955 | static bool ath9k_tx_frames_pending(struct ieee80211_hw *hw) |
| 1956 | { |
| 1957 | struct ath_softc *sc = hw->priv; |
| 1958 | int i; |
| 1959 | |
| 1960 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { |
| 1961 | if (!ATH_TXQ_SETUP(sc, i)) |
| 1962 | continue; |
| 1963 | |
| 1964 | if (ath9k_has_pending_frames(sc, &sc->tx.txq[i])) |
| 1965 | return true; |
| 1966 | } |
| 1967 | return false; |
| 1968 | } |
| 1969 | |
Mohammed Shafi Shajakhan | 5595f11 | 2011-05-19 18:08:57 +0530 | [diff] [blame] | 1970 | static int ath9k_tx_last_beacon(struct ieee80211_hw *hw) |
Felix Fietkau | ba4903f | 2011-05-17 21:09:54 +0200 | [diff] [blame] | 1971 | { |
| 1972 | struct ath_softc *sc = hw->priv; |
| 1973 | struct ath_hw *ah = sc->sc_ah; |
| 1974 | struct ieee80211_vif *vif; |
| 1975 | struct ath_vif *avp; |
| 1976 | struct ath_buf *bf; |
| 1977 | struct ath_tx_status ts; |
Felix Fietkau | 4286df6 | 2012-02-27 19:58:40 +0100 | [diff] [blame] | 1978 | bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA); |
Felix Fietkau | ba4903f | 2011-05-17 21:09:54 +0200 | [diff] [blame] | 1979 | int status; |
| 1980 | |
| 1981 | vif = sc->beacon.bslot[0]; |
| 1982 | if (!vif) |
| 1983 | return 0; |
| 1984 | |
Sujith Manoharan | aa45fe9 | 2012-07-17 17:16:03 +0530 | [diff] [blame] | 1985 | if (!vif->bss_conf.enable_beacon) |
Felix Fietkau | ba4903f | 2011-05-17 21:09:54 +0200 | [diff] [blame] | 1986 | return 0; |
| 1987 | |
Sujith Manoharan | aa45fe9 | 2012-07-17 17:16:03 +0530 | [diff] [blame] | 1988 | avp = (void *)vif->drv_priv; |
| 1989 | |
Felix Fietkau | 4286df6 | 2012-02-27 19:58:40 +0100 | [diff] [blame] | 1990 | if (!sc->beacon.tx_processed && !edma) { |
Felix Fietkau | ba4903f | 2011-05-17 21:09:54 +0200 | [diff] [blame] | 1991 | tasklet_disable(&sc->bcon_tasklet); |
| 1992 | |
| 1993 | bf = avp->av_bcbuf; |
| 1994 | if (!bf || !bf->bf_mpdu) |
| 1995 | goto skip; |
| 1996 | |
| 1997 | status = ath9k_hw_txprocdesc(ah, bf->bf_desc, &ts); |
| 1998 | if (status == -EINPROGRESS) |
| 1999 | goto skip; |
| 2000 | |
| 2001 | sc->beacon.tx_processed = true; |
| 2002 | sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK); |
| 2003 | |
| 2004 | skip: |
| 2005 | tasklet_enable(&sc->bcon_tasklet); |
| 2006 | } |
| 2007 | |
| 2008 | return sc->beacon.tx_last; |
| 2009 | } |
| 2010 | |
Mohammed Shafi Shajakhan | 52c94f4 | 2011-08-20 17:21:42 +0530 | [diff] [blame] | 2011 | static int ath9k_get_stats(struct ieee80211_hw *hw, |
| 2012 | struct ieee80211_low_level_stats *stats) |
| 2013 | { |
| 2014 | struct ath_softc *sc = hw->priv; |
| 2015 | struct ath_hw *ah = sc->sc_ah; |
| 2016 | struct ath9k_mib_stats *mib_stats = &ah->ah_mibStats; |
| 2017 | |
| 2018 | stats->dot11ACKFailureCount = mib_stats->ackrcv_bad; |
| 2019 | stats->dot11RTSFailureCount = mib_stats->rts_bad; |
| 2020 | stats->dot11FCSErrorCount = mib_stats->fcs_bad; |
| 2021 | stats->dot11RTSSuccessCount = mib_stats->rts_good; |
| 2022 | return 0; |
| 2023 | } |
| 2024 | |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 2025 | static u32 fill_chainmask(u32 cap, u32 new) |
| 2026 | { |
| 2027 | u32 filled = 0; |
| 2028 | int i; |
| 2029 | |
| 2030 | for (i = 0; cap && new; i++, cap >>= 1) { |
| 2031 | if (!(cap & BIT(0))) |
| 2032 | continue; |
| 2033 | |
| 2034 | if (new & BIT(0)) |
| 2035 | filled |= BIT(i); |
| 2036 | |
| 2037 | new >>= 1; |
| 2038 | } |
| 2039 | |
| 2040 | return filled; |
| 2041 | } |
| 2042 | |
Felix Fietkau | 5d9c7e3 | 2012-07-15 19:53:30 +0200 | [diff] [blame] | 2043 | static bool validate_antenna_mask(struct ath_hw *ah, u32 val) |
| 2044 | { |
Felix Fietkau | fea92cb | 2013-01-20 21:55:22 +0100 | [diff] [blame] | 2045 | if (AR_SREV_9300_20_OR_LATER(ah)) |
| 2046 | return true; |
| 2047 | |
Felix Fietkau | 5d9c7e3 | 2012-07-15 19:53:30 +0200 | [diff] [blame] | 2048 | switch (val & 0x7) { |
| 2049 | case 0x1: |
| 2050 | case 0x3: |
| 2051 | case 0x7: |
| 2052 | return true; |
| 2053 | case 0x2: |
| 2054 | return (ah->caps.rx_chainmask == 1); |
| 2055 | default: |
| 2056 | return false; |
| 2057 | } |
| 2058 | } |
| 2059 | |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 2060 | static int ath9k_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) |
| 2061 | { |
| 2062 | struct ath_softc *sc = hw->priv; |
| 2063 | struct ath_hw *ah = sc->sc_ah; |
| 2064 | |
Felix Fietkau | 5d9c7e3 | 2012-07-15 19:53:30 +0200 | [diff] [blame] | 2065 | if (ah->caps.rx_chainmask != 1) |
| 2066 | rx_ant |= tx_ant; |
| 2067 | |
| 2068 | if (!validate_antenna_mask(ah, rx_ant) || !tx_ant) |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 2069 | return -EINVAL; |
| 2070 | |
| 2071 | sc->ant_rx = rx_ant; |
| 2072 | sc->ant_tx = tx_ant; |
| 2073 | |
| 2074 | if (ah->caps.rx_chainmask == 1) |
| 2075 | return 0; |
| 2076 | |
| 2077 | /* AR9100 runs into calibration issues if not all rx chains are enabled */ |
| 2078 | if (AR_SREV_9100(ah)) |
| 2079 | ah->rxchainmask = 0x7; |
| 2080 | else |
| 2081 | ah->rxchainmask = fill_chainmask(ah->caps.rx_chainmask, rx_ant); |
| 2082 | |
| 2083 | ah->txchainmask = fill_chainmask(ah->caps.tx_chainmask, tx_ant); |
Oleksij Rempel | b57ba3b | 2014-02-25 14:48:55 +0100 | [diff] [blame] | 2084 | ath9k_cmn_reload_chainmask(ah); |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 2085 | |
| 2086 | return 0; |
| 2087 | } |
| 2088 | |
| 2089 | static int ath9k_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant) |
| 2090 | { |
| 2091 | struct ath_softc *sc = hw->priv; |
| 2092 | |
| 2093 | *tx_ant = sc->ant_tx; |
| 2094 | *rx_ant = sc->ant_rx; |
| 2095 | return 0; |
| 2096 | } |
| 2097 | |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 2098 | static void ath9k_sw_scan_start(struct ieee80211_hw *hw) |
| 2099 | { |
| 2100 | struct ath_softc *sc = hw->priv; |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 2101 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 2102 | set_bit(ATH_OP_SCANNING, &common->op_flags); |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 2103 | } |
| 2104 | |
| 2105 | static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) |
| 2106 | { |
| 2107 | struct ath_softc *sc = hw->priv; |
Oleksij Rempel | eefa01d | 2014-02-27 11:40:46 +0100 | [diff] [blame] | 2108 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 2109 | clear_bit(ATH_OP_SCANNING, &common->op_flags); |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 2110 | } |
Mohammed Shafi Shajakhan | b11e640 | 2012-07-10 14:56:52 +0530 | [diff] [blame] | 2111 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 2112 | #ifdef CONFIG_ATH9K_CHANNEL_CONTEXT |
| 2113 | |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2114 | static int ath9k_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
John W. Linville | 855df36 | 2014-06-25 15:15:14 -0400 | [diff] [blame] | 2115 | struct ieee80211_scan_request *hw_req) |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2116 | { |
John W. Linville | 855df36 | 2014-06-25 15:15:14 -0400 | [diff] [blame] | 2117 | struct cfg80211_scan_request *req = &hw_req->req; |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2118 | struct ath_softc *sc = hw->priv; |
| 2119 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 2120 | int ret = 0; |
| 2121 | |
| 2122 | mutex_lock(&sc->mutex); |
| 2123 | |
| 2124 | if (WARN_ON(sc->offchannel.scan_req)) { |
| 2125 | ret = -EBUSY; |
| 2126 | goto out; |
| 2127 | } |
| 2128 | |
| 2129 | ath9k_ps_wakeup(sc); |
| 2130 | set_bit(ATH_OP_SCANNING, &common->op_flags); |
| 2131 | sc->offchannel.scan_vif = vif; |
| 2132 | sc->offchannel.scan_req = req; |
| 2133 | sc->offchannel.scan_idx = 0; |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2134 | |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2135 | ath_dbg(common, CHAN_CTX, "HW scan request received on vif: %pM\n", |
| 2136 | vif->addr); |
| 2137 | |
| 2138 | if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) { |
| 2139 | ath_dbg(common, CHAN_CTX, "Starting HW scan\n"); |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2140 | ath_offchannel_next(sc); |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2141 | } |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2142 | |
| 2143 | out: |
| 2144 | mutex_unlock(&sc->mutex); |
| 2145 | |
| 2146 | return ret; |
| 2147 | } |
| 2148 | |
| 2149 | static void ath9k_cancel_hw_scan(struct ieee80211_hw *hw, |
| 2150 | struct ieee80211_vif *vif) |
| 2151 | { |
| 2152 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2153 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
| 2154 | |
| 2155 | ath_dbg(common, CHAN_CTX, "Cancel HW scan on vif: %pM\n", vif->addr); |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2156 | |
| 2157 | mutex_lock(&sc->mutex); |
| 2158 | del_timer_sync(&sc->offchannel.timer); |
| 2159 | ath_scan_complete(sc, true); |
| 2160 | mutex_unlock(&sc->mutex); |
| 2161 | } |
| 2162 | |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2163 | static int ath9k_remain_on_channel(struct ieee80211_hw *hw, |
| 2164 | struct ieee80211_vif *vif, |
| 2165 | struct ieee80211_channel *chan, int duration, |
| 2166 | enum ieee80211_roc_type type) |
| 2167 | { |
| 2168 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2169 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2170 | int ret = 0; |
| 2171 | |
| 2172 | mutex_lock(&sc->mutex); |
| 2173 | |
| 2174 | if (WARN_ON(sc->offchannel.roc_vif)) { |
| 2175 | ret = -EBUSY; |
| 2176 | goto out; |
| 2177 | } |
| 2178 | |
| 2179 | ath9k_ps_wakeup(sc); |
| 2180 | sc->offchannel.roc_vif = vif; |
| 2181 | sc->offchannel.roc_chan = chan; |
| 2182 | sc->offchannel.roc_duration = duration; |
| 2183 | |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2184 | ath_dbg(common, CHAN_CTX, |
| 2185 | "RoC request on vif: %pM, type: %d duration: %d\n", |
| 2186 | vif->addr, type, duration); |
| 2187 | |
| 2188 | if (sc->offchannel.state == ATH_OFFCHANNEL_IDLE) { |
| 2189 | ath_dbg(common, CHAN_CTX, "Starting RoC period\n"); |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2190 | ath_offchannel_next(sc); |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2191 | } |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2192 | |
| 2193 | out: |
| 2194 | mutex_unlock(&sc->mutex); |
| 2195 | |
| 2196 | return ret; |
| 2197 | } |
| 2198 | |
| 2199 | static int ath9k_cancel_remain_on_channel(struct ieee80211_hw *hw) |
| 2200 | { |
| 2201 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2202 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2203 | |
| 2204 | mutex_lock(&sc->mutex); |
| 2205 | |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2206 | ath_dbg(common, CHAN_CTX, "Cancel RoC\n"); |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2207 | del_timer_sync(&sc->offchannel.timer); |
| 2208 | |
| 2209 | if (sc->offchannel.roc_vif) { |
| 2210 | if (sc->offchannel.state >= ATH_OFFCHANNEL_ROC_START) |
| 2211 | ath_roc_complete(sc, true); |
| 2212 | } |
| 2213 | |
| 2214 | mutex_unlock(&sc->mutex); |
| 2215 | |
| 2216 | return 0; |
| 2217 | } |
| 2218 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2219 | static int ath9k_add_chanctx(struct ieee80211_hw *hw, |
| 2220 | struct ieee80211_chanctx_conf *conf) |
| 2221 | { |
| 2222 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2223 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2224 | struct ath_chanctx *ctx, **ptr; |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 2225 | int pos; |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2226 | |
| 2227 | mutex_lock(&sc->mutex); |
Rajkumar Manoharan | c4dc0d0 | 2014-06-11 16:17:58 +0530 | [diff] [blame] | 2228 | |
| 2229 | ath_for_each_chanctx(sc, ctx) { |
| 2230 | if (ctx->assigned) |
| 2231 | continue; |
| 2232 | |
| 2233 | ptr = (void *) conf->drv_priv; |
| 2234 | *ptr = ctx; |
| 2235 | ctx->assigned = true; |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 2236 | pos = ctx - &sc->chanctx[0]; |
| 2237 | ctx->hw_queue_base = pos * IEEE80211_NUM_ACS; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2238 | |
| 2239 | ath_dbg(common, CHAN_CTX, |
| 2240 | "Add channel context: %d MHz\n", |
| 2241 | conf->def.chan->center_freq); |
| 2242 | |
Rajkumar Manoharan | c4dc0d0 | 2014-06-11 16:17:58 +0530 | [diff] [blame] | 2243 | ath_chanctx_set_channel(sc, ctx, &conf->def); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2244 | mutex_unlock(&sc->mutex); |
Rajkumar Manoharan | c4dc0d0 | 2014-06-11 16:17:58 +0530 | [diff] [blame] | 2245 | return 0; |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2246 | } |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2247 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2248 | mutex_unlock(&sc->mutex); |
Rajkumar Manoharan | c4dc0d0 | 2014-06-11 16:17:58 +0530 | [diff] [blame] | 2249 | return -ENOSPC; |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2250 | } |
| 2251 | |
| 2252 | |
| 2253 | static void ath9k_remove_chanctx(struct ieee80211_hw *hw, |
| 2254 | struct ieee80211_chanctx_conf *conf) |
| 2255 | { |
| 2256 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2257 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2258 | struct ath_chanctx *ctx = ath_chanctx_get(conf); |
| 2259 | |
| 2260 | mutex_lock(&sc->mutex); |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2261 | |
| 2262 | ath_dbg(common, CHAN_CTX, |
| 2263 | "Remove channel context: %d MHz\n", |
| 2264 | conf->def.chan->center_freq); |
| 2265 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2266 | ctx->assigned = false; |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 2267 | ctx->hw_queue_base = -1; |
Felix Fietkau | 73fa2f2 | 2014-06-11 16:18:10 +0530 | [diff] [blame] | 2268 | ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_UNASSIGN); |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2269 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2270 | mutex_unlock(&sc->mutex); |
| 2271 | } |
| 2272 | |
| 2273 | static void ath9k_change_chanctx(struct ieee80211_hw *hw, |
| 2274 | struct ieee80211_chanctx_conf *conf, |
| 2275 | u32 changed) |
| 2276 | { |
| 2277 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2278 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2279 | struct ath_chanctx *ctx = ath_chanctx_get(conf); |
| 2280 | |
| 2281 | mutex_lock(&sc->mutex); |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2282 | ath_dbg(common, CHAN_CTX, |
| 2283 | "Change channel context: %d MHz\n", |
| 2284 | conf->def.chan->center_freq); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2285 | ath_chanctx_set_channel(sc, ctx, &conf->def); |
| 2286 | mutex_unlock(&sc->mutex); |
| 2287 | } |
| 2288 | |
| 2289 | static int ath9k_assign_vif_chanctx(struct ieee80211_hw *hw, |
| 2290 | struct ieee80211_vif *vif, |
| 2291 | struct ieee80211_chanctx_conf *conf) |
| 2292 | { |
| 2293 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2294 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2295 | struct ath_vif *avp = (void *)vif->drv_priv; |
| 2296 | struct ath_chanctx *ctx = ath_chanctx_get(conf); |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 2297 | int i; |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2298 | |
| 2299 | mutex_lock(&sc->mutex); |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2300 | |
| 2301 | ath_dbg(common, CHAN_CTX, |
| 2302 | "Assign VIF (addr: %pM, type: %d, p2p: %d) to channel context: %d MHz\n", |
| 2303 | vif->addr, vif->type, vif->p2p, |
| 2304 | conf->def.chan->center_freq); |
| 2305 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2306 | avp->chanctx = ctx; |
| 2307 | list_add_tail(&avp->list, &ctx->vifs); |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 2308 | ath9k_calculate_summary_state(sc, ctx); |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 2309 | for (i = 0; i < IEEE80211_NUM_ACS; i++) |
| 2310 | vif->hw_queue[i] = ctx->hw_queue_base + i; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2311 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2312 | mutex_unlock(&sc->mutex); |
| 2313 | |
| 2314 | return 0; |
| 2315 | } |
| 2316 | |
| 2317 | static void ath9k_unassign_vif_chanctx(struct ieee80211_hw *hw, |
| 2318 | struct ieee80211_vif *vif, |
| 2319 | struct ieee80211_chanctx_conf *conf) |
| 2320 | { |
| 2321 | struct ath_softc *sc = hw->priv; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2322 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2323 | struct ath_vif *avp = (void *)vif->drv_priv; |
| 2324 | struct ath_chanctx *ctx = ath_chanctx_get(conf); |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 2325 | int ac; |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2326 | |
| 2327 | mutex_lock(&sc->mutex); |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2328 | |
| 2329 | ath_dbg(common, CHAN_CTX, |
| 2330 | "Remove VIF (addr: %pM, type: %d, p2p: %d) from channel context: %d MHz\n", |
| 2331 | vif->addr, vif->type, vif->p2p, |
| 2332 | conf->def.chan->center_freq); |
| 2333 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2334 | avp->chanctx = NULL; |
| 2335 | list_del(&avp->list); |
Rajkumar Manoharan | 9a9c4fb | 2014-06-11 16:18:03 +0530 | [diff] [blame] | 2336 | ath9k_calculate_summary_state(sc, ctx); |
Rajkumar Manoharan | 3ad9c38 | 2014-06-11 16:18:15 +0530 | [diff] [blame] | 2337 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) |
| 2338 | vif->hw_queue[ac] = IEEE80211_INVAL_HW_QUEUE; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2339 | |
Felix Fietkau | 3930563 | 2014-06-11 16:17:57 +0530 | [diff] [blame] | 2340 | mutex_unlock(&sc->mutex); |
| 2341 | } |
| 2342 | |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2343 | void ath9k_fill_chanctx_ops(void) |
| 2344 | { |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 2345 | if (!ath9k_is_chanctx_enabled()) |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2346 | return; |
| 2347 | |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2348 | ath9k_ops.hw_scan = ath9k_hw_scan; |
| 2349 | ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan; |
| 2350 | ath9k_ops.remain_on_channel = ath9k_remain_on_channel; |
Felix Fietkau | 405393c | 2014-06-11 16:17:56 +0530 | [diff] [blame] | 2351 | ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel; |
Sujith Manoharan | bc81d43 | 2014-08-22 20:39:27 +0530 | [diff] [blame] | 2352 | ath9k_ops.add_chanctx = ath9k_add_chanctx; |
| 2353 | ath9k_ops.remove_chanctx = ath9k_remove_chanctx; |
| 2354 | ath9k_ops.change_chanctx = ath9k_change_chanctx; |
| 2355 | ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx; |
| 2356 | ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx; |
| 2357 | ath9k_ops.mgd_prepare_tx = ath9k_chanctx_force_active; |
Felix Fietkau | 78b2194 | 2014-06-11 16:17:55 +0530 | [diff] [blame] | 2358 | } |
| 2359 | |
Sujith Manoharan | 499afac | 2014-08-22 20:39:31 +0530 | [diff] [blame] | 2360 | #endif |
| 2361 | |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2362 | struct ieee80211_ops ath9k_ops = { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2363 | .tx = ath9k_tx, |
| 2364 | .start = ath9k_start, |
| 2365 | .stop = ath9k_stop, |
| 2366 | .add_interface = ath9k_add_interface, |
Rajkumar Manoharan | 6b3b991 | 2010-12-08 19:38:55 +0530 | [diff] [blame] | 2367 | .change_interface = ath9k_change_interface, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2368 | .remove_interface = ath9k_remove_interface, |
| 2369 | .config = ath9k_config, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2370 | .configure_filter = ath9k_configure_filter, |
Johannes Berg | 4ca7786 | 2010-02-19 19:06:56 +0100 | [diff] [blame] | 2371 | .sta_add = ath9k_sta_add, |
| 2372 | .sta_remove = ath9k_sta_remove, |
Felix Fietkau | 5519541 | 2011-04-17 23:28:09 +0200 | [diff] [blame] | 2373 | .sta_notify = ath9k_sta_notify, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2374 | .conf_tx = ath9k_conf_tx, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2375 | .bss_info_changed = ath9k_bss_info_changed, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2376 | .set_key = ath9k_set_key, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2377 | .get_tsf = ath9k_get_tsf, |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 2378 | .set_tsf = ath9k_set_tsf, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2379 | .reset_tsf = ath9k_reset_tsf, |
Johannes Berg | 4233df6 | 2008-10-13 13:35:05 +0200 | [diff] [blame] | 2380 | .ampdu_action = ath9k_ampdu_action, |
Benoit Papillault | 62dad5b | 2010-04-28 00:08:24 +0200 | [diff] [blame] | 2381 | .get_survey = ath9k_get_survey, |
Johannes Berg | 3b319aa | 2009-06-13 14:50:26 +0530 | [diff] [blame] | 2382 | .rfkill_poll = ath9k_rfkill_poll_state, |
Felix Fietkau | e239d85 | 2010-01-15 02:34:58 +0100 | [diff] [blame] | 2383 | .set_coverage_class = ath9k_set_coverage_class, |
Vasanthakumar Thiagarajan | 6908162 | 2011-02-19 01:13:42 -0800 | [diff] [blame] | 2384 | .flush = ath9k_flush, |
Vivek Natarajan | 15b91e8 | 2011-04-06 11:41:11 +0530 | [diff] [blame] | 2385 | .tx_frames_pending = ath9k_tx_frames_pending, |
Mohammed Shafi Shajakhan | 52c94f4 | 2011-08-20 17:21:42 +0530 | [diff] [blame] | 2386 | .tx_last_beacon = ath9k_tx_last_beacon, |
Felix Fietkau | 86a22ac | 2013-06-07 18:12:01 +0200 | [diff] [blame] | 2387 | .release_buffered_frames = ath9k_release_buffered_frames, |
Mohammed Shafi Shajakhan | 52c94f4 | 2011-08-20 17:21:42 +0530 | [diff] [blame] | 2388 | .get_stats = ath9k_get_stats, |
Felix Fietkau | 43c3528 | 2011-09-03 01:40:27 +0200 | [diff] [blame] | 2389 | .set_antenna = ath9k_set_antenna, |
| 2390 | .get_antenna = ath9k_get_antenna, |
Ben Greear | b90bd9d | 2012-05-15 15:33:25 -0700 | [diff] [blame] | 2391 | |
Sujith Manoharan | e60001e | 2013-10-28 12:22:04 +0530 | [diff] [blame] | 2392 | #ifdef CONFIG_ATH9K_WOW |
Mohammed Shafi Shajakhan | b11e640 | 2012-07-10 14:56:52 +0530 | [diff] [blame] | 2393 | .suspend = ath9k_suspend, |
| 2394 | .resume = ath9k_resume, |
| 2395 | .set_wakeup = ath9k_set_wakeup, |
| 2396 | #endif |
| 2397 | |
Ben Greear | b90bd9d | 2012-05-15 15:33:25 -0700 | [diff] [blame] | 2398 | #ifdef CONFIG_ATH9K_DEBUGFS |
| 2399 | .get_et_sset_count = ath9k_get_et_sset_count, |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 2400 | .get_et_stats = ath9k_get_et_stats, |
| 2401 | .get_et_strings = ath9k_get_et_strings, |
| 2402 | #endif |
| 2403 | |
Sujith Manoharan | 1cdbaf0 | 2014-01-13 07:29:27 +0530 | [diff] [blame] | 2404 | #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_STATION_STATISTICS) |
Sujith Manoharan | a145daf | 2012-11-28 15:08:54 +0530 | [diff] [blame] | 2405 | .sta_add_debugfs = ath9k_sta_add_debugfs, |
Ben Greear | b90bd9d | 2012-05-15 15:33:25 -0700 | [diff] [blame] | 2406 | #endif |
Simon Wunderlich | e93d083 | 2013-01-08 14:48:58 +0100 | [diff] [blame] | 2407 | .sw_scan_start = ath9k_sw_scan_start, |
| 2408 | .sw_scan_complete = ath9k_sw_scan_complete, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2409 | }; |