Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 102 additions & 5 deletions api/v1/dataprocessingunitconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,124 @@ import (

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// ========== Add: Define supported DPU operation types ==========
type DpuOperationType string

const (
// DpuOpNone No operation (default)
DpuOpNone DpuOperationType = "None"
// DpuOpFirmwareUpgrade Firmware upgrade operation
DpuOpFirmwareUpgrade DpuOperationType = "FirmwareUpgrade"
// DpuOpRestart DPU restart operation (mandatory after firmware upgrade)
DpuOpRestart DpuOperationType = "Reboot"
)

// ========== Add: Define firmware types ==========
type DpuFirmwareType string

const (
// DpuFirmwareTypeOAM OAM type firmware
DpuFirmwareTypeOAM DpuFirmwareType = "OAM"
// DpuFirmwareTypeSDK SDK type firmware
DpuFirmwareTypeSDK DpuFirmwareType = "SDK"
)

type DpuOperationStatusPhase string

const (
// DpuPhasePending Operation pending execution (default)
DpuPhasePending DpuOperationStatusPhase = "Pending"
// DpuPhaseRunning Operation is in progress
DpuPhaseRunning DpuOperationStatusPhase = "Running"
// DpuPhaseSucceeded Operation completed successfully
DpuPhaseSucceeded DpuOperationStatusPhase = "Succeeded"
// DpuPhaseFailed Operation execution failed
DpuPhaseFailed DpuOperationStatusPhase = "Failed"
// DpuPhaseCancelled Operation was cancelled
DpuPhaseCancelled DpuOperationStatusPhase = "Cancelled"
)

// ========== Add: Define OAM firmware configuration ==========
type DpuFirmwareSpec struct {
// Firmware type (OAM/SDK)
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=OAM;SDK
Type DpuFirmwareType `json:"type"`

// Target firmware version number, required
// +kubebuilder:validation:Required
TargetVersion string `json:"targetVersion"`

// Firmware image path/package path (e.g. /quay.io/openshift/firmware/dpu:v1.0.8)
// +kubebuilder:validation:Required
FirmwarePath string `json:"firmwarePath,omitempty"`

}

type DataProcessingUnitManagement struct{
// DPU operation type to execute: None/FirmwareUpgrade/Restart
// Modify this field to trigger the corresponding operation!!!
Operation DpuOperationType `json:"operation,omitempty"`

// Detailed configuration for firmware upgrade, required when Operation is upgrade type
// +kubebuilder:validation:RequiredWhen=Operation,FirmwareUpgrade
Firmware DpuFirmwareSpec `json:"firmware,omitempty"`

}
// DataProcessingUnitConfigSpec defines the desired state of DataProcessingUnitConfig.
type DataProcessingUnitConfigSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// DpuSelector specifies which DPUs this DpuConfig CR should target.
// If empty, the DpuConfig will target all DPUs.
// +optional
//matchLabels: nodeName, pci-address
//pci-address is required. 1 node might have multiple DPUs of the same vendor.
//so the specify the target DPU, pci-address is necessary
DpuSelector *metav1.LabelSelector `json:"dpuSelector,omitempty"`

// Foo is an example field of DataProcessingUnitConfig. Edit dataprocessingunitconfig_types.go to remove/update
Foo string `json:"foo,omitempty"`
//each DPU has 1 specific CR
DpuManagement DataProcessingUnitManagement `json:"dpuManagement,omitempty"`
}

// DataProcessingUnitConfigStatus defines the observed state of DataProcessingUnitConfig.
type DataProcessingUnitConfigStatus struct {
// DpuNodeOperationStatus defines the observed state of DataProcessingUnitConfig.
type DpuNodeOperationStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
NodeName string `json:"nodeName"`

// PciAddress of the target DPU device on this node.
// +optional
PciAddress string `json:"pciAddress,omitempty"`

// Sub-operation type: distinguish between FirmwareUpgrade and Restart
SubOperation DpuOperationType `json:"subOperation"`

// Firmware type (valid only when SubOperation is FirmwareUpgrade): OAM/SDK
FirmwareType DpuFirmwareType `json:"firmwareType,omitempty"`

// Operation execution status: Pending/Running/Succeeded/Failed
Phase cv `json:"phase"`

// Operation start time
StartTime *metav1.Time `json:"startTime,omitempty"`

// Operation completion time
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// Upgrade-related versions (valid only when SubOperation is FirmwareUpgrade)
OriginalVersion string `json:"originalVersion,omitempty"` // Version before upgrade
TargetVersion string `json:"targetVersion,omitempty"` // Target version for upgrade

// Error message (required when operation fails)
ErrorMessage string `json:"errorMessage,omitempty"`
}

type DataProcessingUnitConfigStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
NodeStatus DpuNodeOperationStatus `json:"nodeStatuses,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:shortName=dpuconfig
Expand Down
14 changes: 7 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ func main() {
os.Exit(1)
}
}
if err := (&controller.DataProcessingUnitConfigReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DataProcessingUnitConfig")
os.Exit(1)
}
// if err := (&controller.DataProcessingUnitConfigReconciler{
// Client: mgr.GetClient(),
// Scheme: mgr.GetScheme(),
// }).SetupWithManager(mgr); err != nil {
// setupLog.Error(err, "unable to create controller", "controller", "DataProcessingUnitConfig")
// os.Exit(1)
// }
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
17 changes: 17 additions & 0 deletions dpu-api/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ service NetworkFunctionService {
rpc DeleteNetworkFunction(NFRequest) returns (Empty);
}

service DataProcessingUnitManagementService {
rpc DpuRebootFunction(DPUManagementRequest) returns (DPUManagementResponse);
rpc DpuFirmwareUpgradeFunction(DPUManagementRequest) returns (DPUManagementResponse);
}

message InitRequest {
bool dpu_mode = 1;
string dpu_identifier = 2;
Expand Down Expand Up @@ -67,3 +72,15 @@ message PingResponse {
string responder_id = 2;
bool healthy = 3;
}

message DPUManagementRequest{
string nodeName = 1;
string pciAddress = 2;
string firmwareType = 3;
string firmwareImagePath = 4;
}

message DPUManagementResponse{
string status = 1;
string message = 2;
}
Loading