wlan - Update wlan from Adrian / FreeBSD
[dragonfly.git] / sys / netproto / 802_11 / ieee80211_ratectl.h
CommitLineData
4028af95
RP
1/*-
2 * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org>
3 * All rights reserved.
4 *
b9334f94
SZ
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
b9334f94
SZ
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
4028af95
RP
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
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 *
085ff963 25 * $FreeBSD$
b9334f94
SZ
26 */
27
4028af95 28enum ieee80211_ratealgs {
16878352 29 IEEE80211_RATECTL_AMRR = 0,
4028af95
RP
30 IEEE80211_RATECTL_RSSADAPT = 1,
31 IEEE80211_RATECTL_ONOE = 2,
32 IEEE80211_RATECTL_SAMPLE = 3,
16878352 33 IEEE80211_RATECTL_NONE = 4,
4028af95 34 IEEE80211_RATECTL_MAX
b9334f94
SZ
35};
36
085ff963
MD
37#define IEEE80211_RATECTL_TX_SUCCESS 1
38#define IEEE80211_RATECTL_TX_FAILURE 0
7fdf07d2 39
b9334f94 40struct ieee80211_ratectl {
4028af95
RP
41 const char *ir_name;
42 int (*ir_attach)(const struct ieee80211vap *);
43 void (*ir_detach)(const struct ieee80211vap *);
44 void (*ir_init)(struct ieee80211vap *);
45 void (*ir_deinit)(struct ieee80211vap *);
46 void (*ir_node_init)(struct ieee80211_node *);
47 void (*ir_node_deinit)(struct ieee80211_node *);
48 int (*ir_rate)(struct ieee80211_node *, void *, uint32_t);
49 void (*ir_tx_complete)(const struct ieee80211vap *,
50 const struct ieee80211_node *, int,
51 void *, void *);
52 void (*ir_tx_update)(const struct ieee80211vap *,
53 const struct ieee80211_node *,
54 void *, void *, void *);
55 void (*ir_setinterval)(const struct ieee80211vap *, int);
b9334f94
SZ
56};
57
4028af95
RP
58void ieee80211_ratectl_register(int, const struct ieee80211_ratectl *);
59void ieee80211_ratectl_unregister(int);
16878352 60void ieee80211_ratectl_init(struct ieee80211vap *);
4028af95
RP
61void ieee80211_ratectl_set(struct ieee80211vap *, int);
62
63MALLOC_DECLARE(M_80211_RATECTL);
64
db11cb20 65static __inline void
4028af95
RP
66ieee80211_ratectl_deinit(struct ieee80211vap *vap)
67{
68 vap->iv_rate->ir_deinit(vap);
69}
70
db11cb20 71static __inline void
4028af95
RP
72ieee80211_ratectl_node_init(struct ieee80211_node *ni)
73{
74 const struct ieee80211vap *vap = ni->ni_vap;
75
4028af95
RP
76 vap->iv_rate->ir_node_init(ni);
77}
78
db11cb20 79static __inline void
4028af95
RP
80ieee80211_ratectl_node_deinit(struct ieee80211_node *ni)
81{
82 const struct ieee80211vap *vap = ni->ni_vap;
83
4028af95
RP
84 vap->iv_rate->ir_node_deinit(ni);
85}
86
db11cb20 87static __inline int
4028af95
RP
88ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg)
89{
90 const struct ieee80211vap *vap = ni->ni_vap;
91
4028af95
RP
92 return vap->iv_rate->ir_rate(ni, arg, iarg);
93}
94
db11cb20 95static __inline void
4028af95
RP
96ieee80211_ratectl_tx_complete(const struct ieee80211vap *vap,
97 const struct ieee80211_node *ni, int status, void *arg1, void *arg2)
98{
4028af95
RP
99 vap->iv_rate->ir_tx_complete(vap, ni, status, arg1, arg2);
100}
101
db11cb20 102static __inline void
4028af95
RP
103ieee80211_ratectl_tx_update(const struct ieee80211vap *vap,
104 const struct ieee80211_node *ni, void *arg1, void *arg2, void *arg3)
105{
106 if (vap->iv_rate->ir_tx_update == NULL)
107 return;
4028af95
RP
108 vap->iv_rate->ir_tx_update(vap, ni, arg1, arg2, arg3);
109}
110
db11cb20 111static __inline void
4028af95
RP
112ieee80211_ratectl_setinterval(const struct ieee80211vap *vap, int msecs)
113{
114 if (vap->iv_rate->ir_setinterval == NULL)
115 return;
116 vap->iv_rate->ir_setinterval(vap, msecs);
117}