Use EDK2 RedfishHttpLib to replace RedfishHttpCacheLib and RedfishLib Signed-off-by: Nickle Wang <nick...@nvidia.com> Cc: Abner Chang <abner.ch...@amd.com> Cc: Igor Kulchytskyy <ig...@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/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-