hardware

package
v0.0.0-...-ebe7275 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: BSD-2-Clause-Patent Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PCIAddrBusBitSize defines the number of bits used to represent bus in address.
	PCIAddrBusBitSize = 8
)

Variables

View Source
var ErrNoNUMANodes = errors.New("no NUMA nodes detected")

ErrNoNUMANodes indicates that the system can't detect any NUMA nodes.

View Source
var ErrNotVMDBackingAddress = errors.New("not a vmd backing device address")

Functions

func ErrProviderNotOnDevice

func ErrProviderNotOnDevice(provider, dev string) error

ErrProviderNotOnDevice returns an error indicated that the fabric provider is not available on the given network device.

func ErrUnsupportedFabric

func ErrUnsupportedFabric(provider string) error

ErrUnsupportedFabric returns an error indicating that the denoted fabric provider is not supported by this build/platform.

func IsProviderNotOnDevice

func IsProviderNotOnDevice(err error) bool

IsProviderNotOnDevice indicates whether the error is an instance of errProviderNotOnDevice.

func IsUnsupportedFabric

func IsUnsupportedFabric(err error) bool

IsUnsupportedFabric returns true if the supplied error is an instance of errUnsupportedFabric.

func PrintTopology

func PrintTopology(t *Topology, output io.Writer) error

PrintTopology prints the topology to the given writer.

func WaitFabricReady

func WaitFabricReady(ctx context.Context, log logging.Logger, params WaitFabricReadyParams) error

WaitFabricReady loops until either all fabric interfaces are ready, or the context is canceled.

Types

type BlockDevice

type BlockDevice struct {
	Type          string     `json:"type"`
	Name          string     `json:"name"`
	SectorSize    uint64     `json:"sector_size,omitempty"`
	Size          uint64     `json:"size,omitempty"`
	LinuxDeviceID string     `json:"linux_device_id,omitempty"`
	Vendor        string     `json:"vendor,omitempty"`
	Model         string     `json:"model,omitempty"`
	Revision      string     `json:"revision,omitempty"`
	SerialNumber  string     `json:"serial_number,omitempty"`
	BackingDevice *PCIDevice `json:"backing_device,omitempty"`
}

BlockDevice represents a block device that may be backed by a PCI device (SSD, HDD, etc) or may not (NVDIMM).

func (*BlockDevice) DeviceName

func (d *BlockDevice) DeviceName() string

DeviceName is the name of the block device.

func (*BlockDevice) DeviceType

func (d *BlockDevice) DeviceType() DeviceType

DeviceType will always return DeviceTypeBlock.

func (*BlockDevice) PCIDevice

func (d *BlockDevice) PCIDevice() *PCIDevice

PCIDevice is PCI Device associated with the block device, if any.

func (*BlockDevice) String

func (d *BlockDevice) String() string

type CPUCore

type CPUCore struct {
	ID       uint      `json:"id"`
	NUMANode *NUMANode `json:"-"`
}

CPUCore represents a CPU core within a NUMA node.

type Device

type Device interface {
	DeviceName() string
	DeviceType() DeviceType
	PCIDevice() *PCIDevice
}

Device is the interface for a system device.

type DeviceType

type DeviceType uint

DeviceType indicates the type of a hardware device.

const (
	// DeviceTypeUnknown indicates a device type that is not recognized.
	DeviceTypeUnknown DeviceType = iota
	// DeviceTypeNetInterface indicates a standard network interface.
	DeviceTypeNetInterface
	// DeviceTypeOFIDomain indicates an OpenFabrics domain device.
	DeviceTypeOFIDomain
	// DeviceTypeBlock indicates a block device.
	DeviceTypeBlock
)

func (DeviceType) String

func (t DeviceType) String() string

type FabricInterface

type FabricInterface struct {
	// Name is the fabric device name.
	Name string `json:"name"`
	// OSName is the device name as reported by the operating system.
	OSName string `json:"os_name"`
	// NetInterface is the set of corresponding OS-level network interface device.
	NetInterfaces common.StringSet `json:"net_interface"`
	// Providers is the set of supported providers.
	Providers *FabricProviderSet `json:"providers"`
	// DeviceClass is the type of the network interface.
	DeviceClass NetDevClass `json:"device_class"`
	// NUMANode is the NUMA affinity of the network interface.
	NUMANode uint `json:"numa_node"`
}

FabricInterface represents basic information about a fabric interface.

func (*FabricInterface) String

func (fi *FabricInterface) String() string

func (*FabricInterface) SupportsProvider

func (fi *FabricInterface) SupportsProvider(provider string) bool

SupportsProvider reports whether the FabricInterface supports the given provider string. If the string contains multiple comma-separated providers, it verifies that all are supported.

func (*FabricInterface) TopologyName

func (fi *FabricInterface) TopologyName() (string, error)

type FabricInterfaceBuilder

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

FabricInterfaceBuilder is a builder that adds new FabricInterface objects to the FabricInterfaceSet.

func (*FabricInterfaceBuilder) BuildPart

BuildPart collects FabricInterfaces from its providers and adds them to the FabricInterfaceSet.

type FabricInterfaceProvider

type FabricInterfaceProvider interface {
	GetFabricInterfaces(ctx context.Context, provider string) (*FabricInterfaceSet, error)
}

FabricInterfaceProvider is an interface that returns a new set of fabric interfaces.

type FabricInterfaceSet

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

FabricInterfaceSet is a set of fabric interfaces.

func NewFabricInterfaceSet

func NewFabricInterfaceSet(fis ...*FabricInterface) *FabricInterfaceSet

NewFabricInterfaceSet creates a new fabric interface set and initializes it with the passed-in FabricInterfaces if provided.

func (*FabricInterfaceSet) GetInterface

func (s *FabricInterfaceSet) GetInterface(name string) (*FabricInterface, error)

GetInterface fetches a fabric interface by its fabric device name.

func (*FabricInterfaceSet) GetInterfaceOnNetDevice

func (s *FabricInterfaceSet) GetInterfaceOnNetDevice(netDev string, provider string) (*FabricInterface, error)

GetInterfaceOnNetDevice searches for an interface with a given OS network device name that supports a given provider.

func (*FabricInterfaceSet) Names

func (s *FabricInterfaceSet) Names() []string

Names provides a sorted list of the fabric interface names.

func (*FabricInterfaceSet) NetDevices

func (s *FabricInterfaceSet) NetDevices() []string

NetDevices provides a sorted list of the OS-level network devices.

func (*FabricInterfaceSet) NumFabricInterfaces

func (s *FabricInterfaceSet) NumFabricInterfaces() int

NumFabricInterfaces is the total number of FabricInterfaces in the set.

func (*FabricInterfaceSet) NumNetDevices

func (s *FabricInterfaceSet) NumNetDevices() int

NumNetDevices is the number of unique OS-level network devices in the set.

func (*FabricInterfaceSet) Remove

func (s *FabricInterfaceSet) Remove(fiName string)

Remove deletes a FabricInterface from the set.

func (*FabricInterfaceSet) String

func (s *FabricInterfaceSet) String() string

func (*FabricInterfaceSet) Update

func (s *FabricInterfaceSet) Update(fi *FabricInterface)

Update updates the details of the fabric interface if it's already in the set, or adds it to the set otherwise.

type FabricInterfaceSetBuilder

type FabricInterfaceSetBuilder interface {
	BuildPart(context.Context, *FabricInterfaceSet) error
}

FabricInterfaceSetBuilder is an interface used by builders that construct a set of fabric interfaces.

type FabricInterfaceSetBuilderConfig

type FabricInterfaceSetBuilderConfig struct {
	Topology                 *Topology
	Providers                []string
	FabricInterfaceProviders []FabricInterfaceProvider
	NetDevClassProvider      NetDevClassProvider
}

FabricInterfaceSetBuilderConfig contains the configuration used by FabricInterfaceSetBuilders.

type FabricProvider

type FabricProvider struct {
	Name     string
	Priority int
}

FabricProvider includes information about a fabric provider.

func (*FabricProvider) String

func (p *FabricProvider) String() string

type FabricProviderSet

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

FabricProviderSet is a non-duplicated set of FabricProviders.

func NewFabricProviderSet

func NewFabricProviderSet(providers ...*FabricProvider) *FabricProviderSet

NewFabricProviderSet creates a new set of FabricProviders.

func (*FabricProviderSet) Add

func (ps *FabricProviderSet) Add(providers ...*FabricProvider)

Add adds fabric providers to the set.

func (*FabricProviderSet) Has

func (ps *FabricProviderSet) Has(provider string) bool

Has detects whether a provider is in the set.

func (*FabricProviderSet) Len

func (ps *FabricProviderSet) Len() int

Len returns the number of providers in the set.

func (*FabricProviderSet) String

func (ps *FabricProviderSet) String() string

func (*FabricProviderSet) ToSlice

func (ps *FabricProviderSet) ToSlice() []*FabricProvider

ToSlice returns a list of FabricProviders sorted by priority.

type FabricScanner

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

FabricScanner is a type that scans the system for fabric interfaces.

func MockFabricScanner

func MockFabricScanner(log logging.Logger, cfg *MockFabricScannerConfig) *FabricScanner

MockFabricScanner generates a mock FabricScanner for testing.

func NewFabricScanner

func NewFabricScanner(log logging.Logger, config *FabricScannerConfig) (*FabricScanner, error)

NewFabricScanner creates a new FabricScanner with the given configuration.

func (*FabricScanner) CacheTopology

func (s *FabricScanner) CacheTopology(t *Topology) error

CacheTopology caches a specific HW topology for use with the fabric scan.

func (*FabricScanner) Scan

func (s *FabricScanner) Scan(ctx context.Context, providers ...string) (*FabricInterfaceSet, error)

Scan discovers fabric interfaces in the system.

type FabricScannerConfig

type FabricScannerConfig struct {
	TopologyProvider         TopologyProvider
	FabricInterfaceProviders []FabricInterfaceProvider
	NetDevClassProvider      NetDevClassProvider
}

FabricScannerConfig contains the parameters required to set up a FabricScanner.

func GetMockFabricScannerConfig

func GetMockFabricScannerConfig() *FabricScannerConfig

GetMockFabricScannerConfig gets a FabricScannerConfig for testing.

func (*FabricScannerConfig) Validate

func (c *FabricScannerConfig) Validate() error

Validate checks if the FabricScannerConfig is valid.

type IOMMUDetector

type IOMMUDetector interface {
	IsIOMMUEnabled() (bool, error)
}

IOMMUDetector is an interface for detecting if IOMMU is enabled on a system.

type MockFabricInterfaceProvider

type MockFabricInterfaceProvider struct {
	GetFabricReturn *FabricInterfaceSet
	GetFabricErr    error
}

MockFabricInterfaceProvider is a FabricInterfaceProvider for testing.

func (*MockFabricInterfaceProvider) GetFabricInterfaces

func (m *MockFabricInterfaceProvider) GetFabricInterfaces(_ context.Context, _ string) (*FabricInterfaceSet, error)

type MockFabricInterfaceSetBuilder

type MockFabricInterfaceSetBuilder struct {
	BuildPartCalled    int
	BuildPartUpdateFis func(*FabricInterfaceSet)
	BuildPartReturn    error
}

MockFabricInterfaceSetBuilder is a FabricInterfaceSetBuilder for testing.

func (*MockFabricInterfaceSetBuilder) BuildPart

type MockFabricScannerConfig

type MockFabricScannerConfig struct {
	ScanResult *FabricInterfaceSet
}

MockFabricScannerConfig provides parameters for constructing a mock fabric scanner.

type MockGetNetDevClassResult

type MockGetNetDevClassResult struct {
	ExpInput string
	NDC      NetDevClass
	Err      error
}

MockGetNetDevClassResult is used to set up a MockNetDevClassProvider's results for GetNetDevClass.

type MockNetDevClassProvider

type MockNetDevClassProvider struct {
	GetNetDevClassReturn []MockGetNetDevClassResult
	GetNetDevClassCalled int
	// contains filtered or unexported fields
}

MockNetDevClassProvider is a NetDevClassProvider for testing.

func (*MockNetDevClassProvider) GetNetDevClass

func (m *MockNetDevClassProvider) GetNetDevClass(in string) (NetDevClass, error)

type MockNetDevStateProvider

type MockNetDevStateProvider struct {
	sync.Mutex
	GetStateReturn []MockNetDevStateResult
	GetStateCalled []string
}

MockNetDevStateProvider is a fake NetDevStateProvider for testing.

func (*MockNetDevStateProvider) GetNetDevState

func (m *MockNetDevStateProvider) GetNetDevState(iface string) (NetDevState, error)

type MockNetDevStateResult

type MockNetDevStateResult struct {
	State NetDevState
	Err   error
}

MockNetDevStateResult is a structure for injecting results into MockNetDevStateProvider.

type MockTopologyProvider

type MockTopologyProvider struct {
	GetTopoReturn *Topology
	GetTopoErr    error
}

MockTopologyProvider is a TopologyProvider for testing.

func (*MockTopologyProvider) GetTopology

func (m *MockTopologyProvider) GetTopology(_ context.Context) (*Topology, error)

type NUMAAffinityBuilder

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

NUMAAffinityBuilder is a builder that updates FabricInterfaces with a NUMA node affinity.

func (*NUMAAffinityBuilder) BuildPart

BuildPart updates existing FabricInterface structures in the set to include a NUMA node affinity, if available.

type NUMANode

type NUMANode struct {
	ID           uint           `json:"id"`
	Cores        []CPUCore      `json:"cores"`
	PCIBuses     []*PCIBus      `json:"pci_buses"`
	PCIDevices   PCIDevices     `json:"pci_devices"`
	BlockDevices []*BlockDevice `json:"block_devices"`
}

NUMANode represents an individual NUMA node in the system and the devices associated with it.

func MockNUMANode

func MockNUMANode(id uint, numCores uint, optOff ...uint) *NUMANode

MockNUMANode returns a mock NUMA node for testing.

func (*NUMANode) AddBlockDevice

func (n *NUMANode) AddBlockDevice(device *BlockDevice) error

AddBlockDevice adds a block device to the node.

func (*NUMANode) AddCore

func (n *NUMANode) AddCore(core CPUCore) error

AddCore adds a CPU core to the node.

func (*NUMANode) AddDevice

func (n *NUMANode) AddDevice(dev *PCIDevice) error

AddDevice adds a PCI device to the node.

func (*NUMANode) AddPCIBus

func (n *NUMANode) AddPCIBus(bus *PCIBus) error

AddPCIBus adds a PCI bus to the node.

func (*NUMANode) WithBlockDevices

func (n *NUMANode) WithBlockDevices(devices []*BlockDevice) *NUMANode

WithBlockDevices is a convenience function to add a set of block devices to a node. NB: If AddBlockDevice fails, a panic will ensue.

func (*NUMANode) WithCPUCores

func (n *NUMANode) WithCPUCores(cores []CPUCore) *NUMANode

WithCPUCores is a convenience function to add a set of cores to a node. NB: If AddCore fails, a panic will ensue.

func (*NUMANode) WithDevices

func (n *NUMANode) WithDevices(devices []*PCIDevice) *NUMANode

WithDevices is a convenience function to add a set of devices to a node. NB: If AddDevice fails, a panic will ensue.

func (*NUMANode) WithPCIBuses

func (n *NUMANode) WithPCIBuses(buses []*PCIBus) *NUMANode

WithPCIBuses is a convenience function to add multiple PCI buses to the node. NB: If AddPCIBus fails, a panic will ensue.

type NetDevClass

type NetDevClass uint32

NetDevClass represents the class of network device. ARP protocol hardware identifiers: https://elixir.free-electrons.com/linux/v4.0/source/include/uapi/linux/if_arp.h#L29

const (
	Netrom     NetDevClass = 0
	Ether      NetDevClass = 1
	Eether     NetDevClass = 2
	Ax25       NetDevClass = 3
	Pronet     NetDevClass = 4
	Chaos      NetDevClass = 5
	IEEE802    NetDevClass = 6
	Arcnet     NetDevClass = 7
	Appletlk   NetDevClass = 8
	Dlci       NetDevClass = 15
	Atm        NetDevClass = 19
	Metricom   NetDevClass = 23
	IEEE1394   NetDevClass = 24
	Eui64      NetDevClass = 27
	Infiniband NetDevClass = 32
	Loopback   NetDevClass = 772
)

func (NetDevClass) String

func (c NetDevClass) String() string

type NetDevClassBuilder

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

NetDevClassBuilder is a builder updates FabricInterfaces with a NetDevClass.

func (*NetDevClassBuilder) BuildPart

func (n *NetDevClassBuilder) BuildPart(ctx context.Context, fis *FabricInterfaceSet) error

BuildPart updates existing FabricInterface structures in the FabricInterfaceSet to include a net device class (i.e. device type), if available.

type NetDevClassProvider

type NetDevClassProvider interface {
	GetNetDevClass(string) (NetDevClass, error)
}

NetDevClassProvider is an interface that returns the NetDevClass associated with a device.

type NetDevState

type NetDevState int

NetDevState describes the state of a network device.

const (
	// NetDevStateUnknown indicates that the device state can't be determined.
	NetDevStateUnknown NetDevState = iota
	// NetDevStateDown indicates that the device is down. This could mean the device is disabled
	// or physically disconnected.
	NetDevStateDown
	// NetDevStateNotReady indicates that the device is connected but not ready to communicate.
	NetDevStateNotReady
	// NetDevStateReady indicates that the device is up and ready to communicate.
	NetDevStateReady
)

type NetDevStateProvider

type NetDevStateProvider interface {
	GetNetDevState(string) (NetDevState, error)
}

NetDevStateProvider is an interface for a type that can be used to get the state of a network device.

type NetworkDeviceBuilder

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

NetworkDeviceBuilder is a builder that updates FabricInterfaces with NetDevice.

func (*NetworkDeviceBuilder) BuildPart

BuildPart updates existing FabricInterface structures in the FabricInterfaceSet to include an OS-level network device name, if available.

type NodeMap

type NodeMap map[uint]*NUMANode

NodeMap maps a node ID to a node.

func (NodeMap) AddBlockDevice

func (nm NodeMap) AddBlockDevice(numaID uint, device *BlockDevice) error

AddBlockDevice adds a Block device to the topology.

func (NodeMap) AddPCIDevice

func (nm NodeMap) AddPCIDevice(numaID uint, device *PCIDevice) error

AddPCIDevice adds a PCI device to the topology.

func (NodeMap) AsSlice

func (nm NodeMap) AsSlice() []*NUMANode

AsSlice returns the node map as a sorted slice of NUMANodes.

type PCIAddress

type PCIAddress struct {
	VMDAddr  *PCIAddress `json:"vmd_address,omitempty"`
	Domain   uint16      `json:"domain"`
	Bus      uint8       `json:"bus"`
	Device   uint8       `json:"device"`
	Function uint8       `json:"function"`
}

PCIAddress represents the address of a standard PCI device or a VMD backing device.

func MockPCIAddress

func MockPCIAddress(fields ...uint8) *PCIAddress

MockPCIAddress returns a mock PCI address for testing.

func MustNewPCIAddress

func MustNewPCIAddress(addr string) *PCIAddress

MustNewPCIAddress creates a new PCIAddress from input string, which must be valid, otherwise a panic will occur.

func NewPCIAddress

func NewPCIAddress(addr string) (*PCIAddress, error)

NewPCIAddress creates a PCIAddress struct from input string.

func (*PCIAddress) BackingToVMDAddress

func (pa *PCIAddress) BackingToVMDAddress() (*PCIAddress, error)

BackingToVMDAddress returns the VMD PCI address associated with a VMD backing devices address.

func (*PCIAddress) Equals

func (pa *PCIAddress) Equals(other *PCIAddress) bool

Equals compares two PCIAddress structs for equality.

func (*PCIAddress) FieldStrings

func (pa *PCIAddress) FieldStrings() map[string]string

func (*PCIAddress) IsVMDBackingAddress

func (pa *PCIAddress) IsVMDBackingAddress() bool

IsVMDBackingAddress indicates whether PCI address is a VMD backing device.

func (*PCIAddress) IsZero

func (pa *PCIAddress) IsZero() bool

IsZero returns true if address was uninitialized.

func (*PCIAddress) LessThan

func (pa *PCIAddress) LessThan(other *PCIAddress) bool

LessThan evaluate whether "this" address is less than "other" by comparing domain/bus/device/function in order.

func (*PCIAddress) String

func (pa *PCIAddress) String() string

type PCIAddressSet

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

PCIAddressSet represents a unique set of PCI addresses.

func MustNewPCIAddressSet

func MustNewPCIAddressSet(addrs ...string) *PCIAddressSet

MustNewPCIAddressSet creates a new PCIAddressSet from input strings, which must be valid, otherwise a panic will occur.

func NewPCIAddressSet

func NewPCIAddressSet(addrs ...string) (*PCIAddressSet, error)

NewPCIAddressSet takes a variable number of strings and attempts to create an address set.

func NewPCIAddressSetFromString

func NewPCIAddressSetFromString(addrs string) (*PCIAddressSet, error)

NewPCIAddressSetFromString takes a space-separated string and attempts to create an address set.

func (*PCIAddressSet) Add

func (pas *PCIAddressSet) Add(addrs ...*PCIAddress) error

Add adds PCI addresses to set. Ignores duplicate addresses.

func (*PCIAddressSet) AddStrings

func (pas *PCIAddressSet) AddStrings(addrs ...string) error

AddStrings adds PCI addresses to set from supplied strings. If any input string is not a valid PCI address then return error and don't add any elements to set.

func (*PCIAddressSet) Addresses

func (pas *PCIAddressSet) Addresses() []*PCIAddress

Addresses returns sorted slice of PCI address type object references.

func (*PCIAddressSet) BackingToVMDAddresses

func (pas *PCIAddressSet) BackingToVMDAddresses() (*PCIAddressSet, error)

BackingToVMDAddresses converts all VMD backing device PCI addresses (with the VMD address encoded in the domain component of the PCI address) in set back to the PCI address of the VMD e.g. [5d0505:01:00.0, 5d0505:03:00.0] -> [0000:5d:05.5].

Many assumptions are made as to the input and output PCI address structure in the conversion.

func (*PCIAddressSet) Contains

func (pas *PCIAddressSet) Contains(a *PCIAddress) bool

Contains returns true if provided address is already in set.

func (*PCIAddressSet) Difference

func (pas *PCIAddressSet) Difference(in *PCIAddressSet) *PCIAddressSet

Difference returns elements in 'this' set but NOT IN input address set.

func (*PCIAddressSet) Equals

func (pas *PCIAddressSet) Equals(other *PCIAddressSet) bool

Equals compares two PCIAddressSets for equality.

func (*PCIAddressSet) HasVMD

func (pas *PCIAddressSet) HasVMD() bool

HasVMD returns true if any of the addresses in set is for a VMD backing device.

func (*PCIAddressSet) Intersect

func (pas *PCIAddressSet) Intersect(in *PCIAddressSet) *PCIAddressSet

Intersect returns elements in 'this' AND input address sets.

func (*PCIAddressSet) IsEmpty

func (pas *PCIAddressSet) IsEmpty() bool

IsEmpty returns true if address set is empty.

func (*PCIAddressSet) Len

func (pas *PCIAddressSet) Len() int

Len returns length of set. Required by sort.Interface.

func (*PCIAddressSet) String

func (pas *PCIAddressSet) String() string

Strings returns PCI addresses as string of joined space separated strings.

func (*PCIAddressSet) Strings

func (pas *PCIAddressSet) Strings() []string

Strings returns PCI addresses as slice of strings.

type PCIBus

type PCIBus struct {
	LowAddress  PCIAddress `json:"low_address"`
	HighAddress PCIAddress `json:"high_address"`
	NUMANode    *NUMANode  `json:"-"`
	PCIDevices  PCIDevices `json:"pci_devices"`
}

PCIBus represents the root of a PCI bus hierarchy.

func NewPCIBus

func NewPCIBus(domain uint16, lo, hi uint8) *PCIBus

NewPCIBus creates a new PCI bus.

func (*PCIBus) AddDevice

func (b *PCIBus) AddDevice(dev *PCIDevice) error

AddDevice adds a PCI device to the bus.

func (*PCIBus) Contains

func (b *PCIBus) Contains(addr *PCIAddress) bool

Contains returns true if the given PCI address is contained within the bus.

func (*PCIBus) IsZero

func (b *PCIBus) IsZero() bool

IsZero if PCI bus contains no valid addresses.

func (*PCIBus) String

func (b *PCIBus) String() string

type PCIDevice

type PCIDevice struct {
	Name         string       `json:"name"`
	Type         DeviceType   `json:"type"`
	NUMANode     *NUMANode    `json:"-"`
	Bus          *PCIBus      `json:"-"`
	PCIAddr      PCIAddress   `json:"pci_address"`
	LinkPortID   uint16       `json:"port_id"`
	LinkMaxSpeed float32      `json:"link_max_speed,omitempty"`
	LinkMaxWidth uint16       `json:"link_max_width,omitempty"`
	LinkNegSpeed float32      `json:"link_neg_speed,omitempty"`
	LinkNegWidth uint16       `json:"link_neg_width,omitempty"`
	BlockDevice  *BlockDevice `json:"-"`
}

PCIDevice represents an individual hardware device.

func (*PCIDevice) DeviceName

func (d *PCIDevice) DeviceName() string

DeviceName returns the system name of the PCI device.

func (*PCIDevice) DeviceType

func (d *PCIDevice) DeviceType() DeviceType

DeviceType returns the type of PCI device.

func (*PCIDevice) PCIDevice

func (d *PCIDevice) PCIDevice() *PCIDevice

PCIDevice returns a pointer to itself.

func (*PCIDevice) String

func (d *PCIDevice) String() string

type PCIDevices

type PCIDevices map[PCIAddress][]*PCIDevice

PCIDevices groups hardware devices by PCI address.

func (PCIDevices) Add

func (d PCIDevices) Add(dev *PCIDevice) error

Add adds a device to the PCIDevices.

func (PCIDevices) Get

func (d PCIDevices) Get(addr *PCIAddress) []*PCIDevice

Get returns the devices for the given PCI address.

func (PCIDevices) Keys

func (d PCIDevices) Keys() []*PCIAddress

Keys fetches the sorted keys for the map.

func (PCIDevices) MarshalJSON

func (d PCIDevices) MarshalJSON() ([]byte, error)

type PCIeLinkStatsProvider

type PCIeLinkStatsProvider interface {
	// PCIeCapsFromConfig takes a PCIe config space dump (of the format output by lspci
	// -xxx) in the form of a byte slice. The second parameter is a reference to a
	// PCIDevice struct to be populated.
	PCIeCapsFromConfig([]byte, *PCIDevice) error
}

PCIeLinkStatsProvider is an interface for acquiring NVMe PCIe link info.

type ProcessNUMAProvider

type ProcessNUMAProvider interface {
	GetNUMANodeIDForPID(context.Context, int32) (uint, error)
}

ProcessNUMAProvider is an interface for getting the NUMA node associated with a process ID.

type Topology

type Topology struct {
	// NUMANodes is the set of NUMA nodes mapped by their ID.
	NUMANodes NodeMap `json:"numa_nodes"`

	// VirtualDevices is a set of virtual devices created in software that may have a
	// hardware backing device.
	VirtualDevices []*VirtualDevice `json:"virtual_devices"`
}

Topology is a hierarchy of hardware devices grouped under NUMA nodes.

func (*Topology) AddBlockDevice

func (t *Topology) AddBlockDevice(numaID uint, device *BlockDevice) error

AddBlockDevice adds a device to the topology.

func (*Topology) AddDevice

func (t *Topology) AddDevice(numaID uint, device *PCIDevice) error

AddDevice adds a device to the topology.

func (*Topology) AddVirtualDevice

func (t *Topology) AddVirtualDevice(device *VirtualDevice) error

AddVirtualDevice adds a virtual device not associated with a NUMA node to the topology.

func (*Topology) AllDevices

func (t *Topology) AllDevices() map[string]Device

AllDevices returns a map of all system Devices sorted by their name.

func (*Topology) Merge

func (t *Topology) Merge(newTopo *Topology) error

Merge updates the contents of the initial topology from the incoming topology.

func (*Topology) NumCoresPerNUMA

func (t *Topology) NumCoresPerNUMA() int

NumCoresPerNUMA gets the number of cores per NUMA node.

func (*Topology) NumNUMANodes

func (t *Topology) NumNUMANodes() int

NumNUMANodes gets the number of NUMA nodes in the system topology.

type TopologyFactory

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

TopologyFactory is a TopologyProvider that merges results from multiple other TopologyProviders.

func NewTopologyFactory

func NewTopologyFactory(providers ...*WeightedTopologyProvider) *TopologyFactory

NewTopologyFactory creates a TopologyFactory based on the list of weighted topology providers.

func (*TopologyFactory) GetTopology

func (tf *TopologyFactory) GetTopology(ctx context.Context) (*Topology, error)

GetTopology gets a merged master topology from all the topology providers.

type TopologyProvider

type TopologyProvider interface {
	GetTopology(context.Context) (*Topology, error)
}

TopologyProvider is an interface for acquiring a system topology.

type VirtualDevice

type VirtualDevice struct {
	Name          string     `json:"name"`
	Type          DeviceType `json:"type"`
	BackingDevice *PCIDevice `json:"backing_device"`
}

VirtualDevice represents a system device that is created virtually in software, and may have a real PCI hardware device associated with it.

func (*VirtualDevice) DeviceName

func (d *VirtualDevice) DeviceName() string

DeviceName is the name of the virtual device.

func (*VirtualDevice) DeviceType

func (d *VirtualDevice) DeviceType() DeviceType

DeviceType is the type of the virtual device.

func (*VirtualDevice) PCIDevice

func (d *VirtualDevice) PCIDevice() *PCIDevice

PCIDevice is the hardware device associated with the virtual device, if any.

type WaitFabricReadyParams

type WaitFabricReadyParams struct {
	StateProvider  NetDevStateProvider
	FabricIfaces   []string      // Fabric interfaces that must become ready
	IterationSleep time.Duration // Time between iterations if some interfaces aren't ready
	IgnoreUnusable bool          // Ignore interfaces that are in an unusable state
}

WaitFabricReadyParams defines the parameters for a WaitFabricReady call.

type WeightedTopologyProvider

type WeightedTopologyProvider struct {
	Provider TopologyProvider
	Weight   int
}

WeightedTopologyProvider is a provider with associated weight to determine order of operations. Greater weights indicate higher priority.

Directories

Path Synopsis
defaults
network
Package network provides constructors for cross-package composable hardware providers related to networking.
Package network provides constructors for cross-package composable hardware providers related to networking.
topology
Package topology provides constructors for cross-package composable hardware providers related to topology discovery and interrogation.
Package topology provides constructors for cross-package composable hardware providers related to topology discovery and interrogation.

Jump to

Keyboard shortcuts

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