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