xref: /linux/include/uapi/rdma/rdma_netlink.h (revision 1a7a05e88fa0e4e168f83585d1bb1937197a9745)
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 	/* 3 - 4 are free to use */
259 
260 	RDMA_NLDEV_CMD_PORT_GET = 5, /* can dump */
261 
262 	/* 6 - 8 are free to use */
263 
264 	RDMA_NLDEV_CMD_RES_GET = 9, /* can dump */
265 
266 	RDMA_NLDEV_CMD_RES_QP_GET, /* can dump */
267 
268 	RDMA_NLDEV_CMD_RES_CM_ID_GET, /* can dump */
269 
270 	RDMA_NLDEV_CMD_RES_CQ_GET, /* can dump */
271 
272 	RDMA_NLDEV_CMD_RES_MR_GET, /* can dump */
273 
274 	RDMA_NLDEV_CMD_RES_PD_GET, /* can dump */
275 
276 	RDMA_NLDEV_NUM_OPS
277 };
278 
279 enum {
280 	RDMA_NLDEV_ATTR_ENTRY_STRLEN = 16,
281 };
282 
283 enum rdma_nldev_print_type {
284 	RDMA_NLDEV_PRINT_TYPE_UNSPEC,
285 	RDMA_NLDEV_PRINT_TYPE_HEX,
286 };
287 
288 enum rdma_nldev_attr {
289 	/* don't change the order or add anything between, this is ABI! */
290 	RDMA_NLDEV_ATTR_UNSPEC,
291 
292 	/* Pad attribute for 64b alignment */
293 	RDMA_NLDEV_ATTR_PAD = RDMA_NLDEV_ATTR_UNSPEC,
294 
295 	/* Identifier for ib_device */
296 	RDMA_NLDEV_ATTR_DEV_INDEX,		/* u32 */
297 
298 	RDMA_NLDEV_ATTR_DEV_NAME,		/* string */
299 	/*
300 	 * Device index together with port index are identifiers
301 	 * for port/link properties.
302 	 *
303 	 * For RDMA_NLDEV_CMD_GET commamnd, port index will return number
304 	 * of available ports in ib_device, while for port specific operations,
305 	 * it will be real port index as it appears in sysfs. Port index follows
306 	 * sysfs notation and starts from 1 for the first port.
307 	 */
308 	RDMA_NLDEV_ATTR_PORT_INDEX,		/* u32 */
309 
310 	/*
311 	 * Device and port capabilities
312 	 *
313 	 * When used for port info, first 32-bits are CapabilityMask followed by
314 	 * 16-bit CapabilityMask2.
315 	 */
316 	RDMA_NLDEV_ATTR_CAP_FLAGS,		/* u64 */
317 
318 	/*
319 	 * FW version
320 	 */
321 	RDMA_NLDEV_ATTR_FW_VERSION,		/* string */
322 
323 	/*
324 	 * Node GUID (in host byte order) associated with the RDMA device.
325 	 */
326 	RDMA_NLDEV_ATTR_NODE_GUID,			/* u64 */
327 
328 	/*
329 	 * System image GUID (in host byte order) associated with
330 	 * this RDMA device and other devices which are part of a
331 	 * single system.
332 	 */
333 	RDMA_NLDEV_ATTR_SYS_IMAGE_GUID,		/* u64 */
334 
335 	/*
336 	 * Subnet prefix (in host byte order)
337 	 */
338 	RDMA_NLDEV_ATTR_SUBNET_PREFIX,		/* u64 */
339 
340 	/*
341 	 * Local Identifier (LID),
342 	 * According to IB specification, It is 16-bit address assigned
343 	 * by the Subnet Manager. Extended to be 32-bit for OmniPath users.
344 	 */
345 	RDMA_NLDEV_ATTR_LID,			/* u32 */
346 	RDMA_NLDEV_ATTR_SM_LID,			/* u32 */
347 
348 	/*
349 	 * LID mask control (LMC)
350 	 */
351 	RDMA_NLDEV_ATTR_LMC,			/* u8 */
352 
353 	RDMA_NLDEV_ATTR_PORT_STATE,		/* u8 */
354 	RDMA_NLDEV_ATTR_PORT_PHYS_STATE,	/* u8 */
355 
356 	RDMA_NLDEV_ATTR_DEV_NODE_TYPE,		/* u8 */
357 
358 	RDMA_NLDEV_ATTR_RES_SUMMARY,		/* nested table */
359 	RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY,	/* nested table */
360 	RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME,	/* string */
361 	RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR,	/* u64 */
362 
363 	RDMA_NLDEV_ATTR_RES_QP,			/* nested table */
364 	RDMA_NLDEV_ATTR_RES_QP_ENTRY,		/* nested table */
365 	/*
366 	 * Local QPN
367 	 */
368 	RDMA_NLDEV_ATTR_RES_LQPN,		/* u32 */
369 	/*
370 	 * Remote QPN,
371 	 * Applicable for RC and UC only IBTA 11.2.5.3 QUERY QUEUE PAIR
372 	 */
373 	RDMA_NLDEV_ATTR_RES_RQPN,		/* u32 */
374 	/*
375 	 * Receive Queue PSN,
376 	 * Applicable for RC and UC only 11.2.5.3 QUERY QUEUE PAIR
377 	 */
378 	RDMA_NLDEV_ATTR_RES_RQ_PSN,		/* u32 */
379 	/*
380 	 * Send Queue PSN
381 	 */
382 	RDMA_NLDEV_ATTR_RES_SQ_PSN,		/* u32 */
383 	RDMA_NLDEV_ATTR_RES_PATH_MIG_STATE,	/* u8 */
384 	/*
385 	 * QP types as visible to RDMA/core, the reserved QPT
386 	 * are not exported through this interface.
387 	 */
388 	RDMA_NLDEV_ATTR_RES_TYPE,		/* u8 */
389 	RDMA_NLDEV_ATTR_RES_STATE,		/* u8 */
390 	/*
391 	 * Process ID which created object,
392 	 * in case of kernel origin, PID won't exist.
393 	 */
394 	RDMA_NLDEV_ATTR_RES_PID,		/* u32 */
395 	/*
396 	 * The name of process created following resource.
397 	 * It will exist only for kernel objects.
398 	 * For user created objects, the user is supposed
399 	 * to read /proc/PID/comm file.
400 	 */
401 	RDMA_NLDEV_ATTR_RES_KERN_NAME,		/* string */
402 
403 	RDMA_NLDEV_ATTR_RES_CM_ID,		/* nested table */
404 	RDMA_NLDEV_ATTR_RES_CM_ID_ENTRY,	/* nested table */
405 	/*
406 	 * rdma_cm_id port space.
407 	 */
408 	RDMA_NLDEV_ATTR_RES_PS,			/* u32 */
409 	/*
410 	 * Source and destination socket addresses
411 	 */
412 	RDMA_NLDEV_ATTR_RES_SRC_ADDR,		/* __kernel_sockaddr_storage */
413 	RDMA_NLDEV_ATTR_RES_DST_ADDR,		/* __kernel_sockaddr_storage */
414 
415 	RDMA_NLDEV_ATTR_RES_CQ,			/* nested table */
416 	RDMA_NLDEV_ATTR_RES_CQ_ENTRY,		/* nested table */
417 	RDMA_NLDEV_ATTR_RES_CQE,		/* u32 */
418 	RDMA_NLDEV_ATTR_RES_USECNT,		/* u64 */
419 	RDMA_NLDEV_ATTR_RES_POLL_CTX,		/* u8 */
420 
421 	RDMA_NLDEV_ATTR_RES_MR,			/* nested table */
422 	RDMA_NLDEV_ATTR_RES_MR_ENTRY,		/* nested table */
423 	RDMA_NLDEV_ATTR_RES_RKEY,		/* u32 */
424 	RDMA_NLDEV_ATTR_RES_LKEY,		/* u32 */
425 	RDMA_NLDEV_ATTR_RES_IOVA,		/* u64 */
426 	RDMA_NLDEV_ATTR_RES_MRLEN,		/* u64 */
427 
428 	RDMA_NLDEV_ATTR_RES_PD,			/* nested table */
429 	RDMA_NLDEV_ATTR_RES_PD_ENTRY,		/* nested table */
430 	RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY,	/* u32 */
431 	RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY,	/* u32 */
432 	/*
433 	 * Provides logical name and index of netdevice which is
434 	 * connected to physical port. This information is relevant
435 	 * for RoCE and iWARP.
436 	 *
437 	 * The netdevices which are associated with containers are
438 	 * supposed to be exported together with GID table once it
439 	 * will be exposed through the netlink. Because the
440 	 * associated netdevices are properties of GIDs.
441 	 */
442 	RDMA_NLDEV_ATTR_NDEV_INDEX,		/* u32 */
443 	RDMA_NLDEV_ATTR_NDEV_NAME,		/* string */
444 	/*
445 	 * driver-specific attributes.
446 	 */
447 	RDMA_NLDEV_ATTR_DRIVER,			/* nested table */
448 	RDMA_NLDEV_ATTR_DRIVER_ENTRY,		/* nested table */
449 	RDMA_NLDEV_ATTR_DRIVER_STRING,		/* string */
450 	/*
451 	 * u8 values from enum rdma_nldev_print_type
452 	 */
453 	RDMA_NLDEV_ATTR_DRIVER_PRINT_TYPE,	/* u8 */
454 	RDMA_NLDEV_ATTR_DRIVER_S32,		/* s32 */
455 	RDMA_NLDEV_ATTR_DRIVER_U32,		/* u32 */
456 	RDMA_NLDEV_ATTR_DRIVER_S64,		/* s64 */
457 	RDMA_NLDEV_ATTR_DRIVER_U64,		/* u64 */
458 
459 	/*
460 	 * Always the end
461 	 */
462 	RDMA_NLDEV_ATTR_MAX
463 };
464 #endif /* _UAPI_RDMA_NETLINK_H */
465