Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ath/ath_rate/amrr/amrr.c
Show First 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Set the starting transmit rate for a node. | * Set the starting transmit rate for a node. | ||||
*/ | */ | ||||
static void | static void | ||||
ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni) | ath_rate_ctl_start(struct ath_softc *sc, struct ieee80211_node *ni) | ||||
{ | { | ||||
#define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL) | #define RV(_ix) (ieee80211_get_rate(rs->rates[(_ix)].rs_index)->value) | ||||
const struct ieee80211_txparam *tp = ni->ni_txparms; | const struct ieee80211_txparam_vht *tp = ni->ni_txparms; | ||||
const struct ieee80211_rateset *rs = ni->ni_rates; | |||||
int srate; | int srate; | ||||
KASSERT(ni->ni_rates.rs_nrates > 0, ("no rates")); | KASSERT(rs->rs_nrates > 0, ("no rates")); | ||||
if (tp == NULL || tp->ucastrate == IEEE80211_FIXED_RATE_NONE) { | |||||
srate = rs->rs_nrates - 1; | |||||
if (tp == NULL || tp->ucastrate == IEEE80211_RATE_NONEXISTENT) { | |||||
/* | /* | ||||
* No fixed rate is requested. For 11b start with | * No fixed rate is requested. For 11b start with | ||||
* the highest negotiated rate; otherwise, for 11g | * the highest negotiated rate; otherwise, for 11g | ||||
* and 11a, we start "in the middle" at 24Mb or 36Mb. | * 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) { | if (sc->sc_curmode != IEEE80211_MODE_11B) { | ||||
/* | /* | ||||
* Scan the negotiated rate set to find the | * Scan the negotiated rate set to find the | ||||
* closest rate. | * closest rate. | ||||
*/ | */ | ||||
/* NB: the rate set is assumed sorted */ | /* NB: the rate set is assumed sorted */ | ||||
for (; srate >= 0 && RATE(srate) > 72; srate--) | for (; srate >= 0 && RV(srate) > 72; srate--) | ||||
; | ; | ||||
} | } | ||||
} else { | } else { | ||||
/* | /* | ||||
* A fixed rate is to be used; ic_fixed_rate is the | * A fixed rate is to be used; ic_fixed_rate is the | ||||
* IEEE code for this rate (sans basic bit). Convert this | * IEEE code for this rate (sans basic bit). Convert this | ||||
* to the index into the negotiated rate set for | * to the index into the negotiated rate set for | ||||
* the node. We know the rate is there because the | * the node. We know the rate is there because the | ||||
* rate set is checked when the station associates. | * rate set is checked when the station associates. | ||||
*/ | */ | ||||
/* NB: the rate set is assumed sorted */ | /* NB: the rate set is assumed sorted */ | ||||
srate = ni->ni_rates.rs_nrates - 1; | for (; srate >= 0; srate--) | ||||
for (; srate >= 0 && RATE(srate) != tp->ucastrate; srate--) | if (rs->rates[srate].rs_index == tp->ucastrate) | ||||
; | break; | ||||
} | } | ||||
/* | /* | ||||
* The selected rate may not be available due to races | * The selected rate may not be available due to races | ||||
* and mode settings. Also orphaned nodes created in | * and mode settings. Also orphaned nodes created in | ||||
* adhoc mode may not have any rate set so this lookup | * adhoc mode may not have any rate set so this lookup | ||||
* can fail. This is not fatal. | * can fail. This is not fatal. | ||||
*/ | */ | ||||
ath_rate_update(sc, ni, srate < 0 ? 0 : srate); | ath_rate_update(sc, ni, srate < 0 ? 0 : srate); | ||||
#undef RATE | #undef RV | ||||
} | } | ||||
/* | /* | ||||
* Examine and potentially adjust the transmit rate. | * Examine and potentially adjust the transmit rate. | ||||
*/ | */ | ||||
static void | static void | ||||
ath_rate_ctl(void *arg, struct ieee80211_node *ni) | ath_rate_ctl(void *arg, struct ieee80211_node *ni) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |