From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web11.8338.1657628513885338505 for ; Tue, 12 Jul 2022 05:21:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=FlkMAPQv; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0192e24d61=nickle.wang@hpe.com) Received: from pps.filterd (m0148664.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26CC8ZTm009753; Tue, 12 Jul 2022 12:21:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=C4mQ8kvOh7g1RvyhL/ai8dDlVHFU4i32slh3BGNXMcQ=; b=FlkMAPQvDidakyF9G7hMU/DkGriyM4ZiSrXJtWiDG4X8SjoSGRzn4tw49Mm/iXETSOm1 v5E8INgI5L79q2xywH6Q2EaUFtBNsveHpcIUl3XOXvXlE9J5eYqT8WCTRJ+gUqUEoWI6 YKE+vvaAcIwYXG+6qMPfhzxNIPYlesiBEm46IAjFu29Y1qrNv6mBn4NGpN3niN/3gDXo U5/5e2KloJgrShV1GXLSYaBNuQF/4VjbzoGP/lMaFSFoq2JoLZxGSYcBeAJpJ8Vo4Jbz AT8QdcvQr+1c79jI7RmbD3Wz7ICkXFdLc9fesKDBb6q/WVnv3uEbG79ewBxovPKb6EVO Wg== Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3h98pkr47x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 12:21:51 +0000 Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (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 p1lg14880.it.hpe.com (Postfix) with ESMTPS id 2F21380022E; Tue, 12 Jul 2022 12:21:50 +0000 (UTC) Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 2C3B78052F6; Tue, 12 Jul 2022 12:21:49 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-staging][PATCH 04/15] edk2-staging/RedfishClientPkg: Introduce Redfish resource config library Date: Tue, 12 Jul 2022 20:21:32 +0800 Message-Id: <20220712122143.1827-5-nickle.wang@hpe.com> X-Mailer: git-send-email 2.32.0.windows.2 In-Reply-To: <20220712122143.1827-1-nickle.wang@hpe.com> References: <20220712122143.1827-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: adsGRp8SrzGd4gPE1yZ-k3X7bsstMh1f X-Proofpoint-ORIG-GUID: adsGRp8SrzGd4gPE1yZ-k3X7bsstMh1f X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-12_08,2022-07-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207120048 Content-Transfer-Encoding: quoted-printable 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=0D + This file defines the EDKII resource config Library interface.=0D +=0D + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_=0D +#define EDKII_REDFISH_RESOURCE_CONFIG_LIB_H_=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +/**=0D + Provising redfish resource by given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri Target URI to create resource.=0D + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E.=0D + @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST method is used.=0D + FALSE if the resource exist but some of= properties are missing,=0D + HTTP PUT method is used.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigProvisionging (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri,=0D + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,=0D + IN BOOLEAN HttpPostMode=0D + );=0D +=0D +/**=0D + Consume resource from given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri The target URI to consume.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigConsume (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri=0D + );=0D +=0D +=0D +/**=0D + Update resource to given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri The target URI to consume.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigUpdate (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri=0D + );=0D +=0D +=0D +/**=0D + Check resource on given URI.=0D +=0D + @param[in] Uri The target URI to consume.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigCheck (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri=0D + );=0D +=0D +/**=0D + Identify resource on given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri The target URI to consume.=0D + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E.=0D +=0D + @retval EFI_SUCCESS This is target resource which we want t= o handle.=0D + @retval EFI_UNSUPPORTED This is not the target resource.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigIdentify (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri,=0D + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchangeUri=0D + );=0D +=0D +/**=0D + Set Configure language of this resource in the=0D + RESOURCE_INFORMATION_EXCHANGE structure.=0D +=0D + @param[in] ConfigLangList Pointer to REDFISH_FEATURE_ARRAY_TYPE_CONFI= G_LANG_LIST.=0D +=0D + @retval EFI_SUCCESS Configure language is set.=0D + @retval EFI_UNSUPPORTED EdkIIRedfishFeatureInterchangeDataProto= col is not found.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceSetConfigureLang (=0D + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList=0D + );=0D +=0D +/**=0D +=0D + Get schema information by given protocol and service instance.=0D +=0D + @param[in] RedfishService Pointer to Redfish service instance.=0D + @param[in] JsonStructProtocol Json Structure protocol instance.=0D + @param[in] Uri Target URI.=0D + @param[out] SchemaInfo Returned schema information.=0D +=0D + @retval EFI_SUCCESS Schema information is returned successfu= lly.=0D + @retval Others Errors occur.=0D +=0D +**/=0D +EFI_STATUS=0D +GetRedfishSchemaInfo (=0D + IN REDFISH_SERVICE *RedfishService,=0D + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol,=0D + IN EFI_STRING Uri,=0D + OUT REDFISH_SCHEMA_INFO *SchemaInfo=0D + );=0D +=0D +/**=0D +=0D + Get supported schema list by given specify schema name.=0D +=0D + @param[in] Schema Schema type name.=0D + @param[out] SchemaInfo Returned schema information.=0D +=0D + @retval EFI_SUCCESS Schema information is returned successfu= lly.=0D + @retval Others Errors occur.=0D +=0D +**/=0D +EFI_STATUS=0D +GetSupportedSchemaVersion (=0D + IN CHAR8 *Schema,=0D + OUT REDFISH_SCHEMA_INFO *SchemaInfo=0D + );=0D +=0D +#endif=0D 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=0D + This file defines the EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL in= terface.=0D +=0D + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_=0D +#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_=0D +=0D +#include =0D +=0D +typedef struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL EDKII_REDF= ISH_FEATURE_INTERCHANGE_DATA_PROTOCOL;=0D +=0D +#define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL_GUID \=0D + { \=0D + 0x4B8FF71C, 0x4A7B, 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x= 00, 0x91 } \=0D + }=0D +=0D +typedef enum {=0D + InformationTypeNone =3D 0, ///< Invalid informatio= n.=0D + InformationTypeCollectionMemberUri, ///< URI to the new creat= ed collection member.=0D + InformationTypeCollectionMemberConfigLanguage, ///< URI to the new creat= ed collection member.=0D + InformationTypeMax=0D +} RESOURCE_INFORMATION_EXCHANGE_TYPE;=0D +=0D +typedef struct {=0D + RESOURCE_INFORMATION_EXCHANGE_TYPE Type;=0D + EFI_STRING ParentUri; ///< The parent URI (in configure lan= guage) of the resource to process.=0D + EFI_STRING PropertyName; ///< The property name of the resourc= e to process.=0D + EFI_STRING FullUri; ///< The full URI (in configure langu= age) of the resource to process.=0D +} RESOURCE_INFORMATION_SEND;=0D +=0D +typedef struct {=0D + RESOURCE_INFORMATION_EXCHANGE_TYPE Type;=0D + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigureLanguageList;=0D +} RESOURCE_INFORMATION_RETURNED;=0D +=0D +typedef struct {=0D + RESOURCE_INFORMATION_SEND SendInformation;=0D + RESOURCE_INFORMATION_RETURNED ReturnedInformation;=0D +} RESOURCE_INFORMATION_EXCHANGE;=0D +=0D +struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL {=0D + RESOURCE_INFORMATION_EXCHANGE *ResourceInformationExchage;=0D +};=0D +=0D +extern EFI_GUID gEdkIIRedfishFeatureInterchangeDataProtocolGuid;=0D +=0D +#endif=0D 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=0D + Redfish resource config library implementation=0D +=0D + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *mRedfishResourceConfigProtocol =3D= NULL;=0D +EFI_HANDLE medfishResourceConfigProtocolHandle= ;=0D +EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL mRedfishFeatureInterchange= Data;=0D +REDFISH_SCHEMA_INFO mSchemaInfoCache;=0D +=0D +#define SCHEMA_NAME_PREFIX_OFFSET 15 // x-uefi-redfish-=0D +=0D +/**=0D +=0D + Get schema information by given protocol and service instance.=0D +=0D + @param[in] RedfishService Pointer to Redfish service instance.=0D + @param[in] JsonStructProtocol Json Structure protocol instance.=0D + @param[in] Uri Target URI.=0D + @param[out] SchemaInfo Returned schema information.=0D +=0D + @retval EFI_SUCCESS Schema information is returned successfu= lly.=0D + @retval Others Errors occur.=0D +=0D +**/=0D +EFI_STATUS=0D +GetRedfishSchemaInfo (=0D + IN REDFISH_SERVICE *RedfishService,=0D + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol,=0D + IN EFI_STRING Uri,=0D + OUT REDFISH_SCHEMA_INFO *SchemaInfo=0D + )=0D +{=0D + EFI_STATUS Status;=0D + REDFISH_RESPONSE Response;=0D + REDFISH_PAYLOAD Payload;=0D + CHAR8 *JsonText;=0D + EFI_REST_JSON_STRUCTURE_HEADER *Header;=0D +=0D + if (RedfishService =3D=3D NULL || JsonStructProtocol =3D=3D NULL || IS_E= MPTY_STRING (Uri) || SchemaInfo =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D GetResourceByUri (RedfishService, Uri, &Response);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %s: %r", __FUNCT= ION__, Uri, Status));=0D + return Status;=0D + }=0D +=0D + Payload =3D Response.Payload;=0D + ASSERT (Payload !=3D NULL);=0D +=0D + JsonText =3D JsonDumpString (RedfishJsonInPayload (Payload), EDKII_JSON_= COMPACT);=0D + ASSERT (JsonText !=3D NULL);=0D +=0D + //=0D + // Convert JSON text to C structure.=0D + //=0D + Status =3D JsonStructProtocol->ToStructure (=0D + JsonStructProtocol,=0D + NULL,=0D + JsonText,=0D + &Header=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus));=0D + return Status;=0D + }=0D +=0D + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Header->J= sonRsrcIdentifier.NameSpace.ResourceTypeName);=0D + AsciiStrCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.MajorVersion);=0D + AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.MinorVersion);=0D + AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, Header->= JsonRsrcIdentifier.NameSpace.ErrataVersion);=0D +=0D + //=0D + // Release resource.=0D + //=0D + JsonStructProtocol->DestoryStructure (JsonStructProtocol, Header);=0D + FreePool (JsonText);=0D + RedfishFreeResponse (Response.StatusCode, Response.HeaderCount, Response= .Headers, Response.Payload);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D +=0D + Get supported schema list by given specify schema name.=0D +=0D + @param[in] Schema Schema type name.=0D + @param[out] SchemaInfo Returned schema information.=0D +=0D + @retval EFI_SUCCESS Schema information is returned successfu= lly.=0D + @retval Others Errors occur.=0D +=0D +**/=0D +EFI_STATUS=0D +GetSupportedSchemaVersion (=0D + IN CHAR8 *Schema,=0D + OUT REDFISH_SCHEMA_INFO *SchemaInfo=0D + )=0D +{=0D + EFI_STATUS Status;=0D + CHAR8 *SupportSchema;=0D + CHAR8 *SchemaName;=0D + UINTN Index;=0D + UINTN Index2;=0D + BOOLEAN Found;=0D +=0D + if (IS_EMPTY_STRING (Schema) || SchemaInfo =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D RedfishPlatformConfigGetSupportedSchema (NULL, &SupportSchema= );=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + DEBUG ((DEBUG_INFO, "Supported schema: %a\n", SupportSchema));=0D +=0D + Index =3D 0;=0D + Found =3D FALSE;=0D + SchemaName =3D SupportSchema;=0D + while (TRUE) {=0D +=0D + if (SupportSchema[Index] =3D=3D ';' || SupportSchema[Index] =3D=3D '\0= ') {=0D + if (AsciiStrnCmp (&SchemaName[SCHEMA_NAME_PREFIX_OFFSET], Schema, As= ciiStrLen (Schema)) =3D=3D 0) {=0D + Found =3D TRUE;=0D + SupportSchema[Index] =3D '\0';=0D + break;=0D + }=0D +=0D + SchemaName =3D &SupportSchema[Index + 1];=0D + }=0D +=0D + if (SupportSchema[Index] =3D=3D '\0') {=0D + break;=0D + }=0D +=0D + ++Index;=0D + }=0D +=0D + if (Found) {=0D +=0D + AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Schema);= =0D +=0D + //=0D + // forward to '.'=0D + //=0D + Index =3D 0;=0D + while (SchemaName[Index] !=3D '\0' && SchemaName[Index] !=3D '.') {=0D + ++Index;=0D + }=0D + ASSERT (SchemaName[Index] !=3D '\0');=0D +=0D + //=0D + // Skip '.' and 'v'=0D + //=0D + Index +=3D 2;=0D +=0D + //=0D + // forward to '_'=0D + //=0D + Index2 =3D Index;=0D + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') {= =0D + ++Index2;=0D + }=0D + ASSERT (SchemaName[Index2] !=3D '\0');=0D +=0D + AsciiStrnCpyS (SchemaInfo->Major, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index));=0D + Index =3D Index2;=0D +=0D + //=0D + // Skip '_'=0D + //=0D + ++Index;=0D +=0D + //=0D + // forward to '_'=0D + //=0D + Index2 =3D Index;=0D + while (SchemaName[Index2] !=3D '\0' && SchemaName[Index2] !=3D '_') {= =0D + ++Index2;=0D + }=0D + ASSERT (SchemaName[Index2] !=3D '\0');=0D +=0D + AsciiStrnCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index], (Index2 - Index));=0D + Index =3D Index2;=0D +=0D + //=0D + // Skip '_'=0D + //=0D + ++Index;=0D +=0D + AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, &Schema= Name[Index]);=0D + }=0D +=0D + FreePool (SupportSchema);=0D +=0D + return (Found ? EFI_SUCCESS : EFI_NOT_FOUND);=0D +}=0D +=0D +=0D +/**=0D +=0D + Find Redfish Resource Config Protocol that supports given schema and ver= sion.=0D +=0D + @param[in] Schema Schema name.=0D + @param[out] Handle Pointer to receive the handle that has EDKII_RED= FISH_RESOURCE_CONFIG_PROTOCOL=0D + installed on it.=0D +=0D + @retval EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL * Pointer to proto= col=0D + @retval NULL No protocol foun= d.=0D +=0D +**/=0D +EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *=0D +GetRedfishResourceConfigProtocol (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + OUT EFI_HANDLE *Handle OPTIONAL=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_HANDLE *HandleBuffer;=0D + UINTN NumberOfHandles;=0D + UINTN Index;=0D + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *Protocol;=0D + REDFISH_SCHEMA_INFO SchemaInfo;=0D + BOOLEAN Found;=0D +=0D + if (IS_EMPTY_STRING (Schema->Schema) ||=0D + IS_EMPTY_STRING (Schema->Major) ||=0D + IS_EMPTY_STRING (Schema->Minor) ||=0D + IS_EMPTY_STRING (Schema->Errata)=0D + ) {=0D + return NULL;=0D + }=0D +=0D + if (mRedfishResourceConfigProtocol !=3D NULL) {=0D + if (AsciiStrCmp (Schema->Schema, mSchemaInfoCache.Schema) =3D=3D 0 &&= =0D + AsciiStrCmp (Schema->Major, mSchemaInfoCache.Major) =3D=3D 0 &&=0D + AsciiStrCmp (Schema->Minor, mSchemaInfoCache.Minor) =3D=3D 0 &&=0D + AsciiStrCmp (Schema->Errata, mSchemaInfoCache.Errata) =3D=3D 0) {= =0D + if (Handle !=3D NULL) {=0D + *Handle =3D medfishResourceConfigProtocolHandle;=0D + }=0D + return mRedfishResourceConfigProtocol;=0D + }=0D + }=0D +=0D + Status =3D gBS->LocateHandleBuffer (=0D + ByProtocol,=0D + &gEdkIIRedfishResourceConfigProtocolGuid,=0D + NULL,=0D + &NumberOfHandles,=0D + &HandleBuffer=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return NULL;=0D + }=0D +=0D + Found =3D FALSE;=0D +=0D + for (Index =3D 0; Index < NumberOfHandles; Index++) {=0D + Status =3D gBS->HandleProtocol (=0D + HandleBuffer[Index],=0D + &gEdkIIRedfishResourceConfigProtocolGuid,=0D + (VOID **) &Protocol=0D + );=0D + if (EFI_ERROR (Status)) {=0D + continue;=0D + }=0D +=0D + Status =3D Protocol->GetInfo (Protocol, &SchemaInfo);=0D + if (EFI_ERROR (Status)) {=0D + continue;=0D + }=0D +=0D + if (AsciiStrCmp (Schema->Schema, SchemaInfo.Schema) =3D=3D 0 &&=0D + AsciiStrCmp (Schema->Major, SchemaInfo.Major) =3D=3D 0 &&=0D + AsciiStrCmp (Schema->Minor, SchemaInfo.Minor) =3D=3D 0 &&=0D + AsciiStrCmp (Schema->Errata, SchemaInfo.Errata) =3D=3D 0) {=0D + Found =3D TRUE;=0D + break;=0D + }=0D + }=0D +=0D + if (Found) {=0D + medfishResourceConfigProtocolHandle =3D HandleBuffer[Index];=0D + mRedfishResourceConfigProtocol =3D Protocol;=0D + CopyMem (&mSchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO));=0D + if (Handle !=3D NULL) {=0D + *Handle =3D HandleBuffer[Index];=0D + }=0D + }=0D + FreePool(HandleBuffer);=0D +=0D + return (Found ? Protocol : NULL);=0D +}=0D +=0D +/**=0D + Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL=0D + on child feature driver handle.=0D +=0D + @param[in] Handle Handle to install EDKII_REDFISH_FEATURE_INTERCHANGE= _DATA_PROTOCOL.=0D + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +InstallInterchangeDataProtocol (=0D + IN EFI_HANDLE Handle,=0D + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL *Interface;=0D +=0D + Status =3D gBS->HandleProtocol (=0D + Handle,=0D + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid,=0D + (VOID **)&Interface=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Interface->ResourceInformationExchage =3D InformationExchange;=0D + return EFI_SUCCESS;=0D + }=0D + if (Status =3D=3D EFI_UNSUPPORTED) {=0D + mRedfishFeatureInterchangeData.ResourceInformationExchage =3D Informat= ionExchange;=0D + Status =3D gBS->InstallProtocolInterface (=0D + &Handle,=0D + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid,=0D + EFI_NATIVE_INTERFACE,=0D + (VOID *)&mRedfishFeatureInterchangeData=0D + );=0D + }=0D + return Status;=0D +}=0D +=0D +/**=0D + Set Configure language of this resource in the=0D + RESOURCE_INFORMATION_EXCHANGE structure.=0D +=0D + @param[in] ConfigLangList Pointer to REDFISH_FEATURE_ARRAY_TYPE_CONFI= G_LANG_LIST.=0D +=0D + @retval EFI_SUCCESS Configure language is set.=0D + @retval EFI_UNSUPPORTED EdkIIRedfishFeatureInterchangeDataProto= col is not found.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceSetConfigureLang (=0D + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN Index;=0D + EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL *Interface;=0D +=0D + Status =3D gBS->HandleProtocol (=0D + medfishResourceConfigProtocolHandle,=0D + &gEdkIIRedfishFeatureInterchangeDataProtocolGuid,=0D + (VOID **)&Interface=0D + );=0D + if (EFI_ERROR (Status)){=0D + DEBUG ((DEBUG_ERROR, "%a, EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTO= COL is not installed %r", __FUNCTION__, Status));=0D + return Status;=0D + }=0D + Interface->ResourceInformationExchage->ReturnedInformation.Type =3D Info= rmationTypeCollectionMemberConfigLanguage;=0D + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLang= uageList.Count =3D ConfigLangList->Count;=0D + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLang= uageList.List =3D=0D + AllocateZeroPool(sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG) * Con= figLangList->Count);=0D + if (Interface->ResourceInformationExchage->ReturnedInformation.Configure= LanguageList.List =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEATURE_= ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__));=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + for (Index =3D 0; Index < ConfigLangList->Count; Index++) {=0D + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLa= nguageList.List [Index].Index =3D ConfigLangList->List[Index].Index;=0D + Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLa= nguageList.List [Index].ConfigureLang =3D=0D + (EFI_STRING)AllocateCopyPool(StrSize(ConfigLangList->List[Index].Con= figureLang), (VOID *)ConfigLangList->List[Index].ConfigureLang);=0D + }=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Provising redfish resource by given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri Target URI to create resource.=0D + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E.=0D + @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST method is used.=0D + FALSE if the resource exist but some of= properties are missing,=0D + HTTP PUT method is used.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigProvisionging (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri,=0D + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange,=0D + IN BOOLEAN HttpPostMode=0D + )=0D +{=0D + EFI_HANDLE Handle;=0D + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;=0D +=0D + protocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle);=0D + if (protocol =3D=3D NULL || Handle =3D=3D NULL) {=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + //=0D + // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the child= =0D + // feature driver handle.=0D + //=0D + InstallInterchangeDataProtocol (Handle, InformationExchange);=0D + return protocol->Provisioning(protocol, Uri, HttpPostMode);=0D +}=0D +=0D +/**=0D + Consume resource from given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri The target URI to consume.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigConsume (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri=0D + )=0D +{=0D + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;=0D +=0D + protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL);=0D + if (protocol =3D=3D NULL) {=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + return protocol->Consume (protocol, Uri);=0D +}=0D +=0D +=0D +/**=0D + Update resource to given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri The target URI to consume.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigUpdate (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri=0D + )=0D +{=0D + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;=0D +=0D + protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL);=0D + if (protocol =3D=3D NULL) {=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + return protocol->Update (protocol, Uri);=0D +}=0D +=0D +/**=0D + Check resource on given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri The target URI to consume.=0D +=0D + @retval EFI_SUCCESS Value is returned successfully.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigCheck (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri=0D + )=0D +{=0D + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;=0D +=0D + protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL);=0D + if (protocol =3D=3D NULL) {=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + return protocol->Check (protocol, Uri);=0D +}=0D +=0D +/**=0D + Identify resource on given URI.=0D +=0D + @param[in] Schema Redfish schema information.=0D + @param[in] Uri The target URI to consume.=0D + @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E.=0D +=0D + @retval EFI_SUCCESS This is target resource which we want t= o handle.=0D + @retval EFI_UNSUPPORTED This is not the target resource.=0D + @retval Others Some error happened.=0D +=0D +**/=0D +EFI_STATUS=0D +EdkIIRedfishResourceConfigIdentify (=0D + IN REDFISH_SCHEMA_INFO *Schema,=0D + IN EFI_STRING Uri,=0D + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange=0D + )=0D +{=0D + EFI_HANDLE Handle;=0D + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol;=0D +=0D + protocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle);=0D + if (protocol =3D=3D NULL) {=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + //=0D + // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the child= =0D + // feature driver handle.=0D + //=0D + InstallInterchangeDataProtocol (Handle, InformationExchange);=0D + return protocol->Identify (protocol, Uri);=0D +}=0D +=0D +/**=0D +=0D + Initial resource config library instace.=0D +=0D + @param[in] ImageHandle The image handle.=0D + @param[in] SystemTable The system table.=0D +=0D + @retval EFI_SUCEESS Install Boot manager menu success.=0D + @retval Other Return error status.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishResourceConfigConstructor (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + mRedfishResourceConfigProtocol =3D NULL;=0D + ZeroMem (&mSchemaInfoCache, sizeof (REDFISH_SCHEMA_INFO));=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Release allocated resource.=0D +=0D + @param[in] ImageHandle Handle that identifies the image to be unlo= aded.=0D + @param[in] SystemTable The system table.=0D +=0D + @retval EFI_SUCCESS The image has been unloaded.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +RedfishResourceConfigDestructor (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + mRedfishResourceConfigProtocol =3D NULL;=0D +=0D + return EFI_SUCCESS;=0D +}=0D 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=0D +#=0D +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010006=0D + BASE_NAME =3D EdkIIRedfishResourceConfigLib=0D + FILE_GUID =3D B41884F6-693B-4ADE-9558-5C220A24A025= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D EdkIIRedfishResourceConfigLib| DXE_DR= IVER=0D + CONSTRUCTOR =3D RedfishResourceConfigConstructor=0D + DESTRUCTOR =3D RedfishResourceConfigDestructor=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + EdkIIRedfishResourceConfigLib.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + RedfishPkg/RedfishPkg.dec=0D + RedfishClientPkg/RedfishClientPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + DebugLib=0D + UefiBootServicesTableLib=0D + BaseMemoryLib=0D + PcdLib=0D + MemoryAllocationLib=0D + RedfishFeatureUtilityLib=0D + RedfishPlatformConfigLib=0D +=0D +[Protocols]=0D + gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMES ##=0D + gEdkIIRedfishFeatureInterchangeDataProtocolGuid ## CONSUMES ##=0D +=0D +[Pcd]=0D + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize=0D + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize=0D +=0D 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=0D ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf=0D =0D + EdkIIRedfishResourceConfigLib|RedfishClientPkg/Library/EdkIIRedfishResou= rceConfigLib/EdkIIRedfishResourceConfigLib.inf=0D RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib= .inf=0D RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVers= ionLib.inf=0D 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=0D # Redfish Client Package=0D #=0D -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D +# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D ##=0D @@ -21,6 +21,7 @@ =0D [LibraryClasses]=0D RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h=0D + EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConfig= Lib.h=0D RedfishEventLib|Include/Library/RedfishEventLib.h=0D RedfishVersionLib|Include/Library/RedfishVersionLib.h=0D =0D @@ -36,6 +37,8 @@ gEdkIIRedfishResourceConfigProtocolGuid =3D { 0x6f164c68, 0xfb09, 0x4646= , { 0xa8, 0xd3, 0x24, 0x11, 0x5d, 0xab, 0x3e, 0xe7 } }=0D ## Include/Protocol/EdkiiRedfishETagProtocol.h=0D gEdkIIRedfishETagProtocolGuid =3D { 0x5706d368, 0xaf66, 0x48f5= , { 0x89, 0xfc, 0xa6, 0x61, 0xce, 0xb5, 0xa6, 0xa9 } }=0D + ## Include/Protocol/EdkIIRedfishInterchangeData.h=0D + gEdkIIRedfishFeatureInterchangeDataProtocolGuid =3D { 0x4B8FF71C, 0x4A7B= , 0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x00, 0x91 } }=0D =0D [Guids]=0D ## Include/Guid/RedfishClientPkgTokenSpace.h=0D --=20 2.32.0.windows.2