Documentation
¶
Overview ¶
Package devices helps to query DPDK compatibles devices and to bind/unbind drivers
Package devices helps to query DPDK compatibles devices and to bind/unbind drivers
Package devices helps to query DPDK compatibles devices and to bind/unbind drivers
Package devices helps to query DPDK compatibles devices and to bind/unbind drivers
Package devices helps to query DPDK compatibles devices and to bind/unbind drivers
Package devices helps to query DPDK compatibles devices and to bind/unbind drivers
Index ¶
- Constants
- Variables
- func BindPci(devID, driver, vendor, device string) (string, error)
- func FindDefaultDpdkDriver(nicName string) string
- func GetCurrentPciDriver(devID string) (string, error)
- func GetCurrentVmbusDriver(uuid string) (string, error)
- func GetDeviceID(nicName string) (string, error)
- func IsModuleLoaded(driver string) bool
- func ProbePci(devID string) (string, error)
- func UnbindPci(devID, driver string) error
- type Device
- func GetPciDeviceByPciID(pciID string) (Device, error)
- func GetVmbusDeviceByUUID(uuid string) (Device, error)
- func New(input string) (Device, error)
- func NewDeviceByNicName(nicName string) (Device, error)
- func NewDeviceByPciID(pciID string) (Device, error)
- func NewDeviceByVmbusID(uuid string) (Device, error)
Constants ¶
const ( DriverHvNetvcs = "hv_netvcs" DriverUioPciGeneric = "uio_pci_generic" DriverIgUio = "ig_uio" DriverVfioPci = "vfio-pci" DriverUioHvGeneric = "uio_hv_generic" )
Driver names
const ( PathSysPciDevices = "/sys/bus/pci/devices" PathSysPciDrivers = "/sys/bus/pci/drivers" PathSysPciDriverProbe = "/sys/bus/pci/drivers_probe" )
Path to PCI
const ( PathSysVmbusDevices = "/sys/bus/vmbus/devices" PathSysVmbusDrivers = "/sys/bus/vmbus/drivers" )
Path to VMBus
const (
PathSysClassNet = "/sys/class/net"
)
Path to net
Variables ¶
var ( IsPciID *regexp.Regexp IsUUID *regexp.Regexp )
Regular expressions for PCI-ID and UUID
var ( DefaultDpdkDriver = DriverUioPciGeneric DpdkDrivers = [...]string{DriverUioPciGeneric, DriverIgUio, DriverVfioPci, DriverUioHvGeneric} DpdkPciDrivers = [...]string{DriverUioPciGeneric, DriverIgUio, DriverVfioPci} DpdkVmbusDrivers = [...]string{DriverUioHvGeneric} )
DPDK related drivers
var ( ErrNoBoundDriver = errors.New("no driver is bound to the device") ErrAlreadyBoundDriver = errors.New("device has already bound the selected driver") ErrBind = errors.New("fail to bind the driver") ErrUnbind = errors.New("fail to unbind the driver") ErrUnsupportedDriver = errors.New("unsupported DPDK driver") ErrNotProbe = errors.New("device doesn't support 'drive_probe'") ErrKernelModuleNotLoaded = errors.New("kernel module is not loaded") )
Errors of devices package
Functions ¶
func FindDefaultDpdkDriver ¶
FindDefaultDpdkDriver returns a default DPDK driver that the given NIC can use.
func GetCurrentPciDriver ¶
GetCurrentPciDriver returns the current driver that device bound to.
func GetCurrentVmbusDriver ¶
GetCurrentVmbusDriver update the current driver device bound to.
func GetDeviceID ¶
GetDeviceID returns the device ID of given NIC name.
func IsModuleLoaded ¶
IsModuleLoaded checks if the kernel has already loaded the driver or not.
Types ¶
type Device ¶
type Device interface { // Binds a driver to the device Bind(driver string) error // Unbinds the current driver from the device Unbind() error // Returns the name of the driver that is currently bound CurrentDriver() (string, error) // Probes the currently bound driver and checks if there is an error Probe() error // Returns the ID of the device ID() string }
Device is a DPDK compatible device and should be able to bind, unbind and probe.
func GetPciDeviceByPciID ¶
GetPciDeviceByPciID gets device info by PCI bus id.
func GetVmbusDeviceByUUID ¶
GetVmbusDeviceByUUID returns a VMBus device by given UUID.
func NewDeviceByNicName ¶
NewDeviceByNicName returns a device by given NIC name, e.g. eth0.
func NewDeviceByPciID ¶
NewDeviceByPciID returns a PCI device by given PCI ID
func NewDeviceByVmbusID ¶
NewDeviceByVmbusID returns a VMBus device by given UUID