44#include <sys/sysctl.h>
45#include <sys/kernel.h>
50#include <machine/bus.h>
51#include <machine/resource.h>
54#include <sys/socket.h>
57#include <net/if_media.h>
58#include <net/if_arp.h>
59#include <net/ethernet.h>
61#include <net80211/ieee80211_var.h>
66#include <netinet/in.h>
67#include <netinet/if_ether.h>
100static void ath_rate_ctl(
void *,
struct ieee80211_node *);
115 int shortPreamble,
size_t frameLen,
int tid,
int is_aggr,
116 u_int8_t *rix,
int *try0, u_int8_t *txrate,
int *maxdur,
158 struct ath_desc *ds,
int shortPreamble, u_int8_t rix)
172 int frame_size,
int rc_framesize,
int nframes,
int nbad)
205 struct ieee80211vap *vap = ni->ni_vap;
209 KASSERT(rt != NULL, (
"no rate table, mode %u", sc->
sc_curmode));
211 IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, ni,
212 "%s: set xmit rate to %dM", __func__,
213 ni->ni_rates.rs_nrates > 0 ?
214 (ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL) / 2 : 0);
223 if (ni->ni_rates.rs_nrates == 0)
226 ni->ni_txrate = ni->ni_rates.rs_rates[rate] & IEEE80211_RATE_VAL;
243 ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
252 ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL];
277 if (vap->iv_opmode == IEEE80211_M_STA)
288#define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL)
289 const struct ieee80211_txparam *tp = ni->ni_txparms;
292 KASSERT(ni->ni_rates.rs_nrates > 0, (
"no rates"));
293 if (tp == NULL || tp->ucastrate == IEEE80211_FIXED_RATE_NONE) {
299 srate = ni->ni_rates.rs_nrates - 1;
306 for (; srate >= 0 &&
RATE(srate) > 72; srate--)
318 srate = ni->ni_rates.rs_nrates - 1;
319 for (; srate >= 0 &&
RATE(srate) != tp->ucastrate; srate--)
340 struct ieee80211_rateset *rs = &ni->ni_rates;
341 int dir = 0, nrate, enough;
362 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
363 "ok %d err %d retr %d upper %d dir %d",
384 if (nrate + 1 < rs->rs_nrates) {
391 if (nrate != on->
on_rix) {
392 IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni,
393 "%s: %dM -> %dM (%d ok, %d err, %d retr)", __func__,
395 (rs->rs_rates[nrate] & IEEE80211_RATE_VAL) / 2,
405 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->
sc_dev);
406 struct sysctl_oid *tree = device_get_sysctl_tree(sc->
sc_dev);
408 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
410 "rate control: operation interval (ms)");
412 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
414 "rate control: retry threshold to credit rate raise (%%)");
415 SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
417 "rate control: # good periods before raising rate");
433 osc = malloc(
sizeof(
struct onoe_softc), M_DEVBUF, M_NOWAIT|M_ZERO);
#define ath_hal_setupxtxdesc(_ah, _ds, _txr1, _txtr1, _txr2, _txtr2, _txr3, _txtr3)
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 ath_rate_ctl_start(struct ath_softc *, struct ieee80211_node *)
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_rateinterval
static int ath_rate_raise_threshold
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 int ath_rate_raise
static void ath_rate_update(struct ath_softc *, struct ieee80211_node *, int rate)
#define ATH_NODE_ONOE(an)
struct HAL_RATE_TABLE::@3 info[64]
struct ieee80211_node an_node
const HAL_RATE_TABLE * sc_currates
enum ieee80211_phymode sc_curmode
struct ath_stats sc_stats