From nobody Sat May 18 09:23:10 2024 Delivered-To: importer@patchew.org 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+103889+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1683100187240180.9047722385934; Wed, 3 May 2023 00:49:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dAthYY1788612xe8ZN1pQAEB; Wed, 03 May 2023 00:49:44 -0700 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.89]) by mx.groups.io with SMTP id smtpd.web11.13502.1683100183573056459 for ; Wed, 03 May 2023 00:49:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BsrJ0mJwCuPfTi2aMR2K5k5QcHUwhuwaRZ+FDeS71XjA2G0sT4kZipN4nFnr3v80hW/c4N4myMM5SaIr0JoYCw4Y5aEKcbRAihC7Yq7gGL9xt6yvea9rYj5Sng+seaH3DrXwWkyv4U/UHT389REz9iGrMQaXn+g31EMzg8JGMX2iI8tbRMo7HgP4l78XgXQqCO29Xw1w6M02cHj4/aVhbQ64m1IW6pATIKUYrsCm5hoWAWg0V7l1FLFNRxs/AkDWP9jzR+m44FrZnYRjLuIxGVCb4TPdKbMFVyemI5gga1CzLfofC5uLdW1NhgduyGoarA30IO+W+62fuOtF/8reFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=43nOEmWELi2OxaStDUI4nbEbPcOckLjYX57XhG+AS1M=; b=EFXMgwpJS7ypCDUMHJgHTIkl26cguu7ztuSlhV487BUZJhiRrscPgV+LTr1HZnkNzbkLJMcx83yp6UnVrKw9HGw6sDmnOZXe2afAhqnMyoIPiZUXYCKmdgeDPlmU0DdIpFQDpuy+81r9HQ/2408BIDjhDO9RTI67/7ye9svQB9owEFrUCxI83npv5psBxuoBGUvJxg1nTnYPImvj+ybDXL4Qx/lxcryI6QvzkNJSNtuAyc7FmQ/owTdc5p24z0DKEkIFOYY1vzxaUtTNkILrZkXDJdUJgkZQ9cPYejxR2/KftxnA1385S/XPCr8bGiE2F0cAswRq9tUEh+YMh1rCkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none X-Received: from DS7PR03CA0022.namprd03.prod.outlook.com (2603:10b6:5:3b8::27) by DM4PR12MB5247.namprd12.prod.outlook.com (2603:10b6:5:39b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.20; Wed, 3 May 2023 07:49:40 +0000 X-Received: from DM6NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b8:cafe::30) by DS7PR03CA0022.outlook.office365.com (2603:10b6:5:3b8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.20 via Frontend Transport; Wed, 3 May 2023 07:49:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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+103889+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT019.mail.protection.outlook.com (10.13.172.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.22 via Frontend Transport; Wed, 3 May 2023 07:49:40 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 3 May 2023 02:49:04 -0500 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/RedfishFeatureCoreDxe: Redfish Feature Core DXE driver Date: Wed, 3 May 2023 15:48:48 +0800 Message-ID: <20230503074848.409-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT019:EE_|DM4PR12MB5247:EE_ X-MS-Office365-Filtering-Correlation-Id: 5337091d-ffe6-4b4a-1c2b-08db4baaf376 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: 4kZEQts8nVX2D2d+5VmQVltr6PUX0urFyR4Q7vTzpMszLiTLwD5ScEPYyUpNTb//ecg3rsrl4sX130sAMGIoLREmxFJIAXPDCy+vtexgwN5zcJn7MPNC7b9fa5/UiUzldotJY8oYO9z8928OxPxk3KYczISXjpgJEnXo4f95uJ3qydlcIqOw5mYuGoZtnCosTCLW9hwH6o1x3pS1WlCQrLCZ3DoQzOPCdvAubIqhyd6iFpmAUfJfkmPk0Ht3xOFmXAx6uvt4Jlsr3VymWw42gitJAbkJ/IX/dUfTNIiSIu5NeX/UXsKFjpMA3rj/YXeFJPRn59l3UKA8C2lXqmho749R7k68h/+29542rv3SpDzq+CinPkRlWsCdJgtDMqpUFs5BTLNb3rrK4NeXub0RXcuGaldi3BLTUYkBjOQ09/IAw/y/j+9B04TXWSYG8MGsMJfhuYYkk2q6JgPOs5f2iH3aZQwXe3uUS86538y9oxvwIGw7zNG2h5YCAZKSwm1LRgUmj3NDrhQol25frVkNWx2fS1DEK3A5Hgjxa8rkTKEcq8/FRPnEc1yyoW0bR0AWjxxhjKajVzqG0O53zELiP3lI01oVtttmnoghPToOFaESy6dN+yw3DvKAQFkPh4uF8N0JNmm1L1+hcLkdKZQmbm6+ZnkseeE7Irsi9Xu6hXP6HgThImhg4CYVm4cfQr18KE2WrWNL9noFTysHE2KRCsjkxTc3qTp/gQyOFTKzyi6gfg2WDwf9YFgIfrmQXOoBUhbdcuOrcOHTfM/md6m2Xw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2023 07:49:40.3403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5337091d-ffe6-4b4a-1c2b-08db4baaf376 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5247 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,abner.chang@amd.com X-Gm-Message-State: VGdWpfuHTwabjC3jpy2D9NKsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1683100184; bh=N/Q5jFtrs0CzO71Ng28f3fqKya0pUFPv1PelraKgLOA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=DLS1UD/XsGZkiR3SIqHp2LPCPKlkZ7tFAebziY2WMwWIUYA3oLp4NC7fZjGa8aqKwhV Joq3oA7oYGHBQdewggNRwEJOzb3sWyadckv9H2IeU6J1NqyFvaupiWLu/IBQmBxlmb7Kq f2pjZQv0yozO+dw/B9mfKUp6A6BYjXEfPsM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1683100188137100001 Content-Type: text/plain; charset="utf-8" From: Abner Chang EDKII Redfish Feature Core DXE driver provides the protocol interface to the auto-generated Redfish feature driver to register itself for the Redfish resource URI it manages. Refer to the Readme.md for the details. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Reviewed-by: Nickle Wang --- RedfishClientPkg/RedfishClientPkg.dec | 13 +- .../RedfishClientComponents.dsc.inc | 2 + RedfishClientPkg/RedfishClient.fdf.inc | 1 + .../RedfishFeatureCoreDxe.inf | 49 +++ .../Include/Protocol/EdkIIRedfishFeature.h | 117 +++++ .../RedfishFeatureCoreDxe.h | 45 ++ .../RedfishFeatureCoreDxe.c | 403 ++++++++++++++++++ RedfishClientPkg/Readme.md | 36 ++ 8 files changed, 665 insertions(+), 1 deletion(-) create mode 100644 RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCo= reDxe.inf create mode 100644 RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h create mode 100644 RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCo= reDxe.h create mode 100644 RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCo= reDxe.c diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index 4038a47bd5..6da0468e65 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -15,10 +15,21 @@ [Includes] Include =20 - [LibraryClasses] =20 [Protocols] + ## Include/Protocol/EdkIIRedfishFeature.h + gEdkIIRedfishFeatureProtocolGuid =3D { 0x785CC694, 0x4930, 0xEFBF, { 0x2= A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0xAA, 0x34 } } =20 [Guids] gEfiRedfishClientPkgTokenSpaceGuid =3D { 0x8c444dae, 0x728b, 0x48ee, = { 0x9e, 0x19, 0x8f, 0x0a, 0x3d, 0x4e, 0x9c, 0xc8 } } + +[PcdsFixedAtBuild] + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|UINT= 32|0x10000001 + gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|UINT= 32|0x10000002 + # + # gEfiEventReadyToBootGuid is the default event to startup Redfish featu= re drivers. + # { 0x7CE88FB3, 0x4BD7, 0x4679, { 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, 0x= 0D, 0x2B }} + # + gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEv= entGuid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8, = 0xD8, 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x10000003 + diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index 0648fa9d54..e4e2619bfb 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -13,4 +13,6 @@ ## =20 !if $(REDFISH_CLIENT) =3D=3D TRUE + RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf !endif + diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 4f0714004e..d4c5874787 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -11,4 +11,5 @@ # ## !if $(REDFISH_CLIENT) =3D=3D TRUE + INF RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf !endif diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.i= nf b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf new file mode 100644 index 0000000000..5a2cd7fecc --- /dev/null +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf @@ -0,0 +1,49 @@ +## @file +# RedfishFeatureCoreDxe is the DXE driver which provides +# EdkIIRedfishFeatureCoreProtocol to EDK2 Redfish Feature +# drivers for the registration. +# +# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001000b + BASE_NAME =3D RedfishFeatureCoreDxe + FILE_GUID =3D 1E01A624-4161-F1F1-25BC-D28E77420D8E + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D RedfishFeatureCoreEntryPoint + +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 RISCV64 +# + +[Sources] + RedfishFeatureCoreDxe.c + RedfishFeatureCoreDxe.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + PrintLib + UefiBootServicesTableLib + UefiDriverEntryPoint + UefiLib + +[Protocols] + gEdkIIRedfishFeatureProtocolGuid ## BY_START + +[Pcd] + gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEv= entGuid + +[Depex] + TRUE diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h b/Redf= ishClientPkg/Include/Protocol/EdkIIRedfishFeature.h new file mode 100644 index 0000000000..04b65a06a3 --- /dev/null +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h @@ -0,0 +1,117 @@ +/** @file + This file defines the EDKII_REDFISH_FEATURE_PROTOCOL interface. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_FEATURE_H_ +#define EDKII_REDFISH_FEATURE_H_ + +typedef struct _EDKII_REDFISH_FEATURE_PROTOCOL EDKII_REDFISH_FEATURE_PROTO= COL; + +#define EDKII_REDFISH_FEATURE_PROTOCOL_GUID \ + { \ + 0x785CC694, 0x4930, 0xEFBF, { 0x2A, 0xCB, 0xA4, 0xB6, 0xA1, 0xCC, 0x= AA, 0x34 } \ + } + +typedef enum { + CallbackActionNone =3D 0, ///< Invalid action + CallbackActionStartOperation, ///< Start the operations on Redfish resou= rce + CallbackActionMax +} FEATURE_CALLBACK_ACTION; + +typedef enum { + InformationTypeNone =3D 0, ///< Invalid information. + InformationTypeCollectionMemberUri, ///< URI to the new created collecti= on member. + InformationTypeMax +} FEATURE_RETURNED_INFORMATION_TYPE; + +typedef struct { + FEATURE_RETURNED_INFORMATION_TYPE Type; +} FEATURE_RETURNED_INFORMATION; + +/** + The callback function provided by Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROT= OCOL instance. + @param[in] FeatureAction The action Redfish feature driver sho= uld take. + @param[in] Context The context of Redfish feature driver. + @param[in,out] InformationReturned The pointer to retrive the pointer to + FEATURE_RETURNED_INFOMATION. The memo= ry block of this + information should be freed by caller. + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *REDFISH_FEATURE_CALLBACK)( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN FEATURE_CALLBACK_ACTION FeatureAction, + IN VOID *Context, + IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned + ); + +/** + The registration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + @param[in] Callback Callback routine associated with this r= egistration that + provided by Redfish feature driver to e= xecute the action + on Redfish resource which is managed by= this Redfish + feature driver. + @param[in] Context The context of the registering feature = driver. The pointer + to the conext is delivered through call= back function. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *REDFISH_FEATURE_REGISTER)( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN REDFISH_FEATURE_CALLBACK Callback, + IN VOID *Context + ); + +/** + The unregistration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + @param[in] Context The context used for the previous featu= re driver + registration. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval Others Some error happened. + +**/ +typedef +EFI_STATUS +(EFIAPI *REDFISH_FEATURE_UNREGISTER)( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN VOID *Context + ); + +struct _EDKII_REDFISH_FEATURE_PROTOCOL { + REDFISH_FEATURE_REGISTER Register; + REDFISH_FEATURE_UNREGISTER Unregister; +}; + +extern EFI_GUID gEdkIIRedfishFeatureProtocolGuid; + +#endif diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h new file mode 100644 index 0000000000..71432a1aa9 --- /dev/null +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h @@ -0,0 +1,45 @@ +/** @file + Definitions of RedfishFeatureCoreDxe + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef EDKII_REDFISH_FEATURE_CORE_DXE_H_ +#define EDKII_REDFISH_FEATURE_CORE_DXE_H_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#define MaxNodeNameLength 64 +#define NodeSeperator L'/' +#define NodeIsCollectionLeftBracket '{' +#define NodeIsCollectionRightBracket '}' + +typedef struct _REDFISH_FEATURE_INTERNAL_DATA REDFISH_FEATURE_INTERNAL_DAT= A; +struct _REDFISH_FEATURE_INTERNAL_DATA { + REDFISH_FEATURE_INTERNAL_DATA *SiblingList; ///< Next same le= vel in hierarchy of resource URI. + REDFISH_FEATURE_INTERNAL_DATA *ChildList; ///< Next level i= n hierarchy of resource URI. + EFI_STRING NodeName; ///< Name of the = node in hierarchy of resource URI. + REDFISH_FEATURE_CALLBACK Callback; ///< Callback fun= ction of Redfish feature driver. + VOID *Context; ///< Context of f= eature driver. + FEATURE_RETURNED_INFORMATION *ReturnedInformation; ///< Information = returned from Redfish feature driver. + UINT32 Flags; +}; + +#define REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTION 0x00000001 + +typedef struct { + EDKII_REDFISH_FEATURE_PROTOCOL *This; + FEATURE_CALLBACK_ACTION Action; +} REDFISH_FEATURE_STARTUP_CONTEXT; +#endif diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c new file mode 100644 index 0000000000..5cd89872c1 --- /dev/null +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c @@ -0,0 +1,403 @@ +/** @file + RedfishFeatureCoreDxe produces EdkIIRedfishFeatureCoreProtocol + for EDK2 Redfish Feature driver registration. + + (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +EFI_EVENT mEdkIIRedfishFeatureDriverStartupEvent; +REDFISH_FEATURE_STARTUP_CONTEXT mFeatureDriverStartupContext; +REDFISH_FEATURE_INTERNAL_DATA *ResourceUriNodeList; + +/** + Startup child feature drivers and it's sibing feature drivers. + + @param[in] ThisFeatureDriverList This feature driver list. + @param[in] StartupContext Start up information + +**/ +VOID +StartUpFeatureDriver ( + IN REDFISH_FEATURE_INTERNAL_DATA *ThisFeatureDriverList, + IN REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext + ) +{ + EFI_STATUS Status; + REDFISH_FEATURE_INTERNAL_DATA *ThisList; + + ThisList =3D ThisFeatureDriverList; + while (TRUE) { + if (ThisList->Callback !=3D NULL) { + Status =3D ThisList->Callback ( + StartupContext->This, + StartupContext->Action, + ThisList->Context, + &ThisList->ReturnedInformation + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Callback to EDK2 Redfish feature driver = fail.", __func__)); + } + } + + if (ThisList->ChildList !=3D NULL) { + StartUpFeatureDriver (ThisList->ChildList, StartupContext); + } + + // + // Check sibling Redfish feature driver. + // + if (ThisList->SiblingList =3D=3D NULL) { + break; + } + + // + // Go next sibling Redfish feature driver. + // + ThisList =3D ThisList->SiblingList; + } +} + +/** + Callback routine when mEdkIIRedfishFeatureDriverStartupEvent + is signaled. + + @param[in] Event Event whose notification function is b= eing invoked. + @param[in] Context The pointer to the notification functi= on's context, + which is implementation-dependent. + +**/ +VOID +EFIAPI +RedfishFeatureDriverStartup ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext; + + StartupContext =3D (REDFISH_FEATURE_STARTUP_CONTEXT *)Context; + // + // Invoke EDK2 Redfish feature driver callback to start up + // the Redfish operations. + // + if (ResourceUriNodeList =3D=3D NULL) { + return; + } + + // + // Invoke the callback by the hierarchy level + // + StartUpFeatureDriver (ResourceUriNodeList, StartupContext); +} + +/** + Create new internal data instance. + + @param[in,out] PtrToNewInternalData Pointer to receive new instance of + REDFISH_FEATURE_INTERNAL_DATA. + @param[in] NodeName Name of URI node. + + @retval EFI_SUCCESS New entry is inserted successfully. + @retval EFI_INVALID_PARAMETER Improper given parameters. + @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure. + +**/ +EFI_STATUS +NewInternalInstance ( + IN OUT REDFISH_FEATURE_INTERNAL_DATA **PtrToNewInternalData, + IN EFI_STRING NodeName + ) +{ + REDFISH_FEATURE_INTERNAL_DATA *NewInternalData; + + if ((PtrToNewInternalData =3D=3D NULL) || (NodeName =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "%a: Inproper given parameters\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + *PtrToNewInternalData =3D NULL; + NewInternalData =3D AllocateZeroPool (sizeof (REDFISH_FEATURE_INTE= RNAL_DATA)); + if (NewInternalData =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: No memory for REDFISH_FEATURE_INTERNAL_DATA\= n", __func__)); + return EFI_OUT_OF_RESOURCES; + } + + NewInternalData->NodeName =3D AllocateZeroPool (StrSize (NodeName)); + StrnCpyS (NewInternalData->NodeName, StrSize (NodeName), (CONST CHAR16 *= )NodeName, StrLen (NodeName)); + NewInternalData->SiblingList =3D NULL; + NewInternalData->ChildList =3D NULL; + if ((NodeName[0] =3D=3D (UINT16)NodeIsCollectionLeftBracket) && + (NodeName[StrLen (NodeName) - 1] =3D=3D (UINT16)NodeIsCollectionRigh= tBracket)) + { + NewInternalData->Flags |=3D REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTIO= N; + } + + *PtrToNewInternalData =3D NewInternalData; + return EFI_SUCCESS; +} + +/** + Insert the URI node into internal data structure + + @param[in] HeadEntryToInsert The head entry to start the searchi= ng. + @param[in] NodeName Name of URI node. + @param[in, out] NextNodeEntry Pointer to receive the pointer of n= ext head + entry for inserting the follow up n= odes. + The returned LIST_ENTRY is the addr= ess of + ChildList link list. + @retval EFI_SUCCESS New entry is inserted successfully. + @retval EFI_INVALID_PARAMETER Improper given parameters. + @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure. + +**/ +EFI_STATUS +InsertRedfishFeatureUriNode ( + IN REDFISH_FEATURE_INTERNAL_DATA *HeadEntryToInsert, + IN EFI_STRING NodeName, + IN OUT REDFISH_FEATURE_INTERNAL_DATA **NextNodeEntry + ) +{ + EFI_STATUS Status; + REDFISH_FEATURE_INTERNAL_DATA *NewInternalData; + REDFISH_FEATURE_INTERNAL_DATA *ThisInternalData; + REDFISH_FEATURE_INTERNAL_DATA *SiblingList; + + if (NodeName =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Node name is NULL.\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if (NextNodeEntry =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: NextNodeEntry can't be NULL.\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if ((HeadEntryToInsert =3D=3D NULL) || (HeadEntryToInsert->ChildList =3D= =3D NULL)) { + Status =3D NewInternalInstance (&NewInternalData, NodeName); + if (EFI_ERROR (Status)) { + return Status; + } + + if (HeadEntryToInsert =3D=3D NULL) { + ResourceUriNodeList =3D NewInternalData; + } else { + HeadEntryToInsert->ChildList =3D NewInternalData; + } + + *NextNodeEntry =3D NewInternalData; + return EFI_SUCCESS; + } + + // + // Go through sibling list to find the entry. + // + ThisInternalData =3D HeadEntryToInsert; + SiblingList =3D ThisInternalData->SiblingList; + while (TRUE) { + if (StrCmp ((CONST CHAR16 *)ThisInternalData->NodeName, (CONST CHAR16 = *)NodeName) =3D=3D 0) { + *NextNodeEntry =3D ThisInternalData->ChildList; + return EFI_SUCCESS; + } + + // + // If sibing exist? + // + if (SiblingList =3D=3D NULL) { + Status =3D NewInternalInstance (&NewInternalData, NodeName); + if (EFI_ERROR (Status)) { + return Status; + } + + ThisInternalData->SiblingList =3D NewInternalData; + *NextNodeEntry =3D NewInternalData->ChildList; + return EFI_SUCCESS; + } + + SiblingList =3D SiblingList->SiblingList; + } + + return EFI_SUCCESS; +} + +/** + The registration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + e.g. "ServiceRoot/" - Managed by Servic= eRoot feature driver + "ServiceRoot/Systems[]/" - Managed= by ComputerSystemCollection feature driver + "ServiceRoot/Systems[1]/" - Manage= d by ComputerSystem feature driver + "ServiceRoot/Systems[2]/Bios/" - M= anaged by Bios feature driver + @param[in] Callback Callback routine associated with this r= egistration that + provided by Redfish feature driver to e= xecute the action + on Redfish resource which is managed by= this Redfish + feature driver. + @param[in] Context The context of the registering feature = driver. The pointer + to the conext is delivered through call= back function. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval EFI_INVALID_PARAMETER Improper given parameters or fail to re= gister + feature driver. + @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure. + @retval Others Some error happened. + +**/ +EFI_STATUS +EFIAPI +RedfishFeatureRegister ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN REDFISH_FEATURE_CALLBACK Callback, + IN VOID *Context + ) +{ + CHAR16 NodeName[MaxNodeNameLength]; + EFI_STATUS Status; + UINTN Index; + UINTN AnchorIndex; + UINTN UriLength; + REDFISH_FEATURE_INTERNAL_DATA *ThisUriNode; + + if ((FeatureManagedUri =3D=3D NULL) || (Callback =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "%a: The given parameter is invalid\n", __func__)= ); + return EFI_INVALID_PARAMETER; + } + + // + // Walk through URI which managed by this EDK2 Redfish feature driver. + // + UriLength =3D StrLen (FeatureManagedUri) + 1; // Add one NULL for the = last node. + Index =3D 0; + AnchorIndex =3D 0; + ThisUriNode =3D ResourceUriNodeList; + do { + if ((Index - AnchorIndex + 1) >=3D MaxNodeNameLength) { + // Increase one for the NULL terminator + DEBUG ((DEBUG_ERROR, "%a: the length of node name is >=3D MaxNodeNam= eLength\n", __func__)); + ASSERT (FALSE); + } + + NodeName[Index - AnchorIndex] =3D *(FeatureManagedUri + Index); + if ((NodeName[Index - AnchorIndex] =3D=3D NodeSeperator) || (NodeName[= Index - AnchorIndex] =3D=3D (CHAR16)0)) { + NodeName[Index - AnchorIndex] =3D 0; + AnchorIndex =3D Index + 1; + // + // Insert node + // + if (StrLen (NodeName) !=3D 0) { + Status =3D InsertRedfishFeatureUriNode (ThisUriNode, NodeName, &Th= isUriNode); + if (EFI_ERROR (Status)) { + return Status; + } + } + } + + Index++; + } while ((Index < UriLength)); + + if (ThisUriNode =3D=3D NULL) { + // + // No URI node was created + // + DEBUG ((DEBUG_ERROR, "%a: No URI node is added\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + // + // Add feature driver info to internal data instance. + // + ThisUriNode->Callback =3D Callback; + ThisUriNode->Context =3D Context; + return EFI_SUCCESS; +} + +/** + The unregistration function for the Redfish Feature driver. + + @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOC= OL instance. + @param[in] FeatureManagedUri The URI represents the hierarchy path o= f the Redfish + resource in the entire Redfish data mod= el that managed + by Redfish feature driver . Each node i= n the hierarchy + path is the property name defined in th= e schema of the + resource. + @param[in] Context The context used for the previous featu= re driver + registration. + @retval EFI_SUCCESS Redfish feature driver is registered su= ccessfully. + @retval Others Some error happened. + +**/ +EFI_STATUS +EFIAPI +RedfishFeatureUnregister ( + IN EDKII_REDFISH_FEATURE_PROTOCOL *This, + IN EFI_STRING FeatureManagedUri, + IN VOID *Context + ) +{ + return EFI_UNSUPPORTED; +} + +EDKII_REDFISH_FEATURE_PROTOCOL mRedfishFeatureProtocol =3D { + RedfishFeatureRegister, + RedfishFeatureUnregister +}; + +/** + Main entry for this driver. + + @param[in] ImageHandle Image handle this driver. + @param[in] SystemTable Pointer to SystemTable. + + @retval EFI_SUCESS This function always complete successfully. + +**/ +EFI_STATUS +EFIAPI +RedfishFeatureCoreEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + EFI_GUID *EventGuid; + + Handle =3D NULL; + ResourceUriNodeList =3D NULL; + EventGuid =3D (EFI_GUID *)PcdGetPtr (PcdEdkIIRedfishFeatureDri= verStartupEventGuid); + + ZeroMem ((VOID *)&mFeatureDriverStartupContext, sizeof (REDFISH_FEATURE_= STARTUP_CONTEXT)); + mFeatureDriverStartupContext.This =3D &mRedfishFeatureProtocol; + + Status =3D gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + RedfishFeatureDriverStartup, + (CONST VOID *)&mFeatureDriverStartupContext, + EventGuid, + &mEdkIIRedfishFeatureDriverStartupEvent + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Install the RedfishCredentialProtocol onto Handle. + // + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gEdkIIRedfishFeatureProtocolGuid, + &mRedfishFeatureProtocol, + NULL + ); + return Status; +} diff --git a/RedfishClientPkg/Readme.md b/RedfishClientPkg/Readme.md index 9e56fb9039..18a27633cf 100644 --- a/RedfishClientPkg/Readme.md +++ b/RedfishClientPkg/Readme.md @@ -119,6 +119,42 @@ struct _EDKII_REDFISH_PLATFORM_CONFIG_PROTOCOL { For those Non-EDK2 HII-based platform configuration formats, the driver in= stance can provide its own implementation to get or set the platform configuratio= ns. =20 +### EDKII Redfish Feature Core DXE Driver ***[[12]](#[0])*** +EDKII Redfish Feature Core DXE driver provides the protocol interface to +the auto-generated Redfish feature driver to register itself for the +Redfish resource URI it manages. + +```C +struct _EDKII_REDFISH_FEATURE_PROTOCOL { + REDFISH_FEATURE_REGISTER Register; + REDFISH_FEATURE_UNREGISTER Unregister; +}; +``` + +Redfish Feature Core DXE driver records the +URI according to the URI hierarchy, and then it starts up the Redfish +feature drivers based on the hierarchy when the particular event +***[[11]](#[0])*** is triggered. This makes sure the upper-level Redfish +resource is built up before the lower-level resource. For example, +ComputerSystem resource must be ready before the Memory resource managed +by MemoryCollection because the Memory resource is part of ComputerSystem +resource. + +### Start-Up Event to Trigger EDKII Redfish Feature Core ***[[11]](#[0])*** +This is an EFI event for triggering EDKII Redfish Feature Core to travel +URIs in the database and execute the callback that registered by Redfish f= eature +drivers. The event GUID is defined in below PCD and is default set to +**gEfiEventReadyToBootGuid**. + +```C +PcdEdkIIRedfishFeatureDriverStartupEventGuid +``` + +This PCD can be overridden to any events based on the platform +implementation. EDKII Redfish Feature Core can be triggered earlier, +for example before the BDS or in the early DXE phase if the platform provi= des +the EFI REST EX protocol which is available before the BDS phase. + ### EDK2 HII VFR Form ***[[8]](#[0])*** According to **UEFI spec 2.9 section 35.6 Form Browser Protocol**, **EFI_HII_REST_STYLE_FORMSET_GUID** is used on HII form to indicate that H= II --=20 2.37.1.windows.1 -=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 (#103889): https://edk2.groups.io/g/devel/message/103889 Mute This Topic: https://groups.io/mt/98657046/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-