Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1 | /* |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2009 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> |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 18 | #include "ath9k.h" |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 19 | #include "btcoex.h" |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 20 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 21 | static char *dev_info = "ath9k"; |
| 22 | |
| 23 | MODULE_AUTHOR("Atheros Communications"); |
| 24 | MODULE_DESCRIPTION("Support for Atheros 802.11n wireless LAN cards."); |
| 25 | MODULE_SUPPORTED_DEVICE("Atheros 802.11n WLAN cards"); |
| 26 | MODULE_LICENSE("Dual BSD/GPL"); |
| 27 | |
Jouni Malinen | b3bd89c | 2009-02-24 13:42:01 +0200 | [diff] [blame] | 28 | static int modparam_nohwcrypt; |
| 29 | module_param_named(nohwcrypt, modparam_nohwcrypt, int, 0444); |
| 30 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption"); |
| 31 | |
Luis R. Rodriguez | faa27fa | 2009-10-06 21:19:06 -0400 | [diff] [blame] | 32 | static unsigned int ath9k_debug = ATH_DBG_DEFAULT; |
| 33 | module_param_named(debug, ath9k_debug, uint, 0); |
Luis R. Rodriguez | af1fc67 | 2009-10-08 01:00:18 -0400 | [diff] [blame] | 34 | MODULE_PARM_DESC(debug, "Debugging mask"); |
Luis R. Rodriguez | faa27fa | 2009-10-06 21:19:06 -0400 | [diff] [blame] | 35 | |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 36 | /* We use the hw_value as an index into our private channel structure */ |
| 37 | |
| 38 | #define CHAN2G(_freq, _idx) { \ |
| 39 | .center_freq = (_freq), \ |
| 40 | .hw_value = (_idx), \ |
Luis R. Rodriguez | eeddfd9 | 2009-05-19 17:49:46 -0400 | [diff] [blame] | 41 | .max_power = 20, \ |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | #define CHAN5G(_freq, _idx) { \ |
| 45 | .band = IEEE80211_BAND_5GHZ, \ |
| 46 | .center_freq = (_freq), \ |
| 47 | .hw_value = (_idx), \ |
Luis R. Rodriguez | eeddfd9 | 2009-05-19 17:49:46 -0400 | [diff] [blame] | 48 | .max_power = 20, \ |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | /* Some 2 GHz radios are actually tunable on 2312-2732 |
| 52 | * on 5 MHz steps, we support the channels which we know |
| 53 | * we have calibration data for all cards though to make |
| 54 | * this static */ |
| 55 | static struct ieee80211_channel ath9k_2ghz_chantable[] = { |
| 56 | CHAN2G(2412, 0), /* Channel 1 */ |
| 57 | CHAN2G(2417, 1), /* Channel 2 */ |
| 58 | CHAN2G(2422, 2), /* Channel 3 */ |
| 59 | CHAN2G(2427, 3), /* Channel 4 */ |
| 60 | CHAN2G(2432, 4), /* Channel 5 */ |
| 61 | CHAN2G(2437, 5), /* Channel 6 */ |
| 62 | CHAN2G(2442, 6), /* Channel 7 */ |
| 63 | CHAN2G(2447, 7), /* Channel 8 */ |
| 64 | CHAN2G(2452, 8), /* Channel 9 */ |
| 65 | CHAN2G(2457, 9), /* Channel 10 */ |
| 66 | CHAN2G(2462, 10), /* Channel 11 */ |
| 67 | CHAN2G(2467, 11), /* Channel 12 */ |
| 68 | CHAN2G(2472, 12), /* Channel 13 */ |
| 69 | CHAN2G(2484, 13), /* Channel 14 */ |
| 70 | }; |
| 71 | |
| 72 | /* Some 5 GHz radios are actually tunable on XXXX-YYYY |
| 73 | * on 5 MHz steps, we support the channels which we know |
| 74 | * we have calibration data for all cards though to make |
| 75 | * this static */ |
| 76 | static struct ieee80211_channel ath9k_5ghz_chantable[] = { |
| 77 | /* _We_ call this UNII 1 */ |
| 78 | CHAN5G(5180, 14), /* Channel 36 */ |
| 79 | CHAN5G(5200, 15), /* Channel 40 */ |
| 80 | CHAN5G(5220, 16), /* Channel 44 */ |
| 81 | CHAN5G(5240, 17), /* Channel 48 */ |
| 82 | /* _We_ call this UNII 2 */ |
| 83 | CHAN5G(5260, 18), /* Channel 52 */ |
| 84 | CHAN5G(5280, 19), /* Channel 56 */ |
| 85 | CHAN5G(5300, 20), /* Channel 60 */ |
| 86 | CHAN5G(5320, 21), /* Channel 64 */ |
| 87 | /* _We_ call this "Middle band" */ |
| 88 | CHAN5G(5500, 22), /* Channel 100 */ |
| 89 | CHAN5G(5520, 23), /* Channel 104 */ |
| 90 | CHAN5G(5540, 24), /* Channel 108 */ |
| 91 | CHAN5G(5560, 25), /* Channel 112 */ |
| 92 | CHAN5G(5580, 26), /* Channel 116 */ |
| 93 | CHAN5G(5600, 27), /* Channel 120 */ |
| 94 | CHAN5G(5620, 28), /* Channel 124 */ |
| 95 | CHAN5G(5640, 29), /* Channel 128 */ |
| 96 | CHAN5G(5660, 30), /* Channel 132 */ |
| 97 | CHAN5G(5680, 31), /* Channel 136 */ |
| 98 | CHAN5G(5700, 32), /* Channel 140 */ |
| 99 | /* _We_ call this UNII 3 */ |
| 100 | CHAN5G(5745, 33), /* Channel 149 */ |
| 101 | CHAN5G(5765, 34), /* Channel 153 */ |
| 102 | CHAN5G(5785, 35), /* Channel 157 */ |
| 103 | CHAN5G(5805, 36), /* Channel 161 */ |
| 104 | CHAN5G(5825, 37), /* Channel 165 */ |
| 105 | }; |
| 106 | |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 107 | /* Atheros hardware rate code addition for short premble */ |
| 108 | #define SHPCHECK(__hw_rate, __flags) \ |
| 109 | ((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0) |
| 110 | |
| 111 | #define RATE(_bitrate, _hw_rate, _flags) { \ |
| 112 | .bitrate = (_bitrate), \ |
| 113 | .flags = (_flags), \ |
| 114 | .hw_value = (_hw_rate), \ |
| 115 | .hw_value_short = (SHPCHECK(_hw_rate, _flags)) \ |
| 116 | } |
| 117 | |
| 118 | static struct ieee80211_rate ath9k_legacy_rates[] = { |
| 119 | RATE(10, 0x1b, 0), |
| 120 | RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE), |
| 121 | RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE), |
| 122 | RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE), |
| 123 | RATE(60, 0x0b, 0), |
| 124 | RATE(90, 0x0f, 0), |
| 125 | RATE(120, 0x0a, 0), |
| 126 | RATE(180, 0x0e, 0), |
| 127 | RATE(240, 0x09, 0), |
| 128 | RATE(360, 0x0d, 0), |
| 129 | RATE(480, 0x08, 0), |
| 130 | RATE(540, 0x0c, 0), |
| 131 | }; |
| 132 | |
Luis R. Rodriguez | ce111ba | 2008-12-23 15:58:39 -0800 | [diff] [blame] | 133 | static void ath_cache_conf_rate(struct ath_softc *sc, |
| 134 | struct ieee80211_conf *conf) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 135 | { |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 136 | switch (conf->channel->band) { |
| 137 | case IEEE80211_BAND_2GHZ: |
| 138 | if (conf_is_ht20(conf)) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 139 | sc->cur_rate_mode = ATH9K_MODE_11NG_HT20; |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 140 | else if (conf_is_ht40_minus(conf)) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 141 | sc->cur_rate_mode = ATH9K_MODE_11NG_HT40MINUS; |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 142 | else if (conf_is_ht40_plus(conf)) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 143 | sc->cur_rate_mode = ATH9K_MODE_11NG_HT40PLUS; |
Luis R. Rodriguez | 9674225 | 2008-12-23 15:58:38 -0800 | [diff] [blame] | 144 | else |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 145 | sc->cur_rate_mode = ATH9K_MODE_11G; |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 146 | break; |
| 147 | case IEEE80211_BAND_5GHZ: |
| 148 | if (conf_is_ht20(conf)) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 149 | sc->cur_rate_mode = ATH9K_MODE_11NA_HT20; |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 150 | else if (conf_is_ht40_minus(conf)) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 151 | sc->cur_rate_mode = ATH9K_MODE_11NA_HT40MINUS; |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 152 | else if (conf_is_ht40_plus(conf)) |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 153 | sc->cur_rate_mode = ATH9K_MODE_11NA_HT40PLUS; |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 154 | else |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 155 | sc->cur_rate_mode = ATH9K_MODE_11A; |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 156 | break; |
| 157 | default: |
Luis R. Rodriguez | ce111ba | 2008-12-23 15:58:39 -0800 | [diff] [blame] | 158 | BUG_ON(1); |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 159 | break; |
| 160 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | static void ath_update_txpow(struct ath_softc *sc) |
| 164 | { |
Sujith | cbe61d8a | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 165 | struct ath_hw *ah = sc->sc_ah; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 166 | u32 txpow; |
| 167 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 168 | if (sc->curtxpow != sc->config.txpowlimit) { |
| 169 | ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 170 | /* read back in case value is clamped */ |
| 171 | ath9k_hw_getcapability(ah, ATH9K_CAP_TXPOW, 1, &txpow); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 172 | sc->curtxpow = txpow; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
| 176 | static u8 parse_mpdudensity(u8 mpdudensity) |
| 177 | { |
| 178 | /* |
| 179 | * 802.11n D2.0 defined values for "Minimum MPDU Start Spacing": |
| 180 | * 0 for no restriction |
| 181 | * 1 for 1/4 us |
| 182 | * 2 for 1/2 us |
| 183 | * 3 for 1 us |
| 184 | * 4 for 2 us |
| 185 | * 5 for 4 us |
| 186 | * 6 for 8 us |
| 187 | * 7 for 16 us |
| 188 | */ |
| 189 | switch (mpdudensity) { |
| 190 | case 0: |
| 191 | return 0; |
| 192 | case 1: |
| 193 | case 2: |
| 194 | case 3: |
| 195 | /* Our lower layer calculations limit our precision to |
| 196 | 1 microsecond */ |
| 197 | return 1; |
| 198 | case 4: |
| 199 | return 2; |
| 200 | case 5: |
| 201 | return 4; |
| 202 | case 6: |
| 203 | return 8; |
| 204 | case 7: |
| 205 | return 16; |
| 206 | default: |
| 207 | return 0; |
| 208 | } |
| 209 | } |
| 210 | |
Vasanthakumar Thiagarajan | 82880a7 | 2009-06-13 14:50:24 +0530 | [diff] [blame] | 211 | static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc, |
| 212 | struct ieee80211_hw *hw) |
| 213 | { |
| 214 | struct ieee80211_channel *curchan = hw->conf.channel; |
| 215 | struct ath9k_channel *channel; |
| 216 | u8 chan_idx; |
| 217 | |
| 218 | chan_idx = curchan->hw_value; |
| 219 | channel = &sc->sc_ah->channels[chan_idx]; |
| 220 | ath9k_update_ichannel(sc, hw, channel); |
| 221 | return channel; |
| 222 | } |
| 223 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 224 | 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] | 225 | { |
| 226 | unsigned long flags; |
| 227 | bool ret; |
| 228 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 229 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 230 | ret = ath9k_hw_setpower(sc->sc_ah, mode); |
| 231 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
Luis R. Rodriguez | 8c77a56 | 2009-09-09 21:02:34 -0700 | [diff] [blame] | 232 | |
| 233 | return ret; |
| 234 | } |
| 235 | |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 236 | void ath9k_ps_wakeup(struct ath_softc *sc) |
| 237 | { |
| 238 | unsigned long flags; |
| 239 | |
| 240 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 241 | if (++sc->ps_usecount != 1) |
| 242 | goto unlock; |
| 243 | |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 244 | ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE); |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 245 | |
| 246 | unlock: |
| 247 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
| 248 | } |
| 249 | |
| 250 | void ath9k_ps_restore(struct ath_softc *sc) |
| 251 | { |
| 252 | unsigned long flags; |
| 253 | |
| 254 | spin_lock_irqsave(&sc->sc_pm_lock, flags); |
| 255 | if (--sc->ps_usecount != 0) |
| 256 | goto unlock; |
| 257 | |
| 258 | if (sc->ps_enabled && |
| 259 | !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON | |
| 260 | SC_OP_WAIT_FOR_CAB | |
| 261 | SC_OP_WAIT_FOR_PSPOLL_DATA | |
| 262 | SC_OP_WAIT_FOR_TX_ACK))) |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 263 | ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP); |
Luis R. Rodriguez | a91d75a | 2009-09-09 20:29:18 -0700 | [diff] [blame] | 264 | |
| 265 | unlock: |
| 266 | spin_unlock_irqrestore(&sc->sc_pm_lock, flags); |
| 267 | } |
| 268 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 269 | /* |
| 270 | * Set/change channels. If the channel is really being changed, it's done |
| 271 | * by reseting the chip. To accomplish this we must first cleanup any pending |
| 272 | * DMA, then restart stuff. |
| 273 | */ |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 274 | int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw, |
| 275 | struct ath9k_channel *hchan) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 276 | { |
Sujith | cbe61d8a | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 277 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 278 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 279 | struct ieee80211_conf *conf = &common->hw->conf; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 280 | bool fastcc = true, stopped; |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 281 | struct ieee80211_channel *channel = hw->conf.channel; |
| 282 | int r; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 283 | |
| 284 | if (sc->sc_flags & SC_OP_INVALID) |
| 285 | return -EIO; |
| 286 | |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 287 | ath9k_ps_wakeup(sc); |
| 288 | |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 289 | /* |
| 290 | * This is only performed if the channel settings have |
| 291 | * actually changed. |
| 292 | * |
| 293 | * To switch channels clear any pending DMA operations; |
| 294 | * wait long enough for the RX fifo to drain, reset the |
| 295 | * hardware at the new frequency, and then re-enable |
| 296 | * the relevant bits of the h/w. |
| 297 | */ |
| 298 | ath9k_hw_set_interrupts(ah, 0); |
Sujith | 043a040 | 2009-01-16 21:38:47 +0530 | [diff] [blame] | 299 | ath_drain_all_txq(sc, false); |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 300 | stopped = ath_stoprecv(sc); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 301 | |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 302 | /* XXX: do not flush receive queue here. We don't want |
| 303 | * to flush data frames already in queue because of |
| 304 | * changing channel. */ |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 305 | |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 306 | if (!stopped || (sc->sc_flags & SC_OP_FULL_RESET)) |
| 307 | fastcc = false; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 308 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 309 | ath_print(common, ATH_DBG_CONFIG, |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 310 | "(%u MHz) -> (%u MHz), conf_is_ht40: %d\n", |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 311 | sc->sc_ah->curchan->channel, |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 312 | channel->center_freq, conf_is_ht40(conf)); |
Sujith | 99405f9 | 2008-11-24 12:08:35 +0530 | [diff] [blame] | 313 | |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 314 | spin_lock_bh(&sc->sc_resetlock); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 315 | |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 316 | r = ath9k_hw_reset(ah, hchan, fastcc); |
| 317 | if (r) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 318 | ath_print(common, ATH_DBG_FATAL, |
| 319 | "Unable to reset channel (%u Mhz) " |
| 320 | "reset status %d\n", |
| 321 | channel->center_freq, r); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 322 | spin_unlock_bh(&sc->sc_resetlock); |
Gabor Juhos | 3989279 | 2009-06-15 17:49:09 +0200 | [diff] [blame] | 323 | goto ps_restore; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 324 | } |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 325 | spin_unlock_bh(&sc->sc_resetlock); |
| 326 | |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 327 | sc->sc_flags &= ~SC_OP_FULL_RESET; |
| 328 | |
| 329 | if (ath_startrecv(sc) != 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 330 | ath_print(common, ATH_DBG_FATAL, |
| 331 | "Unable to restart recv logic\n"); |
Gabor Juhos | 3989279 | 2009-06-15 17:49:09 +0200 | [diff] [blame] | 332 | r = -EIO; |
| 333 | goto ps_restore; |
Luis R. Rodriguez | c0d7c7a | 2008-12-23 15:58:50 -0800 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | ath_cache_conf_rate(sc, &hw->conf); |
| 337 | ath_update_txpow(sc); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 338 | ath9k_hw_set_interrupts(ah, sc->imask); |
Gabor Juhos | 3989279 | 2009-06-15 17:49:09 +0200 | [diff] [blame] | 339 | |
| 340 | ps_restore: |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 341 | ath9k_ps_restore(sc); |
Gabor Juhos | 3989279 | 2009-06-15 17:49:09 +0200 | [diff] [blame] | 342 | return r; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /* |
| 346 | * This routine performs the periodic noise floor calibration function |
| 347 | * that is used to adjust and optimize the chip performance. This |
| 348 | * takes environmental changes (location, temperature) into account. |
| 349 | * When the task is complete, it reschedules itself depending on the |
| 350 | * appropriate interval that was calculated. |
| 351 | */ |
| 352 | static void ath_ani_calibrate(unsigned long data) |
| 353 | { |
Sujith | 20977d3 | 2009-02-20 15:13:28 +0530 | [diff] [blame] | 354 | struct ath_softc *sc = (struct ath_softc *)data; |
| 355 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 356 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 357 | bool longcal = false; |
| 358 | bool shortcal = false; |
| 359 | bool aniflag = false; |
| 360 | unsigned int timestamp = jiffies_to_msecs(jiffies); |
Sujith | 20977d3 | 2009-02-20 15:13:28 +0530 | [diff] [blame] | 361 | u32 cal_interval, short_cal_interval; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 362 | |
Sujith | 20977d3 | 2009-02-20 15:13:28 +0530 | [diff] [blame] | 363 | short_cal_interval = (ah->opmode == NL80211_IFTYPE_AP) ? |
| 364 | ATH_AP_SHORT_CALINTERVAL : ATH_STA_SHORT_CALINTERVAL; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 365 | |
Jouni Malinen | 1ffc1c6 | 2009-05-19 17:01:39 +0300 | [diff] [blame] | 366 | /* Only calibrate if awake */ |
| 367 | if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE) |
| 368 | goto set_timer; |
| 369 | |
| 370 | ath9k_ps_wakeup(sc); |
| 371 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 372 | /* Long calibration runs independently of short calibration. */ |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 373 | if ((timestamp - common->ani.longcal_timer) >= ATH_LONG_CALINTERVAL) { |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 374 | longcal = true; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 375 | ath_print(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies); |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 376 | common->ani.longcal_timer = timestamp; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 377 | } |
| 378 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 379 | /* Short calibration applies only while caldone is false */ |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 380 | if (!common->ani.caldone) { |
| 381 | if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) { |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 382 | shortcal = true; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 383 | ath_print(common, ATH_DBG_ANI, |
| 384 | "shortcal @%lu\n", jiffies); |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 385 | common->ani.shortcal_timer = timestamp; |
| 386 | common->ani.resetcal_timer = timestamp; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 387 | } |
| 388 | } else { |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 389 | if ((timestamp - common->ani.resetcal_timer) >= |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 390 | ATH_RESTART_CALINTERVAL) { |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 391 | common->ani.caldone = ath9k_hw_reset_calvalid(ah); |
| 392 | if (common->ani.caldone) |
| 393 | common->ani.resetcal_timer = timestamp; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 394 | } |
| 395 | } |
| 396 | |
| 397 | /* Verify whether we must check ANI */ |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 398 | if ((timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) { |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 399 | aniflag = true; |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 400 | common->ani.checkani_timer = timestamp; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | /* Skip all processing if there's nothing to do. */ |
| 404 | if (longcal || shortcal || aniflag) { |
| 405 | /* Call ANI routine if necessary */ |
| 406 | if (aniflag) |
Vasanthakumar Thiagarajan | 22e66a4 | 2009-08-19 16:23:40 +0530 | [diff] [blame] | 407 | ath9k_hw_ani_monitor(ah, ah->curchan); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 408 | |
| 409 | /* Perform calibration if necessary */ |
| 410 | if (longcal || shortcal) { |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 411 | common->ani.caldone = |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 412 | ath9k_hw_calibrate(ah, |
| 413 | ah->curchan, |
| 414 | common->rx_chainmask, |
| 415 | longcal); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 416 | |
Sujith | 379f044 | 2009-04-13 21:56:48 +0530 | [diff] [blame] | 417 | if (longcal) |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 418 | common->ani.noise_floor = ath9k_hw_getchan_noise(ah, |
Sujith | 379f044 | 2009-04-13 21:56:48 +0530 | [diff] [blame] | 419 | ah->curchan); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 420 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 421 | ath_print(common, ATH_DBG_ANI, |
| 422 | " calibrate chan %u/%x nf: %d\n", |
| 423 | ah->curchan->channel, |
| 424 | ah->curchan->channelFlags, |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 425 | common->ani.noise_floor); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | |
Jouni Malinen | 1ffc1c6 | 2009-05-19 17:01:39 +0300 | [diff] [blame] | 429 | ath9k_ps_restore(sc); |
| 430 | |
Sujith | 20977d3 | 2009-02-20 15:13:28 +0530 | [diff] [blame] | 431 | set_timer: |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 432 | /* |
| 433 | * Set timer interval based on previous results. |
| 434 | * The interval must be the shortest necessary to satisfy ANI, |
| 435 | * short calibration and long calibration. |
| 436 | */ |
Sujith | aac9207 | 2008-12-02 18:37:54 +0530 | [diff] [blame] | 437 | cal_interval = ATH_LONG_CALINTERVAL; |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 438 | if (sc->sc_ah->config.enable_ani) |
Sujith | aac9207 | 2008-12-02 18:37:54 +0530 | [diff] [blame] | 439 | cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL); |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 440 | if (!common->ani.caldone) |
Sujith | 20977d3 | 2009-02-20 15:13:28 +0530 | [diff] [blame] | 441 | cal_interval = min(cal_interval, (u32)short_cal_interval); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 442 | |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 443 | mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 444 | } |
| 445 | |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 446 | static void ath_start_ani(struct ath_common *common) |
Sujith | 415f738 | 2009-04-13 21:56:46 +0530 | [diff] [blame] | 447 | { |
| 448 | unsigned long timestamp = jiffies_to_msecs(jiffies); |
| 449 | |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 450 | common->ani.longcal_timer = timestamp; |
| 451 | common->ani.shortcal_timer = timestamp; |
| 452 | common->ani.checkani_timer = timestamp; |
Sujith | 415f738 | 2009-04-13 21:56:46 +0530 | [diff] [blame] | 453 | |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 454 | mod_timer(&common->ani.timer, |
Sujith | 415f738 | 2009-04-13 21:56:46 +0530 | [diff] [blame] | 455 | jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL)); |
| 456 | } |
| 457 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 458 | /* |
| 459 | * Update tx/rx chainmask. For legacy association, |
| 460 | * hard code chainmask to 1x1, for 11n association, use |
Vasanthakumar Thiagarajan | c97c92d | 2009-01-02 15:35:46 +0530 | [diff] [blame] | 461 | * the chainmask configuration, for bt coexistence, use |
| 462 | * the chainmask configuration even in legacy mode. |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 463 | */ |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 464 | void ath_update_chainmask(struct ath_softc *sc, int is_ht) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 465 | { |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 466 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 467 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 468 | |
Sujith | 3d83261 | 2009-08-21 12:00:28 +0530 | [diff] [blame] | 469 | if ((sc->sc_flags & SC_OP_SCANNING) || is_ht || |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 470 | (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE)) { |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 471 | common->tx_chainmask = ah->caps.tx_chainmask; |
| 472 | common->rx_chainmask = ah->caps.rx_chainmask; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 473 | } else { |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 474 | common->tx_chainmask = 1; |
| 475 | common->rx_chainmask = 1; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 476 | } |
| 477 | |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 478 | ath_print(common, ATH_DBG_CONFIG, |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 479 | "tx chmask: %d, rx chmask: %d\n", |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 480 | common->tx_chainmask, |
| 481 | common->rx_chainmask); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta) |
| 485 | { |
| 486 | struct ath_node *an; |
| 487 | |
| 488 | an = (struct ath_node *)sta->drv_priv; |
| 489 | |
Sujith | 87792ef | 2009-03-30 15:28:48 +0530 | [diff] [blame] | 490 | if (sc->sc_flags & SC_OP_TXAGGR) { |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 491 | ath_tx_node_init(sc, an); |
Sujith | 9e98ac6 | 2009-07-23 15:32:34 +0530 | [diff] [blame] | 492 | an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + |
Sujith | 87792ef | 2009-03-30 15:28:48 +0530 | [diff] [blame] | 493 | sta->ht_cap.ampdu_factor); |
| 494 | an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density); |
Senthil Balasubramanian | a59b5a5 | 2009-07-14 20:17:07 -0400 | [diff] [blame] | 495 | an->last_rssi = ATH_RSSI_DUMMY_MARKER; |
Sujith | 87792ef | 2009-03-30 15:28:48 +0530 | [diff] [blame] | 496 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta) |
| 500 | { |
| 501 | struct ath_node *an = (struct ath_node *)sta->drv_priv; |
| 502 | |
| 503 | if (sc->sc_flags & SC_OP_TXAGGR) |
| 504 | ath_tx_node_cleanup(sc, an); |
| 505 | } |
| 506 | |
| 507 | static void ath9k_tasklet(unsigned long data) |
| 508 | { |
| 509 | struct ath_softc *sc = (struct ath_softc *)data; |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 510 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 511 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 512 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 513 | u32 status = sc->intrstatus; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 514 | |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 515 | ath9k_ps_wakeup(sc); |
| 516 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 517 | if (status & ATH9K_INT_FATAL) { |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 518 | ath_reset(sc, false); |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 519 | ath9k_ps_restore(sc); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 520 | return; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 521 | } |
| 522 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 523 | if (status & (ATH9K_INT_RX | ATH9K_INT_RXEOL | ATH9K_INT_RXORN)) { |
| 524 | spin_lock_bh(&sc->rx.rxflushlock); |
| 525 | ath_rx_tasklet(sc, 0); |
| 526 | spin_unlock_bh(&sc->rx.rxflushlock); |
| 527 | } |
| 528 | |
| 529 | if (status & ATH9K_INT_TX) |
| 530 | ath_tx_tasklet(sc); |
| 531 | |
Gabor Juhos | 9614832 | 2009-07-24 17:27:21 +0200 | [diff] [blame] | 532 | if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) { |
Jouni Malinen | 54ce846 | 2009-05-19 17:01:40 +0300 | [diff] [blame] | 533 | /* |
| 534 | * TSF sync does not look correct; remain awake to sync with |
| 535 | * the next Beacon. |
| 536 | */ |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 537 | ath_print(common, ATH_DBG_PS, |
| 538 | "TSFOOR - Sync with next Beacon\n"); |
Jouni Malinen | ccdfeab | 2009-05-20 21:59:08 +0300 | [diff] [blame] | 539 | sc->sc_flags |= SC_OP_WAIT_FOR_BEACON | SC_OP_BEACON_SYNC; |
Jouni Malinen | 54ce846 | 2009-05-19 17:01:40 +0300 | [diff] [blame] | 540 | } |
| 541 | |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 542 | if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) |
Vasanthakumar Thiagarajan | ebb8e1d | 2009-09-01 17:46:32 +0530 | [diff] [blame] | 543 | if (status & ATH9K_INT_GENTIMER) |
| 544 | ath_gen_timer_isr(sc->sc_ah); |
| 545 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 546 | /* re-enable hardware interrupt */ |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 547 | ath9k_hw_set_interrupts(ah, sc->imask); |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 548 | ath9k_ps_restore(sc); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 549 | } |
| 550 | |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 551 | irqreturn_t ath_isr(int irq, void *dev) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 552 | { |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 553 | #define SCHED_INTR ( \ |
| 554 | ATH9K_INT_FATAL | \ |
| 555 | ATH9K_INT_RXORN | \ |
| 556 | ATH9K_INT_RXEOL | \ |
| 557 | ATH9K_INT_RX | \ |
| 558 | ATH9K_INT_TX | \ |
| 559 | ATH9K_INT_BMISS | \ |
| 560 | ATH9K_INT_CST | \ |
Vasanthakumar Thiagarajan | ebb8e1d | 2009-09-01 17:46:32 +0530 | [diff] [blame] | 561 | ATH9K_INT_TSFOOR | \ |
| 562 | ATH9K_INT_GENTIMER) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 563 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 564 | struct ath_softc *sc = dev; |
Sujith | cbe61d8a | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 565 | struct ath_hw *ah = sc->sc_ah; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 566 | enum ath9k_int status; |
| 567 | bool sched = false; |
| 568 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 569 | /* |
| 570 | * The hardware is not ready/present, don't |
| 571 | * touch anything. Note this can happen early |
| 572 | * on if the IRQ is shared. |
| 573 | */ |
| 574 | if (sc->sc_flags & SC_OP_INVALID) |
| 575 | return IRQ_NONE; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 576 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 577 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 578 | /* shared irq, not for us */ |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 579 | |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 580 | if (!ath9k_hw_intrpend(ah)) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 581 | return IRQ_NONE; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 582 | |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 583 | /* |
| 584 | * Figure out the reason(s) for the interrupt. Note |
| 585 | * that the hal returns a pseudo-ISR that may include |
| 586 | * bits we haven't explicitly enabled so we mask the |
| 587 | * value to insure we only process bits we requested. |
| 588 | */ |
| 589 | ath9k_hw_getisr(ah, &status); /* NB: clears ISR too */ |
| 590 | status &= sc->imask; /* discard unasked-for bits */ |
| 591 | |
| 592 | /* |
| 593 | * If there are no status bits set, then this interrupt was not |
| 594 | * for me (should have been caught above). |
| 595 | */ |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 596 | if (!status) |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 597 | return IRQ_NONE; |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 598 | |
| 599 | /* Cache the status */ |
| 600 | sc->intrstatus = status; |
| 601 | |
| 602 | if (status & SCHED_INTR) |
| 603 | sched = true; |
| 604 | |
| 605 | /* |
| 606 | * If a FATAL or RXORN interrupt is received, we have to reset the |
| 607 | * chip immediately. |
| 608 | */ |
| 609 | if (status & (ATH9K_INT_FATAL | ATH9K_INT_RXORN)) |
| 610 | goto chip_reset; |
| 611 | |
| 612 | if (status & ATH9K_INT_SWBA) |
| 613 | tasklet_schedule(&sc->bcon_tasklet); |
| 614 | |
| 615 | if (status & ATH9K_INT_TXURN) |
| 616 | ath9k_hw_updatetxtriglevel(ah, true); |
| 617 | |
| 618 | if (status & ATH9K_INT_MIB) { |
| 619 | /* |
| 620 | * Disable interrupts until we service the MIB |
| 621 | * interrupt; otherwise it will continue to |
| 622 | * fire. |
| 623 | */ |
| 624 | ath9k_hw_set_interrupts(ah, 0); |
| 625 | /* |
| 626 | * Let the hal handle the event. We assume |
| 627 | * it will clear whatever condition caused |
| 628 | * the interrupt. |
| 629 | */ |
Vasanthakumar Thiagarajan | 22e66a4 | 2009-08-19 16:23:40 +0530 | [diff] [blame] | 630 | ath9k_hw_procmibevent(ah); |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 631 | ath9k_hw_set_interrupts(ah, sc->imask); |
| 632 | } |
| 633 | |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 634 | if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP)) |
| 635 | if (status & ATH9K_INT_TIM_TIMER) { |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 636 | /* Clear RxAbort bit so that we can |
| 637 | * receive frames */ |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 638 | ath9k_setpower(sc, ATH9K_PM_AWAKE); |
Vasanthakumar Thiagarajan | 153e080 | 2009-05-15 02:47:16 -0400 | [diff] [blame] | 639 | ath9k_hw_setrxabort(sc->sc_ah, 0); |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 640 | sc->sc_flags |= SC_OP_WAIT_FOR_BEACON; |
| 641 | } |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 642 | |
| 643 | chip_reset: |
| 644 | |
Sujith | 817e11d | 2008-12-07 21:42:44 +0530 | [diff] [blame] | 645 | ath_debug_stat_interrupt(sc, status); |
| 646 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 647 | if (sched) { |
| 648 | /* turn off every interrupt except SWBA */ |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 649 | ath9k_hw_set_interrupts(ah, (sc->imask & ATH9K_INT_SWBA)); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 650 | tasklet_schedule(&sc->intr_tq); |
| 651 | } |
| 652 | |
| 653 | return IRQ_HANDLED; |
Sujith | 063d8be | 2009-03-30 15:28:49 +0530 | [diff] [blame] | 654 | |
| 655 | #undef SCHED_INTR |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 656 | } |
| 657 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 658 | static u32 ath_get_extchanmode(struct ath_softc *sc, |
Sujith | 99405f9 | 2008-11-24 12:08:35 +0530 | [diff] [blame] | 659 | struct ieee80211_channel *chan, |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 660 | enum nl80211_channel_type channel_type) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 661 | { |
| 662 | u32 chanmode = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 663 | |
| 664 | switch (chan->band) { |
| 665 | case IEEE80211_BAND_2GHZ: |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 666 | switch(channel_type) { |
| 667 | case NL80211_CHAN_NO_HT: |
| 668 | case NL80211_CHAN_HT20: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 669 | chanmode = CHANNEL_G_HT20; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 670 | break; |
| 671 | case NL80211_CHAN_HT40PLUS: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 672 | chanmode = CHANNEL_G_HT40PLUS; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 673 | break; |
| 674 | case NL80211_CHAN_HT40MINUS: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 675 | chanmode = CHANNEL_G_HT40MINUS; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 676 | break; |
| 677 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 678 | break; |
| 679 | case IEEE80211_BAND_5GHZ: |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 680 | switch(channel_type) { |
| 681 | case NL80211_CHAN_NO_HT: |
| 682 | case NL80211_CHAN_HT20: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 683 | chanmode = CHANNEL_A_HT20; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 684 | break; |
| 685 | case NL80211_CHAN_HT40PLUS: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 686 | chanmode = CHANNEL_A_HT40PLUS; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 687 | break; |
| 688 | case NL80211_CHAN_HT40MINUS: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 689 | chanmode = CHANNEL_A_HT40MINUS; |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 690 | break; |
| 691 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 692 | break; |
| 693 | default: |
| 694 | break; |
| 695 | } |
| 696 | |
| 697 | return chanmode; |
| 698 | } |
| 699 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 700 | static int ath_setkey_tkip(struct ath_common *common, u16 keyix, const u8 *key, |
Jouni Malinen | 3f53dd6 | 2009-02-26 11:18:46 +0200 | [diff] [blame] | 701 | struct ath9k_keyval *hk, const u8 *addr, |
| 702 | bool authenticator) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 703 | { |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 704 | struct ath_hw *ah = common->ah; |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 705 | const u8 *key_rxmic; |
| 706 | const u8 *key_txmic; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 707 | |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 708 | key_txmic = key + NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY; |
| 709 | key_rxmic = key + NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 710 | |
| 711 | if (addr == NULL) { |
Jouni Malinen | d216aaa | 2009-03-03 13:11:53 +0200 | [diff] [blame] | 712 | /* |
| 713 | * Group key installation - only two key cache entries are used |
| 714 | * regardless of splitmic capability since group key is only |
| 715 | * used either for TX or RX. |
| 716 | */ |
Jouni Malinen | 3f53dd6 | 2009-02-26 11:18:46 +0200 | [diff] [blame] | 717 | if (authenticator) { |
| 718 | memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic)); |
| 719 | memcpy(hk->kv_txmic, key_txmic, sizeof(hk->kv_mic)); |
| 720 | } else { |
| 721 | memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic)); |
| 722 | memcpy(hk->kv_txmic, key_rxmic, sizeof(hk->kv_mic)); |
| 723 | } |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 724 | return ath9k_hw_set_keycache_entry(ah, keyix, hk, addr); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 725 | } |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 726 | if (!common->splitmic) { |
Jouni Malinen | d216aaa | 2009-03-03 13:11:53 +0200 | [diff] [blame] | 727 | /* TX and RX keys share the same key cache entry. */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 728 | memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic)); |
| 729 | memcpy(hk->kv_txmic, key_txmic, sizeof(hk->kv_txmic)); |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 730 | return ath9k_hw_set_keycache_entry(ah, keyix, hk, addr); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 731 | } |
Jouni Malinen | d216aaa | 2009-03-03 13:11:53 +0200 | [diff] [blame] | 732 | |
| 733 | /* Separate key cache entries for TX and RX */ |
| 734 | |
| 735 | /* TX key goes at first index, RX key at +32. */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 736 | memcpy(hk->kv_mic, key_txmic, sizeof(hk->kv_mic)); |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 737 | if (!ath9k_hw_set_keycache_entry(ah, keyix, hk, NULL)) { |
Jouni Malinen | d216aaa | 2009-03-03 13:11:53 +0200 | [diff] [blame] | 738 | /* TX MIC entry failed. No need to proceed further */ |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 739 | ath_print(common, ATH_DBG_FATAL, |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 740 | "Setting TX MIC Key Failed\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 741 | return 0; |
| 742 | } |
| 743 | |
| 744 | memcpy(hk->kv_mic, key_rxmic, sizeof(hk->kv_mic)); |
| 745 | /* XXX delete tx key on failure? */ |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 746 | return ath9k_hw_set_keycache_entry(ah, keyix + 32, hk, addr); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 747 | } |
| 748 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 749 | static int ath_reserve_key_cache_slot_tkip(struct ath_common *common) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 750 | { |
| 751 | int i; |
| 752 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 753 | for (i = IEEE80211_WEP_NKID; i < common->keymax / 2; i++) { |
| 754 | if (test_bit(i, common->keymap) || |
| 755 | test_bit(i + 64, common->keymap)) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 756 | continue; /* At least one part of TKIP key allocated */ |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 757 | if (common->splitmic && |
| 758 | (test_bit(i + 32, common->keymap) || |
| 759 | test_bit(i + 64 + 32, common->keymap))) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 760 | continue; /* At least one part of TKIP key allocated */ |
| 761 | |
| 762 | /* Found a free slot for a TKIP key */ |
| 763 | return i; |
| 764 | } |
| 765 | return -1; |
| 766 | } |
| 767 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 768 | static int ath_reserve_key_cache_slot(struct ath_common *common) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 769 | { |
| 770 | int i; |
| 771 | |
| 772 | /* First, try to find slots that would not be available for TKIP. */ |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 773 | if (common->splitmic) { |
| 774 | for (i = IEEE80211_WEP_NKID; i < common->keymax / 4; i++) { |
| 775 | if (!test_bit(i, common->keymap) && |
| 776 | (test_bit(i + 32, common->keymap) || |
| 777 | test_bit(i + 64, common->keymap) || |
| 778 | test_bit(i + 64 + 32, common->keymap))) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 779 | return i; |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 780 | if (!test_bit(i + 32, common->keymap) && |
| 781 | (test_bit(i, common->keymap) || |
| 782 | test_bit(i + 64, common->keymap) || |
| 783 | test_bit(i + 64 + 32, common->keymap))) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 784 | return i + 32; |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 785 | if (!test_bit(i + 64, common->keymap) && |
| 786 | (test_bit(i , common->keymap) || |
| 787 | test_bit(i + 32, common->keymap) || |
| 788 | test_bit(i + 64 + 32, common->keymap))) |
Jouni Malinen | ea61213 | 2008-12-18 14:31:10 +0200 | [diff] [blame] | 789 | return i + 64; |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 790 | if (!test_bit(i + 64 + 32, common->keymap) && |
| 791 | (test_bit(i, common->keymap) || |
| 792 | test_bit(i + 32, common->keymap) || |
| 793 | test_bit(i + 64, common->keymap))) |
Jouni Malinen | ea61213 | 2008-12-18 14:31:10 +0200 | [diff] [blame] | 794 | return i + 64 + 32; |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 795 | } |
| 796 | } else { |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 797 | for (i = IEEE80211_WEP_NKID; i < common->keymax / 2; i++) { |
| 798 | if (!test_bit(i, common->keymap) && |
| 799 | test_bit(i + 64, common->keymap)) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 800 | return i; |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 801 | if (test_bit(i, common->keymap) && |
| 802 | !test_bit(i + 64, common->keymap)) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 803 | return i + 64; |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | /* No partially used TKIP slots, pick any available slot */ |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 808 | for (i = IEEE80211_WEP_NKID; i < common->keymax; i++) { |
Jouni Malinen | be2864c | 2008-12-18 14:33:00 +0200 | [diff] [blame] | 809 | /* Do not allow slots that could be needed for TKIP group keys |
| 810 | * to be used. This limitation could be removed if we know that |
| 811 | * TKIP will not be used. */ |
| 812 | if (i >= 64 && i < 64 + IEEE80211_WEP_NKID) |
| 813 | continue; |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 814 | if (common->splitmic) { |
Jouni Malinen | be2864c | 2008-12-18 14:33:00 +0200 | [diff] [blame] | 815 | if (i >= 32 && i < 32 + IEEE80211_WEP_NKID) |
| 816 | continue; |
| 817 | if (i >= 64 + 32 && i < 64 + 32 + IEEE80211_WEP_NKID) |
| 818 | continue; |
| 819 | } |
| 820 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 821 | if (!test_bit(i, common->keymap)) |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 822 | return i; /* Found a free slot for a key */ |
| 823 | } |
| 824 | |
| 825 | /* No free slot found */ |
| 826 | return -1; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 827 | } |
| 828 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 829 | static int ath_key_config(struct ath_common *common, |
Jouni Malinen | 3f53dd6 | 2009-02-26 11:18:46 +0200 | [diff] [blame] | 830 | struct ieee80211_vif *vif, |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 831 | struct ieee80211_sta *sta, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 832 | struct ieee80211_key_conf *key) |
| 833 | { |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 834 | struct ath_hw *ah = common->ah; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 835 | struct ath9k_keyval hk; |
| 836 | const u8 *mac = NULL; |
| 837 | int ret = 0; |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 838 | int idx; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 839 | |
| 840 | memset(&hk, 0, sizeof(hk)); |
| 841 | |
| 842 | switch (key->alg) { |
| 843 | case ALG_WEP: |
| 844 | hk.kv_type = ATH9K_CIPHER_WEP; |
| 845 | break; |
| 846 | case ALG_TKIP: |
| 847 | hk.kv_type = ATH9K_CIPHER_TKIP; |
| 848 | break; |
| 849 | case ALG_CCMP: |
| 850 | hk.kv_type = ATH9K_CIPHER_AES_CCM; |
| 851 | break; |
| 852 | default: |
Jouni Malinen | ca470b2 | 2009-01-08 13:32:12 +0200 | [diff] [blame] | 853 | return -EOPNOTSUPP; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 854 | } |
| 855 | |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 856 | hk.kv_len = key->keylen; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 857 | memcpy(hk.kv_val, key->key, key->keylen); |
| 858 | |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 859 | if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { |
| 860 | /* For now, use the default keys for broadcast keys. This may |
| 861 | * need to change with virtual interfaces. */ |
| 862 | idx = key->keyidx; |
| 863 | } else if (key->keyidx) { |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 864 | if (WARN_ON(!sta)) |
| 865 | return -EOPNOTSUPP; |
| 866 | mac = sta->addr; |
| 867 | |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 868 | if (vif->type != NL80211_IFTYPE_AP) { |
| 869 | /* Only keyidx 0 should be used with unicast key, but |
| 870 | * allow this for client mode for now. */ |
| 871 | idx = key->keyidx; |
| 872 | } else |
| 873 | return -EIO; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 874 | } else { |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 875 | if (WARN_ON(!sta)) |
| 876 | return -EOPNOTSUPP; |
| 877 | mac = sta->addr; |
| 878 | |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 879 | if (key->alg == ALG_TKIP) |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 880 | idx = ath_reserve_key_cache_slot_tkip(common); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 881 | else |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 882 | idx = ath_reserve_key_cache_slot(common); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 883 | if (idx < 0) |
Jouni Malinen | ca470b2 | 2009-01-08 13:32:12 +0200 | [diff] [blame] | 884 | return -ENOSPC; /* no free key cache entries */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | if (key->alg == ALG_TKIP) |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 888 | ret = ath_setkey_tkip(common, idx, key->key, &hk, mac, |
Jouni Malinen | 3f53dd6 | 2009-02-26 11:18:46 +0200 | [diff] [blame] | 889 | vif->type == NL80211_IFTYPE_AP); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 890 | else |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 891 | ret = ath9k_hw_set_keycache_entry(ah, idx, &hk, mac); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 892 | |
| 893 | if (!ret) |
| 894 | return -EIO; |
| 895 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 896 | set_bit(idx, common->keymap); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 897 | if (key->alg == ALG_TKIP) { |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 898 | set_bit(idx + 64, common->keymap); |
| 899 | if (common->splitmic) { |
| 900 | set_bit(idx + 32, common->keymap); |
| 901 | set_bit(idx + 64 + 32, common->keymap); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 902 | } |
| 903 | } |
| 904 | |
| 905 | return idx; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 906 | } |
| 907 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 908 | static void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 909 | { |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 910 | struct ath_hw *ah = common->ah; |
| 911 | |
| 912 | ath9k_hw_keyreset(ah, key->hw_key_idx); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 913 | if (key->hw_key_idx < IEEE80211_WEP_NKID) |
| 914 | return; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 915 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 916 | clear_bit(key->hw_key_idx, common->keymap); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 917 | if (key->alg != ALG_TKIP) |
| 918 | return; |
| 919 | |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 920 | clear_bit(key->hw_key_idx + 64, common->keymap); |
| 921 | if (common->splitmic) { |
| 922 | clear_bit(key->hw_key_idx + 32, common->keymap); |
| 923 | clear_bit(key->hw_key_idx + 64 + 32, common->keymap); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 924 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 925 | } |
| 926 | |
Sujith | eb2599c | 2009-01-23 11:20:44 +0530 | [diff] [blame] | 927 | static void setup_ht_cap(struct ath_softc *sc, |
| 928 | struct ieee80211_sta_ht_cap *ht_info) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 929 | { |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 930 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Senthil Balasubramanian | 140add2 | 2009-06-24 18:56:42 +0530 | [diff] [blame] | 931 | u8 tx_streams, rx_streams; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 932 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 933 | ht_info->ht_supported = true; |
| 934 | ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
| 935 | IEEE80211_HT_CAP_SM_PS | |
| 936 | IEEE80211_HT_CAP_SGI_40 | |
| 937 | IEEE80211_HT_CAP_DSSSCCK40; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 938 | |
Sujith | 9e98ac6 | 2009-07-23 15:32:34 +0530 | [diff] [blame] | 939 | ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; |
| 940 | ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_8; |
Sujith | eb2599c | 2009-01-23 11:20:44 +0530 | [diff] [blame] | 941 | |
Johannes Berg | d9fe60d | 2008-10-09 12:13:49 +0200 | [diff] [blame] | 942 | /* set up supported mcs set */ |
| 943 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 944 | tx_streams = !(common->tx_chainmask & (common->tx_chainmask - 1)) ? |
| 945 | 1 : 2; |
| 946 | rx_streams = !(common->rx_chainmask & (common->rx_chainmask - 1)) ? |
| 947 | 1 : 2; |
Sujith | eb2599c | 2009-01-23 11:20:44 +0530 | [diff] [blame] | 948 | |
Senthil Balasubramanian | 140add2 | 2009-06-24 18:56:42 +0530 | [diff] [blame] | 949 | if (tx_streams != rx_streams) { |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 950 | ath_print(common, ATH_DBG_CONFIG, |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 951 | "TX streams %d, RX streams: %d\n", |
| 952 | tx_streams, rx_streams); |
Senthil Balasubramanian | 140add2 | 2009-06-24 18:56:42 +0530 | [diff] [blame] | 953 | ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; |
| 954 | ht_info->mcs.tx_params |= ((tx_streams - 1) << |
| 955 | IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); |
Sujith | eb2599c | 2009-01-23 11:20:44 +0530 | [diff] [blame] | 956 | } |
| 957 | |
Senthil Balasubramanian | 140add2 | 2009-06-24 18:56:42 +0530 | [diff] [blame] | 958 | ht_info->mcs.rx_mask[0] = 0xff; |
| 959 | if (rx_streams >= 2) |
| 960 | ht_info->mcs.rx_mask[1] = 0xff; |
| 961 | |
| 962 | ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 963 | } |
| 964 | |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 965 | static void ath9k_bss_assoc_info(struct ath_softc *sc, |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 966 | struct ieee80211_vif *vif, |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 967 | struct ieee80211_bss_conf *bss_conf) |
| 968 | { |
Luis R. Rodriguez | f2b2143 | 2009-09-10 08:50:20 -0700 | [diff] [blame] | 969 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 970 | struct ath_common *common = ath9k_hw_common(ah); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 971 | |
| 972 | if (bss_conf->assoc) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 973 | ath_print(common, ATH_DBG_CONFIG, |
| 974 | "Bss Info ASSOC %d, bssid: %pM\n", |
| 975 | bss_conf->aid, common->curbssid); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 976 | |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 977 | /* New association, store aid */ |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 978 | common->curaid = bss_conf->aid; |
Luis R. Rodriguez | f2b2143 | 2009-09-10 08:50:20 -0700 | [diff] [blame] | 979 | ath9k_hw_write_associd(ah); |
Jouni Malinen | ccdfeab | 2009-05-20 21:59:08 +0300 | [diff] [blame] | 980 | |
Senthil Balasubramanian | 2664f20 | 2009-06-24 18:56:39 +0530 | [diff] [blame] | 981 | /* |
| 982 | * Request a re-configuration of Beacon related timers |
| 983 | * on the receipt of the first Beacon frame (i.e., |
| 984 | * after time sync with the AP). |
| 985 | */ |
| 986 | sc->sc_flags |= SC_OP_BEACON_SYNC; |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 987 | |
| 988 | /* Configure the beacon */ |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 989 | ath_beacon_config(sc, vif); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 990 | |
| 991 | /* Reset rssi stats */ |
Vasanthakumar Thiagarajan | 22e66a4 | 2009-08-19 16:23:40 +0530 | [diff] [blame] | 992 | sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 993 | |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 994 | ath_start_ani(common); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 995 | } else { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 996 | ath_print(common, ATH_DBG_CONFIG, "Bss Info DISASSOC\n"); |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 997 | common->curaid = 0; |
Senthil Balasubramanian | f38faa3 | 2009-06-24 18:56:40 +0530 | [diff] [blame] | 998 | /* Stop ANI */ |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 999 | del_timer_sync(&common->ani.timer); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1000 | } |
| 1001 | } |
| 1002 | |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 1003 | void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw) |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1004 | { |
Sujith | cbe61d8a | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1005 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1006 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 1007 | struct ieee80211_channel *channel = hw->conf.channel; |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1008 | int r; |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1009 | |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1010 | ath9k_ps_wakeup(sc); |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 1011 | ath9k_hw_configpcipowersave(ah, 0, 0); |
Sujith | d2f5b3a | 2009-04-13 21:56:25 +0530 | [diff] [blame] | 1012 | |
Vasanthakumar Thiagarajan | 159cd46 | 2009-06-13 14:50:25 +0530 | [diff] [blame] | 1013 | if (!ah->curchan) |
| 1014 | ah->curchan = ath_get_curchannel(sc, sc->hw); |
| 1015 | |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1016 | spin_lock_bh(&sc->sc_resetlock); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1017 | r = ath9k_hw_reset(ah, ah->curchan, false); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1018 | if (r) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1019 | ath_print(common, ATH_DBG_FATAL, |
| 1020 | "Unable to reset channel %u (%uMhz) ", |
| 1021 | "reset status %d\n", |
| 1022 | channel->center_freq, r); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1023 | } |
| 1024 | spin_unlock_bh(&sc->sc_resetlock); |
| 1025 | |
| 1026 | ath_update_txpow(sc); |
| 1027 | if (ath_startrecv(sc) != 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1028 | ath_print(common, ATH_DBG_FATAL, |
| 1029 | "Unable to restart recv logic\n"); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1030 | return; |
| 1031 | } |
| 1032 | |
| 1033 | if (sc->sc_flags & SC_OP_BEACONS) |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 1034 | ath_beacon_config(sc, NULL); /* restart beacons */ |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1035 | |
| 1036 | /* Re-Enable interrupts */ |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1037 | ath9k_hw_set_interrupts(ah, sc->imask); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1038 | |
| 1039 | /* Enable LED */ |
Vivek Natarajan | 08fc5c1 | 2009-08-14 11:30:52 +0530 | [diff] [blame] | 1040 | ath9k_hw_cfg_output(ah, ah->led_pin, |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1041 | AR_GPIO_OUTPUT_MUX_AS_OUTPUT); |
Vivek Natarajan | 08fc5c1 | 2009-08-14 11:30:52 +0530 | [diff] [blame] | 1042 | ath9k_hw_set_gpio(ah, ah->led_pin, 0); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1043 | |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 1044 | ieee80211_wake_queues(hw); |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1045 | ath9k_ps_restore(sc); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1046 | } |
| 1047 | |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 1048 | void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw) |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1049 | { |
Sujith | cbe61d8a | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1050 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 1051 | struct ieee80211_channel *channel = hw->conf.channel; |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1052 | int r; |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1053 | |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1054 | ath9k_ps_wakeup(sc); |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 1055 | ieee80211_stop_queues(hw); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1056 | |
| 1057 | /* Disable LED */ |
Vivek Natarajan | 08fc5c1 | 2009-08-14 11:30:52 +0530 | [diff] [blame] | 1058 | ath9k_hw_set_gpio(ah, ah->led_pin, 1); |
| 1059 | ath9k_hw_cfg_gpio_input(ah, ah->led_pin); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1060 | |
| 1061 | /* Disable interrupts */ |
| 1062 | ath9k_hw_set_interrupts(ah, 0); |
| 1063 | |
Sujith | 043a040 | 2009-01-16 21:38:47 +0530 | [diff] [blame] | 1064 | ath_drain_all_txq(sc, false); /* clear pending tx frames */ |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1065 | ath_stoprecv(sc); /* turn off frame recv */ |
| 1066 | ath_flushrecv(sc); /* flush recv queue */ |
| 1067 | |
Vasanthakumar Thiagarajan | 159cd46 | 2009-06-13 14:50:25 +0530 | [diff] [blame] | 1068 | if (!ah->curchan) |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 1069 | ah->curchan = ath_get_curchannel(sc, hw); |
Vasanthakumar Thiagarajan | 159cd46 | 2009-06-13 14:50:25 +0530 | [diff] [blame] | 1070 | |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1071 | spin_lock_bh(&sc->sc_resetlock); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1072 | r = ath9k_hw_reset(ah, ah->curchan, false); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1073 | if (r) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1074 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, |
| 1075 | "Unable to reset channel %u (%uMhz) " |
| 1076 | "reset status %d\n", |
| 1077 | channel->center_freq, r); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1078 | } |
| 1079 | spin_unlock_bh(&sc->sc_resetlock); |
| 1080 | |
| 1081 | ath9k_hw_phy_disable(ah); |
Vivek Natarajan | 93b1b37 | 2009-09-17 09:24:58 +0530 | [diff] [blame] | 1082 | ath9k_hw_configpcipowersave(ah, 1, 1); |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1083 | ath9k_ps_restore(sc); |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 1084 | ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP); |
Vasanthakumar Thiagarajan | 500c064 | 2008-09-10 18:50:17 +0530 | [diff] [blame] | 1085 | } |
| 1086 | |
Luis R. Rodriguez | 7fda166 | 2009-10-06 21:19:08 -0400 | [diff] [blame] | 1087 | static void ath9k_uninit_hw(struct ath_softc *sc) |
| 1088 | { |
| 1089 | struct ath_hw *ah = sc->sc_ah; |
| 1090 | |
| 1091 | BUG_ON(!ah); |
| 1092 | |
| 1093 | ath9k_exit_debug(ah); |
| 1094 | ath9k_hw_detach(ah); |
| 1095 | sc->sc_ah = NULL; |
| 1096 | } |
| 1097 | |
Luis R. Rodriguez | 2568835 | 2009-10-06 21:19:09 -0400 | [diff] [blame] | 1098 | static void ath_clean_core(struct ath_softc *sc) |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1099 | { |
| 1100 | struct ieee80211_hw *hw = sc->hw; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1101 | struct ath_hw *ah = sc->sc_ah; |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1102 | int i = 0; |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1103 | |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1104 | ath9k_ps_wakeup(sc); |
| 1105 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1106 | dev_dbg(sc->dev, "Detach ATH hw\n"); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1107 | |
Luis R. Rodriguez | 35c95ab | 2009-07-27 11:53:03 -0700 | [diff] [blame] | 1108 | ath_deinit_leds(sc); |
Sujith | e31f7b9 | 2009-09-23 13:49:12 +0530 | [diff] [blame] | 1109 | wiphy_rfkill_stop_polling(sc->hw->wiphy); |
Luis R. Rodriguez | 35c95ab | 2009-07-27 11:53:03 -0700 | [diff] [blame] | 1110 | |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1111 | for (i = 0; i < sc->num_sec_wiphy; i++) { |
| 1112 | struct ath_wiphy *aphy = sc->sec_wiphy[i]; |
| 1113 | if (aphy == NULL) |
| 1114 | continue; |
| 1115 | sc->sec_wiphy[i] = NULL; |
| 1116 | ieee80211_unregister_hw(aphy->hw); |
| 1117 | ieee80211_free_hw(aphy->hw); |
| 1118 | } |
Vasanthakumar Thiagarajan | 3fcdfb4 | 2008-11-18 01:19:56 +0530 | [diff] [blame] | 1119 | ieee80211_unregister_hw(hw); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1120 | ath_rx_cleanup(sc); |
| 1121 | ath_tx_cleanup(sc); |
| 1122 | |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1123 | tasklet_kill(&sc->intr_tq); |
| 1124 | tasklet_kill(&sc->bcon_tasklet); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1125 | |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1126 | if (!(sc->sc_flags & SC_OP_INVALID)) |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 1127 | ath9k_setpower(sc, ATH9K_PM_AWAKE); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1128 | |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1129 | /* cleanup tx queues */ |
| 1130 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) |
| 1131 | if (ATH_TXQ_SETUP(sc, i)) |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1132 | ath_tx_cleanupq(sc, &sc->tx.txq[i]); |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1133 | |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 1134 | if ((sc->btcoex.no_stomp_timer) && |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 1135 | ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 1136 | ath_gen_timer_free(ah, sc->btcoex.no_stomp_timer); |
Luis R. Rodriguez | 2568835 | 2009-10-06 21:19:09 -0400 | [diff] [blame] | 1137 | } |
Vasanthakumar Thiagarajan | 1773912 | 2009-08-26 21:08:50 +0530 | [diff] [blame] | 1138 | |
Luis R. Rodriguez | 2568835 | 2009-10-06 21:19:09 -0400 | [diff] [blame] | 1139 | void ath_detach(struct ath_softc *sc) |
| 1140 | { |
| 1141 | ath_clean_core(sc); |
Luis R. Rodriguez | 7fda166 | 2009-10-06 21:19:08 -0400 | [diff] [blame] | 1142 | ath9k_uninit_hw(sc); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1143 | } |
| 1144 | |
Luis R. Rodriguez | bd96d39 | 2009-10-06 21:19:10 -0400 | [diff] [blame] | 1145 | void ath_cleanup(struct ath_softc *sc) |
| 1146 | { |
| 1147 | struct ath_hw *ah = sc->sc_ah; |
| 1148 | struct ath_common *common = ath9k_hw_common(ah); |
| 1149 | |
| 1150 | ath_clean_core(sc); |
| 1151 | free_irq(sc->irq, sc); |
| 1152 | ath_bus_cleanup(common); |
| 1153 | kfree(sc->sec_wiphy); |
| 1154 | ieee80211_free_hw(sc->hw); |
| 1155 | |
| 1156 | ath9k_uninit_hw(sc); |
| 1157 | } |
| 1158 | |
Bob Copeland | e3bb249 | 2009-03-30 22:30:30 -0400 | [diff] [blame] | 1159 | static int ath9k_reg_notifier(struct wiphy *wiphy, |
| 1160 | struct regulatory_request *request) |
| 1161 | { |
| 1162 | struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); |
| 1163 | struct ath_wiphy *aphy = hw->priv; |
| 1164 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | 27c51f1 | 2009-09-10 11:08:14 -0700 | [diff] [blame] | 1165 | struct ath_regulatory *reg = ath9k_hw_regulatory(sc->sc_ah); |
Bob Copeland | e3bb249 | 2009-03-30 22:30:30 -0400 | [diff] [blame] | 1166 | |
| 1167 | return ath_reg_notifier_apply(wiphy, request, reg); |
| 1168 | } |
| 1169 | |
Luis R. Rodriguez | 1e40bcf | 2009-08-03 12:24:47 -0700 | [diff] [blame] | 1170 | /* |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1171 | * Read and write, they both share the same lock. We do this to serialize |
| 1172 | * reads and writes on Atheros 802.11n PCI devices only. This is required |
| 1173 | * as the FIFO on these devices can only accept sanely 2 requests. After |
| 1174 | * that the device goes bananas. Serializing the reads/writes prevents this |
| 1175 | * from happening. |
| 1176 | */ |
| 1177 | |
| 1178 | static void ath9k_iowrite32(void *hw_priv, u32 val, u32 reg_offset) |
| 1179 | { |
| 1180 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1181 | struct ath_common *common = ath9k_hw_common(ah); |
| 1182 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1183 | |
| 1184 | if (ah->config.serialize_regmode == SER_REG_MODE_ON) { |
| 1185 | unsigned long flags; |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1186 | spin_lock_irqsave(&sc->sc_serial_rw, flags); |
| 1187 | iowrite32(val, sc->mem + reg_offset); |
| 1188 | spin_unlock_irqrestore(&sc->sc_serial_rw, flags); |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1189 | } else |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1190 | iowrite32(val, sc->mem + reg_offset); |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | static unsigned int ath9k_ioread32(void *hw_priv, u32 reg_offset) |
| 1194 | { |
| 1195 | struct ath_hw *ah = (struct ath_hw *) hw_priv; |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1196 | struct ath_common *common = ath9k_hw_common(ah); |
| 1197 | struct ath_softc *sc = (struct ath_softc *) common->priv; |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1198 | u32 val; |
| 1199 | |
| 1200 | if (ah->config.serialize_regmode == SER_REG_MODE_ON) { |
| 1201 | unsigned long flags; |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1202 | spin_lock_irqsave(&sc->sc_serial_rw, flags); |
| 1203 | val = ioread32(sc->mem + reg_offset); |
| 1204 | spin_unlock_irqrestore(&sc->sc_serial_rw, flags); |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1205 | } else |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1206 | val = ioread32(sc->mem + reg_offset); |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1207 | return val; |
| 1208 | } |
| 1209 | |
Luis R. Rodriguez | 2ddb5c8 | 2009-09-14 02:09:38 -0700 | [diff] [blame] | 1210 | static const struct ath_ops ath9k_common_ops = { |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1211 | .read = ath9k_ioread32, |
| 1212 | .write = ath9k_iowrite32, |
| 1213 | }; |
| 1214 | |
| 1215 | /* |
Luis R. Rodriguez | 1e40bcf | 2009-08-03 12:24:47 -0700 | [diff] [blame] | 1216 | * Initialize and fill ath_softc, ath_sofct is the |
| 1217 | * "Software Carrier" struct. Historically it has existed |
| 1218 | * to allow the separation between hardware specific |
| 1219 | * variables (now in ath_hw) and driver specific variables. |
| 1220 | */ |
Luis R. Rodriguez | 5bb1279 | 2009-09-14 00:55:09 -0700 | [diff] [blame] | 1221 | static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, |
| 1222 | const struct ath_bus_ops *bus_ops) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1223 | { |
Sujith | cbe61d8a | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1224 | struct ath_hw *ah = NULL; |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1225 | struct ath_common *common; |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1226 | int r = 0, i; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1227 | int csz = 0; |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 1228 | int qnum; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1229 | |
| 1230 | /* XXX: hardware will not be ready until ath_open() being called */ |
| 1231 | sc->sc_flags |= SC_OP_INVALID; |
Sujith | 88b126a | 2008-11-28 22:19:02 +0530 | [diff] [blame] | 1232 | |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1233 | spin_lock_init(&sc->wiphy_lock); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1234 | spin_lock_init(&sc->sc_resetlock); |
Luis R. Rodriguez | 6158425 | 2009-03-12 18:18:49 -0400 | [diff] [blame] | 1235 | spin_lock_init(&sc->sc_serial_rw); |
Gabor Juhos | 04717cc | 2009-07-14 20:17:13 -0400 | [diff] [blame] | 1236 | spin_lock_init(&sc->sc_pm_lock); |
Sujith | aa33de0 | 2008-12-18 11:40:16 +0530 | [diff] [blame] | 1237 | mutex_init(&sc->mutex); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1238 | tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); |
Sujith | 9fc9ab0 | 2009-03-03 10:16:51 +0530 | [diff] [blame] | 1239 | tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet, |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1240 | (unsigned long)sc); |
| 1241 | |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1242 | ah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL); |
Luis R. Rodriguez | 211f585 | 2009-10-06 21:19:07 -0400 | [diff] [blame] | 1243 | if (!ah) |
| 1244 | return -ENOMEM; |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1245 | |
Luis R. Rodriguez | 8df5d1b | 2009-08-03 12:24:37 -0700 | [diff] [blame] | 1246 | ah->hw_version.devid = devid; |
Vasanthakumar Thiagarajan | aeac355 | 2009-09-09 15:25:49 +0530 | [diff] [blame] | 1247 | ah->hw_version.subsysid = subsysid; |
Luis R. Rodriguez | e1e2f93 | 2009-08-03 12:24:38 -0700 | [diff] [blame] | 1248 | sc->sc_ah = ah; |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1249 | |
Luis R. Rodriguez | 27c51f1 | 2009-09-10 11:08:14 -0700 | [diff] [blame] | 1250 | common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 9e4bffd | 2009-09-10 16:11:21 -0700 | [diff] [blame] | 1251 | common->ops = &ath9k_common_ops; |
Luis R. Rodriguez | 5bb1279 | 2009-09-14 00:55:09 -0700 | [diff] [blame] | 1252 | common->bus_ops = bus_ops; |
Luis R. Rodriguez | 13b8155 | 2009-09-10 17:52:45 -0700 | [diff] [blame] | 1253 | common->ah = ah; |
Luis R. Rodriguez | b002a4a | 2009-09-13 00:03:27 -0700 | [diff] [blame] | 1254 | common->hw = sc->hw; |
Luis R. Rodriguez | bc974f4 | 2009-09-28 02:54:40 -0400 | [diff] [blame] | 1255 | common->priv = sc; |
Luis R. Rodriguez | faa27fa | 2009-10-06 21:19:06 -0400 | [diff] [blame] | 1256 | common->debug_mask = ath9k_debug; |
Luis R. Rodriguez | 27c51f1 | 2009-09-10 11:08:14 -0700 | [diff] [blame] | 1257 | |
| 1258 | /* |
| 1259 | * Cache line size is used to size and align various |
| 1260 | * structures used to communicate with the hardware. |
| 1261 | */ |
Luis R. Rodriguez | 5bb1279 | 2009-09-14 00:55:09 -0700 | [diff] [blame] | 1262 | ath_read_cachesize(common, &csz); |
Luis R. Rodriguez | 27c51f1 | 2009-09-10 11:08:14 -0700 | [diff] [blame] | 1263 | /* XXX assert csz is non-zero */ |
| 1264 | common->cachelsz = csz << 2; /* convert to bytes */ |
| 1265 | |
Luis R. Rodriguez | f637cfd | 2009-08-03 12:24:46 -0700 | [diff] [blame] | 1266 | r = ath9k_hw_init(ah); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1267 | if (r) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1268 | ath_print(common, ATH_DBG_FATAL, |
| 1269 | "Unable to initialize hardware; " |
| 1270 | "initialization status: %d\n", r); |
Luis R. Rodriguez | 211f585 | 2009-10-06 21:19:07 -0400 | [diff] [blame] | 1271 | goto bad_free_hw; |
| 1272 | } |
| 1273 | |
| 1274 | if (ath9k_init_debug(ah) < 0) { |
| 1275 | ath_print(common, ATH_DBG_FATAL, |
| 1276 | "Unable to create debugfs files\n"); |
| 1277 | goto bad_free_hw; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1278 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1279 | |
| 1280 | /* Get the hardware key cache size. */ |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 1281 | common->keymax = ah->caps.keycache_size; |
| 1282 | if (common->keymax > ATH_KEYMAX) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1283 | ath_print(common, ATH_DBG_ANY, |
| 1284 | "Warning, using only %u entries in %u key cache\n", |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 1285 | ATH_KEYMAX, common->keymax); |
| 1286 | common->keymax = ATH_KEYMAX; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1287 | } |
| 1288 | |
| 1289 | /* |
| 1290 | * Reset the key cache since some parts do not |
| 1291 | * reset the contents on initial power up. |
| 1292 | */ |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 1293 | for (i = 0; i < common->keymax; i++) |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1294 | ath9k_hw_keyreset(ah, (u16) i); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1295 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1296 | /* default to MONITOR mode */ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1297 | sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR; |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 1298 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1299 | /* |
| 1300 | * Allocate hardware transmit queues: one queue for |
| 1301 | * beacon frames and one data queue for each QoS |
| 1302 | * priority. Note that the hal handles reseting |
| 1303 | * these queues at the needed time. |
| 1304 | */ |
Luis R. Rodriguez | 536b3a7 | 2009-10-06 21:19:11 -0400 | [diff] [blame] | 1305 | sc->beacon.beaconq = ath9k_hw_beaconq_setup(ah); |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1306 | if (sc->beacon.beaconq == -1) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1307 | ath_print(common, ATH_DBG_FATAL, |
| 1308 | "Unable to setup a beacon xmit queue\n"); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1309 | r = -EIO; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1310 | goto bad2; |
| 1311 | } |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1312 | sc->beacon.cabq = ath_txq_setup(sc, ATH9K_TX_QUEUE_CAB, 0); |
| 1313 | if (sc->beacon.cabq == NULL) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1314 | ath_print(common, ATH_DBG_FATAL, |
| 1315 | "Unable to setup CAB xmit queue\n"); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1316 | r = -EIO; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1317 | goto bad2; |
| 1318 | } |
| 1319 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1320 | sc->config.cabqReadytime = ATH_CABQ_READY_TIME; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1321 | ath_cabq_update(sc); |
| 1322 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1323 | for (i = 0; i < ARRAY_SIZE(sc->tx.hwq_map); i++) |
| 1324 | sc->tx.hwq_map[i] = -1; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1325 | |
| 1326 | /* Setup data queues */ |
| 1327 | /* NB: ensure BK queue is the lowest priority h/w queue */ |
| 1328 | if (!ath_tx_setup(sc, ATH9K_WME_AC_BK)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1329 | ath_print(common, ATH_DBG_FATAL, |
| 1330 | "Unable to setup xmit queue for BK traffic\n"); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1331 | r = -EIO; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1332 | goto bad2; |
| 1333 | } |
| 1334 | |
| 1335 | if (!ath_tx_setup(sc, ATH9K_WME_AC_BE)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1336 | ath_print(common, ATH_DBG_FATAL, |
| 1337 | "Unable to setup xmit queue for BE traffic\n"); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1338 | r = -EIO; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1339 | goto bad2; |
| 1340 | } |
| 1341 | if (!ath_tx_setup(sc, ATH9K_WME_AC_VI)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1342 | ath_print(common, ATH_DBG_FATAL, |
| 1343 | "Unable to setup xmit queue for VI traffic\n"); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1344 | r = -EIO; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1345 | goto bad2; |
| 1346 | } |
| 1347 | if (!ath_tx_setup(sc, ATH9K_WME_AC_VO)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1348 | ath_print(common, ATH_DBG_FATAL, |
| 1349 | "Unable to setup xmit queue for VO traffic\n"); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1350 | r = -EIO; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1351 | goto bad2; |
| 1352 | } |
| 1353 | |
| 1354 | /* Initializes the noise floor to a reasonable default value. |
| 1355 | * Later on this will be updated during ANI processing. */ |
| 1356 | |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 1357 | common->ani.noise_floor = ATH_DEFAULT_NOISE_FLOOR; |
| 1358 | setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1359 | |
| 1360 | if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER, |
| 1361 | ATH9K_CIPHER_TKIP, NULL)) { |
| 1362 | /* |
| 1363 | * Whether we should enable h/w TKIP MIC. |
| 1364 | * XXX: if we don't support WME TKIP MIC, then we wouldn't |
| 1365 | * report WMM capable, so it's always safe to turn on |
| 1366 | * TKIP MIC in this case. |
| 1367 | */ |
| 1368 | ath9k_hw_setcapability(sc->sc_ah, ATH9K_CAP_TKIP_MIC, |
| 1369 | 0, 1, NULL); |
| 1370 | } |
| 1371 | |
| 1372 | /* |
| 1373 | * Check whether the separate key cache entries |
| 1374 | * are required to handle both tx+rx MIC keys. |
| 1375 | * With split mic keys the number of stations is limited |
| 1376 | * to 27 otherwise 59. |
| 1377 | */ |
| 1378 | if (ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER, |
| 1379 | ATH9K_CIPHER_TKIP, NULL) |
| 1380 | && ath9k_hw_getcapability(ah, ATH9K_CAP_CIPHER, |
| 1381 | ATH9K_CIPHER_MIC, NULL) |
| 1382 | && ath9k_hw_getcapability(ah, ATH9K_CAP_TKIP_SPLIT, |
| 1383 | 0, NULL)) |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 1384 | common->splitmic = 1; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1385 | |
| 1386 | /* turn on mcast key search if possible */ |
| 1387 | if (!ath9k_hw_getcapability(ah, ATH9K_CAP_MCAST_KEYSRCH, 0, NULL)) |
| 1388 | (void)ath9k_hw_setcapability(ah, ATH9K_CAP_MCAST_KEYSRCH, 1, |
| 1389 | 1, NULL); |
| 1390 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1391 | sc->config.txpowlimit = ATH_TXPOWER_MAX; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1392 | |
| 1393 | /* 11n Capabilities */ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1394 | if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) { |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1395 | sc->sc_flags |= SC_OP_TXAGGR; |
| 1396 | sc->sc_flags |= SC_OP_RXAGGR; |
| 1397 | } |
| 1398 | |
Luis R. Rodriguez | 43c2761 | 2009-09-13 21:07:07 -0700 | [diff] [blame] | 1399 | common->tx_chainmask = ah->caps.tx_chainmask; |
| 1400 | common->rx_chainmask = ah->caps.rx_chainmask; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1401 | |
| 1402 | ath9k_hw_setcapability(ah, ATH9K_CAP_DIVERSITY, 1, true, NULL); |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1403 | sc->rx.defant = ath9k_hw_getdefantenna(ah); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1404 | |
Jouni Malinen | 8ca21f0 | 2009-03-03 19:23:27 +0200 | [diff] [blame] | 1405 | if (ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK) |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1406 | memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1407 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1408 | sc->beacon.slottime = ATH9K_SLOT_TIME_9; /* default to short slot time */ |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1409 | |
| 1410 | /* initialize beacon slots */ |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1411 | for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) { |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 1412 | sc->beacon.bslot[i] = NULL; |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1413 | sc->beacon.bslot_aphy[i] = NULL; |
| 1414 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1415 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1416 | /* setup channels and rates */ |
| 1417 | |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 1418 | if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) { |
| 1419 | sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable; |
| 1420 | sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; |
| 1421 | sc->sbands[IEEE80211_BAND_2GHZ].n_channels = |
| 1422 | ARRAY_SIZE(ath9k_2ghz_chantable); |
| 1423 | sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates; |
| 1424 | sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates = |
| 1425 | ARRAY_SIZE(ath9k_legacy_rates); |
| 1426 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1427 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1428 | if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) { |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1429 | sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1430 | sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1431 | sc->sbands[IEEE80211_BAND_5GHZ].n_channels = |
| 1432 | ARRAY_SIZE(ath9k_5ghz_chantable); |
Felix Fietkau | 545750d | 2009-11-23 22:21:01 +0100 | [diff] [blame] | 1433 | sc->sbands[IEEE80211_BAND_5GHZ].bitrates = |
| 1434 | ath9k_legacy_rates + 4; |
| 1435 | sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates = |
| 1436 | ARRAY_SIZE(ath9k_legacy_rates) - 4; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1437 | } |
| 1438 | |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 1439 | switch (ah->btcoex_hw.scheme) { |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 1440 | case ATH_BTCOEX_CFG_NONE: |
| 1441 | break; |
| 1442 | case ATH_BTCOEX_CFG_2WIRE: |
| 1443 | ath9k_hw_btcoex_init_2wire(ah); |
| 1444 | break; |
| 1445 | case ATH_BTCOEX_CFG_3WIRE: |
| 1446 | ath9k_hw_btcoex_init_3wire(ah); |
| 1447 | r = ath_init_btcoex_timer(sc); |
Vasanthakumar Thiagarajan | 1773912 | 2009-08-26 21:08:50 +0530 | [diff] [blame] | 1448 | if (r) |
| 1449 | goto bad2; |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 1450 | qnum = ath_tx_get_qnum(sc, ATH9K_TX_QUEUE_DATA, ATH9K_WME_AC_BE); |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 1451 | ath9k_hw_init_btcoex_hw(ah, qnum); |
Luis R. Rodriguez | e08a6ac | 2009-09-09 14:26:15 -0700 | [diff] [blame] | 1452 | sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 1453 | break; |
| 1454 | default: |
| 1455 | WARN_ON(1); |
| 1456 | break; |
Vasanthakumar Thiagarajan | 1773912 | 2009-08-26 21:08:50 +0530 | [diff] [blame] | 1457 | } |
Vasanthakumar Thiagarajan | c97c92d | 2009-01-02 15:35:46 +0530 | [diff] [blame] | 1458 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1459 | return 0; |
| 1460 | bad2: |
| 1461 | /* cleanup tx queues */ |
| 1462 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) |
| 1463 | if (ATH_TXQ_SETUP(sc, i)) |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1464 | ath_tx_cleanupq(sc, &sc->tx.txq[i]); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1465 | |
Luis R. Rodriguez | 211f585 | 2009-10-06 21:19:07 -0400 | [diff] [blame] | 1466 | bad_free_hw: |
Luis R. Rodriguez | 7fda166 | 2009-10-06 21:19:08 -0400 | [diff] [blame] | 1467 | ath9k_uninit_hw(sc); |
Luis R. Rodriguez | 4f3acf8 | 2009-08-03 12:24:36 -0700 | [diff] [blame] | 1468 | return r; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1469 | } |
| 1470 | |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1471 | void ath_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1472 | { |
Luis R. Rodriguez | 14acdde | 2009-12-18 11:26:04 -0500 | [diff] [blame] | 1473 | struct ath_hw *ah = sc->sc_ah; |
| 1474 | |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1475 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | |
| 1476 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | |
| 1477 | IEEE80211_HW_SIGNAL_DBM | |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 1478 | IEEE80211_HW_AMPDU_AGGREGATION | |
| 1479 | IEEE80211_HW_SUPPORTS_PS | |
Sujith | eeee132 | 2009-03-10 10:39:53 +0530 | [diff] [blame] | 1480 | IEEE80211_HW_PS_NULLFUNC_STACK | |
| 1481 | IEEE80211_HW_SPECTRUM_MGMT; |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1482 | |
Jouni Malinen | b3bd89c | 2009-02-24 13:42:01 +0200 | [diff] [blame] | 1483 | if (AR_SREV_9160_10_OR_LATER(sc->sc_ah) || modparam_nohwcrypt) |
Jouni Malinen | 0ced0e1 | 2009-01-08 13:32:13 +0200 | [diff] [blame] | 1484 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; |
| 1485 | |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1486 | hw->wiphy->interface_modes = |
| 1487 | BIT(NL80211_IFTYPE_AP) | |
| 1488 | BIT(NL80211_IFTYPE_STATION) | |
Pat Erley | 9cb5412 | 2009-03-20 22:59:59 -0400 | [diff] [blame] | 1489 | BIT(NL80211_IFTYPE_ADHOC) | |
| 1490 | BIT(NL80211_IFTYPE_MESH_POINT); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1491 | |
Luis R. Rodriguez | 14acdde | 2009-12-18 11:26:04 -0500 | [diff] [blame] | 1492 | if (AR_SREV_5416(ah)) |
| 1493 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; |
John W. Linville | 18b6c9a | 2009-11-23 16:15:19 -0500 | [diff] [blame] | 1494 | |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1495 | hw->queues = 4; |
Sujith | e63835b | 2008-11-18 09:07:53 +0530 | [diff] [blame] | 1496 | hw->max_rates = 4; |
Sujith | 171387e | 2009-02-17 15:36:25 +0530 | [diff] [blame] | 1497 | hw->channel_change_time = 5000; |
Jouni Malinen | 465ca84 | 2009-03-03 19:23:34 +0200 | [diff] [blame] | 1498 | hw->max_listen_interval = 10; |
Luis R. Rodriguez | dd19018 | 2009-07-14 20:13:56 -0400 | [diff] [blame] | 1499 | /* Hardware supports 10 but we use 4 */ |
| 1500 | hw->max_rate_tries = 4; |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 1501 | hw->sta_data_size = sizeof(struct ath_node); |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1502 | hw->vif_data_size = sizeof(struct ath_vif); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1503 | |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1504 | hw->rate_control_algorithm = "ath9k_rate_control"; |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1505 | |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 1506 | if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) |
| 1507 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = |
| 1508 | &sc->sbands[IEEE80211_BAND_2GHZ]; |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1509 | if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) |
| 1510 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 1511 | &sc->sbands[IEEE80211_BAND_5GHZ]; |
| 1512 | } |
| 1513 | |
Luis R. Rodriguez | 1e40bcf | 2009-08-03 12:24:47 -0700 | [diff] [blame] | 1514 | /* Device driver core initialization */ |
Luis R. Rodriguez | 5bb1279 | 2009-09-14 00:55:09 -0700 | [diff] [blame] | 1515 | int ath_init_device(u16 devid, struct ath_softc *sc, u16 subsysid, |
| 1516 | const struct ath_bus_ops *bus_ops) |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1517 | { |
| 1518 | struct ieee80211_hw *hw = sc->hw; |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1519 | struct ath_common *common; |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1520 | struct ath_hw *ah; |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1521 | int error = 0, i; |
Bob Copeland | 3a702e4 | 2009-03-30 22:30:29 -0400 | [diff] [blame] | 1522 | struct ath_regulatory *reg; |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1523 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1524 | dev_dbg(sc->dev, "Attach ATH hw\n"); |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1525 | |
Luis R. Rodriguez | 5bb1279 | 2009-09-14 00:55:09 -0700 | [diff] [blame] | 1526 | error = ath_init_softc(devid, sc, subsysid, bus_ops); |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1527 | if (error != 0) |
| 1528 | return error; |
| 1529 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1530 | ah = sc->sc_ah; |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1531 | common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1532 | |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1533 | /* get mac address from hardware and set in mac80211 */ |
| 1534 | |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1535 | SET_IEEE80211_PERM_ADDR(hw, common->macaddr); |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 1536 | |
| 1537 | ath_set_hw_capab(sc, hw); |
| 1538 | |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1539 | error = ath_regd_init(&common->regulatory, sc->hw->wiphy, |
Luis R. Rodriguez | c26c2e5 | 2009-05-19 18:27:11 -0400 | [diff] [blame] | 1540 | ath9k_reg_notifier); |
| 1541 | if (error) |
| 1542 | return error; |
| 1543 | |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 1544 | reg = &common->regulatory; |
Luis R. Rodriguez | c26c2e5 | 2009-05-19 18:27:11 -0400 | [diff] [blame] | 1545 | |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1546 | if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) { |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 1547 | if (test_bit(ATH9K_MODE_11G, ah->caps.wireless_modes)) |
| 1548 | setup_ht_cap(sc, |
| 1549 | &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap); |
Luis R. Rodriguez | 4d6b228 | 2009-09-07 04:52:26 -0700 | [diff] [blame] | 1550 | if (test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes)) |
Gabor Juhos | a9a29ce | 2009-11-27 12:01:35 +0100 | [diff] [blame] | 1551 | setup_ht_cap(sc, |
| 1552 | &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap); |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 1553 | } |
| 1554 | |
Senthil Balasubramanian | db93e7b | 2008-11-13 18:01:08 +0530 | [diff] [blame] | 1555 | /* initialize tx/rx engine */ |
| 1556 | error = ath_tx_init(sc, ATH_TXBUF); |
| 1557 | if (error != 0) |
Vasanthakumar Thiagarajan | 40b130a | 2009-02-16 13:55:07 +0530 | [diff] [blame] | 1558 | goto error_attach; |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1559 | |
Senthil Balasubramanian | db93e7b | 2008-11-13 18:01:08 +0530 | [diff] [blame] | 1560 | error = ath_rx_init(sc, ATH_RXBUF); |
| 1561 | if (error != 0) |
Vasanthakumar Thiagarajan | 40b130a | 2009-02-16 13:55:07 +0530 | [diff] [blame] | 1562 | goto error_attach; |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1563 | |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 1564 | INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work); |
Jouni Malinen | f98c3bd | 2009-03-03 19:23:39 +0200 | [diff] [blame] | 1565 | INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work); |
| 1566 | sc->wiphy_scheduler_int = msecs_to_jiffies(500); |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 1567 | |
Senthil Balasubramanian | db93e7b | 2008-11-13 18:01:08 +0530 | [diff] [blame] | 1568 | error = ieee80211_register_hw(hw); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1569 | |
Bob Copeland | 3a702e4 | 2009-03-30 22:30:29 -0400 | [diff] [blame] | 1570 | if (!ath_is_world_regd(reg)) { |
Bob Copeland | c02cf37 | 2009-03-30 22:30:28 -0400 | [diff] [blame] | 1571 | error = regulatory_hint(hw->wiphy, reg->alpha2); |
Luis R. Rodriguez | fe33eb3 | 2009-02-21 00:04:30 -0500 | [diff] [blame] | 1572 | if (error) |
| 1573 | goto error_attach; |
| 1574 | } |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1575 | |
Senthil Balasubramanian | db93e7b | 2008-11-13 18:01:08 +0530 | [diff] [blame] | 1576 | /* Initialize LED control */ |
| 1577 | ath_init_leds(sc); |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1578 | |
Johannes Berg | 3b319aa | 2009-06-13 14:50:26 +0530 | [diff] [blame] | 1579 | ath_start_rfkill_poll(sc); |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1580 | |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1581 | return 0; |
Vasanthakumar Thiagarajan | 40b130a | 2009-02-16 13:55:07 +0530 | [diff] [blame] | 1582 | |
| 1583 | error_attach: |
| 1584 | /* cleanup tx queues */ |
| 1585 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) |
| 1586 | if (ATH_TXQ_SETUP(sc, i)) |
| 1587 | ath_tx_cleanupq(sc, &sc->tx.txq[i]); |
| 1588 | |
Luis R. Rodriguez | 7fda166 | 2009-10-06 21:19:08 -0400 | [diff] [blame] | 1589 | ath9k_uninit_hw(sc); |
Vasanthakumar Thiagarajan | 40b130a | 2009-02-16 13:55:07 +0530 | [diff] [blame] | 1590 | |
Vasanthakumar Thiagarajan | 8feceb6 | 2008-09-10 18:49:27 +0530 | [diff] [blame] | 1591 | return error; |
| 1592 | } |
| 1593 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1594 | int ath_reset(struct ath_softc *sc, bool retry_tx) |
| 1595 | { |
Sujith | cbe61d8a | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 1596 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1597 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | 030bb49 | 2008-12-23 15:58:37 -0800 | [diff] [blame] | 1598 | struct ieee80211_hw *hw = sc->hw; |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1599 | int r; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1600 | |
Sujith | 2ab81d4 | 2009-12-14 16:34:56 +0530 | [diff] [blame] | 1601 | /* Stop ANI */ |
| 1602 | del_timer_sync(&common->ani.timer); |
| 1603 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1604 | ath9k_hw_set_interrupts(ah, 0); |
Sujith | 043a040 | 2009-01-16 21:38:47 +0530 | [diff] [blame] | 1605 | ath_drain_all_txq(sc, retry_tx); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1606 | ath_stoprecv(sc); |
| 1607 | ath_flushrecv(sc); |
| 1608 | |
| 1609 | spin_lock_bh(&sc->sc_resetlock); |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1610 | r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1611 | if (r) |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1612 | ath_print(common, ATH_DBG_FATAL, |
| 1613 | "Unable to reset hardware; reset status %d\n", r); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1614 | spin_unlock_bh(&sc->sc_resetlock); |
| 1615 | |
| 1616 | if (ath_startrecv(sc) != 0) |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1617 | ath_print(common, ATH_DBG_FATAL, |
| 1618 | "Unable to start recv logic\n"); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1619 | |
| 1620 | /* |
| 1621 | * We may be doing a reset in response to a request |
| 1622 | * that changes the channel so update any state that |
| 1623 | * might change as a result. |
| 1624 | */ |
Luis R. Rodriguez | ce111ba | 2008-12-23 15:58:39 -0800 | [diff] [blame] | 1625 | ath_cache_conf_rate(sc, &hw->conf); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1626 | |
| 1627 | ath_update_txpow(sc); |
| 1628 | |
| 1629 | if (sc->sc_flags & SC_OP_BEACONS) |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 1630 | ath_beacon_config(sc, NULL); /* restart beacons */ |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1631 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1632 | ath9k_hw_set_interrupts(ah, sc->imask); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1633 | |
| 1634 | if (retry_tx) { |
| 1635 | int i; |
| 1636 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) { |
| 1637 | if (ATH_TXQ_SETUP(sc, i)) { |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1638 | spin_lock_bh(&sc->tx.txq[i].axq_lock); |
| 1639 | ath_txq_schedule(sc, &sc->tx.txq[i]); |
| 1640 | spin_unlock_bh(&sc->tx.txq[i].axq_lock); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1641 | } |
| 1642 | } |
| 1643 | } |
| 1644 | |
Sujith | 2ab81d4 | 2009-12-14 16:34:56 +0530 | [diff] [blame] | 1645 | /* Start ANI */ |
| 1646 | ath_start_ani(common); |
| 1647 | |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1648 | return r; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1649 | } |
| 1650 | |
| 1651 | /* |
| 1652 | * This function will allocate both the DMA descriptor structure, and the |
| 1653 | * buffers it contains. These are used to contain the descriptors used |
| 1654 | * by the system. |
| 1655 | */ |
| 1656 | int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, |
| 1657 | struct list_head *head, const char *name, |
| 1658 | int nbuf, int ndesc) |
| 1659 | { |
| 1660 | #define DS2PHYS(_dd, _ds) \ |
| 1661 | ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) |
| 1662 | #define ATH_DESC_4KB_BOUND_CHECK(_daddr) ((((_daddr) & 0xFFF) > 0xF7F) ? 1 : 0) |
| 1663 | #define ATH_DESC_4KB_BOUND_NUM_SKIPPED(_len) ((_len) / 4096) |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1664 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1665 | struct ath_desc *ds; |
| 1666 | struct ath_buf *bf; |
| 1667 | int i, bsize, error; |
| 1668 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1669 | ath_print(common, ATH_DBG_CONFIG, "%s DMA: %u buffers %u desc/buf\n", |
| 1670 | name, nbuf, ndesc); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1671 | |
Senthil Balasubramanian | b03a9db | 2009-03-06 11:24:09 +0530 | [diff] [blame] | 1672 | INIT_LIST_HEAD(head); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1673 | /* ath_desc must be a multiple of DWORDs */ |
| 1674 | if ((sizeof(struct ath_desc) % 4) != 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1675 | ath_print(common, ATH_DBG_FATAL, |
| 1676 | "ath_desc not DWORD aligned\n"); |
Luis R. Rodriguez | 9680e8a | 2009-09-13 23:28:00 -0700 | [diff] [blame] | 1677 | BUG_ON((sizeof(struct ath_desc) % 4) != 0); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1678 | error = -ENOMEM; |
| 1679 | goto fail; |
| 1680 | } |
| 1681 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1682 | dd->dd_desc_len = sizeof(struct ath_desc) * nbuf * ndesc; |
| 1683 | |
| 1684 | /* |
| 1685 | * Need additional DMA memory because we can't use |
| 1686 | * descriptors that cross the 4K page boundary. Assume |
| 1687 | * one skipped descriptor per 4K page. |
| 1688 | */ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1689 | if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_4KB_SPLITTRANS)) { |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1690 | u32 ndesc_skipped = |
| 1691 | ATH_DESC_4KB_BOUND_NUM_SKIPPED(dd->dd_desc_len); |
| 1692 | u32 dma_len; |
| 1693 | |
| 1694 | while (ndesc_skipped) { |
| 1695 | dma_len = ndesc_skipped * sizeof(struct ath_desc); |
| 1696 | dd->dd_desc_len += dma_len; |
| 1697 | |
| 1698 | ndesc_skipped = ATH_DESC_4KB_BOUND_NUM_SKIPPED(dma_len); |
| 1699 | }; |
| 1700 | } |
| 1701 | |
| 1702 | /* allocate descriptors */ |
Gabor Juhos | 7da3c55 | 2009-01-14 20:17:03 +0100 | [diff] [blame] | 1703 | dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len, |
Senthil Balasubramanian | f0e6ce1 | 2009-03-06 11:24:08 +0530 | [diff] [blame] | 1704 | &dd->dd_desc_paddr, GFP_KERNEL); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1705 | if (dd->dd_desc == NULL) { |
| 1706 | error = -ENOMEM; |
| 1707 | goto fail; |
| 1708 | } |
| 1709 | ds = dd->dd_desc; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1710 | ath_print(common, ATH_DBG_CONFIG, "%s DMA map: %p (%u) -> %llx (%u)\n", |
| 1711 | name, ds, (u32) dd->dd_desc_len, |
| 1712 | ito64(dd->dd_desc_paddr), /*XXX*/(u32) dd->dd_desc_len); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1713 | |
| 1714 | /* allocate buffers */ |
| 1715 | bsize = sizeof(struct ath_buf) * nbuf; |
Senthil Balasubramanian | f0e6ce1 | 2009-03-06 11:24:08 +0530 | [diff] [blame] | 1716 | bf = kzalloc(bsize, GFP_KERNEL); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1717 | if (bf == NULL) { |
| 1718 | error = -ENOMEM; |
| 1719 | goto fail2; |
| 1720 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1721 | dd->dd_bufptr = bf; |
| 1722 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1723 | for (i = 0; i < nbuf; i++, bf++, ds += ndesc) { |
| 1724 | bf->bf_desc = ds; |
| 1725 | bf->bf_daddr = DS2PHYS(dd, ds); |
| 1726 | |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 1727 | if (!(sc->sc_ah->caps.hw_caps & |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1728 | ATH9K_HW_CAP_4KB_SPLITTRANS)) { |
| 1729 | /* |
| 1730 | * Skip descriptor addresses which can cause 4KB |
| 1731 | * boundary crossing (addr + length) with a 32 dword |
| 1732 | * descriptor fetch. |
| 1733 | */ |
| 1734 | while (ATH_DESC_4KB_BOUND_CHECK(bf->bf_daddr)) { |
Luis R. Rodriguez | 9680e8a | 2009-09-13 23:28:00 -0700 | [diff] [blame] | 1735 | BUG_ON((caddr_t) bf->bf_desc >= |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1736 | ((caddr_t) dd->dd_desc + |
| 1737 | dd->dd_desc_len)); |
| 1738 | |
| 1739 | ds += ndesc; |
| 1740 | bf->bf_desc = ds; |
| 1741 | bf->bf_daddr = DS2PHYS(dd, ds); |
| 1742 | } |
| 1743 | } |
| 1744 | list_add_tail(&bf->list, head); |
| 1745 | } |
| 1746 | return 0; |
| 1747 | fail2: |
Gabor Juhos | 7da3c55 | 2009-01-14 20:17:03 +0100 | [diff] [blame] | 1748 | dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc, |
| 1749 | dd->dd_desc_paddr); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1750 | fail: |
| 1751 | memset(dd, 0, sizeof(*dd)); |
| 1752 | return error; |
| 1753 | #undef ATH_DESC_4KB_BOUND_CHECK |
| 1754 | #undef ATH_DESC_4KB_BOUND_NUM_SKIPPED |
| 1755 | #undef DS2PHYS |
| 1756 | } |
| 1757 | |
| 1758 | void ath_descdma_cleanup(struct ath_softc *sc, |
| 1759 | struct ath_descdma *dd, |
| 1760 | struct list_head *head) |
| 1761 | { |
Gabor Juhos | 7da3c55 | 2009-01-14 20:17:03 +0100 | [diff] [blame] | 1762 | dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc, |
| 1763 | dd->dd_desc_paddr); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1764 | |
| 1765 | INIT_LIST_HEAD(head); |
| 1766 | kfree(dd->dd_bufptr); |
| 1767 | memset(dd, 0, sizeof(*dd)); |
| 1768 | } |
| 1769 | |
| 1770 | int ath_get_hal_qnum(u16 queue, struct ath_softc *sc) |
| 1771 | { |
| 1772 | int qnum; |
| 1773 | |
| 1774 | switch (queue) { |
| 1775 | case 0: |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1776 | qnum = sc->tx.hwq_map[ATH9K_WME_AC_VO]; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1777 | break; |
| 1778 | case 1: |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1779 | qnum = sc->tx.hwq_map[ATH9K_WME_AC_VI]; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1780 | break; |
| 1781 | case 2: |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1782 | qnum = sc->tx.hwq_map[ATH9K_WME_AC_BE]; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1783 | break; |
| 1784 | case 3: |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1785 | qnum = sc->tx.hwq_map[ATH9K_WME_AC_BK]; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1786 | break; |
| 1787 | default: |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 1788 | qnum = sc->tx.hwq_map[ATH9K_WME_AC_BE]; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1789 | break; |
| 1790 | } |
| 1791 | |
| 1792 | return qnum; |
| 1793 | } |
| 1794 | |
| 1795 | int ath_get_mac80211_qnum(u32 queue, struct ath_softc *sc) |
| 1796 | { |
| 1797 | int qnum; |
| 1798 | |
| 1799 | switch (queue) { |
| 1800 | case ATH9K_WME_AC_VO: |
| 1801 | qnum = 0; |
| 1802 | break; |
| 1803 | case ATH9K_WME_AC_VI: |
| 1804 | qnum = 1; |
| 1805 | break; |
| 1806 | case ATH9K_WME_AC_BE: |
| 1807 | qnum = 2; |
| 1808 | break; |
| 1809 | case ATH9K_WME_AC_BK: |
| 1810 | qnum = 3; |
| 1811 | break; |
| 1812 | default: |
| 1813 | qnum = -1; |
| 1814 | break; |
| 1815 | } |
| 1816 | |
| 1817 | return qnum; |
| 1818 | } |
| 1819 | |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1820 | /* XXX: Remove me once we don't depend on ath9k_channel for all |
| 1821 | * this redundant data */ |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 1822 | void ath9k_update_ichannel(struct ath_softc *sc, struct ieee80211_hw *hw, |
| 1823 | struct ath9k_channel *ichan) |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1824 | { |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1825 | struct ieee80211_channel *chan = hw->conf.channel; |
| 1826 | struct ieee80211_conf *conf = &hw->conf; |
| 1827 | |
| 1828 | ichan->channel = chan->center_freq; |
| 1829 | ichan->chan = chan; |
| 1830 | |
| 1831 | if (chan->band == IEEE80211_BAND_2GHZ) { |
| 1832 | ichan->chanmode = CHANNEL_G; |
Sujith | 8813262 | 2009-09-03 12:08:53 +0530 | [diff] [blame] | 1833 | ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM | CHANNEL_G; |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1834 | } else { |
| 1835 | ichan->chanmode = CHANNEL_A; |
| 1836 | ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM; |
| 1837 | } |
| 1838 | |
Luis R. Rodriguez | 25c56ee | 2009-09-13 23:04:44 -0700 | [diff] [blame] | 1839 | if (conf_is_ht(conf)) |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1840 | ichan->chanmode = ath_get_extchanmode(sc, chan, |
| 1841 | conf->channel_type); |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 1842 | } |
| 1843 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1844 | /**********************/ |
| 1845 | /* mac80211 callbacks */ |
| 1846 | /**********************/ |
| 1847 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1848 | static int ath9k_start(struct ieee80211_hw *hw) |
| 1849 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 1850 | struct ath_wiphy *aphy = hw->priv; |
| 1851 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 1852 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1853 | struct ath_common *common = ath9k_hw_common(ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1854 | struct ieee80211_channel *curchan = hw->conf.channel; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1855 | struct ath9k_channel *init_channel; |
Vasanthakumar Thiagarajan | 82880a7 | 2009-06-13 14:50:24 +0530 | [diff] [blame] | 1856 | int r; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1857 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1858 | ath_print(common, ATH_DBG_CONFIG, |
| 1859 | "Starting driver with initial channel: %d MHz\n", |
| 1860 | curchan->center_freq); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1861 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1862 | mutex_lock(&sc->mutex); |
| 1863 | |
Jouni Malinen | 9580a22 | 2009-03-03 19:23:33 +0200 | [diff] [blame] | 1864 | if (ath9k_wiphy_started(sc)) { |
| 1865 | if (sc->chan_idx == curchan->hw_value) { |
| 1866 | /* |
| 1867 | * Already on the operational channel, the new wiphy |
| 1868 | * can be marked active. |
| 1869 | */ |
| 1870 | aphy->state = ATH_WIPHY_ACTIVE; |
| 1871 | ieee80211_wake_queues(hw); |
| 1872 | } else { |
| 1873 | /* |
| 1874 | * Another wiphy is on another channel, start the new |
| 1875 | * wiphy in paused state. |
| 1876 | */ |
| 1877 | aphy->state = ATH_WIPHY_PAUSED; |
| 1878 | ieee80211_stop_queues(hw); |
| 1879 | } |
| 1880 | mutex_unlock(&sc->mutex); |
| 1881 | return 0; |
| 1882 | } |
| 1883 | aphy->state = ATH_WIPHY_ACTIVE; |
| 1884 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1885 | /* setup initial channel */ |
| 1886 | |
Vasanthakumar Thiagarajan | 82880a7 | 2009-06-13 14:50:24 +0530 | [diff] [blame] | 1887 | sc->chan_idx = curchan->hw_value; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1888 | |
Vasanthakumar Thiagarajan | 82880a7 | 2009-06-13 14:50:24 +0530 | [diff] [blame] | 1889 | init_channel = ath_get_curchannel(sc, hw); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1890 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1891 | /* Reset SERDES registers */ |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 1892 | ath9k_hw_configpcipowersave(ah, 0, 0); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1893 | |
| 1894 | /* |
| 1895 | * The basic interface to setting the hardware in a good |
| 1896 | * state is ``reset''. On return the hardware is known to |
| 1897 | * be powered up and with interrupts disabled. This must |
| 1898 | * be followed by initialization of the appropriate bits |
| 1899 | * and then setup of the interrupt mask. |
| 1900 | */ |
| 1901 | spin_lock_bh(&sc->sc_resetlock); |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 1902 | r = ath9k_hw_reset(ah, init_channel, false); |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1903 | if (r) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1904 | ath_print(common, ATH_DBG_FATAL, |
| 1905 | "Unable to reset hardware; reset status %d " |
| 1906 | "(freq %u MHz)\n", r, |
| 1907 | curchan->center_freq); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1908 | spin_unlock_bh(&sc->sc_resetlock); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1909 | goto mutex_unlock; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1910 | } |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1911 | spin_unlock_bh(&sc->sc_resetlock); |
| 1912 | |
| 1913 | /* |
| 1914 | * This is needed only to setup initial state |
| 1915 | * but it's best done after a reset. |
| 1916 | */ |
| 1917 | ath_update_txpow(sc); |
| 1918 | |
| 1919 | /* |
| 1920 | * Setup the hardware after reset: |
| 1921 | * The receive engine is set going. |
| 1922 | * Frame transmit is handled entirely |
| 1923 | * in the frame output path; there's nothing to do |
| 1924 | * here except setup the interrupt mask. |
| 1925 | */ |
| 1926 | if (ath_startrecv(sc) != 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1927 | ath_print(common, ATH_DBG_FATAL, |
| 1928 | "Unable to start recv logic\n"); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1929 | r = -EIO; |
| 1930 | goto mutex_unlock; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1931 | } |
| 1932 | |
| 1933 | /* Setup our intr mask. */ |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1934 | sc->imask = ATH9K_INT_RX | ATH9K_INT_TX |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1935 | | ATH9K_INT_RXEOL | ATH9K_INT_RXORN |
| 1936 | | ATH9K_INT_FATAL | ATH9K_INT_GLOBAL; |
| 1937 | |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 1938 | if (ah->caps.hw_caps & ATH9K_HW_CAP_GTT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1939 | sc->imask |= ATH9K_INT_GTT; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1940 | |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 1941 | if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1942 | sc->imask |= ATH9K_INT_CST; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1943 | |
Luis R. Rodriguez | ce111ba | 2008-12-23 15:58:39 -0800 | [diff] [blame] | 1944 | ath_cache_conf_rate(sc, &hw->conf); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1945 | |
| 1946 | sc->sc_flags &= ~SC_OP_INVALID; |
| 1947 | |
| 1948 | /* Disable BMISS interrupt when we're not associated */ |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 1949 | sc->imask &= ~(ATH9K_INT_SWBA | ATH9K_INT_BMISS); |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 1950 | ath9k_hw_set_interrupts(ah, sc->imask); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 1951 | |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 1952 | ieee80211_wake_queues(hw); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1953 | |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 1954 | ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); |
Senthil Balasubramanian | 164ace3 | 2009-07-14 20:17:09 -0400 | [diff] [blame] | 1955 | |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 1956 | if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) && |
| 1957 | !ah->btcoex_hw.enabled) { |
Luis R. Rodriguez | 5e19729 | 2009-09-09 15:15:55 -0700 | [diff] [blame] | 1958 | ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, |
| 1959 | AR_STOMP_LOW_WLAN_WGHT); |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 1960 | ath9k_hw_btcoex_enable(ah); |
Vasanthakumar Thiagarajan | f985ad1 | 2009-08-26 21:08:43 +0530 | [diff] [blame] | 1961 | |
Luis R. Rodriguez | 5bb1279 | 2009-09-14 00:55:09 -0700 | [diff] [blame] | 1962 | if (common->bus_ops->bt_coex_prep) |
| 1963 | common->bus_ops->bt_coex_prep(common); |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 1964 | if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 1965 | ath9k_btcoex_timer_resume(sc); |
Vasanthakumar Thiagarajan | 1773912 | 2009-08-26 21:08:50 +0530 | [diff] [blame] | 1966 | } |
| 1967 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 1968 | mutex_unlock: |
| 1969 | mutex_unlock(&sc->mutex); |
| 1970 | |
Luis R. Rodriguez | ae8d285 | 2008-12-23 15:58:40 -0800 | [diff] [blame] | 1971 | return r; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 1972 | } |
| 1973 | |
| 1974 | static int ath9k_tx(struct ieee80211_hw *hw, |
| 1975 | struct sk_buff *skb) |
| 1976 | { |
Jouni Malinen | 147583c | 2008-08-11 14:01:50 +0300 | [diff] [blame] | 1977 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 1978 | struct ath_wiphy *aphy = hw->priv; |
| 1979 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1980 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 1981 | struct ath_tx_control txctl; |
Benoit Papillault | 1bc1488 | 2009-11-24 15:49:18 +0100 | [diff] [blame] | 1982 | int padpos, padsize; |
| 1983 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 1984 | |
Jouni Malinen | 8089cc4 | 2009-03-03 19:23:38 +0200 | [diff] [blame] | 1985 | if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 1986 | ath_print(common, ATH_DBG_XMIT, |
| 1987 | "ath9k: %s: TX in unexpected wiphy state " |
| 1988 | "%d\n", wiphy_name(hw->wiphy), aphy->state); |
Jouni Malinen | ee166a0 | 2009-03-03 19:23:36 +0200 | [diff] [blame] | 1989 | goto exit; |
| 1990 | } |
| 1991 | |
Gabor Juhos | 9614832 | 2009-07-24 17:27:21 +0200 | [diff] [blame] | 1992 | if (sc->ps_enabled) { |
Jouni Malinen | dc8c458 | 2009-05-19 17:01:42 +0300 | [diff] [blame] | 1993 | /* |
| 1994 | * mac80211 does not set PM field for normal data frames, so we |
| 1995 | * need to update that based on the current PS mode. |
| 1996 | */ |
| 1997 | if (ieee80211_is_data(hdr->frame_control) && |
| 1998 | !ieee80211_is_nullfunc(hdr->frame_control) && |
| 1999 | !ieee80211_has_pm(hdr->frame_control)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2000 | ath_print(common, ATH_DBG_PS, "Add PM=1 for a TX frame " |
| 2001 | "while in PS mode\n"); |
Jouni Malinen | dc8c458 | 2009-05-19 17:01:42 +0300 | [diff] [blame] | 2002 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
| 2003 | } |
| 2004 | } |
| 2005 | |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 2006 | if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) { |
| 2007 | /* |
| 2008 | * We are using PS-Poll and mac80211 can request TX while in |
| 2009 | * power save mode. Need to wake up hardware for the TX to be |
| 2010 | * completed and if needed, also for RX of buffered frames. |
| 2011 | */ |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 2012 | ath9k_ps_wakeup(sc); |
| 2013 | ath9k_hw_setrxabort(sc->sc_ah, 0); |
| 2014 | if (ieee80211_is_pspoll(hdr->frame_control)) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2015 | ath_print(common, ATH_DBG_PS, |
| 2016 | "Sending PS-Poll to pick a buffered frame\n"); |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 2017 | sc->sc_flags |= SC_OP_WAIT_FOR_PSPOLL_DATA; |
| 2018 | } else { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2019 | ath_print(common, ATH_DBG_PS, |
| 2020 | "Wake up to complete TX\n"); |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 2021 | sc->sc_flags |= SC_OP_WAIT_FOR_TX_ACK; |
| 2022 | } |
| 2023 | /* |
| 2024 | * The actual restore operation will happen only after |
| 2025 | * the sc_flags bit is cleared. We are just dropping |
| 2026 | * the ps_usecount here. |
| 2027 | */ |
| 2028 | ath9k_ps_restore(sc); |
| 2029 | } |
| 2030 | |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 2031 | memset(&txctl, 0, sizeof(struct ath_tx_control)); |
Jouni Malinen | 147583c | 2008-08-11 14:01:50 +0300 | [diff] [blame] | 2032 | |
| 2033 | /* |
| 2034 | * As a temporary workaround, assign seq# here; this will likely need |
| 2035 | * to be cleaned up to work better with Beacon transmission and virtual |
| 2036 | * BSSes. |
| 2037 | */ |
| 2038 | if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { |
Jouni Malinen | 147583c | 2008-08-11 14:01:50 +0300 | [diff] [blame] | 2039 | if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 2040 | sc->tx.seq_no += 0x10; |
Jouni Malinen | 147583c | 2008-08-11 14:01:50 +0300 | [diff] [blame] | 2041 | hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 2042 | hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no); |
Jouni Malinen | 147583c | 2008-08-11 14:01:50 +0300 | [diff] [blame] | 2043 | } |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2044 | |
| 2045 | /* Add the padding after the header if this is not already done */ |
Benoit Papillault | 1bc1488 | 2009-11-24 15:49:18 +0100 | [diff] [blame] | 2046 | padpos = ath9k_cmn_padpos(hdr->frame_control); |
| 2047 | padsize = padpos & 3; |
| 2048 | if (padsize && skb->len>padpos) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2049 | if (skb_headroom(skb) < padsize) |
| 2050 | return -1; |
| 2051 | skb_push(skb, padsize); |
Benoit Papillault | 1bc1488 | 2009-11-24 15:49:18 +0100 | [diff] [blame] | 2052 | memmove(skb->data, skb->data + padsize, padpos); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2053 | } |
| 2054 | |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 2055 | /* Check if a tx queue is available */ |
| 2056 | |
| 2057 | txctl.txq = ath_test_get_txq(sc, skb); |
| 2058 | if (!txctl.txq) |
| 2059 | goto exit; |
| 2060 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2061 | ath_print(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2062 | |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 2063 | if (ath_tx_start(hw, skb, &txctl) != 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2064 | ath_print(common, ATH_DBG_XMIT, "TX failed\n"); |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 2065 | goto exit; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2066 | } |
| 2067 | |
| 2068 | return 0; |
Sujith | 528f0c6 | 2008-10-29 10:14:26 +0530 | [diff] [blame] | 2069 | exit: |
| 2070 | dev_kfree_skb_any(skb); |
| 2071 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2072 | } |
| 2073 | |
| 2074 | static void ath9k_stop(struct ieee80211_hw *hw) |
| 2075 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2076 | struct ath_wiphy *aphy = hw->priv; |
| 2077 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 2078 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2079 | struct ath_common *common = ath9k_hw_common(ah); |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 2080 | |
Sujith | 4c48381 | 2009-08-18 10:51:52 +0530 | [diff] [blame] | 2081 | mutex_lock(&sc->mutex); |
| 2082 | |
Jouni Malinen | 9580a22 | 2009-03-03 19:23:33 +0200 | [diff] [blame] | 2083 | aphy->state = ATH_WIPHY_INACTIVE; |
| 2084 | |
Luis R. Rodriguez | c94dbff | 2009-07-27 11:53:04 -0700 | [diff] [blame] | 2085 | cancel_delayed_work_sync(&sc->ath_led_blink_work); |
| 2086 | cancel_delayed_work_sync(&sc->tx_complete_work); |
| 2087 | |
| 2088 | if (!sc->num_sec_wiphy) { |
| 2089 | cancel_delayed_work_sync(&sc->wiphy_work); |
| 2090 | cancel_work_sync(&sc->chan_work); |
| 2091 | } |
| 2092 | |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 2093 | if (sc->sc_flags & SC_OP_INVALID) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2094 | ath_print(common, ATH_DBG_ANY, "Device not present\n"); |
Sujith | 4c48381 | 2009-08-18 10:51:52 +0530 | [diff] [blame] | 2095 | mutex_unlock(&sc->mutex); |
Sujith | 9c84b79 | 2008-10-29 10:17:13 +0530 | [diff] [blame] | 2096 | return; |
| 2097 | } |
| 2098 | |
Jouni Malinen | 9580a22 | 2009-03-03 19:23:33 +0200 | [diff] [blame] | 2099 | if (ath9k_wiphy_started(sc)) { |
| 2100 | mutex_unlock(&sc->mutex); |
| 2101 | return; /* another wiphy still in use */ |
| 2102 | } |
| 2103 | |
Sujith | 3867cf6 | 2009-12-23 20:03:27 -0500 | [diff] [blame] | 2104 | /* Ensure HW is awake when we try to shut it down. */ |
| 2105 | ath9k_ps_wakeup(sc); |
| 2106 | |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 2107 | if (ah->btcoex_hw.enabled) { |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 2108 | ath9k_hw_btcoex_disable(ah); |
Luis R. Rodriguez | 766ec4a | 2009-09-09 14:52:02 -0700 | [diff] [blame] | 2109 | if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) |
Luis R. Rodriguez | 75d7839 | 2009-09-09 04:00:10 -0700 | [diff] [blame] | 2110 | ath9k_btcoex_timer_pause(sc); |
Vasanthakumar Thiagarajan | 1773912 | 2009-08-26 21:08:50 +0530 | [diff] [blame] | 2111 | } |
| 2112 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 2113 | /* make sure h/w will not generate any interrupt |
| 2114 | * before setting the invalid flag. */ |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 2115 | ath9k_hw_set_interrupts(ah, 0); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 2116 | |
| 2117 | if (!(sc->sc_flags & SC_OP_INVALID)) { |
Sujith | 043a040 | 2009-01-16 21:38:47 +0530 | [diff] [blame] | 2118 | ath_drain_all_txq(sc, false); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 2119 | ath_stoprecv(sc); |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 2120 | ath9k_hw_phy_disable(ah); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 2121 | } else |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 2122 | sc->rx.rxlink = NULL; |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 2123 | |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 2124 | /* disable HAL and put h/w to sleep */ |
Luis R. Rodriguez | af03abe | 2009-09-09 02:33:11 -0700 | [diff] [blame] | 2125 | ath9k_hw_disable(ah); |
| 2126 | ath9k_hw_configpcipowersave(ah, 1, 1); |
Sujith | 3867cf6 | 2009-12-23 20:03:27 -0500 | [diff] [blame] | 2127 | ath9k_ps_restore(sc); |
| 2128 | |
| 2129 | /* Finally, put the chip in FULL SLEEP mode */ |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 2130 | ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP); |
Sujith | ff37e33 | 2008-11-24 12:07:55 +0530 | [diff] [blame] | 2131 | |
| 2132 | sc->sc_flags |= SC_OP_INVALID; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2133 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2134 | mutex_unlock(&sc->mutex); |
| 2135 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2136 | ath_print(common, ATH_DBG_CONFIG, "Driver halt\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2137 | } |
| 2138 | |
| 2139 | static int ath9k_add_interface(struct ieee80211_hw *hw, |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2140 | struct ieee80211_vif *vif) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2141 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2142 | struct ath_wiphy *aphy = hw->priv; |
| 2143 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2144 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2145 | struct ath_vif *avp = (void *)vif->drv_priv; |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 2146 | enum nl80211_iftype ic_opmode = NL80211_IFTYPE_UNSPECIFIED; |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2147 | int ret = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2148 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2149 | mutex_lock(&sc->mutex); |
| 2150 | |
Jouni Malinen | 8ca21f0 | 2009-03-03 19:23:27 +0200 | [diff] [blame] | 2151 | if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK) && |
| 2152 | sc->nvifs > 0) { |
| 2153 | ret = -ENOBUFS; |
| 2154 | goto out; |
| 2155 | } |
| 2156 | |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2157 | switch (vif->type) { |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 2158 | case NL80211_IFTYPE_STATION: |
Colin McCabe | d97809d | 2008-12-01 13:38:55 -0800 | [diff] [blame] | 2159 | ic_opmode = NL80211_IFTYPE_STATION; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2160 | break; |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 2161 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 2162 | case NL80211_IFTYPE_AP: |
Pat Erley | 9cb5412 | 2009-03-20 22:59:59 -0400 | [diff] [blame] | 2163 | case NL80211_IFTYPE_MESH_POINT: |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2164 | if (sc->nbcnvifs >= ATH_BCBUF) { |
| 2165 | ret = -ENOBUFS; |
| 2166 | goto out; |
| 2167 | } |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2168 | ic_opmode = vif->type; |
Jouni Malinen | 2ad67de | 2008-08-11 14:01:47 +0300 | [diff] [blame] | 2169 | break; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2170 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2171 | ath_print(common, ATH_DBG_FATAL, |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2172 | "Interface type %d not yet supported\n", vif->type); |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2173 | ret = -EOPNOTSUPP; |
| 2174 | goto out; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2175 | } |
| 2176 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2177 | ath_print(common, ATH_DBG_CONFIG, |
| 2178 | "Attach a VIF of type: %d\n", ic_opmode); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2179 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 2180 | /* Set the VIF opmode */ |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 2181 | avp->av_opmode = ic_opmode; |
| 2182 | avp->av_bslot = -1; |
| 2183 | |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2184 | sc->nvifs++; |
Jouni Malinen | 8ca21f0 | 2009-03-03 19:23:27 +0200 | [diff] [blame] | 2185 | |
| 2186 | if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK) |
| 2187 | ath9k_set_bssid_mask(hw); |
| 2188 | |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2189 | if (sc->nvifs > 1) |
| 2190 | goto out; /* skip global settings for secondary vif */ |
| 2191 | |
Sujith | b238e90 | 2009-03-03 10:16:56 +0530 | [diff] [blame] | 2192 | if (ic_opmode == NL80211_IFTYPE_AP) { |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 2193 | ath9k_hw_set_tsfadjust(sc->sc_ah, 1); |
Sujith | b238e90 | 2009-03-03 10:16:56 +0530 | [diff] [blame] | 2194 | sc->sc_flags |= SC_OP_TSF_RESET; |
| 2195 | } |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 2196 | |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 2197 | /* Set the device opmode */ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 2198 | sc->sc_ah->opmode = ic_opmode; |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 2199 | |
Vivek Natarajan | 4e30ffa | 2009-01-28 20:53:27 +0530 | [diff] [blame] | 2200 | /* |
| 2201 | * Enable MIB interrupts when there are hardware phy counters. |
| 2202 | * Note we only do this (at the moment) for station mode. |
| 2203 | */ |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2204 | if ((vif->type == NL80211_IFTYPE_STATION) || |
| 2205 | (vif->type == NL80211_IFTYPE_ADHOC) || |
| 2206 | (vif->type == NL80211_IFTYPE_MESH_POINT)) { |
Sujith | 1aa8e84 | 2009-08-13 09:34:25 +0530 | [diff] [blame] | 2207 | sc->imask |= ATH9K_INT_MIB; |
Sujith | 4af9cf4 | 2009-02-12 10:06:47 +0530 | [diff] [blame] | 2208 | sc->imask |= ATH9K_INT_TSFOOR; |
| 2209 | } |
| 2210 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 2211 | ath9k_hw_set_interrupts(sc->sc_ah, sc->imask); |
Vivek Natarajan | 4e30ffa | 2009-01-28 20:53:27 +0530 | [diff] [blame] | 2212 | |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2213 | if (vif->type == NL80211_IFTYPE_AP || |
| 2214 | vif->type == NL80211_IFTYPE_ADHOC || |
| 2215 | vif->type == NL80211_IFTYPE_MONITOR) |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 2216 | ath_start_ani(common); |
Luis R. Rodriguez | 6f25542 | 2008-10-03 15:45:27 -0700 | [diff] [blame] | 2217 | |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2218 | out: |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2219 | mutex_unlock(&sc->mutex); |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2220 | return ret; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2221 | } |
| 2222 | |
| 2223 | static void ath9k_remove_interface(struct ieee80211_hw *hw, |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2224 | struct ieee80211_vif *vif) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2225 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2226 | struct ath_wiphy *aphy = hw->priv; |
| 2227 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2228 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2229 | struct ath_vif *avp = (void *)vif->drv_priv; |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2230 | int i; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2231 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2232 | ath_print(common, ATH_DBG_CONFIG, "Detach Interface\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2233 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2234 | mutex_lock(&sc->mutex); |
| 2235 | |
Luis R. Rodriguez | 6f25542 | 2008-10-03 15:45:27 -0700 | [diff] [blame] | 2236 | /* Stop ANI */ |
Luis R. Rodriguez | 3d536ac | 2009-11-03 17:07:04 -0800 | [diff] [blame] | 2237 | del_timer_sync(&common->ani.timer); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2238 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2239 | /* Reclaim beacon resources */ |
Pat Erley | 9cb5412 | 2009-03-20 22:59:59 -0400 | [diff] [blame] | 2240 | if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) || |
| 2241 | (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) || |
| 2242 | (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) { |
Luis R. Rodriguez | 5f70a88 | 2009-12-23 20:03:28 -0500 | [diff] [blame] | 2243 | ath9k_ps_wakeup(sc); |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 2244 | ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2245 | ath_beacon_return(sc, avp); |
Luis R. Rodriguez | 5f70a88 | 2009-12-23 20:03:28 -0500 | [diff] [blame] | 2246 | ath9k_ps_restore(sc); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2247 | } |
| 2248 | |
Sujith | 672840a | 2008-08-11 14:05:08 +0530 | [diff] [blame] | 2249 | sc->sc_flags &= ~SC_OP_BEACONS; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2250 | |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2251 | for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++) { |
Johannes Berg | 1ed32e4 | 2009-12-23 13:15:45 +0100 | [diff] [blame] | 2252 | if (sc->beacon.bslot[i] == vif) { |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2253 | printk(KERN_DEBUG "%s: vif had allocated beacon " |
| 2254 | "slot\n", __func__); |
| 2255 | sc->beacon.bslot[i] = NULL; |
Jouni Malinen | c52f33d | 2009-03-03 19:23:29 +0200 | [diff] [blame] | 2256 | sc->beacon.bslot_aphy[i] = NULL; |
Jouni Malinen | 2c3db3d | 2009-03-03 19:23:26 +0200 | [diff] [blame] | 2257 | } |
| 2258 | } |
| 2259 | |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 2260 | sc->nvifs--; |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2261 | |
| 2262 | mutex_unlock(&sc->mutex); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2263 | } |
| 2264 | |
Johannes Berg | e897558 | 2008-10-09 12:18:51 +0200 | [diff] [blame] | 2265 | static int ath9k_config(struct ieee80211_hw *hw, u32 changed) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2266 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2267 | struct ath_wiphy *aphy = hw->priv; |
| 2268 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2269 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Johannes Berg | e897558 | 2008-10-09 12:18:51 +0200 | [diff] [blame] | 2270 | struct ieee80211_conf *conf = &hw->conf; |
Vivek Natarajan | 8782b41 | 2009-03-30 14:17:00 +0530 | [diff] [blame] | 2271 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | 194b7c1 | 2009-10-29 10:41:15 -0700 | [diff] [blame] | 2272 | bool disable_radio; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2273 | |
Sujith | aa33de0 | 2008-12-18 11:40:16 +0530 | [diff] [blame] | 2274 | mutex_lock(&sc->mutex); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2275 | |
Luis R. Rodriguez | 194b7c1 | 2009-10-29 10:41:15 -0700 | [diff] [blame] | 2276 | /* |
| 2277 | * Leave this as the first check because we need to turn on the |
| 2278 | * radio if it was disabled before prior to processing the rest |
| 2279 | * of the changes. Likewise we must only disable the radio towards |
| 2280 | * the end. |
| 2281 | */ |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 2282 | if (changed & IEEE80211_CONF_CHANGE_IDLE) { |
Luis R. Rodriguez | 194b7c1 | 2009-10-29 10:41:15 -0700 | [diff] [blame] | 2283 | bool enable_radio; |
| 2284 | bool all_wiphys_idle; |
| 2285 | bool idle = !!(conf->flags & IEEE80211_CONF_IDLE); |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 2286 | |
| 2287 | spin_lock_bh(&sc->wiphy_lock); |
| 2288 | all_wiphys_idle = ath9k_all_wiphys_idle(sc); |
Luis R. Rodriguez | 194b7c1 | 2009-10-29 10:41:15 -0700 | [diff] [blame] | 2289 | ath9k_set_wiphy_idle(aphy, idle); |
| 2290 | |
| 2291 | if (!idle && all_wiphys_idle) |
| 2292 | enable_radio = true; |
| 2293 | |
| 2294 | /* |
| 2295 | * After we unlock here its possible another wiphy |
| 2296 | * can be re-renabled so to account for that we will |
| 2297 | * only disable the radio toward the end of this routine |
| 2298 | * if by then all wiphys are still idle. |
| 2299 | */ |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 2300 | spin_unlock_bh(&sc->wiphy_lock); |
| 2301 | |
Luis R. Rodriguez | 194b7c1 | 2009-10-29 10:41:15 -0700 | [diff] [blame] | 2302 | if (enable_radio) { |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 2303 | ath_radio_enable(sc, hw); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2304 | ath_print(common, ATH_DBG_CONFIG, |
| 2305 | "not-idle: enabling radio\n"); |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 2306 | } |
| 2307 | } |
| 2308 | |
Luis R. Rodriguez | e7824a5 | 2009-11-24 02:53:25 -0500 | [diff] [blame] | 2309 | /* |
| 2310 | * We just prepare to enable PS. We have to wait until our AP has |
| 2311 | * ACK'd our null data frame to disable RX otherwise we'll ignore |
| 2312 | * those ACKs and end up retransmitting the same null data frames. |
| 2313 | * IEEE80211_CONF_CHANGE_PS is only passed by mac80211 for STA mode. |
| 2314 | */ |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 2315 | if (changed & IEEE80211_CONF_CHANGE_PS) { |
| 2316 | if (conf->flags & IEEE80211_CONF_PS) { |
Luis R. Rodriguez | e7824a5 | 2009-11-24 02:53:25 -0500 | [diff] [blame] | 2317 | sc->sc_flags |= SC_OP_PS_ENABLED; |
Vivek Natarajan | 8782b41 | 2009-03-30 14:17:00 +0530 | [diff] [blame] | 2318 | if (!(ah->caps.hw_caps & |
| 2319 | ATH9K_HW_CAP_AUTOSLEEP)) { |
| 2320 | if ((sc->imask & ATH9K_INT_TIM_TIMER) == 0) { |
| 2321 | sc->imask |= ATH9K_INT_TIM_TIMER; |
| 2322 | ath9k_hw_set_interrupts(sc->sc_ah, |
| 2323 | sc->imask); |
| 2324 | } |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 2325 | } |
Luis R. Rodriguez | e7824a5 | 2009-11-24 02:53:25 -0500 | [diff] [blame] | 2326 | /* |
| 2327 | * At this point we know hardware has received an ACK |
| 2328 | * of a previously sent null data frame. |
| 2329 | */ |
| 2330 | if ((sc->sc_flags & SC_OP_NULLFUNC_COMPLETED)) { |
| 2331 | sc->sc_flags &= ~SC_OP_NULLFUNC_COMPLETED; |
| 2332 | sc->ps_enabled = true; |
| 2333 | ath9k_hw_setrxabort(sc->sc_ah, 1); |
| 2334 | } |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 2335 | } else { |
Gabor Juhos | 9614832 | 2009-07-24 17:27:21 +0200 | [diff] [blame] | 2336 | sc->ps_enabled = false; |
Luis R. Rodriguez | e7824a5 | 2009-11-24 02:53:25 -0500 | [diff] [blame] | 2337 | sc->sc_flags &= ~(SC_OP_PS_ENABLED | |
| 2338 | SC_OP_NULLFUNC_COMPLETED); |
Luis R. Rodriguez | 9ecdef4 | 2009-09-09 21:10:09 -0700 | [diff] [blame] | 2339 | ath9k_setpower(sc, ATH9K_PM_AWAKE); |
Vivek Natarajan | 8782b41 | 2009-03-30 14:17:00 +0530 | [diff] [blame] | 2340 | if (!(ah->caps.hw_caps & |
| 2341 | ATH9K_HW_CAP_AUTOSLEEP)) { |
| 2342 | ath9k_hw_setrxabort(sc->sc_ah, 0); |
Jouni Malinen | 9a23f9c | 2009-05-19 17:01:38 +0300 | [diff] [blame] | 2343 | sc->sc_flags &= ~(SC_OP_WAIT_FOR_BEACON | |
| 2344 | SC_OP_WAIT_FOR_CAB | |
| 2345 | SC_OP_WAIT_FOR_PSPOLL_DATA | |
| 2346 | SC_OP_WAIT_FOR_TX_ACK); |
Vivek Natarajan | 8782b41 | 2009-03-30 14:17:00 +0530 | [diff] [blame] | 2347 | if (sc->imask & ATH9K_INT_TIM_TIMER) { |
| 2348 | sc->imask &= ~ATH9K_INT_TIM_TIMER; |
| 2349 | ath9k_hw_set_interrupts(sc->sc_ah, |
| 2350 | sc->imask); |
| 2351 | } |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 2352 | } |
| 2353 | } |
| 2354 | } |
| 2355 | |
Johannes Berg | 4797938 | 2009-01-07 10:13:27 +0100 | [diff] [blame] | 2356 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { |
Sujith | 99405f9 | 2008-11-24 12:08:35 +0530 | [diff] [blame] | 2357 | struct ieee80211_channel *curchan = hw->conf.channel; |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 2358 | int pos = curchan->hw_value; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2359 | |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 2360 | aphy->chan_idx = pos; |
| 2361 | aphy->chan_is_ht = conf_is_ht(conf); |
| 2362 | |
Jouni Malinen | 8089cc4 | 2009-03-03 19:23:38 +0200 | [diff] [blame] | 2363 | if (aphy->state == ATH_WIPHY_SCAN || |
| 2364 | aphy->state == ATH_WIPHY_ACTIVE) |
| 2365 | ath9k_wiphy_pause_all_forced(sc, aphy); |
| 2366 | else { |
| 2367 | /* |
| 2368 | * Do not change operational channel based on a paused |
| 2369 | * wiphy changes. |
| 2370 | */ |
| 2371 | goto skip_chan_change; |
| 2372 | } |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 2373 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2374 | ath_print(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n", |
| 2375 | curchan->center_freq); |
Johannes Berg | ae5eb02 | 2008-10-14 16:58:37 +0200 | [diff] [blame] | 2376 | |
Luis R. Rodriguez | 5f8e077 | 2009-01-22 15:16:48 -0800 | [diff] [blame] | 2377 | /* XXX: remove me eventualy */ |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 2378 | ath9k_update_ichannel(sc, hw, &sc->sc_ah->channels[pos]); |
Sujith | e11602b | 2008-11-27 09:46:27 +0530 | [diff] [blame] | 2379 | |
Luis R. Rodriguez | ecf7044 | 2008-12-23 15:58:43 -0800 | [diff] [blame] | 2380 | ath_update_chainmask(sc, conf_is_ht(conf)); |
Sujith | 86060f0 | 2009-01-07 14:25:29 +0530 | [diff] [blame] | 2381 | |
Jouni Malinen | 0e2dedf | 2009-03-03 19:23:32 +0200 | [diff] [blame] | 2382 | if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2383 | ath_print(common, ATH_DBG_FATAL, |
| 2384 | "Unable to set channel\n"); |
Sujith | aa33de0 | 2008-12-18 11:40:16 +0530 | [diff] [blame] | 2385 | mutex_unlock(&sc->mutex); |
Sujith | e11602b | 2008-11-27 09:46:27 +0530 | [diff] [blame] | 2386 | return -EINVAL; |
| 2387 | } |
Sujith | 094d05d | 2008-12-12 11:57:43 +0530 | [diff] [blame] | 2388 | } |
Sujith | 86b89ee | 2008-08-07 10:54:57 +0530 | [diff] [blame] | 2389 | |
Jouni Malinen | 8089cc4 | 2009-03-03 19:23:38 +0200 | [diff] [blame] | 2390 | skip_chan_change: |
Luis R. Rodriguez | 5c020dc | 2008-10-22 13:28:45 -0700 | [diff] [blame] | 2391 | if (changed & IEEE80211_CONF_CHANGE_POWER) |
Sujith | 17d7904 | 2009-02-09 13:27:03 +0530 | [diff] [blame] | 2392 | sc->config.txpowlimit = 2 * conf->power_level; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2393 | |
Luis R. Rodriguez | 194b7c1 | 2009-10-29 10:41:15 -0700 | [diff] [blame] | 2394 | spin_lock_bh(&sc->wiphy_lock); |
| 2395 | disable_radio = ath9k_all_wiphys_idle(sc); |
| 2396 | spin_unlock_bh(&sc->wiphy_lock); |
| 2397 | |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 2398 | if (disable_radio) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2399 | ath_print(common, ATH_DBG_CONFIG, "idle: disabling radio\n"); |
Luis R. Rodriguez | 68a8911 | 2009-11-02 14:35:42 -0800 | [diff] [blame] | 2400 | ath_radio_disable(sc, hw); |
Luis R. Rodriguez | 6483917 | 2009-07-14 20:22:53 -0400 | [diff] [blame] | 2401 | } |
| 2402 | |
Sujith | aa33de0 | 2008-12-18 11:40:16 +0530 | [diff] [blame] | 2403 | mutex_unlock(&sc->mutex); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2404 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2405 | return 0; |
| 2406 | } |
| 2407 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2408 | #define SUPPORTED_FILTERS \ |
| 2409 | (FIF_PROMISC_IN_BSS | \ |
| 2410 | FIF_ALLMULTI | \ |
| 2411 | FIF_CONTROL | \ |
Luis R. Rodriguez | af6a3fc | 2009-08-08 21:55:16 -0400 | [diff] [blame] | 2412 | FIF_PSPOLL | \ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2413 | FIF_OTHER_BSS | \ |
| 2414 | FIF_BCN_PRBRESP_PROMISC | \ |
| 2415 | FIF_FCSFAIL) |
| 2416 | |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 2417 | /* FIXME: sc->sc_full_reset ? */ |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2418 | static void ath9k_configure_filter(struct ieee80211_hw *hw, |
| 2419 | unsigned int changed_flags, |
| 2420 | unsigned int *total_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 2421 | u64 multicast) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2422 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2423 | struct ath_wiphy *aphy = hw->priv; |
| 2424 | struct ath_softc *sc = aphy->sc; |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 2425 | u32 rfilt; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2426 | |
| 2427 | changed_flags &= SUPPORTED_FILTERS; |
| 2428 | *total_flags &= SUPPORTED_FILTERS; |
| 2429 | |
Sujith | b77f483 | 2008-12-07 21:44:03 +0530 | [diff] [blame] | 2430 | sc->rx.rxfilter = *total_flags; |
Jouni Malinen | aa68aea | 2009-05-19 17:01:41 +0300 | [diff] [blame] | 2431 | ath9k_ps_wakeup(sc); |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 2432 | rfilt = ath_calcrxfilter(sc); |
| 2433 | ath9k_hw_setrxfilter(sc->sc_ah, rfilt); |
Jouni Malinen | aa68aea | 2009-05-19 17:01:41 +0300 | [diff] [blame] | 2434 | ath9k_ps_restore(sc); |
Sujith | 7dcfdcd | 2008-08-11 14:03:13 +0530 | [diff] [blame] | 2435 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2436 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG, |
| 2437 | "Set HW RX filter: 0x%x\n", rfilt); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2438 | } |
| 2439 | |
| 2440 | static void ath9k_sta_notify(struct ieee80211_hw *hw, |
| 2441 | struct ieee80211_vif *vif, |
| 2442 | enum sta_notify_cmd cmd, |
Johannes Berg | 17741cd | 2008-09-11 00:02:02 +0200 | [diff] [blame] | 2443 | struct ieee80211_sta *sta) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2444 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2445 | struct ath_wiphy *aphy = hw->priv; |
| 2446 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2447 | |
| 2448 | switch (cmd) { |
| 2449 | case STA_NOTIFY_ADD: |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 2450 | ath_node_attach(sc, sta); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2451 | break; |
| 2452 | case STA_NOTIFY_REMOVE: |
Sujith | b5aa9bf | 2008-10-29 10:13:31 +0530 | [diff] [blame] | 2453 | ath_node_detach(sc, sta); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2454 | break; |
| 2455 | default: |
| 2456 | break; |
| 2457 | } |
| 2458 | } |
| 2459 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2460 | static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2461 | const struct ieee80211_tx_queue_params *params) |
| 2462 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2463 | struct ath_wiphy *aphy = hw->priv; |
| 2464 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2465 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | ea9880f | 2008-08-07 10:53:10 +0530 | [diff] [blame] | 2466 | struct ath9k_tx_queue_info qi; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2467 | int ret = 0, qnum; |
| 2468 | |
| 2469 | if (queue >= WME_NUM_AC) |
| 2470 | return 0; |
| 2471 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2472 | mutex_lock(&sc->mutex); |
| 2473 | |
Sujith | 1ffb061 | 2009-03-30 15:28:46 +0530 | [diff] [blame] | 2474 | memset(&qi, 0, sizeof(struct ath9k_tx_queue_info)); |
| 2475 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2476 | qi.tqi_aifs = params->aifs; |
| 2477 | qi.tqi_cwmin = params->cw_min; |
| 2478 | qi.tqi_cwmax = params->cw_max; |
| 2479 | qi.tqi_burstTime = params->txop; |
| 2480 | qnum = ath_get_hal_qnum(queue, sc); |
| 2481 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2482 | ath_print(common, ATH_DBG_CONFIG, |
| 2483 | "Configure tx [queue/halq] [%d/%d], " |
| 2484 | "aifs: %d, cw_min: %d, cw_max: %d, txop: %d\n", |
| 2485 | queue, qnum, params->aifs, params->cw_min, |
| 2486 | params->cw_max, params->txop); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2487 | |
| 2488 | ret = ath_txq_update(sc, qnum, &qi); |
| 2489 | if (ret) |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2490 | ath_print(common, ATH_DBG_FATAL, "TXQ Update failed\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2491 | |
Vivek Natarajan | 94db293 | 2009-11-25 12:01:54 +0530 | [diff] [blame] | 2492 | if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) |
| 2493 | if ((qnum == sc->tx.hwq_map[ATH9K_WME_AC_BE]) && !ret) |
| 2494 | ath_beaconq_config(sc); |
| 2495 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2496 | mutex_unlock(&sc->mutex); |
| 2497 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2498 | return ret; |
| 2499 | } |
| 2500 | |
| 2501 | static int ath9k_set_key(struct ieee80211_hw *hw, |
| 2502 | enum set_key_cmd cmd, |
Johannes Berg | dc822b5 | 2008-12-29 12:55:09 +0100 | [diff] [blame] | 2503 | struct ieee80211_vif *vif, |
| 2504 | struct ieee80211_sta *sta, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2505 | struct ieee80211_key_conf *key) |
| 2506 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2507 | struct ath_wiphy *aphy = hw->priv; |
| 2508 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2509 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2510 | int ret = 0; |
| 2511 | |
Jouni Malinen | b3bd89c | 2009-02-24 13:42:01 +0200 | [diff] [blame] | 2512 | if (modparam_nohwcrypt) |
| 2513 | return -ENOSPC; |
| 2514 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2515 | mutex_lock(&sc->mutex); |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 2516 | ath9k_ps_wakeup(sc); |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2517 | ath_print(common, ATH_DBG_CONFIG, "Set HW Key\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2518 | |
| 2519 | switch (cmd) { |
| 2520 | case SET_KEY: |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 2521 | ret = ath_key_config(common, vif, sta, key); |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 2522 | if (ret >= 0) { |
| 2523 | key->hw_key_idx = ret; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2524 | /* push IV and Michael MIC generation to stack */ |
| 2525 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
Senthil Balasubramanian | 1b96175 | 2008-09-01 19:45:21 +0530 | [diff] [blame] | 2526 | if (key->alg == ALG_TKIP) |
| 2527 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; |
Jouni Malinen | 0ced0e1 | 2009-01-08 13:32:13 +0200 | [diff] [blame] | 2528 | if (sc->sc_ah->sw_mgmt_crypto && key->alg == ALG_CCMP) |
| 2529 | key->flags |= IEEE80211_KEY_FLAG_SW_MGMT; |
Jouni Malinen | 6ace289 | 2008-12-17 13:32:17 +0200 | [diff] [blame] | 2530 | ret = 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2531 | } |
| 2532 | break; |
| 2533 | case DISABLE_KEY: |
Luis R. Rodriguez | 7e86c10 | 2009-11-04 17:21:01 -0800 | [diff] [blame] | 2534 | ath_key_delete(common, key); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2535 | break; |
| 2536 | default: |
| 2537 | ret = -EINVAL; |
| 2538 | } |
| 2539 | |
Vivek Natarajan | 3cbb5dd | 2009-01-20 11:17:08 +0530 | [diff] [blame] | 2540 | ath9k_ps_restore(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2541 | mutex_unlock(&sc->mutex); |
| 2542 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2543 | return ret; |
| 2544 | } |
| 2545 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2546 | static void ath9k_bss_info_changed(struct ieee80211_hw *hw, |
| 2547 | struct ieee80211_vif *vif, |
| 2548 | struct ieee80211_bss_conf *bss_conf, |
| 2549 | u32 changed) |
| 2550 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2551 | struct ath_wiphy *aphy = hw->priv; |
| 2552 | struct ath_softc *sc = aphy->sc; |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 2553 | struct ath_hw *ah = sc->sc_ah; |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 2554 | struct ath_common *common = ath9k_hw_common(ah); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 2555 | struct ath_vif *avp = (void *)vif->drv_priv; |
Sujith | c6089cc | 2009-11-16 11:40:48 +0530 | [diff] [blame] | 2556 | int error; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2557 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2558 | mutex_lock(&sc->mutex); |
| 2559 | |
Sujith | c6089cc | 2009-11-16 11:40:48 +0530 | [diff] [blame] | 2560 | if (changed & BSS_CHANGED_BSSID) { |
| 2561 | /* Set BSSID */ |
| 2562 | memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN); |
| 2563 | memcpy(avp->bssid, bss_conf->bssid, ETH_ALEN); |
Luis R. Rodriguez | 1510718 | 2009-09-10 09:22:37 -0700 | [diff] [blame] | 2564 | common->curaid = 0; |
Luis R. Rodriguez | f2b2143 | 2009-09-10 08:50:20 -0700 | [diff] [blame] | 2565 | ath9k_hw_write_associd(ah); |
Sujith | c6089cc | 2009-11-16 11:40:48 +0530 | [diff] [blame] | 2566 | |
| 2567 | /* Set aggregation protection mode parameters */ |
| 2568 | sc->config.ath_aggr_prot = 0; |
| 2569 | |
| 2570 | /* Only legacy IBSS for now */ |
| 2571 | if (vif->type == NL80211_IFTYPE_ADHOC) |
| 2572 | ath_update_chainmask(sc, 0); |
| 2573 | |
| 2574 | ath_print(common, ATH_DBG_CONFIG, |
| 2575 | "BSSID: %pM aid: 0x%x\n", |
| 2576 | common->curbssid, common->curaid); |
| 2577 | |
| 2578 | /* need to reconfigure the beacon */ |
| 2579 | sc->sc_flags &= ~SC_OP_BEACONS ; |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 2580 | } |
| 2581 | |
Sujith | c6089cc | 2009-11-16 11:40:48 +0530 | [diff] [blame] | 2582 | /* Enable transmission of beacons (AP, IBSS, MESH) */ |
| 2583 | if ((changed & BSS_CHANGED_BEACON) || |
| 2584 | ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon)) { |
| 2585 | ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); |
| 2586 | error = ath_beacon_alloc(aphy, vif); |
| 2587 | if (!error) |
| 2588 | ath_beacon_config(sc, vif); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 2589 | } |
| 2590 | |
Sujith | c6089cc | 2009-11-16 11:40:48 +0530 | [diff] [blame] | 2591 | /* Disable transmission of beacons */ |
| 2592 | if ((changed & BSS_CHANGED_BEACON_ENABLED) && !bss_conf->enable_beacon) |
| 2593 | ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); |
| 2594 | |
| 2595 | if (changed & BSS_CHANGED_BEACON_INT) { |
| 2596 | sc->beacon_interval = bss_conf->beacon_int; |
| 2597 | /* |
| 2598 | * In case of AP mode, the HW TSF has to be reset |
| 2599 | * when the beacon interval changes. |
| 2600 | */ |
| 2601 | if (vif->type == NL80211_IFTYPE_AP) { |
| 2602 | sc->sc_flags |= SC_OP_TSF_RESET; |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 2603 | ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 2604 | error = ath_beacon_alloc(aphy, vif); |
| 2605 | if (!error) |
| 2606 | ath_beacon_config(sc, vif); |
Sujith | c6089cc | 2009-11-16 11:40:48 +0530 | [diff] [blame] | 2607 | } else { |
| 2608 | ath_beacon_config(sc, vif); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 2609 | } |
| 2610 | } |
| 2611 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2612 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2613 | ath_print(common, ATH_DBG_CONFIG, "BSS Changed PREAMBLE %d\n", |
| 2614 | bss_conf->use_short_preamble); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2615 | if (bss_conf->use_short_preamble) |
Sujith | 672840a | 2008-08-11 14:05:08 +0530 | [diff] [blame] | 2616 | sc->sc_flags |= SC_OP_PREAMBLE_SHORT; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2617 | else |
Sujith | 672840a | 2008-08-11 14:05:08 +0530 | [diff] [blame] | 2618 | sc->sc_flags &= ~SC_OP_PREAMBLE_SHORT; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2619 | } |
| 2620 | |
| 2621 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2622 | ath_print(common, ATH_DBG_CONFIG, "BSS Changed CTS PROT %d\n", |
| 2623 | bss_conf->use_cts_prot); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2624 | if (bss_conf->use_cts_prot && |
| 2625 | hw->conf.channel->band != IEEE80211_BAND_5GHZ) |
Sujith | 672840a | 2008-08-11 14:05:08 +0530 | [diff] [blame] | 2626 | sc->sc_flags |= SC_OP_PROTECT_ENABLE; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2627 | else |
Sujith | 672840a | 2008-08-11 14:05:08 +0530 | [diff] [blame] | 2628 | sc->sc_flags &= ~SC_OP_PROTECT_ENABLE; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2629 | } |
| 2630 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2631 | if (changed & BSS_CHANGED_ASSOC) { |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2632 | ath_print(common, ATH_DBG_CONFIG, "BSS Changed ASSOC %d\n", |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2633 | bss_conf->assoc); |
Sujith | 5640b08 | 2008-10-29 10:16:06 +0530 | [diff] [blame] | 2634 | ath9k_bss_assoc_info(sc, vif, bss_conf); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2635 | } |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2636 | |
| 2637 | mutex_unlock(&sc->mutex); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2638 | } |
| 2639 | |
| 2640 | static u64 ath9k_get_tsf(struct ieee80211_hw *hw) |
| 2641 | { |
| 2642 | u64 tsf; |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2643 | struct ath_wiphy *aphy = hw->priv; |
| 2644 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2645 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2646 | mutex_lock(&sc->mutex); |
| 2647 | tsf = ath9k_hw_gettsf64(sc->sc_ah); |
| 2648 | mutex_unlock(&sc->mutex); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2649 | |
| 2650 | return tsf; |
| 2651 | } |
| 2652 | |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 2653 | static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf) |
| 2654 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2655 | struct ath_wiphy *aphy = hw->priv; |
| 2656 | struct ath_softc *sc = aphy->sc; |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 2657 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2658 | mutex_lock(&sc->mutex); |
| 2659 | ath9k_hw_settsf64(sc->sc_ah, tsf); |
| 2660 | mutex_unlock(&sc->mutex); |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 2661 | } |
| 2662 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2663 | static void ath9k_reset_tsf(struct ieee80211_hw *hw) |
| 2664 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2665 | struct ath_wiphy *aphy = hw->priv; |
| 2666 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2667 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2668 | mutex_lock(&sc->mutex); |
Luis R. Rodriguez | 21526d5 | 2009-09-09 20:05:39 -0700 | [diff] [blame] | 2669 | |
| 2670 | ath9k_ps_wakeup(sc); |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2671 | ath9k_hw_reset_tsf(sc->sc_ah); |
Luis R. Rodriguez | 21526d5 | 2009-09-09 20:05:39 -0700 | [diff] [blame] | 2672 | ath9k_ps_restore(sc); |
| 2673 | |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2674 | mutex_unlock(&sc->mutex); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2675 | } |
| 2676 | |
| 2677 | static int ath9k_ampdu_action(struct ieee80211_hw *hw, |
Johannes Berg | c951ad3 | 2009-11-16 12:00:38 +0100 | [diff] [blame] | 2678 | struct ieee80211_vif *vif, |
Sujith | 141b38b | 2009-02-04 08:10:07 +0530 | [diff] [blame] | 2679 | enum ieee80211_ampdu_mlme_action action, |
| 2680 | struct ieee80211_sta *sta, |
| 2681 | u16 tid, u16 *ssn) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2682 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2683 | struct ath_wiphy *aphy = hw->priv; |
| 2684 | struct ath_softc *sc = aphy->sc; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2685 | int ret = 0; |
| 2686 | |
| 2687 | switch (action) { |
| 2688 | case IEEE80211_AMPDU_RX_START: |
Sujith | dca3edb | 2008-10-29 10:19:01 +0530 | [diff] [blame] | 2689 | if (!(sc->sc_flags & SC_OP_RXAGGR)) |
| 2690 | ret = -ENOTSUPP; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2691 | break; |
| 2692 | case IEEE80211_AMPDU_RX_STOP: |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2693 | break; |
| 2694 | case IEEE80211_AMPDU_TX_START: |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 2695 | ath9k_ps_wakeup(sc); |
Sujith | f83da96 | 2009-07-23 15:32:37 +0530 | [diff] [blame] | 2696 | ath_tx_aggr_start(sc, sta, tid, ssn); |
Johannes Berg | c951ad3 | 2009-11-16 12:00:38 +0100 | [diff] [blame] | 2697 | ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 2698 | ath9k_ps_restore(sc); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2699 | break; |
| 2700 | case IEEE80211_AMPDU_TX_STOP: |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 2701 | ath9k_ps_wakeup(sc); |
Sujith | f83da96 | 2009-07-23 15:32:37 +0530 | [diff] [blame] | 2702 | ath_tx_aggr_stop(sc, sta, tid); |
Johannes Berg | c951ad3 | 2009-11-16 12:00:38 +0100 | [diff] [blame] | 2703 | ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 2704 | ath9k_ps_restore(sc); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2705 | break; |
Johannes Berg | b172023 | 2009-03-23 17:28:39 +0100 | [diff] [blame] | 2706 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 2707 | ath9k_ps_wakeup(sc); |
Sujith | 8469cde | 2008-10-29 10:19:28 +0530 | [diff] [blame] | 2708 | ath_tx_aggr_resume(sc, sta, tid); |
Luis R. Rodriguez | 8b685ba | 2009-12-23 20:03:29 -0500 | [diff] [blame] | 2709 | ath9k_ps_restore(sc); |
Sujith | 8469cde | 2008-10-29 10:19:28 +0530 | [diff] [blame] | 2710 | break; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2711 | default: |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 2712 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, |
| 2713 | "Unknown AMPDU action\n"); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2714 | } |
| 2715 | |
| 2716 | return ret; |
| 2717 | } |
| 2718 | |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2719 | static void ath9k_sw_scan_start(struct ieee80211_hw *hw) |
| 2720 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2721 | struct ath_wiphy *aphy = hw->priv; |
| 2722 | struct ath_softc *sc = aphy->sc; |
Sujith | 05c78d6 | 2009-12-14 14:57:04 +0530 | [diff] [blame] | 2723 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2724 | |
Sujith | 3d83261 | 2009-08-21 12:00:28 +0530 | [diff] [blame] | 2725 | mutex_lock(&sc->mutex); |
Jouni Malinen | 8089cc4 | 2009-03-03 19:23:38 +0200 | [diff] [blame] | 2726 | if (ath9k_wiphy_scanning(sc)) { |
| 2727 | printk(KERN_DEBUG "ath9k: Two wiphys trying to scan at the " |
| 2728 | "same time\n"); |
| 2729 | /* |
| 2730 | * Do not allow the concurrent scanning state for now. This |
| 2731 | * could be improved with scanning control moved into ath9k. |
| 2732 | */ |
Sujith | 3d83261 | 2009-08-21 12:00:28 +0530 | [diff] [blame] | 2733 | mutex_unlock(&sc->mutex); |
Jouni Malinen | 8089cc4 | 2009-03-03 19:23:38 +0200 | [diff] [blame] | 2734 | return; |
| 2735 | } |
| 2736 | |
| 2737 | aphy->state = ATH_WIPHY_SCAN; |
| 2738 | ath9k_wiphy_pause_all_forced(sc, aphy); |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2739 | sc->sc_flags |= SC_OP_SCANNING; |
Sujith | 05c78d6 | 2009-12-14 14:57:04 +0530 | [diff] [blame] | 2740 | del_timer_sync(&common->ani.timer); |
Sujith | b6ce5c3 | 2009-12-14 14:57:06 +0530 | [diff] [blame] | 2741 | cancel_delayed_work_sync(&sc->tx_complete_work); |
Sujith | 3d83261 | 2009-08-21 12:00:28 +0530 | [diff] [blame] | 2742 | mutex_unlock(&sc->mutex); |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2743 | } |
| 2744 | |
| 2745 | static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) |
| 2746 | { |
Jouni Malinen | bce048d | 2009-03-03 19:23:28 +0200 | [diff] [blame] | 2747 | struct ath_wiphy *aphy = hw->priv; |
| 2748 | struct ath_softc *sc = aphy->sc; |
Sujith | 05c78d6 | 2009-12-14 14:57:04 +0530 | [diff] [blame] | 2749 | struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2750 | |
Sujith | 3d83261 | 2009-08-21 12:00:28 +0530 | [diff] [blame] | 2751 | mutex_lock(&sc->mutex); |
Jouni Malinen | 8089cc4 | 2009-03-03 19:23:38 +0200 | [diff] [blame] | 2752 | aphy->state = ATH_WIPHY_ACTIVE; |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2753 | sc->sc_flags &= ~SC_OP_SCANNING; |
Sujith | 9c07a77 | 2009-04-13 21:56:36 +0530 | [diff] [blame] | 2754 | sc->sc_flags |= SC_OP_FULL_RESET; |
Sujith | 05c78d6 | 2009-12-14 14:57:04 +0530 | [diff] [blame] | 2755 | ath_start_ani(common); |
Sujith | b6ce5c3 | 2009-12-14 14:57:06 +0530 | [diff] [blame] | 2756 | ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); |
Vivek Natarajan | d0bec34 | 2009-09-02 15:50:55 +0530 | [diff] [blame] | 2757 | ath_beacon_config(sc, NULL); |
Sujith | 3d83261 | 2009-08-21 12:00:28 +0530 | [diff] [blame] | 2758 | mutex_unlock(&sc->mutex); |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2759 | } |
| 2760 | |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2761 | struct ieee80211_ops ath9k_ops = { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2762 | .tx = ath9k_tx, |
| 2763 | .start = ath9k_start, |
| 2764 | .stop = ath9k_stop, |
| 2765 | .add_interface = ath9k_add_interface, |
| 2766 | .remove_interface = ath9k_remove_interface, |
| 2767 | .config = ath9k_config, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2768 | .configure_filter = ath9k_configure_filter, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2769 | .sta_notify = ath9k_sta_notify, |
| 2770 | .conf_tx = ath9k_conf_tx, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2771 | .bss_info_changed = ath9k_bss_info_changed, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2772 | .set_key = ath9k_set_key, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2773 | .get_tsf = ath9k_get_tsf, |
Alina Friedrichsen | 3b5d665 | 2009-01-24 07:09:59 +0100 | [diff] [blame] | 2774 | .set_tsf = ath9k_set_tsf, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2775 | .reset_tsf = ath9k_reset_tsf, |
Johannes Berg | 4233df6 | 2008-10-13 13:35:05 +0200 | [diff] [blame] | 2776 | .ampdu_action = ath9k_ampdu_action, |
Sujith | 0c98de6 | 2009-03-03 10:16:45 +0530 | [diff] [blame] | 2777 | .sw_scan_start = ath9k_sw_scan_start, |
| 2778 | .sw_scan_complete = ath9k_sw_scan_complete, |
Johannes Berg | 3b319aa | 2009-06-13 14:50:26 +0530 | [diff] [blame] | 2779 | .rfkill_poll = ath9k_rfkill_poll_state, |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2780 | }; |
| 2781 | |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2782 | static int __init ath9k_init(void) |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2783 | { |
Vasanthakumar Thiagarajan | ca8a856 | 2008-12-16 12:37:38 +0530 | [diff] [blame] | 2784 | int error; |
| 2785 | |
Vasanthakumar Thiagarajan | ca8a856 | 2008-12-16 12:37:38 +0530 | [diff] [blame] | 2786 | /* Register rate control algorithm */ |
| 2787 | error = ath_rate_control_register(); |
| 2788 | if (error != 0) { |
| 2789 | printk(KERN_ERR |
Luis R. Rodriguez | b51bb3c | 2009-01-26 07:30:03 -0800 | [diff] [blame] | 2790 | "ath9k: Unable to register rate control " |
| 2791 | "algorithm: %d\n", |
Vasanthakumar Thiagarajan | ca8a856 | 2008-12-16 12:37:38 +0530 | [diff] [blame] | 2792 | error); |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2793 | goto err_out; |
Vasanthakumar Thiagarajan | ca8a856 | 2008-12-16 12:37:38 +0530 | [diff] [blame] | 2794 | } |
| 2795 | |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 2796 | error = ath9k_debug_create_root(); |
| 2797 | if (error) { |
| 2798 | printk(KERN_ERR |
| 2799 | "ath9k: Unable to create debugfs root: %d\n", |
| 2800 | error); |
| 2801 | goto err_rate_unregister; |
| 2802 | } |
| 2803 | |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2804 | error = ath_pci_init(); |
| 2805 | if (error < 0) { |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2806 | printk(KERN_ERR |
Luis R. Rodriguez | b51bb3c | 2009-01-26 07:30:03 -0800 | [diff] [blame] | 2807 | "ath9k: No PCI devices found, driver not installed.\n"); |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2808 | error = -ENODEV; |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 2809 | goto err_remove_root; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2810 | } |
| 2811 | |
Gabor Juhos | 09329d3 | 2009-01-14 20:17:07 +0100 | [diff] [blame] | 2812 | error = ath_ahb_init(); |
| 2813 | if (error < 0) { |
| 2814 | error = -ENODEV; |
| 2815 | goto err_pci_exit; |
| 2816 | } |
| 2817 | |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2818 | return 0; |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2819 | |
Gabor Juhos | 09329d3 | 2009-01-14 20:17:07 +0100 | [diff] [blame] | 2820 | err_pci_exit: |
| 2821 | ath_pci_exit(); |
| 2822 | |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 2823 | err_remove_root: |
| 2824 | ath9k_debug_remove_root(); |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2825 | err_rate_unregister: |
Vasanthakumar Thiagarajan | ca8a856 | 2008-12-16 12:37:38 +0530 | [diff] [blame] | 2826 | ath_rate_control_unregister(); |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2827 | err_out: |
| 2828 | return error; |
| 2829 | } |
| 2830 | module_init(ath9k_init); |
| 2831 | |
| 2832 | static void __exit ath9k_exit(void) |
| 2833 | { |
Gabor Juhos | 09329d3 | 2009-01-14 20:17:07 +0100 | [diff] [blame] | 2834 | ath_ahb_exit(); |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2835 | ath_pci_exit(); |
Gabor Juhos | 19d8bc2 | 2009-03-05 16:55:18 +0100 | [diff] [blame] | 2836 | ath9k_debug_remove_root(); |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2837 | ath_rate_control_unregister(); |
Sujith | 04bd4638 | 2008-11-28 22:18:05 +0530 | [diff] [blame] | 2838 | printk(KERN_INFO "%s: Driver unloaded\n", dev_info); |
Luis R. Rodriguez | f078f20 | 2008-08-04 00:16:41 -0700 | [diff] [blame] | 2839 | } |
Gabor Juhos | 6baff7f | 2009-01-14 20:17:06 +0100 | [diff] [blame] | 2840 | module_exit(ath9k_exit); |