public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add ETag to Redfish resource check function
@ 2024-01-04  5:09 Nickle Wang via groups.io
  2024-01-04  8:16 ` Chang, Abner via groups.io
  0 siblings, 1 reply; 2+ messages in thread
From: Nickle Wang via groups.io @ 2024-01-04  5:09 UTC (permalink / raw)
  To: devel; +Cc: Abner Chang, Igor Kulchytskyy, Nick Ramirez

Add ETag parameter to RedfishCheckResourceCommon(). When the ETag
from Redfish resource is not changed, feature driver can skip the
check function. This helps to improve the feature driver performance.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
 RedfishClientPkg/Include/RedfishResourceCommon.h  |  4 +++-
 .../Features/Bios/v1_0_9/Common/BiosCommon.c      | 15 ++++++++++++++-
 .../Features/Bios/v1_0_9/Dxe/BiosDxe.c            | 12 +++++++++++-
 .../v1_5_0/Common/ComputerSystemCommon.c          | 15 ++++++++++++++-
 .../ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c | 12 +++++++++++-
 .../Features/Memory/V1_7_1/Common/MemoryCommon.c  | 15 ++++++++++++++-
 .../Features/Memory/V1_7_1/Dxe/MemoryDxe.c        | 12 +++++++++++-
 7 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/RedfishClientPkg/Include/RedfishResourceCommon.h b/RedfishClientPkg/Include/RedfishResourceCommon.h
index d354d3b0..c1286adc 100644
--- a/RedfishClientPkg/Include/RedfishResourceCommon.h
+++ b/RedfishClientPkg/Include/RedfishResourceCommon.h
@@ -106,6 +106,7 @@ RedfishProvisioningResourceCommon (
 
   @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
   @param[in]   Json                The JSON to consume.
+  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
 
   @retval EFI_SUCCESS              Value is returned successfully.
   @retval Others                   Some error happened.
@@ -114,7 +115,8 @@ RedfishProvisioningResourceCommon (
 EFI_STATUS
 RedfishCheckResourceCommon (
   IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
-  IN     CHAR8                            *Json
+  IN     CHAR8                            *Json,
+  IN     CHAR8                            *HeaderEtag OPTIONAL
   );
 
 /**
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
index a26a1083..0ae84149 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
@@ -530,6 +530,7 @@ RedfishProvisioningResourceCommon (
 
   @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
   @param[in]   Json                The JSON to consume.
+  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
 
   @retval EFI_SUCCESS              Value is returned successfully.
   @retval Others                   Some error happened.
@@ -538,7 +539,8 @@ RedfishProvisioningResourceCommon (
 EFI_STATUS
 RedfishCheckResourceCommon (
   IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
-  IN     CHAR8                            *Json
+  IN     CHAR8                            *Json,
+  IN     CHAR8                            *HeaderEtag OPTIONAL
   )
 {
   UINTN       Index;
@@ -551,6 +553,17 @@ RedfishCheckResourceCommon (
     return EFI_INVALID_PARAMETER;
   }
 
+  //
+  // Check ETAG to see if we need to check this resource again or not.
+  //
+  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
+    //
+    // No change
+    //
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore check action\n", __func__, Private->Uri));
+    return EFI_SUCCESS;
+  }
+
   Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigureLangList, &Count);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, RedfishPlatformConfigGetConfigureLang failed: %r\n", __func__, Status));
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
index 64b9d562..2a49c5cd 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
@@ -336,6 +336,7 @@ RedfishResourceCheck (
   REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
   EFI_STATUS                       Status;
   REDFISH_RESPONSE                 Response;
+  CHAR8                            *Etag;
 
   if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
     return EFI_INVALID_PARAMETER;
@@ -361,7 +362,16 @@ RedfishResourceCheck (
   Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
   ASSERT (Private->Json != NULL);
 
-  Status = RedfishCheckResourceCommon (Private, Private->Json);
+  //
+  // Find etag in HTTP response header
+  //
+  Etag   = NULL;
+  Status = GetEtagAndLocation (&Response, &Etag, NULL);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
+  }
+
+  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __func__, Uri, Status));
   }
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
index 979d49f7..3ace03bd 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystemCommon.c
@@ -1434,6 +1434,7 @@ RedfishProvisioningResourceCommon (
 
   @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
   @param[in]   Json                The JSON to consume.
+  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
 
   @retval EFI_SUCCESS              Value is returned successfully.
   @retval Others                   Some error happened.
@@ -1442,7 +1443,8 @@ RedfishProvisioningResourceCommon (
 EFI_STATUS
 RedfishCheckResourceCommon (
   IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
-  IN     CHAR8                            *Json
+  IN     CHAR8                            *Json,
+  IN     CHAR8                            *HeaderEtag OPTIONAL
   )
 {
   UINTN       Index;
@@ -1455,6 +1457,17 @@ RedfishCheckResourceCommon (
     return EFI_INVALID_PARAMETER;
   }
 
+  //
+  // Check ETAG to see if we need to check this resource again or not.
+  //
+  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
+    //
+    // No change
+    //
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore check action\n", __func__, Private->Uri));
+    return EFI_SUCCESS;
+  }
+
   Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigureLangList, &Count);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, RedfishPlatformConfigGetConfigureLang failed: %r\n", __func__, Status));
diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
index f89a4282..0bbaa92b 100644
--- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
+++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c
@@ -330,6 +330,7 @@ RedfishResourceCheck (
   REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
   EFI_STATUS                       Status;
   REDFISH_RESPONSE                 Response;
+  CHAR8                            *Etag;
 
   if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
     return EFI_INVALID_PARAMETER;
@@ -355,7 +356,16 @@ RedfishResourceCheck (
   Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
   ASSERT (Private->Json != NULL);
 
-  Status = RedfishCheckResourceCommon (Private, Private->Json);
+  //
+  // Find etag in HTTP response header
+  //
+  Etag   = NULL;
+  Status = GetEtagAndLocation (&Response, &Etag, NULL);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
+  }
+
+  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __func__, Uri, Status));
   }
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
index 14c26301..eb52c68c 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
@@ -2350,6 +2350,7 @@ RedfishProvisioningResourceCommon (
 
   @param[in]   This                Pointer to REDFISH_RESOURCE_COMMON_PRIVATE instance.
   @param[in]   Json                The JSON to consume.
+  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
 
   @retval EFI_SUCCESS              Value is returned successfully.
   @retval Others                   Some error happened.
@@ -2358,7 +2359,8 @@ RedfishProvisioningResourceCommon (
 EFI_STATUS
 RedfishCheckResourceCommon (
   IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
-  IN     CHAR8                            *Json
+  IN     CHAR8                            *Json,
+  IN     CHAR8                            *HeaderEtag OPTIONAL
   )
 {
   UINTN       Index;
@@ -2371,6 +2373,17 @@ RedfishCheckResourceCommon (
     return EFI_INVALID_PARAMETER;
   }
 
+  //
+  // Check ETAG to see if we need to check this resource again or not.
+  //
+  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
+    //
+    // No change
+    //
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore check action\n", __func__, Private->Uri));
+    return EFI_SUCCESS;
+  }
+
   Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA, RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN, &ConfigureLangList, &Count);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, RedfishPlatformConfigGetConfigureLang failed: %r\n", __func__, Status));
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
index 450170e1..92300780 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
@@ -330,6 +330,7 @@ RedfishResourceCheck (
   REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
   EFI_STATUS                       Status;
   REDFISH_RESPONSE                 Response;
+  CHAR8                            *Etag;
 
   if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
     return EFI_INVALID_PARAMETER;
@@ -355,7 +356,16 @@ RedfishResourceCheck (
   Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
   ASSERT (Private->Json != NULL);
 
-  Status = RedfishCheckResourceCommon (Private, Private->Json);
+  //
+  // Find etag in HTTP response header
+  //
+  Etag   = NULL;
+  Status = GetEtagAndLocation (&Response, &Etag, NULL);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __func__));
+  }
+
+  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __func__, Uri, Status));
   }
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113132): https://edk2.groups.io/g/devel/message/113132
Mute This Topic: https://groups.io/mt/103517651/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add ETag to Redfish resource check function
  2024-01-04  5:09 [edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add ETag to Redfish resource check function Nickle Wang via groups.io
@ 2024-01-04  8:16 ` Chang, Abner via groups.io
  0 siblings, 0 replies; 2+ messages in thread
From: Chang, Abner via groups.io @ 2024-01-04  8:16 UTC (permalink / raw)
  To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy, Nick Ramirez

[AMD Official Use Only - General]

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

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Thursday, January 4, 2024 1:09 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>
> Subject: [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add ETag to
> Redfish resource check function
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Add ETag parameter to RedfishCheckResourceCommon(). When the ETag
> from Redfish resource is not changed, feature driver can skip the
> check function. This helps to improve the feature driver performance.
>
> Signed-off-by: Nickle Wang <nicklew@nvidia.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Cc: Nick Ramirez <nramirez@nvidia.com>
> ---
>  RedfishClientPkg/Include/RedfishResourceCommon.h  |  4 +++-
>  .../Features/Bios/v1_0_9/Common/BiosCommon.c      | 15
> ++++++++++++++-
>  .../Features/Bios/v1_0_9/Dxe/BiosDxe.c            | 12 +++++++++++-
>  .../v1_5_0/Common/ComputerSystemCommon.c          | 15
> ++++++++++++++-
>  .../ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe.c | 12
> +++++++++++-
>  .../Features/Memory/V1_7_1/Common/MemoryCommon.c  | 15
> ++++++++++++++-
>  .../Features/Memory/V1_7_1/Dxe/MemoryDxe.c        | 12 +++++++++++-
>  7 files changed, 78 insertions(+), 7 deletions(-)
>
> diff --git a/RedfishClientPkg/Include/RedfishResourceCommon.h
> b/RedfishClientPkg/Include/RedfishResourceCommon.h
> index d354d3b0..c1286adc 100644
> --- a/RedfishClientPkg/Include/RedfishResourceCommon.h
> +++ b/RedfishClientPkg/Include/RedfishResourceCommon.h
> @@ -106,6 +106,7 @@ RedfishProvisioningResourceCommon (
>
>    @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
>    @param[in]   Json                The JSON to consume.
> +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
>
>    @retval EFI_SUCCESS              Value is returned successfully.
>    @retval Others                   Some error happened.
> @@ -114,7 +115,8 @@ RedfishProvisioningResourceCommon (
>  EFI_STATUS
>  RedfishCheckResourceCommon (
>    IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> -  IN     CHAR8                            *Json
> +  IN     CHAR8                            *Json,
> +  IN     CHAR8                            *HeaderEtag OPTIONAL
>    );
>
>  /**
> diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> index a26a1083..0ae84149 100644
> --- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
> @@ -530,6 +530,7 @@ RedfishProvisioningResourceCommon (
>
>    @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
>    @param[in]   Json                The JSON to consume.
> +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
>
>    @retval EFI_SUCCESS              Value is returned successfully.
>    @retval Others                   Some error happened.
> @@ -538,7 +539,8 @@ RedfishProvisioningResourceCommon (
>  EFI_STATUS
>  RedfishCheckResourceCommon (
>    IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> -  IN     CHAR8                            *Json
> +  IN     CHAR8                            *Json,
> +  IN     CHAR8                            *HeaderEtag OPTIONAL
>    )
>  {
>    UINTN       Index;
> @@ -551,6 +553,17 @@ RedfishCheckResourceCommon (
>      return EFI_INVALID_PARAMETER;
>    }
>
> +  //
> +  // Check ETAG to see if we need to check this resource again or not.
> +  //
> +  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
> +    //
> +    // No change
> +    //
> +    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore
> check action\n", __func__, Private->Uri));
> +    return EFI_SUCCESS;
> +  }
> +
>    Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN,
> &ConfigureLangList, &Count);
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a, RedfishPlatformConfigGetConfigureLang
> failed: %r\n", __func__, Status));
> diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> index 64b9d562..2a49c5cd 100644
> --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> @@ -336,6 +336,7 @@ RedfishResourceCheck (
>    REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
>    EFI_STATUS                       Status;
>    REDFISH_RESPONSE                 Response;
> +  CHAR8                            *Etag;
>
>    if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
>      return EFI_INVALID_PARAMETER;
> @@ -361,7 +362,16 @@ RedfishResourceCheck (
>    Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT);
>    ASSERT (Private->Json != NULL);
>
> -  Status = RedfishCheckResourceCommon (Private, Private->Json);
> +  //
> +  // Find etag in HTTP response header
> +  //
> +  Etag   = NULL;
> +  Status = GetEtagAndLocation (&Response, &Etag, NULL);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n",
> __func__));
> +  }
> +
> +  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n",
> __func__, Uri, Status));
>    }
> diff --git
> a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Computer
> SystemCommon.c
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Computer
> SystemCommon.c
> index 979d49f7..3ace03bd 100644
> ---
> a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Computer
> SystemCommon.c
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Computer
> SystemCommon.c
> @@ -1434,6 +1434,7 @@ RedfishProvisioningResourceCommon (
>
>    @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
>    @param[in]   Json                The JSON to consume.
> +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
>
>    @retval EFI_SUCCESS              Value is returned successfully.
>    @retval Others                   Some error happened.
> @@ -1442,7 +1443,8 @@ RedfishProvisioningResourceCommon (
>  EFI_STATUS
>  RedfishCheckResourceCommon (
>    IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> -  IN     CHAR8                            *Json
> +  IN     CHAR8                            *Json,
> +  IN     CHAR8                            *HeaderEtag OPTIONAL
>    )
>  {
>    UINTN       Index;
> @@ -1455,6 +1457,17 @@ RedfishCheckResourceCommon (
>      return EFI_INVALID_PARAMETER;
>    }
>
> +  //
> +  // Check ETAG to see if we need to check this resource again or not.
> +  //
> +  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
> +    //
> +    // No change
> +    //
> +    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore
> check action\n", __func__, Private->Uri));
> +    return EFI_SUCCESS;
> +  }
> +
>    Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN,
> &ConfigureLangList, &Count);
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a, RedfishPlatformConfigGetConfigureLang
> failed: %r\n", __func__, Status));
> diff --git
> a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste
> mDxe.c
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste
> mDxe.c
> index f89a4282..0bbaa92b 100644
> ---
> a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste
> mDxe.c
> +++
> b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSyste
> mDxe.c
> @@ -330,6 +330,7 @@ RedfishResourceCheck (
>    REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
>    EFI_STATUS                       Status;
>    REDFISH_RESPONSE                 Response;
> +  CHAR8                            *Etag;
>
>    if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
>      return EFI_INVALID_PARAMETER;
> @@ -355,7 +356,16 @@ RedfishResourceCheck (
>    Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT);
>    ASSERT (Private->Json != NULL);
>
> -  Status = RedfishCheckResourceCommon (Private, Private->Json);
> +  //
> +  // Find etag in HTTP response header
> +  //
> +  Etag   = NULL;
> +  Status = GetEtagAndLocation (&Response, &Etag, NULL);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n",
> __func__));
> +  }
> +
> +  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n",
> __func__, Uri, Status));
>    }
> diff --git
> a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
> b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.
> c
> index 14c26301..eb52c68c 100644
> ---
> a/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.c
> +++
> b/RedfishClientPkg/Features/Memory/V1_7_1/Common/MemoryCommon.
> c
> @@ -2350,6 +2350,7 @@ RedfishProvisioningResourceCommon (
>
>    @param[in]   This                Pointer to
> REDFISH_RESOURCE_COMMON_PRIVATE instance.
>    @param[in]   Json                The JSON to consume.
> +  @param[in]   HeaderEtag          The Etag string returned in HTTP header.
>
>    @retval EFI_SUCCESS              Value is returned successfully.
>    @retval Others                   Some error happened.
> @@ -2358,7 +2359,8 @@ RedfishProvisioningResourceCommon (
>  EFI_STATUS
>  RedfishCheckResourceCommon (
>    IN     REDFISH_RESOURCE_COMMON_PRIVATE  *Private,
> -  IN     CHAR8                            *Json
> +  IN     CHAR8                            *Json,
> +  IN     CHAR8                            *HeaderEtag OPTIONAL
>    )
>  {
>    UINTN       Index;
> @@ -2371,6 +2373,17 @@ RedfishCheckResourceCommon (
>      return EFI_INVALID_PARAMETER;
>    }
>
> +  //
> +  // Check ETAG to see if we need to check this resource again or not.
> +  //
> +  if (CheckEtag (Private->Uri, HeaderEtag, NULL)) {
> +    //
> +    // No change
> +    //
> +    DEBUG ((DEBUG_MANAGEABILITY, "%a: ETAG: %s has no change, ignore
> check action\n", __func__, Private->Uri));
> +    return EFI_SUCCESS;
> +  }
> +
>    Status = RedfishPlatformConfigGetConfigureLang (RESOURCE_SCHEMA,
> RESOURCE_SCHEMA_VERSION, REDPATH_ARRAY_PATTERN,
> &ConfigureLangList, &Count);
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a, RedfishPlatformConfigGetConfigureLang
> failed: %r\n", __func__, Status));
> diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
> b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
> index 450170e1..92300780 100644
> --- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
> +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
> @@ -330,6 +330,7 @@ RedfishResourceCheck (
>    REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
>    EFI_STATUS                       Status;
>    REDFISH_RESPONSE                 Response;
> +  CHAR8                            *Etag;
>
>    if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
>      return EFI_INVALID_PARAMETER;
> @@ -355,7 +356,16 @@ RedfishResourceCheck (
>    Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT);
>    ASSERT (Private->Json != NULL);
>
> -  Status = RedfishCheckResourceCommon (Private, Private->Json);
> +  //
> +  // Find etag in HTTP response header
> +  //
> +  Etag   = NULL;
> +  Status = GetEtagAndLocation (&Response, &Etag, NULL);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n",
> __func__));
> +  }
> +
> +  Status = RedfishCheckResourceCommon (Private, Private->Json, Etag);
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n",
> __func__, Uri, Status));
>    }
> --
> 2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113143): https://edk2.groups.io/g/devel/message/113143
Mute This Topic: https://groups.io/mt/103517651/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-04  8:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-04  5:09 [edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: add ETag to Redfish resource check function Nickle Wang via groups.io
2024-01-04  8:16 ` Chang, Abner via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox