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, isaac.w.oram@intel.com,
	AbdulLateef.Attar@amd.com, nicklew@nvidia.com,
	Konstantin Aladyshev <aladyshev22@gmail.com>
Subject: [edk2-devel] [PATCH edk2-platforms 06/10] ManageabilityPkg: Update the algorithm of using MCTP endpoint ID PCD
Date: Mon, 16 Oct 2023 16:18:12 +0300	[thread overview]
Message-ID: <20231016131816.6634-7-aladyshev22@gmail.com> (raw)
In-Reply-To: <20231016131816.6634-1-aladyshev22@gmail.com>

Although MtcpSubmit function receives source and destination MCTP EID
arguments these value are not used in any way currently. Instead the
code always uses EID values from the PCDs.
To correct this issue modify function interface to receive source and
destination MCTP EIDs via pointers and use PCD values only if the
pointers are NULL.

Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
 .../Include/Protocol/MctpProtocol.h           | 12 ++++--
 .../Dxe/ManageabilityTransportMctp.c          |  4 +-
 .../MctpProtocol/Common/MctpProtocolCommon.c  |  4 +-
 .../Universal/MctpProtocol/Dxe/MctpProtocol.c | 42 ++++++++++++++-----
 4 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h b/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h
index 85e42f157d..c96b986c44 100644
--- a/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h
+++ b/Features/ManageabilityPkg/Include/Protocol/MctpProtocol.h
@@ -28,8 +28,12 @@ typedef struct  _EDKII_MCTP_PROTOCOL EDKII_MCTP_PROTOCOL;
 
   @param[in]         This                       EDKII_MCTP_PROTOCOL instance.
   @param[in]         MctpType                   MCTP message type.
-  @param[in]         MctpSourceEndpointId       MCTP source endpoint ID.
-  @param[in]         MctpDestinationEndpointId  MCTP source endpoint ID.
+  @param[in]         MctpSourceEndpointId       Pointer of MCTP source endpoint ID.
+                                                Set to NULL means use platform PCD value
+                                                (PcdMctpSourceEndpointId).
+  @param[in]         MctpDestinationEndpointId  Pointer of MCTP destination endpoint ID.
+                                                Set to NULL means use platform PCD value
+                                                (PcdMctpDestinationEndpointId).
   @param[in]         RequestDataIntegrityCheck  Indicates whether MCTP message has
                                                 integrity check byte.
   @param[in]         RequestData                Message Data.
@@ -58,8 +62,8 @@ EFI_STATUS
 (EFIAPI *MCTP_SUBMIT_COMMAND)(
   IN     EDKII_MCTP_PROTOCOL  *This,
   IN     UINT8                MctpType,
-  IN     UINT8                MctpSourceEndpointId,
-  IN     UINT8                MctpDestinationEndpointId,
+  IN     UINT8                *MctpSourceEndpointId,
+  IN     UINT8                *MctpDestinationEndpointId,
   IN     BOOLEAN              RequestDataIntegrityCheck,
   IN     UINT8                *RequestData,
   IN     UINT32               RequestDataSize,
diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/ManageabilityTransportMctp.c b/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/ManageabilityTransportMctp.c
index c520e2302d..249104c873 100644
--- a/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/ManageabilityTransportMctp.c
+++ b/Features/ManageabilityPkg/Library/ManageabilityTransportMctpLib/Dxe/ManageabilityTransportMctp.c
@@ -205,8 +205,8 @@ MctpTransportTransmitReceive (
   Status = mMctpProtocol->Functions.Version1_0->MctpSubmitCommand (
                                                   mMctpProtocol,
                                                   TransmitHeader->MessageHeader.MessageType,
-                                                  TransmitHeader->SourceEndpointId,
-                                                  TransmitHeader->DestinationEndpointId,
+                                                  &TransmitHeader->SourceEndpointId,
+                                                  &TransmitHeader->DestinationEndpointId,
                                                   (BOOLEAN)TransmitHeader->MessageHeader.IntegrityCheck,
                                                   TransferToken->TransmitPackage.TransmitPayload,
                                                   TransferToken->TransmitPackage.TransmitSizeInByte,
diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
index 5844d54eb2..3128aadd15 100644
--- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
+++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
@@ -175,8 +175,8 @@ SetupMctpRequestTransportPacket (
     MctpTransportHeader                             = (MCTP_TRANSPORT_HEADER *)ThisPackage;
     MctpTransportHeader->Bits.Reserved              = 0;
     MctpTransportHeader->Bits.HeaderVersion         = MCTP_KCS_HEADER_VERSION;
-    MctpTransportHeader->Bits.DestinationEndpointId = PcdGet8 (PcdMctpDestinationEndpointId);
-    MctpTransportHeader->Bits.SourceEndpointIdId    = PcdGet8 (PcdMctpSourceEndpointId);
+    MctpTransportHeader->Bits.DestinationEndpointId = MctpDestinationEndpointId;
+    MctpTransportHeader->Bits.SourceEndpointId      = MctpSourceEndpointId;
     MctpTransportHeader->Bits.MessageTag            = MCTP_MESSAGE_TAG;
     MctpTransportHeader->Bits.TagOwner              = MCTP_MESSAGE_TAG_OWNER_REQUEST;
     MctpTransportHeader->Bits.PacketSequence        = mMctpPacketSequence & MCTP_PACKET_SEQUENCE_MASK;
diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c
index d0f49a1abb..73445bf816 100644
--- a/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c
+++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocol.c
@@ -29,8 +29,12 @@ UINT32                         mTransportMaximumPayload;
 
   @param[in]         This                       EDKII_MCTP_PROTOCOL instance.
   @param[in]         MctpType                   MCTP message type.
-  @param[in]         MctpSourceEndpointId       MCTP source endpoint ID.
-  @param[in]         MctpDestinationEndpointId  MCTP source endpoint ID.
+  @param[in]         MctpSourceEndpointId       Pointer of MCTP source endpoint ID.
+                                                Set to NULL means use platform PCD value
+                                                (PcdMctpSourceEndpointId).
+  @param[in]         MctpDestinationEndpointId  Pointer of MCTP destination endpoint ID.
+                                                Set to NULL means use platform PCD value
+                                                (PcdMctpDestinationEndpointId).
   @param[in]         RequestDataIntegrityCheck  Indicates whether MCTP message has
                                                 integrity check byte.
   @param[in]         RequestData                Message Data.
@@ -59,8 +63,8 @@ EFIAPI
 MctpSubmitMessage (
   IN     EDKII_MCTP_PROTOCOL                        *This,
   IN     UINT8                                      MctpType,
-  IN     UINT8                                      MctpSourceEndpointId,
-  IN     UINT8                                      MctpDestinationEndpointId,
+  IN     UINT8                                      *MctpSourceEndpointId,
+  IN     UINT8                                      *MctpDestinationEndpointId,
   IN     BOOLEAN                                    RequestDataIntegrityCheck,
   IN     UINT8                                      *RequestData,
   IN     UINT32                                     RequestDataSize,
@@ -72,24 +76,42 @@ MctpSubmitMessage (
   )
 {
   EFI_STATUS  Status;
+  UINT8       SourceEid;
+  UINT8       DestinationEid;
 
   if ((RequestData == NULL) && (ResponseData == NULL)) {
     DEBUG ((DEBUG_ERROR, "%a: Both RequestData and ResponseData are NULL\n", __func__));
     return EFI_INVALID_PARAMETER;
   }
 
+  if (MctpSourceEndpointId == NULL) {
+    SourceEid = PcdGet8 (PcdMctpSourceEndpointId);
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: Use PcdMctpSourceEndpointId for MCTP source EID: %x\n", __func__, SourceEid));
+  } else {
+    SourceEid = *MctpSourceEndpointId;
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: MCTP source EID: %x\n", __func__, SourceEid));
+  }
+
+  if (MctpDestinationEndpointId == NULL) {
+    DestinationEid = PcdGet8 (PcdMctpDestinationEndpointId);
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: Use PcdMctpDestinationEndpointId for MCTP destination EID: %x\n", __func__, DestinationEid));
+  } else {
+    DestinationEid = *MctpDestinationEndpointId;
+    DEBUG ((DEBUG_MANAGEABILITY, "%a: MCTP destination EID: %x\n", __func__, DestinationEid));
+  }
+
   //
   // Check source EID and destination EID
   //
-  if ((MctpSourceEndpointId >= MCTP_RESERVED_ENDPOINT_START_ID) &&
-      (MctpSourceEndpointId <= MCTP_RESERVED_ENDPOINT_END_ID)
+  if ((SourceEid >= MCTP_RESERVED_ENDPOINT_START_ID) &&
+      (SourceEid <= MCTP_RESERVED_ENDPOINT_END_ID)
       ) {
     DEBUG ((DEBUG_ERROR, "%a: The value of MCTP source EID (%x) is reserved.\n", __func__, MctpSourceEndpointId));
     return EFI_INVALID_PARAMETER;
   }
 
-  if ((MctpDestinationEndpointId >= MCTP_RESERVED_ENDPOINT_START_ID) &&
-      (MctpDestinationEndpointId <= MCTP_RESERVED_ENDPOINT_END_ID)
+  if ((DestinationEid >= MCTP_RESERVED_ENDPOINT_START_ID) &&
+      (DestinationEid <= MCTP_RESERVED_ENDPOINT_END_ID)
       ) {
     DEBUG ((DEBUG_ERROR, "%a: The value of MCTP destination EID (%x) is reserved.\n", __func__, MctpDestinationEndpointId));
     return EFI_INVALID_PARAMETER;
@@ -98,8 +120,8 @@ MctpSubmitMessage (
   Status = CommonMctpSubmitMessage (
              mTransportToken,
              MctpType,
-             MctpSourceEndpointId,
-             MctpDestinationEndpointId,
+             SourceEid,
+             DestinationEid,
              RequestDataIntegrityCheck,
              RequestData,
              RequestDataSize,
-- 
2.34.1



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



  parent reply	other threads:[~2023-10-16 13:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-16 13:18 [edk2-devel] [PATCH edk2-platforms 00/10] MTCP-over-KCS support Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 01/10] ManageabilityPkg: Add definition for the MCTP KCS TRAILER structure Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 02/10] ManageabilityPkg: Check MCTP EIDs for reserved values Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 03/10] ManageabilityPkg: Support both MCTP and IPMI in KCS tranport library Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 04/10] ManageabilityPkg: Check header fields in the MCTP response Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 05/10] ManageabilityPkg: Correct typo in MCTP destination EID field Konstantin Aladyshev
2023-10-16 13:18 ` Konstantin Aladyshev [this message]
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 07/10] ManageabilityPkg: Correct value for the MCTP TAG_OWNER response bit Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 08/10] ManageabilityPkg: Don't check MCTP header fields if transfer has failed Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 09/10] ManageabilityPkg: Use correct constants for PLDM header checks Konstantin Aladyshev
2023-10-16 13:18 ` [edk2-devel] [PATCH edk2-platforms 10/10] ManageabilityPkg: Return error on multiple-packet MCTP responses Konstantin Aladyshev
2023-10-18  5:52 ` [edk2-devel] [PATCH edk2-platforms 00/10] MTCP-over-KCS support 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=20231016131816.6634-7-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