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 C3892940F50 for ; Thu, 16 Nov 2023 02:37:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=JD4g+PL8ft1p1c30cOeIPwE09w6liDGUgyUkpbv+SsY=; 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=1700102221; v=1; b=tzizX3b3dSpmvtnpz1xXbXok3cmpB7EA00wuY1mE7A5mNlgL1FcjPW+enmpdy7iV8J/KZCK0 kYyEAAkrHWo9XvcByvYGfJgZ7DLxt9kD7LPyLPwZd26crnrGP7BN8TBSLVRiBiW2L+FaslwmEtc Gtc//JWN4cid9H0bR1Cs3vcM= X-Received: by 127.0.0.2 with SMTP id Xr6CYY7687511xNRKr4tEtn7; Wed, 15 Nov 2023 18:37:01 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.60]) by mx.groups.io with SMTP id smtpd.web11.31747.1700102220727467691 for ; Wed, 15 Nov 2023 18:37:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b2ddVtYJOyVvEhEFwyWTIS0HxHpJcinD0dWtER6Bq99caKcXP8dllytZoZ9rW2oZ6yU+2LUyhzvFLmH9E2kCLiyZjAoAEoWlQwzY4idM5nGJkdUeX3EHYQSflYBlGJvSuYPTgxEEccMEGdm/5FWTiXROP9tjHJadaQtbp6e3dw02CRprlFxJTkOVlRGSXuzNVFnGplS8Zbx2BgJUSPWu8kTJB2aH91diicId17eEAc76vY37ZXpz8QlpbmdBgSplropIE8t9pIs+iaHttdkjwV2KHIOpUzDLbVE89QdotAs3LMQkmZo5ZJs2ryXBPgmVA+qs0D71n6JdlYfyZpUuNw== 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=r0epoMP2FFlaVZir95mI4Z9sSU1ruU4MtJyCnazQ2CM=; b=knNzmKqPFSk/Eazw+OVCbzeS7GawMLQngEUCGrN61UNLi9OUBfsC2V1GmRfZNwUZezlG191RQWjlA8VEb/xPnZ8qlrWGI/P7c3DqZ4YwrixwPkfLHfKUzM77rFX3mAy2bWplaTzwkmmecSAv6g1IYKBcQc6zabjQvRIVDmi3NnGNY329nWs9OZ3V8WPnzBrb/JqZGzLcH6KDX78jeaYTzUSshrcCQlNqNt0YnFNQN6X4OwB4e17uBuI3Arl17rH0Vzc0UyQDcXcV7uIyTbVHgD8I6epiO8G00KGnNKMINlzIhX5u8dfSrnGW13XoQ+SSxzklV40hZhWovXtSm3e22Q== 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 SJ0PR10MB5672.namprd10.prod.outlook.com (2603:10b6:a03:3ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.18; Thu, 16 Nov 2023 02:36:58 +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.021; Thu, 16 Nov 2023 02:36:58 +0000 From: "Igor Kulchytskyy via groups.io" To: "devel@edk2.groups.io" CC: Abner Chang , Nickle Wang , Mike Maslenkin Subject: [edk2-devel] [PATCH v6 2/2] [edk2-stable202311] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow Thread-Topic: [PATCH v6 2/2] [edk2-stable202311] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow Thread-Index: AQHaGDXF49rcpWJ4g0enibz8x9vOTg== Date: Thu, 16 Nov 2023 02:36:58 +0000 Message-ID: <20231116023656.115-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_|SJ0PR10MB5672:EE_ x-ms-office365-filtering-correlation-id: 59304149-49ae-4433-5f17-08dbe64ce7bf x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: yqi5/CYS3zmwTio9POvd8uXn/65e53oM4kAeoHpjOU9TXu02NUs8IymfXEZJIMVGEjnvHpJLQhMam/ja3j2hjstaMomhb6GCBgfqpteqo8Clkj2k0bBnJyXd+fChANyvwwy3FX8OA0ldj1TXZemRSo2ghrr90BVzFFd5nm22k1eix6rL78VWg6FGZZJzGfGluLH9JDQLrjlXhV88LT+7J2XilupUo7m7NFzXJSWKrMOdAKbJBtwonPN3YGWV5r5ZOJLsXcmcbegAdIcHIhnBwsOXv6vUSDru9ytnYifSLcaWSiDhIraR8HTOwPBzO5blwYChjpAlAt3fcJNbQH9Oj3HyaOgDhH/WmW+IMuSa3TY29VJ4ZX7y03z2+r9PuQx946nGFqNUXswV80Pk7lH3NLhV9HyDGK72tqf78qTuZekvEvsesZL7oP3YEFHKmsRtwRueZgkDqmIRxXGVt+ymXV1ZLIHZqUY9UVmq8YQXuEm6m857oRvg6Rcs5STcpigWCEXaODC2Cq9ymoJxfMMb8ssq/AvL2NivpC8U29DAeTPQfBqTCH7ruwsyomvp6FLxe1rKeniwXklrzH/HTUns/xWPKZYayNHEQKOdfKHrKPdphkKu8OaFQZTJU4F7xJDX x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?fXPw2p5v5W+pQGhR29PcwgYuWCcQvKCkXt8MBzAH8phVw43hqbwqllgxhV?= =?iso-8859-1?Q?WvQmfuGdvAOl1JufpM/E5bYvO6VsEjafjlKEJGs6vslGQ5D8bDmKLX8QDw?= =?iso-8859-1?Q?+tf6LoB66mB/ph0xHK6Ds3UfMC/qtXnbHI+I71DTZ2i65VdNwUsdJy3wvq?= =?iso-8859-1?Q?Skw+sE9NUBtFHnMCYVn71g0v/Ou7C5qQKGY3id1llwOCb4qrCFIqNORoi2?= =?iso-8859-1?Q?Na+u6N780iWTXWKKfdUehx0tYWvcGmyXIj88nOld9ASnww51iYgrqpfQzU?= =?iso-8859-1?Q?I8qaHI1jsP5fydLsaq+pXl3+MkyFXhq7jPcKkAz7pvkGRsOXNhkBytco0x?= =?iso-8859-1?Q?miTatrrmDCX2Ge7mLzWtQAw6vCuCjxbVzsTyOnStaxXWwzwJg4h36KfNQi?= =?iso-8859-1?Q?6mP+TSMHCg+UUmUc96ZfuVElaMO0q0Yp6+qfeuyh4nNqkqTTfSmqPMEhRj?= =?iso-8859-1?Q?tK7Eyh3MZ+JlFLFlEbCQurYib5wJzY6ksZjrd8fixwI1BmaTlB/aCB4NJj?= =?iso-8859-1?Q?3muRXbn/OhyJgvQUJmC5KBfha5DXm28YFkDFGevnMJFVRBFmp+8NnaOO79?= =?iso-8859-1?Q?h0Ivf4onrP94QPsMmE0BN3MO1nt05dwKBo56Qwy5gbzijukzToRaF2tb2y?= =?iso-8859-1?Q?FpU4xvaeMF6MgQZPHFT4fYWJkw2g5fbPzjZknwBEFxhLDqAkxHtTAnvwFD?= =?iso-8859-1?Q?8PNNVZfWAOXo2jfI4kpKdBYbTOllV6Kfcq7i3lUrETDDsdQ4nDZWboV+LZ?= =?iso-8859-1?Q?5YSnc3QesbyeayOr1mpGNybjOzLeQ0YlwY4oG8HBBvTI0ts7D86b+noytg?= =?iso-8859-1?Q?EkV2jn+IF7H3bBTkhJQzhTmgcRqQYj2DdymLdCoU+GYBcyGVJh6llZl5xg?= =?iso-8859-1?Q?/IRfT1cuDxCYc7SFcOdAwYFHx3kNflZh/HQepGGiqWfnrDzjotWsLM04F6?= =?iso-8859-1?Q?z0lELQNJQALDYXI3DQGhX+B18TQw72Y2kxmMSOBJxqaqFOwGPsDMhFvoO1?= =?iso-8859-1?Q?Ehz9++GBpvYIXUUSGKGBGL2zngglHHgIVc+OZF3UQgsFXz4TggoHjX6opo?= =?iso-8859-1?Q?HSv3LEmavIdHKCUM7LV8Dr2M3P3ZE/WzkqAsJFXwZIQ6+F9o+7NBcVxuB8?= =?iso-8859-1?Q?lifKPF2mRVhYbiucuDRm90U8GOb+JhQ83PUjc2uFkcFAqVdHUZIi9k4jOg?= =?iso-8859-1?Q?5oOSG6BNGCq5kwmpMzshPRwzLMNiWNgrAVmpKh2+czXmtg61BB4nlKl6j7?= =?iso-8859-1?Q?razZ9+7nLlwoowla7ytMDgXeDC1cymJ6FrTzjv41C+JgHBEdCsOSTgirRM?= =?iso-8859-1?Q?0BG1ll0/uJaJaxEXgVKufjBXpZs9tK3FjAneHhnjZUmhuyupESr4zsB9W3?= =?iso-8859-1?Q?2RwkCAnrgXcSybdtzViNh5BYUE90XWGvkz7MW9++uOU4uElPhj1HNwa+4Z?= =?iso-8859-1?Q?CL5YR+ps6D3tu7jShezBWrR8H4DvsSt4KOH+CZgC1ZPABaTyan8dzx11Re?= =?iso-8859-1?Q?HBb/yhLVCAP56bCGK76bIlvbRo/lL4p3uTWUESi1GfcP5yX+0X82hdTtCs?= =?iso-8859-1?Q?0e1x5mj5Atp2sXlbNk0vUuezjJWOTyyzYsJfQsCLo+xD345c4S6NAkqteA?= =?iso-8859-1?Q?tlhjLStOCGupXCxB4FDKWUAP3KO2VUeaK0?= 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: 59304149-49ae-4433-5f17-08dbe64ce7bf X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Nov 2023 02:36:58.2710 (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: ghhY1pCBTqMDoZv6WSnMEAk+elImTR8Fi9/8Sut55M/aTtg8DCv10uvGr8P5OJ8F X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5672 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: gJ5VItYQqhbEClWUI6gzaevex7686176AA= 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=tzizX3b3; 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 Cc: Mike Maslenkin Signed-off-by: Igor Kulchytskyy --- RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 196 ++++++++++++= ++------ RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h | 4 + 2 files changed, 143 insertions(+), 57 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 0f622e05a9..db927dd93c 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -40,7 +40,7 @@ Tcp6GetSubnetInfo ( IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance ); -static REDFISH_DISCOVER_REQUIRED_PROTOCOL gRequiredProtocol[] =3D { +static REDFISH_DISCOVER_REQUIRED_PROTOCOL mRequiredProtocol[] =3D { { ProtocolTypeTcp4, L"TCP4 Service Binding Protocol", @@ -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)) && + (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) { @@ -399,7 +410,7 @@ ValidateTargetNetworkInterface ( 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)) { break; } @@ -476,6 +487,65 @@ CheckIsIpVersion6 ( return FALSE; } +/** + This function returns the IP type supported by the Host Interface. + + @retval 00h is Unknown + 01h is Ipv4 + 02h is Ipv6 + +**/ +STATIC +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; +} + +/** + Check if Network Protocol Type matches with SMBIOS Type 42 IP Address Ty= pe. + + @param[in] NetworkProtocolType The Network Protocol Type to check with= . + @param[in] IpType The Host IP Address Type from SMBIOS Ty= pe 42. +**/ +STATIC +BOOLEAN +FilterProtocol ( + IN UINT32 NetworkProtocolType, + IN UINT8 IpType + ) +{ + if (NetworkProtocolType =3D=3D ProtocolTypeTcp4) { + return IpType !=3D REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4; + } + if (NetworkProtocolType =3D=3D ProtocolTypeTcp6) { + return IpType !=3D REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6; + } + return FALSE; +} + /** This function discover Redfish service through SMBIOS host interface. @@ -512,6 +582,11 @@ DiscoverRedfishHostInterface ( Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescript= or, &Data); // Search for SMBIOS type 42h if (!EFI_ERROR (Status) && (Data !=3D NULL) && (DeviceDescriptor !=3D NU= LL)) { + // Check IP Type and skip an unnecessary network protocol if does not = match + if (FilterProtocol (Instance->NetworkInterface->NetworkProtocolType, D= ata->HostIpAddressFormat)) { + 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. @@ -1000,8 +1075,8 @@ NetworkInterfaceGetSubnetInfo ( } ProtocolType =3D Instance->NetworkProtocolType; - if ((gRequiredProtocol[ProtocolType].GetSubnetInfo !=3D NULL) && (Instan= ce->GotSubnetInfo =3D=3D FALSE)) { - Status =3D gRequiredProtocol[ProtocolType].GetSubnetInfo ( + if ((mRequiredProtocol[ProtocolType].GetSubnetInfo !=3D NULL) && (Instan= ce->GotSubnetInfo =3D=3D FALSE)) { + Status =3D mRequiredProtocol[ProtocolType].GetSubnetInfo ( ImageHandle, Instance ); @@ -1102,6 +1177,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 +1217,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 +1316,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 +1351,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; } @@ -1506,7 +1603,7 @@ DestroyRedfishNetworkInterface ( Status =3D gBS->UninstallProtocolInterface ( ThisNetworkInterface->OpenDriverControllerHandle, - gRequiredProtocol[ThisNetworkInterface->NetworkProtocolT= ype].DiscoveredProtocolGuid, + mRequiredProtocol[ThisNetworkInterface->NetworkProtocolT= ype].DiscoveredProtocolGuid, &ThisNetworkInterface->NetworkInterfaceProtocolInfo.Prot= ocolDiscoverId ); RemoveEntryList (&ThisNetworkInterface->Entry); @@ -1537,11 +1634,11 @@ TestForRequiredProtocols ( EFI_STATUS Status; UINTN ListCount; - ListCount =3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQ= UIRED_PROTOCOL)); + ListCount =3D (sizeof (mRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQ= UIRED_PROTOCOL)); for (Index =3D 0; Index < ListCount; Index++) { Status =3D gBS->OpenProtocol ( ControllerHandle, - gRequiredProtocol[Index].RequiredServiceBindingProtoco= lGuid, + mRequiredProtocol[Index].RequiredServiceBindingProtoco= lGuid, NULL, This->DriverBindingHandle, ControllerHandle, @@ -1553,7 +1650,7 @@ TestForRequiredProtocols ( Status =3D gBS->OpenProtocol ( ControllerHandle, - gRequiredProtocol[Index].DiscoveredProtocolGuid, + mRequiredProtocol[Index].DiscoveredProtocolGuid, (VOID **)&Id, This->DriverBindingHandle, ControllerHandle, @@ -1601,58 +1698,60 @@ BuildupNetworkInterface ( EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; EFI_TPL OldTpl; BOOLEAN NewNetworkInterfaceInst= alled; + UINT8 IpType; + UINTN ListCount; + ListCount =3D (sizeof (mRequiredProtocol) / 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 (FilterProtocol (mRequiredProtocol[Index].ProtocolType, IpType)) { + continue; + } + Status =3D gBS->OpenProtocol ( // Already in list? ControllerHandle, - gRequiredProtocol[Index].DiscoveredProtocolGuid, + mRequiredProtocol[Index].DiscoveredProtocolGuid, (VOID **)&Id, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (!EFI_ERROR (Status)) { - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCO= VER_REQUIRED_PROTOCOL))) { - break; - } - continue; } Status =3D gBS->OpenProtocol ( ControllerHandle, - gRequiredProtocol[Index].RequiredServiceBindingProtoco= lGuid, + mRequiredProtocol[Index].RequiredServiceBindingProtoco= lGuid, &TempInterface, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCO= VER_REQUIRED_PROTOCOL))) { - break; - } - continue; } - if (gRequiredProtocol[Index].ProtocolType !=3D ProtocolTypeRestEx) { + if (mRequiredProtocol[Index].ProtocolType !=3D ProtocolTypeRestEx) { OldTpl =3D gBS->RaiseTPL (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL= ); - Status =3D CreateRedfishDiscoverNetworkInterface (ControllerHandle, = gRequiredProtocol[Index].ProtocolType, &IsNew, &NetworkInterface); + Status =3D CreateRedfishDiscoverNetworkInterface (ControllerHandle, = mRequiredProtocol[Index].ProtocolType, &IsNew, &NetworkInterface); if (EFI_ERROR (Status)) { gBS->RestoreTPL (OldTpl); return Status; } - NetworkInterface->NetworkProtocolType =3D gRequiredProtocol[I= ndex].ProtocolType; + NetworkInterface->NetworkProtocolType =3D mRequiredProtocol[I= ndex].ProtocolType; NetworkInterface->OpenDriverAgentHandle =3D This->DriverBinding= Handle; NetworkInterface->OpenDriverControllerHandle =3D ControllerHandle; - CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolGu= id, gRequiredProtocol[Index].RequiredProtocolGuid); - CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolSe= rviceGuid, gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid); + CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolGu= id, mRequiredProtocol[Index].RequiredProtocolGuid); + CopyGuid (&NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolSe= rviceGuid, mRequiredProtocol[Index].RequiredServiceBindingProtocolGuid); ProtocolDiscoverIdPtr =3D &NetworkInterface->NetworkInterface= ProtocolInfo.ProtocolDiscoverId; OpenDriverAgentHandle =3D NetworkInterface->OpenDriverAgentHa= ndle; OpenDriverControllerHandle =3D NetworkInterface->OpenDriverControl= lerHandle; @@ -1690,16 +1789,11 @@ BuildupNetworkInterface ( Status =3D gBS->InstallProtocolInterface ( &ControllerHandle, - gRequiredProtocol[Index].DiscoveredProtocolGuid, + mRequiredProtocol[Index].DiscoveredProtocolGuid, EFI_NATIVE_INTERFACE, ProtocolDiscoverIdPtr ); if (EFI_ERROR (Status)) { - Index++; - if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCO= VER_REQUIRED_PROTOCOL))) { - break; - } - continue; } @@ -1709,20 +1803,20 @@ BuildupNetworkInterface ( Status =3D NetLibCreateServiceChild ( ControllerHandle, This->ImageHandle, - gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid= , + mRequiredProtocol[Index].RequiredServiceBindingProtocolGuid= , HandleOfProtocolInterfacePtr ); if (!EFI_ERROR (Status)) { Status =3D gBS->OpenProtocol ( *HandleOfProtocolInterfacePtr, - gRequiredProtocol[Index].RequiredProtocolGuid, + mRequiredProtocol[Index].RequiredProtocolGuid, Interface, OpenDriverAgentHandle, OpenDriverControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER ); if (!EFI_ERROR (Status)) { - if ((gRequiredProtocol[Index].ProtocolType =3D=3D ProtocolTypeRest= Ex)) { + if ((mRequiredProtocol[Index].ProtocolType =3D=3D ProtocolTypeRest= Ex)) { // Install Redfish Discover Protocol when EFI REST EX protocol i= s discovered. // This ensures EFI REST EX is ready while the consumer of EFI_R= EDFISH_DISCOVER_PROTOCOL // acquires Redfish service over network interface. @@ -1756,25 +1850,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; } @@ -1849,14 +1931,14 @@ StopServiceOnNetworkInterface ( 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++) { + for (Index =3D 0; Index < (sizeof (mRequiredProtocol) / sizeof (REDFISH_= DISCOVER_REQUIRED_PROTOCOL)); Index++) { Status =3D gBS->HandleProtocol ( ControllerHandle, - gRequiredProtocol[Index].RequiredProtocolGuid, + mRequiredProtocol[Index].RequiredProtocolGuid, (VOID **)&Interface ); if (!EFI_ERROR (Status)) { - if (gRequiredProtocol[Index].ProtocolType !=3D ProtocolTypeRestEx) { + if (mRequiredProtocol[Index].ProtocolType !=3D ProtocolTypeRestEx) { if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { return EFI_NOT_FOUND; } @@ -1872,7 +1954,7 @@ StopServiceOnNetworkInterface ( Status =3D CloseProtocolService ( ThisBindingProtocol, ControllerHandle, - &gRequiredProtocol[Index], + &mRequiredProtocol[Index], ThisNetworkInterface->OpenDriverAgentHandle, ThisNetworkInterface->OpenDriverControllerHandle ); @@ -1935,7 +2017,7 @@ StopServiceOnNetworkInterface ( // Close REST_EX protocol. ThisBindingProtocol, ControllerHandle, - &gRequiredProtocol[Index], + &mRequiredProtocol[Index], RestExInstance->OpenDriverAgentHandle, RestExInstance->OpenDriverControllerHandle ); diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h index 01454acc1d..e27cfa76e3 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h @@ -39,6 +39,10 @@ #define REDFISH_DISCOVER_VERSION 0x00010000 #define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY +#define MAC_COMPARE(This, Target) (CompareMem ((VOID *)&(This)->MacAddres= s, &(Target)->MacAddress, (This)->HwAddressSize) =3D=3D 0) +#define VALID_TCP6(Target, This) ((Target)->IsIpv6 && ((This)->NetworkPr= otocolType =3D=3D ProtocolTypeTcp6)) +#define VALID_TCP4(Target, This) (!(Target)->IsIpv6 && ((This)->NetworkP= rotocolType =3D=3D ProtocolTypeTcp4)) + // // 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 (#111300): https://edk2.groups.io/g/devel/message/111300 Mute This Topic: https://groups.io/mt/102620282/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-