Documentation
¶
Index ¶
- Constants
- type ConfigSpace
- type ConfigSpaceIO
- type Interface
- type MemoryResource
- type MemoryResources
- type MockNvpci
- func (m *MockNvpci) AddMockA100(address string, numaNode int, sriov *SriovInfo) error
- func (m *MockNvpci) Cleanup()
- func (p MockNvpci) Get3DControllers() ([]*NvidiaPCIDevice, error)
- func (p MockNvpci) GetAllDevices() ([]*NvidiaPCIDevice, error)
- func (p MockNvpci) GetDPUs() ([]*NvidiaPCIDevice, error)
- func (p MockNvpci) GetGPUByIndex(i int) (*NvidiaPCIDevice, error)
- func (p MockNvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error)
- func (p MockNvpci) GetGPUs() ([]*NvidiaPCIDevice, error)
- func (p MockNvpci) GetNVSwitches() ([]*NvidiaPCIDevice, error)
- func (p MockNvpci) GetNetworkControllers() ([]*NvidiaPCIDevice, error)
- func (p MockNvpci) GetPciBridges() ([]*NvidiaPCIDevice, error)
- func (p MockNvpci) GetVGAControllers() ([]*NvidiaPCIDevice, error)
- type NvidiaPCIDevice
- func (d *NvidiaPCIDevice) Is3DController() bool
- func (d *NvidiaPCIDevice) IsDPU() bool
- func (d *NvidiaPCIDevice) IsGPU() bool
- func (d *NvidiaPCIDevice) IsNVSwitch() bool
- func (d *NvidiaPCIDevice) IsNetworkController() bool
- func (d *NvidiaPCIDevice) IsPciBridge() bool
- func (d *NvidiaPCIDevice) IsResetAvailable() bool
- func (d *NvidiaPCIDevice) IsVGAController() bool
- func (d *NvidiaPCIDevice) Reset() error
- type Option
- type PCICapabilities
- type PCIExtendedCapability
- type PCIStandardCapability
- type ResourceInterface
- type SriovInfo
- type SriovPhysicalFunction
- type SriovVirtualFunction
Constants ¶
const ( // PCICfgSpaceStandardSize represents the size in bytes of the standard config space. PCICfgSpaceStandardSize = 256 // PCICfgSpaceExtendedSize represents the size in bytes of the extended config space. PCICfgSpaceExtendedSize = 4096 // PCICapabilityListPointer represents offset for the capability list pointer. PCICapabilityListPointer = 0x34 // PCIStatusCapabilityList represents the status register bit which indicates capability list support. PCIStatusCapabilityList = 0x10 // PCIStatusBytePosition represents the position of the status register. PCIStatusBytePosition = 0x06 )
const ( // PCIMellanoxVendorID represents PCI vendor id for Mellanox. PCIMellanoxVendorID uint16 = 0x15b3 // PCINetworkControllerClass represents the PCI class for network controllers. PCINetworkControllerClass uint32 = 0x020000 // PCIBridgeClass represents the PCI class for network controllers. PCIBridgeClass uint32 = 0x060400 )
const ( // PCIDevicesRoot represents base path for all pci devices under sysfs. PCIDevicesRoot = "/sys/bus/pci/devices" // PCINvidiaVendorID represents PCI vendor id for NVIDIA. PCINvidiaVendorID uint16 = 0x10de // PCIVgaControllerClass represents the PCI class for VGA Controllers. PCIVgaControllerClass uint32 = 0x030000 // PCI3dControllerClass represents the PCI class for 3D Graphics accellerators. PCI3dControllerClass uint32 = 0x030200 // PCINvSwitchClass represents the PCI class for NVSwitches. PCINvSwitchClass uint32 = 0x068000 // UnknownDeviceString is the device name to set for devices not found in the PCI database. UnknownDeviceString = "UNKNOWN_DEVICE" // UnknownClassString is the class name to set for devices not found in the PCI database. UnknownClassString = "UNKNOWN_CLASS" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigSpace ¶
type ConfigSpace struct {
Path string
}
ConfigSpace PCI configuration space (standard extended) file path.
func (*ConfigSpace) Read ¶
func (cs *ConfigSpace) Read() (ConfigSpaceIO, error)
type ConfigSpaceIO ¶
type ConfigSpaceIO interface { bytes.Bytes GetVendorID() uint16 GetDeviceID() uint16 GetPCICapabilities() (*PCICapabilities, error) }
ConfigSpaceIO Interface for reading and writing raw and preconfigured values.
type Interface ¶
type Interface interface { GetAllDevices() ([]*NvidiaPCIDevice, error) Get3DControllers() ([]*NvidiaPCIDevice, error) GetVGAControllers() ([]*NvidiaPCIDevice, error) GetNVSwitches() ([]*NvidiaPCIDevice, error) GetGPUs() ([]*NvidiaPCIDevice, error) GetGPUByIndex(int) (*NvidiaPCIDevice, error) GetGPUByPciBusID(string) (*NvidiaPCIDevice, error) GetNetworkControllers() ([]*NvidiaPCIDevice, error) GetPciBridges() ([]*NvidiaPCIDevice, error) GetDPUs() ([]*NvidiaPCIDevice, error) }
Interface allows us to get a list of all NVIDIA PCI devices.
type MemoryResource ¶
MemoryResource represents a mmio region.
type MemoryResources ¶
type MemoryResources map[int]*MemoryResource
MemoryResources a more human readable handle.
func (MemoryResources) GetTotalAddressableMemory ¶
func (mrs MemoryResources) GetTotalAddressableMemory(roundUp bool) (uint64, uint64)
GetTotalAddressableMemory will accumulate the 32bit and 64bit memory windows of each BAR and round the value if needed to the next power of 2; first return value is the accumulated 32bit addressable memory size the second one is the accumulated 64bit addressable memory size in bytes. These values are needed to configure virtualized environments.
type MockNvpci ¶
type MockNvpci struct {
// contains filtered or unexported fields
}
MockNvpci mock pci device.
func NewMockNvpci ¶
NewMockNvpci create new mock PCI and remove old devices.
func (*MockNvpci) AddMockA100 ¶
AddMockA100 Create an A100 like GPU mock device.
func (*MockNvpci) Cleanup ¶
func (m *MockNvpci) Cleanup()
Cleanup remove the mocked PCI devices root folder.
func (MockNvpci) Get3DControllers ¶
func (p MockNvpci) Get3DControllers() ([]*NvidiaPCIDevice, error)
Get3DControllers returns all NVIDIA 3D Controller PCI devices on the system.
func (MockNvpci) GetAllDevices ¶
func (p MockNvpci) GetAllDevices() ([]*NvidiaPCIDevice, error)
GetAllDevices returns all Nvidia PCI devices on the system.
func (MockNvpci) GetDPUs ¶
func (p MockNvpci) GetDPUs() ([]*NvidiaPCIDevice, error)
GetDPUs returns all Mellanox DPU devices on the system.
func (MockNvpci) GetGPUByIndex ¶
func (p MockNvpci) GetGPUByIndex(i int) (*NvidiaPCIDevice, error)
GetGPUByIndex returns an NVIDIA GPU device at a particular index.
func (MockNvpci) GetGPUByPciBusID ¶
func (p MockNvpci) GetGPUByPciBusID(address string) (*NvidiaPCIDevice, error)
GetGPUByPciBusID constructs an NvidiaPCIDevice for the specified address (PCI Bus ID).
func (MockNvpci) GetGPUs ¶
func (p MockNvpci) GetGPUs() ([]*NvidiaPCIDevice, error)
GetGPUs returns all NVIDIA GPU devices on the system.
func (MockNvpci) GetNVSwitches ¶
func (p MockNvpci) GetNVSwitches() ([]*NvidiaPCIDevice, error)
GetNVSwitches returns all NVIDIA NVSwitch PCI devices on the system.
func (MockNvpci) GetNetworkControllers ¶
func (p MockNvpci) GetNetworkControllers() ([]*NvidiaPCIDevice, error)
GetNetworkControllers returns all Mellanox Network Controller PCI devices on the system.
func (MockNvpci) GetPciBridges ¶
func (p MockNvpci) GetPciBridges() ([]*NvidiaPCIDevice, error)
GetPciBridges retrieves all Mellanox PCI(e) Bridges.
func (MockNvpci) GetVGAControllers ¶
func (p MockNvpci) GetVGAControllers() ([]*NvidiaPCIDevice, error)
GetVGAControllers returns all NVIDIA VGA Controller PCI devices on the system.
type NvidiaPCIDevice ¶
type NvidiaPCIDevice struct { Path string Address string Vendor uint16 Class uint32 ClassName string Device uint16 DeviceName string Driver string IommuGroup int NumaNode int Config *ConfigSpace Resources MemoryResources SriovInfo SriovInfo }
NvidiaPCIDevice represents a PCI device for an NVIDIA product.
func (*NvidiaPCIDevice) Is3DController ¶
func (d *NvidiaPCIDevice) Is3DController() bool
Is3DController if class == 0x302.
func (*NvidiaPCIDevice) IsDPU ¶
func (d *NvidiaPCIDevice) IsDPU() bool
IsDPU returns if a device is a DPU.
func (*NvidiaPCIDevice) IsGPU ¶
func (d *NvidiaPCIDevice) IsGPU() bool
IsGPU either VGA for older cards or 3D for newer.
func (*NvidiaPCIDevice) IsNVSwitch ¶
func (d *NvidiaPCIDevice) IsNVSwitch() bool
IsNVSwitch if class == 0x068.
func (*NvidiaPCIDevice) IsNetworkController ¶
func (d *NvidiaPCIDevice) IsNetworkController() bool
IsNetworkController if class == 0x300.
func (*NvidiaPCIDevice) IsPciBridge ¶
func (d *NvidiaPCIDevice) IsPciBridge() bool
IsPciBridge if class == 0x0604.
func (*NvidiaPCIDevice) IsResetAvailable ¶
func (d *NvidiaPCIDevice) IsResetAvailable() bool
IsResetAvailable some devices can be reset without rebooting, check if applicable.
func (*NvidiaPCIDevice) IsVGAController ¶
func (d *NvidiaPCIDevice) IsVGAController() bool
IsVGAController if class == 0x300.
func (*NvidiaPCIDevice) Reset ¶
func (d *NvidiaPCIDevice) Reset() error
Reset perform a reset to apply a new configuration at HW level.
type Option ¶
type Option func(*nvpci)
Option defines a function for passing options to the New() call.
func WithLogger ¶
func WithLogger(logger logger) Option
WithLogger provides an Option to set the logger for the library.
func WithPCIDatabasePath ¶
WithPCIDatabasePath provides an Option to set the path to the pciids database file.
func WithPCIDevicesRoot ¶
WithPCIDevicesRoot provides an Option to set the root path for PCI devices on the system.
type PCICapabilities ¶
type PCICapabilities struct { Standard map[uint8]*PCIStandardCapability Extended map[uint16]*PCIExtendedCapability }
PCICapabilities combines the standard and extended config space.
type PCIExtendedCapability ¶
PCIExtendedCapability extended PCI config space.
type PCIStandardCapability ¶
PCIStandardCapability standard PCI config space.
type ResourceInterface ¶
ResourceInterface exposes some higher level functions of resources.
type SriovInfo ¶ added in v0.6.0
type SriovInfo struct { PhysicalFunction *SriovPhysicalFunction VirtualFunction *SriovVirtualFunction }
SriovInfo indicates whether device is VF/PF for SRIOV capable devices. Only one should be set at any given time.
type SriovPhysicalFunction ¶ added in v0.6.0
SriovPhysicalFunction stores info about SRIOV physical function.
type SriovVirtualFunction ¶ added in v0.6.0
type SriovVirtualFunction struct {
PhysicalFunction *NvidiaPCIDevice
}
SriovVirtualFunction keeps data about SRIOV virtual function.