mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
RedfishPkg: Populate serial number in SMBIOS type 42 record
Add a stub function to read host interface USB serial number, append serial number to SMBIOS type 42 record if valid data is returned. Signed-off-by: Thejaswani Putta <tputta@nvidia.com>
This commit is contained in:
parent
76c282b075
commit
4a055eb486
4 changed files with 79 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
|
||||
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
|
||||
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@
|
|||
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
|
||||
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
|
||||
Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>
|
||||
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.<BR>
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
#include <Base.h>
|
||||
#include <Uefi.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue