Subject: Re: [PATCH iwl-next 1/2] i40e: implement basic per-queue stats

From: Jakub Kicinski <[email-masked]>
Date: Wed, 8 Apr 2026 17:45:04 -0700

On Wed,  8 Apr 2026 13:43:45 +0200 Paolo Abeni wrote:
> +static void i40e_get_queue_stats_tx(struct net_device *dev, int idx,
> +				    struct netdev_queue_stats_tx *tx)
> +{
> +	struct i40e_netdev_priv *np = netdev_priv(dev);
> +	struct i40e_vsi *vsi = np->vsi;
> +	struct i40e_ring *tx_ring;
> +
> +	rcu_read_lock();
> +	tx_ring = READ_ONCE(vsi->tx_rings[idx]);
> +	if (!tx_ring)
> +		goto out;
> +
> +	i40e_zero_tx_ring_stats(tx);
> +	i40e_add_tx_ring_stats(tx_ring, tx);
> +
> +	if (i40e_enabled_xdp_vsi(vsi)) {
> +		tx_ring = READ_ONCE(vsi->xdp_rings[idx]);
> +		if (tx_ring)
> +			i40e_add_tx_ring_stats(tx_ring, tx);

If XDP Tx happens on dedicated queues it should be added to base,
not to the stats of the "stack" queue. This is in anticipation of
XDP being its own queue type one day, we'll then isolate those
out of base. Ripping the out of TX could cause regressions.

> +	}
> +
> +out:
> +	rcu_read_unlock();
> +}
> +
> +static void i40e_get_base_stats(struct net_device *dev,
> +				struct netdev_queue_stats_rx *rx,
> +				struct netdev_queue_stats_tx *tx)
> +{
> +	struct i40e_netdev_priv *np = netdev_priv(dev);
> +	struct i40e_vsi *vsi = np->vsi;
> +
> +	tx->bytes = vsi->tx_bytes;
> +	tx->packets = vsi->tx_packets;
> +	tx->wake = vsi->tx_restart_base;
> +	tx->stop = vsi->tx_stopped_base;
> +	tx->hw_drops = vsi->tx_busy_base;
> +
> +	rx->bytes = vsi->rx_bytes;
> +	rx->packets = vsi->rx_packets;
> +}