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