Skip to content

Commit

Permalink
IB/mlx5: Add counter_alloc_stats() and counter_update_stats() support
Browse files Browse the repository at this point in the history
Add support for ib callback counter_alloc_stats() and
counter_update_stats().

Signed-off-by: Mark Zhang <markz@mellanox.com>
Reviewed-by: Majd Dibbiny <majd@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Mark Zhang authored and Jason Gunthorpe committed Jul 5, 2019
1 parent c4ffee7 commit 18d422c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions drivers/infiniband/hw/mlx5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5586,6 +5586,27 @@ static int mlx5_ib_get_hw_stats(struct ib_device *ibdev,
return num_counters;
}

static struct rdma_hw_stats *
mlx5_ib_counter_alloc_stats(struct rdma_counter *counter)
{
struct mlx5_ib_dev *dev = to_mdev(counter->device);
struct mlx5_ib_port *port = &dev->port[counter->port - 1];

/* Q counters are in the beginning of all counters */
return rdma_alloc_hw_stats_struct(port->cnts.names,
port->cnts.num_q_counters,
RDMA_HW_STATS_DEFAULT_LIFESPAN);
}

static int mlx5_ib_counter_update_stats(struct rdma_counter *counter)
{
struct mlx5_ib_dev *dev = to_mdev(counter->device);
struct mlx5_ib_port *port = &dev->port[counter->port - 1];

return mlx5_ib_query_q_counters(dev->mdev, port,
counter->stats, counter->id);
}

static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
struct ib_qp *qp)
{
Expand Down Expand Up @@ -6553,6 +6574,8 @@ static const struct ib_device_ops mlx5_ib_dev_hw_stats_ops = {
.counter_bind_qp = mlx5_ib_counter_bind_qp,
.counter_unbind_qp = mlx5_ib_counter_unbind_qp,
.counter_dealloc = mlx5_ib_counter_dealloc,
.counter_alloc_stats = mlx5_ib_counter_alloc_stats,
.counter_update_stats = mlx5_ib_counter_update_stats,
};

static int mlx5_ib_stage_counters_init(struct mlx5_ib_dev *dev)
Expand Down

0 comments on commit 18d422c

Please sign in to comment.