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