From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=Gbq+8Vhg; 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.93.82, mailfrom: abner.chang@amd.com) 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 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=fqTw94bzTg3chaN2okTVZeyXlHbQ9UhjJ0S8gpw9n/s=; b=Gbq+8Vhg2DI1VHtKKYFiXsD9GdxcJawzIEKnPceAQUpN2GewI6CYRHt86uxtJYJ+LsztGrWTiqpqE2XkC6+tftvI50wROTHlmAJ3J74xp4HeTdi7NsqZFalPEcNvX/gPxrix4xElCL/m3/cKcxxSzmd/2QU/lNZ3s6iIHFdxkzA= 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 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 (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 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 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" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [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> 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: 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: BCL: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-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)(136003)(376002)(346002)(396003)(40470700004)(36840700001)(46966006)(86362001)(70206006)(82310400005)(478600001)(6666004)(7696005)(41300700001)(81166007)(26005)(82740400003)(336012)(186003)(16526019)(40480700001)(40460700003)(356005)(83380400001)(426003)(47076005)(1076003)(2616005)(36860700001)(54906003)(5660300002)(8676002)(8936002)(4326008)(2906002)(2876002)(316002)(36756003)(6916009)(19627235002)(70586007)(36900700001)(44824005);DIR:OUT;SFP:1101; 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 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 | 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