From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.78]) by mx.groups.io with SMTP id smtpd.web10.14643.1675220735553256369 for ; Tue, 31 Jan 2023 19:05:35 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=hCeNQ0G9; 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.243.78, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7CZJZtHT6X+Or+WrH80msbTGyO4xwxyeBfU+ArEn0PnF1kWQXO/J+ikpYutboD3HgHlwQbGrN4E+IUKxHtn8IJyRK4Ytqdt7YjoaW5lqduD3smJXmhvOswXYLzwibodSLy802ifW+juEFbtTqtUgKkq/OiQyZuOD1tTsDyNqoyg9ozODSBT6qh1GEMV0l3tSklUpt4SzcVU07xA1LP82rUAuvOBTVrZDQi3JnAwPdJeRtMMgaH13ywa9W9mQq3BpcDKY4mzsF57GIKQqSgUIW9fjqKOD78qTgrDzE5pP4JnbnEj16dX/Xiu1VaCWNt90j9EUZlQccwbJjGih4H8Fw== 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=hqaoFzdgZQJ875n3pOIF520PbC6P4g/4T24Mu8EfmOU=; b=EbUg8M04ap1c+UtZczM27cat58vhnMPmSDXy98i3k+dbH0FEqmK6+LD5YIeWIR7qIW8B07De/N9d2CF2JKBwFF2d45Qw8rxNvdTKJAnZHSc6tG30n5ymXwDYdToBN3DUpvi3fUrX6zuaX7x8rTXMpOSHM1AVe/ERtg8P2ZJkfKaatkK22kU9ykz2kpznLf3U+B/2/PoOggsHY9dIyDN6eUwwlm9xS4ec9AhABQPMIDQUpXCrkiBY9IQgN9xFzZmbrWFKxBuABHpueE9qK5ssE4AJr6lWzN1S2esgNClGoVlZLEaAokDd5QgKnW/TNVLer/Ro8NKNZ2iJxmNu3yiWCQ== 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=hqaoFzdgZQJ875n3pOIF520PbC6P4g/4T24Mu8EfmOU=; b=hCeNQ0G9DM+L/m0lZYiKuax77HaswXiEv/W99HdmqhZtJqI0IIbsYvZ+jzfsql5NTP2J+yQAn4vONqG1UiV3n6/btyM6dFRf/TiIeh8epHyMiXnmIDZvfRoWcnd9kRhsTYz20EiR+X8OB9zGVLQRsVP9pXYC3RIfdgmFO9DaWqO6bgUC+xJUlMZkdhUcwNe04HTUhfjTUr2UEVspkqZ70Y+wFlmawzTFtrpha4e+uaJnI68ZIvaVewLoEv9Cj5Kb6fmZrkLqU6xIvFZ3p/Bs5hxgGuHnS6OYnuNM2i32cfF38GrS0x+R0A9NdzpMeT8zzDA8Iw3VHsF6jFE2QLQjeQ== Received: from MW4PR03CA0216.namprd03.prod.outlook.com (2603:10b6:303:b9::11) by BN9PR12MB5274.namprd12.prod.outlook.com (2603:10b6:408:11f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Wed, 1 Feb 2023 03:05:32 +0000 Received: from CO1NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::e0) by MW4PR03CA0216.outlook.office365.com (2603:10b6:303:b9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38 via Frontend Transport; Wed, 1 Feb 2023 03:05:32 +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 CO1NAM11FT063.mail.protection.outlook.com (10.13.175.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Wed, 1 Feb 2023 03:05:31 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.36; Tue, 31 Jan 2023 19:05:15 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 31 Jan 2023 19:05:15 -0800 Received: from NV-CL38DL3.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Tue, 31 Jan 2023 19:05:14 -0800 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [PATCH 2/2] RedfishPkg: Redfish discover driver improvement Date: Wed, 1 Feb 2023 11:05:13 +0800 Message-ID: <20230201030513.391-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: CO1NAM11FT063:EE_|BN9PR12MB5274:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b4a292e-db8b-49b2-4653-08db04012e41 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uxOQ+G2V77fAsrDrViO5YQlgVzCOJTob7qnenQ+RGhb6E1PqnEOzTA76kkIZqECw9b37Si1cZ+3oXSwmdbbLv6QYFabeFfmBuk6EEs9NWjeUDYOp2ii/48E23wB1fllMxiYdaxx5/L589BZvXYpCz0RPUT+MHd1YemnCj7KldyGMk6m0QzKiIdaByys3cJOOHh2lpSaVZ+pzM9HOn5EaMRKd9k5RlvEQmPkj8A8zia8TVZPYOmfmmDQoOfxW13I/4OhOct/7q2FaPndfkBP/4cAGBY4/ylSqrlt57rCHyLxDeJv42cMCPYYhJUbAmVFzZIDcCWcWvHZ7/jfUnYc+lz4mFL9Wwv7vVKhrVwUhPg1DiB86Y8UbnazcSqosZMIefc8RAms+rb7OHFWQ2xSathZDGYBA6y7mHr0HQgX8VKZ/XTxLW4HNJvfBStRni/pCavRzUFbUlXw0IscazCV2lwkIFH3Wgmd4C1CLDwnbTeX0a70oQtv68172zNlckbuqr4nPFa5pYvFj3u2jgD0ge4yPuqrGdHdsZjRr9zgl98W6hHUSsfsagDCW77bGx8vlZAFLBnBw8o2YXSV8lR6ZXU0e4A30kzY8eo3EySBkk7ep5M3Noien9wUQz7qllLVt1GtaoMlMD6sjx0q9CI6c7C4SNKynC0dl+loAMbwynkE6KU0jq/YzTXKfhg4oqz9FVmSZg3OK0G4glb8fn9xlpsBFZ3F7kVflKruiDIisyek= 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:(13230025)(4636009)(376002)(39860400002)(346002)(136003)(396003)(451199018)(46966006)(36840700001)(40470700004)(41300700001)(70206006)(36756003)(6916009)(54906003)(316002)(8676002)(4326008)(8936002)(82310400005)(5660300002)(70586007)(86362001)(356005)(7636003)(82740400003)(36860700001)(107886003)(186003)(1076003)(26005)(426003)(40480700001)(336012)(2906002)(40460700003)(478600001)(47076005)(7696005)(83380400001)(2616005)(341764005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2023 03:05:31.9002 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b4a292e-db8b-49b2-4653-08db04012e41 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: CO1NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5274 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() 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. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../RedfishDiscoverInternal.h | 4 ++ .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 52 +++++++++++++++---- .../RedfishSmbiosHostInterface.c | 2 +- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h index 04fa09e1cc..3e1bfcdc4d 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 @@ -182,6 +183,9 @@ typedef struct { // 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 /** diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 042d6d5fd5..e72ab71de8 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -4,6 +4,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 @@ -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)); @@ -519,6 +523,14 @@ DiscoverRedfishHostInterface ( 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); + } 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); } else { @@ -849,6 +861,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 +872,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 ( @@ -1467,11 +1489,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 +1514,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 +1543,7 @@ BuildupNetworkInterface ( IN EFI_HANDLE ControllerHandle ) { - UINT32 Id; + UINT32 *Id; UINT32 Index; EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; BOOLEAN IsNew; @@ -1581,10 +1607,8 @@ BuildupNetworkInterface ( 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; + 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; @@ -1678,6 +1702,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 diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c b/R= edfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c index 88cec1f416..b25a222a88 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c @@ -71,7 +71,7 @@ RedfishGetHostInterfaceProtocolData ( 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); } else { - ASSERT (SpecificDataLen > sizeof (REDFISH_HOST_INTERFACE_DEVIC= E_TYPE_USB_V2) + 1); + ASSERT (SpecificDataLen =3D=3D sizeof (USB_INTERFACE_DEVICE_DE= SCRIPTOR_V2) + 1); } =20 *DeviceDescriptor =3D (REDFISH_INTERFACE_DATA *)RecordTmp; --=20 2.39.1.windows.1