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 18874D8042B for ; Thu, 4 Jan 2024 14:58:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=FHkrPgtTnB5cLcfV88MMBYqhu3CEJP6FCCl9CKdLhY4=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1704380333; v=1; b=mLGL62ZNTviICELYMDA9aAsRuyG9SkwHq6gGLsZyiqD5vDdwX9Y+QE8yRAM26G0hDE45+3nO 4sqU6ffTKHTA5Gt1UD8YDCPppxxbjskoMlPXmY5IJt6mz7QIiiucLQvZivaAyR1JQNGROArFons m++QM1Lfx6m+rOgBsYWS/0DU= X-Received: by 127.0.0.2 with SMTP id trOYYY7687511x8u5ciVNs3C; Thu, 04 Jan 2024 06:58:53 -0800 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.66]) by mx.groups.io with SMTP id smtpd.web11.55773.1704380332721308965 for ; Thu, 04 Jan 2024 06:58:52 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fN9/YE6BlGWM8idIQY2IoOr/hBGuRybni8JZkJpsgVDySMg/BRdRobWJlpf6TYmJl9iOtXDrZtaGSvoCLHg3RLtifRRwTJKx6Ov3oHNWa01JyQeCEnCEIqALTgX876584KuCrtBAtiP38D0L36ZzOm94tuISLTRr53l83tpkG4dXunUxoSgKXUEO2Qk6GQr7HJJAtBeTlAIRKZBZCM9FFsl1h7BGyVhwHbUDBTxiHyqlGJ64gOcu6hYhyrnzzdEg73pUPRRuNpViNfiFSO74eyUpeClajbF2J+3IGIDhPpzWh901ZYWiICJSfjU+Ib19j0k7ozERpmWG+IZqEJEtGw== 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=ynBp+QGPTJSR6GYzNKXkw+m4rY4xzvndafT8fpJELDk=; b=SVCdnid0Rn54XLOToNKQTr1aCKBGmU9ChJPnZjf8g0PGJPzxjU7KhpoYww2cZkMwhX45yD8FI7mvV5rvDUXh5td2qiTuQCgphZ8WHqZ40I7LhItQOmKE2wL5li0ON1i/MDuibHmXDuNaNy/Ocr50no4fGyFBESLwp3ifuYycUa3T/DNzacxx3JgmlOvn7GiFMmFgMW3wUtqplCo5acmqAIB/e0+TLQorj1AXMvv1jIc/JXos66MlNi5N6KwL5z8O9oHoyV6NrEDGx7U5G6AO8P0oX+Zg6b5hmAlAFL0sGUuQdHw2yHdfKEZLxYOi5nQ0YYpPLxG1xFEOXpJnacK8uw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by SJ2PR10MB7825.namprd10.prod.outlook.com (2603:10b6:a03:56e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.16; Thu, 4 Jan 2024 14:58:47 +0000 X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::9dc0:d4e1:1d40:3e33]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::9dc0:d4e1:1d40:3e33%5]) with mapi id 15.20.7159.015; Thu, 4 Jan 2024 14:58:47 +0000 From: "Igor Kulchytskyy via groups.io" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Nickle Wang , Mike Maslenkin Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH V3] RedfishClientPkg: Add ETag PCD and revise Redfish ETag functions Thread-Topic: [EXTERNAL] [edk2-redfish-client][PATCH V3] RedfishClientPkg: Add ETag PCD and revise Redfish ETag functions Thread-Index: AQHaPu23T2WssRNBUky7AzsCmisLSbDJvYWg Date: Thu, 4 Jan 2024 14:58:47 +0000 Message-ID: References: <20240104090901.1624-1-abner.chang@amd.com> In-Reply-To: <20240104090901.1624-1-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|SJ2PR10MB7825:EE_ x-ms-office365-filtering-correlation-id: d633bb0c-a87e-42de-d2b4-08dc0d35a789 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 8JKkIE3eB5ADZpgOVcDn7H4N5f0mycQ0I6d5iXMCpQuMNzbN/kDRVsFxlkprqpa0eEQGaqVwto4cSrKStX+6VW//3FY6U2xklsS2nEmoqVsjQfrrb7ywdwlrSyV8vMZcBv1qE6wlB8ER5qbEOIrDtjIGMSWhz42paP6pcc/QgjBOdZyvfb0VX6Ygh8++uqHHRWZg6EW323hQ3nnWBLjBzpMkPyXS2T6wV9VtlwV7pCElBXVRo7bPHdNGSw8lBNAwJOcZwy4gWu9L0VmYMHexrFjbSgFOAVJBbusgbusfRgEdDBDdWLcMXp2qxlHW+9sd3+BoJm7T4Gl2GDvJol6M2m0SXnkTAJuPYUW9TBKPg4WUKLjPxIUh3E+wTcpmm1xzzdkIseBoFsk9NYuCov9KmtWPK7aggCuhCTPdZf7igUHFZO0KRROFUYyo1zZmzOY4++rzFoZZy/r+VAH6HVx8lE0V8wRwEJyWsuyHHU4FGAeMA+1zoLIX45ZIZ9yNm51pOYn4kegpdOoc735s6i0UaOFrUuspFl0ucdeVVCQraMWTBpIBso0dlxB+Ia70rsUg142QCRfY/5DjQdnqQ1DJhLipzeturzEnxYXj/bYzVEnjGqcHj1Uf5qSlnhtcJnG2aDjiZvFo5LLIv6DlfKjwPw/lzRvQs1lVXSQf+wbOSXY= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Iysyaf5h+xWDT3PNqPF3lLSRzgOJiHzK+/+E3kIrnCqLZa8n03RIrYl/OZK1?= =?us-ascii?Q?DYvm91cVmAnifdpA4cvK9n88xinCANNgoD9Yz6cf2rnj0F5J0M1IbIwhC8YF?= =?us-ascii?Q?b0hEeFvXUpOWwO8ZnNnOK1VmLzwyseUObW83kqeqdS0X4TXbWOslaLuqO5xv?= =?us-ascii?Q?whIvmxl6sBrYmIsI9RUTn88VNI37iaZUSu9nxjil3PL/EDi+D4+g2NYggoGs?= =?us-ascii?Q?E1YmzcpRiQ/p37KbD/vYhsE7uyVUb4X8+M29cjwsTS427Q4C2CysXulh+QO+?= =?us-ascii?Q?pO41XofetG76Kafw/LFD+s6RF3nircPYXYNlNswXQNUu4AvJxHBdUFis7ljR?= =?us-ascii?Q?hd8yqQT2LswnvccgqiJRo2x1SQr9Aj0I/q1dxZwPDhToUmDQQo/dsZRzI89/?= =?us-ascii?Q?T3om3ggdAP8UA5CGQskarkaauxggV3UgeuhxUcVBf9YrT0PUUqPqh69ZJ2Ui?= =?us-ascii?Q?M83NLfhvoQUCHc0OE5bugzzk9MfEFneLd/pjZG4m6KdQjB4/HY1zF84tcAfC?= =?us-ascii?Q?lN8z+CA8wUFvOslDoektGK7wYdHNpz+tUbPtB7IA6B1YjG7IpRcjKh1VlEBf?= =?us-ascii?Q?8GWOPlAvjiSfJmjhPpq2pPLZhdG7VBf2lihODMOI0WPKj2uf+AEHh4570L8U?= =?us-ascii?Q?8Tefckl4wjTGHipD7YWMC5H5FFZZXoWZpNEtQmV532MP5fwWhBHmboEr5ajd?= =?us-ascii?Q?XcyJHNb5evzf6Bn3sMb1SQ/8cl0k37Z6JQ+esugpVYO95En7wslZYAQ7iVx2?= =?us-ascii?Q?k40HylWuHgQmS4AFnpy9RO+w30QHK3/n16B3Ykev+QR+6H35lIimEMAhdKai?= =?us-ascii?Q?zAu+OknEbtaevLrzd8EYEi7ERhmv1VKNqjgJsea8FfeRnr4X4NxfAXudag63?= =?us-ascii?Q?TFIFZ6eXPzZONocTSESveWmr1YP6Dn/WcF//jWr0QXA5sbdUcVnUtDsbz0AM?= =?us-ascii?Q?tnYH7FrCrkQFaenrnNAvM1MFmGbzEidsc56a+BbmizPdS9iDPvt6vPKBG/y/?= =?us-ascii?Q?RXIZUndCmUiLMG+3dtXbO+jMXB+6XFeYrVcxKCE0db+B401rxwJnEcaCcBTJ?= =?us-ascii?Q?88r4ZtAZ64PaT8k766osXNGxiHknmGXkCcyWsQYhiSMmLybvahSRR10UAWdx?= =?us-ascii?Q?ZwKQKfA7rFytb9ZespLBVtV1tib4IQxXir5f83ZucfrTdFdSE5jgMX/ouIhi?= =?us-ascii?Q?rZKpiZgsM/d9UL7XvqN8nD9Z6nl0VzNzwpjm0hGQCQp58FF1Zi1wa84/bBvc?= =?us-ascii?Q?goQ2B9e25JuqKUPUOxtspDZeRxT99Zp15Xe8wV5sPBgSivcbV4jFCJjEWffw?= =?us-ascii?Q?jnTzu1MxPViZd+q6/7p381Ct3IIpRzItjeg7oscU001hbNyvEkDC79qJzGTg?= =?us-ascii?Q?BKMvLIbxEnyQSTwqg2uPWov4U6YOI8OtWnSU76ZnhyINmXnutO2PEt2Qfkv2?= =?us-ascii?Q?B8CazH7f7pBL77vsABTOqd1/wYe6uZeMPiR/CUwfiePkxfaPPzs+/27Txm4q?= =?us-ascii?Q?AZprEUtT3FOf0scIJDtp+tccpBLpqi1MtEAV+e/CwgN9DoV3E60YQB1Btgml?= =?us-ascii?Q?/BRD91TFSNG191PtcuY=3D?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d633bb0c-a87e-42de-d2b4-08dc0d35a789 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2024 14:58:47.4791 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wn3dhGrxQTchVZCHvAX6iLb9L0hAUIG950xM4r1kY2LSnWPpfVKSzWRZ8XbEm2gy X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7825 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,igork@ami.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: tfM2zmRjVeTRJFDUtf336C5Kx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=mLGL62ZN; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Hi Abner, Some small correction in comments syntax (see below). Thank you, Igor -----Original Message----- From: abner.chang@amd.com Sent: Thursday, January 4, 2024 4:09 AM To: devel@edk2.groups.io Cc: Nickle Wang ; Igor Kulchytskyy ; Mik= e Maslenkin Subject: [EXTERNAL] [edk2-redfish-client][PATCH V3] RedfishClientPkg: Add E= Tag PCD and revise Redfish ETag functions **CAUTION: The e-mail below is from an external source. Please exercise cau= tion before opening attachments, clicking links, or following guidance.** From: Abner Chang Add PCD to disable ETag capability for the case Redfish service doesn't support ETag. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Cc: Mike Maslenkin --- RedfishClientPkg/RedfishClientPkg.dec | 3 + .../RedfishFeatureUtilityLib.inf | 2 + .../Library/RedfishFeatureUtilityLib.h | 47 +++- .../Features/Bios/v1_0_9/Dxe/BiosDxe.c | 19 +- .../v1_0_4/Common/BootOptionCommon.c | 5 +- .../BootOption/v1_0_4/Dxe/BootOptionDxe.c | 17 +- .../v1_5_0/Dxe/ComputerSystemDxe.c | 13 +- .../Features/Memory/V1_7_1/Dxe/MemoryDxe.c | 17 +- .../RedfishFeatureUtilityLib.c | 209 ++++++++++++------ 9 files changed, 204 insertions(+), 128 deletions(-) diff --git a/RedfishClientPkg/RedfishClientPkg.dec b/RedfishClientPkg/Redfi= shClientPkg.dec index b350facae0..ce3b6d9752 100644 --- a/RedfishClientPkg/RedfishClientPkg.dec +++ b/RedfishClientPkg/RedfishClientPkg.dec @@ -3,6 +3,7 @@ # # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -76,6 +77,8 @@ gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID*|= 0x10000004 ## The number of seconds that the firmware will wait before system reboo= t gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout|5|UINT1= 6|0x20000002 + ## Default capability of Redfish service side ETAG support + gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishServiceEtagSupported|TRUE|B= OOLEAN|0x10000005 [PcdsDynamicEx] ## The flag used to indicate that system reboot is required due to syste= m configuration change diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.inf b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/Redfis= hFeatureUtilityLib.inf index 718273b248..63330c8e9d 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.inf @@ -3,6 +3,7 @@ # # (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights re= served. +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -54,6 +55,7 @@ [Pcd] gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired + gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishServiceEtagSupported [Guids] diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h b/= RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h index 9513a65617..0f8aede5c4 100644 --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h @@ -3,6 +3,7 @@ (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -81,7 +82,7 @@ CopyConfiglanguageList ( /** - Get number of node from the string. Node is seperated by '/'. + Get number of node from the string. Node is separated by '/'. @param[in] NodeString The node string to parse. @@ -559,6 +560,19 @@ GetEtagWithUri ( IN EFI_STRING Uri ); +/** + + This function returns a boolean of ETAG support on Redfish service side. + + @retval TRUE ETAG is supported on Redfish service. + @retval FALSE ETAG is not supported on Redfish service. + +**/ +BOOLEAN +CheckIsServerEtagSupported ( + VOID + ); + /** Get @odata.id from give HTTP payload. It's call responsibility to releas= e returned buffer. @@ -931,22 +945,33 @@ CompareRedfishPropertyVagueValues ( ); /** + Find "ETag" from either HTTP header or Redfish response. - Find "ETag" and "Location" from either HTTP header or Redfish response. + @param[in] Response HTTP response + @param[out] Etag String buffer to return ETag - @param[in] Response HTTP response - @param[out] Etag String buffer to return ETag - @param[out] Location String buffer to return Location + @retval EFI_SUCCESS ETag is returned in Etag + @retval EFI_UNSUPPORTED ETag is unsupported + @retval EFI_INVALID_PARAMETER Response, Etag or both are NULL. - @retval EFI_SUCCESS Data is found and returned. - @retval Others Errors occur. +**/ +EFI_STATUS +GetHttpResponseEtag ( + IN REDFISH_RESPONSE *Response, + OUT CHAR8 **Etag + ); + +/** + Find "Location" from either HTTP header or Redfish response. + + @param[in] Response HTTP response + @param[out] Location String buffer to return Location **/ EFI_STATUS -GetEtagAndLocation ( - IN REDFISH_RESPONSE *Response, - OUT CHAR8 **Etag, OPTIONAL - OUT EFI_STRING *Location OPTIONAL +GetHttpResponseLocation ( + IN REDFISH_RESPONSE *Response, + OUT EFI_STRING *Location ); /** diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c b/RedfishC= lientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c index 2a49c5cd22..f40f2d85af 100644 --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c @@ -3,6 +3,7 @@ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -153,14 +154,10 @@ RedfishResourceConsumeResource ( ASSERT (Private->Json !=3D NULL); // - // Find etag in HTTP response header + // Searching for etag in HTTP response header // - Etag =3D NULL; - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __fu= nc__)); - } - + Etag =3D NULL; + GetHttpResponseEtag (ExpectedResponse, &Etag); Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { if (Status !=3D EFI_ALREADY_STARTED) { @@ -365,12 +362,8 @@ RedfishResourceCheck ( // // Find etag in HTTP response header // - Etag =3D NULL; - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __fu= nc__)); - } - + Etag =3D NULL; + GetHttpResponseEtag (&Response, &Etag); Status =3D RedfishCheckResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __= func__, Uri, Status)); diff --git a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionC= ommon.c b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionComm= on.c index 0d4c2162c6..0b9f2bf284 100644 --- a/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c +++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Common/BootOptionCommon.c @@ -3,6 +3,7 @@ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -455,9 +456,9 @@ RedfishProvisioningResourceCommon ( } // - // per Redfish spec. the URL of new resource will be returned in "Locati= on" header. + // Per Redfish spec. the URL of new resource will be returned in "Locati= on" header. // - Status =3D GetEtagAndLocation (&Response, NULL, &NewResourceLocation); + 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; diff --git a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.= c b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c index ba090c51d3..dc2bd9da85 100644 --- a/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c +++ b/RedfishClientPkg/Features/BootOption/v1_0_4/Dxe/BootOptionDxe.c @@ -3,6 +3,7 @@ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -154,12 +155,8 @@ RedfishResourceConsumeResource ( // // Find etag in HTTP response header // - Etag =3D NULL; - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __fu= nc__)); - } - + Etag =3D NULL; + GetHttpResponseEtag (ExpectedResponse, &Etag); Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to consume resource from: %s: %r\n", = __func__, Private->Uri, Status)); @@ -358,12 +355,8 @@ RedfishResourceCheck ( // // Find etag in HTTP response header // - Etag =3D NULL; - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __fu= nc__)); - } - + Etag =3D NULL; + GetHttpResponseEtag (&Response, &Etag); Status =3D RedfishCheckResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { DEBUG ((REDFISH_BOOT_OPTION_DEBUG_TRACE, "%a: failed to check resource= from: %s: %r\n", __func__, Uri, Status)); 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 0bbaa92bf4..5927b5fa7a 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .c @@ -3,6 +3,7 @@ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -150,11 +151,7 @@ RedfishResourceConsumeResource ( // Find etag in HTTP response header // Etag =3D NULL; - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __fu= nc__)); - } - + GetHttpResponseEtag (ExpectedResponse, &Etag); Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { if (Status !=3D EFI_ALREADY_STARTED) { @@ -360,11 +357,7 @@ RedfishResourceCheck ( // Find etag in HTTP response header // Etag =3D NULL; - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __fu= nc__)); - } - + GetHttpResponseEtag (&Response, &Etag); Status =3D RedfishCheckResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __= func__, Uri, Status)); diff --git a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c b/Redf= ishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c index 9230078051..4a6e342879 100644 --- a/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c +++ b/RedfishClientPkg/Features/Memory/V1_7_1/Dxe/MemoryDxe.c @@ -3,6 +3,7 @@ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -149,12 +150,8 @@ RedfishResourceConsumeResource ( // // Find etag in HTTP response header // - Etag =3D NULL; - Status =3D GetEtagAndLocation (ExpectedResponse, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", __fu= nc__)); - } - + Etag =3D NULL; + GetHttpResponseEtag (ExpectedResponse, &Etag); Status =3D RedfishConsumeResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { if (Status !=3D EFI_ALREADY_STARTED) { @@ -359,12 +356,8 @@ RedfishResourceCheck ( // // Find etag in HTTP response header // - Etag =3D NULL; - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __fu= nc__)); - } - + Etag =3D NULL; + GetHttpResponseEtag (&Response, &Etag); Status =3D RedfishCheckResourceCommon (Private, Private->Json, Etag); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, failed to check resource from: %s: %r\n", __= func__, Uri, Status)); diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishF= eatureUtilityLib.c index 1c2d40f622..f767b4d875 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c @@ -3,6 +3,7 @@ (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -133,6 +134,11 @@ SetEtagFromUri ( REDFISH_RESPONSE Response; EFI_STRING PendingSettingUri; + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported\n", __func__)= ); + return EFI_SUCCESS; + } + if ((RedfishService =3D=3D NULL) || IS_EMPTY_STRING (Uri)) { return EFI_INVALID_PARAMETER; } @@ -157,9 +163,9 @@ SetEtagFromUri ( // // Find etag in HTTP response header // - Status =3D GetEtagAndLocation (&Response, &Etag, NULL); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to get ETag from HTTP header\n", __fu= nc__)); + Status =3D GetHttpResponseEtag (&Response, &Etag); + if (EFI_ERROR (Status) && (Status !=3D EFI_UNSUPPORTED)) { + DEBUG ((DEBUG_ERROR, "%a: Failed to get ETag from HTTP header\n", __fu= nc__)); Status =3D EFI_NOT_FOUND; goto ON_RELEASE; } @@ -241,6 +247,11 @@ SetEtagWithUri ( EFI_STATUS Status; CHAR8 *AsciiUri; + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported\n", __func__)= ); + return EFI_SUCCESS; + } + if (IS_EMPTY_STRING (EtagStr) || IS_EMPTY_STRING (Uri)) { return EFI_INVALID_PARAMETER; } @@ -286,6 +297,11 @@ GetEtagWithUri ( return NULL; } + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported\n", __func__)= ); + return NULL; + } + Status =3D RedfishLocateProtocol ((VOID **)&mEtagProtocol, &gEdkIIRedfis= hETagProtocolGuid); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: fail to locate gEdkIIRedfishETagProtocolGuid= : %r\n", __func__, Status)); @@ -1726,44 +1742,39 @@ RedfishFeatureGetUnifiedArrayTypeConfigureLang ( } /** + Find "ETag" from either HTTP header or Redfish response. - Find "ETag" and "Location" from either HTTP header or Redfish response. + @param[in] Response HTTP response + @param[out] Etag String buffer to return ETag - @param[in] Response HTTP response - @param[out] Etag String buffer to return ETag - @param[out] Location String buffer to return Location - - @retval EFI_SUCCESS Data is found and returned. - @retval Others Errors occur. + @retval EFI_SUCCESS ETag is returned in Etag + @retval EFI_UNSUPPORTED ETag is unsupported + @retval EFI_INVALID_PARAMETER Response, Etag or both are NULL. **/ EFI_STATUS -GetEtagAndLocation ( - IN REDFISH_RESPONSE *Response, - OUT CHAR8 **Etag, OPTIONAL - OUT EFI_STRING *Location OPTIONAL +GetHttpResponseEtag ( + IN REDFISH_RESPONSE *Response, + OUT CHAR8 **Etag ) { + EFI_STATUS Status; EDKII_JSON_VALUE JsonValue; EDKII_JSON_VALUE OdataValue; CHAR8 *OdataString; - CHAR8 *AsciiLocation; EFI_HTTP_HEADER *Header; - EFI_STATUS Status; - if (Response =3D=3D NULL) { + if ((Response =3D=3D NULL) || (Etag =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } - if ((Etag =3D=3D NULL) && (Location =3D=3D NULL)) { - return EFI_SUCCESS; - } - Status =3D EFI_SUCCESS; - - if (Etag !=3D NULL) { - *Etag =3D NULL; - + *Etag =3D NULL; + if (!CheckIsServerEtagSupported ()) { + // Don't look for ETAG header or property in this case. + DEBUG ((DEBUG_INFO, "%a: WARNING - No ETag support on Redfish service.= \n", __func__)); + return EFI_UNSUPPORTED; + } else { if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers,= HTTP_HEADER_ETAG); if (Header !=3D NULL) { @@ -1793,51 +1804,94 @@ GetEtagAndLocation ( if (*Etag =3D=3D NULL) { Status =3D EFI_NOT_FOUND; + DEBUG ((DEBUG_ERROR, "%a: Failed to retrieve ETag from HTTP response= paylaod.\n", __func__)); } } - if (Location !=3D NULL) { - *Location =3D NULL; - AsciiLocation =3D NULL; + return Status; +} - if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { - Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers,= HTTP_HEADER_LOCATION); - if (Header !=3D NULL) { - AsciiLocation =3D AllocateCopyPool (AsciiStrSize (Header->FieldVal= ue), Header->FieldValue); - ASSERT (AsciiLocation !=3D NULL); - } +/** + Find "Location" from either HTTP header or Redfish response. + + @param[in] Response HTTP response + @param[out] Location String buffer to return Location + +**/ +EFI_STATUS +GetHttpResponseLocation ( + IN REDFISH_RESPONSE *Response, + OUT EFI_STRING *Location + ) +{ + EFI_STATUS Status; + EDKII_JSON_VALUE JsonValue; + EDKII_JSON_VALUE OdataValue; + CHAR8 *OdataString; + CHAR8 *AsciiLocation; + EFI_HTTP_HEADER *Header; + + if ((Response =3D=3D NULL) || (Location =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_SUCCESS; + *Location =3D NULL; + AsciiLocation =3D NULL; + if (*(Response->StatusCode) =3D=3D HTTP_STATUS_200_OK) { + Header =3D HttpFindHeader (Response->HeaderCount, Response->Headers, H= TTP_HEADER_LOCATION); + if (Header !=3D NULL) { + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (Header->FieldValue= ), Header->FieldValue); + ASSERT (AsciiLocation !=3D NULL); } + } - // - // No header is returned. Search payload for location. - // - if ((*Location =3D=3D NULL) && (Response->Payload !=3D NULL)) { - JsonValue =3D RedfishJsonInPayload (Response->Payload); - if (JsonValue !=3D NULL) { - OdataValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue),= "@odata.id"); - if (OdataValue !=3D NULL) { - OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataValue); - if (OdataString !=3D NULL) { - AsciiLocation =3D AllocateCopyPool (AsciiStrSize (OdataString)= , OdataString); - ASSERT (AsciiLocation !=3D NULL); - } + // + // No header is returned. Search payload for location. + // + if ((*Location =3D=3D NULL) && (Response->Payload !=3D NULL)) { + JsonValue =3D RedfishJsonInPayload (Response->Payload); + if (JsonValue !=3D NULL) { + OdataValue =3D JsonObjectGetValue (JsonValueGetObject (JsonValue), "= @odata.id"); + if (OdataValue !=3D NULL) { + OdataString =3D (CHAR8 *)JsonValueGetAsciiString (OdataValue); + if (OdataString !=3D NULL) { + AsciiLocation =3D AllocateCopyPool (AsciiStrSize (OdataString), = OdataString); + ASSERT (AsciiLocation !=3D NULL); } - - JsonValueFree (JsonValue); } - } - if (AsciiLocation !=3D NULL) { - *Location =3D StrAsciiToUnicode (AsciiLocation); - FreePool (AsciiLocation); - } else { - Status =3D EFI_NOT_FOUND; + JsonValueFree (JsonValue); } } + if (AsciiLocation !=3D NULL) { + *Location =3D StrAsciiToUnicode (AsciiLocation); + FreePool (AsciiLocation); + } else { + Status =3D EFI_NOT_FOUND; + DEBUG ((DEBUG_ERROR, "%a: Failed to retrieve Location from HTTP respon= se paylaod.\n", __func__)); + } + return Status; } +/** + + This function returns a boolean of ETAG support on Redfish service side. + + @retval TRUE ETAG is supported on Redfish service. + @retval FALSE ETAG is not supported on Redfish service. + +**/ +BOOLEAN +CheckIsServerEtagSupported ( + VOID + ) +{ + return FixedPcdGetBool (PcdRedfishServiceEtagSupported); +} + /** Create HTTP payload and send them to redfish service with PATCH method. @@ -1861,7 +1915,7 @@ CreatePayloadToPatchResource ( { REDFISH_PAYLOAD Payload; EDKII_JSON_VALUE ResourceJsonValue; - REDFISH_RESPONSE PostResponse; + REDFISH_RESPONSE PatchResponse; EFI_STATUS Status; if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_STR= ING (Json)) { @@ -1876,8 +1930,8 @@ CreatePayloadToPatchResource ( goto EXIT_FREE_JSON_VALUE; } - ZeroMem (&PostResponse, sizeof (REDFISH_RESPONSE)); - Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PostResponse)= ; + ZeroMem (&PatchResponse, sizeof (REDFISH_RESPONSE)); + Status =3D RedfishPatchToPayload (TargetPayload, Payload, &PatchResponse= ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a:%d Failed to PATCH payload to Redfish service= .\n", __func__, __LINE__)); @@ -1885,7 +1939,7 @@ CreatePayloadToPatchResource ( DEBUG ((DEBUG_ERROR, "%a: Request:\n", __func__)); DumpRedfishPayload (DEBUG_ERROR, Payload); DEBUG ((DEBUG_ERROR, "%a: Response:\n", __func__)); - DumpRedfishResponse (__func__, DEBUG_ERROR, &PostResponse); + DumpRedfishResponse (__func__, DEBUG_ERROR, &PatchResponse); DEBUG_CODE_END (); goto EXIT_FREE_JSON_VALUE; } @@ -1893,16 +1947,20 @@ CreatePayloadToPatchResource ( // // Find ETag // - Status =3D GetEtagAndLocation (&PostResponse, Etag, NULL); - if (EFI_ERROR (Status)) { + Status =3D GetHttpResponseEtag (&PatchResponse, Etag); + if (Status =3D=3D EFI_UNSUPPORTED) { + Status =3D EFI_SUCCESS; + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported on Redfish se= rvice.\n", __func__)); + } else { Status =3D EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor proerty from= HTTP response payload.\n", __func__)); Igor: DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor Location prop= erty from HTTP response payload.\n", __func__)); } RedfishFreeResponse ( - PostResponse.StatusCode, - PostResponse.HeaderCount, - PostResponse.Headers, - PostResponse.Payload + PatchResponse.StatusCode, + PatchResponse.HeaderCount, + PatchResponse.Headers, + PatchResponse.Payload ); EXIT_FREE_JSON_VALUE: @@ -1935,7 +1993,7 @@ CreatePayloadToPostResource ( IN REDFISH_PAYLOAD *TargetPayload, IN CHAR8 *Json, OUT EFI_STRING *Location, - OUT CHAR8 **Etag + OUT CHAR8 **Etag OPTIONAL ) { REDFISH_PAYLOAD Payload; @@ -1943,7 +2001,7 @@ CreatePayloadToPostResource ( REDFISH_RESPONSE PostResponse; EFI_STATUS Status; - if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_STR= ING (Json) || (Location =3D=3D NULL) || (Etag =3D=3D NULL)) { + if ((Service =3D=3D NULL) || (TargetPayload =3D=3D NULL) || IS_EMPTY_STR= ING (Json) || (Location =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } @@ -1970,12 +2028,22 @@ CreatePayloadToPostResource ( goto EXIT_FREE_JSON_VALUE; } + Status =3D GetHttpResponseEtag (&PostResponse, Etag); + if (Status =3D=3D EFI_UNSUPPORTED) { + Status =3D EFI_SUCCESS; + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported on Redfish se= rvice.\n", __func__)); + } else if (EFI_ERROR (Status)) { + Status =3D EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "%a: Fail to get ETAG header nor ETAG propertyfro= m HTTP response payload.\n", __func__)); Igor: DEBUG ((DEBUG_ERROR, "%a: Fail to get ETAG header nor ETAG property fro= m HTTP response payload.\n", __func__)); + } + // // per Redfish spec. the URL of new resource will be returned in "Locati= on" header. // - Status =3D GetEtagAndLocation (&PostResponse, Etag, Location); + Status =3D GetHttpResponseLocation (&PostResponse, Location); if (EFI_ERROR (Status)) { Status =3D EFI_DEVICE_ERROR; + DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor proerty from= HTTP response payload.\n", __func__)); Igor: DEBUG ((DEBUG_ERROR, "%a: Fail to get Location header nor Location property= from HTTP response payload.\n", __func__)); } RedfishFreeResponse ( @@ -3117,6 +3185,11 @@ CheckEtag ( { CHAR8 *EtagInDb; + if (!CheckIsServerEtagSupported ()) { + DEBUG ((DEBUG_INFO, "%a: WARNING - ETAG is not supported, always retur= ns FALSE to consume resource (Performance would be reduced).\n", __func__))= ; + return FALSE; + } + if (IS_EMPTY_STRING (Uri)) { return FALSE; } -- 2.37.1.windows.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission= . -=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 (#113180): https://edk2.groups.io/g/devel/message/113180 Mute This Topic: https://groups.io/mt/103519370/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-