From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=bYsUBPny; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.94.53, mailfrom: abner.chang@amd.com) 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7gMhEchSW2uMVOHyPdl/+XCKCDflthhUiXy8OmyXXQE=; b=bYsUBPnybVYgepMcBic57Y3KH/+oSl1nj0LSRKNByl06IOR0Kcl1C6RJhaZfVD9A2PtrjgO2Ol25UeLEF/sPCVkEqGsws/D1XnylaRpsTb/tu7GElDCR02DE2B1CEBdGNARxXUhp00OnobVkHD5XtiU5TRuJTecuhZ18eQN1R9c= 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 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 (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 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 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" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [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> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com 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: BCL: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-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(396003)(376002)(346002)(136003)(46966006)(36840700001)(40470700004)(70206006)(86362001)(82310400005)(478600001)(7696005)(41300700001)(16526019)(81166007)(26005)(336012)(40480700001)(82740400003)(40460700003)(186003)(356005)(83380400001)(1076003)(426003)(47076005)(36860700001)(4326008)(5660300002)(2616005)(6666004)(8676002)(54906003)(8936002)(19627235002)(2906002)(316002)(6916009)(2876002)(36756003)(70586007)(36900700001)(44824005);DIR:OUT;SFP:1101; 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 | 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