56#include <sys/sysctl.h>
57#include <sys/kernel.h>
62#include <machine/bus.h>
63#include <machine/resource.h>
66#include <sys/socket.h>
69#include <net/if_media.h>
70#include <net/if_arp.h>
72#include <net80211/ieee80211_var.h>
77#include <netinet/in.h>
78#include <netinet/if_ether.h>
92static void ath_rate_ctl(
void *,
struct ieee80211_node *);
107 int shortPreamble,
size_t frameLen,
int tid,
int is_aggr,
108 u_int8_t *rix,
int *try0, u_int8_t *txrate,
int *maxdur,
150 struct ath_desc *ds,
int shortPreamble, u_int8_t rix)
164 int frame_size,
int rc_framesize,
int nframes,
int nbad)
169 int retry_count = sr + lr;
172 if (retry_count == 1) {
174 }
else if (retry_count == 2) {
177 }
else if (retry_count == 3) {
181 }
else if (retry_count > 3) {
230 struct ieee80211vap *vap = ni->ni_vap;
234 KASSERT(rt != NULL, (
"no rate table, mode %u", sc->
sc_curmode));
236 IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, ni,
237 "%s: set xmit rate to %dM", __func__,
238 ni->ni_rates.rs_nrates > 0 ?
239 (ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
249 if (ni->ni_rates.rs_nrates > 0) {
250 ni->ni_txrate = ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL;
262 ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
271 ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
302 if (vap->iv_opmode == IEEE80211_M_STA)
313#define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
314 const struct ieee80211_txparam *tp = ni->ni_txparms;
317 KASSERT(ni->ni_rates.rs_nrates > 0, (
"no rates"));
318 if (tp == NULL || tp->ucastrate == IEEE80211_FIXED_RATE_NONE) {
324 srate = ni->ni_rates.rs_nrates - 1;
331 for (; srate >= 0 &&
RATE(srate) > 72; srate--)
343 srate = ni->ni_rates.rs_nrates - 1;
344 for (; srate >= 0 &&
RATE(srate) != tp->ucastrate; srate--)
367#define is_success(amn) \
368(amn->amn_tx_try1_cnt < (amn->amn_tx_try0_cnt/10))
369#define is_enough(amn) \
370(amn->amn_tx_try0_cnt > 10)
371#define is_failure(amn) \
372(amn->amn_tx_try1_cnt > (amn->amn_tx_try0_cnt/3))
376 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
377 "cnt0: %d cnt1: %d cnt2: %d cnt3: %d -- threshold: %d",
383 rix + 1 < ni->ni_rates.rs_nrates) {
387 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
388 "increase rate to %d", rix);
400 IEEE80211_NOTE(ni->ni_vap,
401 IEEE80211_MSG_RATECTL, ni,
402 "decrease rate recovery thr: %d",
407 IEEE80211_NOTE(ni->ni_vap,
408 IEEE80211_MSG_RATECTL, ni,
409 "decrease rate normal thr: %d",
442 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->
sc_dev);
443 struct sysctl_oid *tree = device_get_sysctl_tree(sc->
sc_dev);
445 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
447 "rate control: operation interval (ms)");
449 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
450 "max_sucess_threshold", CTLFLAG_RW,
452 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
453 "min_sucess_threshold", CTLFLAG_RW,
462 asc = malloc(
sizeof(
struct amrr_softc), M_DEVBUF, M_NOWAIT|M_ZERO);
static int ath_rate_fetch_node_stats(struct ath_softc *sc, struct ath_node *an, struct ath_rateioctl *re)
void ath_rate_node_init(struct ath_softc *sc, struct ath_node *an)
static void node_reset(struct amrr_node *amn)
static void ath_rate_ctl_start(struct ath_softc *, struct ieee80211_node *)
static int ath_rate_min_success_threshold
static void ath_rate_sysctlattach(struct ath_softc *sc)
void ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, int shortPreamble, size_t frameLen, int tid, int is_aggr, u_int8_t *rix, int *try0, u_int8_t *txrate, int *maxdur, int *maxpktlen)
void ath_rate_newassoc(struct ath_softc *sc, struct ath_node *an, int isnew)
void ath_rate_getxtxrates(struct ath_softc *sc, struct ath_node *an, uint8_t rix0, int is_aggr, struct ath_rc_series *rc)
void ath_rate_update_rx_rssi(struct ath_softc *sc, struct ath_node *an, int rssi)
void ath_rate_detach(struct ath_ratectrl *arc)
struct ath_ratectrl * ath_rate_attach(struct ath_softc *sc)
static void ath_rate_ctl(void *, struct ieee80211_node *)
void ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an, const struct ath_rc_series *rc, const struct ath_tx_status *ts, int frame_size, int rc_framesize, int nframes, int nbad)
static int ath_rate_max_success_threshold
static int ath_rateinterval
void ath_rate_setupxtxdesc(struct ath_softc *sc, struct ath_node *an, struct ath_desc *ds, int shortPreamble, u_int8_t rix)
void ath_rate_node_cleanup(struct ath_softc *sc, struct ath_node *an)
static void ath_rate_update(struct ath_softc *, struct ieee80211_node *, int rate)
#define ATH_NODE_AMRR(an)
#define ath_hal_setupxtxdesc(_ah, _ds, _txr1, _txtr1, _txr2, _txtr2, _txr3, _txtr3)
struct HAL_RATE_TABLE::@3 info[64]
u_int amn_success_threshold
struct ieee80211_node an_node
const HAL_RATE_TABLE * sc_currates
enum ieee80211_phymode sc_curmode