mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/4] net: usb: r8152: disable rx aggregation
@ 2025-08-07 15:53 Stefan Kerkmann
  2025-08-07 15:53 ` [PATCH 1/4] " Stefan Kerkmann
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Stefan Kerkmann @ 2025-08-07 15:53 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Stefan Kerkmann

This series fixes dropped packages I have seen using various USB
Ethernet adapters that utilize the commonly used realtek rtl8152/rtl8153
chipsets.

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
Stefan Kerkmann (4):
      net: usb: r8152: disable rx aggregation
      net: usb: r8152: print the detected version
      net: usb: usbnet: calm noisy debug calls
      net: usb: add debug call in the receive path

 drivers/net/usb/r8152.c  | 17 +++++++++--------
 drivers/net/usb/usbnet.c |  7 +++++--
 2 files changed, 14 insertions(+), 10 deletions(-)
---
base-commit: c3a821fce680bd990b28285422adc8148126baba
change-id: 20250807-fix-rtl8152-dropped-packages-a0592907a244

Best regards,
-- 
Stefan Kerkmann <s.kerkmann@pengutronix.de>




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

* [PATCH 1/4] net: usb: r8152: disable rx aggregation
  2025-08-07 15:53 [PATCH 0/4] net: usb: r8152: disable rx aggregation Stefan Kerkmann
@ 2025-08-07 15:53 ` Stefan Kerkmann
  2025-08-07 15:53 ` [PATCH 2/4] net: usb: r8152: print the detected version Stefan Kerkmann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Kerkmann @ 2025-08-07 15:53 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Stefan Kerkmann

Enabling RX aggregation packs multiple ethernet frames into one usb bulk
transfer. This increases the throughput significantly, but the driver
currently has no logic in `r8152_rx_fixup` to split the received frames.
This causes silently dropped packets. As the expected througput in a
bootloader using a USB ethernet adapter is rather low this "workaround"
is fine for now.

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
 drivers/net/usb/r8152.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2511c524cd6933cd9de844970edcdaa26a62b8e5..e29dd2ba43cedd9204f9cc418975ba1ace4f5167 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -926,10 +926,9 @@ static void r8153_first_init(struct r8152 *tp)
 	r8152_ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TXFIFO_CTRL,
 			      TXFIFO_THR_NORMAL2);
 
-	/* rx aggregation */
+	/* Disable rx aggregation */
 	ocp_data = r8152_ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
-
-	ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
+	ocp_data |= (RX_AGG_DISABLE | RX_ZERO_EN);
 	r8152_ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
 }
 
@@ -1117,10 +1116,9 @@ static void rtl8152b_init(struct r8152 *tp)
 	r8152b_enable_fc(tp);
 	rtl_tally_reset(tp);
 
-	/* enable rx aggregation */
+	/* Disable rx aggregation */
 	ocp_data = r8152_ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
-
-	ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
+	ocp_data |= (RX_AGG_DISABLE | RX_ZERO_EN);
 	r8152_ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
 }
 
@@ -1259,9 +1257,9 @@ static void r8153b_init(struct r8152 *tp)
 		}
 	}
 
-	/* rx aggregation */
+	/* Disable rx aggregation */
 	ocp_data = r8152_ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
-	ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
+	ocp_data |= (RX_AGG_DISABLE | RX_ZERO_EN);
 	r8152_ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
 
 	rtl_tally_reset(tp);

-- 
2.39.5




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

* [PATCH 2/4] net: usb: r8152: print the detected version
  2025-08-07 15:53 [PATCH 0/4] net: usb: r8152: disable rx aggregation Stefan Kerkmann
  2025-08-07 15:53 ` [PATCH 1/4] " Stefan Kerkmann
@ 2025-08-07 15:53 ` Stefan Kerkmann
  2025-08-07 15:53 ` [PATCH 3/4] net: usb: usbnet: calm noisy debug calls Stefan Kerkmann
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Kerkmann @ 2025-08-07 15:53 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Stefan Kerkmann

Which is helpful during debugging to know which version of the chipset
is used.

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
 drivers/net/usb/r8152.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e29dd2ba43cedd9204f9cc418975ba1ace4f5167..f7f4656e1c43bdfe8cfdb877c3e49b9d8816a7eb 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1053,6 +1053,9 @@ static void r8152_get_version(struct r8152 *tp)
 			/* Found a supported version */
 			tp->version = r8152_versions[i].version;
 			tp->supports_gmii = r8152_versions[i].gmii;
+			dev_dbg(&tp->dev->edev.dev,
+				"r8152 tcr version 0x%04x RTL_VER_%02d detected\n",
+				tcr, tp->version);
 			break;
 		}
 	}

-- 
2.39.5




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

* [PATCH 3/4] net: usb: usbnet: calm noisy debug calls
  2025-08-07 15:53 [PATCH 0/4] net: usb: r8152: disable rx aggregation Stefan Kerkmann
  2025-08-07 15:53 ` [PATCH 1/4] " Stefan Kerkmann
  2025-08-07 15:53 ` [PATCH 2/4] net: usb: r8152: print the detected version Stefan Kerkmann
@ 2025-08-07 15:53 ` Stefan Kerkmann
  2025-08-07 15:53 ` [PATCH 4/4] net: usb: add debug call in the receive path Stefan Kerkmann
  2025-08-08  8:52 ` [PATCH 0/4] net: usb: r8152: disable rx aggregation Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Kerkmann @ 2025-08-07 15:53 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Stefan Kerkmann

These calls are in a hot path so adding #DEBUG to this file will spam
the console.

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
 drivers/net/usb/usbnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 91ce1f00fa24471a8c4afac7358ff8665897f063..6e3ee4d552be36fe6bb052ae29f04a0650b4567d 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -85,7 +85,7 @@ static int usbnet_send(struct eth_device *edev, void *eth_data, int data_length)
 	struct driver_info	*info = dev->driver_info;
 	int			len, alen, ret;
 
-	dev_dbg(&edev->dev, "%s\n",__func__);
+	dev_vdbg(&edev->dev, "%s\n", __func__);
 
 	/* some devices want funky USB-level framing, for
 	 * win32 driver (usually) and/or hardware quirks
@@ -121,7 +121,7 @@ static void usbnet_recv(struct eth_device *edev)
 	struct driver_info	*info = dev->driver_info;
 	int len, ret, alen = 0;
 
-	dev_dbg(&edev->dev, "%s\n",__func__);
+	dev_vdbg(&edev->dev, "%s\n", __func__);
 
 	len = dev->rx_urb_size;
 

-- 
2.39.5




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

* [PATCH 4/4] net: usb: add debug call in the receive path
  2025-08-07 15:53 [PATCH 0/4] net: usb: r8152: disable rx aggregation Stefan Kerkmann
                   ` (2 preceding siblings ...)
  2025-08-07 15:53 ` [PATCH 3/4] net: usb: usbnet: calm noisy debug calls Stefan Kerkmann
@ 2025-08-07 15:53 ` Stefan Kerkmann
  2025-08-08  8:52 ` [PATCH 0/4] net: usb: r8152: disable rx aggregation Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Stefan Kerkmann @ 2025-08-07 15:53 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Stefan Kerkmann

This is the equivalent of the debug call `usbnet_send` and useful to
detect problems in the receive path.

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
 drivers/net/usb/usbnet.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 6e3ee4d552be36fe6bb052ae29f04a0650b4567d..95862cc5b5962178f2ff5dc9bc30253ec3c3fa2d 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -129,6 +129,9 @@ static void usbnet_recv(struct eth_device *edev)
 	if (ret)
 		return;
 
+	dev_dbg(&edev->dev, "%s: ret: %d len: %d alen: %d\n", __func__, ret,
+		len, alen);
+
 	if (alen) {
 		if (info->rx_fixup)
 			info->rx_fixup(dev, dev->rx_buf, alen);

-- 
2.39.5




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

* Re: [PATCH 0/4] net: usb: r8152: disable rx aggregation
  2025-08-07 15:53 [PATCH 0/4] net: usb: r8152: disable rx aggregation Stefan Kerkmann
                   ` (3 preceding siblings ...)
  2025-08-07 15:53 ` [PATCH 4/4] net: usb: add debug call in the receive path Stefan Kerkmann
@ 2025-08-08  8:52 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2025-08-08  8:52 UTC (permalink / raw)
  To: BAREBOX, Stefan Kerkmann


On Thu, 07 Aug 2025 17:53:09 +0200, Stefan Kerkmann wrote:
> This series fixes dropped packages I have seen using various USB
> Ethernet adapters that utilize the commonly used realtek rtl8152/rtl8153
> chipsets.
> 
> 

Applied, thanks!

[1/4] net: usb: r8152: disable rx aggregation
      https://git.pengutronix.de/cgit/barebox/commit/?id=5e9658b7571b (link may not be stable)
[2/4] net: usb: r8152: print the detected version
      https://git.pengutronix.de/cgit/barebox/commit/?id=70ef6db0c1fd (link may not be stable)
[3/4] net: usb: usbnet: calm noisy debug calls
      https://git.pengutronix.de/cgit/barebox/commit/?id=9366ccc0686e (link may not be stable)
[4/4] net: usb: add debug call in the receive path
      https://git.pengutronix.de/cgit/barebox/commit/?id=dfc05ae0b342 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2025-08-08  8:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-07 15:53 [PATCH 0/4] net: usb: r8152: disable rx aggregation Stefan Kerkmann
2025-08-07 15:53 ` [PATCH 1/4] " Stefan Kerkmann
2025-08-07 15:53 ` [PATCH 2/4] net: usb: r8152: print the detected version Stefan Kerkmann
2025-08-07 15:53 ` [PATCH 3/4] net: usb: usbnet: calm noisy debug calls Stefan Kerkmann
2025-08-07 15:53 ` [PATCH 4/4] net: usb: add debug call in the receive path Stefan Kerkmann
2025-08-08  8:52 ` [PATCH 0/4] net: usb: r8152: disable rx aggregation Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox