From nobody Sun May 19 13:07:56 2024 Delivered-To: importer@patchew.org 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+103223+1787277+3901457@groups.io; helo=mail02.groups.io; 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+103223+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 1681916657923781.381289963362; Wed, 19 Apr 2023 08:04:17 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Bo3YYY1788612xp9xCS5fCNh; Wed, 19 Apr 2023 08:04:17 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.53]) by mx.groups.io with SMTP id smtpd.web10.40262.1681916656165126911 for ; Wed, 19 Apr 2023 08:04:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gx8YCceOfWVnGIJiNkcc+KboJdO7ozqaTItj/raSgWJtMDAeSqeSTMoii57NRlHfxBgqNAL4Msk38Ya8UarLAziZ9K9U3Dy0OB8Q5Sq85hDB8IS9xEplefy3tna/C9tNPqHqU58nL+oqYnpnrhya18tTweZXM79UwZaraifQF7/1TsZuylZ3tsWfUFn8jjGOvsbNzTslx/Y97jtCBOqGQHY66jEpoTLqGquxaFYbrsj5TW+59BC4rR3IxWdfKAxfXPS8B/qoASQAwFD9lCV4pp6I1aeXj19Jf+W5hlMvW6XBPGMrwxKafUmYN7aNIp7ypCLEWkS4vTsNgABKjDcV4w== 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=FMtf4dOKobY6XNCUykcbUHkv3klmLb4rFMRdoBQLiI8=; b=FAewz6e3LKDFXjm6Z04dgZM/NrvBN/+ydFWIcsedyrpFHR8UFJHhs4b4CsNXWqTapAnLdWeFzGihYAG8oNCHM93x8VXXEdgUz5gko18NUEANkdeIwU06lA4LuDRfx9PulVqnxr9jNLeUOOHoRdCx19v47EcPBOcTL1xp7LLpSFEuPEbX98hR4GMr22Ikmwwmb4LCcBPljoAVsst911Wcq36hgWiJx9hyOlwo5o5IqrMYSOHXwLRJMzsQfxFvsE687SJ/7+OGryxqJob8//IGNUVq+ExeCiioVks9hVCjZvOLxGqE1rX8L8dHBCJFHXQ7h8lVTFOafRr0CyjHy0jZBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by CYYPR10MB7608.namprd10.prod.outlook.com (2603:10b6:930:bb::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Wed, 19 Apr 2023 15:04:12 +0000 X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::d79d:9060:94d8:b4b0]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::d79d:9060:94d8:b4b0%7]) with mapi id 15.20.6319.020; Wed, 19 Apr 2023 15:04:11 +0000 From: "Igor Kulchytskyy via groups.io" To: "devel@edk2.groups.io" CC: Abner Chang , Nickle Wang Subject: [edk2-devel] [PATCH] RedfishPkg: Remove the global variables related to Discover Token functionality Thread-Topic: [PATCH] RedfishPkg: Remove the global variables related to Discover Token functionality Thread-Index: AQHZctAydhY3Kcy4cUiFhJsstK/5NA== Date: Wed, 19 Apr 2023 15:04:11 +0000 Message-ID: <20230419150328.1097-1-igork@ami.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|CYYPR10MB7608:EE_ x-ms-office365-filtering-correlation-id: b957c6f7-464e-4f75-f9aa-08db40e75552 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: nz9AnhGjHMl6G1vCeyJ70VzmrIwr8sV54FYhG5svgd1XQ12W5UZuQI/F1aeJpQ0SD9Ir9dFv2kFIAL3qyvRtisNY7VmgXW8AJUnF2CiY9jX9HWT8WaO1HE5vLlpjtB/wlnNy/zoQhY3SiMObQbSh97QSICdu6AypU2L2LSC11Ci1IslaFpH8iPp8EqLoPxp7rP4DI9JXQBpJZjFPPzTvB37p/JW7HVXjbsMqi7b/5GIsIG3O5oKVgtMIrL3ZrGCujzn30Ni+CfBjcbWadIYIXKNP/fqFos9HpE3XsfCsv/GMSzwo9/xEGlF2u4H48eoRKdaBiFHkIsQlWx3f4xvTObkGbk7PwyMlywmmCh0XY9Imwb3TEV1y1AHvZv+EhR7fo77rYzNvwgKz3GwJd20c0cps3Fve2zV4M3F+K3fPG4ugj7n5IIUrG0CBDUedv8oA2KTLsAJdNNjAFx8KwBQTTe+FV7y3qJhMR29SAfYaSZ5Hr5Lcwa4G3TUIV/PDenEN3qrhcSP5GxtOyuY5VhvKJ5mC2ZiiiGDTM3srNAhbNXPeu1lLBydFnlWfrnnIH46XJ2ldO44Jzv6kGMKR2Ntoy7TOvDyBA29Gr4SSndP0iq+CpS63s/hBn452j8yxsqaNyUXrk6pToDhfEiLizQg3jA== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?XnSy/uqFsPq8MAbCWt5evTI6h8NTufeUuSk+wH4SzUEtQiRZs0fyAjrGNo?= =?iso-8859-1?Q?3/KKP+NvIfstwje/7r8KHJ6KkXQ3P/VKjmOtbj0k/XuPWp4XOq/JTvzxCw?= =?iso-8859-1?Q?NWJI8BTQo3vZLWeQEtNeMKairi5SZkuPUx4RBdenZQyYS5eX9n834tGiSG?= =?iso-8859-1?Q?1/yf3NjJV2+TktJqINWysTZ/AAhJaIRh77e4ym0sNpPsl8dX1dOZCXgIib?= =?iso-8859-1?Q?De8rCJPBIfV15QDndpBVSQwPspb6x+elM5YsM4uqiiloHHxlpH9XRYEajE?= =?iso-8859-1?Q?7i78Iix4/Q1PS4m/F7dcM6TYG9LGv2Tcs1+UD/KFwqmnyg5ZmoY3MVUdEs?= =?iso-8859-1?Q?Zq71iY31yNg7dCgphE7cfsCZWWAp8tUoBfaDlUE46yeDaAE6gVLq6esKIJ?= =?iso-8859-1?Q?JrtesLPrBP44ha6JVwTqoiUWpZe+nNUl9L2Zc67rt78pKi9KiRG/lwEuCW?= =?iso-8859-1?Q?a5JHy60LH+4PRYVUJLFGqpyFVt9HBX2WwIhWfAz/3wwZKoGMrRdNbR/FZq?= =?iso-8859-1?Q?D3bYupE6sSUVIFH1S6fohOdK63kOnLRHZbS75eLRZXPqC/uJkx9pcQ0xYV?= =?iso-8859-1?Q?7n1/4KA0pv/yBNol+GMBk1J8rhyQm8z+nVCKjBs+Uplw5vLS15EnyNKRSx?= =?iso-8859-1?Q?+R/zSApIhr+7JRhF4q6nmIUs3j6Yh3nfmCTLemP7TDRmi0wLnkeZUaSO+j?= =?iso-8859-1?Q?Ij7do/FPgmLIyc5JmUMk2QFU3LumvpWGvbbh3TcrFqTBI4kz+sstmIWukP?= =?iso-8859-1?Q?dj8hergeeVjmRtwGtznSLxr4iuqjev3H2HR/NZyoJagZEdzxAOZBMfXDLA?= =?iso-8859-1?Q?vKQ9yfO3i8WA0QRTuNPtGcMF6wK0oRrQJGZaQW5pQwSlOYnmrOSgohAleG?= =?iso-8859-1?Q?RmfoJNXj43JlhCCyeJIqOKQEyJscIyDVAoyu+zrisSD9+H0oHnrrtP3aKa?= =?iso-8859-1?Q?FYHabJibggsYxyw7x84LTsg3gtK6LuUwYylcBRll80tRG2FRDjMfsXBqBS?= =?iso-8859-1?Q?fQxpgNJnaDR7vZpCuTVUQC+EN2QfWw5DDG56/2m6jS77ITyjst/eJxeWPs?= =?iso-8859-1?Q?TVkS10OcONV+8j4eUQEw7MNL+oobN2J566gv11aGo5oHGUmD+zMNd85xVS?= =?iso-8859-1?Q?azmAIkDHFStX7xq5R5xQ4cNqBkLrXXdo2sP7cnu/t9ngIik39ww+rtp1/J?= =?iso-8859-1?Q?JpEK3iU2LvLOgcEenwcWeeT2FCG71pocneXdkWU04cVCWU0dUpgfoegbLC?= =?iso-8859-1?Q?K/bBJVFK7nnVqkxllBACCsB8owa4KBKNNQNkBsgkAC30saxv+/a3W7mIVd?= =?iso-8859-1?Q?IDuW6UCGfhtlMqS5wxvs+UHlyNCh6Rw5S+YTFwAgKtniyEPr8/LqorMzFG?= =?iso-8859-1?Q?adJfpMPnqQ+T1wM5hQqlrfxcrLJkOEMb5/SyTvomIeZHMKr3UJe4q5kC0A?= =?iso-8859-1?Q?7iuyUzIqfRgrsgXPr230HZzM72++Z7KXuweIkddLVZbx2Ypa4v19BZ8k4G?= =?iso-8859-1?Q?VRkh2hX3Soo15zx8et498aN3gydK/GheYanOCexyrRQxNo9C7kIrYKiCHc?= =?iso-8859-1?Q?h8A3X/2hQXiSfqNZGZS26yAEzE/5Fp7HF5skZ38hS98OHvuf1n3mA4oU/B?= =?iso-8859-1?Q?zhd8pYJ4q0Cpk=3D?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b957c6f7-464e-4f75-f9aa-08db40e75552 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Apr 2023 15:04:11.5866 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5BVfl5qaBpPT04lQ3dfDGS+K4NjGOTJMKx9TF/j6IxS8ArkWJOQz83mB3bXoPdQw X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7608 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,igork@ami.com X-Gm-Message-State: 8rcdPCOFXXst45sYd4K5IoIVx1787277AA= Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1681916657; bh=77ocYMF0X2R1/gR1USyU/X8YZc/F2gptZ454CoLLgRw=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=mfex0EYqBQo6wJLHwObX6yQKujGDe6o+ZjADU6+OCjTAhtBWw99VHzVa1DcUBJxAoPO rYrLf40GQULu0oInJYOXJiDLALE1Sr6UhKGFHChlet88QUcsCt/j1wTgbrn3ch5D3M7YK o1KoCYzU544byr7GoE4+o5ux7Bq1rfXcZl4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1681916658831100001 Content-Type: text/plain; charset="utf-8" gRedfishDiscoveredToken may be allocated several times, if multiple NIC installed on the system. To avoid this issue Discover Token related global variables replaced with the local variables. Cc: Abner Chang Cc: Nickle Wang Signed-off-by: Igor Kulchytskyy --- RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c | 139 +++++++= +------------ RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 87 +++++++= +---- RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h | 28 +++- 3 files changed, 140 insertions(+), 114 deletions(-) diff --git a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c b= /RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c index 993ad33..8f85491 100644 --- a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c +++ b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c @@ -22,12 +22,6 @@ EFI_HANDLE gEfiRedfishDiscoverContro= llerHandle =3D NULL; EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol =3D NUL= L; BOOLEAN gRedfishDiscoverActivated =3D FAL= SE; BOOLEAN gRedfishServiceDiscovered =3D FAL= SE; -// -// Network interfaces discovered by EFI Redfish Discover Protocol. -// -UINTN gNumberOfNetworkInterfaces; -EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *gNetworkInterfaceInstances =3D NU= LL; -EFI_REDFISH_DISCOVERED_TOKEN *gRedfishDiscoveredToken =3D NU= LL; /// /// Driver Binding Protocol instance @@ -58,13 +52,6 @@ RedfishConfigStopRedfishDiscovery ( gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent); } - // - // Stop Redfish service discovery. - // - gEfiRedfishDiscoverProtocol->AbortAcquireRedfishService ( - gEfiRedfishDiscoverProtocol, - gNetworkInterfaceInstances - ); gEfiRedfishDiscoverControllerHandle =3D NULL; gEfiRedfishDiscoverProtocol =3D NULL; gRedfishDiscoverActivated =3D FALSE; @@ -318,36 +305,39 @@ RedfishServiceDiscoveredCallback ( EFI_REDFISH_DISCOVERED_TOKEN *RedfishDiscoveredToken; EFI_REDFISH_DISCOVERED_INSTANCE *RedfishInstance; - if (gRedfishServiceDiscovered) { - // - // Only support one Redfish service on platform. - // - return; - } - RedfishDiscoveredToken =3D (EFI_REDFISH_DISCOVERED_TOKEN *)Context; - RedfishInstance =3D RedfishDiscoveredToken->DiscoverList.RedfishI= nstances; + gBS->CloseEvent (RedfishDiscoveredToken->Event); + // - // Only pick up the first found Redfish service. + // Only support one Redfish service on platform. // - if (RedfishInstance->Status =3D=3D EFI_SUCCESS) { - gRedfishConfigData.RedfishServiceInfo.RedfishServiceRestExHandle =3D R= edfishInstance->Information.RedfishRestExHandle; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceVersion =3D R= edfishInstance->Information.RedfishVersion; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceLocation =3D R= edfishInstance->Information.Location; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceUuid =3D R= edfishInstance->Information.Uuid; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceOs =3D R= edfishInstance->Information.Os; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceOsVersion =3D R= edfishInstance->Information.OsVersion; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceProduct =3D R= edfishInstance->Information.Product; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceProductVer =3D R= edfishInstance->Information.ProductVer; - gRedfishConfigData.RedfishServiceInfo.RedfishServiceUseHttps =3D R= edfishInstance->Information.UseHttps; - gRedfishServiceDiscovered =3D T= RUE; + if (!gRedfishServiceDiscovered) { + RedfishInstance =3D RedfishDiscoveredToken->DiscoverList.Redfis= hInstances; + // + // Only pick up the first found Redfish service. + // + if (RedfishInstance->Status =3D=3D EFI_SUCCESS) { + gRedfishConfigData.RedfishServiceInfo.RedfishServiceRestExHandle =3D= RedfishInstance->Information.RedfishRestExHandle; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceVersion =3D= RedfishInstance->Information.RedfishVersion; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceLocation =3D= RedfishInstance->Information.Location; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceUuid =3D= RedfishInstance->Information.Uuid; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceOs =3D= RedfishInstance->Information.Os; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceOsVersion =3D= RedfishInstance->Information.OsVersion; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceProduct =3D= RedfishInstance->Information.Product; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceProductVer =3D= RedfishInstance->Information.ProductVer; + gRedfishConfigData.RedfishServiceInfo.RedfishServiceUseHttps =3D= RedfishInstance->Information.UseHttps; + gRedfishServiceDiscovered =3D= TRUE; + } + + // + // Invoke RedfishConfigHandlerInstalledCallback to execute + // the initialization of Redfish Configure Handler instance. + // + RedfishConfigHandlerInstalledCallback (gRedfishConfigData.Event, &gRed= fishConfigData); } - // - // Invoke RedfishConfigHandlerInstalledCallback to execute - // the initialization of Redfish Configure Handler instance. - // - RedfishConfigHandlerInstalledCallback (gRedfishConfigData.Event, &gRedfi= shConfigData); + FreePool(RedfishDiscoveredToken); + } /** @@ -371,6 +361,7 @@ RedfishDiscoverProtocolInstalled ( UINTN NetworkInterfaceIndex; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; + UINTN NumberOfNetworkInterfaces; DEBUG ((DEBUG_INFO, "%a: New network interface is installed on system by= EFI Redfish discover driver.\n", __func__)); @@ -408,36 +399,31 @@ RedfishDiscoverProtocolInstalled ( } } - // - // Check the new found network interface. - // - if (gNetworkInterfaceInstances !=3D NULL) { - FreePool (gNetworkInterfaceInstances); - } Status =3D gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList ( gEfiRedfishDiscoverProtocol, gRedfishConfigData.Image, - &gNumberOfNetworkInterfaces, - &gNetworkInterfaceInstances + &NumberOfNetworkInterfaces, + &ThisNetworkInterface ); - if (EFI_ERROR (Status) || (gNumberOfNetworkInterfaces =3D=3D 0)) { + if (EFI_ERROR (Status) || (NumberOfNetworkInterfaces =3D=3D 0)) { DEBUG ((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n= ", __func__)); return; } - gRedfishDiscoveredToken =3D AllocateZeroPool (gNumberOfNetworkInterfaces= * sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); - if (gRedfishDiscoveredToken =3D=3D NULL) { + // + // Loop to discover Redfish service on each network interface. + // + for (NetworkInterfaceIndex =3D 0; NetworkInterfaceIndex < NumberOfNetwor= kInterfaces; NetworkInterfaceIndex++) { + + ThisRedfishDiscoveredToken =3D (EFI_REDFISH_DISCOVERED_TOKEN *)Allocat= eZeroPool(sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); + if (ThisRedfishDiscoveredToken =3D=3D NULL) { DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED= _TOKEN.\n", __func__)); return; } - ThisNetworkInterface =3D gNetworkInterfaceInstances; - ThisRedfishDiscoveredToken =3D gRedfishDiscoveredToken; - // - // Loop to discover Redfish service on each network interface. - // - for (NetworkInterfaceIndex =3D 0; NetworkInterfaceIndex < gNumberOfNetwo= rkInterfaces; NetworkInterfaceIndex++) { + ThisRedfishDiscoveredToken->Signature =3D REDFISH_DISCOVER_TOKEN_SIGNA= TURE; + // // Initial this Redfish Discovered Token // @@ -449,13 +435,11 @@ RedfishDiscoverProtocolInstalled ( &ThisRedfishDiscoveredToken->Event ); if (EFI_ERROR (Status)) { + FreePool(ThisRedfishDiscoveredToken); DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discove= red token.\n", __func__)); - goto ErrorReturn; + return; } - ThisRedfishDiscoveredToken->Signature =3D REDF= ISH_DISCOVER_TOKEN_SIGNATURE; - ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound =3D 0; - ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances =3D NULL; // // Acquire for Redfish service which is reported by // Redfish Host Interface. @@ -467,21 +451,23 @@ RedfishDiscoverProtocolInstalled ( EFI_REDFISH_DISCOVER_HOST_INTE= RFACE, ThisRedfishDiscoveredToken ); - ThisNetworkInterface++; - ThisRedfishDiscoveredToken++; - } - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __func__)); - goto ErrorReturn; + // + // Free Redfish Discovered Token if Discover Instance was not created = and + // Redfish Service Discovered Callback event was not triggered. + // + if(ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound =3D= =3D 0 || + EFI_ERROR(ThisRedfishDiscoveredToken->DiscoverList.RedfishInstance= s->Status)){ + gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); + DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", + __func__, ThisRedfishDiscoveredToken)); + FreePool(ThisRedfishDiscoveredToken); + } + ThisNetworkInterface++; } return; -ErrorReturn: - if (gRedfishDiscoveredToken !=3D NULL) { - FreePool (gRedfishDiscoveredToken); - } } /** @@ -498,25 +484,10 @@ RedfishConfigHandlerDriverUnload ( IN EFI_HANDLE ImageHandle ) { - EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; - UINTN NumberOfNetworkInterfacesIndex; RedfishConfigDriverCommonUnload (ImageHandle); RedfishConfigStopRedfishDiscovery (); - if (gRedfishDiscoveredToken !=3D NULL) { - ThisRedfishDiscoveredToken =3D gRedfishDiscoveredToken; - for (NumberOfNetworkInterfacesIndex =3D 0; NumberOfNetworkInterfacesIn= dex < gNumberOfNetworkInterfaces; NumberOfNetworkInterfacesIndex++) { - if (ThisRedfishDiscoveredToken->Event !=3D NULL) { - gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); - } - - FreePool (ThisRedfishDiscoveredToken); - ThisRedfishDiscoveredToken++; - } - - gRedfishDiscoveredToken =3D NULL; - } return EFI_SUCCESS; } diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 583c6f7..a6c8d60 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -1095,8 +1095,10 @@ RedfishServiceGetNetworkInterface ( { EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterfaceIn= tn; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; + EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; - if ((NetworkIntfInstances =3D=3D NULL) || (NumberOfNetworkIntfs =3D=3D N= ULL) || (ImageHandle =3D=3D NULL)) { + if ((This =3D=3D NULL) || (NetworkIntfInstances =3D=3D NULL) || (NumberO= fNetworkIntfs =3D=3D NULL) || + (ImageHandle =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } @@ -1107,14 +1109,30 @@ RedfishServiceGetNetworkInterface ( return EFI_NOT_FOUND; } + RestExInstance =3D EFI_REDFISH_DISOVER_DATA_FROM_DISCOVER_PROTOCOL(This); + + // + // Check the new found network interface. + // + if (RestExInstance->NetworkInterfaceInstances !=3D NULL) { + FreePool (RestExInstance->NetworkInterfaceInstances); + RestExInstance->NetworkInterfaceInstances =3D NULL; + } + ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *)Alloc= ateZeroPool (sizeof (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE) * mNumNetworkI= nterface); if (ThisNetworkInterface =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } *NetworkIntfInstances =3D ThisNetworkInterface; + + + RestExInstance->NetworkInterfaceInstances =3D ThisNetworkInterface; + RestExInstance->NumberOfNetworkInterfaces =3D 0; + ThisNetworkInterfaceIntn =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INT= ERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); while (TRUE) { + ThisNetworkInterface->IsIpv6 =3D FALSE; if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) { ThisNetworkInterface->IsIpv6 =3D TRUE; @@ -1130,7 +1148,7 @@ RedfishServiceGetNetworkInterface ( ThisNetworkInterface->SubnetPrefixLength =3D ThisNetworkInterfaceIntn-= >SubnetPrefixLength; ThisNetworkInterface->VlanId =3D ThisNetworkInterfaceIntn-= >VlanId; - (*NumberOfNetworkIntfs)++; + RestExInstance->NumberOfNetworkInterfaces++; if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInt= erfaceIntn->Entry)) { break; } @@ -1139,6 +1157,8 @@ RedfishServiceGetNetworkInterface ( ThisNetworkInterface++; } + *NumberOfNetworkIntfs =3D RestExInstance->NumberOfNetworkInterfaces; + return EFI_SUCCESS; } @@ -1178,7 +1198,6 @@ RedfishServiceAcquireService ( { EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance; EFI_STATUS Status1; - EFI_STATUS Status2; BOOLEAN NewInstance; UINTN NumNetworkInterfaces; UINTN NetworkInterfacesIndex; @@ -1215,7 +1234,6 @@ RedfishServiceAcquireService ( for (NetworkInterfacesIndex =3D 0; NetworkInterfacesIndex < NumNetworkIn= terfaces; NetworkInterfacesIndex++) { Status1 =3D EFI_SUCCESS; - Status2 =3D EFI_SUCCESS; NewInstance =3D FALSE; Instance =3D GetInstanceByOwner (ImageHandle, TargetNetworkInterfac= eInternal, Flags & ~EFI_REDFISH_DISCOVER_VALIDATION); // Check if we can re= -use previous instance. if (Instance =3D=3D NULL) { @@ -1223,6 +1241,7 @@ RedfishServiceAcquireService ( Instance =3D (EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *)AllocateZer= oPool (sizeof (EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE)); if (Instance =3D=3D NULL) { DEBUG ((DEBUG_ERROR, "%a:Memory allocation fail.\n", __func__)); + return EFI_OUT_OF_RESOURCES; } InitializeListHead (&Instance->Entry); @@ -1258,9 +1277,11 @@ RedfishServiceAcquireService ( DEBUG ((DEBUG_ERROR, "%a:Redfish service discovery through SSDP is n= ot supported\n", __func__)); return EFI_UNSUPPORTED; } else { - if (EFI_ERROR (Status1) && EFI_ERROR (Status2)) { - FreePool ((VOID *)Instance); - DEBUG ((DEBUG_ERROR, "%a:Something wrong on Redfish service discov= ery Status1=3D%x, Status2=3D%x.\n", __func__, Status1, Status2)); + if (EFI_ERROR (Status1)) { + if (NewInstance) { + FreePool ((VOID *)Instance); + } + DEBUG ((DEBUG_ERROR, "%a:Something wrong on Redfish service discov= ery Status1=3D%r.\n", __func__, Status1)); } else { if (NewInstance) { InsertTailList (&mRedfishDiscoverList, &Instance->Entry); @@ -1387,13 +1408,6 @@ ReleaseNext:; } } -EFI_REDFISH_DISCOVER_PROTOCOL mRedfishDiscover =3D { - RedfishServiceGetNetworkInterface, - RedfishServiceAcquireService, - RedfishServiceAbortAcquire, - RedfishServiceReleaseService -}; - /** This function create an EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL = for the given network interface. @@ -1713,12 +1727,20 @@ BuildupNetworkInterface ( NewNetworkInterfaceInstalled =3D FALSE; NetworkInterface->EfiRedfishDiscoverProtocolHandle =3D NULL; - Status =3D gBS->Inst= allProtocolInterface ( - &Net= workInterface->EfiRedfishDiscoverProtocolHandle, - &gEf= iRedfishDiscoverProtocolGuid, - EFI_= NATIVE_INTERFACE, - (VOI= D *)&mRedfishDiscover - ); + + RestExInstance->Signature =3D EFI_REDFISH_DISCOVER_DATA_SIGNATUR= E; + + RestExInstance->RedfishDiscoverProtocol.GetNetworkInterfaceList = =3D RedfishServiceGetNetworkInterface; + RestExInstance->RedfishDiscoverProtocol.AcquireRedfishService = =3D RedfishServiceAcquireService; + RestExInstance->RedfishDiscoverProtocol.AbortAcquireRedfishServi= ce =3D RedfishServiceAbortAcquire; + RestExInstance->RedfishDiscoverProtocol.ReleaseRedfishService = =3D RedfishServiceReleaseService; + + Status =3D gBS->InstallProtocolInterface ( + &NetworkInterface->EfiRedfishDiscoverProtocolHan= dle, + &gEfiRedfishDiscoverProtocolGuid, + EFI_NATIVE_INTERFACE, + (VOID *)&RestExInstance->RedfishDiscoverProtocol + ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI_REDFISH_DISCOVER= _PROTOCOL\n", __func__)); } @@ -1815,6 +1837,7 @@ StopServiceOnNetworkInterface ( EFI_HANDLE DiscoverProtocolHandle; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; + EFI_REDFISH_DISCOVER_PROTOCOL *RedfishDiscoverProtoco= l; for (Index =3D 0; Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_= DISCOVER_REQUIRED_PROTOCOL)); Index++) { Status =3D gBS->HandleProtocol ( @@ -1854,12 +1877,30 @@ StopServiceOnNetworkInterface ( // client which uses .EFI Redfish discover protocol. // if (DiscoverProtocolHandle !=3D NULL) { - gBS->DisconnectController (DiscoverProtocolHandle, NULL, NUL= L); - Status =3D gBS->UninstallProtocolInterface ( + + Status =3D gBS->HandleProtocol ( DiscoverProtocolHandle, &gEfiRedfishDiscoverProtocolGuid, - (VOID *)&mRedfishDiscover + (VOID **) &RedfishDiscoverProtocol ); + if (!EFI_ERROR (Status)) { + RestExInstance =3D EFI_REDFISH_DISOVER_DATA_FROM_DISCOVER_= PROTOCOL(RedfishDiscoverProtocol); + // + // Stop Redfish service discovery. + // + RedfishDiscoverProtocol->AbortAcquireRedfishService ( + RedfishDiscoverProtocol, + RestExInstance->NetworkInterfac= eInstances + ); + + + gBS->DisconnectController (DiscoverProtocolHandle, NULL, N= ULL); + Status =3D gBS->UninstallProtocolInterface ( + DiscoverProtocolHandle, + &gEfiRedfishDiscoverProtocolGuid, + (VOID *)&RestExInstance->RedfishDiscoverPr= otocol + ); + } } return Status; diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h index 2704cd9..ddb5f2e 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h @@ -118,16 +118,30 @@ typedef struct { } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL; // +// Redfish Discover Instance signature +// + +#define EFI_REDFISH_DISCOVER_DATA_SIGNATURE SIGNATURE_32 ('E', 'R', 'D',= 'D') + +#define EFI_REDFISH_DISOVER_DATA_FROM_DISCOVER_PROTOCOL(a) \ + CR (a, EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL, RedfishDiscoverPr= otocol, EFI_REDFISH_DISCOVER_DATA_SIGNATURE) + +// // Internal structure used to maintain REST EX properties. // typedef struct { - LIST_ENTRY Entry; ///< Link list entry. - EFI_HANDLE OpenDriverAgentHandle; ///< The agent to op= en network protocol. - EFI_HANDLE OpenDriverControllerHandle; ///< The controller = handle to open network protocol. - EFI_HANDLE RestExChildHandle; ///< The child handl= e created through REST EX Service Protocol. - EFI_HANDLE RestExControllerHandle; ///< The controller = handle which provide REST EX protocol. - EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_= REST_EX_PROTOCOL. - UINT32 RestExId; ///< The identifier = installed on REST EX controller handle. + LIST_ENTRY Entry; ///<= Link list entry. + UINT32 Signature; ///<= Instance signature. + EFI_HANDLE OpenDriverAgentHandle; ///<= The agent to open network protocol. + EFI_HANDLE OpenDriverControllerHandle; ///<= The controller handle to open network protocol. + EFI_HANDLE RestExChildHandle; ///<= The child handle created through REST EX Service Protocol. + EFI_HANDLE RestExControllerHandle; ///<= The controller handle which provide REST EX protocol. + EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///<= Pointer to EFI_REST_EX_PROTOCOL. + UINT32 RestExId; ///<= The identifier installed on REST EX controller handle. + UINTN NumberOfNetworkInterfaces; ///<= Number of network interfaces can do Redfish service discovery. + EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *NetworkInterfaceInstances; ///<= Network interface instances. It's an array of instances. The number of ent= ries + ///<= in array is indicated by NumberOfNetworkInterfaces. + EFI_REDFISH_DISCOVER_PROTOCOL RedfishDiscoverProtocol; ///<= EFI_REDFISH_DISCOVER_PROTOCOL protocol. } EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL; /** -- 2.6.1.windows.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission. -=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 (#103223): https://edk2.groups.io/g/devel/message/103223 Mute This Topic: https://groups.io/mt/98368593/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-