net/mlx5: rename flow counter configuration macro
[dpdk.git] / drivers / net / mlx5 / mlx5_glue.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018 6WIND S.A.
3  * Copyright 2018 Mellanox Technologies, Ltd
4  */
5
6 #ifndef MLX5_GLUE_H_
7 #define MLX5_GLUE_H_
8
9 #include <stddef.h>
10 #include <stdint.h>
11
12 /* Verbs headers do not support -pedantic. */
13 #ifdef PEDANTIC
14 #pragma GCC diagnostic ignored "-Wpedantic"
15 #endif
16 #include <infiniband/mlx5dv.h>
17 #include <infiniband/verbs.h>
18 #ifdef PEDANTIC
19 #pragma GCC diagnostic error "-Wpedantic"
20 #endif
21
22 #ifndef MLX5_GLUE_VERSION
23 #define MLX5_GLUE_VERSION ""
24 #endif
25
26 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
27 struct ibv_counter_set;
28 struct ibv_counter_set_data;
29 struct ibv_counter_set_description;
30 struct ibv_counter_set_init_attr;
31 struct ibv_query_counter_set_attr;
32 #endif
33
34 #ifndef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
35 struct mlx5dv_qp_init_attr;
36 #endif
37
38 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
39 struct mlx5dv_wq_init_attr;
40 #endif
41
42 #ifndef HAVE_IBV_FLOW_DV_SUPPORT
43 struct mlx5dv_flow_matcher;
44 struct mlx5dv_flow_matcher_attr;
45 struct mlx5dv_flow_action_attr;
46 struct mlx5dv_flow_match_parameters;
47 #endif
48
49 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
50 struct mlx5_glue {
51         const char *version;
52         int (*fork_init)(void);
53         struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
54         int (*dealloc_pd)(struct ibv_pd *pd);
55         struct ibv_device **(*get_device_list)(int *num_devices);
56         void (*free_device_list)(struct ibv_device **list);
57         struct ibv_context *(*open_device)(struct ibv_device *device);
58         int (*close_device)(struct ibv_context *context);
59         int (*query_device)(struct ibv_context *context,
60                             struct ibv_device_attr *device_attr);
61         int (*query_device_ex)(struct ibv_context *context,
62                                const struct ibv_query_device_ex_input *input,
63                                struct ibv_device_attr_ex *attr);
64         int (*query_port)(struct ibv_context *context, uint8_t port_num,
65                           struct ibv_port_attr *port_attr);
66         struct ibv_comp_channel *(*create_comp_channel)
67                 (struct ibv_context *context);
68         int (*destroy_comp_channel)(struct ibv_comp_channel *channel);
69         struct ibv_cq *(*create_cq)(struct ibv_context *context, int cqe,
70                                     void *cq_context,
71                                     struct ibv_comp_channel *channel,
72                                     int comp_vector);
73         int (*destroy_cq)(struct ibv_cq *cq);
74         int (*get_cq_event)(struct ibv_comp_channel *channel,
75                             struct ibv_cq **cq, void **cq_context);
76         void (*ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
77         struct ibv_rwq_ind_table *(*create_rwq_ind_table)
78                 (struct ibv_context *context,
79                  struct ibv_rwq_ind_table_init_attr *init_attr);
80         int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
81         struct ibv_wq *(*create_wq)(struct ibv_context *context,
82                                     struct ibv_wq_init_attr *wq_init_attr);
83         int (*destroy_wq)(struct ibv_wq *wq);
84         int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
85         struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
86                                         struct ibv_flow_attr *flow);
87         int (*destroy_flow)(struct ibv_flow *flow_id);
88         struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
89                                     struct ibv_qp_init_attr *qp_init_attr);
90         struct ibv_qp *(*create_qp_ex)
91                 (struct ibv_context *context,
92                  struct ibv_qp_init_attr_ex *qp_init_attr_ex);
93         int (*destroy_qp)(struct ibv_qp *qp);
94         int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
95                          int attr_mask);
96         struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr,
97                                  size_t length, int access);
98         int (*dereg_mr)(struct ibv_mr *mr);
99         struct ibv_counter_set *(*create_counter_set)
100                 (struct ibv_context *context,
101                  struct ibv_counter_set_init_attr *init_attr);
102         int (*destroy_counter_set)(struct ibv_counter_set *cs);
103         int (*describe_counter_set)
104                 (struct ibv_context *context,
105                  uint16_t counter_set_id,
106                  struct ibv_counter_set_description *cs_desc);
107         int (*query_counter_set)(struct ibv_query_counter_set_attr *query_attr,
108                                  struct ibv_counter_set_data *cs_data);
109         void (*ack_async_event)(struct ibv_async_event *event);
110         int (*get_async_event)(struct ibv_context *context,
111                                struct ibv_async_event *event);
112         const char *(*port_state_str)(enum ibv_port_state port_state);
113         struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
114         struct ibv_cq_ex *(*dv_create_cq)
115                 (struct ibv_context *context,
116                  struct ibv_cq_init_attr_ex *cq_attr,
117                  struct mlx5dv_cq_init_attr *mlx5_cq_attr);
118         struct ibv_wq *(*dv_create_wq)
119                 (struct ibv_context *context,
120                  struct ibv_wq_init_attr *wq_attr,
121                  struct mlx5dv_wq_init_attr *mlx5_wq_attr);
122         int (*dv_query_device)(struct ibv_context *ctx_in,
123                                struct mlx5dv_context *attrs_out);
124         int (*dv_set_context_attr)(struct ibv_context *ibv_ctx,
125                                    enum mlx5dv_set_ctx_attr_type type,
126                                    void *attr);
127         int (*dv_init_obj)(struct mlx5dv_obj *obj, uint64_t obj_type);
128         struct ibv_qp *(*dv_create_qp)
129                 (struct ibv_context *context,
130                  struct ibv_qp_init_attr_ex *qp_init_attr_ex,
131                  struct mlx5dv_qp_init_attr *dv_qp_init_attr);
132         struct mlx5dv_flow_matcher *(*dv_create_flow_matcher)
133                 (struct ibv_context *context,
134                  struct mlx5dv_flow_matcher_attr *matcher_attr);
135         int (*dv_destroy_flow_matcher)(struct mlx5dv_flow_matcher *matcher);
136         struct ibv_flow *(*dv_create_flow)(struct mlx5dv_flow_matcher *matcher,
137                           struct mlx5dv_flow_match_parameters *match_value,
138                           size_t num_actions,
139                           struct mlx5dv_flow_action_attr *actions_attr);
140 };
141
142 const struct mlx5_glue *mlx5_glue;
143
144 #endif /* MLX5_GLUE_H_ */