From nobody Mon Feb 9 12:15:16 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+91784+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+91784+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1658712969; cv=none; d=zohomail.com; s=zohoarc; b=LeArxa+MOo/3ZibEeD4MzTI862Kl/XVq0ykSQaodKGmHpGHIIB5vCSIrgj0D+5w7gBD77e1OsPA9IG52I43t4BqSzXZeYJqaR5SdUZEiwzA2zx3RPpM+XH5kFi1FKZXMhfXxFSt96sto61/Y1eL+iiQbNu3dRamUyY4yQytpdT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658712969; 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=XelfMnyHahSq4bQh0b5Auyy0NvWDN5n+NUBgnBcFOjQ=; b=b4W7di5xPBOwG1qigbNNC0M/ny+L8p+ChatoqmLprI3oFjFK5RJTKnPuJGERZH+jurGw0tUizl52VsPK64Urm30vZLzBrcFY36rmJJ3/OABCFM5dZ2lyflf59yDTiXZ6cCl86NxPqWU4U5mSkoAj5NqSOelU/Nxj8h/OHKd2n0I= 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+91784+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 1658712969141977.7487055208519; Sun, 24 Jul 2022 18:36:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ICtrYY1788612xbhVkSACfyr; 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.web08.23333.1658712968338576017 for ; Sun, 24 Jul 2022 18:36:08 -0700 X-Received: from pps.filterd (m0150241.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26OM2F2N021989; Mon, 25 Jul 2022 01:36:07 GMT X-Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3hhca81hyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jul 2022 01:36:06 +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 p1lg14878.it.hpe.com (Postfix) with ESMTPS id 37F13D2E4; Mon, 25 Jul 2022 01:36:06 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id D71C1800EC6; Mon, 25 Jul 2022 01:36:04 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-devel] [edk2-staging][PATCH v2 05/15] edk2-staging/RedfishClientPkg: Introduce resource identify library Date: Mon, 25 Jul 2022 09:35:45 +0800 Message-Id: <20220725013555.926-6-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-GUID: LAnuR8Zq6X5SSbU1ncUjDvBJSlNpTZnF X-Proofpoint-ORIG-GUID: LAnuR8Zq6X5SSbU1ncUjDvBJSlNpTZnF 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: BB7zJZgIoJlcACFRsa9jwQmbx1787277AA= 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=KKv53/MxoEgkjODq+s9+FQyoQpexHCbPYuWk9lFUTXU=; h=Cc:Date:From:Reply-To:Subject:To; b=S8HgwJFPxdGw3Y1aQLKYCnlHfgO3xsK7L97gLnki6oKD/fIXNaWh42NkMBswZoowVtx erPq+c6iZevQ2DNFt6ZL4CNV8Se/9L2Jp81KLsQbSSmLGoZCLNAC+1NJkPN7EZlRUgAZr UiYnPjh0iu1p7NZ4OMF5ZAj2dE0MNsrQ42w= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658712969922100013 Content-Type: text/plain; charset="utf-8" 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 + This file defines the Redfish resource identify Library interface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_RESOURCE_IDENTIFY_LIB_H_ +#define REDFISH_RESOURCE_IDENTIFY_LIB_H_ + +/** + Identify resource from given URI and context in JSON format + + @param[in] Uri URI of given Redfish resource + @param[in] Json Context in JSON format of give Redfish resource + + @retval TRUE This is the Redfish resource that we have to handle. + @retval FALSE We don't handle this Redfish resource. + +**/ +BOOLEAN +RedfishIdentifyResource ( + IN EFI_STRING Uri, + IN CHAR8 *Json + ); + +#endif 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 + Redfish resource identify library implementation for computer system ver= sion 1.5.0 + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mJsonStructProtocol =3D NULL; + +/** + Identify resource from given URI and context in JSON format + + @param[in] Uri URI of given Redfish resource + @param[in] Json Context in JSON format of give Redfish resource + + @retval TRUE This is the Redfish resource that we have to handle. + @retval FALSE We don't handle this Redfish resource. + +**/ +BOOLEAN +RedfishIdentifyResource ( + IN EFI_STRING Uri, + IN CHAR8 *Json + ) +{ + EFI_STATUS Status; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *ComputerSystem; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS *ComputerSystemCs; + EFI_GUID SystemUuid; + EFI_GUID ResourceUuid; + + if (IS_EMPTY_STRING (Uri) || IS_EMPTY_STRING (Json)) { + return FALSE; + } + + if (mJsonStructProtocol =3D=3D NULL) { + return FALSE; + } + + ComputerSystem =3D NULL; + ComputerSystemCs =3D NULL; + + Status =3D mJsonStructProtocol->ToStructure ( + mJsonStructProtocol, + NULL, + Json, + (EFI_REST_JSON_STRUCTURE_HEADER **)&Comp= uterSystem + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); + return FALSE; + } + + ComputerSystemCs =3D ComputerSystem->ComputerSystem; + + if (IS_EMPTY_STRING (ComputerSystemCs->UUID)) { + return FALSE; + } + + Status =3D AsciiStrToGuid (ComputerSystemCs->UUID, &ResourceUuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to get resource UUID: %r\n", __FUNCTION= __, Status)); + return FALSE; + } + + Status =3D NetLibGetSystemGuid (&SystemUuid); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, fail to get system UUID from SMBIOS: %r\n", = __FUNCTION__, Status)); + return FALSE; + } + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, Identify: System: %g Resource: %g\n", = __FUNCTION__, &SystemUuid, &ResourceUuid)); + if (CompareGuid (&ResourceUuid, &SystemUuid)) { + Status =3D EFI_SUCCESS; + } else { + Status =3D EFI_UNSUPPORTED; + } + + mJsonStructProtocol->DestoryStructure ( + mJsonStructProtocol, + (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystem + ); + + return (Status =3D=3D EFI_SUCCESS ? TRUE : FALSE); +} + +/** + Callback function when gEfiRestJsonStructureProtocolGuid is installed. + + @param[in] Event Event whose notification function is being invoked. + @param[in] Context Pointer to the notification function's context. +**/ +VOID +EFIAPI +RestJasonStructureProtocolIsReady + ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + + if (mJsonStructProtocol !=3D NULL) { + return; + } + + Status =3D gBS->LocateProtocol ( + &gEfiRestJsonStructureProtocolGuid, + NULL, + (VOID **)&mJsonStructProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to locate gEfiRestJsonStructureProtoc= olGuid: %r\n", __FUNCTION__, Status)); + } + + gBS->CloseEvent (Event); +} + +/** + + Install JSON protocol notification + + @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 +RedfishResourceIdentifyComuterSystemConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + VOID *Registration; + + EfiCreateProtocolNotifyEvent ( + &gEfiRestJsonStructureProtocolGuid, + TPL_CALLBACK, + RestJasonStructureProtocolIsReady, + NULL, + &Registration + ); + + return EFI_SUCCESS; +} 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 +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishResourceIdentifyLibComuterSyst= em + FILE_GUID =3D 2AEE2C80-126A-44A6-877E-642F20510D13 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishResourceIdentifyLib| DXE_DRIVER + CONSTRUCTOR =3D RedfishResourceIdentifyComuterSystemC= onstructor + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + RedfishResourceIdentifyLibComuterSystem.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + NetworkPkg/NetworkPkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + UefiLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## CONSUMES + +[Pcd] + 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 + Redfish resource identify NULL library implementation + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +/** + Identify resource from given URI and context in JSON format + + @param[in] Uri URI of given Redfish resource + @param[in] Json Context in JSON format of give Redfish resource + + @retval TRUE This is the Redfish resource that we have to handle. + @retval FALSE We don't handle this Redfish resource. + +**/ +BOOLEAN +RedfishIdentifyResource ( + IN EFI_STRING Uri, + IN CHAR8 *Json + ) +{ + if (!IS_EMPTY_STRING (Uri)) { + DEBUG ((DEBUG_VERBOSE, "%a, accept resource: %s\n", __FUNCTION__, Uri)= ); + } + + return TRUE; +} 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 +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishResourceIdentifyLibNull + FILE_GUID =3D 6FFD4E25-48F8-4CB6-B194-CFAB407316E1 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishResourceIdentifyLib| DXE_DRIVER + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + RedfishResourceIdentifyLibNull.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + +[Protocols] + +[Pcd] + 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 RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/R= edfishContentCodingLibNull.inf ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf - + RedfishResourceIdentifyLib|RedfishClientPkg/Library/RedfishResourceIdent= ifyLibNull/RedfishResourceIdentifyLibNull.inf 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 9d18c42c24..c61c581213 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -21,6 +21,7 @@ =20 [LibraryClasses] RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h + RedfishResourceIdentifyLib|Include/Library/RedfishResourceIdentifyLib.h EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConfig= Lib.h RedfishEventLib|Include/Library/RedfishEventLib.h RedfishVersionLib|Include/Library/RedfishVersionLib.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 (#91784): https://edk2.groups.io/g/devel/message/91784 Mute This Topic: https://groups.io/mt/92596787/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-