1: 988d8e55faf6 ! 1: 3778e5e139f4 wifi: rtw89: set RA init rate level when the station RSSI is known @@ Commit message then stays at approximately 36 Mbit/s for the full connection.  Move the mapping from RSSI to init_rate_lv to a function. Use it in the - RA association and in the RA update. The firmware uses init_rate_lv only - together with upd_all, and upd_all resets the RA context. Thus, set a - flag when the RSSI is not known at the RA association. The RA update - then sets upd_all one time, when the RSSI is known. + RA association and in the RA update. In a test on RTL8922A, the + firmware used init_rate_lv only together with upd_all, and upd_all + resets the RA context. Thus, the RA + association sets rssi_unknown in the RA info when the RSSI is not known. + The RA update then sets upd_all one time, when the RSSI is known. + The flag is in a struct_group at the end of the RA info, and + rtw89_phy_ra_sta_update() clears the RA info only up to this group. + Thus, the flag stays until the RA update uses it.  Tested on RTL8912AU (RTL8922A, USB) in AP mode with hostapd 2.10 and - VHT 80 MHz. The client is an Intel Meteor Lake CNVi (iwlwifi) at 50 cm, - -38 dBm. Each test reconnects the client, then sends TCP from the AP for + VHT 80 MHz. The client is an Intel Meteor Lake CNVi (iwlwifi) at -38 to + -40 dBm. Each test reconnects the client, then sends TCP from the AP for 60 s. Before: 6 of 8 connections stay at VHT-MCS 2 and 20 MHz, 36 Mbit/s. - After: 8 of 8 connections use VHT-MCS 7 to 9 at 80 MHz, 614 to - 669 Mbit/s. + After: 8 of 8 connections use VHT-MCS 7 to 9 at 80 MHz, 668 to + 684 Mbit/s.  + Suggested-by: Ping-Ke Shih  Signed-off-by: Vincent Schurink   ## drivers/net/wireless/realtek/rtw89/core.h ## -@@ drivers/net/wireless/realtek/rtw89/core.h: struct rtw89_sta_link { - struct rtw89_vif_link *rtwvif_link; - struct rtw89_ra_info ra; - struct rtw89_ra_report ra_report; -+ bool ra_rssi_unknown; - int max_agg_wait; - u8 prev_rssi; - struct ewma_rssi avg_rssi; +@@ drivers/net/wireless/realtek/rtw89/core.h: struct rtw89_ra_info { + u8 macid_msb:2; + u8 band:2; /* enum rtw89_band */ + u8 is_new_dbgreg:1; ++ ++ /* keep driver helpers below in group (not cleared by rtw89_phy_ra_sta_update()) */ ++ struct_group(helpers, ++ bool rssi_unknown; ++ ); + }; +  + #define RTW89_PPDU_MAC_INFO_USR_SIZE 4  ## drivers/net/wireless/realtek/rtw89/phy.c ## +@@ drivers/net/wireless/realtek/rtw89/phy.c: static void rtw89_phy_ra_sta_update(struct rtw89_dev *rtwdev, + bool sgi = false; + bool fix_giltf_en = false; +  +- memset(ra, 0, sizeof(*ra)); ++ memset(ra, 0, offsetof(typeof(*ra), helpers)); + /* Set the ra mask from sta's capability */ + if (link_sta->eht_cap.has_eht) { + mode |= RTW89_RA_MODE_EHT;  @@ drivers/net/wireless/realtek/rtw89/phy.c: static void rtw89_phy_ra_sta_update(struct rtw89_dev *rtwdev, ra->csi_mode = csi_mode; } @@ drivers/net/wireless/realtek/rtw89/phy.c: void rtw89_phy_ra_update_sta_link(stru rcu_read_unlock();   + ra->init_rate_lv = rtw89_phy_ra_get_init_rate_lv(rtwsta_link); -+ if (rtwsta_link->ra_rssi_unknown && ra->init_rate_lv) { -+ rtwsta_link->ra_rssi_unknown = false; ++ if (ra->rssi_unknown && ra->init_rate_lv) {  + ra->upd_all = 1; ++ ra->rssi_unknown = false;  + } if (changed & IEEE80211_RC_SUPP_RATES_CHANGED) ra->upd_mask = 1; @@ drivers/net/wireless/realtek/rtw89/phy.c: void rtw89_phy_ra_assoc(struct rtw89_d  - else  - ra->init_rate_lv = 0;  + ra->init_rate_lv = rtw89_phy_ra_get_init_rate_lv(rtwsta_link); -+ rtwsta_link->ra_rssi_unknown = !ra->init_rate_lv; ++ ra->rssi_unknown = !ra->init_rate_lv; ra->upd_all = 1; rtw89_debug(rtwdev, RTW89_DBG_RA, "ra assoc: macid = %d, mode = %d, bw = %d, nss = %d, lv = %d",