xref: /freebsd/share/man/man9/ieee80211_amrr.9 (revision 692eebe092e81927e190dd5eeb4f65d2324ea3fa)
1692eebe0SSam Leffler.\"
2692eebe0SSam Leffler.\" Copyright (c) 2009 Sam Leffler, Errno Consulting
3692eebe0SSam Leffler.\" All rights reserved.
4692eebe0SSam Leffler.\"
5692eebe0SSam Leffler.\" Redistribution and use in source and binary forms, with or without
6692eebe0SSam Leffler.\" modification, are permitted provided that the following conditions
7692eebe0SSam Leffler.\" are met:
8692eebe0SSam Leffler.\" 1. Redistributions of source code must retain the above copyright
9692eebe0SSam Leffler.\"    notice, this list of conditions and the following disclaimer.
10692eebe0SSam Leffler.\" 2. Redistributions in binary form must reproduce the above copyright
11692eebe0SSam Leffler.\"    notice, this list of conditions and the following disclaimer in the
12692eebe0SSam Leffler.\"    documentation and/or other materials provided with the distribution.
13692eebe0SSam Leffler.\"
14692eebe0SSam Leffler.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15692eebe0SSam Leffler.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16692eebe0SSam Leffler.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17692eebe0SSam Leffler.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18692eebe0SSam Leffler.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19692eebe0SSam Leffler.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20692eebe0SSam Leffler.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21692eebe0SSam Leffler.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22692eebe0SSam Leffler.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23692eebe0SSam Leffler.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24692eebe0SSam Leffler.\" SUCH DAMAGE.
25692eebe0SSam Leffler.\"
26692eebe0SSam Leffler.\" $FreeBSD$
27692eebe0SSam Leffler.\"
28692eebe0SSam Leffler.Dd August 4, 2009
29692eebe0SSam Leffler.Dt IEEE8021_AMRR 9
30692eebe0SSam Leffler.Os
31692eebe0SSam Leffler.Sh NAME
32692eebe0SSam Leffler.Nm ieee80211_amrr
33692eebe0SSam Leffler.Nd 802.11 network driver transmit rate control support
34692eebe0SSam Leffler.Sh SYNOPSIS
35692eebe0SSam Leffler.In net80211/ieee80211_amrr.h
36692eebe0SSam Leffler.Ft void
37692eebe0SSam Leffler.Fo ieee80211_amrr_init
38692eebe0SSam Leffler.Fa "struct ieee80211_amrr *"
39692eebe0SSam Leffler.Fa "struct ieee80211vap *"
40692eebe0SSam Leffler.Fa "int amin"
41692eebe0SSam Leffler.Fa "int amax"
42692eebe0SSam Leffler.Fa "int interval"
43692eebe0SSam Leffler.Fc
44692eebe0SSam Leffler.\"
45692eebe0SSam Leffler.Ft void
46692eebe0SSam Leffler.Fn ieee80211_amrr_cleanup "struct ieee80211_amrr *"
47692eebe0SSam Leffler.\"
48692eebe0SSam Leffler.Ft void
49692eebe0SSam Leffler.Fn ieee80211_amrr_setinterval "struct ieee80211_amrr *" "int interval"
50692eebe0SSam Leffler.\"
51692eebe0SSam Leffler.Ft void
52692eebe0SSam Leffler.Fo ieee80211_amrr_node_init
53692eebe0SSam Leffler.Fa "struct ieee80211_amrr *"
54692eebe0SSam Leffler.Fa "struct ieee80211_amrr_node *"
55692eebe0SSam Leffler.Fa "struct ieee80211_node *"
56692eebe0SSam Leffler.Fc
57692eebe0SSam Leffler.\"
58692eebe0SSam Leffler.Ft int
59692eebe0SSam Leffler.Fo ieee80211_amrr_choose
60692eebe0SSam Leffler.Fa "struct ieee80211_node *"
61692eebe0SSam Leffler.Fa "struct ieee80211_amrr_node *"
62692eebe0SSam Leffler.Fc
63692eebe0SSam Leffler.\"
64692eebe0SSam Leffler.Ft void
65692eebe0SSam Leffler.Fo ieee80211_amrr_tx_complete
66692eebe0SSam Leffler.Fa "struct ieee80211_amrr_node *"
67692eebe0SSam Leffler.Fa "int ok"
68692eebe0SSam Leffler.Fa "int retries"
69692eebe0SSam Leffler.Fc
70692eebe0SSam Leffler.\"
71692eebe0SSam Leffler.Ft void
72692eebe0SSam Leffler.Fo ieee80211_amrr_tx_update
73692eebe0SSam Leffler.Fa "struct ieee80211_amrr_node *"
74692eebe0SSam Leffler.Fa "int txnct"
75692eebe0SSam Leffler.Fa "int success"
76692eebe0SSam Leffler.Fa "int retrycnt"
77692eebe0SSam Leffler.Fc
78692eebe0SSam Leffler.Sh DESCRIPTION
79692eebe0SSam Leffler.Nm
80692eebe0SSam Leffleris an implementation of the AMRR transmit rate control algorithm
81692eebe0SSam Lefflerfor drivers that use the
82692eebe0SSam Leffler.Nm net80211
83692eebe0SSam Lefflersoftware layer.
84692eebe0SSam LefflerA rate control algorithm is responsible for choosing the transmit
85692eebe0SSam Lefflerrate for each frame.
86692eebe0SSam LefflerTo maximize throughput algorithms try to use the highest rate that
87692eebe0SSam Leffleris appropriate for the operating conditions.
88692eebe0SSam LefflerThe rate will vary as conditions change; the distance between two stations
89692eebe0SSam Lefflermay change, transient noise may be present that affects signal quality,
90692eebe0SSam Leffleretc.
91692eebe0SSam Leffler.Nm
92692eebe0SSam Leffleruses very simple information from a driver to do it's job:
93692eebe0SSam Lefflerwhether a frame was successfully delivered and how many transmit
94692eebe0SSam Lefflerattempts were made.
95692eebe0SSam LefflerWhile this enables its use with virtually any wireless device it
96692eebe0SSam Lefflerlimits it's effectiveness--do not expect it to function well in
97692eebe0SSam Lefflerdifficult environments and/or respond quickly to changing conditions.
98692eebe0SSam Leffler.Pp
99692eebe0SSam Leffler.Nm
100692eebe0SSam Lefflerrequires per-vap state and per-node state for each station it is to
101692eebe0SSam Lefflerselect rates for.
102692eebe0SSam LefflerThe API's are designed for drivers to pre-allocate state in the
103692eebe0SSam Lefflerdriver-private extension areas of each vap and node.
104692eebe0SSam LefflerFor example the
105692eebe0SSam Leffler.Xr ral 4
106692eebe0SSam Lefflerdriver defines a vap as:
107692eebe0SSam Leffler.Bd -literal -offset indent
108692eebe0SSam Lefflerstruct rt2560_vap {
109692eebe0SSam Leffler        struct ieee80211vap     ral_vap;
110692eebe0SSam Leffler        struct ieee80211_beacon_offsets ral_bo;
111692eebe0SSam Leffler        struct ieee80211_amrr   amrr;
112692eebe0SSam Leffler
113692eebe0SSam Leffler        int      (*ral_newstate)(struct ieee80211vap *,
114692eebe0SSam Leffler                      enum ieee80211_state, int);
115692eebe0SSam Leffler};
116692eebe0SSam Leffler.Ed
117692eebe0SSam Leffler.Pp
118692eebe0SSam LefflerThe
119692eebe0SSam Leffler.Vt amrr
120692eebe0SSam Lefflerstructure member holds the per-vap state for
121692eebe0SSam Leffler.Nm
122692eebe0SSam Lefflerand
123692eebe0SSam Leffler.Xr ral 4
124692eebe0SSam Lefflerinitializes it in the vap create method with:
125692eebe0SSam Leffler.Bd -literal -offset indent
126692eebe0SSam Lefflerieee80211_amrr_init(&rvp->amrr, vap,
127692eebe0SSam Leffler    IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD,
128692eebe0SSam Leffler    IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD,
129692eebe0SSam Leffler    500 /* ms */);
130692eebe0SSam Leffler.Ed
131692eebe0SSam Leffler.Pp
132692eebe0SSam LefflerThe node is defined as:
133692eebe0SSam Leffler.Bd -literal -offset indent
134692eebe0SSam Lefflerstruct rt2560_node {
135692eebe0SSam Leffler        struct ieee80211_node   ni;
136692eebe0SSam Leffler        struct ieee80211_amrr_node amrr;
137692eebe0SSam Leffler};
138692eebe0SSam Leffler.Ed
139692eebe0SSam Leffler.Pp
140692eebe0SSam Lefflerwith initialization done in the driver's
141692eebe0SSam Leffler.Vt iv_newassoc
142692eebe0SSam Lefflermethod:
143692eebe0SSam Leffler.Bd -literal -offset indent
144692eebe0SSam Lefflerstatic void
145692eebe0SSam Lefflerrt2560_newassoc(struct ieee80211_node *ni, int isnew)
146692eebe0SSam Leffler{
147692eebe0SSam Leffler        struct ieee80211vap *vap = ni->ni_vap;
148692eebe0SSam Leffler
149692eebe0SSam Leffler        ieee80211_amrr_node_init(&RT2560_VAP(vap)->amrr,
150692eebe0SSam Leffler            &RT2560_NODE(ni)->amrr, ni);
151692eebe0SSam Leffler}
152692eebe0SSam Leffler.Ed
153692eebe0SSam Leffler.Pp
154692eebe0SSam LefflerOnce
155692eebe0SSam Leffler.Nm
156692eebe0SSam Lefflerstate is setup, transmit rates are requested by calling
157692eebe0SSam Leffler.Fn ieee80211_amrr_choose
158692eebe0SSam Lefflerin the transmit path; e.g.:
159692eebe0SSam Leffler.Bd -literal -offset indent
160692eebe0SSam Lefflertp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)];
161692eebe0SSam Lefflerif (IEEE80211_IS_MULTICAST(wh->i_addr1)) {
162692eebe0SSam Leffler	rate = tp->mcastrate;
163692eebe0SSam Leffler} else if (m0->m_flags & M_EAPOL) {
164692eebe0SSam Leffler	rate = tp->mgmtrate;
165692eebe0SSam Leffler} else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
166692eebe0SSam Leffler	rate = tp->ucastrate;
167692eebe0SSam Leffler} else {
168692eebe0SSam Leffler	(void) ieee80211_amrr_choose(ni, &RT2560_NODE(ni)->amrr);
169692eebe0SSam Leffler	rate = ni->ni_txrate;
170692eebe0SSam Leffler}
171692eebe0SSam Leffler.Ed
172692eebe0SSam Leffler.Pp
173692eebe0SSam LefflerNote a rate is chosen only for unicast data frames when a fixed
174692eebe0SSam Lefflertransmit rate is not configured; the other cases are handled with
175692eebe0SSam Lefflerthe
176692eebe0SSam Leffler.Nm net80211
177692eebe0SSam Lefflertransmit parameters.
178692eebe0SSam LefflerNote also that
179692eebe0SSam Leffler.Fn ieee80211_amrr_choose
180692eebe0SSam Lefflerwrites the chosen rate in
181692eebe0SSam Leffler.Vt ni_txrate ;
182692eebe0SSam Lefflerthis eliminates copying the value as it is exported to user applications so
183692eebe0SSam Lefflerthey can display the current transmit rate in status.
184692eebe0SSam Leffler.Pp
185692eebe0SSam LefflerThe remaining work a driver must do is feed status back to
186692eebe0SSam Leffler.Nm
187692eebe0SSam Lefflerwhen a frame transmit completes using
188692eebe0SSam Leffler.Fn ieee80211_amrr_tx_complete .
189692eebe0SSam LefflerDrivers that poll a device to retrieve statistics can use
190692eebe0SSam Leffler.Fn ieee80211_amrr_tx_update
191692eebe0SSam Leffler(instead or in addition).
192692eebe0SSam Leffler.Sh SEE ALSO
193692eebe0SSam Leffler.Xr ieee80211 9 ,
194692eebe0SSam Leffler.Xr ieee80211_output 9 ,
195