mirror of
https://github.com/vishvananda/netlink.git
synced 2026-04-22 23:27:13 +08:00
devlink: move devlink structs to devlink.go
the structs and methods for managing devlink are all under the `devlink_linux.go` file, and when trying to write code in a non linux system (mac), the editor doesn't recognize any of it. this commit moves struct definitions from the devlink_linux.go file and creates a devlink_unspecified.go with the devlink funcs. this is similar to what we have in netlink_unspecified.go Signed-off-by: Bernardo Soares <20172413+bersoare@users.noreply.github.com>
This commit is contained in:
committed by
Alessandro Boch
parent
6e61cd407d
commit
7ddb61d720
+2
-124
@@ -3,7 +3,6 @@ package netlink
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
@@ -11,104 +10,6 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// DevlinkDevEswitchAttr represents device's eswitch attributes
|
||||
type DevlinkDevEswitchAttr struct {
|
||||
Mode string
|
||||
InlineMode string
|
||||
EncapMode string
|
||||
}
|
||||
|
||||
// DevlinkDevAttrs represents device attributes
|
||||
type DevlinkDevAttrs struct {
|
||||
Eswitch DevlinkDevEswitchAttr
|
||||
}
|
||||
|
||||
// DevlinkDevice represents device and its attributes
|
||||
type DevlinkDevice struct {
|
||||
BusName string
|
||||
DeviceName string
|
||||
Attrs DevlinkDevAttrs
|
||||
}
|
||||
|
||||
// DevlinkPortFn represents port function and its attributes
|
||||
type DevlinkPortFn struct {
|
||||
HwAddr net.HardwareAddr
|
||||
State uint8
|
||||
OpState uint8
|
||||
}
|
||||
|
||||
// DevlinkPortFnSetAttrs represents attributes to set
|
||||
type DevlinkPortFnSetAttrs struct {
|
||||
FnAttrs DevlinkPortFn
|
||||
HwAddrValid bool
|
||||
StateValid bool
|
||||
}
|
||||
|
||||
// DevlinkPort represents port and its attributes
|
||||
type DevlinkPort struct {
|
||||
BusName string
|
||||
DeviceName string
|
||||
PortIndex uint32
|
||||
PortType uint16
|
||||
NetdeviceName string
|
||||
NetdevIfIndex uint32
|
||||
RdmaDeviceName string
|
||||
PortFlavour uint16
|
||||
Fn *DevlinkPortFn
|
||||
PortNumber *uint32
|
||||
PfNumber *uint16
|
||||
VfNumber *uint16
|
||||
SfNumber *uint32
|
||||
ControllerNumber *uint32
|
||||
External *bool
|
||||
}
|
||||
|
||||
type DevLinkPortAddAttrs struct {
|
||||
Controller uint32
|
||||
SfNumber uint32
|
||||
PortIndex uint32
|
||||
PfNumber uint16
|
||||
SfNumberValid bool
|
||||
PortIndexValid bool
|
||||
ControllerValid bool
|
||||
}
|
||||
|
||||
// DevlinkDeviceInfo represents devlink info
|
||||
type DevlinkDeviceInfo struct {
|
||||
Driver string
|
||||
SerialNumber string
|
||||
BoardID string
|
||||
FwApp string
|
||||
FwAppBoundleID string
|
||||
FwAppName string
|
||||
FwBoundleID string
|
||||
FwMgmt string
|
||||
FwMgmtAPI string
|
||||
FwMgmtBuild string
|
||||
FwNetlist string
|
||||
FwNetlistBuild string
|
||||
FwPsidAPI string
|
||||
FwUndi string
|
||||
}
|
||||
|
||||
// DevlinkResource represents a device resource
|
||||
type DevlinkResource struct {
|
||||
Name string
|
||||
ID uint64
|
||||
Size uint64
|
||||
SizeNew uint64
|
||||
SizeMin uint64
|
||||
SizeMax uint64
|
||||
SizeGranularity uint64
|
||||
PendingChange bool
|
||||
Unit uint8
|
||||
SizeValid bool
|
||||
OCCValid bool
|
||||
OCCSize uint64
|
||||
Parent *DevlinkResource
|
||||
Children []DevlinkResource
|
||||
}
|
||||
|
||||
// parseAttributes parses provided Netlink Attributes and populates DevlinkResource, returns error if occured
|
||||
func (dlr *DevlinkResource) parseAttributes(attrs map[uint16]syscall.NetlinkRouteAttr) error {
|
||||
var attr syscall.NetlinkRouteAttr
|
||||
@@ -201,13 +102,6 @@ func (dlr *DevlinkResource) parseAttributes(attrs map[uint16]syscall.NetlinkRout
|
||||
return nil
|
||||
}
|
||||
|
||||
// DevlinkResources represents all devlink resources of a devlink device
|
||||
type DevlinkResources struct {
|
||||
Bus string
|
||||
Device string
|
||||
Resources []DevlinkResource
|
||||
}
|
||||
|
||||
// parseAttributes parses provided Netlink Attributes and populates DevlinkResources, returns error if occured
|
||||
func (dlrs *DevlinkResources) parseAttributes(attrs map[uint16]syscall.NetlinkRouteAttr) error {
|
||||
var attr syscall.NetlinkRouteAttr
|
||||
@@ -254,22 +148,6 @@ func (dlrs *DevlinkResources) parseAttributes(attrs map[uint16]syscall.NetlinkRo
|
||||
return nil
|
||||
}
|
||||
|
||||
// DevlinkParam represents parameter of the device
|
||||
type DevlinkParam struct {
|
||||
Name string
|
||||
IsGeneric bool
|
||||
Type uint8 // possible values are in nl.DEVLINK_PARAM_TYPE_* constants
|
||||
Values []DevlinkParamValue
|
||||
}
|
||||
|
||||
// DevlinkParamValue contains values of the parameter
|
||||
// Data field contains specific type which can be casted by unsing info from the DevlinkParam.Type field
|
||||
type DevlinkParamValue struct {
|
||||
rawData []byte
|
||||
Data interface{}
|
||||
CMODE uint8 // possible values are in nl.DEVLINK_PARAM_CMODE_* constants
|
||||
}
|
||||
|
||||
// parseAttributes parses provided Netlink Attributes and populates DevlinkParam, returns error if occured
|
||||
func (dlp *DevlinkParam) parseAttributes(attrs []syscall.NetlinkRouteAttr) error {
|
||||
var valuesList [][]syscall.NetlinkRouteAttr
|
||||
@@ -858,7 +736,7 @@ func (h *Handle) DevlinkSplitPort(port *DevlinkPort, count uint32) error {
|
||||
}
|
||||
|
||||
func DevlinkSplitPort(port *DevlinkPort, count uint32) error {
|
||||
return pkgHandle.DevlinkSplitPort(port, count);
|
||||
return pkgHandle.DevlinkSplitPort(port, count)
|
||||
}
|
||||
|
||||
// DevlinkUnsplitPort: unsplit devlink port
|
||||
@@ -876,7 +754,7 @@ func (h *Handle) DevlinkUnsplitPort(port *DevlinkPort) error {
|
||||
}
|
||||
|
||||
func DevlinkUnsplitPort(port *DevlinkPort) error {
|
||||
return pkgHandle.DevlinkUnsplitPort(port);
|
||||
return pkgHandle.DevlinkUnsplitPort(port)
|
||||
}
|
||||
|
||||
// DevlinkSetDeviceParam set specific parameter for devlink device
|
||||
|
||||
Reference in New Issue
Block a user