/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2004 Video54 Technologies, Inc.
* Copyright (c) 2004-2008 Atheros Communications, Inc.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/net80211_ht.h>
#include "arn_core.h"
#include "arn_hw.h"
#include "arn_reg.h"
42,
{0},
{
5400, 0x0b, 0x00, 12,
0, 2, 1, 0, 0, 0, 0, 0 },
7800, 0x0f, 0x00, 18,
0, 3, 1, 1, 1, 1, 1, 0 },
10000, 0x0a, 0x00, 24,
2, 4, 2, 2, 2, 2, 2, 0 },
13900, 0x0e, 0x00, 36,
2, 6, 2, 3, 3, 3, 3, 0 },
17300, 0x09, 0x00, 48,
4, 10, 3, 4, 4, 4, 4, 0 },
23000, 0x0d, 0x00, 72,
4, 14, 3, 5, 5, 5, 5, 0 },
27400, 0x08, 0x00, 96,
4, 20, 3, 6, 6, 6, 6, 0 },
29300, 0x0c, 0x00, 108,
4, 23, 3, 7, 7, 7, 7, 0 },
6400, 0x80, 0x00, 0,
0, 2, 3, 8, 24, 8, 24, 3216 },
12700, 0x81, 0x00, 1,
2, 4, 3, 9, 25, 9, 25, 6434 },
18800, 0x82, 0x00, 2,
2, 6, 3, 10, 26, 10, 26, 9650 },
25000, 0x83, 0x00, 3,
4, 10, 3, 11, 27, 11, 27, 12868 },
36700, 0x84, 0x00, 4,
4, 14, 3, 12, 28, 12, 28, 19304 },
48100, 0x85, 0x00, 5,
4, 20, 3, 13, 29, 13, 29, 25740 },
53500, 0x86, 0x00, 6,
4, 23, 3, 14, 30, 14, 30, 28956 },
59000, 0x87, 0x00, 7,
4, 25, 3, 15, 31, 15, 32, 32180 },
12700, 0x88, 0x00,
8, 0, 2, 3, 16, 33, 16, 33, 6430 },
24800, 0x89, 0x00, 9,
2, 4, 3, 17, 34, 17, 34, 12860 },
36600, 0x8a, 0x00, 10,
2, 6, 3, 18, 35, 18, 35, 19300 },
48100, 0x8b, 0x00, 11,
4, 10, 3, 19, 36, 19, 36, 25736 },
69500, 0x8c, 0x00, 12,
4, 14, 3, 20, 37, 20, 37, 38600 },
89500, 0x8d, 0x00, 13,
4, 20, 3, 21, 38, 21, 38, 51472 },
98900, 0x8e, 0x00, 14,
4, 23, 3, 22, 39, 22, 39, 57890 },
108300, 0x8f, 0x00, 15,
4, 25, 3, 23, 40, 23, 41, 64320 },
13200, 0x80, 0x00, 0,
0, 2, 3, 8, 24, 24, 24, 6684 },
25900, 0x81, 0x00, 1,
2, 4, 3, 9, 25, 25, 25, 13368 },
38600, 0x82, 0x00, 2,
2, 6, 3, 10, 26, 26, 26, 20052 },
49800, 0x83, 0x00, 3,
4, 10, 3, 11, 27, 27, 27, 26738 },
72200, 0x84, 0x00, 4,
4, 14, 3, 12, 28, 28, 28, 40104 },
92900, 0x85, 0x00, 5,
4, 20, 3, 13, 29, 29, 29, 53476 },
102700, 0x86, 0x00, 6,
4, 23, 3, 14, 30, 30, 30, 60156 },
112000, 0x87, 0x00, 7,
4, 25, 3, 15, 31, 32, 32, 66840 },
150000, /* 150Mb */
122000, 0x87, 0x00, 7,
4, 25, 3, 15, 31, 32, 32, 74200 },
25800, 0x88, 0x00, 8,
0, 2, 3, 16, 33, 33, 33, 13360 },
49800, 0x89, 0x00, 9,
2, 4, 3, 17, 34, 34, 34, 26720 },
71900, 0x8a, 0x00, 10,
2, 6, 3, 18, 35, 35, 35, 40080 },
92500, 0x8b, 0x00, 11,
4, 10, 3, 19, 36, 36, 36, 53440 },
130300, 0x8c, 0x00, 12,
4, 14, 3, 20, 37, 37, 37, 80160 },
162800, 0x8d, 0x00, 13,
4, 20, 3, 21, 38, 38, 38, 106880 },
178200, 0x8e, 0x00, 14,
4, 23, 3, 22, 39, 39, 39, 120240 },
192100, 0x8f, 0x00, 15,
4, 25, 3, 23, 40, 41, 41, 133600 },
300000, /* 300 Mb */
207000, 0x8f, 0x00, 15,
4, 25, 3, 23, 40, 41, 41, 148400 },
},
50, /* probe interval */
50, /* rssi reduce interval */
WLAN_RC_HT_FLAG, /* Phy rates allowed initially */
};
/*
* 4ms frame limit not used for NG mode. The values filled
* for HT are the 64K max aggregate limit
*/
46,
{0},
{
900, 0x1b, 0x00, 2,
0, 0, 1, 0, 0, 0, 0, 0 },
1900, 0x1a, 0x04, 4,
1, 1, 1, 1, 1, 1, 1, 0 },
4900, 0x19, 0x04, 11,
2, 2, 2, 2, 2, 2, 2, 0 },
8100, 0x18, 0x04, 22,
3, 3, 2, 3, 3, 3, 3, 0 },
5400, 0x0b, 0x00, 12,
4, 2, 1, 4, 4, 4, 4, 0 },
7800, 0x0f, 0x00, 18,
4, 3, 1, 5, 5, 5, 5, 0 },
10100, 0x0a, 0x00, 24,
6, 4, 1, 6, 6, 6, 6, 0 },
14100, 0x0e, 0x00, 36,
6, 6, 2, 7, 7, 7, 7, 0 },
17700, 0x09, 0x00, 48,
8, 10, 3, 8, 8, 8, 8, 0 },
23700, 0x0d, 0x00, 72,
8, 14, 3, 9, 9, 9, 9, 0 },
27400, 0x08, 0x00, 96,
8, 20, 3, 10, 10, 10, 10, 0 },
30900, 0x0c, 0x00, 108,
8, 23, 3, 11, 11, 11, 11, 0 },
6400, 0x80, 0x00, 0,
4, 2, 3, 12, 28, 12, 28, 3216 },
12700, 0x81, 0x00, 1,
6, 4, 3, 13, 29, 13, 29, 6434 },
18800, 0x82, 0x00, 2,
6, 6, 3, 14, 30, 14, 30, 9650 },
25000, 0x83, 0x00, 3,
8, 10, 3, 15, 31, 15, 31, 12868 },
36700, 0x84, 0x00, 4,
8, 14, 3, 16, 32, 16, 32, 19304 },
48100, 0x85, 0x00, 5,
8, 20, 3, 17, 33, 17, 33, 25740 },
53500, 0x86, 0x00, 6,
8, 23, 3, 18, 34, 18, 34, 28956 },
59000, 0x87, 0x00, 7,
8, 25, 3, 19, 35, 19, 36, 32180 },
12700, 0x88, 0x00, 8,
4, 2, 3, 20, 37, 20, 37, 6430 },
24800, 0x89, 0x00, 9,
6, 4, 3, 21, 38, 21, 38, 12860 },
36600, 0x8a, 0x00, 10,
6, 6, 3, 22, 39, 22, 39, 19300 },
48100, 0x8b, 0x00, 11,
8, 10, 3, 23, 40, 23, 40, 25736 },
69500, 0x8c, 0x00, 12,
8, 14, 3, 24, 41, 24, 41, 38600 },
89500, 0x8d, 0x00, 13,
8, 20, 3, 25, 42, 25, 42, 51472 },
98900, 0x8e, 0x00, 14,
8, 23, 3, 26, 43, 26, 44, 57890 },
108300, 0x8f, 0x00, 15,
8, 25, 3, 27, 44, 27, 45, 64320 },
13200, 0x80, 0x00, 0,
8, 2, 3, 12, 28, 28, 28, 6684 },
25900, 0x81, 0x00, 1,
8, 4, 3, 13, 29, 29, 29, 13368 },
38600, 0x82, 0x00, 2,
8, 6, 3, 14, 30, 30, 30, 20052 },
49800, 0x83, 0x00, 3,
8, 10, 3, 15, 31, 31, 31, 26738 },
72200, 0x84, 0x00, 4,
8, 14, 3, 16, 32, 32, 32, 40104 },
92900, 0x85, 0x00, 5,
8, 20, 3, 17, 33, 33, 33, 53476 },
121500, /* 121.5 Mb */
102700, 0x86, 0x00, 6,
8, 23, 3, 18, 34, 34, 34, 60156 },
112000, 0x87, 0x00, 7,
8, 23, 3, 19, 35, 36, 36, 66840 },
150000, /* 150 Mb */
122000, 0x87, 0x00, 7,
8, 25, 3, 19, 35, 36, 36, 74200 },
25800, 0x88, 0x00, 8,
8, 2, 3, 20, 37, 37, 37, 13360 },
49800, 0x89, 0x00, 9,
8, 4, 3, 21, 38, 38, 38, 26720 },
71900, 0x8a, 0x00, 10,
8, 6, 3, 22, 39, 39, 39, 40080 },
92500, 0x8b, 0x00, 11,
8, 10, 3, 23, 40, 40, 40, 53440 },
130300, 0x8c, 0x00, 12,
8, 14, 3, 24, 41, 41, 41, 80160 },
162800, 0x8d, 0x00, 13,
8, 20, 3, 25, 42, 42, 42, 106880 },
178200, 0x8e, 0x00, 14,
8, 23, 3, 26, 43, 43, 43, 120240 },
192100, 0x8f, 0x00, 15,
8, 23, 3, 27, 44, 45, 45, 133600 },
300000, /* 300 Mb */
207000, 0x8f, 0x00, 15,
8, 25, 3, 27, 44, 45, 45, 148400 },
},
50, /* probe interval */
50, /* rssi reduce interval */
WLAN_RC_HT_FLAG, /* Phy rates allowed initially */
};
8,
{0},
{
5400, 0x0b, 0x00, (0x80|12),
0, 2, 1, 0, 0 },
7800, 0x0f, 0x00, 18,
0, 3, 1, 1, 0 },
10000, 0x0a, 0x00, (0x80|24),
2, 4, 2, 2, 0 },
13900, 0x0e, 0x00, 36,
2, 6, 2, 3, 0 },
17300, 0x09, 0x00, (0x80|48),
4, 10, 3, 4, 0 },
23000, 0x0d, 0x00, 72,
4, 14, 3, 5, 0 },
27400, 0x08, 0x00, 96,
4, 19, 3, 6, 0 },
29300, 0x0c, 0x00, 108,
4, 23, 3, 7, 0 },
},
50, /* probe interval */
50, /* rssi reduce interval */
0, /* Phy rates allowed initially */
};
12,
{0},
{
900, 0x1b, 0x00, 2,
0, 0, 1, 0, 0 },
1900, 0x1a, 0x04, 4,
1, 1, 1, 1, 0 },
4900, 0x19, 0x04, 11,
2, 2, 2, 2, 0 },
8100, 0x18, 0x04, 22,
3, 3, 2, 3, 0 },
5400, 0x0b, 0x00, 12,
4, 2, 1, 4, 0 },
7800, 0x0f, 0x00, 18,
4, 3, 1, 5, 0 },
10000, 0x0a, 0x00, 24,
6, 4, 1, 6, 0 },
13900, 0x0e, 0x00, 36,
6, 6, 2, 7, 0 },
17300, 0x09, 0x00, 48,
8, 10, 3, 8, 0 },
23000, 0x0d, 0x00, 72,
8, 14, 3, 9, 0 },
27400, 0x08, 0x00, 96,
8, 19, 3, 10, 0 },
29300, 0x0c, 0x00, 108,
8, 23, 3, 11, 0 },
},
50, /* probe interval */
50, /* rssi reduce interval */
0, /* Phy rates allowed initially */
};
4,
{0},
{
900, 0x1b, 0x00, (0x80|2),
0, 0, 1, 0, 0 },
1800, 0x1a, 0x04, (0x80|4),
1, 1, 1, 1, 0 },
4300, 0x19, 0x04, (0x80|11),
1, 2, 2, 2, 0 },
7100, 0x18, 0x04, (0x80|22),
1, 4, 100, 3, 0 },
},
100, /* probe interval */
100, /* rssi reduce interval */
0, /* Phy rates allowed initially */
};
static inline int8_t
{
if (a >= b) {
if (b >= c)
return (b);
else if (a > c)
return (c);
else
return (a);
} else {
if (a >= c)
return (a);
else if (b >= c)
return (c);
else
return (b);
}
}
static void
struct ath_rate_priv *ath_rc_priv)
{
for (j = 0; j <= i-1; j++) {
}
}
}
}
static void
{
uint8_t i;
for (i = 0; i < ath_rc_priv->rate_table_size; i++)
ath_rc_priv->valid_rate_index[i] = 0;
}
static inline void
{
}
static inline int
/* LINTED E_STATIC_UNUSED */
{
}
/* ARGSUSED */
static inline int
struct ath_rate_priv *ath_rc_priv,
{
uint8_t i;
return (1);
}
}
/* No more valid rates */
*next_idx = 0;
return (0);
}
/* Return true only for single stream */
static int
{
return (0);
return (0);
return (0);
return (0);
return (0);
return (1);
}
/* ARGSUSED */
static inline int
struct ath_rate_priv *ath_rc_priv,
{
int8_t i;
return (1);
}
}
return (0);
}
static uint8_t
{
for (i = 0; i < rate_table->rate_cnt; i++) {
if (valid == 1) {
continue;
}
}
return (hi);
}
static uint8_t
struct ath_rate_table *rate_table,
struct ath_rateset *rateset,
{
/* Use intersection of working rates and valid rates */
for (j = 0; j < rate_table->rate_cnt; j++) {
/*
* We allow a rate only if its valid and the
* capflag matches one of the validity
*/
WLAN_RC_CAP_MODE(capflag)) &&
!WLAN_RC_PHY_HT(phy)) {
continue;
[valid_rate_count] = j;
}
}
}
return (hi);
}
static uint8_t
struct ath_rate_table *rate_table,
{
/* Use intersection of working rates and valid rates */
for (j = 0; j < rate_table->rate_cnt; j++) {
!WLAN_RC_PHY_HT(phy) ||
continue;
continue;
}
}
return (hi);
}
/* ARGSUSED */
static uint8_t
struct ath_rate_priv *ath_rc_priv,
struct ath_rate_table *rate_table,
int probe_allowed, int *is_probing,
int is_retry)
{
*is_probing = 0;
/*
* Age (reduce) last ack rssi based on how old it is.
* The bizarre numbers are so the delta is 160msec,
* meaning we divide by 16.
* 0msec <= dt <= 25msec: don't derate
* 25msec <= dt <= 185msec: derate linearly from 0 to 10dB
* 185msec <= dt: derate by 10dB
*/
/* now_msec = jiffies_to_msecs(jiffies); */
if (dt >= 185)
rssi_reduce = 10;
else if (dt >= 25)
/* Now reduce rssi_last by rssi_reduce */
if (rssi_last < rssi_reduce)
rssi_last = 0;
else
rssi_last -= rssi_reduce;
/*
* Now look up the rate in the rssi table and return it.
* If no rates match then we return 0 (lowest rate)
*/
best_thruput = 0;
minindex = 0;
/*
* Try the higher rate first. It will reduce memory moving time
* if we have very good channel characteristics.
*/
continue;
/*
* For TCP the average collision rate is around 11%,
* so we ignore PERs less than this. This is to
* prevent the rate we are currently using (whose
* PER might be in the 10-15 range because of TCP
* collisions) looking worse than the next lower
* rate whose PER has decayed close to 0. If we
* used to next lower rate, its PER would grow to
* 10-15 and we would be worse off then staying
* at the current rate.
*/
if (per_thres < 12)
per_thres = 12;
(100 - per_thres);
if (best_thruput <= this_thruput) {
}
}
/*
* if we are retrying for more than half the number
* of max retries, use the min rate for the next retry
*/
if (is_retry)
/*
* Must check the actual rate (ratekbps) to account for
* non-monoticity of 11g's rate table
*/
/* Probe the next allowed phy state */
/* FIXME:XXXX Check to make sure ratMax is checked properly */
rate_table->probe_interval) &&
*is_probing = 1;
}
}
return (rate);
}
static void
struct ath9k_tx_rate *rate,
int rtsctsenable)
{
#if 0
struct ieee80211_node *in;
#endif
if (rtsctsenable)
#if 0
}
#endif
}
/* ARGSUSED */
static uint8_t
struct ath_rate_priv *ath_rc_priv,
struct ath_rate_table *rate_table,
{
uint32_t j;
if (min_rate) {
for (j = RATE_TABLE_SIZE; j > 0; j--) {
else
break;
}
} else {
for (j = stepdown; j > 0; j--) {
else
break;
}
}
return (rix);
}
static void
{
if (*is_probe) {
/*
* set one try for probe rates. For the
* probes don't enable rts
*/
/*
* after the probe rate
*/
} else {
/* Set the choosen rate. No RTS for first series entry. */
}
/* Fill in the other rates for multirate retry */
for (; i < num_rates; i++) {
/* LINTED E_FALSE_LOGICAL_EXPR */
/* All other rates in the series have RTS enabled */
}
/*
* NB:Change rate series to enable aggregation when operating
* at lower MCS rates. When first rate in series is MCS2
* in HT40 @ 2.4GHz, series should look like:
*
* {MCS2, MCS1, MCS0, MCS0}.
*
* When first rate in series is MCS3 in HT20 @ 2.4GHz, series should
* look like:
*
* {MCS3, MCS2, MCS1, MCS1}
*
* So, set fourth rate in series to be same as third one for
* above conditions.
*/
if (i == 4 &&
}
}
}
/* ARGSUSED */
static boolean_t
struct ath_rate_table *rate_table,
struct ath_rate_priv *ath_rc_priv,
struct ath_tx_info_priv *tx_info_priv,
{
int count;
100 * 0 / 1,
100 * 1 / 4,
100 * 1 / 2,
100 * 3 / 4,
100 * 4 / 5,
100 * 5 / 6,
100 * 6 / 7,
100 * 7 / 8,
100 * 8 / 9,
100 * 9 / 10
};
if (xretries) {
if (xretries == 1) {
} else {
/* xretries == 2 */
/* new_PER = 7/8*old_PER + 1/8*(currentPER) */
}
/* xretries == 1 or 2 */
ath_rc_priv->probe_rate = 0;
} else { /* xretries == 0 */
if (tx_info_priv->n_bad_frames) {
/*
* new_PER = 7/8*old_PER + 1/8*(currentPER)
* Assuming that n_frames is not 0. The current PER
* from the retries is 100 * retries / (retries+1),
* since the first retries attempts failed, and the
* next one worked. For the one that worked,
* n_bad_frames subframes out of n_frames wored,
* so the PER for that part is
* 100 * n_bad_frames / n_frames, and it contributes
* 100 * n_bad_frames / (n_frames * (retries+1)) to
* the above PER. The expression below is a
* simplified version of the sum of these two terms.
*/
if (tx_info_priv->n_frames > 0) {
n_bad_frames = retries *
n_frames =
cur_per =
}
} else {
}
/*
* If we got at most one retry then increase the max rate if
* this was a probe. Otherwise, ignore the probe.
*/
if (ath_rc_priv->probe_rate &&
tx_info_priv->n_frames) {
/*
* Since we probed with just a single attempt,
* any retries means the probe failed. Also,
* if the attempt worked, but more than half
* the subframes were bad then also consider
* the probe a failure.
*/
ath_rc_priv->probe_rate = 0;
} else {
ath_rc_priv->probe_rate = 0;
/*
* Since this probe succeeded, we allow the next
* probe twice as soon. This allows the maxRate
* to move up faster if the probes are
* succesful.
*/
}
}
if (retries > 0) {
/*
* Don't update anything. We don't know if
* this was because of collisions or poor signal.
*
* Later: if rssi_ack is close to
* ath_rc_priv->state[txRate].rssi_thres and we see lots
* of retries, then we could increase
* ath_rc_priv->state[txRate].rssi_thres.
*/
} else {
/*
* It worked with no retries. First ignore bogus (small)
* rssi_ack values.
*/
}
goto exit;
/* Average the rssi */
ath_rc_priv->rssi_sum_cnt = 0;
}
goto exit;
ath_rc_priv->rssi_sum_cnt = 0;
/* Now reduce the current rssi threshold */
(rssi_thres > rssi_ack_vmin)) {
}
}
}
exit:
return (state_change);
}
/*
* Update PER, RSSI and whatever else that the code thinks
* it is doing. If you can make sense of all this, you really
* need to go out more.
*/
static void
struct ath_rate_priv *ath_rc_priv,
struct ath_tx_info_priv *tx_info_priv,
{
/* u32 now_msec = jiffies_to_msecs(jiffies); */
int rate;
return;
/* To compensate for some imbalance between ctrl and ext. channel */
/* Update PER first */
/*
* If this rate looks bad (high PER) then stop using it for
* a while (except if we are probing).
*/
/* Don't probe for a little while. */
}
if (state_change) {
/*
* Make sure the rates above this have higher rssi thresholds.
* (Note: Monotonicity is kept within the OFDM rates and
* within the CCK rates. However, no adjustment is
* made to keep the rssi thresholds monotonically
* increasing between the CCK and OFDM rates.)
*/
break;
}
}
/* Make sure the rates below this have lower rssi thresholds. */
break;
else {
}
}
}
}
}
/* Make sure the rates below this have lower PER */
/* Monotonicity is kept only for rates below the current rate. */
break;
}
}
}
/* Maintain monotonicity for rates above the current rate */
}
/*
* Every so often, we reduce the thresholds and
* PER (different for CCK and OFDM).
*/
}
}
/*
* Every so often, we reduce the thresholds
* and PER (different for CCK and OFDM).
*/
}
}
}
static int
struct ath9k_tx_rate *rate)
{
int rix;
else
return (rix);
}
static void
{
/*
* If the first rate is not the final index, there
* are intermediate rate failures to be processed.
*/
if (final_ts_idx != 0) {
/* Process intermediate rates that failed. */
for (i = 0; i < final_ts_idx; i++) {
/*
* If HT40 and we have switched mode from
* 40 to 20 => don't update
*/
if ((flags & ATH9K_TX_RC_40_MHZ_WIDTH) &&
(ath_rc_priv->rc_phy_mode !=
return;
rix =
}
}
} else {
/*
* Handle the special case of MIMO PS burst, where the second
* aggregate is sent out with only one rate and one try.
* Treating it as an excessive retry penalizes the rate
* inordinately.
*/
xretries = 2;
}
/* If HT40 and we have switched mode from 40 to 20 => don't update */
if ((flags & ATH9K_TX_RC_40_MHZ_WIDTH) &&
return;
}
}
static struct ath_rate_table *
{
int ath9k_mode;
switch (cur_mode) {
case IEEE80211_MODE_11A:
case IEEE80211_MODE_11NA:
if (is_ht)
if (is_cw_40)
break;
case IEEE80211_MODE_11B:
break;
case IEEE80211_MODE_11G:
case IEEE80211_MODE_11NG:
if (is_ht)
if (is_cw_40)
break;
default:
return (NULL);
}
switch (ath9k_mode) {
case ATH9K_MODE_11A:
break;
case ATH9K_MODE_11B:
break;
case ATH9K_MODE_11G:
break;
case ATH9K_MODE_11NA_HT20:
"choose rate table:ATH9K_MODE_11NA_HT20\n"));
break;
case ATH9K_MODE_11NA_HT40PLUS:
"choose rate table:ATH9K_MODE_11NA_HT40PLUS\n"));
break;
case ATH9K_MODE_11NG_HT20:
"choose rate table:ATH9K_MODE_11NG_HT20\n"));
break;
case ATH9K_MODE_11NG_HT40PLUS:
"choose rate table:ATH9K_MODE_11NG_HT40PLUS\n"));
break;
default:
arn_problem("Invalid band\n");
break;
}
ath9k_mode));
}
/* Private rate contral initialization */
static void
struct ath_rate_priv *ath_rc_priv,
struct ieee80211_node *in)
{
/* FIXME: Adhoc */
/* 20/40 support */
/* cur_rate_table would be set on init */
}
if (!rate_table) {
return;
}
/* 2.6.30 */
}
}
}
/*
* Initial rate table size. Will change depending
* on the working rate set
*/
/* Initialize thresholds according to the global rate table */
for (i = 0; i < ath_rc_priv->rate_table_size; i++) {
}
/* Determine the valid rates */
for (i = 0; i < WLAN_RC_PHY_MAX; i++) {
for (j = 0; j < MAX_TX_RATE_PHY; j++)
ath_rc_priv->valid_phy_rateidx[i][j] = 0;
ath_rc_priv->valid_phy_ratecnt[i] = 0;
}
/* Set stream capability */
/* No working rate, just initialize valid rates */
} else {
/* Use intersection of working rates and valid rates */
}
}
ath_rc_priv->rate_max_phy = 0;
for (i = 0, k = 0; i < WLAN_RC_PHY_MAX; i++) {
for (j = 0; j < ath_rc_priv->valid_phy_ratecnt[i]; j++) {
ath_rc_priv->valid_rate_index[k++] =
ath_rc_priv->valid_phy_rateidx[i][j];
}
!ath_rc_priv->valid_phy_ratecnt[i])
continue;
}
ASSERT(k <= RATE_TABLE_SIZE);
ath_rc_priv->max_valid_rate = k;
}
void
{
return;
return;
/*
* If underrun error is seen assume it as an excessive retry only
* if prefetch trigger level have reached the max (0x3f for 5416)
* Adjust the long retry as if the frame was tried ATH_11N_TXMAXTRY
* times. This affects how ratectrl updates PER for the failed rate.
*/
tx_status = 1;
is_underrun = 1;
}
tx_status = 1;
bf,
}
void
struct ieee80211_frame *wh)
{
int is_probe = 0;
uint8_t i;
1 : ATH_MGT_TXMAXTRY;
return;
}
/* Find tx rate for unicast frames */
/* Temporary workaround for 'dladm show-wifi' */
"in->in_rates.ir_rates[%d] = %d,"
"bf->rates[0].idx = %d,"
"rt->info[bf->rates[0].idx].dot11rate = %d\n",
i,
break;
}
/* Check if aggregation has to be enabled for this tid */
#ifdef ARN_TX_AGGREGATION
/* should check if enabled, not supported */
if (ieee80211_is_data_qos(wh)) {
/* to do */
}
}
#endif /* ARN_TX_AGGREGATION */
}
void
{
int i;
/* should be moved to arn_node_init later */
"ath_rc_priv->neg_rates.rs_rates[%d] = %d\n",
}
/* negotiated ht rate set ??? */
"ath_rc_priv->neg_ht_rates.rs_rates[%d] = %d\n",
}
/* arn_update_chainmask(sc); */
}
#ifdef ARN_TX_AGGREGATION
/* Temply put the following ht info init here */
(in->in_htparam != 0)) {
}
/* end */
#endif /* ARN_TX_AGGREGATION */
}
static void
struct ath_rate_table *rate_table)
{
int i;
for (i = 0; i < 256; i++)
for (i = 0; i < rate_table->rate_cnt; i++) {
cix,
B_FALSE);
cix,
B_TRUE);
}
}
void
{
}
#ifdef ARN_LEGACY_RC
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 (sc->sc_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
{
}
#endif /* ARN_LEGACY_RC */
/*
* Reset the rate control state for each 802.11 state transition.
*/
void
{
/*
* Reset local xmit state; this is really only
* meaningful when operating in station mode.
*/
#ifdef ARN_LEGACY_RC
if (state == IEEE80211_S_RUN) {
} else {
}
#else
if (state == IEEE80211_S_RUN)
#endif
/* LINTED E_NOP_ELSE_STMT */
} 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.
*/
#ifdef ARN_LEGACY_RC
#endif
}
}
#ifdef ARN_LEGACY_RC
/*
* 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)
}
#endif /* ARN_LEGACY_RC */