ieee80211_power.h revision 184288
1238104Sdes/*-
2238104Sdes * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
3238104Sdes * All rights reserved.
4238104Sdes *
5238104Sdes * Redistribution and use in source and binary forms, with or without
6238104Sdes * modification, are permitted provided that the following conditions
7238104Sdes * are met:
8238104Sdes * 1. Redistributions of source code must retain the above copyright
9238104Sdes *    notice, this list of conditions and the following disclaimer.
10238104Sdes * 2. Redistributions in binary form must reproduce the above copyright
11238104Sdes *    notice, this list of conditions and the following disclaimer in the
12238104Sdes *    documentation and/or other materials provided with the distribution.
13238104Sdes *
14238104Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15238104Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16238104Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17238104Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18238104Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19238104Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20238104Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21238104Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22238104Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23238104Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24238104Sdes *
25238104Sdes * $FreeBSD: head/sys/net80211/ieee80211_power.h 184288 2008-10-26 01:04:46Z sam $
26238104Sdes */
27238104Sdes#ifndef _NET80211_IEEE80211_POWER_H_
28238104Sdes#define _NET80211_IEEE80211_POWER_H_
29238104Sdes
30238104Sdesstruct ieee80211com;
31238104Sdesstruct ieee80211vap;
32238104Sdesstruct ieee80211_node;
33238104Sdesstruct mbuf;
34238104Sdes
35238104Sdes/*
36238104Sdes * Power save packet queues.  There are two queues, one
37238104Sdes * for frames coming from the net80211 layer and the other
38238104Sdes * for frames that come from the driver. Frames from the
39238104Sdes * driver are expected to have M_ENCAP marked to indicate
40238104Sdes * they have already been encapsulated and are treated as
41238104Sdes * higher priority: they are sent first when flushing the
42238104Sdes * queue on a power save state change or in response to a
43238104Sdes * ps-poll frame.
44238104Sdes *
45238104Sdes * Note that frames sent from the high priority queue are
46238104Sdes * fed directly to the driver without going through
47238104Sdes * ieee80211_start again; drivers that send up encap'd
48238104Sdes * frames are required to handle them when they come back.
49238104Sdes */
50238104Sdesstruct ieee80211_psq {
51238104Sdes	ieee80211_psq_lock_t psq_lock;
52238104Sdes	int	psq_len;
53238104Sdes	int	psq_maxlen;
54238104Sdes	int	psq_drops;
55238104Sdes	struct ieee80211_psq_head {
56238104Sdes		struct mbuf *head;
57238104Sdes		struct mbuf *tail;
58238104Sdes		int len;
59238104Sdes	} psq_head[2];			/* 2 priorities */
60238104Sdes};
61238104Sdes
62238104Sdesvoid	ieee80211_psq_init(struct ieee80211_psq *, const char *);
63238104Sdesvoid	ieee80211_psq_cleanup(struct ieee80211_psq *);
64238104Sdes
65238104Sdesvoid	ieee80211_power_attach(struct ieee80211com *);
66238104Sdesvoid	ieee80211_power_detach(struct ieee80211com *);
67238104Sdesvoid	ieee80211_power_vattach(struct ieee80211vap *);
68238104Sdesvoid	ieee80211_power_vdetach(struct ieee80211vap *);
69238104Sdesvoid	ieee80211_power_latevattach(struct ieee80211vap *);
70238104Sdes
71238104Sdesstruct mbuf *ieee80211_node_psq_dequeue(struct ieee80211_node *ni, int *qlen);
72238104Sdesint	ieee80211_node_psq_drain(struct ieee80211_node *);
73238104Sdesint	ieee80211_node_psq_age(struct ieee80211_node *);
74238104Sdesint	ieee80211_pwrsave(struct ieee80211_node *, struct mbuf *);
75238104Sdesvoid	ieee80211_node_pwrsave(struct ieee80211_node *, int enable);
76238104Sdesvoid	ieee80211_sta_pwrsave(struct ieee80211vap *, int enable);
77238104Sdes
78238104Sdesvoid	ieee80211_power_poll(struct ieee80211com *);
79238104Sdes#endif /* _NET80211_IEEE80211_POWER_H_ */
80238104Sdes