All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU
@ 2024-11-07 23:41 Bitterblue Smith
  2024-11-07 23:43 ` [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au Bitterblue Smith
  2024-11-08  2:36 ` [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Ping-Ke Shih
  0 siblings, 2 replies; 7+ messages in thread
From: Bitterblue Smith @ 2024-11-07 23:41 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

Add the function to automatically switch the RTL8812AU into USB 3 mode.

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

diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
index 6fa3c37205f5..752bca05b9af 100644
--- a/drivers/net/wireless/realtek/rtw88/usb.c
+++ b/drivers/net/wireless/realtek/rtw88/usb.c
@@ -931,6 +931,32 @@ static void rtw_usb_intf_deinit(struct rtw_dev *rtwdev,
 	usb_set_intfdata(intf, NULL);
 }
 
+static int rtw_usb_switch_mode_old(struct rtw_dev *rtwdev)
+{
+	struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
+	enum usb_device_speed cur_speed = rtwusb->udev->speed;
+	u8 hci_opt;
+
+	if (cur_speed == USB_SPEED_HIGH) {
+		hci_opt = rtw_read8(rtwdev, REG_HCI_OPT_CTRL);
+
+		if ((hci_opt & (BIT(2) | BIT(3))) != BIT(3)) {
+			rtw_write8(rtwdev, REG_HCI_OPT_CTRL, 0x8);
+			rtw_write8(rtwdev, REG_SYS_SDIO_CTRL, 0x2);
+			rtw_write8(rtwdev, REG_ACLK_MON, 0x1);
+			rtw_write8(rtwdev, 0x3d, 0x3);
+			/* usb disconnect */
+			rtw_write8(rtwdev, REG_SYS_PW_CTRL + 1, 0x80);
+			return 1;
+		}
+	} else if (cur_speed == USB_SPEED_SUPER) {
+		rtw_write8_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT(1));
+		rtw_write8_clr(rtwdev, REG_ACLK_MON, BIT(0));
+	}
+
+	return 0;
+}
+
 static int rtw_usb_switch_mode_new(struct rtw_dev *rtwdev)
 {
 	enum usb_device_speed cur_speed;
@@ -984,7 +1010,8 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
 {
 	u8 id = rtwdev->chip->id;
 
-	if (id != RTW_CHIP_TYPE_8822C && id != RTW_CHIP_TYPE_8822B)
+	if (id != RTW_CHIP_TYPE_8822C && id != RTW_CHIP_TYPE_8822B &&
+	    id != RTW_CHIP_TYPE_8812A)
 		return 0;
 
 	if (!rtwdev->efuse.usb_mode_switch) {
@@ -999,7 +1026,10 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
 		return 0;
 	}
 
-	return rtw_usb_switch_mode_new(rtwdev);
+	if (id == RTW_CHIP_TYPE_8812A)
+		return rtw_usb_switch_mode_old(rtwdev);
+	else /* RTL8822CU, RTL8822BU */
+		return rtw_usb_switch_mode_new(rtwdev);
 }
 
 int rtw_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)

base-commit: 1f3de77752a7bf0d1beb44603f048eb46948b9fe
prerequisite-patch-id: 8b66ae2bfbf46f30a9c17b37423ea9f42f3e56c7
prerequisite-patch-id: a700764f0bfe91e9a17bfe194ffef9b59d8cc994
prerequisite-patch-id: aa91f11d43dbf3e0081fb33022fdf623b2e1fe41
prerequisite-patch-id: fff3a9dafec3b293c8c1c3059ab8c85ed8d51af2
prerequisite-patch-id: 05bc1efb4d16788c5dc7a82a5fc02ebc2c40b9bb
prerequisite-patch-id: 33acc0f39fc264666ddc16e371f4190a117b9b0a
prerequisite-patch-id: 586a4c77227a0942032a70d7752328906f5c2353
prerequisite-patch-id: 9005f7599ce3819f952955e356f2971f942491cf
prerequisite-patch-id: 6565f68bb43594f2e3bbd310ae6d1e10aff52ba2
prerequisite-patch-id: 247a49275f81bc0ea4704813c845d0f4b212b4fa
prerequisite-patch-id: cadb4f3eead80e0b8dc21c4976df6e3d4eed4411
prerequisite-patch-id: bcc4b916fa66e3a1f8830ed91ae66d0edc792c27
prerequisite-patch-id: 61bd0f9fa3727495e0b575699c572e9028add725
prerequisite-patch-id: 67db016e612870e24bb50686c7b8382df78a3b3b
prerequisite-patch-id: 241b9366e96914fdc3736ca3a694a2b7b645c25e
prerequisite-patch-id: d2a9596fdb06a0be72a8810108854ea059b20ac8
prerequisite-patch-id: aa2559586159d347d03e247c6ab1752c7766b198
prerequisite-patch-id: 7981f49a43504646fd84b1b3adf995a736bc33eb
prerequisite-patch-id: 0ce4cf3b765d24fd438e6ba64b89e1b72048b65d
prerequisite-patch-id: c6ac89babaf69252ddbf1717138067c8ab3b0e77
prerequisite-patch-id: 74d3154402984209896914648e007cffe37bdd3c
prerequisite-patch-id: c36cea8efa84a07a046ea2932e1cc5d0eebc467c
prerequisite-patch-id: 479974f2c2409052c0c8448cd27a3fc73b8e73d0
prerequisite-patch-id: b60b6c409a2e5927ac7a49098b001071ce43f3fa
prerequisite-patch-id: 9e4bfe239b896239676462a48d32dacb209a56a6
prerequisite-patch-id: f1b3646b39c10f1f161375b8b776f6b66b8f33fb
prerequisite-patch-id: 736ad8d856f1cc2a83255a011d2db3460f1e85b1
prerequisite-patch-id: 48d62dd217e39eb066b3a06b194b4e381793127b
prerequisite-patch-id: 238957a0ff4ef34bbedf672ff67da8d662b01a67
prerequisite-patch-id: a5449cf3f19fa1b121198019fdb22fa0b6c48a49
prerequisite-patch-id: f346f8594746643ef30be1d361dcdacfb5be4e3c
prerequisite-patch-id: fb031f6f42836fbe1d60763a58b35097a2e9457c
prerequisite-patch-id: e29ec9929e742da830e4ee1fa808829774d8ee6a
prerequisite-patch-id: 0829766dcbc11378cad6c756a6cafd93070b992d
prerequisite-patch-id: 5dd8ec4c6093fd9a1e1737f9ba869ef3d188d5a2
prerequisite-patch-id: a680a3f9bf6c1588e3a62a17522be06a3cdeb079
prerequisite-patch-id: 07c39d390fb61e4eb8e80ee5f3836767a3f6680b
prerequisite-patch-id: 672a373a86d7a211e85859237d243347a2d13ce0
prerequisite-patch-id: d2e00f128353188d030f39b3658451c57bd9c913
prerequisite-patch-id: 7df183849b8a6d64f52d078856eb831e9634b566
prerequisite-patch-id: cd152cbdc8c9de5873e98789abc4caea7dc1c870
prerequisite-patch-id: 4818acfce4e354055ff924b0b89001d0e217cdc1
prerequisite-patch-id: bc0a866ecbe4ed2a47160ed7f4ccc873363f563e
prerequisite-patch-id: e8143557e487ccfe2e47984b2180fcc073809918
prerequisite-patch-id: d63803c13783916dfb1b749eeb1489375a7eb430
prerequisite-patch-id: 99377bd088a6e29960512c992d8230696d738590
prerequisite-patch-id: ed2518483f01f0318d05340c810dd00fa9ef11a6
prerequisite-patch-id: a8cf4b56e129d2f3c45f81c14cfa2303c4390b5d
prerequisite-patch-id: fe466966970d814fa39e382576d81581a12bccaf
prerequisite-patch-id: d93663ab1bf75a8195e277ee3a9ab94a8d7b2549
prerequisite-patch-id: 525e477a3d2b1ea716c1f4f11541b682d63b3cb2
prerequisite-patch-id: 1de02a8e6dcb59729482d47530ac88395cd170e1
prerequisite-patch-id: 0b210cacbae1c807bc8c451810694cbf04022b25
prerequisite-patch-id: c931ac7fbeed6e2726e13c9a6e2d9b3464b95c12
prerequisite-patch-id: 0aca217593ea6baafd4b06b6c0f9afbf072c6b3e
prerequisite-patch-id: 1459cd218e055ad892ace18ed623eba0f5edbd77
prerequisite-patch-id: c7fe9e344191cd37d3f9bc91e005efef0bec334f
prerequisite-patch-id: d663885e71ace7de915daee73c450a85ef4daa8f
prerequisite-patch-id: 3cf29e3f9c292f4eca2e6393d98670c216a22f41
prerequisite-patch-id: 182184449702b94beeade2526e691ea4c4eef7ed
-- 
2.47.0


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

* [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au
  2024-11-07 23:41 [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Bitterblue Smith
@ 2024-11-07 23:43 ` Bitterblue Smith
  2024-11-08  2:40   ` Ping-Ke Shih
  2024-11-08  2:36 ` [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Ping-Ke Shih
  1 sibling, 1 reply; 7+ messages in thread
From: Bitterblue Smith @ 2024-11-07 23:43 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org; +Cc: Ping-Ke Shih

USB RX aggregation improves the RX speed on certain ARM systems, like
the NanoPi NEO Core2. With RTL8811AU, before: 30 Mbps, after: 224 Mbps.

The out-of-tree driver uses aggregation size of 7 in USB 3 mode, but
that doesn't work here. rtw88 advertises support for receiving AMSDU
in AMPDU, so the AP sends larger frames, up to ~5100 bytes. With a size
of 7 RTL8812AU frequently tries to aggregate more frames than will fit
in 32768 bytes. Use a size of 6 instead.

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

diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
index 752bca05b9af..9172af63500b 100644
--- a/drivers/net/wireless/realtek/rtw88/usb.c
+++ b/drivers/net/wireless/realtek/rtw88/usb.c
@@ -790,6 +790,32 @@ static void rtw_usb_dynamic_rx_agg_v1(struct rtw_dev *rtwdev, bool enable)
 	rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
 }
 
+static void rtw_usb_dynamic_rx_agg_v2(struct rtw_dev *rtwdev, bool enable)
+{
+	struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
+	u8 size, timeout;
+	u16 val16;
+
+	if (rtwusb->udev->speed == USB_SPEED_SUPER) {
+		size = 0x6;
+		timeout = 0x1a;
+	} else {
+		size = 0x5;
+		timeout = 0x20;
+	}
+
+	if (!enable) {
+		size = 0x0;
+		timeout = 0x1;
+	}
+
+	val16 = u16_encode_bits(size, BIT_RXDMA_AGG_PG_TH) |
+		u16_encode_bits(timeout, BIT_DMA_AGG_TO_V1);
+
+	rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
+	rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN);
+}
+
 static void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable)
 {
 	switch (rtwdev->chip->id) {
@@ -798,6 +824,10 @@ static void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable)
 	case RTW_CHIP_TYPE_8821C:
 		rtw_usb_dynamic_rx_agg_v1(rtwdev, enable);
 		break;
+	case RTW_CHIP_TYPE_8821A:
+	case RTW_CHIP_TYPE_8812A:
+		rtw_usb_dynamic_rx_agg_v2(rtwdev, enable);
+		break;
 	case RTW_CHIP_TYPE_8723D:
 		/* Doesn't like aggregation. */
 		break;
-- 
2.47.0


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

* RE: [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU
  2024-11-07 23:41 [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Bitterblue Smith
  2024-11-07 23:43 ` [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au Bitterblue Smith
@ 2024-11-08  2:36 ` Ping-Ke Shih
  2024-11-13 23:48   ` Bitterblue Smith
  1 sibling, 1 reply; 7+ messages in thread
From: Ping-Ke Shih @ 2024-11-08  2:36 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> Add the function to automatically switch the RTL8812AU into USB 3 mode.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> ---
>  drivers/net/wireless/realtek/rtw88/usb.c | 34 ++++++++++++++++++++++--
>  1 file changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
> index 6fa3c37205f5..752bca05b9af 100644
> --- a/drivers/net/wireless/realtek/rtw88/usb.c
> +++ b/drivers/net/wireless/realtek/rtw88/usb.c
> @@ -931,6 +931,32 @@ static void rtw_usb_intf_deinit(struct rtw_dev *rtwdev,
>         usb_set_intfdata(intf, NULL);
>  }
> 
> +static int rtw_usb_switch_mode_old(struct rtw_dev *rtwdev)
> +{
> +       struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
> +       enum usb_device_speed cur_speed = rtwusb->udev->speed;
> +       u8 hci_opt;
> +
> +       if (cur_speed == USB_SPEED_HIGH) {
> +               hci_opt = rtw_read8(rtwdev, REG_HCI_OPT_CTRL);
> +
> +               if ((hci_opt & (BIT(2) | BIT(3))) != BIT(3)) {
> +                       rtw_write8(rtwdev, REG_HCI_OPT_CTRL, 0x8);
> +                       rtw_write8(rtwdev, REG_SYS_SDIO_CTRL, 0x2);
> +                       rtw_write8(rtwdev, REG_ACLK_MON, 0x1);
> +                       rtw_write8(rtwdev, 0x3d, 0x3);
> +                       /* usb disconnect */
> +                       rtw_write8(rtwdev, REG_SYS_PW_CTRL + 1, 0x80);
> +                       return 1;
> +               }
> +       } else if (cur_speed == USB_SPEED_SUPER) {
> +               rtw_write8_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT(1));
> +               rtw_write8_clr(rtwdev, REG_ACLK_MON, BIT(0));
> +       }
> +
> +       return 0;
> +}
> +
>  static int rtw_usb_switch_mode_new(struct rtw_dev *rtwdev)
>  {
>         enum usb_device_speed cur_speed;
> @@ -984,7 +1010,8 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
>  {
>         u8 id = rtwdev->chip->id;
> 
> -       if (id != RTW_CHIP_TYPE_8822C && id != RTW_CHIP_TYPE_8822B)
> +       if (id != RTW_CHIP_TYPE_8822C && id != RTW_CHIP_TYPE_8822B &&
> +           id != RTW_CHIP_TYPE_8812A)

Would it be clear to list positive chips in a function? and return new/old type
chip is using for latter condition. 

>                 return 0;
> 
>         if (!rtwdev->efuse.usb_mode_switch) {
> @@ -999,7 +1026,10 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
>                 return 0;
>         }
> 
> -       return rtw_usb_switch_mode_new(rtwdev);
> +       if (id == RTW_CHIP_TYPE_8812A)
> +               return rtw_usb_switch_mode_old(rtwdev);
> +       else /* RTL8822CU, RTL8822BU */
> +               return rtw_usb_switch_mode_new(rtwdev);
>  }




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

* RE: [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au
  2024-11-07 23:43 ` [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au Bitterblue Smith
@ 2024-11-08  2:40   ` Ping-Ke Shih
  2024-11-13 23:50     ` Bitterblue Smith
  0 siblings, 1 reply; 7+ messages in thread
From: Ping-Ke Shih @ 2024-11-08  2:40 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>> 
> USB RX aggregation improves the RX speed on certain ARM systems, like
> the NanoPi NEO Core2. With RTL8811AU, before: 30 Mbps, after: 224 Mbps.
> 
> The out-of-tree driver uses aggregation size of 7 in USB 3 mode, but
> that doesn't work here. rtw88 advertises support for receiving AMSDU
> in AMPDU, so the AP sends larger frames, up to ~5100 bytes. With a size
> of 7 RTL8812AU frequently tries to aggregate more frames than will fit
> in 32768 bytes. Use a size of 6 instead.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> ---
>  drivers/net/wireless/realtek/rtw88/usb.c | 30 ++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
> index 752bca05b9af..9172af63500b 100644
> --- a/drivers/net/wireless/realtek/rtw88/usb.c
> +++ b/drivers/net/wireless/realtek/rtw88/usb.c
> @@ -790,6 +790,32 @@ static void rtw_usb_dynamic_rx_agg_v1(struct rtw_dev *rtwdev, bool enable)
>         rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
>  }
> 
> +static void rtw_usb_dynamic_rx_agg_v2(struct rtw_dev *rtwdev, bool enable)
> +{
> +       struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
> +       u8 size, timeout;
> +       u16 val16;
> +

How about a shortcut?

if (!enable) {
	size = 0x0;
	timeout = 0x1;

	goto rx_agg;
}

> +       if (rtwusb->udev->speed == USB_SPEED_SUPER) {
> +               size = 0x6;
> +               timeout = 0x1a;
> +       } else {
> +               size = 0x5;
> +               timeout = 0x20;
> +       }
> +
> +       if (!enable) {
> +               size = 0x0;
> +               timeout = 0x1;
> +       }
> +

rx_agg:

> +       val16 = u16_encode_bits(size, BIT_RXDMA_AGG_PG_TH) |
> +               u16_encode_bits(timeout, BIT_DMA_AGG_TO_V1);
> +
> +       rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
> +       rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN);
> +}
> +
>  static void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable)
>  {
>         switch (rtwdev->chip->id) {
> @@ -798,6 +824,10 @@ static void rtw_usb_dynamic_rx_agg(struct rtw_dev *rtwdev, bool enable)
>         case RTW_CHIP_TYPE_8821C:
>                 rtw_usb_dynamic_rx_agg_v1(rtwdev, enable);
>                 break;
> +       case RTW_CHIP_TYPE_8821A:
> +       case RTW_CHIP_TYPE_8812A:
> +               rtw_usb_dynamic_rx_agg_v2(rtwdev, enable);
> +               break;
>         case RTW_CHIP_TYPE_8723D:
>                 /* Doesn't like aggregation. */
>                 break;
> --
> 2.47.0


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

* Re: [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU
  2024-11-08  2:36 ` [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Ping-Ke Shih
@ 2024-11-13 23:48   ` Bitterblue Smith
  0 siblings, 0 replies; 7+ messages in thread
From: Bitterblue Smith @ 2024-11-13 23:48 UTC (permalink / raw)
  To: Ping-Ke Shih, linux-wireless@vger.kernel.org

On 08/11/2024 04:36, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>> Add the function to automatically switch the RTL8812AU into USB 3 mode.
>>
>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>> ---
>>  drivers/net/wireless/realtek/rtw88/usb.c | 34 ++++++++++++++++++++++--
>>  1 file changed, 32 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
>> index 6fa3c37205f5..752bca05b9af 100644
>> --- a/drivers/net/wireless/realtek/rtw88/usb.c
>> +++ b/drivers/net/wireless/realtek/rtw88/usb.c
>> @@ -931,6 +931,32 @@ static void rtw_usb_intf_deinit(struct rtw_dev *rtwdev,
>>         usb_set_intfdata(intf, NULL);
>>  }
>>
>> +static int rtw_usb_switch_mode_old(struct rtw_dev *rtwdev)
>> +{
>> +       struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
>> +       enum usb_device_speed cur_speed = rtwusb->udev->speed;
>> +       u8 hci_opt;
>> +
>> +       if (cur_speed == USB_SPEED_HIGH) {
>> +               hci_opt = rtw_read8(rtwdev, REG_HCI_OPT_CTRL);
>> +
>> +               if ((hci_opt & (BIT(2) | BIT(3))) != BIT(3)) {
>> +                       rtw_write8(rtwdev, REG_HCI_OPT_CTRL, 0x8);
>> +                       rtw_write8(rtwdev, REG_SYS_SDIO_CTRL, 0x2);
>> +                       rtw_write8(rtwdev, REG_ACLK_MON, 0x1);
>> +                       rtw_write8(rtwdev, 0x3d, 0x3);
>> +                       /* usb disconnect */
>> +                       rtw_write8(rtwdev, REG_SYS_PW_CTRL + 1, 0x80);
>> +                       return 1;
>> +               }
>> +       } else if (cur_speed == USB_SPEED_SUPER) {
>> +               rtw_write8_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT(1));
>> +               rtw_write8_clr(rtwdev, REG_ACLK_MON, BIT(0));
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>>  static int rtw_usb_switch_mode_new(struct rtw_dev *rtwdev)
>>  {
>>         enum usb_device_speed cur_speed;
>> @@ -984,7 +1010,8 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
>>  {
>>         u8 id = rtwdev->chip->id;
>>
>> -       if (id != RTW_CHIP_TYPE_8822C && id != RTW_CHIP_TYPE_8822B)
>> +       if (id != RTW_CHIP_TYPE_8822C && id != RTW_CHIP_TYPE_8822B &&
>> +           id != RTW_CHIP_TYPE_8812A)
> 
> Would it be clear to list positive chips in a function? and return new/old type
> chip is using for latter condition. 
> 

That sounds good.

>>                 return 0;
>>
>>         if (!rtwdev->efuse.usb_mode_switch) {
>> @@ -999,7 +1026,10 @@ static int rtw_usb_switch_mode(struct rtw_dev *rtwdev)
>>                 return 0;
>>         }
>>
>> -       return rtw_usb_switch_mode_new(rtwdev);
>> +       if (id == RTW_CHIP_TYPE_8812A)
>> +               return rtw_usb_switch_mode_old(rtwdev);
>> +       else /* RTL8822CU, RTL8822BU */
>> +               return rtw_usb_switch_mode_new(rtwdev);
>>  }
> 
> 
> 


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

* Re: [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au
  2024-11-08  2:40   ` Ping-Ke Shih
@ 2024-11-13 23:50     ` Bitterblue Smith
  2024-11-14  0:21       ` Ping-Ke Shih
  0 siblings, 1 reply; 7+ messages in thread
From: Bitterblue Smith @ 2024-11-13 23:50 UTC (permalink / raw)
  To: Ping-Ke Shih, linux-wireless@vger.kernel.org

On 08/11/2024 04:40, Ping-Ke Shih wrote:
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
>>>
>> USB RX aggregation improves the RX speed on certain ARM systems, like
>> the NanoPi NEO Core2. With RTL8811AU, before: 30 Mbps, after: 224 Mbps.
>>
>> The out-of-tree driver uses aggregation size of 7 in USB 3 mode, but
>> that doesn't work here. rtw88 advertises support for receiving AMSDU
>> in AMPDU, so the AP sends larger frames, up to ~5100 bytes. With a size
>> of 7 RTL8812AU frequently tries to aggregate more frames than will fit
>> in 32768 bytes. Use a size of 6 instead.
>>
>> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
>> ---
>>  drivers/net/wireless/realtek/rtw88/usb.c | 30 ++++++++++++++++++++++++
>>  1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
>> index 752bca05b9af..9172af63500b 100644
>> --- a/drivers/net/wireless/realtek/rtw88/usb.c
>> +++ b/drivers/net/wireless/realtek/rtw88/usb.c
>> @@ -790,6 +790,32 @@ static void rtw_usb_dynamic_rx_agg_v1(struct rtw_dev *rtwdev, bool enable)
>>         rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
>>  }
>>
>> +static void rtw_usb_dynamic_rx_agg_v2(struct rtw_dev *rtwdev, bool enable)
>> +{
>> +       struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
>> +       u8 size, timeout;
>> +       u16 val16;
>> +
> 
> How about a shortcut?
> 
> if (!enable) {
> 	size = 0x0;
> 	timeout = 0x1;
> 
> 	goto rx_agg;
> }
> 
>> +       if (rtwusb->udev->speed == USB_SPEED_SUPER) {
>> +               size = 0x6;
>> +               timeout = 0x1a;
>> +       } else {
>> +               size = 0x5;
>> +               timeout = 0x20;
>> +       }
>> +
>> +       if (!enable) {
>> +               size = 0x0;
>> +               timeout = 0x1;
>> +       }
>> +
> 
> rx_agg:
> 
>> +       val16 = u16_encode_bits(size, BIT_RXDMA_AGG_PG_TH) |
>> +               u16_encode_bits(timeout, BIT_DMA_AGG_TO_V1);
>> +
>> +       rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
>> +       rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN);
>> +}

Hmm, I don't like it. What about this?

	if (!enable) {
		size = 0x0;
		timeout = 0x1;
	} else if (rtwusb->udev->speed == USB_SPEED_SUPER) {
		size = 0x6;
		timeout = 0x1a;
	} else {
		size = 0x5;
		timeout = 0x20;
	}

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

* RE: [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au
  2024-11-13 23:50     ` Bitterblue Smith
@ 2024-11-14  0:21       ` Ping-Ke Shih
  0 siblings, 0 replies; 7+ messages in thread
From: Ping-Ke Shih @ 2024-11-14  0:21 UTC (permalink / raw)
  To: Bitterblue Smith, linux-wireless@vger.kernel.org

Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> On 08/11/2024 04:40, Ping-Ke Shih wrote:
> > Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> >>>
> >> USB RX aggregation improves the RX speed on certain ARM systems, like
> >> the NanoPi NEO Core2. With RTL8811AU, before: 30 Mbps, after: 224 Mbps.
> >>
> >> The out-of-tree driver uses aggregation size of 7 in USB 3 mode, but
> >> that doesn't work here. rtw88 advertises support for receiving AMSDU
> >> in AMPDU, so the AP sends larger frames, up to ~5100 bytes. With a size
> >> of 7 RTL8812AU frequently tries to aggregate more frames than will fit
> >> in 32768 bytes. Use a size of 6 instead.
> >>
> >> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> >> ---
> >>  drivers/net/wireless/realtek/rtw88/usb.c | 30 ++++++++++++++++++++++++
> >>  1 file changed, 30 insertions(+)
> >>
> >> diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c
> >> index 752bca05b9af..9172af63500b 100644
> >> --- a/drivers/net/wireless/realtek/rtw88/usb.c
> >> +++ b/drivers/net/wireless/realtek/rtw88/usb.c
> >> @@ -790,6 +790,32 @@ static void rtw_usb_dynamic_rx_agg_v1(struct rtw_dev *rtwdev, bool enable)
> >>         rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
> >>  }
> >>
> >> +static void rtw_usb_dynamic_rx_agg_v2(struct rtw_dev *rtwdev, bool enable)
> >> +{
> >> +       struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev);
> >> +       u8 size, timeout;
> >> +       u16 val16;
> >> +
> >
> > How about a shortcut?
> >
> > if (!enable) {
> >       size = 0x0;
> >       timeout = 0x1;
> >
> >       goto rx_agg;
> > }
> >
> >> +       if (rtwusb->udev->speed == USB_SPEED_SUPER) {
> >> +               size = 0x6;
> >> +               timeout = 0x1a;
> >> +       } else {
> >> +               size = 0x5;
> >> +               timeout = 0x20;
> >> +       }
> >> +
> >> +       if (!enable) {
> >> +               size = 0x0;
> >> +               timeout = 0x1;
> >> +       }
> >> +
> >
> > rx_agg:
> >
> >> +       val16 = u16_encode_bits(size, BIT_RXDMA_AGG_PG_TH) |
> >> +               u16_encode_bits(timeout, BIT_DMA_AGG_TO_V1);
> >> +
> >> +       rtw_write16(rtwdev, REG_RXDMA_AGG_PG_TH, val16);
> >> +       rtw_write8_set(rtwdev, REG_TXDMA_PQ_MAP, BIT_RXDMA_AGG_EN);
> >> +}
> 
> Hmm, I don't like it.

Honestly, I don't like it so much. 

> What about this?
> 
>         if (!enable) {
>                 size = 0x0;
>                 timeout = 0x1;
>         } else if (rtwusb->udev->speed == USB_SPEED_SUPER) {
>                 size = 0x6;
>                 timeout = 0x1a;
>         } else {
>                 size = 0x5;
>                 timeout = 0x20;
>         }

I thought about this too, but a flaw is first condition is for !enable
and later two conditions are for enable. 

I think the logic below is clear, but more indent though. 

        if (!enable) {
                size = 0x0;
                timeout = 0x1;
        } else {
                if (rtwusb->udev->speed == USB_SPEED_SUPER) {
                        size = 0x6;
                        timeout = 0x1a;
                } else {
                        size = 0x5;
                        timeout = 0x20;
                }
        }

Mine, yours and my last proposal are fine to me. You can decide to take
one of them. 



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

end of thread, other threads:[~2024-11-14  0:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 23:41 [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Bitterblue Smith
2024-11-07 23:43 ` [PATCH 2/2] wifi: rtw88: usb: Enable RX aggregation for 8821au/8812au Bitterblue Smith
2024-11-08  2:40   ` Ping-Ke Shih
2024-11-13 23:50     ` Bitterblue Smith
2024-11-14  0:21       ` Ping-Ke Shih
2024-11-08  2:36 ` [PATCH 1/2] wifi: rtw88: usb: Support USB 3 with RTL8812AU Ping-Ke Shih
2024-11-13 23:48   ` Bitterblue Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.