From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id B6C44941934 for ; Tue, 14 Nov 2023 14:28:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=xCIrQA9x0EUiVKWVzwYuBeGCQK9D9LUDTj/Z2KX3BYY=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699972102; v=1; b=ceuw9DDRpjgjVqagQaK2K4XtINsxsZ6o3LkQf/LACrkRn3uLd+clOShlhvkJNgomCsWslOhK 3VYDotA4ATLUItNeIaMXeQF0teNvTFCu+e8fCNhlLLuPPxz9p2MzzYhq1QqgllbPiWpLkMkcUbL IZ/6k0S4DlvYkhTkN7LZngNg= X-Received: by 127.0.0.2 with SMTP id nHe7YY7687511xNhWyVK3fub; Tue, 14 Nov 2023 06:28:22 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.77]) by mx.groups.io with SMTP id smtpd.web11.13795.1699972100943783332 for ; Tue, 14 Nov 2023 06:28:21 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OPsjzjX0eamG1riydnzG3lSkZgqW+0vwKlIgthGmfV9wIkNP0PrNciIn4u+QyDqdtzB6x7lh7rfRtzozINtnej3zIH+CWG/ahppxNUMKRvyAyA4H4p+u9c9WFyhb1hIC8Qxa7zkqVG2qyOXrjomlIPUWtr2EGwNx207XQX7ZJFYM9bGLf3+g6QZj4oLlqiGxKJDDm/KVDTAPmEtdGEiBavW92zxx+yRESp552ltBWSHsng6G2XeF1oxiZ6qUWd9ylgm4gpUqwcEWhpeTpQQzUdrXjYrFf2OR0WSXJc+bRQCxawOSNFVGbWgXVp9VuEoDQ94Cv44MxBjDTcUE/dylbw== 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=1tRaeGU4O6vqMMbX0uMCOLjq0wFD7e8WCoMaRu3K7oM=; b=TzcTrGow0WT1vPgGU9GlobWyGiD8kaMLHKKBp8hyCKWFU4ZFm+3coBgaj1ScNHTTk/+43JRQj6ztDqy1vzp6IM8qAwiUKm1ta4Xt4+JzYJTHBF9jDr3kvgo67nI5NpwmQVIR8RtPd3+Ran8Gsk2q3YOVamDWvTy0+ZFslO3zdVrhRTX2A69cd9QiqH5ZnA4ZDVB4N+gIaQu4acGLWjNabho/TB/Y4Ow+bwIDZRyzUBU4/ur1gPlodP0I+IB3x9F6FnUHw4v4xusFMG+BZAoaAvaOX9eSA9vtCWRiQQd1VDWnK+51riQPSgRUKaj4ifCUfluHj8wOwykL4/fYfqJiuw== 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 CO1PR10MB4594.namprd10.prod.outlook.com (2603:10b6:303:9a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.29; Tue, 14 Nov 2023 14:28:18 +0000 X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::9dc0:d4e1:1d40:3e33]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::9dc0:d4e1:1d40:3e33%4]) with mapi id 15.20.7002.015; Tue, 14 Nov 2023 14:28:18 +0000 From: "Igor Kulchytskyy via groups.io" To: "devel@edk2.groups.io" CC: Abner Chang , Nickle Wang Subject: [edk2-devel] [PATCH v5 2/2] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow Thread-Topic: [PATCH v5 2/2] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow Thread-Index: AQHaFwbPXAEHRBmyU0+CgaKub9bN4g== Date: Tue, 14 Nov 2023 14:28:18 +0000 Message-ID: <20231114142815.1604-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_|CO1PR10MB4594:EE_ x-ms-office365-filtering-correlation-id: 7b40e8d2-8e3c-434c-8dae-08dbe51df23d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 8mgwQ5+32aibway3QHiD6NYf0GcrxR+SMYafAk4fT/Mjxl71nHmyw0oZlW1YgWhFoiAZpskP91w4kW16qVYZY+OWBVF7bZNk6n9cQlH/31vsMsoTtvi61s0v2xuqRnQV9U/oGzndUScHbUMIlQpBiYOK9thFn68anGAqmCOBNHERRx8dWOOkXbStOuCUzpxUhpFQjS7L3Zu7CQOvlfjmwVPdpYbMgv+2eQl79JEKknWKQamO3alMj1Cl+DjUx5nFZl0TGvc1tdGn7qUZvV9/mQTzQKelsYmDuNOTjKl9uQh1V26G21x7XBhhax1GtalGq3nnLWK9FjQE6cx5AMe/hTf1/HHyNCkoQFbLRd3dJRhdGoqmt7dSLxsDyiXTBLL88CzWFdTKOMom8Bn4KzLzaX5ZCJPCAaVSn/A9gxYYsE1Tna93uHOCxEXeH6oHkMmNle5sWvXMVpj6ZMDf+KSDcR98O+Sbsk33iJIqTVYCYwkx46HSf/io61bGSrKqg/FXcuB074FWIHzLX4HBGe/4w12F6fKQSqW+V62ObW+1ctaRx9WULca6DEgMa4N9cyzsuRvT6gau/2EQCpfrTh9G44e0YwJZ4YwIYWU3fhWq/ZTObCW24XKBlbcubj1gIjY+ x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?klzqILTCAtyX3WX+YzullItw0xlwTEl87RZurNfwIVTthhmB9wZECzC9Ga?= =?iso-8859-1?Q?IvDK9YdP4Hr2+YLYyOAjDeSweKQ3IrJrZPaYtpq5l/hVsSnqc4viKeHDcQ?= =?iso-8859-1?Q?ETaji6cI20ks1ka1D//MyRFV0KGm72Yyi1eq10WJvPyzwsHOeOiib6yjr4?= =?iso-8859-1?Q?dG910zFr+KHHi9fdgWscxJbdkvbog6o0Jqrn2BO2idgBIctwlWWqCfKlEA?= =?iso-8859-1?Q?uHEjj1//PH/vm/48al6QMv/c/+crbqo6QSZtCA9ghu0sbuxljwKgWx4gri?= =?iso-8859-1?Q?rPxKtJl8+/3MWzfkGGAICCA/QjNp7ad7AcE3XhjyNPnujxVQ49M6Rtri8l?= =?iso-8859-1?Q?yKTeX/HtrNbxetYrA11Efrh9q64lJMytEqyyxxp471jjFTYuFhx+cKo3uC?= =?iso-8859-1?Q?xzYum0R2Ez4ZPZee5/eqqAHLaRNkKwyzyO056ulfPb6g3Um/CQ0TbndDEy?= =?iso-8859-1?Q?k4XZZpFrfZ3OKIDAd+DDU8V4S5KL08nGvFUflTKBUJyORRkRhxcUW1N4x/?= =?iso-8859-1?Q?WxaY200sGDe1RbqRzIYYW/Qzcoa9LaVPLgranHykFw5ebEPJ84OAZ1rJ4x?= =?iso-8859-1?Q?MqL+fYXsiStfIt6w1bsD2wmXpI6cbjkuVuyEyzUFZSgw8TMfpEzVsyw0PD?= =?iso-8859-1?Q?Q/rYYKDuaKeTBmEFshN6lBWFXeRpkweFn1jFpWSnoSRHl5HBwYQKsHjYio?= =?iso-8859-1?Q?XY/uxQ8Y9w3C07YZb6ALfRf1UT50dVWIFvK7H1ZWL03ncdMQJbBKtJHE4I?= =?iso-8859-1?Q?pt0BiH8rnevClpHxYBpClOryJkTO/HjeLacLRY7O3SXndtY4vtjOIpjs/Z?= =?iso-8859-1?Q?/1XOs/41eIh81CYL6xwlMxZPLrFT8aeR2sr3CM313e8EVVUKuoVzQvYyt3?= =?iso-8859-1?Q?EInbeBx4jfNU8a4f16YdtE7xzY8CzHtXJ/TTXzYKTWVc5+Hl/+6gsDGUEG?= =?iso-8859-1?Q?4B+RYsd8Aj0C2gDL2YpPUl9/d4ySOS9Itlli3gfoDgVuBtL8JFK+QmpQbr?= =?iso-8859-1?Q?sku7z5EipRcDfNmGsxNp3+d7qZDTwXLaeJWuWe20kc0ULeqI9WDHZXk3Nl?= =?iso-8859-1?Q?QNQ30jqwV5y6orpm6WjL8MxeReEiylZCgNLhXzP5nenHgWkvkq4sJOvE1E?= =?iso-8859-1?Q?dtMb8tfJ2FMlzr/a5Yaa87/qxCieDOopdL6bBeu6Rffnbp3n9FiH5PkcWU?= =?iso-8859-1?Q?GOx44TyKsqI6c1uALDb7g2v7zHphi22/jijY3GoENbs2uilrlrfpJ3UaSY?= =?iso-8859-1?Q?Bts1Y4eRvn+K1Ab3qJ4lsCqfUKTxMEbSCL+aXuU2+KMpZx5ZyFGptdYfQ3?= =?iso-8859-1?Q?sXXVxImaVIHvw3Yc6kIiRBKEV3iGdY16ffgzxjxLlU+E6B4dTtPXWTHw1U?= =?iso-8859-1?Q?Clk/so8U3VRXHv1M8KqrEWtPIW0HafjypQ2H1w0iox98ae9qDvCfiW4qPd?= =?iso-8859-1?Q?D9IX/C7zYwhgg8l7Frj8i3B+Kzs65BHgu10edHZ3rydGs5nlvJV60i1bsr?= =?iso-8859-1?Q?odY5+5+jlTE99y6jPG/YHgkgvjBo+VTs8FGkJ5pwY5R0m/+Eyf5i6JmKUa?= =?iso-8859-1?Q?/Fsr6R0PXaf3AJYvytw4tdHT78uR+ME5LYTu4Jgj/CprVKnYrqyMg7l9SS?= =?iso-8859-1?Q?ioKQcX3xzpa0gzoLTEMbmrq3bbc5xIrrps?= 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: 7b40e8d2-8e3c-434c-8dae-08dbe51df23d X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Nov 2023 14:28:18.3781 (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: EGwK9ZMHvhB2a94e1mIbanVjTAT6oRsMChrRASv9dgW28OWbBjIzgSl/2tuwbXMw X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB4594 Precedence: Bulk 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 List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6jowrPlWPjwosZNwia5wVkncx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=ceuw9DDR; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Filter out the network interfaces which are not supported by Redfish Host Interface. Cc: Abner Chang Cc: Nickle Wang Signed-off-by: Igor Kulchytskyy --- RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 163 ++++++++++++= ++------ RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h | 6 + 2 files changed, 120 insertions(+), 49 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 0f622e05a9..ae83cd3c97 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -322,9 +322,16 @@ GetTargetNetworkInterfaceInternal ( { EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; + if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { + return NULL; + } + ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNA= L *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); while (TRUE) { - if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetw= orkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) =3D=3D 0) { + if ((MAC_COMPARE (ThisNetworkInterface, TargetNetworkInterface) =3D=3D= 0) && + (VALID_TCP6 (TargetNetworkInterface, ThisNetworkInterface) || + VALID_TCP4 (TargetNetworkInterface, ThisNetworkInterface))) + { return ThisNetworkInterface; } @@ -354,6 +361,10 @@ GetTargetNetworkInterfaceInternalByController ( { EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface; + if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { + return NULL; + } + ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNA= L *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); while (TRUE) { if (ThisNetworkInterface->OpenDriverControllerHandle =3D=3D Controller= Handle) { @@ -476,6 +487,42 @@ CheckIsIpVersion6 ( return FALSE; } +/** + This function returns the IP type supported by the Host Interface. + + @retval 00h is Unknown + 01h is Ipv4 + 02h is Ipv6 + +**/ +UINT8 +GetHiIpProtocolType ( + VOID + ) +{ + EFI_STATUS Status; + REDFISH_OVER_IP_PROTOCOL_DATA *Data; + REDFISH_INTERFACE_DATA *DeviceDescriptor; + + Data =3D NULL; + DeviceDescriptor =3D NULL; + if (mSmbios =3D=3D NULL) { + Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID *= *)&mSmbios); + if (EFI_ERROR (Status)) { + return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN; + } + } + + Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescript= or, &Data); // Search for SMBIOS type 42h + if (!EFI_ERROR (Status) && (Data !=3D NULL) && + (Data->HostIpAssignmentType =3D=3D RedfishHostIpAssignmentStatic)) + { + return Data->HostIpAddressFormat; + } + + return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN; +} + /** This function discover Redfish service through SMBIOS host interface. @@ -512,6 +559,18 @@ DiscoverRedfishHostInterface ( Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescript= or, &Data); // Search for SMBIOS type 42h if (!EFI_ERROR (Status) && (Data !=3D NULL) && (DeviceDescriptor !=3D NU= LL)) { + if ((Instance->NetworkInterface->NetworkProtocolType =3D=3D ProtocolTy= peTcp4) && + (Data->HostIpAddressFormat !=3D REDFISH_HOST_INTERFACE_HOST_IP_ADD= RESS_FORMAT_IP4)) // IPv4 case + { + DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interf= ace requires Ipv6\n", __func__)); + return EFI_UNSUPPORTED; + } else if ((Instance->NetworkInterface->NetworkProtocolType =3D=3D Pro= tocolTypeTcp6) && + (Data->HostIpAddressFormat !=3D REDFISH_HOST_INTERFACE_HOST= _IP_ADDRESS_FORMAT_IP6)) // IPv6 case + { + DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interf= ace requires IPv4\n", __func__)); + return EFI_UNSUPPORTED; + } + // // Check if we can reach out Redfish service using this network interf= ace. // Check with MAC address using Device Descriptor Data Device Type 04 = and Type 05. @@ -1102,6 +1161,7 @@ RedfishServiceGetNetworkInterface ( OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE **NetworkIntfInstances ) { + EFI_STATUS Status; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterfaceIn= tn; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; @@ -1141,13 +1201,23 @@ RedfishServiceGetNetworkInterface ( ThisNetworkInterfaceIntn =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INT= ERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); while (TRUE) { + // If Get Subnet Info failed then skip this interface + Status =3D NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, Im= ageHandle); // Get subnet info + if (EFI_ERROR (Status)) { + if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkI= nterfaceIntn->Entry)) { + break; + } + + ThisNetworkInterfaceIntn =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE= _INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetwork= InterfaceIntn->Entry); + continue; + } + ThisNetworkInterface->IsIpv6 =3D FALSE; if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) { ThisNetworkInterface->IsIpv6 =3D TRUE; } CopyMem ((VOID *)&ThisNetworkInterface->MacAddress, &ThisNetworkInterf= aceIntn->MacAddress, ThisNetworkInterfaceIntn->HwAddressSize); - NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle);= // Get subnet info. if (!ThisNetworkInterface->IsIpv6) { IP4_COPY_ADDRESS (&ThisNetworkInterface->SubnetId.v4, &ThisNetworkIn= terfaceIntn->SubnetAddr.v4); // IPv4 subnet information. } else { @@ -1230,7 +1300,12 @@ RedfishServiceAcquireService ( if (TargetNetworkInterface !=3D NULL) { TargetNetworkInterfaceInternal =3D GetTargetNetworkInterfaceInternal (= TargetNetworkInterface); - NumNetworkInterfaces =3D 1; + if (TargetNetworkInterfaceInternal =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a:No network interface on platform.\n", __fun= c__)); + return EFI_UNSUPPORTED; + } + + NumNetworkInterfaces =3D 1; } else { TargetNetworkInterfaceInternal =3D (EFI_REDFISH_DISCOVER_NETWORK_INTER= FACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); NumNetworkInterfaces =3D NumberOfNetworkInterface (); @@ -1260,7 +1335,13 @@ RedfishServiceAcquireService ( // Get subnet information in case subnet information is not set beca= use // RedfishServiceGetNetworkInterfaces hasn't been called yet. // - NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, Image= Handle); + Status1 =3D NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInt= ernal, ImageHandle); + if (EFI_ERROR (Status1)) { + DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func_= _)); + FreePool (Instance); + continue; + } + NewInstance =3D TRUE; } @@ -1547,26 +1628,25 @@ TestForRequiredProtocols ( ControllerHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL ); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - - Status =3D gBS->OpenProtocol ( - ControllerHandle, - gRequiredProtocol[Index].DiscoveredProtocolGuid, - (VOID **)&Id, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); if (!EFI_ERROR (Status)) { - // Already installed - return EFI_UNSUPPORTED; + Status =3D gBS->OpenProtocol ( + ControllerHandle, + gRequiredProtocol[Index].DiscoveredProtocolGuid, + (VOID **)&Id, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + if (Index =3D=3D ListCount - 1) { + DEBUG ((DEBUG_INFO, "%a: all required protocols are found on thi= s controller handle: %p.\n", __func__, ControllerHandle)); + return EFI_SUCCESS; + } + } } } - DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on th= is controller handle: %p.\n", __func__, ControllerHandle)); - return EFI_SUCCESS; + return EFI_UNSUPPORTED; } /** @@ -1601,10 +1681,22 @@ BuildupNetworkInterface ( EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; EFI_TPL OldTpl; BOOLEAN NewNetworkInterfaceInst= alled; + UINT8 IpType; + UINTN ListCount; + ListCount =3D (sizeof (gRequiredProtocol) / sizeof (R= EDFISH_DISCOVER_REQUIRED_PROTOCOL)); NewNetworkInterfaceInstalled =3D FALSE; Index =3D 0; - do { + + // Get IP Type to filter out unnecessary network protocol if possible + IpType =3D GetHiIpProtocolType (); + + for (Index =3D 0; Index < ListCount; Index++) { + // Check IP Type and skip an unnecessary network protocol if does not = match + if (IS_TCP4_MATCH (IpType) || IS_TCP6_MATCH (IpType)) { + continue; + } + Status =3D gBS->OpenProtocol ( // Already in list? ControllerHandle, @@ -1615,11 +1707,6 @@ BuildupNetworkInterface ( EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (!EFI_ERROR (Status)) { - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCO= VER_REQUIRED_PROTOCOL))) { - break; - } - continue; } @@ -1632,11 +1719,6 @@ BuildupNetworkInterface ( EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCO= VER_REQUIRED_PROTOCOL))) { - break; - } - continue; } @@ -1695,11 +1777,6 @@ BuildupNetworkInterface ( ProtocolDiscoverIdPtr ); if (EFI_ERROR (Status)) { - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCO= VER_REQUIRED_PROTOCOL))) { - break; - } - continue; } @@ -1756,25 +1833,13 @@ BuildupNetworkInterface ( } } else { DEBUG ((DEBUG_MANAGEABILITY, "%a: Not REST EX, continue with nex= t\n", __func__)); - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_D= ISCOVER_REQUIRED_PROTOCOL))) { - break; - } - continue; } } return Status; - } else { - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCO= VER_REQUIRED_PROTOCOL))) { - break; - } - - continue; } - } while (Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_= REQUIRED_PROTOCOL))); + } return EFI_DEVICE_ERROR; } diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h index 01454acc1d..3093eea0d5 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h @@ -39,6 +39,12 @@ #define REDFISH_DISCOVER_VERSION 0x00010000 #define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY +#define MAC_COMPARE(ThisNetworkInterface, TargetNetworkInterface) (Compar= eMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->M= acAddress, ThisNetworkInterface->HwAddressSize)) +#define VALID_TCP6(TargetNetworkInterface, ThisNetworkInterface) (Target= NetworkInterface->IsIpv6 && (ThisNetworkInterface->NetworkProtocolType =3D= =3D ProtocolTypeTcp6)) +#define VALID_TCP4(TargetNetworkInterface, ThisNetworkInterface) (!Targe= tNetworkInterface->IsIpv6 && (ThisNetworkInterface->NetworkProtocolType =3D= =3D ProtocolTypeTcp4)) +#define IS_TCP4_MATCH(IpType) ((gRequ= iredProtocol[Index].ProtocolType =3D=3D ProtocolTypeTcp4) && (IpType !=3D R= EDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4)) +#define IS_TCP6_MATCH(IpType) ((gRequ= iredProtocol[Index].ProtocolType =3D=3D ProtocolTypeTcp6) && (IpType !=3D R= EDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6)) + // // GUID definitions // -- 2.37.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 (#111197): https://edk2.groups.io/g/devel/message/111197 Mute This Topic: https://groups.io/mt/102584140/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-