From b2c4294c496e6f06125fa48df223448ba8375118 Mon Sep 17 00:00:00 2001 From: Nickle Wang Date: Thu, 24 Apr 2025 10:40:20 +0800 Subject: [PATCH] RedfishPkg: introduce platform wanted device lib Introduce platform wanted device lib to RedfishPkg. This library provide the flexibility for platform owner to device which device we like to support Redfish service. This helps to reduce boot time and resource on devices that is not host interface. A null library is implemented and it accepts all devices as default behavior. Signed-off-by: Nickle Wang --- .../Library/RedfishPlatformWantedDeviceLib.h | 37 +++++++++++++++++ .../RedfishPlatformWantedDeviceLibNull.c | 41 +++++++++++++++++++ .../RedfishPlatformWantedDeviceLibNull.inf | 28 +++++++++++++ RedfishPkg/RedfishPkg.dec | 7 +++- RedfishPkg/RedfishPkg.dsc | 4 +- 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 RedfishPkg/Include/Library/RedfishPlatformWantedDeviceLib.h create mode 100644 RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.c create mode 100644 RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.inf diff --git a/RedfishPkg/Include/Library/RedfishPlatformWantedDeviceLib.h b/RedfishPkg/Include/Library/RedfishPlatformWantedDeviceLib.h new file mode 100644 index 0000000000..31d4c93886 --- /dev/null +++ b/RedfishPkg/Include/Library/RedfishPlatformWantedDeviceLib.h @@ -0,0 +1,37 @@ +/** @file + Definitions of RedfishPlatformWantedDeviceLib. + + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_PLATFORM_WANTED_DEVICE_LIB_H_ +#define REDFISH_PLATFORM_WANTED_DEVICE_LIB_H_ + +#include + +/** + This is the function to decide if input controller is the device + that platform want to support. By returning EFI_UNSUPPORTED to + caller (normally Supported function), caller should ignore this device + and do not provide Redfish service on this controller. + + @param[in] ControllerHandle The handle of the controller to test. + @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. + This is optional. + + @retval EFI_SUCCESS This is the device supported by platform. + @retval EFI_UNSUPPORTED This device is not supported by platform. + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. + +**/ +EFI_STATUS +EFIAPI +IsPlatformWantedDevice ( + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +#endif diff --git a/RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.c b/RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.c new file mode 100644 index 0000000000..11ae0607ee --- /dev/null +++ b/RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.c @@ -0,0 +1,41 @@ +/** @file + NULL instace of RedfishPlatformWantedDeviceLib + + Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include + +/** + This is the function to decide if input controller is the device + that platform want to support. By returning EFI_UNSUPPORTED to + caller (normally Supported function), caller should ignore this device + and do not provide Redfish service on this controller. + + @param[in] ControllerHandle The handle of the controller to test. + @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. + This is optional. + + @retval EFI_SUCCESS This is the device supported by platform. + @retval EFI_UNSUPPORTED This device is not supported by platform. + @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. + +**/ +EFI_STATUS +EFIAPI +IsPlatformWantedDevice ( + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + if (ControllerHandle == NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // Always support Redfish on ControllerHandle. + // + return EFI_SUCCESS; +} diff --git a/RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.inf b/RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.inf new file mode 100644 index 0000000000..1cad2950ec --- /dev/null +++ b/RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.inf @@ -0,0 +1,28 @@ +## @file +# NULL instance of RedfishPlatformWantedDeviceLib +# +# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x0001000b + BASE_NAME = RedfishPlatformWantedDeviceLibNull + FILE_GUID = C5AEFFCA-3692-401E-8F82-9FFAA0622E45 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = RedfishPlatformWantedDeviceLib + +# +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 RISCV64 +# + +[Sources] + RedfishPlatformWantedDeviceLibNull.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec index f80c6795ae..88f84adcb3 100644 --- a/RedfishPkg/RedfishPkg.dec +++ b/RedfishPkg/RedfishPkg.dec @@ -4,7 +4,7 @@ # Copyright (c) 2019, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
# Copyright (c) 2023, American Megatrends International LLC. -# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -75,6 +75,11 @@ # RedfishHttpLib|Include/Library/RedfishHttpLib.h + ## @libraryclass Provides the library functions for platform to decide + # if this is the device platform supported. + # + RedfishPlatformWantedDeviceLib|Include/Library/RedfishPlatformWantedDeviceLib.h + [LibraryClasses.Common.Private] ## @libraryclass Provides the private C runtime library functions. # CRT library is currently used by edk2 JsonLib (open source diff --git a/RedfishPkg/RedfishPkg.dsc b/RedfishPkg/RedfishPkg.dsc index 789f0408b5..5412cc23f2 100644 --- a/RedfishPkg/RedfishPkg.dsc +++ b/RedfishPkg/RedfishPkg.dsc @@ -4,7 +4,7 @@ # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett-Packard Enterprise Development LP. # Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. -# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2023-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -47,6 +47,7 @@ RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf + RedfishPlatformWantedDeviceLib|RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.inf # NULL instance of IPMI related library. IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf @@ -67,5 +68,6 @@ RedfishPkg/Library/HiiUtilityLib/HiiUtilityLib.inf RedfishPkg/Library/RedfishPlatformConfigLib/RedfishPlatformConfigLib.inf RedfishPkg/Library/RedfishHttpLib/RedfishHttpLib.inf + RedfishPkg/Library/RedfishPlatformWantedDeviceLibNull/RedfishPlatformWantedDeviceLibNull.inf !include RedfishPkg/Redfish.dsc.inc