types

package
v1.21.0-pre.4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KernelIfNameLabel contains the interface name
	// assigned by the kernel.
	KernelIfNameLabel = "kernelIfName"
	// IfNameLabel contains the name of the device
	// as assigned by the device managers.
	// must be unique across all devices on the node.
	IfNameLabel = "ifName"
	// HWAddrLabel contains the MAC address of the device.
	HWAddrLabel = "macAddress"
	// DeviceManagerLabel identifies which Device Manager
	// published the device.
	DeviceManagerLabel = "deviceManager"
	// PoolNameLabel is the pool name.
	PoolNameLabel = "pool"
	// PCIBusIDLabel contains the PCI bus address for
	// the device. Only applicable to PCI based devices.
	PCIBusIDLabel = deviceattribute.StandardDeviceAttributePrefix + "pciBusID"
	// PFNameLabel contains the kernel ifname for the
	// PF on a VF device. Only applicable to sr-iov
	// VF devices.
	PFNameLabel = "pfName"
	// VendorLabel identifies the vendor of this device
	// same as /sys/bus/pci/devices/<pciAddr>/vendor
	VendorLabel = "vendor"
	// DeviceIDLabel contains a device's device id
	// same as /sys/bus/pci/devices/<pciAddr>/device
	DeviceIDLabel = "deviceID"
	// DriverLabel identifies a device's driver.
	DriverLabel = "driver"
	// RXQueuesCapacity is the number of RX queues available for allocation.
	RXQueuesCapacity = "rxQueues"
	// RXQueueIDLabel is the leased queue ID on the interface given to the pod.
	RXQueueIDLabel = "rxQueueID"
	// DefaultRXQueuePodIfName is the default existing Pod interface to receive a leased queue.
	DefaultRXQueuePodIfName = "eth0"
)

The labels below are used by the device managers to tag their devices for advertising ResourceSlices. These attributes may be used to filter and match devices on a resource claim.

View Source
const (
	// MaxInterfaceNameLength is the maximum length for a Linux interface name (IFNAMSIZ - 1)
	MaxInterfaceNameLength = 15
)

Interface name validation constants

Variables

This section is empty.

Functions

func ValidateInterfaceName

func ValidateInterfaceName(name string) error

ValidateInterfaceName validates an interface name according to Linux rules

Types

type Device

type Device interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	GetAttrs() map[resourceapi.QualifiedName]resourceapi.DeviceAttribute
	GetCapacity() map[resourceapi.QualifiedName]resourceapi.DeviceCapacity
	AllowMultipleAllocations() bool
	// Setup prepares one allocation and returns the device representing it.
	// For a shared allocation, this may be an allocation-specific child, such as a
	// netdev that leases one RX queue, rather than the device published in the
	// ResourceSlice.
	Setup(allocation DeviceAllocation) (Device, error)
	// Recover re-creates missing kernel state for an allocation restored from
	// ResourceClaim status. The returned device must represent the same logical
	// allocation because recovery does not rewrite that status.
	Recover(allocation DeviceAllocation) (Device, error)
	Free(allocation DeviceAllocation) error
	Match(filter v2alpha1.CiliumNetworkDriverDeviceFilter) bool
	IfName() string
	KernelIfName() string
	Merge(Device)
}

type DeviceAllocation

type DeviceAllocation struct {
	Config DeviceConfig
	// ShareID identifies a shared allocation and is empty for a dedicated one.
	// It reflects the scheduler's allocation-time decision, which may differ
	// from the device's current sharing mode.
	ShareID kube_types.UID
	// ConsumedCapacity contains the capacity assigned by the scheduler.
	ConsumedCapacity map[resourceapi.QualifiedName]resource.Quantity
}

DeviceAllocation contains scheduler and driver parameters for one allocation.

type DeviceConfig

type DeviceConfig struct {
	PodIfName string       `json:"podIfName,omitempty"` // Custom interface name for the pod namespace
	Vlan      int32        `json:"vlan,omitempty"`      // VLAN ID to assign to the device (0 = untagged / no change)
	IPv4Addr  netip.Prefix `json:"ipv4Addr,omitzero"`
	IPv6Addr  netip.Prefix `json:"ipv6Addr,omitzero"`
	IPPool    string       `json:"ipPool,omitempty"`

	// InterfaceSysctlIPv4/IPv6 hold leaf sysctl parameters (e.g.
	// "arp_filter") applied under net.<family>.conf.<interface>. for the
	// interface this claim allocates. Applied once, inside the pod netns,
	// when the interface is brought up; not reverted on Free (the
	// namespace is destroyed with the pod).
	InterfaceSysctlIPv4 map[string]string `json:"interfaceSysctlIPv4,omitempty"`
	InterfaceSysctlIPv6 map[string]string `json:"interfaceSysctlIPv6,omitempty"`
}

func (*DeviceConfig) Empty

func (d *DeviceConfig) Empty() bool

func (*DeviceConfig) HasPool

func (d *DeviceConfig) HasPool() bool

func (*DeviceConfig) Validate

func (d *DeviceConfig) Validate() error

type DeviceManager

type DeviceManager interface {
	Type() DeviceManagerType
	// Run publishes the current device set by calling publish, then blocks
	// until ctx is cancelled. Implementations must call publish at least once
	// before returning so the driver knows what devices are available.
	// On any change to the device set, Run calls publish again with the full
	// updated set.
	Run(ctx context.Context, publish func([]Device)) error
	RestoreDevice([]byte) (Device, error)
}

type DeviceManagerType

type DeviceManagerType int
const (
	// DeviceManagerTypeMock is a sentinel used by unit tests.
	// It is intentionally kept in the types package so that test files in
	// the networkdriver package can reference it without importing a real
	// device-manager package.
	DeviceManagerTypeMock DeviceManagerType = iota
	DeviceManagerTypeDummy
	DeviceManagerTypeSRIOV
	DeviceManagerTypeRXQueue
	DeviceManagerTypeUnknown
)

func (DeviceManagerType) MarshalText

func (d DeviceManagerType) MarshalText() (text []byte, err error)

func (DeviceManagerType) String

func (d DeviceManagerType) String() string

func (*DeviceManagerType) UnmarshalText

func (d *DeviceManagerType) UnmarshalText(text []byte) error

type SerializedDevice

type SerializedDevice struct {
	Manager DeviceManagerType
	Dev     json.RawMessage
	Config  DeviceConfig
	// LogicalPool is the Cilium pool the device was matched against when
	// this allocation was prepared. Persisted so restore can keep the pool
	// pinned even if pool config changes while the driver is down.
	LogicalPool      string                                          `json:"logicalPool,omitempty"`
	ConsumedCapacity map[resourceapi.QualifiedName]resource.Quantity `json:",omitempty"`
}

Jump to

Keyboard shortcuts

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