From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.88]) by mx.groups.io with SMTP id smtpd.web11.8268.1678285041503014594 for ; Wed, 08 Mar 2023 06:17:21 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=1QRbvRCT; 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.243.88, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HZBC85Iyfx5nVq0AL8rsAoFhZbUWp0IOk2AW7WdCxOqHhMr99p/jIL4PiS/DcE0XhML5tuRJ03WWDPsw/vbuG3OvLpevKo55Z+uCM+Z13Y2wpK2uVre9/c9pSAnUn53/B4vTKQ9Gdsx8SbGzqHJSCoo7ME1k2htltqNzXxzUHDC8VGefC+AsNJE1G7XdT8IeO/SUj6WrBUIDTDWWcTK73FkKyyERfQ9mUw51M0TaMKTpkEoffW0dT3C9Lk7f7UI45tjk8OQbOMnI1SoAvuT68yXMt2cENTWFb3b5SYsNCx0hduypcWlK9M2reptelnxHcP6W6bUord76+E3IEuZDiQ== 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=ykOgzJw6T8/cNQPR+EeX7wDRoau20FMko6rICFltBBY=; b=X7caVWb2tQNyYxVGZLzDSL4bI8OE2Ni5zhpLu8zSNem8gWG1ZLrshOju6PpM0HXgkgjDkDnbLMhJ9/KNZIfqDar1fXWtNDZeDcIvk8hb8loNwVN8V0EILr/1QnDqSL3RmMaskaEntinx0lJZAcpl6r3yhe5Nlfr/RdxvJbtGO87sx9Euh9ttX5DQ5qx/g40HGXToMZJZzKFBb2DrM/DrK5SDXsxYXlsLfa6nGS1+qo/LVFVHdp6Q0JLBYb6rOD7LfykOb9E9Na2qm6rG0KkS1d4Y++vf7pSjPwyBSJcx/oDDJKORNro7Yd6noeygiiySxK+P6kw/CS63VG6KvU+LAw== 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=ykOgzJw6T8/cNQPR+EeX7wDRoau20FMko6rICFltBBY=; b=1QRbvRCT1IBywZp4ZXDYLTGULhY4TZHDAl6gbttz2LCFYJBkevzOsDTjcYlLnIRmoOYKaV+hNMfehByEvX8iWNVXxpJcj/lP2oumWpBMBSUa2wPrqwOw39oiXDn/5VL1fYR8F0YMNaipPi+bP4yXhmPdemt0Ndo48V6PsLj/Atg= Received: from CYZPR20CA0006.namprd20.prod.outlook.com (2603:10b6:930:a2::28) by PH7PR12MB7283.namprd12.prod.outlook.com (2603:10b6:510:20a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17; Wed, 8 Mar 2023 14:17:18 +0000 Received: from CY4PEPF0000C985.namprd02.prod.outlook.com (2603:10b6:930:a2:cafe::1b) by CYZPR20CA0006.outlook.office365.com (2603:10b6:930:a2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.17 via Frontend Transport; Wed, 8 Mar 2023 14:17:18 +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 CY4PEPF0000C985.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.13 via Frontend Transport; Wed, 8 Mar 2023 14:17:18 +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; Wed, 8 Mar 2023 08:17:15 -0600 From: "Chang, Abner" To: CC: Liming Gao , Isaac Oram , Nate DeSimone , Nickle Wang , Igor Kulchytskyy , "Abdul Lateef Attar" Subject: [edk2-platforms][PATCH V2 4/8] ManageabilityPkg: Add ManageabilityTransportHelperLib Date: Wed, 8 Mar 2023 22:16:43 +0800 Message-ID: <20230308141647.1318-5-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20230308141647.1318-1-abner.chang@amd.com> References: <20230308141647.1318-1-abner.chang@amd.com> MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000C985:EE_|PH7PR12MB7283:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d7cf2e7-7a83-4571-b020-08db1fdfd339 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LJo8CJ+aNxCTK8nB3xSAfNpEVOCDIZPraWdDCnDFqXYeWsURJTJCaXSjP187vFcChCoZ6jv4IeD65EfNTitHVX+Ab2oiwKBqL+YA3yb+wFfrh+YX80OsUQOxAG/4yDlu/3Uxa4o2yoBIDOOocEw98FXj7x0kuggEl+Gu5DlZcVDUaHlax4/hjX2EBWVKREzTyUcgt+dvJvGjU6dP6nA/Bt35mt+26Otsfbt+aWlpa382qAJtfBH9ZtLIhVtP6cQ9jde2Mcu/XGIGlUKClH6pfDZHzp7e99Ojl3362VwdFtm+W/skPp9sUKjhBCrWlidcPedoZBDiSvTp1yku/aPYps2r1mSOM9lItAxkSV6yRZCI3lp5tKk3QukquA9H+25aeBc0NBAgktulQOcNi4nIXgGPJOGO58b/oKdQDGjdGt/dxg6qIwE6AgY51XtaBqJ8zzW8sJlyi6QFAK0YtCNwIqT4T9RiGSJSusQG6C+ufWxW6BrYmf2EwLtye8rFt4M5gveXRxOOpfMOGJsyo6FFuO5SJdh0pszNFI90baB5E0HxslnU61DuEMn8Q1rwocdH0yaKspb65e2lfr6RbozVE0bdZAM9DjHOm2oneKqY2Ok+M2MT8OGFmUf6g9ycjTzVGU/W80y43wONd8dAk8B2MlMVpzyaxSsZfuUTi7HPfARQO8xzHI3brkrfy+cr2t71q4kTwh/u3JzDBIToTzprKJR+WndZvKDwT6a5/S+9ub5X6SYJ4FZ5hd6/V26pkcI28to5410ymK3uEQThyNWl4Q== 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:(13230025)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199018)(40470700004)(36840700001)(46966006)(316002)(86362001)(336012)(82740400003)(19627235002)(426003)(4326008)(47076005)(54906003)(8676002)(6916009)(70206006)(81166007)(70586007)(8936002)(36756003)(30864003)(2616005)(82310400005)(478600001)(5660300002)(41300700001)(36860700001)(356005)(83380400001)(6666004)(186003)(16526019)(2906002)(2876002)(7696005)(40460700003)(26005)(1076003)(40480700001)(36900700001)(44824005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2023 14:17:18.3904 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d7cf2e7-7a83-4571-b020-08db1fdfd339 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: CY4PEPF0000C985.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7283 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang The helper functions library facilitates reducing duplicated code in the manageability transport library instances. Signed-off-by: Abner Chang Cc: Liming Gao Cc: Isaac Oram Cc: Nate DeSimone Cc: Nickle Wang Cc: Igor Kulchytskyy Cc: Abdul Lateef Attar --- .../ManageabilityPkg/ManageabilityPkg.dec | 23 +- .../Include/Dsc/Manageability.dsc | 2 + .../BaseManageabilityTransportHelper.inf | 40 +++ .../Library/ManageabilityTransportHelperLib.h | 93 +++++++ .../BaseManageabilityTransportHelper.c | 242 ++++++++++++++++++ .../BaseManageabilityTransportHelper.uni | 13 + 6 files changed, 412 insertions(+), 1 deletion(-) create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTran= sportHelperLib/BaseManageabilityTransportHelper.inf create mode 100644 Features/ManageabilityPkg/Include/Library/Manageability= TransportHelperLib.h create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTran= sportHelperLib/BaseManageabilityTransportHelper.c create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTran= sportHelperLib/BaseManageabilityTransportHelper.uni diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/Mana= geabilityPkg/ManageabilityPkg.dec index ebf6e6315e..ebbb04dc0e 100644 --- a/Features/ManageabilityPkg/ManageabilityPkg.dec +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec @@ -22,6 +22,27 @@ # Manageability Transport Library definitions ManageabilityTransportLib|Include/Library/ManageabilityTransportLib.h =20 + ## @libraryclass Manageability Transport Helper Library + # Provide the help functions to use ManageabilityTransportLib + ManageabilityTransportHelperLib|Include/Library/ManageabilityTransportHe= lperLib.h + [Guids] - gManageabilityPkgTokenSpaceGuid =3D { 0xBDEFFF48, 0x1C31, 0x49CD, { 0xA7= , 0x6D, 0x92, 0x9E, 0x60, 0xDB, 0xB9, 0xF8 } } + gManageabilityPkgTokenSpaceGuid =3D { 0xBDEFFF48, 0x1C31, 0x49CD, { 0x= A7, 0x6D, 0x92, 0x9E, 0x60, 0xDB, 0xB9, 0xF8 } } + + # Manageability Transport Interface type + # + # Manageability Transport KCS + gManageabilityTransportKcsGuid =3D { 0x5A6E64E9, 0xFD47, 0x4086, { 0x= AA, 0xB0, 0x7A, 0x5F, 0xD7, 0x6B, 0x02, 0x2E } } + # Manageability Transport I2C + gManageabilityTransportI2CGuid =3D { 0x5B174658, 0x8263, 0x4CB8, { 0x= A0, 0x0F, 0xD6, 0x82, 0xE6, 0xBC, 0x74, 0x93 } } + # Manageability Transport PCI VDM + gManageabilityTransportPciVdmGuid =3D { 0x388021A7, 0xFB59, 0x4811, { 0x= 9D, 0xA7, 0xD5, 0x63, 0x7D, 0x04, 0xA7, 0x2F } } =20 + # Manageability Protocol Specification + # + # Manageability Protocol IPMI + gManageabilityProtocolIpmiGuid =3D { 0x36ACA47C, 0xCC80, 0x473B, { 0x= AB, 0xEC, 0xF3, 0x98, 0xFF, 0x87, 0x74, 0x5B } } + # Manageability Protocol MCTP + gManageabilityProtocolMctpGuid =3D { 0x76FED8F1, 0x0BE5, 0x4269, { 0x= A3, 0x1A, 0x38, 0x0F, 0x54, 0xF1, 0xA1, 0x8A } } + # Manageability Protocol PLDM + gManageabilityProtocolPldmGuid =3D { 0x3958090D, 0x69DD, 0x4868, { 0x= 9C, 0x41, 0xC9, 0xAC, 0x31, 0xB5, 0x25, 0xC5 } } diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc b/Feat= ures/ManageabilityPkg/Include/Dsc/Manageability.dsc index 2cb63c1ca6..994c93f17c 100644 --- a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc +++ b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc @@ -5,6 +5,8 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent # ## +[LibraryClasses] + ManageabilityTransportHelperLib|ManageabilityPkg/Library/BaseManageabili= tyTransportHelperLib/BaseManageabilityTransportHelper.inf =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] # diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Li= brary/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.= inf new file mode 100644 index 0000000000..39abcbcb53 --- /dev/null +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.inf @@ -0,0 +1,40 @@ +## @file +# Null instance of Manageability Transport Helper Library +# +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D BaseManageabilityTransportHelper + MODULE_UNI_FILE =3D BaseManageabilityTransportHelper.uni + FILE_GUID =3D 52F2DE11-A8FC-4A06-B8C6-10DCF4A7397C + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D ManageabilityTransportHelperLib + +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + BaseManageabilityTransportHelper.c + +[LibraryClasses] + BaseMemoryLib + DebugLib + +[Packages] + ManageabilityPkg/ManageabilityPkg.dec + MdePkg/MdePkg.dec + +[Guids] + gManageabilityTransportKcsGuid + gManageabilityTransportI2CGuid + gManageabilityTransportPciVdmGuid + gManageabilityProtocolIpmiGuid + gManageabilityProtocolMctpGuid + gManageabilityProtocolPldmGuid + diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtHelperLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTran= sportHelperLib.h new file mode 100644 index 0000000000..718ac34a1f --- /dev/null +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelpe= rLib.h @@ -0,0 +1,93 @@ +/** @file + + This file defines the manageability transport interface library and func= tions. + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MANAGEABILITY_TRANSPORT_HELPER_LIB_H_ +#define MANAGEABILITY_TRANSPORT_HELPER_LIB_H_ + +#include + +typedef struct _MANAGEABILITY_PROTOCOL_NAME MANAGEABILITY_PROTOCOL_NAME; + +/** + Helper function returns the human readable name of Manageability specifi= cation. + + @param[out] SpecificationGuid The Manageability specification G= UID + + @retval !NULL Human readable name is returned; + @retval NULL No string found, the given Manageability specificati= on is + not supported. +**/ +CHAR16 * +HelperManageabilitySpecName ( + IN EFI_GUID *SpecificationGuid + ); + +/** + Helper function to check if the Manageability specification is supported + by transport interface or not. + + @param[in] TransportGuid GUID of the transport = interface. + @param[in] SupportedManageabilityProtocolArray The Manageability prot= ocols supported + by the transport inter= face. + @param[in] NumberOfSupportedProtocolInArray Number of protocols in= the array. + @param[in] ManageabilityProtocolToCheck The Manageability spec= ification to check. + + @retval EFI_SUCCESS Token is created successfully. + @retval EFI_INVALID_PARAMETER Either NumberOfSupportedProtocolInAr= ray =3D 0 or + SupportedManageabilityProtocolArray = =3D NULL. + @retval EFI_UNSUPPORTED Out of resource to create a new tran= sport session. + Otherwise Other errors. +**/ +EFI_STATUS +HelperManageabilityCheckSupportedSpec ( + IN EFI_GUID *TransportGuid, + IN EFI_GUID **SupportedManageabilityProtocolArray, + IN UINT8 NumberOfSupportedProtocolInArray, + IN EFI_GUID *ManageabilityProtocolToCheck + ); + +/** + Helper function to acquire the Manageability transport token. + + @param[in] ManageabilityProtocolSpec The Manageability protocol speci= fication. + @param[out] TransportToken Pointer to receive Manageability= transport + token. + + @retval EFI_SUCCESS Token is created successfully. + @retval EFI_OUT_OF_RESOURCES Out of resource to create a new tran= sport session. + @retval EFI_UNSUPPORTED Token is created successfully. + @retval EFI_DEVICE_ERROR The transport interface has problems + @retval EFI_INVALID_PARAMETER INput parameter is not valid. + Otherwise Other errors. +**/ +EFI_STATUS +HelperAcquireManageabilityTransport ( + IN EFI_GUID *ManageabilityProtocolSpec, + OUT MANAGEABILITY_TRANSPORT_TOKEN **TransportToken + ); + +/** + Helper function to initial the transport interface. + + @param[in] TransportToken Transport token. + @param[in] HardwareInfo Optional hardware information of= transport interface. + @param[out] TransportAdditionalStatus Transport additional status. + + @retval EFI_SUCCESS Transport interface is initiated suc= cessfully. + @retval EFI_DEVICE_ERROR The transport interface has problems + @retval EFI_INVALID_PARAMETER INput parameter is not valid. + Otherwise Other errors. +**/ +EFI_STATUS +HelperInitManageabilityTransport ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + IN MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION HardwareInfo OPTIONAL, + OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *TransportAdditionalSt= atus OPTIONAL + ); + +#endif diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportHelper.c b/Features/ManageabilityPkg/Libr= ary/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.c new file mode 100644 index 0000000000..9b00f001e0 --- /dev/null +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.c @@ -0,0 +1,242 @@ +/** @file + Null instance of Manageability Transport Helper Library + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include + +MANAGEABILITY_SPECIFICATION_NAME ManageabilitySpecNameTable[] =3D { + { &gManageabilityTransportKcsGuid, L"KCS" }, + { &gManageabilityTransportI2CGuid, L"I2C" }, + { &gManageabilityTransportPciVdmGuid, L"PCI VDM" }, + { &gManageabilityProtocolIpmiGuid, L"IPMI" }, + { &gManageabilityProtocolMctpGuid, L"MCTP" }, + { &gManageabilityProtocolPldmGuid, L"PLDM" } +}; + +UINT16 ManageabilitySpecNum =3D sizeof (ManageabilitySpecNameTable)/ size= of (MANAGEABILITY_SPECIFICATION_NAME); + +/** + Helper function returns the human readable name of Manageability specifi= cation. + + @param[in] SpecificationGuid The Manageability specification GU= ID + + @retval !NULL Human readable name is returned; + @retval NULL No string found, the given Manageability specificati= on is + not supported. +**/ +CHAR16 * +HelperManageabilitySpecName ( + IN EFI_GUID *SpecificationGuid + ) +{ + UINT16 Index; + MANAGEABILITY_SPECIFICATION_NAME *ThisSpec; + + if (ManageabilitySpecNum =3D=3D 0) { + return NULL; + } + + ThisSpec =3D ManageabilitySpecNameTable; + for (Index =3D 0; Index < ManageabilitySpecNum; Index++) { + if (CompareGuid ( + SpecificationGuid, + ThisSpec->SpecificationGuid + )) + { + return ThisSpec->SpecificationName; + } + + ThisSpec++; + } + + return NULL; +} + +/** + Helper function to check if the Manageability specification is supported + by transport interface or not. + + @param[in] TransportGuid GUID of the transport = interface. + @param[in] SupportedManageabilityProtocolArray The Manageability prot= ocols supported + by the transport inter= face. + @param[in] NumberOfSupportedProtocolInArray Number of protocols in= the array. + @param[in] ManageabilityProtocolToCheck The Manageability spec= ification to check. + + @retval EFI_SUCCESS Token is created successfully. + @retval EFI_INVALID_PARAMETER Either NumberOfSupportedProtocolInAr= ray =3D 0 or + SupportedManageabilityProtocolArray = =3D NULL. + @retval EFI_UNSUPPORTED Out of resource to create a new tran= sport session. + Otherwise Other errors. +**/ +EFI_STATUS +HelperManageabilityCheckSupportedSpec ( + IN EFI_GUID *TransportGuid, + IN EFI_GUID **SupportedManageabilityProtocolArray, + IN UINT8 NumberOfSupportedProtocolInArray, + IN EFI_GUID *ManageabilityProtocolToCheck + ) +{ + UINT16 Index; + EFI_GUID *ThisSpecGuid; + + if ((NumberOfSupportedProtocolInArray =3D=3D 0) || (SupportedManageabili= tyProtocolArray =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + ThisSpecGuid =3D *SupportedManageabilityProtocolArray; + for (Index =3D 0; Index < NumberOfSupportedProtocolInArray; Index++) { + if (CompareGuid ( + ThisSpecGuid, + ManageabilityProtocolToCheck + )) + { + DEBUG (( + DEBUG_VERBOSE, + "%a: Transport interface %s supports %s manageability specificatio= n.\n", + __FUNCTION__, + HelperManageabilitySpecName (TransportGuid), + HelperManageabilitySpecName (ManageabilityProtocolToCheck) + )); + return EFI_SUCCESS; + } + + ThisSpecGuid++; + } + + DEBUG (( + DEBUG_ERROR, + "%a: Transport interface %s doesn't support %s manageability specifica= tion.\n", + __FUNCTION__, + HelperManageabilitySpecName (TransportGuid), + HelperManageabilitySpecName (ManageabilityProtocolToCheck) + )); + return EFI_UNSUPPORTED; +} + +/** + Helper function to acquire the Manageability transport token. + + @param[in] ManageabilityProtocolSpec The Manageability protocol speci= fication. + @param[out] TransportToken Pointer to receive Manageability= transport + token. + + @retval EFI_SUCCESS Token is created successfully. + @retval EFI_OUT_OF_RESOURCES Out of resource to create a new tran= sport session. + @retval EFI_UNSUPPORTED Token is created successfully. + @retval EFI_INVALID_PARAMETER Input parameter is not valid. + Otherwise Other errors. +**/ +EFI_STATUS +HelperAcquireManageabilityTransport ( + IN EFI_GUID *ManageabilityProtocolSpec, + OUT MANAGEABILITY_TRANSPORT_TOKEN **TransportToken + ) +{ + EFI_STATUS Status; + CHAR16 *ManageabilityProtocolName; + CHAR16 *ManageabilityTransportName; + + DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__)); + if ((TransportToken =3D=3D NULL) || (ManageabilityProtocolSpec =3D=3D NU= LL)) { + DEBUG ((DEBUG_ERROR, "%a: One of the required input parameters is NULL= .\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + *TransportToken =3D NULL; + ManageabilityProtocolName =3D HelperManageabilitySpecName (Manageability= ProtocolSpec); + if (ManageabilityProtocolName =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Unsupported Manageability Protocol Specifica= tion\n", __FUNCTION__)); + return EFI_UNSUPPORTED; + } + + DEBUG ((DEBUG_INFO, " Manageability protocol %s is going to acquire tra= nsport interface token...\n", ManageabilityProtocolName)); + + Status =3D AcquireTransportSession (ManageabilityProtocolSpec, Transport= Token); + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_ERROR, "%a: No supported transport interface for %s pack= et.\n", __FUNCTION__, ManageabilityProtocolName)); + return Status; + } + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Fail to acquire Manageability transport token for %s (%r).\n", + __FUNCTION__, + ManageabilityProtocolName, + Status + )); + return Status; + } + + ManageabilityTransportName =3D HelperManageabilitySpecName ((*TransportT= oken)->Transport->ManageabilityTransportSpecification); + if (ManageabilityTransportName =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Unsupported Manageability Transport Interfac= e Specification\n", __FUNCTION__)); + return EFI_UNSUPPORTED; + } + + DEBUG ((DEBUG_INFO, "%a: This is the transfer session for %s over %s\n",= __FUNCTION__, ManageabilityProtocolName, ManageabilityTransportName)); + return Status; +} + +/** + Helper function to initial the transport interface. + + @param[in] TransportToken Transport token. + @param[in] HardwareInfo Optional hardware information of= transport interface. + @param[out] TransportAdditionalStatus Transport additional status. + + @retval EFI_SUCCESS Transport interface is initiated suc= cessfully. + @retval EFI_DEVICE_ERROR The transport interface has problems + @retval EFI_INVALID_PARAMETER INput parameter is not valid. + Otherwise Other errors. +**/ +EFI_STATUS +HelperInitManageabilityTransport ( + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, + IN MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION HardwareInfo OPTIONAL, + OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *TransportAdditionalSt= atus OPTIONAL + ) +{ + EFI_STATUS Status; + + if (TransportToken =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: TransportToken is invalid.\n", __FUNCTION__)= ); + return EFI_INVALID_PARAMETER; + } + + // Initial transport interface. + Status =3D TransportToken->Transport->Function.Version1_0->TransportInit= (TransportToken, HardwareInfo); + if ((Status !=3D EFI_SUCCESS) && (Status !=3D EFI_ALREADY_STARTED)) { + if (Status =3D=3D EFI_DEVICE_ERROR) { + // Try to reset the transport and initialize it again. + Status =3D TransportToken->Transport->Function.Version1_0->Transport= Reset ( + Transport= Token, + Transport= AdditionalStatus + ); + if (EFI_ERROR (Status)) { + if (Status =3D=3D EFI_UNSUPPORTED) { + DEBUG ((DEBUG_ERROR, "%a: Transport interface doesn't have reset= capability.\n", __FUNCTION__)); + } else { + DEBUG ((DEBUG_ERROR, "%a: Fail to reset transport interface (%r)= .\n", __FUNCTION__, Status)); + } + + Status =3D EFI_DEVICE_ERROR; + } else { + Status =3D TransportToken->Transport->Function.Version1_0->Transpo= rtInit (TransportToken, HardwareInfo); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Transport interface is not able to use= after the reset (%r).\n", __FUNCTION__, Status)); + } + } + } else { + DEBUG ((DEBUG_ERROR, "%a: Transport interface is not able to use (%r= ).\n", __FUNCTION__, Status)); + } + } + + return Status; +} diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHe= lperLib/BaseManageabilityTransportHelper.uni b/Features/ManageabilityPkg/Li= brary/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.= uni new file mode 100644 index 0000000000..dfb6051aeb --- /dev/null +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib= /BaseManageabilityTransportHelper.uni @@ -0,0 +1,13 @@ +// /** @file +// Null instance of Manageability Transport Helper Library +// +// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Manageability Tra= nsport Helper Library" + +#string STR_MODULE_DESCRIPTION #language en-US "Manageability Tra= nsport Helper Functions." + --=20 2.37.1.windows.1