Re: [PATCH net-next v2 1/4] eth: mpnic: count packets, bytes, and drops per ring
From: Daniel Zahka
Date: Mon Oct 19 2026 - 09:09:38 EST
On Fri Oct 16, 2026 at 6:09 PM EDT, Sebastian Andrzej Siewior wrote:
> On 2026-10-12 05:04:34 [-0700], Daniel Zahka wrote:
>> Keep packet, byte and drop counters on each Tx work, Tx completion, and
>> Rx completion queue. Report them to the core via the rtnl_link_stats64
>> interface.
>>
>> Rx completion queues also count errors. Frames the device marked with an
>> uncorrectable error are counted as errors, and frames that fail for any
>> other reason are counted as drops.
>>
>> All packets cleaned from the TWQ during mpnic_flush() are counted as
>> drops, though completions for some of them may have been DMA'd into
>> the completion ring between the time mpnic_poll() last ran and before
>> mpnic_wait_all_queues_idle() returns. This is done for code simplicity.
>>
>> An RCU approach is used because ndo_get_stats64 is not called with the
>> instance lock.
>
> Why do you have the two mpnic_base_stats and fold the stats into into
> it? My guess would be that on stop the counters are reset and you want
> to preserve the stats.
>
Not sure I understand. I think you are asking about two things:
1. Why have two mpnic_base_stats?
To avoid a separate heap allocation that can fail. Handling an
allocation failure in the ndo_stop path when doing the aggregation into
the base stats is tricky.
2. Why split stats into base stats and per queue stats, and why reset
the per queue counts when the device transitions down?
This is the way the stats in netdev.yaml are exposed depending on the
'scope' request attribute. My reading of the relevant kernel docs is
that the per queue counters are counting events for the current live
queue, so it makes sense to reset them and fold those counts into the
base stats when the interface is transitioned down.
>> Signed-off-by: Daniel Zahka <daniel.zahka@xxxxxxxxx>
>
> Sebastian