Skip to content

Commit fdde66a

Browse files
paravmellanoxSomasundaram Krishnasamy
authored andcommitted
IB/mlx5: Implement clear counters
This patch implements mlx5 driver to support clearing q counters and congestion counters of a port. Orabug: 26761264 MlnxSF: 00384047 Upstream_status: ignore Signed-off-by: Parav Pandit <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Reviewed-by: Yuval Shaia <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent fb50d3a commit fdde66a

File tree

1 file changed

+32
-0
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+32
-0
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,6 +3834,37 @@ static struct rdma_hw_stats *mlx5_ib_alloc_hw_stats(struct ib_device *ibdev,
38343834
RDMA_HW_STATS_DEFAULT_LIFESPAN);
38353835
}
38363836

3837+
static int mlx5_ib_clear_hw_stats(struct ib_device *ibdev, u8 port_num)
3838+
{
3839+
struct mlx5_ib_dev *dev = to_mdev(ibdev);
3840+
struct mlx5_ib_port *port = &dev->port[port_num - 1];
3841+
int outlen = MLX5_ST_SZ_BYTES(query_q_counter_out);
3842+
void *out;
3843+
int ret;
3844+
3845+
out = kvzalloc(outlen, GFP_KERNEL);
3846+
if (!out)
3847+
return -ENOMEM;
3848+
3849+
ret = mlx5_core_query_q_counter(dev->mdev,
3850+
port->cnts.set_id, 1,
3851+
out, outlen);
3852+
kvfree(out);
3853+
3854+
if (ret)
3855+
return ret;
3856+
3857+
outlen = MLX5_ST_SZ_BYTES(query_cong_statistics_out);
3858+
out = kvzalloc(outlen, GFP_KERNEL);
3859+
if (!out)
3860+
return -ENOMEM;
3861+
3862+
ret = mlx5_cmd_query_cong_counter(dev->mdev, true, out, outlen);
3863+
3864+
kvfree(out);
3865+
return ret;
3866+
}
3867+
38373868
static int mlx5_ib_query_q_counters(struct mlx5_core_dev *mdev,
38383869
struct mlx5_ib_port *port,
38393870
struct rdma_hw_stats *stats)
@@ -4571,6 +4602,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
45714602
if (MLX5_CAP_GEN(dev->mdev, max_qp_cnt)) {
45724603
dev->ib_dev.get_hw_stats = mlx5_ib_get_hw_stats;
45734604
dev->ib_dev.alloc_hw_stats = mlx5_ib_alloc_hw_stats;
4605+
dev->ib_dev.clear_hw_stats = mlx5_ib_clear_hw_stats;
45744606
}
45754607

45764608
if (MLX5_CAP_GEN(mdev, xrc)) {

0 commit comments

Comments
 (0)