Deleted Added
full compact
if_ath.c (265115) if_ath.c (265205)
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 265115 2014-04-30 02:19:41Z adrian $");
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 265205 2014-05-02 00:48:09Z 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

--- 260 unchanged lines hidden (view full) ---

300 line,
301 power_state,
302 sc->sc_powersave_refcnt);
303
304 if (sc->sc_powersave_refcnt == 0 &&
305 power_state != sc->sc_cur_powerstate) {
306 sc->sc_cur_powerstate = power_state;
307 ath_hal_setpower(sc->sc_ah, power_state);
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

--- 260 unchanged lines hidden (view full) ---

300 line,
301 power_state,
302 sc->sc_powersave_refcnt);
303
304 if (sc->sc_powersave_refcnt == 0 &&
305 power_state != sc->sc_cur_powerstate) {
306 sc->sc_cur_powerstate = power_state;
307 ath_hal_setpower(sc->sc_ah, power_state);
308
309 /*
310 * If the NIC is force-awake, then set the
311 * self-gen frame state appropriately.
312 *
313 * If the nic is in network sleep or full-sleep,
314 * we let the above call leave the self-gen
315 * state as "sleep".
316 */
317 if (sc->sc_cur_powerstate == HAL_PM_AWAKE &&
318 sc->sc_target_selfgen_state != HAL_PM_AWAKE) {
319 ath_hal_setselfgenpower(sc->sc_ah,
320 sc->sc_target_selfgen_state);
321 }
308 }
309}
310
311/*
322 }
323}
324
325/*
326 * Set the current self-generated frames state.
327 *
328 * This is separate from the target power mode. The chip may be
329 * awake but the desired state is "sleep", so frames sent to the
330 * destination has PWRMGT=1 in the 802.11 header. The NIC also
331 * needs to know to set PWRMGT=1 in self-generated frames.
332 */
333void
334_ath_power_set_selfgen(struct ath_softc *sc, int power_state, const char *file, int line)
335{
336
337 ATH_LOCK_ASSERT(sc);
338
339 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) state=%d, refcnt=%d\n",
340 __func__,
341 file,
342 line,
343 power_state,
344 sc->sc_target_selfgen_state);
345
346 sc->sc_target_selfgen_state = power_state;
347
348 /*
349 * If the NIC is force-awake, then set the power state.
350 * Network-state and full-sleep will already transition it to
351 * mark self-gen frames as sleeping - and we can't
352 * guarantee the NIC is awake to program the self-gen frame
353 * setting anyway.
354 */
355 if (sc->sc_cur_powerstate == HAL_PM_AWAKE) {
356 ath_hal_setselfgenpower(sc->sc_ah, power_state);
357 }
358}
359
360/*
312 * Set the hardware power mode and take a reference.
313 *
314 * This doesn't update the target power mode in the driver;
315 * it just updates the hardware power state.
316 *
317 * XXX it should only ever force the hardware awake; it should
318 * never be called to set it asleep.
319 */

--- 9 unchanged lines hidden (view full) ---

329 power_state,
330 sc->sc_powersave_refcnt);
331
332 sc->sc_powersave_refcnt++;
333
334 if (power_state != sc->sc_cur_powerstate) {
335 ath_hal_setpower(sc->sc_ah, power_state);
336 sc->sc_cur_powerstate = power_state;
361 * Set the hardware power mode and take a reference.
362 *
363 * This doesn't update the target power mode in the driver;
364 * it just updates the hardware power state.
365 *
366 * XXX it should only ever force the hardware awake; it should
367 * never be called to set it asleep.
368 */

--- 9 unchanged lines hidden (view full) ---

378 power_state,
379 sc->sc_powersave_refcnt);
380
381 sc->sc_powersave_refcnt++;
382
383 if (power_state != sc->sc_cur_powerstate) {
384 ath_hal_setpower(sc->sc_ah, power_state);
385 sc->sc_cur_powerstate = power_state;
386
387 /*
388 * Adjust the self-gen powerstate if appropriate.
389 */
390 if (sc->sc_cur_powerstate == HAL_PM_AWAKE &&
391 sc->sc_target_selfgen_state != HAL_PM_AWAKE) {
392 ath_hal_setselfgenpower(sc->sc_ah,
393 sc->sc_target_selfgen_state);
394 }
395
337 }
338}
339
340/*
341 * Restore the power save mode to what it once was.
342 *
343 * This will decrement the reference counter and once it hits
344 * zero, it'll restore the powersave state.

--- 16 unchanged lines hidden (view full) ---

361 else
362 sc->sc_powersave_refcnt--;
363
364 if (sc->sc_powersave_refcnt == 0 &&
365 sc->sc_target_powerstate != sc->sc_cur_powerstate) {
366 sc->sc_cur_powerstate = sc->sc_target_powerstate;
367 ath_hal_setpower(sc->sc_ah, sc->sc_target_powerstate);
368 }
396 }
397}
398
399/*
400 * Restore the power save mode to what it once was.
401 *
402 * This will decrement the reference counter and once it hits
403 * zero, it'll restore the powersave state.

--- 16 unchanged lines hidden (view full) ---

420 else
421 sc->sc_powersave_refcnt--;
422
423 if (sc->sc_powersave_refcnt == 0 &&
424 sc->sc_target_powerstate != sc->sc_cur_powerstate) {
425 sc->sc_cur_powerstate = sc->sc_target_powerstate;
426 ath_hal_setpower(sc->sc_ah, sc->sc_target_powerstate);
427 }
428
429 /*
430 * Adjust the self-gen powerstate if appropriate.
431 */
432 if (sc->sc_cur_powerstate == HAL_PM_AWAKE &&
433 sc->sc_target_selfgen_state != HAL_PM_AWAKE) {
434 ath_hal_setselfgenpower(sc->sc_ah,
435 sc->sc_target_selfgen_state);
436 }
437
369}
370
371#define HAL_MODE_HT20 (HAL_MODE_11NG_HT20 | HAL_MODE_11NA_HT20)
372#define HAL_MODE_HT40 \
373 (HAL_MODE_11NG_HT40PLUS | HAL_MODE_11NG_HT40MINUS | \
374 HAL_MODE_11NA_HT40PLUS | HAL_MODE_11NA_HT40MINUS)
375int
376ath_attach(u_int16_t devid, struct ath_softc *sc)

--- 1352 unchanged lines hidden (view full) ---

1729 */
1730 ath_update_chainmasks(sc,
1731 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan);
1732 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
1733 sc->sc_cur_rxchainmask);
1734
1735 /* Ensure we set the current power state to on */
1736 ATH_LOCK(sc);
438}
439
440#define HAL_MODE_HT20 (HAL_MODE_11NG_HT20 | HAL_MODE_11NA_HT20)
441#define HAL_MODE_HT40 \
442 (HAL_MODE_11NG_HT40PLUS | HAL_MODE_11NG_HT40MINUS | \
443 HAL_MODE_11NA_HT40PLUS | HAL_MODE_11NA_HT40MINUS)
444int
445ath_attach(u_int16_t devid, struct ath_softc *sc)

--- 1352 unchanged lines hidden (view full) ---

1798 */
1799 ath_update_chainmasks(sc,
1800 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan);
1801 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask,
1802 sc->sc_cur_rxchainmask);
1803
1804 /* Ensure we set the current power state to on */
1805 ATH_LOCK(sc);
1806 ath_power_setselfgen(sc, HAL_PM_AWAKE);
1737 ath_power_set_power_state(sc, HAL_PM_AWAKE);
1738 ath_power_setpower(sc, HAL_PM_AWAKE);
1739 ATH_UNLOCK(sc);
1740
1741 ath_hal_reset(ah, sc->sc_opmode,
1742 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan,
1743 AH_FALSE, &status);
1744 ath_reset_keycache(sc);

--- 502 unchanged lines hidden (view full) ---

2247
2248 DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n",
2249 __func__, ifp->if_flags);
2250
2251 ATH_LOCK(sc);
2252 /*
2253 * Force the sleep state awake.
2254 */
1807 ath_power_set_power_state(sc, HAL_PM_AWAKE);
1808 ath_power_setpower(sc, HAL_PM_AWAKE);
1809 ATH_UNLOCK(sc);
1810
1811 ath_hal_reset(ah, sc->sc_opmode,
1812 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan,
1813 AH_FALSE, &status);
1814 ath_reset_keycache(sc);

--- 502 unchanged lines hidden (view full) ---

2317
2318 DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags 0x%x\n",
2319 __func__, ifp->if_flags);
2320
2321 ATH_LOCK(sc);
2322 /*
2323 * Force the sleep state awake.
2324 */
2325 ath_power_setselfgen(sc, HAL_PM_AWAKE);
2255 ath_power_set_power_state(sc, HAL_PM_AWAKE);
2256 ath_power_setpower(sc, HAL_PM_AWAKE);
2257
2258 /*
2259 * Stop anything previously setup. This is safe
2260 * whether this is the first time through or not.
2261 */
2262 ath_stop_locked(ifp);

--- 3388 unchanged lines hidden (view full) ---

5651 * which indicate that it (newstate) may end up dropping the
5652 * lock. This and the subsequent lock assert check after newstate
5653 * are an attempt to catch these and figure out how/why.
5654 */
5655 IEEE80211_LOCK_ASSERT(ic);
5656
5657 /* Before we touch the hardware - wake it up */
5658 ATH_LOCK(sc);
2326 ath_power_set_power_state(sc, HAL_PM_AWAKE);
2327 ath_power_setpower(sc, HAL_PM_AWAKE);
2328
2329 /*
2330 * Stop anything previously setup. This is safe
2331 * whether this is the first time through or not.
2332 */
2333 ath_stop_locked(ifp);

--- 3388 unchanged lines hidden (view full) ---

5722 * which indicate that it (newstate) may end up dropping the
5723 * lock. This and the subsequent lock assert check after newstate
5724 * are an attempt to catch these and figure out how/why.
5725 */
5726 IEEE80211_LOCK_ASSERT(ic);
5727
5728 /* Before we touch the hardware - wake it up */
5729 ATH_LOCK(sc);
5730 /*
5731 * If the NIC is in anything other than SLEEP state,
5732 * we need to ensure that self-generated frames are
5733 * set for PWRMGT=0. Otherwise we may end up with
5734 * strange situations.
5735 *
5736 * XXX TODO: is this actually the case? :-)
5737 */
5738 if (nstate != IEEE80211_S_SLEEP)
5739 ath_power_setselfgen(sc, HAL_PM_AWAKE);
5740
5741 /*
5742 * Now, wake the thing up.
5743 */
5659 ath_power_set_power_state(sc, HAL_PM_AWAKE);
5660 ATH_UNLOCK(sc);
5661
5662 if (ostate == IEEE80211_S_CSA && nstate == IEEE80211_S_RUN)
5663 csa_run_transition = 1;
5664
5665 callout_drain(&sc->sc_cal_ch);
5666 ath_hal_setledstate(ah, leds[nstate]); /* set LED */
5667
5668 if (nstate == IEEE80211_S_SCAN) {
5669 /*
5670 * Scanning: turn off beacon miss and don't beacon.
5671 * Mark beacon state so when we reach RUN state we'll
5672 * [re]setup beacons. Unblock the task q thread so
5673 * deferred interrupt processing is done.
5674 */
5675
5676 /* Ensure we stay awake during scan */
5677 ATH_LOCK(sc);
5744 ath_power_set_power_state(sc, HAL_PM_AWAKE);
5745 ATH_UNLOCK(sc);
5746
5747 if (ostate == IEEE80211_S_CSA && nstate == IEEE80211_S_RUN)
5748 csa_run_transition = 1;
5749
5750 callout_drain(&sc->sc_cal_ch);
5751 ath_hal_setledstate(ah, leds[nstate]); /* set LED */
5752
5753 if (nstate == IEEE80211_S_SCAN) {
5754 /*
5755 * Scanning: turn off beacon miss and don't beacon.
5756 * Mark beacon state so when we reach RUN state we'll
5757 * [re]setup beacons. Unblock the task q thread so
5758 * deferred interrupt processing is done.
5759 */
5760
5761 /* Ensure we stay awake during scan */
5762 ATH_LOCK(sc);
5763 ath_power_setselfgen(sc, HAL_PM_AWAKE);
5678 ath_power_setpower(sc, HAL_PM_AWAKE);
5679 ATH_UNLOCK(sc);
5680
5681 ath_hal_intrset(ah,
5682 sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS));
5683 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
5684 sc->sc_beacons = 0;
5685 taskqueue_unblock(sc->sc_tq);

--- 159 unchanged lines hidden (view full) ---

5845 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER;
5846 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER;
5847 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER;
5848
5849 /*
5850 * Force awake for RUN mode.
5851 */
5852 ATH_LOCK(sc);
5764 ath_power_setpower(sc, HAL_PM_AWAKE);
5765 ATH_UNLOCK(sc);
5766
5767 ath_hal_intrset(ah,
5768 sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS));
5769 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS);
5770 sc->sc_beacons = 0;
5771 taskqueue_unblock(sc->sc_tq);

--- 159 unchanged lines hidden (view full) ---

5931 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER;
5932 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER;
5933 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER;
5934
5935 /*
5936 * Force awake for RUN mode.
5937 */
5938 ATH_LOCK(sc);
5939 ath_power_setselfgen(sc, HAL_PM_AWAKE);
5853 ath_power_setpower(sc, HAL_PM_AWAKE);
5854 ATH_UNLOCK(sc);
5855
5856 /*
5857 * Finally, start any timers and the task q thread
5858 * (in case we didn't go through SCAN state).
5859 */
5860 if (ath_longcalinterval != 0) {

--- 25 unchanged lines hidden (view full) ---

5886#endif
5887 } else if (nstate == IEEE80211_S_SLEEP) {
5888 /* We're going to sleep, so transition appropriately */
5889 /* For now, only do this if we're a single STA vap */
5890 if (sc->sc_nvaps == 1 &&
5891 vap->iv_opmode == IEEE80211_M_STA) {
5892 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: syncbeacon=%d\n", __func__, sc->sc_syncbeacon);
5893 ATH_LOCK(sc);
5940 ath_power_setpower(sc, HAL_PM_AWAKE);
5941 ATH_UNLOCK(sc);
5942
5943 /*
5944 * Finally, start any timers and the task q thread
5945 * (in case we didn't go through SCAN state).
5946 */
5947 if (ath_longcalinterval != 0) {

--- 25 unchanged lines hidden (view full) ---

5973#endif
5974 } else if (nstate == IEEE80211_S_SLEEP) {
5975 /* We're going to sleep, so transition appropriately */
5976 /* For now, only do this if we're a single STA vap */
5977 if (sc->sc_nvaps == 1 &&
5978 vap->iv_opmode == IEEE80211_M_STA) {
5979 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: syncbeacon=%d\n", __func__, sc->sc_syncbeacon);
5980 ATH_LOCK(sc);
5894 if (sc->sc_syncbeacon == 0) {
5895 ath_power_setpower(sc, HAL_PM_NETWORK_SLEEP);
5896 }
5897 /*
5898 * Always at least set the self-generated
5981 /*
5982 * Always at least set the self-generated
5899 * power bits appropriately.
5983 * frame config to set PWRMGT=1.
5984 */
5985 ath_power_setselfgen(sc, HAL_PM_NETWORK_SLEEP);
5986
5987 /*
5988 * If we're not syncing beacons, transition
5989 * to NETWORK_SLEEP.
5900 *
5990 *
5901 * XXX TODO: this should be an ath_power_*() call
5902 * which also tracks whether we're doing self-gen
5903 * frames or not, and allows the hardware to be
5904 * awake _but_ self-gen frames to have PWRMGT=1.
5991 * We stay awake if syncbeacon > 0 in case
5992 * we need to listen for some beacons otherwise
5993 * our beacon timer config may be wrong.
5905 */
5994 */
5906 ath_hal_setselfgenpower(sc->sc_ah,
5907 HAL_PM_NETWORK_SLEEP);
5995 if (sc->sc_syncbeacon == 0) {
5996 ath_power_setpower(sc, HAL_PM_NETWORK_SLEEP);
5997 }
5908 ATH_UNLOCK(sc);
5909 }
5910 }
5911bad:
5912 ieee80211_free_node(ni);
5913
5914 /*
5915 * Restore the power state - either to what it was, or

--- 1036 unchanged lines hidden ---
5998 ATH_UNLOCK(sc);
5999 }
6000 }
6001bad:
6002 ieee80211_free_node(ni);
6003
6004 /*
6005 * Restore the power state - either to what it was, or

--- 1036 unchanged lines hidden ---