[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210818112428.209111-10-markzhang@nvidia.com>
Date: Wed, 18 Aug 2021 14:24:27 +0300
From: Mark Zhang <markzhang@...dia.com>
To: <jgg@...dia.com>, <dledford@...hat.com>, <saeedm@...dia.com>
CC: <linux-rdma@...r.kernel.org>, <netdev@...r.kernel.org>,
<aharonl@...dia.com>, <netao@...dia.com>, <leonro@...dia.com>,
Mark Zhang <markzhang@...dia.com>
Subject: [PATCH rdma-next 09/10] RDMA/mlx5: Add get_op_stats() support
From: Aharon Landau <aharonl@...dia.com>
Add support for ib callback alloc_op_port_stats(), to get optional
counter statistics.
Signed-off-by: Aharon Landau <aharonl@...dia.com>
Signed-off-by: Mark Zhang <markzhang@...dia.com>
---
drivers/infiniband/hw/mlx5/counters.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/counters.c b/drivers/infiniband/hw/mlx5/counters.c
index 5bd1e5a5dffa..5e0cc5af9761 100644
--- a/drivers/infiniband/hw/mlx5/counters.c
+++ b/drivers/infiniband/hw/mlx5/counters.c
@@ -797,12 +797,35 @@ static int mlx5_ib_remove_op_stat(struct ib_device *device, u32 port, int type)
return 0;
}
+static int mlx5_ib_get_op_stats(struct ib_device *device, u32 port,
+ struct rdma_op_stats *stats)
+{
+ struct mlx5_ib_dev *dev = to_mdev(device);
+ struct mlx5_ib_op_fc *opfcs = dev->port[port - 1].cnts.opfcs;
+ u64 packets, bytes;
+ int i, ret, type;
+
+ for (i = 0; i < stats->num_opcounters; i++) {
+ type = stats->opcounters[i].type;
+ if (opfcs[type].fc) {
+ ret = mlx5_fc_query(dev->mdev, opfcs[type].fc,
+ &packets, &bytes);
+ if (ret)
+ return ret;
+ stats->opcounters[i].value = packets;
+ }
+ }
+
+ return 0;
+}
+
static const struct ib_device_ops stats_ops = {
.alloc_hw_port_stats = mlx5_ib_alloc_hw_port_stats,
.alloc_op_port_stats = mlx5_ib_alloc_op_port_stats,
.add_op_stat = mlx5_ib_add_op_stat,
.remove_op_stat = mlx5_ib_remove_op_stat,
.get_hw_stats = mlx5_ib_get_hw_stats,
+ .get_op_stats = mlx5_ib_get_op_stats,
.counter_bind_qp = mlx5_ib_counter_bind_qp,
.counter_unbind_qp = mlx5_ib_counter_unbind_qp,
.counter_dealloc = mlx5_ib_counter_dealloc,
--
2.26.2
Powered by blists - more mailing lists