From: "Nickle Wang via groups.io" <nicklew=nvidia.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Abner Chang <abner.chang@amd.com>,
Igor Kulchytskyy <igork@ami.com>,
"Nick Ramirez" <nramirez@nvidia.com>
Subject: [edk2-devel] [edk2-redfish-client][PATCH 07/10] RedfishClientPkg/Bios: use HTTP cache lib
Date: Wed, 3 Jan 2024 20:00:56 +0800 [thread overview]
Message-ID: <20240103120056.62184-1-nicklew@nvidia.com> (raw)
Use Redfish Http cache library to query Redfish service.
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>
---
.../Features/Bios/v1_0_9/Dxe/BiosDxe.inf | 3 +-
.../Features/Bios/v1_0_9/Dxe/BiosDxe.c | 80 ++++++++-----------
2 files changed, 37 insertions(+), 46 deletions(-)
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf
index 37346e50..6ba4c3cf 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf
@@ -1,7 +1,7 @@
## @file
#
# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
-# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -39,6 +39,7 @@
UefiLib
UefiDriverEntryPoint
RedfishAddendumLib
+ RedfishHttpCacheLib
[Protocols]
gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
index 85dc5461..09ed8b9a 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
@@ -2,7 +2,7 @@
Redfish feature driver implementation - Bios
(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
- Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
+ Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -55,7 +55,8 @@ RedfishResourceProvisioningResource (
return EFI_NOT_READY;
}
- Status = GetResourceByUri (Private->RedfishService, Uri, &Response);
+ ZeroMem (&Response, sizeof (Response));
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -77,6 +78,7 @@ RedfishResourceProvisioningResource (
Response.Headers,
Response.Payload
);
+ RedfishHttpResetResource (Uri);
Private->Payload = NULL;
}
@@ -103,13 +105,10 @@ RedfishResourceConsumeResource (
REDFISH_RESOURCE_COMMON_PRIVATE *Private;
EFI_STATUS Status;
REDFISH_RESPONSE Response;
+ EFI_STRING PendingSettingUri;
+ REDFISH_RESPONSE PendingSettingResponse;
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;
@@ -121,45 +120,32 @@ RedfishResourceConsumeResource (
return EFI_NOT_READY;
}
- Status = GetResourceByUri (Private->RedfishService, Uri, &Response);
+ ZeroMem (&Response, sizeof (Response));
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, Uri));
return Status;
}
- ZeroMem (&RedfishSettingsResponse, sizeof (REDFISH_RESPONSE));
-
- ExpectedResponse = &Response;
- RedfishSettingsUri = NULL;
- JsonValue = RedfishJsonInPayload (Response.Payload);
-
//
- // Seeking RedfishSettings URI link.
+ // Check and see if "@Redfish.Settings" exist or not.
//
- 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;
- }
+ ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE));
+ Status = GetPendingSettings (
+ Private->RedfishService,
+ Response.Payload,
+ &PendingSettingResponse,
+ &PendingSettingUri
+ );
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __func__, PendingSettingUri));
+ Private->Uri = PendingSettingUri;
+ ExpectedResponse = &PendingSettingResponse;
+ } else {
+ Private->Uri = Uri;
+ ExpectedResponse = &Response;
}
- Private->Uri = Uri;
Private->Payload = ExpectedResponse->Payload;
ASSERT (Private->Payload != NULL);
@@ -202,12 +188,12 @@ RedfishResourceConsumeResource (
);
}
- if (RedfishSettingsResponse.Payload != NULL) {
+ if (PendingSettingResponse.Payload != NULL) {
RedfishFreeResponse (
- RedfishSettingsResponse.StatusCode,
- RedfishSettingsResponse.HeaderCount,
- RedfishSettingsResponse.Headers,
- RedfishSettingsResponse.Payload
+ PendingSettingResponse.StatusCode,
+ PendingSettingResponse.HeaderCount,
+ PendingSettingResponse.Headers,
+ PendingSettingResponse.Payload
);
}
@@ -289,7 +275,8 @@ RedfishResourceUpdate (
return EFI_NOT_READY;
}
- Status = GetResourceByUri (Private->RedfishService, Uri, &Response);
+ ZeroMem (&Response, sizeof (Response));
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -317,6 +304,7 @@ RedfishResourceUpdate (
Response.Headers,
Response.Payload
);
+ RedfishHttpResetResource (Uri);
Private->Payload = NULL;
}
@@ -359,7 +347,8 @@ RedfishResourceCheck (
return EFI_NOT_READY;
}
- Status = GetResourceByUri (Private->RedfishService, Uri, &Response);
+ ZeroMem (&Response, sizeof (Response));
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -430,7 +419,8 @@ RedfishResourceIdentify (
return EFI_NOT_READY;
}
- Status = GetResourceByUri (Private->RedfishService, Uri, &Response);
+ ZeroMem (&Response, sizeof (Response));
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, Uri));
return Status;
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113076): https://edk2.groups.io/g/devel/message/113076
Mute This Topic: https://groups.io/mt/103500382/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
reply other threads:[~2024-01-03 12:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240103120056.62184-1-nicklew@nvidia.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