From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] net: r8169: drain RX descriptor ring
Date: Mon, 2 Mar 2026 18:26:30 +0100 [thread overview]
Message-ID: <20260302172630.2713540-1-s.hauer@pengutronix.de> (raw)
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
next reply other threads:[~2026-03-02 17:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 17:26 Sascha Hauer [this message]
2026-03-04 7:48 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260302172630.2713540-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox