1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox Technologies, Ltd
12 /* Verbs headers do not support -pedantic. */
14 #pragma GCC diagnostic ignored "-Wpedantic"
16 #include <infiniband/mlx5dv.h>
17 #include <infiniband/verbs.h>
19 #pragma GCC diagnostic error "-Wpedantic"
22 #ifndef MLX5_GLUE_VERSION
23 #define MLX5_GLUE_VERSION ""
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;
34 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
36 struct ibv_counters_init_attr;
37 struct ibv_counter_attach_attr;
40 #ifndef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
41 struct mlx5dv_qp_init_attr;
44 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
45 struct mlx5dv_wq_init_attr;
48 #ifndef HAVE_IBV_FLOW_DV_SUPPORT
49 struct mlx5dv_flow_matcher;
50 struct mlx5dv_flow_matcher_attr;
51 struct mlx5dv_flow_action_attr;
52 struct mlx5dv_flow_match_parameters;
53 struct ibv_flow_action;
54 enum mlx5dv_flow_action_packet_reformat_type { packet_reformat_type = 0, };
55 enum mlx5dv_flow_table_type { flow_table_type = 0, };
58 #ifndef HAVE_IBV_FLOW_DEVX_COUNTERS
59 #define MLX5DV_FLOW_ACTION_COUNTERS_DEVX 0
62 #ifndef HAVE_IBV_DEVX_OBJ
63 struct mlx5dv_devx_obj;
64 struct mlx5dv_devx_umem { uint32_t umem_id; };
67 #ifndef HAVE_IBV_DEVX_ASYNC
68 struct mlx5dv_devx_cmd_comp;
69 struct mlx5dv_devx_async_cmd_hdr;
72 #ifndef HAVE_MLX5DV_DR
73 enum mlx5dv_dr_domain_type { unused, };
74 struct mlx5dv_dr_domain;
77 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
80 int (*fork_init)(void);
81 struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
82 int (*dealloc_pd)(struct ibv_pd *pd);
83 struct ibv_device **(*get_device_list)(int *num_devices);
84 void (*free_device_list)(struct ibv_device **list);
85 struct ibv_context *(*open_device)(struct ibv_device *device);
86 int (*close_device)(struct ibv_context *context);
87 int (*query_device)(struct ibv_context *context,
88 struct ibv_device_attr *device_attr);
89 int (*query_device_ex)(struct ibv_context *context,
90 const struct ibv_query_device_ex_input *input,
91 struct ibv_device_attr_ex *attr);
92 int (*query_rt_values_ex)(struct ibv_context *context,
93 struct ibv_values_ex *values);
94 int (*query_port)(struct ibv_context *context, uint8_t port_num,
95 struct ibv_port_attr *port_attr);
96 struct ibv_comp_channel *(*create_comp_channel)
97 (struct ibv_context *context);
98 int (*destroy_comp_channel)(struct ibv_comp_channel *channel);
99 struct ibv_cq *(*create_cq)(struct ibv_context *context, int cqe,
101 struct ibv_comp_channel *channel,
103 int (*destroy_cq)(struct ibv_cq *cq);
104 int (*get_cq_event)(struct ibv_comp_channel *channel,
105 struct ibv_cq **cq, void **cq_context);
106 void (*ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
107 struct ibv_rwq_ind_table *(*create_rwq_ind_table)
108 (struct ibv_context *context,
109 struct ibv_rwq_ind_table_init_attr *init_attr);
110 int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
111 struct ibv_wq *(*create_wq)(struct ibv_context *context,
112 struct ibv_wq_init_attr *wq_init_attr);
113 int (*destroy_wq)(struct ibv_wq *wq);
114 int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
115 struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
116 struct ibv_flow_attr *flow);
117 int (*destroy_flow)(struct ibv_flow *flow_id);
118 int (*destroy_flow_action)(void *action);
119 struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
120 struct ibv_qp_init_attr *qp_init_attr);
121 struct ibv_qp *(*create_qp_ex)
122 (struct ibv_context *context,
123 struct ibv_qp_init_attr_ex *qp_init_attr_ex);
124 int (*destroy_qp)(struct ibv_qp *qp);
125 int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
127 struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr,
128 size_t length, int access);
129 int (*dereg_mr)(struct ibv_mr *mr);
130 struct ibv_counter_set *(*create_counter_set)
131 (struct ibv_context *context,
132 struct ibv_counter_set_init_attr *init_attr);
133 int (*destroy_counter_set)(struct ibv_counter_set *cs);
134 int (*describe_counter_set)
135 (struct ibv_context *context,
136 uint16_t counter_set_id,
137 struct ibv_counter_set_description *cs_desc);
138 int (*query_counter_set)(struct ibv_query_counter_set_attr *query_attr,
139 struct ibv_counter_set_data *cs_data);
140 struct ibv_counters *(*create_counters)
141 (struct ibv_context *context,
142 struct ibv_counters_init_attr *init_attr);
143 int (*destroy_counters)(struct ibv_counters *counters);
144 int (*attach_counters)(struct ibv_counters *counters,
145 struct ibv_counter_attach_attr *attr,
146 struct ibv_flow *flow);
147 int (*query_counters)(struct ibv_counters *counters,
148 uint64_t *counters_value,
151 void (*ack_async_event)(struct ibv_async_event *event);
152 int (*get_async_event)(struct ibv_context *context,
153 struct ibv_async_event *event);
154 const char *(*port_state_str)(enum ibv_port_state port_state);
155 struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
156 void *(*dr_create_flow_action_dest_flow_tbl)(void *tbl);
157 void *(*dr_create_flow_action_dest_vport)(void *domain, uint32_t vport);
158 void *(*dr_create_flow_action_drop)();
159 void *(*dr_create_flow_tbl)(void *domain, uint32_t level);
160 int (*dr_destroy_flow_tbl)(void *tbl);
161 void *(*dr_create_domain)(struct ibv_context *ctx,
162 enum mlx5dv_dr_domain_type domain);
163 int (*dr_destroy_domain)(void *domain);
164 struct ibv_cq_ex *(*dv_create_cq)
165 (struct ibv_context *context,
166 struct ibv_cq_init_attr_ex *cq_attr,
167 struct mlx5dv_cq_init_attr *mlx5_cq_attr);
168 struct ibv_wq *(*dv_create_wq)
169 (struct ibv_context *context,
170 struct ibv_wq_init_attr *wq_attr,
171 struct mlx5dv_wq_init_attr *mlx5_wq_attr);
172 int (*dv_query_device)(struct ibv_context *ctx_in,
173 struct mlx5dv_context *attrs_out);
174 int (*dv_set_context_attr)(struct ibv_context *ibv_ctx,
175 enum mlx5dv_set_ctx_attr_type type,
177 int (*dv_init_obj)(struct mlx5dv_obj *obj, uint64_t obj_type);
178 struct ibv_qp *(*dv_create_qp)
179 (struct ibv_context *context,
180 struct ibv_qp_init_attr_ex *qp_init_attr_ex,
181 struct mlx5dv_qp_init_attr *dv_qp_init_attr);
182 void *(*dv_create_flow_matcher)
183 (struct ibv_context *context,
184 struct mlx5dv_flow_matcher_attr *matcher_attr,
186 void *(*dv_create_flow)(void *matcher, void *match_value,
187 size_t num_actions, void *actions[]);
188 void *(*dv_create_flow_action_counter)(void *obj, uint32_t offset);
189 void *(*dv_create_flow_action_dest_ibv_qp)(void *qp);
190 void *(*dv_create_flow_action_dest_devx_tir)(void *tir);
191 void *(*dv_create_flow_action_modify_header)
192 (struct ibv_context *ctx, enum mlx5dv_flow_table_type ft_type,
193 void *domain, uint64_t flags, size_t actions_sz,
195 void *(*dv_create_flow_action_packet_reformat)
196 (struct ibv_context *ctx,
197 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
198 enum mlx5dv_flow_table_type ft_type,
199 struct mlx5dv_dr_domain *domain,
200 uint32_t flags, size_t data_sz, void *data);
201 void *(*dv_create_flow_action_tag)(uint32_t tag);
202 int (*dv_destroy_flow)(void *flow);
203 int (*dv_destroy_flow_matcher)(void *matcher);
204 struct ibv_context *(*dv_open_device)(struct ibv_device *device);
205 struct mlx5dv_devx_obj *(*devx_obj_create)
206 (struct ibv_context *ctx,
207 const void *in, size_t inlen,
208 void *out, size_t outlen);
209 int (*devx_obj_destroy)(struct mlx5dv_devx_obj *obj);
210 int (*devx_obj_query)(struct mlx5dv_devx_obj *obj,
211 const void *in, size_t inlen,
212 void *out, size_t outlen);
213 int (*devx_obj_modify)(struct mlx5dv_devx_obj *obj,
214 const void *in, size_t inlen,
215 void *out, size_t outlen);
216 int (*devx_general_cmd)(struct ibv_context *context,
217 const void *in, size_t inlen,
218 void *out, size_t outlen);
219 struct mlx5dv_devx_cmd_comp *(*devx_create_cmd_comp)
220 (struct ibv_context *context);
221 void (*devx_destroy_cmd_comp)(struct mlx5dv_devx_cmd_comp *cmd_comp);
222 int (*devx_obj_query_async)(struct mlx5dv_devx_obj *obj,
223 const void *in, size_t inlen,
224 size_t outlen, uint64_t wr_id,
225 struct mlx5dv_devx_cmd_comp *cmd_comp);
226 int (*devx_get_async_cmd_comp)(struct mlx5dv_devx_cmd_comp *cmd_comp,
227 struct mlx5dv_devx_async_cmd_hdr *resp,
228 size_t cmd_resp_len);
229 struct mlx5dv_devx_umem *(*devx_umem_reg)(struct ibv_context *context,
230 void *addr, size_t size,
232 int (*devx_umem_dereg)(struct mlx5dv_devx_umem *dv_devx_umem);
233 int (*devx_qp_query)(struct ibv_qp *qp,
234 const void *in, size_t inlen,
235 void *out, size_t outlen);
238 const struct mlx5_glue *mlx5_glue;
240 #endif /* MLX5_GLUE_H_ */