diff mbox

[rdma-core,10/11] mlx5: Add support for counters read

Message ID 1526553577-32273-11-git-send-email-yishaih@mellanox.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Yishai Hadas May 17, 2018, 10:39 a.m. UTC
From: Raed Salem <raeds@mellanox.com>

Reads the hardware counters values and writes them to
the output index location in the user supplied array.

All counters values are represented as uint64_t types.

The read counter values in the array are defined according to the
configuration defined by user in the ibv_attach_counters_point_xxx
functions.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
---
 providers/mlx5/mlx5.c  |  1 +
 providers/mlx5/mlx5.h  |  4 ++++
 providers/mlx5/verbs.c | 15 +++++++++++++++
 3 files changed, 20 insertions(+)
diff mbox

Patch

diff --git a/providers/mlx5/mlx5.c b/providers/mlx5/mlx5.c
index 24a69f3..814f7a6 100644
--- a/providers/mlx5/mlx5.c
+++ b/providers/mlx5/mlx5.c
@@ -144,6 +144,7 @@  static const struct verbs_context_ops mlx5_ctx_common_ops = {
 	.post_srq_ops = mlx5_post_srq_ops,
 	.query_device_ex = mlx5_query_device_ex,
 	.query_rt_values = mlx5_query_rt_values,
+	.read_counters = mlx5_read_counters,
 	.reg_dm_mr = mlx5_reg_dm_mr,
 };
 
diff --git a/providers/mlx5/mlx5.h b/providers/mlx5/mlx5.h
index c975dff..4890e65 100644
--- a/providers/mlx5/mlx5.h
+++ b/providers/mlx5/mlx5.h
@@ -858,6 +858,10 @@  int mlx5_destroy_counters(struct ibv_counters *counters);
 int mlx5_attach_counters_point_flow(struct ibv_counters *counters,
 				    struct ibv_counter_attach_attr *attr,
 				    struct ibv_flow *flow);
+int mlx5_read_counters(struct ibv_counters *counters,
+		       uint64_t *counters_value,
+		       uint32_t ncounters,
+		       uint32_t flags);
 
 static inline void *mlx5_find_uidx(struct mlx5_context *ctx, uint32_t uidx)
 {
diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c
index 780f093..63701b8 100644
--- a/providers/mlx5/verbs.c
+++ b/providers/mlx5/verbs.c
@@ -3323,3 +3323,18 @@  int mlx5_attach_counters_point_flow(struct ibv_counters *counters,
 
 	return 0;
 }
+
+int mlx5_read_counters(struct ibv_counters *counters,
+		       uint64_t *counters_value,
+		       uint32_t ncounters,
+		       uint32_t flags)
+{
+	struct mlx5_counters *mcntrs = to_mcounters(counters);
+
+	return ibv_cmd_read_counters(&mcntrs->vcounters,
+				     counters_value,
+				     ncounters,
+				     flags,
+				     NULL);
+
+}