diff mbox series

[v1,3/3] wifi: rtl8xxxu: Make sure TX rate is reported in AP mode

Message ID 20250219175228.850583-4-ezra@easyb.ch (mailing list archive)
State Changes Requested
Delegated to: Ping-Ke Shih
Headers show
Series wifi: rtl8xxxu: AP mode fixes (for gen1 devices) | expand

Checks

Context Check Description
jmberg/tree_selection success Not a local patch

Commit Message

Ezra Buehler Feb. 19, 2025, 5:52 p.m. UTC
From: Ezra Buehler <ezra.buehler@husqvarnagroup.com>

Without this change, e.g., "iw station dump" will show "tx bitrate:
(unknown)" when in AP mode.

Signed-off-by: Ezra Buehler <ezra.buehler@husqvarnagroup.com>
---
Note: The code was simply copied over from rtl8xxxu_bss_info_changed()
---
 drivers/net/wireless/realtek/rtl8xxxu/core.c | 24 ++++++++++++++++++++
 1 file changed, 24 insertions(+)

--
2.43.0

Comments

Ping-Ke Shih Feb. 20, 2025, 6:10 a.m. UTC | #1
Ezra Buehler <ezra@easyb.ch> wrote:
> From: Ezra Buehler <ezra.buehler@husqvarnagroup.com>
> 
> Without this change, e.g., "iw station dump" will show "tx bitrate:
> (unknown)" when in AP mode.
> 
> Signed-off-by: Ezra Buehler <ezra.buehler@husqvarnagroup.com>
> ---
> Note: The code was simply copied over from rtl8xxxu_bss_info_changed()

The code seems to report the highest rate as initial (fake) TX rate.
Please add a patch ahead that moves the code into an individual function
but don't change existing logic. Then, this patch can use the function
to get your expectation.
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
index 2fa22d3145a4..eb497301b625 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
@@ -7576,6 +7576,12 @@  static int rtl8xxxu_sta_add(struct ieee80211_hw *hw,
 	mutex_lock(&priv->sta_mutex);
 	ewma_rssi_init(&sta_info->avg_rssi);
 	if (vif->type == NL80211_IFTYPE_AP) {
+		struct rtl8xxxu_ra_report *rarpt = &priv->ra_report;
+		u32 ramask;
+		int sgi = 0;
+		u8 highest_rate;
+		u8 bw;
+
 		sta_info->rssi_level = RTL8XXXU_RATR_STA_INIT;
 		sta_info->macid = rtl8xxxu_acquire_macid(priv);
 		if (sta_info->macid >= RTL8XXXU_MAX_MAC_ID_NUM) {
@@ -7584,6 +7590,24 @@  static int rtl8xxxu_sta_add(struct ieee80211_hw *hw,
 		}

 		rtl8xxxu_refresh_rate_mask(priv, 0, sta, true);
+
+		/* TODO: Set bits 28-31 for rate adaptive id */
+		ramask = (sta->deflink.supp_rates[0] & 0xfff) |
+			sta->deflink.ht_cap.mcs.rx_mask[0] << 12 |
+			sta->deflink.ht_cap.mcs.rx_mask[1] << 20;
+		if (sta->deflink.ht_cap.cap &
+		    (IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_SGI_20))
+			sgi = 1;
+
+		highest_rate = fls(ramask) - 1;
+		if (rtl8xxxu_ht40_2g &&
+		    (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
+			bw = RATE_INFO_BW_40;
+		else
+			bw = RATE_INFO_BW_20;
+
+		rtl8xxxu_update_ra_report(rarpt, highest_rate, sgi, bw);
+
 		priv->fops->report_connect(priv, sta_info->macid, H2C_MACID_ROLE_STA, true);
 	} else {
 		switch (rtlvif->port_num) {