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 D5356941E02 for ; Wed, 15 Nov 2023 22:13:11 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=my7Dy3r/Ii4qr86eLNDOI0ZnpS+dupIedoPGky7OX3Y=; 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=1700086390; v=1; b=SaHXzJXL8ICqwOSyEL5RooaBufW/04NfRcmHFhCPku5tSU66qquFFTOEKJpXlXU+J7u+O7LG yPt+GRJo19TuUwp/rHg+qWHMkpFd9XIdLCQhTcHi6c5rQizajo/LRpQQUO3Oqp1gQ9byxzKQDzf 4hw34h+sPfh1LEYTFXFOpPgM= X-Received: by 127.0.0.2 with SMTP id FvzfYY7687511x1sD1rNkzH5; Wed, 15 Nov 2023 14:13:10 -0800 X-Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.83]) by mx.groups.io with SMTP id smtpd.web11.26553.1700086389519449291 for ; Wed, 15 Nov 2023 14:13:09 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WMpsWX7AEfK2huq53tU4hiM75XdaK2P0tIAF2pNXljuB85tYd1SaZLHJzlWJ0Jcc5JHfTVjkgpIR4gm0RAVFJiNwe49L6J36q9Dh8CgCRWoLEw9pKVCvyojpeTltDoMoiotGHl+CMfvnixksTBhzaGjotoGVbUWvsUiK/YywzhRb/Zmr0+lXR30ix1zVJ5fntp+z1Kz6EBwcYZXNkWliR6lERuM+y2ajNtpbglOP2xq8+AYOrChUYv2Fxv45dkrqSTs6PlqVZg6nGOJm73zbyYkzROAhNu9ahmc8CaM0TwGaR819QT3mLGUDLmwh6EheygdhrMbUbTtpCDPDvXZklg== 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=LongarM93+AbrSMpYHxVy9Gu5wmlgYh3DbvSKdU+DcPj/Hu4gYunDD4OADtf3Ccg7RpGTwxf/985IN71nWf1w2Ml9wm1mGqU1UFEGaKpNaEMmiuoZoSyB4tVHYn3KZqOTN+kAHXpalg6iNRIis5epcRlm8cP7hfKqkshVHerB/7I68PF80jpWyPJKGKF1V3ajyNxuvkuxBI73jBna4G4gRXtQuLK7xA7saaR+bexfG5U+I45zKlOw8S6JdQM//OXQvQtXVJqdPt+3wky3e7CJgw1pKMs+DKFgf0XFdNNU6iXo4PVI71LCIX5J3aUOx/YzCLDZNv46cDQD9cUPkvzsA== 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 CH0PR10MB5194.namprd10.prod.outlook.com (2603:10b6:610:d9::14) by SA1PR10MB5685.namprd10.prod.outlook.com (2603:10b6:806:23d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.19; Wed, 15 Nov 2023 22:13:06 +0000 X-Received: from CH0PR10MB5194.namprd10.prod.outlook.com ([fe80::5f36:d8c0:cede:b253]) by CH0PR10MB5194.namprd10.prod.outlook.com ([fe80::5f36:d8c0:cede:b253%5]) with mapi id 15.20.7002.015; Wed, 15 Nov 2023 22:13:06 +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] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow Thread-Topic: [PATCH v6 2/2] RedfishPkg: RedfishDiscoverDxe: Optimize the Redfish Discover flow Thread-Index: AQHaGBDog79NYmEWUkmIf2WEYjiJJA== Date: Wed, 15 Nov 2023 22:13:06 +0000 Message-ID: <20231115221304.2040-1-igork@ami.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH0PR10MB5194:EE_|SA1PR10MB5685:EE_ x-ms-office365-filtering-correlation-id: 89112485-c5a6-4d03-252f-08dbe6280b33 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: /R8AKHObc6QjNqr2BLQHGn4pajahUkG92x4WbeyB5Si25ItWz2hwerZaQOxZsdFHWHsc9IQ/fv/0CMGwmbU3nrU7cKKNhQUeUtTLOKZu8CGYFyRVAf/XGn+7KAc896fPjB7QmcyNsW9dBkmagDfOXDsP8bHOtTBI/pQXmCk/+bUd4ThPsLZaE1giEKbgMwhBWBFC5TLr39iDlwj/k5VMldA2bIZYex1JbWikH4UIlavD9jJpfoNABIlKcKWYNAkEBqKRerEGVu3Cu2YSkY1xtr1ULWKf+Dw5AHXmxXURDFp0X+e8wAkHMkJC5KCDUZMQIM738+82xndXCzF26co5UtVIobwycgbu3v3RCkG4Y05jHJN/GBlQ35wn5dBLcppaPP7PF3EFd+tFAHiXBEDrcloMkHkhTlTjmxyFl5DmcBWrOVSKUtSqTzDmMarNn1llxKvcTGnbV5M6d2rDD/vkkqG2RXpVOXBT9GwncXu9gPxP62rFwqusGW+pBvvT28MMU4lYK1PxY4M26gh6BVmdW2cs/O8YdoeiKLPNa+7YCxZiWO1AlHLx250EmhKxEgx7WCki/tTAZyOo9ks1UDcNsnvqf+V34x0C9UtnYWZkZFIFMJUn7qYPxz45DvoW56bb x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?aeb1zuZNX9i1IgB2fEQiAiEmVcDiJaQDJq1rOaxcNJCz9LRm2KWnfYPDUo?= =?iso-8859-1?Q?NMYez+dogxgE1QWj0tfvtKADlqvyrh/lw08yhEHoOtStuzB+PJcUG4FYfN?= =?iso-8859-1?Q?LSRyS3OsojbxXnEfPUcRc7mMpa9UpXM4Jy+Atdlc7wkPuox2D/vYZcJ4px?= =?iso-8859-1?Q?674PmThyFRU4RcwLUyjkaLgxv5q912/KzWa9XhbXCWE6EBcjIkAYpDIoAw?= =?iso-8859-1?Q?7ZK8WW/Y5D50Wi6KbOfuFKv07Pz8Zciae7wAk4msITXH0dNv/o5Kd7ddzA?= =?iso-8859-1?Q?kiOBtX8su3IGjTPXxal6wfv0Qo2cT+dmWgaNFGiyE4KeltJXYs3Whz7yY/?= =?iso-8859-1?Q?TQtCl7LnRPfglxACMMAWiK08pwdZzXLvTB55+K6kGygRLo/Ygv077WQeeK?= =?iso-8859-1?Q?yem8VypULiRuEhEWoskd1WapHeWDVuDomW1PMrnBdeD+5h/cz2gJAGzwdB?= =?iso-8859-1?Q?SHo1W+8ejc5hXkZNY6q6qiRHMNEuMgXuYwABdxsUEIF0T7tqRsuX2s8Yji?= =?iso-8859-1?Q?ZgfVbOenrkfiv5ijjstk3aV7v4NmT6RqZfo7GpmNep0FpQy0Vm89vBoe0I?= =?iso-8859-1?Q?eGOyaglb7vLjIz0upo4riWql0cSLIWV0uIubty7Az7AOHRyFKbaqbQEy5m?= =?iso-8859-1?Q?0w89MJtIGlDqd6HDkZz4V6AozsL7Q3WO+Dy3Y4S1uTVAwJSWoPNEluAV2h?= =?iso-8859-1?Q?l+aQrFvuN2DO08ZWnfZAQYF3n0f+C+FRXEj9qM08kgciho46no0cJzlEt3?= =?iso-8859-1?Q?G+ZK5NLQBt+DnE9dc5wOUBDCIVzBrV/rbJyTbvfETm+rfpkEhHaBdVjFpD?= =?iso-8859-1?Q?glcFvWXaVOqhLJeysaF2J5j7kALKqPsc9/n+ETRc4v9yWpOsvZIff2xi0Q?= =?iso-8859-1?Q?2QMLvFADcBg8BdYi3Et1t3eAzT0inzNyxv8KdUxwTBykAOM/zb8a9RFxoj?= =?iso-8859-1?Q?xKj2/DyrGZoxEsSQDe8pA3nL5uQn/HI6ldmSNqlXovkXxKVlJuZ/7kg1e1?= =?iso-8859-1?Q?I96RQi86xQWAWZv4QFuq3w+16TJ2jl6nVGZsEtY5y0gxQvtNfASaYNn61q?= =?iso-8859-1?Q?rYWnvsqwrT1Dtcizm1gJ4OhcITfnQkurheNpskGSyNJDGqU13swDmOPNdd?= =?iso-8859-1?Q?J+KbcHjuQw03BzZcetWQr+o3jYEhPFPnHn6X/3sqmhCdCE0zq7wB7jLx2Y?= =?iso-8859-1?Q?OCgfdNB4eCnF1vTtZUNBIQUBbQJ035kBH5F3SLh5QgN5pJNENEEPjSxzGX?= =?iso-8859-1?Q?xU6vUjFmYkzQI/4fRKf15S56VePNAEdSZK+yGmm8OP1hspoxFk40RzXmk1?= =?iso-8859-1?Q?Cxbw9w40aquSnamYK8w1G3cbuzHcPNNSE2L6VT1g6lqLYjuQN1TSwEJcfU?= =?iso-8859-1?Q?P6FbJTju7GXmzqTHSIwQnAAO0EzvbH1YNyfcesd3ldR5cjPUcSGSEuR0ni?= =?iso-8859-1?Q?7jM/jGEd5l/P16c00OdpP6AgzgR3tPhtEOdN9ocXDjOfDGHLC7Y6Z3BLmw?= =?iso-8859-1?Q?Ed2eucyHNfvkkocgNzQtXAy4fFvYm68UjnB7NrIs9ufVhozV9lqI4a5Vbb?= =?iso-8859-1?Q?p8j4d/xA76LpEoxjl2vg/+WuQBYgqXZOsWseFz4MOXYIq+nT4D7z4aqWTn?= =?iso-8859-1?Q?GIC2Z27C7JvHJ2m3ItWWNL+5JG7M09uL7c?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5194.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89112485-c5a6-4d03-252f-08dbe6280b33 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2023 22:13:06.3943 (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: 62VbqzHDJ3m6ziKgoSspWDx1oTYuymLuLFnqB5jE/U07lLMlBP4tkpwpaBO/qeM4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB5685 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: fJANXjlrWDru6lOwYmc932NWx7686176AA= 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=SaHXzJXL; 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 (#111294): https://edk2.groups.io/g/devel/message/111294 Mute This Topic: https://groups.io/mt/102615667/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-