Skip to content

Commit 37e5aaf

Browse files
Charlie999vishvananda
authored andcommitted
Add DevlinkSplitPort, DevlinkUnsplitPort
1 parent db0dbb9 commit 37e5aaf

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

devlink_linux.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,43 @@ func DevlinkGetDeviceParamByName(bus string, device string, param string) (*Devl
818818
return pkgHandle.DevlinkGetDeviceParamByName(bus, device, param)
819819
}
820820

821+
// DevlinkSplitPort splits a devlink port.
822+
// Equivalent to: devlink port split <bus>/<device>/<index> count N
823+
func (h *Handle) DevlinkSplitPort(port *DevlinkPort, count uint32) error {
824+
_, req, err := h.createCmdReq(nl.DEVLINK_CMD_PORT_SPLIT, port.BusName, port.DeviceName)
825+
if err != nil {
826+
return err
827+
}
828+
829+
req.AddData(nl.NewRtAttr(nl.DEVLINK_ATTR_PORT_INDEX, nl.Uint32Attr(port.PortIndex)))
830+
req.AddData(nl.NewRtAttr(nl.DEVLINK_ATTR_PORT_SPLIT_COUNT, nl.Uint32Attr(count)))
831+
832+
_, err = req.Execute(unix.NETLINK_GENERIC, 0)
833+
return err
834+
}
835+
836+
func DevlinkSplitPort(port *DevlinkPort, count uint32) error {
837+
return pkgHandle.DevlinkSplitPort(port, count);
838+
}
839+
840+
// DevlinkUnsplitPort: unsplit devlink port
841+
// Equivalent to devlink port unsplit <bus>/<device>/<index>
842+
func (h *Handle) DevlinkUnsplitPort(port *DevlinkPort) error {
843+
_, req, err := h.createCmdReq(nl.DEVLINK_CMD_PORT_UNSPLIT, port.BusName, port.DeviceName)
844+
if err != nil {
845+
return err
846+
}
847+
848+
req.AddData(nl.NewRtAttr(nl.DEVLINK_ATTR_PORT_INDEX, nl.Uint32Attr(port.PortIndex)))
849+
850+
_, err = req.Execute(unix.NETLINK_GENERIC, 0)
851+
return err
852+
}
853+
854+
func DevlinkUnsplitPort(port *DevlinkPort) error {
855+
return pkgHandle.DevlinkUnsplitPort(port);
856+
}
857+
821858
// DevlinkSetDeviceParam set specific parameter for devlink device
822859
// Equivalent to: `devlink dev param set <bus>/<device> name <param> cmode <cmode> value <value>`
823860
// cmode argument should contain valid cmode value as uint8, modes are define in nl.DEVLINK_PARAM_CMODE_* constants

nl/devlink_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const (
1414
DEVLINK_CMD_PORT_SET = 6
1515
DEVLINK_CMD_PORT_NEW = 7
1616
DEVLINK_CMD_PORT_DEL = 8
17+
DEVLINK_CMD_PORT_SPLIT = 9
18+
DEVLINK_CMD_PORT_UNSPLIT = 10
1719
DEVLINK_CMD_ESWITCH_GET = 29
1820
DEVLINK_CMD_ESWITCH_SET = 30
1921
DEVLINK_CMD_RESOURCE_DUMP = 36
@@ -30,6 +32,7 @@ const (
3032
DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 6
3133
DEVLINK_ATTR_PORT_NETDEV_NAME = 7
3234
DEVLINK_ATTR_PORT_IBDEV_NAME = 8
35+
DEVLINK_ATTR_PORT_SPLIT_COUNT = 9
3336
DEVLINK_ATTR_ESWITCH_MODE = 25
3437
DEVLINK_ATTR_ESWITCH_INLINE_MODE = 26
3538
DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 62

0 commit comments

Comments
 (0)