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 ibv_flow_action;
56 enum mlx5dv_flow_action_packet_reformat_type { packet_reformat_type = 0, };
57 enum mlx5dv_flow_table_type { flow_table_type = 0, };
60 #ifndef HAVE_IBV_FLOW_DEVX_COUNTERS
61 #define MLX5DV_FLOW_ACTION_COUNTERS_DEVX 0
64 #ifndef HAVE_IBV_DEVX_OBJ
65 struct mlx5dv_devx_obj;
66 struct mlx5dv_devx_umem { uint32_t umem_id; };
69 #ifndef HAVE_IBV_DEVX_ASYNC
70 struct mlx5dv_devx_cmd_comp;
71 struct mlx5dv_devx_async_cmd_hdr;
74 #ifndef HAVE_MLX5DV_DR
75 enum mlx5dv_dr_domain_type { unused, };
76 struct mlx5dv_dr_domain;
79 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
82 int (*fork_init)(void);
83 struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
84 int (*dealloc_pd)(struct ibv_pd *pd);
85 struct ibv_device **(*get_device_list)(int *num_devices);
86 void (*free_device_list)(struct ibv_device **list);
87 struct ibv_context *(*open_device)(struct ibv_device *device);
88 int (*close_device)(struct ibv_context *context);
89 int (*query_device)(struct ibv_context *context,
90 struct ibv_device_attr *device_attr);
91 int (*query_device_ex)(struct ibv_context *context,
92 const struct ibv_query_device_ex_input *input,
93 struct ibv_device_attr_ex *attr);
94 int (*query_rt_values_ex)(struct ibv_context *context,
95 struct ibv_values_ex *values);
96 int (*query_port)(struct ibv_context *context, uint8_t port_num,
97 struct ibv_port_attr *port_attr);
98 struct ibv_comp_channel *(*create_comp_channel)
99 (struct ibv_context *context);
100 int (*destroy_comp_channel)(struct ibv_comp_channel *channel);
101 struct ibv_cq *(*create_cq)(struct ibv_context *context, int cqe,
103 struct ibv_comp_channel *channel,
105 int (*destroy_cq)(struct ibv_cq *cq);
106 int (*get_cq_event)(struct ibv_comp_channel *channel,
107 struct ibv_cq **cq, void **cq_context);
108 void (*ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
109 struct ibv_rwq_ind_table *(*create_rwq_ind_table)
110 (struct ibv_context *context,
111 struct ibv_rwq_ind_table_init_attr *init_attr);
112 int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
113 struct ibv_wq *(*create_wq)(struct ibv_context *context,
114 struct ibv_wq_init_attr *wq_init_attr);
115 int (*destroy_wq)(struct ibv_wq *wq);
116 int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
117 struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
118 struct ibv_flow_attr *flow);
119 int (*destroy_flow)(struct ibv_flow *flow_id);
120 int (*destroy_flow_action)(void *action);
121 struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
122 struct ibv_qp_init_attr *qp_init_attr);
123 struct ibv_qp *(*create_qp_ex)
124 (struct ibv_context *context,
125 struct ibv_qp_init_attr_ex *qp_init_attr_ex);
126 int (*destroy_qp)(struct ibv_qp *qp);
127 int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
129 struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr,
130 size_t length, int access);
131 int (*dereg_mr)(struct ibv_mr *mr);
132 struct ibv_counter_set *(*create_counter_set)
133 (struct ibv_context *context,
134 struct ibv_counter_set_init_attr *init_attr);
135 int (*destroy_counter_set)(struct ibv_counter_set *cs);
136 int (*describe_counter_set)
137 (struct ibv_context *context,
138 uint16_t counter_set_id,
139 struct ibv_counter_set_description *cs_desc);
140 int (*query_counter_set)(struct ibv_query_counter_set_attr *query_attr,
141 struct ibv_counter_set_data *cs_data);
142 struct ibv_counters *(*create_counters)
143 (struct ibv_context *context,
144 struct ibv_counters_init_attr *init_attr);
145 int (*destroy_counters)(struct ibv_counters *counters);
146 int (*attach_counters)(struct ibv_counters *counters,
147 struct ibv_counter_attach_attr *attr,
148 struct ibv_flow *flow);
149 int (*query_counters)(struct ibv_counters *counters,
150 uint64_t *counters_value,
153 void (*ack_async_event)(struct ibv_async_event *event);
154 int (*get_async_event)(struct ibv_context *context,
155 struct ibv_async_event *event);
156 const char *(*port_state_str)(enum ibv_port_state port_state);
157 struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
158 void *(*dr_create_flow_action_dest_flow_tbl)(void *tbl);
159 void *(*dr_create_flow_action_dest_vport)(void *domain, uint32_t vport);
160 void *(*dr_create_flow_action_drop)();
161 void *(*dr_create_flow_action_push_vlan)
162 (struct mlx5dv_dr_domain *domain,
163 rte_be32_t vlan_tag);
164 void *(*dr_create_flow_action_pop_vlan)();
165 void *(*dr_create_flow_tbl)(void *domain, uint32_t level);
166 int (*dr_destroy_flow_tbl)(void *tbl);
167 void *(*dr_create_domain)(struct ibv_context *ctx,
168 enum mlx5dv_dr_domain_type domain);
169 int (*dr_destroy_domain)(void *domain);
170 struct ibv_cq_ex *(*dv_create_cq)
171 (struct ibv_context *context,
172 struct ibv_cq_init_attr_ex *cq_attr,
173 struct mlx5dv_cq_init_attr *mlx5_cq_attr);
174 struct ibv_wq *(*dv_create_wq)
175 (struct ibv_context *context,
176 struct ibv_wq_init_attr *wq_attr,
177 struct mlx5dv_wq_init_attr *mlx5_wq_attr);
178 int (*dv_query_device)(struct ibv_context *ctx_in,
179 struct mlx5dv_context *attrs_out);
180 int (*dv_set_context_attr)(struct ibv_context *ibv_ctx,
181 enum mlx5dv_set_ctx_attr_type type,
183 int (*dv_init_obj)(struct mlx5dv_obj *obj, uint64_t obj_type);
184 struct ibv_qp *(*dv_create_qp)
185 (struct ibv_context *context,
186 struct ibv_qp_init_attr_ex *qp_init_attr_ex,
187 struct mlx5dv_qp_init_attr *dv_qp_init_attr);
188 void *(*dv_create_flow_matcher)
189 (struct ibv_context *context,
190 struct mlx5dv_flow_matcher_attr *matcher_attr,
192 void *(*dv_create_flow)(void *matcher, void *match_value,
193 size_t num_actions, void *actions[]);
194 void *(*dv_create_flow_action_counter)(void *obj, uint32_t offset);
195 void *(*dv_create_flow_action_dest_ibv_qp)(void *qp);
196 void *(*dv_create_flow_action_dest_devx_tir)(void *tir);
197 void *(*dv_create_flow_action_modify_header)
198 (struct ibv_context *ctx, enum mlx5dv_flow_table_type ft_type,
199 void *domain, uint64_t flags, size_t actions_sz,
201 void *(*dv_create_flow_action_packet_reformat)
202 (struct ibv_context *ctx,
203 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
204 enum mlx5dv_flow_table_type ft_type,
205 struct mlx5dv_dr_domain *domain,
206 uint32_t flags, size_t data_sz, void *data);
207 void *(*dv_create_flow_action_tag)(uint32_t tag);
208 int (*dv_destroy_flow)(void *flow);
209 int (*dv_destroy_flow_matcher)(void *matcher);
210 struct ibv_context *(*dv_open_device)(struct ibv_device *device);
211 struct mlx5dv_devx_obj *(*devx_obj_create)
212 (struct ibv_context *ctx,
213 const void *in, size_t inlen,
214 void *out, size_t outlen);
215 int (*devx_obj_destroy)(struct mlx5dv_devx_obj *obj);
216 int (*devx_obj_query)(struct mlx5dv_devx_obj *obj,
217 const void *in, size_t inlen,
218 void *out, size_t outlen);
219 int (*devx_obj_modify)(struct mlx5dv_devx_obj *obj,
220 const void *in, size_t inlen,
221 void *out, size_t outlen);
222 int (*devx_general_cmd)(struct ibv_context *context,
223 const void *in, size_t inlen,
224 void *out, size_t outlen);
225 struct mlx5dv_devx_cmd_comp *(*devx_create_cmd_comp)
226 (struct ibv_context *context);
227 void (*devx_destroy_cmd_comp)(struct mlx5dv_devx_cmd_comp *cmd_comp);
228 int (*devx_obj_query_async)(struct mlx5dv_devx_obj *obj,
229 const void *in, size_t inlen,
230 size_t outlen, uint64_t wr_id,
231 struct mlx5dv_devx_cmd_comp *cmd_comp);
232 int (*devx_get_async_cmd_comp)(struct mlx5dv_devx_cmd_comp *cmd_comp,
233 struct mlx5dv_devx_async_cmd_hdr *resp,
234 size_t cmd_resp_len);
235 struct mlx5dv_devx_umem *(*devx_umem_reg)(struct ibv_context *context,
236 void *addr, size_t size,
238 int (*devx_umem_dereg)(struct mlx5dv_devx_umem *dv_devx_umem);
239 int (*devx_qp_query)(struct ibv_qp *qp,
240 const void *in, size_t inlen,
241 void *out, size_t outlen);
244 const struct mlx5_glue *mlx5_glue;
246 #endif /* MLX5_GLUE_H_ */