From nobody Wed Dec 18 23:49:03 2024 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 4YD9PX0RYWz5h7g4; Wed, 18 Dec 2024 23:49:04 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YD9PW2w9Lz44vq; Wed, 18 Dec 2024 23:49:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734565743; 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=XwRBikk767Ft7J4wR83mH/3yY+PLbm2q38uq2zmNj1o=; b=ZuZEzqWU3hjCtjvQ0TIre4IP0KK1K353MMLgQaIASlalERfigKhhogSiKzOJIisuVgRTKF +ArBZ44T9SGPjxgVWuaE+1Edrzomy0tW/6Z9vfd1FTOO+KPrH8IxT6pMkI/G0lcjIpes5u xmzTOl6CeCK/o8LIjVQVzVDXqc2tB6gtq/HuO7yUaqzucNRV4Uo8GUMp7cNdc9rErDtAep QzIqu592+KGpJmIhLjteX2ved7DIeBgIqHkm1gZtSSiwFz2By323ousJvnqthY9f7quiz8 bDthor9U7Bwqsd6ytr1wSxecjhpt0KVrPzHUI6frsGJxgDbdTCy5IlsWJfEz1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734565743; 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=XwRBikk767Ft7J4wR83mH/3yY+PLbm2q38uq2zmNj1o=; b=RY4DlrT/6quu/G8BOAGv1G6LiTjvkh0kA5CpnYaxuGbwqqagmM8Xh0eyWPRdoBX9M/mqgN RaiBc5+MD9trxHRU5q7TEc+00nnbM/Ksu5xrphjhFGBslH2c+j2ucUO9h2+DX2oEStVk6F NhvREEpx7gFXIOr+JrHRPozIX8pCOIbrePLpMQNJyFu2o+KsLS3hXMr0jFJy3a26lKT7V8 XDzucKIfRW5RpElqFLYXlZIPY1LBjK5GUVY9DZSHUrdUCD93bnei4UINOFkqw3cKy0hKiH R8x77b8ER+CE0U1vWeivYFB4ExgvE6fMX56jpsvnTwE+FeeLae2+OulLzX9Y7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734565743; a=rsa-sha256; cv=none; b=ZhwCBR95hBHQldcl2v5nBCY2H+ObsS+TitJ5kZ+9ZiJVtp0Aals2PFHZC8jC0sqMGI7Wf+ RzZYb9oP3LYTht1+KcQZVGtQqzzOYyNIHW8ZgP17iB1yTzAg9GidCs8090pmyzO6jsUtH6 OShdp5utPVJlRTYS6JDQvhZvK9fjDeeeOV70i16AvsSs+1ilEV5iFAiZazHJxa8fK3u/VC 0rVM7GXbwLxojvLvECTtsmgzIc25bloj5aNJdz5Iru9abYRdxYFwOzuqXfipnGOOVIj1BP BV8F/DEw8GXYZ4JDa51SPetppBksskWG1pN0W1yYQXkelPy1bcKHn/8Ec91Kkw== 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 4YD9PW2TqkzT9Y; Wed, 18 Dec 2024 23:49:03 +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 4BINn3nR038307; Wed, 18 Dec 2024 23:49:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BINn3VV038304; Wed, 18 Dec 2024 23:49:03 GMT (envelope-from git) Date: Wed, 18 Dec 2024 23:49:03 GMT Message-Id: <202412182349.4BINn3VV038304@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: 745a85824748 - main - rtwn: update rtwn_get_rates() to separate out the CCK/OFDM and HT rates 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: 745a85824748e06b9b2ca4e9639ba13bbf9c08ca Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=745a85824748e06b9b2ca4e9639ba13bbf9c08ca commit 745a85824748e06b9b2ca4e9639ba13bbf9c08ca Author: Adrian Chadd AuthorDate: 2024-12-08 20:22:04 +0000 Commit: Adrian Chadd CommitDate: 2024-12-18 23:48:10 +0000 rtwn: update rtwn_get_rates() to separate out the CCK/OFDM and HT rates The 32 bit bitmap is enough for CCK/OFDM rates and MCS0..15, but won't work for > MCS15, nor VHT rates. So, break out the legacy rates and HT rates. * break the rates and htrates out * document which calls are looking up basic rates and which care about the rates themselves * ensure the rate bitmap passed into the rate control firmware call (which isn't enabled yet!) is capped at 28 bits so they don't set the mode field. Differential Revision: https://reviews.freebsd.org/D47993 Reviewed by: bz, imp --- sys/dev/rtwn/if_rtwn.c | 3 ++- sys/dev/rtwn/if_rtwn_rx.c | 30 ++++++++++++++++++++++-------- sys/dev/rtwn/if_rtwn_rx.h | 3 ++- sys/dev/rtwn/rtl8192c/r92c_fw.c | 15 +++++++++++---- sys/dev/rtwn/rtl8812a/r12a_chan.c | 3 ++- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c index fdf44467680b..be01ececf307 100644 --- a/sys/dev/rtwn/if_rtwn.c +++ b/sys/dev/rtwn/if_rtwn.c @@ -1213,7 +1213,8 @@ rtwn_calc_basicrates(struct rtwn_softc *sc) continue; ni = ieee80211_ref_node(vap->iv_bss); - rtwn_get_rates(sc, &ni->ni_rates, NULL, &rates, NULL, 1); + /* Only fetches basic rates; no need to add HT/VHT here */ + rtwn_get_rates(sc, &ni->ni_rates, NULL, &rates, NULL, NULL, 1); basicrates |= rates; ieee80211_free_node(ni); } diff --git a/sys/dev/rtwn/if_rtwn_rx.c b/sys/dev/rtwn/if_rtwn_rx.c index 58cd53b01e63..977c1d17a08a 100644 --- a/sys/dev/rtwn/if_rtwn_rx.c +++ b/sys/dev/rtwn/if_rtwn_rx.c @@ -52,12 +52,24 @@ #include +/* + * Get the driver rate set for the current operating rateset(s). + * + * rates_p is set to a mask of 11abg ridx values (not HW rate values.) + * htrates_p is set to a mask of 11n ridx values (not HW rate values), + * starting at MCS0 == bit 0. + * + * maxrate_p is set to the ridx value. + * + * If basic_rates is 1 then only the 11abg basic rate logic will + * be applied; HT/VHT will be ignored. + */ void rtwn_get_rates(struct rtwn_softc *sc, const struct ieee80211_rateset *rs, const struct ieee80211_htrateset *rs_ht, uint32_t *rates_p, - int *maxrate_p, int basic_rates) + uint32_t *htrates_p, int *maxrate_p, int basic_rates) { - uint32_t rates; + uint32_t rates = 0, htrates = 0; uint8_t ridx; int i, maxrate; @@ -65,7 +77,7 @@ rtwn_get_rates(struct rtwn_softc *sc, const struct ieee80211_rateset *rs, rates = 0; maxrate = 0; - /* This is for 11bg */ + /* This is for 11abg */ for (i = 0; i < rs->rs_nrates; i++) { /* Convert 802.11 rate to HW rate index. */ ridx = rate2ridx(IEEE80211_RV(rs->rs_rates[i])); @@ -82,15 +94,15 @@ rtwn_get_rates(struct rtwn_softc *sc, const struct ieee80211_rateset *rs, /* If we're doing 11n, enable 11n rates */ if (rs_ht != NULL && !basic_rates) { for (i = 0; i < rs_ht->rs_nrates; i++) { + /* Only do up to 2-stream rates for now */ if ((rs_ht->rs_rates[i] & 0x7f) > 0xf) continue; - /* 11n rates start at index 12 */ - ridx = RTWN_RIDX_HT_MCS((rs_ht->rs_rates[i]) & 0xf); - rates |= (1 << ridx); + ridx = rs_ht->rs_rates[i] & 0xf; + htrates |= (1 << ridx); /* Guard against the rate table being oddly ordered */ - if (ridx > maxrate) - maxrate = ridx; + if (RTWN_RIDX_HT_MCS(ridx) > maxrate) + maxrate = RTWN_RIDX_HT_MCS(ridx); } } @@ -99,6 +111,8 @@ rtwn_get_rates(struct rtwn_softc *sc, const struct ieee80211_rateset *rs, if (rates_p != NULL) *rates_p = rates; + if (htrates_p != NULL) + *htrates_p = htrates; if (maxrate_p != NULL) *maxrate_p = maxrate; } diff --git a/sys/dev/rtwn/if_rtwn_rx.h b/sys/dev/rtwn/if_rtwn_rx.h index 73bdf0d7a0de..3108f1d4cde4 100644 --- a/sys/dev/rtwn/if_rtwn_rx.h +++ b/sys/dev/rtwn/if_rtwn_rx.h @@ -20,7 +20,8 @@ #define RTWN_NOISE_FLOOR -95 void rtwn_get_rates(struct rtwn_softc *, const struct ieee80211_rateset *, - const struct ieee80211_htrateset *, uint32_t *, int *, int); + const struct ieee80211_htrateset *, uint32_t *, uint32_t *, + int *, int); void rtwn_set_basicrates(struct rtwn_softc *, uint32_t); struct ieee80211_node * rtwn_rx_common(struct rtwn_softc *, struct mbuf *, void *); diff --git a/sys/dev/rtwn/rtl8192c/r92c_fw.c b/sys/dev/rtwn/rtl8192c/r92c_fw.c index 426dfd0e6d3f..1ca37df7d0f4 100644 --- a/sys/dev/rtwn/rtl8192c/r92c_fw.c +++ b/sys/dev/rtwn/rtl8192c/r92c_fw.c @@ -196,7 +196,7 @@ r92c_init_ra(struct rtwn_softc *sc, int macid) { struct ieee80211_htrateset *rs_ht; struct ieee80211_node *ni; - uint32_t rates; + uint32_t rates, htrates; int maxrate; RTWN_NT_LOCK(sc); @@ -212,13 +212,20 @@ r92c_init_ra(struct rtwn_softc *sc, int macid) rs_ht = &ni->ni_htrates; else rs_ht = NULL; - /* XXX MACID_BC */ - rtwn_get_rates(sc, &ni->ni_rates, rs_ht, &rates, &maxrate, 0); + /* + * Note: this pushes the rate bitmap and maxrate into the + * firmware; and for this chipset 2-stream 11n support is enough. + */ + rtwn_get_rates(sc, &ni->ni_rates, rs_ht, &rates, &htrates, &maxrate, 0); RTWN_NT_UNLOCK(sc); #ifndef RTWN_WITHOUT_UCODE if (sc->sc_ratectl == RTWN_RATECTL_FW) { - r92c_send_ra_cmd(sc, macid, rates, maxrate); + uint32_t fw_rates; + /* Add HT rates after normal rates; limit to MCS0..15 */ + fw_rates = rates | + ((htrates & 0xffff) << RTWN_RIDX_HT_MCS_SHIFT); + r92c_send_ra_cmd(sc, macid, fw_rates, maxrate); } #endif diff --git a/sys/dev/rtwn/rtl8812a/r12a_chan.c b/sys/dev/rtwn/rtl8812a/r12a_chan.c index d71e0a8177fd..f900d1ef7b2d 100644 --- a/sys/dev/rtwn/rtl8812a/r12a_chan.c +++ b/sys/dev/rtwn/rtl8812a/r12a_chan.c @@ -452,8 +452,9 @@ r12a_set_band(struct rtwn_softc *sc, struct ieee80211_channel *c) !(rtwn_read_1(sc, R12A_CCK_CHECK) & R12A_CCK_CHECK_5GHZ)) return; + /* Note: this only fetches the basic rates, not the full rateset */ rtwn_get_rates(sc, ieee80211_get_suprates(ic, c), NULL, &basicrates, - NULL, 1); + NULL, NULL, 1); if (IEEE80211_IS_CHAN_2GHZ(c)) { rtwn_r12a_set_band_2ghz(sc, basicrates); swing = rs->tx_bbswing_2g;