FILE
macsec_stats.c
File preview with syntax highlighting.
linux-6.19.14/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec_stats.c
1// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB 2/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ 3 4#include <linux/ethtool.h> 5#include <net/sock.h> 6 7#include "en.h" 8#include "en_accel/macsec.h" 9 10static const struct counter_desc mlx5e_macsec_hw_stats_desc[] = { 11 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_rx_pkts) }, 12 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_rx_bytes) }, 13 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_rx_pkts_drop) }, 14 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_rx_bytes_drop) }, 15 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_tx_pkts) }, 16 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_tx_bytes) }, 17 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_tx_pkts_drop) }, 18 { MLX5E_DECLARE_STAT(struct mlx5_macsec_stats, macsec_tx_bytes_drop) }, 19}; 20 21#define NUM_MACSEC_HW_COUNTERS ARRAY_SIZE(mlx5e_macsec_hw_stats_desc) 22 23static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(macsec_hw) 24{ 25 if (!priv->macsec) 26 return 0; 27 28 if (mlx5e_is_macsec_device(priv->mdev)) 29 return NUM_MACSEC_HW_COUNTERS; 30 31 return 0; 32} 33 34static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(macsec_hw) {} 35 36static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(macsec_hw) 37{ 38 unsigned int i; 39 40 if (!priv->macsec) 41 return; 42 43 if (!mlx5e_is_macsec_device(priv->mdev)) 44 return; 45 46 for (i = 0; i < NUM_MACSEC_HW_COUNTERS; i++) 47 ethtool_puts(data, mlx5e_macsec_hw_stats_desc[i].format); 48} 49 50static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(macsec_hw) 51{ 52 struct mlx5_macsec_fs *macsec_fs; 53 int i; 54 55 if (!priv->macsec) 56 return; 57 58 if (!mlx5e_is_macsec_device(priv->mdev)) 59 return; 60 61 macsec_fs = priv->mdev->macsec_fs; 62 mlx5_macsec_fs_get_stats_fill(macsec_fs, mlx5_macsec_fs_get_stats(macsec_fs)); 63 for (i = 0; i < NUM_MACSEC_HW_COUNTERS; i++) 64 mlx5e_ethtool_put_stat( 65 data, MLX5E_READ_CTR64_CPU( 66 mlx5_macsec_fs_get_stats(macsec_fs), 67 mlx5e_macsec_hw_stats_desc, i)); 68} 69 70MLX5E_DEFINE_STATS_GRP(macsec_hw, 0);
~/
Read-only file preview.