1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
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>
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.
13 #ifndef _UAPI_LINUX_DEVLINK_H_
14 #define _UAPI_LINUX_DEVLINK_H_
16 #define DEVLINK_GENL_NAME "devlink"
17 #define DEVLINK_GENL_VERSION 0x1
18 #define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
20 enum devlink_command
{
21 /* don't change the order or add anything between, this is ABI! */
24 DEVLINK_CMD_GET
, /* can dump */
29 DEVLINK_CMD_PORT_GET
, /* can dump */
34 DEVLINK_CMD_PORT_SPLIT
,
35 DEVLINK_CMD_PORT_UNSPLIT
,
37 DEVLINK_CMD_SB_GET
, /* can dump */
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
,
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
,
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
,
57 /* Shared buffer occupancy monitoring commands */
58 DEVLINK_CMD_SB_OCC_SNAPSHOT
,
59 DEVLINK_CMD_SB_OCC_MAX_CLEAR
,
61 DEVLINK_CMD_ESWITCH_GET
,
62 #define DEVLINK_CMD_ESWITCH_MODE_GET /* obsolete, never use this! */ \
63 DEVLINK_CMD_ESWITCH_GET
65 DEVLINK_CMD_ESWITCH_SET
,
66 #define DEVLINK_CMD_ESWITCH_MODE_SET /* obsolete, never use this! */ \
67 DEVLINK_CMD_ESWITCH_SET
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
,
76 /* Hot driver reload, makes configuration changes take place. The
77 * devlink instance is not released during the process.
81 /* add new commands above here */
83 DEVLINK_CMD_MAX
= __DEVLINK_CMD_MAX
- 1
86 enum devlink_port_type
{
87 DEVLINK_PORT_TYPE_NOTSET
,
88 DEVLINK_PORT_TYPE_AUTO
,
89 DEVLINK_PORT_TYPE_ETH
,
93 enum devlink_sb_pool_type
{
94 DEVLINK_SB_POOL_TYPE_INGRESS
,
95 DEVLINK_SB_POOL_TYPE_EGRESS
,
98 /* static threshold - limiting the maximum number of bytes.
99 * dynamic threshold - limiting the maximum number of bytes
100 * based on the currently available free space in the shared buffer pool.
101 * In this mode, the maximum quota is calculated based
102 * on the following formula:
103 * max_quota = alpha / (1 + alpha) * Free_Buffer
104 * While Free_Buffer is the amount of none-occupied buffer associated to
106 * The value range which can be passed is 0-20 and serves
107 * for computation of alpha by following formula:
108 * alpha = 2 ^ (passed_value - 10)
111 enum devlink_sb_threshold_type
{
112 DEVLINK_SB_THRESHOLD_TYPE_STATIC
,
113 DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC
,
116 #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
118 enum devlink_eswitch_mode
{
119 DEVLINK_ESWITCH_MODE_LEGACY
,
120 DEVLINK_ESWITCH_MODE_SWITCHDEV
,
123 enum devlink_eswitch_inline_mode
{
124 DEVLINK_ESWITCH_INLINE_MODE_NONE
,
125 DEVLINK_ESWITCH_INLINE_MODE_LINK
,
126 DEVLINK_ESWITCH_INLINE_MODE_NETWORK
,
127 DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT
,
130 enum devlink_eswitch_encap_mode
{
131 DEVLINK_ESWITCH_ENCAP_MODE_NONE
,
132 DEVLINK_ESWITCH_ENCAP_MODE_BASIC
,
136 /* don't change the order or add anything between, this is ABI! */
139 /* bus name + dev name together are a handle for devlink entity */
140 DEVLINK_ATTR_BUS_NAME
, /* string */
141 DEVLINK_ATTR_DEV_NAME
, /* string */
143 DEVLINK_ATTR_PORT_INDEX
, /* u32 */
144 DEVLINK_ATTR_PORT_TYPE
, /* u16 */
145 DEVLINK_ATTR_PORT_DESIRED_TYPE
, /* u16 */
146 DEVLINK_ATTR_PORT_NETDEV_IFINDEX
, /* u32 */
147 DEVLINK_ATTR_PORT_NETDEV_NAME
, /* string */
148 DEVLINK_ATTR_PORT_IBDEV_NAME
, /* string */
149 DEVLINK_ATTR_PORT_SPLIT_COUNT
, /* u32 */
150 DEVLINK_ATTR_PORT_SPLIT_GROUP
, /* u32 */
151 DEVLINK_ATTR_SB_INDEX
, /* u32 */
152 DEVLINK_ATTR_SB_SIZE
, /* u32 */
153 DEVLINK_ATTR_SB_INGRESS_POOL_COUNT
, /* u16 */
154 DEVLINK_ATTR_SB_EGRESS_POOL_COUNT
, /* u16 */
155 DEVLINK_ATTR_SB_INGRESS_TC_COUNT
, /* u16 */
156 DEVLINK_ATTR_SB_EGRESS_TC_COUNT
, /* u16 */
157 DEVLINK_ATTR_SB_POOL_INDEX
, /* u16 */
158 DEVLINK_ATTR_SB_POOL_TYPE
, /* u8 */
159 DEVLINK_ATTR_SB_POOL_SIZE
, /* u32 */
160 DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE
, /* u8 */
161 DEVLINK_ATTR_SB_THRESHOLD
, /* u32 */
162 DEVLINK_ATTR_SB_TC_INDEX
, /* u16 */
163 DEVLINK_ATTR_SB_OCC_CUR
, /* u32 */
164 DEVLINK_ATTR_SB_OCC_MAX
, /* u32 */
165 DEVLINK_ATTR_ESWITCH_MODE
, /* u16 */
166 DEVLINK_ATTR_ESWITCH_INLINE_MODE
, /* u8 */
168 DEVLINK_ATTR_DPIPE_TABLES
, /* nested */
169 DEVLINK_ATTR_DPIPE_TABLE
, /* nested */
170 DEVLINK_ATTR_DPIPE_TABLE_NAME
, /* string */
171 DEVLINK_ATTR_DPIPE_TABLE_SIZE
, /* u64 */
172 DEVLINK_ATTR_DPIPE_TABLE_MATCHES
, /* nested */
173 DEVLINK_ATTR_DPIPE_TABLE_ACTIONS
, /* nested */
174 DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED
, /* u8 */
176 DEVLINK_ATTR_DPIPE_ENTRIES
, /* nested */
177 DEVLINK_ATTR_DPIPE_ENTRY
, /* nested */
178 DEVLINK_ATTR_DPIPE_ENTRY_INDEX
, /* u64 */
179 DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES
, /* nested */
180 DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES
, /* nested */
181 DEVLINK_ATTR_DPIPE_ENTRY_COUNTER
, /* u64 */
183 DEVLINK_ATTR_DPIPE_MATCH
, /* nested */
184 DEVLINK_ATTR_DPIPE_MATCH_VALUE
, /* nested */
185 DEVLINK_ATTR_DPIPE_MATCH_TYPE
, /* u32 */
187 DEVLINK_ATTR_DPIPE_ACTION
, /* nested */
188 DEVLINK_ATTR_DPIPE_ACTION_VALUE
, /* nested */
189 DEVLINK_ATTR_DPIPE_ACTION_TYPE
, /* u32 */
191 DEVLINK_ATTR_DPIPE_VALUE
,
192 DEVLINK_ATTR_DPIPE_VALUE_MASK
,
193 DEVLINK_ATTR_DPIPE_VALUE_MAPPING
, /* u32 */
195 DEVLINK_ATTR_DPIPE_HEADERS
, /* nested */
196 DEVLINK_ATTR_DPIPE_HEADER
, /* nested */
197 DEVLINK_ATTR_DPIPE_HEADER_NAME
, /* string */
198 DEVLINK_ATTR_DPIPE_HEADER_ID
, /* u32 */
199 DEVLINK_ATTR_DPIPE_HEADER_FIELDS
, /* nested */
200 DEVLINK_ATTR_DPIPE_HEADER_GLOBAL
, /* u8 */
201 DEVLINK_ATTR_DPIPE_HEADER_INDEX
, /* u32 */
203 DEVLINK_ATTR_DPIPE_FIELD
, /* nested */
204 DEVLINK_ATTR_DPIPE_FIELD_NAME
, /* string */
205 DEVLINK_ATTR_DPIPE_FIELD_ID
, /* u32 */
206 DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH
, /* u32 */
207 DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE
, /* u32 */
211 DEVLINK_ATTR_ESWITCH_ENCAP_MODE
, /* u8 */
212 DEVLINK_ATTR_RESOURCE_LIST
, /* nested */
213 DEVLINK_ATTR_RESOURCE
, /* nested */
214 DEVLINK_ATTR_RESOURCE_NAME
, /* string */
215 DEVLINK_ATTR_RESOURCE_ID
, /* u64 */
216 DEVLINK_ATTR_RESOURCE_SIZE
, /* u64 */
217 DEVLINK_ATTR_RESOURCE_SIZE_NEW
, /* u64 */
218 DEVLINK_ATTR_RESOURCE_SIZE_VALID
, /* u8 */
219 DEVLINK_ATTR_RESOURCE_SIZE_MIN
, /* u64 */
220 DEVLINK_ATTR_RESOURCE_SIZE_MAX
, /* u64 */
221 DEVLINK_ATTR_RESOURCE_SIZE_GRAN
, /* u64 */
222 DEVLINK_ATTR_RESOURCE_UNIT
, /* u8 */
223 DEVLINK_ATTR_RESOURCE_OCC
, /* u64 */
224 DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID
, /* u64 */
225 DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS
,/* u64 */
227 /* add new attributes above here, update the policy in devlink.c */
230 DEVLINK_ATTR_MAX
= __DEVLINK_ATTR_MAX
- 1
233 /* Mapping between internal resource described by the field and system
236 enum devlink_dpipe_field_mapping_type
{
237 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE
,
238 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX
,
241 /* Match type - specify the type of the match */
242 enum devlink_dpipe_match_type
{
243 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT
,
246 /* Action type - specify the action type */
247 enum devlink_dpipe_action_type
{
248 DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY
,
251 enum devlink_dpipe_field_ethernet_id
{
252 DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC
,
255 enum devlink_dpipe_field_ipv4_id
{
256 DEVLINK_DPIPE_FIELD_IPV4_DST_IP
,
259 enum devlink_dpipe_field_ipv6_id
{
260 DEVLINK_DPIPE_FIELD_IPV6_DST_IP
,
263 enum devlink_dpipe_header_id
{
264 DEVLINK_DPIPE_HEADER_ETHERNET
,
265 DEVLINK_DPIPE_HEADER_IPV4
,
266 DEVLINK_DPIPE_HEADER_IPV6
,
269 enum devlink_resource_unit
{
270 DEVLINK_RESOURCE_UNIT_ENTRY
,
273 #endif /* _UAPI_LINUX_DEVLINK_H_ */