From nobody Sun May 19 15:29:22 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+92953+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 1661833369546117.38667738614924; Mon, 29 Aug 2022 21:22:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lDqRYY1788612xffz7K5oS4q; Mon, 29 Aug 2022 21:22:49 -0700 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.82]) by mx.groups.io with SMTP id smtpd.web09.7819.1661833368039274019 for ; Mon, 29 Aug 2022 21:22:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=muYOuEqSidcXZ3xwfXuw8e6etMDuhf4VO/aIhNacoIM2RIJSYhgg+D+J2FRZL4VP/wUT8+tstgbQ1Cpw+lDAmnOLd9Sn62iFcMT4SFgvEAlj2Vd8+LgPAqacIGEyxsrLEMRctNJzDnJG1N5LiPCngY3owsgyrW+sKpcFOFhJwq3OhnalhHpNMU/2IQxaMMkBx888NgAOjabER5L04hObU0z4NnDnsDD/5EQNYMTTGqsYrDzgNC2QukeSF9ajpF1zL/gS0zWHhkvgfwAe9LY7b3yEizrU78tjArYSw530YSKIx/fSGY6WdDKCwgtqPtvmUkKt627EFWYRnHAsG4QoyQ== 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=fqTw94bzTg3chaN2okTVZeyXlHbQ9UhjJ0S8gpw9n/s=; b=a+3PQsl5gxdFD2587FiMUJhNAp8UDbGvgTqZIJOUwgRaRnWgg/BINuhASbykPlTzxUvOwKCzqq76YNMt4S7/d3c4AuzfFnJe60hgWVCsMuSMAKqED2wCHxoSY/4WRKMzCfsLjx2pQgSK0aNzXir5KiqG4l7y06zXJciUn+iJv9rWvCvjRCVHWOrPxd63OojY0O2GNm0vTkviIB9juYGweLSX5s78W5oQjaGn+ZqY4KeZkYubIcFY6EzAxrxxvAlJZU5zC1XezZkN1MpX5tn7fC1BJkIpEm8aj2fx8E6r2lV1Gi8abk+CH1Q3C5uzjHOz556MVXSltxkXRklVaqGEyw== 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 MW4PR02CA0026.namprd02.prod.outlook.com (2603:10b6:303:16d::25) by CH2PR12MB4248.namprd12.prod.outlook.com (2603:10b6:610:7a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Tue, 30 Aug 2022 04:22:46 +0000 X-Received: from CO1NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::55) by MW4PR02CA0026.outlook.office365.com (2603:10b6:303:16d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Tue, 30 Aug 2022 04:22:45 +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+92953+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 CO1NAM11FT036.mail.protection.outlook.com (10.13.174.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5566.15 via Frontend Transport; Tue, 30 Aug 2022 04:22:45 +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; Mon, 29 Aug 2022 23:22:43 -0500 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [PATCH] RedfishPkg/RedfishDiscoverDxe: Install EFI_DISCOVER_PROTOCOL on each network interface Date: Tue, 30 Aug 2022 12:22:26 +0800 Message-ID: <20220830042226.1253-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd498544-73d1-48ff-49f6-08da8a3f4a23 X-MS-TrafficTypeDiagnostic: CH2PR12MB4248:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: zMNCVdr8Oom2OkwGOv6E7nvlRvWPWOV/7Jz3cpHlX9635Qiwbahpi9WRHwo/EzGVavgTcxaQXICxeuTNlgI3OBm6ryonudfAhsSs4kIodzX+hFEzvN5CxR4dK1FDiMrjEikPPUZhCeugxjt7uDyR2bf4vrzfefXDJxOQtlWCY24LWFUU+L1NQrvDJb9zU1ZbkAVUmgCnjL10ftuEUTHjEZonXl+U6dNFlM2FI5bj6K1Nz25rPWoMmgPginjj/FiTeLOzSfu9E3eNwI1BanYR3HpPA7tahXlGV7IzZKiCsfGBBWvhT7l4YCd7TsNeJKsv7aynPAT41TQslcTZux658T3RxOQMJXHVrxCg6eaF2HOZr6HPx/Z2vizoShqAU/L6Toe4KvnLRoDSumEySRsgIT3td2V9DizPxSoB/o8YBinf7NckoiXxhNJNknw8vNa/AGTv2BJm/JYL7LuiGWhsp8A/KPhJB6tvIqCeikMXsFO1F+hitNY7NfO+SGgDNCXZXSILUG090mCGoOVkdBK7YqZJhN/a/UUmlI/j87RIO1ZLzAMJ4IHptajoc0IzZazAGC+S4vtHiekSSa4HmnnxPEQC47HkBbb6aTVgsUg/s+I/fjkEkYbJWWMFEA/WpjJ9eNh7E8GYLokrNC8YQLw3RcPevLZtPlnosR0G9kmZlnx2utz+vJOSUavE+BfSluaud+TvV4fjjNGbEHdqHSN6ZFPNWbgVn5I2ZP+Iic3CxqGIpSiWDNE75OdRxi2BjI6jl47ckDO2JkvlSI4rmPeP+y/LVOJCI4Ug7Rpaz5XhCrBhM/RdnxIzAe6I6lDbrsjWewpKlICQnokUiDGKWCABKA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2022 04:22:45.5714 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd498544-73d1-48ff-49f6-08da8a3f4a23 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: CO1NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4248 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: ABA7BapF5Z7tNS2ac7wAEm3mx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1661833369; bh=mvy76AGL3bCzXGg/8AroAp7e2qy/mRYOY5RYNTGXIYo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=PwJipnu9XmKV/+1/02hm9gKzvl2S+d8gD8aSr3IgbhiPxxRevYR6mt8iYidCDhijScV pKhrGQseeTisAEZRmKYMrSrDy0Zuozxz1RaIe0x3D2mpDZiXb92scvcLDwCuyAIxRnczm 9okf2Vmqe5xVGtH0rv6gwQFeraL3dqWKCjw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1661833369981100001 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 --- .../RedfishDiscoverInternal.h | 7 + .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 138 ++++++++++-------- 2 files changed, 86 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..b5e91cb3469 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,32 @@ 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; + Status =3D CloseProtocolService ( + // Close protocol and destroy servi= ce. + 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 +2067,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 (#92953): https://edk2.groups.io/g/devel/message/92953 Mute This Topic: https://groups.io/mt/93342895/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-