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 E4000D80127 for ; Thu, 4 Jan 2024 02:33:35 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=6e3/IVrBAivfof0XwCesxY3hUjMV38eTwC2hhacLrvk=; 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:msip_labels: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=1704335614; v=1; b=g38PyPJvYVmOtVnpCt5PnCFGEXLbQEzbXJTBSv4lBHq0aPm/Ret1UyKydmEXhVReehPlQbU9 fVFAFr6PTWnlGSMpLUYbMwWltZJBObjm8lpfp5H2+1rCpMEceDHNWaIIwQ92tSlixG4DZXC6I+d ZXR8MtuN7saQd1pAErSOKFXY= X-Received: by 127.0.0.2 with SMTP id Ru4uYY7687511xEjH7lUhx6r; Wed, 03 Jan 2024 18:33:34 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.67]) by mx.groups.io with SMTP id smtpd.web11.45895.1704335613756016482 for ; Wed, 03 Jan 2024 18:33:34 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MNbhfAMrYHHiaQCFAJb/6njPjIx6anK0MLzViiL5wg3OaCF3/6UrNZI39uwfRQH7riXygTsv+fiY6AqRW/MXIBATQ6gnHK3RBG0PhvY+VYd3Uxdjl54n5iLd1skmZ6W3RtfCAifW6gZK1hfYS9CK7/HxZ7Jd2UgdNbtuaWlVsANZ3RRDYpwQkauYsBioc+3PeS+1I0aK9QZogjFoHvQFCCsITOyc1ArpZjLlA0U1uk0H5vMaKL/4SyShRlcI930MXxJ5rQ74cmwWqAJptJCkxJbQCf2ifqBWFr9AtYum5UZaNCzxX0iRBo5pTRpFk6NZ1Xe1SjgtEUZ8epwEII1Q9w== 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=jji3fkgRs+MB7oHBDvztnnrjj0dt5wYh6wEFzE+52Uw=; b=WHM4kTPeI9DKo5Km7ouFcZJNQBLB2AAduTBpKkrQiC3PKYeeyyyGfX1sDsTiuCkOC6r1RmjV/HzH3uycupEgw6UfmfjGrB1KUADt/gY6t38C5w+fwcJf2XExM8bxbQV/49ttze1yacEam1UC9TvaokyHHg7Qu0oTvRGCqTiOM3xCB7qZUExRGw5MjdJlv7jVmMgEJ2Wiq+eBj7g+ubga7fCywOtGrsnyMmIQ3//ROrJ83GRmxjOH9jaw80vH6Y59q5b5booPmsHilqrlY/HPRWE2eu2c/TymAs97Pyexu173+c+kC9STpBjZOYk6PNtK4jPKVJ6EStQkLI0XYgXHVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by LV2PR12MB5822.namprd12.prod.outlook.com (2603:10b6:408:179::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Thu, 4 Jan 2024 02:33:29 +0000 X-Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::a78e:602e:415c:4cb4]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::a78e:602e:415c:4cb4%3]) with mapi id 15.20.7159.013; Thu, 4 Jan 2024 02:33:29 +0000 From: "Nickle Wang via groups.io" To: "devel@edk2.groups.io" , "abner.chang@amd.com" CC: Igor Kulchytskyy , Nick Ramirez Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH 01/10] RedfishClientPkg: introduce Redfish HTTP cache library Thread-Topic: [edk2-devel] [edk2-redfish-client][PATCH 01/10] RedfishClientPkg: introduce Redfish HTTP cache library Thread-Index: AQHaPjxpzKdB3AI9nkK4Lj+TFlGhkbDIC+sggADkReA= Date: Thu, 4 Jan 2024 02:33:29 +0000 Message-ID: References: <20240103115955.61695-1-nicklew@nvidia.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=4ee4c91c-cf0c-4a49-89a6-f8a5c4852071;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2024-01-03T12:55:57Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|LV2PR12MB5822:EE_ x-ms-office365-filtering-correlation-id: 54613f47-bb7f-46a2-9833-08dc0ccd894b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: BNYEiRIbLgLQYn/F/2deXPQgJaULQ3C4GmIgwCnEbkWrtzxbn2eZ83RDrnJYHGF8cKZx2XPF1ez90N969xfAwRhx+myGlg+MvSQr5yAcjjInQn5lJNUijMsp6a9WUGk2Se+2tZUWp9e8LJYybOrIZawp76WdnH6bEiHtnIx1Pbwa2SjJKFj2AdmuON8c0F461AQfx/YZta+CQPzxyZtHt6vMJBCVcU9rgnOLaUbGYskXIf51BCGpSw7m0wk8VS8Bl6wbRVXmsiu15ggy4672TmxZtAQtFXkCKpPBCVnw3CBhGQQvNDund/wNyKKG9BnKKTO+P1A6t7ZmF3OvwXAVyF58E4YvDaGXZhp5J0Ayxvyr9bI1zTvf6tFuf0HPf+4GT92x3Pg9Og7DRjmvuu9Ct7ijmOOXG09hVRPsbAh5Xbt8elhbnYewAWnoBvNoE03bthzl7NtJcbuDkhtOp67qmeqIzjVtz7ZXwSi183NgulAljMEGTY9sazOkB2HjHMpyOboUrpIuLim1pJ7wKwuiss7cKNO8TW25U1DureA25VbdiMwOF3ZKxgLxvamdWr0RNj+Pn6vkT6iQ4Si1kM/R/L4dvZ+nyBv3yT+Bd+tm1fRxGKUZt8Bz+oarXJpELr2BcTlfuTH7M7QYOgxLberuRA== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?mF87BnkaQxbT9nVqRDfYbkAz0I7CHJd5hc0l3Cz2ntXe8v9xhDT/fVj2HYyG?= =?us-ascii?Q?Ps+d9lH8eMGltF/0+PO9Dt2fnfmaBW17G0hG6s5HxX5tlz4d1XOVlXCapQ79?= =?us-ascii?Q?jufHImGmJRNENh5tZdE6n1b5h/J3bLOaVPLAiZ7muZr68ljGishsLP4NO5Di?= =?us-ascii?Q?FQjvn4KKtOqzCvSrFaGDaeaa0tFZM0Q+KVhRECwUuz9wvuOO6xcdqZ6jrYoq?= =?us-ascii?Q?RssF0cDKFLAcNdeeYpqkJikCHmbz9+paDuKy4Ly4kbWhDWlE/wfoXe/4gLrY?= =?us-ascii?Q?XUptnL+aOcbImyCxeI8Fo9LLBh8Rom+RZYl34Cy22USmafpzHfE8jgolq7bv?= =?us-ascii?Q?9t+w20bvJUSe11RxF3+7+VTIFz3GKc4+6fptkzqvX5YIMTuT/PSiKQdTp1We?= =?us-ascii?Q?4mpO3H9MWyrNerxWu9yPXgfaA+/Q3Kog3dK+2XM/UWoIZomJ0NJBCARx7vqq?= =?us-ascii?Q?supY6I1W10gN8pzxizUrQSFLvw1SmiwIBuotRg/JBJfOR6hHZgyZzCJjJevz?= =?us-ascii?Q?ubRfu9Zcg3/IoczNgzAxntTl1k8Sxs7v0Kgqkutv/qRzXPaoQwFmT8Xljt2w?= =?us-ascii?Q?IDBdBf8Vb+9m2Al2BoYzSUtuohdFi3aV5ckq0x7rm0ydOJ7Yol7LLf71klA/?= =?us-ascii?Q?87pfQhHCQZzfXFwhuCqIl4BSZx4OVkRnOJBQcvXoxZydrBOOaE2hgxFPx8Sf?= =?us-ascii?Q?rk0voKCP9l/CV2dhFDsapDpycdP7PpTkZr6e2p9aaZcoiB10tlJs6iWQc5lo?= =?us-ascii?Q?Uo5bcn8y5lTrzHOceLQ5ZgyHu4XqqVFHFPPVpeKkXRZebaCmDG7itDooVstv?= =?us-ascii?Q?4udP3BIdzeXGwSiwNctfPDC7csqtwbG3/E+9U6HHqBgspT6wnY9J0Ah0afzN?= =?us-ascii?Q?ATyBP3fWRB3Ja3DFeNghUzZTNGutU6dmCr1gIEaXpjEnVjU7sLi8M6tehzGk?= =?us-ascii?Q?reG4HdWtGqKG+uPGxu7GVVxqL7/nOk5sUKtDy7Z0OLJg76DSI/CpXio+kg8Y?= =?us-ascii?Q?EfuQXNCesnP1fAT9GSdZxRwYlNMEPgqoDUZmfGW5g+1LSDuJIRYSrvhI1poj?= =?us-ascii?Q?LjLx2KuwFzT7+dtIXGLfTxr2GoRpNLE1eIxnY+r/+9iZjUdI+gTYcnV5bo6p?= =?us-ascii?Q?qhr2+7qID/KazZ02FdKp8Xh1LHDKA13HWT2NOHjd+JZ2+m/f2RmnzxdY+6GX?= =?us-ascii?Q?E4JAZcgg7tSHS5pL1u14APvQTFXIg+bv7i1ZLYovy6+LC13sr/pfNpMMWpQY?= =?us-ascii?Q?XHxqFfCEi/lAq5YJ3iorJIOuAAtH3BGJTOcEkWiT6WQvgU5Nz0eSwoNOgAGZ?= =?us-ascii?Q?wcUf7Cg5M+W26BKR765cquPgesgszHLyMQEZNNukguoJWVh0Nr/tDVNWoZxu?= =?us-ascii?Q?nhuZBa0vppN9XSRsLaaOBDulukVJyMi0ZiW3EJ37/OKsvfNKVUGLq5R61io0?= =?us-ascii?Q?D1KYW9c9DEVN5AXPO8MSmMcU4gvNw1BBAvmjM49oElACtxp1KX1UCFBWcJeM?= =?us-ascii?Q?nsoxGYkqfW2D4ZB0KkSug84wKtEXs6Q4TqIRGpVeG23jnVoFkJNEpoLanh6Z?= =?us-ascii?Q?IGjXKhVeEunBaLd6bpnCD75Zwsl4jbTfsuxAOsHPFrsMw3CATlhTH2YtR/18?= =?us-ascii?Q?/K72qX+/3OmS1o2ZRawLBL6bzyIWQzKZ2MCYKHQ0Ib/S?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54613f47-bb7f-46a2-9833-08dc0ccd894b X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2024 02:33:29.0773 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: beGppZKDnp8pXTGZi3tKe+dbdn+5ZuOfAbASjzrnGfekLGsus78ClHH4ehxh5U7D5u4b7WmRAUCkcS4UvwzLbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5822 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: ohUbA1Zwbp9dHDwZ6SlMZyWnx7686176AA= 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=g38PyPJv; 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}") Thanks Abner. Version 2 patch series is sent for review. Regards, Nickle > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Chang, Abn= er > via groups.io > Sent: Wednesday, January 3, 2024 9:02 PM > To: Nickle Wang ; devel@edk2.groups.io > Cc: Igor Kulchytskyy ; Nick Ramirez > Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH 01/10] RedfishClien= tPkg: > introduce Redfish HTTP cache library >=20 > External email: Use caution opening links or attachments >=20 >=20 > [AMD Official Use Only - General] >=20 > Hi Nickle, > I have no problem with this feature as we have been using this for a whil= e. Per > discussion off line, HttpCacheLibrary would be replaced with protocol ve= rsion > later. I would just give my RB to this patch as this patch is sent for cl= eaning up the > backlogs we are going to upstream. > But before we merging this patch, could you please replace all "BMC" term= in > these files with either Redfish service or service? Thanks. >=20 > Abner >=20 > > -----Original Message----- > > From: Nickle Wang > > Sent: Wednesday, January 3, 2024 8:00 PM > > To: devel@edk2.groups.io > > Cc: Chang, Abner ; Igor Kulchytskyy > > ; Nick Ramirez > > Subject: [edk2-redfish-client][PATCH 01/10] RedfishClientPkg: > > introduce Redfish HTTP cache library > > > > Caution: This message originated from an External Source. Use proper > > caution when opening attachments, clicking links, or responding. > > > > > > Introduce RedfishHttpCacheLib to improve HTTP GET performance in > > Redfish feature drivers. Feature drivers often query same Redfish > > resource multiple times for different purpose. Add HTTP cache > > mechanism to improve the performance. > > > > Signed-off-by: Nickle Wang > > Cc: Abner Chang > > Cc: Igor Kulchytskyy > > Cc: Nick Ramirez > > --- > > RedfishClientPkg/RedfishClientPkg.dec | 3 +- > > RedfishClientPkg/RedfishClientLibs.dsc.inc | 3 +- > > RedfishClientPkg/RedfishClientPkg.dsc | 3 +- > > .../RedfishHttpCacheLib.inf | 48 ++ > > .../Include/Library/RedfishHttpCacheLib.h | 59 ++ > > .../RedfishHttpCacheLibInternal.h | 63 ++ > > .../RedfishHttpCacheLib/RedfishHttpCacheLib.c | 774 > > ++++++++++++++++++ > > 7 files changed, 950 insertions(+), 3 deletions(-) create mode > > 100644 > > RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.inf > > create mode 100644 > > RedfishClientPkg/Include/Library/RedfishHttpCacheLib.h > > create mode 100644 > > RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLibIntern > > al.h > > create mode 100644 > > RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.c > > > > diff --git a/RedfishClientPkg/RedfishClientPkg.dec > > b/RedfishClientPkg/RedfishClientPkg.dec > > index 5f8a0350..b350faca 100644 > > --- a/RedfishClientPkg/RedfishClientPkg.dec > > +++ b/RedfishClientPkg/RedfishClientPkg.dec > > @@ -2,7 +2,7 @@ > > # Redfish Client Package > > # > > # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development > > LP
-# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. > > All rights reserved. > > +# Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All > > +rights > > reserved. > > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -26,6 +26,7 @@ > > > > EdkIIRedfishResourceConfigLib|Include/Library/EdkIIRedfishResourceConf > > EdkIIRedfishResourceConfigLib|igLi > > b.h > > RedfishEventLib|Include/Library/RedfishEventLib.h > > RedfishVersionLib|Include/Library/RedfishVersionLib.h > > + RedfishHttpCacheLib|Include/Library/RedfishHttpCacheLib.h > > > > [LibraryClasses.Common.Private] > > ## @libraryclass Redfish Helper Library diff --git > > a/RedfishClientPkg/RedfishClientLibs.dsc.inc > > b/RedfishClientPkg/RedfishClientLibs.dsc.inc > > index 5eae6711..572f426e 100644 > > --- a/RedfishClientPkg/RedfishClientLibs.dsc.inc > > +++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc > > @@ -6,7 +6,7 @@ > > # of EDKII network library classes. > > # > > # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development > > LP
-# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All > > rights reserved. > > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All > > +rights > > reserved. > > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > @@ -40,3 +40,4 @@ > > > > RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVe > > RedfishVersionLib|rsio > > nLib.inf > > > > RedfishAddendumLib|RedfishClientPkg/Library/RedfishAddendumLib/Redfis > > hAddendumLib.inf > > > > RedfishDebugLib|RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.inf > > + > > RedfishHttpCacheLib|RedfishClientPkg/Library/RedfishHttpCacheLib/Redfi > > RedfishHttpCacheLib|sh > > HttpCacheLib.inf > > diff --git a/RedfishClientPkg/RedfishClientPkg.dsc > > b/RedfishClientPkg/RedfishClientPkg.dsc > > index e16c91b8..0e3ef1ac 100644 > > --- a/RedfishClientPkg/RedfishClientPkg.dsc > > +++ b/RedfishClientPkg/RedfishClientPkg.dsc > > @@ -2,7 +2,7 @@ > > # Redfish Client Package > > # > > # (C) Copyright 2021 Hewlett-Packard Enterprise Development LP. > > -# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All > > +rights > > reserved. > > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > @@ -61,5 +61,6 @@ > > > > RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtility= Lib.inf > > RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.inf > > RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf > > + > > + RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.inf > > > > !include RedfishClientPkg/RedfishClient.dsc.inc > > diff --git > > a/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.inf > > b/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.inf > > new file mode 100644 > > index 00000000..32da4f83 > > --- /dev/null > > +++ > > b/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.inf > > @@ -0,0 +1,48 @@ > > +## @file > > +# Redfish HTTP cache library helps Redfish application to get > > +Redfish > > resource > > +# from BMC with cache mechanism enabled. > > +# > > +# Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All > > +rights > > reserved. > > +# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent # ## > > + > > +[Defines] > > + INF_VERSION =3D 0x00010006 > > + BASE_NAME =3D RedfishHttpCacheLib > > + FILE_GUID =3D 21F8FEEC-023C-451D-824D-823058FD9= 481 > > + MODULE_TYPE =3D DXE_DRIVER > > + VERSION_STRING =3D 1.0 > > + LIBRARY_CLASS =3D RedfishHttpCacheLib| DXE_DRIVER U= EFI_DRIVER > > + CONSTRUCTOR =3D RedfishHttpCacheConstructor > > + DESTRUCTOR =3D RedfishHttpCacheDestructor > > + > > +# > > +# VALID_ARCHITECTURES =3D IA32 X64 EBC > > +# > > + > > +[Sources] > > + RedfishHttpCacheLibInternal.h > > + RedfishHttpCacheLib.c > > + > > +[Packages] > > + MdePkg/MdePkg.dec > > + MdeModulePkg/MdeModulePkg.dec > > + RedfishPkg/RedfishPkg.dec > > + RedfishClientPkg/RedfishClientPkg.dec > > + > > +[LibraryClasses] > > + BaseLib > > + DebugLib > > + UefiBootServicesTableLib > > + MemoryAllocationLib > > + RedfishLib > > + UefiLib > > + RedfishDebugLib > > + ReportStatusCodeLib > > + PrintLib > > + > > +[depex] > > + TRUE > > + > > diff --git a/RedfishClientPkg/Include/Library/RedfishHttpCacheLib.h > > b/RedfishClientPkg/Include/Library/RedfishHttpCacheLib.h > > new file mode 100644 > > index 00000000..1277b981 > > --- /dev/null > > +++ b/RedfishClientPkg/Include/Library/RedfishHttpCacheLib.h > > @@ -0,0 +1,59 @@ > > +/** @file > > + This file defines the Redfish HTTP cache library interface. > > + > > + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All > > + rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef REDFISH_HTTP_CACHE_LIB_H_ > > +#define REDFISH_HTTP_CACHE_LIB_H_ > > + > > +#include > > +#include > > + > > +/** > > + Get redfish resource from given resource URI with cache mechanism > > + supported. It's caller's responsibility to Response by calling > > + RedfishFreeResponse (). > > + > > + @param[in] Service Redfish service instance to make query. > > + @param[in] Uri Target resource URI. > > + @param[out] Response HTTP response from redfish service. > > + @param[in] UseCache If it is TRUE, this function will search f= or > > + cache first. If it is FALSE, this function > > + will query Redfish URI directly. > > + > > + @retval EFI_SUCCESS Resrouce is returned successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +RedfishHttpGetResource ( > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + OUT REDFISH_RESPONSE *Response, > > + IN BOOLEAN UseCache > > + ); > > + > > +/** > > + Reset the cached data specified by given URI. When response data > > + returned by RedfishHttpResetResource() is modified, the response > > + data can not be used by other caller. Application calls this > > + function to make this data to be stale data and > > + RedfishHttpResetResource() will get latest data from remote server > > + again. > > + > > + @param[in] Uri Target resource URI. > > + > > + @retval EFI_SUCCESS Resrouce is reset successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +RedfishHttpResetResource ( > > + IN EFI_STRING Uri > > + ); > > + > > +#endif > > diff --git > > a/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLibInte > > rna > > l.h > > b/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLibInte > > rna > > l.h > > new file mode 100644 > > index 00000000..2549335d > > --- /dev/null > > +++ > > b/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLibInte > > rna > > l.h > > @@ -0,0 +1,63 @@ > > +/** @file > > + This file defines the Redfish HTTP cache library internal headers. > > + > > + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef REDFISH_HTTP_CACHE_INTERNAL_LIB_H_ > > +#define REDFISH_HTTP_CACHE_INTERNAL_LIB_H_ > > + > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include #include > > + #include > > +#include #include > > + > > + > > +#define REDFISH_HTTP_CACHE_LIST_SIZE 0x0F > > +#define REDFISH_HTTP_GET_RETRY_MAX 0x0F > > +#define REDFISH_HTTP_RETRY_WAIT (2 * 1000000U) ///< 1 second > > +#define REDFISH_ERROR_MSG_MAX 128 > > +#define REDFISH_HTTP_ERROR_REPORT "Redfish HTTP failure(0x%x): %a= " > > +#define REDFISH_HTTP_CACHE_DEBUG DEBUG_VERBOSE > > +#define REDFISH_HTTP_CACHE_DEBUG_DUMP DEBUG_VERBOSE > > + > > +/// > > +/// Definition of REDFISH_HTTP_CACHE_DATA /// typedef struct { > > + LIST_ENTRY List; > > + EFI_STRING Uri; > > + UINTN HitCount; > > + REDFISH_RESPONSE *Response; > > +} REDFISH_HTTP_CACHE_DATA; > > + > > +#define REDFISH_HTTP_CACHE_FROM_LIST(a) BASE_CR (a, > > REDFISH_HTTP_CACHE_DATA, List) > > + > > +/// > > +/// Definition of REDFISH_HTTP_CACHE_LIST /// typedef struct { > > + LIST_ENTRY Head; > > + UINTN Count; > > + UINTN Capacity; > > +} REDFISH_HTTP_CACHE_LIST; > > + > > +/// > > +/// Definition of REDFISH_HTTP_CACHE_PRIVATE /// typedef struct { > > + REDFISH_HTTP_CACHE_LIST CacheList; > > +} REDFISH_HTTP_CACHE_PRIVATE; > > + > > +#endif > > diff --git > > a/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.c > > b/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib.c > > new file mode 100644 > > index 00000000..c751e608 > > --- /dev/null > > +++ b/RedfishClientPkg/Library/RedfishHttpCacheLib/RedfishHttpCacheLib > > +++ .c > > @@ -0,0 +1,774 @@ > > +/** @file > > + Redfish HTTP cache library helps Redfish application to get Redfish > > +resource > > + from BMC with cache mechanism enabled. > > + > > + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All > > + rights > > reserved. > > + > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include "RedfishHttpCacheLibInternal.h" > > + > > +REDFISH_HTTP_CACHE_PRIVATE *mRedfishHttpCachePrivate =3D NULL; > > + > > +/** > > + This function copy the data in SrcResponse to DstResponse. > > + > > + @param[in] SrcResponse Source Response to copy. > > + @param[out] DstResponse Destination Response. > > + > > + @retval EFI_SUCCESS Response is copied successfully. > > + @retval Others Error occurs. > > + > > +**/ > > +EFI_STATUS > > +CopyRedfishResponse ( > > + IN REDFISH_RESPONSE *SrcResponse, > > + OUT REDFISH_RESPONSE *DstResponse > > + ) > > +{ > > + EDKII_JSON_VALUE JsonValue; > > + REDFISH_SERVICE Service; > > + UINTN Index; > > + > > + if ((SrcResponse =3D=3D NULL) || (DstResponse =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (SrcResponse =3D=3D DstResponse) { > > + return EFI_SUCCESS; > > + } > > + > > + // > > + // Status code > > + // > > + if (SrcResponse->StatusCode !=3D NULL) { > > + DstResponse->StatusCode =3D AllocateCopyPool (sizeof > > (EFI_HTTP_STATUS_CODE), SrcResponse->StatusCode); > > + if (DstResponse->StatusCode =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + } > > + > > + // > > + // Header > > + // > > + if ((SrcResponse->HeaderCount > 0) && (SrcResponse->Headers !=3D NUL= L)) { > > + DstResponse->HeaderCount =3D 0; > > + DstResponse->Headers =3D AllocateZeroPool (sizeof (EFI_HTTP_HE= ADER) * > > SrcResponse->HeaderCount); > > + if (DstResponse->Headers =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + for (Index =3D 0; Index < SrcResponse->HeaderCount; Index++) { > > + DstResponse->Headers[Index].FieldName =3D AllocateCopyPool > > + (AsciiStrSize > > (SrcResponse->Headers[Index].FieldName), SrcResponse- > > >Headers[Index].FieldName); > > + if (DstResponse->Headers[Index].FieldName =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + DstResponse->Headers[Index].FieldValue =3D AllocateCopyPool > > + (AsciiStrSize > > (SrcResponse->Headers[Index].FieldValue), SrcResponse- > > >Headers[Index].FieldValue); > > + if (DstResponse->Headers[Index].FieldValue =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + > > + DstResponse->HeaderCount +=3D 1; > > + } > > + } > > + > > + // > > + // Payload > > + // > > + if (SrcResponse->Payload !=3D NULL) { > > + Service =3D RedfishServiceInPayload (SrcResponse->Pay= load); > > + JsonValue =3D RedfishJsonInPayload (SrcResponse->Payloa= d); > > + DstResponse->Payload =3D RedfishCreatePayload (JsonValue, Service)= ; > > + if (DstResponse->Payload =3D=3D NULL) { > > + goto ON_ERROR; > > + } > > + } > > + > > + return EFI_SUCCESS; > > + > > +ON_ERROR: > > + > > + RedfishFreeResponse ( > > + DstResponse->StatusCode, > > + DstResponse->HeaderCount, > > + DstResponse->Headers, > > + DstResponse->Payload > > + ); > > + > > + return EFI_OUT_OF_RESOURCES; > > +} > > + > > +/** > > + This function clone input response and return to caller > > + > > + @param[in] Response Response to clone. > > + > > + @retval REDFISH_RESPONSE * Response is cloned. > > + @retval NULL Errors occur. > > + > > +**/ > > +REDFISH_RESPONSE * > > +CloneRedfishResponse ( > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + EFI_STATUS Status; > > + REDFISH_RESPONSE *NewResponse; > > + > > + if (Response =3D=3D NULL) { > > + return NULL; > > + } > > + > > + NewResponse =3D AllocateZeroPool (sizeof (REDFISH_RESPONSE)); if > > + (NewResponse =3D=3D NULL) { > > + return NULL; > > + } > > + > > + Status =3D CopyRedfishResponse (Response, NewResponse); if > > + (EFI_ERROR (Status)) { > > + FreePool (NewResponse); > > + return NULL; > > + } > > + > > + return NewResponse; > > +} > > + > > +/** > > + > > + Convert Unicode string to ASCII string. It's call responsibility to > > + release > > returned buffer. > > + > > + @param[in] UnicodeStr Unicode string to convert. > > + > > + @retval CHAR8 * ASCII string returned. > > + @retval NULL Errors occur. > > + > > +**/ > > +CHAR8 * > > +StringUnicodeToAscii ( > > + IN EFI_STRING UnicodeStr > > + ) > > +{ > > + CHAR8 *AsciiStr; > > + UINTN AsciiStrSize; > > + EFI_STATUS Status; > > + > > + if (IS_EMPTY_STRING (UnicodeStr)) { > > + return NULL; > > + } > > + > > + AsciiStrSize =3D StrLen (UnicodeStr) + 1; > > + AsciiStr =3D AllocatePool (AsciiStrSize); > > + if (AsciiStr =3D=3D NULL) { > > + return NULL; > > + } > > + > > + Status =3D UnicodeStrToAsciiStrS (UnicodeStr, AsciiStr, > > + AsciiStrSize); if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "UnicodeStrToAsciiStrS failed: %r\n", Status)= ); > > + FreePool (AsciiStr); > > + return NULL; > > + } > > + > > + return AsciiStr; > > +} > > + > > +/** > > + Release REDFISH_HTTP_CACHE_DATA resource > > + > > + @param[in] Data Pointer to REDFISH_HTTP_CACHE_DATA instance > > + > > + @retval EFI_SUCCESS REDFISH_HTTP_CACHE_DATA is released > > successfully. > > + @retval EFI_INVALID_PARAMETER Data is NULL > > + > > +**/ > > +EFI_STATUS > > +ReleaseHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_DATA *Data > > + ) > > +{ > > + if (Data =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (Data->Uri !=3D NULL) { > > + FreePool (Data->Uri); > > + } > > + > > + if (Data->Response !=3D NULL) { > > + if (Data->Response->Payload !=3D NULL) { > > + RedfishFreeResponse ( > > + Data->Response->StatusCode, > > + Data->Response->HeaderCount, > > + Data->Response->Headers, > > + Data->Response->Payload > > + ); > > + FreePool (Data->Response); > > + } > > + } > > + > > + FreePool (Data); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Create new cache data. > > + > > + @param[in] Uri The URI string matching to this cache data. > > + @param[in] Response HTTP response. > > + > > + @retval REDFISH_HTTP_CACHE_DATA * Pointer to newly created cache > > data. > > + @retval NULL No memory available. > > + > > +**/ > > +REDFISH_HTTP_CACHE_DATA * > > +NewHttpCacheData ( > > + IN EFI_STRING Uri, > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + REDFISH_HTTP_CACHE_DATA *NewData; > > + UINTN Size; > > + > > + if (IS_EMPTY_STRING (Uri) || (Response =3D=3D NULL)) { > > + return NULL; > > + } > > + > > + NewData =3D AllocateZeroPool (sizeof (REDFISH_HTTP_CACHE_DATA)); if > > + (NewData =3D=3D NULL) { > > + return NULL; > > + } > > + > > + Size =3D StrSize (Uri); > > + NewData->Uri =3D AllocateCopyPool (Size, Uri); if (NewData->Uri =3D= =3D > > + NULL) { > > + goto ON_ERROR; > > + } > > + > > + NewData->Response =3D Response; > > + NewData->HitCount =3D 1; > > + > > + return NewData; > > + > > +ON_ERROR: > > + > > + if (NewData !=3D NULL) { > > + ReleaseHttpCacheData (NewData); > > + } > > + > > + return NULL; > > +} > > + > > +/** > > + Search on given ListHeader for given URI string. > > + > > + @param[in] ListHeader Target list to search. > > + @param[in] Uri Target URI to search. > > + > > + @retval REDFISH_HTTP_CACHE_DATA Target cache data is found. > > + @retval NULL No cache data with given URI is fo= und. > > + > > +**/ > > +REDFISH_HTTP_CACHE_DATA * > > +FindHttpCacheData ( > > + IN LIST_ENTRY *ListHeader, > > + IN EFI_STRING Uri > > + ) > > +{ > > + LIST_ENTRY *List; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + > > + if (IS_EMPTY_STRING (Uri)) { > > + return NULL; > > + } > > + > > + if (IsListEmpty (ListHeader)) { > > + return NULL; > > + } > > + > > + Data =3D NULL; > > + List =3D GetFirstNode (ListHeader); > > + while (!IsNull (ListHeader, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + > > + if (StrCmp (Data->Uri, Uri) =3D=3D 0) { > > + return Data; > > + } > > + > > + List =3D GetNextNode (ListHeader, List); } > > + > > + return NULL; > > +} > > + > > +/** > > + Search on given ListHeader and return cache data with minimum hit co= unt. > > + > > + @param[in] ListHeader Target list to search. > > + > > + @retval REDFISH_HTTP_CACHE_DATA Target cache data is returned. > > + @retval NULL No cache data is found. > > + > > +**/ > > +REDFISH_HTTP_CACHE_DATA * > > +FindUnusedHttpCacheData ( > > + IN LIST_ENTRY *ListHeader > > + ) > > +{ > > + LIST_ENTRY *List; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + REDFISH_HTTP_CACHE_DATA *UnusedData; > > + UINTN HitCount; > > + > > + if (IsListEmpty (ListHeader)) { > > + return NULL; > > + } > > + > > + Data =3D NULL; > > + UnusedData =3D NULL; > > + HitCount =3D 0; > > + > > + List =3D GetFirstNode (ListHeader); > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + UnusedData =3D Data; > > + HitCount =3D Data->HitCount; > > + List =3D GetNextNode (ListHeader, List); > > + > > + while (!IsNull (ListHeader, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + > > + if (Data->HitCount < HitCount) { > > + HitCount =3D Data->HitCount; > > + UnusedData =3D Data; > > + } > > + > > + List =3D GetNextNode (ListHeader, List); } > > + > > + return UnusedData; > > +} > > + > > +/** > > + Delete a cache data by given cache instance. > > + > > + @param[in] List Target cache list to be removed. > > + @param[in] Data Pointer to the instance to be deleted. > > + > > + @retval EFI_SUCCESS Cache data is removed. > > + @retval Others Fail to remove cache data. > > + > > +**/ > > +EFI_STATUS > > +DeleteHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_LIST *List, > > + IN REDFISH_HTTP_CACHE_DATA *Data > > + ) > > +{ > > + if ((List =3D=3D NULL) || (Data =3D=3D NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: delete: %s\n", __func__, > > Data->Uri)); > > + > > + RemoveEntryList (&Data->List); > > + --List->Count; > > + > > + return ReleaseHttpCacheData (Data); } > > + > > +/** > > + Add new cache by given URI and HTTP response to specify List. > > + > > + @param[in] List Target cache list to add. > > + @param[in] Uri The URI string matching to this cache data. > > + @param[in] Response HTTP response. > > + > > + @retval EFI_SUCCESS Cache data is added. > > + @retval Others Fail to add cache data. > > + > > +**/ > > +EFI_STATUS > > +AddHttpCacheData ( > > + IN REDFISH_HTTP_CACHE_LIST *List, > > + IN EFI_STRING Uri, > > + IN REDFISH_RESPONSE *Response > > + ) > > +{ > > + REDFISH_HTTP_CACHE_DATA *NewData; > > + REDFISH_HTTP_CACHE_DATA *OldData; > > + REDFISH_HTTP_CACHE_DATA *UnusedData; > > + REDFISH_RESPONSE *NewResponse; > > + > > + if ((List =3D=3D NULL) || IS_EMPTY_STRING (Uri) || (Response =3D=3D = NULL)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + // > > + // If same cache data exist, replace it with latest one. > > + // > > + OldData =3D FindHttpCacheData (&List->Head, Uri); if (OldData !=3D > > + NULL) { > > + DeleteHttpCacheData (List, OldData); } > > + > > + // > > + // Check capacity > > + // > > + if (List->Count >=3D List->Capacity) { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: list is full and retire > > + unused > > cache\n", __func__)); > > + UnusedData =3D FindUnusedHttpCacheData (&List->Head); > > + if (UnusedData =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + DeleteHttpCacheData (List, UnusedData); } > > + > > + // > > + // Clone a local copy > > + // > > + NewResponse =3D CloneRedfishResponse (Response); if (NewResponse = =3D=3D > > + NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + NewData =3D NewHttpCacheData (Uri, NewResponse); if (NewData =3D=3D > > + NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + InsertTailList (&List->Head, &NewData->List); ++List->Count; > > + > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: cache(%d/%d) %s\n", > > __func__, List->Count, List->Capacity, NewData->Uri)); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Release all cache from list. > > + > > + @param[in] CacheList The list to be released. > > + > > + @retval EFI_SUCCESS All cache data are released. > > + @retval EFI_INVALID_PARAMETER CacheList is NULL. > > + > > +**/ > > +EFI_STATUS > > +ReleaseCacheList ( > > + IN REDFISH_HTTP_CACHE_LIST *CacheList > > + ) > > +{ > > + LIST_ENTRY *List; > > + LIST_ENTRY *Next; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + > > + if (CacheList =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (IsListEmpty (&CacheList->Head)) { > > + return EFI_SUCCESS; > > + } > > + > > + Data =3D NULL; > > + Next =3D NULL; > > + List =3D GetFirstNode (&CacheList->Head); while (!IsNull > > + (&CacheList->Head, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + Next =3D GetNextNode (&CacheList->Head, List); > > + > > + DeleteHttpCacheData (CacheList, Data); > > + > > + List =3D Next; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Debug output the cache list. > > + > > + @param[in] Msg Debug message string. > > + @param[in] ErrorLevel Output error level. > > + @param[in] CacheList Target list to dump. > > + > > + @retval EFI_SUCCESS Debug dump finished. > > + @retval EFI_INVALID_PARAMETER HttpCacheList is NULL. > > + > > +**/ > > +EFI_STATUS > > +DumpHttpCacheList ( > > + IN CONST CHAR8 *Msg, > > + IN UINTN ErrorLevel, > > + IN REDFISH_HTTP_CACHE_LIST *CacheList > > + ) > > +{ > > + LIST_ENTRY *List; > > + REDFISH_HTTP_CACHE_DATA *Data; > > + UINTN Index; > > + > > + if (CacheList =3D=3D NULL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (!IS_EMPTY_STRING (Msg)) { > > + DEBUG ((ErrorLevel, "%a\n", Msg)); } > > + > > + if (IsListEmpty (&CacheList->Head)) { > > + DEBUG ((ErrorLevel, "list is empty\n")); > > + return EFI_NOT_FOUND; > > + } > > + > > + DEBUG ((ErrorLevel, "list count: %d capacity: %d\n", > > + CacheList->Count, > > CacheList->Capacity)); > > + Data =3D NULL; > > + Index =3D 0; > > + List =3D GetFirstNode (&CacheList->Head); while (!IsNull > > + (&CacheList->Head, List)) { > > + Data =3D REDFISH_HTTP_CACHE_FROM_LIST (List); > > + > > + DEBUG ((ErrorLevel, "%d) Uri: %s Hit: %d\n", ++Index, Data->Uri, > > + Data- > > >HitCount)); > > + > > + List =3D GetNextNode (&CacheList->Head, List); } > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Get redfish resource from given resource URI with cache mechanism > > + supported. It's caller's responsibility to Response by calling > > + RedfishFreeResponse (). > > + > > + @param[in] Service Redfish service instance to make query. > > + @param[in] Uri Target resource URI. > > + @param[out] Response HTTP response from redfish service. > > + @param[in] UseCache If it is TRUE, this function will search f= or > > + cache first. If it is FALSE, this function > > + will query Redfish URI directly. > > + > > + @retval EFI_SUCCESS Resrouce is returned successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +RedfishHttpGetResource ( > > + IN REDFISH_SERVICE Service, > > + IN EFI_STRING Uri, > > + OUT REDFISH_RESPONSE *Response, > > + IN BOOLEAN UseCache > > + ) > > +{ > > + EFI_STATUS Status; > > + CHAR8 *AsciiUri; > > + REDFISH_HTTP_CACHE_DATA *CacheData; > > + UINTN RetryCount; > > + > > + if ((Service =3D=3D NULL) || (Response =3D=3D NULL) || IS_EMPTY_STRI= NG (Uri)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (mRedfishHttpCachePrivate =3D=3D NULL) { > > + return EFI_NOT_READY; > > + } > > + > > + AsciiUri =3D NULL; > > + CacheData =3D NULL; > > + RetryCount =3D 0; > > + > > + // > > + // Search for cache list. > > + // > > + if (UseCache) { > > + CacheData =3D FindHttpCacheData (&mRedfishHttpCachePrivate- > > >CacheList.Head, Uri); > > + if (CacheData !=3D NULL) { > > + DEBUG ((REDFISH_HTTP_CACHE_DEBUG, "%a: cache hit! %s\n", > > __func__, Uri)); > > + > > + // > > + // Copy cached response to caller's buffer. > > + // > > + Status =3D CopyRedfishResponse (CacheData->Respons= e, Response); > > + CacheData->HitCount +=3D 1; > > + return Status; > > + } > > + } > > + > > + AsciiUri =3D StringUnicodeToAscii (Uri); if (AsciiUri =3D=3D NULL) = { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + // > > + // Get resource from redfish service. > > + // > > + do { > > + RetryCount +=3D 1; > > + Status =3D RedfishGetByUri ( > > + Service, > > + AsciiUri, > > + Response > > + ); > > + if (!EFI_ERROR (Status) || (RetryCount >=3D > > REDFISH_HTTP_GET_RETRY_MAX)) { > > + break; > > + } > > + > > + // > > + // Retry when BMC is not ready. > > + // > > + if ((Response->StatusCode !=3D NULL)) { > > + DEBUG_CODE ( > > + DumpRedfishResponse (NULL, DEBUG_ERROR, Response); > > + ); > > + > > + if (*Response->StatusCode !=3D > > HTTP_STATUS_500_INTERNAL_SERVER_ERROR) { > > + break; > > + } > > + > > + FreePool (Response->StatusCode); > > + Response->StatusCode =3D NULL; > > + } > > + > > + DEBUG ((DEBUG_WARN, "%a: RedfishGetByUri failed, retry > > + (%d/%d)\n", > > __func__, RetryCount, REDFISH_HTTP_GET_RETRY_MAX)); > > + gBS->Stall (REDFISH_HTTP_RETRY_WAIT); } while (TRUE); > > + > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: get %a failed (%d/%d): %r\n", __func__, > > AsciiUri, RetryCount, REDFISH_HTTP_GET_RETRY_MAX, Status)); > > + if (Response->Payload !=3D NULL) { > > + RedfishFreeResponse ( > > + NULL, > > + 0, > > + NULL, > > + Response->Payload > > + ); > > + Response->Payload =3D NULL; > > + } > > + > > + goto ON_RELEASE; > > + } > > + > > + // > > + // Keep response in cache list > > + // > > + Status =3D AddHttpCacheData (&mRedfishHttpCachePrivate->CacheList, > > + Uri, > > Response); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "%a: failed to cache %s: %r\n", __func__, > > + Uri, > > Status)); > > + goto ON_RELEASE; > > + } > > + > > + DEBUG_CODE ( > > + DumpHttpCacheList (__func__, REDFISH_HTTP_CACHE_DEBUG_DUMP, > > &mRedfishHttpCachePrivate->CacheList); > > + ); > > + > > +ON_RELEASE: > > + > > + if (AsciiUri !=3D NULL) { > > + FreePool (AsciiUri); > > + } > > + > > + return Status; > > +} > > + > > +/** > > + Reset the cached data specified by given URI. When response data > > + returned by RedfishHttpResetResource() is modified, the response > > + data can not be used by other caller. Application calls this > > + function to make this data to be stale data and > > + RedfishHttpResetResource() will get latest data from remote server > > + again. > > + > > + @param[in] Uri Target resource URI. > > + > > + @retval EFI_SUCCESS Resrouce is reset successfully. > > + @retval Others Errors occur. > > + > > +**/ > > +EFI_STATUS > > +RedfishHttpResetResource ( > > + IN EFI_STRING Uri > > + ) > > +{ > > + REDFISH_HTTP_CACHE_DATA *CacheData; > > + > > + if (IS_EMPTY_STRING (Uri)) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + if (mRedfishHttpCachePrivate =3D=3D NULL) { > > + return EFI_NOT_READY; > > + } > > + > > + CacheData =3D FindHttpCacheData (&mRedfishHttpCachePrivate- > > >CacheList.Head, Uri); > > + if (CacheData =3D=3D NULL) { > > + return EFI_NOT_FOUND; > > + } > > + > > + DeleteHttpCacheData (&mRedfishHttpCachePrivate->CacheList, > > + CacheData); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + > > + Initial HTTP cache library instance. > > + > > + @param[in] ImageHandle The image handle. > > + @param[in] SystemTable The system table. > > + > > + @retval EFI_SUCCESS Initial library successfully. > > + @retval Other Return error status. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishHttpCacheConstructor ( > > + IN EFI_HANDLE ImageHandle, > > + IN EFI_SYSTEM_TABLE *SystemTable > > + ) > > +{ > > + mRedfishHttpCachePrivate =3D AllocateZeroPool (sizeof > > (REDFISH_HTTP_CACHE_PRIVATE)); > > + if (mRedfishHttpCachePrivate =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > + // > > + // Initial cache list > > + // > > + mRedfishHttpCachePrivate->CacheList.Capacity =3D > > REDFISH_HTTP_CACHE_LIST_SIZE; > > + mRedfishHttpCachePrivate->CacheList.Count =3D 0x00; > > + InitializeListHead (&mRedfishHttpCachePrivate->CacheList.Head); > > + > > + return EFI_SUCCESS; > > +} > > + > > +/** > > + Release allocated resource. > > + > > + @param[in] ImageHandle Handle that identifies the image to be > > unloaded. > > + @param[in] SystemTable The system table. > > + > > + @retval EFI_SUCCESS The image has been unloaded. > > + > > +**/ > > +EFI_STATUS > > +EFIAPI > > +RedfishHttpCacheDestructor ( > > + IN EFI_HANDLE ImageHandle, > > + IN EFI_SYSTEM_TABLE *SystemTable > > + ) > > +{ > > + if (mRedfishHttpCachePrivate !=3D NULL) { > > + if (!IsListEmpty (&mRedfishHttpCachePrivate->CacheList.Head)) { > > + ReleaseCacheList (&mRedfishHttpCachePrivate->CacheList); > > + } > > + > > + FreePool (mRedfishHttpCachePrivate); > > + mRedfishHttpCachePrivate =3D NULL; > > + } > > + > > + return EFI_SUCCESS; > > +} > > -- > > 2.34.1 >=20 >=20 >=20 >=20 >=20 -=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 (#113125): https://edk2.groups.io/g/devel/message/113125 Mute This Topic: https://groups.io/mt/103500371/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-