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