git: 4e2bd8cf08f4 - main - rtwn: set the shortgi flag in the RTL8192C rate control setup message

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Thu, 19 Dec 2024 16:08:35 UTC
The branch main has been updated by adrian:

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

commit 4e2bd8cf08f4c803f93a4d9d5c9479fa72372869
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2024-12-10 05:47:07 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2024-12-19 16:05:26 +0000

    rtwn: set the shortgi flag in the RTL8192C rate control setup message
    
    Enable the short-GI flag configuring the rate mask.
    
    Obtained from:
    
    * Realtek vendor driver, rtl8192cu
    
    Differential Revision:   https://reviews.freebsd.org/D48013
    Reviewed by:    bz, imp
---
 sys/dev/rtwn/rtl8192c/r92c_fw.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sys/dev/rtwn/rtl8192c/r92c_fw.c b/sys/dev/rtwn/rtl8192c/r92c_fw.c
index 1ca37df7d0f4..939cd942f5e2 100644
--- a/sys/dev/rtwn/rtl8192c/r92c_fw.c
+++ b/sys/dev/rtwn/rtl8192c/r92c_fw.c
@@ -164,7 +164,7 @@ r92c_fw_download_enable(struct rtwn_softc *sc, int enable)
 #ifndef RTWN_WITHOUT_UCODE
 static int
 r92c_send_ra_cmd(struct rtwn_softc *sc, int macid, uint32_t rates,
-    int maxrate)
+    int maxrate, bool shortgi)
 {
 	struct r92c_fw_cmd_macid_cfg cmd;
 	uint8_t mode;
@@ -178,6 +178,8 @@ r92c_send_ra_cmd(struct rtwn_softc *sc, int macid, uint32_t rates,
 	else
 		mode = R92C_RAID_11B;
 	cmd.macid = macid | R92C_CMD_MACID_VALID;
+	if (shortgi)
+		cmd.macid |= R92C_CMD_MACID_SGI;
 	cmd.mask = htole32(mode << 28 | rates);
 	error = r92c_fw_cmd(sc, R92C_CMD_MACID_CONFIG, &cmd, sizeof(cmd));
 	if (error != 0) {
@@ -222,10 +224,18 @@ r92c_init_ra(struct rtwn_softc *sc, int macid)
 #ifndef RTWN_WITHOUT_UCODE
 	if (sc->sc_ratectl == RTWN_RATECTL_FW) {
 		uint32_t fw_rates;
+		bool shortgi;
 		/* 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);
+		/* Re-calculate short-gi based on op mode */
+		if (IEEE80211_IS_CHAN_HT40(ni->ni_chan))
+			shortgi = ieee80211_ht_check_tx_shortgi_40(ni);
+		else if (IEEE80211_IS_CHAN_HT20(ni->ni_chan))
+			shortgi = ieee80211_ht_check_tx_shortgi_20(ni);
+		else
+			shortgi = false;
+		r92c_send_ra_cmd(sc, macid, fw_rates, maxrate, shortgi);
 	}
 #endif