1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox Technologies, Ltd
11 #include <rte_memory.h>
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.
16 #include <sys/types.h>
18 #include "mlx5_glue.h"
19 #include "../mlx5_malloc.h"
22 mlx5_glue_fork_init(void)
24 return ibv_fork_init();
27 static struct ibv_pd *
28 mlx5_glue_alloc_pd(struct ibv_context *context)
30 return ibv_alloc_pd(context);
34 mlx5_glue_dealloc_pd(struct ibv_pd *pd)
36 return ibv_dealloc_pd(pd);
39 static struct ibv_device **
40 mlx5_glue_get_device_list(int *num_devices)
42 return ibv_get_device_list(num_devices);
46 mlx5_glue_free_device_list(struct ibv_device **list)
48 ibv_free_device_list(list);
51 static struct ibv_context *
52 mlx5_glue_open_device(struct ibv_device *device)
54 return ibv_open_device(device);
58 mlx5_glue_close_device(struct ibv_context *context)
60 return ibv_close_device(context);
64 mlx5_glue_query_device(struct ibv_context *context,
65 struct ibv_device_attr *device_attr)
67 return ibv_query_device(context, device_attr);
71 mlx5_glue_query_device_ex(struct ibv_context *context,
72 const struct ibv_query_device_ex_input *input,
73 struct ibv_device_attr_ex *attr)
75 return ibv_query_device_ex(context, input, attr);
79 mlx5_glue_query_rt_values_ex(struct ibv_context *context,
80 struct ibv_values_ex *values)
82 return ibv_query_rt_values_ex(context, values);
86 mlx5_glue_query_port(struct ibv_context *context, uint8_t port_num,
87 struct ibv_port_attr *port_attr)
89 return ibv_query_port(context, port_num, port_attr);
92 static struct ibv_comp_channel *
93 mlx5_glue_create_comp_channel(struct ibv_context *context)
95 return ibv_create_comp_channel(context);
99 mlx5_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
101 return ibv_destroy_comp_channel(channel);
104 static struct ibv_cq *
105 mlx5_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
106 struct ibv_comp_channel *channel, int comp_vector)
108 return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
112 mlx5_glue_destroy_cq(struct ibv_cq *cq)
114 return ibv_destroy_cq(cq);
118 mlx5_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
121 return ibv_get_cq_event(channel, cq, cq_context);
125 mlx5_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
127 ibv_ack_cq_events(cq, nevents);
130 static struct ibv_rwq_ind_table *
131 mlx5_glue_create_rwq_ind_table(struct ibv_context *context,
132 struct ibv_rwq_ind_table_init_attr *init_attr)
134 return ibv_create_rwq_ind_table(context, init_attr);
138 mlx5_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
140 return ibv_destroy_rwq_ind_table(rwq_ind_table);
143 static struct ibv_wq *
144 mlx5_glue_create_wq(struct ibv_context *context,
145 struct ibv_wq_init_attr *wq_init_attr)
147 return ibv_create_wq(context, wq_init_attr);
151 mlx5_glue_destroy_wq(struct ibv_wq *wq)
153 return ibv_destroy_wq(wq);
156 mlx5_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
158 return ibv_modify_wq(wq, wq_attr);
161 static struct ibv_flow *
162 mlx5_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
164 return ibv_create_flow(qp, flow);
168 mlx5_glue_destroy_flow(struct ibv_flow *flow_id)
170 return ibv_destroy_flow(flow_id);
174 mlx5_glue_destroy_flow_action(void *action)
176 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
177 #ifdef HAVE_MLX5DV_DR
178 return mlx5dv_dr_action_destroy(action);
180 struct mlx5dv_flow_action_attr *attr = action;
182 switch (attr->type) {
183 case MLX5DV_FLOW_ACTION_TAG:
186 res = ibv_destroy_flow_action(attr->action);
198 static struct ibv_qp *
199 mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
201 return ibv_create_qp(pd, qp_init_attr);
204 static struct ibv_qp *
205 mlx5_glue_create_qp_ex(struct ibv_context *context,
206 struct ibv_qp_init_attr_ex *qp_init_attr_ex)
208 return ibv_create_qp_ex(context, qp_init_attr_ex);
212 mlx5_glue_destroy_qp(struct ibv_qp *qp)
214 return ibv_destroy_qp(qp);
218 mlx5_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
220 return ibv_modify_qp(qp, attr, attr_mask);
223 static struct ibv_mr *
224 mlx5_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
226 return ibv_reg_mr(pd, addr, length, access);
229 static struct ibv_mr *
230 mlx5_glue_alloc_null_mr(struct ibv_pd *pd)
232 #ifdef HAVE_IBV_DEVX_OBJ
233 return ibv_alloc_null_mr(pd);
242 mlx5_glue_dereg_mr(struct ibv_mr *mr)
244 return ibv_dereg_mr(mr);
247 static struct ibv_counter_set *
248 mlx5_glue_create_counter_set(struct ibv_context *context,
249 struct ibv_counter_set_init_attr *init_attr)
251 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
256 return ibv_create_counter_set(context, init_attr);
261 mlx5_glue_destroy_counter_set(struct ibv_counter_set *cs)
263 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
267 return ibv_destroy_counter_set(cs);
272 mlx5_glue_describe_counter_set(struct ibv_context *context,
273 uint16_t counter_set_id,
274 struct ibv_counter_set_description *cs_desc)
276 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
278 (void)counter_set_id;
282 return ibv_describe_counter_set(context, counter_set_id, cs_desc);
287 mlx5_glue_query_counter_set(struct ibv_query_counter_set_attr *query_attr,
288 struct ibv_counter_set_data *cs_data)
290 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
295 return ibv_query_counter_set(query_attr, cs_data);
299 static struct ibv_counters *
300 mlx5_glue_create_counters(struct ibv_context *context,
301 struct ibv_counters_init_attr *init_attr)
303 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
309 return ibv_create_counters(context, init_attr);
314 mlx5_glue_destroy_counters(struct ibv_counters *counters)
316 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
320 return ibv_destroy_counters(counters);
325 mlx5_glue_attach_counters(struct ibv_counters *counters,
326 struct ibv_counter_attach_attr *attr,
327 struct ibv_flow *flow)
329 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
335 return ibv_attach_counters_point_flow(counters, attr, flow);
340 mlx5_glue_query_counters(struct ibv_counters *counters,
341 uint64_t *counters_value,
345 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
347 (void)counters_value;
352 return ibv_read_counters(counters, counters_value, ncounters, flags);
357 mlx5_glue_ack_async_event(struct ibv_async_event *event)
359 ibv_ack_async_event(event);
363 mlx5_glue_get_async_event(struct ibv_context *context,
364 struct ibv_async_event *event)
366 return ibv_get_async_event(context, event);
370 mlx5_glue_port_state_str(enum ibv_port_state port_state)
372 return ibv_port_state_str(port_state);
375 static struct ibv_cq *
376 mlx5_glue_cq_ex_to_cq(struct ibv_cq_ex *cq)
378 return ibv_cq_ex_to_cq(cq);
382 mlx5_glue_dr_create_flow_action_dest_flow_tbl(void *tbl)
384 #ifdef HAVE_MLX5DV_DR
385 return mlx5dv_dr_action_create_dest_table(tbl);
394 mlx5_glue_dr_create_flow_action_dest_port(void *domain, uint32_t port)
396 #ifdef HAVE_MLX5DV_DR_DEVX_PORT
397 return mlx5dv_dr_action_create_dest_ib_port(domain, port);
399 #ifdef HAVE_MLX5DV_DR_ESWITCH
400 return mlx5dv_dr_action_create_dest_vport(domain, port);
411 mlx5_glue_dr_create_flow_action_drop(void)
413 #ifdef HAVE_MLX5DV_DR_ESWITCH
414 return mlx5dv_dr_action_create_drop();
422 mlx5_glue_dr_create_flow_action_push_vlan(struct mlx5dv_dr_domain *domain,
425 #ifdef HAVE_MLX5DV_DR_VLAN
426 return mlx5dv_dr_action_create_push_vlan(domain, vlan_tag);
436 mlx5_glue_dr_create_flow_action_pop_vlan(void)
438 #ifdef HAVE_MLX5DV_DR_VLAN
439 return mlx5dv_dr_action_create_pop_vlan();
447 mlx5_glue_dr_create_flow_tbl(void *domain, uint32_t level)
449 #ifdef HAVE_MLX5DV_DR
450 return mlx5dv_dr_table_create(domain, level);
460 mlx5_glue_dr_destroy_flow_tbl(void *tbl)
462 #ifdef HAVE_MLX5DV_DR
463 return mlx5dv_dr_table_destroy(tbl);
472 mlx5_glue_dr_create_domain(struct ibv_context *ctx,
473 enum mlx5dv_dr_domain_type domain)
475 #ifdef HAVE_MLX5DV_DR
476 return mlx5dv_dr_domain_create(ctx, domain);
486 mlx5_glue_dr_destroy_domain(void *domain)
488 #ifdef HAVE_MLX5DV_DR
489 return mlx5dv_dr_domain_destroy(domain);
497 static struct ibv_cq_ex *
498 mlx5_glue_dv_create_cq(struct ibv_context *context,
499 struct ibv_cq_init_attr_ex *cq_attr,
500 struct mlx5dv_cq_init_attr *mlx5_cq_attr)
502 return mlx5dv_create_cq(context, cq_attr, mlx5_cq_attr);
505 static struct ibv_wq *
506 mlx5_glue_dv_create_wq(struct ibv_context *context,
507 struct ibv_wq_init_attr *wq_attr,
508 struct mlx5dv_wq_init_attr *mlx5_wq_attr)
510 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
517 return mlx5dv_create_wq(context, wq_attr, mlx5_wq_attr);
522 mlx5_glue_dv_query_device(struct ibv_context *ctx,
523 struct mlx5dv_context *attrs_out)
525 return mlx5dv_query_device(ctx, attrs_out);
529 mlx5_glue_dv_set_context_attr(struct ibv_context *ibv_ctx,
530 enum mlx5dv_set_ctx_attr_type type, void *attr)
532 return mlx5dv_set_context_attr(ibv_ctx, type, attr);
536 mlx5_glue_dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type)
538 return mlx5dv_init_obj(obj, obj_type);
541 static struct ibv_qp *
542 mlx5_glue_dv_create_qp(struct ibv_context *context,
543 struct ibv_qp_init_attr_ex *qp_init_attr_ex,
544 struct mlx5dv_qp_init_attr *dv_qp_init_attr)
546 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
547 return mlx5dv_create_qp(context, qp_init_attr_ex, dv_qp_init_attr);
550 (void)qp_init_attr_ex;
551 (void)dv_qp_init_attr;
558 mlx5_glue_dv_create_flow_matcher(struct ibv_context *context,
559 struct mlx5dv_flow_matcher_attr *matcher_attr,
562 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
563 #ifdef HAVE_MLX5DV_DR
565 return mlx5dv_dr_matcher_create(tbl, matcher_attr->priority,
566 matcher_attr->match_criteria_enable,
567 matcher_attr->match_mask);
570 return mlx5dv_create_flow_matcher(context, matcher_attr);
582 mlx5_glue_dv_create_flow(void *matcher,
587 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
588 #ifdef HAVE_MLX5DV_DR
589 return mlx5dv_dr_rule_create(matcher, match_value, num_actions,
590 (struct mlx5dv_dr_action **)actions);
593 struct mlx5dv_flow_action_attr actions_attr[8];
597 for (i = 0; i < num_actions; i++)
599 *((struct mlx5dv_flow_action_attr *)(actions[i]));
600 return mlx5dv_create_flow(matcher, match_value,
601 num_actions, actions_attr);
613 mlx5_glue_dv_create_flow_action_counter(void *counter_obj, uint32_t offset)
615 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
616 #ifdef HAVE_MLX5DV_DR
617 return mlx5dv_dr_action_create_flow_counter(counter_obj, offset);
619 struct mlx5dv_flow_action_attr *action;
622 action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
625 action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
626 action->obj = counter_obj;
638 mlx5_glue_dv_create_flow_action_dest_ibv_qp(void *qp)
640 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
641 #ifdef HAVE_MLX5DV_DR
642 return mlx5dv_dr_action_create_dest_ibv_qp(qp);
644 struct mlx5dv_flow_action_attr *action;
646 action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
649 action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
661 mlx5_glue_dv_create_flow_action_dest_devx_tir(void *tir)
663 #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR
664 return mlx5dv_dr_action_create_dest_devx_tir(tir);
673 mlx5_glue_dv_create_flow_action_modify_header
674 (struct ibv_context *ctx,
675 enum mlx5dv_flow_table_type ft_type,
676 void *domain, uint64_t flags,
680 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
681 #ifdef HAVE_MLX5DV_DR
684 return mlx5dv_dr_action_create_modify_header(domain, flags, actions_sz,
687 struct mlx5dv_flow_action_attr *action;
691 action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
694 action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
695 action->action = mlx5dv_create_flow_action_modify_header
696 (ctx, actions_sz, actions, ft_type);
712 mlx5_glue_dv_create_flow_action_packet_reformat
713 (struct ibv_context *ctx,
714 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
715 enum mlx5dv_flow_table_type ft_type,
716 struct mlx5dv_dr_domain *domain,
717 uint32_t flags, size_t data_sz, void *data)
719 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
720 #ifdef HAVE_MLX5DV_DR
723 return mlx5dv_dr_action_create_packet_reformat(domain, flags,
724 reformat_type, data_sz,
729 struct mlx5dv_flow_action_attr *action;
731 action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
734 action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
735 action->action = mlx5dv_create_flow_action_packet_reformat
736 (ctx, data_sz, data, reformat_type, ft_type);
753 mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
755 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
756 #ifdef HAVE_MLX5DV_DR
757 return mlx5dv_dr_action_create_tag(tag);
758 #else /* HAVE_MLX5DV_DR */
759 struct mlx5dv_flow_action_attr *action;
761 action = mlx5_malloc(0, sizeof(*action), 0, SOCKET_ID_ANY);
764 action->type = MLX5DV_FLOW_ACTION_TAG;
765 action->tag_value = tag;
767 #endif /* HAVE_MLX5DV_DR */
768 #else /* HAVE_IBV_FLOW_DV_SUPPORT */
772 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
776 mlx5_glue_dv_create_flow_action_meter(struct mlx5dv_dr_flow_meter_attr *attr)
778 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
779 return mlx5dv_dr_action_create_flow_meter(attr);
788 mlx5_glue_dv_modify_flow_action_meter(void *action,
789 struct mlx5dv_dr_flow_meter_attr *attr,
790 uint64_t modify_bits)
792 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
793 return mlx5dv_dr_action_modify_flow_meter(action, attr, modify_bits);
804 mlx5_glue_dr_create_flow_action_default_miss(void)
806 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS)
807 return mlx5dv_dr_action_create_default_miss();
815 mlx5_glue_dv_destroy_flow(void *flow_id)
817 #ifdef HAVE_MLX5DV_DR
818 return mlx5dv_dr_rule_destroy(flow_id);
820 return ibv_destroy_flow(flow_id);
825 mlx5_glue_dv_destroy_flow_matcher(void *matcher)
827 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
828 #ifdef HAVE_MLX5DV_DR
829 return mlx5dv_dr_matcher_destroy(matcher);
831 return mlx5dv_destroy_flow_matcher(matcher);
840 static struct ibv_context *
841 mlx5_glue_dv_open_device(struct ibv_device *device)
843 #ifdef HAVE_IBV_DEVX_OBJ
844 return mlx5dv_open_device(device,
845 &(struct mlx5dv_context_attr){
846 .flags = MLX5DV_CONTEXT_FLAGS_DEVX,
855 static struct mlx5dv_devx_obj *
856 mlx5_glue_devx_obj_create(struct ibv_context *ctx,
857 const void *in, size_t inlen,
858 void *out, size_t outlen)
860 #ifdef HAVE_IBV_DEVX_OBJ
861 return mlx5dv_devx_obj_create(ctx, in, inlen, out, outlen);
874 mlx5_glue_devx_obj_destroy(struct mlx5dv_devx_obj *obj)
876 #ifdef HAVE_IBV_DEVX_OBJ
877 return mlx5dv_devx_obj_destroy(obj);
885 mlx5_glue_devx_obj_query(struct mlx5dv_devx_obj *obj,
886 const void *in, size_t inlen,
887 void *out, size_t outlen)
889 #ifdef HAVE_IBV_DEVX_OBJ
890 return mlx5dv_devx_obj_query(obj, in, inlen, out, outlen);
902 mlx5_glue_devx_obj_modify(struct mlx5dv_devx_obj *obj,
903 const void *in, size_t inlen,
904 void *out, size_t outlen)
906 #ifdef HAVE_IBV_DEVX_OBJ
907 return mlx5dv_devx_obj_modify(obj, in, inlen, out, outlen);
919 mlx5_glue_devx_general_cmd(struct ibv_context *ctx,
920 const void *in, size_t inlen,
921 void *out, size_t outlen)
923 #ifdef HAVE_IBV_DEVX_OBJ
924 return mlx5dv_devx_general_cmd(ctx, in, inlen, out, outlen);
935 static struct mlx5dv_devx_cmd_comp *
936 mlx5_glue_devx_create_cmd_comp(struct ibv_context *ctx)
938 #ifdef HAVE_IBV_DEVX_ASYNC
939 return mlx5dv_devx_create_cmd_comp(ctx);
948 mlx5_glue_devx_destroy_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp)
950 #ifdef HAVE_IBV_DEVX_ASYNC
951 mlx5dv_devx_destroy_cmd_comp(cmd_comp);
959 mlx5_glue_devx_obj_query_async(struct mlx5dv_devx_obj *obj, const void *in,
960 size_t inlen, size_t outlen, uint64_t wr_id,
961 struct mlx5dv_devx_cmd_comp *cmd_comp)
963 #ifdef HAVE_IBV_DEVX_ASYNC
964 return mlx5dv_devx_obj_query_async(obj, in, inlen, outlen, wr_id,
978 mlx5_glue_devx_get_async_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp,
979 struct mlx5dv_devx_async_cmd_hdr *cmd_resp,
982 #ifdef HAVE_IBV_DEVX_ASYNC
983 return mlx5dv_devx_get_async_cmd_comp(cmd_comp, cmd_resp,
993 static struct mlx5dv_devx_umem *
994 mlx5_glue_devx_umem_reg(struct ibv_context *context, void *addr, size_t size,
997 #ifdef HAVE_IBV_DEVX_OBJ
998 return mlx5dv_devx_umem_reg(context, addr, size, access);
1010 mlx5_glue_devx_umem_dereg(struct mlx5dv_devx_umem *dv_devx_umem)
1012 #ifdef HAVE_IBV_DEVX_OBJ
1013 return mlx5dv_devx_umem_dereg(dv_devx_umem);
1021 mlx5_glue_devx_qp_query(struct ibv_qp *qp,
1022 const void *in, size_t inlen,
1023 void *out, size_t outlen)
1025 #ifdef HAVE_IBV_DEVX_QP
1026 return mlx5dv_devx_qp_query(qp, in, inlen, out, outlen);
1039 mlx5_glue_devx_port_query(struct ibv_context *ctx,
1041 struct mlx5dv_devx_port *mlx5_devx_port)
1043 #ifdef HAVE_MLX5DV_DR_DEVX_PORT
1044 return mlx5dv_query_devx_port(ctx, port_num, mlx5_devx_port);
1048 (void)mlx5_devx_port;
1055 mlx5_glue_dr_dump_domain(FILE *file, void *domain)
1057 #ifdef HAVE_MLX5_DR_FLOW_DUMP
1058 return mlx5dv_dump_dr_domain(file, domain);
1061 RTE_SET_USED(domain);
1067 mlx5_glue_dr_create_flow_action_sampler
1068 (struct mlx5dv_dr_flow_sampler_attr *attr)
1070 #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
1071 return mlx5dv_dr_action_create_flow_sampler(attr);
1080 mlx5_glue_dr_action_create_dest_array
1083 struct mlx5dv_dr_action_dest_attr *dests[])
1085 #ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY
1086 return mlx5dv_dr_action_create_dest_array
1100 mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
1103 #ifdef HAVE_IBV_DEVX_OBJ
1104 return mlx5dv_devx_query_eqn(ctx, cpus, eqn);
1113 static struct mlx5dv_devx_event_channel *
1114 mlx5_glue_devx_create_event_channel(struct ibv_context *ctx, int flags)
1116 #ifdef HAVE_IBV_DEVX_EVENT
1117 return mlx5dv_devx_create_event_channel(ctx, flags);
1127 mlx5_glue_devx_destroy_event_channel(struct mlx5dv_devx_event_channel *eventc)
1129 #ifdef HAVE_IBV_DEVX_EVENT
1130 mlx5dv_devx_destroy_event_channel(eventc);
1137 mlx5_glue_devx_subscribe_devx_event(struct mlx5dv_devx_event_channel *eventc,
1138 struct mlx5dv_devx_obj *obj,
1139 uint16_t events_sz, uint16_t events_num[],
1142 #ifdef HAVE_IBV_DEVX_EVENT
1143 return mlx5dv_devx_subscribe_devx_event(eventc, obj, events_sz,
1144 events_num, cookie);
1156 mlx5_glue_devx_subscribe_devx_event_fd(struct mlx5dv_devx_event_channel *eventc,
1157 int fd, struct mlx5dv_devx_obj *obj,
1160 #ifdef HAVE_IBV_DEVX_EVENT
1161 return mlx5dv_devx_subscribe_devx_event_fd(eventc, fd, obj, event_num);
1172 mlx5_glue_devx_get_event(struct mlx5dv_devx_event_channel *eventc,
1173 struct mlx5dv_devx_async_event_hdr *event_data,
1174 size_t event_resp_len)
1176 #ifdef HAVE_IBV_DEVX_EVENT
1177 return mlx5dv_devx_get_event(eventc, event_data, event_resp_len);
1181 (void)event_resp_len;
1187 static struct mlx5dv_devx_uar *
1188 mlx5_glue_devx_alloc_uar(struct ibv_context *context, uint32_t flags)
1190 #ifdef HAVE_IBV_DEVX_OBJ
1191 return mlx5dv_devx_alloc_uar(context, flags);
1201 mlx5_glue_devx_free_uar(struct mlx5dv_devx_uar *devx_uar)
1203 #ifdef HAVE_IBV_DEVX_OBJ
1204 mlx5dv_devx_free_uar(devx_uar);
1210 static struct mlx5dv_var *
1211 mlx5_glue_dv_alloc_var(struct ibv_context *context, uint32_t flags)
1214 return mlx5dv_alloc_var(context, flags);
1224 mlx5_glue_dv_free_var(struct mlx5dv_var *var)
1227 mlx5dv_free_var(var);
1235 mlx5_glue_dr_reclaim_domain_memory(void *domain, uint32_t enable)
1237 #ifdef HAVE_MLX5DV_DR_MEM_RECLAIM
1238 mlx5dv_dr_domain_set_reclaim_device_memory(domain, enable);
1245 static struct mlx5dv_pp *
1246 mlx5_glue_dv_alloc_pp(struct ibv_context *context,
1247 size_t pp_context_sz,
1248 const void *pp_context,
1251 #ifdef HAVE_MLX5DV_PP_ALLOC
1252 return mlx5dv_pp_alloc(context, pp_context_sz, pp_context, flags);
1254 RTE_SET_USED(context);
1255 RTE_SET_USED(pp_context_sz);
1256 RTE_SET_USED(pp_context);
1257 RTE_SET_USED(flags);
1264 mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
1266 #ifdef HAVE_MLX5DV_PP_ALLOC
1274 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
1275 .version = MLX5_GLUE_VERSION,
1276 .fork_init = mlx5_glue_fork_init,
1277 .alloc_pd = mlx5_glue_alloc_pd,
1278 .dealloc_pd = mlx5_glue_dealloc_pd,
1279 .get_device_list = mlx5_glue_get_device_list,
1280 .free_device_list = mlx5_glue_free_device_list,
1281 .open_device = mlx5_glue_open_device,
1282 .close_device = mlx5_glue_close_device,
1283 .query_device = mlx5_glue_query_device,
1284 .query_device_ex = mlx5_glue_query_device_ex,
1285 .query_rt_values_ex = mlx5_glue_query_rt_values_ex,
1286 .query_port = mlx5_glue_query_port,
1287 .create_comp_channel = mlx5_glue_create_comp_channel,
1288 .destroy_comp_channel = mlx5_glue_destroy_comp_channel,
1289 .create_cq = mlx5_glue_create_cq,
1290 .destroy_cq = mlx5_glue_destroy_cq,
1291 .get_cq_event = mlx5_glue_get_cq_event,
1292 .ack_cq_events = mlx5_glue_ack_cq_events,
1293 .create_rwq_ind_table = mlx5_glue_create_rwq_ind_table,
1294 .destroy_rwq_ind_table = mlx5_glue_destroy_rwq_ind_table,
1295 .create_wq = mlx5_glue_create_wq,
1296 .destroy_wq = mlx5_glue_destroy_wq,
1297 .modify_wq = mlx5_glue_modify_wq,
1298 .create_flow = mlx5_glue_create_flow,
1299 .destroy_flow = mlx5_glue_destroy_flow,
1300 .destroy_flow_action = mlx5_glue_destroy_flow_action,
1301 .create_qp = mlx5_glue_create_qp,
1302 .create_qp_ex = mlx5_glue_create_qp_ex,
1303 .destroy_qp = mlx5_glue_destroy_qp,
1304 .modify_qp = mlx5_glue_modify_qp,
1305 .reg_mr = mlx5_glue_reg_mr,
1306 .alloc_null_mr = mlx5_glue_alloc_null_mr,
1307 .dereg_mr = mlx5_glue_dereg_mr,
1308 .create_counter_set = mlx5_glue_create_counter_set,
1309 .destroy_counter_set = mlx5_glue_destroy_counter_set,
1310 .describe_counter_set = mlx5_glue_describe_counter_set,
1311 .query_counter_set = mlx5_glue_query_counter_set,
1312 .create_counters = mlx5_glue_create_counters,
1313 .destroy_counters = mlx5_glue_destroy_counters,
1314 .attach_counters = mlx5_glue_attach_counters,
1315 .query_counters = mlx5_glue_query_counters,
1316 .ack_async_event = mlx5_glue_ack_async_event,
1317 .get_async_event = mlx5_glue_get_async_event,
1318 .port_state_str = mlx5_glue_port_state_str,
1319 .cq_ex_to_cq = mlx5_glue_cq_ex_to_cq,
1320 .dr_create_flow_action_dest_flow_tbl =
1321 mlx5_glue_dr_create_flow_action_dest_flow_tbl,
1322 .dr_create_flow_action_dest_port =
1323 mlx5_glue_dr_create_flow_action_dest_port,
1324 .dr_create_flow_action_drop =
1325 mlx5_glue_dr_create_flow_action_drop,
1326 .dr_create_flow_action_push_vlan =
1327 mlx5_glue_dr_create_flow_action_push_vlan,
1328 .dr_create_flow_action_pop_vlan =
1329 mlx5_glue_dr_create_flow_action_pop_vlan,
1330 .dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
1331 .dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
1332 .dr_create_domain = mlx5_glue_dr_create_domain,
1333 .dr_destroy_domain = mlx5_glue_dr_destroy_domain,
1334 .dv_create_cq = mlx5_glue_dv_create_cq,
1335 .dv_create_wq = mlx5_glue_dv_create_wq,
1336 .dv_query_device = mlx5_glue_dv_query_device,
1337 .dv_set_context_attr = mlx5_glue_dv_set_context_attr,
1338 .dv_init_obj = mlx5_glue_dv_init_obj,
1339 .dv_create_qp = mlx5_glue_dv_create_qp,
1340 .dv_create_flow_matcher = mlx5_glue_dv_create_flow_matcher,
1341 .dv_create_flow = mlx5_glue_dv_create_flow,
1342 .dv_create_flow_action_counter =
1343 mlx5_glue_dv_create_flow_action_counter,
1344 .dv_create_flow_action_dest_ibv_qp =
1345 mlx5_glue_dv_create_flow_action_dest_ibv_qp,
1346 .dv_create_flow_action_dest_devx_tir =
1347 mlx5_glue_dv_create_flow_action_dest_devx_tir,
1348 .dv_create_flow_action_modify_header =
1349 mlx5_glue_dv_create_flow_action_modify_header,
1350 .dv_create_flow_action_packet_reformat =
1351 mlx5_glue_dv_create_flow_action_packet_reformat,
1352 .dv_create_flow_action_tag = mlx5_glue_dv_create_flow_action_tag,
1353 .dv_create_flow_action_meter = mlx5_glue_dv_create_flow_action_meter,
1354 .dv_modify_flow_action_meter = mlx5_glue_dv_modify_flow_action_meter,
1355 .dr_create_flow_action_default_miss =
1356 mlx5_glue_dr_create_flow_action_default_miss,
1357 .dv_destroy_flow = mlx5_glue_dv_destroy_flow,
1358 .dv_destroy_flow_matcher = mlx5_glue_dv_destroy_flow_matcher,
1359 .dv_open_device = mlx5_glue_dv_open_device,
1360 .devx_obj_create = mlx5_glue_devx_obj_create,
1361 .devx_obj_destroy = mlx5_glue_devx_obj_destroy,
1362 .devx_obj_query = mlx5_glue_devx_obj_query,
1363 .devx_obj_modify = mlx5_glue_devx_obj_modify,
1364 .devx_general_cmd = mlx5_glue_devx_general_cmd,
1365 .devx_create_cmd_comp = mlx5_glue_devx_create_cmd_comp,
1366 .devx_destroy_cmd_comp = mlx5_glue_devx_destroy_cmd_comp,
1367 .devx_obj_query_async = mlx5_glue_devx_obj_query_async,
1368 .devx_get_async_cmd_comp = mlx5_glue_devx_get_async_cmd_comp,
1369 .devx_umem_reg = mlx5_glue_devx_umem_reg,
1370 .devx_umem_dereg = mlx5_glue_devx_umem_dereg,
1371 .devx_qp_query = mlx5_glue_devx_qp_query,
1372 .devx_port_query = mlx5_glue_devx_port_query,
1373 .dr_dump_domain = mlx5_glue_dr_dump_domain,
1374 .dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
1375 .dr_create_flow_action_sampler =
1376 mlx5_glue_dr_create_flow_action_sampler,
1377 .dr_create_flow_action_dest_array =
1378 mlx5_glue_dr_action_create_dest_array,
1379 .devx_query_eqn = mlx5_glue_devx_query_eqn,
1380 .devx_create_event_channel = mlx5_glue_devx_create_event_channel,
1381 .devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
1382 .devx_subscribe_devx_event = mlx5_glue_devx_subscribe_devx_event,
1383 .devx_subscribe_devx_event_fd = mlx5_glue_devx_subscribe_devx_event_fd,
1384 .devx_get_event = mlx5_glue_devx_get_event,
1385 .devx_alloc_uar = mlx5_glue_devx_alloc_uar,
1386 .devx_free_uar = mlx5_glue_devx_free_uar,
1387 .dv_alloc_var = mlx5_glue_dv_alloc_var,
1388 .dv_free_var = mlx5_glue_dv_free_var,
1389 .dv_alloc_pp = mlx5_glue_dv_alloc_pp,
1390 .dv_free_pp = mlx5_glue_dv_free_pp,