From f6923226eba5540bd8cde96af91b679ddc4699ab Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 10 Nov 2017 13:58:49 +0000 Subject: [PATCH] Add API function to query port performance counters for infiniband and RoCE traffic in mlx5 core. Sponsored by: Mellanox Technologies MFC after: 1 week --- sys/dev/mlx5/mlx5_core/mlx5_vport.c | 22 ++++++++++++++++++++++ sys/dev/mlx5/vport.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/sys/dev/mlx5/mlx5_core/mlx5_vport.c b/sys/dev/mlx5/mlx5_core/mlx5_vport.c index 448e16fdb4f1..88ef505dbdf3 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_vport.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_vport.c @@ -1757,3 +1757,25 @@ int mlx5_query_hca_vport_state(struct mlx5_core_dev *dev, u8 *vport_state) return err; } EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_state); + +int mlx5_core_query_ib_ppcnt(struct mlx5_core_dev *dev, + u8 port_num, void *out, size_t sz) +{ + u32 *in; + int err; + + in = mlx5_vzalloc(sz); + if (!in) { + err = -ENOMEM; + return err; + } + + MLX5_SET(ppcnt_reg, in, local_port, port_num); + + MLX5_SET(ppcnt_reg, in, grp, MLX5_INFINIBAND_PORT_COUNTERS_GROUP); + err = mlx5_core_access_reg(dev, in, sz, out, + sz, MLX5_REG_PPCNT, 0, 0); + + kvfree(in); + return err; +} diff --git a/sys/dev/mlx5/vport.h b/sys/dev/mlx5/vport.h index 32cfaaeb7da3..bb147e30a99f 100644 --- a/sys/dev/mlx5/vport.h +++ b/sys/dev/mlx5/vport.h @@ -143,4 +143,6 @@ int mlx5_query_vport_counter(struct mlx5_core_dev *dev, void *out, int out_size); int mlx5_get_vport_counters(struct mlx5_core_dev *dev, u8 port_num, struct mlx5_vport_counters *vc); +int mlx5_core_query_ib_ppcnt(struct mlx5_core_dev *dev, + u8 port_num, void *out, size_t sz); #endif /* __MLX5_VPORT_H__ */