2004-12-08 17:32:02 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2004 INRIA
|
2004-12-31 22:42:38 +00:00
|
|
|
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
|
2004-12-08 17:32:02 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
|
|
|
* redistribution must be conditioned upon including a substantially
|
|
|
|
* similar Disclaimer requirement for further binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
|
|
|
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
|
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AMRR rate control. See:
|
|
|
|
* http://www-sop.inria.fr/rapports/sophia/RR-5208.html
|
|
|
|
* "IEEE 802.11 Rate Adaptation: A Practical Approach" by
|
|
|
|
* Mathieu Lacage, Hossein Manshaei, Thierry Turletti
|
|
|
|
*/
|
|
|
|
#include "opt_inet.h"
|
2008-04-20 20:35:46 +00:00
|
|
|
#include "opt_wlan.h"
|
2004-12-08 17:32:02 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#include <net/if_arp.h>
|
|
|
|
|
|
|
|
#include <net80211/ieee80211_var.h>
|
|
|
|
|
|
|
|
#include <net/bpf.h>
|
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dev/ath/if_athvar.h>
|
|
|
|
#include <dev/ath/ath_rate/amrr/amrr.h>
|
2008-12-01 16:53:01 +00:00
|
|
|
#include <dev/ath/ath_hal/ah_desc.h>
|
2004-12-08 17:32:02 +00:00
|
|
|
|
|
|
|
static int ath_rateinterval = 1000; /* rate ctl interval (ms) */
|
|
|
|
static int ath_rate_max_success_threshold = 10;
|
|
|
|
static int ath_rate_min_success_threshold = 1;
|
|
|
|
|
|
|
|
static void ath_rate_update(struct ath_softc *, struct ieee80211_node *,
|
|
|
|
int rate);
|
|
|
|
static void ath_rate_ctl_start(struct ath_softc *, struct ieee80211_node *);
|
|
|
|
static void ath_rate_ctl(void *, struct ieee80211_node *);
|
|
|
|
|
|
|
|
void
|
|
|
|
ath_rate_node_init(struct ath_softc *sc, struct ath_node *an)
|
|
|
|
{
|
|
|
|
/* NB: assumed to be zero'd by caller */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ath_rate_node_cleanup(struct ath_softc *sc, struct ath_node *an)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ath_rate_findrate(struct ath_softc *sc, struct ath_node *an,
|
2005-04-02 18:54:30 +00:00
|
|
|
int shortPreamble, size_t frameLen,
|
2004-12-08 17:32:02 +00:00
|
|
|
u_int8_t *rix, int *try0, u_int8_t *txrate)
|
|
|
|
{
|
|
|
|
struct amrr_node *amn = ATH_NODE_AMRR(an);
|
|
|
|
|
|
|
|
*rix = amn->amn_tx_rix0;
|
|
|
|
*try0 = amn->amn_tx_try0;
|
|
|
|
if (shortPreamble)
|
|
|
|
*txrate = amn->amn_tx_rate0sp;
|
|
|
|
else
|
|
|
|
*txrate = amn->amn_tx_rate0;
|
|
|
|
}
|
|
|
|
|
2011-02-01 08:10:18 +00:00
|
|
|
/*
|
|
|
|
* Get the TX rates.
|
|
|
|
*
|
|
|
|
* The short preamble bits aren't set here; the caller should augment
|
|
|
|
* the returned rate with the relevant preamble rate flag.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ath_rate_getxtxrates(struct ath_softc *sc, struct ath_node *an,
|
|
|
|
uint8_t rix0, uint8_t *rix, uint8_t *try)
|
|
|
|
{
|
|
|
|
struct amrr_node *amn = ATH_NODE_AMRR(an);
|
|
|
|
|
|
|
|
/* rix[0] = amn->amn_tx_rate0; */
|
|
|
|
rix[1] = amn->amn_tx_rate1;
|
|
|
|
rix[2] = amn->amn_tx_rate2;
|
|
|
|
rix[3] = amn->amn_tx_rate3;
|
|
|
|
|
|
|
|
try[0] = amn->amn_tx_try0;
|
|
|
|
try[1] = amn->amn_tx_try1;
|
|
|
|
try[2] = amn->amn_tx_try2;
|
|
|
|
try[3] = amn->amn_tx_try3;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-08 17:32:02 +00:00
|
|
|
void
|
|
|
|
ath_rate_setupxtxdesc(struct ath_softc *sc, struct ath_node *an,
|
2005-04-02 18:54:30 +00:00
|
|
|
struct ath_desc *ds, int shortPreamble, u_int8_t rix)
|
2004-12-08 17:32:02 +00:00
|
|
|
{
|
|
|
|
struct amrr_node *amn = ATH_NODE_AMRR(an);
|
|
|
|
|
|
|
|
ath_hal_setupxtxdesc(sc->sc_ah, ds
|
|
|
|
, amn->amn_tx_rate1sp, amn->amn_tx_try1 /* series 1 */
|
|
|
|
, amn->amn_tx_rate2sp, amn->amn_tx_try2 /* series 2 */
|
|
|
|
, amn->amn_tx_rate3sp, amn->amn_tx_try3 /* series 3 */
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-03-30 20:17:18 +00:00
|
|
|
ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an,
|
2006-12-13 19:34:35 +00:00
|
|
|
const struct ath_buf *bf)
|
2004-12-08 17:32:02 +00:00
|
|
|
{
|
|
|
|
struct amrr_node *amn = ATH_NODE_AMRR(an);
|
2006-12-13 19:34:35 +00:00
|
|
|
const struct ath_tx_status *ts = &bf->bf_status.ds_txstat;
|
|
|
|
int sr = ts->ts_shortretry;
|
|
|
|
int lr = ts->ts_longretry;
|
2004-12-08 17:32:02 +00:00
|
|
|
int retry_count = sr + lr;
|
|
|
|
|
|
|
|
amn->amn_tx_try0_cnt++;
|
|
|
|
if (retry_count == 1) {
|
|
|
|
amn->amn_tx_try1_cnt++;
|
|
|
|
} else if (retry_count == 2) {
|
|
|
|
amn->amn_tx_try1_cnt++;
|
|
|
|
amn->amn_tx_try2_cnt++;
|
|
|
|
} else if (retry_count == 3) {
|
|
|
|
amn->amn_tx_try1_cnt++;
|
|
|
|
amn->amn_tx_try2_cnt++;
|
|
|
|
amn->amn_tx_try3_cnt++;
|
|
|
|
} else if (retry_count > 3) {
|
|
|
|
amn->amn_tx_try1_cnt++;
|
|
|
|
amn->amn_tx_try2_cnt++;
|
|
|
|
amn->amn_tx_try3_cnt++;
|
|
|
|
amn->amn_tx_failure_cnt++;
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
if (amn->amn_interval != 0 &&
|
|
|
|
ticks - amn->amn_ticks > amn->amn_interval) {
|
|
|
|
ath_rate_ctl(sc, &an->an_node);
|
|
|
|
amn->amn_ticks = ticks;
|
|
|
|
}
|
2004-12-08 17:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ath_rate_newassoc(struct ath_softc *sc, struct ath_node *an, int isnew)
|
|
|
|
{
|
|
|
|
if (isnew)
|
|
|
|
ath_rate_ctl_start(sc, &an->an_node);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-20 20:35:46 +00:00
|
|
|
node_reset(struct amrr_node *amn)
|
2004-12-08 17:32:02 +00:00
|
|
|
{
|
|
|
|
amn->amn_tx_try0_cnt = 0;
|
|
|
|
amn->amn_tx_try1_cnt = 0;
|
|
|
|
amn->amn_tx_try2_cnt = 0;
|
|
|
|
amn->amn_tx_try3_cnt = 0;
|
|
|
|
amn->amn_tx_failure_cnt = 0;
|
|
|
|
amn->amn_success = 0;
|
|
|
|
amn->amn_recovery = 0;
|
|
|
|
amn->amn_success_threshold = ath_rate_min_success_threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The code below assumes that we are dealing with hardware multi rate retry
|
|
|
|
* I have no idea what will happen if you try to use this module with another
|
|
|
|
* type of hardware. Your machine might catch fire or it might work with
|
|
|
|
* horrible performance...
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ath_rate_update(struct ath_softc *sc, struct ieee80211_node *ni, int rate)
|
|
|
|
{
|
|
|
|
struct ath_node *an = ATH_NODE(ni);
|
|
|
|
struct amrr_node *amn = ATH_NODE_AMRR(an);
|
2008-04-20 20:35:46 +00:00
|
|
|
struct ieee80211vap *vap = ni->ni_vap;
|
2004-12-08 17:32:02 +00:00
|
|
|
const HAL_RATE_TABLE *rt = sc->sc_currates;
|
|
|
|
u_int8_t rix;
|
|
|
|
|
|
|
|
KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode));
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, ni,
|
|
|
|
"%s: set xmit rate to %dM", __func__,
|
2004-12-08 17:32:02 +00:00
|
|
|
ni->ni_rates.rs_nrates > 0 ?
|
|
|
|
(ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
amn->amn_rix = rate;
|
2004-12-08 17:32:02 +00:00
|
|
|
/*
|
|
|
|
* Before associating a node has no rate set setup
|
|
|
|
* so we can't calculate any transmit codes to use.
|
|
|
|
* This is ok since we should never be sending anything
|
|
|
|
* but management frames and those always go at the
|
|
|
|
* lowest hardware rate.
|
|
|
|
*/
|
|
|
|
if (ni->ni_rates.rs_nrates > 0) {
|
2008-04-20 20:35:46 +00:00
|
|
|
ni->ni_txrate = ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL;
|
|
|
|
amn->amn_tx_rix0 = sc->sc_rixmap[ni->ni_txrate];
|
2004-12-08 17:32:02 +00:00
|
|
|
amn->amn_tx_rate0 = rt->info[amn->amn_tx_rix0].rateCode;
|
|
|
|
amn->amn_tx_rate0sp = amn->amn_tx_rate0 |
|
|
|
|
rt->info[amn->amn_tx_rix0].shortPreamble;
|
|
|
|
if (sc->sc_mrretry) {
|
|
|
|
amn->amn_tx_try0 = 1;
|
|
|
|
amn->amn_tx_try1 = 1;
|
|
|
|
amn->amn_tx_try2 = 1;
|
|
|
|
amn->amn_tx_try3 = 1;
|
|
|
|
if (--rate >= 0) {
|
|
|
|
rix = sc->sc_rixmap[
|
|
|
|
ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
|
|
|
|
amn->amn_tx_rate1 = rt->info[rix].rateCode;
|
|
|
|
amn->amn_tx_rate1sp = amn->amn_tx_rate1 |
|
|
|
|
rt->info[rix].shortPreamble;
|
|
|
|
} else {
|
|
|
|
amn->amn_tx_rate1 = amn->amn_tx_rate1sp = 0;
|
|
|
|
}
|
|
|
|
if (--rate >= 0) {
|
|
|
|
rix = sc->sc_rixmap[
|
|
|
|
ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
|
|
|
|
amn->amn_tx_rate2 = rt->info[rix].rateCode;
|
|
|
|
amn->amn_tx_rate2sp = amn->amn_tx_rate2 |
|
|
|
|
rt->info[rix].shortPreamble;
|
|
|
|
} else {
|
|
|
|
amn->amn_tx_rate2 = amn->amn_tx_rate2sp = 0;
|
|
|
|
}
|
|
|
|
if (rate > 0) {
|
|
|
|
/* NB: only do this if we didn't already do it above */
|
|
|
|
amn->amn_tx_rate3 = rt->info[0].rateCode;
|
|
|
|
amn->amn_tx_rate3sp =
|
2006-02-09 20:49:55 +00:00
|
|
|
amn->amn_tx_rate3 | rt->info[0].shortPreamble;
|
2004-12-08 17:32:02 +00:00
|
|
|
} else {
|
|
|
|
amn->amn_tx_rate3 = amn->amn_tx_rate3sp = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
amn->amn_tx_try0 = ATH_TXMAXTRY;
|
|
|
|
/* theorically, these statements are useless because
|
|
|
|
* the code which uses them tests for an_tx_try0 == ATH_TXMAXTRY
|
|
|
|
*/
|
|
|
|
amn->amn_tx_try1 = 0;
|
|
|
|
amn->amn_tx_try2 = 0;
|
|
|
|
amn->amn_tx_try3 = 0;
|
|
|
|
amn->amn_tx_rate1 = amn->amn_tx_rate1sp = 0;
|
|
|
|
amn->amn_tx_rate2 = amn->amn_tx_rate2sp = 0;
|
|
|
|
amn->amn_tx_rate3 = amn->amn_tx_rate3sp = 0;
|
|
|
|
}
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
node_reset(amn);
|
|
|
|
|
|
|
|
amn->amn_interval = ath_rateinterval;
|
|
|
|
if (vap->iv_opmode == IEEE80211_M_STA)
|
|
|
|
amn->amn_interval /= 2;
|
|
|
|
amn->amn_interval = (amn->amn_interval * hz) / 1000;
|
2004-12-08 17:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the starting transmit rate for a node.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni)
|
|
|
|
{
|
|
|
|
#define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
|
2008-10-27 17:03:24 +00:00
|
|
|
const struct ieee80211_txparam *tp = ni->ni_txparms;
|
2004-12-08 17:32:02 +00:00
|
|
|
int srate;
|
|
|
|
|
|
|
|
KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates"));
|
2008-04-20 20:35:46 +00:00
|
|
|
if (tp == NULL || tp->ucastrate == IEEE80211_FIXED_RATE_NONE) {
|
2004-12-08 17:32:02 +00:00
|
|
|
/*
|
|
|
|
* No fixed rate is requested. For 11b start with
|
|
|
|
* the highest negotiated rate; otherwise, for 11g
|
|
|
|
* and 11a, we start "in the middle" at 24Mb or 36Mb.
|
|
|
|
*/
|
|
|
|
srate = ni->ni_rates.rs_nrates - 1;
|
|
|
|
if (sc->sc_curmode != IEEE80211_MODE_11B) {
|
|
|
|
/*
|
|
|
|
* Scan the negotiated rate set to find the
|
|
|
|
* closest rate.
|
|
|
|
*/
|
|
|
|
/* NB: the rate set is assumed sorted */
|
|
|
|
for (; srate >= 0 && RATE(srate) > 72; srate--)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
* A fixed rate is to be used; ic_fixed_rate is the
|
|
|
|
* IEEE code for this rate (sans basic bit). Convert this
|
2004-12-08 17:32:02 +00:00
|
|
|
* to the index into the negotiated rate set for
|
|
|
|
* the node. We know the rate is there because the
|
|
|
|
* rate set is checked when the station associates.
|
|
|
|
*/
|
|
|
|
/* NB: the rate set is assumed sorted */
|
|
|
|
srate = ni->ni_rates.rs_nrates - 1;
|
2008-04-20 20:35:46 +00:00
|
|
|
for (; srate >= 0 && RATE(srate) != tp->ucastrate; srate--)
|
2004-12-08 17:32:02 +00:00
|
|
|
;
|
|
|
|
}
|
Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing
Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested
This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.
2007-06-11 03:36:55 +00:00
|
|
|
/*
|
|
|
|
* The selected rate may not be available due to races
|
|
|
|
* and mode settings. Also orphaned nodes created in
|
|
|
|
* adhoc mode may not have any rate set so this lookup
|
|
|
|
* can fail. This is not fatal.
|
|
|
|
*/
|
|
|
|
ath_rate_update(sc, ni, srate < 0 ? 0 : srate);
|
2004-12-08 17:32:02 +00:00
|
|
|
#undef RATE
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Examine and potentially adjust the transmit rate.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ath_rate_ctl(void *arg, struct ieee80211_node *ni)
|
|
|
|
{
|
|
|
|
struct ath_softc *sc = arg;
|
|
|
|
struct amrr_node *amn = ATH_NODE_AMRR(ATH_NODE (ni));
|
2008-04-20 20:35:46 +00:00
|
|
|
int rix;
|
2004-12-08 17:32:02 +00:00
|
|
|
|
|
|
|
#define is_success(amn) \
|
|
|
|
(amn->amn_tx_try1_cnt < (amn->amn_tx_try0_cnt/10))
|
|
|
|
#define is_enough(amn) \
|
|
|
|
(amn->amn_tx_try0_cnt > 10)
|
|
|
|
#define is_failure(amn) \
|
|
|
|
(amn->amn_tx_try1_cnt > (amn->amn_tx_try0_cnt/3))
|
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
rix = amn->amn_rix;
|
2004-12-08 17:32:02 +00:00
|
|
|
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
|
|
|
|
"cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d",
|
|
|
|
amn->amn_tx_try0_cnt, amn->amn_tx_try1_cnt, amn->amn_tx_try2_cnt,
|
|
|
|
amn->amn_tx_try3_cnt, amn->amn_success_threshold);
|
2004-12-08 17:32:02 +00:00
|
|
|
if (is_success (amn) && is_enough (amn)) {
|
|
|
|
amn->amn_success++;
|
|
|
|
if (amn->amn_success == amn->amn_success_threshold &&
|
2008-04-20 20:35:46 +00:00
|
|
|
rix + 1 < ni->ni_rates.rs_nrates) {
|
2004-12-08 17:32:02 +00:00
|
|
|
amn->amn_recovery = 1;
|
|
|
|
amn->amn_success = 0;
|
2008-04-20 20:35:46 +00:00
|
|
|
rix++;
|
|
|
|
IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
|
|
|
|
"increase rate to %d", rix);
|
2004-12-08 17:32:02 +00:00
|
|
|
} else {
|
|
|
|
amn->amn_recovery = 0;
|
|
|
|
}
|
|
|
|
} else if (is_failure (amn)) {
|
|
|
|
amn->amn_success = 0;
|
2008-04-20 20:35:46 +00:00
|
|
|
if (rix > 0) {
|
2004-12-08 17:32:02 +00:00
|
|
|
if (amn->amn_recovery) {
|
|
|
|
/* recovery failure. */
|
|
|
|
amn->amn_success_threshold *= 2;
|
|
|
|
amn->amn_success_threshold = min (amn->amn_success_threshold,
|
|
|
|
(u_int)ath_rate_max_success_threshold);
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE(ni->ni_vap,
|
|
|
|
IEEE80211_MSG_RATECTL, ni,
|
|
|
|
"decrease rate recovery thr: %d",
|
|
|
|
amn->amn_success_threshold);
|
2004-12-08 17:32:02 +00:00
|
|
|
} else {
|
|
|
|
/* simple failure. */
|
|
|
|
amn->amn_success_threshold = ath_rate_min_success_threshold;
|
2008-04-20 20:35:46 +00:00
|
|
|
IEEE80211_NOTE(ni->ni_vap,
|
|
|
|
IEEE80211_MSG_RATECTL, ni,
|
|
|
|
"decrease rate normal thr: %d",
|
|
|
|
amn->amn_success_threshold);
|
2004-12-08 17:32:02 +00:00
|
|
|
}
|
|
|
|
amn->amn_recovery = 0;
|
2008-04-20 20:35:46 +00:00
|
|
|
rix--;
|
2004-12-08 17:32:02 +00:00
|
|
|
} else {
|
|
|
|
amn->amn_recovery = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
if (is_enough (amn) || rix != amn->amn_rix) {
|
2004-12-08 17:32:02 +00:00
|
|
|
/* reset counters. */
|
|
|
|
amn->amn_tx_try0_cnt = 0;
|
|
|
|
amn->amn_tx_try1_cnt = 0;
|
|
|
|
amn->amn_tx_try2_cnt = 0;
|
|
|
|
amn->amn_tx_try3_cnt = 0;
|
|
|
|
amn->amn_tx_failure_cnt = 0;
|
|
|
|
}
|
2008-04-20 20:35:46 +00:00
|
|
|
if (rix != amn->amn_rix) {
|
|
|
|
ath_rate_update(sc, ni, rix);
|
2004-12-08 17:32:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ath_rate_sysctlattach(struct ath_softc *sc)
|
|
|
|
{
|
|
|
|
struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
|
|
|
|
struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
|
|
|
|
|
|
|
|
SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
|
|
|
|
"rate_interval", CTLFLAG_RW, &ath_rateinterval, 0,
|
|
|
|
"rate control: operation interval (ms)");
|
|
|
|
/* XXX bounds check values */
|
|
|
|
SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
|
|
|
|
"max_sucess_threshold", CTLFLAG_RW,
|
|
|
|
&ath_rate_max_success_threshold, 0, "");
|
|
|
|
SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
|
|
|
|
"min_sucess_threshold", CTLFLAG_RW,
|
|
|
|
&ath_rate_min_success_threshold, 0, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ath_ratectrl *
|
|
|
|
ath_rate_attach(struct ath_softc *sc)
|
|
|
|
{
|
|
|
|
struct amrr_softc *asc;
|
|
|
|
|
|
|
|
asc = malloc(sizeof(struct amrr_softc), M_DEVBUF, M_NOWAIT|M_ZERO);
|
|
|
|
if (asc == NULL)
|
|
|
|
return NULL;
|
|
|
|
asc->arc.arc_space = sizeof(struct amrr_node);
|
|
|
|
ath_rate_sysctlattach(sc);
|
|
|
|
|
|
|
|
return &asc->arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ath_rate_detach(struct ath_ratectrl *arc)
|
|
|
|
{
|
|
|
|
struct amrr_softc *asc = (struct amrr_softc *) arc;
|
|
|
|
|
|
|
|
free(asc, M_DEVBUF);
|
|
|
|
}
|