Skip to contentSkip to conversation

wifi: rtw89: do RA association again when the station RSSI is known

PATCH In review acio 2 participants 3 messages Nov 8 – Nov 12 Realtek wireless driver (rtw89)

lore
Share & tools
lore

acio

author
#0 lore raw

PATCH 1/1 wifi: rtw89: do RA association again when the station RSSI is known

From: Vincent Schurink <[email protected]>

When a station associates to an AP, the AP does not know the RSSI of the station yet. Thus, rtw89_phy_ra_assoc() sends init_rate_lv 0 to the firmware. With this value, the firmware RA of RTL8922A uses 20 MHz and VHT-MCS 2 for the station. The firmware RA does not try a higher rate, also when the PER is 0. On an 80 MHz AP, the TCP throughput to the station stays at approximately 35 Mbit/s.

Set a flag when the RSSI is not known at the RA association. When the RSSI is known, the periodic RA update does the RA association again.

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 -45 dBm.
Before: TX rate VHT-MCS 2 at 20 MHz, TCP 35 Mbit/s.
After: TX rate VHT-MCS 7 to 9 at 80 MHz, TCP 186 to 320 Mbit/s.

---
 drivers/net/wireless/realtek/rtw89/core.h |  1 +
 drivers/net/wireless/realtek/rtw89/phy.c  | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw89/core.h +1 -0
index 0d893b992a4..ca5f2aced33 100644
@@ -4711,6 +4711,7 @@ 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/phy.c +14 -0
index 795920b899d..96660b781a5 100644
@@ -717,6 +717,19 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
 static void rtw89_phy_ra_update_sta_iter(void *data, struct ieee80211_sta *sta)
 {
 	struct rtw89_dev *rtwdev = (struct rtw89_dev *)data;
+	struct rtw89_sta *rtwsta = sta_to_rtwsta(sta);
+	struct rtw89_sta_link *rtwsta_link;
+	unsigned int link_id;
+	u8 rssi;
+
+	rtw89_sta_for_each_link(rtwsta, rtwsta_link, link_id) {
+		if (!rtwsta_link->ra_rssi_unknown)
+			continue;
+
+		rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
+		if (rssi > 1)
+			rtw89_phy_ra_assoc(rtwdev, rtwsta_link);
+	}
 
 	rtw89_phy_ra_update_sta(rtwdev, sta, IEEE80211_RC_SUPP_RATES_CHANGED);
 }
@@ -755,6 +768,7 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
 		ra->init_rate_lv = 3;
 	else
 		ra->init_rate_lv = 0;
+	rtwsta_link->ra_rssi_unknown = rssi <= 1;
 	ra->upd_all = 1;
 	rtw89_debug(rtwdev, RTW89_DBG_RA,
 		    "ra assoc: macid = %d, mode = %d, bw = %d, nss = %d, lv = %d",
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 46 lines · acio

From: Vincent Schurink <[email protected]>

When a station associates to an AP, the AP does not know the RSSI of the station yet. Thus, rtw89_phy_ra_assoc() sends init_rate_lv 0 to the firmware. With this value, the firmware RA of RTL8922A uses 20 MHz and VHT-MCS 2 for the station. The firmware RA does not try a higher rate, also when the PER is 0. On an 80 MHz AP, the TCP throughput to the station stays at approximately 35 Mbit/s.

Set a flag when the RSSI is not known at the RA association. When the RSSI is known, the periodic RA update does the RA association again.

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 -45 dBm.
Before: TX rate VHT-MCS 2 at 20 MHz, TCP 35 Mbit/s.
After: TX rate VHT-MCS 7 to 9 at 80 MHz, TCP 186 to 320 Mbit/s.

---
 drivers/net/wireless/realtek/rtw89/core.h |  1 +
 drivers/net/wireless/realtek/rtw89/phy.c  | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw89/core.h +1 -0
index 0d893b992a4..ca5f2aced33 100644
@@ -4711,6 +4711,7 @@ 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/phy.c +2 -0
index 795920b899d..96660b781a5 100644
@@ -717,6 +717,19 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
 static void rtw89_phy_ra_update_sta_iter(void *data, struct ieee80211_sta *sta)
 {
        struct rtw89_dev *rtwdev = (struct rtw89_dev *)data;
+       struct rtw89_sta *rtwsta = sta_to_rtwsta(sta);
+       struct rtw89_sta_link *rtwsta_link;

drivers/net/wireless/realtek/rtw89/phy.c void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev, · line 731

Quoted 10 lines
drivers/net/wireless/realtek/rtw89/phy.c +10 -0
+       unsigned int link_id;
+       u8 rssi;
+
+       rtw89_sta_for_each_link(rtwsta, rtwsta_link, link_id) {
+               if (!rtwsta_link->ra_rssi_unknown)
+                       continue;
+
+               rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
+               if (rssi > 1)
+                       rtw89_phy_ra_assoc(rtwdev, rtwsta_link);

Can we move rssi logic to an individual function and call it to update ra->init_rate_lv?

	if (rssi > 40)
		ra->init_rate_lv = 1;
	else if (rssi > 20)
		ra->init_rate_lv = 2;
	else if (rssi > 1)
		ra->init_rate_lv = 3;
	else
		ra->init_rate_lv = 0;

The rtw89_phy_ra_update_sta() will call rtw89_fw_h2c_ra() to send H2C command.

Quoted 14 lines
drivers/net/wireless/realtek/rtw89/phy.c +2 -1
+       }
 
        rtw89_phy_ra_update_sta(rtwdev, sta, IEEE80211_RC_SUPP_RATES_CHANGED);
 }
@@ -755,6 +768,7 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
                ra->init_rate_lv = 3;
        else
                ra->init_rate_lv = 0;
+       rtwsta_link->ra_rssi_unknown = rssi <= 1;
        ra->upd_all = 1;
        rtw89_debug(rtwdev, RTW89_DBG_RA,
                    "ra assoc: macid = %d, mode = %d, bw = %d, nss = %d, lv = %d",
--

2.53.0

author
#2 lore raw

Thank you. I tested this on RTL8912AU in AP mode. With init_rate_lv in the RA update only, the rate stays at VHT-MCS 2 and 20 MHz. The firmware uses init_rate_lv only together with upd_all. Thus, v2 also sets upd_all one time, when the level changes from 0 to a known level. Then the rate goes to VHT-MCS 5 to 9 at 80 MHz.

v2: https://lore.kernel.org/linux-wireless/[email protected]/

Quoted 89 lines · Ping-Ke Shih
Quoted 46 lines · acio

From: Vincent Schurink <[email protected]>

When a station associates to an AP, the AP does not know the RSSI of the station yet. Thus, rtw89_phy_ra_assoc() sends init_rate_lv 0 to the firmware. With this value, the firmware RA of RTL8922A uses 20 MHz and VHT-MCS 2 for the station. The firmware RA does not try a higher rate, also when the PER is 0. On an 80 MHz AP, the TCP throughput to the station stays at approximately 35 Mbit/s.

Set a flag when the RSSI is not known at the RA association. When the RSSI is known, the periodic RA update does the RA association again.

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 -45 dBm.
Before: TX rate VHT-MCS 2 at 20 MHz, TCP 35 Mbit/s.
After: TX rate VHT-MCS 7 to 9 at 80 MHz, TCP 186 to 320 Mbit/s.

---
 drivers/net/wireless/realtek/rtw89/core.h |  1 +
 drivers/net/wireless/realtek/rtw89/phy.c  | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw89/core.h +1 -0
index 0d893b992a4..ca5f2aced33 100644
@@ -4711,6 +4711,7 @@ 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/phy.c +2 -0
index 795920b899d..96660b781a5 100644
@@ -717,6 +717,19 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
 static void rtw89_phy_ra_update_sta_iter(void *data, struct ieee80211_sta *sta)
 {
        struct rtw89_dev *rtwdev = (struct rtw89_dev *)data;
+       struct rtw89_sta *rtwsta = sta_to_rtwsta(sta);
+       struct rtw89_sta_link *rtwsta_link;

drivers/net/wireless/realtek/rtw89/phy.c void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev, · line 731

Quoted 10 lines
drivers/net/wireless/realtek/rtw89/phy.c +10 -0
+       unsigned int link_id;
+       u8 rssi;
+
+       rtw89_sta_for_each_link(rtwsta, rtwsta_link, link_id) {
+               if (!rtwsta_link->ra_rssi_unknown)
+                       continue;
+
+               rssi = ewma_rssi_read(&rtwsta_link->avg_rssi) >> RSSI_FACTOR;
+               if (rssi > 1)
+                       rtw89_phy_ra_assoc(rtwdev, rtwsta_link);

Can we move rssi logic to an individual function and call it to update ra->init_rate_lv?

        if (rssi > 40)
                ra->init_rate_lv = 1;
        else if (rssi > 20)
                ra->init_rate_lv = 2;
        else if (rssi > 1)
                ra->init_rate_lv = 3;
        else
                ra->init_rate_lv = 0;

The rtw89_phy_ra_update_sta() will call rtw89_fw_h2c_ra() to send H2C command.

Quoted 14 lines
drivers/net/wireless/realtek/rtw89/phy.c +2 -1
+       }
 
        rtw89_phy_ra_update_sta(rtwdev, sta, IEEE80211_RC_SUPP_RATES_CHANGED);
 }
@@ -755,6 +768,7 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct rtw89_sta_link *rtwsta_
                ra->init_rate_lv = 3;
        else
                ra->init_rate_lv = 0;
+       rtwsta_link->ra_rssi_unknown = rssi <= 1;
        ra->upd_all = 1;
        rtw89_debug(rtwdev, RTW89_DBG_RA,
                    "ra assoc: macid = %d, mode = %d, bw = %d, nss = %d, lv = %d",
--

2.53.0