From nobody Tue Jan 14 04:34:57 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YXGWP6kxLz5j6BK; Tue, 14 Jan 2025 04:34:57 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YXGWP3D7jz3cVn; Tue, 14 Jan 2025 04:34:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736829297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6X7LW/pb8a35j13rnHeHgmoGb49RNU3GULrE3NJhLaI=; b=PVS88Fz4aV0b4Tn8LMDpUmNCbTCYjT83XmFgf+pnZPgBeQBdEAD0riT8bxxcvZo03QCz6v RcL4/ydFVt8GnJdjfUQv6VJjLZFVOam0luwnnxdcF/iIE3Y0lM79Ll3vsdAnNfEVHA2HhN YzlnQMVonKJc+0mugjs2I/obz+EeAtKDnEpFXuaOP10gRwJAU1CFNMutCc3rGdVDY415fK DktI4Kyr2e4qEvFGM1LsyzPTp0q/DWOGdu88hmX6SNAyPICBIDE3OgMtiMUTxuipsxD1DG Yrnk24eoyAV77bnK+R8GgufsyHpJNhYc4tPHsiGn1E+3s6BqPpSPVtnyWts5oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736829297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6X7LW/pb8a35j13rnHeHgmoGb49RNU3GULrE3NJhLaI=; b=oWjo//QbeZZamVTgubRumoeghLhyy8mFzEwEB5uysYiFM3h6aGSt3rSIvgIvHrd1FrCdDV YTURFQYWCgH14FoF1Qf7iaoRVGC1+cyqR5p+o+IJrObiSsZ4MywGwOQAv73b54GHvOKacj WttuJ6w5nc2SLT2BX18/MG5eQ8zQ8FRgUlHZCnzv3fte0RlZnZMAyyHWDnlWt4XknlavL1 PD+QaJ4RlWtyfzq8QxV2FoPjGTkSNegegY6Ymfck5pF/VOup0OfHGt1qBd1ZBy/1GfAaIC QgUxD0aQalaX9psPsB76nOeAKEuVl+M+1a9ZHq7tL1fdNsLt78/OkkKZFLgNuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736829297; a=rsa-sha256; cv=none; b=Z4orjFnroVdWHLe2k+NxUtDOgLyLyonEjQYgI+qIo4UCnvgxuxgnHBiak7BO2hzAyccFf2 ffTMUVzcyWwbqb/jXcB/dHSNJ1cJk0+dT3BU3UDVM6S3dozPyKYSlK5BFXGVHSCb1bCjKj L2bPav5FXkNqXdNppSX6NvskrFkMUV4XO3ggVfd4ddt5jGid0ztBhX+WtUVAjZeOfABOY8 XWU3KF2S+V5uuceK4tU/Av5uXqydrZiweDnNx3ybI6G1v815wJJ9nDqz3xFlDJ8OJ8FU9t gqVGve9k0Kkh4GqOpyXpD0FsxEnoiM0VRac506hHmIIheIIAl9FmmKo+7Thbbg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YXGWP1XxHz11g1; Tue, 14 Jan 2025 04:34:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50E4YvmN072625; Tue, 14 Jan 2025 04:34:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50E4Yvmd072622; Tue, 14 Jan 2025 04:34:57 GMT (envelope-from git) Date: Tue, 14 Jan 2025 04:34:57 GMT Message-Id: <202501140434.50E4Yvmd072622@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: ce7fca19287c - main - rtwn: refactor out the r92c path protection decision / configuration List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org 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: ce7fca19287cb218794da6fcbe320946485cd67a Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=ce7fca19287cb218794da6fcbe320946485cd67a commit ce7fca19287cb218794da6fcbe320946485cd67a Author: Adrian Chadd AuthorDate: 2024-12-19 03:35:58 +0000 Commit: Adrian Chadd CommitDate: 2025-01-14 04:34:14 +0000 rtwn: refactor out the r92c path protection decision / configuration * refactor out the r92c path protection (RTS/CTS) decision * handle firmware rate control being enabled - if DRVRATE isn't set then the RTSRATE field is ignored and instead RRSR/INIRTS registers are used (and the firmware/hardware will do RTS rate adaptation / retry.) * when making protection decisions with firmware rate control, default to the channel mode rather than rate index. This works on RTL8192CU both with firmware rate control and driver rate control. Locally tested: * RTL8192CU, STA - firmware and net80211 rate control Differential Revision: https://reviews.freebsd.org/D48142 --- sys/dev/rtwn/rtl8192c/r92c_tx.c | 100 +++++++++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/sys/dev/rtwn/rtl8192c/r92c_tx.c b/sys/dev/rtwn/rtl8192c/r92c_tx.c index 9d975e98d95b..6b013de0c536 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_tx.c +++ b/sys/dev/rtwn/rtl8192c/r92c_tx.c @@ -77,10 +77,14 @@ r92c_tx_set_ht40(struct rtwn_softc *sc, void *buf, struct ieee80211_node *ni) static void r92c_tx_protection(struct rtwn_softc *sc, struct r92c_tx_desc *txd, - enum ieee80211_protmode mode, uint8_t ridx) + enum ieee80211_protmode mode, uint8_t ridx, bool force_rate) { struct ieee80211com *ic = &sc->sc_ic; uint8_t rate; + bool use_fw_ratectl; + + use_fw_ratectl = + (sc->sc_ratectl == RTWN_RATECTL_FW && !force_rate); switch (mode) { case IEEE80211_PROT_CTSONLY: @@ -95,17 +99,27 @@ r92c_tx_protection(struct rtwn_softc *sc, struct r92c_tx_desc *txd, if (mode == IEEE80211_PROT_CTSONLY || mode == IEEE80211_PROT_RTSCTS) { - if (RTWN_RATE_IS_HT(ridx)) + if (use_fw_ratectl) { + /* + * If we're not forcing the driver rate then this + * field actually doesn't matter; what matters is + * the RRSR and INIRTS configuration. + */ + ridx = RTWN_RIDX_OFDM24; + } else if (RTWN_RATE_IS_HT(ridx)) { rate = rtwn_ctl_mcsrate(ic->ic_rt, ridx); - else + ridx = rate2ridx(IEEE80211_RV(rate)); + } else { rate = ieee80211_ctl_rate(ic->ic_rt, ridx2rate[ridx]); - ridx = rate2ridx(IEEE80211_RV(rate)); + ridx = rate2ridx(IEEE80211_RV(rate)); + } txd->txdw4 |= htole32(SM(R92C_TXDW4_RTSRATE, ridx)); /* RTS rate fallback limit (max). */ txd->txdw5 |= htole32(SM(R92C_TXDW5_RTSRATE_FB_LMT, 0xf)); - if (RTWN_RATE_IS_CCK(ridx) && ridx != RTWN_RIDX_CCK1 && + if (!use_fw_ratectl && RTWN_RATE_IS_CCK(ridx) && + ridx != RTWN_RIDX_CCK1 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) txd->txdw4 |= htole32(R92C_TXDW4_RTS_SHORT); } @@ -285,6 +299,49 @@ r92c_fill_tx_desc_shpreamble(struct rtwn_softc *sc, struct r92c_tx_desc *txd, txd->txdw4 |= htole32(R92C_TXDW4_DATA_SHPRE); } +static enum ieee80211_protmode +r92c_tx_get_protmode(struct rtwn_softc *sc, const struct ieee80211vap *vap, + const struct ieee80211_node *ni, const struct mbuf *m, + uint8_t ridx, bool force_rate) +{ + const struct ieee80211com *ic = &sc->sc_ic; + enum ieee80211_protmode prot; + + prot = IEEE80211_PROT_NONE; + + /* + * If doing firmware rate control, base it the configured channel. + * This ensures that for HT operation the RTS/CTS or CTS-to-self + * configuration is obeyed. + */ + if (sc->sc_ratectl == RTWN_RATECTL_FW && !force_rate) { + struct ieee80211_channel *chan; + enum ieee80211_phymode mode; + + chan = (ni->ni_chan != IEEE80211_CHAN_ANYC) ? + ni->ni_chan : ic->ic_curchan; + mode = ieee80211_chan2mode(chan); + if (mode == IEEE80211_MODE_11NG) + prot = ic->ic_htprotmode; + else if (ic->ic_flags & IEEE80211_F_USEPROT) + prot = ic->ic_protmode; + } else { + if (RTWN_RATE_IS_HT(ridx)) + prot = ic->ic_htprotmode; + else if (ic->ic_flags & IEEE80211_F_USEPROT) + prot = ic->ic_protmode; + } + + /* XXX fix last comparison for A-MSDU (in net80211) */ + /* XXX A-MPDU? */ + if (m->m_pkthdr.len + IEEE80211_CRC_LEN > + vap->iv_rtsthreshold && + vap->iv_rtsthreshold != IEEE80211_RTS_MAX) + prot = IEEE80211_PROT_RTSCTS; + + return (prot); +} + void r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, struct mbuf *m, void *buf, uint8_t ridx, bool force_rate, int maxretry) @@ -292,7 +349,6 @@ r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, #ifndef RTWN_WITHOUT_UCODE struct r92c_softc *rs = sc->sc_priv; #endif - struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = ni->ni_vap; struct rtwn_vap *uvp = RTWN_VAP(vap); struct ieee80211_frame *wh; @@ -357,24 +413,22 @@ r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni, r92c_fill_tx_desc_shpreamble(sc, txd, ridx, force_rate); - prot = IEEE80211_PROT_NONE; - if (RTWN_RATE_IS_HT(ridx)) { + prot = r92c_tx_get_protmode(sc, vap, ni, m, ridx, + force_rate); + + /* + * Note: Firmware rate control will enable short-GI + * based on the configured rate mask, however HT40 + * may not be enabled. + */ + if (sc->sc_ratectl != RTWN_RATECTL_FW && + RTWN_RATE_IS_HT(ridx)) { r92c_tx_set_ht40(sc, txd, ni); r92c_tx_set_sgi(sc, txd, ni); - prot = ic->ic_htprotmode; - } else if (ic->ic_flags & IEEE80211_F_USEPROT) - prot = ic->ic_protmode; - - /* XXX fix last comparison for A-MSDU (in net80211) */ - /* XXX A-MPDU? */ - if (m->m_pkthdr.len + IEEE80211_CRC_LEN > - vap->iv_rtsthreshold && - vap->iv_rtsthreshold != IEEE80211_RTS_MAX) - prot = IEEE80211_PROT_RTSCTS; + } /* NB: checks for ht40 / short bits (set above). */ - if (prot != IEEE80211_PROT_NONE) - r92c_tx_protection(sc, txd, prot, ridx); + r92c_tx_protection(sc, txd, prot, ridx, force_rate); } else /* IEEE80211_FC0_TYPE_MGT */ qsel = R92C_TXDW1_QSEL_MGNT; } else { @@ -438,9 +492,11 @@ r92c_fill_tx_desc_raw(struct rtwn_softc *sc, struct ieee80211_node *ni, params->ibp_try0)); } if (params->ibp_flags & IEEE80211_BPF_RTS) - r92c_tx_protection(sc, txd, IEEE80211_PROT_RTSCTS, ridx); + r92c_tx_protection(sc, txd, IEEE80211_PROT_RTSCTS, ridx, + true); if (params->ibp_flags & IEEE80211_BPF_CTS) - r92c_tx_protection(sc, txd, IEEE80211_PROT_CTSONLY, ridx); + r92c_tx_protection(sc, txd, IEEE80211_PROT_CTSONLY, ridx, + true); rtwn_r92c_tx_setup_macid(sc, txd, RTWN_MACID_BC); txd->txdw1 |= htole32(SM(R92C_TXDW1_QSEL, R92C_TXDW1_QSEL_MGNT));