1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox
6 /* Verbs headers do not support -pedantic. */
8 #pragma GCC diagnostic ignored "-Wpedantic"
10 #include <infiniband/mlx4dv.h>
11 #include <infiniband/verbs.h>
13 #pragma GCC diagnostic error "-Wpedantic"
16 #include "mlx4_glue.h"
19 mlx4_glue_fork_init(void)
21 return ibv_fork_init();
25 mlx4_glue_get_async_event(struct ibv_context *context,
26 struct ibv_async_event *event)
28 return ibv_get_async_event(context, event);
32 mlx4_glue_ack_async_event(struct ibv_async_event *event)
34 ibv_ack_async_event(event);
37 static struct ibv_pd *
38 mlx4_glue_alloc_pd(struct ibv_context *context)
40 return ibv_alloc_pd(context);
44 mlx4_glue_dealloc_pd(struct ibv_pd *pd)
46 return ibv_dealloc_pd(pd);
49 static struct ibv_device **
50 mlx4_glue_get_device_list(int *num_devices)
52 return ibv_get_device_list(num_devices);
56 mlx4_glue_free_device_list(struct ibv_device **list)
58 ibv_free_device_list(list);
61 static struct ibv_context *
62 mlx4_glue_open_device(struct ibv_device *device)
64 return ibv_open_device(device);
68 mlx4_glue_close_device(struct ibv_context *context)
70 return ibv_close_device(context);
74 mlx4_glue_get_device_name(struct ibv_device *device)
76 return ibv_get_device_name(device);
80 mlx4_glue_query_device(struct ibv_context *context,
81 struct ibv_device_attr *device_attr)
83 return ibv_query_device(context, device_attr);
87 mlx4_glue_query_device_ex(struct ibv_context *context,
88 const struct ibv_query_device_ex_input *input,
89 struct ibv_device_attr_ex *attr)
91 return ibv_query_device_ex(context, input, attr);
95 mlx4_glue_query_port(struct ibv_context *context, uint8_t port_num,
96 struct ibv_port_attr *port_attr)
98 return ibv_query_port(context, port_num, port_attr);
102 mlx4_glue_port_state_str(enum ibv_port_state port_state)
104 return ibv_port_state_str(port_state);
107 static struct ibv_comp_channel *
108 mlx4_glue_create_comp_channel(struct ibv_context *context)
110 return ibv_create_comp_channel(context);
114 mlx4_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
116 return ibv_destroy_comp_channel(channel);
119 static struct ibv_cq *
120 mlx4_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
121 struct ibv_comp_channel *channel, int comp_vector)
123 return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
127 mlx4_glue_destroy_cq(struct ibv_cq *cq)
129 return ibv_destroy_cq(cq);
133 mlx4_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
136 return ibv_get_cq_event(channel, cq, cq_context);
140 mlx4_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
142 ibv_ack_cq_events(cq, nevents);
145 static struct ibv_flow *
146 mlx4_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
148 return ibv_create_flow(qp, flow);
152 mlx4_glue_destroy_flow(struct ibv_flow *flow_id)
154 return ibv_destroy_flow(flow_id);
157 static struct ibv_qp *
158 mlx4_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
160 return ibv_create_qp(pd, qp_init_attr);
163 static struct ibv_qp *
164 mlx4_glue_create_qp_ex(struct ibv_context *context,
165 struct ibv_qp_init_attr_ex *qp_init_attr_ex)
167 return ibv_create_qp_ex(context, qp_init_attr_ex);
171 mlx4_glue_destroy_qp(struct ibv_qp *qp)
173 return ibv_destroy_qp(qp);
177 mlx4_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
179 return ibv_modify_qp(qp, attr, attr_mask);
182 static struct ibv_mr *
183 mlx4_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
185 return ibv_reg_mr(pd, addr, length, access);
189 mlx4_glue_dereg_mr(struct ibv_mr *mr)
191 return ibv_dereg_mr(mr);
194 static struct ibv_rwq_ind_table *
195 mlx4_glue_create_rwq_ind_table(struct ibv_context *context,
196 struct ibv_rwq_ind_table_init_attr *init_attr)
198 return ibv_create_rwq_ind_table(context, init_attr);
202 mlx4_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
204 return ibv_destroy_rwq_ind_table(rwq_ind_table);
207 static struct ibv_wq *
208 mlx4_glue_create_wq(struct ibv_context *context,
209 struct ibv_wq_init_attr *wq_init_attr)
211 return ibv_create_wq(context, wq_init_attr);
215 mlx4_glue_destroy_wq(struct ibv_wq *wq)
217 return ibv_destroy_wq(wq);
220 mlx4_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
222 return ibv_modify_wq(wq, wq_attr);
226 mlx4_glue_dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type)
228 return mlx4dv_init_obj(obj, obj_type);
232 mlx4_glue_dv_set_context_attr(struct ibv_context *context,
233 enum mlx4dv_set_ctx_attr_type attr_type,
236 return mlx4dv_set_context_attr(context, attr_type, attr);
239 const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){
240 .fork_init = mlx4_glue_fork_init,
241 .get_async_event = mlx4_glue_get_async_event,
242 .ack_async_event = mlx4_glue_ack_async_event,
243 .alloc_pd = mlx4_glue_alloc_pd,
244 .dealloc_pd = mlx4_glue_dealloc_pd,
245 .get_device_list = mlx4_glue_get_device_list,
246 .free_device_list = mlx4_glue_free_device_list,
247 .open_device = mlx4_glue_open_device,
248 .close_device = mlx4_glue_close_device,
249 .get_device_name = mlx4_glue_get_device_name,
250 .query_device = mlx4_glue_query_device,
251 .query_device_ex = mlx4_glue_query_device_ex,
252 .query_port = mlx4_glue_query_port,
253 .port_state_str = mlx4_glue_port_state_str,
254 .create_comp_channel = mlx4_glue_create_comp_channel,
255 .destroy_comp_channel = mlx4_glue_destroy_comp_channel,
256 .create_cq = mlx4_glue_create_cq,
257 .destroy_cq = mlx4_glue_destroy_cq,
258 .get_cq_event = mlx4_glue_get_cq_event,
259 .ack_cq_events = mlx4_glue_ack_cq_events,
260 .create_flow = mlx4_glue_create_flow,
261 .destroy_flow = mlx4_glue_destroy_flow,
262 .create_qp = mlx4_glue_create_qp,
263 .create_qp_ex = mlx4_glue_create_qp_ex,
264 .destroy_qp = mlx4_glue_destroy_qp,
265 .modify_qp = mlx4_glue_modify_qp,
266 .reg_mr = mlx4_glue_reg_mr,
267 .dereg_mr = mlx4_glue_dereg_mr,
268 .create_rwq_ind_table = mlx4_glue_create_rwq_ind_table,
269 .destroy_rwq_ind_table = mlx4_glue_destroy_rwq_ind_table,
270 .create_wq = mlx4_glue_create_wq,
271 .destroy_wq = mlx4_glue_destroy_wq,
272 .modify_wq = mlx4_glue_modify_wq,
273 .dv_init_obj = mlx4_glue_dv_init_obj,
274 .dv_set_context_attr = mlx4_glue_dv_set_context_attr,