github.com/sagernet/netlink@v0.0.0-20240612041022-b9a21c07ac6a/nl/devlink_linux.go (about) 1 package nl 2 3 // All the following constants are coming from: 4 // https://github.com/torvalds/linux/blob/master/include/uapi/linux/devlink.h 5 6 const ( 7 GENL_DEVLINK_VERSION = 1 8 GENL_DEVLINK_NAME = "devlink" 9 ) 10 11 const ( 12 DEVLINK_CMD_GET = 1 13 DEVLINK_CMD_PORT_GET = 5 14 DEVLINK_CMD_PORT_SET = 6 15 DEVLINK_CMD_PORT_NEW = 7 16 DEVLINK_CMD_PORT_DEL = 8 17 DEVLINK_CMD_ESWITCH_GET = 29 18 DEVLINK_CMD_ESWITCH_SET = 30 19 DEVLINK_CMD_INFO_GET = 51 20 ) 21 22 const ( 23 DEVLINK_ATTR_BUS_NAME = 1 24 DEVLINK_ATTR_DEV_NAME = 2 25 DEVLINK_ATTR_PORT_INDEX = 3 26 DEVLINK_ATTR_PORT_TYPE = 4 27 DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 6 28 DEVLINK_ATTR_PORT_NETDEV_NAME = 7 29 DEVLINK_ATTR_PORT_IBDEV_NAME = 8 30 DEVLINK_ATTR_ESWITCH_MODE = 25 31 DEVLINK_ATTR_ESWITCH_INLINE_MODE = 26 32 DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 62 33 DEVLINK_ATTR_PORT_FLAVOUR = 77 34 DEVLINK_ATTR_INFO_DRIVER_NAME = 98 35 DEVLINK_ATTR_INFO_SERIAL_NUMBER = 99 36 DEVLINK_ATTR_INFO_VERSION_FIXED = 100 37 DEVLINK_ATTR_INFO_VERSION_RUNNING = 101 38 DEVLINK_ATTR_INFO_VERSION_STORED = 102 39 DEVLINK_ATTR_INFO_VERSION_NAME = 103 40 DEVLINK_ATTR_INFO_VERSION_VALUE = 104 41 DEVLINK_ATTR_PORT_PCI_PF_NUMBER = 127 42 DEVLINK_ATTR_PORT_FUNCTION = 145 43 DEVLINK_ATTR_PORT_CONTROLLER_NUMBER = 150 44 DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 164 45 ) 46 47 const ( 48 DEVLINK_ESWITCH_MODE_LEGACY = 0 49 DEVLINK_ESWITCH_MODE_SWITCHDEV = 1 50 ) 51 52 const ( 53 DEVLINK_ESWITCH_INLINE_MODE_NONE = 0 54 DEVLINK_ESWITCH_INLINE_MODE_LINK = 1 55 DEVLINK_ESWITCH_INLINE_MODE_NETWORK = 2 56 DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT = 3 57 ) 58 59 const ( 60 DEVLINK_ESWITCH_ENCAP_MODE_NONE = 0 61 DEVLINK_ESWITCH_ENCAP_MODE_BASIC = 1 62 ) 63 64 const ( 65 DEVLINK_PORT_FLAVOUR_PHYSICAL = 0 66 DEVLINK_PORT_FLAVOUR_CPU = 1 67 DEVLINK_PORT_FLAVOUR_DSA = 2 68 DEVLINK_PORT_FLAVOUR_PCI_PF = 3 69 DEVLINK_PORT_FLAVOUR_PCI_VF = 4 70 DEVLINK_PORT_FLAVOUR_VIRTUAL = 5 71 DEVLINK_PORT_FLAVOUR_UNUSED = 6 72 DEVLINK_PORT_FLAVOUR_PCI_SF = 7 73 ) 74 75 const ( 76 DEVLINK_PORT_TYPE_NOTSET = 0 77 DEVLINK_PORT_TYPE_AUTO = 1 78 DEVLINK_PORT_TYPE_ETH = 2 79 DEVLINK_PORT_TYPE_IB = 3 80 ) 81 82 const ( 83 DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR = 1 84 DEVLINK_PORT_FN_ATTR_STATE = 2 85 DEVLINK_PORT_FN_ATTR_OPSTATE = 3 86 ) 87 88 const ( 89 DEVLINK_PORT_FN_STATE_INACTIVE = 0 90 DEVLINK_PORT_FN_STATE_ACTIVE = 1 91 ) 92 93 const ( 94 DEVLINK_PORT_FN_OPSTATE_DETACHED = 0 95 DEVLINK_PORT_FN_OPSTATE_ATTACHED = 1 96 )