From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E2F8A941596 for ; Thu, 29 Feb 2024 08:55:24 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=6sGwjNGo6GbjzCGOIMC4MItZADxRzykD4UnG/VhMLDs=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1709196923; v=1; b=kF/5ZiYZPA4KvvHu9lNzG9ewigHtQ0IJPV2oOEFQzblDRcoUyqduG4RAAdP6vqm95INKp6MW Z0b40uGjX3DXn504MujNwTFGqOvOXrK/lCxs2AqwxF0RVjfemay1VDewnPamViBnucb6cOLXTX/ Ksn1aMkhF8nL9hG/xlY2wNWg= X-Received: by 127.0.0.2 with SMTP id ST1UYY7687511xbERGlikVtm; Thu, 29 Feb 2024 00:55:23 -0800 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.57]) by mx.groups.io with SMTP id smtpd.web11.19937.1709196922985180977 for ; Thu, 29 Feb 2024 00:55:23 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dSH7yfBwX1WXcpAI38X11cRaFSejmJ21IOORIEHkkgVVIjDyTpOaJ2f23t+0Wm8zUVsVgWo6NK/zSPJ+ex0Yoq0Ozg/PxGJ6gHQkJ7Ybc8ruMV/GjjGKsSygj4D/hJNqvKkYVYidbpsqxDaWaR42yEeA1RqDOcobqQonaR+0pRxIeXVXO+PObbZwF2IPmv3lCTrEtLZyLC8mFgqgyuQiJtvxGtMlAZfY/oCeJEjIGAmN//ub+YRKU+hs6K7bwzjk4rO4tY69Uh53UUWWI133U+f10xHPaNeiMQ3bbGLPdcfn0fyf21tyAaXBbKWTqz/Y2Jq27c7vivIER3n+lE2l5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XAJQ6oedfSQr2M0fUf/KaBw1L4TALPXElSOVrI3pZFE=; b=IX5OzvGJymrRN8WPGP6DGuy8JdrjMae8QwBRI2eo+uv5FOz/lpos0CbVAppYsweHdXqYD1MZ73HHwjsi6TYrPQnCbdKVjojp/9dDCYXFTjSDGSjPH/o7UekrO5uX+rdjTpZfl3uuxwgk2YT8wLRKArw6wyWuLryv21G7H9FbiJEr9h4uV6jSyeEUrC2AuzTRFH2RqMhOiMknTgY0lghVzhGyE+i+C1L+cSB/6f7XXvTNRp1dL4ZUDNiA01ZLMcmzBbg1gvx60hcpg8HhiR2jD8B6P5sLhyoLddrp6uI4rrUYHNwLJA0w9A3OjYQuvnpdWxI0oBN75R/qA/9LObo92w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from CH5P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::14) by PH0PR12MB7887.namprd12.prod.outlook.com (2603:10b6:510:26d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Thu, 29 Feb 2024 08:55:18 +0000 X-Received: from SA2PEPF00001509.namprd04.prod.outlook.com (2603:10b6:610:1ef:cafe::b4) by CH5P220CA0010.outlook.office365.com (2603:10b6:610:1ef::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.30 via Frontend Transport; Thu, 29 Feb 2024 08:55:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00001509.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Thu, 29 Feb 2024 08:55:17 +0000 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 29 Feb 2024 00:54:59 -0800 X-Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Thu, 29 Feb 2024 00:54:57 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Thu, 29 Feb 2024 00:54:56 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy Subject: [edk2-devel] [edk2-redfish-client][PATCH 10/13] RedfishClientPkg/ComputerSystemDxe: ues RedfishHttpLib Date: Thu, 29 Feb 2024 16:54:55 +0800 Message-ID: <20240229085455.112664-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001509:EE_|PH0PR12MB7887:EE_ X-MS-Office365-Filtering-Correlation-Id: c27cd0da-882a-4cb9-f83c-08dc39042735 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: wLSIy4rBexb4PebQGdmeryruLxU/Wiolh4PhRvCtWu8sDlsJhFqiGG+X/irc4mtsxZr5ZDRfg6NFkUe7nG9IK/fv4E5CzB+mi3i85cr5uPBjU6FiFJJ+LHFXp8hUS18dOJ38lm+5UzFWdBw5DPM6Oke4jmqPgVyEj9/z8nZccKVRJIWV83kvouHm9+sIvAWRDx3w2x6e30idMWDJBd8Csg+i5IF/XswwSg1IGit61xQ+FFfIbN3UC8bOXmkC9CRKxK595ktncMBBUPvjJh9AZATenbIoWsyoVo/VXgJwpVBTKGQy8CZQi6KV5P9GBMI4qU3+2HMtvbCsM/sc0pCWXW93V3zMWJVDcoX2vTow1nJl2VZCa5SFWeRKkRt+1JcNWrgQv9kxVmfzPeff+/WQnnYBXUB4IxzB1M2tXkdrrZTm9B0OOhOI2l+XcWmb95Daw/hAMAalxMzS2MZd0O/FKWyaC7TRaXKVE06W+2iwSqLXgpQGsHZ7oJJPBAdF85MZLT3n/ow7VLchSfbgjr6usVvadak1q2gmSigS8IssFiWdLZFyqYXptXgxqs4Pb7GaA+cH3YKF1qJCRMGmt0bD1RLVFlkfurPaXmJWvjk47eOapWaeg4nZDMalP7utddkDwLNkqx9XDFPPTvnrmqCpvlwimo/kzXjsMeS5ibly+59x2YVt6YtVDuefMq6tvWz9vXkXz6x4cPk5SlCkM0dAk3nkUOnLiba6+uA5tKbzn8LDS/VyONPt7CT06Fi5Qf6w X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Feb 2024 08:55:17.8862 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c27cd0da-882a-4cb9-f83c-08dc39042735 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001509.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7887 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: gsBRuSELzRrEe0i4w7Il8cD1x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="kF/5ZiYZ"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Use EDK2 RedfishHttpLib to replace RedfishHttpCacheLib and RedfishLib Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy --- .../v1_13_0/Dxe/ComputerSystemDxe.inf | 3 +- .../v1_5_0/Dxe/ComputerSystemDxe.inf | 3 +- .../v1_13_0/Common/ComputerSystemCommon.c | 68 +++++++++------ .../v1_13_0/Dxe/ComputerSystemDxe.c | 85 ++++--------------- .../v1_5_0/Common/ComputerSystemCommon.c | 68 +++++++++------ .../v1_5_0/Dxe/ComputerSystemDxe.c | 84 ++++-------------- 6 files changed, 116 insertions(+), 195 deletions(-) diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerS= ystemDxe.inf b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/Compute= rSystemDxe.inf index be1c2164d..40403ac7f 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDx= e.inf +++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDx= e.inf @@ -32,13 +32,12 @@ BaseMemoryLib DebugLib EdkIIRedfishResourceConfigLib - RedfishLib + RedfishHttpLib RedfishFeatureUtilityLib RedfishResourceIdentifyLib UefiLib UefiDriverEntryPoint RedfishAddendumLib - RedfishHttpCacheLib =20 [Protocols] gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSy= stemDxe.inf b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerS= ystemDxe.inf index 4e7dc5c7c..46ac2d4e5 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .inf +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .inf @@ -32,13 +32,12 @@ BaseMemoryLib DebugLib EdkIIRedfishResourceConfigLib - RedfishLib + RedfishHttpLib RedfishFeatureUtilityLib RedfishResourceIdentifyLib UefiLib UefiDriverEntryPoint RedfishAddendumLib - RedfishHttpCacheLib =20 [Protocols] gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/Comput= erSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/= ComputerSystemCommon.c index d69fc176a..df22a1c90 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste= mCommon.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Common/ComputerSyste= mCommon.c @@ -2,7 +2,7 @@ Redfish feature driver implementation - common functions =20 (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -407,18 +407,18 @@ ProvisioningComputerSystemResource ( IN EFI_STRING ConfigureLang ) { - CHAR8 *Json; - CHAR8 *JsonWithAddendum; - EFI_STATUS Status; - EFI_STRING NewResourceLocation; - CHAR8 *EtagStr; - CHAR8 ResourceId[16]; + CHAR8 *Json; + CHAR8 *JsonWithAddendum; + EFI_STATUS Status; + EFI_STRING NewResourceLocation; + CHAR8 ResourceId[16]; + REDFISH_RESPONSE Response; =20 if (IS_EMPTY_STRING (ConfigureLang) || (Private =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 - EtagStr =3D NULL; + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index); =20 Status =3D ProvisioningComputerSystemProperties ( @@ -466,27 +466,31 @@ ProvisioningComputerSystemResource ( JsonWithAddendum =3D NULL; } =20 - Status =3D CreatePayloadToPostResource (Private->RedfishService, Private= ->Payload, Json, &NewResourceLocation, &EtagStr); + Status =3D RedfishHttpPostResource (Private->RedfishService, Private->Ur= i, Json, &Response); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s failed: = %r\n", __func__, ConfigureLang, Status)); + DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", __f= unc__, ConfigureLang, Status)); goto RELEASE_RESOURCE; } =20 - ASSERT (NewResourceLocation !=3D NULL); + // + // Per Redfish spec. the URL of new resource will be returned in "Locati= on" header. + // + Status =3D GetHttpResponseLocation (&Response, &NewResourceLocation); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __func__, S= tatus)); + goto RELEASE_RESOURCE; + } =20 // // Keep location of new resource. // if (NewResourceLocation !=3D NULL) { + DEBUG ((DEBUG_MANAGEABILITY, "%a: Location: %s\n", __func__, NewResour= ceLocation)); RedfishSetRedfishUri (ConfigureLang, NewResourceLocation); } =20 RELEASE_RESOURCE: =20 - if (EtagStr !=3D NULL) { - FreePool (EtagStr); - } - if (NewResourceLocation !=3D NULL) { FreePool (NewResourceLocation); } @@ -495,6 +499,8 @@ RELEASE_RESOURCE: FreePool (Json); } =20 + RedfishHttpFreeResponse (&Response); + return Status; } =20 @@ -537,10 +543,11 @@ ProvisioningComputerSystemExistResource ( IN REDFISH_RESOURCE_COMMON_PRIVATE *Private ) { - EFI_STATUS Status; - EFI_STRING ConfigureLang; - CHAR8 *Json; - CHAR8 *JsonWithAddendum; + EFI_STATUS Status; + EFI_STRING ConfigureLang; + CHAR8 *Json; + CHAR8 *JsonWithAddendum; + REDFISH_RESPONSE Response; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -548,6 +555,7 @@ ProvisioningComputerSystemExistResource ( =20 Json =3D NULL; ConfigureLang =3D NULL; + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); =20 ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); if (ConfigureLang =3D=3D NULL) { @@ -608,15 +616,17 @@ ProvisioningComputerSystemExistResource ( DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for %s\= n", __func__, ConfigureLang)); =20 // - // PUT back to instance + // PATCH back to instance // - Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, NULL); + Status =3D RedfishHttpPatchResource (Private->RedfishService, Private->U= ri, Json, &Response); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func_= _, ConfigureLang, Status)); } =20 ON_RELEASE: =20 + RedfishHttpFreeResponse (&Response); + if (Json !=3D NULL) { FreePool (Json); } @@ -736,10 +746,11 @@ RedfishUpdateResourceCommon ( IN CHAR8 *InputJson ) { - EFI_STATUS Status; - CHAR8 *Json; - CHAR8 *JsonWithAddendum; - EFI_STRING ConfigureLang; + EFI_STATUS Status; + CHAR8 *Json; + CHAR8 *JsonWithAddendum; + EFI_STRING ConfigureLang; + REDFISH_RESPONSE Response; =20 if ((Private =3D=3D NULL) || IS_EMPTY_STRING (InputJson)) { return EFI_INVALID_PARAMETER; @@ -747,6 +758,7 @@ RedfishUpdateResourceCommon ( =20 Json =3D NULL; ConfigureLang =3D NULL; + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); =20 ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); if (ConfigureLang =3D=3D NULL) { @@ -807,15 +819,17 @@ RedfishUpdateResourceCommon ( DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __func__, C= onfigureLang)); =20 // - // PUT back to instance + // PATCH back to instance // - Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, NULL); + Status =3D RedfishHttpPatchResource (Private->RedfishService, Private->U= ri, Json, &Response); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func_= _, ConfigureLang, Status)); } =20 ON_RELEASE: =20 + RedfishHttpFreeResponse (&Response); + if (Json !=3D NULL) { FreePool (Json); } diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerS= ystemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerS= ystemDxe.c index 174a8176a..1235760a1 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDx= e.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_13_0/Dxe/ComputerSystemDx= e.c @@ -51,7 +51,7 @@ RedfishResourceProvisioningResource ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -74,16 +74,8 @@ RedfishResourceProvisioningResource ( // // Release resource // - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - Private->Payload =3D NULL; - } - + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; return Status; } =20 @@ -123,7 +115,7 @@ RedfishResourceConsumeResource ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -175,27 +167,9 @@ RedfishResourceConsumeResource ( // // Release resource // - if (Private->Payload !=3D NULL) { - if (Response.Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - } - - if (PendingSettingResponse.Payload !=3D NULL) { - RedfishFreeResponse ( - PendingSettingResponse.StatusCode, - PendingSettingResponse.HeaderCount, - PendingSettingResponse.Headers, - PendingSettingResponse.Payload - ); - } - - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + RedfishHttpFreeResponse (&PendingSettingResponse); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -269,7 +243,7 @@ RedfishResourceUpdate ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -295,16 +269,8 @@ RedfishResourceUpdate ( // // Release resource // - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - RedfishHttpResetResource (Uri); - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -347,7 +313,7 @@ RedfishResourceCheck ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -377,15 +343,8 @@ RedfishResourceCheck ( FreePool (Etag); } =20 - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -428,7 +387,7 @@ RedfishResourceIdentify ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -449,15 +408,8 @@ RedfishResourceIdentify ( // // Release resource // - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -539,11 +491,6 @@ RedfishResourceStop ( Private->RedfishService =3D NULL; } =20 - if (Private->Payload !=3D NULL) { - RedfishCleanupPayload (Private->Payload); - Private->Payload =3D NULL; - } - return EFI_SUCCESS; } =20 diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Compute= rSystemCommon.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/Co= mputerSystemCommon.c index 11bcb5f76..c383cad59 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystem= Common.c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Common/ComputerSystem= Common.c @@ -2,7 +2,7 @@ Redfish feature driver implementation - common functions =20 (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -1277,18 +1277,18 @@ ProvisioningComputerSystemResource ( IN EFI_STRING ConfigureLang ) { - CHAR8 *Json; - CHAR8 *JsonWithAddendum; - EFI_STATUS Status; - EFI_STRING NewResourceLocation; - CHAR8 *EtagStr; - CHAR8 ResourceId[16]; + CHAR8 *Json; + CHAR8 *JsonWithAddendum; + EFI_STATUS Status; + EFI_STRING NewResourceLocation; + CHAR8 ResourceId[16]; + REDFISH_RESPONSE Response; =20 if (IS_EMPTY_STRING (ConfigureLang) || (Private =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 - EtagStr =3D NULL; + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); AsciiSPrint (ResourceId, sizeof (ResourceId), "%d", Index); =20 Status =3D ProvisioningComputerSystemProperties ( @@ -1336,27 +1336,31 @@ ProvisioningComputerSystemResource ( JsonWithAddendum =3D NULL; } =20 - Status =3D CreatePayloadToPostResource (Private->RedfishService, Private= ->Payload, Json, &NewResourceLocation, &EtagStr); + Status =3D RedfishHttpPostResource (Private->RedfishService, Private->Ur= i, Json, &Response); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: post ComputerSystem resource for %s failed: = %r\n", __func__, ConfigureLang, Status)); + DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", __f= unc__, ConfigureLang, Status)); goto RELEASE_RESOURCE; } =20 - ASSERT (NewResourceLocation !=3D NULL); + // + // Per Redfish spec. the URL of new resource will be returned in "Locati= on" header. + // + Status =3D GetHttpResponseLocation (&Response, &NewResourceLocation); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: cannot find new location: %r\n", __func__, S= tatus)); + goto RELEASE_RESOURCE; + } =20 // // Keep location of new resource. // if (NewResourceLocation !=3D NULL) { + DEBUG ((DEBUG_MANAGEABILITY, "%a: Location: %s\n", __func__, NewResour= ceLocation)); RedfishSetRedfishUri (ConfigureLang, NewResourceLocation); } =20 RELEASE_RESOURCE: =20 - if (EtagStr !=3D NULL) { - FreePool (EtagStr); - } - if (NewResourceLocation !=3D NULL) { FreePool (NewResourceLocation); } @@ -1365,6 +1369,8 @@ RELEASE_RESOURCE: FreePool (Json); } =20 + RedfishHttpFreeResponse (&Response); + return Status; } =20 @@ -1407,10 +1413,11 @@ ProvisioningComputerSystemExistResource ( IN REDFISH_RESOURCE_COMMON_PRIVATE *Private ) { - EFI_STATUS Status; - EFI_STRING ConfigureLang; - CHAR8 *Json; - CHAR8 *JsonWithAddendum; + EFI_STATUS Status; + EFI_STRING ConfigureLang; + CHAR8 *Json; + CHAR8 *JsonWithAddendum; + REDFISH_RESPONSE Response; =20 if (Private =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -1418,6 +1425,7 @@ ProvisioningComputerSystemExistResource ( =20 Json =3D NULL; ConfigureLang =3D NULL; + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); =20 ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); if (ConfigureLang =3D=3D NULL) { @@ -1478,15 +1486,17 @@ ProvisioningComputerSystemExistResource ( DEBUG ((DEBUG_MANAGEABILITY, "%a: provisioning existing resource for %s\= n", __func__, ConfigureLang)); =20 // - // PUT back to instance + // PATCH back to instance // - Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, NULL); + Status =3D RedfishHttpPatchResource (Private->RedfishService, Private->U= ri, Json, &Response); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func_= _, ConfigureLang, Status)); } =20 ON_RELEASE: =20 + RedfishHttpFreeResponse (&Response); + if (Json !=3D NULL) { FreePool (Json); } @@ -1606,10 +1616,11 @@ RedfishUpdateResourceCommon ( IN CHAR8 *InputJson ) { - EFI_STATUS Status; - CHAR8 *Json; - CHAR8 *JsonWithAddendum; - EFI_STRING ConfigureLang; + EFI_STATUS Status; + CHAR8 *Json; + CHAR8 *JsonWithAddendum; + EFI_STRING ConfigureLang; + REDFISH_RESPONSE Response; =20 if ((Private =3D=3D NULL) || IS_EMPTY_STRING (InputJson)) { return EFI_INVALID_PARAMETER; @@ -1617,6 +1628,7 @@ RedfishUpdateResourceCommon ( =20 Json =3D NULL; ConfigureLang =3D NULL; + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); =20 ConfigureLang =3D RedfishGetConfigLanguage (Private->Uri); if (ConfigureLang =3D=3D NULL) { @@ -1677,15 +1689,17 @@ RedfishUpdateResourceCommon ( DEBUG ((REDFISH_DEBUG_TRACE, "%a: update resource for %s\n", __func__, C= onfigureLang)); =20 // - // PUT back to instance + // PATCH back to instance // - Status =3D CreatePayloadToPatchResource (Private->RedfishService, Privat= e->Payload, Json, NULL); + Status =3D RedfishHttpPatchResource (Private->RedfishService, Private->U= ri, Json, &Response); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: patch resource for %s failed: %r\n", __func_= _, ConfigureLang, Status)); } =20 ON_RELEASE: =20 + RedfishHttpFreeResponse (&Response); + if (Json !=3D NULL) { FreePool (Json); } diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSy= stemDxe.c b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSys= temDxe.c index 174a8176a..5207362da 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .c @@ -51,7 +51,7 @@ RedfishResourceProvisioningResource ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -74,15 +74,8 @@ RedfishResourceProvisioningResource ( // // Release resource // - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; =20 return Status; } @@ -123,7 +116,7 @@ RedfishResourceConsumeResource ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -175,27 +168,9 @@ RedfishResourceConsumeResource ( // // Release resource // - if (Private->Payload !=3D NULL) { - if (Response.Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - } - - if (PendingSettingResponse.Payload !=3D NULL) { - RedfishFreeResponse ( - PendingSettingResponse.StatusCode, - PendingSettingResponse.HeaderCount, - PendingSettingResponse.Headers, - PendingSettingResponse.Payload - ); - } - - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + RedfishHttpFreeResponse (&PendingSettingResponse); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -269,7 +244,7 @@ RedfishResourceUpdate ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -295,16 +270,8 @@ RedfishResourceUpdate ( // // Release resource // - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - RedfishHttpResetResource (Uri); - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -347,7 +314,7 @@ RedfishResourceCheck ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -377,15 +344,8 @@ RedfishResourceCheck ( FreePool (Etag); } =20 - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -428,7 +388,7 @@ RedfishResourceIdentify ( } =20 ZeroMem (&Response, sizeof (Response)); - Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, NULL, &= Response, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -449,15 +409,8 @@ RedfishResourceIdentify ( // // Release resource // - if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); - Private->Payload =3D NULL; - } + RedfishHttpFreeResponse (&Response); + Private->Payload =3D NULL; =20 if (Private->Json !=3D NULL) { FreePool (Private->Json); @@ -539,11 +492,6 @@ RedfishResourceStop ( Private->RedfishService =3D NULL; } =20 - if (Private->Payload !=3D NULL) { - RedfishCleanupPayload (Private->Payload); - Private->Payload =3D NULL; - } - return EFI_SUCCESS; } =20 --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116150): https://edk2.groups.io/g/devel/message/116150 Mute This Topic: https://groups.io/mt/104640233/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-