1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox Technologies, Ltd
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.
15 #include <sys/types.h>
17 #include "mlx5_glue.h"
20 mlx5_glue_fork_init(void)
22 return ibv_fork_init();
25 static struct ibv_pd *
26 mlx5_glue_alloc_pd(struct ibv_context *context)
28 return ibv_alloc_pd(context);
32 mlx5_glue_dealloc_pd(struct ibv_pd *pd)
34 return ibv_dealloc_pd(pd);
37 static struct ibv_pd *
38 mlx5_glue_import_pd(struct ibv_context *context, uint32_t pd_handle)
40 #ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
41 return ibv_import_pd(context, pd_handle);
51 mlx5_glue_unimport_pd(struct ibv_pd *pd)
53 #ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
63 static struct ibv_device **
64 mlx5_glue_get_device_list(int *num_devices)
66 return ibv_get_device_list(num_devices);
70 mlx5_glue_free_device_list(struct ibv_device **list)
72 ibv_free_device_list(list);
75 static struct ibv_context *
76 mlx5_glue_open_device(struct ibv_device *device)
78 return ibv_open_device(device);
81 static struct ibv_context *
82 mlx5_glue_import_device(int cmd_fd)
84 #ifdef HAVE_MLX5_IBV_IMPORT_CTX_PD_AND_MR
85 return ibv_import_device(cmd_fd);
94 mlx5_glue_close_device(struct ibv_context *context)
96 return ibv_close_device(context);
100 mlx5_glue_query_device(struct ibv_context *context,
101 struct ibv_device_attr *device_attr)
103 return ibv_query_device(context, device_attr);
107 mlx5_glue_query_device_ex(struct ibv_context *context,
108 const struct ibv_query_device_ex_input *input,
109 struct ibv_device_attr_ex *attr)
111 return ibv_query_device_ex(context, input, attr);
115 mlx5_glue_query_rt_values_ex(struct ibv_context *context,
116 struct ibv_values_ex *values)
118 return ibv_query_rt_values_ex(context, values);
122 mlx5_glue_query_port(struct ibv_context *context, uint8_t port_num,
123 struct ibv_port_attr *port_attr)
125 return ibv_query_port(context, port_num, port_attr);
128 static struct ibv_comp_channel *
129 mlx5_glue_create_comp_channel(struct ibv_context *context)
131 return ibv_create_comp_channel(context);
135 mlx5_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
137 return ibv_destroy_comp_channel(channel);
140 static struct ibv_cq *
141 mlx5_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
142 struct ibv_comp_channel *channel, int comp_vector)
144 return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
148 mlx5_glue_destroy_cq(struct ibv_cq *cq)
150 return ibv_destroy_cq(cq);
154 mlx5_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
157 return ibv_get_cq_event(channel, cq, cq_context);
161 mlx5_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
163 ibv_ack_cq_events(cq, nevents);
166 static struct ibv_rwq_ind_table *
167 mlx5_glue_create_rwq_ind_table(struct ibv_context *context,
168 struct ibv_rwq_ind_table_init_attr *init_attr)
170 return ibv_create_rwq_ind_table(context, init_attr);
174 mlx5_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
176 return ibv_destroy_rwq_ind_table(rwq_ind_table);
179 static struct ibv_wq *
180 mlx5_glue_create_wq(struct ibv_context *context,
181 struct ibv_wq_init_attr *wq_init_attr)
183 return ibv_create_wq(context, wq_init_attr);
187 mlx5_glue_destroy_wq(struct ibv_wq *wq)
189 return ibv_destroy_wq(wq);
192 mlx5_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
194 return ibv_modify_wq(wq, wq_attr);
197 static struct ibv_flow *
198 mlx5_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
200 return ibv_create_flow(qp, flow);
204 mlx5_glue_destroy_flow(struct ibv_flow *flow_id)
206 return ibv_destroy_flow(flow_id);
210 mlx5_glue_destroy_flow_action(void *action)
212 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
213 #ifdef HAVE_MLX5DV_DR
214 return mlx5dv_dr_action_destroy(action);
216 struct mlx5dv_flow_action_attr *attr = action;
218 switch (attr->type) {
219 case MLX5DV_FLOW_ACTION_TAG:
222 res = ibv_destroy_flow_action(attr->action);
234 static struct ibv_qp *
235 mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
237 return ibv_create_qp(pd, qp_init_attr);
240 static struct ibv_qp *
241 mlx5_glue_create_qp_ex(struct ibv_context *context,
242 struct ibv_qp_init_attr_ex *qp_init_attr_ex)
244 return ibv_create_qp_ex(context, qp_init_attr_ex);
248 mlx5_glue_destroy_qp(struct ibv_qp *qp)
250 return ibv_destroy_qp(qp);
254 mlx5_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
256 return ibv_modify_qp(qp, attr, attr_mask);
259 static struct ibv_mr *
260 mlx5_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
262 return ibv_reg_mr(pd, addr, length, access);
265 static struct ibv_mr *
266 mlx5_glue_reg_mr_iova(struct ibv_pd *pd, void *addr, size_t length,
267 uint64_t iova, int access)
269 #ifdef HAVE_MLX5_IBV_REG_MR_IOVA
270 return ibv_reg_mr_iova(pd, addr, length, iova, access);
282 static struct ibv_mr *
283 mlx5_glue_alloc_null_mr(struct ibv_pd *pd)
285 #ifdef HAVE_IBV_DEVX_OBJ
286 return ibv_alloc_null_mr(pd);
295 mlx5_glue_dereg_mr(struct ibv_mr *mr)
297 return ibv_dereg_mr(mr);
300 static struct ibv_counter_set *
301 mlx5_glue_create_counter_set(struct ibv_context *context,
302 struct ibv_counter_set_init_attr *init_attr)
304 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
309 return ibv_create_counter_set(context, init_attr);
314 mlx5_glue_destroy_counter_set(struct ibv_counter_set *cs)
316 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
320 return ibv_destroy_counter_set(cs);
325 mlx5_glue_describe_counter_set(struct ibv_context *context,
326 uint16_t counter_set_id,
327 struct ibv_counter_set_description *cs_desc)
329 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
331 (void)counter_set_id;
335 return ibv_describe_counter_set(context, counter_set_id, cs_desc);
340 mlx5_glue_query_counter_set(struct ibv_query_counter_set_attr *query_attr,
341 struct ibv_counter_set_data *cs_data)
343 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
348 return ibv_query_counter_set(query_attr, cs_data);
352 static struct ibv_counters *
353 mlx5_glue_create_counters(struct ibv_context *context,
354 struct ibv_counters_init_attr *init_attr)
356 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
362 return ibv_create_counters(context, init_attr);
367 mlx5_glue_destroy_counters(struct ibv_counters *counters)
369 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
373 return ibv_destroy_counters(counters);
378 mlx5_glue_attach_counters(struct ibv_counters *counters,
379 struct ibv_counter_attach_attr *attr,
380 struct ibv_flow *flow)
382 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
388 return ibv_attach_counters_point_flow(counters, attr, flow);
393 mlx5_glue_query_counters(struct ibv_counters *counters,
394 uint64_t *counters_value,
398 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
400 (void)counters_value;
405 return ibv_read_counters(counters, counters_value, ncounters, flags);
410 mlx5_glue_ack_async_event(struct ibv_async_event *event)
412 ibv_ack_async_event(event);
416 mlx5_glue_get_async_event(struct ibv_context *context,
417 struct ibv_async_event *event)
419 return ibv_get_async_event(context, event);
423 mlx5_glue_port_state_str(enum ibv_port_state port_state)
425 return ibv_port_state_str(port_state);
428 static struct ibv_cq *
429 mlx5_glue_cq_ex_to_cq(struct ibv_cq_ex *cq)
431 return ibv_cq_ex_to_cq(cq);
435 mlx5_glue_dr_create_flow_action_dest_flow_tbl(void *tbl)
437 #ifdef HAVE_MLX5DV_DR
438 return mlx5dv_dr_action_create_dest_table(tbl);
447 mlx5_glue_dr_create_flow_action_dest_port(void *domain, uint32_t port)
449 #ifdef HAVE_MLX5DV_DR_CREATE_DEST_IB_PORT
450 return mlx5dv_dr_action_create_dest_ib_port(domain, port);
452 #ifdef HAVE_MLX5DV_DR_ESWITCH
453 return mlx5dv_dr_action_create_dest_vport(domain, port);
464 mlx5_glue_dr_create_flow_action_drop(void)
466 #ifdef HAVE_MLX5DV_DR_ESWITCH
467 return mlx5dv_dr_action_create_drop();
475 mlx5_glue_dr_create_flow_action_push_vlan(struct mlx5dv_dr_domain *domain,
478 #ifdef HAVE_MLX5DV_DR_VLAN
479 return mlx5dv_dr_action_create_push_vlan(domain, vlan_tag);
489 mlx5_glue_dr_create_flow_action_pop_vlan(void)
491 #ifdef HAVE_MLX5DV_DR_VLAN
492 return mlx5dv_dr_action_create_pop_vlan();
500 mlx5_glue_dr_create_flow_tbl(void *domain, uint32_t level)
502 #ifdef HAVE_MLX5DV_DR
503 return mlx5dv_dr_table_create(domain, level);
513 mlx5_glue_dr_destroy_flow_tbl(void *tbl)
515 #ifdef HAVE_MLX5DV_DR
516 return mlx5dv_dr_table_destroy(tbl);
525 mlx5_glue_dr_create_domain(struct ibv_context *ctx,
526 enum mlx5dv_dr_domain_type domain)
528 #ifdef HAVE_MLX5DV_DR
529 return mlx5dv_dr_domain_create(ctx, domain);
539 mlx5_glue_dr_destroy_domain(void *domain)
541 #ifdef HAVE_MLX5DV_DR
542 return mlx5dv_dr_domain_destroy(domain);
551 mlx5_glue_dr_sync_domain(void *domain, uint32_t flags)
553 #ifdef HAVE_MLX5DV_DR
554 return mlx5dv_dr_domain_sync(domain, flags);
563 static struct ibv_cq_ex *
564 mlx5_glue_dv_create_cq(struct ibv_context *context,
565 struct ibv_cq_init_attr_ex *cq_attr,
566 struct mlx5dv_cq_init_attr *mlx5_cq_attr)
568 return mlx5dv_create_cq(context, cq_attr, mlx5_cq_attr);
571 static struct ibv_wq *
572 mlx5_glue_dv_create_wq(struct ibv_context *context,
573 struct ibv_wq_init_attr *wq_attr,
574 struct mlx5dv_wq_init_attr *mlx5_wq_attr)
576 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
583 return mlx5dv_create_wq(context, wq_attr, mlx5_wq_attr);
588 mlx5_glue_dv_query_device(struct ibv_context *ctx,
589 struct mlx5dv_context *attrs_out)
591 return mlx5dv_query_device(ctx, attrs_out);
595 mlx5_glue_dv_set_context_attr(struct ibv_context *ibv_ctx,
596 enum mlx5dv_set_ctx_attr_type type, void *attr)
598 return mlx5dv_set_context_attr(ibv_ctx, type, attr);
602 mlx5_glue_dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type)
604 return mlx5dv_init_obj(obj, obj_type);
607 static struct ibv_qp *
608 mlx5_glue_dv_create_qp(struct ibv_context *context,
609 struct ibv_qp_init_attr_ex *qp_init_attr_ex,
610 struct mlx5dv_qp_init_attr *dv_qp_init_attr)
612 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
613 return mlx5dv_create_qp(context, qp_init_attr_ex, dv_qp_init_attr);
616 (void)qp_init_attr_ex;
617 (void)dv_qp_init_attr;
624 mlx5_glue_dv_create_flow_matcher(struct ibv_context *context,
625 struct mlx5dv_flow_matcher_attr *matcher_attr,
628 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
629 #ifdef HAVE_MLX5DV_DR
631 return mlx5dv_dr_matcher_create(tbl, matcher_attr->priority,
632 matcher_attr->match_criteria_enable,
633 matcher_attr->match_mask);
636 return mlx5dv_create_flow_matcher(context, matcher_attr);
648 mlx5_glue_dv_create_flow(void *matcher,
653 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
654 #ifdef HAVE_MLX5DV_DR
655 return mlx5dv_dr_rule_create(matcher, match_value, num_actions,
656 (struct mlx5dv_dr_action **)actions);
659 struct mlx5dv_flow_action_attr actions_attr[8];
663 for (i = 0; i < num_actions; i++)
665 *((struct mlx5dv_flow_action_attr *)(actions[i]));
666 return mlx5dv_create_flow(matcher, match_value,
667 num_actions, actions_attr);
679 mlx5_glue_dv_create_flow_action_counter(void *counter_obj, uint32_t offset)
681 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
682 #ifdef HAVE_MLX5DV_DR
683 return mlx5dv_dr_action_create_flow_counter(counter_obj, offset);
685 struct mlx5dv_flow_action_attr *action;
688 action = malloc(sizeof(*action));
691 action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
692 action->obj = counter_obj;
704 mlx5_glue_dv_create_flow_action_dest_ibv_qp(void *qp)
706 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
707 #ifdef HAVE_MLX5DV_DR
708 return mlx5dv_dr_action_create_dest_ibv_qp(qp);
710 struct mlx5dv_flow_action_attr *action;
712 action = malloc(sizeof(*action));
715 action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
727 mlx5_glue_dv_create_flow_action_dest_devx_tir(void *tir)
729 #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR
730 return mlx5dv_dr_action_create_dest_devx_tir(tir);
739 mlx5_glue_dv_create_flow_action_modify_header
740 (struct ibv_context *ctx,
741 enum mlx5dv_flow_table_type ft_type,
742 void *domain, uint64_t flags,
746 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
747 #ifdef HAVE_MLX5DV_DR
750 return mlx5dv_dr_action_create_modify_header(domain, flags, actions_sz,
753 struct mlx5dv_flow_action_attr *action;
757 action = malloc(sizeof(*action));
760 action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
761 action->action = mlx5dv_create_flow_action_modify_header
762 (ctx, actions_sz, actions, ft_type);
778 mlx5_glue_dv_create_flow_action_packet_reformat
779 (struct ibv_context *ctx,
780 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
781 enum mlx5dv_flow_table_type ft_type,
782 struct mlx5dv_dr_domain *domain,
783 uint32_t flags, size_t data_sz, void *data)
785 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
786 #ifdef HAVE_MLX5DV_DR
789 return mlx5dv_dr_action_create_packet_reformat(domain, flags,
790 reformat_type, data_sz,
795 struct mlx5dv_flow_action_attr *action;
797 action = malloc(sizeof(*action));
800 action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
801 action->action = mlx5dv_create_flow_action_packet_reformat
802 (ctx, data_sz, data, reformat_type, ft_type);
819 mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
821 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
822 #ifdef HAVE_MLX5DV_DR
823 return mlx5dv_dr_action_create_tag(tag);
824 #else /* HAVE_MLX5DV_DR */
825 struct mlx5dv_flow_action_attr *action;
827 action = malloc(sizeof(*action));
830 action->type = MLX5DV_FLOW_ACTION_TAG;
831 action->tag_value = tag;
833 #endif /* HAVE_MLX5DV_DR */
834 #else /* HAVE_IBV_FLOW_DV_SUPPORT */
838 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
842 mlx5_glue_dv_create_flow_action_meter(struct mlx5dv_dr_flow_meter_attr *attr)
844 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
845 return mlx5dv_dr_action_create_flow_meter(attr);
854 mlx5_glue_dv_modify_flow_action_meter(void *action,
855 struct mlx5dv_dr_flow_meter_attr *attr,
856 uint64_t modify_bits)
858 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
859 return mlx5dv_dr_action_modify_flow_meter(action, attr, modify_bits);
870 mlx5_glue_dv_create_flow_action_aso(struct mlx5dv_dr_domain *domain,
874 uint8_t return_reg_c)
876 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_ASO)
877 return mlx5dv_dr_action_create_aso(domain, aso_obj, offset,
878 flags, return_reg_c);
891 mlx5_glue_dr_create_flow_action_default_miss(void)
893 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS)
894 return mlx5dv_dr_action_create_default_miss();
902 mlx5_glue_dv_destroy_flow(void *flow_id)
904 #ifdef HAVE_MLX5DV_DR
905 return mlx5dv_dr_rule_destroy(flow_id);
907 return ibv_destroy_flow(flow_id);
912 mlx5_glue_dv_destroy_flow_matcher(void *matcher)
914 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
915 #ifdef HAVE_MLX5DV_DR
916 return mlx5dv_dr_matcher_destroy(matcher);
918 return mlx5dv_destroy_flow_matcher(matcher);
927 static struct ibv_context *
928 mlx5_glue_dv_open_device(struct ibv_device *device)
930 #ifdef HAVE_IBV_DEVX_OBJ
931 return mlx5dv_open_device(device,
932 &(struct mlx5dv_context_attr){
933 .flags = MLX5DV_CONTEXT_FLAGS_DEVX,
942 static struct mlx5dv_devx_obj *
943 mlx5_glue_devx_obj_create(struct ibv_context *ctx,
944 const void *in, size_t inlen,
945 void *out, size_t outlen)
947 #ifdef HAVE_IBV_DEVX_OBJ
948 return mlx5dv_devx_obj_create(ctx, in, inlen, out, outlen);
961 mlx5_glue_devx_obj_destroy(struct mlx5dv_devx_obj *obj)
963 #ifdef HAVE_IBV_DEVX_OBJ
964 return mlx5dv_devx_obj_destroy(obj);
972 mlx5_glue_devx_obj_query(struct mlx5dv_devx_obj *obj,
973 const void *in, size_t inlen,
974 void *out, size_t outlen)
976 #ifdef HAVE_IBV_DEVX_OBJ
977 return mlx5dv_devx_obj_query(obj, in, inlen, out, outlen);
989 mlx5_glue_devx_obj_modify(struct mlx5dv_devx_obj *obj,
990 const void *in, size_t inlen,
991 void *out, size_t outlen)
993 #ifdef HAVE_IBV_DEVX_OBJ
994 return mlx5dv_devx_obj_modify(obj, in, inlen, out, outlen);
1006 mlx5_glue_devx_general_cmd(struct ibv_context *ctx,
1007 const void *in, size_t inlen,
1008 void *out, size_t outlen)
1010 #ifdef HAVE_IBV_DEVX_OBJ
1011 return mlx5dv_devx_general_cmd(ctx, in, inlen, out, outlen);
1022 static struct mlx5dv_devx_cmd_comp *
1023 mlx5_glue_devx_create_cmd_comp(struct ibv_context *ctx)
1025 #ifdef HAVE_IBV_DEVX_ASYNC
1026 return mlx5dv_devx_create_cmd_comp(ctx);
1035 mlx5_glue_devx_destroy_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp)
1037 #ifdef HAVE_IBV_DEVX_ASYNC
1038 mlx5dv_devx_destroy_cmd_comp(cmd_comp);
1046 mlx5_glue_devx_obj_query_async(struct mlx5dv_devx_obj *obj, const void *in,
1047 size_t inlen, size_t outlen, uint64_t wr_id,
1048 struct mlx5dv_devx_cmd_comp *cmd_comp)
1050 #ifdef HAVE_IBV_DEVX_ASYNC
1051 return mlx5dv_devx_obj_query_async(obj, in, inlen, outlen, wr_id,
1065 mlx5_glue_devx_get_async_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp,
1066 struct mlx5dv_devx_async_cmd_hdr *cmd_resp,
1067 size_t cmd_resp_len)
1069 #ifdef HAVE_IBV_DEVX_ASYNC
1070 return mlx5dv_devx_get_async_cmd_comp(cmd_comp, cmd_resp,
1080 static struct mlx5dv_devx_umem *
1081 mlx5_glue_devx_umem_reg(struct ibv_context *context, void *addr, size_t size,
1084 #ifdef HAVE_IBV_DEVX_OBJ
1085 return mlx5dv_devx_umem_reg(context, addr, size, access);
1097 mlx5_glue_devx_umem_dereg(struct mlx5dv_devx_umem *dv_devx_umem)
1099 #ifdef HAVE_IBV_DEVX_OBJ
1100 return mlx5dv_devx_umem_dereg(dv_devx_umem);
1108 mlx5_glue_devx_qp_query(struct ibv_qp *qp,
1109 const void *in, size_t inlen,
1110 void *out, size_t outlen)
1112 #ifdef HAVE_IBV_DEVX_QP
1113 return mlx5dv_devx_qp_query(qp, in, inlen, out, outlen);
1126 mlx5_glue_devx_wq_query(struct ibv_wq *wq, const void *in, size_t inlen,
1127 void *out, size_t outlen)
1129 #ifdef HAVE_IBV_DEVX_QP
1130 return mlx5dv_devx_wq_query(wq, in, inlen, out, outlen);
1143 mlx5_glue_devx_port_query(struct ibv_context *ctx,
1145 struct mlx5_port_info *info)
1149 info->query_flags = 0;
1150 #ifdef HAVE_MLX5DV_DR_DEVX_PORT_V35
1151 /* The DevX port query API is implemented (rdma-core v35 and above). */
1152 struct mlx5_ib_uapi_query_port devx_port;
1154 memset(&devx_port, 0, sizeof(devx_port));
1155 err = mlx5dv_query_port(ctx, port_num, &devx_port);
1158 if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT_REG_C0) {
1159 info->vport_meta_tag = devx_port.reg_c0.value;
1160 info->vport_meta_mask = devx_port.reg_c0.mask;
1161 info->query_flags |= MLX5_PORT_QUERY_REG_C0;
1163 if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT) {
1164 info->vport_id = devx_port.vport;
1165 info->query_flags |= MLX5_PORT_QUERY_VPORT;
1168 #ifdef HAVE_MLX5DV_DR_DEVX_PORT
1169 /* The legacy DevX port query API is implemented (prior v35). */
1170 struct mlx5dv_devx_port devx_port = {
1171 .comp_mask = MLX5DV_DEVX_PORT_VPORT |
1172 MLX5DV_DEVX_PORT_MATCH_REG_C_0
1175 err = mlx5dv_query_devx_port(ctx, port_num, &devx_port);
1178 if (devx_port.comp_mask & MLX5DV_DEVX_PORT_MATCH_REG_C_0) {
1179 info->vport_meta_tag = devx_port.reg_c_0.value;
1180 info->vport_meta_mask = devx_port.reg_c_0.mask;
1181 info->query_flags |= MLX5_PORT_QUERY_REG_C0;
1183 if (devx_port.comp_mask & MLX5DV_DEVX_PORT_VPORT) {
1184 info->vport_id = devx_port.vport_num;
1185 info->query_flags |= MLX5_PORT_QUERY_VPORT;
1189 RTE_SET_USED(port_num);
1190 #endif /* HAVE_MLX5DV_DR_DEVX_PORT */
1191 #endif /* HAVE_MLX5DV_DR_DEVX_PORT_V35 */
1196 mlx5_glue_dr_dump_single_rule(FILE *file, void *rule)
1198 #ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
1199 return mlx5dv_dump_dr_rule(file, rule);
1208 mlx5_glue_dr_dump_domain(FILE *file, void *domain)
1210 #ifdef HAVE_MLX5_DR_FLOW_DUMP
1211 return mlx5dv_dump_dr_domain(file, domain);
1214 RTE_SET_USED(domain);
1220 mlx5_glue_dr_create_flow_action_sampler
1221 (struct mlx5dv_dr_flow_sampler_attr *attr)
1223 #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
1224 return mlx5dv_dr_action_create_flow_sampler(attr);
1233 mlx5_glue_dr_action_create_dest_array
1236 struct mlx5dv_dr_action_dest_attr *dests[])
1238 #ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY
1239 return mlx5dv_dr_action_create_dest_array
1253 mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
1256 #ifdef HAVE_IBV_DEVX_OBJ
1257 return mlx5dv_devx_query_eqn(ctx, cpus, eqn);
1266 static struct mlx5dv_devx_event_channel *
1267 mlx5_glue_devx_create_event_channel(struct ibv_context *ctx, int flags)
1269 #ifdef HAVE_IBV_DEVX_EVENT
1270 return mlx5dv_devx_create_event_channel(ctx, flags);
1280 mlx5_glue_devx_destroy_event_channel(struct mlx5dv_devx_event_channel *eventc)
1282 #ifdef HAVE_IBV_DEVX_EVENT
1283 mlx5dv_devx_destroy_event_channel(eventc);
1290 mlx5_glue_devx_subscribe_devx_event(struct mlx5dv_devx_event_channel *eventc,
1291 struct mlx5dv_devx_obj *obj,
1292 uint16_t events_sz, uint16_t events_num[],
1295 #ifdef HAVE_IBV_DEVX_EVENT
1296 return mlx5dv_devx_subscribe_devx_event(eventc, obj, events_sz,
1297 events_num, cookie);
1309 mlx5_glue_devx_subscribe_devx_event_fd(struct mlx5dv_devx_event_channel *eventc,
1310 int fd, struct mlx5dv_devx_obj *obj,
1313 #ifdef HAVE_IBV_DEVX_EVENT
1314 return mlx5dv_devx_subscribe_devx_event_fd(eventc, fd, obj, event_num);
1325 mlx5_glue_devx_get_event(struct mlx5dv_devx_event_channel *eventc,
1326 struct mlx5dv_devx_async_event_hdr *event_data,
1327 size_t event_resp_len)
1329 #ifdef HAVE_IBV_DEVX_EVENT
1330 return mlx5dv_devx_get_event(eventc, event_data, event_resp_len);
1334 (void)event_resp_len;
1340 static struct mlx5dv_devx_uar *
1341 mlx5_glue_devx_alloc_uar(struct ibv_context *context, uint32_t flags)
1343 #ifdef HAVE_IBV_DEVX_OBJ
1344 return mlx5dv_devx_alloc_uar(context, flags);
1354 mlx5_glue_devx_free_uar(struct mlx5dv_devx_uar *devx_uar)
1356 #ifdef HAVE_IBV_DEVX_OBJ
1357 mlx5dv_devx_free_uar(devx_uar);
1363 static struct mlx5dv_var *
1364 mlx5_glue_dv_alloc_var(struct ibv_context *context, uint32_t flags)
1367 return mlx5dv_alloc_var(context, flags);
1377 mlx5_glue_dv_free_var(struct mlx5dv_var *var)
1380 mlx5dv_free_var(var);
1388 mlx5_glue_dr_reclaim_domain_memory(void *domain, uint32_t enable)
1390 #ifdef HAVE_MLX5DV_DR_MEM_RECLAIM
1391 mlx5dv_dr_domain_set_reclaim_device_memory(domain, enable);
1398 static struct mlx5dv_pp *
1399 mlx5_glue_dv_alloc_pp(struct ibv_context *context,
1400 size_t pp_context_sz,
1401 const void *pp_context,
1404 #ifdef HAVE_MLX5DV_PP_ALLOC
1405 return mlx5dv_pp_alloc(context, pp_context_sz, pp_context, flags);
1407 RTE_SET_USED(context);
1408 RTE_SET_USED(pp_context_sz);
1409 RTE_SET_USED(pp_context);
1410 RTE_SET_USED(flags);
1417 mlx5_glue_dr_allow_duplicate_rules(void *domain, uint32_t allow)
1419 #ifdef HAVE_MLX5_DR_ALLOW_DUPLICATE
1420 mlx5dv_dr_domain_allow_duplicate_rules(domain, allow);
1428 mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
1430 #ifdef HAVE_MLX5DV_PP_ALLOC
1438 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
1439 .version = MLX5_GLUE_VERSION,
1440 .fork_init = mlx5_glue_fork_init,
1441 .alloc_pd = mlx5_glue_alloc_pd,
1442 .dealloc_pd = mlx5_glue_dealloc_pd,
1443 .import_pd = mlx5_glue_import_pd,
1444 .unimport_pd = mlx5_glue_unimport_pd,
1445 .get_device_list = mlx5_glue_get_device_list,
1446 .free_device_list = mlx5_glue_free_device_list,
1447 .open_device = mlx5_glue_open_device,
1448 .import_device = mlx5_glue_import_device,
1449 .close_device = mlx5_glue_close_device,
1450 .query_device = mlx5_glue_query_device,
1451 .query_device_ex = mlx5_glue_query_device_ex,
1452 .query_rt_values_ex = mlx5_glue_query_rt_values_ex,
1453 .query_port = mlx5_glue_query_port,
1454 .create_comp_channel = mlx5_glue_create_comp_channel,
1455 .destroy_comp_channel = mlx5_glue_destroy_comp_channel,
1456 .create_cq = mlx5_glue_create_cq,
1457 .destroy_cq = mlx5_glue_destroy_cq,
1458 .get_cq_event = mlx5_glue_get_cq_event,
1459 .ack_cq_events = mlx5_glue_ack_cq_events,
1460 .create_rwq_ind_table = mlx5_glue_create_rwq_ind_table,
1461 .destroy_rwq_ind_table = mlx5_glue_destroy_rwq_ind_table,
1462 .create_wq = mlx5_glue_create_wq,
1463 .destroy_wq = mlx5_glue_destroy_wq,
1464 .modify_wq = mlx5_glue_modify_wq,
1465 .create_flow = mlx5_glue_create_flow,
1466 .destroy_flow = mlx5_glue_destroy_flow,
1467 .destroy_flow_action = mlx5_glue_destroy_flow_action,
1468 .create_qp = mlx5_glue_create_qp,
1469 .create_qp_ex = mlx5_glue_create_qp_ex,
1470 .destroy_qp = mlx5_glue_destroy_qp,
1471 .modify_qp = mlx5_glue_modify_qp,
1472 .reg_mr = mlx5_glue_reg_mr,
1473 .reg_mr_iova = mlx5_glue_reg_mr_iova,
1474 .alloc_null_mr = mlx5_glue_alloc_null_mr,
1475 .dereg_mr = mlx5_glue_dereg_mr,
1476 .create_counter_set = mlx5_glue_create_counter_set,
1477 .destroy_counter_set = mlx5_glue_destroy_counter_set,
1478 .describe_counter_set = mlx5_glue_describe_counter_set,
1479 .query_counter_set = mlx5_glue_query_counter_set,
1480 .create_counters = mlx5_glue_create_counters,
1481 .destroy_counters = mlx5_glue_destroy_counters,
1482 .attach_counters = mlx5_glue_attach_counters,
1483 .query_counters = mlx5_glue_query_counters,
1484 .ack_async_event = mlx5_glue_ack_async_event,
1485 .get_async_event = mlx5_glue_get_async_event,
1486 .port_state_str = mlx5_glue_port_state_str,
1487 .cq_ex_to_cq = mlx5_glue_cq_ex_to_cq,
1488 .dr_create_flow_action_dest_flow_tbl =
1489 mlx5_glue_dr_create_flow_action_dest_flow_tbl,
1490 .dr_create_flow_action_dest_port =
1491 mlx5_glue_dr_create_flow_action_dest_port,
1492 .dr_create_flow_action_drop =
1493 mlx5_glue_dr_create_flow_action_drop,
1494 .dr_create_flow_action_push_vlan =
1495 mlx5_glue_dr_create_flow_action_push_vlan,
1496 .dr_create_flow_action_pop_vlan =
1497 mlx5_glue_dr_create_flow_action_pop_vlan,
1498 .dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
1499 .dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
1500 .dr_create_domain = mlx5_glue_dr_create_domain,
1501 .dr_destroy_domain = mlx5_glue_dr_destroy_domain,
1502 .dr_sync_domain = mlx5_glue_dr_sync_domain,
1503 .dv_create_cq = mlx5_glue_dv_create_cq,
1504 .dv_create_wq = mlx5_glue_dv_create_wq,
1505 .dv_query_device = mlx5_glue_dv_query_device,
1506 .dv_set_context_attr = mlx5_glue_dv_set_context_attr,
1507 .dv_init_obj = mlx5_glue_dv_init_obj,
1508 .dv_create_qp = mlx5_glue_dv_create_qp,
1509 .dv_create_flow_matcher = mlx5_glue_dv_create_flow_matcher,
1510 .dv_create_flow = mlx5_glue_dv_create_flow,
1511 .dv_create_flow_action_counter =
1512 mlx5_glue_dv_create_flow_action_counter,
1513 .dv_create_flow_action_dest_ibv_qp =
1514 mlx5_glue_dv_create_flow_action_dest_ibv_qp,
1515 .dv_create_flow_action_dest_devx_tir =
1516 mlx5_glue_dv_create_flow_action_dest_devx_tir,
1517 .dv_create_flow_action_modify_header =
1518 mlx5_glue_dv_create_flow_action_modify_header,
1519 .dv_create_flow_action_packet_reformat =
1520 mlx5_glue_dv_create_flow_action_packet_reformat,
1521 .dv_create_flow_action_tag = mlx5_glue_dv_create_flow_action_tag,
1522 .dv_create_flow_action_meter = mlx5_glue_dv_create_flow_action_meter,
1523 .dv_modify_flow_action_meter = mlx5_glue_dv_modify_flow_action_meter,
1524 .dv_create_flow_action_aso = mlx5_glue_dv_create_flow_action_aso,
1525 .dr_create_flow_action_default_miss =
1526 mlx5_glue_dr_create_flow_action_default_miss,
1527 .dv_destroy_flow = mlx5_glue_dv_destroy_flow,
1528 .dv_destroy_flow_matcher = mlx5_glue_dv_destroy_flow_matcher,
1529 .dv_open_device = mlx5_glue_dv_open_device,
1530 .devx_obj_create = mlx5_glue_devx_obj_create,
1531 .devx_obj_destroy = mlx5_glue_devx_obj_destroy,
1532 .devx_obj_query = mlx5_glue_devx_obj_query,
1533 .devx_obj_modify = mlx5_glue_devx_obj_modify,
1534 .devx_general_cmd = mlx5_glue_devx_general_cmd,
1535 .devx_create_cmd_comp = mlx5_glue_devx_create_cmd_comp,
1536 .devx_destroy_cmd_comp = mlx5_glue_devx_destroy_cmd_comp,
1537 .devx_obj_query_async = mlx5_glue_devx_obj_query_async,
1538 .devx_get_async_cmd_comp = mlx5_glue_devx_get_async_cmd_comp,
1539 .devx_umem_reg = mlx5_glue_devx_umem_reg,
1540 .devx_umem_dereg = mlx5_glue_devx_umem_dereg,
1541 .devx_qp_query = mlx5_glue_devx_qp_query,
1542 .devx_wq_query = mlx5_glue_devx_wq_query,
1543 .devx_port_query = mlx5_glue_devx_port_query,
1544 .dr_dump_domain = mlx5_glue_dr_dump_domain,
1545 .dr_dump_rule = mlx5_glue_dr_dump_single_rule,
1546 .dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
1547 .dr_create_flow_action_sampler =
1548 mlx5_glue_dr_create_flow_action_sampler,
1549 .dr_create_flow_action_dest_array =
1550 mlx5_glue_dr_action_create_dest_array,
1551 .dr_allow_duplicate_rules = mlx5_glue_dr_allow_duplicate_rules,
1552 .devx_query_eqn = mlx5_glue_devx_query_eqn,
1553 .devx_create_event_channel = mlx5_glue_devx_create_event_channel,
1554 .devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
1555 .devx_subscribe_devx_event = mlx5_glue_devx_subscribe_devx_event,
1556 .devx_subscribe_devx_event_fd = mlx5_glue_devx_subscribe_devx_event_fd,
1557 .devx_get_event = mlx5_glue_devx_get_event,
1558 .devx_alloc_uar = mlx5_glue_devx_alloc_uar,
1559 .devx_free_uar = mlx5_glue_devx_free_uar,
1560 .dv_alloc_var = mlx5_glue_dv_alloc_var,
1561 .dv_free_var = mlx5_glue_dv_free_var,
1562 .dv_alloc_pp = mlx5_glue_dv_alloc_pp,
1563 .dv_free_pp = mlx5_glue_dv_free_pp,