net/mlx5: add E-Switch port id action to Direct Verbs
[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_destroy_action(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_create_action_dest_flow_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 *ns, uint32_t vport)
386 {
387 #ifdef HAVE_MLX5DV_DR_ESWITCH
388         return mlx5dv_dr_create_action_dest_vport(ns, vport);
389 #else
390         (void)ns;
391         (void)vport;
392         return NULL;
393 #endif
394 }
395
396 static void *
397 mlx5_glue_dr_create_flow_tbl(void *ns, uint32_t level)
398 {
399 #ifdef HAVE_MLX5DV_DR
400         return mlx5dv_dr_create_ft(ns, level);
401 #else
402         (void)ns;
403         (void)level;
404         return NULL;
405 #endif
406 }
407
408 static int
409 mlx5_glue_dr_destroy_flow_tbl(void *tbl)
410 {
411 #ifdef HAVE_MLX5DV_DR
412         return mlx5dv_dr_destroy_ft(tbl);
413 #else
414         (void)tbl;
415         return 0;
416 #endif
417 }
418
419 static void *
420 mlx5_glue_dr_create_ns(struct ibv_context *ctx,
421                        enum  mlx5dv_dr_ns_domain domain)
422 {
423 #ifdef HAVE_MLX5DV_DR
424         return mlx5dv_dr_create_ns(ctx, domain);
425 #else
426         (void)ctx;
427         (void)domain;
428         return NULL;
429 #endif
430 }
431
432 static int
433 mlx5_glue_dr_destroy_ns(void *ns)
434 {
435 #ifdef HAVE_MLX5DV_DR
436         return mlx5dv_dr_destroy_ns(ns);
437 #else
438         (void)ns;
439         return 0;
440 #endif
441 }
442
443 static struct ibv_cq_ex *
444 mlx5_glue_dv_create_cq(struct ibv_context *context,
445                        struct ibv_cq_init_attr_ex *cq_attr,
446                        struct mlx5dv_cq_init_attr *mlx5_cq_attr)
447 {
448         return mlx5dv_create_cq(context, cq_attr, mlx5_cq_attr);
449 }
450
451 static struct ibv_wq *
452 mlx5_glue_dv_create_wq(struct ibv_context *context,
453                        struct ibv_wq_init_attr *wq_attr,
454                        struct mlx5dv_wq_init_attr *mlx5_wq_attr)
455 {
456 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
457         (void)context;
458         (void)wq_attr;
459         (void)mlx5_wq_attr;
460         return NULL;
461 #else
462         return mlx5dv_create_wq(context, wq_attr, mlx5_wq_attr);
463 #endif
464 }
465
466 static int
467 mlx5_glue_dv_query_device(struct ibv_context *ctx,
468                           struct mlx5dv_context *attrs_out)
469 {
470         return mlx5dv_query_device(ctx, attrs_out);
471 }
472
473 static int
474 mlx5_glue_dv_set_context_attr(struct ibv_context *ibv_ctx,
475                               enum mlx5dv_set_ctx_attr_type type, void *attr)
476 {
477         return mlx5dv_set_context_attr(ibv_ctx, type, attr);
478 }
479
480 static int
481 mlx5_glue_dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type)
482 {
483         return mlx5dv_init_obj(obj, obj_type);
484 }
485
486 static struct ibv_qp *
487 mlx5_glue_dv_create_qp(struct ibv_context *context,
488                        struct ibv_qp_init_attr_ex *qp_init_attr_ex,
489                        struct mlx5dv_qp_init_attr *dv_qp_init_attr)
490 {
491 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
492         return mlx5dv_create_qp(context, qp_init_attr_ex, dv_qp_init_attr);
493 #else
494         (void)context;
495         (void)qp_init_attr_ex;
496         (void)dv_qp_init_attr;
497         return NULL;
498 #endif
499 }
500
501 static void *
502 mlx5_glue_dv_create_flow_matcher(struct ibv_context *context,
503                                  struct mlx5dv_flow_matcher_attr *matcher_attr,
504                                  void *tbl)
505 {
506 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
507 #ifdef HAVE_MLX5DV_DR
508         (void)context;
509         return mlx5dv_dr_create_matcher(tbl, matcher_attr->priority,
510                                        matcher_attr->match_criteria_enable,
511                                        matcher_attr->match_mask);
512 #else
513         (void)tbl;
514         return mlx5dv_create_flow_matcher(context, matcher_attr);
515 #endif
516 #else
517         (void)context;
518         (void)matcher_attr;
519         (void)tbl;
520         return NULL;
521 #endif
522 }
523
524 static void *
525 mlx5_glue_dv_create_flow(void *matcher,
526                          void *match_value,
527                          size_t num_actions,
528                          void *actions[])
529 {
530 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
531 #ifdef HAVE_MLX5DV_DR
532         return mlx5dv_dr_create_rule(matcher, match_value, num_actions,
533                                      (struct mlx5dv_dr_action **)actions);
534 #else
535         struct mlx5dv_flow_action_attr actions_attr[8];
536
537         if (num_actions > 8)
538                 return NULL;
539         for (size_t i = 0; i < num_actions; i++)
540                 actions_attr[i] =
541                         *((struct mlx5dv_flow_action_attr *)(actions[i]));
542         return mlx5dv_create_flow(matcher, match_value,
543                                   num_actions, actions_attr);
544 #endif
545 #else
546         (void)matcher;
547         (void)match_value;
548         (void)num_actions;
549         (void)actions;
550         return NULL;
551 #endif
552 }
553
554 static void *
555 mlx5_glue_dv_create_flow_action_counter(void *counter_obj, uint32_t offset)
556 {
557 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
558 #ifdef HAVE_MLX5DV_DR
559         return mlx5dv_dr_create_action_devx_counter(counter_obj, offset);
560 #else
561         struct mlx5dv_flow_action_attr *action;
562
563         (void)offset;
564         action = malloc(sizeof(*action));
565         if (!action)
566                 return NULL;
567         action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
568         action->obj = counter_obj;
569         return action;
570 #endif
571 #else
572         (void)counter_obj;
573         (void)offset;
574         return NULL;
575 #endif
576 }
577
578 static void *
579 mlx5_glue_dv_create_flow_action_dest_ibv_qp(void *qp)
580 {
581 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
582 #ifdef HAVE_MLX5DV_DR
583         return mlx5dv_dr_create_action_dest_ibv_qp(qp);
584 #else
585         struct mlx5dv_flow_action_attr *action;
586
587         action = malloc(sizeof(*action));
588         if (!action)
589                 return NULL;
590         action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
591         action->obj = qp;
592         return action;
593 #endif
594 #else
595         (void)qp;
596         return NULL;
597 #endif
598 }
599
600 static void *
601 mlx5_glue_dv_create_flow_action_modify_header
602                                         (struct ibv_context *ctx,
603                                          enum mlx5dv_flow_table_type ft_type,
604                                          void *ns, uint64_t flags,
605                                          size_t actions_sz,
606                                          uint64_t actions[])
607 {
608 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
609 #ifdef HAVE_MLX5DV_DR
610         (void)ctx;
611         (void)ft_type;
612         return mlx5dv_dr_create_action_modify_header(ns, flags, actions_sz,
613                                                     actions);
614 #else
615         struct mlx5dv_flow_action_attr *action;
616
617         (void)ns;
618         (void)flags;
619         action = malloc(sizeof(*action));
620         if (!action)
621                 return NULL;
622         action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
623         action->action = mlx5dv_create_flow_action_modify_header
624                 (ctx, actions_sz, actions, ft_type);
625         return action;
626 #endif
627 #else
628         (void)ctx;
629         (void)ft_type;
630         (void)ns;
631         (void)flags;
632         (void)actions_sz;
633         (void)actions;
634         return NULL;
635 #endif
636 }
637
638 static void *
639 mlx5_glue_dv_create_flow_action_packet_reformat
640                 (struct ibv_context *ctx,
641                  enum mlx5dv_flow_action_packet_reformat_type reformat_type,
642                  enum mlx5dv_flow_table_type ft_type, struct mlx5dv_dr_ns *ns,
643                  uint32_t flags, size_t data_sz, void *data)
644 {
645 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
646 #ifdef HAVE_MLX5DV_DR
647         (void)ctx;
648         (void)ft_type;
649         return mlx5dv_dr_create_action_packet_reformat(ns, flags,
650                                                        reformat_type, data_sz,
651                                                        data);
652 #else
653         (void)ns;
654         (void)flags;
655         struct mlx5dv_flow_action_attr *action;
656
657         action = malloc(sizeof(*action));
658         if (!action)
659                 return NULL;
660         action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
661         action->action = mlx5dv_create_flow_action_packet_reformat
662                 (ctx, data_sz, data, reformat_type, ft_type);
663         return action;
664 #endif
665 #else
666         (void)ctx;
667         (void)reformat_type;
668         (void)ft_type;
669         (void)ns;
670         (void)flags;
671         (void)data_sz;
672         (void)data;
673         return NULL;
674 #endif
675 }
676
677 static void *
678 mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
679 {
680 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
681 #ifdef HAVE_MLX5DV_DR
682         return mlx5dv_dr_create_action_tag(tag);
683 #else
684         struct mlx5dv_flow_action_attr *action;
685         action = malloc(sizeof(*action));
686         if (!action)
687                 return NULL;
688         action->type = MLX5DV_FLOW_ACTION_TAG;
689         action->tag_value = tag;
690         return action;
691 #endif
692 #endif
693         (void)tag;
694         return NULL;
695 }
696
697 static int
698 mlx5_glue_dv_destroy_flow(void *flow_id)
699 {
700 #ifdef HAVE_MLX5DV_DR
701         return mlx5dv_dr_destroy_rule(flow_id);
702 #else
703         return ibv_destroy_flow(flow_id);
704 #endif
705 }
706
707 static int
708 mlx5_glue_dv_destroy_flow_matcher(void *matcher)
709 {
710 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
711 #ifdef HAVE_MLX5DV_DR
712         return mlx5dv_dr_destroy_matcher(matcher);
713 #else
714         return mlx5dv_destroy_flow_matcher(matcher);
715 #endif
716 #else
717         (void)matcher;
718         return 0;
719 #endif
720 }
721
722 static struct ibv_context *
723 mlx5_glue_dv_open_device(struct ibv_device *device)
724 {
725 #ifdef HAVE_IBV_DEVX_OBJ
726         return mlx5dv_open_device(device,
727                                   &(struct mlx5dv_context_attr){
728                                         .flags = MLX5DV_CONTEXT_FLAGS_DEVX,
729                                   });
730 #else
731         (void)device;
732         return NULL;
733 #endif
734 }
735
736 static struct mlx5dv_devx_obj *
737 mlx5_glue_devx_obj_create(struct ibv_context *ctx,
738                           const void *in, size_t inlen,
739                           void *out, size_t outlen)
740 {
741 #ifdef HAVE_IBV_DEVX_OBJ
742         return mlx5dv_devx_obj_create(ctx, in, inlen, out, outlen);
743 #else
744         (void)ctx;
745         (void)in;
746         (void)inlen;
747         (void)out;
748         (void)outlen;
749         return NULL;
750 #endif
751 }
752
753 static int
754 mlx5_glue_devx_obj_destroy(struct mlx5dv_devx_obj *obj)
755 {
756 #ifdef HAVE_IBV_DEVX_OBJ
757         return mlx5dv_devx_obj_destroy(obj);
758 #else
759         (void)obj;
760         return -ENOTSUP;
761 #endif
762 }
763
764 static int
765 mlx5_glue_devx_obj_query(struct mlx5dv_devx_obj *obj,
766                          const void *in, size_t inlen,
767                          void *out, size_t outlen)
768 {
769 #ifdef HAVE_IBV_DEVX_OBJ
770         return mlx5dv_devx_obj_query(obj, in, inlen, out, outlen);
771 #else
772         (void)obj;
773         (void)in;
774         (void)inlen;
775         (void)out;
776         (void)outlen;
777         return -ENOTSUP;
778 #endif
779 }
780
781 static int
782 mlx5_glue_devx_obj_modify(struct mlx5dv_devx_obj *obj,
783                           const void *in, size_t inlen,
784                           void *out, size_t outlen)
785 {
786 #ifdef HAVE_IBV_DEVX_OBJ
787         return mlx5dv_devx_obj_modify(obj, in, inlen, out, outlen);
788 #else
789         (void)obj;
790         (void)in;
791         (void)inlen;
792         (void)out;
793         (void)outlen;
794         return -ENOTSUP;
795 #endif
796 }
797
798 static int
799 mlx5_glue_devx_general_cmd(struct ibv_context *ctx,
800                            const void *in, size_t inlen,
801                            void *out, size_t outlen)
802 {
803 #ifdef HAVE_IBV_DEVX_OBJ
804         return mlx5dv_devx_general_cmd(ctx, in, inlen, out, outlen);
805 #else
806         (void)ctx;
807         (void)in;
808         (void)inlen;
809         (void)out;
810         (void)outlen;
811         return -ENOTSUP;
812 #endif
813 }
814
815 alignas(RTE_CACHE_LINE_SIZE)
816 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
817         .version = MLX5_GLUE_VERSION,
818         .fork_init = mlx5_glue_fork_init,
819         .alloc_pd = mlx5_glue_alloc_pd,
820         .dealloc_pd = mlx5_glue_dealloc_pd,
821         .get_device_list = mlx5_glue_get_device_list,
822         .free_device_list = mlx5_glue_free_device_list,
823         .open_device = mlx5_glue_open_device,
824         .close_device = mlx5_glue_close_device,
825         .query_device = mlx5_glue_query_device,
826         .query_device_ex = mlx5_glue_query_device_ex,
827         .query_port = mlx5_glue_query_port,
828         .create_comp_channel = mlx5_glue_create_comp_channel,
829         .destroy_comp_channel = mlx5_glue_destroy_comp_channel,
830         .create_cq = mlx5_glue_create_cq,
831         .destroy_cq = mlx5_glue_destroy_cq,
832         .get_cq_event = mlx5_glue_get_cq_event,
833         .ack_cq_events = mlx5_glue_ack_cq_events,
834         .create_rwq_ind_table = mlx5_glue_create_rwq_ind_table,
835         .destroy_rwq_ind_table = mlx5_glue_destroy_rwq_ind_table,
836         .create_wq = mlx5_glue_create_wq,
837         .destroy_wq = mlx5_glue_destroy_wq,
838         .modify_wq = mlx5_glue_modify_wq,
839         .create_flow = mlx5_glue_create_flow,
840         .destroy_flow = mlx5_glue_destroy_flow,
841         .destroy_flow_action = mlx5_glue_destroy_flow_action,
842         .create_qp = mlx5_glue_create_qp,
843         .create_qp_ex = mlx5_glue_create_qp_ex,
844         .destroy_qp = mlx5_glue_destroy_qp,
845         .modify_qp = mlx5_glue_modify_qp,
846         .reg_mr = mlx5_glue_reg_mr,
847         .dereg_mr = mlx5_glue_dereg_mr,
848         .create_counter_set = mlx5_glue_create_counter_set,
849         .destroy_counter_set = mlx5_glue_destroy_counter_set,
850         .describe_counter_set = mlx5_glue_describe_counter_set,
851         .query_counter_set = mlx5_glue_query_counter_set,
852         .create_counters = mlx5_glue_create_counters,
853         .destroy_counters = mlx5_glue_destroy_counters,
854         .attach_counters = mlx5_glue_attach_counters,
855         .query_counters = mlx5_glue_query_counters,
856         .ack_async_event = mlx5_glue_ack_async_event,
857         .get_async_event = mlx5_glue_get_async_event,
858         .port_state_str = mlx5_glue_port_state_str,
859         .cq_ex_to_cq = mlx5_glue_cq_ex_to_cq,
860         .dr_create_flow_action_dest_flow_tbl =
861                 mlx5_glue_dr_create_flow_action_dest_flow_tbl,
862         .dr_create_flow_action_dest_vport =
863                 mlx5_glue_dr_create_flow_action_dest_vport,
864         .dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
865         .dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
866         .dr_create_ns = mlx5_glue_dr_create_ns,
867         .dr_destroy_ns = mlx5_glue_dr_destroy_ns,
868         .dv_create_cq = mlx5_glue_dv_create_cq,
869         .dv_create_wq = mlx5_glue_dv_create_wq,
870         .dv_query_device = mlx5_glue_dv_query_device,
871         .dv_set_context_attr = mlx5_glue_dv_set_context_attr,
872         .dv_init_obj = mlx5_glue_dv_init_obj,
873         .dv_create_qp = mlx5_glue_dv_create_qp,
874         .dv_create_flow_matcher = mlx5_glue_dv_create_flow_matcher,
875         .dv_create_flow = mlx5_glue_dv_create_flow,
876         .dv_create_flow_action_counter =
877                 mlx5_glue_dv_create_flow_action_counter,
878         .dv_create_flow_action_dest_ibv_qp =
879                 mlx5_glue_dv_create_flow_action_dest_ibv_qp,
880         .dv_create_flow_action_modify_header =
881                 mlx5_glue_dv_create_flow_action_modify_header,
882         .dv_create_flow_action_packet_reformat =
883                 mlx5_glue_dv_create_flow_action_packet_reformat,
884         .dv_create_flow_action_tag =  mlx5_glue_dv_create_flow_action_tag,
885         .dv_destroy_flow = mlx5_glue_dv_destroy_flow,
886         .dv_destroy_flow_matcher = mlx5_glue_dv_destroy_flow_matcher,
887         .dv_open_device = mlx5_glue_dv_open_device,
888         .devx_obj_create = mlx5_glue_devx_obj_create,
889         .devx_obj_destroy = mlx5_glue_devx_obj_destroy,
890         .devx_obj_query = mlx5_glue_devx_obj_query,
891         .devx_obj_modify = mlx5_glue_devx_obj_modify,
892         .devx_general_cmd = mlx5_glue_devx_general_cmd,
893 };