Re: [PATCH v2 net-next 11/26] sf100, sfx: implement generic XDP stats callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/11/2021 16:39, Alexander Lobakin wrote:
> Export 4 per-channel XDP counters for both sf100 and sfx drivers
> using generic XDP stats infra.
> 
> Signed-off-by: Alexander Lobakin <alexandr.lobakin@xxxxxxxxx>
> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@xxxxxxxxx>
The usual Subject: prefix for these drivers is sfc:
 (or occasionally sfc_ef100: for ef100-specific stuff).

> +int efx_get_xdp_stats_nch(const struct net_device *net_dev, u32 attr_id)
> +{
> +	const struct efx_nic *efx = netdev_priv(net_dev);
> +
> +	switch (attr_id) {
> +	case IFLA_XDP_XSTATS_TYPE_XDP:
> +		return efx->n_channels;
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +}
> +
> +int efx_get_xdp_stats(const struct net_device *net_dev, u32 attr_id,
> +		      void *attr_data)
> +{
> +	struct ifla_xdp_stats *xdp_stats = attr_data;
> +	struct efx_nic *efx = netdev_priv(net_dev);
> +	const struct efx_channel *channel;
> +
> +	switch (attr_id) {
> +	case IFLA_XDP_XSTATS_TYPE_XDP:
> +		break;
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +
> +	spin_lock_bh(&efx->stats_lock);
> +
> +	efx_for_each_channel(channel, efx) {
> +		xdp_stats->drop = channel->n_rx_xdp_drops;
> +		xdp_stats->errors = channel->n_rx_xdp_bad_drops;
> +		xdp_stats->redirect = channel->n_rx_xdp_redirect;
> +		xdp_stats->tx = channel->n_rx_xdp_tx;
> +
> +		xdp_stats++;
> +	}What guarantees that efx->n_channels won't change between these two
 calls, potentially overrunning the buffer?

-ed



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux