[AMD Official Use Only - General]

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

> -----Original Message-----
> From: Nickle Wang <nick...@nvidia.com>
> Sent: Friday, May 12, 2023 11:47 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <abner.ch...@amd.com>; Igor Kulchytskyy
> <ig...@ami.com>
> Subject: [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add
> Redfish.Settings support
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> BIOS feature driver cannot recognize "@Redfish.Settings", decode it and get
> pending setting URI. So BIOS feature driver can consume pending setting
> from correct place.
> 
> Signed-off-by: Simon Wang <simow...@nvidia.com>
> Cc: Nickle Wang <nick...@nvidia.com>
> Cc: Abner Chang <abner.ch...@amd.com>
> Cc: Igor Kulchytskyy <ig...@ami.com>
> ---
>  .../Features/Bios/v1_0_9/Dxe/BiosDxe.c        | 65 ++++++++++++++++---
>  1 file changed, 57 insertions(+), 8 deletions(-)
> 
> diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> index 15ec208d..125e4eda 100644
> --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> @@ -2,6 +2,7 @@
>    Redfish feature driver implementation - Bios
> 
>    (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
> +  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -101,7 +102,13 @@ RedfishResourceConsumeResource (
>    REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
>    EFI_STATUS                       Status;
>    REDFISH_RESPONSE                 Response;
> +  REDFISH_RESPONSE                 *ExpectedResponse;
> +  REDFISH_RESPONSE                 RedfishSettingsResponse;
>    CHAR8                            *Etag;
> +  UINTN                            Index;
> +  EDKII_JSON_VALUE                 JsonValue;
> +  EFI_STRING                       RedfishSettingsUri;
> +  CONST CHAR8                      *RedfishSettingsUriKeys[] =
> { "@Redfish.Settings", "SettingsObject", "@odata.id" };
> 
>    if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
>      return EFI_INVALID_PARAMETER;
> @@ -119,8 +126,38 @@ RedfishResourceConsumeResource (
>      return Status;
>    }
> 
> +  ExpectedResponse   = &Response;
> +  RedfishSettingsUri = NULL;
> +  JsonValue          = RedfishJsonInPayload (Response.Payload);
> +
> +  //
> +  // Seeking RedfishSettings URI link.
> +  //
> +  for (Index = 0; Index < sizeof (RedfishSettingsUriKeys) / sizeof
> (*RedfishSettingsUriKeys); Index++) {
> +    if (JsonValue == NULL) {
> +      break;
> +    }
> +
> +    JsonValue = JsonObjectGetValue (JsonValueGetObject (JsonValue),
> + RedfishSettingsUriKeys[Index]);  }
> +
> +  if (JsonValue != NULL) {
> +    //
> +    // Verify RedfishSettings URI link is valid to retrieve resource or not.
> +    //
> +    RedfishSettingsUri = JsonValueGetUnicodeString (JsonValue);
> +
> +    Status = GetResourceByUri (Private->RedfishService, RedfishSettingsUri,
> &RedfishSettingsResponse);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "%a, @Redfish.Settings exists, get resource
> from: %s failed\n", __FUNCTION__, RedfishSettingsUri));
> +    } else {
> +      Uri              = RedfishSettingsUri;
> +      ExpectedResponse = &RedfishSettingsResponse;
> +    }
> +  }
> +
>    Private->Uri     = Uri;
> -  Private->Payload = Response.Payload;
> +  Private->Payload = ExpectedResponse->Payload;
>    ASSERT (Private->Payload != NULL);
> 
>    Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT); @@ -130,7 +167,7 @@
> RedfishResourceConsumeResource (
>    // Find etag in HTTP response header
>    //
>    Etag   = NULL;
> -  Status = GetEtagAndLocation (&Response, &Etag, NULL);
> +  Status = GetEtagAndLocation (ExpectedResponse, &Etag, NULL);
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n",
> __FUNCTION__));
>    }
> @@ -153,12 +190,24 @@ RedfishResourceConsumeResource (
>    // Release resource
>    //
>    if (Private->Payload != NULL) {
> -    RedfishFreeResponse (
> -      Response.StatusCode,
> -      Response.HeaderCount,
> -      Response.Headers,
> -      Response.Payload
> -      );
> +    if (Response.Payload != NULL) {
> +      RedfishFreeResponse (
> +        Response.StatusCode,
> +        Response.HeaderCount,
> +        Response.Headers,
> +        Response.Payload
> +        );
> +    }
> +
> +    if (RedfishSettingsResponse.Payload != NULL) {
> +      RedfishFreeResponse (
> +        RedfishSettingsResponse.StatusCode,
> +        RedfishSettingsResponse.HeaderCount,
> +        RedfishSettingsResponse.Headers,
> +        RedfishSettingsResponse.Payload
> +        );
> +    }
> +
>      Private->Payload = NULL;
>    }
> 
> --
> 2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104755): https://edk2.groups.io/g/devel/message/104755
Mute This Topic: https://groups.io/mt/98842834/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to