All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Charles McLachlan <cmclachlan@solarflare.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<linux-net-drivers@solarflare.com>,
	brouer@redhat.com, David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH net-next v4 6/6] sfc: add XDP counters to ethtool stats
Date: Thu, 31 Oct 2019 21:13:00 +0100	[thread overview]
Message-ID: <20191031211300.7e5c1e7c@carbon> (raw)
In-Reply-To: <1d36bf21-f9d0-c464-1886-ef4ac1ed7557@solarflare.com>

On Thu, 31 Oct 2019 10:24:23 +0000
Charles McLachlan <cmclachlan@solarflare.com> wrote:

> Count XDP packet drops, error drops, transmissions and redirects and
> expose these counters via the ethtool stats command.
> 
> Signed-off-by: Charles McLachlan <cmclachlan@solarflare.com>

I'm going to ACK this even-though I don't like these driver specific
counters.  Given we have failed to standardize this, I really cannot
complain.  Hopefully we will get this standardized later

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

Left code below, if Ahern want to complain ;-)

>  drivers/net/ethernet/sfc/ethtool.c    | 25 +++++++++++++++++++++++++
>  drivers/net/ethernet/sfc/net_driver.h |  8 ++++++++
>  drivers/net/ethernet/sfc/rx.c         |  9 +++++++++
>  3 files changed, 42 insertions(+)
> 
> diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
> index 86b965875540..8db593fb9699 100644
> --- a/drivers/net/ethernet/sfc/ethtool.c
> +++ b/drivers/net/ethernet/sfc/ethtool.c
> @@ -83,6 +83,10 @@ static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
>  	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
>  	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events),
>  	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets),
> +	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_drops),
> +	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_bad_drops),
> +	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_tx),
> +	EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_redirect),
>  };
>  
>  #define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
> @@ -399,6 +403,19 @@ static size_t efx_describe_per_queue_stats(struct efx_nic *efx, u8 *strings)
>  			}
>  		}
>  	}
> +	if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
> +		unsigned short xdp;
> +
> +		for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) {
> +			n_stats++;
> +			if (strings) {
> +				snprintf(strings, ETH_GSTRING_LEN,
> +					 "tx-xdp-cpu-%hu.tx_packets", xdp);
> +				strings += ETH_GSTRING_LEN;
> +			}
> +		}
> +	}
> +
>  	return n_stats;
>  }
>  
> @@ -509,6 +526,14 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
>  			data++;
>  		}
>  	}
> +	if (efx->xdp_tx_queue_count && efx->xdp_tx_queues) {
> +		int xdp;
> +
> +		for (xdp = 0; xdp < efx->xdp_tx_queue_count; xdp++) {
> +			data[0] = efx->xdp_tx_queues[xdp]->tx_packets;
> +			data++;
> +		}
> +	}
>  
>  	efx_ptp_update_stats(efx, data);
>  }
> diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
> index 505ddc060e64..04e49eac7327 100644
> --- a/drivers/net/ethernet/sfc/net_driver.h
> +++ b/drivers/net/ethernet/sfc/net_driver.h
> @@ -453,6 +453,10 @@ enum efx_sync_events_state {
>   *	lack of descriptors
>   * @n_rx_merge_events: Number of RX merged completion events
>   * @n_rx_merge_packets: Number of RX packets completed by merged events
> + * @n_rx_xdp_drops: Count of RX packets intentionally dropped due to XDP
> + * @n_rx_xdp_bad_drops: Count of RX packets dropped due to XDP errors
> + * @n_rx_xdp_tx: Count of RX packets retransmitted due to XDP
> + * @n_rx_xdp_redirect: Count of RX packets redirected to a different NIC by XDP
>   * @rx_pkt_n_frags: Number of fragments in next packet to be delivered by
>   *	__efx_rx_packet(), or zero if there is none
>   * @rx_pkt_index: Ring index of first buffer for next packet to be delivered
> @@ -506,6 +510,10 @@ struct efx_channel {
>  	unsigned int n_rx_nodesc_trunc;
>  	unsigned int n_rx_merge_events;
>  	unsigned int n_rx_merge_packets;
> +	unsigned int n_rx_xdp_drops;
> +	unsigned int n_rx_xdp_bad_drops;
> +	unsigned int n_rx_xdp_tx;
> +	unsigned int n_rx_xdp_redirect;
>  
>  	unsigned int rx_pkt_n_frags;
>  	unsigned int rx_pkt_index;
> diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c
> index 91f6d5b9ceac..a7d9841105d8 100644
> --- a/drivers/net/ethernet/sfc/rx.c
> +++ b/drivers/net/ethernet/sfc/rx.c
> @@ -677,6 +677,7 @@ static bool efx_do_xdp(struct efx_nic *efx, struct efx_channel *channel,
>  			netif_err(efx, rx_err, efx->net_dev,
>  				  "XDP is not possible with multiple receive fragments (%d)\n",
>  				  channel->rx_pkt_n_frags);
> +		channel->n_rx_xdp_bad_drops++;
>  		return false;
>  	}
>  
> @@ -722,6 +723,9 @@ static bool efx_do_xdp(struct efx_nic *efx, struct efx_channel *channel,
>  			if (net_ratelimit())
>  				netif_err(efx, rx_err, efx->net_dev,
>  					  "XDP TX failed (%d)\n", err);
> +			channel->n_rx_xdp_bad_drops++;
> +		} else {
> +			channel->n_rx_xdp_tx++;
>  		}
>  		break;
>  
> @@ -732,12 +736,16 @@ static bool efx_do_xdp(struct efx_nic *efx, struct efx_channel *channel,
>  			if (net_ratelimit())
>  				netif_err(efx, rx_err, efx->net_dev,
>  					  "XDP redirect failed (%d)\n", err);
> +			channel->n_rx_xdp_bad_drops++;
> +		} else {
> +			channel->n_rx_xdp_redirect++;
>  		}
>  		break;
>  
>  	default:
>  		bpf_warn_invalid_xdp_action(xdp_act);
>  		efx_free_rx_buffers(rx_queue, rx_buf, 1);
> +		channel->n_rx_xdp_bad_drops++;
>  		break;
>  
>  	case XDP_ABORTED:
> @@ -745,6 +753,7 @@ static bool efx_do_xdp(struct efx_nic *efx, struct efx_channel *channel,
>  		/* Fall through */
>  	case XDP_DROP:
>  		efx_free_rx_buffers(rx_queue, rx_buf, 1);
> +		channel->n_rx_xdp_drops++;
>  		break;
>  	}
>  



-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


  reply	other threads:[~2019-10-31 20:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 10:21 [PATCH net-next v4 0/6] sfc: Add XDP support Charles McLachlan
2019-10-31 10:23 ` [PATCH net-next v4 1/6] sfc: support encapsulation of xdp_frames in efx_tx_buffer Charles McLachlan
2019-10-31 19:54   ` Jesper Dangaard Brouer
2019-10-31 10:23 ` [PATCH net-next v4 2/6] sfc: perform XDP processing on received packets Charles McLachlan
2019-10-31 19:59   ` Jesper Dangaard Brouer
2019-10-31 10:23 ` [PATCH net-next v4 3/6] sfc: Enable setting of xdp_prog Charles McLachlan
2019-10-31 20:00   ` Jesper Dangaard Brouer
2019-10-31 10:23 ` [PATCH net-next v4 4/6] sfc: allocate channels for XDP tx queues Charles McLachlan
2019-10-31 20:04   ` Jesper Dangaard Brouer
2019-10-31 10:24 ` [PATCH net-next v4 5/6] sfc: handle XDP_TX outcomes of XDP eBPF programs Charles McLachlan
2019-10-31 20:14   ` Jesper Dangaard Brouer
2019-10-31 10:24 ` [PATCH net-next v4 6/6] sfc: add XDP counters to ethtool stats Charles McLachlan
2019-10-31 20:13   ` Jesper Dangaard Brouer [this message]
2019-10-31 20:20     ` David Ahern
2019-10-31 18:42 ` [PATCH net-next v4 0/6] sfc: Add XDP support David Miller
2019-10-31 21:15 ` David Miller
2019-10-31 22:18 ` David Ahern
2019-11-01 10:07   ` Martin Habets
2019-11-03 17:24     ` David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191031211300.7e5c1e7c@carbon \
    --to=brouer@redhat.com \
    --cc=cmclachlan@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.