From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web12.8388.1657628521338048609 for ; Tue, 12 Jul 2022 05:22:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=MlwhiWG0; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0192e24d61=nickle.wang@hpe.com) Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26CAb9aA004563; Tue, 12 Jul 2022 12:22:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=X53oo7wuh/7HtvNzOQL1St/dmkkg017FcuEONWT5L4Y=; b=MlwhiWG03yiVxTquy/11ow2HvcHA3FpDYPjZ7m2/1qvhcAvMPIrbsZC28LI5QgTfNZSv J6rhIt81qk6sLszhMMdsXq9Q5mHliXr3R65lyTH629VTV8Oe8ApcSH9iD1ODAO/wr8ma cNjdJe8zInujrNff6cnd7O2R9QwsxCfCmdZrudcYJDAgZMgUihB9Z0lBxrqiWhhcS5Vj 0dcQSiRaVN621Ihtr6fK2rk7/mtOx7rXBmiORSGPz7Y0B/qsrXwUHuy3v+lepoC9UG71 Esl1mGlIw9iGnLl/CwTfJXLbX0W4a+ILmd57ICm8Y0zJX8s4sBOym7PLMryZNqp3qrm+ LA== Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3h97bu8u4m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 12:22:00 +0000 Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id 8E350800224; Tue, 12 Jul 2022 12:21:59 +0000 (UTC) Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 8CC9A8036BA; Tue, 12 Jul 2022 12:21:58 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-staging][PATCH 11/15] edk2-staging/RedfishClientPkg: Rename RedfishMemoryCollection driver Date: Tue, 12 Jul 2022 20:21:39 +0800 Message-Id: <20220712122143.1827-12-nickle.wang@hpe.com> X-Mailer: git-send-email 2.32.0.windows.2 In-Reply-To: <20220712122143.1827-1-nickle.wang@hpe.com> References: <20220712122143.1827-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: RB8QyOc2xkrQffcc__V8qRHOQYkPI0Ng X-Proofpoint-ORIG-GUID: RB8QyOc2xkrQffcc__V8qRHOQYkPI0Ng X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-12_08,2022-07-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207120048 Content-Transfer-Encoding: quoted-printable 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: Yang Atom Cc: Nick Ramirez --- .../MemoryCollectionDxe.c} | 259 +++++++++--------- .../MemoryCollectionDxe.h} | 7 +- .../MemoryCollectionDxe.inf} | 19 +- .../Include/RedfishCollectionCommon.h | 14 +- RedfishClientPkg/RedfishClient.fdf.inc | 2 +- .../RedfishClientComponents.dsc.inc | 2 +- 6 files changed, 164 insertions(+), 139 deletions(-) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.c =3D> MemoryCollectionDxe/MemoryCollectionDxe.c} (66%) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.h =3D> MemoryCollectionDxe/MemoryCollectionDxe.h} (64%) rename RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemory= CollectionDxe.inf =3D> MemoryCollectionDxe/MemoryCollectionDxe.inf} (71%) diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.c b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryC= ollectionDxe.c similarity index 66% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.c rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .c index d97f0f161e..43426a78af 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.c +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c @@ -1,67 +1,98 @@ /** @file=0D - Redfish feature driver implementation - memory collection=0D =0D - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
=0D + Redfish feature driver implementation - MemoryCollection=0D +=0D + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D =0D -#include "RedfishMemoryCollectionDxe.h"=0D +#include "MemoryCollectionDxe.h"=0D =0D REDFISH_COLLECTION_PRIVATE *mRedfishCollectionPrivate =3D NULL;=0D =0D EFI_STATUS=0D -ProcessResource (=0D +HandleResource (=0D IN REDFISH_COLLECTION_PRIVATE *Private,=0D - IN CHAR8 *Uri=0D + IN EFI_STRING Uri=0D )=0D {=0D - EFI_STATUS Status;=0D - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol;=0D - REDFISH_SCHEMA_INFO SchemaInfo;=0D + EFI_STATUS Status;=0D + REDFISH_SCHEMA_INFO SchemaInfo;=0D + EFI_STRING ConfigLang;=0D + EFI_STRING ReturnedConfigLang;=0D + UINTN Index;=0D =0D if (Private =3D=3D NULL || IS_EMPTY_STRING (Uri)) {=0D return EFI_INVALID_PARAMETER;=0D }=0D =0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %a\n", __FUNCTIO= N__, Uri));=0D + //=0D + // Resource match=0D + //=0D +=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\n", __FUNCTIO= N__, Uri));=0D =0D Status =3D GetRedfishSchemaInfo (Private->RedfishService, Private->JsonS= tructProtocol, Uri, &SchemaInfo);=0D if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %a %r= \n", __FUNCTION__, Uri, Status));=0D + DEBUG ((DEBUG_ERROR, "%a, failed to get schema information from: %s %r= \n", __FUNCTION__, Uri, Status));=0D return Status;=0D }=0D + //=0D + // Check and see if this is target resource that we want to handle.=0D + // Some resource is handled by other provider so we have to make sure th= is first.=0D + //=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%s Identify for %s\n", __FUNCTION__, Uri))= ;=0D + ConfigLang =3D RedfishGetConfigLanguage (Uri);=0D + if (ConfigLang =3D=3D NULL) {=0D + Status =3D EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Priva= te->InformationExchange);=0D + if (EFI_ERROR (Status)) {=0D + if (Status =3D=3D EFI_UNSUPPORTED) {=0D + DEBUG ((DEBUG_INFO, "%a, \"%s\" is not handled by us\n", __FUNCTIO= N__, Uri));=0D + return EFI_SUCCESS;=0D + }=0D =0D - RedfishResrouceProtocol =3D GetRedfishResourceConfigProtocol (=0D - SchemaInfo.Schema,=0D - SchemaInfo.Major,=0D - SchemaInfo.Minor,=0D - SchemaInfo.Errata=0D - );=0D - if (RedfishResrouceProtocol =3D=3D NULL) {=0D - return EFI_DEVICE_ERROR;=0D + DEBUG ((DEBUG_ERROR, "%a, fail to identify resource: \"%s\": %r\n", = __FUNCTION__, Uri, Status));=0D + return Status;=0D + }=0D + } else {=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a, history record found: %s\n", __FUNCT= ION__, ConfigLang));=0D + //=0D + // Set exchange information=0D + //=0D + Status =3D GetArrayIndexFromArrayTypeConfigureLang (ConfigLang, &Retur= nedConfigLang, &Index);=0D + if (!EFI_ERROR (Status) || Status =3D=3D EFI_NOT_FOUND) {=0D + Private->InformationExchange->ReturnedInformation.Type =3D Informati= onTypeCollectionMemberConfigLanguage;=0D + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.Count =3D 1;=0D + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List =3D=0D + AllocateZeroPool(sizeof (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG));= =0D +=0D + if (Private->InformationExchange->ReturnedInformation.ConfigureLangu= ageList.List =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for REDFISH_FEAT= URE_ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__));=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List [Index].Index =3D Index;=0D + Private->InformationExchange->ReturnedInformation.ConfigureLanguageL= ist.List [Index].ConfigureLang =3D=0D + (EFI_STRING)AllocateCopyPool(StrSize(ReturnedConfigLang), (VOID = *)ReturnedConfigLang);=0D + } else {=0D + DEBUG ((DEBUG_ERROR, "%a, GetArrayIndexFromArrayTypeConfigureLang fa= il: %r\n", __FUNCTION__, Status));=0D + }=0D + FreePool (ConfigLang);=0D }=0D =0D //=0D // Check and see if target property exist or not even when collection me= meber exists.=0D // If not, we sill do provision.=0D //=0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %a\n", __FUNCTION__, Uri));=0D - Status =3D RedfishResrouceProtocol->Check (=0D - RedfishResrouceProtocol,=0D - Uri=0D - );=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __FUNCTION__, Uri));=0D + Status =3D EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri);=0D if (EFI_ERROR (Status)) {=0D //=0D // The target property does not exist, do the provision to create prop= erty.=0D //=0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %a\n", __FUNCTION__, Ur= i));=0D - Status =3D RedfishResrouceProtocol->Provisioning (=0D - RedfishResrouceProtocol,=0D - Uri,=0D - FALSE=0D - );=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __FUNCTION__, Ur= i));=0D + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Uri, = Private->InformationExchange, FALSE);=0D if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a, failed to provision with GET mode: %r\n", = __FUNCTION__, Status));=0D }=0D @@ -72,41 +103,36 @@ ProcessResource ( //=0D // Consume first.=0D //=0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %a\n", __FUNCTION__, Uri));= =0D - Status =3D RedfishResrouceProtocol->Consume (=0D - RedfishResrouceProtocol,=0D - Uri=0D - );=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n", __FUNCTION__, Uri));= =0D + Status =3D EdkIIRedfishResourceConfigConsume (&SchemaInfo, Uri);=0D if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %a %r\n", __= FUNCTION__, Uri, Status));=0D + DEBUG ((DEBUG_ERROR, "%a, failed to consume resoruce for: %s: %r\n", _= _FUNCTION__, Uri, Status));=0D }=0D =0D //=0D // Patch.=0D //=0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %a\n", __FUNCTION__, Uri));= =0D - Status =3D RedfishResrouceProtocol->Update (=0D - RedfishResrouceProtocol,=0D - Uri=0D - );=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __FUNCTION__, Uri));= =0D + Status =3D EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, failed to update resoruce for: %s: %r\n", __= FUNCTION__, Uri, Status));=0D + }=0D =0D return Status;=0D }=0D =0D EFI_STATUS=0D -ProcessCollection (=0D +HandleCollectionResource (=0D IN REDFISH_COLLECTION_PRIVATE *Private=0D )=0D {=0D EFI_STATUS Status;=0D - EFI_REDFISH_MEMORYCOLLECTION *Memory;=0D + EFI_REDFISH_MEMORYCOLLECTION *Collection;=0D EFI_REDFISH_MEMORYCOLLECTION_CS *CollectionCs;=0D RedfishCS_Link *List;=0D RedfishCS_Header *Header;=0D RedfishCS_Type_Uri_Data *UriData;=0D - CHAR8 *ConfigureLang;=0D - UINTN Size;=0D - UINTN Count;=0D + EFI_STRING MemberUri;=0D =0D if (Private =3D=3D NULL) {=0D return EFI_INVALID_PARAMETER;=0D @@ -116,7 +142,7 @@ ProcessCollection ( return EFI_NOT_READY;=0D }=0D =0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %a\n", __FUNCT= ION__, Private->CollectionPath));=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %s\n", __FUNCT= ION__, Private->CollectionUri));=0D =0D //=0D // Convert JSON text to C structure.=0D @@ -125,14 +151,14 @@ ProcessCollection ( Private->JsonStructProtocol,=0D NULL,=0D Private->CollectionJson,=0D - (EFI_REST_JSON_STRUCTURE_HEADER = **)&Memory=0D + (EFI_REST_JSON_STRUCTURE_HEADER = **)&Collection=0D );=0D if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __FUNCTION__, S= tatus));=0D return Status;=0D }=0D =0D - CollectionCs =3D Memory->MemoryCollection;=0D + CollectionCs =3D Collection->MemoryCollection;=0D =0D if (*CollectionCs->Membersodata_count =3D=3D 0) {=0D return EFI_NOT_FOUND;=0D @@ -142,23 +168,22 @@ ProcessCollection ( return EFI_NOT_FOUND;=0D }=0D =0D - Count =3D 0;=0D List =3D GetFirstLink (&CollectionCs->Members);=0D while (TRUE) {=0D =0D Header =3D (RedfishCS_Header *)List;=0D if (Header->ResourceType =3D=3D RedfishCS_Type_Uri) {=0D UriData =3D (RedfishCS_Type_Uri_Data *)Header;=0D -=0D - ++Count;=0D - Size =3D AsciiStrLen (Private->CollectionPath) + 5;=0D - ConfigureLang =3D AllocatePool (Size);=0D - ASSERT (ConfigureLang !=3D NULL);=0D - AsciiSPrint (ConfigureLang, Size, "%a[%d]", Private->CollectionPath,= Count);=0D -=0D - Status =3D ProcessResource (Private, ConfigureLang);=0D - if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_ERROR, "%a, process memory resource: %a failed: %r\n= ", __FUNCTION__, UriData->Uri, Status));=0D + MemberUri =3D NULL;=0D + MemberUri =3D StrAsciiToUnicode (UriData->Uri);=0D + ASSERT (MemberUri !=3D NULL);=0D + if (MemberUri !=3D NULL) {=0D + Status =3D HandleResource (Private, MemberUri);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a, process MemoryCollection resource: %a = failed: %r\n", __FUNCTION__, UriData->Uri, Status));=0D + }=0D +=0D + FreePool (MemberUri);=0D }=0D }=0D =0D @@ -172,25 +197,24 @@ ProcessCollection ( //=0D // Release resource.=0D //=0D - Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Memory);=0D + Private->JsonStructProtocol->DestoryStructure (Private->JsonStructProtoc= ol, (EFI_REST_JSON_STRUCTURE_HEADER *)Collection);=0D =0D return EFI_SUCCESS;=0D }=0D =0D EFI_STATUS=0D -CreateCollection (=0D +CreateCollectionResource (=0D IN REDFISH_COLLECTION_PRIVATE *Private=0D )=0D {=0D EFI_STATUS Status;=0D - EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL *RedfishResrouceProtocol;=0D REDFISH_SCHEMA_INFO SchemaInfo;=0D =0D if (Private =3D=3D NULL) {=0D return EFI_INVALID_PARAMETER;=0D }=0D =0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %a= \n", __FUNCTION__, Private->CollectionPath));=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a, create resource for collection for: %s= \n", __FUNCTION__, Private->CollectionUri));=0D =0D Status =3D GetSupportedSchemaVersion (REDFISH_SCHEMA_NAME, &SchemaInfo);= =0D if (EFI_ERROR (Status)) {=0D @@ -200,18 +224,9 @@ CreateCollection ( =0D DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a %a.%a.%a\n", __FU= NCTION__, SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo= .Errata));=0D =0D - RedfishResrouceProtocol =3D GetRedfishResourceConfigProtocol (SchemaInfo= .Schema, SchemaInfo.Major, SchemaInfo.Minor, SchemaInfo.Errata);=0D - if (RedfishResrouceProtocol =3D=3D NULL) {=0D - return EFI_DEVICE_ERROR;=0D - }=0D -=0D - Status =3D RedfishResrouceProtocol->Provisioning (=0D - RedfishResrouceProtocol,=0D - Private->CollectionPath,=0D - TRUE=0D - );=0D + Status =3D EdkIIRedfishResourceConfigProvisionging (&SchemaInfo, Private= ->CollectionUri, Private->InformationExchange, TRUE);=0D if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %a %r\n", __F= UNCTION__, Private->CollectionPath, Status));=0D + DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %s: %r\n", __= FUNCTION__, Private->CollectionUri, Status));=0D }=0D =0D return Status;=0D @@ -248,6 +263,11 @@ ReleaseCollectionResource ( Private->CollectionJson =3D NULL;=0D }=0D =0D + if (Private->RedfishVersion !=3D NULL) {=0D + FreePool (Private->RedfishVersion);=0D + Private->RedfishVersion =3D NULL;=0D + }=0D +=0D return EFI_SUCCESS;=0D }=0D =0D @@ -257,49 +277,19 @@ CollectionHandler ( )=0D {=0D EFI_STATUS Status;=0D - CHAR8 *SystemRootPath;=0D - CHAR8 *PathBuffer;=0D - UINTN BufferSize;=0D =0D if (Private =3D=3D NULL) {=0D return EFI_INVALID_PARAMETER;=0D }=0D =0D - SystemRootPath =3D NULL;=0D - PathBuffer =3D NULL;=0D -=0D - SystemRootPath =3D RedfishGetSystemRootPath ();=0D - if (SystemRootPath =3D=3D NULL) {=0D - DEBUG ((DEBUG_ERROR, "%a, can not find system root path\n", __FUNCTION= __));=0D - return EFI_DEVICE_ERROR;=0D - }=0D -=0D - BufferSize =3D AsciiStrSize (SystemRootPath) + AsciiStrSize (REDFISH_SCH= EMA_NAME);=0D - PathBuffer =3D AllocatePool (BufferSize);=0D - if (PathBuffer =3D=3D NULL) {=0D - Status =3D EFI_OUT_OF_RESOURCES;=0D - goto ON_RELEASE;=0D - }=0D -=0D - AsciiSPrint (PathBuffer, BufferSize, "%a/%a", SystemRootPath, REDFISH_SC= HEMA_NAME);=0D -=0D - DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %a\n", __FUNCTI= ON__, PathBuffer));=0D -=0D - //=0D - // Initialize collection path=0D - //=0D - Private->CollectionPath =3D RedfishBuildPathWithSystemUuid (PathBuffer, = TRUE, NULL);=0D - if (Private->CollectionPath =3D=3D NULL) {=0D - Status =3D EFI_OUT_OF_RESOURCES;=0D - goto ON_RELEASE;=0D - }=0D + DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %s\n", __FUNCTI= ON__, Private->CollectionUri));=0D =0D //=0D // Query collection from Redfish service.=0D //=0D - Status =3D GetResourceByPath (Private->RedfishService, Private->Collecti= onPath, &Private->RedResponse);=0D + Status =3D GetResourceByUri (Private->RedfishService, Private->Collectio= nUri, &Private->RedResponse);=0D if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %a :%r\n", __FU= NCTION__, Private->CollectionPath, Status));=0D + DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %s :%r\n", __FU= NCTION__, Private->CollectionUri, Status));=0D goto ON_RELEASE;=0D }=0D =0D @@ -309,21 +299,13 @@ CollectionHandler ( Private->CollectionJson =3D JsonDumpString (RedfishJsonInPayload (Privat= e->CollectionPayload), EDKII_JSON_COMPACT);=0D ASSERT (Private->CollectionJson !=3D NULL);=0D =0D - Status =3D ProcessCollection (Private);=0D + Status =3D HandleCollectionResource (Private);=0D if (EFI_ERROR (Status) && Status =3D=3D EFI_NOT_FOUND) {=0D - Status =3D CreateCollection (Private);=0D + Status =3D CreateCollectionResource (Private);=0D }=0D =0D ON_RELEASE:=0D =0D - if (SystemRootPath !=3D NULL) {=0D - FreePool (SystemRootPath);=0D - }=0D -=0D - if (PathBuffer !=3D NULL) {=0D - FreePool (PathBuffer);=0D - }=0D -=0D ReleaseCollectionResource (Private);=0D =0D return Status;=0D @@ -334,10 +316,12 @@ ON_RELEASE: =0D @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROT= OCOL instance.=0D @param[in] FeatureAction The action Redfish feature driver sho= uld take.=0D + @param[in] Uri The collection URI.=0D @param[in] Context The context of Redfish feature driver= .=0D - @param[in,out] InformationReturned The pointer to retrive the pointer to= =0D - FEATURE_RETURNED_INFOMATION. The memo= ry block of this=0D - information should be freed by caller= .=0D + @param[in,out] InformationExchange The pointer to RESOURCE_INFORMATION_E= XCHANGE=0D +=0D + @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully.=0D + @retval Others Some errors happened.=0D =0D @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully.=0D @retval Others Some errors happened.=0D @@ -349,12 +333,13 @@ RedfishCollectionFeatureCallback ( IN EDKII_REDFISH_FEATURE_PROTOCOL *This,=0D IN FEATURE_CALLBACK_ACTION FeatureAction,=0D IN VOID *Context,=0D - IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned=0D + IN OUT RESOURCE_INFORMATION_EXCHANGE *InformationExchange=0D )=0D {=0D EFI_STATUS Status;=0D REDFISH_SERVICE RedfishService;=0D REDFISH_COLLECTION_PRIVATE *Private;=0D + EFI_STRING ResourceUri;=0D =0D if (FeatureAction !=3D CallbackActionStartOperation) {=0D return EFI_UNSUPPORTED;=0D @@ -367,6 +352,36 @@ RedfishCollectionFeatureCallback ( return EFI_NOT_READY;=0D }=0D =0D + //=0D + // Save in private structure.=0D + //=0D + Private->InformationExchange =3D InformationExchange;=0D +=0D + //=0D + // Find Redfish version on BMC=0D + //=0D + Private->RedfishVersion =3D RedfishGetVersion (RedfishService);=0D +=0D + //=0D + // Create the full URI from Redfish service root.=0D + //=0D + ResourceUri =3D (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof(CH= AR16));=0D + if (ResourceUri =3D=3D NULL) {=0D + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for full URI.\n", __= FUNCTION__));=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion);=0D + StrCatS (ResourceUri, MAX_URI_LENGTH, InformationExchange->SendInformati= on.FullUri);=0D +=0D + //=0D + // Initialize collection path=0D + //=0D + Private->CollectionUri =3D RedfishGetUri (ResourceUri);=0D + if (Private->CollectionUri =3D=3D NULL) {=0D + ASSERT (FALSE);=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D Status =3D CollectionHandler (Private);=0D if (EFI_ERROR (Status)) {=0D DEBUG ((DEBUG_ERROR, "%a, CollectionHandler failure: %r\n", __FUNCTION= __, Status));=0D @@ -549,7 +564,7 @@ RedfishCollectionUnload ( )=0D {=0D EFI_STATUS Status;=0D - EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;=0D + EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;=0D =0D if (mRedfishCollectionPrivate =3D=3D NULL) {=0D return EFI_NOT_READY;=0D diff --git a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMe= moryCollectionDxe.h b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryC= ollectionDxe.h similarity index 64% rename from RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMem= oryCollectionDxe.h rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe= .h index 83ca836941..75b4a123ff 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.h +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.h @@ -1,7 +1,8 @@ /** @file=0D +=0D Redfish feature driver implementation - internal header file=0D =0D - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
=0D + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -14,5 +15,7 @@ #include =0D =0D #define REDFISH_SCHEMA_NAME "Memory"=0D -#define REDFISH_MANAGED_URI L"/redfish/v1/systems/{1}/memory"= =0D +#define REDFISH_MANAGED_URI L"Chassis/{}/Memory/{};Systems/{}/= Memory/{}"=0D +#define MAX_URI_LENGTH 256=0D +=0D #endif=0D 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 e7bcf49bdb..05e05712e7 100644 --- a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCol= lectionDxe.inf +++ b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf @@ -1,15 +1,18 @@ ## @file=0D #=0D -# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
=0D +# Redfish MemoryCollection collection driver.=0D +#=0D +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D =0D +=0D [Defines]=0D INF_VERSION =3D 0x00010005=0D - BASE_NAME =3D RedfishMemoryCollectionDxe=0D - FILE_GUID =3D 9323359C-11E2-49BC-B501-D6280B6DAE1A=0D + BASE_NAME =3D MemoryCollectionDxe=0D + FILE_GUID =3D 22facf8f-a007-462c-9be4-638043a26858=0D MODULE_TYPE =3D DXE_DRIVER=0D VERSION_STRING =3D 1.0=0D ENTRY_POINT =3D RedfishCollectionEntryPoint=0D @@ -22,8 +25,8 @@ RedfishClientPkg/RedfishClientPkg.dec=0D =0D [Sources]=0D - RedfishMemoryCollectionDxe.h=0D - RedfishMemoryCollectionDxe.c=0D + MemoryCollectionDxe.h=0D + MemoryCollectionDxe.c=0D =0D [LibraryClasses]=0D DebugLib=0D @@ -35,19 +38,19 @@ UefiLib=0D UefiDriverEntryPoint=0D UefiBootServicesTableLib=0D + EdkIIRedfishResourceConfigLib=0D + RedfishVersionLib=0D =0D [Protocols]=0D gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMED=0D gEfiRestJsonStructureProtocolGuid ## CONSUMED=0D - gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMED=0D gEdkIIRedfishFeatureProtocolGuid ## CONSUMED=0D =0D [Guids]=0D - gEfiEventReadyToBootGuid=0D =0D [Pcd]=0D gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize=0D gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize=0D =0D [Depex]=0D - TRUE \ No newline at end of file + TRUE=0D diff --git a/RedfishClientPkg/Include/RedfishCollectionCommon.h b/RedfishCl= ientPkg/Include/RedfishCollectionCommon.h index 05a0f672f3..d4adcedd1f 100644 --- a/RedfishClientPkg/Include/RedfishCollectionCommon.h +++ b/RedfishClientPkg/Include/RedfishCollectionCommon.h @@ -1,7 +1,7 @@ /** @file=0D Redfish feature driver collection common header file.=0D =0D - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP
=0D + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -10,6 +10,8 @@ #ifndef EFI_REDFISH_COLLECTION_COMMON_H_=0D #define EFI_REDFISH_COLLECTION_COMMON_H_=0D =0D +#include =0D +=0D //=0D // Libraries=0D //=0D @@ -22,28 +24,30 @@ #include =0D #include =0D #include =0D +#include =0D +#include =0D =0D //=0D // Protocols=0D //=0D #include =0D -#include =0D #include =0D #include =0D #include =0D =0D -#define IS_EMPTY_STRING(a) ((a) =3D=3D NULL || (a)[0] =3D=3D = '\0')=0D -#define REDFISH_DEBUG_TRACE DEBUG_INFO=0D +#define REDFISH_MAX_COLLECTION_INDEX_LEN 8=0D =0D typedef struct _REDFISH_COLLECTION_PRIVATE {=0D EFI_REST_JSON_STRUCTURE_PROTOCOL *JsonStructProtocol;=0D EDKII_REDFISH_FEATURE_PROTOCOL *FeatureProtocol;=0D REDFISH_SERVICE RedfishService;=0D + RESOURCE_INFORMATION_EXCHANGE *InformationExchange;=0D EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL ConfigHandler;=0D - CHAR8 *CollectionPath;=0D + EFI_STRING CollectionUri;=0D CHAR8 *CollectionJson;=0D REDFISH_PAYLOAD CollectionPayload;=0D REDFISH_RESPONSE RedResponse;=0D + EFI_STRING RedfishVersion;=0D } REDFISH_COLLECTION_PRIVATE;=0D =0D #define REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL(This) \=0D diff --git a/RedfishClientPkg/RedfishClient.fdf.inc b/RedfishClientPkg/Redf= ishClient.fdf.inc index 6292de4e81..3619d2a20f 100644 --- a/RedfishClientPkg/RedfishClient.fdf.inc +++ b/RedfishClientPkg/RedfishClient.fdf.inc @@ -15,7 +15,7 @@ INF RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf=0D INF RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf= =0D INF RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf=0D - INF RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCo= llectionDxe.inf=0D + INF RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.in= f=0D =0D !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc=0D #=0D diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc b/RedfishClie= ntPkg/RedfishClientComponents.dsc.inc index ee4602fe79..5f1aff3c4b 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.=0D #=0D RedfishClientPkg/Features/Memory/V1_7_1/Dxe/RedfishMemoryDxe.inf=0D - RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCollec= tionDxe.inf=0D + RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf=0D =0D !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc=0D =0D --=20 2.32.0.windows.2