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 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 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 /* add new commands above here */ 93 __DEVLINK_CMD_MAX, 94 DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 95 }; 96 97 enum devlink_port_type { 98 DEVLINK_PORT_TYPE_NOTSET, 99 DEVLINK_PORT_TYPE_AUTO, 100 DEVLINK_PORT_TYPE_ETH, 101 DEVLINK_PORT_TYPE_IB, 102 }; 103 104 enum devlink_sb_pool_type { 105 DEVLINK_SB_POOL_TYPE_INGRESS, 106 DEVLINK_SB_POOL_TYPE_EGRESS, 107 }; 108 109 /* static threshold - limiting the maximum number of bytes. 110 * dynamic threshold - limiting the maximum number of bytes 111 * based on the currently available free space in the shared buffer pool. 112 * In this mode, the maximum quota is calculated based 113 * on the following formula: 114 * max_quota = alpha / (1 + alpha) * Free_Buffer 115 * While Free_Buffer is the amount of none-occupied buffer associated to 116 * the relevant pool. 117 * The value range which can be passed is 0-20 and serves 118 * for computation of alpha by following formula: 119 * alpha = 2 ^ (passed_value - 10) 120 */ 121 122 enum devlink_sb_threshold_type { 123 DEVLINK_SB_THRESHOLD_TYPE_STATIC, 124 DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC, 125 }; 126 127 #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20 128 129 enum devlink_eswitch_mode { 130 DEVLINK_ESWITCH_MODE_LEGACY, 131 DEVLINK_ESWITCH_MODE_SWITCHDEV, 132 }; 133 134 enum devlink_eswitch_inline_mode { 135 DEVLINK_ESWITCH_INLINE_MODE_NONE, 136 DEVLINK_ESWITCH_INLINE_MODE_LINK, 137 DEVLINK_ESWITCH_INLINE_MODE_NETWORK, 138 DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT, 139 }; 140 141 enum devlink_eswitch_encap_mode { 142 DEVLINK_ESWITCH_ENCAP_MODE_NONE, 143 DEVLINK_ESWITCH_ENCAP_MODE_BASIC, 144 }; 145 146 enum devlink_port_flavour { 147 DEVLINK_PORT_FLAVOUR_PHYSICAL, /* Any kind of a port physically 148 * facing the user. 149 */ 150 DEVLINK_PORT_FLAVOUR_CPU, /* CPU port */ 151 DEVLINK_PORT_FLAVOUR_DSA, /* Distributed switch architecture 152 * interconnect port. 153 */ 154 }; 155 156 enum devlink_param_cmode { 157 DEVLINK_PARAM_CMODE_RUNTIME, 158 DEVLINK_PARAM_CMODE_DRIVERINIT, 159 DEVLINK_PARAM_CMODE_PERMANENT, 160 161 /* Add new configuration modes above */ 162 __DEVLINK_PARAM_CMODE_MAX, 163 DEVLINK_PARAM_CMODE_MAX = __DEVLINK_PARAM_CMODE_MAX - 1 164 }; 165 166 enum devlink_attr { 167 /* don't change the order or add anything between, this is ABI! */ 168 DEVLINK_ATTR_UNSPEC, 169 170 /* bus name + dev name together are a handle for devlink entity */ 171 DEVLINK_ATTR_BUS_NAME, /* string */ 172 DEVLINK_ATTR_DEV_NAME, /* string */ 173 174 DEVLINK_ATTR_PORT_INDEX, /* u32 */ 175 DEVLINK_ATTR_PORT_TYPE, /* u16 */ 176 DEVLINK_ATTR_PORT_DESIRED_TYPE, /* u16 */ 177 DEVLINK_ATTR_PORT_NETDEV_IFINDEX, /* u32 */ 178 DEVLINK_ATTR_PORT_NETDEV_NAME, /* string */ 179 DEVLINK_ATTR_PORT_IBDEV_NAME, /* string */ 180 DEVLINK_ATTR_PORT_SPLIT_COUNT, /* u32 */ 181 DEVLINK_ATTR_PORT_SPLIT_GROUP, /* u32 */ 182 DEVLINK_ATTR_SB_INDEX, /* u32 */ 183 DEVLINK_ATTR_SB_SIZE, /* u32 */ 184 DEVLINK_ATTR_SB_INGRESS_POOL_COUNT, /* u16 */ 185 DEVLINK_ATTR_SB_EGRESS_POOL_COUNT, /* u16 */ 186 DEVLINK_ATTR_SB_INGRESS_TC_COUNT, /* u16 */ 187 DEVLINK_ATTR_SB_EGRESS_TC_COUNT, /* u16 */ 188 DEVLINK_ATTR_SB_POOL_INDEX, /* u16 */ 189 DEVLINK_ATTR_SB_POOL_TYPE, /* u8 */ 190 DEVLINK_ATTR_SB_POOL_SIZE, /* u32 */ 191 DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE, /* u8 */ 192 DEVLINK_ATTR_SB_THRESHOLD, /* u32 */ 193 DEVLINK_ATTR_SB_TC_INDEX, /* u16 */ 194 DEVLINK_ATTR_SB_OCC_CUR, /* u32 */ 195 DEVLINK_ATTR_SB_OCC_MAX, /* u32 */ 196 DEVLINK_ATTR_ESWITCH_MODE, /* u16 */ 197 DEVLINK_ATTR_ESWITCH_INLINE_MODE, /* u8 */ 198 199 DEVLINK_ATTR_DPIPE_TABLES, /* nested */ 200 DEVLINK_ATTR_DPIPE_TABLE, /* nested */ 201 DEVLINK_ATTR_DPIPE_TABLE_NAME, /* string */ 202 DEVLINK_ATTR_DPIPE_TABLE_SIZE, /* u64 */ 203 DEVLINK_ATTR_DPIPE_TABLE_MATCHES, /* nested */ 204 DEVLINK_ATTR_DPIPE_TABLE_ACTIONS, /* nested */ 205 DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED, /* u8 */ 206 207 DEVLINK_ATTR_DPIPE_ENTRIES, /* nested */ 208 DEVLINK_ATTR_DPIPE_ENTRY, /* nested */ 209 DEVLINK_ATTR_DPIPE_ENTRY_INDEX, /* u64 */ 210 DEVLINK_ATTR_DPIPE_ENTRY_MATCH_VALUES, /* nested */ 211 DEVLINK_ATTR_DPIPE_ENTRY_ACTION_VALUES, /* nested */ 212 DEVLINK_ATTR_DPIPE_ENTRY_COUNTER, /* u64 */ 213 214 DEVLINK_ATTR_DPIPE_MATCH, /* nested */ 215 DEVLINK_ATTR_DPIPE_MATCH_VALUE, /* nested */ 216 DEVLINK_ATTR_DPIPE_MATCH_TYPE, /* u32 */ 217 218 DEVLINK_ATTR_DPIPE_ACTION, /* nested */ 219 DEVLINK_ATTR_DPIPE_ACTION_VALUE, /* nested */ 220 DEVLINK_ATTR_DPIPE_ACTION_TYPE, /* u32 */ 221 222 DEVLINK_ATTR_DPIPE_VALUE, 223 DEVLINK_ATTR_DPIPE_VALUE_MASK, 224 DEVLINK_ATTR_DPIPE_VALUE_MAPPING, /* u32 */ 225 226 DEVLINK_ATTR_DPIPE_HEADERS, /* nested */ 227 DEVLINK_ATTR_DPIPE_HEADER, /* nested */ 228 DEVLINK_ATTR_DPIPE_HEADER_NAME, /* string */ 229 DEVLINK_ATTR_DPIPE_HEADER_ID, /* u32 */ 230 DEVLINK_ATTR_DPIPE_HEADER_FIELDS, /* nested */ 231 DEVLINK_ATTR_DPIPE_HEADER_GLOBAL, /* u8 */ 232 DEVLINK_ATTR_DPIPE_HEADER_INDEX, /* u32 */ 233 234 DEVLINK_ATTR_DPIPE_FIELD, /* nested */ 235 DEVLINK_ATTR_DPIPE_FIELD_NAME, /* string */ 236 DEVLINK_ATTR_DPIPE_FIELD_ID, /* u32 */ 237 DEVLINK_ATTR_DPIPE_FIELD_BITWIDTH, /* u32 */ 238 DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE, /* u32 */ 239 240 DEVLINK_ATTR_PAD, 241 242 DEVLINK_ATTR_ESWITCH_ENCAP_MODE, /* u8 */ 243 DEVLINK_ATTR_RESOURCE_LIST, /* nested */ 244 DEVLINK_ATTR_RESOURCE, /* nested */ 245 DEVLINK_ATTR_RESOURCE_NAME, /* string */ 246 DEVLINK_ATTR_RESOURCE_ID, /* u64 */ 247 DEVLINK_ATTR_RESOURCE_SIZE, /* u64 */ 248 DEVLINK_ATTR_RESOURCE_SIZE_NEW, /* u64 */ 249 DEVLINK_ATTR_RESOURCE_SIZE_VALID, /* u8 */ 250 DEVLINK_ATTR_RESOURCE_SIZE_MIN, /* u64 */ 251 DEVLINK_ATTR_RESOURCE_SIZE_MAX, /* u64 */ 252 DEVLINK_ATTR_RESOURCE_SIZE_GRAN, /* u64 */ 253 DEVLINK_ATTR_RESOURCE_UNIT, /* u8 */ 254 DEVLINK_ATTR_RESOURCE_OCC, /* u64 */ 255 DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_ID, /* u64 */ 256 DEVLINK_ATTR_DPIPE_TABLE_RESOURCE_UNITS,/* u64 */ 257 258 DEVLINK_ATTR_PORT_FLAVOUR, /* u16 */ 259 DEVLINK_ATTR_PORT_NUMBER, /* u32 */ 260 DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER, /* u32 */ 261 262 DEVLINK_ATTR_PARAM, /* nested */ 263 DEVLINK_ATTR_PARAM_NAME, /* string */ 264 DEVLINK_ATTR_PARAM_GENERIC, /* flag */ 265 DEVLINK_ATTR_PARAM_TYPE, /* u8 */ 266 DEVLINK_ATTR_PARAM_VALUES_LIST, /* nested */ 267 DEVLINK_ATTR_PARAM_VALUE, /* nested */ 268 DEVLINK_ATTR_PARAM_VALUE_DATA, /* dynamic */ 269 DEVLINK_ATTR_PARAM_VALUE_CMODE, /* u8 */ 270 271 DEVLINK_ATTR_REGION_NAME, /* string */ 272 DEVLINK_ATTR_REGION_SIZE, /* u64 */ 273 DEVLINK_ATTR_REGION_SNAPSHOTS, /* nested */ 274 DEVLINK_ATTR_REGION_SNAPSHOT, /* nested */ 275 DEVLINK_ATTR_REGION_SNAPSHOT_ID, /* u32 */ 276 277 DEVLINK_ATTR_REGION_CHUNKS, /* nested */ 278 DEVLINK_ATTR_REGION_CHUNK, /* nested */ 279 DEVLINK_ATTR_REGION_CHUNK_DATA, /* binary */ 280 DEVLINK_ATTR_REGION_CHUNK_ADDR, /* u64 */ 281 DEVLINK_ATTR_REGION_CHUNK_LEN, /* u64 */ 282 283 /* add new attributes above here, update the policy in devlink.c */ 284 285 __DEVLINK_ATTR_MAX, 286 DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1 287 }; 288 289 /* Mapping between internal resource described by the field and system 290 * structure 291 */ 292 enum devlink_dpipe_field_mapping_type { 293 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE, 294 DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX, 295 }; 296 297 /* Match type - specify the type of the match */ 298 enum devlink_dpipe_match_type { 299 DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT, 300 }; 301 302 /* Action type - specify the action type */ 303 enum devlink_dpipe_action_type { 304 DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY, 305 }; 306 307 enum devlink_dpipe_field_ethernet_id { 308 DEVLINK_DPIPE_FIELD_ETHERNET_DST_MAC, 309 }; 310 311 enum devlink_dpipe_field_ipv4_id { 312 DEVLINK_DPIPE_FIELD_IPV4_DST_IP, 313 }; 314 315 enum devlink_dpipe_field_ipv6_id { 316 DEVLINK_DPIPE_FIELD_IPV6_DST_IP, 317 }; 318 319 enum devlink_dpipe_header_id { 320 DEVLINK_DPIPE_HEADER_ETHERNET, 321 DEVLINK_DPIPE_HEADER_IPV4, 322 DEVLINK_DPIPE_HEADER_IPV6, 323 }; 324 325 enum devlink_resource_unit { 326 DEVLINK_RESOURCE_UNIT_ENTRY, 327 }; 328 329 #endif /* _UAPI_LINUX_DEVLINK_H_ */ 330