wifi: rtw88: extend 88xxA support
v4 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 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: 61a5eb87b2d9b4d5e353780b781cf691f39ba9e1
Signature · 1 line
2.53.0
PATCH v4 1/7 wifi: rtw88: 8812a, 8814a: enable STBC for HT transmissions
8812a and 8814a support STBC, enable it.
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, 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
@@ -1583,7 +1583,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 v4 1/7] wifi: rtw88: 8812a, 8814a: enable STBC for HT transmissions
Hi Jie Feng,
Thanks for the update. Two comments below.
Quoted 1 line · Ho Jie Feng
8812a and 8814a support STBC, enable it.
Could you mention here that this enables HT TX STBC on these chips? As far as I can see, VHT TX STBC was already advertised when more than one RF path is available, so that would make the scope clearer.
[ ... ]
Quoted 1 line
Tested on RTL8812AU, STBC packets were captured in monitor mode.
Were these HT transmissions from the RTL8812AU, for example on 2.4 GHz or with an HT only AP? As far as I can see, we already advertise VHT TX STBC on this chip, so a VHT capture would not confirm the change here.
Best regards,
Luka Gejak
Re: [PATCH rtw-next v4 1/7] wifi: rtw88: 8812a, 8814a: enable STBC for HT transmissions
Quoted 5 lines · Luka Gejak
Hi Jie Feng,
Thanks for the update. Two comments below.
Quoted 8 lines
Quoted 1 line · Ho Jie Feng
8812a and 8814a support STBC, enable it.
Could you mention here that this enables HT TX STBC on these chips? As far as I can see, VHT TX STBC was already advertised when more than one RF path is available, so that would make the scope clearer.
The commit subject line already mentions HT explicitly, do you think it will be better
to put it again in the description too?
Quoted 7 lines
[ ... ]
Quoted 1 line
Tested on RTL8812AU, STBC packets were captured in monitor mode.
Were these HT transmissions from the RTL8812AU, for example on 2.4 GHz or with an HT only AP? As far as I can see, we already advertise VHT TX STBC on this chip, so a VHT capture would not confirm the change here.
Yes it is a HT only AP, I see HT STBC packets in the capture.
Quoted 2 lines
Best regards,
Luka Gejak
Re: [PATCH rtw-next v4 1/7] wifi: rtw88: 8812a, 8814a: enable STBC for HT transmissions
Quoted 12 lines · Jie Feng
Quoted 6 lines · Luka Gejak
Hi Jie Feng,
Thanks for the update. Two comments below.
On November 15, 2026 12:43:27 PM GMT+01:00, Ho Jie Feng
Quoted 4 lines
Quoted 1 line · wrote:
8812a and 8814a support STBC, enable it.
Quoted 7 lines
Quoted 2 lines
Could you mention here that this enables HT TX STBC on these chips? As far as I can see, VHT TX STBC was already advertised when more than one
RF
Quoted 1 line
path is available, so that would make the scope clearer.
The commit subject line already mentions HT explicitly, do you think it will be better
to put it again in the description too?
The subject makes the HT scope clear. I think it would still help to explain that these chips already advertised VHT TX STBC but did not advertise it for HT. That would give the change a little more context.
Quoted 10 lines
Quoted 8 lines
[ ... ]
Quoted 1 line
Tested on RTL8812AU, STBC packets were captured in monitor mode.
Were these HT transmissions from the RTL8812AU, for example on 2.4 GHz or with an HT only AP? As far as I can see, we already advertise VHT TX STBC on this chip, so a VHT capture would not confirm the change here.
Yes it is a HT only AP, I see HT STBC packets in the capture.
Thanks, that answers my question.
Best regards,
Luka Gejak
PATCH v4 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
PATCH v4 3/7 wifi: rtw88: correctly expose beamformee capabilities
In reply to Ho Jie FengMake 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
@@ -1606,6 +1606,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;
@@ -1624,10 +1625,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 (rtw_bf_support && 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 (rtw_bf_support && 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 v4 3/7] wifi: rtw88: correctly expose beamformee capabilities
Hi Jie Feng,
Thanks for the update. One comment below.
Quoted 3 lines · Ho Jie Feng
drivers/net/wireless/realtek/rtw88/main.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/wireless/realtek/rtw88/main.c +0
-0@@ -1624,10 +1625,13 @@ static void rtw_init_vht_cap(struct rtw_dev *rtwdev,
[ ... ]
drivers/net/wireless/realtek/rtw88/main.c static void rtw_init_vht_cap(struct rtw_dev *rtwdev, · line 1634
Quoted 7 lines
drivers/net/wireless/realtek/rtw88/main.c +7
-0+if (rtw_bf_support && 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 (rtw_bf_support && chip->bfer_mu_max_num) + vht_cap->cap |=IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE ;
As far as I can see, this also changes whether support_bf can be enabled at runtime. It is still writable, but if it is false when the adapter probes, writing Y later and reconnecting leaves these capabilities clear. rtw_set_supported_band() only runs from rtw_register_hw(), and the bool setter does not update the bands.
rtw_bf_assoc() checks these cached capabilities too, so neither SU nor MU setup can run. Before this patch, enabling the parameter before the next association worked on chips that already supported beamforming.
Could we keep that runtime enable working? If the setting now needs to be fixed at probe, maybe the parameter should be read only instead.
Best regards,
Luka Gejak
Re: [PATCH rtw-next v4 3/7] wifi: rtw88: correctly expose beamformee capabilities
In reply to Ho Jie FengOne more thing for this patch.
Quoted 2 lines · Ho Jie Feng
Make MU and SU capability flags each depend on the chip declared maximum instead of setting both flags together.
Could you also describe the problem with the old advertisement? As far as I can see, both SU and MU beamformee flags were set regardless of the chip limits. Explaining why they need separate checks would make the reason for the change clearer.
I think the new support_bf check is worth mentioning too, once the runtime behavior from my earlier reply is settled.
Best regards,
Luka Gejak
Re: [PATCH rtw-next v4 3/7] wifi: rtw88: correctly expose beamformee capabilities
In reply to Ho Jie FengHi Jie Feng,
Thanks for the patch. One comment on the description below.
Quoted 2 lines · Ho Jie Feng
Implement beamformee support for 88xxa since they have support for it.
Could you expand this a little to explain what was missing? As far as I can see, the chips had no config_bfee callback, and this adds the SU beamformee setup for RTL8812A, RTL8821A and RTL8814A.
I think a short explanation of the sounding and CSI report setup would make the change easier to follow.
Best regards,
Luka Gejak
Re: [PATCH rtw-next v4 3/7] wifi: rtw88: correctly expose beamformee capabilities
Quoted 15 lines · Luka Gejak
Hi Jie Feng,
Thanks for the patch. One comment on the description below.
Quoted 2 lines · Ho Jie Feng
Implement beamformee support for 88xxa since they have support for it.
Could you expand this a little to explain what was missing? As far as I can see, the chips had no
config_bfeecallback, and this adds the SU beamformee setup for RTL8812A, RTL8821A and RTL8814A.
Quoted 6 lines
I think a short explanation of the sounding and CSI report setup would make the change easier to follow.
Best regards,
Luka Gejak
This is supposed to be for patch 4. I have used a wrong message id.
PATCH v4 4/7 wifi: rtw88: 88xxa: receive VHT SU beamformed transmissions
In reply to Ho Jie FengImplement beamformee support for 88xxa since they have support for it.
--- 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
@@ -671,6 +671,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
PATCH v4 5/7 wifi: rtw88: prepare frequency-offset correction for more chips
In reply to Ho Jie FengPromote chip specific functions into the common core for cfo tracking. These become helpers which can be used by the other drivers.
--- 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 v4 5/7] wifi: rtw88: prepare frequency-offset correction for more chips
Hi Jie Feng,
Thanks for the patch. One small suggestion below.
Quoted 2 lines · Ho Jie Feng
Promote chip specific functions into the common core for cfo tracking. These become helpers which can be used by the other drivers.
Could you name RTL8822C as the source of these helpers and mention that the crystal register writes stay in the chip code? I think that would make the split between the common tracking logic and the hardware specific part clearer.
Best regards,
Luka Gejak
PATCH v4 6/7 wifi: rtw88: 88xxa: correct carrier-frequency offset
In reply to Ho Jie FengUse the newly promoted helpers to implement support for 88xxa
--- 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 v4 6/7] wifi: rtw88: 88xxa: correct carrier-frequency offset
Hi Jie Feng,
Thanks for the patch. One comment below.
Quoted 3 lines · Ho Jie Feng
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +0
-0@@ -1632,6 +1637,17 @@ void rtw88xxa_query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status,
[ ... ]
Quoted 1 line
+
rtw_phy_parsing_cfo(rtwdev, pkt_stat);
[ ... ]
Quoted 1 line
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +0
-0@@ -2020,6 +2036,21 @@ void rtw88xxa_phy_pwrtrack(struct rtw_dev *rtwdev,
[ ... ]
drivers/net/wireless/realtek/rtw88/rtw88xxa.c void rtw88xxa_phy_pwrtrack(struct rtw_dev *rtwdev, · line 2050
Quoted 6 lines
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +6
-0+ crystal_cap =rtw_phy_cfo_xcap_track (rtwdev,RTW_XCAP_MASK , bt_hold); +if (crystal_cap == cfo->crystal_cap) +return ; + + cfo->crystal_cap = crystal_cap; +rtw88xxa_set_crystal_cap (rtwdev, crystal_cap);
Could the shared helper discard the samples while sta_cnt != 1? In AP mode, frames from both clients match the interface BSSID, so these new calls keep adding their CFO samples. But rtw_phy_cfo_xcap_track() returns through rtw_phy_cfo_tracking_reset() before clearing the sums or counts.
So if I read it right, when one client leaves, the first adjustment still includes samples from that client. For example, on each reporting path, a +12 sample from the remaining client and a -48 sample from the other, followed by another +12, give an average of -20 kHz. The remaining client alone gives +30 kHz, so the first correction goes the wrong way.
This was already present on 8822c, and this patch makes it reachable on 88xxa too. I think the fix belongs in rtw_phy_cfo_xcap_track(), before these new callers start using it. Could the sums and counts be reset there when there is no single peer to track?
Best regards,
Luka Gejak
Re: [PATCH rtw-next v4 6/7] wifi: rtw88: 88xxa: correct carrier-frequency offset
In reply to Ho Jie FengHi Jie Feng,
One more thing in addition to the other patch 6 reply.
Quoted 1 line · Ho Jie Feng
Use the newly promoted helpers to implement support for 88xxa
Could you expand this to describe how the CFO samples are collected and used to adjust the crystal cap? I think the two path reporting limit on RTL8814A and the handling of the efuse crystal value are worth explaining too.
This adds more than the callbacks, and a short description would help explain the changes to the shared parser and chip initialization.
Best regards,
Luka Gejak
PATCH v4 7/7 wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
In reply to Ho Jie FengHonor 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 v4 7/7] wifi: rtw88: 8812a, 8821a: respect peer A-MPDU size limits
Hi Jie Feng,
I have one comment on this description as well.
Quoted 1 line · Ho Jie Feng
Honor the peer-advertised receive limit for transmitted A-MPDUs.
Could you mention that these chips had no set_ampdu_factor callback, so rtw_set_ampdu_factor() returned before programming the peer's limit?
I think it would also help to explain that the new setters clamp the factor to the chip limit before updating REG_AMPDU_MAX_LENGTH.
Best regards,
Luka Gejak