1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3  * include/uapi/linux/devlink.h - Network physical device Netlink interface
4  * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
5  * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  */
12 
13 #ifndef _UAPI_LINUX_DEVLINK_H_
14 #define _UAPI_LINUX_DEVLINK_H_
15 
16 #include <linux/const.h>
17 
18 #define DEVLINK_GENL_NAME "devlink"
19 #define DEVLINK_GENL_VERSION 0x1
20 #define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
21 
22 enum devlink_command {
23 	/* don't change the order or add anything between, this is ABI! */
24 	DEVLINK_CMD_UNSPEC,
25 
26 	DEVLINK_CMD_GET,		/* can dump */
27 	DEVLINK_CMD_SET,
28 	DEVLINK_CMD_NEW,
29 	DEVLINK_CMD_DEL,
30 
31 	DEVLINK_CMD_PORT_GET,		/* can dump */
32 	DEVLINK_CMD_PORT_SET,
33 	DEVLINK_CMD_PORT_NEW,
34 	DEVLINK_CMD_PORT_DEL,
35 
36 	DEVLINK_CMD_PORT_SPLIT,
37 	DEVLINK_CMD_PORT_UNSPLIT,
38 
39 	DEVLINK_CMD_SB_GET,		/* can dump */
40 	DEVLINK_CMD_SB_SET,
41 	DEVLINK_CMD_SB_NEW,
42 	DEVLINK_CMD_SB_DEL,
43 
44 	DEVLINK_CMD_SB_POOL_GET,	/* can dump */
45 	DEVLINK_CMD_SB_POOL_SET,
46 	DEVLINK_CMD_SB_POOL_NEW,
47 	DEVLINK_CMD_SB_POOL_DEL,
48 
49 	DEVLINK_CMD_SB_PORT_POOL_GET,	/* can dump */
50 	DEVLINK_CMD_SB_PORT_POOL_SET,
51 	DEVLINK_CMD_SB_PORT_POOL_NEW,
52 	DEVLINK_CMD_SB_PORT_POOL_DEL,
53 
54 	DEVLINK_CMD_SB_TC_POOL_BIND_GET,	/* can dump */
55 	DEVLINK_CMD_SB_TC_POOL_BIND_SET,
56 	DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
57 	DEVLINK_CMD_SB_TC_POOL_BIND_DEL,
58 
59 	/* Shared buffer occupancy monitoring commands */
60 	DEVLINK_CMD_SB_OCC_SNAPSHOT,
61 	DEVLINK_CMD_SB_OCC_MAX_CLEAR,
62 
63 	DEVLINK_CMD_ESWITCH_GET,
64 #define DEVLINK_CMD_ESWITCH_MODE_GET /* obsolete, never use this! */ \
65 	DEVLINK_CMD_ESWITCH_GET
66 
67 	DEVLINK_CMD_ESWITCH_SET,
68 #define DEVLINK_CMD_ESWITCH_MODE_SET /* obsolete, never use this! */ \
69 	DEVLINK_CMD_ESWITCH_SET
70 
71 	DEVLINK_CMD_DPIPE_TABLE_GET,
72 	DEVLINK_CMD_DPIPE_ENTRIES_GET,
73 	DEVLINK_CMD_DPIPE_HEADERS_GET,
74 	DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
75 	DEVLINK_CMD_RESOURCE_SET,
76 	DEVLINK_CMD_RESOURCE_DUMP,
77 
78 	/* Hot driver reload, makes configuration changes take place. The
79 	 * devlink instance is not released during the process.
80 	 */
81 	DEVLINK_CMD_RELOAD,
82 
83 	DEVLINK_CMD_PARAM_GET,		/* can dump */
84 	DEVLINK_CMD_PARAM_SET,
85 	DEVLINK_CMD_PARAM_NEW,
86 	DEVLINK_CMD_PARAM_DEL,
87 
88 	DEVLINK_CMD_REGION_GET,
89 	DEVLINK_CMD_REGION_SET,
90 	DEVLINK_CMD_REGION_NEW,
91 	DEVLINK_CMD_REGION_DEL,
92 	DEVLINK_CMD_REGION_READ,
93 
94 	DEVLINK_CMD_PORT_PARAM_GET,	/* can dump */
95 	DEVLINK_CMD_PORT_PARAM_SET,
96 	DEVLINK_CMD_PORT_PARAM_NEW,
97 	DEVLINK_CMD_PORT_PARAM_DEL,
98 
99 	DEVLINK_CMD_INFO_GET,		/* can dump */
100 
101 	DEVLINK_CMD_HEALTH_REPORTER_GET,
102 	DEVLINK_CMD_HEALTH_REPORTER_SET,
103 	DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
104 	DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
105 	DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
106 	DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR,
107 
108 	DEVLINK_CMD_FLASH_UPDATE,
109 	DEVLINK_CMD_FLASH_UPDATE_END,		/* notification only */
110 	DEVLINK_CMD_FLASH_UPDATE_STATUS,	/* notification only */
111 
112 	DEVLINK_CMD_TRAP_GET,		/* can dump */
113 	DEVLINK_CMD_TRAP_SET,
114 	DEVLINK_CMD_TRAP_NEW,
115 	DEVLINK_CMD_TRAP_DEL,
116 
117 	DEVLINK_CMD_TRAP_GROUP_GET,	/* can dump */
118 	DEVLINK_CMD_TRAP_GROUP_SET,
119 	DEVLINK_CMD_TRAP_GROUP_NEW,
120 	DEVLINK_CMD_TRAP_GROUP_DEL,
121 
122 	DEVLINK_CMD_TRAP_POLICER_GET,	/* can dump */
123 	DEVLINK_CMD_TRAP_POLICER_SET,
124 	DEVLINK_CMD_TRAP_POLICER_NEW,
125 	DEVLINK_CMD_TRAP_POLICER_DEL,
126 
127 	DEVLINK_CMD_HEALTH_REPORTER_TEST,
128 
129 	DEVLINK_CMD_RATE_GET,		/* can dump */
130 	DEVLINK_CMD_RATE_SET,
131 	DEVLINK_CMD_RATE_NEW,
132 	DEVLINK_CMD_RATE_DEL,
133 
134 	DEVLINK_CMD_LINECARD_GET,		/* can dump */
135 	DEVLINK_CMD_LINECARD_SET,
136 	DEVLINK_CMD_LINECARD_NEW,
137 	DEVLINK_CMD_LINECARD_DEL,
138 
139 	DEVLINK_CMD_SELFTESTS_GET,	/* can dump */
140 	DEVLINK_CMD_SELFTESTS_RUN,
141 
142 	/* add new commands above here */
143 	__DEVLINK_CMD_MAX,
144 	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
145 };
146 
147 enum devlink_port_type {
148 	DEVLINK_PORT_TYPE_NOTSET,
149 	DEVLINK_PORT_TYPE_AUTO,
150 	DEVLINK_PORT_TYPE_ETH,
151 	DEVLINK_PORT_TYPE_IB,
152 };
153 
154 enum devlink_sb_pool_type {
155 	DEVLINK_SB_POOL_TYPE_INGRESS,
156 	DEVLINK_SB_POOL_TYPE_EGRESS,
157 };
158 
159 /* static threshold - limiting the maximum number of bytes.
160  * dynamic threshold - limiting the maximum number of bytes
161  *   based on the currently available free space in the shared buffer pool.
162  *   In this mode, the maximum quota is calculated based
163  *   on the following formula:
164  *     max_quota = alpha / (1 + alpha) * Free_Buffer
165  *   While Free_Buffer is the amount of none-occupied buffer associated to
166  *   the relevant pool.
167  *   The value range which can be passed is 0-20 and serves
168  *   for computation of alpha by following formula:
169  *     alpha = 2 ^ (passed_value - 10)
170  */
171 
172 enum devlink_sb_threshold_type {
173 	DEVLINK_SB_THRESHOLD_TYPE_STATIC,
174 	DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC,
175 };
176 
177 #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
178 
179 enum devlink_eswitch_mode {
180 	DEVLINK_ESWITCH_MODE_LEGACY,
181 	DEVLINK_ESWITCH_MODE_SWITCHDEV,
182 };
183 
184 enum devlink_eswitch_inline_mode {
185 	DEVLINK_ESWITCH_INLINE_MODE_NONE,
186 	DEVLINK_ESWITCH_INLINE_MODE_LINK,
187 	DEVLINK_ESWITCH_INLINE_MODE_NETWORK,
188 	DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT,
189 };
190 
191 enum devlink_eswitch_encap_mode {
192 	DEVLINK_ESWITCH_ENCAP_MODE_NONE,
193 	DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
194 };
195 
196 enum devlink_port_flavour {
197 	DEVLINK_PORT_FLAVOUR_PHYSICAL, /* Any kind of a port physically
198 					* facing the user.
199 					*/
200 	DEVLINK_PORT_FLAVOUR_CPU, /* CPU port */
201 	DEVLINK_PORT_FLAVOUR_DSA, /* Distributed switch architecture
202 				   * interconnect port.
203 				   */
204 	DEVLINK_PORT_FLAVOUR_PCI_PF, /* Represents eswitch port for
205 				      * the PCI PF. It is an internal
206 				      * port that faces the PCI PF.
207 				      */
208 	DEVLINK_PORT_FLAVOUR_PCI_VF, /* Represents eswitch port
209 				      * for the PCI VF. It is an internal
210 				      * port that faces the PCI VF.
211 				      */
212 	DEVLINK_PORT_FLAVOUR_VIRTUAL, /* Any virtual port facing the user. */
213 	DEVLINK_PORT_FLAVOUR_UNUSED, /* Port which exists in the switch, but
214 				      * is not used in any way.
215 				      */
216 	DEVLINK_PORT_FLAVOUR_PCI_SF, /* Represents eswitch port
217 				      * for the PCI SF. It is an internal
218 				      * port that faces the PCI SF.
219 				      */
220 };
221 
222 enum devlink_rate_type {
223 	DEVLINK_RATE_TYPE_LEAF,
224 	DEVLINK_RATE_TYPE_NODE,
225 };
226 
227 enum devlink_param_cmode {
228 	DEVLINK_PARAM_CMODE_RUNTIME,
229 	DEVLINK_PARAM_CMODE_DRIVERINIT,
230 	DEVLINK_PARAM_CMODE_PERMANENT,
231 
232 	/* Add new configuration modes above */
233 	__DEVLINK_PARAM_CMODE_MAX,
234 	DEVLINK_PARAM_CMODE_MAX = __DEVLINK_PARAM_CMODE_MAX - 1
235 };
236 
237 enum devlink_param_fw_load_policy_value {
238 	DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER,
239 	DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_FLASH,
240 	DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DISK,
241 	DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_UNKNOWN,
242 };
243 
244 enum devlink_param_reset_dev_on_drv_probe_value {
245 	DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_UNKNOWN,
246 	DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_ALWAYS,
247 	DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_NEVER,
248 	DEVLINK_PARAM_RESET_DEV_ON_DRV_PROBE_VALUE_DISK,
249 };
250 
251 enum {
252 	DEVLINK_ATTR_STATS_RX_PACKETS,		/* u64 */
253 	DEVLINK_ATTR_STATS_RX_BYTES,		/* u64 */
254 	DEVLINK_ATTR_STATS_RX_DROPPED,		/* u64 */
255 
256 	__DEVLINK_ATTR_STATS_MAX,
257 	DEVLINK_ATTR_STATS_MAX = __DEVLINK_ATTR_STATS_MAX - 1
258 };
259 
260 /* Specify what sections of a flash component can be overwritten when
261  * performing an update. Overwriting of firmware binary sections is always
262  * implicitly assumed to be allowed.
263  *
264  * Each section must be documented in
265  * Documentation/networking/devlink/devlink-flash.rst
266  *
267  */
268 enum {
269 	DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT,
270 	DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT,
271 
272 	__DEVLINK_FLASH_OVERWRITE_MAX_BIT,
273 	DEVLINK_FLASH_OVERWRITE_MAX_BIT = __DEVLINK_FLASH_OVERWRITE_MAX_BIT - 1
274 };
275 
276 #define DEVLINK_FLASH_OVERWRITE_SETTINGS _BITUL(DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT)
277 #define DEVLINK_FLASH_OVERWRITE_IDENTIFIERS _BITUL(DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT)
278 
279 #define DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS \
280 	(_BITUL(__DEVLINK_FLASH_OVERWRITE_MAX_BIT) - 1)
281 
282 enum devlink_attr_selftest_id {
283 	DEVLINK_ATTR_SELFTEST_ID_UNSPEC,
284 	DEVLINK_ATTR_SELFTEST_ID_FLASH,	/* flag */
285 
286 	__DEVLINK_ATTR_SELFTEST_ID_MAX,
287 	DEVLINK_ATTR_SELFTEST_ID_MAX = __DEVLINK_ATTR_SELFTEST_ID_MAX - 1
288 };
289 
290 enum devlink_selftest_status {
291 	DEVLINK_SELFTEST_STATUS_SKIP,
292 	DEVLINK_SELFTEST_STATUS_PASS,
293 	DEVLINK_SELFTEST_STATUS_FAIL
294 };
295 
296 enum devlink_attr_selftest_result {
297 	DEVLINK_ATTR_SELFTEST_RESULT_UNSPEC,
298 	DEVLINK_ATTR_SELFTEST_RESULT,		/* nested */
299 	DEVLINK_ATTR_SELFTEST_RESULT_ID,	/* u32, enum devlink_attr_selftest_id */
300 	DEVLINK_ATTR_SELFTEST_RESULT_STATUS,	/* u8, enum devlink_selftest_status */
301 
302 	__DEVLINK_ATTR_SELFTEST_RESULT_MAX,
303 	DEVLINK_ATTR_SELFTEST_RESULT_MAX = __DEVLINK_ATTR_SELFTEST_RESULT_MAX - 1
304 };
305 
306 /**
307  * enum devlink_trap_action - Packet trap action.
308  * @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not
309  *                            sent to the CPU.
310  * @DEVLINK_TRAP_ACTION_TRAP: The sole copy of the packet is sent to the CPU.
311  * @DEVLINK_TRAP_ACTION_MIRROR: Packet is forwarded by the device and a copy is
312  *                              sent to the CPU.
313  */
314 enum devlink_trap_action {
315 	DEVLINK_TRAP_ACTION_DROP,
316 	DEVLINK_TRAP_ACTION_TRAP,
317 	DEVLINK_TRAP_ACTION_MIRROR,
318 };
319 
320 /**
321  * enum devlink_trap_type - Packet trap type.
322  * @DEVLINK_TRAP_TYPE_DROP: Trap reason is a drop. Trapped packets are only
323  *                          processed by devlink and not injected to the
324  *                          kernel's Rx path.
325  * @DEVLINK_TRAP_TYPE_EXCEPTION: Trap reason is an exception. Packet was not
326  *                               forwarded as intended due to an exception
327  *                               (e.g., missing neighbour entry) and trapped to
328  *                               control plane for resolution. Trapped packets
329  *                               are processed by devlink and injected to
330  *                               the kernel's Rx path.
331  * @DEVLINK_TRAP_TYPE_CONTROL: Packet was trapped because it is required for
332  *                             the correct functioning of the control plane.
333  *                             For example, an ARP request packet. Trapped
334  *                             packets are injected to the kernel's Rx path,
335  *                             but not reported to drop monitor.
336  */
337 enum devlink_trap_type {
338 	DEVLINK_TRAP_TYPE_DROP,
339 	DEVLINK_TRAP_TYPE_EXCEPTION,
340 	DEVLINK_TRAP_TYPE_CONTROL,
341 };
342 
343 enum {
344 	/* Trap can report input port as metadata */
345 	DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT,
346 	/* Trap can report flow action cookie as metadata */
347 	DEVLINK_ATTR_TRAP_METADATA_TYPE_FA_COOKIE,
348 };
349 
350 enum devlink_reload_action {
351 	DEVLINK_RELOAD_ACTION_UNSPEC,
352 	DEVLINK_RELOAD_ACTION_DRIVER_REINIT,	/* Driver entities re-instantiation */
353 	DEVLINK_RELOAD_ACTION_FW_ACTIVATE,	/* FW activate */
354 
355 	/* Add new reload actions above */
356 	__DEVLINK_RELOAD_ACTION_MAX,
357 	DEVLINK_RELOAD_ACTION_MAX = __DEVLINK_RELOAD_ACTION_MAX - 1
358 };
359 
360 enum devlink_reload_limit {
361 	DEVLINK_RELOAD_LIMIT_UNSPEC,	/* unspecified, no constraints */
362 	DEVLINK_RELOAD_LIMIT_NO_RESET,	/* No reset allowed, no down time allowed,
363 					 * no link flap and no configuration is lost.
364 					 */
365 
366 	/* Add new reload limit above */
367 	__DEVLINK_RELOAD_LIMIT_MAX,
368 	DEVLINK_RELOAD_LIMIT_MAX = __DEVLINK_RELOAD_LIMIT_MAX - 1
369 };
370 
371 #define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
372 
373 enum devlink_linecard_state {
374 	DEVLINK_LINECARD_STATE_UNSPEC,
375 	DEVLINK_LINECARD_STATE_UNPROVISIONED,
376 	DEVLINK_LINECARD_STATE_UNPROVISIONING,
377 	DEVLINK_LINECARD_STATE_PROVISIONING,
378 	DEVLINK_LINECARD_STATE_PROVISIONING_FAILED,
379 	DEVLINK_LINECARD_STATE_PROVISIONED,
380 	DEVLINK_LINECARD_STATE_ACTIVE,
381 
382 	__DEVLINK_LINECARD_STATE_MAX,
383 	DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1
384 };
385 
386 enum devlink_attr {
387 	/* don't change the order or add anything between, this is ABI! */
388 	DEVLINK_ATTR_UNSPEC,
389 
390 	/* bus name + dev name together are a handle for devlink entity */
391 	DEVLINK_ATTR_BUS_NAME,			/* string */
392 	DEVLINK_ATTR_DEV_NAME,			/* string */
393 
394 	DEVLINK_ATTR_PORT_INDEX,		/* u32 */
395 	DEVLINK_ATTR_PORT_TYPE,			/* u16 */
396 	DEVLINK_ATTR_PORT_DESIRED_TYPE,		/* u16 */
397 	DEVLINK_ATTR_PORT_NETDEV_IFINDEX,	/* u32 */
398 	DEVLINK_ATTR_PORT_NETDEV_NAME,		/* string */
399 	DEVLINK_ATTR_PORT_IBDEV_NAME,		/* string */
400 	DEVLINK_ATTR_PORT_SPLIT_COUNT,		/* u32 */
401 	DEVLINK_ATTR_PORT_SPLIT_GROUP,		/* u32 */
402 	DEVLINK_ATTR_SB_INDEX,			/* u32 */
403 	DEVLINK_ATTR_SB_SIZE,			/* u32 */
404 	DEVLINK_ATTR_SB_INGRESS_POOL_COUNT,	/* u16 */
405 	DEVLINK_ATTR_SB_EGRESS_POOL_COUNT,	/* u16 */
406 	DEVLINK_ATTR_SB_INGRESS_TC_COUNT,	/* u16 */
407 	DEVLINK_ATTR_SB_EGRESS_TC_COUNT,	/* u16 */
408 	DEVLINK_ATTR_SB_POOL_INDEX,		/* u16 */
409 	DEVLINK_ATTR_SB_POOL_TYPE,		/* u8 */
410 	DEVLINK_ATTR_SB_POOL_SIZE,		/* u32 */
411 	DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,	/* u8 */
412 	DEVLINK_ATTR_SB_THRESHOLD,		/* u32 */
413 	DEVLINK_ATTR_SB_TC_INDEX,		/* u16 */
414 	DEVLINK_ATTR_SB_OCC_CUR,		/* u32 */
415 	DEVLINK_ATTR_SB_OCC_MAX,		/* u32 */
416 	DEVLINK_ATTR_ESWITCH_MODE,		/* u16 */
417 	DEVLINK_ATTR_ESWITCH_INLINE_MODE,	/* u8 */
418 
419 	DEVLINK_ATTR_DPIPE_TABLES,		/* nested */
420 	DEVLINK_ATTR_DPIPE_TABLE,		/* nested */
421 	DEVLINK_ATTR_DPIPE_TABLE_NAME,		/* string */
422 	DEVLINK_ATTR_DPIPE_TABLE_SIZE,		/* u64 */
423 	DEVLINK_ATTR_DPIPE_TABLE_MATCHES,	/* nested */
424 	DEVLINK_ATTR_DPIPE_TABLE_ACTIONS,	/* nested */
425 	DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED,	/* u8 */
426 
427 	DEVLINK_ATTR_DPIPE_ENTRIES,		/* nested */
428 	DEVLINK_ATTR_DPIPE_ENTRY,		/* nested */
429 	DEVLINK_ATTR_DPIPE_ENTRY_INDEX,		/* u64 */
430 	DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES,	/* nested */
431 	DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES,	/* nested */
432 	DEVLINK_ATTR_DPIPE_ENTRY_COUNTER,	/* u64 */
433 
434 	DEVLINK_ATTR_DPIPE_MATCH,		/* nested */
435 	DEVLINK_ATTR_DPIPE_MATCH_VALUE,		/* nested */
436 	DEVLINK_ATTR_DPIPE_MATCH_TYPE,		/* u32 */
437 
438 	DEVLINK_ATTR_DPIPE_ACTION,		/* nested */
439 	DEVLINK_ATTR_DPIPE_ACTION_VALUE,	/* nested */
440 	DEVLINK_ATTR_DPIPE_ACTION_TYPE,		/* u32 */
441 
442 	DEVLINK_ATTR_DPIPE_VALUE,
443 	DEVLINK_ATTR_DPIPE_VALUE_MASK,
444 	DEVLINK_ATTR_DPIPE_VALUE_MAPPING,	/* u32 */
445 
446 	DEVLINK_ATTR_DPIPE_HEADERS,		/* nested */
447 	DEVLINK_ATTR_DPIPE_HEADER,		/* nested */
448 	DEVLINK_ATTR_DPIPE_HEADER_NAME,		/* string */
449 	DEVLINK_ATTR_DPIPE_HEADER_ID,		/* u32 */
450 	DEVLINK_ATTR_DPIPE_HEADER_FIELDS,	/* nested */
451 	DEVLINK_ATTR_DPIPE_HEADER_GLOBAL,	/* u8 */
452 	DEVLINK_ATTR_DPIPE_HEADER_INDEX,	/* u32 */
453 
454 	DEVLINK_ATTR_DPIPE_FIELD,		/* nested */
455 	DEVLINK_ATTR_DPIPE_FIELD_NAME,		/* string */
456 	DEVLINK_ATTR_DPIPE_FIELD_ID,		/* u32 */
457 	DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH,	/* u32 */
458 	DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE,	/* u32 */
459 
460 	DEVLINK_ATTR_PAD,
461 
462 	DEVLINK_ATTR_ESWITCH_ENCAP_MODE,	/* u8 */
463 	DEVLINK_ATTR_RESOURCE_LIST,		/* nested */
464 	DEVLINK_ATTR_RESOURCE,			/* nested */
465 	DEVLINK_ATTR_RESOURCE_NAME,		/* string */
466 	DEVLINK_ATTR_RESOURCE_ID,		/* u64 */
467 	DEVLINK_ATTR_RESOURCE_SIZE,		/* u64 */
468 	DEVLINK_ATTR_RESOURCE_SIZE_NEW,		/* u64 */
469 	DEVLINK_ATTR_RESOURCE_SIZE_VALID,	/* u8 */
470 	DEVLINK_ATTR_RESOURCE_SIZE_MIN,		/* u64 */
471 	DEVLINK_ATTR_RESOURCE_SIZE_MAX,		/* u64 */
472 	DEVLINK_ATTR_RESOURCE_SIZE_GRAN,        /* u64 */
473 	DEVLINK_ATTR_RESOURCE_UNIT,		/* u8 */
474 	DEVLINK_ATTR_RESOURCE_OCC,		/* u64 */
475 	DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID,	/* u64 */
476 	DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,/* u64 */
477 
478 	DEVLINK_ATTR_PORT_FLAVOUR,		/* u16 */
479 	DEVLINK_ATTR_PORT_NUMBER,		/* u32 */
480 	DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,	/* u32 */
481 
482 	DEVLINK_ATTR_PARAM,			/* nested */
483 	DEVLINK_ATTR_PARAM_NAME,		/* string */
484 	DEVLINK_ATTR_PARAM_GENERIC,		/* flag */
485 	DEVLINK_ATTR_PARAM_TYPE,		/* u8 */
486 	DEVLINK_ATTR_PARAM_VALUES_LIST,		/* nested */
487 	DEVLINK_ATTR_PARAM_VALUE,		/* nested */
488 	DEVLINK_ATTR_PARAM_VALUE_DATA,		/* dynamic */
489 	DEVLINK_ATTR_PARAM_VALUE_CMODE,		/* u8 */
490 
491 	DEVLINK_ATTR_REGION_NAME,               /* string */
492 	DEVLINK_ATTR_REGION_SIZE,               /* u64 */
493 	DEVLINK_ATTR_REGION_SNAPSHOTS,          /* nested */
494 	DEVLINK_ATTR_REGION_SNAPSHOT,           /* nested */
495 	DEVLINK_ATTR_REGION_SNAPSHOT_ID,        /* u32 */
496 
497 	DEVLINK_ATTR_REGION_CHUNKS,             /* nested */
498 	DEVLINK_ATTR_REGION_CHUNK,              /* nested */
499 	DEVLINK_ATTR_REGION_CHUNK_DATA,         /* binary */
500 	DEVLINK_ATTR_REGION_CHUNK_ADDR,         /* u64 */
501 	DEVLINK_ATTR_REGION_CHUNK_LEN,          /* u64 */
502 
503 	DEVLINK_ATTR_INFO_DRIVER_NAME,		/* string */
504 	DEVLINK_ATTR_INFO_SERIAL_NUMBER,	/* string */
505 	DEVLINK_ATTR_INFO_VERSION_FIXED,	/* nested */
506 	DEVLINK_ATTR_INFO_VERSION_RUNNING,	/* nested */
507 	DEVLINK_ATTR_INFO_VERSION_STORED,	/* nested */
508 	DEVLINK_ATTR_INFO_VERSION_NAME,		/* string */
509 	DEVLINK_ATTR_INFO_VERSION_VALUE,	/* string */
510 
511 	DEVLINK_ATTR_SB_POOL_CELL_SIZE,		/* u32 */
512 
513 	DEVLINK_ATTR_FMSG,			/* nested */
514 	DEVLINK_ATTR_FMSG_OBJ_NEST_START,	/* flag */
515 	DEVLINK_ATTR_FMSG_PAIR_NEST_START,	/* flag */
516 	DEVLINK_ATTR_FMSG_ARR_NEST_START,	/* flag */
517 	DEVLINK_ATTR_FMSG_NEST_END,		/* flag */
518 	DEVLINK_ATTR_FMSG_OBJ_NAME,		/* string */
519 	DEVLINK_ATTR_FMSG_OBJ_VALUE_TYPE,	/* u8 */
520 	DEVLINK_ATTR_FMSG_OBJ_VALUE_DATA,	/* dynamic */
521 
522 	DEVLINK_ATTR_HEALTH_REPORTER,			/* nested */
523 	DEVLINK_ATTR_HEALTH_REPORTER_NAME,		/* string */
524 	DEVLINK_ATTR_HEALTH_REPORTER_STATE,		/* u8 */
525 	DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT,		/* u64 */
526 	DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT,	/* u64 */
527 	DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS,		/* u64 */
528 	DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD,	/* u64 */
529 	DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER,	/* u8 */
530 
531 	DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME,	/* string */
532 	DEVLINK_ATTR_FLASH_UPDATE_COMPONENT,	/* string */
533 	DEVLINK_ATTR_FLASH_UPDATE_STATUS_MSG,	/* string */
534 	DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE,	/* u64 */
535 	DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL,	/* u64 */
536 
537 	DEVLINK_ATTR_PORT_PCI_PF_NUMBER,	/* u16 */
538 	DEVLINK_ATTR_PORT_PCI_VF_NUMBER,	/* u16 */
539 
540 	DEVLINK_ATTR_STATS,				/* nested */
541 
542 	DEVLINK_ATTR_TRAP_NAME,				/* string */
543 	/* enum devlink_trap_action */
544 	DEVLINK_ATTR_TRAP_ACTION,			/* u8 */
545 	/* enum devlink_trap_type */
546 	DEVLINK_ATTR_TRAP_TYPE,				/* u8 */
547 	DEVLINK_ATTR_TRAP_GENERIC,			/* flag */
548 	DEVLINK_ATTR_TRAP_METADATA,			/* nested */
549 	DEVLINK_ATTR_TRAP_GROUP_NAME,			/* string */
550 
551 	DEVLINK_ATTR_RELOAD_FAILED,			/* u8 0 or 1 */
552 
553 	DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS,	/* u64 */
554 
555 	DEVLINK_ATTR_NETNS_FD,			/* u32 */
556 	DEVLINK_ATTR_NETNS_PID,			/* u32 */
557 	DEVLINK_ATTR_NETNS_ID,			/* u32 */
558 
559 	DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP,	/* u8 */
560 
561 	DEVLINK_ATTR_TRAP_POLICER_ID,			/* u32 */
562 	DEVLINK_ATTR_TRAP_POLICER_RATE,			/* u64 */
563 	DEVLINK_ATTR_TRAP_POLICER_BURST,		/* u64 */
564 
565 	DEVLINK_ATTR_PORT_FUNCTION,			/* nested */
566 
567 	DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER,	/* string */
568 
569 	DEVLINK_ATTR_PORT_LANES,			/* u32 */
570 	DEVLINK_ATTR_PORT_SPLITTABLE,			/* u8 */
571 
572 	DEVLINK_ATTR_PORT_EXTERNAL,		/* u8 */
573 	DEVLINK_ATTR_PORT_CONTROLLER_NUMBER,	/* u32 */
574 
575 	DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT,	/* u64 */
576 	DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK,	/* bitfield32 */
577 
578 	DEVLINK_ATTR_RELOAD_ACTION,		/* u8 */
579 	DEVLINK_ATTR_RELOAD_ACTIONS_PERFORMED,	/* bitfield32 */
580 	DEVLINK_ATTR_RELOAD_LIMITS,		/* bitfield32 */
581 
582 	DEVLINK_ATTR_DEV_STATS,			/* nested */
583 	DEVLINK_ATTR_RELOAD_STATS,		/* nested */
584 	DEVLINK_ATTR_RELOAD_STATS_ENTRY,	/* nested */
585 	DEVLINK_ATTR_RELOAD_STATS_LIMIT,	/* u8 */
586 	DEVLINK_ATTR_RELOAD_STATS_VALUE,	/* u32 */
587 	DEVLINK_ATTR_REMOTE_RELOAD_STATS,	/* nested */
588 	DEVLINK_ATTR_RELOAD_ACTION_INFO,        /* nested */
589 	DEVLINK_ATTR_RELOAD_ACTION_STATS,       /* nested */
590 
591 	DEVLINK_ATTR_PORT_PCI_SF_NUMBER,	/* u32 */
592 
593 	DEVLINK_ATTR_RATE_TYPE,			/* u16 */
594 	DEVLINK_ATTR_RATE_TX_SHARE,		/* u64 */
595 	DEVLINK_ATTR_RATE_TX_MAX,		/* u64 */
596 	DEVLINK_ATTR_RATE_NODE_NAME,		/* string */
597 	DEVLINK_ATTR_RATE_PARENT_NODE_NAME,	/* string */
598 
599 	DEVLINK_ATTR_REGION_MAX_SNAPSHOTS,	/* u32 */
600 
601 	DEVLINK_ATTR_LINECARD_INDEX,		/* u32 */
602 	DEVLINK_ATTR_LINECARD_STATE,		/* u8 */
603 	DEVLINK_ATTR_LINECARD_TYPE,		/* string */
604 	DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES,	/* nested */
605 
606 	DEVLINK_ATTR_NESTED_DEVLINK,		/* nested */
607 
608 	DEVLINK_ATTR_SELFTESTS,			/* nested */
609 
610 	DEVLINK_ATTR_RATE_TX_PRIORITY,		/* u32 */
611 	DEVLINK_ATTR_RATE_TX_WEIGHT,		/* u32 */
612 
613 	DEVLINK_ATTR_REGION_DIRECT,		/* flag */
614 
615 	/* add new attributes above here, update the policy in devlink.c */
616 
617 	__DEVLINK_ATTR_MAX,
618 	DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
619 };
620 
621 /* Mapping between internal resource described by the field and system
622  * structure
623  */
624 enum devlink_dpipe_field_mapping_type {
625 	DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE,
626 	DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX,
627 };
628 
629 /* Match type - specify the type of the match */
630 enum devlink_dpipe_match_type {
631 	DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT,
632 };
633 
634 /* Action type - specify the action type */
635 enum devlink_dpipe_action_type {
636 	DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY,
637 };
638 
639 enum devlink_dpipe_field_ethernet_id {
640 	DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC,
641 };
642 
643 enum devlink_dpipe_field_ipv4_id {
644 	DEVLINK_DPIPE_FIELD_IPV4_DST_IP,
645 };
646 
647 enum devlink_dpipe_field_ipv6_id {
648 	DEVLINK_DPIPE_FIELD_IPV6_DST_IP,
649 };
650 
651 enum devlink_dpipe_header_id {
652 	DEVLINK_DPIPE_HEADER_ETHERNET,
653 	DEVLINK_DPIPE_HEADER_IPV4,
654 	DEVLINK_DPIPE_HEADER_IPV6,
655 };
656 
657 enum devlink_resource_unit {
658 	DEVLINK_RESOURCE_UNIT_ENTRY,
659 };
660 
661 enum devlink_port_fn_attr_cap {
662 	DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT,
663 	DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT,
664 	DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT,
665 	DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT,
666 
667 	/* Add new caps above */
668 	__DEVLINK_PORT_FN_ATTR_CAPS_MAX,
669 };
670 
671 #define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT)
672 #define DEVLINK_PORT_FN_CAP_MIGRATABLE \
673 	_BITUL(DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT)
674 #define DEVLINK_PORT_FN_CAP_IPSEC_CRYPTO _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_CRYPTO_BIT)
675 #define DEVLINK_PORT_FN_CAP_IPSEC_PACKET _BITUL(DEVLINK_PORT_FN_ATTR_CAP_IPSEC_PACKET_BIT)
676 
677 enum devlink_port_function_attr {
678 	DEVLINK_PORT_FUNCTION_ATTR_UNSPEC,
679 	DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR,	/* binary */
680 	DEVLINK_PORT_FN_ATTR_STATE,	/* u8 */
681 	DEVLINK_PORT_FN_ATTR_OPSTATE,	/* u8 */
682 	DEVLINK_PORT_FN_ATTR_CAPS,	/* bitfield32 */
683 
684 	__DEVLINK_PORT_FUNCTION_ATTR_MAX,
685 	DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1
686 };
687 
688 enum devlink_port_fn_state {
689 	DEVLINK_PORT_FN_STATE_INACTIVE,
690 	DEVLINK_PORT_FN_STATE_ACTIVE,
691 };
692 
693 /**
694  * enum devlink_port_fn_opstate - indicates operational state of the function
695  * @DEVLINK_PORT_FN_OPSTATE_ATTACHED: Driver is attached to the function.
696  * For graceful tear down of the function, after inactivation of the
697  * function, user should wait for operational state to turn DETACHED.
698  * @DEVLINK_PORT_FN_OPSTATE_DETACHED: Driver is detached from the function.
699  * It is safe to delete the port.
700  */
701 enum devlink_port_fn_opstate {
702 	DEVLINK_PORT_FN_OPSTATE_DETACHED,
703 	DEVLINK_PORT_FN_OPSTATE_ATTACHED,
704 };
705 
706 #endif /* _UAPI_LINUX_DEVLINK_H_ */
707