aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaed Salem <raeds@mellanox.com>2018-05-31 09:43:40 -0400
committerLeon Romanovsky <leonro@mellanox.com>2018-06-02 00:35:37 -0400
commit5e95af5f7b60796ccd890a39c0ed9c5df3537952 (patch)
treedf627b48598c3c8b0f77b30fea392cb1dad8c807
parent3b3233fbf02ee4c5de4d635ca6c4f2566d9716df (diff)
IB/mlx5: Add flow counters read support
Implements the flow counters read wrapper. Reviewed-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Raed Salem <raeds@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--drivers/infiniband/hw/mlx5/main.c15
-rw-r--r--drivers/infiniband/hw/mlx5/mlx5_ib.h13
2 files changed, 27 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index c52841bad4e7..59e9d10e54b7 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3035,6 +3035,19 @@ static void set_underlay_qp(struct mlx5_ib_dev *dev,
3035 } 3035 }
3036} 3036}
3037 3037
3038static int read_flow_counters(struct ib_device *ibdev,
3039 struct mlx5_read_counters_attr *read_attr)
3040{
3041 struct mlx5_fc *fc = read_attr->hw_cntrs_hndl;
3042 struct mlx5_ib_dev *dev = to_mdev(ibdev);
3043
3044 return mlx5_fc_query(dev->mdev, fc,
3045 &read_attr->out[IB_COUNTER_PACKETS],
3046 &read_attr->out[IB_COUNTER_BYTES]);
3047}
3048
3049/* flow counters currently expose two counters packets and bytes */
3050#define FLOW_COUNTERS_NUM 2
3038static int counters_set_description(struct ib_counters *counters, 3051static int counters_set_description(struct ib_counters *counters,
3039 enum mlx5_ib_counters_type counters_type, 3052 enum mlx5_ib_counters_type counters_type,
3040 struct mlx5_ib_flow_counters_desc *desc_data, 3053 struct mlx5_ib_flow_counters_desc *desc_data,
@@ -3049,6 +3062,8 @@ static int counters_set_description(struct ib_counters *counters,
3049 3062
3050 /* init the fields for the object */ 3063 /* init the fields for the object */
3051 mcounters->type = counters_type; 3064 mcounters->type = counters_type;
3065 mcounters->read_counters = read_flow_counters;
3066 mcounters->counters_num = FLOW_COUNTERS_NUM;
3052 mcounters->ncounters = ncounters; 3067 mcounters->ncounters = ncounters;
3053 /* each counter entry have both description and index pair */ 3068 /* each counter entry have both description and index pair */
3054 for (i = 0; i < ncounters; i++) { 3069 for (i = 0; i < ncounters; i++) {
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 155bca627222..d89c8fe626f6 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -814,6 +814,12 @@ struct mlx5_memic {
814 DECLARE_BITMAP(memic_alloc_pages, MLX5_MAX_MEMIC_PAGES); 814 DECLARE_BITMAP(memic_alloc_pages, MLX5_MAX_MEMIC_PAGES);
815}; 815};
816 816
817struct mlx5_read_counters_attr {
818 struct mlx5_fc *hw_cntrs_hndl;
819 u64 *out;
820 u32 flags;
821};
822
817enum mlx5_ib_counters_type { 823enum mlx5_ib_counters_type {
818 MLX5_IB_COUNTERS_FLOW, 824 MLX5_IB_COUNTERS_FLOW,
819}; 825};
@@ -821,7 +827,12 @@ enum mlx5_ib_counters_type {
821struct mlx5_ib_mcounters { 827struct mlx5_ib_mcounters {
822 struct ib_counters ibcntrs; 828 struct ib_counters ibcntrs;
823 enum mlx5_ib_counters_type type; 829 enum mlx5_ib_counters_type type;
824 void *hw_cntrs_hndl; 830 /* number of counters supported for this counters type */
831 u32 counters_num;
832 struct mlx5_fc *hw_cntrs_hndl;
833 /* read function for this counters type */
834 int (*read_counters)(struct ib_device *ibdev,
835 struct mlx5_read_counters_attr *read_attr);
825 /* max index set as part of create_flow */ 836 /* max index set as part of create_flow */
826 u32 cntrs_max_index; 837 u32 cntrs_max_index;
827 /* number of counters data entries (<description,index> pair) */ 838 /* number of counters data entries (<description,index> pair) */