diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h index 22a8f9283c..4b13282727 100644 --- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h +++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h @@ -3,6 +3,7 @@ (C) Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -74,4 +75,17 @@ RedfishPlatformHostInterfaceNotification ( OUT EFI_GUID **InformationReadinessGuid ); +/** + Get USB Serial Number. + + @param[OUT] SerialNumber Pointer to retrieve complete serial number. + + @retval EFI_SUCCESS Serial number is returned. + @retval Others Failed to get the serial number. +**/ +EFI_STATUS +RedfishPlatformHostInterfaceSerialNumber ( + OUT CHAR8 **SerialNumber + ); + #endif diff --git a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c index 5c3f8f9c50..a6818c6d23 100644 --- a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c +++ b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c @@ -3,6 +3,7 @@ of USB NIC Device exposed by BMC. Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -1366,3 +1367,20 @@ RedfishPlatformHostInterfaceNotification ( DEBUG ((DEBUG_ERROR, "%a: Something wrong when look for BMC USB NIC.\n", __func__)); return Status; } + +/** + Get USB device serial number. + + @param[out] SerialNumber Pointer to retrieve complete serial number. + It is the responsibility of the caller to free the allocated + memory for serial number. + @retval EFI_SUCCESS Serial number is returned. + @retval Others Failed to get the serial number +**/ +EFI_STATUS +RedfishPlatformHostInterfaceSerialNumber ( + OUT CHAR8 **SerialNumber + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c index 40642469c9..b9eca10229 100644 --- a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c +++ b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c @@ -3,6 +3,7 @@ (C) Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -75,3 +76,20 @@ RedfishPlatformHostInterfaceNotification ( { return EFI_UNSUPPORTED; } + +/** + Get USB device serial number. + + @param[out] SerialNumber Pointer to retrieve complete serial number. + It is the responsibility of the caller to free the allocated + memory for serial number. + @retval EFI_SUCCESS Serial number is returned. + @retval Others Failed to get the serial number +**/ +EFI_STATUS +RedfishPlatformHostInterfaceSerialNumber ( + OUT CHAR8 **SerialNumber + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c index 02d5f14bd2..cc929f2f42 100644 --- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c +++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c @@ -7,12 +7,13 @@ Copyright (c) 2019, Intel Corporation. All rights reserved.
(C) Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023 - 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ +#include #include #include #include @@ -54,8 +55,12 @@ RedfishCreateSmbiosTable42 ( EFI_SMBIOS_PROTOCOL *Smbios; EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle; EFI_HANDLE Handle; + CHAR8 *SerialNumber; + UINTN SerialNumStrLen; - Handle = NULL; + Handle = NULL; + SerialNumStrLen = 0; + SerialNumber = NULL; // // Get platform Redfish host interface device type descriptor data. // @@ -82,6 +87,16 @@ RedfishCreateSmbiosTable42 ( DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length; } else { DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length; + Status = RedfishPlatformHostInterfaceSerialNumber (&SerialNumber); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to get redfish host interface serial number, %r.", __func__, Status)); + DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.SerialNumberStr = 0; + } else { + if (SerialNumber != NULL) { + SerialNumStrLen = (UINTN)AsciiStrLen (SerialNumber); + DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.SerialNumberStr = 1; + } + } } // @@ -167,6 +182,7 @@ RedfishCreateSmbiosTable42 ( + DeviceDataLength + 1 /// For Protocol Record Count + CurrentProtocolsDataLength + + SerialNumStrLen + 2 /// Double NULL terminator/ ); if (Type42Record == NULL) { @@ -208,6 +224,13 @@ RedfishCreateSmbiosTable42 ( CurrentProtocolsDataLength ); + // + // Fill in Serial Number string at the end of SMBIOS table 42 + // + if (SerialNumStrLen) { + CopyMem (Type42Record->InterfaceTypeSpecificData + DeviceDataLength + 1 + CurrentProtocolsDataLength, SerialNumber, SerialNumStrLen); + } + // // 5. Add Redfish interface data record to SMBIOS table 42 // @@ -259,6 +282,10 @@ ON_EXIT: FreePool (Type42Record); } + if (SerialNumber != NULL) { + FreePool (SerialNumber); + } + return Status; }