if_ath.c (271823) | if_ath.c (271887) |
---|---|
1/*- 2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 271823 2014-09-18 20:47:39Z glebius $"); | 31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 271887 2014-09-20 01:22:17Z adrian $"); |
32 33/* 34 * Driver for the Atheros Wireless LAN controller. 35 * 36 * This software is derived from work of Atsushi Onoe; his contribution 37 * is greatly appreciated. 38 */ 39 --- 1670 unchanged lines hidden (view full) --- 1710 1711 sc->sc_resume_up = (ifp->if_flags & IFF_UP) != 0; 1712 1713 ieee80211_suspend_all(ic); 1714 /* 1715 * NB: don't worry about putting the chip in low power 1716 * mode; pci will power off our socket on suspend and 1717 * CardBus detaches the device. | 32 33/* 34 * Driver for the Atheros Wireless LAN controller. 35 * 36 * This software is derived from work of Atsushi Onoe; his contribution 37 * is greatly appreciated. 38 */ 39 --- 1670 unchanged lines hidden (view full) --- 1710 1711 sc->sc_resume_up = (ifp->if_flags & IFF_UP) != 0; 1712 1713 ieee80211_suspend_all(ic); 1714 /* 1715 * NB: don't worry about putting the chip in low power 1716 * mode; pci will power off our socket on suspend and 1717 * CardBus detaches the device. |
1718 * 1719 * XXX TODO: well, that's great, except for non-cardbus 1720 * devices! |
|
1718 */ 1719 1720 /* | 1721 */ 1722 1723 /* |
1721 * XXX ensure none of the taskqueues are running | 1724 * XXX This doesn't wait until all pending taskqueue 1725 * items and parallel transmit/receive/other threads 1726 * are running! 1727 */ 1728 ath_hal_intrset(sc->sc_ah, 0); 1729 taskqueue_block(sc->sc_tq); 1730 callout_drain(&sc->sc_cal_ch); 1731 1732 /* |
1722 * XXX ensure sc_invalid is 1 | 1733 * XXX ensure sc_invalid is 1 |
1723 * XXX ensure the calibration callout is disabled | |
1724 */ 1725 1726 /* Disable the PCIe PHY, complete with workarounds */ 1727 ath_hal_enablepcie(sc->sc_ah, 1, 1); 1728} 1729 1730/* 1731 * Reset the key cache since some parts do not reset the --- 74 unchanged lines hidden (view full) --- 1806 ath_power_setpower(sc, HAL_PM_AWAKE); 1807 ATH_UNLOCK(sc); 1808 1809 ath_hal_reset(ah, sc->sc_opmode, 1810 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan, 1811 AH_FALSE, &status); 1812 ath_reset_keycache(sc); 1813 | 1734 */ 1735 1736 /* Disable the PCIe PHY, complete with workarounds */ 1737 ath_hal_enablepcie(sc->sc_ah, 1, 1); 1738} 1739 1740/* 1741 * Reset the key cache since some parts do not reset the --- 74 unchanged lines hidden (view full) --- 1816 ath_power_setpower(sc, HAL_PM_AWAKE); 1817 ATH_UNLOCK(sc); 1818 1819 ath_hal_reset(ah, sc->sc_opmode, 1820 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan, 1821 AH_FALSE, &status); 1822 ath_reset_keycache(sc); 1823 |
1824 ATH_RX_LOCK(sc); 1825 sc->sc_rx_stopped = 1; 1826 sc->sc_rx_resetted = 1; 1827 ATH_RX_UNLOCK(sc); 1828 |
|
1814 /* Let DFS at it in case it's a DFS channel */ 1815 ath_dfs_radar_enable(sc, ic->ic_curchan); 1816 1817 /* Let spectral at in case spectral is enabled */ 1818 ath_spectral_enable(sc, ic->ic_curchan); 1819 1820 /* 1821 * Let bluetooth coexistence at in case it's needed for this channel --- 188 unchanged lines hidden (view full) --- 2010 */ 2011 sc->sc_rx.recv_sched(sc, 1); 2012#endif 2013 } 2014 } 2015 if (status & HAL_INT_RXEOL) { 2016 int imask; 2017 ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXEOL"); | 1829 /* Let DFS at it in case it's a DFS channel */ 1830 ath_dfs_radar_enable(sc, ic->ic_curchan); 1831 1832 /* Let spectral at in case spectral is enabled */ 1833 ath_spectral_enable(sc, ic->ic_curchan); 1834 1835 /* 1836 * Let bluetooth coexistence at in case it's needed for this channel --- 188 unchanged lines hidden (view full) --- 2025 */ 2026 sc->sc_rx.recv_sched(sc, 1); 2027#endif 2028 } 2029 } 2030 if (status & HAL_INT_RXEOL) { 2031 int imask; 2032 ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXEOL"); |
2018 ATH_PCU_LOCK(sc); | 2033 if (! sc->sc_isedma) { 2034 ATH_PCU_LOCK(sc); 2035 /* 2036 * NB: the hardware should re-read the link when 2037 * RXE bit is written, but it doesn't work at 2038 * least on older hardware revs. 2039 */ 2040 sc->sc_stats.ast_rxeol++; 2041 /* 2042 * Disable RXEOL/RXORN - prevent an interrupt 2043 * storm until the PCU logic can be reset. 2044 * In case the interface is reset some other 2045 * way before "sc_kickpcu" is called, don't 2046 * modify sc_imask - that way if it is reset 2047 * by a call to ath_reset() somehow, the 2048 * interrupt mask will be correctly reprogrammed. 2049 */ 2050 imask = sc->sc_imask; 2051 imask &= ~(HAL_INT_RXEOL | HAL_INT_RXORN); 2052 ath_hal_intrset(ah, imask); 2053 /* 2054 * Only blank sc_rxlink if we've not yet kicked 2055 * the PCU. 2056 * 2057 * This isn't entirely correct - the correct solution 2058 * would be to have a PCU lock and engage that for 2059 * the duration of the PCU fiddling; which would include 2060 * running the RX process. Otherwise we could end up 2061 * messing up the RX descriptor chain and making the 2062 * RX desc list much shorter. 2063 */ 2064 if (! sc->sc_kickpcu) 2065 sc->sc_rxlink = NULL; 2066 sc->sc_kickpcu = 1; 2067 ATH_PCU_UNLOCK(sc); 2068 } |
2019 /* | 2069 /* |
2020 * NB: the hardware should re-read the link when 2021 * RXE bit is written, but it doesn't work at 2022 * least on older hardware revs. 2023 */ 2024 sc->sc_stats.ast_rxeol++; 2025 /* 2026 * Disable RXEOL/RXORN - prevent an interrupt 2027 * storm until the PCU logic can be reset. 2028 * In case the interface is reset some other 2029 * way before "sc_kickpcu" is called, don't 2030 * modify sc_imask - that way if it is reset 2031 * by a call to ath_reset() somehow, the 2032 * interrupt mask will be correctly reprogrammed. 2033 */ 2034 imask = sc->sc_imask; 2035 imask &= ~(HAL_INT_RXEOL | HAL_INT_RXORN); 2036 ath_hal_intrset(ah, imask); 2037 /* 2038 * Only blank sc_rxlink if we've not yet kicked 2039 * the PCU. 2040 * 2041 * This isn't entirely correct - the correct solution 2042 * would be to have a PCU lock and engage that for 2043 * the duration of the PCU fiddling; which would include 2044 * running the RX process. Otherwise we could end up 2045 * messing up the RX descriptor chain and making the 2046 * RX desc list much shorter. 2047 */ 2048 if (! sc->sc_kickpcu) 2049 sc->sc_rxlink = NULL; 2050 sc->sc_kickpcu = 1; 2051 ATH_PCU_UNLOCK(sc); 2052 /* 2053 * Enqueue an RX proc, to handled whatever | 2070 * Enqueue an RX proc to handle whatever |
2054 * is in the RX queue. | 2071 * is in the RX queue. |
2055 * This will then kick the PCU. | 2072 * This will then kick the PCU if required. |
2056 */ 2057 sc->sc_rx.recv_sched(sc, 1); 2058 } 2059 if (status & HAL_INT_TXURN) { 2060 sc->sc_stats.ast_txurn++; 2061 /* bump tx trigger level */ 2062 ath_hal_updatetxtriglevel(ah, AH_TRUE); 2063 } --- 279 unchanged lines hidden (view full) --- 2343 sc->sc_cur_rxchainmask); 2344 2345 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE, &status)) { 2346 if_printf(ifp, "unable to reset hardware; hal status %u\n", 2347 status); 2348 ATH_UNLOCK(sc); 2349 return; 2350 } | 2073 */ 2074 sc->sc_rx.recv_sched(sc, 1); 2075 } 2076 if (status & HAL_INT_TXURN) { 2077 sc->sc_stats.ast_txurn++; 2078 /* bump tx trigger level */ 2079 ath_hal_updatetxtriglevel(ah, AH_TRUE); 2080 } --- 279 unchanged lines hidden (view full) --- 2360 sc->sc_cur_rxchainmask); 2361 2362 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE, &status)) { 2363 if_printf(ifp, "unable to reset hardware; hal status %u\n", 2364 status); 2365 ATH_UNLOCK(sc); 2366 return; 2367 } |
2368 2369 ATH_RX_LOCK(sc); 2370 sc->sc_rx_stopped = 1; 2371 sc->sc_rx_resetted = 1; 2372 ATH_RX_UNLOCK(sc); 2373 |
|
2351 ath_chan_change(sc, ic->ic_curchan); 2352 2353 /* Let DFS at it in case it's a DFS channel */ 2354 ath_dfs_radar_enable(sc, ic->ic_curchan); 2355 2356 /* Let spectral at in case spectral is enabled */ 2357 ath_spectral_enable(sc, ic->ic_curchan); 2358 --- 42 unchanged lines hidden (view full) --- 2401 ATH_UNLOCK(sc); 2402 return; 2403 } 2404 2405 /* 2406 * Enable interrupts. 2407 */ 2408 sc->sc_imask = HAL_INT_RX | HAL_INT_TX | 2374 ath_chan_change(sc, ic->ic_curchan); 2375 2376 /* Let DFS at it in case it's a DFS channel */ 2377 ath_dfs_radar_enable(sc, ic->ic_curchan); 2378 2379 /* Let spectral at in case spectral is enabled */ 2380 ath_spectral_enable(sc, ic->ic_curchan); 2381 --- 42 unchanged lines hidden (view full) --- 2424 ATH_UNLOCK(sc); 2425 return; 2426 } 2427 2428 /* 2429 * Enable interrupts. 2430 */ 2431 sc->sc_imask = HAL_INT_RX | HAL_INT_TX |
2409 | HAL_INT_RXEOL | HAL_INT_RXORN 2410 | HAL_INT_TXURN | 2432 | HAL_INT_RXORN | HAL_INT_TXURN |
2411 | HAL_INT_FATAL | HAL_INT_GLOBAL; 2412 2413 /* 2414 * Enable RX EDMA bits. Note these overlap with 2415 * HAL_INT_RX and HAL_INT_RXDESC respectively. 2416 */ 2417 if (sc->sc_isedma) 2418 sc->sc_imask |= (HAL_INT_RXHP | HAL_INT_RXLP); 2419 2420 /* | 2433 | HAL_INT_FATAL | HAL_INT_GLOBAL; 2434 2435 /* 2436 * Enable RX EDMA bits. Note these overlap with 2437 * HAL_INT_RX and HAL_INT_RXDESC respectively. 2438 */ 2439 if (sc->sc_isedma) 2440 sc->sc_imask |= (HAL_INT_RXHP | HAL_INT_RXLP); 2441 2442 /* |
2443 * If we're an EDMA NIC, we don't care about RXEOL. 2444 * Writing a new descriptor in will simply restart 2445 * RX DMA. 2446 */ 2447 if (! sc->sc_isedma) 2448 sc->sc_imask |= HAL_INT_RXEOL; 2449 2450 /* |
|
2421 * Enable MIB interrupts when there are hardware phy counters. 2422 * Note we only do this (at the moment) for station mode. 2423 */ 2424 if (sc->sc_needmib && ic->ic_opmode == IEEE80211_M_STA) 2425 sc->sc_imask |= HAL_INT_MIB; 2426 2427 /* 2428 * XXX add capability for this. --- 301 unchanged lines hidden (view full) --- 2730 ath_update_chainmasks(sc, ic->ic_curchan); 2731 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, 2732 sc->sc_cur_rxchainmask); 2733 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, &status)) 2734 if_printf(ifp, "%s: unable to reset hardware; hal status %u\n", 2735 __func__, status); 2736 sc->sc_diversity = ath_hal_getdiversity(ah); 2737 | 2451 * Enable MIB interrupts when there are hardware phy counters. 2452 * Note we only do this (at the moment) for station mode. 2453 */ 2454 if (sc->sc_needmib && ic->ic_opmode == IEEE80211_M_STA) 2455 sc->sc_imask |= HAL_INT_MIB; 2456 2457 /* 2458 * XXX add capability for this. --- 301 unchanged lines hidden (view full) --- 2760 ath_update_chainmasks(sc, ic->ic_curchan); 2761 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, 2762 sc->sc_cur_rxchainmask); 2763 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, &status)) 2764 if_printf(ifp, "%s: unable to reset hardware; hal status %u\n", 2765 __func__, status); 2766 sc->sc_diversity = ath_hal_getdiversity(ah); 2767 |
2768 ATH_RX_LOCK(sc); 2769 sc->sc_rx_stopped = 1; 2770 sc->sc_rx_resetted = 1; 2771 ATH_RX_UNLOCK(sc); 2772 |
|
2738 /* Let DFS at it in case it's a DFS channel */ 2739 ath_dfs_radar_enable(sc, ic->ic_curchan); 2740 2741 /* Let spectral at in case spectral is enabled */ 2742 ath_spectral_enable(sc, ic->ic_curchan); 2743 2744 /* 2745 * Let bluetooth coexistence at in case it's needed for this channel --- 2582 unchanged lines hidden (view full) --- 5328 ATH_PCU_UNLOCK_ASSERT(sc); 5329 ATH_UNLOCK_ASSERT(sc); 5330 5331 /* (Try to) stop TX/RX from occuring */ 5332 taskqueue_block(sc->sc_tq); 5333 5334 ATH_PCU_LOCK(sc); 5335 | 2773 /* Let DFS at it in case it's a DFS channel */ 2774 ath_dfs_radar_enable(sc, ic->ic_curchan); 2775 2776 /* Let spectral at in case spectral is enabled */ 2777 ath_spectral_enable(sc, ic->ic_curchan); 2778 2779 /* 2780 * Let bluetooth coexistence at in case it's needed for this channel --- 2582 unchanged lines hidden (view full) --- 5363 ATH_PCU_UNLOCK_ASSERT(sc); 5364 ATH_UNLOCK_ASSERT(sc); 5365 5366 /* (Try to) stop TX/RX from occuring */ 5367 taskqueue_block(sc->sc_tq); 5368 5369 ATH_PCU_LOCK(sc); 5370 |
5371 /* Disable interrupts */ 5372 ath_hal_intrset(ah, 0); 5373 |
|
5336 /* Stop new RX/TX/interrupt completion */ 5337 if (ath_reset_grablock(sc, 1) == 0) { 5338 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", 5339 __func__); 5340 } 5341 | 5374 /* Stop new RX/TX/interrupt completion */ 5375 if (ath_reset_grablock(sc, 1) == 0) { 5376 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", 5377 __func__); 5378 } 5379 |
5342 ath_hal_intrset(ah, 0); 5343 | |
5344 /* Stop pending RX/TX completion */ 5345 ath_txrx_stop_locked(sc); 5346 5347 ATH_PCU_UNLOCK(sc); 5348 5349 DPRINTF(sc, ATH_DEBUG_RESET, "%s: %u (%u MHz, flags 0x%x)\n", 5350 __func__, ieee80211_chan2ieee(ic, chan), 5351 chan->ic_freq, chan->ic_flags); --- 27 unchanged lines hidden (view full) --- 5379 "channel %u (%u MHz, flags 0x%x), hal status %u\n", 5380 __func__, ieee80211_chan2ieee(ic, chan), 5381 chan->ic_freq, chan->ic_flags, status); 5382 ret = EIO; 5383 goto finish; 5384 } 5385 sc->sc_diversity = ath_hal_getdiversity(ah); 5386 | 5380 /* Stop pending RX/TX completion */ 5381 ath_txrx_stop_locked(sc); 5382 5383 ATH_PCU_UNLOCK(sc); 5384 5385 DPRINTF(sc, ATH_DEBUG_RESET, "%s: %u (%u MHz, flags 0x%x)\n", 5386 __func__, ieee80211_chan2ieee(ic, chan), 5387 chan->ic_freq, chan->ic_flags); --- 27 unchanged lines hidden (view full) --- 5415 "channel %u (%u MHz, flags 0x%x), hal status %u\n", 5416 __func__, ieee80211_chan2ieee(ic, chan), 5417 chan->ic_freq, chan->ic_flags, status); 5418 ret = EIO; 5419 goto finish; 5420 } 5421 sc->sc_diversity = ath_hal_getdiversity(ah); 5422 |
5423 ATH_RX_LOCK(sc); 5424 sc->sc_rx_stopped = 1; 5425 sc->sc_rx_resetted = 1; 5426 ATH_RX_UNLOCK(sc); 5427 |
|
5387 /* Let DFS at it in case it's a DFS channel */ 5388 ath_dfs_radar_enable(sc, chan); 5389 5390 /* Let spectral at in case spectral is enabled */ 5391 ath_spectral_enable(sc, chan); 5392 5393 /* 5394 * Let bluetooth coexistence at in case it's needed for this --- 1671 unchanged lines hidden --- | 5428 /* Let DFS at it in case it's a DFS channel */ 5429 ath_dfs_radar_enable(sc, chan); 5430 5431 /* Let spectral at in case spectral is enabled */ 5432 ath_spectral_enable(sc, chan); 5433 5434 /* 5435 * Let bluetooth coexistence at in case it's needed for this --- 1671 unchanged lines hidden --- |