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.web10.8351.1657628514346447038 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=QM5RSkQW; 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 (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26CC8VfN007655; Tue, 12 Jul 2022 12:21:52 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=qPkYDEcprCN/cmgsQmWC1H2eABcV1IyefrAoR0H6668=; b=QM5RSkQW8CFB5BEqtj7s0paLUWEVUvYGAHszXSu3XV5UOSw0Mk3hLeQOY5j6zO1Q65e4 xZWbbLP/c/nzB6uneWE7BeDscQyIamAEsy+zrqGitScJPZvVDiLyicze4JFOq30itYw/ aXJYnlfOee5sywpWO81Ue/sqUqdvqqw3fC3RCkJptolMzsr80nDvA3i/aA2eKeUkUva3 KuQHKgdEPUD3Mm+eobSwE2WUt3KRN+o+8nqr7yyIhS0z3XIGo5lXS5coNM0WqEtdreDM 6d6Ww9AYHjgUhLr/3ZC4dV/IXnl8eVvdZBNtaYXP4iPEZZxtiEmxfhK4aXuxzd7Kmvpg Ow== Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3h98pp03yf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 12:21:52 +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 819BD80022F; Tue, 12 Jul 2022 12:21:51 +0000 (UTC) Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 7CCAC802BDD; Tue, 12 Jul 2022 12:21:50 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-staging][PATCH 05/15] edk2-staging/RedfishClientPkg: Introduce resource identify library Date: Tue, 12 Jul 2022 20:21:33 +0800 Message-Id: <20220712122143.1827-6-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: X_QSC_lCCQXwzliiy_4oTNJxWVDW4RZb X-Proofpoint-ORIG-GUID: X_QSC_lCCQXwzliiy_4oTNJxWVDW4RZb 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 impostorscore=0 mlxlogscore=910 mlxscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207120048 Content-Transfer-Encoding: quoted-printable Introduce resource identify library which works with resource config protocol to identify Redfish resource. This library provides the flexibility for platform to implement its own policy and identify resource. Two library implementation are provided as demonstration code. NULL version of library accepts all Redfish resource and another implementation to computer system resource uses UUID to identify Redfish resource. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez --- .../Library/RedfishResourceIdentifyLib.h | 29 ++++ .../RedfishResourceIdentifyLibComuterSystem.c | 164 ++++++++++++++++++ ...edfishResourceIdentifyLibComuterSystem.inf | 42 +++++ .../RedfishResourceIdentifyLibNull.c | 37 ++++ .../RedfishResourceIdentifyLibNull.inf | 37 ++++ RedfishClientPkg/RedfishClientLibs.dsc.inc | 2 +- RedfishClientPkg/RedfishClientPkg.dec | 1 + 7 files changed, 311 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/Include/Library/RedfishResourceIdentif= yLib.h create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibComu= terSystem/v1_5_0/RedfishResourceIdentifyLibComuterSystem.c create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibComu= terSystem/v1_5_0/RedfishResourceIdentifyLibComuterSystem.inf create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibNull= /RedfishResourceIdentifyLibNull.c create mode 100644 RedfishClientPkg/Library/RedfishResourceIdentifyLibNull= /RedfishResourceIdentifyLibNull.inf diff --git a/RedfishClientPkg/Include/Library/RedfishResourceIdentifyLib.h = b/RedfishClientPkg/Include/Library/RedfishResourceIdentifyLib.h new file mode 100644 index 0000000000..91d01b7d68 --- /dev/null +++ b/RedfishClientPkg/Include/Library/RedfishResourceIdentifyLib.h @@ -0,0 +1,29 @@ +/** @file=0D + This file defines the Redfish resource identify 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 REDFISH_RESOURCE_IDENTIFY_LIB_H_=0D +#define REDFISH_RESOURCE_IDENTIFY_LIB_H_=0D +=0D +/**=0D + Identify resource from given URI and context in JSON format=0D +=0D + @param[in] Uri URI of given Redfish resource=0D + @param[in] Json Context in JSON format of give Redfish resource=0D +=0D + @retval TRUE This is the Redfish resource that we have to handle.= =0D + @retval FALSE We don't handle this Redfish resource.=0D +=0D +**/=0D +BOOLEAN=0D +RedfishIdentifyResource (=0D + IN EFI_STRING Uri,=0D + IN CHAR8 *Json=0D + );=0D +=0D +#endif=0D diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSyst= em/v1_5_0/RedfishResourceIdentifyLibComuterSystem.c b/RedfishClientPkg/Libr= ary/RedfishResourceIdentifyLibComuterSystem/v1_5_0/RedfishResourceIdentifyL= ibComuterSystem.c new file mode 100644 index 0000000000..e5699f194c --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSystem/v1_5= _0/RedfishResourceIdentifyLibComuterSystem.c @@ -0,0 +1,164 @@ +/** @file=0D + Redfish resource identify library implementation for computer system ver= sion 1.5.0=0D +=0D + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +#include =0D +=0D +#include =0D +=0D +EFI_REST_JSON_STRUCTURE_PROTOCOL *mJsonStructProtocol =3D NULL;=0D +=0D +/**=0D + Identify resource from given URI and context in JSON format=0D +=0D + @param[in] Uri URI of given Redfish resource=0D + @param[in] Json Context in JSON format of give Redfish resource=0D +=0D + @retval TRUE This is the Redfish resource that we have to handle.= =0D + @retval FALSE We don't handle this Redfish resource.=0D +=0D +**/=0D +BOOLEAN=0D +RedfishIdentifyResource (=0D + IN EFI_STRING Uri,=0D + IN CHAR8 *Json=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *ComputerSystem;=0D + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS *ComputerSystemCs;=0D + EFI_GUID SystemUuid;=0D + EFI_GUID ResourceUuid;=0D +=0D + if (IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Json)) {=0D + return FALSE;=0D + }=0D +=0D + if (mJsonStructProtocol =3D=3D NULL) {=0D + return FALSE;=0D + }=0D +=0D + ComputerSystem =3D NULL;=0D + ComputerSystemCs =3D NULL;=0D +=0D + Status =3D mJsonStructProtocol->ToStructure (=0D + mJsonStructProtocol,=0D + NULL,=0D + Json,=0D + (EFI_REST_JSON_STRUCTURE_HEADER **)&Comp= uterSystem=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus));=0D + return FALSE;=0D + }=0D +=0D + ComputerSystemCs =3D ComputerSystem->ComputerSystem;=0D +=0D + if (IS_EMPTY_STRING (ComputerSystemCs->UUID)) {=0D + return FALSE;=0D + }=0D +=0D + Status =3D AsciiStrToGuid (ComputerSystemCs->UUID, &ResourceUuid);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, fail to get resource UUID: %r\n", __FUNCTION= __, Status));=0D + return FALSE;=0D + }=0D +=0D + Status =3D NetLibGetSystemGuid (&SystemUuid);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, fail to get system UUID from SMBIOS: %r\n", = __FUNCTION__, Status));=0D + return FALSE;=0D + }=0D +=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a, Identify: System: %g Resource: %g\n", = __FUNCTION__, &SystemUuid, &ResourceUuid));=0D + if (CompareGuid (&ResourceUuid, &SystemUuid)) {=0D + Status =3D EFI_SUCCESS;=0D + } else {=0D + Status =3D EFI_UNSUPPORTED;=0D + }=0D +=0D + mJsonStructProtocol->DestoryStructure (=0D + mJsonStructProtocol,=0D + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem=0D + );=0D +=0D + return (Status =3D=3D EFI_SUCCESS ? TRUE : FALSE);=0D +}=0D +=0D +/**=0D + Callback function when gEfiRestJsonStructureProtocolGuid is installed.=0D +=0D + @param[in] Event Event whose notification function is being invoked.= =0D + @param[in] Context Pointer to the notification function's context.=0D +**/=0D +VOID=0D +EFIAPI=0D +RestJasonStructureProtocolIsReady=0D + (=0D + IN EFI_EVENT Event,=0D + IN VOID *Context=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + if (mJsonStructProtocol !=3D NULL) {=0D + return;=0D + }=0D +=0D + Status =3D gBS->LocateProtocol (=0D + &gEfiRestJsonStructureProtocolGuid,=0D + NULL,=0D + (VOID **)&mJsonStructProtocol=0D + );=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to locate gEfiRestJsonStructureProtoc= olGuid: %r\n", __FUNCTION__, Status));=0D + }=0D +=0D + gBS->CloseEvent (Event);=0D +}=0D +=0D +/**=0D +=0D + Install JSON protocol notification=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 +RedfishResourceIdentifyComuterSystemConstructor (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + VOID *Registration;=0D +=0D + EfiCreateProtocolNotifyEvent (=0D + &gEfiRestJsonStructureProtocolGuid,=0D + TPL_CALLBACK,=0D + RestJasonStructureProtocolIsReady,=0D + NULL,=0D + &Registration=0D + );=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSyst= em/v1_5_0/RedfishResourceIdentifyLibComuterSystem.inf b/RedfishClientPkg/Li= brary/RedfishResourceIdentifyLibComuterSystem/v1_5_0/RedfishResourceIdentif= yLibComuterSystem.inf new file mode 100644 index 0000000000..862522cdf6 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibComuterSystem/v1_5= _0/RedfishResourceIdentifyLibComuterSystem.inf @@ -0,0 +1,42 @@ +## @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 RedfishResourceIdentifyLibComuterSyst= em=0D + FILE_GUID =3D 2AEE2C80-126A-44A6-877E-642F20510D13= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D RedfishResourceIdentifyLib| DXE_DRIVE= R=0D + CONSTRUCTOR =3D RedfishResourceIdentifyComuterSystemC= onstructor=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + RedfishResourceIdentifyLibComuterSystem.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + NetworkPkg/NetworkPkg.dec=0D + RedfishPkg/RedfishPkg.dec=0D + RedfishClientPkg/RedfishClientPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + DebugLib=0D + UefiBootServicesTableLib=0D + UefiLib=0D +=0D +[Protocols]=0D + gEfiRestJsonStructureProtocolGuid ## CONSUMES=0D +=0D +[Pcd]=0D +=0D diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/Redfis= hResourceIdentifyLibNull.c b/RedfishClientPkg/Library/RedfishResourceIdenti= fyLibNull/RedfishResourceIdentifyLibNull.c new file mode 100644 index 0000000000..98eb8fde47 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/RedfishResour= ceIdentifyLibNull.c @@ -0,0 +1,37 @@ +/** @file=0D + Redfish resource identify NULL library implementation=0D +=0D + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + Identify resource from given URI and context in JSON format=0D +=0D + @param[in] Uri URI of given Redfish resource=0D + @param[in] Json Context in JSON format of give Redfish resource=0D +=0D + @retval TRUE This is the Redfish resource that we have to handle.= =0D + @retval FALSE We don't handle this Redfish resource.=0D +=0D +**/=0D +BOOLEAN=0D +RedfishIdentifyResource (=0D + IN EFI_STRING Uri,=0D + IN CHAR8 *Json=0D + )=0D +{=0D + if (!IS_EMPTY_STRING (Uri)) {=0D + DEBUG ((DEBUG_VERBOSE, "%a, accept resource: %s\n", __FUNCTION__, Uri)= );=0D + }=0D +=0D + return TRUE;=0D +}=0D diff --git a/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/Redfis= hResourceIdentifyLibNull.inf b/RedfishClientPkg/Library/RedfishResourceIden= tifyLibNull/RedfishResourceIdentifyLibNull.inf new file mode 100644 index 0000000000..092e180305 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishResourceIdentifyLibNull/RedfishResour= ceIdentifyLibNull.inf @@ -0,0 +1,37 @@ +## @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 RedfishResourceIdentifyLibNull=0D + FILE_GUID =3D 6FFD4E25-48F8-4CB6-B194-CFAB407316E1= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D RedfishResourceIdentifyLib| DXE_DRIVE= R=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + RedfishResourceIdentifyLibNull.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 +=0D +[Protocols]=0D +=0D +[Pcd]=0D +=0D diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 8acb479170..413b83a732 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -27,7 +27,7 @@ RedfishPlatformConfigLib|RedfishPkg/Library/RedfishPlatformConfigLib/Red= fishPlatformConfigLib.inf=0D RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/R= edfishContentCodingLibNull.inf=0D ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf=0D -=0D + RedfishResourceIdentifyLib|RedfishClientPkg/Library/RedfishResourceIdent= ifyLibNull/RedfishResourceIdentifyLibNull.inf=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 9d18c42c24..c61c581213 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -21,6 +21,7 @@ =0D [LibraryClasses]=0D RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h=0D + RedfishResourceIdentifyLib|Include/Library/RedfishResourceIdentifyLib.h= =0D EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConfig= Lib.h=0D RedfishEventLib|Include/Library/RedfishEventLib.h=0D RedfishVersionLib|Include/Library/RedfishVersionLib.h=0D --=20 2.32.0.windows.2