git: 8df9c187c742 - stable/15 - LinuxKPI: 802.11: adjust timing of sync_from_ni in lkpi_sta_assoc_to_run()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 29 Jun 2026 06:34:46 UTC
The branch stable/15 has been updated by bz:

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

commit 8df9c187c7425fd1c14f707a608d1479c8b249c7
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-06-22 01:16:45 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-06-29 03:55:13 +0000

    LinuxKPI: 802.11: adjust timing of sync_from_ni in lkpi_sta_assoc_to_run()
    
    We used to call the (*sta_state) downcall into the driver to set the
    sta state to ASSOC.  After that we did a lot of sync operations incl.
    the lkpi_sta_sync_from_ni() which does a lot of rate and bandwith
    adjustments.   This sync call needs to happen before we set the sta
    to assoc as drivers rely on some of this information, e.g., ht_cap and
    vht_cap (and equivalents for later standards) at that point.  Moving
    this will make, e.g., mt7921 transmit at higher rates than just
    basic_rates.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 75aadc902298005c47d2b931c483452027ceae69)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 04874b0e340f..4ed05d32ceed 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -3184,6 +3184,16 @@ lkpi_sta_assoc_to_run(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	if (vap->iv_flags & IEEE80211_F_WME)
 		sta->wme = true;
 #endif
+	bss_changed = 0;
+	/*
+	 * This sync needs to happen before the sta_state change to ASSOC.
+	 * At least mt7921 (likely all drivers) rely on, e.g., ht_cap, vht_cap,
+	 * .. to be set at the point we go to assoc.
+	 */
+	bss_changed |= lkpi_sta_sync_from_ni(hw, vif, sta, ni, true);
+	if (ieee80211_hw_check(hw, HAS_RATE_CONTROL))
+		lkpi_80211_mo_set_bitrate_mask(hw, vif, &lvif->br_mask);
+
 	error = lkpi_80211_mo_sta_state(hw, vif, lsta, IEEE80211_STA_ASSOC);
 	if (error != 0) {
 		ic_printf(vap->iv_ic, "%s:%d: mo_sta_state(ASSOC) "
@@ -3194,7 +3204,6 @@ lkpi_sta_assoc_to_run(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	IMPROVE("wme / conf_tx [all]");
 
 	/* Update bss info (bss_info_changed) (assoc, aid, ..). */
-	bss_changed = 0;
 #ifdef LKPI_80211_WME
 	bss_changed |= lkpi_wme_update(lhw, vap, true);
 #endif
@@ -3255,7 +3264,6 @@ lkpi_sta_assoc_to_run(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 
 	bss_changed = 0;
 	IMPROVE("Is this the right spot, has net80211 done all updates already?");
-	bss_changed |= lkpi_sta_sync_from_ni(hw, vif, sta, ni, true);
 
 	/* Update thresholds. */
 	hw->wiphy->frag_threshold = vap->iv_fragthreshold;