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#define DEVLINK_GENL_NAME "devlink"
17#define DEVLINK_GENL_VERSION 0x1
18#define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
19
20enum devlink_command {
21 /* don't change the order or add anything between, this is ABI! */
22 DEVLINK_CMD_UNSPEC,
23
24 DEVLINK_CMD_GET, /* can dump */
25 DEVLINK_CMD_SET,
26 DEVLINK_CMD_NEW,
27 DEVLINK_CMD_DEL,
28
29 DEVLINK_CMD_PORT_GET, /* can dump */
30 DEVLINK_CMD_PORT_SET,
31 DEVLINK_CMD_PORT_NEW,
32 DEVLINK_CMD_PORT_DEL,
33
34 DEVLINK_CMD_PORT_SPLIT,
35 DEVLINK_CMD_PORT_UNSPLIT,
36
37 DEVLINK_CMD_SB_GET, /* can dump */
38 DEVLINK_CMD_SB_SET,
39 DEVLINK_CMD_SB_NEW,
40 DEVLINK_CMD_SB_DEL,
41
42 DEVLINK_CMD_SB_POOL_GET, /* can dump */
43 DEVLINK_CMD_SB_POOL_SET,
44 DEVLINK_CMD_SB_POOL_NEW,
45 DEVLINK_CMD_SB_POOL_DEL,
46
47 DEVLINK_CMD_SB_PORT_POOL_GET, /* can dump */
48 DEVLINK_CMD_SB_PORT_POOL_SET,
49 DEVLINK_CMD_SB_PORT_POOL_NEW,
50 DEVLINK_CMD_SB_PORT_POOL_DEL,
51
52 DEVLINK_CMD_SB_TC_POOL_BIND_GET, /* can dump */
53 DEVLINK_CMD_SB_TC_POOL_BIND_SET,
54 DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
55 DEVLINK_CMD_SB_TC_POOL_BIND_DEL,
56
57 /* Shared buffer occupancy monitoring commands */
58 DEVLINK_CMD_SB_OCC_SNAPSHOT,
59 DEVLINK_CMD_SB_OCC_MAX_CLEAR,
60
61 DEVLINK_CMD_ESWITCH_GET,
62#define DEVLINK_CMD_ESWITCH_MODE_GET /* obsolete, never use this! */ \
63 DEVLINK_CMD_ESWITCH_GET
64
65 DEVLINK_CMD_ESWITCH_SET,
66#define DEVLINK_CMD_ESWITCH_MODE_SET /* obsolete, never use this! */ \
67 DEVLINK_CMD_ESWITCH_SET
68
69 DEVLINK_CMD_DPIPE_TABLE_GET,
70 DEVLINK_CMD_DPIPE_ENTRIES_GET,
71 DEVLINK_CMD_DPIPE_HEADERS_GET,
72 DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
73 DEVLINK_CMD_RESOURCE_SET,
74 DEVLINK_CMD_RESOURCE_DUMP,
75
76 /* Hot driver reload, makes configuration changes take place. The
77 * devlink instance is not released during the process.
78 */
79 DEVLINK_CMD_RELOAD,
80
81 DEVLINK_CMD_PARAM_GET, /* can dump */
82 DEVLINK_CMD_PARAM_SET,
83 DEVLINK_CMD_PARAM_NEW,
84 DEVLINK_CMD_PARAM_DEL,
85
86 DEVLINK_CMD_REGION_GET,
87 DEVLINK_CMD_REGION_SET,
88 DEVLINK_CMD_REGION_NEW,
89 DEVLINK_CMD_REGION_DEL,
90 DEVLINK_CMD_REGION_READ,
91
92 DEVLINK_CMD_PORT_PARAM_GET, /* can dump */
93 DEVLINK_CMD_PORT_PARAM_SET,
94 DEVLINK_CMD_PORT_PARAM_NEW,
95 DEVLINK_CMD_PORT_PARAM_DEL,
96
97 DEVLINK_CMD_INFO_GET, /* can dump */
98
99 DEVLINK_CMD_HEALTH_REPORTER_GET,
100 DEVLINK_CMD_HEALTH_REPORTER_SET,
101 DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
102 DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
103 DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
104 DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR,
105
106 DEVLINK_CMD_FLASH_UPDATE,
107
108 /* add new commands above here */
109 __DEVLINK_CMD_MAX,
110 DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
111};
112
113enum devlink_port_type {
114 DEVLINK_PORT_TYPE_NOTSET,
115 DEVLINK_PORT_TYPE_AUTO,
116 DEVLINK_PORT_TYPE_ETH,
117 DEVLINK_PORT_TYPE_IB,
118};
119
120enum devlink_sb_pool_type {
121 DEVLINK_SB_POOL_TYPE_INGRESS,
122 DEVLINK_SB_POOL_TYPE_EGRESS,
123};
124
125/* static threshold - limiting the maximum number of bytes.
126 * dynamic threshold - limiting the maximum number of bytes
127 * based on the currently available free space in the shared buffer pool.
128 * In this mode, the maximum quota is calculated based
129 * on the following formula:
130 * max_quota = alpha / (1 + alpha) * Free_Buffer
131 * While Free_Buffer is the amount of none-occupied buffer associated to
132 * the relevant pool.
133 * The value range which can be passed is 0-20 and serves
134 * for computation of alpha by following formula:
135 * alpha = 2 ^ (passed_value - 10)
136 */
137
138enum devlink_sb_threshold_type {
139 DEVLINK_SB_THRESHOLD_TYPE_STATIC,
140 DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC,
141};
142
143#define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
144
145enum devlink_eswitch_mode {
146 DEVLINK_ESWITCH_MODE_LEGACY,
147 DEVLINK_ESWITCH_MODE_SWITCHDEV,
148};
149
150enum devlink_eswitch_inline_mode {
151 DEVLINK_ESWITCH_INLINE_MODE_NONE,
152 DEVLINK_ESWITCH_INLINE_MODE_LINK,
153 DEVLINK_ESWITCH_INLINE_MODE_NETWORK,
154 DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT,
155};
156
157enum devlink_eswitch_encap_mode {
158 DEVLINK_ESWITCH_ENCAP_MODE_NONE,
159 DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
160};
161
162enum devlink_port_flavour {
163 DEVLINK_PORT_FLAVOUR_PHYSICAL, /* Any kind of a port physically
164 * facing the user.
165 */
166 DEVLINK_PORT_FLAVOUR_CPU, /* CPU port */
167 DEVLINK_PORT_FLAVOUR_DSA, /* Distributed switch architecture
168 * interconnect port.
169 */
170};
171
172enum devlink_param_cmode {
173 DEVLINK_PARAM_CMODE_RUNTIME,
174 DEVLINK_PARAM_CMODE_DRIVERINIT,
175 DEVLINK_PARAM_CMODE_PERMANENT,
176
177 /* Add new configuration modes above */
178 __DEVLINK_PARAM_CMODE_MAX,
179 DEVLINK_PARAM_CMODE_MAX = __DEVLINK_PARAM_CMODE_MAX - 1
180};
181
182enum devlink_param_fw_load_policy_value {
183 DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_DRIVER,
184 DEVLINK_PARAM_FW_LOAD_POLICY_VALUE_FLASH,
185};
186
187enum devlink_attr {
188 /* don't change the order or add anything between, this is ABI! */
189 DEVLINK_ATTR_UNSPEC,
190
191 /* bus name + dev name together are a handle for devlink entity */
192 DEVLINK_ATTR_BUS_NAME, /* string */
193 DEVLINK_ATTR_DEV_NAME, /* string */
194
195 DEVLINK_ATTR_PORT_INDEX, /* u32 */
196 DEVLINK_ATTR_PORT_TYPE, /* u16 */
197 DEVLINK_ATTR_PORT_DESIRED_TYPE, /* u16 */
198 DEVLINK_ATTR_PORT_NETDEV_IFINDEX, /* u32 */
199 DEVLINK_ATTR_PORT_NETDEV_NAME, /* string */
200 DEVLINK_ATTR_PORT_IBDEV_NAME, /* string */
201 DEVLINK_ATTR_PORT_SPLIT_COUNT, /* u32 */
202 DEVLINK_ATTR_PORT_SPLIT_GROUP, /* u32 */
203 DEVLINK_ATTR_SB_INDEX, /* u32 */
204 DEVLINK_ATTR_SB_SIZE, /* u32 */
205 DEVLINK_ATTR_SB_INGRESS_POOL_COUNT, /* u16 */
206 DEVLINK_ATTR_SB_EGRESS_POOL_COUNT, /* u16 */
207 DEVLINK_ATTR_SB_INGRESS_TC_COUNT, /* u16 */
208 DEVLINK_ATTR_SB_EGRESS_TC_COUNT, /* u16 */
209 DEVLINK_ATTR_SB_POOL_INDEX, /* u16 */
210 DEVLINK_ATTR_SB_POOL_TYPE, /* u8 */
211 DEVLINK_ATTR_SB_POOL_SIZE, /* u32 */
212 DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE, /* u8 */
213 DEVLINK_ATTR_SB_THRESHOLD, /* u32 */
214 DEVLINK_ATTR_SB_TC_INDEX, /* u16 */
215 DEVLINK_ATTR_SB_OCC_CUR, /* u32 */
216 DEVLINK_ATTR_SB_OCC_MAX, /* u32 */
217 DEVLINK_ATTR_ESWITCH_MODE, /* u16 */
218 DEVLINK_ATTR_ESWITCH_INLINE_MODE, /* u8 */
219
220 DEVLINK_ATTR_DPIPE_TABLES, /* nested */
221 DEVLINK_ATTR_DPIPE_TABLE, /* nested */
222 DEVLINK_ATTR_DPIPE_TABLE_NAME, /* string */
223 DEVLINK_ATTR_DPIPE_TABLE_SIZE, /* u64 */
224 DEVLINK_ATTR_DPIPE_TABLE_MATCHES, /* nested */
225 DEVLINK_ATTR_DPIPE_TABLE_ACTIONS, /* nested */
226 DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED, /* u8 */
227
228 DEVLINK_ATTR_DPIPE_ENTRIES, /* nested */
229 DEVLINK_ATTR_DPIPE_ENTRY, /* nested */
230 DEVLINK_ATTR_DPIPE_ENTRY_INDEX, /* u64 */
231 DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES, /* nested */
232 DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES, /* nested */
233 DEVLINK_ATTR_DPIPE_ENTRY_COUNTER, /* u64 */
234
235 DEVLINK_ATTR_DPIPE_MATCH, /* nested */
236 DEVLINK_ATTR_DPIPE_MATCH_VALUE, /* nested */
237 DEVLINK_ATTR_DPIPE_MATCH_TYPE, /* u32 */
238
239 DEVLINK_ATTR_DPIPE_ACTION, /* nested */
240 DEVLINK_ATTR_DPIPE_ACTION_VALUE, /* nested */
241 DEVLINK_ATTR_DPIPE_ACTION_TYPE, /* u32 */
242
243 DEVLINK_ATTR_DPIPE_VALUE,
244 DEVLINK_ATTR_DPIPE_VALUE_MASK,
245 DEVLINK_ATTR_DPIPE_VALUE_MAPPING, /* u32 */
246
247 DEVLINK_ATTR_DPIPE_HEADERS, /* nested */
248 DEVLINK_ATTR_DPIPE_HEADER, /* nested */
249 DEVLINK_ATTR_DPIPE_HEADER_NAME, /* string */
250 DEVLINK_ATTR_DPIPE_HEADER_ID, /* u32 */
251 DEVLINK_ATTR_DPIPE_HEADER_FIELDS, /* nested */
252 DEVLINK_ATTR_DPIPE_HEADER_GLOBAL, /* u8 */
253 DEVLINK_ATTR_DPIPE_HEADER_INDEX, /* u32 */
254
255 DEVLINK_ATTR_DPIPE_FIELD, /* nested */
256 DEVLINK_ATTR_DPIPE_FIELD_NAME, /* string */
257 DEVLINK_ATTR_DPIPE_FIELD_ID, /* u32 */
258 DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH, /* u32 */
259 DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE, /* u32 */
260
261 DEVLINK_ATTR_PAD,
262
263 DEVLINK_ATTR_ESWITCH_ENCAP_MODE, /* u8 */
264 DEVLINK_ATTR_RESOURCE_LIST, /* nested */
265 DEVLINK_ATTR_RESOURCE, /* nested */
266 DEVLINK_ATTR_RESOURCE_NAME, /* string */
267 DEVLINK_ATTR_RESOURCE_ID, /* u64 */
268 DEVLINK_ATTR_RESOURCE_SIZE, /* u64 */
269 DEVLINK_ATTR_RESOURCE_SIZE_NEW, /* u64 */
270 DEVLINK_ATTR_RESOURCE_SIZE_VALID, /* u8 */
271 DEVLINK_ATTR_RESOURCE_SIZE_MIN, /* u64 */
272 DEVLINK_ATTR_RESOURCE_SIZE_MAX, /* u64 */
273 DEVLINK_ATTR_RESOURCE_SIZE_GRAN, /* u64 */
274 DEVLINK_ATTR_RESOURCE_UNIT, /* u8 */
275 DEVLINK_ATTR_RESOURCE_OCC, /* u64 */
276 DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID, /* u64 */
277 DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,/* u64 */
278
279 DEVLINK_ATTR_PORT_FLAVOUR, /* u16 */
280 DEVLINK_ATTR_PORT_NUMBER, /* u32 */
281 DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER, /* u32 */
282
283 DEVLINK_ATTR_PARAM, /* nested */
284 DEVLINK_ATTR_PARAM_NAME, /* string */
285 DEVLINK_ATTR_PARAM_GENERIC, /* flag */
286 DEVLINK_ATTR_PARAM_TYPE, /* u8 */
287 DEVLINK_ATTR_PARAM_VALUES_LIST, /* nested */
288 DEVLINK_ATTR_PARAM_VALUE, /* nested */
289 DEVLINK_ATTR_PARAM_VALUE_DATA, /* dynamic */
290 DEVLINK_ATTR_PARAM_VALUE_CMODE, /* u8 */
291
292 DEVLINK_ATTR_REGION_NAME, /* string */
293 DEVLINK_ATTR_REGION_SIZE, /* u64 */
294 DEVLINK_ATTR_REGION_SNAPSHOTS, /* nested */
295 DEVLINK_ATTR_REGION_SNAPSHOT, /* nested */
296 DEVLINK_ATTR_REGION_SNAPSHOT_ID, /* u32 */
297
298 DEVLINK_ATTR_REGION_CHUNKS, /* nested */
299 DEVLINK_ATTR_REGION_CHUNK, /* nested */
300 DEVLINK_ATTR_REGION_CHUNK_DATA, /* binary */
301 DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */
302 DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */
303
304 DEVLINK_ATTR_INFO_DRIVER_NAME, /* string */
305 DEVLINK_ATTR_INFO_SERIAL_NUMBER, /* string */
306 DEVLINK_ATTR_INFO_VERSION_FIXED, /* nested */
307 DEVLINK_ATTR_INFO_VERSION_RUNNING, /* nested */
308 DEVLINK_ATTR_INFO_VERSION_STORED, /* nested */
309 DEVLINK_ATTR_INFO_VERSION_NAME, /* string */
310 DEVLINK_ATTR_INFO_VERSION_VALUE, /* string */
311
312 DEVLINK_ATTR_SB_POOL_CELL_SIZE, /* u32 */
313
314 DEVLINK_ATTR_FMSG, /* nested */
315 DEVLINK_ATTR_FMSG_OBJ_NEST_START, /* flag */
316 DEVLINK_ATTR_FMSG_PAIR_NEST_START, /* flag */
317 DEVLINK_ATTR_FMSG_ARR_NEST_START, /* flag */
318 DEVLINK_ATTR_FMSG_NEST_END, /* flag */
319 DEVLINK_ATTR_FMSG_OBJ_NAME, /* string */
320 DEVLINK_ATTR_FMSG_OBJ_VALUE_TYPE, /* u8 */
321 DEVLINK_ATTR_FMSG_OBJ_VALUE_DATA, /* dynamic */
322
323 DEVLINK_ATTR_HEALTH_REPORTER, /* nested */
324 DEVLINK_ATTR_HEALTH_REPORTER_NAME, /* string */
325 DEVLINK_ATTR_HEALTH_REPORTER_STATE, /* u8 */
326 DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT, /* u64 */
327 DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT, /* u64 */
328 DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS, /* u64 */
329 DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD, /* u64 */
330 DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER, /* u8 */
331
332 DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME, /* string */
333 DEVLINK_ATTR_FLASH_UPDATE_COMPONENT, /* string */
334
335 /* add new attributes above here, update the policy in devlink.c */
336
337 __DEVLINK_ATTR_MAX,
338 DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
339};
340
341/* Mapping between internal resource described by the field and system
342 * structure
343 */
344enum devlink_dpipe_field_mapping_type {
345 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE,
346 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX,
347};
348
349/* Match type - specify the type of the match */
350enum devlink_dpipe_match_type {
351 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT,
352};
353
354/* Action type - specify the action type */
355enum devlink_dpipe_action_type {
356 DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY,
357};
358
359enum devlink_dpipe_field_ethernet_id {
360 DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC,
361};
362
363enum devlink_dpipe_field_ipv4_id {
364 DEVLINK_DPIPE_FIELD_IPV4_DST_IP,
365};
366
367enum devlink_dpipe_field_ipv6_id {
368 DEVLINK_DPIPE_FIELD_IPV6_DST_IP,
369};
370
371enum devlink_dpipe_header_id {
372 DEVLINK_DPIPE_HEADER_ETHERNET,
373 DEVLINK_DPIPE_HEADER_IPV4,
374 DEVLINK_DPIPE_HEADER_IPV6,
375};
376
377enum devlink_resource_unit {
378 DEVLINK_RESOURCE_UNIT_ENTRY,
379};
380
381#endif /* _UAPI_LINUX_DEVLINK_H_ */
382