From nobody Wed May 8 13:17:43 2024 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+89790+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+89790+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1652755210; cv=none; d=zohomail.com; s=zohoarc; b=INNv9Gck26U3c8NgB30rz/fOcLQz72fseddWNU5zNSpIVABj4INog1tqi9NKQ1pLLngxNBiTiEHZBv6/gFwgWTmnQK2UUbX2D61KSK9VZd2TvP9xDZYm3Xrs58bV7ffIA9ml0EDqqB3i35dO8PXLQsNGxzifXXgFl3O4tu10NGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652755210; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=/nXicvAmSN5l7HcZlq4lOFmaY/bGybCs2ZgCNHPu7ms=; b=GQC5V2UJp5pGmNnB7pdnah2eZOpqBKp88CKlvzScH4jEy8K1FiUWazYDzA1zQOGIz0kXHuBI7nKLw5KOarCuR6/SFbIaPbCcnUilHTgz79wedawIAe6OiRw42io1nZj+cjfxbQtKo0dfDFxWF7c9Yt7LJy1nRdRrEsZtjcRqwxI= 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+89790+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 1652755210639988.4629682695671; Mon, 16 May 2022 19:40:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2uxKYY1788612xuMsvbaqbAL; Mon, 16 May 2022 19:40:10 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.2559.1652755209054821238 for ; Mon, 16 May 2022 19:40:09 -0700 X-Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24GLiqw3018478 for ; Tue, 17 May 2022 02:40:08 GMT X-Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3g3rwuysdc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 May 2022 02:40:08 +0000 X-Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id 78D3665 for ; Tue, 17 May 2022 02:40:07 +0000 (UTC) X-Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [10.43.61.53]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 8A0A13F; Tue, 17 May 2022 02:40:06 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Nickle Wang , Abner Chang Subject: [edk2-devel] [edk2-staging][PATCH] edk2-staging/RedfishClientPkg: Introduce Redfish event library Date: Tue, 17 May 2022 10:40:03 +0800 Message-Id: <20220517024003.718-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: djBsxZPIyUv9zKPUcwuuNwXYFlRzA3q8 X-Proofpoint-GUID: djBsxZPIyUv9zKPUcwuuNwXYFlRzA3q8 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: O6wfpoASOBlEpUXTgJxSqBDox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1652755210; bh=URCd7AJXtkQE8do1l0xt5xTYIJyer7BJiyA7x4XiRyM=; h=Cc:Date:From:Reply-To:Subject:To; b=UbWhN5q7dT969TFs0VhMMWD2/Rmgm9C8F4BNRUVz3vArI2ThFbASDT2lSOGbpHPg0ch Pdn5hkHWCOALSO1fptA0oVn2jM+QcYhaO7cZ4ax79LApTG9/gPgi/u1bpxcgd47G+T6Oj U8HfTIzJA0pvD1wu4GdklsDJr2Yu/9MxIiM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1652755212460100001 Content-Type: text/plain; charset="utf-8" Add RedfishEventLib to Redfish client package. This library provides interface for Redfish feature drivers to listen to Redfish event such as the event before provisioning and the event after provisioning. Feature driver can perform additional operation before and after Redfish provisioning. Signed-off-by: Nickle Wang Cc: Abner Chang --- .../Include/Guid/RedfishClientEventGroup.h | 27 ++++ .../Include/Library/RedfishEventLib.h | 77 ++++++++++ .../Library/RedfishEventLib/RedfishEventLib.c | 139 ++++++++++++++++++ .../RedfishEventLib/RedfishEventLib.inf | 38 +++++ RedfishClientPkg/RedfishClientLibs.dsc.inc | 2 +- RedfishClientPkg/RedfishClientPkg.dec | 7 +- 6 files changed, 288 insertions(+), 2 deletions(-) create mode 100644 RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h create mode 100644 RedfishClientPkg/Include/Library/RedfishEventLib.h create mode 100644 RedfishClientPkg/Library/RedfishEventLib/RedfishEventLi= b.c create mode 100644 RedfishClientPkg/Library/RedfishEventLib/RedfishEventLi= b.inf diff --git a/RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h b/Redf= ishClientPkg/Include/Guid/RedfishClientEventGroup.h new file mode 100644 index 0000000000..0d88dd4726 --- /dev/null +++ b/RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h @@ -0,0 +1,27 @@ +/** @file + GUID for Redfish Client Event Group GUID + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_CLIENT_EVENT_GROUP_GUID_H_ +#define REDFISH_CLIENT_EVENT_GROUP_GUID_H_ + +#define REDFISH_CLIENT_FEATURE_READY_TO_PROVISIONING_GUID \ + { \ + 0x77E4FC1C, 0x2428, 0x47EE, { 0x9E, 0xEC, 0x8B, 0x77, 0xEF, 0x9D, 0x4E= , 0xF0 } \ + } + +extern EFI_GUID gEfiRedfishClientFeatureReadyToProvisioningGuid; + +#define REDFISH_CLIENT_FEATURE_AFTER_PROVISIONING_GUID \ + { \ + 0xE547CB6F, 0x306F, 0x4226, { 0xAB, 0x70, 0xA0, 0x6E, 0x26, 0xF1, 0x2E= , 0xD0 } \ + } + +extern EFI_GUID gEfiRedfishClientFeatureAfterProvisioningGuid; + +#endif diff --git a/RedfishClientPkg/Include/Library/RedfishEventLib.h b/RedfishCl= ientPkg/Include/Library/RedfishEventLib.h new file mode 100644 index 0000000000..1f3d0acf19 --- /dev/null +++ b/RedfishClientPkg/Include/Library/RedfishEventLib.h @@ -0,0 +1,77 @@ +/** @file + This file defines the Redfish event library interface. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_EVENT_LIB_H_ +#define REDFISH_EVENT_LIB_H_ + +#include + +/** + Create an EFI event before Redfish provisioning start. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateReadyToProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ); + +/** + Create an EFI event after Redfish provisioning finished. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateAfterProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ); + +/** + Signal ready to provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalReadyToProvisioningEvent ( + IN VOID + ); + +/** + Signal after provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalAfterProvisioningEvent ( + IN VOID + ); + +#endif diff --git a/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c b/R= edfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c new file mode 100644 index 0000000000..1c8cfe53c7 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c @@ -0,0 +1,139 @@ +/** @file + Redfish event library implementation. + + (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include + +#include +#include +#include +#include +#include + +/** + Create an EFI event before Redfish provisioning start. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateReadyToProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ) +{ + EFI_STATUS Status; + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (NotifyFunction =3D=3D NULL ? EfiEventEmptyFunction : No= tifyFunction), + NotifyContext, + &gEfiRedfishClientFeatureReadyToProvisioningGuid, + ReadyToProvisioningEvent + ); + + return Status; +} + +/** + Create an EFI event after Redfish provisioning finished. + + @param NotifyFunction The notification function to call when= the event is signaled. + @param NotifyContext The content to pass to NotifyFunction = when the event is signaled. + @param ReadyToProvisioningEvent Returns the EFI event returned from gB= S->CreateEvent(Ex). + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +EFIAPI +CreateAfterProvisioningEvent ( + IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL + IN VOID *NotifyContext, OPTIONAL + OUT EFI_EVENT *ReadyToProvisioningEvent + ) +{ + EFI_STATUS Status; + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (NotifyFunction =3D=3D NULL ? EfiEventEmptyFunction : No= tifyFunction), + NotifyContext, + &gEfiRedfishClientFeatureAfterProvisioningGuid, + ReadyToProvisioningEvent + ); + + return Status; +} + +/** + Signal ready to provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalReadyToProvisioningEvent ( + IN VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + Status =3D CreateReadyToProvisioningEvent (NULL, NULL, &Event); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to create after provisioning event\n"= , __FUNCTION__)); + return Status; + } + + gBS->SignalEvent (Event); + gBS->CloseEvent (Event); + + return EFI_SUCCESS; +} + +/** + Signal after provisioning event. + + @retval EFI_SUCCESS Event was created. + @retval Other Event was not created. + +**/ +EFI_STATUS +SignalAfterProvisioningEvent ( + IN VOID + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + Status =3D CreateAfterProvisioningEvent (NULL, NULL, &Event); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to create after provisioning event\n"= , __FUNCTION__)); + return Status; + } + + gBS->SignalEvent (Event); + gBS->CloseEvent (Event); + + return EFI_SUCCESS; +} + diff --git a/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf b= /RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf new file mode 100644 index 0000000000..edafca0c65 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf @@ -0,0 +1,38 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D RedfishEventLib + FILE_GUID =3D C4F7E27D-2338-43EA-9D1F-D10960E36521 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RedfishEventLib| DXE_DRIVER UEFI_DRIV= ER + +# +# VALID_ARCHITECTURES =3D IA32 X64 EBC +# + +[Sources] + RedfishEventLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + UefiLib + +[Guids] + gEfiRedfishClientFeatureReadyToProvisioningGuid + gEfiRedfishClientFeatureAfterProvisioningGuid diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/= RedfishClientLibs.dsc.inc index 5467acedd0..91e5de4296 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -27,4 +27,4 @@ RedfishPlatformConfigLib|RedfishPkg/Library/RedfishPlatformConfigLib/Red= fishPlatformConfigLib.inf RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/R= edfishContentCodingLibNull.inf ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCo= mmonLib/ConverterCommonLib.inf - + RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib= .inf diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 09df062dd3..56e542f03c 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 + RedfishEventLib|Include/Library/RedfishEventLib.h =20 [LibraryClasses.Common.Private] ## @libraryclass Redfish Helper Library @@ -39,6 +40,10 @@ ## Include/Guid/RedfishClientPkgTokenSpace.h gEfiRedfishClientPkgTokenSpaceGuid =3D { 0x8c444dae, 0x728b, 0x48ee, = { 0x9e, 0x19, 0x8f, 0x0a, 0x3d, 0x4e, 0x9c, 0xc8 } } =20 + ## Include/Guid/RedfishClientEventGroup.h + gEfiRedfishClientFeatureReadyToProvisioningGuid =3D { 0x77E4FC1C, 0x2428= , 0x47EE, { 0x9E, 0xEC, 0x8B, 0x77, 0xEF, 0x9D, 0x4E, 0xF0 } } + gEfiRedfishClientFeatureAfterProvisioningGuid =3D { 0xE547CB6F, 0x306F= , 0x4226, { 0xAB, 0x70, 0xA0, 0x6E, 0x26, 0xF1, 0x2E, 0xD0 } } + [PcdsFixedAtBuild] gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|UINT= 32|0x10000001 gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|UINT= 32|0x10000002 --=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 (#89790): https://edk2.groups.io/g/devel/message/89790 Mute This Topic: https://groups.io/mt/91156124/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-