vgpu

package
v0.7.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PciDevicesRoot represents base path for all pci devices under sysfs
	PciDevicesRoot = "/sys/bus/pci/devices"
	// PciStatusByte indicates status byte
	PciStatusByte = 0x06
	// PciStatusCapabilityList indicates if capability list is supported
	PciStatusCapabilityList = 0x10
	// PciCapabilityList indicates offset of first capability list entry
	PciCapabilityList = 0x34
	// PciCapabilityListID indicates offset for capability id
	PciCapabilityListID = 0
	// PciCapabilityListNext indicates offset for next capability in the list
	PciCapabilityListNext = 1
	// PciCapabilityLength indicates offset for capability length
	PciCapabilityLength = 2
	// PciCapabilityVendorSpecificID indicates PCI vendor specific capability id
	PciCapabilityVendorSpecificID = 0x09
	// PciNvidiaVendorID represents PCI vendor id for Nvidia
	PciNvidiaVendorID = "0x10de"
)
View Source
const (
	// VGPUCapabilityRecordStart indicates offset of beginning vGPU capability record
	VGPUCapabilityRecordStart = 5
	// HostDriverVersionLength indicates max length of driver version
	HostDriverVersionLength = 10
	// HostDriverBranchLength indicates max length of driver branch
	HostDriverBranchLength = 10
)

Variables

This section is empty.

Functions

func GetByte

func GetByte(buffer []byte, pos int) uint8

GetByte returns a single byte of data at specified position

func GetLong

func GetLong(buffer []byte, pos int) uint32

GetLong returns 4 bytes of data from specified position

func GetWord

func GetWord(buffer []byte, pos int) uint16

GetWord returns 2 bytes of data from specified position

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device is just an alias to a PCIDevice

func (*Device) GetInfo

func (d *Device) GetInfo() (*Info, error)

GetInfo returns information about vGPU manager running on the underlying hypervisor host

type Info

type Info struct {
	HostDriverVersion string
	HostDriverBranch  string
}

Info represents vGPU driver info running on underlying hypervisor host.

type Interface

type Interface interface {
	Devices() ([]*Device, error)
}

Interface allows us to get a list of vGPU specific PCI devices

func NewMockVGPU

func NewMockVGPU() Interface

NewMockVGPU initializes and returns mock Interface interface type

func NewVGPULib

func NewVGPULib(pci NvidiaPCI) Interface

NewVGPULib returns an instance of Lib implementing the VGPU interface

type Lib

type Lib struct {
	// contains filtered or unexported fields
}

Lib implements the NvidiaVGPU interface

func (*Lib) Devices

func (v *Lib) Devices() ([]*Device, error)

Devices returns all vGPU devices attached to the guest

func (*Lib) IsVGPUDevice

func (v *Lib) IsVGPUDevice(capability []byte) bool

IsVGPUDevice returns true if the device is of type vGPU

type MockNvidiaPCI

type MockNvidiaPCI struct {
	// contains filtered or unexported fields
}

MockNvidiaPCI represents mock of NvidiaPCI interface

func (*MockNvidiaPCI) Devices

func (p *MockNvidiaPCI) Devices() ([]*PCIDevice, error)

Devices returns PCI devices with mocked data

type NvidiaPCI

type NvidiaPCI interface {
	Devices() ([]*PCIDevice, error)
}

NvidiaPCI interface allows us to get a list of all NVIDIA PCI devices

func NewMockNvidiaPCI

func NewMockNvidiaPCI() NvidiaPCI

NewMockNvidiaPCI initializes and returns mock PCI interface type

func NewNvidiaPCILib

func NewNvidiaPCILib() NvidiaPCI

NewNvidiaPCILib returns an instance of NvidiaPCILib implementing the NvidiaPCI interface

type NvidiaPCILib

type NvidiaPCILib struct{}

NvidiaPCILib implements the NvidiaPCI interface

func (*NvidiaPCILib) Devices

func (p *NvidiaPCILib) Devices() ([]*PCIDevice, error)

Devices returns all PCI devices on the system

type PCIDevice

type PCIDevice struct {
	Path    string
	Address string
	Class   string
	Vendor  string
	Config  []byte
}

PCIDevice represents a single PCI device

func (*PCIDevice) GetVendorSpecificCapability

func (d *PCIDevice) GetVendorSpecificCapability() ([]byte, error)

GetVendorSpecificCapability returns the vendor specific capability from configuration space

Jump to

Keyboard shortcuts

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