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 2/3] RedfishClientPkg/Edk2RedfishResourceConfigLib: support config2 protocol
Date: Mon, 4 Mar 2024 21:26:49 +0800 [thread overview]
Message-ID: <20240304132649.41171-1-nicklew@nvidia.com> (raw)
Support Redfish resource config2 protocol in Edk2RedfishResourceConfigLib.
This library will try Redfish resource config2 protocol first. And if
there is no matching protocol found, Redfish resource config protocol will
be used.
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>
---
.../EdkIIRedfishResourceConfigLib.inf | 4 +-
.../Library/EdkIIRedfishResourceConfigLib.h | 33 +-
.../EdkIIRedfishResourceConfigInternal.h | 44 ++
.../EdkIIRedfishResourceConfigLib.c | 391 ++++++++++++++----
4 files changed, 385 insertions(+), 87 deletions(-)
create mode 100644 RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigInternal.h
diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.inf b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.inf
index 2d10445f0..998a05c80 100644
--- a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.inf
+++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.inf
@@ -22,6 +22,7 @@
#
[Sources]
+ EdkIIRedfishResourceConfigInternal.h
EdkIIRedfishResourceConfigLib.c
[Packages]
@@ -42,8 +43,9 @@
RedfishHttpLib
[Protocols]
- gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMES ##
+ gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMES ##
gEdkIIRedfishFeatureInterchangeDataProtocolGuid ## CONSUMES ##
+ gEdkIIRedfishResourceConfig2ProtocolGuid ## CONSUEMS ##
[Pcd]
gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize
diff --git a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
index 3aa953cec..57c7f2b80 100644
--- a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
+++ b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
@@ -16,6 +16,7 @@
#include <RedfishServiceData.h>
#include <Protocol/RestJsonStructure.h>
#include <Protocol/EdkIIRedfishResourceConfigProtocol.h>
+#include <Protocol/EdkIIRedfishResourceConfig2Protocol.h>
#include <Protocol/EdkIIRedfishInterchangeData.h>
/**
@@ -23,6 +24,7 @@
@param[in] Schema Redfish schema information.
@param[in] Uri Target URI to create resource.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANGE.
@param[in] HttpPostMode TRUE if resource does not exist, HTTP POST method is used.
FALSE if the resource exist but some of properties are missing,
@@ -33,9 +35,11 @@
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigProvisioning (
IN REDFISH_SCHEMA_INFO *Schema,
IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL,
IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,
IN BOOLEAN HttpPostMode
);
@@ -45,15 +49,18 @@ EdkIIRedfishResourceConfigProvisioning (
@param[in] Schema Redfish schema information.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@retval EFI_SUCCESS Value is returned successfully.
@retval Others Some error happened.
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigConsume (
IN REDFISH_SCHEMA_INFO *Schema,
- IN EFI_STRING Uri
+ IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL
);
/**
@@ -61,21 +68,25 @@ EdkIIRedfishResourceConfigConsume (
@param[in] Schema Redfish schema information.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@retval EFI_SUCCESS Value is returned successfully.
@retval Others Some error happened.
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigUpdate (
IN REDFISH_SCHEMA_INFO *Schema,
- IN EFI_STRING Uri
+ IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL
);
/**
Check resource on given URI.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@retval EFI_SUCCESS Value is returned successfully.
@retval EFI_UNSUPPORTED This resource is not owned by feature driver.
@@ -84,9 +95,11 @@ EdkIIRedfishResourceConfigUpdate (
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigCheck (
IN REDFISH_SCHEMA_INFO *Schema,
- IN EFI_STRING Uri
+ IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL
);
/**
@@ -94,6 +107,7 @@ EdkIIRedfishResourceConfigCheck (
@param[in] Schema Redfish schema information.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANGE.
@retval EFI_SUCCESS This is target resource which we want to handle.
@@ -107,10 +121,12 @@ EdkIIRedfishResourceConfigCheck (
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigIdentify (
IN REDFISH_SCHEMA_INFO *Schema,
IN EFI_STRING Uri,
- IN RESOURCE_INFORMATION_EXCHANGE *InformationExchangeUri
+ IN CHAR8 *JsonText OPTIONAL,
+ IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange
);
/**
@@ -126,6 +142,7 @@ EdkIIRedfishResourceConfigIdentify (
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceSetConfigureLang (
IN EFI_HANDLE ImageHandle,
IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
@@ -133,11 +150,14 @@ EdkIIRedfishResourceSetConfigureLang (
/**
- Get schema information by given protocol and service instance.
+ Get schema information by given protocol and service instance if JsonText
+ is NULL or empty. When JsonText is provided by caller, this function read
+ schema information from JsonText.
@param[in] RedfishService Pointer to Redfish service instance.
@param[in] JsonStructProtocol Json Structure protocol instance.
@param[in] Uri Target URI.
+ @param[in] JsonText Redfish data in JSON format. This is optional.
@param[out] SchemaInfo Returned schema information.
@retval EFI_SUCCESS Schema information is returned successfully.
@@ -145,10 +165,12 @@ EdkIIRedfishResourceSetConfigureLang (
**/
EFI_STATUS
+EFIAPI
GetRedfishSchemaInfo (
IN REDFISH_SERVICE *RedfishService,
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol,
IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL,
OUT REDFISH_SCHEMA_INFO *SchemaInfo
);
@@ -164,6 +186,7 @@ GetRedfishSchemaInfo (
**/
EFI_STATUS
+EFIAPI
GetSupportedSchemaVersion (
IN CHAR8 *Schema,
OUT REDFISH_SCHEMA_INFO *SchemaInfo
diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigInternal.h b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigInternal.h
new file mode 100644
index 000000000..51984738b
--- /dev/null
+++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigInternal.h
@@ -0,0 +1,44 @@
+/** @file
+ Header file of EDKII Redfish Resource Config Library.
+
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef REDFISH_RESOURCE_CONFIG_INTERNAL_H_
+#define REDFISH_RESOURCE_CONFIG_INTERNAL_H_
+
+#include <RedfishBase.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/EdkIIRedfishResourceConfigLib.h>
+#include <Library/RedfishFeatureUtilityLib.h>
+#include <Library/RedfishPlatformConfigLib.h>
+#include <Library/RedfishHttpLib.h>
+
+///
+/// Definition of EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOLS
+///
+typedef union {
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol;
+ EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol;
+} EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOLS;
+
+///
+/// Definition of REDFISH_CONFIG_PROTOCOL_CACHE
+///
+typedef struct {
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOLS RedfishResourceConfig;
+ EFI_HANDLE CachedHandle;
+ REDFISH_SCHEMA_INFO SchemaInfoCache;
+} REDFISH_CONFIG_PROTOCOL_CACHE;
+
+#define SCHEMA_NAME_PREFIX "x-uefi-redfish-"
+#define SCHEMA_NAME_PREFIX_OFFSET (AsciiStrLen (SCHEMA_NAME_PREFIX))
+
+#endif
diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
index 5d0944f8c..4ba5c309d 100644
--- a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
+++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
@@ -7,32 +7,23 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#include <RedfishBase.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/EdkIIRedfishResourceConfigLib.h>
-#include <Library/RedfishFeatureUtilityLib.h>
-#include <Library/RedfishHttpLib.h>
-#include <Library/RedfishPlatformConfigLib.h>
-
-EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *mRedfishResourceConfigProtocol = NULL;
-EFI_HANDLE mCachedHandle;
-EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL mRedfishFeatureInterchangeData;
-REDFISH_SCHEMA_INFO mSchemaInfoCache;
-#define SCHEMA_NAME_PREFIX "x-uefi-redfish-"
-#define SCHEMA_NAME_PREFIX_OFFSET (AsciiStrLen (SCHEMA_NAME_PREFIX))
+#include "EdkIIRedfishResourceConfigInternal.h"
+
+REDFISH_CONFIG_PROTOCOL_CACHE *mRedfishResourceConfigCache = NULL;
+REDFISH_CONFIG_PROTOCOL_CACHE *mRedfishResourceConfig2Cache = NULL;
+EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL mRedfishFeatureInterchangeData;
/**
- Get schema information by given protocol and service instance.
+ Get schema information by given protocol and service instance if JsonText
+ is NULL or empty. When JsonText is provided by caller, this function read
+ schema information from JsonText.
@param[in] RedfishService Pointer to Redfish service instance.
@param[in] JsonStructProtocol Json Structure protocol instance.
@param[in] Uri Target URI.
+ @param[in] JsonText Redfish data in JSON format. This is optional.
@param[out] SchemaInfo Returned schema information.
@retval EFI_SUCCESS Schema information is returned successfully.
@@ -40,35 +31,45 @@ REDFISH_SCHEMA_INFO mSchemaInfoCache;
**/
EFI_STATUS
+EFIAPI
GetRedfishSchemaInfo (
IN REDFISH_SERVICE *RedfishService,
IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol,
IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL,
OUT REDFISH_SCHEMA_INFO *SchemaInfo
)
{
EFI_STATUS Status;
REDFISH_RESPONSE Response;
- REDFISH_PAYLOAD Payload;
- CHAR8 *JsonText;
+ CHAR8 *JsonData;
EFI_REST_JSON_STRUCTURE_HEADER *Header;
if ((RedfishService == NULL) || (JsonStructProtocol == NULL) || IS_EMPTY_STRING (Uri) || (SchemaInfo == NULL)) {
return EFI_INVALID_PARAMETER;
}
+ JsonData = NULL;
+ Header = NULL;
ZeroMem (&Response, sizeof (Response));
- Status = RedfishHttpGetResource (RedfishService, Uri, NULL, &Response, TRUE);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %s: %r", __func__, Uri, Status));
- return Status;
- }
+ if (IS_EMPTY_STRING (JsonText)) {
+ Status = RedfishHttpGetResource (RedfishService, Uri, NULL, &Response, TRUE);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: failed to get resource from %s: %r", __func__, Uri, Status));
+ return Status;
+ }
- Payload = Response.Payload;
- ASSERT (Payload != NULL);
+ if (Response.Payload != NULL) {
+ JsonData = JsonDumpString (RedfishJsonInPayload (Response.Payload), EDKII_JSON_COMPACT);
+ }
+ } else {
+ JsonData = AllocateCopyPool (AsciiStrSize (JsonText), JsonText);
+ }
- JsonText = JsonDumpString (RedfishJsonInPayload (Payload), EDKII_JSON_COMPACT);
- ASSERT (JsonText != NULL);
+ if (IS_EMPTY_STRING (JsonData)) {
+ Status = EFI_NOT_FOUND;
+ goto ON_RELEASE;
+ }
//
// Convert JSON text to C structure.
@@ -76,17 +77,12 @@ GetRedfishSchemaInfo (
Status = JsonStructProtocol->ToStructure (
JsonStructProtocol,
NULL,
- JsonText,
+ JsonData,
&Header
);
if (EFI_ERROR (Status)) {
- if (Status == EFI_UNSUPPORTED) {
- DEBUG ((DEBUG_ERROR, "%a, No proper JSON to C structure converter for this Redfish resource.\n", __func__));
- } else {
- DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __func__, Status));
- }
-
- return Status;
+ DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, Status));
+ goto ON_RELEASE;
}
AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Header->JsonRsrcIdentifier.NameSpace.ResourceTypeName);
@@ -94,14 +90,19 @@ GetRedfishSchemaInfo (
AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, Header->JsonRsrcIdentifier.NameSpace.MinorVersion);
AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, Header->JsonRsrcIdentifier.NameSpace.ErrataVersion);
+ON_RELEASE:
//
// Release resource.
//
JsonStructProtocol->DestoryStructure (JsonStructProtocol, Header);
- FreePool (JsonText);
+
+ if (JsonData != NULL) {
+ FreePool (JsonData);
+ }
+
RedfishHttpFreeResponse (&Response);
- return EFI_SUCCESS;
+ return Status;
}
/**
@@ -116,6 +117,7 @@ GetRedfishSchemaInfo (
**/
EFI_STATUS
+EFIAPI
GetSupportedSchemaVersion (
IN CHAR8 *Schema,
OUT REDFISH_SCHEMA_INFO *SchemaInfo
@@ -257,17 +259,17 @@ GetRedfishResourceConfigProtocol (
return NULL;
}
- if (mRedfishResourceConfigProtocol != NULL) {
- if ((AsciiStrCmp (Schema->Schema, mSchemaInfoCache.Schema) == 0) &&
- (AsciiStrCmp (Schema->Major, mSchemaInfoCache.Major) == 0) &&
- (AsciiStrCmp (Schema->Minor, mSchemaInfoCache.Minor) == 0) &&
- (AsciiStrCmp (Schema->Errata, mSchemaInfoCache.Errata) == 0))
+ if ((mRedfishResourceConfigCache != NULL) && (mRedfishResourceConfigCache->RedfishResourceConfig.ConfigProtocol != NULL)) {
+ if ((AsciiStrCmp (Schema->Schema, mRedfishResourceConfigCache->SchemaInfoCache.Schema) == 0) &&
+ (AsciiStrCmp (Schema->Major, mRedfishResourceConfigCache->SchemaInfoCache.Major) == 0) &&
+ (AsciiStrCmp (Schema->Minor, mRedfishResourceConfigCache->SchemaInfoCache.Minor) == 0) &&
+ (AsciiStrCmp (Schema->Errata, mRedfishResourceConfigCache->SchemaInfoCache.Errata) == 0))
{
if (Handle != NULL) {
- *Handle = mCachedHandle;
+ *Handle = mRedfishResourceConfigCache->CachedHandle;
}
- return mRedfishResourceConfigProtocol;
+ return mRedfishResourceConfigCache->RedfishResourceConfig.ConfigProtocol;
}
}
@@ -310,9 +312,116 @@ GetRedfishResourceConfigProtocol (
}
if (Found) {
- mCachedHandle = HandleBuffer[Index];
- mRedfishResourceConfigProtocol = Protocol;
- CopyMem (&mSchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO));
+ if (mRedfishResourceConfigCache != NULL) {
+ mRedfishResourceConfigCache->CachedHandle = HandleBuffer[Index];
+ mRedfishResourceConfigCache->RedfishResourceConfig.ConfigProtocol = Protocol;
+ CopyMem (&mRedfishResourceConfigCache->SchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO));
+ }
+
+ if (Handle != NULL) {
+ *Handle = HandleBuffer[Index];
+ }
+ }
+
+ FreePool (HandleBuffer);
+
+ return (Found ? Protocol : NULL);
+}
+
+/**
+
+ Find Redfish Resource Config2 Protocol that supports given schema and version.
+
+ @param[in] Schema Schema name.
+ @param[out] Handle Pointer to receive the handle that has EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL
+ installed on it.
+
+ @retval EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL * Pointer to protocol
+ @retval NULL No protocol found.
+
+**/
+EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *
+GetRedfishResourceConfig2Protocol (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ OUT EFI_HANDLE *Handle OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Protocol;
+ REDFISH_SCHEMA_INFO SchemaInfo;
+ BOOLEAN Found;
+
+ if (IS_EMPTY_STRING (Schema->Schema) ||
+ IS_EMPTY_STRING (Schema->Major) ||
+ IS_EMPTY_STRING (Schema->Minor) ||
+ IS_EMPTY_STRING (Schema->Errata)
+ )
+ {
+ return NULL;
+ }
+
+ if ((mRedfishResourceConfig2Cache != NULL) && (mRedfishResourceConfig2Cache->RedfishResourceConfig.Config2Protocol != NULL)) {
+ if ((AsciiStrCmp (Schema->Schema, mRedfishResourceConfig2Cache->SchemaInfoCache.Schema) == 0) &&
+ (AsciiStrCmp (Schema->Major, mRedfishResourceConfig2Cache->SchemaInfoCache.Major) == 0) &&
+ (AsciiStrCmp (Schema->Minor, mRedfishResourceConfig2Cache->SchemaInfoCache.Minor) == 0) &&
+ (AsciiStrCmp (Schema->Errata, mRedfishResourceConfig2Cache->SchemaInfoCache.Errata) == 0))
+ {
+ if (Handle != NULL) {
+ *Handle = mRedfishResourceConfig2Cache->CachedHandle;
+ }
+
+ return mRedfishResourceConfig2Cache->RedfishResourceConfig.Config2Protocol;
+ }
+ }
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEdkIIRedfishResourceConfig2ProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ Found = FALSE;
+
+ for (Index = 0; Index < NumberOfHandles; Index++) {
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEdkIIRedfishResourceConfig2ProtocolGuid,
+ (VOID **)&Protocol
+ );
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ Status = Protocol->GetInfo (Protocol, &SchemaInfo);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ if ((AsciiStrCmp (Schema->Schema, SchemaInfo.Schema) == 0) &&
+ (AsciiStrCmp (Schema->Major, SchemaInfo.Major) == 0) &&
+ (AsciiStrCmp (Schema->Minor, SchemaInfo.Minor) == 0) &&
+ (AsciiStrCmp (Schema->Errata, SchemaInfo.Errata) == 0))
+ {
+ Found = TRUE;
+ break;
+ }
+ }
+
+ if (Found) {
+ if (mRedfishResourceConfig2Cache != NULL) {
+ mRedfishResourceConfig2Cache->CachedHandle = HandleBuffer[Index];
+ mRedfishResourceConfig2Cache->RedfishResourceConfig.Config2Protocol = Protocol;
+ CopyMem (&mRedfishResourceConfig2Cache->SchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO));
+ }
+
if (Handle != NULL) {
*Handle = HandleBuffer[Index];
}
@@ -379,6 +488,7 @@ InstallInterchangeDataProtocol (
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceSetConfigureLang (
IN EFI_HANDLE ImageHandle,
IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
@@ -411,7 +521,7 @@ EdkIIRedfishResourceSetConfigureLang (
Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLanguageList.List =
AllocateZeroPool (sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG) * ConfigLangList->Count);
if (Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLanguageList.List == NULL) {
- DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG.\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG.\n", __func__));
return EFI_OUT_OF_RESOURCES;
}
@@ -425,10 +535,11 @@ EdkIIRedfishResourceSetConfigureLang (
}
/**
- Provising redfish resource by given URI.
+ Provision redfish resource by given URI.
@param[in] Schema Redfish schema information.
@param[in] Uri Target URI to create resource.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANGE.
@param[in] HttpPostMode TRUE if resource does not exist, HTTP POST method is used.
FALSE if the resource exist but some of properties are missing,
@@ -439,18 +550,41 @@ EdkIIRedfishResourceSetConfigureLang (
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigProvisioning (
IN REDFISH_SCHEMA_INFO *Schema,
IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL,
IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,
IN BOOLEAN HttpPostMode
)
{
- EFI_HANDLE Handle;
- EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+ EFI_HANDLE Handle;
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol;
+ EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol;
- protocol = GetRedfishResourceConfigProtocol (Schema, &Handle);
- if ((protocol == NULL) || (Handle == NULL)) {
+ //
+ // Initialization.
+ //
+ Handle = NULL;
+ ConfigProtocol = NULL;
+ Config2Protocol = NULL;
+
+ //
+ // Try to use config2 protocol first.
+ //
+ Config2Protocol = GetRedfishResourceConfig2Protocol (Schema, &Handle);
+ if ((Config2Protocol != NULL) && (Handle != NULL)) {
+ //
+ // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the child
+ // feature driver handle.
+ //
+ InstallInterchangeDataProtocol (Handle, InformationExchange);
+ return Config2Protocol->Provisioning (Config2Protocol, Uri, JsonText, HttpPostMode);
+ }
+
+ ConfigProtocol = GetRedfishResourceConfigProtocol (Schema, &Handle);
+ if ((ConfigProtocol == NULL) || (Handle == NULL)) {
return EFI_DEVICE_ERROR;
}
@@ -459,7 +593,7 @@ EdkIIRedfishResourceConfigProvisioning (
// feature driver handle.
//
InstallInterchangeDataProtocol (Handle, InformationExchange);
- return protocol->Provisioning (protocol, Uri, HttpPostMode);
+ return ConfigProtocol->Provisioning (ConfigProtocol, Uri, HttpPostMode);
}
/**
@@ -467,25 +601,43 @@ EdkIIRedfishResourceConfigProvisioning (
@param[in] Schema Redfish schema information.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@retval EFI_SUCCESS Value is returned successfully.
@retval Others Some error happened.
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigConsume (
IN REDFISH_SCHEMA_INFO *Schema,
- IN EFI_STRING Uri
+ IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL
)
{
- EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol;
+ EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol;
- protocol = GetRedfishResourceConfigProtocol (Schema, NULL);
- if (protocol == NULL) {
+ //
+ // Initialization.
+ //
+ ConfigProtocol = NULL;
+ Config2Protocol = NULL;
+
+ //
+ // Try to use config2 protocol first.
+ //
+ Config2Protocol = GetRedfishResourceConfig2Protocol (Schema, NULL);
+ if (Config2Protocol != NULL) {
+ return Config2Protocol->Consume (Config2Protocol, Uri, JsonText);
+ }
+
+ ConfigProtocol = GetRedfishResourceConfigProtocol (Schema, NULL);
+ if (ConfigProtocol == NULL) {
return EFI_DEVICE_ERROR;
}
- return protocol->Consume (protocol, Uri);
+ return ConfigProtocol->Consume (ConfigProtocol, Uri);
}
/**
@@ -493,25 +645,43 @@ EdkIIRedfishResourceConfigConsume (
@param[in] Schema Redfish schema information.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@retval EFI_SUCCESS Value is returned successfully.
@retval Others Some error happened.
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigUpdate (
IN REDFISH_SCHEMA_INFO *Schema,
- IN EFI_STRING Uri
+ IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL
)
{
- EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol;
+ EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol;
+
+ //
+ // Initialization.
+ //
+ ConfigProtocol = NULL;
+ Config2Protocol = NULL;
- protocol = GetRedfishResourceConfigProtocol (Schema, NULL);
- if (protocol == NULL) {
+ //
+ // Try to use config2 protocol first.
+ //
+ Config2Protocol = GetRedfishResourceConfig2Protocol (Schema, NULL);
+ if (Config2Protocol != NULL) {
+ return Config2Protocol->Update (Config2Protocol, Uri, JsonText);
+ }
+
+ ConfigProtocol = GetRedfishResourceConfigProtocol (Schema, NULL);
+ if (ConfigProtocol == NULL) {
return EFI_DEVICE_ERROR;
}
- return protocol->Update (protocol, Uri);
+ return ConfigProtocol->Update (ConfigProtocol, Uri);
}
/**
@@ -519,25 +689,43 @@ EdkIIRedfishResourceConfigUpdate (
@param[in] Schema Redfish schema information.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@retval EFI_SUCCESS Value is returned successfully.
@retval Others Some error happened.
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigCheck (
IN REDFISH_SCHEMA_INFO *Schema,
- IN EFI_STRING Uri
+ IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL
)
{
- EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol;
+ EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol;
+
+ //
+ // Initialization.
+ //
+ ConfigProtocol = NULL;
+ Config2Protocol = NULL;
+
+ //
+ // Try to use config2 protocol first.
+ //
+ Config2Protocol = GetRedfishResourceConfig2Protocol (Schema, NULL);
+ if (Config2Protocol != NULL) {
+ return Config2Protocol->Check (Config2Protocol, Uri, JsonText);
+ }
- protocol = GetRedfishResourceConfigProtocol (Schema, NULL);
- if (protocol == NULL) {
+ ConfigProtocol = GetRedfishResourceConfigProtocol (Schema, NULL);
+ if (ConfigProtocol == NULL) {
return EFI_DEVICE_ERROR;
}
- return protocol->Check (protocol, Uri);
+ return ConfigProtocol->Check (ConfigProtocol, Uri);
}
/**
@@ -545,6 +733,7 @@ EdkIIRedfishResourceConfigCheck (
@param[in] Schema Redfish schema information.
@param[in] Uri The target URI to consume.
+ @param[in] JsonText The JSON data in ASCII string format. This is optional.
@param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANGE.
@retval EFI_SUCCESS This is target resource which we want to handle.
@@ -553,17 +742,40 @@ EdkIIRedfishResourceConfigCheck (
**/
EFI_STATUS
+EFIAPI
EdkIIRedfishResourceConfigIdentify (
IN REDFISH_SCHEMA_INFO *Schema,
IN EFI_STRING Uri,
+ IN CHAR8 *JsonText OPTIONAL,
IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange
)
{
- EFI_HANDLE Handle;
- EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+ EFI_HANDLE Handle;
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol;
+ EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol;
+
+ //
+ // Initialization.
+ //
+ Handle = NULL;
+ ConfigProtocol = NULL;
+ Config2Protocol = NULL;
+
+ //
+ // Try to use config2 protocol first.
+ //
+ Config2Protocol = GetRedfishResourceConfig2Protocol (Schema, &Handle);
+ if ((Config2Protocol != NULL) && (Handle != NULL)) {
+ //
+ // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the child
+ // feature driver handle.
+ //
+ InstallInterchangeDataProtocol (Handle, InformationExchange);
+ return Config2Protocol->Identify (Config2Protocol, Uri, JsonText);
+ }
- protocol = GetRedfishResourceConfigProtocol (Schema, &Handle);
- if (protocol == NULL) {
+ ConfigProtocol = GetRedfishResourceConfigProtocol (Schema, &Handle);
+ if (ConfigProtocol == NULL) {
return EFI_DEVICE_ERROR;
}
@@ -572,17 +784,17 @@ EdkIIRedfishResourceConfigIdentify (
// feature driver handle.
//
InstallInterchangeDataProtocol (Handle, InformationExchange);
- return protocol->Identify (protocol, Uri);
+ return ConfigProtocol->Identify (ConfigProtocol, Uri);
}
/**
- Initial resource config library instace.
+ Initial resource config library instance.
@param[in] ImageHandle The image handle.
@param[in] SystemTable The system table.
- @retval EFI_SUCEESS Install Boot manager menu success.
+ @retval EFI_SUCCESS Install Boot manager menu success.
@retval Other Return error status.
**/
@@ -593,8 +805,17 @@ RedfishResourceConfigConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- mRedfishResourceConfigProtocol = NULL;
- ZeroMem (&mSchemaInfoCache, sizeof (REDFISH_SCHEMA_INFO));
+ mRedfishResourceConfigCache = AllocateZeroPool (sizeof (REDFISH_CONFIG_PROTOCOL_CACHE));
+ if (mRedfishResourceConfigCache == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ mRedfishResourceConfig2Cache = AllocateZeroPool (sizeof (REDFISH_CONFIG_PROTOCOL_CACHE));
+ if (mRedfishResourceConfig2Cache == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ ZeroMem (&mRedfishFeatureInterchangeData, sizeof (mRedfishFeatureInterchangeData));
return EFI_SUCCESS;
}
@@ -615,7 +836,15 @@ RedfishResourceConfigDestructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- mRedfishResourceConfigProtocol = NULL;
+ if (mRedfishResourceConfigCache != NULL) {
+ FreePool (mRedfishResourceConfigCache);
+ mRedfishResourceConfigCache = NULL;
+ }
+
+ if (mRedfishResourceConfig2Cache != NULL) {
+ FreePool (mRedfishResourceConfig2Cache);
+ mRedfishResourceConfig2Cache = NULL;
+ }
return EFI_SUCCESS;
}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116316): https://edk2.groups.io/g/devel/message/116316
Mute This Topic: https://groups.io/mt/104721512/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next reply other threads:[~2024-03-04 13:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 13:26 Nickle Wang via groups.io [this message]
2024-03-06 6:12 ` [edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg/Edk2RedfishResourceConfigLib: support config2 protocol 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=20240304132649.41171-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