Documentation
¶
Index ¶
- Constants
- Variables
- func AddVFToBridge(vfName, bridgeName string) error
- func ApplyNetplan() error
- func ConfigureBridgeMTU(controlPlaneMTU int) (bool, error)
- func ConfigureBridgeMTUForBridge(bridgeName string, controlPlaneMTU int) (bool, error)
- func ConfigurePFs(pciAddress string, portConfigs []PortConfig) (bool, error)
- func CreateBridgeIfNotExists(bridgeName string) (netlink.Link, error)
- func GetBridgeMembers(bridgeName string) ([]string, error)
- func GetCurrentMTU(interfaceName string) (int, error)
- func GetDPUMode(ctx context.Context, pciAddress string) (provisioningv1.DpuModeType, error)
- func GetNodeName() (string, bool, error)
- func IsDHCPConfigured(interfaceName string) (bool, error)
- func IsVF(interfaceName string) bool
- func ReadDeviceSerialNumberFromVPD(sysFSRoot string, pciAddress string) (string, error)
- func RemoveVFFromBridge(vfName string) error
- func RunBash(cmdStr string) (stdout, stderr bytes.Buffer, err error)
- func SetDPUMode(pciAddress string) error
- func SetLinkMTU(linkName string, mtu int) error
- type ConditionBuilder
- type ConditionSetter
- type Device
- type PCIHelper
- func (h *PCIHelper) BindDriver(driverName string) error
- func (h *PCIHelper) BoundDriver() (string, error)
- func (h *PCIHelper) DeviceID() (string, error)
- func (h *PCIHelper) GetMTU() (int, error)
- func (h *PCIHelper) InterfaceName() (string, error)
- func (h *PCIHelper) IsDPU() (bool, error)
- func (h *PCIHelper) PF(pf int) *PCIHelper
- func (h *PCIHelper) Path() string
- func (h *PCIHelper) RebindDriver(ctx context.Context, driverName string) error
- func (h *PCIHelper) SerialNumber() (string, error)
- func (h *PCIHelper) SetNumOfVFs(num int) error
- func (h *PCIHelper) SetSysFS(newPath string) *PCIHelper
- func (h *PCIHelper) UnbindDriver() error
- func (h *PCIHelper) VF(vf int) *PCIHelper
- type PortConfig
- type RshimInfo
- type RshimQuerier
Constants ¶
const ( NetplanConfigFilePrefix = "/etc/netplan/99-dpu" BridgeMTUNetplanFile = "/etc/netplan/99-dpf-oob-bridge-mtu.yaml" // LegacyBridgeMTUNetplanFile is the old bridge MTU netplan file path used prior to bridge-name configurability. LegacyBridgeMTUNetplanFile = "/etc/netplan/99-br-dpu-interfaces-mtu.yaml" )
const ( DPFNamespace = "dpf-operator-system" MaximumHostNameLength = 48 NodeNameEnv = "NODE_NAME" K8sNodeNameEnv = "KUBERNETES_NODE_NAME" K8sPodNamespaceEnv = "POD_NAMESPACE" // CATrustBundleDir is the directory where the dpf CA trust bundle ConfigMap is mounted into the // HostAgent (DMS) Pod. It is a non-subPath volume so kubelet keeps it in sync as the bundle is // updated during CA rotation. CATrustBundleDir = "/etc/dpf/ca" // CATrustBundleFile is the full path to the CA trust bundle PEM inside the HostAgent Pod. The // file name matches the ConfigMap data key (operatorv1.CATrustBundleKey = "ca.crt"). CATrustBundleFile = CATrustBundleDir + "/ca.crt" )
const ( DeviceIDBlueField2 = "0xa2d6" DeviceIDBlueField3 = "0xa2dc" DeviceIDBlueField4 = "0xa2df" MLX5CoreDriver = "mlx5_core" )
const (
// SysFSRoot is the path to the sysfs directory.
SysFSRoot = "/sys"
)
Mutable paths for sysfs directories - can be overridden in tests for mocking
Variables ¶
var OOBBridge = &oobBridgeConfig{name: operatorv1.DefaultDPUNodeOOBBridgeName}
OOBBridge holds the process-wide OOB bridge name synced from DPFOperatorConfig.
Functions ¶
func AddVFToBridge ¶
func ConfigureBridgeMTU ¶
ConfigureBridgeMTU configures the bridge and its member interfaces MTU using netplan. Returns (needsApply, error) where needsApply indicates if changes are needed.
func ConfigureBridgeMTUForBridge ¶
ConfigureBridgeMTUForBridge configures bridge and member MTU for a specific bridge via netplan. Returns (needsApply, error) where needsApply indicates if changes are needed.
func ConfigurePFs ¶
func ConfigurePFs(pciAddress string, portConfigs []PortConfig) (bool, error)
ConfigurePFs configures the PF network interfaces using netplan. Returns (needsApply, error) where needsApply indicates if changes are needed.
func CreateBridgeIfNotExists ¶
func GetBridgeMembers ¶
GetBridgeMembers returns the names of all member interfaces of the specified bridge
func GetCurrentMTU ¶
GetCurrentMTU returns the current MTU of the specified interface
func GetDPUMode ¶
func GetDPUMode(ctx context.Context, pciAddress string) (provisioningv1.DpuModeType, error)
func GetNodeName ¶
GetNodeName returns the name of the DPUNode. If the hostname is longer than MaximumHostNameLength, it is truncated and true is returned.
func IsDHCPConfigured ¶
IsDHCPConfigured checks if DHCP is configured for the interface. It uses a two-tier approach: 1. First checks runtime state via networkctl (if DHCP obtained an address, it's definitely configured) 2. If no address found, checks the configuration file (DHCP may be configured but no address yet)
func ReadDeviceSerialNumberFromVPD ¶
ReadDeviceSerialNumberFromVPD reads the serial number from a PCI device's VPD data via sysfs configuration space. The pciAddress should be in format like "0000:4d:00.0"
func RemoveVFFromBridge ¶
func SetDPUMode ¶
func SetLinkMTU ¶
Types ¶
type ConditionBuilder ¶
type ConditionBuilder struct {
// contains filtered or unexported fields
}
func NewCondition ¶
func NewCondition(condType string) *ConditionBuilder
func (*ConditionBuilder) Failure ¶
func (b *ConditionBuilder) Failure(err error, reason string) *ConditionSetter
func (*ConditionBuilder) Success ¶
func (b *ConditionBuilder) Success(message string) *ConditionSetter
type ConditionSetter ¶
type ConditionSetter struct {
// contains filtered or unexported fields
}
ConditionSetter is a struct that sets a condition on a list of conditions. todo: move the setter and builder to controller util and substitute the existing condition functions
func (*ConditionSetter) Set ¶
func (s *ConditionSetter) Set(conditions *[]metav1.Condition)
type Device ¶
type Device struct {
// Address is the PCI address of the device after truncating the function number, e.g. "0000:4d:00"
Address string
// SerialNumber is the serial number of the device
SerialNumber string
// NumOfPFs is the number of PFs of the device
NumOfPFs int
}
func DiscoverDPUs ¶
func (Device) PFPCIAddress ¶
PFPCIAddress returns the full PCI BDF for a PF index on this device.
func (Device) PFPCIAddresses ¶
PFPCIAddresses returns full PCI BDFs for discovered PFs in deterministic order.
type PCIHelper ¶
type PCIHelper struct {
// contains filtered or unexported fields
}
func NewPCIHelper ¶
func (*PCIHelper) BindDriver ¶
BindDriver writes the device's BDF to /sys/bus/pci/drivers/<driverName>/bind, causing the kernel to attempt to bind the named driver to the device. No-op if the named driver is already bound. Returns an error if a *different* driver is bound — silently overriding could disrupt setups that intentionally bound the device to another driver (e.g. vfio-pci for passthrough). May block while the kernel runs the driver's probe routine; if the device's firmware is in pre-init, the bind can return -ETIMEDOUT after the kernel's wait_fw_init timeout.
func (*PCIHelper) BoundDriver ¶
BoundDriver returns the name of the driver currently bound to the device, or empty string if no driver is bound.
func (*PCIHelper) InterfaceName ¶
InterfaceName returns the name of the network interface of the device.
func (*PCIHelper) RebindDriver ¶
RebindDriver unbinds and rebinds a PF to driverName, then waits until a netdev appears. Callers should pass a ctx with a deadline; if none is set, waitForNetdev falls back to a 2-minute timeout so a missing netdev cannot poll forever.
func (*PCIHelper) SerialNumber ¶
func (*PCIHelper) SetNumOfVFs ¶
func (*PCIHelper) UnbindDriver ¶
UnbindDriver removes the current driver binding for this PCI device.
type PortConfig ¶
type PortConfig struct {
// PortNumber identifies the port (0 for P0, 1 for P1, etc.)
PortNumber int32 `json:"portNumber"`
// MTU is the MTU value for the port. nil means "no configuration requested, keep current"
MTU *int32 `json:"mtu,omitempty"`
// DHCP configuration for the port. nil when no configuration requested
DHCP *bool `json:"dhcp,omitempty"`
}
PortConfig holds the configuration for a specific network port
type RshimInfo ¶
type RshimInfo struct {
// RshimName is the rshim device name (e.g., "rshim0", "rshim1")
RshimName string
// SecureBootEnabled indicates UEFI Secure Boot status (nil if not found in output)
SecureBootEnabled *bool
// RawOutput contains the full output from rshim for additional parsing if needed
RawOutput string
}
RshimInfo contains comprehensive information from querying a rshim device with DISPLAY_LEVEL 2.
func QueryRshimByPCI ¶
QueryRshimByPCI is a convenience wrapper around RshimQuerier.QueryByPCI for backward compatibility. It uses the default RunBash implementation for bash execution.
For testing with mocked bash commands, use RshimQuerier directly with an injected runBash function.
type RshimQuerier ¶
type RshimQuerier struct {
// contains filtered or unexported fields
}
RshimQuerier provides methods for querying rshim devices with injectable bash execution for testing.
func (*RshimQuerier) QueryByPCI ¶
func (r *RshimQuerier) QueryByPCI(pciAddress string) (*RshimInfo, error)
QueryByPCI finds the rshim device for a given PCI address and queries it with DISPLAY_LEVEL 2. This is the single comprehensive method for all rshim operations to avoid duplication.
DISPLAY_LEVEL 2 returns all available information including:
- PCI address (for device matching)
- UEFI Secure Boot status
- Firmware version, BIOS version, etc.
Args:
- pciAddress: PCI address of the DPU (e.g., "0000:4d:00")
Returns:
- RshimInfo: Comprehensive information from the rshim device
- error: Any error encountered during discovery/query
Usage examples:
- Secure Boot detection: Check info.SecureBootEnabled
- General rshim lookup: Use info.RshimName