1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox Technologies, Ltd
11 /* Verbs headers do not support -pedantic. */
13 #pragma GCC diagnostic ignored "-Wpedantic"
15 #include <infiniband/mlx5dv.h>
16 #include <infiniband/verbs.h>
18 #pragma GCC diagnostic error "-Wpedantic"
21 #include <rte_byteorder.h>
23 #include "mlx5_autoconf.h"
25 #ifndef MLX5_GLUE_VERSION
26 #define MLX5_GLUE_VERSION ""
29 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
30 struct ibv_counter_set
;
31 struct ibv_counter_set_data
;
32 struct ibv_counter_set_description
;
33 struct ibv_counter_set_init_attr
;
34 struct ibv_query_counter_set_attr
;
37 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
39 struct ibv_counters_init_attr
;
40 struct ibv_counter_attach_attr
;
43 #ifndef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
44 struct mlx5dv_qp_init_attr
;
47 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
48 struct mlx5dv_wq_init_attr
;
51 #ifndef HAVE_IBV_FLOW_DV_SUPPORT
52 struct mlx5dv_flow_matcher
;
53 struct mlx5dv_flow_matcher_attr
;
54 struct mlx5dv_flow_action_attr
;
55 struct mlx5dv_flow_match_parameters
;
56 struct mlx5dv_dr_flow_meter_attr
;
57 struct ibv_flow_action
;
58 enum mlx5dv_flow_action_packet_reformat_type
{ packet_reformat_type
= 0, };
59 enum mlx5dv_flow_table_type
{ flow_table_type
= 0, };
62 #ifndef HAVE_IBV_FLOW_DEVX_COUNTERS
63 #define MLX5DV_FLOW_ACTION_COUNTERS_DEVX 0
66 #ifndef HAVE_IBV_DEVX_OBJ
67 struct mlx5dv_devx_obj
;
68 struct mlx5dv_devx_umem
{ uint32_t umem_id
; };
69 struct mlx5dv_devx_uar
{ void *reg_addr
; void *base_addr
; uint32_t page_id
; };
72 #ifndef HAVE_IBV_DEVX_ASYNC
73 struct mlx5dv_devx_cmd_comp
;
74 struct mlx5dv_devx_async_cmd_hdr
;
77 #ifndef HAVE_MLX5DV_DR
78 enum mlx5dv_dr_domain_type
{ unused
, };
79 struct mlx5dv_dr_domain
;
82 #ifndef HAVE_MLX5DV_DR_DEVX_PORT
83 struct mlx5dv_devx_port
;
86 #ifndef HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER
87 struct mlx5dv_dr_flow_meter_attr
;
90 #ifndef HAVE_IBV_DEVX_EVENT
91 struct mlx5dv_devx_event_channel
{ int fd
; };
92 struct mlx5dv_devx_async_event_hdr
;
93 #define MLX5DV_DEVX_CREATE_EVENT_CHANNEL_FLAGS_OMIT_EV_DATA 1
97 struct mlx5dv_var
{ uint32_t page_id
; uint32_t length
; off_t mmap_off
;
98 uint64_t comp_mask
; };
101 #ifndef HAVE_IBV_RELAXED_ORDERING
102 #define IBV_ACCESS_RELAXED_ORDERING 0
105 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
108 int (*fork_init
)(void);
109 struct ibv_pd
*(*alloc_pd
)(struct ibv_context
*context
);
110 int (*dealloc_pd
)(struct ibv_pd
*pd
);
111 struct ibv_device
**(*get_device_list
)(int *num_devices
);
112 void (*free_device_list
)(struct ibv_device
**list
);
113 struct ibv_context
*(*open_device
)(struct ibv_device
*device
);
114 int (*close_device
)(struct ibv_context
*context
);
115 int (*query_device
)(struct ibv_context
*context
,
116 struct ibv_device_attr
*device_attr
);
117 int (*query_device_ex
)(struct ibv_context
*context
,
118 const struct ibv_query_device_ex_input
*input
,
119 struct ibv_device_attr_ex
*attr
);
120 int (*query_rt_values_ex
)(struct ibv_context
*context
,
121 struct ibv_values_ex
*values
);
122 int (*query_port
)(struct ibv_context
*context
, uint8_t port_num
,
123 struct ibv_port_attr
*port_attr
);
124 struct ibv_comp_channel
*(*create_comp_channel
)
125 (struct ibv_context
*context
);
126 int (*destroy_comp_channel
)(struct ibv_comp_channel
*channel
);
127 struct ibv_cq
*(*create_cq
)(struct ibv_context
*context
, int cqe
,
129 struct ibv_comp_channel
*channel
,
131 int (*destroy_cq
)(struct ibv_cq
*cq
);
132 int (*get_cq_event
)(struct ibv_comp_channel
*channel
,
133 struct ibv_cq
**cq
, void **cq_context
);
134 void (*ack_cq_events
)(struct ibv_cq
*cq
, unsigned int nevents
);
135 struct ibv_rwq_ind_table
*(*create_rwq_ind_table
)
136 (struct ibv_context
*context
,
137 struct ibv_rwq_ind_table_init_attr
*init_attr
);
138 int (*destroy_rwq_ind_table
)(struct ibv_rwq_ind_table
*rwq_ind_table
);
139 struct ibv_wq
*(*create_wq
)(struct ibv_context
*context
,
140 struct ibv_wq_init_attr
*wq_init_attr
);
141 int (*destroy_wq
)(struct ibv_wq
*wq
);
142 int (*modify_wq
)(struct ibv_wq
*wq
, struct ibv_wq_attr
*wq_attr
);
143 struct ibv_flow
*(*create_flow
)(struct ibv_qp
*qp
,
144 struct ibv_flow_attr
*flow
);
145 int (*destroy_flow
)(struct ibv_flow
*flow_id
);
146 int (*destroy_flow_action
)(void *action
);
147 struct ibv_qp
*(*create_qp
)(struct ibv_pd
*pd
,
148 struct ibv_qp_init_attr
*qp_init_attr
);
149 struct ibv_qp
*(*create_qp_ex
)
150 (struct ibv_context
*context
,
151 struct ibv_qp_init_attr_ex
*qp_init_attr_ex
);
152 int (*destroy_qp
)(struct ibv_qp
*qp
);
153 int (*modify_qp
)(struct ibv_qp
*qp
, struct ibv_qp_attr
*attr
,
155 struct ibv_mr
*(*reg_mr
)(struct ibv_pd
*pd
, void *addr
,
156 size_t length
, int access
);
157 struct ibv_mr
*(*alloc_null_mr
)(struct ibv_pd
*pd
);
158 int (*dereg_mr
)(struct ibv_mr
*mr
);
159 struct ibv_counter_set
*(*create_counter_set
)
160 (struct ibv_context
*context
,
161 struct ibv_counter_set_init_attr
*init_attr
);
162 int (*destroy_counter_set
)(struct ibv_counter_set
*cs
);
163 int (*describe_counter_set
)
164 (struct ibv_context
*context
,
165 uint16_t counter_set_id
,
166 struct ibv_counter_set_description
*cs_desc
);
167 int (*query_counter_set
)(struct ibv_query_counter_set_attr
*query_attr
,
168 struct ibv_counter_set_data
*cs_data
);
169 struct ibv_counters
*(*create_counters
)
170 (struct ibv_context
*context
,
171 struct ibv_counters_init_attr
*init_attr
);
172 int (*destroy_counters
)(struct ibv_counters
*counters
);
173 int (*attach_counters
)(struct ibv_counters
*counters
,
174 struct ibv_counter_attach_attr
*attr
,
175 struct ibv_flow
*flow
);
176 int (*query_counters
)(struct ibv_counters
*counters
,
177 uint64_t *counters_value
,
180 void (*ack_async_event
)(struct ibv_async_event
*event
);
181 int (*get_async_event
)(struct ibv_context
*context
,
182 struct ibv_async_event
*event
);
183 const char *(*port_state_str
)(enum ibv_port_state port_state
);
184 struct ibv_cq
*(*cq_ex_to_cq
)(struct ibv_cq_ex
*cq
);
185 void *(*dr_create_flow_action_dest_flow_tbl
)(void *tbl
);
186 void *(*dr_create_flow_action_dest_port
)(void *domain
,
188 void *(*dr_create_flow_action_drop
)();
189 void *(*dr_create_flow_action_push_vlan
)
190 (struct mlx5dv_dr_domain
*domain
,
191 rte_be32_t vlan_tag
);
192 void *(*dr_create_flow_action_pop_vlan
)();
193 void *(*dr_create_flow_tbl
)(void *domain
, uint32_t level
);
194 int (*dr_destroy_flow_tbl
)(void *tbl
);
195 void *(*dr_create_domain
)(struct ibv_context
*ctx
,
196 enum mlx5dv_dr_domain_type domain
);
197 int (*dr_destroy_domain
)(void *domain
);
198 struct ibv_cq_ex
*(*dv_create_cq
)
199 (struct ibv_context
*context
,
200 struct ibv_cq_init_attr_ex
*cq_attr
,
201 struct mlx5dv_cq_init_attr
*mlx5_cq_attr
);
202 struct ibv_wq
*(*dv_create_wq
)
203 (struct ibv_context
*context
,
204 struct ibv_wq_init_attr
*wq_attr
,
205 struct mlx5dv_wq_init_attr
*mlx5_wq_attr
);
206 int (*dv_query_device
)(struct ibv_context
*ctx_in
,
207 struct mlx5dv_context
*attrs_out
);
208 int (*dv_set_context_attr
)(struct ibv_context
*ibv_ctx
,
209 enum mlx5dv_set_ctx_attr_type type
,
211 int (*dv_init_obj
)(struct mlx5dv_obj
*obj
, uint64_t obj_type
);
212 struct ibv_qp
*(*dv_create_qp
)
213 (struct ibv_context
*context
,
214 struct ibv_qp_init_attr_ex
*qp_init_attr_ex
,
215 struct mlx5dv_qp_init_attr
*dv_qp_init_attr
);
216 void *(*dv_create_flow_matcher
)
217 (struct ibv_context
*context
,
218 struct mlx5dv_flow_matcher_attr
*matcher_attr
,
220 void *(*dv_create_flow
)(void *matcher
, void *match_value
,
221 size_t num_actions
, void *actions
[]);
222 void *(*dv_create_flow_action_counter
)(void *obj
, uint32_t offset
);
223 void *(*dv_create_flow_action_dest_ibv_qp
)(void *qp
);
224 void *(*dv_create_flow_action_dest_devx_tir
)(void *tir
);
225 void *(*dv_create_flow_action_modify_header
)
226 (struct ibv_context
*ctx
, enum mlx5dv_flow_table_type ft_type
,
227 void *domain
, uint64_t flags
, size_t actions_sz
,
229 void *(*dv_create_flow_action_packet_reformat
)
230 (struct ibv_context
*ctx
,
231 enum mlx5dv_flow_action_packet_reformat_type reformat_type
,
232 enum mlx5dv_flow_table_type ft_type
,
233 struct mlx5dv_dr_domain
*domain
,
234 uint32_t flags
, size_t data_sz
, void *data
);
235 void *(*dv_create_flow_action_tag
)(uint32_t tag
);
236 void *(*dv_create_flow_action_meter
)
237 (struct mlx5dv_dr_flow_meter_attr
*attr
);
238 int (*dv_modify_flow_action_meter
)(void *action
,
239 struct mlx5dv_dr_flow_meter_attr
*attr
, uint64_t modify_bits
);
240 int (*dv_destroy_flow
)(void *flow
);
241 int (*dv_destroy_flow_matcher
)(void *matcher
);
242 struct ibv_context
*(*dv_open_device
)(struct ibv_device
*device
);
243 struct mlx5dv_var
*(*dv_alloc_var
)(struct ibv_context
*context
,
245 void (*dv_free_var
)(struct mlx5dv_var
*var
);
246 struct mlx5dv_devx_uar
*(*devx_alloc_uar
)(struct ibv_context
*context
,
248 void (*devx_free_uar
)(struct mlx5dv_devx_uar
*devx_uar
);
249 struct mlx5dv_devx_obj
*(*devx_obj_create
)
250 (struct ibv_context
*ctx
,
251 const void *in
, size_t inlen
,
252 void *out
, size_t outlen
);
253 int (*devx_obj_destroy
)(struct mlx5dv_devx_obj
*obj
);
254 int (*devx_obj_query
)(struct mlx5dv_devx_obj
*obj
,
255 const void *in
, size_t inlen
,
256 void *out
, size_t outlen
);
257 int (*devx_obj_modify
)(struct mlx5dv_devx_obj
*obj
,
258 const void *in
, size_t inlen
,
259 void *out
, size_t outlen
);
260 int (*devx_general_cmd
)(struct ibv_context
*context
,
261 const void *in
, size_t inlen
,
262 void *out
, size_t outlen
);
263 struct mlx5dv_devx_cmd_comp
*(*devx_create_cmd_comp
)
264 (struct ibv_context
*context
);
265 void (*devx_destroy_cmd_comp
)(struct mlx5dv_devx_cmd_comp
*cmd_comp
);
266 int (*devx_obj_query_async
)(struct mlx5dv_devx_obj
*obj
,
267 const void *in
, size_t inlen
,
268 size_t outlen
, uint64_t wr_id
,
269 struct mlx5dv_devx_cmd_comp
*cmd_comp
);
270 int (*devx_get_async_cmd_comp
)(struct mlx5dv_devx_cmd_comp
*cmd_comp
,
271 struct mlx5dv_devx_async_cmd_hdr
*resp
,
272 size_t cmd_resp_len
);
273 struct mlx5dv_devx_umem
*(*devx_umem_reg
)(struct ibv_context
*context
,
274 void *addr
, size_t size
,
276 int (*devx_umem_dereg
)(struct mlx5dv_devx_umem
*dv_devx_umem
);
277 int (*devx_qp_query
)(struct ibv_qp
*qp
,
278 const void *in
, size_t inlen
,
279 void *out
, size_t outlen
);
280 int (*devx_port_query
)(struct ibv_context
*ctx
,
282 struct mlx5dv_devx_port
*mlx5_devx_port
);
283 int (*dr_dump_domain
)(FILE *file
, void *domain
);
284 int (*devx_query_eqn
)(struct ibv_context
*context
, uint32_t cpus
,
286 struct mlx5dv_devx_event_channel
*(*devx_create_event_channel
)
287 (struct ibv_context
*context
, int flags
);
288 void (*devx_destroy_event_channel
)
289 (struct mlx5dv_devx_event_channel
*event_channel
);
290 int (*devx_subscribe_devx_event
)
291 (struct mlx5dv_devx_event_channel
*event_channel
,
292 struct mlx5dv_devx_obj
*obj
,
294 uint16_t events_num
[],
296 int (*devx_subscribe_devx_event_fd
)
297 (struct mlx5dv_devx_event_channel
*event_channel
,
299 struct mlx5dv_devx_obj
*obj
,
301 ssize_t (*devx_get_event
)
302 (struct mlx5dv_devx_event_channel
*event_channel
,
303 struct mlx5dv_devx_async_event_hdr
*event_data
,
304 size_t event_resp_len
);
307 extern const struct mlx5_glue
*mlx5_glue
;
309 #endif /* MLX5_GLUE_H_ */