On Tue, Apr 23, 2024 at 7:32 PM Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> wrote: > > Now, we just show the stats of every queue. > > But for the user, the total values of every stat may are valuable. > > NIC statistics: > rx_packets: 373522 > rx_bytes: 85919736 > rx_drops: 0 > rx_xdp_packets: 0 > rx_xdp_tx: 0 > rx_xdp_redirects: 0 > rx_xdp_drops: 0 > rx_kicks: 11125 > rx_hw_notifications: 0 > rx_hw_packets: 1325870 > rx_hw_bytes: 263348963 > rx_hw_interrupts: 0 > rx_hw_drops: 1451 > rx_hw_drop_overruns: 0 > rx_hw_csum_valid: 1325870 > rx_hw_needs_csum: 1325870 > rx_hw_csum_none: 0 > rx_hw_csum_bad: 0 > rx_hw_ratelimit_packets: 0 > rx_hw_ratelimit_bytes: 0 > tx_packets: 10050 > tx_bytes: 1230176 > tx_xdp_tx: 0 > tx_xdp_tx_drops: 0 > tx_kicks: 10050 > tx_timeouts: 0 > tx_hw_notifications: 0 > tx_hw_packets: 32281 > tx_hw_bytes: 4315590 > tx_hw_interrupts: 0 > tx_hw_drops: 0 > tx_hw_drop_malformed: 0 > tx_hw_csum_none: 0 > tx_hw_needs_csum: 32281 > tx_hw_ratelimit_packets: 0 > tx_hw_ratelimit_bytes: 0 > rx0_packets: 373522 > rx0_bytes: 85919736 > rx0_drops: 0 > rx0_xdp_packets: 0 > rx0_xdp_tx: 0 > rx0_xdp_redirects: 0 > rx0_xdp_drops: 0 > rx0_kicks: 11125 > rx0_hw_notifications: 0 > rx0_hw_packets: 1325870 > rx0_hw_bytes: 263348963 > rx0_hw_interrupts: 0 > rx0_hw_drops: 1451 > rx0_hw_drop_overruns: 0 > rx0_hw_csum_valid: 1325870 > rx0_hw_needs_csum: 1325870 > rx0_hw_csum_none: 0 > rx0_hw_csum_bad: 0 > rx0_hw_ratelimit_packets: 0 > rx0_hw_ratelimit_bytes: 0 > tx0_packets: 10050 > tx0_bytes: 1230176 > tx0_xdp_tx: 0 > tx0_xdp_tx_drops: 0 > tx0_kicks: 10050 > tx0_timeouts: 0 > tx0_hw_notifications: 0 > tx0_hw_packets: 32281 > tx0_hw_bytes: 4315590 > tx0_hw_interrupts: 0 > tx0_hw_drops: 0 > tx0_hw_drop_malformed: 0 > tx0_hw_csum_none: 0 > tx0_hw_needs_csum: 32281 > tx0_hw_ratelimit_packets: 0 > tx0_hw_ratelimit_bytes: 0 > > Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> > --- > drivers/net/virtio_net.c | 81 ++++++++++++++++++++++++++++++++++------ > 1 file changed, 69 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 6d24cd8fb15f..8a4d22f5f5b1 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -3344,14 +3344,15 @@ static void virtnet_stats_sprintf(u8 **p, const char *fmt, const char *noq_fmt, > } > } > > +/* qid == -1: for rx/tx queue total field */ > static void virtnet_get_stats_string(struct virtnet_info *vi, int type, int qid, u8 **data) Nit: -1 for all seems to be a wired API, could we have the caller to iterate the possible qid? Other parts look good. Thanks