]> git.baikalelectronics.ru Git - kernel.git/commitdiff
wifi: rtl8xxxu: Fix AIFS written to REG_EDCA_*_PARAM
authorBitterblue Smith <rtl8821cerfe2@gmail.com>
Sun, 18 Sep 2022 12:42:25 +0000 (15:42 +0300)
committerKalle Valo <kvalo@kernel.org>
Thu, 29 Sep 2022 06:18:41 +0000 (09:18 +0300)
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: 08b253d81906 ("New driver: rtl8xxxu (mac80211)")
Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Jes Sorensen <jes@trained-monkey.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/038cc03f-3567-77ba-a7bd-c4930e3b2fad@gmail.com
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c

index 60ce65bcdd78256d674354aa19ff55fb5f552e06..731aba24bb381d5f7e0ec05d55c3297b5e4b639a 100644 (file)
@@ -4560,6 +4560,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)
@@ -4679,6 +4726,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) {