• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 _LINUX_DEVLINK_H_
14 #define _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 
20 enum 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 
74 	/* add new commands above here */
75 	__DEVLINK_CMD_MAX,
76 	DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
77 };
78 
79 enum devlink_port_type {
80 	DEVLINK_PORT_TYPE_NOTSET,
81 	DEVLINK_PORT_TYPE_AUTO,
82 	DEVLINK_PORT_TYPE_ETH,
83 	DEVLINK_PORT_TYPE_IB,
84 };
85 
86 enum devlink_sb_pool_type {
87 	DEVLINK_SB_POOL_TYPE_INGRESS,
88 	DEVLINK_SB_POOL_TYPE_EGRESS,
89 };
90 
91 /* static threshold - limiting the maximum number of bytes.
92  * dynamic threshold - limiting the maximum number of bytes
93  *   based on the currently available free space in the shared buffer pool.
94  *   In this mode, the maximum quota is calculated based
95  *   on the following formula:
96  *     max_quota = alpha / (1 + alpha) * Free_Buffer
97  *   While Free_Buffer is the amount of none-occupied buffer associated to
98  *   the relevant pool.
99  *   The value range which can be passed is 0-20 and serves
100  *   for computation of alpha by following formula:
101  *     alpha = 2 ^ (passed_value - 10)
102  */
103 
104 enum devlink_sb_threshold_type {
105 	DEVLINK_SB_THRESHOLD_TYPE_STATIC,
106 	DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC,
107 };
108 
109 #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
110 
111 enum devlink_eswitch_mode {
112 	DEVLINK_ESWITCH_MODE_LEGACY,
113 	DEVLINK_ESWITCH_MODE_SWITCHDEV,
114 };
115 
116 enum devlink_eswitch_inline_mode {
117 	DEVLINK_ESWITCH_INLINE_MODE_NONE,
118 	DEVLINK_ESWITCH_INLINE_MODE_LINK,
119 	DEVLINK_ESWITCH_INLINE_MODE_NETWORK,
120 	DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT,
121 };
122 
123 enum devlink_eswitch_encap_mode {
124 	DEVLINK_ESWITCH_ENCAP_MODE_NONE,
125 	DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
126 };
127 
128 enum devlink_attr {
129 	/* don't change the order or add anything between, this is ABI! */
130 	DEVLINK_ATTR_UNSPEC,
131 
132 	/* bus name + dev name together are a handle for devlink entity */
133 	DEVLINK_ATTR_BUS_NAME,			/* string */
134 	DEVLINK_ATTR_DEV_NAME,			/* string */
135 
136 	DEVLINK_ATTR_PORT_INDEX,		/* u32 */
137 	DEVLINK_ATTR_PORT_TYPE,			/* u16 */
138 	DEVLINK_ATTR_PORT_DESIRED_TYPE,		/* u16 */
139 	DEVLINK_ATTR_PORT_NETDEV_IFINDEX,	/* u32 */
140 	DEVLINK_ATTR_PORT_NETDEV_NAME,		/* string */
141 	DEVLINK_ATTR_PORT_IBDEV_NAME,		/* string */
142 	DEVLINK_ATTR_PORT_SPLIT_COUNT,		/* u32 */
143 	DEVLINK_ATTR_PORT_SPLIT_GROUP,		/* u32 */
144 	DEVLINK_ATTR_SB_INDEX,			/* u32 */
145 	DEVLINK_ATTR_SB_SIZE,			/* u32 */
146 	DEVLINK_ATTR_SB_INGRESS_POOL_COUNT,	/* u16 */
147 	DEVLINK_ATTR_SB_EGRESS_POOL_COUNT,	/* u16 */
148 	DEVLINK_ATTR_SB_INGRESS_TC_COUNT,	/* u16 */
149 	DEVLINK_ATTR_SB_EGRESS_TC_COUNT,	/* u16 */
150 	DEVLINK_ATTR_SB_POOL_INDEX,		/* u16 */
151 	DEVLINK_ATTR_SB_POOL_TYPE,		/* u8 */
152 	DEVLINK_ATTR_SB_POOL_SIZE,		/* u32 */
153 	DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,	/* u8 */
154 	DEVLINK_ATTR_SB_THRESHOLD,		/* u32 */
155 	DEVLINK_ATTR_SB_TC_INDEX,		/* u16 */
156 	DEVLINK_ATTR_SB_OCC_CUR,		/* u32 */
157 	DEVLINK_ATTR_SB_OCC_MAX,		/* u32 */
158 	DEVLINK_ATTR_ESWITCH_MODE,		/* u16 */
159 	DEVLINK_ATTR_ESWITCH_INLINE_MODE,	/* u8 */
160 
161 	DEVLINK_ATTR_DPIPE_TABLES,		/* nested */
162 	DEVLINK_ATTR_DPIPE_TABLE,		/* nested */
163 	DEVLINK_ATTR_DPIPE_TABLE_NAME,		/* string */
164 	DEVLINK_ATTR_DPIPE_TABLE_SIZE,		/* u64 */
165 	DEVLINK_ATTR_DPIPE_TABLE_MATCHES,	/* nested */
166 	DEVLINK_ATTR_DPIPE_TABLE_ACTIONS,	/* nested */
167 	DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED,	/* u8 */
168 
169 	DEVLINK_ATTR_DPIPE_ENTRIES,		/* nested */
170 	DEVLINK_ATTR_DPIPE_ENTRY,		/* nested */
171 	DEVLINK_ATTR_DPIPE_ENTRY_INDEX,		/* u64 */
172 	DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES,	/* nested */
173 	DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES,	/* nested */
174 	DEVLINK_ATTR_DPIPE_ENTRY_COUNTER,	/* u64 */
175 
176 	DEVLINK_ATTR_DPIPE_MATCH,		/* nested */
177 	DEVLINK_ATTR_DPIPE_MATCH_VALUE,		/* nested */
178 	DEVLINK_ATTR_DPIPE_MATCH_TYPE,		/* u32 */
179 
180 	DEVLINK_ATTR_DPIPE_ACTION,		/* nested */
181 	DEVLINK_ATTR_DPIPE_ACTION_VALUE,	/* nested */
182 	DEVLINK_ATTR_DPIPE_ACTION_TYPE,		/* u32 */
183 
184 	DEVLINK_ATTR_DPIPE_VALUE,
185 	DEVLINK_ATTR_DPIPE_VALUE_MASK,
186 	DEVLINK_ATTR_DPIPE_VALUE_MAPPING,	/* u32 */
187 
188 	DEVLINK_ATTR_DPIPE_HEADERS,		/* nested */
189 	DEVLINK_ATTR_DPIPE_HEADER,		/* nested */
190 	DEVLINK_ATTR_DPIPE_HEADER_NAME,		/* string */
191 	DEVLINK_ATTR_DPIPE_HEADER_ID,		/* u32 */
192 	DEVLINK_ATTR_DPIPE_HEADER_FIELDS,	/* nested */
193 	DEVLINK_ATTR_DPIPE_HEADER_GLOBAL,	/* u8 */
194 	DEVLINK_ATTR_DPIPE_HEADER_INDEX,	/* u32 */
195 
196 	DEVLINK_ATTR_DPIPE_FIELD,		/* nested */
197 	DEVLINK_ATTR_DPIPE_FIELD_NAME,		/* string */
198 	DEVLINK_ATTR_DPIPE_FIELD_ID,		/* u32 */
199 	DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH,	/* u32 */
200 	DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE,	/* u32 */
201 
202 	DEVLINK_ATTR_PAD,
203 
204 	DEVLINK_ATTR_ESWITCH_ENCAP_MODE,	/* u8 */
205 
206 	/* add new attributes above here, update the policy in devlink.c */
207 
208 	__DEVLINK_ATTR_MAX,
209 	DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
210 };
211 
212 /* Mapping between internal resource described by the field and system
213  * structure
214  */
215 enum devlink_dpipe_field_mapping_type {
216 	DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE,
217 	DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX,
218 };
219 
220 /* Match type - specify the type of the match */
221 enum devlink_dpipe_match_type {
222 	DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT,
223 };
224 
225 /* Action type - specify the action type */
226 enum devlink_dpipe_action_type {
227 	DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY,
228 };
229 
230 enum devlink_dpipe_field_ethernet_id {
231 	DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC,
232 };
233 
234 enum devlink_dpipe_field_ipv4_id {
235 	DEVLINK_DPIPE_FIELD_IPV4_DST_IP,
236 };
237 
238 enum devlink_dpipe_field_ipv6_id {
239 	DEVLINK_DPIPE_FIELD_IPV6_DST_IP,
240 };
241 
242 enum devlink_dpipe_header_id {
243 	DEVLINK_DPIPE_HEADER_ETHERNET,
244 	DEVLINK_DPIPE_HEADER_IPV4,
245 	DEVLINK_DPIPE_HEADER_IPV6,
246 };
247 
248 #endif /* _LINUX_DEVLINK_H_ */
249