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.web12.23224.1658712961630784122 for ; Sun, 24 Jul 2022 18:36:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=ikEAJAwm; 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=0205fca832=nickle.wang@hpe.com) Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26P1XKOJ006686; Mon, 25 Jul 2022 01:36:00 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=tonG9cwK9Wu7R5ihSxwM/zydAo0syl1j7GySWqDWUVo=; b=ikEAJAwmdw2P/aSYW+Ires/w4PiM19Rp6UfxVZc5So0Olnu9HDu7Gu5vnyDJuoR65Nc+ NtZE0O+lWcx+HbvXTzz7876MzLnPTB1AUiVfCVYBxB33lMH5O/UwDImC8NkEhK8Zfpg0 87ghJVdIshiOdnXGniYtn+CD8/3x7WwzaJgQWzt4TxpGfROhStAcxK0Mo9XcphYPFBUf VkkMGY45ehqvsMOUX5aAhUL0TxS+oTbIm4N0ZkYkwtj7HP7YFv94Tql7cVLZzJO4aR++ pi6dOKnBUpQcUVfhmbiMY7OGz4cKeCLsgNEWfoNcJFbd6wueI50TKGIOf5q6VGcvO0Qu PQ== Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3hhhm3r0qx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jul 2022 01:35:59 +0000 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 p1lg14879.it.hpe.com (Postfix) with ESMTPS id 29CF7D2E0; Mon, 25 Jul 2022 01:35:59 +0000 (UTC) Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id C6B61800EC9; Mon, 25 Jul 2022 01:35:57 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-staging][PATCH v2 01/15] edk2-staging/RedfishClientPkg: Introduce Redfish event library Date: Mon, 25 Jul 2022 09:35:41 +0800 Message-Id: <20220725013555.926-2-nickle.wang@hpe.com> X-Mailer: git-send-email 2.32.0.windows.2 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: 16sW4rcZUPO2RetyclntkZmYKjJWnm0k X-Proofpoint-ORIG-GUID: 16sW4rcZUPO2RetyclntkZmYKjJWnm0k 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-23_02,2022-07-21_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 phishscore=0 mlxlogscore=888 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207250005 Content-Transfer-Encoding: 8bit Add RedfishEventLib to handle Redfish event. There are two events defined in this library. One is the event before feature driver provisioning and the other one is the event after all provisioning is finished. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez --- .../Include/Guid/RedfishClientEventGroup.h | 27 ++++ .../Include/Library/RedfishEventLib.h | 77 ++++++++++ .../Library/RedfishEventLib/RedfishEventLib.c | 139 ++++++++++++++++++ .../RedfishEventLib/RedfishEventLib.inf | 42 ++++++ RedfishClientPkg/RedfishClientLibs.dsc.inc | 1 + RedfishClientPkg/RedfishClientPkg.dec | 5 + 6 files changed, 291 insertions(+) create mode 100644 RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h create mode 100644 RedfishClientPkg/Include/Library/RedfishEventLib.h create mode 100644 RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c create mode 100644 RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf diff --git a/RedfishClientPkg/Include/Guid/RedfishClientEventGroup.h b/RedfishClientPkg/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/RedfishClientPkg/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 gBS->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 gBS->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/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c new file mode 100644 index 0000000000..0a8483c371 --- /dev/null +++ b/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.c @@ -0,0 +1,139 @@ +/** @file + Redfish event library to deliver Redfish specific event. + + (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 gBS->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 = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (NotifyFunction == NULL ? EfiEventEmptyFunction : NotifyFunction), + 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 gBS->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 = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + (NotifyFunction == NULL ? EfiEventEmptyFunction : NotifyFunction), + 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 = 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 = 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..a9d475c27c --- /dev/null +++ b/RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf @@ -0,0 +1,42 @@ +## @file +# +# (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010006 + BASE_NAME = RedfishEventLib + FILE_GUID = C4F7E27D-2338-43EA-9D1F-D10960E36521 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = RedfishEventLib| DXE_DRIVER UEFI_DRIVER + +# +# VALID_ARCHITECTURES = IA32 X64 EBC +# + +[Sources] + RedfishEventLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + UefiLib + +[Protocols] + +[Pcd] + +[Guids] + gEfiRedfishClientFeatureReadyToProvisioningGuid + gEfiRedfishClientFeatureAfterProvisioningGuid diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc b/RedfishClientPkg/RedfishClientLibs.dsc.inc index 5467acedd0..ce1c27d884 100644 --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc @@ -28,3 +28,4 @@ RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.inf ConverterCommonLib|RedfishClientPkg/ConverterLib/edk2library/ConverterCommonLib/ConverterCommonLib.inf + RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/RedfishClientPkg.dec index 09df062dd3..39b2f5baf8 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -21,6 +21,7 @@ [LibraryClasses] RedfishFeatureUtilityLib|Include/Library/RedfishFeatureUtilityLib.h + RedfishEventLib|Include/Library/RedfishEventLib.h [LibraryClasses.Common.Private] ## @libraryclass Redfish Helper Library @@ -39,6 +40,10 @@ ## Include/Guid/RedfishClientPkgTokenSpace.h gEfiRedfishClientPkgTokenSpaceGuid = { 0x8c444dae, 0x728b, 0x48ee, { 0x9e, 0x19, 0x8f, 0x0a, 0x3d, 0x4e, 0x9c, 0xc8 } } + ## Include/Guid/RedfishClientEventGroup.h + gEfiRedfishClientFeatureReadyToProvisioningGuid = { 0x77E4FC1C, 0x2428, 0x47EE, { 0x9E, 0xEC, 0x8B, 0x77, 0xEF, 0x9D, 0x4E, 0xF0 } } + gEfiRedfishClientFeatureAfterProvisioningGuid = { 0xE547CB6F, 0x306F, 0x4226, { 0xAB, 0x70, 0xA0, 0x6E, 0x26, 0xF1, 0x2E, 0xD0 } } + [PcdsFixedAtBuild] gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|UINT32|0x10000001 gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|UINT32|0x10000002 -- 2.32.0.windows.2