PERFORCE change 137113 for review
Sam Leffler
sam at FreeBSD.org
Fri Mar 7 20:39:43 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=137113
Change 137113 by sam at sam_ebb on 2008/03/07 20:38:57
convert ni_txrate handling from setting the rate index to the
rate code; change algorithms that use ni_txrate directly to
maintain a private value
Affected files ...
.. //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.c#7 edit
.. //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.h#3 edit
.. //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.c#10 edit
.. //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.h#6 edit
.. //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.c#8 edit
Differences ...
==== //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.c#7 (text+ko) ====
@@ -210,7 +210,7 @@
ni->ni_rates.rs_nrates > 0 ?
(ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
- ni->ni_txrate = rate;
+ amn->amn_rix = rate;
/*
* Before associating a node has no rate set setup
* so we can't calculate any transmit codes to use.
@@ -219,8 +219,8 @@
* lowest hardware rate.
*/
if (ni->ni_rates.rs_nrates > 0) {
- amn->amn_tx_rix0 = sc->sc_rixmap[
- ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL];
+ ni->ni_txrate = ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL;
+ amn->amn_tx_rix0 = sc->sc_rixmap[ni->ni_txrate];
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;
@@ -391,7 +391,7 @@
{
struct ath_softc *sc = arg;
struct amrr_node *amn = ATH_NODE_AMRR(ATH_NODE (ni));
- int old_rate;
+ int rix;
#define is_success(amn) \
(amn->amn_tx_try1_cnt < (amn->amn_tx_try0_cnt/10))
@@ -399,12 +399,8 @@
(amn->amn_tx_try0_cnt > 10)
#define is_failure(amn) \
(amn->amn_tx_try1_cnt > (amn->amn_tx_try0_cnt/3))
-#define is_max_rate(ni) \
-((ni->ni_txrate + 1) >= ni->ni_rates.rs_nrates)
-#define is_min_rate(ni) \
-(ni->ni_txrate == 0)
- old_rate = ni->ni_txrate;
+ rix = amn->amn_rix;
DPRINTF (sc, "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d\n",
amn->amn_tx_try0_cnt,
@@ -415,17 +411,17 @@
if (is_success (amn) && is_enough (amn)) {
amn->amn_success++;
if (amn->amn_success == amn->amn_success_threshold &&
- !is_max_rate (ni)) {
+ rix + 1 < ni->ni_rates.rs_nrates) {
amn->amn_recovery = 1;
amn->amn_success = 0;
- ni->ni_txrate++;
- DPRINTF (sc, "increase rate to %d\n", ni->ni_txrate);
+ rix++;
+ DPRINTF (sc, "increase rate to %d\n", rix);
} else {
amn->amn_recovery = 0;
}
} else if (is_failure (amn)) {
amn->amn_success = 0;
- if (!is_min_rate (ni)) {
+ if (rix > 0) {
if (amn->amn_recovery) {
/* recovery failure. */
amn->amn_success_threshold *= 2;
@@ -438,13 +434,13 @@
DPRINTF (sc, "decrease rate normal thr: %d\n", amn->amn_success_threshold);
}
amn->amn_recovery = 0;
- ni->ni_txrate--;
+ rix--;
} else {
amn->amn_recovery = 0;
}
}
- if (is_enough (amn) || old_rate != ni->ni_txrate) {
+ if (is_enough (amn) || rix != amn->amn_rix) {
/* reset counters. */
amn->amn_tx_try0_cnt = 0;
amn->amn_tx_try1_cnt = 0;
@@ -452,8 +448,8 @@
amn->amn_tx_try3_cnt = 0;
amn->amn_tx_failure_cnt = 0;
}
- if (old_rate != ni->ni_txrate) {
- ath_rate_update(sc, ni, ni->ni_txrate);
+ if (rix != amn->amn_rix) {
+ ath_rate_update(sc, ni, rix);
}
}
==== //depot/projects/vap/sys/dev/ath/ath_rate/amrr/amrr.h#3 (text+ko) ====
@@ -48,6 +48,7 @@
/* per-node state */
struct amrr_node {
+ int amn_rix; /* current rate index */
/* AMRR statistics for this node */
u_int amn_tx_try0_cnt;
u_int amn_tx_try1_cnt;
==== //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.c#10 (text+ko) ====
@@ -187,7 +187,6 @@
ni->ni_rates.rs_nrates > 0 ?
(ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
- ni->ni_txrate = rate;
/*
* Before associating a node has no rate set setup
* so we can't calculate any transmit codes to use.
@@ -197,8 +196,9 @@
*/
if (ni->ni_rates.rs_nrates == 0)
goto done;
- on->on_tx_rix0 = sc->sc_rixmap[
- ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL];
+ on->on_rix = rate;
+ ni->ni_txrate = ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL;
+ on->on_tx_rix0 = sc->sc_rixmap[ni->ni_txrate];
on->on_tx_rate0 = rt->info[on->on_tx_rix0].rateCode;
on->on_tx_rate0sp = on->on_tx_rate0 |
@@ -395,7 +395,7 @@
on->on_tx_ok, on->on_tx_err, on->on_tx_retr,
on->on_tx_upper, dir);
- nrate = ni->ni_txrate;
+ nrate = on->on_rix;
switch (dir) {
case 0:
if (enough && on->on_tx_upper > 0)
@@ -420,10 +420,10 @@
break;
}
- if (nrate != ni->ni_txrate) {
+ if (nrate != on->on_rix) {
DPRINTF(sc, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n",
__func__,
- (rs->rs_rates[ni->ni_txrate] & IEEE80211_RATE_VAL) / 2,
+ ni->ni_txrate / 2,
(rs->rs_rates[nrate] & IEEE80211_RATE_VAL) / 2,
on->on_tx_ok, on->on_tx_err, on->on_tx_retr);
ath_rate_update(sc, ni, nrate);
==== //depot/projects/vap/sys/dev/ath/ath_rate/onoe/onoe.h#6 (text+ko) ====
@@ -43,6 +43,7 @@
/* per-node state */
struct onoe_node {
+ int on_rix; /* current rate index */
u_int on_tx_ok; /* tx ok pkt */
u_int on_tx_err; /* tx !ok pkt */
u_int on_tx_retr; /* tx retry count */
==== //depot/projects/vap/sys/dev/ath/ath_rate/sample/sample.c#8 (text+ko) ====
@@ -340,16 +340,13 @@
sn->packets_since_switch[size_bin] = 0;
sn->current_rate[size_bin] = best_ndx;
sn->ticks_since_switch[size_bin] = ticks;
+ /*
+ * Set the visible txrate for this node.
+ */
+ an->an_node.ni_txrate = sn->rates[best_ndx].rate;
}
ndx = sn->current_rate[size_bin];
sn->packets_since_switch[size_bin]++;
- if (size_bin == 0) {
- /*
- * set the visible txrate for this node
- * to the rate of small packets
- */
- an->an_node.ni_txrate = ndx;
- }
}
}
@@ -722,8 +719,6 @@
}
DPRINTF(sc, ATH_DEBUG_RATE, "%s\n", "");
- /* set the visible bit-rate to the lowest one available */
- ni->ni_txrate = 0;
sn->num_rates = ni->ni_rates.rs_nrates;
for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) {
@@ -767,10 +762,11 @@
sn->stats[1][sn->num_rates-1].perfect_tx_time
);
- if (sn->static_rate_ndx != -1)
- ni->ni_txrate = sn->static_rate_ndx;
+ /* set the visible bit-rate */
+ if (sn->static_rate_ndx != -1)
+ ni->ni_txrate = sn->rates[sn->static_rate_ndx].rate;
else
- ni->ni_txrate = sn->current_rate[0];
+ ni->ni_txrate = sn->rates[0].rate;
#undef RATE
}
More information about the p4-projects
mailing list