]> git.proxmox.com Git - mirror_iproute2.git/blob - include/linux/devlink.h
update headers to 4.11 net-next
[mirror_iproute2.git] / include / linux / devlink.h
1 /*
2 * include/uapi/linux/devlink.h - Network physical device Netlink interface
3 * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2016 Jiri Pirko <jiri@mellanox.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12 #ifndef _LINUX_DEVLINK_H_
13 #define _LINUX_DEVLINK_H_
14
15 #define DEVLINK_GENL_NAME "devlink"
16 #define DEVLINK_GENL_VERSION 0x1
17 #define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
18
19 enum devlink_command {
20 /* don't change the order or add anything between, this is ABI! */
21 DEVLINK_CMD_UNSPEC,
22
23 DEVLINK_CMD_GET, /* can dump */
24 DEVLINK_CMD_SET,
25 DEVLINK_CMD_NEW,
26 DEVLINK_CMD_DEL,
27
28 DEVLINK_CMD_PORT_GET, /* can dump */
29 DEVLINK_CMD_PORT_SET,
30 DEVLINK_CMD_PORT_NEW,
31 DEVLINK_CMD_PORT_DEL,
32
33 DEVLINK_CMD_PORT_SPLIT,
34 DEVLINK_CMD_PORT_UNSPLIT,
35
36 DEVLINK_CMD_SB_GET, /* can dump */
37 DEVLINK_CMD_SB_SET,
38 DEVLINK_CMD_SB_NEW,
39 DEVLINK_CMD_SB_DEL,
40
41 DEVLINK_CMD_SB_POOL_GET, /* can dump */
42 DEVLINK_CMD_SB_POOL_SET,
43 DEVLINK_CMD_SB_POOL_NEW,
44 DEVLINK_CMD_SB_POOL_DEL,
45
46 DEVLINK_CMD_SB_PORT_POOL_GET, /* can dump */
47 DEVLINK_CMD_SB_PORT_POOL_SET,
48 DEVLINK_CMD_SB_PORT_POOL_NEW,
49 DEVLINK_CMD_SB_PORT_POOL_DEL,
50
51 DEVLINK_CMD_SB_TC_POOL_BIND_GET, /* can dump */
52 DEVLINK_CMD_SB_TC_POOL_BIND_SET,
53 DEVLINK_CMD_SB_TC_POOL_BIND_NEW,
54 DEVLINK_CMD_SB_TC_POOL_BIND_DEL,
55
56 /* Shared buffer occupancy monitoring commands */
57 DEVLINK_CMD_SB_OCC_SNAPSHOT,
58 DEVLINK_CMD_SB_OCC_MAX_CLEAR,
59
60 DEVLINK_CMD_ESWITCH_GET,
61 #define DEVLINK_CMD_ESWITCH_MODE_GET /* obsolete, never use this! */ \
62 DEVLINK_CMD_ESWITCH_GET
63
64 DEVLINK_CMD_ESWITCH_SET,
65 #define DEVLINK_CMD_ESWITCH_MODE_SET /* obsolete, never use this! */ \
66 DEVLINK_CMD_ESWITCH_SET
67
68 DEVLINK_CMD_DPIPE_TABLE_GET,
69 DEVLINK_CMD_DPIPE_ENTRIES_GET,
70 DEVLINK_CMD_DPIPE_HEADERS_GET,
71 DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
72
73 /* add new commands above here */
74 __DEVLINK_CMD_MAX,
75 DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
76 };
77
78 enum devlink_port_type {
79 DEVLINK_PORT_TYPE_NOTSET,
80 DEVLINK_PORT_TYPE_AUTO,
81 DEVLINK_PORT_TYPE_ETH,
82 DEVLINK_PORT_TYPE_IB,
83 };
84
85 enum devlink_sb_pool_type {
86 DEVLINK_SB_POOL_TYPE_INGRESS,
87 DEVLINK_SB_POOL_TYPE_EGRESS,
88 };
89
90 /* static threshold - limiting the maximum number of bytes.
91 * dynamic threshold - limiting the maximum number of bytes
92 * based on the currently available free space in the shared buffer pool.
93 * In this mode, the maximum quota is calculated based
94 * on the following formula:
95 * max_quota = alpha / (1 + alpha) * Free_Buffer
96 * While Free_Buffer is the amount of none-occupied buffer associated to
97 * the relevant pool.
98 * The value range which can be passed is 0-20 and serves
99 * for computation of alpha by following formula:
100 * alpha = 2 ^ (passed_value - 10)
101 */
102
103 enum devlink_sb_threshold_type {
104 DEVLINK_SB_THRESHOLD_TYPE_STATIC,
105 DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC,
106 };
107
108 #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20
109
110 enum devlink_eswitch_mode {
111 DEVLINK_ESWITCH_MODE_LEGACY,
112 DEVLINK_ESWITCH_MODE_SWITCHDEV,
113 };
114
115 enum devlink_eswitch_inline_mode {
116 DEVLINK_ESWITCH_INLINE_MODE_NONE,
117 DEVLINK_ESWITCH_INLINE_MODE_LINK,
118 DEVLINK_ESWITCH_INLINE_MODE_NETWORK,
119 DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT,
120 };
121
122 enum devlink_eswitch_encap_mode {
123 DEVLINK_ESWITCH_ENCAP_MODE_NONE,
124 DEVLINK_ESWITCH_ENCAP_MODE_BASIC,
125 };
126
127 enum devlink_attr {
128 /* don't change the order or add anything between, this is ABI! */
129 DEVLINK_ATTR_UNSPEC,
130
131 /* bus name + dev name together are a handle for devlink entity */
132 DEVLINK_ATTR_BUS_NAME, /* string */
133 DEVLINK_ATTR_DEV_NAME, /* string */
134
135 DEVLINK_ATTR_PORT_INDEX, /* u32 */
136 DEVLINK_ATTR_PORT_TYPE, /* u16 */
137 DEVLINK_ATTR_PORT_DESIRED_TYPE, /* u16 */
138 DEVLINK_ATTR_PORT_NETDEV_IFINDEX, /* u32 */
139 DEVLINK_ATTR_PORT_NETDEV_NAME, /* string */
140 DEVLINK_ATTR_PORT_IBDEV_NAME, /* string */
141 DEVLINK_ATTR_PORT_SPLIT_COUNT, /* u32 */
142 DEVLINK_ATTR_PORT_SPLIT_GROUP, /* u32 */
143 DEVLINK_ATTR_SB_INDEX, /* u32 */
144 DEVLINK_ATTR_SB_SIZE, /* u32 */
145 DEVLINK_ATTR_SB_INGRESS_POOL_COUNT, /* u16 */
146 DEVLINK_ATTR_SB_EGRESS_POOL_COUNT, /* u16 */
147 DEVLINK_ATTR_SB_INGRESS_TC_COUNT, /* u16 */
148 DEVLINK_ATTR_SB_EGRESS_TC_COUNT, /* u16 */
149 DEVLINK_ATTR_SB_POOL_INDEX, /* u16 */
150 DEVLINK_ATTR_SB_POOL_TYPE, /* u8 */
151 DEVLINK_ATTR_SB_POOL_SIZE, /* u32 */
152 DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE, /* u8 */
153 DEVLINK_ATTR_SB_THRESHOLD, /* u32 */
154 DEVLINK_ATTR_SB_TC_INDEX, /* u16 */
155 DEVLINK_ATTR_SB_OCC_CUR, /* u32 */
156 DEVLINK_ATTR_SB_OCC_MAX, /* u32 */
157 DEVLINK_ATTR_ESWITCH_MODE, /* u16 */
158 DEVLINK_ATTR_ESWITCH_INLINE_MODE, /* u8 */
159
160 DEVLINK_ATTR_DPIPE_TABLES, /* nested */
161 DEVLINK_ATTR_DPIPE_TABLE, /* nested */
162 DEVLINK_ATTR_DPIPE_TABLE_NAME, /* string */
163 DEVLINK_ATTR_DPIPE_TABLE_SIZE, /* u64 */
164 DEVLINK_ATTR_DPIPE_TABLE_MATCHES, /* nested */
165 DEVLINK_ATTR_DPIPE_TABLE_ACTIONS, /* nested */
166 DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED, /* u8 */
167
168 DEVLINK_ATTR_DPIPE_ENTRIES, /* nested */
169 DEVLINK_ATTR_DPIPE_ENTRY, /* nested */
170 DEVLINK_ATTR_DPIPE_ENTRY_INDEX, /* u64 */
171 DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES, /* nested */
172 DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES, /* nested */
173 DEVLINK_ATTR_DPIPE_ENTRY_COUNTER, /* u64 */
174
175 DEVLINK_ATTR_DPIPE_MATCH, /* nested */
176 DEVLINK_ATTR_DPIPE_MATCH_VALUE, /* nested */
177 DEVLINK_ATTR_DPIPE_MATCH_TYPE, /* u32 */
178
179 DEVLINK_ATTR_DPIPE_ACTION, /* nested */
180 DEVLINK_ATTR_DPIPE_ACTION_VALUE, /* nested */
181 DEVLINK_ATTR_DPIPE_ACTION_TYPE, /* u32 */
182
183 DEVLINK_ATTR_DPIPE_VALUE,
184 DEVLINK_ATTR_DPIPE_VALUE_MASK,
185 DEVLINK_ATTR_DPIPE_VALUE_MAPPING, /* u32 */
186
187 DEVLINK_ATTR_DPIPE_HEADERS, /* nested */
188 DEVLINK_ATTR_DPIPE_HEADER, /* nested */
189 DEVLINK_ATTR_DPIPE_HEADER_NAME, /* string */
190 DEVLINK_ATTR_DPIPE_HEADER_ID, /* u32 */
191 DEVLINK_ATTR_DPIPE_HEADER_FIELDS, /* nested */
192 DEVLINK_ATTR_DPIPE_HEADER_GLOBAL, /* u8 */
193 DEVLINK_ATTR_DPIPE_HEADER_INDEX, /* u32 */
194
195 DEVLINK_ATTR_DPIPE_FIELD, /* nested */
196 DEVLINK_ATTR_DPIPE_FIELD_NAME, /* string */
197 DEVLINK_ATTR_DPIPE_FIELD_ID, /* u32 */
198 DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH, /* u32 */
199 DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE, /* u32 */
200
201 DEVLINK_ATTR_PAD,
202
203 DEVLINK_ATTR_ESWITCH_ENCAP_MODE, /* u8 */
204
205 /* add new attributes above here, update the policy in devlink.c */
206
207 __DEVLINK_ATTR_MAX,
208 DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1
209 };
210
211 /* Mapping between internal resource described by the field and system
212 * structure
213 */
214 enum devlink_dpipe_field_mapping_type {
215 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE,
216 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX,
217 };
218
219 /* Match type - specify the type of the match */
220 enum devlink_dpipe_match_type {
221 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT,
222 };
223
224 /* Action type - specify the action type */
225 enum devlink_dpipe_action_type {
226 DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY,
227 };
228
229 #endif /* _LINUX_DEVLINK_H_ */