Re: [PATCH rdma-next 04/10] RDMA/mlx5: Add alloc_op_port_stats() support
From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2021-08-23 19:19:31
Also in:
linux-rdma
From: Jason Gunthorpe <jgg@nvidia.com>
Date: 2021-08-23 19:19:31
Also in:
linux-rdma
On Wed, Aug 18, 2021 at 02:24:22PM +0300, Mark Zhang wrote:
+static struct rdma_op_stats *
+mlx5_ib_alloc_op_port_stats(struct ib_device *ibdev, u32 port_num)
+{
+ struct rdma_op_stats *opstats;
+ struct mlx5_ib_dev *dev = to_mdev(ibdev);
+ int num_opcounters, i, j = 0;
+
+ num_opcounters = ARRAY_SIZE(basic_op_cnts);
+
+ if (MLX5_CAP_FLOWTABLE(dev->mdev,
+ ft_field_support_2_nic_receive_rdma.bth_opcode))
+ num_opcounters += ARRAY_SIZE(rdmarx_cnp_op_cnts);
+
+ if (MLX5_CAP_FLOWTABLE(dev->mdev,
+ ft_field_support_2_nic_transmit_rdma.bth_opcode))
+ num_opcounters += ARRAY_SIZE(rdmatx_cnp_op_cnts);
+
+ opstats = kzalloc(sizeof(*opstats) +
+ num_opcounters * sizeof(struct rdma_op_counter),
+ GFP_KERNEL);This should use struct_size Jason