1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox Technologies, Ltd
9 /* Verbs headers do not support -pedantic. */
11 #pragma GCC diagnostic ignored "-Wpedantic"
13 #include <infiniband/mlx4dv.h>
14 #include <infiniband/verbs.h>
16 #pragma GCC diagnostic error "-Wpedantic"
19 #include "mlx4_glue.h"
22 mlx4_glue_fork_init(void)
24 return ibv_fork_init();
28 mlx4_glue_get_async_event(struct ibv_context *context,
29 struct ibv_async_event *event)
31 return ibv_get_async_event(context, event);
35 mlx4_glue_ack_async_event(struct ibv_async_event *event)
37 ibv_ack_async_event(event);
40 static struct ibv_pd *
41 mlx4_glue_alloc_pd(struct ibv_context *context)
43 return ibv_alloc_pd(context);
47 mlx4_glue_dealloc_pd(struct ibv_pd *pd)
49 return ibv_dealloc_pd(pd);
52 static struct ibv_device **
53 mlx4_glue_get_device_list(int *num_devices)
55 return ibv_get_device_list(num_devices);
59 mlx4_glue_free_device_list(struct ibv_device **list)
61 ibv_free_device_list(list);
64 static struct ibv_context *
65 mlx4_glue_open_device(struct ibv_device *device)
67 return ibv_open_device(device);
71 mlx4_glue_close_device(struct ibv_context *context)
73 return ibv_close_device(context);
77 mlx4_glue_get_device_name(struct ibv_device *device)
79 return ibv_get_device_name(device);
83 mlx4_glue_query_device(struct ibv_context *context,
84 struct ibv_device_attr *device_attr)
86 return ibv_query_device(context, device_attr);
90 mlx4_glue_query_device_ex(struct ibv_context *context,
91 const struct ibv_query_device_ex_input *input,
92 struct ibv_device_attr_ex *attr)
94 return ibv_query_device_ex(context, input, attr);
98 mlx4_glue_query_port(struct ibv_context *context, uint8_t port_num,
99 struct ibv_port_attr *port_attr)
101 return ibv_query_port(context, port_num, port_attr);
105 mlx4_glue_port_state_str(enum ibv_port_state port_state)
107 return ibv_port_state_str(port_state);
110 static struct ibv_comp_channel *
111 mlx4_glue_create_comp_channel(struct ibv_context *context)
113 return ibv_create_comp_channel(context);
117 mlx4_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
119 return ibv_destroy_comp_channel(channel);
122 static struct ibv_cq *
123 mlx4_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
124 struct ibv_comp_channel *channel, int comp_vector)
126 return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
130 mlx4_glue_destroy_cq(struct ibv_cq *cq)
132 return ibv_destroy_cq(cq);
136 mlx4_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
139 return ibv_get_cq_event(channel, cq, cq_context);
143 mlx4_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
145 ibv_ack_cq_events(cq, nevents);
148 static struct ibv_flow *
149 mlx4_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
151 return ibv_create_flow(qp, flow);
155 mlx4_glue_destroy_flow(struct ibv_flow *flow_id)
157 return ibv_destroy_flow(flow_id);
160 static struct ibv_qp *
161 mlx4_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
163 return ibv_create_qp(pd, qp_init_attr);
166 static struct ibv_qp *
167 mlx4_glue_create_qp_ex(struct ibv_context *context,
168 struct ibv_qp_init_attr_ex *qp_init_attr_ex)
170 return ibv_create_qp_ex(context, qp_init_attr_ex);
174 mlx4_glue_destroy_qp(struct ibv_qp *qp)
176 return ibv_destroy_qp(qp);
180 mlx4_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
182 return ibv_modify_qp(qp, attr, attr_mask);
185 static struct ibv_mr *
186 mlx4_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
188 return ibv_reg_mr(pd, addr, length, access);
192 mlx4_glue_dereg_mr(struct ibv_mr *mr)
194 return ibv_dereg_mr(mr);
197 static struct ibv_rwq_ind_table *
198 mlx4_glue_create_rwq_ind_table(struct ibv_context *context,
199 struct ibv_rwq_ind_table_init_attr *init_attr)
201 return ibv_create_rwq_ind_table(context, init_attr);
205 mlx4_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
207 return ibv_destroy_rwq_ind_table(rwq_ind_table);
210 static struct ibv_wq *
211 mlx4_glue_create_wq(struct ibv_context *context,
212 struct ibv_wq_init_attr *wq_init_attr)
214 return ibv_create_wq(context, wq_init_attr);
218 mlx4_glue_destroy_wq(struct ibv_wq *wq)
220 return ibv_destroy_wq(wq);
223 mlx4_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
225 return ibv_modify_wq(wq, wq_attr);
229 mlx4_glue_dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type)
231 return mlx4dv_init_obj(obj, obj_type);
235 mlx4_glue_dv_set_context_attr(struct ibv_context *context,
236 enum mlx4dv_set_ctx_attr_type attr_type,
239 return mlx4dv_set_context_attr(context, attr_type, attr);
242 const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){
243 .version = MLX4_GLUE_VERSION,
244 .fork_init = mlx4_glue_fork_init,
245 .get_async_event = mlx4_glue_get_async_event,
246 .ack_async_event = mlx4_glue_ack_async_event,
247 .alloc_pd = mlx4_glue_alloc_pd,
248 .dealloc_pd = mlx4_glue_dealloc_pd,
249 .get_device_list = mlx4_glue_get_device_list,
250 .free_device_list = mlx4_glue_free_device_list,
251 .open_device = mlx4_glue_open_device,
252 .close_device = mlx4_glue_close_device,
253 .get_device_name = mlx4_glue_get_device_name,
254 .query_device = mlx4_glue_query_device,
255 .query_device_ex = mlx4_glue_query_device_ex,
256 .query_port = mlx4_glue_query_port,
257 .port_state_str = mlx4_glue_port_state_str,
258 .create_comp_channel = mlx4_glue_create_comp_channel,
259 .destroy_comp_channel = mlx4_glue_destroy_comp_channel,
260 .create_cq = mlx4_glue_create_cq,
261 .destroy_cq = mlx4_glue_destroy_cq,
262 .get_cq_event = mlx4_glue_get_cq_event,
263 .ack_cq_events = mlx4_glue_ack_cq_events,
264 .create_flow = mlx4_glue_create_flow,
265 .destroy_flow = mlx4_glue_destroy_flow,
266 .create_qp = mlx4_glue_create_qp,
267 .create_qp_ex = mlx4_glue_create_qp_ex,
268 .destroy_qp = mlx4_glue_destroy_qp,
269 .modify_qp = mlx4_glue_modify_qp,
270 .reg_mr = mlx4_glue_reg_mr,
271 .dereg_mr = mlx4_glue_dereg_mr,
272 .create_rwq_ind_table = mlx4_glue_create_rwq_ind_table,
273 .destroy_rwq_ind_table = mlx4_glue_destroy_rwq_ind_table,
274 .create_wq = mlx4_glue_create_wq,
275 .destroy_wq = mlx4_glue_destroy_wq,
276 .modify_wq = mlx4_glue_modify_wq,
277 .dv_init_obj = mlx4_glue_dv_init_obj,
278 .dv_set_context_attr = mlx4_glue_dv_set_context_attr,