From: Joe Damato <joe@dama.to>
To: Linus Walleij <linusw@kernel.org>
Cc: "Hans Ulli Kroll" <ulli.kroll@googlemail.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
netdev@vger.kernel.org
Subject: Re: [PATCH 2/3] net: ethernet: cortina: Count dropped frames as NAPI work
Date: Tue, 1 Sep 2026 13:09:02 -0700 [thread overview]
Message-ID: <apcw3tpNHStCCCc/@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <20260901-gemini-ethernet-fixes-v1-2-ee6b09675876@kernel.org>
On Tue, Sep 01, 2026 at 07:04:56PM +0200, Linus Walleij wrote:
> The RX loop only consumes budget when it successfully delivers a frame.
> Error paths keep consuming descriptors without reducing the budget, so a
> stream of bad frames can process the entire receive ring in one poll.
>
> Move the budget accounting to a common end-of-frame path. This counts
> each completed frame as NAPI work whether it was delivered or dropped,
> matching the behavior of the vendor driver.
>
> Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")
> Assisted-by: LLM
> Signed-off-by: Linus Walleij <linusw@kernel.org>
> ---
> drivers/net/ethernet/cortina/gemini.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
[...]
> @@ -1575,27 +1579,27 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)
> struct gemini_ethernet_port *port = netdev_priv(napi->dev);
> struct gemini_ethernet *geth = port->geth;
> unsigned int freeq_threshold;
> - unsigned int received;
> + unsigned int work_done;
>
> freeq_threshold = 1 << (geth->freeq_order - 1);
> u64_stats_update_begin(&port->rx_stats_syncp);
>
> - received = gmac_rx(napi->dev, budget);
> - if (received < budget) {
> + work_done = gmac_rx(napi->dev, budget);
> + if (work_done < budget) {
> napi_gro_flush(napi, false);
> - napi_complete_done(napi, received);
> + napi_complete_done(napi, work_done);
> gmac_enable_rx_irq(napi->dev, 1);
> ++port->rx_napi_exits;
> }
Hmm. I could be wrong, but I think the above code could be simplified by
calling napi_complete_done and letting it do the gro_flush? You can check the
return value and then optionally enable interrupts. That's what most other
drivers do, IIRC.
next prev parent reply other threads:[~2026-09-01 20:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 17:04 [PATCH 0/3] net: ethernet: cortina: Fix RX budget accounting Linus Walleij
2026-09-01 17:04 ` [PATCH 1/3] net: ethernet: cortina: Fix " Linus Walleij
2026-09-01 20:20 ` Joe Damato
2026-09-01 17:04 ` [PATCH 2/3] net: ethernet: cortina: Count dropped frames as NAPI work Linus Walleij
2026-09-01 20:09 ` Joe Damato [this message]
2026-09-01 22:38 ` Jakub Kicinski
2026-09-01 22:00 ` Joe Damato
2026-09-01 22:37 ` Jakub Kicinski
2026-09-02 7:53 ` Linus Walleij
2026-09-01 17:04 ` [PATCH 3/3] net: ethernet: cortina: Count RX descriptors for freeq refill Linus Walleij
2026-09-01 22:01 ` Joe Damato
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=apcw3tpNHStCCCc/@devvm20253.cco0.facebook.com \
--to=joe@dama.to \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ulli.kroll@googlemail.com \
/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 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.