Skip to contentSkip to conversation

wifi: rtw88: Prepare to support RTL8814AU (part 1/2)

PATCH Superseded Bitterblue Smith 2 participants 22 messages Jan 26, 2025 – Jan 30, 2025 Realtek wireless driver (rtw88)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover wifi: rtw88: Prepare to support RTL8814AU (part 1/2)

A few small changes for RTL8814AU. Mostly it's about supporting more than 2 RF paths and spatial streams.

Part 2 will have 7 more patches to prepare things.

Part 3 will be mostly the new files for RTL8814AU.

Part 4 will improve performance.

Bitterblue Smith (7):
wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
wifi: rtw88: Fix download_firmware_validate() for RTL8814AU
wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU
wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU
wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
wifi: rtw88: Extend TX power stuff for 3-4 spatial streams
wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU

 drivers/net/wireless/realtek/rtw88/fw.c       |  14 ++
 drivers/net/wireless/realtek/rtw88/fw.h       |   1 +
 drivers/net/wireless/realtek/rtw88/mac.c      |   6 +-
 drivers/net/wireless/realtek/rtw88/main.c     |  14 +-
 drivers/net/wireless/realtek/rtw88/main.h     |  20 ++-
 drivers/net/wireless/realtek/rtw88/phy.c      | 149 ++++++++++++------
 drivers/net/wireless/realtek/rtw88/phy.h      |   4 +
 drivers/net/wireless/realtek/rtw88/reg.h      |   3 +-
 drivers/net/wireless/realtek/rtw88/rtw8821c.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822b.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822c.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw88xxa.c |   2 +-
 12 files changed, 158 insertions(+), 61 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/7 wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU

Don't call ltecoex_read_reg() and ltecoex_reg_write() when the ltecoex_addr member of struct rtw_chip_info is NULL. The RTL8814AU doesn't have this feature.

---
 drivers/net/wireless/realtek/rtw88/mac.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/mac.c +4 -2
index cae9cca6dca3..63edf6461de8 100644
@@ -784,7 +784,8 @@ static int __rtw_download_firmware(struct rtw_dev *rtwdev,
 	if (!check_firmware_size(data, size))
 		return -EINVAL;
 
-	if (!ltecoex_read_reg(rtwdev, 0x38, &ltecoex_bckp))
+	if (rtwdev->chip->ltecoex_addr &&
+	    !ltecoex_read_reg(rtwdev, 0x38, &ltecoex_bckp))
 		return -EBUSY;
 
 	wlan_cpu_enable(rtwdev, false);
@@ -802,7 +803,8 @@ static int __rtw_download_firmware(struct rtw_dev *rtwdev,
 
 	wlan_cpu_enable(rtwdev, true);
 
-	if (!ltecoex_reg_write(rtwdev, 0x38, ltecoex_bckp)) {
+	if (rtwdev->chip->ltecoex_addr &&
+	    !ltecoex_reg_write(rtwdev, 0x38, ltecoex_bckp)) {
 		ret = -EBUSY;
 		goto dlfw_fail;
 	}
Signature · 1 line
2.48.1
#3 lore raw

PATCH 2/7 wifi: rtw88: Fix download_firmware_validate() for RTL8814AU

In reply to Bitterblue Smith

After the firmware is uploaded, download_firmware_validate() checks some bits in REG_MCUFW_CTRL to see if everything went okay. The RTL8814AU power on sequence sets bits 13 and 12 to 2, which this function does not expect, so it thinks the firmware upload failed.

Make download_firmware_validate() ignore bits 13 and 12.

---
 drivers/net/wireless/realtek/rtw88/reg.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/reg.h +2 -1
index e438405fba56..209b6fc08a73 100644
@@ -130,6 +130,7 @@
 #define BIT_SHIFT_ROM_PGE	16
 #define BIT_FW_INIT_RDY		BIT(15)
 #define BIT_FW_DW_RDY		BIT(14)
+#define BIT_CPU_CLK_SEL		(BIT(12) | BIT(13))
 #define BIT_RPWM_TOGGLE		BIT(7)
 #define BIT_RAM_DL_SEL		BIT(7)	/* legacy only */
 #define BIT_DMEM_CHKSUM_OK	BIT(6)
@@ -147,7 +148,7 @@
 				 BIT_CHECK_SUM_OK)
 #define FW_READY_LEGACY		(BIT_MCUFWDL_RDY | BIT_FWDL_CHK_RPT |	       \
 				 BIT_WINTINI_RDY | BIT_RAM_DL_SEL)
-#define FW_READY_MASK		0xffff
+#define FW_READY_MASK		(0xffff & ~BIT_CPU_CLK_SEL)
 
 #define REG_MCU_TST_CFG		0x84
 #define VAL_FW_TRIGGER		0x1
Signature · 1 line
2.48.1
#5 lore raw

PATCH 3/7 wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU

In reply to Bitterblue Smith

Currently this struct has the members required for chips with 2 RF paths. Add more members to support chips with 4 RF paths, like the RTL8814AU.

---
 drivers/net/wireless/realtek/rtw88/main.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/wireless/realtek/rtw88/main.h +12 -0
index 62cd4c526301..e40e62302984 100644
@@ -1130,14 +1130,26 @@ struct rtw_rfe_def {
  * For 2G there are cck rate and ofdm rate with different settings.
  */
 struct rtw_pwr_track_tbl {
+	const u8 *pwrtrk_5gd_n[RTW_PWR_TRK_5G_NUM];
+	const u8 *pwrtrk_5gd_p[RTW_PWR_TRK_5G_NUM];
+	const u8 *pwrtrk_5gc_n[RTW_PWR_TRK_5G_NUM];
+	const u8 *pwrtrk_5gc_p[RTW_PWR_TRK_5G_NUM];
 	const u8 *pwrtrk_5gb_n[RTW_PWR_TRK_5G_NUM];
 	const u8 *pwrtrk_5gb_p[RTW_PWR_TRK_5G_NUM];
 	const u8 *pwrtrk_5ga_n[RTW_PWR_TRK_5G_NUM];
 	const u8 *pwrtrk_5ga_p[RTW_PWR_TRK_5G_NUM];
+	const u8 *pwrtrk_2gd_n;
+	const u8 *pwrtrk_2gd_p;
+	const u8 *pwrtrk_2gc_n;
+	const u8 *pwrtrk_2gc_p;
 	const u8 *pwrtrk_2gb_n;
 	const u8 *pwrtrk_2gb_p;
 	const u8 *pwrtrk_2ga_n;
 	const u8 *pwrtrk_2ga_p;
+	const u8 *pwrtrk_2g_cckd_n;
+	const u8 *pwrtrk_2g_cckd_p;
+	const u8 *pwrtrk_2g_cckc_n;
+	const u8 *pwrtrk_2g_cckc_p;
 	const u8 *pwrtrk_2g_cckb_n;
 	const u8 *pwrtrk_2g_cckb_p;
 	const u8 *pwrtrk_2g_ccka_n;
Signature · 1 line
2.48.1
#7 lore raw

PATCH 4/7 wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU

In reply to Bitterblue Smith

These members of struct rtw_chip_info each have a size of 2. Increase their size to 4, which is the number of RF paths the RTL8814AU has.

This is required to read and write the RF registers of the RTL8814AU.

---
 drivers/net/wireless/realtek/rtw88/main.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +2 -2
index e40e62302984..ba64d269521a 100644
@@ -1239,8 +1239,8 @@ struct rtw_chip_info {
 
 	const struct rtw_hw_reg *dig;
 	const struct rtw_hw_reg *dig_cck;
-	u32 rf_base_addr[2];
-	u32 rf_sipi_addr[2];
+	u32 rf_base_addr[RTW_RF_PATH_MAX];
+	u32 rf_sipi_addr[RTW_RF_PATH_MAX];
 	const struct rtw_rf_sipi_addr *rf_sipi_read_addr;
 	u8 fix_rf_phy_num;
 	const struct rtw_ltecoex_addr *ltecoex_addr;
Signature · 1 line
2.48.1
#9 lore raw

PATCH 5/7 wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

In reply to Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +14 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
 	u8 h2c_pkt[H2C_PKT_SIZE] = {0};
 	bool disable_pt = true;
+	u32 mask_hi;
 
 	SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 	si->init_ra_lv = 0;
 
 	rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+	if (rtwdev->chip->rf_tbl[RF_PATH_C]) {
+		SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO_HI);
+
+		mask_hi = si->ra_mask >> 32;
+
+		SET_RA_INFO_RA_MASK0(h2c_pkt, (mask_hi & 0xff));
+		SET_RA_INFO_RA_MASK1(h2c_pkt, (mask_hi & 0xff00) >> 8);
+		SET_RA_INFO_RA_MASK2(h2c_pkt, (mask_hi & 0xff0000) >> 16);
+		SET_RA_INFO_RA_MASK3(h2c_pkt, (mask_hi & 0xff000000) >> 24);
+
+		rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+	}
 }
 
 void rtw_fw_media_status_report(struct rtw_dev *rtwdev, u8 mac_id, bool connect)
drivers/net/wireless/realtek/rtw88/fw.h +1 -0
index 404de1b0c407..48ad9ceab6ea 100644
@@ -557,6 +557,7 @@ static inline void rtw_h2c_pkt_set_header(u8 *h2c_pkt, u8 sub_id)
 #define H2C_CMD_DEFAULT_PORT		0x2c
 #define H2C_CMD_RA_INFO			0x40
 #define H2C_CMD_RSSI_MONITOR		0x42
+#define H2C_CMD_RA_INFO_HI		0x46
 #define H2C_CMD_BCN_FILTER_OFFLOAD_P0	0x56
 #define H2C_CMD_BCN_FILTER_OFFLOAD_P1	0x57
 #define H2C_CMD_WL_PHY_INFO		0x58
Signature · 1 line
2.48.1
#18 lore raw

PATCH 6/7 wifi: rtw88: Extend TX power stuff for 3-4 spatial streams

In reply to Bitterblue Smith

Although the RTL8814AU only has 3 spatial streams, maybe some other chip has 4.

Correct the TX power index and TX power limit calculations for 3SS and 4SS HT/VHT rates.

With this the RTL8814AU can set the TX power correctly.

---
I just realised this patch depends on another pending patch:
https://lore.kernel.org/linux-wireless/[email protected]/

Originally this patch was going to be in part 2, but then I rearranged them. Too late to turn back now...

---
 drivers/net/wireless/realtek/rtw88/main.h     |   4 +
 drivers/net/wireless/realtek/rtw88/phy.c      | 149 ++++++++++++------
 drivers/net/wireless/realtek/rtw88/phy.h      |   4 +
 drivers/net/wireless/realtek/rtw88/rtw8821c.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822b.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822c.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw88xxa.c |   2 +-
 7 files changed, 114 insertions(+), 51 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +4 -0
index ba64d269521a..bbae6d7c1aa9 100644
@@ -166,6 +166,10 @@ enum rtw_rate_section {
 	RTW_RATE_SECTION_HT_2S,
 	RTW_RATE_SECTION_VHT_1S,
 	RTW_RATE_SECTION_VHT_2S,
+	RTW_RATE_SECTION_HT_3S,
+	RTW_RATE_SECTION_HT_4S,
+	RTW_RATE_SECTION_VHT_3S,
+	RTW_RATE_SECTION_VHT_4S,
 
 	/* keep last */
 	RTW_RATE_SECTION_MAX,
drivers/net/wireless/realtek/rtw88/phy.c +102 -47

286 lines not on this page · raw message

drivers/net/wireless/realtek/rtw88/phy.h +4 -0
index ccfcbd3ced03..707576d04262 100644
@@ -13,6 +13,10 @@ extern u8 rtw_ht_1s_rates[];
 extern u8 rtw_ht_2s_rates[];
 extern u8 rtw_vht_1s_rates[];
 extern u8 rtw_vht_2s_rates[];
+extern u8 rtw_ht_3s_rates[];
+extern u8 rtw_ht_4s_rates[];
+extern u8 rtw_vht_3s_rates[];
+extern u8 rtw_vht_4s_rates[];
 extern u8 *rtw_rate_section[];
 extern u8 rtw_rate_size[];
 
drivers/net/wireless/realtek/rtw88/rtw8821c.c +1 -1
index cc152248407c..106a9e38e428 100644
@@ -709,7 +709,7 @@ static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
 	int rs, path;
 
 	for (path = 0; path < hal->rf_path_num; path++) {
-		for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) {
+		for (rs = 0; rs < RTW_RATE_SECTION_HT_3S; rs++) {
 			if (rs == RTW_RATE_SECTION_HT_2S ||
 			    rs == RTW_RATE_SECTION_VHT_2S)
 				continue;
drivers/net/wireless/realtek/rtw88/rtw8822b.c +1 -1
index 23a29019752d..5472fbf2b498 100644
@@ -964,7 +964,7 @@ static void rtw8822b_set_tx_power_index(struct rtw_dev *rtwdev)
 	int rs, path;
 
 	for (path = 0; path < hal->rf_path_num; path++) {
-		for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++)
+		for (rs = 0; rs < RTW_RATE_SECTION_HT_3S; rs++)
 			rtw8822b_set_tx_power_index_by_rate(rtwdev, path, rs,
 							    &phy_pwr_idx);
 	}
drivers/net/wireless/realtek/rtw88/rtw8822c.c +1 -1
index ec362a817f5f..aea9a20eab59 100644
@@ -2746,7 +2746,7 @@ static void rtw8822c_set_tx_power_index(struct rtw_dev *rtwdev)
 	s8 diff_idx[4];
 
 	rtw8822c_set_write_tx_power_ref(rtwdev, pwr_ref_cck, pwr_ref_ofdm);
-	for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) {
+	for (rs = 0; rs < RTW_RATE_SECTION_HT_3S; rs++) {
 		for (j = 0; j < rtw_rate_size[rs]; j++) {
 			rate = rtw_rate_section[rs][j];
 			pwr_a = hal->tx_pwr_tbl[RF_PATH_A][rate];
drivers/net/wireless/realtek/rtw88/rtw88xxa.c +1 -1
index 71e61b9c0bec..08bbd84733d1 100644
@@ -1637,7 +1637,7 @@ void rtw88xxa_set_tx_power_index(struct rtw_dev *rtwdev)
 	int rs, path;
 
 	for (path = 0; path < hal->rf_path_num; path++) {
-		for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) {
+		for (rs = 0; rs < RTW_RATE_SECTION_HT_3S; rs++) {
 			if (hal->rf_path_num == 1 &&
 			    (rs == RTW_RATE_SECTION_HT_2S ||
 			     rs == RTW_RATE_SECTION_VHT_2S))
Signature · 1 line
2.48.1
#20 lore raw

PATCH 7/7 wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU

In reply to Bitterblue Smith

This function tells the firmware what rates it can use.

Put the 3SS and 4SS HT rates supported by the other station into the rate mask.

Remove the 3SS and 4SS rates from the rate mask if the hardware only has 2 spatial streams.

And finally, select the right rate ID (a parameter for the firmware) when the hardware has 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtw88/main.c +9 -5
index 0cee0fd8c0ef..fab7e79fce47 100644
@@ -1234,7 +1234,9 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 		if (sta->deflink.vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC)
 			ldpc_en = VHT_LDPC_EN;
 	} else if (sta->deflink.ht_cap.ht_supported) {
-		ra_mask |= (sta->deflink.ht_cap.mcs.rx_mask[1] << 20) |
+		ra_mask |= ((u64)sta->deflink.ht_cap.mcs.rx_mask[3] << 36) |
+			   ((u64)sta->deflink.ht_cap.mcs.rx_mask[2] << 28) |
+			   (sta->deflink.ht_cap.mcs.rx_mask[1] << 20) |
 			   (sta->deflink.ht_cap.mcs.rx_mask[0] << 12);
 		if (sta->deflink.ht_cap.cap & IEEE80211_HT_CAP_RX_STBC)
 			stbc_en = HT_STBC_EN;
@@ -1244,6 +1246,9 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 
 	if (efuse->hw_cap.nss == 1 || rtwdev->hal.txrx_1ss)
 		ra_mask &= RA_MASK_VHT_RATES_1SS | RA_MASK_HT_RATES_1SS;
+	else if (efuse->hw_cap.nss == 2)
+		ra_mask &= RA_MASK_VHT_RATES_2SS | RA_MASK_HT_RATES_2SS |
+			   RA_MASK_VHT_RATES_1SS | RA_MASK_HT_RATES_1SS;
 
 	if (hal->current_band_type == RTW_BAND_5G) {
 		ra_mask |= (u64)sta->deflink.supp_rates[NL80211_BAND_5GHZ] << 4;
@@ -1302,10 +1307,9 @@ void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 		break;
 	}
 
-	if (sta->deflink.vht_cap.vht_supported && ra_mask & 0xffc00000)
-		tx_num = 2;
-	else if (sta->deflink.ht_cap.ht_supported && ra_mask & 0xfff00000)
-		tx_num = 2;
+	if (sta->deflink.vht_cap.vht_supported ||
+	    sta->deflink.ht_cap.ht_supported)
+		tx_num = efuse->hw_cap.nss;
 
 	rate_id = get_rate_id(wireless_set, bw_mode, tx_num);
 
Signature · 1 line
2.48.1
maintainer Acked-by on v1 2/7
#4 lore raw

Re: [PATCH 2/7] wifi: rtw88: Fix download_firmware_validate() for RTL8814AU

In reply to Bitterblue Smith
Quoted 9 lines · Bitterblue Smith

After the firmware is uploaded, download_firmware_validate() checks some bits in REG_MCUFW_CTRL to see if everything went okay. The RTL8814AU power on sequence sets bits 13 and 12 to 2, which this function does not expect, so it thinks the firmware upload failed.

Make download_firmware_validate() ignore bits 13 and 12.

Memo some traces from vendor driver:

For most chips, poll firmware ready by
while (HALMAC_REG_R16(REG_MCUFW_CTRL) != 0xC078)

Other chips check ready by
while ((HALMAC_REG_R16(REG_MCUFW_CTRL) & 0xC078) != 0xC078)

And, for all chips, BIT 12-13 are defined as CPU_CLK_SEL, so I think this change is well.

maintainer Acked-by on v1 4/7
#8 lore raw

Re: [PATCH 4/7] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU

In reply to Bitterblue Smith
Quoted 7 lines · Bitterblue Smith

These members of struct rtw_chip_info each have a size of 2. Increase their size to 4, which is the number of RF paths the RTL8814AU has.

This is required to read and write the RF registers of the RTL8814AU.

maintainer
#10 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

In reply to Bitterblue Smith
Quoted 23 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 5 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 772

Quoted 12 lines
drivers/net/wireless/realtek/rtw88/fw.c +11 -0
+               SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO_HI);
+
+               mask_hi = si->ra_mask >> 32;
+
+               SET_RA_INFO_RA_MASK0(h2c_pkt, (mask_hi & 0xff));
+               SET_RA_INFO_RA_MASK1(h2c_pkt, (mask_hi & 0xff00) >> 8);
+               SET_RA_INFO_RA_MASK2(h2c_pkt, (mask_hi & 0xff0000) >> 16);
+               SET_RA_INFO_RA_MASK3(h2c_pkt, (mask_hi & 0xff000000) >> 24);
+
+               rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+       }
 }

Prefer calling RA_INFO LO/HI in the same level. I meant

rtw_fw_send_ra_info()

{
        rtw_fw_send_ra_info_lo(); // original RA info
    
        if (efuse->hw_cap.nss <= 2)
                return;

        rtw_fw_send_ra_info_hi();
}
maintainer
#19 lore raw

Re: [PATCH 6/7] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams

In reply to Bitterblue Smith
Quoted 8 lines · Bitterblue Smith

Although the RTL8814AU only has 3 spatial streams, maybe some other chip has 4.

Correct the TX power index and TX power limit calculations for 3SS and 4SS HT/VHT rates.

With this the RTL8814AU can set the TX power correctly.

Quoted 7 lines

---
I just realised this patch depends on another pending patch:
https://lore.kernel.org/linux-wireless/[email protected]/

Originally this patch was going to be in part 2, but then I rearranged them. Too late to turn back now...

Next time, if you want rearrange two or more patchset, just ask me to drop all patches and re-send with increasing version number.

Quoted 15 lines
---
 drivers/net/wireless/realtek/rtw88/main.h     |   4 +
 drivers/net/wireless/realtek/rtw88/phy.c      | 149 ++++++++++++------
 drivers/net/wireless/realtek/rtw88/phy.h      |   4 +
 drivers/net/wireless/realtek/rtw88/rtw8821c.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822b.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw8822c.c |   2 +-
 drivers/net/wireless/realtek/rtw88/rtw88xxa.c |   2 +-
 7 files changed, 114 insertions(+), 51 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +0 -0
index ba64d269521a..bbae6d7c1aa9 100644

drivers/net/wireless/realtek/rtw88/main.h enum rtw_rate_section { · line 168

Quoted 3 lines
drivers/net/wireless/realtek/rtw88/main.h +0 -0
@@ -166,6 +166,10 @@ enum rtw_rate_section {
        RTW_RATE_SECTION_HT_2S,
        RTW_RATE_SECTION_VHT_1S,
        RTW_RATE_SECTION_VHT_2S,

Suggest to add a

          __RTW_RATE_SECTION_2SS_MAX = RTW_RATE_SECTION_VHT_2S,
          or
          __RTW_RATE_SECTION_2SS_NUM = RTW_RATE_SECTION_HT_3S,
          (Be careful the place, enumerator will increase automatically)

(The suffix of existing RTW_RATE_SECTION_MAX is wrong -- _NUM instead of _MAX)

Quoted 112 lines
drivers/net/wireless/realtek/rtw88/main.h +4 -0
+       RTW_RATE_SECTION_HT_3S,
+       RTW_RATE_SECTION_HT_4S,
+       RTW_RATE_SECTION_VHT_3S,
+       RTW_RATE_SECTION_VHT_4S,
 
        /* keep last */
        RTW_RATE_SECTION_MAX,
drivers/net/wireless/realtek/rtw88/phy.c +42 -9
index 8ed20c89d216..5ddc9d4988b8 100644
@@ -53,21 +53,25 @@ static const u32 db_invert_table[12][8] = {
 };
 
 u8 rtw_cck_rates[] = { DESC_RATE1M, DESC_RATE2M, DESC_RATE5_5M, DESC_RATE11M };
+
 u8 rtw_ofdm_rates[] = {
        DESC_RATE6M,  DESC_RATE9M,  DESC_RATE12M,
        DESC_RATE18M, DESC_RATE24M, DESC_RATE36M,
        DESC_RATE48M, DESC_RATE54M
 };
+
 u8 rtw_ht_1s_rates[] = {
        DESC_RATEMCS0, DESC_RATEMCS1, DESC_RATEMCS2,
        DESC_RATEMCS3, DESC_RATEMCS4, DESC_RATEMCS5,
        DESC_RATEMCS6, DESC_RATEMCS7
 };
+
 u8 rtw_ht_2s_rates[] = {
        DESC_RATEMCS8,  DESC_RATEMCS9,  DESC_RATEMCS10,
        DESC_RATEMCS11, DESC_RATEMCS12, DESC_RATEMCS13,
        DESC_RATEMCS14, DESC_RATEMCS15
 };
+
 u8 rtw_vht_1s_rates[] = {
        DESC_RATEVHT1SS_MCS0, DESC_RATEVHT1SS_MCS1,
        DESC_RATEVHT1SS_MCS2, DESC_RATEVHT1SS_MCS3,
@@ -75,6 +79,7 @@ u8 rtw_vht_1s_rates[] = {
        DESC_RATEVHT1SS_MCS6, DESC_RATEVHT1SS_MCS7,
        DESC_RATEVHT1SS_MCS8, DESC_RATEVHT1SS_MCS9
 };
+
 u8 rtw_vht_2s_rates[] = {
        DESC_RATEVHT2SS_MCS0, DESC_RATEVHT2SS_MCS1,
        DESC_RATEVHT2SS_MCS2, DESC_RATEVHT2SS_MCS3,
@@ -82,10 +87,41 @@ u8 rtw_vht_2s_rates[] = {
        DESC_RATEVHT2SS_MCS6, DESC_RATEVHT2SS_MCS7,
        DESC_RATEVHT2SS_MCS8, DESC_RATEVHT2SS_MCS9
 };
+
+u8 rtw_ht_3s_rates[] = {
+       DESC_RATEMCS16, DESC_RATEMCS17, DESC_RATEMCS18,
+       DESC_RATEMCS19, DESC_RATEMCS20, DESC_RATEMCS21,
+       DESC_RATEMCS22, DESC_RATEMCS23
+};
+
+u8 rtw_ht_4s_rates[] = {
+       DESC_RATEMCS24, DESC_RATEMCS25, DESC_RATEMCS26,
+       DESC_RATEMCS27, DESC_RATEMCS28, DESC_RATEMCS29,
+       DESC_RATEMCS30, DESC_RATEMCS31
+};
+
+u8 rtw_vht_3s_rates[] = {
+       DESC_RATEVHT3SS_MCS0, DESC_RATEVHT3SS_MCS1,
+       DESC_RATEVHT3SS_MCS2, DESC_RATEVHT3SS_MCS3,
+       DESC_RATEVHT3SS_MCS4, DESC_RATEVHT3SS_MCS5,
+       DESC_RATEVHT3SS_MCS6, DESC_RATEVHT3SS_MCS7,
+       DESC_RATEVHT3SS_MCS8, DESC_RATEVHT3SS_MCS9
+};
+
+u8 rtw_vht_4s_rates[] = {
+       DESC_RATEVHT4SS_MCS0, DESC_RATEVHT4SS_MCS1,
+       DESC_RATEVHT4SS_MCS2, DESC_RATEVHT4SS_MCS3,
+       DESC_RATEVHT4SS_MCS4, DESC_RATEVHT4SS_MCS5,
+       DESC_RATEVHT4SS_MCS6, DESC_RATEVHT4SS_MCS7,
+       DESC_RATEVHT4SS_MCS8, DESC_RATEVHT4SS_MCS9
+};
+
 u8 *rtw_rate_section[RTW_RATE_SECTION_MAX] = {
        rtw_cck_rates, rtw_ofdm_rates,
        rtw_ht_1s_rates, rtw_ht_2s_rates,
-       rtw_vht_1s_rates, rtw_vht_2s_rates
+       rtw_vht_1s_rates, rtw_vht_2s_rates,
+       rtw_ht_3s_rates, rtw_ht_4s_rates,
+       rtw_vht_3s_rates, rtw_vht_4s_rates
 };
 EXPORT_SYMBOL(rtw_rate_section);
 
@@ -95,17 +131,14 @@ u8 rtw_rate_size[RTW_RATE_SECTION_MAX] = {
        ARRAY_SIZE(rtw_ht_1s_rates),
        ARRAY_SIZE(rtw_ht_2s_rates),
        ARRAY_SIZE(rtw_vht_1s_rates),
-       ARRAY_SIZE(rtw_vht_2s_rates)
+       ARRAY_SIZE(rtw_vht_2s_rates),
+       ARRAY_SIZE(rtw_ht_3s_rates),
+       ARRAY_SIZE(rtw_ht_4s_rates),
+       ARRAY_SIZE(rtw_vht_3s_rates),
+       ARRAY_SIZE(rtw_vht_4s_rates)
 };
 EXPORT_SYMBOL(rtw_rate_size);
 
-static const u8 rtw_cck_size = ARRAY_SIZE(rtw_cck_rates);
-static const u8 rtw_ofdm_size = ARRAY_SIZE(rtw_ofdm_rates);
-static const u8 rtw_ht_1s_size = ARRAY_SIZE(rtw_ht_1s_rates);
-static const u8 rtw_ht_2s_size = ARRAY_SIZE(rtw_ht_2s_rates);
-static const u8 rtw_vht_1s_size = ARRAY_SIZE(rtw_vht_1s_rates);
-static const u8 rtw_vht_2s_size = ARRAY_SIZE(rtw_vht_2s_rates);
-
 enum rtw_phy_band_type {
        PHY_BAND_2G     = 0,
        PHY_BAND_5G     = 1,

drivers/net/wireless/realtek/rtw88/phy.c static void · line 1674

Quoted 9 lines
drivers/net/wireless/realtek/rtw88/phy.c +4 -2
@@ -1635,10 +1668,12 @@ static void
 rtw_xref_txpwr_lmt_by_rs(struct rtw_dev *rtwdev, u8 regd, u8 bw, u8 ch_idx)
 {
        u8 rs_idx, rs_ht, rs_vht;
-       u8 rs_cmp[2][2] = {{RTW_RATE_SECTION_HT_1S, RTW_RATE_SECTION_VHT_1S},
-                          {RTW_RATE_SECTION_HT_2S, RTW_RATE_SECTION_VHT_2S} };
+       u8 rs_cmp[4][2] = {{RTW_RATE_SECTION_HT_1S, RTW_RATE_SECTION_VHT_1S},
+                          {RTW_RATE_SECTION_HT_2S, RTW_RATE_SECTION_VHT_2S},
+                          {RTW_RATE_SECTION_HT_3S, RTW_RATE_SECTION_VHT_3S},
+                          {RTW_RATE_SECTION_HT_4S, RTW_RATE_SECTION_VHT_4S} };

Can be 'static const' by the way.

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/phy.c +1 -1
-       for (rs_idx = 0; rs_idx < 2; rs_idx++) {
+       for (rs_idx = 0; rs_idx < 4; rs_idx++) {
                rs_ht = rs_cmp[rs_idx][0];
                rs_vht = rs_cmp[rs_idx][1];
 

[...]

drivers/net/wireless/realtek/rtw88/rtw8821c.c static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev) · line 712

Quoted 10 lines
drivers/net/wireless/realtek/rtw88/rtw8821c.c +1 -1
index cc152248407c..106a9e38e428 100644
@@ -709,7 +709,7 @@ static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
        int rs, path;
 
        for (path = 0; path < hal->rf_path_num; path++) {
-               for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) {
+               for (rs = 0; rs < RTW_RATE_SECTION_HT_3S; rs++) {

As mentioned above,

        rs < __RTW_RATE_SECTION_2SS_NUM
        or
        rs <= __RTW_RATE_SECTION_2SS_MAX
Quoted 3 lines
drivers/net/wireless/realtek/rtw88/rtw8821c.c +0 -0
                        if (rs == RTW_RATE_SECTION_HT_2S ||
                            rs == RTW_RATE_SECTION_VHT_2S)
                                continue;
maintainer Acked-by on v1 7/7
#21 lore raw

Re: [PATCH 7/7] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU

In reply to Bitterblue Smith
Quoted 5 lines · Bitterblue Smith

This function tells the firmware what rates it can use.

Put the 3SS and 4SS HT rates supported by the other station into the rate mask.

Quoted 7 lines

Remove the 3SS and 4SS rates from the rate mask if the hardware only has 2 spatial streams.

And finally, select the right rate ID (a parameter for the firmware) when the hardware has 3 spatial streams.

#11 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

In reply to Ping-Ke Shih
Quoted 23 lines · Ping-Ke Shih
Quoted 22 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
Quoted 9 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

I would like that, but nss is 2 when RTL8814AU is in USB 2 mode. I assume this is to keep the current draw under the 500 mA limit of USB 2.

What about rtwdev->hal.rf_path_num >= 3 ? I don't remember why I didn't do that.

Quoted 25 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 772

Quoted 12 lines
drivers/net/wireless/realtek/rtw88/fw.c +11 -0
+               SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO_HI);
+
+               mask_hi = si->ra_mask >> 32;
+
+               SET_RA_INFO_RA_MASK0(h2c_pkt, (mask_hi & 0xff));
+               SET_RA_INFO_RA_MASK1(h2c_pkt, (mask_hi & 0xff00) >> 8);
+               SET_RA_INFO_RA_MASK2(h2c_pkt, (mask_hi & 0xff0000) >> 16);
+               SET_RA_INFO_RA_MASK3(h2c_pkt, (mask_hi & 0xff000000) >> 24);
+
+               rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+       }
 }

Prefer calling RA_INFO LO/HI in the same level. I meant

rtw_fw_send_ra_info()

{
        rtw_fw_send_ra_info_lo(); // original RA info
    
        if (efuse->hw_cap.nss <= 2)
                return;

        rtw_fw_send_ra_info_hi();
}
maintainer
#12 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

Quoted 34 lines · Bitterblue Smith
Quoted 23 lines · Ping-Ke Shih
Quoted 22 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
Quoted 9 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

Quoted 6 lines

I would like that, but nss is 2 when RTL8814AU is in USB 2 mode. I assume this is to keep the current draw under the 500 mA limit of USB 2.

What about rtwdev->hal.rf_path_num >= 3 ? I don't remember why I didn't do that.

I think rtwdev->hal.rf_path_num >= 3 is suitable to initialize/configure hardware registers, because no matter USB 2 or 3 mode should be the same.

For this case (RA info), this is related to protocol, so I feel efuse->hw_cap.nss >= 3 is suitable, but I have not seen a patch to declare supported NSS in register_hw(), or I missed it? Or, without RA_INFO_HI, it gets abnormal rate to RTL8814AU in your test?

#13 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

Quoted 42 lines · Ping-Ke Shih
Quoted 34 lines · Bitterblue Smith
Quoted 23 lines · Ping-Ke Shih
Quoted 22 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
Quoted 9 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

Quoted 6 lines

I would like that, but nss is 2 when RTL8814AU is in USB 2 mode. I assume this is to keep the current draw under the 500 mA limit of USB 2.

What about rtwdev->hal.rf_path_num >= 3 ? I don't remember why I didn't do that.

Quoted 8 lines

I think rtwdev->hal.rf_path_num >= 3 is suitable to initialize/configure hardware registers, because no matter USB 2 or 3 mode should be the same.

For this case (RA info), this is related to protocol, so I feel efuse->hw_cap.nss >= 3 is suitable, but I have not seen a patch to declare supported NSS in register_hw(), or I missed it? Or, without RA_INFO_HI, it gets abnormal rate to RTL8814AU in your test?

You didn't miss it, that will be in part 3. You can see the code here:

https://github.com/lwfinger/rtw88/blob/21a3fa7ec11a0cbb3be14145f45cdca35c3d3217/rtw8814a.c#L82

I get a steady 300 Mbps even without RA_INFO_HI. The problem is only cosmetic. Right after connecting to the AP the first C2H_RA_RPT comes a bit later than usual, after the first CTRL-EVENT-SIGNAL-CHANGE, so we see a TX rate of 0:

Jan 28 19:00:06 ideapad2 NetworkManager[504]: <info>  [1738083606.4996] manager: NetworkManager state is now CONNECTED_SITE
Jan 28 19:00:06 ideapad2 NetworkManager[504]: <info>  [1738083606.5003] device (wlp3s0f3u2): Activation: successful, device activated.
Jan 28 19:00:06 ideapad2 wpa_supplicant[1480]: wlp3s0f3u2: CTRL-EVENT-SIGNAL-CHANGE above=1 signal=-42 noise=9999 txrate=0
Jan 28 19:00:06 ideapad2 NetworkManager[504]: <info>  [1738083606.6020] manager: NetworkManager state is now CONNECTED_GLOBAL

With RA_INFO_HI the first C2H_RA_RPT comes at the normal time, before the first CTRL-EVENT-SIGNAL-CHANGE:

Jan 28 19:09:44 ideapad2 NetworkManager[504]: <info>  [1738084184.2400] manager: NetworkManager state is now CONNECTED_SITE
Jan 28 19:09:44 ideapad2 NetworkManager[504]: <info>  [1738084184.2407] device (wlp3s0f3u2): Activation: successful, device activated.
Jan 28 19:09:44 ideapad2 wpa_supplicant[1480]: wlp3s0f3u2: CTRL-EVENT-SIGNAL-CHANGE above=1 signal=-44 noise=9999 txrate=780000
Jan 28 19:09:44 ideapad2 NetworkManager[504]: <info>  [1738084184.3810] manager: NetworkManager state is now CONNECTED_GLOBAL
maintainer
#14 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

Quoted 52 lines · Bitterblue Smith
Quoted 42 lines · Ping-Ke Shih
Quoted 34 lines · Bitterblue Smith
Quoted 23 lines · Ping-Ke Shih
Quoted 22 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
Quoted 9 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

Quoted 6 lines

I would like that, but nss is 2 when RTL8814AU is in USB 2 mode. I assume this is to keep the current draw under the 500 mA limit of USB 2.

What about rtwdev->hal.rf_path_num >= 3 ? I don't remember why I didn't do that.

Quoted 8 lines

I think rtwdev->hal.rf_path_num >= 3 is suitable to initialize/configure hardware registers, because no matter USB 2 or 3 mode should be the same.

For this case (RA info), this is related to protocol, so I feel efuse->hw_cap.nss >= 3 is suitable, but I have not seen a patch to declare supported NSS in register_hw(), or I missed it? Or, without RA_INFO_HI, it gets abnormal rate to RTL8814AU in your test?

Quoted 4 lines

You didn't miss it, that will be in part 3. You can see the code here:

https://github.com/lwfinger/rtw88/blob/21a3fa7ec11a0cbb3be14145f45cdca35c3d3217/rtw8814a.c#L82

I feel we should clearly define the meaning. What I thought for 8814AU are:
- hal->rf_type: hardware capability. Should be RF_3T3R no matter USB 2 or 3.
- hal->antenna_tx: the antenna for current TX. Can be 2 antenna.
- hal->antenna_rx: the antenna for current RX. Can be 2 antenna.
- efuse->hw_cap.nss: read from efuse. So this will be 3SS for USB 2/3.
If you have better defnitiion, please share your ideas.

Also, I would want to point the mcs_map implemented in rtw_init_vht_cap().

	if (efuse->hw_cap.nss > 1) {
		highest = cpu_to_le16(780);
		mcs_map |= IEEE80211_VHT_MCS_SUPPORT_0_9 << 2;
	}

This can only support up to 2SS, and I'm not sure if 'efuse->hw_cap.nss' is still sutiable for 8814AU.

Quoted 3 lines

With RA_INFO_HI the first C2H_RA_RPT comes at the normal time, before the first CTRL-EVENT-SIGNAL-CHANGE:

So, how about sending RA_INFO_HI unconditionally for 8814AU (just check chip ID as condition)?

#15 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

Quoted 58 lines · Ping-Ke Shih
Quoted 52 lines · Bitterblue Smith
Quoted 42 lines · Ping-Ke Shih
Quoted 34 lines · Bitterblue Smith
Quoted 23 lines · Ping-Ke Shih
Quoted 22 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
Quoted 9 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

Quoted 6 lines

I would like that, but nss is 2 when RTL8814AU is in USB 2 mode. I assume this is to keep the current draw under the 500 mA limit of USB 2.

What about rtwdev->hal.rf_path_num >= 3 ? I don't remember why I didn't do that.

Quoted 8 lines

I think rtwdev->hal.rf_path_num >= 3 is suitable to initialize/configure hardware registers, because no matter USB 2 or 3 mode should be the same.

For this case (RA info), this is related to protocol, so I feel efuse->hw_cap.nss >= 3 is suitable, but I have not seen a patch to declare supported NSS in register_hw(), or I missed it? Or, without RA_INFO_HI, it gets abnormal rate to RTL8814AU in your test?

Quoted 4 lines

You didn't miss it, that will be in part 3. You can see the code here:

https://github.com/lwfinger/rtw88/blob/21a3fa7ec11a0cbb3be14145f45cdca35c3d3217/rtw8814a.c#L82

Quoted 7 lines

I feel we should clearly define the meaning. What I thought for 8814AU are:
- hal->rf_type: hardware capability. Should be RF_3T3R no matter USB 2 or 3.
- hal->antenna_tx: the antenna for current TX. Can be 2 antenna.
- hal->antenna_rx: the antenna for current RX. Can be 2 antenna.
- efuse->hw_cap.nss: read from efuse. So this will be 3SS for USB 2/3.
If you have better defnitiion, please share your ideas.

If efuse->hw_cap.nss is always 3, how to limit the spatial streams to 2 in USB 2 mode?

Quoted 10 lines

Also, I would want to point the mcs_map implemented in rtw_init_vht_cap().

	if (efuse->hw_cap.nss > 1) {
		highest = cpu_to_le16(780);
		mcs_map |= IEEE80211_VHT_MCS_SUPPORT_0_9 << 2;
	}

This can only support up to 2SS, and I'm not sure if 'efuse->hw_cap.nss' is still sutiable for 8814AU.

rtw_init_vht_cap() will be fixed in the next patch set:

https://github.com/lwfinger/rtw88/blob/21a3fa7ec11a0cbb3be14145f45cdca35c3d3217/main.c#L1718

Quoted 7 lines
Quoted 3 lines

With RA_INFO_HI the first C2H_RA_RPT comes at the normal time, before the first CTRL-EVENT-SIGNAL-CHANGE:

So, how about sending RA_INFO_HI unconditionally for 8814AU (just check chip ID as condition)?

I guess that's fine.

maintainer
#16 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

Quoted 67 lines · Bitterblue Smith
Quoted 58 lines · Ping-Ke Shih
Quoted 52 lines · Bitterblue Smith
Quoted 42 lines · Ping-Ke Shih
Quoted 34 lines · Bitterblue Smith
Quoted 23 lines · Ping-Ke Shih
Quoted 22 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
Quoted 9 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

Quoted 6 lines

I would like that, but nss is 2 when RTL8814AU is in USB 2 mode. I assume this is to keep the current draw under the 500 mA limit of USB 2.

What about rtwdev->hal.rf_path_num >= 3 ? I don't remember why I didn't do that.

Quoted 8 lines

I think rtwdev->hal.rf_path_num >= 3 is suitable to initialize/configure hardware registers, because no matter USB 2 or 3 mode should be the same.

For this case (RA info), this is related to protocol, so I feel efuse->hw_cap.nss >= 3 is suitable, but I have not seen a patch to declare supported NSS in register_hw(), or I missed it? Or, without RA_INFO_HI, it gets abnormal rate to RTL8814AU in your test?

Quoted 4 lines

You didn't miss it, that will be in part 3. You can see the code here:

https://github.com/lwfinger/rtw88/blob/21a3fa7ec11a0cbb3be14145f45cdca35c3d3217/rtw8814a.c#L82

Quoted 7 lines

I feel we should clearly define the meaning. What I thought for 8814AU are:
- hal->rf_type: hardware capability. Should be RF_3T3R no matter USB 2 or 3.
- hal->antenna_tx: the antenna for current TX. Can be 2 antenna.
- hal->antenna_rx: the antenna for current RX. Can be 2 antenna.
- efuse->hw_cap.nss: read from efuse. So this will be 3SS for USB 2/3.
If you have better defnitiion, please share your ideas.

Quoted 2 lines

If efuse->hw_cap.nss is always 3, how to limit the spatial streams to 2 in USB 2 mode?

That's a proposal only, because I felt efuse->hw_cap.nss read from efuse should be persistent, but it is fine to define desired meaning.

I would like to confirm if USB devices will not switch USB 2/3 mode after USB probe? If so, efuse->hw_cap.nss is also a kind of persistent. Then, using efuse->hw_cap.nss seems fine.

#17 lore raw

Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU

Quoted 71 lines · Ping-Ke Shih
Quoted 67 lines · Bitterblue Smith
Quoted 58 lines · Ping-Ke Shih
Quoted 52 lines · Bitterblue Smith
Quoted 42 lines · Ping-Ke Shih
Quoted 34 lines · Bitterblue Smith
Quoted 23 lines · Ping-Ke Shih
Quoted 22 lines · Bitterblue Smith

The existing code is suitable for chips with up to 2 spatial streams. Inform the firmware about the rates it's allowed to use when transmitting 3 spatial streams.

---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)
drivers/net/wireless/realtek/rtw88/fw.c +1 -0
index 02389b7c6876..0ca1b139110d 100644
@@ -735,6 +735,7 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
 {
        u8 h2c_pkt[H2C_PKT_SIZE] = {0};
        bool disable_pt = true;
+       u32 mask_hi;
 
        SET_H2C_CMD_ID_CLASS(h2c_pkt, H2C_CMD_RA_INFO);
 
Quoted 9 lines

drivers/net/wireless/realtek/rtw88/fw.c void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si, · line 760

Quoted 6 lines
drivers/net/wireless/realtek/rtw88/fw.c +2 -0
@@ -755,6 +756,19 @@ void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si,
        si->init_ra_lv = 0;
 
        rtw_fw_send_h2c_command(rtwdev, h2c_pkt);
+
+       if (rtwdev->chip->rf_tbl[RF_PATH_C]) {

Using efuse->hw_cap.nss >= 3 would be consistent with latter patch.

Quoted 6 lines

I would like that, but nss is 2 when RTL8814AU is in USB 2 mode. I assume this is to keep the current draw under the 500 mA limit of USB 2.

What about rtwdev->hal.rf_path_num >= 3 ? I don't remember why I didn't do that.

Quoted 8 lines

I think rtwdev->hal.rf_path_num >= 3 is suitable to initialize/configure hardware registers, because no matter USB 2 or 3 mode should be the same.

For this case (RA info), this is related to protocol, so I feel efuse->hw_cap.nss >= 3 is suitable, but I have not seen a patch to declare supported NSS in register_hw(), or I missed it? Or, without RA_INFO_HI, it gets abnormal rate to RTL8814AU in your test?

Quoted 4 lines

You didn't miss it, that will be in part 3. You can see the code here:

https://github.com/lwfinger/rtw88/blob/21a3fa7ec11a0cbb3be14145f45cdca35c3d3217/rtw8814a.c#L82

Quoted 7 lines

I feel we should clearly define the meaning. What I thought for 8814AU are:
- hal->rf_type: hardware capability. Should be RF_3T3R no matter USB 2 or 3.
- hal->antenna_tx: the antenna for current TX. Can be 2 antenna.
- hal->antenna_rx: the antenna for current RX. Can be 2 antenna.
- efuse->hw_cap.nss: read from efuse. So this will be 3SS for USB 2/3.
If you have better defnitiion, please share your ideas.

Quoted 2 lines

If efuse->hw_cap.nss is always 3, how to limit the spatial streams to 2 in USB 2 mode?

Quoted 7 lines

That's a proposal only, because I felt efuse->hw_cap.nss read from efuse should be persistent, but it is fine to define desired meaning.

I would like to confirm if USB devices will not switch USB 2/3 mode after USB probe? If so, efuse->hw_cap.nss is also a kind of persistent. Then, using efuse->hw_cap.nss seems fine.

Oh, yes, the switching is done only in the USB probe function.