7fed302bad4bdcd2d09e3f4c1ebebb9bac62204f
[dpdk.git] / drivers / net / mlx5 / mlx5_glue.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2018 6WIND S.A.
3  * Copyright 2018 Mellanox Technologies, Ltd.
4  */
5
6 #ifndef MLX5_GLUE_H_
7 #define MLX5_GLUE_H_
8
9 #include <stddef.h>
10 #include <stdint.h>
11
12 /* Verbs headers do not support -pedantic. */
13 #ifdef PEDANTIC
14 #pragma GCC diagnostic ignored "-Wpedantic"
15 #endif
16 #include <infiniband/mlx5dv.h>
17 #include <infiniband/verbs.h>
18 #ifdef PEDANTIC
19 #pragma GCC diagnostic error "-Wpedantic"
20 #endif
21
22 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
23 struct ibv_counter_set;
24 struct ibv_counter_set_data;
25 struct ibv_counter_set_description;
26 struct ibv_counter_set_init_attr;
27 struct ibv_query_counter_set_attr;
28 #endif
29
30 struct mlx5_glue {
31         int (*fork_init)(void);
32         struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
33         int (*dealloc_pd)(struct ibv_pd *pd);
34         struct ibv_device **(*get_device_list)(int *num_devices);
35         void (*free_device_list)(struct ibv_device **list);
36         struct ibv_context *(*open_device)(struct ibv_device *device);
37         int (*close_device)(struct ibv_context *context);
38         int (*query_device)(struct ibv_context *context,
39                             struct ibv_device_attr *device_attr);
40         int (*query_device_ex)(struct ibv_context *context,
41                                const struct ibv_query_device_ex_input *input,
42                                struct ibv_device_attr_ex *attr);
43         int (*query_port)(struct ibv_context *context, uint8_t port_num,
44                           struct ibv_port_attr *port_attr);
45         struct ibv_comp_channel *(*create_comp_channel)
46                 (struct ibv_context *context);
47         int (*destroy_comp_channel)(struct ibv_comp_channel *channel);
48         struct ibv_cq *(*create_cq)(struct ibv_context *context, int cqe,
49                                     void *cq_context,
50                                     struct ibv_comp_channel *channel,
51                                     int comp_vector);
52         int (*destroy_cq)(struct ibv_cq *cq);
53         int (*get_cq_event)(struct ibv_comp_channel *channel,
54                             struct ibv_cq **cq, void **cq_context);
55         void (*ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
56         struct ibv_rwq_ind_table *(*create_rwq_ind_table)
57                 (struct ibv_context *context,
58                  struct ibv_rwq_ind_table_init_attr *init_attr);
59         int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
60         struct ibv_wq *(*create_wq)(struct ibv_context *context,
61                                     struct ibv_wq_init_attr *wq_init_attr);
62         int (*destroy_wq)(struct ibv_wq *wq);
63         int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
64         struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
65                                         struct ibv_flow_attr *flow);
66         int (*destroy_flow)(struct ibv_flow *flow_id);
67         struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
68                                     struct ibv_qp_init_attr *qp_init_attr);
69         struct ibv_qp *(*create_qp_ex)
70                 (struct ibv_context *context,
71                  struct ibv_qp_init_attr_ex *qp_init_attr_ex);
72         int (*destroy_qp)(struct ibv_qp *qp);
73         int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
74                          int attr_mask);
75         struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr,
76                                  size_t length, int access);
77         int (*dereg_mr)(struct ibv_mr *mr);
78         struct ibv_counter_set *(*create_counter_set)
79                 (struct ibv_context *context,
80                  struct ibv_counter_set_init_attr *init_attr);
81         int (*destroy_counter_set)(struct ibv_counter_set *cs);
82         int (*describe_counter_set)
83                 (struct ibv_context *context,
84                  uint16_t counter_set_id,
85                  struct ibv_counter_set_description *cs_desc);
86         int (*query_counter_set)(struct ibv_query_counter_set_attr *query_attr,
87                                  struct ibv_counter_set_data *cs_data);
88         void (*ack_async_event)(struct ibv_async_event *event);
89         int (*get_async_event)(struct ibv_context *context,
90                                struct ibv_async_event *event);
91         const char *(*port_state_str)(enum ibv_port_state port_state);
92         struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
93         struct ibv_cq_ex *(*dv_create_cq)
94                 (struct ibv_context *context,
95                  struct ibv_cq_init_attr_ex *cq_attr,
96                  struct mlx5dv_cq_init_attr *mlx5_cq_attr);
97         int (*dv_query_device)(struct ibv_context *ctx_in,
98                                struct mlx5dv_context *attrs_out);
99         int (*dv_set_context_attr)(struct ibv_context *ibv_ctx,
100                                    enum mlx5dv_set_ctx_attr_type type,
101                                    void *attr);
102         int (*dv_init_obj)(struct mlx5dv_obj *obj, uint64_t obj_type);
103 };
104
105 const struct mlx5_glue *mlx5_glue;
106
107 #endif /* MLX5_GLUE_H_ */