From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.71]) by mx.groups.io with SMTP id smtpd.web10.764.1682035844904344857 for ; Thu, 20 Apr 2023 17:10:45 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=N20V27Ng; 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.223.71, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=czcSKwOCioLH++zGg9DWzdxcM57GF7woLr9/ViMTndyqVLVyFpoyMTiZ32beY+uxbFghoUl0fj2KX6vExzM7pn1mdUZuODNG3K711eZt06I1WE1Td+ZdOTliPhH1lezJooHfAKX/fCR8PUz9/bkKCYPzreb6Tte6f1rmtLXhec8ljubhgLujVOlVGXR4qTPKLHWe8NP3awzJ3hZ5STmLPT+d2huIvWIWQXkKGqm95koCypL/2lHMml+OXMzLHWyQmcld1szRvI/n9SjlEofhcJmknk005gizSnQamFmmIarfACYI/OjqjNg+3h3iRQuj9kL7gUBELBhwq2gDu2/FPA== 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=rJhpUV2MN37q82PPY6S2GxwHaAQ+ovizx/BzZvTupgc=; b=MDzzDaFcbC/jwHgY4t3CUVZAskqztL4ucsqYIfMSYh3Yy5suK5PJ8+9tUsZGiBE2Pc+YeDZnlvPBNjIRqh8RAyFYPZPhxeSjWO8OALCEXcD+NUXo62vqjLlxS6xopj1YGSXzxmrOreE9wylKXmsmJm5zUeoYwENk4qZMLtDEB0pr9zMNdIW6VQvNQjgG0dGJdvu8RG3sw6MnGs53oeyJDbtgN0XxiAq15aH68hylzcLTRN9ntaQzFDFpKQGNllPyw8czWNkX7bfVNTz7aOIvltytWbIDAI2e0Yj+tpcwrAQWie46r9BHAB4Iwg82rlM6raJdhaUqxGXG3gWgI2NtMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=rJhpUV2MN37q82PPY6S2GxwHaAQ+ovizx/BzZvTupgc=; b=N20V27NgAL6MIQrcTNTu7GUmV3EplPd/lEjKVULCfOEs7MmsLHPMl/h8M3lOUz3ZOh0m2xhXQStqxbEqOMuY8y5bVgfkesGCqarrghSbPHGKQyRblsNHM8fAdIt3/tMVC36nbMl7i74hlnco8H0pQajJccWm8s+85um8rsLQjxE= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by CH2PR12MB4152.namprd12.prod.outlook.com (2603:10b6:610:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Fri, 21 Apr 2023 00:10:42 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::46f1:bdce:a4bc:29e3%3]) with mapi id 15.20.6319.022; Fri, 21 Apr 2023 00:10:41 +0000 From: "Chang, Abner" To: Igor Kulchytskyy , "devel@edk2.groups.io" CC: Nickle Wang Subject: Re: [PATCH V2] RedfishPkg: Remove the Discover Token global variables Thread-Topic: [PATCH V2] RedfishPkg: Remove the Discover Token global variables Thread-Index: AQHZc9osnqIepGtfo024iNPmDDdI2K8047Cw Date: Fri, 21 Apr 2023 00:10:41 +0000 Message-ID: References: <20230420224759.925-1-igork@ami.com> In-Reply-To: <20230420224759.925-1-igork@ami.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-04-21T00:10:39Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=a11ab748-eb9b-42c0-a25e-f5c48b96705f; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|CH2PR12MB4152:EE_ x-ms-office365-filtering-correlation-id: 5bf4d9f3-5bfc-4099-bf93-08db41fcd817 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nbgjFNQhvva9C9d+v8pl4GI91O4cYEC6V5x6fXxR6AWZojsHoRMU2GoT3jG0M00Gpj/T+hmRsWNcTkjAnGty/lNfMDMOoRlS+hEMyNMeU5xn6+dpwzxz2q0dnSaJmNzYEPRbYq2B7Ca3Vl0CKdKc6CVkhNDHGhxT0vSYOUojcJql4tLV1DsJ8NKBJTYHzaK3do2Nm/kWqW8RpKzb5tiOkuVMKKE9LatdUrNybAlodLZgt/qlmubsyOf0kNyZJtEn0dMOGSU4oQdFClHxIf9Iza7BhETUxpZNN1tjO5S34aUkj6HgZwniv8jknyTxyaV4D0ecFlExMO2oRX3MBMqMV93xbu9oy//7hc1E1RQQIW6SmhkIcUB/uFuwKHyIAKq5uabiBZJFPZ7enfqrnxD90bkaHxgoKKc9P8tKq6vXmmmY3cGWTUKt5HzC9htOhlUGKWPRRNhPLCAL8YKLhE/zW/NpU12bv2IjhdRarXVkDYFC5GfO/X4S1Z9Mhxcxi2INglAkx4tt6cKeNrMORqKq6NHy8WNmcWqL15MvqsTOrt9f2jJNIuOr3HxzUgIGXcBy/AVZ4tZPFLTM0iAAV+khq3ZTSnlXz/PGXx+RtgaxH96K+0/3rnGRiwiPDe/XmOGUgPhI/IqtNyXS/ZhQh+zx2g== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(396003)(39860400002)(346002)(136003)(451199021)(30864003)(2906002)(38070700005)(38100700002)(8936002)(8676002)(52536014)(5660300002)(55016003)(86362001)(33656002)(40140700001)(7696005)(71200400001)(26005)(6506007)(110136005)(478600001)(9686003)(83380400001)(53546011)(186003)(66476007)(66946007)(316002)(66556008)(41300700001)(66446008)(122000001)(4326008)(76116006)(64756008)(579004)(559001)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?aSHHAtDjIdmcHX3SYWowr/yC0P1ttiq3a5pNGCUMuOIB8bSh17iNlREKqm7w?= =?us-ascii?Q?hXUutsQ+XmcLHaDpMz8S8DZRQUOOlftp5GxCAcH+zBfIGxh2CZoe2CublPoy?= =?us-ascii?Q?/dNEvEwwL3ccLP/iyBRyUnXG00Df+CptcTrJWfrRelzcru+NGXhcG4Hgjxnh?= =?us-ascii?Q?JD1Lqtawiy+XLQbOo1xI1g4zb8OHtT9cKV/wUuDVJCEK4ioUBTiixIQl2A1u?= =?us-ascii?Q?+mcXasZDEq60Yrj0ZOq9FITVVMvgIAy0g4FDEATJrjpZ45eq3O3CCFHpDVUl?= =?us-ascii?Q?zq4Ias44BmMydJR38fLTDIGArGcZX3CxAgUJFfkYg3qfSJsfXH98JiUvJu23?= =?us-ascii?Q?meXYzQUc/ZKweDP5OtKlARGt+kjm0x7rQh6+zScioPgqZlzb1RxqTcRTf2Fq?= =?us-ascii?Q?+FP4bC4unQjLlfc+0MtfS6bHxqxrKLGDsXxVTQnYENe3RobIEa3KmqJ4ptK4?= =?us-ascii?Q?+TjmI+3RCObH0/UQrvOvL0hHVKjwteB3bV6g+pA965NhSjG/+zPdTc9i4m0b?= =?us-ascii?Q?YfdCFcEIdXL8JnyQdS6fn4/z2IKw0T3glILXXv8sfS1fzKN9zjluXO33pQgd?= =?us-ascii?Q?bA+VXCUxP1hfvldMtuuHo2bCWxsR6FDym0v9x1UUsNNfiYsmp1r6jd37r3Pn?= =?us-ascii?Q?R+igSXKs4dq2N8Pu7U+7eL4ElsL3f0UnTA0yIDdaT55sC2h8LkRS/AsFdh8A?= =?us-ascii?Q?KE2E8nnwqdIw52gPd0OBbVrSPu8b+kfZgmXdYQsQzeFEhZfo6LG+WXYWpDGB?= =?us-ascii?Q?KBbnOdBuNrHlRQVPJNd9uiS6ZXP6K8QxCenRNoFX0VxywmmZPKj5gLQh2NVt?= =?us-ascii?Q?otU3mje7TS7OrPn2YxZD2fpaERm3isLrcOnKYqM1b3pkG2hzGCqsE1BP3goL?= =?us-ascii?Q?NRG+5z/0RvlIwntH7Y3BTQTNz9I9JMItCO8Ficz6gaNeoQOgk5s9WPhYXd9T?= =?us-ascii?Q?UqwTAtPEHnALcxObLoqszL+GWy2AEz859CY/d9D3PTmgkO5oLThoWzJcRq8H?= =?us-ascii?Q?g/v+/FxlpeL5q8/SS+SsDMeU0KgzyMtOVhnFg3mohAXq0t6an4+CU2UJ25Aq?= =?us-ascii?Q?WpxW7Uj77XbWJcshjIvHoUDkKjsOtRX9MVtgng5BRcQcg1m+N2YAbNU9IA1U?= =?us-ascii?Q?ZDiuy1p47vux5EDvSsmAC/oc46R7tm97wphEe0m8Uvcd+33EDHwxrhaWTGHY?= =?us-ascii?Q?sNpQDKjEL5AxzQOiMI52qvQEpjyn+1cn7hgQRPWv1QAswfR+zsyLe/WjNlXW?= =?us-ascii?Q?6gpUEG7JwdmD55u3cT4PW7mkeKuNRL0HshXEzGJuL5YofFXoisf82fTCZnGs?= =?us-ascii?Q?/b41xnb4XFxRgHMIQkRFrRDxyw0KkQWTmWALv4u7vUtwHEz86DOzzcmsX9YQ?= =?us-ascii?Q?Z3tWQP2fj74LwC8GOFKus0vF+9wjxOhL2fbOU9W9SxN0G+EXv4qPyaDjV2wA?= =?us-ascii?Q?qwqiKH8BUahA2sBnVDlerU0o+YvkFTABZCtAp2MpWHjQn5OttbZXim/p+lmK?= =?us-ascii?Q?peMuqCwom6wnC59Tr3SOYQ60LkvHO1sLL6VdGoI/ZF3wG1dMBqAJD0OXPFn9?= =?us-ascii?Q?U9rHz/D09g+IIlBMnDgKKGXQX555vxImrmV63sN/?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bf4d9f3-5bfc-4099-bf93-08db41fcd817 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Apr 2023 00:10:41.6012 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: CzRXPidiJOkmMFP7XsBUvx64/IjLtNXXEppe+1EY4jlcc241citpztGDNJdeiA+yvkS0d8OhB7NGycWMmKqPqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4152 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Igor Kulchytskyy > Sent: Friday, April 21, 2023 6:48 AM > To: devel@edk2.groups.io > Cc: Chang, Abner ; Nickle Wang > > Subject: [PATCH V2] RedfishPkg: Remove the Discover Token global variable= s >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > 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. >=20 > Cc: Abner Chang > Cc: Nickle Wang > Cc: Igor Kulchytskyy > Signed-off-by: Igor Kulchytskyy > --- > RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c | 143 > ++++++++------------ > RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 88 +++++= +++- > --- > RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h | 28 +++- > 3 files changed, 140 insertions(+), 119 deletions(-) >=20 > diff --git a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > index 993ad338b6..161731b211 100644 > --- a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > +++ b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c > @@ -22,12 +22,6 @@ EFI_HANDLE > gEfiRedfishDiscoverControllerHandle =3D NULL; > EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol =3D > NULL; > BOOLEAN gRedfishDiscoverActivated =3D F= ALSE; > BOOLEAN gRedfishServiceDiscovered =3D F= ALSE; > -// > -// Network interfaces discovered by EFI Redfish Discover Protocol. > -// > -UINTN gNumberOfNetworkInterfaces; > -EFI_REDFISH_DISCOVER_NETWORK_INTERFACE > *gNetworkInterfaceInstances =3D NULL; > -EFI_REDFISH_DISCOVERED_TOKEN *gRedfishDiscoveredToken =3D > NULL; >=20 > /// > /// Driver Binding Protocol instance > @@ -58,13 +52,6 @@ RedfishConfigStopRedfishDiscovery ( > gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent); > } >=20 > - // > - // Stop Redfish service discovery. > - // > - gEfiRedfishDiscoverProtocol->AbortAcquireRedfishService ( > - gEfiRedfishDiscoverProtocol, > - gNetworkInterfaceInstances > - ); > gEfiRedfishDiscoverControllerHandle =3D NULL; > gEfiRedfishDiscoverProtocol =3D NULL; > gRedfishDiscoverActivated =3D FALSE; > @@ -318,36 +305,38 @@ RedfishServiceDiscoveredCallback ( > EFI_REDFISH_DISCOVERED_TOKEN *RedfishDiscoveredToken; > EFI_REDFISH_DISCOVERED_INSTANCE *RedfishInstance; >=20 > - if (gRedfishServiceDiscovered) { > - // > - // Only support one Redfish service on platform. > - // > - return; > - } > - > RedfishDiscoveredToken =3D (EFI_REDFISH_DISCOVERED_TOKEN *)Context; > - RedfishInstance =3D RedfishDiscoveredToken- > >DiscoverList.RedfishInstances; > + 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 > 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; > + if (!gRedfishServiceDiscovered) { > + RedfishInstance =3D RedfishDiscoveredToken- > >DiscoverList.RedfishInstances; > + // > + // 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, > + &gRedfishConfigData); > } >=20 > - // > - // Invoke RedfishConfigHandlerInstalledCallback to execute > - // the initialization of Redfish Configure Handler instance. > - // > - RedfishConfigHandlerInstalledCallback (gRedfishConfigData.Event, > &gRedfishConfigData); > + FreePool (RedfishDiscoveredToken); > } >=20 > /** > @@ -371,6 +360,7 @@ RedfishDiscoverProtocolInstalled ( > UINTN NetworkInterfaceIndex; > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; > EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; > + UINTN NumberOfNetworkInterfaces; >=20 > DEBUG ((DEBUG_INFO, "%a: New network interface is installed on system > by EFI Redfish discover driver.\n", __func__)); >=20 > @@ -408,36 +398,29 @@ RedfishDiscoverProtocolInstalled ( > } > } >=20 > - // > - // 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; > } >=20 > - gRedfishDiscoveredToken =3D AllocateZeroPool > (gNumberOfNetworkInterfaces * sizeof > (EFI_REDFISH_DISCOVERED_TOKEN)); > - if (gRedfishDiscoveredToken =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 < > gNumberOfNetworkInterfaces; NetworkInterfaceIndex++) { > + for (NetworkInterfaceIndex =3D 0; NetworkInterfaceIndex < > NumberOfNetworkInterfaces; NetworkInterfaceIndex++) { > + ThisRedfishDiscoveredToken =3D (EFI_REDFISH_DISCOVERED_TOKEN > *)AllocateZeroPool (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; > + } > + > + ThisRedfishDiscoveredToken->Signature =3D > + REDFISH_DISCOVER_TOKEN_SIGNATURE; > + > // > // Initial this Redfish Discovered Token > // > @@ -449,13 +432,11 @@ RedfishDiscoverProtocolInstalled ( > &ThisRedfishDiscoveredToken->Event > ); > if (EFI_ERROR (Status)) { > + FreePool (ThisRedfishDiscoveredToken); > DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish > discovered token.\n", __func__)); > - goto ErrorReturn; > + return; > } >=20 > - ThisRedfishDiscoveredToken->Signature =3D > REDFISH_DISCOVER_TOKEN_SIGNATURE; > - ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound =3D 0; > - ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances =3D NU= LL; > // > // Acquire for Redfish service which is reported by > // Redfish Host Interface. > @@ -467,21 +448,23 @@ RedfishDiscoverProtocolInstalled ( > EFI_REDFISH_DISCOVER_HOST_IN= TERFACE, > ThisRedfishDiscoveredToken > ); > - ThisNetworkInterface++; > - ThisRedfishDiscoveredToken++; > - } >=20 > - 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 create= d > and > + // Redfish Service Discovered Callback event was not triggered. > + // > + if ((ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound > =3D=3D 0) || > + EFI_ERROR (ThisRedfishDiscoveredToken- > >DiscoverList.RedfishInstances->Status)) > + { > + gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); > + DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", > __func__, ThisRedfishDiscoveredToken)); > + FreePool (ThisRedfishDiscoveredToken); > + } > + > + ThisNetworkInterface++; > } >=20 > return; > - > -ErrorReturn: > - if (gRedfishDiscoveredToken !=3D NULL) { > - FreePool (gRedfishDiscoveredToken); > - } > } >=20 > /** > @@ -498,25 +481,9 @@ RedfishConfigHandlerDriverUnload ( > IN EFI_HANDLE ImageHandle > ) > { > - EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; > - UINTN NumberOfNetworkInterfacesIndex; > - > RedfishConfigDriverCommonUnload (ImageHandle); >=20 > RedfishConfigStopRedfishDiscovery (); > - if (gRedfishDiscoveredToken !=3D NULL) { > - ThisRedfishDiscoveredToken =3D gRedfishDiscoveredToken; > - for (NumberOfNetworkInterfacesIndex =3D 0; > NumberOfNetworkInterfacesIndex < gNumberOfNetworkInterfaces; > NumberOfNetworkInterfacesIndex++) { > - if (ThisRedfishDiscoveredToken->Event !=3D NULL) { > - gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); > - } > - > - FreePool (ThisRedfishDiscoveredToken); > - ThisRedfishDiscoveredToken++; > - } > - > - gRedfishDiscoveredToken =3D NULL; > - } >=20 > return EFI_SUCCESS; > } > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > index 583c6f78e1..a56e2406aa 100644 > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > @@ -1095,8 +1095,11 @@ RedfishServiceGetNetworkInterface ( { > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL > *ThisNetworkInterfaceIntn; > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE > *ThisNetworkInterface; > + EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; >=20 > - if ((NetworkIntfInstances =3D=3D NULL) || (NumberOfNetworkIntfs =3D=3D= NULL) > || (ImageHandle =3D=3D NULL)) { > + if ((This =3D=3D NULL) || (NetworkIntfInstances =3D=3D NULL) || > (NumberOfNetworkIntfs =3D=3D NULL) || > + (ImageHandle =3D=3D NULL)) > + { > return EFI_INVALID_PARAMETER; > } >=20 > @@ -1107,12 +1110,26 @@ RedfishServiceGetNetworkInterface ( > return EFI_NOT_FOUND; > } >=20 > + 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 > *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE) > * mNumNetworkInterface); > if (ThisNetworkInterface =3D=3D NULL) { > return EFI_OUT_OF_RESOURCES; > } >=20 > - *NetworkIntfInstances =3D ThisNetworkInterface; > + *NetworkIntfInstances =3D ThisNetworkInterface; > + > + RestExInstance->NetworkInterfaceInstances =3D ThisNetworkInterface; > + RestExInstance->NumberOfNetworkInterfaces =3D 0; > + > ThisNetworkInterfaceIntn =3D > (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode > (&mEfiRedfishDiscoverNetworkInterface); > while (TRUE) { > ThisNetworkInterface->IsIpv6 =3D FALSE; @@ -1130,7 +1147,7 @@ > RedfishServiceGetNetworkInterface ( >=20 > ThisNetworkInterface->SubnetPrefixLength =3D ThisNetworkInterfaceInt= n- > >SubnetPrefixLength; > ThisNetworkInterface->VlanId =3D ThisNetworkInterfaceInt= n->VlanId; > - (*NumberOfNetworkIntfs)++; > + RestExInstance->NumberOfNetworkInterfaces++; > if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, > &ThisNetworkInterfaceIntn->Entry)) { > break; > } > @@ -1139,6 +1156,8 @@ RedfishServiceGetNetworkInterface ( > ThisNetworkInterface++; > } >=20 > + *NumberOfNetworkIntfs =3D RestExInstance- > >NumberOfNetworkInterfaces; > + > return EFI_SUCCESS; > } >=20 > @@ -1178,7 +1197,6 @@ RedfishServiceAcquireService ( { > EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance; > EFI_STATUS Status1; > - EFI_STATUS Status2; > BOOLEAN NewInstance; > UINTN NumNetworkInterfaces; > UINTN NetworkInterfacesInde= x; > @@ -1215,7 +1233,6 @@ RedfishServiceAcquireService ( >=20 > for (NetworkInterfacesIndex =3D 0; NetworkInterfacesIndex < > NumNetworkInterfaces; NetworkInterfacesIndex++) { > Status1 =3D EFI_SUCCESS; > - Status2 =3D EFI_SUCCESS; > NewInstance =3D FALSE; > Instance =3D GetInstanceByOwner (ImageHandle, > TargetNetworkInterfaceInternal, Flags & > ~EFI_REDFISH_DISCOVER_VALIDATION); // Check if we can re-use previous > instance. > if (Instance =3D=3D NULL) { > @@ -1223,6 +1240,7 @@ RedfishServiceAcquireService ( > Instance =3D (EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE > *)AllocateZeroPool (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; > } >=20 > InitializeListHead (&Instance->Entry); @@ -1258,9 +1276,12 @@ > RedfishServiceAcquireService ( > DEBUG ((DEBUG_ERROR, "%a:Redfish service discovery through SSDP is > not 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 > discovery 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 > + discovery Status1=3D%r.\n", __func__, Status1)); > } else { > if (NewInstance) { > InsertTailList (&mRedfishDiscoverList, &Instance->Entry); @@ -= 1387,13 > +1408,6 @@ ReleaseNext:; > } > } >=20 > -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 ( >=20 > NewNetworkInterfaceInstalled =3D FALSE; > NetworkInterface->EfiRedfishDiscoverProtocolHandle =3D NULL; > - Status =3D gBS->In= stallProtocolInterface ( > - &N= etworkInterface- > >EfiRedfishDiscoverProtocolHandle, > - &g= EfiRedfishDiscoverProtocolGuid, > - EF= I_NATIVE_INTERFACE, > - (V= OID *)&mRedfishDiscover > - ); > + > + RestExInstance->Signature =3D > + EFI_REDFISH_DISCOVER_DATA_SIGNATURE; > + > + RestExInstance->RedfishDiscoverProtocol.GetNetworkInterfaceLis= t =3D > RedfishServiceGetNetworkInterface; > + RestExInstance->RedfishDiscoverProtocol.AcquireRedfishService = =3D > RedfishServiceAcquireService; > + RestExInstance->RedfishDiscoverProtocol.AbortAcquireRedfishSer= vice > =3D RedfishServiceAbortAcquire; > + RestExInstance->RedfishDiscoverProtocol.ReleaseRedfishService = =3D > RedfishServiceReleaseService; > + > + Status =3D gBS->InstallProtocolInterface ( > + &NetworkInterface->EfiRedfishDiscoverProtocolH= andle, > + &gEfiRedfishDiscoverProtocolGuid, > + EFI_NATIVE_INTERFACE, > + (VOID *)&RestExInstance->RedfishDiscoverProtoc= ol > + ); > if (EFI_ERROR (Status)) { > DEBUG ((DEBUG_ERROR, "%a: Fail to install > EFI_REDFISH_DISCOVER_PROTOCOL\n", __func__)); > } > @@ -1815,6 +1837,7 @@ StopServiceOnNetworkInterface ( > EFI_HANDLE DiscoverProtocolHandl= e; > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL > *ThisNetworkInterface; > EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; > + EFI_REDFISH_DISCOVER_PROTOCOL *RedfishDiscoverProto= col; >=20 > for (Index =3D 0; Index < (sizeof (gRequiredProtocol) / sizeof > (REDFISH_DISCOVER_REQUIRED_PROTOCOL)); Index++) { > Status =3D gBS->HandleProtocol ( > @@ -1854,12 +1877,29 @@ StopServiceOnNetworkInterface ( > // client which uses .EFI Redfish discover protocol. > // > if (DiscoverProtocolHandle !=3D NULL) { > - gBS->DisconnectController (DiscoverProtocolHandle, NULL, N= ULL); > - 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->NetworkInterf= aceInstances > + ); > + > + > + gBS->DisconnectController (DiscoverProtocolHandle, NULL,= NULL); > + Status =3D gBS->UninstallProtocolInterface ( > + DiscoverProtocolHandle, > + &gEfiRedfishDiscoverProtocolGuid, > + (VOID *)&RestExInstance->RedfishDiscover= Protocol > + ); > + } > } >=20 > return Status; > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h > b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h > index 2704cd955d..d24c4081d9 100644 > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h > @@ -117,17 +117,31 @@ typedef struct { > = ///< on this network interface. > } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL; >=20 > +// > +// 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, > +RedfishDiscoverProtocol, EFI_REDFISH_DISCOVER_DATA_SIGNATURE) > + > // > // Internal structure used to maintain REST EX properties. > // > typedef struct { > - LIST_ENTRY Entry; ///< Link list ent= ry. > - EFI_HANDLE OpenDriverAgentHandle; ///< The agent to = open > network protocol. > - EFI_HANDLE OpenDriverControllerHandle; ///< The controlle= r handle > to open network protocol. > - EFI_HANDLE RestExChildHandle; ///< The child han= dle created > through REST EX Service Protocol. > - EFI_HANDLE RestExControllerHandle; ///< The controlle= r handle > which provide REST EX protocol. > - EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to > EFI_REST_EX_PROTOCOL. > - UINT32 RestExId; ///< The identifie= r 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 arr= ay > of instances. The number of entries > + = ///< in array is indicated by > NumberOfNetworkInterfaces. > + EFI_REDFISH_DISCOVER_PROTOCOL RedfishDiscoverProtocol; = ///< > EFI_REDFISH_DISCOVER_PROTOCOL protocol. > } EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL; >=20 > /** > -- > 2.37.1.windows.1 > -The information contained in this message may be confidential and > proprietary 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 > designee. If the reader of this message is not the intended recipient, yo= u are > on notice that any distribution of this message, in any form, is strictly > prohibited. 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.