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