[edk2-devel] [edk2-staging][PATCH v3 11/15] edk2-staging/RedfishClientPkg: Rename RedfishMemoryCollection driver

Chang, Abner via groups.io abner.chang=amd.com at groups.io
Thu Jul 28 03:41:28 UTC 2022


[AMD Official Use Only - General]

Reviewed-by: Abner Chang <abner.chang at amd.com>

> -----Original Message-----
> From: Nickle Wang <nickle.wang at hpe.com>
> Sent: Wednesday, July 27, 2022 9:38 AM
> To: devel at edk2.groups.io
> Cc: Chang, Abner <Abner.Chang at amd.com>; Yang, Atom
> <Atom.Yang at amd.com>; Nick Ramirez <nramirez at nvidia.com>
> Subject: [edk2-staging][PATCH v3 11/15] edk2-staging/RedfishClientPkg:
> Rename RedfishMemoryCollection driver
> 
> [CAUTION: External Email]
> 
> 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 <nickle.wang at hpe.com>
> Cc: Abner Chang <abner.chang at amd.com>
> Cc: Yang Atom <Atom.Yang at amd.com>
> Cc: Nick Ramirez <nramirez at nvidia.com>
> ---
>  .../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/RedfishMemoryC
> ollectionDxe.c => MemoryCollectionDxe/MemoryCollectionDxe.c} (66%)
> rename
> RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.h => MemoryCollectionDxe/MemoryCollectionDxe.h} (64%)
> rename
> RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.inf => MemoryCollectionDxe/MemoryCollectionDxe.inf} (71%)
> 
> diff --git
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.c
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> c
> similarity index 66%
> rename from
> RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.c
> rename to
> RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
> index d97f0f161e..43426a78af 100644
> ---
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.c
> +++
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> +++ c
> @@ -1,67 +1,98 @@
>  /** @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;
>    }
> +  //
> +  // 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;
> +      }
> 
> -  RedfishResrouceProtocol = GetRedfishResourceConfigProtocol (
> -                              SchemaInfo.Schema,
> -                              SchemaInfo.Major,
> -                              SchemaInfo.Minor,
> -                              SchemaInfo.Errata
> -                              );
> -  if (RedfishResrouceProtocol == NULL) {
> -    return EFI_DEVICE_ERROR;
> +      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 +103,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 +142,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 +151,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,23 +168,22 @@ ProcessCollection (
>      return EFI_NOT_FOUND;
>    }
> 
> -  Count = 0;
>    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));
> +      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);
>        }
>      }
> 
> @@ -172,25 +197,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;
> 
>    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)) {
> @@ -200,18 +224,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;
> @@ -248,6 +263,11 @@ ReleaseCollectionResource (
>      Private->CollectionJson = NULL;
>    }
> 
> +  if (Private->RedfishVersion != NULL) {
> +    FreePool (Private->RedfishVersion);
> +    Private->RedfishVersion = NULL;
> +  }
> +
>    return EFI_SUCCESS;
>  }
> 
> @@ -257,49 +277,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;
>    }
> 
> @@ -309,21 +299,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;
> @@ -334,10 +316,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.
> @@ -349,12 +333,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;
> @@ -367,6 +352,36 @@ 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)); @@ -549,7 +564,7 @@ RedfishCollectionUnload (
>    )
>  {
>    EFI_STATUS                             Status;
> -  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL    *ConfigHandler;
> +  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *ConfigHandler;
> 
>    if (mRedfishCollectionPrivate == NULL) {
>      return EFI_NOT_READY;
> diff --git
> a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemory
> CollectionDxe.h
> b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.
> h
> similarity index 64%
> rename from
> RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryC
> ollectionDxe.h
> rename to
> RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.h
> index 83ca836941..75b4a123ff 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/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 e7bcf49bdb..05e05712e7 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,19 +38,19 @@
>    UefiLib
>    UefiDriverEntryPoint
>    UefiBootServicesTableLib
> +  EdkIIRedfishResourceConfigLib
> +  RedfishVersionLib
> 
>  [Protocols]
>    gEdkIIRedfishConfigHandlerProtocolGuid    ## CONSUMED
>    gEfiRestJsonStructureProtocolGuid         ## CONSUMED
> -  gEdkIIRedfishResourceConfigProtocolGuid   ## CONSUMED
>    gEdkIIRedfishFeatureProtocolGuid          ## CONSUMED
> 
>  [Guids]
> -  gEfiEventReadyToBootGuid
> 
>  [Pcd]
>    gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize
>    gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize
> 
>  [Depex]
> -  TRUE
> \ No newline at end of file
> +  TRUE
> diff --git a/RedfishClientPkg/Include/RedfishCollectionCommon.h
> b/RedfishClientPkg/Include/RedfishCollectionCommon.h
> index 05a0f672f3..d4adcedd1f 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/RedfishClient.fdf.inc
> b/RedfishClientPkg/RedfishClient.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
>    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
>    #
> diff --git a/RedfishClientPkg/RedfishClientComponents.dsc.inc
> b/RedfishClientPkg/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.
>    #
>    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
> 
> --
> 2.32.0.windows.2


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91921): https://edk2.groups.io/g/devel/message/91921
Mute This Topic: https://groups.io/mt/92641652/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list