Skip to content

Commit

Permalink
FS-1123: Flesh out generic config options for supermicro a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
splaspood committed Jun 5, 2024
1 parent e4d8a1e commit a070a21
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 5 deletions.
11 changes: 11 additions & 0 deletions config/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var errUnknownConfigFormat = errors.New("unknown config format")
var errUnknownVendor = errors.New("unknown/unsupported vendor")
var errUnknownSettingType = errors.New("unknown setting type")

var errInvalidBootModeOption = errors.New("invalid BootMode option <LEGACY|UEFI|DUAL>")
var errInvalidSGXOption = errors.New("invalid SGX option <Enabled|Disabled|Software Controlled>")

func UnknownConfigFormatError(format string) error {
return fmt.Errorf("unknown config format %w : %s", errUnknownConfigFormat, format)
}
Expand All @@ -20,3 +23,11 @@ func UnknownSettingType(t string) error {
func UnknownVendorError(vendorName string) error {
return fmt.Errorf("unknown/unsupported vendor %w : %s", errUnknownVendor, vendorName)
}

func InvalidBootModeOption(mode string) error {
return fmt.Errorf("%w : %s", errInvalidBootModeOption, mode)
}

func InvalidSGXOption(mode string) error {
return fmt.Errorf("%w : %s", errInvalidSGXOption, mode)
}
88 changes: 83 additions & 5 deletions config/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,89 @@ func normalizeValue(k, v string) string {

// Generic config options

func (cm *supermicroVendorConfig) EnableTPM() {
cm.Raw(" Security Device Support", "Enable", []string{"Trusted Computing"})
cm.Raw(" SHA-1 PCR Bank", "Enabled", []string{"Trusted Computing"})
func (cm *supermicroVendorConfig) BootMode(mode string) error {
switch strings.ToUpper(mode) {
case "LEGACY", "UEFI", "DUAL":
cm.Raw("Boot mode select", strings.ToUpper(mode), []string{"Boot"})
default:
return InvalidBootModeOption(strings.ToUpper(mode))
}

return nil
}

func (cm *supermicroVendorConfig) BootOrder(mode string) error {
switch strings.ToUpper(mode) {
case "LEGACY":
cm.Raw("Legacy Boot Option #1", "Hard Disk", []string{"Boot"})
cm.Raw("Legacy Boot Option #2", "Network", []string{"Boot"})
for i := 3; i < 8; i++ {
cm.Raw("Legacy Boot Option #"+string(i), "Disabled", []string{"Boot"})
}
case "UEFI":
cm.Raw("UEFI Boot Option #1", "UEFI Hard Disk", []string{"Boot"})
cm.Raw("UEFI Boot Option #2", "UEFI Network", []string{"Boot"})
for i := 3; i < 9; i++ {
cm.Raw("UEFI Boot Option #"+string(i), "Disabled", []string{"Boot"})
}
case "DUAL":
// TODO(jwb) Is this just both sets?
default:
return InvalidBootModeOption(strings.ToUpper(mode))
}

return nil
}

func (cm *supermicroVendorConfig) IntelSGX(mode string) error {
switch mode {
case "Disabled", "Enabled", "Software Controlled":
// TODO(jwb) Path needs to be determined.
cm.Raw("Software Guard Extensions (SGX)", mode, []string{"Advanced", "PCIe/PCI/PnP Configuration"})
default:
return InvalidSGXOption(mode)
}

return nil
}

func (cm *supermicroVendorConfig) SecureBoot(enable bool) error {
if enable {
cm.Raw("Secure Boot", "Enabled", []string{"SMC Secure Boot Configuration"})
// cm.Raw("Secure Boot Mode", "Setup", []string{"SMC Secure Boot Configuration"})
} else {
cm.Raw("Secure Boot", "Disabled", []string{"SMC Secure Boot Configuration"})
}

return nil
}

func (cm *supermicroVendorConfig) TPM(enable bool) error {
if enable {
// Note, this is actually 'Enable' not 'Enabled' like everything else.
cm.Raw(" Security Device Support", "Enable", []string{"Trusted Computing"})
cm.Raw(" SHA-1 PCR Bank", "Enabled", []string{"Trusted Computing"})
} else {
// Note, this is actually 'Disable' not 'Disabled' like everything else.
cm.Raw(" Security Device Support", "Disable", []string{"Trusted Computing"})
cm.Raw(" SHA-1 PCR Bank", "Disabled", []string{"Trusted Computing"})
}

return nil
}

func (cm *supermicroVendorConfig) EnableSRIOV() {
cm.Raw("SR-IOV Support", "Enabled", []string{"Advanced", "PCIe/PCI/PnP Configuration"})
func (cm *supermicroVendorConfig) SMT(enable bool) error {
if enable {
cm.Raw("Hyper-Threading", "Enabled", []string{"Advanced", "CPU Configuration"})
} else {
cm.Raw("Hyper-Threading", "Disabled", []string{"Advanced", "CPU Configuration"})
}

return nil
}

func (cm *supermicroVendorConfig) SRIOV(enable bool) error {
// TODO(jwb) Need to figure out how we do this on platforms that support it...

return nil
}

0 comments on commit a070a21

Please sign in to comment.