xref: /openbmc/linux/include/uapi/rdma/rdma_netlink.h (revision ba61bb17)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_RDMA_NETLINK_H
3 #define _UAPI_RDMA_NETLINK_H
4 
5 #include <linux/types.h>
6 
7 enum {
8 	RDMA_NL_RDMA_CM = 1,
9 	RDMA_NL_IWCM,
10 	RDMA_NL_RSVD,
11 	RDMA_NL_LS,	/* RDMA Local Services */
12 	RDMA_NL_NLDEV,	/* RDMA device interface */
13 	RDMA_NL_NUM_CLIENTS
14 };
15 
16 enum {
17 	RDMA_NL_GROUP_CM = 1,
18 	RDMA_NL_GROUP_IWPM,
19 	RDMA_NL_GROUP_LS,
20 	RDMA_NL_NUM_GROUPS
21 };
22 
23 #define RDMA_NL_GET_CLIENT(type) ((type & (((1 << 6) - 1) << 10)) >> 10)
24 #define RDMA_NL_GET_OP(type) (type & ((1 << 10) - 1))
25 #define RDMA_NL_GET_TYPE(client, op) ((client << 10) + op)
26 
27 enum {
28 	RDMA_NL_RDMA_CM_ID_STATS = 0,
29 	RDMA_NL_RDMA_CM_NUM_OPS
30 };
31 
32 enum {
33 	RDMA_NL_RDMA_CM_ATTR_SRC_ADDR = 1,
34 	RDMA_NL_RDMA_CM_ATTR_DST_ADDR,
35 	RDMA_NL_RDMA_CM_NUM_ATTR,
36 };
37 
38 /* iwarp port mapper op-codes */
39 enum {
40 	RDMA_NL_IWPM_REG_PID = 0,
41 	RDMA_NL_IWPM_ADD_MAPPING,
42 	RDMA_NL_IWPM_QUERY_MAPPING,
43 	RDMA_NL_IWPM_REMOVE_MAPPING,
44 	RDMA_NL_IWPM_REMOTE_INFO,
45 	RDMA_NL_IWPM_HANDLE_ERR,
46 	RDMA_NL_IWPM_MAPINFO,
47 	RDMA_NL_IWPM_MAPINFO_NUM,
48 	RDMA_NL_IWPM_NUM_OPS
49 };
50 
51 struct rdma_cm_id_stats {
52 	__u32	qp_num;
53 	__u32	bound_dev_if;
54 	__u32	port_space;
55 	__s32	pid;
56 	__u8	cm_state;
57 	__u8	node_type;
58 	__u8	port_num;
59 	__u8	qp_type;
60 };
61 
62 enum {
63 	IWPM_NLA_REG_PID_UNSPEC = 0,
64 	IWPM_NLA_REG_PID_SEQ,
65 	IWPM_NLA_REG_IF_NAME,
66 	IWPM_NLA_REG_IBDEV_NAME,
67 	IWPM_NLA_REG_ULIB_NAME,
68 	IWPM_NLA_REG_PID_MAX
69 };
70 
71 enum {
72 	IWPM_NLA_RREG_PID_UNSPEC = 0,
73 	IWPM_NLA_RREG_PID_SEQ,
74 	IWPM_NLA_RREG_IBDEV_NAME,
75 	IWPM_NLA_RREG_ULIB_NAME,
76 	IWPM_NLA_RREG_ULIB_VER,
77 	IWPM_NLA_RREG_PID_ERR,
78 	IWPM_NLA_RREG_PID_MAX
79 
80 };
81 
82 enum {
83 	IWPM_NLA_MANAGE_MAPPING_UNSPEC = 0,
84 	IWPM_NLA_MANAGE_MAPPING_SEQ,
85 	IWPM_NLA_MANAGE_ADDR,
86 	IWPM_NLA_MANAGE_MAPPED_LOC_ADDR,
87 	IWPM_NLA_RMANAGE_MAPPING_ERR,
88 	IWPM_NLA_RMANAGE_MAPPING_MAX
89 };
90 
91 #define IWPM_NLA_MANAGE_MAPPING_MAX 3
92 #define IWPM_NLA_QUERY_MAPPING_MAX  4
93 #define IWPM_NLA_MAPINFO_SEND_MAX   3
94 
95 enum {
96 	IWPM_NLA_QUERY_MAPPING_UNSPEC = 0,
97 	IWPM_NLA_QUERY_MAPPING_SEQ,
98 	IWPM_NLA_QUERY_LOCAL_ADDR,
99 	IWPM_NLA_QUERY_REMOTE_ADDR,
100 	IWPM_NLA_RQUERY_MAPPED_LOC_ADDR,
101 	IWPM_NLA_RQUERY_MAPPED_REM_ADDR,
102 	IWPM_NLA_RQUERY_MAPPING_ERR,
103 	IWPM_NLA_RQUERY_MAPPING_MAX
104 };
105 
106 enum {
107 	IWPM_NLA_MAPINFO_REQ_UNSPEC = 0,
108 	IWPM_NLA_MAPINFO_ULIB_NAME,
109 	IWPM_NLA_MAPINFO_ULIB_VER,
110 	IWPM_NLA_MAPINFO_REQ_MAX
111 };
112 
113 enum {
114 	IWPM_NLA_MAPINFO_UNSPEC = 0,
115 	IWPM_NLA_MAPINFO_LOCAL_ADDR,
116 	IWPM_NLA_MAPINFO_MAPPED_ADDR,
117 	IWPM_NLA_MAPINFO_MAX
118 };
119 
120 enum {
121 	IWPM_NLA_MAPINFO_NUM_UNSPEC = 0,
122 	IWPM_NLA_MAPINFO_SEQ,
123 	IWPM_NLA_MAPINFO_SEND_NUM,
124 	IWPM_NLA_MAPINFO_ACK_NUM,
125 	IWPM_NLA_MAPINFO_NUM_MAX
126 };
127 
128 enum {
129 	IWPM_NLA_ERR_UNSPEC = 0,
130 	IWPM_NLA_ERR_SEQ,
131 	IWPM_NLA_ERR_CODE,
132 	IWPM_NLA_ERR_MAX
133 };
134 
135 /*
136  * Local service operations:
137  *   RESOLVE - The client requests the local service to resolve a path.
138  *   SET_TIMEOUT - The local service requests the client to set the timeout.
139  *   IP_RESOLVE - The client requests the local service to resolve an IP to GID.
140  */
141 enum {
142 	RDMA_NL_LS_OP_RESOLVE = 0,
143 	RDMA_NL_LS_OP_SET_TIMEOUT,
144 	RDMA_NL_LS_OP_IP_RESOLVE,
145 	RDMA_NL_LS_NUM_OPS
146 };
147 
148 /* Local service netlink message flags */
149 #define RDMA_NL_LS_F_ERR	0x0100	/* Failed response */
150 
151 /*
152  * Local service resolve operation family header.
153  * The layout for the resolve operation:
154  *    nlmsg header
155  *    family header
156  *    attributes
157  */
158 
159 /*
160  * Local service path use:
161  * Specify how the path(s) will be used.
162  *   ALL - For connected CM operation (6 pathrecords)
163  *   UNIDIRECTIONAL - For unidirectional UD (1 pathrecord)
164  *   GMP - For miscellaneous GMP like operation (at least 1 reversible
165  *         pathrecord)
166  */
167 enum {
168 	LS_RESOLVE_PATH_USE_ALL = 0,
169 	LS_RESOLVE_PATH_USE_UNIDIRECTIONAL,
170 	LS_RESOLVE_PATH_USE_GMP,
171 	LS_RESOLVE_PATH_USE_MAX
172 };
173 
174 #define LS_DEVICE_NAME_MAX 64
175 
176 struct rdma_ls_resolve_header {
177 	__u8 device_name[LS_DEVICE_NAME_MAX];
178 	__u8 port_num;
179 	__u8 path_use;
180 };
181 
182 struct rdma_ls_ip_resolve_header {
183 	__u32 ifindex;
184 };
185 
186 /* Local service attribute type */
187 #define RDMA_NLA_F_MANDATORY	(1 << 13)
188 #define RDMA_NLA_TYPE_MASK	(~(NLA_F_NESTED | NLA_F_NET_BYTEORDER | \
189 				  RDMA_NLA_F_MANDATORY))
190 
191 /*
192  * Local service attributes:
193  *   Attr Name       Size                       Byte order
194  *   -----------------------------------------------------
195  *   PATH_RECORD     struct ib_path_rec_data
196  *   TIMEOUT         u32                        cpu
197  *   SERVICE_ID      u64                        cpu
198  *   DGID            u8[16]                     BE
199  *   SGID            u8[16]                     BE
200  *   TCLASS          u8
201  *   PKEY            u16                        cpu
202  *   QOS_CLASS       u16                        cpu
203  *   IPV4            u32                        BE
204  *   IPV6            u8[16]                     BE
205  */
206 enum {
207 	LS_NLA_TYPE_UNSPEC = 0,
208 	LS_NLA_TYPE_PATH_RECORD,
209 	LS_NLA_TYPE_TIMEOUT,
210 	LS_NLA_TYPE_SERVICE_ID,
211 	LS_NLA_TYPE_DGID,
212 	LS_NLA_TYPE_SGID,
213 	LS_NLA_TYPE_TCLASS,
214 	LS_NLA_TYPE_PKEY,
215 	LS_NLA_TYPE_QOS_CLASS,
216 	LS_NLA_TYPE_IPV4,
217 	LS_NLA_TYPE_IPV6,
218 	LS_NLA_TYPE_MAX
219 };
220 
221 /* Local service DGID/SGID attribute: big endian */
222 struct rdma_nla_ls_gid {
223 	__u8		gid[16];
224 };
225 
226 enum rdma_nldev_command {
227 	RDMA_NLDEV_CMD_UNSPEC,
228 
229 	RDMA_NLDEV_CMD_GET, /* can dump */
230 
231 	/* 2 - 4 are free to use */
232 
233 	RDMA_NLDEV_CMD_PORT_GET = 5, /* can dump */
234 
235 	/* 6 - 8 are free to use */
236 
237 	RDMA_NLDEV_CMD_RES_GET = 9, /* can dump */
238 
239 	RDMA_NLDEV_CMD_RES_QP_GET, /* can dump */
240 
241 	RDMA_NLDEV_CMD_RES_CM_ID_GET, /* can dump */
242 
243 	RDMA_NLDEV_CMD_RES_CQ_GET, /* can dump */
244 
245 	RDMA_NLDEV_CMD_RES_MR_GET, /* can dump */
246 
247 	RDMA_NLDEV_CMD_RES_PD_GET, /* can dump */
248 
249 	RDMA_NLDEV_NUM_OPS
250 };
251 
252 enum {
253 	RDMA_NLDEV_ATTR_ENTRY_STRLEN = 16,
254 };
255 
256 enum rdma_nldev_print_type {
257 	RDMA_NLDEV_PRINT_TYPE_UNSPEC,
258 	RDMA_NLDEV_PRINT_TYPE_HEX,
259 };
260 
261 enum rdma_nldev_attr {
262 	/* don't change the order or add anything between, this is ABI! */
263 	RDMA_NLDEV_ATTR_UNSPEC,
264 
265 	/* Pad attribute for 64b alignment */
266 	RDMA_NLDEV_ATTR_PAD = RDMA_NLDEV_ATTR_UNSPEC,
267 
268 	/* Identifier for ib_device */
269 	RDMA_NLDEV_ATTR_DEV_INDEX,		/* u32 */
270 
271 	RDMA_NLDEV_ATTR_DEV_NAME,		/* string */
272 	/*
273 	 * Device index together with port index are identifiers
274 	 * for port/link properties.
275 	 *
276 	 * For RDMA_NLDEV_CMD_GET commamnd, port index will return number
277 	 * of available ports in ib_device, while for port specific operations,
278 	 * it will be real port index as it appears in sysfs. Port index follows
279 	 * sysfs notation and starts from 1 for the first port.
280 	 */
281 	RDMA_NLDEV_ATTR_PORT_INDEX,		/* u32 */
282 
283 	/*
284 	 * Device and port capabilities
285 	 */
286 	RDMA_NLDEV_ATTR_CAP_FLAGS,		/* u64 */
287 
288 	/*
289 	 * FW version
290 	 */
291 	RDMA_NLDEV_ATTR_FW_VERSION,		/* string */
292 
293 	/*
294 	 * Node GUID (in host byte order) associated with the RDMA device.
295 	 */
296 	RDMA_NLDEV_ATTR_NODE_GUID,			/* u64 */
297 
298 	/*
299 	 * System image GUID (in host byte order) associated with
300 	 * this RDMA device and other devices which are part of a
301 	 * single system.
302 	 */
303 	RDMA_NLDEV_ATTR_SYS_IMAGE_GUID,		/* u64 */
304 
305 	/*
306 	 * Subnet prefix (in host byte order)
307 	 */
308 	RDMA_NLDEV_ATTR_SUBNET_PREFIX,		/* u64 */
309 
310 	/*
311 	 * Local Identifier (LID),
312 	 * According to IB specification, It is 16-bit address assigned
313 	 * by the Subnet Manager. Extended to be 32-bit for OmniPath users.
314 	 */
315 	RDMA_NLDEV_ATTR_LID,			/* u32 */
316 	RDMA_NLDEV_ATTR_SM_LID,			/* u32 */
317 
318 	/*
319 	 * LID mask control (LMC)
320 	 */
321 	RDMA_NLDEV_ATTR_LMC,			/* u8 */
322 
323 	RDMA_NLDEV_ATTR_PORT_STATE,		/* u8 */
324 	RDMA_NLDEV_ATTR_PORT_PHYS_STATE,	/* u8 */
325 
326 	RDMA_NLDEV_ATTR_DEV_NODE_TYPE,		/* u8 */
327 
328 	RDMA_NLDEV_ATTR_RES_SUMMARY,		/* nested table */
329 	RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY,	/* nested table */
330 	RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME,	/* string */
331 	RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR,	/* u64 */
332 
333 	RDMA_NLDEV_ATTR_RES_QP,			/* nested table */
334 	RDMA_NLDEV_ATTR_RES_QP_ENTRY,		/* nested table */
335 	/*
336 	 * Local QPN
337 	 */
338 	RDMA_NLDEV_ATTR_RES_LQPN,		/* u32 */
339 	/*
340 	 * Remote QPN,
341 	 * Applicable for RC and UC only IBTA 11.2.5.3 QUERY QUEUE PAIR
342 	 */
343 	RDMA_NLDEV_ATTR_RES_RQPN,		/* u32 */
344 	/*
345 	 * Receive Queue PSN,
346 	 * Applicable for RC and UC only 11.2.5.3 QUERY QUEUE PAIR
347 	 */
348 	RDMA_NLDEV_ATTR_RES_RQ_PSN,		/* u32 */
349 	/*
350 	 * Send Queue PSN
351 	 */
352 	RDMA_NLDEV_ATTR_RES_SQ_PSN,		/* u32 */
353 	RDMA_NLDEV_ATTR_RES_PATH_MIG_STATE,	/* u8 */
354 	/*
355 	 * QP types as visible to RDMA/core, the reserved QPT
356 	 * are not exported through this interface.
357 	 */
358 	RDMA_NLDEV_ATTR_RES_TYPE,		/* u8 */
359 	RDMA_NLDEV_ATTR_RES_STATE,		/* u8 */
360 	/*
361 	 * Process ID which created object,
362 	 * in case of kernel origin, PID won't exist.
363 	 */
364 	RDMA_NLDEV_ATTR_RES_PID,		/* u32 */
365 	/*
366 	 * The name of process created following resource.
367 	 * It will exist only for kernel objects.
368 	 * For user created objects, the user is supposed
369 	 * to read /proc/PID/comm file.
370 	 */
371 	RDMA_NLDEV_ATTR_RES_KERN_NAME,		/* string */
372 
373 	RDMA_NLDEV_ATTR_RES_CM_ID,		/* nested table */
374 	RDMA_NLDEV_ATTR_RES_CM_ID_ENTRY,	/* nested table */
375 	/*
376 	 * rdma_cm_id port space.
377 	 */
378 	RDMA_NLDEV_ATTR_RES_PS,			/* u32 */
379 	/*
380 	 * Source and destination socket addresses
381 	 */
382 	RDMA_NLDEV_ATTR_RES_SRC_ADDR,		/* __kernel_sockaddr_storage */
383 	RDMA_NLDEV_ATTR_RES_DST_ADDR,		/* __kernel_sockaddr_storage */
384 
385 	RDMA_NLDEV_ATTR_RES_CQ,			/* nested table */
386 	RDMA_NLDEV_ATTR_RES_CQ_ENTRY,		/* nested table */
387 	RDMA_NLDEV_ATTR_RES_CQE,		/* u32 */
388 	RDMA_NLDEV_ATTR_RES_USECNT,		/* u64 */
389 	RDMA_NLDEV_ATTR_RES_POLL_CTX,		/* u8 */
390 
391 	RDMA_NLDEV_ATTR_RES_MR,			/* nested table */
392 	RDMA_NLDEV_ATTR_RES_MR_ENTRY,		/* nested table */
393 	RDMA_NLDEV_ATTR_RES_RKEY,		/* u32 */
394 	RDMA_NLDEV_ATTR_RES_LKEY,		/* u32 */
395 	RDMA_NLDEV_ATTR_RES_IOVA,		/* u64 */
396 	RDMA_NLDEV_ATTR_RES_MRLEN,		/* u64 */
397 
398 	RDMA_NLDEV_ATTR_RES_PD,			/* nested table */
399 	RDMA_NLDEV_ATTR_RES_PD_ENTRY,		/* nested table */
400 	RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY,	/* u32 */
401 	RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY,	/* u32 */
402 	/*
403 	 * Provides logical name and index of netdevice which is
404 	 * connected to physical port. This information is relevant
405 	 * for RoCE and iWARP.
406 	 *
407 	 * The netdevices which are associated with containers are
408 	 * supposed to be exported together with GID table once it
409 	 * will be exposed through the netlink. Because the
410 	 * associated netdevices are properties of GIDs.
411 	 */
412 	RDMA_NLDEV_ATTR_NDEV_INDEX,		/* u32 */
413 	RDMA_NLDEV_ATTR_NDEV_NAME,		/* string */
414 	/*
415 	 * driver-specific attributes.
416 	 */
417 	RDMA_NLDEV_ATTR_DRIVER,			/* nested table */
418 	RDMA_NLDEV_ATTR_DRIVER_ENTRY,		/* nested table */
419 	RDMA_NLDEV_ATTR_DRIVER_STRING,		/* string */
420 	/*
421 	 * u8 values from enum rdma_nldev_print_type
422 	 */
423 	RDMA_NLDEV_ATTR_DRIVER_PRINT_TYPE,	/* u8 */
424 	RDMA_NLDEV_ATTR_DRIVER_S32,		/* s32 */
425 	RDMA_NLDEV_ATTR_DRIVER_U32,		/* u32 */
426 	RDMA_NLDEV_ATTR_DRIVER_S64,		/* s64 */
427 	RDMA_NLDEV_ATTR_DRIVER_U64,		/* u64 */
428 
429 	/*
430 	 * Always the end
431 	 */
432 	RDMA_NLDEV_ATTR_MAX
433 };
434 #endif /* _UAPI_RDMA_NETLINK_H */
435