From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 60A45940F22 for ; Thu, 7 Mar 2024 03:24:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=tFPbGGaqMPNE6UqwO1Iil/tNXZygI34Tv9RcQZvy5BE=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1709781858; v=1; b=fFrrQxPUvLR26y+I8th4LgAOIGJwXHngjKmKeZJTOLmt8UEOpAVk0Njzx/x4lo+9O8XLXgY8 WbD0qMAbBaGoDB5PYuJIUdX8N/HWVRya2ZDP+kAVq7g0QX6jBaQnHJ6nZxwYq1yz9vDTCLCES7k gqiSUgk12xHCv65NtJXmWjrfbWXqUtKOXr87csrAl991X7QzK3wrKiYE+zxVhVjbWKobfTrB+lv p33mpRiwQyGRDhbOvaJ8W/kNQnmhjqzxwJaVJYalyKZE2xO3EweAV6AgQVcZh0t2f9cg4GQgmy3 nt0oogN2nVwsMGpG7l7fDQXftn7abF0GUFu6tg8njK9nA== X-Received: by 127.0.0.2 with SMTP id tzwHYY7687511xdPyHqfDxDh; Wed, 06 Mar 2024 19:24:18 -0800 X-Received: from NAM04-BN8-obe.outbound.protection.outlook.com (NAM04-BN8-obe.outbound.protection.outlook.com [40.107.100.66]) by mx.groups.io with SMTP id smtpd.web11.15044.1709781857126073923 for ; Wed, 06 Mar 2024 19:24:17 -0800 X-Received: from BL0PR0102CA0014.prod.exchangelabs.com (2603:10b6:207:18::27) by PH7PR12MB7113.namprd12.prod.outlook.com (2603:10b6:510:1ec::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Thu, 7 Mar 2024 03:24:12 +0000 X-Received: from BN2PEPF000044AB.namprd04.prod.outlook.com (2603:10b6:207:18:cafe::df) by BL0PR0102CA0014.outlook.office365.com (2603:10b6:207:18::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26 via Frontend Transport; Thu, 7 Mar 2024 03:24:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by BN2PEPF000044AB.mail.protection.outlook.com (10.167.243.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Thu, 7 Mar 2024 03:24:11 +0000 X-Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 6 Mar 2024 19:24:00 -0800 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Wed, 6 Mar 2024 19:23:59 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Wed, 6 Mar 2024 19:23:58 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [edk2-redfish-client][PATCH v3 2/2] RedfishClientPkg/Edk2RedfishResourceConfigLib: support config2 protocol Date: Wed, 06 Mar 2024 19:24:17 -0800 Message-ID: <20240307032358.42644-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044AB:EE_|PH7PR12MB7113:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c6c73a4-f8df-4b95-9173-08dc3e560ee0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: WbghZl9KG/+2WJmpbBj9Zfkf5W7ZHVIqEFucT6JjEQhqBxRVzH4z/KeEXH9TW51AbCIi9EsD0rYBRkrvJepXGjZsgtyxSvM/ripWsJLHZwgLwAVe41+ND/ru2AlkIf5gNKi5DiX4obs5JkP0KHCm5lGV/TSZwfC/h3DApieB6yTs7JcemA3J6KONwa3DdBYtmU+A9hkh4kl/jEL/DiZVa+nYhsIdu+xJj2mhsPODMW3Yhj664EAWmou42diQiTmp/554ubCpXUhNkQ/d6WZGFFwWwjr/uEKOIcqo3P75Gr7yLYPLPnYh/vD2JwMn3vYjM/uHXowK5BfPdKjEl6CHk7nvqhZshXnvH9qhaznakY0of3Qf+3PBKfI6FIHm3ev7ysXCmmcNv6gNpHUujfDLKgunHqsZL3FqPaQu8L7bjtl/wExdVk1ZdXfvTkT2GQ0bGDIsMTS+RT78dEtzelAAhtoJmArZpC4QoWQm8YReq3zSkSwJSTs1MNeVqqNGJNirdKUM1gjJcVahiWSgKmnKZRH4LdJzCJuWHBvnqBhJaEs+3/K6rHu+UXLlhV+dKYcMeRo0wl/yMWvVZrx6kJfGTBm3u7YKAHrfs+s/y7zmuEfFybpG/FP5AHhGWYFmjDkwQbuYGd0bkicP2AMepbGf5nmWOd9xB+7YgSNEVXwxK7mrcdwI7YECETwfYl2kTSZyqFJqQPHiLpGS1nzQkvCjLpfeSzb/mHEIE0bDc2A589aUFvLzRImqlZ4P5ijdOIFu X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 03:24:11.5600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c6c73a4-f8df-4b95-9173-08dc3e560ee0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044AB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7113 Precedence: Bulk 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: WeVk7N9kPmQb6HJgULd6eLCux7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=fFrrQxPU; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io -Support Redfish resource config2 protocol in Edk2RedfishResourceConfigLib. This library will try Redfish resource config2 protocol first. And if there is no matching protocol found, Redfish resource config protocol will be used. -Because EdkIIRedfishResourceConfigLib is updated to support Redfish resource config2 protocol, update corresponding functions in feature drivers. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../EdkIIRedfishResourceConfigLib.inf | 4 +- .../Library/EdkIIRedfishResourceConfigLib.h | 33 +- .../EdkIIRedfishResourceConfigInternal.h | 44 ++ .../Features/Bios/v1_0_9/Common/BiosCommon.c | 14 +- .../BootOptionCollectionDxe.c | 14 +- .../ComputerSystemCollectionDxe.c | 16 +- .../MemoryCollectionDxe/MemoryCollectionDxe.c | 16 +- .../EdkIIRedfishResourceConfigLib.c | 391 ++++++++++++++---- 8 files changed, 415 insertions(+), 117 deletions(-) create mode 100644 RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/= EdkIIRedfishResourceConfigInternal.h diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRe= dfishResourceConfigLib.inf b/RedfishClientPkg/Library/EdkIIRedfishResourceC= onfigLib/EdkIIRedfishResourceConfigLib.inf index 2d10445f0..998a05c80 100644 --- a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.inf +++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.inf @@ -22,6 +22,7 @@ # =20 [Sources] + EdkIIRedfishResourceConfigInternal.h EdkIIRedfishResourceConfigLib.c =20 [Packages] @@ -42,8 +43,9 @@ RedfishHttpLib =20 [Protocols] - gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMES ## + gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMES ## gEdkIIRedfishFeatureInterchangeDataProtocolGuid ## CONSUMES ## + gEdkIIRedfishResourceConfig2ProtocolGuid ## CONSUEMS ## =20 [Pcd] gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize diff --git a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib= .h b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h index 3aa953cec..57c7f2b80 100644 --- a/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h +++ b/RedfishClientPkg/Include/Library/EdkIIRedfishResourceConfigLib.h @@ -16,6 +16,7 @@ #include #include #include +#include #include =20 /** @@ -23,6 +24,7 @@ =20 @param[in] Schema Redfish schema information. @param[in] Uri Target URI to create resource. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST method is used. FALSE if the resource exist but some of= properties are missing, @@ -33,9 +35,11 @@ =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigProvisioning ( IN REDFISH_SCHEMA_INFO *Schema, IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL, IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange, IN BOOLEAN HttpPostMode ); @@ -45,15 +49,18 @@ EdkIIRedfishResourceConfigProvisioning ( =20 @param[in] Schema Redfish schema information. @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. =20 @retval EFI_SUCCESS Value is returned successfully. @retval Others Some error happened. =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigConsume ( IN REDFISH_SCHEMA_INFO *Schema, - IN EFI_STRING Uri + IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL ); =20 /** @@ -61,21 +68,25 @@ EdkIIRedfishResourceConfigConsume ( =20 @param[in] Schema Redfish schema information. @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. =20 @retval EFI_SUCCESS Value is returned successfully. @retval Others Some error happened. =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigUpdate ( IN REDFISH_SCHEMA_INFO *Schema, - IN EFI_STRING Uri + IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL ); =20 /** Check resource on given URI. =20 @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. =20 @retval EFI_SUCCESS Value is returned successfully. @retval EFI_UNSUPPORTED This resource is not owned by feature d= river. @@ -84,9 +95,11 @@ EdkIIRedfishResourceConfigUpdate ( =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigCheck ( IN REDFISH_SCHEMA_INFO *Schema, - IN EFI_STRING Uri + IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL ); =20 /** @@ -94,6 +107,7 @@ EdkIIRedfishResourceConfigCheck ( =20 @param[in] Schema Redfish schema information. @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. =20 @retval EFI_SUCCESS This is target resource which we want t= o handle. @@ -107,10 +121,12 @@ EdkIIRedfishResourceConfigCheck ( =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigIdentify ( IN REDFISH_SCHEMA_INFO *Schema, IN EFI_STRING Uri, - IN RESOURCE_INFORMATION_EXCHANGE *InformationExchangeUri + IN CHAR8 *JsonText OPTIONAL, + IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange ); =20 /** @@ -126,6 +142,7 @@ EdkIIRedfishResourceConfigIdentify ( =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceSetConfigureLang ( IN EFI_HANDLE ImageHandle, IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList @@ -133,11 +150,14 @@ EdkIIRedfishResourceSetConfigureLang ( =20 /** =20 - Get schema information by given protocol and service instance. + Get schema information by given protocol and service instance if JsonTex= t + is NULL or empty. When JsonText is provided by caller, this function rea= d + schema information from JsonText. =20 @param[in] RedfishService Pointer to Redfish service instance. @param[in] JsonStructProtocol Json Structure protocol instance. @param[in] Uri Target URI. + @param[in] JsonText Redfish data in JSON format. This is opt= ional. @param[out] SchemaInfo Returned schema information. =20 @retval EFI_SUCCESS Schema information is returned successfu= lly. @@ -145,10 +165,12 @@ EdkIIRedfishResourceSetConfigureLang ( =20 **/ EFI_STATUS +EFIAPI GetRedfishSchemaInfo ( IN REDFISH_SERVICE *RedfishService, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL, OUT REDFISH_SCHEMA_INFO *SchemaInfo ); =20 @@ -164,6 +186,7 @@ GetRedfishSchemaInfo ( =20 **/ EFI_STATUS +EFIAPI GetSupportedSchemaVersion ( IN CHAR8 *Schema, OUT REDFISH_SCHEMA_INFO *SchemaInfo diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRe= dfishResourceConfigInternal.h b/RedfishClientPkg/Library/EdkIIRedfishResour= ceConfigLib/EdkIIRedfishResourceConfigInternal.h new file mode 100644 index 000000000..51984738b --- /dev/null +++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigInternal.h @@ -0,0 +1,44 @@ +/** @file + Header file of EDKII Redfish Resource Config Library. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef REDFISH_RESOURCE_CONFIG_INTERNAL_H_ +#define REDFISH_RESOURCE_CONFIG_INTERNAL_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/// +/// Definition of EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOLS +/// +typedef union { + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol; + EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol; +} EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOLS; + +/// +/// Definition of REDFISH_CONFIG_PROTOCOL_CACHE +/// +typedef struct { + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOLS RedfishResourceConfig; + EFI_HANDLE CachedHandle; + REDFISH_SCHEMA_INFO SchemaInfoCache; +} REDFISH_CONFIG_PROTOCOL_CACHE; + +#define SCHEMA_NAME_PREFIX "x-uefi-redfish-" +#define SCHEMA_NAME_PREFIX_OFFSET (AsciiStrLen (SCHEMA_NAME_PREFIX)) + +#endif diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c b/Re= dfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c index 1f3c30147..1eb269a84 100644 --- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c @@ -782,7 +782,7 @@ HandleResource ( =20 DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\n", __func__,= Uri)); =20 - Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, &SchemaInfo); + Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, NULL, &SchemaInfo); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %s %r= \n", __func__, Uri, Status)); return Status; @@ -795,7 +795,7 @@ HandleResource ( DEBUG ((REDFISH_DEBUG_TRACE, "%a Identify for %s\n", __func__, Uri)); ConfigLang =3D RedfishGetConfigLanguage (Uri); if (ConfigLang =3D=3D NULL) { - Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, NULL,= Private->InformationExchange); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_UNSUPPORTED) { DEBUG ((DEBUG_MANAGEABILITY, "%a, \"%s\" is not handled by us\n", = __func__, Uri)); @@ -811,17 +811,17 @@ HandleResource ( } =20 // - // Check and see if target property exist or not even when collection me= meber exists. + // Check and see if target property exist or not even when collection me= mber exists. // If not, we sill do provision. // DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { // // The target property does not exist, do the provision to create prop= erty. // DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, P= rivate->InformationExchange, FALSE); + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, N= ULL, Private->InformationExchange, FALSE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", = __func__, Status)); } @@ -833,7 +833,7 @@ HandleResource ( // Consume first. // DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to consume resource for: %s: %r\n", _= _func__, Uri, Status)); } @@ -842,7 +842,7 @@ HandleResource ( // Patch. // DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to update resource for: %s: %r\n", __= func__, Uri, Status)); } diff --git a/RedfishClientPkg/Features/BootOptionCollection/BootOptionColle= ctionDxe.c b/RedfishClientPkg/Features/BootOptionCollection/BootOptionColle= ctionDxe.c index 4f94a4495..cd1437f54 100644 --- a/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDx= e.c +++ b/RedfishClientPkg/Features/BootOptionCollection/BootOptionCollectionDx= e.c @@ -44,7 +44,7 @@ HandleResource ( =20 DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: process resourc= e for: %s\n", __func__, Uri)); =20 - Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, &SchemaInfo); + Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, NULL, &SchemaInfo); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to get schema information from: %s %r= \n", __func__, Uri, Status)); return Status; @@ -58,7 +58,7 @@ HandleResource ( SystemRestDetected =3D FALSE; ConfigLang =3D RedfishGetConfigLanguage (Uri); if (ConfigLang =3D=3D NULL) { - Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, NULL,= Private->InformationExchange); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_UNSUPPORTED) { DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: \"%s\" is= not handled by us\n", __func__, Uri)); @@ -88,7 +88,7 @@ HandleResource ( // If not, we sill do provision. // DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a Check for %s\n",= __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_UNSUPPORTED) { DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: \"%s\" is n= ot handled by us\n", __func__, Uri)); @@ -99,7 +99,7 @@ HandleResource ( // The target property does not exist, do the provision to create prop= erty. // DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a provision for = %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, P= rivate->InformationExchange, FALSE); + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, N= ULL, Private->InformationExchange, FALSE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to provision with GET mode: %r\n", = __func__, Status)); } @@ -114,7 +114,7 @@ HandleResource ( DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a system has bee= n reset to default setting. ignore pending settings because they may be sta= le values\n", __func__)); } else { DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a consume for %s= \n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to consume resource for: %s: %r\n",= __func__, Uri, Status)); } @@ -124,7 +124,7 @@ HandleResource ( // Patch. // DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a update for %s\n"= , __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to update resource for: %s: %r\n", __= func__, Uri, Status)); } @@ -262,7 +262,7 @@ CreateCollectionResource ( =20 DEBUG ((REDFISH_BOOT_OPTION_COLLECTION_DEBUG_TRACE, "%a: supported schem= a: %a %a.%a.%a\n", __func__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInf= o.Minor, SchemaInfo.Errata)); =20 - Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, BootOpti= onUri, Private->InformationExchange, TRUE); + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, BootOpti= onUri, NULL, Private->InformationExchange, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to create resource for: %s: %r\n", __= func__, BootOptionUri, Status)); } diff --git a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/Computer= SystemCollectionDxe.c b/RedfishClientPkg/Features/ComputerSystemCollectionD= xe/ComputerSystemCollectionDxe.c index 975ba0564..55a6d07db 100644 --- a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC= ollectionDxe.c +++ b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemC= ollectionDxe.c @@ -35,7 +35,7 @@ HandleResource ( =20 DEBUG ((REDFISH_DEBUG_TRACE, "%a: process resource for: %s\n", __func__,= Uri)); =20 - Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, &SchemaInfo); + Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, NULL, &SchemaInfo); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to get schema information from: %s %r= \n", __func__, Uri, Status)); return Status; @@ -48,7 +48,7 @@ HandleResource ( DEBUG ((REDFISH_DEBUG_TRACE, "%a Identify for %s\n", __func__, Uri)); ConfigLang =3D RedfishGetConfigLanguage (Uri); if (ConfigLang =3D=3D NULL) { - Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, NULL,= Private->InformationExchange); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_UNSUPPORTED) { DEBUG ((DEBUG_MANAGEABILITY, "%a: \"%s\" is not handled by us\n", = __func__, Uri)); @@ -90,11 +90,11 @@ HandleResource ( } =20 // - // Check and see if target property exist or not even when collection me= meber exists. + // Check and see if target property exist or not even when collection me= mber exists. // If not, we sill do provision. // DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_UNSUPPORTED) { DEBUG ((REDFISH_DEBUG_TRACE, "%a: \"%s\" is not handled by us\n", __= func__, Uri)); @@ -105,7 +105,7 @@ HandleResource ( // The target property does not exist, do the provision to create prop= erty. // DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, P= rivate->InformationExchange, FALSE); + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, N= ULL, Private->InformationExchange, FALSE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to provision with PATCH mode: %r\n"= , __func__, Status)); } @@ -117,7 +117,7 @@ HandleResource ( // Consume first. // DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to consume resource for: %s: %r\n", _= _func__, Uri, Status)); } @@ -126,7 +126,7 @@ HandleResource ( // Patch. // DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to update resource for: %s: %r\n", __= func__, Uri, Status)); } @@ -236,7 +236,7 @@ CreateCollectionResource ( =20 DEBUG ((REDFISH_DEBUG_TRACE, "%a: supported schema: %a %a.%a.%a\n", __fu= nc__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Err= ata)); =20 - Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Private-= >CollectionUri, Private->InformationExchange, TRUE); + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Private-= >CollectionUri, NULL, Private->InformationExchange, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to create resource for: %s: %r\n", __= func__, Private->CollectionUri, Status)); } diff --git a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollection= Dxe.c b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c index 1b7d74e86..d963fb52a 100644 --- a/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c @@ -35,7 +35,7 @@ HandleResource ( =20 DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\n", __func__,= Uri)); =20 - Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, &SchemaInfo); + Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, NULL, &SchemaInfo); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %s %r= \n", __func__, Uri, Status)); return Status; @@ -48,7 +48,7 @@ HandleResource ( DEBUG ((REDFISH_DEBUG_TRACE, "%a Identify for %s\n", __func__, Uri)); ConfigLang =3D RedfishGetConfigLanguage (Uri); if (ConfigLang =3D=3D NULL) { - Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, NULL,= Private->InformationExchange); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_UNSUPPORTED) { DEBUG ((DEBUG_MANAGEABILITY, "%a, \"%s\" is not handled by us\n", = __func__, Uri)); @@ -86,17 +86,17 @@ HandleResource ( } =20 // - // Check and see if target property exist or not even when collection me= meber exists. + // Check and see if target property exist or not even when collection me= mber exists. // If not, we sill do provision. // DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { // // The target property does not exist, do the provision to create prop= erty. // DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, P= rivate->InformationExchange, FALSE); + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Uri, N= ULL, Private->InformationExchange, FALSE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", = __func__, Status)); } @@ -108,7 +108,7 @@ HandleResource ( // Consume first. // DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to consume resource for: %s: %r\n", _= _func__, Uri, Status)); } @@ -117,7 +117,7 @@ HandleResource ( // Patch. // DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __func__, Uri)); - Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri, NULL); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to update resource for: %s: %r\n", __= func__, Uri, Status)); } @@ -227,7 +227,7 @@ CreateCollectionResource ( =20 DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a %a.%a.%a\n", __fu= nc__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Err= ata)); =20 - Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Private-= >CollectionUri, Private->InformationExchange, TRUE); + Status =3D EdkIIRedfishResourceConfigProvisioning (&SchemaInfo, Private-= >CollectionUri, NULL, Private->InformationExchange, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to create resource for: %s: %r\n", __= func__, Private->CollectionUri, Status)); } diff --git a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRe= dfishResourceConfigLib.c b/RedfishClientPkg/Library/EdkIIRedfishResourceCon= figLib/EdkIIRedfishResourceConfigLib.c index 5d0944f8c..4ba5c309d 100644 --- a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.c +++ b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRe= sourceConfigLib.c @@ -7,32 +7,23 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *mRedfishResourceConfigPr= otocol =3D NULL; -EFI_HANDLE mCachedHandle; -EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL mRedfishFeatureInterchang= eData; -REDFISH_SCHEMA_INFO mSchemaInfoCache; =20 -#define SCHEMA_NAME_PREFIX "x-uefi-redfish-" -#define SCHEMA_NAME_PREFIX_OFFSET (AsciiStrLen (SCHEMA_NAME_PREFIX)) +#include "EdkIIRedfishResourceConfigInternal.h" + +REDFISH_CONFIG_PROTOCOL_CACHE *mRedfishResourceConfigCa= che =3D NULL; +REDFISH_CONFIG_PROTOCOL_CACHE *mRedfishResourceConfig2C= ache =3D NULL; +EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL mRedfishFeatureInterchang= eData; =20 /** =20 - Get schema information by given protocol and service instance. + Get schema information by given protocol and service instance if JsonTex= t + is NULL or empty. When JsonText is provided by caller, this function rea= d + schema information from JsonText. =20 @param[in] RedfishService Pointer to Redfish service instance. @param[in] JsonStructProtocol Json Structure protocol instance. @param[in] Uri Target URI. + @param[in] JsonText Redfish data in JSON format. This is opt= ional. @param[out] SchemaInfo Returned schema information. =20 @retval EFI_SUCCESS Schema information is returned successfu= lly. @@ -40,35 +31,45 @@ REDFISH_SCHEMA_INFO mSchem= aInfoCache; =20 **/ EFI_STATUS +EFIAPI GetRedfishSchemaInfo ( IN REDFISH_SERVICE *RedfishService, IN EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol, IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL, OUT REDFISH_SCHEMA_INFO *SchemaInfo ) { EFI_STATUS Status; REDFISH_RESPONSE Response; - REDFISH_PAYLOAD Payload; - CHAR8 *JsonText; + CHAR8 *JsonData; EFI_REST_JSON_STRUCTURE_HEADER *Header; =20 if ((RedfishService =3D=3D NULL) || (JsonStructProtocol =3D=3D NULL) || = IS_EMPTY_STRING (Uri) || (SchemaInfo =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 + JsonData =3D NULL; + Header =3D NULL; ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (RedfishService, Uri, NULL, &Response,= TRUE); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to get resource from %s: %r", __func_= _, Uri, Status)); - return Status; - } + if (IS_EMPTY_STRING (JsonText)) { + Status =3D RedfishHttpGetResource (RedfishService, Uri, NULL, &Respons= e, TRUE); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: failed to get resource from %s: %r", __fun= c__, Uri, Status)); + return Status; + } =20 - Payload =3D Response.Payload; - ASSERT (Payload !=3D NULL); + if (Response.Payload !=3D NULL) { + JsonData =3D JsonDumpString (RedfishJsonInPayload (Response.Payload)= , EDKII_JSON_COMPACT); + } + } else { + JsonData =3D AllocateCopyPool (AsciiStrSize (JsonText), JsonText); + } =20 - JsonText =3D JsonDumpString (RedfishJsonInPayload (Payload), EDKII_JSON_= COMPACT); - ASSERT (JsonText !=3D NULL); + if (IS_EMPTY_STRING (JsonData)) { + Status =3D EFI_NOT_FOUND; + goto ON_RELEASE; + } =20 // // Convert JSON text to C structure. @@ -76,17 +77,12 @@ GetRedfishSchemaInfo ( Status =3D JsonStructProtocol->ToStructure ( JsonStructProtocol, NULL, - JsonText, + JsonData, &Header ); if (EFI_ERROR (Status)) { - if (Status =3D=3D EFI_UNSUPPORTED) { - DEBUG ((DEBUG_ERROR, "%a, No proper JSON to C structure converter fo= r this Redfish resource.\n", __func__)); - } else { - DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __func__, Sta= tus)); - } - - return Status; + DEBUG ((DEBUG_ERROR, "%a: ToStructure() failed: %r\n", __func__, Statu= s)); + goto ON_RELEASE; } =20 AsciiStrCpyS (SchemaInfo->Schema, REDFISH_SCHEMA_STRING_SIZE, Header->Js= onRsrcIdentifier.NameSpace.ResourceTypeName); @@ -94,14 +90,19 @@ GetRedfishSchemaInfo ( AsciiStrCpyS (SchemaInfo->Minor, REDFISH_SCHEMA_VERSION_SIZE, Header->Js= onRsrcIdentifier.NameSpace.MinorVersion); AsciiStrCpyS (SchemaInfo->Errata, REDFISH_SCHEMA_VERSION_SIZE, Header->J= sonRsrcIdentifier.NameSpace.ErrataVersion); =20 +ON_RELEASE: // // Release resource. // JsonStructProtocol->DestoryStructure (JsonStructProtocol, Header); - FreePool (JsonText); + + if (JsonData !=3D NULL) { + FreePool (JsonData); + } + RedfishHttpFreeResponse (&Response); =20 - return EFI_SUCCESS; + return Status; } =20 /** @@ -116,6 +117,7 @@ GetRedfishSchemaInfo ( =20 **/ EFI_STATUS +EFIAPI GetSupportedSchemaVersion ( IN CHAR8 *Schema, OUT REDFISH_SCHEMA_INFO *SchemaInfo @@ -257,17 +259,17 @@ GetRedfishResourceConfigProtocol ( return NULL; } =20 - if (mRedfishResourceConfigProtocol !=3D NULL) { - if ((AsciiStrCmp (Schema->Schema, mSchemaInfoCache.Schema) =3D=3D 0) &= & - (AsciiStrCmp (Schema->Major, mSchemaInfoCache.Major) =3D=3D 0) && - (AsciiStrCmp (Schema->Minor, mSchemaInfoCache.Minor) =3D=3D 0) && - (AsciiStrCmp (Schema->Errata, mSchemaInfoCache.Errata) =3D=3D 0)) + if ((mRedfishResourceConfigCache !=3D NULL) && (mRedfishResourceConfigCa= che->RedfishResourceConfig.ConfigProtocol !=3D NULL)) { + if ((AsciiStrCmp (Schema->Schema, mRedfishResourceConfigCache->SchemaI= nfoCache.Schema) =3D=3D 0) && + (AsciiStrCmp (Schema->Major, mRedfishResourceConfigCache->SchemaIn= foCache.Major) =3D=3D 0) && + (AsciiStrCmp (Schema->Minor, mRedfishResourceConfigCache->SchemaIn= foCache.Minor) =3D=3D 0) && + (AsciiStrCmp (Schema->Errata, mRedfishResourceConfigCache->SchemaI= nfoCache.Errata) =3D=3D 0)) { if (Handle !=3D NULL) { - *Handle =3D mCachedHandle; + *Handle =3D mRedfishResourceConfigCache->CachedHandle; } =20 - return mRedfishResourceConfigProtocol; + return mRedfishResourceConfigCache->RedfishResourceConfig.ConfigProt= ocol; } } =20 @@ -310,9 +312,116 @@ GetRedfishResourceConfigProtocol ( } =20 if (Found) { - mCachedHandle =3D HandleBuffer[Index]; - mRedfishResourceConfigProtocol =3D Protocol; - CopyMem (&mSchemaInfoCache, Schema, sizeof (REDFISH_SCHEMA_INFO)); + if (mRedfishResourceConfigCache !=3D NULL) { + mRedfishResourceConfigCache->CachedHandle = =3D HandleBuffer[Index]; + mRedfishResourceConfigCache->RedfishResourceConfig.ConfigProtocol = =3D Protocol; + CopyMem (&mRedfishResourceConfigCache->SchemaInfoCache, Schema, size= of (REDFISH_SCHEMA_INFO)); + } + + if (Handle !=3D NULL) { + *Handle =3D HandleBuffer[Index]; + } + } + + FreePool (HandleBuffer); + + return (Found ? Protocol : NULL); +} + +/** + + Find Redfish Resource Config2 Protocol that supports given schema and ve= rsion. + + @param[in] Schema Schema name. + @param[out] Handle Pointer to receive the handle that has EDKII_RED= FISH_RESOURCE_CONFIG2_PROTOCOL + installed on it. + + @retval EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL * Pointer to prot= ocol + @retval NULL No protocol fou= nd. + +**/ +EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL * +GetRedfishResourceConfig2Protocol ( + IN REDFISH_SCHEMA_INFO *Schema, + OUT EFI_HANDLE *Handle OPTIONAL + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN NumberOfHandles; + UINTN Index; + EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Protocol; + REDFISH_SCHEMA_INFO SchemaInfo; + BOOLEAN Found; + + if (IS_EMPTY_STRING (Schema->Schema) || + IS_EMPTY_STRING (Schema->Major) || + IS_EMPTY_STRING (Schema->Minor) || + IS_EMPTY_STRING (Schema->Errata) + ) + { + return NULL; + } + + if ((mRedfishResourceConfig2Cache !=3D NULL) && (mRedfishResourceConfig2= Cache->RedfishResourceConfig.Config2Protocol !=3D NULL)) { + if ((AsciiStrCmp (Schema->Schema, mRedfishResourceConfig2Cache->Schema= InfoCache.Schema) =3D=3D 0) && + (AsciiStrCmp (Schema->Major, mRedfishResourceConfig2Cache->SchemaI= nfoCache.Major) =3D=3D 0) && + (AsciiStrCmp (Schema->Minor, mRedfishResourceConfig2Cache->SchemaI= nfoCache.Minor) =3D=3D 0) && + (AsciiStrCmp (Schema->Errata, mRedfishResourceConfig2Cache->Schema= InfoCache.Errata) =3D=3D 0)) + { + if (Handle !=3D NULL) { + *Handle =3D mRedfishResourceConfig2Cache->CachedHandle; + } + + return mRedfishResourceConfig2Cache->RedfishResourceConfig.Config2Pr= otocol; + } + } + + Status =3D gBS->LocateHandleBuffer ( + ByProtocol, + &gEdkIIRedfishResourceConfig2ProtocolGuid, + NULL, + &NumberOfHandles, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + Found =3D FALSE; + + for (Index =3D 0; Index < NumberOfHandles; Index++) { + Status =3D gBS->HandleProtocol ( + HandleBuffer[Index], + &gEdkIIRedfishResourceConfig2ProtocolGuid, + (VOID **)&Protocol + ); + if (EFI_ERROR (Status)) { + continue; + } + + Status =3D Protocol->GetInfo (Protocol, &SchemaInfo); + if (EFI_ERROR (Status)) { + continue; + } + + if ((AsciiStrCmp (Schema->Schema, SchemaInfo.Schema) =3D=3D 0) && + (AsciiStrCmp (Schema->Major, SchemaInfo.Major) =3D=3D 0) && + (AsciiStrCmp (Schema->Minor, SchemaInfo.Minor) =3D=3D 0) && + (AsciiStrCmp (Schema->Errata, SchemaInfo.Errata) =3D=3D 0)) + { + Found =3D TRUE; + break; + } + } + + if (Found) { + if (mRedfishResourceConfig2Cache !=3D NULL) { + mRedfishResourceConfig2Cache->CachedHandle = =3D HandleBuffer[Index]; + mRedfishResourceConfig2Cache->RedfishResourceConfig.Config2Protocol = =3D Protocol; + CopyMem (&mRedfishResourceConfig2Cache->SchemaInfoCache, Schema, siz= eof (REDFISH_SCHEMA_INFO)); + } + if (Handle !=3D NULL) { *Handle =3D HandleBuffer[Index]; } @@ -379,6 +488,7 @@ InstallInterchangeDataProtocol ( =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceSetConfigureLang ( IN EFI_HANDLE ImageHandle, IN REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST *ConfigLangList @@ -411,7 +521,7 @@ EdkIIRedfishResourceSetConfigureLang ( Interface->ResourceInformationExchage->ReturnedInformation.ConfigureLang= uageList.List =3D AllocateZeroPool (sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG) * Co= nfigLangList->Count); if (Interface->ResourceInformationExchage->ReturnedInformation.Configure= LanguageList.List =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEATURE_= ARRAY_TYPE_CONFIG_LANG.\n", __func__)); + DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for REDFISH_FEATURE_= ARRAY_TYPE_CONFIG_LANG.\n", __func__)); return EFI_OUT_OF_RESOURCES; } =20 @@ -425,10 +535,11 @@ EdkIIRedfishResourceSetConfigureLang ( } =20 /** - Provising redfish resource by given URI. + Provision redfish resource by given URI. =20 @param[in] Schema Redfish schema information. @param[in] Uri Target URI to create resource. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. @param[in] HttpPostMode TRUE if resource does not exist, HTTP P= OST method is used. FALSE if the resource exist but some of= properties are missing, @@ -439,18 +550,41 @@ EdkIIRedfishResourceSetConfigureLang ( =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigProvisioning ( IN REDFISH_SCHEMA_INFO *Schema, IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL, IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange, IN BOOLEAN HttpPostMode ) { - EFI_HANDLE Handle; - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + EFI_HANDLE Handle; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol; + EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol; =20 - protocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle); - if ((protocol =3D=3D NULL) || (Handle =3D=3D NULL)) { + // + // Initialization. + // + Handle =3D NULL; + ConfigProtocol =3D NULL; + Config2Protocol =3D NULL; + + // + // Try to use config2 protocol first. + // + Config2Protocol =3D GetRedfishResourceConfig2Protocol (Schema, &Handle); + if ((Config2Protocol !=3D NULL) && (Handle !=3D NULL)) { + // + // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the chil= d + // feature driver handle. + // + InstallInterchangeDataProtocol (Handle, InformationExchange); + return Config2Protocol->Provisioning (Config2Protocol, Uri, JsonText, = HttpPostMode); + } + + ConfigProtocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle); + if ((ConfigProtocol =3D=3D NULL) || (Handle =3D=3D NULL)) { return EFI_DEVICE_ERROR; } =20 @@ -459,7 +593,7 @@ EdkIIRedfishResourceConfigProvisioning ( // feature driver handle. // InstallInterchangeDataProtocol (Handle, InformationExchange); - return protocol->Provisioning (protocol, Uri, HttpPostMode); + return ConfigProtocol->Provisioning (ConfigProtocol, Uri, HttpPostMode); } =20 /** @@ -467,25 +601,43 @@ EdkIIRedfishResourceConfigProvisioning ( =20 @param[in] Schema Redfish schema information. @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. =20 @retval EFI_SUCCESS Value is returned successfully. @retval Others Some error happened. =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigConsume ( IN REDFISH_SCHEMA_INFO *Schema, - IN EFI_STRING Uri + IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL ) { - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol; + EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol; =20 - protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); - if (protocol =3D=3D NULL) { + // + // Initialization. + // + ConfigProtocol =3D NULL; + Config2Protocol =3D NULL; + + // + // Try to use config2 protocol first. + // + Config2Protocol =3D GetRedfishResourceConfig2Protocol (Schema, NULL); + if (Config2Protocol !=3D NULL) { + return Config2Protocol->Consume (Config2Protocol, Uri, JsonText); + } + + ConfigProtocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (ConfigProtocol =3D=3D NULL) { return EFI_DEVICE_ERROR; } =20 - return protocol->Consume (protocol, Uri); + return ConfigProtocol->Consume (ConfigProtocol, Uri); } =20 /** @@ -493,25 +645,43 @@ EdkIIRedfishResourceConfigConsume ( =20 @param[in] Schema Redfish schema information. @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. =20 @retval EFI_SUCCESS Value is returned successfully. @retval Others Some error happened. =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigUpdate ( IN REDFISH_SCHEMA_INFO *Schema, - IN EFI_STRING Uri + IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL ) { - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol; + EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol; + + // + // Initialization. + // + ConfigProtocol =3D NULL; + Config2Protocol =3D NULL; =20 - protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); - if (protocol =3D=3D NULL) { + // + // Try to use config2 protocol first. + // + Config2Protocol =3D GetRedfishResourceConfig2Protocol (Schema, NULL); + if (Config2Protocol !=3D NULL) { + return Config2Protocol->Update (Config2Protocol, Uri, JsonText); + } + + ConfigProtocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (ConfigProtocol =3D=3D NULL) { return EFI_DEVICE_ERROR; } =20 - return protocol->Update (protocol, Uri); + return ConfigProtocol->Update (ConfigProtocol, Uri); } =20 /** @@ -519,25 +689,43 @@ EdkIIRedfishResourceConfigUpdate ( =20 @param[in] Schema Redfish schema information. @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. =20 @retval EFI_SUCCESS Value is returned successfully. @retval Others Some error happened. =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigCheck ( IN REDFISH_SCHEMA_INFO *Schema, - IN EFI_STRING Uri + IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL ) { - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol; + EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol; + + // + // Initialization. + // + ConfigProtocol =3D NULL; + Config2Protocol =3D NULL; + + // + // Try to use config2 protocol first. + // + Config2Protocol =3D GetRedfishResourceConfig2Protocol (Schema, NULL); + if (Config2Protocol !=3D NULL) { + return Config2Protocol->Check (Config2Protocol, Uri, JsonText); + } =20 - protocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); - if (protocol =3D=3D NULL) { + ConfigProtocol =3D GetRedfishResourceConfigProtocol (Schema, NULL); + if (ConfigProtocol =3D=3D NULL) { return EFI_DEVICE_ERROR; } =20 - return protocol->Check (protocol, Uri); + return ConfigProtocol->Check (ConfigProtocol, Uri); } =20 /** @@ -545,6 +733,7 @@ EdkIIRedfishResourceConfigCheck ( =20 @param[in] Schema Redfish schema information. @param[in] Uri The target URI to consume. + @param[in] JsonText The JSON data in ASCII string format. T= his is optional. @param[in] InformationExchange Pointer to RESOURCE_INFORMATION_EXCHANG= E. =20 @retval EFI_SUCCESS This is target resource which we want t= o handle. @@ -553,17 +742,40 @@ EdkIIRedfishResourceConfigCheck ( =20 **/ EFI_STATUS +EFIAPI EdkIIRedfishResourceConfigIdentify ( IN REDFISH_SCHEMA_INFO *Schema, IN EFI_STRING Uri, + IN CHAR8 *JsonText OPTIONAL, IN RESOURCE_INFORMATION_EXCHANGE *InformationExchange ) { - EFI_HANDLE Handle; - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *protocol; + EFI_HANDLE Handle; + EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *ConfigProtocol; + EDKII_REDFISH_RESOURCE_CONFIG2_PROTOCOL *Config2Protocol; + + // + // Initialization. + // + Handle =3D NULL; + ConfigProtocol =3D NULL; + Config2Protocol =3D NULL; + + // + // Try to use config2 protocol first. + // + Config2Protocol =3D GetRedfishResourceConfig2Protocol (Schema, &Handle); + if ((Config2Protocol !=3D NULL) && (Handle !=3D NULL)) { + // + // Install EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL on the chil= d + // feature driver handle. + // + InstallInterchangeDataProtocol (Handle, InformationExchange); + return Config2Protocol->Identify (Config2Protocol, Uri, JsonText); + } =20 - protocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle); - if (protocol =3D=3D NULL) { + ConfigProtocol =3D GetRedfishResourceConfigProtocol (Schema, &Handle); + if (ConfigProtocol =3D=3D NULL) { return EFI_DEVICE_ERROR; } =20 @@ -572,17 +784,17 @@ EdkIIRedfishResourceConfigIdentify ( // feature driver handle. // InstallInterchangeDataProtocol (Handle, InformationExchange); - return protocol->Identify (protocol, Uri); + return ConfigProtocol->Identify (ConfigProtocol, Uri); } =20 /** =20 - Initial resource config library instace. + Initial resource config library instance. =20 @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. =20 - @retval EFI_SUCEESS Install Boot manager menu success. + @retval EFI_SUCCESS Install Boot manager menu success. @retval Other Return error status. =20 **/ @@ -593,8 +805,17 @@ RedfishResourceConfigConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - mRedfishResourceConfigProtocol =3D NULL; - ZeroMem (&mSchemaInfoCache, sizeof (REDFISH_SCHEMA_INFO)); + mRedfishResourceConfigCache =3D AllocateZeroPool (sizeof (REDFISH_CONFIG= _PROTOCOL_CACHE)); + if (mRedfishResourceConfigCache =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + mRedfishResourceConfig2Cache =3D AllocateZeroPool (sizeof (REDFISH_CONFI= G_PROTOCOL_CACHE)); + if (mRedfishResourceConfig2Cache =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ZeroMem (&mRedfishFeatureInterchangeData, sizeof (mRedfishFeatureInterch= angeData)); =20 return EFI_SUCCESS; } @@ -615,7 +836,15 @@ RedfishResourceConfigDestructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - mRedfishResourceConfigProtocol =3D NULL; + if (mRedfishResourceConfigCache !=3D NULL) { + FreePool (mRedfishResourceConfigCache); + mRedfishResourceConfigCache =3D NULL; + } + + if (mRedfishResourceConfig2Cache !=3D NULL) { + FreePool (mRedfishResourceConfig2Cache); + mRedfishResourceConfig2Cache =3D NULL; + } =20 return EFI_SUCCESS; } --=20 2.34.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 (#116468): https://edk2.groups.io/g/devel/message/116468 Mute This Topic: https://groups.io/mt/104781209/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-