Documentation ¶
Index ¶
- Constants
- Variables
- func ErrProviderNotOnDevice(provider, dev string) error
- func ErrUnsupportedFabric(provider string) error
- func IsProviderNotOnDevice(err error) bool
- func IsUnsupportedFabric(err error) bool
- func PrintTopology(t *Topology, output io.Writer) error
- func WaitFabricReady(ctx context.Context, log logging.Logger, params WaitFabricReadyParams) error
- type BlockDevice
- type CPUCore
- type Device
- type DeviceType
- type FabricInterface
- type FabricInterfaceBuilder
- type FabricInterfaceProvider
- type FabricInterfaceSet
- func (s *FabricInterfaceSet) GetInterface(name string) (*FabricInterface, error)
- func (s *FabricInterfaceSet) GetInterfaceOnNetDevice(netDev string, provider string) (*FabricInterface, error)
- func (s *FabricInterfaceSet) Names() []string
- func (s *FabricInterfaceSet) NetDevices() []string
- func (s *FabricInterfaceSet) NumFabricInterfaces() int
- func (s *FabricInterfaceSet) NumNetDevices() int
- func (s *FabricInterfaceSet) Remove(fiName string)
- func (s *FabricInterfaceSet) String() string
- func (s *FabricInterfaceSet) Update(fi *FabricInterface)
- type FabricInterfaceSetBuilder
- type FabricInterfaceSetBuilderConfig
- type FabricProvider
- type FabricProviderSet
- type FabricScanner
- type FabricScannerConfig
- type IOMMUDetector
- type MockFabricInterfaceProvider
- type MockFabricInterfaceSetBuilder
- type MockFabricScannerConfig
- type MockGetNetDevClassResult
- type MockNetDevClassProvider
- type MockNetDevStateProvider
- type MockNetDevStateResult
- type MockTopologyProvider
- type NUMAAffinityBuilder
- type NUMANode
- func (n *NUMANode) AddBlockDevice(device *BlockDevice) error
- func (n *NUMANode) AddCore(core CPUCore) error
- func (n *NUMANode) AddDevice(dev *PCIDevice) error
- func (n *NUMANode) AddPCIBus(bus *PCIBus) error
- func (n *NUMANode) WithBlockDevices(devices []*BlockDevice) *NUMANode
- func (n *NUMANode) WithCPUCores(cores []CPUCore) *NUMANode
- func (n *NUMANode) WithDevices(devices []*PCIDevice) *NUMANode
- func (n *NUMANode) WithPCIBuses(buses []*PCIBus) *NUMANode
- type NetDevClass
- type NetDevClassBuilder
- type NetDevClassProvider
- type NetDevState
- type NetDevStateProvider
- type NetworkDeviceBuilder
- type NodeMap
- type PCIAddress
- func (pa *PCIAddress) BackingToVMDAddress() (*PCIAddress, error)
- func (pa *PCIAddress) Equals(other *PCIAddress) bool
- func (pa *PCIAddress) FieldStrings() map[string]string
- func (pa *PCIAddress) IsVMDBackingAddress() bool
- func (pa *PCIAddress) IsZero() bool
- func (pa *PCIAddress) LessThan(other *PCIAddress) bool
- func (pa *PCIAddress) String() string
- type PCIAddressSet
- func (pas *PCIAddressSet) Add(addrs ...*PCIAddress) error
- func (pas *PCIAddressSet) AddStrings(addrs ...string) error
- func (pas *PCIAddressSet) Addresses() []*PCIAddress
- func (pas *PCIAddressSet) BackingToVMDAddresses() (*PCIAddressSet, error)
- func (pas *PCIAddressSet) Contains(a *PCIAddress) bool
- func (pas *PCIAddressSet) Difference(in *PCIAddressSet) *PCIAddressSet
- func (pas *PCIAddressSet) Equals(other *PCIAddressSet) bool
- func (pas *PCIAddressSet) HasVMD() bool
- func (pas *PCIAddressSet) Intersect(in *PCIAddressSet) *PCIAddressSet
- func (pas *PCIAddressSet) IsEmpty() bool
- func (pas *PCIAddressSet) Len() int
- func (pas *PCIAddressSet) String() string
- func (pas *PCIAddressSet) Strings() []string
- type PCIBus
- type PCIDevice
- type PCIDevices
- type PCIeLinkStatsProvider
- type ProcessNUMAProvider
- type Topology
- func (t *Topology) AddBlockDevice(numaID uint, device *BlockDevice) error
- func (t *Topology) AddDevice(numaID uint, device *PCIDevice) error
- func (t *Topology) AddVirtualDevice(device *VirtualDevice) error
- func (t *Topology) AllDevices() map[string]Device
- func (t *Topology) Merge(newTopo *Topology) error
- func (t *Topology) NumCoresPerNUMA() int
- func (t *Topology) NumNUMANodes() int
- type TopologyFactory
- type TopologyProvider
- type VirtualDevice
- type WaitFabricReadyParams
- type WeightedTopologyProvider
Constants ¶
const (
// PCIAddrBusBitSize defines the number of bits used to represent bus in address.
PCIAddrBusBitSize = 8
)
Variables ¶
var ErrNoNUMANodes = errors.New("no NUMA nodes detected")
ErrNoNUMANodes indicates that the system can't detect any NUMA nodes.
var ErrNotVMDBackingAddress = errors.New("not a vmd backing device address")
Functions ¶
func ErrProviderNotOnDevice ¶
ErrProviderNotOnDevice returns an error indicated that the fabric provider is not available on the given network device.
func ErrUnsupportedFabric ¶
ErrUnsupportedFabric returns an error indicating that the denoted fabric provider is not supported by this build/platform.
func IsProviderNotOnDevice ¶
IsProviderNotOnDevice indicates whether the error is an instance of errProviderNotOnDevice.
func IsUnsupportedFabric ¶
IsUnsupportedFabric returns true if the supplied error is an instance of errUnsupportedFabric.
func PrintTopology ¶
PrintTopology prints the topology to the given writer.
func WaitFabricReady ¶
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 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 ¶
func (f *FabricInterfaceBuilder) BuildPart(ctx context.Context, fis *FabricInterfaceSet) error
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 ¶
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 ¶
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 ¶
func (m *MockFabricInterfaceSetBuilder) BuildPart(_ context.Context, fis *FabricInterfaceSet) error
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 ¶
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 ¶
func (n *NUMAAffinityBuilder) BuildPart(ctx context.Context, fis *FabricInterfaceSet) error
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 ¶
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) 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 ¶
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 ¶
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 ¶
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 ¶
func (o *NetworkDeviceBuilder) BuildPart(ctx context.Context, fis *FabricInterfaceSet) error
BuildPart updates existing FabricInterface structures in the FabricInterfaceSet to include an OS-level network device name, if available.
type NodeMap ¶
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 ¶
AddPCIDevice adds a PCI device to the topology.
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 (*PCIBus) Contains ¶
func (b *PCIBus) Contains(addr *PCIAddress) bool
Contains returns true if the given PCI address is contained within the bus.
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 ¶
DeviceName returns the system name of the PCI device.
func (*PCIDevice) DeviceType ¶
func (d *PCIDevice) DeviceType() DeviceType
DeviceType returns the type of PCI device.
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 ¶
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) 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 ¶
AllDevices returns a map of all system Devices sorted by their name.
func (*Topology) Merge ¶
Merge updates the contents of the initial topology from the incoming topology.
func (*Topology) NumCoresPerNUMA ¶
NumCoresPerNUMA gets the number of cores per NUMA node.
func (*Topology) NumNUMANodes ¶
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 ¶
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.
Source Files ¶
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. |