public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chang, Abner" <abner.chang@amd.com>
To: <devel@edk2.groups.io>
Cc: Isaac Oram <isaac.w.oram@intel.com>,
	Abdul Lateef Attar <abdattar@amd.com>,
	Nickle Wang <nicklew@nvidia.com>,
	Igor Kulchytskyy <igork@ami.com>
Subject: [edk2-platforms][PATCH 02/14] ManageabilityPkg: Support Maximum Transfer Unit
Date: Mon, 3 Apr 2023 23:04:47 +0800	[thread overview]
Message-ID: <20230403150459.925-3-abner.chang@amd.com> (raw)
In-Reply-To: <20230403150459.925-1-abner.chang@amd.com>

From: Abner Chang <abner.chang@amd.com>

Update GetTransportCapability to support
Maximum Transfer Unit (MTU) of transport interface.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Abdul Lateef Attar <abdattar@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
 .../Library/ManageabilityTransportLib.h       | 31 ++++++++++++++-----
 .../Common/ManageabilityTransportKcs.h        |  2 ++
 .../IpmiProtocol/Pei/IpmiPpiInternal.h        |  8 +++--
 .../BaseManageabilityTransportNull.c          | 18 +++++++----
 .../Dxe/ManageabilityTransportKcs.c           | 25 +++++++++------
 .../Universal/IpmiProtocol/Dxe/IpmiProtocol.c | 20 +++++++++---
 .../Universal/IpmiProtocol/Pei/IpmiPpi.c      | 15 +++++++--
 .../Universal/IpmiProtocol/Smm/IpmiProtocol.c | 21 ++++++++++---
 8 files changed, 103 insertions(+), 37 deletions(-)

diff --git a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
index c022b4ac5c..ad6cd1a464 100644
--- a/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
+++ b/Features/ManageabilityPkg/Include/Library/ManageabilityTransportLib.h
@@ -14,6 +14,9 @@
 #define MANAGEABILITY_TRANSPORT_TOKEN_VERSION        ((MANAGEABILITY_TRANSPORT_TOKEN_VERSION_MAJOR << 8) |\
                                                 MANAGEABILITY_TRANSPORT_TOKEN_VERSION_MINOR)
 
+#define MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(a)  (1 << ((a & MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_MASK) >>\
+           MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_BIT_POSITION))
+
 typedef struct  _MANAGEABILITY_TRANSPORT_FUNCTION_V1_0  MANAGEABILITY_TRANSPORT_FUNCTION_V1_0;
 typedef struct  _MANAGEABILITY_TRANSPORT                MANAGEABILITY_TRANSPORT;
 typedef struct  _MANAGEABILITY_TRANSPORT_TOKEN          MANAGEABILITY_TRANSPORT_TOKEN;
@@ -68,8 +71,17 @@ typedef UINT32 MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS;
 /// Additional transport interface features.
 ///
 typedef UINT32 MANAGEABILITY_TRANSPORT_CAPABILITY;
+/// Bit 0
 #define MANAGEABILITY_TRANSPORT_CAPABILITY_MULTIPLE_TRANSFER_TOKENS  0x00000001
+/// Bit 1
 #define MANAGEABILITY_TRANSPORT_CAPABILITY_ASYNCHRONOUS_TRANSFER     0x00000002
+/// Bit 2   - Reserved
+/// Bit 7:3 - Transport interface maximum payload size, which is (2 ^ bit[7:3] - 1)
+///           bit[7:3] means no maximum payload.
+#define MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_MASK          0x000000f8
+#define MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_BIT_POSITION  3
+  #define MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE  0x00
+/// Bit 8:31 - Reserved
 
 ///
 /// Definitions of Manageability transport interface functions.
@@ -187,15 +199,20 @@ AcquireTransportSession (
   );
 
 /**
-  This function returns the transport capabilities.
-
-  @param [out]  TransportFeature        Pointer to receive transport capabilities.
-                                        See the definitions of
-                                        MANAGEABILITY_TRANSPORT_CAPABILITY.
-
+  This function returns the transport capabilities according to
+  the manageability protocol.
+
+  @param [in]   TransportToken             Transport token acquired from manageability
+                                           transport library.
+  @param [out]  TransportFeature           Pointer to receive transport capabilities.
+                                           See the definitions of
+                                           MANAGEABILITY_TRANSPORT_CAPABILITY.
+  @retval       EFI_SUCCESS                TransportCapability is returned successfully.
+  @retval       EFI_INVALID_PARAMETER      TransportToken is not a valid token.
 **/
-VOID
+EFI_STATUS
 GetTransportCapability (
+  IN MANAGEABILITY_TRANSPORT_TOKEN        *TransportToken,
   OUT MANAGEABILITY_TRANSPORT_CAPABILITY  *TransportCapability
   );
 
diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h
index f1758ffd8f..2cdf60ba7e 100644
--- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h
+++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h
@@ -32,6 +32,8 @@ typedef struct {
 #define IPMI_KCS_GET_STATE(s)  (s >> 6)
 #define IPMI_KCS_SET_STATE(s)  (s << 6)
 
+#define MCTP_KCS_MTU_IN_POWER_OF_2  8
+
 /// 5 sec, according to IPMI spec
 #define IPMI_KCS_TIMEOUT_5_SEC  5000*1000
 #define IPMI_KCS_TIMEOUT_1MS    1000
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h
index bbe0c8c5cb..7b6ab0f529 100644
--- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpiInternal.h
@@ -17,9 +17,11 @@
 #define MANAGEABILITY_IPMI_PPI_INTERNAL_FROM_LINK(a)  CR (a, PEI_IPMI_PPI_INTERNAL, PeiIpmiPpi, MANAGEABILITY_IPMI_PPI_INTERNAL_SIGNATURE)
 
 typedef struct {
-  UINT32                         Signature;
-  MANAGEABILITY_TRANSPORT_TOKEN  *TransportToken;
-  PEI_IPMI_PPI                   PeiIpmiPpi;
+  UINT32                              Signature;
+  MANAGEABILITY_TRANSPORT_TOKEN       *TransportToken;
+  MANAGEABILITY_TRANSPORT_CAPABILITY  TransportCapability;
+  UINT32                              TransportMaximumPayload;
+  PEI_IPMI_PPI                        PeiIpmiPpi;
 } PEI_IPMI_PPI_INTERNAL;
 
 #endif // MANAGEABILITY_IPMI_PPI_INTERNAL_H_
diff --git a/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c b/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c
index 49fc8c0f71..3aa68578a6 100644
--- a/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c
+++ b/Features/ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.c
@@ -31,19 +31,25 @@ AcquireTransportSession (
 }
 
 /**
-  This function returns the transport capabilities.
-
-  @param [out]  TransportFeature        Pointer to receive transport capabilities.
-                                        See the definitions of
-                                        MANAGEABILITY_TRANSPORT_CAPABILITY.
+  This function returns the transport capabilities according to
+  the manageability protocol.
 
+  @param [in]   TransportToken             Transport token acquired from manageability
+                                           transport library.
+  @param [out]  TransportFeature           Pointer to receive transport capabilities.
+                                           See the definitions of
+                                           MANAGEABILITY_TRANSPORT_CAPABILITY.
+  @retval       EFI_SUCCESS                TransportCapability is returned successfully.
+  @retval       EFI_INVALID_PARAMETER      TransportToken is not a valid token.
 **/
-VOID
+EFI_STATUS
 GetTransportCapability (
+  IN MANAGEABILITY_TRANSPORT_TOKEN        *TransportToken,
   OUT MANAGEABILITY_TRANSPORT_CAPABILITY  *TransportCapability
   )
 {
   *TransportCapability = 0;
+  return EFI_SUCCESS;
 }
 
 /**
diff --git a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c
index ab416e5449..25d6e49886 100644
--- a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c
+++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c
@@ -329,21 +329,28 @@ AcquireTransportSession (
 }
 
 /**
-  This function returns the transport capabilities.
-
-  @param [out]  TransportFeature        Pointer to receive transport capabilities.
-                                        See the definitions of
-                                        MANAGEABILITY_TRANSPORT_CAPABILITY.
-
+  This function returns the transport capabilities according to
+  the manageability protocol.
+
+  @param [in]   TransportToken             Transport token acquired from manageability
+                                           transport library.
+  @param [out]  TransportFeature           Pointer to receive transport capabilities.
+                                           See the definitions of
+                                           MANAGEABILITY_TRANSPORT_CAPABILITY.
+  @retval       EFI_SUCCESS                TransportCapability is returned successfully.
+  @retval       EFI_INVALID_PARAMETER      TransportToken is not a valid token.
 **/
-VOID
+EFI_STATUS
 GetTransportCapability (
+  IN MANAGEABILITY_TRANSPORT_TOKEN        *TransportToken,
   OUT MANAGEABILITY_TRANSPORT_CAPABILITY  *TransportCapability
   )
 {
-  if (TransportCapability != NULL) {
-    *TransportCapability = 0;
+  if (TransportToken == NULL || TransportCapability == NULL) {
+    return EFI_INVALID_PARAMETER;
   }
+  *TransportCapability = 0;
+  return EFI_SUCCESS;
 }
 
 /**
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c
index 05175ee448..c30132419d 100644
--- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Dxe/IpmiProtocol.c
@@ -17,9 +17,9 @@
 
 #include "IpmiProtocolCommon.h"
 
-MANAGEABILITY_TRANSPORT_TOKEN  *mTransportToken = NULL;
-CHAR16                         *mTransportName;
-
+MANAGEABILITY_TRANSPORT_TOKEN                 *mTransportToken = NULL;
+CHAR16                                        *mTransportName;
+UINT32                                        TransportMaximumPayload;
 MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION  mHardwareInformation;
 
 /**
@@ -92,8 +92,6 @@ DxeIpmiEntry (
   MANAGEABILITY_TRANSPORT_CAPABILITY         TransportCapability;
   MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  TransportAdditionalStatus;
 
-  GetTransportCapability (&TransportCapability);
-
   Status = HelperAcquireManageabilityTransport (
              &gManageabilityProtocolIpmiGuid,
              &mTransportToken
@@ -102,6 +100,18 @@ DxeIpmiEntry (
     DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for IPMI protocol - %r\n", __FUNCTION__, Status));
     return Status;
   }
+  Status = GetTransportCapability (mTransportToken, &TransportCapability);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to GetTransportCapability().\n", __FUNCTION__));
+    return Status;
+  }
+  TransportMaximumPayload = MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(TransportCapability);
+  if (TransportMaximumPayload == (1 << MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE)) {
+    DEBUG ((DEBUG_INFO, "%a: Transport interface maximum payload is undefined.\n", __FUNCTION__));
+  } else {
+    TransportMaximumPayload -= 1;
+    DEBUG ((DEBUG_INFO, "%a: Transport interface for IPMI protocol has maximum payload %x.\n", __FUNCTION__, TransportMaximumPayload));
+  }
 
   mTransportName = HelperManageabilitySpecName (mTransportToken->Transport->ManageabilityTransportSpecification);
   DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTransportName));
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c
index f839cd7387..0dda6d2d47 100644
--- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Pei/IpmiPpi.c
@@ -87,7 +87,6 @@ PeiIpmiEntry (
   CHAR16                                        *TransportName;
   PEI_IPMI_PPI_INTERNAL                         *PeiIpmiPpiinternal;
   EFI_PEI_PPI_DESCRIPTOR                        *PpiDescriptor;
-  MANAGEABILITY_TRANSPORT_CAPABILITY            TransportCapability;
   MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS     TransportAdditionalStatus;
   MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION  HardwareInformation;
 
@@ -109,7 +108,6 @@ PeiIpmiEntry (
   PpiDescriptor->Guid  = &gPeiIpmiPpiGuid;
   PpiDescriptor->Ppi   = &PeiIpmiPpiinternal->PeiIpmiPpi;
 
-  GetTransportCapability (&TransportCapability);
   Status = HelperAcquireManageabilityTransport (
              &gManageabilityProtocolIpmiGuid,
              &PeiIpmiPpiinternal->TransportToken
@@ -118,6 +116,19 @@ PeiIpmiEntry (
     DEBUG ((DEBUG_ERROR, "%a: Failed to acquire transport interface for IPMI protocol - %r\n", __FUNCTION__, Status));
     return Status;
   }
+  Status = GetTransportCapability (PeiIpmiPpiinternal->TransportToken, &PeiIpmiPpiinternal->TransportCapability);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to GetTransportCapability().\n", __FUNCTION__));
+    return Status;
+  }
+
+  PeiIpmiPpiinternal->TransportMaximumPayload = MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(PeiIpmiPpiinternal->TransportCapability);
+  if (PeiIpmiPpiinternal->TransportMaximumPayload  == (1 << MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE)) {
+    DEBUG((DEBUG_INFO, "%a: Transport interface maximum payload is undefined.\n", __FUNCTION__));
+  } else {
+    PeiIpmiPpiinternal->TransportMaximumPayload -= 1;
+    DEBUG((DEBUG_INFO, "%a: Transport interface for IPMI protocol has maximum payload 0x%x.\n", __FUNCTION__, PeiIpmiPpiinternal->TransportMaximumPayload));
+  }
 
   TransportName = HelperManageabilitySpecName (PeiIpmiPpiinternal->TransportToken->Transport->ManageabilityTransportSpecification);
   DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, TransportName));
diff --git a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c
index 87a5436bdf..86dee2fa24 100644
--- a/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c
+++ b/Features/ManageabilityPkg/Universal/IpmiProtocol/Smm/IpmiProtocol.c
@@ -18,9 +18,9 @@
 
 #include "IpmiProtocolCommon.h"
 
-MANAGEABILITY_TRANSPORT_TOKEN  *mTransportToken = NULL;
-CHAR16                         *mTransportName;
-
+MANAGEABILITY_TRANSPORT_TOKEN                 *mTransportToken = NULL;
+CHAR16                                        *mTransportName;
+UINT32                                        TransportMaximumPayload;
 MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION  mHardwareInformation;
 
 /**
@@ -93,8 +93,6 @@ SmmIpmiEntry (
   MANAGEABILITY_TRANSPORT_CAPABILITY         TransportCapability;
   MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  TransportAdditionalStatus;
 
-  GetTransportCapability (&TransportCapability);
-
   Status = HelperAcquireManageabilityTransport (
              &gManageabilityProtocolIpmiGuid,
              &mTransportToken
@@ -104,6 +102,19 @@ SmmIpmiEntry (
     return Status;
   }
 
+  Status = GetTransportCapability (mTransportToken, &TransportCapability);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Failed to GetTransportCapability().\n", __FUNCTION__));
+    return Status;
+  }
+  TransportMaximumPayload = MANAGEABILITY_TRANSPORT_PAYLOAD_SIZE_FROM_CAPABILITY(TransportCapability);
+  if (TransportMaximumPayload == (1 << MANAGEABILITY_TRANSPORT_CAPABILITY_MAXIMUM_PAYLOAD_NOT_AVAILABLE)) {
+    DEBUG((DEBUG_INFO, "%a: Transport interface maximum payload is undefined.\n", __FUNCTION__));
+  } else {
+    TransportMaximumPayload -= 1;
+    DEBUG((DEBUG_INFO, "%a: Transport interface for IPMI protocol has maximum payload 0x%x.\n", __FUNCTION__, TransportMaximumPayload));
+  }
+
   mTransportName = HelperManageabilitySpecName (mTransportToken->Transport->ManageabilityTransportSpecification);
   DEBUG ((DEBUG_INFO, "%a: IPMI protocol over %s.\n", __FUNCTION__, mTransportName));
 
-- 
2.37.1.windows.1


  parent reply	other threads:[~2023-04-03 15:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 15:04 [edk2-platforms][PATCH 00/14] ManageabilityPkg part II Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 01/14] ManageabilityPkg: Add more helper functions Chang, Abner
2023-04-10 17:23   ` [edk2-devel] " Tinh Nguyen
2023-04-11  5:29     ` Chang, Abner
2023-04-03 15:04 ` Chang, Abner [this message]
2023-04-03 15:04 ` [edk2-platforms][PATCH 03/14] ManageabilityPkg: Fix Uncrustify errors Chang, Abner
2023-04-10 17:25   ` [edk2-devel] " Tinh Nguyen
2023-04-11  5:31     ` Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 04/14] ManageabilityPkg: Add HeaderSize and TrailerSize Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 05/14] ManageabilityPkg: Add PldmProtocolLib Chang, Abner
2023-04-11 13:41   ` Nickle Wang
2023-04-03 15:04 ` [edk2-platforms][PATCH 06/14] ManageabilityPkg: Add PldmSmbiosTransferDxe driver Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 07/14] ManageabilityPkg/KCS: KCS transport interface Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 08/14] ManageabilityPkg: Add definitions of MCTP Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 09/14] ManageabilityPkg/MctpProtocol: Add MctpProtocol Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 10/14] ManageabilityPkg: Add MCTP transport interface Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 11/14] ManageabilityPkg/PldmProtocol: Add PLDM protocol Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 12/14] ManageabilityPkg: Add Manageability PCDs Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 13/14] ManageabilityPkg: Relocate Manageability.dsc Chang, Abner
2023-04-10 17:27   ` Tinh Nguyen
2023-04-11  5:55     ` Chang, Abner
2023-04-03 15:04 ` [edk2-platforms][PATCH 14/14] ManageabilityPkg: Add Manageability FDFs Chang, Abner

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=20230403150459.925-3-abner.chang@amd.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