Date: Mon, 18 Jan 2016 05:43:35 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294248 - head/sys/dev/iwm Message-ID: <201601180543.u0I5hZUv028987@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: adrian Date: Mon Jan 18 05:43:34 2016 New Revision: 294248 URL: https://svnweb.freebsd.org/changeset/base/294248 Log: [iwm] fix up the rate control setup code to initialise rates in the order we want to use it. The rate table was being initialised in low->high, but the link quality table was being initialised high->low. So, when we did a lookup, we would get the indexes wrong. This started by a patch from dragonflybsd which reversed how the ni->in_ridx[] array is being used; I'd rather it all be consistent. So, this is consistent. Inspired by: what I did to iwn(4) a while ago Inspired by: DragonflyBSD; <imre@vdsz.com> Modified: head/sys/dev/iwm/if_iwm.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Mon Jan 18 04:41:11 2016 (r294247) +++ head/sys/dev/iwm/if_iwm.c Mon Jan 18 05:43:34 2016 (r294248) @@ -3373,6 +3373,11 @@ iwm_setrates(struct iwm_softc *sc, struc "only %zu\n", __func__, nrates, nitems(lq->rs_table)); return; } + if (nrates == 0) { + device_printf(sc->sc_dev, + "%s: node supports 0 rates, odd!\n", __func__); + return; + } /* * XXX .. and most of iwm_node is not initialised explicitly; @@ -3384,8 +3389,14 @@ iwm_setrates(struct iwm_softc *sc, struc memset(&in->in_ridx, -1, sizeof(in->in_ridx)); IWM_DPRINTF(sc, IWM_DEBUG_TXRATE, "%s: nrates=%d\n", __func__, nrates); - for (i = 0; i < nrates; i++) { - int rate = ni->ni_rates.rs_rates[i] & IEEE80211_RATE_VAL; + + /* + * Loop over nrates and populate in_ridx from the highest + * rate to the lowest rate. Remember, in_ridx[] has + * IEEE80211_RATE_MAXSIZE entries! + */ + for (i = 0; i < min(nrates, IEEE80211_RATE_MAXSIZE); i++) { + int rate = ni->ni_rates.rs_rates[(nrates - 1) - i] & IEEE80211_RATE_VAL; /* Map 802.11 rate to HW rate index. */ for (ridx = 0; ridx <= IWM_RIDX_MAX; ridx++) @@ -3442,7 +3453,7 @@ iwm_setrates(struct iwm_softc *sc, struc * our hardware table containing the * configuration to use for this rate. */ - ridx = in->in_ridx[(nrates-1)-i]; + ridx = in->in_ridx[i]; tab = iwm_rates[ridx].plcp; tab |= nextant << IWM_RATE_MCS_ANT_POS; if (IWM_RIDX_IS_CCK(ridx))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601180543.u0I5hZUv028987>