Documentation
¶
Index ¶
- Constants
- func DevLinkPortDel(Socket string, Bus string, Device string, PortIndex uint32) error
- func DevLinkSetEswitchMode(Socket string, Dev *DevlinkDevice, NewMode string) error
- func DevlinkPortFnSet(Socket string, Bus string, Device string, PortIndex uint32, ...) error
- func GetSocketTimeout() time.Duration
- func SetSocketTimeout(to time.Duration) error
- type DevLinkPortAddAttrs
- type DevlinkDevAttrs
- type DevlinkDevEswitchAttr
- type DevlinkDevice
- type DevlinkPort
- type DevlinkPortFn
- type DevlinkPortFnSetAttrs
- type GenlFamily
- type GenlMulticastGroup
- type GenlOp
- type Handle
- func (h *Handle) Delete()
- func (h *Handle) DevLinkGetAllPortList(Socket string) ([]*DevlinkPort, error)
- func (h *Handle) DevLinkGetDeviceByName(Socket string, Bus string, Device string) (*DevlinkDevice, error)
- func (h *Handle) DevLinkGetDeviceList(Socket string) ([]*DevlinkDevice, error)
- func (h *Handle) DevLinkGetPortByIndex(Socket string, Bus string, Device string, PortIndex uint32) (*DevlinkPort, error)
- func (h *Handle) DevLinkPortAdd(Socket string, Bus string, Device string, Flavour uint16, ...) (*DevlinkPort, error)
- func (h *Handle) DevLinkPortDel(Socket string, Bus string, Device string, PortIndex uint32) error
- func (h *Handle) DevLinkSetEswitchMode(Socket string, Dev *DevlinkDevice, NewMode string) error
- func (h *Handle) DevlinkPortFnSet(Socket string, Bus string, Device string, PortIndex uint32, ...) error
- func (h *Handle) GenlFamilyGet(name string) (*GenlFamily, error)
- func (h *Handle) GenlFamilyList() ([]*GenlFamily, error)
- func (h *Handle) GetSocketReceiveBufferSize() ([]int, error)
- func (h *Handle) SetSocketReceiveBufferSize(size int, force bool) error
- func (h *Handle) SetSocketTimeout(to time.Duration) error
- func (h *Handle) SupportsNetlinkFamily(nlFamily int) bool
Constants ¶
const ( GENL_DEVLINK_VERSION = 1 GENL_DEVLINK_NAME = "devlink" GENL_MLXDEVM_NAME = "mlxdevm" )
const ( DEVLINK_CMD_GET = 1 DEVLINK_CMD_PORT_GET = 5 DEVLINK_CMD_PORT_SET = 6 DEVLINK_CMD_PORT_NEW = 7 DEVLINK_CMD_PORT_DEL = 8 DEVLINK_CMD_ESWITCH_GET = 29 DEVLINK_CMD_ESWITCH_SET = 30 )
const ( DEVLINK_ATTR_BUS_NAME = 1 DEVLINK_ATTR_DEV_NAME = 2 DEVLINK_ATTR_PORT_INDEX = 3 DEVLINK_ATTR_PORT_TYPE = 4 DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 6 DEVLINK_ATTR_PORT_NETDEV_NAME = 7 DEVLINK_ATTR_PORT_IBDEV_NAME = 8 DEVLINK_ATTR_ESWITCH_MODE = 25 DEVLINK_ATTR_ESWITCH_INLINE_MODE = 26 DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 62 DEVLINK_ATTR_PORT_FLAVOUR = 77 DEVLINK_ATTR_PORT_PCI_PF_NUMBER = 127 DEVLINK_ATTR_PORT_FUNCTION = 145 DEVLINK_ATTR_PORT_CONTROLLER_NUMBER = 150 DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 164 )
const ( DEVLINK_ESWITCH_MODE_LEGACY = 0 DEVLINK_ESWITCH_MODE_SWITCHDEV = 1 )
const ( DEVLINK_ESWITCH_INLINE_MODE_NONE = 0 DEVLINK_ESWITCH_INLINE_MODE_LINK = 1 DEVLINK_ESWITCH_INLINE_MODE_NETWORK = 2 DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT = 3 )
const ( DEVLINK_ESWITCH_ENCAP_MODE_NONE = 0 DEVLINK_ESWITCH_ENCAP_MODE_BASIC = 1 )
const ( DEVLINK_PORT_FLAVOUR_PHYSICAL = 0 DEVLINK_PORT_FLAVOUR_CPU = 1 DEVLINK_PORT_FLAVOUR_DSA = 2 DEVLINK_PORT_FLAVOUR_PCI_PF = 3 DEVLINK_PORT_FLAVOUR_PCI_VF = 4 DEVLINK_PORT_FLAVOUR_VIRTUAL = 5 DEVLINK_PORT_FLAVOUR_UNUSED = 6 DEVLINK_PORT_FLAVOUR_PCI_SF = 7 )
const ( DEVLINK_PORT_TYPE_NOTSET = 0 DEVLINK_PORT_TYPE_AUTO = 1 DEVLINK_PORT_TYPE_ETH = 2 DEVLINK_PORT_TYPE_IB = 3 )
const ( DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR = 1 DEVLINK_PORT_FN_ATTR_STATE = 2 DEVLINK_PORT_FN_ATTR_OPSTATE = 3 )
const ( DEVLINK_PORT_FN_STATE_INACTIVE = 0 DEVLINK_PORT_FN_STATE_ACTIVE = 1 )
const ( DEVLINK_PORT_FN_OPSTATE_DETACHED = 0 DEVLINK_PORT_FN_OPSTATE_ATTACHED = 1 )
Variables ¶
This section is empty.
Functions ¶
func DevLinkPortDel ¶
DevLinkPortDel deletes a devlink port and returns success or error code.
func DevLinkSetEswitchMode ¶
func DevLinkSetEswitchMode(Socket string, Dev *DevlinkDevice, NewMode string) error
DevLinkSetEswitchMode sets eswitch mode if able to set successfully or returns an error code. Equivalent to: `devlink dev eswitch set $dev mode switchdev` Equivalent to: `devlink dev eswitch set $dev mode legacy`
func DevlinkPortFnSet ¶
func DevlinkPortFnSet(Socket string, Bus string, Device string, PortIndex uint32, FnAttrs DevlinkPortFnSetAttrs) error
DevlinkPortFnSet sets one or more port function attributes specified by the attribute mask. It returns 0 on success or error code.
func GetSocketTimeout ¶
GetSocketTimeout returns the timeout value used by default netlink sockets
func SetSocketTimeout ¶
SetSocketTimeout configures timeout for default netlink sockets
Types ¶
type DevLinkPortAddAttrs ¶
type DevlinkDevAttrs ¶
type DevlinkDevAttrs struct {
Eswitch DevlinkDevEswitchAttr
}
DevlinkDevAttrs represents device attributes
type DevlinkDevEswitchAttr ¶
DevlinkDevEswitchAttr represents device's eswitch attributes
type DevlinkDevice ¶
type DevlinkDevice struct {
BusName string
DeviceName string
Attrs DevlinkDevAttrs
}
DevlinkDevice represents device and its attributes
func DevLinkGetDeviceByName ¶
func DevLinkGetDeviceByName(Socket string, Bus string, Device string) (*DevlinkDevice, error)
DevlinkGetDeviceByName provides a pointer to devlink device and nil error, otherwise returns an error code. Take Socket as either GENL_DEVLINK_NAME or as GENL_MLXDEVM_NAME.
func DevLinkGetDeviceList ¶
func DevLinkGetDeviceList(Socket string) ([]*DevlinkDevice, error)
DevLinkGetDeviceList provides a pointer to devlink devices and nil error, otherwise returns an error code.
type DevlinkPort ¶
type DevlinkPort struct {
BusName string
DeviceName string
PortIndex uint32
PortType uint16
NetdeviceName string
NetdevIfIndex uint32
RdmaDeviceName string
PortFlavour uint16
Fn *DevlinkPortFn
}
DevlinkPort represents port and its attributes
func DevLinkGetAllPortList ¶
func DevLinkGetAllPortList(Socket string) ([]*DevlinkPort, error)
DevLinkGetPortList provides a pointer to devlink ports and nil error, otherwise returns an error code.
func DevLinkGetPortByIndex ¶
func DevLinkGetPortByIndex(Socket string, Bus string, Device string, PortIndex uint32) (*DevlinkPort, error)
DevLinkGetPortByIndex provides a pointer to devlink portand nil error, otherwise returns an error code.
func DevLinkPortAdd ¶
func DevLinkPortAdd(Socket string, Bus string, Device string, Flavour uint16, Attrs DevLinkPortAddAttrs) (*DevlinkPort, error)
DevLinkPortAdd adds a devlink port and returns a port on success otherwise returns nil port and an error code.
type DevlinkPortFn ¶
type DevlinkPortFn struct {
HwAddr net.HardwareAddr
State uint8
OpState uint8
}
DevlinkPortFn represents port function and its attributes
type DevlinkPortFnSetAttrs ¶
type DevlinkPortFnSetAttrs struct {
FnAttrs DevlinkPortFn
HwAddrValid bool
StateValid bool
}
DevlinkPortFnSetAttrs represents attributes to set
type GenlFamily ¶
type GenlFamily struct {
ID uint16
HdrSize uint32
Name string
Version uint32
MaxAttr uint32
Ops []GenlOp
Groups []GenlMulticastGroup
}
func GenlFamilyGet ¶
func GenlFamilyGet(name string) (*GenlFamily, error)
func GenlFamilyList ¶
func GenlFamilyList() ([]*GenlFamily, error)
type GenlMulticastGroup ¶
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle is an handle for the netlink requests on a specific network namespace. All the requests on the same netlink family share the same netlink socket, which gets released when the handle is deleted.
func NewHandle ¶
NewHandle returns a netlink handle on the current network namespace. Caller may specify the netlink families the handle should support. If no families are specified, all the families the netlink package supports will be automatically added.
func NewHandleAt ¶
NewHandleAt returns a netlink handle on the network namespace specified by ns. If ns=netns.None(), current network namespace will be assumed
func NewHandleAtFrom ¶
NewHandleAtFrom works as NewHandle but allows client to specify the new and the origin netns Handle.
func (*Handle) Delete ¶
func (h *Handle) Delete()
Delete releases the resources allocated to this handle
func (*Handle) DevLinkGetAllPortList ¶
func (h *Handle) DevLinkGetAllPortList(Socket string) ([]*DevlinkPort, error)
DevLinkGetPortList provides a pointer to devlink ports and nil error, otherwise returns an error code.
func (*Handle) DevLinkGetDeviceByName ¶
func (h *Handle) DevLinkGetDeviceByName(Socket string, Bus string, Device string) (*DevlinkDevice, error)
DevlinkGetDeviceByName provides a pointer to devlink device and nil error, otherwise returns an error code. Take Socket as either GENL_DEVLINK_NAME or as GENL_MLXDEVM_NAME.
func (*Handle) DevLinkGetDeviceList ¶
func (h *Handle) DevLinkGetDeviceList(Socket string) ([]*DevlinkDevice, error)
DevLinkGetDeviceList provides a pointer to devlink devices and nil error, otherwise returns an error code.
func (*Handle) DevLinkGetPortByIndex ¶
func (h *Handle) DevLinkGetPortByIndex(Socket string, Bus string, Device string, PortIndex uint32) (*DevlinkPort, error)
DevLinkGetPortByIndexprovides a pointer to devlink device and nil error, otherwise returns an error code.
func (*Handle) DevLinkPortAdd ¶
func (h *Handle) DevLinkPortAdd(Socket string, Bus string, Device string, Flavour uint16, Attrs DevLinkPortAddAttrs) (*DevlinkPort, error)
DevLinkPortAdd adds a devlink port and returns a port on success otherwise returns nil port and an error code.
func (*Handle) DevLinkPortDel ¶
DevLinkPortDel deletes a devlink port and returns success or error code.
func (*Handle) DevLinkSetEswitchMode ¶
func (h *Handle) DevLinkSetEswitchMode(Socket string, Dev *DevlinkDevice, NewMode string) error
DevLinkSetEswitchMode sets eswitch mode if able to set successfully or returns an error code. Equivalent to: `devlink dev eswitch set $dev mode switchdev` Equivalent to: `devlink dev eswitch set $dev mode legacy`
func (*Handle) DevlinkPortFnSet ¶
func (h *Handle) DevlinkPortFnSet(Socket string, Bus string, Device string, PortIndex uint32, FnAttrs DevlinkPortFnSetAttrs) error
DevlinkPortFnSet sets one or more port function attributes specified by the attribute mask. It returns 0 on success or error code.
func (*Handle) GenlFamilyGet ¶
func (h *Handle) GenlFamilyGet(name string) (*GenlFamily, error)
func (*Handle) GenlFamilyList ¶
func (h *Handle) GenlFamilyList() ([]*GenlFamily, error)
func (*Handle) GetSocketReceiveBufferSize ¶
GetSocketReceiveBufferSize gets the receiver buffer size for each socket in the netlink handle. The retrieved value should be the double to the one set for SetSocketReceiveBufferSize.
func (*Handle) SetSocketReceiveBufferSize ¶
SetSocketReceiveBufferSize sets the receive buffer size for each socket in the netlink handle. The maximum value is capped by /proc/sys/net/core/rmem_max.
func (*Handle) SetSocketTimeout ¶
SetSocketTimeout sets the send and receive timeout for each socket in the netlink handle. Although the socket timeout has granularity of one microsecond, the effective granularity is floored by the kernel timer tick, which default value is four milliseconds.
func (*Handle) SupportsNetlinkFamily ¶
SupportsNetlinkFamily reports whether the passed netlink family is supported by this Handle