git: d82bfe73a3f4 - main - rtwn: don't set the RTS/CTS primary channel field for RTL8812AU/RTL8821AU

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Wed, 08 Jan 2025 02:59:16 UTC
The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/src/commit/?id=d82bfe73a3f4f3f38757c2e064047f09629ec7b7

commit d82bfe73a3f4f3f38757c2e064047f09629ec7b7
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2024-12-16 20:11:16 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2025-01-08 02:32:42 +0000

    rtwn: don't set the RTS/CTS primary channel field for RTL8812AU/RTL8821AU
    
    According to the rtl8812au reference driver, this seems to control
    the bandwidth used by lower-bandwidth frames when transmitted in
    a higher bandwidth channel.  For example, transmitting a 20MHz frame
    on an 80MHz channel (eg in hostap mode) is doable, but you may want
    to at least duplicate the RTS/CTS exchange across all four 20MHz
    subchannels, AND perhaps duplicate the 20MHz frame.
    
    I haven't fired this up with a spectrum analyser to see what the
    result is.
    
    The vendor driver doesn't bother with this and it doesn't change
    performance.  My guess is that for modes like AP mode we MAY wantto
    be able to control the RTS/CTS bandwidth choices rather than letting
    the firmare do it, but we're not there yet.
    
    The rtl8812au code in hal/rtl8812a_xmit.c:SCMapping_8812() has
    the gory details, but then the one place it's used just has it
    commented out and 0 (ie "do not care") is always programmed in.
    
    Differential Revision:  https://reviews.freebsd.org/D48113
    Obtained from:  https://github.com/lwfinger/rtl8812au
    Reviewed by:    bz
---
 sys/dev/rtwn/rtl8812a/r12a_tx.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/sys/dev/rtwn/rtl8812a/r12a_tx.c b/sys/dev/rtwn/rtl8812a/r12a_tx.c
index 582e6e0ddaf4..336ad75a0b1f 100644
--- a/sys/dev/rtwn/rtl8812a/r12a_tx.c
+++ b/sys/dev/rtwn/rtl8812a/r12a_tx.c
@@ -56,14 +56,35 @@
 #include <dev/rtwn/rtl8812a/r12a.h>
 #include <dev/rtwn/rtl8812a/r12a_tx_desc.h>
 
+/*
+ * This function actually handles the secondary channel mapping,
+ * not the primary channel mapping.  It hints to the MAC where
+ * to handle duplicate transmission of the RTS/CTS and payload
+ * frames when the requested transmit channel width is less than
+ * the configured channel width.
+ *
+ * Note: the vendor driver and linux rtw88 driver both leave this
+ * field currently set to 0.
+ *
+ * See the rtl8812au vendor driver, hal/rtl8812a_xmit.c:SCMapping_8812()
+ * and where it's used (and ignored.)
+ */
 static int
 r12a_get_primary_channel(struct rtwn_softc *sc, struct ieee80211_channel *c)
 {
+#if 0
 	/* XXX VHT80; VHT40 */
 	if (IEEE80211_IS_CHAN_HT40U(c))
 		return (R12A_TXDW5_PRIM_CHAN_20_80_2);
 	else
 		return (R12A_TXDW5_PRIM_CHAN_20_80_3);
+#endif
+
+	/*
+	 * For now just return the VHT_DATA_SC_DONOT_CARE value
+	 * from the reference driver.
+	 */
+	return (0);
 }
 
 static void