Documentation ¶
Index ¶
- Constants
- func DevlinkDevParamSet(Socket string, Bus string, Device string, ParamName string, NewValue string, ...) error
- func DevlinkPortDel(Socket string, Bus string, Device string, PortIndex uint32) error
- func DevlinkPortFnCapSet(Socket string, Bus string, Device string, PortIndex uint32, ...) error
- func DevlinkPortFnSet(Socket string, Bus string, Device string, PortIndex uint32, ...) error
- func DevlinkSetEswitchMode(Socket string, Dev *DevlinkDevice, NewMode string) error
- func GetSocketTimeout() time.Duration
- func SetSocketTimeout(to time.Duration) error
- type DevlinkDevAttrs
- type DevlinkDevEswitchAttr
- type DevlinkDevParam
- type DevlinkDevice
- type DevlinkPort
- type DevlinkPortAddAttrs
- type DevlinkPortFn
- type DevlinkPortFnCap
- type DevlinkPortFnCapSetAttrs
- type DevlinkPortFnSetAttrs
- type GenlFamily
- type GenlMulticastGroup
- type GenlOp
- type Handle
- func (h *Handle) Delete()
- func (h *Handle) DevlinkDevParamGet(Socket string, Bus string, Device string, ParamName string) (*DevlinkDevParam, error)
- func (h *Handle) DevlinkDevParamSet(Socket string, Bus string, Device string, ParamName string, NewValue string, ...) error
- 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) DevlinkPortFnCapSet(Socket string, Bus string, Device string, PortIndex uint32, ...) error
- func (h *Handle) DevlinkPortFnSet(Socket string, Bus string, Device string, PortIndex uint32, ...) error
- func (h *Handle) DevlinkSetEswitchMode(Socket string, Dev *DevlinkDevice, NewMode string) 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 DEVLINK_CMD_PARAM_GET = 38 DEVLINK_CMD_PARAM_SET = 39 DEVLINK_CMD_EXT_CAP_SET = 161 )
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_PARAM = 80 /* nested */ DEVLINK_ATTR_PARAM_NAME = 81 /* string */ DEVLINK_ATTR_PARAM_GENERIC = 82 /* flag */ DEVLINK_ATTR_PARAM_TYPE = 83 /* u8 */ DEVLINK_ATTR_PARAM_VALUES_LIST = 84 /* nested */ DEVLINK_ATTR_PARAM_VALUE = 85 /* nested */ DEVLINK_ATTR_PARAM_VALUE_DATA = 86 /* dynamic */ DEVLINK_ATTR_PARAM_VALUE_CMODE = 87 /* u8 */ DEVLINK_ATTR_PORT_PCI_PF_NUMBER = 127 /* u16 */ DEVLINK_ATTR_PORT_FUNCTION = 145 /* nested */ DEVLINK_ATTR_PORT_CONTROLLER_NUMBER = 150 /* u32 */ DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 164 /* u32 */ DEVLINK_ATTR_EXT_PORT_FN_CAP = 8193 DEVLINK_ATTR_MAX = 8201 )
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 )
const ( DEVLINK_PORT_FN_ATTR_EXT_CAP_ROCE = 161 DEVLINK_PORT_FN_ATTR_EXT_CAP_UC_LIST = 162 )
const ( DEVLINK_PARAM_CMODE_RUNTIME = 0 DEVLINK_PARAM_CMODE_DRIVERINIT = 1 )
const ( MNL_TYPE_U8 = 1 MNL_TYPE_U16 = 2 MNL_TYPE_U32 = 3 MNL_TYPE_U64 = 4 MNL_TYPE_STRING = 5 MNL_TYPE_FLAG = 6 MNL_TYPE_MSECS = 7 MNL_TYPE_NESTED = 8 MNL_TYPE_NESTED_COMPAT = 9 MNL_TYPE_NUL_STRING = 10 MNL_TYPE_BINARY = 11 MNL_TYPE_MAX = 12 )
Variables ¶
This section is empty.
Functions ¶
func DevlinkDevParamSet ¶ added in v0.3.0
func DevlinkDevParamSet(Socket string, Bus string, Device string, ParamName string, NewValue string, NewCMode string) error
DevlinkDevParamSet sets one device parameter. It returns 0 on success or error code. Equivalent to: `mlxdevm dev param set $dev name disable_netdev value true cmode runtime`
func DevlinkPortDel ¶ added in v0.3.0
DevlinkPortDel deletes a devlink port and returns success or error code.
func DevlinkPortFnCapSet ¶ added in v0.3.0
func DevlinkPortFnCapSet(Socket string, Bus string, Device string, PortIndex uint32, FnCapAttrs DevlinkPortFnCapSetAttrs) error
DevlinkPortFnCapSet sets roce and max_uc_macs port function cap attributes. It returns 0 on success or error code. Equivalent to: `mlxdevm port function cap sep $port roce true max_uc_macs 64` Equivalent to: `mlxdevm port function cap sep $port roce false max_uc_macs 128`
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 DevlinkSetEswitchMode ¶ added in v0.3.0
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 GetSocketTimeout ¶
GetSocketTimeout returns the timeout value used by default netlink sockets
func SetSocketTimeout ¶
SetSocketTimeout configures timeout for default netlink sockets
Types ¶
type DevlinkDevAttrs ¶
type DevlinkDevAttrs struct {
Eswitch DevlinkDevEswitchAttr
}
DevlinkDevAttrs represents device attributes
type DevlinkDevEswitchAttr ¶
DevlinkDevEswitchAttr represents device's eswitch attributes
type DevlinkDevParam ¶ added in v0.3.0
DevlinkDevParam represents a device parameter
func DevlinkDevParamGet ¶ added in v0.3.0
func DevlinkDevParamGet(Socket string, Bus string, Device string, ParamName string) (*DevlinkDevParam, error)
DevlinkDevParamGet returns information about a set device parameter Equivalent to `mlxdevm dev param show $dev name disable_netdev`
type DevlinkDevice ¶
type DevlinkDevice struct { BusName string DeviceName string Attrs DevlinkDevAttrs }
DevlinkDevice represents device and its attributes
func DevlinkGetDeviceByName ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 Controller uint32 PfNumber uint16 SfNumber uint32 Fn *DevlinkPortFn PortCap *DevlinkPortFnCap }
DevlinkPort represents port and its attributes
func DevlinkGetAllPortList ¶ added in v0.3.0
func DevlinkGetAllPortList(Socket string) ([]*DevlinkPort, error)
DevlinkGetAllPortList provides a pointer to devlink ports and nil error, otherwise returns an error code.
func DevlinkGetPortByIndex ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 DevlinkPortAddAttrs ¶ added in v0.3.0
type DevlinkPortFn ¶
type DevlinkPortFn struct { HwAddr net.HardwareAddr State uint8 OpState uint8 }
DevlinkPortFn represents port function and its attributes
type DevlinkPortFnCap ¶ added in v0.3.0
DevlinkPortFnCap represents port function and its attributes
type DevlinkPortFnCapSetAttrs ¶ added in v0.3.0
type DevlinkPortFnCapSetAttrs struct { FnCapAttrs DevlinkPortFnCap RoceValid bool UCListValid bool }
DevlinkPortFnCapSetAttrs represents attributes to set
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) DevlinkDevParamGet ¶ added in v0.3.0
func (h *Handle) DevlinkDevParamGet(Socket string, Bus string, Device string, ParamName string) (*DevlinkDevParam, error)
DevlinkDevParamGet returns information about a set device parameter Equivalent to `mlxdevm dev param show $dev name disable_netdev`
func (*Handle) DevlinkDevParamSet ¶ added in v0.3.0
func (h *Handle) DevlinkDevParamSet(Socket string, Bus string, Device string, ParamName string, NewValue string, NewCMode string) error
DevlinkDevParamSet sets one device parameter. It returns 0 on success or error code. Equivalent to: `mlxdevm dev param set $dev name disable_netdev value true cmode runtime`
func (*Handle) DevlinkGetAllPortList ¶ added in v0.3.0
func (h *Handle) DevlinkGetAllPortList(Socket string) ([]*DevlinkPort, error)
DevlinkGetAllPortList provides a pointer to devlink ports and nil error, otherwise returns an error code.
func (*Handle) DevlinkGetDeviceByName ¶ added in v0.3.0
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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (h *Handle) DevlinkGetPortByIndex(Socket string, Bus string, Device string, PortIndex uint32) (*DevlinkPort, error)
DevlinkGetPortByIndex provides a pointer to devlink device and nil error, otherwise returns an error code.
func (*Handle) DevlinkPortAdd ¶ added in v0.3.0
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 ¶ added in v0.3.0
DevlinkPortDel deletes a devlink port and returns success or error code.
func (*Handle) DevlinkPortFnCapSet ¶ added in v0.3.0
func (h *Handle) DevlinkPortFnCapSet(Socket string, Bus string, Device string, PortIndex uint32, FnCapAttrs DevlinkPortFnCapSetAttrs) error
DevlinkPortFnCapSet sets roce and max_uc_macs port function cap attributes. It returns 0 on success or error code. Equivalent to: `mlxdevm port function cap sep $port roce true max_uc_macs 64` Equivalent to: `mlxdevm port function cap sep $port roce false max_uc_macs 128`
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) DevlinkSetEswitchMode ¶ added in v0.3.0
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) 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