From: "Daniel Zahka" <daniel.zahka@gmail.com>
To: <netdev-bot+sashiko@kernel.org>, <daniel.zahka@gmail.com>
Cc: <alexanderduyck@fb.com>, <kuba@kernel.org>,
<kernel-team@meta.com>, <andrew+netdev@lunn.ch>,
<davem@davemloft.net>, <pabeni@redhat.com>, <ast@kernel.org>,
<daniel@iogearbox.net>, <hawk@kernel.org>,
<john.fastabend@gmail.com>, <sdf@fomichev.me>,
<edumazet@kernel.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <bpf@vger.kernel.org>
Subject: Re: [PATCH net-next v2 2/4] eth: mpnic: report per-queue stats
Date: Tue, 13 Oct 2026 09:30:02 -0400 [thread overview]
Message-ID: <DM3QWDZ4B408.2O12B5PXKY8AR@gmail.com> (raw)
In-Reply-To: <179189313526.434549.10762925482009523771@kernel.org>
On Tue Oct 13, 2026 at 8:05 AM EDT, netdev-bot+sashiko wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] This patch reports the RCQ `rcq.packets` and `rcq.bytes`
> counters as the netdev qstats `rx-packets` and `rx-bytes` attributes.
>
> --
>
> eth: mpnic: report per-queue stats
>
> This commit exposes the per-ring packet and byte counters through the
> netdev queue stats API. Counters for deactivated rings are reported
> through the base stats.
>
>> diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>> index 5164475a0f943..c2f4a326a8f0f 100644
>> --- a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>> +++ b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>
> [ ... ]
>
>> @@ -146,6 +147,77 @@ static const struct net_device_ops mpnic_netdev_ops = {
>> .ndo_get_stats64 = mpnic_get_stats64,
>> };
>>
>> +static void mpnic_get_queue_stats_rx(struct net_device *dev, int idx,
>> + struct netdev_queue_stats_rx *rx)
>> +{
>> + struct mpnic_net *mpn = netdev_priv(dev);
>> + struct mpnic_ring *rxr = mpn->rx[idx];
>> + struct mpnic_queue_stats *stats;
>> + unsigned int start;
>> + u64 bytes, packets;
>> +
>> + if (!rxr)
>> + return;
>> +
>> + stats = &rxr->stats;
>> + do {
>> + start = u64_stats_fetch_begin(&stats->syncp);
>> + bytes = u64_stats_read(&stats->rcq.bytes);
>> + packets = u64_stats_read(&stats->rcq.packets);
>> + } while (u64_stats_fetch_retry(&stats->syncp, start));
>> +
>> + rx->bytes = bytes;
>> + rx->packets = packets;
>> +}
>
> [Severity: Medium]
> Do rcq.packets and rcq.bytes match the qstats meaning of rx-packets and
> rx-bytes?
>
> The netdev.yaml spec defines rx-packets as "Number of wire packets
> successfully received and passed to the stack". It defines rx-bytes as
> "Successfully received bytes, see rx-packets".
>
> In mpnic_clean_rcq() in mpnic_txrx.c, packets++ runs for every META
> completion, including completions where the driver drops the packet:
>
> drivers/net/ethernet/meta/mpnic/mpnic_txrx.c:mpnic_clean_rcq() {
> ...
> if (likely(!(rcd &
> MPNIC_RCD_META_UNCORRECTABLE_ERR_MASK) &&
> !state->pkt.add_frag_failed)) {
> bytes += xdp_get_buff_len(&state->pkt.buff);
> skb = xdp_build_skb_from_buff(&state->pkt.buff);
> }
>
> if (likely(skb)) {
> napi_gro_receive(&nv->napi, skb);
> } else {
> mpnic_put_pkt_buff(&state->pkt, true);
> if (rcd & MPNIC_RCD_META_UNCORRECTABLE_ERR_MASK)
> errors++;
> else
> dropped++;
> }
>
> state->pkt.buff.data_hard_start = NULL;
> packets++;
> ...
> u64_stats_add(&rcq->stats.rcq.packets, packets - errors);
> u64_stats_add(&rcq->stats.rcq.bytes, bytes);
> u64_stats_add(&rcq->stats.rcq.dropped, dropped);
> ...
> }
>
> Only errors are subtracted from packets. If add_frag_failed is set, or if
> xdp_build_skb_from_buff() returns NULL, the packet is counted in dropped
> and also in rx-packets.
>
> The buffer length is also added to bytes before xdp_build_skb_from_buff()
> runs. A failed skb build therefore still counts toward rx-bytes. An
> add_frag_failed drop adds to packets but not to bytes, so the two
> counters also disagree with each other.
>
> mpnic_get_base_stats() reports the same values once
> mpnic_aggregate_ring_rcq_counters() folds them into base->rx. The
> miscount carries over after a ring is deactivated.
>
> fbnic_clean_rcq() handles this by jumping to next_dont_count for dropped
> packets, so they are counted in neither packets nor bytes. Could mpnic
> do the same?
>
v1 of this series matched fbnic in this regard, but the bot pointed out
correctly that rtnl stats docs say that packets received ok at the host,
but dropped in the driver (mainly skb allocation failure here), should
be counted in rx-packets.
> The counter semantics come from "eth: mpnic: count packets, bytes, and
> drops per ring" earlier in this series. This patch is the one that
> exposes them as qstats rx-packets and rx-bytes.
>
> The later patch "eth: mpnic: count Rx allocation failures" also counts
> skb build failures in alloc_failed. Those packets still stay in packets
> and bytes.
>
> [ ... ]
So, the question is whether or not rx-packets, reported both to rtnl
stats and qstats, should count drops in the driver. Here, drops are
either running out of shinfo frags, but really just skb allocation
failure.
The docs for rtnl stats strongly suggest an skb allocation failure
should still be counted for rx-packets.
The docs for qstats imply the opposite. Especially when xdp is not
present, which is the case as of this point. Once xdp is introduced,
though, counting an skb allocation failure in rx-packets becomes
reasonable by the qstats docs, because xdp runs before the point of skb
allocation.
Another option would be reporting rx-packets differently for the two
APIs. I think this is not desirable, and seems to violate what is in
the stats.py selftest.
So, I could either submit a v3, which would just be reverting to v1, or
take the approach here as is.
I'm going to hold off on sending a v3, unless there is some human
feedback.
next prev parent reply other threads:[~2026-10-13 13:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 12:04 [PATCH net-next v2 0/4] eth: mpnic: add basic netdev statistics Daniel Zahka
2026-10-12 12:04 ` [PATCH net-next v2 1/4] eth: mpnic: count packets, bytes, and drops per ring Daniel Zahka
2026-10-13 12:05 ` netdev-bot+sashiko
2026-10-13 12:10 ` Daniel Zahka
2026-10-12 12:04 ` [PATCH net-next v2 2/4] eth: mpnic: report per-queue stats Daniel Zahka
2026-10-13 12:05 ` netdev-bot+sashiko
2026-10-13 13:30 ` Daniel Zahka [this message]
2026-10-12 12:04 ` [PATCH net-next v2 3/4] eth: mpnic: count Tx queue stops and wakes Daniel Zahka
2026-10-12 12:04 ` [PATCH net-next v2 4/4] eth: mpnic: count Rx allocation failures Daniel Zahka
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=DM3QWDZ4B408.2O12B5PXKY8AR@gmail.com \
--to=daniel.zahka@gmail.com \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/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.