Reviewed-by: Isaac Oram <isaac.w.o...@intel.com>

Multiple instances of typo:  AdditioalStatus       
I think it is ok to fix before push since it is simple search and replace.

-----Original Message-----
From: abner.ch...@amd.com <abner.ch...@amd.com> 
Sent: Tuesday, May 9, 2023 12:56 AM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.o...@intel.com>; Abdul Lateef Attar 
<abdat...@amd.com>; Nickle Wang <nick...@nvidia.com>; Tinh Nguyen 
<tinhngu...@os.amperecomputing.com>
Subject: [edk2-platforms][PATCH 2/2] 
ManageabilityPkg/ManageabilityTransportKcsLib: Add debug message of IPMI KCS 
Completion Code

From: abnchang <abnch...@amd.com>

Print out IPMI Completion Code and return additional transport interface status.

Signed-off-by: Abner Chang <abner.ch...@amd.com>
Cc: Isaac Oram <isaac.w.o...@intel.com>
Cc: Abdul Lateef Attar <abdat...@amd.com>
Cc: Nickle Wang <nick...@nvidia.com>
Cc: Tinh Nguyen <tinhngu...@os.amperecomputing.com>
---
 .../Common/ManageabilityTransportKcs.h        | 18 +++++----
 .../Common/KcsCommon.c                        | 39 +++++++++++++------
 .../Dxe/ManageabilityTransportKcs.c           |  7 +++-
 3 files changed, 42 insertions(+), 22 deletions(-)

diff --git 
a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h
 
b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h
index 8c6a64416a..166aa8dcde 100644
--- 
a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/ManageabilityTransportKcs.h
+++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Com
+++ mon/ManageabilityTransportKcs.h
@@ -51,6 +51,7 @@ typedef struct {
                                         code is the first byte of response
                                         data.
   @param[in, out] ResponseDataSize      Size of Command Response Data.
+  @param[out]     AdditioalStatus       Additional status of this transaction.
 
   @retval         EFI_SUCCESS           The command byte stream was
                                         successfully submit to the device and 
a @@ -71,14 +72,15 @@ typedef struct {  EFI_STATUS  EFIAPI  
KcsTransportSendCommand (
-  IN  MANAGEABILITY_TRANSPORT_HEADER   TransmitHeader OPTIONAL,
-  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
+  IN  MANAGEABILITY_TRANSPORT_HEADER              TransmitHeader OPTIONAL,
+  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,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditioalStatus
   );
 
 /**
diff --git 
a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/KcsCommon.c
 
b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/KcsCommon.c
index a8c6a674c9..84792311be 100644
--- 
a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Common/KcsCommon.c
+++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Com
+++ mon/KcsCommon.c
@@ -392,10 +392,8 @@ KcsTransportRead (
                                         code is the first byte of response
                                         data.
   @param[in, out] ResponseDataSize      Size of Command Response Data.
-                                        When IN, it is the expected data size
-                                        of response data.
-                                        When OUT, it is the data size of 
response
-                                        exactly returned.
+  @param[out]     AdditioalStatus       Additional status of this transaction.
+
   @retval         EFI_SUCCESS           The command byte stream was
                                         successfully submit to the device and a
                                         response was successfully received.
@@ -414,20 +412,22 @@ KcsTransportRead (  EFI_STATUS  EFIAPI  
KcsTransportSendCommand (
-  IN  MANAGEABILITY_TRANSPORT_HEADER   TransmitHeader OPTIONAL,
-  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
+  IN  MANAGEABILITY_TRANSPORT_HEADER              TransmitHeader OPTIONAL,
+  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,
+  OUT  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  *AdditioalStatus
   )
 {
   EFI_STATUS                Status;
   UINT32                    RspHeaderSize;
   IPMI_KCS_RESPONSE_HEADER  RspHeader;
   UINT32                    ExpectedResponseDataSize;
+  CHAR16                    *CompletionCodeStr;
 
   if ((RequestData != NULL) && (RequestDataSize == 0)) {
     DEBUG ((DEBUG_ERROR, "%a: Mismatched values of RequestData and 
RequestDataSize\n", __FUNCTION__)); @@ -439,6 +439,11 @@ 
KcsTransportSendCommand (
     return EFI_INVALID_PARAMETER;
   }
 
+  if (AdditioalStatus == NULL) {
+    DEBUG ((DEBUG_ERROR, "%a: AdditioalStatus is NULL.\n", __func__));
+    return EFI_INVALID_PARAMETER;
+  }
+
   // Print out the request payloads.
   if ((TransmitHeader != NULL) && (TransmitHeaderSize != 0)) {
     HelperManageabilityDebugPrint ((VOID *)TransmitHeader, 
(UINT32)TransmitHeaderSize, "KCS Transmit Header:\n"); @@ -504,6 +509,16 @@ 
KcsTransportSendCommand (
       }
 
       HelperManageabilityDebugPrint ((VOID *)ResponseData, 
(UINT32)*ResponseDataSize, "KCS Response Data:\n");
+
+      // Print Completion Code
+      Status = IpmiHelperCheckCompletionCode (*((UINT8 *)ResponseData), 
&CompletionCodeStr, AdditioalStatus);
+      if (!EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_MANAGEABILITY_INFO, "Cc: %02x %s.\n", *((UINT8 
*)ResponseData), CompletionCodeStr));
+      } else if (Status == EFI_NOT_FOUND) {
+        DEBUG ((DEBUG_MANAGEABILITY_INFO, "Cc: %02x not defined in 
IpmiCompletionCodeMapping or invalid.\n", *((UINT8 *)ResponseData)));
+      }
+    } else {
+      DEBUG ((DEBUG_ERROR, "No response, can't determine Completion 
+ Code.\n"));
     }
   } else {
     *ResponseDataSize = 0;
diff --git 
a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c
 
b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c
index 9175556a26..c2d1ac6b62 100644
--- 
a/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe/ManageabilityTransportKcs.c
+++ b/Features/ManageabilityPkg/Library/ManageabilityTransportKcsLib/Dxe
+++ /ManageabilityTransportKcs.c
@@ -219,7 +219,8 @@ KcsTransportTransmitReceive (
   IN  MANAGEABILITY_TRANSFER_TOKEN   *TransferToken
   )
 {
-  EFI_STATUS  Status;
+  EFI_STATUS                                 Status;
+  MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS  AdditioalStatus;
 
   if ((TransportToken == NULL) || (TransferToken == NULL)) {
     DEBUG ((DEBUG_ERROR, "%a: Invalid transport token or transfer token.\n", 
__FUNCTION__)); @@ -234,11 +235,13 @@ KcsTransportTransmitReceive (
              TransferToken->TransmitPackage.TransmitPayload,
              TransferToken->TransmitPackage.TransmitSizeInByte,
              TransferToken->ReceivePackage.ReceiveBuffer,
-             &TransferToken->ReceivePackage.ReceiveSizeInByte
+             &TransferToken->ReceivePackage.ReceiveSizeInByte,
+             &AdditioalStatus
              );
 
   TransferToken->TransferStatus = Status;
   KcsTransportStatus (TransportToken, 
&TransferToken->TransportAdditionalStatus);
+  TransferToken->TransportAdditionalStatus |= AdditioalStatus;
 }
 
 /**
--
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104443): https://edk2.groups.io/g/devel/message/104443
Mute This Topic: https://groups.io/mt/98779145/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to