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 16C85D811AC for ; Mon, 8 Jan 2024 14:46:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=X6oO5z8BUcgeVsRVkzRuohKQNxWLd3GCQTTW/OpvgaQ=; 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=1704725175; v=1; b=DZ/kQ9K2g113xhnw1NSNU+i1/zcGyt+Kf7yZ1jXTMvbpc2YEFAc0E669lUB+fZuBCfKsJlQZ LIfQn78H/XwoRUfNThXTDZv4EXpJ1M29FNKYs0EfIOLlPI1cJae9GUTQYp3se8BxW7X/tuphXg8 K1jP3YbrZnuaDvksMYM+D6Cs= X-Received: by 127.0.0.2 with SMTP id dh01YY7687511xRhUfYFMT7g; Mon, 08 Jan 2024 06:46:15 -0800 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.51]) by mx.groups.io with SMTP id smtpd.web11.8454.1704725174761833616 for ; Mon, 08 Jan 2024 06:46:15 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DrQ0pXYig6voZgHLkrsQtWcrhM30szPDO5AUwqSMm5wMyWu4VBb62s3h9oJs1rusqvAcQ9WcIkqPlw6LMiaXHMP0aOXUWxyc8SsFWLQmp7c4N5z76tSJ05rMOD+WdBpveEEVz5Y9fu9Q49/stPGaKK3UXPAG0acqsStozE20aTPpn98eCsCsq4GMOPQKnJgshAXhMelCe43PZWDwe7TaSLWPkSECmfgd3tUZbTh1+m8H3I2kiIETxh8U9kvJgOgEniNzzSameKY+oYensnrAt5ZEuP/jLtxAwMDOD7RF3jnMrOsi2NqB+XJCIO7KrDtljROYSmDEsjetngDhGSN3Rg== 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=xvfSJQjF9nkiFGBBD7Bk7EbOQevA8Mlxnvy5JzILXBs=; b=Xl9KkF662cm3Ze97ODL/D9eSLPnpgO9+eoJHQ6u/Oi8h1Pj7o1wRr13wWCUqjREHXX3bZSqAd79IOQVFL8smqqavPMwUrFNfCRGYDsML8+zSDFH216CCDSMbLRpCWSOt+xkkG4fA1TUXS2Kz8VvGOpdPhOffC8x8keYIsAjYgzUCDck6VkVEXh+o3Se2EX3bklUN9wiD2UK9CPLRpuUpgCMVYH27tRRGiydp57dxOmOA/EJXUvAArmDq/lhlKnBc3EEGLhbz5DgmTtTqYRSMf6o6bcUTS1aMGUW0OXdP40AENcuuP4B5KWzgXOCvGSLySvEm1wAiVk3xFVyXPUGvDw== 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 PH0PR10MB5777.namprd10.prod.outlook.com (2603:10b6:510:128::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.21; Mon, 8 Jan 2024 14:46:11 +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.020; Mon, 8 Jan 2024 14:46:11 +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 V4] RedfishClientPkg: Add ETag PCD and revise Redfish ETag functions Thread-Topic: [EXTERNAL] [edk2-redfish-client][PATCH V4] RedfishClientPkg: Add ETag PCD and revise Redfish ETag functions Thread-Index: AQHaQd1QZrc5LtTcCkawr9MltwHz9LDP/xcQ Date: Mon, 8 Jan 2024 14:46:10 +0000 Message-ID: References: <20240108024913.9-1-abner.chang@amd.com> In-Reply-To: <20240108024913.9-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_|PH0PR10MB5777:EE_ x-ms-office365-filtering-correlation-id: ff237fcf-b5c7-4f66-33c5-08dc10588e4a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: u2IQpk4OnZYJVPW3mmqUnTLyjer2HCT8Mr9EoX4H6cXRpRA4AXHT3SbQMXFjMS5rJg/hVXkkXNxLHFefT65qaQZQ0v0XHudwaECqmZmxn0anHkY3DM9tbbWxp4K0W7rGFSXcQKgHV0cX22N5t3l4ccZROxb7Mfj0ZNXnCKLZDXpqd28AjOB9cwSs4VN3gttx5uAYq/EFU9pnArx+OjDubHQFZAM+8kcbZJpECCJfpfUl2otk4Jw0ak9671cGnBf2Z39xoSaLBuc3ErSNNQ4WU5zRwq8zVUoz1qDLlKNlvlcFNO7M65lW0Sl1GavH+9TXcIGeEOe64hxhOcgsaNYwDVhLL+H+jpRa/2wXlAzMoO7EGufhJIuXgV3E8LcdweUz0cZ5J3RcmPzwUtqJ80mhZypaChKql5z//cRdr2Icmpy3kEqhbnYRc/EOTXxx2gWS9mYAYYYhCNS108u9Y2TsQrvA26rYTylo6pKRDguknb37GzCML4nzgaNA5SyZOnzxY+JkvN7e7c2XmD8Be8B6Z+w2BRTx3G8ZiD7AIRpnFuQh0V/wuDeo81mJazDY35kjan0pxJcRNzu+KXlxRUFdSAo2ifUYkIKw7YNWTTQcY8Mli22tg7qj/1zYcPgW6LjJLDXIc1boerYbMJY/7dyeM//0yWy5hCnwgdYXLNYM6FE= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?TQZQOZ70fogouycXZHeUXUmww2/EYr7sONvzNTkvDktslFW8eQ8yA9RxCNzd?= =?us-ascii?Q?+xX478caP3FG3i04GHsBtpick2j89CnAlLHKxaQAZ22DizJYH4CxsHz7D4pB?= =?us-ascii?Q?ayNNGPNhSybpV63WvIrNkKXHsqfbLG42j9ChxRf1lJDvsfe4JXDT/WauYfvD?= =?us-ascii?Q?6tgTfhWOiCLCF601sQHgZkoTbG6KOwuND+3icZ75ew//zMZ1vNf31Gi8PW9u?= =?us-ascii?Q?xz8bqNQT0PdFQ3k9kMrPvBCCr8Tmwb8F4ivjjAAwjH1pLqJ5LxAnXpjw/JzM?= =?us-ascii?Q?EyIHxbgV2Gt0t5w/P6CER3aqxWOgSpQO9fFVS25wU5ZbRPQKHaQ12BzIsnjl?= =?us-ascii?Q?azovw9YP2cjFbJ25CSasdW+kIV/jPVQttctaNzY8/VTCpp4MYMRfn2QQyVnW?= =?us-ascii?Q?QVnxSgZZijmgtNe+uED9FwDtKmorqqnCMA9wKqCps03AlLOFlKl3dACdzvij?= =?us-ascii?Q?z/uEABm0SiflvDo1OzcAWL2NoE2Jt4MwVHXStyZSebbbZcZ1hk5JTk6okIEK?= =?us-ascii?Q?Q9L2bPRQ2zhAJVlMgGZKi5LtozSqyYkzC2+nGe7+HgyWSqdFKusDzC82cLVo?= =?us-ascii?Q?/53bI2VWzoUazAYTyc96ifKTiWOowaYXFccfaaJOs5tBCOnSnR8Qb9Y4gxQi?= =?us-ascii?Q?cgkx4LHXz8/+1Fbx+jos4XAtNVeJqsu4f3G7ZmkoL6W8LShsluxaLYXsacOq?= =?us-ascii?Q?G4J40w+112IYN9AXF7AR3ldjPnXlWhjJ6ovVF/KzyQXEynrcY+EEpIpWdIn7?= =?us-ascii?Q?7sArxh/SGVDklnwAYk7h8l8Y5YcAueTCn7Q0yC365eU2HGZ4LozG8RaE1g1X?= =?us-ascii?Q?MSMaqewT1o4sTqFRyHi00QpqyEzsnhbxd4h9QQ/Z1ZHEig5AizUlEXAeIi4Q?= =?us-ascii?Q?d4JvaSMS0bL32YBt16N+H8I+yNGShQ7BFk1bqrn5UxdfIRWkKNLyN/fkUr6S?= =?us-ascii?Q?hHpI0nxXKYsO3hB8UTcCSDzjwCT7rtzsbVV3lLkQGDMe4vGW4zpvxtvTs5TE?= =?us-ascii?Q?urpQWzBUnOYWUvb2XHkZp7WTDKu5jS9uOIhGWu+0dSqr1VFbx+OAnVfl5qUo?= =?us-ascii?Q?R9dTpTyFR5MwEE9VjxRvhBI5OPYgW6Ymr7QrtIfuNPnNH7Xaj3o/tZmBXElq?= =?us-ascii?Q?xpIIk4kFtdyxamQFP+gHRUP/uBkAnsTCoHPMcFtC9v6wuc4E3eQh8KbzQjVz?= =?us-ascii?Q?SD06H5jr6S0FdFIgQAmZhgkpH3A9rpTNUWNegehF+BwzSmqeYSjrhvCoexqu?= =?us-ascii?Q?3AfzsQ4RH9eJLUQgEpp/ZiVTvsHjg6pivW0aTvTkEWAIsuEjbMBqYL4Ca/On?= =?us-ascii?Q?0v74oAUdlQnek9zpoSKRZM+rPV8PdOUIgnWG2m47r01vgYg6VY3szYGYkFc2?= =?us-ascii?Q?bz15ShN2fr5C7Vkm83L9cYOPrW6CViGE20j/fqIsJcmfrMX4TVZkT+cgOIvt?= =?us-ascii?Q?ehYTphWK4lgc+4msmzAoszXuKx4tGAeVHOd19Cx9ptQcaOP91NSlLXCBty9w?= =?us-ascii?Q?ho4od5p9mnjf21KUB+2R76pSqbPz3kQnZBwVWV1/OCbIAp1HC5BHoDp/xoIQ?= =?us-ascii?Q?eZnN3r5k7O4Kby7lakg=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: ff237fcf-b5c7-4f66-33c5-08dc10588e4a X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2024 14:46:10.9808 (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: GaXsz9BvdWx4mPUZaxFufSqcVBIuQWQaZjBRAwKSk6/FTXfFbcW7ZW7OV0X8WQ+X X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5777 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: aRIxQmWPJdfeupheUTrmROgdx7686176AA= 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="DZ/kQ9K2"; 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}") Reviewed-by: Igor Kulchytskyy Regards, Igor -----Original Message----- From: abner.chang@amd.com Sent: Sunday, January 07, 2024 9:49 PM To: devel@edk2.groups.io Cc: Nickle Wang ; Igor Kulchytskyy ; Mik= e Maslenkin Subject: [EXTERNAL] [edk2-redfish-client][PATCH V4] 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..aa723264e8 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 Location pro= perty 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 property fr= om 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 Location pro= erty 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 (#113399): https://edk2.groups.io/g/devel/message/113399 Mute This Topic: https://groups.io/mt/103590679/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-