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 06494D8119E for ; Wed, 3 Jan 2024 12:00:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=h8O8qDieXlWYQzVY/8Equ7UNwpo2xhtpikNoqtjBOlo=; 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=1704283246; v=1; b=k1wcwO9y+coOOZ+kPfcLllvSk5uRahi1x88H3lP/IOQOsJCWi+hsD98R6/erCjLEaS+Cq95E 8GcEbS+dX6j7tDkqE8i04AeohbBnHm/7KEmET1Yve7gQPqzRrPkih5lGNDry3OsYJ9vayG9MQmk PJPCewLjNd/tMicoalEpmHNQ= X-Received: by 127.0.0.2 with SMTP id gRTYYY7687511xePAgyDpyYc; Wed, 03 Jan 2024 04:00:46 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.52]) by mx.groups.io with SMTP id smtpd.web10.15982.1704283246152312633 for ; Wed, 03 Jan 2024 04:00:46 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l3Thf3maUsPYNwmQjS1sU/Rn99JLclmH6oYJuyVwNShjAKjkfWxzgQYYW1pZdRg+I8yzDKQ668+HQ8cGoJiOSvzpnbidML497Zn4TnEBPBO2Opyvg1wmgCsYt0CiqygWtB4hIfSUpER1YZJBpSYGynQA7328WEdwpps31mDZDntecZbrWZwVyuHGvh6r3TUkzgAirGq75lG+aoUemyWWwvS2FthbEqPRMQQMCG9ObwIFPPdrUR9+jJ19Wnnojsaa+gQmZexEdJQW2Fg70q7ACcCtI+tqTCmrSb50pT2b+N4oMIbzQ61gsTm/YOClUzeMa4725XK2SvB2QwIkeJVKfg== 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=V4oN4QsUZPRhDUikj0zZr1+D8jBqolzPkvPW1cCHJVo=; b=F6RyB80eiKsf+8rcH0aSFb5BmfWWVvyDSg+IY8uPwtnOCu7hzPlcWYz7hHcHmQGobUqqWGgc8o6xnYit99OoYtJVzcxoMO8429KtfC+lmEAJOASNZkwICyNvOcqnnXxSiZmVk1+RV02rNvmu92T7ATGD03POfmmYslgxPMuoZpVjoVIoICxkWdKqrpPqLObVKhrGoozpgnadxGToCThvz+x6S6H93uspMreVTxj7aDuXMSM7JVd2IL+uEp2IZttlKYeC2Q9Tw/Lqt4ZYxk6ML/3YwHOJHCmBJfnB5ZZKSbXewuRxIzQpZe3JoFiVESWeRa2mD5Tu+Hw/rJEK6n45RA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from CYZPR12CA0006.namprd12.prod.outlook.com (2603:10b6:930:8b::22) by BN9PR12MB5132.namprd12.prod.outlook.com (2603:10b6:408:119::7) 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:00:43 +0000 X-Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2603:10b6:930:8b:cafe::30) by CYZPR12CA0006.outlook.office365.com (2603:10b6:930:8b::22) 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:00:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.11 via Frontend Transport; Wed, 3 Jan 2024 12:00:43 +0000 X-Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 3 Jan 2024 04:00:26 -0800 X-Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) 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:00:26 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Wed, 3 Jan 2024 04:00:25 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [edk2-redfish-client][PATCH 04/10] RedfishClientPkg/ComputerSystem: use HTTP cache lib Date: Wed, 3 Jan 2024 20:00:24 +0800 Message-ID: <20240103120024.61938-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: CY4PEPF0000EDD5:EE_|BN9PR12MB5132:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d6040d8-4904-4bd4-e547-08dc0c539ccf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: O9bdX6H9NDenSd6cA5I+Y1ar+0Tr2C8D3Z5YvjRojQN8qlio0xhTADDWgPUHGr7XWC7BgqPraRnqdLA45KKSdLZu02OOyVD8rO5UmhU1CDdGt6K48V+i2mIj6DTWKEb/Rcee3xSTEZi8ADQkTky1pKeF5qcC1r1VbAu/r+IwdrKem7JP25yugqqs3kTbKHG27w9kP36yub201mTLSjLyQqhmILSLLR/Q7LV4/dQ7NtNckXjoSmSnOaueBlKKeCxfF7l55pPTboWdCHWSFnmzdC4BYEX4S59QGRorVYJOz0rqg7ZzMGRd/ubl+6hws/V4LuREnF9g6McRwj8XKr68FKnGnAZfjfUAukIu5RjNARW/xIOIakvQ3DcoDADEapIwUFQWKohF+Ev0acAab68vYA+bm9OKoavTZFSEeu2uU1ZpBPPmP6HEU8FGv8mF0xtPNqgNcbZdpEGzhiuVlwI+mKQR9mDaJQWA7HxLx6Nh5JmE50lZ7J43ArfAyeroM3IJN4jcFD4jVtduG6qMqU3WZ+PS90mCIoE4WFFUThXh37sqLdEIydTX6Ma1WaG1ldBaRgc/0yFbKh800MjTKarpSSYwS/tDGbGMjHOsxMPC/XnKiEx3yHtZD+/j+IMi7RLdrenz88x+bhoIvaAggLGVdgf43PKZ8GwlmNrdEG+RGH3xXWgKOp7i4TutNbQhkuiy1Fwl/v7P1d0OzWoCEAL1J8HyNpor604Ha9A7dpToh3+pqyycVv5q9WOjq3YHWUFb X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2024 12:00:43.1363 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d6040d8-4904-4bd4-e547-08dc0c539ccf X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5132 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: fxg0RuO3zjrzWma5yjQSOIUXx7686176AA= 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=k1wcwO9y; 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}") Use Redfish Http cache library to query Redfish service. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../v1_5_0/Dxe/ComputerSystemDxe.inf | 3 +- .../v1_5_0/Dxe/ComputerSystemDxe.c | 70 +++++++++++++++---- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSy= stemDxe.inf b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerS= ystemDxe.inf index 67412f5f..36cbe062 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .inf +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .inf @@ -1,6 +1,7 @@ ## @file # # (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -36,7 +37,7 @@ RedfishResourceIdentifyLib UefiLib UefiDriverEntryPoint - + RedfishHttpCacheLib =20 [Protocols] gEdkIIRedfishConfigHandlerProtocolGuid ## PRODUCED 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 4ee72eeb..f89a4282 100644 --- a/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .c +++ b/RedfishClientPkg/Features/ComputerSystem/v1_5_0/Dxe/ComputerSystemDxe= .c @@ -2,7 +2,7 @@ Redfish feature driver implementation - ComputerSystem =20 (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
- Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights res= erved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -49,7 +49,8 @@ RedfishResourceProvisioningResource ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); + ZeroMem (&Response, sizeof (Response)); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -71,6 +72,7 @@ RedfishResourceProvisioningResource ( Response.Headers, Response.Payload ); + RedfishHttpResetResource (Uri); Private->Payload =3D NULL; } =20 @@ -97,6 +99,9 @@ RedfishResourceConsumeResource ( REDFISH_RESOURCE_COMMON_PRIVATE *Private; EFI_STATUS Status; REDFISH_RESPONSE Response; + EFI_STRING PendingSettingUri; + REDFISH_RESPONSE PendingSettingResponse; + REDFISH_RESPONSE *ExpectedResponse; CHAR8 *Etag; =20 if ((This =3D=3D NULL) || IS_EMPTY_STRING (Uri)) { @@ -109,14 +114,33 @@ RedfishResourceConsumeResource ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); + ZeroMem (&Response, sizeof (Response)); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, U= ri)); return Status; } =20 - Private->Uri =3D Uri; - Private->Payload =3D Response.Payload; + // + // Check and see if "@Redfish.Settings" exist or not. + // + ZeroMem (&PendingSettingResponse, sizeof (REDFISH_RESPONSE)); + Status =3D GetPendingSettings ( + Private->RedfishService, + Response.Payload, + &PendingSettingResponse, + &PendingSettingUri + ); + if (!EFI_ERROR (Status)) { + DEBUG ((REDFISH_DEBUG_TRACE, "%a: @Redfish.Settings found: %s\n", __fu= nc__, PendingSettingUri)); + Private->Uri =3D PendingSettingUri; + ExpectedResponse =3D &PendingSettingResponse; + } else { + Private->Uri =3D Uri; + ExpectedResponse =3D &Response; + } + + Private->Payload =3D ExpectedResponse->Payload; ASSERT (Private->Payload !=3D NULL); =20 Private->Json =3D JsonDumpString (RedfishJsonInPayload (Private->Payload= ), EDKII_JSON_COMPACT); @@ -126,7 +150,7 @@ RedfishResourceConsumeResource ( // Find etag in HTTP response header // Etag =3D NULL; - Status =3D GetEtagAndLocation (&Response, &Etag, 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__)); } @@ -149,12 +173,24 @@ RedfishResourceConsumeResource ( // Release resource // if (Private->Payload !=3D NULL) { - RedfishFreeResponse ( - Response.StatusCode, - Response.HeaderCount, - Response.Headers, - Response.Payload - ); + if (Response.Payload !=3D NULL) { + RedfishFreeResponse ( + Response.StatusCode, + Response.HeaderCount, + Response.Headers, + Response.Payload + ); + } + + if (PendingSettingResponse.Payload !=3D NULL) { + RedfishFreeResponse ( + PendingSettingResponse.StatusCode, + PendingSettingResponse.HeaderCount, + PendingSettingResponse.Headers, + PendingSettingResponse.Payload + ); + } + Private->Payload =3D NULL; } =20 @@ -233,7 +269,8 @@ RedfishResourceUpdate ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); + ZeroMem (&Response, sizeof (Response)); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -261,6 +298,7 @@ RedfishResourceUpdate ( Response.Headers, Response.Payload ); + RedfishHttpResetResource (Uri); Private->Payload =3D NULL; } =20 @@ -303,7 +341,8 @@ RedfishResourceCheck ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); + ZeroMem (&Response, sizeof (Response)); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, U= ri)); return Status; @@ -374,7 +413,8 @@ RedfishResourceIdentify ( return EFI_NOT_READY; } =20 - Status =3D GetResourceByUri (Private->RedfishService, Uri, &Response); + ZeroMem (&Response, sizeof (Response)); + Status =3D RedfishHttpGetResource (Private->RedfishService, Uri, &Respon= se, TRUE); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a, get resource from: %s failed\n", __func__, U= ri)); return Status; --=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 (#113074): https://edk2.groups.io/g/devel/message/113074 Mute This Topic: https://groups.io/mt/103500377/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-