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$ 27.\" 28.Dd August 4, 2009 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 80is an implementation of the AMRR transmit rate control algorithm 81for drivers that use the 82.Nm net80211 83software layer. 84A rate control algorithm is responsible for choosing the transmit 85rate for each frame. 86To maximize throughput algorithms try to use the highest rate that 87is appropriate for the operating conditions. 88The rate will vary as conditions change; the distance between two stations 89may change, transient noise may be present that affects signal quality, 90etc. 91.Nm 92uses very simple information from a driver to do it's job: 93whether a frame was successfully delivered and how many transmit 94attempts were made. 95While this enables its use with virtually any wireless device it 96limits it's effectiveness--do not expect it to function well in 97difficult environments and/or respond quickly to changing conditions. 98.Pp 99.Nm 100requires per-vap state and per-node state for each station it is to 101select rates for. 102The API's are designed for drivers to pre-allocate state in the 103driver-private extension areas of each vap and node. 104For example the 105.Xr ral 4 106driver defines a vap as: 107.Bd -literal -offset indent 108struct 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 118The 119.Vt amrr 120structure member holds the per-vap state for 121.Nm 122and 123.Xr ral 4 124initializes it in the vap create method with: 125.Bd -literal -offset indent 126ieee80211_amrr_init(&rvp->amrr, vap, 127 IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, 128 IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD, 129 500 /* ms */); 130.Ed 131.Pp 132The node is defined as: 133.Bd -literal -offset indent 134struct rt2560_node { 135 struct ieee80211_node ni; 136 struct ieee80211_amrr_node amrr; 137}; 138.Ed 139.Pp 140with initialization done in the driver's 141.Vt iv_newassoc 142method: 143.Bd -literal -offset indent 144static void 145rt2560_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 154Once 155.Nm 156state is setup, transmit rates are requested by calling 157.Fn ieee80211_amrr_choose 158in the transmit path; e.g.: 159.Bd -literal -offset indent 160tp = &vap->iv_txparms[ieee80211_chan2mode(ni->ni_chan)]; 161if (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 173Note a rate is chosen only for unicast data frames when a fixed 174transmit rate is not configured; the other cases are handled with 175the 176.Nm net80211 177transmit parameters. 178Note also that 179.Fn ieee80211_amrr_choose 180writes the chosen rate in 181.Vt ni_txrate ; 182this eliminates copying the value as it is exported to user applications so 183they can display the current transmit rate in status. 184.Pp 185The remaining work a driver must do is feed status back to 186.Nm 187when a frame transmit completes using 188.Fn ieee80211_amrr_tx_complete . 189Drivers 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 195