Skip to content

Commit b29e2a1

Browse files
Raed SalemLeon Romanovsky
authored andcommitted
IB/mlx5: Add counters create and destroy support
This patch implements the device counters create and destroy APIs and introducing some internal management structures. Downstream patches in this series will add the functionality to support flow counters binding and reading. Reviewed-by: Yishai Hadas <[email protected]> Signed-off-by: Raed Salem <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent b6ba4a9 commit b29e2a1

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5006,6 +5006,27 @@ static void depopulate_specs_root(struct mlx5_ib_dev *dev)
50065006
uverbs_free_spec_tree(dev->ib_dev.specs_root);
50075007
}
50085008

5009+
static int mlx5_ib_destroy_counters(struct ib_counters *counters)
5010+
{
5011+
struct mlx5_ib_mcounters *mcounters = to_mcounters(counters);
5012+
5013+
kfree(mcounters);
5014+
5015+
return 0;
5016+
}
5017+
5018+
static struct ib_counters *mlx5_ib_create_counters(struct ib_device *device,
5019+
struct uverbs_attr_bundle *attrs)
5020+
{
5021+
struct mlx5_ib_mcounters *mcounters;
5022+
5023+
mcounters = kzalloc(sizeof(*mcounters), GFP_KERNEL);
5024+
if (!mcounters)
5025+
return ERR_PTR(-ENOMEM);
5026+
5027+
return &mcounters->ibcntrs;
5028+
}
5029+
50095030
void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev)
50105031
{
50115032
mlx5_ib_cleanup_multiport_master(dev);
@@ -5249,6 +5270,8 @@ int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
52495270
dev->ib_dev.destroy_flow_action = mlx5_ib_destroy_flow_action;
52505271
dev->ib_dev.modify_flow_action_esp = mlx5_ib_modify_flow_action_esp;
52515272
dev->ib_dev.driver_id = RDMA_DRIVER_MLX5;
5273+
dev->ib_dev.create_counters = mlx5_ib_create_counters;
5274+
dev->ib_dev.destroy_counters = mlx5_ib_destroy_counters;
52525275

52535276
err = init_node_data(dev);
52545277
if (err)

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,16 @@ struct mlx5_memic {
813813
DECLARE_BITMAP(memic_alloc_pages, MLX5_MAX_MEMIC_PAGES);
814814
};
815815

816+
struct mlx5_ib_mcounters {
817+
struct ib_counters ibcntrs;
818+
};
819+
820+
static inline struct mlx5_ib_mcounters *
821+
to_mcounters(struct ib_counters *ibcntrs)
822+
{
823+
return container_of(ibcntrs, struct mlx5_ib_mcounters, ibcntrs);
824+
}
825+
816826
struct mlx5_ib_dev {
817827
struct ib_device ib_dev;
818828
struct mlx5_core_dev *mdev;

0 commit comments

Comments
 (0)