From: Jakub Kicinski <kuba@kernel.org>
To: nb@tipi-net.de
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, justin.chen@broadcom.com,
horms@kernel.org, mohsin.bashr@gmail.com, opendmb@gmail.com,
florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, andrew+netdev@lunn.ch,
edumazet@google.com, pabeni@redhat.com, davem@davemloft.net,
rajashekar.hudumula@broadcom.com, vikas.gupta@broadcom.com,
bhargava.marreddy@broadcom.com, sashal@kernel.org,
ebiggers@google.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v8 6/7] net: bcmgenet: add XDP statistics counters
Date: Thu, 30 Apr 2026 18:42:34 -0700 [thread overview]
Message-ID: <20260501014233.3171164-2-kuba@kernel.org> (raw)
In-Reply-To: <20260428205846.2625550-7-nb@tipi-net.de>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: bcmgenet: add XDP statistics counters
This commit adds six per-action XDP counters (xdp_pass, xdp_drop, xdp_tx,
xdp_tx_err, xdp_redirect, xdp_redirect_err) to bcmgenet via the existing
soft MIB infrastructure, exposing them through ethtool -S and
incrementing them from bcmgenet_run_xdp().
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 9dd258567824..02ad2f410d6c 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -1169,6 +1169,13 @@ static const struct bcmgenet_stats bcmgenet_gstrings_stats[] = {
> STAT_GENET_SOFT_MIB("tx_realloc_tsb", mib.tx_realloc_tsb),
> STAT_GENET_SOFT_MIB("tx_realloc_tsb_failed",
> mib.tx_realloc_tsb_failed),
> + /* XDP counters */
> + STAT_GENET_SOFT_MIB("xdp_pass", mib.xdp_pass),
> + STAT_GENET_SOFT_MIB("xdp_drop", mib.xdp_drop),
> + STAT_GENET_SOFT_MIB("xdp_tx", mib.xdp_tx),
> + STAT_GENET_SOFT_MIB("xdp_tx_err", mib.xdp_tx_err),
> + STAT_GENET_SOFT_MIB("xdp_redirect", mib.xdp_redirect),
> + STAT_GENET_SOFT_MIB("xdp_redirect_err", mib.xdp_redirect_err),
Should these counters be exposed through the standard netdev netlink
qstats interface rather than as driver-private ethtool -S strings?
Per-action XDP statistics are a generic, cross-driver category that
already has a standard uAPI: the netdev netlink family exposes per-device
and per-queue XDP counters (rx-xdp-packets, rx-xdp-bytes, rx-xdp-errors,
tx-xdp-xmit-*, etc.) via the qstats ops, retrievable with ynl.
Documentation/networking/statistics.rst reserves ethtool -S for
driver-private counters, and the networking subsystem guidance is that
new counters should be plumbed through the standard interface rather
than added as private strings, even when the driver does not currently
implement that interface.
Jakub: no, this is wrong, there are no standard counters for XDP today
> /* Per TX queues */
> STAT_GENET_Q(0),
> STAT_GENET_Q(1),
> @@ -2428,6 +2435,7 @@ static unsigned int bcmgenet_run_xdp(struct bcmgenet_rx_ring *ring,
>
> switch (act) {
> case XDP_PASS:
> + priv->mib.xdp_pass++;
> return XDP_PASS;
> case XDP_TX:
> /* Prepend a zeroed TSB (Transmit Status Block). The GENET
> @@ -2440,6 +2448,7 @@ static unsigned int bcmgenet_run_xdp(struct bcmgenet_rx_ring *ring,
> sizeof(struct status_64) + sizeof(struct xdp_frame)) {
> page_pool_put_full_page(ring->page_pool, rx_page,
> true);
> + priv->mib.xdp_tx_err++;
> return XDP_DROP;
> }
> xdp->data -= sizeof(struct status_64);
> @@ -2459,19 +2468,24 @@ static unsigned int bcmgenet_run_xdp(struct bcmgenet_rx_ring *ring,
> xdpf, false))) {
> spin_unlock(&tx_ring->lock);
> xdp_return_frame_rx_napi(xdpf);
> + priv->mib.xdp_tx_err++;
> return XDP_DROP;
> }
> bcmgenet_xdp_ring_doorbell(priv, tx_ring);
> spin_unlock(&tx_ring->lock);
> + priv->mib.xdp_tx++;
> return XDP_TX;
Is the XDP_TX path missing an increment on one of its failure exits?
The headroom check and the bcmgenet_xdp_xmit_frame() failure both bump
xdp_tx_err, but the xdp_convert_buff_to_frame() failure in between:
xdpf = xdp_convert_buff_to_frame(xdp);
if (unlikely(!xdpf)) {
page_pool_put_full_page(ring->page_pool, rx_page,
true);
return XDP_DROP;
}
returns XDP_DROP without touching any counter.
With this path in place, does the identity
xdp_pass + xdp_drop + xdp_tx + xdp_tx_err +
xdp_redirect + xdp_redirect_err == packets_processed
still hold?
> case XDP_REDIRECT:
> if (unlikely(xdp_do_redirect(priv->dev, xdp, prog))) {
> + priv->mib.xdp_redirect_err++;
> page_pool_put_full_page(ring->page_pool, rx_page,
> true);
> return XDP_DROP;
> }
> + priv->mib.xdp_redirect++;
> return XDP_REDIRECT;
> case XDP_DROP:
> + priv->mib.xdp_drop++;
> page_pool_put_full_page(ring->page_pool, rx_page, true);
> return XDP_DROP;
> default:
> @@ -2479,6 +2493,7 @@ static unsigned int bcmgenet_run_xdp(struct bcmgenet_rx_ring *ring,
> fallthrough;
> case XDP_ABORTED:
> trace_xdp_exception(priv->dev, prog, act);
> + priv->mib.xdp_drop++;
> page_pool_put_full_page(ring->page_pool, rx_page, true);
> return XDP_ABORTED;
> }
Does folding XDP_ABORTED and the unsupported-action default case into
xdp_drop match the commit message's description of "per-action XDP
counters"?
The function returns XDP_ABORTED (not XDP_DROP) in those cases, and the
existing trace_xdp_exception() call distinguishes aborts and unknown
actions from intentional XDP_DROP.
With the current mapping, operators cannot tell an explicit XDP_DROP
from a program abort or an invalid action return when looking at
xdp_drop. Would a separate xdp_aborted (or xdp_errors) counter for the
XDP_ABORTED and default cases be more appropriate?
next prev parent reply other threads:[~2026-05-01 1:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 20:58 [PATCH net-next v8 0/7] net: bcmgenet: add XDP support Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 1/7] net: bcmgenet: convert RX path to page_pool Nicolai Buchwitz
2026-05-01 1:37 ` Jakub Kicinski
2026-04-28 20:58 ` [PATCH net-next v8 2/7] net: bcmgenet: register xdp_rxq_info for each RX ring Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 3/7] net: bcmgenet: add basic XDP support (PASS/DROP) Nicolai Buchwitz
2026-04-28 20:58 ` [PATCH net-next v8 4/7] net: bcmgenet: add XDP_TX support Nicolai Buchwitz
2026-05-01 1:39 ` Jakub Kicinski
2026-04-28 20:58 ` [PATCH net-next v8 5/7] net: bcmgenet: add XDP_REDIRECT and ndo_xdp_xmit support Nicolai Buchwitz
2026-05-01 1:40 ` Jakub Kicinski
2026-04-28 20:58 ` [PATCH net-next v8 6/7] net: bcmgenet: add XDP statistics counters Nicolai Buchwitz
2026-05-01 1:42 ` Jakub Kicinski [this message]
2026-04-28 20:58 ` [PATCH net-next v8 7/7] net: bcmgenet: reject MTU changes incompatible with XDP Nicolai Buchwitz
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=20260501014233.3171164-2-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhargava.marreddy@broadcom.com \
--cc=davem@davemloft.net \
--cc=ebiggers@google.com \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=horms@kernel.org \
--cc=justin.chen@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mohsin.bashr@gmail.com \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=pabeni@redhat.com \
--cc=rajashekar.hudumula@broadcom.com \
--cc=sashal@kernel.org \
--cc=vikas.gupta@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox