• Xuan Zhuo's avatar
    virtio_net: support device stats · 941168f8
    Xuan Zhuo authored
    As the spec https://github.com/oasis-tcs/virtio-spec/commit/42f389989823039724f95bbbd243291ab0064f82
    
    make virtio-net support getting the stats from the device by ethtool -S
    <eth0>.
    
    NIC statistics:
         rx0_packets: 582951
         rx0_bytes: 155307077
         rx0_drops: 0
         rx0_xdp_packets: 0
         rx0_xdp_tx: 0
         rx0_xdp_redirects: 0
         rx0_xdp_drops: 0
         rx0_kicks: 17007
         rx0_hw_packets: 2179409
         rx0_hw_bytes: 510015040
         rx0_hw_notifications: 0
         rx0_hw_interrupts: 0
         rx0_hw_needs_csum: 2179409
         rx0_hw_ratelimit_bytes: 0
         tx0_packets: 15361
         tx0_bytes: 1918970
         tx0_xdp_tx: 0
         tx0_xdp_tx_drops: 0
         tx0_kicks: 15361
         tx0_timeouts: 0
         tx0_hw_packets: 32272
         tx0_hw_bytes: 4311698
         tx0_hw_notifications: 0
         tx0_hw_interrupts: 0
         tx0_hw_ratelimit_bytes: 0
    
    The follow stats are hidden, there are exported by the queue stat API
    in the subsequent comment.
    
        VIRTNET_STATS_DESC_RX(basic, drops)
        VIRTNET_STATS_DESC_RX(basic, drop_overruns),
        VIRTNET_STATS_DESC_TX(basic, drops),
        VIRTNET_STATS_DESC_TX(basic, drop_malformed),
        VIRTNET_STATS_DESC_RX(csum, csum_valid),
        VIRTNET_STATS_DESC_RX(csum, csum_none),
        VIRTNET_STATS_DESC_RX(csum, csum_bad),
        VIRTNET_STATS_DESC_TX(csum, needs_csum),
        VIRTNET_STATS_DESC_TX(csum, csum_none),
        VIRTNET_STATS_DESC_RX(gso, gso_packets),
        VIRTNET_STATS_DESC_RX(gso, gso_bytes),
        VIRTNET_STATS_DESC_RX(gso, gso_packets_coalesced),
        VIRTNET_STATS_DESC_RX(gso, gso_bytes_coalesced),
        VIRTNET_STATS_DESC_TX(gso, gso_packets),
        VIRTNET_STATS_DESC_TX(gso, gso_bytes),
        VIRTNET_STATS_DESC_TX(gso, gso_segments),
        VIRTNET_STATS_DESC_TX(gso, gso_segments_bytes),
        VIRTNET_STATS_DESC_RX(speed, ratelimit_packets),
        VIRTNET_STATS_DESC_TX(speed, ratelimit_packets),
    Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
    Acked-by: default avatarJason Wang <jasowang@redhat.com>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    941168f8
virtio_net.c 146 KB