* [PATCH] net: r8169: drain RX descriptor ring
@ 2026-03-02 17:26 Sascha Hauer
2026-03-04 7:48 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2026-03-02 17:26 UTC (permalink / raw)
To: Barebox List
When not busy waiting for incoming packets we poll for new packets only
every 10ms. Each time only a single frame is fetched from the hardware.
On a network with many broadcast traffic there might be more than
100 packets/s incoming, which will sooner or later fill up our RX descriptor
ring. Unfortunately the Realtek Hardware has no way to gracefully handle
a RX queue overflow. Fix this by fetching multiple packets from the
hardware in each receive callback.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/r8169_main.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/drivers/net/r8169_main.c b/drivers/net/r8169_main.c
index b74cc43ab0..bc2040a017 100644
--- a/drivers/net/r8169_main.c
+++ b/drivers/net/r8169_main.c
@@ -3013,14 +3013,19 @@ static void rtl8169_eth_rx(struct eth_device *edev)
{
struct rtl8169_private *tp = edev->priv;
struct device *dev = &tp->pci_dev->dev;
- unsigned int entry, pkt_size = 0;
- u8 status;
+ unsigned int entry, pkt_size;
+ u32 opts;
+ int budget = NUM_RX_DESC;
- entry = tp->cur_rx % NUM_RX_DESC;
+ while (budget-- > 0) {
+ entry = tp->cur_rx % NUM_RX_DESC;
+ opts = le32_to_cpu(tp->RxDescArray[entry].opts1);
- if ((le32_to_cpu(tp->RxDescArray[entry].opts1) & DescOwn) == 0) {
- if (!(le32_to_cpu(tp->RxDescArray[entry].opts1) & RxRES)) {
- pkt_size = (le32_to_cpu(tp->RxDescArray[entry].opts1) & 0x1fff) - 4;
+ if (opts & DescOwn)
+ break;
+
+ if (!(opts & RxRES)) {
+ pkt_size = (opts & 0x1fff) - 4;
dma_sync_single_for_cpu(dev, tp->rx_buf_phys + entry * PKT_BUF_SIZE,
pkt_size, DMA_FROM_DEVICE);
@@ -3030,24 +3035,20 @@ static void rtl8169_eth_rx(struct eth_device *edev)
dma_sync_single_for_device(dev, tp->rx_buf_phys + entry * PKT_BUF_SIZE,
pkt_size, DMA_FROM_DEVICE);
-
- if (entry == NUM_RX_DESC - 1)
- tp->RxDescArray[entry].opts1 = cpu_to_le32(DescOwn |
- RingEnd | PKT_BUF_SIZE);
- else
- tp->RxDescArray[entry].opts1 =
- cpu_to_le32(DescOwn | PKT_BUF_SIZE);
- tp->RxDescArray[entry].addr = cpu_to_le64(tp->rx_buf_phys +
- entry * PKT_BUF_SIZE);
} else {
dev_err(&edev->dev, "rx error\n");
}
+ if (entry == NUM_RX_DESC - 1)
+ tp->RxDescArray[entry].opts1 = cpu_to_le32(DescOwn |
+ RingEnd | PKT_BUF_SIZE);
+ else
+ tp->RxDescArray[entry].opts1 =
+ cpu_to_le32(DescOwn | PKT_BUF_SIZE);
+ tp->RxDescArray[entry].addr = cpu_to_le64(tp->rx_buf_phys +
+ entry * PKT_BUF_SIZE);
+
tp->cur_rx++;
- } else {
- status = RTL_R8(tp, IntrStatus);
- RTL_W8(tp, IntrStatus, status & ~(TxErr | RxErr | SYSErr));
- udelay(100); /* wait */
}
}
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net: r8169: drain RX descriptor ring
2026-03-02 17:26 [PATCH] net: r8169: drain RX descriptor ring Sascha Hauer
@ 2026-03-04 7:48 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-03-04 7:48 UTC (permalink / raw)
To: Barebox List, Sascha Hauer
On Mon, 02 Mar 2026 18:26:30 +0100, Sascha Hauer wrote:
> When not busy waiting for incoming packets we poll for new packets only
> every 10ms. Each time only a single frame is fetched from the hardware.
> On a network with many broadcast traffic there might be more than
> 100 packets/s incoming, which will sooner or later fill up our RX descriptor
> ring. Unfortunately the Realtek Hardware has no way to gracefully handle
> a RX queue overflow. Fix this by fetching multiple packets from the
> hardware in each receive callback.
>
> [...]
Applied, thanks!
[1/1] net: r8169: drain RX descriptor ring
https://git.pengutronix.de/cgit/barebox/commit/?id=ba8dab21987b (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-04 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-02 17:26 [PATCH] net: r8169: drain RX descriptor ring Sascha Hauer
2026-03-04 7:48 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox