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 v2 06/10] RedfishClientPkg/Memory: use HTTP cache lib
Date: Thu, 4 Jan 2024 10:32:10 +0800 [thread overview]
Message-ID: <20240104023210.11150-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/Memory/V1_7_1/Dxe/MemoryDxe.inf | 3 +-
.../Features/Memory/V1_7_1/Dxe/MemoryDxe.c | 70 +++++++++++++++----
2 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf
index 594a8749..43039b9f 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.inf
@@ -1,6 +1,7 @@
## @file
#
# (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP<BR>
+# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -36,7 +37,7 @@
RedfishResourceIdentifyLib
UefiLib
UefiDriverEntryPoint
-
+ RedfishHttpCacheLib
[Protocols]
gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED
diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
index 80bfd6d2..450170e1 100644
--- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
+++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c
@@ -2,7 +2,7 @@
Redfish feature driver implementation - Memory
(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
@@ -49,7 +49,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;
@@ -71,6 +72,7 @@ RedfishResourceProvisioningResource (
Response.Headers,
Response.Payload
);
+ RedfishHttpResetResource (Uri);
Private->Payload = NULL;
}
@@ -97,6 +99,9 @@ RedfishResourceConsumeResource (
REDFISH_RESOURCE_COMMON_PRIVATE *Private;
EFI_STATUS Status;
REDFISH_RESPONSE Response;
+ EFI_STRING PendingSettingUri;
+ REDFISH_RESPONSE PendingSettingResponse;
+ REDFISH_RESPONSE *ExpectedResponse;
CHAR8 *Etag;
if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
@@ -109,14 +114,33 @@ 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;
}
- Private->Uri = Uri;
- Private->Payload = Response.Payload;
+ //
+ // Check and see if "@Redfish.Settings" exist or not.
+ //
+ 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->Payload = ExpectedResponse->Payload;
ASSERT (Private->Payload != NULL);
Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), EDKII_JSON_COMPACT);
@@ -126,7 +150,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", __func__));
}
@@ -149,12 +173,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 (PendingSettingResponse.Payload != NULL) {
+ RedfishFreeResponse (
+ PendingSettingResponse.StatusCode,
+ PendingSettingResponse.HeaderCount,
+ PendingSettingResponse.Headers,
+ PendingSettingResponse.Payload
+ );
+ }
+
Private->Payload = NULL;
}
@@ -233,7 +269,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;
@@ -261,6 +298,7 @@ RedfishResourceUpdate (
Response.Headers,
Response.Payload
);
+ RedfishHttpResetResource (Uri);
Private->Payload = NULL;
}
@@ -303,7 +341,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;
@@ -374,7 +413,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 (#113121): https://edk2.groups.io/g/devel/message/113121
Mute This Topic: https://groups.io/mt/103516006/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
reply other threads:[~2024-01-04 2:32 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=20240104023210.11150-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