|
|
|
|
@@ -3592,7 +3592,7 @@ func parseNIC(doc map[string]interface{}) models.NetworkAdapter {
|
|
|
|
|
}
|
|
|
|
|
if pcieIf, ok := ctrl["PCIeInterface"].(map[string]interface{}); ok && linkWidth == 0 && maxLinkWidth == 0 && linkSpeed == "" && maxLinkSpeed == "" {
|
|
|
|
|
linkWidth = asInt(pcieIf["LanesInUse"])
|
|
|
|
|
maxLinkWidth = asInt(pcieIf["MaxLanes"])
|
|
|
|
|
maxLinkWidth = firstNonZeroInt(asInt(pcieIf["MaxLanes"]), asInt(pcieIf["Maxlanes"]))
|
|
|
|
|
linkSpeed = firstNonEmpty(asString(pcieIf["PCIeType"]), asString(pcieIf["CurrentLinkSpeedGTs"]), asString(pcieIf["CurrentLinkSpeed"]))
|
|
|
|
|
maxLinkSpeed = firstNonEmpty(asString(pcieIf["MaxPCIeType"]), asString(pcieIf["MaxLinkSpeedGTs"]), asString(pcieIf["MaxLinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
@@ -3705,6 +3705,9 @@ func enrichNICFromPCIe(nic *models.NetworkAdapter, pcieDoc map[string]interface{
|
|
|
|
|
if strings.TrimSpace(nic.MaxLinkSpeed) == "" {
|
|
|
|
|
nic.MaxLinkSpeed = firstNonEmpty(asString(pcieDoc["MaxLinkSpeedGTs"]), asString(pcieDoc["MaxLinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
if nic.LinkWidth == 0 || nic.MaxLinkWidth == 0 || nic.LinkSpeed == "" || nic.MaxLinkSpeed == "" {
|
|
|
|
|
redfishEnrichFromOEMxFusionPCIeLink(pcieDoc, &nic.LinkWidth, &nic.MaxLinkWidth, &nic.LinkSpeed, &nic.MaxLinkSpeed)
|
|
|
|
|
}
|
|
|
|
|
if normalizeRedfishIdentityField(nic.SerialNumber) == "" {
|
|
|
|
|
nic.SerialNumber = findFirstNormalizedStringByKeys(pcieDoc, "SerialNumber")
|
|
|
|
|
}
|
|
|
|
|
@@ -3736,6 +3739,9 @@ func enrichNICFromPCIe(nic *models.NetworkAdapter, pcieDoc map[string]interface{
|
|
|
|
|
if strings.TrimSpace(nic.MaxLinkSpeed) == "" {
|
|
|
|
|
nic.MaxLinkSpeed = firstNonEmpty(asString(fn["MaxLinkSpeedGTs"]), asString(fn["MaxLinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
if nic.LinkWidth == 0 || nic.MaxLinkWidth == 0 || nic.LinkSpeed == "" || nic.MaxLinkSpeed == "" {
|
|
|
|
|
redfishEnrichFromOEMxFusionPCIeLink(fn, &nic.LinkWidth, &nic.MaxLinkWidth, &nic.LinkSpeed, &nic.MaxLinkSpeed)
|
|
|
|
|
}
|
|
|
|
|
if normalizeRedfishIdentityField(nic.SerialNumber) == "" {
|
|
|
|
|
nic.SerialNumber = findFirstNormalizedStringByKeys(fn, "SerialNumber")
|
|
|
|
|
}
|
|
|
|
|
@@ -4302,6 +4308,21 @@ func parseGPUWithSupplementalDocs(doc map[string]interface{}, functionDocs []map
|
|
|
|
|
gpu.DeviceID = asHexOrInt(doc["DeviceId"])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if pcieIf, ok := doc["PCIeInterface"].(map[string]interface{}); ok {
|
|
|
|
|
if gpu.CurrentLinkWidth == 0 {
|
|
|
|
|
gpu.CurrentLinkWidth = asInt(pcieIf["LanesInUse"])
|
|
|
|
|
}
|
|
|
|
|
if gpu.MaxLinkWidth == 0 {
|
|
|
|
|
gpu.MaxLinkWidth = firstNonZeroInt(asInt(pcieIf["MaxLanes"]), asInt(pcieIf["Maxlanes"]))
|
|
|
|
|
}
|
|
|
|
|
if gpu.CurrentLinkSpeed == "" {
|
|
|
|
|
gpu.CurrentLinkSpeed = firstNonEmpty(asString(pcieIf["PCIeType"]), asString(pcieIf["CurrentLinkSpeedGTs"]), asString(pcieIf["CurrentLinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
if gpu.MaxLinkSpeed == "" {
|
|
|
|
|
gpu.MaxLinkSpeed = firstNonEmpty(asString(pcieIf["MaxPCIeType"]), asString(pcieIf["MaxLinkSpeedGTs"]), asString(pcieIf["MaxLinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, fn := range functionDocs {
|
|
|
|
|
if gpu.BDF == "" {
|
|
|
|
|
gpu.BDF = sanitizeRedfishBDF(asString(fn["FunctionId"]))
|
|
|
|
|
@@ -4324,6 +4345,9 @@ func parseGPUWithSupplementalDocs(doc map[string]interface{}, functionDocs []map
|
|
|
|
|
if gpu.CurrentLinkSpeed == "" {
|
|
|
|
|
gpu.CurrentLinkSpeed = firstNonEmpty(asString(fn["CurrentLinkSpeedGTs"]), asString(fn["CurrentLinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
if gpu.CurrentLinkWidth == 0 || gpu.MaxLinkWidth == 0 || gpu.CurrentLinkSpeed == "" || gpu.MaxLinkSpeed == "" {
|
|
|
|
|
redfishEnrichFromOEMxFusionPCIeLink(fn, &gpu.CurrentLinkWidth, &gpu.MaxLinkWidth, &gpu.CurrentLinkSpeed, &gpu.MaxLinkSpeed)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if isMissingOrRawPCIModel(gpu.Model) {
|
|
|
|
|
@@ -4384,6 +4408,9 @@ func parsePCIeDeviceWithSupplementalDocs(doc map[string]interface{}, functionDoc
|
|
|
|
|
if dev.MaxLinkSpeed == "" {
|
|
|
|
|
dev.MaxLinkSpeed = firstNonEmpty(asString(fn["MaxLinkSpeedGTs"]), asString(fn["MaxLinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
if dev.LinkWidth == 0 || dev.MaxLinkWidth == 0 || dev.LinkSpeed == "" || dev.MaxLinkSpeed == "" {
|
|
|
|
|
redfishEnrichFromOEMxFusionPCIeLink(fn, &dev.LinkWidth, &dev.MaxLinkWidth, &dev.LinkSpeed, &dev.MaxLinkSpeed)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if dev.DeviceClass == "" || isGenericPCIeClassLabel(dev.DeviceClass) {
|
|
|
|
|
dev.DeviceClass = firstNonEmpty(redfishFirstStringAcrossDocs(supplementalDocs, "DeviceType"), dev.DeviceClass)
|
|
|
|
|
@@ -4633,6 +4660,59 @@ func buildBDFfromOemPublic(doc map[string]interface{}) string {
|
|
|
|
|
return fmt.Sprintf("%04x:%02x:%02x.%x", segment, bus, dev, fn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// redfishEnrichFromOEMxFusionPCIeLink fills in missing PCIe link width/speed
|
|
|
|
|
// from the xFusion OEM namespace. xFusion reports link width as a string like
|
|
|
|
|
// "X8" in Oem.xFusion.LinkWidth / Oem.xFusion.LinkWidthAbility, and link speed
|
|
|
|
|
// as a string like "Gen4 (16.0GT/s)" in Oem.xFusion.LinkSpeed /
|
|
|
|
|
// Oem.xFusion.LinkSpeedAbility. These fields appear on PCIeFunction docs.
|
|
|
|
|
func redfishEnrichFromOEMxFusionPCIeLink(doc map[string]interface{}, linkWidth, maxLinkWidth *int, linkSpeed, maxLinkSpeed *string) {
|
|
|
|
|
oem, _ := doc["Oem"].(map[string]interface{})
|
|
|
|
|
if oem == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
xf, _ := oem["xFusion"].(map[string]interface{})
|
|
|
|
|
if xf == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if *linkWidth == 0 {
|
|
|
|
|
*linkWidth = parseXFusionLinkWidth(asString(xf["LinkWidth"]))
|
|
|
|
|
}
|
|
|
|
|
if *maxLinkWidth == 0 {
|
|
|
|
|
*maxLinkWidth = parseXFusionLinkWidth(asString(xf["LinkWidthAbility"]))
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(*linkSpeed) == "" {
|
|
|
|
|
*linkSpeed = strings.TrimSpace(asString(xf["LinkSpeed"]))
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(*maxLinkSpeed) == "" {
|
|
|
|
|
*maxLinkSpeed = strings.TrimSpace(asString(xf["LinkSpeedAbility"]))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parseXFusionLinkWidth converts an xFusion link-width string like "X8" or
|
|
|
|
|
// "x16" to the integer lane count. Returns 0 for unrecognised values.
|
|
|
|
|
func parseXFusionLinkWidth(s string) int {
|
|
|
|
|
s = strings.TrimSpace(s)
|
|
|
|
|
if s == "" {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
s = strings.TrimPrefix(strings.ToUpper(s), "X")
|
|
|
|
|
v := asInt(s)
|
|
|
|
|
if v <= 0 {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// firstNonZeroInt returns the first argument that is non-zero.
|
|
|
|
|
func firstNonZeroInt(vals ...int) int {
|
|
|
|
|
for _, v := range vals {
|
|
|
|
|
if v != 0 {
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func normalizeRedfishIdentityField(v string) string {
|
|
|
|
|
v = strings.TrimSpace(v)
|
|
|
|
|
if v == "" {
|
|
|
|
|
|