Sync our ieee80211*(9) manual pages with FreeBSD.
[dragonfly.git] / share / man / man9 / ieee80211_amrr.9
1 .\"
2 .\" Copyright (c) 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
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
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 AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/share/man/man9/ieee80211_amrr.9,v 1.2 2009/09/18 00:33:47 brueffer Exp $
27 .\"
28 .Dd April 28, 2010
29 .Dt IEEE8021_AMRR 9
30 .Os
31 .Sh NAME
32 .Nm ieee80211_amrr
33 .Nd 802.11 network driver transmit rate control support
34 .Sh SYNOPSIS
35 .In net80211/ieee80211_amrr.h
36 .Ft void
37 .Fo ieee80211_amrr_init
38 .Fa "struct ieee80211_amrr *"
39 .Fa "struct ieee80211vap *"
40 .Fa "int amin"
41 .Fa "int amax"
42 .Fa "int interval"
43 .Fc
44 .\"
45 .Ft void
46 .Fn ieee80211_amrr_cleanup "struct ieee80211_amrr *"
47 .\"
48 .Ft void
49 .Fn ieee80211_amrr_setinterval "struct ieee80211_amrr *" "int interval"
50 .\"
51 .Ft void
52 .Fo ieee80211_amrr_node_init
53 .Fa "struct ieee80211_amrr *"
54 .Fa "struct ieee80211_amrr_node *"
55 .Fa "struct ieee80211_node *"
56 .Fc
57 .\"
58 .Ft int
59 .Fo ieee80211_amrr_choose
60 .Fa "struct ieee80211_node *"
61 .Fa "struct ieee80211_amrr_node *"
62 .Fc
63 .\"
64 .Ft void
65 .Fo ieee80211_amrr_tx_complete
66 .Fa "struct ieee80211_amrr_node *"
67 .Fa "int ok"
68 .Fa "int retries"
69 .Fc
70 .\"
71 .Ft void
72 .Fo ieee80211_amrr_tx_update
73 .Fa "struct ieee80211_amrr_node *"
74 .Fa "int txnct"
75 .Fa "int success"
76 .Fa "int retrycnt"
77 .Fc
78 .Sh DESCRIPTION
79 .Nm
80 is an implementation of the AMRR transmit rate control algorithm
81 for drivers that use the
82 .Nm net80211
83 software layer.
84 A rate control algorithm is responsible for choosing the transmit
85 rate for each frame.
86 To maximize throughput algorithms try to use the highest rate that
87 is appropriate for the operating conditions.
88 The rate will vary as conditions change; the distance between two stations
89 may change, transient noise may be present that affects signal quality,
90 etc.
91 .Nm
92 uses very simple information from a driver to do it's job:
93 whether a frame was successfully delivered and how many transmit
94 attempts were made.
95 While this enables its use with virtually any wireless device it
96 limits it's effectiveness--do not expect it to function well in
97 difficult environments and/or respond quickly to changing conditions.
98 .Pp
99 .Nm
100 requires per-vap state and per-node state for each station it is to
101 select rates for.
102 The API's are designed for drivers to pre-allocate state in the
103 driver-private extension areas of each vap and node.
104 For example the
105 .Xr ral 4
106 driver defines a vap as:
107 .Bd -literal -offset indent
108 struct rt2560_vap {
109         struct ieee80211vap     ral_vap;
110         struct ieee80211_beacon_offsets ral_bo;
111         struct ieee80211_amrr   amrr;
112
113         int      (*ral_newstate)(struct ieee80211vap *,
114                       enum ieee80211_state, int);
115 };
116 .Ed
117 .Pp
118 The
119 .Vt amrr
120 structure member holds the per-vap state for
121 .Nm
122 and
123 .Xr ral 4
124 initializes it in the vap create method with:
125 .Bd -literal -offset indent
126 ieee80211_amrr_init(&rvp->amrr, vap,
127     IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD,
128     IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD,
129     500 /* ms */);
130 .Ed
131 .Pp
132 The node is defined as:
133 .Bd -literal -offset indent
134 struct rt2560_node {
135         struct ieee80211_node   ni;
136         struct ieee80211_amrr_node amrr;
137 };
138 .Ed
139 .Pp
140 with initialization done in the driver's
141 .Vt iv_newassoc
142 method:
143 .Bd -literal -offset indent
144 static void
145 rt2560_newassoc(struct ieee80211_node *ni, int isnew)
146 {
147         struct ieee80211vap *vap = ni->ni_vap;
148
149         ieee80211_amrr_node_init(&RT2560_VAP(vap)->amrr,
150             &RT2560_NODE(ni)->amrr, ni);
151 }
152 .Ed
153 .Pp
154 Once
155 .Nm
156 state is setup, transmit rates are requested by calling
157 .Fn ieee80211_amrr_choose
158 in the transmit path; e.g.:
159 .Bd -literal -offset indent
160 tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
161 if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
162         rate = tp->mcastrate;
163 } else if (m0->m_flags & M_EAPOL) {
164         rate = tp->mgmtrate;
165 } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
166         rate = tp->ucastrate;
167 } else {
168         (void) ieee80211_amrr_choose(ni, &RT2560_NODE(ni)->amrr);
169         rate = ni->ni_txrate;
170 }
171 .Ed
172 .Pp
173 Note a rate is chosen only for unicast data frames when a fixed
174 transmit rate is not configured; the other cases are handled with
175 the
176 .Nm net80211
177 transmit parameters.
178 Note also that
179 .Fn ieee80211_amrr_choose
180 writes the chosen rate in
181 .Vt ni_txrate ;
182 this eliminates copying the value as it is exported to user applications so
183 they can display the current transmit rate in status.
184 .Pp
185 The remaining work a driver must do is feed status back to
186 .Nm
187 when a frame transmit completes using
188 .Fn ieee80211_amrr_tx_complete .
189 Drivers that poll a device to retrieve statistics can use
190 .Fn ieee80211_amrr_tx_update
191 (instead or in addition).
192 .Sh SEE ALSO
193 .Xr ieee80211 9 ,
194 .Xr ieee80211_output 9