public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Konstantin Aladyshev" <aladyshev22@gmail.com>
To: devel@edk2.groups.io
Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com,
	nicklew@nvidia.com, Konstantin Aladyshev <aladyshev22@gmail.com>
Subject: [edk2-devel] [PATCH edk2-platforms v3 01/16] ManageabilityPkg: Add definition for the MCTP KCS TRAILER structure
Date: Mon, 23 Oct 2023 16:04:56 +0300	[thread overview]
Message-ID: <20231023130511.4521-2-aladyshev22@gmail.com> (raw)
In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com>

Currently there is only a definition for the MCTP KCS HEADER structure.
Add definition for the MCTP KCS TRAILER structure as well.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
 .../Library/ManageabilityTransportMctpLib.h        |  5 +++++
 .../MctpProtocol/Common/MctpProtocolCommon.c       | 14 +++++++-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpLib.h
index 43bd142f4c..462e7436e6 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportMctpLib.h
@@ -39,6 +39,11 @@ typedef struct {
   UINT8    DefiningBody; ///< Message type.
   UINT8    ByteCount;    ///< Byte count of payload.
 } MANAGEABILITY_MCTP_KCS_HEADER;
+
+typedef struct {
+  UINT8    Pec;  ///< MCTP over KCS Packet Error Code.
+} MANAGEABILITY_MCTP_KCS_TRAILER;
+
 #define MCTP_KCS_NETFN_LUN                       0xb0
 #define DEFINING_BODY_DMTF_PRE_OS_WORKING_GROUP  0x01
 
diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
index 1ad48efdc7..7576007f77 100644
--- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
+++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
@@ -132,7 +132,7 @@ SetupMctpRequestTransportPacket (
   MANAGEABILITY_MCTP_KCS_HEADER  *MctpKcsHeader;
   MCTP_TRANSPORT_HEADER          *MctpTransportHeader;
   MCTP_MESSAGE_HEADER            *MctpMessageHeader;
-  UINT8                          *Pec;
+  MANAGEABILITY_MCTP_KCS_TRAILER *MctpKcsTrailer;
   UINT8                          *ThisPackage;
 
   if ((PacketHeader == NULL) || (PacketHeaderSize == NULL) ||
@@ -151,8 +151,8 @@ SetupMctpRequestTransportPacket (
       return EFI_OUT_OF_RESOURCES;
     }
 
-    Pec = (UINT8 *)AllocateZeroPool (sizeof (UINT8));
-    if (Pec == NULL) {
+    MctpKcsTrailer = (MANAGEABILITY_MCTP_KCS_TRAILER *)AllocateZeroPool (sizeof (MANAGEABILITY_MCTP_KCS_TRAILER));
+    if (MctpKcsTrailer == NULL) {
       DEBUG ((DEBUG_ERROR, "%a: Not enough resource for PEC.\n", __func__));
       FreePool (MctpKcsHeader);
       return EFI_OUT_OF_RESOURCES;
@@ -167,7 +167,7 @@ SetupMctpRequestTransportPacket (
     if (ThisPackage == NULL) {
       DEBUG ((DEBUG_ERROR, "%a: Not enough resource for package.\n", __func__));
       FreePool (MctpKcsHeader);
-      FreePool (Pec);
+      FreePool (MctpKcsTrailer);
       return EFI_OUT_OF_RESOURCES;
     }
 
@@ -193,14 +193,14 @@ SetupMctpRequestTransportPacket (
 
     //
     // Generate PEC follow SMBUS 2.0 specification.
-    *Pec = HelperManageabilityGenerateCrc8 (MCTP_KCS_PACKET_ERROR_CODE_POLY, 0, ThisPackage, MctpKcsHeader->ByteCount);
+    MctpKcsTrailer->Pec = HelperManageabilityGenerateCrc8 (MCTP_KCS_PACKET_ERROR_CODE_POLY, 0, ThisPackage, MctpKcsHeader->ByteCount);
 
     *PacketBody        = (UINT8 *)ThisPackage;
     *PacketBodySize    = MctpKcsHeader->ByteCount;
-    *PacketTrailer     = (MANAGEABILITY_TRANSPORT_TRAILER)Pec;
+    *PacketTrailer     = (MANAGEABILITY_TRANSPORT_TRAILER)MctpKcsTrailer;
     *PacketHeader      = (MANAGEABILITY_TRANSPORT_HEADER)MctpKcsHeader;
     *PacketHeaderSize  = sizeof (MANAGEABILITY_MCTP_KCS_HEADER);
-    *PacketTrailerSize = 1;
+    *PacketTrailerSize = sizeof (MANAGEABILITY_MCTP_KCS_TRAILER);
     return EFI_SUCCESS;
   } else {
     DEBUG ((DEBUG_ERROR, "%a: No implementation of building up packet.", __func__));
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109909): https://edk2.groups.io/g/devel/message/109909
Mute This Topic: https://groups.io/mt/102134647/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-10-23 13:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 13:04 [edk2-devel] [PATCH edk2-platforms v3 00/16] MTCP-over-KCS support Konstantin Aladyshev
2023-10-23 13:04 ` Konstantin Aladyshev [this message]
2023-10-25  8:55   ` [edk2-devel] [PATCH edk2-platforms v3 01/16] ManageabilityPkg: Add definition for the MCTP KCS TRAILER structure Attar, AbdulLateef (Abdul Lateef) via groups.io
2023-10-23 13:04 ` [edk2-devel] [PATCH edk2-platforms v3 02/16] ManageabilityPkg: Check MCTP EIDs for reserved values Konstantin Aladyshev
2023-10-25  8:57   ` Attar, AbdulLateef (Abdul Lateef) via groups.io
2023-10-23 13:04 ` [edk2-devel] [PATCH edk2-platforms v3 03/16] ManageabilityPkg: Support both MCTP and IPMI in KCS tranport library Konstantin Aladyshev
2023-10-23 13:04 ` [edk2-devel] [PATCH edk2-platforms v3 04/16] ManageabilityPkg: Check header fields in the MCTP response Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 05/16] ManageabilityPkg: Correct typo in MCTP destination EID field Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 06/16] ManageabilityPkg: Update the algorithm of using MCTP endpoint ID PCD Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 07/16] ManageabilityPkg: Correct value for the MCTP TAG_OWNER response bit Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 08/16] ManageabilityPkg: Don't check MCTP header fields if transfer has failed Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 09/16] ManageabilityPkg: Use correct constants for PLDM header checks Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 10/16] ManageabilityPkg: Return error on multiple-packet MCTP responses Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 11/16] ManageabilityPkg: Add PLDM terminus PCDs Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 12/16] PldmProtocolDxe: Correct TID argument usage Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 13/16] ManageabilityPkg/PldmProtocol: Remove PLDM command table Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 14/16] ManageabilityPkg: Return error on PLDM header check fails Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 15/16] PldmSmbiosTransferDxe: Implement Set PLDM terminus ID API Konstantin Aladyshev
2023-10-23 13:05 ` [edk2-devel] [PATCH edk2-platforms v3 16/16] ManageabilityPkg: Check PLDM completion code Konstantin Aladyshev
2023-10-24  2:44 ` [edk2-devel] [PATCH edk2-platforms v3 00/16] MTCP-over-KCS support Chang, Abner via groups.io
2023-10-26  5:03   ` Chang, Abner via groups.io
2023-10-31  6:37     ` Yoshinoya
2023-10-31  7:00       ` Chang, Abner via groups.io
2023-11-01  5:19         ` Yoshinoya
2023-11-01  5:53           ` Chang, Abner via groups.io

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231023130511.4521-2-aladyshev22@gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox