Skip to content

Commit

Permalink
wifi: rtl8xxxu: Fix AIFS written to REG_EDCA_*_PARAM
Browse files Browse the repository at this point in the history
[ Upstream commit 5574d32 ]

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: 26f1fad ("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
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Bitterblue Smith authored and gregkh committed Oct 21, 2022
1 parent c621e38 commit 4a3653b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4a3653b

Please sign in to comment.