From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.69]) by mx.groups.io with SMTP id smtpd.web10.9437.1682077878644317957 for ; Fri, 21 Apr 2023 04:51:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=M8NFKgQ9; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.243.69, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YvB6RpetIqBMk5SiXdv5P1QpTDTtdzJJvNc6r18wBE57lmJWWxg2ciPz71iVXCG7fxUabPSXsrioRAatnNSyoCjtus9VfdsyMO7sq+Q5fdGd0se07r4vD+nqjVu5iB3usPM1jyt4BEyEkw7y7X/PTJeTvRRr8XQftl2RZ1xfCBPRpouyeKhBmeOgMc1qHnHEi9C5c87qb8sxSeV8WIZzGFxSz30J23/kt5v0ElLBuIznwmaIAhqQbJ2Vkt4Gp6cZzDk1YAnyUYmGpJ3hojjCtZB9x7T86rfFyXwY8MSQ0FwndSKAgHxNmcBI+wpwOKSVSyu+mij/oVxeAf9JRrqjnQ== 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=HziGG9hLjELdnuPwUq4TUIftIT6lw7dDc++yNFBBp6s=; b=AladGTgU8Aw0Texp93VME9lQ+tGyvaI8SNwoyeWrsCXwOP88emMSx4Iuhr9qGDgt6+6BPAptGwUv+RIavUWwlpjQ+t30eAf2SHEUAAlMERxX3kHH7GU7LO6GEMJvXSaTaBkuufoOrcukT4HXmoBEHwGnFt8y73+zHjxM6w88TA7Xrj047KaYcSyGJ19e3u0WRAtuYehCfYyFPMxMbWoo+zxSl6UNzZW/Xguq5LmxVhB7ADWZfYV0fvPHjrN+MKKz1cm8aD3xcK2o6IquFsoipgWkYpRqHSnoHXUiDdiBK9arKJwkxgOXAgnwtud4POeJgM+mDGq6pzMqtifTbuShAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HziGG9hLjELdnuPwUq4TUIftIT6lw7dDc++yNFBBp6s=; b=M8NFKgQ9IQYqZxNg9vo4rTB6AxgS8HxxjHJMlxP5R1lGTMLhoO8uEADwosoWV6H44+MTQI83fek76lhnNsU9D7gSWb8xU79WUHWNZxBHHXA/zyVoeB+ME2FWCpIcPn0P1hDrsceQng+gU/ch6pbK2GIuKV/lNo5/1UrfmGXrHBs= Received: from IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) by SN7PR12MB7788.namprd12.prod.outlook.com (2603:10b6:806:345::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Fri, 21 Apr 2023 11:51:15 +0000 Received: from IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::fb82:b2bf:60f9:45a1]) by IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::fb82:b2bf:60f9:45a1%6]) with mapi id 15.20.6319.022; Fri, 21 Apr 2023 11:51:15 +0000 From: "Attar, AbdulLateef (Abdul Lateef)" To: "Chang, Abner" , "devel@edk2.groups.io" CC: Isaac Oram , Nickle Wang , Igor Kulchytskyy Subject: Re: [edk2-platforms][PATCH V3 03/14] ManageabilityPkg: Add HeaderSize and TrailerSize Thread-Topic: [edk2-platforms][PATCH V3 03/14] ManageabilityPkg: Add HeaderSize and TrailerSize Thread-Index: AQHZdBFmU7OT0o0o5kKW28cBBCUss681pvGQ Date: Fri, 21 Apr 2023 11:51:15 +0000 Message-ID: References: <20230421052247.1520-1-abner.chang@amd.com> <20230421052247.1520-4-abner.chang@amd.com> In-Reply-To: <20230421052247.1520-4-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=7759e854-eb49-4bdc-a468-ce8ab6514b77;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-04-21T11:50:59Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: IA1PR12MB6458:EE_|SN7PR12MB7788:EE_ x-ms-office365-filtering-correlation-id: 1d7f8b04-48fa-474a-0c81-08db425eb622 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AA7rCVP6PwEMChIZU4Hv47Bl7tq6DsTYKVk+PTMbNyYFNIPjsMgN4m4HFGKv04EHIs+NmTtW4kMUGooyGkes2T5s3iaOBNLZGz+XukjoJ6ZPS3v4/rkY6j0ZTRBSYH8LqSGgxZCdaXbUS4AhwAK90Fpk/IlvdA324mdPHaiwFW3lwYxJvXYfb/8ksApjIf6pWIHKp9wz1TNp9fMTbMdB5A8n3FsywcBOg/rXh0jQDH4TRtNV0/HxfM/MpbNOE+MMnJv4DtCwHGoVEEO9BdiYdV3OPn+PwuuTBnKCgtA27saHeg6SCsiG8njtb6vZOgNE3aCG7j5YlvUiYBaMJ7dHRAc4kugVZUlQJybQ5s7PdVlOO03WBKPiw3LClIJopjTZu6tYqvnDC8GibOR/FNtaeKmr2WmMDBnh954kzUEQjaueQrxaXYZVzAwAkiMUT3gZRanqgMwb5+0PuBPvgj3VGqojQwVqLlzIb4MkckimODtQAfXtvXIume64fOuUfFea/yjvMge0g8HaBGQoJmxsrr8QnZS5v7ACxWHQiYueAStSkYrUauYL/ig2+Yfq/wVZ3HgKasLVbgEbPJZkbrkpdSDuXSb/AybZZ/mEPKEyKq97yHOaz1JFbBZT+Uve56Wi x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA1PR12MB6458.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(366004)(396003)(39860400002)(376002)(451199021)(30864003)(186003)(6506007)(26005)(71200400001)(53546011)(9686003)(7696005)(38100700002)(5660300002)(41300700001)(4326008)(52536014)(66476007)(76116006)(66446008)(66946007)(8676002)(8936002)(66556008)(110136005)(54906003)(478600001)(2906002)(316002)(38070700005)(64756008)(86362001)(83380400001)(122000001)(33656002)(55016003)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?clK8rMxgOn20h2TGfEnm1XO73f+3WkH5Oax1zlTtKhxTXFsKOGVE5gjdJ7Bp?= =?us-ascii?Q?tV3BYTdZwtkmF7FSma9wemRlGEluFvpZdqlBcxhKSZBsL7RehHktvmXqnvxf?= =?us-ascii?Q?R6zz+Wm9ezisYBwGw1BO5xYaRlRiGky2trD+RG4zdAwkOBKuA6Hp3UrBh/Nz?= =?us-ascii?Q?tjsKK+HCU7y22XyEDkClGHeHvr9I8rsVGhKWh4W7pFnyU4XlZctblVbVzXaE?= =?us-ascii?Q?5Cp6D3GuGSXMyEd1dpiaLFRfuCQwyw2a7kOaBn0Ru4J8mAPHh5ebf5jn3THq?= =?us-ascii?Q?EwLhuXqpII9KyhykdJGn/yja/5fyeCoFzImMOvFUXtqKbL+8iSe9bc9Vq+AK?= =?us-ascii?Q?/AXnhxLpl9uJN8H58Gfh0PhE88SwKQa6dMvfLAoWP7kP5Bf5GHz8nPaOG56G?= =?us-ascii?Q?4ep0X/kOfvuinw1fKKHZEdkDTlM9lFIVQyiUKrBLuhMmayVgz2fOZ24PnH2j?= =?us-ascii?Q?vKpIpxIvzr/djgyaKTscEE8v9tLxO4ZTbkSf6J8hurElcrI3Ar5QWfrNLTvF?= =?us-ascii?Q?geIjEJQQtFXVAQyCgsvYbR41cs/kTs9vyQwiGc26Li6sDoc//ao2XmTGKj4k?= =?us-ascii?Q?GieBt+Bgahe2g+mwK6sW6Yx+s9+WQQJhRb2UJkV6aPas4ocXHaOK0sSCxmxu?= =?us-ascii?Q?Uw40mp/1k+gaq72gtiOWO6/U/f/r0gjGbCsDcZlvVHf1I6dHDYBqxMSLJEM2?= =?us-ascii?Q?wczd7ZQwKwY1NCu6sggO9vEUvtsytAAvZlZtRifmh1axb3sNX0WKc1bxgKBm?= =?us-ascii?Q?R3SHpOrDG1T56S2RPkn+n1xLqFY5RQbGJ0LVdjD5CEOiq/NJ/sO7Aj01qNbX?= =?us-ascii?Q?CE/ahf7fVeOhNxca1u6dwsHIsWxCXy/c4HgXdfXEFGXr2UGa65pe9jWGsf9T?= =?us-ascii?Q?LIqV7OhEo8eli+hwEZuzcaw4mw8i7wfmQwHtb3uMer3AFBtEKBtrIv/zjWvK?= =?us-ascii?Q?UN+Vcmq50Gi9dToeFRbQKN8+PUKd1OQ0fIdkTPIyRwf332lUp+b5SnRT2+t3?= =?us-ascii?Q?e84/uEjPRpjBqQAZdti4pymPHzaXXHoF6m8ON92DGUwDqolwkE5myK/NyN8Y?= =?us-ascii?Q?15HP40XJCvA1058J3PCt+s3nCzFUl790l9x6R0zS184grlF7zKAsVVsWapby?= =?us-ascii?Q?KM0b5b/va5O7XpnWbGECUVLt5d3tpy+NwriNJu5TGq/8n4FRMc+Alersddcs?= =?us-ascii?Q?i1gfBoaDVcRznQm/zzdT8JRl1o1/1ndWkPEi0X362JBR07bd85k5gnYuRRuS?= =?us-ascii?Q?6/Sg9NIy1I5L+/U7ThzH17XekTOxNtrUTetPNg21w4b93OefIt7dWWJ/t+ID?= =?us-ascii?Q?+VB+6XyENoeFNA7DH0HvcU/5nVXO6nYw7UCp2po7pMcc6ikMH7TFhANwx4c/?= =?us-ascii?Q?pe723BrE+1Yx9JLMMFvJpwAPlU1U6pnyevhiQ/Dw1I39NkNcpdGgUB1NbXdI?= =?us-ascii?Q?NyM7Cgtcw5+sh2CsZqsn8MD5wczII0WnZ0RhG2n15bTufG+zQ1iCJyB96U10?= =?us-ascii?Q?X1KvWS/K7XaCbO2mvQb45fPommoq7yNt5EGn+8ghkKshHtR5whaMgc0j0U0N?= =?us-ascii?Q?buQZzNVFNz5ifzoe4Io=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: IA1PR12MB6458.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d7f8b04-48fa-474a-0c81-08db425eb622 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Apr 2023 11:51:15.2762 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 1NdHm2tHhESGMiTnNwNH2ufurOMZ+/vQBhTzifxBhmoMVi+/wZxeYx+/5Znn5dOi8CH/2huv17nP2apvrLHSQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7788 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abdul Lateef Attar -----Original Message----- From: Chang, Abner Sent: 21 April 2023 10:53 To: devel@edk2.groups.io Cc: Isaac Oram ; Attar, AbdulLateef (Abdul Lateef) = ; Nickle Wang ; Igor Kulchyt= skyy Subject: [edk2-platforms][PATCH V3 03/14] ManageabilityPkg: Add HeaderSize = and TrailerSize From: Abner Chang Add HeaderSize and TrailerSize in MANAGEABILITY_TRANSFER_TOKEN structure. Manageability transport interface may used by multiple protocols which have= different header and trailer of payload. (e.g. MCTP over KCS and IPMI over= KCS). Signed-off-by: Abner Chang Cc: Isaac Oram Cc: Abdul Lateef Attar Cc: Nickle Wang Cc: Igor Kulchytskyy Reviewed-by: Nickle Wang --- .../Library/ManageabilityTransportLib.h | 2 + .../Common/ManageabilityTransportKcs.h | 20 ++- .../IpmiProtocol/Common/IpmiProtocolCommon.h | 36 +++-- .../Common/KcsCommon.c | 152 ++++++++++++------ .../Dxe/ManageabilityTransportKcs.c | 14 +- .../IpmiProtocol/Common/IpmiProtocolCommon.c | 63 +++++--- Features/ManageabilityPkg/Readme.md | 10 ++ 7 files changed, 194 insertions(+), 103 deletions(-) diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTranspo= rtLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportL= ib.h index d86d0d87d5..04072aee89 100644 --- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h +++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLi +++ b.h @@ -168,10 +168,12 @@ struct _MANAGEABILITY_TRANSFER_TOKEN { = ///< which is sent discretely of payload. = ///< This field can be NULL if the transport = ///< doesn't require this. + UINT16 TransmitHeaderSize; = ///< Transmit header size in byte. MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer; = ///< This is the transport-specific trailer = ///< which is sent discretely of payload. = ///< This field can be NULL if the transport = ///< doesn't require this. + UINT16 TransmitTrailerSize; = ///< Transmit trailer size in byte. MANAGEABILITY_TRANSMIT_PACKAGE TransmitPackage; = ///< The payload sent to transport interface. MANAGEABILITY_RECEIVE_PACKAGE ReceivePackage; = ///< The buffer to receive the response. EFI_STATUS TransferStatus; = ///< The EFI Status of the transfer. diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib= /Common/ManageabilityTransportKcs.h b/Features/ManageabilityPkg/Library/Man= ageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h index 2cdf60ba7e..d6685c165e 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /ManageabilityTransportKcs.h +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Com +++ mon/ManageabilityTransportKcs.h @@ -41,8 +41,10 @@ typedef struct { /** This service communicates with BMC using KCS protocol. - @param[in] NetFunction Net function of the command. - @param[in] Command IPMI Command. + @param[in] TransmitHeader KCS packet header. + @param[in] TransmitHeaderSize KCS packet header size in byte. + @param[in] TransmitTrailer KCS packet trailer. + @param[in] TransmitTrailerSize KCS packet trailer size in byte. @param[in] RequestData Command Request Data. @param[in] RequestDataSize Size of Command Request Data. @param[out] ResponseData Command Response Data. The complet= ion @@ -69,12 +71,14 @@ typedef struct { EFI_STATUS EFIAPI KcsTransportSendCommand ( - IN UINT8 NetFunction, - IN UINT8 Command, - IN UINT8 *RequestData OPTIONAL, - IN UINT32 RequestDataSize, - OUT UINT8 *ResponseData OPTIONAL, - IN OUT UINT32 *ResponseDataSize OPTIONAL + IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader, + IN UINT16 TransmitHeaderSize, + IN MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer OPTIONAL, + IN UINT16 TransmitTrailerSize, + IN UINT8 *RequestData OPTIONAL, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData OPTIONAL, + IN OUT UINT32 *ResponseDataSize OPTIONAL ); /** diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiPr= otocolCommon.h b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/Ip= miProtocolCommon.h index 5a7236e9a6..8bf16e6277 100644 --- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC= ommon.h +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtoc +++ olCommon.h @@ -44,21 +44,23 @@ SetupIpmiTransportHardwareInformation ( This functions setup the final header/body/trailer packets for the acquired transport interface. - @param[in] TransportToken The transport interface. - @param[in] NetFunction IPMI function. - @param[in] Command IPMI command. - @param[out] PacketHeader The pointer to receive header of requ= est. - @param[in, out] PacketBody The request body. - When IN, it is the caller's request b= ody. - When OUT and NULL, the request body i= s not - changed. - Whee out and non-NULL, the request bo= dy is - changed to comfort the transport inte= rface. - @param[in, out] PacketBodySize The request body size. - When IN and non-zero, it is the new d= ata - length of request body. - When IN and zero, the request body is= unchanged. - @param[out] PacketTrailer The pointer to receive trailer of req= uest. + @param[in] TransportToken The transport interface. + @param[in] NetFunction IPMI function. + @param[in] Command IPMI command. + @param[out] PacketHeader The pointer to receive header of r= equest. + @param[out] PacketHeaderSize Pinter to receive packet header si= ze in byte. + @param[in, out] PacketBody The request body. + When IN, it is the caller's reques= t body. + When OUT and NULL, the request bod= y is not + changed. + Whee out and non-NULL, the request= body is + changed to comfort the transport i= nterface. + @param[in, out] PacketBodySize The request body size. + When IN and non-zero, it is the ne= w data + length of request body. + When IN and zero, the request body= is unchanged. + @param[out] PacketTrailer The pointer to receive trailer of = request. + @param[out] PacketTrailerSize Pinter to receive packet trailer s= ize in byte. @retval EFI_SUCCESS Request packet is returned. @retval EFI_UNSUPPORTED Request packet is not returned because @@ -70,9 +72,11 @@ SetupIpmiRequestTransportPacket ( IN UINT8 NetFunction, IN UINT8 Command, OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader OPTIONAL, + OUT UINT16 *PacketHeaderSize, IN OUT UINT8 **PacketBody OPTIONAL, IN OUT UINT32 *PacketBodySize OPTIONAL, - OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer OPTIONAL + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer OPTIONAL, + OUT UINT16 *PacketTrailerSize ); /** diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib= /Common/KcsCommon.c b/Features/ManageabilityPkg/Library/ManageabilityTransp= ortKcsLib/Common/KcsCommon.c index 17e2b8f231..14a7047447 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common= /KcsCommon.c +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Com +++ mon/KcsCommon.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -98,8 +99,10 @@ ClearOBF ( Algorithm is based on flow chart provided in IPMI spec 2.0 Figure 9-6, KCS Interface BMC to SMS Write Transfer Flow Chart - @param[in] NetFunction Net function of the command. - @param[in] Command IPMI Command. + @param[in] TransmitHeader KCS packet header. + @param[in] TransmitHeaderSize KCS packet header size in byte. + @param[in] TransmitTrailer KCS packet trailer. + @param[in] TransmitTrailerSize KCS packet trailer size in byte. @param[in] RequestData Command Request Data, could be NULL. RequestDataSize must be zero, if Reque= stData is NULL. @@ -122,10 +125,12 @@ ClearOBF ( **/ EFI_STATUS KcsTransportWrite ( - IN UINT8 NetFunction, - IN UINT8 Command, - IN UINT8 *RequestData OPTIONAL, - IN UINT32 RequestDataSize + IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader, + IN UINT16 TransmitHeaderSize, + IN MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer OPTIONAL, + IN UINT16 TransmitTrailerSize, + IN UINT8 *RequestData OPTIONAL, + IN UINT32 RequestDataSize ) { EFI_STATUS Status; @@ -134,37 +139,63 @@ KcsTransportWrite ( UINT8 *BufferPtr; // Validation on RequestData and RequestDataSize. - if ((RequestData =3D=3D NULL && RequestDataSize !=3D 0) || - (RequestData !=3D NULL && RequestDataSize =3D=3D 0) - ) { + if (((RequestData =3D=3D NULL) && (RequestDataSize !=3D 0)) || + ((RequestData !=3D NULL) && (RequestDataSize =3D=3D 0)) + ) + { DEBUG ((DEBUG_ERROR, "%a: Mismatched values of RequestData or RequestD= ataSize.\n", __FUNCTION__)); return EFI_INVALID_PARAMETER; } - Length =3D sizeof (NetFunction) + sizeof (Command); + // Validation on TransmitHeader and TransmitHeaderSize. + if (((TransmitHeader =3D=3D NULL) && (TransmitHeaderSize !=3D 0)) || + ((TransmitHeader !=3D NULL) && (TransmitHeaderSize =3D=3D 0)) + ) + { + DEBUG ((DEBUG_ERROR, "%a: Mismatched values of TransmitHeader or Trans= mitHeaderSize.\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + // Validation on TransmitHeader and TransmitHeaderSize. + if (((TransmitTrailer =3D=3D NULL) && (TransmitTrailerSize !=3D 0)) || + ((TransmitTrailer !=3D NULL) && (TransmitTrailerSize =3D=3D 0)) + ) + { + DEBUG ((DEBUG_ERROR, "%a: Mismatched values of TransmitTrailer or Tran= smitTrailerSize.\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + Length =3D TransmitHeaderSize; if (RequestData !=3D NULL) { Length =3D Length + RequestDataSize; } + if ((TransmitTrailer !=3D NULL) && (TransmitTrailerSize !=3D 0)) { + Length +=3D TransmitTrailerSize; + } + Buffer =3D AllocateZeroPool (Length); if (Buffer =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } // - // Buffer[0] =3D NetFunction - // Buffer[1] =3D Command - // Buffer [2..RequestDataSize] =3D RequestData + // Buffer[0..(TransmitHeaderSize - 1)] =3D TransmitHeader // Buffer + [TransmitHeader..(TransmitHeader + RequestDataSize - 1)] =3D RequestData + // Buffer [(TransmitHeader + RequestDataSize)..(TransmitHeader + + RequestDataSize + TransmitTrailerSize - 1)] =3D TransmitTrailer // BufferPtr =3D Buffer; - CopyMem (BufferPtr, &NetFunction, sizeof (NetFunction)); - BufferPtr +=3D sizeof (NetFunction); - CopyMem (BufferPtr, &Command, sizeof (Command)); - BufferPtr +=3D sizeof (Command); - if (Length > (sizeof (NetFunction) + sizeof (Command))) { + CopyMem ((VOID *)BufferPtr, (VOID *)TransmitHeader, + TransmitHeaderSize); BufferPtr +=3D TransmitHeaderSize; if + (RequestData !=3D NULL) { CopyMem (BufferPtr, RequestData, RequestDataSize); } + BufferPtr +=3D RequestDataSize; + if (TransmitTrailer !=3D NULL) { + CopyMem (BufferPtr, (VOID *)TransmitTrailer, TransmitTrailerSize); + } + BufferPtr =3D Buffer; // Step 1. wait for IBF to get clear @@ -293,10 +324,11 @@ KcsTransportRead ( EFI_STATUS Status; UINT32 ReadLength; - if (DataByte =3D=3D NULL || *Length =3D=3D 0) { + if ((DataByte =3D=3D NULL) || (*Length =3D=3D 0)) { DEBUG ((DEBUG_ERROR, "%a: Either DataByte is NULL or Length is 0.\n", = __FUNCTION__)); return EFI_INVALID_PARAMETER; } + ReadLength =3D 0; while (ReadLength < *Length) { // Step 1. wait for IBF to get clear @@ -350,8 +382,10 @@ KcsTransport= Read ( /** This service communicates with BMC using KCS protocol. - @param[in] NetFunction Net function of the command. - @param[in] Command IPMI Command. + @param[in] TransmitHeader KCS packet header. + @param[in] TransmitHeaderSize KCS packet header size in byte. + @param[in] TransmitTrailer KCS packet trailer. + @param[in] TransmitTrailerSize KCS packet trailer size in byte. @param[in] RequestData Command Request Data. @param[in] RequestDataSize Size of Command Request Data. @param[out] ResponseData Command Response Data. The complet= ion @@ -380,12 +414,14 @@ KcsTransportRead ( EFI_STATUS EFIAPI KcsTransportS= endCommand ( - IN UINT8 NetFunction, - IN UINT8 Command, - IN UINT8 *RequestData OPTIONAL, - IN UINT32 RequestDataSize, - OUT UINT8 *ResponseData OPTIONAL, - IN OUT UINT32 *ResponseDataSize OPTIONAL + IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader, + IN UINT16 TransmitHeaderSize, + IN MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer OPTIONAL, + IN UINT16 TransmitTrailerSize, + IN UINT8 *RequestData OPTIONAL, + IN UINT32 RequestDataSize, + OUT UINT8 *ResponseData OPTIONAL, + IN OUT UINT32 *ResponseDataSize OPTIONAL ) { EFI_STATUS Status; @@ -393,30 +429,41 @@ KcsTransportSendCommand ( IPMI_KCS_RESPONSE_HEADER RspHeader; if ((RequestData !=3D NULL) && (RequestDataSize =3D=3D 0)) { - DEBUG((DEBUG_ERROR, "%a: Mismatched values of RequestData and RequestD= ataSize\n", __FUNCTION__)); + DEBUG ((DEBUG_ERROR, "%a: Mismatched values of RequestData and + RequestDataSize\n", __FUNCTION__)); return EFI_INVALID_PARAMETER; } if ((ResponseData !=3D NULL) && ((ResponseDataSize !=3D NULL) && (*Respo= nseDataSize =3D=3D 0))) { - DEBUG((DEBUG_ERROR, "%a: Mismatched values of ResponseData and Respons= eDataSize\n", __FUNCTION__)); + DEBUG ((DEBUG_ERROR, "%a: Mismatched values of ResponseData and Respon= seDataSize\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + if (TransmitHeader =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: TransmitHeader is NULL\n", + __FUNCTION__)); return EFI_INVALID_PARAMETER; } + // + // Print out the request payloads. + HelperManageabilityDebugPrint ((VOID *)TransmitHeader, + TransmitHeaderSize, "KCS Transmit Header:\n"); if (RequestData !=3D NULL= ) { + HelperManageabilityDebugPrint ((VOID *)RequestData, + RequestDataSize, "KCS Request Data:\n"); } + + if (TransmitTrailer !=3D NULL) { + HelperManageabilityDebugPrint ((VOID *)TransmitTrailer, + TransmitTrailerSize, "KCS Transmit Trailer:\n"); } + Status =3D KcsTransportWrite ( - (NetFunction << 2), - Command, + TransmitHeader, + TransmitHeaderSize, + TransmitTrailer, + TransmitTrailerSize, RequestData, RequestDataSize ); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "IPMI KCS Write Failed with Status(%r) for NetFunction(0x%x)," \ - " Command(0x%x).\n", - Status, - NetFunction, - Command - )); + DEBUG ((DEBUG_ERROR, "IPMI KCS Write Failed with Status(%r)", + Status)); return Status; } @@ -429,7 +476,7 @@ KcsTransportSendCommand ( DEBUG_ERROR, "IPMI KCS read response header failed Status(%r), " \ "RspNetFunctionLun =3D 0x%x, " \ - "Comamnd =3D 0x%x \n", + "Command =3D 0x%x \n", Status, RspHeader.NetFunc, RspHeader.Command @@ -437,16 +484,21 @@ KcsTransportSendCommand ( return (Status); } - Status =3D KcsTransportRead ((UINT8 *)ResponseData, ResponseDataSize); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "IPMI KCS response read Failed with Status(%r) for NetFunction(0x%x)= ," \ - " Command(0x%x).\n", - Status, - NetFunction, - Command - )); + // + // Print out the response payloads. + HelperManageabilityDebugPrint ((VOID *)&RspHeader, + (UINT16)RspHeaderSize, "KCS Response Header:\n"); + + if ((ResponseData !=3D NULL) && (ResponseDataSize !=3D NULL) && (*Respon= seDataSize !=3D 0)) { + Status =3D KcsTransportRead ((UINT8 *)ResponseData, ResponseDataSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "IPMI KCS response read Failed with Status(%r)"= , Status)); + } + + // + // Print out the response payloads. + HelperManageabilityDebugPrint ((VOID *)ResponseData, + *ResponseDataSize, "KCS Response Data:\n"); } else { + *ResponseDataSize =3D 0; } return Status; diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib= /Dxe/ManageabilityTransportKcs.c b/Features/ManageabilityPkg/Library/Manage= abilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c index 7d85378fc1..c236354605 100644 --- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/Ma= nageabilityTransportKcs.c +++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe +++ /ManageabilityTransportKcs.c @@ -218,23 +218,25 @@ KcsTransportTransmitReceive ( IN MANAGEABILITY_TRANSFER_TOKEN *TransferToken ) { - EFI_STATUS Status; - MANAGEABILITY_IPMI_TRANSPORT_HEADER *TransmitHeader; + EFI_STATUS Status; if ((TransportToken =3D=3D NULL) || (TransferToken =3D=3D NULL)) { DEBUG ((DEBUG_ERROR, "%a: Invalid transport token or transfer token.\n= ", __FUNCTION__)); return; } - TransmitHeader =3D (MANAGEABILITY_IPMI_TRANSPORT_HEADER *)TransferToken-= >TransmitHeader; - if (TransmitHeader =3D=3D NULL) { + // Transmit header is necessary for KCS transport, which could be // + NetFn, Command and etc. + if (TransferToken->TransmitHeader =3D=3D NULL) { TransferToken->TransferStatus =3D EFI_INVALID_PARAMETER; return; } Status =3D KcsTransportSendCommand ( - TransmitHeader->NetFn, - TransmitHeader->Command, + TransferToken->TransmitHeader, + TransferToken->TransmitHeaderSize, + TransferToken->TransmitTrailer, + TransferToken->TransmitTrailerSize, TransferToken->TransmitPackage.TransmitPayload, TransferToken->TransmitPackage.TransmitSizeInByte, TransferToken->ReceivePackage.ReceiveBuffer, diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/Ip= miProtocolCommon.c index 82bae58292..b055bad7da 100644 --- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Common/IpmiProtoc +++ olCommon.c @@ -65,21 +65,23 @@ SetupIpmiTransportHardwareInformation ( This functions setup the final header/body/trailer packets for the acquired transport interface. - @param[in] TransportToken The transport interface. - @param[in] NetFunction IPMI function. - @param[in] Command IPMI command. - @param[out] PacketHeader The pointer to receive header of requ= est. - @param[in, out] PacketBody The request body. - When IN, it is the caller's request b= ody. - When OUT and NULL, the request body i= s not - changed. - When OUT and non-NULL, the request bo= dy is - changed to conform the transport inte= rface. - @param[in, out] PacketBodySize The request body size. - When OUT and non-zero, it is the new = data - length of request body. - When OUT and zero, the request body i= s unchanged. - @param[out] PacketTrailer The pointer to receive trailer of req= uest. + @param[in] TransportToken The transport interface. + @param[in] NetFunction IPMI function. + @param[in] Command IPMI command. + @param[out] PacketHeader The pointer to receive header of r= equest. + @param[out] PacketHeaderSize Pinter to receive packet header si= ze in byte. + @param[in, out] PacketBody The request body. + When IN, it is the caller's reques= t body. + When OUT and NULL, the request bod= y is not + changed. + Whee out and non-NULL, the request= body is + changed to comfort the transport i= nterface. + @param[in, out] PacketBodySize The request body size. + When IN and non-zero, it is the ne= w data + length of request body. + When IN and zero, the request body= is unchanged. + @param[out] PacketTrailer The pointer to receive trailer of = request. + @param[out] PacketTrailerSize Pinter to receive packet trailer s= ize in byte. @retval EFI_SUCCESS Request packet is returned. @retval EFI_UNSUPPORTED Request packet is not returned because @@ -91,9 +93,11 @@ SetupIpmiRequestTransportPacket ( IN UINT8 NetFunction, IN UINT8 Command, OUT MANAGEABILITY_TRANSPORT_HEADER *PacketHeader OPTIONAL, + OUT UINT16 *PacketHeaderSize, IN OUT UINT8 **PacketBody OPTIONAL, IN OUT UINT32 *PacketBodySize OPTIONAL, - OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer OPTIONAL + OUT MANAGEABILITY_TRANSPORT_TRAILER *PacketTrailer OPTIONAL, + OUT UINT16 *PacketTrailerSize ) { MANAGEABILITY_IPMI_TRANSPORT_HEADER *IpmiHeader; @@ -105,18 +109,24 @@ = SetupIpmiRequestTransportPacket ( return EFI_OUT_OF_RESOURCES; } + *PacketHeaderSize =3D 0; + *PacketTrailerSize =3D 0; IpmiHeader->Command =3D Command; IpmiHeader->Lun =3D 0; IpmiHeader->NetFn =3D NetFunction; if (PacketHeader !=3D NULL) { - *PacketHeader =3D (MANAGEABILITY_TRANSPORT_HEADER *)IpmiHeader; + *PacketHeader =3D (MANAGEABILITY_TRANSPORT_HEADER *)IpmiHeader; + *PacketHeaderSize =3D sizeof (MANAGEABILITY_IPMI_TRANSPORT_HEADER); } + if (PacketTrailer !=3D NULL) { *PacketTrailer =3D NULL; } + if (PacketBody !=3D NULL) { *PacketBody =3D NULL; } + if (PacketBodySize !=3D NULL) { *PacketBodySize =3D 0; } @@ -124,6 +134,7 @@ SetupIpmiRequestTransportPacket ( DEBUG ((DEBUG_ERROR, "%a: No implementation of building up packet.", _= _FUNCTION__)); ASSERT (FALSE); } + return EFI_SUCCESS; } @@ -164,6 +175,8 @@ CommonIpmiSubmitCommand ( MANAGEABILITY_TRANSPORT_HEADER IpmiTransportHeader; MANAGEABILITY_TRANSPORT_TRAILER IpmiTransportTrailer; MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS TransportAdditionalStatus; + UINT16 HeaderSize; + UINT16 TrailerSize; if (TransportToken =3D=3D NULL) { DEBUG ((DEBUG_ERROR, "%a: No transport toke for IPMI\n", __FUNCTION__)= ); @@ -179,8 +192,8 @@ CommonIpmiSubmitCommand ( return Status; } - ThisRequestData =3D RequestData; - ThisRequestDataSize =3D RequestDataSize; + ThisRequestData =3D RequestData; + ThisRequestDataSize =3D RequestDataSize; IpmiTransportHeader =3D NULL; IpmiTransportTrailer =3D NULL; Status =3D SetupIpmiRequestTransportPacket ( @@ -188,9 +201,11 @@ CommonIpmiSubmitCommand ( NetFunction, Command, &IpmiTransportHeader, + &HeaderSize, &ThisRequestData, &ThisRequestDataSize, - &IpmiTransportTrailer + &IpmiTransportTrailer, + &TrailerSize ); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Fail to build packets - (%r)\n", __FUNCTION_= _, Status)); @@ -198,12 +213,13 @@ CommonIpmiSubmitCommand ( } ZeroMem (&TransferToken, sizeof (MANAGEABILITY_TRANSFER_TOKEN)); - TransferToken.TransmitHeader =3D IpmiTransportHeader; - TransferToken.TransmitTrailer =3D IpmiTransportTrailer; + TransferToken.TransmitHeader =3D IpmiTransportHeader; + TransferToken.TransmitHeaderSize =3D HeaderSize; + TransferToken.TransmitTrailer =3D IpmiTransportTrailer; + TransferToken.TransmitTrailerSize =3D TrailerSize; // Transmit packet. if ((ThisRequestData =3D=3D NULL) || (ThisRequestDataSize =3D=3D 0)) { - // Transmit parameter were not changed by SetupIpmiRequestTransportPac= ket(). TransferToken.TransmitPackage.TransmitPayload =3D RequestData; TransferToken.TransmitPackage.TransmitSizeInByte =3D RequestDataSize; = @@ -247,5 +263,6 @@ CommonIpmiSubmitCommand ( if (ResponseDataSize !=3D NULL) { *ResponseDataSize =3D TransferToken.ReceivePackage.ReceiveSizeInByte; } + return Status; } diff --git a/Features/ManageabilityPkg/Readme.md b/Features/ManageabilityPk= g/Readme.md index 2ecee96313..81c9322b98 100644 --- a/Features/ManageabilityPkg/Readme.md +++ b/Features/ManageabilityPkg/Readme.md @@ -99,7 +99,9 @@ library to compliant with the framework of ManageabilityP= kg design. struct _MANAGEABILITY_TRANSFER_TOKEN { EFI_EVENT ReceiveEvent; MANAGEABILITY_TRANSPORT_HEADER TransmitHeader; + UINT16 TransmitHeaderSize; MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer; + UINT16 TransmitTrailerSize; MANAGEABILITY_TRANSMIT_PACKAGE TransmitPackage; MANAGEABILITY_RECEIVE_PACKAGE ReceivePackage; EFI_STATUS TransferStatus; @@ -124,6 +126,10 @@ library to compliant with the framework of Manageabili= tyPkg design. manageability transport library to make the transport implementation a= gnostic to the manageability protocol specification. +* ***TransmitHeaderSize*** + + This indicates the size of TransmitHeader. + * ***TransmitTrailer*** The transmit trailer may be different according to the disparate trans= port @@ -131,6 +137,10 @@ library to compliant with the framework of Manage= abilityPkg design. manageability transport library to make the transport implementation a= gnostic to the manageability protocol specification. +* ***TransmitTrailerSize*** + + This indicates the size of TransmitTrailer. + * ***TransmitPackage*** The buffer of packet to transmit, this could be a value of NULL if the= manageability -- 2.37.1.windows.1