ath_rate.c revision 129d67acdc2d029d3d6cff4022c0c26c81c76f89
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
* 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.
*
* 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/ethernet.h>
#include <sys/byteorder.h>
#include <inet/wifi_ioctl.h>
#include "ath_hal.h"
#include "ath_impl.h"
#include "ath_rate.h"
void
{
/* management/control frames always go at the lowest speed */
"mgtrate=%d mgtratesp=%d\n",
/*
* 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.
*/
goto done;
if (asc->asc_mrretry) {
/*
* Hardware supports multi-rate retry; setup two
* step-down retry rates and make the lowest rate
* be the ``last chance''. We use 4, 2, 2, 2 tries
* respectively (4 is set here, the rest are fixed
* in the xmit routine).
*/
if (--rate >= 0) {
} else {
}
if (--rate >= 0) {
} else {
}
if (rate > 0) {
an->an_tx_rate3sp =
} else {
}
} else {
}
done:
}
/*
* Set the starting transmit rate for a node.
*/
void
{
/*
* 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.
*/
/*
* Scan the negotiated rate set to find the
* closest rate.
*/
/* NB: the rate set is assumed sorted */
srate--) {}
}
} else {
/*
* A fixed rate is to be used; We know the rate is
* there because the rate set is checked when the
* station associates.
*/
/* NB: the rate set is assumed sorted */
srate--) {}
}
}
void
{
}
/*
* Reset the rate control state for each 802.11 state transition.
*/
void
{
struct ieee80211_node *in;
/*
* Reset local xmit state; this is really only
* meaningful when operating in station mode.
*/
if (state == IEEE80211_S_RUN) {
} else {
}
} else {
/*
* When operating as a station the node table holds
* the AP's that were discovered during scanning.
* For any other operating mode we want to reset the
* tx rate state of each node.
*/
}
}
/*
* Examine and potentially adjust the transmit rate.
*/
void
{
/*
* Rate control(very primitive version).
*/
/* no packet reached -> down */
mod = -1;
/* all packets needs retry in average -> down */
mod = -1;
/* no error and less than 10% of packets needs retry -> up */
mod = 1;
switch (mod) {
case 0:
an->an_tx_upper--;
break;
case -1:
if (nrate > 0) {
nrate--;
}
an->an_tx_upper = 0;
break;
case 1:
break;
an->an_tx_upper = 0;
nrate++;
}
break;
}
"(%d ok, %d err, %d retr)\n",
} else if (enough)
}
/*
* Read rate table from the HAL, and then
* copy the table to the driver's data structure.
*/
void
{
int32_t i;
struct ieee80211_rateset *rs;
const HAL_RATE_TABLE *rt;
switch (mode) {
case IEEE80211_MODE_11A:
break;
case IEEE80211_MODE_11B:
break;
case IEEE80211_MODE_11G:
break;
case IEEE80211_MODE_TURBO_A:
break;
case IEEE80211_MODE_TURBO_G:
break;
default:
"invalid mode %u\n", mode));
return;
}
return;
"rate table too small (%u > %u)\n",
} else
for (i = 0; i < maxrates; i++)
}