6172e0d2ac6d12c0a79c25d37b75230c0edae485
[dpdk.git] / drivers / net / mlx5 / mlx5_glue.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018 6WIND S.A.
3  * Copyright 2018 Mellanox Technologies, Ltd
4  */
5
6 #include <errno.h>
7 #include <stdalign.h>
8 #include <stddef.h>
9 #include <stdint.h>
10 #include <stdlib.h>
11
12 /*
13  * Not needed by this file; included to work around the lack of off_t
14  * definition for mlx5dv.h with unpatched rdma-core versions.
15  */
16 #include <sys/types.h>
17
18 /* Verbs headers do not support -pedantic. */
19 #ifdef PEDANTIC
20 #pragma GCC diagnostic ignored "-Wpedantic"
21 #endif
22 #include <infiniband/mlx5dv.h>
23 #include <infiniband/verbs.h>
24 #ifdef PEDANTIC
25 #pragma GCC diagnostic error "-Wpedantic"
26 #endif
27
28 #include <rte_config.h>
29
30 #include "mlx5_autoconf.h"
31 #include "mlx5_glue.h"
32
33 static int
34 mlx5_glue_fork_init(void)
35 {
36         return ibv_fork_init();
37 }
38
39 static struct ibv_pd *
40 mlx5_glue_alloc_pd(struct ibv_context *context)
41 {
42         return ibv_alloc_pd(context);
43 }
44
45 static int
46 mlx5_glue_dealloc_pd(struct ibv_pd *pd)
47 {
48         return ibv_dealloc_pd(pd);
49 }
50
51 static struct ibv_device **
52 mlx5_glue_get_device_list(int *num_devices)
53 {
54         return ibv_get_device_list(num_devices);
55 }
56
57 static void
58 mlx5_glue_free_device_list(struct ibv_device **list)
59 {
60         ibv_free_device_list(list);
61 }
62
63 static struct ibv_context *
64 mlx5_glue_open_device(struct ibv_device *device)
65 {
66         return ibv_open_device(device);
67 }
68
69 static int
70 mlx5_glue_close_device(struct ibv_context *context)
71 {
72         return ibv_close_device(context);
73 }
74
75 static int
76 mlx5_glue_query_device(struct ibv_context *context,
77                        struct ibv_device_attr *device_attr)
78 {
79         return ibv_query_device(context, device_attr);
80 }
81
82 static int
83 mlx5_glue_query_device_ex(struct ibv_context *context,
84                           const struct ibv_query_device_ex_input *input,
85                           struct ibv_device_attr_ex *attr)
86 {
87         return ibv_query_device_ex(context, input, attr);
88 }
89
90 static int
91 mlx5_glue_query_port(struct ibv_context *context, uint8_t port_num,
92                      struct ibv_port_attr *port_attr)
93 {
94         return ibv_query_port(context, port_num, port_attr);
95 }
96
97 static struct ibv_comp_channel *
98 mlx5_glue_create_comp_channel(struct ibv_context *context)
99 {
100         return ibv_create_comp_channel(context);
101 }
102
103 static int
104 mlx5_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
105 {
106         return ibv_destroy_comp_channel(channel);
107 }
108
109 static struct ibv_cq *
110 mlx5_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
111                     struct ibv_comp_channel *channel, int comp_vector)
112 {
113         return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
114 }
115
116 static int
117 mlx5_glue_destroy_cq(struct ibv_cq *cq)
118 {
119         return ibv_destroy_cq(cq);
120 }
121
122 static int
123 mlx5_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
124                        void **cq_context)
125 {
126         return ibv_get_cq_event(channel, cq, cq_context);
127 }
128
129 static void
130 mlx5_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
131 {
132         ibv_ack_cq_events(cq, nevents);
133 }
134
135 static struct ibv_rwq_ind_table *
136 mlx5_glue_create_rwq_ind_table(struct ibv_context *context,
137                                struct ibv_rwq_ind_table_init_attr *init_attr)
138 {
139         return ibv_create_rwq_ind_table(context, init_attr);
140 }
141
142 static int
143 mlx5_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
144 {
145         return ibv_destroy_rwq_ind_table(rwq_ind_table);
146 }
147
148 static struct ibv_wq *
149 mlx5_glue_create_wq(struct ibv_context *context,
150                     struct ibv_wq_init_attr *wq_init_attr)
151 {
152         return ibv_create_wq(context, wq_init_attr);
153 }
154
155 static int
156 mlx5_glue_destroy_wq(struct ibv_wq *wq)
157 {
158         return ibv_destroy_wq(wq);
159 }
160 static int
161 mlx5_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
162 {
163         return ibv_modify_wq(wq, wq_attr);
164 }
165
166 static struct ibv_flow *
167 mlx5_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
168 {
169         return ibv_create_flow(qp, flow);
170 }
171
172 static int
173 mlx5_glue_destroy_flow(struct ibv_flow *flow_id)
174 {
175         return ibv_destroy_flow(flow_id);
176 }
177
178 static int
179 mlx5_glue_destroy_flow_action(void *action)
180 {
181 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
182 #ifdef HAVE_MLX5DV_DR
183         return mlx5dv_dr_action_destroy(action);
184 #else
185         struct mlx5dv_flow_action_attr *attr = action;
186         int res = 0;
187         switch (attr->type) {
188         case MLX5DV_FLOW_ACTION_TAG:
189                 break;
190         default:
191                 res = ibv_destroy_flow_action(attr->action);
192                 break;
193         }
194         free(action);
195         return res;
196 #endif
197 #else
198         (void)action;
199         return ENOTSUP;
200 #endif
201 }
202
203 static struct ibv_qp *
204 mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
205 {
206         return ibv_create_qp(pd, qp_init_attr);
207 }
208
209 static struct ibv_qp *
210 mlx5_glue_create_qp_ex(struct ibv_context *context,
211                        struct ibv_qp_init_attr_ex *qp_init_attr_ex)
212 {
213         return ibv_create_qp_ex(context, qp_init_attr_ex);
214 }
215
216 static int
217 mlx5_glue_destroy_qp(struct ibv_qp *qp)
218 {
219         return ibv_destroy_qp(qp);
220 }
221
222 static int
223 mlx5_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
224 {
225         return ibv_modify_qp(qp, attr, attr_mask);
226 }
227
228 static struct ibv_mr *
229 mlx5_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
230 {
231         return ibv_reg_mr(pd, addr, length, access);
232 }
233
234 static int
235 mlx5_glue_dereg_mr(struct ibv_mr *mr)
236 {
237         return ibv_dereg_mr(mr);
238 }
239
240 static struct ibv_counter_set *
241 mlx5_glue_create_counter_set(struct ibv_context *context,
242                              struct ibv_counter_set_init_attr *init_attr)
243 {
244 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
245         (void)context;
246         (void)init_attr;
247         return NULL;
248 #else
249         return ibv_create_counter_set(context, init_attr);
250 #endif
251 }
252
253 static int
254 mlx5_glue_destroy_counter_set(struct ibv_counter_set *cs)
255 {
256 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
257         (void)cs;
258         return ENOTSUP;
259 #else
260         return ibv_destroy_counter_set(cs);
261 #endif
262 }
263
264 static int
265 mlx5_glue_describe_counter_set(struct ibv_context *context,
266                                uint16_t counter_set_id,
267                                struct ibv_counter_set_description *cs_desc)
268 {
269 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
270         (void)context;
271         (void)counter_set_id;
272         (void)cs_desc;
273         return ENOTSUP;
274 #else
275         return ibv_describe_counter_set(context, counter_set_id, cs_desc);
276 #endif
277 }
278
279 static int
280 mlx5_glue_query_counter_set(struct ibv_query_counter_set_attr *query_attr,
281                             struct ibv_counter_set_data *cs_data)
282 {
283 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
284         (void)query_attr;
285         (void)cs_data;
286         return ENOTSUP;
287 #else
288         return ibv_query_counter_set(query_attr, cs_data);
289 #endif
290 }
291
292 static struct ibv_counters *
293 mlx5_glue_create_counters(struct ibv_context *context,
294                           struct ibv_counters_init_attr *init_attr)
295 {
296 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
297         (void)context;
298         (void)init_attr;
299         return NULL;
300 #else
301         return ibv_create_counters(context, init_attr);
302 #endif
303 }
304
305 static int
306 mlx5_glue_destroy_counters(struct ibv_counters *counters)
307 {
308 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
309         (void)counters;
310         return ENOTSUP;
311 #else
312         return ibv_destroy_counters(counters);
313 #endif
314 }
315
316 static int
317 mlx5_glue_attach_counters(struct ibv_counters *counters,
318                           struct ibv_counter_attach_attr *attr,
319                           struct ibv_flow *flow)
320 {
321 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
322         (void)counters;
323         (void)attr;
324         (void)flow;
325         return ENOTSUP;
326 #else
327         return ibv_attach_counters_point_flow(counters, attr, flow);
328 #endif
329 }
330
331 static int
332 mlx5_glue_query_counters(struct ibv_counters *counters,
333                          uint64_t *counters_value,
334                          uint32_t ncounters,
335                          uint32_t flags)
336 {
337 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
338         (void)counters;
339         (void)counters_value;
340         (void)ncounters;
341         (void)flags;
342         return ENOTSUP;
343 #else
344         return ibv_read_counters(counters, counters_value, ncounters, flags);
345 #endif
346 }
347
348 static void
349 mlx5_glue_ack_async_event(struct ibv_async_event *event)
350 {
351         ibv_ack_async_event(event);
352 }
353
354 static int
355 mlx5_glue_get_async_event(struct ibv_context *context,
356                           struct ibv_async_event *event)
357 {
358         return ibv_get_async_event(context, event);
359 }
360
361 static const char *
362 mlx5_glue_port_state_str(enum ibv_port_state port_state)
363 {
364         return ibv_port_state_str(port_state);
365 }
366
367 static struct ibv_cq *
368 mlx5_glue_cq_ex_to_cq(struct ibv_cq_ex *cq)
369 {
370         return ibv_cq_ex_to_cq(cq);
371 }
372
373 static void *
374 mlx5_glue_dr_create_flow_action_dest_flow_tbl(void *tbl)
375 {
376 #ifdef HAVE_MLX5DV_DR
377         return mlx5dv_dr_action_create_dest_table(tbl);
378 #else
379         (void)tbl;
380         return NULL;
381 #endif
382 }
383
384 static void *
385 mlx5_glue_dr_create_flow_action_dest_vport(void *domain, uint32_t vport)
386 {
387 #ifdef HAVE_MLX5DV_DR_ESWITCH
388         return mlx5dv_dr_action_create_dest_vport(domain, vport);
389 #else
390         (void)domain;
391         (void)vport;
392         return NULL;
393 #endif
394 }
395
396 static void *
397 mlx5_glue_dr_create_flow_action_drop(void)
398 {
399 #ifdef HAVE_MLX5DV_DR_ESWITCH
400         return mlx5dv_dr_action_create_drop();
401 #else
402         return NULL;
403 #endif
404 }
405
406 static void *
407 mlx5_glue_dr_create_flow_tbl(void *domain, uint32_t level)
408 {
409 #ifdef HAVE_MLX5DV_DR
410         return mlx5dv_dr_table_create(domain, level);
411 #else
412         (void)domain;
413         (void)level;
414         return NULL;
415 #endif
416 }
417
418 static int
419 mlx5_glue_dr_destroy_flow_tbl(void *tbl)
420 {
421 #ifdef HAVE_MLX5DV_DR
422         return mlx5dv_dr_table_destroy(tbl);
423 #else
424         (void)tbl;
425         return 0;
426 #endif
427 }
428
429 static void *
430 mlx5_glue_dr_create_domain(struct ibv_context *ctx,
431                            enum  mlx5dv_dr_domain_type domain)
432 {
433 #ifdef HAVE_MLX5DV_DR
434         return mlx5dv_dr_domain_create(ctx, domain);
435 #else
436         (void)ctx;
437         (void)domain;
438         return NULL;
439 #endif
440 }
441
442 static int
443 mlx5_glue_dr_destroy_domain(void *domain)
444 {
445 #ifdef HAVE_MLX5DV_DR
446         return mlx5dv_dr_domain_destroy(domain);
447 #else
448         (void)domain;
449         return 0;
450 #endif
451 }
452
453 static struct ibv_cq_ex *
454 mlx5_glue_dv_create_cq(struct ibv_context *context,
455                        struct ibv_cq_init_attr_ex *cq_attr,
456                        struct mlx5dv_cq_init_attr *mlx5_cq_attr)
457 {
458         return mlx5dv_create_cq(context, cq_attr, mlx5_cq_attr);
459 }
460
461 static struct ibv_wq *
462 mlx5_glue_dv_create_wq(struct ibv_context *context,
463                        struct ibv_wq_init_attr *wq_attr,
464                        struct mlx5dv_wq_init_attr *mlx5_wq_attr)
465 {
466 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
467         (void)context;
468         (void)wq_attr;
469         (void)mlx5_wq_attr;
470         return NULL;
471 #else
472         return mlx5dv_create_wq(context, wq_attr, mlx5_wq_attr);
473 #endif
474 }
475
476 static int
477 mlx5_glue_dv_query_device(struct ibv_context *ctx,
478                           struct mlx5dv_context *attrs_out)
479 {
480         return mlx5dv_query_device(ctx, attrs_out);
481 }
482
483 static int
484 mlx5_glue_dv_set_context_attr(struct ibv_context *ibv_ctx,
485                               enum mlx5dv_set_ctx_attr_type type, void *attr)
486 {
487         return mlx5dv_set_context_attr(ibv_ctx, type, attr);
488 }
489
490 static int
491 mlx5_glue_dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type)
492 {
493         return mlx5dv_init_obj(obj, obj_type);
494 }
495
496 static struct ibv_qp *
497 mlx5_glue_dv_create_qp(struct ibv_context *context,
498                        struct ibv_qp_init_attr_ex *qp_init_attr_ex,
499                        struct mlx5dv_qp_init_attr *dv_qp_init_attr)
500 {
501 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
502         return mlx5dv_create_qp(context, qp_init_attr_ex, dv_qp_init_attr);
503 #else
504         (void)context;
505         (void)qp_init_attr_ex;
506         (void)dv_qp_init_attr;
507         return NULL;
508 #endif
509 }
510
511 static void *
512 mlx5_glue_dv_create_flow_matcher(struct ibv_context *context,
513                                  struct mlx5dv_flow_matcher_attr *matcher_attr,
514                                  void *tbl)
515 {
516 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
517 #ifdef HAVE_MLX5DV_DR
518         (void)context;
519         return mlx5dv_dr_matcher_create(tbl, matcher_attr->priority,
520                                         matcher_attr->match_criteria_enable,
521                                         matcher_attr->match_mask);
522 #else
523         (void)tbl;
524         return mlx5dv_create_flow_matcher(context, matcher_attr);
525 #endif
526 #else
527         (void)context;
528         (void)matcher_attr;
529         (void)tbl;
530         return NULL;
531 #endif
532 }
533
534 static void *
535 mlx5_glue_dv_create_flow(void *matcher,
536                          void *match_value,
537                          size_t num_actions,
538                          void *actions[])
539 {
540 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
541 #ifdef HAVE_MLX5DV_DR
542         return mlx5dv_dr_rule_create(matcher, match_value, num_actions,
543                                      (struct mlx5dv_dr_action **)actions);
544 #else
545         struct mlx5dv_flow_action_attr actions_attr[8];
546
547         if (num_actions > 8)
548                 return NULL;
549         for (size_t i = 0; i < num_actions; i++)
550                 actions_attr[i] =
551                         *((struct mlx5dv_flow_action_attr *)(actions[i]));
552         return mlx5dv_create_flow(matcher, match_value,
553                                   num_actions, actions_attr);
554 #endif
555 #else
556         (void)matcher;
557         (void)match_value;
558         (void)num_actions;
559         (void)actions;
560         return NULL;
561 #endif
562 }
563
564 static void *
565 mlx5_glue_dv_create_flow_action_counter(void *counter_obj, uint32_t offset)
566 {
567 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
568 #ifdef HAVE_MLX5DV_DR
569         return mlx5dv_dr_action_create_flow_counter(counter_obj, offset);
570 #else
571         struct mlx5dv_flow_action_attr *action;
572
573         (void)offset;
574         action = malloc(sizeof(*action));
575         if (!action)
576                 return NULL;
577         action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
578         action->obj = counter_obj;
579         return action;
580 #endif
581 #else
582         (void)counter_obj;
583         (void)offset;
584         return NULL;
585 #endif
586 }
587
588 static void *
589 mlx5_glue_dv_create_flow_action_dest_ibv_qp(void *qp)
590 {
591 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
592 #ifdef HAVE_MLX5DV_DR
593         return mlx5dv_dr_action_create_dest_ibv_qp(qp);
594 #else
595         struct mlx5dv_flow_action_attr *action;
596
597         action = malloc(sizeof(*action));
598         if (!action)
599                 return NULL;
600         action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
601         action->obj = qp;
602         return action;
603 #endif
604 #else
605         (void)qp;
606         return NULL;
607 #endif
608 }
609
610 static void *
611 mlx5_glue_dv_create_flow_action_modify_header
612                                         (struct ibv_context *ctx,
613                                          enum mlx5dv_flow_table_type ft_type,
614                                          void *domain, uint64_t flags,
615                                          size_t actions_sz,
616                                          uint64_t actions[])
617 {
618 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
619 #ifdef HAVE_MLX5DV_DR
620         (void)ctx;
621         (void)ft_type;
622         return mlx5dv_dr_action_create_modify_header(domain, flags, actions_sz,
623                                                      (__be64 *)actions);
624 #else
625         struct mlx5dv_flow_action_attr *action;
626
627         (void)domain;
628         (void)flags;
629         action = malloc(sizeof(*action));
630         if (!action)
631                 return NULL;
632         action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
633         action->action = mlx5dv_create_flow_action_modify_header
634                 (ctx, actions_sz, actions, ft_type);
635         return action;
636 #endif
637 #else
638         (void)ctx;
639         (void)ft_type;
640         (void)domain;
641         (void)flags;
642         (void)actions_sz;
643         (void)actions;
644         return NULL;
645 #endif
646 }
647
648 static void *
649 mlx5_glue_dv_create_flow_action_packet_reformat
650                 (struct ibv_context *ctx,
651                  enum mlx5dv_flow_action_packet_reformat_type reformat_type,
652                  enum mlx5dv_flow_table_type ft_type,
653                  struct mlx5dv_dr_domain *domain,
654                  uint32_t flags, size_t data_sz, void *data)
655 {
656 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
657 #ifdef HAVE_MLX5DV_DR
658         (void)ctx;
659         (void)ft_type;
660         return mlx5dv_dr_action_create_packet_reformat(domain, flags,
661                                                        reformat_type, data_sz,
662                                                        data);
663 #else
664         (void)domain;
665         (void)flags;
666         struct mlx5dv_flow_action_attr *action;
667
668         action = malloc(sizeof(*action));
669         if (!action)
670                 return NULL;
671         action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
672         action->action = mlx5dv_create_flow_action_packet_reformat
673                 (ctx, data_sz, data, reformat_type, ft_type);
674         return action;
675 #endif
676 #else
677         (void)ctx;
678         (void)reformat_type;
679         (void)ft_type;
680         (void)domain;
681         (void)flags;
682         (void)data_sz;
683         (void)data;
684         return NULL;
685 #endif
686 }
687
688 static void *
689 mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
690 {
691 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
692 #ifdef HAVE_MLX5DV_DR
693         return mlx5dv_dr_action_create_tag(tag);
694 #else
695         struct mlx5dv_flow_action_attr *action;
696         action = malloc(sizeof(*action));
697         if (!action)
698                 return NULL;
699         action->type = MLX5DV_FLOW_ACTION_TAG;
700         action->tag_value = tag;
701         return action;
702 #endif
703 #endif
704         (void)tag;
705         return NULL;
706 }
707
708 static int
709 mlx5_glue_dv_destroy_flow(void *flow_id)
710 {
711 #ifdef HAVE_MLX5DV_DR
712         return mlx5dv_dr_rule_destroy(flow_id);
713 #else
714         return ibv_destroy_flow(flow_id);
715 #endif
716 }
717
718 static int
719 mlx5_glue_dv_destroy_flow_matcher(void *matcher)
720 {
721 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
722 #ifdef HAVE_MLX5DV_DR
723         return mlx5dv_dr_matcher_destroy(matcher);
724 #else
725         return mlx5dv_destroy_flow_matcher(matcher);
726 #endif
727 #else
728         (void)matcher;
729         return 0;
730 #endif
731 }
732
733 static struct ibv_context *
734 mlx5_glue_dv_open_device(struct ibv_device *device)
735 {
736 #ifdef HAVE_IBV_DEVX_OBJ
737         return mlx5dv_open_device(device,
738                                   &(struct mlx5dv_context_attr){
739                                         .flags = MLX5DV_CONTEXT_FLAGS_DEVX,
740                                   });
741 #else
742         (void)device;
743         return NULL;
744 #endif
745 }
746
747 static struct mlx5dv_devx_obj *
748 mlx5_glue_devx_obj_create(struct ibv_context *ctx,
749                           const void *in, size_t inlen,
750                           void *out, size_t outlen)
751 {
752 #ifdef HAVE_IBV_DEVX_OBJ
753         return mlx5dv_devx_obj_create(ctx, in, inlen, out, outlen);
754 #else
755         (void)ctx;
756         (void)in;
757         (void)inlen;
758         (void)out;
759         (void)outlen;
760         return NULL;
761 #endif
762 }
763
764 static int
765 mlx5_glue_devx_obj_destroy(struct mlx5dv_devx_obj *obj)
766 {
767 #ifdef HAVE_IBV_DEVX_OBJ
768         return mlx5dv_devx_obj_destroy(obj);
769 #else
770         (void)obj;
771         return -ENOTSUP;
772 #endif
773 }
774
775 static int
776 mlx5_glue_devx_obj_query(struct mlx5dv_devx_obj *obj,
777                          const void *in, size_t inlen,
778                          void *out, size_t outlen)
779 {
780 #ifdef HAVE_IBV_DEVX_OBJ
781         return mlx5dv_devx_obj_query(obj, in, inlen, out, outlen);
782 #else
783         (void)obj;
784         (void)in;
785         (void)inlen;
786         (void)out;
787         (void)outlen;
788         return -ENOTSUP;
789 #endif
790 }
791
792 static int
793 mlx5_glue_devx_obj_modify(struct mlx5dv_devx_obj *obj,
794                           const void *in, size_t inlen,
795                           void *out, size_t outlen)
796 {
797 #ifdef HAVE_IBV_DEVX_OBJ
798         return mlx5dv_devx_obj_modify(obj, in, inlen, out, outlen);
799 #else
800         (void)obj;
801         (void)in;
802         (void)inlen;
803         (void)out;
804         (void)outlen;
805         return -ENOTSUP;
806 #endif
807 }
808
809 static int
810 mlx5_glue_devx_general_cmd(struct ibv_context *ctx,
811                            const void *in, size_t inlen,
812                            void *out, size_t outlen)
813 {
814 #ifdef HAVE_IBV_DEVX_OBJ
815         return mlx5dv_devx_general_cmd(ctx, in, inlen, out, outlen);
816 #else
817         (void)ctx;
818         (void)in;
819         (void)inlen;
820         (void)out;
821         (void)outlen;
822         return -ENOTSUP;
823 #endif
824 }
825
826 alignas(RTE_CACHE_LINE_SIZE)
827 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
828         .version = MLX5_GLUE_VERSION,
829         .fork_init = mlx5_glue_fork_init,
830         .alloc_pd = mlx5_glue_alloc_pd,
831         .dealloc_pd = mlx5_glue_dealloc_pd,
832         .get_device_list = mlx5_glue_get_device_list,
833         .free_device_list = mlx5_glue_free_device_list,
834         .open_device = mlx5_glue_open_device,
835         .close_device = mlx5_glue_close_device,
836         .query_device = mlx5_glue_query_device,
837         .query_device_ex = mlx5_glue_query_device_ex,
838         .query_port = mlx5_glue_query_port,
839         .create_comp_channel = mlx5_glue_create_comp_channel,
840         .destroy_comp_channel = mlx5_glue_destroy_comp_channel,
841         .create_cq = mlx5_glue_create_cq,
842         .destroy_cq = mlx5_glue_destroy_cq,
843         .get_cq_event = mlx5_glue_get_cq_event,
844         .ack_cq_events = mlx5_glue_ack_cq_events,
845         .create_rwq_ind_table = mlx5_glue_create_rwq_ind_table,
846         .destroy_rwq_ind_table = mlx5_glue_destroy_rwq_ind_table,
847         .create_wq = mlx5_glue_create_wq,
848         .destroy_wq = mlx5_glue_destroy_wq,
849         .modify_wq = mlx5_glue_modify_wq,
850         .create_flow = mlx5_glue_create_flow,
851         .destroy_flow = mlx5_glue_destroy_flow,
852         .destroy_flow_action = mlx5_glue_destroy_flow_action,
853         .create_qp = mlx5_glue_create_qp,
854         .create_qp_ex = mlx5_glue_create_qp_ex,
855         .destroy_qp = mlx5_glue_destroy_qp,
856         .modify_qp = mlx5_glue_modify_qp,
857         .reg_mr = mlx5_glue_reg_mr,
858         .dereg_mr = mlx5_glue_dereg_mr,
859         .create_counter_set = mlx5_glue_create_counter_set,
860         .destroy_counter_set = mlx5_glue_destroy_counter_set,
861         .describe_counter_set = mlx5_glue_describe_counter_set,
862         .query_counter_set = mlx5_glue_query_counter_set,
863         .create_counters = mlx5_glue_create_counters,
864         .destroy_counters = mlx5_glue_destroy_counters,
865         .attach_counters = mlx5_glue_attach_counters,
866         .query_counters = mlx5_glue_query_counters,
867         .ack_async_event = mlx5_glue_ack_async_event,
868         .get_async_event = mlx5_glue_get_async_event,
869         .port_state_str = mlx5_glue_port_state_str,
870         .cq_ex_to_cq = mlx5_glue_cq_ex_to_cq,
871         .dr_create_flow_action_dest_flow_tbl =
872                 mlx5_glue_dr_create_flow_action_dest_flow_tbl,
873         .dr_create_flow_action_dest_vport =
874                 mlx5_glue_dr_create_flow_action_dest_vport,
875         .dr_create_flow_action_drop =
876                 mlx5_glue_dr_create_flow_action_drop,
877         .dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
878         .dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
879         .dr_create_domain = mlx5_glue_dr_create_domain,
880         .dr_destroy_domain = mlx5_glue_dr_destroy_domain,
881         .dv_create_cq = mlx5_glue_dv_create_cq,
882         .dv_create_wq = mlx5_glue_dv_create_wq,
883         .dv_query_device = mlx5_glue_dv_query_device,
884         .dv_set_context_attr = mlx5_glue_dv_set_context_attr,
885         .dv_init_obj = mlx5_glue_dv_init_obj,
886         .dv_create_qp = mlx5_glue_dv_create_qp,
887         .dv_create_flow_matcher = mlx5_glue_dv_create_flow_matcher,
888         .dv_create_flow = mlx5_glue_dv_create_flow,
889         .dv_create_flow_action_counter =
890                 mlx5_glue_dv_create_flow_action_counter,
891         .dv_create_flow_action_dest_ibv_qp =
892                 mlx5_glue_dv_create_flow_action_dest_ibv_qp,
893         .dv_create_flow_action_modify_header =
894                 mlx5_glue_dv_create_flow_action_modify_header,
895         .dv_create_flow_action_packet_reformat =
896                 mlx5_glue_dv_create_flow_action_packet_reformat,
897         .dv_create_flow_action_tag =  mlx5_glue_dv_create_flow_action_tag,
898         .dv_destroy_flow = mlx5_glue_dv_destroy_flow,
899         .dv_destroy_flow_matcher = mlx5_glue_dv_destroy_flow_matcher,
900         .dv_open_device = mlx5_glue_dv_open_device,
901         .devx_obj_create = mlx5_glue_devx_obj_create,
902         .devx_obj_destroy = mlx5_glue_devx_obj_destroy,
903         .devx_obj_query = mlx5_glue_devx_obj_query,
904         .devx_obj_modify = mlx5_glue_devx_obj_modify,
905         .devx_general_cmd = mlx5_glue_devx_general_cmd,
906 };