From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.71]) by mx.groups.io with SMTP id smtpd.web10.72523.1673273540742770919 for ; Mon, 09 Jan 2023 06:12:20 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=NNTmbcAP; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.220.71, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ir29N/Fdn+oMt1AaWso0aqOBJqwiUXSoyZqa1waTARRCJQlXR3JFSnRW+7uLsQVyTmTKqaFTzcCim+o6HbHy/vT0v98eNvOMavTUYsbH+Ve6HkUzaMGe/436HE+VnehrkeeBc9ER7KUqiREQoN0cKdg8gf34TghjtX/E44dpYEyIWiP/bICieJ39nokaGNx38lduWtKq5OhW5P6yK1yI4Y5vYEX7pVVj3r5fbI+BAy88zGIpl/ck8zGi39z9s5SK2DqjoebcB/bzrSagk/MFD9BhLedZRl2OtxC8SrwstyzfIksx4YIxYzG2GAYuS2KPn16U8WPqYnwvC3c+yndTlQ== 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=bJZ4Xsz3csNCbH7mU3L/uIMvg2khtsvWq1xnLmYp3UE=; b=WGXO6pg+tWiOF54IYdYGqdpRtp0+1ELW4bVNWrCRpsTKVpW7KVY73fEMR0i758h+h2HGcgWSscw7Y6yK85z4sKIpkU2FrDwLu0IYIgVfGyGYl9+AfIpAA0Nz7RTsfSoVS2tWv1ycAeDMuhjKN0OyUz8BCgmLGIYbiCsRhjyL7/UxRE0EPWMYy3HakwvgAkdGy+bkHKVFENRZm+4cZXNRHhviZ1X5vIyS1rJU8JlwuzSQ2pHLmjJ23YN/T0tO7EQD4r5FoazrKHsJCCHNo0LiEZ16dm+rqThFxutXjRbQsh6L+FnB2Ms0+HyeIHzqfsFcHiQ4RTimur7+wCBsy3tNVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bJZ4Xsz3csNCbH7mU3L/uIMvg2khtsvWq1xnLmYp3UE=; b=NNTmbcAP5puYfmZz0WAHv3FNcLZOeujYYiGJq9Gg2feJhgmcE+Xv6yWeH3vvjc325FDAqhmWsxN2A8Pi00TO8XoRnuBCd5RPX/L7UmxtpCb0ZlCndVp5SgAS/m2UwYocYvNAk+2hhQrSF5EotGgc4r8ikL8gOAaiXApwl62Bhgs= Received: from MW4PR03CA0177.namprd03.prod.outlook.com (2603:10b6:303:8d::32) by SJ0PR12MB8613.namprd12.prod.outlook.com (2603:10b6:a03:44d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Mon, 9 Jan 2023 14:12:17 +0000 Received: from CO1NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::5f) by MW4PR03CA0177.outlook.office365.com (2603:10b6:303:8d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 14:12:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT025.mail.protection.outlook.com (10.13.175.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5986.18 via Frontend Transport; Mon, 9 Jan 2023 14:12:17 +0000 Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 9 Jan 2023 08:12:14 -0600 From: "Chang, Abner" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-staging][PATCH 1/3] RedfishPkg/Library: Redfish BMC USBNIC Host Interface Date: Mon, 9 Jan 2023 22:11:22 +0800 Message-ID: <20230109141124.622-2-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230109141124.622-1-abner.chang@amd.com> References: <20230109141124.622-1-abner.chang@amd.com> MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT025:EE_|SJ0PR12MB8613:EE_ X-MS-Office365-Filtering-Correlation-Id: bb52ce53-7edb-4d63-4b49-08daf24b83ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EXrz7WAb7/F4vIdRwPBlMDqnzNX7lC19d1hHOQKTR8ikILlNf/vzMlaPiERKQ5IYvvuQQ1xQHeLnsyEyS6ZFYpABEDbLd4HnyHjJt71WhuGfyWogFmZi1XM8dzcEBY61olpVn9BPLWENGZXMUTGSfEOrZLRskYnj2BwP6T+aT0nVeHp/LcqMONDZYC5YlE8hsI37+LuWdWHeJS39p3TAEuhe76iJSvIIMnPx8Q8+qzi2GXqJ+40bo45ChawVXYaTD9el/NWDPpv71gBMXeXxdcBjITUv5MmWq/Dgs4Tz9p5VrJDnqK0txylEvSGUnmx+/XMzznemN778NNs8rA9bvzoyEGm03nRrrRZSHpAhwWxj5YFtiki9KmSrmVy99sZ+FCzkzjaIm4NvWaC9kk1RoOmTlhKDGgXW1oPFNzgsXCYE8tEuFZZsRpliHeZoaihymn43/3ShHEPq2/g188V/2HPEcuTYrj7LmlvSxYXXdAPLkgvsH7rcxk7sziCChoSpoFf1+eAWkcM1Ovrueo/m5PgWisFcgVORYb884iqYMA/V+ROQwz4w92gWmt/OJYt92I5YMyJM0vaBn+O5i8WAdIrTdFk8wiT/hECpZWQANA8jINJPOwmI5Wo1a8yy79/sxg/56CEoypV3Y/oNDPlvTG34D7Vt+GMb3c6Didns1H3xy9sxqAcNRPES7bS23ElB03TaXXaP34k6sL8/RKshmO2QPGe/kYY/fMrcHc7XFZ4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(478600001)(6666004)(47076005)(40480700001)(2616005)(1076003)(336012)(4326008)(16526019)(26005)(186003)(70586007)(70206006)(8676002)(6916009)(54906003)(316002)(7696005)(83380400001)(36860700001)(40460700003)(86362001)(81166007)(82740400003)(356005)(426003)(41300700001)(82310400005)(30864003)(36756003)(5660300002)(2876002)(2906002)(8936002)(36900700001)(579004)(559001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2023 14:12:17.4907 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb52ce53-7edb-4d63-4b49-08daf24b83ef X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8613 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang BMC exposed USB NIC platform Redfish Host Interface library implementation. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../PlatformHostInterfaceBmcUsbNicLib.inf | 44 + .../PlatformHostInterfaceBmcUsbNicLib.h | 83 ++ .../PlatformHostInterfaceBmcUsbNicLib.c | 1262 +++++++++++++++++ 3 files changed, 1389 insertions(+) create mode 100644 RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/Pl= atformHostInterfaceBmcUsbNicLib.inf create mode 100644 RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/Pl= atformHostInterfaceBmcUsbNicLib.h create mode 100644 RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/Pl= atformHostInterfaceBmcUsbNicLib.c diff --git a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformH= ostInterfaceBmcUsbNicLib.inf b/RedfishPkg/Library/PlatformHostInterfaceBmcU= sbNicLib/PlatformHostInterfaceBmcUsbNicLib.inf new file mode 100644 index 00000000000..6150e3d8480 --- /dev/null +++ b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInte= rfaceBmcUsbNicLib.inf @@ -0,0 +1,44 @@ +## @file +# Module to provide the platform Redfish Host Interface information +# of USB NIC Device exposed by BMC. +# +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001000b + BASE_NAME =3D PlatformHostInterfaceBmcUsbNicLib + FILE_GUID =3D C4837B58-225E-4352-8FDC-4C52A5D65891 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PlatformHostInterfaceBmcUsbNicLib + +[Sources] + PlatformHostInterfaceBmcUsbNicLib.c + PlatformHostInterfaceBmcUsbNicLib.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + NetworkPkg/NetworkPkg.dec + RedfishPkg/RedfishPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + IpmiLib + IpmiCommandLib + MemoryAllocationLib + UefiLib + UefiBootServicesTableLib + +[Protocols] + gEfiSimpleNetworkProtocolGuid ## CONSUMED + gEfiUsbIoProtocolGuid ## CONSUMED + gEfiDevicePathProtocolGuid ## CONSUMED + +[Depex] + TRUE diff --git a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformH= ostInterfaceBmcUsbNicLib.h b/RedfishPkg/Library/PlatformHostInterfaceBmcUsb= NicLib/PlatformHostInterfaceBmcUsbNicLib.h new file mode 100644 index 00000000000..6ec59a79892 --- /dev/null +++ b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInte= rfaceBmcUsbNicLib.h @@ -0,0 +1,83 @@ +/** @file +* Header file to provide the platform Redfish Host Interface information +* of USB NIC Device exposed by BMC. +* +* Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#ifndef PLATFORM_HOST_INTERFACE_BMC_USB_NIC_LIB_H_ +#define PLATFORM_HOST_INTERFACE_BMC_USB_NIC_LIB_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define BMC_USB_NIC_HOST_INTERFASCE_READINESS_GUID \ + { \ + 0xDD96F5D7, 0x4AE1, 0x4E6C, {0xA1, 0x30, 0xA5, 0xAC, 0x77, 0xDD, 0xE= 4, 0xA5} \ + } + +// +// This is the structure for BMC exposed +// USB NIC information. +// +typedef struct { + LIST_ENTRY NextInstance; ///< Link to t= he next instance. + BOOLEAN IsExposedByBmc; ///< Flag indi= cates this USB NIC is + ///< exposed b= y BMC. + BOOLEAN IsSuppportedHostInterface; ///< This BMC = USB NIC is supported + ///< as Redfis= h host interface + EFI_SIMPLE_NETWORK_PROTOCOL *ThisSnp; ///< The SNP i= nstance associated with + ///< this USB = NIC. + EFI_USB_IO_PROTOCOL *ThisUsbIo; ///< The USBIO= instance associated with + ///< this USB = NIC. + UINT16 UsbVendorId; ///< USB Vendo= r ID of this BMC exposed USB NIC. + UINT16 UsbProductId; ///< USB Produ= ct ID of this BMC exposed USB NIC. + UINTN MacAddressSize; ///< HW addres= s size. + UINT8 *MacAddress; ///< HW addres= s. + UINT8 IpmiLanChannelNumber; ///< BMC IPMI = Lan Channel number. + + // + // Below is the infortmation for building SMBIOS type 42. + // + UINT8 IpAssignedType; ///< Redfish ser= vice IP assign type. + UINT8 IpAddressFormat; ///< Redfish ser= vice IP version. + UINT8 HostIpAddressIpv4[4]; ///< Host IP add= ress. + UINT8 RedfishIpAddressIpv4[4]; ///< Redfish ser= vice IP address. + UINT8 SubnetMaskIpv4[4]; ///< Subnet mask= . + UINT8 GatewayIpv4[4]; ///< Gateway IP = address. + UINT16 VLanId; ///< VLAN ID. + BOOLEAN CredentialBootstrapping; ///< If Credenti= al bootstrapping is + ///< supported. +} HOST_INTERFACE_BMC_USB_NIC_INFO; + +// +// This is the structure for caching +// BMC IPMI LAN Channel +// +typedef struct { + LIST_ENTRY NextInstance; ///< Link to the next IPMI L= AN Channel. + UINT8 Channel; ///< IPMI Channel number. + EFI_MAC_ADDRESS MacAddress; ///< IPMI LAN Channel MAC ad= dress. + UINT8 MacAddressSize; ///< MAC address size; +} BMC_IPMI_LAN_CHANNEL_INFO; +#endif diff --git a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformH= ostInterfaceBmcUsbNicLib.c b/RedfishPkg/Library/PlatformHostInterfaceBmcUsb= NicLib/PlatformHostInterfaceBmcUsbNicLib.c new file mode 100644 index 00000000000..465ae7ecd40 --- /dev/null +++ b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInte= rfaceBmcUsbNicLib.c @@ -0,0 +1,1262 @@ +/** @file +* Source file to provide the platform Redfish Host Interface information +* of USB NIC Device exposed by BMC. +* +* Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include "PlatformHostInterfaceBmcUsbNicLib.h" + +static EFI_GUID mPlatformHostInterfaceBmcUsbNicReadinessGuid =3D + BMC_USB_NIC_HOST_INTERFASCE_READINESS_GUID; +static EFI_EVENT mPlatformHostInterfaceSnpEvent =3D NULL; +static VOID *mPlatformHostInterfaceSnpRegistration =3D NULL; + +static LIST_ENTRY mBmcUsbNic; +static LIST_ENTRY mBmcIpmiLan; + +/** + Probe if the system supports Redfish Host Interface Credentail + Bootstrapping. + + @retval TRUE Yes, it is supported. + TRUE No, it is not supported. + +**/ +BOOLEAN +ProbeRedfishCredentialBootstrap ( + VOID + ) +{ + EFI_STATUS Status; + IPMI_BOOTSTRAP_CREDENTIALS_COMMAND_DATA CommandData; + IPMI_BOOTSTRAP_CREDENTIALS_RESULT_RESPONSE ResponseData; + UINT32 ResponseSize; + BOOLEAN ReturnBool; + + DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__)); + + // + // IPMI callout to NetFn 2C, command 02 + // Request data: + // Byte 1: REDFISH_IPMI_GROUP_EXTENSION + // Byte 2: DisableBootstrapControl + // + CommandData.GroupExtensionId =3D REDFISH_IPMI_GROUP_EXTENSION; + CommandData.DisableBootstrapControl =3D REDFISH_IPMI_BOOTSTRAP_CREDENTIA= L_ENABLE; + ResponseData.CompletionCode =3D IPMI_COMP_CODE_UNSPECIFIED; + ResponseSize =3D sizeof (ResponseData); + // + // Response data: Ignored. + // + Status =3D IpmiSubmitCommand ( + IPMI_NETFN_GROUP_EXT, + REDFISH_IPMI_GET_BOOTSTRAP_CREDENTIALS_CMD, + (UINT8 *)&CommandData, + sizeof (CommandData), + (UINT8 *)&ResponseData, + &ResponseSize + ); + if (!EFI_ERROR (Status) && + ((ResponseData.CompletionCode =3D=3D IPMI_COMP_CODE_NORMAL) || + (ResponseData.CompletionCode =3D=3D REDFISH_IPMI_COMP_CODE_BOOTSTRA= P_CREDENTIAL_DISABLED) + )) + { + DEBUG ((DEBUG_INFO, " Redfish Credentail Bootstrapping is supported= \n", __FUNCTION__)); + ReturnBool =3D TRUE; + } else { + DEBUG ((DEBUG_INFO, " Redfish Credentail Bootstrapping is not suppo= rted\n", __FUNCTION__)); + ReturnBool =3D FALSE; + } + + return ReturnBool; +} + +/** + Get platform Redfish host interface device descriptor. + + @param[in] DeviceType Pointer to retrieve device type. + @param[out] DeviceDescriptor Pointer to retrieve REDFISH_INTERFACE_DATA= , caller has to free + this memory using FreePool(). + + @retval EFI_NOT_FOUND No Redfish host interface descriptor provided on= this platform. + +**/ +EFI_STATUS +RedfishPlatformHostInterfaceDeviceDescriptor ( + IN UINT8 *DeviceType, + OUT REDFISH_INTERFACE_DATA **DeviceDescriptor + ) +{ + HOST_INTERFACE_BMC_USB_NIC_INFO *ThisInstance; + REDFISH_INTERFACE_DATA *InterfaceData; + + DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__)); + + if (IsListEmpty (&mBmcUsbNic)) { + return EFI_NOT_FOUND; + } + + // Check if BMC exposed USB NIC is found and ready for using. + ThisInstance =3D (HOST_INTERFACE_BMC_USB_NIC_INFO *)GetFirstNode (&mBmcU= sbNic); + while (TRUE) { + if (ThisInstance->IsExposedByBmc && ThisInstance->IsSuppportedHostInte= rface) { + *DeviceType =3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2; + + // Fill up REDFISH_INTERFACE_DATA defined in Redfish host interface = spec v1.3 + InterfaceData =3D (REDFISH_INTERFACE_DATA *)AllocateZeroPool (USB_IN= TERFACE_DEVICE_DESCRIPTOR_V2_SIZE_1_3); + if (InterfaceData =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "Failed to allocate memory for REDFISH_INTERF= ACE_DATA\n")); + return EFI_OUT_OF_RESOURCES; + } + + InterfaceData->DeviceType =3D REDF= ISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2; + InterfaceData->DeviceDescriptor.UsbDeviceV2.Length =3D USB_= INTERFACE_DEVICE_DESCRIPTOR_V2_SIZE_1_3; + InterfaceData->DeviceDescriptor.UsbDeviceV2.IdVendor =3D This= Instance->UsbVendorId; + InterfaceData->DeviceDescriptor.UsbDeviceV2.IdProduct =3D This= Instance->UsbProductId; + InterfaceData->DeviceDescriptor.UsbDeviceV2.SerialNumberStr =3D 0; + CopyMem ( + (VOID *)&InterfaceData->DeviceDescriptor.UsbDeviceV2.MacAddress, + (VOID *)&ThisInstance->MacAddress, + sizeof (InterfaceData->DeviceDescriptor.UsbDeviceV2.MacAddress) + ); + InterfaceData->DeviceDescriptor.UsbDeviceV2.Characteristics = |=3D (UINT16)ThisInstance->CredentialBootstrapping; + InterfaceData->DeviceDescriptor.UsbDeviceV2.CredentialBootstrappingH= andle =3D 0; + *DeviceDescriptor = =3D InterfaceData; + DEBUG ((DEBUG_INFO, " REDFISH_INTERFACE_DATA is returned successf= ully.\n")); + return EFI_SUCCESS; + } + + if (IsNodeAtEnd (&mBmcUsbNic, &ThisInstance->NextInstance)) { + break; + } + + ThisInstance =3D (HOST_INTERFACE_BMC_USB_NIC_INFO *) + GetNextNode (&mBmcUsbNic, &ThisInstance->NextInstance); + } + + return EFI_NOT_FOUND; +} + +/** + Get platform Redfish host interface protocol data. + Caller should pass NULL in ProtocolRecord to retrive the first protocol = record. + Then continuously pass previous ProtocolRecord for retrieving the next P= rotocolRecord. + + @param[in, out] ProtocolRecord Pointer to retrieve the first or the nex= t protocol record. + caller has to free the new protocol reco= rd returned from + this function using FreePool(). + @param[in] IndexOfProtocolData The index of protocol data. + + @retval EFI_NOT_FOUND No more protocol records. + +**/ +EFI_STATUS +RedfishPlatformHostInterfaceProtocolData ( + IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord, + IN UINT8 IndexOfProtocolData + ) +{ + HOST_INTERFACE_BMC_USB_NIC_INFO *ThisInstance; + MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord; + REDFISH_OVER_IP_PROTOCOL_DATA *RedfishOverIpData; + UINT8 HostNameLength; + + DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__)); + + if (IsListEmpty (&mBmcUsbNic) || (IndexOfProtocolData > 0)) { + return EFI_NOT_FOUND; + } + + ThisInstance =3D (HOST_INTERFACE_BMC_USB_NIC_INFO *)GetFirstNode (&mBmcU= sbNic); + while (TRUE) { + if (ThisInstance->IsExposedByBmc && ThisInstance->IsSuppportedHostInt= erface) { + HostNameLength =3D 0; + ThisProtocolRecord =3D (MC_HOST_INTERFACE_PROTOCOL_RECORD *)Allocate= ZeroPool ( + sizeof (= MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1 + + sizeof (= REDFISH_OVER_IP_PROTOCOL_DATA) + + HostName= Length + ); + if (ThisProtocolRecord =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, " Aloocate memory fail for MC_HOST_INTERFA= CE_PROTOCOL_RECORD.\n")); + return EFI_OUT_OF_RESOURCES; + } + + ThisProtocolRecord->ProtocolType =3D MCHostInterfaceProtocolT= ypeRedfishOverIP; + ThisProtocolRecord->ProtocolTypeDataLen =3D sizeof (REDFISH_OVER_IP_= PROTOCOL_DATA) + HostNameLength; + RedfishOverIpData =3D (REDFISH_OVER_IP_PROTOCO= L_DATA *)&ThisProtocolRecord->ProtocolTypeData[0]; + // + // Fill up REDFISH_OVER_IP_PROTOCOL_DATA + // + + // ServiceUuid TODO: Redfish Host Interface spec update. + // RedfishOverIpData->ServiceUuid =3D ; + + // HostIpAddressFormat and RedfishServiceIpDiscoveryType + RedfishOverIpData->HostIpAssignmentType =3D RedfishHostIpAs= signmentUnknown; + RedfishOverIpData->RedfishServiceIpDiscoveryType =3D RedfishHostIpAs= signmentUnknown; + if (ThisInstance->IpAssignedType =3D=3D IpmiStaticAddrsss) { + RedfishOverIpData->HostIpAssignmentType =3D RedfishHostIp= AssignmentStatic; + RedfishOverIpData->RedfishServiceIpDiscoveryType =3D RedfishHostIp= AssignmentStatic; + } else if (ThisInstance->IpAssignedType =3D=3D IpmiDynamicAddressBmc= Dhcp) { + RedfishOverIpData->HostIpAssignmentType =3D RedfishHostIp= AssignmentDhcp; + RedfishOverIpData->RedfishServiceIpDiscoveryType =3D RedfishHostIp= AssignmentDhcp; + } + + // HostIpAddressFormat and RedfishServiceIpAddressFormat, only suppo= rt IPv4 for now. + RedfishOverIpData->HostIpAddressFormat =3D REDFISH_HOST_IN= TERFACE_HOST_IP_ADDRESS_FORMAT_IP4; + RedfishOverIpData->RedfishServiceIpAddressFormat =3D REDFISH_HOST_IN= TERFACE_HOST_IP_ADDRESS_FORMAT_IP4; + + // HostIpAddress + CopyMem ( + (VOID *)RedfishOverIpData->HostIpAddress, + (VOID *)ThisInstance->HostIpAddressIpv4, + sizeof (ThisInstance->HostIpAddressIpv4) + ); + + // HostIpMask and RedfishServiceIpMask + CopyMem ( + (VOID *)RedfishOverIpData->HostIpMask, + (VOID *)ThisInstance->SubnetMaskIpv4, + sizeof (ThisInstance->SubnetMaskIpv4) + ); + CopyMem ( + (VOID *)RedfishOverIpData->RedfishServiceIpMask, + (VOID *)ThisInstance->SubnetMaskIpv4, + sizeof (ThisInstance->SubnetMaskIpv4) + ); + + // RedfishServiceIpAddress + CopyMem ( + (VOID *)RedfishOverIpData->RedfishServiceIpAddress, + (VOID *)ThisInstance->RedfishIpAddressIpv4, + sizeof (ThisInstance->RedfishIpAddressIpv4) + ); + + // RedfishServiceIpPort + RedfishOverIpData->RedfishServiceIpPort =3D 0; + + // RedfishServiceVlanId + RedfishOverIpData->RedfishServiceVlanId =3D ThisInstance->VLanId; + + // RedfishServiceHostnameLength + RedfishOverIpData->RedfishServiceHostnameLength =3D 0; + + // RedfishServiceHostname TODO: Redfish Host Interface spec update. + // RedfishOverIpData->RedfishServiceHostname =3D ; + + DEBUG ((DEBUG_INFO, " MC_HOST_INTERFACE_PROTOCOL_RECORD is return= ed successfully.\n")); + *ProtocolRecord =3D ThisProtocolRecord; + return EFI_SUCCESS; + } + + if (IsNodeAtEnd (&mBmcUsbNic, &ThisInstance->NextInstance)) { + break; + } + + ThisInstance =3D (HOST_INTERFACE_BMC_USB_NIC_INFO *) + GetNextNode (&mBmcUsbNic, &ThisInstance->NextInstance); + } + + return EFI_NOT_FOUND; +} + +/** + This function retrieve the information of BMC USB NIC. + + @retval EFI_SUCCESS All necessary information is retrieved. + @retval EFI_NOT_FOUND There is no BMC exposed USB NIC. + @retval Others Other errors. + +**/ +EFI_STATUS +RetrievedBmcUsbNicInfo ( + VOID + ) +{ + EFI_STATUS Status; + UINT32 ResponseDataSize; + HOST_INTERFACE_BMC_USB_NIC_INFO *ThisInstance; + IPMI_GET_LAN_CONFIGURATION_PARAMETERS_REQUEST GetLanConfigReq; + IPMI_GET_LAN_CONFIGURATION_PARAMETERS_RESPONSE *GetLanConfigReps; + IPMI_LAN_IP_ADDRESS_SRC *IpAddressSrc; + IPMI_LAN_IP_ADDRESS *DestIpAddress; + IPMI_LAN_SUBNET_MASK *SubnetMask; + IPMI_LAN_DEFAULT_GATEWAY *DefaultGateway; + IPMI_LAN_VLAN_ID *LanVlanId; + EFI_USB_DEVICE_DESCRIPTOR UsbDeviceDescriptor; + + DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__)); + + if (IsListEmpty (&mBmcUsbNic)) { + return EFI_NOT_FOUND; + } + + ThisInstance =3D (HOST_INTERFACE_BMC_USB_NIC_INFO *)GetFirstNode (&mBmcU= sbNic); + while (TRUE) { + if (ThisInstance->IsExposedByBmc) { + ThisInstance->IsSuppportedHostInterface =3D FALSE; + + // Probe if Redfish Host Interface Credential Bootstrapping is suppo= rted. + ThisInstance->CredentialBootstrapping =3D ProbeRedfishCredentialBoot= strap (); + + // Get IP address source + GetLanConfigReq.SetSelector =3D 0; + GetLanConfigReq.BlockSelector =3D 0; + GetLanConfigReq.ChannelNumber.Bits.ChannelNo =3D ThisInstance->Ip= miLanChannelNumber; + GetLanConfigReq.ChannelNumber.Bits.GetParameter =3D 0; + GetLanConfigReq.ChannelNumber.Bits.Reserved =3D 0; + GetLanConfigReq.ParameterSelector =3D IpmiLanIpAddress= Source; + ResponseDataSize =3D sizeof (IPMI_GET= _LAN_CONFIGURATION_PARAMETERS_RESPONSE) + sizeof (IPMI_LAN_IP_ADDRESS_SRC); + GetLanConfigReps =3D (IPMI_GET_LAN_CO= NFIGURATION_PARAMETERS_RESPONSE *)AllocateZeroPool (ResponseDataSize); + GetLanConfigReps->CompletionCode =3D IPMI_COMP_CODE_U= NSPECIFIED; + Status =3D IpmiGetLanConfig= urationParameters ( + &GetLanConfigReq= , + GetLanConfigReps= , + &ResponseDataSiz= e + ); + if (EFI_ERROR (Status) || (GetLanConfigReps->CompletionCode !=3D IPM= I_COMP_CODE_NORMAL)) { + DEBUG ((DEBUG_ERROR, " Failed to get IP address source at chann= el %d: %r, 0x%02x.\n", ThisInstance->IpmiLanChannelNumber, Status, GetLanCo= nfigReps->CompletionCode)); + FreePool (GetLanConfigReps); + return Status; + } + + IpAddressSrc =3D (IPMI_LAN_IP_ADDRESS_SRC *)(GetLanConfigReps + 1); + DEBUG ((DEBUG_INFO, " IP address source at channel %d: %x\n", Thi= sInstance->IpmiLanChannelNumber, IpAddressSrc->Bits.AddressSrc)); + ThisInstance->IpAssignedType =3D IpAddressSrc->Bits.AddressSrc; + FreePool (GetLanConfigReps); + + // Get LAN IPv4 IP address + GetLanConfigReq.ParameterSelector =3D IpmiLanIpAddress; + ResponseDataSize =3D sizeof (IPMI_GET_LAN_CONFIGURA= TION_PARAMETERS_RESPONSE) + sizeof (IPMI_LAN_IP_ADDRESS); + GetLanConfigReps =3D (IPMI_GET_LAN_CONFIGURATION_PA= RAMETERS_RESPONSE *)AllocateZeroPool (ResponseDataSize); + GetLanConfigReps->CompletionCode =3D IPMI_COMP_CODE_UNSPECIFIED; + Status =3D IpmiGetLanConfigurationParamet= ers ( + &GetLanConfigReq, + GetLanConfigReps, + &ResponseDataSize + ); + if (EFI_ERROR (Status) || (GetLanConfigReps->CompletionCode !=3D IPM= I_COMP_CODE_NORMAL)) { + DEBUG ((DEBUG_ERROR, " Failed to get Dest IP address at channel= %d: %r, 0x%02x.\n", ThisInstance->IpmiLanChannelNumber, Status, GetLanConf= igReps->CompletionCode)); + FreePool (GetLanConfigReps); + return Status; + } + + DestIpAddress =3D (IPMI_LAN_IP_ADDRESS *)(GetLanConfigReps + 1); + DEBUG (( + DEBUG_INFO, + " Dest IP address at channel %d: %d.%d.%d.%d\n", + ThisInstance->IpmiLanChannelNumber, + DestIpAddress->IpAddress[0], + DestIpAddress->IpAddress[1], + DestIpAddress->IpAddress[2], + DestIpAddress->IpAddress[3] + )); + CopyMem ((VOID *)&ThisInstance->RedfishIpAddressIpv4, (VOID *)&DestI= pAddress->IpAddress, sizeof (DestIpAddress->IpAddress)); + // + // According to UEFI spec, the IP address at BMC USB NIC host end is= the IP address at BMC end minus 1. + // + CopyMem ((VOID *)&ThisInstance->HostIpAddressIpv4, (VOID *)&DestIpAd= dress->IpAddress, sizeof (DestIpAddress->IpAddress)); + ThisInstance->HostIpAddressIpv4[sizeof (ThisInstance->HostIpAddressI= pv4) - 1] -=3D 1; + FreePool (GetLanConfigReps); + DEBUG (( + DEBUG_INFO, + " Host IP address at channel %d: %d.%d.%d.%d\n", + ThisInstance->IpmiLanChannelNumber, + ThisInstance->HostIpAddressIpv4[0], + ThisInstance->HostIpAddressIpv4[1], + ThisInstance->HostIpAddressIpv4[2], + ThisInstance->HostIpAddressIpv4[3] + )); + + // Get IPv4 subnet mask + GetLanConfigReq.ParameterSelector =3D IpmiLanSubnetMask; + ResponseDataSize =3D sizeof (IPMI_GET_LAN_CONFIGURA= TION_PARAMETERS_RESPONSE) + sizeof (IPMI_LAN_SUBNET_MASK); + GetLanConfigReps =3D (IPMI_GET_LAN_CONFIGURATION_PA= RAMETERS_RESPONSE *)AllocateZeroPool (ResponseDataSize); + GetLanConfigReps->CompletionCode =3D IPMI_COMP_CODE_UNSPECIFIED; + Status =3D IpmiGetLanConfigurationParamet= ers ( + &GetLanConfigReq, + GetLanConfigReps, + &ResponseDataSize + ); + if ((EFI_ERROR (Status)) || (GetLanConfigReps->CompletionCode !=3D I= PMI_COMP_CODE_NORMAL)) { + DEBUG ((DEBUG_ERROR, " Failed to get subnet mask at channel %d:= %r, 0x%02x.\n", ThisInstance->IpmiLanChannelNumber, Status, GetLanConfigRe= ps->CompletionCode)); + FreePool (GetLanConfigReps); + return Status; + } + + SubnetMask =3D (IPMI_LAN_SUBNET_MASK *)(GetLanConfigReps + 1); + DEBUG (( + DEBUG_INFO, + " Subnet mask at channel %d: %d.%d.%d.%d\n", + ThisInstance->IpmiLanChannelNumber, + SubnetMask->IpAddress[0], + SubnetMask->IpAddress[1], + SubnetMask->IpAddress[2], + SubnetMask->IpAddress[3] + )); + CopyMem ((VOID *)&ThisInstance->SubnetMaskIpv4, (VOID *)&SubnetMask-= >IpAddress, sizeof (SubnetMask->IpAddress)); + FreePool (GetLanConfigReps); + + // Get Gateway IP address. + GetLanConfigReq.ParameterSelector =3D IpmiLanDefaultGateway; + ResponseDataSize =3D sizeof (IPMI_GET_LAN_CONFIGURA= TION_PARAMETERS_RESPONSE) + sizeof (IPMI_LAN_DEFAULT_GATEWAY); + GetLanConfigReps =3D (IPMI_GET_LAN_CONFIGURATION_PA= RAMETERS_RESPONSE *)AllocateZeroPool (ResponseDataSize); + GetLanConfigReps->CompletionCode =3D IPMI_COMP_CODE_UNSPECIFIED; + Status =3D IpmiGetLanConfigurationParamet= ers ( + &GetLanConfigReq, + GetLanConfigReps, + &ResponseDataSize + ); + if ((EFI_ERROR (Status)) || (GetLanConfigReps->CompletionCode !=3D I= PMI_COMP_CODE_NORMAL)) { + DEBUG ((DEBUG_ERROR, " Failed to get default gateway at channel= %d: %r, 0x%02x.\n", ThisInstance->IpmiLanChannelNumber, Status, GetLanConf= igReps->CompletionCode)); + FreePool (GetLanConfigReps); + return Status; + } + + DefaultGateway =3D (IPMI_LAN_DEFAULT_GATEWAY *)(GetLanConfigReps + 1= ); + DEBUG (( + DEBUG_INFO, + " Gateway at channel %d: %d.%d.%d.%d\n", + ThisInstance->IpmiLanChannelNumber, + DefaultGateway->IpAddress[0], + DefaultGateway->IpAddress[1], + DefaultGateway->IpAddress[2], + DefaultGateway->IpAddress[3] + )); + CopyMem ((VOID *)&ThisInstance->GatewayIpv4, (VOID *)&DefaultGateway= ->IpAddress, sizeof (DefaultGateway->IpAddress)); + FreePool (GetLanConfigReps); + + // Get VLAN ID + GetLanConfigReq.ParameterSelector =3D IpmiLanVlanId; + ResponseDataSize =3D sizeof (IPMI_GET_LAN_CONFIGURA= TION_PARAMETERS_RESPONSE) + sizeof (IPMI_LAN_VLAN_ID); + GetLanConfigReps =3D (IPMI_GET_LAN_CONFIGURATION_PA= RAMETERS_RESPONSE *)AllocateZeroPool (ResponseDataSize); + GetLanConfigReps->CompletionCode =3D IPMI_COMP_CODE_UNSPECIFIED; + Status =3D IpmiGetLanConfigurationParamet= ers ( + &GetLanConfigReq, + GetLanConfigReps, + &ResponseDataSize + ); + if ((EFI_ERROR (Status)) || (GetLanConfigReps->CompletionCode !=3D I= PMI_COMP_CODE_NORMAL)) { + DEBUG ((DEBUG_ERROR, " Failed to get VLAN ID at channel %d: %r,= 0x%02x.\n", ThisInstance->IpmiLanChannelNumber, Status, GetLanConfigReps->= CompletionCode)); + FreePool (GetLanConfigReps); + return Status; + } + + LanVlanId =3D (IPMI_LAN_VLAN_ID *)(GetLanConfigReps + 1); + ThisInstance->VLanId =3D 0; + if (LanVlanId->Data2.Bits.Enabled =3D=3D 1) { + ThisInstance->VLanId =3D LanVlanId->Data1.VanIdLowByte | (LanVlanI= d->Data2.Bits.VanIdHighByte << 8); + } + + DEBUG ((DEBUG_INFO, " VLAN ID %x\n", ThisInstance->VLanId)); + + FreePool (GetLanConfigReps); + + // + // Read USB device information. + // + if (ThisInstance->ThisUsbIo !=3D NULL) { + Status =3D ThisInstance->ThisUsbIo->UsbGetDeviceDescriptor (ThisIn= stance->ThisUsbIo, &UsbDeviceDescriptor); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, " USB NIC Vendor ID: 0x%04x, Device ID: 0= x%04x\n", UsbDeviceDescriptor.IdVendor, UsbDeviceDescriptor.IdProduct)); + ThisInstance->UsbVendorId =3D UsbDeviceDescriptor.IdVendor; + ThisInstance->UsbProductId =3D UsbDeviceDescriptor.IdProduct; + } else { + DEBUG ((DEBUG_INFO, " Fail to get USB device descriptor.\n"))= ; + } + } + + // All information is retrieved. + ThisInstance->IsSuppportedHostInterface =3D TRUE; + return EFI_SUCCESS; + } + + if (IsNodeAtEnd (&mBmcUsbNic, &ThisInstance->NextInstance)) { + break; + } + + ThisInstance =3D (HOST_INTERFACE_BMC_USB_NIC_INFO *) + GetNextNode (&mBmcUsbNic, &ThisInstance->NextInstance); + } + + return EFI_NOT_FOUND; +} + +/** + This function caches the found IPMI LAN channel. So we + don't have to sedn IPMI commands again if the USB NIC is + connected later. + + @param[in] ChannelNum The IPMI channel number. + @param[in] IpmiLanChannelMacAddress Pointer to EFI_MAC_ADDRESS. + @param[in] IpmiLanMacAddressSize The MAC address size. + + @retval EFI_SUCCESS IPMI LAN channel is cached. + @retval EFI_OUT_OF_RESOURCE Memory allocated failed. + @retval Others Other errors. + +**/ +EFI_STATUS +CacheIpmiLanMac ( + IN UINT8 ChannelNum, + IN EFI_MAC_ADDRESS *IpmiLanChannelMacAddress, + IN UINT8 IpmiLanMacAddressSize + ) +{ + BMC_IPMI_LAN_CHANNEL_INFO *ChannelInfo; + + ChannelInfo =3D (BMC_IPMI_LAN_CHANNEL_INFO *)AllocateZeroPool (sizeof (B= MC_IPMI_LAN_CHANNEL_INFO)); + if (ChannelInfo =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ChannelInfo->Channel =3D ChannelNum; + CopyMem ((VOID *)&ChannelInfo->MacAddress.Addr, (VOID *)IpmiLanChannelMa= cAddress->Addr, IpmiLanMacAddressSize); + ChannelInfo->MacAddressSize =3D IpmiLanMacAddressSize; + InitializeListHead (&ChannelInfo->NextInstance); + InsertTailList (&mBmcIpmiLan, &ChannelInfo->NextInstance); + return EFI_SUCCESS; +} + +/** + This function checks if the IPMI channel already identified + previously. + + @param[in] ChannelNum The IPMI channel number. + @param[out] CachedIpmiLanChannel Pointer to retrieve the cached + BMC_IPMI_LAN_CHANNEL_INFO. + + @retval EFI_SUCCESS IPMI LAN channel is found. + @retval Others Other errors. + +**/ +EFI_STATUS +CheckCachedIpmiLanMac ( + IN UINT8 ChannelNum, + OUT BMC_IPMI_LAN_CHANNEL_INFO **CachedIpmiLanChannel + ) +{ + BMC_IPMI_LAN_CHANNEL_INFO *ThisInstance; + + if (IsListEmpty (&mBmcIpmiLan)) { + return EFI_NOT_FOUND; + } + + ThisInstance =3D (BMC_IPMI_LAN_CHANNEL_INFO *)GetFirstNode (&mBmcIpmiLan= ); + while (TRUE) { + if (ThisInstance->Channel =3D=3D ChannelNum) { + *CachedIpmiLanChannel =3D ThisInstance; + return EFI_SUCCESS; + } + + if (IsNodeAtEnd (&mBmcIpmiLan, &ThisInstance->NextInstance)) { + break; + } + + ThisInstance =3D (BMC_IPMI_LAN_CHANNEL_INFO *) + GetNextNode (&mBmcIpmiLan, &ThisInstance->NextInstance)= ; + } + + return EFI_NOT_FOUND; +} + +/** + This function goes through IPMI channels to find the + mactched MAC addrss of BMC USB NIC endpoint. + + @param[in] UsbNicInfo The instance of HOST_INTERFACE_BMC_USB_NIC_INFO. + + @retval EFI_SUCCESS Yes, USB NIC exposed by BMC is found. + @retval EFI_NOT_FOUND No, USB NIC exposed by BMC is not found + on the existing SNP handle. + @retval Others Other errors. + +**/ +EFI_STATUS +HostInterfaceIpmiCheckMacAddress ( + IN HOST_INTERFACE_BMC_USB_NIC_INFO *UsbNicInfo + ) +{ + EFI_STATUS Status; + EFI_STATUS ExitStatus; + UINTN ChannelNum; + UINT32 ResponseDataSize; + IPMI_GET_CHANNEL_INFO_REQUEST GetChanelInfoRequest; + IPMI_GET_CHANNEL_INFO_RESPONSE GetChanelInfoResponse; + IPMI_GET_LAN_CONFIGURATION_PARAMETERS_REQUEST GetLanConfigReq; + IPMI_GET_LAN_CONFIGURATION_PARAMETERS_RESPONSE *GetLanConfigReps; + BMC_IPMI_LAN_CHANNEL_INFO *CachedIpmiLanChannel; + UINT8 IpmiLanMacAddressSize; + EFI_MAC_ADDRESS IpmiLanChannelMacAddress= ; + BOOLEAN AlreadyCached; + + DEBUG ((DEBUG_INFO, "%a: Entry.\n", __FUNCTION__)); + + GetLanConfigReps =3D NULL; + AlreadyCached =3D FALSE; + if (!IsListEmpty (&mBmcIpmiLan)) { + AlreadyCached =3D TRUE; + } + + // Initial the get MAC address request. + GetLanConfigReq.SetSelector =3D 0; + GetLanConfigReq.BlockSelector =3D 0; + GetLanConfigReq.ParameterSelector =3D IpmiLanMacAddress; + + ExitStatus =3D EFI_NOT_FOUND; + for (ChannelNum =3D IPMI_CHANNEL_NUMBER_IMPLEMENTATION_SPECIFIC_1; + ChannelNum <=3D IPMI_CHANNEL_NUMBER_IMPLEMENTATION_SPECIFIC_11; + ChannelNum++) + { + IpmiLanMacAddressSize =3D 0; + + // Check if the IPMI channel information is already cached. + Status =3D EFI_NOT_FOUND; + if (AlreadyCached) { + Status =3D CheckCachedIpmiLanMac ((UINT8)ChannelNum, &CachedIpmiLanC= hannel); + } + + if (Status =3D=3D EFI_SUCCESS) { + DEBUG ((DEBUG_INFO, " Got cached IPMI LAN info.\n")); + IpmiLanMacAddressSize =3D sizeof (IPMI_LAN_MAC_ADDRESS); + CopyMem ((VOID *)&IpmiLanChannelMacAddress.Addr, (VOID *)&CachedIpmi= LanChannel->MacAddress.Addr, IpmiLanMacAddressSize); + } else { + DEBUG ((DEBUG_INFO, " No cached IPMI LAN info\n")); + DEBUG ((DEBUG_INFO, " Send NetFn =3D App, Command =3D 0x42 to chann= el %d\n", ChannelNum)); + GetChanelInfoRequest.ChannelNumber.Bits.ChannelNo =3D (UINT8)Channel= Num; + Status =3D IpmiGetChannel= Info ( + &GetChanelInfo= Request, + &GetChanelInfo= Response, + &ResponseDataS= ize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, " - Fails to send command.\n", ChannelNum)= ); + continue; + } + + DEBUG ((DEBUG_INFO, " - Response data size =3D 0x%x\n", ResponseD= ataSize)); + if ((GetChanelInfoResponse.CompletionCode !=3D IPMI_COMP_CODE_NORMAL= ) || (ResponseDataSize =3D=3D 0)) { + DEBUG ((DEBUG_ERROR, " - Command returned fail: 0x%x.\n", GetCh= anelInfoResponse.CompletionCode)); + continue; + } + + DEBUG (( + DEBUG_INFO, + " - Channel protocol =3D 0x%x, Media =3D 0x%x\n", + GetChanelInfoResponse.ProtocolType.Bits.ChannelProtocolType, + GetChanelInfoResponse.MediumType.Bits.ChannelMediumType + )); + + if (GetChanelInfoResponse.ChannelNumber.Bits.ChannelNo !=3D ChannelN= um) { + DEBUG (( + DEBUG_ERROR, + " - ChannelNumber =3D %d in the response which is not macthed= to the request.\n", + GetChanelInfoResponse.ChannelNumber.Bits.ChannelNo + )); + continue; + } + + if ((GetChanelInfoResponse.MediumType.Bits.ChannelMediumType =3D=3D = IPMI_CHANNEL_MEDIA_TYPE_802_3_LAN) && + (GetChanelInfoResponse.ProtocolType.Bits.ChannelProtocolType =3D= =3D IPMI_CHANNEL_PROTOCOL_TYPE_IPMB_1_0)) + { + DEBUG ((DEBUG_INFO, " - Channel %d is a LAN device!\n", Channel= Num)); + + ResponseDataSize =3D sizeof (IPMI_GET_LAN_CONFIGURATION_PARAMETERS= _RESPONSE) + + sizeof (IPMI_LAN_MAC_ADDRESS); + if (GetLanConfigReps =3D=3D NULL) { + GetLanConfigReps =3D + (IPMI_GET_LAN_CONFIGURATION_PARAMETERS_RESPONSE *)AllocateZero= Pool (ResponseDataSize); + if (GetLanConfigReps =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, " Allocate memory failed for getting M= AC address.\n")); + continue; + } + } + + GetLanConfigReq.ChannelNumber.Bits.ChannelNo =3D (UINT8)ChannelNum= ; + GetLanConfigReps->CompletionCode =3D IPMI_COMP_CODE_UN= SPECIFIED; + Status =3D IpmiGetLanConfigu= rationParameters ( + &GetLanConfigReq, + GetLanConfigReps, + &ResponseDataSize + ); + if (EFI_ERROR (Status) || (GetLanConfigReps->CompletionCode !=3D I= PMI_COMP_CODE_NORMAL)) { + DEBUG (( + DEBUG_ERROR, + " Fails to get MAC address of channel %d, CompletionCode = =3D %02x.\n", + ChannelNum, + GetLanConfigReps->CompletionCode + )); + continue; + } else { + DEBUG ((DEBUG_INFO, " The MAC address of channel %d.\n", Chan= nelNum)); + DEBUG (( + DEBUG_INFO, + " %02x:%02x:%02x:%02x:%02x:%02x\n", + *((UINT8 *)(GetLanConfigReps + 1) + 0), + *((UINT8 *)(GetLanConfigReps + 1) + 1), + *((UINT8 *)(GetLanConfigReps + 1) + 2), + *((UINT8 *)(GetLanConfigReps + 1) + 3), + *((UINT8 *)(GetLanConfigReps + 1) + 4), + *((UINT8 *)(GetLanConfigReps + 1) + 5) + )); + IpmiLanMacAddressSize =3D sizeof (IPMI_LAN_MAC_ADDRESS); + CopyMem ((VOID *)&IpmiLanChannelMacAddress.Addr, (VOID *)(GetLan= ConfigReps + 1), IpmiLanMacAddressSize); + } + } + } + + if (IpmiLanMacAddressSize !=3D 0) { + if (!AlreadyCached) { + // Cache this IPMI LAN channel. + DEBUG ((DEBUG_INFO, " Cache this IPMI LAN channel.\n")); + CacheIpmiLanMac ((UINT8)ChannelNum, &IpmiLanChannelMacAddress, Ipm= iLanMacAddressSize); + } + + // + // According to UEFI spec section: TBD. + // Compare the first five MAC address and + // the 6th MAC address. + // + if ((IpmiLanMacAddressSize !=3D UsbNicInfo->MacAddressSize) || + (CompareMem ( + (VOID *)UsbNicInfo->MacAddress, + (VOID *)&IpmiLanChannelMacAddress.Addr, + IpmiLanMacAddressSize - 1 + ) !=3D 0) || + (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] !=3D + *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1) - 1) + ) + { + DEBUG ((DEBUG_INFO, " MAC address is not matched.\n")); + continue; + } + + // This is the NIC exposed by BMC. + UsbNicInfo->IpmiLanChannelNumber =3D (UINT8)ChannelNum; + UsbNicInfo->IsExposedByBmc =3D TRUE; + DEBUG ((DEBUG_INFO, " MAC address is matched.\n")); + ExitStatus =3D EFI_SUCCESS; + break; + } + } + + if (GetLanConfigReps !=3D NULL) { + FreePool (GetLanConfigReps); + } + + return ExitStatus; +} + +/** + This function searches the next MSG_USB_DP device path node. + + @param[in] ThisDevicePath Device path to search. + + @retval NULL MSG_USB_DP is not found. + Otherwise MSG_USB_DP is found. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +UsbNicGetNextMsgUsbDp ( + IN EFI_DEVICE_PATH_PROTOCOL *ThisDevicePath + ) +{ + if (ThisDevicePath =3D=3D NULL) { + return NULL; + } + + while (TRUE) { + ThisDevicePath =3D NextDevicePathNode (ThisDevicePath); + if (IsDevicePathEnd (ThisDevicePath)) { + return NULL; + } + + if ((ThisDevicePath->Type =3D=3D MESSAGING_DEVICE_PATH) && (ThisDevice= Path->SubType =3D=3D MSG_USB_DP)) { + return ThisDevicePath; + } + } + + return NULL; +} + +/** + This function search the UsbIo handle that matches the UsbDevicePath. + + @param[in] UsbDevicePath Device path of this SNP handle. + @param[out] UsbIo Return the UsbIo protocol. + + @retval EFI_SUCCESS Yes, UsbIo protocl is found. + @retval EFI_NOT_FOUND No, UsbIo protocl is not found + @retval Others Other errors. + +**/ +EFI_STATUS +UsbNicSearchUsbIo ( + IN EFI_DEVICE_PATH_PROTOCOL *UsbDevicePath, + OUT EFI_USB_IO_PROTOCOL **UsbIo + ) +{ + EFI_STATUS Status; + UINTN BufferSize; + EFI_HANDLE *HandleBuffer; + UINT16 Length; + UINTN Index; + CHAR16 *DevicePathStr; + EFI_DEVICE_PATH_PROTOCOL *TempDevicePath; + EFI_DEVICE_PATH_PROTOCOL *ThisDevicePath; + EFI_DEVICE_PATH_PROTOCOL *ThisDevicePathEnd; + EFI_DEVICE_PATH_PROTOCOL *ThisUsbDevicePath; + EFI_DEVICE_PATH_PROTOCOL *ThisUsbDevicePathEnd; + + DEBUG ((DEBUG_INFO, "%a: Entry.\n", __FUNCTION__)); + DEBUG ((DEBUG_INFO, "Device path on the EFI handle which has UsbIo and S= NP instaleld on it.\n")); + DevicePathStr =3D ConvertDevicePathToText (UsbDevicePath, FALSE, FALSE); + DEBUG ((DEBUG_INFO, "%s\n", DevicePathStr)); + FreePool (DevicePathStr); + + BufferSize =3D 0; + HandleBuffer =3D NULL; + *UsbIo =3D NULL; + Status =3D gBS->LocateHandle ( + ByProtocol, + &gEfiUsbIoProtocolGuid, + NULL, + &BufferSize, + NULL + ); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + DEBUG ((DEBUG_INFO, " %d UsbIo protocol instances.\n", BufferSize/siz= eof (EFI_HANDLE))); + HandleBuffer =3D AllocateZeroPool (BufferSize); + if (HandleBuffer =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, " Falied to allocate buffer for the handles.= \n")); + return EFI_OUT_OF_RESOURCES; + } + + Status =3D gBS->LocateHandle ( + ByProtocol, + &gEfiUsbIoProtocolGuid, + NULL, + &BufferSize, + HandleBuffer + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, " Falied to locate UsbIo protocol handles.\n")= ); + FreePool (HandleBuffer); + return Status; + } + } else { + return Status; + } + + for (Index =3D 0; Index < (BufferSize/sizeof (EFI_HANDLE)); Index++) { + Status =3D gBS->HandleProtocol ( + *(HandleBuffer + Index), + &gEfiDevicePathProtocolGuid, + (VOID **)&ThisDevicePath + ); + if (EFI_ERROR (Status)) { + continue; + } + + DEBUG ((DEBUG_INFO, "Device path on #%d instance of UsbIo.\n", Index))= ; + DevicePathStr =3D ConvertDevicePathToText (ThisDevicePath, FALSE, FALS= E); + DEBUG ((DEBUG_INFO, "%s\n", DevicePathStr)); + FreePool (DevicePathStr); + + Status =3D EFI_NOT_FOUND; + + // Search for the starting MSG_USB_DP node. + ThisUsbDevicePath =3D UsbDevicePath; + if ((DevicePathType (ThisUsbDevicePath) !=3D MESSAGING_DEVICE_PATH) || + (DevicePathSubType (ThisUsbDevicePath) !=3D MSG_USB_DP)) + { + ThisUsbDevicePath =3D UsbNicGetNextMsgUsbDp (ThisUsbDevicePath); + if (ThisUsbDevicePath =3D=3D NULL) { + continue; + } + } + + if ((DevicePathType (ThisDevicePath) !=3D MESSAGING_DEVICE_PATH) || + (DevicePathSubType (ThisDevicePath) !=3D MSG_USB_DP)) + { + ThisDevicePath =3D UsbNicGetNextMsgUsbDp (ThisDevicePath); + if (ThisDevicePath =3D=3D NULL) { + continue; + } + } + + // Search for the ending MSG_USB_DP node. + ThisDevicePathEnd =3D ThisDevicePath; + ThisUsbDevicePathEnd =3D ThisUsbDevicePath; + while (TRUE) { + TempDevicePath =3D UsbNicGetNextMsgUsbDp (ThisDevicePathEnd); + if (TempDevicePath =3D=3D NULL) { + break; + } + + ThisDevicePathEnd =3D TempDevicePath; + } + + while (TRUE) { + TempDevicePath =3D UsbNicGetNextMsgUsbDp (ThisUsbDevicePathEnd); + if (TempDevicePath =3D=3D NULL) { + break; + } + + ThisUsbDevicePathEnd =3D TempDevicePath; + } + + // Compare these two device paths + Length =3D (UINTN)(UINT8 *)ThisDevicePathEnd + DevicePathNodeLength (T= hisDevicePathEnd) - (UINTN)(UINT8 *)ThisDevicePath; + if (Length !=3D ((UINTN)(UINT8 *)ThisUsbDevicePathEnd + DevicePathNode= Length (ThisUsbDevicePathEnd) - (UINTN)(UINT8 *)ThisUsbDevicePath)) { + continue; + } + + if (CompareMem ( + (VOID *)ThisDevicePath, + (VOID *)ThisUsbDevicePath, + Length + ) =3D=3D 0) + { + Status =3D EFI_SUCCESS; + DEBUG ((DEBUG_INFO, "EFI handle with the correct UsbIo is found at #= %d instance of UsbIo.\n", Index)); + break; + } + } + + if (Status =3D=3D EFI_SUCCESS) { + // Locate UsbIo from this handle. + Status =3D gBS->HandleProtocol ( + *(HandleBuffer + Index), + &gEfiUsbIoProtocolGuid, + (VOID **)UsbIo + ); + return Status; + } + + return EFI_NOT_FOUND; +} + +/** + This function identifies if the USB NIC is exposed by BMC as + the host-BMC channel. + + @param[in] Handle This is the EFI handle with SNP installed. + @param[in] UsbDevicePath USB device path. + + @retval EFI_SUCCESS Yes, USB NIC exposed by BMC is found. + @retval EFI_NOT_FOUND No, USB NIC exposed by BMC is not found + on the existing SNP handle. + @retval Others Other errors. + +**/ +EFI_STATUS +IdentifyUsbNicBmcChannel ( + IN EFI_HANDLE Handle, + IN EFI_DEVICE_PATH_PROTOCOL *UsbDevicePath + ) +{ + UINTN Index; + EFI_STATUS Status; + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + EFI_USB_IO_PROTOCOL *UsbIo; + HOST_INTERFACE_BMC_USB_NIC_INFO *BmcUsbNic; + + DEBUG ((DEBUG_INFO, "%a: Entry.\n", __FUNCTION__)); + Status =3D gBS->HandleProtocol ( + Handle, + &gEfiSimpleNetworkProtocolGuid, + (VOID **)&Snp + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, " Failed to locate SNP.\n")); + return Status; + } + + Status =3D UsbNicSearchUsbIo (UsbDevicePath, &UsbIo); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, " Failed to find USBIO.\n")); + return Status; + } + + // Get the MAC address of this SNP instance. + BmcUsbNic =3D AllocateZeroPool (sizeof (HOST_INTERFACE_BMC_USB_NIC_INFO)= ); + if (BmcUsbNic =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, " Failed to allocate memory for HOST_INTERFACE= _BMC_USB_NIC_INFO.\n")); + return EFI_OUT_OF_RESOURCES; + } + + InitializeListHead (&BmcUsbNic->NextInstance); + BmcUsbNic->MacAddressSize =3D Snp->Mode->HwAddressSize; + BmcUsbNic->MacAddress =3D AllocateZeroPool (sizeof (BmcUsbNic->MacAd= dressSize)); + if (BmcUsbNic->MacAddress =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, " Failed to allocate memory for HW MAC address= s.\n")); + FreePool (BmcUsbNic); + return EFI_OUT_OF_RESOURCES; + } + + CopyMem ( + (VOID *)BmcUsbNic->MacAddress, + (VOID *)&Snp->Mode->CurrentAddress, + BmcUsbNic->MacAddressSize + ); + DEBUG ((DEBUG_INFO, " MAC address (in size %d) for this SNP instance:= \n ", BmcUsbNic->MacAddressSize)); + for (Index =3D 0; Index < BmcUsbNic->MacAddressSize; Index++) { + DEBUG ((DEBUG_INFO, "%02x ", *(BmcUsbNic->MacAddress + Index))); + } + + DEBUG ((DEBUG_INFO, "\n")); + BmcUsbNic->ThisSnp =3D Snp; + BmcUsbNic->ThisUsbIo =3D UsbIo; + + Status =3D HostInterfaceIpmiCheckMacAddress (BmcUsbNic); + if (Status =3D=3D EFI_SUCCESS) { + BmcUsbNic->IsExposedByBmc =3D TRUE; + DEBUG ((DEBUG_INFO, " BMC exposed USB NIC is found.\n")); + } else { + DEBUG ((DEBUG_INFO, " BMC exposed USB NIC is not found.\n")); + } + + InsertTailList (&mBmcUsbNic, &BmcUsbNic->NextInstance); + return Status; +} + +/** + This function checks if the USB NIC exposed by BMC + on each handle has SNP protocol installed on it. + + @param[in] HandleNumer Number of handles to check. + @param[in] HandleBuffer Handles buffer. + + @retval EFI_SUCCESS Yes, USB NIC exposed by BMC is found. + @retval EFI_NOT_FOUND No, USB NIC exposed by BMC is not found + on the existing SNP handle. + @retval Others Other errors. + +**/ +EFI_STATUS +CheckBmcUsbNicOnHandles ( + IN UINTN HandleNumer, + IN EFI_HANDLE *HandleBuffer + ) +{ + UINTN Index; + EFI_STATUS Status; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + if ((HandleNumer =3D=3D 0) || (HandleBuffer =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((DEBUG_INFO, "%a: Entry, #%d SNP handle\n", __FUNCTION__, HandleN= umer)); + + for (Index =3D 0; Index < HandleNumer; Index++) { + Status =3D gBS->HandleProtocol ( + *(HandleBuffer + Index), + &gEfiDevicePathProtocolGuid, + (VOID **)&DevicePath + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, " Failed to locate SNP on %d handle.\n", __F= UNCTION__, Index)); + continue; + } + + // Check if this is an BMC exposed USB NIC device. + while (TRUE) { + if ((DevicePath->Type =3D=3D MESSAGING_DEVICE_PATH) && (DevicePath->= SubType =3D=3D MSG_USB_DP)) { + Status =3D IdentifyUsbNicBmcChannel (*(HandleBuffer + Index), Devi= cePath); + if (!EFI_ERROR (Status)) { + break; + } + } + + DevicePath =3D NextDevicePathNode (DevicePath); + if (IsDevicePathEnd (DevicePath)) { + break; + } + } + } + + return EFI_NOT_FOUND; +} + +/** + This function checks if the USB NIC exposed by BMC + is already connected. + + @param[in] Registration Locate SNP protocol from the notification + registeration key. + NULL means locate SNP protocol from the exi= sting + handles. + + @retval EFI_SUCCESS Yes, USB NIC exposed by BMC is found. + @retval EFI_NOT_FOUND No, USB NIC exposed by BMC is not found + on the existing SNP handle. + @retval Others Other errors. + +**/ +EFI_STATUS +CheckBmcUsbNic ( + VOID *Registration + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + UINTN BufferSize; + EFI_HANDLE *HandleBuffer; + + DEBUG ((DEBUG_INFO, "%a: Entry, the registration key - 0x%08x.\n", __FUN= CTION__, Registration)); + + Handle =3D NULL; + Status =3D EFI_SUCCESS; + BufferSize =3D 0; + + Status =3D gBS->LocateHandle ( + Registration =3D=3D NULL ? ByProtocol : ByRegisterNotify= , + &gEfiSimpleNetworkProtocolGuid, + Registration, + &BufferSize, + NULL + ); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + DEBUG ((DEBUG_INFO, " %d SNP protocol instances.\n", BufferSize/siz= eof (EFI_HANDLE))); + HandleBuffer =3D AllocateZeroPool (BufferSize); + if (HandleBuffer =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, " Falied to allocate buffer for the handles.= \n")); + return EFI_OUT_OF_RESOURCES; + } + + Status =3D gBS->LocateHandle ( + Registration =3D=3D NULL ? ByProtocol : ByRegisterNoti= fy, + &gEfiSimpleNetworkProtocolGuid, + Registration, + &BufferSize, + HandleBuffer + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, " Falied to locate SNP protocol handles.\n")= ); + FreePool (HandleBuffer); + return Status; + } + } else if (EFI_ERROR (Status)) { + return Status; + } + + // Check USB NIC on handles. + Status =3D CheckBmcUsbNicOnHandles (BufferSize/sizeof (EFI_HANDLE), Hand= leBuffer); + if ((Registration !=3D NULL) && !EFI_ERROR (Status)) { + // Retrieve the rest of BMC USB NIC information for Redfish over IP in= formation + // and USB Network Interface V2. + Status =3D RetrievedBmcUsbNicInfo (); + + DEBUG ((DEBUG_INFO, " Install protocol to notify the platform Redfi= sh Host Interface information is ready.\n")); + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &mPlatformHostInterfaceBmcUsbNicReadinessGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, " Install protocol fail %r.\n", Status)); + } + } + + FreePool (HandleBuffer); + return Status; +} + +/** + Notification event of SNP readiness. + + @param[in] Event Event whose notification function is b= eing invoked. + @param[in] Context The pointer to the notification functi= on's context, + which is implementation-dependent. + +**/ +VOID +EFIAPI +PlatformHostInterfaceSnpCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + DEBUG ((DEBUG_INFO, "%a: Entry.\n", __FUNCTION__)); + + CheckBmcUsbNic (mPlatformHostInterfaceSnpRegistration); + return; +} + +/** + Get the EFI protocol GUID installed by platform library which + indicates the necessary information is ready for building + SMBIOS 42h record. + + @param[out] InformationReadinessGuid Pointer to retrive the protocol + GUID. + + @retval EFI_SUCCESS Notification is required for building up + SMBIOS type 42h record. + @retval EFI_UNSUPPORTED Notification is not required for building u= p + SMBIOS type 42h record. + @retval EFI_ALREADY_STARTED Platform host information is already ready. + @retval Others Other errors. +**/ +EFI_STATUS +RedfishPlatformHostInterfaceNotification ( + OUT EFI_GUID **InformationReadinessGuid + ) +{ + EFI_STATUS Status; + + DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__)); + + *InformationReadinessGuid =3D NULL; + InitializeListHead (&mBmcUsbNic); + InitializeListHead (&mBmcIpmiLan); + + // + // Check if USB NIC exposed by BMC is already + // connected. + // + Status =3D CheckBmcUsbNic (NULL); + if (!EFI_ERROR (Status)) { + return EFI_ALREADY_STARTED; + } + + if (Status =3D=3D EFI_NOT_FOUND) { + DEBUG ((DEBUG_INFO, "%a: BMC USB NIC is not found. Register the notifi= cation.\n", __FUNCTION__)); + + // Register the notification of SNP installation. + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + PlatformHostInterfaceSnpCallback, + NULL, + &mPlatformHostInterfaceSnpEvent + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to create event for the installation = of SNP protocol.", __FUNCTION__)); + return Status; + } + + Status =3D gBS->RegisterProtocolNotify ( + &gEfiSimpleNetworkProtocolGuid, + mPlatformHostInterfaceSnpEvent, + &mPlatformHostInterfaceSnpRegistration + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installatio= n of SNP protocol.", __FUNCTION__)); + return Status; + } + + *InformationReadinessGuid =3D &mPlatformHostInterfaceBmcUsbNicReadines= sGuid; + return EFI_SUCCESS; + } + + DEBUG ((DEBUG_ERROR, "%a: Something wrong when look for BMC USB NIC.\n",= __FUNCTION__)); + return Status; +} --=20 2.37.1.windows.1