Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 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 _UAPI_LINUX_DEVLINK_H_ |
| 13 | #define _UAPI_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 | |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 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 | |
Jiri Pirko | df38daf | 2016-04-14 18:19:14 +0200 | [diff] [blame] | 56 | /* Shared buffer occupancy monitoring commands */ |
| 57 | DEVLINK_CMD_SB_OCC_SNAPSHOT, |
| 58 | DEVLINK_CMD_SB_OCC_MAX_CLEAR, |
| 59 | |
Or Gerlitz | 08f4b59 | 2016-07-01 14:51:01 +0300 | [diff] [blame] | 60 | DEVLINK_CMD_ESWITCH_MODE_GET, |
| 61 | DEVLINK_CMD_ESWITCH_MODE_SET, |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 62 | /* add new commands above here */ |
| 63 | |
| 64 | __DEVLINK_CMD_MAX, |
| 65 | DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 |
| 66 | }; |
| 67 | |
| 68 | enum devlink_port_type { |
| 69 | DEVLINK_PORT_TYPE_NOTSET, |
| 70 | DEVLINK_PORT_TYPE_AUTO, |
| 71 | DEVLINK_PORT_TYPE_ETH, |
| 72 | DEVLINK_PORT_TYPE_IB, |
| 73 | }; |
| 74 | |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 75 | enum devlink_sb_pool_type { |
| 76 | DEVLINK_SB_POOL_TYPE_INGRESS, |
| 77 | DEVLINK_SB_POOL_TYPE_EGRESS, |
| 78 | }; |
| 79 | |
| 80 | /* static threshold - limiting the maximum number of bytes. |
| 81 | * dynamic threshold - limiting the maximum number of bytes |
| 82 | * based on the currently available free space in the shared buffer pool. |
| 83 | * In this mode, the maximum quota is calculated based |
| 84 | * on the following formula: |
| 85 | * max_quota = alpha / (1 + alpha) * Free_Buffer |
| 86 | * While Free_Buffer is the amount of none-occupied buffer associated to |
| 87 | * the relevant pool. |
| 88 | * The value range which can be passed is 0-20 and serves |
| 89 | * for computation of alpha by following formula: |
| 90 | * alpha = 2 ^ (passed_value - 10) |
| 91 | */ |
| 92 | |
| 93 | enum devlink_sb_threshold_type { |
| 94 | DEVLINK_SB_THRESHOLD_TYPE_STATIC, |
| 95 | DEVLINK_SB_THRESHOLD_TYPE_DYNAMIC, |
| 96 | }; |
| 97 | |
| 98 | #define DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX 20 |
| 99 | |
Or Gerlitz | 08f4b59 | 2016-07-01 14:51:01 +0300 | [diff] [blame] | 100 | enum devlink_eswitch_mode { |
| 101 | DEVLINK_ESWITCH_MODE_LEGACY, |
| 102 | DEVLINK_ESWITCH_MODE_SWITCHDEV, |
| 103 | }; |
| 104 | |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 105 | enum devlink_attr { |
| 106 | /* don't change the order or add anything between, this is ABI! */ |
| 107 | DEVLINK_ATTR_UNSPEC, |
| 108 | |
| 109 | /* bus name + dev name together are a handle for devlink entity */ |
| 110 | DEVLINK_ATTR_BUS_NAME, /* string */ |
| 111 | DEVLINK_ATTR_DEV_NAME, /* string */ |
| 112 | |
| 113 | DEVLINK_ATTR_PORT_INDEX, /* u32 */ |
| 114 | DEVLINK_ATTR_PORT_TYPE, /* u16 */ |
| 115 | DEVLINK_ATTR_PORT_DESIRED_TYPE, /* u16 */ |
| 116 | DEVLINK_ATTR_PORT_NETDEV_IFINDEX, /* u32 */ |
| 117 | DEVLINK_ATTR_PORT_NETDEV_NAME, /* string */ |
| 118 | DEVLINK_ATTR_PORT_IBDEV_NAME, /* string */ |
| 119 | DEVLINK_ATTR_PORT_SPLIT_COUNT, /* u32 */ |
| 120 | DEVLINK_ATTR_PORT_SPLIT_GROUP, /* u32 */ |
Jiri Pirko | bf79747 | 2016-04-14 18:19:13 +0200 | [diff] [blame] | 121 | DEVLINK_ATTR_SB_INDEX, /* u32 */ |
| 122 | DEVLINK_ATTR_SB_SIZE, /* u32 */ |
| 123 | DEVLINK_ATTR_SB_INGRESS_POOL_COUNT, /* u16 */ |
| 124 | DEVLINK_ATTR_SB_EGRESS_POOL_COUNT, /* u16 */ |
| 125 | DEVLINK_ATTR_SB_INGRESS_TC_COUNT, /* u16 */ |
| 126 | DEVLINK_ATTR_SB_EGRESS_TC_COUNT, /* u16 */ |
| 127 | DEVLINK_ATTR_SB_POOL_INDEX, /* u16 */ |
| 128 | DEVLINK_ATTR_SB_POOL_TYPE, /* u8 */ |
| 129 | DEVLINK_ATTR_SB_POOL_SIZE, /* u32 */ |
| 130 | DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE, /* u8 */ |
| 131 | DEVLINK_ATTR_SB_THRESHOLD, /* u32 */ |
| 132 | DEVLINK_ATTR_SB_TC_INDEX, /* u16 */ |
Jiri Pirko | df38daf | 2016-04-14 18:19:14 +0200 | [diff] [blame] | 133 | DEVLINK_ATTR_SB_OCC_CUR, /* u32 */ |
| 134 | DEVLINK_ATTR_SB_OCC_MAX, /* u32 */ |
Or Gerlitz | 08f4b59 | 2016-07-01 14:51:01 +0300 | [diff] [blame] | 135 | DEVLINK_ATTR_ESWITCH_MODE, /* u16 */ |
Jiri Pirko | bfcd3a4 | 2016-02-26 17:32:23 +0100 | [diff] [blame] | 136 | |
| 137 | /* add new attributes above here, update the policy in devlink.c */ |
| 138 | |
| 139 | __DEVLINK_ATTR_MAX, |
| 140 | DEVLINK_ATTR_MAX = __DEVLINK_ATTR_MAX - 1 |
| 141 | }; |
| 142 | |
| 143 | #endif /* _UAPI_LINUX_DEVLINK_H_ */ |