diff --git a/sys/dev/ath/ath_rate/sample/sample.c b/sys/dev/ath/ath_rate/sample/sample.c index 47ca0630660c..7b96cb365038 100644 --- a/sys/dev/ath/ath_rate/sample/sample.c +++ b/sys/dev/ath/ath_rate/sample/sample.c @@ -495,6 +495,14 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, ath_rate_update_static_rix(sc, &an->an_node); + if (sn->currates != sc->sc_currates) { + device_printf(sc->sc_dev, "%s: currates != sc_currates!\n", + __func__); + rix = 0; + *try0 = ATH_TXMAXTRY; + goto done; + } + if (sn->static_rix != -1) { rix = sn->static_rix; *try0 = ATH_TXMAXTRY; @@ -621,6 +629,20 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, } *try0 = mrr ? sn->sched[rix].t0 : ATH_TXMAXTRY; done: + + /* + * This bug totally sucks and should be fixed. + * + * For now though, let's not panic, so we can start to figure + * out how to better reproduce it. + */ + if (rix < 0 || rix >= rt->rateCount) { + printf("%s: ERROR: rix %d out of bounds (rateCount=%d)\n", + __func__, + rix, + rt->rateCount); + rix = 0; /* XXX just default for now */ + } KASSERT(rix >= 0 && rix < rt->rateCount, ("rix is %d", rix)); *rix0 = rix; @@ -1073,6 +1095,8 @@ ath_rate_ctl_reset(struct ath_softc *sc, struct ieee80211_node *ni) sn->static_rix = -1; ath_rate_update_static_rix(sc, ni); + sn->currates = sc->sc_currates; + /* * Construct a bitmask of usable rates. This has all * negotiated rates minus those marked by the hal as diff --git a/sys/dev/ath/ath_rate/sample/sample.h b/sys/dev/ath/ath_rate/sample/sample.h index 805ae463c00c..bb72c0a2329e 100644 --- a/sys/dev/ath/ath_rate/sample/sample.h +++ b/sys/dev/ath/ath_rate/sample/sample.h @@ -86,6 +86,8 @@ struct sample_node { uint32_t ratemask; /* bit mask of valid rate indices */ const struct txschedule *sched; /* tx schedule table */ + const HAL_RATE_TABLE *currates; + struct rate_stats stats[NUM_PACKET_SIZE_BINS][SAMPLE_MAXRATES]; int last_sample_rix[NUM_PACKET_SIZE_BINS];