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_device **
38 mlx5_glue_get_device_list(int *num_devices)
40 return ibv_get_device_list(num_devices);
44 mlx5_glue_free_device_list(struct ibv_device **list)
46 ibv_free_device_list(list);
49 static struct ibv_context *
50 mlx5_glue_open_device(struct ibv_device *device)
52 return ibv_open_device(device);
56 mlx5_glue_close_device(struct ibv_context *context)
58 return ibv_close_device(context);
62 mlx5_glue_query_device(struct ibv_context *context,
63 struct ibv_device_attr *device_attr)
65 return ibv_query_device(context, device_attr);
69 mlx5_glue_query_device_ex(struct ibv_context *context,
70 const struct ibv_query_device_ex_input *input,
71 struct ibv_device_attr_ex *attr)
73 return ibv_query_device_ex(context, input, attr);
77 mlx5_glue_query_rt_values_ex(struct ibv_context *context,
78 struct ibv_values_ex *values)
80 return ibv_query_rt_values_ex(context, values);
84 mlx5_glue_query_port(struct ibv_context *context, uint8_t port_num,
85 struct ibv_port_attr *port_attr)
87 return ibv_query_port(context, port_num, port_attr);
90 static struct ibv_comp_channel *
91 mlx5_glue_create_comp_channel(struct ibv_context *context)
93 return ibv_create_comp_channel(context);
97 mlx5_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
99 return ibv_destroy_comp_channel(channel);
102 static struct ibv_cq *
103 mlx5_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
104 struct ibv_comp_channel *channel, int comp_vector)
106 return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
110 mlx5_glue_destroy_cq(struct ibv_cq *cq)
112 return ibv_destroy_cq(cq);
116 mlx5_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
119 return ibv_get_cq_event(channel, cq, cq_context);
123 mlx5_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
125 ibv_ack_cq_events(cq, nevents);
128 static struct ibv_rwq_ind_table *
129 mlx5_glue_create_rwq_ind_table(struct ibv_context *context,
130 struct ibv_rwq_ind_table_init_attr *init_attr)
132 return ibv_create_rwq_ind_table(context, init_attr);
136 mlx5_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
138 return ibv_destroy_rwq_ind_table(rwq_ind_table);
141 static struct ibv_wq *
142 mlx5_glue_create_wq(struct ibv_context *context,
143 struct ibv_wq_init_attr *wq_init_attr)
145 return ibv_create_wq(context, wq_init_attr);
149 mlx5_glue_destroy_wq(struct ibv_wq *wq)
151 return ibv_destroy_wq(wq);
154 mlx5_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
156 return ibv_modify_wq(wq, wq_attr);
159 static struct ibv_flow *
160 mlx5_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
162 return ibv_create_flow(qp, flow);
166 mlx5_glue_destroy_flow(struct ibv_flow *flow_id)
168 return ibv_destroy_flow(flow_id);
172 mlx5_glue_destroy_flow_action(void *action)
174 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
175 #ifdef HAVE_MLX5DV_DR
176 return mlx5dv_dr_action_destroy(action);
178 struct mlx5dv_flow_action_attr *attr = action;
180 switch (attr->type) {
181 case MLX5DV_FLOW_ACTION_TAG:
184 res = ibv_destroy_flow_action(attr->action);
196 static struct ibv_qp *
197 mlx5_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
199 return ibv_create_qp(pd, qp_init_attr);
202 static struct ibv_qp *
203 mlx5_glue_create_qp_ex(struct ibv_context *context,
204 struct ibv_qp_init_attr_ex *qp_init_attr_ex)
206 return ibv_create_qp_ex(context, qp_init_attr_ex);
210 mlx5_glue_destroy_qp(struct ibv_qp *qp)
212 return ibv_destroy_qp(qp);
216 mlx5_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
218 return ibv_modify_qp(qp, attr, attr_mask);
221 static struct ibv_mr *
222 mlx5_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
224 return ibv_reg_mr(pd, addr, length, access);
227 static struct ibv_mr *
228 mlx5_glue_alloc_null_mr(struct ibv_pd *pd)
230 #ifdef HAVE_IBV_DEVX_OBJ
231 return ibv_alloc_null_mr(pd);
240 mlx5_glue_dereg_mr(struct ibv_mr *mr)
242 return ibv_dereg_mr(mr);
245 static struct ibv_counter_set *
246 mlx5_glue_create_counter_set(struct ibv_context *context,
247 struct ibv_counter_set_init_attr *init_attr)
249 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
254 return ibv_create_counter_set(context, init_attr);
259 mlx5_glue_destroy_counter_set(struct ibv_counter_set *cs)
261 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
265 return ibv_destroy_counter_set(cs);
270 mlx5_glue_describe_counter_set(struct ibv_context *context,
271 uint16_t counter_set_id,
272 struct ibv_counter_set_description *cs_desc)
274 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
276 (void)counter_set_id;
280 return ibv_describe_counter_set(context, counter_set_id, cs_desc);
285 mlx5_glue_query_counter_set(struct ibv_query_counter_set_attr *query_attr,
286 struct ibv_counter_set_data *cs_data)
288 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
293 return ibv_query_counter_set(query_attr, cs_data);
297 static struct ibv_counters *
298 mlx5_glue_create_counters(struct ibv_context *context,
299 struct ibv_counters_init_attr *init_attr)
301 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
307 return ibv_create_counters(context, init_attr);
312 mlx5_glue_destroy_counters(struct ibv_counters *counters)
314 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
318 return ibv_destroy_counters(counters);
323 mlx5_glue_attach_counters(struct ibv_counters *counters,
324 struct ibv_counter_attach_attr *attr,
325 struct ibv_flow *flow)
327 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
333 return ibv_attach_counters_point_flow(counters, attr, flow);
338 mlx5_glue_query_counters(struct ibv_counters *counters,
339 uint64_t *counters_value,
343 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
345 (void)counters_value;
350 return ibv_read_counters(counters, counters_value, ncounters, flags);
355 mlx5_glue_ack_async_event(struct ibv_async_event *event)
357 ibv_ack_async_event(event);
361 mlx5_glue_get_async_event(struct ibv_context *context,
362 struct ibv_async_event *event)
364 return ibv_get_async_event(context, event);
368 mlx5_glue_port_state_str(enum ibv_port_state port_state)
370 return ibv_port_state_str(port_state);
373 static struct ibv_cq *
374 mlx5_glue_cq_ex_to_cq(struct ibv_cq_ex *cq)
376 return ibv_cq_ex_to_cq(cq);
380 mlx5_glue_dr_create_flow_action_dest_flow_tbl(void *tbl)
382 #ifdef HAVE_MLX5DV_DR
383 return mlx5dv_dr_action_create_dest_table(tbl);
392 mlx5_glue_dr_create_flow_action_dest_port(void *domain, uint32_t port)
394 #ifdef HAVE_MLX5DV_DR_CREATE_DEST_IB_PORT
395 return mlx5dv_dr_action_create_dest_ib_port(domain, port);
397 #ifdef HAVE_MLX5DV_DR_ESWITCH
398 return mlx5dv_dr_action_create_dest_vport(domain, port);
409 mlx5_glue_dr_create_flow_action_drop(void)
411 #ifdef HAVE_MLX5DV_DR_ESWITCH
412 return mlx5dv_dr_action_create_drop();
420 mlx5_glue_dr_create_flow_action_push_vlan(struct mlx5dv_dr_domain *domain,
423 #ifdef HAVE_MLX5DV_DR_VLAN
424 return mlx5dv_dr_action_create_push_vlan(domain, vlan_tag);
434 mlx5_glue_dr_create_flow_action_pop_vlan(void)
436 #ifdef HAVE_MLX5DV_DR_VLAN
437 return mlx5dv_dr_action_create_pop_vlan();
445 mlx5_glue_dr_create_flow_tbl(void *domain, uint32_t level)
447 #ifdef HAVE_MLX5DV_DR
448 return mlx5dv_dr_table_create(domain, level);
458 mlx5_glue_dr_destroy_flow_tbl(void *tbl)
460 #ifdef HAVE_MLX5DV_DR
461 return mlx5dv_dr_table_destroy(tbl);
470 mlx5_glue_dr_create_domain(struct ibv_context *ctx,
471 enum mlx5dv_dr_domain_type domain)
473 #ifdef HAVE_MLX5DV_DR
474 return mlx5dv_dr_domain_create(ctx, domain);
484 mlx5_glue_dr_destroy_domain(void *domain)
486 #ifdef HAVE_MLX5DV_DR
487 return mlx5dv_dr_domain_destroy(domain);
496 mlx5_glue_dr_sync_domain(void *domain, uint32_t flags)
498 #ifdef HAVE_MLX5DV_DR
499 return mlx5dv_dr_domain_sync(domain, flags);
508 static struct ibv_cq_ex *
509 mlx5_glue_dv_create_cq(struct ibv_context *context,
510 struct ibv_cq_init_attr_ex *cq_attr,
511 struct mlx5dv_cq_init_attr *mlx5_cq_attr)
513 return mlx5dv_create_cq(context, cq_attr, mlx5_cq_attr);
516 static struct ibv_wq *
517 mlx5_glue_dv_create_wq(struct ibv_context *context,
518 struct ibv_wq_init_attr *wq_attr,
519 struct mlx5dv_wq_init_attr *mlx5_wq_attr)
521 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
528 return mlx5dv_create_wq(context, wq_attr, mlx5_wq_attr);
533 mlx5_glue_dv_query_device(struct ibv_context *ctx,
534 struct mlx5dv_context *attrs_out)
536 return mlx5dv_query_device(ctx, attrs_out);
540 mlx5_glue_dv_set_context_attr(struct ibv_context *ibv_ctx,
541 enum mlx5dv_set_ctx_attr_type type, void *attr)
543 return mlx5dv_set_context_attr(ibv_ctx, type, attr);
547 mlx5_glue_dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type)
549 return mlx5dv_init_obj(obj, obj_type);
552 static struct ibv_qp *
553 mlx5_glue_dv_create_qp(struct ibv_context *context,
554 struct ibv_qp_init_attr_ex *qp_init_attr_ex,
555 struct mlx5dv_qp_init_attr *dv_qp_init_attr)
557 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
558 return mlx5dv_create_qp(context, qp_init_attr_ex, dv_qp_init_attr);
561 (void)qp_init_attr_ex;
562 (void)dv_qp_init_attr;
569 mlx5_glue_dv_create_flow_matcher(struct ibv_context *context,
570 struct mlx5dv_flow_matcher_attr *matcher_attr,
573 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
574 #ifdef HAVE_MLX5DV_DR
576 return mlx5dv_dr_matcher_create(tbl, matcher_attr->priority,
577 matcher_attr->match_criteria_enable,
578 matcher_attr->match_mask);
581 return mlx5dv_create_flow_matcher(context, matcher_attr);
593 mlx5_glue_dv_create_flow(void *matcher,
598 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
599 #ifdef HAVE_MLX5DV_DR
600 return mlx5dv_dr_rule_create(matcher, match_value, num_actions,
601 (struct mlx5dv_dr_action **)actions);
604 struct mlx5dv_flow_action_attr actions_attr[8];
608 for (i = 0; i < num_actions; i++)
610 *((struct mlx5dv_flow_action_attr *)(actions[i]));
611 return mlx5dv_create_flow(matcher, match_value,
612 num_actions, actions_attr);
624 mlx5_glue_dv_create_flow_action_counter(void *counter_obj, uint32_t offset)
626 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
627 #ifdef HAVE_MLX5DV_DR
628 return mlx5dv_dr_action_create_flow_counter(counter_obj, offset);
630 struct mlx5dv_flow_action_attr *action;
633 action = malloc(sizeof(*action));
636 action->type = MLX5DV_FLOW_ACTION_COUNTERS_DEVX;
637 action->obj = counter_obj;
649 mlx5_glue_dv_create_flow_action_dest_ibv_qp(void *qp)
651 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
652 #ifdef HAVE_MLX5DV_DR
653 return mlx5dv_dr_action_create_dest_ibv_qp(qp);
655 struct mlx5dv_flow_action_attr *action;
657 action = malloc(sizeof(*action));
660 action->type = MLX5DV_FLOW_ACTION_DEST_IBV_QP;
672 mlx5_glue_dv_create_flow_action_dest_devx_tir(void *tir)
674 #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR
675 return mlx5dv_dr_action_create_dest_devx_tir(tir);
684 mlx5_glue_dv_create_flow_action_modify_header
685 (struct ibv_context *ctx,
686 enum mlx5dv_flow_table_type ft_type,
687 void *domain, uint64_t flags,
691 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
692 #ifdef HAVE_MLX5DV_DR
695 return mlx5dv_dr_action_create_modify_header(domain, flags, actions_sz,
698 struct mlx5dv_flow_action_attr *action;
702 action = malloc(sizeof(*action));
705 action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
706 action->action = mlx5dv_create_flow_action_modify_header
707 (ctx, actions_sz, actions, ft_type);
723 mlx5_glue_dv_create_flow_action_packet_reformat
724 (struct ibv_context *ctx,
725 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
726 enum mlx5dv_flow_table_type ft_type,
727 struct mlx5dv_dr_domain *domain,
728 uint32_t flags, size_t data_sz, void *data)
730 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
731 #ifdef HAVE_MLX5DV_DR
734 return mlx5dv_dr_action_create_packet_reformat(domain, flags,
735 reformat_type, data_sz,
740 struct mlx5dv_flow_action_attr *action;
742 action = malloc(sizeof(*action));
745 action->type = MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
746 action->action = mlx5dv_create_flow_action_packet_reformat
747 (ctx, data_sz, data, reformat_type, ft_type);
764 mlx5_glue_dv_create_flow_action_tag(uint32_t tag)
766 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
767 #ifdef HAVE_MLX5DV_DR
768 return mlx5dv_dr_action_create_tag(tag);
769 #else /* HAVE_MLX5DV_DR */
770 struct mlx5dv_flow_action_attr *action;
772 action = malloc(sizeof(*action));
775 action->type = MLX5DV_FLOW_ACTION_TAG;
776 action->tag_value = tag;
778 #endif /* HAVE_MLX5DV_DR */
779 #else /* HAVE_IBV_FLOW_DV_SUPPORT */
783 #endif /* HAVE_IBV_FLOW_DV_SUPPORT */
787 mlx5_glue_dv_create_flow_action_meter(struct mlx5dv_dr_flow_meter_attr *attr)
789 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
790 return mlx5dv_dr_action_create_flow_meter(attr);
799 mlx5_glue_dv_modify_flow_action_meter(void *action,
800 struct mlx5dv_dr_flow_meter_attr *attr,
801 uint64_t modify_bits)
803 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER)
804 return mlx5dv_dr_action_modify_flow_meter(action, attr, modify_bits);
815 mlx5_glue_dv_create_flow_action_aso(struct mlx5dv_dr_domain *domain,
819 uint8_t return_reg_c)
821 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_ASO)
822 return mlx5dv_dr_action_create_aso(domain, aso_obj, offset,
823 flags, return_reg_c);
836 mlx5_glue_dr_create_flow_action_default_miss(void)
838 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_DEFAULT_MISS)
839 return mlx5dv_dr_action_create_default_miss();
847 mlx5_glue_dv_destroy_flow(void *flow_id)
849 #ifdef HAVE_MLX5DV_DR
850 return mlx5dv_dr_rule_destroy(flow_id);
852 return ibv_destroy_flow(flow_id);
857 mlx5_glue_dv_destroy_flow_matcher(void *matcher)
859 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
860 #ifdef HAVE_MLX5DV_DR
861 return mlx5dv_dr_matcher_destroy(matcher);
863 return mlx5dv_destroy_flow_matcher(matcher);
872 static struct ibv_context *
873 mlx5_glue_dv_open_device(struct ibv_device *device)
875 #ifdef HAVE_IBV_DEVX_OBJ
876 return mlx5dv_open_device(device,
877 &(struct mlx5dv_context_attr){
878 .flags = MLX5DV_CONTEXT_FLAGS_DEVX,
887 static struct mlx5dv_devx_obj *
888 mlx5_glue_devx_obj_create(struct ibv_context *ctx,
889 const void *in, size_t inlen,
890 void *out, size_t outlen)
892 #ifdef HAVE_IBV_DEVX_OBJ
893 return mlx5dv_devx_obj_create(ctx, in, inlen, out, outlen);
906 mlx5_glue_devx_obj_destroy(struct mlx5dv_devx_obj *obj)
908 #ifdef HAVE_IBV_DEVX_OBJ
909 return mlx5dv_devx_obj_destroy(obj);
917 mlx5_glue_devx_obj_query(struct mlx5dv_devx_obj *obj,
918 const void *in, size_t inlen,
919 void *out, size_t outlen)
921 #ifdef HAVE_IBV_DEVX_OBJ
922 return mlx5dv_devx_obj_query(obj, in, inlen, out, outlen);
934 mlx5_glue_devx_obj_modify(struct mlx5dv_devx_obj *obj,
935 const void *in, size_t inlen,
936 void *out, size_t outlen)
938 #ifdef HAVE_IBV_DEVX_OBJ
939 return mlx5dv_devx_obj_modify(obj, in, inlen, out, outlen);
951 mlx5_glue_devx_general_cmd(struct ibv_context *ctx,
952 const void *in, size_t inlen,
953 void *out, size_t outlen)
955 #ifdef HAVE_IBV_DEVX_OBJ
956 return mlx5dv_devx_general_cmd(ctx, in, inlen, out, outlen);
967 static struct mlx5dv_devx_cmd_comp *
968 mlx5_glue_devx_create_cmd_comp(struct ibv_context *ctx)
970 #ifdef HAVE_IBV_DEVX_ASYNC
971 return mlx5dv_devx_create_cmd_comp(ctx);
980 mlx5_glue_devx_destroy_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp)
982 #ifdef HAVE_IBV_DEVX_ASYNC
983 mlx5dv_devx_destroy_cmd_comp(cmd_comp);
991 mlx5_glue_devx_obj_query_async(struct mlx5dv_devx_obj *obj, const void *in,
992 size_t inlen, size_t outlen, uint64_t wr_id,
993 struct mlx5dv_devx_cmd_comp *cmd_comp)
995 #ifdef HAVE_IBV_DEVX_ASYNC
996 return mlx5dv_devx_obj_query_async(obj, in, inlen, outlen, wr_id,
1010 mlx5_glue_devx_get_async_cmd_comp(struct mlx5dv_devx_cmd_comp *cmd_comp,
1011 struct mlx5dv_devx_async_cmd_hdr *cmd_resp,
1012 size_t cmd_resp_len)
1014 #ifdef HAVE_IBV_DEVX_ASYNC
1015 return mlx5dv_devx_get_async_cmd_comp(cmd_comp, cmd_resp,
1025 static struct mlx5dv_devx_umem *
1026 mlx5_glue_devx_umem_reg(struct ibv_context *context, void *addr, size_t size,
1029 #ifdef HAVE_IBV_DEVX_OBJ
1030 return mlx5dv_devx_umem_reg(context, addr, size, access);
1042 mlx5_glue_devx_umem_dereg(struct mlx5dv_devx_umem *dv_devx_umem)
1044 #ifdef HAVE_IBV_DEVX_OBJ
1045 return mlx5dv_devx_umem_dereg(dv_devx_umem);
1053 mlx5_glue_devx_qp_query(struct ibv_qp *qp,
1054 const void *in, size_t inlen,
1055 void *out, size_t outlen)
1057 #ifdef HAVE_IBV_DEVX_QP
1058 return mlx5dv_devx_qp_query(qp, in, inlen, out, outlen);
1071 mlx5_glue_devx_wq_query(struct ibv_wq *wq, const void *in, size_t inlen,
1072 void *out, size_t outlen)
1074 #ifdef HAVE_IBV_DEVX_QP
1075 return mlx5dv_devx_wq_query(wq, in, inlen, out, outlen);
1088 mlx5_glue_devx_port_query(struct ibv_context *ctx,
1090 struct mlx5_port_info *info)
1094 info->query_flags = 0;
1095 #ifdef HAVE_MLX5DV_DR_DEVX_PORT_V35
1096 /* The DevX port query API is implemented (rdma-core v35 and above). */
1097 struct mlx5_ib_uapi_query_port devx_port;
1099 memset(&devx_port, 0, sizeof(devx_port));
1100 err = mlx5dv_query_port(ctx, port_num, &devx_port);
1103 if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT_REG_C0) {
1104 info->vport_meta_tag = devx_port.reg_c0.value;
1105 info->vport_meta_mask = devx_port.reg_c0.mask;
1106 info->query_flags |= MLX5_PORT_QUERY_REG_C0;
1108 if (devx_port.flags & MLX5DV_QUERY_PORT_VPORT) {
1109 info->vport_id = devx_port.vport;
1110 info->query_flags |= MLX5_PORT_QUERY_VPORT;
1113 #ifdef HAVE_MLX5DV_DR_DEVX_PORT
1114 /* The legacy DevX port query API is implemented (prior v35). */
1115 struct mlx5dv_devx_port devx_port = {
1116 .comp_mask = MLX5DV_DEVX_PORT_VPORT |
1117 MLX5DV_DEVX_PORT_MATCH_REG_C_0
1120 err = mlx5dv_query_devx_port(ctx, port_num, &devx_port);
1123 if (devx_port.comp_mask & MLX5DV_DEVX_PORT_MATCH_REG_C_0) {
1124 info->vport_meta_tag = devx_port.reg_c_0.value;
1125 info->vport_meta_mask = devx_port.reg_c_0.mask;
1126 info->query_flags |= MLX5_PORT_QUERY_REG_C0;
1128 if (devx_port.comp_mask & MLX5DV_DEVX_PORT_VPORT) {
1129 info->vport_id = devx_port.vport_num;
1130 info->query_flags |= MLX5_PORT_QUERY_VPORT;
1134 RTE_SET_USED(port_num);
1135 #endif /* HAVE_MLX5DV_DR_DEVX_PORT */
1136 #endif /* HAVE_MLX5DV_DR_DEVX_PORT_V35 */
1141 mlx5_glue_dr_dump_single_rule(FILE *file, void *rule)
1143 #ifdef HAVE_MLX5_DR_FLOW_DUMP_RULE
1144 return mlx5dv_dump_dr_rule(file, rule);
1153 mlx5_glue_dr_dump_domain(FILE *file, void *domain)
1155 #ifdef HAVE_MLX5_DR_FLOW_DUMP
1156 return mlx5dv_dump_dr_domain(file, domain);
1159 RTE_SET_USED(domain);
1165 mlx5_glue_dr_create_flow_action_sampler
1166 (struct mlx5dv_dr_flow_sampler_attr *attr)
1168 #ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
1169 return mlx5dv_dr_action_create_flow_sampler(attr);
1178 mlx5_glue_dr_action_create_dest_array
1181 struct mlx5dv_dr_action_dest_attr *dests[])
1183 #ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY
1184 return mlx5dv_dr_action_create_dest_array
1198 mlx5_glue_devx_query_eqn(struct ibv_context *ctx, uint32_t cpus,
1201 #ifdef HAVE_IBV_DEVX_OBJ
1202 return mlx5dv_devx_query_eqn(ctx, cpus, eqn);
1211 static struct mlx5dv_devx_event_channel *
1212 mlx5_glue_devx_create_event_channel(struct ibv_context *ctx, int flags)
1214 #ifdef HAVE_IBV_DEVX_EVENT
1215 return mlx5dv_devx_create_event_channel(ctx, flags);
1225 mlx5_glue_devx_destroy_event_channel(struct mlx5dv_devx_event_channel *eventc)
1227 #ifdef HAVE_IBV_DEVX_EVENT
1228 mlx5dv_devx_destroy_event_channel(eventc);
1235 mlx5_glue_devx_subscribe_devx_event(struct mlx5dv_devx_event_channel *eventc,
1236 struct mlx5dv_devx_obj *obj,
1237 uint16_t events_sz, uint16_t events_num[],
1240 #ifdef HAVE_IBV_DEVX_EVENT
1241 return mlx5dv_devx_subscribe_devx_event(eventc, obj, events_sz,
1242 events_num, cookie);
1254 mlx5_glue_devx_subscribe_devx_event_fd(struct mlx5dv_devx_event_channel *eventc,
1255 int fd, struct mlx5dv_devx_obj *obj,
1258 #ifdef HAVE_IBV_DEVX_EVENT
1259 return mlx5dv_devx_subscribe_devx_event_fd(eventc, fd, obj, event_num);
1270 mlx5_glue_devx_get_event(struct mlx5dv_devx_event_channel *eventc,
1271 struct mlx5dv_devx_async_event_hdr *event_data,
1272 size_t event_resp_len)
1274 #ifdef HAVE_IBV_DEVX_EVENT
1275 return mlx5dv_devx_get_event(eventc, event_data, event_resp_len);
1279 (void)event_resp_len;
1285 static struct mlx5dv_devx_uar *
1286 mlx5_glue_devx_alloc_uar(struct ibv_context *context, uint32_t flags)
1288 #ifdef HAVE_IBV_DEVX_OBJ
1289 return mlx5dv_devx_alloc_uar(context, flags);
1299 mlx5_glue_devx_free_uar(struct mlx5dv_devx_uar *devx_uar)
1301 #ifdef HAVE_IBV_DEVX_OBJ
1302 mlx5dv_devx_free_uar(devx_uar);
1308 static struct mlx5dv_var *
1309 mlx5_glue_dv_alloc_var(struct ibv_context *context, uint32_t flags)
1312 return mlx5dv_alloc_var(context, flags);
1322 mlx5_glue_dv_free_var(struct mlx5dv_var *var)
1325 mlx5dv_free_var(var);
1333 mlx5_glue_dr_reclaim_domain_memory(void *domain, uint32_t enable)
1335 #ifdef HAVE_MLX5DV_DR_MEM_RECLAIM
1336 mlx5dv_dr_domain_set_reclaim_device_memory(domain, enable);
1343 static struct mlx5dv_pp *
1344 mlx5_glue_dv_alloc_pp(struct ibv_context *context,
1345 size_t pp_context_sz,
1346 const void *pp_context,
1349 #ifdef HAVE_MLX5DV_PP_ALLOC
1350 return mlx5dv_pp_alloc(context, pp_context_sz, pp_context, flags);
1352 RTE_SET_USED(context);
1353 RTE_SET_USED(pp_context_sz);
1354 RTE_SET_USED(pp_context);
1355 RTE_SET_USED(flags);
1362 mlx5_glue_dr_allow_duplicate_rules(void *domain, uint32_t allow)
1364 #ifdef HAVE_MLX5_DR_ALLOW_DUPLICATE
1365 mlx5dv_dr_domain_allow_duplicate_rules(domain, allow);
1373 mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
1375 #ifdef HAVE_MLX5DV_PP_ALLOC
1383 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
1384 .version = MLX5_GLUE_VERSION,
1385 .fork_init = mlx5_glue_fork_init,
1386 .alloc_pd = mlx5_glue_alloc_pd,
1387 .dealloc_pd = mlx5_glue_dealloc_pd,
1388 .get_device_list = mlx5_glue_get_device_list,
1389 .free_device_list = mlx5_glue_free_device_list,
1390 .open_device = mlx5_glue_open_device,
1391 .close_device = mlx5_glue_close_device,
1392 .query_device = mlx5_glue_query_device,
1393 .query_device_ex = mlx5_glue_query_device_ex,
1394 .query_rt_values_ex = mlx5_glue_query_rt_values_ex,
1395 .query_port = mlx5_glue_query_port,
1396 .create_comp_channel = mlx5_glue_create_comp_channel,
1397 .destroy_comp_channel = mlx5_glue_destroy_comp_channel,
1398 .create_cq = mlx5_glue_create_cq,
1399 .destroy_cq = mlx5_glue_destroy_cq,
1400 .get_cq_event = mlx5_glue_get_cq_event,
1401 .ack_cq_events = mlx5_glue_ack_cq_events,
1402 .create_rwq_ind_table = mlx5_glue_create_rwq_ind_table,
1403 .destroy_rwq_ind_table = mlx5_glue_destroy_rwq_ind_table,
1404 .create_wq = mlx5_glue_create_wq,
1405 .destroy_wq = mlx5_glue_destroy_wq,
1406 .modify_wq = mlx5_glue_modify_wq,
1407 .create_flow = mlx5_glue_create_flow,
1408 .destroy_flow = mlx5_glue_destroy_flow,
1409 .destroy_flow_action = mlx5_glue_destroy_flow_action,
1410 .create_qp = mlx5_glue_create_qp,
1411 .create_qp_ex = mlx5_glue_create_qp_ex,
1412 .destroy_qp = mlx5_glue_destroy_qp,
1413 .modify_qp = mlx5_glue_modify_qp,
1414 .reg_mr = mlx5_glue_reg_mr,
1415 .alloc_null_mr = mlx5_glue_alloc_null_mr,
1416 .dereg_mr = mlx5_glue_dereg_mr,
1417 .create_counter_set = mlx5_glue_create_counter_set,
1418 .destroy_counter_set = mlx5_glue_destroy_counter_set,
1419 .describe_counter_set = mlx5_glue_describe_counter_set,
1420 .query_counter_set = mlx5_glue_query_counter_set,
1421 .create_counters = mlx5_glue_create_counters,
1422 .destroy_counters = mlx5_glue_destroy_counters,
1423 .attach_counters = mlx5_glue_attach_counters,
1424 .query_counters = mlx5_glue_query_counters,
1425 .ack_async_event = mlx5_glue_ack_async_event,
1426 .get_async_event = mlx5_glue_get_async_event,
1427 .port_state_str = mlx5_glue_port_state_str,
1428 .cq_ex_to_cq = mlx5_glue_cq_ex_to_cq,
1429 .dr_create_flow_action_dest_flow_tbl =
1430 mlx5_glue_dr_create_flow_action_dest_flow_tbl,
1431 .dr_create_flow_action_dest_port =
1432 mlx5_glue_dr_create_flow_action_dest_port,
1433 .dr_create_flow_action_drop =
1434 mlx5_glue_dr_create_flow_action_drop,
1435 .dr_create_flow_action_push_vlan =
1436 mlx5_glue_dr_create_flow_action_push_vlan,
1437 .dr_create_flow_action_pop_vlan =
1438 mlx5_glue_dr_create_flow_action_pop_vlan,
1439 .dr_create_flow_tbl = mlx5_glue_dr_create_flow_tbl,
1440 .dr_destroy_flow_tbl = mlx5_glue_dr_destroy_flow_tbl,
1441 .dr_create_domain = mlx5_glue_dr_create_domain,
1442 .dr_destroy_domain = mlx5_glue_dr_destroy_domain,
1443 .dr_sync_domain = mlx5_glue_dr_sync_domain,
1444 .dv_create_cq = mlx5_glue_dv_create_cq,
1445 .dv_create_wq = mlx5_glue_dv_create_wq,
1446 .dv_query_device = mlx5_glue_dv_query_device,
1447 .dv_set_context_attr = mlx5_glue_dv_set_context_attr,
1448 .dv_init_obj = mlx5_glue_dv_init_obj,
1449 .dv_create_qp = mlx5_glue_dv_create_qp,
1450 .dv_create_flow_matcher = mlx5_glue_dv_create_flow_matcher,
1451 .dv_create_flow = mlx5_glue_dv_create_flow,
1452 .dv_create_flow_action_counter =
1453 mlx5_glue_dv_create_flow_action_counter,
1454 .dv_create_flow_action_dest_ibv_qp =
1455 mlx5_glue_dv_create_flow_action_dest_ibv_qp,
1456 .dv_create_flow_action_dest_devx_tir =
1457 mlx5_glue_dv_create_flow_action_dest_devx_tir,
1458 .dv_create_flow_action_modify_header =
1459 mlx5_glue_dv_create_flow_action_modify_header,
1460 .dv_create_flow_action_packet_reformat =
1461 mlx5_glue_dv_create_flow_action_packet_reformat,
1462 .dv_create_flow_action_tag = mlx5_glue_dv_create_flow_action_tag,
1463 .dv_create_flow_action_meter = mlx5_glue_dv_create_flow_action_meter,
1464 .dv_modify_flow_action_meter = mlx5_glue_dv_modify_flow_action_meter,
1465 .dv_create_flow_action_aso = mlx5_glue_dv_create_flow_action_aso,
1466 .dr_create_flow_action_default_miss =
1467 mlx5_glue_dr_create_flow_action_default_miss,
1468 .dv_destroy_flow = mlx5_glue_dv_destroy_flow,
1469 .dv_destroy_flow_matcher = mlx5_glue_dv_destroy_flow_matcher,
1470 .dv_open_device = mlx5_glue_dv_open_device,
1471 .devx_obj_create = mlx5_glue_devx_obj_create,
1472 .devx_obj_destroy = mlx5_glue_devx_obj_destroy,
1473 .devx_obj_query = mlx5_glue_devx_obj_query,
1474 .devx_obj_modify = mlx5_glue_devx_obj_modify,
1475 .devx_general_cmd = mlx5_glue_devx_general_cmd,
1476 .devx_create_cmd_comp = mlx5_glue_devx_create_cmd_comp,
1477 .devx_destroy_cmd_comp = mlx5_glue_devx_destroy_cmd_comp,
1478 .devx_obj_query_async = mlx5_glue_devx_obj_query_async,
1479 .devx_get_async_cmd_comp = mlx5_glue_devx_get_async_cmd_comp,
1480 .devx_umem_reg = mlx5_glue_devx_umem_reg,
1481 .devx_umem_dereg = mlx5_glue_devx_umem_dereg,
1482 .devx_qp_query = mlx5_glue_devx_qp_query,
1483 .devx_wq_query = mlx5_glue_devx_wq_query,
1484 .devx_port_query = mlx5_glue_devx_port_query,
1485 .dr_dump_domain = mlx5_glue_dr_dump_domain,
1486 .dr_dump_rule = mlx5_glue_dr_dump_single_rule,
1487 .dr_reclaim_domain_memory = mlx5_glue_dr_reclaim_domain_memory,
1488 .dr_create_flow_action_sampler =
1489 mlx5_glue_dr_create_flow_action_sampler,
1490 .dr_create_flow_action_dest_array =
1491 mlx5_glue_dr_action_create_dest_array,
1492 .dr_allow_duplicate_rules = mlx5_glue_dr_allow_duplicate_rules,
1493 .devx_query_eqn = mlx5_glue_devx_query_eqn,
1494 .devx_create_event_channel = mlx5_glue_devx_create_event_channel,
1495 .devx_destroy_event_channel = mlx5_glue_devx_destroy_event_channel,
1496 .devx_subscribe_devx_event = mlx5_glue_devx_subscribe_devx_event,
1497 .devx_subscribe_devx_event_fd = mlx5_glue_devx_subscribe_devx_event_fd,
1498 .devx_get_event = mlx5_glue_devx_get_event,
1499 .devx_alloc_uar = mlx5_glue_devx_alloc_uar,
1500 .devx_free_uar = mlx5_glue_devx_free_uar,
1501 .dv_alloc_var = mlx5_glue_dv_alloc_var,
1502 .dv_free_var = mlx5_glue_dv_free_var,
1503 .dv_alloc_pp = mlx5_glue_dv_alloc_pp,
1504 .dv_free_pp = mlx5_glue_dv_free_pp,