lkml.org 
[lkml]   [2021]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 net-next 11/26] sf100, sfx: implement generic XDP stats callbacks
From
Date
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@intel.com>
> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
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

\
 
 \ /
  Last update: 2021-11-24 11:00    [W:0.329 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site