1 /*
2  * Copyright (c) 2018, Mellanox Technologies inc.  All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef MLX5_USER_IOCTL_CMDS_H
34 #define MLX5_USER_IOCTL_CMDS_H
35 
36 #include <linux/types.h>
37 #include <rdma/ib_user_ioctl_cmds.h>
38 
39 enum mlx5_ib_create_flow_action_attrs {
40 	/* This attribute belong to the driver namespace */
41 	MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS = (1U << UVERBS_ID_NS_SHIFT),
42 };
43 
44 enum mlx5_ib_alloc_dm_attrs {
45 	MLX5_IB_ATTR_ALLOC_DM_RESP_START_OFFSET = (1U << UVERBS_ID_NS_SHIFT),
46 	MLX5_IB_ATTR_ALLOC_DM_RESP_PAGE_INDEX,
47 };
48 
49 enum mlx5_ib_devx_methods {
50 	MLX5_IB_METHOD_DEVX_OTHER  = (1U << UVERBS_ID_NS_SHIFT),
51 	MLX5_IB_METHOD_DEVX_QUERY_UAR,
52 	MLX5_IB_METHOD_DEVX_QUERY_EQN,
53 };
54 
55 enum  mlx5_ib_devx_other_attrs {
56 	MLX5_IB_ATTR_DEVX_OTHER_CMD_IN = (1U << UVERBS_ID_NS_SHIFT),
57 	MLX5_IB_ATTR_DEVX_OTHER_CMD_OUT,
58 };
59 
60 enum mlx5_ib_devx_obj_create_attrs {
61 	MLX5_IB_ATTR_DEVX_OBJ_CREATE_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
62 	MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_IN,
63 	MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_OUT,
64 };
65 
66 enum  mlx5_ib_devx_query_uar_attrs {
67 	MLX5_IB_ATTR_DEVX_QUERY_UAR_USER_IDX = (1U << UVERBS_ID_NS_SHIFT),
68 	MLX5_IB_ATTR_DEVX_QUERY_UAR_DEV_IDX,
69 };
70 
71 enum mlx5_ib_devx_obj_destroy_attrs {
72 	MLX5_IB_ATTR_DEVX_OBJ_DESTROY_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
73 };
74 
75 enum mlx5_ib_devx_obj_modify_attrs {
76 	MLX5_IB_ATTR_DEVX_OBJ_MODIFY_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
77 	MLX5_IB_ATTR_DEVX_OBJ_MODIFY_CMD_IN,
78 	MLX5_IB_ATTR_DEVX_OBJ_MODIFY_CMD_OUT,
79 };
80 
81 enum mlx5_ib_devx_obj_query_attrs {
82 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
83 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_CMD_IN,
84 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_CMD_OUT,
85 };
86 
87 enum mlx5_ib_devx_obj_query_async_attrs {
88 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_ASYNC_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
89 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_ASYNC_CMD_IN,
90 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_ASYNC_FD,
91 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_ASYNC_WR_ID,
92 	MLX5_IB_ATTR_DEVX_OBJ_QUERY_ASYNC_OUT_LEN,
93 };
94 
95 enum  mlx5_ib_devx_query_eqn_attrs {
96 	MLX5_IB_ATTR_DEVX_QUERY_EQN_USER_VEC = (1U << UVERBS_ID_NS_SHIFT),
97 	MLX5_IB_ATTR_DEVX_QUERY_EQN_DEV_EQN,
98 };
99 
100 enum mlx5_ib_devx_obj_methods {
101 	MLX5_IB_METHOD_DEVX_OBJ_CREATE = (1U << UVERBS_ID_NS_SHIFT),
102 	MLX5_IB_METHOD_DEVX_OBJ_DESTROY,
103 	MLX5_IB_METHOD_DEVX_OBJ_MODIFY,
104 	MLX5_IB_METHOD_DEVX_OBJ_QUERY,
105 	MLX5_IB_METHOD_DEVX_OBJ_ASYNC_QUERY,
106 };
107 
108 enum mlx5_ib_devx_umem_reg_attrs {
109 	MLX5_IB_ATTR_DEVX_UMEM_REG_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
110 	MLX5_IB_ATTR_DEVX_UMEM_REG_ADDR,
111 	MLX5_IB_ATTR_DEVX_UMEM_REG_LEN,
112 	MLX5_IB_ATTR_DEVX_UMEM_REG_ACCESS,
113 	MLX5_IB_ATTR_DEVX_UMEM_REG_OUT_ID,
114 };
115 
116 enum mlx5_ib_devx_umem_dereg_attrs {
117 	MLX5_IB_ATTR_DEVX_UMEM_DEREG_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
118 };
119 
120 enum mlx5_ib_devx_umem_methods {
121 	MLX5_IB_METHOD_DEVX_UMEM_REG = (1U << UVERBS_ID_NS_SHIFT),
122 	MLX5_IB_METHOD_DEVX_UMEM_DEREG,
123 };
124 
125 enum mlx5_ib_devx_async_cmd_fd_alloc_attrs {
126 	MLX5_IB_ATTR_DEVX_ASYNC_CMD_FD_ALLOC_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
127 };
128 
129 enum mlx5_ib_devx_async_cmd_fd_methods {
130 	MLX5_IB_METHOD_DEVX_ASYNC_CMD_FD_ALLOC = (1U << UVERBS_ID_NS_SHIFT),
131 };
132 
133 enum mlx5_ib_objects {
134 	MLX5_IB_OBJECT_DEVX = (1U << UVERBS_ID_NS_SHIFT),
135 	MLX5_IB_OBJECT_DEVX_OBJ,
136 	MLX5_IB_OBJECT_DEVX_UMEM,
137 	MLX5_IB_OBJECT_FLOW_MATCHER,
138 	MLX5_IB_OBJECT_DEVX_ASYNC_CMD_FD,
139 };
140 
141 enum mlx5_ib_flow_matcher_create_attrs {
142 	MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
143 	MLX5_IB_ATTR_FLOW_MATCHER_MATCH_MASK,
144 	MLX5_IB_ATTR_FLOW_MATCHER_FLOW_TYPE,
145 	MLX5_IB_ATTR_FLOW_MATCHER_MATCH_CRITERIA,
146 	MLX5_IB_ATTR_FLOW_MATCHER_FLOW_FLAGS,
147 };
148 
149 enum mlx5_ib_flow_matcher_destroy_attrs {
150 	MLX5_IB_ATTR_FLOW_MATCHER_DESTROY_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
151 };
152 
153 enum mlx5_ib_flow_matcher_methods {
154 	MLX5_IB_METHOD_FLOW_MATCHER_CREATE = (1U << UVERBS_ID_NS_SHIFT),
155 	MLX5_IB_METHOD_FLOW_MATCHER_DESTROY,
156 };
157 
158 #define MLX5_IB_DW_MATCH_PARAM 0x80
159 
160 struct mlx5_ib_match_params {
161 	__u32	match_params[MLX5_IB_DW_MATCH_PARAM];
162 };
163 
164 enum mlx5_ib_flow_type {
165 	MLX5_IB_FLOW_TYPE_NORMAL,
166 	MLX5_IB_FLOW_TYPE_SNIFFER,
167 	MLX5_IB_FLOW_TYPE_ALL_DEFAULT,
168 	MLX5_IB_FLOW_TYPE_MC_DEFAULT,
169 };
170 
171 enum mlx5_ib_create_flow_attrs {
172 	MLX5_IB_ATTR_CREATE_FLOW_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
173 	MLX5_IB_ATTR_CREATE_FLOW_MATCH_VALUE,
174 	MLX5_IB_ATTR_CREATE_FLOW_DEST_QP,
175 	MLX5_IB_ATTR_CREATE_FLOW_DEST_DEVX,
176 	MLX5_IB_ATTR_CREATE_FLOW_MATCHER,
177 	MLX5_IB_ATTR_CREATE_FLOW_ARR_FLOW_ACTIONS,
178 	MLX5_IB_ATTR_CREATE_FLOW_TAG,
179 	MLX5_IB_ATTR_CREATE_FLOW_ARR_COUNTERS_DEVX,
180 };
181 
182 enum mlx5_ib_destoy_flow_attrs {
183 	MLX5_IB_ATTR_DESTROY_FLOW_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
184 };
185 
186 enum mlx5_ib_flow_methods {
187 	MLX5_IB_METHOD_CREATE_FLOW = (1U << UVERBS_ID_NS_SHIFT),
188 	MLX5_IB_METHOD_DESTROY_FLOW,
189 };
190 
191 enum mlx5_ib_flow_action_methods {
192 	MLX5_IB_METHOD_FLOW_ACTION_CREATE_MODIFY_HEADER = (1U << UVERBS_ID_NS_SHIFT),
193 	MLX5_IB_METHOD_FLOW_ACTION_CREATE_PACKET_REFORMAT,
194 };
195 
196 enum mlx5_ib_create_flow_action_create_modify_header_attrs {
197 	MLX5_IB_ATTR_CREATE_MODIFY_HEADER_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
198 	MLX5_IB_ATTR_CREATE_MODIFY_HEADER_ACTIONS_PRM,
199 	MLX5_IB_ATTR_CREATE_MODIFY_HEADER_FT_TYPE,
200 };
201 
202 enum mlx5_ib_create_flow_action_create_packet_reformat_attrs {
203 	MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
204 	MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_TYPE,
205 	MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_FT_TYPE,
206 	MLX5_IB_ATTR_CREATE_PACKET_REFORMAT_DATA_BUF,
207 };
208 
209 #endif
210