Re: [edk2-staging][PATCH v2 04/15] edk2-staging/RedfishClientPkg: Introduce Redfish resource config library


Chang, Abner
 

[AMD Official Use Only - General]

Comment in line.

-----Original Message-----
From: Nickle Wang <nickle.wang@...>
Sent: Monday, July 25, 2022 9:36 AM
To: devel@edk2.groups.io
Cc: Chang, Abner <Abner.Chang@...>; Yang, Atom
<Atom.Yang@...>; Nick Ramirez <nramirez@...>
Subject: [edk2-staging][PATCH v2 04/15] edk2-staging/RedfishClientPkg:
Introduce Redfish resource config library

[CAUTION: External Email]

Add EdkIIRedfishResourceConfigLib in order to work with Redfish Config
Protocol and do the communication between each feature drivers. Also
introduce Redfish interchange data protocol to exchange data efficiently.

Signed-off-by: Nickle Wang <nickle.wang@...>
Cc: Abner Chang <abner.chang@...>
Cc: Yang Atom <Atom.Yang@...>
Cc: Nick Ramirez <nramirez@...>
---
.../Library/EdkIIRedfishResourceConfigLib.h | 163 +++++
.../Protocol/EdkIIRedfishInterchangeData.h | 52 ++
.../EdkIIRedfishResourceConfigLib.c | 593 ++++++++++++++++++
.../EdkIIRedfishResourceConfigLib.inf | 49 ++
RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 +
RedfishClientPkg/RedfishClientPkg.dec | 5 +-
6 files changed, 862 insertions(+), 1 deletion(-) create mode 100644
RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
create mode 100644
RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
create mode 100644
RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceC
onfigLib.c
create mode 100644
RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceC
onfigLib.inf

diff --git a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
new file mode 100644
index 0000000000..1e843ec551
--- /dev/null
+++ b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h
@@ -0,0 +1,163 @@
+/** @file
+ This file defines the EDKII resource config Library interface.
+
+ (C) Copyright 2022 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_
+#define EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_
+
+#include <Uefi.h>
+#include <Library/PcdLib.h>
+#include <Library/RedfishLib.h>
+#include <Protocol/RestJsonStructure.h> #include
+<Protocol/EdkIIRedfishResourceConfigProtocol.h>
+#include <Protocol/EdkIIRedfishInterchangeData.h>
+/**
+ Provising redfish resource by given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri Target URI to create resource.
+ @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,
+ HTTP PUT method is used.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigProvisionging (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri,
+ IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,
+ IN BOOLEAN HttpPostMode
+ );
+
+/**
+ Consume resource from given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri The target URI to consume.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigConsume (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri
+ );
+
+
+/**
+ Update resource to given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri The target URI to consume.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigUpdate (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri
+ );
+
+
+/**
+ Check resource on given URI.
+
+ @param[in] Uri The target URI to consume.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigCheck (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri
+ );
+
+/**
+ Identify resource on given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri The target URI to consume.
+ @param[in] InformationExchange Pointer to
RESOURCE_INFORMATION_EXCHANGE.
+
+ @retval EFI_SUCCESS This is target resource which we want to handle.
+ @retval EFI_UNSUPPORTED This is not the target resource.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigIdentify (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri,
+ IN RESOURCE_INFORMATION_EXCHANGE *InformationExchangeUri
+ );
+
+/**
+ Set Configure language of this resource in the
+ RESOURCE_INFORMATION_EXCHANGE structure.
+
+ @param[in] ConfigLangList Pointer to
REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST.
+
+ @retval EFI_SUCCESS Configure language is set.
+ @retval EFI_UNSUPPORTED
EdkIIRedfishFeatureInterchangeDataProtocol is not found.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceSetConfigureLang (
+ REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
+ );
+
+/**
+
+ Get schema information by given protocol and service instance.
+
+ @param[in] RedfishService Pointer to Redfish service instance.
+ @param[in] JsonStructProtocol Json Structure protocol instance.
+ @param[in] Uri Target URI.
+ @param[out] SchemaInfo Returned schema information.
+
+ @retval EFI_SUCCESS Schema information is returned successfully.
+ @retval Others Errors occur.
+
+**/
+EFI_STATUS
+GetRedfishSchemaInfo (
+ IN REDFISH_SERVICE *RedfishService,
+ IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol,
+ IN EFI_STRING Uri,
+ OUT REDFISH_SCHEMA_INFO *SchemaInfo
+ );
+
+/**
+
+ Get supported schema list by given specify schema name.
+
+ @param[in] Schema Schema type name.
+ @param[out] SchemaInfo Returned schema information.
+
+ @retval EFI_SUCCESS Schema information is returned successfully.
+ @retval Others Errors occur.
+
+**/
+EFI_STATUS
+GetSupportedSchemaVersion (
+ IN CHAR8 *Schema,
+ OUT REDFISH_SCHEMA_INFO *SchemaInfo
+ );
+
+#endif
diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
new file mode 100644
index 0000000000..e8d0462fb7
--- /dev/null
+++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
@@ -0,0 +1,52 @@
+/** @file
+ This file defines the
EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL interface.
+
+ (C) Copyright 2022 Hewlett Packard Enterprise Development LP<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_
+#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_
+
+#include <Library/RedfishFeatureUtilityLib.h>
+
+typedef struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL
+EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL;
+
+#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL_GUID \
+ { \
+ 0x4B8FF71C, 0x4A7B, 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x00,
0x91 } \
+ }
+
+typedef enum {
+ InformationTypeNone = 0, ///< Invalid information.
+ InformationTypeCollectionMemberUri, ///< URI to the new created
collection member.
+ InformationTypeCollectionMemberConfigLanguage, ///< URI to the new
created collection member.
+ InformationTypeMax
+} RESOURCE_INFORMATION_EXCHANGE_TYPE;
+
+typedef struct {
+ RESOURCE_INFORMATION_EXCHANGE_TYPE Type;
+ EFI_STRING ParentUri; ///< The parent URI (in configure language) of
the resource to process.
+ EFI_STRING PropertyName; ///< The property name of the resource to
process.
+ EFI_STRING FullUri; ///< The full URI (in configure language) of the
resource to process.
+} RESOURCE_INFORMATION_SEND;
+
+typedef struct {
+ RESOURCE_INFORMATION_EXCHANGE_TYPE Type;
+ REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST
ConfigureLanguageList; }
+RESOURCE_INFORMATION_RETURNED;
+
+typedef struct {
+ RESOURCE_INFORMATION_SEND SendInformation;
+ RESOURCE_INFORMATION_RETURNED ReturnedInformation;
+} RESOURCE_INFORMATION_EXCHANGE;
+
+struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL {
+ RESOURCE_INFORMATION_EXCHANGE *ResourceInformationExchage; };
+
+extern EFI_GUID gEdkIIRedfishFeatureInterchangeDataProtocolGuid;
+
+#endif
diff --git
a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourc
eConfigLib.c
b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourc
eConfigLib.c
new file mode 100644
index 0000000000..d09da6bd67
--- /dev/null
+++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfis
+++ hResourceConfigLib.c
@@ -0,0 +1,593 @@
+/** @file
+ Redfish resource config library implementation
+
+ (C) Copyright 2022 Hewlett Packard Enterprise Development LP<BR>
+
+ 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/RedfishPlatformConfigLib.h>
+
+EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL
*mRedfishResourceConfigProtocol = NULL;
+EFI_HANDLE medfishResourceConfigProtocolHandle;
+EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL
mRedfishFeatureInterchangeData;
+REDFISH_SCHEMA_INFO mSchemaInfoCache;
+
+#define SCHEMA_NAME_PREFIX_OFFSET 15 // x-uefi-redfish-
Could we define a string macro for "x-uefi-redfish-" and use strlen to obtain the length of schema name prefix in code?
Abner

+
+/**
+
+ Get schema information by given protocol and service instance.
+
+ @param[in] RedfishService Pointer to Redfish service instance.
+ @param[in] JsonStructProtocol Json Structure protocol instance.
+ @param[in] Uri Target URI.
+ @param[out] SchemaInfo Returned schema information.
+
+ @retval EFI_SUCCESS Schema information is returned successfully.
+ @retval Others Errors occur.
+
+**/
+EFI_STATUS
+GetRedfishSchemaInfo (
+ IN REDFISH_SERVICE *RedfishService,
+ IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol,
+ IN EFI_STRING Uri,
+ OUT REDFISH_SCHEMA_INFO *SchemaInfo
+ )
+{
+ EFI_STATUS Status;
+ REDFISH_RESPONSE Response;
+ REDFISH_PAYLOAD Payload;
+ CHAR8 *JsonText;
+ EFI_REST_JSON_STRUCTURE_HEADER *Header;
+
+ if (RedfishService == NULL || JsonStructProtocol == NULL ||
IS_EMPTY_STRING (Uri) || SchemaInfo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = GetResourceByUri (RedfishService, Uri, &Response); if
+ (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %s: %r",
__FUNCTION__, Uri, Status));
+ return Status;
+ }
+
+ Payload = Response.Payload;
+ ASSERT (Payload != NULL);
+
+ JsonText = JsonDumpString (RedfishJsonInPayload (Payload),
+ EDKII_JSON_COMPACT); ASSERT (JsonText != NULL);
+
+ //
+ // Convert JSON text to C structure.
+ //
+ Status = JsonStructProtocol->ToStructure (
+ JsonStructProtocol,
+ NULL,
+ JsonText,
+ &Header
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__,
Status));
+ return Status;
+ }
+
+ AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE,
+ Header->JsonRsrcIdentifier.NameSpace.ResourceTypeName);
+ AsciiStrCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE,
+ Header->JsonRsrcIdentifier.NameSpace.MajorVersion);
+ AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE,
+ Header->JsonRsrcIdentifier.NameSpace.MinorVersion);
+ AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE,
+ Header->JsonRsrcIdentifier.NameSpace.ErrataVersion);
+
+ //
+ // Release resource.
+ //
+ JsonStructProtocol->DestoryStructure (JsonStructProtocol, Header);
+ FreePool (JsonText); RedfishFreeResponse (Response.StatusCode,
+ Response.HeaderCount, Response.Headers, Response.Payload);
+
+ return EFI_SUCCESS;
+}
+
+/**
+
+ Get supported schema list by given specify schema name.
+
+ @param[in] Schema Schema type name.
+ @param[out] SchemaInfo Returned schema information.
+
+ @retval EFI_SUCCESS Schema information is returned successfully.
+ @retval Others Errors occur.
+
+**/
+EFI_STATUS
+GetSupportedSchemaVersion (
+ IN CHAR8 *Schema,
+ OUT REDFISH_SCHEMA_INFO *SchemaInfo
+ )
+{
+ EFI_STATUS Status;
+ CHAR8 *SupportSchema;
+ CHAR8 *SchemaName;
+ UINTN Index;
+ UINTN Index2;
+ BOOLEAN Found;
+
+ if (IS_EMPTY_STRING (Schema) || SchemaInfo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = RedfishPlatformConfigGetSupportedSchema (NULL,
+ &SupportSchema); if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ DEBUG ((DEBUG_INFO, "Supported schema: %a\n", SupportSchema));
+
+ Index = 0;
+ Found = FALSE;
+ SchemaName = SupportSchema;
+ while (TRUE) {
+
+ if (SupportSchema[Index] == ';' || SupportSchema[Index] == '\0') {
+ if (AsciiStrnCmp (&SchemaName[SCHEMA_NAME_PREFIX_OFFSET], Schema,
AsciiStrLen (Schema)) == 0) {
+ Found = TRUE;
+ SupportSchema[Index] = '\0';
+ break;
+ }
+
+ SchemaName = &SupportSchema[Index + 1];
+ }
+
+ if (SupportSchema[Index] == '\0') {
+ break;
+ }
+
+ ++Index;
+ }
+
+ if (Found) {
+
+ AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE,
+ Schema);
+
+ //
+ // forward to '.'
+ //
+ Index = 0;
+ while (SchemaName[Index] != '\0' && SchemaName[Index] != '.') {
+ ++Index;
+ }
+ ASSERT (SchemaName[Index] != '\0');
+
+ //
+ // Skip '.' and 'v'
+ //
+ Index += 2;
+
+ //
+ // forward to '_'
+ //
+ Index2 = Index;
+ while (SchemaName[Index2] != '\0' && SchemaName[Index2] != '_') {
+ ++Index2;
+ }
+ ASSERT (SchemaName[Index2] != '\0');
+
+ AsciiStrnCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE,
&SchemaName[Index], (Index2 - Index));
+ Index = Index2;
+
+ //
+ // Skip '_'
+ //
+ ++Index;
+
+ //
+ // forward to '_'
+ //
+ Index2 = Index;
+ while (SchemaName[Index2] != '\0' && SchemaName[Index2] != '_') {
+ ++Index2;
+ }
+ ASSERT (SchemaName[Index2] != '\0');
+
+ AsciiStrnCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE,
&SchemaName[Index], (Index2 - Index));
+ Index = Index2;
+
+ //
+ // Skip '_'
+ //
+ ++Index;
+
+ AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE,
+ &SchemaName[Index]); }
+
+ FreePool (SupportSchema);
+
+ return (Found ? EFI_SUCCESS : EFI_NOT_FOUND); }
+
+
+/**
+
+ Find Redfish Resource Config 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_CONFIG_PROTOCOL
+ installed on it.
+
+ @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to
protocol
+ @retval NULL No protocol found.
+
+**/
+EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *
+GetRedfishResourceConfigProtocol (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ OUT EFI_HANDLE *Handle OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Index;
+ EDKII_REDFISH_RESOURCE_CONFIG_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 (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 (Handle != NULL) {
+ *Handle = medfishResourceConfigProtocolHandle;
+ }
+ return mRedfishResourceConfigProtocol;
+ }
+ }
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEdkIIRedfishResourceConfigProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ Found = FALSE;
+
+ for (Index = 0; Index < NumberOfHandles; Index++) {
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEdkIIRedfishResourceConfigProtocolGuid,
+ (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) {
+ medfishResourceConfigProtocolHandle = HandleBuffer[Index];
+ mRedfishResourceConfigProtocol = Protocol;
+ CopyMem (&mSchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO));
+ if (Handle != NULL) {
+ *Handle = HandleBuffer[Index];
+ }
+ }
+ FreePool(HandleBuffer);
+
+ return (Found ? Protocol : NULL);
+}
+
+/**
+ Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL
+ on child feature driver handle.
+
+ @param[in] Handle Handle to install
EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL.
+ @param[in] InformationExchange Pointer to
RESOURCE_INFORMATION_EXCHANGE.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+InstallInterchangeDataProtocol (
+ IN EFI_HANDLE Handle,
+ IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange
+ )
+{
+ EFI_STATUS Status;
+ EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL *Interface;
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEdkIIRedfishFeatureInterchangeDataProtocolGuid,
+ (VOID **)&Interface
+ );
+ if (!EFI_ERROR (Status)) {
+ Interface->ResourceInformationExchage = InformationExchange;
+ return EFI_SUCCESS;
+ }
+ if (Status == EFI_UNSUPPORTED) {
+ mRedfishFeatureInterchangeData.ResourceInformationExchage =
InformationExchange;
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gEdkIIRedfishFeatureInterchangeDataProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ (VOID *)&mRedfishFeatureInterchangeData
+ );
+ }
+ return Status;
+}
+
+/**
+ Set Configure language of this resource in the
+ RESOURCE_INFORMATION_EXCHANGE structure.
+
+ @param[in] ConfigLangList Pointer to
REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST.
+
+ @retval EFI_SUCCESS Configure language is set.
+ @retval EFI_UNSUPPORTED
EdkIIRedfishFeatureInterchangeDataProtocol is not found.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceSetConfigureLang (
+ REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL *Interface;
+
+ Status = gBS->HandleProtocol (
+ medfishResourceConfigProtocolHandle,
+ &gEdkIIRedfishFeatureInterchangeDataProtocolGuid,
+ (VOID **)&Interface
+ );
+ if (EFI_ERROR (Status)){
+ DEBUG ((DEBUG_ERROR, "%a,
EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL is not installed %r",
__FUNCTION__, Status));
+ return Status;
+ }
+ Interface->ResourceInformationExchage->ReturnedInformation.Type =
+InformationTypeCollectionMemberConfigLanguage;
+
+Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLan
+guageList.Count = ConfigLangList->Count;
+ 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", __FUNCTION__));
+ return EFI_OUT_OF_RESOURCES;
+ }
+ for (Index = 0; Index < ConfigLangList->Count; Index++) {
+ Interface->ResourceInformationExchage-
ReturnedInformation.ConfigureLanguageList.List [Index].Index =
ConfigLangList->List[Index].Index;
+ Interface->ResourceInformationExchage-
ReturnedInformation.ConfigureLanguageList.List [Index].ConfigureLang =
+
+(EFI_STRING)AllocateCopyPool(StrSize(ConfigLangList->List[Index].Config
+ureLang), (VOID *)ConfigLangList->List[Index].ConfigureLang);
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Provising redfish resource by given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri Target URI to create resource.
+ @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,
+ HTTP PUT method is used.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigProvisionging (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri,
+ IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,
+ IN BOOLEAN HttpPostMode
+ )
+{
+ EFI_HANDLE Handle;
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+
+ protocol = GetRedfishResourceConfigProtocol (Schema, &Handle); if
+ (protocol == NULL || Handle == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the
+child
+ // feature driver handle.
+ //
+ InstallInterchangeDataProtocol (Handle, InformationExchange);
+ return protocol->Provisioning(protocol, Uri, HttpPostMode); }
+
+/**
+ Consume resource from given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri The target URI to consume.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigConsume (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri
+ )
+{
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+
+ protocol = GetRedfishResourceConfigProtocol (Schema, NULL); if
+ (protocol == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return protocol->Consume (protocol, Uri); }
+
+
+/**
+ Update resource to given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri The target URI to consume.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigUpdate (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri
+ )
+{
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+
+ protocol = GetRedfishResourceConfigProtocol (Schema, NULL); if
+ (protocol == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return protocol->Update (protocol, Uri); }
+
+/**
+ Check resource on given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri The target URI to consume.
+
+ @retval EFI_SUCCESS Value is returned successfully.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigCheck (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri
+ )
+{
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+
+ protocol = GetRedfishResourceConfigProtocol (Schema, NULL); if
+ (protocol == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return protocol->Check (protocol, Uri); }
+
+/**
+ Identify resource on given URI.
+
+ @param[in] Schema Redfish schema information.
+ @param[in] Uri The target URI to consume.
+ @param[in] InformationExchange Pointer to
RESOURCE_INFORMATION_EXCHANGE.
+
+ @retval EFI_SUCCESS This is target resource which we want to handle.
+ @retval EFI_UNSUPPORTED This is not the target resource.
+ @retval Others Some error happened.
+
+**/
+EFI_STATUS
+EdkIIRedfishResourceConfigIdentify (
+ IN REDFISH_SCHEMA_INFO *Schema,
+ IN EFI_STRING Uri,
+ IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange
+ )
+{
+ EFI_HANDLE Handle;
+ EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;
+
+ protocol = GetRedfishResourceConfigProtocol (Schema, &Handle); if
+ (protocol == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the
+child
+ // feature driver handle.
+ //
+ InstallInterchangeDataProtocol (Handle, InformationExchange);
+ return protocol->Identify (protocol, Uri); }
+
+/**
+
+ Initial resource config library instace.
+
+ @param[in] ImageHandle The image handle.
+ @param[in] SystemTable The system table.
+
+ @retval EFI_SUCEESS Install Boot manager menu success.
+ @retval Other Return error status.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceConfigConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ mRedfishResourceConfigProtocol = NULL;
+ ZeroMem (&mSchemaInfoCache, sizeof (REDFISH_SCHEMA_INFO));
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Release allocated resource.
+
+ @param[in] ImageHandle Handle that identifies the image to be unloaded.
+ @param[in] SystemTable The system table.
+
+ @retval EFI_SUCCESS The image has been unloaded.
+
+**/
+EFI_STATUS
+EFIAPI
+RedfishResourceConfigDestructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ mRedfishResourceConfigProtocol = NULL;
+
+ return EFI_SUCCESS;
+}
diff --git
a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourc
eConfigLib.inf
b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourc
eConfigLib.inf
new file mode 100644
index 0000000000..0da3423d26
--- /dev/null
+++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfis
+++ hResourceConfigLib.inf
@@ -0,0 +1,49 @@
+## @file
+#
+# (C) Copyright 2022 Hewlett Packard Enterprise Development LP<BR> # #
+SPDX-License-Identifier: BSD-2-Clause-Patent # ##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = EdkIIRedfishResourceConfigLib
+ FILE_GUID = B41884F6-693B-4ADE-9558-5C220A24A025
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = EdkIIRedfishResourceConfigLib| DXE_DRIVER
+ CONSTRUCTOR = RedfishResourceConfigConstructor
+ DESTRUCTOR = RedfishResourceConfigDestructor
+
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ EdkIIRedfishResourceConfigLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ RedfishPkg/RedfishPkg.dec
+ RedfishClientPkg/RedfishClientPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ UefiBootServicesTableLib
+ BaseMemoryLib
+ PcdLib
+ MemoryAllocationLib
+ RedfishFeatureUtilityLib
+ RedfishPlatformConfigLib
+
+[Protocols]
+ gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMES ##
+ gEdkIIRedfishFeatureInterchangeDataProtocolGuid ## CONSUMES ##
+
+[Pcd]
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize
+ gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize
+
diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc
b/RedfishClientPkg/RedfishClientLibs.dsc.inc
index 1cf0406912..8acb479170 100644
--- a/RedfishClientPkg/RedfishClientLibs.dsc.inc
+++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc
@@ -28,5 +28,6 @@

RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/Red
fishContentCodingLibNull.inf

ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo
mmonLib/ConverterCommonLib.inf

+
+ EdkIIRedfishResourceConfigLib|RedfishClientPkg/Library/EdkIIRedfishRes
+ ourceConfigLib/EdkIIRedfishResourceConfigLib.inf
RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf

RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLi
b.inf
diff --git a/RedfishClientPkg/RedfishClientPkg.dec
b/RedfishClientPkg/RedfishClientPkg.dec
index 2ce51d14af..9d18c42c24 100644
--- a/RedfishClientPkg/RedfishClientPkg.dec
+++ b/RedfishClientPkg/RedfishClientPkg.dec
@@ -1,7 +1,7 @@
## @file
# Redfish Client Package
#
-# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
+# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -21,6 +21,7 @@

[LibraryClasses]
RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h
+
+ EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConf
+ igLib.h
RedfishEventLib|Include/Library/RedfishEventLib.h
RedfishVersionLib|Include/Library/RedfishVersionLib.h

@@ -36,6 +37,8 @@
gEdkIIRedfishResourceConfigProtocolGuid = { 0x6f164c68, 0xfb09, 0x4646,
{ 0xa8, 0xd3, 0x24, 0x11, 0x5d, 0xab, 0x3e, 0xe7 } }
## Include/Protocol/EdkiiRedfishETagProtocol.h
gEdkIIRedfishETagProtocolGuid = { 0x5706d368, 0xaf66, 0x48f5, { 0x89,
0xfc, 0xa6, 0x61, 0xce, 0xb5, 0xa6, 0xa9 } }
+ ## Include/Protocol/EdkIIRedfishInterchangeData.h
+ gEdkIIRedfishFeatureInterchangeDataProtocolGuid = { 0x4B8FF71C,
+ 0x4A7B, 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x00, 0x91 } }

[Guids]
## Include/Guid/RedfishClientPkgTokenSpace.h
--
2.32.0.windows.2

Join devel@edk2.groups.io to automatically receive all group messages.