1170530Ssam/*-
2178354Ssam * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3170530Ssam * All rights reserved.
4170530Ssam *
5170530Ssam * Redistribution and use in source and binary forms, with or without
6170530Ssam * modification, are permitted provided that the following conditions
7170530Ssam * are met:
8170530Ssam * 1. Redistributions of source code must retain the above copyright
9170530Ssam *    notice, this list of conditions and the following disclaimer.
10170530Ssam * 2. Redistributions in binary form must reproduce the above copyright
11170530Ssam *    notice, this list of conditions and the following disclaimer in the
12170530Ssam *    documentation and/or other materials provided with the distribution.
13170530Ssam *
14170530Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15170530Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16170530Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17170530Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18170530Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19170530Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20170530Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21170530Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22170530Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23170530Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24170530Ssam *
25170530Ssam * $FreeBSD$
26170530Ssam */
27170530Ssam#ifndef _NET80211_IEEE80211_POWER_H_
28170530Ssam#define _NET80211_IEEE80211_POWER_H_
29170530Ssam
30170530Ssamstruct ieee80211com;
31184288Ssamstruct ieee80211vap;
32184288Ssamstruct ieee80211_node;
33184288Ssamstruct mbuf;
34170530Ssam
35184288Ssam/*
36184288Ssam * Power save packet queues.  There are two queues, one
37184288Ssam * for frames coming from the net80211 layer and the other
38184288Ssam * for frames that come from the driver. Frames from the
39184288Ssam * driver are expected to have M_ENCAP marked to indicate
40184288Ssam * they have already been encapsulated and are treated as
41184288Ssam * higher priority: they are sent first when flushing the
42184288Ssam * queue on a power save state change or in response to a
43184288Ssam * ps-poll frame.
44184288Ssam *
45184288Ssam * Note that frames sent from the high priority queue are
46184288Ssam * fed directly to the driver without going through
47184288Ssam * ieee80211_start again; drivers that send up encap'd
48184288Ssam * frames are required to handle them when they come back.
49184288Ssam */
50184288Ssamstruct ieee80211_psq {
51184288Ssam	ieee80211_psq_lock_t psq_lock;
52184288Ssam	int	psq_len;
53184288Ssam	int	psq_maxlen;
54184288Ssam	int	psq_drops;
55184288Ssam	struct ieee80211_psq_head {
56184288Ssam		struct mbuf *head;
57184288Ssam		struct mbuf *tail;
58184288Ssam		int len;
59184288Ssam	} psq_head[2];			/* 2 priorities */
60184288Ssam};
61184288Ssam
62184288Ssamvoid	ieee80211_psq_init(struct ieee80211_psq *, const char *);
63184288Ssamvoid	ieee80211_psq_cleanup(struct ieee80211_psq *);
64184288Ssam
65170530Ssamvoid	ieee80211_power_attach(struct ieee80211com *);
66170530Ssamvoid	ieee80211_power_detach(struct ieee80211com *);
67178354Ssamvoid	ieee80211_power_vattach(struct ieee80211vap *);
68178354Ssamvoid	ieee80211_power_vdetach(struct ieee80211vap *);
69178354Ssamvoid	ieee80211_power_latevattach(struct ieee80211vap *);
70170530Ssam
71184288Ssamstruct mbuf *ieee80211_node_psq_dequeue(struct ieee80211_node *ni, int *qlen);
72184288Ssamint	ieee80211_node_psq_drain(struct ieee80211_node *);
73184288Ssamint	ieee80211_node_psq_age(struct ieee80211_node *);
74241138Sadrian
75241138Sadrian/*
76241138Sadrian * Don't call these directly from the stack; they are vap methods
77241138Sadrian * that should be overridden.
78241138Sadrian */
79184288Ssamint	ieee80211_pwrsave(struct ieee80211_node *, struct mbuf *);
80170530Ssamvoid	ieee80211_node_pwrsave(struct ieee80211_node *, int enable);
81178354Ssamvoid	ieee80211_sta_pwrsave(struct ieee80211vap *, int enable);
82264855Sadrianvoid	ieee80211_sta_tim_notify(struct ieee80211vap *vap, int set);
83264855Sadrianvoid	ieee80211_sta_ps_timer_check(struct ieee80211vap *vap);
84170530Ssam
85264855Sadrian/* XXX what's this? */
86170530Ssamvoid	ieee80211_power_poll(struct ieee80211com *);
87170530Ssam#endif /* _NET80211_IEEE80211_POWER_H_ */
88