Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2018 6WIND S.A.
3 : : * Copyright 2018 Mellanox Technologies, Ltd
4 : : */
5 : :
6 : : #include <stddef.h>
7 : : #include <stdint.h>
8 : :
9 : : /* Verbs headers do not support -pedantic. */
10 : : #ifdef PEDANTIC
11 : : #pragma GCC diagnostic ignored "-Wpedantic"
12 : : #endif
13 : : #include <infiniband/mlx4dv.h>
14 : : #include <infiniband/verbs.h>
15 : : #ifdef PEDANTIC
16 : : #pragma GCC diagnostic error "-Wpedantic"
17 : : #endif
18 : :
19 : : #include "mlx4_glue.h"
20 : :
21 : : static int
22 : 251 : mlx4_glue_fork_init(void)
23 : : {
24 : 251 : return ibv_fork_init();
25 : : }
26 : :
27 : : static int
28 : 0 : mlx4_glue_get_async_event(struct ibv_context *context,
29 : : struct ibv_async_event *event)
30 : : {
31 : 0 : return ibv_get_async_event(context, event);
32 : : }
33 : :
34 : : static void
35 : 0 : mlx4_glue_ack_async_event(struct ibv_async_event *event)
36 : : {
37 : 0 : ibv_ack_async_event(event);
38 : 0 : }
39 : :
40 : : static struct ibv_pd *
41 : 0 : mlx4_glue_alloc_pd(struct ibv_context *context)
42 : : {
43 : 0 : return ibv_alloc_pd(context);
44 : : }
45 : :
46 : : static int
47 : 0 : mlx4_glue_dealloc_pd(struct ibv_pd *pd)
48 : : {
49 : 0 : return ibv_dealloc_pd(pd);
50 : : }
51 : :
52 : : static struct ibv_device **
53 : 0 : mlx4_glue_get_device_list(int *num_devices)
54 : : {
55 : 0 : return ibv_get_device_list(num_devices);
56 : : }
57 : :
58 : : static void
59 : 0 : mlx4_glue_free_device_list(struct ibv_device **list)
60 : : {
61 : 0 : ibv_free_device_list(list);
62 : 0 : }
63 : :
64 : : static struct ibv_context *
65 : 0 : mlx4_glue_open_device(struct ibv_device *device)
66 : : {
67 : 0 : return ibv_open_device(device);
68 : : }
69 : :
70 : : static int
71 : 0 : mlx4_glue_close_device(struct ibv_context *context)
72 : : {
73 : 0 : return ibv_close_device(context);
74 : : }
75 : :
76 : : static const char *
77 : 0 : mlx4_glue_get_device_name(struct ibv_device *device)
78 : : {
79 : 0 : return ibv_get_device_name(device);
80 : : }
81 : :
82 : : static int
83 : 0 : mlx4_glue_query_device(struct ibv_context *context,
84 : : struct ibv_device_attr *device_attr)
85 : : {
86 : 0 : return ibv_query_device(context, device_attr);
87 : : }
88 : :
89 : : static int
90 : 0 : 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)
93 : : {
94 : 0 : return ibv_query_device_ex(context, input, attr);
95 : : }
96 : :
97 : : static int
98 : 0 : mlx4_glue_query_port(struct ibv_context *context, uint8_t port_num,
99 : : struct ibv_port_attr *port_attr)
100 : : {
101 : 0 : return ibv_query_port(context, port_num, port_attr);
102 : : }
103 : :
104 : : static const char *
105 : 0 : mlx4_glue_port_state_str(enum ibv_port_state port_state)
106 : : {
107 : 0 : return ibv_port_state_str(port_state);
108 : : }
109 : :
110 : : static struct ibv_comp_channel *
111 : 0 : mlx4_glue_create_comp_channel(struct ibv_context *context)
112 : : {
113 : 0 : return ibv_create_comp_channel(context);
114 : : }
115 : :
116 : : static int
117 : 0 : mlx4_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
118 : : {
119 : 0 : return ibv_destroy_comp_channel(channel);
120 : : }
121 : :
122 : : static struct ibv_cq *
123 : 0 : mlx4_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
124 : : struct ibv_comp_channel *channel, int comp_vector)
125 : : {
126 : 0 : return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
127 : : }
128 : :
129 : : static int
130 : 0 : mlx4_glue_destroy_cq(struct ibv_cq *cq)
131 : : {
132 : 0 : return ibv_destroy_cq(cq);
133 : : }
134 : :
135 : : static int
136 : 0 : mlx4_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
137 : : void **cq_context)
138 : : {
139 : 0 : return ibv_get_cq_event(channel, cq, cq_context);
140 : : }
141 : :
142 : : static void
143 : 0 : mlx4_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
144 : : {
145 : 0 : ibv_ack_cq_events(cq, nevents);
146 : 0 : }
147 : :
148 : : static struct ibv_flow *
149 : 0 : mlx4_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
150 : : {
151 : 0 : return ibv_create_flow(qp, flow);
152 : : }
153 : :
154 : : static int
155 [ # # ]: 0 : mlx4_glue_destroy_flow(struct ibv_flow *flow_id)
156 : : {
157 : 0 : return ibv_destroy_flow(flow_id);
158 : : }
159 : :
160 : : static struct ibv_qp *
161 : 0 : mlx4_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
162 : : {
163 : 0 : return ibv_create_qp(pd, qp_init_attr);
164 : : }
165 : :
166 : : static struct ibv_qp *
167 : 0 : mlx4_glue_create_qp_ex(struct ibv_context *context,
168 : : struct ibv_qp_init_attr_ex *qp_init_attr_ex)
169 : : {
170 : 0 : return ibv_create_qp_ex(context, qp_init_attr_ex);
171 : : }
172 : :
173 : : static int
174 : 0 : mlx4_glue_destroy_qp(struct ibv_qp *qp)
175 : : {
176 : 0 : return ibv_destroy_qp(qp);
177 : : }
178 : :
179 : : static int
180 : 0 : mlx4_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
181 : : {
182 : 0 : return ibv_modify_qp(qp, attr, attr_mask);
183 : : }
184 : :
185 : : static struct ibv_mr *
186 : 0 : mlx4_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
187 : : {
188 [ # # ]: 0 : return ibv_reg_mr(pd, addr, length, access);
189 : : }
190 : :
191 : : static int
192 : 0 : mlx4_glue_dereg_mr(struct ibv_mr *mr)
193 : : {
194 : 0 : return ibv_dereg_mr(mr);
195 : : }
196 : :
197 : : static struct ibv_rwq_ind_table *
198 : 0 : mlx4_glue_create_rwq_ind_table(struct ibv_context *context,
199 : : struct ibv_rwq_ind_table_init_attr *init_attr)
200 : : {
201 : 0 : return ibv_create_rwq_ind_table(context, init_attr);
202 : : }
203 : :
204 : : static int
205 [ # # ]: 0 : mlx4_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
206 : : {
207 : 0 : return ibv_destroy_rwq_ind_table(rwq_ind_table);
208 : : }
209 : :
210 : : static struct ibv_wq *
211 : 0 : mlx4_glue_create_wq(struct ibv_context *context,
212 : : struct ibv_wq_init_attr *wq_init_attr)
213 : : {
214 : 0 : return ibv_create_wq(context, wq_init_attr);
215 : : }
216 : :
217 : : static int
218 [ # # ]: 0 : mlx4_glue_destroy_wq(struct ibv_wq *wq)
219 : : {
220 : 0 : return ibv_destroy_wq(wq);
221 : : }
222 : : static int
223 [ # # ]: 0 : mlx4_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
224 : : {
225 : 0 : return ibv_modify_wq(wq, wq_attr);
226 : : }
227 : :
228 : : static int
229 : 0 : mlx4_glue_dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type)
230 : : {
231 : 0 : return mlx4dv_init_obj(obj, obj_type);
232 : : }
233 : :
234 : : static int
235 : 0 : mlx4_glue_dv_set_context_attr(struct ibv_context *context,
236 : : enum mlx4dv_set_ctx_attr_type attr_type,
237 : : void *attr)
238 : : {
239 : 0 : return mlx4dv_set_context_attr(context, attr_type, attr);
240 : : }
241 : :
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,
279 : : };
|