mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-26 20:01:13 +08:00
Add DevlinkSplitPort, DevlinkUnsplitPort
This commit is contained in:

committed by
Vish (Ishaya) Abrams

parent
db0dbb948c
commit
37e5aafde3
@@ -818,6 +818,43 @@ func DevlinkGetDeviceParamByName(bus string, device string, param string) (*Devl
|
||||
return pkgHandle.DevlinkGetDeviceParamByName(bus, device, param)
|
||||
}
|
||||
|
||||
// DevlinkSplitPort splits a devlink port.
|
||||
// Equivalent to: devlink port split <bus>/<device>/<index> count N
|
||||
func (h *Handle) DevlinkSplitPort(port *DevlinkPort, count uint32) error {
|
||||
_, req, err := h.createCmdReq(nl.DEVLINK_CMD_PORT_SPLIT, port.BusName, port.DeviceName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.AddData(nl.NewRtAttr(nl.DEVLINK_ATTR_PORT_INDEX, nl.Uint32Attr(port.PortIndex)))
|
||||
req.AddData(nl.NewRtAttr(nl.DEVLINK_ATTR_PORT_SPLIT_COUNT, nl.Uint32Attr(count)))
|
||||
|
||||
_, err = req.Execute(unix.NETLINK_GENERIC, 0)
|
||||
return err
|
||||
}
|
||||
|
||||
func DevlinkSplitPort(port *DevlinkPort, count uint32) error {
|
||||
return pkgHandle.DevlinkSplitPort(port, count);
|
||||
}
|
||||
|
||||
// DevlinkUnsplitPort: unsplit devlink port
|
||||
// Equivalent to devlink port unsplit <bus>/<device>/<index>
|
||||
func (h *Handle) DevlinkUnsplitPort(port *DevlinkPort) error {
|
||||
_, req, err := h.createCmdReq(nl.DEVLINK_CMD_PORT_UNSPLIT, port.BusName, port.DeviceName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.AddData(nl.NewRtAttr(nl.DEVLINK_ATTR_PORT_INDEX, nl.Uint32Attr(port.PortIndex)))
|
||||
|
||||
_, err = req.Execute(unix.NETLINK_GENERIC, 0)
|
||||
return err
|
||||
}
|
||||
|
||||
func DevlinkUnsplitPort(port *DevlinkPort) error {
|
||||
return pkgHandle.DevlinkUnsplitPort(port);
|
||||
}
|
||||
|
||||
// DevlinkSetDeviceParam set specific parameter for devlink device
|
||||
// Equivalent to: `devlink dev param set <bus>/<device> name <param> cmode <cmode> value <value>`
|
||||
// cmode argument should contain valid cmode value as uint8, modes are define in nl.DEVLINK_PARAM_CMODE_* constants
|
||||
|
@@ -14,6 +14,8 @@ const (
|
||||
DEVLINK_CMD_PORT_SET = 6
|
||||
DEVLINK_CMD_PORT_NEW = 7
|
||||
DEVLINK_CMD_PORT_DEL = 8
|
||||
DEVLINK_CMD_PORT_SPLIT = 9
|
||||
DEVLINK_CMD_PORT_UNSPLIT = 10
|
||||
DEVLINK_CMD_ESWITCH_GET = 29
|
||||
DEVLINK_CMD_ESWITCH_SET = 30
|
||||
DEVLINK_CMD_RESOURCE_DUMP = 36
|
||||
@@ -30,6 +32,7 @@ const (
|
||||
DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 6
|
||||
DEVLINK_ATTR_PORT_NETDEV_NAME = 7
|
||||
DEVLINK_ATTR_PORT_IBDEV_NAME = 8
|
||||
DEVLINK_ATTR_PORT_SPLIT_COUNT = 9
|
||||
DEVLINK_ATTR_ESWITCH_MODE = 25
|
||||
DEVLINK_ATTR_ESWITCH_INLINE_MODE = 26
|
||||
DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 62
|
||||
|
Reference in New Issue
Block a user