From nobody Sat May 11 08:33:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93021+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662004964813873.7478510372534; Wed, 31 Aug 2022 21:02:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id AInfYY1788612xbs7Hc1WiSo; Wed, 31 Aug 2022 21:02:44 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.53]) by mx.groups.io with SMTP id smtpd.web09.8277.1662004963547526375 for ; Wed, 31 Aug 2022 21:02:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AA4MxXcEKVpPhn168bmrF2lD0h0yMlvPXD0qbK2u6ikSouLterdsrbSUKDBNSvNY1lP3J3VWc/KNdH0fgFOwLWNVJ6r2jiRcK5e050Bv8GUPQq9DUuGIaiENZDNgh2YQKFdYjAG6+oEhesa4REJAqVDpPdB8jyZHoTAN8KHjGkf3mXB5eRGt1xs8GnFJwVYE726kve4vfOnR8zwhVU+7N62ridkNdkA62tX+kKwVhPDzD5ICsxCPE7qXBM7+6SeWRfRr6nTSOrCesNXWLiXhVp7VYWsY6uAgWrJ4Q6BGVI8jQqFqLKSQqYxiWcgSOYekgvw5Oem/Vr00baL9fLDbug== 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=7gMhEchSW2uMVOHyPdl/+XCKCDflthhUiXy8OmyXXQE=; b=YUIgaYk/Rw5SB8ODULPyQRVnw2v6tlSPRs1reQ+Fyzw1JffqPyNXmeIfuCRvH/0Oq0a2GlLkU2d3MoMOFi5jgQRrAkCnTsZX8Hig0RBRKTwFDKJrLSmoY0Tb8jXdTY5uck1xMjjDLAG/hryrkLH8EzyR2YtIBhUbRTU20tSi0xTsEQLRdXWj+Ip8dbqoVbsK7Mav27VOqzE0Xv1JjJDfW3f1XO/PaCxDUlNdqoxntPYDO63s4Xu+NDy6vQU7DVhhwW80UlBU1w7CpOBDzSbM7xJ2WfdhgePubE3H5ApwX5ZUXFYoVi6GtujOs7bqUphdo3rfycLogWy5KTbPPebDwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none X-Received: from BN9P222CA0020.NAMP222.PROD.OUTLOOK.COM (2603:10b6:408:10c::25) by SA1PR12MB5659.namprd12.prod.outlook.com (2603:10b6:806:236::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Thu, 1 Sep 2022 04:02:41 +0000 X-Received: from BN8NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10c:cafe::2b) by BN9P222CA0020.outlook.office365.com (2603:10b6:408:10c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Thu, 1 Sep 2022 04:02:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93021+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT062.mail.protection.outlook.com (10.13.177.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5588.10 via Frontend Transport; Thu, 1 Sep 2022 04:02:40 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 31 Aug 2022 23:02:39 -0500 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [PATCH V2] RedfishPkg/RedfishDiscoverDxe: Install EFI_DISCOVER_PROTOCOL on each network interface Date: Thu, 1 Sep 2022 12:02:22 +0800 Message-ID: <20220901040222.1472-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ec2fb1d-5086-48a4-080d-08da8bced0dc X-MS-TrafficTypeDiagnostic: SA1PR12MB5659:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: rUQSapYPD96dSL2slOunmW7rQg9aYFWRAKv6QgaFwx6q9XjklxqdMWUNK5HDigMvAYjQzrH0lnsL9a+35impb/XIJFr6ynd6OEdQzA6FD0e9jzIle4oCJ2WwVOEyD+rVDjj6uf9CBp8HeY4VOsJ+IuFGxa396l+rb+CM7Fti1/K4BaE3Xs6kprN0pvzCwzuO7H0qbIxkK7V9arXn9wtmLQrV2vSB9ID1fz+oTkSegeTPhaF1Fjlxg0Y7RGtR/5yBGz0Xq+oPgpNAckXmZP8Q639VxrmlVwJlUs6CCYwndmf87mJozYEweDd9lTzTb2L3/HWoLz8DTx19Fkcb/oDZhFAW5ubVIqeDyKyaFKUNYTJYcDndKmvA/2S7zS1eg07D7fvbi9uNOtd9wOAZnEyRXa6qGtoQmaGDxg8NZhlOT7Bc3sg+YNanPfHVW8kek4fhh+rr4fZOoif1KL84dDiFRm/lbq+CH+eMDxol1dlqVovp5pOmx/PkJqKu3j8k2NcGNiex0gtnrAg6KX/Xtg76BY3wQ6Z2z2nSDTOGm7ziHG6kUVjbAYqzsgXUVILhFVf9HOv/EpdEsJJynOlaM7yrUXPLWjTQ8XVb9P5dEB34lWSDZVNXfcTeJ+A+xJnbo94o8qPh33F5Jpf0hooyRv6F9B2+Hm9kWHp3/+e1KFxcLLJFq8Z7y/YptEWFFjd9+aC0JMPjRXv+gfaSx/d3UcClmh+MWq2AqQ9IwUVUcSf7wK2TOuvFw6OkWeNGDkC1nNTstrPuZ0IhI1Xc/j/kK+/oSmSFxffwj52/gv+QaXQ8vtAZ0TPtXmGlcvgywZBMFmjoD8ece/TGmRWgvzztLGM0cw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2022 04:02:40.9170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ec2fb1d-5086-48a4-080d-08da8bced0dc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5659 Precedence: Bulk List-Unsubscribe: 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,abner.chang@amd.com X-Gm-Message-State: NPyAGjHbbhqEhaWvCopjlPtOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662004964; bh=/gk8R8hO6QQoMQQWlnREHR6LpB9f9HsWaEGIMc1zlzM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=boZDJkqoarLrI0qWySnLn43zOUN+vXJ4NJJDt3c0kCPb2gC/822N73cpg2mK6sksTOf OEP7BF/YkDReBFjN2vO4Tf04t67Uk7ELL3bEGMcqeWK47AnPZ77gFhE724tdOs64CiBjY io27YpdvNgbBlmLUqfdpjMefa0gUCXIdTwY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662004966208100001 Content-Type: text/plain; charset="utf-8" From: Abner Chang BZ 4037: Install EFI_DISCOVER_PROTOCOL on each network interface. This fixes the issue that causes the high-level Redfish driver on the network interface is stopped when: 1. EFI_DISCOVER_PROTOCOL is reinstalled on a new-found network interface, or 2. EFI_DISCOVER_PROTOCOL is stopped on the network interface other than the one which is used to communicate with Redfish service. Cc: Nickle Wang Cc: Igor Kulchytskyy Signed-off-by: Abner Chang Reviewed-by: Igor Kulchytskyy Reviewed-by: Nickle Wang --- .../RedfishDiscoverInternal.h | 7 + .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 140 ++++++++++-------- 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h index 4d1319b2641..04fa09e1cc2 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h @@ -2,6 +2,7 @@ This file defines the EFI Redfish Discover Protocol interface. =20 (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, AMD Incorporated. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -107,6 +108,12 @@ typedef struct { = ///< NETWORK_INTERFACE_PROTOCOL_TYPE. REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL NetworkInterfaceProtocolI= nfo; ///< Network interface protocol information. EFI_HANDLE RestExHandle; = ///< REST EX handle associated with this network interface. + // + // EFI_REDFISH_DISCOVER_PROTOCOL instance installed + // on this network interface. + // + EFI_HANDLE EfiRedfishDiscoverProtoco= lHandle; ///< EFI_REDFISH_DISCOVER_PROTOTOCOL instance installed + = ///< on this network interface. } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL; =20 // diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index bf50c78c928..a271f6e942d 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -3,6 +3,7 @@ The implementation of EFI Redfidh Discover Protocol. =20 (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2022, AMD Incorporated. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -23,8 +24,6 @@ EFI_GUID mRedfishDiscoverTcp4InstanceGuid =3D EFI_REDF= ISH_DISCOVER_TCP4_INSTANC EFI_GUID mRedfishDiscoverTcp6InstanceGuid =3D EFI_REDFISH_DISCOVER_TCP6= _INSTANCE_GUID; EFI_GUID mRedfishDiscoverRestExInstanceGuid =3D EFI_REDFISH_DISCOVER_REST= _EX_INSTANCE_GUID; =20 -EFI_HANDLE EfiRedfishDiscoverProtocolHandle =3D NULL; - EFI_STATUS EFIAPI Tcp4GetSubnetInfo ( @@ -325,6 +324,38 @@ GetTargetNetworkInterfaceInternal ( return NULL; } =20 +/** + This function searches EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL + instance with the given Controller handle. + + @param[in] ControllerHandle The controller handle associated with netwo= rk interface. + + @retval Non-NULL EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL is ret= urned. + @retval NULL Non of EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL= instance is returned. +**/ +EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL * +GetTargetNetworkInterfaceInternalByController ( + IN EFI_HANDLE ControllerHandle + ) +{ + EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; + + ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNA= L *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); + while (TRUE) { + if (ThisNetworkInterface->OpenDriverControllerHandle =3D=3D Controller= Handle) { + return ThisNetworkInterface; + } + + if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInt= erface->Entry)) { + return NULL; + } + + ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTER= NAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterf= ace->Entry); + } + + return NULL; +} + /** This function validate if target network interface is ready for discover= ing Redfish service. @@ -1619,29 +1650,30 @@ BuildupNetworkInterface ( EFI_OPEN_PROTOCOL_BY_DRIVER ); if (!EFI_ERROR (Status)) { - if ((EfiRedfishDiscoverProtocolHandle =3D=3D NULL) && - (gRequiredProtocol[Index].ProtocolType =3D=3D ProtocolTypeRest= Ex) && - !IsListEmpty (&mEfiRedfishDiscoverNetworkInterface) - ) - { - // Install the fisrt Redfish Discover Protocol when EFI REST EX = protcol is discovered. - // This ensures EFI REST EX is ready while EFI_REDFISH_DISCOVER_= PROTOCOL consumer acquires - // Redfish serivce over network interface. - - Status =3D gBS->InstallProtocolInterface ( - &EfiRedfishDiscoverProtocolHandle, - &gEfiRedfishDiscoverProtocolGuid, - EFI_NATIVE_INTERFACE, - (VOID *)&mRedfishDiscover - ); - } else if ((EfiRedfishDiscoverProtocolHandle !=3D NULL) && NewNetw= orkInterfaceInstalled) { - Status =3D gBS->ReinstallProtocolInterface ( - EfiRedfishDiscoverProtocolHandle, - &gEfiRedfishDiscoverProtocolGuid, - (VOID *)&mRedfishDiscover, - (VOID *)&mRedfishDiscover - ); - NewNetworkInterfaceInstalled =3D FALSE; + if ((gRequiredProtocol[Index].ProtocolType =3D=3D ProtocolTypeRest= Ex)) { + // Install Redfish Discover Protocol when EFI REST EX protcol is= discovered. + // This ensures EFI REST EX is ready while the consumer of EFI_R= EDFISH_DISCOVER_PROTOCOL + // acquires Redfish serivce over network interface. + + if (!NewNetworkInterfaceInstalled) { + NetworkInterface =3D GetTargetNetworkInterfaceInternalByContro= ller (ControllerHandle); + if (NetworkInterface =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Can't find network interface by Co= ntrollerHandle\n", __FUNCTION__)); + return Status; + } + } + + NewNetworkInterfaceInstalled =3D FALSE; + NetworkInterface->EfiRedfishDiscoverProtocolHandle =3D NULL; + Status =3D gBS->Inst= allProtocolInterface ( + &Net= workInterface->EfiRedfishDiscoverProtocolHandle, + &gEf= iRedfishDiscoverProtocolGuid, + EFI_= NATIVE_INTERFACE, + (VOI= D *)&mRedfishDiscover + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI_REDFISH_DISCOVER= _PROTOCOL\n", __FUNCTION__)); + } } } =20 @@ -1724,6 +1756,7 @@ StopServiceOnNetworkInterface ( EFI_STATUS Status; VOID *Interface; EFI_TPL OldTpl; + EFI_HANDLE DiscoverProtocolHandle; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; =20 @@ -1743,30 +1776,34 @@ StopServiceOnNetworkInterface ( ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_I= NTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); while (TRUE) { if (ThisNetworkInterface->NetworkInterfaceProtocolInfo.ProtocolC= ontrollerHandle =3D=3D ControllerHandle) { - Status =3D CloseProtocolService ( - // Close protocol and destroy service. - ThisBindingProtocol, - ControllerHandle, - &gRequiredProtocol[Index], - ThisNetworkInterface->OpenDriverAgentHandle, - ThisNetworkInterface->OpenDriverControllerHandle - ); + DiscoverProtocolHandle =3D ThisNetworkInterface->EfiRedfishDis= coverProtocolHandle; + // + // Close protocol and destroy service. + // + Status =3D CloseProtocolService ( + ThisBindingProtocol, + ControllerHandle, + &gRequiredProtocol[Index], + ThisNetworkInterface->OpenDriverAge= ntHandle, + ThisNetworkInterface->OpenDriverCon= trollerHandle + ); if (!EFI_ERROR (Status)) { Status =3D DestroyRedfishNetwrokInterface (ThisNetworkInterf= ace); } =20 gBS->RestoreTPL (OldTpl); - // Reinstall Redfish Discover protocol to notify network - // interface change. - - Status =3D gBS->ReinstallProtocolInterface ( - EfiRedfishDiscoverProtocolHandle, - &gEfiRedfishDiscoverProtocolGuid, - (VOID *)&mRedfishDiscover, - (VOID *)&mRedfishDiscover - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: Reinstall gEfiRedfishDiscoverProto= colGuid fail.", __FUNCTION__)); + + // + // Disconnect EFI Redfish discover driver controller to notify= the + // clinet which uses .EFI Redfish discover protocol. + // + if (DiscoverProtocolHandle !=3D NULL) { + gBS->DisconnectController (DiscoverProtocolHandle, NULL, NUL= L); + Status =3D gBS->UninstallProtocolInterface ( + DiscoverProtocolHandle, + &gEfiRedfishDiscoverProtocolGuid, + (VOID *)&mRedfishDiscover + ); } =20 return Status; @@ -2032,20 +2069,5 @@ RedfishDiscoverUnload ( StopServiceOnNetworkInterface (&gRedfishDiscoverDriverBinding, ThisNet= workInterface->NetworkInterfaceProtocolInfo.ProtocolControllerHandle); } =20 - // Disconnect EFI Redfish discover driver controller to notify the - // clinet which uses .EFI Redfish discover protocol. - - if (EfiRedfishDiscoverProtocolHandle !=3D NULL) { - // - // Notify user EFI_REDFISH_DISCOVER_PROTOCOL is unloaded. - // - gBS->DisconnectController (EfiRedfishDiscoverProtocolHandle, NULL, NUL= L); - Status =3D gBS->UninstallProtocolInterface ( - EfiRedfishDiscoverProtocolHandle, - &gEfiRedfishDiscoverProtocolGuid, - (VOID *)&mRedfishDiscover - ); - } - return Status; } --=20 2.37.1.windows.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 (#93021): https://edk2.groups.io/g/devel/message/93021 Mute This Topic: https://groups.io/mt/93388097/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-