From owner-dev-commits-src-all@freebsd.org Fri Mar 26 01:26:30 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9B6995AF322; Fri, 26 Mar 2021 01:26:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F647V42yRz3HXL; Fri, 26 Mar 2021 01:26:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D9011185C; Fri, 26 Mar 2021 01:26:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12Q1QU0x042508; Fri, 26 Mar 2021 01:26:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12Q1QUWP042507; Fri, 26 Mar 2021 01:26:30 GMT (envelope-from git) Date: Fri, 26 Mar 2021 01:26:30 GMT Message-Id: <202103260126.12Q1QUWP042507@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: b6fd00791f2b - main - [iwn] Flip over to use VAP flags rather than ic flags for things MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b6fd00791f2b9690b0a5d8670fc03f74eda96da2 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2021 01:26:30 -0000 The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=b6fd00791f2b9690b0a5d8670fc03f74eda96da2 commit b6fd00791f2b9690b0a5d8670fc03f74eda96da2 Author: Adrian Chadd AuthorDate: 2021-03-22 16:47:43 +0000 Commit: Adrian Chadd CommitDate: 2021-03-26 01:26:09 +0000 [iwn] Flip over to use VAP flags rather than ic flags for things net80211 changed a while back to support per-VAP config for things rather than it being global. This is to support firmware NICs that support per-VAP flags and configuration where the firmware will figure out how to combine them. However, it introduced a fun timing issue - those changes used to happen to the shared ic state before newstate() was called, but now they're also tasks and they can happen /after/. This isn't a problem for ath(4), but it exposed some interesting timing and config bugs here. Notably, I saw short slot NOT being configured in 5GHz mode during some associations, so 5GHz stuff would hang or behave poorly. Other times the follow-up auth has the right config, so it didn't hang. So for now, just flip this over to using the per-VAP flags which are correct when newstate() is called. net80211 should also have those flags synch'ed to the global ic state before newstate() runs and that can come in a subsequent commit. Whilst here also fix plcp to be consistently logged as a hex value. Tested: * iwn(4) Intel 6205, STA mode, both 2GHz and 5GHz Differential Revision: https://reviews.freebsd.org/D29379 Reviewed by: bz --- sys/dev/iwn/if_iwn.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 2121a15bad6e..b07b52cbea7c 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -4450,7 +4450,7 @@ iwn_check_rate_needs_protection(struct iwn_softc *sc, /* * 11bg protection not enabled? Then don't use it. */ - if ((ic->ic_flags & IEEE80211_F_USEPROT) == 0) + if ((vap->iv_flags & IEEE80211_F_USEPROT) == 0) return (0); /* @@ -4936,7 +4936,7 @@ iwn_tx_cmd(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni, data->ni = ni; DPRINTF(sc, IWN_DEBUG_XMIT, "%s: qid %d idx %d len %d nsegs %d " - "plcp %d\n", + "plcp 0x%x\n", __func__, ring->qid, ring->cur, totlen, nsegs, tx->rate); /* Fill TX descriptor. */ @@ -6654,18 +6654,18 @@ iwn5000_runtime_calib(struct iwn_softc *sc) } static uint32_t -iwn_get_rxon_ht_flags(struct iwn_softc *sc, struct ieee80211_channel *c) +iwn_get_rxon_ht_flags(struct iwn_softc *sc, struct ieee80211vap *vap, + struct ieee80211_channel *c) { - struct ieee80211com *ic = &sc->sc_ic; uint32_t htflags = 0; if (! IEEE80211_IS_CHAN_HT(c)) return (0); - htflags |= IWN_RXON_HT_PROTMODE(ic->ic_curhtprotmode); + htflags |= IWN_RXON_HT_PROTMODE(vap->iv_curhtprotmode); if (IEEE80211_IS_CHAN_HT40(c)) { - switch (ic->ic_curhtprotmode) { + switch (vap->iv_curhtprotmode) { case IEEE80211_HTINFO_OPMODE_HT20PR: htflags |= IWN_RXON_HT_MODEPURE40; break; @@ -6912,7 +6912,7 @@ iwn_config(struct iwn_softc *sc) sc->rxchainmask, sc->nrxchains); - sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, ic->ic_curchan)); + sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, vap, ic->ic_curchan)); DPRINTF(sc, IWN_DEBUG_RESET, "%s: setting configuration; flags=0x%08x\n", @@ -7285,9 +7285,17 @@ iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap) sc->rxon->flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF); if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) sc->rxon->flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ); - if (ic->ic_flags & IEEE80211_F_SHSLOT) + + /* + * We always set short slot on 5GHz channels. + * We optionally set it for 2.4GHz channels. + */ + if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan)) + sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); + else if (vap->iv_flags & IEEE80211_F_SHSLOT) sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); - if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) + + if (vap->iv_flags & IEEE80211_F_SHPREAMBLE) sc->rxon->flags |= htole32(IWN_RXON_SHPREAMBLE); if (IEEE80211_IS_CHAN_A(ni->ni_chan)) { sc->rxon->cck_mask = 0; @@ -7302,7 +7310,7 @@ iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap) } /* try HT */ - sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, ic->ic_curchan)); + sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, vap, ic->ic_curchan)); DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x cck %x ofdm %x\n", sc->rxon->chan, sc->rxon->flags, sc->rxon->cck_mask, @@ -7349,9 +7357,14 @@ iwn_run(struct iwn_softc *sc, struct ieee80211vap *vap) sc->rxon->flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF); if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan)) sc->rxon->flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ); - if (ic->ic_flags & IEEE80211_F_SHSLOT) + + /* As previously - short slot only on 5GHz */ + if (IEEE80211_IS_CHAN_5GHZ(ni->ni_chan)) sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); - if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) + else if (vap->iv_flags & IEEE80211_F_SHSLOT) + sc->rxon->flags |= htole32(IWN_RXON_SHSLOT); + + if (vap->iv_flags & IEEE80211_F_SHPREAMBLE) sc->rxon->flags |= htole32(IWN_RXON_SHPREAMBLE); if (IEEE80211_IS_CHAN_A(ni->ni_chan)) { sc->rxon->cck_mask = 0; @@ -7365,10 +7378,10 @@ iwn_run(struct iwn_softc *sc, struct ieee80211vap *vap) sc->rxon->ofdm_mask = 0x15; } /* try HT */ - sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, ni->ni_chan)); + sc->rxon->flags |= htole32(iwn_get_rxon_ht_flags(sc, vap, ni->ni_chan)); sc->rxon->filter |= htole32(IWN_FILTER_BSS); DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x, curhtprotmode=%d\n", - sc->rxon->chan, le32toh(sc->rxon->flags), ic->ic_curhtprotmode); + sc->rxon->chan, le32toh(sc->rxon->flags), vap->iv_curhtprotmode); if ((error = iwn_send_rxon(sc, 0, 1)) != 0) { device_printf(sc->sc_dev, "%s: could not send RXON\n",