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>
Subject: [edk2-devel] [edk2-redfish-client][PATCH 08/13] RedfishClientPkg/BootOptionDxe: ues RedfishHttpLib
Date: Thu, 29 Feb 2024 16:54:41 +0800 [thread overview]
Message-ID: <20240229085441.112518-1-nicklew@nvidia.com> (raw)
Use EDK2 RedfishHttpLib to replace RedfishHttpCacheLib and RedfishLib
Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
.../BootOption/v1_0_4/Dxe/BootOptionDxe.inf | 5 +-
.../v1_0_4/Common/BootOptionCommon.c | 45 ++--------
.../BootOption/v1_0_4/Dxe/BootOptionDxe.c | 86 ++++---------------
3 files changed, 26 insertions(+), 110 deletions(-)
diff --git a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf
index 00c1c5bba..cd3c1c711 100644
--- a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.inf
+++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.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
#
@@ -32,13 +32,12 @@
BaseMemoryLib
DebugLib
EdkIIRedfishResourceConfigLib
- RedfishLib
+ RedfishHttpLib
RedfishFeatureUtilityLib
RedfishResourceIdentifyLib
UefiLib
UefiDriverEntryPoint
RedfishAddendumLib
- RedfishHttpCacheLib
UefiBootManagerLib
DevicePathLib
BaseLib
diff --git a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c
index f471c01c3..339c8ba04 100644
--- a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c
+++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c
@@ -2,7 +2,7 @@
Redfish feature driver implementation - common functions
(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.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -449,7 +449,7 @@ RedfishProvisioningResourceCommon (
JsonWithAddendum = NULL;
}
- Status = CreatePayloadToPostResource (Private->RedfishService, Private->Payload, Json, NULL, NULL);
+ Status = RedfishHttpPostResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: post BootOption resource for %s failed: %r\n", __func__, BootOptionName, Status));
goto RELEASE_RESOURCE;
@@ -482,12 +482,7 @@ RELEASE_RESOURCE:
FreePool (Json);
}
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
+ RedfishHttpFreeResponse (&Response);
return Status;
}
@@ -519,7 +514,6 @@ RedfishCheckResourceCommon (
BOOLEAN DeleteResourceRequired;
EFI_STRING DevicePathString;
CHAR8 *DevicePathAsciiString;
- CHAR8 *AsciiUri;
if ((Private == NULL) || IS_EMPTY_STRING (Json)) {
return EFI_INVALID_PARAMETER;
@@ -531,8 +525,6 @@ RedfishCheckResourceCommon (
DeleteResourceRequired = FALSE;
BootOptionName = NULL;
BootOption = NULL;
- AsciiUri = NULL;
- Response.Payload = NULL;
Status = Private->JsonStructProtocol->ToStructure (
Private->JsonStructProtocol,
NULL,
@@ -594,13 +586,7 @@ RedfishCheckResourceCommon (
//
if (DeleteResourceRequired) {
DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: boot option %s is deleted in system. Delete %s\n", __func__, BootOptionName, Private->Uri));
- AsciiUri = StrUnicodeToAscii (Private->Uri);
- if (AsciiUri == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ON_RELEASE;
- }
-
- Status = RedfishDeleteByUri (Private->RedfishService, AsciiUri, &Response);
+ Status = RedfishHttpDeleteResource (Private->RedfishService, Private->Uri, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: can not delete %s: %r\n", __func__, Private->Uri, Status));
}
@@ -631,16 +617,8 @@ ON_RELEASE:
//
// Release resource
//
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
+ RedfishHttpFreeResponse (&Response);
- //
- // Release resource.
- //
Private->JsonStructProtocol->DestoryStructure (
Private->JsonStructProtocol,
(EFI_REST_JSON_STRUCTURE_HEADER *)BootOption
@@ -650,10 +628,6 @@ ON_RELEASE:
FreePool (BootOptionName);
}
- if (AsciiUri != NULL) {
- FreePool (AsciiUri);
- }
-
return Status;
}
@@ -748,7 +722,7 @@ RedfishUpdateResourceCommon (
//
// PATCH back to instance
//
- Status = CreatePayloadToPatchResource (Private->RedfishService, Private->Payload, Json, NULL);
+ Status = RedfishHttpPatchResource (Private->RedfishService, Private->Uri, Json, &Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func__, ConfigureLang, Status));
}
@@ -763,12 +737,7 @@ ON_RELEASE:
FreePool (ConfigureLang);
}
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
+ RedfishHttpFreeResponse (&Response);
return Status;
}
diff --git a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c
index dc2bd9da8..7501c1a97 100644
--- a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c
+++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c
@@ -2,7 +2,7 @@
Redfish feature driver implementation - BootOption
(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.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -51,7 +51,7 @@ RedfishResourceProvisioningResource (
return EFI_NOT_READY;
}
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -68,20 +68,11 @@ RedfishResourceProvisioningResource (
//
// Get latest ETag on URI and keep it in variable.
//
- RedfishHttpResetResource (Private->Uri);
SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
}
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
-
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
return Status;
}
@@ -122,7 +113,7 @@ RedfishResourceConsumeResource (
return EFI_NOT_READY;
}
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -169,25 +160,9 @@ RedfishResourceConsumeResource (
FreePool (Etag);
}
- if (Private->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;
- }
+ RedfishHttpFreeResponse (&Response);
+ RedfishHttpFreeResponse (&PendingSettingResponse);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -261,7 +236,7 @@ RedfishResourceUpdate (
return EFI_NOT_READY;
}
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -281,22 +256,14 @@ RedfishResourceUpdate (
//
// Get latest ETag on URI and keep it in variable.
//
- RedfishHttpResetResource (Private->Uri);
SetEtagFromUri (Private->RedfishService, Private->Uri, TRUE);
}
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -339,7 +306,7 @@ RedfishResourceCheck (
return EFI_NOT_READY;
}
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -369,15 +336,8 @@ RedfishResourceCheck (
FreePool (Etag);
}
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -420,7 +380,7 @@ RedfishResourceIdentify (
return EFI_NOT_READY;
}
- Status = RedfishHttpGetResource (Private->RedfishService, Uri, &Response, TRUE);
+ Status = RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &Response, TRUE);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, Uri));
return Status;
@@ -441,15 +401,8 @@ RedfishResourceIdentify (
//
// Release resource
//
- if (Private->Payload != NULL) {
- RedfishFreeResponse (
- Response.StatusCode,
- Response.HeaderCount,
- Response.Headers,
- Response.Payload
- );
- Private->Payload = NULL;
- }
+ RedfishHttpFreeResponse (&Response);
+ Private->Payload = NULL;
if (Private->Json != NULL) {
FreePool (Private->Json);
@@ -531,11 +484,6 @@ RedfishResourceStop (
Private->RedfishService = NULL;
}
- if (Private->Payload != NULL) {
- RedfishCleanupPayload (Private->Payload);
- Private->Payload = NULL;
- }
-
return EFI_SUCCESS;
}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116149): https://edk2.groups.io/g/devel/message/116149
Mute This Topic: https://groups.io/mt/104640232/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
reply other threads:[~2024-02-29 8:55 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=20240229085441.112518-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