diff mbox series

[3/4] wifi: rtl8xxxu: Fix AIFS written to REG_EDCA_*_PARAM

Message ID 038cc03f-3567-77ba-a7bd-c4930e3b2fad@gmail.com (mailing list archive)
State Accepted
Commit 5574d3290449916397f3092dcd2bac92415498e1
Delegated to: Kalle Valo
Headers show
Series wifi: rtl8xxxu: A few improvements | expand

Commit Message

Bitterblue Smith Sept. 18, 2022, 12:42 p.m. UTC
ieee80211_tx_queue_params.aifs is not supposed to be written directly
to the REG_EDCA_*_PARAM registers. Instead process it like the vendor
drivers do. It's kinda hacky but it works.

This change boosts the download speed and makes it more stable.

Tested with RTL8188FU but all the other supported chips should also
benefit.

Fixes: 26f1fad29ad9 ("New driver: rtl8xxxu (mac80211)")
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)

Comments

Jes Sorensen Sept. 25, 2022, 4:56 p.m. UTC | #1
On 9/18/22 08:42, Bitterblue Smith wrote:
> ieee80211_tx_queue_params.aifs is not supposed to be written directly
> to the REG_EDCA_*_PARAM registers. Instead process it like the vendor
> drivers do. It's kinda hacky but it works.
> 
> This change boosts the download speed and makes it more stable.
> 
> Tested with RTL8188FU but all the other supported chips should also
> benefit.
> 
> Fixes: 26f1fad29ad9 ("New driver: rtl8xxxu (mac80211)")
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>

Acked-by: Jes Sorensen <jes@trained-monkey.org>

Jes
Kalle Valo Sept. 26, 2022, 9:24 a.m. UTC | #2
Bitterblue Smith <rtl8821cerfe2@gmail.com> writes:

> ieee80211_tx_queue_params.aifs is not supposed to be written directly
> to the REG_EDCA_*_PARAM registers. Instead process it like the vendor
> drivers do. It's kinda hacky but it works.
>
> This change boosts the download speed and makes it more stable.
>
> Tested with RTL8188FU but all the other supported chips should also
> benefit.
>
> Fixes: 26f1fad29ad9 ("New driver: rtl8xxxu (mac80211)")
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>

[...]

> +static void rtl8xxxu_set_aifs(struct rtl8xxxu_priv *priv, u8 slot_time)
> +{
> +	u32 reg_edca_param[IEEE80211_NUM_ACS] = {
> +		[IEEE80211_AC_VO] = REG_EDCA_VO_PARAM,
> +		[IEEE80211_AC_VI] = REG_EDCA_VI_PARAM,
> +		[IEEE80211_AC_BE] = REG_EDCA_BE_PARAM,
> +		[IEEE80211_AC_BK] = REG_EDCA_BK_PARAM,
> +	};

static const?
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 7724ee8033a8..9ddff43b5cfc 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4656,6 +4656,53 @@  rtl8xxxu_wireless_mode(struct ieee80211_hw *hw, struct ieee80211_sta *sta)
 	return network_type;
 }
 
+static void rtl8xxxu_set_aifs(struct rtl8xxxu_priv *priv, u8 slot_time)
+{
+	u32 reg_edca_param[IEEE80211_NUM_ACS] = {
+		[IEEE80211_AC_VO] = REG_EDCA_VO_PARAM,
+		[IEEE80211_AC_VI] = REG_EDCA_VI_PARAM,
+		[IEEE80211_AC_BE] = REG_EDCA_BE_PARAM,
+		[IEEE80211_AC_BK] = REG_EDCA_BK_PARAM,
+	};
+	u32 val32;
+	u16 wireless_mode = 0;
+	u8 aifs, aifsn, sifs;
+	int i;
+
+	if (priv->vif) {
+		struct ieee80211_sta *sta;
+
+		rcu_read_lock();
+		sta = ieee80211_find_sta(priv->vif, priv->vif->bss_conf.bssid);
+		if (sta)
+			wireless_mode = rtl8xxxu_wireless_mode(priv->hw, sta);
+		rcu_read_unlock();
+	}
+
+	if (priv->hw->conf.chandef.chan->band == NL80211_BAND_5GHZ ||
+	    (wireless_mode & WIRELESS_MODE_N_24G))
+		sifs = 16;
+	else
+		sifs = 10;
+
+	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
+		val32 = rtl8xxxu_read32(priv, reg_edca_param[i]);
+
+		/* It was set in conf_tx. */
+		aifsn = val32 & 0xff;
+
+		/* aifsn not set yet or already fixed */
+		if (aifsn < 2 || aifsn > 15)
+			continue;
+
+		aifs = aifsn * slot_time + sifs;
+
+		val32 &= ~0xff;
+		val32 |= aifs;
+		rtl8xxxu_write32(priv, reg_edca_param[i], val32);
+	}
+}
+
 static void
 rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			  struct ieee80211_bss_conf *bss_conf, u64 changed)
@@ -4775,6 +4822,8 @@  rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		else
 			val8 = 20;
 		rtl8xxxu_write8(priv, REG_SLOT, val8);
+
+		rtl8xxxu_set_aifs(priv, val8);
 	}
 
 	if (changed & BSS_CHANGED_BSSID) {