wifi: rtw88: Set AMPDU factor to hardware for RTL8814A

Tell the chip the maximum AMPDU size supported by the AP. This greatly
improves the TX speed of RTL8814AU in the 2.4 GHz band. Before: ~90
Mbps. After: ~300 Mbps.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/4edc2a63-81b3-431c-9a37-5a7d899a6cc2@gmail.com
This commit is contained in:
Bitterblue Smith 2025-04-02 18:31:12 +03:00 committed by Ping-Ke Shih
parent dcbb7bb3a3
commit 0d2a88690e
11 changed files with 55 additions and 0 deletions

View file

@ -396,6 +396,8 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw,
if (rtw_bf_support) if (rtw_bf_support)
rtw_bf_assoc(rtwdev, vif, conf); rtw_bf_assoc(rtwdev, vif, conf);
rtw_set_ampdu_factor(rtwdev, vif, conf);
rtw_fw_beacon_filter_config(rtwdev, true, vif); rtw_fw_beacon_filter_config(rtwdev, true, vif);
} else { } else {
rtw_leave_lps(rtwdev); rtw_leave_lps(rtwdev);

View file

@ -2447,6 +2447,38 @@ void rtw_core_enable_beacon(struct rtw_dev *rtwdev, bool enable)
} }
} }
void rtw_set_ampdu_factor(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *bss_conf)
{
const struct rtw_chip_ops *ops = rtwdev->chip->ops;
struct ieee80211_sta *sta;
u8 factor = 0xff;
if (!ops->set_ampdu_factor)
return;
rcu_read_lock();
sta = ieee80211_find_sta(vif, bss_conf->bssid);
if (!sta) {
rcu_read_unlock();
rtw_warn(rtwdev, "%s: failed to find station %pM\n",
__func__, bss_conf->bssid);
return;
}
if (sta->deflink.vht_cap.vht_supported)
factor = u32_get_bits(sta->deflink.vht_cap.cap,
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
else if (sta->deflink.ht_cap.ht_supported)
factor = sta->deflink.ht_cap.ampdu_factor;
rcu_read_unlock();
if (factor != 0xff)
ops->set_ampdu_factor(rtwdev, factor);
}
MODULE_AUTHOR("Realtek Corporation"); MODULE_AUTHOR("Realtek Corporation");
MODULE_DESCRIPTION("Realtek 802.11ac wireless core module"); MODULE_DESCRIPTION("Realtek 802.11ac wireless core module");
MODULE_LICENSE("Dual BSD/GPL"); MODULE_LICENSE("Dual BSD/GPL");

View file

@ -878,6 +878,7 @@ struct rtw_chip_ops {
u32 antenna_rx); u32 antenna_rx);
void (*cfg_ldo25)(struct rtw_dev *rtwdev, bool enable); void (*cfg_ldo25)(struct rtw_dev *rtwdev, bool enable);
void (*efuse_grant)(struct rtw_dev *rtwdev, bool enable); void (*efuse_grant)(struct rtw_dev *rtwdev, bool enable);
void (*set_ampdu_factor)(struct rtw_dev *rtwdev, u8 factor);
void (*false_alarm_statistics)(struct rtw_dev *rtwdev); void (*false_alarm_statistics)(struct rtw_dev *rtwdev);
void (*phy_calibration)(struct rtw_dev *rtwdev); void (*phy_calibration)(struct rtw_dev *rtwdev);
void (*dpk_track)(struct rtw_dev *rtwdev); void (*dpk_track)(struct rtw_dev *rtwdev);
@ -2272,4 +2273,6 @@ void rtw_update_channel(struct rtw_dev *rtwdev, u8 center_channel,
void rtw_core_port_switch(struct rtw_dev *rtwdev, struct ieee80211_vif *vif); void rtw_core_port_switch(struct rtw_dev *rtwdev, struct ieee80211_vif *vif);
bool rtw_core_check_sta_active(struct rtw_dev *rtwdev); bool rtw_core_check_sta_active(struct rtw_dev *rtwdev);
void rtw_core_enable_beacon(struct rtw_dev *rtwdev, bool enable); void rtw_core_enable_beacon(struct rtw_dev *rtwdev, bool enable);
void rtw_set_ampdu_factor(struct rtw_dev *rtwdev, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *bss_conf);
#endif #endif

View file

@ -1904,6 +1904,7 @@ static const struct rtw_chip_ops rtw8703b_ops = {
.set_antenna = NULL, .set_antenna = NULL,
.cfg_ldo25 = rtw8723x_cfg_ldo25, .cfg_ldo25 = rtw8723x_cfg_ldo25,
.efuse_grant = rtw8723x_efuse_grant, .efuse_grant = rtw8723x_efuse_grant,
.set_ampdu_factor = NULL,
.false_alarm_statistics = rtw8723x_false_alarm_statistics, .false_alarm_statistics = rtw8723x_false_alarm_statistics,
.phy_calibration = rtw8703b_phy_calibration, .phy_calibration = rtw8703b_phy_calibration,
.dpk_track = NULL, .dpk_track = NULL,

View file

@ -1404,6 +1404,7 @@ static const struct rtw_chip_ops rtw8723d_ops = {
.set_antenna = NULL, .set_antenna = NULL,
.cfg_ldo25 = rtw8723x_cfg_ldo25, .cfg_ldo25 = rtw8723x_cfg_ldo25,
.efuse_grant = rtw8723x_efuse_grant, .efuse_grant = rtw8723x_efuse_grant,
.set_ampdu_factor = NULL,
.false_alarm_statistics = rtw8723x_false_alarm_statistics, .false_alarm_statistics = rtw8723x_false_alarm_statistics,
.phy_calibration = rtw8723d_phy_calibration, .phy_calibration = rtw8723d_phy_calibration,
.cck_pd_set = rtw8723d_phy_cck_pd_set, .cck_pd_set = rtw8723d_phy_cck_pd_set,

View file

@ -925,6 +925,7 @@ static const struct rtw_chip_ops rtw8812a_ops = {
.set_tx_power_index = rtw88xxa_set_tx_power_index, .set_tx_power_index = rtw88xxa_set_tx_power_index,
.cfg_ldo25 = rtw8812a_cfg_ldo25, .cfg_ldo25 = rtw8812a_cfg_ldo25,
.efuse_grant = rtw88xxa_efuse_grant, .efuse_grant = rtw88xxa_efuse_grant,
.set_ampdu_factor = NULL,
.false_alarm_statistics = rtw88xxa_false_alarm_statistics, .false_alarm_statistics = rtw88xxa_false_alarm_statistics,
.phy_calibration = rtw8812a_phy_calibration, .phy_calibration = rtw8812a_phy_calibration,
.cck_pd_set = rtw88xxa_phy_cck_pd_set, .cck_pd_set = rtw88xxa_phy_cck_pd_set,

View file

@ -1332,6 +1332,16 @@ static void rtw8814a_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
{ {
} }
/* Without this RTL8814A sends too many frames and (some?) 11n AP
* can't handle it, resulting in low TX speed. Other chips seem fine.
*/
static void rtw8814a_set_ampdu_factor(struct rtw_dev *rtwdev, u8 factor)
{
factor = min_t(u8, factor, IEEE80211_VHT_MAX_AMPDU_256K);
rtw_write32(rtwdev, REG_AMPDU_MAX_LENGTH, (8192 << factor) - 1);
}
static void rtw8814a_false_alarm_statistics(struct rtw_dev *rtwdev) static void rtw8814a_false_alarm_statistics(struct rtw_dev *rtwdev)
{ {
struct rtw_dm_info *dm_info = &rtwdev->dm_info; struct rtw_dm_info *dm_info = &rtwdev->dm_info;
@ -2051,6 +2061,7 @@ static const struct rtw_chip_ops rtw8814a_ops = {
.set_antenna = NULL, .set_antenna = NULL,
.cfg_ldo25 = rtw8814a_cfg_ldo25, .cfg_ldo25 = rtw8814a_cfg_ldo25,
.efuse_grant = rtw8814a_efuse_grant, .efuse_grant = rtw8814a_efuse_grant,
.set_ampdu_factor = rtw8814a_set_ampdu_factor,
.false_alarm_statistics = rtw8814a_false_alarm_statistics, .false_alarm_statistics = rtw8814a_false_alarm_statistics,
.phy_calibration = rtw8814a_phy_calibration, .phy_calibration = rtw8814a_phy_calibration,
.cck_pd_set = rtw8814a_phy_cck_pd_set, .cck_pd_set = rtw8814a_phy_cck_pd_set,

View file

@ -871,6 +871,7 @@ static const struct rtw_chip_ops rtw8821a_ops = {
.set_tx_power_index = rtw88xxa_set_tx_power_index, .set_tx_power_index = rtw88xxa_set_tx_power_index,
.cfg_ldo25 = rtw8821a_cfg_ldo25, .cfg_ldo25 = rtw8821a_cfg_ldo25,
.efuse_grant = rtw88xxa_efuse_grant, .efuse_grant = rtw88xxa_efuse_grant,
.set_ampdu_factor = NULL,
.false_alarm_statistics = rtw88xxa_false_alarm_statistics, .false_alarm_statistics = rtw88xxa_false_alarm_statistics,
.phy_calibration = rtw8821a_phy_calibration, .phy_calibration = rtw8821a_phy_calibration,
.cck_pd_set = rtw88xxa_phy_cck_pd_set, .cck_pd_set = rtw88xxa_phy_cck_pd_set,

View file

@ -1668,6 +1668,7 @@ static const struct rtw_chip_ops rtw8821c_ops = {
.set_antenna = NULL, .set_antenna = NULL,
.set_tx_power_index = rtw8821c_set_tx_power_index, .set_tx_power_index = rtw8821c_set_tx_power_index,
.cfg_ldo25 = rtw8821c_cfg_ldo25, .cfg_ldo25 = rtw8821c_cfg_ldo25,
.set_ampdu_factor = NULL,
.false_alarm_statistics = rtw8821c_false_alarm_statistics, .false_alarm_statistics = rtw8821c_false_alarm_statistics,
.phy_calibration = rtw8821c_phy_calibration, .phy_calibration = rtw8821c_phy_calibration,
.cck_pd_set = rtw8821c_phy_cck_pd_set, .cck_pd_set = rtw8821c_phy_cck_pd_set,

View file

@ -2158,6 +2158,7 @@ static const struct rtw_chip_ops rtw8822b_ops = {
.set_tx_power_index = rtw8822b_set_tx_power_index, .set_tx_power_index = rtw8822b_set_tx_power_index,
.set_antenna = rtw8822b_set_antenna, .set_antenna = rtw8822b_set_antenna,
.cfg_ldo25 = rtw8822b_cfg_ldo25, .cfg_ldo25 = rtw8822b_cfg_ldo25,
.set_ampdu_factor = NULL,
.false_alarm_statistics = rtw8822b_false_alarm_statistics, .false_alarm_statistics = rtw8822b_false_alarm_statistics,
.phy_calibration = rtw8822b_phy_calibration, .phy_calibration = rtw8822b_phy_calibration,
.pwr_track = rtw8822b_pwr_track, .pwr_track = rtw8822b_pwr_track,

View file

@ -4968,6 +4968,7 @@ static const struct rtw_chip_ops rtw8822c_ops = {
.set_tx_power_index = rtw8822c_set_tx_power_index, .set_tx_power_index = rtw8822c_set_tx_power_index,
.set_antenna = rtw8822c_set_antenna, .set_antenna = rtw8822c_set_antenna,
.cfg_ldo25 = rtw8822c_cfg_ldo25, .cfg_ldo25 = rtw8822c_cfg_ldo25,
.set_ampdu_factor = NULL,
.false_alarm_statistics = rtw8822c_false_alarm_statistics, .false_alarm_statistics = rtw8822c_false_alarm_statistics,
.dpk_track = rtw8822c_dpk_track, .dpk_track = rtw8822c_dpk_track,
.phy_calibration = rtw8822c_phy_calibration, .phy_calibration = rtw8822c_phy_calibration,