From nobody Mon Feb 9 11:30:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+91783+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91783+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658712968; cv=none; d=zohomail.com; s=zohoarc; b=JZqzQqM+YwXa0+/pIMcplNQXwtfq2td3VfrnSfIecovGo5YAMvfRd48U/dyX3EDj/zk4+mW2fkvf21tK4bSj7zvgLssvdilXQ7BGjq0X8OSlGJHGiAkPlSv7GzHXZbmw9NRci4UN330aC94yEdgC1BbD06YNm8peObd+sdyhA5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658712968; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=nWKxsH2/7VlIiNeRSNPerQODN3y1DYTxjI4GzyutDPs=; b=Iow9XA0ygsNlTST+sIJKlJHBzdxjLsvPFl+xSsKeIQARcfpZLIp9qitcaXoEY7wq95/kDG6QCyAHgQrMPFcDQi8BELEec5XDPYyDbhZoJXd04KHhYYxpGa6gmk/8FgB4Ai51oxAFRa+ellz01aB8hFSg9Pl7tlwAkHxyZOrU6Gk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91783+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1658712968652436.23263029797215; Sun, 24 Jul 2022 18:36:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id pwG7YY1788612xWR1wIYcS9s; Sun, 24 Jul 2022 18:36:08 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web09.23387.1658712967257128419 for ; Sun, 24 Jul 2022 18:36:07 -0700 X-Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26OJTY87027459; Mon, 25 Jul 2022 01:36:05 GMT X-Received: from p1lg14881.it.hpe.com (p1lg14881.it.hpe.com [16.230.97.202]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3hhc971jnk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jul 2022 01:36:05 +0000 X-Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id 6D62B804C9C; Mon, 25 Jul 2022 01:36:04 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 1CCD7800B83; Mon, 25 Jul 2022 01:36:02 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v2 04/15] edk2-staging/RedfishClientPkg: Introduce Redfish resource config library Date: Mon, 25 Jul 2022 09:35:44 +0800 Message-Id: <20220725013555.926-5-nickle.wang@hpe.com> In-Reply-To: <20220725013555.926-1-nickle.wang@hpe.com> References: <20220725013555.926-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 24dIq13aqfBdHCEyYm4LzeS1R9pCegMA X-Proofpoint-GUID: 24dIq13aqfBdHCEyYm4LzeS1R9pCegMA X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nickle.wang@hpe.com X-Gm-Message-State: SOjdaKPNKr1SfQ5dM0ZvmHxyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658712968; bh=HVaqpVlr6bPaowlOSPJ0ZpXaO09GsFdlF6hAMHGw9UI=; h=Cc:Date:From:Reply-To:Subject:To; b=gk0AEchAa9F8NK3FPJFA91Zlkrhxf6B0rgek+JgEJ9hYLllXpSZurySh72vpKID11ZW awtIzgQ5+iHqpic76JMYMcB7nAsAq27lmXH8wA5bva12iozUY7Li6u15if5UGlyxITrvO Y0S/BwJvCOB1JYhGoXfZEvpnqI5NlgTMdnQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658712969952100014 Content-Type: text/plain; charset="utf-8" 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 Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez --- .../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/EdkIIRedfishResourceCo= nfigLib.h create mode 100644 RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchan= geData.h create mode 100644 RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/= EdkIIRedfishResourceConfigLib.c create mode 100644 RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/= EdkIIRedfishResourceConfigLib.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
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_ +#define EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_ + +#include +#include +#include +#include +#include +#include +/** + 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_EXCHANG= E. + @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST 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_EXCHANG= E. + + @retval EFI_SUCCESS This is target resource which we want t= o 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_CONFI= G_LANG_LIST. + + @retval EFI_SUCCESS Configure language is set. + @retval EFI_UNSUPPORTED EdkIIRedfishFeatureInterchangeDataProto= col 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 successfu= lly. + @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 successfu= lly. + @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 in= terface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_ +#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_ + +#include + +typedef struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL EDKII_REDF= ISH_FEATURE_INTERCHANGE_DATA_PROTOCOL; + +#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL_GUID \ + { \ + 0x4B8FF71C, 0x4A7B, 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x= 00, 0x91 } \ + } + +typedef enum { + InformationTypeNone =3D 0, ///< Invalid informatio= n. + InformationTypeCollectionMemberUri, ///< URI to the new creat= ed collection member. + InformationTypeCollectionMemberConfigLanguage, ///< URI to the new creat= ed collection member. + InformationTypeMax +} RESOURCE_INFORMATION_EXCHANGE_TYPE; + +typedef struct { + RESOURCE_INFORMATION_EXCHANGE_TYPE Type; + EFI_STRING ParentUri; ///< The parent URI (in configure lan= guage) of the resource to process. + EFI_STRING PropertyName; ///< The property name of the resourc= e to process. + EFI_STRING FullUri; ///< The full URI (in configure langu= age) 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/EdkIIRe= dfishResourceConfigLib.c b/RedfishClientPkg/Library/EdkIIRedfishResourceCon= figLib/EdkIIRedfishResourceConfigLib.c new file mode 100644 index 0000000000..d09da6bd67 --- /dev/null +++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.c @@ -0,0 +1,593 @@ +/** @file + Redfish resource config library implementation + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *mRedfishResourceConfigProtocol =3D= NULL; +EFI_HANDLE medfishResourceConfigProtocolHandle; +EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL mRedfishFeatureInterchange= Data; +REDFISH_SCHEMA_INFO mSchemaInfoCache; + +#define SCHEMA_NAME_PREFIX_OFFSET 15 // x-uefi-redfish- + +/** + + 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 successfu= lly. + @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 =3D=3D NULL || JsonStructProtocol =3D=3D NULL || IS_E= MPTY_STRING (Uri) || SchemaInfo =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D GetResourceByUri (RedfishService, Uri, &Response); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %s: %r", __FUNCT= ION__, Uri, Status)); + return Status; + } + + Payload =3D Response.Payload; + ASSERT (Payload !=3D NULL); + + JsonText =3D JsonDumpString (RedfishJsonInPayload (Payload), EDKII_JSON_= COMPACT); + ASSERT (JsonText !=3D NULL); + + // + // Convert JSON text to C structure. + // + Status =3D JsonStructProtocol->ToStructure ( + JsonStructProtocol, + NULL, + JsonText, + &Header + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return Status; + } + + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Header->J= sonRsrcIdentifier.NameSpace.ResourceTypeName); + AsciiStrCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.MajorVersion); + AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.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 successfu= lly. + @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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D RedfishPlatformConfigGetSupportedSchema (NULL, &SupportSchema= ); + if (EFI_ERROR (Status)) { + return Status; + } + + DEBUG ((DEBUG_INFO, "Supported schema: %a\n", SupportSchema)); + + Index =3D 0; + Found =3D FALSE; + SchemaName =3D SupportSchema; + while (TRUE) { + + if (SupportSchema[Index] =3D=3D ';' || SupportSchema[Index] =3D=3D '\0= ') { + if (AsciiStrnCmp (&SchemaName[SCHEMA_NAME_PREFIX_OFFSET], Schema, As= ciiStrLen (Schema)) =3D=3D 0) { + Found =3D TRUE; + SupportSchema[Index] =3D '\0'; + break; + } + + SchemaName =3D &SupportSchema[Index + 1]; + } + + if (SupportSchema[Index] =3D=3D '\0') { + break; + } + + ++Index; + } + + if (Found) { + + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Schema); + + // + // forward to '.' + // + Index =3D 0; + while (SchemaName[Index] !=3D '\0' && SchemaName[Index] !=3D '.') { + ++Index; + } + ASSERT (SchemaName[Index] !=3D '\0'); + + // + // Skip '.' and 'v' + // + Index +=3D 2; + + // + // forward to '_' + // + Index2 =3D Index; + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') { + ++Index2; + } + ASSERT (SchemaName[Index2] !=3D '\0'); + + AsciiStrnCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index)); + Index =3D Index2; + + // + // Skip '_' + // + ++Index; + + // + // forward to '_' + // + Index2 =3D Index; + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') { + ++Index2; + } + ASSERT (SchemaName[Index2] !=3D '\0'); + + AsciiStrnCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index)); + Index =3D Index2; + + // + // Skip '_' + // + ++Index; + + AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index]); + } + + FreePool (SupportSchema); + + return (Found ? EFI_SUCCESS : EFI_NOT_FOUND); +} + + +/** + + Find Redfish Resource Config Protocol that supports given schema and ver= sion. + + @param[in] Schema Schema name. + @param[out] Handle Pointer to receive the handle that has EDKII_RED= FISH_RESOURCE_CONFIG_PROTOCOL + installed on it. + + @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to proto= col + @retval NULL No protocol foun= d. + +**/ +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 !=3D NULL) { + if (AsciiStrCmp (Schema->Schema, mSchemaInfoCache.Schema) =3D=3D 0 && + AsciiStrCmp (Schema->Major, mSchemaInfoCache.Major) =3D=3D 0 && + AsciiStrCmp (Schema->Minor, mSchemaInfoCache.Minor) =3D=3D 0 && + AsciiStrCmp (Schema->Errata, mSchemaInfoCache.Errata) =3D=3D 0) { + if (Handle !=3D NULL) { + *Handle =3D medfishResourceConfigProtocolHandle; + } + return mRedfishResourceConfigProtocol; + } + } + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEdkIIRedfishResourceConfigProtocolGuid, + NULL, + &NumberOfHandles, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + Found =3D FALSE; + + for (Index =3D 0; Index < NumberOfHandles; Index++) { + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEdkIIRedfishResourceConfigProtocolGuid, + (VOID **) &Protocol + ); + if (EFI_ERROR (Status)) { + continue; + } + + Status =3D Protocol->GetInfo (Protocol, &SchemaInfo); + if (EFI_ERROR (Status)) { + continue; + } + + if (AsciiStrCmp (Schema->Schema, SchemaInfo.Schema) =3D=3D 0 && + AsciiStrCmp (Schema->Major, SchemaInfo.Major) =3D=3D 0 && + AsciiStrCmp (Schema->Minor, SchemaInfo.Minor) =3D=3D 0 && + AsciiStrCmp (Schema->Errata, SchemaInfo.Errata) =3D=3D 0) { + Found =3D TRUE; + break; + } + } + + if (Found) { + medfishResourceConfigProtocolHandle =3D HandleBuffer[Index]; + mRedfishResourceConfigProtocol =3D Protocol; + CopyMem (&mSchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO)); + if (Handle !=3D NULL) { + *Handle =3D 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_EXCHANG= E. + + @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 =3D gBS->HandleProtocol ( + Handle, + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid, + (VOID **)&Interface + ); + if (!EFI_ERROR (Status)) { + Interface->ResourceInformationExchage =3D InformationExchange; + return EFI_SUCCESS; + } + if (Status =3D=3D EFI_UNSUPPORTED) { + mRedfishFeatureInterchangeData.ResourceInformationExchage =3D Informat= ionExchange; + Status =3D 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_CONFI= G_LANG_LIST. + + @retval EFI_SUCCESS Configure language is set. + @retval EFI_UNSUPPORTED EdkIIRedfishFeatureInterchangeDataProto= col 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 =3D gBS->HandleProtocol ( + medfishResourceConfigProtocolHandle, + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid, + (VOID **)&Interface + ); + if (EFI_ERROR (Status)){ + DEBUG ((DEBUG_ERROR, "%a, EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTO= COL is not installed %r", __FUNCTION__, Status)); + return Status; + } + Interface->ResourceInformationExchage->ReturnedInformation.Type =3D Info= rmationTypeCollectionMemberConfigLanguage; + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLang= uageList.Count =3D ConfigLangList->Count; + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLang= uageList.List =3D + AllocateZeroPool(sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG) * Con= figLangList->Count); + if (Interface->ResourceInformationExchage->ReturnedInformation.Configure= LanguageList.List =3D=3D 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 =3D 0; Index < ConfigLangList->Count; Index++) { + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLa= nguageList.List [Index].Index =3D ConfigLangList->List[Index].Index; + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLa= nguageList.List [Index].ConfigureLang =3D + (EFI_STRING)AllocateCopyPool(StrSize(ConfigLangList->List[Index].Con= figureLang), (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_EXCHANG= E. + @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST 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 =3D GetRedfishResourceConfigProtocol (Schema, &Handle); + if (protocol =3D=3D NULL || Handle =3D=3D 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 =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (protocol =3D=3D 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 =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (protocol =3D=3D 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 =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (protocol =3D=3D 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_EXCHANG= E. + + @retval EFI_SUCCESS This is target resource which we want t= o 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 =3D GetRedfishResourceConfigProtocol (Schema, &Handle); + if (protocol =3D=3D 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 =3D NULL; + ZeroMem (&mSchemaInfoCache, sizeof (REDFISH_SCHEMA_INFO)); + + return EFI_SUCCESS; +} + +/** + Release allocated resource. + + @param[in] ImageHandle Handle that identifies the image to be unlo= aded. + @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 =3D NULL; + + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRe= dfishResourceConfigLib.inf b/RedfishClientPkg/Library/EdkIIRedfishResourceC= onfigLib/EdkIIRedfishResourceConfigLib.inf new file mode 100644 index 0000000000..0da3423d26 --- /dev/null +++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.inf @@ -0,0 +1,49 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D EdkIIRedfishResourceConfigLib + FILE_GUID =3D B41884F6-693B-4ADE-9558-5C220A24A025 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D EdkIIRedfishResourceConfigLib| DXE_DR= IVER + CONSTRUCTOR =3D RedfishResourceConfigConstructor + DESTRUCTOR =3D RedfishResourceConfigDestructor + +# +# VALID_ARCHITECTURES =3D 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/R= edfishContentCodingLibNull.inf ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf =20 + EdkIIRedfishResourceConfigLib|RedfishClientPkg/Library/EdkIIRedfishResou= rceConfigLib/EdkIIRedfishResourceConfigLib.inf RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib= .inf RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVers= ionLib.inf diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.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
+# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -21,6 +21,7 @@ =20 [LibraryClasses] RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h + EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConfig= Lib.h RedfishEventLib|Include/Library/RedfishEventLib.h RedfishVersionLib|Include/Library/RedfishVersionLib.h =20 @@ -36,6 +37,8 @@ gEdkIIRedfishResourceConfigProtocolGuid =3D { 0x6f164c68, 0xfb09, 0x4646= , { 0xa8, 0xd3, 0x24, 0x11, 0x5d, 0xab, 0x3e, 0xe7 } } ## Include/Protocol/EdkiiRedfishETagProtocol.h gEdkIIRedfishETagProtocolGuid =3D { 0x5706d368, 0xaf66, 0x48f5= , { 0x89, 0xfc, 0xa6, 0x61, 0xce, 0xb5, 0xa6, 0xa9 } } + ## Include/Protocol/EdkIIRedfishInterchangeData.h + gEdkIIRedfishFeatureInterchangeDataProtocolGuid =3D { 0x4B8FF71C, 0x4A7B= , 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x00, 0x91 } } =20 [Guids] ## Include/Guid/RedfishClientPkgTokenSpace.h --=20 2.32.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91783): https://edk2.groups.io/g/devel/message/91783 Mute This Topic: https://groups.io/mt/92596785/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-