On Mon, Nov 09, 2026 at 05:43:10PM +0800, Longjun Tang wrote:
> From: Longjun Tang <[email protected]>
> 
> Add an rx_timeouts field to the per-queue RX statistics and expose it
> via ethtool. Whenever an RX queue gets stuck, the NAPI poll increments
> rx_timeouts, so it counts RX queue stuck events.
> 
> Signed-off-by: Longjun Tang <[email protected]>
> ---
>  drivers/net/virtio_net.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index ec7c248080c5..feb6bfbb1c5a 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -135,6 +135,7 @@ struct virtnet_rq_stats {
>       u64_stats_t xdp_redirects;
>       u64_stats_t xdp_drops;
>       u64_stats_t kicks;
> +     u64_stats_t rx_timeouts;
>  };
>  
>  #define VIRTNET_SQ_STAT(name, m) {name, offsetof(struct virtnet_sq_stats, 
> m), -1}
> @@ -168,6 +169,7 @@ static const struct virtnet_stat_desc 
> virtnet_rq_stats_desc[] = {
>       VIRTNET_RQ_STAT("xdp_redirects", xdp_redirects),
>       VIRTNET_RQ_STAT("xdp_drops",     xdp_drops),
>       VIRTNET_RQ_STAT("kicks",         kicks),
> +     VIRTNET_RQ_STAT("rx_timeouts",   rx_timeouts),
>  };
>

Is this consistent with any other hardware?
  
>  static const struct virtnet_stat_desc virtnet_sq_stats_desc_qstat[] = {
> @@ -2983,6 +2985,12 @@ static int virtnet_receive(struct receive_queue *rq, 
> int budget,
>               u64_stats_add(item, u64_stats_read(src));
>       }
>  
> +     /* Count a stall recovered by this poll. */
> +     if (rq->watchdog.stalled) {
> +             u64_stats_inc(&rq->stats.rx_timeouts);
> +             rq->watchdog.stalled = false;
> +     }
> +
>       u64_stats_add(&rq->stats.packets, u64_stats_read(&stats.packets));
>       u64_stats_add(&rq->stats.bytes, u64_stats_read(&stats.bytes));
>       u64_stats_add(&rq->stats.alloc_fail, u64_stats_read(&stats.alloc_fail));
> -- 
> 2.51.0


Reply via email to