linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2)
@ 2025-01-26 22:53 Bitterblue Smith
  2025-01-26 22:53 ` [PATCH 1/7] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU Bitterblue Smith
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 22:53 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH 1/7] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
  2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
@ 2025-01-26 22:53 ` Bitterblue Smith
  2025-01-27  6:06   ` Ping-Ke Shih
  2025-01-26 22:54 ` [PATCH 2/7] wifi: rtw88: Fix download_firmware_validate() " Bitterblue Smith
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 22:53 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/mac.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/mac.c b/drivers/net/wireless/realtek/rtw88/mac.c
index cae9cca6dca3..63edf6461de8 100644
--- a/drivers/net/wireless/realtek/rtw88/mac.c
+++ b/drivers/net/wireless/realtek/rtw88/mac.c
@@ -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;
 	}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/7] wifi: rtw88: Fix download_firmware_validate() for RTL8814AU
  2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
  2025-01-26 22:53 ` [PATCH 1/7] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU Bitterblue Smith
@ 2025-01-26 22:54 ` Bitterblue Smith
  2025-01-27  6:21   ` Ping-Ke Shih
  2025-01-26 22:55 ` [PATCH 3/7] wifi: rtw88: Extend struct rtw_pwr_track_tbl " Bitterblue Smith
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 22:54 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/reg.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw88/reg.h b/drivers/net/wireless/realtek/rtw88/reg.h
index e438405fba56..209b6fc08a73 100644
--- a/drivers/net/wireless/realtek/rtw88/reg.h
+++ b/drivers/net/wireless/realtek/rtw88/reg.h
@@ -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
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/7] wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU
  2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
  2025-01-26 22:53 ` [PATCH 1/7] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU Bitterblue Smith
  2025-01-26 22:54 ` [PATCH 2/7] wifi: rtw88: Fix download_firmware_validate() " Bitterblue Smith
@ 2025-01-26 22:55 ` Bitterblue Smith
  2025-01-27  6:23   ` Ping-Ke Shih
  2025-01-26 22:55 ` [PATCH 4/7] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr " Bitterblue Smith
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 22:55 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/main.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 62cd4c526301..e40e62302984 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -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;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 4/7] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU
  2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
                   ` (2 preceding siblings ...)
  2025-01-26 22:55 ` [PATCH 3/7] wifi: rtw88: Extend struct rtw_pwr_track_tbl " Bitterblue Smith
@ 2025-01-26 22:55 ` Bitterblue Smith
  2025-01-27  6:26   ` Ping-Ke Shih
  2025-01-26 22:56 ` [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() " Bitterblue Smith
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 22:55 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/main.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index e40e62302984..ba64d269521a 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -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;
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
                   ` (3 preceding siblings ...)
  2025-01-26 22:55 ` [PATCH 4/7] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr " Bitterblue Smith
@ 2025-01-26 22:56 ` Bitterblue Smith
  2025-01-27  6:36   ` Ping-Ke Shih
  2025-01-26 23:01 ` [PATCH 6/7] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams Bitterblue Smith
  2025-01-26 23:02 ` [PATCH 7/7] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU Bitterblue Smith
  6 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 22:56 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
 drivers/net/wireless/realtek/rtw88/fw.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
index 02389b7c6876..0ca1b139110d 100644
--- a/drivers/net/wireless/realtek/rtw88/fw.c
+++ b/drivers/net/wireless/realtek/rtw88/fw.c
@@ -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)
diff --git a/drivers/net/wireless/realtek/rtw88/fw.h b/drivers/net/wireless/realtek/rtw88/fw.h
index 404de1b0c407..48ad9ceab6ea 100644
--- a/drivers/net/wireless/realtek/rtw88/fw.h
+++ b/drivers/net/wireless/realtek/rtw88/fw.h
@@ -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
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 6/7] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams
  2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
                   ` (4 preceding siblings ...)
  2025-01-26 22:56 ` [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() " Bitterblue Smith
@ 2025-01-26 23:01 ` Bitterblue Smith
  2025-01-27  7:06   ` Ping-Ke Shih
  2025-01-26 23:02 ` [PATCH 7/7] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU Bitterblue Smith
  6 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 23:01 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
I just realised this patch depends on another pending patch:
https://lore.kernel.org/linux-wireless/8a60f581-0ab5-4d98-a97d-dd83b605008f@gmail.com/

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(-)

diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index ba64d269521a..bbae6d7c1aa9 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -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,
diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c
index 8ed20c89d216..5ddc9d4988b8 100644
--- a/drivers/net/wireless/realtek/rtw88/phy.c
+++ b/drivers/net/wireless/realtek/rtw88/phy.c
@@ -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,
@@ -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} };
 
-	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];
 
@@ -1959,10 +1994,10 @@ static u8 rtw_phy_get_2g_tx_power_index(struct rtw_dev *rtwdev,
 					u8 rate, u8 group)
 {
 	const struct rtw_chip_info *chip = rtwdev->chip;
-	u8 tx_power;
-	bool mcs_rate;
-	bool above_2ss;
+	bool above_2ss, above_3ss, above_4ss;
 	u8 factor = chip->txgi_factor;
+	bool mcs_rate;
+	u8 tx_power;
 
 	if (rate <= DESC_RATE11M)
 		tx_power = pwr_idx_2g->cck_base[group];
@@ -1972,11 +2007,15 @@ static u8 rtw_phy_get_2g_tx_power_index(struct rtw_dev *rtwdev,
 	if (rate >= DESC_RATE6M && rate <= DESC_RATE54M)
 		tx_power += pwr_idx_2g->ht_1s_diff.ofdm * factor;
 
-	mcs_rate = (rate >= DESC_RATEMCS0 && rate <= DESC_RATEMCS15) ||
+	mcs_rate = (rate >= DESC_RATEMCS0 && rate <= DESC_RATEMCS31) ||
 		   (rate >= DESC_RATEVHT1SS_MCS0 &&
-		    rate <= DESC_RATEVHT2SS_MCS9);
-	above_2ss = (rate >= DESC_RATEMCS8 && rate <= DESC_RATEMCS15) ||
+		    rate <= DESC_RATEVHT4SS_MCS9);
+	above_2ss = (rate >= DESC_RATEMCS8 && rate <= DESC_RATEMCS31) ||
 		    (rate >= DESC_RATEVHT2SS_MCS0);
+	above_3ss = (rate >= DESC_RATEMCS16 && rate <= DESC_RATEMCS31) ||
+		    (rate >= DESC_RATEVHT3SS_MCS0);
+	above_4ss = (rate >= DESC_RATEMCS24 && rate <= DESC_RATEMCS31) ||
+		    (rate >= DESC_RATEVHT4SS_MCS0);
 
 	if (!mcs_rate)
 		return tx_power;
@@ -1989,11 +2028,19 @@ static u8 rtw_phy_get_2g_tx_power_index(struct rtw_dev *rtwdev,
 		tx_power += pwr_idx_2g->ht_1s_diff.bw20 * factor;
 		if (above_2ss)
 			tx_power += pwr_idx_2g->ht_2s_diff.bw20 * factor;
+		if (above_3ss)
+			tx_power += pwr_idx_2g->ht_3s_diff.bw20 * factor;
+		if (above_4ss)
+			tx_power += pwr_idx_2g->ht_4s_diff.bw20 * factor;
 		break;
 	case RTW_CHANNEL_WIDTH_40:
 		/* bw40 is the base power */
 		if (above_2ss)
 			tx_power += pwr_idx_2g->ht_2s_diff.bw40 * factor;
+		if (above_3ss)
+			tx_power += pwr_idx_2g->ht_3s_diff.bw40 * factor;
+		if (above_4ss)
+			tx_power += pwr_idx_2g->ht_4s_diff.bw40 * factor;
 		break;
 	}
 
@@ -2006,19 +2053,23 @@ static u8 rtw_phy_get_5g_tx_power_index(struct rtw_dev *rtwdev,
 					u8 rate, u8 group)
 {
 	const struct rtw_chip_info *chip = rtwdev->chip;
-	u8 tx_power;
+	bool above_2ss, above_3ss, above_4ss;
+	u8 factor = chip->txgi_factor;
 	u8 upper, lower;
 	bool mcs_rate;
-	bool above_2ss;
-	u8 factor = chip->txgi_factor;
+	u8 tx_power;
 
 	tx_power = pwr_idx_5g->bw40_base[group];
 
-	mcs_rate = (rate >= DESC_RATEMCS0 && rate <= DESC_RATEMCS15) ||
+	mcs_rate = (rate >= DESC_RATEMCS0 && rate <= DESC_RATEMCS31) ||
 		   (rate >= DESC_RATEVHT1SS_MCS0 &&
-		    rate <= DESC_RATEVHT2SS_MCS9);
-	above_2ss = (rate >= DESC_RATEMCS8 && rate <= DESC_RATEMCS15) ||
+		    rate <= DESC_RATEVHT4SS_MCS9);
+	above_2ss = (rate >= DESC_RATEMCS8 && rate <= DESC_RATEMCS31) ||
 		    (rate >= DESC_RATEVHT2SS_MCS0);
+	above_3ss = (rate >= DESC_RATEMCS16 && rate <= DESC_RATEMCS31) ||
+		    (rate >= DESC_RATEVHT3SS_MCS0);
+	above_4ss = (rate >= DESC_RATEMCS24 && rate <= DESC_RATEMCS31) ||
+		    (rate >= DESC_RATEVHT4SS_MCS0);
 
 	if (!mcs_rate) {
 		tx_power += pwr_idx_5g->ht_1s_diff.ofdm * factor;
@@ -2033,11 +2084,19 @@ static u8 rtw_phy_get_5g_tx_power_index(struct rtw_dev *rtwdev,
 		tx_power += pwr_idx_5g->ht_1s_diff.bw20 * factor;
 		if (above_2ss)
 			tx_power += pwr_idx_5g->ht_2s_diff.bw20 * factor;
+		if (above_3ss)
+			tx_power += pwr_idx_5g->ht_3s_diff.bw20 * factor;
+		if (above_4ss)
+			tx_power += pwr_idx_5g->ht_4s_diff.bw20 * factor;
 		break;
 	case RTW_CHANNEL_WIDTH_40:
 		/* bw40 is the base power */
 		if (above_2ss)
 			tx_power += pwr_idx_5g->ht_2s_diff.bw40 * factor;
+		if (above_3ss)
+			tx_power += pwr_idx_5g->ht_3s_diff.bw40 * factor;
+		if (above_4ss)
+			tx_power += pwr_idx_5g->ht_4s_diff.bw40 * factor;
 		break;
 	case RTW_CHANNEL_WIDTH_80:
 		/* the base idx of bw80 is the average of bw40+/bw40- */
@@ -2048,6 +2107,10 @@ static u8 rtw_phy_get_5g_tx_power_index(struct rtw_dev *rtwdev,
 		tx_power += pwr_idx_5g->vht_1s_diff.bw80 * factor;
 		if (above_2ss)
 			tx_power += pwr_idx_5g->vht_2s_diff.bw80 * factor;
+		if (above_3ss)
+			tx_power += pwr_idx_5g->vht_3s_diff.bw80 * factor;
+		if (above_4ss)
+			tx_power += pwr_idx_5g->vht_4s_diff.bw80 * factor;
 		break;
 	}
 
@@ -2065,10 +2128,18 @@ static u8 rtw_phy_rate_to_rate_section(u8 rate)
 		return RTW_RATE_SECTION_HT_1S;
 	else if (rate >= DESC_RATEMCS8 && rate <= DESC_RATEMCS15)
 		return RTW_RATE_SECTION_HT_2S;
+	else if (rate >= DESC_RATEMCS16 && rate <= DESC_RATEMCS23)
+		return RTW_RATE_SECTION_HT_3S;
+	else if (rate >= DESC_RATEMCS24 && rate <= DESC_RATEMCS31)
+		return RTW_RATE_SECTION_HT_4S;
 	else if (rate >= DESC_RATEVHT1SS_MCS0 && rate <= DESC_RATEVHT1SS_MCS9)
 		return RTW_RATE_SECTION_VHT_1S;
 	else if (rate >= DESC_RATEVHT2SS_MCS0 && rate <= DESC_RATEVHT2SS_MCS9)
 		return RTW_RATE_SECTION_VHT_2S;
+	else if (rate >= DESC_RATEVHT3SS_MCS0 && rate <= DESC_RATEVHT3SS_MCS9)
+		return RTW_RATE_SECTION_VHT_3S;
+	else if (rate >= DESC_RATEVHT4SS_MCS0 && rate <= DESC_RATEVHT4SS_MCS9)
+		return RTW_RATE_SECTION_VHT_4S;
 	else
 		return RTW_RATE_SECTION_MAX;
 }
@@ -2096,7 +2167,7 @@ static s8 rtw_phy_get_tx_power_limit(struct rtw_dev *rtwdev, u8 band,
 		bw = RTW_CHANNEL_WIDTH_20;
 
 	/* only 20/40M BW with ht */
-	if (rs == RTW_RATE_SECTION_HT_1S || rs == RTW_RATE_SECTION_HT_2S)
+	if (rate >= DESC_RATEMCS0 && rate <= DESC_RATEMCS31)
 		bw = min_t(u8, bw, RTW_CHANNEL_WIDTH_40);
 
 	/* select min power limit among [20M BW ~ current BW] */
@@ -2280,7 +2351,7 @@ rtw_phy_tx_power_by_rate_config_by_path(struct rtw_hal *hal, u8 path,
 	u8 base_idx, rate_idx;
 	s8 base_2g, base_5g;
 
-	if (rs >= RTW_RATE_SECTION_VHT_1S)
+	if (size == 10) /* VHT rates */
 		base_idx = rates[size - 3];
 	else
 		base_idx = rates[size - 1];
@@ -2297,28 +2368,12 @@ rtw_phy_tx_power_by_rate_config_by_path(struct rtw_hal *hal, u8 path,
 
 void rtw_phy_tx_power_by_rate_config(struct rtw_hal *hal)
 {
-	u8 path;
+	u8 path, rs;
 
-	for (path = 0; path < RTW_RF_PATH_MAX; path++) {
-		rtw_phy_tx_power_by_rate_config_by_path(hal, path,
-				RTW_RATE_SECTION_CCK,
-				rtw_cck_size, rtw_cck_rates);
-		rtw_phy_tx_power_by_rate_config_by_path(hal, path,
-				RTW_RATE_SECTION_OFDM,
-				rtw_ofdm_size, rtw_ofdm_rates);
-		rtw_phy_tx_power_by_rate_config_by_path(hal, path,
-				RTW_RATE_SECTION_HT_1S,
-				rtw_ht_1s_size, rtw_ht_1s_rates);
-		rtw_phy_tx_power_by_rate_config_by_path(hal, path,
-				RTW_RATE_SECTION_HT_2S,
-				rtw_ht_2s_size, rtw_ht_2s_rates);
-		rtw_phy_tx_power_by_rate_config_by_path(hal, path,
-				RTW_RATE_SECTION_VHT_1S,
-				rtw_vht_1s_size, rtw_vht_1s_rates);
-		rtw_phy_tx_power_by_rate_config_by_path(hal, path,
-				RTW_RATE_SECTION_VHT_2S,
-				rtw_vht_2s_size, rtw_vht_2s_rates);
-	}
+	for (path = 0; path < RTW_RF_PATH_MAX; path++)
+		for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++)
+			rtw_phy_tx_power_by_rate_config_by_path(hal, path, rs,
+				rtw_rate_size[rs], rtw_rate_section[rs]);
 }
 
 static void
diff --git a/drivers/net/wireless/realtek/rtw88/phy.h b/drivers/net/wireless/realtek/rtw88/phy.h
index ccfcbd3ced03..707576d04262 100644
--- a/drivers/net/wireless/realtek/rtw88/phy.h
+++ b/drivers/net/wireless/realtek/rtw88/phy.h
@@ -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[];
 
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
index cc152248407c..106a9e38e428 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
@@ -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;
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.c b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
index 23a29019752d..5472fbf2b498 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822b.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.c
@@ -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);
 	}
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.c b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
index ec362a817f5f..aea9a20eab59 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.c
@@ -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];
diff --git a/drivers/net/wireless/realtek/rtw88/rtw88xxa.c b/drivers/net/wireless/realtek/rtw88/rtw88xxa.c
index 71e61b9c0bec..08bbd84733d1 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw88xxa.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw88xxa.c
@@ -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))
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 7/7] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU
  2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
                   ` (5 preceding siblings ...)
  2025-01-26 23:01 ` [PATCH 6/7] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams Bitterblue Smith
@ 2025-01-26 23:02 ` Bitterblue Smith
  2025-01-27  7:14   ` Ping-Ke Shih
  6 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-26 23:02 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

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.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 0cee0fd8c0ef..fab7e79fce47 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -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);
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/7] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU
  2025-01-26 22:53 ` [PATCH 1/7] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU Bitterblue Smith
@ 2025-01-27  6:06   ` Ping-Ke Shih
  0 siblings, 0 replies; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-27  6:06 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> 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.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> 

Acked-by: Ping-Ke Shih <pkshih@realtek.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/7] wifi: rtw88: Fix download_firmware_validate() for RTL8814AU
  2025-01-26 22:54 ` [PATCH 2/7] wifi: rtw88: Fix download_firmware_validate() " Bitterblue Smith
@ 2025-01-27  6:21   ` Ping-Ke Shih
  0 siblings, 0 replies; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-27  6:21 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> 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.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> 

Acked-by: Ping-Ke Shih <pkshih@realtek.com>

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. 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/7] wifi: rtw88: Extend struct rtw_pwr_track_tbl for RTL8814AU
  2025-01-26 22:55 ` [PATCH 3/7] wifi: rtw88: Extend struct rtw_pwr_track_tbl " Bitterblue Smith
@ 2025-01-27  6:23   ` Ping-Ke Shih
  0 siblings, 0 replies; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-27  6:23 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> 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.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> 

Acked-by: Ping-Ke Shih <pkshih@realtek.com>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 4/7] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr for RTL8814AU
  2025-01-26 22:55 ` [PATCH 4/7] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr " Bitterblue Smith
@ 2025-01-27  6:26   ` Ping-Ke Shih
  0 siblings, 0 replies; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-27  6:26 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> 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.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> 

Acked-by: Ping-Ke Shih <pkshih@realtek.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-26 22:56 ` [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() " Bitterblue Smith
@ 2025-01-27  6:36   ` Ping-Ke Shih
  2025-01-27 23:18     ` Bitterblue Smith
  0 siblings, 1 reply; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-27  6:36 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> 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.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> ---
>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
>  2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
> index 02389b7c6876..0ca1b139110d 100644
> --- a/drivers/net/wireless/realtek/rtw88/fw.c
> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
> @@ -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]) {

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

> +               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();
}


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 6/7] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams
  2025-01-26 23:01 ` [PATCH 6/7] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams Bitterblue Smith
@ 2025-01-27  7:06   ` Ping-Ke Shih
  0 siblings, 0 replies; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-27  7:06 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:

> 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.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> ---
> I just realised this patch depends on another pending patch:
> https://lore.kernel.org/linux-wireless/8a60f581-0ab5-4d98-a97d-dd83b605008f@gmail.com/
> 
> 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. 

> ---
>  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(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
> index ba64d269521a..bbae6d7c1aa9 100644
> --- a/drivers/net/wireless/realtek/rtw88/main.h
> +++ b/drivers/net/wireless/realtek/rtw88/main.h
> @@ -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)

> +       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,
> diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c
> index 8ed20c89d216..5ddc9d4988b8 100644
> --- a/drivers/net/wireless/realtek/rtw88/phy.c
> +++ b/drivers/net/wireless/realtek/rtw88/phy.c
> @@ -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,
> @@ -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. 

> 
> -       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];
> 

[...]

> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
> index cc152248407c..106a9e38e428 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
> @@ -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

>                         if (rs == RTW_RATE_SECTION_HT_2S ||
>                             rs == RTW_RATE_SECTION_VHT_2S)
>                                 continue;

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 7/7] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU
  2025-01-26 23:02 ` [PATCH 7/7] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU Bitterblue Smith
@ 2025-01-27  7:14   ` Ping-Ke Shih
  0 siblings, 0 replies; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-27  7:14 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:

> 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.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>

Acked-by: Ping-Ke Shih <pkshih@realtek.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-27  6:36   ` Ping-Ke Shih
@ 2025-01-27 23:18     ` Bitterblue Smith
  2025-01-28  5:52       ` Ping-Ke Shih
  0 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-27 23:18 UTC (permalink / raw)
  To: Ping-Ke Shih, linux-wireless@vger.kernel.org

On 27/01/2025 08:36, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>> 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.
>>
>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>> ---
>>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
>>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
>>  2 files changed, 15 insertions(+)
>>
>> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
>> index 02389b7c6876..0ca1b139110d 100644
>> --- a/drivers/net/wireless/realtek/rtw88/fw.c
>> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
>> @@ -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]) {
> 
> 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.

>> +               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();
> }
> 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-27 23:18     ` Bitterblue Smith
@ 2025-01-28  5:52       ` Ping-Ke Shih
  2025-01-28 17:17         ` Bitterblue Smith
  0 siblings, 1 reply; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-28  5:52 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> On 27/01/2025 08:36, Ping-Ke Shih wrote:
> > Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> >> 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.
> >>
> >> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> >> ---
> >>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
> >>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
> >>  2 files changed, 15 insertions(+)
> >>
> >> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
> >> index 02389b7c6876..0ca1b139110d 100644
> >> --- a/drivers/net/wireless/realtek/rtw88/fw.c
> >> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
> >> @@ -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]) {
> >
> > 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.

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?


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-28  5:52       ` Ping-Ke Shih
@ 2025-01-28 17:17         ` Bitterblue Smith
  2025-01-29  2:43           ` Ping-Ke Shih
  0 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-28 17:17 UTC (permalink / raw)
  To: Ping-Ke Shih, linux-wireless@vger.kernel.org

On 28/01/2025 07:52, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>> On 27/01/2025 08:36, Ping-Ke Shih wrote:
>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>>>> ---
>>>>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
>>>>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
>>>>  2 files changed, 15 insertions(+)
>>>>
>>>> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
>>>> index 02389b7c6876..0ca1b139110d 100644
>>>> --- a/drivers/net/wireless/realtek/rtw88/fw.c
>>>> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
>>>> @@ -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]) {
>>>
>>> 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.
> 
> 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


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-28 17:17         ` Bitterblue Smith
@ 2025-01-29  2:43           ` Ping-Ke Shih
  2025-01-29 23:14             ` Bitterblue Smith
  0 siblings, 1 reply; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-29  2:43 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> On 28/01/2025 07:52, Ping-Ke Shih wrote:
> > Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> >> On 27/01/2025 08:36, Ping-Ke Shih wrote:
> >>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> >>>> 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.
> >>>>
> >>>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> >>>> ---
> >>>>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
> >>>>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
> >>>>  2 files changed, 15 insertions(+)
> >>>>
> >>>> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
> >>>> index 02389b7c6876..0ca1b139110d 100644
> >>>> --- a/drivers/net/wireless/realtek/rtw88/fw.c
> >>>> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
> >>>> @@ -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]) {
> >>>
> >>> 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.
> >
> > 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 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.

> 
> 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)?


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-29  2:43           ` Ping-Ke Shih
@ 2025-01-29 23:14             ` Bitterblue Smith
  2025-01-30  9:12               ` Ping-Ke Shih
  0 siblings, 1 reply; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-29 23:14 UTC (permalink / raw)
  To: Ping-Ke Shih, linux-wireless@vger.kernel.org

On 29/01/2025 04:43, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>> On 28/01/2025 07:52, Ping-Ke Shih wrote:
>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>> On 27/01/2025 08:36, Ping-Ke Shih wrote:
>>>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>>>> 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.
>>>>>>
>>>>>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>>>>>> ---
>>>>>>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
>>>>>>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
>>>>>>  2 files changed, 15 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>> index 02389b7c6876..0ca1b139110d 100644
>>>>>> --- a/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>> @@ -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]) {
>>>>>
>>>>> 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.
>>>
>>> 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 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?

> 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

>>
>> 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.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-29 23:14             ` Bitterblue Smith
@ 2025-01-30  9:12               ` Ping-Ke Shih
  2025-01-30 21:16                 ` Bitterblue Smith
  0 siblings, 1 reply; 22+ messages in thread
From: Ping-Ke Shih @ 2025-01-30  9:12 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>On 29/01/2025 04:43, Ping-Ke Shih wrote:
>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>> On 28/01/2025 07:52, Ping-Ke Shih wrote:
>>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>>> On 27/01/2025 08:36, Ping-Ke Shih wrote:
>>>>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>>>>> 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.
>>>>>>>
>>>>>>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>>>>>>> ---
>>>>>>>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
>>>>>>>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
>>>>>>>  2 files changed, 15 insertions(+)
>>>>>>>
>>>>>>> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>>> index 02389b7c6876..0ca1b139110d 100644
>>>>>>> --- a/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>>> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>>> @@ -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]) {
>>>>>>
>>>>>> 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.
>>>>
>>>> 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 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?

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. 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() for RTL8814AU
  2025-01-30  9:12               ` Ping-Ke Shih
@ 2025-01-30 21:16                 ` Bitterblue Smith
  0 siblings, 0 replies; 22+ messages in thread
From: Bitterblue Smith @ 2025-01-30 21:16 UTC (permalink / raw)
  To: Ping-Ke Shih, linux-wireless@vger.kernel.org

On 30/01/2025 11:12, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>> On 29/01/2025 04:43, Ping-Ke Shih wrote:
>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>> On 28/01/2025 07:52, Ping-Ke Shih wrote:
>>>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>>>> On 27/01/2025 08:36, Ping-Ke Shih wrote:
>>>>>>> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>>>>>> 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.
>>>>>>>>
>>>>>>>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>>>>>>>> ---
>>>>>>>>  drivers/net/wireless/realtek/rtw88/fw.c | 14 ++++++++++++++
>>>>>>>>  drivers/net/wireless/realtek/rtw88/fw.h |  1 +
>>>>>>>>  2 files changed, 15 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/drivers/net/wireless/realtek/rtw88/fw.c b/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>>>> index 02389b7c6876..0ca1b139110d 100644
>>>>>>>> --- a/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>>>> +++ b/drivers/net/wireless/realtek/rtw88/fw.c
>>>>>>>> @@ -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]) {
>>>>>>>
>>>>>>> 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.
>>>>>
>>>>> 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 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?
> 
> 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.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-01-30 21:16 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-26 22:53 [PATCH 0/7] wifi: rtw88: Prepare to support RTL8814AU (part 1/2) Bitterblue Smith
2025-01-26 22:53 ` [PATCH 1/7] wifi: rtw88: Fix __rtw_download_firmware() for RTL8814AU Bitterblue Smith
2025-01-27  6:06   ` Ping-Ke Shih
2025-01-26 22:54 ` [PATCH 2/7] wifi: rtw88: Fix download_firmware_validate() " Bitterblue Smith
2025-01-27  6:21   ` Ping-Ke Shih
2025-01-26 22:55 ` [PATCH 3/7] wifi: rtw88: Extend struct rtw_pwr_track_tbl " Bitterblue Smith
2025-01-27  6:23   ` Ping-Ke Shih
2025-01-26 22:55 ` [PATCH 4/7] wifi: rtw88: Extend rf_base_addr and rf_sipi_addr " Bitterblue Smith
2025-01-27  6:26   ` Ping-Ke Shih
2025-01-26 22:56 ` [PATCH 5/7] wifi: rtw88: Extend rtw_fw_send_ra_info() " Bitterblue Smith
2025-01-27  6:36   ` Ping-Ke Shih
2025-01-27 23:18     ` Bitterblue Smith
2025-01-28  5:52       ` Ping-Ke Shih
2025-01-28 17:17         ` Bitterblue Smith
2025-01-29  2:43           ` Ping-Ke Shih
2025-01-29 23:14             ` Bitterblue Smith
2025-01-30  9:12               ` Ping-Ke Shih
2025-01-30 21:16                 ` Bitterblue Smith
2025-01-26 23:01 ` [PATCH 6/7] wifi: rtw88: Extend TX power stuff for 3-4 spatial streams Bitterblue Smith
2025-01-27  7:06   ` Ping-Ke Shih
2025-01-26 23:02 ` [PATCH 7/7] wifi: rtw88: Fix rtw_update_sta_info() for RTL8814AU Bitterblue Smith
2025-01-27  7:14   ` Ping-Ke Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).