> From: Stephen Hemminger [mailto:step...@networkplumber.org]
> Sent: Friday, 10 May 2024 07.01
> 
> This is my attempt to demonstrate:
>   - generic counters for SW drivers, the example does af_packet and tap
>     but same should be applied to af_xdp, virtio, etc.
>   - counters are safe against 64 bit tearing on 32 bit platform

+1 for this RFC

> 
> The naming and organization could be improved:
>   - should this be in rte_ethdev?

I think the part for handling 64 bit counters should be moved out into a 
generic library, so it can also be used by libraries and applications. It can 
be extended with more features (feature creep) later. And if some architectures 
offer (more feature creep) optimized implementations, all 64 bit counters for 
those architectures will benefit from such improvements.

I like the concept of joining and generalizing the stats handling for SW 
drivers, to avoid copy-paste of detailed stats handing between SW drivers. 
Copy-paste is bad, common functions are good.

I'm somewhat skeptical about putting the stats structure first in the 
rte_eth_dev_data's tx_queues and rx_queues.
These are void* because their types are private to the PMD. Putting the stats 
structure first is somewhat a hack, partially removing that privacy.
Perhaps we can make it look less like a hack. After all, it is still a private 
structure type, only the first part is public and must be the same across 
drivers using the SW stats counters. Overlapping certain parts of a private 
structure with a public structure is a common design pattern; I've seen it used 
elsewhere in DPDK too.
If we get used to it for SW ethdev drivers, we might not consider it a hack 
anymore. ;-)

>   - better name for struct and vairables?
>   - audit and handle errors better.
> 
> Stephen Hemminger (3):
>   ethdev: add internal helper of SW driver statistics
>   net/af_packet: use SW stats helper
>   net/tap: use generic SW stats
> 
>  drivers/net/af_packet/rte_eth_af_packet.c |  97 ++-----
>  drivers/net/tap/rte_eth_tap.c             | 100 ++------
>  drivers/net/tap/rte_eth_tap.h             |  17 +-
>  lib/ethdev/ethdev_swstats.c               | 294 ++++++++++++++++++++++
>  lib/ethdev/ethdev_swstats.h               |  60 +++++
>  lib/ethdev/meson.build                    |   2 +
>  lib/ethdev/version.map                    |   7 +
>  7 files changed, 400 insertions(+), 177 deletions(-)
>  create mode 100644 lib/ethdev/ethdev_swstats.c
>  create mode 100644 lib/ethdev/ethdev_swstats.h
> 
> --
> 2.43.0

Reply via email to