1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 6WIND S.A.
3 * Copyright 2018 Mellanox Technologies, Ltd
12 /* Verbs headers do not support -pedantic. */
14 #pragma GCC diagnostic ignored "-Wpedantic"
16 #include <infiniband/mlx5dv.h>
17 #include <infiniband/verbs.h>
19 #pragma GCC diagnostic error "-Wpedantic"
22 #ifndef MLX5_GLUE_VERSION
23 #define MLX5_GLUE_VERSION ""
26 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V42
27 struct ibv_counter_set;
28 struct ibv_counter_set_data;
29 struct ibv_counter_set_description;
30 struct ibv_counter_set_init_attr;
31 struct ibv_query_counter_set_attr;
34 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_V45
36 struct ibv_counters_init_attr;
37 struct ibv_counter_attach_attr;
40 #ifndef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
41 struct mlx5dv_qp_init_attr;
44 #ifndef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
45 struct mlx5dv_wq_init_attr;
48 #ifndef HAVE_IBV_FLOW_DV_SUPPORT
49 struct mlx5dv_flow_matcher;
50 struct mlx5dv_flow_matcher_attr;
51 struct mlx5dv_flow_action_attr;
52 struct mlx5dv_flow_match_parameters;
53 struct ibv_flow_action;
54 enum mlx5dv_flow_action_packet_reformat_type { packet_reformat_type = 0, };
55 enum mlx5dv_flow_table_type { flow_table_type = 0, };
58 #ifndef HAVE_IBV_DEVX_OBJ
59 struct mlx5dv_devx_obj;
62 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
65 int (*fork_init)(void);
66 struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
67 int (*dealloc_pd)(struct ibv_pd *pd);
68 struct ibv_device **(*get_device_list)(int *num_devices);
69 void (*free_device_list)(struct ibv_device **list);
70 struct ibv_context *(*open_device)(struct ibv_device *device);
71 int (*close_device)(struct ibv_context *context);
72 int (*query_device)(struct ibv_context *context,
73 struct ibv_device_attr *device_attr);
74 int (*query_device_ex)(struct ibv_context *context,
75 const struct ibv_query_device_ex_input *input,
76 struct ibv_device_attr_ex *attr);
77 int (*query_port)(struct ibv_context *context, uint8_t port_num,
78 struct ibv_port_attr *port_attr);
79 struct ibv_comp_channel *(*create_comp_channel)
80 (struct ibv_context *context);
81 int (*destroy_comp_channel)(struct ibv_comp_channel *channel);
82 struct ibv_cq *(*create_cq)(struct ibv_context *context, int cqe,
84 struct ibv_comp_channel *channel,
86 int (*destroy_cq)(struct ibv_cq *cq);
87 int (*get_cq_event)(struct ibv_comp_channel *channel,
88 struct ibv_cq **cq, void **cq_context);
89 void (*ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
90 struct ibv_rwq_ind_table *(*create_rwq_ind_table)
91 (struct ibv_context *context,
92 struct ibv_rwq_ind_table_init_attr *init_attr);
93 int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
94 struct ibv_wq *(*create_wq)(struct ibv_context *context,
95 struct ibv_wq_init_attr *wq_init_attr);
96 int (*destroy_wq)(struct ibv_wq *wq);
97 int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
98 struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
99 struct ibv_flow_attr *flow);
100 int (*destroy_flow)(struct ibv_flow *flow_id);
101 int (*destroy_flow_action)(struct ibv_flow_action *action);
102 struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
103 struct ibv_qp_init_attr *qp_init_attr);
104 struct ibv_qp *(*create_qp_ex)
105 (struct ibv_context *context,
106 struct ibv_qp_init_attr_ex *qp_init_attr_ex);
107 int (*destroy_qp)(struct ibv_qp *qp);
108 int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
110 struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr,
111 size_t length, int access);
112 int (*dereg_mr)(struct ibv_mr *mr);
113 struct ibv_counter_set *(*create_counter_set)
114 (struct ibv_context *context,
115 struct ibv_counter_set_init_attr *init_attr);
116 int (*destroy_counter_set)(struct ibv_counter_set *cs);
117 int (*describe_counter_set)
118 (struct ibv_context *context,
119 uint16_t counter_set_id,
120 struct ibv_counter_set_description *cs_desc);
121 int (*query_counter_set)(struct ibv_query_counter_set_attr *query_attr,
122 struct ibv_counter_set_data *cs_data);
123 struct ibv_counters *(*create_counters)
124 (struct ibv_context *context,
125 struct ibv_counters_init_attr *init_attr);
126 int (*destroy_counters)(struct ibv_counters *counters);
127 int (*attach_counters)(struct ibv_counters *counters,
128 struct ibv_counter_attach_attr *attr,
129 struct ibv_flow *flow);
130 int (*query_counters)(struct ibv_counters *counters,
131 uint64_t *counters_value,
134 void (*ack_async_event)(struct ibv_async_event *event);
135 int (*get_async_event)(struct ibv_context *context,
136 struct ibv_async_event *event);
137 const char *(*port_state_str)(enum ibv_port_state port_state);
138 struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
139 struct ibv_cq_ex *(*dv_create_cq)
140 (struct ibv_context *context,
141 struct ibv_cq_init_attr_ex *cq_attr,
142 struct mlx5dv_cq_init_attr *mlx5_cq_attr);
143 struct ibv_wq *(*dv_create_wq)
144 (struct ibv_context *context,
145 struct ibv_wq_init_attr *wq_attr,
146 struct mlx5dv_wq_init_attr *mlx5_wq_attr);
147 int (*dv_query_device)(struct ibv_context *ctx_in,
148 struct mlx5dv_context *attrs_out);
149 int (*dv_set_context_attr)(struct ibv_context *ibv_ctx,
150 enum mlx5dv_set_ctx_attr_type type,
152 int (*dv_init_obj)(struct mlx5dv_obj *obj, uint64_t obj_type);
153 struct ibv_qp *(*dv_create_qp)
154 (struct ibv_context *context,
155 struct ibv_qp_init_attr_ex *qp_init_attr_ex,
156 struct mlx5dv_qp_init_attr *dv_qp_init_attr);
157 struct mlx5dv_flow_matcher *(*dv_create_flow_matcher)
158 (struct ibv_context *context,
159 struct mlx5dv_flow_matcher_attr *matcher_attr);
160 int (*dv_destroy_flow_matcher)(struct mlx5dv_flow_matcher *matcher);
161 struct ibv_flow *(*dv_create_flow)(struct mlx5dv_flow_matcher *matcher,
162 struct mlx5dv_flow_match_parameters *match_value,
164 struct mlx5dv_flow_action_attr *actions_attr);
165 struct ibv_flow_action *(*dv_create_flow_action_packet_reformat)
166 (struct ibv_context *ctx,
169 enum mlx5dv_flow_action_packet_reformat_type reformat_type,
170 enum mlx5dv_flow_table_type ft_type);
171 struct ibv_flow_action *(*dv_create_flow_action_modify_header)
172 (struct ibv_context *ctx,
175 enum mlx5dv_flow_table_type ft_type);
176 struct ibv_context *(*dv_open_device)(struct ibv_device *device);
177 struct mlx5dv_devx_obj *(*devx_obj_create)
178 (struct ibv_context *ctx,
179 const void *in, size_t inlen,
180 void *out, size_t outlen);
181 int (*devx_obj_destroy)(struct mlx5dv_devx_obj *obj);
182 int (*devx_obj_query)(struct mlx5dv_devx_obj *obj,
183 const void *in, size_t inlen,
184 void *out, size_t outlen);
185 int (*devx_obj_modify)(struct mlx5dv_devx_obj *obj,
186 const void *in, size_t inlen,
187 void *out, size_t outlen);
188 int (*devx_general_cmd)(struct ibv_context *context,
189 const void *in, size_t inlen,
190 void *out, size_t outlen);
193 const struct mlx5_glue *mlx5_glue;
195 #endif /* MLX5_GLUE_H_ */