From owner-svn-src-all@freebsd.org Mon Jan 18 05:43:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4FDE4A86B66; Mon, 18 Jan 2016 05:43:36 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 06C731E84; Mon, 18 Jan 2016 05:43:35 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0I5hZKS028988; Mon, 18 Jan 2016 05:43:35 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0I5hZUv028987; Mon, 18 Jan 2016 05:43:35 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201601180543.u0I5hZUv028987@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Mon, 18 Jan 2016 05:43:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294248 - head/sys/dev/iwm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2016 05:43:36 -0000 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; 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))