From: "Chang, Abner" <abner.chang@amd.com>
To: Nickle Wang <nicklew@nvidia.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Igor Kulchytskyy <igork@ami.com>
Subject: Re: [edk2-redfish-client][PATCH 1/5] RedfishClientPkg: Rename RedfishMemoryCollection driver
Date: Wed, 10 May 2023 14:06:18 +0000 [thread overview]
Message-ID: <MN2PR12MB396642375B9531A044708A38EA779@MN2PR12MB3966.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20230510130417.9226-1-nicklew@nvidia.com>
[AMD Official Use Only - General]
Please review your commit message in which the characters per line should be < 76.
Reviewed-by: <abner.chang@amd.com>
> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Wednesday, May 10, 2023 9:04 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>
> Subject: [edk2-redfish-client][PATCH 1/5] RedfishClientPkg: Rename
> RedfishMemoryCollection driver
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> 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 <nicklew@nvidia.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> ---
> .../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/RedfishMemoryC
> ollectionDxe.inf => MemoryCollectionDxe/MemoryCollectionDxe.inf} (71%)
> rename
> RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.h => MemoryCollectionDxe/MemoryCollectionDxe.h} (65%)
> rename
> RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.c => MemoryCollectionDxe/MemoryCollectionDxe.c} (65%)
>
> diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc
> b/RedfishClientPkg/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/RedfishMemoryC
> ollectionDxe.inf
> +
> RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf
>
> !include RedfishClientPkg/RedfishJsonStructureDxe.dsc.inc
>
> diff --git
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.inf
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.i
> nf
> similarity index 71%
> rename from
> RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.inf
> rename to
> RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf
> index c28a3bfe..05e05712 100644
> ---
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.inf
> +++
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> +++ inf
> @@ -1,15 +1,18 @@
> ## @file
> #
> -# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>
> +# Redfish MemoryCollection collection driver.
> +#
> +# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development
> +LP<BR>
> #
> # SPDX-License-Identifier: BSD-2-Clause-Patent # ##
>
> +
> [Defines]
> INF_VERSION = 0x00010005
> - BASE_NAME = RedfishMemoryCollectionDxe
> - FILE_GUID = 9323359C-11E2-49BC-B501-D6280B6DAE1A
> + BASE_NAME = MemoryCollectionDxe
> + FILE_GUID = 22facf8f-a007-462c-9be4-638043a26858
> MODULE_TYPE = DXE_DRIVER
> VERSION_STRING = 1.0
> ENTRY_POINT = RedfishCollectionEntryPoint
> @@ -22,8 +25,8 @@
> RedfishClientPkg/RedfishClientPkg.dec
>
> [Sources]
> - RedfishMemoryCollectionDxe.h
> - RedfishMemoryCollectionDxe.c
> + MemoryCollectionDxe.h
> + MemoryCollectionDxe.c
>
> [LibraryClasses]
> DebugLib
> @@ -35,15 +38,15 @@
> UefiLib
> UefiDriverEntryPoint
> UefiBootServicesTableLib
> + EdkIIRedfishResourceConfigLib
> + RedfishVersionLib
>
> [Protocols]
> gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMED
> gEfiRestJsonStructureProtocolGuid ## CONSUMED
> - gEdkIIRedfishResourceConfigProtocolGuid ## CONSUMED
> gEdkIIRedfishFeatureProtocolGuid ## CONSUMED
>
> [Guids]
> - gEfiEventReadyToBootGuid
>
> [Pcd]
> gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize
> diff --git
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.h
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> h
> similarity index 65%
> rename from
> RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.h
> rename to
> RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.h
> index e5da48db..3d02285d 100644
> ---
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.h
> +++
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> +++ h
> @@ -1,7 +1,8 @@
> /** @file
> +
> Redfish feature driver implementation - internal header file
>
> - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>
> + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -14,5 +15,7 @@
> #include <RedfishCollectionCommon.h>
>
> #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/RedfishClientPkg/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.
>
> - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>
> + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -10,6 +10,8 @@
> #ifndef EFI_REDFISH_COLLECTION_COMMON_H_ #define
> EFI_REDFISH_COLLECTION_COMMON_H_
>
> +#include <RedfishBase.h>
> +
> //
> // Libraries
> //
> @@ -22,28 +24,30 @@
> #include <Library/RedfishFeatureUtilityLib.h>
> #include <Library/UefiLib.h>
> #include <Library/UefiBootServicesTableLib.h>
> +#include <Library/EdkIIRedfishResourceConfigLib.h>
> +#include <Library/RedfishVersionLib.h>
>
> //
> // Protocols
> //
> #include <Protocol/EdkIIRedfishConfigHandler.h>
> -#include <Protocol/EdkIIRedfishResourceConfigProtocol.h>
> #include <Protocol/EdkIIRedfishFeature.h> #include
> <Protocol/RestJsonStructure.h> #include <Protocol/RestEx.h>
>
> -#define IS_EMPTY_STRING(a) ((a) == NULL || (a)[0] == '\0') -#define
> REDFISH_DEBUG_TRACE DEBUG_INFO
> +#define REDFISH_MAX_COLLECTION_INDEX_LEN 8
>
> 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;
>
> #define REDFISH_COLLECTION_PRIVATE_DATA_FROM_PROTOCOL(This) \
> diff --git
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.c
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> c
> similarity index 65%
> rename from
> RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.c
> rename to
> RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
> index e70a7f76..c86628a4 100644
> ---
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.c
> +++
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> +++ c
> @@ -1,67 +1,101 @@
> /** @file
> - Redfish feature driver implementation - memory collection
>
> - (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>
> + Redfish feature driver implementation - MemoryCollection
> +
> + (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
>
> -#include "RedfishMemoryCollectionDxe.h"
> +#include "MemoryCollectionDxe.h"
>
> REDFISH_COLLECTION_PRIVATE *mRedfishCollectionPrivate = NULL;
>
> 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;
>
> if ((Private == NULL) || IS_EMPTY_STRING (Uri)) {
> return EFI_INVALID_PARAMETER;
> }
>
> - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %a\n",
> __FUNCTION__, Uri));
> + //
> + // Resource match
> + //
> +
> + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process resource for: %s\n",
> + __FUNCTION__, Uri));
>
> Status = GetRedfishSchemaInfo (Private->RedfishService, Private-
> >JsonStructProtocol, 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;
> }
>
> - RedfishResrouceProtocol = GetRedfishResourceConfigProtocol (
> - SchemaInfo.Schema,
> - SchemaInfo.Major,
> - SchemaInfo.Minor,
> - SchemaInfo.Errata
> - );
> - if (RedfishResrouceProtocol == 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
> this first.
> + //
> + DEBUG ((REDFISH_DEBUG_TRACE, "%s Identify for %s\n", __FUNCTION__,
> + Uri)); ConfigLang = RedfishGetConfigLanguage (Uri); if (ConfigLang
> + == NULL) {
> + Status = EdkIIRedfishResourceConfigIdentify (&SchemaInfo, Uri, Private-
> >InformationExchange);
> + if (EFI_ERROR (Status)) {
> + if (Status == EFI_UNSUPPORTED) {
> + DEBUG ((DEBUG_INFO, "%a, \"%s\" is not handled by us\n",
> __FUNCTION__, 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",
> __FUNCTION__, ConfigLang));
> + //
> + // Set exchange information
> + //
> + Status = GetArrayIndexFromArrayTypeConfigureLang (ConfigLang,
> &ReturnedConfigLang, &Index);
> + if (!EFI_ERROR (Status) || (Status == EFI_NOT_FOUND)) {
> + Private->InformationExchange->ReturnedInformation.Type
> = InformationTypeCollectionMemberConfigLanguage;
> + Private->InformationExchange-
> >ReturnedInformation.ConfigureLanguageList.Count = 1;
> + Private->InformationExchange-
> >ReturnedInformation.ConfigureLanguageList.List =
> + AllocateZeroPool (sizeof
> + (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG));
> +
> + if (Private->InformationExchange-
> >ReturnedInformation.ConfigureLanguageList.List == NULL) {
> + DEBUG ((DEBUG_ERROR, "%a, Fail to allocate memory for
> REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG.\n", __FUNCTION__));
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> + Private->InformationExchange-
> >ReturnedInformation.ConfigureLanguageList.List[Index].Index = Index;
> + Private->InformationExchange-
> >ReturnedInformation.ConfigureLanguageList.List[Index].ConfigureLang =
> + (EFI_STRING)AllocateCopyPool (StrSize (ReturnedConfigLang), (VOID
> *)ReturnedConfigLang);
> + } else {
> + DEBUG ((DEBUG_ERROR, "%a,
> GetArrayIndexFromArrayTypeConfigureLang fail: %r\n", __FUNCTION__,
> Status));
> + }
> +
> + FreePool (ConfigLang);
> }
>
> //
> // Check and see if target property exist or not even when collection
> memeber exists.
> // If not, we sill do provision.
> //
> - DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %a\n", __FUNCTION__,
> Uri));
> - Status = RedfishResrouceProtocol->Check (
> - RedfishResrouceProtocol,
> - Uri
> - );
> + DEBUG ((REDFISH_DEBUG_TRACE, "%a Check for %s\n", __FUNCTION__,
> + Uri)); Status = EdkIIRedfishResourceConfigCheck (&SchemaInfo, Uri);
> if (EFI_ERROR (Status)) {
> //
> // The target property does not exist, do the provision to create property.
> //
> - DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %a\n",
> __FUNCTION__, Uri));
> - Status = RedfishResrouceProtocol->Provisioning (
> - RedfishResrouceProtocol,
> - Uri,
> - FALSE
> - );
> + DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n",
> __FUNCTION__, Uri));
> + Status = 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 = RedfishResrouceProtocol->Consume (
> - RedfishResrouceProtocol,
> - Uri
> - );
> + DEBUG ((REDFISH_DEBUG_TRACE, "%a consume for %s\n",
> __FUNCTION__,
> + Uri)); Status = 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));
> }
>
> //
> // Patch.
> //
> - DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %a\n", __FUNCTION__,
> Uri));
> - Status = RedfishResrouceProtocol->Update (
> - RedfishResrouceProtocol,
> - Uri
> - );
> + DEBUG ((REDFISH_DEBUG_TRACE, "%a update for %s\n", __FUNCTION__,
> + Uri)); Status = EdkIIRedfishResourceConfigUpdate (&SchemaInfo, Uri);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a, failed to update resoruce for: %s: %r\n",
> + __FUNCTION__, Uri, Status)); }
>
> return Status;
> }
>
> 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;
>
> if (Private == NULL) {
> return EFI_INVALID_PARAMETER;
> @@ -116,7 +145,7 @@ ProcessCollection (
> return EFI_NOT_READY;
> }
>
> - DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %a\n",
> __FUNCTION__, Private->CollectionPath));
> + DEBUG ((REDFISH_DEBUG_TRACE, "%a, process collection for: %s\n",
> + __FUNCTION__, Private->CollectionUri));
>
> //
> // 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__,
> Status));
> return Status;
> }
>
> - CollectionCs = Memory->MemoryCollection;
> + CollectionCs = Collection->MemoryCollection;
>
> if (*CollectionCs->Membersodata_count == 0) {
> return EFI_NOT_FOUND;
> @@ -142,22 +171,21 @@ ProcessCollection (
> return EFI_NOT_FOUND;
> }
>
> - Count = 0;
> - List = GetFirstLink (&CollectionCs->Members);
> + List = GetFirstLink (&CollectionCs->Members);
> while (TRUE) {
> Header = (RedfishCS_Header *)List;
> if (Header->ResourceType == RedfishCS_Type_Uri) {
> - UriData = (RedfishCS_Type_Uri_Data *)Header;
> -
> - ++Count;
> - Size = AsciiStrLen (Private->CollectionPath) + 5;
> - ConfigureLang = AllocatePool (Size);
> - ASSERT (ConfigureLang != NULL);
> - AsciiSPrint (ConfigureLang, Size, "%a[%d]", Private->CollectionPath,
> Count);
> -
> - Status = ProcessResource (Private, ConfigureLang);
> - if (EFI_ERROR (Status)) {
> - DEBUG ((DEBUG_ERROR, "%a, process memory resource: %a failed:
> %r\n", __FUNCTION__, UriData->Uri, Status));
> + UriData = (RedfishCS_Type_Uri_Data *)Header;
> + MemberUri = NULL;
> + MemberUri = StrAsciiToUnicode (UriData->Uri);
> + ASSERT (MemberUri != NULL);
> + if (MemberUri != NULL) {
> + Status = HandleResource (Private, MemberUri);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a, process MemoryCollection resource:
> %a failed: %r\n", __FUNCTION__, UriData->Uri, Status));
> + }
> +
> + FreePool (MemberUri);
> }
> }
>
> @@ -171,25 +199,24 @@ ProcessCollection (
> //
> // Release resource.
> //
> - Private->JsonStructProtocol->DestoryStructure (Private-
> >JsonStructProtocol, (EFI_REST_JSON_STRUCTURE_HEADER *)Memory);
> + Private->JsonStructProtocol->DestoryStructure
> + (Private->JsonStructProtocol, (EFI_REST_JSON_STRUCTURE_HEADER
> + *)Collection);
>
> return EFI_SUCCESS;
> }
>
> 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;
>
> if (Private == NULL) {
> return EFI_INVALID_PARAMETER;
> }
>
> - 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));
>
> Status = GetSupportedSchemaVersion (REDFISH_SCHEMA_NAME,
> &SchemaInfo);
> if (EFI_ERROR (Status)) {
> @@ -199,18 +226,9 @@ CreateCollection (
>
> DEBUG ((REDFISH_DEBUG_TRACE, "%a, supported schema: %a
> %a.%a.%a\n", __FUNCTION__, SchemaInfo.Schema, SchemaInfo.Major,
> SchemaInfo.Minor, SchemaInfo.Errata));
>
> - RedfishResrouceProtocol = GetRedfishResourceConfigProtocol
> (SchemaInfo.Schema, SchemaInfo.Major, SchemaInfo.Minor,
> SchemaInfo.Errata);
> - if (RedfishResrouceProtocol == NULL) {
> - return EFI_DEVICE_ERROR;
> - }
> -
> - Status = RedfishResrouceProtocol->Provisioning (
> - RedfishResrouceProtocol,
> - Private->CollectionPath,
> - TRUE
> - );
> + Status = EdkIIRedfishResourceConfigProvisionging (&SchemaInfo,
> + Private->CollectionUri, Private->InformationExchange, TRUE);
> if (EFI_ERROR (Status)) {
> - DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %a %r\n",
> __FUNCTION__, Private->CollectionPath, Status));
> + DEBUG ((DEBUG_ERROR, "%a, failed to create resoruce for: %s: %r\n",
> + __FUNCTION__, Private->CollectionUri, Status));
> }
>
> return Status;
> @@ -246,6 +264,11 @@ ReleaseCollectionResource (
> Private->CollectionJson = NULL;
> }
>
> + if (Private->RedfishVersion != NULL) {
> + FreePool (Private->RedfishVersion);
> + Private->RedfishVersion = NULL;
> + }
> +
> return EFI_SUCCESS;
> }
>
> @@ -255,49 +278,19 @@ CollectionHandler (
> )
> {
> EFI_STATUS Status;
> - CHAR8 *SystemRootPath;
> - CHAR8 *PathBuffer;
> - UINTN BufferSize;
>
> if (Private == NULL) {
> return EFI_INVALID_PARAMETER;
> }
>
> - SystemRootPath = NULL;
> - PathBuffer = NULL;
> -
> - SystemRootPath = RedfishGetSystemRootPath ();
> - if (SystemRootPath == NULL) {
> - DEBUG ((DEBUG_ERROR, "%a, can not find system root path\n",
> __FUNCTION__));
> - return EFI_DEVICE_ERROR;
> - }
> -
> - BufferSize = AsciiStrSize (SystemRootPath) + AsciiStrSize
> (REDFISH_SCHEMA_NAME);
> - PathBuffer = AllocatePool (BufferSize);
> - if (PathBuffer == NULL) {
> - Status = EFI_OUT_OF_RESOURCES;
> - goto ON_RELEASE;
> - }
> -
> - AsciiSPrint (PathBuffer, BufferSize, "%a/%a", SystemRootPath,
> REDFISH_SCHEMA_NAME);
> -
> - DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %a\n",
> __FUNCTION__, PathBuffer));
> -
> - //
> - // Initialize collection path
> - //
> - Private->CollectionPath = RedfishBuildPathWithSystemUuid (PathBuffer,
> TRUE, NULL);
> - if (Private->CollectionPath == NULL) {
> - Status = EFI_OUT_OF_RESOURCES;
> - goto ON_RELEASE;
> - }
> + DEBUG ((REDFISH_DEBUG_TRACE, "%a, collection handler for %s\n",
> + __FUNCTION__, Private->CollectionUri));
>
> //
> // Query collection from Redfish service.
> //
> - Status = GetResourceByPath (Private->RedfishService, Private-
> >CollectionPath, &Private->RedResponse);
> + Status = GetResourceByUri (Private->RedfishService,
> + Private->CollectionUri, &Private->RedResponse);
> if (EFI_ERROR (Status)) {
> - DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %a :%r\n",
> __FUNCTION__, Private->CollectionPath, Status));
> + DEBUG ((DEBUG_ERROR, "%a, unable to get resource from: %s :%r\n",
> + __FUNCTION__, Private->CollectionUri, Status));
> goto ON_RELEASE;
> }
>
> @@ -307,21 +300,13 @@ CollectionHandler (
> Private->CollectionJson = JsonDumpString (RedfishJsonInPayload (Private-
> >CollectionPayload), EDKII_JSON_COMPACT);
> ASSERT (Private->CollectionJson != NULL);
>
> - Status = ProcessCollection (Private);
> + Status = HandleCollectionResource (Private);
> if (EFI_ERROR (Status) && (Status == EFI_NOT_FOUND)) {
> - Status = CreateCollection (Private);
> + Status = CreateCollectionResource (Private);
> }
>
> ON_RELEASE:
>
> - if (SystemRootPath != NULL) {
> - FreePool (SystemRootPath);
> - }
> -
> - if (PathBuffer != NULL) {
> - FreePool (PathBuffer);
> - }
> -
> ReleaseCollectionResource (Private);
>
> return Status;
> @@ -332,10 +317,12 @@ ON_RELEASE:
>
> @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROTOCOL
> instance.
> @param[in] FeatureAction The action Redfish feature driver should
> 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 memory block
> of this
> - information should be freed by caller.
> + @param[in,out] InformationExchange The pointer to
> + RESOURCE_INFORMATION_EXCHANGE
> +
> + @retval EFI_SUCCESS Redfish feature driver callback is executed
> successfully.
> + @retval Others Some errors happened.
>
> @retval EFI_SUCCESS Redfish feature driver callback is executed
> 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;
>
> if (FeatureAction != CallbackActionStartOperation) {
> return EFI_UNSUPPORTED;
> @@ -365,6 +353,37 @@ RedfishCollectionFeatureCallback (
> return EFI_NOT_READY;
> }
>
> + //
> + // Save in private structure.
> + //
> + Private->InformationExchange = InformationExchange;
> +
> + //
> + // Find Redfish version on BMC
> + //
> + Private->RedfishVersion = RedfishGetVersion (RedfishService);
> +
> + //
> + // Create the full URI from Redfish service root.
> + //
> + ResourceUri = (EFI_STRING)AllocateZeroPool (MAX_URI_LENGTH * sizeof
> + (CHAR16)); if (ResourceUri == 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->SendInformation.FullUri);
> +
> + //
> + // Initialize collection path
> + //
> + Private->CollectionUri = RedfishGetUri (ResourceUri); if
> + (Private->CollectionUri == NULL) {
> + ASSERT (FALSE);
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> Status = 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/RedfishClient.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/RedfishMemoryC
> ollectionDxe.inf
> + INF
> +
> RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.inf
>
> !include RedfishClientPkg/RedfishJsonStructureDxe.fdf.inc
> #
> --
> 2.17.1
prev parent reply other threads:[~2023-05-10 14:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 13:04 [edk2-redfish-client][PATCH 1/5] RedfishClientPkg: Rename RedfishMemoryCollection driver Nickle Wang
2023-05-10 14:06 ` Chang, Abner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MN2PR12MB396642375B9531A044708A38EA779@MN2PR12MB3966.namprd12.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox