public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chang, Abner" <abner.chang@amd.com>
To: Nickle Wang <nicklew@nvidia.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Igor Kulchytskyy <igork@ami.com>
Subject: Re: [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add Redfish.Settings support
Date: Fri, 12 May 2023 04:09:30 +0000	[thread overview]
Message-ID: <MN2PR12MB396663D6701699D1EA67C72BEA759@MN2PR12MB3966.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20230512034705.8537-1-nicklew@nvidia.com>

[AMD Official Use Only - General]

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

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Friday, May 12, 2023 11:47 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@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 <simowang@nvidia.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@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

      reply	other threads:[~2023-05-12  4:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12  3:47 [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add Redfish.Settings support Nickle Wang
2023-05-12  4:09 ` Chang, Abner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN2PR12MB396663D6701699D1EA67C72BEA759@MN2PR12MB3966.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox