diff mbox series

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

Message ID fa9ff2b4-6e1a-45e4-90de-db6fe0d4f433@gmail.com
State New
Headers show
Series wifi: rtw88: Prepare to support RTL8814AU (part 1/2) | expand

Commit Message

Bitterblue Smith Jan. 26, 2025, 10:56 p.m. UTC
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(+)

Comments

Ping-Ke Shih Jan. 27, 2025, 6:36 a.m. UTC | #1
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();
}
Bitterblue Smith Jan. 27, 2025, 11:18 p.m. UTC | #2
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();
> }
>
Bitterblue Smith Jan. 28, 2025, 5:17 p.m. UTC | #3
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
diff mbox series

Patch

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