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.87]) by mx.groups.io with SMTP id smtpd.web11.8957.1679300756066437650 for ; Mon, 20 Mar 2023 01:25:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=McPDCr7a; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.93.87, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QaVObafaDG23nAhxJJ2wBZqfk5EWwYLBjBseu1S2Gj+HXkXo0CR0eHOz3r0MVJD298Y+T9CgmInwQ8sR3xZaGiP2d2l/KzDDPXtGR/kuQnH50vjh7aCsUkaoOemVPZzJNFBBscgTPffxSHJRafQx+R6HdSYRm0ZofKDC4d2Af3cu+xFuaDtPn5Gf1w574u7DGFSz6341MjUbKEww0TO/+kpgvFBZaHbIhyreu8grNoXZ1ljS6ZWbrCKRvhVZQ/5PT58uUqe30SPP/gQcvEColBa0ud6DTx4aKodtSeL9iKFbwXUTleXxjGsxUrmcBGl73dLHdaFiyMBffjCQsGAeMA== 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=Dj2cYAFh/5h+qoFuXr4G4rm5iW+3wz/H61VVBIzgScI=; b=nkXyzR46uDtf+ICCXnvV9iv69OnEVsuVrtoDbRRatm01rKA2kJH8U68cpyy85h5JOxZMQibIPkAmSky/0BLCRYCFasjXSv7SH+3sY+v8wKbXdfwu//6Q9eqHjH3mJyVTJ7kiq1s3O6zCaa38PPA6B4Erj1MHN2RGbvu6UXpGiuK6icSX25UZ5n2gEFVFvcSSdAQE1OeMzyfNfvEIrenXVdDmFOs43Dx8XwyixHU6CjCoPtodb4b5IGBIOAt1e6/ch0OOtqrQ8rdll7LsAHr/4Nu+/19C+TpoPvKoFAvn3Hu5qiCDTZHvrwWRO3BRlq1cdH3bwQVztwOG7NvL5x5EqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dj2cYAFh/5h+qoFuXr4G4rm5iW+3wz/H61VVBIzgScI=; b=McPDCr7az8VTb4Ko0FkFDFtvFeqMR8EJzD16uQ+RUAlsWx5sNdeltr58pzScz8iE3qoCee0XnlKqqhTX82OZAl0bI70OrYa0a8AwbA0eGDeTATsV/2h+6xwqYwMw47VHgIlgGHAqCmAB84ISdUC6R9/OhMrdvFIXprBxX/WipZ2OyJBnfJA3GnidR96XpX3+GZxDrYDJ/Ug15oz+fz4uMhYFZLturWjiMVj6uaWPTy/o7PI00ch7OE5GuEV6KD3VjnRIXcyE75/uXYd5gMli+euZRTZt5i/vsxtBdmqayPXQlMp3gDmy5gOK5NxlW7l7GWhBpxpeIXxpX9L3h67ytA== Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by DM4PR12MB8450.namprd12.prod.outlook.com (2603:10b6:8:188::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.29; Mon, 20 Mar 2023 08:25:53 +0000 Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::c27a:fa4b:66ea:d266]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::c27a:fa4b:66ea:d266%5]) with mapi id 15.20.6178.037; Mon, 20 Mar 2023 08:25:49 +0000 From: "Nickle Wang" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Liming Gao , Isaac Oram , Nate DeSimone , Igor Kulchytskyy , Abdul Lateef Attar Subject: Re: [edk2-platforms][PATCH V2 4/8] ManageabilityPkg: Add ManageabilityTransportHelperLib Thread-Topic: [edk2-platforms][PATCH V2 4/8] ManageabilityPkg: Add ManageabilityTransportHelperLib Thread-Index: AQHZUci4zJe5yI0o60GrJVGLdHv2kK8DZayw Date: Mon, 20 Mar 2023 08:25:49 +0000 Message-ID: References: <20230308141647.1318-1-abner.chang@amd.com> <20230308141647.1318-5-abner.chang@amd.com> In-Reply-To: <20230308141647.1318-5-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR12MB7031:EE_|DM4PR12MB8450:EE_ x-ms-office365-filtering-correlation-id: 58e5562b-cf6e-42a8-ec82-08db291cb5fd x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: t/ClRZLaA5q8vsGR1Mn3AZRH5Zp6tG6d/OqYKua9GxIThvK8I2AIz6aaTjEj8G27tZgB1pSy9lwJ+vzh/U2g0sc6jCiCM28Sq0+G2RWbUGoq6kbOKhTda9cHEZXs33oX9O/eqqlo5QdwSBOQiv71g+dias8e3OmgScQKGJ7/w/THhs9SsTXIHYrJL2gHM3++pWPTQoo3eYYKrTeLfRhKvhYb5juJkIC+tzjuuKPuOB1c1OUOtukZxCdLbSENIaJZCcJTHwdWTEzDJ1AszffpJiejpYDMUZ3TKiqG53mEMFhSWUq5JwoTTX48e/mNp+DASkRgd9tandCrFJgqqk51iOpN21SGwkxOpwXqr2d/BSTEBG6AXaFGtmLu+IIJq5PSQPJSqenycQtp5Hj4mh+Yl9PwaEqfdO7R638IFd/cSNC7tscxulYUYHF3BV3/ErfgtqRn8Y06GKE6pF1KVuY+HqG2xqlLO7Rgd9LivpSoTjYcBijKroSFrck+KFY4FbuAK7tvRTJc5DtMq55p2ShuZxo5/I/sIfHTwhxvHfs8GvjxFHzxgVV74Eg65auLcGztK5fVKLD5CmjV9qHCwT3C0EkWKs2em9TOvX56DtbAEZS8sQAMNjm94/uDp9/BO192cF0pDQaM501bA/KzzZmdMRf2MiXcD4cEuK7mVXzr6f8Nu9yogDCLNP4cXIb8/3aXhOEKVQoBdsgWbGSDzz2usg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR12MB7031.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199018)(66946007)(966005)(110136005)(122000001)(55016003)(71200400001)(76116006)(9686003)(66446008)(4326008)(66556008)(64756008)(316002)(66476007)(38070700005)(2906002)(8676002)(38100700002)(54906003)(478600001)(19627235002)(86362001)(53546011)(83380400001)(7696005)(41300700001)(33656002)(5660300002)(30864003)(26005)(186003)(52536014)(6506007)(8936002)(579004)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?CyifTaXHaUimCyz25pKn1UGv+UVW0BVs+0ZnOAmRd1aUC3S4RyZL47AFVFhG?= =?us-ascii?Q?t6STc7MRBKFyKVN6YJbziWomqT/CVEnAZbygy5XxifuA/B/3frLzen12iJHz?= =?us-ascii?Q?K975hI+twdDSB6JsBj+WwKfhf609BXg6C0e8iecdIQidK1SziVptQ3KUKUNu?= =?us-ascii?Q?kMJj432YuO/kIxqO2V/E5UNP1ppLMqYJb5nXqHnAPktedVXY3PFnlbrUTXps?= =?us-ascii?Q?PxIytKUjWsNKxOwUwX2pBjpkDcQ8g/yk+mNYoTYD+6amRjA7OfClhte3KgHB?= =?us-ascii?Q?6YZB+5Qr0uEZ/wxfnJh51a4G0jPXzScDDEVuotMbL3tFH8QNSqMJMrlkyXGD?= =?us-ascii?Q?0g22V1dt+VzetWTouIxLN45V6+2lj+lVjTIxgCeGhI3BB7rkt7mVWmHRB4Gn?= =?us-ascii?Q?FjQ2lXjNX608dPAovsOoJYBQl3zFq0oQFQeKp6Iz1ebBYVpGMcnjhjuQ/l/w?= =?us-ascii?Q?fV8uR8LwobgoDfaPGGkZ+0w5HLELpURbhadyHF8QI41VQIJUIb3zUWgch1Nj?= =?us-ascii?Q?aWaTowmzvutrWrvajpDOd1Nhf7HKftSSArhd6AsIhxp2XllkkIhVckZompHd?= =?us-ascii?Q?nmHbrk72l9NcTHMYgIo7/liHoP6mCPuEXqKw00eeSnjJTSmqTkHQlNEkPWpU?= =?us-ascii?Q?SZLeFRO6E1LZqRkFMTXDx+HuXJUBkBokxEpyzrT6Rj/r/IPIBuf05G/2eKJU?= =?us-ascii?Q?VSR2iJSowzvAFdzFvZ7UgRaWlYkPzQQuxPCLWcxGuyakEOKaqsF75C49N3y6?= =?us-ascii?Q?cCZqOSIZRU+oENIHMC78mXMLnDy5sPOVoxQK/+mKG0BooZDO2RoKzH175LpU?= =?us-ascii?Q?xdDZfeUigTR7Ah+qiSqFg/7seZgx0TbKS3F6HjDPXmDvj2/0JZBgjO7dMDSY?= =?us-ascii?Q?1fjY+WBNGvEESrxRxxa21giY8pgJON7vF+ykf2GqFsR5KBFHQ1AFr4FE31hP?= =?us-ascii?Q?IRRTr7iDgqka4DMR7tJs9nZhQIgZr61DP4Hqqb9wH68cWk+bKgsvvyAfPDOo?= =?us-ascii?Q?vE4i8avw3xK+DUnWcna81Q8TgxH6FMWxTiEW2FdnFNMWRFn0hJfH1Uebvg7x?= =?us-ascii?Q?UWvxk0DeiR19S2rF7rjmKs4FCVY1JUn8411nAN859khO0egxlvOYGzsNmkOC?= =?us-ascii?Q?Z3SdoyrWZEJDUeZBM2a2JeZHvJr1bP0LeRNwnHMrSjh8QgPYMjzUui5aIk2I?= =?us-ascii?Q?fRN21J70PkRT2MPJZjUyp9VM6wa1OaHj3fz1SNOSIaRymXtH1uQ40VHX4jXt?= =?us-ascii?Q?2WVJd0BFgqjJ2nwpcV2hgfcVLipHkozZNJVVj02O6K01veX6LB6UuKAYUgS7?= =?us-ascii?Q?13qi1WxCLw1LgzDz7cYuyWiLWRd1Emc4qoo5CUaD7+L3U/cC8N7Sy4gW51on?= =?us-ascii?Q?c5F3xkRJWlA6zYPVrGFb2dPCN7kkA17wCbVc6yj6ztsinH0g2xpI1hrJZDbt?= =?us-ascii?Q?vcL0T76XyM1OMCvvEtV44yVE7jYCjiJFmyfs8PycetvjP9S9CYKIAUXXWvYq?= =?us-ascii?Q?eatrXwRHMpJRMKjoE9dHYP8HECdOOwnmhnfcEEuLjumyKjnLD5KBO68bwt2t?= =?us-ascii?Q?BGFr84852XjN0VVkV6THl9ir46mrsBNfOk+4jQAE?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7031.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58e5562b-cf6e-42a8-ec82-08db291cb5fd X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Mar 2023 08:25:49.2041 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lKIj6NLy+g3XLIC1c2aAQTIBwemm7ZXB8SZv2+hxL1krbpM9S5+QAdcK9BMPwswk9mqePtpnSxMEQmkOlnPCyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8450 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please find my comment inline below. Regards, Nickle -----Original Message----- From: abner.chang@amd.com =20 Sent: Wednesday, March 8, 2023 10:17 PM To: devel@edk2.groups.io Cc: Liming Gao ; Isaac Oram ; Nate DeSimone ; Nickle Wang ; Igor Kulchytskyy ; Abdul Lateef Attar Subject: [edk2-platforms][PATCH V2 4/8] ManageabilityPkg: Add Manageability= TransportHelperLib External email: Use caution opening links or attachments From: Abner Chang The helper functions library facilitates reducing duplicated code in the ma= nageability 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 Feat= ures/ManageabilityPkg/Library/BaseManageabilityTransportHelperLib/BaseManag= eabilityTransportHelper.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 + ## @libraryclass Manageability Transport Helper Library + # Provide the help functions to use ManageabilityTransportLib + =20 + ManageabilityTransportHelperLib|Include/Library/ManageabilityTransport + HelperLib.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=20 + 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, {=20 + 0x9D, 0xA7, 0xD5, 0x63, 0x7D, 0x04, 0xA7, 0x2F } } + # Manageability Protocol Specification # # Manageability Protocol=20 + 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] + =20 +ManageabilityTransportHelperLib|ManageabilityPkg/Library/BaseManageabil +ityTransportHelperLib/BaseManageabilityTransportHelper.inf [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/BaseManageabilityTransportHelper +++ Lib/BaseManageabilityTransportHelper.inf @@ -0,0 +1,40 @@ +## @file +# Null instance of Manageability Transport Helper Library # # Copyright=20 +(C) 2023 Advanced Micro Devices, Inc. All rights reserved.
#=20 +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/ManageabilityTransportHe +++ lperLib.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=20 +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=20 +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=20 +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/BaseManageabilityTransportHelper +++ Lib/BaseManageabilityTransportHelper.c @@ -0,0 +1,242 @@ +/** @file + Null instance of Manageability Transport Helper Library + + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights=20 +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)/=20 +sizeof (MANAGEABILITY_SPECIFICATION_NAME); Per edk2 coding standard, I suggest to add prefix 'm' or 'g' to these globa= l variables. (ref: https://edk2-docs.gitbook.io/edk-ii-c-coding-standards-s= pecification/v/release-2.20/4_naming_conventions/43_identifiers#4.3.3.2-any= -variable-with-file-scope-or-better-shall-be-prefixed-by-an-m-or-g) + +/** + 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 + ) We can use IsZeroGuid() to check input GUID and see if input is Zero/NULL G= UID or not. +{ + UINT16 Index; + MANAGEABILITY_SPECIFICATION_NAME *ThisSpec; + + if (ManageabilitySpecNum =3D=3D 0) { + return NULL; + } + + ThisSpec =3D ManageabilitySpecNameTable; for (Index =3D 0; Index <=20 + ManageabilitySpecNum; Index++) { + if (CompareGuid ( + SpecificationGuid, + ThisSpec->SpecificationGuid + )) + { + return ThisSpec->SpecificationName; + } + + ThisSpec++; + } + + return NULL; +} + +/** + Helper function to check if the Manageability specification is=20 +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; + I suggest checking input GUID by using IsZeroGuid(). This can apply to othe= r input GUID pointer in this patch. Thanks, Nickle + 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=20 + ((TransportToken =3D=3D NULL) || (ManageabilityProtocolSpec =3D=3D NULL))= { + DEBUG ((DEBUG_ERROR, "%a: One of the required input parameters is NULL= .\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + *TransportToken =3D NULL; + ManageabilityProtocolName =3D HelperManageabilitySpecName=20 + (ManageabilityProtocolSpec); 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=20 + transport interface token...\n", ManageabilityProtocolName)); + + Status =3D AcquireTransportSession (ManageabilityProtocolSpec,=20 + TransportToken); 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=20 + ((*TransportToken)->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=20 +%s\n", __FUNCTION__, ManageabilityProtocolName,=20 +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=20 + TransportToken->Transport->Function.Version1_0->TransportInit (TransportT= oken, HardwareInfo); if ((Status !=3D EFI_SUCCESS) && (Status !=3D EFI_ALR= EADY_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/BaseManageabilityTransportHelper +++ Lib/BaseManageabilityTransportHelper.uni @@ -0,0 +1,13 @@ +// /** @file +// Null instance of Manageability Transport Helper Library // //=20 +Copyright (C) 2023 Advanced Micro Devices, Inc. All rights=20 +reserved.
// // SPDX-License-Identifier: BSD-2-Clause-Patent // //=20 +**/ + +#string STR_MODULE_ABSTRACT #language en-US "Manageability Tra= nsport Helper Library" + +#string STR_MODULE_DESCRIPTION #language en-US "Manageability Tra= nsport Helper Functions." + -- 2.37.1.windows.1