From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (NAM04-MW2-obe.outbound.protection.outlook.com [40.107.101.87]) by mx.groups.io with SMTP id smtpd.web10.59615.1679983166687874030 for ; Mon, 27 Mar 2023 22:59:26 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=oKVxi2K8; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.101.87, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QyK+uqnAqeHkBmQxU49r5f4a0hFQQUSDJ7x/XRsisvU9UGHHIT79WSimW3D8tLrfsO52+bH/8FxLR/xI4H6O2AI3L3P6C/+OJ7DijH8W5w/TfLdxDrrgCQa62G+Gdc5fVdMLSsvbTNDZhbKT3+HdHg3W2kMDdtXf+N/Ey34Vo0rcn2XOPTY73xB9+ZIxi2oUnwLe4Iex5eJNEQ9xC9ZS6BkxnnxlcigZA/khk+JTbVs+FlVZ30nAN27oJ95h03ghJw4xv2zQRnHk+pjlI0PA/bIKS5t7ECtWM9s6qm5iS7B6x+2/YN83XVL8DTlOSZy0U5pEp4ioyXuCApeA1DiMYg== 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=zAHmFB4aiJ+NbZM4/yQzcsc/4vZnYk0TM36TLuQ+qtE=; b=Qx5LK63QwfH2Cn8UgEURJ0GHxMU/LXLi3OTfX6KxjpIHx+UbBb/kqcvv4Xk24OA0aiIcaR/SGYAq7VjPBraIre+dZv4pad8Yz5TAnqIMq9gbEa6RsjUXuLy+XyQGDT+XhDyM3MAKpsZ3J9PEuCYgyu3rZQ1esoWNdNvcsweoQ9LPIXJM9t+Qx1xuna0R99ycHiqo6PqzpuEGltNYZbhLRW2Wm7Eh7NmwbCj7NiM8PrIWxqRnPiD6De1O0UPz4dz1Nyep8D7L4PZA0FO+UgX6C3qGbImsOk2lmpXj4orS651bQIwOqSs5/Q1aFgNZlh9R7hDB82mQdA42qPqGlXUFEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zAHmFB4aiJ+NbZM4/yQzcsc/4vZnYk0TM36TLuQ+qtE=; b=oKVxi2K8RNDAK/Baxg+SUHQ3AQkrijLu5I+VreK7EMTocGFhk7qPWnuTfsxqLa7OE3e+zrs8kIthAq0Bt+LEMOioJbBTs6Vv92OzW6sC1XBJrM+BAk7P4xgirbWrhdoW66Eni893nh6Rkc4QVNmfs2yj1DBU+IxO0Yva+MypsZLpV6r3FludZ+woxf5eNVEtJ7D9ccC2GRYKXxGmX1wLyYYlVSdxb9dUt1VdVjVIkSCF//27aoLL0fEuTef1fKLoekrcwFrzac+DM1GMJyOtXshHodWVwEzJfVYyDp3nScMJeBcJyq3gMFlYnwODDeJv138pq14OHfMQcdGF9XqQfw== Received: from DM5PR07CA0098.namprd07.prod.outlook.com (2603:10b6:4:ae::27) by SJ0PR12MB6992.namprd12.prod.outlook.com (2603:10b6:a03:483::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Tue, 28 Mar 2023 05:59:23 +0000 Received: from DM6NAM11FT076.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ae:cafe::42) by DM5PR07CA0098.outlook.office365.com (2603:10b6:4:ae::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.43 via Frontend Transport; Tue, 28 Mar 2023 05:59:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT076.mail.protection.outlook.com (10.13.173.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.9 via Frontend Transport; Tue, 28 Mar 2023 05:59:23 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 27 Mar 2023 22:59:11 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 27 Mar 2023 22:59:11 -0700 Received: from NV-CL38DL3.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Mon, 27 Mar 2023 22:59:10 -0700 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [PATCH 2/3] RedfishPkg: Redfish discover driver improvement Date: Tue, 28 Mar 2023 13:59:11 +0800 Message-ID: <20230328055911.221-1-nicklew@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Return-Path: nicklew@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT076:EE_|SJ0PR12MB6992:EE_ X-MS-Office365-Filtering-Correlation-Id: ad73335e-fad1-42a0-2a9d-08db2f5194aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4TpDlRZXEwopHEz9fh4gD/fWekB2cu8FCUAc6AZjtURmVKVHwyATPcBWfZp91EM25rAekBIZjwvZA+j821hol2KQAGmBnWft0+HnC1LcjZJoYLX64ejeN75jfCFB1KNmqLTzbu1ZBrGwV9QqojdX8puDyYy7MPZCdzYj9Wr1issBw4+wPqU5KdlCRRykFPZ7Pu3ESciZAfPsMxJM7uq87m41VYd+MEJGqlpEABvHpEtK1Z2ht5BJ6VCOf47SRmJEztMIqH5weYNOTPFjYTsvvUjLbsBfho2KSLvS2p4ZRVZLPcQpgtkduSk6RopuaOwA4oPeohe5awfmn6nzD0/CN0rjWfjgzUC0QkbsFE+2X8Lum8+HshvqijBntwWBb424HJX63CCZNqQ09Th6X+bAp+/pGMvcMgylXbSCnUylu9jhNZHYwMTrF/RTKIn1ox7HiRWnFlR5eZXouwzCmZAz/d5q5gZvvEBGyaOR6v9yMWckHKpbEQG1khBX5aorBBptDrOqvInZpSIknFosEDwEghR+23uqRlabGYOQrJMW2xYKXw8ky10OmboSuyTjyFJtsrrvHs2TIdEZFYjpHHeh1XblS8GXwKrGvUVdV7bz5qlTNDtx+oEb+DC6iNL52HACRU+qMfuBzuxrPziiEKy9NuOBTZ6l5PRV/Q42xDodivFZRZ6G5e01AmTvXtthFYgqnI1vRsy1llUtwCsa6WlNZ1sdKUyrSzoffTPdWnY2NlsFaOfaT+NZM4u4+MiuiLrq3FtFJ/ZuOSgjhRugyFiYnbrW1BwEWoI1F3C18iuV345VBNH665ZPGthgzSu65PZC X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(396003)(39860400002)(136003)(451199021)(40470700004)(36840700001)(46966006)(83380400001)(478600001)(2906002)(36860700001)(1076003)(7696005)(426003)(336012)(30864003)(356005)(2616005)(5660300002)(54906003)(8936002)(7636003)(107886003)(40460700003)(316002)(86362001)(19627235002)(82740400003)(186003)(82310400005)(34020700004)(26005)(40480700001)(41300700001)(70586007)(47076005)(70206006)(4326008)(6916009)(8676002)(36756003)(341764005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2023 05:59:23.4843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad73335e-fad1-42a0-2a9d-08db2f5194aa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT076.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6992 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Bug fix: - function stack fault - properly handle "SubnetAddrInfoIPv6" when there is no IPv6 support - copy-n-paste error in RedfishGetHostInterfaceProtocolData() - fix typo Enhancement: - Redfish discover driver now can configure host IP address based on the information from SMBIOS type 42 record. This saves the effort of configuring host IP address in setup menu. - Performance improvement to driver binding process. Redfish discover driver will wait until all required drivers are ready and do driver binding start(). - Use CopyGuid() to copy GUID instead of intrinsic function. - Error handling when SMBIOS data is corrupted. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../RedfishDiscoverInternal.h | 20 ++- .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 142 ++++++++++++------ .../RedfishSmbiosHostInterface.c | 13 +- 3 files changed, 119 insertions(+), 56 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h index 04fa09e1cc..2704cd955d 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h @@ -3,6 +3,7 @@ =20 (C) Copyright 2021 Hewlett Packard Enterprise Development LP
Copyright (c) 2022, AMD Incorporated. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -102,7 +103,7 @@ typedef struct { UINT32 SubnetAddrInfoIPv6Number;= ///< IPv6 address info number. EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6; = ///< IPv6 address info. // - // Network interface protocol and REST EX infor. + // Network interface protocol and REST EX info. // UINT32 NetworkProtocolType; = ///< Network protocol type. Refer to = ///< NETWORK_INTERFACE_PROTOCOL_TYPE. @@ -112,7 +113,7 @@ typedef struct { // EFI_REDFISH_DISCOVER_PROTOCOL instance installed // on this network interface. // - EFI_HANDLE EfiRedfishDiscoverProtoco= lHandle; ///< EFI_REDFISH_DISCOVER_PROTOTOCOL instance installed + EFI_HANDLE EfiRedfishDiscoverProtoco= lHandle; ///< EFI_REDFISH_DISCOVER_PROTOCOL instance installed = ///< on this network interface. } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL; =20 @@ -123,7 +124,7 @@ typedef struct { LIST_ENTRY Entry; ///< Link list entry= . EFI_HANDLE OpenDriverAgentHandle; ///< The agent to op= en network protocol. EFI_HANDLE OpenDriverControllerHandle; ///< The controller = handle to open network protocol. - EFI_HANDLE RestExChildHandle; ///< The child handl= e created throught REST EX Service Protocol. + EFI_HANDLE RestExChildHandle; ///< The child handl= e created through REST EX Service Protocol. EFI_HANDLE RestExControllerHandle; ///< The controller = handle which provide REST EX protocol. EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_= REST_EX_PROTOCOL. UINT32 RestExId; ///< The identifier = installed on REST EX controller handle. @@ -178,15 +179,18 @@ typedef struct { EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; //= /< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL //= /< instance used to discover Redfish service. // - // Below for Host insterface discovery. + // Below for Host interface discovery. // BOOLEAN HostIntfValidation; /= //< Indicates whether to validate Redfish Host interface. EFI_IP_ADDRESS TargetIpAddress; /= //< Target IP address reported in Redfish Host interface. + UINT8 HostAddrFormat; /= //< Unknown=3D00h, Ipv4=3D01h, Ipv6=3D02h. + EFI_IP_ADDRESS HostIpAddress; /= //< Host IP address reported in Redfish Host interface. + EFI_IP_ADDRESS HostSubnetMask; /= //< Host subnet mask address reported in Redfish Host interface. } EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE; =20 /** - The function adds a new foudn Redfish service to internal list and - notify clinet. + The function adds a new found Redfish service to internal list and + notify client. =20 It simply frees the packet. =20 @@ -197,7 +201,7 @@ typedef struct { @param[in] Os OS string. @param[in] OsVer OS version string. @param[in] Product Product string. - @param[in] ProductVer Product verison string. + @param[in] ProductVer Product version string. @param[in] UseHttps Redfish service requires secured conne= ction. @retval EFI_SUCCESS Redfish service is added to list succe= ssfully. =20 @@ -224,7 +228,7 @@ AddAndSignalNewRedfishService ( @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA. @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA. =20 - @retval EFI_SUCCESS Get host interface succesfully. + @retval EFI_SUCCESS Get host interface successfully. @retval Otherwise Fail to tet host interface. =20 **/ diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 042d6d5fd5..ba42c8a5de 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -1,9 +1,10 @@ /** @file =20 - The implementation of EFI Redfidh Discover Protocol. + The implementation of EFI Redfish Discover Protocol. =20 (C) Copyright 2021 Hewlett Packard Enterprise Development LP
Copyright (c) 2022, AMD Incorporated. All rights reserved. + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -270,10 +271,13 @@ Tcp6GetSubnetInfo ( =20 if (IpModedata.AddressCount =3D=3D 0) { DEBUG ((DEBUG_INFO, "%a: No IPv6 address configured.\n", __FUNCTION__)= ); + Instance->SubnetAddrInfoIPv6Number =3D 0; + return EFI_SUCCESS; } =20 if (Instance->SubnetAddrInfoIPv6 !=3D NULL) { FreePool (Instance->SubnetAddrInfoIPv6); + Instance->SubnetAddrInfoIPv6 =3D NULL; } =20 Instance->SubnetAddrInfoIPv6 =3D AllocateZeroPool (IpModedata.AddressCou= nt * sizeof (EFI_IP6_ADDRESS_INFO)); @@ -447,7 +451,7 @@ NumberOfNetworkInterface ( =20 /** This function checks the IP version supported on this - netwoek interface. + network interface. =20 @param[in] ThisNetworkInterface EFI_REDFISH_DISCOVER_NETWORK_INTERF= ACE_INTERNAL =20 @@ -472,7 +476,7 @@ CheckIsIpVersion6 ( @param[in] Instance EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE =20 @retval EFI_SUCCESS Redfish service is discovered through SMBIOS = Host interface. - @retval Others Fail to discover Redfish service throught SMB= IOS host interface + @retval Others Fail to discover Redfish service through SMBI= OS host interface =20 **/ EFI_STATUS @@ -487,7 +491,7 @@ DiscoverRedfishHostInterface ( CHAR16 Ipv6Str[sizeof "ffff:ffff:ffff:ffff:ffff:= ffff:ffff:ffff" + 1]; CHAR8 RedfishServiceLocateStr[sizeof "ffff:ffff= :ffff:ffff:ffff:ffff:ffff:ffff" + 1]; UINTN StrSize; - UINTN MacCompareStstus; + UINTN MacCompareStatus; BOOLEAN IsHttps; =20 Data =3D NULL; @@ -503,24 +507,52 @@ DiscoverRedfishHostInterface ( Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescript= or, &Data); // Search for SMBIOS type 42h if (!EFI_ERROR (Status) && (Data !=3D NULL) && (DeviceDescriptor !=3D NU= LL)) { // - // Chceck if we can reach out Redfish service using this network inter= face. - // Check with MAC address using Device Descroptor Data Device Type 04 = and Type 05. + // 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. // Those two types of Redfish host interface device has MAC informatio= n. // if (DeviceDescriptor->DeviceType =3D=3D REDFISH_HOST_INTERFACE_DEVICE_= TYPE_PCI_PCIE_V2) { - MacCompareStstus =3D CompareMem (&Instance->NetworkInterface->MacAdd= ress, &DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.MacAddress, 6); + MacCompareStatus =3D CompareMem (&Instance->NetworkInterface->MacAdd= ress, &DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.MacAddress, 6); } else if (DeviceDescriptor->DeviceType =3D=3D REDFISH_HOST_INTERFACE_= DEVICE_TYPE_USB_V2) { - MacCompareStstus =3D CompareMem (&Instance->NetworkInterface->MacAdd= ress, &DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress, 6); + MacCompareStatus =3D CompareMem (&Instance->NetworkInterface->MacAdd= ress, &DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress, 6); } else { return EFI_UNSUPPORTED; } =20 - if (MacCompareStstus !=3D 0) { + if (MacCompareStatus !=3D 0) { return EFI_UNSUPPORTED; } =20 + Instance->HostAddrFormat =3D Data->HostIpAddressFormat; + if (Data->HostIpAddressFormat =3D=3D 1) { + IP4_COPY_ADDRESS ((VOID *)&Instance->HostIpAddress.v4, (VOID *)Data-= >HostIpAddress); + IP4_COPY_ADDRESS ((VOID *)&Instance->HostSubnetMask.v4, (VOID *)Data= ->HostIpMask); + + if (EFI_IP4_EQUAL (&Instance->HostIpAddress.v4, &mZeroIp4Addr)) { + DEBUG ((DEBUG_ERROR, "%a: invalid host IP address: zero address\n"= , __FUNCTION__)); + // + // Invalid IP address detected. Change address format to Unknown a= nd use system default address. + // + Instance->HostAddrFormat =3D 0x00; + } + + if (!IP4_IS_VALID_NETMASK (EFI_IP4 (Instance->HostSubnetMask.v4))) { + DEBUG ((DEBUG_ERROR, "%a: invalid subnet mask address\n", __FUNCTI= ON__)); + // + // Invalid subnet mast address detected. Change address format to = Unknown and use system default address. + // + Instance->HostAddrFormat =3D 0x00; + } + } else if (Data->HostIpAddressFormat =3D=3D 2) { + IP6_COPY_ADDRESS ((VOID *)&Instance->HostIpAddress.v6, (VOID *)Data-= >HostIpAddress); + } + if (Data->RedfishServiceIpAddressFormat =3D=3D 1) { IP4_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v4, (VOID *)Dat= a->RedfishServiceIpAddress); + + if (EFI_IP4_EQUAL (&Instance->TargetIpAddress.v4, &mZeroIp4Addr)) { + DEBUG ((DEBUG_ERROR, "%a: invalid service IP address: zero address= \n", __FUNCTION__)); + } } else { IP6_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v6, (VOID *)Dat= a->RedfishServiceIpAddress); } @@ -530,7 +562,7 @@ DiscoverRedfishHostInterface ( Status =3D EFI_UNSUPPORTED; } else { // - // Add this istance to list without detial information of Redfish + // Add this instance to list without detail information of Redfish // service. // IsHttps =3D FALSE; @@ -614,7 +646,7 @@ DiscoverRedfishHostInterface ( @param[in] Os OS string. @param[in] OsVer OS version string. @param[in] Product Product string. - @param[in] ProductVer Product verison string. + @param[in] ProductVer Product version string. @param[in] UseHttps Redfish service requires secured conne= ction. @retval EFI_SUCCESS Redfish service is added to list succe= ssfully. =20 @@ -671,7 +703,7 @@ AddAndSignalNewRedfishService ( do { if ((Char16Uuid =3D=3D NULL) || (DiscoveredList->Instance->Informati= on.Uuid =3D=3D NULL)) { // - // Check if this Redfish instance already found using IP addrress. + // Check if this Redfish instance already found using IP address. // if (!CheckIsIpVersion6 (NetworkInterface)) { if (CompareMem ( @@ -849,6 +881,10 @@ AddAndSignalNewRedfishService ( Status =3D EFI_OUT_OF_RESOURCES; goto EXIT_FREE_CONFIG_DATA; } + + if (Instance->HostAddrFormat =3D=3D 2) { + IP6_COPY_ADDRESS (&RestExHttpConfigData->HttpConfigData.AccessPo= int.IPv6Node->LocalAddress, &Instance->HostIpAddress.v6); + } } else { RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node =3D Allo= cateZeroPool (sizeof (EFI_HTTPv4_ACCESS_POINT)); if (RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node =3D= =3D NULL) { @@ -856,7 +892,13 @@ AddAndSignalNewRedfishService ( goto EXIT_FREE_CONFIG_DATA; } =20 - RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->UseDefa= ultAddress =3D TRUE; + if (Instance->HostAddrFormat =3D=3D 1) { + RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->UseDe= faultAddress =3D FALSE; + IP4_COPY_ADDRESS (&RestExHttpConfigData->HttpConfigData.AccessPo= int.IPv4Node->LocalAddress, &Instance->HostIpAddress.v4); + IP4_COPY_ADDRESS (&RestExHttpConfigData->HttpConfigData.AccessPo= int.IPv4Node->LocalSubnet, &Instance->HostSubnetMask.v4); + } else { + RestExHttpConfigData->HttpConfigData.AccessPoint.IPv4Node->UseDe= faultAddress =3D TRUE; + } } =20 Status =3D RestEx->Configure ( @@ -955,7 +997,7 @@ NetworkInterfaceGetSubnetInfo ( Instance ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a:Faile to get Subnet infomation.\n", __FUNCT= ION__)); + DEBUG ((DEBUG_ERROR, "%a:Failed to get Subnet infomation.\n", __FUNC= TION__)); return Status; } else { DEBUG ((DEBUG_INFO, "%a:MAC address: %s\n", __FUNCTION__, Instance->= StrMacAddr)); @@ -982,7 +1024,7 @@ NetworkInterfaceGetSubnetInfo ( ThisSubnetAddrInfoIPv6++; for (IPv6InfoIndex =3D 0; IPv6InfoIndex < Instance->SubnetAddrInfo= IPv6Number - 1; IPv6InfoIndex++) { // - // Build up addtional EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INT= ERNAL instances. + // Build up additional EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_IN= TERNAL instances. // NewNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_= INTERNAL *)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE= _INTERNAL)); if (NewNetworkInterface !=3D NULL) { @@ -1103,9 +1145,9 @@ RedfishServiceGetNetworkInterface ( /** This function acquires Redfish services by discovering static Redfish se= tting according to Redfish Host Interface or through SSDP. Returns a list of E= FI - handles in EFI_REDFISH_DISCOVERED_LIST. Each of EFI handle has coorespon= ding - EFI REST EX instance installed on it. Each REST EX isntance is a child i= nstance which - created through EFI REST EX serivce protoocl for communicating with spec= ific + handles in EFI_REDFISH_DISCOVERED_LIST. Each of EFI handle has correspon= ding + EFI REST EX instance installed on it. Each REST EX instance is a child i= nstance which + created through EFI REST EX service protocol for communicating with spec= ific Redfish service. =20 @param[in] This EFI_REDFISH_DISCOVER_PROTOCOL inst= ance. @@ -1255,7 +1297,7 @@ RedfishServiceAbortAcquire ( ) { // This function is used to abort Redfish service discovery through SSDP - // on the network interface. SSDP is optionally supprted by EFI_REDFISH_= DISCOVER_PROTOCOL, + // on the network interface. SSDP is optionally suppoted by EFI_REDFISH_= DISCOVER_PROTOCOL, // we dont have implementation for SSDP now. =20 return EFI_UNSUPPORTED; @@ -1425,7 +1467,7 @@ CreateRedfishDiscoverNetworkInterface ( } =20 /** - This function destory network interface + This function destroy network interface =20 =20 @param[in] ThisNetworkInterface EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_= INTERNAL instance. @@ -1433,7 +1475,7 @@ CreateRedfishDiscoverNetworkInterface ( @retval EFI_STATUS **/ EFI_STATUS -DestroyRedfishNetwrokInterface ( +DestroyRedfishNetworkInterface ( IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterfac= e ) { @@ -1467,11 +1509,13 @@ TestForRequiredProtocols ( IN EFI_HANDLE ControllerHandle ) { - UINT32 Id; + UINT32 *Id; UINTN Index; EFI_STATUS Status; + UINTN ListCount; =20 - for (Index =3D 0; Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_= DISCOVER_REQUIRED_PROTOCOL)); Index++) { + ListCount =3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQ= UIRED_PROTOCOL)); + for (Index =3D 0; Index < ListCount; Index++) { Status =3D gBS->OpenProtocol ( ControllerHandle, gRequiredProtocol[Index].RequiredServiceBindingProtoco= lGuid, @@ -1490,8 +1534,10 @@ TestForRequiredProtocols ( EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: %s is found on this controller handle.\n= ", __FUNCTION__, gRequiredProtocol[Index].ProtocolName)); - return EFI_SUCCESS; + if (Index =3D=3D ListCount - 1) { + DEBUG ((DEBUG_ERROR, "%a: all required protocols are found on th= is controller handle: %p.\n", __FUNCTION__, ControllerHandle)); + return EFI_SUCCESS; + } } } } @@ -1517,7 +1563,7 @@ BuildupNetworkInterface ( IN EFI_HANDLE ControllerHandle ) { - UINT32 Id; + UINT32 *Id; UINT32 Index; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; BOOLEAN IsNew; @@ -1578,13 +1624,11 @@ BuildupNetworkInterface ( return Status; } =20 - NetworkInterface->NetworkProtocolType =3D gReq= uiredProtocol[Index].ProtocolType; - NetworkInterface->OpenDriverAgentHandle =3D This= ->DriverBindingHandle; - NetworkInterface->OpenDriverControllerHandle =3D Cont= rollerHandle; - NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolGuid =3D \ - *gRequiredProtocol[Index].RequiredProtocolGuid; - NetworkInterface->NetworkInterfaceProtocolInfo.ProtocolServiceGuid = =3D \ - *gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid; + NetworkInterface->NetworkProtocolType =3D gRequiredProtocol[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); ProtocolDiscoverIdPtr =3D &NetworkInterface->NetworkInterface= ProtocolInfo.ProtocolDiscoverId; OpenDriverAgentHandle =3D NetworkInterface->OpenDriverAgentHa= ndle; OpenDriverControllerHandle =3D NetworkInterface->OpenDriverControl= lerHandle; @@ -1598,7 +1642,7 @@ BuildupNetworkInterface ( =20 gBS->RestoreTPL (OldTpl); } else { - // Record REST_EX instance. REST_EX is created when clinet asks for = Redfish service discovery. + // Record REST_EX instance. REST_EX is created when client asks for = Redfish service discovery. // Redfish Service Discover protocol will match REST EX to the corre= sponding EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL // when discovery. =20 @@ -1655,9 +1699,9 @@ BuildupNetworkInterface ( ); if (!EFI_ERROR (Status)) { if ((gRequiredProtocol[Index].ProtocolType =3D=3D ProtocolTypeRest= Ex)) { - // Install Redfish Discover Protocol when EFI REST EX protcol is= discovered. + // 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 serivce over network interface. + // acquires Redfish service over network interface. =20 if (!NewNetworkInterfaceInstalled) { NetworkInterface =3D GetTargetNetworkInterfaceInternalByContro= ller (ControllerHandle); @@ -1678,6 +1722,14 @@ BuildupNetworkInterface ( if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI_REDFISH_DISCOVER= _PROTOCOL\n", __FUNCTION__)); } + } else { + DEBUG ((DEBUG_INFO, "%a: Not REST EX, continue with next\n", __F= UNCTION__)); + Index++; + if (Index =3D=3D (sizeof (gRequiredProtocol) / sizeof (REDFISH_D= ISCOVER_REQUIRED_PROTOCOL))) { + break; + } + + continue; } } =20 @@ -1692,11 +1744,11 @@ BuildupNetworkInterface ( } } while (Index < (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_= REQUIRED_PROTOCOL))); =20 - return EFI_UNSUPPORTED; + return EFI_DEVICE_ERROR; } =20 /** - Close the protocol opened for Redfish discovery. This function also dest= ories + Close the protocol opened for Redfish discovery. This function also dest= roy the network services. =20 @param[in] ThisBindingProtocol A pointer to the EFI_DRIVER_BINDING_= PROTOCOL instance. @@ -1707,8 +1759,8 @@ BuildupNetworkInterface ( @param[in] DriverAgentHandle Driver agent handle which used to ope= n protocol earlier. @param[in] DriverControllerHandle Driver controller handle which used t= o open protocol earlier. =20 - @retval EFI_SUCCESS Prorocol is closed successfully. - @retval Others Prorocol is closed unsuccessfully. + @retval EFI_SUCCESS Protocol is closed successfully. + @retval Others Protocol is closed unsuccessfully. =20 **/ EFI_STATUS @@ -1748,7 +1800,7 @@ CloseProtocolService ( must support a protocol interface that = supplies an I/O abstraction to the driver. @retval EFI_SUCCESS One of required protocol is found. - @retval Others Faile to stop the services on network i= nterface. + @retval Others Failed to stop the services on network = interface. **/ EFI_STATUS StopServiceOnNetworkInterface ( @@ -1792,14 +1844,14 @@ StopServiceOnNetworkInterface ( ThisNetworkInterface->OpenDriverControllerHandle ); if (!EFI_ERROR (Status)) { - Status =3D DestroyRedfishNetwrokInterface (ThisNetworkInterf= ace); + Status =3D DestroyRedfishNetworkInterface (ThisNetworkInterf= ace); } =20 gBS->RestoreTPL (OldTpl); =20 // // Disconnect EFI Redfish discover driver controller to notify= the - // clinet which uses .EFI Redfish discover protocol. + // client which uses .EFI Redfish discover protocol. // if (DiscoverProtocolHandle !=3D NULL) { gBS->DisconnectController (DiscoverProtocolHandle, NULL, NUL= L); @@ -1945,7 +1997,7 @@ RedfishDiscoverDriverBindingSupported ( @retval EFI_SUCCESS The device was started. @retval EFI_DEVICE_ERROR The device could not be started due to = a device error.Currently not implemented. @retval EFI_OUT_OF_RESOURCES The request could not be completed due = to a lack of resources. - @retval Others The driver failded to start the device. + @retval Others The driver failed to start the device. =20 **/ EFI_STATUS @@ -2030,7 +2082,7 @@ RedfishDiscoverEntryPoint ( InitializeListHead (&mEfiRedfishDiscoverNetworkInterface); InitializeListHead (&mEfiRedfishDiscoverRestExInstance); // - // Install binding protoocl to obtain UDP and REST EX protocol. + // Install binding protocol to obtain UDP and REST EX protocol. // Status =3D EfiLibInstallDriverBindingComponentName2 ( ImageHandle, diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c b/R= edfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c index 88cec1f416..0d6edc7dc3 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c @@ -4,6 +4,7 @@ Discover Redfish SMBIOS Host Interface. =20 (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -22,7 +23,7 @@ SMBIOS_TABLE_TYPE42 *mType42Record; @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA. @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA. =20 - @retval EFI_SUCCESS Get host interface succesfully. + @retval EFI_SUCCESS Get host interface successfully. @retval Otherwise Fail to tet host interface. =20 **/ @@ -69,9 +70,15 @@ RedfishGetHostInterfaceProtocolData ( // if ((*RecordTmp =3D=3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE= _V2) || (*RecordTmp =3D=3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) { if (*RecordTmp =3D=3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCI= E_V2) { - ASSERT (SpecificDataLen =3D=3D sizeof (PCI_OR_PCIE_INTERFACE_D= EVICE_DESCRIPTOR_V2) + 1); + if (SpecificDataLen !=3D sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_= DESCRIPTOR_V2) + 1) { + ASSERT (SpecificDataLen =3D=3D sizeof (PCI_OR_PCIE_INTERFACE= _DEVICE_DESCRIPTOR_V2) + 1); + return EFI_VOLUME_CORRUPTED; + } } else { - ASSERT (SpecificDataLen > sizeof (REDFISH_HOST_INTERFACE_DEVIC= E_TYPE_USB_V2) + 1); + if (SpecificDataLen !=3D sizeof (USB_INTERFACE_DEVICE_DESCRIPT= OR_V2) + 1) { + ASSERT (SpecificDataLen =3D=3D sizeof (USB_INTERFACE_DEVICE_= DESCRIPTOR_V2) + 1); + return EFI_VOLUME_CORRUPTED; + } } =20 *DeviceDescriptor =3D (REDFISH_INTERFACE_DATA *)RecordTmp; --=20 2.40.0.windows.1