mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-10 15:54:39 +08:00
net/mlx5e: Add MACsec stats support for Rx/Tx flows
Add the following statistics: RX successfully decrypted MACsec packets: macsec_rx_pkts : Number of packets decrypted successfully macsec_rx_bytes : Number of bytes decrypted successfully Rx dropped MACsec packets: macsec_rx_pkts_drop : Number of MACsec packets dropped macsec_rx_bytes_drop : Number of MACsec bytes dropped TX successfully encrypted MACsec packets: macsec_tx_pkts : Number of packets encrypted/authenticated successfully macsec_tx_bytes : Number of bytes encrypted/authenticated successfully Tx dropped MACsec packets: macsec_tx_pkts_drop : Number of MACsec packets dropped macsec_tx_bytes_drop : Number of MACsec bytes dropped The above can be seen using: ethtool -S <ifc> |grep macsec Signed-off-by: Lior Nahmanson <liorna@nvidia.com> Reviewed-by: Raed Salem <raeds@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5a39816a75
commit
807a1b765b
@ -92,7 +92,8 @@ mlx5_core-$(CONFIG_MLX5_CORE_IPOIB) += ipoib/ipoib.o ipoib/ethtool.o ipoib/ipoib
|
||||
#
|
||||
mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o
|
||||
|
||||
mlx5_core-$(CONFIG_MLX5_EN_MACSEC) += en_accel/macsec.o en_accel/macsec_fs.o
|
||||
mlx5_core-$(CONFIG_MLX5_EN_MACSEC) += en_accel/macsec.o en_accel/macsec_fs.o \
|
||||
en_accel/macsec_stats.o
|
||||
|
||||
mlx5_core-$(CONFIG_MLX5_EN_IPSEC) += en_accel/ipsec.o en_accel/ipsec_rxtx.o \
|
||||
en_accel/ipsec_stats.o en_accel/ipsec_fs.o \
|
||||
|
@ -68,6 +68,9 @@ struct mlx5e_macsec {
|
||||
|
||||
unsigned char *dev_addr;
|
||||
struct mlx5_core_dev *mdev;
|
||||
|
||||
/* Stats manage */
|
||||
struct mlx5e_macsec_stats stats;
|
||||
};
|
||||
|
||||
struct mlx5_macsec_obj_attrs {
|
||||
@ -990,7 +993,7 @@ static int mlx5e_macsec_del_secy(struct macsec_context *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool mlx5e_is_macsec_device(const struct mlx5_core_dev *mdev)
|
||||
bool mlx5e_is_macsec_device(const struct mlx5_core_dev *mdev)
|
||||
{
|
||||
if (!(MLX5_CAP_GEN_64(mdev, general_obj_types) &
|
||||
MLX5_GENERAL_OBJ_TYPES_CAP_MACSEC_OFFLOAD))
|
||||
@ -1021,6 +1024,19 @@ static bool mlx5e_is_macsec_device(const struct mlx5_core_dev *mdev)
|
||||
return true;
|
||||
}
|
||||
|
||||
void mlx5e_macsec_get_stats_fill(struct mlx5e_macsec *macsec, void *macsec_stats)
|
||||
{
|
||||
mlx5e_macsec_fs_get_stats_fill(macsec->macsec_fs, macsec_stats);
|
||||
}
|
||||
|
||||
struct mlx5e_macsec_stats *mlx5e_macsec_get_stats(struct mlx5e_macsec *macsec)
|
||||
{
|
||||
if (!macsec)
|
||||
return NULL;
|
||||
|
||||
return &macsec->stats;
|
||||
}
|
||||
|
||||
static const struct macsec_ops macsec_offload_ops = {
|
||||
.mdo_add_txsa = mlx5e_macsec_add_txsa,
|
||||
.mdo_upd_txsa = mlx5e_macsec_upd_txsa,
|
||||
|
@ -17,6 +17,17 @@
|
||||
struct mlx5e_priv;
|
||||
struct mlx5e_macsec;
|
||||
|
||||
struct mlx5e_macsec_stats {
|
||||
u64 macsec_rx_pkts;
|
||||
u64 macsec_rx_bytes;
|
||||
u64 macsec_rx_pkts_drop;
|
||||
u64 macsec_rx_bytes_drop;
|
||||
u64 macsec_tx_pkts;
|
||||
u64 macsec_tx_bytes;
|
||||
u64 macsec_tx_pkts_drop;
|
||||
u64 macsec_tx_bytes_drop;
|
||||
};
|
||||
|
||||
void mlx5e_macsec_build_netdev(struct mlx5e_priv *priv);
|
||||
int mlx5e_macsec_init(struct mlx5e_priv *priv);
|
||||
void mlx5e_macsec_cleanup(struct mlx5e_priv *priv);
|
||||
@ -39,6 +50,9 @@ static inline bool mlx5e_macsec_is_rx_flow(struct mlx5_cqe64 *cqe)
|
||||
|
||||
void mlx5e_macsec_offload_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
|
||||
struct mlx5_cqe64 *cqe);
|
||||
bool mlx5e_is_macsec_device(const struct mlx5_core_dev *mdev);
|
||||
void mlx5e_macsec_get_stats_fill(struct mlx5e_macsec *macsec, void *macsec_stats);
|
||||
struct mlx5e_macsec_stats *mlx5e_macsec_get_stats(struct mlx5e_macsec *macsec);
|
||||
|
||||
#else
|
||||
|
||||
@ -51,6 +65,7 @@ static inline void mlx5e_macsec_offload_handle_rx_skb(struct net_device *netdev,
|
||||
struct sk_buff *skb,
|
||||
struct mlx5_cqe64 *cqe)
|
||||
{}
|
||||
static inline bool mlx5e_is_macsec_device(const struct mlx5_core_dev *mdev) { return false; }
|
||||
|
||||
#endif /* CONFIG_MLX5_EN_MACSEC */
|
||||
|
||||
|
@ -1297,6 +1297,30 @@ static void macsec_fs_rx_cleanup(struct mlx5e_macsec_fs *macsec_fs)
|
||||
macsec_fs->rx_fs = NULL;
|
||||
}
|
||||
|
||||
void mlx5e_macsec_fs_get_stats_fill(struct mlx5e_macsec_fs *macsec_fs, void *macsec_stats)
|
||||
{
|
||||
struct mlx5e_macsec_stats *stats = (struct mlx5e_macsec_stats *)macsec_stats;
|
||||
struct mlx5e_macsec_tables *tx_tables = &macsec_fs->tx_fs->tables;
|
||||
struct mlx5e_macsec_tables *rx_tables = &macsec_fs->rx_fs->tables;
|
||||
struct mlx5_core_dev *mdev = macsec_fs->mdev;
|
||||
|
||||
if (tx_tables->check_rule_counter)
|
||||
mlx5_fc_query(mdev, tx_tables->check_rule_counter,
|
||||
&stats->macsec_tx_pkts, &stats->macsec_tx_bytes);
|
||||
|
||||
if (tx_tables->check_miss_rule_counter)
|
||||
mlx5_fc_query(mdev, tx_tables->check_miss_rule_counter,
|
||||
&stats->macsec_tx_pkts_drop, &stats->macsec_tx_bytes_drop);
|
||||
|
||||
if (rx_tables->check_rule_counter)
|
||||
mlx5_fc_query(mdev, rx_tables->check_rule_counter,
|
||||
&stats->macsec_rx_pkts, &stats->macsec_rx_bytes);
|
||||
|
||||
if (rx_tables->check_miss_rule_counter)
|
||||
mlx5_fc_query(mdev, rx_tables->check_miss_rule_counter,
|
||||
&stats->macsec_rx_pkts_drop, &stats->macsec_rx_bytes_drop);
|
||||
}
|
||||
|
||||
union mlx5e_macsec_rule *
|
||||
mlx5e_macsec_fs_add_rule(struct mlx5e_macsec_fs *macsec_fs,
|
||||
const struct macsec_context *macsec_ctx,
|
||||
|
@ -40,6 +40,8 @@ void mlx5e_macsec_fs_del_rule(struct mlx5e_macsec_fs *macsec_fs,
|
||||
union mlx5e_macsec_rule *macsec_rule,
|
||||
int action);
|
||||
|
||||
void mlx5e_macsec_fs_get_stats_fill(struct mlx5e_macsec_fs *macsec_fs, void *macsec_stats);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __MLX5_MACSEC_STEERING_H__ */
|
||||
|
@ -0,0 +1,72 @@
|
||||
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
|
||||
/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
|
||||
|
||||
#include <linux/ethtool.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
#include "en.h"
|
||||
#include "en_accel/macsec.h"
|
||||
|
||||
static const struct counter_desc mlx5e_macsec_hw_stats_desc[] = {
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_rx_pkts) },
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_rx_bytes) },
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_rx_pkts_drop) },
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_rx_bytes_drop) },
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_tx_pkts) },
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_tx_bytes) },
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_tx_pkts_drop) },
|
||||
{ MLX5E_DECLARE_STAT(struct mlx5e_macsec_stats, macsec_tx_bytes_drop) },
|
||||
};
|
||||
|
||||
#define NUM_MACSEC_HW_COUNTERS ARRAY_SIZE(mlx5e_macsec_hw_stats_desc)
|
||||
|
||||
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(macsec_hw)
|
||||
{
|
||||
if (!priv->macsec)
|
||||
return 0;
|
||||
|
||||
if (mlx5e_is_macsec_device(priv->mdev))
|
||||
return NUM_MACSEC_HW_COUNTERS;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(macsec_hw) {}
|
||||
|
||||
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(macsec_hw)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!priv->macsec)
|
||||
return idx;
|
||||
|
||||
if (!mlx5e_is_macsec_device(priv->mdev))
|
||||
return idx;
|
||||
|
||||
for (i = 0; i < NUM_MACSEC_HW_COUNTERS; i++)
|
||||
strcpy(data + (idx++) * ETH_GSTRING_LEN,
|
||||
mlx5e_macsec_hw_stats_desc[i].format);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(macsec_hw)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!priv->macsec)
|
||||
return idx;
|
||||
|
||||
if (!mlx5e_is_macsec_device(priv->mdev))
|
||||
return idx;
|
||||
|
||||
mlx5e_macsec_get_stats_fill(priv->macsec, mlx5e_macsec_get_stats(priv->macsec));
|
||||
for (i = 0; i < NUM_MACSEC_HW_COUNTERS; i++)
|
||||
data[idx++] = MLX5E_READ_CTR64_CPU(mlx5e_macsec_get_stats(priv->macsec),
|
||||
mlx5e_macsec_hw_stats_desc,
|
||||
i);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
MLX5E_DEFINE_STATS_GRP(macsec_hw, 0);
|
@ -2451,6 +2451,9 @@ mlx5e_stats_grp_t mlx5e_nic_stats_grps[] = {
|
||||
&MLX5E_STATS_GRP(per_port_buff_congest),
|
||||
&MLX5E_STATS_GRP(ptp),
|
||||
&MLX5E_STATS_GRP(qos),
|
||||
#ifdef CONFIG_MLX5_EN_MACSEC
|
||||
&MLX5E_STATS_GRP(macsec_hw),
|
||||
#endif
|
||||
};
|
||||
|
||||
unsigned int mlx5e_nic_stats_grps_num(struct mlx5e_priv *priv)
|
||||
|
@ -486,5 +486,6 @@ extern MLX5E_DECLARE_STATS_GRP(channels);
|
||||
extern MLX5E_DECLARE_STATS_GRP(per_port_buff_congest);
|
||||
extern MLX5E_DECLARE_STATS_GRP(ipsec_sw);
|
||||
extern MLX5E_DECLARE_STATS_GRP(ptp);
|
||||
extern MLX5E_DECLARE_STATS_GRP(macsec_hw);
|
||||
|
||||
#endif /* __MLX5_EN_STATS_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user