config

package
v0.0.0-...-9bd9f91 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package config is used to collect the devices configurations on the machine.

Index

Constants

View Source
const (
	ModeDedicated = "dedicated" // ModeDedicated represents a dedicated workqueue mode
	ModeShared    = "shared"    // ModeShared represents a shared workqueue mode
)
View Source
const (
	DeviceStateUnknown  = "unknown"
	DeviceStateEnabled  = "enabled"
	DeviceStateDisabled = "disabled"
)

Device state constants.

View Source
const (
	BlockOnFaultSupport           = 1 << iota // Block on fault support.
	OverlappingSupport                        // Overlapping support.
	CacheControlSupportMemory                 // Cache control support memory.
	CacheControlSupportCacheFlush             // Cache control support cache flush.
	CommandCapabilitiesSupport                // Command capabilities support.

	DestinationReadbackSupport                      // Destination readback support.
	DrainDescriptorReadbackAddressSupport           // Drain descriptor readback address support.
	ConfigurationSupport                  = 1 << 31 // Configuration support.
)

Device capabilities constants.

View Source
const (
	WQTypeKernel // WQTypeKernel indicates current wq is kernel mode.
	WQTypeUser   // WQTypeUser indicates current wq is User mode.
	WQTypeMDev   // WQTypeMDev indicates current wq is Mdev mode.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Devices []*Device
}

Context represents the devices information which supported on the local machine.

func NewContext

func NewContext() *Context

NewContext create a Context

func (*Context) AddDevice

func (c *Context) AddDevice(id int, path string, busType string) (err error)

AddDevice adds a Device to the context.

func (*Context) DedicatedWQs

func (c *Context) DedicatedWQs(typ DeviceType) []*WorkQueue

DedicatedWQs returns the dedicated work queues of the specified device type.

func (*Context) Engines

func (c *Context) Engines(typ DeviceType) (results []*Engine)

Engines returns the engines of the specified device type.

func (*Context) Init

func (c *Context) Init()

Init starts to load devices information from the local sysfs.

func (*Context) SharedWQs

func (c *Context) SharedWQs(typ DeviceType) []*WorkQueue

SharedWQs returns the shared work queues of the specified device type.

func (*Context) WorkQueues

func (c *Context) WorkQueues(typ DeviceType) []*WorkQueue

WorkQueues returns the work queues of the specified device type.

type Device

type Device struct {
	MaxGroups         int    `binding:""` // Maximum number of groups.
	MaxWorkQueues     int    `binding:""` // Maximum number of work queues.
	MaxEngines        int    `binding:""` // Maximum number of engines.
	MaxWorkQueuesSize int    `binding:""` // Maximum size of work queues.
	NumaNode          int    `binding:""` // NUMA node.
	ImsSize           int    `binding:""` // IMS size.
	MaxBatchSize      int    `binding:""` // Maximum batch size.
	MaxTransferSize   uint64 `binding:""` // Maximum transfer size.
	GenCap            uint64 `binding:""` // Generation capabilities.
	Configurable      int    `binding:""` // Configurable parameters.
	PasidEnabled      bool   `binding:""` // PASID enabled.
	MaxReadBuffers    int    `binding:""` // Maximum number of read buffers.
	ReadBufferLimit   uint64 `binding:""` // Read buffer limit.
	CdevMajor         uint64 `binding:""` // cdev major number.
	Version           uint64 `binding:""` // Device version number.
	State             string `binding:""` // Device state.

	ID       uint64     // Device ID.
	OpCap    [4]uint64  // Device operation capabilities.
	Path     string     // Device's sysfs path.
	MDevPath string     // Device's mediated device path.
	Type     DeviceType // Device type.
	BusType  string     // Bus type.

	Groups     []*Group     // Groups associated with the device.
	Engines    []*Engine    `json:"-"` // Engines associated with the device.
	WorkQueues []*WorkQueue `json:"-"` // Work queues associated with the device.
}

Device represents a device with parameters.

func (*Device) Clients

func (d *Device) Clients() (int, error)

Clients returns the number of clients for a device.

func (*Device) ReadOPCap

func (d *Device) ReadOPCap() error

ReadOPCap reads the op_cap file for a device and updates the device's op cap array.

type DeviceType

type DeviceType uint8

DeviceType is a type of device.

const (
	DSA DeviceType = 0 // DSA represents a device type of DSA.
	IAA DeviceType = 1 // IAA represents a device type of IAA.
)

func (DeviceType) Name

func (t DeviceType) Name() string

Name returns the name of the device type.

func (DeviceType) Names

func (t DeviceType) Names() []string

Names returns the names of the device type.

func (DeviceType) String

func (t DeviceType) String() string

String returns the string representation of the device type.

type Engine

type Engine struct {
	// Device is the device this engine belongs to.
	Device *Device `json:"-"`
	// Group is the group this engine belongs to.
	Group *Group `json:"-"`
	// Type is the type of this engine.
	Type int
	// ID is the ID of this engine.
	ID int
	// GroupID is the ID of the group this engine belongs to.
	GroupID int `binding:""`
}

Engine represents an engine in a device.

type GenCap

type GenCap struct {
	BlockOnFault                   bool   // Block on fault support.
	Overlapping                    bool   // Overlapping support.
	CacheControlMemory             bool   // Cache control support memory.
	CacheControlCacheFlush         bool   // Cache control support cache flush.
	CommandCapabilities            bool   // Command capabilities support.
	DestinationReadback            bool   // Destination readback support.
	DrainDescriptorReadbackAddress bool   // Drain descriptor readback address support.
	ConfigurationSupport           bool   // Configuration support.
	MaxTransferSize                uint64 // Maximum transfer size.
	MaxBatchSize                   uint64 // Maximum batch size.
	InterruptMessageStorageSize    uint64 // Interrupt message storage size.
}

GenCap represents a device's generation capabilities.

func ParseGenCap

func ParseGenCap(gencap uint64) (g *GenCap)

ParseGenCap parses a uint64 value representing a device's generation capabilities.

type Group

type Group struct {
	// Device is the device that manages the group.
	Device *Device `json:"-"`
	// ID is the ID of the group.
	ID int
	// Path is the path to the group.
	Path string
	// NumaNode is the NUMA node the group belongs to.
	NumaNode int
	// GroupID is the ID of the group.
	GroupID int

	// Engines is the list of engines in the group.
	Engines string `binding:""`
	// WorkQueues is the list of work queues in the group.
	WorkQueues string `binding:""`
	// ReadBuffersReserved is the number of read buffers reserved.
	ReadBuffersReserved uint64 `binding:""`
	// ReadBufferAllowed is the number of read buffers allowed.
	ReadBufferAllowed uint64 `binding:""`
	// UseReadBufferLimit is the number of read buffers to use.
	UseReadBufferLimit uint64 `binding:""`
	// TrafficClassA is the number of traffic class A messages.
	TrafficClassA uint64 `binding:""`
	// TrafficClassB is the number of traffic class B messages.
	TrafficClassB uint64 `binding:""`

	// GroupedEngines is the list of engines in the group.
	GroupedEngines []*Engine
	// GroupedWorkQueues is the list of work queues in the group.
	GroupedWorkQueues []*WorkQueue
}

Group represents a group of devices managed by a device.

type WQType

type WQType uint

WQType represents the type of a work queue.

type WorkQueue

type WorkQueue struct {
	Device          *Device `json:"-"` // Device associated with the work queue.
	Group           *Group  `json:"-"` // Group associated with the work queue.
	ID              int     // Work queue ID.
	NumaNode        int     // NUMA node.
	DeviceName      string  // Device name.
	Path            string  // Path to the work queue.
	GroupID         int     `binding:""` // ID of the group associated with the work queue.
	Size            int     `binding:""` // Work queue size.
	Priority        int     `binding:""` // Queue priority.
	BlockOnFault    int     `binding:""` // Block on fault flag.
	CdevMinor       int     `binding:""` // cdev minor number.
	Type            string  `binding:""` // Type of the work queue.
	Name            string  `binding:""` // Name of the work queue.
	Mode            string  `binding:""` // Mode of the work queue.
	State           string  `binding:""` // State of the work queue.
	DriverName      string  `binding:""` // Name of the driver.
	Threshold       uint    `binding:""` // Threshold limit.
	MaxBatchSize    uint    `binding:""` // Maximum batch size.
	MaxTransferSize uint64  `binding:""` // Maximum transfer size.
	AtsDisable      int     `binding:""` // ATS disable flag.
}

WorkQueue represents a work queue of a device.

func (*WorkQueue) Clients

func (w *WorkQueue) Clients() (int, error)

Clients returns the number of clients for a work queue.

func (*WorkQueue) DevicePath

func (w *WorkQueue) DevicePath() string

DevicePath returns the device path of a work queue.

Jump to

Keyboard shortcuts

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