1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
2 /*
3  * Copyright (c) 2017-2018, Mellanox Technologies inc.  All rights reserved.
4  *
5  * This software is available to you under a choice of one of two
6  * licenses.  You may choose to be licensed under the terms of the GNU
7  * General Public License (GPL) Version 2, available from the file
8  * COPYING in the main directory of this source tree, or the
9  * OpenIB.org BSD license below:
10  *
11  *     Redistribution and use in source and binary forms, with or
12  *     without modification, are permitted provided that the following
13  *     conditions are met:
14  *
15  *      - Redistributions of source code must retain the above
16  *        copyright notice, this list of conditions and the following
17  *        disclaimer.
18  *
19  *      - Redistributions in binary form must reproduce the above
20  *        copyright notice, this list of conditions and the following
21  *        disclaimer in the documentation and/or other materials
22  *        provided with the distribution.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  */
33 
34 #ifndef IB_USER_IOCTL_VERBS_H
35 #define IB_USER_IOCTL_VERBS_H
36 
37 #include <linux/types.h>
38 #include <rdma/ib_user_verbs.h>
39 
40 #ifndef RDMA_UAPI_PTR
41 #define RDMA_UAPI_PTR(_type, _name)	__aligned_u64 _name
42 #endif
43 
44 #define IB_UVERBS_ACCESS_OPTIONAL_FIRST (1 << 20)
45 #define IB_UVERBS_ACCESS_OPTIONAL_LAST (1 << 29)
46 
47 enum ib_uverbs_core_support {
48 	IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS = 1 << 0,
49 };
50 
51 enum ib_uverbs_access_flags {
52 	IB_UVERBS_ACCESS_LOCAL_WRITE = 1 << 0,
53 	IB_UVERBS_ACCESS_REMOTE_WRITE = 1 << 1,
54 	IB_UVERBS_ACCESS_REMOTE_READ = 1 << 2,
55 	IB_UVERBS_ACCESS_REMOTE_ATOMIC = 1 << 3,
56 	IB_UVERBS_ACCESS_MW_BIND = 1 << 4,
57 	IB_UVERBS_ACCESS_ZERO_BASED = 1 << 5,
58 	IB_UVERBS_ACCESS_ON_DEMAND = 1 << 6,
59 	IB_UVERBS_ACCESS_HUGETLB = 1 << 7,
60 
61 	IB_UVERBS_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST,
62 	IB_UVERBS_ACCESS_OPTIONAL_RANGE =
63 		((IB_UVERBS_ACCESS_OPTIONAL_LAST << 1) - 1) &
64 		~(IB_UVERBS_ACCESS_OPTIONAL_FIRST - 1)
65 };
66 
67 enum ib_uverbs_srq_type {
68 	IB_UVERBS_SRQT_BASIC,
69 	IB_UVERBS_SRQT_XRC,
70 	IB_UVERBS_SRQT_TM,
71 };
72 
73 enum ib_uverbs_wq_type {
74 	IB_UVERBS_WQT_RQ,
75 };
76 
77 enum ib_uverbs_wq_flags {
78 	IB_UVERBS_WQ_FLAGS_CVLAN_STRIPPING = 1 << 0,
79 	IB_UVERBS_WQ_FLAGS_SCATTER_FCS = 1 << 1,
80 	IB_UVERBS_WQ_FLAGS_DELAY_DROP = 1 << 2,
81 	IB_UVERBS_WQ_FLAGS_PCI_WRITE_END_PADDING = 1 << 3,
82 };
83 
84 enum ib_uverbs_qp_type {
85 	IB_UVERBS_QPT_RC = 2,
86 	IB_UVERBS_QPT_UC,
87 	IB_UVERBS_QPT_UD,
88 	IB_UVERBS_QPT_RAW_PACKET = 8,
89 	IB_UVERBS_QPT_XRC_INI,
90 	IB_UVERBS_QPT_XRC_TGT,
91 	IB_UVERBS_QPT_DRIVER = 0xFF,
92 };
93 
94 enum ib_uverbs_qp_create_flags {
95 	IB_UVERBS_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1,
96 	IB_UVERBS_QP_CREATE_SCATTER_FCS = 1 << 8,
97 	IB_UVERBS_QP_CREATE_CVLAN_STRIPPING = 1 << 9,
98 	IB_UVERBS_QP_CREATE_PCI_WRITE_END_PADDING = 1 << 11,
99 	IB_UVERBS_QP_CREATE_SQ_SIG_ALL = 1 << 12,
100 };
101 
102 enum ib_uverbs_query_port_cap_flags {
103 	IB_UVERBS_PCF_SM = 1 << 1,
104 	IB_UVERBS_PCF_NOTICE_SUP = 1 << 2,
105 	IB_UVERBS_PCF_TRAP_SUP = 1 << 3,
106 	IB_UVERBS_PCF_OPT_IPD_SUP = 1 << 4,
107 	IB_UVERBS_PCF_AUTO_MIGR_SUP = 1 << 5,
108 	IB_UVERBS_PCF_SL_MAP_SUP = 1 << 6,
109 	IB_UVERBS_PCF_MKEY_NVRAM = 1 << 7,
110 	IB_UVERBS_PCF_PKEY_NVRAM = 1 << 8,
111 	IB_UVERBS_PCF_LED_INFO_SUP = 1 << 9,
112 	IB_UVERBS_PCF_SM_DISABLED = 1 << 10,
113 	IB_UVERBS_PCF_SYS_IMAGE_GUID_SUP = 1 << 11,
114 	IB_UVERBS_PCF_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
115 	IB_UVERBS_PCF_EXTENDED_SPEEDS_SUP = 1 << 14,
116 	IB_UVERBS_PCF_CM_SUP = 1 << 16,
117 	IB_UVERBS_PCF_SNMP_TUNNEL_SUP = 1 << 17,
118 	IB_UVERBS_PCF_REINIT_SUP = 1 << 18,
119 	IB_UVERBS_PCF_DEVICE_MGMT_SUP = 1 << 19,
120 	IB_UVERBS_PCF_VENDOR_CLASS_SUP = 1 << 20,
121 	IB_UVERBS_PCF_DR_NOTICE_SUP = 1 << 21,
122 	IB_UVERBS_PCF_CAP_MASK_NOTICE_SUP = 1 << 22,
123 	IB_UVERBS_PCF_BOOT_MGMT_SUP = 1 << 23,
124 	IB_UVERBS_PCF_LINK_LATENCY_SUP = 1 << 24,
125 	IB_UVERBS_PCF_CLIENT_REG_SUP = 1 << 25,
126 	/*
127 	 * IsOtherLocalChangesNoticeSupported is aliased by IP_BASED_GIDS and
128 	 * is inaccessible
129 	 */
130 	IB_UVERBS_PCF_LINK_SPEED_WIDTH_TABLE_SUP = 1 << 27,
131 	IB_UVERBS_PCF_VENDOR_SPECIFIC_MADS_TABLE_SUP = 1 << 28,
132 	IB_UVERBS_PCF_MCAST_PKEY_TRAP_SUPPRESSION_SUP = 1 << 29,
133 	IB_UVERBS_PCF_MCAST_FDB_TOP_SUP = 1 << 30,
134 	IB_UVERBS_PCF_HIERARCHY_INFO_SUP = 1ULL << 31,
135 
136 	/* NOTE this is an internal flag, not an IBA flag */
137 	IB_UVERBS_PCF_IP_BASED_GIDS = 1 << 26,
138 };
139 
140 enum ib_uverbs_query_port_flags {
141 	IB_UVERBS_QPF_GRH_REQUIRED = 1 << 0,
142 };
143 
144 enum ib_uverbs_flow_action_esp_keymat {
145 	IB_UVERBS_FLOW_ACTION_ESP_KEYMAT_AES_GCM,
146 };
147 
148 enum ib_uverbs_flow_action_esp_keymat_aes_gcm_iv_algo {
149 	IB_UVERBS_FLOW_ACTION_IV_ALGO_SEQ,
150 };
151 
152 struct ib_uverbs_flow_action_esp_keymat_aes_gcm {
153 	__aligned_u64	iv;
154 	__u32		iv_algo; /* Use enum ib_uverbs_flow_action_esp_keymat_aes_gcm_iv_algo */
155 
156 	__u32		salt;
157 	__u32		icv_len;
158 
159 	__u32		key_len;
160 	__u32		aes_key[256 / 32];
161 };
162 
163 enum ib_uverbs_flow_action_esp_replay {
164 	IB_UVERBS_FLOW_ACTION_ESP_REPLAY_NONE,
165 	IB_UVERBS_FLOW_ACTION_ESP_REPLAY_BMP,
166 };
167 
168 struct ib_uverbs_flow_action_esp_replay_bmp {
169 	__u32	size;
170 };
171 
172 enum ib_uverbs_flow_action_esp_flags {
173 	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_INLINE_CRYPTO	= 0UL << 0,	/* Default */
174 	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_FULL_OFFLOAD	= 1UL << 0,
175 
176 	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_TUNNEL		= 0UL << 1,	/* Default */
177 	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_TRANSPORT	= 1UL << 1,
178 
179 	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_DECRYPT		= 0UL << 2,	/* Default */
180 	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ENCRYPT		= 1UL << 2,
181 
182 	IB_UVERBS_FLOW_ACTION_ESP_FLAGS_ESN_NEW_WINDOW	= 1UL << 3,
183 };
184 
185 struct ib_uverbs_flow_action_esp_encap {
186 	/* This struct represents a list of pointers to flow_xxxx_filter that
187 	 * encapsulates the payload in ESP tunnel mode.
188 	 */
189 	RDMA_UAPI_PTR(void *, val_ptr); /* pointer to a flow_xxxx_filter */
190 	RDMA_UAPI_PTR(struct ib_uverbs_flow_action_esp_encap *, next_ptr);
191 	__u16	len;		/* Len of the filter struct val_ptr points to */
192 	__u16	type;		/* Use flow_spec_type enum */
193 };
194 
195 struct ib_uverbs_flow_action_esp {
196 	__u32		spi;
197 	__u32		seq;
198 	__u32		tfc_pad;
199 	__u32		flags;
200 	__aligned_u64	hard_limit_pkts;
201 };
202 
203 enum ib_uverbs_read_counters_flags {
204 	/* prefer read values from driver cache */
205 	IB_UVERBS_READ_COUNTERS_PREFER_CACHED = 1 << 0,
206 };
207 
208 enum ib_uverbs_advise_mr_advice {
209 	IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH,
210 	IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_WRITE,
211 	IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_NO_FAULT,
212 };
213 
214 enum ib_uverbs_advise_mr_flag {
215 	IB_UVERBS_ADVISE_MR_FLAG_FLUSH = 1 << 0,
216 };
217 
218 struct ib_uverbs_query_port_resp_ex {
219 	struct ib_uverbs_query_port_resp legacy_resp;
220 	__u16 port_cap_flags2;
221 	__u8  reserved[6];
222 };
223 
224 struct ib_uverbs_qp_cap {
225 	__u32 max_send_wr;
226 	__u32 max_recv_wr;
227 	__u32 max_send_sge;
228 	__u32 max_recv_sge;
229 	__u32 max_inline_data;
230 };
231 
232 enum rdma_driver_id {
233 	RDMA_DRIVER_UNKNOWN,
234 	RDMA_DRIVER_MLX5,
235 	RDMA_DRIVER_MLX4,
236 	RDMA_DRIVER_CXGB3,
237 	RDMA_DRIVER_CXGB4,
238 	RDMA_DRIVER_MTHCA,
239 	RDMA_DRIVER_BNXT_RE,
240 	RDMA_DRIVER_OCRDMA,
241 	RDMA_DRIVER_NES,
242 	RDMA_DRIVER_I40IW,
243 	RDMA_DRIVER_VMW_PVRDMA,
244 	RDMA_DRIVER_QEDR,
245 	RDMA_DRIVER_HNS,
246 	RDMA_DRIVER_USNIC,
247 	RDMA_DRIVER_RXE,
248 	RDMA_DRIVER_HFI1,
249 	RDMA_DRIVER_QIB,
250 	RDMA_DRIVER_EFA,
251 	RDMA_DRIVER_SIW,
252 };
253 
254 enum ib_uverbs_gid_type {
255 	IB_UVERBS_GID_TYPE_IB,
256 	IB_UVERBS_GID_TYPE_ROCE_V1,
257 	IB_UVERBS_GID_TYPE_ROCE_V2,
258 };
259 
260 struct ib_uverbs_gid_entry {
261 	__aligned_u64 gid[2];
262 	__u32 gid_index;
263 	__u32 port_num;
264 	__u32 gid_type;
265 	__u32 netdev_ifindex; /* It is 0 if there is no netdev associated with it */
266 };
267 
268 #endif
269