From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.89]) by mx.groups.io with SMTP id smtpd.web10.17798.1680070450645207157 for ; Tue, 28 Mar 2023 23:14:10 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=YaWrzr1X; 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.93.89, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ba9YZ35kVI3WhaS3z8GX4tLGeiiTWP75hDQPS5BwdBuZx5xgsY91rlYTDAMChe5HauTbY6xedN5NumGabtamZwolmAhY/LMfS6Y4owUbOVSmeZ+E1S9uc4upUKDpNS64lIZQpZ/w9y4ZWgRvg2DYz5Kj6ES86U79lR7d//uMihxgZTECKnNp5oTD7YcqJiFwZwedC/z+GvvLQ+46T5BEWenlRPqIpZjZNMfjBsAKsDOUjnY6qDTNkIuCL+qWcFVwq2Dq4xH++c+GqsE7zlRdlZxKyPxOllYzMOpSOzNwlrQCfVrL4cITep1haxpFyGjpTHy9seU5dZN+KCjTc5Ay8A== 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=qm916uIzwGdIT1mEr5Dv8FcOd7RbmTIX7xkOMLNAHyY=; b=IaqeIa35kYJCqp7uP+JINGe4mYfWzwWZSyH2CmiYbdEnKAZlqMLYqSkXZ3T1wGtozPQwgeZYWxfUISVpEpzwwJewfAaxG+zbULW49iBqnJgChaIM6FOvShpHa+cgMdRycYyuouaLmfEdY2Yxc31t1i+ViQkLJj5a9UiVvJxHdrPVx3FKbMlwDbT6gGONivFJkoekN/ZCg9qelYt92zfZLvY/TA83ub+8aqeh5OeqCe1mb8i8yx6a4BoQWW+AtQMua2avadAweFrBmfxsyubP3XY+VM0z3TIxdHlsceT5cUAENAFth8cV6XnAfWfwITjcSxNYRGvBN0WWrGdgNI5V2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=qm916uIzwGdIT1mEr5Dv8FcOd7RbmTIX7xkOMLNAHyY=; b=YaWrzr1XHOPTAoR1BmLgc9jSRHoC0u261d8w8FxdaJSKGypxY0PlGU/01vKmfCVagsvyyxb3yXejBLxyStDGub1lmIiOckSq/DepsedQWFnx4RJiq+3Z81p+odxLpB17Vi2Kp7boqSNGImHYFKxZ60ud4r4lGZHgaej/d6Se4e7QQIppXKFZh83qcxooBhyNPdxKtmhu/a2dJh3NxT+DEicKRd2fYA8Q+ybbfaLGX4oEqa913B85u3uZghy1pNftlY8o//rKcd4wvBpZmfag7mrcLsnKQA/6Ywnm5K2fXp8Gu1DyDmr5aUCJ61qQdXCqixcHo5REK+wAdM//dlQVzw== Received: from DM6PR02CA0066.namprd02.prod.outlook.com (2603:10b6:5:177::43) by DM6PR12MB4958.namprd12.prod.outlook.com (2603:10b6:5:20a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Wed, 29 Mar 2023 06:14:08 +0000 Received: from DS1PEPF0000E631.namprd02.prod.outlook.com (2603:10b6:5:177:cafe::d2) by DM6PR02CA0066.outlook.office365.com (2603:10b6:5:177::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.43 via Frontend Transport; Wed, 29 Mar 2023 06:14:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS1PEPF0000E631.mail.protection.outlook.com (10.167.17.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.30 via Frontend Transport; Wed, 29 Mar 2023 06:14:07 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Mar 2023 23:13:50 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Mar 2023 23:13:49 -0700 Received: from NV-CL38DL3.nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Mar 2023 23:13:48 -0700 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [PATCH v2 2/3] RedfishPkg: Redfish discover driver improvement Date: Wed, 29 Mar 2023 14:13:49 +0800 Message-ID: <20230329061349.311-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: DS1PEPF0000E631:EE_|DM6PR12MB4958:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b0b47c8-d8b8-4d62-ff25-08db301cce30 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 56EBQ5V8k8qAQ5i8ViljFN7330rCqUAiuIy6Y5n00/WgjZuO466UFgCB3NCEXH+COuVr328I8mWDB9oFE53GozvkarUjDiF18r1eGCsqEOdaN8xDM4Z2GFUyU/D2rJPvaCyxRJSpsRZD6wMZIZXEP7FvLD1ZIIGU3pjdhGaWqYWRvVG9E9STNjlTk/I0mhPCaP412BpCZBpoX6vKH2t/l2W1wSVJ/TPO2mP5ymBydHO2w3UGgFmiEIaKTcLvlpyaKF4XyhudSMyHt8RCyST4tjmMJavYiZPdJZ0L4AtWLzhQ3pN3niL2vJAUBoCai7HWfj1z6oGc7uePz4hjhiEn1FVK9ahtSjjnQDk7otxrNhXJF1ONwadlIxmkAC6kKd/J7N0UxOI+f7mimuUaepBbhUKNUKCYMQeoQr33zQ8G4UFfuZ74ZIntf7iK06/GyCaNs9CZfHQkYXLe4rOiqKscIqeJdNfFpeOivofT5x4ercsGN/o+7gP4BrHx4kHygYqPdrf1We7O2ucLoV7uwTpHfaL9siMWx7Lo/UySLq7ZRvDI47cHU5o9fnZA3HiQHJC2cO4SPyOmicF5GEk8MkVbpRnhPwSxZhn+h5H94XgnpxJmYJG8e4SM8wkQDNvzJgf3TclXRCxvIUTiHeEd2xlditbixX22pBWxzk6KxS2Z2+z3AJANlkcJfCd8tIys9/CBPdokK4xtv9HILowYXXjYUi670khcOm/IMCVPj/nOSMvEDa6S5Uf8FHcqG6uThGwF3giTuYrx4i6fuNFgh9U1Ykm9cjpnQpBz6Y02L3bLWCc= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199021)(46966006)(36840700001)(40470700004)(336012)(83380400001)(36756003)(2616005)(426003)(47076005)(186003)(107886003)(26005)(1076003)(82310400005)(7696005)(478600001)(86362001)(316002)(54906003)(19627235002)(36860700001)(6916009)(41300700001)(4326008)(40480700001)(40460700003)(356005)(82740400003)(7636003)(70586007)(8676002)(70206006)(30864003)(8936002)(2906002)(5660300002)(341764005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 06:14:07.8029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4b0b47c8-d8b8-4d62-ff25-08db301cce30 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E631.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4958 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 | 144 ++++++++++++------ .../RedfishSmbiosHostInterface.c | 13 +- 3 files changed, 120 insertions(+), 57 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..f64c79088f 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 - if (Data->RedfishServiceIpAddressFormat =3D=3D 1) { + Instance->HostAddrFormat =3D Data->HostIpAddressFormat; + if (Data->HostIpAddressFormat =3D=3D REDFISH_HOST_INTERFACE_HOST_IP_AD= DRESS_FORMAT_IP4) { + 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 REDFISH_HOST_INTERFACE_HOST_IP_ADDRES= S_FORMAT_UNKNOWN; + } + + 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 REDFISH_HOST_INTERFACE_HOST_IP_ADDRES= S_FORMAT_UNKNOWN; + } + } else if (Data->HostIpAddressFormat =3D=3D REDFISH_HOST_INTERFACE_HOS= T_IP_ADDRESS_FORMAT_IP6) { + IP6_COPY_ADDRESS ((VOID *)&Instance->HostIpAddress.v6, (VOID *)Data-= >HostIpAddress); + } + + if (Data->RedfishServiceIpAddressFormat =3D=3D REDFISH_HOST_INTERFACE_= HOST_IP_ADDRESS_FORMAT_IP4) { 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 REDFISH_HOST_INTERFACE_HOST_IP= _ADDRESS_FORMAT_IP6) { + 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 REDFISH_HOST_INTERFACE_HOST_IP= _ADDRESS_FORMAT_IP4) { + 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