[AMD Official Use Only - General]

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

> -----Original Message-----
> From: Nickle Wang <nick...@nvidia.com>
> Sent: Thursday, January 4, 2024 1:09 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <abner.ch...@amd.com>; Igor Kulchytskyy
> <ig...@ami.com>; Nick Ramirez <nrami...@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 <nick...@nvidia.com>
> Cc: Abner Chang <abner.ch...@amd.com>
> Cc: Igor Kulchytskyy <ig...@ami.com>
> Cc: Nick Ramirez <nrami...@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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to