From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (NAM02-DM3-obe.outbound.protection.outlook.com [40.107.95.83]) by mx.groups.io with SMTP id smtpd.web11.15870.1683723876348010279 for ; Wed, 10 May 2023 06:04:36 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=Jw3yLqsr; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.95.83, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hTu547j+8IkXGhIRL01zg75DhBojyhC4dUDAYjneG8XlXCXx0B2S0cwlgvD3poQpAWkFZmGLMCp2XpeOCXhFtNRKdlnQ9BsWWRkUSG+rxTZhDVSSvfoexbFsnXiOe/dFEAztwT7dEdy3XG/lhhAlkE7p1k0yl9Gy3Al4XJZqKxEu82frFJ4i+85coU1xMID09mvtZ4FlYD8H5c2JllA7bF85Tq4Lzm7F7oOmPgzU9v/bDF8ipQdS8oB9ZIRmBDE6FljzrqBporiF6fEkda0jXa6bgpJ0da8r2WDdM14CMkuglxnzhzGdVnxYhNhYw4F0zkTQ4p/ABUxPN+WdrDRebA== 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=AEIagJMDR32SC+JnQmVgCWPJphbyopuXv4n1bIOsVXY=; b=MN8Cc2FmL/Lvy7vRFU+6RokrB40Avv75E7Dg906XOlkIyUYcqTLzCxxb8bElmiPGuewtqX9jr6SuhVzLcy+YWF1qC10Kk3VvTxqYFnYdI3DVtdbBllzE4Mi7ZJTmLrsWTAVIZJbiVs3EXM4qufr/HZrbVCXZ62PYnye3tf+d16x0SOhInAD4ZP9uxTEnflvAqGn5agOq7P9A+uT9ebG8R9GHDrLfsljU1Dqi3wrojVAWqnMiyYEAF0iqQzkijchpL5mzbDyw21sksyfukiJchQ5/VSuY9phOVN3OYdoXJrtoNavs117RVQXpoQf8mruPVZ0ofTeUdYF4AV11boHySA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AEIagJMDR32SC+JnQmVgCWPJphbyopuXv4n1bIOsVXY=; b=Jw3yLqsrI9O8hVcP25VhTT97t3iRo9rGua7auIrO1h3hc4ZmWjA1EBqq6xixA75KwrPNm8qzxZoqm7QgoeeuBvrFLRv7UMWS2eQvwErRUWX7ZOj409tT2Od0rI0wa/s1LrQXSrhRn9WDLV13mmgoOujBsYhP/t7f1X1r462fv/cnpM7EzmMoEbh7hGQifLlyOeIPmnf0aNWzdd++b2nioYViLB9JAbNCegmEozkElaRc3Lw3JH7c/xU+gUrMqCut+wsJnhUM7Aj4ztim/aUh07niWwhjWuxA5p5vi+mQ/bVUmx9tBTso68OXbDGl5tifLu7ajFCV9Y5oOjzagojFkQ== Received: from BN9PR03CA0878.namprd03.prod.outlook.com (2603:10b6:408:13c::13) by BY5PR12MB4291.namprd12.prod.outlook.com (2603:10b6:a03:20c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Wed, 10 May 2023 13:04:32 +0000 Received: from BN8NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13c:cafe::90) by BN9PR03CA0878.outlook.office365.com (2603:10b6:408:13c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.20 via Frontend Transport; Wed, 10 May 2023 13:04:32 +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 Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT059.mail.protection.outlook.com (10.13.177.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.18 via Frontend Transport; Wed, 10 May 2023 13:04:32 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.5; Wed, 10 May 2023 06:04:18 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 10 May 2023 06:04:17 -0700 Received: from NV-CL38DL3.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 10 May 2023 06:04:17 -0700 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy Subject: [edk2-redfish-client][PATCH 1/5] RedfishClientPkg: Rename RedfishMemoryCollection driver Date: Wed, 10 May 2023 21:04:17 +0800 Message-ID: <20230510130417.9226-1-nicklew@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Return-Path: nicklew@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT059:EE_|BY5PR12MB4291:EE_ X-MS-Office365-Filtering-Correlation-Id: 902554f0-084f-4fb9-8a40-08db51571905 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sZb6zsHcvdi1wwJXuxhbe+hH42rWNqG77x2ngOCKnf6NyCNutGrsb/tqBrJ3ZWwanahdE+WcJYBuhP5LbpNgpT/DUEJ0m1SB+m8OsoE5/eyWDcbpV424YSTUVocrLLRvk82xMz1qE8wM+kCL1PWdurEu3YXAtGxoq692YMI7JtKLo9SZdYUiDh0eM6hjAlVYe+UR30G1Y2rDI3YmgTS9Yj3I5U6FsPz4jmOvL4Iy81M6DNIlJj85lQ8mEz1w2j3vjgZQ8tShZFBviuqlumvQIhp5+1cfbE6ygZfQjPAaDr/7/NmroJve9yeRADrTJSnTs4fYsTLBZCB8KzdoFtafVh/tYevcBaSSDT1ghxuUlLv9imc/ET4e+9CWl5plrqpNAWKancaaKEnZuemNBN/2SUNqLW+WDw/GOEQtHDesJeN/86RZ/xeAR21WoGK35SoZsMJjFXUaRZs9yIFEUSArl21QkZBqS4D3XkRXnFksBhBtJIX2dYSL1ejPfZanmrtnOoPjYZpi5sl2ecaB2V0KK72K0ELOAETEdK5K8Nd/X5c458adorSVLXSMJt3NT+GVAPUlTspOCdnel6Jag8+VbJWPTNjWRqEmKjsXbmRrv/OIbDEb4t/38Ma1UETMvT6GP5pAd5MkWB0HQhpSrLNxKpxZx/o4etKdXqbA3khqaEkRWfkEZC/VDnfa7fq6pnEDB0EX4vVTWM4tEJV56GEOKw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(36860700001)(83380400001)(316002)(70586007)(70206006)(426003)(6916009)(478600001)(47076005)(2616005)(7696005)(186003)(26005)(1076003)(54906003)(4326008)(40480700001)(2906002)(30864003)(86362001)(36756003)(82740400003)(82310400005)(41300700001)(336012)(356005)(5660300002)(8676002)(7636003)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 13:04:32.4980 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 902554f0-084f-4fb9-8a40-08db51571905 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: BN8NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4291 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Rename RedfishMemoryCollectionDxe by removing Redfish prefix. Update memory collection driver to support "Identify" action and also have code refactoring to support Redfish operation. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy --- .../RedfishClientComponents.dsc.inc | 2 +- .../MemoryCollectionDxe.inf} | 17 +- .../MemoryCollectionDxe.h} | 7 +- .../Include/RedfishCollectionCommon.h | 14 +- .../MemoryCollectionDxe.c} | 269 ++++++++++-------- RedfishClientPkg/RedfishClient.fdf.inc | 2 +- 6 files changed, 170 insertions(+), 141 deletions(-) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.inf =3D> MemoryCollectionDxe/MemoryCollectionDxe.inf} (71%) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.h =3D> MemoryCollectionDxe/MemoryCollectionDxe.h} (65%) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.c =3D> MemoryCollectionDxe/MemoryCollectionDxe.c} (65%) diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index ee4602fe..5f1aff3c 100644 --- a/RedfishClientPkg/RedfishClientComponents.dsc.inc +++ b/RedfishClientPkg/RedfishClientComponents.dsc.inc @@ -20,7 +20,7 @@ # Below two modules should be pulled in by build tool. # RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf - RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCollec= tionDxe.inf + RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf =20 !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc =20 diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.inf b/RedfishClientPkg/Features/MemoryCollectionDxe/Memor= yCollectionDxe.inf similarity index 71% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.inf rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .inf index c28a3bfe..05e05712 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.inf +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf @@ -1,15 +1,18 @@ ## @file # -# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+# Redfish MemoryCollection collection driver. +# +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ## =20 + [Defines] INF_VERSION =3D 0x00010005 - BASE_NAME =3D RedfishMemoryCollectionDxe - FILE_GUID =3D 9323359C-11E2-49BC-B501-D6280B6DAE1A + BASE_NAME =3D MemoryCollectionDxe + FILE_GUID =3D 22facf8f-a007-462c-9be4-638043a26858 MODULE_TYPE =3D DXE_DRIVER VERSION_STRING =3D 1.0 ENTRY_POINT =3D RedfishCollectionEntryPoint @@ -22,8 +25,8 @@ RedfishClientPkg/RedfishClientPkg.dec =20 [Sources] - RedfishMemoryCollectionDxe.h - RedfishMemoryCollectionDxe.c + MemoryCollectionDxe.h + MemoryCollectionDxe.c =20 [LibraryClasses] DebugLib @@ -35,15 +38,15 @@ UefiLib UefiDriverEntryPoint UefiBootServicesTableLib + EdkIIRedfishResourceConfigLib + RedfishVersionLib =20 [Protocols] gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMED gEfiRestJsonStructureProtocolGuid ## CONSUMED - gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMED gEdkIIRedfishFeatureProtocolGuid ## CONSUMED =20 [Guids] - gEfiEventReadyToBootGuid =20 [Pcd] gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.h b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryC= ollectionDxe.h similarity index 65% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.h rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .h index e5da48db..3d02285d 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.h +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.h @@ -1,7 +1,8 @@ /** @file + Redfish feature driver implementation - internal header file =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -14,5 +15,7 @@ #include =20 #define REDFISH_SCHEMA_NAME "Memory" -#define REDFISH_MANAGED_URI L"/redfish/v1/systems/{1}/memory" +#define REDFISH_MANAGED_URI L"Chassis/{}/Memory/{};Systems/{}/Memory/{}" +#define MAX_URI_LENGTH 256 + #endif diff --git a/RedfishClientPkg/Include/RedfishCollectionCommon.h b/RedfishCl= ientPkg/Include/RedfishCollectionCommon.h index 3c1e72b6..59cc3607 100644 --- a/RedfishClientPkg/Include/RedfishCollectionCommon.h +++ b/RedfishClientPkg/Include/RedfishCollectionCommon.h @@ -1,7 +1,7 @@ /** @file Redfish feature driver collection common header file. =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -10,6 +10,8 @@ #ifndef EFI_REDFISH_COLLECTION_COMMON_H_ #define EFI_REDFISH_COLLECTION_COMMON_H_ =20 +#include + // // Libraries // @@ -22,28 +24,30 @@ #include #include #include +#include +#include =20 // // Protocols // #include -#include #include #include #include =20 -#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D '\0') -#define REDFISH_DEBUG_TRACE DEBUG_INFO +#define REDFISH_MAX_COLLECTION_INDEX_LEN 8 =20 typedef struct _REDFISH_COLLECTION_PRIVATE { EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol; EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol; REDFISH_SERVICE RedfishService; + RESOURCE_INFORMATION_EXCHANGE *InformationExchange; EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL ConfigHandler; - CHAR8 *CollectionPath; + EFI_STRING CollectionUri; CHAR8 *CollectionJson; REDFISH_PAYLOAD CollectionPayload; REDFISH_RESPONSE RedResponse; + EFI_STRING RedfishVersion; } REDFISH_COLLECTION_PRIVATE; =20 #define REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL(This) \ diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.c b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryC= ollectionDxe.c similarity index 65% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.c rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .c index e70a7f76..c86628a4 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.c +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c @@ -1,67 +1,101 @@ /** @file - Redfish feature driver implementation - memory collection =20 - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
+ Redfish feature driver implementation - MemoryCollection + + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include "RedfishMemoryCollectionDxe.h" +#include "MemoryCollectionDxe.h" =20 REDFISH_COLLECTION_PRIVATE *mRedfishCollectionPrivate =3D NULL; =20 EFI_STATUS -ProcessResource ( +HandleResource ( IN REDFISH_COLLECTION_PRIVATE *Private, - IN CHAR8 *Uri + IN EFI_STRING Uri ) { - EFI_STATUS Status; - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol; - REDFISH_SCHEMA_INFO SchemaInfo; + EFI_STATUS Status; + REDFISH_SCHEMA_INFO SchemaInfo; + EFI_STRING ConfigLang; + EFI_STRING ReturnedConfigLang; + UINTN Index; =20 if ((Private =3D=3D NULL) || IS_EMPTY_STRING (Uri)) { return EFI_INVALID_PARAMETER; } =20 - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %a\n", __FUNCTIO= N__, Uri)); + // + // Resource match + // + + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\n", __FUNCTIO= N__, Uri)); =20 Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, &SchemaInfo); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %a %r= \n", __FUNCTION__, Uri, Status)); + DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %s %r= \n", __FUNCTION__, Uri, Status)); return Status; } =20 - RedfishResrouceProtocol =3D GetRedfishResourceConfigProtocol ( - SchemaInfo.Schema, - SchemaInfo.Major, - SchemaInfo.Minor, - SchemaInfo.Errata - ); - if (RedfishResrouceProtocol =3D=3D NULL) { - return EFI_DEVICE_ERROR; + // + // Check and see if this is target resource that we want to handle. + // Some resource is handled by other provider so we have to make sure th= is first. + // + DEBUG ((REDFISH_DEBUG_TRACE, "%s Identify for %s\n", __FUNCTION__, Uri))= ; + ConfigLang =3D RedfishGetConfigLanguage (Uri); + if (ConfigLang =3D=3D NULL) { + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_INFO, "%a, \"%s\" is not handled by us\n", __FUNCTIO= N__, Uri)); + return EFI_SUCCESS; + } + + DEBUG ((DEBUG_ERROR, "%a, fail to identify resource: \"%s\": %r\n", = __FUNCTION__, Uri, Status)); + return Status; + } + } else { + DEBUG ((REDFISH_DEBUG_TRACE, "%a, history record found: %s\n", __FUNCT= ION__, ConfigLang)); + // + // Set exchange information + // + Status =3D GetArrayIndexFromArrayTypeConfigureLang (ConfigLang, &Retur= nedConfigLang, &Index); + if (!EFI_ERROR (Status) || (Status =3D=3D EFI_NOT_FOUND)) { + Private->InformationExchange->ReturnedInformation.Type = =3D InformationTypeCollectionMemberConfigLanguage; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.Count =3D 1; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List =3D + AllocateZeroPool (sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG))= ; + + if (Private->InformationExchange->ReturnedInformation.ConfigureLangu= ageList.List =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEAT= URE_ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List[Index].Index =3D Index; + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List[Index].ConfigureLang =3D + (EFI_STRING)AllocateCopyPool (StrSize (ReturnedConfigLang), (VOID = *)ReturnedConfigLang); + } else { + DEBUG ((DEBUG_ERROR, "%a, GetArrayIndexFromArrayTypeConfigureLang fa= il: %r\n", __FUNCTION__, Status)); + } + + FreePool (ConfigLang); } =20 // // Check and see if target property exist or not even when collection me= meber exists. // If not, we sill do provision. // - DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %a\n", __FUNCTION__, Uri)); - Status =3D RedfishResrouceProtocol->Check ( - RedfishResrouceProtocol, - Uri - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri); if (EFI_ERROR (Status)) { // // The target property does not exist, do the provision to create prop= erty. // - DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %a\n", __FUNCTION__, Ur= i)); - Status =3D RedfishResrouceProtocol->Provisioning ( - RedfishResrouceProtocol, - Uri, - FALSE - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __FUNCTION__, Ur= i)); + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, = Private->InformationExchange, FALSE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", = __FUNCTION__, Status)); } @@ -72,41 +106,36 @@ ProcessResource ( // // Consume first. // - DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %a\n", __FUNCTION__, Uri)); - Status =3D RedfishResrouceProtocol->Consume ( - RedfishResrouceProtocol, - Uri - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %a %r\n", __= FUNCTION__, Uri, Status)); + DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %s: %r\n", _= _FUNCTION__, Uri, Status)); } =20 // // Patch. // - DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %a\n", __FUNCTION__, Uri)); - Status =3D RedfishResrouceProtocol->Update ( - RedfishResrouceProtocol, - Uri - ); + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __FUNCTION__, Uri)); + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, failed to update resoruce for: %s: %r\n", __= FUNCTION__, Uri, Status)); + } =20 return Status; } =20 EFI_STATUS -ProcessCollection ( +HandleCollectionResource ( IN REDFISH_COLLECTION_PRIVATE *Private ) { EFI_STATUS Status; - EFI_REDFISH_MEMORYCOLLECTION *Memory; + EFI_REDFISH_MEMORYCOLLECTION *Collection; EFI_REDFISH_MEMORYCOLLECTION_CS *CollectionCs; RedfishCS_Link *List; RedfishCS_Header *Header; RedfishCS_Type_Uri_Data *UriData; - CHAR8 *ConfigureLang; - UINTN Size; - UINTN Count; + EFI_STRING MemberUri; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -116,7 +145,7 @@ ProcessCollection ( return EFI_NOT_READY; } =20 - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %a\n", __FUNCT= ION__, Private->CollectionPath)); + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %s\n", __FUNCT= ION__, Private->CollectionUri)); =20 // // Convert JSON text to C structure. @@ -125,14 +154,14 @@ ProcessCollection ( Private->JsonStructProtocol, NULL, Private->CollectionJson, - (EFI_REST_JSON_STRUCTURE_HEADER = **)&Memory + (EFI_REST_JSON_STRUCTURE_HEADER = **)&Collection ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus)); return Status; } =20 - CollectionCs =3D Memory->MemoryCollection; + CollectionCs =3D Collection->MemoryCollection; =20 if (*CollectionCs->Membersodata_count =3D=3D 0) { return EFI_NOT_FOUND; @@ -142,22 +171,21 @@ ProcessCollection ( return EFI_NOT_FOUND; } =20 - Count =3D 0; - List =3D GetFirstLink (&CollectionCs->Members); + List =3D GetFirstLink (&CollectionCs->Members); while (TRUE) { Header =3D (RedfishCS_Header *)List; if (Header->ResourceType =3D=3D RedfishCS_Type_Uri) { - UriData =3D (RedfishCS_Type_Uri_Data *)Header; - - ++Count; - Size =3D AsciiStrLen (Private->CollectionPath) + 5; - ConfigureLang =3D AllocatePool (Size); - ASSERT (ConfigureLang !=3D NULL); - AsciiSPrint (ConfigureLang, Size, "%a[%d]", Private->CollectionPath,= Count); - - Status =3D ProcessResource (Private, ConfigureLang); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, process memory resource: %a failed: %r\n= ", __FUNCTION__, UriData->Uri, Status)); + UriData =3D (RedfishCS_Type_Uri_Data *)Header; + MemberUri =3D NULL; + MemberUri =3D StrAsciiToUnicode (UriData->Uri); + ASSERT (MemberUri !=3D NULL); + if (MemberUri !=3D NULL) { + Status =3D HandleResource (Private, MemberUri); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a, process MemoryCollection resource: %a = failed: %r\n", __FUNCTION__, UriData->Uri, Status)); + } + + FreePool (MemberUri); } } =20 @@ -171,25 +199,24 @@ ProcessCollection ( // // Release resource. // - Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Memory); + Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Collection); =20 return EFI_SUCCESS; } =20 EFI_STATUS -CreateCollection ( +CreateCollectionResource ( IN REDFISH_COLLECTION_PRIVATE *Private ) { - EFI_STATUS Status; - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol; - REDFISH_SCHEMA_INFO SchemaInfo; + EFI_STATUS Status; + REDFISH_SCHEMA_INFO SchemaInfo; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %a= \n", __FUNCTION__, Private->CollectionPath)); + DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %s= \n", __FUNCTION__, Private->CollectionUri)); =20 Status =3D GetSupportedSchemaVersion (REDFISH_SCHEMA_NAME, &SchemaInfo); if (EFI_ERROR (Status)) { @@ -199,18 +226,9 @@ CreateCollection ( =20 DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a %a.%a.%a\n", __FU= NCTION__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo= .Errata)); =20 - RedfishResrouceProtocol =3D GetRedfishResourceConfigProtocol (SchemaInfo= .Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Errata); - if (RedfishResrouceProtocol =3D=3D NULL) { - return EFI_DEVICE_ERROR; - } - - Status =3D RedfishResrouceProtocol->Provisioning ( - RedfishResrouceProtocol, - Private->CollectionPath, - TRUE - ); + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Private= ->CollectionUri, Private->InformationExchange, TRUE); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %a %r\n", __F= UNCTION__, Private->CollectionPath, Status)); + DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %s: %r\n", __= FUNCTION__, Private->CollectionUri, Status)); } =20 return Status; @@ -246,6 +264,11 @@ ReleaseCollectionResource ( Private->CollectionJson =3D NULL; } =20 + if (Private->RedfishVersion !=3D NULL) { + FreePool (Private->RedfishVersion); + Private->RedfishVersion =3D NULL; + } + return EFI_SUCCESS; } =20 @@ -255,49 +278,19 @@ CollectionHandler ( ) { EFI_STATUS Status; - CHAR8 *SystemRootPath; - CHAR8 *PathBuffer; - UINTN BufferSize; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - SystemRootPath =3D NULL; - PathBuffer =3D NULL; - - SystemRootPath =3D RedfishGetSystemRootPath (); - if (SystemRootPath =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a, can not find system root path\n", __FUNCTION= __)); - return EFI_DEVICE_ERROR; - } - - BufferSize =3D AsciiStrSize (SystemRootPath) + AsciiStrSize (REDFISH_SCH= EMA_NAME); - PathBuffer =3D AllocatePool (BufferSize); - if (PathBuffer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto ON_RELEASE; - } - - AsciiSPrint (PathBuffer, BufferSize, "%a/%a", SystemRootPath, REDFISH_SC= HEMA_NAME); - - DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %a\n", __FUNCTI= ON__, PathBuffer)); - - // - // Initialize collection path - // - Private->CollectionPath =3D RedfishBuildPathWithSystemUuid (PathBuffer, = TRUE, NULL); - if (Private->CollectionPath =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - goto ON_RELEASE; - } + DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %s\n", __FUNCTI= ON__, Private->CollectionUri)); =20 // // Query collection from Redfish service. // - Status =3D GetResourceByPath (Private->RedfishService, Private->Collecti= onPath, &Private->RedResponse); + Status =3D GetResourceByUri (Private->RedfishService, Private->Collectio= nUri, &Private->RedResponse); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %a :%r\n", __FU= NCTION__, Private->CollectionPath, Status)); + DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %s :%r\n", __FU= NCTION__, Private->CollectionUri, Status)); goto ON_RELEASE; } =20 @@ -307,21 +300,13 @@ CollectionHandler ( Private->CollectionJson =3D JsonDumpString (RedfishJsonInPayload (Privat= e->CollectionPayload), EDKII_JSON_COMPACT); ASSERT (Private->CollectionJson !=3D NULL); =20 - Status =3D ProcessCollection (Private); + Status =3D HandleCollectionResource (Private); if (EFI_ERROR (Status) && (Status =3D=3D EFI_NOT_FOUND)) { - Status =3D CreateCollection (Private); + Status =3D CreateCollectionResource (Private); } =20 ON_RELEASE: =20 - if (SystemRootPath !=3D NULL) { - FreePool (SystemRootPath); - } - - if (PathBuffer !=3D NULL) { - FreePool (PathBuffer); - } - ReleaseCollectionResource (Private); =20 return Status; @@ -332,10 +317,12 @@ ON_RELEASE: =20 @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROT= OCOL instance. @param[in] FeatureAction The action Redfish feature driver sho= uld take. + @param[in] Uri The collection URI. @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= . + @param[in,out] InformationExchange The pointer to RESOURCE_INFORMATION_E= XCHANGE + + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. + @retval Others Some errors happened. =20 @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully. @retval Others Some errors happened. @@ -347,12 +334,13 @@ RedfishCollectionFeatureCallback ( IN EDKII_REDFISH_FEATURE_PROTOCOL *This, IN FEATURE_CALLBACK_ACTION FeatureAction, IN VOID *Context, - IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned + IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange ) { EFI_STATUS Status; REDFISH_SERVICE RedfishService; REDFISH_COLLECTION_PRIVATE *Private; + EFI_STRING ResourceUri; =20 if (FeatureAction !=3D CallbackActionStartOperation) { return EFI_UNSUPPORTED; @@ -365,6 +353,37 @@ RedfishCollectionFeatureCallback ( return EFI_NOT_READY; } =20 + // + // Save in private structure. + // + Private->InformationExchange =3D InformationExchange; + + // + // Find Redfish version on BMC + // + Private->RedfishVersion =3D RedfishGetVersion (RedfishService); + + // + // Create the full URI from Redfish service root. + // + ResourceUri =3D (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof (C= HAR16)); + if (ResourceUri =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for full URI.\n", __= FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion); + StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange->SendInformati= on.FullUri); + + // + // Initialize collection path + // + Private->CollectionUri =3D RedfishGetUri (ResourceUri); + if (Private->CollectionUri =3D=3D NULL) { + ASSERT (FALSE); + return EFI_OUT_OF_RESOURCES; + } + Status =3D CollectionHandler (Private); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, CollectionHandler failure: %r\n", __FUNCTION= __, Status)); diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 6292de4e..3619d2a2 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -15,7 +15,7 @@ INF RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf INF RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf - INF RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCo= llectionDxe.inf + INF RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.in= f =20 !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc # --=20 2.17.1