Deleted Added
full compact
ieee80211_power.c (257176) ieee80211_power.c (264855)
1/*-
2 * Copyright (c) 2002-2008 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

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

19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2008 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

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

19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_power.c 257176 2013-10-26 17:58:36Z glebius $");
27__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_power.c 264855 2014-04-24 01:39:53Z adrian $");
28
29/*
30 * IEEE 802.11 power save support.
31 */
32#include "opt_wlan.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>

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

550 */
551 if (ni->ni_psq.psq_len != 0)
552 pwrsave_flushq(ni);
553 } else {
554 ni->ni_flags |= IEEE80211_NODE_PWR_MGT;
555 ieee80211_send_nulldata(ieee80211_ref_node(ni));
556 }
557}
28
29/*
30 * IEEE 802.11 power save support.
31 */
32#include "opt_wlan.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>

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

550 */
551 if (ni->ni_psq.psq_len != 0)
552 pwrsave_flushq(ni);
553 } else {
554 ni->ni_flags |= IEEE80211_NODE_PWR_MGT;
555 ieee80211_send_nulldata(ieee80211_ref_node(ni));
556 }
557}
558
559/*
560 * Handle being notified that we have data available for us in a TIM/ATIM.
561 *
562 * This may schedule a transition from _SLEEP -> _RUN if it's appropriate.
563 */
564void
565ieee80211_sta_tim_notify(struct ieee80211vap *vap, int set)
566{
567 /*
568 * Schedule the driver state change. It'll happen at some point soon.
569 * Since the hardware shouldn't know that we're running just yet
570 * (and thus tell the peer that we're awake before we actually wake
571 * up said hardware), we leave the actual node state transition
572 * up to the transition to RUN.
573 *
574 * XXX TODO: verify that the transition to RUN will wake up the
575 * BSS node!
576 */
577 IEEE80211_DPRINTF(vap, IEEE80211_MSG_POWER, "%s: TIM=%d\n", __func__, set);
578 IEEE80211_LOCK(vap->iv_ic);
579 if (set == 1 && vap->iv_state == IEEE80211_S_SLEEP) {
580 ieee80211_new_state_locked(vap, IEEE80211_S_RUN, 0);
581 }
582 IEEE80211_UNLOCK(vap->iv_ic);
583}
584
585/*
586 * Timer check on whether the VAP has had any transmit activity.
587 *
588 * This may schedule a transition from _RUN -> _SLEEP if it's appropriate.
589 */
590void
591ieee80211_sta_ps_timer_check(struct ieee80211vap *vap)
592{
593 struct ieee80211com *ic = vap->iv_ic;
594
595 /* XXX lock assert */
596
597 /* For no, only do this in STA mode */
598 if (! (vap->iv_caps & IEEE80211_C_SWSLEEP))
599 goto out;
600
601 if (vap->iv_opmode != IEEE80211_M_STA)
602 goto out;
603
604 /* If we're not at run state, bail */
605 if (vap->iv_state != IEEE80211_S_RUN)
606 goto out;
607
608 IEEE80211_DPRINTF(vap, IEEE80211_MSG_POWER,
609 "%s: lastdata=%llu, ticks=%llu\n",
610 __func__, (unsigned long long) ic->ic_lastdata,
611 (unsigned long long) ticks);
612
613 /* If powersave is disabled on the VAP, don't bother */
614 if (! (vap->iv_flags & IEEE80211_F_PMGTON))
615 goto out;
616
617 /* If we've done any data within our idle interval, bail */
618 /* XXX hard-coded to one second for now, ew! */
619 if (time_after(ic->ic_lastdata + 500, ticks))
620 goto out;
621
622 /*
623 * Signify we're going into power save and transition the
624 * node to powersave.
625 */
626 if ((vap->iv_bss->ni_flags & IEEE80211_NODE_PWR_MGT) == 0)
627 vap->iv_sta_ps(vap, 1);
628
629 /*
630 * XXX The driver has to handle the fact that we're going
631 * to sleep but frames may still be transmitted;
632 * hopefully it and/or us will do the right thing and mark any
633 * transmitted frames with PWRMGT set to 1.
634 */
635 ieee80211_new_state_locked(vap, IEEE80211_S_SLEEP, 0);
636
637 IEEE80211_DPRINTF(vap, IEEE80211_MSG_POWER,
638 "%s: time delta=%d msec\n", __func__,
639 (int) ticks_to_msecs(ticks - ic->ic_lastdata));
640
641out:
642 return;
643}