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

2022-07-27 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Reviewed-by: Abner Chang 

> -Original Message-
> From: Nickle Wang 
> Sent: Wednesday, July 27, 2022 9:38 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Yang, Atom
> ; Nick Ramirez 
> 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 
> 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/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
> +  Redfish feature driver implementation - MemoryCollection
> +
> +  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> 
>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_STATUSStatus;
> -  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, );
>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 (, 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 

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

2022-07-26 Thread Nickle Wang
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/RedfishMemoryCollectionDxe.c
 => MemoryCollectionDxe/MemoryCollectionDxe.c} (66%)
 rename 
RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemoryCollectionDxe.h
 => MemoryCollectionDxe/MemoryCollectionDxe.h} (64%)
 rename 
RedfishClientPkg/Features/{RedfishMemoryCollectionDxe/RedfishMemoryCollectionDxe.inf
 => MemoryCollectionDxe/MemoryCollectionDxe.inf} (71%)

diff --git 
a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCollectionDxe.c
 b/RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
similarity index 66%
rename from 
RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCollectionDxe.c
rename to RedfishClientPkg/Features/MemoryCollectionDxe/MemoryCollectionDxe.c
index d97f0f161e..43426a78af 100644
--- 
a/RedfishClientPkg/Features/RedfishMemoryCollectionDxe/RedfishMemoryCollectionDxe.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
+  Redfish feature driver implementation - MemoryCollection
+
+  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
 
   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_STATUSStatus;
-  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, );
   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 (, 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, 
, );
+if (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND) {
+  Private->InformationExchange->ReturnedInformation.Type = 
InformationTypeCollectionMemberConfigLanguage;
+