New upstream version 18.02
[deb_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 MLX5_GLUE_VERSION
23 #define MLX5_GLUE_VERSION ""
24 #endif
25
26 #ifndef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
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;
32 #endif
33
34 /* LIB_GLUE_VERSION must be updated every time this structure is modified. */
35 struct mlx5_glue {
36         const char *version;
37         int (*fork_init)(void);
38         struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
39         int (*dealloc_pd)(struct ibv_pd *pd);
40         struct ibv_device **(*get_device_list)(int *num_devices);
41         void (*free_device_list)(struct ibv_device **list);
42         struct ibv_context *(*open_device)(struct ibv_device *device);
43         int (*close_device)(struct ibv_context *context);
44         int (*query_device)(struct ibv_context *context,
45                             struct ibv_device_attr *device_attr);
46         int (*query_device_ex)(struct ibv_context *context,
47                                const struct ibv_query_device_ex_input *input,
48                                struct ibv_device_attr_ex *attr);
49         int (*query_port)(struct ibv_context *context, uint8_t port_num,
50                           struct ibv_port_attr *port_attr);
51         struct ibv_comp_channel *(*create_comp_channel)
52                 (struct ibv_context *context);
53         int (*destroy_comp_channel)(struct ibv_comp_channel *channel);
54         struct ibv_cq *(*create_cq)(struct ibv_context *context, int cqe,
55                                     void *cq_context,
56                                     struct ibv_comp_channel *channel,
57                                     int comp_vector);
58         int (*destroy_cq)(struct ibv_cq *cq);
59         int (*get_cq_event)(struct ibv_comp_channel *channel,
60                             struct ibv_cq **cq, void **cq_context);
61         void (*ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
62         struct ibv_rwq_ind_table *(*create_rwq_ind_table)
63                 (struct ibv_context *context,
64                  struct ibv_rwq_ind_table_init_attr *init_attr);
65         int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
66         struct ibv_wq *(*create_wq)(struct ibv_context *context,
67                                     struct ibv_wq_init_attr *wq_init_attr);
68         int (*destroy_wq)(struct ibv_wq *wq);
69         int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
70         struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
71                                         struct ibv_flow_attr *flow);
72         int (*destroy_flow)(struct ibv_flow *flow_id);
73         struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
74                                     struct ibv_qp_init_attr *qp_init_attr);
75         struct ibv_qp *(*create_qp_ex)
76                 (struct ibv_context *context,
77                  struct ibv_qp_init_attr_ex *qp_init_attr_ex);
78         int (*destroy_qp)(struct ibv_qp *qp);
79         int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
80                          int attr_mask);
81         struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr,
82                                  size_t length, int access);
83         int (*dereg_mr)(struct ibv_mr *mr);
84         struct ibv_counter_set *(*create_counter_set)
85                 (struct ibv_context *context,
86                  struct ibv_counter_set_init_attr *init_attr);
87         int (*destroy_counter_set)(struct ibv_counter_set *cs);
88         int (*describe_counter_set)
89                 (struct ibv_context *context,
90                  uint16_t counter_set_id,
91                  struct ibv_counter_set_description *cs_desc);
92         int (*query_counter_set)(struct ibv_query_counter_set_attr *query_attr,
93                                  struct ibv_counter_set_data *cs_data);
94         void (*ack_async_event)(struct ibv_async_event *event);
95         int (*get_async_event)(struct ibv_context *context,
96                                struct ibv_async_event *event);
97         const char *(*port_state_str)(enum ibv_port_state port_state);
98         struct ibv_cq *(*cq_ex_to_cq)(struct ibv_cq_ex *cq);
99         struct ibv_cq_ex *(*dv_create_cq)
100                 (struct ibv_context *context,
101                  struct ibv_cq_init_attr_ex *cq_attr,
102                  struct mlx5dv_cq_init_attr *mlx5_cq_attr);
103         int (*dv_query_device)(struct ibv_context *ctx_in,
104                                struct mlx5dv_context *attrs_out);
105         int (*dv_set_context_attr)(struct ibv_context *ibv_ctx,
106                                    enum mlx5dv_set_ctx_attr_type type,
107                                    void *attr);
108         int (*dv_init_obj)(struct mlx5dv_obj *obj, uint64_t obj_type);
109 };
110
111 const struct mlx5_glue *mlx5_glue;
112
113 #endif /* MLX5_GLUE_H_ */