xref: /freebsd/share/man/man9/ieee80211_amrr.9 (revision aa1a8ff2d6dbc51ef058f46f3db5a8bb77967145)
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.Dd August 4, 2009
27.Dt IEEE8021_AMRR 9
28.Os
29.Sh NAME
30.Nm ieee80211_amrr
31.Nd 802.11 network driver transmit rate control support
32.Sh SYNOPSIS
33.In net80211/ieee80211_amrr.h
34.Ft void
35.Fo ieee80211_amrr_init
36.Fa "struct ieee80211_amrr *"
37.Fa "struct ieee80211vap *"
38.Fa "int amin"
39.Fa "int amax"
40.Fa "int interval"
41.Fc
42.\"
43.Ft void
44.Fn ieee80211_amrr_cleanup "struct ieee80211_amrr *"
45.\"
46.Ft void
47.Fn ieee80211_amrr_setinterval "struct ieee80211_amrr *" "int interval"
48.\"
49.Ft void
50.Fo ieee80211_amrr_node_init
51.Fa "struct ieee80211_amrr *"
52.Fa "struct ieee80211_amrr_node *"
53.Fa "struct ieee80211_node *"
54.Fc
55.\"
56.Ft int
57.Fo ieee80211_amrr_choose
58.Fa "struct ieee80211_node *"
59.Fa "struct ieee80211_amrr_node *"
60.Fc
61.\"
62.Ft void
63.Fo ieee80211_amrr_tx_complete
64.Fa "struct ieee80211_amrr_node *"
65.Fa "int ok"
66.Fa "int retries"
67.Fc
68.\"
69.Ft void
70.Fo ieee80211_amrr_tx_update
71.Fa "struct ieee80211_amrr_node *"
72.Fa "int txnct"
73.Fa "int success"
74.Fa "int retrycnt"
75.Fc
76.Sh DESCRIPTION
77.Nm
78is an implementation of the AMRR transmit rate control algorithm
79for drivers that use the
80.Nm net80211
81software layer.
82A rate control algorithm is responsible for choosing the transmit
83rate for each frame.
84To maximize throughput algorithms try to use the highest rate that
85is appropriate for the operating conditions.
86The rate will vary as conditions change; the distance between two stations
87may change, transient noise may be present that affects signal quality,
88etc.
89.Nm
90uses very simple information from a driver to do it's job:
91whether a frame was successfully delivered and how many transmit
92attempts were made.
93While this enables its use with virtually any wireless device it
94limits it's effectiveness--do not expect it to function well in
95difficult environments and/or respond quickly to changing conditions.
96.Pp
97.Nm
98requires per-vap state and per-node state for each station it is to
99select rates for.
100The API's are designed for drivers to pre-allocate state in the
101driver-private extension areas of each vap and node.
102For example the
103.Xr ral 4
104driver defines a vap as:
105.Bd -literal -offset indent
106struct rt2560_vap {
107        struct ieee80211vap     ral_vap;
108        struct ieee80211_beacon_offsets ral_bo;
109        struct ieee80211_amrr   amrr;
110
111        int      (*ral_newstate)(struct ieee80211vap *,
112                      enum ieee80211_state, int);
113};
114.Ed
115.Pp
116The
117.Vt amrr
118structure member holds the per-vap state for
119.Nm
120and
121.Xr ral 4
122initializes it in the vap create method with:
123.Bd -literal -offset indent
124ieee80211_amrr_init(&rvp->amrr, vap,
125    IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD,
126    IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD,
127    500 /* ms */);
128.Ed
129.Pp
130The node is defined as:
131.Bd -literal -offset indent
132struct rt2560_node {
133        struct ieee80211_node   ni;
134        struct ieee80211_amrr_node amrr;
135};
136.Ed
137.Pp
138with initialization done in the driver's
139.Vt iv_newassoc
140method:
141.Bd -literal -offset indent
142static void
143rt2560_newassoc(struct ieee80211_node *ni, int isnew)
144{
145        struct ieee80211vap *vap = ni->ni_vap;
146
147        ieee80211_amrr_node_init(&RT2560_VAP(vap)->amrr,
148            &RT2560_NODE(ni)->amrr, ni);
149}
150.Ed
151.Pp
152Once
153.Nm
154state is setup, transmit rates are requested by calling
155.Fn ieee80211_amrr_choose
156in the transmit path; e.g.:
157.Bd -literal -offset indent
158tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
159if (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
160	rate = tp->mcastrate;
161} else if (m0->m_flags & M_EAPOL) {
162	rate = tp->mgmtrate;
163} else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
164	rate = tp->ucastrate;
165} else {
166	(void) ieee80211_amrr_choose(ni, &RT2560_NODE(ni)->amrr);
167	rate = ni->ni_txrate;
168}
169.Ed
170.Pp
171Note a rate is chosen only for unicast data frames when a fixed
172transmit rate is not configured; the other cases are handled with
173the
174.Nm net80211
175transmit parameters.
176Note also that
177.Fn ieee80211_amrr_choose
178writes the chosen rate in
179.Vt ni_txrate ;
180this eliminates copying the value as it is exported to user applications so
181they can display the current transmit rate in status.
182.Pp
183The remaining work a driver must do is feed status back to
184.Nm
185when a frame transmit completes using
186.Fn ieee80211_amrr_tx_complete .
187Drivers that poll a device to retrieve statistics can use
188.Fn ieee80211_amrr_tx_update
189(instead or in addition).
190.Sh SEE ALSO
191.Xr ieee80211 9 ,
192.Xr ieee80211_output 9
193