main.c (03ab3da3b215bac4ebb093c808d54596e03e3225) | main.c (fbbcd14690d3c42b664740d58a22af50a77d5689) |
---|---|
1/* 2 * Copyright (c) 2008-2011 Atheros Communications Inc. 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 --- 219 unchanged lines hidden (view full) --- 228 229 ath9k_cmn_update_txpow(ah, sc->curtxpow, 230 sc->config.txpowlimit, &sc->curtxpow); 231 232 clear_bit(ATH_OP_HW_RESET, &common->op_flags); 233 ath9k_hw_set_interrupts(ah); 234 ath9k_hw_enable_interrupts(ah); 235 | 1/* 2 * Copyright (c) 2008-2011 Atheros Communications Inc. 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 --- 219 unchanged lines hidden (view full) --- 228 229 ath9k_cmn_update_txpow(ah, sc->curtxpow, 230 sc->config.txpowlimit, &sc->curtxpow); 231 232 clear_bit(ATH_OP_HW_RESET, &common->op_flags); 233 ath9k_hw_set_interrupts(ah); 234 ath9k_hw_enable_interrupts(ah); 235 |
236 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) && start) { | 236 if (!sc->cur_chan->offchannel && start) { |
237 if (!test_bit(ATH_OP_BEACONS, &common->op_flags)) 238 goto work; 239 240 if (ah->opmode == NL80211_IFTYPE_STATION && 241 test_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags)) { 242 spin_lock_irqsave(&sc->sc_pm_lock, flags); 243 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; 244 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); --- 16 unchanged lines hidden (view full) --- 261 sc->gtt_cnt = 0; 262 ieee80211_wake_queues(sc->hw); 263 264 ath9k_p2p_ps_timer(sc); 265 266 return true; 267} 268 | 237 if (!test_bit(ATH_OP_BEACONS, &common->op_flags)) 238 goto work; 239 240 if (ah->opmode == NL80211_IFTYPE_STATION && 241 test_bit(ATH_OP_PRIM_STA_VIF, &common->op_flags)) { 242 spin_lock_irqsave(&sc->sc_pm_lock, flags); 243 sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON; 244 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); --- 16 unchanged lines hidden (view full) --- 261 sc->gtt_cnt = 0; 262 ieee80211_wake_queues(sc->hw); 263 264 ath9k_p2p_ps_timer(sc); 265 266 return true; 267} 268 |
269static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan) | 269int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan) |
270{ 271 struct ath_hw *ah = sc->sc_ah; 272 struct ath_common *common = ath9k_hw_common(ah); 273 struct ath9k_hw_cal_data *caldata = NULL; 274 bool fastcc = true; 275 int r; 276 277 __ath_cancel_work(sc); 278 279 tasklet_disable(&sc->intr_tq); 280 spin_lock_bh(&sc->sc_pcu_lock); 281 | 270{ 271 struct ath_hw *ah = sc->sc_ah; 272 struct ath_common *common = ath9k_hw_common(ah); 273 struct ath9k_hw_cal_data *caldata = NULL; 274 bool fastcc = true; 275 int r; 276 277 __ath_cancel_work(sc); 278 279 tasklet_disable(&sc->intr_tq); 280 spin_lock_bh(&sc->sc_pcu_lock); 281 |
282 if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) { | 282 if (!sc->cur_chan->offchannel) { |
283 fastcc = false; 284 caldata = &sc->caldata; 285 } 286 287 if (!hchan) { 288 fastcc = false; 289 hchan = ah->curchan; 290 } --- 11 unchanged lines hidden (view full) --- 302 303 ath9k_hw_enable_interrupts(ah); 304 ath9k_queue_reset(sc, RESET_TYPE_BB_HANG); 305 306 goto out; 307 } 308 309 if (ath9k_hw_mci_is_enabled(sc->sc_ah) && | 283 fastcc = false; 284 caldata = &sc->caldata; 285 } 286 287 if (!hchan) { 288 fastcc = false; 289 hchan = ah->curchan; 290 } --- 11 unchanged lines hidden (view full) --- 302 303 ath9k_hw_enable_interrupts(ah); 304 ath9k_queue_reset(sc, RESET_TYPE_BB_HANG); 305 306 goto out; 307 } 308 309 if (ath9k_hw_mci_is_enabled(sc->sc_ah) && |
310 (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) | 310 sc->cur_chan->offchannel) |
311 ath9k_mci_set_txpower(sc, true, false); 312 313 if (!ath_complete_reset(sc, true)) 314 r = -EIO; 315 316out: 317 spin_unlock_bh(&sc->sc_pcu_lock); 318 tasklet_enable(&sc->intr_tq); 319 320 return r; 321} 322 | 311 ath9k_mci_set_txpower(sc, true, false); 312 313 if (!ath_complete_reset(sc, true)) 314 r = -EIO; 315 316out: 317 spin_unlock_bh(&sc->sc_pcu_lock); 318 tasklet_enable(&sc->intr_tq); 319 320 return r; 321} 322 |
323 324/* 325 * Set/change channels. If the channel is really being changed, it's done 326 * by reseting the chip. To accomplish this we must first cleanup any pending 327 * DMA, then restart stuff. 328*/ 329static int ath_set_channel(struct ath_softc *sc, struct cfg80211_chan_def *chandef) 330{ 331 struct ath_hw *ah = sc->sc_ah; 332 struct ath_common *common = ath9k_hw_common(ah); 333 struct ieee80211_hw *hw = sc->hw; 334 struct ath9k_channel *hchan; 335 struct ieee80211_channel *chan = chandef->chan; 336 bool offchannel; 337 int pos = chan->hw_value; 338 int old_pos = -1; 339 int r; 340 341 if (test_bit(ATH_OP_INVALID, &common->op_flags)) 342 return -EIO; 343 344 offchannel = !!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL); 345 346 if (ah->curchan) 347 old_pos = ah->curchan - &ah->channels[0]; 348 349 ath_dbg(common, CONFIG, "Set channel: %d MHz width: %d\n", 350 chan->center_freq, chandef->width); 351 352 /* update survey stats for the old channel before switching */ 353 spin_lock_bh(&common->cc_lock); 354 ath_update_survey_stats(sc); 355 spin_unlock_bh(&common->cc_lock); 356 357 ath9k_cmn_get_channel(hw, ah, chandef); 358 359 /* 360 * If the operating channel changes, change the survey in-use flags 361 * along with it. 362 * Reset the survey data for the new channel, unless we're switching 363 * back to the operating channel from an off-channel operation. 364 */ 365 if (!offchannel && sc->cur_survey != &sc->survey[pos]) { 366 if (sc->cur_survey) 367 sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE; 368 369 sc->cur_survey = &sc->survey[pos]; 370 371 memset(sc->cur_survey, 0, sizeof(struct survey_info)); 372 sc->cur_survey->filled |= SURVEY_INFO_IN_USE; 373 } else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) { 374 memset(&sc->survey[pos], 0, sizeof(struct survey_info)); 375 } 376 377 hchan = &sc->sc_ah->channels[pos]; 378 r = ath_reset_internal(sc, hchan); 379 if (r) 380 return r; 381 382 /* 383 * The most recent snapshot of channel->noisefloor for the old 384 * channel is only available after the hardware reset. Copy it to 385 * the survey stats now. 386 */ 387 if (old_pos >= 0) 388 ath_update_survey_nf(sc, old_pos); 389 390 /* 391 * Enable radar pulse detection if on a DFS channel. Spectral 392 * scanning and radar detection can not be used concurrently. 393 */ 394 if (hw->conf.radar_enabled) { 395 u32 rxfilter; 396 397 /* set HW specific DFS configuration */ 398 ath9k_hw_set_radar_params(ah); 399 rxfilter = ath9k_hw_getrxfilter(ah); 400 rxfilter |= ATH9K_RX_FILTER_PHYRADAR | 401 ATH9K_RX_FILTER_PHYERR; 402 ath9k_hw_setrxfilter(ah, rxfilter); 403 ath_dbg(common, DFS, "DFS enabled at freq %d\n", 404 chan->center_freq); 405 } else { 406 /* perform spectral scan if requested. */ 407 if (test_bit(ATH_OP_SCANNING, &common->op_flags) && 408 sc->spectral_mode == SPECTRAL_CHANSCAN) 409 ath9k_spectral_scan_trigger(hw); 410 } 411 412 return 0; 413} 414 | |
415static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, 416 struct ieee80211_vif *vif) 417{ 418 struct ath_node *an; 419 an = (struct ath_node *)sta->drv_priv; 420 421 an->sc = sc; 422 an->sta = sta; --- 285 unchanged lines hidden (view full) --- 708/**********************/ 709 710static int ath9k_start(struct ieee80211_hw *hw) 711{ 712 struct ath_softc *sc = hw->priv; 713 struct ath_hw *ah = sc->sc_ah; 714 struct ath_common *common = ath9k_hw_common(ah); 715 struct ieee80211_channel *curchan = hw->conf.chandef.chan; | 323static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, 324 struct ieee80211_vif *vif) 325{ 326 struct ath_node *an; 327 an = (struct ath_node *)sta->drv_priv; 328 329 an->sc = sc; 330 an->sta = sta; --- 285 unchanged lines hidden (view full) --- 616/**********************/ 617 618static int ath9k_start(struct ieee80211_hw *hw) 619{ 620 struct ath_softc *sc = hw->priv; 621 struct ath_hw *ah = sc->sc_ah; 622 struct ath_common *common = ath9k_hw_common(ah); 623 struct ieee80211_channel *curchan = hw->conf.chandef.chan; |
624 struct ath_chanctx *ctx = sc->cur_chan; |
|
716 struct ath9k_channel *init_channel; 717 int r; 718 719 ath_dbg(common, CONFIG, 720 "Starting driver with initial channel: %d MHz\n", 721 curchan->center_freq); 722 723 ath9k_ps_wakeup(sc); 724 mutex_lock(&sc->mutex); 725 | 625 struct ath9k_channel *init_channel; 626 int r; 627 628 ath_dbg(common, CONFIG, 629 "Starting driver with initial channel: %d MHz\n", 630 curchan->center_freq); 631 632 ath9k_ps_wakeup(sc); 633 mutex_lock(&sc->mutex); 634 |
726 init_channel = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef); | 635 memcpy(&ctx->chandef, &hw->conf.chandef, sizeof(ctx->chandef)); 636 init_channel = ath9k_cmn_get_channel(hw, ah, &ctx->chandef); |
727 728 /* Reset SERDES registers */ 729 ath9k_hw_configpcipowersave(ah, false); 730 731 /* 732 * The basic interface to setting the hardware in a good 733 * state is ``reset''. On return the hardware is known to 734 * be powered up and with interrupts disabled. This must --- 194 unchanged lines hidden (view full) --- 929 ath_prepare_reset(sc); 930 931 if (sc->rx.frag) { 932 dev_kfree_skb_any(sc->rx.frag); 933 sc->rx.frag = NULL; 934 } 935 936 if (!ah->curchan) | 637 638 /* Reset SERDES registers */ 639 ath9k_hw_configpcipowersave(ah, false); 640 641 /* 642 * The basic interface to setting the hardware in a good 643 * state is ``reset''. On return the hardware is known to 644 * be powered up and with interrupts disabled. This must --- 194 unchanged lines hidden (view full) --- 839 ath_prepare_reset(sc); 840 841 if (sc->rx.frag) { 842 dev_kfree_skb_any(sc->rx.frag); 843 sc->rx.frag = NULL; 844 } 845 846 if (!ah->curchan) |
937 ah->curchan = ath9k_cmn_get_channel(hw, ah, &hw->conf.chandef); | 847 ah->curchan = ath9k_cmn_get_channel(hw, ah, 848 &sc->cur_chan->chandef); |
938 939 ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); 940 ath9k_hw_phy_disable(ah); 941 942 ath9k_hw_configpcipowersave(ah, true); 943 944 spin_unlock_bh(&sc->sc_pcu_lock); 945 --- 394 unchanged lines hidden (view full) --- 1340} 1341 1342static int ath9k_config(struct ieee80211_hw *hw, u32 changed) 1343{ 1344 struct ath_softc *sc = hw->priv; 1345 struct ath_hw *ah = sc->sc_ah; 1346 struct ath_common *common = ath9k_hw_common(ah); 1347 struct ieee80211_conf *conf = &hw->conf; | 849 850 ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); 851 ath9k_hw_phy_disable(ah); 852 853 ath9k_hw_configpcipowersave(ah, true); 854 855 spin_unlock_bh(&sc->sc_pcu_lock); 856 --- 394 unchanged lines hidden (view full) --- 1251} 1252 1253static int ath9k_config(struct ieee80211_hw *hw, u32 changed) 1254{ 1255 struct ath_softc *sc = hw->priv; 1256 struct ath_hw *ah = sc->sc_ah; 1257 struct ath_common *common = ath9k_hw_common(ah); 1258 struct ieee80211_conf *conf = &hw->conf; |
1259 struct ath_chanctx *ctx = sc->cur_chan; |
|
1348 bool reset_channel = false; 1349 1350 ath9k_ps_wakeup(sc); 1351 mutex_lock(&sc->mutex); 1352 1353 if (changed & IEEE80211_CONF_CHANGE_IDLE) { 1354 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE); 1355 if (sc->ps_idle) { --- 31 unchanged lines hidden (view full) --- 1387 sc->sc_ah->is_monitoring = true; 1388 } else { 1389 ath_dbg(common, CONFIG, "Monitor mode is disabled\n"); 1390 sc->sc_ah->is_monitoring = false; 1391 } 1392 } 1393 1394 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) { | 1260 bool reset_channel = false; 1261 1262 ath9k_ps_wakeup(sc); 1263 mutex_lock(&sc->mutex); 1264 1265 if (changed & IEEE80211_CONF_CHANGE_IDLE) { 1266 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE); 1267 if (sc->ps_idle) { --- 31 unchanged lines hidden (view full) --- 1299 sc->sc_ah->is_monitoring = true; 1300 } else { 1301 ath_dbg(common, CONFIG, "Monitor mode is disabled\n"); 1302 sc->sc_ah->is_monitoring = false; 1303 } 1304 } 1305 1306 if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) { |
1395 if (ath_set_channel(sc, &hw->conf.chandef) < 0) { | 1307 ctx->offchannel = !!(conf->flags & IEEE80211_CONF_OFFCHANNEL); 1308 if (ath_chanctx_set_channel(sc, ctx, &hw->conf.chandef) < 0) { |
1396 ath_err(common, "Unable to set channel\n"); 1397 mutex_unlock(&sc->mutex); 1398 ath9k_ps_restore(sc); 1399 return -EINVAL; 1400 } 1401 } 1402 1403 if (changed & IEEE80211_CONF_CHANGE_POWER) { --- 877 unchanged lines hidden --- | 1309 ath_err(common, "Unable to set channel\n"); 1310 mutex_unlock(&sc->mutex); 1311 ath9k_ps_restore(sc); 1312 return -EINVAL; 1313 } 1314 } 1315 1316 if (changed & IEEE80211_CONF_CHANGE_POWER) { --- 877 unchanged lines hidden --- |