From: "Nickle Wang via groups.io" <nicklew=nvidia.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Abner Chang <abner.chang@amd.com>,
Igor Kulchytskyy <igork@ami.com>,
"Nick Ramirez" <nramirez@nvidia.com>
Subject: [edk2-devel] [edk2-redfish-client][PATCH 5/6] RedfishClientPkg/Features: fix NULL cached handler issue.
Date: Thu, 23 Nov 2023 22:34:19 +0800 [thread overview]
Message-ID: <20231123143419.3612-1-nicklew@nvidia.com> (raw)
EdkIIRedfishResourceSetConfigureLang() uses cached handler to
locate protocol. However, if EdkIIRedfishResourceSetConfigureLang()
is called at non-collection driver, the cached handler is NULL because
cached handler is initialized by collection driver. Since
EdkIIRedfishResourceSetConfigureLang() is in library, the cached handler
is not shared in different drivers. Fix this issue by getting image
handler from caller.
Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
.../Library/EdkIIRedfishResourceConfigLib.h | 9 ++++++---
.../Features/Bios/v1_0_9/Common/BiosCommon.c | 9 +++++----
.../Features/Bios/v1_0_9/Dxe/BiosDxe.c | 3 +--
.../v1_5_0/Common/ComputerSystemCommon.c | 8 +++++---
.../v1_5_0/Dxe/ComputerSystemDxe.c | 3 +--
.../ComputerSystemCollectionDxe.c | 5 +++--
.../Memory/V1_7_1/Common/MemoryCommon.c | 8 +++++---
.../Features/Memory/V1_7_1/Dxe/MemoryDxe.c | 3 +--
.../MemoryCollectionDxe/MemoryCollectionDxe.c | 5 +++--
.../EdkIIRedfishResourceConfigLib.c | 18 ++++++++++++++----
10 files changed, 44 insertions(+), 27 deletions(-)
diff --git a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
index a7856033..c8c9cb86 100644
--- a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
+++ b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
@@ -2,6 +2,7 @@
This file defines the EDKII resource config Library interface.
(C) Copyright 2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -18,7 +19,7 @@
#include <Protocol/EdkIIRedfishInterchangeData.h>
/**
- Provising redfish resource by given URI.
+ Provisioning redfish resource by given URI.
@param[in] Schema Redfish schema information.
@param[in] Uri Target URI to create resource.
@@ -32,7 +33,7 @@
**/
EFI_STATUS
-EdkIIRedfishResourceConfigProvisionging (
+EdkIIRedfishResourceConfigProvisioning (
IN REDFISH_SCHEMA_INFO *Schema,
IN EFI_STRING Uri,
IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,
@@ -109,6 +110,7 @@ EdkIIRedfishResourceConfigIdentify (
Set Configure language of this resource in the
RESOURCE_INFORMATION_EXCHANGE structure.
+ @param[in] ImageHandle Pointer to image handle.
@param[in] ConfigLangList Pointer to REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST.
@retval EFI_SUCCESS Configure language is set.
@@ -118,7 +120,8 @@ EdkIIRedfishResourceConfigIdentify (
**/
EFI_STATUS
EdkIIRedfishResourceSetConfigureLang (
- REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
+ IN EFI_HANDLE ImageHandle,
+ IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
);
/**
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
index 98288d66..ea274018 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
@@ -12,7 +12,8 @@
CHAR8 BiosEmptyJson[] = "{\"@odata.id\": \"\", \"@odata.type\": \"#Bios.v1_0_9.Bios\", \"Id\": \"\", \"Name\": \"\", \"Attributes\":{}}";
-REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = NULL;
+REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = NULL;
+EFI_HANDLE mRedfishResourceConfigProtocolHandle = NULL;
/**
Consume resource from given URI.
@@ -385,7 +386,7 @@ ProvisioningBiosResources (
// Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
// This information is sent back to the parent resource (e.g. the collection driver).
//
- EdkIIRedfishResourceSetConfigureLang (&UnifiedConfigureLangList);
+ EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &UnifiedConfigureLangList);
for (Index = 0; Index < UnifiedConfigureLangList.Count; Index++) {
DEBUG ((DEBUG_MANAGEABILITY, "[%d] create Bios resource from: %s\n", UnifiedConfigureLangList.List[Index].Index, UnifiedConfigureLangList.List[Index].ConfigureLang));
@@ -750,7 +751,7 @@ RedfishIdentifyResourceCommon (
// Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
// This information is sent back to the parent resource (e.g. the collection driver).
//
- EdkIIRedfishResourceSetConfigureLang (&ConfigLangList);
+ EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &ConfigLangList);
DestroyConfiglanguageList (&ConfigLangList);
return EFI_SUCCESS;
}
@@ -817,7 +818,7 @@ HandleResource (
// The target property does not exist, do the provision to create property.
//
DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri));
- Status = EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, Private->InformationExchange, FALSE);
+ Status = EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, Private->InformationExchange, FALSE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", __func__, Status));
}
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
index 9b336d3d..8b9bdc31 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
@@ -11,6 +11,7 @@
#include "../Common/BiosCommon.h"
extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate;
+extern EFI_HANDLE mRedfishResourceConfigProtocolHandle;
EFI_STATUS
HandleResource (
@@ -18,8 +19,6 @@ HandleResource (
IN EFI_STRING Uri
);
-EFI_HANDLE mRedfishResourceConfigProtocolHandle;
-
/**
Provisioning redfish resource by given URI.
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
index 1ffb7d1d..78beb5cb 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
@@ -2,6 +2,7 @@
Redfish feature driver implementation - common functions
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -11,7 +12,8 @@
CHAR8 ComputerSystemEmptyJson[] = "{\"@odata.id\": \"\", \"@odata.type\": \"#ComputerSystem.v1_5_0.ComputerSystem\", \"Id\": \"\", \"Name\": \"\", \"Boot\":{}}";
-REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = NULL;
+REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = NULL;
+EFI_HANDLE mRedfishResourceConfigProtocolHandle = NULL;
/**
Consume resource from given URI.
@@ -1321,7 +1323,7 @@ ProvisioningComputerSystemResources (
// Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
// This information is sent back to the parent resource (e.g. the collection driver).
//
- EdkIIRedfishResourceSetConfigureLang (&UnifiedConfigureLangList);
+ EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &UnifiedConfigureLangList);
for (Index = 0; Index < UnifiedConfigureLangList.Count; Index++) {
DEBUG ((DEBUG_MANAGEABILITY, "[%d] create ComputerSystem resource from: %s\n", UnifiedConfigureLangList.List[Index].Index, UnifiedConfigureLangList.List[Index].ConfigureLang));
@@ -1626,7 +1628,7 @@ RedfishIdentifyResourceCommon (
// Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
// This information is sent back to the parent resource (e.g. the collection driver).
//
- EdkIIRedfishResourceSetConfigureLang (&ConfigLangList);
+ EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &ConfigLangList);
DestroyConfiglanguageList (&ConfigLangList);
return EFI_SUCCESS;
}
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
index 5c2a4ead..4ee72eeb 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
@@ -11,8 +11,7 @@
#include "../Common/ComputerSystemCommon.h"
extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate;
-
-EFI_HANDLE mRedfishResourceConfigProtocolHandle;
+extern EFI_HANDLE mRedfishResourceConfigProtocolHandle;
/**
Provisioning redfish resource by given URI.
diff --git a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
index 1e362d49..5c6850c9 100644
--- a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
+++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
@@ -3,6 +3,7 @@
Redfish feature driver implementation - ComputerSystemCollection
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -95,7 +96,7 @@ HandleResource (
// The target property does not exist, do the provision to create property.
//
DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri));
- Status = EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, Private->InformationExchange, FALSE);
+ Status = EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, Private->InformationExchange, FALSE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", __func__, Status));
}
@@ -226,7 +227,7 @@ CreateCollectionResource (
DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a %a.%a.%a\n", __func__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Errata));
- Status = EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Private->CollectionUri, Private->InformationExchange, TRUE);
+ Status = EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Private->CollectionUri, Private->InformationExchange, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to create resource for: %s: %r\n", __func__, Private->CollectionUri, Status));
}
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
index 4c41f16b..44325ddb 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
@@ -2,6 +2,7 @@
Redfish feature driver implementation - common functions
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -11,7 +12,8 @@
CHAR8 MemoryEmptyJson[] = "{\"@odata.id\": \"\", \"@odata.type\": \"#Memory.v1_7_1.Memory\", \"Id\": \"\", \"Name\": \"\"}";
-REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = NULL;
+REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate = NULL;
+EFI_HANDLE mRedfishResourceConfigProtocolHandle = NULL;
/**
Consume resource from given URI.
@@ -2237,7 +2239,7 @@ ProvisioningMemoryResources (
// Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
// This information is sent back to the parent resource (e.g. the collection driver).
//
- EdkIIRedfishResourceSetConfigureLang (&UnifiedConfigureLangList);
+ EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &UnifiedConfigureLangList);
for (Index = 0; Index < UnifiedConfigureLangList.Count; Index++) {
DEBUG ((DEBUG_MANAGEABILITY, "[%d] create Memory resource from: %s\n", UnifiedConfigureLangList.List[Index].Index, UnifiedConfigureLangList.List[Index].ConfigureLang));
@@ -2542,7 +2544,7 @@ RedfishIdentifyResourceCommon (
// Set the configuration language in the RESOURCE_INFORMATION_EXCHANGE.
// This information is sent back to the parent resource (e.g. the collection driver).
//
- EdkIIRedfishResourceSetConfigureLang (&ConfigLangList);
+ EdkIIRedfishResourceSetConfigureLang (mRedfishResourceConfigProtocolHandle, &ConfigLangList);
DestroyConfiglanguageList (&ConfigLangList);
return EFI_SUCCESS;
}
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
index f34f3266..80bfd6d2 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
@@ -11,8 +11,7 @@
#include "../Common/MemoryCommon.h"
extern REDFISH_RESOURCE_COMMON_PRIVATE *mRedfishResourcePrivate;
-
-EFI_HANDLE mRedfishResourceConfigProtocolHandle;
+extern EFI_HANDLE mRedfishResourceConfigProtocolHandle;
/**
Provisioning redfish resource by given URI.
diff --git a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
index 1b755cde..dc1ee5ca 100644
--- a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
+++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
@@ -3,6 +3,7 @@
Redfish feature driver implementation - MemoryCollection
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -95,7 +96,7 @@ HandleResource (
// The target property does not exist, do the provision to create property.
//
DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri));
- Status = EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, Private->InformationExchange, FALSE);
+ Status = EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, Private->InformationExchange, FALSE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", __func__, Status));
}
@@ -226,7 +227,7 @@ CreateCollectionResource (
DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a %a.%a.%a\n", __func__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Errata));
- Status = EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Private->CollectionUri, Private->InformationExchange, TRUE);
+ Status = EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Private->CollectionUri, Private->InformationExchange, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, failed to create resource for: %s: %r\n", __func__, Private->CollectionUri, Status));
}
diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
index ce86ce70..7a7bb4de 100644
--- a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
+++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
@@ -363,6 +363,7 @@ InstallInterchangeDataProtocol (
Set Configure language of this resource in the
RESOURCE_INFORMATION_EXCHANGE structure.
+ @param[in] ImageHandle Pointer to image handle.
@param[in] ConfigLangList Pointer to REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST.
@retval EFI_SUCCESS Configure language is set.
@@ -372,20 +373,29 @@ InstallInterchangeDataProtocol (
**/
EFI_STATUS
EdkIIRedfishResourceSetConfigureLang (
- REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
+ IN EFI_HANDLE ImageHandle,
+ IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
)
{
EFI_STATUS Status;
UINTN Index;
EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL *Interface;
+ if ((ImageHandle == NULL) || (ConfigLangList == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((ConfigLangList->Count == 0) || (ConfigLangList->List == NULL)) {
+ return EFI_NOT_FOUND;
+ }
+
Status = gBS->HandleProtocol (
- mCachedHandle,
+ ImageHandle,
&gEdkIIRedfishFeatureInterchangeDataProtocolGuid,
(VOID **)&Interface
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a, EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL is not installed %r", __func__, Status));
+ DEBUG ((DEBUG_ERROR, "%a: EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL is not installed on %p: %r\n", __func__, ImageHandle, Status));
return Status;
}
@@ -422,7 +432,7 @@ EdkIIRedfishResourceSetConfigureLang (
**/
EFI_STATUS
-EdkIIRedfishResourceConfigProvisionging (
+EdkIIRedfishResourceConfigProvisioning (
IN REDFISH_SCHEMA_INFO *Schema,
IN EFI_STRING Uri,
IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,
--
2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111676): https://edk2.groups.io/g/devel/message/111676
Mute This Topic: https://groups.io/mt/102767548/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next reply other threads:[~2023-11-23 14:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 14:34 Nickle Wang via groups.io [this message]
2023-11-28 5:16 ` [edk2-devel] [edk2-redfish-client][PATCH 5/6] RedfishClientPkg/Features: fix NULL cached handler issue Chang, Abner via groups.io
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231123143419.3612-1-nicklew@nvidia.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox