devices

package
v0.9.3-0...-e3c37e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2019 License: BSD-3-Clause Imports: 9 Imported by: 0

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

View Source
const (
	DriverHvNetvcs      = "hv_netvcs"
	DriverUioPciGeneric = "uio_pci_generic"
	DriverIgbUio        = "igb_uio"
	DriverVfioPci       = "vfio-pci"
	DriverUioHvGeneric  = "uio_hv_generic"
)

Driver names

View Source
const (
	PathSysPciDevices     = "/sys/bus/pci/devices"
	PathSysPciDrivers     = "/sys/bus/pci/drivers"
	PathSysPciDriverProbe = "/sys/bus/pci/drivers_probe"
)

Path to PCI

View Source
const (
	PathSysVmbusDevices = "/sys/bus/vmbus/devices"
	PathSysVmbusDrivers = "/sys/bus/vmbus/drivers"
)

Path to VMBus

View Source
const (
	PathSysClassNet = "/sys/class/net"
)

Path to net

Variables

View Source
var (
	IsPciID *regexp.Regexp
	IsUUID  *regexp.Regexp
)

Regular expressions for PCI-ID and UUID

View Source
var (
	DefaultDpdkDriver = DriverUioPciGeneric
	DpdkDrivers       = [...]string{DriverUioPciGeneric, DriverIgbUio, DriverVfioPci, DriverUioHvGeneric}
	DpdkPciDrivers    = [...]string{DriverUioPciGeneric, DriverIgbUio, DriverVfioPci}
	DpdkVmbusDrivers  = [...]string{DriverUioHvGeneric}
)

DPDK related drivers

View Source
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 BindPci

func BindPci(devID, driver, vendor, device string) (string, error)

BindPci binds the driver to the given device ID

func FindDefaultDpdkDriver

func FindDefaultDpdkDriver(nicName string) string

FindDefaultDpdkDriver returns a default DPDK driver that the given NIC can use.

func GetCurrentPciDriver

func GetCurrentPciDriver(devID string) (string, error)

GetCurrentPciDriver returns the current driver that device bound to.

func GetCurrentVmbusDriver

func GetCurrentVmbusDriver(uuid string) (string, error)

GetCurrentVmbusDriver update the current driver device bound to.

func GetDeviceID

func GetDeviceID(nicName string) (string, error)

GetDeviceID returns the device ID of given NIC name.

func IsModuleLoaded

func IsModuleLoaded(driver string) bool

IsModuleLoaded checks if the kernel has already loaded the driver or not.

func ProbePci

func ProbePci(devID string) (string, error)

func UnbindPci

func UnbindPci(devID, driver string) error

UnbindPci unbinds the driver that is bound to the given device ID

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

func GetPciDeviceByPciID(pciID string) (Device, error)

GetPciDeviceByPciID gets device info by PCI bus id.

func GetVmbusDeviceByUUID

func GetVmbusDeviceByUUID(uuid string) (Device, error)

GetVmbusDeviceByUUID returns a VMBus device by given UUID.

func New

func New(input string) (Device, error)

New returns a corresponding device by given input

func NewDeviceByNicName

func NewDeviceByNicName(nicName string) (Device, error)

NewDeviceByNicName returns a device by given NIC name, e.g. eth0.

func NewDeviceByPciID

func NewDeviceByPciID(pciID string) (Device, error)

NewDeviceByPciID returns a PCI device by given PCI ID

func NewDeviceByVmbusID

func NewDeviceByVmbusID(uuid string) (Device, error)

NewDeviceByVmbusID returns a VMBus device by given UUID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL