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