From nobody Tue May 14 22:06:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98190+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1673273542100554.6115681537732; Mon, 9 Jan 2023 06:12:22 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id PO2jYY1788612xTFlJ78G529; Mon, 09 Jan 2023 06:12:21 -0800 X-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 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 X-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 X-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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+98190+1787277+3901457@groups.io; helo=mail02.groups.io; 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 X-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 X-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 via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [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> In-Reply-To: <20230109141124.622-1-abner.chang@amd.com> References: <20230109141124.622-1-abner.chang@amd.com> MIME-Version: 1.0 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-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-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 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com X-Gm-Message-State: h2xu6X1OeKU0VUtaq2WJJZsex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1673273541; bh=1dXONVoKCP1ZOr24PVKau7l1aJWo4nxDaH7VKENNFjs=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=f8nmPYnZhzixI38gWTBj1zoFsGBU5P2+SNpzQhioIn9ef4BBbcDbVjLhqHpo+2cfMPK uW3Murnk5o2IYxTw69rRfQS2ZnetMvB3XlF4hnCn8HeBklVEtg8OoXm3TBBtoOV9lZuIb /o3qXTVgHa9lRHhcEDZI2FmIT9OhxV5aXYU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1673273543511100005 Content-Type: text/plain; charset="utf-8" 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, + &ResponseDataSize + ); + 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 up + 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#98190): https://edk2.groups.io/g/devel/message/98190 Mute This Topic: https://groups.io/mt/96152740/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 14 22:06:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98191+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1673273546657899.5049165794935; Mon, 9 Jan 2023 06:12:26 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8kssYY1788612xZoByloa3Ia; Mon, 09 Jan 2023 06:12:26 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.46]) by mx.groups.io with SMTP id smtpd.web11.72723.1673273545181049651 for ; Mon, 09 Jan 2023 06:12:25 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BTOyJ85PwsB3YHEU8+IIL/KsLHAQJkGKt6VNUrm5Jtx+hK70OnhSBWyYowBaWuf3hm0V4Wc+f7Y1VS3A6I9vmKycvOSpL3cguI6x2NO6upFa4kk9NXr/Xwo7KYtT/09HBxtCx5waxtUJTXBt4BZfOQJF4T2hbZFowPa/4wPLJHbRFz3SJj6ohzBX26oruO+WrZ/ewNgtxrHJqOwQCFKV5eWsHX44byK81tCUM2toGoNP7TfIrxEn/ZC9cHZ5Ta+DXjgtyJi0Ig7Fb7xb3ZekzJ9YUO1ATaRCRqJvNN5imeLPqhNjvUkyopL7lHDyUlt48evIeJWFkQRguTrF216MKw== 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=+UgrzOI3jKxRYl8t5vfpN4bX+KyUB4qyK2lA63wZXBI=; b=gI0nydaLGei4xWQqkTzyQMMr0eMXvKUkkUWnOK9tbEd6X5qM5GNss2kAeJ0dRFsUNvzPVpdgKJfzgXVLv1iujeeNwJmrZMYg14kIQjJCGpq5Sap3Kd5pmOiiV0ys3K+JYaJBUM4eDumFwYRruqO5ChfDgr1k3gQNEyZe413LNhk9vnQWhhEzXpULZdKwetQQBPur3Y2MkRd91dn6gbYbbdOsbadYqbGQgX1trzh0VPaFxR9gpdZzbLzup8XsKyi0efees1KAm+zBCK8R8RYLaWnDAkaDsEbQOmRAhmx25TLkD+4HyilxhTZz0tZcyjxvB2NNBol8YdY84NNIsy+8Ww== 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 X-Received: from MW3PR06CA0029.namprd06.prod.outlook.com (2603:10b6:303:2a::34) by CO6PR12MB5475.namprd12.prod.outlook.com (2603:10b6:5:354::7) 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:20 +0000 X-Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2a:cafe::16) by MW3PR06CA0029.outlook.office365.com (2603:10b6:303:2a::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19 via Frontend Transport; Mon, 9 Jan 2023 14:12:20 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+98191+1787277+3901457@groups.io; helo=mail02.groups.io; 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 X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) 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:20 +0000 X-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:17 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [edk2-staging][PATCH 2/3] RedfishPkg: Update Redfish DSC Date: Mon, 9 Jan 2023 22:11:23 +0800 Message-ID: <20230109141124.622-3-abner.chang@amd.com> In-Reply-To: <20230109141124.622-1-abner.chang@amd.com> References: <20230109141124.622-1-abner.chang@amd.com> MIME-Version: 1.0 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: CO1NAM11FT033:EE_|CO6PR12MB5475:EE_ X-MS-Office365-Filtering-Correlation-Id: d3a946f2-431f-4993-e89a-08daf24b85c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: xrqF8oyq/oyf/lssQy/vOtzdTernFZc5TizW3o/B3h9zXwq72sHpmACdWQv3SrhAWiEeiLfCuofPjbMUeLVFb1aMNj26XGqbIUPQZ8WIftumMQWTJWEiD1uAv3FNl9WS2idfFGHo17E5Ki0dX2rDyvQBX4s3YFey2Q7lOOyKLrLmtcqNZNB4BGT8NdI9cBSm9xDp1WncE11CF3kzfVk39IDicGjg8Rl5wJg17pk3z7lj95lppluMVHATnXGCtF8m001Yj3/0viIFHbIHgWO6iOJoXFKUSEMRDUdFNm9hq03tvufTPqbogMXsiZKdyuIxPMj3q6iRAysZCwisjr5Gcvuz+dJKefW9D7BABZvr+kj7Pq7JS5pBGA/uMW12GVdgQTbcqg+EErNXrEDDjPD3iZ77S+km4cRKIy7bNDDFoJumjXRvqSQkzlKmZRJWk2DyQ/ARta5OMwEo5XrjF+yXhQ6jYwVWc2lFmb7CfnowG++ZHPLxmHEaUlsixbqiFoBKCyZs/6CsowOjlxpILnjKr7gIJ9wjKCPXRDl+vaekPVHP2Sm+i4gONkuJLJiLleeVVaXixAW6SizdqmW3A9FBCShhFl8ojrzkLsFwynoqhKhNtg/Daw3gUGsVEwctuI4mDotnzX7iiSfM+ZlZlwxfynzmKjgAL+k2wFe9ukA08w9+5u3bewS3B4wCedOetteIRWFCatmBlAkOlLRoYJoyCJcQ8OBN2E0OD6vo6Zn97FM= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2023 14:12:20.5658 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3a946f2-431f-4993-e89a-08daf24b85c6 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: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5475 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com X-Gm-Message-State: 3Qn4OMbV7dMqajnsNqTgxVfcx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1673273546; bh=OwA4sQuZeJE5xQLVnhVgpWWJTcXGEMM+wK9rFL/TEK4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=JaIgzdMrChtQuVB75Tfg8Au4cXSP1RPZEmBQ8mwkcZNIgkWFTSHZr6wIvqL/tAAzbik U3gRh13vUdABe04miod/FnnoaaO9Pau/IiFOJbyO7UUVac2FaSlCEaIlVkN0Gsop7ruqd GkK6DyHbBO9F+uibZ3NEURYgLY0N2Z4jzo8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1673273547533100001 Content-Type: text/plain; charset="utf-8" From: Abner Chang Update Redfish DSC for PlatformHostInterfaceBmcUsbNicLib. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy --- RedfishPkg/RedfishPkg.dsc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/RedfishPkg/RedfishPkg.dsc b/RedfishPkg/RedfishPkg.dsc index 16139146ff8..3f6a397794a 100644 --- a/RedfishPkg/RedfishPkg.dsc +++ b/RedfishPkg/RedfishPkg.dsc @@ -3,6 +3,7 @@ # # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
# (C) Copyright 2021 Hewlett-Packard Enterprise Development LP. +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -34,6 +35,7 @@ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD= ebugPrintErrorLevelLib.inf PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf RedfishPlatformHostInterfaceLib|RedfishPkg/Library/PlatformHostInterface= LibNull/PlatformHostInterfaceLibNull.inf + RedfishPlatformHostInterfaceLib|RedfishPkg/Library/PlatformHostInterface= BmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.inf HttpLib|NetworkPkg/Library/DxeHttpLib/DxeHttpLib.inf HttpIoLib|NetworkPkg/Library/DxeHttpIoLib/DxeHttpIoLib.inf NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf @@ -41,6 +43,10 @@ RedfishPlatformCredentialLib|RedfishPkg/Library/PlatformCredentialLibNul= l/PlatformCredentialLibNull.inf RedfishContentCodingLib|RedfishPkg/Library/RedfishContentCodingLibNull/R= edfishContentCodingLibNull.inf =20 + # NULL instance of IPMI related library. + IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf + IpmiCommandLib|MdeModulePkg/Library/BaseIpmiCommandLibNull/BaseIpmiComma= ndLibNull.inf + [LibraryClasses.ARM, LibraryClasses.AARCH64] # # This library provides the instrinsic functions generated by a given co= mpiler. @@ -51,6 +57,7 @@ =20 [Components] RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLib= Null.inf + RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfa= ceBmcUsbNicLib.inf RedfishPkg/Library/PlatformCredentialLibNull/PlatformCredentialLibNull.i= nf RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNu= ll.inf RedfishPkg/Library/DxeRestExLib/DxeRestExLib.inf --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#98191): https://edk2.groups.io/g/devel/message/98191 Mute This Topic: https://groups.io/mt/96152743/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue May 14 22:06:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98192+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1673273569983306.95572857036984; Mon, 9 Jan 2023 06:12:49 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ercHYY1788612xFolPTc4awq; Mon, 09 Jan 2023 06:12:49 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web10.72535.1673273568315947231 for ; Mon, 09 Jan 2023 06:12:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KGWa9QpqgmsNaZayKMDwlTf/TVz89Pz+HfjK6o1jwPvifcbFHzvs2LO/gdTOkubfeCInXVcP0OPyis1rtcg140xCWb1oRLspsaSSi6tHI4yaDHHkILQe43GFwHUCHf2Fo1VZcIGo+sR74te07SJwBN5M0vooyNZsRcr9Z8QNAbgoRSGPAjQZ9AHGvtkahPlkT/mugumjWaRRjfhm3Dqe+Ya6brR4PQQTE65ZUxp+ci3ybwJY5AR6Pswz8VJQ6pzQJmgaguNEZxYlX4dScymX/HNi5CJ03fvkyPHbHNaBrFWgUtJFutglVPuMzWo2VF57/P8eUREvu4oSDa7Peo9/3Q== 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=IwLvkkKdE4iyr0zyawzlWUywJYe5G1FcSJbFLQ7Kw/w=; b=T/A2yehZpqXwOOH4yjpBIcThuJxRFmmA0RlS5FRAguv9Kbyexwy93e66ejubvbcyKL04Ynh3Q3LZC7rWwa0MXPx5/t5f1Fkr0ZiBPW+BCO4Jiu+OTvrblODR9V6FUenNBAuSHAqbvbN8B0sxXRqzeZISSHE/r8R9i1gdqCNvw6v6LfVMOlxBtMMuGC4VpId408CfCHBZBwNSAPvpRypf0MCacOoiOBWlTOxx6zT4+cH4bUCIwwA38bgk2ftbKhxdQzNvn10+tIoxAHGmJXbCZHNFDy/+zk7wl/H034S691Wc0o/fXtL+rueZWCiCVdN+l8SXB58Fw/C4n2S9q3J+ZQ== 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 X-Received: from MW3PR06CA0005.namprd06.prod.outlook.com (2603:10b6:303:2a::10) by MN0PR12MB5738.namprd12.prod.outlook.com (2603:10b6:208:371::12) 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:42 +0000 X-Received: from CO1NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2a:cafe::9c) by MW3PR06CA0005.outlook.office365.com (2603:10b6:303:2a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19 via Frontend Transport; Mon, 9 Jan 2023 14:12:41 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+98192+1787277+3901457@groups.io; helo=mail02.groups.io; 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 X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT033.mail.protection.outlook.com (10.13.174.247) 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:23 +0000 X-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:19 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [edk2-staging][PATCH 3/3] RedfishPkg: Update Readme.md Date: Mon, 9 Jan 2023 22:11:24 +0800 Message-ID: <20230109141124.622-4-abner.chang@amd.com> In-Reply-To: <20230109141124.622-1-abner.chang@amd.com> References: <20230109141124.622-1-abner.chang@amd.com> MIME-Version: 1.0 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: CO1NAM11FT033:EE_|MN0PR12MB5738:EE_ X-MS-Office365-Filtering-Correlation-Id: f2a953e6-dcef-4115-02d7-08daf24b926a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: 0my8c8lMkCmVB0pQr0/klecZqnw/jRgQ2nTRkoD/FkM5ZZg/gIaZtPatoAQ0CD3U2K01WyTEmeSbaBIFPs5K0eMswzoliMTnq4t40dDrQTHY3YPl3CyAia/QDoI7K39jTjiZdGKkAnYKLl1GAP+FnoPRDAnUwz4AH5iJd4/hMjppWA+BNgFQEoMZTyFxKZrR99x8pl62fKBzQKpeI60NZqc/LDvz1JcelWQNlawWFor2U8w0KVgqKmyaOKALvbrUIfmEpdshcGXK8ir17RvJ9HPQ77Z0yBIzZ4VjW0Yk+BhN5u1RwJFSSDk99ULoetRC8a02ULUnkYESEyGrC1BDYGl+r6n9pvyPZ6bRbLewom1dNSqTH01uzgQ5gX7d6CZIJUwK3wcIWVOBXgFy4UUjocoWx9T94GHhTJB0dd/uw2iz9AvQ414L5IMAwhoujgx5xux91SyE2z3Cc2SeN+RWkksDc2Mtw/fbmZ6zhvlPorFYxzDxfOBvXs+1xVbH38Rn/AorXkUYJZd99oHQG7ixEjQf7piOBN6z/sUpBtoVsrrYY4kTV41+nNJqlHzfV3KTEsElK/8rKoojqDB286ZXPrI5GNdgUGdM+4qPoBJqRWPgRXHKeX8VWy80RUSlPirgZSL40bFm2lhORz1AtZIL9OSuO3xP9NdUXGhmwrGLV1dURSyZhfk2ksTY7q5UsyJiFW42SZHM1cCsbA6xzUUfbaxsWpnJGVP2UNsI4/Ze+XxPPTLu9oQ+TKfQAQcmHfC5ph2tQbVrzpl7EvJly9F9h1o0qKNOv/Nnge13GxIN52yuf3f6KGYkcKHyTBVdwEff7e7GtlxuoBGcM5byD24BPw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2023 14:12:23.0187 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2a953e6-dcef-4115-02d7-08daf24b926a 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: CO1NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5738 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com X-Gm-Message-State: mTerqFtlkTZpkBr5tUDEobRlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1673273569; bh=v/CJV57gKpNSr2dOuZ21Lmxoss1DG2nFX51/FM4Mmlc=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=NaEFlVMGfwafl+NJDgPBdCxdA4ymL1HQes4u3LOcOQmf2CjU4a/t68q34Wlqy1+ICDI kbu4x68prqqcBMW+vVFUnwRJSXNNq43C8W9CTukSC2iiu/71HYMOsDpT+KvL+y41qNoGN 1qD0tZcic94adkrTZ7ncm6wzh8kQ67pceV0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1673273571565100001 Content-Type: text/plain; charset="utf-8" From: Abner Chang Update readme.md and add figures to delineate the relationship of edk2 Redfish, USB NIC and IPMI. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy --- RedfishPkg/Readme.md | 95 ++++- .../Media/Emualtor Platform Library.svg | 286 +++++++++++++++ .../Media/Platform wiht BMC Library.svg | 328 ++++++++++++++++++ .../Documents/Media/USB Exposed USB NIC.svg | 283 +++++++++++++++ 4 files changed, 984 insertions(+), 8 deletions(-) create mode 100644 RedfishPkg/Documents/Media/Emualtor Platform Library.svg create mode 100644 RedfishPkg/Documents/Media/Platform wiht BMC Library.svg create mode 100644 RedfishPkg/Documents/Media/USB Exposed USB NIC.svg diff --git a/RedfishPkg/Readme.md b/RedfishPkg/Readme.md index a0e9f0892c2..80b687db9f0 100644 --- a/RedfishPkg/Readme.md +++ b/RedfishPkg/Readme.md @@ -50,12 +50,90 @@ The library is incorporated with RedfishLib ***[[13]](#= [0])*** to encode and dec * **RedfishPkg\Library\JsonLib** ***[[14]](#[0])*** This is the wrapper of open source project ***[Jansson](https://digip.or= g/jansson)***, which is the library that provides APIs to manipulate JSON = payload. =20 -## Platform Components for EDK2 EmulatorPkg: - * **RedfishPlatformCredentialLib** - the EDK2 Emulator platform implementation of acquiring credential to bui= ld up the communication between UEFI firmware and Redfish service. ***[[10]= ](#[0])*** - - * **RedfishPlatformHostInterfaceLib** - EDK2 Emulator platform implementation which provides the information of = building up SMBIOS type 42h record. ***[[11]](#[0])*** +## Platform Components +### **EDK2 EmulatorPkg** +![EDK2 EmulatorPkg Figure](https://github.com/changab/edk2-staging/blob/Re= dfishReadme/RedfishPkg/Documents/Media/Emualtor%20Platform%20Library.svg?ra= w=3Dtrue) + + * **RedfishPlatformCredentialLib**
+ The EDK2 Emulator platform implementation of acquiring credential to b= uild up the communication between + UEFI firmware and Redfish service. ***[[10]](#[0])*** + + The Redfish credential is hardcoded in the EmulatorPkg RedfishPlatform= CredentialLib. The credential is + used to access to the Redfish service hosted by [Redfish Profile Simul= ator](https://github.com/DMTF/Redfish-Profile-Simulator). + + * **RedfishPlatformHostInterfaceLib**
+ EDK2 Emulator platform implementation which provides the information o= f building up SMBIOS type 42h + record. ***[[11]](#[0])*** + + EmulatorPkg RedfishPlatformHostInterfaceLib library consumes the EFI V= ariable which is created + by [RedfishPlatformConfig EFI application](https://github.com/tianocor= e/edk2/tree/master/EmulatorPkg/Application/RedfishPlatformConfig). RedfishP= latformConfig EFI application stores not all of SMBIOS + Type42 record information but the necessary network properties of Redf= ish Host Interface in EFI + Variable. + +### **Platform with BMC and the BMC-Exposed USB Network Device** +![Platform with BMC Figure](https://github.com/changab/edk2-staging/blob/R= edfishReadme/RedfishPkg/Documents/Media/USB%20Exposed%20USB%20NIC.svg?raw= =3Dtrue) + +Server platform with BMC as the server management entity may expose the [U= SB Network Interface Device (NIC)](https://www.usb.org/document-library/cla= ss-definitions-communication-devices-12) +to the platform, which is so called the in-band host-BMC transport interfa= ce. The USB NIC exposed by BMC is +usually a link-local network device which has two network endpoints at hos= t and BMC ends. The endpoint at +host side is connected to the platform USB port, and it is enumerated by e= dk2 USB BUS driver. The edk2 USB +NIC driver then produces the **EFI Network Interface Identifier Protocol** +*(EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31)* and connected by EFI= Simple +Network Protocol (SNP) driver and the upper layer edk2 network drivers. Th= e applications can then utilize +the network stack built up on top of USB NIC to communicate with Redfish s= ervice hosted by BMC.
+BMC-exposed USB NIC is mainly designed for the communication between host = and BMC-hosted Redfish service. +BMC-exposed USB NIC can be public to host through [Redfish Host Interface = Specification](https://www.dmtf.org/sites/default/files/standards/documents= /DSP0270_1.3.0.pdf) and discovered by edk2 Redfish discovery +driver. The [Redfish Host Interface Specification](https://www.dmtf.org/si= tes/default/files/standards/documents/DSP0270_1.3.0.pdf) describes the dedi= cated host interface between host and +BMC. The specification follows the [SMBIOS Type 42 format](https://www.dmt= f.org/sites/default/files/standards/documents/DSP0134_3.6.0.pdf) and define= s the host interface as: +- Network Host Interface type (40h) +- Redfish over IP Protocol (04h) + +
+ +![Platform BMC Library Figure](https://github.com/changab/edk2-staging/blo= b/RedfishReadme/RedfishPkg/Documents/Media/Platform%20wiht%20BMC%20Library.= svg?raw=3Dtrue) + + * **RedfishPlatformCredentialLib**
+RedfishPlatformCredentialLib library instance on the platform with BMC use= s Redfish Credential +Bootstrapping IPMI commands defined in [Redfish Host Interface Specificati= on](https://www.dmtf.org/sites/default/files/standards/documents/DSP0270_1.= 3.0.pdf) to acquire the Redfish credential from BMC. edk2 +Redfish firmware then uses this credential to access to Redfish service ho= sted by BMC. + + * **RedfishPlatformHostInterfaceLib**
+BMC-exposed USB NIC, a IPMI Message channel is reported by BMC as a "IPMB-= 1.0" protocol and "802.3 LAN" +medium channel. edk2 firmware can issue a series of IPMI commands to acqui= re the channel +application information (NetFn App), transport network properties (NetFn T= ransport) and other necessary +information to build up the SMBIOS type 42h record. +In order to recognize the specific BMC-exposed USB NIC in case the platfor= m has more than one USB NIC +devices attached, the MAC address specified in the EFI Device Path Protoco= l of SNP EFI handle is used to +match with the MAC address of IPMI message channel. Due to the network inf= ormation such as the MAC +address, IP address, Subnet mask and Gateway are assigned by BMC, edk2 Red= fish implementation needs a +programmatic way to recognize the BMC-exposed USB NIC. + + * **MAC address:** Searching for the BMC-exposed USB NIC
+ The last byte of host-end USB NIC MAC address is the last byte of BMC-= end USB NIC MAC address minus 1. + RedfishPlatformHostInterfaceLib issues the NetFn Transport IPMI comman= d to get the MAC address of each + channel and checks them with the MAC address specified in the EFI Devi= ce Path Protocol.
+ + **_For example:_**
+ BMC-end USB NIC MAC address: 11-22-33-44-55-00
+ Host-end USB NIC MAC address: 11-22-33-44-55-ff + + * **IP Address:** Acquiring the host-end USB NIC IP Address
+ The last byte of host-end USB NIC IPv4 address is the last byte of BMC= -end USB NIC IPv4 address minus 1. + + **_For example:_**
+ BMC-end USB NIC IPv4 address: 165.10.0.0
+ Host-end USB NIC IPv5 address: 165.10.0.255 + + * **Other Network Properties**:
+ Due to the host-end USB NIC and BMC-end USB NIC is a link-local networ= k. Both of them have the same + network properties such as subnet mask and gateway. RedfishPlatformHos= tInterfaceLib issues the NetFn + Transport IPMI command to get the network properties of BMC-end USB NI= C and apply it on host-end USB + NIC. + + **__NOTE__**=20 +``` +Current RedfishPlatformHostInterfaceLib implementation of BMC-exposed USB = NIC can only support IPv4 address format. +``` =20 ## Miscellaneous: =20 @@ -65,7 +143,6 @@ The library is incorporated with RedfishLib ***[[13]](#[= 0])*** to encode and dec For example, run shell command "RedfishPlatformConfig.efi -s 192.168.1= 0.101 255.255.255.0 192.168.10.123 255.255.255.0", which means the source IP address is 192.168.10.101, and the Redfish Server IP a= ddress is 192.168.10.123. ``` - * **Redfish Profile Simulator** Refer to [Redfish Profile Simulator](https://github.com/DMTF/Redfish-Pr= ofile-Simulator) to set up the Redfish service. We are also in the progress to contribute bug fixes and enhancements to= the mainstream Redfish Profile Simulator in order to incorporate with EDK2= Redfish solution. @@ -121,7 +198,9 @@ The library is incorporated with RedfishLib ***[[13]](#= [0])*** to encode and dec 1. [DSP0270](https://www.dmtf.org/sites/default/files/standards/documents/= DSP0270_1.3.0.pdf) - Redfish Host Interface Specification, 1.3.0 2. [DSP0266](https://www.dmtf.org/sites/default/files/standards/documents/= DSP0266_1.12.0.pdf) - Redfish Specification, 1.12.0 3. Redfish Schemas - https://redfish.dmtf.org/schemas/v1/ -4. UEFI Specification - http://uefi.org/specifications +4. SMBIOS - https://www.dmtf.org/sites/default/files/standards/documents/D= SP0134_3.6.0.pdf +5. USB CDC - https://www.usb.org/document-library/class-definitions-commun= ication-devices-12 +6. UEFI Specification - http://uefi.org/specifications =20 ## The Contributors Thanks to the below predecessors who contributed to the UEFI EDK2 Redfish = Prove of Concept code.\ diff --git a/RedfishPkg/Documents/Media/Emualtor Platform Library.svg b/Red= fishPkg/Documents/Media/Emualtor Platform Library.svg new file mode 100644 index 00000000000..584e8e0f9b7 --- /dev/null +++ b/RedfishPkg/Documents/Media/Emualtor Platform Library.svg=09 @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Redfish Service= + + + + + + + + + + + + On Network + + + + + + + + EDKII Redfish Creden= tial(DXE Driver) + + + + + + + + EDKII Redfish Host = Interf= ace(DXE Driver) + + + + + + + + Platform Redfish Credenti= al Library + + + + + + + + Platform Redfish Ho= st Int= erface Library + + + + + + EmulatorPkg Library Instan= ce + + + + + + EmulatorPkg Library Insta= nce + + + + + + + + + + + + + + + + + + + + + EFI Variable<= /text> + + + + + + + + + + + + + + + RedfishPlatformConfg.efi= + + + + + + + + + + + + + Information of <= /tspan>SMBIOS 42 Record + + + + + + Hardcoded Redfish Credential<= /tspan> + + + + + + Redfish Profile = Simulator + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RedfishPkg/Documents/Media/Platform wiht BMC Library.svg b/Red= fishPkg/Documents/Media/Platform wiht BMC Library.svg new file mode 100644 index 00000000000..c6d0c250dee --- /dev/null +++ b/RedfishPkg/Documents/Media/Platform wiht BMC Library.svg=09 @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Redfish Service= + + + + + + + + + + + + On Network + + + + + + + + EDKII Redfish Creden= tial(DXE Driver) + + + + + + + + EDKII Redfish Host = Interf= ace(DXE Driver) + + + + + + + + Platform Redfish Credenti= al Library + + + + + + + + Platform Redfish Ho= st Int= erface Library + + + + + + Platform with BMC Library = Instance + + + + + + + + + + + + + + + + + + + + Send IPMI NetFn App and I= PMI NetFn Transprort commands to acquire the network Information to build up SMBIOS 42 Record + + + + + + Platform with BMC Library= Instance + + + + + + + + + + + + BMC + + + + + + + + IpmiCommandLibrary= + + + + + + + + IpmiTransportProto= col + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BMC ExposedUSB Network Interface Device + + + + + + + + + + + + + Get Redfish Credential us= ing IPMI Group Extension (Body code 52h for Redfish) + + + + + + + + \ No newline at end of file diff --git a/RedfishPkg/Documents/Media/USB Exposed USB NIC.svg b/RedfishPk= g/Documents/Media/USB Exposed USB NIC.svg new file mode 100644 index 00000000000..f4d36e86991 --- /dev/null +++ b/RedfishPkg/Documents/Media/USB Exposed USB NIC.svg=09 @@ -0,0 +1,283 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EDKII Network Stack= s(UEFI Driver Model) + + + + + + + + EFI REST EX= (UEFI Driver Model) + + + + + + + + BMC ExposedUSB Network Interface Device + + + + + + + + + + Redfish Service= + + + + + + + + + + + + + + + + + + + + EDKII Redfish Host = Interf= ace(DXE Driver) + + + + + + BMC + + + + + + On Network<= /text> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + EDKII Redfish Crede= ntial(DXE Driver) + + + + + + + + + + + + + + + + + + + + + + EDKII USB Stacks(UEFI Driver Model) + + + + + + + + + + + + + + + + + + + + + + EFI Redfish Discove= ry(UEFI Driver Model) + + + + + + + + \ No newline at end of file --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#98192): https://edk2.groups.io/g/devel/message/98192 Mute This Topic: https://groups.io/mt/96152753/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-