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 EB0059418BE for ; Wed, 3 Jan 2024 12:01:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=esbNDGfJJrSCHsk830Wc4NnbTDuzEGPbNTRN7t9owf0=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1704283297; v=1; b=jb0s1WCS05f4z5iKkOPwuqDYluSDuiZ2zo9JWN2kBGLYFno3ocCe/mn2qF5KSr1hNU1OM+yv ImGaeivScqDzkWUWTM60PeHQvE9OVS0uNdAsfSWJgM88LowivaPcPEj4TxHfmcJ8oXJ3cIoa4MF H7zCE5qu1Ax2yHIzaMOuP+xM= X-Received: by 127.0.0.2 with SMTP id Ve2QYY7687511xvPg2wn55RD; Wed, 03 Jan 2024 04:01:37 -0800 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.55]) by mx.groups.io with SMTP id smtpd.web10.16003.1704283296862397531 for ; Wed, 03 Jan 2024 04:01:37 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KuZzUYBkHn9nNZ5TmOdszj2AoFph6f+5aLAde0NDrP69VewbrIu4phU5/2o1hyZGZ8vxum/FBho1I6MPH1AdV/EokbiYCdDoslZqkDiUliUno+0ZJduohy0PwG8eOmrF5+Tbyfpw7fcT7WyGU728Drtb5Npne9HCZN+E17K2YGWQr/TWeF6dPUj6fd5OC+WnDv6e6tVKsQb9lCNp/rCjYbpDD2dECG0fEomsuDiUl7L9ntjcW2SC0d0j+wZfL+kKze0tc+WcwstSaL0e8VaI8FV61d7guyNRUwzG8JLpiY54p39frb+zGR4NELOO/5ODjXVbknHi8BEElkDfPh0SwQ== 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=JN3B21BuMaZ+aRj9Ell4dYRT28kD7IK6yHhYAI/xRVQ=; b=Ry7tPMojH8PXaJVrfpRH2lOoCXbmwj1HQqw9MzR9I4cj6SSiyPgUqR25V8tYbbG9wUFMOSsASC8HDQqXmge3BpXlTUf3VN9hwUKqArHpCck94cqS0bhFuXANpUNSi0+Vr5nwfjzWGff5ST79z1ohrZ/kps5x2sS6uptZAkw24j15bbtpCWQapcp7SQ3sJlulD8h72ow42EhfVNZmDBDJWOcb0yZR3JWqwm1zV2sneyobrEwxnTF+Zcgjl7rqfJjYRiWGGytBSFomNLmr++dufg3AIlp3l2RaUS8+9NPM/aje3CY0d/UaIOSsMDEa8Sdg1ERT8+G9z954TcUdk2fr0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from MN2PR22CA0020.namprd22.prod.outlook.com (2603:10b6:208:238::25) by DM8PR12MB5431.namprd12.prod.outlook.com (2603:10b6:8:34::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Wed, 3 Jan 2024 12:01:31 +0000 X-Received: from BL6PEPF0001AB50.namprd04.prod.outlook.com (2603:10b6:208:238:cafe::ec) by MN2PR22CA0020.outlook.office365.com (2603:10b6:208:238::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13 via Frontend Transport; Wed, 3 Jan 2024 12:01:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by BL6PEPF0001AB50.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.9 via Frontend Transport; Wed, 3 Jan 2024 12:01:31 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 3 Jan 2024 04:01:13 -0800 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 3 Jan 2024 04:01:12 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Wed, 3 Jan 2024 04:01:12 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [edk2-redfish-client][PATCH 09/10] RedfishClientPkg/RedfishVersionLib: use HTTP cache lib Date: Wed, 3 Jan 2024 20:01:11 +0800 Message-ID: <20240103120111.62336-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB50:EE_|DM8PR12MB5431:EE_ X-MS-Office365-Filtering-Correlation-Id: 04c7181e-c088-4cc4-ec1d-08dc0c53b9aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: ilS2pzZ6UbOQ5GJedFx5cJ639mR6PjjOtwvGM1+bjtzBwjX0ILPwfJ6KoDPRRPtZtfB1vZwtWECp+Zi9iOgMe5pEmVj90z88JzyGSQk74IaVT8zdUJoVi0KVoHRe2YdvzucrO5SpU0bz+v7o1Zz5nabq6Yg2iVOBYfO8i6R9nT9oe8rrhhoOOK8P46SXTVxeLUd69BAEZGldt4W5s93Z482MRN+V7J/JfJOyCI+wOPculspUc7uYczQQoYs2hAcWvFZDdnSY9fVLhROGq6RMc0l/hxt1Kp28V13jVMFJ1+nJB6ygEp+Aid7+VhV5mQ1SctD/LX0OPJKhwkBigkQGbuYPgokwPQ5kctnAAPp4rfbLPMbZFZX0Ln/BuyfUG+kkway1eFWlllcTleaRPpWyZ5tKWVow8ozd8V+grnEromEQfIEtZQZbrHhJ17/wWUiU1t5cKdqj3jQboMUk/k/mt2MzbX/V/oySqoYDYp5xocW4W9a5vy5o+T9tIV9GiFQOhHISbH/87i6d/UwME1rD8b+mJKzBWo9fnt2JRWXLj1BBCpVUOp3dpAqzZLPj+Z+1qwSNYCK8xTrAGkchdoYam5HdBPvIlaYKpj33f1fodMLfxpiU2eSHt+5CwhHNRoYxLzDfqQWlwCaFMOqywqTyFd40gGPVReWBycTNs8Gq1Z9GgGxxn59+4h/ccFCFmEQ7gUQ7QV7sdb76AGhJWF33/M8jSKOrrkoFXxErX2VRcmsqzR6/uzaON2SvYXnib2M2 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 12:01:31.3918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04c7181e-c088-4cc4-ec1d-08dc0c53b9aa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB50.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5431 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: AfGbe81GswAPrME6jHiMYvISx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=jb0s1WCS; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Use Redfish Http cache library to query Redfish service. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../RedfishVersionLib/RedfishVersionLib.inf | 3 ++ .../RedfishVersionLib/RedfishVersionLib.c | 30 ++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.i= nf b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf index 34d13d64..10e335af 100644 --- a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf @@ -1,6 +1,7 @@ ## @file # # (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -31,11 +32,13 @@ =20 [LibraryClasses] BaseLib + BaseMemoryLib DebugLib MemoryAllocationLib PcdLib RedfishLib JsonLib + RedfishHttpCacheLib =20 [Protocols] =20 diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c= b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c index bcaca3c7..9a31c6a9 100644 --- a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c +++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c @@ -2,6 +2,7 @@ Redfish version library implementation =20 (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -10,15 +11,17 @@ #include #include #include +#include #include #include #include #include #include #include +#include =20 #define REDFISH_VERSION_DEFAULT_STRING L"v1" -#define REDFISH_ROOT_URI "/redfish" +#define REDFISH_ROOT_URI L"/redfish" =20 REDFISH_SERVICE *mCacheService; EFI_STRING mVersionCache; @@ -26,7 +29,7 @@ UINTN mVersionStringSize; =20 /** Cache the redfish service version for later use so we don't have to quer= y - HTTP request everytime. + HTTP request every time. =20 @param[in] Service Redfish service instance @param[in] Version Version string to cache @@ -66,7 +69,7 @@ CacheVersion ( =20 /** Query HTTP request to BMC with given redfish service and return redfish - version information. If there is troulbe to get Redfish version on BMC, + version information. If there is trouble to get Redfish version on BMC, The value of PcdDefaultRedfishVersion is returned. =20 It's call responsibility to release returned buffer. @@ -90,6 +93,7 @@ RedfishGetVersion ( EDKII_JSON_VALUE Value; =20 VersionString =3D NULL; + ZeroMem (&Response, sizeof (REDFISH_RESPONSE)); =20 if (Service =3D=3D NULL) { goto ON_ERROR; @@ -105,13 +109,14 @@ RedfishGetVersion ( // // Get resource from redfish service. // - Status =3D RedfishGetByUri ( + Status =3D RedfishHttpGetResource ( Service, REDFISH_ROOT_URI, - &Response + &Response, + TRUE ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a, RedfishGetByService to %a failed: %r\n", __f= unc__, REDFISH_ROOT_URI, Status)); + DEBUG ((DEBUG_ERROR, "%a, RedfishGetByService to %s failed: %r\n", __f= unc__, REDFISH_ROOT_URI, Status)); if (Response.Payload !=3D NULL) { RedfishDumpPayload (Response.Payload); RedfishFreeResponse ( @@ -151,18 +156,27 @@ ON_ERROR: VersionString =3D REDFISH_VERSION_DEFAULT_STRING; } =20 + if (Response.Payload !=3D NULL) { + RedfishFreeResponse ( + Response.StatusCode, + Response.HeaderCount, + Response.Headers, + Response.Payload + ); + } + DEBUG ((DEBUG_MANAGEABILITY, "%a: Redfish version - %s\n", __func__, Ver= sionString)); return AllocateCopyPool (StrSize (VersionString), VersionString); } =20 /** =20 - Initial redfish version library instace. + Initial redfish version library instate. =20 @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. =20 - @retval EFI_SUCEESS Install Boot manager menu success. + @retval EFI_SUCCESS Install Boot manager menu success. @retval Other Return error status. =20 **/ --=20 2.34.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113079): https://edk2.groups.io/g/devel/message/113079 Mute This Topic: https://groups.io/mt/103500391/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-