From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.82]) by mx.groups.io with SMTP id smtpd.web10.2309.1681974351023195446 for ; Thu, 20 Apr 2023 00:05:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=CMPtg02e; 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.94.82, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RHgyktHmgm623cCWYZ4hWhJmGp4KWj91FwmQz5+Vmm3iwUJ5drOfa5fQBy53aX/847pFtXbR0P2yviwonwXh3RHvIyDO6J9SSe6c/O2n5dDff4lVm461zI5+v189ybeIgkzsVicgoXZqdQXzRP2vKOAjqI43AyQAWUNXqCLiyC66ExK9g8VMtFIE9DHZpLd7LbACYBtczXKUEiTiQU/jlAPu2vc2/0/qoJKrUnR4uBZ+RaJP+P7ygpGU+k5jyJoVMNxvfkkIjdHRFzNa0rijhF2yk8lfJEwyomx6kMCdD5chxZrhUk96h5YrYYqGYjgvq859ZuEns8LEyJAZjM7FKw== 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=kVLZkvQQ/bXSccpLZHmM02uzTznf7P4M4K9b98lkifw=; b=b5d7cMR1gRAE/UZUHgTpuToyM/YV4tI9xXyVK5w3Le/qwUSvqYeH5WG/CX+3jgLJvu7F82Y3TtRc6Ezfoy8WVauLLQ3Ap/huohCp2mGMw2t5FfoU5bXnpc/aqxKtoZZInz4taR+fJPsh8E1m0ZQdCXMztuylVOBZ57zUbEo27FyX+bZfYSEq3T8MdcA/5MmBaeI1X0gC1LgXyZ9DSPOGHXLstJcHkvSpec35waEIYayyjiKu9n5NVeQ/A9jpsFiG/wWsJdncH6njkRSXyhee6/cbuI2Bz33nQHmklvyyT7pLInXjHFzrwFuNWKKWu4Enp6rp0whXKmFvXOCFaZUHuw== 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=kVLZkvQQ/bXSccpLZHmM02uzTznf7P4M4K9b98lkifw=; b=CMPtg02eRJL3xVaU7CGhMuEHDm5wEgkJmpkquGGizJ5sy4t7SFgT8lTCu0khtPIzJeK3A6xRUbooiIp+0Dp0zahIIPJYj8T+a9vYbJIT/9CjIMXavcwrI48L+p8sarOo6mfezOOG8F9gStun36eRsURDMVN9jSBeG+nofnV0FCwcntQdkYEOsazJnYvedd5EullZHDEGMkIkYRJYRPmQ0/d8gr7DbNEhMzoClq7jLZJBoRRiM1ThaJqW8I91gMSPsf6BeDZoDoyvqblBo7neE3ENCZVc2F+o4R6ICfENfBO6S/279q3nImaB5Ke/eXCIAZQv5lF8aY4BG8oyDFZCzw== Received: from MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) by PH0PR12MB7789.namprd12.prod.outlook.com (2603:10b6:510:283::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Thu, 20 Apr 2023 07:05:47 +0000 Received: from MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::d9df:b45b:2cc1:f017]) by MW4PR12MB7031.namprd12.prod.outlook.com ([fe80::d9df:b45b:2cc1:f017%5]) with mapi id 15.20.6319.022; Thu, 20 Apr 2023 07:05:47 +0000 From: "Nickle Wang" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Isaac Oram , Abdul Lateef Attar , Igor Kulchytskyy Subject: Re: [edk2-platforms][PATCH V2 11/14] ManageabilityPkg/PldmProtocol: Add PLDM protocol Thread-Topic: [edk2-platforms][PATCH V2 11/14] ManageabilityPkg/PldmProtocol: Add PLDM protocol Thread-Index: AQHZccW0W7qBap26p0CRHNjpXNns/K8zyXQg Date: Thu, 20 Apr 2023 07:05:47 +0000 Message-ID: References: <20230418071543.1951-1-abner.chang@amd.com> <20230418071543.1951-12-abner.chang@amd.com> In-Reply-To: <20230418071543.1951-12-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_|PH0PR12MB7789:EE_ x-ms-office365-filtering-correlation-id: 453c6480-546b-446d-3360-08db416daa85 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: R4wZKK8w58yY/6OqsgPkqnpYfWEVZ7iZwCyUPQraAtfdrynC8dtYQUqtmGu8R8CSrCBdbAgNo+YSoPBVlx1D27OPi+hAI5AL2yEI1l7QJ//1+nikK4XCuY2HcN2blg2KSc6F0L0m23FiL+YtxnTH9HQGsSAK+q+9UoJ8fR9EUyymBQU+GerZGeCx6FjXzTmBeE19g4kD7vU9RCJkrxURyByO4SVJOvnDzdZwtBf5DWEU4XWbnuvsD+AUo+ILBamLlMGYjGcBlQD1DHCw4SIr9TFsf82Je9YLoL+SPMRD5EtuUhdtBOXG6UKMDkPY3c1h/YHT1KOdb3kEWGxz8h+dd508pRuvRPT3Sn3UEYQVM77P5H8t8Qjj97tmxzAMUmj0NNpxV5iWvXprC6922m8UMRpm2w3ceoyvWVsH7ABDMB11iszYuKUXqDzohMF4V5bhUZ3ki/+2cEGw7hQeRNba40V3akhufUk+amlx77gufuZM5/5o6D5ZAC+PcKmnKD1TRijnaexH01SwjEMWD5x5QuiGRpZhRwOH5pxazsrfeHtZFVmqnFUqvYXjeyAILlwf6YxrGjmIGY7VfV88QOKYGwmwcMtm0KEbDNK6KNBHdxSzoHOuIJY+RuDDxgGSY67fACqPZxjUFOw0DwFQLl2QsQ== 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:(13230028)(4636009)(136003)(376002)(346002)(39860400002)(396003)(366004)(451199021)(66946007)(64756008)(66556008)(2906002)(30864003)(66446008)(66476007)(86362001)(4326008)(5660300002)(52536014)(8936002)(41300700001)(55016003)(76116006)(54906003)(478600001)(33656002)(110136005)(19627235002)(316002)(71200400001)(7696005)(26005)(9686003)(186003)(122000001)(6506007)(83380400001)(53546011)(8676002)(38070700005)(38100700002)(579004)(559001)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?coYmszcLqp+x/fdN558CwfjgsrcLLAoiyNOcXFSJeFQveVyL2LvUa/k4h8fI?= =?us-ascii?Q?ito3bRNweUF9Uj9kpMCj4Xv1q3ZnzXWR4Uy9+5P5ZHRVd+s1AMOWUULdx7dj?= =?us-ascii?Q?l8EAVXUBRXsbb7+FaLixWM4Gqa/y9gN7wqH7FolkLR+Tj2pETDY1Q9dyV7cM?= =?us-ascii?Q?EN9044XX3jkq5oSbZq4s/FROCB+OqUpQmr+12zR0dU4srk5qpb/oejAeOa32?= =?us-ascii?Q?Abkt6hT2Y9b3ZYdbe3NZ3W6yVEsWXF1fVSzw6efKEVh4F2W2KT0zt5VbqwZ+?= =?us-ascii?Q?y4KyNYFc4DuSBKL2gF/gb3ZSCQDOm6L0AGbEwGXgCXtRceTZUfG6CoMRTFcz?= =?us-ascii?Q?ZQe5Iq4yfghP8XIOwAN4ZbQpXWTxN4v2B5usBpS1eBjctWiJ/u1U2Vldvxtb?= =?us-ascii?Q?+hT+KNCg2C3BgEypoXE/+82CJH4943xOI3CmJUPoTiARYI9A6m4Pm2NH30fW?= =?us-ascii?Q?Xbqk5nqxnAM7nLPEdXt9MxmPjBahGbGPTplx3/tT+MNPfEqLio4dCKJZh3fF?= =?us-ascii?Q?fYucFE4HZYReNtrwsUHc8ByIxP1ZZqJX8uIukObl8dGorWUlSTOc3fjm+dxM?= =?us-ascii?Q?KnmXwoxqJSaMv5/fDg+6ImuXMKM0suGY4TtaIcYIcRUfzyEqkeZbBYOyOKH0?= =?us-ascii?Q?fD9Q3/YDfeLLQqzpFKNp0nhJcRuEErAMdkGIWivykLK7zeCUQn9We1GGE5Bv?= =?us-ascii?Q?vTrwZXmN2gadR1hud0PIG3w64LAtg6uonOudRUweGF+tNYa2UHH8XjIWJRWX?= =?us-ascii?Q?51nEG2Q6tMboUGA1nMEtgt/mKUBtruRHgDqO6F1CQLxjk0LvVg6Mcztassr2?= =?us-ascii?Q?XLSGYbPPf2xXwyYnSB5D8jSXd8RxV5Bnh/8feuehJNv4ZceJilFj6FJGyb2u?= =?us-ascii?Q?8zYmJRxEHLRGYxi8zO6XzHhCeWMMrx346Rv0C1SzAf/epIyuqMF/ohFjHV2B?= =?us-ascii?Q?+CiG8Ym2LffEXwqXXT2e32XdDFczpZmSxRC/kIodg4flIF6F0nl4euQj5+rq?= =?us-ascii?Q?WLZTBeOfqfPw+N30pnSZq5TeOoaq9rFJPMcppHJESzYU2E3MVlwGWVqFKWTP?= =?us-ascii?Q?Zesia5wxbzTw/cGXUgPIjc8PQ5dlhms0zbULJvlaNfxtvW1kQLt+V+OwoUgJ?= =?us-ascii?Q?4b4NKP/Q95eEd1kqGaSgD3mpn2vHIrjQw2j9Bou5IUeJEXB+2wVumZrDeAgC?= =?us-ascii?Q?oZxUFCGbjgTM93Yl4PF3yk9pZ5jql/4D6Rb017PH7t73rQ1iI/IPvJ6RlmDg?= =?us-ascii?Q?Sh4JN1UpAlWkA5cS/y1Kdwvq5QSuM8tMvkQHuZpPrW4JKsyFfbqXS8j7keOn?= =?us-ascii?Q?LivdQc9dFIyZ5SwP7c0sfUEUOIo1595FkO9RQznXZJlH9wVVtyznHn7vWS05?= =?us-ascii?Q?gaqEPUAaJWhGcAsINaDVohDVEjnbwUpOy77XvgqkHbpOkp53AEGTS4lj7rZQ?= =?us-ascii?Q?vj0tWtTUcdQ6a8g396U6NB5bzogiBWfrBJ01EDzgK6qL8UBBttAhu7A4kfGb?= =?us-ascii?Q?tPCXa8him1k2G8iLnIHXpxqPWRs3WIhctpLNtCeugAZXtkS7Jxkgpf1hR7/n?= =?us-ascii?Q?L4TvxXbRrGzCS++w4I4=3D?= 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: 453c6480-546b-446d-3360-08db416daa85 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2023 07:05:47.0789 (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: 5/oNJBftLJ57isz24eedOrhddgfIhuKcZSvjlSqmToHe81eWdYp+kM/PXJzmkXH+t7tB81hERVAalw8SaZ74Hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7789 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nickle Wang Regards, Nickle > -----Original Message----- > From: abner.chang@amd.com > Sent: Tuesday, April 18, 2023 3:16 PM > To: devel@edk2.groups.io > Cc: Isaac Oram ; Abdul Lateef Attar > ; Nickle Wang ; Igor Kulchytskyy > > Subject: [edk2-platforms][PATCH V2 11/14] ManageabilityPkg/PldmProtocol: > Add PLDM protocol >=20 > External email: Use caution opening links or attachments >=20 >=20 > From: Abner Chang >=20 > PldmProtocol that transmits PLDM message over manageability transport > interface library. >=20 > Signed-off-by: Abner Chang > Cc: Isaac Oram > Cc: Abdul Lateef Attar > Cc: Nickle Wang > Cc: Igor Kulchytskyy > --- > .../Include/Dsc/Manageability.dsc | 1 + > .../PldmProtocol/Dxe/PldmProtocolDxe.inf | 50 ++ > .../PldmProtocol/Common/PldmProtocolCommon.h | 109 > +++++ .../PldmProtocol/Common/PldmProtocolCommon.c | 437 > ++++++++++++++++++ .../Universal/PldmProtocol/Dxe/PldmProtocol.c | 181 > ++++++++ > 5 files changed, 778 insertions(+) > create mode 100644 > Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocolDxe.inf > create mode 100644 > Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolCo > mmon.h > create mode 100644 > Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolCo > mmon.c > create mode 100644 > Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c >=20 > diff --git a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc > b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc > index 17f067c6d0..0fab562844 100644 > --- a/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc > +++ b/Features/ManageabilityPkg/Include/Dsc/Manageability.dsc > @@ -32,6 +32,7 @@ >=20 > [Components.X64] > ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocolSmm.inf > + ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocolDxe.inf >=20 > ManageabilityPkg/Universal/PldmSmbiosTransferDxe/PldmSmbiosTransferDxe.i > nf > ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf >=20 > diff --git > a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocolDxe.in > f > b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocolDxe.in > f > new file mode 100644 > index 0000000000..006f77b09a > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocolD > +++ xe.inf > @@ -0,0 +1,50 @@ > +## @file > +# EDKII PLDM Pootocol module INF file. > +# > +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent ## > + > +[Defines] > + INF_VERSION =3D 0x0001001d > + BASE_NAME =3D PldmProtocolDxe > + FILE_GUID =3D DA83FBDC-ECFE-4094-9ED3-EAFD1342333= F > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + ENTRY_POINT =3D DxePldmProtocolEntry > + UNLOAD_IMAGE =3D PldmProtocolUnloadImage > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + PldmProtocol.c > + ../Common/PldmProtocolCommon.c > + ../Common/PldmProtocolCommon.h > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + ManageabilityPkg/ManageabilityPkg.dec > + > +[LibraryClasses] > + BaseMemoryLib > + DebugLib > + ManageabilityTransportHelperLib > + ManageabilityTransportLib > + UefiDriverEntryPoint > + UefiBootServicesTableLib > + > +[Guids] > + gManageabilityTransportMctpGuid > + > +[Protocols] > + gEdkiiPldmProtocolGuid > + > +[FixedPcd] > + gManageabilityPkgTokenSpaceGuid.PcdMctpSourceEndpointId > + gManageabilityPkgTokenSpaceGuid.PcdMctpDestinationEndpointId > + > +[Depex] > + TRUE > diff --git > a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC > ommon.h > b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC > ommon.h > new file mode 100644 > index 0000000000..231d6e802e > --- /dev/null > +++ > b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtoc > +++ olCommon.h > @@ -0,0 +1,109 @@ > +/** @file > + > + EDKII PLDM Protocol common header file. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#ifndef MANAGEABILITY_EDKII_PLDM_COMMON_H_ > +#define MANAGEABILITY_EDKII_PLDM_COMMON_H_ > + > +#include > +#include > + > +typedef struct { > + UINT8 PldmType; > + UINT8 PldmCommand; > + UINT32 ResponseSize; > +} PLDM_MESSAGE_PACKET_MAPPING; > + > +/** > + This functions setup the PLDM transport hardware information > +according > + to the specification of transport token acquired from transport librar= y. > + > + @param[in] TransportToken The transport interface. > + @param[out] HardwareInformation Pointer to receive the hardwar= e > information. > + > + @retval EFI_SUCCESS Hardware information is returned in > HardwareInformation. > + Caller must free the memory allocated f= or > HardwareInformation > + once it doesn't need it. > + @retval EFI_UNSUPPORTED No hardware information for the > specification specified > + in the transport token. > +**/ > +EFI_STATUS > +SetupPldmTransportHardwareInformation ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + OUT MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION > +*HardwareInformation > + ); > + > +/** > + This functions setup the final header/body/trailer packets for > + the acquired transport interface. > + > + @param[in] TransportToken The transport interface. > + @param[in] PldmType PLDM message type. > + @param[in] PldmCommand PLDM command of this PLDM type. > + @param[out] PacketHeader The pointer to receive header of= request. > + @param[out] PacketHeaderSize Packet header size in bytes. > + @param[in, out] PacketBody The request body. > + When IN, it is the caller's requ= est body. > + When OUT and NULL, the request b= ody is not > + changed. > + Whee out and non-NULL, the reque= st body is > + changed to comfort the transport= interface. > + @param[in, out] PacketBodySize The request body size. > + When IN and non-zero, it is the = new data > + length of request body. > + When IN and zero, the request bo= dy is unchanged. > + @param[out] PacketTrailer The pointer to receive trailer o= f request. > + @param[out] PacketTrailerSize Packet trailer size in bytes. > + > + @retval EFI_SUCCESS Request packet is returned. > + @retval EFI_UNSUPPORTED Request packet is not returned because > + the unsupported transport interface. > +**/ > +EFI_STATUS > +SetupPldmRequestTransportPacket ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 PldmType, > + IN UINT8 PldmCommand, > + OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader, > + OUT UINT16 *PacketHeaderSize, > + IN OUT UINT8 **PacketBody, > + IN OUT UINT32 *PacketBodySize, > + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer, > + OUT UINT16 *PacketTrailerSize > + ); > + > +/** > + Common code to submit PLDM commands > + > + @param[in] TransportToken Transport token. > + @param[in] PldmType PLDM message type. > + @param[in] PldmCommand PLDM command of this PLDM type. > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The > completion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y > submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the > device or a response was not successfully received from the device. > + @retval EFI_NOT_READY PLDM transport interface is not ready f= or PLDM > command access. > + @retval EFI_DEVICE_ERROR PLDM Device hardware error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o > the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce > or data size error. > +**/ > +EFI_STATUS > +CommonPldmSubmitCommand ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 PldmType, > + IN UINT8 PldmCommand, > + IN UINT8 *RequestData OPTIONAL, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData OPTIONAL, > + IN OUT UINT32 *ResponseDataSize > + ); > + > +#endif // MANAGEABILITY_EDKII_PLDM_COMMON_H_ > diff --git > a/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC > ommon.c > b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtocolC > ommon.c > new file mode 100644 > index 0000000000..bb4d3f61a0 > --- /dev/null > +++ > b/Features/ManageabilityPkg/Universal/PldmProtocol/Common/PldmProtoc > +++ olCommon.c > @@ -0,0 +1,437 @@ > +/** @file > + > + IPMI Manageability Protocol common file. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > + reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#include > +#include > +#include > +#include #include > + > +#include > +#include > +#include > +#include > +#include > +#include "PldmProtocolCommon.h" > + > +extern CHAR16 *mTransportName; > +extern UINT8 mPldmRequestInstanceId; > + > +PLDM_MESSAGE_PACKET_MAPPING PldmMessagePacketMappingTable[] =3D { > + { PLDM_TYPE_SMBIOS, > +PLDM_GET_SMBIOS_STRUCTURE_TABLE_METADATA_COMMAND_CODE, > sizeof > +(PLDM_GET_SMBIOS_STRUCTURE_TABLE_METADATA_RESPONSE_FORMAT) }, > + { PLDM_TYPE_SMBIOS, > PLDM_SET_SMBIOS_STRUCTURE_TABLE_METADATA_COMMAND_CODE, sizeof > (PLDM_SET_SMBIOS_STRUCTURE_TABLE_METADATA_RESPONSE_FORMAT) }, > + { PLDM_TYPE_SMBIOS, > PLDM_SET_SMBIOS_STRUCTURE_TABLE_COMMAND_CODE, sizeof > (PLDM_SET_SMBIOS_STRUCTURE_TABLE_REQUEST_FORMAT) } > +}; > + > +/** > + This function returns the expected full size of PLDM response message. > + > + @param[in] PldmType PLDM message type. > + @param[in] PldmCommand PLDM command of this PLDM type. > + > + @retval Zero No matched entry for this PldmType/PldmCommand. > + @retval None-zero Size of full packet is returned. > +**/ > +UINT32 > +GetFullPacketResponseSize ( > + IN UINT8 PldmType, > + IN UINT8 PldmCommand > + ) > +{ > + INT16 Index; > + PLDM_MESSAGE_PACKET_MAPPING *ThisEntry; > + > + ThisEntry =3D PldmMessagePacketMappingTable; for (Index =3D 0; Index = < > + (sizeof (PldmMessagePacketMappingTable)/ sizeof > (PLDM_MESSAGE_PACKET_MAPPING)); Index++) { > + if ((PldmType =3D=3D ThisEntry->PldmType) && (PldmCommand =3D=3D Thi= sEntry- > >PldmCommand)) { > + return ThisEntry->ResponseSize; > + } > + > + ThisEntry++; > + } > + > + return 0; > +} > + > +/** > + This functions setup the final header/body/trailer packets for > + the acquired transport interface. > + > + @param[in] TransportToken The transport interface. > + @param[in] PldmType PLDM message type. > + @param[in] PldmCommand PLDM command of this PLDM type. > + @param[out] PacketHeader The pointer to receive header of= request. > + @param[out] PacketHeaderSize Packet header size in bytes. > + @param[in, out] PacketBody The request body. > + When IN, it is the caller's requ= est body. > + When OUT and NULL, the request b= ody is not > + changed. > + Whee out and non-NULL, the reque= st body is > + changed to comfort the transport= interface. > + @param[in, out] PacketBodySize The request body size. > + When IN and non-zero, it is the = new data > + length of request body. > + When IN and zero, the request bo= dy is unchanged. > + @param[out] PacketTrailer The pointer to receive trailer o= f request. > + @param[out] PacketTrailerSize Packet trailer size in bytes. > + > + @retval EFI_SUCCESS Request packet is returned. > + @retval EFI_UNSUPPORTED Request packet is not returned because > + the unsupported transport interface. > +**/ > +EFI_STATUS > +SetupPldmRequestTransportPacket ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 PldmType, > + IN UINT8 PldmCommand, > + OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader, > + OUT UINT16 *PacketHeaderSize, > + IN OUT UINT8 **PacketBody, > + IN OUT UINT32 *PacketBodySize, > + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer, > + OUT UINT16 *PacketTrailerSize > + ) > +{ > + MANAGEABILITY_MCTP_TRANSPORT_HEADER *MctpHeader; > + PLDM_REQUEST_HEADER *PldmRequestHeader; > + > + if ((PacketHeader =3D=3D NULL) || (PacketHeaderSize =3D=3D NULL) || > + (PacketBody =3D=3D NULL) || (PacketBodySize =3D=3D NULL) || > + (PacketTrailer =3D=3D NULL) || (PacketTrailerSize =3D=3D NULL) > + ) > + { > + DEBUG ((DEBUG_ERROR, "%a: One or more than one of the required > parameters is NULL.\n", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + if (CompareGuid (&gManageabilityTransportMctpGuid, TransportToken- > >Transport->ManageabilityTransportSpecification)) { > + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%a: Setup transport header for > + PLDM over MCTP.\n", __FUNCTION__)); > + > + // This is MCTP transport interface. > + MctpHeader =3D AllocateZeroPool (sizeof > (MANAGEABILITY_MCTP_TRANSPORT_HEADER)); > + if (MctpHeader =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for > MANAGEABILITY_MCTP_TRANSPORT_HEADER.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + MctpHeader->SourceEndpointId =3D PcdGet8 > (PcdMctpSourceEndpointId); > + MctpHeader->SourceEndpointId =3D PcdGet8 > (PcdMctpDestinationEndpointId); > + MctpHeader->MessageHeader.IntegrityCheck =3D FALSE; > + MctpHeader->MessageHeader.MessageType =3D > MCTP_MESSAGE_TYPE_PLDM; > + *PacketHeader =3D (MANAGEABILITY_TRANSPOR= T_HEADER > *)MctpHeader; > + *PacketHeaderSize =3D sizeof > (MANAGEABILITY_TRANSPORT_HEADER); > + *PacketTrailer =3D NULL; > + *PacketTrailerSize =3D 0; > + } else { > + DEBUG ((DEBUG_ERROR, "%a: No implementation of building up packet.\n= ", > __FUNCTION__)); > + ASSERT (FALSE); > + } > + > + // > + // Create header for the final request message. > + // > + PldmRequestHeader =3D (PLDM_REQUEST_HEADER *)AllocateZeroPool (sizeof > + (PLDM_REQUEST_HEADER) + *PacketBodySize); if (PldmRequestHeader =3D=3D > NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for final PLDM request > message.\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + PldmRequestHeader->RequestBit =3D > PLDM_MESSAGE_HEADER_IS_REQUEST; > + PldmRequestHeader->HeaderVersion =3D > PLDM_MESSAGE_HEADER_VERSION; > + PldmRequestHeader->PldmType =3D PldmType; > + PldmRequestHeader->PldmTypeCommandCode =3D PldmCommand; > + PldmRequestHeader->InstanceId =3D mPldmRequestInstanceId; > + if ((*PacketBody !=3D NULL) && (*PacketBodySize !=3D 0)) { > + CopyMem ( > + (VOID *)((UINT8 *)PldmRequestHeader + sizeof (PLDM_REQUEST_HEADER)= ), > + (VOID *)*PacketBody, > + *PacketBodySize > + ); > + } > + > + *PacketBody =3D (UINT8 *)PldmRequestHeader; > + *PacketBodySize =3D sizeof (PLDM_REQUEST_HEADER) + *PacketBodySize; > + return EFI_SUCCESS; > +} > + > +/** > + Common code to submit PLDM commands > + > + @param[in] TransportToken Transport token. > + @param[in] PldmType PLDM message type. > + @param[in] PldmCommand PLDM command of this PLDM type. > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The > completion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y > submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the > device or a response was not successfully received from the device. > + @retval EFI_NOT_READY Ipmi Device is not ready for Ipmi comma= nd > access. > + @retval EFI_DEVICE_ERROR Ipmi Device hardware error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o > the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce > or data size error. > +**/ > +EFI_STATUS > +CommonPldmSubmitCommand ( > + IN MANAGEABILITY_TRANSPORT_TOKEN *TransportToken, > + IN UINT8 PldmType, > + IN UINT8 PldmCommand, > + IN UINT8 *RequestData OPTIONAL, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData OPTIONAL, > + IN OUT UINT32 *ResponseDataSize > + ) > +{ > + EFI_STATUS Status; > + UINT8 *ThisRequestData; > + UINT32 ThisRequestDataSize; > + MANAGEABILITY_TRANSFER_TOKEN TransferToken; > + MANAGEABILITY_TRANSPORT_HEADER PldmTransportHeader; > + MANAGEABILITY_TRANSPORT_TRAILER PldmTransportTrailer; > + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS > TransportAdditionalStatus; > + UINT8 *FullPacketResponseData; > + UINT32 FullPacketResponseDataSize; > + PLDM_RESPONSE_HEADER *ResponseHeader; > + UINT16 HeaderSize; > + UINT16 TrailerSize; > + > + if (TransportToken =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: No transport token for PLDM\n", > __FUNCTION__)); > + return EFI_UNSUPPORTED; > + } > + > + Status =3D TransportToken->Transport->Function.Version1_0->TransportSt= atus ( > + TransportTo= ken, > + &TransportA= dditionalStatus > + ); if > + (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Transport %s for PLDM has problem - (%r)\n= ", > __FUNCTION__, mTransportName, Status)); > + return Status; > + } > + > + ThisRequestData =3D RequestData; // Save the original reque= st data > because the request data maybe modified > + // in SetupIpmiRequestTransp= ortPacket() according to > transport interface. > + ThisRequestDataSize =3D RequestDataSize; // Save the original reque= st data > size because the request data size maybe modified > + // in SetupIpmiRequestTrans= portPacket() according to > transport interface. > + PldmTransportHeader =3D NULL; > + PldmTransportTrailer =3D NULL; > + Status =3D SetupPldmRequestTransportPacket ( > + TransportToken, > + PldmType, > + PldmCommand, > + &PldmTransportHeader, > + &HeaderSize, > + &ThisRequestData, > + &ThisRequestDataSize, > + &PldmTransportTrailer, > + &TrailerSize > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Fail to build packets - (%r)\n", __FUNCTIO= N__, > Status)); > + return Status; > + } > + > + ZeroMem (&TransferToken, sizeof (MANAGEABILITY_TRANSFER_TOKEN)); > + TransferToken.TransmitHeader =3D PldmTransportHeader; > + TransferToken.TransmitHeaderSize =3D HeaderSize; > + TransferToken.TransmitTrailer =3D PldmTransportTrailer; > + TransferToken.TransmitTrailerSize =3D TrailerSize; > + > + // Transmit packet. > + if ((ThisRequestData =3D=3D NULL) || (ThisRequestDataSize =3D=3D 0)) { > + // Transmit parameter were not changed by > SetupIpmiRequestTransportPacket(). > + TransferToken.TransmitPackage.TransmitPayload =3D RequestData; > + TransferToken.TransmitPackage.TransmitSizeInByte =3D > + ThisRequestDataSize; } else { > + // Transmit parameter were changed by SetupIpmiRequestTransportPacke= t(). > + TransferToken.TransmitPackage.TransmitPayload =3D ThisRequestData= ; > + TransferToken.TransmitPackage.TransmitSizeInByte =3D > + ThisRequestDataSize; } > + > + TransferToken.TransmitPackage.TransmitTimeoutInMillisecond =3D > + MANAGEABILITY_TRANSPORT_NO_TIMEOUT; > + > + // Set receive packet. > + FullPacketResponseDataSize =3D GetFullPacketResponseSize (PldmType, > + PldmCommand); if (FullPacketResponseDataSize =3D=3D 0) { > + DEBUG ((DEBUG_ERROR, " No mapping entry in > PldmMessagePacketMappingTable for PLDM Type:%d Command %d\n", > PldmType, PldmCommand)); > + ASSERT (FALSE); > + } > + > + FullPacketResponseData =3D (UINT8 *)AllocateZeroPool > + (FullPacketResponseDataSize); if (FullPacketResponseData =3D=3D NULL) = { > + DEBUG ((DEBUG_ERROR, " Not enough memory for > FullPacketResponseDataSize.\n")); > + Status =3D EFI_OUT_OF_RESOURCES; > + goto ErrorExit2; > + } > + > + // Print out PLDM packet. > + DEBUG (( > + DEBUG_MANAGEABILITY_INFO, > + "%a: Send PLDM type: 0x%x, Command: 0x%x: Request size: 0x%x, Respon= se > size: 0x%x\n", > + __FUNCTION__, > + PldmType, > + PldmCommand, > + TransferToken.TransmitPackage.TransmitSizeInByte, > + FullPacketResponseDataSize > + )); > + > + HelperManageabilityDebugPrint ( > + (VOID *)TransferToken.TransmitPackage.TransmitPayload, > + TransferToken.TransmitPackage.TransmitSizeInByte, > + "PLDM full request payload.\n" > + ); > + > + TransferToken.ReceivePackage.ReceiveBuffer =3D > FullPacketResponseData; > + TransferToken.ReceivePackage.ReceiveSizeInByte =3D > FullPacketResponseDataSize; > + TransferToken.ReceivePackage.TransmitTimeoutInMillisecond =3D > + MANAGEABILITY_TRANSPORT_NO_TIMEOUT; > + TransportToken->Transport->Function.Version1_0- > >TransportTransmitReceive ( > + TransportToken, > + &TransferToken > + ); // // Check > + the response size. > + if (TransferToken.ReceivePackage.ReceiveSizeInByte < sizeof > (PLDM_RESPONSE_HEADER)) { > + DEBUG (( > + DEBUG_MANAGEABILITY_INFO, > + "Invalid response header size of PLDM Type %d Command %d, Returned= size: > %d Expected size: %d\n", > + PldmType, > + PldmCommand, > + TransferToken.ReceivePackage.ReceiveSizeInByte, > + FullPacketResponseDataSize > + )); > + if (ResponseDataSize !=3D NULL) { > + if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeIn= Byte) > { > + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeIn= Byte; > + } > + } > + > + if (ResponseData !=3D NULL) { > + CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, > *ResponseDataSize); > + } > + > + goto ErrorExit; > + } > + > + // > + // Check the integrity of response. data. > + ResponseHeader =3D (PLDM_RESPONSE_HEADER *)FullPacketResponseData; if > + ((ResponseHeader->PldmHeader.DatagramBit !=3D 0) || > + (ResponseHeader->PldmHeader.RequestBit !=3D 0) || > + (ResponseHeader->PldmHeader.InstanceId !=3D mPldmRequestInstanceId= ) || > + (ResponseHeader->PldmHeader.PldmType !=3D PldmType) || > + (ResponseHeader->PldmHeader.PldmTypeCommandCode !=3D > PldmCommand)) > + { > + DEBUG ((DEBUG_ERROR, "PLDM integrity check of response data is > failed.\n")); > + DEBUG ((DEBUG_ERROR, " Request bit =3D %d (Expected value: 0)\n"= )); > + DEBUG ((DEBUG_ERROR, " Datagram =3D %d (Expected value: 0)\n"= )); > + DEBUG ((DEBUG_ERROR, " Instance ID =3D %d (Expected value: %d)\n= ", > ResponseHeader->PldmHeader.InstanceId, mPldmRequestInstanceId)); > + DEBUG ((DEBUG_ERROR, " Pldm Type =3D %d (Expected value: %d)\n= ", > ResponseHeader->PldmHeader.PldmType, PldmType)); > + DEBUG ((DEBUG_ERROR, " Pldm Command =3D %d (Expected value: %d)\n= ", > ResponseHeader->PldmHeader.PldmTypeCommandCode, PldmCommand)); > + if (ResponseDataSize !=3D NULL) { > + if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeIn= Byte) > { > + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeIn= Byte; > + } > + } > + > + if (ResponseData !=3D NULL) { > + CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, > *ResponseDataSize); > + } > + > + goto ErrorExit; > + } > + > + // > + // Check the response size > + if (TransferToken.ReceivePackage.ReceiveSizeInByte !=3D > FullPacketResponseDataSize) { > + DEBUG (( > + DEBUG_ERROR, > + "The response size is incorrect: Response size %d (Expected %d), > Completion code %d.\n", > + TransferToken.ReceivePackage.ReceiveSizeInByte, > + FullPacketResponseDataSize, > + ResponseHeader->PldmCompletionCode > + )); > + if (ResponseDataSize !=3D NULL) { > + if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeIn= Byte) > { > + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeIn= Byte; > + } > + } > + > + if (ResponseData !=3D NULL) { > + CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, > *ResponseDataSize); > + } > + > + goto ErrorExit; > + } > + > + if (*ResponseDataSize !=3D (TransferToken.ReceivePackage.ReceiveSizeIn= Byte - > sizeof (PLDM_RESPONSE_HEADER))) { > + DEBUG ((DEBUG_ERROR, " The size of response is not matched to > RequestDataSize assigned by caller.\n")); > + DEBUG (( > + DEBUG_ERROR, > + "Caller expects %d, the response size minus PLDM_RESPONSE_HEADER s= ize > is %d, Completion Code %d.\n", > + *ResponseDataSize, > + TransferToken.ReceivePackage.ReceiveSizeInByte - sizeof > (PLDM_RESPONSE_HEADER), > + ResponseHeader->PldmCompletionCode > + )); > + if (ResponseDataSize !=3D NULL) { > + if (*ResponseDataSize > TransferToken.ReceivePackage.ReceiveSizeIn= Byte) > { > + *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeIn= Byte; > + } > + } > + > + if (ResponseData !=3D NULL) { > + CopyMem ((VOID *)ResponseData, (VOID *)FullPacketResponseData, > *ResponseDataSize); > + } > + > + goto ErrorExit; > + } > + > + // Print out PLDM full responses payload. > + HelperManageabilityDebugPrint ((VOID *)FullPacketResponseData, > + FullPacketResponseDataSize, "PLDM full response payload\n"); > + > + // Copy response data (without header) to caller's buffer. > + if ((ResponseData !=3D NULL) && (*ResponseDataSize !=3D 0)) { > + *ResponseDataSize =3D FullPacketResponseDataSize - sizeof > (PLDM_RESPONSE_HEADER); > + CopyMem ( > + (VOID *)ResponseData, > + (VOID *)(FullPacketResponseData + sizeof (PLDM_RESPONSE_HEADER)), > + *ResponseDataSize > + ); > + } > + > + // Return transfer status. > + // > +ErrorExit: > + Status =3D TransferToken.TransferStatus; > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to send PLDM command over %s\n", > +__FUNCTION__, mTransportName)); > + } > + > +ErrorExit2: > + if (PldmTransportHeader !=3D NULL) { > + FreePool ((VOID *)PldmTransportHeader); > + } > + > + if (PldmTransportTrailer !=3D NULL) { > + FreePool ((VOID *)PldmTransportTrailer); } > + > + if (ThisRequestData !=3D NULL) { > + FreePool ((VOID *)ThisRequestData); } > + > + if (FullPacketResponseData !=3D NULL) { > + FreePool ((VOID *)FullPacketResponseData); } > + > + // > + // Update PLDM message instance ID. > + mPldmRequestInstanceId++; > + mPldmRequestInstanceId &=3D PLDM_MESSAGE_HEADER_INSTANCE_ID_MASK; > + return Status; > +} > diff --git > a/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c > b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol.c > new file mode 100644 > index 0000000000..bb34fec16e > --- /dev/null > +++ b/Features/ManageabilityPkg/Universal/PldmProtocol/Dxe/PldmProtocol. > +++ c > @@ -0,0 +1,181 @@ > +/** @file > + This file provides edk2 PLDM SMBIOS Transfer Protocol implementation. > + > + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#include > +#include > +#include > +#include #include > + > +#include > +#include > +#include > +#include > + > +#include "PldmProtocolCommon.h" > + > +MANAGEABILITY_TRANSPORT_TOKEN *mTransportToken =3D NULL; > +CHAR16 *mTransportName; > +UINT8 mPldmRequestInstanceId; > +UINT32 TransportMaximumPayload; > + > +/** > + This service enables submitting commands via EDKII PLDM protocol. > + > + @param[in] This EDKII_PLDM_PROTOCOL instance. > + @param[in] PldmType PLDM message type. > + @param[in] Command PLDM Command of PLDM message type= . > + @param[in] RequestData Command Request Data. > + @param[in] RequestDataSize Size of Command Request Data. > + @param[out] ResponseData Command Response Data. The > completion code is the first byte of response data. > + @param[in, out] ResponseDataSize Size of Command Response Data. > + > + @retval EFI_SUCCESS The command byte stream was successfull= y > submit to the device and a response was successfully received. > + @retval EFI_NOT_FOUND The command was not successfully sent t= o the > device or a response was not successfully received from the device. > + @retval EFI_NOT_READY PLDM transport interface is not ready f= or PLDM > command access. > + @retval EFI_DEVICE_ERROR PLDM transport interface Device hardwar= e > error. > + @retval EFI_TIMEOUT The command time out. > + @retval EFI_UNSUPPORTED The command was not successfully sent t= o > the device. > + @retval EFI_OUT_OF_RESOURCES The resource allocation is out of resou= rce > or data size error. > + @retval EFI_INVALID_PARAMETER Both RequestData and ResponseData are > +NULL **/ EFI_STATUS EFIAPI PldmSubmitCommand ( > + IN EDKII_PLDM_PROTOCOL *This, > + IN UINT8 PldmType, > + IN UINT8 Command, > + IN UINT8 *RequestData, > + IN UINT32 RequestDataSize, > + OUT UINT8 *ResponseData, > + IN OUT UINT32 *ResponseDataSize > + ) > +{ > + EFI_STATUS Status; > + > + if ((RequestData =3D=3D NULL) && (ResponseData =3D=3D NULL)) { > + DEBUG ((DEBUG_ERROR, "%a: Both RequestData and ResponseData are > NULL\n", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D CommonPldmSubmitCommand ( > + mTransportToken, > + PldmType, > + Command, > + RequestData, > + RequestDataSize, > + ResponseData, > + ResponseDataSize > + ); > + return Status; > +} > + > +EDKII_PLDM_PROTOCOL_V1_0 mPldmProtocolV10 =3D { > + PldmSubmitCommand > +}; > + > +EDKII_PLDM_PROTOCOL mPldmProtocol; > + > +/** > + The entry point of the PLDM SMBIOS Transfer DXE driver. > + > + @param[in] ImageHandle - Handle of this driver image @param[in] > + SystemTable - Table containing standard EFI services > + > + @retval EFI_SUCCESS - PLDM Protocol is installed successfully. > + @retval Otherwise - Other errors. > +**/ > +EFI_STATUS > +EFIAPI > +DxePldmProtocolEntry ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE Handle; > + MANAGEABILITY_TRANSPORT_CAPABILITY TransportCapability; > + MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS > TransportAdditionalStatus; > + MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION HardwareInfo; > + > + Status =3D HelperAcquireManageabilityTransport ( > + &gManageabilityProtocolPldmGuid, > + &mTransportToken > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for = PLDM > protocol - %r\n", __FUNCTION__, Status)); > + return Status; > + } > + > + Status =3D GetTransportCapability (mTransportToken, > + &TransportCapability); if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to GetTransportCapability().\n", > __FUNCTION__)); > + return Status; > + } > + > + TransportMaximumPayload =3D > + MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY > (TransportCapability); if (TransportMaximumPayload =3D=3D (1 << > MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILA > BLE)) { > + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%a: Transport interface maximum > + payload is undefined.\n", __FUNCTION__)); } else { > + TransportMaximumPayload -=3D 1; > + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%a: Transport interface for PLDM > + protocol has maximum payload 0x%x.\n", __FUNCTION__, > + TransportMaximumPayload)); } > + > + mTransportName =3D HelperManageabilitySpecName > + (mTransportToken->Transport->ManageabilityTransportSpecification); > + DEBUG ((DEBUG_MANAGEABILITY_INFO, "%a: PLDM protocol over %s.\n", > + __FUNCTION__, mTransportName)); > + > + // Initial transport interface with the hardware information assigned. > + HardwareInfo.Pointer =3D NULL; > + Status =3D HelperInitManageabilityTransport ( > + mTransportToken, > + HardwareInfo, > + &TransportAdditionalStatus > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + mPldmRequestInstanceId =3D 0; > + mPldmProtocol.ProtocolVersion =3D EDKII_PLDM_PROTOCOL_VERSION; > + mPldmProtocol.Functions.Version1_0 =3D &mPldmProtocolV10; > + Handle =3D NULL; > + Status =3D gBS->InstallProtocolInterface ( > + &Handle, > + &gEdkiiPldmProtocolGuid, > + EFI_NATIVE_INTERFACE, > + (VOID **)&mPldmProtocol > + ); if (EFI_ERROR > + (Status)) { > + DEBUG ((DEBUG_ERROR, "%a: Failed to install EDKII PLDM protocol - > + %r\n", __FUNCTION__, Status)); } > + > + return Status; > +} > + > +/** > + This is the unload handler of PLDM SMBIOS Transfer DXE driver. > + > + @param[in] ImageHandle The driver's image handle. > + > + @retval EFI_SUCCESS The image is unloaded. > + @retval Others Failed to unload the image. > + > +**/ > +EFI_STATUS > +EFIAPI > +PldmProtocolUnloadImage ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D EFI_SUCCESS; > + if (mTransportToken !=3D NULL) { > + Status =3D ReleaseTransportSession (mTransportToken); } > + > + return Status; > +} > -- > 2.37.1.windows.1