wifi: rtw88: extend 88xxA support
v5 cover wifi: rtw88: extend 88xxA support
This series enables HT STBC transmission, VHT SU beamformed reception and carrier-frequency-offset correction on supported 88xxA devices.
Tested on RTL8812AU:
TX went from 136.0 to 144.2.
RX went from 215.5 to 249.2.
Changelog v5:
- Rebase on latest rtw-next
- Beamformee caps: drop the support_bf check, so support_bf can
still be enabled at runtime
- Expand the commit messages
- Link to v4: https://lore.kernel.org/linux-wireless/[email protected]/
Changelog v4:
- Restore "wifi: rtw88: correctly expose beamformee capabilities"
- Add a patch to skip the dynamic CSI rate on chips without a
cfg_csi_rate op.
- Describe magic numbers
- Link to v3: https://lore.kernel.org/linux-wireless/[email protected]/
Changelog v3:
- Remove EDCCA commits since it causes problems in some situations
- Beamformee: gate on spatial streams instead of the RX antennas,
in case an antenna is disabled
- Beamformee: writes RTL8814A use rtw_write32_mask() instead of
an unaligned 16-bit write
- Beamformee: drop the chip ID from the debug message, style fixes
- CFO: add RTW_XCAP_MASK to phy.h
- CFO: use 0x20 as the RTL8814A crystal cap when the efuse is empty,
following the vendor driver
- CFO: add comment on why min(...,2) is needed for rtl8814
- A-MPDU: set BIT(31) of REG_AMPDU_MAX_LENGTH, like the vendor driver
- A-MPDU: limit RTL8821A with IEEE80211_VHT_MAX_AMPDU_64K
- Link to v2: https://lore.kernel.org/linux-wireless/[email protected]/
Changelog v2:
- Split correcting beamform caps into its own commit
- Adjust EDCCA threshold on scan to avoid high latency
- Link to v1: https://lore.kernel.org/linux-wireless/[email protected]/
Ho Jie Feng (7):
wifi: rtw88: 8812a, 8814a: enable STBC for HT transmissions
wifi: rtw88: skip the dynamic CSI rate without a cfg_csi_rate op
wifi: rtw88: correctly expose beamformee capabilities
wifi: rtw88: 88xxa: receive VHT SU beamformed transmissions
wifi: rtw88: prepare frequency-offset correction for more chips
wifi: rtw88: 88xxa: correct carrier-frequency offset
wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
drivers/net/wireless/realtek/rtw88/bf.h | 7 + drivers/net/wireless/realtek/rtw88/main.c | 17 ++- drivers/net/wireless/realtek/rtw88/phy.c | 109 +++++++++++++++- drivers/net/wireless/realtek/rtw88/phy.h | 8 ++ drivers/net/wireless/realtek/rtw88/reg.h | 1 + drivers/net/wireless/realtek/rtw88/rtw8812a.c | 17 ++- drivers/net/wireless/realtek/rtw88/rtw8814a.c | 75 ++++++++++- drivers/net/wireless/realtek/rtw88/rtw8821a.c | 16 ++- drivers/net/wireless/realtek/rtw88/rtw8822c.c | 100 +-------------- drivers/net/wireless/realtek/rtw88/rtw8822c.h | 3 - drivers/net/wireless/realtek/rtw88/rtw88xxa.c | 120 ++++++++++++++++-- drivers/net/wireless/realtek/rtw88/rtw88xxa.h | 3 + 12 files changed, 353 insertions(+), 123 deletions(-)
base-commit: ae6b9e98b9045e47f609ec2a8197a3f3109627cb
Signature · 1 line
2.53.0
PATCH v5 1/7 wifi: rtw88: 8812a, 8814a: enable STBC for HT transmissions
8812a and 8814a support HT STBC, enable it. Previously, only VHT TX STBC was advertised, this patch enables STBC for HT too.
8822c will lose reporting TX STBC capability if efuse reports only 1 path, but this is correct, since in that case it doesn't actually support STBC.
Tested on RTL8812AU with an HT only AP, HT STBC packets were captured in monitor mode.
--- drivers/net/wireless/realtek/rtw88/main.c | 2 +- drivers/net/wireless/realtek/rtw88/rtw8812a.c | 1 + drivers/net/wireless/realtek/rtw88/rtw8814a.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/main.c +1 -1
@@ -1591,7 +1591,7 @@ static void rtw_init_ht_cap(struct rtw_dev *rtwdev,if (rtw_chip_has_rx_ldpc (rtwdev)) ht_cap->cap |=IEEE80211_HT_CAP_LDPC_CODING ; -if (rtw_chip_has_tx_stbc (rtwdev)) +if (rtw_chip_has_tx_stbc (rtwdev) && rtwdev->hal.rf_path_num >1 ) ht_cap->cap |=IEEE80211_HT_CAP_TX_STBC ;if (efuse->hw_cap.bw &BIT (RTW_CHANNEL_WIDTH_40 ))
drivers/net/wireless/realtek/rtw88/rtw8812a.c +1 -0
@@ -1077,6 +1077,7 @@ const struct rtw_chip_info rtw8812a_hw_spec = { .rfe_defs = rtw8812a_rfe_defs, .rfe_defs_size = ARRAY_SIZE(rtw8812a_rfe_defs), .rx_ldpc = false, + .tx_stbc = true, .amsdu_in_ampdu = true, .hw_feature_report = false, .c2h_ra_report_size = 4,
drivers/net/wireless/realtek/rtw88/rtw8814a.c +1 -0
@@ -2200,6 +2200,7 @@ const struct rtw_chip_info rtw8814a_hw_spec = { .txgi_factor = 1, .is_pwr_by_rate_dec = true, .rx_ldpc = true, + .tx_stbc = true, .max_power_index = 0x3f, .ampdu_density = IEEE80211_HT_MPDU_DENSITY_2, .amsdu_in_ampdu = false, /* RX speed is better without AMSDU */
Signature · 1 line
2.53.0
Re: [PATCH rtw-next v5 1/7] wifi: rtw88: 8812a, 8814a: enable STBC for HT transmissions
Quoted 7 lines · Ho Jie Feng
8812a and 8814a support HT STBC, enable it. Previously, only VHT TX STBC was advertised, this patch enables STBC for HT too.
8822c will lose reporting TX STBC capability if efuse reports only 1 path, but this is correct, since in that case it doesn't actually support STBC.
Quoted 5 lines
Tested on RTL8812AU with an HT only AP, HT STBC packets were captured in monitor mode.
Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Best regards,
Luka Gejak
PATCH v5 2/7 wifi: rtw88: skip the dynamic CSI rate without a cfg_csi_rate op
In reply to Ho Jie Fengrtw_dynamic_csi_rate() runs from the watchdog for each vif that is a SU or MU beamformee. new_csi_rate_idx is only written by the cfg_csi_rate chip op, so on a chip without that op such as 88xxa, an uninitialized value is compared with cur_csi_rpt_rate.
Return early when the chip has no cfg_csi_rate op.
--- drivers/net/wireless/realtek/rtw88/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/realtek/rtw88/main.c +3 -0
@@ -174,6 +174,9 @@ static void rtw_dynamic_csi_rate(struct rtw_dev *rtwdev, struct rtw_vif *rtwvif)u8 fix_rate_enable =0 ;u8 new_csi_rate_idx; +if (!rtwdev->chip->ops->cfg_csi_rate) +return ; +if (rtwvif->bfee.role !=RTW_BFEE_SU && rtwvif->bfee.role !=RTW_BFEE_MU )return ;
Signature · 1 line
2.53.0
Re: [PATCH rtw-next v5 2/7] wifi: rtw88: skip the dynamic CSI rate without a cfg_csi_rate op
Quoted 10 lines · Ho Jie Feng
rtw_dynamic_csi_rate()runs from the watchdog for each vif that is a SU or MU beamformee.new_csi_rate_idxis only written by thecfg_csi_ratechip op, so on a chip without that op such as 88xxa, an uninitialized value is compared withcur_csi_rpt_rate.Return early when the chip has no
cfg_csi_rateop.Suggested-by Luka Gejak <[email protected]>Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Best regards,
Luka Gejak
PATCH v5 3/7 wifi: rtw88: correctly expose beamformee capabilities
In reply to Ho Jie FengBoth SU and MU beamformee flags were set on every VHT chip, regardless of the chip limits bfer_su_max_num and bfer_mu_max_num. This is wrong when the chip does not support SU or MU beamformee.
rtw_bf_assoc() also checks these flags. With an AP that is a MU beamformer, the MU flag makes it take the MU branch and return at bfer_mu_max_num, so a chip without MU support is never set up as a SU beamformee either.
Make MU and SU capability flags each depend on the chip declared maximum instead of setting both flags together.
--- drivers/net/wireless/realtek/rtw88/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtw88/main.c +8 -4
@@ -1614,6 +1614,7 @@ static void rtw_init_ht_cap(struct rtw_dev *rtwdev,static void rtw_init_vht_cap (struct rtw_dev *rtwdev,struct ieee80211_sta_vht_cap *vht_cap) { +const struct rtw_chip_info *chip = rtwdev->chip;struct rtw_efuse *efuse = &rtwdev->efuse;u16 mcs_map =0 ;__le16 highest;
@@ -1632,10 +1633,13 @@ static void rtw_init_vht_cap(struct rtw_dev *rtwdev,0 ;if (rtwdev->hal.rf_path_num >1 ) vht_cap->cap |=IEEE80211_VHT_CAP_TXSTBC ; - vht_cap->cap |=IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE | -IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE ; - vht_cap->cap |= (rtwdev->hal.bfee_sts_cap << -IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT ); +if (chip->bfer_su_max_num) { + vht_cap->cap |=IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE ; + vht_cap->cap |= rtwdev->hal.bfee_sts_cap << +IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT ; + } +if (chip->bfer_mu_max_num) + vht_cap->cap |=IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE ;if (rtw_chip_has_rx_ldpc (rtwdev)) vht_cap->cap |=IEEE80211_VHT_CAP_RXLDPC ;
Signature · 1 line
2.53.0
Re: [PATCH rtw-next v5 3/7] wifi: rtw88: correctly expose beamformee capabilities
Quoted 9 lines · Ho Jie Feng
Both SU and MU beamformee flags were set on every VHT chip, regardless of the chip limits
bfer_su_max_numandbfer_mu_max_num. This is wrong when the chip does not support SU or MU beamformee.
rtw_bf_assoc()also checks these flags. With an AP that is a MU beamformer, the MU flag makes it take the MU branch and return atbfer_mu_max_num, so a chip without MU support is never set up as a SU beamformee either.
Quoted 5 lines
Make MU and SU capability flags each depend on the chip declared maximum instead of setting both flags together.
Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Best regards,
Luka Gejak
PATCH v5 4/7 wifi: rtw88: 88xxa: receive VHT SU beamformed transmissions
In reply to Ho Jie FengRTL8812A, RTL8821A and RTL8814A can be a VHT SU beamformee, but they have no config_bfee callback and bfer_su_max_num is 0, so rtw_bf_assoc() never sets them up.
This adds the SU beamformee setup for these chips, for up to two beamformers. This is done by enabling sounding to the AP and setting the correct CSI report parameters.
--- drivers/net/wireless/realtek/rtw88/bf.h | 7 ++ drivers/net/wireless/realtek/rtw88/reg.h | 1 + drivers/net/wireless/realtek/rtw88/rtw8812a.c | 3 +- drivers/net/wireless/realtek/rtw88/rtw8814a.c | 42 ++++++++++- drivers/net/wireless/realtek/rtw88/rtw8821a.c | 3 +- drivers/net/wireless/realtek/rtw88/rtw88xxa.c | 73 +++++++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw88xxa.h | 2 + 7 files changed, 126 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtw88/bf.h +7 -0
@@ -12,9 +12,16 @@#define REG_ASSOCIATED_BFMER0_INFO 0x06E4#define REG_ASSOCIATED_BFMER1_INFO 0x06EC#define REG_TX_CSI_RPT_PARAM_BW20 0x06F4 +#define REG_TX_CSI_RPT_PARAM_BW40 0x06F8 +#define REG_TX_CSI_RPT_PARAM_BW80 0x06FC#define REG_SND_PTCL_CTRL 0x0718 +#define BIT_USE_NSTS BIT(7)#define BIT_DIS_CHK_VHTSIGB_CRC BIT(6)#define BIT_DIS_CHK_VHTSIGA_CRC BIT(5) +#define BIT_BFPARAM_SEL BIT(4) +#define BIT_CSISEQ_SEL BIT(3) +#define BIT_HT_NDPA_EN BIT(1) +#define BIT_VHT_NDPA_EN BIT(0)#define BIT_MASK_BEAMFORM (GENMASK(4, 0) | BIT(7))#define REG_MU_TX_CTL 0x14C0#define REG_MU_STA_GID_VLD 0x14C4
drivers/net/wireless/realtek/rtw88/reg.h +1 -0
@@ -672,6 +672,7 @@#define REG_IQK_COM96 0x0984#define REG_FAS 0x09a4 +#define REG_CSI_CONTENT_VALUE 0x09b4#define REG_RXSB 0x0a00#define BIT_RXSB_ANA_DIV BIT(15)#define REG_CCK_RX 0x0a04
drivers/net/wireless/realtek/rtw88/rtw8812a.c +2 -1
@@ -931,7 +931,7 @@ static const struct rtw_chip_ops rtw8812a_ops = { .phy_calibration = rtw8812a_phy_calibration, .cck_pd_set = rtw_phy_cck_pd_set, .pwr_track = rtw8812a_pwr_track, - .config_bfee = NULL, + .config_bfee = rtw88xxa_bf_config_bfee, .set_gid_table = NULL, .cfg_csi_rate = NULL, .led_set = rtw8812a_led_set,
@@ -1084,6 +1084,7 @@ const struct rtw_chip_info rtw8812a_hw_spec = { .old_datarate_fb_limit = true, .usb_tx_agg_desc_num = 1, .iqk_threshold = 8, + .bfer_su_max_num = 2, .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, .max_scan_ie_len = IEEE80211_MAX_DATA_LEN,
drivers/net/wireless/realtek/rtw88/rtw8814a.c +39 -3
74 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw8821a.c +2 -1
@@ -877,7 +877,7 @@ static const struct rtw_chip_ops rtw8821a_ops = { .phy_calibration = rtw8821a_phy_calibration, .cck_pd_set = rtw_phy_cck_pd_set, .pwr_track = rtw8821a_pwr_track, - .config_bfee = NULL, + .config_bfee = rtw88xxa_bf_config_bfee, .set_gid_table = NULL, .cfg_csi_rate = NULL, .led_set = rtw8821a_led_set,
@@ -1188,6 +1188,7 @@ const struct rtw_chip_info rtw8821a_hw_spec = { .old_datarate_fb_limit = true, .usb_tx_agg_desc_num = 6, .iqk_threshold = 8, + .bfer_su_max_num = 2, .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, .max_scan_ie_len = IEEE80211_MAX_DATA_LEN,
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +73 -0
85 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw88xxa.h +2 -0
@@ -170,5 +170,7 @@ bool rtw88xxa_iqk_finish(int average, int threshold,void rtw88xxa_phy_pwrtrack (struct rtw_dev *rtwdev,void (*do_lck)(struct rtw_dev *rtwdev),void (*do_iqk)(struct rtw_dev *rtwdev)); +void rtw88xxa_bf_config_bfee (struct rtw_dev *rtwdev,struct rtw_vif *vif, +struct rtw_bfee *bfee,bool enable);#endif
Signature · 1 line
2.53.0
Re: [PATCH rtw-next v5 4/7] wifi: rtw88: 88xxa: receive VHT SU beamformed transmissions
Quoted 10 lines · Ho Jie Feng
RTL8812A, RTL8821A and RTL8814A can be a VHT SU beamformee, but they have no
config_bfeecallback andbfer_su_max_numis 0, sortw_bf_assoc()never sets them up.This adds the SU beamformee setup for these chips, for up to two beamformers. This is done by enabling sounding to the AP and setting the correct CSI report parameters.
Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Best regards,
Luka Gejak
PATCH v5 5/7 wifi: rtw88: prepare frequency-offset correction for more chips
In reply to Ho Jie FengPromote chip specific functions from RTL8822C into the common core for cfo tracking. These become helpers which can be used by the other drivers.
Crystal register writes stay in the chip code, while common tracking logic is promoted. This ensures that the chip specific portion stays within the per chip files.
--- drivers/net/wireless/realtek/rtw88/phy.c | 106 ++++++++++++++++++ drivers/net/wireless/realtek/rtw88/phy.h | 2 + drivers/net/wireless/realtek/rtw88/rtw8822c.c | 100 +---------------- drivers/net/wireless/realtek/rtw88/rtw8822c.h | 3 - 4 files changed, 113 insertions(+), 98 deletions(-)
drivers/net/wireless/realtek/rtw88/phy.c +106 -0
@@ -720,6 +720,112 @@ void rtw_phy_parsing_cfo(struct rtw_dev *rtwdev, }EXPORT_SYMBOL (rtw_phy_parsing_cfo); +#define CFO_TRK_ENABLE_TH 20 +#define CFO_TRK_STOP_TH 10 +#define CFO_TRK_ADJ_TH 10 + +static u8 rtw_phy_cfo_tracking_reset (struct rtw_dev *rtwdev) +{ +struct rtw_dm_info *dm_info = &rtwdev->dm_info; +struct rtw_cfo_track *cfo = &dm_info->cfo_track; + + cfo->is_adjust = true; + +if (cfo->crystal_cap > rtwdev->efuse.crystal_cap) +return cfo->crystal_cap -1 ; +else if (cfo->crystal_cap < rtwdev->efuse.crystal_cap) +return cfo->crystal_cap +1 ; + +return cfo->crystal_cap; +} + +void rtw_phy_cfo_xcap_init (struct rtw_dev *rtwdev) +{ +struct rtw_dm_info *dm_info = &rtwdev->dm_info; +struct rtw_cfo_track *cfo = &dm_info->cfo_track; + + cfo->crystal_cap = rtwdev->efuse.crystal_cap; + cfo->is_adjust = true; +} +EXPORT_SYMBOL (rtw_phy_cfo_xcap_init); + +#define REPORT_TO_KHZ (val) ({typeof(val) _v = (val); (_v << 1) + (_v >> 1); }) +static s32 rtw_phy_cfo_calc_avg (struct rtw_dev *rtwdev,u8 path_num) +{ +struct rtw_dm_info *dm_info = &rtwdev->dm_info; +struct rtw_cfo_track *cfo = &dm_info->cfo_track; +s32 cfo_avg, cfo_path_sum =0 , cfo_rpt_sum; +u8 i; + +for (i =0 ; i < path_num; i++) { + cfo_rpt_sum =REPORT_TO_KHZ (cfo->cfo_tail[i]); + +if (cfo->cfo_cnt[i]) + cfo_avg = cfo_rpt_sum / cfo->cfo_cnt[i]; +else + cfo_avg =0 ; + + cfo_path_sum += cfo_avg; + } + +for (i =0 ; i < path_num; i++) { + cfo->cfo_tail[i] =0 ; + cfo->cfo_cnt[i] =0 ; + } + +return cfo_path_sum / path_num; +} + +static void rtw_phy_cfo_need_adjust (struct rtw_dev *rtwdev,s32 cfo_avg) +{ +struct rtw_dm_info *dm_info = &rtwdev->dm_info; +struct rtw_cfo_track *cfo = &dm_info->cfo_track; + +if (!cfo->is_adjust) { +if (abs (cfo_avg) >CFO_TRK_ENABLE_TH ) + cfo->is_adjust = true; + }else { +if (abs (cfo_avg) <=CFO_TRK_STOP_TH ) + cfo->is_adjust = false; + } +} + +u8 rtw_phy_cfo_xcap_track (struct rtw_dev *rtwdev,u8 xcap_max,bool bt_hold) +{ +struct rtw_dm_info *dm_info = &rtwdev->dm_info; +struct rtw_cfo_track *cfo = &dm_info->cfo_track; +u8 path_num = rtwdev->hal.rf_path_num; +s8 crystal_cap = cfo->crystal_cap; +s32 cfo_avg =0 ; + +if (rtwdev->sta_cnt !=1 ) +return rtw_phy_cfo_tracking_reset (rtwdev); + +if (cfo->packet_count == cfo->packet_count_pre) +return cfo->crystal_cap; + + cfo->packet_count_pre = cfo->packet_count; + cfo_avg =rtw_phy_cfo_calc_avg (rtwdev, path_num); +rtw_phy_cfo_need_adjust (rtwdev, cfo_avg); + +if (bt_hold) { + cfo->is_adjust = false; +return rtwdev->efuse.crystal_cap; + } + +if (cfo->is_adjust) { +if (cfo_avg >CFO_TRK_ADJ_TH ) + crystal_cap++; +else if (cfo_avg < -CFO_TRK_ADJ_TH ) + crystal_cap--; + + crystal_cap =clamp_t (s8, crystal_cap,0 , xcap_max); + } + +return (u8 )crystal_cap; +} +EXPORT_SYMBOL (rtw_phy_cfo_xcap_track); +static void rtw_phy_cfo_track (struct rtw_dev *rtwdev) {const struct rtw_chip_info *chip = rtwdev->chip;
drivers/net/wireless/realtek/rtw88/phy.h +2 -0
@@ -68,6 +68,8 @@ void rtw_phy_adaptivity_set_mode(struct rtw_dev *rtwdev);void rtw_phy_cck_pd_set (struct rtw_dev *rtwdev,u8 new_lvl);void rtw_phy_parsing_cfo (struct rtw_dev *rtwdev,struct rtw_rx_pkt_stat *pkt_stat); +void rtw_phy_cfo_xcap_init (struct rtw_dev *rtwdev); +u8 rtw_phy_cfo_xcap_track (struct rtw_dev *rtwdev,u8 xcap_max,bool bt_hold);void rtw_phy_tx_path_diversity (struct rtw_dev *rtwdev);struct rtw_txpwr_lmt_cfg_pair {
drivers/net/wireless/realtek/rtw88/rtw8822c.c +5 -95
115 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw8822c.h +0 -3
@@ -181,9 +181,6 @@ const struct rtw_table name ## _tbl = { \#define REG_ANAPARLDO_POW_MAC 0x0029#define BIT_LDOE25_PON BIT(0)#define XCAP_MASK GENMASK(6, 0) -#define CFO_TRK_ENABLE_TH 20 -#define CFO_TRK_STOP_TH 10 -#define CFO_TRK_ADJ_TH 10#define REG_TXDFIR0 0x808#define REG_DFIRBW 0x810
Signature · 1 line
2.53.0
Re: [PATCH rtw-next v5 5/7] wifi: rtw88: prepare frequency-offset correction for more chips
Quoted 10 lines · Ho Jie Feng
Promote chip specific functions from RTL8822C into the common core for cfo tracking. These become helpers which can be used by the other drivers.
Crystal register writes stay in the chip code, while common tracking logic is promoted. This ensures that the chip specific portion stays within the per chip files.
Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Best regards,
Luka Gejak
PATCH v5 6/7 wifi: rtw88: 88xxa: correct carrier-frequency offset
In reply to Ho Jie FengUse the newly promoted helpers to implement CFO tracking for 88xxa.
The PHY status of each received frame reports a CFO tail per RF path. The CFO tracking code averages them and corrects the offset if the offset is too large.
RTL8814A has four RF paths, but reports a CFO tail only for paths A and B, so we only take the CFO tail of 2 paths.
The crystal cap is 6 bits wide on all chips except RTL8822C. Obtain the correct value by masking it. For RTL8814A, use 0x20 if the the efuse is empty, like the vendor driver.
--- drivers/net/wireless/realtek/rtw88/phy.c | 5 +- drivers/net/wireless/realtek/rtw88/phy.h | 6 +++ drivers/net/wireless/realtek/rtw88/rtw8812a.c | 2 + drivers/net/wireless/realtek/rtw88/rtw8814a.c | 32 +++++++++++-- drivers/net/wireless/realtek/rtw88/rtw8821a.c | 2 + drivers/net/wireless/realtek/rtw88/rtw88xxa.c | 47 +++++++++++++++---- drivers/net/wireless/realtek/rtw88/rtw88xxa.h | 1 + 7 files changed, 81 insertions(+), 14 deletions(-)
drivers/net/wireless/realtek/rtw88/phy.c +3 -2
@@ -687,13 +687,14 @@ static void rtw_phy_parsing_cfo_iter(void *data, u8 *mac,struct rtw_rx_pkt_stat *pkt_stat = iter_data->pkt_stat;struct rtw_dm_info *dm_info = &rtwdev->dm_info;struct rtw_cfo_track *cfo = &dm_info->cfo_track; +u8 path_num =min_t (u8, rtwdev->hal.rf_path_num,RTW_CFO_PATH_NUM_MAX );u8 *bssid = iter_data->bssid;u8 i;if (!ether_addr_equal (vif->bss_conf.bssid, bssid))return ; -for (i =0 ; i < rtwdev->hal.rf_path_num; i++) { +for (i =0 ; i < path_num; i++) { cfo->cfo_tail[i] += pkt_stat->cfo_tail[i]; cfo->cfo_cnt[i]++; }
@@ -794,7 +795,7 @@ u8 rtw_phy_cfo_xcap_track(struct rtw_dev *rtwdev, u8 xcap_max, bool bt_hold) {struct rtw_dm_info *dm_info = &rtwdev->dm_info;struct rtw_cfo_track *cfo = &dm_info->cfo_track; -u8 path_num = rtwdev->hal.rf_path_num; +u8 path_num =min_t (u8, rtwdev->hal.rf_path_num,RTW_CFO_PATH_NUM_MAX );s8 crystal_cap = cfo->crystal_cap;s32 cfo_avg =0 ;
drivers/net/wireless/realtek/rtw88/phy.h +6 -0
@@ -204,4 +204,10 @@ enum rtw_phy_cck_pd_lv {#define RRSR_RATE_ORDER_MAX 0xfffff#define RRSR_RATE_ORDER_CCK_LEN 4 +/* crystal cap width of all chips except RTL8822C */ +#define RTW_XCAP_MASK GENMASK(5, 0) + +/* RTL8814A has 4 paths, but only paths A and B report CFO */ +#define RTW_CFO_PATH_NUM_MAX 2 +#endif
drivers/net/wireless/realtek/rtw88/rtw8812a.c +2 -0
@@ -943,6 +943,8 @@ static const struct rtw_chip_ops rtw8812a_ops = { .coex_set_rfe_type = rtw8821a_coex_cfg_rfe_type, .coex_set_wl_tx_power = rtw8821a_coex_cfg_wl_tx_power, .coex_set_wl_rx_gain = rtw8821a_coex_cfg_wl_rx_gain, + .cfo_init = rtw_phy_cfo_xcap_init, + .cfo_track = rtw88xxa_cfo_track, };static const struct rtw_page_table page_table_8812a[] = {
drivers/net/wireless/realtek/rtw88/rtw8814a.c +28 -4
@@ -146,6 +146,9 @@ static int rtw8814a_read_efuse(struct rtw_dev *rtwdev, u8 *log_map, u8 *phy_map) efuse->rfe_option = map->rfe_option; efuse->rf_board_option = map->rf_board_option; efuse->crystal_cap = map->xtal_k; +if (efuse->crystal_cap ==0xff ) + efuse->crystal_cap =0x20 ; + efuse->crystal_cap &=RTW_XCAP_MASK ; efuse->channel_plan = map->channel_plan; efuse->country_code[0 ] = map->country_code[0 ]; efuse->country_code[1 ] = map->country_code[1 ];
@@ -284,9 +287,15 @@ static void rtw8814a_config_cck_rx_antenna_init(struct rtw_dev *rtwdev)rtw_write32_mask (rtwdev,REG_CCKTX ,BIT_CMB_CCA_2R ,1 ); } +static void rtw8814a_set_crystal_cap (struct rtw_dev *rtwdev,u8 crystal_cap) +{ +rtw_write32_mask (rtwdev,REG_AFE_CTRL3 ,0x07ff8000 , + crystal_cap | (crystal_cap <<6 )); +} +static void rtw8814a_phy_set_param (struct rtw_dev *rtwdev) { -u32 crystal_cap, val32; +u32 val32;u8 val8, rf_path;/* power on BB/RF domain */
@@ -308,9 +317,7 @@ static void rtw8814a_phy_set_param(struct rtw_dev *rtwdev)rtw_load_table (rtwdev, rtwdev->chip->bb_tbl);rtw_load_table (rtwdev, rtwdev->chip->agc_tbl); - crystal_cap = rtwdev->efuse.crystal_cap &0x3F ; - crystal_cap |= crystal_cap <<6 ; -rtw_write32_mask (rtwdev,REG_AFE_CTRL3 ,0x07ff8000 , crystal_cap); +rtw8814a_set_crystal_cap (rtwdev, rtwdev->efuse.crystal_cap);rtw8814a_config_trx_path (rtwdev);
@@ -1269,6 +1276,8 @@ static void rtw8814a_query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status, pkt_stat->cfo_tail[i] = cfo[i]; dm_info->cfo_tail[i] = (cfo[i] *5 ) >>1 ; } + +rtw_phy_parsing_cfo (rtwdev, pkt_stat); } }
@@ -2074,6 +2083,19 @@ static void rtw8814a_bf_config_bfee(struct rtw_dev *rtwdev,rtw_bf_remove_bfee_su (rtwdev, bfee); } +static void rtw8814a_cfo_track (struct rtw_dev *rtwdev) +{ +struct rtw_cfo_track *cfo = &rtwdev->dm_info.cfo_track; +u8 crystal_cap; + + crystal_cap =rtw_phy_cfo_xcap_track (rtwdev,RTW_XCAP_MASK , false); +if (crystal_cap == cfo->crystal_cap) +return ; + + cfo->crystal_cap = crystal_cap; +rtw8814a_set_crystal_cap (rtwdev, crystal_cap); +} +static void rtw8814a_fill_txdesc_checksum (struct rtw_dev *rtwdev,struct rtw_tx_pkt_info *pkt_info,u8 *txdesc)
@@ -2108,6 +2130,8 @@ static const struct rtw_chip_ops rtw8814a_ops = { .cfg_csi_rate = NULL, .led_set = rtw8814a_led_set, .fill_txdesc_checksum = rtw8814a_fill_txdesc_checksum, + .cfo_init = rtw_phy_cfo_xcap_init, + .cfo_track = rtw8814a_cfo_track, .coex_set_init = rtw8814a_coex_cfg_init, .coex_set_ant_switch = rtw8814a_coex_cfg_ant_switch,
drivers/net/wireless/realtek/rtw88/rtw8821a.c +2 -0
@@ -889,6 +889,8 @@ static const struct rtw_chip_ops rtw8821a_ops = { .coex_set_rfe_type = rtw8821a_coex_cfg_rfe_type, .coex_set_wl_tx_power = rtw8821a_coex_cfg_wl_tx_power, .coex_set_wl_rx_gain = rtw8821a_coex_cfg_wl_rx_gain, + .cfo_init = rtw_phy_cfo_xcap_init, + .cfo_track = rtw88xxa_cfo_track, };static const struct rtw_page_table page_table_8821a[] = {
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +39 -8
79 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw88xxa.h +1 -0
@@ -172,5 +172,6 @@ void rtw88xxa_phy_pwrtrack(struct rtw_dev *rtwdev, void (*do_iqk)(struct rtw_dev *rtwdev));void rtw88xxa_bf_config_bfee (struct rtw_dev *rtwdev,struct rtw_vif *vif,struct rtw_bfee *bfee,bool enable); +void rtw88xxa_cfo_track (struct rtw_dev *rtwdev);#endif
Signature · 1 line
2.53.0
Re: [PATCH rtw-next v5 6/7] wifi: rtw88: 88xxa: correct carrier-frequency offset
Hi Jie Feng,
Thanks for the update. Two comments below.
drivers/net/wireless/realtek/rtw88/phy.c static void rtw_phy_parsing_cfo_iter(void *data, u8 *mac, · line 700
Quoted 5 lines · Ho Jie Feng
drivers/net/wireless/realtek/rtw88/phy.c +1
-1-for (i =0 ; i < rtwdev->hal.rf_path_num; i++) { +for (i =0 ; i < path_num; i++) { cfo->cfo_tail[i] += pkt_stat->cfo_tail[i]; cfo->cfo_cnt[i]++; }
As far as I can see, RX can update these fields while the watchdog is running rtw_phy_cfo_calc_avg(). It reads the sum and count separately, then clears them in a second loop. A packet that arrives in between can be counted against the wrong sum or cleared before it is used. That can change the crystal adjustment even with a single peer.
I think the same race exists on RTL8822C. Could we take and clear the samples under the same lock as the RX updates before using the helper on these chips?
[ ... ]
drivers/net/wireless/realtek/rtw88/rtw88xxa.c void rtw88xxa_phy_pwrtrack(struct rtw_dev *rtwdev, · line 2045
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +4
-0+bool bt_hold = rtwdev->efuse.btcoex && !rtw_coex_disabled (rtwdev); +u8 crystal_cap; + + crystal_cap =rtw_phy_cfo_xcap_track (rtwdev,RTW_XCAP_MASK , bt_hold);
So if I read it right, the helper returns the current cap when no new CFO samples have arrived, before checking bt_hold. If the RTL8821AU already adjusted the cap, a firmware report that Bluetooth is active can set bt_hold while WiFi is idle. The cap then stays adjusted until another CFO sample arrives. On 2.4 GHz the AP may only be sending CCK beacons in the meantime, which this path doesn't sample.
Could the Bluetooth check restore the efuse value even when the sample count has not changed?
Best regards,
Luka Gejak
Re: [PATCH rtw-next v5 6/7] wifi: rtw88: 88xxa: correct carrier-frequency offset
Quoted 20 lines · Luka Gejak
Hi Jie Feng,
Thanks for the update. Two comments below.
drivers/net/wireless/realtek/rtw88/phy.c static void rtw_phy_parsing_cfo_iter(void *data, u8 *mac, · line 700
Quoted 5 lines · Ho Jie Feng
drivers/net/wireless/realtek/rtw88/phy.c +1
-1-for (i =0 ; i < rtwdev->hal.rf_path_num; i++) { +for (i =0 ; i < path_num; i++) { cfo->cfo_tail[i] += pkt_stat->cfo_tail[i]; cfo->cfo_cnt[i]++; }As far as I can see, RX can update these fields while the watchdog is running
rtw_phy_cfo_calc_avg(). It reads the sum and count separately, then clears them in a second loop. A packet that arrives in between can be counted against the wrong sum or cleared before it is used. That can change the crystal adjustment even with a single peer.
Quoted 3 lines
I think the same race exists on RTL8822C. Could we take and clear the samples under the same lock as the RX updates before using the helper on these chips?
Yes, that makes sense. This could also be part of a CFO fixup patch series later? I don't want to unnecessarily bloat this patch series too much, and it currently doesn't change behaviour for RTL8822C.
Quoted 14 lines
[ ... ]
drivers/net/wireless/realtek/rtw88/rtw88xxa.c void rtw88xxa_phy_pwrtrack(struct rtw_dev *rtwdev, · line 2045
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +4
-0+bool bt_hold = rtwdev->efuse.btcoex && !rtw_coex_disabled (rtwdev); +u8 crystal_cap; + + crystal_cap =rtw_phy_cfo_xcap_track (rtwdev,RTW_XCAP_MASK , bt_hold);So if I read it right, the helper returns the current cap when no new CFO samples have arrived, before checking
bt_hold. If the RTL8821AU already adjusted the cap, a firmware report that Bluetooth is active can setbt_holdwhile WiFi is idle. The cap then stays adjusted until another CFO sample arrives. On 2.4 GHz the AP may only be sending CCK beacons in the meantime, which this path doesn't sample.
Quoted 2 lines
Could the Bluetooth check restore the efuse value even when the sample count has not changed?
This is also an existing bug in RTL8822C, so same as the above?
Quoted 2 lines
Best regards,
Luka Gejak
Re: [PATCH rtw-next v5 6/7] wifi: rtw88: 88xxa: correct carrier-frequency offset
Quoted 21 lines · Jie Feng
Quoted 20 lines · Luka Gejak
Hi Jie Feng,
Thanks for the update. Two comments below.
drivers/net/wireless/realtek/rtw88/phy.c static void rtw_phy_parsing_cfo_iter(void *data, u8 *mac, · line 700
Quoted 5 lines · Ho Jie Feng
drivers/net/wireless/realtek/rtw88/phy.c +1
-1-for (i =0 ; i < rtwdev->hal.rf_path_num; i++) { +for (i =0 ; i < path_num; i++) { cfo->cfo_tail[i] += pkt_stat->cfo_tail[i]; cfo->cfo_cnt[i]++; }As far as I can see, RX can update these fields while the watchdog is running
rtw_phy_cfo_calc_avg(). It reads the sum and count separately, then clears them in a second loop. A packet that arrives in between can be counted against the wrong sum or cleared before it is used. That can change the crystal adjustment even with a single peer.
Quoted 6 lines
Quoted 3 lines
I think the same race exists on RTL8822C. Could we take and clear the samples under the same lock as the RX updates before using the helper on these chips?
Yes, that makes sense. This could also be part of a CFO fixup patch series later? I don't want to unnecessarily bloat this patch series too much, and it currently doesn't change behaviour for RTL8822C.
Fine by me.
Quoted 17 lines
Quoted 4 lines
[ ... ]
Quoted 1 line
+ bool
bt_hold=rtwdev->efuse.btcoex&&!rtw_coex_disabled(rtwdev);
Quoted 3 lines
drivers/net/wireless/realtek/rtw88/rtw8814a.c static void rtw8814a_bf_config_bfee(struct rtw_dev *rtwdev,
Quoted 3 lines
drivers/net/wireless/realtek/rtw88/rtw8814a.c +3
-0+u8 crystal_cap; + + crystal_cap = rtw_phy_cfo_xcap_track(rtwdev, RTW_XCAP_MASK,
bt_hold);Quoted 8 lines
So if I read it right, the helper returns the current cap when no new CFO samples have arrived, before checking
bt_hold. If the RTL8821AU already adjusted the cap, a firmware report that Bluetooth is active can setbt_holdwhile WiFi is idle. The cap then stays adjusted until another CFO sample arrives. On 2.4 GHz the AP may only be sending CCK beacons in the meantime, which this path doesn't sample.
Quoted 4 lines
Quoted 2 lines
Could the Bluetooth check restore the efuse value even when the sample count has not changed?
This is also an existing bug in RTL8822C, so same as the above?
That works for me.
Best regards,
Luka Gejak
Re: [PATCH rtw-next v5 6/7] wifi: rtw88: 88xxa: correct carrier-frequency offset
In reply to Ho Jie FengQuoted 9 lines · Ho Jie Feng
Use the newly promoted helpers to implement CFO tracking for 88xxa.
The PHY status of each received frame reports a CFO tail per RF path. The CFO tracking code averages them and corrects the offset if the offset is too large.
RTL8814A has four RF paths, but reports a CFO tail only for paths A and B, so we only take the CFO tail of 2 paths.
Quoted 6 lines
The crystal cap is 6 bits wide on all chips except RTL8822C. Obtain the correct value by masking it. For RTL8814A, use
0x20if the the efuse is empty, like the vendor driver.Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Best regards,
Luka Gejak
PATCH v5 7/7 wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
In reply to Ho Jie FengPreviously, these chips had no set_ampdu_factor callback, so rtw_set_ampdu_factor() returned before programming the peer's limit.
Honor the peer-advertised receive limit for transmitted A-MPDUs.
--- drivers/net/wireless/realtek/rtw88/rtw8812a.c | 11 ++++++++++- drivers/net/wireless/realtek/rtw88/rtw8821a.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/rtw8812a.c +10 -1
@@ -78,6 +78,15 @@ static void rtw8812a_cfg_ldo25(struct rtw_dev *rtwdev, bool enable) { } +static void rtw8812a_set_ampdu_factor (struct rtw_dev *rtwdev,u8 factor) +{ + factor =min_t (u8, factor,IEEE80211_VHT_MAX_AMPDU_128K ); + +/* the vendor driver sets the undocumented BIT(31) */ +rtw_write32 (rtwdev,REG_AMPDU_MAX_LENGTH , + ((8192 << factor) -1 ) |BIT (31 )); +} +static void rtw8812a_do_lck (struct rtw_dev *rtwdev) {u32 cont_tx, lc_cal, i;
@@ -926,7 +935,7 @@ static const struct rtw_chip_ops rtw8812a_ops = { .set_tx_power_index = rtw88xxa_set_tx_power_index, .cfg_ldo25 = rtw8812a_cfg_ldo25, .efuse_grant = rtw88xxa_efuse_grant, - .set_ampdu_factor = NULL, + .set_ampdu_factor = rtw8812a_set_ampdu_factor, .false_alarm_statistics = rtw88xxa_false_alarm_statistics, .phy_calibration = rtw8812a_phy_calibration, .cck_pd_set = rtw_phy_cck_pd_set,
drivers/net/wireless/realtek/rtw88/rtw8821a.c +10 -1
@@ -49,6 +49,15 @@ static void rtw8821a_cfg_ldo25(struct rtw_dev *rtwdev, bool enable) { } +static void rtw8821a_set_ampdu_factor (struct rtw_dev *rtwdev,u8 factor) +{ + factor =min_t (u8, factor,IEEE80211_VHT_MAX_AMPDU_64K ); + +/* the vendor driver sets the undocumented BIT(31) */ +rtw_write32 (rtwdev,REG_AMPDU_MAX_LENGTH , + ((8192 << factor) -1 ) |BIT (31 )); +} +#define CAL_NUM_8821A 3#define MACBB_REG_NUM_8821A 8#define AFE_REG_NUM_8821A 4
@@ -872,7 +881,7 @@ static const struct rtw_chip_ops rtw8821a_ops = { .set_tx_power_index = rtw88xxa_set_tx_power_index, .cfg_ldo25 = rtw8821a_cfg_ldo25, .efuse_grant = rtw88xxa_efuse_grant, - .set_ampdu_factor = NULL, + .set_ampdu_factor = rtw8821a_set_ampdu_factor, .false_alarm_statistics = rtw88xxa_false_alarm_statistics, .phy_calibration = rtw8821a_phy_calibration, .cck_pd_set = rtw_phy_cck_pd_set,
Signature · 1 line
2.53.0
Re: [PATCH rtw-next v5 7/7] wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
Hi Jie Feng,
Thanks for the patch. One comment below.
drivers/net/wireless/realtek/rtw88/rtw8812a.c static const struct rtw_chip_ops rtw8812a_ops = { · line 938
Quoted 2 lines · Ho Jie Feng
drivers/net/wireless/realtek/rtw88/rtw8812a.c +1
-1- .set_ampdu_factor = NULL, + .set_ampdu_factor = rtw8812a_set_ampdu_factor,
I think this only programs the byte limit when the adapter joins an AP. The only caller of rtw_set_ampdu_factor() is the BSS_CHANGED_ASSOC handler. An AP client goes through rtw_ops_sta_add() and rtw_ops_ampdu_action(). Those paths leave the byte limit alone, even with a single client. On a fresh AP start that leaves the value from MAC initialization. The aggregate limit in the TX descriptor is an MPDU count. The same applies to RTL8821A.
Is managed mode the intended scope here?
Best regards,
Luka Gejak
Re: [PATCH rtw-next v5 7/7] wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
Quoted 19 lines · Luka Gejak
Hi Jie Feng,
Thanks for the patch. One comment below.
drivers/net/wireless/realtek/rtw88/rtw8812a.c static const struct rtw_chip_ops rtw8812a_ops = { · line 938
Quoted 2 lines · Ho Jie Feng
drivers/net/wireless/realtek/rtw88/rtw8812a.c +1
-1- .set_ampdu_factor = NULL, + .set_ampdu_factor = rtw8812a_set_ampdu_factor,I think this only programs the byte limit when the adapter joins an AP. The only caller of
rtw_set_ampdu_factor()is theBSS_CHANGED_ASSOChandler. An AP client goes throughrtw_ops_sta_add()andrtw_ops_ampdu_action(). Those paths leave the byte limit alone, even with a single client. On a fresh AP start that leaves the value from MAC initialization. The aggregate limit in the TX descriptor is an MPDU count. The same applies to RTL8821A.
Quoted 1 line
Is managed mode the intended scope here?
Yes.
Quoted 2 lines
Best regards,
Luka Gejak
Re: [PATCH rtw-next v5 7/7] wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
In reply to Ho Jie FengQuoted 8 lines · Ho Jie Feng
Previously, these chips had no
set_ampdu_factorcallback, sortw_set_ampdu_factor()returned before programming the peer's limit.Honor the peer-advertised receive limit for transmitted A-MPDUs.
Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Best regards,
Luka Gejak
Re: [PATCH rtw-next v5 7/7] wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
Quoted 7 lines · Luka Gejak
Quoted 4 lines · Ho Jie Feng
Previously, these chips had no
set_ampdu_factorcallback, sortw_set_ampdu_factor()returned before programming the peer's limit.
Quoted 8 lines
Quoted 4 lines
Honor the peer-advertised receive limit for transmitted A-MPDUs.
Signed-off-by Ho Jie Feng <[email protected]>---
Looks good to me,
Reviewed-by Luka Gejak <[email protected]>
Thanks for reviewing all the revisions!
Quoted 2 lines
Best regards,
Luka Gejak
Best regards,
Jie Feng