void ath_rate_setupxtxdesc(struct ath_softc *sc, struct ath_node *an, struct ath_desc *ds, int shortPreamble, u_int8_t rix) { struct onoe_node *on = ATH_NODE_ONOE(an); ath_hal_setupxtxdesc(sc->sc_ah, ds , on->on_tx_rate1sp, 2 /* series 1 */ , on->on_tx_rate2sp, 2 /* series 2 */ , on->on_tx_rate3sp, 2 /* series 3 */ ); }
void ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an, const struct ath_desc *ds, const struct ath_desc *ds0) { struct onoe_node *on = ATH_NODE_ONOE(an); if (ds->ds_txstat.ts_status == 0) on->on_tx_ok++; else on->on_tx_err++; on->on_tx_retr += ds->ds_txstat.ts_shortretry + ds->ds_txstat.ts_longretry; }
void ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, int shortPreamble, size_t frameLen, u_int8_t *rix, int *try0, u_int8_t *txrate) { struct onoe_node *on = ATH_NODE_ONOE(an); *rix = on->on_tx_rix0; *try0 = on->on_tx_try0; if (shortPreamble) *txrate = on->on_tx_rate0sp; else *txrate = on->on_tx_rate0; }
static void ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an, const struct ath_desc *ds) { struct onoe_node *on = ATH_NODE_ONOE(an); if (ds->ds_txstat.ts_status == 0) on->on_tx_ok++; else on->on_tx_err++; on->on_tx_retr += ds->ds_txstat.ts_shortretry + ds->ds_txstat.ts_longretry; if (jiffies >= on->on_nextcheck) { ath_rate_ctl(sc, &an->an_node); /* XXX halve rate for station mode */ on->on_nextcheck = jiffies + (ath_rateinterval * HZ) / 1000; } }
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 nframes, int nbad) { struct onoe_node *on = ATH_NODE_ONOE(an); if (ts->ts_status == 0) on->on_tx_ok++; else on->on_tx_err++; on->on_tx_retr += ts->ts_shortretry + ts->ts_longretry; if (on->on_interval != 0 && ticks - on->on_ticks > on->on_interval) { ath_rate_ctl(sc, &an->an_node); on->on_ticks = ticks; } }
/* * Get the TX rates. * * The short preamble bits aren't set here; the caller should augment * the returned rate with the relevant preamble rate flag. */ void ath_rate_getxtxrates(struct ath_softc *sc, struct ath_node *an, uint8_t rix0, struct ath_rc_series *rc) { struct onoe_node *on = ATH_NODE_ONOE(an); rc[0].flags = rc[1].flags = rc[2].flags = rc[3].flags = 0; rc[0].rix = on->on_tx_rate0; rc[1].rix = on->on_tx_rate1; rc[2].rix = on->on_tx_rate2; rc[3].rix = on->on_tx_rate3; rc[0].tries = on->on_tx_try0; rc[1].tries = 2; rc[2].tries = 2; rc[3].tries = 2; }
/* * Examine and potentially adjust the transmit rate. */ static void ath_rate_ctl(void *arg, struct ieee80211_node *ni) { struct ath_softc *sc = arg; struct onoe_node *on = ATH_NODE_ONOE(ATH_NODE(ni)); struct ieee80211_rateset *rs = &ni->ni_rates; int dir = 0, nrate, enough; /* * Rate control * XXX: very primitive version. */ enough = (on->on_tx_ok + on->on_tx_err >= 10); /* no packet reached -> down */ if (on->on_tx_err > 0 && on->on_tx_ok == 0) dir = -1; /* all packets needs retry in average -> down */ if (enough && on->on_tx_ok < on->on_tx_retr) dir = -1; /* no error and less than rate_raise% of packets need retry -> up */ if (enough && on->on_tx_err == 0 && on->on_tx_retr < (on->on_tx_ok * ath_rate_raise) / 100) dir = 1; DPRINTF(sc, "%s: ok %d err %d retr %d upper %d dir %d\n", ether_sprintf(ni->ni_macaddr), on->on_tx_ok, on->on_tx_err, on->on_tx_retr, on->on_tx_upper, dir); nrate = ni->ni_txrate; switch (dir) { case 0: if (enough && on->on_tx_upper > 0) on->on_tx_upper--; break; case -1: if (nrate > 0) { nrate--; sc->sc_stats.ast_rate_drop++; } on->on_tx_upper = 0; break; case 1: /* raise rate if we hit rate_raise_threshold */ if (++on->on_tx_upper < ath_rate_raise_threshold) break; on->on_tx_upper = 0; if (nrate + 1 < rs->rs_nrates) { nrate++; sc->sc_stats.ast_rate_raise++; } break; } if (nrate != ni->ni_txrate) { DPRINTF(sc, "%s: %dM -> %dM (%d ok, %d err, %d retr)\n", __func__, (rs->rs_rates[ni->ni_txrate] & IEEE80211_RATE_VAL) / 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); } else if (enough) on->on_tx_ok = on->on_tx_err = on->on_tx_retr = 0; }
static void ath_rate_update(struct ath_softc *sc, struct ieee80211_node *ni, int rate) { struct ath_node *an = ATH_NODE(ni); struct onoe_node *on = ATH_NODE_ONOE(an); const HAL_RATE_TABLE *rt = sc->sc_currates; u_int8_t rix; KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); DPRINTF(sc, "%s: set xmit rate for %s to %dM\n", __func__, ether_sprintf(ni->ni_macaddr), 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. * This is ok since we should never be sending anything * but management frames and those always go at the * lowest hardware rate. */ 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_tx_rate0 = rt->info[on->on_tx_rix0].rateCode; on->on_tx_rate0sp = on->on_tx_rate0 | rt->info[on->on_tx_rix0].shortPreamble; 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). */ on->on_tx_try0 = 1 + 3; /* 4 tries at rate 0 */ if (--rate >= 0) { rix = sc->sc_rixmap[ ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL]; on->on_tx_rate1 = rt->info[rix].rateCode; on->on_tx_rate1sp = on->on_tx_rate1 | rt->info[rix].shortPreamble; } else { on->on_tx_rate1 = on->on_tx_rate1sp = 0; } if (--rate >= 0) { rix = sc->sc_rixmap[ ni->ni_rates.rs_rates[rate]&IEEE80211_RATE_VAL]; on->on_tx_rate2 = rt->info[rix].rateCode; on->on_tx_rate2sp = on->on_tx_rate2 | rt->info[rix].shortPreamble; } else { on->on_tx_rate2 = on->on_tx_rate2sp = 0; } if (rate > 0) { /* NB: only do this if we didn't already do it above */ on->on_tx_rate3 = rt->info[0].rateCode; on->on_tx_rate3sp = on->on_tx_rate3 | rt->info[0].shortPreamble; } else { on->on_tx_rate3 = on->on_tx_rate3sp = 0; } } else { on->on_tx_try0 = ATH_TXMAXTRY; /* max tries at rate 0 */ on->on_tx_rate1 = on->on_tx_rate1sp = 0; on->on_tx_rate2 = on->on_tx_rate2sp = 0; on->on_tx_rate3 = on->on_tx_rate3sp = 0; } done: on->on_tx_ok = on->on_tx_err = on->on_tx_retr = on->on_tx_upper = 0; }
*txrate = on->on_tx_rate0sp; else *txrate = on->on_tx_rate0; } /* * Get the TX rates. * * The short preamble bits aren't set here; the caller should augment * the returned rate with the relevant preamble rate flag. */ void ath_rate_getxtxrates(struct ath_softc *sc, struct ath_node *an, uint8_t rix0, uint8_t *rix, uint8_t *try) { struct onoe_node *on = ATH_NODE_ONOE(an); /* rix[0] = on->on_tx_rate0; */ rix[1] = on->on_tx_rate1; rix[2] = on->on_tx_rate2; rix[3] = on->on_tx_rate3; try[0] = on->on_tx_try0; try[1] = 2; try[2] = 2; try[3] = 2; } void ath_rate_setupxtxdesc(struct ath_softc *sc, struct ath_node *an, struct ath_desc *ds, int shortPreamble, u_int8_t rix)