* [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add Redfish.Settings support
@ 2023-05-12 3:47 Nickle Wang
2023-05-12 4:09 ` Chang, Abner
0 siblings, 1 reply; 2+ messages in thread
From: Nickle Wang @ 2023-05-12 3:47 UTC (permalink / raw)
To: devel; +Cc: Abner Chang, Igor Kulchytskyy
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add Redfish.Settings support
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
0 siblings, 0 replies; 2+ messages in thread
From: Chang, Abner @ 2023-05-12 4:09 UTC (permalink / raw)
To: Nickle Wang, devel@edk2.groups.io; +Cc: Igor Kulchytskyy
[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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-12 4:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox