From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.129]) by mx.groups.io with SMTP id smtpd.web10.81747.1679596248292544529 for ; Thu, 23 Mar 2023 11:30:48 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="no key for verify" header.i=@amperemail.onmicrosoft.com header.s=selector1-amperemail-onmicrosoft-com header.b=kT1j3rz+; spf=pass (domain: os.amperecomputing.com, ip: 40.107.93.129, mailfrom: tinhnguyen@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VqsatfsvicE8YVDnrRDOlWJjwpJs9cz/EnqzUXf1RBBfwuGyO1+LO8BamOn91+mutGBVVX3Yyh50WqVsvL2LeX+UXVlWCxd5yF1A5PNOIHuInIOmerfrRSGF5MBmm1FdxP9l5X3NP5Ku4jrUTnLlF+49r65rDr3sOjfIRh+uCmMipDqN4go0F//teEznkx0Dl8Rb4zTbReAZZGkjccj877yqyjNOmEDDZxkpb2vgEIDoqonk8usuBxcerpJVzdyRuDUlmOycvEPlCHWKbVJXwM3LyjGdGxPk79VdJUsSzMoSc6OmJ02ZxRGiwphseziI96TN8R6FGDHko6lZumSpBw== 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=y3AQMZZtwbY5TmB8Y9dp6WkkZGuMbSpvnYevVrgryN0=; b=FetvtlTQ2GH66T0IL+OuCPEGK1UJtD5qNOYUA5+OVbWXyTowrBdzmUfBHFVv6CylZNf/I6rb6uY287HOUV3Zq6Oabyvr2Fmz9vhytXs54+8u/koQztUpNU41T03KQLiL901sW/QCUbg9gvtiwwFY0Hj6d7KeVbij0eIPNkCEflmgLAxrkd8yjaMZ/B/0W2L8LLTKgK/OE3ubI6GuOx6Bx7pkROASRNg8FSvWmc3fYXxmQpKYEUrMmQv57ZQPWfUneolGCMSkeBeSsJPfmyf8cmnOBDwK7qg42UaWZAMca89B8I9NZZo5GLmUpEaNZNft+Cx/59x/Ky/sVfYmzyoELA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=amperemail.onmicrosoft.com; dkim=pass header.d=amperemail.onmicrosoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amperemail.onmicrosoft.com; s=selector1-amperemail-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y3AQMZZtwbY5TmB8Y9dp6WkkZGuMbSpvnYevVrgryN0=; b=kT1j3rz++S2o3HtmX0wERADliXygsIUnHLditDR0hmxdmKvm7rfob5h0m5udd4JPklEkTwlOpqWDKjnqhf85Czs3A/DQWIxOg5/FxTaM6hhRkKG0eb9U9wbJa+PHnLRUGioA5a9vjYKZUqML5mCEE1OI4NreAQWco+6TxzrSrg0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amperemail.onmicrosoft.com; Received: from MWHPR0101MB2942.prod.exchangelabs.com (2603:10b6:301:2e::14) by BN7PR01MB3987.prod.exchangelabs.com (2603:10b6:406:8e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Thu, 23 Mar 2023 18:30:44 +0000 Received: from MWHPR0101MB2942.prod.exchangelabs.com ([fe80::1d06:a51a:ca3d:c2f6]) by MWHPR0101MB2942.prod.exchangelabs.com ([fe80::1d06:a51a:ca3d:c2f6%4]) with mapi id 15.20.6178.024; Thu, 23 Mar 2023 18:30:44 +0000 Message-ID: Date: Fri, 24 Mar 2023 01:30:37 +0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [edk2-devel] [PATCH v4 5/9] ManageabilityPkg: Add ManageabilityTransportHelperLib To: devel@edk2.groups.io, abner.chang@amd.com Cc: Liming Gao , Isaac Oram , Nate DeSimone , Nickle Wang , Igor Kulchytskyy , Abdul Lateef Attar References: <20230322024840.1629-1-abner.chang@amd.com> <20230322024840.1629-5-abner.chang@amd.com> From: "Tinh Nguyen" In-Reply-To: <20230322024840.1629-5-abner.chang@amd.com> X-ClientProxiedBy: SG2PR04CA0212.apcprd04.prod.outlook.com (2603:1096:4:187::8) To MWHPR0101MB2942.prod.exchangelabs.com (2603:10b6:301:2e::14) Return-Path: tinhnguyen@os.amperecomputing.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR0101MB2942:EE_|BN7PR01MB3987:EE_ X-MS-Office365-Filtering-Correlation-Id: a83fd67d-e230-4ad4-8c8d-08db2bccb6b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gler8wwI11K+amMhzkX7iIhIlLNDaJuQczH327J5dNPVVTGUPp/8FBWi6TnoBQOsq0GNGSrflY+WEEJsG3yIgq3sPAZ2+oS7spM81sgnwnhSzp3AQe1SY1DuGypwMojdfKV4cHr52z2M4/f8z/UB8zYx6atjClLW825Olc3lbfZ6pHQE+U+g6C0sBgHnongwk9u7bQDtpDYdcTinSaxJJQ1YFhfbqg1UH+31arXbaonVyTywT48xjiqS/mHROsLOa3Vathy9x6Mf/5okO7z3rliA4bzdgq1Pi1Bsonb3EFqrSVQSF6+3+AQd8C8tQa/qSP5uil5XMuw4YGieEkEG5B6Pa8/cYZbTASBuXW29qaIso54TyyTu4uNqsV2+fQCo34DwvMWbs4bBlxhI9K/mSGyN+rv4XT4equ5XSal977H004xMF4dibeztz5BzOmbuWoYse2IBdfcjuS+NMcztqgVrIEC8wW2p/lC8CASPmLymbiQvsDQcwSWM4Ntnnu8Hl0JcNs1kMAxGfbMoLb2DyJehzsFS25ainLQP5Pl1v2GNIqytTBQGobwimtiB0elxQHGkA8Md65qN0GqhUW77tgb+W/0owxLj193m1DGZX3fvd2aHCk/KhcdALI4SENmICXtbbbP9Sek6j2Zoc8Z/KyiXd261Ktmp96jsmQZrIVIAc0Q+QfK1/GD/4ft+7jMCDMYYso8mcpoJXQ25e1ZyaeZ9iqKGSIOQ+NnoA28dCMY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR0101MB2942.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(396003)(376002)(136003)(366004)(39850400004)(451199018)(31686004)(83170400001)(38100700002)(2906002)(6486002)(83380400001)(478600001)(186003)(42882007)(2616005)(31696002)(19627235002)(54906003)(8676002)(4326008)(66556008)(66946007)(66476007)(30864003)(5660300002)(53546011)(6666004)(8936002)(26005)(6512007)(6506007)(316002)(41300700001)(43740500002)(44824005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SWZkSDFJc1BFYVVjNWJRTlo5SkpzVTUxdldEU0xBTXZEaTFnQVhoejdqRU93?= =?utf-8?B?YlR1Nk9TaUFielhDdjdaeVByblE4cERUY0Znb1FYVVV2OHI1dkE1Zjc1VWxa?= =?utf-8?B?Zm1qZm1Vd0R5TUJBbkY1dXRENU0xaDJBcG1CMmcvR2g2ZUdyRVRTRitobytx?= =?utf-8?B?bFErUCtFQWdPMWlLN2xkTDVPMjVsTzlMRmhRcjZwWEJzazc3Ty9GWUZFaytV?= =?utf-8?B?VjFnSkNSTmhzVkhZZ3lMbW5uUlhmSkZSSXRDbHJUSmZLc0hGL0VzZW9CWjRS?= =?utf-8?B?VExaMDZQU3Z4MGJGZ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NUFd5ckdZSmxP?= =?utf-8?B?T2hVVjlVdXRFZDVoZE9rRXJlY3l5VEUvUFo2WTZmTy80VGtndmZweUJOY29B?= =?utf-8?Q?O/NJ6wAmqn12GmhNfSGobHbAaTFcAsJOabP+4tDn3SHX?= X-OriginatorOrg: amperemail.onmicrosoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: a83fd67d-e230-4ad4-8c8d-08db2bccb6b1 X-MS-Exchange-CrossTenant-AuthSource: MWHPR0101MB2942.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2023 18:30:44.4750 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tx0IDTaKiHIbfXeGMBe5guQtuvx6cZfvguwO4oBN/AwBj3HnScMeBMQQVc8qut6igARTefbM+TVFHk8aczw2xPgDzVAZSG55aZMCZHxhy13guDtdBWRCFqeLC95bEYS7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR01MB3987 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Abner, On 3/22/2023 9:48 AM, Chang, Abner via groups.io wrote: > 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 | 24 +- > .../Include/Dsc/Manageability.dsc | 2 + > .../BaseManageabilityTransportHelper.inf | 41 +++ > .../Library/ManageabilityTransportHelperLib.h | 93 +++++++ > .../BaseManageabilityTransportHelper.c | 261 ++++++++++++++++++ > .../BaseManageabilityTransportHelper.uni | 13 + > 6 files changed, 433 insertions(+), 1 deletion(-) > create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf > create mode 100644 Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h > create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.c > create mode 100644 Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.uni > > diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec b/Features/ManageabilityPkg/ManageabilityPkg.dec > index 92ba4538c0..ebbb04dc0e 100644 > --- a/Features/ManageabilityPkg/ManageabilityPkg.dec > +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec > @@ -22,5 +22,27 @@ > # Manageability Transport Library definitions > ManageabilityTransportLib|Include/Library/ManageabilityTransportLib.h > > + ## @libraryclass Manageability Transport Helper Library > + # Provide the help functions to use ManageabilityTransportLib > + ManageabilityTransportHelperLib|Include/Library/ManageabilityTransportHelperLib.h > + > [Guids] > - gManageabilityPkgTokenSpaceGuid = { 0xBDEFFF48, 0x1C31, 0x49CD, { 0xA7, 0x6D, 0x92, 0x9E, 0x60, 0xDB, 0xB9, 0xF8 } } > + gManageabilityPkgTokenSpaceGuid = { 0xBDEFFF48, 0x1C31, 0x49CD, { 0xA7, 0x6D, 0x92, 0x9E, 0x60, 0xDB, 0xB9, 0xF8 } } > + > + # Manageability Transport Interface type > + # > + # Manageability Transport KCS > + gManageabilityTransportKcsGuid = { 0x5A6E64E9, 0xFD47, 0x4086, { 0xAA, 0xB0, 0x7A, 0x5F, 0xD7, 0x6B, 0x02, 0x2E } } > + # Manageability Transport I2C > + gManageabilityTransportI2CGuid = { 0x5B174658, 0x8263, 0x4CB8, { 0xA0, 0x0F, 0xD6, 0x82, 0xE6, 0xBC, 0x74, 0x93 } } > + # Manageability Transport PCI VDM > + gManageabilityTransportPciVdmGuid = { 0x388021A7, 0xFB59, 0x4811, { 0x9D, 0xA7, 0xD5, 0x63, 0x7D, 0x04, 0xA7, 0x2F } } > + > + # Manageability Protocol Specification > + # > + # Manageability Protocol IPMI > + gManageabilityProtocolIpmiGuid = { 0x36ACA47C, 0xCC80, 0x473B, { 0xAB, 0xEC, 0xF3, 0x98, 0xFF, 0x87, 0x74, 0x5B } } > + # Manageability Protocol MCTP > + gManageabilityProtocolMctpGuid = { 0x76FED8F1, 0x0BE5, 0x4269, { 0xA3, 0x1A, 0x38, 0x0F, 0x54, 0xF1, 0xA1, 0x8A } } > + # Manageability Protocol PLDM > + gManageabilityProtocolPldmGuid = { 0x3958090D, 0x69DD, 0x4868, { 0x9C, 0x41, 0xC9, 0xAC, 0x31, 0xB5, 0x25, 0xC5 } } > diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc b/Features/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/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf > > [LibraryClasses.ARM, LibraryClasses.AARCH64] > # > diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf > new file mode 100644 > index 0000000000..95c3362ddb > --- /dev/null > +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.inf > @@ -0,0 +1,41 @@ > +## @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 = 0x0001001B > + BASE_NAME = BaseManageabilityTransportHelper > + MODULE_UNI_FILE = BaseManageabilityTransportHelper.uni > + FILE_GUID = 52F2DE11-A8FC-4A06-B8C6-10DCF4A7397C > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = ManageabilityTransportHelperLib > + > +# > +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + BaseManageabilityTransportHelper.c > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + > +[Packages] > + ManageabilityPkg/ManageabilityPkg.dec > + MdePkg/MdePkg.dec > + > +[Guids] > + gManageabilityTransportKcsGuid > + gManageabilityTransportI2CGuid > + gManageabilityTransportPciVdmGuid > + gManageabilityTransportMctpGuid Please check here since I am unable to find the definition of gManageabilityTransportMctpGuid. > + gManageabilityProtocolIpmiGuid > + gManageabilityProtocolMctpGuid > + gManageabilityProtocolPldmGuid > + > diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h > new file mode 100644 > index 0000000000..718ac34a1f > --- /dev/null > +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportHelperLib.h > @@ -0,0 +1,93 @@ > +/** @file > + > + This file defines the manageability transport interface library and functions. > + > + 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 specification. > + > + @param[out] SpecificationGuid The Manageability specification GUID > + > + @retval !NULL Human readable name is returned; > + @retval NULL No string found, the given Manageability specification 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 protocols supported > + by the transport interface. > + @param[in] NumberOfSupportedProtocolInArray Number of protocols in the array. > + @param[in] ManageabilityProtocolToCheck The Manageability specification to check. > + > + @retval EFI_SUCCESS Token is created successfully. > + @retval EFI_INVALID_PARAMETER Either NumberOfSupportedProtocolInArray = 0 or > + SupportedManageabilityProtocolArray = NULL. > + @retval EFI_UNSUPPORTED Out of resource to create a new transport 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 specification. > + @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 transport 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 successfully. > + @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 *TransportAdditionalStatus OPTIONAL > + ); > + > +#endif > diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.c b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.c > new file mode 100644 > index 0000000000..81da209764 > --- /dev/null > +++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.c > @@ -0,0 +1,261 @@ > +/** @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 > + > +// > +// BaseManageabilityTransportHelper is used by PEI, DXE and SMM. > +// Make sure the global variables added here should be unchangable. > +// > +MANAGEABILITY_SPECIFICATION_NAME ManageabilitySpecNameTable[] = { > + { &gManageabilityTransportKcsGuid, L"KCS" }, > + { &gManageabilityTransportI2CGuid, L"I2C" }, Should we use SMBUS_I2C instead of I2C? When we use SmbusLib/SmbusHcProtocol for IPMI SSIF and name it I2C, it causes a lot of confusion. The term SMBus is used in the IPMI specification, and the term SMBus/I2c is used in the MCTP specification. - Tinh > + { &gManageabilityTransportPciVdmGuid, L"PCI VDM" }, > + { &gManageabilityTransportMctpGuid, L"MCTP" }, > + { &gManageabilityProtocolIpmiGuid, L"IPMI" }, > + { &gManageabilityProtocolMctpGuid, L"MCTP" }, > + { &gManageabilityProtocolPldmGuid, L"PLDM" } > +}; > + > +UINT16 mManageabilitySpecNum = sizeof (ManageabilitySpecNameTable)/ sizeof (MANAGEABILITY_SPECIFICATION_NAME); > + > +/** > + Helper function returns the human readable name of Manageability specification. > + > + @param[in] SpecificationGuid The Manageability specification GUID > + > + @retval !NULL Human readable name is returned; > + @retval NULL No string found, the given Manageability specification is > + not supported. > +**/ > +CHAR16 * > +HelperManageabilitySpecName ( > + IN EFI_GUID *SpecificationGuid > + ) > +{ > + UINT16 Index; > + MANAGEABILITY_SPECIFICATION_NAME *ThisSpec; > + > + if (mManageabilitySpecNum == 0) { > + return NULL; > + } > + > + if (SpecificationGuid == NULL || IsZeroGuid (SpecificationGuid)) { > + DEBUG((DEBUG_ERROR, "%a: Improper input GUIDs, could be NULL or zero GUID.\n", __FUNCTION__)); > + return NULL; > + } > + > + ThisSpec = ManageabilitySpecNameTable; > + for (Index = 0; Index < mManageabilitySpecNum; 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 protocols supported > + by the transport interface. > + @param[in] NumberOfSupportedProtocolInArray Number of protocols in the array. > + @param[in] ManageabilityProtocolToCheck The Manageability specification to check. > + > + @retval EFI_SUCCESS Token is created successfully. > + @retval EFI_INVALID_PARAMETER Either NumberOfSupportedProtocolInArray = 0 or > + SupportedManageabilityProtocolArray = NULL. > + @retval EFI_UNSUPPORTED Out of resource to create a new transport 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 == 0) || (SupportedManageabilityProtocolArray == NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (TransportGuid == NULL || > + IsZeroGuid (TransportGuid) || > + ManageabilityProtocolToCheck == NULL || > + IsZeroGuid (ManageabilityProtocolToCheck) > + ) { > + DEBUG((DEBUG_ERROR, "%a: Improper input GUIDs, could be NULL or zero GUID.\n", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + ThisSpecGuid = SupportedManageabilityProtocolArray; > + for (Index = 0; Index < NumberOfSupportedProtocolInArray; Index++) { > + if (CompareGuid ( > + *ThisSpecGuid, > + ManageabilityProtocolToCheck > + )) > + { > + DEBUG (( > + DEBUG_VERBOSE, > + "%a: Transport interface %s supports %s manageability specification.\n", > + __FUNCTION__, > + HelperManageabilitySpecName (TransportGuid), > + HelperManageabilitySpecName (ManageabilityProtocolToCheck) > + )); > + return EFI_SUCCESS; > + } > + > + ThisSpecGuid++; > + } > + > + DEBUG (( > + DEBUG_ERROR, > + "%a: Transport interface %s doesn't support %s manageability specification.\n", > + __FUNCTION__, > + HelperManageabilitySpecName (TransportGuid), > + HelperManageabilitySpecName (ManageabilityProtocolToCheck) > + )); > + return EFI_UNSUPPORTED; > +} > + > +/** > + Helper function to acquire the Manageability transport token. > + > + @param[in] ManageabilityProtocolSpec The Manageability protocol specification. > + @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 transport 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 == NULL) || (ManageabilityProtocolSpec == NULL)) { > + DEBUG ((DEBUG_ERROR, "%a: One of the required input parameters is NULL.\n", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + *TransportToken = NULL; > + ManageabilityProtocolName = HelperManageabilitySpecName (ManageabilityProtocolSpec); > + if (ManageabilityProtocolName == NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Unsupported Manageability Protocol Specification.\n", __FUNCTION__)); > + return EFI_UNSUPPORTED; > + } > + > + DEBUG ((DEBUG_INFO, " Manageability protocol %s is going to acquire transport interface token...\n", ManageabilityProtocolName)); > + > + Status = AcquireTransportSession (ManageabilityProtocolSpec, TransportToken); > + if (Status == EFI_UNSUPPORTED) { > + DEBUG ((DEBUG_ERROR, "%a: No supported transport interface for %s packet.\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 = HelperManageabilitySpecName ((*TransportToken)->Transport->ManageabilityTransportSpecification); > + if (ManageabilityTransportName == NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Unsupported Manageability Transport Interface 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 successfully. > + @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 *TransportAdditionalStatus OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + > + if (TransportToken == NULL) { > + DEBUG ((DEBUG_ERROR, "%a: TransportToken is invalid.\n", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + // Initial transport interface. > + Status = TransportToken->Transport->Function.Version1_0->TransportInit (TransportToken, HardwareInfo); > + if ((Status != EFI_SUCCESS) && (Status != EFI_ALREADY_STARTED)) { > + if (Status == EFI_DEVICE_ERROR) { > + // Try to reset the transport and initialize it again. > + Status = TransportToken->Transport->Function.Version1_0->TransportReset ( > + TransportToken, > + TransportAdditionalStatus > + ); > + if (EFI_ERROR (Status)) { > + if (Status == 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 = EFI_DEVICE_ERROR; > + } else { > + Status = TransportToken->Transport->Function.Version1_0->TransportInit (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/BaseManageabilityTransportHelperLib/BaseManageabilityTransportHelper.uni b/Features/ManageabilityPkg/Library/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 Transport Helper Library" > + > +#string STR_MODULE_DESCRIPTION #language en-US "Manageability Transport Helper Functions." > +